|
|
@@ -41,6 +41,7 @@ using MongoDB.Driver.Linq;
|
|
|
using Bussiness.Model.SRM;
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
using Bussiness.Model.Sale;
|
|
|
+using Amazon.Runtime.Internal.Transform;
|
|
|
|
|
|
namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
@@ -61,11 +62,13 @@ namespace Business.ResourceExamineManagement
|
|
|
/// 工序
|
|
|
/// </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>
|
|
|
/// 工作日历
|
|
|
@@ -208,9 +211,9 @@ namespace Business.ResourceExamineManagement
|
|
|
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<srm_pr_main, long> mysql_srm_pr_main,
|
|
|
+ IRepository<mes_process, long> mysql_mes_process,
|
|
|
+ IRepository<mes_tech_process, long> mysql_mes_tech_process
|
|
|
)
|
|
|
{
|
|
|
_mes_technique = mes_technique;
|
|
|
@@ -242,6 +245,8 @@ namespace Business.ResourceExamineManagement
|
|
|
_mysql_ic_factory_details= mysql_ic_factory_details;
|
|
|
_mysql_mes_oorder= mysql_mes_oorder;
|
|
|
_mysql_srm_pr_main= mysql_srm_pr_main;
|
|
|
+ _mysql_mes_process = mysql_mes_process;
|
|
|
+ _mysql_mes_tech_process = mysql_mes_tech_process;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -305,15 +310,15 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
|
public async Task<PschedDto> ReceiveResult(SeorderentryDto input)
|
|
|
{
|
|
|
- //数据库快照-同步mysql库数据到mongoDB中
|
|
|
- //await SyncData(input.factoryId);
|
|
|
//生成当前计算bangid
|
|
|
- //SnowFlake snow = new SnowFlake();
|
|
|
- //long bangid = snow.NextId();
|
|
|
-
|
|
|
+ SnowFlake snow = new SnowFlake();
|
|
|
+ long bangid = snow.NextId();
|
|
|
+
|
|
|
+ //数据库快照-同步mysql库数据到mongoDB中
|
|
|
+ //await SyncData(input.factoryId,bangid);
|
|
|
+
|
|
|
//产能检查
|
|
|
- await ProductiveExamine(1735281284746956800, 1000);
|
|
|
- //await ProductiveExamine(1733221167209762816, 100);
|
|
|
+ await ProductiveExamine(1353957529328291842, 1000);
|
|
|
|
|
|
await GenerateMorder(14);
|
|
|
return null;
|
|
|
@@ -324,16 +329,17 @@ namespace Business.ResourceExamineManagement
|
|
|
/// 数据库快照
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
- public async Task SyncData(long factoryId)
|
|
|
+ public async Task SyncData(long factoryId,long bangid)
|
|
|
{
|
|
|
//同步物料库存数据
|
|
|
var icitemStokc = _mysql_ic_item_stock.GetListAsync(p => p.factory_id == factoryId).Result;
|
|
|
if (icitemStokc.Count > 0)
|
|
|
{
|
|
|
+ //设置当前计算bangid
|
|
|
+ icitemStokc.ForEach(item => { item.bang_id = bangid; });
|
|
|
+ //插入数据
|
|
|
await _ic_item_stock.InsertMany(icitemStokc);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -378,11 +384,17 @@ namespace Business.ResourceExamineManagement
|
|
|
//工序需要等待时间记录
|
|
|
List<StartTimeDto> starts = new List<StartTimeDto>();
|
|
|
//1、获取工艺路径下的第一层级工序
|
|
|
- List<mes_tech_process> fistChilds = tech_Processes.Where(p => p.parentprocid == tech_id).OrderBy(m => m.Id).ToList();
|
|
|
+ List<mes_tech_process> fistChilds = tech_Processes.Where(p => p.parentprocid == tech_id).ToList();
|
|
|
if (fistChilds.Count == 0)
|
|
|
{
|
|
|
throw new NotImplementedException("当前工艺路径没有配置工序,请调整!");
|
|
|
}
|
|
|
+ List<mes_tech_process> sortChilds = new List<mes_tech_process>();
|
|
|
+ //添加最后一个工序
|
|
|
+ var last = fistChilds.First(p => p.nextprocid == null);
|
|
|
+ sortChilds.Add(last);
|
|
|
+ SortProcess(fistChilds, last.Id, sortChilds);
|
|
|
+
|
|
|
decimal curTakeTime = 0.00m;//当前工序耗时(分钟)
|
|
|
//添加第一个工序需要等待时间记录
|
|
|
StartTimeDto dto;
|
|
|
@@ -411,6 +423,22 @@ namespace Business.ResourceExamineManagement
|
|
|
return sumTimes;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 递归:工序按照先后顺序排序-暂时不考虑两个分支合并到一个分支的情况
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="Processes"></param>
|
|
|
+ /// <param name="processId"></param>
|
|
|
+ /// <param name="sortProcesses"></param>
|
|
|
+ private void SortProcess(List<mes_tech_process> Processes, long processId, List<mes_tech_process> sortProcesses)
|
|
|
+ {
|
|
|
+ var curProcess = Processes.Where(p => p.nextprocid == processId).FirstOrDefault();
|
|
|
+ if (curProcess != null)
|
|
|
+ {
|
|
|
+ sortProcesses.AddFirst(curProcess);
|
|
|
+ SortProcess(Processes, curProcess.Id,sortProcesses);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 计算当前工序前置准备时间
|
|
|
/// </summary>
|
|
|
@@ -425,14 +453,14 @@ namespace Business.ResourceExamineManagement
|
|
|
takeTime = quantity / proc.uph.Value * 60 / proc.wsinuse.Value;
|
|
|
return takeTime;
|
|
|
}
|
|
|
- else if (proc.wctype == 2)//流水线型:数量*ct(生产一件所需时间)
|
|
|
+ else if (proc.wctype == 2)//流水线型:数量*ct(生产一件所需时间)/wsinuse(工位数)
|
|
|
{
|
|
|
- takeTime = quantity * proc.ct.Value;
|
|
|
+ takeTime = quantity * proc.ct.Value / proc.wsinuse.Value;
|
|
|
return takeTime;
|
|
|
}
|
|
|
- else if (proc.wctype == 3)//设备型:向上取整(数量/一次可加工数量)*ct(老化一次所需时间)
|
|
|
+ else if (proc.wctype == 3)//设备型:向上取整(数量/一次可加工数量/wsinuse(工位数))*ct(老化一次所需时间)
|
|
|
{
|
|
|
- takeTime = Math.Ceiling(quantity / proc.upe.Value) * proc.ct.Value;
|
|
|
+ takeTime = Math.Ceiling(quantity / proc.upe.Value / proc.wsinuse.Value) * proc.ct.Value;
|
|
|
return takeTime;
|
|
|
}
|
|
|
return takeTime;
|