123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- using System;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Linq;
- using JLHHJSvr.BLL;
- using JLHHJSvr.Com;
- using JLHHJSvr.Com.Model;
- using JLHHJSvr.Helper;
- using JLHHJSvr.LJException;
- using LJLib.DAL.SQL;
- using LJLib.Net.SPI.Server;
- namespace JLHHJSvr.Excutor
- {
- internal sealed class RefreshMattressInterfaceQdExcutor : ExcutorBase<RefreshMattressInterfaceQdRequest, RefreshMattressInterfaceQdResponse>
- {
- protected override void ExcuteInternal(RefreshMattressInterfaceQdRequest request, object state, RefreshMattressInterfaceQdResponse rslt)
- {
- var tokendata = BllHelper.GetToken(request.token);
- if (tokendata == null)
- {
- rslt.ErrMsg = "会话已经中断,请重新登录";
- return;
- }
- if (request.mattressid == null || request.mattressid <= 0)
- {
- rslt.ErrMsg = "床垫id有误,请检查!";
- return;
- }
- using (var con = new SqlConnection(GlobalVar.ConnectionString))
- using (var cmd = con.CreateCommand())
- {
- con.Open();
- var mattress = new u_mattress() { mattressid = request.mattressid.Value };
- DbSqlHelper.SelectOne(cmd, mattress, "js2_flag");
- if (request.isCheck == 1 && mattress.js2_flag == 1)
- {
- throw new LJCommonException("床垫已技术2审核,不能重新生成!");
- }
- var copy_list = new List<u_mattress_interface_qd>();
- var selectStr = @"SELECT u_mattress_interface_qd.mattressid
- ,u_mattress_interface_qd.printid
- ,u_mattress_interface_qd.itemname
- ,u_mattress_interface_qd.bj_pzname
- ,u_mattress_interface_qd.bj_pzname_mx
- ,u_mattress_interface_qd.bj_pzname_mx_mx
- ,u_mattress_interface_qd.mtrlid
- ,u_mattress_interface_qd.erp_mtrlid
- ,u_mattress_interface_qd.useqty
- ,u_mattress_interface_qd.dscrp
- ,u_mtrl_price.name AS mtrlname
- ,u_mattress_interface_qd.actual_useqty
- ,u_mattress_interface_qd.qd_actual_size
- ,u_mattress_interface_qd.qd_pfgroupqty
- ,u_mattress_interface_qd.wrkgrpid
- ,u_mattress_interface_qd.ss_rate
- ,u_mattress_interface_qd.ls_rate
- ,u_mattress_interface_qd.sh_rate
- FROM u_mattress_interface_qd
- LEFT JOIN u_mtrl_price ON u_mtrl_price.mtrlid = u_mattress_interface_qd.mtrlid";
- var outputFields = "mattressid,printid,itemname,bj_pzname,bj_pzname_mx,bj_pzname_mx_mx,mtrlid,erp_mtrlid,useqty,dscrp,mtrlname,actual_useqty,qd_actual_size,qd_pfgroupqty,wrkgrpid,ss_rate,ls_rate,sh_rate";
- DbSqlHelper.SelectJoin(cmd, selectStr, "mattressid = @mattressid", new Dictionary<string, object>() { { "@mattressid", request.mattressid } }, "printid", outputFields, 0, 0, copy_list);
- using (var erp_con = new SqlConnection(BllHelper.GetERPConnectString(cmd)))
- using (var erp_cmd = erp_con.CreateCommand())
- {
- erp_con.Open();
- var interfaceHelper = HelperBase.GetHelper<InterfaceHelper>(cmd, erp_cmd, new HelperBase.Context() { tokendata = tokendata });
- var qdList = interfaceHelper.RefreshMattressInterfaceQdList(request.mattressid.Value);
- if(request.isPz != null && request.isPz == 1)
- {
- var copyDict = new Dictionary<Tuple<string, string, string>, u_mattress_interface_qd>();
- foreach (var mx2 in copy_list)
- {
- var key = Tuple.Create(mx2.itemname, mx2.bj_pzname, mx2.bj_pzname_mx);
- if (!copyDict.ContainsKey(key))
- {
- copyDict[key] = mx2;
- }
- }
- // 遍历qdList
- foreach (var mx in qdList)
- {
- var key = Tuple.Create(mx.itemname, mx.bj_pzname, mx.bj_pzname_mx); // 创建复合键
- if (copyDict.TryGetValue(key, out var mx2)) // 高效查找对应的mx2
- {
- // 更新mx属性
- mx.erp_mtrlid = mx2.erp_mtrlid;
- mx.erp_mtrlcode = mx2.erp_mtrlcode;
- mx.erp_mtrlname = mx2.erp_mtrlname;
- mx.erp_mtrlmode = mx2.erp_mtrlmode;
- mx.erp_unit = mx2.erp_unit;
- mx.useqty = mx2.useqty;
- mx.actual_useqty = mx2.actual_useqty;
- mx.wrkgrpid = mx2.wrkgrpid;
- mx.qd_actual_size = mx2.qd_actual_size;
- mx.qd_pfgroupqty = mx2.qd_pfgroupqty;
- mx.dscrp = mx2.dscrp;
- }
- }
- }
- rslt.mxList = qdList;
- }
- }
- }
- }
- }
|