|
|
|
|
@@ -3,11 +3,16 @@ package com.njcn.system.service.impl;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
|
|
|
|
import com.njcn.system.pojo.po.EleEpdPqd;
|
|
|
|
|
import com.njcn.system.pojo.param.CsStatisticalSetAddParam;
|
|
|
|
|
import com.njcn.system.pojo.po.*;
|
|
|
|
|
import com.njcn.system.pojo.vo.CsStatisticalSetVO;
|
|
|
|
|
import com.njcn.system.pojo.vo.DictTreeVO;
|
|
|
|
|
import com.njcn.system.pojo.vo.EleEpdPqdListVO;
|
|
|
|
|
import com.njcn.system.service.IDicService;
|
|
|
|
|
import com.njcn.system.service.IEleEpdPqdService;
|
|
|
|
|
import com.njcn.system.service.SysDicTreePOService;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
@@ -16,9 +21,9 @@ import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.njcn.system.mapper.CsStatisticalSetPOMapper;
|
|
|
|
|
import com.njcn.system.pojo.po.CsStatisticalSetPO;
|
|
|
|
|
import com.njcn.system.service.CsStatisticalSetPOService;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
@@ -33,55 +38,90 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
public class CsStatisticalSetPOServiceImpl extends MppServiceImpl<CsStatisticalSetPOMapper, CsStatisticalSetPO> implements CsStatisticalSetPOService{
|
|
|
|
|
|
|
|
|
|
private final IEleEpdPqdService epdPqdService;
|
|
|
|
|
private final IDicService dicService;
|
|
|
|
|
|
|
|
|
|
private final SysDicTreePOService sysDicTreePOService;
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
|
|
|
public Boolean saveData(String id, List<String> ids) {
|
|
|
|
|
List<CsStatisticalSetPO> csStatisticalSetPOList = new ArrayList<>();
|
|
|
|
|
QueryWrapper<CsStatisticalSetPO> queryWrap = new QueryWrapper<>();
|
|
|
|
|
queryWrap.lambda().eq(CsStatisticalSetPO::getStatisicalId, id);
|
|
|
|
|
this.getBaseMapper().delete(queryWrap);
|
|
|
|
|
ids.forEach(tempId -> {
|
|
|
|
|
CsStatisticalSetPO csStatisticalSetPO = new CsStatisticalSetPO();
|
|
|
|
|
csStatisticalSetPO.setStatisicalId(id);
|
|
|
|
|
csStatisticalSetPO.setTargetId(tempId);
|
|
|
|
|
csStatisticalSetPOList.add(csStatisticalSetPO);
|
|
|
|
|
public Boolean saveData(List<CsStatisticalSetAddParam> csStatisticalSetAddParams) {
|
|
|
|
|
csStatisticalSetAddParams.forEach(temp->{
|
|
|
|
|
List<CsStatisticalSetPO> csStatisticalSetPOList = new ArrayList<>();
|
|
|
|
|
QueryWrapper<CsStatisticalSetPO> queryWrap = new QueryWrapper<>();
|
|
|
|
|
queryWrap.lambda().eq(CsStatisticalSetPO::getStatisicalId, temp.getId());
|
|
|
|
|
this.getBaseMapper().delete(queryWrap);
|
|
|
|
|
temp.getIds().forEach(tempId -> {
|
|
|
|
|
CsStatisticalSetPO csStatisticalSetPO = new CsStatisticalSetPO();
|
|
|
|
|
csStatisticalSetPO.setStatisicalId(temp.getId());
|
|
|
|
|
csStatisticalSetPO.setTargetId(tempId);
|
|
|
|
|
csStatisticalSetPOList.add(csStatisticalSetPO);
|
|
|
|
|
});
|
|
|
|
|
boolean b = this.saveBatch(csStatisticalSetPOList);
|
|
|
|
|
});
|
|
|
|
|
boolean b = this.saveBatch(csStatisticalSetPOList);
|
|
|
|
|
return b;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public CsStatisticalSetVO queryStatistical(String id) {
|
|
|
|
|
CsStatisticalSetVO csStatisticalSetVO = new CsStatisticalSetVO();
|
|
|
|
|
QueryWrapper<CsStatisticalSetPO> queryWrap = new QueryWrapper<>();
|
|
|
|
|
queryWrap.lambda().eq(CsStatisticalSetPO::getStatisicalId, id);
|
|
|
|
|
List<CsStatisticalSetPO> result = this.baseMapper.selectList(queryWrap);
|
|
|
|
|
List<String> collect = result.stream().map(CsStatisticalSetPO::getTargetId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
List<EleEpdPqdListVO> allList = epdPqdService.selectAll();
|
|
|
|
|
List<EleEpdPqdListVO> selectedList = new ArrayList<>();
|
|
|
|
|
List<EleEpdPqdListVO> unSelectedList = new ArrayList<>();
|
|
|
|
|
List<DictTreeVO> dictTreeVOS = sysDicTreePOService.queryByPid(id);
|
|
|
|
|
// SysDicTreePO sysDicTreePO = sysDicTreePOService.queryById(id);
|
|
|
|
|
// DictTreeVO dictTreeVO = new DictTreeVO();
|
|
|
|
|
// BeanUtils.copyProperties(sysDicTreePO,dictTreeVO);
|
|
|
|
|
// dictTreeVOS.add(dictTreeVO);
|
|
|
|
|
List<String> collect;
|
|
|
|
|
if(!CollectionUtils.isEmpty(dictTreeVOS)){
|
|
|
|
|
List<String> collect3 = dictTreeVOS.stream().map(DictTreeVO::getId).collect(Collectors.toList());
|
|
|
|
|
collect3.add(id);
|
|
|
|
|
QueryWrapper<CsStatisticalSetPO> queryWrap = new QueryWrapper<>();
|
|
|
|
|
queryWrap.lambda().in(CsStatisticalSetPO::getStatisicalId, collect3);
|
|
|
|
|
List<CsStatisticalSetPO> result = this.baseMapper.selectList(queryWrap);
|
|
|
|
|
collect = result.stream().map(CsStatisticalSetPO::getTargetId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, List<CsStatisticalSetPO>> collect1 = result.stream().collect(Collectors.groupingBy(CsStatisticalSetPO::getStatisicalId));
|
|
|
|
|
dictTreeVOS.forEach(temp->{
|
|
|
|
|
EleEpdPqdListVO vo = new EleEpdPqdListVO();
|
|
|
|
|
vo.setDataType(temp.getId());
|
|
|
|
|
List<CsStatisticalSetPO> collect2 = result.stream().filter(csStatisticalSetPO -> Objects.equals(csStatisticalSetPO.getStatisicalId(), temp.getId())).collect(Collectors.toList());
|
|
|
|
|
List<EleEpdPqd> eleEpdPqds = new ArrayList<>();
|
|
|
|
|
if(!CollectionUtil.isEmpty(collect2)){
|
|
|
|
|
List<String> collect4 = collect2.stream().map(CsStatisticalSetPO::getTargetId).collect(Collectors.toList());
|
|
|
|
|
eleEpdPqds = epdPqdService.getBaseMapper().selectBatchIds(collect4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (EleEpdPqdListVO temp :allList){
|
|
|
|
|
EleEpdPqdListVO selected = new EleEpdPqdListVO();
|
|
|
|
|
EleEpdPqdListVO unSelected = new EleEpdPqdListVO();
|
|
|
|
|
List<EleEpdPqd> all = temp.getEleEpdPqdVOS();
|
|
|
|
|
List<EleEpdPqd> selectedELe = all.stream().filter(tempEleEpdPqd -> collect.contains(tempEleEpdPqd.getId())).collect(Collectors.toList());
|
|
|
|
|
List<EleEpdPqd> unSelectedELe = all.stream().filter(tempEleEpdPqd -> !collect.contains(tempEleEpdPqd.getId())).collect(Collectors.toList());
|
|
|
|
|
vo.setEleEpdPqdVOS(eleEpdPqds);
|
|
|
|
|
vo.setDataTypeName(temp.getName());
|
|
|
|
|
selectedList.add(vo);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
collect = new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
selected.setDataTypeName(temp.getDataTypeName());
|
|
|
|
|
selected.setDataType(temp.getDataTypeName());
|
|
|
|
|
selected.setEleEpdPqdVOS(selectedELe);
|
|
|
|
|
unSelected.setDataTypeName(temp.getDataTypeName());
|
|
|
|
|
unSelected.setDataType(temp.getDataTypeName());
|
|
|
|
|
unSelected.setEleEpdPqdVOS(unSelectedELe);
|
|
|
|
|
selectedList.add(selected);
|
|
|
|
|
unSelectedList.add(unSelected);
|
|
|
|
|
}
|
|
|
|
|
csStatisticalSetVO.setUnSelectedList(unSelectedList);
|
|
|
|
|
csStatisticalSetVO.setSelectedList(selectedList);
|
|
|
|
|
|
|
|
|
|
for (EleEpdPqdListVO temp :allList){
|
|
|
|
|
// EleEpdPqdListVO selected = new EleEpdPqdListVO();
|
|
|
|
|
EleEpdPqdListVO unSelected = new EleEpdPqdListVO();
|
|
|
|
|
List<EleEpdPqd> all = temp.getEleEpdPqdVOS();
|
|
|
|
|
|
|
|
|
|
// List<EleEpdPqd> selectedELe = all.stream().filter(tempEleEpdPqd -> collect.contains(tempEleEpdPqd.getId())).collect(Collectors.toList());
|
|
|
|
|
List<EleEpdPqd> unSelectedELe = all.stream().filter(tempEleEpdPqd -> !collect.contains(tempEleEpdPqd.getId())).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
// selected.setDataTypeName(temp.getDataTypeName());
|
|
|
|
|
// selected.setDataType(temp.getDataTypeName());
|
|
|
|
|
// selected.setEleEpdPqdVOS(selectedELe);
|
|
|
|
|
unSelected.setDataTypeName(temp.getDataTypeName());
|
|
|
|
|
unSelected.setDataType(temp.getDataType());
|
|
|
|
|
unSelected.setEleEpdPqdVOS(unSelectedELe);
|
|
|
|
|
// selectedList.add(selected);
|
|
|
|
|
unSelectedList.add(unSelected);
|
|
|
|
|
}
|
|
|
|
|
csStatisticalSetVO.setUnSelectedList(unSelectedList);
|
|
|
|
|
csStatisticalSetVO.setSelectedList(selectedList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|