|
|
@@ -47,12 +47,12 @@ using System.Collections;
|
|
|
using System.Data.SqlTypes;
|
|
|
using Bussiness.Model.SystemData;
|
|
|
|
|
|
-namespace Business.ScheduleTaskManagement
|
|
|
+namespace Business.SyncDataManagement
|
|
|
{
|
|
|
/// <summary>
|
|
|
- /// 资源检查
|
|
|
+ /// 同步mysql数据到mongodb
|
|
|
/// </summary>
|
|
|
- public class ScheduleTaskAppService : ApplicationService, IScheduleTaskAppService
|
|
|
+ public class SyncMySQLDataAppService : ApplicationService
|
|
|
{
|
|
|
#region 服务
|
|
|
/// <summary>
|
|
|
@@ -119,7 +119,7 @@ namespace Business.ScheduleTaskManagement
|
|
|
/// <summary>
|
|
|
/// 构造函数
|
|
|
/// </summary>
|
|
|
- public ScheduleTaskAppService(
|
|
|
+ public SyncMySQLDataAppService(
|
|
|
IMongoDB<ic_bom> ic_bom,
|
|
|
IMongoDB<ic_bom_child> ic_bom_child,
|
|
|
IMongoDB<ic_item> ic_item,
|
|
|
@@ -169,123 +169,106 @@ namespace Business.ScheduleTaskManagement
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
|
- public async Task<ResultDto> SyncBaseDataToMongoDB()
|
|
|
+ public async Task SyncBaseDataToMongoDB()
|
|
|
{
|
|
|
- //数据同步返回结果
|
|
|
- ResultDto result = new ResultDto();
|
|
|
- result.start = DateTime.Now;
|
|
|
- try
|
|
|
+ //同步物料Bom数据
|
|
|
+ var icBoms = await _mysql_ic_bom.GetListAsync();
|
|
|
+ if (icBoms.Count > 0)
|
|
|
{
|
|
|
- //同步物料Bom数据
|
|
|
- var icBoms = await _mysql_ic_bom.GetListAsync();
|
|
|
- if (icBoms.Count > 0)
|
|
|
- {
|
|
|
- //先清空表数据(删除mongodb中的集合)
|
|
|
- await _ic_bom.DeleteAll();
|
|
|
- //插入数据
|
|
|
- await _ic_bom.InsertMany(icBoms);
|
|
|
- }
|
|
|
-
|
|
|
- //同步物料BOM明细数据
|
|
|
- var icbom_childs = await _mysql_ic_bom_child.GetListAsync();
|
|
|
- if (icbom_childs.Count > 0)
|
|
|
- {
|
|
|
- //先清空表数据(删除mongodb中的集合)
|
|
|
- await _ic_bom_child.DeleteAll();
|
|
|
- //插入数据
|
|
|
- await _ic_bom_child.InsertMany(icbom_childs);
|
|
|
- }
|
|
|
-
|
|
|
- //同步物料数据
|
|
|
- var icItems = await _mysql_ic_item.GetListAsync();
|
|
|
- if (icItems.Count > 0)
|
|
|
- {
|
|
|
- //先清空表数据(删除mongodb中的集合)
|
|
|
- await _ic_item.DeleteAll();
|
|
|
- //插入数据
|
|
|
- await _ic_item.InsertMany(icItems);
|
|
|
- }
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _ic_bom.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _ic_bom.InsertMany(icBoms);
|
|
|
+ }
|
|
|
|
|
|
- //同步替代群组数据
|
|
|
- var subtitutes = await _mysql_ic_substitute.GetListAsync();
|
|
|
- if (subtitutes.Count > 0)
|
|
|
- {
|
|
|
- //先清空表数据(删除mongodb中的集合)
|
|
|
- await _ic_substitute.DeleteAll();
|
|
|
- //插入数据
|
|
|
- await _ic_substitute.InsertMany(subtitutes);
|
|
|
- }
|
|
|
+ //同步物料BOM明细数据
|
|
|
+ var icbom_childs = await _mysql_ic_bom_child.GetListAsync();
|
|
|
+ if (icbom_childs.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _ic_bom_child.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _ic_bom_child.InsertMany(icbom_childs);
|
|
|
+ }
|
|
|
|
|
|
- //同步物料替代多群组数据
|
|
|
- var subAlls = await _mysql_ic_substitute_all.GetListAsync();
|
|
|
- if (subAlls.Count > 0)
|
|
|
- {
|
|
|
- //先清空表数据(删除mongodb中的集合)
|
|
|
- await _ic_substitute_all.DeleteAll();
|
|
|
- //插入数据
|
|
|
- await _ic_substitute_all.InsertMany(subAlls);
|
|
|
- }
|
|
|
+ //同步物料数据
|
|
|
+ var icItems = await _mysql_ic_item.GetListAsync();
|
|
|
+ if (icItems.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _ic_item.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _ic_item.InsertMany(icItems);
|
|
|
+ }
|
|
|
|
|
|
- //同步物料替代多群组明细数据
|
|
|
- var subAllDtls = await _mysql_ic_substitute_all_dtl.GetListAsync();
|
|
|
- if (subAllDtls.Count > 0)
|
|
|
- {
|
|
|
- //先清空表数据(删除mongodb中的集合)
|
|
|
- await _ic_substitute_all_dtl.DeleteAll();
|
|
|
- //插入数据
|
|
|
- await _ic_substitute_all_dtl.InsertMany(subAllDtls);
|
|
|
- }
|
|
|
+ //同步替代群组数据
|
|
|
+ var subtitutes = await _mysql_ic_substitute.GetListAsync();
|
|
|
+ if (subtitutes.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _ic_substitute.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _ic_substitute.InsertMany(subtitutes);
|
|
|
+ }
|
|
|
|
|
|
- //同步供应商数据
|
|
|
- var suppliers = await _mysql_srm_supplier.GetListAsync();
|
|
|
- if (suppliers.Count > 0)
|
|
|
- {
|
|
|
- //先清空表数据(删除mongodb中的集合)
|
|
|
- await _srm_supplier.DeleteAll();
|
|
|
- //插入数据
|
|
|
- await _srm_supplier.InsertMany(suppliers);
|
|
|
- }
|
|
|
+ //同步物料替代多群组数据
|
|
|
+ var subAlls = await _mysql_ic_substitute_all.GetListAsync();
|
|
|
+ if (subAlls.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _ic_substitute_all.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _ic_substitute_all.InsertMany(subAlls);
|
|
|
+ }
|
|
|
|
|
|
- //同步工艺路径数据
|
|
|
- var techs = await _mysql_mes_technique.GetListAsync();
|
|
|
- if (techs.Count > 0)
|
|
|
- {
|
|
|
- //先清空表数据(删除mongodb中的集合)
|
|
|
- await _mes_technique.DeleteAll();
|
|
|
- //插入数据
|
|
|
- await _mes_technique.InsertMany(techs);
|
|
|
- }
|
|
|
+ //同步物料替代多群组明细数据
|
|
|
+ var subAllDtls = await _mysql_ic_substitute_all_dtl.GetListAsync();
|
|
|
+ if (subAllDtls.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _ic_substitute_all_dtl.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _ic_substitute_all_dtl.InsertMany(subAllDtls);
|
|
|
+ }
|
|
|
|
|
|
- //同步工序数据
|
|
|
- var processes = await _mysql_mes_process.GetListAsync();
|
|
|
- if (suppliers.Count > 0)
|
|
|
- {
|
|
|
- //先清空表数据(删除mongodb中的集合)
|
|
|
- await _mes_process.DeleteAll();
|
|
|
- //插入数据
|
|
|
- await _mes_process.InsertMany(processes);
|
|
|
- }
|
|
|
+ //同步供应商数据
|
|
|
+ var suppliers = await _mysql_srm_supplier.GetListAsync();
|
|
|
+ if (suppliers.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _srm_supplier.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _srm_supplier.InsertMany(suppliers);
|
|
|
+ }
|
|
|
|
|
|
- //同步工艺关联工序数据
|
|
|
- var tech_procs = await _mysql_mes_tech_process.GetListAsync();
|
|
|
- if (tech_procs.Count > 0)
|
|
|
- {
|
|
|
- //先清空表数据(删除mongodb中的集合)
|
|
|
- await _mes_tech_process.DeleteAll();
|
|
|
- //插入数据
|
|
|
- await _mes_tech_process.InsertMany(tech_procs);
|
|
|
- }
|
|
|
+ //同步工艺路径数据
|
|
|
+ var techs = await _mysql_mes_technique.GetListAsync();
|
|
|
+ if (techs.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _mes_technique.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _mes_technique.InsertMany(techs);
|
|
|
+ }
|
|
|
|
|
|
- result.end = DateTime.Now;
|
|
|
- result.isSuccess = true;
|
|
|
- return result;
|
|
|
+ //同步工序数据
|
|
|
+ var processes = await _mysql_mes_process.GetListAsync();
|
|
|
+ if (suppliers.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _mes_process.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _mes_process.InsertMany(processes);
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
+
|
|
|
+ //同步工艺关联工序数据
|
|
|
+ var tech_procs = await _mysql_mes_tech_process.GetListAsync();
|
|
|
+ if (tech_procs.Count > 0)
|
|
|
{
|
|
|
- result.end = DateTime.Now;
|
|
|
- result.isSuccess = false;
|
|
|
- result.msg = ex.Message;
|
|
|
- return result;
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _mes_tech_process.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _mes_tech_process.InsertMany(tech_procs);
|
|
|
}
|
|
|
}
|
|
|
}
|