DelMtrlPfExcutor.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 (tokendata == null)
  27. {
  28. rslt.ErrMsg = "会话已经中断,请重新登录";
  29. return;
  30. }
  31. if (request.list.Count <= 0)
  32. {
  33. rslt.ErrMsg = "床垫id参数为空!";
  34. return;
  35. }
  36. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  37. using (var cmd = con.CreateCommand())
  38. {
  39. con.Open();
  40. var power91 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 91);
  41. if (!power91)
  42. {
  43. throw new LJCommonException("你没有删除清单权限");
  44. }
  45. foreach (var mattressid in request.list)
  46. {
  47. var mattress = new u_mattress();
  48. if (DbSqlHelper.SelectOne(cmd, "u_mattress", "mattressid = @mattressid", new Dictionary<string, object>() { { "mattressid", mattressid } }, mattress, "erp_mtrlid, creatmtrlqd_flag") != 1)
  49. {
  50. rslt.ErrMsg = "床垫报价单匹配失败";
  51. return;
  52. }
  53. if (mattress.erp_mtrlid <= 0)
  54. {
  55. rslt.ErrMsg = "床垫清单还没匹配L1成品";
  56. return;
  57. }
  58. if (mattress.creatmtrlqd_flag == 0)
  59. {
  60. rslt.ErrMsg = "床垫未生成erp清单,不能删除erp清单!";
  61. return;
  62. }
  63. var l1Helper = HelperBase.GetHelper<ERPHelper>(cmd);
  64. l1Helper.context = new HelperBase.Context() { tokendata = tokendata };
  65. l1Helper.CheckLogin();
  66. var l1Req = new JObject()
  67. {
  68. ["token"] = GlobalVar.ERP_TOKEN,
  69. ["mtrlid"] = mattress.erp_mtrlid,
  70. };
  71. var l1Rslt = l1Helper.DoExecute("DelPrdPf", l1Req);
  72. rslt.ErrMsg = $"{l1Rslt.GetValue("ErrMsg")}";
  73. }
  74. }
  75. }
  76. }
  77. }