@ -7,6 +7,7 @@ using SqlSugar;
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Globalization ;
using System.Linq ;
using System.Linq.Expressions ;
using System.Reflection ;
@ -389,6 +390,83 @@ namespace FactorySystemBll
formulaIds + = first . FID + "," + fids ;
}
}
//if (hasNewView.Count() > 0)
//{
// hasNewView.OrderBy(s => s.Key);
// string facoryIds = ""; bool hasOther = false;
// foreach (var item in hasNewView)
// {
// //创建视图事项
// string factorys = item.Value.Trim(',');
// BaseBll.CreateTaskData(teamInfo.FID, userId, (item.Key + 2).ToString(), factorys);
// facoryIds += factorys;
// if (item.Key != (int)Constant.ViewType.原料视图) hasOther = true;
// }
// if (hasNewView.ContainsKey((int)Constant.ViewType.原料视图))
// {
// proSql += BaseBll.GetProcessSql(teamInfo.FID, (int)Constant.ProcessType.新原料视图, "F2", 1);
// }
// else
// {
// proSql += BaseBll.GetProcessSql(teamInfo.FID, (int)Constant.ProcessType.新原料视图, "F4", 2);
// }
// if (hasOther)
// {
// proSql += BaseBll.GetProcessSql(teamInfo.FID, (int)Constant.ProcessType.新半成品中间品香基, "F2", 1);
// }
// else
// {
// proSql += BaseBll.GetProcessSql(teamInfo.FID, (int)Constant.ProcessType.新半成品中间品香基, "F4", 2);
// }
// if (hasNewView.ContainsKey((int)Constant.ViewType.中间品视图) || hasNewView.ContainsKey((int)Constant.ViewType.香基视图)
// || hasNewView.ContainsKey((int)Constant.ViewType.半成品视图))
// {
// proSql += string.Format("update TFS_FTeamwork set FViewType=FViewType+',3,4' where FID={0};", teamInfo.FID);
// BaseBll.CreateTaskData(teamId, userId, "8");
// }
// proSql += BaseBll.GetProcessSql(teamInfo.FID, (int)Constant.ProcessType.配方视图, "F2", 1);
//}
//else
//{
// proSql += BaseBll.GetProcessSql(teamInfo.FID, (int)Constant.ProcessType.配方视图, "F2", 2);
// proSql += BaseBll.GetProcessSql(teamInfo.FID, (int)Constant.ProcessType.新半成品中间品香基, "F4", 2);
// proSql += BaseBll.GetProcessSql(teamInfo.FID, (int)Constant.ProcessType.新原料视图, "F4", 2);
//}
////下面两个要根据包材判断, 先改成进行中, hasNewView == 0 && 包材是旧的,完成
//int pVersion = (hasNewView.Count == 0 && teamInfo.FPackID < 1) ? 2 : 1;
//proSql += BaseBll.GetProcessSql(teamInfo.FID, (int)Constant.ProcessType.生产工艺路线, "F2", pVersion);
//proSql += BaseBll.GetProcessSql(teamInfo.FID, (int)Constant.ProcessType.生成版本, "F2", pVersion);
string updateSql = "" ;
formulaIds = formulaIds . Replace ( ",," , "," ) . Replace ( ",," , "," ) . Replace ( ",," , "," ) . Trim ( ',' ) ;
if ( ! string . IsNullOrEmpty ( formulaIds ) )
{
updateSql + = string . Format ( "FMaterialFormulaIDs='{0}',FViewType=FViewType+',2'," , formulaIds ) ;
updateSql + = string . Format ( "FBomFormula='{0}'," , JsonConvert . SerializeObject ( bfList ) ) ;
}
if ( ! string . IsNullOrEmpty ( halfIds ) ) updateSql + = string . Format ( "FMaterialHalfIDs='{0}'," , halfIds ) ;
if ( ! string . IsNullOrEmpty ( updateSql ) ) proSql + = string . Format ( "update TFS_FTeamwork set {1} where FID={0};" , teamInfo . FID , updateSql . Trim ( ',' ) ) ;
proSql + = BaseBll . GetTaskSql ( - 1 , 2 , teamId , ( int ) Constant . TaskType . BOM 下 载 , 2 ) ;
db . Ado . ExecuteCommand ( proSql . Trim ( ';' ) ) ;
db . CommitTran ( ) ;
}
catch ( Exception ex )
{
db . RollbackTran ( ) ;
return false ;
}
return true ;
}
public bool CreateMaterialTask ( Dictionary < int , string > hasNewView , TFS_FTeamwork teamInfo , int userId )
{
string proSql = "" ;
SqlSugarClient db = AppSettingsHelper . GetSqlSugar ( ) ;
db . BeginTran ( ) ;
try
{
if ( hasNewView . Count ( ) > 0 )
{
hasNewView . OrderBy ( s = > s . Key ) ;
@ -421,7 +499,7 @@ namespace FactorySystemBll
| | hasNewView . ContainsKey ( ( int ) Constant . ViewType . 半 成 品 视 图 ) )
{
proSql + = string . Format ( "update TFS_FTeamwork set FViewType=FViewType+',3,4' where FID={0};" , teamInfo . FID ) ;
BaseBll . CreateTaskData ( teamI d , userId , "8" ) ;
BaseBll . CreateTaskData ( teamI nfo. FID , userId , "8" ) ;
}
proSql + = BaseBll . GetProcessSql ( teamInfo . FID , ( int ) Constant . ProcessType . 配 方 视 图 , "F2" , 1 ) ;
}
@ -435,27 +513,15 @@ namespace FactorySystemBll
int pVersion = ( hasNewView . Count = = 0 & & teamInfo . FPackID < 1 ) ? 2 : 1 ;
proSql + = BaseBll . GetProcessSql ( teamInfo . FID , ( int ) Constant . ProcessType . 生 产 工 艺 路 线 , "F2" , pVersion ) ;
proSql + = BaseBll . GetProcessSql ( teamInfo . FID , ( int ) Constant . ProcessType . 生 成 版 本 , "F2" , pVersion ) ;
string updateSql = "" ;
formulaIds = formulaIds . Replace ( ",," , "," ) . Replace ( ",," , "," ) . Replace ( ",," , "," ) . Trim ( ',' ) ;
if ( ! string . IsNullOrEmpty ( formulaIds ) )
{
updateSql + = string . Format ( "FMaterialFormulaIDs='{0}',FViewType=FViewType+',2'," , formulaIds ) ;
updateSql + = string . Format ( "FBomFormula='{0}'," , JsonConvert . SerializeObject ( bfList ) ) ;
}
if ( ! string . IsNullOrEmpty ( halfIds ) ) updateSql + = string . Format ( "FMaterialHalfIDs='{0}'," , halfIds ) ;
if ( ! string . IsNullOrEmpty ( updateSql ) ) proSql + = string . Format ( "update TFS_FTeamwork set {1} where FID={0};" , teamInfo . FID , updateSql . Trim ( ',' ) ) ;
proSql + = BaseBll . GetTaskSql ( - 1 , 2 , teamId , ( int ) Constant . TaskType . BOM 下 载 , 2 ) ;
db . Ado . ExecuteCommand ( proSql . Trim ( ';' ) ) ;
db . CommitTran ( ) ;
}
catch ( Exception ex )
{
db . RollbackTran ( ) ;
return false ;
}
return true ;
}
private List < BomFormulaDto > GetBomFormulaChild ( TFS_Material first , List < TFS_Material > formulaList , out string fids )
@ -542,7 +608,7 @@ namespace FactorySystemBll
FTeamID = teamInfo . FID ,
FFactoryID = teamInfo . FCreateFactoryID ,
FFactoryCode = teamInfo . FCreateFactoryCode ,
FViewType = ( int ) Constant . ViewType . 成品 视 图 ,
FViewType = ( int ) Constant . ViewType . 物料 分 类 视 图 ,
FLevel = 1 ,
FEditUser = userId ,
FBaseMaterialCode = teamInfo . FMdmCode ,