|
|
|
|
@ -112,6 +112,113 @@ namespace FactorySystemBll
|
|
|
|
|
return viewList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据协同ID获取物料视图
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<Dictionary<string, object>> GetHalfMaterialListByTeamId(int teamId, int viewType, int currUserId, out List<int> materialId, out string FGuaranteePeriod, out string FStorageConditions, bool byFactory = true)
|
|
|
|
|
{
|
|
|
|
|
TUser currUser = null;
|
|
|
|
|
FGuaranteePeriod = "";
|
|
|
|
|
FStorageConditions = "";
|
|
|
|
|
if (byFactory == true) currUser = BaseBll.GetTempModel<TUser>(currUserId, "FFactoryID");
|
|
|
|
|
var db = AppSettingsHelper.GetSqlSugar();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 20230414 需求变更
|
|
|
|
|
* 新增物料分类视图获取逻辑
|
|
|
|
|
* 物料分类的viewType=10,此时,取所有下载的bomList中的视图,a.FViewType in (2,3,4,5)
|
|
|
|
|
* 分别对应半成品视图、中间品视图、香基视图、原料视图
|
|
|
|
|
* 此处的viewType来自TBasicCode中FType=33时,的FRemark字段
|
|
|
|
|
* **/
|
|
|
|
|
List<Dictionary<string, object>> viewList = new List<Dictionary<string, object>>();
|
|
|
|
|
List<int> viewTypes = new List<int> { 2, 3, 4, 5 };
|
|
|
|
|
if (viewTypes.Contains(viewType))
|
|
|
|
|
{
|
|
|
|
|
viewList = db.Queryable<TFS_ViewMaterial, TFS_Material>((a, b) =>
|
|
|
|
|
new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID))
|
|
|
|
|
.Where((a, b) => a.FHalfMaterialTeamID == teamId)
|
|
|
|
|
.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID)
|
|
|
|
|
.WhereIF(viewType > 0, (a, b) => a.FViewType == viewType)
|
|
|
|
|
.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.FQualityTest1,b.FQualityTest2").ToDictionaryList();
|
|
|
|
|
}
|
|
|
|
|
else if (viewType == 10)
|
|
|
|
|
{
|
|
|
|
|
viewList = db.Queryable<TFS_ViewMaterial, TFS_Material>((a, b) =>
|
|
|
|
|
new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID))
|
|
|
|
|
.Where((a, b) => a.FTeamID == teamId)
|
|
|
|
|
.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," +
|
|
|
|
|
"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_HalfMaterialFTeamwork teamWork = db.Queryable<TFS_HalfMaterialFTeamwork>().Where(s => s.FID == teamId).First();
|
|
|
|
|
TFS_PackageMain packAge = db.Queryable<TFS_PackageMain>().Where(s => s.FCode == teamWork.FPackCode).First();
|
|
|
|
|
|
|
|
|
|
if (packAge != null)
|
|
|
|
|
{
|
|
|
|
|
viewList[0].Remove("FBaseGrossWeight");
|
|
|
|
|
viewList[0].Add("FBaseGrossWeight", packAge.FGrossWeight);
|
|
|
|
|
viewList[0].Remove("FBaseNetWeight");
|
|
|
|
|
viewList[0].Add("FBaseNetWeight", packAge.FNetWeight);
|
|
|
|
|
viewList[0].Remove("FBaseSpecification");
|
|
|
|
|
viewList[0].Add("FBaseSpecification", packAge.FSpecs);
|
|
|
|
|
viewList[0].Add("HalfCode", teamWork.FMaterialHalfIDs);
|
|
|
|
|
}
|
|
|
|
|
var FBaseMaterialDesc = viewList.GroupBy(s => s["FBaseMaterialDesc"]).Select(s => s.Key).ToList();
|
|
|
|
|
|
|
|
|
|
if (FBaseMaterialDesc.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
viewList[0].Add("HalfDesc", FBaseMaterialDesc[0]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (viewType == 1)
|
|
|
|
|
{
|
|
|
|
|
viewList = db.Queryable<TFS_ViewMaterial, TFS_Material>((a, b) =>
|
|
|
|
|
new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID))
|
|
|
|
|
.Where((a, b) => a.FHalfMaterialTeamID == teamId)
|
|
|
|
|
.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID)
|
|
|
|
|
.WhereIF(viewType > 0, (a, b) => a.FViewType == 2)
|
|
|
|
|
.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.FQualityTest1,b.FQualityTest2").ToDictionaryList();
|
|
|
|
|
List<TFS_MaterialInfo> Minfo = GetMaterialInfoList(viewList.GroupBy(s => s["FMaterialID"]).Select(s => int.Parse(s.Key.ToString())).ToList(), "", "", currUserId);
|
|
|
|
|
if (Minfo.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
FGuaranteePeriod = Minfo[0].FGuaranteePeriod;
|
|
|
|
|
FStorageConditions = Minfo[0].FStorageConditions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TFS_HalfMaterialFTeamwork teamWork = db.Queryable<TFS_HalfMaterialFTeamwork>().Where(s => s.FID == teamId).First();
|
|
|
|
|
TFS_PackageMain packAge = db.Queryable<TFS_PackageMain>().Where(s => s.FCode == teamWork.FPackCode).First();
|
|
|
|
|
|
|
|
|
|
if (packAge != null)
|
|
|
|
|
{
|
|
|
|
|
viewList[0].Remove("FBaseGrossWeight");
|
|
|
|
|
viewList[0].Add("FBaseGrossWeight", packAge.FGrossWeight);
|
|
|
|
|
viewList[0].Remove("FBaseNetWeight");
|
|
|
|
|
viewList[0].Add("FBaseNetWeight", packAge.FNetWeight);
|
|
|
|
|
viewList[0].Remove("FBaseSpecification");
|
|
|
|
|
viewList[0].Add("FBaseSpecification", packAge.FSpecs);
|
|
|
|
|
viewList[0].Add("HalfCode", teamWork.FMaterialHalfIDs);
|
|
|
|
|
}
|
|
|
|
|
var FBaseMaterialDesc = viewList.GroupBy(s => s["FBaseMaterialDesc"]).Select(s => s.Key).ToList();
|
|
|
|
|
|
|
|
|
|
if (FBaseMaterialDesc.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
viewList[0].Add("HalfDesc", FBaseMaterialDesc[0]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
materialId = viewList.GroupBy(s => s["FMaterialID"]).Select(s => int.Parse(s.Key.ToString())).ToList();
|
|
|
|
|
return viewList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据协同ID获取物料视图
|
|
|
|
|
/// </summary>
|
|
|
|
|
@ -547,7 +654,7 @@ namespace FactorySystemBll
|
|
|
|
|
sqlWhere = string.Format("FViewType in (2, 3, 4, 5) and FTeamID={1}", viewType, teamId);
|
|
|
|
|
}
|
|
|
|
|
result += db.Updateable(viewList).AS("TFS_ViewMaterial").WhereColumns("FMaterialID").Where(sqlWhere).ExecuteCommand();
|
|
|
|
|
result += UnionModifyData(viewList, "TFS_ViewMaterial", teamId, db, "FMaterialID");
|
|
|
|
|
result += HalfMaterialUnionModifyData(viewList, "TFS_ViewMaterial", teamId, db, "FMaterialID");
|
|
|
|
|
}
|
|
|
|
|
if (materialList != null && materialList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
@ -568,7 +675,7 @@ namespace FactorySystemBll
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
result += db.Updateable(materialList).AS("TFS_Material").WhereColumns("FID").ExecuteCommand();
|
|
|
|
|
result += UnionModifyData(materialList, "TFS_Material", teamId, db);
|
|
|
|
|
result += HalfMaterialUnionModifyData(materialList, "TFS_Material", teamId, db);
|
|
|
|
|
}
|
|
|
|
|
if (infoList != null && infoList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
@ -689,6 +796,48 @@ namespace FactorySystemBll
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int HalfMaterialUnionModifyData(List<Dictionary<string, object>> dataList, string srcTable, int teamId, SqlSugarClient db = null, string colName = "FID")
|
|
|
|
|
{
|
|
|
|
|
int result = 0;
|
|
|
|
|
if (dataList != null && dataList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
if (db == null) db = AppSettingsHelper.GetSqlSugar();
|
|
|
|
|
List<TFS_UnionModify> unionList = db.Queryable<TFS_UnionModify>().Where(s => s.FDeleted != 1 && s.FTableOriginal == srcTable).ToList();
|
|
|
|
|
if (unionList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
List<string> sqlList = new List<string>() { "update {0} set {0}.{1}={2}.{3} from {0} left join {2} on {4} where {2}.{5}='{6}' {7}" };
|
|
|
|
|
foreach (Dictionary<string, object> data in dataList)
|
|
|
|
|
{
|
|
|
|
|
foreach (TFS_UnionModify union in unionList)
|
|
|
|
|
{
|
|
|
|
|
if (data.TryGetValue(union.FColumnOriginal, out object srcVal))
|
|
|
|
|
{
|
|
|
|
|
string sqlWhere = "";
|
|
|
|
|
if (union.FTableTarget == "TFS_ViewMaterial" || union.FTableOriginal == "TFS_ViewMaterial")
|
|
|
|
|
{
|
|
|
|
|
sqlWhere = " and TFS_ViewMaterial.FHalfMaterialTeamID=" + teamId;
|
|
|
|
|
}
|
|
|
|
|
sqlList.Add(string.Format(sqlList[0], union.FTableTarget, union.FColumnTarget,
|
|
|
|
|
union.FTableOriginal, union.FColumnOriginal, union.FUnionCondition, colName,
|
|
|
|
|
data[colName], sqlWhere));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sqlList.RemoveAt(0);
|
|
|
|
|
if (sqlList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
string updateSql = string.Join(";", sqlList);
|
|
|
|
|
try { result = db.Ado.ExecuteCommand(updateSql); }
|
|
|
|
|
catch (Exception) { }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public object EexcSql(int tempId=0)
|
|
|
|
|
{
|
|
|
|
|
string sql = "";
|
|
|
|
|
|