From c8d138de62133c15cd8e09bd9c8055411f64147c Mon Sep 17 00:00:00 2001
From: yxj <1qaz@123>
Date: 星期三, 15 十二月 2021 13:42:31 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/博日自动扫码线/ScanlineAPIController.cs |  166 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 157 insertions(+), 9 deletions(-)

diff --git "a/WebAPI/Controllers/\345\215\232\346\227\245\350\207\252\345\212\250\346\211\253\347\240\201\347\272\277/ScanlineAPIController.cs" "b/WebAPI/Controllers/\345\215\232\346\227\245\350\207\252\345\212\250\346\211\253\347\240\201\347\272\277/ScanlineAPIController.cs"
index 9a93a8d..1b23643 100644
--- "a/WebAPI/Controllers/\345\215\232\346\227\245\350\207\252\345\212\250\346\211\253\347\240\201\347\272\277/ScanlineAPIController.cs"
+++ "b/WebAPI/Controllers/\345\215\232\346\227\245\350\207\252\345\212\250\346\211\253\347\240\201\347\272\277/ScanlineAPIController.cs"
@@ -17,6 +17,7 @@
     {
         private jsonScanline objJsonResult = new jsonScanline();
         public DataSet ds = new DataSet();
+        public DataSet ds0 = new DataSet();
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
 
         #region 鐢熸垚绠辩爜鎺ュ彛
@@ -66,13 +67,7 @@
         }
         #endregion
 
-
-        #region 鎶ュ伐骞冲彴寮�宸ュ崟淇濆瓨/缂栬緫
-        /// <summary>
-        /// 寮�宸ュ崟
-        /// </summary>
-        /// <param name="msg"></param>
-        /// <returns></returns>
+        #region 绠辨潯鐮佺粦瀹氬叧绯绘彁浜ゆ帴鍙�
         [Route("packagebarcode/pack")]
         [HttpPost]
         public object pack([FromBody] JObject msg)
@@ -81,6 +76,159 @@
             {
                 JavaScriptSerializer js = new JavaScriptSerializer();   //瀹炰緥鍖栦竴涓兘澶熷簭鍒楀寲鏁版嵁鐨勭被
                 ScanLineCode list = js.Deserialize<ScanLineCode>(msg.ToString());    //灏唈son鏁版嵁杞寲涓哄璞$被鍨嬪苟璧嬪�肩粰list
+                if (list.billno != "" && list.billno != null)  //浠诲姟鍗曞彿锛岄潪蹇呴』锛岄潪绌哄垯鏍¢獙barcodes閲宐arcode鏄惁鐢辨浠诲姟鍗曞埗浣滅敓鎴愮殑
+                {
+                    ds = oCN.RunProcReturn("Select HBarCode barcode from Gy_BarCodeBill where HSourceBillNo='" + list.billno.ToString().Trim()+"'  Order by HItemID ", "Gy_BarCodeBill");
+                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.status = -1;
+                        objJsonResult.msg = "褰撳墠璁㈠崟鏃犵粦瀹氭潯鐮�!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    List<string> NameList = (from r in ds.Tables[0].AsEnumerable() select r.Field<string>("barcode")).ToList();
+                    List<string> NameList1= list.barcodes.Select(t => t.barcode).ToList();
+                    var strList = NameList1.Except(NameList).ToList();  //鍒ゆ柇鎻愪氦鏁版嵁涓潯鐮佹槸鍚﹀瓨鍦ㄤ簬璁㈠崟涓�
+                    if (strList.Count > 0) 
+                    {
+                        string Str=String.Join(",", strList.ToArray());
+                        objJsonResult.status = -1;
+                        objJsonResult.msg = "鏉$爜:"+ Str.ToString()+" 涓嶅寘鍚湪璁㈠崟:"+list.billno+"涓�!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }                
+                }
+                DLL.ClsSc_PackUnionBill oBill = new DLL.ClsSc_PackUnionBill();
+                //鍒ゆ柇绠辩爜鏄惁瀛樺湪
+                bool IsBarCodePack = oBill.IsBarCodePack(list.packagebarcode);
+                if (IsBarCodePack == false) 
+                {
+                    objJsonResult.status = -1;
+                    objJsonResult.msg = "绠辩爜宸插瓨鍦�,涓嶈兘閲嶅缁戝畾锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                Models.ClsSc_PackUnionBillMain oItem = new ClsSc_PackUnionBillMain();
+                oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+                oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
+                oItem.HBillType = "3783";
+                oItem.HBillSubType = "3783";
+                oItem.HDate= DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
+                oItem.HBillNo = DBUtility.ClsPub.CreateBillCode(oItem.HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
+                oItem.HBillStatus = 1;
+                oItem.HCheckItemNowID = 0;
+                oItem.HCheckItemNextID = 0;
+                oItem.HCheckFlowID = 0;
+                oItem.HRemark = "鑷姩鍖呰绾跨敓杈扮鏉$爜";
+                oItem.HBacker = "";
+                oItem.HBackDate = "";
+                oItem.HMaker = "";
+                oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
+                oItem.HChecker = "";
+                oItem.HCheckDate = "";
+                oItem.HUpDater = "";
+                oItem.HUpDateDate = "";
+                oItem.HCloseMan = "";
+                oItem.HCloseDate = "";
+                oItem.HCloseType = false;
+                oItem.HDeleteMan = "";
+                oItem.HDeleteDate = "";
+                oItem.HICMOInterID = 0;
+                oItem.HICMOBillNo = "";
+                oItem.HBarCode_Pack= list.packagebarcode;
+                oItem.HMaterID = 0;
+                oItem.HUnitID = 0;
+                oItem.HUseFlag =false;   //鏈夋晥鐘舵��
+                oBill.omodel = oItem;
+                for (int i = 0; i < list.barcodes.Count; i++)
+                {
+                    //鍒ゆ柇鏉$爜鏄惁瀛樺湪
+                    bool IsBarCode = oBill.IsBarCodePack(list.barcodes[i].barcode);
+                    if (IsBarCodePack == false)
+                    {
+                        objJsonResult.status = -1;
+                        objJsonResult.msg = "鏉$爜宸插瓨鍦�,涓嶈兘閲嶅缁戝畾锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    Models.ClsSc_PackUnionBillSub oItemSub = new ClsSc_PackUnionBillSub();
+                    ds0 = oCN.RunProcReturn("Select HBarCode,HMaterID,HUnitID,HQty,HSourceID,HGroupID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType from Gy_BarCodeBill where HSourceBillNo='" + list.billno.ToString().Trim() + "' and HBarCode='" + list.barcodes[i].barcode + "'  Order by HItemID ", "Gy_BarCodeBill");
+                    oItemSub.HEntryID = i+1;
+                    oItemSub.HMaterID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HMaterID"].ToString());
+                    oItemSub.HUnitID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HUnitID"].ToString());
+                    oItemSub.HQty = DBUtility.ClsPub.isDoule(ds0.Tables[0].Rows[0]["HQty"].ToString());
+                    oItemSub.HSourceID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HSourceID"].ToString());
+                    oItemSub.HEquipID = 0;
+                    oItemSub.HGroupID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HGroupID"].ToString());
+                    oItemSub.HWorkerID = 0; 
+                    oItemSub.HBarCode = list.barcodes[i].barcode;
+                    oItemSub.HBarCode_Pack = list.packagebarcode;
+                    oItemSub.HCloseMan = "";
+                    oItemSub.HCloseType = false;
+                    oItemSub.HRemark = "";
+                    oItemSub.HSourceInterID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HSourceInterID"].ToString());
+                    oItemSub.HSourceEntryID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HSourceEntryID"].ToString());
+                    oItemSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds0.Tables[0].Rows[0]["HSourceBillNo"].ToString());
+                    oItemSub.HSourceBillType = DBUtility.ClsPub.isStrNull(ds0.Tables[0].Rows[0]["HSourceBillType"].ToString());
+                    oItemSub.HRelationQty = 0;
+                    oItemSub.HRelationMoney = 0;
+                    oBill.DetailColl.Add(oItemSub);
+                }
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                if (oBill.omodel.HInterID == 0)
+                {
+                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                else
+                {
+                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                if (bResult)
+                {
+                    objJsonResult.status = 0;
+                    objJsonResult.msg = "success";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.status = -1;
+                    objJsonResult.msg = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.status =-1;
+                objJsonResult.msg = e.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 绠辨潯鐮佸彇娑堢粦瀹氬叧绯�
+        [Route("packagebarcode/cancel")]
+        [HttpPost]
+        public object cancel(string packagebarcode)
+        {
+            try
+            {
+                //
+                oCN.BeginTran();
+                //鍒犻櫎瀛愯〃
+                oCN.RunProc("Delete From Sc_PackUnionBillSub  where HBarCode_Pack=" + packagebarcode.ToString());
+                //鍒犻櫎涓昏〃
+                oCN.RunProc("Delete From Sc_PackUnionBillMain  where HBarCode_Pack=" + packagebarcode.ToString());
+                //鍒犻櫎鏉$爜妗f琛�
+                oCN.RunProc("Delete From Gy_BarCodeBill  where HBarCode=" + packagebarcode.ToString());
+
+                oCN.Commit();
 
                 objJsonResult.status = 0;
                 objJsonResult.msg = "success";
@@ -89,8 +237,8 @@
             }
             catch (Exception e)
             {
-                objJsonResult.status =-1;
-                objJsonResult.msg = "success";
+                objJsonResult.status = -1;
+                objJsonResult.msg = e.Message;
                 objJsonResult.data = null;
                 return objJsonResult;
             }

--
Gitblit v1.9.1