All checks were successful
continuous-integration/drone/push Build is passing
- Add marker pole CRUD functionality with database tables (odf_marker_poles, odf_marker_pole_images) - Implement marker pole API endpoints and service layer with data isolation by department - Add UniApp pages for marker pole list, detail, and creation workflows - Add Vue management backend pages for marker pole and audit log management - Implement audit logging system via ActionFilter to track all business entity modifications - Extend search API to include marker poles in results alongside cables and faults - Add OdfAuditLogsController and service for querying audit trail data - Update optical box detail page with left-right frame color scheme (green-orange) - Add cable type page as entry point for marker poles and fault lists - Create database migration scripts for v1.2.0 schema and permissions - Add DeptDataScopeHelper for department-based data access control - Update MCP settings to disable SQL Server connection and fix formatting - Add marker pole service integration in UniApp with COS image upload support
151 lines
5.3 KiB
C#
151 lines
5.3 KiB
C#
using Infrastructure.Attribute;
|
||
using ZR.Model;
|
||
using ZR.Model.Business;
|
||
using ZR.Model.Business.Dto;
|
||
using ZR.Repository;
|
||
using ZR.Service.Business.IBusinessService;
|
||
|
||
namespace ZR.Service.Business
|
||
{
|
||
/// <summary>
|
||
/// 光缆管理Service业务层处理
|
||
/// </summary>
|
||
[AppService(ServiceType = typeof(IOdfCablesService), ServiceLifetime = LifeTime.Transient)]
|
||
public class OdfCablesService : BaseService<OdfCables>, IOdfCablesService
|
||
{
|
||
/// <summary>
|
||
/// 按 DeptId 过滤光缆列表(支持分页和 CableName 模糊查询),应用部门数据隔离
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <param name="deptId">当前用户所属部门ID,用于数据隔离</param>
|
||
/// <returns></returns>
|
||
public PagedInfo<OdfCables> GetList(OdfCablesQueryDto parm, long deptId)
|
||
{
|
||
var predicate = Expressionable.Create<OdfCables>();
|
||
|
||
// 部门数据隔离:查询本级及所有下级部门的数据
|
||
var visibleDeptIds = DeptDataScopeHelper.GetVisibleDeptIds(Context, deptId);
|
||
predicate = predicate.And(it => visibleDeptIds.Contains(it.DeptId));
|
||
|
||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CableName), it => it.CableName.Contains(parm.CableName));
|
||
|
||
var response = Queryable()
|
||
.Where(predicate.ToExpression())
|
||
.OrderByDescending(it => it.CreatedAt)
|
||
.ToPage(parm);
|
||
|
||
return response;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 在指定公司范围内搜索光缆、故障和标石/杆号牌
|
||
/// </summary>
|
||
/// <param name="deptId"></param>
|
||
/// <param name="keyword"></param>
|
||
/// <returns></returns>
|
||
public object Search(long deptId, string keyword)
|
||
{
|
||
// 搜索光缆:按 DeptId 过滤,CableName LIKE keyword
|
||
var cables = Queryable()
|
||
.Where(c => c.DeptId == deptId)
|
||
.WhereIF(!string.IsNullOrEmpty(keyword), c => c.CableName.Contains(keyword))
|
||
.Select(c => new { c.Id, c.CableName })
|
||
.ToList();
|
||
|
||
// 搜索故障:联查 odf_cables 按 DeptId 过滤,对 FaultReason/Mileage/Location LIKE keyword
|
||
var faults = Context.Queryable<OdfCableFaults>()
|
||
.LeftJoin<OdfCables>((f, c) => f.CableId == c.Id)
|
||
.Where((f, c) => c.DeptId == deptId)
|
||
.WhereIF(!string.IsNullOrEmpty(keyword), (f, c) =>
|
||
f.FaultReason.Contains(keyword) ||
|
||
f.Mileage.Contains(keyword) ||
|
||
f.Location.Contains(keyword))
|
||
.OrderByDescending((f, c) => f.FaultTime)
|
||
.Select((f, c) => new
|
||
{
|
||
f.Id,
|
||
f.FaultTime,
|
||
f.FaultReason,
|
||
f.Mileage,
|
||
CableName = c.CableName
|
||
})
|
||
.ToList();
|
||
|
||
// 搜索标石/杆号牌:联查 odf_cables 按 DeptId 过滤,按 Name LIKE keyword
|
||
var markerPoles = Context.Queryable<OdfMarkerPoles>()
|
||
.LeftJoin<OdfCables>((m, c) => m.CableId == c.Id)
|
||
.Where((m, c) => c.DeptId == deptId)
|
||
.WhereIF(!string.IsNullOrEmpty(keyword), (m, c) => m.Name.Contains(keyword))
|
||
.OrderByDescending((m, c) => m.RecordTime)
|
||
.Select((m, c) => new
|
||
{
|
||
m.Id,
|
||
m.Name,
|
||
m.RecordTime,
|
||
m.Personnel,
|
||
m.CableId,
|
||
CableName = c.CableName
|
||
})
|
||
.ToList();
|
||
|
||
return new { cables, faults, markerPoles };
|
||
}
|
||
|
||
/// <summary>
|
||
/// 新增光缆
|
||
/// </summary>
|
||
/// <param name="model"></param>
|
||
/// <returns></returns>
|
||
public OdfCables Add(OdfCables model)
|
||
{
|
||
model.CreatedAt = DateTime.Now;
|
||
model.UpdatedAt = DateTime.Now;
|
||
return Insertable(model).ExecuteReturnEntity();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 修改光缆
|
||
/// </summary>
|
||
/// <param name="model"></param>
|
||
/// <returns></returns>
|
||
public int Update(OdfCables model)
|
||
{
|
||
model.UpdatedAt = DateTime.Now;
|
||
return base.Update(model, true);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除光缆
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <returns></returns>
|
||
public int Delete(int id)
|
||
{
|
||
return base.Delete(id);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取光缆详情
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <returns></returns>
|
||
public OdfCables GetDetail(int id)
|
||
{
|
||
return GetFirst(x => x.Id == id);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 导出光缆列表
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <param name="deptId">当前用户所属部门ID,用于数据隔离</param>
|
||
/// <returns></returns>
|
||
public PagedInfo<OdfCables> ExportList(OdfCablesQueryDto parm, long deptId)
|
||
{
|
||
parm.PageNum = 1;
|
||
parm.PageSize = 100000;
|
||
return GetList(parm, deptId);
|
||
}
|
||
}
|
||
}
|