From d5eefbf9d5a186413bcb3c59f5dbb31b71e3e483 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Tue, 7 Nov 2023 16:56:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=95=E6=96=99=E4=BF=9D=E5=AD=98=20?= =?UTF-8?q?=E9=A2=86=E6=96=99=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.EquipMgr.Entities/Entity/EqpDaq.cs | 5 + .../Dto/PrdManage/FeedingInput.cs | 36 +++++ .../Dto/PrdManage/FeedingRecordInfoInput.cs | 11 ++ .../Dto/PrdManage/FeedingRecordInfoOutput.cs | 19 +++ .../Dto/PrdManage/FeedingRecordListInput.cs | 12 ++ .../Dto/PrdManage/FeedingRecordListOutput.cs | 15 ++ .../MaterialPreparationPlanOutput.cs | 1 + .../Entity/PrdKittingOutH.cs | 5 + .../Entity/PrdOutstockH.cs | 16 +++ .../Tnb.ProductionMgr/PrdFeedingService.cs | 134 ++++++++++++++++-- .../Tnb.ProductionMgr/PrdMoTaskService.cs | 1 + .../Tnb.ProductionMgr/PrdOutstockService.cs | 10 +- .../Tnb.ProductionMgr/PrdPackReportService.cs | 2 +- 13 files changed, 252 insertions(+), 15 deletions(-) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingInput.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordInfoInput.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordInfoOutput.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordListInput.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordListOutput.cs diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpDaq.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpDaq.cs index d387f251..638794b3 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpDaq.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpDaq.cs @@ -18,6 +18,11 @@ public partial class EqpDaq : BaseEntity /// 数据源 /// public string data_source { get; set; } = string.Empty; + + /// + /// 机号 + /// + public string? equip_code { get; set; } /// /// 标签名称 diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingInput.cs new file mode 100644 index 00000000..ed6a266d --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingInput.cs @@ -0,0 +1,36 @@ +namespace Tnb.ProductionMgr.Entities.Dto +{ + public class FeedingInput + { + /// + /// 工位id + /// + public string station_id { get; set; } = string.Empty; + + // /// + // /// 任务单id + // /// + // public string? mo_task_id { get; set; } + // + // /// + // /// 设备id + // /// + // public string? equip_id { get; set; } + + /// + /// 二维码信息 + /// + public string? carry_code { get; set; } + + public List details { get; set; } = new List(); + } + + public class FeedingDInput + { + + public string material_id { get; set; } + public string code_batch { get; set; } + public string unit_id { get; set; } + public decimal codeqty { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordInfoInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordInfoInput.cs new file mode 100644 index 00000000..bd59a8c9 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordInfoInput.cs @@ -0,0 +1,11 @@ +using JNPF.Common.Filter; + +namespace Tnb.ProductionMgr.Entities.Dto +{ + public class FeedingRecordInfoInput + { + public string id { get; set; } + + public string type { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordInfoOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordInfoOutput.cs new file mode 100644 index 00000000..b87be2dd --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordInfoOutput.cs @@ -0,0 +1,19 @@ +using JNPF.Common.Filter; + +namespace Tnb.ProductionMgr.Entities.Dto +{ + public class FeedingRecordInfoOutput + { + public string id { get; set; } + + public string material_id { get; set; } + + public string material_code { get; set; } + + public string material_name { get; set; } + + public decimal? num { get; set; } + + public string unit_name { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordListInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordListInput.cs new file mode 100644 index 00000000..15a4b826 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordListInput.cs @@ -0,0 +1,12 @@ +using JNPF.Common.Filter; + +namespace Tnb.ProductionMgr.Entities.Dto +{ + public class FeedingRecordListInput : PageInputBase + { + /// + /// 工位id + /// + public string stationId { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordListOutput.cs new file mode 100644 index 00000000..8dc92bfe --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordListOutput.cs @@ -0,0 +1,15 @@ + +namespace Tnb.ProductionMgr.Entities.Dto +{ + public class FeedingRecordListOutput + { + public string id { get; set; } + public string code { get; set; } + public string type_name { get; set; } + public string type { get; set; } + public string create_name { get; set; } + public string create_time { get; set; } + public string status { get; set; } + + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialPreparationPlanOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialPreparationPlanOutput.cs index 4f09160e..3c583966 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialPreparationPlanOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialPreparationPlanOutput.cs @@ -26,6 +26,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage { public string material_id { get; set; } public string material_code { get; set; } + public string category_id { get; set; } public decimal? num { get; set; } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdKittingOutH.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdKittingOutH.cs index 6169c976..693b57fa 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdKittingOutH.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdKittingOutH.cs @@ -93,5 +93,10 @@ public partial class PrdKittingOutH : BaseEntity /// 任务单 /// public string? mo_task_id { get; set; } + + /// + /// 状态 1 待配送 2 已完成 + /// + public string status { get; set; } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockH.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockH.cs index 8e07b8db..787a4198 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockH.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockH.cs @@ -14,6 +14,7 @@ public partial class PrdOutstockH : BaseEntity { id = SnowflakeIdHelper.NextId(); } + /// /// 出库单创建日期 /// @@ -23,6 +24,11 @@ public partial class PrdOutstockH : BaseEntity /// 单据类型 /// public string? bill_type { get; set; } + + /// + /// 单据类型 1 一般出库 2 物料出库 + /// + public string? type { get; set; } /// /// 发料仓库id @@ -38,6 +44,11 @@ public partial class PrdOutstockH : BaseEntity /// 创建用户 /// public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } /// /// 所属组织 @@ -58,6 +69,11 @@ public partial class PrdOutstockH : BaseEntity /// 所属产线 /// public string? workline { get; set; } + + /// + /// 状态 1 待配送 2 已完成 + /// + public string status { get; set; } /// /// 流程任务Id diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs index 6aebde11..054301b6 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs @@ -1,12 +1,15 @@ using JNPF.Common.Core.Manager; +using JNPF.Common.Filter; using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; using JNPF.Systems.Entitys.Permission; +using JNPF.Systems.Entitys.System; using JNPF.Systems.Interfaces.System; using Microsoft.AspNetCore.Mvc; using SqlSugar; +using Tnb.BasicData; using Tnb.BasicData.Entities; using Tnb.EquipMgr.Entities; using Tnb.ProductionMgr.Entities; @@ -335,7 +338,7 @@ namespace Tnb.ProductionMgr /// /// [HttpPost] - public async Task Feeding(MaterialReceiptNewInput input) + public async Task Feeding(FeedingInput input) { ISqlSugarClient db = _repository.AsSugarClient(); PrdMoTask moTask = await _prdMoTaskService.GetPrdMoTaskInfoByStationId(new Dictionary() @@ -375,7 +378,7 @@ namespace Tnb.ProductionMgr station_id = input.station_id, mo_task_id = moTask.id, process_id = moTask.process_id, - equip_id = input.equip_id, + // equip_id = input.equip_id, workshop_id = workshop?.Id, carry_id = carry.id, workline_id = moTask.workline_id, @@ -389,24 +392,24 @@ namespace Tnb.ProductionMgr if (input.details != null && input.details.Count > 0) { - foreach (Dictionary item in input.details) + foreach (var item in input.details) { - if (!inputMaterials.Contains(item["material_id"])) - { - throw new Exception("该物料不是生产bom投入物料,不能签收"); - } + // if (!inputMaterials.Contains(item["material_id"])) + // { + // throw new Exception("该物料不是生产bom投入物料,不能签收"); + // } PrdMaterialReceiptD? detail = await db.Queryable() .Where(x => x.member_carry_code == input.carry_code && x.is_all_feeding == 0).FirstAsync(); - decimal num = Convert.ToDecimal(item["num"]); + decimal num = item.codeqty; list.Add(new PrdFeedingD { feeding_id = prdFeedingH.id, material_receipt_detail_id = detail?.id, - material_id = item["material_id"], + material_id = item.material_id, num = num, - batch = item["batch"], - unit_id = item["unit_id"], + batch = item.code_batch, + unit_id = item.unit_id, carry_id = carry.id, status = "0", use_num = 0, @@ -440,7 +443,7 @@ namespace Tnb.ProductionMgr } else { - throw new Exception("没有签收物料"); + throw new Exception("没有签收物料,无法投料"); } @@ -450,7 +453,7 @@ namespace Tnb.ProductionMgr }); - return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "签收成功" : result.ErrorMessage); + return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "投料成功" : result.ErrorMessage); } [HttpPost] @@ -496,5 +499,110 @@ namespace Tnb.ProductionMgr .ToListAsync(); return result; } + + /// + /// pad app 领料记录列表 + /// + /// + [HttpPost] + public async Task FeedingRecordList(FeedingRecordListInput input) + { + if (string.IsNullOrEmpty(input.stationId)) + { + return new + { + pagination = new PageResult(), + list = Array.Empty() + }; + } + var db = _repository.AsSugarClient(); + + Dictionary queryJson = string.IsNullOrEmpty(input.queryJson) ? new Dictionary() : input.queryJson.ToObject>(); + string? code = queryJson.ContainsKey("code") ? queryJson["code"].ToString() : ""; + // DateTime? start_time = queryJson.ContainsKey("start_time") ? queryJson["start_time"].ToString() == "" ? null : Convert.ToDateTime(queryJson["start_time"]) : null; + // DateTime? end_time = queryJson.ContainsKey("end_time") ? queryJson["end_time"].ToString() == "" ? null : Convert.ToDateTime(queryJson["end_time"]) : null; + + if (string.IsNullOrEmpty(input.sidx)) + { + input.sidx = "create_time"; + input.sort = "desc"; + } + + var queryable1 = db.Queryable() + .LeftJoin((a, b) => a.create_id == b.Id) + .Select((a, b) => new FeedingRecordListOutput() + { + id = a.id, + code = a.code, + type_name = "齐套出库", + type = "0", + create_name = b.RealName, + create_time = a.create_time==null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS), + status = a.status + }); + + var queryable2 = db.Queryable() + .LeftJoin((a, b) => a.create_id == b.Id) + .Select((a, b) => new FeedingRecordListOutput() + { + id = a.id, + code = a.bill_code, + type_name = a.type=="1" ? "一般出库" : "物料出库", + type = a.type, + create_name = b.RealName, + create_time = a.create_time==null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS), + status = a.status + }); + var result = await db.UnionAll(queryable1,queryable2) + .MergeTable() + .OrderBy($"{input.sidx} {input.sort}") + .ToPagedListAsync(input.currentPage, input.pageSize); + + return PageResult.SqlSugarPageResult(result); + + } + + [HttpPost] + public async Task GetFeedingRecordInFoById(FeedingRecordInfoInput input) + { + var db = _repository.AsSugarClient(); + if (input.type == "0") + { + var result = db.Queryable() + .LeftJoin((a, b) => a.material_id == b.id) + .LeftJoin((a,b,c)=>c.EnCode==DictConst.MeasurementUnit) + .LeftJoin((a,b,c,d)=>d.DictionaryTypeId==c.Id && a.unit_id==d.Id) + .Where((a, b) => a.kitting_out_id == input.id) + .Select((a, b,c,d) => new FeedingRecordInfoOutput + { + id = a.id, + material_id = a.material_id, + material_code = b.code, + material_name = b.name, + num = a.pr_qty, + unit_name = d.FullName + }).ToListAsync(); + return result; + } + else + { + var result = db.Queryable() + .LeftJoin((a, b) => a.material_id == b.id) + .LeftJoin((a,b,c)=>c.EnCode==DictConst.MeasurementUnit) + .LeftJoin((a,b,c,d)=>d.DictionaryTypeId==c.Id && a.unit_id==d.Id) + .Where((a, b) => a.outstock_id == input.id) + .Select((a, b,c,d) => new FeedingRecordInfoOutput + { + id = a.id, + material_id = a.material_id, + material_code = b.code, + material_name = b.name, + num = a.pr_qty, + unit_name = d.FullName + }).ToListAsync(); + + return result; + } + } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index ab3d127c..e5383bf1 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -2675,6 +2675,7 @@ namespace Tnb.ProductionMgr { material_id = x.material_id, material_code = y.code, + category_id = y.category_id, num = x.num }) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs index a725cbe2..597ab613 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs @@ -42,13 +42,15 @@ namespace Tnb.ProductionMgr private readonly IDictionaryDataService _dictionaryDataService; private readonly IOrganizeService _organizeService; private readonly IUserManager _userManager; + private readonly IBillRullService _billRullService; public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); - public PrdOutstockService(ISqlSugarRepository repository, IOrganizeService organizeService, IRunService runService, IUserManager userManager, IVisualDevService visualDevService, IDictionaryDataService dictionaryDataService) + public PrdOutstockService(ISqlSugarRepository repository, IOrganizeService organizeService, IBillRullService billRullService,IRunService runService, IUserManager userManager, IVisualDevService visualDevService, IDictionaryDataService dictionaryDataService) { _db = repository.AsSugarClient(); _runService = runService; _visualDevService = visualDevService; + _billRullService = billRullService; _dictionaryDataService = dictionaryDataService; _repository = repository; _userManager = userManager; @@ -195,12 +197,15 @@ namespace Tnb.ProductionMgr { PrdOutstockH prdOutstockH = new() { + bill_code = await _billRullService.GetBillNumber(CodeTemplateConst.PRDOUTSTOCK_CODE), bill_type = DictConst.SHENGCHANLINGLIAO, + type = "1", warehouse_id = warehouse_id, location_code = generalOutstockInput.location_code, create_id = _userManager.UserId, org_id = _userManager.GetUserInfo().Result.organizeId, bill_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + create_time = DateTime.Now, workstation = generalOutstockInput.workstation_id, workline = workline?.Id ?? "" }; @@ -311,12 +316,15 @@ namespace Tnb.ProductionMgr else { PrdOutstockH prdOutstockH = new PrdOutstockH(); + prdOutstockH.bill_code = await _billRullService.GetBillNumber(CodeTemplateConst.PRDOUTSTOCK_CODE); prdOutstockH.bill_type = DictConst.SHENGCHANLINGLIAO; + prdOutstockH.type = "2"; prdOutstockH.warehouse_id = warehouse_id; prdOutstockH.location_code = materialOutstockInput.location_code; prdOutstockH.create_id = _userManager.UserId; prdOutstockH.org_id = _userManager.GetUserInfo().Result.organizeId; prdOutstockH.bill_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + prdOutstockH.create_time = DateTime.Now; prdOutstockH.workstation = materialOutstockInput.workstation_id; prdOutstockH.workline = workline?.Id ?? ""; diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs index 811f1948..6843bd63 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs @@ -464,7 +464,7 @@ namespace Tnb.ProductionMgr minpacking = b.minpacking, main_num = k.number_of_primary_unit, deputy_num = k.number_of_auxiliary_unit, - third_equip_code = f.third_equip_code, + third_equip_code = l.equip_code, weight_name = l.label_name, category_id = b.category_id })