|
|
@@ -25,6 +25,11 @@ using ZstdSharp.Unsafe;
|
|
|
using System.Transactions;
|
|
|
using NUglify.JavaScript.Syntax;
|
|
|
using System.Linq.Expressions;
|
|
|
+using XCZ.Extensions;
|
|
|
+using System.ComponentModel;
|
|
|
+using System.Reflection.Emit;
|
|
|
+using NUglify.Helpers;
|
|
|
+using Microsoft.AspNetCore.SignalR.Protocol;
|
|
|
|
|
|
namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
@@ -85,6 +90,22 @@ namespace Business.ResourceExamineManagement
|
|
|
/// 物料库存表
|
|
|
/// </summary>
|
|
|
private readonly IMongoDB<ic_item_stock> _ic_item_stock;
|
|
|
+ /// <summary>
|
|
|
+ /// 物料质检表
|
|
|
+ /// </summary>
|
|
|
+ private readonly IMongoDB<ic_check> _ic_check;
|
|
|
+ /// <summary>
|
|
|
+ /// 替代群组
|
|
|
+ /// </summary>
|
|
|
+ private readonly IMongoDB<ic_substitute> _ic_substitute;
|
|
|
+ /// <summary>
|
|
|
+ /// 替代群组
|
|
|
+ /// </summary>
|
|
|
+ private readonly IMongoDB<ic_substitute_all> _ic_substitute_all;
|
|
|
+ /// <summary>
|
|
|
+ /// 替代群组
|
|
|
+ /// </summary>
|
|
|
+ private readonly IMongoDB<ic_substitute_all_dtl> _ic_substitute_all_dtl;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 生产工单主表
|
|
|
@@ -103,6 +124,10 @@ namespace Business.ResourceExamineManagement
|
|
|
IMongoDB<ic_bom> ic_bom,
|
|
|
IMongoDB<ic_bom_child> ic_bom_child,
|
|
|
IMongoDB<ic_item_stock> ic_item_stock,
|
|
|
+ IMongoDB<ic_check> ic_check,
|
|
|
+ IMongoDB<ic_substitute> ic_substitute,
|
|
|
+ IMongoDB<ic_substitute_all> ic_substitute_all,
|
|
|
+ IMongoDB<ic_substitute_all_dtl> ic_substitute_all_dtl,
|
|
|
IMongoDB<mes_morder> mes_morder,
|
|
|
IBasicRepository<ic_item, long> mysql_ic_item,
|
|
|
IBasicRepository<ic_bom, long> mysql_ic_bom,
|
|
|
@@ -115,6 +140,10 @@ namespace Business.ResourceExamineManagement
|
|
|
_ic_bom = ic_bom;
|
|
|
_ic_bom_child = ic_bom_child;
|
|
|
_ic_item_stock = ic_item_stock;
|
|
|
+ _ic_check = ic_check;
|
|
|
+ _ic_substitute = ic_substitute;
|
|
|
+ _ic_substitute_all = ic_substitute_all;
|
|
|
+ _ic_substitute_all_dtl = ic_substitute_all_dtl;
|
|
|
_mes_morder = mes_morder;
|
|
|
_mysql_ic_item = mysql_ic_item;
|
|
|
_mysql_ic_bom = mysql_ic_bom;
|
|
|
@@ -210,7 +239,12 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
// List =>数量满足Quantity && 生成工单结束日期最早
|
|
|
}
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// BOM预处理
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="orderid"></param>
|
|
|
+ /// <param name="BomId"></param>
|
|
|
+ /// <param name="Quantity"></param>
|
|
|
public void BomPretreatment(long? orderid, long? BomId, int Quantity)
|
|
|
{
|
|
|
if (orderid == null)
|
|
|
@@ -243,7 +277,14 @@ namespace Business.ResourceExamineManagement
|
|
|
GetBomList(bomlist, bomchildlist, icitemlist, dto, returnlist);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// BOM预处理层级组装
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="bomlist"></param>
|
|
|
+ /// <param name="bomchildlist"></param>
|
|
|
+ /// <param name="icitemlist"></param>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <param name="returnlist"></param>
|
|
|
public void GetBomList(List<ic_bom> bomlist, List<ic_bom_child> bomchildlist, List<ic_item> icitemlist, BomChildExamineDto dto, List<BomChildExamineDto> returnlist)
|
|
|
{
|
|
|
int level = dto.level++;//初始化定义level层级
|
|
|
@@ -331,18 +372,119 @@ namespace Business.ResourceExamineManagement
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// BOM替代关系预处理
|
|
|
+ /// </summary>
|
|
|
+ public void BomSubstitute(List<BomChildExamineDto> returnlist, List<ic_item> icitemlist)
|
|
|
+ {
|
|
|
+ var sublist = _ic_substitute.GetManyByCondition(s => s.substitute_code.IsIn(returnlist.Select(c => c.substitute_code))).Result.ToList();
|
|
|
+ var suballlist =_ic_substitute_all.GetManyByCondition(s => s.substitute_id.IsIn(sublist.Select(c => c.Id))).Result.ToList();
|
|
|
+ var subdtllist = _ic_substitute_all_dtl.GetManyByCondition(s => s.substitute_allid.IsIn(suballlist.Select(c => c.Id))).Result.ToList();
|
|
|
+
|
|
|
+ List<long> dicIds = new List<long>();
|
|
|
+ var help = new SnowFlake();
|
|
|
+ //除顶级外,其他层级关系全带出来。生成平铺
|
|
|
+ foreach (var item in returnlist)
|
|
|
+ {
|
|
|
+ //最顶级、虚拟件
|
|
|
+ if (item.level != 1 && item.erp_cls!=4)
|
|
|
+ {
|
|
|
+ //有替代关系
|
|
|
+ if (item.haveicsubs == 1)
|
|
|
+ {
|
|
|
+ /*//群组替代
|
|
|
+ if (item.is_replace == 1)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(item.icitem_ids))
|
|
|
+ {
|
|
|
+ var ids = item.icitem_ids.Split(',');
|
|
|
+ foreach (var i in ids)
|
|
|
+ {
|
|
|
+ long id = 0;
|
|
|
+ if (long.TryParse(i, out id))
|
|
|
+ {
|
|
|
+ dicIds.Add(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+ var sl = sublist.Find(s => s.substitute_code == item.substitute_code);
|
|
|
+ if (sl != null)
|
|
|
+ {
|
|
|
+ var sall = suballlist.Where(s => s.substitute_id == sl.Id).ToList();
|
|
|
+ foreach (var sal in sall)
|
|
|
+ {
|
|
|
+ var sadl = subdtllist.Where(s => s.substitute_allid== sal.Id).ToList();
|
|
|
+ foreach (var dtl in sadl)
|
|
|
+ {
|
|
|
+ SubstitutePretreatment(sal, dtl, item, returnlist, icitemlist);
|
|
|
+ //var sitem = icitemlist.Find(s => s.Id == dtl.icitem_id);
|
|
|
+ //if (sitem != null)
|
|
|
+ //{
|
|
|
+ // var childDto = new BomChildExamineDto();
|
|
|
+ // childDto.level = item.level;
|
|
|
+ // childDto.bom_id = item.bom_id;
|
|
|
+ // childDto.id = help.NextId();
|
|
|
+ // childDto.parent_id = item.parent_id;
|
|
|
+ // childDto.item_id = sitem.Id;
|
|
|
+ // childDto.item_name = sitem.name;
|
|
|
+ // childDto.item_code = sitem.number;
|
|
|
+ // childDto.num = item.num;
|
|
|
+ // childDto.model = sitem.model;
|
|
|
+ // childDto.unit = sitem.unit;
|
|
|
+ // childDto.erp_cls = sitem.erp_cls;
|
|
|
+ // childDto.erp_cls_name = sitem.erp_cls_name;
|
|
|
+ // childDto.backflush = item.backflush;
|
|
|
+ // childDto.replace_amount = dtl.use_amount.Value;
|
|
|
+ // childDto.replace_amount = dtl.replace_amount.Value;
|
|
|
+
|
|
|
+ // childDto.isbom = 0;
|
|
|
+ // childDto.is_replace = c.is_replace;
|
|
|
+ // childDto.haveicsubs = c.haveicsubs;
|
|
|
+ // childDto.substitute_code = c.substitute_code;
|
|
|
+ // childDto.icitem_ids = c.icitem_ids;
|
|
|
+ // returnlist.Add(childDto);
|
|
|
+ //}
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SubstitutePretreatment(ic_substitute_all sal, ic_substitute_all_dtl dtl,BomChildExamineDto toDto,List<BomChildExamineDto> returnlist, List<ic_item> icitemlist)
|
|
|
+ {
|
|
|
+ //生成sal层级dto,是toDto的替代关系,类似R6-K50的BOM的层级1.1.1
|
|
|
+ //循环生成dtl层级dto,明细
|
|
|
+ //如果dtl对应的icitem是BOM,还需要向下继续展开。
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 计算库存量
|
|
|
/// </summary>
|
|
|
/// <param name="returnlist"></param>
|
|
|
- public void BomStock(List<BomChildExamineDto> returnlist)
|
|
|
+ public void BomStock(List<BomChildExamineDto> returnlist,long factoryid)
|
|
|
{
|
|
|
returnlist = returnlist.OrderBy(s => s.num).ToList();
|
|
|
-
|
|
|
+ //取物料库存记录
|
|
|
+ var stocklist = _ic_item_stock.GetManyByCondition(s => s.icitem_id.IsIn(returnlist.Select(c => c.item_id)) && s.factory_id == factoryid).Result;
|
|
|
+ //取当前物料质检记录
|
|
|
+ //var checklist = _ic_check.GetManyByCondition(s => s.icitem_id.IsIn(returnlist.Select(c => c.item_id)) && s.istest.GetValueOrDefault() != 1).Result.ToList();
|
|
|
List<long> idlist = new List<long>();
|
|
|
foreach (var item in returnlist)
|
|
|
{
|
|
|
-
|
|
|
+ if (item.erp_cls != 4)//虚拟件不计算
|
|
|
+ {
|
|
|
+ var sl = stocklist.Where(s => s.icitem_id == item.item_id).ToList();
|
|
|
+ //库存=物料库存+VMI库存+质检未入库。
|
|
|
+ item.sqty = sl.Sum(s => s.sqty).GetValueOrDefault();
|
|
|
+ //质检记录没加入,暂时不考虑。
|
|
|
+ //VMI仓储信息
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|