20230727 修改协同路线中,物料视图的查询逻辑

增加对视图表中FTeamType的判断,当FTeamType = 0时,时协同路线
master
Leo 2 years ago
parent d12920f96d
commit f182a95ae1

@ -143,11 +143,21 @@ namespace FactorySystemApi.Controllers
List<TFS_Material> materialList = TeamworkBll.CheckMaterialListByTest(teamwork.FFormulaTestCode, teamwork.FVersionCode); List<TFS_Material> materialList = TeamworkBll.CheckMaterialListByTest(teamwork.FFormulaTestCode, teamwork.FVersionCode);
if (materialList.Count == 0) { if (materialList.Count == 0) {
TeamworkBll.CreateProductView(teamwork, null, user.FID); TeamworkBll.CreateProductView(teamwork, null, user.FID);
// 20230726 不论新增或暂存,都在创建协同时生成成品事项
//BaseBll.CreateTaskData(teamwork.FID, user.FID, "3", teamwork.FCreateFactoryID + "," + teamwork.FProdFactoryID);
//BaseBll.UpdateTeamProcess(teamwork.FID, (int)Constant.ProcessType.成品视图, 2, 1);
//开始BOM下载 //开始BOM下载
DockGetBomData(teamwork.FID, user.FID); DockGetBomData(teamwork.FID, user.FID);
} }
else { else {
TeamworkBll.CreateProductView(teamwork, materialList, user.FID); TeamworkBll.CreateProductView(teamwork, materialList, user.FID);
// 20230726 不论新增或暂存,都在创建协同时生成成品事项
//BaseBll.CreateTaskData(teamwork.FID, user.FID, "3", teamwork.FCreateFactoryID + "," + teamwork.FProdFactoryID);
//BaseBll.UpdateTeamProcess(teamwork.FID, (int)Constant.ProcessType.成品视图, 2, 1);
TeamworkBll.HasMaterialTestCode(teamwork); TeamworkBll.HasMaterialTestCode(teamwork);
/** /**
@ -178,6 +188,12 @@ namespace FactorySystemApi.Controllers
} }
else else
{ {
// 20230726 不论新增或暂存,都在创建协同时生成成品事项
//TFS_FTeamwork teamwork = BaseBll.GetTempModel<TFS_FTeamwork>(teamId);
//TeamworkBll.CreateProductView(teamwork, null, user.FID);
//BaseBll.CreateTaskData(teamwork.FID, user.FID, "3", teamwork.FCreateFactoryID + "," + teamwork.FProdFactoryID);
//BaseBll.UpdateTeamProcess(teamwork.FID, (int)Constant.ProcessType.成品视图, 2, 1);
BaseBll.CreateTaskData(teamId, user.FID, ((int)Constant.TaskType.).ToString()); BaseBll.CreateTaskData(teamId, user.FID, ((int)Constant.TaskType.).ToString());
BaseBll.UpdateTeamProcess(teamId, (int)Constant.ProcessType., 1, 1); BaseBll.UpdateTeamProcess(teamId, (int)Constant.ProcessType., 1, 1);
} }
@ -304,16 +320,16 @@ namespace FactorySystemApi.Controllers
savePath += Constant.TeamViewType..ToString(); savePath += Constant.TeamViewType..ToString();
//原始配方 //原始配方
whereSql = string.Format(@"dbo.StrExistInStr(TFS_ViewMaterial.FMaterialID,(select FMaterialFormulaIDs from TFS_FTeamwork where FID={0}))>0 whereSql = string.Format(@"dbo.StrExistInStr(TFS_ViewMaterial.FMaterialID,(select FMaterialFormulaIDs from TFS_FTeamwork where FID={0}))>0
and TFS_ViewMaterial.FFactoryID=(select FProdFactoryID from TFS_FTeamwork where FID={0})", inParam["FTeamID"]); and TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FFactoryID=(select FProdFactoryID from TFS_FTeamwork where FID={0})", inParam["FTeamID"]);
//生产、计划配方 //生产、计划配方
joinSql = string.Format(@"(dbo.StrExistInStr(TFS_ViewMaterial.FMaterialID,(select FMaterialFormulaIDs from TFS_FTeamwork where FID={0}))>0 joinSql = string.Format(@"(dbo.StrExistInStr(TFS_ViewMaterial.FMaterialID,(select FMaterialFormulaIDs from TFS_FTeamwork where FID={0}))>0
and TFS_Material.FSuccedaneumID<1)and TFS_ViewMaterial.FFactoryID=(select FProdFactoryID from TFS_FTeamwork where FID={0})", and TFS_Material.FSuccedaneumID<1) and TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FFactoryID=(select FProdFactoryID from TFS_FTeamwork where FID={0})",
inParam["FTeamID"]); inParam["FTeamID"]);
break; break;
case (int)Constant.TeamViewType.线: case (int)Constant.TeamViewType.线:
savePath += Constant.TeamViewType.线.ToString(); savePath += Constant.TeamViewType.线.ToString();
//只要生产工厂 //只要生产工厂
whereSql += string.Format(" and TFS_ViewMaterial.FFactoryID in(select FID from TFS_Factory where FType={0})", (int)Constant.FactoryType.); whereSql += string.Format(" and TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FFactoryID in(select FID from TFS_Factory where FType={0})", (int)Constant.FactoryType.);
//视图类型 //视图类型
List<int> tempInt3_1 = new List<int> List<int> tempInt3_1 = new List<int>
{ {
@ -322,12 +338,12 @@ namespace FactorySystemApi.Controllers
(int)Constant.ViewType., (int)Constant.ViewType.,
(int)Constant.ViewType. (int)Constant.ViewType.
}; };
whereSql += string.Format(" and TFS_ViewMaterial.FViewType in({0})", string.Join(",", tempInt3_1)); whereSql += string.Format(" and TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FViewType in({0})", string.Join(",", tempInt3_1));
break; break;
case (int)Constant.TeamViewType.: case (int)Constant.TeamViewType.:
savePath += Constant.TeamViewType..ToString(); savePath += Constant.TeamViewType..ToString();
//只要生产工厂 //只要生产工厂
whereSql += string.Format(" and TFS_ViewMaterial.FFactoryID in(select FID from TFS_Factory where FType={0})", (int)Constant.FactoryType.); whereSql += string.Format(" and TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FFactoryID in(select FID from TFS_Factory where FType={0})", (int)Constant.FactoryType.);
//视图类型 //视图类型
List<int> tempInt4_1 = new List<int> List<int> tempInt4_1 = new List<int>
{ {
@ -336,22 +352,22 @@ namespace FactorySystemApi.Controllers
(int)Constant.ViewType., (int)Constant.ViewType.,
(int)Constant.ViewType. (int)Constant.ViewType.
}; };
whereSql += string.Format(" and TFS_ViewMaterial.FViewType in({0})", string.Join(",", tempInt4_1)); whereSql += string.Format(" and TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FViewType in({0})", string.Join(",", tempInt4_1));
break; break;
case (int)Constant.TeamViewType.BOM: case (int)Constant.TeamViewType.BOM:
savePath += Constant.TeamViewType.BOM.ToString(); savePath += Constant.TeamViewType.BOM.ToString();
//一级半成品、包材→无替代料的 //一级半成品、包材→无替代料的
whereSql = string.Format(@"(dbo.StrExistInStr(TFS_ViewMaterial.FMaterialID,(select FMaterialHalfIDs from TFS_FTeamwork where FID={0}))>0 or whereSql = string.Format(@"(dbo.StrExistInStr(TFS_ViewMaterial.FMaterialID,(select FMaterialHalfIDs from TFS_FTeamwork where FID={0}))>0 or (
TFS_ViewMaterial.FMaterialID in(select FMaterialID from TFS_PackageChild where FTeamID={0} or TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FMaterialID in(select FMaterialID from TFS_PackageChild where FTeamID={0}) or
FPackageID=(select FPackID from TFS_FTeamwork where FID={0}))) FPackageID=(select FPackID from TFS_FTeamwork where FID={0})))
", inParam["FTeamID"]); ", inParam["FTeamID"]);
//只要生产工厂 //只要生产工厂
whereSql += string.Format(" and TFS_ViewMaterial.FFactoryID=(select FProdFactoryID from TFS_FTeamwork where FID={0})", inParam["FTeamID"]); whereSql += string.Format(" and TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FFactoryID=(select FProdFactoryID from TFS_FTeamwork where FID={0})", inParam["FTeamID"]);
break; break;
case (int)Constant.TeamViewType.: case (int)Constant.TeamViewType.:
default: default:
savePath += Constant.TeamViewType..ToString(); savePath += Constant.TeamViewType..ToString();
whereSql += " and TFS_ViewMaterial.FMaterialID>0"; whereSql += " and TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FMaterialID>0";
break; break;
} }
savePath += ".xlsx"; savePath += ".xlsx";
@ -621,10 +637,6 @@ namespace FactorySystemApi.Controllers
return result; return result;
} }
/// <summary> /// <summary>
/// 递归梳理BOM /// 递归梳理BOM
/// </summary> /// </summary>

@ -37,24 +37,26 @@ namespace FactorySystemBll
{ {
viewList = db.Queryable<TFS_ViewMaterial, TFS_Material>((a, b) => viewList = db.Queryable<TFS_ViewMaterial, TFS_Material>((a, b) =>
new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID)) new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID))
.Where((a, b) => a.FTeamID == teamId) .Where((a, b) => a.FTeamID == teamId)
//.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) .Where((a, b) => a.FTeamType == 0)
.WhereIF(currUser != null, (a, b) => currUser.FFactoryList.Contains(a.FFactoryID.ToString())) //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID)
.WhereIF(viewType > 0, (a, b) => a.FViewType == viewType) .WhereIF(currUser != null, (a, b) => currUser.FFactoryList.Contains(a.FFactoryID.ToString()))
.Select<object>("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse," + .WhereIF(viewType > 0, (a, b) => a.FViewType == viewType)
"b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield," + .Select<object>("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse," +
"b.FQualityTest1,b.FQualityTest2").ToDictionaryList(); "b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield," +
"b.FQualityTest1,b.FQualityTest2").ToDictionaryList();
} }
else if (viewType == 10) else if (viewType == 10)
{ {
viewList = db.Queryable<TFS_ViewMaterial, TFS_Material>((a, b) => viewList = db.Queryable<TFS_ViewMaterial, TFS_Material>((a, b) =>
new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID)) new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID))
.Where((a, b) => a.FTeamID == teamId) .Where((a, b) => a.FTeamID == teamId)
//.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) .Where((a, b) => a.FTeamType == 0)
.WhereIF(currUser != null, (a, b) => currUser.FFactoryList.Contains(a.FFactoryID.ToString())) //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID)
.Select<object>("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse," + .WhereIF(currUser != null, (a, b) => currUser.FFactoryList.Contains(a.FFactoryID.ToString()))
"b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield," + .Select<object>("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse," +
"b.FQualityTest1,b.FQualityTest2").ToDictionaryList(); "b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield," +
"b.FQualityTest1,b.FQualityTest2").ToDictionaryList();
TFS_FTeamwork teamWork = db.Queryable<TFS_FTeamwork>().Where(s => s.FID == teamId).First(); TFS_FTeamwork teamWork = db.Queryable<TFS_FTeamwork>().Where(s => s.FID == teamId).First();
TFS_PackageMain packAge = db.Queryable<TFS_PackageMain>().Where(s => s.FCode == teamWork.FPackCode).First(); TFS_PackageMain packAge = db.Queryable<TFS_PackageMain>().Where(s => s.FCode == teamWork.FPackCode).First();
@ -81,11 +83,12 @@ namespace FactorySystemBll
{ {
viewList = db.Queryable<TFS_ViewMaterial, TFS_Material>((a, b) => viewList = db.Queryable<TFS_ViewMaterial, TFS_Material>((a, b) =>
new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID)) new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID))
.Where((a, b) => a.FTeamID == teamId) .Where((a, b) => a.FTeamID == teamId)
//.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) .Where((a, b) => a.FTeamType == 0)
.WhereIF(currUser != null, (a, b) => currUser.FFactoryList.Contains(a.FFactoryID.ToString())) //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID)
.WhereIF(viewType > 0, (a, b) => a.FViewType == 1) .WhereIF(currUser != null, (a, b) => currUser.FFactoryList.Contains(a.FFactoryID.ToString()))
.Select<object>("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse," + .WhereIF(viewType > 0, (a, b) => a.FViewType == 1)
.Select<object>("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse," +
"b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield," + "b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield," +
"b.FQualityTest1,b.FQualityTest2").ToDictionaryList(); "b.FQualityTest1,b.FQualityTest2").ToDictionaryList();
List<TFS_MaterialInfo> Minfo = GetMaterialInfoList(viewList.GroupBy(s => s["FMaterialID"]).Select(s => int.Parse(s.Key.ToString())).ToList(), "", "", currUserId); List<TFS_MaterialInfo> Minfo = GetMaterialInfoList(viewList.GroupBy(s => s["FMaterialID"]).Select(s => int.Parse(s.Key.ToString())).ToList(), "", "", currUserId);
@ -281,6 +284,7 @@ namespace FactorySystemBll
List<Dictionary<string, object>> viewList = db.Queryable<TFS_ViewMaterial, TFS_Material>((a, b) => List<Dictionary<string, object>> viewList = db.Queryable<TFS_ViewMaterial, TFS_Material>((a, b) =>
new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID)) new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID))
.Where((a, b) => a.FTeamID == teamId) .Where((a, b) => a.FTeamID == teamId)
.Where((a, b) => a.FTeamType == 0)
//.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID)
.Select<object>("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode").ToDictionaryList(); .Select<object>("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode").ToDictionaryList();
@ -294,10 +298,11 @@ namespace FactorySystemBll
{ {
List<Dictionary<string, object>> viewList1 = db.Queryable<TFS_ViewMaterial, TFS_Material>((a, b) => List<Dictionary<string, object>> viewList1 = db.Queryable<TFS_ViewMaterial, TFS_Material>((a, b) =>
new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID)) new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID))
.Where((a, b) => a.FTeamID == teamId) .Where((a, b) => a.FTeamID == teamId)
.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) .Where((a, b) => a.FTeamType == 0)
.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID)
.WhereIF(viewType > 0, (a, b) => a.FViewType == 2) .WhereIF(viewType > 0, (a, b) => a.FViewType == 2)
.Select<object>("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode").ToDictionaryList(); .Select<object>("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode").ToDictionaryList();
List<TFS_MaterialInfo> Minfo = GetMaterialInfoList(viewList1.GroupBy(s => s["FMaterialID"]).Select(s => int.Parse(s.Key.ToString())).ToList(), "", "", currUserId); List<TFS_MaterialInfo> Minfo = GetMaterialInfoList(viewList1.GroupBy(s => s["FMaterialID"]).Select(s => int.Parse(s.Key.ToString())).ToList(), "", "", currUserId);
if (Minfo.Count > 0) if (Minfo.Count > 0)
{ {

Loading…
Cancel
Save