|
|
@@ -131,6 +131,10 @@ namespace Business.ResourceExamineManagement
|
|
|
/// 生产工单主表
|
|
|
/// </summary>
|
|
|
private readonly IMongoDB<mes_morder> _mes_morder;
|
|
|
+ /// <summary>
|
|
|
+ /// 生产工单子表
|
|
|
+ /// </summary>
|
|
|
+ private readonly IMongoDB<mes_moentry> _mes_moentry;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 在制工单占用记录表
|
|
|
@@ -165,6 +169,7 @@ namespace Business.ResourceExamineManagement
|
|
|
//IMongoDB<ic_substitute_all> ic_substitute_all,
|
|
|
//IMongoDB<ic_substitute_all_dtl> ic_substitute_all_dtl,
|
|
|
IMongoDB<mes_morder> mes_morder,
|
|
|
+ IMongoDB<mes_moentry> mes_moentry,
|
|
|
IMongoDB<mes_mooccupy> mes_mooccupy,
|
|
|
IMongoDB<ic_item_stockoccupy> ic_item_stockoccupy,
|
|
|
IRepository<ic_item, long> mysql_ic_item,
|
|
|
@@ -174,6 +179,7 @@ namespace Business.ResourceExamineManagement
|
|
|
IRepository<crm_seorder, long> mysql_crm_seorder,
|
|
|
IRepository<crm_seorderentry, long> mysql_crm_seorderentry,
|
|
|
IRepository<ic_item_stock, long> mysql_ic_item_stock
|
|
|
+
|
|
|
)
|
|
|
{
|
|
|
_mes_technique = mes_technique;
|
|
|
@@ -189,6 +195,7 @@ namespace Business.ResourceExamineManagement
|
|
|
//_ic_substitute_all = ic_substitute_all;
|
|
|
//_ic_substitute_all_dtl = ic_substitute_all_dtl;
|
|
|
_mes_morder = mes_morder;
|
|
|
+ _mes_moentry = mes_moentry;
|
|
|
_mes_mooccupy = mes_mooccupy;
|
|
|
_ic_item_stockoccupy = ic_item_stockoccupy;
|
|
|
_mysql_ic_item = mysql_ic_item;
|
|
|
@@ -239,15 +246,17 @@ namespace Business.ResourceExamineManagement
|
|
|
////await _ic_item_stock.DeleteByIds(136123);
|
|
|
|
|
|
////根据id删除表数据
|
|
|
- //List<long> aa= new List<long>();
|
|
|
- //aa.Add(136126);
|
|
|
- //aa.Add(136127);
|
|
|
- //aa.Add(136128);
|
|
|
+ //List<long> aa = new List<long>();
|
|
|
+ //aa.Add(136131);
|
|
|
+ //aa.Add(136132);
|
|
|
+ //aa.Add(136133);
|
|
|
//FilterDefinition<ic_item_stock> filter = Builders<ic_item_stock>.Filter.In(s => s.icitem_id, aa);
|
|
|
- //await _ic_item_stock.DeleteManyByIds(filter);
|
|
|
-
|
|
|
+ //await _ic_item_stock.Delete(filter);
|
|
|
+
|
|
|
//根据条件删除数据
|
|
|
- await _ic_item_stock.DeleteManyByCondition(p=>p.icitem_name == "111");
|
|
|
+ //await _ic_item_stock.Delete(p=>p.icitem_name == "test");
|
|
|
+
|
|
|
+ //await _ic_item_stock.DeleteByIds(aa);
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -259,15 +268,14 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
|
public async Task<PschedDto> ReceiveResult(SeorderentryDto input)
|
|
|
{
|
|
|
- await test();
|
|
|
//数据库快照-同步mysql库数据到mongoDB中
|
|
|
//await SyncData(input.factoryId);
|
|
|
//生成当前计算bangid
|
|
|
//SnowFlake snow = new SnowFlake();
|
|
|
//long bangid = snow.NextId();
|
|
|
|
|
|
- ////产能检查
|
|
|
- //await ProductiveExamine(1733221167209762816, 100);
|
|
|
+ //产能检查
|
|
|
+ await ProductiveExamine(1733221167209762816, 100);
|
|
|
return null;
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
@@ -291,7 +299,8 @@ namespace Business.ResourceExamineManagement
|
|
|
/// </summary>
|
|
|
/// <param name="tech_id">工艺路径主键</param>
|
|
|
/// <param name="packages">需要生产产品件数</param>
|
|
|
- public async Task<DateTime> ProductiveExamine(long tech_id, int packages)
|
|
|
+ /// <returns>生产时长</returns>
|
|
|
+ public async Task<decimal> ProductiveExamine(long tech_id, int packages)
|
|
|
{
|
|
|
if (packages <= 0)
|
|
|
{
|
|
|
@@ -348,7 +357,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
- return DateTime.Now.AddDays(1).AddMinutes((double)sumTimes);
|
|
|
+ return sumTimes;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -393,10 +402,10 @@ namespace Business.ResourceExamineManagement
|
|
|
//1.库存、在制工单检查完成后 当前BOM需要自制时 产生工单。
|
|
|
|
|
|
//2.每一个销售订单行对应一个工单。
|
|
|
- //获取销售订单信息
|
|
|
- //var seorder = await _crm_seorder.FindAsync(x => x.Id == OrderId);
|
|
|
//查询销售订单子表数据
|
|
|
var seorderentry = await _crm_seorderentry.FindAsync(x => x.Id == seorderentry_id);
|
|
|
+ //获取销售订单信息
|
|
|
+ var seorder = await _crm_seorder.FindAsync(x => x.Id == seorderentry.seorder_id);
|
|
|
|
|
|
mes_morder mes_Morder = new mes_morder();
|
|
|
mes_Morder.GenerateNewId();
|
|
|
@@ -404,7 +413,38 @@ namespace Business.ResourceExamineManagement
|
|
|
//mes_Morder.morder_icitem_type
|
|
|
mes_Morder.work_order_type = "常规工单";
|
|
|
mes_Morder.morder_state = "初始";
|
|
|
-
|
|
|
+ mes_Morder.morder_no = "";//TODO:编码规则暂时没有
|
|
|
+ mes_Morder.fms_number = seorderentry.fms_number;
|
|
|
+ mes_Morder.bom_number = seorderentry.bom_number;
|
|
|
+ mes_Morder.fmodel = seorderentry.specification;
|
|
|
+ mes_Morder.moentry_startup_status = 1;
|
|
|
+ mes_Morder.tenant_id = 0;
|
|
|
+ mes_Morder.product_code = seorderentry.item_number;
|
|
|
+ mes_Morder.product_name = seorderentry.item_name;
|
|
|
+ mes_Morder.project_name = seorder.project_name;
|
|
|
+ mes_Morder.planner_num = seorderentry.planner_no;
|
|
|
+ mes_Morder.planner_name = seorderentry.planner_name;
|
|
|
+ mes_Morder.morder_date = DateTime.Now.Date;
|
|
|
+ //TODO:可删除主表字段
|
|
|
+ mes_Morder.unit = seorderentry.unit;
|
|
|
+ mes_Morder.morder_production_number = seorderentry.qty;
|
|
|
+ mes_Morder.need_number = seorderentry.qty;
|
|
|
+ mes_Morder.remaining_number = 0;
|
|
|
+ await _mes_morder.InsertOne(mes_Morder);
|
|
|
+
|
|
|
+ mes_moentry mes_Moentry = new mes_moentry();
|
|
|
+ mes_Moentry.GenerateNewId();
|
|
|
+ mes_Moentry.moentry_moid = mes_Morder.Id;
|
|
|
+ mes_Moentry.moentry_mono = mes_Morder.morder_no;
|
|
|
+ mes_Moentry.soentry_id = seorderentry.Id;
|
|
|
+ mes_Moentry.fbill_no = seorderentry.bill_no;
|
|
|
+ mes_Moentry.fentry_id = seorderentry.entry_seq.Value;
|
|
|
+ mes_Moentry.unit = seorderentry.unit;
|
|
|
+ mes_Moentry.morder_production_number = seorderentry.qty;
|
|
|
+ mes_Moentry.need_number = seorderentry.qty;
|
|
|
+ mes_Moentry.remaining_number = 0;
|
|
|
+
|
|
|
+ await _mes_moentry.InsertOne(mes_Moentry);
|
|
|
|
|
|
}
|
|
|
/// <summary>
|
|
|
@@ -801,11 +841,9 @@ namespace Business.ResourceExamineManagement
|
|
|
public void BomStock(List<BomChildExamineDto> returnlist, long bangid, long orderid, long orderentryid, long factoryid)
|
|
|
{
|
|
|
returnlist = returnlist.OrderBy(s => s.num).ToList();
|
|
|
- //取物料库存记录
|
|
|
- FilterDefinition<ic_item_stock> filter = Builders<ic_item_stock>.Filter.In(s => s.icitem_id, returnlist.Select(c => c.item_id).ToList());
|
|
|
- var stockListAll = _ic_item_stock.GetManyByIds(filter).Result;
|
|
|
//获取当前工厂下物料库存数据
|
|
|
- var stocklist = stockListAll.Where(p=>p.factory_id == factoryid).ToList();
|
|
|
+ List<long> icitemIds = returnlist.Select(c => c.item_id).ToList();
|
|
|
+ var stocklist = _ic_item_stock.GetManyByCondition(p=>p.factory_id == factoryid && icitemIds.Contains(p.icitem_id)).Result;
|
|
|
//取当前订单的物料库存占用记录
|
|
|
var occupylist = _ic_item_stockoccupy.GetManyByCondition(p => p.bang_id == bangid && p.order_id == orderid).Result;
|
|
|
//计算剩余库存
|
|
|
@@ -828,7 +866,7 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <summary>
|
|
|
/// 替代关系检查计算
|
|
|
/// </summary>
|
|
|
- public void CalcIcitemSubstitute(List<BomChildExamineDto> returnlist,int count)
|
|
|
+ public void CalcIcitemSubstitute(List<BomChildExamineDto> returnlist, int count)
|
|
|
{
|
|
|
returnlist = returnlist.OrderBy(s => s.num).ToList();
|
|
|
//1.如果主料够的时候,不需要显示替代料的平铺视图,如果主料不够,显示替代料的平铺视图。
|
|
|
@@ -842,7 +880,7 @@ namespace Business.ResourceExamineManagement
|
|
|
foreach (var item in returnlist)
|
|
|
{
|
|
|
//循环平铺整个资源检查的物料库存情况、缺料情况
|
|
|
- CaclMaterialShortage(returnlist,item, count);
|
|
|
+ CaclMaterialShortage(returnlist, item, count);
|
|
|
}
|
|
|
foreach (var item in returnlist)
|
|
|
{
|
|
|
@@ -886,14 +924,15 @@ namespace Business.ResourceExamineManagement
|
|
|
var sublist = returnlist.Where(s => s.parent_id == item.parent_id && s.num == item.num && s.level == item.level).OrderBy(c => c.substitute_all_num).ToList();
|
|
|
//sublist找出当前含替代关系的标准件和替代件。
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
if (item.substitute_mode == 0)
|
|
|
{
|
|
|
//替代
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
//取代
|
|
|
|
|
|
}
|
|
|
@@ -901,7 +940,7 @@ namespace Business.ResourceExamineManagement
|
|
|
else
|
|
|
{
|
|
|
//无替代关系
|
|
|
- if (item.stock_state==0)
|
|
|
+ if (item.stock_state == 0)
|
|
|
{
|
|
|
item.use_qty = item.needCount;
|
|
|
item.is_show = true;
|