From e3943331106fe2cfb2ed16eff53b53a06a61c5ef Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Tue, 7 Nov 2023 09:56:32 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E7=89=A9=E6=96=99=E5=87=BA=E5=BA=93?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=20+=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/EqpEquipment.cs | 5 - .../Dto/PrdManage/MaterialOutstockInput.cs | 29 +++++ .../Dto/PrdManage/PADPackageTaskPageOutput.cs | 9 +- .../IPrdOutstockService.cs | 6 + .../Tnb.ProductionMgr/PrdMoTaskService.cs | 11 +- .../Tnb.ProductionMgr/PrdOutstockService.cs | 114 ++++++++++++++++++ .../Tnb.ProductionMgr/PrdPackReportService.cs | 4 +- 7 files changed, 164 insertions(+), 14 deletions(-) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialOutstockInput.cs diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipment.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipment.cs index 1a5d0b6c..300bbf3d 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipment.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipment.cs @@ -208,11 +208,6 @@ public partial class EqpEquipment : BaseEntity /// public string? qrcode { get; set; } - /// - /// 挤出件类型 - /// - public string? tube { get; set; } - /// /// 入库库位id /// diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialOutstockInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialOutstockInput.cs new file mode 100644 index 00000000..4fb08686 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialOutstockInput.cs @@ -0,0 +1,29 @@ +namespace Tnb.ProductionMgr.Entities.Dto +{ + public class MaterialOutstockInput + { + /// + /// 目标库位编号 + /// + public string location_code { get; set; } = string.Empty; + + /// 所属工位 + /// + public string? workstation_id { get; set; } + + /// + /// 任务单 + /// + public string? mo_task_id { get; set; } + + public List details { get; set; } = new List(); + } + + public class MaterialOutstockDInput + { + public string material_id { get; set; } + public string material_code { get; set; } + public string material_name { get; set; } + public decimal num { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PADPackageTaskPageOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PADPackageTaskPageOutput.cs index ddf21a33..9d415482 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PADPackageTaskPageOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PADPackageTaskPageOutput.cs @@ -127,10 +127,6 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// public string? act_end_date { get; set; } /// - /// 挤出件类型 - /// - public string? tube { get; set; } - /// /// 最小包装 /// public decimal? minpacking { get; set; } @@ -154,5 +150,10 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// 称重点位名称 /// public string? weight_name { get; set; } + + /// + /// 物料分类ID + /// + public string category_id { get; set; } = string.Empty; } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs index 0a669e72..8b90ba1b 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs @@ -12,5 +12,11 @@ namespace Tnb.ProductionMgr.Interfaces /// /// public Task GeneralOutstock(GeneralOutstockInput input); + + /// + /// 物料出库申请 + /// + /// + public Task MaterialOutstock(MaterialOutstockInput input); } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index b4da378d..b3129bd7 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1444,6 +1444,7 @@ namespace Tnb.ProductionMgr ISqlSugarClient db = _repository.AsSugarClient(); PrdMoTask? prdMoTask = await db.Queryable().SingleAsync(x => x.id == input.mo_task_id); EqpEquipment equip = await db.Queryable().SingleAsync(x => x.id == prdMoTask.eqp_id); + BasMaterial basMaterial = await db.Queryable().SingleAsync(x => x.id == prdMoTask.material_id); PrdReport report = await db.Queryable().FirstAsync(it => it.mo_task_id == input.mo_task_id); DbResult result = await _repository.AsSugarClient().Ado.UseTranAsync(async () => { @@ -1709,10 +1710,14 @@ namespace Tnb.ProductionMgr if (result.IsSuccess) { - if (equip.tube == "1") + if (!string.IsNullOrEmpty(basMaterial.category_id)) { - string resultMsg = await _prdInstockService.InstockTubeOne(report); - return resultMsg == "true" ? (dynamic)true : throw Oops.Bah(resultMsg); + string[] arr = JsonConvert.DeserializeObject(basMaterial.category_id); + if (arr.Length > 0 && arr.Contains("DGJCJ"))//短管挤出件入库申请 + { + string resultMsg = await _prdInstockService.InstockTubeOne(report); + return resultMsg == "true" ? (dynamic)true : throw Oops.Bah(resultMsg); + } } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs index 57409ef4..d810f4d7 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs @@ -243,5 +243,119 @@ namespace Tnb.ProductionMgr throw Oops.Bah(e.Message); } } + + public async Task MaterialOutstock(MaterialOutstockInput materialOutstockInput) + { + try + { + var db = _repository.AsSugarClient(); + string warehouse_id = "26103348825381";//二楼缓存仓 + + MESCreateOutstockInput input = new MESCreateOutstockInput(); + input.outstock = new MESWmsOutstockHInput(); + input.outstockDs = new List(); + + PrdMoTask prdMoTask = await db.Queryable().SingleAsync(x=>x.id==materialOutstockInput.mo_task_id); + BasLocation location = await db.Queryable().Where(x=>x.location_code==materialOutstockInput.location_code).FirstAsync(); + if (location == null) throw Oops.Bah("未找到库位"); + string locationId = location.id; + + input.outstock.bill_type = DictConst.SHENGCHANLINGLIAO; + // input.outstock.bill_date = visualDevModelDataCrInput.data.ContainsKey("bill_date") ? Convert.ToDateTime(visualDevModelDataCrInput.data["bill_date"].ToString()) : DateTime.Now; + input.outstock.bill_date = DateTime.Now; + input.outstock.org_id = _userManager.GetUserInfo().Result.organizeId; + input.outstock.warehouse_id = warehouse_id; + input.outstock.create_id = _userManager.UserId; + input.outstock.location_code = location?.location_code ?? ""; + OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(materialOutstockInput.workstation_id, DictConst.RegionCategoryWorklineCode); + + List materialIds = materialOutstockInput.details.Select(x => x.material_id).ToList(); + List basMaterials = await db.Queryable().Where(x=>materialIds.Contains(x.id)).ToListAsync(); + Dictionary unitIdDic = await db.Queryable() + .LeftJoin((a, b) => b.EnCode == DictConst.MeasurementUnit) + .LeftJoin((a, b, c) => b.Id == c.DictionaryTypeId && a.unit_id == c.EnCode) + .Where((a,b,c)=>materialIds.Contains(a.id)) + .Select((a, b, c) => new + { + key = a.id, + value = c.Id + }) + .ToDictionaryAsync(x => x.key, x => x.value); + + foreach (var item in materialOutstockInput.details) + { + input.outstockDs.Add(new MESWmsOutstockDInput() + { + material_id = item.material_id, + material_code = basMaterials.First(x=>x.id==item.material_id).code, + pr_qty = item.num, + unit_id = unitIdDic[item.material_id].ToString() + }); + } + + string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host; + Dictionary header = new Dictionary() + { + ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] + }; + var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_OUTSTOCK,JsonConvert.SerializeObject(input),header); + Log.Information(sendResult); + + AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); + if (authResponse.code != 200) + { + throw Oops.Bah(authResponse.msg); + } + else + { + PrdOutstockH prdOutstockH = new PrdOutstockH(); + prdOutstockH.bill_type = DictConst.SHENGCHANLINGLIAO; + 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.workstation = materialOutstockInput.workstation_id; + prdOutstockH.workline = workline?.Id ?? ""; + + List prdOutstockDs = new List(); + foreach (var item in materialOutstockInput.details) + { + prdOutstockDs.Add(new PrdOutstockD() + { + material_id = item.material_id, + material_code = basMaterials.First(x=>x.id==item.material_id).code, + material_name = basMaterials.First(x=>x.id==item.material_id).name, + pr_qty = item.num, + unit_id = unitIdDic[item.material_id].ToString(), + outstock_id = prdOutstockH.id, + source_id = prdMoTask.mo_task_code + }); + } + + DbResult result = await _repository.AsSugarClient().Ado.UseTranAsync(async () => + { + await _repository.InsertAsync(prdOutstockH); + if (prdOutstockDs.Count > 0) + { + await db.Insertable(prdOutstockDs).ExecuteCommandAsync(); + } + }); + + if (!result.IsSuccess) + { + throw Oops.Bah(result.ErrorMessage); + } + + } + return await Task.FromResult(true); + } + catch (Exception e) + { + Console.WriteLine(e); + Log.Error(e.Message); + throw Oops.Bah(e.Message); + } + } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs index 74c5bfa9..811f1948 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs @@ -461,12 +461,12 @@ namespace Tnb.ProductionMgr act_start_date = a.act_start_date == null ? "" : a.act_start_date.Value.ToString(DbTimeFormat.SS), act_end_date = a.act_end_date == null ? "" : a.act_end_date.Value.ToString(DbTimeFormat.SS), plan_end_date = a.plan_end_date == null ? "" : a.plan_end_date.Value.ToString(DbTimeFormat.SS), - tube = f.tube, minpacking = b.minpacking, main_num = k.number_of_primary_unit, deputy_num = k.number_of_auxiliary_unit, third_equip_code = f.third_equip_code, - weight_name = l.label_name + weight_name = l.label_name, + category_id = b.category_id }) .MergeTable() .OrderBy($"{input.sidx} {input.sort}") From eb3037385eb917f595edbdf1a7bd8bdc3ea7cb31 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Tue, 7 Nov 2023 10:15:47 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E5=B7=A5=E4=BD=8D=E5=8F=AA=E8=83=BD?= =?UTF-8?q?=E6=9C=89=E4=B8=80=E4=B8=AA=E8=BF=9B=E8=A1=8C=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index b3129bd7..d15877e2 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1114,6 +1114,11 @@ namespace Tnb.ProductionMgr throw Oops.Bah("已开始的不能再开始"); } + if (await db.Queryable().AnyAsync(x => x.workstation_id == item.workstation_id && x.mo_task_status == DictConst.InProgressEnCode && x.id != item.id)) + { + throw Oops.Bah("该工位已有生产中的任务单"); + } + if (item.mo_task_status is not DictConst.ToBeStartedEnCode and not DictConst.MoStatusPauseCode) { throw Oops.Bah("状态错误无法开始"); From 4029614a878bcbac5c56096d520a94fbfcd780a2 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Tue, 7 Nov 2023 10:31:43 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E4=B8=8D=E5=B1=9E=E4=BA=8E=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=8D=95=E7=9A=84=E7=89=A9=E6=96=99=E4=B9=9F=E5=8F=AF?= =?UTF-8?q?=E7=AD=BE=E6=94=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/PrdManage/MaterialReceiptInput.cs | 5 +++++ ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptInput.cs index a89af914..ab7c44cd 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptInput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptInput.cs @@ -60,5 +60,10 @@ namespace Tnb.ProductionMgr.Entities.Dto public string? mbom_process_id { get; set; } public List>? details { get; set; } + + /// + /// 存在不属于该任务单的原材料也要签收 + /// + public bool sure { get; set; } = false; } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs index 5516ea48..5cb24f52 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs @@ -170,9 +170,9 @@ namespace Tnb.ProductionMgr { foreach (Dictionary item in input.details) { - if (!inputMaterials.Contains(item["material_id"])) + if (!inputMaterials.Contains(item["material_id"]) && !input.sure) { - throw new Exception("该物料不是生产bom投入物料,不能签收"); + throw new Exception("存在不属于生产bom的投入物料,确认签收吗"); } list.Add(new PrdMaterialReceiptD From 0e67f002a7b4d033ef739fe56cb8bc4fed1b7455 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Tue, 7 Nov 2023 10:42:19 +0800 Subject: [PATCH 04/11] 1 --- ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs index d810f4d7..1ba42f52 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs @@ -122,6 +122,7 @@ namespace Tnb.ProductionMgr } + [HttpPost] public async Task GeneralOutstock(GeneralOutstockInput generalOutstockInput) { try @@ -244,6 +245,7 @@ namespace Tnb.ProductionMgr } } + [HttpPost] public async Task MaterialOutstock(MaterialOutstockInput materialOutstockInput) { try From 886a365aa0fbe6fa4108c6ac7326d44a07fd7a09 Mon Sep 17 00:00:00 2001 From: "fei.pan" Date: Tue, 7 Nov 2023 11:01:28 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E6=9A=82=E6=97=B6=E5=B1=8F=E8=94=BDCS860?= =?UTF-8?q?1-8604=E7=9A=84=E5=8F=AF=E7=A9=BA=E6=8A=A5=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Directory.Build.props | 2 +- visualdev/Tnb.Vengine/CodeGenerator/TemplateContext.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index d59ff165..a363d7b9 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ $(MSBuildThisFileDirectory) latest - $(NoWarn);CS1591; + $(NoWarn);CS1570;CS1587;CS1591;CS8601;CS8602;CS8603;CS8618; diff --git a/visualdev/Tnb.Vengine/CodeGenerator/TemplateContext.cs b/visualdev/Tnb.Vengine/CodeGenerator/TemplateContext.cs index b3fc49b9..2f9cd19b 100644 --- a/visualdev/Tnb.Vengine/CodeGenerator/TemplateContext.cs +++ b/visualdev/Tnb.Vengine/CodeGenerator/TemplateContext.cs @@ -28,7 +28,7 @@ public class TemplateContext #if DEBUG BasePath = CodeHelper.GetSolutionDirectoryPath(false)!; #else - BasePath = FileVariable.GenerateCodePath; + BasePath = JNPF.Common.Configuration.FileVariable.GenerateCodePath; #endif ModuleCode = moduleCode; } From 793524a06f95118cd043f59d765dfef4e0b7e72c Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Tue, 7 Nov 2023 11:29:51 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E7=89=A9=E6=96=99=E7=AD=BE=E6=94=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/PrdManage/NewMaterialReceiptInput.cs | 37 +++++ .../Entity/PrdMaterialReceiptD.cs | 2 +- .../PrdMaterialReceiptService.cs | 127 +++++++++++++++++- .../Tnb.ProductionMgr/PrdMoService.cs | 6 +- 4 files changed, 165 insertions(+), 7 deletions(-) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/NewMaterialReceiptInput.cs diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/NewMaterialReceiptInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/NewMaterialReceiptInput.cs new file mode 100644 index 00000000..62dde488 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/NewMaterialReceiptInput.cs @@ -0,0 +1,37 @@ +namespace Tnb.ProductionMgr.Entities.Dto +{ + public class NewMaterialReceiptInput + { + + /// + /// 工位id + /// + public string station_id { get; set; } = string.Empty; + + /// + /// 载具编号 + /// + public string? carry_code { get; set; } + + public List? details { get; set; } = new List(); + + /// + /// 存在不属于该任务单的原材料也要签收 + /// + public bool sure { get; set; } = false; + } + + public class NewMaterialReceiptDInput + { + public string material_id{get;set;} + public decimal num {get;set;} + public string batch {get;set;} + public string unit_id {get;set;} + public string barcode {get;set;} + public string member_carry_id {get;set;} + public string member_carry_code {get;set;} + public string supplier_id {get;set;} + public DateTime? instock_time {get;set;} + public string check_conclusion {get;set;} + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs index 27cadcf2..a693a3fd 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs @@ -77,7 +77,7 @@ public partial class PrdMaterialReceiptD : BaseEntity /// /// 入库时间 /// - public DateTime instock_time { get; set; } + public DateTime? instock_time { get; set; } /// /// 检验结论 /// diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs index 5cb24f52..a001b296 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs @@ -34,12 +34,13 @@ namespace Tnb.ProductionMgr private readonly IUserManager _userManager; private readonly IOrganizeService _organizeService; private readonly IBillRullService _billRullService; - + private readonly IPrdMoTaskService _prdMoTaskService; public PrdMaterialReceiptService( ISqlSugarRepository repository, IBillRullService billRullService, IOrganizeService organizeService, + IPrdMoTaskService prdMoTaskService, IUserManager userManager ) { @@ -47,6 +48,7 @@ namespace Tnb.ProductionMgr _userManager = userManager; _organizeService = organizeService; _billRullService = billRullService; + _prdMoTaskService = prdMoTaskService; } @@ -170,9 +172,9 @@ namespace Tnb.ProductionMgr { foreach (Dictionary item in input.details) { - if (!inputMaterials.Contains(item["material_id"]) && !input.sure) + if (!inputMaterials.Contains(item["material_id"])) { - throw new Exception("存在不属于生产bom的投入物料,确认签收吗"); + throw new Exception("该物料不是生产bom投入物料,不能签收"); } list.Add(new PrdMaterialReceiptD @@ -206,6 +208,125 @@ namespace Tnb.ProductionMgr }); + if (result.IsSuccess) + { + //签收后调用载具签收接口 + // await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput() + // { + // org_id = _userManager.GetUserInfo().Result.organizeId, + // create_id = _userManager.UserId, + // carry_code = input.carry_code ?? "", + // }); + + MESCarrySignInput mesCarrySignInput = new() + { + org_id = _userManager.GetUserInfo().Result.organizeId, + create_id = _userManager.UserId, + carry_code = input.carry_code ?? "", + }; + + string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host; + Dictionary header = new() + { + ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] + }; + string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN, JsonConvert.SerializeObject(mesCarrySignInput), header); + Log.Information(sendResult); + AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); + result2 = authResponse.code != 200 + ? throw Oops.Bah(authResponse.msg) + : await db.Ado.UseTranAsync(async () => + { + _ = await db.Insertable(prdMaterialReceiptH).ExecuteCommandAsync(); + _ = await db.Insertable(list).ExecuteCommandAsync(); + }); + } + return !result.IsSuccess + ? throw Oops.Bah(result.ErrorMessage) + : !result2.IsSuccess ? throw Oops.Bah(result2.ErrorMessage) : (dynamic)"签收成功"; + } + + [HttpPost] + public async Task SaveDataNew(NewMaterialReceiptInput input) + { + ISqlSugarClient db = _repository.AsSugarClient(); + PrdMoTask moTask = await _prdMoTaskService.GetPrdMoTaskInfoByStationId(new Dictionary(){ + {"station_id",input.station_id} + }); + DbResult result2 = new(); + PrdMaterialReceiptH? prdMaterialReceiptH = null; + List list = new(); + DbResult result = await db.Ado.UseTranAsync(async () => + { + List inputMaterials = await db.Queryable() + .Where(x => x.mbom_id == moTask.bom_id) + .WhereIF(!string.IsNullOrEmpty(moTask.mbom_process_id), x => x.mbom_process_id == moTask.mbom_process_id) + .Select(x => x.material_id) + .ToListAsync(); + + string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.MATERIAL_RECEIPT_CODE); + OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(input.station_id, DictConst.RegionCategoryWorklineCode); + OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(input.station_id, DictConst.RegionCategoryWorkshopCode); + WmsCarryH carry = await db.Queryable().Where(x=>x.carry_code==input.carry_code).FirstAsync(); + + + prdMaterialReceiptH = new PrdMaterialReceiptH() + { + code = code, + station_id = input.station_id, + mo_task_id = moTask.id, + process_id = moTask.process_id, + equip_id = moTask.eqp_id, + workshop_id = workshop?.Id ?? "", + carry_id = carry.id, + workline_id = workline?.Id ?? "", + carry_code = input.carry_code, + mbom_process_id = moTask.mbom_process_id, + create_id = _userManager.UserId, + create_time = DateTime.Now, + org_id = _userManager.GetUserInfo().Result.organizeId + }; + + if (input.details != null && input.details.Count > 0) + { + foreach (var item in input.details) + { + if (!inputMaterials.Contains(item.material_id) && !input.sure) + { + throw new Exception("存在不属于生产bom的投入物料,确认签收吗"); + } + + list.Add(new PrdMaterialReceiptD + { + material_receipt_id = prdMaterialReceiptH.id, + material_id = item.material_id, + num = item.num, + batch = item.batch, + unit_id = item.unit_id, + carry_id = carry.id, + barcode = item.barcode, + is_all_feeding = 0, + member_carry_id = item.member_carry_id, + member_carry_code = item.member_carry_code, + feeding_num = 0, + supplier_id = item.supplier_id, + instock_time = item.instock_time, + check_conclusion = item.check_conclusion, + }); + } + } + else + { + throw new Exception("没有签收物料"); + } + + + // await db.Insertable(prdMaterialReceiptH).ExecuteCommandAsync(); + // await db.Insertable(list).ExecuteCommandAsync(); + + }); + + if (result.IsSuccess) { //签收后调用载具签收接口 diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs index bfeceab0..acaad592 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs @@ -735,7 +735,7 @@ namespace Tnb.ProductionMgr batch = a.batch, supplier_name = d.supplier_name, check_conclusion = c.check_conclusion, - instock_time = c.instock_time.ToString(DbTimeFormat.SS), + instock_time = c.instock_time==null ? "" : c.instock_time.Value.ToString(DbTimeFormat.SS), feeding_time = e.create_time == null ? "" : e.create_time.Value.ToString(DbTimeFormat.SS), }).ToListAsync(); @@ -848,8 +848,8 @@ namespace Tnb.ProductionMgr batch = a.batch, supplier_name = d.supplier_name, check_conclusion = c.check_conclusion, - instock_time = c.instock_time.ToString("yyyy-MM-dd HH:mm:ss"), - feeding_time = e.create_time == null ? "" : e.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"), + instock_time = c.instock_time==null ? "" : c.instock_time.Value.ToString(DbTimeFormat.SS), + feeding_time = e.create_time == null ? "" : e.create_time.Value.ToString(DbTimeFormat.SS), }); if (lastPrdReportIds != null && lastPrdReportIds.Count > 0) From b7ae473d8e3063d7f077760532fda879f3ba1b0d Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Tue, 7 Nov 2023 11:35:25 +0800 Subject: [PATCH 07/11] 1 --- .../Dto/PrdManage/NewMaterialReceiptInput.cs | 8 ++++---- .../Tnb.ProductionMgr/PrdMaterialReceiptService.cs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/NewMaterialReceiptInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/NewMaterialReceiptInput.cs index 62dde488..8759ff05 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/NewMaterialReceiptInput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/NewMaterialReceiptInput.cs @@ -24,12 +24,12 @@ namespace Tnb.ProductionMgr.Entities.Dto public class NewMaterialReceiptDInput { public string material_id{get;set;} - public decimal num {get;set;} - public string batch {get;set;} + public decimal codeqty {get;set;} + public string code_batch {get;set;} public string unit_id {get;set;} public string barcode {get;set;} - public string member_carry_id {get;set;} - public string member_carry_code {get;set;} + public string member_carryid {get;set;} + public string member_carrycode {get;set;} public string supplier_id {get;set;} public DateTime? instock_time {get;set;} public string check_conclusion {get;set;} diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs index a001b296..e6a66826 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs @@ -300,14 +300,14 @@ namespace Tnb.ProductionMgr { material_receipt_id = prdMaterialReceiptH.id, material_id = item.material_id, - num = item.num, - batch = item.batch, + num = item.codeqty, + batch = item.code_batch, unit_id = item.unit_id, carry_id = carry.id, barcode = item.barcode, is_all_feeding = 0, - member_carry_id = item.member_carry_id, - member_carry_code = item.member_carry_code, + member_carry_id = item.member_carryid, + member_carry_code = item.member_carrycode, feeding_num = 0, supplier_id = item.supplier_id, instock_time = item.instock_time, From 64bb0ff68035df0ed3c2abf9359be76a12f7f5db Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Tue, 7 Nov 2023 14:58:43 +0800 Subject: [PATCH 08/11] 1 --- .../IBasMaterialService.cs | 7 + BasicData/Tnb.BasicData/BasMaterialService.cs | 16 +++ .../Dto/PrdManage/PADPackageTaskPageOutput.cs | 11 ++ .../Entity/PrdReport.cs | 5 + .../IPrdInstockService.cs | 7 + .../Tnb.ProductionMgr/PrdInstockService.cs | 121 +++++++++++++++++- .../PrdMaterialReceiptService.cs | 5 + .../Tnb.ProductionMgr/PrdMoTaskService.cs | 6 + .../Tnb.ProductionMgr/PrdOutstockService.cs | 2 +- 9 files changed, 175 insertions(+), 5 deletions(-) diff --git a/BasicData/Tnb.BasicData.Interfaces/IBasMaterialService.cs b/BasicData/Tnb.BasicData.Interfaces/IBasMaterialService.cs index ddfc341b..4b25fed5 100644 --- a/BasicData/Tnb.BasicData.Interfaces/IBasMaterialService.cs +++ b/BasicData/Tnb.BasicData.Interfaces/IBasMaterialService.cs @@ -32,5 +32,12 @@ namespace Tnb.BasicData.Interfaces /// /// public Task GetMaterialByQueryJson(MaterialQueryInput input); + + /// + /// 获取物料的入库仓库 + /// + /// + /// + public Task GetInboundWarehouseById(Dictionary dic); } } \ No newline at end of file diff --git a/BasicData/Tnb.BasicData/BasMaterialService.cs b/BasicData/Tnb.BasicData/BasMaterialService.cs index fb4df1df..1b769e9d 100644 --- a/BasicData/Tnb.BasicData/BasMaterialService.cs +++ b/BasicData/Tnb.BasicData/BasMaterialService.cs @@ -220,6 +220,22 @@ namespace Tnb.BasicData } + [HttpPost] + public async Task GetInboundWarehouseById(Dictionary dic) + { + string id = dic.ContainsKey("id") ? dic["id"] : ""; + + return await _repository.AsSugarClient().Queryable() + .LeftJoin((a, b) => a.wh_id == b.id) + .Where((a, b) => a.material_id == id) + .Select((a, b) => new + { + warehouse_id = a.wh_id, + warehouse_code = b.whcode, + warehouse_name = b.whname + }).ToListAsync(); + } + /// /// 获取物料清单下所子集物料id /// diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PADPackageTaskPageOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PADPackageTaskPageOutput.cs index 9d415482..fe96dc58 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PADPackageTaskPageOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PADPackageTaskPageOutput.cs @@ -155,5 +155,16 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// 物料分类ID /// public string category_id { get; set; } = string.Empty; + + /// + /// 入库仓库id + /// + public string warehouse_id { get; set; } + + public string warehouse_code { get; set; } + + public string warehouse_name { 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 f19f3a84..a24b070f 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs @@ -129,5 +129,10 @@ public partial class PrdReport : BaseEntity /// 料箱编号 /// public string material_box_code { get; set; } + + /// + /// 长管挤出入库库位 + /// + public string location_code { get; set; } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs index 9fdbb4e9..82f82e86 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs @@ -36,5 +36,12 @@ namespace Tnb.ProductionMgr.Interfaces /// /// public Task InstockTubeOne(PrdReport prdReport); + + /// + /// 长管管挤出入库申请 + /// + /// + /// + public Task InstockTubeThree(PrdReport prdReport); } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs index 377649b8..44594713 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs @@ -263,6 +263,7 @@ namespace Tnb.ProductionMgr { string equip_code = inut.equip_code; string as_location_code = inut.as_location_code; + string warehouse_id = "2"; if (!string.IsNullOrEmpty(equip_code)) { throw Oops.Bah("请传机台号"); @@ -315,7 +316,8 @@ namespace Tnb.ProductionMgr workline_id = workline?.Id ?? "", workshop_id = workshop?.Id ?? "", org_id = _userManager.GetUserInfo().Result.organizeId, - warehouse_id = basLocation?.wh_id, + // warehouse_id = basLocation?.wh_id, + warehouse_id = warehouse_id, status = 0, }; @@ -341,7 +343,8 @@ namespace Tnb.ProductionMgr org_id = _userManager.GetUserInfo().Result.organizeId, bill_date = DateTime.Now, bill_type = DictConst.CHANCHENGPINRUKUDAN, - warehouse_id = basLocation?.wh_id, + // warehouse_id = basLocation?.wh_id, + warehouse_id = warehouse_id, source_id = prdInstockH.id, create_id = _userManager.UserId, carry_code = prdReport.material_box_code, @@ -397,8 +400,118 @@ namespace Tnb.ProductionMgr public async Task InstockTubeOne(PrdReport prdReport) { ISqlSugarClient db = _repository.AsSugarClient(); - string location_code = "JMXHC-01"; - string warehouse_id = "26103348825381"; + string location_code = "ZCR01";//todo 短管挤出件目标库位之后改 + string warehouse_id = "2"; + + PrdInstockH? prdInstockH = null; + List prdInstockDs = new() { }; + DbResult result2 = new(); + BasMaterial basMaterial = await db.Queryable().SingleAsync(x => x.id == prdReport.material_id); + DbResult result = await db.Ado.UseTranAsync(async () => + { + OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorklineCode); + OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorkshopCode); + + prdInstockH = new PrdInstockH() + { + bill_type = DictConst.CHANCHENGPINRUKUDAN, + bill_date = DateTime.Now, + create_id = _userManager.UserId, + location_code = location_code, + carry_code = prdReport.material_box_code, + is_check = 1, + station_id = prdReport.station, + workline_id = workline?.Id ?? "", + workshop_id = workshop?.Id ?? "", + org_id = _userManager.GetUserInfo().Result.organizeId, + warehouse_id = warehouse_id, + status = 0, + }; + + prdInstockDs.Add(new PrdInstockD() + { + instock_id = prdInstockH.id, + report_id = prdReport.create_id, + material_id = prdReport.material_id, + material_code = basMaterial.code, + unit_id = prdReport.unit_id, + barcode = prdReport.barcode, + code_batch = prdReport.barcode + "0001", + quantity = (int)prdReport.reported_qty, + }); + }); + + if (result.IsSuccess) + { + MESCreateInstockInput mesCreateInstockInput = new() + { + instock = new MESWmsInstockHInput() + { + org_id = _userManager.GetUserInfo().Result.organizeId, + bill_date = DateTime.Now, + bill_type = DictConst.CHANCHENGPINRUKUDAN, + warehouse_id = warehouse_id, + source_id = prdInstockH.id, + create_id = _userManager.UserId, + carry_code = prdReport.material_box_code, + location_code = location_code, + is_check = 1, + }, + instockds = new List(), + instockcodes = new List() + }; + mesCreateInstockInput.instockds.Add(new MESWmsInstockDInput() + { + material_id = prdReport.material_id, + material_code = basMaterial.code, + unit_id = prdReport.unit_id, + code_batch = prdReport.barcode, + pr_qty = (int)prdReport.reported_qty, + }); + + mesCreateInstockInput.instockcodes.Add(new MESWmsInstockCodeInput() + { + material_id = prdReport.material_id, + material_code = basMaterial.code, + unit_id = prdReport.unit_id, + barcode = prdReport.barcode, + code_batch = prdReport.barcode + "0001", + codeqty = (int)prdReport.reported_qty, + }); + string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host; + Dictionary header = new() + { + ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] + }; + string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header); + Log.Information(sendResult); + AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); + result2 = authResponse.code != 200 || !authResponse.data.ObjToBool() + ? throw Oops.Bah(authResponse.msg) + : await db.Ado.UseTranAsync(async () => + { + _ = await _repository.InsertAsync(prdInstockH); + + if (prdInstockDs.Count > 0) + { + _ = await db.Insertable(prdInstockDs).ExecuteCommandAsync(); + } + }); + } + + return result2.IsSuccess ? "true" : "false"; + } + + /// + /// 长管管挤出入库申请 + /// + /// + /// + public async Task InstockTubeThree(PrdReport prdReport) + { + ISqlSugarClient db = _repository.AsSugarClient(); + string location_code = prdReport.location_code; + string warehouse_id = "27209786980373";//长件挤出缓存仓 PrdInstockH? prdInstockH = null; List prdInstockDs = new() { }; diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs index e6a66826..b6141638 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs @@ -360,6 +360,11 @@ namespace Tnb.ProductionMgr _ = await db.Insertable(list).ExecuteCommandAsync(); }); } + + if (result.ErrorMessage == "存在不属于生产bom的投入物料,确认签收吗") + { + return "存在不属于生产bom的投入物料,确认签收吗"; + } return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : !result2.IsSuccess ? throw Oops.Bah(result2.ErrorMessage) : (dynamic)"签收成功"; diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index d15877e2..ab3d127c 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1723,6 +1723,12 @@ namespace Tnb.ProductionMgr string resultMsg = await _prdInstockService.InstockTubeOne(report); return resultMsg == "true" ? (dynamic)true : throw Oops.Bah(resultMsg); } + + if (arr.Length > 0 && arr.Contains("CGJCJ"))//短管挤出件入库申请 + { + string resultMsg = await _prdInstockService.InstockTubeThree(report); + return resultMsg == "true" ? (dynamic)true : throw Oops.Bah(resultMsg); + } } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs index 1ba42f52..a725cbe2 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs @@ -251,7 +251,7 @@ namespace Tnb.ProductionMgr try { var db = _repository.AsSugarClient(); - string warehouse_id = "26103348825381";//二楼缓存仓 + string warehouse_id = "27209786980373";//长件挤出缓存仓 MESCreateOutstockInput input = new MESCreateOutstockInput(); input.outstock = new MESWmsOutstockHInput(); From f76a04059db3628ddfd06f43c8fa2cc33711f615 Mon Sep 17 00:00:00 2001 From: qianjiawei <1184704771@qq.com> Date: Tue, 7 Nov 2023 16:16:50 +0800 Subject: [PATCH 09/11] redis --- .../Tnb.ProductionMgr/RedisBackGround.cs | 42 +-- .../Tnb.ProductionMgr/RedisDataService.cs | 30 +-- .../Tnb.API.Entry/Configurations/Cache.json | 6 + apihost/Tnb.API.Entry/Startup.cs | 4 +- common/Tnb.Common/Redis/RedisData.cs | 247 ++++++++++++++++++ common/Tnb.Common/Redis/RedisOptions.cs | 34 +++ 6 files changed, 319 insertions(+), 44 deletions(-) create mode 100644 common/Tnb.Common/Redis/RedisData.cs create mode 100644 common/Tnb.Common/Redis/RedisOptions.cs diff --git a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs index b6e7f3ad..12879acb 100644 --- a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs +++ b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.Hosting; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Tnb.Common.Redis; using Tnb.ProductionMgr.Entities.Dto; using Tnb.ProductionMgr.Entities.Enums; using Tnb.ProductionMgr.Interfaces; @@ -11,25 +12,24 @@ namespace Tnb.ProductionMgr //redis定时获取数采数据 public class RedisBackGround : IHostedService, IDisposable { - private readonly Timer? packtimer; - private readonly Timer? limittimer; - private readonly RedisCache _redisCache; + private Timer? ZSpacktimer; + private Timer? JCpacktimer; + private Timer? limittimer; + private readonly RedisData _redisData; private readonly IPrdInstockService _prdInstockService; - public RedisBackGround(RedisCache redisCache, IPrdInstockService prdInstockService) + public RedisBackGround(RedisData redisData, IPrdInstockService prdInstockService) { - _redisCache = redisCache; + _redisData = redisData; _prdInstockService = prdInstockService; } //获取注塑装箱状态 private void GetZSPackStatus(object state) { - // Console.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss}"); - // Console.WriteLine($"获取注塑装箱状态"); string[] strs = new string[1] { "TY4C-ZHUSU1" }; string sign = "agvMode"; foreach (string s in strs) { - Dictionary dic = _redisCache.HGetAll(s).Result; + Dictionary dic = _redisData.HGetAll(s).Result; foreach (KeyValuePair kv in dic) { if (!kv.Key.Contains(sign)) @@ -40,7 +40,7 @@ namespace Tnb.ProductionMgr JObject? res = JsonConvert.DeserializeObject(kv.Value); if (res != null && res["Value"] != null) { - if (int.Parse(res["Value"]!.ToString()) is not ((int)Eagvmode.无请求) or not ((int)Eagvmode.收到请求)) + if (int.Parse(res["Value"]!.ToString()) is not ((int)Eagvmode.无请求) and not ((int)Eagvmode.收到请求)) { InstockInput instockInput = new() { @@ -55,13 +55,11 @@ namespace Tnb.ProductionMgr //获取挤出装箱状态 private void GetJCPackStatus(object state) { - // Console.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss}"); - // Console.WriteLine($"获取挤出装箱状态"); string[] strs = new string[1] { "TY4C-SHUSONG-JC" }; string sign = "AGVFullCall"; foreach (string s in strs) { - Dictionary dic = _redisCache.HGetAll(s).Result; + Dictionary dic = _redisData.HGetAll(s).Result; foreach (KeyValuePair kv in dic) { if (!kv.Key.Contains(sign)) @@ -87,13 +85,17 @@ namespace Tnb.ProductionMgr //获取限位状态 private void GetLimitStatus(object state) { - // Console.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss}"); - // Console.WriteLine($"获取限位状态"); + /* + Console.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss}"); + Console.WriteLine($"获取挤出装箱状态"); + string data = _redisData.GetHash("TY4C-SHUSONG-JC", "AGVFullCall").Result; + Console.WriteLine(data);*/ + /* string[] strs = new string[1] { "TY4C-WAIBAO" }; string sign = "AGVCall"; foreach (string s in strs) { - Dictionary dic = _redisCache.HGetAll(s).Result; + Dictionary dic = _redisData.HGetAll(s).Result; foreach (KeyValuePair kv in dic) { if (!kv.Key.Contains(sign)) @@ -110,17 +112,19 @@ namespace Tnb.ProductionMgr } } } - } + }*/ } public void Dispose() { - packtimer?.Dispose(); + ZSpacktimer?.Dispose(); + JCpacktimer?.Dispose(); limittimer?.Dispose(); } public Task StartAsync(CancellationToken cancellationToken) { - // packtimer = new Timer(GetPackStatus, null, TimeSpan.Zero, TimeSpan.FromSeconds(2)); - // limittimer = new Timer(GetLimitStatus, null, TimeSpan.Zero, TimeSpan.FromSeconds(2)); + // ZSpacktimer = new Timer(GetZSPackStatus, null, TimeSpan.Zero, TimeSpan.FromSeconds(2)); + // JCpacktimer = new Timer(GetJCPackStatus, null, TimeSpan.Zero, TimeSpan.FromSeconds(2)); + // limittimer = new Timer(GetLimitStatus, null, TimeSpan.Zero, TimeSpan.FromSeconds(2)); return Task.CompletedTask; } public Task StopAsync(CancellationToken cancellationToken) diff --git a/ProductionMgr/Tnb.ProductionMgr/RedisDataService.cs b/ProductionMgr/Tnb.ProductionMgr/RedisDataService.cs index f6ce935f..6007f34f 100644 --- a/ProductionMgr/Tnb.ProductionMgr/RedisDataService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/RedisDataService.cs @@ -5,6 +5,7 @@ using JNPF.FriendlyException; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Tnb.Common.Redis; using Tnb.ProductionMgr.Interfaces; namespace Tnb.ProductionMgr @@ -16,11 +17,10 @@ namespace Tnb.ProductionMgr [Route("api/[area]/[controller]/[action]")] public class RedisDataService : IRedisDataService, IDynamicApiController, ITransient { - private readonly RedisCache _redisCache; - public RedisDataService(RedisCache redisCache) + private readonly RedisData _redisData; + public RedisDataService(RedisData redisData) { - _redisCache = redisCache; - + _redisData = redisData; } /// /// 根据机号获取重量 @@ -28,31 +28,13 @@ namespace Tnb.ProductionMgr [HttpPost] public async Task GetWeight(string device, string jihao) { - bool flag = await _redisCache.HashExist(device, jihao); + bool flag = await _redisData.HashExist(device, jihao); if (!flag) { throw Oops.Bah("没有找到" + device + "----" + jihao + "的数据"); } - - string data = await _redisCache.GetHash(device, jihao); + string data = await _redisData.GetHash(device, jihao); JObject? res = JsonConvert.DeserializeObject(data); - /* - var dic =await _redisCache.HGetAll("TY4C-JICHU"); - string a = ""; - foreach (var kvp in dic) - { - a += kvp.Key + "&" + kvp.Value + "$"; - } - - - string aa = ""; - var ss= aa.Split('$', StringSplitOptions.RemoveEmptyEntries); - foreach (var s in ss) - { - var b = s.Split('&'); - await _redisCache.HSet("TY4C-JICHU", b[0], b[1]); - }*/ - decimal result = res != null && res["Value"] != null ? decimal.Parse(res["Value"]!.ToString()) : throw Oops.Bah("数据格式错误"); return result; } diff --git a/apihost/Tnb.API.Entry/Configurations/Cache.json b/apihost/Tnb.API.Entry/Configurations/Cache.json index 8f0ff1f3..69116fb8 100644 --- a/apihost/Tnb.API.Entry/Configurations/Cache.json +++ b/apihost/Tnb.API.Entry/Configurations/Cache.json @@ -5,5 +5,11 @@ "port": 6379, "password": "05jWEoJa8v", "RedisConnectionString": "{0}:{1},password={2}, poolsize=500,ssl=false,defaultDatabase=7" + }, + "Redis": { + "ip": "localhost", + "port": 6379, + "password": "05jWEoJa8v", + "RedisConnectionString": "{0}:{1},password={2}, poolsize=500,ssl=false,defaultDatabase=0" } } \ No newline at end of file diff --git a/apihost/Tnb.API.Entry/Startup.cs b/apihost/Tnb.API.Entry/Startup.cs index d7d716d8..3dbfefd2 100644 --- a/apihost/Tnb.API.Entry/Startup.cs +++ b/apihost/Tnb.API.Entry/Startup.cs @@ -2,6 +2,7 @@ using JNPF.Common.Cache; using JNPF.Common.Core.Handlers; using JNPF.Common.Security; +using JNPF.DependencyInjection; using JNPF.SpecificationDocument; using JNPF.TaskScheduler.Interfaces.TaskScheduler; using JNPF.VisualDev; @@ -11,6 +12,7 @@ using Senparc.CO2NET.RegisterServices; using Senparc.Weixin; using Senparc.Weixin.Entities; using Senparc.Weixin.RegisterServices; +using Tnb.Common.Redis; using Tnb.ProductionMgr; using Tnb.WarehouseMgr; @@ -46,7 +48,7 @@ public class Startup : AppStartup services.AddMemoryCache(); // 使用本地缓存必须添加 services.AddConfigurableOptions(); - + services.AddSingleton( typeof(ISingleton), typeof(RedisData)); // 微信 services.AddSenparcGlobalServices(App.Configuration) // Senparc.CO2NET 全局注册 .AddSenparcWeixinServices(App.Configuration); // Senparc.Weixin 注册(如果使用Senparc.Weixin SDK则添加) diff --git a/common/Tnb.Common/Redis/RedisData.cs b/common/Tnb.Common/Redis/RedisData.cs new file mode 100644 index 00000000..3c296f5c --- /dev/null +++ b/common/Tnb.Common/Redis/RedisData.cs @@ -0,0 +1,247 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CSRedis; +using JNPF; +using JNPF.Common.Cache; +using JNPF.DependencyInjection; +using Microsoft.Extensions.Options; + +namespace Tnb.Common.Redis +{ + public class RedisData : ISingleton + { + private static CSRedisClient _instance; + public RedisData() + { + RedisOptions _RedisOptions = App.GetConfig("Redis", true); + _instance = new CSRedis.CSRedisClient(string.Format(_RedisOptions.RedisConnectionString, _RedisOptions.ip, _RedisOptions.port, _RedisOptions.password)); + } + + /// + /// 用于在 key 存在时删除 key. + /// + /// 键. + public long Del(params string[] key) + { + return _instance.Del(key); + } + + /// + /// 用于在 key 存在时删除 key. + /// + /// 键. + public Task DelAsync(params string[] key) + { + return _instance.DelAsync(key); + } + + /// + /// 用于在 key 模板存在时删除. + /// + /// key模板. + public async Task DelByPatternAsync(string pattern) + { + if (string.IsNullOrEmpty(pattern)) + return default; + + // pattern = Regex.Replace(pattern, @"\{.*\}", "*"); + string[]? keys = await _instance.KeysAsync(pattern); + if (keys?.Length > 0) + { + return await _instance.DelAsync(keys); + } + + return default; + } + + /// + /// 检查给定 key 是否存在. + /// + /// 键. + public bool Exists(string key) + { + return _instance.Exists(key); + } + + /// + /// 检查给定 key 是否存在. + /// + /// 键. + public Task ExistsAsync(string key) + { + return _instance.ExistsAsync(key); + } + + /// + /// 获取指定 key 的增量值. + /// + /// 键. + /// 增量. + /// + public long Incrby(string key, long incrBy) + { + return _instance.IncrBy(key, incrBy); + } + + /// + /// 获取指定 key 的增量值. + /// + /// 键. + /// 增量. + /// + public Task IncrbyAsync(string key, long incrBy) + { + return _instance.IncrByAsync(key, incrBy); + } + + /// + /// 获取指定 key 的值. + /// + /// 键. + public string Get(string key) + { + return _instance.Get(key); + } + + /// + /// 获取指定 key 的值. + /// + /// byte[] 或其他类型. + /// 键. + public T Get(string key) + { + return _instance.Get(key); + } + + /// + /// 获取指定 key 的值. + /// + /// 键. + /// + public Task GetAsync(string key) + { + return _instance.GetAsync(key); + } + + /// + /// 获取指定 key 的值. + /// + /// byte[] 或其他类型. + /// 键. + public Task GetAsync(string key) + { + return _instance.GetAsync(key); + } + + /// + /// 设置指定 key 的值,所有写入参数object都支持string | byte[] | 数值 | 对象. + /// + /// 键. + /// 值. + public bool Set(string key, object value) + { + return _instance.Set(key, value); + } + + /// + /// 设置指定 key 的值,所有写入参数object都支持string | byte[] | 数值 | 对象. + /// + /// 键. + /// 值. + /// 有效期. + public bool Set(string key, object value, TimeSpan expire) + { + return _instance.Set(key, value, expire); + } + + /// + /// 设置指定 key 的值,所有写入参数object都支持string | byte[] | 数值 | 对象. + /// + /// 键. + /// 值. + public Task SetAsync(string key, object value) + { + return _instance.SetAsync(key, value); + } + + /// + /// 保存. + /// + /// 键. + /// 值. + /// 过期时间. + /// + public Task SetAsync(string key, object value, TimeSpan expire) + { + return _instance.SetAsync(key, value, expire); + } + + /// + /// 只有在 key 不存在时设置 key 的值. + /// + /// 键. + /// 值. + /// 有效期. + public bool SetNx(string key, object value, TimeSpan expire) + { + if (_instance.SetNx(key, value)) + { + _instance.Set(key, value, expire); + return true; + } + else + { + return false; + } + } + + /// + /// 只有在 key 不存在时设置 key 的值. + /// + /// 键. + /// 值. + public bool SetNx(string key, object value) + { + return _instance.SetNx(key, value); + } + + /// + /// 获取所有key. + /// + /// + public List GetAllKeys() + { + return _instance.Keys("*").ToList(); + } + + /// + /// 获取缓存过期时间. + /// + /// 键值. + /// + public DateTime GetCacheOutTime(string key) + { + long second = _instance.PTtl(key); + return DateTime.Now.AddMilliseconds(second); + } + public Task GetHash(string key, string field) + { + return _instance.HGetAsync(key, field); + } + public Task HashExist(string key, string field) + { + return _instance.HExistsAsync(key, field); + } + public Task> HGetAll(string key) + { + return _instance.HGetAllAsync(key); + } + public Task HSet(string key, string field, string value) + { + return _instance.HSetAsync(key, field, value); + } + } +} \ No newline at end of file diff --git a/common/Tnb.Common/Redis/RedisOptions.cs b/common/Tnb.Common/Redis/RedisOptions.cs new file mode 100644 index 00000000..1e718b4a --- /dev/null +++ b/common/Tnb.Common/Redis/RedisOptions.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Cache; +using JNPF.ConfigurableOptions; + +namespace Tnb.Common.Redis +{ + public class RedisOptions : IConfigurableOptions + { + + /// + /// Redis配置. + /// + public string RedisConnectionString { get; set; } + + /// + /// 服务器地址. + /// + public string ip { get; set; } + + /// + /// 端口. + /// + public int port { get; set; } + + /// + /// 密码. + /// + public string password { get; set; } + } +} \ No newline at end of file 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 10/11] =?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 }) From f16f89e86ae47c4470b49067d50d8822c81c589e Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Tue, 7 Nov 2023 17:28:01 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=B3=A8=E5=A1=91?= =?UTF-8?q?=E6=BB=A1=E7=AE=B1=E5=88=B0=E4=BD=8D=E5=90=8E=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E6=8E=A5=E5=8F=A3=20=E9=A2=86=E6=96=99?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=B7=A5=E4=BD=8D=E5=88=B7=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/CodeTemplateConst.cs | 5 +++++ .../Dto/PrdManage/InstockInput.cs | 1 + ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs | 2 ++ ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs | 12 +++++++++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs index 171f491c..eedf0c86 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs @@ -29,6 +29,11 @@ namespace Tnb.BasicData /// 生产齐套领料 /// public const string PRDKITTINGOUTSTOCK_CODE = "PrdKittingOutStocK"; + + /// + /// 生产领料 + /// + public const string PRDOUTSTOCK_CODE = "PrdOutstock"; /// /// 设备维修单 diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/InstockInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/InstockInput.cs index c7413345..66479a8a 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/InstockInput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/InstockInput.cs @@ -3,6 +3,7 @@ namespace Tnb.ProductionMgr.Entities.Dto public class InstockInput { public string equip_code { get; set; } + public string label_code { get; set; } public string as_location_code { get; set; } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs index 054301b6..08625689 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs @@ -530,6 +530,7 @@ namespace Tnb.ProductionMgr var queryable1 = db.Queryable() .LeftJoin((a, b) => a.create_id == b.Id) + .Where((a,b)=>a.workstation_id==input.stationId) .Select((a, b) => new FeedingRecordListOutput() { id = a.id, @@ -543,6 +544,7 @@ namespace Tnb.ProductionMgr var queryable2 = db.Queryable() .LeftJoin((a, b) => a.create_id == b.Id) + .Where((a,b)=>a.workstation==input.stationId) .Select((a, b) => new FeedingRecordListOutput() { id = a.id, diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs index 44594713..80cc8a35 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs @@ -262,15 +262,25 @@ namespace Tnb.ProductionMgr public async Task InstockTypeOne(InstockInput inut) { string equip_code = inut.equip_code; + string label_code = inut.label_code; string as_location_code = inut.as_location_code; string warehouse_id = "2"; if (!string.IsNullOrEmpty(equip_code)) { throw Oops.Bah("请传机台号"); } + + if (!string.IsNullOrEmpty(label_code)) + { + throw Oops.Bah("请传标签号"); + } ISqlSugarClient db = _repository.AsSugarClient(); - EqpEquipment equipment = await db.Queryable().Where(x => x.code == equip_code).FirstAsync(); + EqpEquipment equipment = await db.Queryable() + .LeftJoin((x,y)=>x.id==y.equip_id) + .Where((x,y) => y.equip_code==equip_code && y.label_name==label_code && y.label_point=="提报装箱称重点位") + .Select((x,y)=>x) + .FirstAsync(); if (equipment == null) { throw Oops.Bah("未找到机台");