From ecad98aa74a1284a036572fa364bcc352480149c Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期一, 11 五月 2026 08:01:35 +0800
Subject: [PATCH] 1.车间综合看板接口调整 2.报工记录子表和不良记录表写入报工人员,班组编码 3.修改调整定时任务写入到数据库,并实现消息推送

---
 VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs |  195 ++++++++++++++++++++++++++++++++++--------------
 1 files changed, 139 insertions(+), 56 deletions(-)

diff --git a/VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs b/VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs
index 406fcf0..f69e311 100644
--- a/VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs
+++ b/VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs
@@ -133,7 +133,7 @@
         #endregion
 
         #region[ERP璁㈠崟涓嬭揪]
-        public static ToMessage MarkSaveErpOrder(string erporderid, string sbid, string erpordercode, string saleordercode, string partcode,string deptcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty, string idTopInventory, string TopInventoryCode, string TopInventoryName, string saleOrderDeliveryDate, string paystartdate, string payenddate, string clerkuser, User us)
+        public static ToMessage MarkSaveErpOrder(string erporderid, string sbid, string erpordercode, string saleordercode, string partcode, string deptcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty, string idTopInventory, string TopInventoryCode, string TopInventoryName, string saleOrderDeliveryDate, string paystartdate, string payenddate, string clerkuser, User us)
         {
             var sql = "";
             string orderstatus = "", isstep = ""; //宸ュ崟鐘舵�併�佹槸鍚︾粦瀹氬伐鑹�
@@ -230,7 +230,7 @@
                                 wo_code = wo,
                                 wotype = "PO",
                                 status = orderstatus,  //"NEW"
-                                dept_code= deptcode,
+                                dept_code = deptcode,
                                 wkshp_code = wkshopcode,
                                 plan_qty = cdqty + (decimal.Parse(markqty) - sumqty),  //鏈崟涓嬪崟鏁伴噺=鍒囧垎鏁伴噺+(涓嬪崟鏁伴噺-绱鍒囧垎涓嬪崟鏁伴噺)
                                 stck_code = warehousecode,
@@ -298,7 +298,7 @@
                                 wo_code = wo,
                                 wotype = "PO",
                                 status = orderstatus, //"NEW"
-                                dept_code=deptcode,
+                                dept_code = deptcode,
                                 wkshp_code = wkshopcode,
                                 plan_qty = cdqty,
                                 stck_code = warehousecode,
@@ -500,13 +500,13 @@
                                 wo_code = wo,
                                 wotype = "PO",
                                 status = orderstatus, //"NEW"
-                                dept_code=model.deptcode,
+                                dept_code = model.deptcode,
                                 wkshp_code = model.wkshopcode,
                                 plan_qty = decimal.Parse(model.erpqty),  //璁㈠崟鏁伴噺
                                 stck_code = model.warehousecode,
                                 sbid = model.sbid,
                                 materiel_code = model.partcode,
-                                route_code=data0.Rows.Count<=0?"": data0.Rows[0]["default_route"].ToString(),
+                                route_code = data0.Rows.Count <= 0 ? "" : data0.Rows[0]["default_route"].ToString(),
                                 sourceid = model.erporderid,
                                 m_po = model.erpordercode,
                                 username = us.usercode,
@@ -518,7 +518,7 @@
                                 data_sources = "ERP",
                                 isstep = isstep,  //鏄惁鍏宠仈宸ュ簭 "N"
                                 clerkuser = model.clerkuser, //閿�鍞鍗曚笟鍔″憳
-                                idTopInventory =model.idTopInventory,
+                                idTopInventory = model.idTopInventory,
                                 TopInventoryCode = model.TopInventoryCode,
                                 TopInventoryName = model.TopInventoryName
                             }
@@ -540,7 +540,7 @@
                                         seq = data0.Rows[i]["seq"].ToString(),
                                         step_code = data0.Rows[i]["step_code"].ToString(),
                                         route_code = data0.Rows[i]["default_route"].ToString(),
-                                        stepprice = decimal.Parse(data0.Rows[i]["unprice"].ToString()==""|| data0.Rows[i]["unprice"].ToString() ==null? "0":data0.Rows[i]["unprice"].ToString()),
+                                        stepprice = decimal.Parse(data0.Rows[i]["unprice"].ToString() == "" || data0.Rows[i]["unprice"].ToString() == null ? "0" : data0.Rows[i]["unprice"].ToString()),
                                         plan_quantity = decimal.Parse(model.erpqty),  //璁㈠崟鏁伴噺
                                         plan_qty = decimal.Parse(model.erpqty),  //璁㈠崟鏁伴噺
                                         ratio = 0,
@@ -931,7 +931,7 @@
                 var total = 0; //鎬绘潯鏁�
                 var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.idTopInventory,A.TopInventoryCode,A.TopInventoryName,A.route_code,B.default_route,R.name as route_name,A.plan_qty,A.wkshp_code,C.torg_name as wkshp_name,
                             A.stck_code,D.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,A.saleOrderDeliveryDate,A.saleOrderCode,U.username as lm_user,A.lm_date,A.data_sources,A.isstep,A.clerkuser,
-                            B.priuserdefnvc1,B.priuserdefnvc2,B.priuserdefnvc3,B.priuserdefnvc4,B.priuserdefnvc5,B.priuserdefnvc6,A.printcount
+                            B.priuserdefnvc1,B.priuserdefnvc2,B.priuserdefnvc3,B.priuserdefnvc4,B.priuserdefnvc5,B.priuserdefnvc6,A.printcount,W.memo,W.bomsubspec
                             from TK_Wrk_Man A
                             left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code and A.sbid=W.sbid
                             left join TMateriel_Info B on A.materiel_code=B.partcode
@@ -1019,7 +1019,7 @@
                 var total = 0; //鎬绘潯鏁�
                 var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.idTopInventory,A.TopInventoryCode,A.TopInventoryName,A.plan_qty,A.wkshp_code,C.torg_name as wkshp_name,
                             A.stck_code,D.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,A.saleOrderDeliveryDate,W.saleOrderCode,U.username as lm_user,A.lm_date,S.laborbad_qty,S.materielbad_qty,
-                            B.priuserdefnvc1,B.priuserdefnvc2,B.priuserdefnvc3,B.priuserdefnvc4,B.priuserdefnvc5,B.priuserdefnvc6
+                            B.priuserdefnvc1,B.priuserdefnvc2,B.priuserdefnvc3,B.priuserdefnvc4,B.priuserdefnvc5,B.priuserdefnvc6,W.memo,W.bomsubspec
                             from TK_Wrk_Man A
                             left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code and A.sbid=W.sbid
                             left join (select wo_code,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty from  TK_Wrk_Step where (laborbad_qty+materielbad_qty)>0 group by wo_code) S on A.wo_code=S.wo_code
@@ -1178,7 +1178,7 @@
                             materiel_code = json.partcode,
                             route_code = route_code,
                             sourceid = json.sourceid == "" ? null : json.sourceid, //鏃犳簮鍗曟椂璧嬪�糔ULL
-                            saleOrderCode=json.saleordercode,
+                            saleOrderCode = json.saleordercode,
                             m_po = json.sourcewo,
                             saleOrderDeliveryDate = json.deliverydate,
                             plan_startdate = json.paystartdate,
@@ -1206,7 +1206,7 @@
                                 stepprice = json.WorkListSub[i].stepprice,
                                 plan_quantity = json.woqty,
                                 plan_qty = json.WorkListSub[i].sumqty,
-                                ratio=json.WorkListSub[i].ratio,
+                                ratio = json.WorkListSub[i].ratio,
                                 status = json.wostatus,
                                 isbott = json.WorkListSub[i].isbott,
                                 isend = json.WorkListSub[i].isend,
@@ -1288,7 +1288,7 @@
                                 stepprice = json.WorkListSub[i].stepprice,
                                 plan_quantity = json.woqty,
                                 plan_qty = json.WorkListSub[i].sumqty,
-                                ratio=json.WorkListSub[i].ratio,
+                                ratio = json.WorkListSub[i].ratio,
                                 status = json.wostatus,
                                 isbott = json.WorkListSub[i].isbott,
                                 isend = json.WorkListSub[i].isend,
@@ -1382,7 +1382,7 @@
 
                     if (worksteplist[i].data_sources == "ERP")  //鏁版嵁鏉ユ簮ERP
                     {
-                       
+
                         //鏌ヨ褰撳墠宸ュ崟鍙慨鏀规暟閲�=璁㈠崟鎬绘暟-宸蹭笅杈惧伐鍗曟�绘暟
                         sql = @"select isnull(plan_qty,0) as plan_qty   from TK_Wrk_Man 
                             where sourceid=@sourceid and m_po=@sourcewo and wo_code=@wocode";
@@ -1421,7 +1421,7 @@
 
                     // 鍚戝瓧鍏镐腑娣诲姞鏁版嵁
                     dict.Add("canupdate_qty", canupdate_qty);
-                    dict.Add("stepdata", data1); 
+                    dict.Add("stepdata", data1);
                     // 灏嗗瓧鍏告坊鍔犲埌鍒楄〃涓�
                     dir.Add(dict);
                     mes.code = "200";
@@ -1478,7 +1478,7 @@
                                 materiel_code = json[i].partcode,
                                 route_code = route_code,
                                 sourceid = json[i].sourceid == "" ? null : json[i].sourceid, //鏃犳簮鍗曟椂璧嬪�糔ULL
-                                saleOrderCode=json[i].saleordercode,
+                                saleOrderCode = json[i].saleordercode,
                                 m_po = json[i].sourcewo,
                                 saleOrderDeliveryDate = json[i].deliverydate,
                                 plan_startdate = json[i].paystartdate,
@@ -1506,7 +1506,7 @@
                                     stepprice = json[i].WorkListSub[j].stepprice,
                                     plan_quantity = json[i].woqty,
                                     plan_qty = json[i].WorkListSub[j].sumqty,
-                                    ratio=json[i].WorkListSub[j].ratio,
+                                    ratio = json[i].WorkListSub[j].ratio,
                                     status = json[i].wostatus,
                                     isbott = json[i].WorkListSub[j].isbott,
                                     isend = json[i].WorkListSub[j].isend,
@@ -1555,7 +1555,7 @@
                                 materiel_code = json[i].partcode,
                                 route_code = route_code,
                                 sourceid = json[i].sourceid == "" ? null : json[i].sourceid, //鏃犳簮鍗曟椂璧嬪�糔ULL
-                                saleOrderCode=json[i].saleordercode,
+                                saleOrderCode = json[i].saleordercode,
                                 m_po = json[i].sourcewo,
                                 saleOrderDeliveryDate = json[i].deliverydate,
                                 plan_startdate = json[i].paystartdate,
@@ -1592,7 +1592,7 @@
                                     stepprice = json[i].WorkListSub[j].stepprice,
                                     plan_quantity = json[i].woqty,
                                     plan_qty = json[i].WorkListSub[j].sumqty,
-                                    ratio=json[i].WorkListSub[j].ratio,
+                                    ratio = json[i].WorkListSub[j].ratio,
                                     status = json[i].wostatus,
                                     isbott = json[i].WorkListSub[j].isbott,
                                     isend = json[i].WorkListSub[j].isend,
@@ -1856,6 +1856,82 @@
         }
         #endregion
 
+        #region[MES宸ュ崟鎵归噺鏌ユ壘鍘嗗彶寮曠敤鏈�鏂板伐搴忎俊鎭痌
+        public static ToMessage MesOrderNewStepListContent(List<BatchProcess> list, User us)
+        {
+            var sql = "";
+            List<Dictionary<object, object>> dir = new List<Dictionary<object, object>>();
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                dynamic dynObj = JObject.Parse(us.mesSetting);
+                bool route = dynObj.route;
+                for (int i = 0; i < list.Count; i++)
+                {
+                    if (route) //宸ヨ壓璺嚎鐗�
+                    {
+                        Dictionary<object, object> dict = new Dictionary<object, object>();
+                        //MES宸ュ崟鏌ユ壘鍘嗗彶寮曠敤鏈�鏂板伐搴忎俊鎭�
+                        sql = @"select S.wo_code,S.seq,S.step_code as stepcode,T.stepname as stepname,S.stepprice,S.isbott,S.isend,S.ratio
+                        from TK_Wrk_Step S
+                        inner join (
+                        select top 1 A.wo_code,A.route_code   from TK_Wrk_Man A
+                        inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.route_code=S.route_code
+                        where A.materiel_code=@partcode and A.wkshp_code=@wkshopcode and A.route_code=@routecode
+                        order by A.lm_date desc
+                        ) as W on S.wo_code=W.wo_code and S.route_code=W.route_code
+                        left join TStep  T on S.step_code=T.stepcode
+                        order by S.seq";
+                        dynamicParams.Add("@wkshopcode", list[i].wkshopcode);
+                        dynamicParams.Add("@partcode", list[i].partcode);
+                        dynamicParams.Add("@routecode", list[i].routecode);
+                        var data = DapperHelper.selectdata(sql, dynamicParams);
+                        // 鍚戝瓧鍏镐腑娣诲姞鏁版嵁
+                        dict.Add("partcode", list[i].partcode);
+                        dict.Add("stepdata", data);
+                        // 灏嗗瓧鍏告坊鍔犲埌鍒楄〃涓�
+                        dir.Add(dict);
+                    }
+                    else
+                    {
+                        Dictionary<object, object> dict = new Dictionary<object, object>();
+                        //MES宸ュ崟鏌ユ壘鍘嗗彶寮曠敤鏈�鏂板伐搴忎俊鎭�
+                        sql = @"select S.wo_code,S.seq,S.step_code as stepcode,T.stepname as stepname,S.stepprice,S.isbott,S.isend,S.ratio
+                        from TK_Wrk_Step S
+                        inner join (
+                        select top 1 A.wo_code   from TK_Wrk_Man A
+                        inner join TK_Wrk_Step S on A.wo_code=S.wo_code
+                        where A.materiel_code=@partcode and A.wkshp_code=@wkshopcode
+                        order by A.lm_date desc
+                        ) as W on S.wo_code=W.wo_code
+                        left join TStep  T on S.step_code=T.stepcode
+                        order by S.seq";
+                        dynamicParams.Add("@wkshopcode", list[i].wkshopcode);
+                        dynamicParams.Add("@partcode", list[i].partcode);
+                        var data = DapperHelper.selectdata(sql, dynamicParams);
+                        // 鍚戝瓧鍏镐腑娣诲姞鏁版嵁
+                        dict.Add("partcode", list[i].partcode);
+                        dict.Add("stepdata", data);
+                        // 灏嗗瓧鍏告坊鍔犲埌鍒楄〃涓�
+                        dir.Add(dict);
+                    }
+                }
+                mes.code = "200";
+                mes.count = dir.Count;
+                mes.data = dir;
+                mes.message = "鏌ヨ鎴愬姛!";
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
+
         #region[MES宸ュ崟鏌ョ湅宸ュ崟SOP]
         public static ToMessage MesOrderSopSearch(string wocode, string materielcode)
         {
@@ -1958,8 +2034,8 @@
                     {
                         wocode = wocodelist,
                         status = "ALLO",
-                        distributionuser=us.usercode,
-                        distributiontime= DateTime.Now.ToString()
+                        distributionuser = us.usercode,
+                        distributiontime = DateTime.Now.ToString()
                     }
                 });
                 //鏇存柊宸ュ簭浠诲姟琛ㄧ姸鎬�
@@ -2200,7 +2276,7 @@
 
 
         #region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇宸ュ崟瀵瑰簲宸ュ簭浠诲姟(鑷埗)]
-        public static ToMessage MesOrderStepSearch(string wkshopcode, string wocode,string orderno,string saorderno, string partcode, string partname, string partspec, int startNum, int endNum, string prop, string order)
+        public static ToMessage MesOrderStepSearch(string wkshopcode, string wocode, string orderno, string saorderno, string partcode, string partname, string partspec, int startNum, int endNum, string prop, string order)
         {
             var sql = "";
             string search = "";
@@ -2313,7 +2389,7 @@
         #endregion
 
         #region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇宸ュ崟瀵瑰簲宸ュ簭浠诲姟(澶栧崗)]
-        public static ToMessage MesOrderWxStepSearch(string wkshopcode, string wocode, string orderno,string saorderno, string partcode, string partname, string partspec, int startNum, int endNum, string prop, string order)
+        public static ToMessage MesOrderWxStepSearch(string wkshopcode, string wocode, string orderno, string saorderno, string partcode, string partname, string partspec, int startNum, int endNum, string prop, string order)
         {
             var sql = "";
             string search = "";
@@ -2429,7 +2505,7 @@
         #endregion
 
         #region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇宸ュ崟瀵瑰簲宸ュ簭浠诲姟(涓嶈壇)]
-        public static ToMessage MesOrderNgStepSearch(string wkshopcode, string wocode, string orderno,string saorderno, string partcode, string partname, string partspec, int startNum, int endNum, string prop, string order)
+        public static ToMessage MesOrderNgStepSearch(string wkshopcode, string wocode, string orderno, string saorderno, string partcode, string partname, string partspec, int startNum, int endNum, string prop, string order)
         {
             var sql = "";
             string search = "";
@@ -2571,7 +2647,7 @@
                     rt.stepname = data.Rows[0]["stepname"].ToString(); //宸ュ簭鍚嶇О
                     rt.stepdesc = data.Rows[0]["descr"].ToString(); //宸ュ簭鎻忚堪
                     rt.planqty = decimal.Parse(data.Rows[0]["plan_qty"].ToString()); //浠诲姟瓒呬骇鎬绘暟閲�
-                    rt.planquantity= decimal.Parse(data.Rows[0]["plan_quantity"].ToString()); //浠诲姟鏁伴噺
+                    rt.planquantity = decimal.Parse(data.Rows[0]["plan_quantity"].ToString()); //浠诲姟鏁伴噺
                     rt.noreportqty = decimal.Parse(data.Rows[0]["good_qty"].ToString()); //鎶ュ伐鏁伴噺
                     rt.noputqty = decimal.Parse(data.Rows[0]["ng_qty"].ToString()); //涓嶈壇鏁伴噺
                     string isend = data.Rows[0]["isend"].ToString();//鏈亾宸ュ簭
@@ -2665,7 +2741,7 @@
                         else //涓嶆寜搴忔敹鍙戞枡
                         {
                             mes = ScanStartReport.NoWXEncodingSeach(SelectType, wocode, stepcode);
-                        } 
+                        }
                         break;
                     default:
                         break;
@@ -2683,7 +2759,7 @@
         #endregion
 
         #region[鐢熶骇寮�鎶ュ伐,鎶ュ伐鎻愪氦]
-        public static ToMessage SavaMesOrderStepReport(string mesordercode, string partcode, string stepseq, string stepcode, string stepprice, string eqpcode, string inbarcode, string reckway, string usergroupcode, string reportuser,string payrate, string taskqty, string startqty, string reportqty, List<ReportDefectList> defectobjs, string remarks, User us)
+        public static ToMessage SavaMesOrderStepReport(string mesordercode, string partcode, string stepseq, string stepcode, string stepprice, string eqpcode, string inbarcode, string reckway, string usergroupcode, string reportuser, string payrate, string taskqty, string startqty, string reportqty, List<ReportDefectList> defectobjs, string remarks, User us)
         {
             var sql = "";
             decimal ngqty = 0;
@@ -2789,7 +2865,7 @@
                         {
                             m_id = int.Parse(dt.Rows[0]["ID"].ToString()),
                             eqp_code = eqpcode,
-                            payrate= payrate,
+                            payrate = payrate,
                             report_person = reportuser,
                             report_date = date,
                             report_qty = reportqty,
@@ -2807,9 +2883,9 @@
                         //鍐欏叆缂洪櫡璁板綍琛�
                         for (int i = 0; i < groupedItems.Count; i++)
                         {
-                            sql = @"insert into  CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,remarks,style,lm_user,lm_date) 
-                                values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@remarks,@style,@lm_user,@lm_date)";
-                            list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, remarks = remarks, style = "B", lm_user = us.usercode, lm_date = date } });
+                            sql = @"insert into  CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,report_person,usergroup_code,remarks,style,lm_user,lm_date) 
+                                values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@report_person,@usergroup_code,@remarks,@style,@lm_user,@lm_date)";
+                            list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code,report_person=reportuser,usergroup_code= usergroupcode, remarks = remarks, style = "B", lm_user = us.usercode, lm_date = date } });
 
                         }
                     }
@@ -2834,7 +2910,7 @@
                         {
                             m_id = int.Parse(dt.Rows[0]["ID"].ToString()),
                             eqp_code = eqpcode,
-                            payrate= payrate,
+                            payrate = payrate,
                             report_person = reportuser,
                             report_date = date,
                             report_qty = reportqty,
@@ -2852,9 +2928,9 @@
                         //鍐欏叆缂洪櫡璁板綍琛�
                         for (int i = 0; i < groupedItems.Count; i++)
                         {
-                            sql = @"insert into  CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,remarks,style,lm_user,lm_date) 
-                                values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@remarks,@style,@lm_user,@lm_date)";
-                            list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, remarks = remarks, style = "B", lm_user = us.usercode, lm_date = date } });
+                            sql = @"insert into  CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,report_person,usergroup_code,remarks,style,lm_user,lm_date) 
+                                values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@report_person,@usergroup_code,@remarks,@style,@lm_user,@lm_date)";
+                            list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, report_person=reportuser, usergroup_code =usergroupcode, remarks = remarks, style = "B", lm_user = us.usercode, lm_date = date } });
 
                         }
                     }
@@ -3084,9 +3160,9 @@
                         //鍐欏叆缂洪櫡璁板綍琛�
                         for (int i = 0; i < groupedItems.Count; i++)
                         {
-                            sql = @"insert into  CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,remarks,style,lm_user,lm_date) 
-                                values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@remarks,@style,@lm_user,@lm_date)";
-                            list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, remarks = remarks, style = "S", lm_user = us.usercode, lm_date = date } });
+                            sql = @"insert into  CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,report_person,remarks,style,lm_user,lm_date) 
+                                values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@report_person,@remarks,@style,@lm_user,@lm_date)";
+                            list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, report_person=inuser, remarks = remarks, style = "S", lm_user = us.usercode, lm_date = date } });
 
                         }
                     }
@@ -3111,9 +3187,9 @@
                         //鍐欏叆缂洪櫡璁板綍琛�
                         for (int i = 0; i < groupedItems.Count; i++)
                         {
-                            sql = @"insert into  CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,remarks,style,lm_user,lm_date) 
-                                values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@remarks,@style,@lm_user,@lm_date)";
-                            list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, remarks = remarks, style = "S", lm_user = us.usercode, lm_date = date } });
+                            sql = @"insert into  CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,report_person,remarks,style,lm_user,lm_date) 
+                                values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@report_person,@remarks,@style,@lm_user,@lm_date)";
+                            list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, report_person=inuser, remarks = remarks, style = "S", lm_user = us.usercode, lm_date = date } });
 
                         }
                     }
@@ -3433,7 +3509,7 @@
 
 
         #region[鐢熶骇鎵ц,鎶ュ伐璋冩暣鏁版嵁鏌ヨ鎺ュ彛]
-        public static ToMessage MesOrderStepVerifySearch(string wkshopcode, string wo_code,string orderno,string saorderno, string partnumber, string partname, string partspec,string stepcode, string reportuser, string reportdateopendate, string reportdateclosedate, int startNum, int endNum, string prop, string order)
+        public static ToMessage MesOrderStepVerifySearch(string wkshopcode, string wo_code, string orderno, string saorderno, string partnumber, string partname, string partspec, string stepcode, string reportuser, string reportdateopendate, string reportdateclosedate, int startNum, int endNum, string prop, string order)
         {
             var dynamicParams = new DynamicParameters();
             string search = "";
@@ -4141,7 +4217,7 @@
                                     }
                                 }
                             }
-                        }  
+                        }
                     }
                 }
                 else //涓嶆寜搴�
@@ -4149,10 +4225,10 @@
                     //鎺у埗閫昏緫锛氬綋鍓嶅伐搴忔姤宸ヨ皟鏁�-> (鏈亾宸ュ簭褰撳墠璋冩暣鍚堟牸鏁�+鏈亾宸ュ簭闈炲綋鍓嶆姤宸ュ悎鏍兼�绘暟)<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟(鍚堟牸+涓嶈壇+鎶ュ簾)   ==涓嶈兘灏忎簬涓嬮亾鎶ュ伐鎬绘暟
                     list.Clear();
                     //鍒ゆ柇褰撳墠宸ュ簭鏄嚜鍒跺伐搴忚繕鏄鍗忓伐搴�
-                    if (json[0].flw_type.ToString() == "Z") 
+                    if (json[0].flw_type.ToString() == "Z")
                     {
-                        
-                       //鏌ヨ褰撳墠鎶ュ伐宸ュ簭闈炴娆℃姤宸ワ細鎬绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�诲伐搴熸暟閲忋�佹�绘枡搴熸暟閲�
+
+                        //鏌ヨ褰撳墠鎶ュ伐宸ュ簭闈炴娆℃姤宸ワ細鎬绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�诲伐搴熸暟閲忋�佹�绘枡搴熸暟閲�
                         sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty   
                                 from TK_Wrk_Record where wo_code=@wo_code and style='B' and id<>@id and step_code=@step_code";
                         dynamicParams.Add("@wo_code", json[0].wo_code);
@@ -4174,7 +4250,7 @@
                             return mes;
                         }
                     }
-                    if (json[0].flw_type.ToString() == "W") 
+                    if (json[0].flw_type.ToString() == "W")
                     {
                         //鑾峰彇褰撳墠宸ュ簭銆佷緵搴斿晢瀵瑰簲鐨勬�诲彂鏂欐暟閲�
                         sql = @"select isnull(sum(fqty),0) as fqty
@@ -4196,7 +4272,7 @@
                         decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString());  //褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ユ�绘暟
                         decimal notthis_laborbad_qty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString());  //褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ュ伐搴熸�绘暟
                         decimal notthis_materielbad_qty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString());  //褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ユ枡搴熸�绘暟
-                       //鑾峰彇褰撳墠鏈亾宸ュ簭鏀舵枡鎬绘暟閲忥細鏈淇敼鏀舵枡鏁伴噺+鏈淇敼涓嶈壇鏁伴噺+鏈淇敼宸ュ簾鏁伴噺+鏈淇敼鎶ュ伐鏂欏簾鏁伴噺+褰撳墠宸ュ簭闈炴湰娆℃敹鏂欐�绘暟+褰撳墠宸ュ簭闈炴湰娆′笉鑹�绘暟+褰撳墠宸ュ簭闈炴湰娆″伐搴熸�绘暟+褰撳墠宸ュ簭闈炴湰娆℃枡搴熸�绘暟
+                                                                                                                    //鑾峰彇褰撳墠鏈亾宸ュ簭鏀舵枡鎬绘暟閲忥細鏈淇敼鏀舵枡鏁伴噺+鏈淇敼涓嶈壇鏁伴噺+鏈淇敼宸ュ簾鏁伴噺+鏈淇敼鎶ュ伐鏂欏簾鏁伴噺+褰撳墠宸ュ簭闈炴湰娆℃敹鏂欐�绘暟+褰撳墠宸ュ簭闈炴湰娆′笉鑹�绘暟+褰撳墠宸ュ簭闈炴湰娆″伐搴熸�绘暟+褰撳墠宸ュ簭闈炴湰娆℃枡搴熸�绘暟
                         decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbad_qty + notthis_materielbad_qty;
                         //鍒ゆ柇褰撳墠宸ュ簭渚涘簲鍟嗘敹鏂欐�绘暟>褰撳墠宸ュ簭渚涘簲鍟嗗搴斿彂鏂欐暟閲�
                         if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString()))
@@ -4217,7 +4293,7 @@
 
                         //鍥炲啓瀵瑰簲鐨勬姤宸ヨ褰曞瓙琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
                         sql = @"update TK_Wrk_RecordSub set report_qty=report_qty+@repair_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty,
-                            updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
+                            report_person=@report_person,usergroup_code=@usergroup_code,updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
                             where  m_id=@m_id and id=@id and style='B'";
                         list.Add(new
                         {
@@ -4231,6 +4307,8 @@
                                 laborbad_qty = this_laborbad_dvalue,
                                 materielbad_qty = this_materielbad_dvalue,
                                 //bad_money = decimal.Parse(json[i].badmoney_dvalue),
+                                report_person = json[0].usercode,
+                                usergroup_code = json[0].groupcode,
                                 updatereportuser = us.usercode,
                                 updatereportdate = date
                             }
@@ -4244,7 +4322,7 @@
                             str = sql,
                             parm = new
                             {
-                                step_price=decimal.Parse(json[0].unprice),
+                                step_price = decimal.Parse(json[0].unprice),
                                 good_qty = decimal.Parse(json[0].report_dvalue),
                                 ng_qty = this_ng_dvalue,
                                 laborbad_qty = this_laborbad_dvalue,
@@ -4277,7 +4355,7 @@
                         {
                             //鍥炲啓涓嶈壇
                             sql = @"update CSR_WorkRecord_Defect set defect_qty=defect_qty+@ng_qty,defect_pendqty=defect_pendqty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty,
-                                updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
+                                report_person=@report_person,usergroup_code=@usergroup_code,updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
                                 where wo_code=@wo_code and step_code=@step_code and id=@ng_id and record_id=@record_id and style='B'";
                             list.Add(new
                             {
@@ -4291,6 +4369,8 @@
                                     step_code = json[0].step_code,
                                     ng_id = int.Parse(json[0].children[i].ng_id),
                                     record_id = json[0].id,
+                                    report_person = json[0].usercode,
+                                    usergroup_code = json[0].groupcode,
                                     updatereportuser = us.usercode,
                                     updatereportdate = date
                                 }
@@ -4319,7 +4399,7 @@
 
                         //鍥炲啓瀵瑰簲鐨勫鍗忚褰曞瓙琛ㄦ敹鏂欐暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
                         sql = @"update TK_Wrk_OutRecordSub set sqty=sqty+@repair_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty,
-                            updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
+                            out_person=@out_person,updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
                             where  m_id=@m_id and id=@id and style='S' and wx_code=@wx_code";
                         list.Add(new
                         {
@@ -4334,6 +4414,7 @@
                                 materielbad_qty = this_materielbad_dvalue,
                                 wx_code = json[0].wxcode,
                                 //bad_money = decimal.Parse(json[i].badmoney_dvalue),
+                                out_person = json[0].usercode,
                                 updatereportuser = us.usercode,
                                 updatereportdate = date
                             }
@@ -4347,7 +4428,7 @@
                             str = sql,
                             parm = new
                             {
-                                step_price=decimal.Parse(json[0].unprice),
+                                step_price = decimal.Parse(json[0].unprice),
                                 good_qty = decimal.Parse(json[0].report_dvalue),
                                 ng_qty = this_ng_dvalue,
                                 laborbad_qty = this_laborbad_dvalue,
@@ -4381,7 +4462,7 @@
                         {
                             //鍥炲啓涓嶈壇
                             sql = @"update CSR_WorkRecord_Defect set defect_qty=defect_qty+@ng_qty,defect_pendqty=defect_pendqty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty,
-                                updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
+                                report_person=@report_person,usergroup_code=@usergroup_code,updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
                                 where wo_code=@wo_code and step_code=@step_code and id=@ng_id and record_id=@record_id and style='S'";
                             list.Add(new
                             {
@@ -4395,6 +4476,8 @@
                                     step_code = json[0].step_code,
                                     ng_id = int.Parse(json[0].children[i].ng_id),
                                     record_id = json[0].id,
+                                    report_person = json[0].usercode,
+                                    usergroup_code = json[0].groupcode,
                                     updatereportuser = us.usercode,
                                     updatereportdate = date
                                 }
@@ -4530,7 +4613,7 @@
                     if (aa)
                     {
                         //鍐欏叆鎿嶄綔璁板綍琛�
-                        LogHelper.DbOperateLog(us.usercode, "鎵归噺淇敼宸ヤ环", "鎶ュ伐ID:" + string.Join(",",json.Select(bp => bp.id).ToArray())+",鎿嶄綔绫诲瀷:"+ string.Join(",", json.Select(bp => bp.type).ToArray()), us.usertype);
+                        LogHelper.DbOperateLog(us.usercode, "鎵归噺淇敼宸ヤ环", "鎶ュ伐ID:" + string.Join(",", json.Select(bp => bp.id).ToArray()) + ",鎿嶄綔绫诲瀷:" + string.Join(",", json.Select(bp => bp.type).ToArray()), us.usertype);
                         mes.code = "200";
                         mes.count = 0;
                         mes.message = "鎿嶄綔鎴愬姛!";
@@ -4544,7 +4627,7 @@
                         mes.data = null;
                     }
                 }
-                else 
+                else
                 {
                     mes.code = "300";
                     mes.count = 0;
@@ -4565,7 +4648,7 @@
 
 
         #region[鐢熶骇鎵ц,鎶ュ伐瀹℃牳鍒楄〃鏁版嵁鏌ヨ鎺ュ彛]
-        public static ToMessage MesOrderStepReportVerifySearch(string reviewstatus, string wkshopcode, string wo_code, string orderno,string saorderno, string partnumber, string partname, string partspec, string stepname, string reportuser, string reportdateopendate, string reportdateclosedate, int startNum, int endNum, string prop, string order)
+        public static ToMessage MesOrderStepReportVerifySearch(string reviewstatus, string wkshopcode, string wo_code, string orderno, string saorderno, string partnumber, string partname, string partspec, string stepname, string reportuser, string reportdateopendate, string reportdateclosedate, int startNum, int endNum, string prop, string order)
         {
             var dynamicParams = new DynamicParameters();
             string search = "";

--
Gitblit v1.9.3