1
This commit is contained in:
@@ -57,8 +57,7 @@ namespace RB_MES_API.Controllers
|
|||||||
/// <param name="kdhttpClient"></param>
|
/// <param name="kdhttpClient"></param>
|
||||||
/// <param name="chiledSelect"></param>
|
/// <param name="chiledSelect"></param>
|
||||||
/// <param name="kdsqlhelper"></param>
|
/// <param name="kdsqlhelper"></param>
|
||||||
public EnpowerApiController(RBContext context, IShareController shareController, IKDCloudHttpClient kdhttpClient,
|
public EnpowerApiController(RBContext context, IShareController shareController, IKDCloudHttpClient kdhttpClient, IChiledSelect chiledSelect, IKDSqlHelper kdsqlhelper)
|
||||||
IChiledSelect chiledSelect, IKDSqlHelper kdsqlhelper )
|
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_shareController = shareController;
|
_shareController = shareController;
|
||||||
@@ -9878,7 +9877,7 @@ namespace RB_MES_API.Controllers
|
|||||||
//FNumerator = b.IS_BACK == "Y" ? GetNumerator(b.TN_QTY, a.FQty, true) : a.FNumerator,
|
//FNumerator = b.IS_BACK == "Y" ? GetNumerator(b.TN_QTY, a.FQty, true) : a.FNumerator,
|
||||||
//FDenominator = b.IS_BACK == "Y" ? GetNumerator(b.TN_QTY, a.FQty, false) : a.FDenominator,
|
//FDenominator = b.IS_BACK == "Y" ? GetNumerator(b.TN_QTY, a.FQty, false) : a.FDenominator,
|
||||||
FNumerator = (b.IS_BACK == "Y" ? b.TN_QTY : (b.TN_QTY == 0 ? 0 : GetNumerator(b.TN_QTY, a.FQty, true))),//20250108
|
FNumerator = (b.IS_BACK == "Y" ? b.TN_QTY : (b.TN_QTY == 0 ? 0 : GetNumerator(b.TN_QTY, a.FQty, true))),//20250108
|
||||||
FDenominator = (b.IS_BACK == "Y" ? a.FQty : (b.TN_QTY == 0 ? 1 : GetNumerator(b.TN_QTY, a.FQty, true))),//20250108
|
FDenominator = (b.IS_BACK == "Y" ? a.FQty : (b.TN_QTY == 0 ? 1 : GetNumerator(b.TN_QTY, a.FQty, false))),//20250108
|
||||||
//FUseRate= b.TN_QTY==0 ? 0 : 100,
|
//FUseRate= b.TN_QTY==0 ? 0 : 100,
|
||||||
FPositionNO = b.POINT_STR,
|
FPositionNO = b.POINT_STR,
|
||||||
FNeedQty2 = b.IS_BACK == "Y" ? 0 : b.TN_QTY,
|
FNeedQty2 = b.IS_BACK == "Y" ? 0 : b.TN_QTY,
|
||||||
@@ -10079,19 +10078,26 @@ namespace RB_MES_API.Controllers
|
|||||||
select new
|
select new
|
||||||
{
|
{
|
||||||
FReplaceGroup = b.Key.FReplaceGroup,
|
FReplaceGroup = b.Key.FReplaceGroup,
|
||||||
TotalQty = b.Sum(s => s.FMustQty)
|
TotalQty = b.Sum(s => s.FMustQty),
|
||||||
|
TotalCount = b.Count()
|
||||||
}).ToList().Distinct();
|
}).ToList().Distinct();
|
||||||
|
|
||||||
foreach (var item in groupid)
|
foreach (var item in groupid)
|
||||||
{
|
{
|
||||||
int id = item.FReplaceGroup;
|
int id = item.FReplaceGroup;
|
||||||
|
|
||||||
decimal itemqty = item.TotalQty;
|
decimal itemqty = item.TotalQty;
|
||||||
|
int itemCount = item.TotalCount;
|
||||||
|
|
||||||
List<PRD_PPBOMChange.Entity> itemgroup = entities.Where(s => s.FReplaceGroup == id && s.FChangeType != "2").ToList();
|
List<PRD_PPBOMChange.Entity> itemgroup = entities.Where(s => s.FReplaceGroup == id && s.FChangeType != "2").ToList();
|
||||||
|
|
||||||
var count = itemgroup.Count();
|
var count = itemgroup.Count();
|
||||||
var index = 0;
|
var index = 0;
|
||||||
foreach (PRD_PPBOMChange.Entity entity in itemgroup)
|
foreach (PRD_PPBOMChange.Entity entity in itemgroup)
|
||||||
{
|
{
|
||||||
|
if (itemCount > 1)
|
||||||
|
entity.FReplaceGroupNumerator = itemqty;
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
if (itemqty != 0)
|
if (itemqty != 0)
|
||||||
{
|
{
|
||||||
@@ -10168,6 +10174,10 @@ namespace RB_MES_API.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 合并用料清单的重算使用比例
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entities"></param>
|
||||||
private void UpdateUseRate(List<PRD_PPBOMMerge.MergeEntity> entities)
|
private void UpdateUseRate(List<PRD_PPBOMMerge.MergeEntity> entities)
|
||||||
{
|
{
|
||||||
var groupid = (from a in entities.Where(s => s.FChangeType != "2")
|
var groupid = (from a in entities.Where(s => s.FChangeType != "2")
|
||||||
@@ -10178,19 +10188,25 @@ namespace RB_MES_API.Controllers
|
|||||||
select new
|
select new
|
||||||
{
|
{
|
||||||
FReplaceGroup = b.Key.FReplaceGroup,
|
FReplaceGroup = b.Key.FReplaceGroup,
|
||||||
TotalQty = b.Sum(s => s.FMustQty)
|
TotalQty = b.Sum(s => s.FMustQty),
|
||||||
|
TotalCount = b.Count()
|
||||||
}).ToList().Distinct();
|
}).ToList().Distinct();
|
||||||
|
|
||||||
foreach (var item in groupid)
|
foreach (var item in groupid)
|
||||||
{
|
{
|
||||||
int id = item.FReplaceGroup;
|
int id = item.FReplaceGroup;
|
||||||
decimal itemqty = item.TotalQty;
|
decimal itemqty = item.TotalQty;
|
||||||
|
int itemCount = item.TotalCount;
|
||||||
|
|
||||||
List<PRD_PPBOMMerge.MergeEntity> itemgroup = entities.Where(s => s.FReplaceGroup == id && s.FChangeType != "2").ToList();
|
List<PRD_PPBOMMerge.MergeEntity> itemgroup = entities.Where(s => s.FReplaceGroup == id && s.FChangeType != "2").ToList();
|
||||||
|
|
||||||
var count = itemgroup.Count();
|
var count = itemgroup.Count();
|
||||||
var index = 0;
|
var index = 0;
|
||||||
foreach (var entity in itemgroup)
|
foreach (var entity in itemgroup)
|
||||||
{
|
{
|
||||||
|
if (itemCount > 1)
|
||||||
|
entity.FReplaceGroupNumerator = itemqty;
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
if (itemqty != 0)
|
if (itemqty != 0)
|
||||||
{
|
{
|
||||||
@@ -10342,6 +10358,7 @@ namespace RB_MES_API.Controllers
|
|||||||
FIssueType = a.IS_BACK == "Y" ? 0 : 1,
|
FIssueType = a.IS_BACK == "Y" ? 0 : 1,
|
||||||
FPPBOMEntrySeq = int.Parse(a.SEQ.ToString()) //对应MES提供的JSON中的唯一项
|
FPPBOMEntrySeq = int.Parse(a.SEQ.ToString()) //对应MES提供的JSON中的唯一项
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
return entities;
|
return entities;
|
||||||
}
|
}
|
||||||
private List<SUB_PPBOMChange.Entity> GetSUBEntitiesForNew(List<PPBOMEntryStr> ppbomlist, List<WPLAN_MN_CHANGE> newpbom
|
private List<SUB_PPBOMChange.Entity> GetSUBEntitiesForNew(List<PPBOMEntryStr> ppbomlist, List<WPLAN_MN_CHANGE> newpbom
|
||||||
@@ -10485,6 +10502,7 @@ namespace RB_MES_API.Controllers
|
|||||||
if (newentities.Count != 0)
|
if (newentities.Count != 0)
|
||||||
{
|
{
|
||||||
//var changees = newentities.Where(s => int.Parse(s.FChangeType) != 3);
|
//var changees = newentities.Where(s => int.Parse(s.FChangeType) != 3);
|
||||||
|
int idx = 0;
|
||||||
foreach (PRD_PPBOMChange.Entity entity in newentities)
|
foreach (PRD_PPBOMChange.Entity entity in newentities)
|
||||||
{
|
{
|
||||||
//从源单信息中把主料找出来
|
//从源单信息中把主料找出来
|
||||||
@@ -10496,25 +10514,16 @@ namespace RB_MES_API.Controllers
|
|||||||
var mainrow = ppbom.Where(s => s.FMainMaterial == mainitem && s.FMaterial == mainitem && s.FMaterialType == 1);
|
var mainrow = ppbom.Where(s => s.FMainMaterial == mainitem && s.FMaterial == mainitem && s.FMaterialType == 1);
|
||||||
if (mainrow.Any())
|
if (mainrow.Any())
|
||||||
{
|
{
|
||||||
entity.FReplacePriority = ppbomchanges.Count(w =>
|
entity.FReplacePriority = ppbomchanges.Count(w => w.FReplaceGroup == mainrow.FirstOrDefault().FReplaceGroup && (w.FChangeType == "3" || w.FChangeType == "1"));
|
||||||
w.FReplaceGroup == mainrow.FirstOrDefault().FReplaceGroup
|
|
||||||
&& (w.FChangeType == "3" || w.FChangeType == "1")
|
|
||||||
);
|
|
||||||
entity.FParentRowId = mainrow.FirstOrDefault().FRowId;
|
entity.FParentRowId = mainrow.FirstOrDefault().FRowId;
|
||||||
entity.FReplaceGroup = mainrow.FirstOrDefault().FReplaceGroup; //实际上是多余的,提交给ERP之后,会被覆盖...
|
entity.FReplaceGroup = mainrow.FirstOrDefault().FReplaceGroup; //实际上是多余的,提交给ERP之后,会被覆盖...
|
||||||
}
|
}
|
||||||
////entity.FSeq = maxseq; //对于新的子项,这里的赋值没起作用...
|
else
|
||||||
//WPLAN_MN_CHANGE _CHANGE = newpbom.Find(s=>s.MTRL_ID==entity.FMaterialID2.FirstOrDefault().Value && s.SEQ==entity.FPPBOMEntrySeq);
|
{
|
||||||
//string parrowid = string.Empty;
|
entity.FReplaceGroup = 9999 - idx;
|
||||||
//int groupno = GetChangeReplaceGroup(entity, entity.FMaterialID2.FirstOrDefault().Value, _CHANGE, ref reason, ref parrowid);
|
entity.FSeq = idx++;
|
||||||
//if (!string.IsNullOrWhiteSpace(reason)) { break; }
|
}
|
||||||
////if (groupno == 0 && entity.FMaterialType == "3")
|
//entity.FSeq = maxseq; //对于新的子项,这里的赋值没起作用...
|
||||||
////{
|
|
||||||
//// reason = "替代子项的同时主料也得变更";
|
|
||||||
//// return null;
|
|
||||||
////}
|
|
||||||
//entity.FReplaceGroup = groupno;
|
|
||||||
//entity.FParentRowId = parrowid;
|
|
||||||
//注意:FPPBOMEntrySeq在此之前属于主料的SEQ,用完既应该恢复为0
|
//注意:FPPBOMEntrySeq在此之前属于主料的SEQ,用完既应该恢复为0
|
||||||
entity.FPPBOMEntrySeq = 0;
|
entity.FPPBOMEntrySeq = 0;
|
||||||
}
|
}
|
||||||
@@ -10526,6 +10535,16 @@ namespace RB_MES_API.Controllers
|
|||||||
if (string.IsNullOrEmpty(reason))
|
if (string.IsNullOrEmpty(reason))
|
||||||
{
|
{
|
||||||
UpdateUseRate(ppbomchanges);
|
UpdateUseRate(ppbomchanges);
|
||||||
|
|
||||||
|
ppbomchanges.ForEach(data =>
|
||||||
|
{
|
||||||
|
if (data.FSeq + data.FReplaceGroup == 9999)
|
||||||
|
{
|
||||||
|
data.FSeq = 0;
|
||||||
|
data.FReplaceGroup = 0;
|
||||||
|
}
|
||||||
|
}); //提交前把SEQ清0,让系统自动生成
|
||||||
|
|
||||||
var hp = ppbomchanges.OrderBy(s => s.FReplaceGroup).ThenBy(s => s.FReplaceType).ToList();
|
var hp = ppbomchanges.OrderBy(s => s.FReplaceGroup).ThenBy(s => s.FReplaceType).ToList();
|
||||||
change.FEntity.AddRange(hp);
|
change.FEntity.AddRange(hp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -250,6 +250,8 @@ namespace RB_MES_API.Models.Cloud
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int FReplaceGroup { get; set; }
|
public int FReplaceGroup { get; set; }
|
||||||
|
|
||||||
|
public decimal FReplaceGroupNumerator { get; set; }
|
||||||
|
|
||||||
public List<Entity_Link> FEntity_Link { get; set; }
|
public List<Entity_Link> FEntity_Link { get; set; }
|
||||||
public class Entity_Link
|
public class Entity_Link
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user