1、修改配方申请结果各列数据取值

2、增加配方导出次数和导出日期
3、修改配方申请记录列数据,增加导出次数和最后导出时间
master
Leo 2 years ago
parent 61ec1abbcc
commit 38e3e2daa5

@ -359,6 +359,7 @@ namespace FactorySystemApi.Controllers
{
ApiResult apiResult = new ApiResult();
ApiAuthInfo user = Request.Properties["token"] as ApiAuthInfo;
Dictionary<string, object> resultObj = new Dictionary<string, object>();
return ExceptionHelper.TryReturnException(() =>
{
@ -373,6 +374,7 @@ namespace FactorySystemApi.Controllers
{
TFS_Formula formula = formulas[0];
OAService oAService = new OAService();
string bomListStr = "";
List<Specifications> specifList = new List<Specifications>() { new Specifications() };
@ -387,13 +389,87 @@ namespace FactorySystemApi.Controllers
RestResult restResult = oAService.GetSpecificationsList(oaParam);
apiResult.Data = restResult.data;
if (restResult.data != null)
if (restResult != null && restResult.data != null)
{
FormulaBll.AddFormulaApplyHistroy(formula, user.FName, user.FID);
List<BomModel> bomList = JsonConvert.DeserializeObject<List<BomModel>>(restResult.data.ToString());
string materialCodes = ",";
string testCodes = ",";
if (bomList != null && bomList.Count > 0)
{
List<BomModel> subBomList = bomList[0].Specifications;
if (subBomList != null && subBomList.Count > 0)
{
foreach(BomModel bom in subBomList)
{
if (bom.Type == "a" || bom.Type == "f")
{
bom.ABomType = "20";
}
else if (bom.Type == "b" || bom.Type == "bb" || bom.Type == "i" || bom.Type == "iz")
{
bom.ABomType = "30";
}
else
{
bom.ABomType = "40";
}
if ("40".Equals(bom.ABomType))
{
bom.ASapCode = bom.SP_VALUE;
materialCodes = materialCodes + bom.ASapCode + ",";
}
else
{
bom.ATestCode = bom.SP_VALUE;
testCodes = testCodes + bom.ATestCode + ",";
}
}
List<TFS_ViewMaterial> viewsByMaterialCodes = FormulaBll.GetViewByMaterialCodes(materialCodes);
List<TFS_ViewMaterial> viewsByTestCodes = FormulaBll.GetViewByTestCodes(testCodes);
foreach (BomModel bom in subBomList)
{
if ("40".Equals(bom.ABomType))
{
if (viewsByMaterialCodes != null && viewsByMaterialCodes.Count > 0)
{
TFS_ViewMaterial view = viewsByMaterialCodes.Find(v => v.FBaseMaterialCode.Equals(bom.ASapCode));
if (view != null)
{
bom.AMaterialCode = view.FSaleOldMaterialCode;
}
}
}
else
{
if (viewsByTestCodes != null && viewsByTestCodes.Count > 0)
{
TFS_ViewMaterial view = viewsByTestCodes.Find(v => v.FBaseTestCode.Equals(bom.ATestCode));
if (view != null)
{
bom.AMaterialCode = view.FSaleOldMaterialCode;
bom.ASapCode = view.FBaseMaterialCode;
}
}
}
}
int formulaApplyHistoryId = FormulaBll.AddFormulaApplyHistroy(formula, user.FName, user.FID);
resultObj.Add("applyHistoryId", formulaApplyHistoryId);
resultObj.Add("bomList", bomList);
bomListStr = JsonConvert.SerializeObject(resultObj);
}
}
}
apiResult.Data = bomListStr;
}
}, apiResult, Request);
}
@ -465,11 +541,16 @@ namespace FactorySystemApi.Controllers
List<Dictionary<string, object>> bomList = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(JsonConvert.SerializeObject(bomObj));
inParam.TryGetValue("FID", out object oFid);
inParam.TryGetValue("ApplyHisId", out object oApplyHisId);
string sFid = oFid != null ? oFid.ToString() : "-1";
int nFid = 0;
int nFid = -1;
int.TryParse(sFid, out nFid);
string sApplyHisId = oApplyHisId != null ? oApplyHisId.ToString() : "-1";
int nApplyHisId = -1;
int.TryParse(sApplyHisId, out nApplyHisId);
string testCode = "";
string userName = user.FName;
string productNumber = "";
@ -489,6 +570,15 @@ namespace FactorySystemApi.Controllers
if (exportResult)
{
apiResult.Data = Request.RequestUri.AbsoluteUri.Replace(Request.RequestUri.AbsolutePath, "").Trim('/') + savePath;
TFS_FormulaApplyHistory formulaApplyHistory = FormulaBll.GetFormulaApplyHistory(nApplyHisId);
if (formulaApplyHistory != null)
{
formulaApplyHistory.FExportTimes = formulaApplyHistory.FExportTimes + 1;
formulaApplyHistory.FLastExportTime = DateTime.Now;
FormulaBll.UpdateFormulaApplyHistory(formulaApplyHistory);
}
}
else
{
@ -528,7 +618,8 @@ namespace FactorySystemApi.Controllers
dataList.Columns.Add("申请人");
dataList.Columns.Add("试验号");
dataList.Columns.Add("产品名称");
dataList.Columns.Add("申请数量");
dataList.Columns.Add("导出次数");
dataList.Columns.Add("最后导出时间");
dataList.Columns.Add("备注");
foreach (Dictionary<string, object> his in hisList)
@ -539,14 +630,17 @@ namespace FactorySystemApi.Controllers
string userName = his["FUserName"] != null ? his["FUserName"].ToString() : "";
string testCode = his["FTestCode"] != null ? his["FTestCode"].ToString() : "";
string formulaName = his["FFormulaName"] != null ? his["FFormulaName"].ToString() : "";
string applyNumber = his["FApplyNumber"] != null ? his["FApplyNumber"].ToString() : "";
string applyNumber = his["FApplyNumber"] != null ? his["FApplyNumber"].ToString() : "0";
string exportTimes = his["FExportTimes"] != null ? his["FExportTimes"].ToString() : "0";
string lastExportTime = string.Compare(exportTimes, "0") > 0 && his["FLastExportTime"] != null ? his["FLastExportTime"].ToString() : "";
string remark = his["FRemark"] != null ? his["FRemark"].ToString() : "";
row["申请日期"] = applyTime;
row["申请人"] = userName;
row["试验号"] = testCode;
row["产品名称"] = formulaName;
row["申请数量"] = applyNumber;
row["导出次数"] = exportTimes;
row["最后导出时间"] = lastExportTime;
row["备注"] = remark;
dataList.Rows.Add(row);

@ -351,7 +351,7 @@ namespace FactorySystemBll
public int AddFormulaApplyHistroy(TFS_Formula formula, string userName, int userId)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
int okCount = 0;
int fid = -1;
if (formula != null)
{
@ -366,10 +366,10 @@ namespace FactorySystemBll
formulaApplyHistory.FApplyNumber = 0;
formulaApplyHistory.FRemark = "";
okCount += db.Insertable(formulaApplyHistory).IgnoreColumns(true).ExecuteCommand();
fid = db.Insertable(formulaApplyHistory).IgnoreColumns(true).ExecuteReturnIdentity();
}
return okCount;
return fid;
}
public List<object> GetFormulaApplyHistory(int formulaId, int pageIndex, int pageSize)
@ -396,5 +396,59 @@ namespace FactorySystemBll
return formulaApplyHistory;
}
public TFS_FormulaApplyHistory GetFormulaApplyHistory(int fid)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
TFS_FormulaApplyHistory formulaApplyHistory = null;
formulaApplyHistory = db.Queryable<TFS_FormulaApplyHistory>()
.Where((fah) => fah.FID == fid)
.Select<TFS_FormulaApplyHistory>("*")
.First();
return formulaApplyHistory;
}
public int UpdateFormulaApplyHistory(TFS_FormulaApplyHistory fah)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
int result = -1;
result = db.Updateable(fah).IgnoreColumns(true).WhereColumns("FID").ExecuteCommand();
return result;
}
public List<TFS_ViewMaterial> GetViewByMaterialCodes(string codes)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
List<TFS_ViewMaterial> views = null;
if (!string.IsNullOrEmpty(codes.Replace(",", ""))) {
views = db.Queryable<TFS_ViewMaterial>()
.Where((vm) => codes.Contains(vm.FBaseMaterialCode))
.Select<TFS_ViewMaterial>("*")
.ToList();
}
return views;
}
public List<TFS_ViewMaterial> GetViewByTestCodes(string codes)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
List<TFS_ViewMaterial> views = null;
if (!string.IsNullOrEmpty(codes.Replace(",", "")))
{
views = db.Queryable<TFS_ViewMaterial>()
.Where((vm) => codes.Contains(vm.FBaseTestCode))
.Select<TFS_ViewMaterial>("*")
.ToList();
}
return views;
}
}
}

@ -34,6 +34,15 @@ namespace FactorySystemModel.BusinessModel
public string Version { get; set; }
public string Quantity { get; set; }
public string TestNO { get; set; }
public string AMaterialCode { get; set; }
public string ASapCode { get; set; }
public string ATestCode { get; set; }
public string ABomType { get; set; }
public List<BomModel> Specifications { get; set; }
}

@ -56,7 +56,14 @@ namespace FactorySystemModel.SqlSugarModel
/// 备注
/// </summary>
public string FRemark { get; set; }
/// <summary>
/// 导出次数
/// </summary>
public int FExportTimes { get; set; }
/// <summary>
/// 最后导出时间
/// </summary>
public DateTime FLastExportTime { get; set; }
}
}

Loading…
Cancel
Save