|
|
@@ -279,7 +279,7 @@ namespace Business.ResourceExamineManagement
|
|
|
_srm_po_list = srm_po_list;
|
|
|
_crm_seorder = crm_seorder;
|
|
|
_crm_seorderentry = crm_seorderentry;
|
|
|
- _srm_po_occupy= srm_po_occupy;
|
|
|
+ _srm_po_occupy = srm_po_occupy;
|
|
|
//_ic_substitute = ic_substitute;
|
|
|
//_ic_substitute_all = ic_substitute_all;
|
|
|
//_ic_substitute_all_dtl = ic_substitute_all_dtl;
|
|
|
@@ -304,7 +304,7 @@ namespace Business.ResourceExamineManagement
|
|
|
_mysql_mes_tech_process = mysql_mes_tech_process;
|
|
|
_mysql_srm_po_main = mysql_srm_po_main;
|
|
|
_mysql_srm_po_list = mysql_srm_po_list;
|
|
|
- _mysql_srm_po_occupy= mysql_srm_po_occupy;
|
|
|
+ _mysql_srm_po_occupy = mysql_srm_po_occupy;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -476,21 +476,21 @@ namespace Business.ResourceExamineManagement
|
|
|
await _ic_item_stock.InsertMany(icitemStokc);
|
|
|
}
|
|
|
//在制工单占用记录表
|
|
|
- var mes_mooccupy = _mysql_mes_mooccupy.GetListAsync(x => x.factory_id == factoryId).Result;
|
|
|
+ var mes_mooccupy = _mysql_mes_mooccupy.GetListAsync(x => x.tenant_id == tenantId && x.factory_id == factoryId).Result;
|
|
|
if (mes_mooccupy.Count > 0)
|
|
|
{
|
|
|
mes_mooccupy.ForEach(item => { item.bang_id = bangid; });
|
|
|
await _mes_mooccupy.InsertMany(mes_mooccupy);
|
|
|
}
|
|
|
//工单主表
|
|
|
- var mes_morder = _mysql_mes_morder.GetListAsync(x => x.factory_id == factoryId).Result;
|
|
|
+ var mes_morder = _mysql_mes_morder.GetListAsync(x => x.tenant_id == tenantId && x.factory_id == factoryId).Result;
|
|
|
if (mes_morder.Count > 0)
|
|
|
{
|
|
|
mes_morder.ForEach(item => { item.bang_id = bangid; });
|
|
|
await _mes_morder.InsertMany(mes_morder);
|
|
|
}
|
|
|
//工单子表
|
|
|
- var mes_moentry = _mysql_mes_moentry.GetListAsync(x => x.factory_id == factoryId).Result;
|
|
|
+ var mes_moentry = _mysql_mes_moentry.GetListAsync(x => x.tenant_id == tenantId && x.factory_id == factoryId).Result;
|
|
|
if (mes_moentry.Count > 0)
|
|
|
{
|
|
|
mes_moentry.ForEach(item => { item.bang_id = bangid; });
|
|
|
@@ -499,7 +499,7 @@ namespace Business.ResourceExamineManagement
|
|
|
|
|
|
//TODO:要不要根据某些条件只同步有效的数据
|
|
|
//销售订单
|
|
|
- var crm_seorder = _mysql_crm_seorder.GetListAsync(x => x.factory_id == factoryId).Result;
|
|
|
+ var crm_seorder = _mysql_crm_seorder.GetListAsync(x => x.tenant_id == tenantId && x.factory_id == factoryId).Result;
|
|
|
if (crm_seorder.Count > 0)
|
|
|
{
|
|
|
crm_seorder.ForEach(item => { item.bang_id = bangid; });
|
|
|
@@ -507,7 +507,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
|
|
|
//销售订单明细
|
|
|
- var crm_seorderentry = _mysql_crm_seorderentry.GetListAsync(x => x.factory_id == factoryId).Result;
|
|
|
+ var crm_seorderentry = _mysql_crm_seorderentry.GetListAsync(x => x.tenant_id == tenantId && x.factory_id == factoryId).Result;
|
|
|
if (crm_seorderentry.Count > 0)
|
|
|
{
|
|
|
crm_seorderentry.ForEach(item => { item.bang_id = bangid; });
|
|
|
@@ -515,7 +515,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
|
|
|
//采购订单
|
|
|
- var srm_po_main = _mysql_srm_po_main.GetListAsync(x => x.factory_id == factoryId).Result;
|
|
|
+ var srm_po_main = _mysql_srm_po_main.GetListAsync(x => x.tenant_id == tenantId && x.factory_id == factoryId).Result;
|
|
|
if (crm_seorderentry.Count > 0)
|
|
|
{
|
|
|
srm_po_main.ForEach(item => { item.bang_id = bangid; });
|
|
|
@@ -523,7 +523,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
|
|
|
//采购订单明细
|
|
|
- var srm_po_list = _mysql_srm_po_list.GetListAsync(x => x.factory_id == factoryId).Result;
|
|
|
+ var srm_po_list = _mysql_srm_po_list.GetListAsync(x => x.tenant_id == tenantId && x.factory_id == factoryId).Result;
|
|
|
if (srm_po_list.Count > 0)
|
|
|
{
|
|
|
srm_po_list.ForEach(item => { item.bang_id = bangid; });
|
|
|
@@ -531,7 +531,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
|
|
|
//采购订单占用详情
|
|
|
- var srm_po_occupy = _mysql_srm_po_occupy.GetListAsync(x => x.factory_id == factoryId).Result;
|
|
|
+ var srm_po_occupy = _mysql_srm_po_occupy.GetListAsync(x => x.tenant_id == tenantId && x.factory_id == factoryId).Result;
|
|
|
if (srm_po_occupy.Count > 0)
|
|
|
{
|
|
|
srm_po_occupy.ForEach(item => { item.bang_id = bangid; });
|
|
|
@@ -553,7 +553,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
#region 1、数据准备
|
|
|
//1.1、获取工艺路径数据
|
|
|
- mes_technique tech = _mes_technique.Find(p=>p.bom == bom_number).Result.FirstOrDefault();
|
|
|
+ mes_technique tech = _mes_technique.Find(p => p.bom == bom_number).Result.FirstOrDefault();
|
|
|
if (tech == null)
|
|
|
{
|
|
|
throw new NotImplementedException("请先配置工艺路径!");
|
|
|
@@ -1534,19 +1534,19 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <param name="factoryid">工厂id</param>
|
|
|
/// <param name="deliveryDate">销售订单交付日期</param>
|
|
|
/// <returns></returns>
|
|
|
- private async Task<List<ICItemDateDto>> CheckOnOrder(List<BomChildExamineDto> returnlist, long factoryid,DateTime deliveryDate)
|
|
|
+ private async Task<List<ICItemDateDto>> CheckOnOrder(List<BomChildExamineDto> returnlist, long factoryid, DateTime deliveryDate)
|
|
|
{
|
|
|
//ToDo:企业Id,数据状态过滤以及isdeleted
|
|
|
- var po_list=_srm_po_list.Find(p => returnlist.Select(x => x.item_id).Contains(p.icitem_id) && p.factory_id == factoryid && p.rarrdate>=DateTime.Now && p.rarrdate<deliveryDate).Result;
|
|
|
+ var po_list = _srm_po_list.Find(p => returnlist.Select(x => x.item_id).Contains(p.icitem_id) && p.factory_id == factoryid && p.rarrdate >= DateTime.Now && p.rarrdate < deliveryDate).Result;
|
|
|
var itemlist = new List<ICItemDateDto>();//需要生成采购申请单的物料信息
|
|
|
var leadTimeList = GetLeadTime(returnlist, factoryid);
|
|
|
foreach (var item in returnlist)
|
|
|
{
|
|
|
//缺料
|
|
|
- if(item.lack_qty>0)
|
|
|
+ if (item.lack_qty > 0)
|
|
|
{
|
|
|
- var itemPO =po_list.FindAll(x => x.icitem_id == item.item_id).OrderBy(v=>v.rarrdate).ToList();
|
|
|
- if(itemPO.Count<=0 || itemPO.Sum(p => (p.qty - p.esqty))<item.lack_qty)
|
|
|
+ var itemPO = po_list.FindAll(x => x.icitem_id == item.item_id).OrderBy(v => v.rarrdate).ToList();
|
|
|
+ if (itemPO.Count <= 0 || itemPO.Sum(p => (p.qty - p.esqty)) < item.lack_qty)
|
|
|
{
|
|
|
//外购生成采购申请单
|
|
|
if (item.erp_cls == 3)
|
|
|
@@ -1559,7 +1559,8 @@ namespace Business.ResourceExamineManagement
|
|
|
CreateSRMPR(item, factoryid, 1, leadTimeList);
|
|
|
CreateMesOOder(item, factoryid, leadTimeList);
|
|
|
}
|
|
|
- }else
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
decimal? itemPOQty = 0;//当前物料已抵扣数量
|
|
|
for (int i = 0; i < itemPO.Count; i++)
|
|
|
@@ -1567,7 +1568,7 @@ namespace Business.ResourceExamineManagement
|
|
|
if (itemPOQty + itemPO[i].qty - itemPO[i].esqty >= item.lack_qty)
|
|
|
{
|
|
|
//在途满足,写占用表
|
|
|
- itemlist.Add(new ICItemDateDto { item_id = itemPO[i].icitem_id, dateTime = itemPO[i].rarrdate});
|
|
|
+ itemlist.Add(new ICItemDateDto { item_id = itemPO[i].icitem_id, dateTime = itemPO[i].rarrdate });
|
|
|
srm_po_occupy po_Occupy = new srm_po_occupy();
|
|
|
po_Occupy.GenerateNewId();
|
|
|
po_Occupy.polist_id = itemPO[i].po_id;//采购订单id
|
|
|
@@ -1576,7 +1577,7 @@ namespace Business.ResourceExamineManagement
|
|
|
po_Occupy.bill_no = 111;//客户订单id
|
|
|
po_Occupy.type = "在途占用";//类型
|
|
|
po_Occupy.entry_id = 1;//行号
|
|
|
- po_Occupy.qty = item.lack_qty- itemPOQty;//占用量
|
|
|
+ po_Occupy.qty = item.lack_qty - itemPOQty;//占用量
|
|
|
po_Occupy.stime = DateTime.Now;//开始时间
|
|
|
po_Occupy.etime = deliveryDate;//结束时间
|
|
|
po_Occupy.state = 1;//占用状态
|
|
|
@@ -1639,17 +1640,17 @@ namespace Business.ResourceExamineManagement
|
|
|
oOrder.ffms_number = "1000";//fms旧料号
|
|
|
oOrder.product_name = "test";//产品名称
|
|
|
oOrder.specification_model = returnlist.model;//规格型号
|
|
|
- oOrder.bom_number ="";//bom编码
|
|
|
+ oOrder.bom_number = "";//bom编码
|
|
|
oOrder.unit = returnlist.unit;//单位
|
|
|
oOrder.morder_progress = "";//工单进度
|
|
|
oOrder.morder_production_number = 120;//工单生产数量(计划数量)
|
|
|
- oOrder.need_number =returnlist.lack_qty;//需求数量
|
|
|
+ oOrder.need_number = returnlist.lack_qty;//需求数量
|
|
|
oOrder.remaining_number = returnlist.lack_qty;//剩余可用数量
|
|
|
oOrder.work_number = 0;//报工数量
|
|
|
oOrder.inspection_number = 0;//报检数量
|
|
|
oOrder.qualified_number = 0;//合格数量
|
|
|
oOrder.inventory_number = 0;//入库数量
|
|
|
- oOrder.notice_qty =0;//已开通知单数量
|
|
|
+ oOrder.notice_qty = 0;//已开通知单数量
|
|
|
oOrder.moentry_on = 1;//启动状态
|
|
|
//oOrder.start_time = DateTime.Now;//开始时间
|
|
|
//oOrder.pause_time = DateTime.Now;//最近暂停时间
|
|
|
@@ -1670,7 +1671,7 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <param name="returnlist"></param>
|
|
|
/// <param name="factoryid"></param>
|
|
|
/// <param name="orderType">1委外采购申请单,2采购申请单</param>
|
|
|
- private DateTime CreateSRMPR(BomChildExamineDto returnlist, long factoryid, int orderType,List<ICItemLeadTimeDto> iCItemLeadTimes)
|
|
|
+ private DateTime CreateSRMPR(BomChildExamineDto returnlist, long factoryid, int orderType, List<ICItemLeadTimeDto> iCItemLeadTimes)
|
|
|
{
|
|
|
srm_pr_main srm_Pr = new srm_pr_main();
|
|
|
srm_Pr.GenerateNewId();
|
|
|
@@ -1709,7 +1710,7 @@ namespace Business.ResourceExamineManagement
|
|
|
srm_Pr.currencytype = 22;//币种
|
|
|
srm_Pr.secInv_ratio = 22;//安全库存触发采购比例
|
|
|
_srm_pr_main.InsertOne(srm_Pr);
|
|
|
- var leadTime=iCItemLeadTimes.Select(x => x.item_id == returnlist.item_id).First();
|
|
|
+ var leadTime = iCItemLeadTimes.Select(x => x.item_id == returnlist.item_id).First();
|
|
|
return DateTime.Now;
|
|
|
}
|
|
|
|