From 9326b55a8e2f0819db7cf949b285a456416ce0d1 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Thu, 18 Jul 2024 14:05:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=8D=95=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.ProductionMgr/TimeWorkService.cs | 63 +++++++++++++------ .../Consts/WmsWareHouseConst.cs | 5 ++ 2 files changed, 48 insertions(+), 20 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs index 48e21453..8800b994 100644 --- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs @@ -17,6 +17,7 @@ using JNPF.Systems.Interfaces.System; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; +using SQLitePCL; using SqlSugar; using SqlSugar.Extensions; using Tnb.BasicData.Entities; @@ -703,26 +704,48 @@ namespace Tnb.ProductionMgr [AllowAnonymous] public async Task SyncUnit() { - // var mysqlDb = _db.AsTenant().GetConnection("erpdb"); - // List list = await mysqlDb.Queryable().ToListAsync(); - // List erpExtendFields = await _db.Queryable().ToListAsync(); - // List insertMaterial = new List(); - // List insertExtendFields = new List(); - // foreach (ErpBdMaterial erpBdMaterial in list) - // { - // if (erpExtendFields.All(x => x.cmaterialoid != erpBdMaterial.ID)) - // { - // insertMaterial.Add(new BasMaterial() - // { - // id = SnowflakeIdHelper.NextId(), - // name = erpBdMaterial.NAME, - // code = erpBdMaterial.CODE, - // org_id = WmsWareHouseConst.AdministratorOrgId, - // material_specification = erpBdMaterial.MATERIALSPEC, - // material_standard = erpBdMaterial.MATERIALTYPE - // }); - // } - // } + var mysqlDb = _db.AsTenant().GetConnection("erpdb"); + List list = await mysqlDb.Queryable().ToListAsync(); + List erpExtendFields = await _db.Queryable().ToListAsync(); + List insertUnit = new List(); + List insertExtendFields = new List(); + foreach (ErpBdMeasdoc erpBdMeasdoc in list) + { + if (erpExtendFields.All(x => x.cunitid != erpBdMeasdoc.ID)) + { + DictionaryDataEntity dictionaryDataEntity = new DictionaryDataEntity() + { + Id = SnowflakeIdHelper.NextId(), + FullName = erpBdMeasdoc.NAME, + EnCode = erpBdMeasdoc.CODE, + ParentId = "0", + SortCode = 0, + EnabledMark = 1, + CreatorTime = DateTime.Now, + DictionaryTypeId = WmsWareHouseConst.UNITTYPEID, + }; + ErpExtendField erpExtendField = new ErpExtendField() + { + table_id = dictionaryDataEntity.Id, + table_name = "base_dictionarydata", + cunitid = erpBdMeasdoc.ID, + create_time = DateTime.Now + }; + + insertUnit.Add(dictionaryDataEntity); + insertExtendFields.Add(erpExtendField); + } + } + + if (!insertUnit.IsEmpty() && !insertExtendFields.IsEmpty()) + { + DbResult result = await _db.Ado.UseTranAsync(async () => + { + await _db.Insertable(insertUnit).ExecuteCommandAsync(); + await _db.Insertable(insertExtendFields).ExecuteCommandAsync(); + }); + } + return "true"; } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs index 42a16698..aea05018 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs @@ -485,5 +485,10 @@ /// 第三方 bip /// public const string BIP_DOMAIN = "http://192.168.1.11:8087/"; + + /// + /// 单位类型id + /// + public const string UNITTYPEID = "24906054811669"; } }