diff --git a/FactorySystemApi/Controllers/HalfMaterialTeamworkController.cs b/FactorySystemApi/Controllers/HalfMaterialTeamworkController.cs
index b06fbc6..51531c2 100644
--- a/FactorySystemApi/Controllers/HalfMaterialTeamworkController.cs
+++ b/FactorySystemApi/Controllers/HalfMaterialTeamworkController.cs
@@ -89,7 +89,6 @@ namespace FactorySystemApi.Controllers
{
try
{
- ids = MaterialTeamworkBll.UpdateFormula(inParam["FTestCode"].ToString(), inParam["FNewTestCode"].ToString());
inParam.TryGetValue("FState", out object state);
if (null == state)
{
@@ -149,6 +148,10 @@ namespace FactorySystemApi.Controllers
//创建 TFS_FTeamwork
int teamId = BaseBll.InsertDataModel(inParam, "TFS_HalfMaterialFTeamwork");
+
+ ids = MaterialTeamworkBll.UpdateFormula(inParam["FTestCode"].ToString(), inParam["FNewTestCode"].ToString());
+
+
apiResult.Data = teamId;
if (teamId > 0)
{
@@ -178,8 +181,8 @@ namespace FactorySystemApi.Controllers
* 在创建各类事项前,先创建物料分类事项
* 此处创建各类事项流程中断,转移至物料分类事项提交后进行
* **/
- BaseBll.CreateTaskData2(teamwork.FID, user.FID, "15"); //新增物料分类事项
- BaseBll.UpdateTeamProcess2(teamId, (int)Constant.ProcessType.物料分类, 2, 1); // 更新物料分类流程
+ BaseBll.CreateTaskData2(teamwork.FID, user.FID, "1"); //新增物料分类事项
+ BaseBll.UpdateTeamProcess2(teamId, (int)Constant.HalfMaterialProcessType.物料分类, 2, 1); // 更新物料分类流程
////补充包材规格
//BaseBll.CreateTaskData(teamId, user.FID, "14");
@@ -611,8 +614,8 @@ namespace FactorySystemApi.Controllers
* 在创建各类事项前,先创建物料分类事项
* 此处创建各类事项流程中断,转移至物料分类事项提交后进行
* **/
- BaseBll.CreateTaskData2(teamwork.FID, userId, "15"); //新增物料分类事项
- BaseBll.UpdateTeamProcess2(teamId, (int)Constant.ProcessType.物料分类, 2, 1); // 更新物料分类流程
+ BaseBll.CreateTaskData2(teamwork.FID, userId, "2"); //新增物料分类事项
+ BaseBll.UpdateTeamProcess2(teamId, (int)Constant.HalfMaterialProcessType.物料分类, 2, 1); // 更新物料分类流程
////协同发起事项
//BaseBll.UpdateTeamProcess(teamwork.FID, (int)Constant.ProcessType.协同发起, 3, 2);
@@ -640,7 +643,7 @@ namespace FactorySystemApi.Controllers
else
{
OperateLogBll.Add(teamwork.FID, 2, "BOM下载失败,BOM数据为空", userId);
- BaseBll.CreateTaskData2(teamwork.FID, userId, ((int)Constant.TaskType.BOM下载).ToString());
+ BaseBll.CreateTaskData2(teamwork.FID, userId, ((int)Constant.HalfMaterialTask.BOM下载).ToString());
BaseBll.UpdateTeamProcess2(teamwork.FID, (int)Constant.ProcessType.协同发起, 2, 1);
HalfMaterialTeamworkBll.ChangeTeamProcess(teamwork.FID);
}
@@ -648,7 +651,7 @@ namespace FactorySystemApi.Controllers
catch (Exception ex)
{
OperateLogBll.Add(teamwork.FID, 2, "BOM下载失败,请稍后重试(对接)", userId);
- BaseBll.CreateTaskData2(teamwork.FID, userId, ((int)Constant.TaskType.BOM下载).ToString());
+ BaseBll.CreateTaskData2(teamwork.FID, userId, ((int)Constant.HalfMaterialTask.BOM下载).ToString());
BaseBll.UpdateTeamProcess(teamwork.FID, (int)Constant.ProcessType.协同发起, 2, 1);
ExceptionHelper.AddSystemJournal(Request, specifList[0], ex.Message, userId, "DockGetBomData");
}
diff --git a/FactorySystemApi/Controllers/ViewController.cs b/FactorySystemApi/Controllers/ViewController.cs
index b3d7c94..209429c 100644
--- a/FactorySystemApi/Controllers/ViewController.cs
+++ b/FactorySystemApi/Controllers/ViewController.cs
@@ -202,5 +202,65 @@ namespace FactorySystemApi.Controllers
}
}, apiResult, Request);
}
+
+
+ ///
+ /// 保存视图编辑的内容
+ ///
+ [HttpPost]
+ public ApiResult UpdateBatchById3(Dictionary inParam)
+ {
+ var apiResult = new ApiResult();
+ return ExceptionHelper.TryReturnException(() =>
+ {
+ if (Request.Properties["token"] is ApiAuthInfo user)
+ {
+ inParam.TryGetValue("TFS_ViewMaterial", out object viewObj);
+ inParam.TryGetValue("TFS_Material", out object materialObj);
+ inParam.TryGetValue("TFS_MaterialInfo", out object infoObj);
+ List> viewList = JsonConvert.DeserializeObject>>(JsonConvert.SerializeObject(viewObj));
+ List> materialList = JsonConvert.DeserializeObject>>(JsonConvert.SerializeObject(materialObj));
+ List> infoList = JsonConvert.DeserializeObject>>(JsonConvert.SerializeObject(infoObj));
+ int teamId = int.Parse(inParam["FTeamID"].ToString());
+ int viewType = int.Parse(inParam["FViewType"].ToString());
+ apiResult.Data = _viewBll.UpdateBatchById3(viewList, materialList, infoList, teamId, viewType, user.FID);
+
+ if (viewType == 10)
+ {
+ // 创建物料视图事项
+ TFS_HalfMaterialFTeamwork teamwork = BaseBll.GetTempModel(teamId);
+ List> vml = _viewBll.GetListByTeamId(teamId, viewType, user.FID, out List materialId, out string FGuaranteePeriod, out string FStorageConditions, true);
+ Dictionary hasNewView = new Dictionary();
+
+ if (vml != null)
+ {
+ foreach (Dictionary row in vml)
+ {
+ int materialType = (int)(long)row["FViewType"];
+ string factoryId = row["FFactoryID"].ToString();
+
+ if (materialType == 2 || materialType == 3 || materialType == 4 || materialType == 5)
+ {
+ if (hasNewView.ContainsKey(materialType))
+ {
+ hasNewView[materialType] = hasNewView[materialType] + factoryId + ",";
+ }
+ else
+ {
+ hasNewView.Add(materialType, factoryId + ",");
+ }
+ }
+ }
+ HalfMaterialTeamworkBll TeamworkBll = new HalfMaterialTeamworkBll();
+ TeamworkBll.CreateMaterialTask(hasNewView, teamwork, user.FID);
+ }
+ BaseBll.CreateTaskData2(teamId, user.FID, "3");
+
+ BaseBll.UpdateTeamProcess2(teamwork.FID, (int)Constant.HalfMaterialProcessType.物料分类, 3, 2);
+ BaseBll.UpdateTeamProcess2(teamwork.FID, (int)Constant.HalfMaterialProcessType.物料编辑, 2, 1);
+ }
+ }
+ }, apiResult, Request);
+ }
}
}
diff --git a/FactorySystemBll/BaseBll.cs b/FactorySystemBll/BaseBll.cs
index 1f36ae9..c214d0c 100644
--- a/FactorySystemBll/BaseBll.cs
+++ b/FactorySystemBll/BaseBll.cs
@@ -233,7 +233,7 @@ namespace FactorySystemBll
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
TBasicCode basicCode = db.Queryable().Where(s => s.FValue == proType.ToString()
- && s.FType == (int)Constant.BasicCode.流程类型).First();
+ && s.FType == (int)Constant.BasicCode.变更试验号流程).First();
if (basicCode != null)
{
Dictionary updateModel = new Dictionary();
@@ -488,7 +488,7 @@ namespace FactorySystemBll
List taskTypeList = taskTypes.Split(',').ToList();
- List basicCodeList = db.Queryable().Where(s => s.FType == (int)Constant.BasicCode.事项类型
+ List basicCodeList = db.Queryable().Where(s => s.FType == (int)Constant.BasicCode.变更试验号事项
&& s.FState == 1 && taskTypeList.Contains(s.FValue)).ToList();
PropertyInfo[] basicCodeProps = typeof(TBasicCode).GetProperties();
diff --git a/FactorySystemBll/HalfMaterialTeamworkBll.cs b/FactorySystemBll/HalfMaterialTeamworkBll.cs
index 11cd82b..a80d95c 100644
--- a/FactorySystemBll/HalfMaterialTeamworkBll.cs
+++ b/FactorySystemBll/HalfMaterialTeamworkBll.cs
@@ -568,7 +568,7 @@ namespace FactorySystemBll
if (hasNewView.ContainsKey((int)Constant.ViewType.中间品视图) || hasNewView.ContainsKey((int)Constant.ViewType.香基视图)
|| hasNewView.ContainsKey((int)Constant.ViewType.半成品视图))
{
- proSql += string.Format("update TFS_MaterialFTeamwork set FViewType=FViewType+',3,4' where FID={0};", teamInfo.FID);
+ proSql += string.Format("update TFS_HalfMaterialFTeamwork set FViewType=FViewType+',3,4' where FID={0};", teamInfo.FID);
BaseBll.CreateTaskData2(teamInfo.FID, userId, "8");
}
proSql += BaseBll.GetProcessSql2(teamInfo.FID, (int)Constant.ProcessType.配方视图, "F2", 1);
diff --git a/FactorySystemBll/ViewBll.cs b/FactorySystemBll/ViewBll.cs
index 0e0d6bc..fde9130 100644
--- a/FactorySystemBll/ViewBll.cs
+++ b/FactorySystemBll/ViewBll.cs
@@ -32,8 +32,8 @@ namespace FactorySystemBll
* 此处的viewType来自TBasicCode中FType=33时,的FRemark字段
* **/
List> viewList = new List>();
-
- if (viewType == 10)
+ List viewTypes=new List { 2,3,4,5,10};
+ if (viewTypes.Contains(viewType))
{
viewList = db.Queryable((a, b) =>
new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID))
@@ -401,6 +401,120 @@ namespace FactorySystemBll
}
return result;
}
+ ///
+ /// 试验号变更-保存视图编辑内容3
+ ///
+ public int UpdateBatchById3(List> viewList, List> materialList,
+ List> 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;
+ }
+
+ ///
+ /// 试验号变更-
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private int CheckTaskComplete2(SqlSugarClient db, int teamId, int taskType, int userId)
+ {
+ int result = 0;
+ //List fields = db.Queryable((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;
+ }
///
/// 联合修改
diff --git a/FactorySystemModel/EnumModel/Constant.cs b/FactorySystemModel/EnumModel/Constant.cs
index 75c5f74..14f44a7 100644
--- a/FactorySystemModel/EnumModel/Constant.cs
+++ b/FactorySystemModel/EnumModel/Constant.cs
@@ -55,7 +55,10 @@ namespace FactorySystemModel.EnumModel
用户状态 = 41,
工厂状态 = 42,
协同视图导出 = 43,
- 物料基础编辑 = 44
+ 物料基础编辑 = 44,
+ 变更试验号流程=45,
+ 变更试验号事项=46
+
}
///
@@ -102,7 +105,8 @@ namespace FactorySystemModel.EnumModel
流程确认完成 = 13,
补充包材规格 = 14,
物料分类 = 15,
- 替代料确认=16
+ 替代料确认=16,
+ 物料编辑=17
}
///
@@ -120,7 +124,8 @@ namespace FactorySystemModel.EnumModel
生成版本 = 7,
组装BOM包含新包材 = 8,
流程完成 = 9,
- 替代品确认=10
+ 替代品确认=10,
+ 物料编辑=11
}
///
@@ -168,5 +173,22 @@ namespace FactorySystemModel.EnumModel
中间品 = 30,
原辅料 = 40
}
+
+ //code=45
+ public enum HalfMaterialTask
+ {
+ BOM下载 = 1,
+ 物料分类 = 2,
+ 物料编辑 = 3
+ }
+
+ //code=46
+ public enum HalfMaterialProcessType
+ {
+ 物料分类 = 1,
+ 物料编辑 = 2,
+ 流程完成 = 3,
+
+ }
}
}