Browse Source

料品管控,生产委外倒冲

master
冒林杰 3 years ago
parent
commit
7cb9b1d3bc
  1. 22
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSManufactureService.cs
  2. 53
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSOutsourcingService.cs
  3. 1
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs
  4. 336
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs

22
ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSManufactureService.cs

@ -805,7 +805,7 @@ namespace ICSSoft.DataProject
SELECT Costre,Costre2,TransSequence,Sequence,InvCode,Quantity,Amount,MODetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
FROM #TempERP
SELECT c.WHCode,c.MODetailID AS Costre2,a.TransCode,a.TransSequence AS Sequence,a.InvCode,c.Quantity/b.Quantity*a.Quantity as Quantity,c.Amount,c.PickID,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
SELECT n.WHCode,n.Costre2,n.TransCode,n.Sequence,n.InvCode,SUM(n.Quantity) AS Quantity,n.Amount,n.PickID,n.ProjectCode,n.BatchCode,n.Version,n.Brand,n.cFree1,n.cFree2,n.cFree3,n.cFree4,n.cFree5,n.cFree6,n.cFree7,n.cFree8,n.cFree9,n.cFree10 FROM( SELECT c.WHCode,c.MODetailID AS Costre2,a.TransCode,a.TransSequence AS Sequence,a.InvCode,c.Quantity/b.Quantity*a.Quantity as Quantity,c.Amount,c.PickID,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
FROM ICSWareHouseLotInfoLog a
INNER JOIN ICSMO b ON b.MOCode=a.TransCode AND b.WorkPoint=a.WorkPoint
INNER JOIN ICSMOPick c ON c.MODetailID=b.MODetailID AND c.WorkPoint=b.WorkPoint AND a.TransSequence=b.Sequence+'~'+c.Sequence
@ -813,6 +813,8 @@ namespace ICSSoft.DataProject
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
WHERE a.Identification='{0}' AND a.TransType='12'
GROUP BY c.WHCode,c.MODetailID,a.TransCode,a.TransSequence,a.InvCode,c.Amount,c.Quantity,b.Quantity,a.Quantity,c.PickID,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, ''),a.TransSequence) n GROUP BY n.WHCode,n.Costre2,n.TransCode,n.Sequence,n.InvCode,n.Amount,n.PickID,n.ProjectCode,n.BatchCode,n.Version,n.Brand,n.cFree1,n.cFree2,n.cFree3,n.cFree4,n.cFree5,n.cFree6,n.cFree7,n.cFree8,n.cFree9,n.cFree10
DROP TABLE #TempERP";
sql = string.Format(sql, Identification);
@ -840,8 +842,22 @@ namespace ICSSoft.DataProject
foreach (var details in resdetails)
{
JObject dets = (JObject)details;
ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["MODetailID"].ToString(), Identification, dets["ERPID"].ToString(),
dets["ERPDetailID"].ToString(), dets["MRCVCode"].ToString(), dets["Sequence"].ToString(),"", cmd, language);
if (dets != null)
{
//直接回写
string ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
FROM ICSWareHouseLotInfoLog a
LEFT JOIN ICSMO b ON a.TransCode=b.MOCode AND a.WorkPoint=b.WorkPoint
LEFT JOIN ICSMOPick c ON b.MODetailID=c.MODetailID AND b.WorkPoint=c.WorkPoint AND a.TransSequence=b.Sequence+'~'+c.Sequence
WHERE c.PickID='{0}' and a.Identification='{1}' AND ERPUpload='0' AND (a.BusinessCode <> '31' and a.BusinessCode <> '32')";
ERPupdate = string.Format(ERPupdate, dets["SourceDetailID"].ToString(), Identification, jo["ID"].ToString(), dets["ERPDetailID"].ToString(), jo["MRCVCode"].ToString()
, dets["Sequence"].ToString());
if (!DBHelper.ExecuteNonQuery(ERPupdate, cmd))
{
throw new Exception(language.GetNameByCode("WMSAPIInfo079"));//"成品倒冲回写失败!";
}
}
}
}
}

53
ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSOutsourcingService.cs

@ -880,9 +880,9 @@ namespace ICSSoft.DataProject
INNER JOIN ICSOASNDetail g ON a.LotNo=g.LotNo AND a.WorkPoint=g.WorkPoint
INNER JOIN ICSODeliveryNotice f ON g.OASNCode=f.OASNCode AND g.WorkPoint=f.WorkPoint
INNER JOIN ICSOutsourcingOrder c ON b.TransCode = c.OOCode
AND b.TransSequence = c.Sequence
AND f.OODetailID = c.OODetailID
AND b.WorkPoint = c.WorkPoint
AND b.TransSequence = c.Sequence
AND f.OODetailID = c.OODetailID
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'
INNER JOIN ICSConfiguration conv ON conv.Code='CompleteVerification' AND a.WorkPoint=conv.WorkPoint
@ -894,14 +894,17 @@ namespace ICSSoft.DataProject
SELECT DISTINCT Costre,WorkPoint,VenCode,WarehouseCode AS WHCode,OOCode,ODNCode,MUSER AS [User],SYSDATETIME() AS MTime,Enable,UpdateTodoQuantity,CompleteVerification FROM #TempERP
SELECT Costre,Costre2,Sequence,ODNSequence,InvCode,Quantity,Amount,OODetailID,Currency,UnitPrice,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
FROM #TempERP
SELECT c.WHCode,c.OODetailID AS Costre2,a.TransCode,a.TransSequence AS Sequence,a.InvCode,c.Quantity/b.Quantity*a.Quantity as Quantity,c.Amount,c.PickID,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
FROM ICSWareHouseLotInfoLog a
INNER JOIN ICSOutsourcingOrder b ON b.OOCode=a.TransCode AND b.WorkPoint=a.WorkPoint
INNER JOIN ICSOOPick c ON c.OODetailID=b.OODetailID AND c.WorkPoint=b.WorkPoint AND a.TransSequence=b.Sequence+'~'+c.Sequence
INNER JOIN ICSExtension ext ON ext.ID=c.ExtensionID AND ext.WorkPoint=c.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
WHERE a.Identification='{0}' AND a.TransType='12'
SELECT n.WHCode,n.Costre2,n.TransCode,n.Sequence,n.InvCode,SUM(n.Quantity) AS Quantity,n.Amount,n.PickID,n.ProjectCode,n.BatchCode,n.Version,n.Brand,n.cFree1,n.cFree2,n.cFree3,n.cFree4,n.cFree5,n.cFree6,n.cFree7,n.cFree8,n.cFree9,n.cFree10 FROM( SELECT c.WHCode,c.OODetailID AS Costre2,a.TransCode,a.TransSequence AS Sequence,a.InvCode,c.Quantity/b.Quantity*a.Quantity as Quantity,c.Amount,c.PickID,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
FROM ICSWareHouseLotInfoLog a
INNER JOIN ICSOutsourcingOrder b ON b.OOCode=a.TransCode AND b.WorkPoint=a.WorkPoint
INNER JOIN ICSOOPick c ON c.OODetailID=b.OODetailID AND c.WorkPoint=b.WorkPoint AND a.TransSequence=b.Sequence+'~'+c.Sequence
INNER JOIN ICSExtension ext ON ext.ID=c.ExtensionID AND ext.WorkPoint=c.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
WHERE a.Identification='{0}' AND a.TransType='12'
GROUP BY c.WHCode,c.OODetailID,a.TransCode,a.TransSequence,a.InvCode,c.Amount,c.Quantity,b.Quantity,a.Quantity,c.PickID,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, ''),a.TransSequence) n GROUP BY n.WHCode,n.Costre2,n.TransCode,n.Sequence,n.InvCode,n.Amount,n.PickID,n.ProjectCode,n.BatchCode,n.Version,n.Brand,n.cFree1,n.cFree2,n.cFree3,n.cFree4,n.cFree5,n.cFree6,n.cFree7,n.cFree8,n.cFree9,n.cFree10
DROP TABLE #TempERP";
sql = string.Format(sql, Identification);
@ -923,17 +926,33 @@ namespace ICSSoft.DataProject
foreach (var detail in resdetail)
{
JObject det = (JObject)detail;
string allcol = "" + 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["OODetailID"].ToString(), Identification, jo["ID"].ToString(),
det["DetailID"].ToString(), jo["ORCVTCode"].ToString(), det["Sequence"].ToString(), "",cmd, language);
det["DetailID"].ToString(), jo["ORCVTCode"].ToString(), det["Sequence"].ToString(), allcol, cmd, language);
JArray resdetails = (JArray)JsonConvert.DeserializeObject(det["detailss"].ToString());
foreach (var details in resdetails)
{
JObject dets = (JObject)details;
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["OODetailID"].ToString(), Identification, dets["ERPID"].ToString(),
dets["ERPDetailID"].ToString(), dets["MRCVCode"].ToString(), dets["Sequence"].ToString(), allcol, cmd, language);
if (dets != null)
{
//直接回写
string ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
FROM ICSWareHouseLotInfoLog a
LEFT JOIN ICSOutsourcingOrder b ON a.TransCode=b.OOCode AND a.WorkPoint=b.WorkPoint
LEFT JOIN ICSOOPick c ON b.OODetailID=c.OODetailID AND b.WorkPoint=c.WorkPoint AND a.TransSequence=b.Sequence+'~'+c.Sequence
WHERE c.PickID='{0}' and a.Identification='{1}' AND ERPUpload='0' AND (a.BusinessCode <> '31' and a.BusinessCode <> '32')";
ERPupdate = string.Format(ERPupdate, dets["SourceDetailID"].ToString(), Identification, jo["ID"].ToString(), dets["ERPDetailID"].ToString(), jo["ORCVTCode"].ToString()
, dets["Sequence"].ToString());
if (!DBHelper.ExecuteNonQuery(ERPupdate, cmd))
{
throw new Exception(language.GetNameByCode("WMSAPIInfo079"));//"委外倒冲回写失败!";
}
//ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["OODetailID"].ToString(), Identification, dets["ERPID"].ToString(),
// dets[" "].ToString(), dets["MRCVCode"].ToString(), dets["Sequence"].ToString(), allcol, cmd, language);
}
}
}

1
ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs

@ -951,6 +951,7 @@ namespace ICSSoft.DataProject
inv.InvName,
inv.InvStd,
inv.InvUnit,
inv.LotEnable,
{0}
inv.AmountUnit,
ext.ID AS ExtensionID,

336
ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs

@ -56,13 +56,13 @@ namespace ICSSoft.DataProject
{
try
{
#region 正常入库
///添加库存(原条码退回,更新库存;新条码直接入库)
//stirng locationcode = "";
string sql = string.Empty;
string locationcode = "";
if (BusinessCode != TransTypeEnum.SalesReturnBack.GetDescription<DBValue>())
{
if (string.IsNullOrWhiteSpace(LogID))
@ -84,8 +84,8 @@ namespace ICSSoft.DataProject
}
locationcode = dt.Rows[0]["LocationCode"].ToString();
}
}
sql += @" IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}')
BEGIN
@ -168,9 +168,156 @@ namespace ICSSoft.DataProject
{
throw new Exception(language.GetNameByCode("WMSAPIInfo166"));
}
#endregion
#region 管控方式是"料品"时
ControlMode mode = ICSControlModeService.GetControlMode();
if (mode.itemCode.Equals("ControlMode02"))
{
//查询是否存在料品管控的条码
string sqlStrNew = @"SELECT a.ID,
con.ContainerCode,
con.ContainerName,
a.LotNo,
a.InvCode,
inv.InvName,
inv.InvStd,
inv.InvUnit,-- {0}
inv.AmountUnit,
ext.ID AS ExtensionID,
ext.ProjectCode,
ext.Version,
ext.BatchCode,
ext.Brand,
ext.cFree1,
ext.cFree2,
ext.cFree3,
ext.cFree4,
ext.cFree5,
ext.cFree6,
ext.cFree7,
ext.cFree8,
ext.cFree9,
ext.cFree10,
a.MUSER AS [ USER ],
a.MTIME AS [ MTime ]
FROM
ICSInventoryLot a
LEFT JOIN ICSContainerLot conlot ON a.LotNo = conlot.LotNo AND a.WorkPoint = conlot.WorkPoint
LEFT JOIN ICSContainer con ON conlot.ContainerID = con.ID AND conlot.WorkPoint = con.WorkPoint
INNER JOIN ICSInventory inv ON a.InvCode = inv.InvCode AND a.WorkPoint = inv.WorkPoint
INNER JOIN ICSExtension ext ON a.ExtensionID = ext.ID AND a.WorkPoint = ext.WorkPoint
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'";
sqlStrNew = string.Format(sqlStrNew, jointLotNo, WorkPoint);
DataTable table = DBHelper.SQlReturnData(sqlStrNew, cmd);
string json = JsonConvert.SerializeObject(table);
List<LotNoMode> modelNew = JsonConvert.DeserializeObject<List<LotNoMode>>(json);
//当不存在料品管控条码时,生成新条码
if (!(modelNew.Count > 0))
{
//获取旧条码的信息
string jsonStr = ICSControlModeService.QueryLotNo(LotNo, WorkPoint);
List<LotNoMode> model = JsonConvert.DeserializeObject<List<LotNoMode>>(jsonStr);
//在条码表中插入一条新数据,在条码表中插入一条新数据,并在库存表中添加新数据
LotNoMode lotNoMode = model[0];
CreateLotNo(jointLotNo, Quantity, "", "", WorkPoint, Identification, User, lotNoMode.InvCode, BusinessCode, lotNoMode.ProjectCode, lotNoMode.BatchCode,
lotNoMode.Version, lotNoMode.Brand, lotNoMode.cFree1, lotNoMode.cFree2, lotNoMode.cFree3, lotNoMode.cFree4, lotNoMode.cFree5, lotNoMode.cFree6, lotNoMode.cFree7,
lotNoMode.cFree8, lotNoMode.cFree9, lotNoMode.cFree10, cmd, language, LocationCode, LotNo);
///添加日志
sql = @"INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity,
Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID,
ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName,
MTIME,WorkPoint,EATTRIBUTE1,LogID)
SELECT NEWID(),'{3}',b.TransCode,b.TransSequence,a.LotNo ,a.InvCode ,
'','',c.WarehouseCode,c.LocationCode,'{6}',
'','0','{4}','{5}','0','',
'','','',f.F_Account ,f.F_RealName ,
SYSDATETIME() ,a.WorkPoint ,'','{7}'
FROM ICSInventoryLot a
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
";
sql = string.Format(sql, jointLotNo, WorkPoint, User, Identification, TransType, BusinessCode, Quantity, LogID);
if (!DBHelper.ExecuteNonQuery(sql, cmd))
{
throw new Exception(language.GetNameByCode("WMSAPIInfo166"));
}
}
//当存在料品管控条码时,直接将数量叠加
else
{
try
{
///更新目标条码库存
WareHouseLotInfoMerge(Identification, jointLotNo,LotNo, Quantity, User, WorkPoint, "5",
TransTypeEnum.LOTMergeAfter.GetDescription<DBValue>(), cmd, language);
//sql = @"
// IF NOT EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}')
// BEGIN
// RAISERROR('" + language.GetNameByCode("WMSAPIInfo171") + @"',16,1);
// RETURN
// END
// UPDATE ICSWareHouseLotInfo SET Quantity=ISNULL(Quantity,0)+'{2}' WHERE LotNo='{0}' AND WorkPoint='{1}'
// ";
//sql = string.Format(sql, jointLotNo, WorkPoint, Quantity);
//if (!DBHelper.ExecuteNonQuery(sql, cmd))
//{
// throw new Exception(language.GetNameByCode("WMSAPIInfo169"));//"目标条码库存更新失败!");
//}
/// 添加日志
//sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}')
//BEGIN
// RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{2}") + @"',16,1);
// RETURN
//END
//INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
//FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity,
//Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID,
//ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName,
//MTIME,WorkPoint,EATTRIBUTE1)
//SELECT NEWID(),'{3}',b.TransCode,b.TransSequence,a.LotNo ,a.InvCode ,
//'','',c.WarehouseCode,c.LocationCode,c.Quantity,
//'','0','{4}','{5}','0','',
//'','','',f.F_Account ,f.F_RealName ,
//SYSDATETIME() ,a.WorkPoint ,''
//FROM ICSInventoryLot a
//INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
//INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
//INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
//WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
//";
//sql = string.Format(sql, jointLotNo, WorkPoint, User, Identification, TransType, BusinessCode);
//if (!DBHelper.ExecuteNonQuery(sql, cmd))
//{
// throw new Exception(language.GetNameByCode("WMSAPIInfo166"));
//}
}
catch (Exception)
{
throw;
}
}
}
#endregion
#region 生产入库,倒冲
#region 成品(生产)入库,倒冲
if (BusinessCode.Equals(TransTypeEnum.ManufactureReceiveDoc.GetDescription<DBValue>()))
{
#region sql
@ -181,7 +328,7 @@ namespace ICSSoft.DataProject
a.InvCode,
b.InvName,
b.InvStd,
a.Quantity,
a.Quantity/c.Quantity*{2} AS Quantity,
a.Amount,
a.Sequence AS TransSequence,
a.IssueQuantity,
@ -205,7 +352,7 @@ namespace ICSSoft.DataProject
ext.cFree8,
ext.cFree9,
ext.cFree10
INTO #maintemp
INTO #maintemp
FROM
ICSMOPick a
@ -221,7 +368,7 @@ namespace ICSSoft.DataProject
WHERE c.LotNo='{0}' AND c.WorkPoint='{1}'
) temp ON c.MOCode=temp.MOCode AND a.WorkPoint=temp.WorkPoint AND c.Sequence=temp.Sequence
WHERE a.SupplyType='1'
GROUP BY c.MOCode,a.Quantity,a.InvCode,b.InvName,b.InvStd,a.WhCode,a.ExtensionID,a.WorkPoint,inv.BatchEnable,a.MODetailID,a.Amount,a.Sequence,a.IssueQuantity,inv.InvName,inv.InvCode,inv.InvUnit,inv.AmountUnit,c.Sequence,
GROUP BY c.MOCode,a.Quantity,c.Quantity,a.InvCode,b.InvName,b.InvStd,a.WhCode,a.ExtensionID,a.WorkPoint,inv.BatchEnable,a.MODetailID,a.Amount,a.Sequence,a.IssueQuantity,inv.InvName,inv.InvCode,inv.InvUnit,inv.AmountUnit,c.Sequence,
ext.ProjectCode,ext.BatchCode,ext.Version,ext.Brand,ext.cFree1,ext.cFree2,ext.cFree3,ext.cFree4,ext.cFree5,ext.cFree6,ext.cFree7,ext.cFree8,ext.cFree9,ext.cFree10;
select * into #resulttemp from #maintemp
@ -303,12 +450,16 @@ namespace ICSSoft.DataProject
DROP table #resulttemp
DROP table #barcodetemp";
#endregion
sql = String.Format(sql,LotNo,WorkPoint);
sql = String.Format(sql,LotNo,WorkPoint, Quantity);
DataTable table = DBHelper.SQlReturnData(sql,cmd);
string json = JsonConvert.SerializeObject(table);
List<DownItemModel> downItemModels = JsonConvert.DeserializeObject<List<DownItemModel>>(json);
foreach (DownItemModel model in downItemModels)
{
if (model != null && model.LotNo == null || "" == model.LotNo)
{
throw new Exception(language.GetNameByCode("WMSAPIInfo201"));
}
WareHouseLotInfoDown(Identification,model.TransCode,model.Sequence + "~" + model.TransSequence,model.LotNo,model.Quantity,User,WorkPoint,"12",BusinessCode,cmd,language);
//回写已领数量
sql = @"UPDATE ICSMOPick SET IssueQuantity=(ISNULL(IssueQuantity,0)+" + model.Quantity+") WHERE MODetailID='{0}' AND Sequence='{1}' AND WorkPoint='{2}'";
@ -332,7 +483,7 @@ namespace ICSSoft.DataProject
a.InvCode,
b.InvName,
b.InvStd,
a.Quantity,
a.Quantity/c.Quantity*{2} AS Quantity,
a.Amount,
a.Sequence AS TransSequence,
a.IssueQuantity,
@ -372,7 +523,7 @@ namespace ICSSoft.DataProject
WHERE c.LotNo='{0}' AND c.WorkPoint='{1}'
) temp ON c.OOCode=temp.OOCode AND a.WorkPoint=temp.WorkPoint AND c.Sequence=temp.Sequence
WHERE a.SupplyType='1'
GROUP BY c.OOCode,a.Quantity,a.InvCode,b.InvName,b.InvStd,a.WhCode,a.ExtensionID,a.WorkPoint,inv.BatchEnable,a.OODetailID,a.Amount,a.Sequence,a.IssueQuantity,inv.InvName,inv.InvCode,inv.InvUnit,inv.AmountUnit,c.Sequence,
GROUP BY c.OOCode,a.Quantity,c.Quantity,a.InvCode,b.InvName,b.InvStd,a.WhCode,a.ExtensionID,a.WorkPoint,inv.BatchEnable,a.OODetailID,a.Amount,a.Sequence,a.IssueQuantity,inv.InvName,inv.InvCode,inv.InvUnit,inv.AmountUnit,c.Sequence,
ext.ProjectCode,ext.BatchCode,ext.Version,ext.Brand,ext.cFree1,ext.cFree2,ext.cFree3,ext.cFree4,ext.cFree5,ext.cFree6,ext.cFree7,ext.cFree8,ext.cFree9,ext.cFree10;
select * into #resulttemp from #maintemp
@ -454,12 +605,16 @@ namespace ICSSoft.DataProject
DROP table #resulttemp
DROP table #barcodetemp";
#endregion
sql = String.Format(sql, LotNo, WorkPoint);
sql = String.Format(sql, LotNo, WorkPoint, Quantity);
DataTable table = DBHelper.SQlReturnData(sql, cmd);
string json = JsonConvert.SerializeObject(table);
List<DownItemModel> downItemModels = JsonConvert.DeserializeObject<List<DownItemModel>>(json);
foreach (DownItemModel model in downItemModels)
{
if (model != null && model.LotNo == null || "" == model.LotNo)
{
throw new Exception(language.GetNameByCode("WMSAPIInfo201"));
}
WareHouseLotInfoDown(Identification, model.TransCode, model.Sequence + "~" + model.TransSequence, model.LotNo, model.Quantity, User, WorkPoint, "12", BusinessCode, cmd, language);
//回写已领数量
sql = @"UPDATE ICSOOPick SET IssueQuantity=(ISNULL(IssueQuantity,0)+" + model.Quantity+") WHERE OODetailID='{0}' AND Sequence='{1}' AND WorkPoint='{2}'";
@ -472,146 +627,7 @@ namespace ICSSoft.DataProject
}
#endregion
#region 管控方式是"料品"时
ControlMode mode = ICSControlModeService.GetControlMode();
if (mode.itemCode.Equals("ControlMode02"))
{
//查询是否存在料品管控的条码
string sqlStrNew = @"SELECT a.ID,
con.ContainerCode,
con.ContainerName,
a.LotNo,
a.InvCode,
inv.InvName,
inv.InvStd,
inv.InvUnit,-- {0}
inv.AmountUnit,
ext.ID AS ExtensionID,
ext.ProjectCode,
ext.Version,
ext.BatchCode,
ext.Brand,
ext.cFree1,
ext.cFree2,
ext.cFree3,
ext.cFree4,
ext.cFree5,
ext.cFree6,
ext.cFree7,
ext.cFree8,
ext.cFree9,
ext.cFree10,
a.MUSER AS [ USER ],
a.MTIME AS [ MTime ]
FROM
ICSInventoryLot a
LEFT JOIN ICSContainerLot conlot ON a.LotNo = conlot.LotNo AND a.WorkPoint = conlot.WorkPoint
LEFT JOIN ICSContainer con ON conlot.ContainerID = con.ID AND conlot.WorkPoint = con.WorkPoint
INNER JOIN ICSInventory inv ON a.InvCode = inv.InvCode AND a.WorkPoint = inv.WorkPoint
INNER JOIN ICSExtension ext ON a.ExtensionID = ext.ID AND a.WorkPoint = ext.WorkPoint
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'";
sqlStrNew = string.Format(sqlStrNew, jointLotNo, WorkPoint);
DataTable table = DBHelper.SQlReturnData(sqlStrNew, cmd);
string json = JsonConvert.SerializeObject(table);
List<LotNoMode> modelNew = JsonConvert.DeserializeObject<List<LotNoMode>>(json);
//当不存在料品管控条码时,生成新条码
if (!(modelNew.Count > 0))
{
//获取旧条码的信息
string jsonStr = ICSControlModeService.QueryLotNo(LotNo, WorkPoint);
List<LotNoMode> model = JsonConvert.DeserializeObject<List<LotNoMode>>(jsonStr);
//在条码表中插入一条新数据,在条码表中插入一条新数据,并在库存表中添加新数据
LotNoMode lotNoMode = model[0];
CreateLotNo(jointLotNo, Quantity, "", "", WorkPoint, Identification, User, lotNoMode.InvCode, BusinessCode, lotNoMode.ProjectCode,lotNoMode.BatchCode,
lotNoMode.Version,lotNoMode.Brand,lotNoMode.cFree1, lotNoMode.cFree2, lotNoMode.cFree3, lotNoMode.cFree4, lotNoMode.cFree5, lotNoMode.cFree6, lotNoMode.cFree7,
lotNoMode.cFree8, lotNoMode.cFree9, lotNoMode.cFree10,cmd,language,LocationCode);
///添加日志
sql = @"INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity,
Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID,
ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName,
MTIME,WorkPoint,EATTRIBUTE1,LogID)
SELECT NEWID(),'{3}',b.TransCode,b.TransSequence,a.LotNo ,a.InvCode ,
'','',c.WarehouseCode,c.LocationCode,'{6}',
'','0','{4}','{5}','0','',
'','','',f.F_Account ,f.F_RealName ,
SYSDATETIME() ,a.WorkPoint ,'','{7}'
FROM ICSInventoryLot a
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
";
sql = string.Format(sql, jointLotNo, WorkPoint, User, Identification, TransType, BusinessCode, Quantity, LogID);
if (!DBHelper.ExecuteNonQuery(sql, cmd))
{
throw new Exception(language.GetNameByCode("WMSAPIInfo166"));
}
}
//当存在料品管控条码时,直接将数量叠加
else
{
try
{
///更新目标条码库存
sql = @"
IF NOT EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}')
BEGIN
RAISERROR('" + language.GetNameByCode("WMSAPIInfo171") + @"',16,1);
RETURN
END
UPDATE ICSWareHouseLotInfo SET Quantity=ISNULL(Quantity,0)+'{2}' WHERE LotNo='{0}' AND WorkPoint='{1}'
";
sql = string.Format(sql, jointLotNo, WorkPoint, Quantity);
if (!DBHelper.ExecuteNonQuery(sql, cmd))
{
throw new Exception(language.GetNameByCode("WMSAPIInfo169"));//"目标条码库存更新失败!");
}
///添加日志
sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}')
BEGIN
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{2}") + @"',16,1);
RETURN
END
INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity,
Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID,
ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName,
MTIME,WorkPoint,EATTRIBUTE1)
SELECT NEWID(),'{3}',b.TransCode,b.TransSequence,a.LotNo ,a.InvCode ,
'','',c.WarehouseCode,c.LocationCode,c.Quantity,
'','0','{4}','{5}','0','',
'','','',f.F_Account ,f.F_RealName ,
SYSDATETIME() ,a.WorkPoint ,''
FROM ICSInventoryLot a
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
";
sql = string.Format(sql, jointLotNo, WorkPoint, User, Identification, TransType, BusinessCode);
if (!DBHelper.ExecuteNonQuery(sql, cmd))
{
throw new Exception(language.GetNameByCode("WMSAPIInfo166"));
}
}
catch (Exception)
{
throw;
}
}
}
#endregion
}
catch (Exception)
@ -1495,7 +1511,7 @@ namespace ICSSoft.DataProject
ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName,
MTIME,WorkPoint,EATTRIBUTE1)
SELECT NEWID(),'{3}',b.TransCode,b.TransSequence,a.LotNo ,a.InvCode ,
'','',c.WarehouseCode,c.LocationCode,c.Quantity,
'','',c.WarehouseCode,c.LocationCode,'{6}',
'','0','{4}','{5}','0','',
'','','',f.F_Account ,f.F_RealName ,
SYSDATETIME() ,a.WorkPoint ,''
@ -1505,7 +1521,7 @@ namespace ICSSoft.DataProject
INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
";
sql = string.Format(sql, CurrentLotNo, WorkPoint, User, Identification, TransType, BusinessCode);
sql = string.Format(sql, CurrentLotNo, WorkPoint, User, Identification, TransType, BusinessCode,Quantity);
if (!DBHelper.ExecuteNonQuery(sql, cmd))
{
@ -2199,6 +2215,7 @@ namespace ICSSoft.DataProject
{
log.Debug(ex.ToString());
log.Debug(TransType + Environment.NewLine + ERPupdate);
throw;
}
}
@ -2239,7 +2256,7 @@ namespace ICSSoft.DataProject
/// <param name="cmd"></param>
/// <param name="language"></param>
public static void CreateLotNo(string LotNo, string Quantity, string TransCode, string TransSequence, string WorkPoint, string Identification, string User, string InvCode, string BusinessCode,
string ProjectCode, string BatchCode, string Version, string Brand, string cFree1, string cFree2, string cFree3, string cFree4, string cFree5,string cFree6, string cFree7, string cFree8, string cFree9, string cFree10, SqlCommand cmd, Dictionary<string, string> language,string LocationCode)
string ProjectCode, string BatchCode, string Version, string Brand, string cFree1, string cFree2, string cFree3, string cFree4, string cFree5,string cFree6, string cFree7, string cFree8, string cFree9, string cFree10, SqlCommand cmd, Dictionary<string, string> language,string LocationCode,string OLDLotNo)
{
try
{
@ -2333,7 +2350,7 @@ namespace ICSSoft.DataProject
LastPrintUser,LastPrintTime,MUSER,MUSERName,MTIME,
WorkPoint,EATTRIBUTE1)
SELECT TOP 1 NEWID(),'{0}','{8}',GETDATE(),'{6}',
1,'0','{7}','16',null,
'{1}','0','{7}','16',null,
null,null,'{2}' ,f.F_RealName ,GETDATE(),
'{4}' ,''
FROM Sys_SRM_User f
@ -2354,13 +2371,14 @@ namespace ICSSoft.DataProject
INSERT INTO ICSInventoryLotDetail(LotNo,TransCode,TransSequence,MUSER,MUSERName,MTIME,
WorkPoint,EATTRIBUTE1)
SELECT a.LotNo,'{0}','{1}',f.F_Account ,f.F_RealName,GETDATE(),
SELECT '{4}',b.TransCode,b.TransSequence,f.F_Account ,f.F_RealName,GETDATE(),
a.WorkPoint,''
FROM ICSInventoryLot a
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
WHERE a.LotNo='{4}' AND a.WorkPoint='{3}'
WHERE a.LotNo='{5}' AND a.WorkPoint='{3}'
";
sql = string.Format(sql, TransCode, TransSequence, User, WorkPoint, LotNo);
sql = string.Format(sql, TransCode, TransSequence, User, WorkPoint, LotNo, OLDLotNo);
if (!DBHelper.ExecuteNonQuery(sql, cmd))
{

Loading…
Cancel
Save