|
|
@@ -6,6 +6,8 @@ using Business.Dto;
|
|
|
using Business.EntityFrameworkCore;
|
|
|
using Business.EntityFrameworkCore.SqlRepositories;
|
|
|
using Business.PriorityManagement;
|
|
|
+using Business.Replenishment;
|
|
|
+using Business.ReplenishmentManagement;
|
|
|
using Business.ResourceExamineManagement.Dto;
|
|
|
using Business.StructuredDB.SaleFcst;
|
|
|
using Business.StructuredDB.WMS;
|
|
|
@@ -298,6 +300,11 @@ namespace Business.ResourceExamineManagement
|
|
|
|
|
|
private readonly SerialNumberAppService _serialNumberAppService;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 优先级
|
|
|
+ /// </summary>
|
|
|
+ private readonly ReplenishmentAppService _replenishmentAppService;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 计算BOM平铺物料情况
|
|
|
/// </summary>
|
|
|
@@ -471,7 +478,8 @@ namespace Business.ResourceExamineManagement
|
|
|
ISqlRepository<MonthlyShipmentPlan> monthlyShipmentPlan,
|
|
|
IRepository<srm_purchase, long> srmPurchase,
|
|
|
IUnitOfWorkManager unitOfWorkManager,
|
|
|
- SerialNumberAppService serialNumberAppService
|
|
|
+ SerialNumberAppService serialNumberAppService,
|
|
|
+ ReplenishmentAppService replenishmentAppService
|
|
|
)
|
|
|
{
|
|
|
_mes_technique = mes_technique;
|
|
|
@@ -560,6 +568,7 @@ namespace Business.ResourceExamineManagement
|
|
|
_unitOfWorkManager = unitOfWorkManager;
|
|
|
_scheduleResultOpMaster = scheduleResultOpMaster;
|
|
|
_serialNumberAppService = serialNumberAppService;
|
|
|
+ _replenishmentAppService = replenishmentAppService;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
@@ -1033,7 +1042,7 @@ namespace Business.ResourceExamineManagement
|
|
|
srm_Pr.pr_purchasenumber = prlist[0].pr_purchasenumber;//供应商编码
|
|
|
srm_Pr.pr_purchasename = prlist[0].pr_purchasename;//供应商名称
|
|
|
srm_Pr.pr_purchaser = prlist[0].pr_purchaser;//采购员
|
|
|
- srm_Pr.pr_purchaser_num = "";//采购员工号(采购信息表)*//*
|
|
|
+ srm_Pr.pr_purchaser_num = prlist[0].pr_purchaser_num;//采购员工号(采购信息表)*//*
|
|
|
srm_Pr.pr_rqty = prlist.Sum(s => s.pr_rqty);//需求数量
|
|
|
srm_Pr.pr_aqty = prlist.Sum(s => s.pr_aqty);//申请数量
|
|
|
srm_Pr.pr_sqty = prlist.Sum(s => s.pr_sqty);//建议数量
|
|
|
@@ -1594,6 +1603,20 @@ namespace Business.ResourceExamineManagement
|
|
|
//PO占用记录
|
|
|
List<mo_srm_po_occupy> po_occupy = await _srm_po_occupy.GetListAsync(s => seIds.Contains(s.eid.Value) && bangidList.Contains(s.bang_id.Value));
|
|
|
List<mo_srm_pr_main> prmainlist = await _srm_pr_main.GetListAsync(s => seIds.Contains(s.sentry_id.Value) && bangidList.Contains(s.bang_id.Value));
|
|
|
+ if (prmainlist.Any())
|
|
|
+ {
|
|
|
+ var nbrlistDto = _serialNumberAppService.GetBillNo(prmainlist[0].factory_id.ToString(), "PR", prmainlist.Count, "admin", 1);
|
|
|
+ int index = 0;
|
|
|
+ foreach (var p in prmainlist)
|
|
|
+ {
|
|
|
+ if (nbrlistDto[index] != null)
|
|
|
+ {
|
|
|
+ p.pr_billno = nbrlistDto[index].NbrResult;
|
|
|
+ }
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
List<mo_ic_item_stockoccupy> item_stockoccupy = await _ic_item_stockoccupy.GetListAsync(s => seIds.Contains(s.orderentry_id.Value) && bangidList.Contains(s.bang_id));
|
|
|
|
|
|
using (var unitOfWork = _unitOfWorkManager.Begin(false, true))
|
|
|
@@ -2147,7 +2170,7 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
srm_po_main po_Main = new srm_po_main();
|
|
|
po_Main.GenerateNewId(help.NextId());
|
|
|
- po_Main.po_billno = poType == 1 ? GetMaxSerialNumber(416188684804165) : GetMaxSerialNumber(416555323363397);
|
|
|
+ po_Main.po_billno = help.NextId().ToString();
|
|
|
var pr = list.Find(s => s.Id == dto.polist[0].pr_id);
|
|
|
var itemsupplier = itemsupplierList.Find(a => a.Id == pr.pr_purchaseid);
|
|
|
po_Main.po_purchaser = pr.pr_purchaser;
|
|
|
@@ -2223,6 +2246,23 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
poaction.poMain.AddRange(polist);
|
|
|
poaction.polist.AddRange(podetaillist);
|
|
|
+
|
|
|
+ var nbrlistDto = _serialNumberAppService.GetBillNo(domain, "DO", polist.Count, "admin", 1);
|
|
|
+ int index = 0;
|
|
|
+ foreach (var p in polist)
|
|
|
+ {
|
|
|
+ if (nbrlistDto[index] != null)
|
|
|
+ {
|
|
|
+ var podtls = podetaillist.Where(s => s.po_billno == p.po_billno).ToList();
|
|
|
+
|
|
|
+ p.po_billno = nbrlistDto[index].NbrResult;
|
|
|
+ podtls.ForEach(s =>
|
|
|
+ {
|
|
|
+ s.po_billno = p.po_billno;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ index++;
|
|
|
+ }
|
|
|
List<PurOrdMaster> purOrdMasters = new List<PurOrdMaster>();
|
|
|
polist.ForEach(a =>
|
|
|
{
|
|
|
@@ -2231,7 +2271,7 @@ namespace Business.ResourceExamineManagement
|
|
|
Domain = domain,
|
|
|
Potype = poType==1?"po":"pw",
|
|
|
PurOrd = a.po_billno,
|
|
|
- Buyer = a.po_purchaser,
|
|
|
+ Buyer = a.po_purchaser_no,
|
|
|
OrdDate = a.po_ssend_date,
|
|
|
Curr = "CNY",
|
|
|
Supp = a.supplier_no,
|
|
|
@@ -3526,24 +3566,36 @@ namespace Business.ResourceExamineManagement
|
|
|
});
|
|
|
_locationDetail.Update(locStock);*/
|
|
|
}
|
|
|
+ if (nbrMasterList.Any())
|
|
|
+ {
|
|
|
+ var nbrlistDto = _serialNumberAppService.GetBillNo(workOrdMasters[0].Domain, "SM", nbrMasterList.Count, userAccount, 1);
|
|
|
+ if (nbrlistDto.Any())
|
|
|
+ {
|
|
|
+ int index = 0;
|
|
|
+ foreach (var nm in nbrMasterList)
|
|
|
+ {
|
|
|
+ var nbrDtls = nbrDetailList.Where(s => s.Nbr == nm.Nbr).ToList();
|
|
|
+ if (nbrlistDto[index] != null)
|
|
|
+ {
|
|
|
+ nm.Nbr = nbrlistDto[index].NbrResult;
|
|
|
+ nbrDtls.ForEach(i => { i.Nbr = nm.Nbr; });
|
|
|
+ }
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void GenerateNbr(WorkOrdMaster workord,decimal cleanTime, LineMaster defaultLine, string userAccount, List<NbrMaster> nbrMasterList, List<NbrDetail> nbrDetailList, List<WorkOrdDetail> detail, List<ItemMaster> itemLocList, List<EmpWorkDutyMaster> ewdmList, string LocationTo,EmployeeMaster user,string TransType)
|
|
|
{
|
|
|
- //var Nbr = GetMaxSerialNumber(417416915624005);
|
|
|
- string Nbr = "";
|
|
|
+ string Nbr = help.NextId().ToString();
|
|
|
DateTime eff = workord.OrdDate.GetValueOrDefault().Date.AddDays(-1);
|
|
|
DateTime start = eff.AddDays((double)(0 - cleanTime));
|
|
|
if (start <= DateTime.Now.Date)
|
|
|
{
|
|
|
start = DateTime.Now.Date;
|
|
|
}
|
|
|
- var nbrlistDto = _serialNumberAppService.GetBillNo(workord.Domain, "SM", 1, userAccount, 1);
|
|
|
- if (nbrlistDto.Any())
|
|
|
- {
|
|
|
- Nbr = nbrlistDto[0].NbrResult;
|
|
|
- }
|
|
|
var newNbr = new NbrMaster
|
|
|
{
|
|
|
Domain = workord.Domain,
|
|
|
@@ -4354,10 +4406,16 @@ namespace Business.ResourceExamineManagement
|
|
|
workOrd.JointTyped = "B";
|
|
|
_workOrdMaster.Update(workOrd);
|
|
|
|
|
|
+ //获取需要排产的工单(获取四周的工单:正常工单+已审批通过的特殊工单)
|
|
|
+ DateTime endDate = DateTime.Now.Date.AddDays(28).AddDays(1);
|
|
|
+ //取数开始时间为当前天的下一天
|
|
|
+ DateTime startDate = DateTime.Now.Date.AddDays(1);
|
|
|
+ //尚未开始生产的工单+正在生产的工单
|
|
|
+ var workOrds = _workOrdMaster.Select(p => p.IsActive && p.Domain == input.domain && ((p.OrdDate < endDate && p.OrdDate >= startDate && (string.IsNullOrEmpty(p.Typed) || (!string.IsNullOrEmpty(p.Typed) && p.BusinessID > 0))) || p.Status.ToLower() == "w")).ToList();
|
|
|
//调用优先级计算算法
|
|
|
-
|
|
|
- //调用手动排产算法
|
|
|
- string result = await ProductionSchedule(input.domain);
|
|
|
+ workOrds = _replenishmentAppService.CalcPriority(workOrds.Select(p=>p.WorkOrd).ToList(), input.domain);
|
|
|
+ //执行排产
|
|
|
+ string result = await _productionScheduleAppService.DoProductSchedule(workOrds, input.domain, 2);
|
|
|
return result;
|
|
|
}
|
|
|
|