From bcc1a5c6d14e01477ac624872b6be8a8b276481a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E5=B1=95=E8=88=AA?= <2426745133@qq.com> Date: Tue, 23 Sep 2025 11:39:18 +0800 Subject: [PATCH] =?UTF-8?q?09-23-=E6=8A=A2=E4=BF=AE=EF=BC=8C=E6=8A=A5?= =?UTF-8?q?=E4=BF=AE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OpsInspectionRepairController.java | 119 +++++++ .../OpsInspectionReportController.java | 5 +- .../domain/OpsInspectionRepair.java | 112 ++++++ .../domain/bo/OpsInspectionRepairBo.java | 124 +++++++ .../domain/bo/OpsInspectionReportBo.java | 2 +- .../domain/vo/OpsInspectionRepairVo.java | 141 ++++++++ .../mapper/OpsInspectionRepairMapper.java | 15 + .../service/IOpsInspectionRepairService.java | 68 ++++ .../impl/OpsInspectionRepairServiceImpl.java | 331 ++++++++++++++++++ .../impl/OpsInspectionReportServiceImpl.java | 48 ++- 10 files changed, 949 insertions(+), 16 deletions(-) create mode 100644 ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/controller/OpsInspectionRepairController.java create mode 100644 ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/OpsInspectionRepair.java create mode 100644 ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/bo/OpsInspectionRepairBo.java create mode 100644 ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/vo/OpsInspectionRepairVo.java create mode 100644 ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/mapper/OpsInspectionRepairMapper.java create mode 100644 ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/IOpsInspectionRepairService.java create mode 100644 ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionRepairServiceImpl.java diff --git a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/controller/OpsInspectionRepairController.java b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/controller/OpsInspectionRepairController.java new file mode 100644 index 0000000..8e42664 --- /dev/null +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/controller/OpsInspectionRepairController.java @@ -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 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 list = opsInspectionRepairService.queryList(bo); + ExcelUtil.exportExcel(list, "运维-巡检-抢修", OpsInspectionRepairVo.class, response); + } + + /** + * 获取运维-巡检-抢修详细信息 + * + * @param id 主键 + */ + @SaCheckPermission("inspection:repair:query") + @GetMapping("/{id}") + public R 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 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 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 remove(@NotEmpty(message = "主键不能为空") + @PathVariable("ids") Long[] ids) { + return toAjax(opsInspectionRepairService.deleteWithValidByIds(List.of(ids), true)); + } + + /** + * 生成纪录 + */ + @SaCheckPermission("inspection:repair:record") + @GetMapping("/record") + public R record(@RequestParam Long projectId){ + + return opsInspectionRepairService.record(projectId); + } + +} diff --git a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/controller/OpsInspectionReportController.java b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/controller/OpsInspectionReportController.java index d5212e7..798756e 100644 --- a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/controller/OpsInspectionReportController.java +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/controller/OpsInspectionReportController.java @@ -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 record(@RequestParam Long projectId){ - return null; + return opsInspectionReportService.record(projectId); } } diff --git a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/OpsInspectionRepair.java b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/OpsInspectionRepair.java new file mode 100644 index 0000000..6dc2329 --- /dev/null +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/OpsInspectionRepair.java @@ -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; + + +} diff --git a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/bo/OpsInspectionRepairBo.java b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/bo/OpsInspectionRepairBo.java new file mode 100644 index 0000000..98b00be --- /dev/null +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/bo/OpsInspectionRepairBo.java @@ -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; + + +} diff --git a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/bo/OpsInspectionReportBo.java b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/bo/OpsInspectionReportBo.java index 3e68457..28cd03e 100644 --- a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/bo/OpsInspectionReportBo.java +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/bo/OpsInspectionReportBo.java @@ -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; /** diff --git a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/vo/OpsInspectionRepairVo.java b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/vo/OpsInspectionRepairVo.java new file mode 100644 index 0000000..84bba78 --- /dev/null +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/vo/OpsInspectionRepairVo.java @@ -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; + +} diff --git a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/mapper/OpsInspectionRepairMapper.java b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/mapper/OpsInspectionRepairMapper.java new file mode 100644 index 0000000..9fa9e13 --- /dev/null +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/mapper/OpsInspectionRepairMapper.java @@ -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 { + +} diff --git a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/IOpsInspectionRepairService.java b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/IOpsInspectionRepairService.java new file mode 100644 index 0000000..b0b85d7 --- /dev/null +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/IOpsInspectionRepairService.java @@ -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 queryPageList(OpsInspectionRepairBo bo, PageQuery pageQuery); + + /** + * 查询符合条件的运维-巡检-抢修列表 + * + * @param bo 查询条件 + * @return 运维-巡检-抢修列表 + */ + List 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 ids, Boolean isValid); +} diff --git a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionRepairServiceImpl.java b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionRepairServiceImpl.java new file mode 100644 index 0000000..5e5df29 --- /dev/null +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionRepairServiceImpl.java @@ -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 vo1 = List.of(vo); + setValue(vo1); + return vo1.getFirst(); + } + + /** + * 分页查询运维-巡检-抢修列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 运维-巡检-抢修分页列表 + */ + @Override + public TableDataInfo queryPageList(OpsInspectionRepairBo bo, PageQuery pageQuery) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); + setValue(result.getRecords()); + return TableDataInfo.build(result); + } + + /** + * 查询符合条件的运维-巡检-抢修列表 + * + * @param bo 查询条件 + * @return 运维-巡检-抢修列表 + */ + @Override + public List queryList(OpsInspectionRepairBo bo) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + return baseMapper.selectVoList(lqw); + } + + private LambdaQueryWrapper buildQueryWrapper(OpsInspectionRepairBo bo) { + Map params = bo.getParams(); + LambdaQueryWrapper 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 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 ids, Boolean isValid) { + if(isValid){ + //TODO 做一些业务上的校验,判断是否需要校验 + } + + List 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 list = Arrays.asList(url.split(",")); + remoteFileService.deleteFile(list); + } + } + + return baseMapper.deleteByIds(ids) > 0; + } + + /** + * 处理回显数据 + */ + private void setValue(List 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 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 vos = queryList(bo); + + //过滤本月数据 + List 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); + } + +} diff --git a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionReportServiceImpl.java b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionReportServiceImpl.java index 6fbdb4c..661ee38 100644 --- a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionReportServiceImpl.java +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionReportServiceImpl.java @@ -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); } }