|
|
@ -9,6 +9,7 @@ using ICSSoft.Frame.Data.Entity; |
|
|
|
using ICSSoft.Base.Config.AppConfig; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.IO; |
|
|
|
using Newtonsoft.Json; |
|
|
|
|
|
|
|
namespace ICSSoft.FromERP |
|
|
|
{ |
|
|
@ -48,55 +49,61 @@ namespace ICSSoft.FromERP |
|
|
|
try |
|
|
|
{ |
|
|
|
//获取成品入库单
|
|
|
|
var manufactureReceives = db.ICSManufactureReceive.Where(e=>e.Status=="3"&&e.RCVQuantity==0).ToList(); |
|
|
|
var manufactureReceives = db.ICSManufactureReceive.Where(e => e.Status == "3" && e.RCVQuantity == 0).ToList(); |
|
|
|
//基础信息
|
|
|
|
DateTime time = DateTime.Now; |
|
|
|
string user= "JOB"; |
|
|
|
string username = "JOB"; |
|
|
|
if (manufactureReceives.Any()) |
|
|
|
string user = "JOB"; |
|
|
|
string username = "JOB"; |
|
|
|
if (manufactureReceives.Any()) |
|
|
|
{ |
|
|
|
foreach (var data in manufactureReceives) |
|
|
|
foreach (var data in manufactureReceives) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.Info(JsonConvert.SerializeObject(data)); |
|
|
|
|
|
|
|
|
|
|
|
string invCode = data.InvCode; |
|
|
|
string workPoint = data.WorkPoint; |
|
|
|
decimal quantity = data.Quantity; |
|
|
|
string rcvCode = data.RCVCode; |
|
|
|
string sequence=data.Sequence; |
|
|
|
var warehouse = db.ICSWarehouse.SingleOrDefault(e=>e.WarehouseCode==data.WHCode&&e.WorkPoint==data.WorkPoint); |
|
|
|
string location = db.ICSLocation.Where(e=>e.WHID== warehouse.ID&&e.WorkPoint==workPoint).FirstOrDefault()?.LocationCode; |
|
|
|
string sequence = data.Sequence; |
|
|
|
var warehouse = db.ICSWarehouse.SingleOrDefault(e => e.WarehouseCode == data.WHCode && e.WorkPoint == data.WorkPoint); |
|
|
|
string location = db.ICSLocation.Where(e => e.WHID == warehouse.ID && e.WorkPoint == workPoint).FirstOrDefault()?.LocationCode; |
|
|
|
log.Info(location); |
|
|
|
string sql = $@"EXEC Addins_GetSerialCode '{workPoint}','ICSInventoryLot','LotNO','KCP{rcvCode}{sequence}',5;"; |
|
|
|
log.Info(sql); |
|
|
|
string lotNo; |
|
|
|
log.Info(data.IsSerialNumber); |
|
|
|
if (data.IsSerialNumber == "ZS01") |
|
|
|
{ |
|
|
|
var extention = db.ICSExtension.Where(e => e.ID==data.ExtensionID)?.SingleOrDefault(); |
|
|
|
if (extention!=null) |
|
|
|
{ |
|
|
|
lotNo = extention.BatchCode; |
|
|
|
var extention = db.ICSExtension.Where(e => e.ID == data.ExtensionID)?.SingleOrDefault(); |
|
|
|
if (extention != null) |
|
|
|
{ |
|
|
|
lotNo = extention.BatchCode; |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
lotNo = ICSHelper.ExecuteScalar(CommandType.Text, sql).ToString(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
log.Info("111"); |
|
|
|
lotNo = ICSHelper.ExecuteScalar(CommandType.Text, sql).ToString(); |
|
|
|
} |
|
|
|
log.Info(lotNo); |
|
|
|
//条码
|
|
|
|
var inventoryLot = new ICSInventoryLot() |
|
|
|
{ |
|
|
|
ID = AppConfig.GetGuid(), |
|
|
|
LotNo = lotNo, |
|
|
|
InvCode= invCode, |
|
|
|
ProductDate=time, |
|
|
|
ExpirationDate=time.AddYears(+100), |
|
|
|
Quantity= quantity, |
|
|
|
Amount=data.Amount, |
|
|
|
ExtensionID=data.ExtensionID, |
|
|
|
Type="9", |
|
|
|
InvCode = invCode, |
|
|
|
ProductDate = time, |
|
|
|
ExpirationDate = time.AddYears(+100), |
|
|
|
Quantity = quantity, |
|
|
|
Amount = data.Amount, |
|
|
|
ExtensionID = data.ExtensionID, |
|
|
|
Type = "9", |
|
|
|
MUSER = user, |
|
|
|
MUSERName = username, |
|
|
|
MTIME = time, |
|
|
@ -104,71 +111,71 @@ namespace ICSSoft.FromERP |
|
|
|
|
|
|
|
}; |
|
|
|
//库存表
|
|
|
|
var wareHouseLotInfo = new ICSWareHouseLotInfo() |
|
|
|
var wareHouseLotInfo = new ICSWareHouseLotInfo() |
|
|
|
{ |
|
|
|
ID= AppConfig.GetGuid(), |
|
|
|
LotNo= lotNo, |
|
|
|
WarehouseCode=data.WHCode, |
|
|
|
LocationCode=location, |
|
|
|
InvCode= invCode, |
|
|
|
Quantity= quantity, |
|
|
|
InDate=time, |
|
|
|
LockQuantity=0, |
|
|
|
MUSER= user, |
|
|
|
MUSERName= username, |
|
|
|
MTIME=time, |
|
|
|
WorkPoint= workPoint, |
|
|
|
EATTRIBUTE1="" |
|
|
|
|
|
|
|
ID = AppConfig.GetGuid(), |
|
|
|
LotNo = lotNo, |
|
|
|
WarehouseCode = data.WHCode, |
|
|
|
LocationCode = location, |
|
|
|
InvCode = invCode, |
|
|
|
Quantity = quantity, |
|
|
|
InDate = time, |
|
|
|
LockQuantity = 0, |
|
|
|
MUSER = user, |
|
|
|
MUSERName = username, |
|
|
|
MTIME = time, |
|
|
|
WorkPoint = workPoint, |
|
|
|
EATTRIBUTE1 = "" |
|
|
|
|
|
|
|
}; |
|
|
|
//条码单据关联
|
|
|
|
var inventoryLotDetail = new ICSInventoryLotDetail() |
|
|
|
{ |
|
|
|
LotNo = lotNo, |
|
|
|
TransCode = rcvCode, |
|
|
|
TransSequence= sequence, |
|
|
|
MUSER=user, |
|
|
|
MUSERName=username, |
|
|
|
MTIME=time, |
|
|
|
WorkPoint=workPoint, |
|
|
|
EATTRIBUTE1="" |
|
|
|
|
|
|
|
TransSequence = sequence, |
|
|
|
MUSER = user, |
|
|
|
MUSERName = username, |
|
|
|
MTIME = time, |
|
|
|
WorkPoint = workPoint, |
|
|
|
EATTRIBUTE1 = "" |
|
|
|
|
|
|
|
}; |
|
|
|
//出入库记录
|
|
|
|
var wareHouseLotInfoLog = new ICSWareHouseLotInfoLog() |
|
|
|
{ |
|
|
|
ID= AppConfig.GetGuid(), |
|
|
|
Identification= wareHouseLotInfo.ID, |
|
|
|
TransCode= rcvCode, |
|
|
|
TransSequence= sequence, |
|
|
|
LotNo= lotNo, |
|
|
|
InvCode= invCode, |
|
|
|
FromWarehouseCode="", |
|
|
|
FromLocationCode="", |
|
|
|
ToWarehouseCode=data.WHCode, |
|
|
|
ToLocationCode=location, |
|
|
|
Quantity= quantity, |
|
|
|
Memo="", |
|
|
|
Lock=false, |
|
|
|
TransType="2", |
|
|
|
BusinessCode="18", |
|
|
|
ERPUpload=false, |
|
|
|
ERPID="", |
|
|
|
ERPDetailID="", |
|
|
|
ERPCode="", |
|
|
|
ERPSequence="", |
|
|
|
LogID="", |
|
|
|
MergeID="", |
|
|
|
MUSER=user, |
|
|
|
MUSERName=username, |
|
|
|
MTIME=time, |
|
|
|
WorkPoint=workPoint |
|
|
|
ID = AppConfig.GetGuid(), |
|
|
|
Identification = wareHouseLotInfo.ID, |
|
|
|
TransCode = rcvCode, |
|
|
|
TransSequence = sequence, |
|
|
|
LotNo = lotNo, |
|
|
|
InvCode = invCode, |
|
|
|
FromWarehouseCode = "", |
|
|
|
FromLocationCode = "", |
|
|
|
ToWarehouseCode = data.WHCode, |
|
|
|
ToLocationCode = location, |
|
|
|
Quantity = quantity, |
|
|
|
Memo = "", |
|
|
|
Lock = false, |
|
|
|
TransType = "2", |
|
|
|
BusinessCode = "18", |
|
|
|
ERPUpload = false, |
|
|
|
ERPID = "", |
|
|
|
ERPDetailID = "", |
|
|
|
ERPCode = "", |
|
|
|
ERPSequence = "", |
|
|
|
LogID = "", |
|
|
|
MergeID = "", |
|
|
|
MUSER = user, |
|
|
|
MUSERName = username, |
|
|
|
MTIME = time, |
|
|
|
WorkPoint = workPoint |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data.RCVQuantity = quantity; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data.RCVQuantity = quantity; |
|
|
|
db.ICSInventoryLot.InsertOnSubmit(inventoryLot); |
|
|
|
db.ICSInventoryLotDetail.InsertOnSubmit(inventoryLotDetail); |
|
|
|
db.ICSWareHouseLotInfo.InsertOnSubmit(wareHouseLotInfo); |
|
|
|