From e235d94e5987d43117439837e3a0ee2e316e91d2 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期三, 22 三月 2023 17:19:00 +0800
Subject: [PATCH] 获取标签接口修改、过滤器修改、用户清单导入班组字段

---
 VueWebApi/DLL/DAL/AppPurchManagementDAL.cs |  300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 296 insertions(+), 4 deletions(-)

diff --git a/VueWebApi/DLL/DAL/AppPurchManagementDAL.cs b/VueWebApi/DLL/DAL/AppPurchManagementDAL.cs
index fc7f4eb..3b05d98 100644
--- a/VueWebApi/DLL/DAL/AppPurchManagementDAL.cs
+++ b/VueWebApi/DLL/DAL/AppPurchManagementDAL.cs
@@ -5,6 +5,7 @@
 using System.Data.SqlClient;
 using System.Linq;
 using System.Web;
+using VueWebApi.Models;
 using VueWebApi.Tools;
 
 namespace VueWebApi.DLL.DAL
@@ -69,14 +70,15 @@
             try
             {
                 //鏍规嵁閲囪喘璁㈠崟鍙锋煡璇㈢墿鏂欎俊鎭紝渚涘簲鍟嗕俊鎭�
-                sql = @"select B.materiel_code as partcode,M.partname,M.partspec,M.is_batchno,
-                        B.quantity,B.customercode,C.name as customername,U.code as uomcode,U.name as uomname,
-                        A.ordercode,B.countarrivalquantity  
+                sql = @"select B.rownumber, B.materiel_code as partcode,M.partname,M.partspec,M.is_batchno,M.is_incheck,
+                        B.quantity,B.customercode,C.name as customername,A.departmentcode,T.org_name as departmentname,U.code as uomcode,U.name as uomname,
+                        A.ordercode,B.countarrivalquantity,A.acceptdate  
                         from T_PurchaseOrder A
                         inner join T_PurchaseOrder_sub B on A.ordercode=B.purchaseorder_code
                         left  join TMateriel_Info M on B.materiel_code=M.partcode
                         left  join TUom U on M.uom_code=U.code
                         left  join TCustomer C on B.customercode=C.code
+                        left  join TOrganization T on A.departmentcode=T.org_code
                         where A.ordercode=@purchordercode";
                 dynamicParams.Add("@purchordercode", purchordercode);
                 var data = DapperHelper.selectdata(sql, dynamicParams);
@@ -107,9 +109,299 @@
         #region[閲囪喘鍒拌揣锛氱敓鎴愮郴缁熸潯鐮乚
         public static ToMessage MesAppPurchOrderLabelBarCode(string partcode, string arrivalqty, string onelableqty)
         {
-            mes = AppLableBarCode.EncodingSeach("2060",partcode, arrivalqty, onelableqty);
+            mes = AppLableBarCode.EncodingSeach("2060", partcode, arrivalqty, onelableqty);
             return mes;
         }
         #endregion
+
+        #region[閲囪喘鍒拌揣锛氭彁浜
+        public static ToMessage MesAppPurchOrderSave(string purordercode, string orderstaus, string username, List<AppPurchOrderSave> json)
+        {
+            var sql = "";
+            string djwo = "", numvalue = "";
+            List<object> list = new List<object>();
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                list.Clear();
+                mes = SeachEncode.EncodingSeach("2060");  //APP绔噰璐埌璐х敓鎴愬崟鍙�
+                if (mes.code == "300")
+                {
+                    return mes;
+                }
+                else
+                {
+                    List<string> wo = (List<string>)mes.data;
+                    djwo = wo[0].ToString(); //鑾峰彇鍗曞彿
+                    numvalue = wo[1].ToString(); //鑾峰彇娴佹按鍙�
+                }
+                if (json == null || json.Count <= 0)
+                {
+                    mes.code = "300";
+                    mes.count = 0;
+                    mes.Message = "鐗╂枡淇℃伅涓嶈兘涓虹┖!";
+                    mes.data = null;
+                    return mes;
+                }
+                //Lambda琛ㄨ揪寮忚繃婊よ幏鍙栭璁″埌璐ф棩鏈熴�侀儴闂ㄣ�佷緵搴斿晢鍙栫涓�涓�
+                string hacceptdate = json.Select(p => p.hacceptdate).Distinct().ToList().First().ToString(); //棰勮鍒拌揣鏃ユ湡
+                string dpartment = json.Select(p => p.hdepartmentcode).Distinct().ToList().First().ToString(); //閮ㄩ棬
+                string customercode = json.Select(p => p.hcustomercode).Distinct().ToList().First().ToString(); //渚涘簲鍟�
+                //鍐欏叆閲囪喘鍒拌揣鍗曚富琛�
+                sql = @"insert into T_PurchaseArrivalOrder(hbillno,hdate,hacceptdate,hbillstaus,hdepartmentcode,hcustomercode,hsourcebillno,lm_user,lm_date) 
+                        values(@hbillno,@hdate,@hacceptdate,@hbillstaus,@hdepartmentcode,@hcustomercode,@hsourcebillno,@lm_user,@lm_date)";
+                list.Add(new
+                {
+                    str = sql,
+                    parm = new
+                    {
+                        hbillno = djwo,
+                        hdate = DateTime.Now.ToString(),
+                        hacceptdate =hacceptdate==""?null:hacceptdate,
+                        hbillstaus = orderstaus,
+                        hdepartmentcode = dpartment,
+                        hcustomercode = customercode,
+                        hsourcebillno = purordercode,
+                        lm_user = username,
+                        lm_date = DateTime.Now.ToString()
+                    }
+                });
+                //寰幆鑾峰彇鐗╀俊鎭�
+                for (int i = 0; i < json.Count; i++)
+                {
+                    //鍐欏叆閲囪喘鍒拌揣鍗曞瓙琛�
+                    sql = @"insert into T_PurchaseArrivalOrder_sub(hbillno,rownumber,hpartcode,hplanqty,hqty,hacceptdate,hischeck,hbatchno) 
+                        values(@hbillno,@hpartcode,@hplanqty,@hqty,@hacceptdate,@hischeck,@hbatchno)";
+                    list.Add(new
+                    {
+                        str = sql,
+                        parm = new
+                        {
+                            hbillno = djwo,
+                            rownumber=json[i].rownumber,
+                            hpartcode = json[i].hpartcode,
+                            hplanqty = decimal.Parse(json[i].hplanqty),
+                            hqty = decimal.Parse(json[i].hqty),
+                            hacceptdate = hacceptdate == "" ? null : hacceptdate,
+                            hischeck = json[i].hischeck,
+                            hbatchno = json[i].hbatchno
+                        }
+                    });
+
+                    //寰幆鑾峰彇鐗╂枡鐢熸垚鏍囩淇℃伅
+                    for (int j = 0; j < json[i].children.Count; j++)
+                    {
+                        //鍐欏叆鏉$爜妗f琛�
+                        sql = @"insert into T_BarCodeBill(rightcode,hbillno,hbilltype,hbarcode,hbarcodestatus,hbarcodetype,hmaterialcode,hqty,hbatchno,hcustomercode,hdeptcode,hsourcebillno,hsourcebilltype,barcodeposition,lm_user,lm_date) 
+                        values(@rightcode,hbillno,@hbilltype,@hbarcode,@hbarcodestatus,@hbarcodetype,@hmaterialcode,@hqty,@hbatchno,@hcustomercode,@hdeptcode,@hsourcebillno,@hsourcebilltype,@barcodeposition,@lm_user,@lm_date)";
+                        list.Add(new
+                        {
+                            str = sql,
+                            parm = new
+                            {
+                                rightcode = "2060",
+                                hbillno = djwo,
+                                hbilltype = "1103", //閲囪喘鍒拌揣鍗曠被鍨�
+                                hbarcode = json[i].children[j].labcode,
+                                hbarcodestatus = "Y",
+                                hbarcodetype = "P",
+                                hmaterialcode = json[i].children[j].partnumber,
+                                hqty = decimal.Parse(json[i].children[j].labqty),
+                                hbatchno = json[i].hbatchno,
+                                hcustomercode = customercode,
+                                hdeptcode = dpartment,
+                                hsourcebillno = purordercode,
+                                hsourcebilltype = "1102",
+                                barcodeposition="2060;閲囪喘鍒拌揣",
+                                lm_user = username,
+                                lm_date = DateTime.Now.ToString()
+                            }
+                        });
+                    }
+                    //鏇存柊閲囪喘璁㈠崟瀛愯〃锛氱疮璁″埌璐ф暟閲�
+                    sql = @"update T_PurchaseOrder_sub set countarrivalquantity=countarrivalquantity+@hqty where ordercode=@purordercode and materiel_code=@materiel_code and rownumber=@rownumber";
+                    list.Add(new
+                    {
+                        str = sql,
+                        parm = new
+                        {
+                            purordercode = purordercode,
+                            materiel_code = json[i].hpartcode,
+                            rownumber=json[i].rownumber,
+                            hqty=decimal.Parse(json[i].hqty)
+                        }
+                    });
+                }
+                //鏇存柊閲囪喘璁㈠崟涓昏〃锛氳鍗曠姸鎬�
+                sql = @"update T_PurchaseOrder set status=@status where ordercode=@purordercode";
+                list.Add(new
+                {
+                    str = sql,
+                    parm = new
+                    {
+                        status = orderstaus,
+                        ordercode = purordercode
+                    }
+                });
+                bool aa = DapperHelper.DoTransaction(list);
+                if (aa)
+                {
+                    mes.code = "200";
+                    mes.count = 0;
+                    mes.Message = "閲囪喘鍒拌揣鎴愬姛!";
+                    mes.data = djwo;
+                }
+                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[閲囪喘鍏ュ簱閫夋嫨鏈夊埌璐ч噰璐鍗昡
+        public static ToMessage MesAppPurchInStorSelectCGOrder()
+        {
+            string sql = "";
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                //鏈夊埌璐ф垨鑰呴儴鍒嗗叆搴撶殑閲囪喘璁㈠崟
+                sql = @"select distinct A.ordercode   from T_PurchaseOrder A
+                        inner join T_PurchaseArrivalOrder B on A.ordercode=B.hsourcebillno
+                        where B.hbillstaus in('BINARIVE','INARIVE','BINSTOG')";
+                var data = DapperHelper.selecttable(sql);
+                if (data.Rows.Count > 0)
+                {
+                    mes.code = "200";
+                    mes.Message = "success!";
+                    mes.data = data;
+                }
+                else
+                {
+                    mes.code = "300";
+                    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[閫夋嫨閲囪喘璁㈠崟甯﹀嚭璁㈠崟涓嬫湁鍒拌揣鐨勭墿鏂欎俊鎭痌
+        public static ToMessage MesAppPurchInStorSelectCGOrderPart(string ordercode)
+        {
+            string sql = "";
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                //閫夋嫨閲囪喘璁㈠崟甯﹀嚭璁㈠崟涓嬫湁鍒拌揣鐨勭墿鏂欎俊鎭�
+                sql = @"select A.ordercode,M.partcode,M.partname,M.partspec,avg(S.hplanqty) as hplanqty,sum(S.hqty) as hqty 
+                        from T_PurchaseOrder A
+                        inner join T_PurchaseArrivalOrder B on A.ordercode=B.hsourcebillno
+                        inner join T_PurchaseArrivalOrder_sub S on B.hbillno=S.hbillno
+                        left  join TMateriel_Info M on S.hpartcode=M.partcode
+                        where B.hbillstaus in('BINARIVE','INARIVE','BINSTOG') and A.ordercode=@ordercode
+                        group by A.ordercode,M.partcode,M.partname,M.partspec";
+                dynamicParams.Add("@ordercode", ordercode);
+                var data = DapperHelper.selectdata(sql, dynamicParams);
+                if (data.Rows.Count > 0)
+                {
+                    mes.code = "200";
+                    mes.Message = "success!";
+                    mes.data = data;
+                }
+                else
+                {
+                    mes.code = "300";
+                    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[閲囪喘鍏ュ簱鎵弿鏍囩鏉$爜甯﹀嚭鍒拌揣鍗曚俊鎭痌
+        public static ToMessage MesAppPurchInStorScanLabCode(string labcode,string ordercode)
+        {
+            string sql = "";
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                //鍒ゆ柇鏉$爜鐘舵��
+                mes = LabCodeStatusMessage.LabCodeStatus("2060", "1103",labcode);//鍔熻兘缂栧彿銆佸崟鎹被鍨嬬紪鐮併�佹爣绛剧紪鐮�
+                if (mes.code == "300") 
+                {
+                    return mes;
+                }
+                //鍒ゆ柇鎵弿鏍囩鏄惁涓哄綋鍓嶉�夋嫨閲囪喘璁㈠崟涓嬬殑鍒拌揣鍗曟墍鐢熸垚鏍囩
+                sql = @"select *   from T_BarCodeBill where hsourcebillno=@ordercode";
+                dynamicParams.Add("@ordercode", ordercode);
+                var data0 = DapperHelper.selectdata(sql, dynamicParams);
+                if (data0.Rows.Count < 0) 
+                {
+                    mes.code = "300";
+                    mes.Message = "褰撳墠鏉$爜涓嶆槸閲囪喘璁㈠崟銆�"+ ordercode + "銆戠敓鎴愭潯鐮�!";
+                    mes.data = null;
+                    return mes;
+                }
+                //鏍规嵁鏍囩鏉$爜鏌ヨ鍒拌揣鐢熸垚鐨勬爣绛句俊鎭�
+                sql = @"select A.hbarcode,A.hbillno,A.hqty,A.hcustomercode,C.name as hcustomername,A.hbatchno,A.qualitystatus   
+                        from T_BarCodeBill A
+                        left join TCustomer C on A.hcustomercode=C.code
+                        where A.hbarcode=@labcode";
+                dynamicParams.Add("@labcode", labcode);
+                var data = DapperHelper.selectdata(sql, dynamicParams);
+                if (data.Rows.Count > 0)
+                {
+                    mes.code = "200";
+                    mes.Message = "success!";
+                    mes.data = data;
+                }
+                else
+                {
+                    mes.code = "300";
+                    mes.Message = "鏍囩淇℃伅涓嶅瓨鍦�!";
+                    mes.data = null;
+                }
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.Message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3