diff --git a/BasicData/Tnb.BasicData.Entities/Dto/ThirdResult.cs b/BasicData/Tnb.BasicData.Entities/Dto/ThirdResult.cs index ba0ee32c..e41aa57e 100644 --- a/BasicData/Tnb.BasicData.Entities/Dto/ThirdResult.cs +++ b/BasicData/Tnb.BasicData.Entities/Dto/ThirdResult.cs @@ -4,6 +4,9 @@ namespace Tnb.BasicData.Entities { public int Code { get; set; } public string msgResult { get; set; } + + public object msg { get; set; } + } // public enum ThirdResultCode diff --git a/BasicData/Tnb.BasicData/ThirdApiRecordService.cs b/BasicData/Tnb.BasicData/ThirdApiRecordService.cs index f9f0a5f7..f8ab798f 100644 --- a/BasicData/Tnb.BasicData/ThirdApiRecordService.cs +++ b/BasicData/Tnb.BasicData/ThirdApiRecordService.cs @@ -4,11 +4,16 @@ using JNPF.Common.Extension; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.Extras.CollectiveOAuth.Utils; +using JNPF.FriendlyException; +using JNPF.Logging; using JNPF.Systems.Interfaces.Permission; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using SqlSugar; using Tnb.BasicData.Entities; +using Tnb.WarehouseMgr.Entities; namespace Tnb.BasicData { @@ -68,30 +73,145 @@ namespace Tnb.BasicData thirdResult.Code = 500; thirdResult.msgResult = response; } - if (thirdResult.Code == 200) + + try { - await db.Updateable() - .SetColumns(x => x.response_data == response) - .SetColumns(x => x.response_code == thirdResult.Code) - .SetColumns(x => x.last_send_time == now) - .SetColumns(x => x.response_time == elapsedMilliseconds) - .SetColumns(x => x.send_type == "手动") - .SetColumns(x => x.status == 1) - .Where(x=>x.id==record.id) - .ExecuteCommandAsync(); + await db.Ado.BeginTranAsync(); + if (thirdResult.Code == 200) + { + await db.Updateable() + .SetColumns(x => x.response_data == response) + .SetColumns(x => x.response_code == thirdResult.Code) + .SetColumns(x => x.last_send_time == now) + .SetColumns(x => x.response_time == elapsedMilliseconds) + .SetColumns(x => x.send_type == "手动") + .SetColumns(x => x.status == 1) + .Where(x=>x.id==record.id) + .ExecuteCommandAsync(); + } + else + { + await db.Updateable() + .SetColumns(x => x.response_data == response) + .SetColumns(x => x.response_code == thirdResult.Code) + .SetColumns(x => x.last_send_time == now) + .SetColumns(x => x.response_time == elapsedMilliseconds) + .Where(x=>x.id==record.id) + .ExecuteCommandAsync(); + } + + if (thirdResult.Code == 200 && record.third_name == "BIP" && record.name == "采购到货") + { + Dictionary requestData = JsonConvert.DeserializeObject>(record.request_data); + //((JObject)requestData[0]["dtls"]).SelectTokens("csourcebid") + + string billCode = requestData.ContainsKey("vbillcode") ? requestData["vbillcode"].ToString() : ""; + if (string.IsNullOrEmpty(billCode)) + { + Log.Error($"请求记录id{record.id}采购到货单号为空"); + } + var requestDtos = ((JArray)requestData["dtls"]).Select(x => new ErpPurchaseDto() + { + csourcebid = x["csourcebid"]?.ToString(), + mes_detail_id = x["mes_detail_id"]?.ToString(), + }).ToList(); + + JObject data = (JObject)thirdResult.msg; + JToken children = data.SelectToken("children")[0]; + var responsetDtos = children.Select(x => new ErpPurchaseDto() + { + pk_arriveorder = x["valueIndex"]["pk_arriveorder"].ToString(), + pk_arriveorder_b = x["valueIndex"]["pk_arriveorder_b"].ToString(), + csourcebid = x["valueIndex"]["csourcebid"].ToString() + }).ToList(); + + string pk_arriveorder = responsetDtos[0]?.pk_arriveorder ?? ""; + int updateDRow = 0; + bool flag = !string.IsNullOrEmpty(pk_arriveorder); + foreach (var item in requestDtos) + { + string pk_arriveorder_b = responsetDtos.Find(x => x.csourcebid == item.csourcebid)?.pk_arriveorder_b; + if (string.IsNullOrEmpty(pk_arriveorder_b)) + { + flag = true; + break; + } + updateDRow += await db.Updateable() + .SetColumns(x => x.erp_arriveorder_b_pk == pk_arriveorder_b) + .Where(x => x.id == item.mes_detail_id) + .ExecuteCommandAsync(); + } + + int updateRow = await db.Updateable() + .SetColumns(x => x.erp_arriveorder_pk == pk_arriveorder) + .Where(x => x.bill_code == billCode) + .ExecuteCommandAsync(); + + if (flag || updateRow <= 0 || updateDRow <= 0) + { + Log.Error($"更新失败,requestDtos:{JsonConvert.SerializeObject(requestDtos)},responsetDtos:{JsonConvert.SerializeObject(responsetDtos)}"); + } + } + + await db.Ado.CommitTranAsync(); } - else + catch (Exception e) { - await db.Updateable() - .SetColumns(x => x.response_data == response) - .SetColumns(x => x.response_code == thirdResult.Code) - .SetColumns(x => x.last_send_time == now) - .SetColumns(x => x.response_time == elapsedMilliseconds) - .Where(x=>x.id==record.id) - .ExecuteCommandAsync(); + Log.Error(e.Message,e); + await db.Ado.RollbackTranAsync(); } + return thirdResult.Code == 200 ? "成功" : "失败"; } + + [HttpGet] + [AllowAnonymous] + public async Task test() + { + var db = _repository.AsSugarClient(); + string response = + "{\"Code\":200,\"msg\":{\"children\":[[{\"valueIndex\":{\"cfirstbid\":\"1001A1100000000KLLLV\",\"pk_group\":\"0001H11000000000257J\",\"pk_reqstoorg\":\"0001A11000000007GGN9\",\"dproducedate\":{\"utcTime\":1722355200000},\"bfixedrate\":{\"value\":true},\"ccurrencyid\":\"1002Z0100000000001K1\",\"nplanastnum\":{\"power\":0,\"si\":1,\"v\":[0,10,0,0,0],\"trimZero\":false},\"nprice\":{\"power\":-3,\"si\":1,\"v\":[5690000000000000,7,0,0,0],\"trimZero\":false},\"pk_org\":\"0001A11000000007GGN9\",\"norigtaxprice\":{\"power\":-1,\"si\":1,\"v\":[7000000000000000,8,0,0,0],\"trimZero\":false},\"pk_material\":\"1001A11000000000WHK1\",\"csourcetypecode\":\"21\",\"ctaxcountryid\":\"0001Z010000000079UJJ\",\"pk_arriveorder\":\"1001B1100000000KM4ZE\",\"pk_order\":\"1001A1100000000KLLLV\",\"pk_psfinanceorg_v\":\"0001A11000000007GGN8\",\"bbackreforder\":{\"value\":false},\"castunitid\":\"0001Z0100000000000XI\",\"pk_apfinanceorg_v\":\"0001A11000000007GGN8\",\"cunitid\":\"0001Z0100000000000XI\",\"fproductclass\":1,\"cfirsttypecode\":\"21\",\"pk_reqstoorg_v\":\"0001A11000000007GGN8\",\"pk_srcmaterial\":\"1001A11000000000WHK1\",\"ntaxmny\":{\"power\":-8,\"si\":1,\"v\":[5000000000000000,43,0,0,0],\"trimZero\":false},\"pk_order_b\":\"1001A1100000000KLLLX\",\"ntaxrate\":{\"power\":0,\"si\":1,\"v\":[0,13,0,0,0],\"trimZero\":false},\"fbuysellflag\":1,\"pk_org_v\":\"0001A11000000007GGN8\",\"ntaxprice\":{\"power\":-1,\"si\":1,\"v\":[7000000000000000,8,0,0,0],\"trimZero\":false},\"pk_psfinanceorg\":\"0001A11000000007GGN8\",\"crececountryid\":\"0001Z010000000079UJJ\",\"norigtaxmny\":{\"power\":-8,\"si\":1,\"v\":[5000000000000000,43,0,0,0],\"trimZero\":false},\"naccumchecknum\":{\"power\":-8,\"si\":1,\"v\":[0,0,0,0,0],\"trimZero\":false},\"nastnum\":{\"power\":-1,\"si\":1,\"v\":[0,5,0,0,0],\"trimZero\":false},\"pk_arriveorder_b\":\"1001B1100000000KM4ZF\",\"ntax\":{\"power\":-8,\"si\":1,\"v\":[6550000000000000,5,0,0,0],\"trimZero\":false},\"pk_receivestore\":\"1001A1100000000JXT9L\",\"dplanreceivedate\":{\"utcTime\":1722355200000},\"dbilldate\":{\"utcTime\":1722355200000},\"csourcebid\":\"1001A1100000000KLLLX\",\"csourceid\":\"1001A1100000000KLLLV\",\"corigcurrencyid\":\"1002Z0100000000001K1\",\"nplannum\":{\"power\":0,\"si\":1,\"v\":[0,10,0,0,0],\"trimZero\":false},\"nexchangerate\":{\"power\":-8,\"si\":1,\"v\":[0,1,0,0,0],\"trimZero\":false},\"vchangerate\":\"1/1\",\"nelignum\":{\"power\":-8,\"si\":1,\"v\":[0,0,0,0,0],\"trimZero\":false},\"nnum\":{\"power\":-1,\"si\":1,\"v\":[0,5,0,0,0],\"trimZero\":false},\"norigprice\":{\"power\":-3,\"si\":1,\"v\":[5690000000000000,7,0,0,0],\"trimZero\":false},\"csendcountryid\":\"0001Z010000000079UJJ\",\"cfirstid\":\"1001A1100000000KLLLX\",\"crowno\":\"10\",\"vbatchcode\":\"123456789\",\"nmny\":{\"power\":-8,\"si\":1,\"v\":[8450000000000000,37,0,0,0],\"trimZero\":false},\"norigmny\":{\"power\":-8,\"si\":1,\"v\":[8450000000000000,37,0,0,0],\"trimZero\":false},\"ts\":{\"utcTime\":1722415114000}},\"status\":0,\"m_isDirty\":false},{\"valueIndex\":{\"cfirstbid\":\"1001A1100000000KLLLV\",\"pk_group\":\"0001H11000000000257J\",\"pk_reqstoorg\":\"0001A11000000007GGN9\",\"dproducedate\":{\"utcTime\":1722355200000},\"bfixedrate\":{\"value\":true},\"ccurrencyid\":\"1002Z0100000000001K1\",\"nplanastnum\":{\"power\":0,\"si\":1,\"v\":[0,10,0,0,0],\"trimZero\":false},\"nprice\":{\"power\":-3,\"si\":1,\"v\":[5690000000000000,7,0,0,0],\"trimZero\":false},\"pk_org\":\"0001A11000000007GGN9\",\"norigtaxprice\":{\"power\":-1,\"si\":1,\"v\":[7000000000000000,8,0,0,0],\"trimZero\":false},\"pk_material\":\"1001A11000000000WHK1\",\"csourcetypecode\":\"21\",\"ctaxcountryid\":\"0001Z010000000079UJJ\",\"pk_arriveorder\":\"1001B1100000000KM4ZE\",\"pk_order\":\"1001A1100000000KLLLV\",\"pk_psfinanceorg_v\":\"0001A11000000007GGN8\",\"bbackreforder\":{\"value\":false},\"castunitid\":\"0001Z0100000000000XI\",\"pk_apfinanceorg_v\":\"0001A11000000007GGN8\",\"cunitid\":\"0001Z0100000000000XI\",\"fproductclass\":1,\"cfirsttypecode\":\"21\",\"pk_reqstoorg_v\":\"0001A11000000007GGN8\",\"pk_srcmaterial\":\"1001A11000000000WHK1\",\"ntaxmny\":{\"power\":-8,\"si\":1,\"v\":[5000000000000000,43,0,0,0],\"trimZero\":false},\"pk_order_b\":\"1001A1100000000KLLLX\",\"ntaxrate\":{\"power\":0,\"si\":1,\"v\":[0,13,0,0,0],\"trimZero\":false},\"fbuysellflag\":1,\"pk_org_v\":\"0001A11000000007GGN8\",\"ntaxprice\":{\"power\":-1,\"si\":1,\"v\":[7000000000000000,8,0,0,0],\"trimZero\":false},\"pk_psfinanceorg\":\"0001A11000000007GGN8\",\"crececountryid\":\"0001Z010000000079UJJ\",\"norigtaxmny\":{\"power\":-8,\"si\":1,\"v\":[5000000000000000,43,0,0,0],\"trimZero\":false},\"naccumchecknum\":{\"power\":-8,\"si\":1,\"v\":[0,0,0,0,0],\"trimZero\":false},\"nastnum\":{\"power\":-1,\"si\":1,\"v\":[0,5,0,0,0],\"trimZero\":false},\"pk_arriveorder_b\":\"测试1111\",\"ntax\":{\"power\":-8,\"si\":1,\"v\":[6550000000000000,5,0,0,0],\"trimZero\":false},\"pk_receivestore\":\"1001A1100000000JXT9L\",\"dplanreceivedate\":{\"utcTime\":1722355200000},\"dbilldate\":{\"utcTime\":1722355200000},\"csourcebid\":\"1001A1100000000KLLLX\",\"csourceid\":\"1001A1100000000KLLLV\",\"corigcurrencyid\":\"1002Z0100000000001K1\",\"nplannum\":{\"power\":0,\"si\":1,\"v\":[0,10,0,0,0],\"trimZero\":false},\"nexchangerate\":{\"power\":-8,\"si\":1,\"v\":[0,1,0,0,0],\"trimZero\":false},\"vchangerate\":\"1/1\",\"nelignum\":{\"power\":-8,\"si\":1,\"v\":[0,0,0,0,0],\"trimZero\":false},\"nnum\":{\"power\":-1,\"si\":1,\"v\":[0,5,0,0,0],\"trimZero\":false},\"norigprice\":{\"power\":-3,\"si\":1,\"v\":[5690000000000000,7,0,0,0],\"trimZero\":false},\"csendcountryid\":\"0001Z010000000079UJJ\",\"cfirstid\":\"1001A1100000000KLLLX\",\"crowno\":\"10\",\"vbatchcode\":\"123456789\",\"nmny\":{\"power\":-8,\"si\":1,\"v\":[8450000000000000,37,0,0,0],\"trimZero\":false},\"norigmny\":{\"power\":-8,\"si\":1,\"v\":[8450000000000000,37,0,0,0],\"trimZero\":false},\"ts\":{\"utcTime\":1722415114000}},\"status\":0,\"m_isDirty\":false}]],\"parent\":{\"valueIndex\":{\"ntotaltaxmny\":{\"power\":-1,\"si\":1,\"v\":[5000000000000000,43,0,0,0],\"trimZero\":false},\"pk_purchaseorg\":\"0001A11000000007GGN9\",\"ntotalastnum\":{\"power\":0,\"si\":1,\"v\":[0,5,0,0,0],\"trimZero\":false},\"pk_org\":\"0001A11000000007GGN9\",\"dbilldate\":{\"utcTime\":1722355200000},\"pk_supplier\":\"1001A110000000007U02\",\"approver\":\"1001H11000000000000X\",\"pk_arriveorder\":\"1001B1100000000KM4ZE\",\"bisback\":{\"value\":false},\"creator\":\"1001H11000000000000X\",\"ctrantypeid\":\"0001H11000000000D2ZU\",\"fbillstatus\":3,\"pk_dept_v\":\"0001A11000000000S786\",\"vtrantypecode\":\"23-01\",\"taudittime\":{\"utcTime\":1722415114000},\"pk_busitype\":\"1001A110000000009NUO\",\"dmakedate\":{\"utcTime\":1722355200000},\"pk_supplier_v\":\"1001A110000000007U02\",\"vbillcode\":\"DH2024070012\",\"pk_dept\":\"1001A110000000003CC3\",\"billmaker\":\"1001A110000000026S7L\",\"pk_purchaseorg_v\":\"0001A11000000007GGN8\",\"creationtime\":{\"utcTime\":1722415114000},\"pk_org_v\":\"0001A11000000007GGN8\",\"ts\":{\"utcTime\":1722415114000}},\"status\":0,\"m_isDirty\":false}},\"msgResult\":\"执行成功\"}"; + + string requestDataJson = "{\"approver\":\"1001A110000000026S7L\",\"billmaker\":\"1001A110000000026S7L\",\"creationtime\":\"2024-07-31 16:18:30\",\"creator\":\"1001A110000000026S7L\",\"dbilldate\":\"2024-07-31 16:18:30\",\"dmakedate\":\"2024-07-31 16:18:30\",\"ntotalastnum\":0.0,\"pk_arriveorder\":null,\"Pk_receivepsndoc\":\"1001A110000000026S7L\",\"pk_org\":\"0001A11000000007GGN9\",\"pk_org_v\":\"0001A11000000007GGN8\",\"pk_group\":\"0001H11000000000257J\",\"pk_pupsndoc\":\"\",\"pk_purchaseorg\":\"0001A11000000007GGN9\",\"pk_purchaseorg_v\":\"0001A11000000007GGN8\",\"pk_supplier\":\"1001A110000000007U02\",\"pk_supplier_v\":\"1001A110000000007U02\",\"vbillcode\":\"WP202407310004\",\"vmemo\":null,\"vtrantypecode\":\"\",\"csourceid\":\"1001A1100000000KLLLV\",\"dtls\":[{\"castunitid\":\"0001Z0100000000000XI\",\"cfirstbid\":\"1001A1100000000KLLLV\",\"cfirstid\":\"1001A1100000000KLLLX\",\"cfirsttypecode\":\"\",\"crececountryid\":\"0001Z010000000079UJJ\",\"crowno\":10,\"csendcountryid\":\"0001Z010000000079UJJ\",\"csourcetypecode\":\"\",\"ctaxcountryid\":\"0001Z010000000079UJJ\",\"cunitid\":\"0001Z0100000000000XI\",\"dbilldate\":\"2024-07-31 16:18:30\",\"dplanreceivedate\":\"2024-07-31 16:18:30\",\"dproducedate\":\"2024-07-31 16:18:30\",\"fbuysellflag\":1,\"fproductclass\":1,\"naccumchecknum\":0,\"nnum\":5.0,\"nplannum\":10.0,\"apfinanceorg\":\"0001A11000000007GGN9\",\"pk_apfinanceorg_v\":\"0001A11000000007GGN8\",\"pk_arriveorder\":null,\"pk_arriveorder_b\":null,\"pk_group\":\"\",\"csourcebid\":\"1001A1100000000KLLLX\",\"csourceid\":\"1001A1100000000KLLLV\",\"pk_material\":\"1001A11000000000WHK1\",\"pk_order\":\"1001A1100000000KLLLV\",\"pk_order_b\":\"1001A1100000000KLLLX\",\"pk_org\":\"0001A11000000007GGN9\",\"pk_org_v\":\"0001A11000000007GGN8\",\"pk_psfinanceorg\":\"0001A11000000007GGN8\",\"pk_psfinanceorg_v\":\"0001A11000000007GGN8\",\"pk_receivestore\":\"1001A1100000000JXT9L\",\"pk_reqstoorg\":\"0001A11000000007GGN9\",\"pk_reqstoorg_v\":\"0001A11000000007GGN8\",\"pk_srcmaterial\":\"1001A11000000000WHK1\",\"vbatchcode\":\"123456789\",\"Vfree1\":\"123456789\"}]}"; + Dictionary requestData = JsonConvert.DeserializeObject>(requestDataJson); + var aaa = ((JArray)requestData["dtls"]).Select(x => new ErpPurchaseDto() + { + csourcebid = x["csourcebid"]?.ToString(), + mes_detail_id = x["mes_detail_id"]?.ToString(), + }).ToList(); + + try + { + ThirdResult thirdResult = JsonConvert.DeserializeObject(response); + Console.WriteLine(thirdResult); + JObject data = (JObject)thirdResult.msg; + JToken children = data.SelectToken("children")[0]; + JToken parent = data.SelectToken("parent"); + var bbb = children.Select(x => new ErpPurchaseDto() + { + pk_arriveorder = x["valueIndex"]["pk_arriveorder"].ToString(), + pk_arriveorder_b = x["valueIndex"]["pk_arriveorder_b"].ToString(), + csourcebid = x["valueIndex"]["csourcebid"].ToString() + }).ToList(); + + } + catch (Exception e) + { + Log.Error(e.Message,e); + + } + + + return "失败"; + } + } + + public class ErpPurchaseDto + { + public string pk_arriveorder { get; set; } + public string pk_arriveorder_b { get; set; } + public string csourcebid { get; set; } + public string mes_detail_id { get; set; } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdRawMaterialBarcode.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdRawMaterialBarcode.cs new file mode 100644 index 00000000..42a61f33 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdRawMaterialBarcode.cs @@ -0,0 +1,92 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entities; + +/// +/// 料仓原料条码 +/// +[SugarTable("prd_raw_material_barcode")] +public partial class PrdRawMaterialBarcode : BaseEntity +{ + public PrdRawMaterialBarcode() + { + 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 new file mode 100644 index 00000000..3dd1b373 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr/PrdRawMaterialBarcodeService.cs @@ -0,0 +1,43 @@ +using JNPF.Common.Core.Manager; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.Systems.Interfaces.System; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.ProductionMgr.Entities; + +namespace Tnb.ProductionMgr +{ + /// + /// 料仓原料条码服务 + /// + [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + public class PrdRawMaterialBarcodeService: IDynamicApiController, ITransient + { + private readonly ISqlSugarClient _db; + private readonly IDictionaryDataService _dictionaryDataService; + private readonly IUserManager _userManager; + private static Dictionary> _dicWorkLine = new(); + public PrdRawMaterialBarcodeService(ISqlSugarRepository repository, + IUserManager userManager, + IDictionaryDataService dictionaryDataService) + { + _db = repository.AsSugarClient(); + _userManager = userManager; + _dictionaryDataService = dictionaryDataService; + } + + // /// + // /// 上模校验 + // /// + // /// + // [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; + // } + } +} \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseD.cs index a4211dfc..8d197b24 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseD.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseD.cs @@ -113,4 +113,9 @@ public partial class WmsPurchaseD : BaseEntity /// 质检结果 /// public string? qc_res { get; set; } + + /// + /// erp到货单子表pk + /// + public string erp_arriveorder_b_pk { get;set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseH.cs index 8f4a8282..f9304917 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseH.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseH.cs @@ -155,5 +155,8 @@ public partial class WmsPurchaseH : BaseEntity, IPurchaseAndSaleAuitEnti /// public string? transaction_type { get; set; } - + /// + /// erp到货单主表pk + /// + public string erp_arriveorder_pk { get;set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs index 46e124ca..778fa8a5 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs @@ -342,12 +342,13 @@ namespace Tnb.WarehouseMgr DictionaryDataEntity tranType = await _db.Queryable().Where(x=>x.DictionaryTypeId=="25043925951909" && x.EnCode==wmsPurchaseH.transaction_type).FirstAsync(); string tranTypeId = tranType?.Id ?? ""; + string supplierId = wmsPurchaseOrderH?.supplier_id ?? ""; List tableIds = new List(); tableIds.Add(_userManager.UserId); tableIds.Add(WmsWareHouseConst.AdministratorOrgId); tableIds.Add(instock.warehouse_id); tableIds.AddRange(materialIds); - tableIds.Add(instock.supplier_id); + tableIds.Add(supplierId); tableIds.Add(tranTypeId); tableIds.AddRange(unitDatas.Select(x => x.Id).ToList()); @@ -367,8 +368,8 @@ namespace Tnb.WarehouseMgr erpRequestData.Add("creationtime", nowStr); erpRequestData.Add("creator", erpCreateId); erpRequestData.Add("ctrantypeid", erpExtendFields.Find(x => x.table_id == tranTypeId)?.transaction_type_id ?? ""); - erpRequestData.Add("cvendorid", erpExtendFields.Find(x => x.table_id == instock.supplier_id)?.supplier_id ?? ""); - erpRequestData.Add("cvendorvid", erpExtendFields.Find(x => x.table_id == instock.supplier_id)?.supplier_vid ?? ""); + erpRequestData.Add("cvendorid", erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_id ?? ""); + erpRequestData.Add("cvendorvid", erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_vid ?? ""); erpRequestData.Add("cwarehouseid", erpExtendFields.Find(x => x.table_id == instock.warehouse_id)?.cotherwhid ?? "");//类型视图里取 erpRequestData.Add("dbilldate", nowStr); erpRequestData.Add("dmakedate", nowStr); @@ -397,8 +398,8 @@ namespace Tnb.WarehouseMgr ["corpvid"] = erpOrg.corpvid, ["crowno"] = (allInstockDetails.FindIndex(x => x.id == item.id) + 1) * 10, ["cunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x => x.EnCode == item.unit_id)?.Id ?? ""))?.cunitid ?? "", - ["cvendorid"] = erpExtendFields.Find(x => x.table_id == instock.supplier_id)?.supplier_id ?? "", - ["cvendorvid"] = erpExtendFields.Find(x => x.table_id == instock.supplier_id)?.supplier_vid ?? "", + ["cvendorid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_id ?? "", + ["cvendorvid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_vid ?? "", ["dbizdate"] = instock.create_time.ToString("yyyy-MM-dd HH:mm:ss"), ["nnum"] = item.qty, ["nshouldnum"] = item.pr_qty, @@ -408,15 +409,15 @@ namespace Tnb.WarehouseMgr ["pk_org_v"] = erpOrg.pk_org_v, ["pseudocolumn"] = (allInstockDetails.FindIndex(x => x.id == item.id) + 1) * 10, ["vbatchcode"] = item.code_batch, - ["csourcebillhid"] = wmsPurchaseOrderH?.erp_pk ?? "", - ["csourcebillbid"] = wmsPurchaseOrderDs?.erp_line_pk ?? "", - ["vsourcebillcode"] = wmsPurchaseOrderH?.erp_bill_code ?? "", + ["csourcebillhid"] = wmsPurchaseH?.erp_arriveorder_pk ?? "", + ["csourcebillbid"] = wmsPurchaseD?.erp_arriveorder_b_pk ?? "", + ["vsourcebillcode"] = wmsPurchaseH?.bill_code ?? "", ["lineno"] = wmsPurchaseOrderDs?.lineno ?? "", - ["vfree1"] = erpExtendFields.Find(x => x.table_id == instock.supplier_id)?.supplier_id ?? "", + ["vfree1"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_id ?? "", }); } - erpRequestData.Add("PurchaseInBodyVODtl", erpRequestDataDetails); + erpRequestData.Add("dtls", erpRequestDataDetails); requestData.Add(erpRequestData); ThirdWebapiRecord thirdWebapiRecord = new ThirdWebapiRecord(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs index f268e43a..1f304d91 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs @@ -219,6 +219,7 @@ namespace Tnb.WarehouseMgr ["pk_srcmaterial"] = erpExtendFields.Find(x=>x.table_id==item.material_id)?.cmaterialoid ?? "", ["vbatchcode"] = item.code_batch, ["Vfree1"] = item.code_batch, + ["mes_detail_id"] = item.id, }); } erpRequestData.Add("dtls",erpRequestDataDetails); diff --git a/system/Tnb.Systems/Common/TestService.cs b/system/Tnb.Systems/Common/TestService.cs index 9da961f9..0aebbf50 100644 --- a/system/Tnb.Systems/Common/TestService.cs +++ b/system/Tnb.Systems/Common/TestService.cs @@ -280,9 +280,9 @@ public class TestService : IDynamicApiController, ITransient }; inserteErpExtendFields.Add(extendField); - await _sugar.Insertable(insertList).ExecuteCommandAsync(); - await _sugar.Insertable(inserteErpExtendFields).ExecuteCommandAsync(); } + await _sugar.Insertable(insertList).ExecuteCommandAsync(); + await _sugar.Insertable(inserteErpExtendFields).ExecuteCommandAsync(); return "测试成功"; }