|
|
@@ -45,6 +45,7 @@ using Amazon.Runtime.Internal.Transform;
|
|
|
using System.IO.Compression;
|
|
|
using System.Collections;
|
|
|
using System.Data.SqlTypes;
|
|
|
+using Bussiness.Model.SystemData;
|
|
|
|
|
|
namespace Business.ScheduleTaskManagement
|
|
|
{
|
|
|
@@ -55,217 +56,112 @@ namespace Business.ScheduleTaskManagement
|
|
|
{
|
|
|
#region 服务
|
|
|
/// <summary>
|
|
|
- /// 工艺路径
|
|
|
- /// </summary>
|
|
|
- private readonly IMongoDB<mes_technique> _mes_technique;
|
|
|
- private IRepository<mes_technique, long> _mysql_mes_technique;
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 工序
|
|
|
- /// </summary>
|
|
|
- private readonly IMongoDB<mes_process> _mes_process;
|
|
|
- private IRepository<mes_process, long> _mysql_mes_process;
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 工艺关联工序
|
|
|
- /// </summary>
|
|
|
- private readonly IMongoDB<mes_tech_process> _mes_tech_process;
|
|
|
- private IRepository<mes_tech_process, long> _mysql_mes_tech_process;
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 工作日历
|
|
|
- /// </summary>
|
|
|
- private readonly IMongoDB<mes_work_calendar> _mes_work_calendar;
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 工作日历明细
|
|
|
- /// </summary>
|
|
|
- private readonly IMongoDB<mes_work_calendar_list> _mes_work_calendar_list;
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 工艺工序关联工位
|
|
|
- /// </summary>
|
|
|
- private readonly IMongoDB<mes_tech_proc_workshop> _mes_tech_proc_workshop;
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 排程占用记录
|
|
|
- /// </summary>
|
|
|
- private readonly IMongoDB<mes_schedule_occupy> _mes_schedule_occupy;
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 物料占用记录
|
|
|
- /// </summary>
|
|
|
- private readonly IMongoDB<ic_item_stockoccupy> _ic_item_stockoccupy;
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 物料详情
|
|
|
- /// </summary>
|
|
|
- private readonly IMongoDB<ic_item> _ic_item;
|
|
|
- private IRepository<ic_item, long> _mysql_ic_item;
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 物料BOM
|
|
|
+ /// 物料bom
|
|
|
/// </summary>
|
|
|
private readonly IMongoDB<ic_bom> _ic_bom;
|
|
|
private IRepository<ic_bom, long> _mysql_ic_bom;
|
|
|
+
|
|
|
/// <summary>
|
|
|
- /// 物料BOM明细
|
|
|
+ /// 物料bom子表
|
|
|
/// </summary>
|
|
|
private readonly IMongoDB<ic_bom_child> _ic_bom_child;
|
|
|
private IRepository<ic_bom_child, long> _mysql_ic_bom_child;
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 物料库存表
|
|
|
- /// </summary>
|
|
|
- private readonly IMongoDB<ic_item_stock> _ic_item_stock;
|
|
|
- private IRepository<ic_item_stock, long> _mysql_ic_item_stock;
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 物料工厂明细表
|
|
|
+ /// 物料
|
|
|
/// </summary>
|
|
|
- private readonly IMongoDB<ic_factory_details> _ic_factory_details;
|
|
|
- private IRepository<ic_factory_details, long> _mysql_ic_factory_details;
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 采购申请单
|
|
|
- /// </summary>
|
|
|
- private readonly IMongoDB<srm_pr_main> _srm_pr_main;
|
|
|
- private IRepository<srm_pr_main, long> _mysql_srm_pr_main;
|
|
|
-
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 委外工单
|
|
|
- /// </summary>
|
|
|
- private readonly IMongoDB<mes_oorder> _mes_oorder;
|
|
|
- private IRepository<mes_oorder, long> _mysql_mes_oorder;
|
|
|
+ private readonly IMongoDB<ic_item> _ic_item;
|
|
|
+ private IRepository<ic_item, long> _mysql_ic_item;
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 物料质检表
|
|
|
- /// </summary>
|
|
|
- private readonly IMongoDB<ic_check> _ic_check;
|
|
|
/// <summary>
|
|
|
/// 替代群组
|
|
|
/// </summary>
|
|
|
private readonly IMongoDB<ic_substitute> _ic_substitute;
|
|
|
+ private IRepository<ic_substitute, long> _mysql_ic_substitute;
|
|
|
+
|
|
|
/// <summary>
|
|
|
- /// 替代群组
|
|
|
+ /// 物料替代多群组
|
|
|
/// </summary>
|
|
|
private readonly IMongoDB<ic_substitute_all> _ic_substitute_all;
|
|
|
+ private IRepository<ic_substitute_all, long> _mysql_ic_substitute_all;
|
|
|
+
|
|
|
/// <summary>
|
|
|
- /// 替代群组
|
|
|
+ /// 物料替代多群组明细
|
|
|
/// </summary>
|
|
|
private readonly IMongoDB<ic_substitute_all_dtl> _ic_substitute_all_dtl;
|
|
|
+ private IRepository<ic_substitute_all_dtl, long> _mysql_ic_substitute_all_dtl;
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 生产工单主表
|
|
|
- /// </summary>
|
|
|
- private readonly IMongoDB<mes_morder> _mes_morder;
|
|
|
- /// <summary>
|
|
|
- /// 生产工单子表
|
|
|
+ /// 供应商
|
|
|
/// </summary>
|
|
|
- private readonly IMongoDB<mes_moentry> _mes_moentry;
|
|
|
+ private readonly IMongoDB<srm_supplier> _srm_supplier;
|
|
|
+ private IRepository<srm_supplier, long> _mysql_srm_supplier;
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 在制工单占用记录表
|
|
|
- /// </summary>
|
|
|
- private readonly IMongoDB<mes_mooccupy> _mes_mooccupy;
|
|
|
- /// <summary>
|
|
|
- /// mysql在制工单占用表
|
|
|
- /// </summary>
|
|
|
- private readonly IRepository<mes_mooccupy, long> _mysql_mes_mooccupy;
|
|
|
- /// <summary>
|
|
|
- /// 销售工单
|
|
|
- /// </summary>
|
|
|
- private readonly IRepository<crm_seorder, long> _mysql_crm_seorder;
|
|
|
- /// <summary>
|
|
|
- /// 销售工单
|
|
|
+ /// 工艺路径
|
|
|
/// </summary>
|
|
|
- private readonly IRepository<crm_seorderentry, long> _mysql_crm_seorderentry;
|
|
|
+ private readonly IMongoDB<mes_technique> _mes_technique;
|
|
|
+ private IRepository<mes_technique, long> _mysql_mes_technique;
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 生产工单主表
|
|
|
+ /// 工序
|
|
|
/// </summary>
|
|
|
- private readonly IRepository<mes_morder, long> _mysql_mes_morder;
|
|
|
+ private readonly IMongoDB<mes_process> _mes_process;
|
|
|
+ private IRepository<mes_process, long> _mysql_mes_process;
|
|
|
+
|
|
|
/// <summary>
|
|
|
- /// 生产工单子表
|
|
|
+ /// 工艺路径关联工序
|
|
|
/// </summary>
|
|
|
- private readonly IRepository<mes_moentry, long> _mysql_mes_moentry;
|
|
|
+ private readonly IMongoDB<mes_tech_process> _mes_tech_process;
|
|
|
+ private IRepository<mes_tech_process, long> _mysql_mes_tech_process;
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
|
/// 构造函数
|
|
|
/// </summary>
|
|
|
public ScheduleTaskAppService(
|
|
|
+ IMongoDB<ic_bom> ic_bom,
|
|
|
+ IMongoDB<ic_bom_child> ic_bom_child,
|
|
|
+ IMongoDB<ic_item> ic_item,
|
|
|
+ IMongoDB<ic_substitute> ic_substitute,
|
|
|
+ IMongoDB<ic_substitute_all> ic_substitute_all,
|
|
|
+ IMongoDB<ic_substitute_all_dtl> ic_substitute_all_dtl,
|
|
|
+ IMongoDB<srm_supplier> srm_supplier,
|
|
|
IMongoDB<mes_technique> mes_technique,
|
|
|
IMongoDB<mes_process> mes_process,
|
|
|
IMongoDB<mes_tech_process> mes_tech_process,
|
|
|
- IMongoDB<mes_tech_proc_workshop> mes_tech_proc_workshop,
|
|
|
- IMongoDB<ic_item> ic_item,
|
|
|
- IMongoDB<ic_bom> ic_bom,
|
|
|
- IMongoDB<ic_bom_child> ic_bom_child,
|
|
|
- IMongoDB<ic_item_stock> ic_item_stock,
|
|
|
- IMongoDB<ic_check> ic_check,
|
|
|
- IMongoDB<ic_factory_details> ic_factory_details,
|
|
|
- IMongoDB<mes_oorder> mes_oorder,
|
|
|
- IMongoDB<srm_pr_main> srm_pr_main,
|
|
|
- //IMongoDB<ic_substitute> ic_substitute,
|
|
|
- //IMongoDB<ic_substitute_all> ic_substitute_all,
|
|
|
- //IMongoDB<ic_substitute_all_dtl> ic_substitute_all_dtl,
|
|
|
- IMongoDB<mes_morder> mes_morder,
|
|
|
- IMongoDB<mes_moentry> mes_moentry,
|
|
|
- IMongoDB<mes_mooccupy> mes_mooccupy,
|
|
|
- IMongoDB<ic_item_stockoccupy> ic_item_stockoccupy,
|
|
|
- IRepository<ic_item, long> mysql_ic_item,
|
|
|
IRepository<ic_bom, long> mysql_ic_bom,
|
|
|
IRepository<ic_bom_child, long> mysql_ic_bom_child,
|
|
|
+ IRepository<ic_item, long> mysql_ic_item,
|
|
|
+ IRepository<ic_substitute, long> mysql_ic_substitute,
|
|
|
+ IRepository<ic_substitute_all, long> mysql_ic_substitute_all,
|
|
|
+ IRepository<ic_substitute_all_dtl, long> mysql_ic_substitute_all_dtl,
|
|
|
+ IRepository<srm_supplier, long> mysql_srm_supplier,
|
|
|
IRepository<mes_technique, long> mysql_mes_technique,
|
|
|
- IRepository<crm_seorder, long> mysql_crm_seorder,
|
|
|
- IRepository<crm_seorderentry, long> mysql_crm_seorderentry,
|
|
|
- IRepository<ic_item_stock, long> mysql_ic_item_stock,
|
|
|
- IRepository<ic_factory_details, long> mysql_ic_factory_details,
|
|
|
- IRepository<mes_oorder, long> mysql_mes_oorder,
|
|
|
- IRepository<srm_pr_main, long> mysql_srm_pr_main,
|
|
|
- IRepository<mes_mooccupy, long> mysql_mes_mooccupy,
|
|
|
- IRepository<mes_morder, long> mysql_mes_morder,
|
|
|
- IRepository<mes_moentry, long> mysql_mes_moentry,
|
|
|
IRepository<mes_process, long> mysql_mes_process,
|
|
|
IRepository<mes_tech_process, long> mysql_mes_tech_process
|
|
|
)
|
|
|
{
|
|
|
+ _ic_bom= ic_bom;
|
|
|
+ _ic_bom_child= ic_bom_child;
|
|
|
+ _ic_item= ic_item;
|
|
|
+ _ic_substitute= ic_substitute;
|
|
|
+ _ic_substitute_all= ic_substitute_all;
|
|
|
+ _ic_substitute_all_dtl= ic_substitute_all_dtl;
|
|
|
+ _srm_supplier= srm_supplier;
|
|
|
_mes_technique = mes_technique;
|
|
|
- _mes_process = mes_process;
|
|
|
+ _mes_process= mes_process;
|
|
|
_mes_tech_process = mes_tech_process;
|
|
|
- _mes_tech_proc_workshop = mes_tech_proc_workshop;
|
|
|
- _ic_item = ic_item;
|
|
|
- _ic_bom = ic_bom;
|
|
|
- _ic_bom_child = ic_bom_child;
|
|
|
- _ic_item_stock = ic_item_stock;
|
|
|
- _ic_check = ic_check;
|
|
|
- _ic_factory_details = ic_factory_details;
|
|
|
- _mes_oorder = mes_oorder;
|
|
|
- _srm_pr_main = srm_pr_main;
|
|
|
- //_ic_substitute = ic_substitute;
|
|
|
- //_ic_substitute_all = ic_substitute_all;
|
|
|
- //_ic_substitute_all_dtl = ic_substitute_all_dtl;
|
|
|
- _mes_morder = mes_morder;
|
|
|
- _mes_moentry = mes_moentry;
|
|
|
- _mes_mooccupy = mes_mooccupy;
|
|
|
- _ic_item_stockoccupy = ic_item_stockoccupy;
|
|
|
- _mysql_ic_item = mysql_ic_item;
|
|
|
- _mysql_ic_bom = mysql_ic_bom;
|
|
|
- _mysql_ic_bom_child = mysql_ic_bom_child;
|
|
|
- _mysql_crm_seorder = mysql_crm_seorder;
|
|
|
- _mysql_crm_seorderentry = mysql_crm_seorderentry;
|
|
|
- _mysql_mes_technique = mysql_mes_technique;
|
|
|
- _mysql_ic_item_stock = mysql_ic_item_stock;
|
|
|
- _mysql_ic_factory_details = mysql_ic_factory_details;
|
|
|
- _mysql_mes_oorder = mysql_mes_oorder;
|
|
|
- _mysql_srm_pr_main = mysql_srm_pr_main;
|
|
|
- _mysql_mes_mooccupy = mysql_mes_mooccupy;
|
|
|
- _mysql_mes_morder = mysql_mes_morder;
|
|
|
- _mysql_mes_moentry = mysql_mes_moentry;
|
|
|
- _mysql_mes_process = mysql_mes_process;
|
|
|
- _mysql_mes_tech_process = mysql_mes_tech_process;
|
|
|
+ _mysql_ic_bom= mysql_ic_bom;
|
|
|
+ _mysql_ic_bom_child= mysql_ic_bom_child;
|
|
|
+ _mysql_ic_item= mysql_ic_item;
|
|
|
+ _mysql_ic_substitute= mysql_ic_substitute;
|
|
|
+ _mysql_ic_substitute_all= mysql_ic_substitute_all;
|
|
|
+ _mysql_ic_substitute_all_dtl= mysql_ic_substitute_all_dtl;
|
|
|
+ _mysql_srm_supplier= mysql_srm_supplier;
|
|
|
+ _mysql_mes_technique= mysql_mes_technique;
|
|
|
+ _mysql_mes_process= mysql_mes_process;
|
|
|
+ _mysql_mes_tech_process= mysql_mes_tech_process;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -273,9 +169,124 @@ namespace Business.ScheduleTaskManagement
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
|
- public async Task SyncBaseDataToMongoDB()
|
|
|
+ public async Task<ResultDto> SyncBaseDataToMongoDB()
|
|
|
{
|
|
|
- throw new NotImplementedException();
|
|
|
+ //数据同步返回结果
|
|
|
+ ResultDto result = new ResultDto();
|
|
|
+ result.start = DateTime.Now;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //同步物料Bom数据
|
|
|
+ var icBoms = _mysql_ic_bom.GetListAsync().Result;
|
|
|
+ if (icBoms.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _ic_bom.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _ic_bom.InsertMany(icBoms);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步物料BOM明细数据
|
|
|
+ var icbom_childs = _mysql_ic_bom_child.GetListAsync().Result;
|
|
|
+ if (icbom_childs.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _ic_bom_child.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _ic_bom_child.InsertMany(icbom_childs);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步物料数据
|
|
|
+ var icItems = _mysql_ic_item.GetListAsync().Result;
|
|
|
+ if (icItems.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _ic_item.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _ic_item.InsertMany(icItems);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步替代群组数据
|
|
|
+ var subtitutes = _mysql_ic_substitute.GetListAsync().Result;
|
|
|
+ if (subtitutes.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _ic_substitute.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _ic_substitute.InsertMany(subtitutes);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步物料替代多群组数据
|
|
|
+ var subAlls = _mysql_ic_substitute_all.GetListAsync().Result;
|
|
|
+ if (subAlls.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _ic_substitute_all.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _ic_substitute_all.InsertMany(subAlls);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步物料替代多群组明细数据
|
|
|
+ var subAllDtls = _mysql_ic_substitute_all_dtl.GetListAsync().Result;
|
|
|
+ if (subAllDtls.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _ic_substitute_all_dtl.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _ic_substitute_all_dtl.InsertMany(subAllDtls);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步供应商数据
|
|
|
+ var suppliers = _mysql_srm_supplier.GetListAsync().Result;
|
|
|
+ if (suppliers.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _srm_supplier.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _srm_supplier.InsertMany(suppliers);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步工艺路径数据
|
|
|
+ var techs = _mysql_mes_technique.GetListAsync().Result;
|
|
|
+ if (techs.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _mes_technique.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _mes_technique.InsertMany(techs);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步工序数据
|
|
|
+ var processes = _mysql_mes_process.GetListAsync().Result;
|
|
|
+ if (suppliers.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _mes_process.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _mes_process.InsertMany(processes);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步工艺关联工序数据
|
|
|
+ var tech_procs = _mysql_mes_tech_process.GetListAsync().Result;
|
|
|
+ if (tech_procs.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据(删除mongodb中的集合)
|
|
|
+ await _mes_tech_process.DeleteAll();
|
|
|
+ //插入数据
|
|
|
+ await _mes_tech_process.InsertMany(tech_procs);
|
|
|
+ }
|
|
|
+
|
|
|
+ result.end = DateTime.Now;
|
|
|
+ result.isSuccess = true;
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ result.end = DateTime.Now;
|
|
|
+ result.isSuccess = false;
|
|
|
+ result.msg = ex.Message;
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|