|
@@ -4512,22 +4512,13 @@ namespace Business.ResourceExamineManagement
|
|
|
List<mo_ic_item_stock> stocklist = new List<mo_ic_item_stock>();
|
|
List<mo_ic_item_stock> stocklist = new List<mo_ic_item_stock>();
|
|
|
//物料占用记录
|
|
//物料占用记录
|
|
|
List<mo_ic_item_stockoccupy> sklist = new List<mo_ic_item_stockoccupy>();
|
|
List<mo_ic_item_stockoccupy> sklist = new List<mo_ic_item_stockoccupy>();
|
|
|
- //工单物料信息组成bom清单
|
|
|
|
|
- var pretreatments = _mysql_b_bom_pretreatment.GetListAsync(s => mo_Mes_Morders.Select(c => c.Id).ToList().Contains(s.sourceid)).Result;
|
|
|
|
|
- int autoCreates = 0;
|
|
|
|
|
- mo_Mes_Morders.ForEach(p =>
|
|
|
|
|
- {
|
|
|
|
|
- if (!pretreatments.Where(s => s.sourceid == p.Id).Any())
|
|
|
|
|
- {
|
|
|
|
|
- autoCreates++;
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- if (autoCreates>0)
|
|
|
|
|
- {
|
|
|
|
|
- AutoCreateBomFromOrderDetail(boms, icitemlist, mo_Mes_Morders, workOrdDetails);
|
|
|
|
|
- pretreatments = _mysql_b_bom_pretreatment.GetListAsync(s => boms.Select(c => c.mysql_id).ToList().Contains(s.sourceid)).Result;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //工单物料和领料信息组成bom清单
|
|
|
|
|
+ var nbrDetails = _nbrDetail.Select(n=> workOrds.Select(s => s.WorkOrd).Contains(n.WorkOrd));
|
|
|
|
|
+ //排除领料单已发料数量
|
|
|
|
|
+ AutoCreateBomFromOrderDetail(boms, icitemlist, mo_Mes_Morders, workOrdDetails, nbrDetails);
|
|
|
|
|
+ //排除已发完料的工单
|
|
|
|
|
+ var pretreatments = _mysql_b_bom_pretreatment.GetListAsync(s => mo_Mes_Morders.Select(c => c.Id).ToList().Contains(s.sourceid) && s.version != "ok").Result;
|
|
|
|
|
+
|
|
|
await AsyncItemStockFromWMS(pretreatments);
|
|
await AsyncItemStockFromWMS(pretreatments);
|
|
|
//数据库快照-同步mysql库数据到mongoDB中
|
|
//数据库快照-同步mysql库数据到mongoDB中
|
|
|
await DbSnapShot(param.company_id, param.factoryId, bangid, pretreatments);
|
|
await DbSnapShot(param.company_id, param.factoryId, bangid, pretreatments);
|
|
@@ -4667,7 +4658,7 @@ namespace Business.ResourceExamineManagement
|
|
|
return rtn;
|
|
return rtn;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void AutoCreateBomFromOrderDetail(List<mo_ic_bom> boms, List<mo_ic_item> icitemlist, List<mes_morder> mo_Mes_Morders,List<WorkOrdDetail> workOrdDetails)
|
|
|
|
|
|
|
+ public void AutoCreateBomFromOrderDetail(List<mo_ic_bom> boms, List<mo_ic_item> icitemlist, List<mes_morder> mo_Mes_Morders,List<WorkOrdDetail> workOrdDetails, List<NbrDetail> nbrDetails)
|
|
|
{
|
|
{
|
|
|
List<BomChildExamineDto> bomChildExamineDtos = new List<BomChildExamineDto>();
|
|
List<BomChildExamineDto> bomChildExamineDtos = new List<BomChildExamineDto>();
|
|
|
List<b_bom_pretreatment> deleteList = new List<b_bom_pretreatment>();
|
|
List<b_bom_pretreatment> deleteList = new List<b_bom_pretreatment>();
|
|
@@ -4701,31 +4692,75 @@ namespace Business.ResourceExamineManagement
|
|
|
bomChildExamineDto.type = 0;
|
|
bomChildExamineDto.type = 0;
|
|
|
bomChildExamineDto.PurLT = curicitem == null ? 0 : curicitem.PurLT;
|
|
bomChildExamineDto.PurLT = curicitem == null ? 0 : curicitem.PurLT;
|
|
|
bomChildExamineDto.clean_leadtime = curicitem == null ? 0 : curicitem.clean_leadtime;
|
|
bomChildExamineDto.clean_leadtime = curicitem == null ? 0 : curicitem.clean_leadtime;
|
|
|
-
|
|
|
|
|
- workOrdDetails.ForEach(d => {
|
|
|
|
|
- var curicbom = boms.Where(p => p.bom_number == d.ItemNum).FirstOrDefault();
|
|
|
|
|
- var curicitem = icitemlist.Where(p => p.number == d.ItemNum).FirstOrDefault();
|
|
|
|
|
- BomChildExamineDto bomChildExamineDto = new BomChildExamineDto();
|
|
|
|
|
- bomChildExamineDto.id = help.NextId();
|
|
|
|
|
- bomChildExamineDto.fid = help.NextId();
|
|
|
|
|
- bomChildExamineDto.bom_child_id = null;
|
|
|
|
|
- bomChildExamineDto.bom_id = null;
|
|
|
|
|
- bomChildExamineDto.bom_number = "";
|
|
|
|
|
- bomChildExamineDto.qty = d.FrozenBOMQty;
|
|
|
|
|
- bomChildExamineDto.erp_cls = curicitem == null ? 4 : curicitem.erp_cls.GetValueOrDefault();
|
|
|
|
|
- bomChildExamineDto.item_id = curicitem == null ? 0 : curicitem.Id;
|
|
|
|
|
- bomChildExamineDto.item_name = curicitem == null ? "" : curicitem.name;
|
|
|
|
|
- bomChildExamineDto.item_number = d.ItemNum;
|
|
|
|
|
- bomChildExamineDto.level = 2;
|
|
|
|
|
- bomChildExamineDto.model = curicitem == null ? "" : curicitem.model;
|
|
|
|
|
- bomChildExamineDto.unit = curicitem == null ? "" : curicitem.unit;
|
|
|
|
|
- bomChildExamineDto.num = "1."+d.Line;
|
|
|
|
|
- bomChildExamineDto.parent_id = fid;
|
|
|
|
|
- bomChildExamineDto.type = 0;
|
|
|
|
|
- bomChildExamineDto.PurLT = curicitem == null ? 0 : curicitem.PurLT;
|
|
|
|
|
- bomChildExamineDto.clean_leadtime = curicitem == null ? 0 : curicitem.clean_leadtime;
|
|
|
|
|
- bomChildExamineDtos.Add(bomChildExamineDto);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var curworkOrdDetails = workOrdDetails.Where(w=>w.WorkOrd==x.morder_no).ToList();
|
|
|
|
|
+ if (curworkOrdDetails.Any())
|
|
|
|
|
+ {
|
|
|
|
|
+ var curnbrDetails = nbrDetails.Where(n=>n.WorkOrd==x.morder_no).ToList();
|
|
|
|
|
+ if (curnbrDetails.Any())
|
|
|
|
|
+ {
|
|
|
|
|
+ curnbrDetails = curnbrDetails.Where(n=>n.Status!="C").ToList();
|
|
|
|
|
+ if (!curnbrDetails.Any())
|
|
|
|
|
+ {
|
|
|
|
|
+ bomChildExamineDto.version = "ok";
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ curnbrDetails.ForEach(d =>
|
|
|
|
|
+ {
|
|
|
|
|
+ var curicbom = boms.Where(p => p.bom_number == d.ItemNum).FirstOrDefault();
|
|
|
|
|
+ var curicitem = icitemlist.Where(p => p.number == d.ItemNum).FirstOrDefault();
|
|
|
|
|
+ BomChildExamineDto bomChildExamineDto = new BomChildExamineDto();
|
|
|
|
|
+ bomChildExamineDto.id = help.NextId();
|
|
|
|
|
+ bomChildExamineDto.fid = help.NextId();
|
|
|
|
|
+ bomChildExamineDto.bom_child_id = null;
|
|
|
|
|
+ bomChildExamineDto.bom_id = null;
|
|
|
|
|
+ bomChildExamineDto.bom_number = "";
|
|
|
|
|
+ bomChildExamineDto.qty = x.morder_production_number.GetValueOrDefault() == 0 ? 1 : d.QtyOrd - d.QtyRec / x.morder_production_number.GetValueOrDefault();
|
|
|
|
|
+ bomChildExamineDto.erp_cls = curicitem == null ? 4 : curicitem.erp_cls.GetValueOrDefault();
|
|
|
|
|
+ bomChildExamineDto.item_id = curicitem == null ? 0 : curicitem.Id;
|
|
|
|
|
+ bomChildExamineDto.item_name = curicitem == null ? "" : curicitem.name;
|
|
|
|
|
+ bomChildExamineDto.item_number = d.ItemNum;
|
|
|
|
|
+ bomChildExamineDto.level = 2;
|
|
|
|
|
+ bomChildExamineDto.model = curicitem == null ? "" : curicitem.model;
|
|
|
|
|
+ bomChildExamineDto.unit = curicitem == null ? "" : curicitem.unit;
|
|
|
|
|
+ bomChildExamineDto.num = "1." + d.Line;
|
|
|
|
|
+ bomChildExamineDto.parent_id = fid;
|
|
|
|
|
+ bomChildExamineDto.type = 0;
|
|
|
|
|
+ bomChildExamineDto.PurLT = curicitem == null ? 0 : curicitem.PurLT;
|
|
|
|
|
+ bomChildExamineDto.clean_leadtime = curicitem == null ? 0 : curicitem.clean_leadtime;
|
|
|
|
|
+ bomChildExamineDtos.Add(bomChildExamineDto);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ curworkOrdDetails.ForEach(d => {
|
|
|
|
|
+ var curicbom = boms.Where(p => p.bom_number == d.ItemNum).FirstOrDefault();
|
|
|
|
|
+ var curicitem = icitemlist.Where(p => p.number == d.ItemNum).FirstOrDefault();
|
|
|
|
|
+ BomChildExamineDto bomChildExamineDto = new BomChildExamineDto();
|
|
|
|
|
+ bomChildExamineDto.id = help.NextId();
|
|
|
|
|
+ bomChildExamineDto.fid = help.NextId();
|
|
|
|
|
+ bomChildExamineDto.bom_child_id = null;
|
|
|
|
|
+ bomChildExamineDto.bom_id = null;
|
|
|
|
|
+ bomChildExamineDto.bom_number = "";
|
|
|
|
|
+ bomChildExamineDto.qty = d.FrozenBOMQty;
|
|
|
|
|
+ bomChildExamineDto.erp_cls = curicitem == null ? 4 : curicitem.erp_cls.GetValueOrDefault();
|
|
|
|
|
+ bomChildExamineDto.item_id = curicitem == null ? 0 : curicitem.Id;
|
|
|
|
|
+ bomChildExamineDto.item_name = curicitem == null ? "" : curicitem.name;
|
|
|
|
|
+ bomChildExamineDto.item_number = d.ItemNum;
|
|
|
|
|
+ bomChildExamineDto.level = 2;
|
|
|
|
|
+ bomChildExamineDto.model = curicitem == null ? "" : curicitem.model;
|
|
|
|
|
+ bomChildExamineDto.unit = curicitem == null ? "" : curicitem.unit;
|
|
|
|
|
+ bomChildExamineDto.num = "1." + d.Line;
|
|
|
|
|
+ bomChildExamineDto.parent_id = fid;
|
|
|
|
|
+ bomChildExamineDto.type = 0;
|
|
|
|
|
+ bomChildExamineDto.PurLT = curicitem == null ? 0 : curicitem.PurLT;
|
|
|
|
|
+ bomChildExamineDto.clean_leadtime = curicitem == null ? 0 : curicitem.clean_leadtime;
|
|
|
|
|
+ bomChildExamineDtos.Add(bomChildExamineDto);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
bomChildExamineDtos.Add(bomChildExamineDto);
|
|
bomChildExamineDtos.Add(bomChildExamineDto);
|
|
|
|
|
|
|
@@ -6290,7 +6325,9 @@ namespace Business.ResourceExamineManagement
|
|
|
//按照优先级排序
|
|
//按照优先级排序
|
|
|
workOrds = workOrds.OrderBy(p => p.Priority).ToList();
|
|
workOrds = workOrds.OrderBy(p => p.Priority).ToList();
|
|
|
var morders = _mysql_mes_morder.GetListAsync(p => workOrds.Select(x => x.WorkOrd).ToList().Contains(p.morder_no) && !p.IsDeleted && p.factory_id.ToString() == domain).Result;
|
|
var morders = _mysql_mes_morder.GetListAsync(p => workOrds.Select(x => x.WorkOrd).ToList().Contains(p.morder_no) && !p.IsDeleted && p.factory_id.ToString() == domain).Result;
|
|
|
- var rtn = await OrderKittingCheck(morders, false, null, true, workOrds);
|
|
|
|
|
|
|
+ //var rtn = await OrderKittingCheck(morders, false, null, true, workOrds);
|
|
|
|
|
+ //刷新在库齐套个数
|
|
|
|
|
+ var rtn = await OrderDetailKittingCheck(domain,"");
|
|
|
if (workOrds.Any())
|
|
if (workOrds.Any())
|
|
|
{
|
|
{
|
|
|
workOrds = workOrds.Where(w => w.LocationStock + w.OpQtyCompleted > 0).ToList();
|
|
workOrds = workOrds.Where(w => w.LocationStock + w.OpQtyCompleted > 0).ToList();
|