09-22-文件服务暴露删除方法
This commit is contained in:
		| @ -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<SysOssVo> sysOssVos = sysOssService.listByIds(StringUtils.splitTo(ossIds, Convert::toLong)); | ||||
|         return MapstructUtils.convert(sysOssVos, RemoteFile.class); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     @Override | ||||
|     public void deleteFile(Collection<String> urls){ | ||||
|         OssClient storage = OssFactory.instance(); | ||||
|         for (String url : urls) { | ||||
|             storage.delete(url); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -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<OpsInspectionReportVo> 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<OpsInspectionReportVo> list = opsInspectionReportService.queryList(bo); | ||||
|         ExcelUtil.exportExcel(list, "运维-巡检-报修", OpsInspectionReportVo.class, response); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 获取运维-巡检-报修详细信息 | ||||
|      * | ||||
|      * @param id 主键 | ||||
|      */ | ||||
|     @SaCheckPermission("inspection:report:query") | ||||
|     @GetMapping("/{id}") | ||||
|     public R<OpsInspectionReportVo> 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<Void> 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<Void> 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<Void> remove(@NotEmpty(message = "主键不能为空") | ||||
|                           @PathVariable("ids") Long[] ids) { | ||||
|         return toAjax(opsInspectionReportService.deleteWithValidByIds(List.of(ids), true)); | ||||
|     } | ||||
| } | ||||
| @ -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; | ||||
|  | ||||
|  | ||||
| } | ||||
| @ -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; | ||||
|  | ||||
|  | ||||
| } | ||||
| @ -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; | ||||
|  | ||||
|  | ||||
| } | ||||
| @ -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<OpsInspectionReport, OpsInspectionReportVo> { | ||||
|  | ||||
| } | ||||
| @ -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<OpsInspectionReportVo> queryPageList(OpsInspectionReportBo bo, PageQuery pageQuery); | ||||
|  | ||||
|     /** | ||||
|      * 查询符合条件的运维-巡检-报修列表 | ||||
|      * | ||||
|      * @param bo 查询条件 | ||||
|      * @return 运维-巡检-报修列表 | ||||
|      */ | ||||
|     List<OpsInspectionReportVo> 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<Long> ids, Boolean isValid); | ||||
| } | ||||
| @ -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<OpsInspectionReportVo> opsInspectionReportVo1 = List.of(opsInspectionReportVo); | ||||
|         setValue(opsInspectionReportVo1); | ||||
|         return opsInspectionReportVo1.getFirst(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 分页查询运维-巡检-报修列表 | ||||
|      * | ||||
|      * @param bo        查询条件 | ||||
|      * @param pageQuery 分页参数 | ||||
|      * @return 运维-巡检-报修分页列表 | ||||
|      */ | ||||
|     @Override | ||||
|     public TableDataInfo<OpsInspectionReportVo> queryPageList(OpsInspectionReportBo bo, PageQuery pageQuery) { | ||||
|         LambdaQueryWrapper<OpsInspectionReport> lqw = buildQueryWrapper(bo); | ||||
|         Page<OpsInspectionReportVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); | ||||
|         setValue(result.getRecords()); | ||||
|         return TableDataInfo.build(result); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 查询符合条件的运维-巡检-报修列表 | ||||
|      * | ||||
|      * @param bo 查询条件 | ||||
|      * @return 运维-巡检-报修列表 | ||||
|      */ | ||||
|     @Override | ||||
|     public List<OpsInspectionReportVo> queryList(OpsInspectionReportBo bo) { | ||||
|         LambdaQueryWrapper<OpsInspectionReport> lqw = buildQueryWrapper(bo); | ||||
|         return baseMapper.selectVoList(lqw); | ||||
|     } | ||||
|  | ||||
|     private LambdaQueryWrapper<OpsInspectionReport> buildQueryWrapper(OpsInspectionReportBo bo) { | ||||
|         Map<String, Object> params = bo.getParams(); | ||||
|         LambdaQueryWrapper<OpsInspectionReport> 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<Long> ids, Boolean isValid) { | ||||
|         if(isValid){ | ||||
|             //TODO 做一些业务上的校验,判断是否需要校验 | ||||
|         } | ||||
|  | ||||
|         List<String> 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<OpsInspectionReportVo> 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); | ||||
|  | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user