增加配方清单申请

master
Leo 2 years ago
parent bbc4955914
commit fe684f4b29

@ -11,6 +11,7 @@ using System.Reflection;
using System.Web.Http;
using FactorySystemModel.EnumModel;
using FactorySystemModel.RequestModel;
using FactorySystemApi.Plm_Formula;
namespace FactorySystemApi.Controllers
{
@ -248,6 +249,135 @@ namespace FactorySystemApi.Controllers
}, apiResult, Request, null);
}
/// <summary>
/// 获取用户是否具备申请查询配方权限
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetApplyBomPower()
{
ApiResult apiResult = new ApiResult();
return ExceptionHelper.TryReturnException(() =>
{
bool hasPower = false;
ApiAuthInfo user = Request.Properties["token"] as ApiAuthInfo;
List<object> powerList = FormulaBll.GetTaskPower(user.FID);
List<object> applyBomPowers = powerList.FindAll(p => ((IDictionary<string, object>)p)["FFunctionID"].ToString().Equals("12")).ToList();
if (applyBomPowers.Count > 0)
{
hasPower = true;
}
apiResult.Data = hasPower;
}, apiResult, Request);
}
/// <summary>
/// 获取用户是否具备申请查询配方权限
/// </summary>
/// <param name="inParam"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetFormulaByTestCode(Dictionary<string, object> inParam)
{
ApiResult apiResult = new ApiResult();
return ExceptionHelper.TryReturnException(() =>
{
SearchFormulaQuery searchFormulaQuery = new SearchFormulaQuery();
string testCode = inParam["FTestCode"] == null ? "" : inParam["FTestCode"].ToString();
string pageIndex = inParam["FPageIndex"] == null ? "0" : inParam["FPageIndex"].ToString();
string pageSize = inParam["FPageSize"] == null ? "5" : inParam["FPageSize"].ToString();
int nPageIndex = 0;
int nPageSize = 0;
int.TryParse(pageIndex, out nPageIndex);
int.TryParse(pageSize, out nPageSize);
searchFormulaQuery.FTestCode = testCode;
searchFormulaQuery.FPageIndex = nPageIndex;
searchFormulaQuery.FPageSize = nPageSize;
apiResult.Data = new
{
List = FormulaBll.GetListByTestCode(searchFormulaQuery, out var totalNumber),
Total = totalNumber
};
}, apiResult, Request);
}
/// <summary>
/// 获取配方清单
/// </summary>
/// <param name="inParam"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetBomList(Dictionary<string, object> inParam)
{
ApiResult apiResult = new ApiResult();
ApiAuthInfo user = Request.Properties["token"] as ApiAuthInfo;
return ExceptionHelper.TryReturnException(() =>
{
string fid = inParam["FID"] == null ? "" : inParam["FID"].ToString();
int nFid = 0;
int.TryParse(fid, out nFid);
List<TFS_Formula> formulas = FormulaBll.GetFormulaListById(nFid);
if (formulas != null && formulas.Count > 0)
{
TFS_Formula formula = formulas[0];
OAService oAService = new OAService();
List<Specifications> specifList = new List<Specifications>() { new Specifications() };
specifList[0].SP = formula.FPlmCode;
specifList[0].SP_Version = formula.FVersionCode;
InputSpecifications oaParam = new InputSpecifications();
oaParam.USERNAME = AppSettingsHelper.GetAppSettingVal("Plm_Formula_Username");
oaParam.PASSWORD = AppSettingsHelper.GetAppSettingVal("Plm_Formula_Password");
oaParam.Specifications = specifList.ToArray();
RestResult restResult = oAService.GetSpecificationsList(oaParam);
apiResult.Data = restResult.data;
if (restResult.data != null)
{
FormulaBll.AddFormulaApplyHistroy(formula, user.FName, user.FID);
}
}
}, apiResult, Request);
}
/// <summary>
/// 根据物料号列表获取物料列表
/// </summary>
/// <param name="inParam"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetMaterialList(Dictionary<string, object> inParam)
{
ApiResult apiResult = new ApiResult();
return ExceptionHelper.TryReturnException(() =>
{
string materialCodes = inParam["materialCodes"] == null ? "" : inParam["materialCodes"].ToString();
List<object> materialList = FormulaBll.GetMaterialList(materialCodes);
apiResult.Data = materialList;
}, apiResult, Request);
}
#region 内部方法
/// <summary>

@ -29,6 +29,12 @@ namespace FactorySystemBll
return AppSettingsHelper.GetSqlSugar().Queryable<TFS_Formula>().Where(s => s.FDeleted != isDelete).Distinct().ToList();
}
public List<TFS_Formula> GetFormulaListById(int id)
{
int isDelete = (int)Constant.DeleteCode.;
return AppSettingsHelper.GetSqlSugar().Queryable<TFS_Formula>().Where(s => s.FID == id && s.FDeleted != isDelete).Distinct().ToList();
}
public object GetFormulaByFTestCode(string code)
{
int isDelete = (int)Constant.DeleteCode.;
@ -278,5 +284,92 @@ namespace FactorySystemBll
}
return okCount;
}
// 获取用户事项权限
public List<object> GetTaskPower(int userId)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
List<object> powers = db.Queryable<TRole_Right, FPower>((a, b) => new JoinQueryInfos(
JoinType.Full, b.FRole.Equals(a.FRoleID.ToString())
))
.Where((a, b) => b.FUserID.Equals(userId.ToString()))
.Where((a, b) => a.FType == 2)
.Select<object>("a.FRoleID, a.FType, a.FFunctionID, b.FFactoryID").Distinct()
.ToList();
return powers;
}
// 根据试验号获取配方信息+查询记录
public List<object> GetListByTestCode(SearchFormulaQuery sfq, out int totalNumber)
{
totalNumber = 0;
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
List<object> formulas;
if (string.IsNullOrEmpty(sfq.FTestCode))
{
formulas = null;
totalNumber = 0;
}
else
{
formulas = db.Queryable<TFS_Formula, TFS_FormulaApplyHistory>((a, b) => new JoinQueryInfos(
JoinType.Left, a.FID == b.FFormulaID
))
.Where((a, b) => a.FTestCode.Equals(sfq.FTestCode))
.OrderBy((a, b) => a.FID)
.Select<object>("a. *, b.FUserName, b.FApplyTime")
.ToPageList(sfq.FPageIndex, sfq.FPageSize, ref totalNumber);
}
return formulas;
}
// 根据物料编号列表获取物料信息列表
public List<object> GetMaterialList(string materialCodes)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
List<object> materials;
if (string.IsNullOrEmpty(materialCodes))
{
materials = null;
}
else
{
materials = db.Queryable<TFS_Material>()
.Where((a) => materialCodes.Contains("," + a.FCode + ","))
.Select<object>("FCode, FSuccedaneumID, FSuccedaneumInfo, FSuccedaneumType, FSuccedaneumCode")
.ToList();
}
return materials;
}
public int AddFormulaApplyHistroy(TFS_Formula formula, string userName, int userId)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
int okCount = 0;
if (formula != null)
{
TFS_FormulaApplyHistory formulaApplyHistory = new TFS_FormulaApplyHistory();
formulaApplyHistory.FFormulaID = formula.FID;
formulaApplyHistory.FFormulaName = formula.FName;
formulaApplyHistory.FTestCode = formula.FTestCode;
formulaApplyHistory.FVersionCode = formula.FVersionCode;
formulaApplyHistory.FUserID = userId;
formulaApplyHistory.FUserName = userName;
formulaApplyHistory.FApplyTime = DateTime.Now;
formulaApplyHistory.FApplyNumber = 0;
formulaApplyHistory.FRemark = "";
okCount += db.Insertable(formulaApplyHistory).IgnoreColumns(true).ExecuteCommand();
}
return okCount;
}
}
}

@ -59,9 +59,11 @@
<Compile Include="RequestModel\FormulaQuery.cs" />
<Compile Include="RequestModel\MaterialTeamworkQuery.cs" />
<Compile Include="RequestModel\MaterialTaskQuery.cs" />
<Compile Include="RequestModel\SearchFormulaQuery.cs" />
<Compile Include="RequestModel\TaskQuery.cs" />
<Compile Include="RequestModel\UploadTempFileRequest.cs" />
<Compile Include="ResponseModel\ApiResult.cs" />
<Compile Include="ResponseModel\ApplyFormulaRow.cs" />
<Compile Include="ResponseModel\FormulaRow.cs" />
<Compile Include="ResponseModel\LogRow.cs" />
<Compile Include="ResponseModel\MaterialTaskRow.cs" />
@ -70,6 +72,7 @@
<Compile Include="SqlSugarModel\Common.cs" />
<Compile Include="SqlSugarModel\FPower.cs" />
<Compile Include="SqlSugarModel\TFS_FMaterialTask.cs" />
<Compile Include="SqlSugarModel\TFS_FormualApplyHistory.cs" />
<Compile Include="SqlSugarModel\TFS_FreezingColumns.cs" />
<Compile Include="SqlSugarModel\TDataCode.cs" />
<Compile Include="SqlSugarModel\TBasicCode.cs" />

@ -0,0 +1,11 @@
namespace FactorySystemModel.RequestModel
{
public class SearchFormulaQuery
{
public string FTestCode { get; set; }
public int FPageIndex { get; set; }
public int FPageSize { get; set; }
}
}

@ -0,0 +1,21 @@
using System;
namespace FactorySystemModel.ResponseModel
{
public class ApplyFormulaRow : FormulaRow
{
/// <summary>
/// Desc:最近查询用户
/// Default:
/// Nullable:False
/// </summary>
public string FUserName { get; set; }
/// <summary>
/// Desc:最近查询时间
/// Default:DateTime.Now
/// Nullable:False
/// </summary>
public DateTime? FSearchTime { get; set; }
}
}

@ -0,0 +1,62 @@
using System;
using SqlSugar;
namespace FactorySystemModel.SqlSugarModel
{
///<summary>
///基础数据字典
///</summary>
[SugarTable("TFS_FormulaApplyHistory")]
public partial class TFS_FormulaApplyHistory
{
public TFS_FormulaApplyHistory()
{
}
/// <summary>
/// Desc:唯一标识
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int FID { get; set; }
/// <summary>
/// 配方ID
/// </summary>
public int FFormulaID { get; set; }
/// <summary>
/// 配方名称
/// </summary>
public string FFormulaName { get; set; }
/// <summary>
/// 试验号
/// </summary>
public string FTestCode { get; set; }
/// <summary>
/// 版本号
/// </summary>
public string FVersionCode { get; set; }
/// <summary>
/// 用户ID
/// </summary>
public int FUserID { get; set; }
/// <summary>
/// 用户名
/// </summary>
public string FUserName { get; set; }
/// <summary>
/// 申请时间
/// </summary>
public DateTime FApplyTime { get; set; }
/// <summary>
/// 申请数量
/// </summary>
public int FApplyNumber { get; set; }
/// <summary>
/// 备注
/// </summary>
public string FRemark { get; set; }
}
}
Loading…
Cancel
Save