|
|
@@ -511,7 +511,7 @@ namespace Business.ResourceExamineManagement
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 资源检查
|
|
|
+ /// 资源检查 -- TODO:根据客户的不同标准交货期(假如客户设定10天),如果检查交期小于标准交货期(10天),则默认把建议交期调整为10天。
|
|
|
/// </summary>
|
|
|
/// <param name="input"></param>
|
|
|
/// <param name="type">类型(0,销售订单 1,销售订单行)</param>
|
|
|
@@ -1032,7 +1032,7 @@ namespace Business.ResourceExamineManagement
|
|
|
DateTime endtime = toTime.AddDays(8);
|
|
|
List<srm_pr_main> prlist = _mysql_srm_pr_main.GetListAsync(s => s.pr_rarrive_date >= starttime && s.pr_rarrive_date <= endtime && (s.state == 1 || s.state == 3)).Result;
|
|
|
//List<srm_pr_main> prlist = _mysql_srm_pr_main.GetListAsync(s => s.icitem_id == 1949).Result;
|
|
|
- List<srm_purchase> purchaselist = _mysql_srm_purchase.GetListAsync(s => prlist.Select(c => c.icitem_id).Contains(s.icitem_id) && prlist.Select(c => c.pr_purchaseid).Contains(s.supplier_id)).Result;
|
|
|
+ //List<srm_purchase> purchaselist = _mysql_srm_purchase.GetListAsync(s => prlist.Select(c => c.icitem_id).Contains(s.icitem_id) && prlist.Select(c => c.pr_purchaseid).Contains(s.supplier_id)).Result;
|
|
|
List<ic_item> ic_Items = _mysql_ic_item.GetListAsync(s => prlist.Select(c => c.icitem_id).Contains(s.Id)).Result;
|
|
|
List<PrWeekDto> prWeekDtos = new List<PrWeekDto>();
|
|
|
|
|
|
@@ -1041,12 +1041,13 @@ namespace Business.ResourceExamineManagement
|
|
|
var moPrlist = ObjectMapper.Map<List<srm_pr_main>, List<mo_srm_pr_main>>(prlist);
|
|
|
foreach (var pr in prlist)
|
|
|
{
|
|
|
+ bool bl = pr.sentry_id == null ? true : false;
|
|
|
//找到是否生成了新的PR
|
|
|
- var newPr = insetPrList.Find(s => s.pr_purchaseid == pr.pr_purchaseid && s.icitem_id == pr.icitem_id && s.sentry_id == pr.sentry_id);
|
|
|
+ var newPr = insetPrList.Find(s => s.pr_purchaseid == pr.pr_purchaseid && s.icitem_id == pr.icitem_id && (s.sentry_id == null) == bl);
|
|
|
if (newPr == null)
|
|
|
{
|
|
|
//有多条才进行合并
|
|
|
- var ilist = prlist.Where(s => s.pr_purchaseid == pr.pr_purchaseid && s.icitem_id == pr.icitem_id && s.sentry_id == pr.sentry_id).ToList();
|
|
|
+ var ilist = prlist.Where(s => s.pr_purchaseid == pr.pr_purchaseid && s.icitem_id == pr.icitem_id && (s.sentry_id == null) == bl).ToList();
|
|
|
if (ilist.Count > 1)
|
|
|
{
|
|
|
var icitem = ic_Items.Find(s => s.Id == pr.icitem_id);
|
|
|
@@ -1238,7 +1239,45 @@ namespace Business.ResourceExamineManagement
|
|
|
List<srm_purchase> purchaselist = _mysql_srm_purchase.GetListAsync(s => prlist.Select(c => c.icitem_id).Contains(s.icitem_id) && prlist.Select(c => c.pr_purchaseid).Contains(s.supplier_id)).Result;
|
|
|
List<ic_item> ic_Items = _mysql_ic_item.GetListAsync(s => prlist.Select(c => c.icitem_id).Contains(s.Id)).Result;
|
|
|
PoActionListDto poaction = new PoActionListDto();
|
|
|
- AutoCreatePOFromPR(prlist, ic_Items, itemsupplierList, poaction);
|
|
|
+ AutoCreatePOFromPR(prlist, ic_Items, itemsupplierList, purchaselist, poaction);
|
|
|
+
|
|
|
+ using (var unitOfWork = _unitOfWorkManager.Begin(false, true))
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (poaction.poMain.Any())
|
|
|
+ {
|
|
|
+ _businessDbContext.BulkInsert(poaction.poMain);
|
|
|
+ }
|
|
|
+ if (poaction.polist.Any())
|
|
|
+ {
|
|
|
+ _businessDbContext.BulkInsert(poaction.polist);
|
|
|
+ }
|
|
|
+ if (poaction.poOccupiesList.Any())
|
|
|
+ {
|
|
|
+ _businessDbContext.BulkInsert(poaction.poOccupiesList);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (poaction.poMasterList.Any())
|
|
|
+ {
|
|
|
+ _purOrdMaster.Insert(poaction.poMasterList);
|
|
|
+ //快开平台用自增列RecId关联,所以需要插入后再查给明细表赋相应的值
|
|
|
+ List<string> nbrs = poaction.poMasterList.Select(a => a.PurOrd).ToList();
|
|
|
+ var nbrList = _purOrdMaster.Select(a => a.Domain == "1001" && nbrs.Contains(a.PurOrd));
|
|
|
+ poaction.poDetailList.ForEach(c =>
|
|
|
+ {
|
|
|
+ c.PurOrdRecID = nbrList.Where(a => a.PurOrd == c.PurOrd).First().RecID;
|
|
|
+ });
|
|
|
+ _purOrdDetail.Insert(poaction.poDetailList);
|
|
|
+ }
|
|
|
+ await unitOfWork.CompleteAsync();
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ unitOfWork.Dispose();
|
|
|
+ new NLogHelper("ResourceExamineAppService").WriteLog("OrderKittingCheck", "工单检查数据更新失败:" + e.Message, _currentTenant.Id.ToString());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1773,18 +1812,18 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
return isSameWeek;
|
|
|
}
|
|
|
- private void AutoCreatePOFromPR(List<srm_pr_main> list , List<ic_item> icitemlist, List<srm_supplier> itemsupplierList, PoActionListDto poaction)
|
|
|
+ private void AutoCreatePOFromPR(List<srm_pr_main> list , List<ic_item> icitemlist, List<srm_supplier> itemsupplierList, List<srm_purchase> purchaselist, PoActionListDto poaction)
|
|
|
{
|
|
|
var zcPr = list.Where(a => a.pr_billno.StartsWith("PR")).ToList();
|
|
|
if (zcPr.Any())
|
|
|
{
|
|
|
- AutoCreatePOFromPRByType(zcPr, icitemlist, itemsupplierList, poaction,1);
|
|
|
+ AutoCreatePOFromPRByType(zcPr, icitemlist, itemsupplierList, purchaselist, poaction,1);
|
|
|
}
|
|
|
|
|
|
var wwPr = list.Where(a => a.pr_billno.StartsWith("WWPR")).ToList();
|
|
|
if (wwPr.Any())
|
|
|
{
|
|
|
- AutoCreatePOFromPRByType(wwPr, icitemlist, itemsupplierList, poaction,2);
|
|
|
+ AutoCreatePOFromPRByType(wwPr, icitemlist, itemsupplierList, purchaselist, poaction,2);
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
@@ -1796,255 +1835,133 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <param name="itemsupplierList"></param>
|
|
|
/// <param name="poaction"></param>
|
|
|
/// <param name="poType">1正常PO,2是委外</param>
|
|
|
- private void AutoCreatePOFromPRByType(List<srm_pr_main> list, List<ic_item> itemList, List<srm_supplier> itemsupplierList, PoActionListDto poaction,int poType)
|
|
|
+ private void AutoCreatePOFromPRByType(List<srm_pr_main> list, List<ic_item> itemList, List<srm_supplier> itemsupplierList, List<srm_purchase> purchaselist, PoActionListDto poaction,int poType)
|
|
|
{
|
|
|
List<srm_po_main> polist = new List<srm_po_main>();
|
|
|
List<srm_po_list> podetaillist = new List<srm_po_list>();
|
|
|
+ List<POGroupDto> pOGroupDtos = new List<POGroupDto>();
|
|
|
//合并条件:目前传入的数据是一周的数据,暂时不考虑多周数据合并。
|
|
|
//标准类 1.销售订单产生 2.计划工单产生
|
|
|
- //物料属性 VMI类 费用类
|
|
|
-
|
|
|
-
|
|
|
- //var itemList = _ic_item.Find(a => a.tenant_id == input.tenantId && a.factory_id == input.factoryId).Result;
|
|
|
- //将PR按供应商和物料和日期(一周内)进行合并,生成PO
|
|
|
- //1.按照供应商、需求日期排序
|
|
|
- //2.判断是不是同一个供应商,不是的话就新建一个PO;是的话判断是不是同一周,不是的话就新建一个PO,是的话判断有没有相同物料,有的话合并物料数量价格,没有的话新建一条明细
|
|
|
- list = list.OrderBy(a => a.pr_purchaseid).ThenBy(b => b.pr_rarrive_date).ToList();
|
|
|
- long? supplierId = -1;
|
|
|
- DateTime supplierDate = DateTime.Now;
|
|
|
+ //物料属性 委外 外购
|
|
|
+ //供应商类别 标准类 外协类 VMI类 费用类 资产类
|
|
|
+ //此逻辑已经在PR按周合并了。这一块直接转PO_list,然后根据此类型,再生成PO
|
|
|
foreach (var item in list)
|
|
|
{
|
|
|
- mo_srm_po_occupy srm_Po_Occupy = new mo_srm_po_occupy();
|
|
|
- srm_Po_Occupy.id = help.NextId();
|
|
|
- srm_Po_Occupy.mysql_id = help.NextId();
|
|
|
- //srm_Po_Occupy.bang_id = bangid;
|
|
|
- srm_Po_Occupy.morder_mo = item.pr_mono;
|
|
|
- srm_Po_Occupy.qty = item.pr_aqty;
|
|
|
- srm_Po_Occupy.eid = item.sentry_id;
|
|
|
-
|
|
|
- if (item.pr_purchaseid != supplierId)
|
|
|
+ int type = item.sentry_id == null ? 1 : 0;
|
|
|
+ var pur = purchaselist.Find(s => s.supplier_id == item.pr_purchaseid && s.icitem_id == item.icitem_id);
|
|
|
+ POGroupDto poDto = pOGroupDtos.Find(s => s.supplier_type == pur.supplier_type && s.Type == type && s.erp_cls == item.pr_type.GetValueOrDefault());
|
|
|
+ if (poDto == null)
|
|
|
{
|
|
|
- var itemsupplier = itemsupplierList.Find(a => a.Id == item.pr_purchaseid);
|
|
|
- //新建一个PO
|
|
|
- srm_po_main po_Main = new srm_po_main();
|
|
|
- po_Main.GenerateNewId(help.NextId());
|
|
|
- po_Main.po_billno = poType==1? GetMaxSerialNumber(416188684804165) : GetMaxSerialNumber(416555323363397);
|
|
|
- po_Main.po_purchaser = item.pr_purchaser;
|
|
|
- po_Main.po_purchaser_no = item.pr_purchaser_num;
|
|
|
- po_Main.po_ssend_date = DateTime.Now;
|
|
|
- po_Main.po_total = item.pr_orderprice;
|
|
|
- po_Main.po_tax_rate = item.pr_rate;
|
|
|
- po_Main.po_express = 1;
|
|
|
- po_Main.state = 0;
|
|
|
- po_Main.po_note = "PR自动转PO";
|
|
|
- po_Main.po_order_type = 1;
|
|
|
- po_Main.currency = item.currencytype;
|
|
|
- po_Main.bill_type = poType;
|
|
|
- po_Main.supplier_id = item.pr_purchaseid;
|
|
|
- po_Main.supplier_name = item.pr_purchasename;
|
|
|
- po_Main.supplier_no = item.pr_purchasenumber;
|
|
|
- po_Main.contact = itemsupplier is null ? "" : itemsupplier.contact;
|
|
|
- po_Main.suppliertelephone = itemsupplier is null ? "" : itemsupplier.telephone;
|
|
|
- po_Main.deliveryaddress = "";
|
|
|
- po_Main.supplierdddress = itemsupplier is null ? "" : itemsupplier.supplier_address;
|
|
|
- po_Main.confirmstate = 1;
|
|
|
- po_Main.logisticsstate = 0;
|
|
|
- po_Main.financialstate = 0;
|
|
|
- po_Main.create_time = DateTime.Now;
|
|
|
- po_Main.factory_id = param.factoryId;
|
|
|
- po_Main.tenant_id = param.tenantId;
|
|
|
- po_Main.po_delivery = 1;
|
|
|
- polist.Add(po_Main);
|
|
|
-
|
|
|
- srm_po_list podetail = new srm_po_list();
|
|
|
- podetail.GenerateNewId(help.NextId());
|
|
|
- podetail.po_id = po_Main.Id;
|
|
|
- podetail.po_billno = po_Main.po_billno;
|
|
|
- podetail.polist_row = podetaillist.Where(a => a.po_billno == po_Main.po_billno).Count() + 1;
|
|
|
- podetail.pr_id = item.Id;
|
|
|
- podetail.pr_billno = item.pr_billno;
|
|
|
- podetail.pr_purchase_id = po_Main.supplier_id;
|
|
|
- podetail.pr_purchase_name = po_Main.supplier_name;
|
|
|
- podetail.icitem_id = item.icitem_id;
|
|
|
- podetail.ItemNum = itemList.First(a => a.Id == item.icitem_id).number;
|
|
|
- podetail.icitem_name = item.icitem_name;
|
|
|
- podetail.qty = item.pr_aqty;
|
|
|
- podetail.netprice = item.pr_price;
|
|
|
- podetail.rate = item.pr_rate;
|
|
|
- podetail.price = item.pr_orderprice / item.pr_aqty;
|
|
|
- podetail.total_price = item.pr_orderprice;
|
|
|
- podetail.plan_qty = item.pr_aqty;
|
|
|
- podetail.unit = item.pr_unit;
|
|
|
- podetail.state = item.state;
|
|
|
- podetail.rarrdate = item.pr_rarrive_date;
|
|
|
- podetail.rnumber = 0;
|
|
|
- podetail.currencytype = item.currencytype;
|
|
|
- podetail.create_time = DateTime.Now;
|
|
|
- podetail.factory_id = param.factoryId;
|
|
|
- podetail.tenant_id = param.tenantId;
|
|
|
- podetail.stock_id = 1;
|
|
|
- podetaillist.Add(podetail);
|
|
|
-
|
|
|
- srm_Po_Occupy.polist_id = podetail.Id;
|
|
|
- srm_Po_Occupy.polist_row = podetail.polist_row;
|
|
|
- srm_Po_Occupy.type = MorderEnum.Zyjc_Type;//TODO:类型未知
|
|
|
- srm_Po_Occupy.stime = podetail.create_time;
|
|
|
- srm_Po_Occupy.etime = podetail.rarrdate;
|
|
|
-
|
|
|
- supplierId = item.pr_purchaseid;
|
|
|
- supplierDate = item.pr_rarrive_date.Value;
|
|
|
+ poDto = new POGroupDto();
|
|
|
+ poDto.Type = type;
|
|
|
+ poDto.erp_cls = item.pr_type.GetValueOrDefault();//委外 外购
|
|
|
+ poDto.supplier_type = pur.supplier_type;
|
|
|
+ poDto.polist = new List<srm_po_list>();
|
|
|
+ pOGroupDtos.Add(poDto);
|
|
|
}
|
|
|
- else
|
|
|
+ srm_po_list podetail = new srm_po_list();
|
|
|
+ podetail.GenerateNewId(help.NextId());
|
|
|
+ podetail.pr_id = item.Id;
|
|
|
+ podetail.pr_billno = item.pr_billno;
|
|
|
+ podetail.icitem_id = item.icitem_id;
|
|
|
+ podetail.ItemNum = itemList.First(a => a.Id == item.icitem_id).number;
|
|
|
+ podetail.icitem_name = item.icitem_name;
|
|
|
+ podetail.qty = item.pr_aqty;
|
|
|
+ podetail.netprice = item.pr_price;
|
|
|
+ podetail.rate = item.pr_rate;
|
|
|
+ podetail.price = item.pr_orderprice / item.pr_aqty;
|
|
|
+ podetail.total_price = item.pr_orderprice;
|
|
|
+ podetail.plan_qty = item.pr_aqty;
|
|
|
+ podetail.unit = item.pr_unit;
|
|
|
+ podetail.state = item.state;
|
|
|
+ podetail.rarrdate = item.pr_rarrive_date;
|
|
|
+ podetail.rnumber = 0;
|
|
|
+ podetail.currencytype = item.currencytype;
|
|
|
+ podetail.create_time = DateTime.Now;
|
|
|
+ podetail.factory_id = param.factoryId;
|
|
|
+ podetail.tenant_id = param.tenantId;
|
|
|
+ podetail.stock_id = 1;
|
|
|
+ podetaillist.Add(podetail);
|
|
|
+ poDto.polist.Add(podetail);
|
|
|
+ }
|
|
|
+ List<srm_pr_main> referlist = new List<srm_pr_main>();
|
|
|
+ RecursionGetDbPr(list, referlist);
|
|
|
+ //组合PO
|
|
|
+ foreach (var dto in pOGroupDtos)
|
|
|
+ {
|
|
|
+ srm_po_main po_Main = new srm_po_main();
|
|
|
+ po_Main.GenerateNewId(help.NextId());
|
|
|
+ po_Main.po_billno = poType == 1 ? GetMaxSerialNumber(416188684804165) : GetMaxSerialNumber(416555323363397);
|
|
|
+ var pr = list.Find(s => s.Id == dto.polist[0].pr_id);
|
|
|
+ var itemsupplier = itemsupplierList.Find(a => a.Id == pr.pr_purchaseid);
|
|
|
+ po_Main.po_purchaser = pr.pr_purchaser;
|
|
|
+ po_Main.po_purchaser_no = pr.pr_purchaser_num;
|
|
|
+ po_Main.po_ssend_date = DateTime.Now;
|
|
|
+ po_Main.po_tax_rate = pr.pr_rate;
|
|
|
+ po_Main.po_express = 1;
|
|
|
+ po_Main.state = 0;
|
|
|
+ po_Main.po_note = "";
|
|
|
+ po_Main.po_order_type = 1;
|
|
|
+ po_Main.currency = pr.currencytype;
|
|
|
+ po_Main.bill_type = poType;
|
|
|
+ po_Main.supplier_id = pr.pr_purchaseid;
|
|
|
+ po_Main.supplier_name = pr.pr_purchasename;
|
|
|
+ po_Main.supplier_no = pr.pr_purchasenumber;
|
|
|
+ po_Main.contact = itemsupplier is null ? "" : itemsupplier.contact;
|
|
|
+ po_Main.suppliertelephone = itemsupplier is null ? "" : itemsupplier.telephone;
|
|
|
+ po_Main.deliveryaddress = "";
|
|
|
+ po_Main.supplierdddress = itemsupplier is null ? "" : itemsupplier.supplier_address;
|
|
|
+ po_Main.confirmstate = 1;
|
|
|
+ po_Main.logisticsstate = 0;
|
|
|
+ po_Main.financialstate = 0;
|
|
|
+ po_Main.create_time = DateTime.Now;
|
|
|
+ po_Main.factory_id = param.factoryId;
|
|
|
+ po_Main.tenant_id = param.tenantId;
|
|
|
+ po_Main.po_delivery = 1;
|
|
|
+ polist.Add(po_Main);
|
|
|
+
|
|
|
+ int row = 1;
|
|
|
+ dto.polist.ForEach(p =>
|
|
|
{
|
|
|
- //同一个供应商先判断需求日期是否在同一周
|
|
|
- if (IsSameWeek(supplierDate, item.pr_rarrive_date.Value))
|
|
|
+ var toPr = list.Find(s => s.Id == p.pr_id);
|
|
|
+ List<srm_pr_main> clist = new List<srm_pr_main>();
|
|
|
+ RecursionPr(toPr, referlist, clist);
|
|
|
+ if (clist.Any())
|
|
|
{
|
|
|
- var pomain = polist.FindAll(x => x.supplier_id == item.pr_purchaseid).OrderByDescending(b => b.create_time).First();
|
|
|
- List<srm_po_list> detail = podetaillist.FindAll(a => a.po_billno == pomain.po_billno && a.icitem_id == item.icitem_id);
|
|
|
- if (detail.Count > 0)
|
|
|
+ clist.ForEach(c =>
|
|
|
{
|
|
|
- //TODO:只能记录一条PR,可能需要先合PR
|
|
|
- //存在同一种物料,存在就计算数量和价格,
|
|
|
- detail[0].qty = detail[0].qty + item.pr_aqty;
|
|
|
- detail[0].netprice = detail[0].netprice + item.pr_price;
|
|
|
- detail[0].total_price = detail[0].total_price + item.pr_orderprice;
|
|
|
- detail[0].plan_qty = detail[0].plan_qty + item.pr_aqty;
|
|
|
- detail[0].rarrdate = item.pr_rarrive_date;
|
|
|
-
|
|
|
- srm_Po_Occupy.polist_id = detail[0].Id;
|
|
|
- srm_Po_Occupy.polist_row = detail[0].polist_row;
|
|
|
+ srm_po_occupy srm_Po_Occupy = new srm_po_occupy();
|
|
|
+ srm_Po_Occupy.GenerateNewId(help.NextId());
|
|
|
+ //srm_Po_Occupy.bang_id = bangid;
|
|
|
+ srm_Po_Occupy.morder_mo = c.pr_mono;
|
|
|
+ srm_Po_Occupy.qty = c.pr_aqty;
|
|
|
+ srm_Po_Occupy.eid = c.sentry_id;
|
|
|
+ srm_Po_Occupy.polist_id = p.Id;
|
|
|
+ srm_Po_Occupy.polist_row = p.polist_row;
|
|
|
srm_Po_Occupy.type = MorderEnum.Zyjc_Type;//TODO:类型未知
|
|
|
- srm_Po_Occupy.stime = detail[0].create_time;
|
|
|
- srm_Po_Occupy.etime = detail[0].rarrdate;
|
|
|
- pomain.po_total = pomain.po_total + item.pr_orderprice;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //不存在同一种物料新增一条明细
|
|
|
- srm_po_list podetail = new srm_po_list();
|
|
|
- podetail.GenerateNewId(help.NextId());
|
|
|
- podetail.po_id = pomain.Id;
|
|
|
- podetail.po_billno = pomain.po_billno;
|
|
|
- podetail.polist_row = podetaillist.Where(a => a.po_billno == pomain.po_billno).Count() + 1;
|
|
|
- podetail.pr_id = item.Id;
|
|
|
- podetail.pr_billno = item.pr_billno;
|
|
|
- podetail.pr_purchase_id = pomain.supplier_id;
|
|
|
- podetail.pr_purchase_name = pomain.supplier_name;
|
|
|
- podetail.icitem_id = item.icitem_id;
|
|
|
- podetail.ItemNum = itemList.First(a => a.Id == item.icitem_id).number;
|
|
|
- podetail.icitem_name = item.icitem_name;
|
|
|
- podetail.qty = item.pr_aqty;
|
|
|
- podetail.netprice = item.pr_price;
|
|
|
- podetail.rate = item.pr_rate;
|
|
|
- podetail.price = item.pr_orderprice / item.pr_aqty;
|
|
|
- podetail.total_price = item.pr_orderprice;
|
|
|
- podetail.plan_qty = item.pr_aqty;
|
|
|
- podetail.unit = item.pr_unit;
|
|
|
- podetail.state = item.state;
|
|
|
- podetail.rarrdate = item.pr_rarrive_date;
|
|
|
- podetail.rnumber = 0;
|
|
|
- podetail.currencytype = item.currencytype;
|
|
|
- podetail.create_time = DateTime.Now;
|
|
|
- podetail.factory_id = param.factoryId;
|
|
|
- podetail.tenant_id = param.tenantId;
|
|
|
- //podetail.bang_id = bangid;
|
|
|
- podetail.stock_id = 1;
|
|
|
- podetaillist.Add(podetail);
|
|
|
-
|
|
|
- srm_Po_Occupy.polist_id = podetail.Id;
|
|
|
- srm_Po_Occupy.polist_row = podetail.polist_row;
|
|
|
- srm_Po_Occupy.type = MorderEnum.Zyjc_Type;//TODO:类型未知
|
|
|
- srm_Po_Occupy.stime = podetail.create_time;
|
|
|
- srm_Po_Occupy.etime = podetail.rarrdate;
|
|
|
-
|
|
|
- pomain.po_total = pomain.po_total + item.pr_orderprice;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //不在同一周需要新建一张PO
|
|
|
- var itemsupplier = itemsupplierList.Find(a => a.Id == item.pr_purchaseid);
|
|
|
- //新建一个PO单
|
|
|
- srm_po_main po_Main = new srm_po_main();
|
|
|
- po_Main.GenerateNewId(help.NextId());
|
|
|
- po_Main.po_billno = poType == 1 ? GetMaxSerialNumber(416188684804165) : GetMaxSerialNumber(416555323363397);
|
|
|
- po_Main.po_purchaser = item.pr_purchaser;
|
|
|
- po_Main.po_purchaser_no = item.pr_purchaser_num;
|
|
|
- po_Main.po_ssend_date = DateTime.Now;
|
|
|
- po_Main.po_total = item.pr_orderprice;
|
|
|
- po_Main.po_tax_rate = item.pr_rate;
|
|
|
- po_Main.po_express = 1;
|
|
|
- po_Main.state = 0;
|
|
|
- po_Main.po_note = "PR自动转PO";
|
|
|
- po_Main.po_order_type = 1;
|
|
|
- po_Main.currency = item.currencytype;
|
|
|
- po_Main.bill_type = poType;
|
|
|
- po_Main.supplier_id = item.pr_purchaseid;
|
|
|
- po_Main.supplier_name = item.pr_purchasename;
|
|
|
- po_Main.supplier_no = item.pr_purchasenumber;
|
|
|
- po_Main.contact = itemsupplier is null ? "" : itemsupplier.contact;
|
|
|
- po_Main.suppliertelephone = itemsupplier is null ? "" : itemsupplier.telephone;
|
|
|
- po_Main.deliveryaddress = "";
|
|
|
- po_Main.supplierdddress = itemsupplier is null ? "" : itemsupplier.supplier_address;
|
|
|
- po_Main.confirmstate = 1;
|
|
|
- po_Main.logisticsstate = 0;
|
|
|
- po_Main.financialstate = 0;
|
|
|
- po_Main.create_time = DateTime.Now;
|
|
|
- po_Main.factory_id = param.factoryId;
|
|
|
- po_Main.tenant_id = param.tenantId;
|
|
|
- po_Main.po_delivery = 1;
|
|
|
- polist.Add(po_Main);
|
|
|
-
|
|
|
- srm_po_list podetail = new srm_po_list();
|
|
|
- podetail.GenerateNewId(help.NextId());
|
|
|
- podetail.po_id = po_Main.Id;
|
|
|
- podetail.po_billno = po_Main.po_billno;
|
|
|
- podetail.polist_row = podetaillist.Where(a => a.po_billno == po_Main.po_billno).Count() + 1;
|
|
|
- podetail.pr_id = item.Id;
|
|
|
- podetail.pr_billno = item.pr_billno;
|
|
|
- podetail.pr_purchase_id = po_Main.supplier_id;
|
|
|
- podetail.pr_purchase_name = po_Main.supplier_name;
|
|
|
- podetail.icitem_id = item.icitem_id;
|
|
|
- podetail.ItemNum = itemList.First(a => a.Id == item.icitem_id).number;
|
|
|
- podetail.icitem_name = item.icitem_name;
|
|
|
- podetail.qty = item.pr_aqty;
|
|
|
- podetail.netprice = item.pr_price;
|
|
|
- podetail.rate = item.pr_rate;
|
|
|
- podetail.price = item.pr_orderprice / item.pr_aqty;
|
|
|
- podetail.total_price = item.pr_orderprice;
|
|
|
- podetail.plan_qty = item.pr_aqty;
|
|
|
- podetail.unit = item.pr_unit;
|
|
|
- podetail.state = item.state;
|
|
|
- podetail.rarrdate = item.pr_rarrive_date;
|
|
|
- podetail.rnumber = 0;
|
|
|
- podetail.currencytype = item.currencytype;
|
|
|
- podetail.create_time = DateTime.Now;
|
|
|
- podetail.factory_id = param.factoryId;
|
|
|
- podetail.tenant_id = param.tenantId;
|
|
|
- podetail.stock_id = 1;
|
|
|
- podetaillist.Add(podetail);
|
|
|
-
|
|
|
- srm_Po_Occupy.polist_id = podetail.Id;
|
|
|
- srm_Po_Occupy.polist_row = podetail.polist_row;
|
|
|
- srm_Po_Occupy.type = MorderEnum.Zyjc_Type;//TODO:类型未知
|
|
|
- srm_Po_Occupy.stime = podetail.create_time;
|
|
|
- srm_Po_Occupy.etime = podetail.rarrdate;
|
|
|
-
|
|
|
- supplierId = item.pr_purchaseid;
|
|
|
- supplierDate = item.pr_rarrive_date.Value;
|
|
|
+ srm_Po_Occupy.stime = p.create_time;
|
|
|
+ srm_Po_Occupy.etime = p.rarrdate;
|
|
|
+ srm_Po_Occupy.state = 1;
|
|
|
+ srm_Po_Occupy.tenant_id = param.tenantId;//取销售子表企业ID
|
|
|
+ srm_Po_Occupy.factory_id = param.factoryId;
|
|
|
+ srm_Po_Occupy.create_time = DateTime.Now;
|
|
|
+ srm_Po_Occupy.create_by_name = "admin";
|
|
|
+ srm_Po_Occupy.update_time = DateTime.Now;
|
|
|
+ srm_Po_Occupy.update_by_name = "admin";
|
|
|
+ poaction.poOccupiesList.Add(srm_Po_Occupy);
|
|
|
+ });
|
|
|
}
|
|
|
- }
|
|
|
- srm_Po_Occupy.state = 1;
|
|
|
- srm_Po_Occupy.tenant_id = param.tenantId;//取销售子表企业ID
|
|
|
- srm_Po_Occupy.factory_id = param.factoryId;
|
|
|
- srm_Po_Occupy.create_time = DateTime.Now;
|
|
|
- srm_Po_Occupy.create_by_name = "admin";
|
|
|
- srm_Po_Occupy.update_time = DateTime.Now;
|
|
|
- srm_Po_Occupy.update_by_name = "admin";
|
|
|
- poaction.poOccupiesList.Add(srm_Po_Occupy);
|
|
|
+
|
|
|
+ po_Main.po_total += p.total_price;
|
|
|
+ p.po_id = po_Main.Id;
|
|
|
+ p.po_billno = po_Main.po_billno;
|
|
|
+ p.polist_row = row;
|
|
|
+ p.pr_purchase_id = po_Main.supplier_id;
|
|
|
+ p.pr_purchase_name = po_Main.supplier_name;
|
|
|
+ row++;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-
|
|
|
poaction.poMain.AddRange(polist);
|
|
|
poaction.polist.AddRange(podetaillist);
|
|
|
List<PurOrdMaster> purOrdMasters = new List<PurOrdMaster>();
|
|
|
@@ -2093,6 +2010,40 @@ namespace Business.ResourceExamineManagement
|
|
|
poaction.poDetailList.AddRange(purOrdDetails);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 递归寻找PR,找到最末级数据,生成占用关系
|
|
|
+ /// </summary>
|
|
|
+ public void RecursionGetDbPr(List<srm_pr_main> list, List<srm_pr_main> referlist)
|
|
|
+ {
|
|
|
+ List<srm_pr_main> prlist = _mysql_srm_pr_main.GetListAsync(s => list.Select(c => c.pr_billno).Contains(s.refer_pr_billno)).Result;
|
|
|
+ if (prlist.Any())
|
|
|
+ {
|
|
|
+ referlist.AddRange(prlist);
|
|
|
+ RecursionGetDbPr(prlist, referlist);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 递归寻找当前PR所关联的真实工单生成的PR,需要形成占用关系。
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="list"></param>
|
|
|
+ /// <param name="referlist"></param>
|
|
|
+ public void RecursionPr(srm_pr_main pr, List<srm_pr_main> referlist, List<srm_pr_main> clist)
|
|
|
+ {
|
|
|
+ var list = referlist.Where(s => s.refer_pr_billno == pr.pr_billno).ToList();
|
|
|
+ if (list.Any())
|
|
|
+ {
|
|
|
+ foreach (var child in list)
|
|
|
+ {
|
|
|
+ RecursionPr(child, referlist, clist);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ clist.Add(pr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 计划工单齐套检查
|
|
|
/// </summary>
|
|
|
@@ -2512,9 +2463,9 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
_businessDbContext.BulkInsert(poaction.polist);
|
|
|
}
|
|
|
- if (poaction.poOccupiesList.Any())
|
|
|
+ if (poaction.mopoOccupiesList.Any())
|
|
|
{
|
|
|
- var poOccupies = ObjectMapper.Map<List<mo_srm_po_occupy>, List<srm_po_occupy>>(poaction.poOccupiesList);
|
|
|
+ var poOccupies = ObjectMapper.Map<List<mo_srm_po_occupy>, List<srm_po_occupy>>(poaction.mopoOccupiesList);
|
|
|
_businessDbContext.BulkInsert(poOccupies);
|
|
|
}
|
|
|
|