|
|
@@ -0,0 +1,292 @@
|
|
|
+using Microsoft.EntityFrameworkCore;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Linq.Dynamic.Core;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using Volo.Abp.Application.Dtos;
|
|
|
+using Volo.Abp.Domain.Repositories;
|
|
|
+using Business.Models;
|
|
|
+using Microsoft.AspNetCore.Authorization;
|
|
|
+using Business.Permissions;
|
|
|
+using XCZ;
|
|
|
+using Business.ResourceExamineManagement.Dto;
|
|
|
+using Bussiness.Model.MES.IC;
|
|
|
+using AutoMapper.Internal.Mappers;
|
|
|
+using Bussiness.Model.Tech;
|
|
|
+using Bussiness.Model.Production;
|
|
|
+using Business.Core.MongoDBHelper;
|
|
|
+using Business.Core.Utilities;
|
|
|
+using Hangfire.Storage.Monitoring;
|
|
|
+using Business.BookManagement.Dto;
|
|
|
+using Volo.Abp.ObjectMapping;
|
|
|
+using Volo.Abp.Application.Services;
|
|
|
+using ZstdSharp.Unsafe;
|
|
|
+using System.Transactions;
|
|
|
+using NUglify.JavaScript.Syntax;
|
|
|
+using System.Linq.Expressions;
|
|
|
+using XCZ.Extensions;
|
|
|
+using System.ComponentModel;
|
|
|
+using System.Reflection.Emit;
|
|
|
+using NUglify.Helpers;
|
|
|
+using Microsoft.AspNetCore.SignalR.Protocol;
|
|
|
+using System.ComponentModel.Design;
|
|
|
+using Volo.Abp.Validation.StringValues;
|
|
|
+using System.Runtime.CompilerServices;
|
|
|
+using MongoDB.Driver;
|
|
|
+using Volo.Abp.Validation.Localization;
|
|
|
+using Hangfire.Annotations;
|
|
|
+using System.Globalization;
|
|
|
+using MongoDB.Driver.Linq;
|
|
|
+using Bussiness.Model.SRM;
|
|
|
+using System.ComponentModel.DataAnnotations;
|
|
|
+using Bussiness.Model.Sale;
|
|
|
+using Amazon.Runtime.Internal.Transform;
|
|
|
+using System.IO.Compression;
|
|
|
+using System.Collections;
|
|
|
+using System.Data.SqlTypes;
|
|
|
+using Bussiness.Model.SystemData;
|
|
|
+
|
|
|
+namespace Business.ScheduleTaskManagement
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// 资源检查
|
|
|
+ /// </summary>
|
|
|
+ public class ScheduleTaskAppService : ApplicationService, IScheduleTaskAppService
|
|
|
+ {
|
|
|
+ #region 服务
|
|
|
+ /// <summary>
|
|
|
+ /// 物料bom
|
|
|
+ /// </summary>
|
|
|
+ private readonly IMongoDB<ic_bom> _ic_bom;
|
|
|
+ private IRepository<ic_bom, long> _mysql_ic_bom;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 物料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> _ic_item;
|
|
|
+ private IRepository<ic_item, long> _mysql_ic_item;
|
|
|
+
|
|
|
+ /// <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<srm_supplier> _srm_supplier;
|
|
|
+ private IRepository<srm_supplier, long> _mysql_srm_supplier;
|
|
|
+
|
|
|
+ /// <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;
|
|
|
+ #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,
|
|
|
+ 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<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_tech_process = 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>
|
|
|
+ /// 同步基础数据到mongodb
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ /// <exception cref="NotImplementedException"></exception>
|
|
|
+ public async Task<ResultDto> SyncBaseDataToMongoDB()
|
|
|
+ {
|
|
|
+ //数据同步返回结果
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|