diff --git a/DeviceRepair.DataAccess/Data/BaseDa.cs b/DeviceRepair.DataAccess/Data/BaseDa.cs
index ef47f78..83c076e 100644
--- a/DeviceRepair.DataAccess/Data/BaseDa.cs
+++ b/DeviceRepair.DataAccess/Data/BaseDa.cs
@@ -424,6 +424,47 @@ namespace DeviceRepair.DataAccess.Data
return (dtReturn);
}
+
+ ///
+ /// 对象转换为字典
+ ///
+ /// 待转化的对象
+ ///
+ public Dictionary ObjectToMap(object obj)
+ {
+ Dictionary map = new Dictionary(); //
+
+ Type t = obj.GetType(); // 获取对象对应的类, 对应的类型string
+
+ PropertyInfo[] pi = t.GetProperties(BindingFlags.Public | BindingFlags.Instance); // 获取当前type公共属性io
+
+ foreach (PropertyInfo p in pi)
+ {
+ MethodInfo m = p.GetGetMethod();
+ if (m != null && m.IsPublic)
+ {
+ // 进行判NULL处理
+ if (m.Invoke(obj, new object[] { }) != null)
+ {
+ map.Add(p.Name, m.Invoke(obj, new object[] { }).ToString()); // 向字典添加元素
+ }
+ }
+ }
+ return map;
+ }
+
+ public bool CompareDictionaries(Dictionary d1, Dictionary d2)
+ {
+ //比较d2>=d1
+ if (d1.Count != d2.Count) return false;
+ foreach (string key in d1.Keys)
+ {
+ if (!d2.ContainsKey(key)) return false;
+ if (d1[key]?.Trim() != d2[key].Trim()) return false;
+ }
+ return true;
+ }
+
#endregion
}
}
\ No newline at end of file
diff --git a/DeviceRepair.DataAccess/Device/DeviceDa.cs b/DeviceRepair.DataAccess/Device/DeviceDa.cs
index 917c1a4..c805d6f 100644
--- a/DeviceRepair.DataAccess/Device/DeviceDa.cs
+++ b/DeviceRepair.DataAccess/Device/DeviceDa.cs
@@ -284,6 +284,31 @@ namespace DeviceRepair.DataAccess.Device
.First(x => x.AutoID == Data.AutoID);
if (Item == null)
throw new ArgumentException($"没有获取到设备编号为:【{Data.EquipmentID}】的设备信息!");
+
+ Dictionary dc1 = ObjectToMap(Data);
+ Dictionary dc2 = ObjectToMap(Item);
+ if (dc1.ContainsKey("UsingDate")) dc1.Remove("UsingDate");
+ if (dc2.ContainsKey("UsingDate")) dc2.Remove("UsingDate");
+ if (dc1.ContainsKey("CreatDate")) dc1.Remove("CreatDate");
+ if (dc2.ContainsKey("CreatDate")) dc2.Remove("CreatDate");
+ if (dc1.ContainsKey("CreatUser")) dc1.Remove("CreatUser");
+ if (dc2.ContainsKey("CreatUser")) dc2.Remove("CreatUser");
+ if (dc1.ContainsKey("ChangeDate")) dc1.Remove("ChangeDate");
+ if (dc2.ContainsKey("ChangeDate")) dc2.Remove("ChangeDate");
+ if (dc1.ContainsKey("ChangeUser")) dc1.Remove("ChangeUser");
+ if (dc2.ContainsKey("ChangeUser")) dc2.Remove("ChangeUser");
+ if (dc1.ContainsKey("GUID")) dc1.Remove("GUID");
+ if (dc2.ContainsKey("GUID")) dc2.Remove("GUID");
+
+ var ud1 = (Data.UsingDate ?? "");
+ ud1 = ud1.Length > 8 ? ud1.Substring(0, 7) : ud1;
+ var ud2 = (Item.UsingDate ?? "");
+ ud2 = ud2.Length > 8 ? ud2.Substring(0, 7) : ud2;
+
+ if (CompareDictionaries(dc1, dc2) && ud1 == ud2)
+ {
+ throw new Exception("当前数据无更改!");
+ }
var dataHistory = new DeviceDataHistory
{
diff --git a/DeviceRepair.DataAccess/HistoryDa.cs b/DeviceRepair.DataAccess/HistoryDa.cs
index dffc440..f038bf9 100644
--- a/DeviceRepair.DataAccess/HistoryDa.cs
+++ b/DeviceRepair.DataAccess/HistoryDa.cs
@@ -172,12 +172,17 @@ namespace DeviceRepair.DataAccess
DataSet dsDatas = new DataSet("Datas");
try
{
- int vEnumType = 0;
+ int vEnumType = -1;
if (ApiParameters.ContainsKey("EnumType") && !string.IsNullOrEmpty(ApiParameters["EnumType"] + ""))
{
int.TryParse((ApiParameters["EnumType"] + ""), out vEnumType);
}
+ if (vEnumType == -1)
+ {
+ throw new Exception("请选择字段类型!");
+ }
+
string FieldText = "";
if (ApiParameters.ContainsKey("FieldText"))
{
@@ -222,25 +227,33 @@ namespace DeviceRepair.DataAccess
DataSet dsDatas = new DataSet("Datas");
try
{
- int vEnumType = 0;
+ int vEnumType = -1;
string EnumType = string.Empty;
if (ApiParameters.ContainsKey("FieldCode") && !string.IsNullOrEmpty(ApiParameters["FieldCode"] + ""))
{
int.TryParse((ApiParameters["FieldCode"] + ""), out vEnumType);
}
+
+ if (vEnumType == -1)
+ {
+ throw new Exception("请选择字段类型!");
+ }
+
switch (vEnumType)
{
+ case 0:
+ EnumType = "SymptomlDistinction";
+ break;
case 1:
EnumType = "MAINTENANCE";
break;
case 2:
- EnumType = "ACCESSORIES";
- break;
- case 3:
EnumType = "WHEREFAILUREOCCURRED";
break;
+ case 3:
+ EnumType = "ACCESSORIES";
+ break;
default:
- EnumType = "SymptomlDistinction";
break;
}
diff --git a/DeviceRepair.DataAccess/SysCommon/CustomFieldDa.cs b/DeviceRepair.DataAccess/SysCommon/CustomFieldDa.cs
index ae1e1e2..535ff54 100644
--- a/DeviceRepair.DataAccess/SysCommon/CustomFieldDa.cs
+++ b/DeviceRepair.DataAccess/SysCommon/CustomFieldDa.cs
@@ -186,6 +186,7 @@ namespace DeviceRepair.DataAccess.SysCommon
{
try
{
+ EnumOperationType OpsType = EnumOperationType.Add;
DateTime CurrentDate = DateTime.Now;
if (!ApiParameters.ContainsKey("OPERATORAUTOID"))
@@ -213,18 +214,25 @@ namespace DeviceRepair.DataAccess.SysCommon
&& x.FieldText.Equals(Item.FieldText, StringComparison.CurrentCultureIgnoreCase)))
throw new Exception($"已存在名称为【{Item.FieldText}】的数据,无法重复添加!");
- if (devMain.Insertable(Item).ExecuteCommand() != 1)
+ Item.AutoID = devMain.Insertable(Item).ExecuteReturnIdentity();
+ if (Item.AutoID == 0)
throw new Exception($"执行自定义字段新增失败!");
devMain.CommitTran();
}
else
{
+ OpsType = EnumOperationType.Change;
/* 修改 */
var old = devMain.Queryable().Single(x => x.AutoID == Item.AutoID);
if (old == null)
throw new Exception($"传入的修改对象出错,主键编号为【{Item.AutoID}】的数据不存在!");
+ if (old.FieldText == Item.FieldText && old.FieldType == Item.FieldType && old.FieldValue == Item.FieldValue)
+ {
+ throw new Exception("当前数据无更改!");
+ }
+
his = new FieldDataHistory
{
FieldID = old.AutoID,
@@ -268,7 +276,7 @@ namespace DeviceRepair.DataAccess.SysCommon
GUID = Guid.NewGuid(),
FieldAutoID = Item.AutoID,
FieldHisGuid = Item.GUID,
- }, Item.AutoID == 0 ? EnumOperationType.Add : EnumOperationType.Change, "FieldLog", CurrentDate);
+ }, OpsType, "FieldLog", CurrentDate);
}
catch
{
diff --git a/DeviceRepair.DataAccess/Tag/TagDa.cs b/DeviceRepair.DataAccess/Tag/TagDa.cs
index cfa1363..d12bc39 100644
--- a/DeviceRepair.DataAccess/Tag/TagDa.cs
+++ b/DeviceRepair.DataAccess/Tag/TagDa.cs
@@ -112,6 +112,33 @@ namespace DeviceRepair.DataAccess.Tag
if (tag.TagFormStatus == "C")
throw new Exception($"TagNo.{Model.AutoID}的数据已被修改!");
+ Dictionary dc1 = ObjectToMap(Model);
+ Dictionary dc2 = ObjectToMap(tag);
+ if (dc1.ContainsKey("CreateBy"))
+ dc1.Remove("CreateBy");
+ if (dc1.ContainsKey("CreatOn"))
+ dc1.Remove("CreatOn");
+ if (dc2.ContainsKey("CreateBy"))
+ dc2.Remove("CreateBy");
+ if (dc2.ContainsKey("CreatOn"))
+ dc2.Remove("CreatOn");
+ if (dc2.ContainsKey("CreatorName"))
+ dc2.Remove("CreatorName");
+ if (dc2.ContainsKey("ModifyBy"))
+ dc2.Remove("ModifyBy");
+ if (dc2.ContainsKey("ModifyOn"))
+ dc2.Remove("ModifyOn");
+ if (dc2.ContainsKey("ModifyName"))
+ dc2.Remove("ModifyName");
+ if (dc2.ContainsKey("TagFormStatus"))
+ dc2.Remove("TagFormStatus");
+
+ if (CompareDictionaries(dc1, dc2))
+ {
+ throw new Exception("当前操作无更改!");
+ }
+
+
operationType = EnumOperationType.Change;
/* 插入历史记录 */
diff --git a/TsSFCDevice.Client.Biz/His/DevDataHistory.cs b/TsSFCDevice.Client.Biz/His/DevDataHistory.cs
index 8e19496..a7af072 100644
--- a/TsSFCDevice.Client.Biz/His/DevDataHistory.cs
+++ b/TsSFCDevice.Client.Biz/His/DevDataHistory.cs
@@ -185,7 +185,7 @@ namespace TsSFCDevice.Client.Biz.His
///
/// 路径
///
- [HistoryGridField(Description = "路径", ShowSequence = 22)]
+ [HistoryGridField(Description = "父级分类字段", ShowSequence = 22)]
[JsonProperty("Route", NullValueHandling = NullValueHandling.Ignore)]
public string Route { get; set; }
diff --git a/TsSFCDevice.Client.Launch/Device/Page_DriveInfoEdit.cs b/TsSFCDevice.Client.Launch/Device/Page_DriveInfoEdit.cs
index 28d82c2..ada2d83 100644
--- a/TsSFCDevice.Client.Launch/Device/Page_DriveInfoEdit.cs
+++ b/TsSFCDevice.Client.Launch/Device/Page_DriveInfoEdit.cs
@@ -24,7 +24,12 @@ namespace TsSFCDevice.Client.Launch.Device
public Page_DriveInfoEdit(string caption = null, View_DriveInfomationModel Model = null)
{
InitializeComponent();
+ if (!string.IsNullOrEmpty(caption))
+ {
+ txt_EquipmentName.Enabled = false;
+ }
Caption = caption ?? "新增";
+
CurrentModel = Model ?? new View_DriveInfomationModel();
layoutControlGroup1.ViewInfo.OwnerILayoutControl.AllowCustomizationMenu = false;
}
diff --git a/TsSFCDeviceSvc/Properties/PublishProfiles/default.pubxml.user b/TsSFCDeviceSvc/Properties/PublishProfiles/default.pubxml.user
index 5b35d53..c7a4a12 100644
--- a/TsSFCDeviceSvc/Properties/PublishProfiles/default.pubxml.user
+++ b/TsSFCDeviceSvc/Properties/PublishProfiles/default.pubxml.user
@@ -10,13 +10,13 @@
- 11/07/2024 15:42:33
+ 11/09/2024 21:55:48
- 11/07/2024 15:42:32
+ 11/09/2024 13:22:12
- 11/07/2024 15:42:32
+ 11/09/2024 13:22:13
06/12/2023 14:20:18
@@ -76,7 +76,7 @@
05/28/2024 22:39:54
- 11/07/2024 15:42:36
+ 11/09/2024 21:55:50
07/21/2024 00:35:30