| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gkhy.safePlatform.targetDuty.entity.ExamineItem; |
| | | import com.gkhy.safePlatform.targetDuty.entity.TargetMng; |
| | | import com.gkhy.safePlatform.targetDuty.enums.TargetDutyResultCodes; |
| | | import com.gkhy.safePlatform.targetDuty.excepiton.TargetDutyException; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | @Autowired |
| | | private TargetMngRepository targetMngRepository; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public ResultVO queryAll(PageQuery<TargetDivideDetailQueryCriteria> pageQuery) { |
| | | Long pageIndex = pageQuery.getPageIndex(); |
| | |
| | | if(StringUtils.hasText(infoDto.getDelTargetDivideDetails())){ |
| | | List<Long> idList = Arrays.stream(infoDto.getDelTargetDivideDetails().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | | this.removeByIds(idList); |
| | | List<TargetDivideDetail> delList = new ArrayList<>(); |
| | | idList.forEach(f->{ |
| | | TargetDivideDetail info = new TargetDivideDetail(); |
| | | info.setDelFlag(1); |
| | | info.setId(f); |
| | | delList.add(info); |
| | | }); |
| | | this.updateBatchById(delList); |
| | | } |
| | | |
| | | //保存主数据 |
| | | //如果目标指标已经被分解,那么就不能再次增加 |
| | | if(targetMng.getDivideStatus() == 1){ |
| | | if(targetMng.getDivideStatus() == 1 && infoDto.getTargetId() == null){ |
| | | throw new TargetDutyException(TargetDutyResultCodes.E2); |
| | | } |
| | | |
| | |
| | | list.forEach(f->{f.setTargetId(infoDto.getTargetId());}); |
| | | this.saveOrUpdateBatch(list); |
| | | |
| | | //设置状态为 《已分解》 |
| | | targetMng.setDivideStatus(1); |
| | | //查询最新的分解数量,如果>0,设置状态为 《已分解》,否则设置为未分解 |
| | | int divideStatus = 2; |
| | | if(infoDto.getTargetId() != null){ |
| | | long number = this.count(new QueryWrapper<TargetDivideDetail>().eq("target_id",infoDto.getTargetId())); |
| | | if(number > 0){ |
| | | divideStatus = 1; |
| | | } |
| | | } |
| | | targetMng.setDivideStatus(divideStatus); |
| | | targetMngRepository.update(targetMng,new UpdateWrapper<TargetMng>().eq("id",targetMng.getId())); |
| | | |
| | | |
| | | } |
| | | } |
| | | } |