|
|
@@ -5735,21 +5735,32 @@ namespace Business.Replenishment
|
|
|
if (srm_pr_main.Count > 0)
|
|
|
{
|
|
|
var moSrm_pr_main = ObjectMapper.Map<List<srm_pr_main>, List<mo_srm_pr_main>>(srm_pr_main);
|
|
|
- moSrm_pr_main.ForEach(item => { item.GenerateNewId(help.NextId()); item.bang_id = bangid; });
|
|
|
+ moSrm_pr_main.ForEach(item => { item.GenerateNewId(help.NextId()); item.bang_id = bangid; item.create_time = DateTime.Now; });
|
|
|
await MongoHelper<mo_srm_pr_main>.InsertManyAsync(moSrm_pr_main);
|
|
|
|
|
|
- //采购申请占用详情
|
|
|
- var occupyList = _businessDbContext.srm_po_occupy.Join(_businessDbContext.srm_pr_main.Where(x => x.company_id == companyId && x.factory_id == factoryId && x.state != 0 && itemIds.ToArray().Any(a => a == x.icitem_id.GetValueOrDefault())), p => p.polist_id, pr => pr.Id, (p, pr) => new { p, pr }).ToList();
|
|
|
- List<srm_po_occupy> srm_pr_occupy = new List<srm_po_occupy>();
|
|
|
- for (int i = 0; i < occupyList.Count; i++)
|
|
|
+ List<srm_po_occupy> occupylist = new List<srm_po_occupy>();
|
|
|
+ if (string.IsNullOrEmpty(analogCalcVersion))
|
|
|
{
|
|
|
- srm_pr_occupy.Add(occupyList[i].p);
|
|
|
+ var occupyListLINQ = _businessDbContext.srm_po_occupy.Where(x => x.company_id == companyId && x.factory_id == factoryId && !x.IsDeleted).Join(_businessDbContext.srm_pr_main.Where(x => x.company_id == companyId && x.factory_id == factoryId && x.state != 0 && string.IsNullOrEmpty(x.analogcalcversion) && itemIds.Contains(x.icitem_id.GetValueOrDefault())), p => p.polist_id, pr => pr.Id, (p, pr) => new { p, pr }).ToList();
|
|
|
+
|
|
|
+ for (int i = 0; i < occupyListLINQ.Count; i++)
|
|
|
+ {
|
|
|
+ occupylist.Add(occupyListLINQ[i].p);
|
|
|
+ }
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ var occupyListLINQ = _businessDbContext.srm_po_occupy.Where(x => x.company_id == companyId && x.factory_id == factoryId && !x.IsDeleted).Join(_businessDbContext.srm_pr_main.Where(x => x.company_id == companyId && x.factory_id == factoryId && x.state != 0 && itemIds.Contains(x.icitem_id.GetValueOrDefault())), p => p.polist_id, pr => pr.Id, (p, pr) => new { p, pr }).ToList();
|
|
|
+
|
|
|
+ for (int i = 0; i < occupyListLINQ.Count; i++)
|
|
|
+ {
|
|
|
+ occupylist.Add(occupyListLINQ[i].p);
|
|
|
+ }
|
|
|
}
|
|
|
- //var srm_pr_occupy=_businessDbContext.srm_po_occupy.Where(x => x.company_id == companyId && x.factory_id == factoryId && srm_pr_main.Select(c => c.Id).Contains(x.polist_id.Value)).ToList();
|
|
|
- //var srm_pr_occupy = _mysql_srm_po_occupy.GetListAsync(x => x.company_id == companyId && x.factory_id == factoryId && srm_pr_main.Select(c => c.Id).Any(a=>a==x.polist_id.GetValueOrDefault())).Result;
|
|
|
- if (srm_pr_occupy.Count > 0)
|
|
|
+ //采购申请占用详情
|
|
|
+ //var srm_pr_occupy = _mysql_srm_po_occupy.GetListAsync(x => x.company_id == companyId && x.factory_id == factoryId && srm_pr_main.Select(c => c.Id).Contains(x.polist_id.GetValueOrDefault())).Result;
|
|
|
+ if (occupylist.Count > 0)
|
|
|
{
|
|
|
- var moSrm_pr_occupy = ObjectMapper.Map<List<srm_po_occupy>, List<mo_srm_po_occupy>>(srm_pr_occupy);
|
|
|
+ var moSrm_pr_occupy = ObjectMapper.Map<List<srm_po_occupy>, List<mo_srm_po_occupy>>(occupylist);
|
|
|
moSrm_pr_occupy.ForEach(item => { item.GenerateNewId(help.NextId()); item.bang_id = bangid; item.create_time = DateTime.Now; });
|
|
|
await MongoHelper<mo_srm_po_occupy>.InsertManyAsync(moSrm_pr_occupy);
|
|
|
}
|