代码提交
This commit is contained in:
@@ -8,6 +8,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
|
||||
import com.njcn.system.pojo.param.CsStatisticalSetAddParam;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.system.pojo.vo.CsStatisticalSetVO;
|
||||
|
||||
@@ -48,14 +49,10 @@ public class CsStatisticalSetController extends BaseController {
|
||||
@PostMapping("/addStatistical")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("绑定指标")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "统计类型id", required = true),
|
||||
@ApiImplicitParam(name = "ids", value = "统计指标id集合", required = true)
|
||||
})
|
||||
public HttpResult<Boolean> addStatistical(@RequestParam("id")String id,@RequestParam("ids")List<String> ids){
|
||||
public HttpResult<Boolean> addStatistical(@RequestBody List<CsStatisticalSetAddParam> csStatisticalSetAddParams){
|
||||
log.info("根据模板录入字典数据");
|
||||
String methodDescribe = getMethodDescribe("addstatistical");
|
||||
Boolean result = csStatisticalSetPOService.saveData(id,ids);
|
||||
Boolean result = csStatisticalSetPOService.saveData(csStatisticalSetAddParams);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@@ -71,7 +68,7 @@ public class CsStatisticalSetController extends BaseController {
|
||||
|
||||
@PostMapping("/queryStatisticalSelect")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("根据统计类型id查询已绑定指标下拉框")
|
||||
@ApiOperation("根据统计类型id组查询已绑定指标")
|
||||
public HttpResult<List<EleEpdPqd>> queryStatisticalSelect(@RequestParam("id")String id){
|
||||
log.info("根据模板录入字典数据");
|
||||
String methodDescribe = getMethodDescribe("EleEpdPqd");
|
||||
@@ -82,5 +79,7 @@ public class CsStatisticalSetController extends BaseController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.system.service;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.IMppService;
|
||||
import com.njcn.system.pojo.param.CsStatisticalSetAddParam;
|
||||
import com.njcn.system.pojo.po.CsStatisticalSetPO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
@@ -19,7 +20,7 @@ import java.util.List;
|
||||
public interface CsStatisticalSetPOService extends IMppService<CsStatisticalSetPO> {
|
||||
|
||||
|
||||
Boolean saveData(String id, List<String> ids);
|
||||
Boolean saveData(List<CsStatisticalSetAddParam> csStatisticalSetAddParams);
|
||||
|
||||
CsStatisticalSetVO queryStatistical(String id);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user