|
|
|
|
@ -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 != null && restResult.data != null)
|
|
|
|
|
{
|
|
|
|
|
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 (restResult.data != null)
|
|
|
|
|
if ("40".Equals(bom.ABomType))
|
|
|
|
|
{
|
|
|
|
|
bom.ASapCode = bom.SP_VALUE;
|
|
|
|
|
materialCodes = materialCodes + bom.ASapCode + ",";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FormulaBll.AddFormulaApplyHistroy(formula, user.FName, user.FID);
|
|
|
|
|
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);
|
|
|
|
|
|