|
|
@@ -174,7 +174,7 @@ namespace Business.ResourceExamineManagement
|
|
|
/// </summary>
|
|
|
private readonly MorderAppService _morderAppService;
|
|
|
|
|
|
-
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 预处理
|
|
|
/// </summary>
|
|
|
@@ -305,7 +305,7 @@ namespace Business.ResourceExamineManagement
|
|
|
param.sorderId = input.sorderId;
|
|
|
param.tenantId = input.tenantId;
|
|
|
param.factoryId = input.factoryId;
|
|
|
-
|
|
|
+
|
|
|
|
|
|
//资源检查结果
|
|
|
PschedDto rtn = new PschedDto();
|
|
|
@@ -327,6 +327,10 @@ namespace Business.ResourceExamineManagement
|
|
|
//获取订单行数据
|
|
|
List<crm_seorderentry> sentrys = await _mysql_crm_seorderentry.GetListAsync(p => p.tenant_id == input.tenantId && p.factory_id == input.factoryId && p.seorder_id == input.sorderId && !p.IsDeleted);
|
|
|
|
|
|
+ //删除同步Mysql后旧数据
|
|
|
+ await DeleteMySqlOldData(sentrys);
|
|
|
+
|
|
|
+
|
|
|
//数据库快照-同步mysql库数据到mongoDB中
|
|
|
await DbSnapShot(input.tenantId, input.factoryId, bangid);
|
|
|
|
|
|
@@ -372,7 +376,7 @@ namespace Business.ResourceExamineManagement
|
|
|
|
|
|
_CalcBomViewAppService.param = param;
|
|
|
_CalcBomViewAppService.planList = planList;
|
|
|
- _CalcBomViewAppService.leadTimeList= leadTimeList;
|
|
|
+ _CalcBomViewAppService.leadTimeList = leadTimeList;
|
|
|
_CalcBomViewAppService.supplierList = supplierList;
|
|
|
foreach (var item in sentrys)
|
|
|
{
|
|
|
@@ -396,7 +400,7 @@ namespace Business.ResourceExamineManagement
|
|
|
//计算
|
|
|
_CalcBomViewAppService.CalcView(getBomList, bangid, item.qty.Value, input, item.plan_date, sklist, item, icitemlist);
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
//TODO:最晚开始时间
|
|
|
var curFacDtl = leadTimeList.FirstOrDefault(p => p.item_id == childBom.icitem_id);
|
|
|
@@ -408,8 +412,6 @@ namespace Business.ResourceExamineManagement
|
|
|
dtl.substitutes = getBomList;
|
|
|
//添加订单行开工信息
|
|
|
examines.Add(dtl);
|
|
|
- //生成工单 TODO:0=产品数量
|
|
|
- //GenerateMorder(o, 0);
|
|
|
}
|
|
|
if (_CalcBomViewAppService.mooccupyAllList.Any())
|
|
|
{
|
|
|
@@ -430,6 +432,7 @@ namespace Business.ResourceExamineManagement
|
|
|
//清空快照数据
|
|
|
await ClearSnapShot(bangid);
|
|
|
return JsonConvert.SerializeObject(rtn);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -462,6 +465,33 @@ namespace Business.ResourceExamineManagement
|
|
|
GetIcBomData(curBoms, bomlist, bomchildlist);
|
|
|
}
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 删除旧订单行数据
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="tenantId"></param>
|
|
|
+ /// <param name="factoryId"></param>
|
|
|
+ /// <param name="soentry_id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task DeleteMySqlOldData(List<crm_seorderentry> soentry_id)
|
|
|
+ {
|
|
|
+ //删除工单相关表数据
|
|
|
+ var mes_moentry = _mysql_mes_moentry.GetListAsync(x => soentry_id.Select(p => p.Id).Contains(x.soentry_id.Value)).Result;
|
|
|
+
|
|
|
+ var mes_morder = _mysql_mes_morder.GetListAsync(x => mes_moentry.Select(p => p.moentry_moid).ToList().Contains(x.Id)).Result;
|
|
|
+ if (mes_moentry.Count > 0)
|
|
|
+ {
|
|
|
+ await _mysql_mes_moentry.DeleteManyAsync(mes_moentry);
|
|
|
+ }
|
|
|
+ if (mes_morder.Count > 0)
|
|
|
+ {
|
|
|
+ await _mysql_mes_morder.DeleteManyAsync(mes_morder);
|
|
|
+ }
|
|
|
+ var mysql_mes_mooccupy = _mysql_mes_mooccupy.GetListAsync(x => soentry_id.Select(p => p.Id).Contains(x.moo_id_billid.Value)).Result;
|
|
|
+ if (mysql_mes_mooccupy.Count > 0)
|
|
|
+ {
|
|
|
+ await _mysql_mes_mooccupy.DeleteManyAsync(mysql_mes_mooccupy);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 数据库快照
|
|
|
@@ -580,10 +610,16 @@ namespace Business.ResourceExamineManagement
|
|
|
ProjectionDefinitionBuilder<mo_ic_factory_details> project = new ProjectionDefinitionBuilder<mo_ic_factory_details>();
|
|
|
return _ic_factory_details.Find(p => icItemIds.Contains(p.icitem_id) && p.factory_id == factoryid && p.tenant_id == tenantId && !p.IsDeleted,
|
|
|
project.Include(p => p.icitem_id).Include(p => p.production_leadtime).Include(p => p.stock_leadtime).
|
|
|
- Include(p => p.transportation_leadtime).Include(p => p.order_leadtime).Include(p=>p.minorderqty)).Result.
|
|
|
- Select(x => new ICItemLeadTimeDto { item_id = x.icitem_id, transportation_leadtime = x.transportation_leadtime,
|
|
|
- stock_leadtime = x.stock_leadtime, production_leadtime = x.production_leadtime,
|
|
|
- order_leadtime = x.order_leadtime,minorderqty=x.minorderqty }).AsQueryable<ICItemLeadTimeDto>().ToList();
|
|
|
+ Include(p => p.transportation_leadtime).Include(p => p.order_leadtime).Include(p => p.minorderqty)).Result.
|
|
|
+ Select(x => new ICItemLeadTimeDto
|
|
|
+ {
|
|
|
+ item_id = x.icitem_id,
|
|
|
+ transportation_leadtime = x.transportation_leadtime,
|
|
|
+ stock_leadtime = x.stock_leadtime,
|
|
|
+ production_leadtime = x.production_leadtime,
|
|
|
+ order_leadtime = x.order_leadtime,
|
|
|
+ minorderqty = x.minorderqty
|
|
|
+ }).AsQueryable<ICItemLeadTimeDto>().ToList();
|
|
|
}
|
|
|
|
|
|
//根据物料id获取物料供应商
|
|
|
@@ -872,7 +908,7 @@ namespace Business.ResourceExamineManagement
|
|
|
return sRMPR;
|
|
|
//throw new NotImplementedException("未找到物料ic_factory_details或ic_item_pur或ic_plan信息!");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
srm_Pr.GenerateNewId();
|
|
|
srm_Pr.pr_billno = getOrderNum("PR");//pr单号
|
|
|
srm_Pr.pr_mono = "";//关联工单号
|
|
|
@@ -908,7 +944,7 @@ namespace Business.ResourceExamineManagement
|
|
|
srm_Pr.bang_id = bangId;
|
|
|
//_srm_pr_main.InsertOne(srm_Pr);
|
|
|
decimal? totalLeadTime = leadTime.transportation_leadtime + leadTime.stock_leadtime + leadTime.production_leadtime + leadTime.order_leadtime;
|
|
|
-
|
|
|
+
|
|
|
sRMPR.srm_Pr_Main = srm_Pr;
|
|
|
sRMPR.lastStartTmie = deliveryDate.AddDays((double)totalLeadTime * -1);//减去提前期
|
|
|
return sRMPR;
|