<add>[important]添加编辑堆垛机功能
This commit is contained in:
parent
50b0dbd599
commit
f1da7a4d28
|
|
@ -0,0 +1,63 @@
|
||||||
|
using DataCheck;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace WcsMain.ApiServe.Controllers.Dto.WcsDto.Stacker;
|
||||||
|
|
||||||
|
|
||||||
|
public class EditStackerRequest
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备编号
|
||||||
|
/// </summary>
|
||||||
|
[DataRules]
|
||||||
|
[JsonPropertyName("stackerId")]
|
||||||
|
public int? StackerId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 堆垛机名称
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("stackerName")]
|
||||||
|
public string? StackerName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 堆垛机状态
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// 0 - 禁用
|
||||||
|
/// 1 - 启用
|
||||||
|
/// </remarks>
|
||||||
|
[DataRules]
|
||||||
|
[JsonPropertyName("stackerStatus")]
|
||||||
|
public int? StackerStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 货叉状态
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("forkStatus")]
|
||||||
|
public string? ForkStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 控制该堆垛机的PLC
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("actionPlc")]
|
||||||
|
public int? ActionPlc { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 入库站台,格式 : 101-102-103
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("inStand")]
|
||||||
|
public string? InStand { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 出库站台,格式 : 101-102-103
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("outStand")]
|
||||||
|
public string? OutStand { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 备注
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("remark")]
|
||||||
|
public string? Remark { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -35,4 +35,15 @@ public class StackerController(StackerService stackerService) : ControllerBase
|
||||||
{
|
{
|
||||||
return _stackerService.GetStackerStatus();
|
return _stackerService.GetStackerStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加或者编辑堆垛机信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("editStacker")]
|
||||||
|
public WcsApiResponse EditStacker([FromBody] EditStackerRequest request)
|
||||||
|
{
|
||||||
|
return _stackerService.EditStacker(request);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using DataCheck;
|
||||||
|
using System.Collections.Generic;
|
||||||
using WcsMain.ApiServe.Controllers.Dto;
|
using WcsMain.ApiServe.Controllers.Dto;
|
||||||
using WcsMain.ApiServe.Controllers.Dto.WcsDto.Stacker;
|
using WcsMain.ApiServe.Controllers.Dto.WcsDto.Stacker;
|
||||||
using WcsMain.ApiServe.Factory;
|
using WcsMain.ApiServe.Factory;
|
||||||
|
|
@ -74,5 +75,55 @@ public class StackerService(AppStackerDao stackerDao, StackerOperation stackerOp
|
||||||
}
|
}
|
||||||
return WcsApiResponseFactory.Success(getStackerStatusResponses, "查询成功");
|
return WcsApiResponseFactory.Success(getStackerStatusResponses, "查询成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加或者编辑堆垛机信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public WcsApiResponse EditStacker(EditStackerRequest request)
|
||||||
|
{
|
||||||
|
if(!CheckData.CheckDataRules(request))
|
||||||
|
{
|
||||||
|
return WcsApiResponseFactory.RequestErr();
|
||||||
|
}
|
||||||
|
/* 查询是否存在这个编号的堆垛机,若存在则更新数据,若不存在则添加 */
|
||||||
|
List<AppStacker>? 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,10 @@ public class AppStackerDao
|
||||||
.WhereIF(appStacker.StackerId != default, w => w.StackerId == appStacker.StackerId)
|
.WhereIF(appStacker.StackerId != default, w => w.StackerId == appStacker.StackerId)
|
||||||
.WhereIF(appStacker.StackerName != default, w => w.StackerName == appStacker.StackerName)
|
.WhereIF(appStacker.StackerName != default, w => w.StackerName == appStacker.StackerName)
|
||||||
.WhereIF(appStacker.StackerStatus != default, w => w.StackerStatus == appStacker.StackerStatus)
|
.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.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);
|
.WhereIF(appStacker.Remark != default, w => w.Remark == appStacker.Remark);
|
||||||
return sqlFuc.ToList();
|
return sqlFuc.ToList();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user