09-23-抢修,报修优化
This commit is contained in:
		| @ -0,0 +1,119 @@ | ||||
| package org.dromara.inspection.controller; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import jakarta.servlet.http.HttpServletResponse; | ||||
| import jakarta.validation.constraints.*; | ||||
| import cn.dev33.satoken.annotation.SaCheckPermission; | ||||
| import org.dromara.inspection.domain.vo.OpsInspectionReportRecordVo; | ||||
| import org.dromara.inspection.service.impl.OpsInspectionRepairServiceImpl; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.dromara.common.idempotent.annotation.RepeatSubmit; | ||||
| import org.dromara.common.log.annotation.Log; | ||||
| import org.dromara.common.web.core.BaseController; | ||||
| import org.dromara.common.mybatis.core.page.PageQuery; | ||||
| import org.dromara.common.core.domain.R; | ||||
| import org.dromara.common.core.validate.AddGroup; | ||||
| import org.dromara.common.core.validate.EditGroup; | ||||
| import org.dromara.common.log.enums.BusinessType; | ||||
| import org.dromara.common.excel.utils.ExcelUtil; | ||||
| import org.dromara.inspection.domain.vo.OpsInspectionRepairVo; | ||||
| import org.dromara.inspection.domain.bo.OpsInspectionRepairBo; | ||||
| import org.dromara.inspection.service.IOpsInspectionRepairService; | ||||
| import org.dromara.common.mybatis.core.page.TableDataInfo; | ||||
|  | ||||
| /** | ||||
|  * 运维-巡检-抢修 | ||||
|  * 前端访问路由地址为:/inspection/repair | ||||
|  * | ||||
|  * @author LionLi | ||||
|  * @date 2025-09-22 | ||||
|  */ | ||||
| @Validated | ||||
| @RequiredArgsConstructor | ||||
| @RestController | ||||
| @RequestMapping("/repair") | ||||
| public class OpsInspectionRepairController extends BaseController { | ||||
|  | ||||
|     private final OpsInspectionRepairServiceImpl opsInspectionRepairService; | ||||
|  | ||||
|     /** | ||||
|      * 查询运维-巡检-抢修列表 | ||||
|      */ | ||||
|     @SaCheckPermission("inspection:repair:list") | ||||
|     @GetMapping("/list") | ||||
|     public TableDataInfo<OpsInspectionRepairVo> list(OpsInspectionRepairBo bo, PageQuery pageQuery) { | ||||
|         return opsInspectionRepairService.queryPageList(bo, pageQuery); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 导出运维-巡检-抢修列表 | ||||
|      */ | ||||
|     @SaCheckPermission("inspection:repair:export") | ||||
|     @Log(title = "运维-巡检-抢修", businessType = BusinessType.EXPORT) | ||||
|     @PostMapping("/export") | ||||
|     public void export(OpsInspectionRepairBo bo, HttpServletResponse response) { | ||||
|         List<OpsInspectionRepairVo> list = opsInspectionRepairService.queryList(bo); | ||||
|         ExcelUtil.exportExcel(list, "运维-巡检-抢修", OpsInspectionRepairVo.class, response); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 获取运维-巡检-抢修详细信息 | ||||
|      * | ||||
|      * @param id 主键 | ||||
|      */ | ||||
|     @SaCheckPermission("inspection:repair:query") | ||||
|     @GetMapping("/{id}") | ||||
|     public R<OpsInspectionRepairVo> getInfo(@NotNull(message = "主键不能为空") | ||||
|                                      @PathVariable("id") Long id) { | ||||
|         return R.ok(opsInspectionRepairService.queryById(id)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 新增运维-巡检-抢修 | ||||
|      */ | ||||
|     @SaCheckPermission("inspection:repair:add") | ||||
|     @Log(title = "运维-巡检-抢修", businessType = BusinessType.INSERT) | ||||
|     @RepeatSubmit() | ||||
|     @PostMapping() | ||||
|     public R<Void> add(@Validated(AddGroup.class) @RequestBody OpsInspectionRepairBo bo) { | ||||
|         return toAjax(opsInspectionRepairService.insertByBo(bo)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 修改运维-巡检-抢修 | ||||
|      */ | ||||
|     @SaCheckPermission("inspection:repair:edit") | ||||
|     @Log(title = "运维-巡检-抢修", businessType = BusinessType.UPDATE) | ||||
|     @RepeatSubmit() | ||||
|     @PutMapping() | ||||
|     public R<Void> edit(@Validated(EditGroup.class) @RequestBody OpsInspectionRepairBo bo) { | ||||
|         return toAjax(opsInspectionRepairService.updateByBo(bo)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 删除运维-巡检-抢修 | ||||
|      * | ||||
|      * @param ids 主键串 | ||||
|      */ | ||||
|     @SaCheckPermission("inspection:repair:remove") | ||||
|     @Log(title = "运维-巡检-抢修", businessType = BusinessType.DELETE) | ||||
|     @DeleteMapping("/{ids}") | ||||
|     public R<Void> remove(@NotEmpty(message = "主键不能为空") | ||||
|                           @PathVariable("ids") Long[] ids) { | ||||
|         return toAjax(opsInspectionRepairService.deleteWithValidByIds(List.of(ids), true)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 生成纪录 | ||||
|      */ | ||||
|     @SaCheckPermission("inspection:repair:record") | ||||
|     @GetMapping("/record") | ||||
|     public R<OpsInspectionReportRecordVo> record(@RequestParam Long projectId){ | ||||
|  | ||||
|         return opsInspectionRepairService.record(projectId); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -7,6 +7,7 @@ import jakarta.servlet.http.HttpServletResponse; | ||||
| import jakarta.validation.constraints.*; | ||||
| import cn.dev33.satoken.annotation.SaCheckPermission; | ||||
| import org.dromara.inspection.domain.vo.OpsInspectionReportRecordVo; | ||||
| import org.dromara.inspection.service.impl.OpsInspectionReportServiceImpl; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.dromara.common.idempotent.annotation.RepeatSubmit; | ||||
| @ -37,7 +38,7 @@ import org.springframework.web.multipart.MultipartFile; | ||||
| @RequestMapping("/report") | ||||
| public class OpsInspectionReportController extends BaseController { | ||||
|  | ||||
|     private final IOpsInspectionReportService opsInspectionReportService; | ||||
|     private final OpsInspectionReportServiceImpl opsInspectionReportService; | ||||
|  | ||||
|     /** | ||||
|      * 查询运维-巡检-报修列表 | ||||
| @ -113,7 +114,7 @@ public class OpsInspectionReportController extends BaseController { | ||||
|     @GetMapping("/record") | ||||
|     public R<OpsInspectionReportRecordVo> record(@RequestParam Long projectId){ | ||||
|  | ||||
|         return null; | ||||
|         return opsInspectionReportService.record(projectId); | ||||
|     } | ||||
|  | ||||
| } | ||||
|  | ||||
| @ -0,0 +1,112 @@ | ||||
| package org.dromara.inspection.domain; | ||||
|  | ||||
| import org.dromara.common.mybatis.core.domain.BaseEntity; | ||||
| import com.baomidou.mybatisplus.annotation.*; | ||||
| import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | ||||
| import java.util.Date; | ||||
|  | ||||
| import java.io.Serial; | ||||
|  | ||||
| /** | ||||
|  * 运维-巡检-抢修对象 ops_inspection_repair | ||||
|  * | ||||
|  * @author LionLi | ||||
|  * @date 2025-09-22 | ||||
|  */ | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @TableName("ops_inspection_repair") | ||||
| public class OpsInspectionRepair extends BaseEntity { | ||||
|  | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * | ||||
|      */ | ||||
|     @TableId(value = "id") | ||||
|     private Long id; | ||||
|  | ||||
|     /** | ||||
|      * | ||||
|      */ | ||||
|     private Long projectId; | ||||
|  | ||||
|     /** | ||||
|      * 1常规2紧急3致命 | ||||
|      */ | ||||
|     private String level; | ||||
|  | ||||
|     /** | ||||
|      * 1待处理2处理中3已完成 | ||||
|      */ | ||||
|     private String status; | ||||
|  | ||||
|     /** | ||||
|      * 抢修类型1电力2设备3供水4网络5设施 | ||||
|      */ | ||||
|     private String type; | ||||
|  | ||||
|     /** | ||||
|      * 报修名称 | ||||
|      */ | ||||
|     private String name; | ||||
|  | ||||
|     /** | ||||
|      * 指派维修人 | ||||
|      */ | ||||
|     private Long sendPerson; | ||||
|  | ||||
|     /** | ||||
|      * 详细信息 | ||||
|      */ | ||||
|     private String reportInfo; | ||||
|  | ||||
|     /** | ||||
|      * 故障位置 | ||||
|      */ | ||||
|     private String position; | ||||
|  | ||||
|     /** | ||||
|      * 文件IDS | ||||
|      */ | ||||
|     private String fileId; | ||||
|  | ||||
|     /** | ||||
|      * 文件路径 | ||||
|      */ | ||||
|     private String fileUrl; | ||||
|  | ||||
|     /** | ||||
|      * 报修人姓名 | ||||
|      */ | ||||
|     private String reportName; | ||||
|  | ||||
|     /** | ||||
|      * 报修人联系电话 | ||||
|      */ | ||||
|     private String reportPhone; | ||||
|  | ||||
|     /** | ||||
|      * 维修结果 | ||||
|      */ | ||||
| //    private String reportFinal; | ||||
|  | ||||
|     /** | ||||
|      * 预计完成时间 | ||||
|      */ | ||||
|     private String expectedTime; | ||||
|  | ||||
|     /** | ||||
|      * 完成时间 | ||||
|      */ | ||||
|     private Date reportFinishTime; | ||||
|  | ||||
|     /** | ||||
|      * 支援,1需要2不需要 | ||||
|      */ | ||||
|     private String support; | ||||
|  | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,124 @@ | ||||
| package org.dromara.inspection.domain.bo; | ||||
|  | ||||
| import org.dromara.inspection.domain.OpsInspectionRepair; | ||||
| import org.dromara.common.mybatis.core.domain.BaseEntity; | ||||
| import org.dromara.common.core.validate.AddGroup; | ||||
| import org.dromara.common.core.validate.EditGroup; | ||||
| import io.github.linpeilie.annotations.AutoMapper; | ||||
| import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | ||||
| import jakarta.validation.constraints.*; | ||||
| import java.util.Date; | ||||
|  | ||||
| /** | ||||
|  * 运维-巡检-抢修业务对象 ops_inspection_repair | ||||
|  * | ||||
|  * @author LionLi | ||||
|  * @date 2025-09-22 | ||||
|  */ | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @AutoMapper(target = OpsInspectionRepair.class, reverseConvertGenerate = false) | ||||
| public class OpsInspectionRepairBo extends BaseEntity { | ||||
|  | ||||
|     /** | ||||
|      * | ||||
|      */ | ||||
|     private Long id; | ||||
|  | ||||
|     /** | ||||
|      * | ||||
|      */ | ||||
|     @NotNull(message = "不能为空", groups = { AddGroup.class, EditGroup.class }) | ||||
|     private Long projectId; | ||||
|  | ||||
|     /** | ||||
|      * 1常规2紧急3致命 | ||||
|      */ | ||||
|     @NotBlank(message = "1常规2紧急3致命不能为空", groups = { AddGroup.class, EditGroup.class }) | ||||
|     private String level; | ||||
|  | ||||
|     /** | ||||
|      * 1待处理2处理中3已完成 | ||||
|      */ | ||||
|     @NotBlank(message = "1待处理2处理中3已完成不能为空", groups = { AddGroup.class, EditGroup.class }) | ||||
|     private String status; | ||||
|  | ||||
|     /** | ||||
|      * 抢修类型1电力2设备3供水4网络5设施 | ||||
|      */ | ||||
|     @NotBlank(message = "抢修类型1电力2设备3供水4网络5设施不能为空", groups = { AddGroup.class, EditGroup.class }) | ||||
|     private String type; | ||||
|  | ||||
|     /** | ||||
|      * 报修名称 | ||||
|      */ | ||||
|     @NotBlank(message = "报修名称不能为空", groups = { AddGroup.class, EditGroup.class }) | ||||
|     private String name; | ||||
|  | ||||
|     /** | ||||
|      * 指派维修人 | ||||
|      */ | ||||
| //    @NotNull(message = "指派维修人不能为空", groups = { AddGroup.class, EditGroup.class }) | ||||
|     private Long sendPerson; | ||||
|  | ||||
|     /** | ||||
|      * 详细信息 | ||||
|      */ | ||||
|     @NotBlank(message = "详细信息不能为空", groups = { AddGroup.class, EditGroup.class }) | ||||
|     private String reportInfo; | ||||
|  | ||||
|     /** | ||||
|      * 故障位置 | ||||
|      */ | ||||
|     @NotBlank(message = "故障位置不能为空", groups = { AddGroup.class, EditGroup.class }) | ||||
|     private String position; | ||||
|  | ||||
|     /** | ||||
|      * 文件IDS | ||||
|      */ | ||||
|     private String fileId; | ||||
|  | ||||
|     /** | ||||
|      * 文件路径 | ||||
|      */ | ||||
|     private String fileUrl; | ||||
|  | ||||
|     /** | ||||
|      * 报修人姓名 | ||||
|      */ | ||||
|     @NotBlank(message = "报修人姓名不能为空", groups = { AddGroup.class, EditGroup.class }) | ||||
|     private String reportName; | ||||
|  | ||||
|     /** | ||||
|      * 报修人联系电话 | ||||
|      */ | ||||
|     @NotBlank(message = "报修人联系电话不能为空", groups = { AddGroup.class, EditGroup.class }) | ||||
|     private String reportPhone; | ||||
|  | ||||
|     /** | ||||
|      * 维修结果 | ||||
|      */ | ||||
| //    @NotBlank(message = "维修结果不能为空", groups = { AddGroup.class, EditGroup.class }) | ||||
| //    private String reportFinal; | ||||
|  | ||||
|     /** | ||||
|      * 预计完成时间 | ||||
|      */ | ||||
|     @NotBlank(message = "预计完成时间不能为空", groups = { AddGroup.class, EditGroup.class }) | ||||
|     private String expectedTime; | ||||
|  | ||||
|     /** | ||||
|      * 完成时间 | ||||
|      */ | ||||
| //    @NotNull(message = "完成时间不能为空", groups = { AddGroup.class, EditGroup.class }) | ||||
|     private Date reportFinishTime; | ||||
|  | ||||
|     /** | ||||
|      * 支援,1需要2不需要 | ||||
|      */ | ||||
|     @NotBlank(message = "支援,1需要2不需要不能为空", groups = { AddGroup.class, EditGroup.class }) | ||||
|     private String support; | ||||
|  | ||||
|  | ||||
| } | ||||
| @ -59,7 +59,7 @@ public class OpsInspectionReportBo extends BaseEntity { | ||||
|     /** | ||||
|      * 指派维修人 | ||||
|      */ | ||||
|     @NotNull(message = "指派维修人不能为空", groups = { AddGroup.class, EditGroup.class }) | ||||
| //    @NotNull(message = "指派维修人不能为空", groups = { AddGroup.class, EditGroup.class }) | ||||
|     private Long sendPerson; | ||||
|  | ||||
|     /** | ||||
|  | ||||
| @ -0,0 +1,141 @@ | ||||
| package org.dromara.inspection.domain.vo; | ||||
|  | ||||
| import java.util.Date; | ||||
|  | ||||
| import org.dromara.inspection.domain.OpsInspectionRepair; | ||||
| import cn.idev.excel.annotation.ExcelIgnoreUnannotated; | ||||
| import cn.idev.excel.annotation.ExcelProperty; | ||||
| import io.github.linpeilie.annotations.AutoMapper; | ||||
| import lombok.Data; | ||||
| import org.dromara.personnel.domain.vo.OpsUserVo; | ||||
|  | ||||
| import java.io.Serial; | ||||
| import java.io.Serializable; | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * 运维-巡检-抢修视图对象 ops_inspection_repair | ||||
|  * | ||||
|  * @author LionLi | ||||
|  * @date 2025-09-22 | ||||
|  */ | ||||
| @Data | ||||
| @ExcelIgnoreUnannotated | ||||
| @AutoMapper(target = OpsInspectionRepair.class) | ||||
| public class OpsInspectionRepairVo implements Serializable { | ||||
|  | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * | ||||
|      */ | ||||
|     @ExcelProperty(value = "") | ||||
|     private Long id; | ||||
|  | ||||
|     /** | ||||
|      * | ||||
|      */ | ||||
|     @ExcelProperty(value = "") | ||||
|     private Long projectId; | ||||
|  | ||||
|     /** | ||||
|      * 1常规2紧急3致命 | ||||
|      */ | ||||
|     @ExcelProperty(value = "1常规2紧急3致命") | ||||
|     private String level; | ||||
|  | ||||
|     /** | ||||
|      * 1待处理2处理中3已完成 | ||||
|      */ | ||||
|     @ExcelProperty(value = "1待处理2处理中3已完成") | ||||
|     private String status; | ||||
|  | ||||
|     /** | ||||
|      * 抢修类型1电力2设备3供水4网络5设施 | ||||
|      */ | ||||
|     @ExcelProperty(value = "抢修类型1电力2设备3供水4网络5设施") | ||||
|     private String type; | ||||
|  | ||||
|     /** | ||||
|      * 报修名称 | ||||
|      */ | ||||
|     @ExcelProperty(value = "报修名称") | ||||
|     private String name; | ||||
|  | ||||
|     /** | ||||
|      * 指派维修人 | ||||
|      */ | ||||
|     @ExcelProperty(value = "指派维修人") | ||||
|     private Long sendPerson; | ||||
|  | ||||
|     private OpsUserVo sendPersonVo; | ||||
|  | ||||
|     /** | ||||
|      * 详细信息 | ||||
|      */ | ||||
|     @ExcelProperty(value = "详细信息") | ||||
|     private String reportInfo; | ||||
|  | ||||
|     /** | ||||
|      * 故障位置 | ||||
|      */ | ||||
|     @ExcelProperty(value = "故障位置") | ||||
|     private String position; | ||||
|  | ||||
|     /** | ||||
|      * 文件IDS | ||||
|      */ | ||||
|     @ExcelProperty(value = "文件IDS") | ||||
|     private String fileId; | ||||
|  | ||||
|     /** | ||||
|      * 文件路径 | ||||
|      */ | ||||
|     @ExcelProperty(value = "文件路径") | ||||
|     private String fileUrl; | ||||
|  | ||||
|     /** | ||||
|      * 报修人姓名 | ||||
|      */ | ||||
|     @ExcelProperty(value = "报修人姓名") | ||||
|     private String reportName; | ||||
|  | ||||
|     /** | ||||
|      * 报修人联系电话 | ||||
|      */ | ||||
|     @ExcelProperty(value = "报修人联系电话") | ||||
|     private String reportPhone; | ||||
|  | ||||
|     /** | ||||
|      * 维修结果 | ||||
|      */ | ||||
| //    @ExcelProperty(value = "维修结果") | ||||
| //    private String reportFinal; | ||||
|  | ||||
|     /** | ||||
|      * 预计完成时间 | ||||
|      */ | ||||
|     @ExcelProperty(value = "预计完成时间") | ||||
|     private String expectedTime; | ||||
|  | ||||
|     /** | ||||
|      * 完成时间 | ||||
|      */ | ||||
|     @ExcelProperty(value = "完成时间") | ||||
|     private Date reportFinishTime; | ||||
|  | ||||
|     /** | ||||
|      * 支援,1需要2不需要 | ||||
|      */ | ||||
|     @ExcelProperty(value = "支援,1需要2不需要") | ||||
|     private String support; | ||||
|  | ||||
|     /** | ||||
|      * 分钟数 | ||||
|      */ | ||||
|     private String minute; | ||||
|  | ||||
|     private Date createTime; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,15 @@ | ||||
| package org.dromara.inspection.mapper; | ||||
|  | ||||
| import org.dromara.inspection.domain.OpsInspectionRepair; | ||||
| import org.dromara.inspection.domain.vo.OpsInspectionRepairVo; | ||||
| import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; | ||||
|  | ||||
| /** | ||||
|  * 运维-巡检-抢修Mapper接口 | ||||
|  * | ||||
|  * @author LionLi | ||||
|  * @date 2025-09-22 | ||||
|  */ | ||||
| public interface OpsInspectionRepairMapper extends BaseMapperPlus<OpsInspectionRepair, OpsInspectionRepairVo> { | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,68 @@ | ||||
| package org.dromara.inspection.service; | ||||
|  | ||||
| import org.dromara.inspection.domain.vo.OpsInspectionRepairVo; | ||||
| import org.dromara.inspection.domain.bo.OpsInspectionRepairBo; | ||||
| import org.dromara.common.mybatis.core.page.TableDataInfo; | ||||
| import org.dromara.common.mybatis.core.page.PageQuery; | ||||
|  | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 运维-巡检-抢修Service接口 | ||||
|  * | ||||
|  * @author LionLi | ||||
|  * @date 2025-09-22 | ||||
|  */ | ||||
| public interface IOpsInspectionRepairService { | ||||
|  | ||||
|     /** | ||||
|      * 查询运维-巡检-抢修 | ||||
|      * | ||||
|      * @param id 主键 | ||||
|      * @return 运维-巡检-抢修 | ||||
|      */ | ||||
|     OpsInspectionRepairVo queryById(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 分页查询运维-巡检-抢修列表 | ||||
|      * | ||||
|      * @param bo        查询条件 | ||||
|      * @param pageQuery 分页参数 | ||||
|      * @return 运维-巡检-抢修分页列表 | ||||
|      */ | ||||
|     TableDataInfo<OpsInspectionRepairVo> queryPageList(OpsInspectionRepairBo bo, PageQuery pageQuery); | ||||
|  | ||||
|     /** | ||||
|      * 查询符合条件的运维-巡检-抢修列表 | ||||
|      * | ||||
|      * @param bo 查询条件 | ||||
|      * @return 运维-巡检-抢修列表 | ||||
|      */ | ||||
|     List<OpsInspectionRepairVo> queryList(OpsInspectionRepairBo bo); | ||||
|  | ||||
|     /** | ||||
|      * 新增运维-巡检-抢修 | ||||
|      * | ||||
|      * @param bo 运维-巡检-抢修 | ||||
|      * @return 是否新增成功 | ||||
|      */ | ||||
|     Boolean insertByBo(OpsInspectionRepairBo bo); | ||||
|  | ||||
|     /** | ||||
|      * 修改运维-巡检-抢修 | ||||
|      * | ||||
|      * @param bo 运维-巡检-抢修 | ||||
|      * @return 是否修改成功 | ||||
|      */ | ||||
|     Boolean updateByBo(OpsInspectionRepairBo bo); | ||||
|  | ||||
|     /** | ||||
|      * 校验并批量删除运维-巡检-抢修信息 | ||||
|      * | ||||
|      * @param ids     待删除的主键集合 | ||||
|      * @param isValid 是否进行有效性校验 | ||||
|      * @return 是否删除成功 | ||||
|      */ | ||||
|     Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); | ||||
| } | ||||
| @ -0,0 +1,331 @@ | ||||
| package org.dromara.inspection.service.impl; | ||||
|  | ||||
| import org.apache.dubbo.config.annotation.DubboReference; | ||||
| import org.apache.seata.spring.annotation.GlobalTransactional; | ||||
| import org.dromara.common.core.domain.R; | ||||
| import org.dromara.common.core.utils.MapstructUtils; | ||||
| import org.dromara.common.core.utils.StringUtils; | ||||
| import org.dromara.common.mybatis.core.page.TableDataInfo; | ||||
| import org.dromara.common.mybatis.core.page.PageQuery; | ||||
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
| import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.dromara.inspection.domain.bo.OpsInspectionReportBo; | ||||
| import org.dromara.inspection.domain.vo.OpsInspectionReportRecordVo; | ||||
| import org.dromara.inspection.domain.vo.OpsInspectionReportVo; | ||||
| import org.dromara.inspection.service.IOpsInspectionRepairService; | ||||
| import org.dromara.personnel.domain.vo.OpsUserVo; | ||||
| import org.dromara.personnel.service.impl.OpsUserServiceImpl; | ||||
| import org.dromara.resource.api.RemoteFileService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.dromara.inspection.domain.bo.OpsInspectionRepairBo; | ||||
| import org.dromara.inspection.domain.vo.OpsInspectionRepairVo; | ||||
| import org.dromara.inspection.domain.OpsInspectionRepair; | ||||
| import org.dromara.inspection.mapper.OpsInspectionRepairMapper; | ||||
|  | ||||
| import java.math.BigDecimal; | ||||
| import java.math.RoundingMode; | ||||
| import java.time.LocalDate; | ||||
| import java.time.ZoneId; | ||||
| import java.util.*; | ||||
| import java.util.concurrent.TimeUnit; | ||||
|  | ||||
| /** | ||||
|  * 运维-巡检-抢修Service业务层处理 | ||||
|  * | ||||
|  * @author LionLi | ||||
|  * @date 2025-09-22 | ||||
|  */ | ||||
| @Slf4j | ||||
| @RequiredArgsConstructor | ||||
| @Service | ||||
| public class OpsInspectionRepairServiceImpl implements IOpsInspectionRepairService { | ||||
|  | ||||
|     private final OpsInspectionRepairMapper baseMapper; | ||||
|  | ||||
|     @DubboReference | ||||
|     private RemoteFileService remoteFileService; | ||||
|     @Autowired | ||||
|     private OpsUserServiceImpl opsUserService; | ||||
|  | ||||
|     /** | ||||
|      * 查询运维-巡检-抢修 | ||||
|      * | ||||
|      * @param id 主键 | ||||
|      * @return 运维-巡检-抢修 | ||||
|      */ | ||||
|     @Override | ||||
|     public OpsInspectionRepairVo queryById(Long id){ | ||||
|         OpsInspectionRepairVo vo = baseMapper.selectVoById(id); | ||||
|         List<OpsInspectionRepairVo> vo1 = List.of(vo); | ||||
|         setValue(vo1); | ||||
|         return vo1.getFirst(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 分页查询运维-巡检-抢修列表 | ||||
|      * | ||||
|      * @param bo        查询条件 | ||||
|      * @param pageQuery 分页参数 | ||||
|      * @return 运维-巡检-抢修分页列表 | ||||
|      */ | ||||
|     @Override | ||||
|     public TableDataInfo<OpsInspectionRepairVo> queryPageList(OpsInspectionRepairBo bo, PageQuery pageQuery) { | ||||
|         LambdaQueryWrapper<OpsInspectionRepair> lqw = buildQueryWrapper(bo); | ||||
|         Page<OpsInspectionRepairVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); | ||||
|         setValue(result.getRecords()); | ||||
|         return TableDataInfo.build(result); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 查询符合条件的运维-巡检-抢修列表 | ||||
|      * | ||||
|      * @param bo 查询条件 | ||||
|      * @return 运维-巡检-抢修列表 | ||||
|      */ | ||||
|     @Override | ||||
|     public List<OpsInspectionRepairVo> queryList(OpsInspectionRepairBo bo) { | ||||
|         LambdaQueryWrapper<OpsInspectionRepair> lqw = buildQueryWrapper(bo); | ||||
|         return baseMapper.selectVoList(lqw); | ||||
|     } | ||||
|  | ||||
|     private LambdaQueryWrapper<OpsInspectionRepair> buildQueryWrapper(OpsInspectionRepairBo bo) { | ||||
|         Map<String, Object> params = bo.getParams(); | ||||
|         LambdaQueryWrapper<OpsInspectionRepair> lqw = Wrappers.lambdaQuery(); | ||||
|         lqw.orderByAsc(OpsInspectionRepair::getId); | ||||
|         lqw.eq(bo.getProjectId() != null, OpsInspectionRepair::getProjectId, bo.getProjectId()); | ||||
|         lqw.eq(StringUtils.isNotBlank(bo.getLevel()), OpsInspectionRepair::getLevel, bo.getLevel()); | ||||
|         lqw.eq(StringUtils.isNotBlank(bo.getStatus()), OpsInspectionRepair::getStatus, bo.getStatus()); | ||||
|         lqw.eq(StringUtils.isNotBlank(bo.getType()), OpsInspectionRepair::getType, bo.getType()); | ||||
|         return lqw; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 新增运维-巡检-抢修 | ||||
|      * | ||||
|      * @param bo 运维-巡检-抢修 | ||||
|      * @return 是否新增成功 | ||||
|      */ | ||||
|     @Override | ||||
|     public Boolean insertByBo(OpsInspectionRepairBo bo) { | ||||
|         OpsInspectionRepair add = MapstructUtils.convert(bo, OpsInspectionRepair.class); | ||||
|         validEntityBeforeSave(add); | ||||
|  | ||||
|         if (add.getFileId() != null){ | ||||
|             String[] split = add.getFileId().split(","); | ||||
|             List<String> urls = new ArrayList<>(); | ||||
|             for (String s : split) { | ||||
|                 String ossUrl = remoteFileService.selectUrlByIds(s); | ||||
|                 if (ossUrl != null){ | ||||
|                     urls.add(ossUrl); | ||||
|                 } | ||||
|             } | ||||
|             String join = String.join(",", urls); | ||||
|             add.setFileUrl(join); | ||||
|             bo.setFileUrl(join); | ||||
|         } | ||||
|  | ||||
|         boolean flag = baseMapper.insert(add) > 0; | ||||
|         if (flag) { | ||||
|             bo.setId(add.getId()); | ||||
|         } | ||||
|         return flag; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 修改运维-巡检-抢修 | ||||
|      * | ||||
|      * @param bo 运维-巡检-抢修 | ||||
|      * @return 是否修改成功 | ||||
|      */ | ||||
|     @Override | ||||
|     public Boolean updateByBo(OpsInspectionRepairBo bo) { | ||||
|         OpsInspectionRepair update = MapstructUtils.convert(bo, OpsInspectionRepair.class); | ||||
|         validEntityBeforeSave(update); | ||||
|         return baseMapper.updateById(update) > 0; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 保存前的数据校验 | ||||
|      */ | ||||
|     private void validEntityBeforeSave(OpsInspectionRepair entity){ | ||||
|         //TODO 做一些数据校验,如唯一约束 | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 校验并批量删除运维-巡检-抢修信息 | ||||
|      * | ||||
|      * @param ids     待删除的主键集合 | ||||
|      * @param isValid 是否进行有效性校验 | ||||
|      * @return 是否删除成功 | ||||
|      */ | ||||
|     @Override | ||||
|     @GlobalTransactional | ||||
|     public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { | ||||
|         if(isValid){ | ||||
|             //TODO 做一些业务上的校验,判断是否需要校验 | ||||
|         } | ||||
|  | ||||
|         List<String> urls = new ArrayList<>(); | ||||
|         for (Long id : ids) { | ||||
|             OpsInspectionRepairVo vo = queryById(id); | ||||
|             if (vo != null){ | ||||
|                 if (vo.getFileUrl()!=null) { | ||||
|                     urls.add(vo.getFileUrl()); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (!urls.isEmpty()) { | ||||
|             for (String url : urls) { | ||||
|                 List<String> list = Arrays.asList(url.split(",")); | ||||
|                 remoteFileService.deleteFile(list); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return baseMapper.deleteByIds(ids) > 0; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 处理回显数据 | ||||
|      */ | ||||
|     private void setValue(List<OpsInspectionRepairVo> list){ | ||||
|         if (list == null || list.isEmpty()){ | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         for (OpsInspectionRepairVo vo : list) { | ||||
|  | ||||
|             if (vo.getSendPerson() == null){ | ||||
|                 continue; | ||||
|             } | ||||
|  | ||||
|             OpsUserVo opsUserVo = opsUserService.queryById(vo.getSendPerson()); | ||||
|             if (opsUserVo == null){ | ||||
|                 continue; | ||||
|             } | ||||
|  | ||||
|             vo.setSendPersonVo(opsUserVo); | ||||
|  | ||||
|  | ||||
|             //处理分钟数 | ||||
|             if (vo.getStatus().equals("3")){ | ||||
|                 long time = vo.getReportFinishTime().getTime() - vo.getCreateTime().getTime(); | ||||
|                 vo.setMinute(String.valueOf(TimeUnit.MILLISECONDS.toMinutes( time))); | ||||
|             } | ||||
|  | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public R<OpsInspectionReportRecordVo> record(Long projectId) { | ||||
|         //变量初始化 | ||||
|         OpsInspectionReportRecordVo recordVo = new OpsInspectionReportRecordVo(); | ||||
|         OpsInspectionRepairBo bo = new OpsInspectionRepairBo(); | ||||
|         bo.setProjectId(projectId); | ||||
|         //日期初始化 | ||||
|         LocalDate firstDay = LocalDate.now().withDayOfMonth(1); | ||||
|         LocalDate lastDay = firstDay.plusMonths(1).minusDays(1); | ||||
|         Date startDate = Date.from(firstDay.atStartOfDay(ZoneId.systemDefault()).toInstant()); | ||||
|         Date endDate = Date.from(lastDay.atTime(23, 59, 59).atZone(ZoneId.systemDefault()).toInstant()); | ||||
|         //查询当前项目的报修数据 | ||||
|         List<OpsInspectionRepairVo> vos = queryList(bo); | ||||
|  | ||||
|         //过滤本月数据 | ||||
|         List<OpsInspectionRepairVo> thisMonth = vos.stream() | ||||
|             .filter(vo -> vo.getCreateTime().after(startDate)) | ||||
|             .filter(vo -> vo.getCreateTime().before(endDate)) | ||||
|             .toList(); | ||||
|         //本月总报修数 | ||||
|         recordVo.setByzbxs(String.valueOf(thisMonth.size())); | ||||
|  | ||||
|         //平均处理时长    完成时间-创建时间 转为 分钟 / 总报 | ||||
|         Long time = 0L;//总共完成时间 | ||||
|         for (OpsInspectionRepairVo vo : thisMonth) { | ||||
|             if (vo.getStatus().equals("3")){ | ||||
|                 time += vo.getReportFinishTime().getTime() - vo.getCreateTime().getTime(); | ||||
|             } | ||||
|         } | ||||
|         time = TimeUnit.MILLISECONDS.toMinutes(time); | ||||
|         BigDecimal divide1 = BigDecimal.valueOf(time).divide(BigDecimal.valueOf(thisMonth.size()), 0, RoundingMode.HALF_UP); | ||||
|         long hours = TimeUnit.MINUTES.toHours(Long.parseLong(divide1.toString())); | ||||
|  | ||||
|         //平均处理时长 | ||||
|         recordVo.setPjclsc(Long.toString(hours)); | ||||
|  | ||||
|         //待处理报修 | ||||
|         int size = thisMonth.stream().filter(vo -> vo.getStatus().equals("1")).toList().size(); | ||||
|         recordVo.setDclbx(String.valueOf(size)); | ||||
|  | ||||
|         //完成率 | ||||
|         //完成数 | ||||
|         int finishCount = thisMonth.stream().filter(vo -> vo.getStatus().equals("3")).toList().size(); | ||||
|         BigDecimal divide = BigDecimal.valueOf(finishCount).divide(BigDecimal.valueOf(thisMonth.size()), 2, RoundingMode.HALF_UP); | ||||
|         recordVo.setWcl(divide.multiply(new BigDecimal("100")).toString()); | ||||
|  | ||||
|         //统计上一月的数据 | ||||
|         firstDay = LocalDate.now().minusMonths(1).withDayOfMonth(1); | ||||
|         lastDay = firstDay.plusMonths(1).minusDays(1); | ||||
|         Date finalStartDate = Date.from(firstDay.atStartOfDay(ZoneId.systemDefault()).toInstant()); | ||||
|         Date finalEndDate = Date.from(lastDay.atTime(23, 59, 59).atZone(ZoneId.systemDefault()).toInstant()); | ||||
|  | ||||
|  | ||||
|         thisMonth = vos.stream() | ||||
|             .filter(vo -> vo.getCreateTime().after(finalStartDate)) | ||||
|             .filter(vo -> vo.getCreateTime().before(finalEndDate)) | ||||
|             .toList(); | ||||
|  | ||||
|         //上一月总报修数 | ||||
|         Long lastMonth = (long) thisMonth.size(); | ||||
|         //上一月平均处理时长 | ||||
|         BigDecimal avg; | ||||
|         time = 0L; | ||||
|         for (OpsInspectionRepairVo vo : thisMonth) { | ||||
|             if (vo.getStatus().equals("3")){ | ||||
|                 time += vo.getReportFinishTime().getTime() - vo.getCreateTime().getTime(); | ||||
|             } | ||||
|         } | ||||
|         time = TimeUnit.MILLISECONDS.toMinutes(time); | ||||
|  | ||||
|         if (thisMonth.isEmpty()){ | ||||
|             avg = BigDecimal.ZERO; | ||||
|         }else { | ||||
|             avg = BigDecimal.valueOf(time).divide(BigDecimal.valueOf(thisMonth.size()),2, RoundingMode.HALF_UP); | ||||
|         } | ||||
|         //上一月完成率 | ||||
|         finishCount = thisMonth.stream().filter(vo -> vo.getStatus().equals("3")).toList().size(); | ||||
|  | ||||
|         if (!thisMonth.isEmpty()) { | ||||
|             divide = BigDecimal.valueOf(finishCount).divide(BigDecimal.valueOf(thisMonth.size()), 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); | ||||
|         }else { | ||||
|             divide = BigDecimal.ZERO; | ||||
|         } | ||||
|  | ||||
|         //总报修数增长率 | ||||
|         BigDecimal multiply; | ||||
|         if (lastMonth != 0) { | ||||
|             multiply = BigDecimal.valueOf(Long.parseLong(recordVo.getByzbxs())).divide(BigDecimal.valueOf(lastMonth), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100")); | ||||
|         }else { | ||||
|             multiply = BigDecimal.ZERO; | ||||
|         } | ||||
|         recordVo.setBxsjszzzl(multiply.toString()); | ||||
|  | ||||
|         //平均处理时长增长率 本月 / 上月 * 100 | ||||
|         if (!avg.equals(BigDecimal.ZERO)) { | ||||
|             recordVo.setClscjszzzl(BigDecimal.valueOf(Long.parseLong(recordVo.getPjclsc())).divide(avg, 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).toString()); | ||||
|         }else{ | ||||
|             recordVo.setClscjszzzl("0"); | ||||
|         } | ||||
|  | ||||
|         //完成率增长率 本月 / 上月 * 100 | ||||
|         if (!divide.equals(BigDecimal.ZERO)) { | ||||
|             recordVo.setWcljszzzl(BigDecimal.valueOf(Long.parseLong(recordVo.getWcl())).divide(divide, 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).toString()); | ||||
|         }else { | ||||
|             recordVo.setWcljszzzl("0"); | ||||
|         } | ||||
|         return R.ok(recordVo); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -210,18 +210,18 @@ public class OpsInspectionReportServiceImpl implements IOpsInspectionReportServi | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         for (OpsInspectionReportVo opsInspectionReportVo : list) { | ||||
|         for (OpsInspectionReportVo vo : list) { | ||||
|  | ||||
|             if (opsInspectionReportVo.getSendPerson() == null){ | ||||
|             if (vo.getSendPerson() == null){ | ||||
|                 continue; | ||||
|             } | ||||
|  | ||||
|             OpsUserVo opsUserVo = opsUserService.queryById(opsInspectionReportVo.getSendPerson()); | ||||
|             OpsUserVo opsUserVo = opsUserService.queryById(vo.getSendPerson()); | ||||
|             if (opsUserVo == null){ | ||||
|                 continue; | ||||
|             } | ||||
|  | ||||
|             opsInspectionReportVo.setSendPersonVo(opsUserVo); | ||||
|             vo.setSendPersonVo(opsUserVo); | ||||
|  | ||||
|         } | ||||
|     } | ||||
| @ -255,7 +255,7 @@ public class OpsInspectionReportServiceImpl implements IOpsInspectionReportServi | ||||
|             } | ||||
|         } | ||||
|         time = TimeUnit.MILLISECONDS.toMinutes(time); | ||||
|         BigDecimal divide1 = BigDecimal.valueOf(time).divide(BigDecimal.valueOf(thisMonth.size()), 2, RoundingMode.HALF_UP); | ||||
|         BigDecimal divide1 = BigDecimal.valueOf(time).divide(BigDecimal.valueOf(thisMonth.size()), 0, RoundingMode.HALF_UP); | ||||
|         long hours = TimeUnit.MINUTES.toHours(Long.parseLong(divide1.toString())); | ||||
|  | ||||
|         //平均处理时长 | ||||
| @ -286,7 +286,7 @@ public class OpsInspectionReportServiceImpl implements IOpsInspectionReportServi | ||||
|         //上一月总报修数 | ||||
|         Long lastMonth = (long) thisMonth.size(); | ||||
|         //上一月平均处理时长 | ||||
|         BigDecimal avg = BigDecimal.ZERO; | ||||
|         BigDecimal avg; | ||||
|         time = 0L; | ||||
|         for (OpsInspectionReportVo vo : thisMonth) { | ||||
|             if (vo.getStatus().equals("3")){ | ||||
| @ -294,22 +294,44 @@ public class OpsInspectionReportServiceImpl implements IOpsInspectionReportServi | ||||
|             } | ||||
|         } | ||||
|         time = TimeUnit.MILLISECONDS.toMinutes(time); | ||||
|         avg = BigDecimal.valueOf(time).divide(BigDecimal.valueOf(thisMonth.size()),2, RoundingMode.HALF_UP); | ||||
|  | ||||
|         if (thisMonth.isEmpty()){ | ||||
|             avg = BigDecimal.ZERO; | ||||
|         }else { | ||||
|             avg = BigDecimal.valueOf(time).divide(BigDecimal.valueOf(thisMonth.size()),2, RoundingMode.HALF_UP); | ||||
|         } | ||||
|         //上一月完成率 | ||||
|         finishCount = thisMonth.stream().filter(vo -> vo.getStatus().equals("3")).toList().size(); | ||||
|         divide = BigDecimal.valueOf(finishCount).divide(BigDecimal.valueOf(thisMonth.size()), 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100.00)); | ||||
|  | ||||
|         if (!thisMonth.isEmpty()) { | ||||
|             divide = BigDecimal.valueOf(finishCount).divide(BigDecimal.valueOf(thisMonth.size()), 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); | ||||
|         }else { | ||||
|             divide = BigDecimal.ZERO; | ||||
|         } | ||||
|  | ||||
|         //总报修数增长率 | ||||
|         BigDecimal multiply = BigDecimal.valueOf(Long.parseLong(recordVo.getByzbxs())).divide(BigDecimal.valueOf(lastMonth), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100")); | ||||
|         BigDecimal multiply; | ||||
|         if (lastMonth != 0) { | ||||
|             multiply = BigDecimal.valueOf(Long.parseLong(recordVo.getByzbxs())).divide(BigDecimal.valueOf(lastMonth), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100")); | ||||
|         }else { | ||||
|             multiply = BigDecimal.ZERO; | ||||
|         } | ||||
|         recordVo.setBxsjszzzl(multiply.toString()); | ||||
|  | ||||
|         //平均处理时长增长率 本月 / 上月 * 100 | ||||
|         recordVo.setClscjszzzl(BigDecimal.valueOf(Long.parseLong(recordVo.getPjclsc())).divide(avg,2, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).toString()); | ||||
|         if (!avg.equals(BigDecimal.ZERO)) { | ||||
|             recordVo.setClscjszzzl(BigDecimal.valueOf(Long.parseLong(recordVo.getPjclsc())).divide(avg, 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).toString()); | ||||
|         }else{ | ||||
|             recordVo.setClscjszzzl("0"); | ||||
|         } | ||||
|  | ||||
|         //完成率增长率 本月 / 上月 * 100 | ||||
|         recordVo.getWcl(); | ||||
|  | ||||
|         return null; | ||||
|         if (!divide.equals(BigDecimal.ZERO)) { | ||||
|             recordVo.setWcljszzzl(BigDecimal.valueOf(Long.parseLong(recordVo.getWcl())).divide(divide, 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).toString()); | ||||
|         }else { | ||||
|             recordVo.setWcljszzzl("0"); | ||||
|         } | ||||
|         return R.ok(recordVo); | ||||
|     } | ||||
|  | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user