|
|
@@ -437,14 +437,14 @@ namespace Business.Replenishment
|
|
|
var expectedList = sapItemList.Except(planItemList).ToList();
|
|
|
if (expectedList.Count > 0)
|
|
|
{
|
|
|
- throw new NotImplementedException("年度销售预测物料" + string.Join(",", expectedList) + "在DOP物料表找不到!");
|
|
|
+ return "年度销售预测物料" + string.Join(",", expectedList) + "在DOP物料表找不到!";
|
|
|
}
|
|
|
|
|
|
var bomItemList = bomList.Select(a => a.item_number).Distinct().ToList();
|
|
|
var expectedBOMList = sapItemList.Except(bomItemList).ToList();
|
|
|
if (expectedBOMList.Count > 0)
|
|
|
{
|
|
|
- throw new NotImplementedException("年度销售预测物料" + string.Join(",", expectedBOMList) + "在BOM没有维护!");
|
|
|
+ return "年度销售预测物料" + string.Join(",", expectedBOMList) + "在BOM没有维护!";
|
|
|
}
|
|
|
var itemMasterList = _itemMaster.Select(i => sapItemList.Contains(i.ItemNum) && i.Domain == input.factory_id.ToString());
|
|
|
List<RoutingOpDetail> routingOps = _routingOpDetail.Select(p => sapItemList.Contains(p.RoutingCode) && p.Domain == input.factory_id.ToString() && p.IsActive);
|
|
|
@@ -497,14 +497,10 @@ namespace Business.Replenishment
|
|
|
List<YearDemandManagement> frontYearDemand = new List<YearDemandManagement>();
|
|
|
for(int i=0;i< yearDemands.Count;i++)
|
|
|
{
|
|
|
- if (yearDemands.Where(a=>a.SAPItemNumber==yearDemands[i].SAPItemNumber).Count()!=12)
|
|
|
+ if (yearDemands.Where(a => a.SAPItemNumber == yearDemands[i].SAPItemNumber).Count() != 12)
|
|
|
{
|
|
|
- throw new NotImplementedException("年度销售预测物料" + yearDemands[i].SAPItemNumber + "年度的12个月数据不完整!");
|
|
|
+ return "年度销售预测物料" + yearDemands[i].SAPItemNumber + "年度的12个月数据不完整或者存在重复物料!";
|
|
|
}
|
|
|
- //if (yearDemands.Where(a => a.SAPItemNumber == yearDemands[i].SAPItemNumber).Sum(s=>s.Qty)==0)
|
|
|
- //{
|
|
|
- // throw new NotImplementedException("年度销售预测物料" + yearDemands[i].SAPItemNumber + "年度的12个月数据不能全为零!");
|
|
|
- //}
|
|
|
frontYearDemand.Add(yearDemands[i]);
|
|
|
var routingOp = routingOps.Where(x => x.RoutingCode == yearDemands[i].SAPItemNumber).ToList();
|
|
|
//组装标准工时
|
|
|
@@ -1945,7 +1941,7 @@ namespace Business.Replenishment
|
|
|
}
|
|
|
}
|
|
|
List<string> subItems = new List<string>();
|
|
|
- for (int j = 0; j < 4; j++)
|
|
|
+ for (int j = 0; j < 3; j++)
|
|
|
{
|
|
|
var jweekTime = GetNextMonday().AddDays(28);
|
|
|
jweekTime = jweekTime.AddDays(28 * j);
|
|
|
@@ -1954,10 +1950,11 @@ namespace Business.Replenishment
|
|
|
}
|
|
|
var weeksubPlanList = _replenishmentWeekPlan.GetListAsync(a => subItems.Contains(a.PlanMonth) && !a.IsDeleted && a.factory_id == input.factory_id && a.IsReplenishmentModel == "N").Result;
|
|
|
//中间件钉匣泡壳四周开一张工单
|
|
|
- for (int i = 0; i < 4; i++)
|
|
|
+ for (int i = 0; i < 3; i++)
|
|
|
{
|
|
|
var weekTime = GetNextMonday().AddDays(28);
|
|
|
weekTime = weekTime.AddDays(28 * i);
|
|
|
+ var weekofMonth = WeekOfMonth(weekTime, 1);
|
|
|
string kMonth = $"{weekTime.Year}-{weekTime.Month.ToString("00")}";
|
|
|
if (prodLines.Count == 0)
|
|
|
{
|
|
|
@@ -2063,7 +2060,7 @@ namespace Business.Replenishment
|
|
|
weekItem.Year = mes_Morder.moentry_sys_stime.Value.Year;
|
|
|
weekItem.Month = mes_Morder.moentry_sys_stime.Value.Month;
|
|
|
weekItem.PlanMonth = kMonth;
|
|
|
- weekItem.WeekSeq = WeekOfMonth(weekTime, 1);
|
|
|
+ weekItem.WeekSeq = weekofMonth;
|
|
|
weekItem.tenant_id = input.tenant_id;
|
|
|
weekItem.factory_id = input.factory_id;
|
|
|
weekItem.company_id = input.company_id;
|
|
|
@@ -2091,7 +2088,7 @@ namespace Business.Replenishment
|
|
|
weekPlan[i].ProductionOrder = morder_noList[i].NbrResult;
|
|
|
weekPlan[i].OrderNO = OrderNOList[i].NbrResult;
|
|
|
}
|
|
|
- await PlanOrderResourceCheck(moList, moentryList, bang_id, input,false);
|
|
|
+ await PlanOrderResourceCheck(moList, moentryList, bang_id, input);
|
|
|
|
|
|
var examine_resultList = _mysql_examine_result.GetListAsync(a => a.bangid == bang_id).Result;
|
|
|
await _businessDbContext.BulkInsertAsync(moList);
|
|
|
@@ -2232,8 +2229,9 @@ namespace Business.Replenishment
|
|
|
/// <returns></returns>
|
|
|
public async Task<string> PublishWeekPlan(InputDto input)
|
|
|
{
|
|
|
+ //默认发布未来四周工单
|
|
|
DateTime nextWeekMonday = getPreWeekStartTime().AddDays(14);
|
|
|
- DateTime next2WeekMonday = getPreWeekStartTime().AddDays(28);
|
|
|
+ DateTime next2WeekMonday = getPreWeekStartTime().AddDays(42);
|
|
|
//主工单发布,子工单需要一起发布
|
|
|
var weekPlan = _replenishmentWeekPlan.GetListAsync(a => a.PlanStartDate >= nextWeekMonday && a.PlanStartDate < next2WeekMonday && a.IsReplenishmentModel == "N" && a.ProductionStatus=="").Result.OrderBy(a => a.Priority).ToList();
|
|
|
List<mes_morder> mes_Morders = _mysql_mes_morder.GetListAsync(a => weekPlan.Select(p => p.ProductionOrder).ToList().Contains(a.morder_no) && a.factory_id == input.factory_id).Result;
|
|
|
@@ -3128,7 +3126,7 @@ namespace Business.Replenishment
|
|
|
/// </summary>
|
|
|
/// <param name="input"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<string> PlanOrderResourceCheck(List<mes_morder> Mes_Morders, List<mes_moentry> moentryList,long bangid, InputDto input,bool longPeriodCheck)
|
|
|
+ public async Task<string> PlanOrderResourceCheck(List<mes_morder> Mes_Morders, List<mes_moentry> moentryList,long bangid, InputDto input)
|
|
|
{
|
|
|
if (Mes_Morders.Any())
|
|
|
{
|
|
|
@@ -3188,7 +3186,7 @@ namespace Business.Replenishment
|
|
|
// _scheduleResultOpMaster.Delete(s => monolist.Contains(s.WorkOrd));
|
|
|
//}
|
|
|
//只走计划工单
|
|
|
- var rtn = await OrderKittingCheck(Mes_Morders, moentryList, bangid, longPeriodCheck, true);
|
|
|
+ var rtn = await OrderKittingCheck(Mes_Morders, moentryList, bangid, true);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -3238,7 +3236,7 @@ namespace Business.Replenishment
|
|
|
/// 工单检查物料齐套
|
|
|
/// </summary>
|
|
|
/// <param name="input"></param>
|
|
|
- public async Task<PschedDto> OrderKittingCheck(List<mes_morder> mo_Mes_Morders, List<mes_moentry> moentryList,long bangid,bool longPeriodCheck, bool planCheck = false)
|
|
|
+ public async Task<PschedDto> OrderKittingCheck(List<mes_morder> mo_Mes_Morders, List<mes_moentry> moentryList,long bangid, bool planCheck = false)
|
|
|
{
|
|
|
//资源检查结果
|
|
|
PschedDto rtn = new PschedDto();
|
|
|
@@ -3386,16 +3384,6 @@ namespace Business.Replenishment
|
|
|
}
|
|
|
if (prmainlist.Any())
|
|
|
{
|
|
|
- var ropParam = GetROPParam(input.factoryId.ToString());
|
|
|
- var itemIds = prmainlist.Select(a => a.icitem_id).Distinct().ToList();
|
|
|
- var itemList=_mysql_ic_item.GetListAsync(a => itemIds.Contains(a.Id) && a.factory_id == input.factoryId).Result;
|
|
|
- var mesItem = _itemMaster.Select(a => itemList.Select(a=>a.number).ToList().Contains(a.ItemNum) && a.PurLT>= ropParam.LongPeriodDay && a.IsActive && a.Domain == input.factoryId.ToString());
|
|
|
- List<long> longPRIds = new List<long>();
|
|
|
- foreach(var item in mesItem)
|
|
|
- {
|
|
|
- longPRIds.Add(itemList.Find(a => a.number == item.ItemNum).Id);
|
|
|
- }
|
|
|
- prmainlist = prmainlist.Where(a => longPRIds.Contains(a.icitem_id.GetValueOrDefault())).ToList();
|
|
|
var nbrlistDto = _serialNumberAppService.GetBillNo(prmainlist[0].factory_id.ToString(), "PR", prmainlist.Count, "admin", 1);
|
|
|
int index = 0;
|
|
|
foreach (var p in prmainlist)
|
|
|
@@ -3675,7 +3663,8 @@ namespace Business.Replenishment
|
|
|
var moIcitemStokc = ObjectMapper.Map<List<ic_item_stock>, List<mo_ic_item_stock>>(icitemStokc);
|
|
|
moIcitemStokc.ForEach(item => { item.GenerateNewId(help.NextId()); });
|
|
|
//插入数据
|
|
|
- await _ic_item_stock.InsertManyAsync(moIcitemStokc);
|
|
|
+ //await _ic_item_stock.InsertManyAsync(moIcitemStokc);
|
|
|
+ await MongoHelper<mo_ic_item_stock>.InsertManyAsync(moIcitemStokc);
|
|
|
}
|
|
|
|
|
|
var workordmsters = _workOrdMaster.Select(s => s.Domain == factoryId.ToString() && string.IsNullOrEmpty(s.Status) != true && s.Status.ToLower() != "c");
|
|
|
@@ -3714,7 +3703,8 @@ namespace Business.Replenishment
|
|
|
{
|
|
|
var mo_item_occupy = ObjectMapper.Map<List<ic_item_stockoccupy>, List<mo_ic_item_stockoccupy>>(item_occupy);
|
|
|
mo_item_occupy.ForEach(item => { item.GenerateNewId(help.NextId()); item.bang_id = bangid; });
|
|
|
- await _ic_item_stockoccupy.InsertManyAsync(mo_item_occupy);
|
|
|
+ //await _ic_item_stockoccupy.InsertManyAsync(mo_item_occupy);
|
|
|
+ await MongoHelper<mo_ic_item_stockoccupy>.InsertManyAsync(mo_item_occupy);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -3725,7 +3715,8 @@ namespace Business.Replenishment
|
|
|
mes_morder.ForEach(item => { item.bang_id = bangid; });
|
|
|
var moMes_morder = ObjectMapper.Map<List<mes_morder>, List<mo_mes_morder>>(mes_morder);
|
|
|
moMes_morder.ForEach(item => { item.GenerateNewId(help.NextId()); });
|
|
|
- await _mes_morder.InsertManyAsync(moMes_morder);
|
|
|
+ //await _mes_morder.InsertManyAsync(moMes_morder);
|
|
|
+ await MongoHelper<mo_mes_morder>.InsertManyAsync(moMes_morder);
|
|
|
}
|
|
|
//工单子表
|
|
|
var mes_moentry = _mysql_mes_moentry.GetListAsync(x => x.company_id == companyId && x.factory_id == factoryId).Result;
|
|
|
@@ -3734,7 +3725,8 @@ namespace Business.Replenishment
|
|
|
mes_moentry.ForEach(item => { item.bang_id = bangid; });
|
|
|
var moMes_moentry = ObjectMapper.Map<List<mes_moentry>, List<mo_mes_moentry>>(mes_moentry);
|
|
|
moMes_moentry.ForEach(item => { item.GenerateNewId(help.NextId()); });
|
|
|
- await _mes_moentry.InsertManyAsync(moMes_moentry);
|
|
|
+ //await _mes_moentry.InsertManyAsync(moMes_moentry);
|
|
|
+ await MongoHelper<mo_mes_moentry>.InsertManyAsync(moMes_moentry);
|
|
|
}
|
|
|
|
|
|
//在制工单占用记录表
|
|
|
@@ -3743,7 +3735,8 @@ namespace Business.Replenishment
|
|
|
{
|
|
|
var moMes_mooccupy = ObjectMapper.Map<List<mes_mooccupy>, List<mo_mes_mooccupy>>(mes_mooccupy);
|
|
|
moMes_mooccupy.ForEach(item => { item.GenerateNewId(help.NextId()); item.bang_id = bangid; });
|
|
|
- await _mes_mooccupy.InsertManyAsync(moMes_mooccupy);
|
|
|
+ //await _mes_mooccupy.InsertManyAsync(moMes_mooccupy);
|
|
|
+ await MongoHelper<mo_mes_mooccupy>.InsertManyAsync(moMes_mooccupy);
|
|
|
}
|
|
|
}
|
|
|
//根据物料信息,只同步在途未关闭的采购订单和采购申请
|
|
|
@@ -3758,13 +3751,14 @@ namespace Business.Replenishment
|
|
|
{
|
|
|
var moSrm_po_main = ObjectMapper.Map<List<srm_po_main>, List<mo_srm_po_main>>(srm_po_main);
|
|
|
moSrm_po_main.ForEach(item => { item.GenerateNewId(help.NextId()); item.bang_id = bangid; });
|
|
|
- await _srm_po_main.InsertManyAsync(moSrm_po_main);
|
|
|
-
|
|
|
+ //await _srm_po_main.InsertManyAsync(moSrm_po_main);
|
|
|
+ await MongoHelper<mo_srm_po_main>.InsertManyAsync(moSrm_po_main);
|
|
|
//订单明细--根据在途PO过滤出有效的Po_list
|
|
|
srm_po_list = srm_po_list.Where(s => srm_po_main.Select(x => x.Id).Contains(s.po_id.GetValueOrDefault())).ToList();
|
|
|
var moSrm_po_list = ObjectMapper.Map<List<srm_po_list>, List<mo_srm_po_list>>(srm_po_list);
|
|
|
moSrm_po_list.ForEach(item => { item.GenerateNewId(help.NextId()); item.bang_id = bangid; });
|
|
|
- await _srm_po_list.InsertManyAsync(moSrm_po_list);
|
|
|
+ //await _srm_po_list.InsertManyAsync(moSrm_po_list);
|
|
|
+ await MongoHelper<mo_srm_po_list>.InsertManyAsync(moSrm_po_list);
|
|
|
}
|
|
|
//采购订单明细占用详情
|
|
|
var srm_po_occupy = _mysql_srm_po_occupy.GetListAsync(x => x.company_id == companyId && x.factory_id == factoryId && srm_po_list.Select(c => c.Id).Contains(x.polist_id.GetValueOrDefault())).Result;
|
|
|
@@ -3772,7 +3766,8 @@ namespace Business.Replenishment
|
|
|
{
|
|
|
var moSrm_po_occupy = ObjectMapper.Map<List<srm_po_occupy>, List<mo_srm_po_occupy>>(srm_po_occupy);
|
|
|
moSrm_po_occupy.ForEach(item => { item.GenerateNewId(help.NextId()); item.bang_id = bangid; });
|
|
|
- await _srm_po_occupy.InsertManyAsync(moSrm_po_occupy);
|
|
|
+ //await _srm_po_occupy.InsertManyAsync(moSrm_po_occupy);
|
|
|
+ await MongoHelper<mo_srm_po_occupy>.InsertManyAsync(moSrm_po_occupy);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -3782,15 +3777,18 @@ namespace Business.Replenishment
|
|
|
{
|
|
|
var moSrm_pr_main = ObjectMapper.Map<List<srm_pr_main>, List<mo_srm_pr_main>>(srm_pr_main);
|
|
|
moSrm_pr_main.ForEach(item => { item.GenerateNewId(help.NextId()); item.bang_id = bangid; });
|
|
|
- await _srm_pr_main.InsertManyAsync(moSrm_pr_main);
|
|
|
+ //await _srm_pr_main.InsertManyAsync(moSrm_pr_main);
|
|
|
+ await MongoHelper<mo_srm_pr_main>.InsertManyAsync(moSrm_pr_main);
|
|
|
|
|
|
//采购申请占用详情
|
|
|
- var srm_pr_occupy = _mysql_srm_po_occupy.GetListAsync(x => x.company_id == companyId && x.factory_id == factoryId && srm_pr_main.Select(c => c.Id).Contains(x.polist_id.GetValueOrDefault())).Result;
|
|
|
+ var srm_pr_occupy=_businessDbContext.srm_po_occupy.Where(x => x.company_id == companyId && x.factory_id == factoryId && srm_pr_main.Select(c => c.Id).Contains(x.polist_id.Value)).ToList();
|
|
|
+ //var srm_pr_occupy = _mysql_srm_po_occupy.GetListAsync(x => x.company_id == companyId && x.factory_id == factoryId && srm_pr_main.Select(c => c.Id).Contains(x.polist_id.GetValueOrDefault())).Result;
|
|
|
if (srm_pr_occupy.Count > 0)
|
|
|
{
|
|
|
var moSrm_pr_occupy = ObjectMapper.Map<List<srm_po_occupy>, List<mo_srm_po_occupy>>(srm_pr_occupy);
|
|
|
moSrm_pr_occupy.ForEach(item => { item.GenerateNewId(help.NextId()); item.bang_id = bangid; });
|
|
|
- await _srm_po_occupy.InsertManyAsync(moSrm_pr_occupy);
|
|
|
+ //await _srm_po_occupy.InsertManyAsync(moSrm_pr_occupy);
|
|
|
+ await MongoHelper<mo_srm_po_occupy>.InsertManyAsync(moSrm_pr_occupy);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -4217,7 +4215,7 @@ namespace Business.Replenishment
|
|
|
//长周期物料只产生PR不生成实际工单
|
|
|
//await _mysql_mes_morder.InsertManyAsync(moList);
|
|
|
//await _mysql_mes_moentry.InsertManyAsync(moentryList);
|
|
|
- await PlanOrderResourceCheck(moList,moentryList, bangid,input,true);
|
|
|
+ await PlanOrderResourceCheck(moList,moentryList, bangid,input);
|
|
|
return "OK";
|
|
|
}
|
|
|
|