diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs index 9490814b..1df9f805 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs @@ -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(); 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!; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs index ce45df01..11e7004a 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs @@ -56,7 +56,6 @@ namespace Tnb.WarehouseMgr _prdInstockService = prdInstockService; OverideFuncs.CreateAsync = ScanInStock; } - [HttpPost("xxx")] public async Task 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 pretaskCodes = new(); + foreach (var pt in preTasks) + { + WmsPretaskCode ptc = pt.Adapt(); + 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().SetColumns(it => new WmsInstockCode { is_end = 1 }).Where(it => barCodes.Contains(it.barcode)).ExecuteCommandAsync(); - var instockCodes = await _db.Queryable().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().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().SingleAsync(it => it.id == input.requireId); - if (instock.IsNull()) ArgumentNullException.ThrowIfNull(nameof(instock)); - if (instock.sync_status != WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC) - { - //如果是自动单据,需要回更上层系统 - Dictionary 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().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; - } - } } } diff --git a/taskschedule/Tnb.TaskScheduler/Listener/MoldMaintainTask.cs b/taskschedule/Tnb.TaskScheduler/Listener/MoldMaintainTask.cs index 6bcbd9ff..ea0da118 100644 --- a/taskschedule/Tnb.TaskScheduler/Listener/MoldMaintainTask.cs +++ b/taskschedule/Tnb.TaskScheduler/Listener/MoldMaintainTask.cs @@ -16,7 +16,7 @@ using Tnb.QcMgr.Entities.Entity; namespace Tnb.TaskScheduler.Listener { - internal class MoldMaintainTask : ISpareTimeWorker + public class MoldMaintainTask : ISpareTimeWorker { private ISqlSugarRepository repository => App.GetService>(); [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 toolMoldMaintainPlanRelations = new List();