From 2f1e5677f07865c998d62b623cf40bf51a9e2b55 Mon Sep 17 00:00:00 2001 From: yusijie <ysj@hz-kingdee.com> Date: 星期五, 13 一月 2023 18:52:54 +0800 Subject: [PATCH] 单据同步(收料通知单;采购订单;退料通知单;生产订单;生产用料清单;销售订单;发货通知单;退货通知单;生产汇报单) --- WebAPI/Controllers/生产管理/生产任务单/Sc_ICMOBillController.cs | 329 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 329 insertions(+), 0 deletions(-) diff --git "a/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs" "b/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs" index 3caf227..82e4b73 100644 --- "a/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs" +++ "b/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs" @@ -23,6 +23,9 @@ SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); DataSet ds; + //鑾峰彇绯荤粺鍙傛暟 + Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); + #region 鐢熶骇浠诲姟鍗� 淇濆瓨/缂栬緫鍔熻兘 [Route("Sc_ICMOBill/ICMOBillEdit")] [HttpPost] @@ -1080,5 +1083,331 @@ #endregion + #region [鍚屾鍗曟嵁] + [Route("Sc_ICMOBill/Sc_ICMOBillViewApi")] + [HttpGet] + public json Sc_ICMOBillViewApi(string BillNo, string BillType) + { + string sql = string.Empty; + string sReturn = ""; + if (oSystemParameter.ShowBill(ref sReturn) == true) + { + //绯荤粺鍙傛暟鏄惁涓虹鏈変簯妯″紡,N涓哄叕鏈変簯妯″紡锛孻涓虹鏈変簯妯″紡 + if (oSystemParameter.omodel.WMS_CloudMode == "Y") + { + #region [绉佹湁浜戞ā寮忥紝鐩存帴璋冪敤鏁版嵁搴撳瓨鍌ㄨ繃绋嬫洿鏂癩 + try + { + oCN.BeginTran(); + SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); + DataSet DS = oCn.RunProcReturn("exec h_p_WMS_ERPSourceBillToLocal '" + BillNo + "','" + BillType + "'", "h_p_WMS_ERPSourceBillToLocal"); + if (DS == null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鍚屾澶辫触"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + if (DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HBack"]) == "2") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "ERP涓笉瀛樺湪璇ュ崟鎹彿"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍗曟嵁鍚屾鎴愬姛"; + objJsonResult.data = null; + return objJsonResult; + } + } + + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + #endregion + } + else + { + #region [鍏湁浜戞ā寮忥紝璋冪敤WEBAPI鐨勬柟寮忚繘琛屾洿鏂癩 + var json = new + { + CreateOrgId = 0, + Number = BillNo, + Id = "" + }; + #region [閲戣澏閮ㄥ垎] + //鐧诲綍閲戣澏 + 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.View("PRD_MO", JsonConvert.SerializeObject(json)); + var _saveObj = JObject.Parse(_result); + //鍒ゆ柇鏁版嵁鏄惁鑾峰彇鎴愬姛 + if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "閲戣澏鏀舵枡閫氱煡鍗曞悓姝ュけ璐sonRoot锛�" + _result; + objJsonResult.data = null; + return objJsonResult; + } + + #endregion + //鑾峰彇涓昏〃鏁版嵁 + DataSet Ds; + Int64 InterID = 0; + Ds = oCN.RunProcReturn("select * from Sc_ICMOBillMain where HBillNo = '" + BillNo + "'", "Sc_ICMOBillMain"); + if (Ds.Tables[0].Rows.Count != 0 && ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString()) != 0) + { + InterID = ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString()); + } + + #region [涓昏〃鏁版嵁璧嬪�糫 + var jsonData = new + { + HInterID = _saveObj["Result"]["Result"]["Id"], + HYear = DateTime.Now.Year, + HPeriod = DateTime.Now.Month, + HBillType = 3710, + HDate = _saveObj["Result"]["Result"]["Date"], + HBillNo = _saveObj["Result"]["Result"]["BillNo"], + HBillStatus = _saveObj["Result"]["Result"]["ApproverId_Id"].ToString() == Convert.ToString(0) ? 1 : 2, + HEMPID = 0, + HRoutingInterID = 0, + HPlanQty = 1, + HRelationQty = 0, + HPlanBeginDate = _saveObj["Result"]["Result"]["Date"], + HPlanEndDate = DateTime.Now.ToString(), + HBeginDate = _saveObj["Result"]["Result"]["Date"], + HEndDate = DateTime.Now.ToString(), + HMaterID = 0, + HUnitID = 0, + HBomID = 0, + HBatchNo = "", + HSourceInterID = 0, + HSourceEntryID = 0, + HSourceBillNo = "", + HSourceBillType = "", + HSeOrderInterID = 0, + HSeOrderEntryID = 0, + HSeOrderBillNo = "", + HPRDORGID = _saveObj["Result"]["Result"]["PrdOrgId_Id"], + HENTRUSTORGID = _saveObj["Result"]["Result"]["ENTrustOrgId_Id"], + HOWNERID = _saveObj["Result"]["Result"]["OwnerId_Id"], + HOWNERTYPEID = _saveObj["Result"]["Result"]["OwnerTypeId"], + HCusID = 0, + HDeptID = _saveObj["Result"]["Result"]["WorkShopID_Id"].ToString() == null ? 0 : _saveObj["Result"]["Result"]["WorkShopID_Id"], + HRemark = "CLOUD瀵煎叆", + HMTONo = "", + HERPInterID = _saveObj["Result"]["Result"]["Id"], + HERPBillType = _saveObj["Result"]["Result"]["BillType_Id"], + HMaker = _saveObj["Result"]["Result"]["CreatorId"]["Name"], + HMakeDate = _saveObj["Result"]["Result"]["CreateDate"], + HChecker = _saveObj["Result"]["Result"]["ApproverId"]["Name"], + HCheckDate = _saveObj["Result"]["Result"]["ApproveDate"], + HBillSubType = _saveObj["Result"]["Result"]["IsRework"] = true ? 1 : 0, + HISENTRUST = _saveObj["Result"]["Result"]["IsEntrust"], + HISREWORK = _saveObj["Result"]["Result"]["IsRework"] + }; + #endregion + // 鍒犻櫎涓昏〃瀵瑰簲鏁版嵁 + sql = $"delete from Sc_ICMOBillMain where HInterID = " + InterID; + oCN.RunProc(sql); + + //鎻掑叆涓昏〃 + sql = $@" + insert into Sc_ICMOBillMain + (HInterID,HYear,HPeriod,HBillType,HDate + ,HBillNo,HBillStatus,HEMPID,HRoutingInterID + ,HPlanQty,HRelationQty,HPlanBeginDate,HPlanEndDate,HBeginDate,HEndDate + ,HMaterID,HUnitID,HBomID,HBatchNo + ,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo + ,HPRDORGID,HENTRUSTORGID,HOWNERID,HOWNERTYPEID + ,HCusID,HDeptID,HRemark,HMTONo,HERPInterID,HERPBillType + ,HMaker,HMakeDate,HChecker,HCheckDate + ,HBillSubType,HISENTRUST,HISREWORK + ) + values + ({jsonData.HInterID},{jsonData.HYear},{jsonData.HPeriod},{jsonData.HBillType},'{jsonData.HDate}','{jsonData.HBillNo}', + {jsonData.HBillStatus},{jsonData.HEMPID},{jsonData.HRoutingInterID},{jsonData.HPlanQty},{jsonData.HRelationQty}, + '{jsonData.HPlanBeginDate}', '{jsonData.HPlanEndDate}','{jsonData.HBeginDate}','{jsonData.HEndDate}',{jsonData.HMaterID}, + {jsonData.HUnitID},{jsonData.HBomID},'{jsonData.HBatchNo}',{jsonData.HSourceInterID},{jsonData.HSourceEntryID}, + '{jsonData.HSourceBillNo}','{jsonData.HSourceBillType}',{jsonData.HSeOrderInterID}, {jsonData.HSeOrderEntryID},'{jsonData.HSeOrderBillNo}', + {jsonData.HPRDORGID},{jsonData.HENTRUSTORGID},{jsonData.HOWNERID},'{jsonData.HOWNERTYPEID}',{jsonData.HCusID},{jsonData.HDeptID}, + '{jsonData.HRemark}','{jsonData.HMTONo}',{jsonData.HERPInterID},'{jsonData.HERPBillType}','{jsonData.HMaker}','{jsonData.HMakeDate}', + '{jsonData.HChecker}','{jsonData.HCheckDate}','{jsonData.HBillSubType}','{jsonData.HISENTRUST}','{jsonData.HISREWORK}')"; + + oCN.RunProc(sql); + + #region [鐢宠瀛愯〃鍙橀噺] + var dataArr = _saveObj["Result"]["Result"]["TreeEntity"]; + + DataSet Cs; + double RelationQty = 0; + #endregion + int i = 0; + + // 鑾峰彇瀛愯〃鏁版嵁 + Cs = oCN.RunProcReturn("select * from Sc_ICMOBillSub where HInterID = " + InterID, "Sc_ICMOBillSub"); + // 鍒犻櫎瀛愯〃瀵瑰簲鏁版嵁 + sql = $"delete from Sc_ICMOBillSub where HInterID = " + InterID; + oCN.RunProc(sql); + + foreach (var oSub in dataArr) + { + #region [瀛愯〃鏁版嵁璧嬪�糫 + + if (Cs.Tables[0].Rows.Count != 0 && ClsPub.isLong(Cs.Tables[0].Rows[0]["HInterID"].ToString()) != 0) + { + RelationQty = ClsPub.isDoule(Cs.Tables[0].Rows[i]["HRelationQty"].ToString()); + + i++; + } + + var subData = new + { + HInterID = _saveObj["Result"]["Result"]["Id"], + HENTRYID = oSub["Id"], + HSEQ = oSub["Seq"], + HQty = oSub["Qty"], + HQTYMUST = oSub["Qty"], + HRelationQty = RelationQty, + HRelationMoney = 0, + HPlanBeginDate = oSub["IdPlanStartDate"], + HPlanEndDate = oSub["PlanFinishDate"], + HBeginDate = oSub["StartDate"], + HEndDate = oSub["FinishDate"], + HBomID = oSub["BomId_Id"], + HRemark = "CLOUD瀵煎叆", + HMaterID = oSub["MaterialId_Id"], + HUnitID = oSub["UnitId_Id"], + HWHID = oSub["StockId_Id"], + HSPID = oSub["StockLocId_Id"], + HPROCID = oSub["ProcessId_Id"], + HDEPTID = oSub["WorkShopID_Id"], + HBatchNo = oSub["Lot_Text"], + HSourceInterID = oSub["SrcBillId"], + HSourceEntryID = oSub["SrcBillEntryId"], + HSourceBillNo = oSub["SrcBillNo"], + HSourceBillType = oSub["SrcBillType"], + HSeOrderInterID = oSub["SaleOrderId"], + HSeOrderEntryID = oSub["SaleOrderEntryId"], + HSeOrderBillNo = oSub["SaleOrderNo"], + HSTOCKINORGID = oSub["StockInOrgId_Id"], + HINSTOCKOWNERID = oSub["InStockOwnerId_Id"], + HINSTOCKOWNERTYPEID = oSub["InStockOwnerTypeId"], + HREQUESTORGID = oSub["RequestOrgId_Id"], + HPlanMode = 0, + HMTONo = oSub["MTONo"], + HERPInterID = _saveObj["Result"]["Result"]["Id"], + HERPEntryID = oSub["Id"], + HSTATUS = oSub["Status"], + HEntryCusID = 0, + HICMOReportRelationQty = oSub["RepQuaSelAuxQty"], + HAuxPropID = oSub["AuxPropId_Id"], + HProdMaterCode = "", + HCusShortName = "", + HCusNeedMaterial = "", + HPlanSendGoodsDate = "", + HProdMaterName = "", + HWorkRemark = "", + HImportNote = "", + HCusName = "", + HInstockQty_Max = 0, + HInstockQty_Min = 0, + HPickLabel = "", + HPickLabelNumber = oSub["StockInLimitH"], + HCusNumber = oSub["StockInLimitL"], + HINSTOCKTYPE = oSub["InStockType"], + HCHECKPRODUCT = oSub["CheckProduct"], + HQAIP = oSub["QAIP"], + HISBACKFLUSH = oSub["ISBACKFLUSH"], + HREQSRC = oSub["ReqSrc"], + HSTOCKINQUASELAUXQTY = oSub["StockInQuaSelAuxQty"], + HSeOrderEntrySEQ = oSub["SaleOrderEntrySeq"], + HPROJECTNO = oSub["ProjectNo"], + HPRODUCTTYPE = oSub["ProductType"], + HCOSTRATE = oSub["CostRate"], + HBASEUNITID = oSub["BaseUnitId_Id"], + }; + #endregion + + //鎻掑叆瀛愯〃 + sql = $@" + insert into Sc_ICMOBillSub + (HInterID,HENTRYID,HSEQ,HQty,HQTYMUST,HRelationQty,HRelationMoney + ,HPlanBeginDate,HPlanEndDate,HBeginDate,HEndDate,HBomID,HRemark + ,HMaterID,HUnitID,HWHID,HSPID,HPROCID,HDEPTID,HBatchNo + ,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType + ,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo + ,HSTOCKINORGID,HINSTOCKOWNERID,HINSTOCKOWNERTYPEID,HREQUESTORGID + ,HPlanMode,HMTONo,HERPInterID,HERPEntryID,HSTATUS + ,HEntryCusID,HICMOReportRelationQty,HAuxPropID,HProdMaterCode,HCusShortName + ,HCusNeedMaterial,HPlanSendGoodsDate,HProdMaterName,HWorkRemark,HImportNote,HCusName + ,HInstockQty_Max,HInstockQty_Min,HPickLabel,HPickLabelNumber,HCusNumber + ,HINSTOCKTYPE,HCHECKPRODUCT,HQAIP,HISBACKFLUSH,HREQSRC,HSTOCKINQUASELAUXQTY + ,HSeOrderEntrySEQ,HPROJECTNO,HPRODUCTTYPE,HCOSTRATE,HBASEUNITID + ) + values + ({subData.HInterID},{subData.HENTRYID},{subData.HSEQ},{subData.HQty},{subData.HQTYMUST},{subData.HRelationQty}, + {subData.HRelationMoney},'{subData.HPlanBeginDate}','{subData.HPlanEndDate}','{subData.HBeginDate}','{subData.HEndDate}',{subData.HBomID}, + '{subData.HRemark}',{subData.HMaterID},{subData.HUnitID},{subData.HWHID},{subData.HSPID},{subData.HPROCID},{subData.HDEPTID}, + '{subData.HBatchNo}',{subData.HSourceInterID},{subData.HSourceEntryID},'{subData.HSourceBillNo}','{subData.HSourceBillType}', + {subData.HSeOrderInterID},{subData.HSeOrderEntryID},'{subData.HSeOrderBillNo}',{subData.HSTOCKINORGID},{subData.HINSTOCKOWNERID}, + '{subData.HINSTOCKOWNERTYPEID}',{subData.HREQUESTORGID},'{subData.HPlanMode}','{subData.HMTONo}',{subData.HERPInterID}, + {subData.HERPEntryID},{subData.HSTATUS},{subData.HEntryCusID},{subData.HICMOReportRelationQty},{subData.HAuxPropID}, + '{subData.HProdMaterCode}','{subData.HCusShortName}','{subData.HCusNeedMaterial}','{subData.HPlanSendGoodsDate}', + '{subData.HProdMaterName}','{subData.HWorkRemark}','{subData.HImportNote}','{subData.HCusName}',{subData.HInstockQty_Max}, + {subData.HInstockQty_Min},'{subData.HPickLabel}',{subData.HPickLabelNumber},{subData.HCusNumber},'{subData.HINSTOCKTYPE}', + '{subData.HCHECKPRODUCT}','{subData.HQAIP}','{subData.HISBACKFLUSH}','{subData.HREQSRC}',{subData.HSTOCKINQUASELAUXQTY}, + {subData.HSeOrderEntrySEQ},'{subData.HPROJECTNO}','{subData.HPRODUCTTYPE}',{subData.HCOSTRATE},{subData.HBASEUNITID})"; + + oCN.RunProc(sql); + } + + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍗曟嵁鍚屾鎴愬姛锛�"; + objJsonResult.data = null; + return objJsonResult; + + #endregion + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁璇诲彇澶辫触锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + } } \ No newline at end of file -- Gitblit v1.9.1