|
|
@@ -0,0 +1,944 @@
|
|
|
+using Abp.Application.Services;
|
|
|
+using Abp.Dependency;
|
|
|
+using Business.Core.MongoDBHelper;
|
|
|
+using Business.Core.Utilities;
|
|
|
+using Business.EntityFrameworkCore;
|
|
|
+using Business.EntityFrameworkCore.SqlRepositories;
|
|
|
+using Business.Model.MES.IC;
|
|
|
+using Business.Model.Sale;
|
|
|
+using Business.Model.SRM;
|
|
|
+using Business.Model.Tech;
|
|
|
+using Business.MongoModel.MES.IC;
|
|
|
+using Business.MongoModel.SRM;
|
|
|
+using Business.MongoModel.Tech;
|
|
|
+using Business.SystemJob;
|
|
|
+using EFCore.BulkExtensions;
|
|
|
+using NLog;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using Volo.Abp.Domain.Repositories;
|
|
|
+
|
|
|
+namespace Business.SystemJobManagement
|
|
|
+{
|
|
|
+ public class SystemJobAppService : ApplicationService, ISystemJobAppService
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// 物料bom
|
|
|
+ /// </summary>
|
|
|
+ private IRepository<ic_bom, long> _mysql_ic_bom;
|
|
|
+ private readonly IMongoDB<mo_ic_bom> _ic_bom;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 物料bom子表
|
|
|
+ /// </summary>
|
|
|
+ private IRepository<ic_bom_child, long> _mysql_ic_bom_child;
|
|
|
+ private readonly IMongoDB<mo_ic_bom_child> _ic_bom_child;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 物料
|
|
|
+ /// </summary>
|
|
|
+ private IRepository<ic_item, long> _mysql_ic_item;
|
|
|
+ private readonly IMongoDB<mo_ic_item> _ic_item;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 供应商
|
|
|
+ /// </summary>
|
|
|
+ private IRepository<srm_supplier, long> _mysql_srm_supplier;
|
|
|
+ private readonly IMongoDB<mo_srm_supplier> _srm_supplier;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 物料采购报价单
|
|
|
+ /// </summary>
|
|
|
+ private IRepository<srm_purchase, long> _mysql_srm_purchase;
|
|
|
+ private readonly IMongoDB<mo_srm_purchase> _srm_purchase;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 物料采购报价单
|
|
|
+ /// </summary>
|
|
|
+ private IRepository<crm_customer, long> _mysql_crm_customer;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 销售订单
|
|
|
+ /// </summary>
|
|
|
+ private IRepository<crm_seorder, long> _mysql_crm_seorder;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 销售订单明细
|
|
|
+ /// </summary>
|
|
|
+ private IRepository<crm_seorderentry, long> _mysql_crm_seorderentry;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 雪花算法
|
|
|
+ /// </summary>
|
|
|
+ SnowFlake help = new SnowFlake();
|
|
|
+ private readonly BusinessDbContext _businessDbContext;
|
|
|
+ private readonly ISqlRepository<CustMaster> _custMaster;
|
|
|
+ private readonly ISqlRepository<SuppMaster> _suppMaster;
|
|
|
+ private readonly ISqlRepository<ConsigneeAddressMaster> _consigneeAddressMaster;
|
|
|
+ private readonly ISqlRepository<ItemMaster> _itemMaster;
|
|
|
+ private readonly ISqlRepository<ProductStructureMaster> _productStructureMaster;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 替代群组
|
|
|
+ /// </summary>
|
|
|
+ private readonly IMongoDB<mo_ic_substitute> _ic_substitute;
|
|
|
+ private IRepository<ic_substitute, long> _mysql_ic_substitute;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 物料替代多群组
|
|
|
+ /// </summary>
|
|
|
+ private readonly IMongoDB<mo_ic_substitute_group> _ic_substitute_group;
|
|
|
+ private IRepository<ic_substitute_group, long> _mysql_ic_substitute_group;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 物料替代多群组明细
|
|
|
+ /// </summary>
|
|
|
+ private readonly IMongoDB<mo_ic_substitute_group_detail> _ic_substitute_group_detail;
|
|
|
+ private IRepository<ic_substitute_group_detail, long> _mysql_ic_substitute_group_detail;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 工艺路径
|
|
|
+ /// </summary>
|
|
|
+ private readonly IMongoDB<mo_mes_technique> _mes_technique;
|
|
|
+ private IRepository<mes_technique, long> _mysql_mes_technique;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 工序
|
|
|
+ /// </summary>
|
|
|
+ private readonly IMongoDB<mo_mes_process> _mes_process;
|
|
|
+ private IRepository<mes_process, long> _mysql_mes_process;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 工艺路径关联工序
|
|
|
+ /// </summary>
|
|
|
+ private readonly IMongoDB<mo_mes_tech_process> _mes_tech_process;
|
|
|
+ private IRepository<mes_tech_process, long> _mysql_mes_tech_process;
|
|
|
+
|
|
|
+ public SystemJobAppService(
|
|
|
+ IRepository<ic_bom, long> mysql_ic_bom,
|
|
|
+ IRepository<ic_bom_child, long> mysql_ic_bom_child,
|
|
|
+ IRepository<ic_item, long> mysql_ic_item,
|
|
|
+ IRepository<srm_supplier, long> mysql_srm_supplier,
|
|
|
+ IRepository<srm_purchase, long> mysql_srm_purchase,
|
|
|
+ IRepository<crm_customer, long> mysql_crm_customer,
|
|
|
+ IRepository<crm_seorder, long> mysql_crm_seorder,
|
|
|
+ IRepository<crm_seorderentry, long> mysql_crm_seorderentry,
|
|
|
+ IRepository<ic_substitute, long> mysql_ic_substitute,
|
|
|
+ IRepository<ic_substitute_group, long> mysql_ic_substitute_group,
|
|
|
+ IRepository<ic_substitute_group_detail, long> mysql_ic_substitute_group_detail,
|
|
|
+ IRepository<mes_technique, long> mysql_mes_technique,
|
|
|
+ IRepository<mes_process, long> mysql_mes_process,
|
|
|
+ IRepository<mes_tech_process, long> mysql_mes_tech_process,
|
|
|
+ ISqlRepository<CustMaster> custMaster,
|
|
|
+ ISqlRepository<SuppMaster> suppMaster,
|
|
|
+ ISqlRepository<ConsigneeAddressMaster> consigneeAddressMaster,
|
|
|
+ ISqlRepository<ItemMaster> itemMaster,
|
|
|
+ ISqlRepository<ProductStructureMaster> productStructureMaster,
|
|
|
+ IMongoDB<mo_ic_bom> ic_bom,
|
|
|
+ IMongoDB<mo_ic_bom_child> ic_bom_child,
|
|
|
+ IMongoDB<mo_ic_item> ic_item,
|
|
|
+ IMongoDB<mo_ic_substitute> ic_substitute,
|
|
|
+ IMongoDB<mo_ic_substitute_group> ic_substitute_group,
|
|
|
+ IMongoDB<mo_ic_substitute_group_detail> ic_substitute_group_detail,
|
|
|
+ IMongoDB<mo_srm_supplier> srm_supplier,
|
|
|
+ IMongoDB<mo_mes_technique> mes_technique,
|
|
|
+ IMongoDB<mo_mes_process> mes_process,
|
|
|
+ IMongoDB<mo_mes_tech_process> mes_tech_process,
|
|
|
+ IMongoDB<mo_srm_purchase> srm_purchase,
|
|
|
+ BusinessDbContext businessDbContext
|
|
|
+ )
|
|
|
+ {
|
|
|
+ _mysql_ic_bom = mysql_ic_bom;
|
|
|
+ _mysql_ic_bom_child = mysql_ic_bom_child;
|
|
|
+ _mysql_ic_item = mysql_ic_item;
|
|
|
+ _mysql_srm_supplier = mysql_srm_supplier;
|
|
|
+ _mysql_srm_purchase = mysql_srm_purchase;
|
|
|
+ _mysql_crm_customer = mysql_crm_customer;
|
|
|
+ _mysql_crm_seorder = mysql_crm_seorder;
|
|
|
+ _mysql_crm_seorderentry = mysql_crm_seorderentry;
|
|
|
+ _mysql_ic_substitute = mysql_ic_substitute;
|
|
|
+ _mysql_ic_substitute_group = mysql_ic_substitute_group;
|
|
|
+ _mysql_ic_substitute_group_detail = mysql_ic_substitute_group_detail;
|
|
|
+ _mysql_mes_technique = mysql_mes_technique;
|
|
|
+ _mysql_mes_process = mysql_mes_process;
|
|
|
+ _mysql_mes_tech_process = mysql_mes_tech_process;
|
|
|
+ _custMaster = custMaster;
|
|
|
+ _suppMaster = suppMaster;
|
|
|
+ _consigneeAddressMaster = consigneeAddressMaster;
|
|
|
+ _itemMaster = itemMaster;
|
|
|
+ _productStructureMaster = productStructureMaster;
|
|
|
+ _ic_bom = ic_bom;
|
|
|
+ _ic_bom_child = ic_bom_child;
|
|
|
+ _ic_item = ic_item;
|
|
|
+ _ic_substitute = ic_substitute;
|
|
|
+ _ic_substitute_group = ic_substitute_group;
|
|
|
+ _ic_substitute_group_detail = ic_substitute_group_detail;
|
|
|
+ _srm_supplier = srm_supplier;
|
|
|
+ _mes_technique = mes_technique;
|
|
|
+ _mes_process = mes_process;
|
|
|
+ _mes_tech_process = mes_tech_process;
|
|
|
+ _srm_purchase = srm_purchase;
|
|
|
+ _businessDbContext = businessDbContext;
|
|
|
+ }
|
|
|
+
|
|
|
+ public string SyncWMSDataToMySQL()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //SyncCustMaster();
|
|
|
+ //SyncSuppMaster();
|
|
|
+ //SyncSalesOrdMaster();
|
|
|
+ //SyncSalesOrdMasterEntry();
|
|
|
+ //SyncItemMaster();
|
|
|
+ //SyncBom();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return ex.Message;
|
|
|
+ }
|
|
|
+ return "同步完成";
|
|
|
+ }
|
|
|
+
|
|
|
+ public string LogInstall()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ LogManager.Configuration.Install(new NLog.Config.InstallationContext());//每天0点执行一次
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return ex.Message;
|
|
|
+ }
|
|
|
+ return "任务执行成功";
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public string SyncBaseDataToMongoDB()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //物料采购报价单
|
|
|
+ //var srm_purchase = _mysql_srm_purchase.GetListAsync().Result;
|
|
|
+ //if (srm_purchase.Count > 0)
|
|
|
+ //{
|
|
|
+ // //先清空表数据
|
|
|
+ // _srm_purchase.Delete(p => p.mysql_id != -1);
|
|
|
+ // List<mo_srm_purchase> mosrm_purchase = ObjectMapper.Map<List<srm_purchase>, List<mo_srm_purchase>>(srm_purchase);
|
|
|
+ // mosrm_purchase.ForEach(s => s.id = help.NextId());
|
|
|
+ // _srm_purchase.InsertMany(mosrm_purchase);
|
|
|
+ //}
|
|
|
+ /*//同步物料BOM明细数据
|
|
|
+ var icbom_childs = _mysql_ic_bom_child.GetListAsync().Result;
|
|
|
+ if (icbom_childs.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据
|
|
|
+ await _ic_bom_child.Delete(p => p.mysql_id != -1);
|
|
|
+ var moIcbom_childs = ObjectMapper.Map<List<ic_bom_child>, List<mo_ic_bom_child>>(icbom_childs);
|
|
|
+ moIcbom_childs.ForEach(s => s.id = help.NextId());
|
|
|
+ //插入数据
|
|
|
+ await _ic_bom_child.InsertMany(moIcbom_childs);
|
|
|
+ }*/
|
|
|
+
|
|
|
+ /*//同步物料Bom数据
|
|
|
+ var icBoms = _mysql_ic_bom.GetListAsync().Result;
|
|
|
+ if (icBoms.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据
|
|
|
+ await _ic_bom.Delete(p => p.mysql_id != -1);
|
|
|
+ var moIcBoms = ObjectMapper.Map<List<ic_bom>, List<mo_ic_bom>>(icBoms);
|
|
|
+ moIcBoms.ForEach(s => s.id = help.NextId());
|
|
|
+ //插入数据
|
|
|
+ await _ic_bom.InsertMany(moIcBoms);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步物料BOM明细数据
|
|
|
+ var icbom_childs = _mysql_ic_bom_child.GetListAsync().Result;
|
|
|
+ if (icbom_childs.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据
|
|
|
+ await _ic_bom_child.Delete(p => p.mysql_id != -1);
|
|
|
+ var moIcbom_childs = ObjectMapper.Map<List<ic_bom_child>, List<mo_ic_bom_child>>(icbom_childs);
|
|
|
+ moIcbom_childs.ForEach(s => s.id = help.NextId());
|
|
|
+ //插入数据
|
|
|
+ await _ic_bom_child.InsertMany(moIcbom_childs);
|
|
|
+ }
|
|
|
+
|
|
|
+ ////工厂物料明细表
|
|
|
+ //var ic_factory_details = _mysql_ic_factory_details.GetListAsync().Result;
|
|
|
+ //if (ic_factory_details.Count > 0)
|
|
|
+ //{
|
|
|
+ // //先清空表数据
|
|
|
+ // await _ic_factory_details.Delete(p => p.mysql_id != -1);
|
|
|
+ // var moIc_factory_details = ObjectMapper.Map<List<ic_factory_details>, List<mo_ic_factory_details>>(ic_factory_details);
|
|
|
+ // moIc_factory_details.ForEach(s => s.id = help.NextId());
|
|
|
+ // await _ic_factory_details.InsertMany(moIc_factory_details);
|
|
|
+ //}
|
|
|
+
|
|
|
+ //同步物料数据
|
|
|
+ var icItems = _mysql_ic_item.GetListAsync().Result;
|
|
|
+ if (icItems.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据
|
|
|
+ await _ic_item.Delete(p => p.mysql_id != -1);
|
|
|
+ var moIcItems = ObjectMapper.Map<List<ic_item>, List<mo_ic_item>>(icItems);
|
|
|
+ moIcItems.ForEach(s => s.id = help.NextId());
|
|
|
+ //插入数据
|
|
|
+ await _ic_item.InsertMany(moIcItems);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步替代群组数据
|
|
|
+ var subtitutes = _mysql_ic_substitute.GetListAsync().Result;
|
|
|
+ if (subtitutes.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据
|
|
|
+ await _ic_substitute.Delete(p => p.mysql_id != -1);
|
|
|
+ var moSubtitutes = ObjectMapper.Map<List<ic_substitute>, List<mo_ic_substitute>>(subtitutes);
|
|
|
+ moSubtitutes.ForEach(s => s.id = help.NextId());
|
|
|
+ //插入数据
|
|
|
+ await _ic_substitute.InsertMany(moSubtitutes);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步物料替代多群组数据
|
|
|
+ var subAlls = _mysql_ic_substitute_group.GetListAsync().Result;
|
|
|
+ if (subAlls.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据
|
|
|
+ await _ic_substitute_group.Delete(p => p.mysql_id != -1);
|
|
|
+ var moSubAlls = ObjectMapper.Map<List<ic_substitute_group>, List<mo_ic_substitute_group>>(subAlls);
|
|
|
+ moSubAlls.ForEach(s => s.id = help.NextId());
|
|
|
+ //插入数据
|
|
|
+ await _ic_substitute_group.InsertMany(moSubAlls);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步物料替代多群组明细数据
|
|
|
+ var subAllDtls = _mysql_ic_substitute_group_detail.GetListAsync().Result;
|
|
|
+ if (subAllDtls.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据
|
|
|
+ await _ic_substitute_group_detail.Delete(p => p.mysql_id != -1);
|
|
|
+ var moSubAllDtls = ObjectMapper.Map<List<ic_substitute_group_detail>, List<mo_ic_substitute_group_detail>>(subAllDtls);
|
|
|
+ moSubAllDtls.ForEach(s => s.id = help.NextId());
|
|
|
+ //插入数据
|
|
|
+ await _ic_substitute_group_detail.InsertMany(moSubAllDtls);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步供应商数据
|
|
|
+ var suppliers = _mysql_srm_supplier.GetListAsync().Result;
|
|
|
+ if (suppliers.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据
|
|
|
+ await _srm_supplier.Delete(p => p.mysql_id != -1);
|
|
|
+ var moSuppliers = ObjectMapper.Map<List<srm_supplier>, List<mo_srm_supplier>>(suppliers);
|
|
|
+ moSuppliers.ForEach(s => s.id = help.NextId());
|
|
|
+ //插入数据
|
|
|
+ await _srm_supplier.InsertMany(moSuppliers);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步工艺路径数据
|
|
|
+ var techs = _mysql_mes_technique.GetListAsync().Result;
|
|
|
+ if (techs.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据
|
|
|
+ await _mes_technique.Delete(p => p.mysql_id != -1);
|
|
|
+ var moTechs = ObjectMapper.Map<List<mes_technique>, List<mo_mes_technique>>(techs);
|
|
|
+ moTechs.ForEach(s => s.id = help.NextId());
|
|
|
+ //插入数据
|
|
|
+ await _mes_technique.InsertMany(moTechs);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步工序数据
|
|
|
+ var processes = _mysql_mes_process.GetListAsync().Result;
|
|
|
+ if (suppliers.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据
|
|
|
+ await _mes_process.Delete(p => p.mysql_id != -1);
|
|
|
+ var moProcesses = ObjectMapper.Map<List<mes_process>, List<mo_mes_process>>(processes);
|
|
|
+ moProcesses.ForEach(s => s.id = help.NextId());
|
|
|
+ //插入数据
|
|
|
+ await _mes_process.InsertMany(moProcesses);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步工艺关联工序数据
|
|
|
+ var tech_procs = _mysql_mes_tech_process.GetListAsync().Result;
|
|
|
+ if (tech_procs.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据
|
|
|
+ await _mes_tech_process.Delete(p => p.mysql_id != -1);
|
|
|
+ var moTech_procs = ObjectMapper.Map<List<mes_tech_process>, List<mo_mes_tech_process>>(tech_procs);
|
|
|
+ moTech_procs.ForEach(s => s.id = help.NextId());
|
|
|
+ //插入数据
|
|
|
+ await _mes_tech_process.InsertMany(moTech_procs);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ////物料采购计划表
|
|
|
+ //var ic_plan = _mysql_ic_plan.GetListAsync().Result;
|
|
|
+ //if (ic_plan.Count > 0)
|
|
|
+ //{
|
|
|
+ // //先清空表数据
|
|
|
+ // await _ic_plan.Delete(p => p.mysql_id != -1);
|
|
|
+ // var moIc_plan = ObjectMapper.Map<List<ic_plan>, List<mo_ic_plan>>(ic_plan);
|
|
|
+ // moIc_plan.ForEach(s => s.id = help.NextId());
|
|
|
+ // await _ic_plan.InsertMany(moIc_plan);
|
|
|
+ //}
|
|
|
+
|
|
|
+ //物料采购报价单
|
|
|
+ var srm_purchase = _mysql_srm_purchase.GetListAsync().Result;
|
|
|
+ if (srm_purchase.Count > 0)
|
|
|
+ {
|
|
|
+ //先清空表数据
|
|
|
+ await _srm_purchase.Delete(p => p.mysql_id != -1);
|
|
|
+ var mosrm_purchase = ObjectMapper.Map<List<srm_purchase>, List<mo_srm_purchase>>(srm_purchase);
|
|
|
+ mosrm_purchase.ForEach(s => s.id = help.NextId());
|
|
|
+ await _srm_purchase.InsertMany(mosrm_purchase);
|
|
|
+ }*/
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return ex.Message;
|
|
|
+ }
|
|
|
+ return "任务执行成功";
|
|
|
+ }
|
|
|
+
|
|
|
+ ////同步客户
|
|
|
+ //public void SyncCustMaster()
|
|
|
+ //{
|
|
|
+ // var customerList = _mysql_crm_customer.GetListAsync().Result;
|
|
|
+ // List<CustMaster> custList = _custMaster.Select(a => a.Domain == "1001" && a.IsActive);
|
|
|
+ // var addressList = _consigneeAddressMaster.Select(a => a.Domain == "1001" && a.Typed == "Cust" && a.IsActive);
|
|
|
+ // List<crm_customer> ItemsAdd = new List<crm_customer>();
|
|
|
+ // if (custList != null && custList.Count > 0)
|
|
|
+ // {
|
|
|
+ // for (int i = 0; i < custList.Count; i++)
|
|
|
+ // {
|
|
|
+ // long domain = Convert.ToInt64(custList[i].Domain);
|
|
|
+ // long factory_id = domain % 1000;
|
|
|
+ // long tenant_id = domain - factory_id;
|
|
|
+ // var cust = customerList.Find(x => x.customer_no == custList[i].Cust && x.tenant_id == 1000 && x.factory_id == 1001);
|
|
|
+ // if (cust is null)
|
|
|
+ // {
|
|
|
+ // ConsigneeAddressMaster address = addressList.Find(a => a.Address == custList[i].Cust);
|
|
|
+ // var customer = new crm_customer
|
|
|
+ // {
|
|
|
+ // customer_no = custList[i].Cust,
|
|
|
+ // customer_name = address is null ? address.Name : "",
|
|
|
+ // telephone = address is null ? address.Telephone : "",
|
|
|
+ // email = address is null ? address.AttentionEmail : "",
|
|
|
+ // contact = address is null ? address.Attention1 : "",
|
|
|
+ // post_code = address is null ? address.Post : "",
|
|
|
+ // country = address is null ? address.Country : "",
|
|
|
+ // province = address is null ? address.State : "",
|
|
|
+ // city = address is null ? address.City : "",
|
|
|
+ // region = address is null ? address.State : "",
|
|
|
+ // address = address is null ? address.Address1 : "",
|
|
|
+ // short_name = custList[i].SortName,
|
|
|
+ // carrying_aos = Convert.ToInt32(custList[i].CustShippingLT),
|
|
|
+ // currency = custList[i].Curr,
|
|
|
+ // employee_name = custList[i].Salesperson1,
|
|
|
+ // factory_id = 1001,
|
|
|
+ // tenant_id = 1000
|
|
|
+ // };
|
|
|
+ // customer.GenerateNewId(help.NextId());
|
|
|
+ // ItemsAdd.Add(customer);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // _businessDbContext.BulkInsert(ItemsAdd);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+ ////同步供应商
|
|
|
+ //public void SyncSuppMaster()
|
|
|
+ //{
|
|
|
+ // var suppList = _mysql_srm_supplier.GetListAsync().Result;
|
|
|
+ // List<SuppMaster> custList = _suppMaster.Select(a => a.Domain == "1001" && a.IsActive);
|
|
|
+ // var addressList = _consigneeAddressMaster.Select(a => a.Domain == "1001" && a.Typed == "Supp" && a.IsActive);
|
|
|
+ // List<srm_supplier> ItemsAdd = new List<srm_supplier>();
|
|
|
+ // if (custList != null && custList.Count > 0)
|
|
|
+ // {
|
|
|
+ // for (int i = 0; i < custList.Count; i++)
|
|
|
+ // {
|
|
|
+ // long domain = Convert.ToInt64(custList[i].Domain.ToString());
|
|
|
+ // long factory_id = domain % 1000;
|
|
|
+ // long tenant_id = domain - factory_id;
|
|
|
+ // var supp = suppList.Find(x => x.supplier_no == custList[i].Supp.ToString() && x.tenant_id == factory_id && x.factory_id == tenant_id);
|
|
|
+ // if (supp is null)
|
|
|
+ // {
|
|
|
+ // ConsigneeAddressMaster address = addressList.Find(a => a.Address == custList[i].Supp);
|
|
|
+ // var supplier = new srm_supplier
|
|
|
+ // {
|
|
|
+ // supplier_no = custList[i].Supp,
|
|
|
+ // supplier_name = address is null ? address.Name : "",
|
|
|
+ // supplier_short_name = custList[i].SortName,
|
|
|
+ // country = address is null ? address.Country : "",
|
|
|
+ // state = address is null ? address.State : "",
|
|
|
+ // region = address is null ? address.City : "",
|
|
|
+ // contact = address is null ? address.Attention1 : "",
|
|
|
+ // telephone = address is null ? address.Telephone : "",
|
|
|
+ // post_code = address is null ? address.Post : "",
|
|
|
+ // email = address is null ? address.AttentionEmail : "",
|
|
|
+ // currency = custList[i].Curr,
|
|
|
+ // supply_type = custList[i].Type,
|
|
|
+ // settlement = custList[i].CrTerms,
|
|
|
+ // factory_id = factory_id,
|
|
|
+ // tenant_id = tenant_id
|
|
|
+ // };
|
|
|
+ // supplier.GenerateNewId(help.NextId());
|
|
|
+ // ItemsAdd.Add(supplier);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // _businessDbContext.BulkInsert(ItemsAdd);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //////同步销售订单
|
|
|
+ ////public void SyncSalesOrdMaster()
|
|
|
+ ////{
|
|
|
+ //// var customerList = _mysql_crm_customer.GetListAsync().Result;
|
|
|
+ //// var saleOrderList = _mysql_crm_seorder.GetListAsync().Result;
|
|
|
+ //// var ItemMasterDS = _repository.SelectDataBaseBySql("SELECT A.SalesOrd,C.SortName AS CustomName,A.SoldTo AS Cust,A.OrdDate,A.RequiredDate,A.Sequence,A.Curr,A.ExchRate,A.Salesperson1,A.Project,B.Descr AS ProjectName,A.[Domain] from SalesOrdMaster A INNER JOIN CustMaster C ON A.SoldTo=C.Cust and A.[Domain]=C.[Domain]\r\nLEFT JOIN ProjectMaster B On A.Project=B.Project AND A.[Domain]=B.[Domain] ", "SalesOrdMaster");
|
|
|
+ //// List<crm_seorder> ItemsAdd = new List<crm_seorder>();
|
|
|
+ //// List<crm_seorder> ItemsUpdate = new List<crm_seorder>();
|
|
|
+ //// if (ItemMasterDS != null && ItemMasterDS.Tables.Count > 0 && ItemMasterDS.Tables[0].Rows.Count > 0)
|
|
|
+ //// {
|
|
|
+ //// for (int i = 0; i < ItemMasterDS.Tables[0].Rows.Count; i++)
|
|
|
+ //// {
|
|
|
+ //// long domain = Convert.ToInt64(ItemMasterDS.Tables[0].Rows[i]["Domain"].ToString());
|
|
|
+ //// long factory_id = domain % 1000;
|
|
|
+ //// long tenant_id = domain - factory_id;
|
|
|
+ //// var custno = ItemMasterDS.Tables[0].Rows[i]["Cust"].ToString();
|
|
|
+ //// var cust = customerList.Find(a => a.customer_no == custno && a.factory_id == factory_id && a.tenant_id == tenant_id);
|
|
|
+ //// long? custom_id = cust is null ? cust.Id : null;
|
|
|
+ //// var saleorder = saleOrderList.Find(x => x.bill_no == ItemMasterDS.Tables[0].Rows[i]["SalesOrd"].ToString() && x.tenant_id == factory_id && x.factory_id == tenant_id);
|
|
|
+ //// if (saleorder is null)
|
|
|
+ //// {
|
|
|
+ //// var order = new crm_seorder
|
|
|
+ //// {
|
|
|
+ //// bill_no = ItemMasterDS.Tables[0].Rows[i]["SalesOrd"].ToString(),
|
|
|
+ //// custom_id = custom_id,
|
|
|
+ //// custom_name = ItemMasterDS.Tables[0].Rows[i]["CustomName"].ToString(),
|
|
|
+ //// custom_no = ItemMasterDS.Tables[0].Rows[i]["Cust"].ToString(),
|
|
|
+ //// //custom_level = ItemMasterDS.Tables[0].Rows[i]["PurMfg"].ToString() == "P" ? "外购" : "自制",
|
|
|
+ //// date = (DateTime?)ItemMasterDS.Tables[0].Rows[i]["OrdDate"],
|
|
|
+ //// rdate = (DateTime?)ItemMasterDS.Tables[0].Rows[i]["RequiredDate"],
|
|
|
+ //// //urgent = "",
|
|
|
+ //// currency = ItemMasterDS.Tables[0].Rows[i]["Curr"].ToString() == "RMB" ? 1 : 0,
|
|
|
+ //// exchange_rate = (decimal?)ItemMasterDS.Tables[0].Rows[i]["ExchRate"],
|
|
|
+ //// //biller = ItemMasterDS.Tables[0].Rows[i]["NetWeightUM"].ToString(),
|
|
|
+ //// //emp_no = (decimal)ItemMasterDS.Tables[0].Rows[i]["Length"],
|
|
|
+ //// emp_name = ItemMasterDS.Tables[0].Rows[i]["Salesperson1"].ToString(),
|
|
|
+ //// //auditor = (decimal)ItemMasterDS.Tables[0].Rows[i]["Height"],
|
|
|
+ //// //audit_date = ItemMasterDS.Tables[0].Rows[i]["PurMfg"].ToString() == "P" ? 1 : 0,
|
|
|
+ //// //status = 1,
|
|
|
+ //// //closed = "",
|
|
|
+ //// //op_time = 1,
|
|
|
+ //// bill_from = "",
|
|
|
+ //// //project_name = Convert.ToBoolean(ItemMasterDS.Tables[0].Rows[i]["LotSerialControl"]) == true ? 1 : 0,
|
|
|
+ //// //project_code = "",
|
|
|
+ //// out_stock_type = 1,//TODO
|
|
|
+ //// //sale_dept_id = "",
|
|
|
+ //// //sale_dept_name = 1,
|
|
|
+ //// //sale_dept_code = 1,
|
|
|
+ //// //create_dept = 1
|
|
|
+ //// factory_id = factory_id,
|
|
|
+ //// tenant_id = tenant_id
|
|
|
+ //// };
|
|
|
+ //// order.GenerateNewId();
|
|
|
+ //// ItemsAdd.Add(order);
|
|
|
+ //// }
|
|
|
+ //// else
|
|
|
+ //// {
|
|
|
+ //// saleorder.bill_no = ItemMasterDS.Tables[0].Rows[i]["SalesOrd"].ToString();
|
|
|
+ //// saleorder.custom_id = custom_id;
|
|
|
+ //// saleorder.custom_name = ItemMasterDS.Tables[0].Rows[i]["CustomName"].ToString();
|
|
|
+ //// saleorder.custom_no = ItemMasterDS.Tables[0].Rows[i]["Cust"].ToString();
|
|
|
+ //// //custom_level = ItemMasterDS.Tables[0].Rows[i]["PurMfg"].ToString() == "P" ? "外购" : "自制",
|
|
|
+ //// saleorder.date = (DateTime?)ItemMasterDS.Tables[0].Rows[i]["OrdDate"];
|
|
|
+ //// saleorder.rdate = (DateTime?)ItemMasterDS.Tables[0].Rows[i]["RequiredDate"];
|
|
|
+ //// saleorder.urgent = (int?)ItemMasterDS.Tables[0].Rows[i]["Sequence"];
|
|
|
+ //// saleorder.currency = ItemMasterDS.Tables[0].Rows[i]["Curr"].ToString() == "RMB" ? 1 : 0;
|
|
|
+ //// saleorder.exchange_rate = (decimal?)ItemMasterDS.Tables[0].Rows[i]["ExchRate"];
|
|
|
+ //// //biller = ItemMasterDS.Tables[0].Rows[i]["NetWeightUM"].ToString(),
|
|
|
+ //// //emp_no = (decimal)ItemMasterDS.Tables[0].Rows[i]["Length"],
|
|
|
+ //// saleorder.emp_name = ItemMasterDS.Tables[0].Rows[i]["Salesperson1"].ToString();
|
|
|
+ //// //auditor = (decimal)ItemMasterDS.Tables[0].Rows[i]["Height"],
|
|
|
+ //// //audit_date = ItemMasterDS.Tables[0].Rows[i]["PurMfg"].ToString() == "P" ? 1 : 0,
|
|
|
+ //// //status = 1,
|
|
|
+ //// //closed = "",
|
|
|
+ //// //op_time = 1,
|
|
|
+ //// saleorder.bill_from = "";
|
|
|
+ //// saleorder.project_name = ItemMasterDS.Tables[0].Rows[i]["ProjectName"].ToString();
|
|
|
+ //// saleorder.project_code = ItemMasterDS.Tables[0].Rows[i]["Project"].ToString();
|
|
|
+ //// saleorder.out_stock_type = 1;//TODO
|
|
|
+ //// //sale_dept_id = "",
|
|
|
+ //// //sale_dept_name = 1,
|
|
|
+ //// //sale_dept_code = 1,
|
|
|
+ //// //create_dept = 1
|
|
|
+ //// ItemsUpdate.Add(saleorder);
|
|
|
+ //// }
|
|
|
+ //// }
|
|
|
+ //// //_businessDbContext.crm_seorder.Delete();
|
|
|
+ //// _businessDbContext.crm_seorder.BulkInsert(ItemsAdd);
|
|
|
+ //// _businessDbContext.crm_seorder.BulkUpdate(ItemsUpdate);
|
|
|
+ //// }
|
|
|
+ ////}
|
|
|
+
|
|
|
+ //////同步销售订单明细
|
|
|
+ ////public void SyncSalesOrdMasterEntry()
|
|
|
+ ////{
|
|
|
+ //// var saleOrderEntryList = _mysql_crm_seorderentry.GetListAsync().Result;
|
|
|
+ //// var saleOrderList = _mysql_crm_seorder.GetListAsync().Result;
|
|
|
+ //// var ItemMasterDS = _repository.SelectDataBaseBySql("SELECT A.SalesOrd,A.Line,C.Descr,C.Descr1,A.ItemNum,A.UM,A.QtyOrded,A.Price,A.Disc,A.RequiredDate,A.Remark,B.CustPO,A.CustItem,A.Status,A.QtyShipped,A.QtyReturned,B.Contract,A.Domain from SalesOrdDetail A INNER JOIN SalesOrdMaster B On A.SalesOrd=B.SalesOrd and A.[Domain]=B.[Domain] INNER JOIN ItemMaster C on A.ItemNum=C.ItemNum and A.[Domain]=C.[Domain]", "SalesOrdDetail");
|
|
|
+ //// List<crm_seorderentry> ItemsAdd = new List<crm_seorderentry>();
|
|
|
+ //// List<crm_seorderentry> ItemsUpdate = new List<crm_seorderentry>();
|
|
|
+ //// if (ItemMasterDS != null && ItemMasterDS.Tables.Count > 0 && ItemMasterDS.Tables[0].Rows.Count > 0)
|
|
|
+ //// {
|
|
|
+ //// for (int i = 0; i < ItemMasterDS.Tables[0].Rows.Count; i++)
|
|
|
+ //// {
|
|
|
+ //// long domain = Convert.ToInt64(ItemMasterDS.Tables[0].Rows[i]["Domain"].ToString());
|
|
|
+ //// long factory_id = domain % 1000;
|
|
|
+ //// long tenant_id = domain - factory_id;
|
|
|
+ //// var bill_no = ItemMasterDS.Tables[0].Rows[i]["SalesOrd"].ToString();
|
|
|
+ //// var seorder = saleOrderList.Find(a => a.bill_no == bill_no && a.factory_id == factory_id && a.tenant_id == tenant_id);
|
|
|
+ //// long? seorder_id = seorder is null ? seorder.Id : null;
|
|
|
+ //// var saleorderentry = saleOrderEntryList.Find(x => x.bill_no == bill_no && x.tenant_id == factory_id && x.factory_id == tenant_id);
|
|
|
+ //// if (saleorderentry is null)
|
|
|
+ //// {
|
|
|
+ //// var entry = new crm_seorderentry
|
|
|
+ //// {
|
|
|
+ //// seorder_id = seorder_id,
|
|
|
+ //// bill_no = ItemMasterDS.Tables[0].Rows[i]["SalesOrd"].ToString(),
|
|
|
+ //// entry_seq = (int?)ItemMasterDS.Tables[0].Rows[i]["Line"],
|
|
|
+ //// item_number = ItemMasterDS.Tables[0].Rows[i]["ItemNum"].ToString(),
|
|
|
+ //// item_name = ItemMasterDS.Tables[0].Rows[i]["Descr"].ToString(),
|
|
|
+ //// specification = ItemMasterDS.Tables[0].Rows[i]["Descr1"].ToString(),
|
|
|
+ //// //urgent = (int?)ItemMasterDS.Tables[0].Rows[i]["PLPriority"],
|
|
|
+ //// bom_number = ItemMasterDS.Tables[0].Rows[i]["ItemNum"].ToString(),
|
|
|
+ //// unit = ItemMasterDS.Tables[0].Rows[i]["UM"].ToString(),
|
|
|
+ //// qty = (decimal?)ItemMasterDS.Tables[0].Rows[i]["QtyOrded"],
|
|
|
+ //// //price = (decimal?)ItemMasterDS.Tables[0].Rows[i]["Price"],
|
|
|
+ //// //tax_price = (decimal?)ItemMasterDS.Tables[0].Rows[i]["ExchRate"],
|
|
|
+ //// //tax_rate = (decimal?)ItemMasterDS.Tables[0].Rows[i]["ExchRate"],
|
|
|
+ //// amount = (decimal?)ItemMasterDS.Tables[0].Rows[i]["Price"],
|
|
|
+ //// //discount_rate = (decimal?)ItemMasterDS.Tables[0].Rows[i]["ExchRate"],
|
|
|
+ //// discount_amount = (decimal?)ItemMasterDS.Tables[0].Rows[i]["Disc"],
|
|
|
+ //// //total_amount = (decimal?)ItemMasterDS.Tables[0].Rows[i]["ExchRate"],
|
|
|
+ //// plan_date = (DateTime?)ItemMasterDS.Tables[0].Rows[i]["RequiredDate"],
|
|
|
+ //// //date = (DateTime?)ItemMasterDS.Tables[0].Rows[i]["OrdDate"],
|
|
|
+ //// //planner_name = ItemMasterDS.Tables[0].Rows[i]["Salesperson1"].ToString(),
|
|
|
+ //// //planner_no = ItemMasterDS.Tables[0].Rows[i]["Salesperson1"].ToString(),
|
|
|
+ //// remark = ItemMasterDS.Tables[0].Rows[i]["Remark"].ToString(),
|
|
|
+ //// //soure_bill_no = ItemMasterDS.Tables[0].Rows[i]["Salesperson1"].ToString(),
|
|
|
+ //// custom_order_bill_no = ItemMasterDS.Tables[0].Rows[i]["CustPO"].ToString(),
|
|
|
+ //// //custom_order_entryid = ItemMasterDS.Tables[0].Rows[i]["Salesperson1"].ToString(),
|
|
|
+ //// //sys_capacity_date = (DateTime?)ItemMasterDS.Tables[0].Rows[i]["OrdDate"],
|
|
|
+ //// //adjust_date = (DateTime?)ItemMasterDS.Tables[0].Rows[i]["OrdDate"],
|
|
|
+ //// //mrp_closed = Convert.ToBoolean(ItemMasterDS.Tables[0].Rows[i]["OrdDate"]),
|
|
|
+ //// custom_order_itemno = ItemMasterDS.Tables[0].Rows[i]["CustItem"].ToString(),
|
|
|
+ //// state = Convert.ToBoolean(ItemMasterDS.Tables[0].Rows[i]["Status"]),//TODO
|
|
|
+ //// deliver_count = (decimal?)ItemMasterDS.Tables[0].Rows[i]["QtyShipped"],
|
|
|
+ //// returned_count = (decimal?)ItemMasterDS.Tables[0].Rows[i]["QtyReturned"],
|
|
|
+ //// //se_reject_reason = ItemMasterDS.Tables[0].Rows[i]["Salesperson1"].ToString(),
|
|
|
+ //// //out_stock_type = ItemMasterDS.Tables[0].Rows[i]["Salesperson1"].ToString(),
|
|
|
+ //// //is_checked = Convert.ToBoolean(ItemMasterDS.Tables[0].Rows[i]["OrdDate"]),
|
|
|
+ //// //sys_material_date = Convert.ToBoolean(ItemMasterDS.Tables[0].Rows[i]["OrdDate"]),
|
|
|
+ //// contract_no = ItemMasterDS.Tables[0].Rows[i]["Contract"].ToString(),
|
|
|
+ //// //create_dept = Convert.ToBoolean(ItemMasterDS.Tables[0].Rows[i]["OrdDate"])
|
|
|
+ //// factory_id = factory_id,
|
|
|
+ //// tenant_id = tenant_id
|
|
|
+ //// };
|
|
|
+ //// entry.GenerateNewId();
|
|
|
+ //// ItemsAdd.Add(entry);
|
|
|
+ //// }
|
|
|
+ //// else
|
|
|
+ //// {
|
|
|
+ //// saleorderentry.seorder_id = seorder_id;
|
|
|
+ //// saleorderentry.bill_no = ItemMasterDS.Tables[0].Rows[i]["SalesOrd"].ToString();
|
|
|
+ //// saleorderentry.entry_seq = (int?)ItemMasterDS.Tables[0].Rows[i]["Line"];
|
|
|
+ //// saleorderentry.item_number = ItemMasterDS.Tables[0].Rows[i]["ItemNum"].ToString();
|
|
|
+ //// saleorderentry.item_name = ItemMasterDS.Tables[0].Rows[i]["Descr"].ToString();
|
|
|
+ //// saleorderentry.specification = ItemMasterDS.Tables[0].Rows[i]["Descr1"].ToString();
|
|
|
+ //// //urgent = (int?)ItemMasterDS.Tables[0].Rows[i]["PLPriority"],
|
|
|
+ //// saleorderentry.bom_number = ItemMasterDS.Tables[0].Rows[i]["ItemNum"].ToString();
|
|
|
+ //// saleorderentry.unit = ItemMasterDS.Tables[0].Rows[i]["UM"].ToString();
|
|
|
+ //// saleorderentry.qty = (decimal?)ItemMasterDS.Tables[0].Rows[i]["QtyOrded"];
|
|
|
+ //// //price = (decimal?)ItemMasterDS.Tables[0].Rows[i]["Price"],
|
|
|
+ //// //tax_price = (decimal?)ItemMasterDS.Tables[0].Rows[i]["ExchRate"],
|
|
|
+ //// //tax_rate = (decimal?)ItemMasterDS.Tables[0].Rows[i]["ExchRate"],
|
|
|
+ //// saleorderentry.amount = (decimal?)ItemMasterDS.Tables[0].Rows[i]["Price"];
|
|
|
+ //// //discount_rate = (decimal?)ItemMasterDS.Tables[0].Rows[i]["ExchRate"],
|
|
|
+ //// saleorderentry.discount_amount = (decimal?)ItemMasterDS.Tables[0].Rows[i]["Disc"];
|
|
|
+ //// //total_amount = (decimal?)ItemMasterDS.Tables[0].Rows[i]["ExchRate"],
|
|
|
+ //// saleorderentry.plan_date = (DateTime?)ItemMasterDS.Tables[0].Rows[i]["RequiredDate"];
|
|
|
+ //// //date = (DateTime?)ItemMasterDS.Tables[0].Rows[i]["OrdDate"],
|
|
|
+ //// //planner_name = ItemMasterDS.Tables[0].Rows[i]["Salesperson1"].ToString(),
|
|
|
+ //// //planner_no = ItemMasterDS.Tables[0].Rows[i]["Salesperson1"].ToString(),
|
|
|
+ //// saleorderentry.remark = ItemMasterDS.Tables[0].Rows[i]["Remark"].ToString();
|
|
|
+ //// //soure_bill_no = ItemMasterDS.Tables[0].Rows[i]["Salesperson1"].ToString(),
|
|
|
+ //// saleorderentry.custom_order_bill_no = ItemMasterDS.Tables[0].Rows[i]["CustPO"].ToString();
|
|
|
+ //// //custom_order_entryid = ItemMasterDS.Tables[0].Rows[i]["Salesperson1"].ToString(),
|
|
|
+ //// //sys_capacity_date = (DateTime?)ItemMasterDS.Tables[0].Rows[i]["OrdDate"],
|
|
|
+ //// //adjust_date = (DateTime?)ItemMasterDS.Tables[0].Rows[i]["OrdDate"],
|
|
|
+ //// //mrp_closed = Convert.ToBoolean(ItemMasterDS.Tables[0].Rows[i]["OrdDate"]),
|
|
|
+ //// saleorderentry.custom_order_itemno = ItemMasterDS.Tables[0].Rows[i]["CustItem"].ToString();
|
|
|
+ //// saleorderentry.state = Convert.ToBoolean(ItemMasterDS.Tables[0].Rows[i]["Status"]);//TODO
|
|
|
+ //// //rnumber = Convert.ToBoolean(ItemMasterDS.Tables[0].Rows[i]["OrdDate"]),
|
|
|
+ //// //deliver_notice_count = (decimal?)ItemMasterDS.Tables[0].Rows[i]["ExchRate"],
|
|
|
+ //// saleorderentry.deliver_count = (decimal?)ItemMasterDS.Tables[0].Rows[i]["QtyShipped"];
|
|
|
+ //// saleorderentry.returned_count = (decimal?)ItemMasterDS.Tables[0].Rows[i]["QtyReturned"];
|
|
|
+ //// //se_reject_reason = ItemMasterDS.Tables[0].Rows[i]["Salesperson1"].ToString(),
|
|
|
+ //// //out_stock_type = ItemMasterDS.Tables[0].Rows[i]["Salesperson1"].ToString(),
|
|
|
+ //// //is_checked = Convert.ToBoolean(ItemMasterDS.Tables[0].Rows[i]["OrdDate"]),
|
|
|
+ //// //sys_material_date = Convert.ToBoolean(ItemMasterDS.Tables[0].Rows[i]["OrdDate"]),
|
|
|
+ //// saleorderentry.contract_no = ItemMasterDS.Tables[0].Rows[i]["Contract"].ToString();
|
|
|
+ //// //create_dept = Convert.ToBoolean(ItemMasterDS.Tables[0].Rows[i]["OrdDate"])
|
|
|
+ //// ItemsUpdate.Add(saleorderentry);
|
|
|
+ //// }
|
|
|
+ //// }
|
|
|
+ //// //_businessDbContext.crm_seorder.Delete();
|
|
|
+ //// _businessDbContext.crm_seorderentry.BulkInsert(ItemsAdd);
|
|
|
+ //// _businessDbContext.crm_seorderentry.BulkUpdate(ItemsUpdate);
|
|
|
+
|
|
|
+ //// }
|
|
|
+ ////}
|
|
|
+
|
|
|
+ ////同步物料
|
|
|
+ //public void SyncItemMaster()
|
|
|
+ //{
|
|
|
+ // bool isAll = true;//是否同步所有物料
|
|
|
+ // var ic_itemList = _mysql_ic_item.GetListAsync(a => a.tenant_id == 1000 && a.factory_id == 1001).Result;
|
|
|
+ // List<ItemMaster> custList = new List<ItemMaster>();
|
|
|
+ // if (isAll)
|
|
|
+ // {
|
|
|
+ // custList = _itemMaster.Select(a => a.IsActive && a.Domain == "1001");
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // //格努产品编码同步子级物料
|
|
|
+ // List<string> childItems = GetChildItemNumber("", new List<string>());
|
|
|
+ // custList = _itemMaster.Select(a => a.IsActive && a.Domain == "1001" && childItems.Distinct().Contains(a.ItemNum));
|
|
|
+ // }
|
|
|
+ // List<ic_item> ItemsAdd = new List<ic_item>();
|
|
|
+ // List<srm_purchase> srm_purchaseAdd = new List<srm_purchase>();
|
|
|
+ // if (custList != null && custList.Count > 0)
|
|
|
+ // {
|
|
|
+ // for (int i = 0; i < custList.Count; i++)
|
|
|
+ // {
|
|
|
+ // var ic_item = ic_itemList.Find(x => x.number == custList[i].ItemNum && x.tenant_id == 1000 && x.factory_id == 1001);
|
|
|
+ // if (ic_item == null)
|
|
|
+ // {
|
|
|
+ // long itemId = help.NextId();
|
|
|
+ // ItemsAdd.Add(new ic_item(itemId)
|
|
|
+ // {
|
|
|
+ // number = custList[i].ItemNum, //物料编码
|
|
|
+ // name = custList[i].Descr, //物料名称
|
|
|
+ // model = custList[i].Descr1,//规格型号
|
|
|
+ // fversion = "",//版本号
|
|
|
+ // //ext.FErpClsID == "配置类" ? 0 : ext.FErpClsID == "自制" ? 1 : ext.FErpClsID == "委外" ? 2 : ext.FErpClsID == "外购" ? 3 : ext.FErpClsID == "虚拟" ? 4 : ext.FErpClsID == "费用" ? 5 : ext.FErpClsID == "服务" ? 6 : -1;
|
|
|
+ // //erp_cls = custList[i].PurMfg == "P" ? 3 : 1,//物料属性
|
|
|
+ // erp_cls = custList[i].ItemNum == "1.SD1.D.0056-F" || custList[i].ItemNum == "1.ZC1.D.0001" || custList[i].ItemNum == "1.BW1.D.0030" ? 1 : 3,
|
|
|
+ // //erp_cls_name = custList[i].PurMfg == "P" ? "外购" : "自制",//物料属性名称
|
|
|
+ // erp_cls_name = custList[i].ItemNum == "1.SD1.D.0056-F" || custList[i].ItemNum == "1.ZC1.D.0001" || custList[i].ItemNum == "1.BW1.D.0030" ? "自制" : "外购",
|
|
|
+ // unit = custList[i].UM,//单位
|
|
|
+ // item_level = 0,//物料等级
|
|
|
+ // source = "",//来源
|
|
|
+ // iskeyitem = custList[i].IsMainMas ? 1 : 0,//是否关键件
|
|
|
+ // net_weight = (decimal)custList[i].NetWeight,//净重
|
|
|
+ // maund = custList[i].NetWeightUM,//重量单位
|
|
|
+ // length = (decimal)custList[i].Length,//长度
|
|
|
+ // width = (decimal)custList[i].Width,//宽度
|
|
|
+ // height = (decimal)custList[i].Height,//高度
|
|
|
+ // allowpur = custList[i].PurMfg == "P" ? 1 : 0,//允许采购
|
|
|
+ // allowsale = 1,//允许销售
|
|
|
+ // allowmanu = custList[i].PurMfg == "L" ? 1 : 0,//允许生产
|
|
|
+ // allowout = 1,//允许委外
|
|
|
+ // allowbatch = custList[i].LotSerialControl ? 1 : 0,//批号管理
|
|
|
+ // allowserial = custList[i].LotSerialControl ? 1 : 0,//序列号管理
|
|
|
+ // photo = "",//图片
|
|
|
+ // enable_warning = 1,//启用预警
|
|
|
+ // factory_id = 1001,
|
|
|
+ // tenant_id = 1000,
|
|
|
+ // IsDeleted = false,
|
|
|
+
|
|
|
+
|
|
|
+ // batch_manager = custList[i].LotSerialControl ? 1 : 0,
|
|
|
+ // minorderqty = custList[i].MinOrd,
|
|
|
+ // minpackqty = 1,
|
|
|
+ // ordissu_days = 1,
|
|
|
+ // transportation_leadtime = 3,
|
|
|
+ // stock_leadtime = 1,
|
|
|
+ // production_leadtime = 4,
|
|
|
+ // order_leadtime = 4,
|
|
|
+
|
|
|
+ // fix_leadtime = 1,
|
|
|
+ // order_inter_val = 1,
|
|
|
+ // lead_time = 1,
|
|
|
+ // bat_change_economy = 1,
|
|
|
+ // total_tqq = 1,
|
|
|
+ // order_point = 1,
|
|
|
+ // secinv = 1,
|
|
|
+ // secinv_ratio = 1,
|
|
|
+ // self_inspection_date = 1,
|
|
|
+ // Warehousing_date = 1,
|
|
|
+ // Shipping_date = 3,
|
|
|
+ // });
|
|
|
+ // srm_purchaseAdd.Add(new srm_purchase(help.NextId())
|
|
|
+ // {
|
|
|
+ // icitem_id = itemId,
|
|
|
+ // icitem_name = custList[i].Descr,
|
|
|
+ // sourcelist_number = "HYQD12064",
|
|
|
+ // supplier_id = 10101000051,
|
|
|
+ // supplier_number = "",
|
|
|
+ // supplier_name = "广州市伟正金属构件有限公司",
|
|
|
+ // purchgroup = "",
|
|
|
+ // purcher = "",
|
|
|
+ // purchase_unit = "",
|
|
|
+ // netpurchase_price = 1,
|
|
|
+ // taxrate = 0.13m,
|
|
|
+ // currency_type = 1,
|
|
|
+ // order_rector_name = "",
|
|
|
+ // order_rector_num = "",
|
|
|
+ // factory_code = "",
|
|
|
+ // order_dept = "",
|
|
|
+ // order_price = 13,
|
|
|
+ // sale_price = 130,
|
|
|
+ // qty_min = 10,
|
|
|
+ // batch_append_qty = 10,
|
|
|
+ // factory_id = 1001,
|
|
|
+ // tenant_id = 1000,
|
|
|
+ // IsDeleted = false
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // _businessDbContext.BulkInsert(ItemsAdd);
|
|
|
+ // _businessDbContext.BulkInsert(srm_purchaseAdd);
|
|
|
+ //}
|
|
|
+
|
|
|
+ //public void SyncBom()
|
|
|
+ //{
|
|
|
+ // var ic_bomList = _mysql_ic_bom.GetListAsync(a => a.tenant_id == 1000 && a.factory_id == 1001).Result;
|
|
|
+ // var ic_itemList = _mysql_ic_item.GetListAsync(a => a.tenant_id == 1000 && a.factory_id == 1001).Result;
|
|
|
+ // var ic_bomchildList = _mysql_ic_bom_child.GetListAsync(a => a.tenant_id == 1000 && a.factory_id == 1001 && (a.bom_number == "1.SD1.D.0056-F" || a.bom_number == "1.ZC1.D.0001" || a.bom_number == "1.BW1.D.0030")).Result;
|
|
|
+ // List<ProductStructureMaster> wmsBomList = _productStructureMaster.Select(a => a.Domain == "1001" && (a.ParentItem == "1.SD1.D.0056-F" || a.ParentItem == "1.ZC1.D.0001" || a.ParentItem == "1.BW1.D.0030") && a.IsActive);
|
|
|
+ // List<ic_bom> ItemsAdd = new List<ic_bom>();
|
|
|
+ // List<ic_bom_child> childItemsAdd = new List<ic_bom_child>();
|
|
|
+ // if (wmsBomList != null && wmsBomList.Count > 0)
|
|
|
+ // {
|
|
|
+ // var ItemMasterDS = wmsBomList.Select(a => a.ParentItem).Distinct().ToList();
|
|
|
+ // foreach (var c in ItemMasterDS)
|
|
|
+ // {
|
|
|
+ // var icbom = ic_bomList.Find(x => x.item_number == c && x.tenant_id == 1000 && x.factory_id == 1001);
|
|
|
+ // var ItemList = wmsBomList.Where(a => a.ParentItem == c);
|
|
|
+ // var item = ic_itemList.Find(a => a.number == c);
|
|
|
+ // if (item == null)
|
|
|
+ // {
|
|
|
+ // continue;
|
|
|
+ // }
|
|
|
+ // if (icbom == null)
|
|
|
+ // {
|
|
|
+ // long domain = Convert.ToInt64(ItemList.First().Domain);
|
|
|
+ // long factory_id = domain % 1000;
|
|
|
+ // long tenant_id = domain - factory_id;
|
|
|
+ // var bom = new ic_bom(help.NextId())
|
|
|
+ // {
|
|
|
+ // bom_number = c,
|
|
|
+ // icitem_id = item.Id,
|
|
|
+ // item_name = item.name,
|
|
|
+ // item_number = c,
|
|
|
+ // version = ItemList.First().Refs,
|
|
|
+ // factory_id = 1001,
|
|
|
+ // tenant_id = 1000,
|
|
|
+ // IsDeleted = false,
|
|
|
+ // use_status = 1
|
|
|
+ // };
|
|
|
+ // ItemsAdd.Add(bom);
|
|
|
+ // foreach (var child in ItemList)
|
|
|
+ // {
|
|
|
+ // var itemchild = ic_itemList.Find(a => a.number == child.ComponentItem);
|
|
|
+ // if (itemchild == null) { continue; }
|
|
|
+ // var bomchild = new ic_bom_child(help.NextId())
|
|
|
+ // {
|
|
|
+ // bom_id = bom.Id,
|
|
|
+ // bom_number = bom.bom_number,
|
|
|
+ // icitem_id = itemchild == null ? long.MinValue : itemchild.Id,
|
|
|
+ // item_number = child.ComponentItem,
|
|
|
+ // item_name = itemchild == null ? "" : itemchild.name,
|
|
|
+ // unit = child.UM,
|
|
|
+ // qty = child.Qty,
|
|
|
+ // entryid = child.SequenceNum,
|
|
|
+ // erp_cls = itemchild == null ? 2 : itemchild.erp_cls,
|
|
|
+ // begin_day = child.StartEff,
|
|
|
+ // end_day = child.EndEff,
|
|
|
+ // child_num = child.SequenceNum,
|
|
|
+ // version = child.Refs,
|
|
|
+ // factory_id = 1001,
|
|
|
+ // tenant_id = 1000,
|
|
|
+ // IsDeleted = false,
|
|
|
+ // use_status = 1
|
|
|
+ // };
|
|
|
+ // childItemsAdd.Add(bomchild);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // foreach (var child in ItemList)
|
|
|
+ // {
|
|
|
+ // var itemchild = ic_itemList.Find(a => a.number == child.ComponentItem);
|
|
|
+ // if (itemchild == null) { continue; }
|
|
|
+ // var icbomchild = ic_bomchildList.Find(s => s.bom_number == c && s.item_number == child.ComponentItem);
|
|
|
+ // if (icbomchild == null)
|
|
|
+ // {
|
|
|
+ // var bomchild = new ic_bom_child(help.NextId())
|
|
|
+ // {
|
|
|
+ // bom_id = icbom.Id,
|
|
|
+ // bom_number = icbom.bom_number,
|
|
|
+ // icitem_id = itemchild == null ? long.MinValue : itemchild.Id,
|
|
|
+ // item_number = child.ComponentItem,
|
|
|
+ // item_name = itemchild == null ? "" : itemchild.name,
|
|
|
+ // unit = child.UM,
|
|
|
+ // qty = child.Qty,
|
|
|
+ // entryid = child.SequenceNum,
|
|
|
+ // erp_cls = itemchild == null ? 2 : itemchild.erp_cls,
|
|
|
+ // begin_day = child.StartEff,
|
|
|
+ // end_day = child.EndEff,
|
|
|
+ // child_num = child.SequenceNum,
|
|
|
+ // version = child.Refs,
|
|
|
+ // factory_id = 1001,
|
|
|
+ // tenant_id = 1000,
|
|
|
+ // IsDeleted = false,
|
|
|
+ // use_status = 1
|
|
|
+ // };
|
|
|
+ // childItemsAdd.Add(bomchild);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+ // }
|
|
|
+ // _businessDbContext.BulkInsert(ItemsAdd);
|
|
|
+ // _businessDbContext.BulkInsert(childItemsAdd);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+ ////循环获取子级物料编码,包括产品本身,有重复的结果去重即可
|
|
|
+ //public List<string> GetChildItemNumber(string itemNum, List<string> list)
|
|
|
+ //{
|
|
|
+ // list.Add(itemNum);
|
|
|
+ // var productStructures = _productStructureMaster.Select(p => p.ParentItem == itemNum && p.Domain == "1001" && p.IsActive);
|
|
|
+ // list.AddRange(productStructures.Select(a => a.ComponentItem));
|
|
|
+ // foreach (var item in productStructures)
|
|
|
+ // {
|
|
|
+ // if (item.StructureType.ToUpper() == "X")
|
|
|
+ // {
|
|
|
+ // GetChildItemNumber(item.ComponentItem, list);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // return list;
|
|
|
+ //}
|
|
|
+ }
|
|
|
+}
|