同步单位
This commit is contained in:
@@ -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<String> SyncUnit()
|
||||
{
|
||||
// var mysqlDb = _db.AsTenant().GetConnection("erpdb");
|
||||
// List<ErpBdMeasdoc> list = await mysqlDb.Queryable<ErpBdMeasdoc>().ToListAsync();
|
||||
// List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().ToListAsync();
|
||||
// List<DictionaryDataEntity> insertMaterial = new List<DictionaryDataEntity>();
|
||||
// List<ErpExtendField> insertExtendFields = new List<ErpExtendField>();
|
||||
// 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<ErpBdMeasdoc> list = await mysqlDb.Queryable<ErpBdMeasdoc>().ToListAsync();
|
||||
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().ToListAsync();
|
||||
List<DictionaryDataEntity> insertUnit = new List<DictionaryDataEntity>();
|
||||
List<ErpExtendField> insertExtendFields = new List<ErpExtendField>();
|
||||
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<bool> result = await _db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _db.Insertable(insertUnit).ExecuteCommandAsync();
|
||||
await _db.Insertable(insertExtendFields).ExecuteCommandAsync();
|
||||
});
|
||||
}
|
||||
|
||||
return "true";
|
||||
}
|
||||
|
||||
|
||||
@@ -485,5 +485,10 @@
|
||||
/// 第三方 bip
|
||||
/// </summary>
|
||||
public const string BIP_DOMAIN = "http://192.168.1.11:8087/";
|
||||
|
||||
/// <summary>
|
||||
/// 单位类型id
|
||||
/// </summary>
|
||||
public const string UNITTYPEID = "24906054811669";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user