DelMtrlPfExcutor.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 Newtonsoft.Json.Linq;
  17. namespace JLHHJSvr.Excutor
  18. {
  19. internal sealed class DelMtrlPfExcutor : ExcutorBase<CreatMtrlPfRequest, CreatMtrlPfResponse>
  20. {
  21. Dictionary<string, object> replacements = new Dictionary<string, object>();
  22. protected override void ExcuteInternal(CreatMtrlPfRequest request, object state, CreatMtrlPfResponse rslt)
  23. {
  24. var tokendata = BllHelper.GetToken(request.token);
  25. if (tokendata == null)
  26. {
  27. rslt.ErrMsg = "会话已经中断,请重新登录";
  28. return;
  29. }
  30. if (request.mattressid <= 0)
  31. {
  32. rslt.ErrMsg = "床垫id参数为空!";
  33. return;
  34. }
  35. using (var con = new SqlConnection(GlobalVar.ConnectionString))
  36. using (var cmd = con.CreateCommand())
  37. {
  38. con.Open();
  39. var power91 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 91);
  40. if (!power91)
  41. {
  42. throw new LJCommonException("你没有删除清单权限");
  43. }
  44. var mattress = new u_mattress();
  45. if (DbSqlHelper.SelectOne(cmd, "u_mattress", "mattressid = @mattressid", new Dictionary<string, object>() { { "mattressid", request.mattressid } }, mattress, "erp_mtrlid, creatmtrlqd_flag") != 1)
  46. {
  47. rslt.ErrMsg = "床垫报价单匹配失败";
  48. return;
  49. }
  50. if (mattress.erp_mtrlid <= 0)
  51. {
  52. rslt.ErrMsg = "床垫清单还没匹配L1成品";
  53. return;
  54. }
  55. if (mattress.creatmtrlqd_flag == 0)
  56. {
  57. rslt.ErrMsg = "床垫未生成erp清单,不能删除erp清单!";
  58. return;
  59. }
  60. var l1Helper = HelperBase.GetHelper<ERPHelper>(cmd);
  61. l1Helper.context = new HelperBase.Context() { tokendata = tokendata };
  62. l1Helper.CheckLogin();
  63. var l1Req = new JObject()
  64. {
  65. ["token"] = GlobalVar.ERP_TOKEN,
  66. ["mtrlid"] = mattress.erp_mtrlid,
  67. };
  68. var l1Rslt = l1Helper.DoExecute("DelPrdPf", l1Req);
  69. rslt.ErrMsg = $"{l1Rslt.GetValue("ErrMsg")}";
  70. }
  71. }
  72. }
  73. }