using System; using System.Collections.Generic; using System.Data.SqlClient; using System.Linq; using System.Text; using DirectService.Tools; using JLHHJSvr.BLL; using JLHHJSvr.Com; using JLHHJSvr.Com.Model; using JLHHJSvr.Helper; using JLHHJSvr.LJException; using JLHHJSvr.LJFramework.Tools; using JLHHJSvr.Tools; using LJLib.DAL.SQL; using LJLib.Net.SPI.Server; using Newtonsoft.Json.Linq; namespace JLHHJSvr.Excutor { internal sealed class DelMtrlPfExcutor : ExcutorBase { Dictionary replacements = new Dictionary(); protected override void ExcuteInternal(CreatMtrlPfRequest request, object state, CreatMtrlPfResponse rslt) { var tokendata = BllHelper.GetToken(request.token); if (tokendata == null) { rslt.ErrMsg = "会话已经中断,请重新登录"; return; } if (request.mattressid <= 0) { rslt.ErrMsg = "床垫id参数为空!"; return; } using (var con = new SqlConnection(GlobalVar.ConnectionString)) using (var cmd = con.CreateCommand()) { con.Open(); var power91 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 91); if (!power91) { throw new LJCommonException("你没有删除清单权限"); } var mattress = new u_mattress(); if (DbSqlHelper.SelectOne(cmd, "u_mattress", "mattressid = @mattressid", new Dictionary() { { "mattressid", request.mattressid } }, mattress, "erp_mtrlid, creatmtrlqd_flag") != 1) { rslt.ErrMsg = "床垫报价单匹配失败"; return; } if (mattress.erp_mtrlid <= 0) { rslt.ErrMsg = "床垫清单还没匹配L1成品"; return; } if (mattress.creatmtrlqd_flag == 0) { rslt.ErrMsg = "床垫未生成erp清单,不能删除erp清单!"; return; } var l1Helper = HelperBase.GetHelper(cmd); l1Helper.context = new HelperBase.Context() { tokendata = tokendata }; l1Helper.CheckLogin(); var l1Req = new JObject() { ["token"] = GlobalVar.ERP_TOKEN, ["mtrlid"] = mattress.erp_mtrlid, }; var l1Rslt = l1Helper.DoExecute("DelPrdPf", l1Req); rslt.ErrMsg = $"{l1Rslt.GetValue("ErrMsg")}"; } } } }