fix(自定义对比): 自定义对比查询问题修复
This commit is contained in:
+15
-1
@@ -4,6 +4,7 @@ package com.jero.modules.laws.customcompare.controller;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
import com.jero.common.aspect.annotation.Translation;
|
||||
import com.jero.common.util.MessageUtils;
|
||||
import com.jero.modules.laws.common.constant.ResultCommon;
|
||||
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareCell;
|
||||
@@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -64,7 +66,7 @@ public class LawsCustomCompareInfoController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义对比-标准检索
|
||||
* 自定义对比-标准检索分页列表查询
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "自定义对比-标准检索分页列表查询")
|
||||
@@ -76,6 +78,17 @@ public class LawsCustomCompareInfoController {
|
||||
return Result.OK(lawsCustomCompareInfoService.queryStandard(standardVO, pageNo, pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义对比-标准检索列表查询
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "自定义对比-标准检索列表查询")
|
||||
@ApiOperation(value="自定义对比-标准检索列表查询", notes="自定义对比-标准检索列表查询")
|
||||
@GetMapping(value = "/queryStandardList")
|
||||
public Result<List<StandardVO>> queryStandardList(StandardVO standardVO) {
|
||||
return Result.OK(lawsCustomCompareInfoService.queryStandardList(standardVO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义对比-删除标准列表
|
||||
* @return
|
||||
@@ -166,6 +179,7 @@ public class LawsCustomCompareInfoController {
|
||||
@AutoLog(value = "自定义对比-通过id查询")
|
||||
@ApiOperation(value="自定义对比-通过id查询", notes="自定义对比-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
@Translation
|
||||
public Result<LawsCustomCompareInfoVO> queryById(String id) {
|
||||
return Result.OK(lawsCustomCompareInfoService.queryById(id));
|
||||
}
|
||||
|
||||
+10
-1
@@ -5,11 +5,13 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.modules.laws.customcompare.vo.LawsCustomCompareInfoVO;
|
||||
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareInfo;
|
||||
import com.jero.modules.laws.customcompare.vo.LawsCustomCompareInfoVO;
|
||||
import com.jero.modules.laws.customcompare.vo.StandardVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: 31318
|
||||
* @Date: 2023/10/24/17:50
|
||||
@@ -33,6 +35,13 @@ public interface LawsCustomCompareInfoMapper extends BaseMapper<LawsCustomCompar
|
||||
*/
|
||||
IPage<StandardVO> queryStandard(Page<StandardVO> page, @Param(Constants.WRAPPER) QueryWrapper<StandardVO> queryWrapper);
|
||||
|
||||
/**
|
||||
* 自定义对比-标准检索
|
||||
* @param queryWrapper
|
||||
* @return
|
||||
*/
|
||||
List<StandardVO> queryStandardList(QueryWrapper<StandardVO> queryWrapper);
|
||||
|
||||
/**
|
||||
* 自定义对比-自定义对比-通过id查询
|
||||
* @param queryWrapper
|
||||
|
||||
+21
-13
@@ -7,19 +7,11 @@
|
||||
</select>
|
||||
|
||||
<select id="queryStandard" resultType="com.jero.modules.laws.customcompare.vo.StandardVO">
|
||||
select standard.*
|
||||
from (select id, standard_number, standard_name, standard_state, '' country_or_region, release_date, 1 standard_type
|
||||
from laws_domestic_standard
|
||||
where del_flag = 0
|
||||
union all
|
||||
select id, standard_number, standard_name, standard_state, country_or_region, release_date, 2 standard_type
|
||||
from laws_overseas_standard
|
||||
where del_flag = 0
|
||||
union all
|
||||
select id, standard_number, standard_name, standard_state, '' country_or_region, release_date, 3 standard_type
|
||||
from laws_enterprise_standard
|
||||
where del_flag = 0) standard
|
||||
${ew.customSqlSegment}
|
||||
<include refid="queryStandard"/>
|
||||
</select>
|
||||
|
||||
<select id="queryStandardList" resultType="com.jero.modules.laws.customcompare.vo.StandardVO">
|
||||
<include refid="queryStandard"/>
|
||||
</select>
|
||||
|
||||
<select id="queryById" resultType="com.jero.modules.laws.customcompare.vo.LawsCustomCompareInfoVO">
|
||||
@@ -48,4 +40,20 @@
|
||||
${ew.customSqlSegment}
|
||||
group by i.id
|
||||
</sql>
|
||||
|
||||
<sql id="queryStandard">
|
||||
select standard.*
|
||||
from (select id, standard_number, standard_name, standard_state, '' country_or_region, release_date, 1 standard_type
|
||||
from laws_domestic_standard
|
||||
where del_flag = 0
|
||||
union all
|
||||
select id, standard_number, standard_name, standard_state, country_or_region, release_date, 2 standard_type
|
||||
from laws_overseas_standard
|
||||
where del_flag = 0
|
||||
union all
|
||||
select id, standard_number, standard_name, standard_state, '' country_or_region, release_date, 3 standard_type
|
||||
from laws_enterprise_standard
|
||||
where del_flag = 0) standard
|
||||
${ew.customSqlSegment}
|
||||
</sql>
|
||||
</mapper>
|
||||
|
||||
+10
-1
@@ -10,6 +10,7 @@ import com.jero.modules.laws.customcompare.vo.TableDetailVO;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -30,7 +31,7 @@ public interface ILawsCustomCompareInfoService extends IService<LawsCustomCompar
|
||||
IPage<LawsCustomCompareInfoVO> queryByPage(LawsCustomCompareInfoVO lawsCustomCompareInfoVO, Integer pageNo, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 自定义对比-标准检索
|
||||
* 自定义对比-标准检索分页列表查询
|
||||
* @param standardVO
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
@@ -38,6 +39,14 @@ public interface ILawsCustomCompareInfoService extends IService<LawsCustomCompar
|
||||
*/
|
||||
IPage<StandardVO> queryStandard(StandardVO standardVO, Integer pageNo, Integer pageSize);
|
||||
|
||||
|
||||
/**
|
||||
*自定义对比-标准检索列表查询
|
||||
* @param standardVO
|
||||
* @return
|
||||
*/
|
||||
List<StandardVO> queryStandardList(StandardVO standardVO);
|
||||
|
||||
/**
|
||||
* 自定义对比-通过id查询
|
||||
* @param id
|
||||
|
||||
+62
-14
@@ -3,6 +3,7 @@ package com.jero.modules.laws.customcompare.service.impl;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -44,6 +45,7 @@ import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -123,6 +125,12 @@ public class LawsCustomCompareInfoServiceImpl extends ServiceImpl<LawsCustomComp
|
||||
|
||||
@Override
|
||||
public IPage<StandardVO> queryStandard(StandardVO standardVO, Integer pageNo, Integer pageSize) {
|
||||
QueryWrapper<StandardVO> queryWrapper = getStandardVOQueryWrapper(standardVO);
|
||||
return lawsCustomCompareInfoMapper.queryStandard(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static QueryWrapper<StandardVO> getStandardVOQueryWrapper(StandardVO standardVO) {
|
||||
QueryWrapper<StandardVO> queryWrapper = new QueryWrapper<>();
|
||||
// 标准编号/标准名称
|
||||
if (StringUtils.isNotBlank(standardVO.getStandardNumberOrName())){
|
||||
@@ -135,18 +143,30 @@ public class LawsCustomCompareInfoServiceImpl extends ServiceImpl<LawsCustomComp
|
||||
List<String> list = Arrays.asList(standardVO.getIds().split(","));
|
||||
queryWrapper.in("id", list);
|
||||
}
|
||||
if(StringUtils.isNotBlank(standardVO.getStandardNumbers())){
|
||||
List<String> list = Arrays.asList(standardVO.getStandardNumber().split(","));
|
||||
queryWrapper.in("standard_number", list);
|
||||
}
|
||||
queryWrapper.eq(StringUtils.isNotBlank(standardVO.getStandardNumber()), "standard_number", standardVO.getStandardNumber());
|
||||
queryWrapper.eq(StringUtils.isNotBlank(standardVO.getStandardState()), "standard_state", standardVO.getStandardState());
|
||||
queryWrapper.apply(StringUtils.isNotBlank(standardVO.getReleaseDateBegin()),
|
||||
"date_format (create_time,'%Y-%m-%d') >= date_format ({0},'%Y-%m-%d')", standardVO.getReleaseDateBegin())
|
||||
.apply(StringUtils.isNotBlank(standardVO.getReleaseDatesEnd()),
|
||||
"date_format (create_time,'%Y-%m-%d') <= date_format ({0},'%Y-%m-%d')", standardVO.getReleaseDatesEnd());
|
||||
return lawsCustomCompareInfoMapper.queryStandard(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StandardVO> queryStandardList(StandardVO standardVO) {
|
||||
QueryWrapper<StandardVO> queryWrapper = getStandardVOQueryWrapper(standardVO);
|
||||
return lawsCustomCompareInfoMapper.queryStandardList(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LawsCustomCompareInfoVO queryById(String id) {
|
||||
QueryWrapper<LawsCustomCompareInfoVO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("id", id);
|
||||
queryWrapper.eq("i.id", id);
|
||||
return lawsCustomCompareInfoMapper.queryById(queryWrapper);
|
||||
}
|
||||
|
||||
@@ -154,25 +174,53 @@ public class LawsCustomCompareInfoServiceImpl extends ServiceImpl<LawsCustomComp
|
||||
public void saveStandard(StandardSaveVO standardSaveVO) {
|
||||
// 自定义对比表
|
||||
LawsCustomCompareInfo lawsCustomCompareInfo = standardSaveVO.getLawsCustomCompareInfo();
|
||||
// 自定义对比_标准 关联表
|
||||
LawsCustomCompareInfoStandard lawsCustomCompareInfoStandard = standardSaveVO.getLawsCustomCompareInfoStandard();
|
||||
String id = String.valueOf(SnowflakeUtils.snowflake());
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
// 自定义对比数据不存在则新增
|
||||
if (StringUtils.isBlank(lawsCustomCompareInfo.getId())){
|
||||
lawsCustomCompareInfo.setId(id);
|
||||
lawsCustomCompareInfo.setAuthor(sysUser.getId());
|
||||
}
|
||||
saveOrUpdate(lawsCustomCompareInfo);
|
||||
|
||||
// 处理关联表数据
|
||||
// 删除旧数据
|
||||
lawsCustomCompareInfoStandardService.remove(
|
||||
new LambdaQueryWrapper<LawsCustomCompareInfoStandard>()
|
||||
.eq(LawsCustomCompareInfoStandard::getInfoId, lawsCustomCompareInfo.getId()));
|
||||
lawsCustomCompareInfoStandard.setInfoId(lawsCustomCompareInfo.getId());
|
||||
// 添加新数据
|
||||
lawsCustomCompareInfoStandardService.save(lawsCustomCompareInfoStandard);
|
||||
// 处理自定义对比_标准 关联表
|
||||
if (StringUtils.isBlank(standardSaveVO.getStandardNumber())){
|
||||
// 删除数据
|
||||
lawsCustomCompareInfoStandardService.remove(
|
||||
new LambdaQueryWrapper<LawsCustomCompareInfoStandard>()
|
||||
.eq(LawsCustomCompareInfoStandard::getInfoId, lawsCustomCompareInfo.getId()));
|
||||
// 自定义对比单元格数据 删除
|
||||
lawsCustomCompareCellService.remove(
|
||||
new LambdaUpdateWrapper<LawsCustomCompareCell>()
|
||||
.eq(LawsCustomCompareCell::getInfoId, lawsCustomCompareInfo.getId()));
|
||||
}else {
|
||||
// 更新数据
|
||||
StandardVO standardVO = new StandardVO();
|
||||
standardVO.setStandardNumbers(standardSaveVO.getStandardNumber());
|
||||
List<StandardVO> standardVOS = queryStandardList(standardVO);
|
||||
List<LawsCustomCompareInfoStandard> lawsCustomCompareInfoStandards = BeanCopyUtils.copyBeanList(standardVOS, LawsCustomCompareInfoStandard.class);
|
||||
for (LawsCustomCompareInfoStandard lawsCustomCompareInfoStandard : lawsCustomCompareInfoStandards) {
|
||||
String snowflakeId = String.valueOf(SnowflakeUtils.snowflake());
|
||||
// 自定义对比单元格数据更新
|
||||
lawsCustomCompareCellService.update(
|
||||
new LambdaUpdateWrapper<LawsCustomCompareCell>()
|
||||
.eq(LawsCustomCompareCell::getInfoId, lawsCustomCompareInfo.getId())
|
||||
.eq(LawsCustomCompareCell::getStandardId, lawsCustomCompareInfoStandard.getId())
|
||||
.set(LawsCustomCompareCell::getStandardId, snowflakeId));
|
||||
|
||||
lawsCustomCompareInfoStandard.setId(snowflakeId);
|
||||
lawsCustomCompareInfoStandard.setCreateBy("");
|
||||
lawsCustomCompareInfoStandard.setCreateTime(null);
|
||||
lawsCustomCompareInfoStandard.setUpdateBy("");
|
||||
lawsCustomCompareInfoStandard.setUpdateTime(null);
|
||||
lawsCustomCompareInfoStandardService.save(lawsCustomCompareInfoStandard);
|
||||
}
|
||||
|
||||
// 自定义对比单元格 删除
|
||||
String ids = standardVOS.stream().map(StandardVO::getId).collect(Collectors.joining(","));
|
||||
lawsCustomCompareCellService.remove(
|
||||
new LambdaUpdateWrapper<LawsCustomCompareCell>()
|
||||
.eq(LawsCustomCompareCell::getInfoId, lawsCustomCompareInfo.getId())
|
||||
.notIn(LawsCustomCompareCell::getStandardId, ids));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-4
@@ -1,7 +1,6 @@
|
||||
package com.jero.modules.laws.customcompare.vo;
|
||||
|
||||
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareInfo;
|
||||
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareInfoStandard;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -15,7 +14,7 @@ public class StandardSaveVO {
|
||||
/**自定义对比表*/
|
||||
@ApiModelProperty(value = "自定义对比表")
|
||||
private LawsCustomCompareInfo lawsCustomCompareInfo;
|
||||
/**自定义对比_标准 关联表*/
|
||||
@ApiModelProperty(value = "自定义对比_标准 关联表")
|
||||
private LawsCustomCompareInfoStandard lawsCustomCompareInfoStandard;
|
||||
/**标准号*/
|
||||
@ApiModelProperty(value = "标准号")
|
||||
private String standardNumber;
|
||||
}
|
||||
|
||||
@@ -53,4 +53,7 @@ public class StandardVO {
|
||||
/**ids 搜索用*/
|
||||
@ApiModelProperty(value = "ids 搜索用")
|
||||
private String ids;
|
||||
/**标准号 搜索用*/
|
||||
@ApiModelProperty(value = "标准号 搜索用")
|
||||
private String standardNumbers;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user