From 376bb6cf439eaa3b2867825fe22a14e381dd9213 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期三, 14 八月 2024 17:55:48 +0800
Subject: [PATCH] 1.新增工序找设备(工位)接口 2.新增物料清单查询、新增、修改接口

---
 VueWebCoreApi/DLL/DAL/BasicSettingDAL.cs |  639 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 576 insertions(+), 63 deletions(-)

diff --git a/VueWebCoreApi/DLL/DAL/BasicSettingDAL.cs b/VueWebCoreApi/DLL/DAL/BasicSettingDAL.cs
index 5ab8f29..4a4638e 100644
--- a/VueWebCoreApi/DLL/DAL/BasicSettingDAL.cs
+++ b/VueWebCoreApi/DLL/DAL/BasicSettingDAL.cs
@@ -249,12 +249,17 @@
 
 
         #region[缁勭粐鏋舵瀯,鏌ヨ缁勭粐淇℃伅]
-        public static ToMessage STorgData(string storg_code, string storg_name)
+        public static ToMessage STorgData(string storg_code, string storg_name,string torgtype_code)
         {
             var dynamicParams = new DynamicParameters();
             string search = "";
             try
             {
+                if (torgtype_code != "" && torgtype_code != null)
+                {
+                    search += "and T.torgtype_code=@torgtype_code ";
+                    dynamicParams.Add("@torgtype_code", torgtype_code);
+                }
                 if (storg_code != "" && storg_code != null)
                 {
                     search += "and T.torg_code like '%'+@storg_code+'%' ";
@@ -265,9 +270,10 @@
                     search += "and T.torg_name like '%'+@storg_name+'%' ";
                     dynamicParams.Add("@storg_name", storg_name);
                 }
-                var sql = @"select T.id,T.parent_id,T.torg_code,T.torg_name,T.status,T.leve,T.torg_seq,
+                var sql = @"select T.id,T.parent_id,T.torg_code,T.torg_name,T.torgtype_code,Y.torgtype_name,T.status,T.leve,T.torg_seq,
                             T.lm_user  as usercode,U.username,T.lm_date  
                             from TOrganization T
+                            left join TOrganType Y on T.torgtype_code=Y.torgtype_code
                             left join  TUser U on T.lm_user=U.usercode
                             where 1=1" + search + " order by T.lm_date desc";
                 var data = DapperHelper.selectdata(sql, dynamicParams);
@@ -288,7 +294,7 @@
         #endregion
 
         #region[鏂板缂栬緫缁勭粐鏋舵瀯]
-        public static ToMessage AddUpdateOrganization(string OrganCode, string OrganName, string leve, string parent_id, string storgcode, string torg_seq, string status, string OperType, User us)
+        public static ToMessage AddUpdateOrganization(string OrganCode, string OrganName, string leve, string parent_id, string storgcode,string torgtype_code, string torg_seq, string status, string OperType, User us)
         {
             string sql = "";
             List<object> list = new List<object>();
@@ -309,8 +315,8 @@
                         return mes;
                     }
 
-                    sql = @"insert into TOrganization(parent_id,torg_code,torg_name,status,leve,torg_seq,lm_user,lm_date) 
-                            values(@parent_id,@torg_code,@torg_name,@status,@leve,@torg_seq,@lm_user,@lm_date)";
+                    sql = @"insert into TOrganization(parent_id,torg_code,torg_name,torgtype_code,status,leve,torg_seq,lm_user,lm_date) 
+                            values(@parent_id,@torg_code,@torg_name,@torgtype_code,@status,@leve,@torg_seq,@lm_user,@lm_date)";
                     list.Add(new
                     {
                         str = sql,
@@ -319,6 +325,7 @@
                             parent_id = storgcode,
                             torg_code = OrganCode,
                             torg_name = OrganName,
+                            torgtype_code= torgtype_code,
                             status = status,
                             leve = leve,
                             torg_seq = torg_seq,
@@ -387,7 +394,7 @@
                     }
 
                     //淇敼褰撳墠缁勭粐鏁版嵁
-                    sql = @"update TOrganization set parent_id=@parent_id,torg_name=@torg_name,leve=@leve,torg_seq=@torg_seq,lm_user=@lm_user,lm_date=@lm_date 
+                    sql = @"update TOrganization set parent_id=@parent_id,torg_name=@torg_name,torgtype_code=@torgtype_code,leve=@leve,torg_seq=@torg_seq,lm_user=@lm_user,lm_date=@lm_date 
                             where torg_code=@torg_code";
                     list.Add(new
                     {
@@ -397,6 +404,7 @@
                             parent_id = storgcode,
                             torg_code = OrganCode,
                             torg_name = OrganName,
+                            torgtype_code= torgtype_code,
                             leve = leve,
                             torg_seq = torg_seq,
                             lm_user = us.usercode,
@@ -489,7 +497,7 @@
                 if (cont > 0)
                 {
                     //鍐欏叆鎿嶄綔璁板綍琛�
-                    LogHelper.DbOperateLog(us.usercode, "鏂板", "鍒犻櫎浜嗙粍缁�:" + orgcode, us.usertype);
+                    LogHelper.DbOperateLog(us.usercode, "鍒犻櫎", "鍒犻櫎浜嗙粍缁�:" + orgcode, us.usertype);
                     mes.code = "200";
                     mes.count = 0;
                     mes.message = "鍒犻櫎鎿嶄綔鎴愬姛!";
@@ -3127,7 +3135,7 @@
                 else
                 {
                     //鍒ゆ柇褰撳墠宸ヨ壓璺嚎鏄惁鏈夎缃妭鎷嶅伐浠�(鏈夎缃紝鎻愮ず鍏堝垹闄よ妭鎷嶅伐浠疯缃�)
-                    sql = @"select *   from TPrteEqp_Stad where route_code=@routecode";
+                    sql = @"select *   from TPrteStep_Price where route_code=@routecode";
                     dynamicParams.Add("@routecode", routecode);
                     var data0 = DapperHelper.selectdata(sql, dynamicParams);
                     if (data0.Rows.Count > 0)
@@ -3218,7 +3226,7 @@
                 }
                 // --------------鏌ヨ鎸囧畾鏁版嵁--------------
                 var total = 0; //鎬绘潯鏁�
-                var sql = @"select A.id,A.stepcode,A.stepname,A.flwtype,A.enable,A.descr,U.username as lm_user,A.lm_date
+                var sql = @"select A.id,A.stepcode,A.stepname,A.flwtype,A.enable,A.is_eqp,A.descr,U.username as lm_user,A.lm_date
                             from TStep A
                             left join TUser U on A.lm_user=U.usercode
                             where A.is_delete<>'1' " + search;
@@ -3240,7 +3248,7 @@
         #endregion
 
         #region[宸ュ簭鏂板缂栬緫]
-        public static ToMessage AddUpdateStep(string stepid, string stepcode, string stepname, string steptypecode, string enable, string description, User us, string operType)
+        public static ToMessage AddUpdateStep(string operType, User us, TFlw_Rteqp tflw_rteqp)
         {
             var dynamicParams = new DynamicParameters();
             List<object> list = new List<object>();
@@ -3250,7 +3258,7 @@
                 if (operType == "Add")
                 {
                     sql = @"select *  from TStep where stepcode=@stepcode";
-                    dynamicParams.Add("@stepcode", stepcode);
+                    dynamicParams.Add("@stepcode", tflw_rteqp.stepcode);
                     var data = DapperHelper.selectdata(sql, dynamicParams);
                     if (data.Rows.Count > 0)
                     {
@@ -3260,20 +3268,52 @@
                         mes.data = null;
                         return mes;
                     }
+                    //鍐欏叆宸ュ簭琛�
                     sql = @"insert into TStep(stepcode,stepname,flwtype,enable,descr,lm_user,lm_date) 
                                values(@stepcode,@stepname,@steptypecode,@enable,@description,@username,@CreateDate)";
-                    dynamicParams.Add("@stepcode", stepcode);
-                    dynamicParams.Add("@stepname", stepname);
-                    dynamicParams.Add("@steptypecode", steptypecode);
-                    dynamicParams.Add("@enable", enable);
-                    dynamicParams.Add("@description", description);
-                    dynamicParams.Add("@username", us.usercode);
-                    dynamicParams.Add("@CreateDate", DateTime.Now.ToString());
-                    int cont = DapperHelper.SQL(sql, dynamicParams);
-                    if (cont > 0)
+                    list.Add(new
+                    {
+                        str = sql,
+                        parm = new
+                        {
+                            stepcode = tflw_rteqp.stepcode,
+                            stepname = tflw_rteqp.stepname,
+                            steptypecode = tflw_rteqp.steptypecode,
+                            enable = tflw_rteqp.enable,
+                            description = tflw_rteqp.description,
+                            username = us.usercode,
+                            CreateDate = DateTime.Now.ToString()
+                        }
+                    });
+                    //鍐欏叆宸ュ簭鍏宠仈璁惧琛�
+                    if (tflw_rteqp.children.Count > 0)
+                    {
+                        for (int i = 0; i < tflw_rteqp.children.Count; i++)
+                        {
+                            sql = @"insert into TFlw_Rteqp(eqp_code,step_code,style,lm_user,lm_date) 
+                               values(@eqp_code,@step_code,@style,@lm_user,@lm_date)";
+                            list.Add(new
+                            {
+                                str = sql,
+                                parm = new
+                                {
+                                    eqp_code = tflw_rteqp.children[i].eqpcode,
+                                    step_code = tflw_rteqp.children[i].stepcode,
+                                    style = tflw_rteqp.children[i].style,
+                                    lm_user = us.usercode,
+                                    lm_date = DateTime.Now.ToString()
+                                }
+                            });
+                        }
+                        //鏍囪鐗╂枡琛ㄥ叧鑱斿伐鑹鸿矾绾挎爣璇�
+                        sql = @"update TStep set is_eqp='Y' where stepcode=@stepcode";
+                        list.Add(new { str = sql, parm = new { stepcode = tflw_rteqp.stepcode } });
+                    }
+                    bool aa = DapperHelper.DoTransaction(list);
+                    if (aa)
                     {
                         //鍐欏叆鎿嶄綔璁板綍琛�
-                        LogHelper.DbOperateLog(us.usercode, "鏂板", "鏂板浜嗗伐搴�:" + stepcode, us.usertype);
+                        LogHelper.DbOperateLog(us.usercode, "鏂板", "鏂板浜嗗伐搴�:" + tflw_rteqp.stepcode, us.usertype);
                         mes.code = "200";
                         mes.count = 0;
                         mes.message = "鏂板鎿嶄綔鎴愬姛!";
@@ -3290,13 +3330,14 @@
                 if (operType == "Update")
                 {
                     list.Clear();
-                    //濡傛灉褰撳墠宸ュ簭浣跨敤鐘舵�佷綅N(鏈惎鐢�),闇�鍒ゆ柇褰撳墠宸ュ簭鏄惁琚伐鍗曞紩鐢�
-                    if (enable == "N")
+                    //濡傛灉褰撳墠宸ュ簭浣跨敤鐘舵�佷綅N(鏈惎鐢�)
+                    if (tflw_rteqp.enable == "N")
                     {
-                        var sql0 = @"select *  from TK_Wrk_Step A where A.step_code=@stepcode";
-                        dynamicParams.Add("@stepcode", stepcode);
-                        var data = DapperHelper.selectdata(sql0, dynamicParams);
-                        if (data.Rows.Count > 0)
+                        //闇�鍒ゆ柇褰撳墠宸ュ簭鏄惁琚伐鍗曞紩鐢�
+                        sql = @"select *  from TK_Wrk_Step A where A.step_code=@stepcode";
+                        dynamicParams.Add("@stepcode", tflw_rteqp.stepcode);
+                        var data0 = DapperHelper.selectdata(sql, dynamicParams);
+                        if (data0.Rows.Count > 0)
                         {
                             mes.code = "300";
                             mes.count = 0;
@@ -3305,14 +3346,61 @@
                             return mes;
                         }
                     }
+                    //鏍规嵁宸ュ簭鏌ユ壘鍘嗗彶璁惧
+                    sql = @"select step_code as stepcode,eqp_code as eqpcode,style  from TFlw_Rteqp  where step_code=@stepcode";
+                    dynamicParams.Add("@stepcode", tflw_rteqp.stepcode);
+                    var data = DapperHelper.select<StepEqpData>(sql, dynamicParams);
+                    // 鍘嗗彶涓湁鑰屾彁浜や腑娌℃湁鐨勫厓绱�(鎵ц鍒犻櫎)  
+                    var inBNotInA = data.Where(b => !tflw_rteqp.children.Any(a => a.eqpcode == b.eqpcode)).ToList();
+                    for (int i = 0; i < inBNotInA.Count; i++)
+                    {
+                        //鍒犻櫎宸ュ簭鍏宠仈璁惧琛�
+                        sql = @"delete TFlw_Rteqp  where step_code=@step_code and eqp_code=@eqp_code";
+                        list.Add(new { str = sql, parm = new { step_code = inBNotInA[i].stepcode, eqp_code= inBNotInA[i].eqpcode } });
+                        //鍒犻櫎璁惧鑺傛媿宸ヤ环琛�
+                        sql = @"delete TPrteEqp_Stad  where step_code=@step_code and eqp_code=@eqp_code";
+                        list.Add(new { str = sql, parm = new { step_code = inBNotInA[i].stepcode, eqp_code = inBNotInA[i].eqpcode } });
+                    }
+                    // 鎻愪氦涓湁鑰屽巻鍙蹭腑娌℃湁鐨勫厓绱�(鎵ц鍐欏叆)
+                    var inANotInB = tflw_rteqp.children.Where(a => !data.Any(b => b.eqpcode == a.eqpcode)).ToList();
+                    for (int i = 0; i < inANotInB.Count; i++)
+                    {
+                        //鍐欏叆宸ュ簭鍏宠仈璁惧琛�
+                        sql = @"insert into TFlw_Rteqp(eqp_code,step_code,style,lm_user,lm_date) 
+                               values(@eqp_code,@step_code,@style,@lm_user,@lm_date)";
+                        list.Add(new
+                        {
+                            str = sql,
+                            parm = new
+                            {
+                                eqp_code = inANotInB[i].eqpcode,
+                                step_code = inANotInB[i].stepcode,
+                                style = inANotInB[i].style,
+                                lm_user = us.usercode,
+                                lm_date = DateTime.Now.ToString()
+                            }
+                        });
+                    }
+                    if (tflw_rteqp.children.Count > 0)
+                    {
+                        //鏍囪鐗╂枡琛ㄥ叧鑱斿伐鑹鸿矾绾挎爣璇�
+                        sql = @"update TStep set is_eqp='Y' where stepcode=@stepcode";
+                        list.Add(new { str = sql, parm = new { stepcode = tflw_rteqp.stepcode } });
+                    }
+                    if (tflw_rteqp.children.Count <= 0) 
+                    {
+                        //鏍囪鐗╂枡琛ㄥ叧鑱斿伐鑹鸿矾绾挎爣璇�
+                        sql = @"update TStep set is_eqp='N' where stepcode=@stepcode";
+                        list.Add(new { str = sql, parm = new { stepcode = tflw_rteqp.stepcode } });
+                    }
                     sql = @"update TStep set stepname=@stepname,flwtype=@steptypecode,enable=@enable,descr=@description,
                                 lm_user=@username,lm_date=@CreateDate where id=@stepid";
-                    list.Add(new { str = sql, parm = new { stepid = stepid, stepname = stepname, steptypecode = steptypecode, enable = enable, description = description, username = us.usercode, CreateDate = DateTime.Now.ToString() } });
+                    list.Add(new { str = sql, parm = new { stepid = tflw_rteqp.id, stepname = tflw_rteqp.stepname, steptypecode = tflw_rteqp.steptypecode, enable = tflw_rteqp.enable, description = tflw_rteqp.description, username = us.usercode, CreateDate = DateTime.Now.ToString() } });
                     bool aa = DapperHelper.DoTransaction(list);
                     if (aa)
                     {
                         //鍐欏叆鎿嶄綔璁板綍琛�
-                        LogHelper.DbOperateLog(us.usercode, "淇敼", "淇敼浜嗗伐搴�:" + stepcode, us.usertype);
+                        LogHelper.DbOperateLog(us.usercode, "淇敼", "淇敼浜嗗伐搴�:" + tflw_rteqp.stepcode, us.usertype);
                         mes.code = "200";
                         mes.count = 0;
                         mes.message = "淇敼鎿嶄綔鎴愬姛!";
@@ -3347,6 +3435,18 @@
             try
             {
                 list.Clear();
+                //褰撳墠宸ュ簭鏄惁璁剧疆宸ヤ环
+                sql = @"select *  from TPrteStep_Price A where A.step_code=@stepcode";
+                dynamicParams.Add("@stepcode", stepcode);
+                var data0 = DapperHelper.selectdata(sql, dynamicParams);
+                if (data0.Rows.Count > 0)
+                {
+                    mes.code = "300";
+                    mes.count = 0;
+                    mes.message = "宸ュ簭鏈夎缃伐浠�,涓嶅厑璁稿垹闄�!";
+                    mes.data = null;
+                    return mes;
+                }
                 //褰撳墠宸ュ簭鏄惁鍏宠仈宸ュ崟
                 sql = @"select *  from TK_Wrk_Step A where A.step_code=@stepcode";
                 dynamicParams.Add("@stepcode", stepcode);
@@ -3359,6 +3459,9 @@
                     mes.data = null;
                     return mes;
                 }
+                //鍒犻櫎宸ュ簭鍏宠仈宸ヤ綔绔欒〃
+                sql = @"delete TFlw_Rteqp  where step_code=@stepcode";
+                list.Add(new { str = sql, parm = new { stepcode = stepcode } });
                 //鍒犻櫎宸ュ簭
                 sql = @"delete TStep  where stepcode=@stepcode";
                 list.Add(new { str = sql, parm = new { stepcode = stepcode } });
@@ -3390,6 +3493,188 @@
             return mes;
         }
         #endregion
+
+        #region[宸ュ簭瀹氫箟鍏宠仈宸ヤ綔绔欐煡璇
+        public static ToMessage StepAssociationEqp(string stepcode, User us)
+        {
+            string sql = "";
+            var dynamicParams = new DynamicParameters();
+            List<StepEqp> list = new List<StepEqp>();
+            try
+            {
+                //鑾峰彇宸ヤ綔绔欓泦鍚�(杞﹂棿銆佸鍗忎緵搴斿晢,鍖呭惈宸茬粦瀹氬伐浣滅珯鏍囪瘑)
+                sql = @"select distinct T.torg_code as wksp_code,T.torg_name as wksp_name,'E' as type,(case when B.eqp_code is null then 'N' else 'Y' end) flag 
+                        from TOrganization T
+                         left join(
+                          select distinct A.eqp_code,B.torg_code as wksp_code  from TFlw_Rteqp A 
+                          inner join TEqpInfo B on A.eqp_code=B.code 
+                          where A.step_code=@stepcode   and B.enable='Y'
+                         ) B on T.torg_code=B.wksp_code where T.torgtype_code='W' 
+                         UNION ALL
+                         select distinct T.code as wksp_code,T.name as wksp_name,'W' as type,(case when B.customertype is null then 'N' else 'Y' end) flag 
+                         from TCustomerType T
+                         left join(
+                         select distinct A.eqp_code,B.customertype  from TFlw_Rteqp A 
+                         inner join TCustomer B on A.eqp_code=B.code 
+                         where A.step_code=@stepcode   
+                         ) B on T.code=B.customertype"; 
+                dynamicParams.Add("@stepcode", stepcode);
+                var data = DapperHelper.selectdata(sql, dynamicParams);
+                for (int i = 0; i < data.Rows.Count; i++)
+                {
+                    StepEqp rout = new StepEqp();
+                    rout.code = data.Rows[i]["WKSP_CODE"].ToString();
+                    rout.name = data.Rows[i]["WKSP_NAME"].ToString();
+                    rout.type = data.Rows[i]["TYPE"].ToString();
+                    rout.flag = data.Rows[i]["FLAG"].ToString();
+                    rout.children = new List<StepEqpCn>();
+                    if (rout.type == "W") //澶栧崗渚涙柟
+                    {
+                        //鏍规嵁澶栧崗渚涙柟鏍囪瘑缂栫爜鏌ユ壘澶栧崗渚涙柟淇℃伅(鍖呭惈宸插叧鑱旀爣璇�)
+                        sql = @"select A.code,A.name,'W' as type,(case when B.eqp_code is null then 'N' else 'Y' end) flag
+                                from TCustomer A
+                                left join(
+                                select distinct A.eqp_code  from TFlw_Rteqp A 
+                                inner join TCustomer B on A.eqp_code=B.code 
+                                where A.step_code=@stepcode and B.customertype=@wxcode 
+                                ) B on A.code=B.eqp_code where A.customertype=@wxcode ";
+                        dynamicParams.Add("@stepcode", stepcode);
+                        dynamicParams.Add("@wxcode", rout.code);
+                        var data0 = DapperHelper.selectdata(sql, dynamicParams);
+                        for (int k = 0; k < data0.Rows.Count; k++)
+                        {
+                            StepEqpCn cn = new StepEqpCn();
+                            cn.code = data0.Rows[k]["CODE"].ToString();//澶栧崗渚涙柟缂栫爜
+                            cn.name = data0.Rows[k]["NAME"].ToString();//澶栧崗渚涙柟鍚嶇О
+                            cn.type = data0.Rows[k]["TYPE"].ToString();//宸ヤ綔绔欑被鍨�(E:璁惧 W:澶栧崗渚涙柟)
+                            cn.flag = data0.Rows[k]["FLAG"].ToString();//鍏宠仈鏍囪瘑
+                            rout.children.Add(cn);
+                        }
+                        list.Add(rout);
+                    }
+                    else
+                    {
+                        //鏍规嵁杞﹂棿缂栫爜鏌ユ壘璁惧(鍖呭惈宸插叧鑱旀爣璇�)
+                        sql = @"select A.code,A.name,'E' as type,(case when B.eqp_code is null then 'N' else 'Y' end) flag
+                                from TEqpInfo A
+                                left join(
+                                select distinct A.eqp_code  from TFlw_Rteqp A 
+                                inner join TEqpInfo B on A.eqp_code=B.code 
+                                where A.step_code=@stepcode  and B.enable='Y'
+                                ) B on A.code=B.eqp_code where A.torg_code=@wkspcode ";
+                        dynamicParams.Add("@stepcode", stepcode);
+                        dynamicParams.Add("@wkspcode", data.Rows[i]["WKSP_CODE"].ToString());
+                        var data0 = DapperHelper.selectdata(sql, dynamicParams);
+                        for (int j = 0; j < data0.Rows.Count; j++)
+                        {
+                            StepEqpCn cn = new StepEqpCn();
+                            cn.code = data0.Rows[j]["CODE"].ToString();//璁惧缂栫爜
+                            cn.name = data0.Rows[j]["NAME"].ToString();//璁惧鍚嶇О
+                            cn.type = data0.Rows[j]["TYPE"].ToString();//宸ヤ綔绔欑被鍨�(E:璁惧 W:澶栧崗渚涙柟)
+                            cn.flag = data0.Rows[j]["FLAG"].ToString();//鍏宠仈鏍囪瘑
+                            rout.children.Add(cn);
+                        }
+                        list.Add(rout);
+                    }
+                }
+                mes.code = "200";
+                mes.message = "鏌ヨ鎴愬姛!";
+                mes.data = list;
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
+
+        #region [宸ュ簭瀹氫箟鍏宠仈宸ヤ綔绔欐彁浜
+        public static ToMessage SaveStepAssociationEqp(string stepcode, User us, List<ObjectData> json)
+        {
+            var sql = "";
+            List<object> list = new List<object>();
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                list.Clear();
+                //鏍规嵁宸ュ簭鏌ユ壘鍘嗗彶璁惧
+                sql = @"select step_code as stepcode,eqp_code as eqpcode,style  from TFlw_Rteqp  where step_code=@stepcode";
+                dynamicParams.Add("@stepcode", stepcode);
+                var data = DapperHelper.select<StepEqpData>(sql, dynamicParams);
+                // 鍘嗗彶涓湁鑰屾彁浜や腑娌℃湁鐨勫厓绱�(鎵ц鍒犻櫎)  
+                var inBNotInA = data.Where(b => !json.Any(a => a.code == b.eqpcode)).ToList();
+                for (int i = 0; i < inBNotInA.Count; i++)
+                {
+                    //鍒犻櫎宸ュ簭鍏宠仈璁惧琛�
+                    sql = @"delete TFlw_Rteqp  where step_code=@step_code and eqp_code=@eqp_code";
+                    list.Add(new { str = sql, parm = new { step_code = inBNotInA[i].stepcode, eqp_code = inBNotInA[i].eqpcode } });
+                    //鍒犻櫎璁惧鑺傛媿宸ヤ环琛�
+                    sql = @"delete TPrteEqp_Stad  where step_code=@step_code and eqp_code=@eqp_code";
+                    list.Add(new { str = sql, parm = new { step_code = inBNotInA[i].stepcode, eqp_code = inBNotInA[i].eqpcode } });
+                }
+                // 鎻愪氦涓湁鑰屽巻鍙蹭腑娌℃湁鐨勫厓绱�(鎵ц鍐欏叆)
+                var inANotInB = json.Where(a => !data.Any(b => b.eqpcode == a.code)).ToList();
+                for (int i = 0; i < inANotInB.Count; i++)
+                {
+                    //鍐欏叆宸ュ簭鍏宠仈璁惧琛�
+                    sql = @"insert into TFlw_Rteqp(eqp_code,step_code,style,lm_user,lm_date) 
+                               values(@eqp_code,@step_code,@style,@lm_user,@lm_date)";
+                    list.Add(new
+                    {
+                        str = sql,
+                        parm = new
+                        {
+                            eqp_code = inANotInB[i].code,
+                            step_code = stepcode,
+                            style = inANotInB[i].name,
+                            lm_user = us.usercode,
+                            lm_date = DateTime.Now.ToString()
+                        }
+                    });
+                }
+                if (json.Count > 0)
+                {
+                    //鏍囪鐗╂枡琛ㄥ叧鑱斿伐鑹鸿矾绾挎爣璇�
+                    sql = @"update TStep set is_eqp='Y' where stepcode=@stepcode";
+                    list.Add(new { str = sql, parm = new { stepcode = stepcode } });
+                }
+                if (json.Count <= 0)
+                {
+                    //鏍囪鐗╂枡琛ㄥ叧鑱斿伐鑹鸿矾绾挎爣璇�
+                    sql = @"update TStep set is_eqp='N' where stepcode=@stepcode";
+                    list.Add(new { str = sql, parm = new { stepcode = stepcode } });
+                }
+                bool aa = DapperHelper.DoTransaction(list);
+                if (aa)
+                {
+                    mes.code = "200";
+                    mes.count = 0;
+                    mes.message = "鎿嶄綔鎴愬姛!";
+                    mes.data = null;
+                }
+                else
+                {
+                    mes.code = "300";
+                    mes.count = 0;
+                    mes.message = "鎿嶄綔澶辫触!";
+                    mes.data = null;
+                }
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
+
 
 
         #region[鑺傛媿宸ヤ环,浜у搧淇℃伅鏌ヨ]
@@ -3437,28 +3722,79 @@
                         inner join TFlw_Rout B on A.route_code=B.code 
                         where A.materiel_code=@partcode and B.is_delete<>'1' and A.is_delete<>'1'";
                     dynamicParams.Add("@partcode", partcode);
+                    var data = DapperHelper.selectdata(sql, dynamicParams);
+                    mes.code = "200";
+                    mes.message = "鏌ヨ鎴愬姛!";
+                    mes.data = data;
                 }
                 else //宸ュ簭鐗�
                 {
                     //閫氳繃浜у搧缂栫爜鏌ユ壘鍏宠仈鐨勫伐搴忎俊鎭�
-                    sql = @"select A.step_seq,A.step_code,S.stepname as step_name,A.unprice,A.isbott,A.isend   
+                    sql = @"select A.step_seq as seq,A.step_code as code,S.stepname as name,A.unprice,A.isbott,A.isend,S.flwtype   
                             from (
-                            select S.materiel_code,R.step_seq,S.step_code,S.unprice,R.isbott,R.isend   from TPrteEqp_Stad S
+                            select S.materiel_code,R.step_seq,S.step_code,S.unprice,R.isbott,R.isend   from TPrteStep_Price S
                             inner join TMateriel_Step R on S.materiel_code=R.materiel_code and S.step_code=R.step_code
-                            where S.materiel_code=@partcode
+                            where S.route_code is null and S.materiel_code=@partcode
                             union all
                             select  materiel_code,step_seq,step_code,'0' as unprice,isbott,isend from TMateriel_Step 
                             where materiel_code=@partcode and materiel_code+step_code
-                            not in(select materiel_code+step_code  from TPrteEqp_Stad
-                            where materiel_code=@partcode)
+                            not in(select materiel_code+step_code  from TPrteStep_Price
+                            where route_code is null and materiel_code=@partcode)
                             ) as A
-                            left join TStep S on A.step_code=S.stepcode";
+                            left join TStep S on A.step_code=S.stepcode
+                            A.step_seq";
                     dynamicParams.Add("@partcode", partcode);
+                    var parents = DapperHelper.select<SubData>(sql, dynamicParams);
+                    for (int i = 0; i < parents.Count; i++)
+                    {
+                        if (parents[i].flwtype == "Z")
+                        {
+                            //閫氳繃浜у搧缂栫爜+宸ュ簭缂栫爜鏌ユ壘瀵瑰簲璁惧淇℃伅
+                            sql = @"select A.eqp_code,E.name as eqp_name,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice   
+                                from (
+                                select S.eqp_code,S.eqp_value,S.stand_value,S.cavity_qty,S.unprice  from TPrteEqp_Stad S
+                                inner join TMateriel_Step R on S.materiel_code=R.materiel_code and S.step_code=R.step_code
+                                where S.materiel_code=@partcode and S.step_code=@stepcode and S.route_code is null
+                                union all
+                                select  R.eqp_code,'0' as eqp_value,'0' as stand_value,'0' as cavity_qty,'0' as unprice from TMateriel_Step S
+                                inner join TFlw_Rteqp R on S.step_code=R.step_code
+                                where S.materiel_code=@partcode and S.step_code=@stepcode and S.materiel_code+S.step_code+R.eqp_code
+                                not in(select materiel_code+step_code+eqp_code  from TPrteEqp_Stad
+                                where materiel_code=@partcode and step_code=@stepcode and route_code is null)
+                                ) as A
+                                left join TEqpInfo E on A.eqp_code=E.code";
+                            dynamicParams.Add("@partcode", partcode);
+                            dynamicParams.Add("@stepcode", parents[i].code);
+                            var children = DapperHelper.select<EqpSubData>(sql, dynamicParams);
+                            parents[i].children = children.ToList();
+                        }
+                        else 
+                        {
+                            //閫氳繃浜у搧缂栫爜+宸ュ簭缂栫爜鏌ユ壘瀵瑰簲澶栧崗渚涘簲鍟嗕俊鎭�
+                            sql = @"select A.eqp_code,C.name as eqp_name,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice   
+                                from (
+                                select S.eqp_code,S.eqp_value,S.stand_value,S.cavity_qty,S.unprice  from TPrteEqp_Stad S
+                                inner join TMateriel_Step R on S.materiel_code=R.materiel_code and S.step_code=R.step_code
+                                where S.materiel_code=@partcode and S.step_code=@stepcode and S.route_code is null
+                                union all
+                                select  R.eqp_code,'0' as eqp_value,'0' as stand_value,'0' as cavity_qty,'0' as unprice from TMateriel_Step S
+                                inner join TFlw_Rteqp R on S.step_code=R.step_code
+                                where S.materiel_code=@partcode and S.step_code=@stepcode and S.materiel_code+S.step_code+R.eqp_code
+                                not in(select materiel_code+step_code+eqp_code  from TPrteEqp_Stad
+                                where materiel_code=@partcode and step_code=@stepcode and route_code is null)
+                                ) as A
+                                left join TCustomer C on A.eqp_code=C.code";
+                            dynamicParams.Add("@partcode", partcode);
+                            dynamicParams.Add("@stepcode", parents[i].code);
+                            var children = DapperHelper.select<EqpSubData>(sql, dynamicParams);
+                            parents[i].children = children.ToList();
+                        }
+                        
+                    }
+                    mes.code = "200";
+                    mes.message = "鏌ヨ鎴愬姛!";
+                    mes.data = parents;
                 }
-                var data = DapperHelper.selectdata(sql, dynamicParams);
-                mes.code = "200";
-                mes.message = "鏌ヨ鎴愬姛!";
-                mes.data = data;
             }
             catch (Exception e)
             {
@@ -3479,25 +3815,73 @@
             try
             {
                 //閫氳繃宸ヨ壓璺嚎缂栫爜鏌ユ壘鍏宠仈鐨勫伐搴忎俊鎭�
-                sql = @"select A.step_seq,A.step_code,S.stepname as step_name,A.unprice,A.isbott,A.isend   
+                sql = @"select A.step_seq as seq,A.step_code as code,S.stepname as name,A.unprice,A.isbott,A.isend,S.flwtype   
                         from (
-                        select S.materiel_code,R.seq as step_seq,S.step_code,S.unprice,R.first_choke as isbott,R.last_choke as isend   from TPrteEqp_Stad S
+                        select S.materiel_code,R.seq as step_seq,S.step_code,S.unprice,R.first_choke as isbott,R.last_choke as isend   from TPrteStep_Price S
                         inner join TFlw_Rtdt R on  S.route_code=R.rout_code and S.step_code=R.step_code
                         where S.materiel_code=@partcode and S.route_code=@route_code 
                         union all
                         select  @partcode as materiel_code,B.seq as step_seq,B.step_code,'0' as unprice,B.first_choke as isbott,B.last_choke as isend from TFlw_Rout A
                         inner join TFlw_Rtdt B on A.code=B.rout_code
                         where A.code=@route_code and  @partcode+A.code+B.step_code
-                        not in(select materiel_code+rout_code+step_code  from TPrteEqp_Stad
+                        not in(select materiel_code+rout_code+step_code  from TPrteStep_Price
                         where materiel_code=@partcode and route_code=@route_code)
                         ) as A
-                        left join TStep S on A.step_code=S.stepcode";
+                        left join TStep S on A.step_code=S.stepcode
+                        order by A.step_seq";
                 dynamicParams.Add("@partcode", partcode);
                 dynamicParams.Add("@route_code", routecode);
-                var data = DapperHelper.selectdata(sql, dynamicParams);
+                var parents = DapperHelper.select<SubData>(sql, dynamicParams);
+                for (int i = 0; i < parents.Count; i++)
+                {
+                    if (parents[i].flwtype == "Z")
+                    {
+                        //閫氳繃浜у搧缂栫爜+宸ヨ壓璺嚎+宸ュ簭缂栫爜鏌ユ壘瀵瑰簲璁惧淇℃伅
+                        sql = @"select A.eqp_code,E.name as eqp_name,A.enable,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice   
+                                from (
+                                select S.eqp_code,S.eqp_value,S.enable,S.stand_value,S.cavity_qty,S.unprice  from TPrteEqp_Stad S
+                                where S.materiel_code=@partcode and S.route_code=@routecode and S.step_code=@stepcode
+                                union all
+                                select  R.eqp_code,'0' as eqp_value,'N' as enable,'0' as stand_value,'0' as cavity_qty,'0' as unprice from TMateriel_Route S
+                                inner join TFlw_Rtdt T on S.route_code=T.rout_code
+                                inner join TFlw_Rteqp R on T.step_code=R.step_code
+                                where S.materiel_code=@partcode and S.route_code=@routecode and T.step_code=@stepcode and S.materiel_code+S.route_code+T.step_code+R.eqp_code
+                                not in(select materiel_code+route_code+step_code+eqp_code  from TPrteEqp_Stad
+                                where materiel_code=@partcode and route_code=@routecode  and step_code=@stepcode)
+                                ) as A
+                                left join TEqpInfo E on A.eqp_code=E.code";
+                        dynamicParams.Add("@partcode", partcode);
+                        dynamicParams.Add("@routecode", routecode);
+                        dynamicParams.Add("@stepcode", parents[i].code);
+                        var children = DapperHelper.select<EqpSubData>(sql, dynamicParams);
+                        parents[i].children = children.ToList();
+                    }
+                    else
+                    {
+                        //閫氳繃浜у搧缂栫爜+宸ヨ壓璺嚎+宸ュ簭缂栫爜鏌ユ壘瀵瑰簲澶栧崗渚涘簲鍟嗕俊鎭�
+                        sql = @"select A.eqp_code,C.name as eqp_name,A.enable,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice   
+                                from (
+                                select S.eqp_code,S.eqp_value,S.enable,S.stand_value,S.cavity_qty,S.unprice  from TPrteEqp_Stad S
+                                where S.materiel_code=@partcode and S.route_code=@routecode and S.step_code=@stepcode
+                                union all
+                                select  R.eqp_code,'0' as eqp_value,'N' as enable,'0' as stand_value,'0' as cavity_qty,'0' as unprice from TMateriel_Route S
+                                inner join TFlw_Rtdt T on S.route_code=T.rout_code
+                                inner join TFlw_Rteqp R on T.step_code=R.step_code
+                                where S.materiel_code=@partcode and S.route_code=@routecode and T.step_code=@stepcode and S.materiel_code+S.route_code+T.step_code+R.eqp_code
+                                not in(select materiel_code+route_code+step_code+eqp_code  from TPrteEqp_Stad
+                                where materiel_code=@partcode and route_code=@routecode  and step_code=@stepcode)
+                                ) as A
+                                left join TCustomer C on A.eqp_code=C.code";
+                        dynamicParams.Add("@partcode", partcode);
+                        dynamicParams.Add("@routecode", routecode);
+                        dynamicParams.Add("@stepcode", parents[i].code);
+                        var children = DapperHelper.select<EqpSubData>(sql, dynamicParams);
+                        parents[i].children = children.ToList();
+                    }
+                }
                 mes.code = "200";
                 mes.message = "鏌ヨ鎴愬姛!";
-                mes.data = data;
+                mes.data = parents;
             }
             catch (Exception e)
             {
@@ -3546,8 +3930,8 @@
                     total = 0; //鎬绘潯鏁�
                     sql = @"select *  from (
                             select A.id,A.materiel_code as partcode,B.partname,B.partspec,A.route_code,C.name as route_name,
-                            D.stepcode,D.stepname,A.unprice,U.username as lm_user,A.lm_date
-                            from TPrteEqp_Stad A
+                            D.stepcode,D.stepname,D.flwtype,A.unprice,U.username as lm_user,A.lm_date
+                            from TPrteStep_Price A
                             left join TMateriel_Info B on A.materiel_code=B.partcode
                             left join TFlw_Rout C on A.route_code=C.code
                             left join TStep D on A.step_code=D.stepcode
@@ -3559,8 +3943,8 @@
                     search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
                     total = 0; //鎬绘潯鏁�
                     sql = @"select *  from (
-                            select A.id,A.materiel_code as partcode,B.partname,B.partspec,D.stepcode,D.stepname,A.unprice,U.username as lm_user,A.lm_date
-                            from TPrteEqp_Stad A
+                            select A.id,A.materiel_code as partcode,B.partname,B.partspec,D.stepcode,D.stepname,D.flwtype,A.unprice,U.username as lm_user,A.lm_date
+                            from TPrteStep_Price A
                             left join TMateriel_Info B on A.materiel_code=B.partcode
                             left join TStep D on A.step_code=D.stepcode
                             left join TUser U on A.lm_user=U.usercode
@@ -3596,18 +3980,18 @@
                 bool route = dynObj.route;
                 if (route) //宸ヨ壓璺嚎鐗�
                 {
+                    //宸ュ簭淇℃伅
                     for (int i = 0; i < json[0].children.Count; i++)
                     {
-                        //褰撳墠浜у搧宸ヨ壓璺嚎瀵瑰簲宸ュ簭鏄惁宸茶缃妭鎷嶅伐浠�
-                        sql = @"select *  from TPrteEqp_Stad
-                        where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode";
+                        //褰撳墠浜у搧宸ヨ壓璺嚎瀵瑰簲宸ュ簭鏄惁宸茶缃伐浠�
+                        sql = @"select *  from TPrteStep_Price where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode";
                         dynamicParams.Add("@partcode", json[0].partcode);
                         dynamicParams.Add("@routecode", json[0].defaultroute_code);
                         dynamicParams.Add("@stepcode", json[0].children[i].code);
                         var data = DapperHelper.selectdata(sql, dynamicParams);
                         if (data.Rows.Count > 0)
                         {
-                            sql = @"update TPrteEqp_Stad set unprice=@unprice,lm_user=@username,lm_date=@userdate
+                            sql = @"update TPrteStep_Price set unprice=@unprice,lm_user=@username,lm_date=@userdate
                                     where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode";
                             list.Add(new
                             {
@@ -3625,7 +4009,7 @@
                         }
                         else 
                         {
-                            sql = @"insert into TPrteEqp_Stad(materiel_code,route_code,step_code,unprice,lm_user,lm_date) 
+                            sql = @"insert into TPrteStep_Price(materiel_code,route_code,step_code,unprice,lm_user,lm_date) 
                                     values(@partcode,@routecode,@stepcode,@unprice,@username,@userdate)";
                             list.Add(new
                             {
@@ -3641,6 +4025,63 @@
                                 }
                             });
                         }
+                        //璁惧淇℃伅
+                        for (int j = 0; j < json[0].children[i].children.Count; j++)
+                        {
+                            //褰撳墠浜у搧宸ヨ壓璺嚎瀵瑰簲宸ュ簭璁惧鏄惁宸茶缃妭鎷嶅伐浠�
+                            sql = @"select *  from TPrteEqp_Stad where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode and eqp_code=@eqpcode";
+                            dynamicParams.Add("@partcode", json[0].partcode);
+                            dynamicParams.Add("@routecode", json[0].defaultroute_code);
+                            dynamicParams.Add("@stepcode", json[0].children[i].code);
+                            dynamicParams.Add("@eqpcode", json[0].children[i].children[j].eqp_code);
+                            var data0 = DapperHelper.selectdata(sql, dynamicParams);
+                            if (data0.Rows.Count > 0)
+                            {
+                                sql = @"update TPrteEqp_Stad set enable=@enable, eqp_value=@eqp_value,stand_value=@stand_value,cavity_qty=@cavity_qty,unprice=@unprice,lm_user=@username,lm_date=@userdate
+                                    where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode and eqp_code=@eqpcode";
+                                list.Add(new
+                                {
+                                    str = sql,
+                                    parm = new
+                                    {
+                                        partcode = json[0].partcode,
+                                        routecode = json[0].defaultroute_code,
+                                        stepcode = json[0].children[i].code,
+                                        eqpcode = json[0].children[i].children[j].eqp_code,
+                                        enable= json[0].children[i].children[j].enable,
+                                        eqp_value = json[0].children[i].children[j].eqp_value,
+                                        stand_value = json[0].children[i].children[j].stand_value,
+                                        cavity_qty = json[0].children[i].children[j].cavity_qty,
+                                        unprice = json[0].children[i].children[j].unprice,
+                                        username = us.usercode,
+                                        userdate = DateTime.Now.ToString()
+                                    }
+                                });
+                            }
+                            else
+                            {
+                                sql = @"insert into TPrteEqp_Stad(materiel_code,route_code,step_code,eqp_code,enable,stand_value,eqp_value,cavity_qty,unprice,lm_user,lm_date) 
+                                    values(@materiel_code,@route_code,@step_code,@eqp_code,@enable,@stand_value,@eqp_value,@cavity_qty,@unprice,@lm_user,@lm_date)";
+                                list.Add(new
+                                {
+                                    str = sql,
+                                    parm = new
+                                    {
+                                        materiel_code = json[0].partcode,
+                                        route_code = json[0].defaultroute_code,
+                                        step_code = json[0].children[i].code,
+                                        eqp_code = json[0].children[i].children[j].eqp_code,
+                                        enable = json[0].children[i].children[j].enable,
+                                        stand_value = json[0].children[i].children[j].eqp_value,
+                                        eqp_value = json[0].children[i].children[j].stand_value,
+                                        cavity_qty = json[0].children[i].children[j].cavity_qty,
+                                        unprice = json[0].children[i].children[j].unprice,
+                                        lm_user = us.usercode,
+                                        lm_date = DateTime.Now.ToString()
+                                    }
+                                });
+                            }
+                        }
                     }
                 }
                 else //宸ュ簭鐗�
@@ -3648,14 +4089,13 @@
                     for (int i = 0; i < json[0].children.Count; i++)
                     {
                         //褰撳墠浜у搧瀵瑰簲宸ュ簭鏄惁宸茶缃妭鎷嶅伐浠�
-                        sql = @"select *  from TPrteEqp_Stad
-                        where materiel_code=@partcode and step_code=@stepcode";
+                        sql = @"select *  from TPrteStep_Price where materiel_code=@partcode and step_code=@stepcode";
                         dynamicParams.Add("@partcode", json[0].partcode);
                         dynamicParams.Add("@stepcode", json[0].children[i].code);
                         var data = DapperHelper.selectdata(sql, dynamicParams);
                         if (data.Rows.Count > 0)
                         {
-                            sql = @"update TPrteEqp_Stad set unprice=@unprice,lm_user=@username,lm_date=@userdate
+                            sql = @"update TPrteStep_Price set unprice=@unprice,lm_user=@username,lm_date=@userdate
                                     where materiel_code=@partcode  and step_code=@stepcode";
                             list.Add(new
                             {
@@ -3672,7 +4112,7 @@
                         }
                         else
                         {
-                            sql = @"insert into TPrteEqp_Stad(materiel_code,step_code,unprice,lm_user,lm_date) 
+                            sql = @"insert into TPrteStep_Price(materiel_code,step_code,unprice,lm_user,lm_date) 
                                     values(@partcode,@stepcode,@unprice,@username,@userdate)";
                             list.Add(new
                             {
@@ -3687,11 +4127,65 @@
                                 }
                             });
                         }
+                        //璁惧淇℃伅
+                        for (int j = 0; j < json[0].children[i].children.Count; j++)
+                        {
+                            //褰撳墠浜у搧宸ヨ壓璺嚎瀵瑰簲宸ュ簭璁惧鏄惁宸茶缃妭鎷嶅伐浠�
+                            sql = @"select *  from TPrteEqp_Stad where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode and eqp_code=@eqpcode";
+                            dynamicParams.Add("@partcode", json[0].partcode);
+                            dynamicParams.Add("@routecode", json[0].defaultroute_code);
+                            dynamicParams.Add("@stepcode", json[0].children[i].code);
+                            dynamicParams.Add("@eqpcode", json[0].children[i].children[j].eqp_code);
+                            var data0 = DapperHelper.selectdata(sql, dynamicParams);
+                            if (data0.Rows.Count > 0)
+                            {
+                                sql = @"update TPrteEqp_Stad set enable=@enable,eqp_value=@eqp_value,stand_value=@stand_value,cavity_qty=@cavity_qty,unprice=@unprice,lm_user=@username,lm_date=@userdate
+                                    where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode and eqp_code=@eqpcode";
+                                list.Add(new
+                                {
+                                    str = sql,
+                                    parm = new
+                                    {
+                                        partcode = json[0].partcode,
+                                        routecode = json[0].defaultroute_code,
+                                        stepcode = json[0].children[i].code,
+                                        eqpcode = json[0].children[i].children[j].eqp_code,
+                                        enable= json[0].children[i].children[j].enable,
+                                        eqp_value = json[0].children[i].children[j].eqp_value,
+                                        stand_value = json[0].children[i].children[j].stand_value,
+                                        cavity_qty = json[0].children[i].children[j].cavity_qty,
+                                        unprice = json[0].children[i].children[j].unprice,
+                                        username = us.usercode,
+                                        userdate = DateTime.Now.ToString()
+                                    }
+                                });
+                            }
+                            else
+                            {
+                                sql = @"insert into TPrteEqp_Stad(materiel_code,route_code,step_code,eqp_code,enable,stand_value,eqp_value,cavity_qty,unprice,lm_user,lm_date) 
+                                    values(@materiel_code,@route_code,@step_code,@eqp_code,@enable,@stand_value,@eqp_value,@cavity_qty,@unprice,@lm_user,@lm_date)";
+                                list.Add(new
+                                {
+                                    str = sql,
+                                    parm = new
+                                    {
+                                        materiel_code = json[0].partcode,
+                                        route_code = json[0].defaultroute_code,
+                                        step_code = json[0].children[i].code,
+                                        eqp_code = json[0].children[i].children[j].eqp_code,
+                                        enable= json[0].children[i].children[j].enable,
+                                        stand_value = json[0].children[i].children[j].eqp_value,
+                                        eqp_value = json[0].children[i].children[j].stand_value,
+                                        cavity_qty = json[0].children[i].children[j].cavity_qty,
+                                        unprice = json[0].children[i].children[j].unprice,
+                                        lm_user = us.usercode,
+                                        lm_date = DateTime.Now.ToString()
+                                    }
+                                });
+                            }
+                        }
                     }
                 }
-
-
-                   
                 bool aa = DapperHelper.DoTransaction(list);
                 if (aa)
                 {
@@ -3729,8 +4223,27 @@
             var dynamicParams = new DynamicParameters();
             try
             {
-                //鍒犻櫎鑺傛媿宸ヤ环琛�
-                sql = @"delete TPrteEqp_Stad  where id=@id";
+                //鏌ユ壘宸ュ簭宸ヤ环琛�
+                sql = @"select *  from TPrteStep_Price where id=@id";
+                dynamicParams.Add("@id", id);
+                var data = DapperHelper.selectdata(sql, dynamicParams);
+                if (data.Rows.Count > 0)
+                {
+                    //鍒犻櫎鑺傛媿宸ヤ环琛�
+                    sql = @"delete TPrteEqp_Stad  where materiel_code=@materiel_code and route_code=@route_code and step_code=@step_code";
+                    list.Add(new
+                    {
+                        str = sql,
+                        parm = new
+                        {
+                            materiel_code = data.Rows[0]["materiel_code"].ToString(),
+                            route_code = data.Rows[0]["route_code"].ToString(),
+                            step_code = data.Rows[0]["step_code"].ToString()
+                        }
+                    });
+                }
+                //鍒犻櫎宸ュ簭宸ヤ环琛�
+                sql = @"delete TPrteStep_Price  where id=@id";
                 list.Add(new
                 {
                     str = sql,

--
Gitblit v1.9.3