feat(自定义对比): 功能开发

This commit is contained in:
yjz
2023-10-26 16:12:58 +08:00
parent 21a25ae474
commit b346065657
33 changed files with 1569 additions and 8 deletions
@@ -0,0 +1,40 @@
package com.jero.modules.laws.customcompare.common;
/**
* @Author: yjz
* @Date: 2023/10/13/11:46
* @Description:
*/
public class LawsCustomCompareCommon {
private LawsCustomCompareCommon(){
}
/**
* 是否公开(1:是,0:否)
*/
public static final String IS_SHOW_1 = "1";
/**
* 是否公开(1:是,0:否)
*/
public static final String IS_SHOW_0 = "0";
/**
* 标准类型(1:国内,2:海外,3:企业)
*/
public static final String STANDARD_TYPE1 = "1";
/**
* 标准类型(1:国内,2:海外,3:企业)
*/
public static final String STANDARD_TYPE2 = "2";
/**
* 标准类型(1:国内,2:海外,3:企业)
*/
public static final String STANDARD_TYPE3 = "3";
/**
* 清单维护类型(1:特点,2:对比项)
*/
public static final String INVENTORY_TYPE_1 = "1";
/**
* 清单维护类型(1:特点,2:对比项)
*/
public static final String INVENTORY_TYPE_2 = "2";
}
@@ -0,0 +1,18 @@
package com.jero.modules.laws.customcompare.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 自定义对比单元格内容表
*
* @author yjz
* @since 2023-10-24 17:59:27
*/
@RestController
@RequestMapping("/customCompare/lawsCustomCompareCell")
public class LawsCustomCompareCellController {
}
@@ -0,0 +1,213 @@
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.util.MessageUtils;
import com.jero.modules.laws.common.constant.ResultCommon;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareCell;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareInfo;
import com.jero.modules.laws.customcompare.service.ILawsCustomCompareCellService;
import com.jero.modules.laws.customcompare.service.ILawsCustomCompareInfoService;
import com.jero.modules.laws.customcompare.service.ILawsCustomCompareInventoryService;
import com.jero.modules.laws.customcompare.vo.LawsCustomCompareInfoVO;
import com.jero.modules.laws.customcompare.vo.StandardSaveVO;
import com.jero.modules.laws.customcompare.vo.StandardVO;
import com.jero.modules.laws.customcompare.vo.TableDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/**
* 自定义对比
*
* @author yjz
* @since 2023-10-24 17:45:51
*/
@Api(tags="自定义对比")
@Slf4j
@RestController
@RequestMapping("/customCompare/lawsCustomCompareInfo")
public class LawsCustomCompareInfoController {
private final ILawsCustomCompareInfoService lawsCustomCompareInfoService;
private final ILawsCustomCompareCellService lawsCustomCompareCellService;
private final ILawsCustomCompareInventoryService lawsCustomCompareInventoryService;
public LawsCustomCompareInfoController(ILawsCustomCompareInfoService lawsCustomCompareInfoService,
@Lazy ILawsCustomCompareCellService lawsCustomCompareCellService,
@Lazy ILawsCustomCompareInventoryService lawsCustomCompareInventoryService) {
this.lawsCustomCompareInfoService = lawsCustomCompareInfoService;
this.lawsCustomCompareCellService = lawsCustomCompareCellService;
this.lawsCustomCompareInventoryService = lawsCustomCompareInventoryService;
}
/**
* 自定义对比-分页列表查询
* @return
*/
@AutoLog(value = "自定义对比-分页列表查询")
@ApiOperation(value="自定义对比-分页列表查询", notes="自定义对比-分页列表查询")
@GetMapping(value = "/queryByPage")
public Result<IPage<LawsCustomCompareInfoVO>> queryByPage(LawsCustomCompareInfoVO lawsCustomCompareInfoVO,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
return Result.OK(lawsCustomCompareInfoService.queryByPage(lawsCustomCompareInfoVO, pageNo, pageSize));
}
/**
* 自定义对比-标准检索
* @return
*/
@AutoLog(value = "自定义对比-标准检索分页列表查询")
@ApiOperation(value="自定义对比-标准检索分页列表查询", notes="自定义对比-标准检索分页列表查询")
@GetMapping(value = "/queryStandard")
public Result<IPage<StandardVO>> queryStandard(StandardVO standardVO,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
return Result.OK(lawsCustomCompareInfoService.queryStandard(standardVO, pageNo, pageSize));
}
/**
* 自定义对比-删除标准列表
* @return
*/
@AutoLog(value = "自定义对比-删除标准列表")
@ApiOperation(value="自定义对比-删除标准列表", notes="自定义对比-删除标准列表")
@GetMapping(value = "/delStandard")
public Result<T> delStandard(String infoId, String standardId) {
lawsCustomCompareInfoService.delStandard(infoId, standardId);
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
}
/**
* 自定义对比-标准列表查询
* @return
*/
@AutoLog(value = "自定义对比-标准列表分页查询")
@ApiOperation(value="自定义对比-标准列表分页查询", notes="自定义对比-标准列表分页查询")
@GetMapping(value = "/queryStandardByInfoId")
public Result<IPage<StandardVO>> queryStandardList(String id,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
return Result.OK(lawsCustomCompareInfoService.queryStandardByInfoId(id, pageNo, pageSize));
}
/**
* 自定义对比-表格详情
* @return
*/
@AutoLog(value = "自定义对比-表格详情")
@ApiOperation(value="自定义对比-表格详情", notes="自定义对比-表格详情")
@GetMapping(value = "/queryTableDetail")
public Result<TableDetailVO> queryTableDetail(String id) {
return Result.OK(lawsCustomCompareInfoService.queryTableDetail(id));
}
/**
* 自定义对比-清单维护
* @return
*/
@AutoLog(value = "自定义对比-清单维护列表查询")
@ApiOperation(value="自定义对比-清单维护列表查询", notes="自定义对比-清单维护列表查询")
@GetMapping(value = "/queryInventory")
public Result<Map<String, Object>> queryInventoryByInfoId(String id) {
return Result.OK(lawsCustomCompareInfoService.queryInventory(id));
}
/**
* 自定义对比-标准检索保存
* @return
*/
@AutoLog(value = "自定义对比-标准检索保存")
@ApiOperation(value="自定义对比-标准检索保存", notes="自定义对比-标准检索保存")
@GetMapping(value = "/saveStandard")
public Result<IPage<StandardVO>> saveStandard(StandardSaveVO standardSaveVO) {
lawsCustomCompareInfoService.saveStandard(standardSaveVO);
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
}
/**
* 自定义对比-单元格内容保存
* @return
*/
@AutoLog(value = "自定义对比-单元格内容保存")
@ApiOperation(value="自定义对比-单元格内容保存", notes="自定义对比-单元格内容保存")
@PostMapping(value = "/saveCell")
public Result<IPage<StandardVO>> saveCell(LawsCustomCompareCell lawsCustomCompareCell) {
lawsCustomCompareCellService.save(lawsCustomCompareCell);
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
}
/**
* 自定义对比-通过id查询
* @return
*/
@AutoLog(value = "自定义对比-通过id查询")
@ApiOperation(value="自定义对比-通过id查询", notes="自定义对比-通过id查询")
@GetMapping(value = "/queryById")
public Result<LawsCustomCompareInfoVO> queryById(String id) {
return Result.OK(lawsCustomCompareInfoService.queryById(id));
}
/**
* 自定义对比-保存
* @return
*/
@AutoLog(value = "自定义对比-保存")
@ApiOperation(value="自定义对比-保存", notes="自定义对比-保存")
@PostMapping(value = "/save")
public Result<T> save(@RequestBody LawsCustomCompareInfo lawsCustomCompareInfo) {
lawsCustomCompareInfoService.saveOrUpdate(lawsCustomCompareInfo);
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
}
/**
* 自定义对比-根据id删除
* @return
*/
@AutoLog(value = "自定义对比-根据id删除")
@ApiOperation(value="自定义对比-根据id删除", notes="自定义对比-根据id删除")
@PostMapping(value = "/delById")
public Result<T> delById(@RequestBody Map<String, Object> map) {
if (map.containsKey("id")){
lawsCustomCompareInfoService.delById((String) map.get("id"));
}
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
}
/**
* 自定义对比-根据id删除特点/对比项
* @return
*/
@AutoLog(value = "自定义对比-根据id删除特点/对比项")
@ApiOperation(value="自定义对比-根据id删除特点/对比项", notes="自定义对比-根据id删除特点/对比项")
@PostMapping(value = "/delInventoryById")
public Result<T> delInventoryById(@RequestBody Map<String, Object> map) {
if (map.containsKey("id")){
lawsCustomCompareInventoryService.removeById((String) map.get("id"));
}
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
}
/**
* 自定义对比-导出
* @param request
* @param response
*/
@AutoLog(value = "自定义对比-导出")
@ApiOperation(value = "自定义对比-导出")
@GetMapping("/exportExcel")
public void exportExcel(String id,HttpServletRequest request, HttpServletResponse response) {
lawsCustomCompareInfoService.exportExcel(id, request, response);
}
}
@@ -0,0 +1,18 @@
package com.jero.modules.laws.customcompare.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 自定义对比_标准 关联表
*
* @author yjz
* @since 2023-10-24 17:57:06
*/
@RestController
@RequestMapping("/customCompare/lawsCustomCompareInfoStandard")
public class LawsCustomCompareInfoStandardController {
}
@@ -0,0 +1,18 @@
package com.jero.modules.laws.customcompare.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 自定义对比清单维护表
*
* @author yjz
* @since 2023-10-24 17:57:49
*/
@RestController
@RequestMapping("/customCompare/lawsCustomCompareInventory")
public class LawsCustomCompareInventoryController {
}
@@ -0,0 +1,40 @@
package com.jero.modules.laws.customcompare.entity;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.jero.modules.laws.documenttool.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 自定义对比单元格内容表
*
* @author yjz
* @since 2023-10-24 17:59:27
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class LawsCustomCompareCell extends BaseEntity {
/**自定义对比id*/
@ApiModelProperty(value = "自定义对比id")
private String infoId;
/**标准id*/
@ApiModelProperty(value = "标准id")
private String standardId;
/**特点id*/
@ApiModelProperty(value = "特点id")
private String featureId;
/**对比项id*/
@ApiModelProperty(value = "对比项id")
private String compareItemId;
/**单元格内容*/
@ApiModelProperty(value = "单元格内容")
private String content;
/**文件id*/
@ApiModelProperty(value = "文件id")
@TableField(updateStrategy = FieldStrategy.IGNORED)
private String fileId;
}
@@ -0,0 +1,34 @@
package com.jero.modules.laws.customcompare.entity;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.jero.modules.laws.documenttool.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 自定义对比表
*
* @author yjz
* @since 2023-10-24 17:45:58
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class LawsCustomCompareInfo extends BaseEntity {
/**清单名称*/
@ApiModelProperty(value = "清单名称")
private String listName;
/**是否公开(1:是,0:否)*/
@ApiModelProperty(value = "是否公开(1:是,0:否)")
private String isShow;
/**操作人*/
@ApiModelProperty(value = "操作人")
@TableField(exist = false)
private String author;
/**文件id*/
@ApiModelProperty(value = "文件id")
@TableField(updateStrategy = FieldStrategy.IGNORED)
private String fileId;
}
@@ -0,0 +1,31 @@
package com.jero.modules.laws.customcompare.entity;
import com.jero.modules.laws.documenttool.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 自定义对比_标准 关联表
*
* @author yjz
* @since 2023-10-24 17:57:06
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class LawsCustomCompareInfoStandard extends BaseEntity {
/**自定义对比id*/
@ApiModelProperty(value = "自定义对比id")
private String infoId;
/**标准id*/
@ApiModelProperty(value = "标准id")
private String standardId;
/**标准号*/
@ApiModelProperty(value = "标准号")
private String standardNumber;
/**标准类型(1:国内,2:海外,3:企业)*/
@ApiModelProperty(value = "标准类型(1:国内,2:海外,3:企业)")
private String standardType;
}
@@ -0,0 +1,39 @@
package com.jero.modules.laws.customcompare.entity;
import com.jero.common.aspect.annotation.Dict;
import com.jero.modules.laws.documenttool.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 自定义对比清单维护表
*
* @author yjz
* @since 2023-10-24 17:57:49
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class LawsCustomCompareInventory extends BaseEntity {
/**自定义对比id*/
@ApiModelProperty(value = "自定义对比id")
private String infoId;
/**单元格文本*/
@ApiModelProperty(value = "单元格文本")
private String cellTitle;
/**清单维护类型(1:特点,2:对比项)*/
@ApiModelProperty(value = "清单维护类型(1:特点,2:对比项)")
@Dict(dicCode = "inventory_type")
private String inventoryType;
/**排序*/
@ApiModelProperty(value = "排序")
private Integer orderNum;
/**对比分析结果*/
@ApiModelProperty(value = "对比分析结果")
private String compareResult;
/**颜色*/
@ApiModelProperty(value = "颜色")
private String colour;
}
@@ -0,0 +1,12 @@
package com.jero.modules.laws.customcompare.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareCell;
/**
* @Author: 31318
* @Date: 2023/10/24/18:02
* @Description:
*/
public interface LawsCustomCompareCellMapper extends BaseMapper<LawsCustomCompareCell> {
}
@@ -0,0 +1,42 @@
package com.jero.modules.laws.customcompare.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.StandardVO;
import org.apache.ibatis.annotations.Param;
/**
* @Author: 31318
* @Date: 2023/10/24/17:50
* @Description:
*/
public interface LawsCustomCompareInfoMapper extends BaseMapper<LawsCustomCompareInfo> {
/**
* 自定义对比-分页列表查询
* @param page
* @param queryWrapper
* @return
*/
IPage<LawsCustomCompareInfoVO> queryByPage(Page<LawsCustomCompareInfoVO> page, @Param(Constants.WRAPPER) QueryWrapper<LawsCustomCompareInfoVO> queryWrapper);
/**
* 自定义对比-标准检索
* @param page
* @param queryWrapper
* @return
*/
IPage<StandardVO> queryStandard(Page<StandardVO> page, @Param(Constants.WRAPPER) QueryWrapper<StandardVO> queryWrapper);
/**
* 自定义对比-自定义对比-通过id查询
* @param queryWrapper
* @return
*/
LawsCustomCompareInfoVO queryById(@Param(Constants.WRAPPER) QueryWrapper<LawsCustomCompareInfoVO> queryWrapper);
}
@@ -0,0 +1,12 @@
package com.jero.modules.laws.customcompare.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareInfoStandard;
/**
* @Author: 31318
* @Date: 2023/10/24/18:02
* @Description:
*/
public interface LawsCustomCompareInfoStandardMapper extends BaseMapper<LawsCustomCompareInfoStandard> {
}
@@ -0,0 +1,12 @@
package com.jero.modules.laws.customcompare.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareInventory;
/**
* @Author: 31318
* @Date: 2023/10/24/18:02
* @Description:
*/
public interface LawsCustomCompareInventoryMapper extends BaseMapper<LawsCustomCompareInventory> {
}
@@ -0,0 +1,5 @@
<?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.jero.modules.laws.customcompare.mapper.LawsCustomCompareCellMapper">
</mapper>
@@ -0,0 +1,51 @@
<?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.jero.modules.laws.customcompare.mapper.LawsCustomCompareInfoMapper">
<select id="queryByPage" resultType="com.jero.modules.laws.customcompare.vo.LawsCustomCompareInfoVO">
<include refid="queryInfo"/>
</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}
</select>
<select id="queryById" resultType="com.jero.modules.laws.customcompare.vo.LawsCustomCompareInfoVO">
<include refid="queryInfo"/>
</select>
<sql id="queryInfo">
select i.id,
list_name,
group_concat(s.standard_number order by s.create_by) referenceStandard,
(select group_concat(os.country_or_region order by s.create_by)
from laws_custom_compare_info_standard s
left join laws_overseas_standard os on s.standard_id = os.id and s.standard_type = '2' and os.del_flag = 0
where s.del_flag = 0
) referenceCountry,
is_show,
concat(u.realname, '(', u.username, ')') author,
i.create_by,
i.create_time,
i.update_by,
i.update_time,
i.del_flag
from laws_custom_compare_info i
left join laws_custom_compare_info_standard s on i.id = s.info_id
left join sys_user u on i.create_by = u.username
${ew.customSqlSegment}
group by i.id
</sql>
</mapper>
@@ -0,0 +1,5 @@
<?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.jero.modules.laws.customcompare.mapper.LawsCustomCompareInfoStandardMapper">
</mapper>
@@ -0,0 +1,5 @@
<?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.jero.modules.laws.customcompare.mapper.LawsCustomCompareInventoryMapper">
</mapper>
@@ -0,0 +1,15 @@
package com.jero.modules.laws.customcompare.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareCell;
/**
* 自定义对比单元格内容表(LawsCustomCompareCell)表服务接口
*
* @author yjz
* @since 2023-10-24 17:59:28
*/
public interface ILawsCustomCompareCellService extends IService<LawsCustomCompareCell> {
}
@@ -0,0 +1,94 @@
package com.jero.modules.laws.customcompare.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareInfo;
import com.jero.modules.laws.customcompare.vo.LawsCustomCompareInfoVO;
import com.jero.modules.laws.customcompare.vo.StandardSaveVO;
import com.jero.modules.laws.customcompare.vo.StandardVO;
import com.jero.modules.laws.customcompare.vo.TableDetailVO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/**
* 自定义对比(LawsCustomCompareInfo)表服务接口
*
* @author yjz
* @since 2023-10-24 17:45:58
*/
public interface ILawsCustomCompareInfoService extends IService<LawsCustomCompareInfo> {
/**
* 自定义对比-分页列表查询
* @param lawsCustomCompareInfoVO
* @param pageNo
* @param pageSize
* @return
*/
IPage<LawsCustomCompareInfoVO> queryByPage(LawsCustomCompareInfoVO lawsCustomCompareInfoVO, Integer pageNo, Integer pageSize);
/**
* 自定义对比-标准检索
* @param standardVO
* @param pageNo
* @param pageSize
* @return
*/
IPage<StandardVO> queryStandard(StandardVO standardVO, Integer pageNo, Integer pageSize);
/**
* 自定义对比-通过id查询
* @param id
* @return
*/
LawsCustomCompareInfoVO queryById(String id);
/**
* 自定义对比-标准检索保存
* @param standardSaveVO
*/
void saveStandard(StandardSaveVO standardSaveVO);
/**
* 自定义对比-表格详情
* @param id
* @return
*/
TableDetailVO queryTableDetail(String id);
/**
* 自定义对比-根据id删除
* @param id
*/
void delById(String id);
/**
* 自定义对比-清单维护列表查询
* @param id
*/
Map<String, Object> queryInventory(String id);
/**
* 自定义对比-标准列表分页查询
* @param id
* @return
*/
IPage<StandardVO> queryStandardByInfoId(String id,Integer pageNo, Integer pageSize);
/**
* 自定义对比-删除标准列表
* @param infoId
* @param standardId
*/
void delStandard(String infoId, String standardId);
/**
* 自定义对比-导出
* @param request
* @param response
*/
void exportExcel(String id, HttpServletRequest request, HttpServletResponse response);
}
@@ -0,0 +1,15 @@
package com.jero.modules.laws.customcompare.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareInfoStandard;
/**
* 自定义对比_标准 关联表(LawsCustomCompareInfoStandard)表服务接口
*
* @author yjz
* @since 2023-10-24 17:57:09
*/
public interface ILawsCustomCompareInfoStandardService extends IService<LawsCustomCompareInfoStandard> {
}
@@ -0,0 +1,15 @@
package com.jero.modules.laws.customcompare.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareInventory;
/**
* 自定义对比清单维护表(LawsCustomCompareInventory)表服务接口
*
* @author yjz
* @since 2023-10-24 17:57:49
*/
public interface ILawsCustomCompareInventoryService extends IService<LawsCustomCompareInventory> {
}
@@ -0,0 +1,21 @@
package com.jero.modules.laws.customcompare.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareCell;
import com.jero.modules.laws.customcompare.mapper.LawsCustomCompareCellMapper;
import com.jero.modules.laws.customcompare.service.ILawsCustomCompareCellService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 自定义对比单元格内容表(LawsCustomCompareCell)表服务实现类
*
* @author yjz
* @since 2023-10-24 17:59:28
*/
@Service
@Transactional
public class LawsCustomCompareCellServiceImpl extends ServiceImpl<LawsCustomCompareCellMapper, LawsCustomCompareCell> implements ILawsCustomCompareCellService {
}
@@ -0,0 +1,538 @@
package com.jero.modules.laws.customcompare.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.BeanCopyUtils;
import com.jero.common.util.FileUtils;
import com.jero.common.util.SnowflakeUtils;
import com.jero.common.util.ZipUtil;
import com.jero.modules.laws.customcompare.common.LawsCustomCompareCommon;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareCell;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareInfo;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareInfoStandard;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareInventory;
import com.jero.modules.laws.customcompare.mapper.LawsCustomCompareInfoMapper;
import com.jero.modules.laws.customcompare.service.ILawsCustomCompareCellService;
import com.jero.modules.laws.customcompare.service.ILawsCustomCompareInfoService;
import com.jero.modules.laws.customcompare.service.ILawsCustomCompareInfoStandardService;
import com.jero.modules.laws.customcompare.service.ILawsCustomCompareInventoryService;
import com.jero.modules.laws.customcompare.vo.LawsCustomCompareInfoVO;
import com.jero.modules.laws.customcompare.vo.StandardSaveVO;
import com.jero.modules.laws.customcompare.vo.StandardVO;
import com.jero.modules.laws.customcompare.vo.TableDetailVO;
import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard;
import com.jero.modules.laws.standard.entity.LawsOverseasStandard;
import com.jero.modules.laws.standard.service.ILawsDomesticStandardService;
import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService;
import com.jero.modules.laws.standard.service.ILawsOverseasStandardService;
import com.jero.modules.system.entity.SysDict;
import com.jero.modules.system.entity.SysDictItem;
import com.jero.modules.system.service.ISysDictItemService;
import com.jero.modules.system.service.ISysDictService;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Workbook;
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.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
*
*
* @author yjz
* @since 2023-10-24 17:45:59
*/
@Service
@Transactional
public class LawsCustomCompareInfoServiceImpl extends ServiceImpl<LawsCustomCompareInfoMapper, LawsCustomCompareInfo> implements ILawsCustomCompareInfoService {
private final LawsCustomCompareInfoMapper lawsCustomCompareInfoMapper;
private final ILawsCustomCompareInfoStandardService lawsCustomCompareInfoStandardService;
private final ILawsCustomCompareInventoryService lawsCustomCompareInventoryService;
private final ILawsCustomCompareCellService lawsCustomCompareCellService;
private final ILawsDomesticStandardService lawsDomesticStandardService;
private final ILawsOverseasStandardService lawsOverseasStandardService;
private final ILawsEnterpriseStandardService lawsEnterpriseStandardService;
private final ISysDictService sysDictService;
private final ISysDictItemService sysDictItemService;
public LawsCustomCompareInfoServiceImpl(LawsCustomCompareInfoMapper lawsCustomCompareInfoMapper,
ILawsCustomCompareInfoStandardService lawsCustomCompareInfoStandardService,
ILawsCustomCompareInventoryService lawsCustomCompareInventoryService,
ILawsCustomCompareCellService lawsCustomCompareCellService,
ILawsDomesticStandardService lawsDomesticStandardService,
ILawsOverseasStandardService lawsOverseasStandardService,
ILawsEnterpriseStandardService lawsEnterpriseStandardService,
ISysDictService sysDictService,
ISysDictItemService sysDictItemService) {
this.lawsCustomCompareInfoMapper = lawsCustomCompareInfoMapper;
this.lawsCustomCompareInfoStandardService = lawsCustomCompareInfoStandardService;
this.lawsCustomCompareInventoryService = lawsCustomCompareInventoryService;
this.lawsCustomCompareCellService = lawsCustomCompareCellService;
this.lawsDomesticStandardService = lawsDomesticStandardService;
this.lawsOverseasStandardService = lawsOverseasStandardService;
this.lawsEnterpriseStandardService = lawsEnterpriseStandardService;
this.sysDictService = sysDictService;
this.sysDictItemService = sysDictItemService;
}
@Value("${jero.path.exportExcelTempPath}")
private String exportExcelTempPath;
@Override
public IPage<LawsCustomCompareInfoVO> queryByPage(LawsCustomCompareInfoVO lawsCustomCompareInfoVO, Integer pageNo, Integer pageSize) {
QueryWrapper<LawsCustomCompareInfoVO> queryWrapper = new QueryWrapper<>();
queryWrapper.like(StringUtils.isNotBlank(lawsCustomCompareInfoVO.getListName()), "list_name", lawsCustomCompareInfoVO.getListName());
queryWrapper.like(StringUtils.isNotBlank(lawsCustomCompareInfoVO.getReferenceStandard()), "referenceStandard", lawsCustomCompareInfoVO.getReferenceStandard());
if (StringUtils.isNotBlank(lawsCustomCompareInfoVO.getListName())){
List<String> list = Arrays.asList(lawsCustomCompareInfoVO.getListName().split(","));
queryWrapper.and(qw -> list.forEach(v -> qw.or(iqw -> iqw.eq("referenceCountry", v))));
}
queryWrapper.like(StringUtils.isNotBlank(lawsCustomCompareInfoVO.getAuthor()), "username", lawsCustomCompareInfoVO.getAuthor());
queryWrapper.like(StringUtils.isNotBlank(lawsCustomCompareInfoVO.getIsShow()), "is_show", lawsCustomCompareInfoVO.getIsShow());
// 数据权限,默认只能查看公开的数据和操作人是当前登录人数据,管理员查看所有
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
List<String> roleIds = Arrays.asList(loginUser.getRoleIds().split(","));
if (!roleIds.contains("admin")){
queryWrapper.eq("i.create_by", loginUser.getId());
queryWrapper.eq("is_show", LawsCustomCompareCommon.IS_SHOW_1);
}
return lawsCustomCompareInfoMapper.queryByPage(new Page<>(pageNo, pageSize), queryWrapper);
}
@Override
public IPage<StandardVO> queryStandard(StandardVO standardVO, Integer pageNo, Integer pageSize) {
QueryWrapper<StandardVO> queryWrapper = new QueryWrapper<>();
// 标准编号/标准名称
if (StringUtils.isNotBlank(standardVO.getStandardNumberOrName())){
queryWrapper.and(qw -> qw
.like("standard_number", standardVO.getStandardNumberOrName())
.or()
.like("standard_name", standardVO.getStandardNumberOrName()));
}
if (StringUtils.isNotBlank(standardVO.getIds())){
List<String> list = Arrays.asList(standardVO.getIds().split(","));
queryWrapper.in("id", list);
}
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);
}
@Override
public LawsCustomCompareInfoVO queryById(String id) {
QueryWrapper<LawsCustomCompareInfoVO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id", id);
return lawsCustomCompareInfoMapper.queryById(queryWrapper);
}
@Override
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);
}
@Override
public TableDetailVO queryTableDetail(String id) {
TableDetailVO tableDetailVO = new TableDetailVO();
// 处理表头
setCountryMap(id, tableDetailVO);
// 处理特点/对比项
setRanksMap(id, tableDetailVO);
// 处理单元格
setList(id, tableDetailVO);
return tableDetailVO;
}
@Override
public void delById(String id) {
// 删除自定义对比表
removeById(id);
// 删除自定义对比_标准 关联表
lawsCustomCompareInfoStandardService.remove(
new LambdaQueryWrapper<LawsCustomCompareInfoStandard>()
.eq(LawsCustomCompareInfoStandard::getInfoId, id));
// 删除自定义对比清单维护表
lawsCustomCompareInventoryService.remove(
new LambdaQueryWrapper<LawsCustomCompareInventory>()
.eq(LawsCustomCompareInventory::getInfoId, id));
// 删除自定义对比单元格内容表
lawsCustomCompareCellService.remove(
new LambdaQueryWrapper<LawsCustomCompareCell>()
.eq(LawsCustomCompareCell::getInfoId, id));
}
@Override
public Map<String, Object> queryInventory(String id) {
List<LawsCustomCompareInventory> list = lawsCustomCompareInventoryService.list(
new LambdaQueryWrapper<LawsCustomCompareInventory>()
.eq(LawsCustomCompareInventory::getInfoId, id));
Map<String, Object> map = new HashMap<>();
// 特点
List<LawsCustomCompareInventory> feature = list.stream()
.filter(v -> LawsCustomCompareCommon.INVENTORY_TYPE_1.equals(v.getInventoryType()))
.collect(Collectors.toList());
// 对比项
List<LawsCustomCompareInventory> compareItem = list.stream()
.filter(v -> LawsCustomCompareCommon.INVENTORY_TYPE_2.equals(v.getInventoryType()))
.collect(Collectors.toList());
List<SysDictItem> sysDictItemList = getDicItem("inventory_type");
Optional<SysDictItem> featureDicItem = sysDictItemList.stream()
.filter(v -> LawsCustomCompareCommon.INVENTORY_TYPE_1.equals(v.getItemValue()))
.findFirst();
Optional<SysDictItem> compareItemDicItem = sysDictItemList.stream()
.filter(v -> LawsCustomCompareCommon.INVENTORY_TYPE_1.equals(v.getItemValue()))
.findFirst();
featureDicItem.ifPresent(v -> map.put(v.getItemText(), feature));
compareItemDicItem.ifPresent(v -> map.put(v.getItemText(), compareItem));
return map;
}
@Override
public IPage<StandardVO> queryStandardByInfoId(String id, Integer pageNo, Integer pageSize){
// 自定义对比_标准 关联表
List<LawsCustomCompareInfoStandard> list = lawsCustomCompareInfoStandardService.list(
new LambdaQueryWrapper<LawsCustomCompareInfoStandard>()
.eq(LawsCustomCompareInfoStandard::getInfoId, id)
.orderByAsc(LawsCustomCompareInfoStandard::getCreateTime));
if (!list.isEmpty()){
// 查询标准数据
List<String> standardIdList = list.stream().map(LawsCustomCompareInfoStandard::getStandardId).collect(Collectors.toList());
StandardVO standardVO = new StandardVO();
standardVO.setIds(String.join(",", standardIdList));
return queryStandard(standardVO, pageNo, pageSize);
}
return new Page<>();
}
@Override
public void delStandard(String infoId, String standardId) {
// 删除自定义对比_标准 关联表数据
lawsCustomCompareInfoStandardService.remove(
new LambdaQueryWrapper<LawsCustomCompareInfoStandard>()
.eq(LawsCustomCompareInfoStandard::getInfoId, infoId)
.eq(LawsCustomCompareInfoStandard::getStandardId, standardId));
}
@Override
public void exportExcel(String id, HttpServletRequest request, HttpServletResponse response) {
// 获取清单数据
TableDetailVO tableDetailVO = queryTableDetail(id);
// 获取国家/地区内容和标准内容
Map<String, List<StandardVO>> countryMap = tableDetailVO.getCountryMap();
// 内容整合
List<StandardVO> standardVOS = new ArrayList<>();
countryMap.forEach((k, v) -> standardVOS.addAll(v));
Map<String, List<LawsCustomCompareInventory>> ranksMap = tableDetailVO.getRanksMap();
// 获取特点内容
List<LawsCustomCompareInventory> featureList = ranksMap.get("特点");
// 获取对比项内容
List<LawsCustomCompareInventory> compareList = ranksMap.get("对比项");
// 获取单元格内容
List<LawsCustomCompareCell> list = tableDetailVO.getList();
try (Workbook workbook = new XSSFWorkbook()){
String fileName = "清单详情.xlsx";
// sheet页
XSSFSheet sheet = (XSSFSheet) workbook.createSheet("清单详情");
// 列宽
sheet.setDefaultColumnWidth(20);
// 创建表头内容
createTableHeader(sheet, countryMap, featureList);
// 创建第二行内容
createTableSecondRow(sheet, standardVOS, featureList);
// 创建单元格内容
createTableCellContent(sheet, standardVOS, featureList, compareList, list);
// excel临时保存到本地并在同级创建文件夹
generateExcel(workbook, fileName);
// 生成zip文件返回文件流
ZipUtil.toZip(exportExcelTempPath, response.getOutputStream(), response, true);
//删除指定文件夹
FileUtils.deleteFolders(exportExcelTempPath);
}catch (Exception e){
throw new JeroBootException("导出失败!");
}
}
private void createTableCellContent(XSSFSheet sheet, List<StandardVO> standardVOS, List<LawsCustomCompareInventory> featureList, List<LawsCustomCompareInventory> compareList, List<LawsCustomCompareCell> list) {
for (int i = 2; i < compareList.size() + 2; i++) {
// 创建行
Row indexRow = sheet.createRow(i);
// 创建列
Cell indexCell = indexRow.createCell(0);
if (i == 2){
// 特点列
createFeatureColumn(standardVOS, featureList, indexRow, indexCell);
}else {
// 普通列
createOrdinaryColumn(standardVOS, featureList, compareList, list, i, indexRow, indexCell);
}
}
}
private static void createOrdinaryColumn(List<StandardVO> standardVOS, List<LawsCustomCompareInventory> featureList, List<LawsCustomCompareInventory> compareList, List<LawsCustomCompareCell> list, int i, Row indexRow, Cell indexCell) {
indexCell.setCellValue(compareList.get(i).getCellTitle());
int index = 0;
for (StandardVO standardVO : standardVOS) {
for (LawsCustomCompareInventory lawsCustomCompareInventory : featureList) {
index += 1;
// 创建列
Cell cell1 = indexRow.createCell(index);
Optional<LawsCustomCompareCell> cellOptional = list.stream()
.filter(v -> Objects.equals(lawsCustomCompareInventory.getId(), v.getFeatureId())
&& Objects.equals(standardVO.getId(), v.getCompareItemId()))
.findFirst();
cellOptional.ifPresent(v -> cell1.setCellValue(v.getContent()));
}
}
}
private static void createFeatureColumn(List<StandardVO> standardVOS, List<LawsCustomCompareInventory> featureList, Row indexRow, Cell indexCell) {
indexCell.setCellValue("特点/对比项");
// 计算列数量
int cellSize = featureList.size() * standardVOS.size();
for (int j = 1; j <= cellSize; j++) {
// 创建列
Cell cell = indexRow.createCell(j);
int index = j % featureList.size();
if (index == 0){
cell.setCellValue(featureList.get(featureList.size() - 1).getCellTitle());
}else {
cell.setCellValue(featureList.get(index - 1).getCellTitle());
}
}
}
private void createTableSecondRow(XSSFSheet sheet, List<StandardVO> standardVOS, List<LawsCustomCompareInventory> featureList) {
// 创建第二行
Row row = sheet.createRow(1);
// 创建列
Cell cell = row.createCell(0);
cell.setCellValue("标准号");
// 计算第二行文字内容和需要合并的单元格
// 下标
AtomicInteger index2 = new AtomicInteger();
for (StandardVO standardVO : standardVOS) {
index2.addAndGet(1);
// 创建列
Cell indexCell = row.createCell(index2.get());
indexCell.setCellValue(standardVO.getStandardNumber());
// 特点数量
int featureSize = featureList.size();
// 合并单元格(参数说明:起始行,结束行,起始列,结束列)
CellRangeAddress region = new CellRangeAddress(1, 1, index2.get(), index2.get() + featureSize - 1);
sheet.addMergedRegion(region);
}
}
private void createTableHeader(XSSFSheet sheet, Map<String, List<StandardVO>> countryMap, List<LawsCustomCompareInventory> featureList) {
// 创建第一行
Row headerRow = sheet.createRow(0);
// 创建列
Cell cell = headerRow.createCell(0);
cell.setCellValue("国家/地区");
if (!countryMap.isEmpty()){
// 下标
AtomicInteger index = new AtomicInteger();
countryMap.forEach((k, v) -> {
index.addAndGet(1);
// 标准数量
int standardSize = v.size();
// 特点数量
int featureSize = featureList.size();
// 单元格合并数量
int merge = standardSize * featureSize;
// 首先先填充内容,再合并单元格
Cell indexCell = headerRow.createCell(index.get());
indexCell.setCellValue(k);
// 合并单元格(参数说明:起始行,结束行,起始列,结束列)
CellRangeAddress region = new CellRangeAddress(0, 0, index.get(), index.get() + merge - 1);
sheet.addMergedRegion(region);
});
}
}
private void generateExcel(Workbook workbook, String fileName) throws IOException {
File saveFile = new File(exportExcelTempPath);
// 导出路径 没有则创建
if (!saveFile.exists()) {
saveFile.mkdirs();
}
// 生成excel文件路径
String excelPath = exportExcelTempPath + File.separator + fileName;
// 写出excel文件
try (FileOutputStream fos = new FileOutputStream(excelPath)){
workbook.write(fos);
}catch (Exception e){
throw new JeroBootException(e.getMessage());
}
}
private void setList(String id, TableDetailVO tableDetailVO) {
List<LawsCustomCompareCell> cellList = lawsCustomCompareCellService.list(
new LambdaQueryWrapper<LawsCustomCompareCell>()
.eq(LawsCustomCompareCell::getInfoId, id));
tableDetailVO.setList(cellList);
}
private void setRanksMap(String id, TableDetailVO tableDetailVO) {
List<LawsCustomCompareInventory> inventoryList = lawsCustomCompareInventoryService.list(
new LambdaQueryWrapper<LawsCustomCompareInventory>()
.eq(LawsCustomCompareInventory::getInfoId, id)
.orderByAsc(LawsCustomCompareInventory::getCreateTime));
if (!inventoryList.isEmpty()){
List<SysDictItem> sysDictItemList = getDicItem("inventory_type");
Map<String, List<LawsCustomCompareInventory>> ranksMap = inventoryList.stream()
.map(v -> {
// 字典翻译
Optional<String> sysDictIte = sysDictItemList.stream()
.filter(o -> v.getInventoryType()
.equals(o.getItemValue())).map(SysDictItem::getItemText).findFirst();
sysDictIte.ifPresent(v::setInventoryType);
return v;
})
.collect(Collectors.groupingBy(LawsCustomCompareInventory::getInventoryType));
if (!ranksMap.containsKey("特点")){
ranksMap.put("特点", new ArrayList<>());
}
if (!ranksMap.containsKey("对比项")){
ranksMap.put("对比项", new ArrayList<>());
}
tableDetailVO.setRanksMap(ranksMap);
}else{
Map<String, List<LawsCustomCompareInventory>> map = new HashMap<>();
map.put("特点", new ArrayList<>());
map.put("对比项", new ArrayList<>());
tableDetailVO.setRanksMap(map);
}
}
private void setCountryMap(String id, TableDetailVO tableDetailVO) {
List<LawsCustomCompareInfoStandard> infoStandardList = lawsCustomCompareInfoStandardService.list(
new LambdaQueryWrapper<LawsCustomCompareInfoStandard>()
.eq(LawsCustomCompareInfoStandard::getInfoId, id)
.orderByAsc(LawsCustomCompareInfoStandard::getCreateTime));
if (!infoStandardList.isEmpty()){
// 国内
List<String> domesticIds = infoStandardList.stream()
.filter(v -> LawsCustomCompareCommon.STANDARD_TYPE1.equals(v.getStandardType()))
.map(LawsCustomCompareInfoStandard::getStandardId)
.collect(Collectors.toList());
List<LawsDomesticStandard> lawsDomesticStandards = lawsDomesticStandardService.listByIds(domesticIds);
// 海外
List<String> overseasIds= infoStandardList.stream()
.filter(v -> LawsCustomCompareCommon.STANDARD_TYPE2.equals(v.getStandardType()))
.map(LawsCustomCompareInfoStandard::getStandardId)
.collect(Collectors.toList());
List<LawsOverseasStandard> lawsOverseasStandards = lawsOverseasStandardService.listByIds(overseasIds);
// 企业
List<String> enterpriseIds = infoStandardList.stream()
.filter(v -> LawsCustomCompareCommon.STANDARD_TYPE3.equals(v.getStandardType()))
.map(LawsCustomCompareInfoStandard::getStandardId)
.collect(Collectors.toList());
List<LawsEnterpriseStandard> lawsEnterpriseStandards = lawsEnterpriseStandardService.listByIds(enterpriseIds);
// 处理数据
List<StandardVO> standardVOList = new ArrayList<>();
List<StandardVO> domesticStandardVOList = BeanCopyUtils.copyBeanList(lawsDomesticStandards, StandardVO.class);
List<StandardVO> overseasStandardVOList = BeanCopyUtils.copyBeanList(lawsOverseasStandards, StandardVO.class);
List<StandardVO> enterpriseStandardVOList = BeanCopyUtils.copyBeanList(lawsEnterpriseStandards, StandardVO.class);
standardVOList.addAll(domesticStandardVOList);
standardVOList.addAll(overseasStandardVOList);
standardVOList.addAll(enterpriseStandardVOList);
// 获取字典
List<SysDictItem> sysDictItemList = getDicItem("country_or_region");
// 按国家/地区分组
Map<String, List<StandardVO>> countryMap = standardVOList.stream()
.map(v -> {
v.setInfoId(id);
// 字典翻译
String countryOrRegion = v.getCountryOrRegion();
if (StringUtils.isNotBlank(countryOrRegion)){
List<String> list = Arrays.asList(countryOrRegion.split(","));
List<String> sysDictItems = sysDictItemList.stream()
.filter(o -> list
.contains(o.getItemValue())).map(SysDictItem::getItemText).collect(Collectors.toList());
if (!sysDictItems.isEmpty()){
v.setCountryOrRegion(String.join(",", sysDictItems));
}
}
return v;
})
.collect(Collectors.groupingBy(StandardVO::getCountryOrRegion));
tableDetailVO.setCountryMap(countryMap);
}
}
private List<SysDictItem> getDicItem(String dicCode) {
SysDict sysDict = sysDictService.getOne(
new LambdaQueryWrapper<SysDict>()
.eq(SysDict::getDictCode, dicCode), false);
if (Objects.isNull(sysDict)){
return new ArrayList<>();
}
List<SysDictItem> sysDictItemList = sysDictItemService.list(
new LambdaQueryWrapper<SysDictItem>()
.eq(SysDictItem::getDictId, sysDict.getId()));
return Optional.of(sysDictItemList).orElse(new ArrayList<>());
}
}
@@ -0,0 +1,21 @@
package com.jero.modules.laws.customcompare.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareInfoStandard;
import com.jero.modules.laws.customcompare.mapper.LawsCustomCompareInfoStandardMapper;
import com.jero.modules.laws.customcompare.service.ILawsCustomCompareInfoStandardService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 自定义对比_标准 关联表(LawsCustomCompareInfoStandard)表服务实现类
*
* @author yjz
* @since 2023-10-24 17:57:09
*/
@Service
@Transactional
public class LawsCustomCompareInfoStandardServiceImpl extends ServiceImpl<LawsCustomCompareInfoStandardMapper, LawsCustomCompareInfoStandard> implements ILawsCustomCompareInfoStandardService {
}
@@ -0,0 +1,21 @@
package com.jero.modules.laws.customcompare.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareInventory;
import com.jero.modules.laws.customcompare.mapper.LawsCustomCompareInventoryMapper;
import com.jero.modules.laws.customcompare.service.ILawsCustomCompareInventoryService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 自定义对比清单维护表
*
* @author yjz
* @since 2023-10-24 17:57:49
*/
@Service
@Transactional
public class LawsCustomCompareInventoryServiceImpl extends ServiceImpl<LawsCustomCompareInventoryMapper, LawsCustomCompareInventory> implements ILawsCustomCompareInventoryService {
}
@@ -0,0 +1,42 @@
package com.jero.modules.laws.customcompare.vo;
import com.jero.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @Author: yjz
* @Date: 2023/10/25/9:09
* @Description:
*/
@Data
public class LawsCustomCompareInfoVO {
/**id*/
@ApiModelProperty(value = "id")
private String id;
/**清单名称*/
@ApiModelProperty(value = "清单名称")
private String listName;
/**涉及标准*/
@ApiModelProperty(value = "涉及标准")
private String referenceStandard;
/**涉及国家*/
@ApiModelProperty(value = "涉及国家")
@Dict(dicCode = "country_or_region")
private String referenceCountry;
/**比对时间*/
@ApiModelProperty(value = "比对时间")
private Date createTime;
/**是否公开(1:是,0:否)*/
@ApiModelProperty(value = "是否公开(1:是,0:否)")
@Dict(dicCode = "yn")
private String isShow;
/**操作人*/
@ApiModelProperty(value = "操作人")
private String createBy;
/**操作人翻译*/
@ApiModelProperty(value = "操作人翻译")
private String author;
}
@@ -0,0 +1,21 @@
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;
/**
* @Author: 31318
* @Date: 2023/10/25/15:25
* @Description:
*/
@Data
public class StandardSaveVO {
/**自定义对比表*/
@ApiModelProperty(value = "自定义对比表")
private LawsCustomCompareInfo lawsCustomCompareInfo;
/**自定义对比_标准 关联表*/
@ApiModelProperty(value = "自定义对比_标准 关联表")
private LawsCustomCompareInfoStandard lawsCustomCompareInfoStandard;
}
@@ -0,0 +1,56 @@
package com.jero.modules.laws.customcompare.vo;
import com.jero.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @Author: yjz
* @Date: 2023/10/25/14:04
* @Description:
*/
@Data
public class StandardVO {
/**id*/
@ApiModelProperty(value = "id")
private String id;
/**标准号*/
@ApiModelProperty(value = "标准号")
private String standardNumber;
/**标准名称*/
@ApiModelProperty(value = "标准名称")
private String standardName;
/**标准状态*/
@ApiModelProperty(value = "标准状态")
@Dict(dicCode = "standard_state")
private String standardState;
/**国家/地区*/
@ApiModelProperty(value = "国家/地区")
@Dict(dicCode = "country_or_region")
private String countryOrRegion;
/**发布日期*/
@ApiModelProperty(value = "发布日期")
private Date releaseDate;
/**标准类型(1:国内,2:海外,3:企业)*/
@ApiModelProperty(value = "标准类型(1:国内,2:海外,3:企业)")
@Dict(dicCode = "standard_source")
private String standardType;
/**自定义对比id 表格详情用*/
@ApiModelProperty(value = "自定义对比id 表格详情用")
private String infoId;
/**标准编号/标准名称 搜索用*/
@ApiModelProperty(value = "标准编号/标准名称 搜索用")
private String standardNumberOrName;
/**发布日期开始 搜索用*/
@ApiModelProperty(value = "发布日期开始 搜索用")
private String releaseDateBegin;
/**发布日期结束 搜索用*/
@ApiModelProperty(value = "发布日期结束 搜索用")
private String releaseDatesEnd;
/**ids 搜索用*/
@ApiModelProperty(value = "ids 搜索用")
private String ids;
}
@@ -0,0 +1,27 @@
package com.jero.modules.laws.customcompare.vo;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareCell;
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareInventory;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @Author: 31318
* @Date: 2023/10/25/15:56
* @Description:
*/
@Data
public class TableDetailVO {
/**表头*/
@ApiModelProperty(value = "表头")
private Map<String, List<StandardVO>> countryMap;
/**清单维护*/
@ApiModelProperty(value = "清单维护")
private Map<String, List<LawsCustomCompareInventory>> ranksMap;
/**单元格*/
@ApiModelProperty(value = "单元格")
private List<LawsCustomCompareCell> list;
}
@@ -695,14 +695,6 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
// 写出excel文件
try (FileOutputStream fos = new FileOutputStream(excelPath)){
workbook.write(fos);
// 同级创建文件夹
/**
* File savePaperFile = new File(exportExcelTempPath+ File.separator + "外部资源");
* if (!savePaperFile.exists()) {
* savePaperFile.mkdirs();
* }
*/
}catch (Exception e){
throw new JeroBootException(e.getMessage());
}