@ -13,6 +13,7 @@ using System.IO;
using Newtonsoft.Json.Linq ;
using FactorySystemApi.Plm_Formula ;
using System.Linq ;
using SqlSugar ;
namespace FactorySystemApi.Controllers
{
@ -77,9 +78,6 @@ namespace FactorySystemApi.Controllers
{
//对接获取
//inParam.Add("FMdmCode", GetMdmCode(inParam));
var ts = DateTime . UtcNow - new DateTime ( 1970 , 1 , 1 , 0 , 0 , 0 , 0 ) ;
inParam . Add ( "FMdmCode" , ts . TotalSeconds . ToString ( "F0" ) ) ;
if ( ! inParam . ContainsKey ( "FMdmCode" ) | | string . IsNullOrEmpty ( inParam [ "FMdmCode" ] . ToString ( ) . Trim ( ) ) )
@ -146,7 +144,8 @@ namespace FactorySystemApi.Controllers
TeamworkBll . CreateProductView ( teamwork , null , user . FID ) ;
//开始BOM下载
DockGetBomData ( teamwork . FID , user . FID ) ;
} else {
}
else {
TeamworkBll . CreateProductView ( teamwork , materialList , user . FID ) ;
TeamworkBll . HasMaterialTestCode ( teamwork ) ;
//补充包材规格
@ -389,8 +388,100 @@ namespace FactorySystemApi.Controllers
} , apiResult , Request , inParam ) ;
}
/// <summary>
/// 更新物料分类
/// </summary>
/// <param name="inParam"></param>
/// <returns></returns>
[HttpPost]
public ApiResult EditTypeList ( Dictionary < string , object > inParam )
{
ApiResult apiResult = new ApiResult ( ) ;
return ExceptionHelper . TryReturnException ( ( ) = > {
if ( inParam [ "tempId" ] ! = null & & inParam [ "taskId" ] ! = null )
{
string sql = "" ;
JArray item = JArray . Parse ( inParam [ "list" ] . ToString ( ) ) ;
for ( int i = 0 ; i < item . Count ; i + + )
{
JObject a = JObject . Parse ( item [ i ] . ToString ( ) ) ;
sql + = string . Format ( "update TFS_Material set FTypeID1={0},FTypeID2={1} where FID={2};" , a [ "FTypeID1" ] . ToString ( ) , a [ "FTypeID2" ] . ToString ( ) , a [ "FMaterialID" ] . ToString ( ) ) ;
}
int count = TeamworkBll . ExecSql ( sql ) ;
apiResult . Data = NextTask ( int . Parse ( inParam [ "tempId" ] . ToString ( ) ) , int . Parse ( inParam [ "taskId" ] . ToString ( ) ) ) ;
}
} , apiResult , Request , inParam ) ;
}
#region 对接相关
private int NextTask ( int teamId , int taskId )
{
int result = 0 ;
List < Specifications > specifList = new List < Specifications > ( ) { new Specifications ( ) } ;
TFS_FTeamwork teamwork = BaseBll . GetTempModel < TFS_FTeamwork > ( teamId ) ;
try
{
ApiAuthInfo user = Request . Properties [ "token" ] as ApiAuthInfo ;
TFS_Formula formula = BaseBll . GetTempModel < TFS_Formula > ( teamwork . FFormulaID ) ;
OAService oAService = new OAService ( ) ;
specifList [ 0 ] . Code = formula . FTestCode ;
specifList [ 0 ] . Version = formula . FVersionCode ;
RestResult restResult = oAService . GetSpecificationsList ( specifList . ToArray ( ) ) ;
string bomStr = restResult . data = = null ? "[]" : restResult . data . ToString ( ) ;
ExceptionHelper . AddSystemJournal ( Request , specifList [ 0 ] , restResult , user . FID , "DockGetBomData" ) ;
List < BomModel > bomList = JsonConvert . DeserializeObject < List < BomModel > > ( bomStr ) ;
if ( bomList ! = null & & bomList . Count > 0 )
{
//修改协同主数据
Dictionary < string , object > upParam = new Dictionary < string , object >
{
{ "FID" , teamwork . FID } ,
{ "FBomState" , 1 } ,
{ "FBomJson" , bomStr }
} ;
BaseBll . UpdateDataModel ( upParam , "TFS_FTeamwork" ) ;
BaseBll . UpdateTeamProcess ( teamwork . FID , ( int ) Constant . ProcessType . 视 图 类 型 编 辑 , 2 , 2 ) ;
int count = TeamworkBll . ExecSql ( BaseBll . GetTaskSql ( taskId , 2 , teamId , ( int ) Constant . ProcessType . 视 图 类 型 编 辑 ) ) ;
BaseBll . UpdateTeamProcess ( teamwork . FID , ( int ) Constant . ProcessType . 协 同 发 起 , 3 , 2 ) ;
if ( teamwork . FPackID = = - 1 )
{
BaseBll . CreateTaskData ( teamwork . FID , user . FID , "9" ) ; //新增新包材事项
BaseBll . UpdateTeamProcess ( teamwork . FID , ( int ) Constant . ProcessType . 组 装 BOM 包 含 新 包 材 , 2 , 1 ) ;
}
else
{
BaseBll . UpdateTeamProcess ( teamwork . FID , ( int ) Constant . ProcessType . 组 装 BOM 包 含 新 包 材 , 3 , 2 ) ;
}
//等类型修改结束使用
//成品视图
BaseBll . CreateTaskData ( teamwork . FID , user . FID , "3" , teamwork . FCreateFactoryID + "," + teamwork . FProdFactoryID ) ;
//补充包材规格
BaseBll . CreateTaskData ( teamwork . FID , user . FID , "14" ) ;
//成品视图物料组复核,有权限的所有
BaseBll . CreateTaskData ( teamwork . FID , user . FID , "12" ) ;
TeamworkBll . ChangeTeamProcess ( teamwork . FID ) ;
result = 1 ;
}
}
catch ( Exception )
{
throw ;
}
return result ;
}
/// <summary>
/// 对接获取Bom数据
/// </summary>
@ -438,23 +529,28 @@ namespace FactorySystemApi.Controllers
} ;
BaseBll . UpdateDataModel ( upParam , "TFS_FTeamwork" ) ;
//协同发起事项
BaseBll . UpdateTeamProcess ( teamwork . FID , ( int ) Constant . ProcessType . 协 同 发 起 , 3 , 2 ) ;
BaseBll . UpdateTeamProcess ( teamwork . FID , ( int ) Constant . ProcessType . 成 品 视 图 , 2 , 1 ) ;
if ( teamwork . FPackID = = - 1 )
{
BaseBll . CreateTaskData ( teamwork . FID , userId , "9" ) ; //新增新包材事项
BaseBll . UpdateTeamProcess ( teamwork . FID , ( int ) Constant . ProcessType . 组 装 BOM 包 含 新 包 材 , 2 , 1 ) ;
}
else
{
BaseBll . UpdateTeamProcess ( teamwork . FID , ( int ) Constant . ProcessType . 组 装 BOM 包 含 新 包 材 , 3 , 2 ) ;
}
//成品视图
BaseBll . CreateTaskData ( teamwork . FID , userId , "3" , teamwork . FCreateFactoryID + "," + teamwork . FProdFactoryID ) ;
//补充包材规格
BaseBll . CreateTaskData ( teamwork . FID , userId , "14" ) ;
//成品视图物料组复核,有权限的所有
BaseBll . CreateTaskData ( teamwork . FID , userId , "12" ) ;
//BaseBll.UpdateTeamProcess(teamwork.FID, (int)Constant.ProcessType.协同发起, 3, 2);
BaseBll . UpdateTeamProcess ( teamwork . FID , ( int ) Constant . ProcessType . 视 图 类 型 编 辑 , 2 , 1 ) ;
//改
//if (teamwork.FPackID == -1)
//{
//
// //BaseBll.CreateTaskData(teamwork.FID, userId, "9");//新增新包材事项
// //BaseBll.UpdateTeamProcess(teamwork.FID, (int)Constant.ProcessType.组装BOM包含新包材, 2, 1);
//}
//else
//{
// BaseBll.UpdateTeamProcess(teamwork.FID, (int)Constant.ProcessType.组装BOM包含新包材, 3, 2);
//}
///等类型修改结束使用
////成品视图
//BaseBll.CreateTaskData(teamwork.FID, userId, "3", teamwork.FCreateFactoryID + "," + teamwork.FProdFactoryID);
////补充包材规格
//BaseBll.CreateTaskData(teamwork.FID, userId, "14");
////成品视图物料组复核,有权限的所有
//BaseBll.CreateTaskData(teamwork.FID, userId, "12");
BaseBll . CreateTaskData ( teamwork . FID , userId , "15" ) ; //新增新包材事项
OperateLogBll . Add ( teamwork . FID , 2 , "BOM下载成功" , userId ) ;
TeamworkBll . ChangeTeamProcess ( teamwork . FID ) ;
result = 1 ;
@ -479,6 +575,10 @@ namespace FactorySystemApi.Controllers
return result ;
}
/// <summary>
/// 递归梳理BOM
/// </summary>