|
|
|
|
@ -32,8 +32,8 @@ namespace FactorySystemBll
|
|
|
|
|
* 此处的viewType来自TBasicCode中FType=33时,的FRemark字段
|
|
|
|
|
* **/
|
|
|
|
|
List<Dictionary<string, object>> viewList = new List<Dictionary<string, object>>();
|
|
|
|
|
|
|
|
|
|
if (viewType == 10)
|
|
|
|
|
List<int> viewTypes=new List<int> { 2,3,4,5,10};
|
|
|
|
|
if (viewTypes.Contains(viewType))
|
|
|
|
|
{
|
|
|
|
|
viewList = db.Queryable<TFS_ViewMaterial, TFS_Material>((a, b) =>
|
|
|
|
|
new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID))
|
|
|
|
|
@ -401,6 +401,120 @@ namespace FactorySystemBll
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 试验号变更-保存视图编辑内容3
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int UpdateBatchById3(List<Dictionary<string, object>> viewList, List<Dictionary<string, object>> materialList,
|
|
|
|
|
List<Dictionary<string, object>> infoList, int teamId, int viewType, int userId)
|
|
|
|
|
{
|
|
|
|
|
int result = 0;
|
|
|
|
|
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
|
|
|
|
|
if (viewList != null && viewList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
string sqlWhere = string.Format("FViewType={0} and FTeamID={1}", viewType, teamId);
|
|
|
|
|
if (viewType == 10)
|
|
|
|
|
{
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
if (materialList != null && materialList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < materialList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
materialList[i]["FID"] = materialList[i]["FMaterialID"];
|
|
|
|
|
materialList[i].Remove("FMaterialID");
|
|
|
|
|
if (materialList[i].TryGetValue("FK3Code", out object k3Code))
|
|
|
|
|
{
|
|
|
|
|
if (materialList[i].ContainsKey("FK3ShortCode"))
|
|
|
|
|
{
|
|
|
|
|
materialList[i]["FK3ShortCode"] = k3Code.ToString().Split('.').Last();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
materialList[i].Add("FK3ShortCode", k3Code.ToString().Split('.').Last());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
result += db.Updateable(materialList).AS("TFS_Material").WhereColumns("FID").ExecuteCommand();
|
|
|
|
|
result += UnionModifyData(materialList, "TFS_Material", teamId, db);
|
|
|
|
|
}
|
|
|
|
|
if (infoList != null && infoList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < infoList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
infoList[i]["FDataID"] = infoList[i]["FMaterialID"];
|
|
|
|
|
infoList[i].Remove("FMaterialID");
|
|
|
|
|
infoList[i].Add("FType", 2);
|
|
|
|
|
}
|
|
|
|
|
result += db.Updateable(infoList).AS("TFS_MaterialInfo").WhereColumns("FType", "FDataID").ExecuteCommand();
|
|
|
|
|
result += UnionModifyData(infoList, "TFS_MaterialInfo", teamId, db, "FDataID");
|
|
|
|
|
}
|
|
|
|
|
//result += CheckTaskComplete2(db, teamId, viewType, userId);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 试验号变更-
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="db"></param>
|
|
|
|
|
/// <param name="teamId"></param>
|
|
|
|
|
/// <param name="taskType"></param>
|
|
|
|
|
/// <param name="userId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private int CheckTaskComplete2(SqlSugarClient db, int teamId, int taskType, int userId)
|
|
|
|
|
{
|
|
|
|
|
int result = 0;
|
|
|
|
|
//List<string> fields = db.Queryable<TBasicCode, TFS_ViewFieldInfo>((a, b) => new JoinQueryInfos(JoinType.Left, a.F2 == b.FID.ToString()))
|
|
|
|
|
// .Where((a, b) => a.FType == 40 && b.FType == 1 && a.F1 == taskType.ToString()).Select((a, b) => b.FField).ToList();
|
|
|
|
|
//string okSql = string.Format("select count(1) from TFS_ViewMaterial where FTeamID={0} and FViewType={1} and(", teamId, taskType);
|
|
|
|
|
//okSql += string.Join("='' or ", fields).Replace("TFS_ViewMaterial.", "") + "='')";
|
|
|
|
|
//string okResult = db.Ado.GetString(okSql);
|
|
|
|
|
string okResult = "";
|
|
|
|
|
if (string.IsNullOrEmpty(okResult) || okResult == "0")
|
|
|
|
|
{
|
|
|
|
|
if (taskType != 10)
|
|
|
|
|
{
|
|
|
|
|
//视图类型+2是事项,除了包材
|
|
|
|
|
taskType += 2;
|
|
|
|
|
if (taskType >= (int)Constant.TaskType.组编号申请) taskType = (int)Constant.TaskType.新包材视图;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
taskType = 15;
|
|
|
|
|
}
|
|
|
|
|
string taskSql = "";
|
|
|
|
|
|
|
|
|
|
int proType = -2; string appSql = " and(select count(1) from TFS_HalfMaterialTask t where t.FTeamID=a.FTeamID and t.FType in({0}) and t.FState!=2)=0";
|
|
|
|
|
switch (taskType)
|
|
|
|
|
{
|
|
|
|
|
case 3://成品视图事项:3→成品视图:2
|
|
|
|
|
proType = 2;
|
|
|
|
|
break;
|
|
|
|
|
case 4://新半成品视图:4
|
|
|
|
|
case 5://新中间品视图:5
|
|
|
|
|
case 6://新香基视图:6→新半成品/中间品/香基:3
|
|
|
|
|
proType = 3;
|
|
|
|
|
appSql = string.Format(appSql, "4,5,6");
|
|
|
|
|
break;
|
|
|
|
|
case 7://新原料视图:7→新原料视图:4
|
|
|
|
|
proType = 4;
|
|
|
|
|
break;
|
|
|
|
|
case 15://物料分类视图:15→物料分类视图:0
|
|
|
|
|
proType = 0;
|
|
|
|
|
break;
|
|
|
|
|
case 11://新包材视图:7→新原料视图:8
|
|
|
|
|
proType = 8;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (taskType == 15 || proType > 0) taskSql = BaseBll.GetProcessSql2(teamId, proType, "F3", 2, string.Format(appSql, taskType));
|
|
|
|
|
taskSql = BaseBll.GetTaskSql2(-1, 2, teamId, taskType, -1, string.Format("','+a.FUserID+',' like ',%{0}%,'", userId)) + taskSql;
|
|
|
|
|
result += db.Ado.ExecuteCommand(taskSql);
|
|
|
|
|
HalfMaterialTeamworkBll.ChangeTeamProcess(teamId);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 联合修改
|
|
|
|
|
|