From 85a2049429d80deefb0634598082f48725ce6440 Mon Sep 17 00:00:00 2001
From: leo <10200039@qq.com>
Date: Fri, 21 Apr 2023 23:46:40 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=A9=E6=96=99?=
=?UTF-8?q?=E8=B7=AF=E7=BA=BF=E8=B0=83=E7=94=A8MDM=E6=9B=B4=E6=96=B0?=
=?UTF-8?q?=E7=89=A9=E6=96=99=E5=8F=B7=20=E4=BF=AE=E6=94=B9=E7=89=A9?=
=?UTF-8?q?=E6=96=99=E8=B7=AF=E7=BA=BF=E7=AD=9B=E9=80=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/MaterialTeamworkController.cs | 51 ++++++++++++++++---
FactorySystemBll/MaterialTaskBll.cs | 2 +-
FactorySystemBll/MaterialTeamworkBll.cs | 9 ++++
3 files changed, 53 insertions(+), 9 deletions(-)
diff --git a/FactorySystemApi/Controllers/MaterialTeamworkController.cs b/FactorySystemApi/Controllers/MaterialTeamworkController.cs
index 2069322..8f9860b 100644
--- a/FactorySystemApi/Controllers/MaterialTeamworkController.cs
+++ b/FactorySystemApi/Controllers/MaterialTeamworkController.cs
@@ -17,8 +17,7 @@ namespace FactorySystemApi.Controllers
/// 协同接口
///
[UserLoginFilter]
- public class MaterialTeamworkController : ApiController
- {
+ public class MaterialTeamworkController : ApiController {
///
/// 数据处理层
///
@@ -34,10 +33,13 @@ namespace FactorySystemApi.Controllers
///
/// 事项操作日志
///
- public readonly OperateLogBll OperateLogBll = new OperateLogBll();
+ private readonly OperateLogBll OperateLogBll = new OperateLogBll();
///
/// 初始化
///
+
+ private readonly BaseController baseController = new BaseController();
+
public MaterialTeamworkController()
{
}
@@ -54,7 +56,7 @@ namespace FactorySystemApi.Controllers
{
ApiAuthInfo user = Request.Properties["token"] as ApiAuthInfo;
TFS_Factory factory = BaseBll.GetTempModel(int.Parse(inParam["FCreateFactoryID"].ToString()));
- Dictionary result = new Dictionary();
+ Dictionary result = new Dictionary();
inParam.Remove("FID");
@@ -135,7 +137,14 @@ namespace FactorySystemApi.Controllers
TFS_FMaterialTeamwork teamwork = BaseBll.GetTempModel(teamId);
// 创建物料和物料视图
- Dictionary materialInfo = CreateMaterialData(inParam, factory, teamwork);
+ Dictionary 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 CreateMaterialData(Dictionary inParam, TFS_Factory factory, TFS_FMaterialTeamwork teamwork)
+ private Dictionary CreateMaterialData(Dictionary inParam, TFS_Factory factory, TFS_FMaterialTeamwork teamwork)
{
- Dictionary result = new Dictionary();
+ Dictionary result = new Dictionary();
// 创建物料(物料表新增数据)
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 temp = new Dictionary
+ {
+ { "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);
diff --git a/FactorySystemBll/MaterialTaskBll.cs b/FactorySystemBll/MaterialTaskBll.cs
index 51bf0b9..4c955c5 100644
--- a/FactorySystemBll/MaterialTaskBll.cs
+++ b/FactorySystemBll/MaterialTaskBll.cs
@@ -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]))
diff --git a/FactorySystemBll/MaterialTeamworkBll.cs b/FactorySystemBll/MaterialTeamworkBll.cs
index e7053c9..a707c64 100644
--- a/FactorySystemBll/MaterialTeamworkBll.cs
+++ b/FactorySystemBll/MaterialTeamworkBll.cs
@@ -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 SearchMaterialsByFactory(string materialName, int pageNumber, int pageSize, out int totalNumber)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
From f6a928458b63f084cefdfadd462410e8bfebf6e4 Mon Sep 17 00:00:00 2001
From: leo <10200039@qq.com>
Date: Sat, 22 Apr 2023 00:10:36 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E5=8C=85=E8=A7=84=E5=AD=98=E5=9C=A8?=
=?UTF-8?q?=E5=88=A4=E6=96=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
FactorySystemApi/Controllers/PackageController.cs | 10 ++++++++++
FactorySystemBll/PackageBll.cs | 7 +++++++
2 files changed, 17 insertions(+)
diff --git a/FactorySystemApi/Controllers/PackageController.cs b/FactorySystemApi/Controllers/PackageController.cs
index 156ecc5..6423a12 100644
--- a/FactorySystemApi/Controllers/PackageController.cs
+++ b/FactorySystemApi/Controllers/PackageController.cs
@@ -142,6 +142,16 @@ namespace FactorySystemApi.Controllers
if ("1".Equals(sOperateType))
{
+ // 20230422 新增逻辑
+ // 包规存在则不允许添加包材
+ string fcode = inParam["FCode"].ToString();
+ TFS_PackageMain package = PackageBll.GetPackageByFCode(fcode);
+
+ if (package != null)
+ {
+ return -2;
+ }
+
mainId = PackageBll.UpdatePackage(inParam);
inParam.Remove("FID");
inParam.Add("FID", mainId);
diff --git a/FactorySystemBll/PackageBll.cs b/FactorySystemBll/PackageBll.cs
index b9eab7b..2db58f0 100644
--- a/FactorySystemBll/PackageBll.cs
+++ b/FactorySystemBll/PackageBll.cs
@@ -212,6 +212,13 @@ namespace FactorySystemBll
* 当FOperateType == 1,即由包材清单入口进入时调用
* **/
+ // 根据包规获取包材 20230421
+ public TFS_PackageMain GetPackageByFCode(string FCode)
+ {
+ SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
+ return db.Queryable().Where(s => s.FCode == FCode).First();
+ }
+
// 新的包材子项新增
public void InsertPackageChild(Dictionary inParam, List childList)
{