数据库: - 新增 odf_checkin/odf_cables/odf_cable_faults/odf_cable_fault_images/odf_user_modules 5张表 - 新增菜单权限和角色分配 SQL 脚本 后台 API (.NET/SqlSugar): - 新增实体模型、DTO、Service、Controller (签到/光缆/故障/图片/用户模块) 前端 APP (UniApp): - 新增 portal/checkin/trunk/cable/fault-list/fault-detail/fault-add/trunk-search/route-plan 9个页面 - 新增 permission/checkin/trunk 服务层 - 新增 navigation/watermark 工具函数 后台管理前端 (ZR.Vue): - 新增光缆管理/干线故障管理/签到记录管理/用户模块权限 4个管理页面 - 新增对应 API 模块和表单组件
129 lines
4.2 KiB
C#
129 lines
4.2 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>
|
||
/// <returns></returns>
|
||
public PagedInfo<OdfCables> GetList(OdfCablesQueryDto parm)
|
||
{
|
||
var predicate = Expressionable.Create<OdfCables>();
|
||
|
||
predicate = predicate.AndIF(parm.DeptId != null, it => it.DeptId == parm.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();
|
||
|
||
return new { cables, faults };
|
||
}
|
||
|
||
/// <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>
|
||
/// <returns></returns>
|
||
public PagedInfo<OdfCables> ExportList(OdfCablesQueryDto parm)
|
||
{
|
||
parm.PageNum = 1;
|
||
parm.PageSize = 100000;
|
||
return GetList(parm);
|
||
}
|
||
}
|
||
}
|