修改物料路线调用MDM更新物料号

修改物料路线筛选
master
leo 3 years ago
parent 7317568ccf
commit 85a2049429

@ -17,8 +17,7 @@ namespace FactorySystemApi.Controllers
/// 协同接口
/// </summary>
[UserLoginFilter]
public class MaterialTeamworkController : ApiController
{
public class MaterialTeamworkController : ApiController {
/// <summary>
/// 数据处理层
/// </summary>
@ -34,10 +33,13 @@ namespace FactorySystemApi.Controllers
/// <summary>
/// 事项操作日志
/// </summary>
public readonly OperateLogBll OperateLogBll = new OperateLogBll();
private readonly OperateLogBll OperateLogBll = new OperateLogBll();
/// <summary>
/// 初始化
/// </summary>
private readonly BaseController<TFS_FMaterialTeamwork> baseController = new BaseController<TFS_FMaterialTeamwork>();
public MaterialTeamworkController()
{
}
@ -54,7 +56,7 @@ namespace FactorySystemApi.Controllers
{
ApiAuthInfo user = Request.Properties["token"] as ApiAuthInfo;
TFS_Factory factory = BaseBll.GetTempModel<TFS_Factory>(int.Parse(inParam["FCreateFactoryID"].ToString()));
Dictionary<string, int> result = new Dictionary<string, int>();
Dictionary<string, object> result = new Dictionary<string, object>();
inParam.Remove("FID");
@ -135,7 +137,14 @@ namespace FactorySystemApi.Controllers
TFS_FMaterialTeamwork teamwork = BaseBll.GetTempModel<TFS_FMaterialTeamwork>(teamId);
// 创建物料和物料视图
Dictionary<string, int> materialInfo = CreateMaterialData(inParam, factory, teamwork);
Dictionary<string, object> materialInfo = CreateMaterialData(inParam, factory, teamwork);
if (materialInfo.ContainsKey("FMaterialCode") && !string.IsNullOrEmpty(materialInfo["FMaterialCode"].ToString()))
{
teamwork.FMaterialCode = materialInfo["FMaterialCode"].ToString();
MaterialTeamworkBll.UpdateMaterialTeamwork(teamwork);
}
foreach(string key in materialInfo.Keys)
{
result.Add(key, materialInfo[key]);
@ -295,9 +304,9 @@ namespace FactorySystemApi.Controllers
}
private Dictionary<string, int> CreateMaterialData(Dictionary<string, object> inParam, TFS_Factory factory, TFS_FMaterialTeamwork teamwork)
private Dictionary<string, object> CreateMaterialData(Dictionary<string, object> inParam, TFS_Factory factory, TFS_FMaterialTeamwork teamwork)
{
Dictionary<string, int> result = new Dictionary<string, int>();
Dictionary<string, object> result = new Dictionary<string, object>();
// 创建物料(物料表新增数据)
TFS_Material material = new TFS_Material();
material.FName = inParam["FMaterialName"].ToString(); // 物料名称
@ -306,7 +315,33 @@ namespace FactorySystemApi.Controllers
material.FBaseUnit = inParam["FWeightUnit"].ToString(); // 计量单位
material.FFactoryID = factory.FFactoryID; // 工厂
material.FFactoryCode = factory.FCode; // 工厂标识
material.FTestCode = inParam["FTestCode"].ToString(); // 试验号
material.FTestCode = inParam.ContainsKey("FTestCode") ? inParam["FTestCode"].ToString() : ""; // 试验号
// 需要获取MDM编码逻辑在页面勾选了需要获取MDM编码时调用获取MDM编码接口
// 此处直接调用BaseController的GetMdmCode方法inParam作为方法的输入参数
// 必须要传递FWeightUnitFTestCodeFMaterialGroup/FGroupFSaleCode/FNameFType/FMaterialType五个参数
// 其中FMaterialType传入固定值ZMATFTestCode非必填其他参数必填
// 此处FWeightUnitFTestCodeFMaterialGroup添加FMaterialType为ZMAT已有添加FName为FMaterialName
bool FIsRaw = (bool)inParam["FIsRaw"];
if (FIsRaw)
{
// 添加物料名称属性
Dictionary<string, object> temp = new Dictionary<string, object>
{
{ "FName", inParam["FMaterialName"] },
{ "FGroup", inParam["FMaterialGroup"] },
{ "FWeightUnit", inParam["FWeightUnit"] },
{ "FType", "ZMAT" }
};
if (!string.IsNullOrEmpty(material.FTestCode))
{
temp.Add("FTestCode", material.FTestCode);
}
string FCode = baseController.GetMdmCode(temp);
material.FCode = FCode;
result.Add("FMaterialCode", FCode);
}
int materialId = MaterialTeamworkBll.InsertMaterial(material);

@ -25,7 +25,7 @@ namespace FactorySystemBll
// 物料号
.WhereIF(!string.IsNullOrEmpty(mtq.FMaterialCode), (a, b) => b.FMaterialCode.Equals(mtq.FMaterialCode))
// 类型
.WhereIF(mtq.FTeamworkType > 0, (a, b) => b.FTeamworkType == mtq.FTeamworkType)
.WhereIF(mtq.FType >= 0, (a, b) => a.FType == mtq.FType)
// 发起时间
.WhereIF(mtq.FDateRange != null && mtq.FDateRange[0] != "", (a, b) => a.FAddDate >= DateTime.Parse(mtq.FDateRange[0]))
.WhereIF(mtq.FDateRange != null && mtq.FDateRange[1] != "", (a, b) => a.FAddDate <= DateTime.Parse(mtq.FDateRange[1]))

@ -348,6 +348,15 @@ namespace FactorySystemBll
return result;
}
public int UpdateMaterialTeamwork(TFS_FMaterialTeamwork teamwork)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
int result = 0;
result = db.Updateable(teamwork).IgnoreColumns(true).WhereColumns("FID").ExecuteCommand();
return result;
}
public List<TFS_Material> SearchMaterialsByFactory(string materialName, int pageNumber, int pageSize, out int totalNumber)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();

Loading…
Cancel
Save