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] =?UTF-8?q?=E7=89=A9=E6=96=99=E5=87=BA=E5=BA=93=E7=94=B3?= =?UTF-8?q?=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}")