From c63b40452aeaf1b46ef716da9f5dc9e8c2a843a6 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期三, 13 七月 2022 20:30:33 +0800
Subject: [PATCH] 生产开报工提交

---
 VueWebApi/DLL/DAL/ProductionManagementDAL.cs |  193 ++++++++++++++++++++++++++++++++++++------------
 1 files changed, 145 insertions(+), 48 deletions(-)

diff --git a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
index 5262d35..fef2858 100644
--- a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
+++ b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
@@ -54,12 +54,12 @@
                 if (paydatestartdate != "" && paydatestartdate != null)
                 {
                     search += "and A.paydate between @paydatestartdate and @paydateenddate ";
-                    dynamicParams.Add("@paydatestartdate", paydatestartdate);
+                    dynamicParams.Add("@paydatestartdate", paydatestartdate+" 00:00:00");
                     dynamicParams.Add("@paydateenddate", paydateenddate + " 23:59:59");
                 }
                 if (createstartdate != "" && createstartdate != null)
                 {
-                    search += "and A.createdate between @paydatestartdate and @paydateenddate ";
+                    search += "and A.createdate between @createstartdate and @createenddate ";
                     dynamicParams.Add("@createstartdate", createstartdate);
                     dynamicParams.Add("@createenddate", createenddate + " 23:59:59");
                 }
@@ -494,7 +494,7 @@
                             from TFlw_Rtdt A
                             left join TStep B on A.step_code=B.stepcode
                             left join TFlw_Rout C on A.rout_code=C.code
-                            where A.first_choke='Y' and A.rout_code=@routecode
+                            where A.rout_code=@routecode
                             and B.is_delete<>'1' and C.enable='Y' and C.is_delete<>'1'";
                     list.Add(new
                     {
@@ -554,7 +554,7 @@
                             from TFlw_Rtdt A
                             left join TStep B on A.step_code=B.stepcode
                             left join TFlw_Rout C on A.rout_code=C.code
-                            where A.first_choke='Y' and A.rout_code='R001'
+                            where  A.rout_code=@routecode
                             and B.is_delete<>'1' and C.enable='Y' and C.is_delete<>'1'";
                     list.Add(new
                     {
@@ -567,6 +567,7 @@
                             planenddate = planenddate,
                             status = "ALLO",  //娲惧彂
                             username = username,
+                            routecode= routecode,
                             CreateDate = DateTime.Now.ToString()
                         }
                     });
@@ -612,22 +613,25 @@
                 var data = DapperHelper.selectdata(sql, dynamicParams);
                 if (data.Rows.Count > 0)
                 {
-                    //鏌ヨ鐢熶骇璁㈠崟琛ㄦ暟鎹�
-                    sql = @"select *  from TKimp_Ewo where wo=@m_po";
-                    dynamicParams.Add("@m_po", m_po);
-                    var data0 = DapperHelper.selectdata(sql, dynamicParams);
-                    decimal relse_qty = decimal.Parse(data0.Rows[0]["RELSE_QTY"].ToString());//浠ヤ笅鍗曟暟閲�
-                    if ((relse_qty - decimal.Parse(orderqty)) == 0)  //鍏ㄩ儴鎾ら攢 璁㈠崟鐘舵�佸洖鍐欐湭寮�濮�,宸蹭笅鍗曟暟閲忎负0
+                    if (m_po != "" && m_po != null)
                     {
-                        //鍥炲啓璁㈠崟琛ㄧ姸鎬佸強宸蹭笅鍗曟暟閲�
-                        sql = @"update TKimp_Ewo set status='NEW',relse_qty=0  where wo=@m_po";
-                        list.Add(new { str = sql, parm = new { m_po = m_po } });
-                    }
-                    else
-                    {
-                        //鍥炲啓璁㈠崟琛ㄧ姸鎬佸強宸蹭笅鍗曟暟閲�
-                        sql = @"update TKimp_Ewo set status='CREATING',relse_qty=relse_qty-@orderqty  where wo=@m_po";
-                        list.Add(new { str = sql, parm = new { m_po = m_po, orderqty = decimal.Parse(orderqty) } });
+                        //鏌ヨ鐢熶骇璁㈠崟琛ㄦ暟鎹�
+                        sql = @"select *  from TKimp_Ewo where wo=@m_po";
+                        dynamicParams.Add("@m_po", m_po);
+                        var data0 = DapperHelper.selectdata(sql, dynamicParams);
+                        decimal relse_qty = decimal.Parse(data0.Rows[0]["RELSE_QTY"].ToString());//浠ヤ笅鍗曟暟閲�
+                        if ((relse_qty - decimal.Parse(orderqty)) == 0)  //鍏ㄩ儴鎾ら攢 璁㈠崟鐘舵�佸洖鍐欐湭寮�濮�,宸蹭笅鍗曟暟閲忎负0
+                        {
+                            //鍥炲啓璁㈠崟琛ㄧ姸鎬佸強宸蹭笅鍗曟暟閲�
+                            sql = @"update TKimp_Ewo set status='NEW',relse_qty=0  where wo=@m_po";
+                            list.Add(new { str = sql, parm = new { m_po = m_po } });
+                        }
+                        else
+                        {
+                            //鍥炲啓璁㈠崟琛ㄧ姸鎬佸強宸蹭笅鍗曟暟閲�
+                            sql = @"update TKimp_Ewo set status='CREATING',relse_qty=relse_qty-@orderqty  where wo=@m_po";
+                            list.Add(new { str = sql, parm = new { m_po = m_po, orderqty = decimal.Parse(orderqty) } });
+                        }
                     }
                     //鍒犻櫎宸ュ崟宸ュ簭琛�
                     sql = @"delete TK_Wrk_Step  where wo_code=@wocode";
@@ -759,6 +763,11 @@
                     if (arra.Length == 1) //宸ュ崟鍙蜂簩缁寸爜
                     {
                         ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+                        mes.code = "300";
+                        mes.count = 0;
+                        mes.Message = "璇锋壂鎻忓伐搴忎簩缁寸爜!";
+                        mes.data = null;
+                        return mes;
                     }
                     if (arra.Length == 2) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
                     {
@@ -766,12 +775,12 @@
                         stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
                     }
 
-                    if (ordercode != "" && ordercode == null) //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂负绌�
+                    if (ordercode != "" && ordercode != null) //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂负绌�
                     {
                         search += "and A.wo_code=@ordercode ";
                         dynamicParams.Add("@ordercode", ordercode);
                     }
-                    if (ordercode != "" && ordercode != "") //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂笉涓虹┖
+                    if (ordercode != "" && stepcode != "") //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂笉涓虹┖
                     {
                         search += "and A.wo_code=@ordercode ";
                         dynamicParams.Add("@ordercode", ordercode);
@@ -779,18 +788,18 @@
                         dynamicParams.Add("@stepcode", stepcode);
                     }
                 }
-                else
-                {
-                    mes.code = "300";
-                    mes.count = 0;
-                    mes.Message = "浜岀淮鐮佷俊鎭负绌�!";
-                    mes.data = null;
-                    return mes;
-                }
+                //else
+                //{
+                //    mes.code = "300";
+                //    mes.count = 0;
+                //    mes.Message = "浜岀淮鐮佷俊鎭负绌�!";
+                //    mes.data = null;
+                //    return mes;
+                //}
                 if (stepcode != "")
                 {
                     //鏌ユ壘褰撳墠宸ュ簭灞炴��
-                    sql = @"select *  from TStep where TStep where stepcode=@stepcode";
+                    sql = @"select *  from TStep  where stepcode=@stepcode";
                     dynamicParams.Add("@stepcode", stepcode);
                     var data0 = DapperHelper.selectdata(sql, dynamicParams);
                     if (data0.Rows.Count > 0) 
@@ -859,18 +868,23 @@
                     if (arra.Length == 1) //宸ュ崟鍙蜂簩缁寸爜
                     {
                         ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+                        mes.code = "300";
+                        mes.count = 0;
+                        mes.Message = "璇锋壂鎻忓伐搴忎簩缁寸爜!";
+                        mes.data = null;
+                        return mes;
                     }
                     if (arra.Length == 2) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
                     {
                         ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
                         stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
                     }
-                    if (ordercode != "" && ordercode == null) //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂负绌�
+                    if (ordercode != "" && ordercode != null) //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂负绌�
                     {
                         search += "and A.wo_code=@ordercode ";
                         dynamicParams.Add("@ordercode", ordercode);
                     }
-                    if (ordercode != "" && ordercode != "") //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂笉涓虹┖
+                    if (ordercode != "" && stepcode != "") //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂笉涓虹┖
                     {
                         search += "and A.wo_code=@ordercode ";
                         dynamicParams.Add("@ordercode", ordercode);
@@ -878,18 +892,18 @@
                         dynamicParams.Add("@stepcode", stepcode);
                     }
                 }
-                else
-                {
-                    mes.code = "300";
-                    mes.count = 0;
-                    mes.Message = "浜岀淮鐮佷俊鎭负绌�!";
-                    mes.data = null;
-                    return mes;
-                }
+                //else
+                //{
+                //    mes.code = "300";
+                //    mes.count = 0;
+                //    mes.Message = "浜岀淮鐮佷俊鎭负绌�!";
+                //    mes.data = null;
+                //    return mes;
+                //}
                 if (stepcode != "")
                 {
                     //鏌ユ壘褰撳墠宸ュ簭灞炴��
-                    sql = @"select *  from TStep where TStep where stepcode=@stepcode";
+                    sql = @"select *  from TStep  where stepcode=@stepcode";
                     dynamicParams.Add("@stepcode", stepcode);
                     var data0 = DapperHelper.selectdata(sql, dynamicParams);
                     if (data0.Rows.Count > 0)
@@ -959,7 +973,7 @@
                     {
                         mes.code = "300";
                         mes.count = 0;
-                        mes.Message = "浜岀淮鐮佷俊鎭敊璇�,璇锋壂鎻忓伐搴忎换鍔″崱鎴栬�呮姤宸ユ墦鍗版爣绛�!";
+                        mes.Message = "璇锋壂鎻忓伐搴忔潯鐮�!";
                         mes.data = null;
                         return mes;
                     }
@@ -1084,9 +1098,92 @@
             try
             {
                 //鐝粍鑾峰彇浜哄憳鍒楄〃
-                sql = @"select usercode,username  from TUser where usergroup_code=@stepcode";
+                sql = @"select usercode,username  from TUser where usergroup_code=@usergroupcode and is_delete<>'1'";
                 dynamicParams.Add("@usergroupcode", usergroupcode);
                 var data = DapperHelper.selectdata(sql, dynamicParams);
+                mes.code = "200";
+                mes.Message = "鏌ヨ鎴愬姛!";
+                mes.data = data;
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.Message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
+
+        #region[鐢熶骇寮�鎶ュ伐锛氫汉鍛樹笅鎷夊垪琛╙
+        public static ToMessage MesOrderSelectUser(string usercode)
+        {
+            string sql = "";
+            string search = "";
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                if (usercode != "" && usercode != null) //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂负绌�
+                {
+                    search += "and usercode=@usercode ";
+                    dynamicParams.Add("@usercode", usercode);
+                }
+                //鐝粍鑾峰彇浜哄憳鍒楄〃
+                sql = @"select usercode,username  from TUser where is_delete<>'1' "+search;
+                dynamicParams.Add("@usercode", usercode);
+                var data = DapperHelper.selectdata(sql, dynamicParams);
+                mes.code = "200";
+                mes.Message = "鏌ヨ鎴愬姛!";
+                mes.data = data;
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.Message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
+
+        #region[鐢熶骇寮�鎶ュ伐锛氬彂鏂�/鏀舵枡鏃惰幏鍙栧鍗忎笅鎷夊垪琛╙
+        public static ToMessage MesOrderStepSelectWX(string orderstepqrcode)
+        {
+            string sql = "";
+            string ordercode = "";
+            string stepcode = "";
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                if (orderstepqrcode != "" && orderstepqrcode != null)
+                {
+                    string[] arra = orderstepqrcode.Split(';');
+                    if (arra.Length == 1) //宸ュ崟鍙蜂簩缁寸爜
+                    {
+                        ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+                    }
+                    if (arra.Length == 2) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
+                    {
+                        ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+                        stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+                    }
+                }
+                else
+                {
+                    mes.code = "300";
+                    mes.count = 0;
+                    mes.Message = "浜岀淮鐮佷俊鎭负绌�!";
+                    mes.data = null;
+                    return mes;
+                }
+                //鑾峰彇澶栧崗涓嬫媺妗�
+                sql = @"select C.code,C.name from TFlw_Rteqp A
+                        left join TCustomer C on A.eqp_code=C.code
+                        where A.step_code=@stepcode and A.style='W'";
+                dynamicParams.Add("@stepcode", stepcode);
+                var data = DapperHelper.selectdata(sql,dynamicParams);
                 mes.code = "200";
                 mes.Message = "鏌ヨ鎴愬姛!";
                 mes.data = data;
@@ -1346,7 +1443,7 @@
                 string date = DateTime.Now.ToString(); //鑾峰彇绯荤粺鏃堕棿
                 list.Clear();
                 //鍒ゆ柇鏄惁鏈夊彂鏂欒褰�(鏈�(鍚屽伐鍗�+宸ュ簭+澶栧崗渚涙柟淇敼) 鏃狅細鏂板)
-                sql = @"select *  from TK_Wrk_OutRecord where wo_code=@wo_code and step_code=@step_code and wx_code=@wxcode and style='F'";
+                sql = @"select *  from TK_Wrk_OutRecord where wo_code=@wo_code and step_code=@step_code and wx_code=@wx_code and style='F'";
                 dynamicParams.Add("@wo_code", mesordercode);
                 dynamicParams.Add("@step_code", stepcode);
                 dynamicParams.Add("@wx_code", wxcode);
@@ -1358,7 +1455,7 @@
                              where wo_code=@mesordercode and step_code=@stepcode and wx_code=@wx_code";
                     list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, wx_code = wxcode, fqty = decimal.Parse(fqty), username = username, CreateDate = date } });
                     //鍐欏叆瀛愯〃
-                    sql = @"insert into  TK_Wrk_RecordSub(m_id,wx_code,out_person,out_time,fqty,syle,lm_user,lm_date) 
+                    sql = @"insert into  TK_Wrk_OutRecordSub(m_id,wx_code,out_person,out_time,fqty,syle,lm_user,lm_date) 
                                 values(@m_id,@wx_code,@out_person,@out_time,@fqty,@lm_user,@lm_date)";
                     list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), wx_code = wxcode, out_person = outuser, out_time = date, fqty = fqty, style = 'F', lm_user = username, lm_date = date } });
                 }
@@ -1373,7 +1470,7 @@
                     list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, wx_code = wxcode, partcode = partcode, style = 'F', fqty = fqty, lm_user = username, lm_date = date } });
 
                     //鍐欏叆瀛愯〃
-                    sql = @"insert into  TK_Wrk_RecordSub(m_id,wx_code,out_person,out_time,fqty,style,lm_user,lm_date) 
+                    sql = @"insert into  TK_Wrk_OutRecordSub(m_id,wx_code,out_person,out_time,fqty,style,lm_user,lm_date) 
                                 values(@m_id,@wx_code,@out_person,@out_time,@fqty,@style,@lm_user,@lm_date)";
                     list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), wx_code = wxcode, out_person = outuser, out_time = date, fqty = fqty, style = 'F', lm_user = username, lm_date = date } });
                 }
@@ -1443,7 +1540,7 @@
                              where wo_code=@mesordercode and step_code=@stepcode and wx_code=@wx_code";
                     list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, wx_code = wxcode, sqty = decimal.Parse(sqty), ngqty = decimal.Parse(ngqty), username = username, CreateDate = date } });
                     //鍐欏叆澶栧崗璁板綍瀛愯〃
-                    sql = @"insert into  TK_Wrk_RecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,syle,lm_user,lm_date) 
+                    sql = @"insert into  TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,syle,lm_user,lm_date) 
                                 values(@m_id,@wx_code,@in_person,@in_time,@sqty,@ngqty,@lm_user,@lm_date)";
                     list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), wx_code = wxcode, in_person = inuser, in_time = date, sqty = sqty, ngqty = ngqty, style = 'S', lm_user = username, lm_date = date } });
 
@@ -1470,7 +1567,7 @@
                     list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, wx_code = wxcode, partcode = partcode, style = 'S', sqty = sqty, ngqty = ngqty, lm_user = username, lm_date = date } });
 
                     //鍐欏叆澶栧崗璁板綍瀛愯〃
-                    sql = @"insert into  TK_Wrk_RecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date) 
+                    sql = @"insert into  TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date) 
                                 values(@m_id,@wxcode,@in_person,@in_time,@sqty,@ng_qty,@style,@lm_user,@lm_date)";
                     list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), wxcode = wxcode, in_person = inuser, in_time = date, sqty = sqty, ng_qty = ngqty, style = "S", lm_user = username, lm_date = date } });
 

--
Gitblit v1.9.3