Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr.Entities.Entity.ErpEntity
|
||||||
|
{
|
||||||
|
[SugarTable("ERP_ORG_DEPT")]
|
||||||
|
public class ErpOrgDept
|
||||||
|
{
|
||||||
|
public string PK_ORG { get; set; }
|
||||||
|
public string ID { get; set; }
|
||||||
|
public string CODE { get; set; }
|
||||||
|
public string NAME { get; set; }
|
||||||
|
public string VID { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 修改时间
|
||||||
|
/// </summary>
|
||||||
|
public string MODIFIEDTIME { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -965,6 +965,18 @@ namespace Tnb.ProductionMgr
|
|||||||
result += e.Message;
|
result += e.Message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string response6 = HttpUtils.RequestGet($"{config.value}/api/production/time-work/sync-dept");
|
||||||
|
AuthResponse authResponse6 = JsonConvert.DeserializeObject<AuthResponse>(response6);
|
||||||
|
result += ","+authResponse6.data.ToString();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error(e.Message,e);
|
||||||
|
result += e.Message;
|
||||||
|
}
|
||||||
|
|
||||||
Log.Information($"基础数据同步结果:{result}");
|
Log.Information($"基础数据同步结果:{result}");
|
||||||
BasSyncRecord basSyncRecord = new BasSyncRecord()
|
BasSyncRecord basSyncRecord = new BasSyncRecord()
|
||||||
{
|
{
|
||||||
@@ -1528,6 +1540,96 @@ namespace Tnb.ProductionMgr
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 同步部门
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
[AllowAnonymous]
|
||||||
|
public async Task<String> SyncDept()
|
||||||
|
{
|
||||||
|
string msg = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int editCount = 0;
|
||||||
|
var erpdb = _db.AsTenant().GetConnection("erpdb");
|
||||||
|
List<ErpOrgDept> list = await erpdb.Queryable<ErpOrgDept>().ToListAsync();
|
||||||
|
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x=>x.table_name=="base_organize").ToListAsync();
|
||||||
|
List<OrganizeEntity> insertDepts = new List<OrganizeEntity>();
|
||||||
|
List<ErpExtendField> insertExtendFields = new List<ErpExtendField>();
|
||||||
|
|
||||||
|
await _db.Ado.BeginTranAsync();
|
||||||
|
|
||||||
|
foreach (ErpOrgDept erpOrgDept in list)
|
||||||
|
{
|
||||||
|
if (erpExtendFields.All(x => x.cdptid != erpOrgDept.ID))
|
||||||
|
{
|
||||||
|
string id = SnowflakeIdHelper.NextId();
|
||||||
|
OrganizeEntity organizeEntity = new OrganizeEntity()
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
ParentId = WmsWareHouseConst.AdministratorOrgId,
|
||||||
|
Category = "department",
|
||||||
|
EnCode = erpOrgDept.CODE,
|
||||||
|
FullName = erpOrgDept.NAME,
|
||||||
|
SortCode = 0,
|
||||||
|
EnabledMark = 1,
|
||||||
|
OrganizeIdTree = $"24755469898005,25193668006933,{id}",
|
||||||
|
CreatorTime = DateTime.Now
|
||||||
|
};
|
||||||
|
ErpExtendField erpExtendField = new ErpExtendField()
|
||||||
|
{
|
||||||
|
table_id = organizeEntity.Id,
|
||||||
|
table_name = "base_organize",
|
||||||
|
cdptid = erpOrgDept.ID,
|
||||||
|
cdptvid = erpOrgDept.VID,
|
||||||
|
create_time = DateTime.Now,
|
||||||
|
erp_modify_time = erpOrgDept.MODIFIEDTIME,
|
||||||
|
};
|
||||||
|
|
||||||
|
insertDepts.Add(organizeEntity);
|
||||||
|
insertExtendFields.Add(erpExtendField);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ErpExtendField erpExtendField = erpExtendFields.Find(x => x.cdptid == erpOrgDept.ID);
|
||||||
|
if (erpOrgDept.MODIFIEDTIME != erpExtendField.erp_modify_time)
|
||||||
|
{
|
||||||
|
int updateRow = await _db.Updateable<OrganizeEntity>()
|
||||||
|
.SetColumns(x => x.EnCode == erpOrgDept.CODE)
|
||||||
|
.SetColumns(x => x.FullName == erpOrgDept.NAME)
|
||||||
|
.Where(x => x.Id == erpExtendField.table_id)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
|
||||||
|
await _db.Updateable<ErpExtendField>()
|
||||||
|
.SetColumns(x => x.erp_modify_time == erpOrgDept.MODIFIEDTIME)
|
||||||
|
.Where(x => x.table_id == erpExtendField.table_id)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
|
||||||
|
editCount += updateRow;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await _db.Insertable(insertDepts).ExecuteCommandAsync();
|
||||||
|
await _db.Insertable(insertExtendFields).ExecuteCommandAsync();
|
||||||
|
|
||||||
|
await _db.Ado.CommitTranAsync();
|
||||||
|
|
||||||
|
msg = $"新增供应商{insertDepts.Count}条,修改供应商{editCount}条";
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error(e.Message, e);
|
||||||
|
msg = e.Message;
|
||||||
|
await _db.Ado.RollbackTranAsync();
|
||||||
|
throw Oops.Bah(e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 同步用户
|
/// 同步用户
|
||||||
|
|||||||
Reference in New Issue
Block a user