From 790643bfa671cc2c6a4579c3676845eebe0fa9ac Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期二, 25 十月 2022 15:12:01 +0800
Subject: [PATCH] 条码生成完善

---
 WebAPI/Controllers/POStockInBillController.cs |  298 +++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 245 insertions(+), 53 deletions(-)

diff --git a/WebAPI/Controllers/POStockInBillController.cs b/WebAPI/Controllers/POStockInBillController.cs
index d59000c..1e8517e 100644
--- a/WebAPI/Controllers/POStockInBillController.cs
+++ b/WebAPI/Controllers/POStockInBillController.cs
@@ -709,6 +709,7 @@
                 websLsmain.HDeptID = lsmain[0].HDeptID;
                 websLsmain.HWHID = lsmain[0].HWHID;
                 websLsmain.HSCWHID = 0;
+                //websLsmain.HSPID = lsmain[0].HSPID;
                 websLsmain.HSupID = lsmain[0].HSupID;
                 websLsmain.HKeeperID = lsmain[0].HKeeperID;
                 websLsmain.HSecManagerID = lsmain[0].HSecManagerID;
@@ -716,11 +717,13 @@
                 websLsmain.HManagerID = 0;
                 websLsmain.HBillerID = lsmain[0].HBillerID;
                 websLsmain.HRemark = "";
+                websLsmain.HExplanation = lsmain[0].HExplanation;
                 websLsmain.HInnerBillNo = "";
                 websLsmain.HRedBlueFlag = false;//false钃濆瓧 true绾㈠瓧
                 websLsmain.HMainSourceBillType = lsmain[0].HBillType;
-                websLsmain.HExplanation = lsmain[0].HExplanation;
-
+                websLsmain.HMaker = lsmain[0].HMaker;
+                websLsmain.HSTOCKORGID = lsmain[0].HSTOCKORGID;
+                websLsmain.HOWNERID = lsmain[0].HSTOCKORGID;
 
                 if (webserver.set_SavePOStockInBill_New(websLsmain, sSourceBillType, ref DBUtility.ClsPub.sErrInfo))
                 {
@@ -844,8 +847,6 @@
                 return objJsonResult;
             }
         }
-
-
         [Route("POStockInBill/Delete_Json")]
         [HttpGet]
         public object Delete_Json(long HInterID, long HMaterID, long HAuxPropID, string HMTONo, long HSourceInterID, long HSourceEntryID, string sHBillType)
@@ -982,7 +983,6 @@
             }
             catch (Exception)
             {
-
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "鍒犻櫎澶辫触锛�";
@@ -1000,25 +1000,27 @@
         {
             try
             {
-                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
-                string sql = $"select * from H_v_SRM_POInStockBillList where 鍗曟嵁鍙� ='{HBillno}'";
-                ds = oCn.RunProcReturn(sql, "H_v_SRM_POInStockBillList");
-                if (ds == null || ds.Tables[0].Rows.Count == 0)
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-                else
-                {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "Sucess锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
-                }
+                json result = Get_ReciveBillCheckDate(HBillno);
+                return result;
+                //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                //string sql = $"select * from H_v_SRM_POInStockBillList where 鍗曟嵁鍙� ='{HBillno}'";
+                //ds = oCn.RunProcReturn(sql, "H_v_SRM_POInStockBillList");
+                //if (ds == null || ds.Tables[0].Rows.Count == 0)
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+                //else
+                //{
+                //    objJsonResult.code = "1";
+                //    objJsonResult.count = 1;
+                //    objJsonResult.Message = "Sucess锛�";
+                //    objJsonResult.data = ds.Tables[0];
+                //    return objJsonResult;
+                //}
             }
             catch (Exception e)
             {
@@ -1058,7 +1060,7 @@
                     string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo);
                     DataTable dt = new DataTable();
                     List<string> fidList = new List<string>();
-                    if (FCusName == "鐟炰笌绁�")
+                    if (FCusName == "鐟炰笌绁�" || FCusName == "")
                     {
                         sql = string.Format(@"
 SELECT T3.FNAME AS FTYPENAME,M.HBILLNO,B.HINTERID,B.HENTRYID,C.FID,C.FENTRYID, D.FBILLNO,B.HQTY,CD.FRECEIVEORGID,CDOO.FNUMBER AS FRECEIVENUMBER
@@ -1076,7 +1078,7 @@
 LEFT JOIN {0}..T_ORG_ORGANIZATIONS CROO ON CR.FSETTLEORGID = CROO.FORGID
 LEFT JOIN {0}..T_PUR_POORDER D ON C.FID =D.FID
 LEFT JOIN {0}..T_BAS_BILLTYPE T2 ON D.FBILLTYPEID = T2.FBILLTYPEID
-LEFT JOIN {0}..T_BAS_BILLTYPE_L T3 ON T2.FBILLTYPEID = T3.FBILLTYPEID
+LEFT JOIN {0}..T_BAS_BILLTYPE_L T3 ON T2.FBILLTYPEID = T3.FBILLTYPEID and FLOCALEID=2052
 LEFT JOIN  {0}..V_BD_BUYER T4 ON D.FPURCHASERID =T4.FID
 LEFT JOIN {0}..T_BD_SUPPLIER DS ON D.FSUPPLIERID = DS.FSUPPLIERID
 LEFT JOIN {0}..T_ORG_ORGANIZATIONS DOO ON D.FPURCHASEORGID = DOO.FORGID
@@ -1118,10 +1120,8 @@
                                 model.Add("FPurOrgId", new JObject() { ["Fnumber"] = dr["FPURCHASEORGNUMBER"].ToString() }); //閲囪喘缁勭粐
                                 model.Add("FSupplierId", new JObject() { ["Fnumber"] = dr["FSUPPLIERNUMBER"].ToString() }); //渚涘簲鍟�
                                 model.Add("FPURCHASERID", new JObject() { ["Fnumber"] = dr["FPURCHASERNUMBER"].ToString() }); //閲囪喘鍛�
-                                                                                                                              //model.Add("F_xbkf_Base", new JObject() { ["Fnumber"] = dr["FRECEIVEMENNUMBER"].ToString() }); //鏀舵枡鍛�
                                 model.Add("FOwnerTypeIdHead", "BD_Supplier");//  璐т富绫诲瀷
                                 model.Add("FOwnerIdHead", new JObject() { ["Fnumber"] = dr["FSUPPLIERNUMBER"].ToString() });//璐т富 渚涘簲鍟� 
-                                                                                                                            //model.Add("F_XBKF_COMBO", dr["F_xbkf_Combo1"].ToString());//鏄惁鏈夌エ 
                                 JArray Fentity = new JArray();
                                 foreach (var item in drs)
                                 {
@@ -1174,7 +1174,7 @@
                                 };
                                 var loginRet = InvokeHelper.Login();
                                 var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
-                                if (isSuccess == 0)
+                                if (isSuccess <= 0)
                                 {
                                     objjson.code = "0";
                                     objjson.count = 0;
@@ -1231,8 +1231,8 @@
 JOIN {0}..T_PUR_POORDERENTRY_F CR ON    C.FENTRYID = CR.FENTRYID
 LEFT JOIN {0}..T_ORG_ORGANIZATIONS CROO ON CR.FSETTLEORGID = CROO.FORGID
 LEFT JOIN {0}..T_PUR_POORDER D ON C.FID =D.FID
-LEFT JOIN {0}..T_BAS_BILLTYPE T2 ON D.FBILLTYPEID = T2.FBILLTYPEID
-LEFT JOIN {0}..T_BAS_BILLTYPE_L T3 ON T2.FBILLTYPEID = T3.FBILLTYPEID
+LEFT JOIN {0}..T_BAS_BILLTYPE T2 ON D.FBILLTYPEID = T2.FBILLTYPEID 
+LEFT JOIN {0}..T_BAS_BILLTYPE_L T3 ON T2.FBILLTYPEID = T3.FBILLTYPEID  and FLOCALEID=2052
 LEFT JOIN  {0}..V_BD_BUYER T4 ON D.FPURCHASERID =T4.FID
 LEFT JOIN  {0}..T_HR_EMPINFO T5 ON D.F_XBKF_BASE1 = T5.FID
 LEFT JOIN {0}..T_BD_SUPPLIER DS ON D.FSUPPLIERID = DS.FSUPPLIERID
@@ -1330,7 +1330,7 @@
                                 };
                                 var loginRet = InvokeHelper.Login();
                                 var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
-                                if (isSuccess == 0)
+                                if (isSuccess < 0)
                                 {
                                     objjson.code = "0";
                                     objjson.count = 0;
@@ -1338,7 +1338,7 @@
                                     objjson.data = null;
                                     return objjson;
                                 }
-                                LogService.Write("jsonRoot:" + jsonRoot.ToString());
+                                //LogService.Write("jsonRoot:" + jsonRoot.ToString());
                                 var result = InvokeHelper.Save("PUR_ReceiveBill", jsonRoot.ToString());
                                 //LogService.Write(result);
                                 if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() == "TRUE")
@@ -1371,7 +1371,7 @@
                         }
                     }
                 }
-                var check = Get_ReciveBillCheckDate(HBillNo);
+                var check = Exec_ReciveBillCheck(HBillNo);
                 if (check.code == "0")
                     return check;
                 //if(check)
@@ -1410,6 +1410,11 @@
             return HInterID;
         }
 
+        /// <summary>
+        /// 鍒拌揣纭鎵敹鏂欓�氱煡鍗曞彿 鑾峰彇琛ㄤ綋鍜岃〃澶存暟鎹�
+        /// </summary>
+        /// <param name="HBarCode"></param>
+        /// <returns></returns>
         public json Get_ReciveBillCheckDate(string HBarCode)
         {
             json objjson = new json();
@@ -1438,7 +1443,7 @@
                     else
                     {
                         objjson.code = "0";
-                        objjson.count = 0; 
+                        objjson.count = 0;
                         objjson.Message = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRemark"]);
                         objjson.data = null;
                         return objjson;
@@ -1452,15 +1457,202 @@
                 objjson.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
                 objjson.data = null;
                 return objjson;
-               
+
+            }
+        }
+
+        [Route("POStockInBillList/AuditPOInStockBillPost")]
+        [HttpPost]
+        public object AuditPOInStockBill([FromBody] JObject msg)
+        {
+            try
+            {
+                string _msg = msg["msg"].ToString();
+                _msg = _msg.Replace("\\", "");
+                _msg = _msg.Replace("\n", "");
+                List<Models.ReciveBill_FastModel> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.ReciveBill_FastModel>>(_msg);
+                DAL.ClsCg_POInStockBill oBill = new DAL.ClsCg_POInStockBill();
+                var hinterID = list[0].HInterID;
+                var FID = list[0].FID;
+
+                #region 閲戣澏瀹℃牳鍚庝細閲嶆柊鍚屾鍗曟嵁鍒癿es 鏁呬笉闇�瑕佹洿鏂癿es鐨勬敹鏂欓�氱煡鍗� 
+                /*
+                oCn.BeginTran();
+                string sql = string.Empty;
+
+                foreach (var item in list)
+                {
+                    if (item.HSQty == 0)
+                        continue;
+                    sql = $"update Cg_POInStockBillSub set Hqty = {item.HSQty} where HInterID ={item.HInterID} and HEntryID = {item.HEntryID}";
+                    oCn.RunProc(sql);
+                }
+                oCn.RunProc("exec h_p_Cg_UpDatePOOrderRelation_Del " + hinterID);//鍒犻櫎鍏宠仈鍏崇郴
+                sql = string.Format(@"update Cg_POInStockBillMain set 
+HBillStatus = 2 ,
+HCheckDate   = getdate()
+where HInterID in ({0})", HInterID);
+                oCn.RunProc(sql);//鏇存柊mes鐘舵��  
+                //鏇存柊鎴愬姛鍚� 鍚屾鏇存柊閲戣澏
+                oCn.Commit();
+                **/
+                #endregion 
+
+                JObject jsonRoot = new JObject();
+                jsonRoot.Add("Creator", "");
+                jsonRoot.Add("NeedUpDateFields", new JArray());
+                jsonRoot.Add("NeedReturnFields", new JArray());
+                jsonRoot.Add("IsDeleteEntry", "false");
+                jsonRoot.Add("SubSystemId", "");
+                jsonRoot.Add("IsVerifyBaseDataField", "");
+
+                JObject jsonModel = new JObject();
+                jsonModel.Add("FID", FID);
+                JArray Entry = new JArray();
+                foreach (var item in list)
+                {
+                    if (item.HSQty == 0)
+                        continue;
+                    JObject jsonFPOOrderEntry = new JObject();
+                    jsonFPOOrderEntry.Add("FEntryID", item.FEntryID);
+                    jsonFPOOrderEntry.Add("FActReceiveQty ", item.HSQty); ;
+                    Entry.Add(jsonFPOOrderEntry);
+                }
+                jsonModel.Add("FDetailEntity", Entry);
+                jsonRoot.Add("Model", jsonModel);
+                var loginRet = InvokeHelper.Login();
+                var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
+                if (isSuccess <= 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = loginRet;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                var result = InvokeHelper.Save("PUR_ReceiveBill", jsonRoot.ToString());
+                //LogService.Write(result);
+                if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
+                {
+                    LogService.Write("鏀舵枡閫氱煡鍗曚慨鏀瑰け璐sonRoot:" + jsonRoot.ToString());
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "閲戣澏鏀舵枡閫氱煡鍗曟洿鏂板け璐�" + result;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                var json = new
+                {
+                    Ids = FID,
+                };
+                //鎻愪氦
+                var _result = InvokeHelper.Submit("PUR_ReceiveBill", JsonConvert.SerializeObject(json));
+                var _saveObj = JObject.Parse(_result);
+                if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
+                {
+                    LogService.Write("鏀舵枡閫氱煡鍗曟彁浜ゅけ璐sonRoot:" + jsonRoot.ToString());
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "閲戣澏鏀舵枡閫氱煡鍗曟彁浜ゅけ璐�" + _result;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+
+                }
+                //瀹℃牳
+                _result = InvokeHelper.Audit("PUR_ReceiveBill", JsonConvert.SerializeObject(json));
+                _saveObj = JObject.Parse(_result);
+                if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
+                {
+                    LogService.Write("鏀舵枡閫氱煡鍗曞鏍稿け璐sonRoot:" + jsonRoot.ToString());
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "閲戣澏鏀舵枡閫氱煡鍗曞鏍稿け璐sonRoot" + _result;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+
+                }
+
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎿嶄綔鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                //oCn.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "寮傚父锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+        }
+
+        /// <summary>
+        /// 鍒拌揣纭 鎵潯鐮� 鏍¢獙
+        /// </summary>
+        /// <param name="HBarcode"></param>
+        /// <param name="HInterID"></param>
+        /// <returns></returns>
+        [Route("POStockInBillList/Get_ReciveBillByBarcode")]
+        [HttpGet]
+        public object Get_ReciveBillByBarcode(string HBarcode, string HInterID)
+        {
+            try
+            {
+                //var code = HBarcode.Split('#')[0];
+                //鏍¢獙鏉$爜鏄惁瀛樺湪
+                string sql = $"select* from  Gy_BarCodeBill where HSourceInterID ={HInterID} and HBarCode = '{HBarcode.Split('#')[0]}' and HQty = {HBarcode.Split('#')[1]}";
+                DataSet ds = oCn.RunProcReturn(sql, "H_v_SRM_POOrderBillList");
+                if (ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏉$爜涓嶅瓨鍦紒";
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+                //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                //string sql = $"select * from H_v_SRM_POInStockBillList where 鍗曟嵁鍙� ='{HBillno}'";
+                //ds = oCn.RunProcReturn(sql, "H_v_SRM_POInStockBillList");
+                //if (ds == null || ds.Tables[0].Rows.Count == 0)
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+                //else
+                //{
+
+                //}
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
             }
         }
 
         //鏀舵枡閫氱煡鍗曞鏍� 瀹℃牳鎻愪氦
         [Route("POStockInBillList/Exec_ReciveBillCheck")]
         [HttpGet]
-        public object Exec_ReciveBillCheck(string HBarCode)
+        public json Exec_ReciveBillCheck(string HBarCode)
         {
+            json objjson = new json();
             try
             {
                 //淇敼閲戣澏鐢熶骇鍗曠殑鐘舵��
@@ -1470,11 +1662,11 @@
 
                 if (isSuccess == 0)
                 {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鎿嶄綔澶辫触,閲戣澏璐﹀彿鐧诲綍寮傚父銆�" + loginRet;
-                    objJsonResult.data = null;
-                    return objJsonResult;
+                    objjson.code = "0";
+                    objjson.count = 0;
+                    objjson.Message = "鎿嶄綔澶辫触,閲戣澏璐﹀彿鐧诲綍寮傚父銆�" + loginRet;
+                    objjson.data = null;
+                    return objjson;
                 }
                 var json = new
                 {
@@ -1499,25 +1691,25 @@
                 //鍒ゆ柇瀹℃牳鏄惁鎴愬姛
                 if (JObject.Parse(result2)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
                 {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "瀹℃牳鏀舵枡閫氱煡鍗曞け璐ワ紒鍗曟嵁鍙凤細" + HBarCode;
-                    objJsonResult.data = null;
-                    return objJsonResult;
+                    objjson.code = "0";
+                    objjson.count = 0;
+                    objjson.Message = "瀹℃牳鏀舵枡閫氱煡鍗曞け璐ワ紒鍗曟嵁鍙凤細" + HBarCode;
+                    objjson.data = null;
+                    return objjson;
                 }
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "瀹℃牳鎴愬姛锛�";
                 objJsonResult.data = 1;
-                return objJsonResult;
+                return objjson;
             }
             catch (Exception e)
             {
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
-                objJsonResult.data = null;
-                return objJsonResult;
+                objjson.code = "0";
+                objjson.count = 0;
+                objjson.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objjson.data = null;
+                return objjson;
             }
 
         }

--
Gitblit v1.9.1