|
@@ -3,12 +3,16 @@ package com.platform.service.fill.impl;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
|
-import com.platform.common.exception.BusinessException;
|
|
|
+import com.platform.common.exception.DeniedException;
|
|
|
import com.platform.common.util.BeanConverterUtil;
|
|
|
+import com.platform.common.util.IdGeneratorUtils;
|
|
|
+import com.platform.common.util.SecurityUtils;
|
|
|
import com.platform.dao.bean.MyPage;
|
|
|
import com.platform.dao.bean.MyVOPage;
|
|
|
import com.platform.dao.dto.fill.FillGatherDTO;
|
|
|
import com.platform.dao.entity.fill.FillGather;
|
|
|
+import com.platform.dao.entity.fill.FillGatherInfo;
|
|
|
+import com.platform.dao.mapper.fill.FillGatherInfoMapper;
|
|
|
import com.platform.dao.mapper.fill.FillGatherMapper;
|
|
|
import com.platform.dao.vo.query.fill.FillGatherVO;
|
|
|
import com.platform.service.base.impl.BaseServiceImpl;
|
|
@@ -18,6 +22,8 @@ import org.springframework.stereotype.Service;
|
|
|
import tk.mybatis.mapper.weekend.Weekend;
|
|
|
import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -30,6 +36,7 @@ import java.util.List;
|
|
|
@Service("fillGatherService")
|
|
|
public class FillGatherServiceImpl extends BaseServiceImpl<FillGatherMapper, FillGather, FillGatherDTO> implements FillGatherService {
|
|
|
|
|
|
+ private final FillGatherInfoMapper fillGatherInfoMapper;
|
|
|
@Override
|
|
|
public int batchDelete(List<String> ids) {
|
|
|
Weekend<FillGather> weekend = new Weekend<>(FillGather.class);
|
|
@@ -41,22 +48,54 @@ public class FillGatherServiceImpl extends BaseServiceImpl<FillGatherMapper, Fil
|
|
|
|
|
|
@Override
|
|
|
public FillGather saveModelByDTO(FillGatherDTO model) {
|
|
|
- Integer codeId = model.getCodeId();
|
|
|
- FillGatherVO fillGatherVO = this.selectByCodeIdUseType(codeId, model.getUseType());
|
|
|
- if (fillGatherVO != null) {
|
|
|
- throw new BusinessException("该类型已设置");
|
|
|
+ if(model.getInfoIds() == null || model.getInfoIds().size() == 0){
|
|
|
+ throw new DeniedException("巡检内容项,至少勾选一项");
|
|
|
+ }
|
|
|
+ FillGather gather = super.saveModelByDTO(model);
|
|
|
+ // 处理巡检内容项的新增
|
|
|
+ addGatherInfos(gather.getId(),model.getInfoIds(),1);
|
|
|
+ return gather;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param gatherId 巡检标准ID
|
|
|
+ * @param infoIds 巡检内容项IDs
|
|
|
+ * @param type 插入类型 1 add 2 queryAndAdd
|
|
|
+ */
|
|
|
+ private void addGatherInfos(String gatherId,List<String> infoIds,Integer type){
|
|
|
+ if(type == 2){
|
|
|
+ // 先删除历史数据
|
|
|
+ Weekend<FillGatherInfo> weekend = new Weekend<>(FillGatherInfo.class);
|
|
|
+ WeekendCriteria<FillGatherInfo, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
+ weekendCriteria.andEqualTo(FillGatherInfo::getGatherId, gatherId);
|
|
|
+ fillGatherInfoMapper.deleteByExample(weekend);
|
|
|
+ }
|
|
|
+ List<FillGatherInfo> infos = new ArrayList<>();
|
|
|
+ for(String infoId : infoIds){
|
|
|
+ FillGatherInfo info = new FillGatherInfo();
|
|
|
+ info.setCreatedTime(LocalDateTime.now());
|
|
|
+ info.setCreatedUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
+ info.setCreatedUserName(SecurityUtils.getUserInfo().getUsername());
|
|
|
+ info.setInfoId(infoId);
|
|
|
+ info.setGatherId(gatherId);
|
|
|
+ info.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ infos.add(info);
|
|
|
+ }
|
|
|
+ // 存储巡检标准对应的内容项
|
|
|
+ if(infos.size() > 0){
|
|
|
+ fillGatherInfoMapper.insertListforComplex(infos);
|
|
|
}
|
|
|
- return super.saveModelByDTO(model);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void modModelByDTO(FillGatherDTO model) {
|
|
|
- Integer codeId = model.getCodeId();
|
|
|
+ /*Integer codeId = model.getCodeId();
|
|
|
FillGatherVO fillGatherVO = this.selectByCodeIdUseType(codeId, model.getUseType());
|
|
|
if (fillGatherVO != null && !fillGatherVO.getId().equals(model.getId())) {
|
|
|
throw new BusinessException("该类型已设置");
|
|
|
- }
|
|
|
+ }*/
|
|
|
super.modModelByDTO(model);
|
|
|
+ addGatherInfos(model.getId(),model.getInfoIds(),2);
|
|
|
}
|
|
|
|
|
|
@Override
|