|
|
|
|
@ -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作为方法的输入参数
|
|
|
|
|
// 必须要传递FWeightUnit,FTestCode,FMaterialGroup/FGroup,FSaleCode/FName,FType/FMaterialType五个参数
|
|
|
|
|
// 其中FMaterialType传入固定值ZMAT,FTestCode非必填,其他参数必填
|
|
|
|
|
// 此处FWeightUnit,FTestCode,FMaterialGroup,添加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);
|
|
|
|
|
|
|
|
|
|
|