@ -178,10 +178,10 @@ namespace ICSSoft.DataProject
SELECT
c . MOCode AS TransCode ,
a . MODetailID AS DetailID ,
a . InvCode ,
b . InvName ,
b . InvStd ,
a . Quantity ,
a . InvCode ,
b . InvName ,
b . InvStd ,
a . Quantity ,
a . Amount ,
a . Sequence AS TransSequence ,
a . IssueQuantity ,
@ -478,8 +478,43 @@ namespace ICSSoft.DataProject
if ( mode . itemCode . Equals ( "ControlMode02" ) )
{
//查询是否存在料品管控的条码
string jsonStrNew = ICSControlModeService . QueryLotNo ( jointLotNo , WorkPoint ) ;
List < LotNoMode > modelNew = JsonConvert . DeserializeObject < List < LotNoMode > > ( jsonStrNew ) ;
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 ) )
@ -517,12 +552,61 @@ namespace ICSSoft.DataProject
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo166" ) ) ;
}
}
//当存在料品管控条码时,执行合批
//当存在料品管控条码时,直接将数量叠加
else
{
LotNoMode lotNoMode = modelNew [ 0 ] ;
WareHouseLotInfoMerge ( Identification , jointLotNo , LotNo , Quantity , User , WorkPoint , TransType , BusinessCode , cmd , language ) ;
try
{
///更新目标条码库存
sql = @ "
IF NOT EXISTS ( SELECT a . LotNo FROM ICSWareHouseLotInfo a WHERE a . LotNo = ' { 0 } ' AND a . WorkPoint = ' { 1 } ' )
BEGIN
RAISERROR ( ' " + language.GetNameByCode(" WMSAPIInfo171 ") + @" ' , 1 6 , 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 } ") + @" ' , 1 6 , 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 ;
}
}
@ -917,6 +1001,20 @@ namespace ICSSoft.DataProject
}
if ( ! LotEnable . Equals ( "False" ) )
{
///更新库存
sql = @ "UPDATE ICSWareHouseLotInfo SET Quantity=ISNULL(Quantity,0)-'{2}' WHERE LotNo='{0}' AND WorkPoint='{1}'
IF EXISTS ( SELECT a . LotNo FROM ICSWareHouseLotInfo a WHERE a . LotNo = ' { 0 } ' AND a . WorkPoint = ' { 1 } ' AND Quantity < 0 )
BEGIN
RAISERROR ( ' " + language.GetNameByCode(" WMSAPIInfo167 ") + @" ' , 1 6 , 1 ) ;
RETURN
END ";
sql = string . Format ( sql , LotNo , WorkPoint , Quantity ) ;
if ( ! DBHelper . ExecuteNonQuery ( sql , cmd ) )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo168" ) ) ; //"库存更新失败!");
}
///分批前添加日志
sql = @ "IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}')
@ -983,7 +1081,7 @@ namespace ICSSoft.DataProject
}
#endregion
sql = @ "INSERT INTO ICSWareHouseLotInfo(ID,LotNO,WarehouseCode,LocationCode,InvCode,Quantity,InDate,LockQuantity,MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1)
select NEWID ( ) , ' { 0 } ' , WarehouseCode , LocationCode , InvCode , '0 ', InDate , LockQuantity
select NEWID ( ) , ' { 0 } ' , WarehouseCode , LocationCode , InvCode , ' { 2 } ' , InDate , LockQuantity
, MUSER , MUSERName , GETDATE ( ) , ' { 3 } ',' '
from ICSWareHouseLotInfo
where LotNO = ' { 1 } ' AND WorkPoint = ' { 3 } ' ";
@ -1013,7 +1111,7 @@ namespace ICSSoft.DataProject
ERPDetailID , ERPCode , ERPSequence , MUSER , MUSERName ,
MTIME , WorkPoint , EATTRIBUTE1 , LogID )
SELECT NEWID ( ) , ' { 3 } ',' { 4 } ',' { 5 } ',' { 1 0 } ' , a . InvCode ,
c . WarehouseCode , c . LocationCode , ' ',' ',' { 6 } ' ,
c . WarehouseCode , c . LocationCode , ' { 1 1 } ',' { 1 2 } ',' { 6 } ' ,
' ',' 0 ',' { 7 } ',' { 8 } ',' 0 ',' ' ,
' ',' ',' ' , f . F_Account , f . F_RealName ,
SYSDATETIME ( ) , a . WorkPoint , ' ',' { 9 } '
@ -1022,7 +1120,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 , LotNo , WorkPoint , User , Identification , TransCode , TransSequence , Quantity , TransType , BusinessCode , MergeID , lotstr ) ;
sql = string . Format ( sql , LotNo , WorkPoint , User , Identification , TransCode , TransSequence , Quantity , TransType , BusinessCode , MergeID , lotstr , WarehouseCode , LocationCode ) ;
cmd . CommandText = sql ;
result = cmd . ExecuteNonQuery ( ) ;
if ( result < = 0 )
@ -1092,7 +1190,7 @@ namespace ICSSoft.DataProject
Memo , Lock , TransType , BusinessCode , ERPUpload , ERPID ,
ERPDetailID , ERPCode , ERPSequence , MUSER , MUSERName ,
MTIME , WorkPoint , EATTRIBUTE1 , MergeID )
SELECT NEWID ( ) , ' { 3 } ',' ',' ' , a . LotNo , a . InvCode ,
SELECT NEWID ( ) , ' { 3 } ',' { 4 } ',' { 5 } ' , a . LotNo , a . InvCode ,
c . WarehouseCode , c . LocationCode , ' { 9 } ',' { 1 0 } ' , { 6 } ,
' ',' 0 ',' { 7 } ',' { 8 } ',' 0 ',' ' ,
' ',' ',' ' , f . F_Account , f . F_RealName ,
@ -1108,6 +1206,21 @@ namespace ICSSoft.DataProject
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo166" ) ) ;
}
///更新库存
sql = @ "UPDATE ICSWareHouseLotInfo SET WareHouseCode='{2}',LocationCode='{3}' WHERE LotNo='{0}' AND WorkPoint='{1}'
IF EXISTS ( SELECT a . LotNo FROM ICSWareHouseLotInfo a WHERE a . LotNo = ' { 0 } ' AND a . WorkPoint = ' { 1 } ' AND Quantity < 0 )
BEGIN
RAISERROR ( ' " + language.GetNameByCode(" WMSAPIInfo167 ") + @" ' , 1 6 , 1 ) ;
RETURN
END ";
sql = string . Format ( sql , LotNo , WorkPoint , WarehouseCode , LocationCode ) ;
if ( ! DBHelper . ExecuteNonQuery ( sql , cmd ) )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo168" ) ) ; //"库存更新失败!");
}
}
}