|
|
@@ -1023,79 +1023,19 @@ namespace Business.ResourceExamineManagement
|
|
|
SRMPRDto sRMPR = new SRMPRDto();
|
|
|
mo_srm_pr_main srm_Pr = new mo_srm_pr_main();
|
|
|
var leadTime = iCItemLeadTimes.Find(x => x.item_id == returnlist.item_id);
|
|
|
- var supplier = supplierList.Find(x => x.icitem_id == returnlist.item_id);//默认取第一个供应商
|
|
|
- var plan = planList.Find(x => x.icitem_id == returnlist.item_id);
|
|
|
- if (leadTime == null || supplier == null || plan == null)
|
|
|
- {
|
|
|
- sRMPR.srm_Pr_Main = null;
|
|
|
- sRMPR.lastStartTmie = deliveryDate.AddDays(7 * -1);//减去提前期
|
|
|
- return sRMPR;
|
|
|
- //throw new NotImplementedException("未找到物料ic_factory_details或ic_item_pur或ic_plan信息!");
|
|
|
- }
|
|
|
- srm_Pr.id = help.NextId();
|
|
|
- srm_Pr.GenerateNewId();
|
|
|
- srm_Pr.pr_billno = getOrderNum("PR");//pr单号
|
|
|
- srm_Pr.pr_mono = "";//关联工单号
|
|
|
- srm_Pr.entity_id = 1;//工单行号
|
|
|
- srm_Pr.pr_purchaseid = supplier.supplier_id;//供应商id
|
|
|
- srm_Pr.pr_purchasenumber = supplier.supplier_number;//供应商编码
|
|
|
- srm_Pr.pr_purchasename = supplier.supplier_name;//供应商名称
|
|
|
- srm_Pr.pr_purchaser = supplier.purcher;//采购员
|
|
|
- srm_Pr.pr_purchaser_num = "";//采购员工号(采购信息表)
|
|
|
- srm_Pr.pr_rqty = returnlist.lack_qty;//需求数量
|
|
|
- srm_Pr.pr_aqty = returnlist.lack_qty;//申请数量
|
|
|
- srm_Pr.pr_sqty = returnlist.lack_qty;//建议数量
|
|
|
- srm_Pr.icitem_id = returnlist.item_id;//物料id
|
|
|
- srm_Pr.icitem_name = returnlist.item_name;//物料名称
|
|
|
- srm_Pr.pr_order_type = 1;//单据类型
|
|
|
- srm_Pr.pr_ssend_date = deliveryDate.AddDays((double)leadTime.order_leadtime * -1);//系统建议下单日期
|
|
|
- srm_Pr.pr_sarrive_date = deliveryDate.AddDays((double)leadTime.transportation_leadtime * -1);//系统建议到达日期(建议到货日期)
|
|
|
- srm_Pr.pr_psend_date = deliveryDate.AddDays((double)leadTime.order_leadtime * -1);//计划下单日期
|
|
|
- srm_Pr.pr_parrive_date = deliveryDate.AddDays((double)leadTime.transportation_leadtime * -1);//计划到达日期
|
|
|
- srm_Pr.pr_psend_date = deliveryDate.AddDays((double)leadTime.order_leadtime * -1);//计划下单日期
|
|
|
- srm_Pr.pr_sysprice = returnlist.lack_qty * supplier.netpurchase_price * (1 + supplier.taxrate);//系统价格(含税)
|
|
|
- srm_Pr.pr_orderprice = returnlist.lack_qty * supplier.netpurchase_price * (1 + supplier.taxrate);//订单价格(含税)
|
|
|
- srm_Pr.pr_price = supplier.netpurchase_price;//采购净价(不含税)
|
|
|
- srm_Pr.pr_rate = supplier.taxrate;//税率
|
|
|
- srm_Pr.pr_unit = returnlist.unit;//单位
|
|
|
- srm_Pr.state = 1;//状态
|
|
|
- srm_Pr.old_apply_aqty = 0;//已申请数量
|
|
|
- srm_Pr.pr_type = orderType;//申请类型
|
|
|
- srm_Pr.currencytype = supplier.currency_type;//币种
|
|
|
- srm_Pr.secInv_ratio = plan.secinv_ratio;//安全库存触发采购比例
|
|
|
- srm_Pr.tenant_id = tenantId;
|
|
|
- srm_Pr.factory_id = factoryid;
|
|
|
- srm_Pr.bang_id = bangId;
|
|
|
- //_srm_pr_main.InsertOne(srm_Pr);
|
|
|
- decimal? totalLeadTime = leadTime.transportation_leadtime + leadTime.stock_leadtime + leadTime.production_leadtime + leadTime.order_leadtime;
|
|
|
-
|
|
|
- sRMPR.srm_Pr_Main = srm_Pr;
|
|
|
- sRMPR.item_no = returnlist.num;
|
|
|
- sRMPR.orderentry_id = returnlist.sentry_id;
|
|
|
- sRMPR.lastStartTmie = deliveryDate.AddDays((double)totalLeadTime * -1);//减去提前期
|
|
|
- return sRMPR;
|
|
|
- }
|
|
|
-
|
|
|
- private SRMPRShowDto CreateSRMPRShow(BomChildExamineDto returnlist, long tenantId, long factoryid, long bangId, int orderType, List<ICItemLeadTimeDto> iCItemLeadTimes, List<mo_ic_item_pur> supplierList, List<mo_ic_plan> planList, DateTime deliveryDate)
|
|
|
- {
|
|
|
- SRMPRShowDto sRMPRShowDto = new SRMPRShowDto();
|
|
|
- SRMPRDto sRMPR = new SRMPRDto();
|
|
|
-
|
|
|
- mo_srm_pr_main srm_Pr = new mo_srm_pr_main();
|
|
|
- var leadTime = iCItemLeadTimes.Find(x => x.item_id == returnlist.item_id);
|
|
|
var supplier = supplierList.Where(x => x.icitem_id == returnlist.item_id);//默认取第一个供应商
|
|
|
var plan = planList.Find(x => x.icitem_id == returnlist.item_id);
|
|
|
if (leadTime == null || supplier == null || plan == null)
|
|
|
{
|
|
|
sRMPR.srm_Pr_Main = null;
|
|
|
sRMPR.lastStartTmie = deliveryDate.AddDays(7 * -1);//减去提前期
|
|
|
- sRMPRShowDto.srm_Pr_Main = sRMPR;
|
|
|
- sRMPRShowDto.srm_Pr_MainList.Add(sRMPR);
|
|
|
- return sRMPRShowDto;
|
|
|
+ return sRMPR;
|
|
|
//throw new NotImplementedException("未找到物料ic_factory_details或ic_item_pur或ic_plan信息!");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ decimal bestLead = decimal.MaxValue;
|
|
|
+ decimal bestPrice=decimal.MaxValue;
|
|
|
+ long bestid = 0;
|
|
|
supplier.ForEach(x =>
|
|
|
{
|
|
|
//提前期随机数,金额随机数
|
|
|
@@ -1143,17 +1083,15 @@ namespace Business.ResourceExamineManagement
|
|
|
srm_Pr.bang_id = bangId;
|
|
|
//_srm_pr_main.InsertOne(srm_Pr);
|
|
|
decimal? totalLeadTime = leadTime.transportation_leadtime + leadTime.stock_leadtime + leadTime.production_leadtime + leadTime.order_leadtime;
|
|
|
-
|
|
|
- sRMPR.srm_Pr_Main = srm_Pr;
|
|
|
- sRMPR.item_no = returnlist.num;
|
|
|
- sRMPR.orderentry_id = returnlist.sentry_id;
|
|
|
- sRMPR.lastStartTmie = deliveryDate.AddDays((double)totalLeadTime * -1);//减去提前期
|
|
|
- sRMPRShowDto.srm_Pr_MainList.Add(sRMPR);
|
|
|
+ srm_Pr.totalLeadTime= totalLeadTime;
|
|
|
+ sRMPR.srm_Pr_Main.Add(srm_Pr);
|
|
|
});
|
|
|
- sRMPRShowDto.srm_Pr_Main= sRMPRShowDto.srm_Pr_MainList.OrderByDescending(x=>x.lastStartTmie).ThenBy(x=>x.pr_orderprice).First();
|
|
|
- return sRMPRShowDto;
|
|
|
+ sRMPR.srm_Pr_Main.OrderBy(x=>x.totalLeadTime).ThenBy(x=>x.pr_orderprice).First().isbestoptions= true;
|
|
|
+ sRMPR.item_no = returnlist.num;
|
|
|
+ sRMPR.orderentry_id = returnlist.sentry_id;
|
|
|
+ sRMPR.lastStartTmie = deliveryDate.AddDays((double)sRMPR.srm_Pr_Main.MinBy(x=>x.totalLeadTime).totalLeadTime * -1);//减去提前期
|
|
|
+ return sRMPR;
|
|
|
}
|
|
|
-
|
|
|
// 生成订单编号 字母+年月日+8位随机数+时间戳
|
|
|
private string getOrderNum(string preCode)
|
|
|
{
|
|
|
@@ -1258,22 +1196,26 @@ namespace Business.ResourceExamineManagement
|
|
|
item.purchase_list = new List<purchase>();
|
|
|
if (SRMPRDto.srm_Pr_Main != null)
|
|
|
{
|
|
|
- purchase pur = new purchase();
|
|
|
- pur.Id = SRMPRDto.srm_Pr_Main.id;
|
|
|
- pur.pr_billno = SRMPRDto.srm_Pr_Main.pr_billno;
|
|
|
- pur.pr_purchasenumber = SRMPRDto.srm_Pr_Main.pr_purchasenumber;
|
|
|
- pur.pr_purchasename = SRMPRDto.srm_Pr_Main.pr_purchasename;
|
|
|
- pur.pr_rqty = SRMPRDto.srm_Pr_Main.pr_rqty;
|
|
|
- pur.pr_aqty = SRMPRDto.srm_Pr_Main.pr_aqty;
|
|
|
- pur.pr_sqty = SRMPRDto.srm_Pr_Main.pr_sqty;
|
|
|
- pur.pr_parrive_date = SRMPRDto.srm_Pr_Main.pr_parrive_date;
|
|
|
- pur.pr_rarrive_date = SRMPRDto.srm_Pr_Main.pr_rarrive_date;
|
|
|
- pur.pr_pur_affirm_date = SRMPRDto.srm_Pr_Main.pr_pur_affirm_date;
|
|
|
- pur.pr_sysprice = SRMPRDto.srm_Pr_Main.pr_sysprice;
|
|
|
- pur.pr_orderprice = SRMPRDto.srm_Pr_Main.pr_orderprice;
|
|
|
- pur.pr_price = SRMPRDto.srm_Pr_Main.pr_price;
|
|
|
- pur.pr_rate = SRMPRDto.srm_Pr_Main.pr_rate;
|
|
|
- item.purchase_list.Add(pur);
|
|
|
+ for(int i=0;i< SRMPRDto.srm_Pr_Main.Count;i++)
|
|
|
+ {
|
|
|
+ purchase pur = new purchase();
|
|
|
+ pur.Id = SRMPRDto.srm_Pr_Main[i].id;
|
|
|
+ pur.pr_billno = SRMPRDto.srm_Pr_Main[i].pr_billno;
|
|
|
+ pur.pr_purchasenumber = SRMPRDto.srm_Pr_Main[i].pr_purchasenumber;
|
|
|
+ pur.pr_purchasename = SRMPRDto.srm_Pr_Main[i].pr_purchasename;
|
|
|
+ pur.pr_rqty = SRMPRDto.srm_Pr_Main[i].pr_rqty;
|
|
|
+ pur.pr_aqty = SRMPRDto.srm_Pr_Main[i].pr_aqty;
|
|
|
+ pur.pr_sqty = SRMPRDto.srm_Pr_Main[i].pr_sqty;
|
|
|
+ pur.pr_parrive_date = SRMPRDto.srm_Pr_Main[i].pr_parrive_date;
|
|
|
+ pur.pr_rarrive_date = SRMPRDto.srm_Pr_Main[i].pr_rarrive_date;
|
|
|
+ pur.pr_pur_affirm_date = SRMPRDto.srm_Pr_Main[i].pr_pur_affirm_date;
|
|
|
+ pur.pr_sysprice = SRMPRDto.srm_Pr_Main[i].pr_sysprice;
|
|
|
+ pur.pr_orderprice = SRMPRDto.srm_Pr_Main[i].pr_orderprice;
|
|
|
+ pur.pr_price = SRMPRDto.srm_Pr_Main[i].pr_price;
|
|
|
+ pur.pr_rate = SRMPRDto.srm_Pr_Main[i].pr_rate;
|
|
|
+ pur.isbestoptions = SRMPRDto.srm_Pr_Main[i].isbestoptions;
|
|
|
+ item.purchase_list.Add(pur);
|
|
|
+ }
|
|
|
}
|
|
|
item.kitting_time = SRMPRDto.lastStartTmie;
|
|
|
SRMPRDtoList.Add(SRMPRDto);
|