diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMaterialReceiptRecordUpListOutPut.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMaterialReceiptRecordUpListOutPut.cs new file mode 100644 index 00000000..49d1e25d --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMaterialReceiptRecordUpListOutPut.cs @@ -0,0 +1,34 @@ +namespace Tnb.ProductionMgr.Entities.Dto +{ + public class PrdMaterialReceiptRecordUpListOutPut + { + public string id { get; set; } + public string mo_task_code { get; set; } + public string mo_task_status { get; set; } + public string mo_id { get; set; } + public string material_id { get; set; } + public string workstation_id { get; set; } + public string workline_id { get; set; } + public string act_start_date { get; set; } + public List tablefield103 { get; set; } = new List(); + } + + public class PrdMaterialReceiptRecordUpListChildOutPut + { + public string id { get; set; } + public string code { get; set; } + public string create_id { get; set; } + public string create_time { get; set; } + } + + public class PrdMaterialReceiptRecordUpListDownOutPut + { + public string id { get; set; } + public string material_id { get; set; } + public string unit_id { get; set; } + public string batch { get; set; } + public string feeding_num { get; set; } + public string num { get; set; } + public string member_carry_code { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptRecordDownServicecs.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptRecordDownServicecs.cs new file mode 100644 index 00000000..0f4ba098 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptRecordDownServicecs.cs @@ -0,0 +1,80 @@ +using JNPF.Common.Core.Manager; +using JNPF.Common.Filter; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.Systems.Entitys.Permission; +using JNPF.Systems.Entitys.System; +using JNPF.Systems.Interfaces.Permission; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using SqlSugar; +using Tnb.BasicData; +using Tnb.BasicData.Entities; +using Tnb.EquipMgr.Entities; +using Tnb.ProductionMgr.Entities; +using Tnb.ProductionMgr.Entities.Dto; +using Tnb.WarehouseMgr.Entities; + +namespace Tnb.ProductionMgr +{ + /// + /// 物料签收记录pc端 + /// + [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + [OverideVisualDev(ModuleId)] + public class PrdMaterialReceiptRecordDownServicecs : IDynamicApiController, ITransient, IOverideVisualDevService + { + private readonly ISqlSugarRepository _repository; + private readonly IUserManager _userManager; + private readonly IOrganizeService _organizeService; + private const string ModuleId = "30371998404373"; + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + + public PrdMaterialReceiptRecordDownServicecs( + ISqlSugarRepository repository, + IOrganizeService organizeService, + IUserManager userManager + ) + { + _repository = repository; + _organizeService = organizeService; + _userManager = userManager; + OverideFuncs.GetListAsync = GetList; + } + + private async Task GetList(VisualDevModelListQueryInput input) + { + var db = _repository.AsSugarClient(); + Dictionary? queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); + string material_receipt_id = queryJson.ContainsKey("material_receipt_id") ? queryJson["material_receipt_id"].ToString() : ""; + if (string.IsNullOrEmpty(material_receipt_id)) + { + return new + { + pagination = new PageResult(), + list = Array.Empty() + }; + } + + var result = await db.Queryable() + .LeftJoin((a, b) => a.material_id == b.id) + .LeftJoin((a,b,c)=>c.EnCode==DictConst.MeasurementUnit) + .LeftJoin((a,b,c,d)=>a.unit_id==d.EnCode && c.Id==d.DictionaryTypeId) + .WhereIF(!string.IsNullOrEmpty(material_receipt_id),a=>a.material_receipt_id==material_receipt_id) + .Select((a, b, c,d) => new PrdMaterialReceiptRecordUpListDownOutPut + { + id = a.id, + material_id = b.name, + unit_id = d.FullName, + batch = a.batch, + num = a.num.ToString(), + feeding_num = a.feeding_num.ToString(), + member_carry_code = a.member_carry_code + }).ToPagedListAsync(input.currentPage, input.pageSize); + return PageResult.SqlSugarPageResult(result); + } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptRecordUpServicecs.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptRecordUpServicecs.cs new file mode 100644 index 00000000..4d2292c8 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptRecordUpServicecs.cs @@ -0,0 +1,110 @@ +using JNPF.Common.Core.Manager; +using JNPF.Common.Filter; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.Systems.Entitys.Permission; +using JNPF.Systems.Entitys.System; +using JNPF.Systems.Interfaces.Permission; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using SqlSugar; +using Tnb.BasicData; +using Tnb.BasicData.Entities; +using Tnb.EquipMgr.Entities; +using Tnb.ProductionMgr.Entities; +using Tnb.ProductionMgr.Entities.Dto; +using Tnb.WarehouseMgr.Entities; + +namespace Tnb.ProductionMgr +{ + /// + /// 物料签收记录pc端 + /// + [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + [OverideVisualDev(ModuleId)] + public class PrdMaterialReceiptRecordUpServicecs : IDynamicApiController, ITransient, IOverideVisualDevService + { + private readonly ISqlSugarRepository _repository; + private readonly IUserManager _userManager; + private readonly IOrganizeService _organizeService; + private const string ModuleId = "30371961209365"; + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + + public PrdMaterialReceiptRecordUpServicecs( + ISqlSugarRepository repository, + IOrganizeService organizeService, + IUserManager userManager + ) + { + _repository = repository; + _organizeService = organizeService; + _userManager = userManager; + OverideFuncs.GetListAsync = GetList; + } + + private async Task GetList(VisualDevModelListQueryInput input) + { + var db = _repository.AsSugarClient(); + Dictionary? queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); + string mo_task_code = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : ""; + string mo_code = queryJson.ContainsKey("mo_id.mo_code") ? queryJson["mo_id.mo_code"].ToString() : ""; + // string workstation_id_str = queryJson.ContainsKey("workstation_id") ? queryJson["workstation_id"].ToString() : ""; + // string workstation_id = ""; + // if (!string.IsNullOrEmpty(workstation_id_str)) + // { + // string[] workstation_arr = JsonConvert.DeserializeObject(workstation_id_str); + // if (workstation_arr != null && workstation_arr.Length > 0) + // { + // workstation_id = workstation_arr[workstation_arr.Length - 1]; + // } + // } + + if (string.IsNullOrEmpty(input.sidx)) + { + input.sidx = "a.create_time"; + input.sort = "desc"; + } + else + { + input.sidx = "a." + input.sidx; + } + + + var result = await db.Queryable() + .LeftJoin((a, b) => a.material_id == b.id) + .LeftJoin((a,b,c)=>a.workstation_id==c.Id) + .LeftJoin((a,b,c,d)=>a.mo_id==d.id) + .LeftJoin((a,b,c,d,e)=>e.DictionaryTypeId==DictConst.PrdTaskStatusTypeId && a.mo_task_status==e.EnCode) + .LeftJoin((a,b,c,d,e,f)=>a.workline_id==f.Id) + .WhereIF(!string.IsNullOrEmpty(mo_task_code),a=>a.mo_task_code.Contains(mo_task_code)) + .WhereIF(!string.IsNullOrEmpty(mo_code),(a,b,c,d,e)=>d.mo_code.Contains(mo_code)) + .Where(a=>a.act_start_date!=null) + .OrderBy($"{input.sidx} {input.sort}") + .Select((a, b, c, d,e,f) => new PrdMaterialReceiptRecordUpListOutPut() + { + id = a.id, + mo_task_code = a.mo_task_code, + mo_id = d.mo_code, + material_id = b.name, + workstation_id = c.FullName, + mo_task_status = e.FullName, + workline_id = f.FullName, + act_start_date = a.act_start_date==null ? "" : a.act_start_date.Value.ToString(DbTimeFormat.SS), + tablefield103 = SqlFunc.Subqueryable() + .LeftJoin((x,y)=>x.create_id==y.Id) + .Where(x=>x.mo_task_id==a.id).ToList((x,y)=>new PrdMaterialReceiptRecordUpListChildOutPut() + { + id = x.id, + code = x.code, + create_id = y.RealName, + create_time = x.create_time==null ? "" : x.create_time.Value.ToString(DbTimeFormat.SS), + + }), + }).ToPagedListAsync(input.currentPage, input.pageSize); + return PageResult.SqlSugarPageResult(result); + } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index b1dde9b2..7ec20099 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1497,6 +1497,21 @@ namespace Tnb.ProductionMgr // throw Oops.Bah("已完成数量不能大于任务单数量"); // } + if (string.IsNullOrEmpty((input.material_box_code))) + { + throw Oops.Bah("载具不能为空"); + } + + if (string.IsNullOrEmpty((input.location_code))) + { + throw Oops.Bah("入库库位不能为空"); + } + + if (input.reported_qty<=0) + { + throw Oops.Bah("提报数量为正数"); + } + report = input.Adapt(); report.id = SnowflakeIdHelper.NextId(); report.reported_qty = input.reported_qty;