From 2fceead274cb100489235206f70f23786fe1821d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=92=E6=9E=97=E6=9D=B0?= <1205395967@qq.com> Date: Fri, 10 Feb 2023 17:51:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E8=B4=AD=E4=B8=8A=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ICSSoft.DataProject/ICSPurchaseService.cs | 113 +++++++++++++----- .../ICSSoft.DataProject/ICSSubmitService.cs | 37 ++++-- 2 files changed, 106 insertions(+), 44 deletions(-) diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSPurchaseService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSPurchaseService.cs index c061aa5..9a3c996 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSPurchaseService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSPurchaseService.cs @@ -163,7 +163,7 @@ namespace ICSSoft.DataProject try { #region ERP - string sql = @"SELECT c.VenCode+a.ToWarehouseCode+c.POCode+a.MUSER+f.DNCode AS Costre,c.VenCode,a.ToWarehouseCode AS WarehouseCode,c.POCode,f.DNCode,a.MUSER,f.Sequence AS DNSequence,ROW_NUMBER() OVER (ORDER BY c.VenCode,a.ToWarehouseCode,c.POCode,c.PODetailID,a.InvCode) AS Sequence, + string sql = @"SELECT c.VenCode+a.ToWarehouseCode+c.POCode+a.MUSER+CASE WHEN(LEN(f.DNID)>=20) THEN '' ELSE f.DNCode END AS Costre,c.VenCode,a.ToWarehouseCode AS WarehouseCode,c.POCode,CASE WHEN(LEN(f.DNID)>=20) THEN '' ELSE f.DNCode END AS DNCode,CASE WHEN(LEN(f.DNID)>=20) THEN '1' ELSE '0' END AS HasDN,a.MUSER,CASE WHEN(LEN(f.DNID)>=20) THEN '' ELSE f.Sequence END AS DNSequence,ROW_NUMBER() OVER (ORDER BY c.VenCode,a.ToWarehouseCode,c.POCode,c.PODetailID,a.InvCode) AS Sequence, a.InvCode,SUM(a.Quantity) AS Quantity,SUM(a.Quantity*(lot.Amount/lot.Quantity)) AS Amount,isnull((c.UnitPrice),0) as UnitPrice,c.Currency,c.PODetailID,con.Enable AS UpdateTodoQuantity,conn.Enable ,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 @@ -180,51 +180,99 @@ namespace ICSSoft.DataProject INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint INNER JOIN ICSConfiguration conn ON con.WorkPoint=conn.WorkPoint AND conn.Code='Escrow001' WHERE a.Identification='{0}' AND ERPUpload='0' AND BusinessCode='{1}' - GROUP BY c.VenCode,a.ToWarehouseCode,c.POCode,f.DNCode,a.MUSER,a.InvCode,f.Sequence,c.PODetailID,isnull((c.UnitPrice),0),c.Currency,con.Enable,conn.Enable + GROUP BY c.VenCode,a.ToWarehouseCode,c.POCode,CASE WHEN(LEN(f.DNID)>=20) THEN '' ELSE f.DNCode END,f.DNID,a.MUSER,a.InvCode,CASE WHEN(LEN(f.DNID)>=20) THEN '' ELSE f.Sequence END,c.PODetailID,isnull((c.UnitPrice),0),c.Currency,con.Enable,conn.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,VenCode,WarehouseCode AS WHCode,POCode,DNCode,MUSER AS [User],SYSDATETIME() AS MTime,Enable,UpdateTodoQuantity FROM #TempERP SELECT Costre,Sequence,DNSequence,InvCode,Quantity,Amount,PODetailID,Currency,UnitPrice,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 FROM #TempERP + SELECT HasDN 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.PurchaseOrderURL, Inputstr); - Result result = new Result(); - result = JsonConvert.DeserializeObject(resultStr); - if (result.Success) + + var IsDNCode = ds.Tables[2]; + if (IsDNCode == null || IsDNCode.Rows.Count != 1) { - try + throw new Exception(language.GetNameByCode("WMSAPIInfo463"));//ERP到货单只能选择启用或不启用中的一种! + } + string dncode = Convert.ToString(IsDNCode.Rows[0]["HasDN"]); + if (dncode.Equals("")) + { + string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.DeliveryNoticeURL, Inputstr); + Result result = new Result(); + result = JsonConvert.DeserializeObject(resultStr); + if (result.Success) { - JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString()); - foreach (var item in res) + try { - JObject jo = (JObject)item; - JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString()); - foreach (var detail in resdetail) + JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString()); + foreach (var item in res) { - 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["PODetailID"].ToString(), Identification, jo["ID"].ToString(), - det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), allcol, cmd, language, BusinessCode); + 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["DNDetailID"].ToString(), Identification, jo["ID"].ToString(), + det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), allcol, cmd, language, BusinessCode); + } } } + catch (Exception ex) + { + log.Debug(ex.ToString()); + log.Debug(resultStr); + } } - catch (Exception ex) + else { - log.Debug(ex.ToString()); - log.Debug(resultStr); + throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message); } } else { - throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message); + string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.PurchaseOrderURL, Inputstr); + Result result = new Result(); + result = JsonConvert.DeserializeObject(resultStr); + if (result.Success) + { + try + { + JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString()); + foreach (var item in res) + { + 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["PODetailID"].ToString(), Identification, jo["ID"].ToString(), + det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), allcol, cmd, language, BusinessCode); + } + } + } + catch (Exception ex) + { + log.Debug(ex.ToString()); + log.Debug(resultStr); + } + } + else + { + throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message); + } } + #endregion } catch (Exception) @@ -298,8 +346,8 @@ namespace ICSSoft.DataProject try { #region ERP - string sql = @"SELECT c.VenCode+a.ToWarehouseCode+c.DNCode+a.MUSER AS Costre,c.VenCode,a.ToWarehouseCode AS WarehouseCode,c.DNCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY c.VenCode,a.ToWarehouseCode,c.DNCode,c.DNDetailID,a.InvCode) AS Sequence, - a.InvCode,SUM(a.Quantity) AS Quantity,SUM(a.Quantity*(lot.Amount/lot.Quantity)) AS Amount,isnull((c.UnitPrice),0) as UnitPrice,c.Currency,c.DNDetailID,con.Enable AS UpdateTodoQuantity,conn.Enable + string sql = @"SELECT c.VenCode+a.ToWarehouseCode+c.DNCode+a.MUSER AS Costre,c.VenCode,a.ToWarehouseCode AS WarehouseCode,c.DNCode ,a.MUSER,ROW_NUMBER() OVER (ORDER BY c.VenCode,a.ToWarehouseCode,c.DNDetailID,a.InvCode) AS Sequence, + a.InvCode,SUM(a.Quantity) AS Quantity,0 AS Amount,isnull((c.UnitPrice),0) as UnitPrice,c.Currency,c.DNDetailID,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 @@ -311,21 +359,21 @@ namespace ICSSoft.DataProject INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint - INNER JOIN ICSConfiguration conn ON con.WorkPoint=conn.WorkPoint AND conn.Code='Escrow001' - WHERE a.Identification='{0}' AND ERPUpload='0' AND BusinessCode='{1}' - GROUP BY c.VenCode,a.ToWarehouseCode,c.DNCode,a.MUSER,a.InvCode,c.DNDetailID,isnull((c.UnitPrice),0),c.Currency,con.Enable,conn.Enable + WHERE a.Identification='{0}' AND ERPUpload='0' + GROUP BY c.VenCode,a.ToWarehouseCode,c.DNCode,c.DNID,a.MUSER,a.InvCode,c.DNDetailID,isnull((c.UnitPrice),0),c.Currency,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,VenCode,WarehouseCode AS WHCode,DNCode,MUSER AS [User],SYSDATETIME() AS MTime,Enable,UpdateTodoQuantity FROM #TempERP + SELECT DISTINCT Costre,WorkPoint,VenCode,WarehouseCode AS WHCode,DNCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity FROM #TempERP SELECT Costre,Sequence,InvCode,Quantity,Amount,DNDetailID,Currency,UnitPrice,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.DeliveryNoticeURL, Inputstr); Result result = new Result(); result = JsonConvert.DeserializeObject(resultStr); @@ -343,8 +391,8 @@ namespace ICSSoft.DataProject 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["DNDetailID"].ToString(), Identification, jo["ID"].ToString(), - det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), allcol,cmd, language, BusinessCode); + ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["DNDetailID"].ToString(), Identification, jo["ID"].ToString(), + det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), allcol, cmd, language, BusinessCode); } } } @@ -356,8 +404,11 @@ namespace ICSSoft.DataProject } else { - throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message); + throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message); } + + + #endregion } catch (Exception) diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs index 6381378..58b3b12 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs @@ -1007,6 +1007,7 @@ namespace ICSSoft.DataProject string TransType = JsonData.TransType; string sql = ""; + string LotTypesql = ""; string Losql = ""; string sqlNew = ""; string LotType = ""; @@ -1792,11 +1793,10 @@ namespace ICSSoft.DataProject RAISERROR('" + language.GetNameByCode("WMSAPIInfo039") + @"',16,1); RETURN END - IF EXISTS(SELECT a.ID FROM ICSInventoryLot a + IF EXISTS(SELECT a.ID,c.TransCode FROM ICSInventoryLot a INNER JOIN ICSInventory b ON a.InvCode=b.InvCode AND a.WorkPoint=b.WorkPoint - LEFT JOIN ICSInspection ins ON a.LotNo=ins.LotNo AND a.WorkPoint=ins.WorkPoint - LEFT JOIN ICSInventoryLotDetail c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint - WHERE a.LotNo='{2}' AND a.WorkPoint='{3}' AND (b.InvIQC='1'AND ins.LotNo IS NULL) AND c.TransCode NOT LIKE 'RD%') + LEFT JOIN ICSInspection ins ON a.LotNo=ins.LotNo AND a.WorkPoint=ins.WorkPoint + WHERE a.LotNo='{2}' AND a.WorkPoint='{3}' AND (b.InvIQC='1' AND ins.LotNo IS NULL)) BEGIN RAISERROR('" + language.GetNameByCode("WMSAPIInfo040") + @"',16,1); RETURN @@ -1806,16 +1806,16 @@ namespace ICSSoft.DataProject ControlMode mode = ICSControlModeService.GetSuLocation(); - + //获取条码类型 - sql = @"IF EXISTS(SELECT Type FROM ICSInventoryLot WHERE LotNo='{0}' AND WorkPoint='{1}') + LotTypesql = @"IF NOT EXISTS(SELECT Type FROM ICSInventoryLot WHERE LotNo='{0}' AND WorkPoint='{1}') BEGIN RAISERROR('" + language.GetNameByCode("WMSAPIInfo461") + @"',16,1); RETURN END SELECT Type FROM ICSInventoryLot WHERE LotNo='{0}' AND WorkPoint='{1}'"; - sql = string.Format(sql, JsonData.Code, JsonData.WorkPoint); - DataTable dt = DBHelper.SQlReturnData(sql, cmd); + LotTypesql = string.Format(LotTypesql, JsonData.Code, JsonData.WorkPoint); + DataTable dt = DBHelper.SQlReturnData(LotTypesql, cmd); LotType = dt.Rows[0]["Type"].ToString(); @@ -1884,7 +1884,7 @@ namespace ICSSoft.DataProject } else if (LotType.Equals("7")) {//采购到货单 - columnsWHCODE = @"(SELECT a.WHCode FROM ICSDeliveryNotice a WHERE a.DNCode=lotdd.TransCode AND a.Sequence=lotdd.TransSequence AND a.WorkPoint=lotdd.WorkPoint a.DNType='1') AS WHCode"; + columnsWHCODE = @"(SELECT a.WHCode FROM ICSDeliveryNotice a WHERE a.DNCode=lotdd.TransCode AND a.Sequence=lotdd.TransSequence AND a.WorkPoint=lotdd.WorkPoint AND a.DNType='1') AS WHCode"; } else if (LotType.Equals("8")) {//委外到货单 @@ -1931,9 +1931,9 @@ namespace ICSSoft.DataProject columns = @"ISNULL(ins.QualifiedQuantity+ins.WaiveQuantity, a.Quantity) AS Quantity, a.Quantity*(a.Amount/a.Quantity) AS Amount, - '{0}','' AS WHName, + {0},'' AS WHName, '' AS LocationCode, - '{1}' + {1} ext.BatchCode AS BatchCode,"; tableName = @"ICSInventoryLot a @@ -2010,8 +2010,8 @@ namespace ICSSoft.DataProject else { sql = string.Format(sql, columns, tableName, JsonData.Code, JsonData.WorkPoint); - - table = DBHelper.SQlReturnData(sql, cmd); + log.Info("条码sql:" + sql); + table = DBHelper.SQlReturnData(sql, cmd); } if (table == null || table.Rows.Count <= 0) @@ -2883,7 +2883,18 @@ namespace ICSSoft.DataProject { throw new Exception(language.GetNameByCode("WMSAPIInfo010")); //"送货单子表信息更新失败!"); } + + sql = @"UPDATE ICSInventoryLot SET Quantity='{2}' + WHERE LotNo='{0}' AND WorkPoint='{1}'"; + sql = string.Format(sql, itemInfo.LotNo, item.WorkPoint, itemInfo.Quantity); + + if (!DBHelper.ExecuteNonQuery(sql, cmd)) + { + throw new Exception(language.GetNameByCode("WMSAPIInfo462")); //"条码表信息更新失败!"); + } } + + //创建到货单信息 sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{1}' AND F_Location='{2}') BEGIN