DelMtrlPfExcutor.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Linq;
  5. using System.Text;
  6. using DirectService.Tools;
  7. using JLHHJSvr.BLL;
  8. using JLHHJSvr.Com;
  9. using JLHHJSvr.Com.Model;
  10. using JLHHJSvr.Helper;
  11. using JLHHJSvr.LJException;
  12. using JLHHJSvr.LJFramework.Tools;
  13. using JLHHJSvr.Tools;
  14. using LJLib.DAL.SQL;
  15. using LJLib.Net.SPI.Server;
  16. using LJLib.SQLEX;
  17. using Newtonsoft.Json.Linq;
  18. namespace JLHHJSvr.Excutor
  19. {
  20. internal sealed class DelMtrlPfExcutor : ExcutorBase<CreatMtrldefRequest, CreatMtrldefResponse>
  21. {
  22. Dictionary<string, object> replacements = new Dictionary<string, object>();
  23. protected override void ExcuteInternal(CreatMtrldefRequest request, object state, CreatMtrldefResponse rslt)
  24. {
  25. var tokendata = BllHelper.GetToken(request.token);
  26. if (request.list.Count <= 0)
  27. {
  28. rslt.ErrMsg = "床垫id参数为空!";
  29. return;
  30. }
  31. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  32. using (var cmd = con.CreateCommand())
  33. {
  34. con.Open();
  35. var power91 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 91);
  36. if (!power91)
  37. {
  38. throw new LJCommonException("你没有删除清单权限");
  39. }
  40. foreach (var mattressid in request.list)
  41. {
  42. var mattress = new u_mattress();
  43. if (DbSqlHelper.SelectOne(cmd, "u_mattress", "mattressid = @mattressid", new Dictionary<string, object>() { { "mattressid", mattressid } }, mattress, "erp_mtrlid, creatmtrlqd_flag") != 1)
  44. {
  45. rslt.ErrMsg = "床垫报价单匹配失败";
  46. return;
  47. }
  48. if (mattress.erp_mtrlid <= 0)
  49. {
  50. rslt.ErrMsg = "床垫清单还没匹配L1成品";
  51. return;
  52. }
  53. if (mattress.creatmtrlqd_flag == 0)
  54. {
  55. rslt.ErrMsg = "床垫未生成erp清单,不能删除erp清单!";
  56. return;
  57. }
  58. var l1Helper = HelperBase.GetHelper<ERPHelper>(cmd);
  59. l1Helper.context = new HelperBase.Context() { tokendata = tokendata };
  60. l1Helper.CheckLogin();
  61. var l1Req = new JObject()
  62. {
  63. ["token"] = GlobalVar.ERP_TOKEN,
  64. ["mtrlid"] = mattress.erp_mtrlid,
  65. };
  66. var l1Rslt = l1Helper.DoExecute("DelPrdPf", l1Req);
  67. rslt.ErrMsg = $"{l1Rslt.GetValue("ErrMsg")}";
  68. }
  69. }
  70. }
  71. }
  72. }