<add>[important]添加PLC管理相关接口
This commit is contained in:
parent
fcb5b72d4f
commit
caae20fe04
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Text.Json.Serialization;
|
using DataCheck;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace WcsMain.ApiServe.Controllers.Dto.WcsDto.PLC;
|
namespace WcsMain.ApiServe.Controllers.Dto.WcsDto.PLC;
|
||||||
|
|
||||||
|
|
@ -7,16 +8,11 @@ namespace WcsMain.ApiServe.Controllers.Dto.WcsDto.PLC;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EditePLCRequest
|
public class EditePLCRequest
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 是否处于编辑模式
|
|
||||||
/// </summary>
|
|
||||||
[JsonPropertyName("isEdite")]
|
|
||||||
public bool IsEdite { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// PLC的编号
|
/// PLC的编号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonPropertyName("plcId")]
|
[JsonPropertyName("plcId")]
|
||||||
|
[DataRules]
|
||||||
public int? PlcId { get; set; }
|
public int? PlcId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -25,6 +21,12 @@ public class EditePLCRequest
|
||||||
[JsonPropertyName("plcIp")]
|
[JsonPropertyName("plcIp")]
|
||||||
public string? PlcIp { get; set; }
|
public string? PlcIp { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PLC 的名称
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("plcName")]
|
||||||
|
public string? PlcName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 机架
|
/// 机架
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -35,4 +35,16 @@ public class PlcController(PlcService plcService) : ControllerBase
|
||||||
{
|
{
|
||||||
return _plcService.EditePlc(request);
|
return _plcService.EditePlc(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加或者修改配置项
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpDelete("deletePlc")]
|
||||||
|
public WcsApiResponse DeletePlc([FromQuery(Name = "plcId")] int? plcId)
|
||||||
|
{
|
||||||
|
return _plcService.DeletePlc(plcId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using DataCheck;
|
using DataCheck;
|
||||||
|
using System.Collections.Generic;
|
||||||
using WcsMain.ApiServe.Controllers.Dto;
|
using WcsMain.ApiServe.Controllers.Dto;
|
||||||
using WcsMain.ApiServe.Controllers.Dto.WcsDto.PLC;
|
using WcsMain.ApiServe.Controllers.Dto.WcsDto.PLC;
|
||||||
using WcsMain.ApiServe.Factory;
|
using WcsMain.ApiServe.Factory;
|
||||||
|
|
@ -42,13 +43,20 @@ public class PlcService(AppPLCDao pLCDao)
|
||||||
{
|
{
|
||||||
PLCId = Convert.ToInt32(request.PlcId),
|
PLCId = Convert.ToInt32(request.PlcId),
|
||||||
PLCIp = request.PlcIp,
|
PLCIp = request.PlcIp,
|
||||||
|
PLCName = request.PlcName,
|
||||||
PLCKind = request.PlcKind,
|
PLCKind = request.PlcKind,
|
||||||
PLCRack = request.Rack,
|
PLCRack = request.Rack,
|
||||||
PLCSlot = request.Slot,
|
PLCSlot = request.Slot,
|
||||||
PLCStatus = request.PlcStatus,
|
PLCStatus = request.PlcStatus,
|
||||||
Remark = request.Remark
|
Remark = request.Remark
|
||||||
};
|
};
|
||||||
if (request.IsEdite)
|
/* 判断这个编号是否存在 */
|
||||||
|
List <AppPLC>? appPLCs = _plcDao.Query(new AppPLC { PLCId = request.PlcId});
|
||||||
|
if (appPLCs == default)
|
||||||
|
{
|
||||||
|
return WcsApiResponseFactory.DataBaseErr();
|
||||||
|
}
|
||||||
|
if (appPLCs.Count > 0)
|
||||||
{
|
{
|
||||||
// 修改信息
|
// 修改信息
|
||||||
var result = _plcDao.Update(plc);
|
var result = _plcDao.Update(plc);
|
||||||
|
|
@ -60,6 +68,17 @@ public class PlcService(AppPLCDao pLCDao)
|
||||||
var result = _plcDao.Insert(plc);
|
var result = _plcDao.Insert(plc);
|
||||||
return result > 0 ? WcsApiResponseFactory.Success() : WcsApiResponseFactory.DataBaseErr();
|
return result > 0 ? WcsApiResponseFactory.Success() : WcsApiResponseFactory.DataBaseErr();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除一条数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="plcId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public WcsApiResponse DeletePlc(int? plcId)
|
||||||
|
{
|
||||||
|
if(plcId == default) return WcsApiResponseFactory.RequestErr();
|
||||||
|
var result = _plcDao.Delete(new AppPLC { PLCId = plcId });
|
||||||
|
return result > 0 ? WcsApiResponseFactory.Success() : WcsApiResponseFactory.DataBaseErr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -27,6 +27,35 @@ public class AppPLCDao
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据条件查询
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="plc"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<AppPLC>? Query(AppPLC plc)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sqlFuc = CommonTool.DbServe.Queryable<AppPLC>()
|
||||||
|
.WhereIF(plc.PLCId != default, w=>w.PLCId == plc.PLCId)
|
||||||
|
.WhereIF(plc.PLCIp != default, w => w.PLCIp == plc.PLCIp)
|
||||||
|
.WhereIF(plc.PLCName != default, w => w.PLCName == plc.PLCName)
|
||||||
|
.WhereIF(plc.PLCStatus != default, w => w.PLCStatus == plc.PLCStatus)
|
||||||
|
.WhereIF(plc.PLCKind != default, w => w.PLCKind == plc.PLCKind)
|
||||||
|
.WhereIF(plc.PLCRack != default, w => w.PLCRack == plc.PLCRack)
|
||||||
|
.WhereIF(plc.PLCSlot != default, w => w.PLCSlot == plc.PLCSlot)
|
||||||
|
.OrderBy(o => o.PLCId);
|
||||||
|
var ss = sqlFuc.ToSql();
|
||||||
|
return sqlFuc.ToList();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_ = ex;
|
||||||
|
}
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据主键返回更新条数
|
/// 根据主键返回更新条数
|
||||||
|
|
@ -69,6 +98,26 @@ public class AppPLCDao
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除一行数据,根据主键
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="plcInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Delete(AppPLC plcInfo)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sqlFuc = CommonTool.DbServe.Deleteable(plcInfo);
|
||||||
|
return sqlFuc.ExecuteCommand();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_ = ex;
|
||||||
|
}
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据状态查询PLC数据
|
/// 根据状态查询PLC数据
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,21 @@ public class AppPLC
|
||||||
[JsonPropertyName("plcIp")]
|
[JsonPropertyName("plcIp")]
|
||||||
public string? PLCIp { get; set; }
|
public string? PLCIp { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PLC 名称
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "plc_name")]
|
||||||
|
[JsonPropertyName("plcName")]
|
||||||
|
public string? PLCName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PLC 状态,是否启用
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "plc_status")]
|
||||||
|
[JsonPropertyName("plcStatus")]
|
||||||
|
public int? PLCStatus { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// PLC 系列
|
/// PLC 系列
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -50,12 +65,7 @@ public class AppPLC
|
||||||
[JsonPropertyName("slot")]
|
[JsonPropertyName("slot")]
|
||||||
public int? PLCSlot { get; set; }
|
public int? PLCSlot { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// PLC 状态,是否启用
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnName = "plc_status")]
|
|
||||||
[JsonPropertyName("plcStatus")]
|
|
||||||
public int? PLCStatus { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 备注信息
|
/// 备注信息
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user