<add>[important]添加db地址接口逻辑
This commit is contained in:
parent
caae20fe04
commit
50b0dbd599
|
|
@ -33,10 +33,4 @@ public class EditeDBRequest
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonPropertyName("remark")]
|
[JsonPropertyName("remark")]
|
||||||
public string? Remark { get; set; }
|
public string? Remark { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 是否是编辑状态
|
|
||||||
/// </summary>
|
|
||||||
[JsonPropertyName("isEdite")]
|
|
||||||
public bool IsEdite { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace WcsMain.ApiServe.Controllers.Dto.WcsDto.DB;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回PLCDB块同时返回 PLC名称的请求实体
|
||||||
|
/// </summary>
|
||||||
|
public class GetDBWithPlcNameRequest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// DB 名称
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("dbName")]
|
||||||
|
public string? DBName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// plc编号
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("plcId")]
|
||||||
|
public int? PlcId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace WcsMain.ApiServe.Controllers.Dto.WcsDto.DB;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回PLCDB块同时返回 PLC名称的响应实体
|
||||||
|
/// </summary>
|
||||||
|
public class GetDBWithPlcNameResponse
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// plc ID
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("plcId")]
|
||||||
|
public int? PlcId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// plc 名称
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("plcName")]
|
||||||
|
public string? PlcName { get; set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// db的名称
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("dbName")]
|
||||||
|
public string? DBName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// db 地址
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("dbAddress")]
|
||||||
|
public string? DBAddress { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否系统级别
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("isSystem")]
|
||||||
|
public int? IsSystem { get; set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 备注
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("remark")]
|
||||||
|
public string? Remark { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -31,7 +31,7 @@ public class PlcDbController(PlcDbService plcDbService) : ControllerBase
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("editeDB")]
|
[HttpPost("addOrUpdate")]
|
||||||
public WcsApiResponse EditeDB([FromBody] EditeDBRequest request)
|
public WcsApiResponse EditeDB([FromBody] EditeDBRequest request)
|
||||||
{
|
{
|
||||||
return _plcDbService.EditePlc(request);
|
return _plcDbService.EditePlc(request);
|
||||||
|
|
@ -48,4 +48,15 @@ public class PlcDbController(PlcDbService plcDbService) : ControllerBase
|
||||||
return _plcDbService.DeleteDB(dbName);
|
return _plcDbService.DeleteDB(dbName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询 db 同时返回 PLC名称
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("getDBWithPlcName")]
|
||||||
|
public WcsApiResponse<List<GetDBWithPlcNameResponse>> GetDBWithPlcName(GetDBWithPlcNameRequest request)
|
||||||
|
{
|
||||||
|
return _plcDbService.GetDBWithPlcName(request);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -49,7 +49,12 @@ public class PlcDbService(AppDBDao dBDao)
|
||||||
IsSystem = request.IsSystem,
|
IsSystem = request.IsSystem,
|
||||||
Remark = request.Remark
|
Remark = request.Remark
|
||||||
};
|
};
|
||||||
if (request.IsEdite)
|
List<AppDB>? dBs = _dBDao.Select(new AppDB { DBName = request.DbName});
|
||||||
|
if(dBs == default)
|
||||||
|
{
|
||||||
|
return WcsApiResponseFactory.DataBaseErr();
|
||||||
|
}
|
||||||
|
if (dBs.Count > 0)
|
||||||
{
|
{
|
||||||
// 修改信息
|
// 修改信息
|
||||||
var result = _dBDao.Update(db);
|
var result = _dBDao.Update(db);
|
||||||
|
|
@ -78,4 +83,19 @@ public class PlcDbService(AppDBDao dBDao)
|
||||||
var result = _dBDao.Delete(new AppDB() { DBName = dbName });
|
var result = _dBDao.Delete(new AppDB() { DBName = dbName });
|
||||||
return result > 0 ? WcsApiResponseFactory.Success() : WcsApiResponseFactory.DataBaseErr();
|
return result > 0 ? WcsApiResponseFactory.Success() : WcsApiResponseFactory.DataBaseErr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询 PLCDB地址,同时返回PLC名称
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public WcsApiResponse<List<GetDBWithPlcNameResponse>> GetDBWithPlcName(GetDBWithPlcNameRequest request)
|
||||||
|
{
|
||||||
|
List<GetDBWithPlcNameResponse>? dbs = _dBDao.QueryWithPlcName(new AppDB { PlcId = request.PlcId, DBName = request.DBName });
|
||||||
|
if (dbs == default)
|
||||||
|
{
|
||||||
|
return WcsApiResponseFactory.DataBaseErr<List<GetDBWithPlcNameResponse>>();
|
||||||
|
}
|
||||||
|
return WcsApiResponseFactory.Success(dbs, "查询成功");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using WcsMain.Common;
|
using WcsMain.ApiServe.Controllers.Dto.WcsDto.DB;
|
||||||
|
using WcsMain.Common;
|
||||||
using WcsMain.DataBase.TableEntity;
|
using WcsMain.DataBase.TableEntity;
|
||||||
using WcsMain.WcsAttribute.AutoFacAttribute;
|
using WcsMain.WcsAttribute.AutoFacAttribute;
|
||||||
|
|
||||||
|
|
@ -109,4 +110,37 @@ public class AppDBDao
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<AppDB>? Select() => Select(new AppDB());
|
public List<AppDB>? Select() => Select(new AppDB());
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询所有DB地址,同时返回PLC名称
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="appDB"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<GetDBWithPlcNameResponse>? QueryWithPlcName(AppDB appDB)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sqlFuc = CommonTool.DbServe.Queryable<AppDB>()
|
||||||
|
.LeftJoin<AppPLC>((db, plc) => db.PlcId == plc.PLCId)
|
||||||
|
.WhereIF(!string.IsNullOrEmpty(appDB.DBName), db => db.DBName!.Contains(appDB.DBName!))
|
||||||
|
.WhereIF(appDB.PlcId != default, db => db.PlcId == appDB.PlcId)
|
||||||
|
.OrderBy(db => new { db.PlcId, db.DBName })
|
||||||
|
.Select((db, plc) => new GetDBWithPlcNameResponse
|
||||||
|
{
|
||||||
|
PlcId = db.PlcId,
|
||||||
|
PlcName = plc.PLCName,
|
||||||
|
DBName = db.DBName,
|
||||||
|
DBAddress = db.DBAddress,
|
||||||
|
IsSystem = db.IsSystem,
|
||||||
|
Remark = db.Remark,
|
||||||
|
});
|
||||||
|
return sqlFuc.ToList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_ = ex;
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user