diff --git a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs index bfc6fcf5..f14fefef 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs @@ -87,7 +87,7 @@ public static class DictConst /// public const string ComplatedEnCode = "Complated"; /// - /// 任务单状态-待排产 + /// 任务单状态-待下发 /// public const string ToBeScheduledEncode = "ToBeScheduled"; /// diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipment.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipment.cs index fc78a08f..aeb2e3b9 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipment.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipment.cs @@ -203,4 +203,9 @@ public partial class EqpEquipment : BaseEntity /// public string? responsibler_id { get; set; } + /// + /// 二维码 + /// + public string? qrcode { get; set; } + } diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs index 3473dbf8..803272f5 100644 --- a/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs @@ -23,5 +23,12 @@ namespace Tnb.EquipMgr.Interfaces /// /// public Task GetWorklineAndEquipTree(Dictionary dic); + + /// + /// 根据二维码查设备 + /// + /// + /// + public Task GetEntityByQrcode(Dictionary dic); } } \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/EquipmentService.cs b/EquipMgr/Tnb.EquipMgr/EquipmentService.cs index 610e4002..f73e11f5 100644 --- a/EquipMgr/Tnb.EquipMgr/EquipmentService.cs +++ b/EquipMgr/Tnb.EquipMgr/EquipmentService.cs @@ -233,5 +233,12 @@ namespace Tnb.EquipMgr ["list"] = list1, }); } + + [HttpPost] + public async Task GetEntityByQrcode(Dictionary dic) + { + string qrcode = dic["qrcode"]; + return await _repository.GetSingleAsync(x => x.qrcode == qrcode); + } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ChangeEquipInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ChangeEquipInput.cs new file mode 100644 index 00000000..9906a0d5 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ChangeEquipInput.cs @@ -0,0 +1,8 @@ +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + public class ChangeEquipInput + { + public string mo_task_id { get; set; } + public string equip_id { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ChangeMoldInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ChangeMoldInput.cs new file mode 100644 index 00000000..dc5e1a41 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ChangeMoldInput.cs @@ -0,0 +1,8 @@ +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + public class ChangeMoldInput + { + public string mo_task_id { get; set; } + public string mold_id { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ChangeWorklineInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ChangeWorklineInput.cs new file mode 100644 index 00000000..e945bfe2 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ChangeWorklineInput.cs @@ -0,0 +1,8 @@ +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + public class ChangeWorklineInput + { + public string mo_task_id { get; set; } + public string workline_id { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs index aa48d3b7..e3e66deb 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Security.Principal; using System.Text; using System.Threading.Tasks; +using JNPF.Common.Security; namespace Tnb.ProductionMgr.Entities.Dto.PrdManage { @@ -86,7 +87,45 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage public string process_name { get; set;} public string create_time { get; set; } + } + public class PrdMoTaskTreeOutput : TreeModel + { + /// + /// 生产任务单号 + /// + public string? mo_task_code { get; set; } + public string? material_id { get; set; } + public string? mold_id { get; set; } + public string? eqp_id { get; set; } + + /// + /// 物料 + /// + public string? material_id_id { get; set; } + /// + /// 模具 + /// + public string? mold_id_id { get; set; } + /// + /// 设备 + /// + public string? eqp_id_id { get; set; } + + /// + /// 预计开始时间 + /// + public string? estimated_start_date { get; set; } + + /// + /// 预计结束时间 + /// + public string? estimated_end_date { get; set; } + + /// + /// 创建时间 + /// + public string? create_time { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskOperOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskOperOutput.cs index 0e651046..365d18c9 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskOperOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskOperOutput.cs @@ -16,5 +16,10 @@ namespace Tnb.ProductionMgr.Entities.Dto ///任务单操作状态 /// public string statusName { get; set; } + + /// + /// 排产类型:1、注塑、挤出2、组装、包装 + /// + public int? schedule_type { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs index c5ca9609..cb0fd31a 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs @@ -9,14 +9,18 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage public string mo_task_code { get; set; } public string mo_task_status { get; set; } public string material_id { get; set; } + public string material_id_id { get; set; } public string mold_id { get; set; } + public string mold_id_id { get; set; } public int? plan_qty { get; set; } public int? complete_qty { get; set; } public int? scheduled_qty { get; set; } public string workline_id { get; set; } + public string workline_id_id { get; set; } public string estimated_start_date { get; set; } public string estimated_end_date { get; set; } public string eqp_id { get; set; } + public string eqp_id_id { get; set; } public string create_time { get; set; } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs index 8128efe1..f6875100 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs @@ -113,4 +113,10 @@ public partial class PrdReport : BaseEntity /// 物料单位 /// public string? unit_id { get; set; } + + /// + /// 工序id + /// + public string? process_id { get; set; } + } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdTaskLog.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdTaskLog.cs index 28792475..f9785a42 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdTaskLog.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdTaskLog.cs @@ -114,6 +114,14 @@ namespace Tnb.ProductionMgr.Entities [SugarColumn(IsIgnore = true)] public string workline_code { get; set; } + /// + /// 工位编号 + /// + public string? station_code { get; set; } + /// + /// 工序编号 + /// + public string? process_code { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs index 545d70eb..8b634316 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs @@ -23,6 +23,7 @@ using Tnb.ProductionMgr.Entities.Consts; using Tnb.WarehouseMgr; using Tnb.WarehouseMgr.Entities; using Tnb.BasicData; +using Tnb.EquipMgr.Entities; namespace Tnb.ProductionMgr { @@ -141,9 +142,29 @@ namespace Tnb.ProductionMgr throw new Exception("没有签收物料"); } + var mo = await db.Queryable().SingleAsync(x => x.id == moTask.mo_id); + var material = await db.Queryable().SingleAsync(x => x.id == moTask.material_id); + var station = await db.Queryable().SingleAsync(x => x.Id == input.station_id); + var process = await db.Queryable().SingleAsync(x => x.id == input.process_id); + var taskLog = new PrdTaskLog(); + taskLog.id = SnowflakeIdHelper.NextId(); + taskLog.mo_code = mo?.mo_code!; + taskLog.eqp_code = (await db.Queryable().FirstAsync(it => it.id == input.equip_id))?.code!; + taskLog.mold_code = ""; + taskLog.item_code = material?.code!; + taskLog.item_standard = material?.material_standard!; + taskLog.status = "生产投料"; + taskLog.operator_name = _userManager.RealName; + taskLog.create_id = _userManager.UserId; + taskLog.create_time = DateTime.Now; + taskLog.mo_task_id = moTask.id; + taskLog.mo_task_code = moTask.mo_task_code; + taskLog.station_code = station?.EnCode; + taskLog.process_code = process.code; await db.Insertable(prdFeedingH).ExecuteCommandAsync(); await db.Insertable(list).ExecuteCommandAsync(); + await db.Insertable(taskLog).ExecuteCommandAsync(); }); diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs index 2e0b5b3c..64429b5e 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs @@ -21,6 +21,12 @@ using Tnb.ProductionMgr.Interfaces; using Tnb.WarehouseMgr; using Tnb.WarehouseMgr.Entities.Dto.Inputs; using Tnb.BasicData; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; +using Tnb.EquipMgr.Entities; +using Tnb.ProductionMgr.Entities.Dto.PrdManage; +using JNPF.Common.Filter; +using JNPF.Common.Security; namespace Tnb.ProductionMgr { @@ -29,11 +35,13 @@ namespace Tnb.ProductionMgr /// [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)] [Route("api/[area]/[controller]/[action]")] - public class PrdInstockService : IPrdInstockService, IDynamicApiController, ITransient + [OverideVisualDev(ModuleId)] + public class PrdInstockService : IPrdInstockService, IDynamicApiController, ITransient, IOverideVisualDevService { private readonly ISqlSugarRepository _repository; private readonly IUserManager _userManager; - + private const string ModuleId = "25572529329173"; + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); public PrdInstockService( ISqlSugarRepository repository, @@ -42,6 +50,46 @@ namespace Tnb.ProductionMgr { _repository = repository; _userManager = userManager; + OverideFuncs.GetListAsync = GetList; + } + + private async Task GetList(VisualDevModelListQueryInput input) + { + Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? Newtonsoft.Json.JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); + string moCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : ""; + var list = await _repository.AsSugarClient().Queryable() + .LeftJoin((a, b) => a.material_id == b.id) + .LeftJoin((a, b, c) => a.mold_id == c.id) + .LeftJoin((a, b, c, d) => a.eqp_id == d.id) + .WhereIF(!string.IsNullOrEmpty(moCode), (a, b, c, d) => a.mo_task_code!.Contains(moCode)) + .Select((a, b, c, d) => new PrdMoTaskTreeOutput() + { + id = a.id, + parentId = string.IsNullOrEmpty(a.parent_id) ? "0" : a.parent_id, + mo_task_code = a.mo_task_code, + material_id = b.name, + material_id_id = b.id, + mold_id = c.mold_name, + mold_id_id = c.id, + eqp_id = d.name, + eqp_id_id = d.id, + estimated_start_date = a.estimated_start_date!.ToString(), + estimated_end_date = a.estimated_end_date.ToString(), + create_time = a.create_time.ToString() + }).ToListAsync(); + var treeList = list.ToTree(); + treeList= treeList.Skip((input.currentPage-1)* input.pageSize).Take(input.pageSize).ToList(); + SqlSugarPagedList pagedList = new() + { + list = treeList, + pagination = new Pagination + { + CurrentPage = input.currentPage, + PageSize = input.pageSize, + Total = treeList.Count + } + }; + return PageResult.SqlSugarPageResult(pagedList); } [HttpPost] diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 9305e7eb..326cb5fa 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -226,7 +226,11 @@ namespace Tnb.ProductionMgr var list = await _repository.AsSugarClient().Queryable().Where(it => it.mo_task_id == taskId).ToListAsync(); var data = list.Adapt>(); var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId); - _repository.AsSugarClient().ThenMapper(data, x => x.statusName = dic.ContainsKey(x.status) ? dic[x.status].ToString() : ""); + _repository.AsSugarClient().ThenMapper(data, x => + { + x.statusName = dic.ContainsKey(x.status) ? dic[x.status].ToString() : x.status; + x.schedule_type = _repository.AsSugarClient().Queryable().Single(y => y.id == x.mo_task_id).schedule_type; + }); return data; } /// @@ -1360,6 +1364,7 @@ namespace Tnb.ProductionMgr var row = -1; var report = await db.Queryable().FirstAsync(it => it.mo_task_id == input.mo_task_id); var prdMoTask = await db.Queryable().SingleAsync(x => x.id == input.mo_task_id); + var mbomProcess = await db.Queryable().SingleAsync(x => x.id == prdMoTask.mbom_process_id); if (prdMoTask.mo_task_status == DictConst.MoStatusPauseCode) { @@ -1405,6 +1410,7 @@ namespace Tnb.ProductionMgr report.status = 0; report.material_id = prdMoTask.material_id; report.unit_id = prdMoTask.unit_id; + report.process_id = mbomProcess?.process_id ?? ""; row = await db.Insertable(report).ExecuteCommandAsync(); @@ -1440,7 +1446,6 @@ namespace Tnb.ProductionMgr if (prdMoTask.schedule_type == 2 && !string.IsNullOrEmpty(prdMoTask.mbom_process_id)) { - var mbomProcess = await db.Queryable().SingleAsync(x => x.id == prdMoTask.mbom_process_id); if (mbomProcess.is_last==1 && prdMoTask != null && !string.IsNullOrEmpty(prdMoTask.parent_id)) { var parentMoTask = await db.Queryable().SingleAsync(x => x.id == prdMoTask.parent_id); @@ -1820,20 +1825,25 @@ namespace Tnb.ProductionMgr (a, b, c, d) => a.workline_id == eqpId || a.eqp_id == eqpId) .WhereIF(worklineIds.Count > 0, (a, b, c, d) => worklineIds.Contains(a.workline_id)) .WhereIF(equipIds.Count > 0, (a, b, c, d) => equipIds.Contains(a.eqp_id)) + .Where((a)=>a.mo_task_status==DictConst.ToBeStartedEnCode || a.mo_task_code==DictConst.ToBeScheduledEncode || a.mo_task_code==DictConst.MoStatusPauseCode) .Select((a, b, c, d,e,f,g,h) => new WorkOrderAdjustmentListOutput { id = a.id, mo_task_code = a.mo_task_code, material_id = b.code+"/"+b.name, + material_id_id = a.material_id, mold_id = e.mold_code+"/"+e.mold_name, + mold_id_id = a.mold_id, mo_task_status = d.FullName, plan_qty = f.plan_qty, complete_qty = SqlFunc.IsNull(a.reported_work_qty,0) + SqlFunc.IsNull(a.scrap_qty,0), scheduled_qty = a.scheduled_qty, workline_id = a.workline_id==null ? "" :g.EnCode+"/"+g.FullName, + workline_id_id = a.workline_id, estimated_start_date = a.estimated_start_date==null ? "" : a.estimated_start_date.Value.ToString("yyyy-MM-dd"), estimated_end_date = a.estimated_end_date==null ? "" : a.estimated_end_date.Value.ToString("yyyy-MM-dd"), eqp_id = a.eqp_id==null ? "" : h.code+"/"+h.name, + eqp_id_id = a.eqp_id, create_time = a.create_time==null ? "" :a.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss") }).OrderByDescending(a => a.create_time).ToPagedListAsync(input.currentPage, input.pageSize); return PageResult.SqlSugarPageResult(result); @@ -1924,5 +1934,145 @@ namespace Tnb.ProductionMgr .Where(x => x.workline_id == id && x.mo_task_status == DictConst.InProgressEnCode).FirstAsync(); } + /// + /// 更换机台 + /// + /// + [HttpPost] + public async Task ChangeEquip(ChangeEquipInput input) + { + var db = _repository.AsSugarClient(); + DbResult result = await db.Ado.UseTranAsync(async () => + { + var moTask = await db.Queryable().SingleAsync(x => x.id == input.mo_task_id); + if (moTask.eqp_id == input.equip_id) + { + throw new Exception("与原机台相同"); + } + + await db.Updateable().SetColumns(x => x.eqp_id == input.equip_id) + .Where(x => x.id == input.mo_task_id).ExecuteCommandAsync(); + + var mo = await db.Queryable().SingleAsync(x => x.id == moTask.mo_id); + var material = await db.Queryable().SingleAsync(x => x.id == moTask.material_id); + var process = await db.Queryable().SingleAsync(x => x.id == moTask.process_id); + var taskLog = new PrdTaskLog(); + taskLog.id = SnowflakeIdHelper.NextId(); + taskLog.mo_code = mo?.mo_code!; + taskLog.eqp_code = (await db.Queryable().FirstAsync(it => it.id == input.equip_id))?.code!; + taskLog.mold_code = ""; + taskLog.item_code = material?.code!; + taskLog.item_standard = material?.material_standard!; + taskLog.status = "更换机台"; + taskLog.operator_name = _userManager.RealName; + taskLog.create_id = _userManager.UserId; + taskLog.create_time = DateTime.Now; + taskLog.mo_task_id = moTask.id; + taskLog.mo_task_code = moTask.mo_task_code; + taskLog.station_code = ""; + taskLog.process_code = process?.code; + + await db.Insertable(taskLog).ExecuteCommandAsync(); + }); + + if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage); + return result.IsSuccess ? "延期成功" : result.ErrorMessage; + + } + + /// + /// 更换模具 + /// + /// + [HttpPost] + public async Task ChangeMold(ChangeMoldInput input) + { + var db = _repository.AsSugarClient(); + DbResult result = await db.Ado.UseTranAsync(async () => + { + var moTask = await db.Queryable().SingleAsync(x => x.id == input.mo_task_id); + if (moTask.mold_id == input.mold_id) + { + throw new Exception("与原模具相同"); + } + + await db.Updateable().SetColumns(x => x.mold_id == input.mold_id) + .Where(x => x.id == input.mo_task_id).ExecuteCommandAsync(); + + var mo = await db.Queryable().SingleAsync(x => x.id == moTask.mo_id); + var mold = await db.Queryable().SingleAsync(x => x.id == input.mold_id); + var material = await db.Queryable().SingleAsync(x => x.id == moTask.material_id); + var process = await db.Queryable().SingleAsync(x => x.id == moTask.process_id); + var taskLog = new PrdTaskLog(); + taskLog.id = SnowflakeIdHelper.NextId(); + taskLog.mo_code = mo?.mo_code!; + taskLog.eqp_code = ""; + taskLog.mold_code = mold?.mold_code; + taskLog.item_code = material?.code!; + taskLog.item_standard = material?.material_standard!; + taskLog.status = "更换模具"; + taskLog.operator_name = _userManager.RealName; + taskLog.create_id = _userManager.UserId; + taskLog.create_time = DateTime.Now; + taskLog.mo_task_id = moTask.id; + taskLog.mo_task_code = moTask.mo_task_code; + taskLog.station_code = ""; + taskLog.process_code = process?.code; + + await db.Insertable(taskLog).ExecuteCommandAsync(); + }); + + if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage); + return result.IsSuccess ? "延期成功" : result.ErrorMessage; + + } + + /// + /// 更换产线 + /// + /// + [HttpPost] + public async Task ChangeWorkline(ChangeWorklineInput input) + { + var db = _repository.AsSugarClient(); + DbResult result = await db.Ado.UseTranAsync(async () => + { + var moTask = await db.Queryable().SingleAsync(x => x.id == input.mo_task_id); + if (moTask.workline_id == input.workline_id) + { + throw new Exception("与原产线相同"); + } + + + await db.Updateable().SetColumns(x => x.workline_id == input.workline_id) + .Where(x => x.id == input.mo_task_id).ExecuteCommandAsync(); + + var mo = await db.Queryable().SingleAsync(x => x.id == moTask.mo_id); + var material = await db.Queryable().SingleAsync(x => x.id == moTask.material_id); + var process = await db.Queryable().SingleAsync(x => x.id == moTask.process_id); + var taskLog = new PrdTaskLog(); + taskLog.id = SnowflakeIdHelper.NextId(); + taskLog.mo_code = mo?.mo_code!; + taskLog.eqp_code = ""; + taskLog.mold_code = ""; + taskLog.item_code = material?.code!; + taskLog.item_standard = material?.material_standard!; + taskLog.status = "更换产线"; + taskLog.operator_name = _userManager.RealName; + taskLog.create_id = _userManager.UserId; + taskLog.create_time = DateTime.Now; + taskLog.mo_task_id = moTask.id; + taskLog.mo_task_code = moTask.mo_task_code; + taskLog.station_code = ""; + taskLog.process_code = process?.code; + + await db.Insertable(taskLog).ExecuteCommandAsync(); + }); + + if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage); + return result.IsSuccess ? "延期成功" : result.ErrorMessage; + + } + } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/TimedTaskBackgroundService.cs b/WarehouseMgr/Tnb.WarehouseMgr/TimedTaskBackgroundService.cs index 8eb61c17..55ba81df 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/TimedTaskBackgroundService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/TimedTaskBackgroundService.cs @@ -32,7 +32,7 @@ namespace Tnb.WarehouseMgr /// public class TimedTaskBackgroundService : BackgroundService { - private IEventPublisher _eventPublisher; + private IEventPublisher _eventPublisher = default!; protected override Task ExecuteAsync(CancellationToken stoppingToken) => Task.Run(() => { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 1f78ed98..71c65a20 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -500,18 +500,37 @@ namespace Tnb.WarehouseMgr //更新载具,锁定状态为未锁定,更新载具的库位当前任务的目标库位 var multiList = disTasks.Select(it => (it.carry_id, it.endlocation_id, it.endlocation_code)).ToList(); + var locWhIdMap = await _db.Queryable().Where(it => multiList.Select(x => x.endlocation_id).Contains(it.id)).ToDictionaryAsync(it => it.id, it => it.wh_id); + List carryIts = new(); + List carryCodeIts = new(); for (int i = 0; i < multiList.Count; i++) { - await _db.Updateable().SetColumns(it => new WmsCarryH { is_lock = 0, location_id = multiList[i].endlocation_id, location_code = multiList[i].endlocation_code }).Where(it => it.id == multiList[i].carry_id).ExecuteCommandAsync(); - //更新条码的库位和仓库信息 - var carryCodes = await _db.Queryable().Where(it => it.id == multiList[i].carry_id).ToListAsync(); - if (carryCodes?.Count > 0) + WmsCarryH carry = new() { - var loc = await _db.Queryable().SingleAsync(it => it.id == multiList[i].endlocation_id); - await _db.Updateable().SetColumns(it => new WmsCarryCode { warehouse_id = loc.wh_id, location_id = multiList[i].endlocation_id, location_code = multiList[i].endlocation_code }).Where(it => it.id == multiList[i].carry_id).ExecuteCommandAsync(); - } - } + id = multiList[i].carry_id, + is_lock = 0, + location_id = multiList[i].endlocation_id, + location_code = multiList[i].endlocation_code + }; + WmsCarryCode carryCode = new() + { + warehouse_id = locWhIdMap[multiList[i].endlocation_id].ToString(), + location_id = multiList[i].endlocation_id, + location_code = multiList[i].endlocation_code + }; + carryIts.Add(carry); + carryCodeIts.Add(carryCode); + //await _db.Updateable().SetColumns(it => new WmsCarryH { is_lock = 0, location_id = multiList[i].endlocation_id, location_code = multiList[i].endlocation_code }).Where(it => it.id == multiList[i].carry_id).ExecuteCommandAsync(); + ////更新条码的库位和仓库信息 + //var carryCodes = await _db.Queryable().Where(it => it.id == multiList[i].carry_id).ToListAsync(); + //if (carryCodes?.Count > 0) + //{ + // await _db.Updateable().SetColumns(it => new WmsCarryCode { warehouse_id = locWhIdMap[multiList[i].endlocation_id].ToString(), location_id = multiList[i].endlocation_id, location_code = multiList[i].endlocation_code }).Where(it => it.id == multiList[i].carry_id).ExecuteCommandAsync(); + //} + } + await _db.Updateable(carryIts).UpdateColumns(it => new { it.is_lock, it.location_id, it.location_code }).ExecuteCommandAsync(); + await _db.Updateable(carryCodeIts).UpdateColumns(it => new { it.warehouse_id, it.location_id, it.location_code }).Where(it => multiList.Select(x => x.carry_id).Contains(it.carry_id)).ExecuteCommandAsync(); //更新库位信息,使用状态为 使用,锁定状态为未锁定 var multis = disTasks.Select(it => (it.endlocation_id, it.carry_status)).ToList(); for (int i = 0; i < multis.Count; i++) diff --git a/system/Tnb.Systems/Permission/DepartmentService.cs b/system/Tnb.Systems/Permission/DepartmentService.cs index 47949942..872c5ce1 100644 --- a/system/Tnb.Systems/Permission/DepartmentService.cs +++ b/system/Tnb.Systems/Permission/DepartmentService.cs @@ -536,6 +536,20 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra isOK = await _repository.AsSugarClient().Updateable().SetColumns(it => new EqpEquipment { station_code = "" }).Where(it => unbindEqpIds.Contains(it.id)).ExecuteCommandAsync(); } } + await _repository.AsSugarClient().Deleteable(p => p.OrganizeId == id && p.ObjectType == "Eqp").ExecuteCommandAsync(); + var OrganizeRelationEntitys = new List(); + foreach (var item in eqpIds) + { + OrganizeRelationEntity organizeRelationEntity = new OrganizeRelationEntity(); + organizeRelationEntity.Id = SnowflakeIdHelper.NextId(); + organizeRelationEntity.OrganizeId = id; + organizeRelationEntity.ObjectType = "Eqp"; + organizeRelationEntity.ObjectId = item; + organizeRelationEntity.CreatorTime = DateTime.Now; + organizeRelationEntity.CreatorUserId = _userManager.UserId; + OrganizeRelationEntitys.Add(organizeRelationEntity); + } + await _repository.AsSugarClient().Insertable(OrganizeRelationEntitys).ExecuteCommandAsync(); } var processVal = jsonObj.GetValue("rowprocess"); if (processVal is not null) @@ -570,6 +584,25 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra isOK = await _repository.AsSugarClient().Updateable(it => new BasProcessStation { station_id = "", station_code = "" }).Where(it => curProcIds.Contains(it.process_id)).ExecuteCommandAsync(); } } + var correlation= jsonObj.GetValue("correlation"); + if (correlation is not null) + { + await _repository.AsSugarClient().Deleteable(p => p.OrganizeId == id && p.ObjectType == "User").ExecuteCommandAsync(); + var OrganizeRelationEntitys=new List(); + for (int i = 0; i < correlation.Count(); i++) + { + OrganizeRelationEntity organizeRelationEntity = new OrganizeRelationEntity(); + organizeRelationEntity.Id = SnowflakeIdHelper.NextId(); + organizeRelationEntity.OrganizeId = id; + organizeRelationEntity.ObjectType = "User"; + organizeRelationEntity.ObjectId = correlation[i].ToString(); + organizeRelationEntity.CreatorTime = DateTime.Now; + organizeRelationEntity.CreatorUserId = _userManager.UserId; + OrganizeRelationEntitys.Add(organizeRelationEntity); + } + await _repository.AsSugarClient().Insertable(OrganizeRelationEntitys).ExecuteCommandAsync(); + } + if (!(isOK > 0)) throw Oops.Oh(ErrorCode.COM1001); }