指标库代码
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package com.njcn.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.system.pojo.po.CsStatisticalSetPO;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/9 16:17【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface CsStatisticalSetPOMapper extends MppBaseMapper<CsStatisticalSetPO> {
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
import com.njcn.system.pojo.vo.DictTreeVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/9 14:00【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface SysDicTreePOMapper extends BaseMapper<SysDicTreePO> {
|
||||
List<DictTreeVO> queryByid(@Param("id") String id);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.system.mapper.SysDicTreePOMapper">
|
||||
<resultMap id="BaseResultMap" type="com.njcn.system.pojo.po.SysDicTreePO">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table sys_dic_tree-->
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="pid" jdbcType="VARCHAR" property="pid" />
|
||||
<result column="pids" jdbcType="LONGVARCHAR" property="pids" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="code" jdbcType="VARCHAR" property="code" />
|
||||
<result column="sort" jdbcType="INTEGER" property="sort" />
|
||||
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
||||
<result column="status" jdbcType="TINYINT" property="status" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, pid, pids, `name`, code, sort, remark, `status`, create_time, create_by, update_time,
|
||||
update_by
|
||||
</sql>
|
||||
|
||||
<select id="queryByid" resultType="com.njcn.system.pojo.vo.DictTreeVO">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sys_dic_tree a
|
||||
WHERE
|
||||
a.pids LIKE concat('%',#{id},'%')
|
||||
AND NOT EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
sys_dic_tree b
|
||||
WHERE
|
||||
b.pids LIKE concat('%',#{id},'%') and a.id = b.pid)
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.system.service;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.IMppService;
|
||||
import com.njcn.system.pojo.po.CsStatisticalSetPO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.system.pojo.vo.CsStatisticalSetVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/9 16:17【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface CsStatisticalSetPOService extends IMppService<CsStatisticalSetPO> {
|
||||
|
||||
|
||||
Boolean saveData(String id, List<String> ids);
|
||||
|
||||
CsStatisticalSetVO queryStatistical(String id);
|
||||
|
||||
List<EleEpdPqd> queryStatisticalSelect(String id);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.system.service;
|
||||
|
||||
import com.njcn.system.pojo.param.DictTreeParam;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.system.pojo.vo.DictTreeVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/9 14:00【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface SysDicTreePOService extends IService<SysDicTreePO>{
|
||||
|
||||
|
||||
boolean addDictTree(DictTreeParam dictTreeParam);
|
||||
|
||||
List<DictTreeVO> queryByPid(String pid);
|
||||
|
||||
DictTreeVO queryByCode(String code);
|
||||
|
||||
List<DictTreeVO> queryByid(String id);
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
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.vo.CsStatisticalSetVO;
|
||||
import com.njcn.system.pojo.vo.EleEpdPqdListVO;
|
||||
import com.njcn.system.service.IEleEpdPqdService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/9 16:17【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CsStatisticalSetPOServiceImpl extends MppServiceImpl<CsStatisticalSetPOMapper, CsStatisticalSetPO> implements CsStatisticalSetPOService{
|
||||
|
||||
private final IEleEpdPqdService epdPqdService;
|
||||
|
||||
@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);
|
||||
});
|
||||
boolean b = this.saveBatch(csStatisticalSetPOList);
|
||||
return b;
|
||||
}
|
||||
|
||||
@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<>();
|
||||
|
||||
|
||||
|
||||
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.getDataTypeName());
|
||||
unSelected.setEleEpdPqdVOS(unSelectedELe);
|
||||
selectedList.add(selected);
|
||||
unSelectedList.add(unSelected);
|
||||
}
|
||||
csStatisticalSetVO.setUnSelectedList(unSelectedList);
|
||||
csStatisticalSetVO.setSelectedList(selectedList);
|
||||
|
||||
|
||||
|
||||
return csStatisticalSetVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EleEpdPqd> queryStatisticalSelect(String id) {
|
||||
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<EleEpdPqd> eleEpdPqds = epdPqdService.listByIds(collect);
|
||||
return eleEpdPqds;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.njcn.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.njcn.system.pojo.param.DictTreeParam;
|
||||
import com.njcn.system.pojo.vo.DictTreeVO;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.system.mapper.SysDicTreePOMapper;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
import com.njcn.system.service.SysDicTreePOService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/9 14:00【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Service
|
||||
public class SysDicTreePOServiceImpl extends ServiceImpl<SysDicTreePOMapper, SysDicTreePO> implements SysDicTreePOService{
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean addDictTree(DictTreeParam dictTreeParam) {
|
||||
SysDicTreePO sysDicTreePO = new SysDicTreePO();
|
||||
BeanUtils.copyProperties(dictTreeParam, sysDicTreePO);
|
||||
if(!Objects.equals(sysDicTreePO.getPid(), "0")){
|
||||
QueryWrapper<SysDicTreePO> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
queryWrapper.eq("id", sysDicTreePO.getPid());
|
||||
SysDicTreePO instance = this.baseMapper.selectOne(queryWrapper);
|
||||
|
||||
|
||||
sysDicTreePO.setPids(instance.getPids()+","+instance.getId());
|
||||
|
||||
}else{
|
||||
sysDicTreePO.setPids("0");
|
||||
}
|
||||
sysDicTreePO.setStatus("0");
|
||||
boolean save = this.save(sysDicTreePO);
|
||||
|
||||
return save;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictTreeVO> queryByPid(String pid) {
|
||||
LambdaQueryWrapper<SysDicTreePO> query = new LambdaQueryWrapper<>();
|
||||
query.clear();
|
||||
query.eq(SysDicTreePO::getPid, pid).eq(SysDicTreePO::getStatus,"0");
|
||||
List<SysDicTreePO> resultList = this.list(query);
|
||||
|
||||
SysDicTreePO byId = this.getById(pid);
|
||||
|
||||
if (resultList != null && resultList.size() > 0) {
|
||||
List<DictTreeVO> collect = resultList.stream().map(temp -> {
|
||||
DictTreeVO resultVO = new DictTreeVO();
|
||||
BeanUtils.copyProperties(temp, resultVO);
|
||||
|
||||
resultVO.setPname(byId.getName());
|
||||
return resultVO;
|
||||
}).collect(Collectors.toList());
|
||||
return collect;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictTreeVO queryByCode(String code) {
|
||||
LambdaQueryWrapper<SysDicTreePO> query = new LambdaQueryWrapper<>();
|
||||
query.clear();
|
||||
query.eq(SysDicTreePO::getCode, code).eq(SysDicTreePO::getStatus,"0");
|
||||
SysDicTreePO result = this.getOne(query);
|
||||
|
||||
if (result != null) {
|
||||
DictTreeVO resultVO = new DictTreeVO();
|
||||
BeanUtils.copyProperties(result, resultVO);
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictTreeVO> queryByid(String id) {
|
||||
List<DictTreeVO> dictTreeVOS=this.baseMapper.queryByid(id);
|
||||
return dictTreeVOS;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user