From f043f3fafee48914223ea7969a309dd0df7611c1 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Fri, 2 Aug 2024 17:50:27 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=99=E4=BB=93=E5=8E=9F=E6=96=99?= =?UTF-8?q?=E6=9D=A1=E7=A0=81=20=E6=9B=B4=E6=96=B0=20=E5=88=B7=E6=96=B0=20?= =?UTF-8?q?=E5=90=B8=E6=96=99=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.EquipMgr/EquMaintainRecordService.cs | 12 +- .../ToolMoldMaintainRecordService.cs | 12 +- .../Entity/PrdRawMaterialBarcodeRecord.cs | 92 +++++ .../PrdRawMaterialBarcodeService.cs | 316 +++++++++++++++++- .../Tnb.WarehouseMgr/WmsInStockService.cs | 4 +- .../Tnb.WarehouseMgr/WmsPurchaseService.cs | 13 + 6 files changed, 423 insertions(+), 26 deletions(-) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdRawMaterialBarcodeRecord.cs diff --git a/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs b/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs index 46ad3c4c..04f49383 100644 --- a/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs +++ b/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs @@ -100,16 +100,16 @@ namespace Tnb.EquipMgr .Mapper(a => { a.status = a.status == "1" ? "待执行" : a.status == "2" ? "待复核" : "已完成"; - a.create_time = a.date_create_time == null ? "" : a.date_create_time.Value.ToString(DbTimeFormat.SS); - a.execute_time = a.date_execute_time == null ? "" : a.date_execute_time.Value.ToString(DbTimeFormat.SS); - a.repeat_time = a.date_repeat_time == null ? "" : a.date_repeat_time.Value.ToString(DbTimeFormat.SS); - a.last_execute_time = a.date_last_execute_time == null ? "" : a.date_last_execute_time.Value.ToString(DbTimeFormat.SS); + a.create_time = a.date_create_time == null ? "" : a.date_create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"); + a.execute_time = a.date_execute_time == null ? "" : a.date_execute_time.Value.ToString("yyyy-MM-dd HH:mm:ss"); + a.repeat_time = a.date_repeat_time == null ? "" : a.date_repeat_time.Value.ToString("yyyy-MM-dd HH:mm:ss"); + a.last_execute_time = a.date_last_execute_time == null ? "" : a.date_last_execute_time.Value.ToString("yyyy-MM-dd HH:mm:ss"); }) .ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50); var EqpMaintainRecordHs = await db.Queryable().Where(p => list.list.Select(p => p.equip_id_id).ToList().Contains(p.equip_id)).ToListAsync(); foreach (var data in list.list) { - data.last_execute_time = EqpMaintainRecordHs.Where(x => data.equip_id_id == x.equip_id && x.execute_time != null).Any() ? EqpMaintainRecordHs.Where(x => data.equip_id_id == x.equip_id && x.execute_time != null).OrderByDescending(x => x.execute_time).FirstOrDefault()!.execute_time!.Value.ToString(DbTimeFormat.SS) : ""; + data.last_execute_time = EqpMaintainRecordHs.Where(x => data.equip_id_id == x.equip_id && x.execute_time != null).Any() ? EqpMaintainRecordHs.Where(x => data.equip_id_id == x.equip_id && x.execute_time != null).OrderByDescending(x => x.execute_time).FirstOrDefault()!.execute_time!.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""; } return PageResult.SqlSugarPageResult(list); } @@ -291,7 +291,7 @@ namespace Tnb.EquipMgr a.equip_id, equip_code = b.code, equip_name = b.name, - create_time = a.create_time == null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS), + create_time = a.create_time == null ? "" : a.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"), a.result_remark, a.result, a.status, diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRecordService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRecordService.cs index 9b5ca597..53e65b26 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRecordService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRecordService.cs @@ -100,16 +100,16 @@ namespace Tnb.EquipMgr .Mapper(a => { a.status = a.status == "1" ? "待执行" : a.status == "2" ? "待复核" : "已完成"; - a.create_time = a.date_create_time == null ? "" : a.date_create_time.Value.ToString(DbTimeFormat.SS); - a.execute_time = a.date_execute_time == null ? "" : a.date_execute_time.Value.ToString(DbTimeFormat.SS); - a.repeat_time = a.date_repeat_time == null ? "" : a.date_repeat_time.Value.ToString(DbTimeFormat.SS); - a.last_execute_time = a.date_last_execute_time == null ? "" : a.date_last_execute_time.Value.ToString(DbTimeFormat.SS); + a.create_time = a.date_create_time == null ? "" : a.date_create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"); + a.execute_time = a.date_execute_time == null ? "" : a.date_execute_time.Value.ToString("yyyy-MM-dd HH:mm:ss"); + a.repeat_time = a.date_repeat_time == null ? "" : a.date_repeat_time.Value.ToString("yyyy-MM-dd HH:mm:ss"); + a.last_execute_time = a.date_last_execute_time == null ? "" : a.date_last_execute_time.Value.ToString("yyyy-MM-dd HH:mm:ss"); }) .ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50); var ToolMoldMaintainRecordHs = await db.Queryable().Where(p => list.list.Select(p => p.mold_id_id).ToList().Contains(p.mold_id)).ToListAsync(); foreach (var data in list.list) { - data.last_execute_time = ToolMoldMaintainRecordHs.Where(x => data.mold_id_id == x.mold_id && x.execute_time != null).Any() ? ToolMoldMaintainRecordHs.Where(x => data.mold_id_id == x.mold_id && x.execute_time != null).OrderByDescending(x => x.execute_time).FirstOrDefault()!.execute_time!.Value.ToString(DbTimeFormat.SS) : ""; + data.last_execute_time = ToolMoldMaintainRecordHs.Where(x => data.mold_id_id == x.mold_id && x.execute_time != null).Any() ? ToolMoldMaintainRecordHs.Where(x => data.mold_id_id == x.mold_id && x.execute_time != null).OrderByDescending(x => x.execute_time).FirstOrDefault()!.execute_time!.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""; } return PageResult.SqlSugarPageResult(list); } @@ -293,7 +293,7 @@ namespace Tnb.EquipMgr a.mold_id, mold_code = b.mold_code, mold_name = b.mold_name, - create_time = a.create_time == null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS), + create_time = a.create_time == null ? "" : a.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"), a.result_remark, a.result, a.status, diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdRawMaterialBarcodeRecord.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdRawMaterialBarcodeRecord.cs new file mode 100644 index 00000000..07e37510 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdRawMaterialBarcodeRecord.cs @@ -0,0 +1,92 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entities; + +/// +/// 料仓原料条码记录表 +/// +[SugarTable("prd_raw_material_barcode_record")] +public partial class PrdRawMaterialBarcodeRecord : BaseEntity +{ + public PrdRawMaterialBarcodeRecord() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 单据编号 + /// + public string bill_code { get; set; } = string.Empty; + + /// + /// 料仓id/机台id + /// + public string equip_id { get; set; } = string.Empty; + + /// + /// 物料id + /// + public string? material_id { get; set; } + + /// + /// 1 料仓原料条码 2 机台原料 + /// + public string type { get; set; } + + /// + /// 是否更新 + /// + public int is_update { get; set; } + + /// + /// 吸料完成 + /// + public int absorb_material_finish { get; set; } + + /// + /// 管道状态 + /// + public int piping_status { get; set; } + + /// + /// 开始时间 + /// + public DateTime start_time { get; set; } = DateTime.Now; + + /// + /// 结束时间 + /// + public DateTime end_time { get; set; } = DateTime.Now; + + /// + /// 备注 + /// + public string? remark { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// 所属组织 + /// + public string? org_id { get; set; } + +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdRawMaterialBarcodeService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdRawMaterialBarcodeService.cs index 3dd1b373..3aebee3d 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdRawMaterialBarcodeService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdRawMaterialBarcodeService.cs @@ -1,10 +1,30 @@ +using JNPF; using JNPF.Common.Core.Manager; +using JNPF.Common.Dtos.VisualDev; +using JNPF.Common.Extension; +using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; +using JNPF.FriendlyException; +using JNPF.Logging; using JNPF.Systems.Interfaces.System; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys; +using JNPF.VisualDev.Interfaces; +using Mapster; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using Senparc.CO2NET.HttpUtility; using SqlSugar; +using Tnb.BasicData; +using Tnb.BasicData.Entities; +using Tnb.Common.Extension; +using Tnb.EquipMgr.Entities; using Tnb.ProductionMgr.Entities; +using Tnb.WarehouseMgr.Entities.Configs; +using Tnb.Common.Utils; +using Tnb.WarehouseMgr.Entities.Consts; +using HttpClientHelper = Tnb.Common.Utils.HttpClientHelper; namespace Tnb.ProductionMgr { @@ -13,31 +33,303 @@ namespace Tnb.ProductionMgr /// [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)] [Route("api/[area]/[controller]/[action]")] - public class PrdRawMaterialBarcodeService: IDynamicApiController, ITransient + [OverideVisualDev(ModuleId)] + public class PrdRawMaterialBarcodeService: IOverideVisualDevService,IDynamicApiController, ITransient { + private const string ModuleId = "35925395676181"; private readonly ISqlSugarClient _db; private readonly IDictionaryDataService _dictionaryDataService; private readonly IUserManager _userManager; private static Dictionary> _dicWorkLine = new(); + private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build(); + private readonly IBillRullService _billRuleService; + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + private readonly IVisualDevService _visualDevService; + private readonly IRunService _runService; + public PrdRawMaterialBarcodeService(ISqlSugarRepository repository, IUserManager userManager, + IBillRullService billRuleService, + IVisualDevService visualDevService, + IRunService runService, IDictionaryDataService dictionaryDataService) { _db = repository.AsSugarClient(); _userManager = userManager; + _billRuleService = billRuleService; _dictionaryDataService = dictionaryDataService; + _visualDevService = visualDevService; + _runService = runService; + OverideFuncs.UpdateAsync = Update; } - // /// - // /// 上模校验 - // /// - // /// - // [HttpPost] - // public async Task CheckMold(string id) - // { - // // PrdRawMaterialBarcode prdRawMaterialBarcode = await _db.Queryable().SingleAsync(x => x.id == input.mo_task_id); - // // BasQrcode basQrcode = await _db.Queryable().Where(x => x.source_name == "TOOL_MOLDS" && x.code == input.mold_qrcode).FirstAsync(); - // // return prdMoTask != null && basQrcode != null ? prdMoTask.mold_id == basQrcode.source_id : (dynamic)false; - // } + private async Task Update(string id, VisualDevModelDataUpInput visualDevModelDataUpInput) + { + PrdRawMaterialBarcode prdRawMaterialBarcode = await _db.Queryable().SingleAsync(x=>x.id==id); + string newMaterialId = visualDevModelDataUpInput.data.ContainsKey("material_id") ? visualDevModelDataUpInput.data["material_id"].ToString() : ""; + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + await _runService.Update(id, templateEntity, visualDevModelDataUpInput); + if (!string.IsNullOrEmpty(newMaterialId) && prdRawMaterialBarcode.material_id != newMaterialId) + { + string billCode = await _billRuleService.GetBillNumber(CodeTemplateConst.PRDRAWMATERIALBARCODE_CODE); + await _db.Updateable() + .SetColumns(x => x.bill_code == billCode) + .Where(x => x.id == id) + .ExecuteCommandAsync(); + } + return await Task.FromResult(true); + } + + /// + /// 更新 + /// + /// + [HttpPost] + public async Task UpdateBarcode(List ids) + { + try + { + await _db.Ado.BeginTranAsync(); + + Dictionary dicCommand = new(StringComparer.OrdinalIgnoreCase) + { + ["DevName"] = "注塑主控柜", + ["token"] = _eleCtlCfg.token, + ["TagName"] = "开工1", + ["Value"] = "true", + }; + string responseresult = + await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand, false); + Log.Information($"注塑主控柜开工1开启返回结果:{responseresult}"); + + Dictionary dicCommand2 = new(StringComparer.OrdinalIgnoreCase) + { + ["DevName"] = "注塑主控柜", + ["token"] = _eleCtlCfg.token, + ["TagName"] = "开工2", + ["Value"] = "true", + }; + + string responseresult2 = + await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2, false); + Log.Information($"注塑主控柜开工2开启返回结果:{responseresult2}"); + + List prdRawMaterialBarcodeList = await _db.Queryable() + .Where(x => ids.Contains(x.id)).ToListAsync(); + foreach (var item in prdRawMaterialBarcodeList) + { + if (string.IsNullOrEmpty(item.material_id)) + { + throw Oops.Bah($"{item.bill_code}未设置原材料"); + } + + EqpEquipment eqpEquipment = + await _db.Queryable().SingleAsync(x => x.id == item.equip_id); + EqpDaq eqpDaq = await _db.Queryable() + .Where(x => x.equip_id == item.equip_id && x.label_name.Contains("原料条码")).FirstAsync(); + + if (eqpDaq == null) + { + throw Oops.Bah($"{eqpEquipment.name}未设置原料条码数据采集项"); + } + + Dictionary dicCommand3 = new(StringComparer.OrdinalIgnoreCase) + { + ["DevName"] = eqpDaq.equip_code, + ["token"] = _eleCtlCfg.token, + ["TagName"] = eqpDaq.label_name, + ["Value"] = item.material_id, + }; + Log.Information($"注塑主控柜{eqpDaq.label_name}更新参数:{JsonConvert.SerializeObject(dicCommand3)}"); + string responseresult3 = + await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand3, false); + Log.Information($"注塑主控柜{eqpDaq.label_name}更新返回结果:{responseresult3}"); + + await _db.Updateable() + .SetColumns(x => x.start_time == DateTime.Now) + .SetColumns(x => x.is_update == 1) + .Where(x => x.id == item.id) + .ExecuteCommandAsync(); + } + + await _db.Ado.CommitTranAsync(); + } + catch (Exception e) + { + await _db.Ado.RollbackTranAsync(); + throw Oops.Bah(e.Message); + } + finally + { + Dictionary dicCommand = new(StringComparer.OrdinalIgnoreCase) + { + ["DevName"] = "注塑主控柜", + ["token"] = _eleCtlCfg.token, + ["TagName"] = "开工1", + ["Value"] = "false", + }; + string responseresult = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand, false); + Log.Information($"注塑主控柜开工1关闭返回结果:{responseresult}"); + + Dictionary dicCommand2 = new(StringComparer.OrdinalIgnoreCase) + { + ["DevName"] = "注塑主控柜", + ["token"] = _eleCtlCfg.token, + ["TagName"] = "开工2", + ["Value"] = "false", + }; + string responseresult2 = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2, false); + Log.Information($"注塑主控柜开工2关闭返回结果:{responseresult2}"); + } + + return "成功"; + } + + /// + /// 刷新 同步料仓 + /// + /// + [HttpPost] + public async Task AsyncMaterialWarhouse() + { + List equipIds = await _db.Queryable().Where(x=>x.type=="1").Select(x=>x.equip_id).ToListAsync(); + List equipments = await _db.Queryable().Where(x=>!equipIds.Contains(x.id) && x.code.StartsWith("abc")).ToListAsync(); + + List insertList = new List(); + if (equipments != null && !equipments.IsEmpty()) + { + foreach (var item in equipments) + { + insertList.Add(new PrdRawMaterialBarcode() + { + id = SnowflakeIdHelper.NextId(), + bill_code = await _billRuleService.GetBillNumber(CodeTemplateConst.PRDRAWMATERIALBARCODE_CODE), + equip_id = item.id, + type = "1", + create_id = _userManager.UserId, + create_time = DateTime.Now, + org_id = WmsWareHouseConst.AdministratorOrgId, + }); + } + } + + if (!insertList.IsEmpty()) + { + await _db.Insertable(insertList).ExecuteCommandAsync(); + } + return "成功"; + } + + /// + /// 吸料完成 + /// + /// + [HttpPost] + public async Task MaterialSuctionCompleted(List ids) + { + try + { + await _db.Ado.BeginTranAsync(); + + Dictionary dicCommand = new(StringComparer.OrdinalIgnoreCase) + { + ["DevName"] = "注塑主控柜", + ["token"] = _eleCtlCfg.token, + ["TagName"] = "开工1", + ["Value"] = "true", + }; + string responseresult = + await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand, false); + Log.Information($"注塑主控柜开工1开启返回结果:{responseresult}"); + + Dictionary dicCommand2 = new(StringComparer.OrdinalIgnoreCase) + { + ["DevName"] = "注塑主控柜", + ["token"] = _eleCtlCfg.token, + ["TagName"] = "开工2", + ["Value"] = "true", + }; + + string responseresult2 = + await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2, false); + Log.Information($"注塑主控柜开工2开启返回结果:{responseresult2}"); + + List prdRawMaterialBarcodeList = await _db.Queryable() + .Where(x => ids.Contains(x.id)).ToListAsync(); + List insertList = new List(); + foreach (var item in prdRawMaterialBarcodeList) + { + EqpEquipment eqpEquipment = await _db.Queryable().SingleAsync(x => x.id == item.equip_id); + EqpDaq eqpDaq = await _db.Queryable().Where(x => x.equip_id == item.equip_id && x.label_name.Contains("原料条码")).FirstAsync(); + + if (eqpDaq == null) + { + throw Oops.Bah($"{eqpEquipment.name}未设置原料条码数据采集项"); + } + + Dictionary dicCommand3 = new(StringComparer.OrdinalIgnoreCase) + { + ["DevName"] = eqpDaq.equip_code, + ["token"] = _eleCtlCfg.token, + ["TagName"] = eqpDaq.label_name, + ["Value"] = "", + }; + Log.Information($"注塑主控柜{eqpDaq.label_name}吸料完成参数:{JsonConvert.SerializeObject(dicCommand3)}"); + string responseresult3 = + await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand3, false); + Log.Information($"注塑主控柜{eqpDaq.label_name}吸料完成返回结果:{responseresult3}"); + + PrdRawMaterialBarcodeRecord prdRawMaterialBarcodeRecord = item.Adapt(); + prdRawMaterialBarcodeRecord.id = SnowflakeIdHelper.NextId(); + prdRawMaterialBarcodeRecord.end_time = DateTime.Now; + insertList.Add(prdRawMaterialBarcodeRecord); + + await _db.Updateable() + .SetColumns(x => x.bill_code == "") + .SetColumns(x => x.start_time == null) + .SetColumns(x => x.end_time == null) + .SetColumns(x => x.is_update == 0) + .SetColumns(x => x.material_id == "") + .Where(x => x.id == item.id) + .ExecuteCommandAsync(); + + } + + if (!insertList.IsEmpty()) + { + await _db.Insertable(insertList).ExecuteCommandAsync(); + } + + await _db.Ado.CommitTranAsync(); + } + catch (Exception e) + { + await _db.Ado.RollbackTranAsync(); + throw Oops.Bah(e.Message); + } + finally + { + Dictionary dicCommand = new(StringComparer.OrdinalIgnoreCase) + { + ["DevName"] = "注塑主控柜", + ["token"] = _eleCtlCfg.token, + ["TagName"] = "开工1", + ["Value"] = "false", + }; + string responseresult = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand, false); + Log.Information($"注塑主控柜开工1关闭返回结果:{responseresult}"); + + Dictionary dicCommand2 = new(StringComparer.OrdinalIgnoreCase) + { + ["DevName"] = "注塑主控柜", + ["token"] = _eleCtlCfg.token, + ["TagName"] = "开工2", + ["Value"] = "false", + }; + string responseresult2 = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2, false); + Log.Information($"注塑主控柜开工2关闭返回结果:{responseresult2}"); + } + return "成功"; + } } } \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs index 778fa8a5..28526034 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs @@ -379,8 +379,8 @@ namespace Tnb.WarehouseMgr erpRequestData.Add("pk_org", erpOrg.pk_org); erpRequestData.Add("pk_org_v", erpOrg.pk_org_v); erpRequestData.Add("pk_group", erpOrg.pk_group); - erpRequestData.Add("vbillcode", null); - erpRequestData.Add("vtrantypecode", null); + erpRequestData.Add("vbillcode", instock.bill_code); + erpRequestData.Add("vtrantypecode", tranType?.EnCode ?? ""); List> erpRequestDataDetails = new List>(); foreach (WmsInstockD item in allInstockDetails) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs index 1f304d91..66ef258b 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs @@ -123,6 +123,19 @@ namespace Tnb.WarehouseMgr await _db.Insertable(instockDs).ExecuteCommandAsync(); var purchase = await _db.Queryable().FirstAsync(it => it.id == purchaseDs.First().bill_id); + if (string.IsNullOrEmpty(purchase.supplier_id)) + { + BasSupplier basSupplier = await _db.Queryable().Where(x=>x.supplier_code==purchase.supplier_code).FirstAsync(); + if (basSupplier != null) + { + await _db.Updateable() + .SetColumns(x => x.supplier_id == basSupplier.id) + .Where(x => x.id == purchase.id) + .ExecuteCommandAsync(); + + purchase.supplier_id = basSupplier.id; + } + } List dList = await _db.Queryable().Where(x=>x.bill_id==purchaseDs.First().bill_id).OrderBy(x=>x.id).ToListAsync(); List materialIds = purchaseDs.Select(x=>x.material_id).Distinct().ToList(); List unitCodes = purchaseDs.Select(x => x.unit_id).Distinct().ToList(); From 982f3ccad7ab4bc362f2d0b376c708bd67483bad Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Fri, 2 Aug 2024 17:50:42 +0800 Subject: [PATCH 2/2] 1 --- BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs index 59b761da..84749afb 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs @@ -50,6 +50,10 @@ namespace Tnb.BasicData /// public const string PROMO_CODE = "ProMoCode"; + /// + /// 料仓原料条码单 + /// + public const string PRDRAWMATERIALBARCODE_CODE = "PrdRawMaterialBarcode"; } } \ No newline at end of file