|
@@ -0,0 +1,147 @@
|
|
|
+package org.springblade.manager.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.common.utils.ForestNodeMergerEx;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
+import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.constant.BladeConstant;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.manager.dto.ArchiveTreeContractAutoRuleMapDTO;
|
|
|
+import org.springblade.manager.dto.ArchiveTreeDTO;
|
|
|
+import org.springblade.manager.dto.ArchiveTreeSortDTO;
|
|
|
+import org.springblade.manager.dto.RoutingInspectionDTO;
|
|
|
+import org.springblade.manager.entity.*;
|
|
|
+import org.springblade.manager.mapper.ArchiveAutoRuleWbsMapper;
|
|
|
+import org.springblade.manager.mapper.ArchiveTreeMapper;
|
|
|
+import org.springblade.manager.mapper.RoutingInspectionMapper;
|
|
|
+import org.springblade.manager.service.*;
|
|
|
+import org.springblade.manager.utils.DiffListUtil;
|
|
|
+import org.springblade.manager.utils.ForestNodeMerger;
|
|
|
+import org.springblade.manager.vo.*;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+public class RoutingInspectionServiceImpl extends BaseServiceImpl<RoutingInspectionMapper, RoutingInspection> implements IRoutingInspectionService {
|
|
|
+
|
|
|
+ private final IInspectionRectifyService rectifyService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void add(RoutingInspectionDTO dto) {
|
|
|
+ //获取检查部位
|
|
|
+ List<InspectionRectify> list = dto.getList();
|
|
|
+ if (list == null || list.size() == 0){
|
|
|
+ throw new ServiceException("请填写检查项目");
|
|
|
+ }
|
|
|
+ //先保存巡检信息
|
|
|
+ Long id = SnowFlakeUtil.getId();
|
|
|
+ RoutingInspection inspection = new RoutingInspection();
|
|
|
+ BeanUtils.copyProperties(dto,inspection);
|
|
|
+ inspection.setId(id);
|
|
|
+ this.save(inspection);
|
|
|
+ //再保存具体的巡检项目
|
|
|
+ list.stream().forEach(l->l.setInspectId(id));
|
|
|
+ rectifyService.saveBatch(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void Update(RoutingInspectionDTO dto) {
|
|
|
+ //获取检查部位
|
|
|
+ List<InspectionRectify> list = dto.getList();
|
|
|
+ if (list == null || list.size() == 0){
|
|
|
+ throw new ServiceException("请填写检查项目");
|
|
|
+ }
|
|
|
+ RoutingInspection inspection = new RoutingInspection();
|
|
|
+ BeanUtils.copyProperties(dto,inspection);
|
|
|
+ this.updateById(inspection);
|
|
|
+ //修改先删除,再保存
|
|
|
+ rectifyService.deleteByInspectId(dto.getId());
|
|
|
+ list.stream().forEach(l->l.setInspectId(dto.getId()));
|
|
|
+ rectifyService.saveBatch(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<RoutingInspectionVO> page(Query query, RoutingInspection inspection) {
|
|
|
+ IPage<RoutingInspectionVO> iPage = new Page<>(query.getCurrent(), query.getSize());
|
|
|
+ baseMapper.page(iPage,inspection);
|
|
|
+ return iPage;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void delete(Long id) {
|
|
|
+ //先删除巡检项目
|
|
|
+ rectifyService.deleteByInspectId(id);
|
|
|
+ //再删除巡检信息
|
|
|
+ this.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RoutingInspectionVO2 detail(Long id) {
|
|
|
+ //先查出巡检项目集合
|
|
|
+ List<InspectionRectify> list = rectifyService.list(new LambdaQueryWrapper<InspectionRectify>().eq(InspectionRectify::getInspectId, id));
|
|
|
+ //再查出巡检信息,集合设置进巡检信息
|
|
|
+ RoutingInspection inspection = this.getById(id);
|
|
|
+ RoutingInspectionVO2 vo2 = new RoutingInspectionVO2();
|
|
|
+ BeanUtils.copyProperties(inspection,vo2);
|
|
|
+ vo2.setList(list);
|
|
|
+ return vo2;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void reviewInspect(Long id, Integer status) {
|
|
|
+ //判断复检状态
|
|
|
+ if (status == 1){
|
|
|
+ //复检未通过,修改复检状态为2未通过
|
|
|
+ this.update(new LambdaUpdateWrapper<RoutingInspection>()
|
|
|
+ .set(RoutingInspection::getReviewInspectStatus,2)
|
|
|
+ .eq(RoutingInspection::getId,id));
|
|
|
+ }else if (status == 2){
|
|
|
+ //复检通过,修改复检状态为3通过,修改整改状态为2不用整改
|
|
|
+ this.update(new LambdaUpdateWrapper<RoutingInspection>()
|
|
|
+ .set(RoutingInspection::getReviewInspectStatus,3)
|
|
|
+ .set(RoutingInspection::getIsRectify,2)
|
|
|
+ .eq(RoutingInspection::getId,id));
|
|
|
+ }else {
|
|
|
+ throw new ServiceException("参数错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void submitRectify(RoutingInspectionDTO dto) {
|
|
|
+ //修改巡检信息状态为已经整改
|
|
|
+ this.update(new LambdaUpdateWrapper<RoutingInspection>()
|
|
|
+ .set(RoutingInspection::getSubmitRectify,2)
|
|
|
+ .eq(RoutingInspection::getId,dto.getId()));
|
|
|
+ //保存检查项目
|
|
|
+ List<InspectionRectify> list = dto.getList();
|
|
|
+ rectifyService.updateBatchById(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void revokeSubmit(Long id) {
|
|
|
+ //修改巡检信息为未整改
|
|
|
+ this.update(new LambdaUpdateWrapper<RoutingInspection>()
|
|
|
+ .set(RoutingInspection::getSubmitRectify,1)
|
|
|
+ .eq(RoutingInspection::getId,id));
|
|
|
+ }
|
|
|
+}
|