执行代码清理,修复warning
This commit is contained in:
@@ -92,10 +92,10 @@ namespace Tnb.WarehouseMgr
|
||||
* 2.1 根据这些库位去查任务执行 目的库位是这些库位的未完成任务数。 A 10 B 9
|
||||
* 2.2 哪个最少给哪个
|
||||
*/
|
||||
var org = await _db.Queryable<OrganizeEntity>().FirstAsync(it => it.Id == input.data[nameof(WmsOutstockH.station_id)].ToString());
|
||||
OrganizeEntity? org = await _db.Queryable<OrganizeEntity>().FirstAsync(it => it.Id == input.data[nameof(WmsOutstockH.station_id)].ToString());
|
||||
if (!org?.FeedingLocationId.IsNullOrWhiteSpace() ?? false)
|
||||
{
|
||||
var fLocIds = JArray.Parse(org.FeedingLocationId).Values<string>().ToList();
|
||||
List<string?> fLocIds = JArray.Parse(org.FeedingLocationId).Values<string>().ToList();
|
||||
var minTaskNumLocs = await _db.Queryable<WmsPretaskH>().Where(it => it.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && fLocIds.Contains(it.endlocation_id))
|
||||
.GroupBy(it => it.endlocation_id)
|
||||
.Select(it => new
|
||||
@@ -108,21 +108,21 @@ namespace Tnb.WarehouseMgr
|
||||
.ToListAsync();
|
||||
if (minTaskNumLocs?.Count > 0)
|
||||
{
|
||||
var freeLocIds = fLocIds.Except(minTaskNumLocs.Select(x => x.endlocation_id)).ToList();
|
||||
List<string?> freeLocIds = fLocIds.Except(minTaskNumLocs.Select(x => x.endlocation_id)).ToList();
|
||||
if (freeLocIds?.Count > 0)
|
||||
{
|
||||
var rIdx = new Random().Next(0, freeLocIds.Count);
|
||||
int rIdx = new Random().Next(0, freeLocIds.Count);
|
||||
loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == freeLocIds[rIdx]);
|
||||
}
|
||||
else
|
||||
{
|
||||
var firstLocId = minTaskNumLocs.FirstOrDefault().endlocation_id;
|
||||
string firstLocId = minTaskNumLocs.FirstOrDefault().endlocation_id;
|
||||
loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == firstLocId);
|
||||
}
|
||||
}
|
||||
else if (minTaskNumLocs?.Count < 1)
|
||||
{
|
||||
var rIdx = new Random().Next(0, fLocIds.Count);
|
||||
int rIdx = new Random().Next(0, fLocIds.Count);
|
||||
loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == fLocIds[rIdx]);
|
||||
}
|
||||
input.data[nameof(WmsOutstockH.location_id)] = loc.id;
|
||||
@@ -130,26 +130,26 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
|
||||
|
||||
var carryIds = new List<string>();
|
||||
List<string> carryIds = new();
|
||||
//tablefield120 出库物料明细
|
||||
if (input.data.ContainsKey("tablefield120") && input.data["tablefield120"].IsNotEmptyOrNull())
|
||||
{
|
||||
var outStockDList = input.data["tablefield120"].ToObject<List<WmsOutstockD>>();
|
||||
List<WmsOutstockD> outStockDList = input.data["tablefield120"].ToObject<List<WmsOutstockD>>();
|
||||
if (outStockDList?.Count > 0)
|
||||
{
|
||||
List<WmsCarryMat> carryMats = new();
|
||||
List<WmsCarryCode> carryCodes = new();
|
||||
List<WmsCarryCode> carryCodesPart = new();
|
||||
foreach (var os in outStockDList)
|
||||
foreach (WmsOutstockD os in outStockDList)
|
||||
{
|
||||
var OutStockStrategyInput = new OutStockStrategyQuery
|
||||
OutStockStrategyQuery OutStockStrategyInput = new()
|
||||
{
|
||||
carry_id = input.data[nameof(OutStockStrategyQuery.carry_id)]?.ToString() ?? string.Empty,
|
||||
warehouse_id = input.data[nameof(WmsOutstockH.warehouse_id)]?.ToString() ?? string.Empty,
|
||||
material_id = os.material_id,
|
||||
code_batch = os.code_batch,
|
||||
};
|
||||
var outStkCarrys = await _wareHouseService.OutStockStrategy(OutStockStrategyInput);
|
||||
List<WmsCarryH> outStkCarrys = await _wareHouseService.OutStockStrategy(OutStockStrategyInput);
|
||||
Expression<Func<WmsCarryH, WmsCarryCode, bool>> whereExp = input.data.ContainsKey(nameof(WmsOutstockH.carry_id)) && input.data[nameof(WmsOutstockH.carry_id)].IsNotEmptyOrNull()
|
||||
? (a, b) => a.id == input.data[nameof(WmsOutstockH.carry_id)].ToString()
|
||||
: (a, b) => outStkCarrys.Select(x => x.id).Contains(b.carry_id);
|
||||
@@ -163,7 +163,7 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
if (carryCodesPart?.Count > 0)
|
||||
{
|
||||
var codeQty = carryCodesPart.Sum(x => x.codeqty);
|
||||
decimal codeQty = carryCodesPart.Sum(x => x.codeqty);
|
||||
if (codeQty < os.pr_qty)
|
||||
{
|
||||
throw new AppFriendlyException($"需要出库[{os.pr_qty}],实际库存{codeQty},数量不足", 500);
|
||||
@@ -185,7 +185,7 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
carryCodes.AddRange(curCarryCodes);
|
||||
var partCarryMats = curCarryCodes.Adapt<List<WmsCarryMat>>();
|
||||
List<WmsCarryMat> partCarryMats = curCarryCodes.Adapt<List<WmsCarryMat>>();
|
||||
for (int i = 0; i < partCarryMats.Count; i++)
|
||||
{
|
||||
partCarryMats[i].need_qty = curCarryCodes[i].codeqty;
|
||||
@@ -199,19 +199,19 @@ namespace Tnb.WarehouseMgr
|
||||
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
|
||||
.Select(x =>
|
||||
{
|
||||
var arr = x.ToArray();
|
||||
WmsCarryMat[] arr = x.ToArray();
|
||||
WmsCarryMat carryMat = arr[^arr.Length];
|
||||
carryMat.need_qty = x.Sum(d => d.need_qty);
|
||||
return carryMat;
|
||||
})
|
||||
.ToList();
|
||||
await _db.Insertable(carryMats).ExecuteCommandAsync();
|
||||
var dic = carryMats.DistinctBy(x => x.carry_id).ToDictionary(x => x.carry_id, x => x.need_qty);
|
||||
var allOutIds = new List<string>();
|
||||
var sortingOutIds = new List<string>();
|
||||
foreach (var pair in dic)
|
||||
_ = await _db.Insertable(carryMats).ExecuteCommandAsync();
|
||||
Dictionary<string, decimal> dic = carryMats.DistinctBy(x => x.carry_id).ToDictionary(x => x.carry_id, x => x.need_qty);
|
||||
List<string> allOutIds = new();
|
||||
List<string> sortingOutIds = new();
|
||||
foreach (KeyValuePair<string, decimal> pair in dic)
|
||||
{
|
||||
var codes = carryCodesPart.FindAll(x => x.carry_id == pair.Key);
|
||||
List<WmsCarryCode> codes = carryCodesPart.FindAll(x => x.carry_id == pair.Key);
|
||||
if (codes?.Count > 0)
|
||||
{
|
||||
if (pair.Value == codes.Sum(d => d.codeqty))
|
||||
@@ -225,18 +225,18 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
carryIds = allOutIds.Concat(sortingOutIds).ToList();
|
||||
var carryH = new WmsCarryH
|
||||
WmsCarryH carryH = new()
|
||||
{
|
||||
out_status = ((int)EnumOutStatus.全部出).ToString(),
|
||||
source_id = input.data.ContainsKey(nameof(WmsOutstockH.source_id)) ? input.data[nameof(WmsOutstockH.source_id)]?.ToString() ?? string.Empty : string.Empty,
|
||||
source_code = input.data.ContainsKey(nameof(WmsOutstockH.source_code)) ? input.data[nameof(WmsOutstockH.source_code)]?.ToString() ?? string.Empty : string.Empty,
|
||||
};
|
||||
await _db.Updateable(carryH)
|
||||
_ = await _db.Updateable(carryH)
|
||||
.UpdateColumns(it => new { it.out_status, it.source_id, it.source_code })
|
||||
.Where(it => allOutIds.Contains(it.id))
|
||||
.ExecuteCommandAsync();
|
||||
carryH.out_status = ((int)EnumOutStatus.分拣出).ToString();
|
||||
await _db.Updateable(carryH)
|
||||
_ = await _db.Updateable(carryH)
|
||||
.UpdateColumns(it => new { it.out_status, it.source_id, it.source_code })
|
||||
.Where(it => sortingOutIds.Contains(it.id))
|
||||
.ExecuteCommandAsync();
|
||||
@@ -244,7 +244,7 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
|
||||
|
||||
var carrys = await _db.Queryable<WmsCarryH>().Where(it => carryIds.Contains(it.id)).ToListAsync();
|
||||
List<WmsCarryH> carrys = await _db.Queryable<WmsCarryH>().Where(it => carryIds.Contains(it.id)).ToListAsync();
|
||||
if (carrys?.Count > 0)
|
||||
{
|
||||
|
||||
@@ -254,10 +254,13 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
List<WmsPretaskH> preTasks = new();
|
||||
List<string> locIds = new();
|
||||
foreach (var carry in carrys)
|
||||
foreach (WmsCarryH carry in carrys)
|
||||
{
|
||||
var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
|
||||
if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500);
|
||||
bool isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
|
||||
if (!isMatch)
|
||||
{
|
||||
throw new AppFriendlyException("该载具无法放置到目标库位", 500);
|
||||
}
|
||||
|
||||
WmsPointH sPoint = null!;
|
||||
WmsPointH ePoint = null!;
|
||||
@@ -272,16 +275,20 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
if (sPoint != null && ePoint != null)
|
||||
{
|
||||
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||
List<WmsPointH> points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||
locIds.AddRange(points.Select(x => x.location_id).ToList()!);
|
||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||
if (points?.Count > 0)
|
||||
{
|
||||
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
|
||||
var curPreTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
||||
if (points.Count <= 2)
|
||||
{
|
||||
var sPoint = it.FirstOrDefault();
|
||||
var ePoint = it.LastOrDefault();
|
||||
throw new AppFriendlyException("该路径不存在", 500);
|
||||
}
|
||||
|
||||
List<WmsPretaskH> curPreTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
||||
{
|
||||
WmsPointH? sPoint = it.FirstOrDefault();
|
||||
WmsPointH? ePoint = it.LastOrDefault();
|
||||
|
||||
WmsPretaskH preTask = new()
|
||||
{
|
||||
@@ -321,10 +328,10 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
List<WmsPretaskCode> pretaskCodes = new();
|
||||
foreach (var pt in preTasks)
|
||||
foreach (WmsPretaskH pt in preTasks)
|
||||
{
|
||||
var partCodes = carryCodes.FindAll(x => x.carry_id == pt.carry_id).Distinct().ToList();
|
||||
var curPreTaskCodes = partCodes.Adapt<List<WmsPretaskCode>>();
|
||||
List<WmsCarryCode> partCodes = carryCodes.FindAll(x => x.carry_id == pt.carry_id).Distinct().ToList();
|
||||
List<WmsPretaskCode> curPreTaskCodes = partCodes.Adapt<List<WmsPretaskCode>>();
|
||||
curPreTaskCodes.ForEach(x =>
|
||||
{
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
@@ -333,24 +340,30 @@ namespace Tnb.WarehouseMgr
|
||||
});
|
||||
pretaskCodes.AddRange(curPreTaskCodes);
|
||||
}
|
||||
var isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes);
|
||||
bool isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes);
|
||||
if (isOk)
|
||||
{
|
||||
outStockDList.ForEach(x => x.line_status = WmsWareHouseConst.BILLSTATUS_ON_ID);
|
||||
await _db.Updateable(outStockDList).UpdateColumns(it => it.line_status).ExecuteCommandAsync();
|
||||
await _db.Updateable<WmsOutstockH>().SetColumns(it => it.status == WmsWareHouseConst.BILLSTATUS_ON_ID).Where(it => it.id == input.data["ReturnIdentity"].ToString()).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable(outStockDList).UpdateColumns(it => it.line_status).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable<WmsOutstockH>().SetColumns(it => it.status == WmsWareHouseConst.BILLSTATUS_ON_ID).Where(it => it.id == input.data["ReturnIdentity"].ToString()).ExecuteCommandAsync();
|
||||
|
||||
GenPreTaskUpInput genPreTaskAfterUpInput = new();
|
||||
genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList();
|
||||
genPreTaskAfterUpInput.LocationIds = new HashSet<string>(locIds).ToList();
|
||||
GenPreTaskUpInput genPreTaskAfterUpInput = new()
|
||||
{
|
||||
CarryIds = preTasks.Select(x => x.carry_id).ToList(),
|
||||
LocationIds = new HashSet<string>(locIds).ToList()
|
||||
};
|
||||
await _wareHouseService.GenInStockTaskHandleAfter(genPreTaskAfterUpInput, it => new WmsCarryH { is_lock = 1 }, it => new BasLocation { is_lock = 1 });
|
||||
}
|
||||
}
|
||||
else throw new AppFriendlyException("库存不足", 500);
|
||||
else
|
||||
{
|
||||
throw new AppFriendlyException("库存不足", 500);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AppFriendlyException($"请输入物料明细", 500);
|
||||
}
|
||||
else throw new AppFriendlyException($"请输入物料明细", 500);
|
||||
|
||||
|
||||
}
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
@@ -369,7 +382,7 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
|
||||
|
||||
public async Task<dynamic> PrintTest(List<string> barCodes)
|
||||
public dynamic? PrintTest(List<string> barCodes)
|
||||
{
|
||||
// open port.
|
||||
int nLen, ret, sw;
|
||||
@@ -378,7 +391,7 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
IntPtr ver;
|
||||
System.Text.Encoding encAscII = System.Text.Encoding.ASCII;
|
||||
System.Text.Encoding encUnicode = System.Text.Encoding.Unicode;
|
||||
_ = System.Text.Encoding.Unicode;
|
||||
|
||||
// dll version.
|
||||
ver = PPLBUtility.B_Get_DLL_Version(0);
|
||||
@@ -393,8 +406,8 @@ namespace Tnb.WarehouseMgr
|
||||
int len1 = 128, len2 = 128;
|
||||
buf1 = new byte[len1];
|
||||
buf2 = new byte[len2];
|
||||
PPLBUtility.B_EnumUSB(pbuf);
|
||||
PPLBUtility.B_GetUSBDeviceInfo(1, buf1, out len1, buf2, out len2);
|
||||
_ = PPLBUtility.B_EnumUSB(pbuf);
|
||||
_ = PPLBUtility.B_GetUSBDeviceInfo(1, buf1, out len1, buf2, out len2);
|
||||
sw = 1;
|
||||
if (1 == sw)
|
||||
{
|
||||
@@ -406,62 +419,61 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
if (0 != ret)
|
||||
{
|
||||
strmsg += "Open USB fail!";
|
||||
}
|
||||
else
|
||||
{
|
||||
strmsg += "Open USB:\r\nDevice name: ";
|
||||
strmsg += encAscII.GetString(buf1, 0, len1);
|
||||
strmsg += "\r\nDevice path: ";
|
||||
strmsg += encAscII.GetString(buf2, 0, len2);
|
||||
_ = encAscII.GetString(buf2, 0, len2);
|
||||
//sw = 2;
|
||||
if (2 == sw)
|
||||
{
|
||||
//Immediate Error Report.
|
||||
PPLBUtility.B_WriteData(1, encAscII.GetBytes("^ee\r\n"), 5);//^ee
|
||||
_ = PPLBUtility.B_WriteData(1, encAscII.GetBytes("^ee\r\n"), 5);//^ee
|
||||
ret = PPLBUtility.B_ReadData(pbuf, 4, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(PPLBUtility.szSavePath);
|
||||
_ = System.IO.Directory.CreateDirectory(PPLBUtility.szSavePath);
|
||||
ret = PPLBUtility.B_CreatePrn(0, PPLBUtility.szSaveFile);// open file.
|
||||
strmsg += "Open ";
|
||||
strmsg += PPLBUtility.szSaveFile;
|
||||
if (0 != ret)
|
||||
{
|
||||
strmsg += " file fail!";
|
||||
}
|
||||
else
|
||||
{
|
||||
strmsg += " file succeed!";
|
||||
}
|
||||
}
|
||||
if (0 != ret)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// sample setting.
|
||||
//B_Set_DebugDialog(1);
|
||||
//var sznop2 = "测试";
|
||||
//var sznop1 = "测试2";
|
||||
PPLBUtility.B_Set_Originpoint(0, 0);
|
||||
PPLBUtility.B_Select_Option(2);
|
||||
PPLBUtility.B_Set_Darkness(8);
|
||||
PPLBUtility.B_Del_Pcx("*");// delete all picture.
|
||||
_ = PPLBUtility.B_Set_Originpoint(0, 0);
|
||||
_ = PPLBUtility.B_Select_Option(2);
|
||||
_ = PPLBUtility.B_Set_Darkness(8);
|
||||
_ = PPLBUtility.B_Del_Pcx("*");// delete all picture.
|
||||
//PPLBUtility.B_WriteData(0, encAscII.GetBytes(sznop2), sznop2.Length);
|
||||
//PPLBUtility.B_WriteData(1, encAscII.GetBytes(sznop1), sznop1.Length);
|
||||
//When using standard label, and the printer is Intelli Print mode or Smart Print mode,
|
||||
//When calling this function and giving the correct label information,
|
||||
//the immediate print function will be enabled according to the label length setting.
|
||||
PPLBUtility.B_Set_LabelForSmartPrint(254 * 3, 30);//label information: length= 3 * 25.4 mm, gap= 3 mm.
|
||||
_ = PPLBUtility.B_Set_LabelForSmartPrint(254 * 3, 30);//label information: length= 3 * 25.4 mm, gap= 3 mm.
|
||||
|
||||
//draw box.
|
||||
//PPLBUtility.B_Draw_Box(20, 20, 4, 760, 560);
|
||||
//PPLBUtility.B_Draw_Line('O', 400, 20, 4, 540);
|
||||
|
||||
//print text, true type text.
|
||||
PPLBUtility.B_Prn_Text(250, 50, 0, 2, 2, 2, 'N', "PPLB Lib Example");
|
||||
_ = PPLBUtility.B_Prn_Text(250, 50, 0, 2, 2, 2, 'N', "PPLB Lib Example");
|
||||
//PPLBUtility.B_Prn_Text_TrueType(30, 100, 30, "Arial", 1, 400, 0, 0, 0, "AA", "TrueType Font");//save in printer.
|
||||
//PPLBUtility.B_Prn_Text_TrueType_W(30, 160, 20, 20, "Times New Roman", 1, 400, 0, 0, 0, "AB", "TT_W: 多字元測試");
|
||||
//PPLBUtility.B_Prn_Text_TrueType_Uni(30, 220, 30, "Times New Roman", 1, 400, 0, 0, 0, "AC", Encoding.Unicode.GetBytes("TT_Uni: 多字元測試"), 1);//UTF-16
|
||||
@@ -470,12 +482,12 @@ namespace Tnb.WarehouseMgr
|
||||
//encUnicode.GetBytes("\x0000", 0, 1, pbuf, 30);//null.//pbuf[30]=0x00,pbuf[31]=0x00;
|
||||
//PPLBUtility.B_Prn_Text_TrueType_UniB(30, 280, 30, "Times New Roman", 1, 400, 0, 0, 0, "AD", pbuf, 0);//Byte Order Mark.
|
||||
|
||||
var labelWth = 800;
|
||||
var barcodeWth = 508;
|
||||
var x = (labelWth - barcodeWth) / 2;
|
||||
int labelWth = 800;
|
||||
int barcodeWth = 508;
|
||||
_ = (labelWth - barcodeWth) / 2;
|
||||
|
||||
//barcode.
|
||||
PPLBUtility.B_Prn_Barcode(150, 100, 0, "E80", 8, 500, 70, 'N', "1234<+10>");//have a counter
|
||||
_ = PPLBUtility.B_Prn_Barcode(150, 100, 0, "E80", 8, 500, 70, 'N', "1234<+10>");//have a counter
|
||||
//PPLBUtility.B_Bar2d_QR(420, 200, 1, 3, 'M', 'A', 0, 0, 0, "QR CODE");
|
||||
|
||||
//picture.
|
||||
@@ -487,7 +499,7 @@ namespace Tnb.WarehouseMgr
|
||||
// DeleteObject(himage);
|
||||
|
||||
// output.
|
||||
PPLBUtility.B_Print_Out(1);// copy 2.
|
||||
_ = PPLBUtility.B_Print_Out(1);// copy 2.
|
||||
|
||||
// close port.
|
||||
PPLBUtility.B_ClosePrn();
|
||||
@@ -503,8 +515,8 @@ namespace Tnb.WarehouseMgr
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetInStockDetailsListById([FromRoute] string billId)
|
||||
{
|
||||
var dic = await _dictionaryDataService.GetDictionaryByTypeId(WmsWareHouseConst.WMS_INSTOCK_D_BILL_STATUS_TYPEID);
|
||||
var items = await _db.Queryable<WmsOutstockD>().Where(it => it.bill_id == billId).ToListAsync();
|
||||
Dictionary<string, object> dic = await _dictionaryDataService.GetDictionaryByTypeId(WmsWareHouseConst.WMS_INSTOCK_D_BILL_STATUS_TYPEID);
|
||||
List<WmsOutstockD> items = await _db.Queryable<WmsOutstockD>().Where(it => it.bill_id == billId).ToListAsync();
|
||||
_db.ThenMapper(items,
|
||||
it => it.line_status = dic.ContainsKey(it.line_status) ? dic[it.line_status]?.ToString()! : "");
|
||||
return items;
|
||||
@@ -519,7 +531,7 @@ namespace Tnb.WarehouseMgr
|
||||
//[NonUnify]
|
||||
public async Task<dynamic> MESCreateOutstock(MESCreateOutstockInput input)
|
||||
{
|
||||
var isSuccessful = true;
|
||||
bool isSuccessful = true;
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
@@ -528,7 +540,7 @@ namespace Tnb.WarehouseMgr
|
||||
//出库申请明细表
|
||||
List<WmsOutstockD> outstockDs = input.outstockDs.Adapt<List<WmsOutstockD>>();
|
||||
|
||||
var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.outstock.location_code && it.is_type != EnumLocationType.存储库位.ToString());
|
||||
BasLocation location = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.outstock.location_code && it.is_type != EnumLocationType.存储库位.ToString());
|
||||
//如果数据不全或有误,
|
||||
if (location.IsNull() || outstockDs?.Count < 1)
|
||||
{
|
||||
@@ -547,7 +559,7 @@ namespace Tnb.WarehouseMgr
|
||||
outstock.create_time = DateTime.Now;
|
||||
|
||||
//明细表
|
||||
foreach (var outstockD in outstockDs!)
|
||||
foreach (WmsOutstockD outstockD in outstockDs!)
|
||||
{
|
||||
outstockD.id = SnowflakeIdHelper.NextId();
|
||||
outstockD.bill_id = outstock.id;
|
||||
@@ -558,16 +570,16 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
|
||||
//var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == outstock.location_id.ToString());
|
||||
var carryIds = new List<string>();
|
||||
List<string>? carryIds = new();
|
||||
//tablefield120 出库物料明细
|
||||
var outStockDList = outstockDs.ToObject<List<WmsOutstockD>>();
|
||||
List<WmsOutstockD> outStockDList = outstockDs.ToObject<List<WmsOutstockD>>();
|
||||
if (outStockDList?.Count > 0)
|
||||
{
|
||||
List<WmsCarryMat> carryMats = new();
|
||||
List<WmsCarryCode> carryCodes = new();
|
||||
foreach (var os in outStockDList)
|
||||
foreach (WmsOutstockD os in outStockDList)
|
||||
{
|
||||
var whereExp = Expressionable.Create<WmsCarryH, WmsCarryCode, BasLocation>()
|
||||
Expressionable<WmsCarryH, WmsCarryCode, BasLocation> whereExp = Expressionable.Create<WmsCarryH, WmsCarryCode, BasLocation>()
|
||||
.And((a, b, c) => a.is_lock == 0)
|
||||
.And((a, b, c) => !string.IsNullOrEmpty(a.location_id))
|
||||
.And((a, b, c) => a.status == (int)EnumCarryStatus.占用)
|
||||
@@ -575,13 +587,13 @@ namespace Tnb.WarehouseMgr
|
||||
.And((a, b, c) => b.material_id == os.material_id)
|
||||
.AndIF(!string.IsNullOrEmpty(os.code_batch), (a, b, c) => b.code_batch == os.code_batch);
|
||||
|
||||
var carryCodesPart = await _db.Queryable<WmsCarryH>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.carry_id).InnerJoin<BasLocation>((a, b, c) => a.location_id == c.id)
|
||||
List<WmsCarryCode> carryCodesPart = await _db.Queryable<WmsCarryH>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.carry_id).InnerJoin<BasLocation>((a, b, c) => a.location_id == c.id)
|
||||
.Where(whereExp.ToExpression())
|
||||
.Select<WmsCarryCode>()
|
||||
.ToListAsync();
|
||||
if (carryCodesPart?.Count > 0)
|
||||
{
|
||||
var codeQty = carryCodes.Sum(x => x.codeqty);
|
||||
decimal codeQty = carryCodes.Sum(x => x.codeqty);
|
||||
if (codeQty < os.pr_qty)
|
||||
{
|
||||
throw new AppFriendlyException($"需要出库[{os.pr_qty}],实际库存{codeQty},数量不足", 500);
|
||||
@@ -596,14 +608,14 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
else if (os.pr_qty <= carryCodesPart[i].codeqty)
|
||||
{
|
||||
var tmp = DeepCopyHelper<WmsCarryCode>.DeepCopy(carryCodesPart[i]);
|
||||
WmsCarryCode tmp = DeepCopyHelper<WmsCarryCode>.DeepCopy(carryCodesPart[i]);
|
||||
tmp.codeqty = os.pr_qty;
|
||||
curCarryCodes.Add(tmp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
carryCodes.AddRange(curCarryCodes);
|
||||
var partCarryMats = curCarryCodes.Adapt<List<WmsCarryMat>>();
|
||||
List<WmsCarryMat> partCarryMats = curCarryCodes.Adapt<List<WmsCarryMat>>();
|
||||
for (int i = 0; i < partCarryMats.Count; i++)
|
||||
{
|
||||
partCarryMats[i].need_qty = curCarryCodes[i].codeqty;
|
||||
@@ -617,19 +629,19 @@ namespace Tnb.WarehouseMgr
|
||||
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
|
||||
.Select(x =>
|
||||
{
|
||||
var arr = x.ToArray();
|
||||
WmsCarryMat[] arr = x.ToArray();
|
||||
WmsCarryMat carryMat = arr[^arr.Length];
|
||||
carryMat.need_qty = x.Sum(d => d.need_qty);
|
||||
return carryMat;
|
||||
})
|
||||
.ToList();
|
||||
await _db.Insertable(carryMats).ExecuteCommandAsync();
|
||||
var dic = carryMats.DistinctBy(x => x.carry_id).ToDictionary(x => x.carry_id, x => x.need_qty);
|
||||
var allOutIds = new List<string>();
|
||||
var sortingOutIds = new List<string>();
|
||||
foreach (var pair in dic)
|
||||
_ = await _db.Insertable(carryMats).ExecuteCommandAsync();
|
||||
Dictionary<string, decimal> dic = carryMats.DistinctBy(x => x.carry_id).ToDictionary(x => x.carry_id, x => x.need_qty);
|
||||
List<string> allOutIds = new();
|
||||
List<string> sortingOutIds = new();
|
||||
foreach (KeyValuePair<string, decimal> pair in dic)
|
||||
{
|
||||
var codes = carryCodes.FindAll(x => x.carry_id == pair.Key);
|
||||
List<WmsCarryCode> codes = carryCodes.FindAll(x => x.carry_id == pair.Key);
|
||||
if (codes?.Count > 0)
|
||||
{
|
||||
if (pair.Value == codes.Sum(d => d.codeqty))
|
||||
@@ -645,39 +657,46 @@ namespace Tnb.WarehouseMgr
|
||||
carryIds = allOutIds.Concat(sortingOutIds).ToList();
|
||||
if (carryIds?.Count > 0)
|
||||
{
|
||||
var carryId = carryIds[^carryIds.Count];
|
||||
var curCurry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == carryId);
|
||||
var isMatch = await IsCarryAndLocationMatchByCarryStd(curCurry, location);
|
||||
if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500);
|
||||
string carryId = carryIds[^carryIds.Count];
|
||||
WmsCarryH curCurry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == carryId);
|
||||
bool isMatch = await IsCarryAndLocationMatchByCarryStd(curCurry, location);
|
||||
if (!isMatch)
|
||||
{
|
||||
throw new AppFriendlyException("该载具无法放置到目标库位", 500);
|
||||
}
|
||||
}
|
||||
await _db.Insertable(outstock).ExecuteCommandAsync();
|
||||
await _db.Insertable(outstockDs).ExecuteCommandAsync();
|
||||
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString(), source_id = outstock.source_id, source_code = outstock.source_code }).Where(it => allOutIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.分拣出).ToString(), source_id = outstock.source_id, source_code = outstock.source_code }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
_ = await _db.Insertable(outstock).ExecuteCommandAsync();
|
||||
_ = await _db.Insertable(outstockDs).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString(), source_id = outstock.source_id, source_code = outstock.source_code }).Where(it => allOutIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.分拣出).ToString(), source_id = outstock.source_id, source_code = outstock.source_code }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
|
||||
}
|
||||
var carrys = await _db.Queryable<WmsCarryH>().Where(it => carryIds.Contains(it.id)).ToListAsync();
|
||||
List<WmsCarryH> carrys = await _db.Queryable<WmsCarryH>().Where(it => carryIds.Contains(it.id)).ToListAsync();
|
||||
if (carrys?.Count > 0)
|
||||
{
|
||||
List<WmsPretaskH> preTasks = new();
|
||||
List<string> locIds = new();
|
||||
foreach (var carry in carrys)
|
||||
foreach (WmsCarryH carry in carrys)
|
||||
{
|
||||
WmsPointH sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
|
||||
WmsPointH ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == outstock.location_id.ToString());
|
||||
|
||||
if (sPoint != null && ePoint != null)
|
||||
{
|
||||
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||
List<WmsPointH> points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||
locIds.AddRange(points.Select(x => x.location_id).ToList()!);
|
||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||
if (points?.Count > 0)
|
||||
{
|
||||
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
|
||||
var curPreTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
||||
if (points.Count <= 2)
|
||||
{
|
||||
var sPoint = it.FirstOrDefault();
|
||||
var ePoint = it.LastOrDefault();
|
||||
throw new AppFriendlyException("该路径不存在", 500);
|
||||
}
|
||||
|
||||
List<WmsPretaskH> curPreTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
||||
{
|
||||
WmsPointH? sPoint = it.FirstOrDefault();
|
||||
WmsPointH? ePoint = it.LastOrDefault();
|
||||
|
||||
WmsPretaskH preTask = new()
|
||||
{
|
||||
@@ -716,10 +735,10 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
List<WmsPretaskCode> pretaskCodes = new();
|
||||
foreach (var pt in preTasks)
|
||||
foreach (WmsPretaskH pt in preTasks)
|
||||
{
|
||||
var partCodes = carryCodes.FindAll(x => x.carry_id == pt.carry_id).Distinct().ToList();
|
||||
var curPreTaskCodes = partCodes.Adapt<List<WmsPretaskCode>>();
|
||||
List<WmsCarryCode> partCodes = carryCodes.FindAll(x => x.carry_id == pt.carry_id).Distinct().ToList();
|
||||
List<WmsPretaskCode> curPreTaskCodes = partCodes.Adapt<List<WmsPretaskCode>>();
|
||||
curPreTaskCodes.ForEach(x =>
|
||||
{
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
@@ -728,22 +747,30 @@ namespace Tnb.WarehouseMgr
|
||||
});
|
||||
pretaskCodes.AddRange(curPreTaskCodes);
|
||||
}
|
||||
var isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes);
|
||||
bool isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes);
|
||||
if (isOk)
|
||||
{
|
||||
outstockDs.ForEach(x => x.line_status = WmsWareHouseConst.BILLSTATUS_ON_ID);
|
||||
await _db.Updateable(outstockDs).UpdateColumns(it => it.line_status).ExecuteCommandAsync();
|
||||
await _db.Updateable<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == outstock.id).ExecuteCommandAsync();
|
||||
GenPreTaskUpInput genPreTaskAfterUpInput = new();
|
||||
genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList();
|
||||
genPreTaskAfterUpInput.LocationIds = new HashSet<string>(locIds).ToList();
|
||||
_ = await _db.Updateable(outstockDs).UpdateColumns(it => it.line_status).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == outstock.id).ExecuteCommandAsync();
|
||||
GenPreTaskUpInput genPreTaskAfterUpInput = new()
|
||||
{
|
||||
CarryIds = preTasks.Select(x => x.carry_id).ToList(),
|
||||
LocationIds = new HashSet<string>(locIds).ToList()
|
||||
};
|
||||
await _wareHouseService.GenInStockTaskHandleAfter(genPreTaskAfterUpInput, it => new WmsCarryH { is_lock = 1 }, it => new BasLocation { is_lock = 1 });
|
||||
}
|
||||
|
||||
}
|
||||
else throw new AppFriendlyException("库存不足", 500);
|
||||
else
|
||||
{
|
||||
throw new AppFriendlyException("库存不足", 500);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AppFriendlyException($"请输入物料明细", 500);
|
||||
}
|
||||
else throw new AppFriendlyException($"请输入物料明细", 500);
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
@@ -763,29 +790,33 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
public override async Task ModifyAsync(WareHouseUpInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException(nameof(input));
|
||||
if (input == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
var carryId = input.carryIds[^input.carryIds.Count];
|
||||
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == carryId);
|
||||
string carryId = input.carryIds[^input.carryIds.Count];
|
||||
WmsCarryH carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == carryId);
|
||||
if (carry != null)
|
||||
{
|
||||
|
||||
var otds = await _db.Queryable<WmsOutstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
||||
var outStatus = carry.out_status.ToEnum<EnumOutStatus>();
|
||||
List<WmsOutstockD>? otds = await _db.Queryable<WmsOutstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
||||
EnumOutStatus outStatus = carry.out_status.ToEnum<EnumOutStatus>();
|
||||
if (outStatus == EnumOutStatus.全部出)
|
||||
{
|
||||
//当前载具对应的所有条码插入
|
||||
var carryCodes = await _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == carryId).ToListAsync();
|
||||
var outStockCodes = carryCodes.Adapt<List<WmsOutstockCode>>();
|
||||
List<WmsCarryCode> carryCodes = await _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == carryId).ToListAsync();
|
||||
List<WmsOutstockCode> outStockCodes = carryCodes.Adapt<List<WmsOutstockCode>>();
|
||||
|
||||
|
||||
outStockCodes.ForEach(x =>
|
||||
{
|
||||
var billDId = otds?.Find(xx => xx.material_id == x.material_id && xx.code_batch == x.code_batch)?.id;
|
||||
string? billDId = otds?.Find(xx => xx.material_id == x.material_id && xx.code_batch == x.code_batch)?.id;
|
||||
if (billDId.IsNullOrEmpty())
|
||||
{
|
||||
billDId = otds?.Find(xx => xx.material_id == x.material_id)?.id;
|
||||
@@ -797,47 +828,40 @@ namespace Tnb.WarehouseMgr
|
||||
x.create_id = _userManager.UserId;
|
||||
x.create_time = DateTime.Now;
|
||||
});
|
||||
await _db.Insertable(outStockCodes).ExecuteCommandAsync();
|
||||
_ = await _db.Insertable(outStockCodes).ExecuteCommandAsync();
|
||||
|
||||
var detailIds = outStockCodes.Select(x => x.bill_d_id).ToList();
|
||||
var curOutstockDetails = otds.FindAll(x => detailIds.Contains(x.id));
|
||||
var dic = outStockCodes.GroupBy(g => g.bill_d_id).ToDictionary(x => x.Key, x => x.Select(x => x.codeqty).ToList());
|
||||
foreach (var osd in curOutstockDetails)
|
||||
List<string> detailIds = outStockCodes.Select(x => x.bill_d_id).ToList();
|
||||
List<WmsOutstockD> curOutstockDetails = otds.FindAll(x => detailIds.Contains(x.id));
|
||||
Dictionary<string, List<decimal>> dic = outStockCodes.GroupBy(g => g.bill_d_id).ToDictionary(x => x.Key, x => x.Select(x => x.codeqty).ToList());
|
||||
foreach (WmsOutstockD osd in curOutstockDetails)
|
||||
{
|
||||
if (dic.ContainsKey(osd.id))
|
||||
{
|
||||
osd.qty += dic[osd.id].Sum(d => d);
|
||||
if (osd.qty >= osd.pr_qty)
|
||||
{
|
||||
osd.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
osd.line_status = WmsWareHouseConst.BILLSTATUS_ON_ID;
|
||||
}
|
||||
osd.line_status = osd.qty >= osd.pr_qty ? WmsWareHouseConst.BILLSTATUS_COMPLETE_ID : WmsWareHouseConst.BILLSTATUS_ON_ID;
|
||||
}
|
||||
}
|
||||
await _db.Updateable(curOutstockDetails).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable(curOutstockDetails).ExecuteCommandAsync();
|
||||
if (otds.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID))
|
||||
{
|
||||
await _db.Updateable<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
|
||||
//如果是自动单据,需要回更上层系统
|
||||
}
|
||||
else
|
||||
{
|
||||
//如果没有完成,修改为工作中
|
||||
await _db.Updateable<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
|
||||
}
|
||||
await _wareCarryService.UpdateNullCarry(carry).Unwrap();
|
||||
_ = await _wareCarryService.UpdateNullCarry(carry).Unwrap();
|
||||
}
|
||||
else if (outStatus == EnumOutStatus.分拣出)
|
||||
{
|
||||
if (input.distaskCodes?.Count > 0)
|
||||
{
|
||||
var osCodes = input.distaskCodes.Adapt<List<WmsOutstockCode>>();
|
||||
List<WmsOutstockCode> osCodes = input.distaskCodes.Adapt<List<WmsOutstockCode>>();
|
||||
osCodes.ForEach(x =>
|
||||
{
|
||||
var billDId = otds?.Find(xx => xx.material_id == x.material_id && xx.code_batch == x.code_batch)?.id;
|
||||
string? billDId = otds?.Find(xx => xx.material_id == x.material_id && xx.code_batch == x.code_batch)?.id;
|
||||
if (billDId.IsNullOrEmpty())
|
||||
{
|
||||
billDId = otds?.Find(xx => xx.material_id == x.material_id)?.id;
|
||||
@@ -849,12 +873,12 @@ namespace Tnb.WarehouseMgr
|
||||
x.create_id = _userManager.UserId;
|
||||
x.create_time = DateTime.Now;
|
||||
});
|
||||
await _db.Insertable(osCodes).ExecuteCommandAsync();
|
||||
_ = await _db.Insertable(osCodes).ExecuteCommandAsync();
|
||||
// 更新主表
|
||||
var detailIds = osCodes.Select(x => x.bill_d_id).ToList();
|
||||
var curOutstockDetails = otds.FindAll(x => detailIds.Contains(x.id));
|
||||
var dic = osCodes.GroupBy(g => g.bill_d_id).ToDictionary(x => x.Key, x => x.Select(x => x.codeqty).ToList());
|
||||
foreach (var osd in curOutstockDetails)
|
||||
List<string> detailIds = osCodes.Select(x => x.bill_d_id).ToList();
|
||||
List<WmsOutstockD> curOutstockDetails = otds.FindAll(x => detailIds.Contains(x.id));
|
||||
Dictionary<string, List<decimal>> dic = osCodes.GroupBy(g => g.bill_d_id).ToDictionary(x => x.Key, x => x.Select(x => x.codeqty).ToList());
|
||||
foreach (WmsOutstockD osd in curOutstockDetails)
|
||||
{
|
||||
if (dic.ContainsKey(osd.id))
|
||||
{
|
||||
@@ -870,23 +894,23 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
}
|
||||
await _db.Updateable(curOutstockDetails).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable(curOutstockDetails).ExecuteCommandAsync();
|
||||
if (otds.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID))
|
||||
{
|
||||
//如果是自动单据,需要回更上层系统
|
||||
await _db.Updateable<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
//如果没有完成,修改为工作中
|
||||
await _db.Updateable<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
var carryCodes = await _db.Queryable<WmsCarryCode>().Where(it => input.carryIds.Contains(it.carry_id!)).ToListAsync();
|
||||
var dicCodeQty = carryCodes.GroupBy(g => g.barcode).ToDictionary(x => x.Key, x => x.First().codeqty);
|
||||
var dicUpdate = new Dictionary<string, decimal>();
|
||||
var delBarcodes = new List<string>();
|
||||
foreach (var dtc in input.distaskCodes)
|
||||
List<WmsCarryCode> carryCodes = await _db.Queryable<WmsCarryCode>().Where(it => input.carryIds.Contains(it.carry_id!)).ToListAsync();
|
||||
Dictionary<string, decimal> dicCodeQty = carryCodes.GroupBy(g => g.barcode).ToDictionary(x => x.Key, x => x.First().codeqty);
|
||||
Dictionary<string, decimal> dicUpdate = new();
|
||||
List<string> delBarcodes = new();
|
||||
foreach (WmsDistaskCode dtc in input.distaskCodes)
|
||||
{
|
||||
if (dicCodeQty.ContainsKey(dtc.barcode))
|
||||
{
|
||||
@@ -902,36 +926,38 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
if (dicUpdate.Count > 0)
|
||||
{
|
||||
foreach (var pair in dicUpdate)
|
||||
foreach (KeyValuePair<string, decimal> pair in dicUpdate)
|
||||
{
|
||||
WmsCarryCode? carryCode = carryCodes.Find(x => x.barcode == pair.Key);
|
||||
if (carryCode != null)
|
||||
{
|
||||
carryCode.codeqty = pair.Value;
|
||||
await _db.Updateable(carryCode).UpdateColumns(it => it.codeqty).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable(carryCode).UpdateColumns(it => it.codeqty).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (delBarcodes.Count > 0)
|
||||
{
|
||||
await _db.Deleteable<WmsCarryCode>().Where(it => delBarcodes.Contains(it.barcode)).ExecuteCommandAsync();
|
||||
_ = await _db.Deleteable<WmsCarryCode>().Where(it => delBarcodes.Contains(it.barcode)).ExecuteCommandAsync();
|
||||
}
|
||||
var row = await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.正常).ToString() }).Where(it => input.carryIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
await _db.Deleteable<WmsCarryMat>().Where(it => input.carryIds.Contains(it.carry_id)).ExecuteCommandAsync();
|
||||
int row = await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.正常).ToString() }).Where(it => input.carryIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
_ = await _db.Deleteable<WmsCarryMat>().Where(it => input.carryIds.Contains(it.carry_id)).ExecuteCommandAsync();
|
||||
//载具移入
|
||||
var outStockH = await _db.Queryable<WmsOutstockH>().SingleAsync(it => it.id == input.requireId);
|
||||
var visulDevInput = new VisualDevModelDataCrInput();
|
||||
visulDevInput.data = new Dictionary<string, object>
|
||||
WmsOutstockH outStockH = await _db.Queryable<WmsOutstockH>().SingleAsync(it => it.id == input.requireId);
|
||||
VisualDevModelDataCrInput visulDevInput = new()
|
||||
{
|
||||
[nameof(InStockStrategyQuery.warehouse_id)] = outStockH.warehouse_id,
|
||||
[nameof(WmsPointH.location_id)] = outStockH.location_id,
|
||||
[nameof(WmsCarryD.carry_id)] = input.carryIds.First(),
|
||||
[nameof(WmsCarryH.carry_code)] = carry.carry_code,
|
||||
[nameof(WmsHandleH.biz_type)] = input.bizTypeId,
|
||||
[nameof(WmsHandleH.create_id)] = _userManager.UserId,
|
||||
[nameof(WmsHandleH.create_time)] = DateTime.Now,
|
||||
[nameof(WmsMoveInstock.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
||||
[nameof(WmsHandleH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_CARRYMOINSTK_ENCODE).GetAwaiter().GetResult(),
|
||||
data = new Dictionary<string, object>
|
||||
{
|
||||
[nameof(InStockStrategyQuery.warehouse_id)] = outStockH.warehouse_id,
|
||||
[nameof(WmsPointH.location_id)] = outStockH.location_id,
|
||||
[nameof(WmsCarryD.carry_id)] = input.carryIds.First(),
|
||||
[nameof(WmsCarryH.carry_code)] = carry.carry_code,
|
||||
[nameof(WmsHandleH.biz_type)] = input.bizTypeId,
|
||||
[nameof(WmsHandleH.create_id)] = _userManager.UserId,
|
||||
[nameof(WmsHandleH.create_time)] = DateTime.Now,
|
||||
[nameof(WmsMoveInstock.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
||||
[nameof(WmsHandleH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_CARRYMOINSTK_ENCODE).GetAwaiter().GetResult(),
|
||||
}
|
||||
};
|
||||
|
||||
await _wmsCarryMoveInStockService.CarryMoveIn(visulDevInput);
|
||||
|
||||
Reference in New Issue
Block a user