From f738949d04680285462068e97523e1c170fac5ac Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期六, 04 三月 2023 14:44:08 +0800
Subject: [PATCH] 工单派发写入节拍工价复制表

---
 VueWebApi/DLL/DAL/ProductionManagementDAL.cs |  109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 109 insertions(+), 0 deletions(-)

diff --git a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
index a4718c2..5eaecd0 100644
--- a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
+++ b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
@@ -508,6 +508,69 @@
         }
         #endregion
 
+        #region[宸ュ崟娲惧彂閫夋嫨宸ヨ壓璺嚎鎴栭�夋嫨鐢熶骇杞﹂棿鏃跺垽鏂粦瀹氭潯浠禲
+        public static ToMessage SelectRouteOrWkshop(string partcode, string routecode, string wkshopcode)
+        {
+            string sql = "";
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                mes.code = "200";
+                mes.Message = "";
+                mes.data = null;
+                //鍒ゆ柇宸ヨ壓璺嚎瀵瑰簲宸ュ簭鏄惁閮芥湁鍏宠仈宸ヤ綔绔�
+                sql = @"select B.step_code,C.eqp_code from TFlw_Rout A
+                        inner join TFlw_Rtdt B on A.code=B.rout_code
+                        left join TFlw_Rteqp C on B.step_code=C.step_code
+                        where A.code=@routecode";
+                dynamicParams.Add("@routecode", routecode);
+                var dtck = DapperHelper.selectdata(sql, dynamicParams);
+                for (int i = 0; i < dtck.Rows.Count; i++)
+                {
+                    if (dtck.Rows[i].IsNull("eqp_code"))
+                    {
+                        mes.code = "300";
+                        mes.count = 0;
+                        mes.Message = "褰撳墠宸ヨ壓璺嚎瀵瑰簲宸ュ簭銆�" + dtck.Rows[i]["step_code"].ToString() + "銆戯紝鏈叧鑱旇澶囷紝璇峰叧鑱旀墍鏈夊伐搴忓搴旇澶�!";
+                        mes.data = null;
+                        return mes;
+                    }
+                }
+                //鍒ゆ柇宸ヨ壓璺嚎瀵瑰簲宸ュ簭鍏宠仈鐨勫伐浣滅珯鏄惁鏈夎缃妭鎷嶅伐浠�
+                sql = @"select AA.step_code,AA.eqp_code,S.unprice  from (
+                        select A.code,B.step_code,C.eqp_code from TFlw_Rout A
+                        inner join TFlw_Rtdt B on A.code=B.rout_code
+                        left join TFlw_Rteqp C on B.step_code=C.step_code
+                        where A.code=@route_code
+                        ) as AA
+                        left join (select * from TPrteEqp_Stad   where materiel_code=@partcode and route_code=@route_code) as S on
+                        AA.code=S.route_code and AA.step_code=S.step_code and AA.eqp_code=S.eqp_code";
+                dynamicParams.Add("@partcode", partcode);
+                dynamicParams.Add("@route_code", routecode);
+                var dtc = DapperHelper.selectdata(sql, dynamicParams);
+                for (int i = 0; i < dtc.Rows.Count; i++)
+                {
+                    if (dtc.Rows[i].IsNull("unprice") || decimal.Parse(dtc.Rows[i]["unprice"].ToString()) == 0)
+                    {
+                        mes.code = "300";
+                        mes.count = 0;
+                        mes.Message = "鑺傛媿宸ヤ环涓細褰撳墠浜у搧銆�" + partcode + "銆戯紝瀵瑰簲宸ヨ壓璺嚎銆�" + routecode + "銆戞湭璁剧疆(鎴栨湭璁剧疆鍏�)鎴栧伐浠峰皬浜庣瓑浜�0!";
+                        mes.data = null;
+                        return mes;
+                    }
+                }
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.Message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
+
         #region[MES宸ュ崟鏂板銆佺紪杈戞彁浜
         public static ToMessage AddUpdateMesOrder(string mesorderstus, string sourceorder, string ordertype, string mesordercode, string partcode, string mesqty, string routecode, string wkshopcode, string planstartdate, string planenddate, string orderlev, string username, string opertype, string is_aps, string bom_id)
         {
@@ -615,6 +678,23 @@
                         }
                     });
 
+                    //鍐欏叆宸ュ崟宸ヨ壓璺嚎宸ュ簭宸ヤ环澶嶅埗琛�
+                    sql = @"insert into TWoPrteEqp_Stad(wo,materiel_code,eqp_code,stand_value,opc_conver,route_code,unprice,eqp_value,cavity_qty,wkspcode,lm_user,lm_date,torg_code,is_delete,step_code)
+                           select distinct @mesordercode as wo,S.materiel_code,S.eqp_code,S.stand_value,S.opc_conver,S.route_code,S.unprice,
+                           S.eqp_value,S.cavity_qty,S.wkspcode,S.lm_user,S.lm_date,S.torg_code,S.is_delete,S.step_code
+                           from TFlw_Rtdt A
+                           inner join TFlw_Rteqp C on A.step_code=C.step_code
+                           inner join (select *   from TPrteEqp_Stad  where materiel_code=@materiel_code and route_code=@routecode) as S on C.step_code=S.step_code and C.eqp_code=S.eqp_code";
+                    list.Add(new
+                    {
+                        str = sql,
+                        parm = new
+                        {
+                            mesordercode = mesordercode,
+                            materiel_code = partcode,
+                            routecode = routecode
+                        }
+                    });
 
                     bool aa = DapperHelper.DoTransaction(list);
                     if (aa)
@@ -708,6 +788,35 @@
                             CreateDate = DateTime.Now.ToString()
                         }
                     });
+
+                    //鍒犻櫎宸ュ崟宸ヨ壓璺嚎宸ュ簭宸ヤ环澶嶅埗琛�
+                    sql = @"delete TWoPrteEqp_Stad where wo=@mesordercode";
+                    list.Add(new
+                    {
+                        str = sql,
+                        parm = new
+                        {
+                            mesordercode = mesordercode
+                        }
+                    });
+                    //鍐欏叆宸ュ崟宸ヨ壓璺嚎宸ュ簭宸ヤ环澶嶅埗琛�
+                    sql = @"insert into TWoPrteEqp_Stad(wo,materiel_code,eqp_code,stand_value,opc_conver,route_code,unprice,eqp_value,cavity_qty,wkspcode,lm_user,lm_date,torg_code,is_delete,step_code)
+                           select distinct @mesordercode as wo,S.materiel_code,S.eqp_code,S.stand_value,S.opc_conver,S.route_code,S.unprice,
+                           S.eqp_value,S.cavity_qty,S.wkspcode,S.lm_user,S.lm_date,S.torg_code,S.is_delete,S.step_code
+                           from TFlw_Rtdt A
+                           inner join TFlw_Rteqp C on A.step_code=C.step_code
+                           inner join (select *   from TPrteEqp_Stad  where materiel_code=@materiel_code and route_code=@routecode) as S on C.step_code=S.step_code and C.eqp_code=S.eqp_code";
+                    list.Add(new
+                    {
+                        str = sql,
+                        parm = new
+                        {
+                            mesordercode = mesordercode,
+                            materiel_code = partcode,
+                            routecode = routecode
+                        }
+                    });
+
                     bool aa = DapperHelper.DoTransaction(list);
                     if (aa)
                     {

--
Gitblit v1.9.3