From 772b610bec52c25a198e9aa8b2e6a4cd8c99d282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E5=B1=95=E8=88=AA?= <2426745133@qq.com> Date: Mon, 22 Sep 2025 15:05:41 +0800 Subject: [PATCH] =?UTF-8?q?09-22-=E6=96=87=E4=BB=B6=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E6=9A=B4=E9=9C=B2=E5=88=A0=E9=99=A4=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resource/api/RemoteFileService.java | 4 + .../resource/api/RemoteFileServiceMock.java | 6 + .../resource/dubbo/RemoteFileServiceImpl.java | 10 + .../OpsInspectionReportController.java | 107 +++++++++ .../domain/OpsInspectionReport.java | 91 ++++++++ .../domain/bo/OpsInspectionReportBo.java | 99 ++++++++ .../domain/vo/OpsInspectionReportVo.java | 111 +++++++++ .../mapper/OpsInspectionReportMapper.java | 15 ++ .../service/IOpsInspectionReportService.java | 69 ++++++ .../impl/OpsInspectionReportServiceImpl.java | 212 ++++++++++++++++++ 10 files changed, 724 insertions(+) create mode 100644 ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/controller/OpsInspectionReportController.java create mode 100644 ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/OpsInspectionReport.java create mode 100644 ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/bo/OpsInspectionReportBo.java create mode 100644 ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/vo/OpsInspectionReportVo.java create mode 100644 ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/mapper/OpsInspectionReportMapper.java create mode 100644 ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/IOpsInspectionReportService.java create mode 100644 ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionReportServiceImpl.java diff --git a/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileService.java b/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileService.java index 2204de6..ec60969 100644 --- a/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileService.java +++ b/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileService.java @@ -3,6 +3,7 @@ package org.dromara.resource.api; import org.dromara.common.core.exception.ServiceException; import org.dromara.resource.api.domain.RemoteFile; +import java.util.Collection; import java.util.List; /** @@ -35,4 +36,7 @@ public interface RemoteFileService { * @return 列表 */ List selectByIds(String ossIds); + + + void deleteFile(Collection urls); } diff --git a/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileServiceMock.java b/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileServiceMock.java index 5ce7c5a..ca76112 100644 --- a/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileServiceMock.java +++ b/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileServiceMock.java @@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.utils.StringUtils; import org.dromara.resource.api.domain.RemoteFile; +import java.util.Collection; import java.util.List; /** @@ -50,4 +51,9 @@ public class RemoteFileServiceMock implements RemoteFileService { return List.of(); } + @Override + public void deleteFile(Collection urls){ + log.warn("服务调用异常 -> 降级处理"); + } + } diff --git a/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/dubbo/RemoteFileServiceImpl.java b/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/dubbo/RemoteFileServiceImpl.java index dcdc9bd..4072a27 100644 --- a/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/dubbo/RemoteFileServiceImpl.java +++ b/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/dubbo/RemoteFileServiceImpl.java @@ -18,6 +18,7 @@ import org.dromara.resource.service.ISysOssService; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.Collection; import java.util.List; /** @@ -86,4 +87,13 @@ public class RemoteFileServiceImpl implements RemoteFileService { List sysOssVos = sysOssService.listByIds(StringUtils.splitTo(ossIds, Convert::toLong)); return MapstructUtils.convert(sysOssVos, RemoteFile.class); } + + + @Override + public void deleteFile(Collection urls){ + OssClient storage = OssFactory.instance(); + for (String url : urls) { + storage.delete(url); + } + } } 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 new file mode 100644 index 0000000..e5eebdc --- /dev/null +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/controller/OpsInspectionReportController.java @@ -0,0 +1,107 @@ +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.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.OpsInspectionReportVo; +import org.dromara.inspection.domain.bo.OpsInspectionReportBo; +import org.dromara.inspection.service.IOpsInspectionReportService; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.springframework.web.multipart.MultipartFile; + +/** + * 运维-巡检-报修 + * 前端访问路由地址为:/inspection/report + * + * @author LionLi + * @date 2025-09-22 + */ +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/report") +public class OpsInspectionReportController extends BaseController { + + private final IOpsInspectionReportService opsInspectionReportService; + + /** + * 查询运维-巡检-报修列表 + */ + @SaCheckPermission("inspection:report:list") + @GetMapping("/list") + public TableDataInfo list(OpsInspectionReportBo bo, PageQuery pageQuery) { + return opsInspectionReportService.queryPageList(bo, pageQuery); + } + + /** + * 导出运维-巡检-报修列表 + */ + @SaCheckPermission("inspection:report:export") + @Log(title = "运维-巡检-报修", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(OpsInspectionReportBo bo, HttpServletResponse response) { + List list = opsInspectionReportService.queryList(bo); + ExcelUtil.exportExcel(list, "运维-巡检-报修", OpsInspectionReportVo.class, response); + } + + /** + * 获取运维-巡检-报修详细信息 + * + * @param id 主键 + */ + @SaCheckPermission("inspection:report:query") + @GetMapping("/{id}") + public R getInfo(@NotNull(message = "主键不能为空") + @PathVariable("id") Long id) { + return R.ok(opsInspectionReportService.queryById(id)); + } + + /** + * 新增运维-巡检-报修 + */ + @SaCheckPermission("inspection:report:add") + @Log(title = "运维-巡检-报修", businessType = BusinessType.INSERT) + @RepeatSubmit() + @PostMapping() + public R add(@Validated(AddGroup.class) @RequestBody OpsInspectionReportBo bo) { + return toAjax(opsInspectionReportService.insertByBo(bo)); + } + + /** + * 修改运维-巡检-报修 + */ + @SaCheckPermission("inspection:report:edit") + @Log(title = "运维-巡检-报修", businessType = BusinessType.UPDATE) + @RepeatSubmit() + @PutMapping() + public R edit(@Validated(EditGroup.class) @RequestBody OpsInspectionReportBo bo) { + return toAjax(opsInspectionReportService.updateByBo(bo)); + } + + /** + * 删除运维-巡检-报修 + * + * @param ids 主键串 + */ + @SaCheckPermission("inspection:report:remove") + @Log(title = "运维-巡检-报修", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public R remove(@NotEmpty(message = "主键不能为空") + @PathVariable("ids") Long[] ids) { + return toAjax(opsInspectionReportService.deleteWithValidByIds(List.of(ids), true)); + } +} diff --git a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/OpsInspectionReport.java b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/OpsInspectionReport.java new file mode 100644 index 0000000..e944a3e --- /dev/null +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/OpsInspectionReport.java @@ -0,0 +1,91 @@ +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.io.Serial; + +/** + * 运维-巡检-报修对象 ops_inspection_report + * + * @author LionLi + * @date 2025-09-22 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("ops_inspection_report") +public class OpsInspectionReport extends BaseEntity { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * + */ + @TableId(value = "id") + private Long id; + + /** + * 项目ID(电站ID) + */ + private Long projectId; + + /** + * 1低优先2中优先3高优先 + */ + private String level; + + /** + * 1待处理2处理中3已完成 + */ + private String status; + + /** + * 报修类型1硬件2软件 + */ + private String type; + + /** + * 报修名称 + */ + private String name; + + /** + * 指派维修人 + */ + private Long sendPerson; + + /** + * 详细信息 + */ + private String reportInfo; + + /** + * 故障位置 + */ + private String position; + + /** + * 文件ID + */ + private Long fileId; + + /** + * 文件路径 + */ + private String fileUrl; + + /** + * 报修人姓名 + */ + private String reportName; + + /** + * 报修人联系电话 + */ + private String reportPhone; + + +} 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 new file mode 100644 index 0000000..4dbc81e --- /dev/null +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/bo/OpsInspectionReportBo.java @@ -0,0 +1,99 @@ +package org.dromara.inspection.domain.bo; + +import org.dromara.inspection.domain.OpsInspectionReport; +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.*; + +/** + * 运维-巡检-报修业务对象 ops_inspection_report + * + * @author LionLi + * @date 2025-09-22 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@AutoMapper(target = OpsInspectionReport.class, reverseConvertGenerate = false) +public class OpsInspectionReportBo extends BaseEntity { + + /** + * id + */ + private Long id; + + /** + * 项目ID(电站ID) + */ + @NotNull(message = "项目ID(电站ID)不能为空", groups = { AddGroup.class, EditGroup.class }) + private Long projectId; + + /** + * 1低优先2中优先3高优先 + */ + @NotBlank(message = "优先级不能为空", groups = {AddGroup.class, EditGroup.class}) + private String level; + + /** + * 1待处理2处理中3已完成 + */ + private String status; + + /** + * 报修类型1硬件2软件 + */ + @NotBlank(message = "报修类型不能为空", 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; + + /** + * 文件ID + */ +// @NotBlank(message = "文件不能为空", groups = {AddGroup.class, EditGroup.class}) + private Long fileId; + + /** + * 文件路径 + */ + private String fileUrl; + + /** + * 报修人姓名 + */ + @NotBlank(message = "姓名不能为空", groups = {AddGroup.class, EditGroup.class}) + private String reportName; + + /** + * 报修人联系电话 + */ + @NotBlank(message = "电话不能为空", groups = {AddGroup.class, EditGroup.class}) + private String reportPhone; + + +} diff --git a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/vo/OpsInspectionReportVo.java b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/vo/OpsInspectionReportVo.java new file mode 100644 index 0000000..ddf4aac --- /dev/null +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/domain/vo/OpsInspectionReportVo.java @@ -0,0 +1,111 @@ +package org.dromara.inspection.domain.vo; + +import org.dromara.inspection.domain.OpsInspectionReport; +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_report + * + * @author LionLi + * @date 2025-09-22 + */ +@Data +@ExcelIgnoreUnannotated +@AutoMapper(target = OpsInspectionReport.class) +public class OpsInspectionReportVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * id + */ + @ExcelProperty(value = "") + private Long id; + + /** + * 项目ID(电站ID) + */ + 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软件 + */ + @ExcelProperty(value = "报修类型1硬件2软件") + private String type; + + /** + * 报修名称 + */ + @ExcelProperty(value = "报修名称") + private String name; + + /** + * 指派维修人ID + */ + @ExcelProperty(value = "指派维修人") + private Long sendPerson; + + /** + * 指派维修人 + */ + private OpsUserVo sendPersonVo; + + /** + * 详细信息 + */ + @ExcelProperty(value = "详细信息") + private String reportInfo; + + /** + * 故障位置 + */ + @ExcelProperty(value = "故障位置") + private String position; + + /** + * 文件ID + */ + @ExcelProperty(value = "文件ID") + private Long fileId; + + /** + * 文件路径 + */ + @ExcelProperty(value = "文件路径") + private String fileUrl; + + /** + * 报修人姓名 + */ + @ExcelProperty(value = "报修人姓名") + private String reportName; + + /** + * 报修人联系电话 + */ + @ExcelProperty(value = "报修人联系电话") + private String reportPhone; + + +} diff --git a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/mapper/OpsInspectionReportMapper.java b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/mapper/OpsInspectionReportMapper.java new file mode 100644 index 0000000..5e6a8de --- /dev/null +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/mapper/OpsInspectionReportMapper.java @@ -0,0 +1,15 @@ +package org.dromara.inspection.mapper; + +import org.dromara.inspection.domain.OpsInspectionReport; +import org.dromara.inspection.domain.vo.OpsInspectionReportVo; +import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; + +/** + * 运维-巡检-报修Mapper接口 + * + * @author LionLi + * @date 2025-09-22 + */ +public interface OpsInspectionReportMapper extends BaseMapperPlus { + +} diff --git a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/IOpsInspectionReportService.java b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/IOpsInspectionReportService.java new file mode 100644 index 0000000..4c79494 --- /dev/null +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/IOpsInspectionReportService.java @@ -0,0 +1,69 @@ +package org.dromara.inspection.service; + +import org.dromara.inspection.domain.vo.OpsInspectionReportVo; +import org.dromara.inspection.domain.bo.OpsInspectionReportBo; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.common.mybatis.core.page.PageQuery; +import org.springframework.web.multipart.MultipartFile; + +import java.util.Collection; +import java.util.List; + +/** + * 运维-巡检-报修Service接口 + * + * @author LionLi + * @date 2025-09-22 + */ +public interface IOpsInspectionReportService { + + /** + * 查询运维-巡检-报修 + * + * @param id 主键 + * @return 运维-巡检-报修 + */ + OpsInspectionReportVo queryById(Long id); + + /** + * 分页查询运维-巡检-报修列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 运维-巡检-报修分页列表 + */ + TableDataInfo queryPageList(OpsInspectionReportBo bo, PageQuery pageQuery); + + /** + * 查询符合条件的运维-巡检-报修列表 + * + * @param bo 查询条件 + * @return 运维-巡检-报修列表 + */ + List queryList(OpsInspectionReportBo bo); + + /** + * 新增运维-巡检-报修 + * + * @param bo 运维-巡检-报修 + * @return 是否新增成功 + */ + Boolean insertByBo(OpsInspectionReportBo bo); + + /** + * 修改运维-巡检-报修 + * + * @param bo 运维-巡检-报修 + * @return 是否修改成功 + */ + Boolean updateByBo(OpsInspectionReportBo 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/OpsInspectionReportServiceImpl.java b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionReportServiceImpl.java new file mode 100644 index 0000000..e5864f2 --- /dev/null +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionReportServiceImpl.java @@ -0,0 +1,212 @@ +package org.dromara.inspection.service.impl; + +import org.apache.dubbo.config.annotation.DubboReference; +import org.apache.dubbo.config.annotation.DubboService; +import org.apache.seata.spring.annotation.GlobalTransactional; +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.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.OpsInspectionReportBo; +import org.dromara.inspection.domain.vo.OpsInspectionReportVo; +import org.dromara.inspection.domain.OpsInspectionReport; +import org.dromara.inspection.mapper.OpsInspectionReportMapper; +import org.dromara.inspection.service.IOpsInspectionReportService; +import org.springframework.web.multipart.MultipartFile; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Collection; + +/** + * 运维-巡检-报修Service业务层处理 + * + * @author LionLi + * @date 2025-09-22 + */ +@Slf4j +@RequiredArgsConstructor +@Service +public class OpsInspectionReportServiceImpl implements IOpsInspectionReportService { + + private final OpsInspectionReportMapper baseMapper; + + @DubboReference + private RemoteFileService remoteFileService; + @Autowired + private OpsUserServiceImpl opsUserService; + + /** + * 查询运维-巡检-报修 + * + * @param id 主键 + * @return 运维-巡检-报修 + */ + @Override + public OpsInspectionReportVo queryById(Long id){ + OpsInspectionReportVo opsInspectionReportVo = baseMapper.selectVoById(id); + List opsInspectionReportVo1 = List.of(opsInspectionReportVo); + setValue(opsInspectionReportVo1); + return opsInspectionReportVo1.getFirst(); + } + + /** + * 分页查询运维-巡检-报修列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 运维-巡检-报修分页列表 + */ + @Override + public TableDataInfo queryPageList(OpsInspectionReportBo 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(OpsInspectionReportBo bo) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + return baseMapper.selectVoList(lqw); + } + + private LambdaQueryWrapper buildQueryWrapper(OpsInspectionReportBo bo) { + Map params = bo.getParams(); + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.orderByAsc(OpsInspectionReport::getId); + lqw.eq(bo.getProjectId() != null, OpsInspectionReport::getProjectId, bo.getProjectId()); + lqw.eq(StringUtils.isNotBlank(bo.getLevel()), OpsInspectionReport::getLevel, bo.getLevel()); + lqw.eq(StringUtils.isNotBlank(bo.getStatus()), OpsInspectionReport::getStatus, bo.getStatus()); + lqw.eq(StringUtils.isNotBlank(bo.getType()), OpsInspectionReport::getType, bo.getType()); + lqw.like(StringUtils.isNotBlank(bo.getName()), OpsInspectionReport::getName, bo.getName()); + lqw.eq(bo.getSendPerson() != null, OpsInspectionReport::getSendPerson, bo.getSendPerson()); + lqw.eq(StringUtils.isNotBlank(bo.getReportInfo()), OpsInspectionReport::getReportInfo, bo.getReportInfo()); + lqw.eq(StringUtils.isNotBlank(bo.getPosition()), OpsInspectionReport::getPosition, bo.getPosition()); + lqw.eq(bo.getFileId() != null, OpsInspectionReport::getFileId, bo.getFileId()); + lqw.eq(StringUtils.isNotBlank(bo.getFileUrl()), OpsInspectionReport::getFileUrl, bo.getFileUrl()); + lqw.like(StringUtils.isNotBlank(bo.getReportName()), OpsInspectionReport::getReportName, bo.getReportName()); + lqw.eq(StringUtils.isNotBlank(bo.getReportPhone()), OpsInspectionReport::getReportPhone, bo.getReportPhone()); + return lqw; + } + + /** + * 新增运维-巡检-报修 + * + * @param bo 运维-巡检-报修 + * @return 是否新增成功 + */ + @Override + @GlobalTransactional + public Boolean insertByBo(OpsInspectionReportBo bo) { + OpsInspectionReport add = MapstructUtils.convert(bo, OpsInspectionReport.class); + validEntityBeforeSave(add); + + if (add == null){ + return false; + } + + String s = remoteFileService.selectUrlByIds(String.valueOf(add.getFileId())); + add.setFileUrl(s); + + boolean flag = baseMapper.insert(add) > 0; + if (flag) { + bo.setId(add.getId()); + bo.setFileUrl(s); + } + return flag; + } + + /** + * 修改运维-巡检-报修 + * + * @param bo 运维-巡检-报修 + * @return 是否修改成功 + */ + @Override + public Boolean updateByBo(OpsInspectionReportBo bo) { + OpsInspectionReport update = MapstructUtils.convert(bo, OpsInspectionReport.class); + validEntityBeforeSave(update); + return baseMapper.updateById(update) > 0; + } + + /** + * 保存前的数据校验 + */ + private void validEntityBeforeSave(OpsInspectionReport 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) { + OpsInspectionReportVo opsInspectionReportVo = queryById(id); + if (opsInspectionReportVo != null){ + if (opsInspectionReportVo.getFileUrl()!=null) { + urls.add(opsInspectionReportVo.getFileUrl()); + } + } + } + + if (!urls.isEmpty()) { + remoteFileService.deleteFile(urls); + } + + return baseMapper.deleteByIds(ids) > 0; + } + + /** + * 处理回显数据 + */ + private void setValue(List list){ + if (list == null || list.isEmpty()){ + return; + } + + for (OpsInspectionReportVo opsInspectionReportVo : list) { + + if (opsInspectionReportVo.getSendPerson() == null){ + continue; + } + + OpsUserVo opsUserVo = opsUserService.queryById(opsInspectionReportVo.getSendPerson()); + if (opsUserVo == null){ + continue; + } + + opsInspectionReportVo.setSendPersonVo(opsUserVo); + + } + } + +}