From be324e1dc4df9e72b0b8986d596b723404804f22 Mon Sep 17 00:00:00 2001 From: ch <37327@LLOOCCY> Date: 星期二, 15 十一月 2022 10:05:06 +0800 Subject: [PATCH] 修改了出站汇报单生成生产入库单方法 --- WebAPI/Controllers/POStockInBillController.cs | 390 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 368 insertions(+), 22 deletions(-) diff --git a/WebAPI/Controllers/POStockInBillController.cs b/WebAPI/Controllers/POStockInBillController.cs index 6ff55fd..49d4a0b 100644 --- a/WebAPI/Controllers/POStockInBillController.cs +++ b/WebAPI/Controllers/POStockInBillController.cs @@ -90,6 +90,7 @@ WebS.ClsKf_ICStockBill_WMS WebSoBar = new WebS.ClsKf_ICStockBill_WMS(); string sExpressNumber = ""; WebSoBar = oWebs.get_CheckTypeByBarCode_All(sCode, sInterID, HBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID, sExpressNumber, ref DBUtility.ClsPub.sErrInfo); + //WebSoBar = oWebs.get_ba(sCode, sInterID, HBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID, sExpressNumber, ref DBUtility.ClsPub.sErrInfo); if (WebSoBar == null) { objJsonResult.code = "0"; @@ -156,6 +157,76 @@ objJsonResult.data = WebSoBar; return objJsonResult; } + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = e.Message + ";" + e.StackTrace; + objJsonResult.data = null; + return objJsonResult; + } + + } + + + [Route("kf_PoStockInBill/JX_Json")] + [HttpGet] + public Object JX_Json(string sBarCodeNew,Int64 HOrgID) + { + try + { + string[] sArray = sBarCodeNew.Split('@'); + string HMaterNumber = ""; + HMaterNumber = sArray[0]; + Int64 HQty = 0; + HQty = ClsPub.isInt(sArray[4]); + string HBarchNo = ""; + HBarchNo = sArray[6]; + + Int64 HMaterID = 0; + + SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); + DataSet Dss; + Dss = oCn.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList"); + string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]); + + DataSet Dss1; + Dss1 = oCn.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and huseorgid = " + HOrgID, "Gy_Material"); + HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]); + string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]); + string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]); + Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]); + + string HTM = ""; + HTM = HOrgNumber + HMaterID + HBarchNo; + string ModName = "85"; + HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo); + oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" + + ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" + + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " + + ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " + + ",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate " + + ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " + + ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " + + ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo " + + ") values (" + + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString() + + ",'" + HBarchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString() + + ", 0,0,'','',0" + + ", 0,'',0,0,0,''" + + ",0,'','','',getdate()" + + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1" + + ",0,0,0" + + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','')"); + + + string sExpressNumber = ""; + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = DBUtility.ClsPub.sErrInfo; + objJsonResult.data = HTM; + return objJsonResult; } catch (Exception e) { @@ -409,6 +480,55 @@ return objJsonResult; } } + + + + + + + [Route("Kf_QCStockInCheckBill_Fast/BarCode_Json")] + [HttpGet] + public object BarCode_Json(string HBarCode) + { + try + { + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + ds = oCN.RunProcReturn("select * from h_v_QCStockInCheckBill_Json where 鏉$爜缂栧彿 ='" + HBarCode.ToString() + "'" , "h_v_QCStockInCheckBill_Json"); + if (ds == null || ds.Tables[0].Rows.Count <= 0) + { + + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�"; + objJsonResult.data = null; + return objJsonResult; + //DBUtility.ClsPub.MessageBeep((int)DBUtility.ClsPub.BeepType.Warning); + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�"; + objJsonResult.data = ds.Tables[0]; + return objJsonResult; + } + } + catch (Exception e) + { + + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + + + + + + /// <summary> @@ -847,8 +967,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) @@ -985,7 +1103,6 @@ } catch (Exception) { - objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "鍒犻櫎澶辫触锛�"; @@ -1003,25 +1120,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) { @@ -1411,6 +1530,11 @@ return HInterID; } + /// <summary> + /// 鍒拌揣纭鎵敹鏂欓�氱煡鍗曞彿 鑾峰彇琛ㄤ綋鍜岃〃澶存暟鎹� + /// </summary> + /// <param name="HBarCode"></param> + /// <returns></returns> public json Get_ReciveBillCheckDate(string HBarCode) { json objjson = new json(); @@ -1457,6 +1581,228 @@ } } + [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 鏍¢獙鏄惁鎵弿鏉$爜 + var HInterID = list[0].HInterID; + string jysql = string.Format(@"select * from KF_PonderationBillMain_Temp where HSourceInterID = {0}", HInterID); + DataTable jyDt =oCn.RunProcReturn(jysql, "jysql").Tables[0]; + if (jyDt.Rows.Count == 0 || jyDt == null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "璇锋壂鎻忔潯鐮�"; + objJsonResult.data = null; + return objJsonResult; + } + #endregion + #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 HItemID,HSourceBillNo 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; + } + else + { + //瀛樺叆鏉$爜涓存椂琛� + sql = $"delete from KF_PonderationBillMain_Temp Where HBillNo='{ds.Tables[0].Rows[0]["HSourceBillNo"]}' "; + oCn.RunProc(sql); + sql = string.Format(@"Insert into KF_PonderationBillMain_Temp + (HInterID,HBillNo,HBillType,HMaterID,HProcID,HWhID,HSCWHID + ,HStockPlaceID,HOutStockPlaceID,HGroupID,HQty,HQtyMust,HPieceQty + ,HAuxPropID,HBatchNo,HBarCode,HAddr,HMaker,HMakeDate + ,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo,HMTONo + ,HSTOCKORGID,HOWNERID,HExpressNumber,HSubBillType + ,HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag + ,HCusID) + select HInterID,HSourceBillNo,HBillType,HMaterID,0,0,0 + ,0,0,0,HQty,HQty,0 + ,HAuxPropID,HBatchNo,'','','System',getdate() + ,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo,HMTONo + ,HSTOCKORGID,HOWNERID,'',HBillType + ,0,0,'',0 + ,0 from Gy_BarCodeBill + where HItemID = {0}", ds.Tables[0].Rows[0]["HItemID"]); + oCn.RunProc(sql); + } + + 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] -- Gitblit v1.9.1