diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpExtendField.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpExtendField.cs index 2133e2b0..da3ed2ba 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpExtendField.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpExtendField.cs @@ -7,7 +7,7 @@ namespace Tnb.ProductionMgr.Entities.Entity /// erp扩展字段 /// [SugarTable("erp_extend_field")] - public class ErpExtendField: BaseEntity + public class ErpExtendField { /// /// 天益表名 @@ -35,8 +35,66 @@ namespace Tnb.ProductionMgr.Entities.Entity /// public string erp_line_pk { get; set; } + /// + /// 用户id + /// public string user_id { get; set; } public DateTime create_time { get; set; } + + /// + /// 公司id + /// + public string corpoid { get; set; } + + /// + /// 公司vid + /// + public string corpvid { get; set; } + + /// + /// 部门id + /// + public string cdptid { get; set; } + + /// + /// 部门vid + /// + public string cdptvid { get; set; } + + /// + /// 入库仓库id + /// + public string cotherwhid { get; set; } + + /// + /// 集团id + /// + public string pk_group { get; set; } + + /// + /// 组织id + /// + public string pk_org { get; set; } + + /// + /// 组织vid + /// + public string pk_org_v { get; set; } + + /// + /// 物料id + /// + public string cmaterialoid { get; set; } + + /// + /// 物料vid + /// + public string cmaterialvid { get; set; } + + /// + /// 单位id + /// + public string cunitid { get; set; } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs b/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs index 74017417..76fa8a44 100644 --- a/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs @@ -104,7 +104,6 @@ namespace Tnb.ProductionMgr moList.Add(item); extendFieldList.Add(new ErpExtendField() { - id = SnowflakeIdHelper.NextId(), org_id =WmsWareHouseConst.AdministratorOrgId, table_name = "prd_mo", table_id = item.id, diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs index 6ad17597..f7878298 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; @@ -40,6 +41,7 @@ using NPOI.SS.Formula.Functions; using Org.BouncyCastle.Asn1.X509; using Tnb.ProductionMgr.Entities; using Tnb.BasicData; +using Tnb.ProductionMgr.Entities.Entity; using Tnb.WarehouseMgr.Entities.Dto.Outputs; namespace Tnb.WarehouseMgr @@ -624,6 +626,84 @@ namespace Tnb.WarehouseMgr if (input.area_code == "E") await sign(input); + + WmsMaterialTransfer wmsMaterialTransfer = await _db.Queryable().SingleAsync(x => x.id == wmsMaterialTransferd.bill_id); + List dList = await _db.Queryable().Where(x => x.bill_id == wmsMaterialTransferd.bill_id).OrderBy(x=>x.id).ToListAsync(); + DictionaryDataEntity unitData = await _db.Queryable() + .LeftJoin((x, y) => x.Id == y.DictionaryTypeId) + .Where((x, y) => x.EnCode == DictConst.MeasurementUnit && y.EnCode == wmsMaterialTransferd.unit_id) + .Select((x,y)=>y) + .FirstAsync(); + List ids = new List(); + ids.Add(wmsMaterialTransfer.create_id); + ids.Add(WmsWareHouseConst.AdministratorOrgId); + ids.Add(wmsMaterialTransfer.warehouse_outstock); + ids.Add(wmsMaterialTransfer.warehouse_instock); + ids.Add(wmsMaterialTransferd.material_id); + ids.Add(unitData.Id); + + List erpExtendFields = await _db.Queryable().Where(x=>ids.Contains(x.table_id)).ToListAsync(); + + ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == wmsMaterialTransfer.org_id); + if (erpOrg == null) + throw Oops.Bah("未配置erp组织"); + string erpCreateId = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.create_id)?.user_id ?? ""; + + Dictionary erpRequestData = new Dictionary(); + erpRequestData.Add("billmaker",erpCreateId); + erpRequestData.Add("cdptid","1001A1100000000JRLI1A100");// 先写死 + erpRequestData.Add("cdptvid","0001A11000000007GGO8");// 先写死 + erpRequestData.Add("corpoid",erpOrg.corpoid); + erpRequestData.Add("corpvid",erpOrg.corpoid); + erpRequestData.Add("cothercalbodyoid",erpOrg.cdptid); + erpRequestData.Add("cotherwhid",erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.warehouse_instock)?.cotherwhid ?? ""); + erpRequestData.Add("creationtime",DateTime.Now); + erpRequestData.Add("creator",erpCreateId); + erpRequestData.Add("ctrantypeid","0001H11000000000D31W"); + erpRequestData.Add("cwarehouseid",erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.warehouse_outstock)?.cotherwhid ?? ""); + erpRequestData.Add("dbilldate",DateTime.Now); + erpRequestData.Add("dmakedate",DateTime.Now); + erpRequestData.Add("ntotalnum",wmsCarryCodes.Sum(r => r.codeqty)); + erpRequestData.Add("pk_group",erpOrg.pk_group); + erpRequestData.Add("pk_org",erpOrg.pk_org); + erpRequestData.Add("pk_org_v",erpOrg.pk_org_v); + erpRequestData.Add("vbillcode",wmsMaterialTransfer.bill_code); + erpRequestData.Add("vtrantypecode","4I-01");//其他出库 先写死 + List> erpRequestDataDetails = new List>(); + erpRequestDataDetails.Add(new Dictionary() + { + ["cbodytranstypecode"] = "4I-01", + ["cbodywarehouseid"] = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.warehouse_outstock)?.cotherwhid ?? "", + ["cmaterialoid"] = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransferd.material_id)?.cmaterialoid ?? "", + ["cmaterialvid"] = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransferd.material_id)?.cmaterialvid ?? "", + ["corpoid"] = erpOrg.corpoid, + ["corpvid"] = erpOrg.corpvid, + ["crowno"] = (dList.FindIndex(x=>x.id==wmsMaterialTransferd.id)+1) * 10, + ["csourcebillbid"] = wmsMaterialTransferd.id, + ["csourcebillhid"] = wmsMaterialTransferd.bill_id, + ["cunitid"] = erpExtendFields.Find(x=>x.table_id==unitData.Id)?.cunitid ?? "", + ["cvendorid"] = "", + ["cvendorvid"] = "", + ["dbizdate"] = DateTime.Now, + ["nnum"] = wmsCarryCodes.Sum(r => r.codeqty), + ["nshouldnum"] = wmsMaterialTransferd.qty, + ["pk_group"] = erpOrg.pk_group, + ["pk_org"] = erpOrg.pk_org, + ["pk_org_v"] = erpOrg.pk_org_v, + ["vbatchcode"] = wmsMaterialTransferd.code_batch, + }); + + ThirdWebapiRecord thirdWebapiRecord = new ThirdWebapiRecord(); + thirdWebapiRecord.id = SnowflakeIdHelper.NextId(); + thirdWebapiRecord.third_name = WmsWareHouseConst.BIP; + thirdWebapiRecord.name = "其它出库"; + thirdWebapiRecord.method = "POST"; + thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN+"uapws/rest/purarrvial/save"; + thirdWebapiRecord.request_data = JsonConvert.SerializeObject(erpRequestData); + thirdWebapiRecord.create_time = DateTime.Now; + + await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync(); + await _db.Ado.CommitTranAsync(); } catch(Exception ex) diff --git a/system/Tnb.Systems/Common/TestService.cs b/system/Tnb.Systems/Common/TestService.cs index c8786b91..048e0cb9 100644 --- a/system/Tnb.Systems/Common/TestService.cs +++ b/system/Tnb.Systems/Common/TestService.cs @@ -129,8 +129,7 @@ public class TestService : IDynamicApiController, ITransient insertUserRelations.Add(userRelationEntity); ErpExtendField extendField = new ErpExtendField(); - extendField.id = SnowflakeIdHelper.NextId(); - extendField.org_id = "25398501929509"; + extendField.org_id = "25193668006933"; extendField.table_name = "base_user"; extendField.table_id = userEntity.Id; extendField.user_id = user.id;