|
|
|
|
|
using FactorySystemCommon;
|
|
|
|
|
|
using FactorySystemModel.SqlSugarModel;
|
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using FactorySystemModel.EnumModel;
|
|
|
|
|
|
using FactorySystemModel.RequestModel;
|
|
|
|
|
|
using FactorySystemModel.ResponseModel;
|
|
|
|
|
|
|
|
|
|
|
|
namespace FactorySystemBll
|
|
|
|
|
|
{
|
|
|
|
|
|
public class FormulaBll
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取配置信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public object GetBasicList(int type)
|
|
|
|
|
|
{
|
|
|
|
|
|
return AppSettingsHelper.GetSqlSugar().Queryable<TBasicCode>().Where(s => s.FType == type && s.FState == 1).ToList();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取配置信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static List<TFS_Formula> GetFormulaList()
|
|
|
|
|
|
{
|
|
|
|
|
|
int isDelete = (int)Constant.DeleteCode.已删除;
|
|
|
|
|
|
return AppSettingsHelper.GetSqlSugar().Queryable<TFS_Formula>().Where(s => s.FDeleted != isDelete).Distinct().ToList();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取修改配方信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static List<TFS_UpdateFormula> GetUpdateFormulaList()
|
|
|
|
|
|
{
|
|
|
|
|
|
return AppSettingsHelper.GetSqlSugar().Queryable<TFS_UpdateFormula>().Distinct().OrderByDescending(m=>m.Change_Time).ToList();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取修改配方信息更具ID获取
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static TFS_UpdateFormula GetUpdateFormulaByFID(int fid)
|
|
|
|
|
|
{
|
|
|
|
|
|
return AppSettingsHelper.GetSqlSugar().Queryable<TFS_UpdateFormula>().Where(m=>m.FID==fid).Distinct().OrderByDescending(m => m.Change_Time).ToList().LastOrDefault();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.已删除;
|
|
|
|
|
|
return AppSettingsHelper.GetSqlSugar().Queryable<TFS_Formula>().Where(s => s.FDeleted != isDelete&&s.FTestCode==code).First();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<FormulaRow> GetList(FormulaQuery tr, out int totalNumber)
|
|
|
|
|
|
{
|
|
|
|
|
|
totalNumber = 0;
|
|
|
|
|
|
var db = AppSettingsHelper.GetSqlSugar();
|
|
|
|
|
|
return db.Queryable<TFS_Formula>().Where(s => s.FTestCode != "")
|
|
|
|
|
|
.WhereIF(tr.FName != null, s => s.FName.Contains(tr.FName) || s.FPlmCode.Contains(tr.FPlmCode) || s.FTestCode.Contains(tr.FTestCode) || s.FVersionCode.Contains(tr.FVersionCode))
|
|
|
|
|
|
.Select<FormulaRow>("*").ToPageList(tr.FPageIndex, tr.FPageSize, ref totalNumber);
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取配方变更列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="tr"></param>
|
|
|
|
|
|
/// <param name="totalNumber"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public List<object> GetUpdateFormulaList(FormulaQuery tr, out int totalNumber)
|
|
|
|
|
|
{
|
|
|
|
|
|
totalNumber = 0;
|
|
|
|
|
|
var db = AppSettingsHelper.GetSqlSugar();
|
|
|
|
|
|
List<object> list = db.Queryable<TFS_UpdateFormula>()
|
|
|
|
|
|
.WhereIF(tr.FPlmCode != null, s => s.Change_Content.Contains(tr.FPlmCode))
|
|
|
|
|
|
.WhereIF(tr.FTestCode != null, s => s.SP_VALUE.Contains(tr.FTestCode))
|
|
|
|
|
|
.WhereIF(tr.FStatus != null, s => s.Status.Contains(tr.FStatus)).OrderByDescending(m=>m.Change_Time)
|
|
|
|
|
|
.Select<object>("*").ToPageList(tr.FPageIndex, tr.FPageSize, ref totalNumber);
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 配方数据比对
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int DockingRecipeData(List<TFS_Formula> formulaList, int userId)
|
|
|
|
|
|
{
|
|
|
|
|
|
formulaList = formulaList.Where(s => !string.IsNullOrEmpty(s.FPlmCode)).ToList();
|
|
|
|
|
|
if (formulaList.Count == 0) return 1;
|
|
|
|
|
|
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
|
|
|
|
|
|
List<TFS_Formula> updateList = new List<TFS_Formula>();
|
|
|
|
|
|
List<TFS_Formula> insertList = new List<TFS_Formula>();
|
|
|
|
|
|
List<TFS_Factory> factorys = db.Queryable<TFS_Factory>().OrderBy(s => s.FDeleted).ToList();
|
|
|
|
|
|
List<TFS_Material> materials = db.Queryable<TFS_Material>().Where(m => !"10".Equals(m.FType)).OrderBy(s => s.FDeleted).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
List<TBasicCode> typeList = db.Queryable<TBasicCode>().Where(s => s.FType == (int)Constant.BasicCode.配方种类).ToList();
|
|
|
|
|
|
//根据PLM码分组
|
|
|
|
|
|
foreach (var item in formulaList.GroupBy(s => s.FPlmCode))
|
|
|
|
|
|
{
|
|
|
|
|
|
List<TFS_Formula> formulas = db.Queryable<TFS_Formula>().Where(s => s.FPlmCode == item.Key
|
|
|
|
|
|
&& s.FDeleted != (int)Constant.DeleteCode.已删除).ToList();
|
|
|
|
|
|
List<TFS_Formula> temps = item.Where(s1 => !string.IsNullOrEmpty(s1.FVersionCode.Trim())).ToList();
|
|
|
|
|
|
if (temps.Count > 0)//版本号非空
|
|
|
|
|
|
{
|
|
|
|
|
|
//根据版本号分组
|
|
|
|
|
|
foreach (var item2 in item.GroupBy(ss => ss.FVersionCode.Trim()))
|
|
|
|
|
|
{
|
|
|
|
|
|
TFS_Formula formula = formulas.Find(d => d.FVersionCode == item2.Key.Trim());
|
|
|
|
|
|
if (formula == null) formula = formulas.Find(d => d.FVersionCode == "");
|
|
|
|
|
|
TFS_Formula temp = item2.FirstOrDefault();
|
|
|
|
|
|
if (formula != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
formula.FName = temp.FName.Trim();
|
|
|
|
|
|
formula.FDesc = (string.IsNullOrEmpty(temp.FDesc) ? formula.FDesc : temp.FDesc).Trim();
|
|
|
|
|
|
formula.FType = (string.IsNullOrEmpty(temp.FType) ? formula.FType : temp.FType).Trim();
|
|
|
|
|
|
formula.FTestCode = (string.IsNullOrEmpty(temp.FTestCode) ? formula.FTestCode : temp.FTestCode).Trim();
|
|
|
|
|
|
formula.FProductCode = (string.IsNullOrEmpty(temp.FProductCode) ? formula.FProductCode : temp.FProductCode).Trim();
|
|
|
|
|
|
formula.FFactoryCode = (string.IsNullOrEmpty(temp.FFactoryCode) ? formula.FFactoryCode : temp.FFactoryCode).Trim();
|
|
|
|
|
|
formula.FVersionCode = (string.IsNullOrEmpty(temp.FVersionCode) ? formula.FVersionCode : temp.FVersionCode).Trim();
|
|
|
|
|
|
if (!string.IsNullOrEmpty(formula.FFactoryCode))
|
|
|
|
|
|
{
|
|
|
|
|
|
TFS_Factory factory = factorys.Find(s => s.FCode == formula.FFactoryCode);
|
|
|
|
|
|
if (factory == null) factory = factorys.Find(s => s.FName == formula.FFactoryCode);
|
|
|
|
|
|
if (factory == null) formula.FFactoryID = -1;
|
|
|
|
|
|
else formula.FFactoryID = factory.FID;
|
|
|
|
|
|
}
|
|
|
|
|
|
formula.FEditDate = DateTime.Now;
|
|
|
|
|
|
formula.FEditUser = userId;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 20230401 新增
|
|
|
|
|
|
* 表中增加:
|
|
|
|
|
|
* 转规格人员 FConversionPersonnel
|
|
|
|
|
|
* 开发日期 FDevDate
|
|
|
|
|
|
* BOM版本号 FBomVersionCode
|
|
|
|
|
|
* **/
|
|
|
|
|
|
formula.FConversionPersonnel = (string.IsNullOrEmpty(temp.FConversionPersonnel) ? formula.FConversionPersonnel : temp.FConversionPersonnel).Trim();
|
|
|
|
|
|
formula.FDevDate = DateTime.Now;
|
|
|
|
|
|
formula.FBomVersionCode = (string.IsNullOrEmpty(temp.FBomVersionCode) ? formula.FBomVersionCode : temp.FBomVersionCode).Trim();
|
|
|
|
|
|
|
|
|
|
|
|
// 20230401 根据试验号获取生产号
|
|
|
|
|
|
if (materials != null && materials.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
TFS_Material material = materials.Find(m => m.FTestCode == formula.FTestCode);
|
|
|
|
|
|
|
|
|
|
|
|
if (material != null && !string.IsNullOrEmpty(material.FCode))
|
|
|
|
|
|
{
|
|
|
|
|
|
formula.FProductCode = material.FCode;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 按照协同物料清单下来的逻辑修改配方物料类型
|
|
|
|
|
|
string ftype = formula.FType.ToLower();
|
|
|
|
|
|
if(ftype == "f")
|
|
|
|
|
|
{
|
|
|
|
|
|
formula.FType = "10";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (ftype == "a")
|
|
|
|
|
|
{
|
|
|
|
|
|
formula.FType = "20";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (ftype == "b" || ftype == "bb" || ftype == "i" || ftype == "iz")
|
|
|
|
|
|
{
|
|
|
|
|
|
formula.FType = "30";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
formula.FType = "40";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TBasicCode bType = typeList.Find(s => s.FName == formula.FType || s.FValue == formula.FType);
|
|
|
|
|
|
if (bType != null) formula.FType = bType.FValue;
|
|
|
|
|
|
updateList.Add(formula);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(temp.FFactoryCode))
|
|
|
|
|
|
{
|
|
|
|
|
|
TFS_Factory factory = factorys.Find(s => s.FCode == temp.FFactoryCode);
|
|
|
|
|
|
if (factory == null) factory = factorys.Find(s => s.FName == temp.FFactoryCode);
|
|
|
|
|
|
if (factory == null) temp.FFactoryID = -1;
|
|
|
|
|
|
else temp.FFactoryID = factory.FID;
|
|
|
|
|
|
}
|
|
|
|
|
|
temp.FID = -1;
|
|
|
|
|
|
temp.FAddDate = temp.FEditDate = DateTime.Now;
|
|
|
|
|
|
temp.FEditUser = userId;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 20230401 新增
|
|
|
|
|
|
* 表中增加:
|
|
|
|
|
|
* 转规格人员 FConversionPersonnel
|
|
|
|
|
|
* 开发日期 FDevDate
|
|
|
|
|
|
* BOM版本号 FBomVersionCode
|
|
|
|
|
|
* **/
|
|
|
|
|
|
temp.FDevDate = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
|
|
// 20230401 根据试验号获取生产号
|
|
|
|
|
|
if (materials != null && materials.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
TFS_Material material = materials.Find(m => m.FTestCode == temp.FTestCode);
|
|
|
|
|
|
|
|
|
|
|
|
if (material != null && !string.IsNullOrEmpty(material.FCode))
|
|
|
|
|
|
{
|
|
|
|
|
|
temp.FProductCode = material.FCode;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 按照协同物料清单下来的逻辑修改配方物料类型
|
|
|
|
|
|
string ftype = temp.FType.ToLower();
|
|
|
|
|
|
if (ftype == "f")
|
|
|
|
|
|
{
|
|
|
|
|
|
temp.FType = "10";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (ftype == "a")
|
|
|
|
|
|
{
|
|
|
|
|
|
temp.FType = "20";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (ftype == "b" || ftype == "bb" || ftype == "i" || ftype == "iz")
|
|
|
|
|
|
{
|
|
|
|
|
|
temp.FType = "30";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
temp.FType = "40";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TBasicCode bType = typeList.Find(s => s.FName == temp.FType || s.FValue == temp.FType);
|
|
|
|
|
|
if (bType != null) temp.FType = bType.FValue;
|
|
|
|
|
|
insertList.Add(temp);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (formulas == null || formulas.Count == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
TFS_Formula temp = item.FirstOrDefault();
|
|
|
|
|
|
temp.FAddDate = temp.FEditDate = DateTime.Now;
|
|
|
|
|
|
temp.FEditUser = userId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 按照协同物料清单下来的逻辑修改配方物料类型
|
|
|
|
|
|
string ftype = temp.FType.ToLower();
|
|
|
|
|
|
if (ftype == "f")
|
|
|
|
|
|
{
|
|
|
|
|
|
temp.FType = "10";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (ftype == "a")
|
|
|
|
|
|
{
|
|
|
|
|
|
temp.FType = "20";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (ftype == "b" || ftype == "bb" || ftype == "i" || ftype == "iz")
|
|
|
|
|
|
{
|
|
|
|
|
|
temp.FType = "30";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
temp.FType = "40";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 20230401 新增
|
|
|
|
|
|
* 表中增加:
|
|
|
|
|
|
* 转规格人员 FConversionPersonnel
|
|
|
|
|
|
* 开发日期 FDevDate
|
|
|
|
|
|
* BOM版本号 FBomVersionCode
|
|
|
|
|
|
* **/
|
|
|
|
|
|
temp.FDevDate = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
|
|
// 20230401 根据试验号获取生产号
|
|
|
|
|
|
if (materials != null && materials.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
TFS_Material material = materials.Find(m => m.FTestCode == temp.FTestCode);
|
|
|
|
|
|
|
|
|
|
|
|
if (material != null && !string.IsNullOrEmpty(material.FCode))
|
|
|
|
|
|
{
|
|
|
|
|
|
temp.FProductCode = material.FCode;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
insertList.Add(temp);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
db.BeginTran();
|
|
|
|
|
|
if (updateList.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < updateList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
db.Updateable(updateList[i]).IgnoreColumns(true).ExecuteCommand();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (insertList.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < insertList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
db.Insertable(insertList[i]).IgnoreColumns(true).ExecuteCommand();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
db.CommitTran();
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
db.RollbackTran();
|
|
|
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// (对接)SAP配方同步
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int DockSapFormula(List<TFS_Formula> formulaList)
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
|
|
|
|
|
|
int okCount = 0;
|
|
|
|
|
|
db.BeginTran();
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (TFS_Formula item in formulaList)
|
|
|
|
|
|
{
|
|
|
|
|
|
TFS_Formula temp = db.Queryable<TFS_Formula>().Where(s => s.FName == item.FName && s.FFactoryID == item.FFactoryID
|
|
|
|
|
|
&& s.FTestCode == item.FTestCode).First();
|
|
|
|
|
|
if (string.IsNullOrEmpty(item.FType)) item.FType = "";
|
|
|
|
|
|
if (temp == null) okCount += db.Insertable(item).IgnoreColumns(true).ExecuteCommand();
|
|
|
|
|
|
}
|
|
|
|
|
|
db.CommitTran();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
ExceptionHelper.AddSystemJournal(null, formulaList, ex.Message, -1, "DockSapFormulaDb");
|
|
|
|
|
|
db.RollbackTran();
|
|
|
|
|
|
}
|
|
|
|
|
|
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.Contains(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 fid = -1;
|
|
|
|
|
|
|
|
|
|
|
|
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 = "";
|
|
|
|
|
|
|
|
|
|
|
|
fid = db.Insertable(formulaApplyHistory).IgnoreColumns(true).ExecuteReturnIdentity();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return fid;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<object> GetFormulaApplyHistory(int formulaId, int pageIndex, int pageSize)
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
|
|
|
|
|
|
List<object> formulaApplyHistory;
|
|
|
|
|
|
|
|
|
|
|
|
if (pageSize > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
formulaApplyHistory = db.Queryable<TFS_FormulaApplyHistory>()
|
|
|
|
|
|
.Where((a) => a.FFormulaID == formulaId)
|
|
|
|
|
|
.OrderBy(a => a.FApplyTime, OrderByType.Desc)
|
|
|
|
|
|
.Select<object>("*")
|
|
|
|
|
|
.ToPageList(pageIndex, pageSize);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
formulaApplyHistory = db.Queryable<TFS_FormulaApplyHistory>()
|
|
|
|
|
|
.Where((a) => a.FFormulaID == formulaId)
|
|
|
|
|
|
.OrderBy(a => a.FApplyTime, OrderByType.Desc)
|
|
|
|
|
|
.Select<object>("*")
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 新增修改配方表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public int SevaTFS_UpdateFormula(TFS_UpdateFormula model)
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
|
|
|
|
|
|
int taskId = -1;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
taskId = db.Insertable(model).IgnoreColumns(true).ExecuteReturnIdentity();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
taskId = -1; ;
|
|
|
|
|
|
}
|
|
|
|
|
|
return taskId;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int EditUpdateFormula(TFS_UpdateFormula model)
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
|
|
|
|
|
|
int taskId = -1;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
//taskId = db.Insertable(model).IgnoreColumns(true).ExecuteReturnIdentity();
|
|
|
|
|
|
taskId = db.Updateable(model).IgnoreColumns(true).ExecuteCommand();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
taskId = -1; ;
|
|
|
|
|
|
}
|
|
|
|
|
|
return taskId;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|