diff --git a/ICSSoft.FromERP/ICSSoft.FromERP/ICSDispatchDoc.cs b/ICSSoft.FromERP/ICSSoft.FromERP/ICSDispatchDoc.cs index d0d8d40..75ce4a8 100644 --- a/ICSSoft.FromERP/ICSSoft.FromERP/ICSDispatchDoc.cs +++ b/ICSSoft.FromERP/ICSSoft.FromERP/ICSDispatchDoc.cs @@ -56,7 +56,7 @@ namespace ICSSoft.FromERP { SAPDispatchGet.ZWMS_SK_DO_READ client = new SAPDispatchGet.ZWMS_SK_DO_READ(); SAPDispatchGet.ZWMS_SK_DO_READ1 Info = new SAPDispatchGet.ZWMS_SK_DO_READ1(); - Info.VBELN = DocNO; + Info.VBELN = "74000321"; Info.CHG_DATE = ""; Info.T_HEAD = new SAPDispatchGet.ZWMS_DO_HEAD[1]; Info.T_ITEM = new SAPDispatchGet.ZWMS_DO_ITEM[1]; diff --git a/ICSSoft.FromERP/ICSSoft.FromERP/ICSSAPDocGet.cs b/ICSSoft.FromERP/ICSSoft.FromERP/ICSSAPDocGet.cs index dedba15..da9d6a8 100644 --- a/ICSSoft.FromERP/ICSSoft.FromERP/ICSSAPDocGet.cs +++ b/ICSSoft.FromERP/ICSSoft.FromERP/ICSSAPDocGet.cs @@ -55,9 +55,9 @@ namespace ICSSoft.FromERP { SAPGetDocInfo.ZWMS_SK_WS_HEAD client = new SAPGetDocInfo.ZWMS_SK_WS_HEAD(); SAPGetDocInfo.ZWMS_SK_WS_HEAD1 DocInfo = new SAPGetDocInfo.ZWMS_SK_WS_HEAD1(); - DocInfo.DANJU = "00000000000"; + DocInfo.DANJU = "1701096630"; DocInfo.WERKS = dr["WorkPointCode"].ToString(); - DocInfo.CHG_DATE = Date; + DocInfo.CHG_DATE = ""; DocInfo.SET_NOTMODIFY = ""; DocInfo.CLEAR_NOTMODIFY = ""; DocInfo.Z_HEAD = new SAPGetDocInfo.ZWMS_SK_HEAD[1]; @@ -350,8 +350,8 @@ namespace ICSSoft.FromERP } #endregion - #region 生产领料单同步(单据类型:01 03 09 17) - HeadInfo = HeadInfoList.Where(a => a.LEIXING == "01" || a.LEIXING == "03" || a.LEIXING == "09" || a.LEIXING == "17"); + #region 生产领料单同步(单据类型:01 03 17) + HeadInfo = HeadInfoList.Where(a => a.LEIXING == "01" || a.LEIXING == "03" || a.LEIXING == "17"); foreach (SAPGetDocInfo.ZWMS_SK_HEAD Info in HeadInfo) { try @@ -490,8 +490,8 @@ namespace ICSSoft.FromERP } #endregion - #region 生产退料单同步(单据类型:02 04 10) - HeadInfo = HeadInfoList.Where(a => a.LEIXING == "02" || a.LEIXING == "04" || a.LEIXING == "10"); + #region 生产退料单同步(单据类型:02 04) + HeadInfo = HeadInfoList.Where(a => a.LEIXING == "02" || a.LEIXING == "04"); foreach (SAPGetDocInfo.ZWMS_SK_HEAD Info in HeadInfo) { try @@ -673,7 +673,7 @@ namespace ICSSoft.FromERP line.Quantity = Item.LINGYSL;//领用数量 line.Amount = 0; line.WHCode = Item.LGORT;//仓库 - if (Info.TEST1 == "0")//Info.TEST1=0为SAP未过账入库单 Info.TEST1=1为SAP已过账入库单 + if (Info.TEST1 == "N")//Info.TEST1=N为SAP未过账入库单 Info.TEST1=Y为SAP已过账入库单 { line.Status = "1"; } diff --git a/ICSSoft.FromERP/ICSSoft.FromERP/Properties/Settings.Designer.cs b/ICSSoft.FromERP/ICSSoft.FromERP/Properties/Settings.Designer.cs index 1ae3e4e..da58d5f 100644 --- a/ICSSoft.FromERP/ICSSoft.FromERP/Properties/Settings.Designer.cs +++ b/ICSSoft.FromERP/ICSSoft.FromERP/Properties/Settings.Designer.cs @@ -37,8 +37,8 @@ namespace ICSSoft.FromERP.Properties { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.WebServiceUrl)] - [global::System.Configuration.DefaultSettingValueAttribute("http://ERPQA1.neway.com.cn:8000/sap/bc/srt/rfc/sap/zwms_sk_ws_head/900/zwms_sk_ws" + - "_head/zwms_sk_ws_head")] + [global::System.Configuration.DefaultSettingValueAttribute("http://58.210.216.118:8072/sap/bc/srt/rfc/sap/zwms_sk_ws_head/900/zwms_sk_ws_head" + + "/zwms_sk_ws_head")] public string ICSSoft_FromERP_SAPGetDocInfo_ZWMS_SK_WS_HEAD { get { return ((string)(this["ICSSoft_FromERP_SAPGetDocInfo_ZWMS_SK_WS_HEAD"])); diff --git a/ICSSoft.FromERP/ICSSoft.FromERP/Properties/Settings.settings b/ICSSoft.FromERP/ICSSoft.FromERP/Properties/Settings.settings index cde10e7..6406ddf 100644 --- a/ICSSoft.FromERP/ICSSoft.FromERP/Properties/Settings.settings +++ b/ICSSoft.FromERP/ICSSoft.FromERP/Properties/Settings.settings @@ -6,7 +6,7 @@ http://58.210.216.118:8072/sap/bc/srt/rfc/sap/zwms_sk_mara/900/zwms_sk_mara/zwms_sk_mara - http://ERPQA1.neway.com.cn:8000/sap/bc/srt/rfc/sap/zwms_sk_ws_head/900/zwms_sk_ws_head/zwms_sk_ws_head + http://58.210.216.118:8072/sap/bc/srt/rfc/sap/zwms_sk_ws_head/900/zwms_sk_ws_head/zwms_sk_ws_head http://58.210.216.118:8072/sap/bc/srt/rfc/sap/zwms_sk_ws_check/900/zwms_sk_ws_check/zwms_sk_ws_check diff --git a/ICSSoft.FromERP/ICSSoft.FromERP/Web References/SAPGetDocInfo/document.wsdl b/ICSSoft.FromERP/ICSSoft.FromERP/Web References/SAPGetDocInfo/document.wsdl index 815c61f..ee94551 100644 --- a/ICSSoft.FromERP/ICSSoft.FromERP/Web References/SAPGetDocInfo/document.wsdl +++ b/ICSSoft.FromERP/ICSSoft.FromERP/Web References/SAPGetDocInfo/document.wsdl @@ -329,7 +329,7 @@ - + \ No newline at end of file diff --git a/ICSSoft.FromERP/ICSSoft.Test/Program.cs b/ICSSoft.FromERP/ICSSoft.Test/Program.cs index 035bb60..83b5240 100644 --- a/ICSSoft.FromERP/ICSSoft.Test/Program.cs +++ b/ICSSoft.FromERP/ICSSoft.Test/Program.cs @@ -13,7 +13,7 @@ namespace ICSSoft.Test //ICSVendor test = new ICSVendor(); //test.Execute(); - ICSDeliveryNotice test = new ICSDeliveryNotice(); + ICSSAPDocGet test = new ICSSAPDocGet(); test.Execute(); } diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSManufactureService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSManufactureService.cs index 7e46e15..90ec0dc 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSManufactureService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSManufactureService.cs @@ -688,7 +688,7 @@ namespace ICSSoft.DataProject SAPCallBackDoc.ZWMS_SK_WS_PZ1 Info = new SAPCallBackDoc.ZWMS_SK_WS_PZ1(); Info.NEWID = Identification; Info.DANJU = dt.Rows[i]["ApplyNegCode"].ToString(); - Info.STATE = "1"; + Info.STATE = "0"; List ItemList = new List(); Info.Z_GERNR = new SAPCallBackDoc.ZWEBS_GERNR[1]; Info.Z_FLAG = new SAPCallBackDoc.ZWEB_RETURN[1]; @@ -970,46 +970,72 @@ namespace ICSSoft.DataProject { try { - #region ERP开立状态单据审核 - string sql = @"IF EXISTS(SELECT b.ID FROM ICSManufactureReceive b - WHERE b.RCVCode+b.WorkPoint IN (SELECT a.TransCode+a.WorkPoint FROM ICSWareHouseLotInfoLog a WHERE a.Identification='{0}') - AND b.Quantity!=b.RCVQuantity) - BEGIN - RAISERROR('" + language.GetNameByCode("WMSAPIInfo096") + @"',16,1); - RETURN - END - SELECT b.RCVID AS ID,a.MUSER AS [User],SYSDATETIME() AS MTime,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock,a.WorkPoint - FROM ICSWareHouseLotInfoLog a - INNER JOIN ICSManufactureReceive b ON a.TransCode=b.RCVCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint - INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint - INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock004' AND a.WorkPoint=conStock.WorkPoint - WHERE a.Identification='{0}' AND ERPUpload='0' - GROUP BY b.RCVID,a.MUSER,con.Enable,conStock.Enable,a.WorkPoint"; + #region SAP + string IsSuccess = ""; + string ErrorMessage = ""; + string sql = @" select Distinct A.RCVCode,A.WorkPoint from ICSManufactureReceive A + LEFT JOIN ICSWareHouseLotInfoLog B ON B.TransCode=A.RCVCode AND B.WorkPoint=A.WorkPoint + where B.Identification='{0}' AND BusinessCode='18'"; sql = string.Format(sql, Identification); DataTable dt = DBHelper.SQlReturnData(sql, cmd); - - string Inputstr = JsonConvert.SerializeObject(dt); - string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.ICSManufactureReceiveURL, Inputstr); - Result result = new Result(); - result = JsonConvert.DeserializeObject(resultStr); - if (result.Success) + if (dt.Rows.Count > 1) { - try + throw new Exception(language.GetNameByCode("WMSAPIInfo202"));//单次提交单据数量卡控(只允许一张单据) + } + for (int i = 0; i < dt.Rows.Count; i++) + { + string chksql = @"select SUM(Quantity) AS Quantity,SUM(RCVQuantity) AS RCVQuantity from ICSManufactureReceive + where RCVCode='{0}' and WorkPoint='{1}' + GROUP BY RCVCode,WorkPoint"; + chksql = string.Format(chksql, dt.Rows[i]["RCVCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString()); + DataTable chkdt = DBHelper.SQlReturnData(chksql, cmd); + if (Convert.ToDecimal(chkdt.Rows[0]["Quantity"]) != Convert.ToDecimal(chkdt.Rows[0]["RCVQuantity"])) { - foreach (DataRow dr in dt.Rows) + throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo203"), chkdt.Rows[0]["Quantity"].ToString(), chkdt.Rows[0]["RCVQuantity"].ToString()));//单次提交数量卡控(必须整单提交) + } + SAPCallBackDoc.ZWMS_SK_WS_PZ Client = new SAPCallBackDoc.ZWMS_SK_WS_PZ(); + SAPCallBackDoc.ZWMS_SK_WS_PZ1 Info = new SAPCallBackDoc.ZWMS_SK_WS_PZ1(); + Info.NEWID = Identification; + Info.DANJU = dt.Rows[i]["RCVCode"].ToString(); + Info.STATE = "0"; + List ItemList = new List(); + Info.Z_GERNR = new SAPCallBackDoc.ZWEBS_GERNR[1]; + Info.Z_FLAG = new SAPCallBackDoc.ZWEB_RETURN[1]; + sql = @"select A.RCVCode,A.Sequence,A.Quantity,A.RCVQuantity,B.BatchCode from ICSManufactureReceive A + LEFT JOIN ICSExtension B ON B.ID=A.ExtensionID AND B.WorkPoint=A.WorkPoint + WHERE RCVCode='{0}' AND A.WorkPoint='{1}'"; + sql = string.Format(sql, dt.Rows[i]["RCVCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString()); + DataTable Sapdt = DBHelper.SQlReturnData(sql, cmd); + foreach (DataRow dr in Sapdt.Rows) + { + if (Convert.ToDecimal(dr["Quantity"].ToString()) == Convert.ToDecimal(dr["RCVQuantity"].ToString())) { - ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, dr["ID"].ToString(), Identification, "", "", "", "", "", cmd, language, BusinessCode); + SAPCallBackDoc.ZWMS_PZ Item = new SAPCallBackDoc.ZWMS_PZ(); + Item.DANJU = dr["RCVCode"].ToString(); + Item.POSNR = dr["Sequence"].ToString(); + Item.LINGYSL = System.Decimal.Round(Convert.ToDecimal(dr["Quantity"].ToString()), 3); + Item.SERNP = dr["BatchCode"].ToString(); + ItemList.Add(Item); } } - catch (Exception ex) + if (ItemList.Count > 0) { - log.Debug(ex.ToString()); - log.Debug(resultStr); + Info.Z_ITEM = ItemList.ToArray(); + SAPCallBackDoc.ZWMS_SK_WS_PZResponse result = new SAPCallBackDoc.ZWMS_SK_WS_PZResponse(); + result = Client.CallZWMS_SK_WS_PZ(Info); + if (result.Z_NULL == "N") + { + foreach (SAPCallBackDoc.ZWEB_RETURN resultItem in result.Z_FLAG) + { + IsSuccess = "N"; + ErrorMessage += resultItem.L_MESSAGE + "/r/n"; + } + } } } - else + if (IsSuccess == "N") { - throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message); + throw new Exception(ErrorMessage); } #endregion } diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSOutsourcingService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSOutsourcingService.cs index 9806806..5ed867a 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSOutsourcingService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSOutsourcingService.cs @@ -242,7 +242,7 @@ namespace ICSSoft.DataProject SAPCallBackDoc.ZWMS_SK_WS_PZ1 Info = new SAPCallBackDoc.ZWMS_SK_WS_PZ1(); Info.NEWID = Identification; Info.DANJU = dt.Rows[i]["ApplyCode"].ToString(); - Info.STATE = "1"; + Info.STATE = "0"; List ItemList = new List(); Info.Z_GERNR = new SAPCallBackDoc.ZWEBS_GERNR[1]; Info.Z_FLAG = new SAPCallBackDoc.ZWEB_RETURN[1]; diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSPurchaseService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSPurchaseService.cs index fb4a321..864257c 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSPurchaseService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSPurchaseService.cs @@ -775,7 +775,7 @@ namespace ICSSoft.DataProject SAPCallBackDoc.ZWMS_SK_WS_PZ1 Info = new SAPCallBackDoc.ZWMS_SK_WS_PZ1(); Info.NEWID = Identification; Info.DANJU = dt.Rows[i]["DNCode"].ToString(); - Info.STATE = "1"; + Info.STATE = "0"; List ItemList = new List(); Info.Z_GERNR = new SAPCallBackDoc.ZWEBS_GERNR[1]; Info.Z_FLAG = new SAPCallBackDoc.ZWEB_RETURN[1]; diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSalesService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSalesService.cs index f031201..1d59e1c 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSalesService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSalesService.cs @@ -109,7 +109,7 @@ namespace ICSSoft.DataProject SAPCallBackDoc.ZWMS_SK_WS_PZ1 Info = new SAPCallBackDoc.ZWMS_SK_WS_PZ1(); Info.NEWID = Identification; Info.DANJU = dt.Rows[i]["SDNCode"].ToString(); - Info.STATE = "1"; + Info.STATE = "0"; List ItemList = new List(); Info.Z_GERNR = new SAPCallBackDoc.ZWEBS_GERNR[1]; Info.Z_FLAG = new SAPCallBackDoc.ZWEB_RETURN[1]; @@ -221,65 +221,72 @@ namespace ICSSoft.DataProject { try { - #region ERP - string sql = @"SELECT c.CusCode+a.ToWarehouseCode+c.SDNCode+a.MUSER AS Costre,c.CusCode,a.ToWarehouseCode AS WarehouseCode,c.SDNCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY c.CusCode,a.ToWarehouseCode,c.SDNCode,c.SDNDetailID,a.InvCode) AS Sequence, - a.InvCode,SUM(a.Quantity) AS Quantity,SUM(a.Quantity*(lot.Amount/lot.Quantity)) AS Amount,c.SDNDetailID,Enable AS UpdateTodoQuantity - ,a.WorkPoint,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,ISNULL(ext.Version, '') AS Version,ISNULL(ext.Brand, '') AS Brand, - ISNULL(ext.cFree1, '') AS cFree1,ISNULL(ext.cFree2, '') AS cFree2,ISNULL(ext.cFree3, '') AS cFree3,ISNULL(ext.cFree4, '') AS cFree4,ISNULL(ext.cFree5, '') AS cFree5,ISNULL(ext.cFree6, '') AS cFree6,ISNULL(ext.cFree7, '') AS cFree7,ISNULL(ext.cFree8, '') AS cFree8,ISNULL(ext.cFree9, '') AS cFree9,ISNULL(ext.cFree10, '') AS cFree10 - INTO #TempERP - FROM ICSWareHouseLotInfoLog a - INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint - INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint - INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint - LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint - INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint - INNER JOIN ICSSDN c ON b.TransCode=c.SDNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint - INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint - WHERE a.Identification='{0}' AND ERPUpload='0' AND c.Type='2' AND BusinessCode='{1}' - GROUP BY c.CusCode,a.ToWarehouseCode,c.SDNCode,a.MUSER,a.InvCode,c.SDNDetailID,Enable - ,a.WorkPoint,ISNULL(ext.ProjectCode, ''),CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,ISNULL(ext.Version, ''),ISNULL(ext.Brand, ''), - ISNULL(ext.cFree1, ''),ISNULL(ext.cFree2, ''),ISNULL(ext.cFree3, ''),ISNULL(ext.cFree4, ''),ISNULL(ext.cFree5, ''),ISNULL(ext.cFree6, ''),ISNULL(ext.cFree7, ''),ISNULL(ext.cFree8, ''),ISNULL(ext.cFree9, ''),ISNULL(ext.cFree10, '') - - SELECT DISTINCT Costre,WorkPoint,CusCode,WarehouseCode AS WHCode,SDNCode AS SDNRTCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity FROM #TempERP - SELECT Costre,Sequence,InvCode,Quantity,Amount,SDNDetailID AS SDNRTDetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 FROM #TempERP - - DROP TABLE #TempERP"; - sql = string.Format(sql, Identification,BusinessCode); - DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd); - - string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre"); - - string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.SalesReturnBackURL, Inputstr); - Result result = new Result(); - result = JsonConvert.DeserializeObject(resultStr); - if (result.Success) + #region SAP + string IsSuccess = ""; + string ErrorMessage = ""; + string sql = @" select Distinct A.SDNCode,A.WorkPoint from ICSSDN A + LEFT JOIN ICSWareHouseLotInfoLog B ON B.TransCode=A.SDNCode AND B.WorkPoint=A.WorkPoint + where B.Identification='{0}' AND BusinessCode='18'"; + sql = string.Format(sql, Identification); + DataTable dt = DBHelper.SQlReturnData(sql, cmd); + if (dt.Rows.Count > 1) { - try + throw new Exception(language.GetNameByCode("WMSAPIInfo202"));//单次提交单据数量卡控(只允许一张单据) + } + for (int i = 0; i < dt.Rows.Count; i++) + { + string chksql = @"select SUM(Quantity) AS Quantity,SUM(SDNQuantity) AS SDNQuantity from ICSSDN + where SDNCode='{0}' and WorkPoint='{1}' + GROUP BY SDNCode,WorkPoint"; + chksql = string.Format(chksql, dt.Rows[i]["SDNCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString()); + DataTable chkdt = DBHelper.SQlReturnData(chksql, cmd); + if (Convert.ToDecimal(chkdt.Rows[0]["Quantity"]) != Convert.ToDecimal(chkdt.Rows[0]["SDNQuantity"])) { - JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString()); - foreach (var item in res) + throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo203"), chkdt.Rows[0]["Quantity"].ToString(), chkdt.Rows[0]["SDNQuantity"].ToString()));//单次提交数量卡控(必须整单提交) + } + SAPCallBackDoc.ZWMS_SK_WS_PZ Client = new SAPCallBackDoc.ZWMS_SK_WS_PZ(); + SAPCallBackDoc.ZWMS_SK_WS_PZ1 Info = new SAPCallBackDoc.ZWMS_SK_WS_PZ1(); + Info.NEWID = Identification; + Info.DANJU = dt.Rows[i]["SDNCode"].ToString(); + Info.STATE = "0"; + List ItemList = new List(); + Info.Z_GERNR = new SAPCallBackDoc.ZWEBS_GERNR[1]; + Info.Z_FLAG = new SAPCallBackDoc.ZWEB_RETURN[1]; + sql = @"select A.SDNCode,A.Sequence,A.Quantity,A.SDNQuantity,B.BatchCode from ICSSDN A + LEFT JOIN ICSExtension B ON B.ID=A.ExtensionID AND B.WorkPoint=A.WorkPoint + WHERE SDNCode='{0}' AND A.WorkPoint='{1}'"; + sql = string.Format(sql, dt.Rows[i]["SDNCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString()); + DataTable Sapdt = DBHelper.SQlReturnData(sql, cmd); + foreach (DataRow dr in Sapdt.Rows) + { + if (Convert.ToDecimal(dr["Quantity"].ToString()) == Convert.ToDecimal(dr["SDNQuantity"].ToString())) { - JObject jo = (JObject)item; - JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString()); - foreach (var detail in resdetail) - { - JObject det = (JObject)detail; - string allcol = jo["cWhCode"].ToString() + det["ProjectCode"].ToString() + det["cBatch"].ToString() + det["version"].ToString() + det["brand"].ToString() + det["cFree1"].ToString() + det["cFree2"].ToString() + det["cFree3"].ToString() + det["cFree4"].ToString() + det["cFree5"].ToString() - + det["cFree6"].ToString() + det["cFree7"].ToString() + det["cFree8"].ToString() + det["cFree9"].ToString() + det["cFree10"].ToString(); - ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["SDNRTDetailID"].ToString(), Identification, jo["ID"].ToString(), - det["DetailID"].ToString(), jo["SDNNEGCode"].ToString(), det["Sequence"].ToString(), allcol, cmd, language, BusinessCode); - } + SAPCallBackDoc.ZWMS_PZ Item = new SAPCallBackDoc.ZWMS_PZ(); + Item.DANJU = dr["SDNCode"].ToString(); + Item.POSNR = dr["Sequence"].ToString(); + Item.LINGYSL = System.Decimal.Round(Convert.ToDecimal(dr["Quantity"].ToString()), 3); + Item.SERNP = dr["BatchCode"].ToString(); + ItemList.Add(Item); } } - catch (Exception ex) + if (ItemList.Count > 0) { - log.Debug(ex.ToString()); - log.Debug(resultStr); + Info.Z_ITEM = ItemList.ToArray(); + SAPCallBackDoc.ZWMS_SK_WS_PZResponse result = new SAPCallBackDoc.ZWMS_SK_WS_PZResponse(); + result = Client.CallZWMS_SK_WS_PZ(Info); + if (result.Z_NULL == "N") + { + foreach (SAPCallBackDoc.ZWEB_RETURN resultItem in result.Z_FLAG) + { + IsSuccess = "N"; + ErrorMessage += resultItem.L_MESSAGE + "/r/n"; + } + } } } - else + if (IsSuccess == "N") { - throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message); + throw new Exception(ErrorMessage); } #endregion } diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseService.cs index ee9b934..3e41fff 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseService.cs @@ -103,47 +103,72 @@ namespace ICSSoft.DataProject { try { - #region ERP开立状态单据审核 - //检验调拨单是否一次性发完 - string sql = @"IF EXISTS(SELECT b.ID FROM ICSTransfer b - WHERE b.TransferNO+b.WorkPoint IN (SELECT a.TransCode+a.WorkPoint FROM ICSWareHouseLotInfoLog a WHERE a.Identification='{0}') - AND b.Type = '1' AND b.Quantity!=b.TransferQuantity) - BEGIN - RAISERROR('" + language.GetNameByCode("WMSAPIInfo097") + @"',16,1); - RETURN - END - SELECT b.TransferID AS ID,a.MUSER AS [User],SYSDATETIME() AS MTime,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock,a.WorkPoint - FROM ICSWareHouseLotInfoLog a - INNER JOIN ICSTransfer b ON a.TransCode=b.TransferNO AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint - INNER JOIN ICSConfiguration con ON con.Code='Stock003' AND a.WorkPoint=con.WorkPoint - INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock006' AND a.WorkPoint=conStock.WorkPoint - WHERE a.Identification='{0}' AND ERPUpload='0' AND b.Type='1' - GROUP BY b.TransferID,a.MUSER,con.Enable,conStock.Enable,a.WorkPoint"; + #region SAP + string IsSuccess = ""; + string ErrorMessage = ""; + string sql = @" select Distinct A.TransferNO,A.WorkPoint from ICSTransfer A + LEFT JOIN ICSWareHouseLotInfoLog B ON B.TransCode=A.TransferNO AND B.WorkPoint=A.WorkPoint + where B.Identification='{0}' AND BusinessCode='21'"; sql = string.Format(sql, Identification); DataTable dt = DBHelper.SQlReturnData(sql, cmd); - - string Inputstr =JsonConvert.SerializeObject(dt); - string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.OneStepTransferDocInURL, Inputstr); - Result result = new Result(); - result = JsonConvert.DeserializeObject(resultStr); - if (result.Success) + if (dt.Rows.Count > 1) { - try + throw new Exception(language.GetNameByCode("WMSAPIInfo202"));//单次提交单据数量卡控(只允许一张单据) + } + for (int i = 0; i < dt.Rows.Count; i++) + { + string chksql = @"select SUM(Quantity) AS Quantity,SUM(TransferQuantity) AS TransferQuantity from ICSTransfer + where TransferNO='{0}' and WorkPoint='{1}' + GROUP BY TransferNO,WorkPoint"; + chksql = string.Format(chksql, dt.Rows[i]["TransferNO"].ToString(), dt.Rows[i]["WorkPoint"].ToString()); + DataTable chkdt = DBHelper.SQlReturnData(chksql, cmd); + if (Convert.ToDecimal(chkdt.Rows[0]["Quantity"]) != Convert.ToDecimal(chkdt.Rows[0]["TransferQuantity"])) { - foreach (DataRow dr in dt.Rows) + throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo203"), chkdt.Rows[0]["Quantity"].ToString(), chkdt.Rows[0]["TransferQuantity"].ToString()));//单次提交数量卡控(必须整单提交) + } + SAPCallBackDoc.ZWMS_SK_WS_PZ Client = new SAPCallBackDoc.ZWMS_SK_WS_PZ(); + SAPCallBackDoc.ZWMS_SK_WS_PZ1 Info = new SAPCallBackDoc.ZWMS_SK_WS_PZ1(); + Info.NEWID = Identification; + Info.DANJU = dt.Rows[i]["TransferNO"].ToString(); + Info.STATE = "0"; + List ItemList = new List(); + Info.Z_GERNR = new SAPCallBackDoc.ZWEBS_GERNR[1]; + Info.Z_FLAG = new SAPCallBackDoc.ZWEB_RETURN[1]; + sql = @" select A.TransferNO,A.Sequence,A.Quantity,A.TransferQuantity,B.BatchCode from ICSTransfer A + LEFT JOIN ICSExtension B ON B.ID=A.ExtensionID AND B.WorkPoint=A.WorkPoint + WHERE TransferNO='{0}' AND A.WorkPoint='{1}'"; + sql = string.Format(sql, dt.Rows[i]["TransferNO"].ToString(), dt.Rows[i]["WorkPoint"].ToString()); + DataTable Sapdt = DBHelper.SQlReturnData(sql, cmd); + foreach (DataRow dr in Sapdt.Rows) + { + if (Convert.ToDecimal(dr["Quantity"].ToString()) == Convert.ToDecimal(dr["TransferQuantity"].ToString())) { - ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, dr["ID"].ToString(), Identification, "", "", "", "","", cmd, language, BusinessCode); + SAPCallBackDoc.ZWMS_PZ Item = new SAPCallBackDoc.ZWMS_PZ(); + Item.DANJU = dr["TransferNO"].ToString(); + Item.POSNR = dr["Sequence"].ToString(); + Item.LINGYSL = System.Decimal.Round(Convert.ToDecimal(dr["Quantity"].ToString()), 3); + Item.SERNP = dr["BatchCode"].ToString(); + ItemList.Add(Item); } } - catch (Exception ex) + if (ItemList.Count > 0) { - log.Debug(ex.ToString()); - log.Debug(resultStr); + Info.Z_ITEM = ItemList.ToArray(); + SAPCallBackDoc.ZWMS_SK_WS_PZResponse result = new SAPCallBackDoc.ZWMS_SK_WS_PZResponse(); + result = Client.CallZWMS_SK_WS_PZ(Info); + if (result.Z_NULL == "N") + { + foreach (SAPCallBackDoc.ZWEB_RETURN resultItem in result.Z_FLAG) + { + IsSuccess = "N"; + ErrorMessage += resultItem.L_MESSAGE + "/r/n"; + } + } } } - else + if (IsSuccess == "N") { - throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message); + throw new Exception(ErrorMessage); } #endregion } @@ -620,46 +645,72 @@ namespace ICSSoft.DataProject { try { - #region ERP开立状态单据审核 - string sql = @"IF EXISTS(SELECT b.ID FROM ICSOtherOut b - WHERE b.OutCode+b.WorkPoint IN (SELECT a.TransCode+a.WorkPoint FROM ICSWareHouseLotInfoLog a WHERE a.Identification='{0}') - AND b.Quantity!=b.OutQuantity) - BEGIN - RAISERROR('" + language.GetNameByCode("WMSAPIInfo100") + @"',16,1); - RETURN - END - SELECT b.OutID AS ID,a.MUSER AS [User],SYSDATETIME() AS MTime,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock,a.WorkPoint - FROM ICSWareHouseLotInfoLog a - INNER JOIN ICSOtherOut b ON a.TransCode=b.OutCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint - INNER JOIN ICSConfiguration con ON con.Code='Stock002' AND a.WorkPoint=con.WorkPoint - INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock003' AND a.WorkPoint=conStock.WorkPoint - WHERE a.Identification='{0}' AND ERPUpload='0' AND a.BusinessCode = '24' - GROUP BY b.OutID,a.MUSER,con.Enable,conStock.Enable,a.WorkPoint"; + #region SAP + string IsSuccess = ""; + string ErrorMessage = ""; + string sql = @" select Distinct A.OutCode,A.WorkPoint from ICSOtherOut A + LEFT JOIN ICSWareHouseLotInfoLog B ON B.TransCode=A.OutCode AND B.WorkPoint=A.WorkPoint + where B.Identification='{0}' AND BusinessCode='24'"; sql = string.Format(sql, Identification); DataTable dt = DBHelper.SQlReturnData(sql, cmd); - - string Inputstr = JsonConvert.SerializeObject(dt); - string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.OtherOutDocURL, Inputstr); - Result result = new Result(); - result = JsonConvert.DeserializeObject(resultStr); - if (result.Success) + if (dt.Rows.Count > 1) { - try + throw new Exception(language.GetNameByCode("WMSAPIInfo202"));//单次提交单据数量卡控(只允许一张单据) + } + for (int i = 0; i < dt.Rows.Count; i++) + { + string chksql = @"select SUM(Quantity) AS Quantity,SUM(OutQuantity) AS OutQuantity from ICSOtherOut + where OutCode='{0}' and WorkPoint='{1}' + GROUP BY OutCode,WorkPoint"; + chksql = string.Format(chksql, dt.Rows[i]["OutCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString()); + DataTable chkdt = DBHelper.SQlReturnData(chksql, cmd); + if (Convert.ToDecimal(chkdt.Rows[0]["Quantity"]) != Convert.ToDecimal(chkdt.Rows[0]["OutQuantity"])) { - foreach (DataRow dr in dt.Rows) + throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo203"), chkdt.Rows[0]["Quantity"].ToString(), chkdt.Rows[0]["OutQuantity"].ToString()));//单次提交数量卡控(必须整单提交) + } + SAPCallBackDoc.ZWMS_SK_WS_PZ Client = new SAPCallBackDoc.ZWMS_SK_WS_PZ(); + SAPCallBackDoc.ZWMS_SK_WS_PZ1 Info = new SAPCallBackDoc.ZWMS_SK_WS_PZ1(); + Info.NEWID = Identification; + Info.DANJU = dt.Rows[i]["OutCode"].ToString(); + Info.STATE = "0"; + List ItemList = new List(); + Info.Z_GERNR = new SAPCallBackDoc.ZWEBS_GERNR[1]; + Info.Z_FLAG = new SAPCallBackDoc.ZWEB_RETURN[1]; + sql = @"select A.OutCode,A.Sequence,A.Quantity,A.OutQuantity,B.BatchCode from ICSOtherOut A + LEFT JOIN ICSExtension B ON B.ID=A.ExtensionID AND B.WorkPoint=A.WorkPoint + WHERE OutCode='{0}' AND A.WorkPoint='{1}'"; + sql = string.Format(sql, dt.Rows[i]["OutCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString()); + DataTable Sapdt = DBHelper.SQlReturnData(sql, cmd); + foreach (DataRow dr in Sapdt.Rows) + { + if (Convert.ToDecimal(dr["Quantity"].ToString()) == Convert.ToDecimal(dr["OutQuantity"].ToString())) { - ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, dr["ID"].ToString(), Identification, "", "", "", "","", cmd, language, BusinessCode); + SAPCallBackDoc.ZWMS_PZ Item = new SAPCallBackDoc.ZWMS_PZ(); + Item.DANJU = dr["OutCode"].ToString(); + Item.POSNR = dr["Sequence"].ToString(); + Item.LINGYSL = System.Decimal.Round(Convert.ToDecimal(dr["Quantity"].ToString()), 3); + Item.SERNP = dr["BatchCode"].ToString(); + ItemList.Add(Item); } } - catch (Exception ex) + if (ItemList.Count > 0) { - log.Debug(ex.ToString()); - log.Debug(resultStr); + Info.Z_ITEM = ItemList.ToArray(); + SAPCallBackDoc.ZWMS_SK_WS_PZResponse result = new SAPCallBackDoc.ZWMS_SK_WS_PZResponse(); + result = Client.CallZWMS_SK_WS_PZ(Info); + if (result.Z_NULL == "N") + { + foreach (SAPCallBackDoc.ZWEB_RETURN resultItem in result.Z_FLAG) + { + IsSuccess = "N"; + ErrorMessage += resultItem.L_MESSAGE + "/r/n"; + } + } } } - else + if (IsSuccess == "N") { - throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message); + throw new Exception(ErrorMessage); } #endregion } @@ -733,46 +784,72 @@ namespace ICSSoft.DataProject { try { - #region ERP开立状态单据审核 - string sql = @"IF EXISTS(SELECT b.ID FROM ICSOtherIn b - WHERE b.InCode+b.WorkPoint IN (SELECT a.TransCode+a.WorkPoint FROM ICSWareHouseLotInfoLog a WHERE a.Identification='{0}') - AND b.Quantity!=b.InQuantity) - BEGIN - RAISERROR('" + language.GetNameByCode("WMSAPIInfo101") + @"',16,1); - RETURN - END - SELECT b.InID AS ID,a.MUSER AS [User],SYSDATETIME() AS MTime,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock,a.WorkPoint - FROM ICSWareHouseLotInfoLog a - INNER JOIN ICSOtherIn b ON a.TransCode=b.InCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint - INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint - INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock003' AND a.WorkPoint=conStock.WorkPoint - WHERE a.Identification='{0}' AND ERPUpload='0' - GROUP BY b.InID,a.MUSER,con.Enable,conStock.Enable,a.WorkPoint"; + #region SAP + string IsSuccess = ""; + string ErrorMessage = ""; + string sql = @" select Distinct A.InCode,A.WorkPoint from ICSOtherIn A + LEFT JOIN ICSWareHouseLotInfoLog B ON B.TransCode=A.InCode AND B.WorkPoint=A.WorkPoint + where B.Identification='{0}' AND BusinessCode='25'"; sql = string.Format(sql, Identification); DataTable dt = DBHelper.SQlReturnData(sql, cmd); - - string Inputstr = JsonConvert.SerializeObject(dt); - string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.OtherInDocURL, Inputstr); - Result result = new Result(); - result = JsonConvert.DeserializeObject(resultStr); - if (result.Success) + if (dt.Rows.Count > 1) { - try + throw new Exception(language.GetNameByCode("WMSAPIInfo202"));//单次提交单据数量卡控(只允许一张单据) + } + for (int i = 0; i < dt.Rows.Count; i++) + { + string chksql = @"select SUM(Quantity) AS Quantity,SUM(InQuantity) AS InQuantity from ICSOtherIn + where InCode='{0}' and WorkPoint='{1}' + GROUP BY InCode,WorkPoint"; + chksql = string.Format(chksql, dt.Rows[i]["InCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString()); + DataTable chkdt = DBHelper.SQlReturnData(chksql, cmd); + if (Convert.ToDecimal(chkdt.Rows[0]["Quantity"]) != Convert.ToDecimal(chkdt.Rows[0]["InQuantity"])) { - foreach (DataRow dr in dt.Rows) + throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo203"), chkdt.Rows[0]["Quantity"].ToString(), chkdt.Rows[0]["InQuantity"].ToString()));//单次提交数量卡控(必须整单提交) + } + SAPCallBackDoc.ZWMS_SK_WS_PZ Client = new SAPCallBackDoc.ZWMS_SK_WS_PZ(); + SAPCallBackDoc.ZWMS_SK_WS_PZ1 Info = new SAPCallBackDoc.ZWMS_SK_WS_PZ1(); + Info.NEWID = Identification; + Info.DANJU = dt.Rows[i]["InCode"].ToString(); + Info.STATE = "0"; + List ItemList = new List(); + Info.Z_GERNR = new SAPCallBackDoc.ZWEBS_GERNR[1]; + Info.Z_FLAG = new SAPCallBackDoc.ZWEB_RETURN[1]; + sql = @"select A.InCode,A.Sequence,A.Quantity,A.InQuantity,B.BatchCode from ICSOtherIn A + LEFT JOIN ICSExtension B ON B.ID=A.ExtensionID AND B.WorkPoint=A.WorkPoint + WHERE InCode='{0}' AND A.WorkPoint='{1}'"; + sql = string.Format(sql, dt.Rows[i]["InCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString()); + DataTable Sapdt = DBHelper.SQlReturnData(sql, cmd); + foreach (DataRow dr in Sapdt.Rows) + { + if (Convert.ToDecimal(dr["Quantity"].ToString()) == Convert.ToDecimal(dr["InQuantity"].ToString())) { - ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, dr["ID"].ToString(), Identification, "", "", "", "","", cmd, language, BusinessCode); + SAPCallBackDoc.ZWMS_PZ Item = new SAPCallBackDoc.ZWMS_PZ(); + Item.DANJU = dr["InCode"].ToString(); + Item.POSNR = dr["Sequence"].ToString(); + Item.LINGYSL = System.Decimal.Round(Convert.ToDecimal(dr["Quantity"].ToString()), 3); + Item.SERNP = dr["BatchCode"].ToString(); + ItemList.Add(Item); } } - catch (Exception ex) + if (ItemList.Count > 0) { - log.Debug(ex.ToString()); - log.Debug(resultStr); + Info.Z_ITEM = ItemList.ToArray(); + SAPCallBackDoc.ZWMS_SK_WS_PZResponse result = new SAPCallBackDoc.ZWMS_SK_WS_PZResponse(); + result = Client.CallZWMS_SK_WS_PZ(Info); + if (result.Z_NULL == "N") + { + foreach (SAPCallBackDoc.ZWEB_RETURN resultItem in result.Z_FLAG) + { + IsSuccess = "N"; + ErrorMessage += resultItem.L_MESSAGE + "/r/n"; + } + } } } - else + if (IsSuccess == "N") { - throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message); + throw new Exception(ErrorMessage); } #endregion } diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Web.config b/ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Web.config index c146188..a555745 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Web.config +++ b/ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Web.config @@ -11,7 +11,7 @@ - +