diff --git a/WcsMain/ApiServe/Controllers/Dto/WcsDto/Stacker/EditStackerRequest.cs b/WcsMain/ApiServe/Controllers/Dto/WcsDto/Stacker/EditStackerRequest.cs
new file mode 100644
index 0000000..a4b5a3a
--- /dev/null
+++ b/WcsMain/ApiServe/Controllers/Dto/WcsDto/Stacker/EditStackerRequest.cs
@@ -0,0 +1,63 @@
+using DataCheck;
+using System.Text.Json.Serialization;
+
+namespace WcsMain.ApiServe.Controllers.Dto.WcsDto.Stacker;
+
+
+public class EditStackerRequest
+{
+
+ ///
+ /// 设备编号
+ ///
+ [DataRules]
+ [JsonPropertyName("stackerId")]
+ public int? StackerId { get; set; }
+
+ ///
+ /// 堆垛机名称
+ ///
+ [JsonPropertyName("stackerName")]
+ public string? StackerName { get; set; }
+
+ ///
+ /// 堆垛机状态
+ ///
+ ///
+ /// 0 - 禁用
+ /// 1 - 启用
+ ///
+ [DataRules]
+ [JsonPropertyName("stackerStatus")]
+ public int? StackerStatus { get; set; }
+
+ ///
+ /// 货叉状态
+ ///
+ [JsonPropertyName("forkStatus")]
+ public string? ForkStatus { get; set; }
+
+ ///
+ /// 控制该堆垛机的PLC
+ ///
+ [JsonPropertyName("actionPlc")]
+ public int? ActionPlc { get; set; }
+
+ ///
+ /// 入库站台,格式 : 101-102-103
+ ///
+ [JsonPropertyName("inStand")]
+ public string? InStand { get; set; }
+
+ ///
+ /// 出库站台,格式 : 101-102-103
+ ///
+ [JsonPropertyName("outStand")]
+ public string? OutStand { get; set; }
+
+ ///
+ /// 备注
+ ///
+ [JsonPropertyName("remark")]
+ public string? Remark { get; set; }
+}
diff --git a/WcsMain/ApiServe/Controllers/WcsController/StackerController.cs b/WcsMain/ApiServe/Controllers/WcsController/StackerController.cs
index 653e288..3502fa0 100644
--- a/WcsMain/ApiServe/Controllers/WcsController/StackerController.cs
+++ b/WcsMain/ApiServe/Controllers/WcsController/StackerController.cs
@@ -35,4 +35,15 @@ public class StackerController(StackerService stackerService) : ControllerBase
{
return _stackerService.GetStackerStatus();
}
+
+ ///
+ /// 添加或者编辑堆垛机信息
+ ///
+ ///
+ ///
+ [HttpPost("editStacker")]
+ public WcsApiResponse EditStacker([FromBody] EditStackerRequest request)
+ {
+ return _stackerService.EditStacker(request);
+ }
}
\ No newline at end of file
diff --git a/WcsMain/ApiServe/Service/WcsService/StackerService.cs b/WcsMain/ApiServe/Service/WcsService/StackerService.cs
index e454e3d..95cc624 100644
--- a/WcsMain/ApiServe/Service/WcsService/StackerService.cs
+++ b/WcsMain/ApiServe/Service/WcsService/StackerService.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using DataCheck;
+using System.Collections.Generic;
using WcsMain.ApiServe.Controllers.Dto;
using WcsMain.ApiServe.Controllers.Dto.WcsDto.Stacker;
using WcsMain.ApiServe.Factory;
@@ -74,5 +75,55 @@ public class StackerService(AppStackerDao stackerDao, StackerOperation stackerOp
}
return WcsApiResponseFactory.Success(getStackerStatusResponses, "查询成功");
}
-
+
+ ///
+ /// 添加或者编辑堆垛机信息
+ ///
+ ///
+ ///
+ public WcsApiResponse EditStacker(EditStackerRequest request)
+ {
+ if(!CheckData.CheckDataRules(request))
+ {
+ return WcsApiResponseFactory.RequestErr();
+ }
+ /* 查询是否存在这个编号的堆垛机,若存在则更新数据,若不存在则添加 */
+ List? appStackers = _stackerDao.Select(new AppStacker { StackerId = request.StackerId });
+ if (appStackers == default)
+ {
+ return WcsApiResponseFactory.DataBaseErr();
+ }
+ if (appStackers.Count == 0) // 没有数据,新增一条新的
+ {
+ var insertResult = _stackerDao.Insert(new AppStacker
+ {
+ StackerId = request.StackerId,
+ StackerName = request.StackerName,
+ StackerStatus = request.StackerStatus,
+ ForkStatus = request.ForkStatus,
+ ActionPlc = request.ActionPlc,
+ InStand = request.InStand,
+ OutStand = request.OutStand,
+ Remark = request.Remark,
+ });
+ return insertResult > 0 ? WcsApiResponseFactory.Success() : WcsApiResponseFactory.DataBaseErr();
+ }
+ else // 存在,更新数据
+ {
+ var updateResult = _stackerDao.Update(new AppStacker
+ {
+ StackerId = request.StackerId,
+ StackerName = request.StackerName,
+ StackerStatus = request.StackerStatus,
+ ForkStatus = request.ForkStatus,
+ ActionPlc = request.ActionPlc,
+ InStand = request.InStand,
+ OutStand = request.OutStand,
+ Remark = request.Remark,
+ });
+ return updateResult > 0 ? WcsApiResponseFactory.Success() : WcsApiResponseFactory.DataBaseErr();
+ }
+ }
+
+
}
diff --git a/WcsMain/DataBase/Dao/AppStackerDao.cs b/WcsMain/DataBase/Dao/AppStackerDao.cs
index 5381c81..e546104 100644
--- a/WcsMain/DataBase/Dao/AppStackerDao.cs
+++ b/WcsMain/DataBase/Dao/AppStackerDao.cs
@@ -78,7 +78,10 @@ public class AppStackerDao
.WhereIF(appStacker.StackerId != default, w => w.StackerId == appStacker.StackerId)
.WhereIF(appStacker.StackerName != default, w => w.StackerName == appStacker.StackerName)
.WhereIF(appStacker.StackerStatus != default, w => w.StackerStatus == appStacker.StackerStatus)
+ .WhereIF(appStacker.ForkStatus != default, w => w.ForkStatus == appStacker.ForkStatus)
.WhereIF(appStacker.ActionPlc != default, w => w.ActionPlc == appStacker.ActionPlc)
+ .WhereIF(appStacker.InStand != default, w => w.InStand == appStacker.InStand)
+ .WhereIF(appStacker.OutStand != default, w => w.OutStand == appStacker.OutStand)
.WhereIF(appStacker.Remark != default, w => w.Remark == appStacker.Remark);
return sqlFuc.ToList();
}