Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -24,6 +24,7 @@ using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using SqlSugar;
|
||||
@@ -72,6 +73,8 @@ namespace Tnb.EquipMgr
|
||||
toolMoldMaintainRule.mode = input.data["mode"].ToString();
|
||||
toolMoldMaintainRule.cycle = cycle;
|
||||
toolMoldMaintainRule.startandend_date = startTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
toolMoldMaintainRule.create_id = _userManager.UserId;
|
||||
toolMoldMaintainRule.create_time=DateTime.Now;
|
||||
await _db.Insertable(toolMoldMaintainRule).ExecuteCommandAsync();
|
||||
if (toolMoldMaintainRule.mode == "27118635748885")
|
||||
{
|
||||
@@ -83,7 +86,8 @@ namespace Tnb.EquipMgr
|
||||
comtentModel.parameter = new List<InterfaceParameter>();
|
||||
comtentModel.parameter!.Add(new InterfaceParameter() { field = "id", value = id, defaultValue = "" });
|
||||
comtentModel.localHostTaskId = "MoldMaintainTask/CreateTask";
|
||||
comtentModel.startTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
DateTimeOffset dateTimeOffset = new DateTimeOffset(startTime);
|
||||
comtentModel.startTime = dateTimeOffset.ToUnixTimeMilliseconds();
|
||||
comtentModel.TenantId = _userManager?.TenantId!;
|
||||
comtentModel.TenantDbName = _userManager?.TenantDbName!;
|
||||
comtentModel.ConnectionConfig = _userManager?.ConnectionConfig!;
|
||||
|
||||
@@ -56,7 +56,6 @@ namespace Tnb.WarehouseMgr
|
||||
_prdInstockService = prdInstockService;
|
||||
OverideFuncs.CreateAsync = ScanInStock;
|
||||
}
|
||||
[HttpPost("xxx")]
|
||||
public async Task<dynamic> ScanInStock(VisualDevModelDataCrInput input)
|
||||
{
|
||||
try
|
||||
@@ -86,8 +85,8 @@ namespace Tnb.WarehouseMgr
|
||||
warehouse_id = "26103372441637",
|
||||
status = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
||||
generate_type = "0",
|
||||
sync_status = "",
|
||||
print_status = "0",
|
||||
sync_status = WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC,
|
||||
print_status = WmsWareHouseConst.PRINT_STATUS_PRINTCOMPLETE,
|
||||
is_check = 1,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
@@ -102,7 +101,7 @@ namespace Tnb.WarehouseMgr
|
||||
unit_id = mat.unit_id,
|
||||
pr_qty = item.codeqty,
|
||||
qty = 0,
|
||||
code_batch= item.code_batch,
|
||||
code_batch = item.code_batch,
|
||||
warehouse_id = "26103372441637",
|
||||
print_qty = item.codeqty,
|
||||
scan_qty = item.codeqty,
|
||||
@@ -184,7 +183,21 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.create_time = DateTime.Now;
|
||||
return preTask;
|
||||
}).ToList();
|
||||
var isOk = await _wareHouseService.GenPreTask(preTasks, null!);
|
||||
List<WmsPretaskCode> pretaskCodes = new();
|
||||
foreach (var pt in preTasks)
|
||||
{
|
||||
WmsPretaskCode ptc = pt.Adapt<WmsPretaskCode>();
|
||||
ptc.id = SnowflakeIdHelper.NextId();
|
||||
ptc.bill_id = pt.id;
|
||||
ptc.material_id = instockCode.material_id;
|
||||
ptc.material_code = instockCode.material_code;
|
||||
ptc.barcode = instockCode.barcode;
|
||||
ptc.codeqty = instockCode.codeqty;
|
||||
ptc.unit_id = instockCode.unit_id;
|
||||
ptc.code_batch = instockCode.code_batch;
|
||||
pretaskCodes.Add(ptc);
|
||||
}
|
||||
var isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes);
|
||||
if (isOk)
|
||||
{
|
||||
var preTaskUpInput = new GenPreTaskUpInput();
|
||||
@@ -225,70 +238,5 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
public override async Task ModifyAsync(WareHouseUpInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException(nameof(input));
|
||||
//更具distaskCode的barcode 更新 instockcode 的 is_end 为 1
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
if (input.distaskCodes?.Count > 0)
|
||||
{
|
||||
var barCodes = input.distaskCodes.Select(x => x.barcode);
|
||||
await _db.Updateable<WmsInstockCode>().SetColumns(it => new WmsInstockCode { is_end = 1 }).Where(it => barCodes.Contains(it.barcode)).ExecuteCommandAsync();
|
||||
var instockCodes = await _db.Queryable<WmsInstockCode>().Where(it => barCodes.Contains(it.barcode)).Select(it => new
|
||||
{
|
||||
id = it.bill_d_id,
|
||||
barcode_qty = it.codeqty,
|
||||
}).ToListAsync();
|
||||
var dic = instockCodes.GroupBy(g => g.id).ToDictionary(x => x.Key, x => x.Select(d => d.barcode_qty).ToList());
|
||||
var ids = instockCodes.Select(it => it.id).ToList();
|
||||
var instockDetails = await _db.Queryable<WmsInstockD>().Where(it => ids.Contains(it.id)).ToListAsync();
|
||||
|
||||
foreach (var item in instockDetails)
|
||||
{
|
||||
if (dic.ContainsKey(item.id))
|
||||
{
|
||||
item.qty += dic[item.id].Sum(x => x);
|
||||
if (item.qty >= item.pr_qty)
|
||||
{
|
||||
item.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
await _db.Updateable(instockDetails).ExecuteCommandAsync();
|
||||
var instock = await _db.Queryable<WmsInstockH>().SingleAsync(it => it.id == input.requireId);
|
||||
if (instock.IsNull()) ArgumentNullException.ThrowIfNull(nameof(instock));
|
||||
if (instock.sync_status != WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC)
|
||||
{
|
||||
//如果是自动单据,需要回更上层系统
|
||||
Dictionary<string, string> pars = new() { { nameof(WmsInstockH.source_id), instock?.source_id ?? string.Empty } };
|
||||
var callBackRes = await _prdInstockService.SyncInstock(pars);
|
||||
instock!.sync_status = callBackRes == true ? WmsWareHouseConst.SYNC_STATUS__SYNCCOMPLETE : WmsWareHouseConst.SYNC_STATUS__SYNCFAILED;
|
||||
await _db.Updateable(instock).UpdateColumns(it => it.sync_status).ExecuteCommandAsync();
|
||||
}
|
||||
var allInstockDetails = await _db.Queryable<WmsInstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
||||
if (allInstockDetails.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID))
|
||||
{
|
||||
instock.status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
//任务没有结束,更新状态为工作中
|
||||
instock.status = WmsWareHouseConst.BILLSTATUS_ON_ID;
|
||||
}
|
||||
await _db.Updateable(instock).UpdateColumns(it => it.status).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ using Tnb.QcMgr.Entities.Entity;
|
||||
|
||||
namespace Tnb.TaskScheduler.Listener
|
||||
{
|
||||
internal class MoldMaintainTask : ISpareTimeWorker
|
||||
public class MoldMaintainTask : ISpareTimeWorker
|
||||
{
|
||||
private ISqlSugarRepository<ToolMoldMaintainRule> repository => App.GetService<ISqlSugarRepository<ToolMoldMaintainRule>>();
|
||||
[SpareTime("0 0 0 * * ?", "生成模具保养任务", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)]
|
||||
@@ -41,6 +41,8 @@ namespace Tnb.TaskScheduler.Listener
|
||||
toolMoldMaintainPlan.plan_code = "JHDM" + now.ToString("yyyyMMdd") + rNum.Next(1000, 9999).ToString();
|
||||
toolMoldMaintainPlan.mode = ToolMoldMaintainRule.mode;
|
||||
toolMoldMaintainPlan.status = "UnMaintain";
|
||||
toolMoldMaintainPlan.create_id = ToolMoldMaintainRule.create_id;
|
||||
toolMoldMaintainPlan.create_time = now;
|
||||
toolMoldMaintainPlan.plan_start_date = now;
|
||||
toolMoldMaintainPlan.plan_end_date = now.AddDays((double)ToolMoldMaintainRule.cycle!);
|
||||
List<ToolMoldMaintainPlanRelation> toolMoldMaintainPlanRelations = new List<ToolMoldMaintainPlanRelation>();
|
||||
|
||||
Reference in New Issue
Block a user