|
|
@@ -1613,15 +1613,18 @@ namespace Business.ResourceExamineManagement
|
|
|
//PO占用记录
|
|
|
List<mo_srm_po_occupy> po_occupy = await _srm_po_occupy.GetListAsync(s => seIds.Contains(s.eid.Value) && bangidList.Contains(s.bang_id.Value));
|
|
|
List<mo_srm_pr_main> prmainlist = await _srm_pr_main.GetListAsync(s => seIds.Contains(s.sentry_id.Value) && bangidList.Contains(s.bang_id.Value));
|
|
|
+ string seqSql = "";
|
|
|
if (prmainlist.Any())
|
|
|
{
|
|
|
var nbrlistDto = _serialNumberAppService.GetBillNo(prmainlist[0].factory_id.ToString(), "PR", prmainlist.Count, "admin", 1);
|
|
|
+
|
|
|
int index = 0;
|
|
|
+
|
|
|
foreach (var p in prmainlist)
|
|
|
{
|
|
|
if (nbrlistDto[index] != null)
|
|
|
{
|
|
|
- p.pr_billno = nbrlistDto[index].NbrResult;
|
|
|
+ p.pr_billno = nbrlistDto[index].NbrResult.ToString();
|
|
|
}
|
|
|
index++;
|
|
|
if (p.pr_purchaseid.GetValueOrDefault() == 0)
|
|
|
@@ -1635,8 +1638,25 @@ namespace Business.ResourceExamineManagement
|
|
|
p.pr_purchasenumber = list[0].supplier_number;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+ var prapplyList = prmainlist.Where(s => s.IsRequireGoods != 1).ToList();
|
|
|
+ if (prapplyList.Any())
|
|
|
+ {
|
|
|
+ var rstSeqId = _serialNumberAppService.GetSeqIdList(prapplyList[0].factory_id.ToString(), 1, 1);
|
|
|
+ long seqId = 0;
|
|
|
+ if (long.TryParse(rstSeqId, out seqId))
|
|
|
+ {
|
|
|
+ prapplyList.ForEach(p =>
|
|
|
+ {
|
|
|
+ seqSql += "insert QadTracking(Domain,SeqID,TransType,Subject,[Order],Int1,CreateTime,CreateUser,UpdateTime,UpdateUser) value('" + p.factory_id.ToString() +
|
|
|
+ "'," + seqId + ",'nbr-pr-mes','请购单'," + p.pr_billno + " [Order]," + p.Id.ToString() + " as Int1,getdate() as CreateTime,'',getdate() as UpdateTime,'');";
|
|
|
+ seqId++;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
List<mo_ic_item_stockoccupy> item_stockoccupy = await _ic_item_stockoccupy.GetListAsync(s => seIds.Contains(s.orderentry_id.Value) && bangidList.Contains(s.bang_id));
|
|
|
|
|
|
@@ -1648,6 +1668,10 @@ namespace Business.ResourceExamineManagement
|
|
|
//批量保存 后期考虑子工单
|
|
|
if (moderlist.Any())
|
|
|
{
|
|
|
+ if (!string.IsNullOrEmpty(seqSql))
|
|
|
+ {
|
|
|
+ _businessBangDbContext.Database.ExecuteSqlRaw(seqSql);
|
|
|
+ }
|
|
|
_businessDbContext.BulkInsert(moderlist);
|
|
|
if (workOrds.Any())
|
|
|
{
|
|
|
@@ -2278,7 +2302,7 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
var podtls = podetaillist.Where(s => s.po_billno == p.po_billno).ToList();
|
|
|
|
|
|
- p.po_billno = nbrlistDto[index].NbrResult;
|
|
|
+ p.po_billno = nbrlistDto[index].NbrResult.ToString();
|
|
|
podtls.ForEach(s =>
|
|
|
{
|
|
|
s.po_billno = p.po_billno;
|
|
|
@@ -3233,7 +3257,7 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
if (nbrlistDto[index] != null)
|
|
|
{
|
|
|
- p.pr_billno = nbrlistDto[index].NbrResult;
|
|
|
+ p.pr_billno = nbrlistDto[index].NbrResult.ToString();
|
|
|
}
|
|
|
index++;
|
|
|
if (p.pr_purchaseid.GetValueOrDefault() == 0)
|
|
|
@@ -3632,7 +3656,7 @@ namespace Business.ResourceExamineManagement
|
|
|
var nbrDtls = nbrDetailList.Where(s => s.Nbr == nm.Nbr).ToList();
|
|
|
if (nbrlistDto[index] != null)
|
|
|
{
|
|
|
- nm.Nbr = nbrlistDto[index].NbrResult;
|
|
|
+ nm.Nbr = nbrlistDto[index].NbrResult.ToString();
|
|
|
nbrDtls.ForEach(i => { i.Nbr = nm.Nbr; });
|
|
|
}
|
|
|
index++;
|
|
|
@@ -3746,7 +3770,8 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
itemChildList.AddRange(GetChildItemNumber(a, new List<string>()));
|
|
|
});
|
|
|
- var stockList = _locationDetail.Select(a => a.Domain == param.factoryId.ToString() && a.IsActive && itemChildList.Distinct().Contains(a.ItemNum));
|
|
|
+ List<string> locationList = new List<string> { "1000", "1001", "5008", "8000", "8001" };
|
|
|
+ var stockList = _locationDetail.Select(a => a.Domain == param.factoryId.ToString() && locationList.Contains(a.Location) && a.IsActive && itemChildList.Distinct().Contains(a.ItemNum));
|
|
|
var groupList = stockList.
|
|
|
GroupBy(m => new { m.ItemNum }).
|
|
|
Select(a => new { ItemNum = a.Key.ItemNum, Qty = a.Sum(c => c.QtyOnHand) }).ToList();
|
|
|
@@ -3776,6 +3801,7 @@ namespace Business.ResourceExamineManagement
|
|
|
stock.icitem_id = num.Id;
|
|
|
stock.icitem_name = num.name;
|
|
|
stock.sqty = groupList.First(a => a.ItemNum == num.number).Qty;
|
|
|
+ needAddList.Add(stock);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
@@ -3860,16 +3886,19 @@ namespace Business.ResourceExamineManagement
|
|
|
await AutoCreatePickBill(workOrdMasters, dbPeriodSequences, nbrMasterList, nbrDetailList, userAccount, workDetails);
|
|
|
if (nbrMasterList.Any())
|
|
|
{
|
|
|
+ string seqSql = "";
|
|
|
var weekplan = _replenishmentWeekPlan.GetListAsync(s => s.factory_id.ToString() == domain && workOrdMasters.Select(x => x.WorkOrd).Contains(s.OrderNO)).Result;
|
|
|
- var worklistDto = _serialNumberAppService.GetBillNo(workOrdMasters[0].Domain, "WOlot", workOrdMasters.Count, userAccount, 1);
|
|
|
+ var worklistDto = _serialNumberAppService.GetBillNo(domain, "WOlot", workOrdMasters.Count, userAccount, 1);
|
|
|
+ var seqid = _serialNumberAppService.GetSeqIdList(domain, 1, 1);
|
|
|
int index = 0;
|
|
|
+ int idx = 0;
|
|
|
workOrdMasters.ForEach(p => {
|
|
|
p.Status = "r";
|
|
|
if (worklistDto.Any())
|
|
|
{
|
|
|
if (worklistDto[index] != null)
|
|
|
{
|
|
|
- p.LotSerial = worklistDto[index].NbrResult;
|
|
|
+ p.LotSerial = worklistDto[index].NbrResult.ToString();
|
|
|
var weekp = weekplan.Find(s => s.OrderNO == p.WorkOrd);
|
|
|
if (weekp != null)
|
|
|
{
|
|
|
@@ -3878,6 +3907,17 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
index++;
|
|
|
}
|
|
|
+ /*if (seqidlist.Any())
|
|
|
+ {
|
|
|
+ if (seqidlist.Any())
|
|
|
+ {
|
|
|
+ if (seqidlist[idx] != null)
|
|
|
+ {
|
|
|
+ seqSql += "insert QadTracking(Domain,SeqID,TransType,Subject,[Order],Int1,CreateTime,CreateUser,UpdateTime,UpdateUser) select '" + domain + "'," + seqidlist[idx].NbrResult + ",'nbr-wo-mes','工单',WorkOrd [Order],RecID as Int1,getdate() as CreateTime,CreateUser,getdate() as UpdateTime,UpdateUser from WorkOrdMaster where RecID=" + p.RecID.ToString() + ";";
|
|
|
+ idx++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }*/
|
|
|
});
|
|
|
|
|
|
var nbrlistDto = _serialNumberAppService.GetBillNo(workOrdMasters[0].Domain, "SM", nbrMasterList.Count, userAccount, 1);
|
|
|
@@ -3889,7 +3929,7 @@ namespace Business.ResourceExamineManagement
|
|
|
var nbrDtls = nbrDetailList.Where(s => s.Nbr == nm.Nbr).ToList();
|
|
|
if (nbrlistDto[index] != null)
|
|
|
{
|
|
|
- nm.Nbr = nbrlistDto[index].NbrResult;
|
|
|
+ nm.Nbr = nbrlistDto[index].NbrResult.ToString();
|
|
|
nbrDtls.ForEach(i => { i.Nbr = nm.Nbr; });
|
|
|
}
|
|
|
index++;
|
|
|
@@ -3902,6 +3942,9 @@ namespace Business.ResourceExamineManagement
|
|
|
var icitem = _mysql_ic_item.GetListAsync(s => s.factory_id.ToString() == domain && nbrDetailList.Select(c => c.ItemNum).Contains(s.number)).Result;
|
|
|
//根据领料单生成一次工单的数据占用
|
|
|
List<ic_item_stockoccupy> insertOccuyy = new List<ic_item_stockoccupy>();
|
|
|
+
|
|
|
+ var seqId = _serialNumberAppService.GetSeqIdList(workOrdMasters[0].Domain, 1, 1);
|
|
|
+ int sidx = 0;
|
|
|
nbrMasterList.ForEach(s =>
|
|
|
{
|
|
|
var nbrdtls = nbrDetailList.Where(a => a.Nbr == s.Nbr).ToList();
|
|
|
@@ -3923,6 +3966,11 @@ namespace Business.ResourceExamineManagement
|
|
|
insertOccuyy.Add(itemStockoccupyDto);
|
|
|
}
|
|
|
});
|
|
|
+ /*if (seqIdlist[sidx] != null)
|
|
|
+ {
|
|
|
+ seqSql += "insert QadTracking(Domain,SeqID,TransType,Subject,[Order],Int1,Ufld1,Ufld2,CreateTime,CreateUser,UpdateTime,UpdateUser) select '" + domain + "'," + seqIdlist[sidx].NbrResult + " as SeqID,'nbr-sm-mes','领料申请单',Nbr as [Order],RecID as Int1,'A' as Ufld1,'sm' as Ufld2,getdate() as CreateTime,CreateUser,getdate() as UpdateTime,UpdateUser from NbrMaster where RecID=" + s.RecID + ";";
|
|
|
+ sidx++;
|
|
|
+ }*/
|
|
|
});
|
|
|
|
|
|
//获取工单工艺路径数据
|
|
|
@@ -3938,7 +3986,9 @@ namespace Business.ResourceExamineManagement
|
|
|
string sql =string.Format("exec pr_WMS_BPM_AddMobileTask @TaskID='{0}',@PlanDate='{1}',@ExecuterTypeID=2,@CreateUser='{2}'", a.Nbr, a.Date.Value.ToString("yyyy-MM-dd"), a.CreateUser);
|
|
|
_businessDbContext.Database.ExecuteSqlRaw(sql);
|
|
|
});
|
|
|
-
|
|
|
+ if (!string.IsNullOrEmpty(seqSql)) {
|
|
|
+ _businessBangDbContext.Database.ExecuteSqlRaw(seqSql);
|
|
|
+ }
|
|
|
if (itemstockoccupy.Any())
|
|
|
{
|
|
|
await _mysql_ic_item_stockoccupy.HardDeleteAsync(itemstockoccupy);
|
|
|
@@ -4226,6 +4276,67 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
|
public async Task<string> SubstituteSave(SubstituteDto dto)
|
|
|
+ {
|
|
|
+ var rst = SubstituteSaveSync(dto).Result;
|
|
|
+ if (rst == "ok")
|
|
|
+ {
|
|
|
+ //如果保存成功,则同步到mongodb。
|
|
|
+ var list = _mysql_ic_substitute.GetListAsync(s => s.substitute_code == dto.scode && s.company_id == dto.company_id && s.factory_id == dto.factory_id).Result;
|
|
|
+ //同步替代群组数据
|
|
|
+ //var subtitutes = _mysql_ic_substitute.GetListAsync().Result;
|
|
|
+ if (list.Count > 0)
|
|
|
+ {
|
|
|
+ var moSubstitute = _ic_substitute.GetListAsync(s => s.substitute_code == dto.scode).Result;
|
|
|
+ if (moSubstitute.Any())
|
|
|
+ {
|
|
|
+ await _ic_substitute.DeleteManyAsync(moSubstitute);
|
|
|
+ }
|
|
|
+ var moSubtitutes = ObjectMapper.Map<List<ic_substitute>, List<mo_ic_substitute>>(list);
|
|
|
+ moSubtitutes.ForEach(s => s.GenerateNewId(help.NextId()));
|
|
|
+ await MongoHelper<mo_ic_substitute>.InsertManyAsync(moSubtitutes);
|
|
|
+
|
|
|
+ //同步物料替代多群组数据
|
|
|
+ var subAlls = _mysql_ic_substitute_group.GetListAsync(s => s.substitute_code == dto.scode && s.company_id == dto.company_id && s.factory_id == dto.factory_id).Result;
|
|
|
+ if (subAlls.Count > 0)
|
|
|
+ {
|
|
|
+ var moSubAll = _ic_substitute_group.GetListAsync(s => s.substitute_code == dto.scode).Result;
|
|
|
+ if (moSubAll.Any())
|
|
|
+ {
|
|
|
+ await _ic_substitute_group.DeleteManyAsync(moSubAll);
|
|
|
+ }
|
|
|
+ var moSubAlls = ObjectMapper.Map<List<ic_substitute_group>, List<mo_ic_substitute_group>>(subAlls);
|
|
|
+ moSubAlls.ForEach(s => s.GenerateNewId(help.NextId()));
|
|
|
+ await MongoHelper<mo_ic_substitute_group>.InsertManyAsync(moSubAlls);
|
|
|
+ }
|
|
|
+
|
|
|
+ //同步物料替代多群组明细数据
|
|
|
+ var subAllDtls = _mysql_ic_substitute_group_detail.GetListAsync(s => s.substitute_code == dto.scode && s.company_id == dto.company_id && s.factory_id == dto.factory_id).Result;
|
|
|
+ if (subAllDtls.Count > 0)
|
|
|
+ {
|
|
|
+ var moSuballDtl = _ic_substitute_group_detail.GetListAsync(s => s.substitute_code == dto.scode).Result;
|
|
|
+ if (moSuballDtl.Any())
|
|
|
+ {
|
|
|
+ await _ic_substitute_group_detail.DeleteManyAsync(moSuballDtl);
|
|
|
+ }
|
|
|
+ var moSubAllDtls = ObjectMapper.Map<List<ic_substitute_group_detail>, List<mo_ic_substitute_group_detail>>(subAllDtls);
|
|
|
+ moSubAllDtls.ForEach(s => s.GenerateNewId(help.NextId()));
|
|
|
+ await MongoHelper<mo_ic_substitute_group_detail>.InsertManyAsync(moSubAllDtls);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return rst;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 替代方案保存
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<string> SubstituteSaveSync(SubstituteDto dto)
|
|
|
{
|
|
|
ic_substitute stt;
|
|
|
if (dto.id == null)
|
|
|
@@ -4533,5 +4644,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
return "ok";
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|