Commit 218b0293 authored by 廖旭伟's avatar 廖旭伟

Merge remote-tracking branch 'origin/first' into first

parents c026832e 15d8f678
...@@ -82,3 +82,24 @@ ALTER TABLE mortals_xhx_certificate_child ...@@ -82,3 +82,24 @@ ALTER TABLE mortals_xhx_certificate_child
ADD COLUMN `catalogName` varchar(64) DEFAULT NULL COMMENT '目录名称', ADD COLUMN `catalogName` varchar(64) DEFAULT NULL COMMENT '目录名称',
ADD COLUMN `documentName` varchar(64) DEFAULT NULL COMMENT '子证名称' ADD COLUMN `documentName` varchar(64) DEFAULT NULL COMMENT '子证名称'
AFTER catalogId ; AFTER catalogId ;
-- ----------------------------
-- 2024-08-8
-- ----------------------------
ALTER TABLE `mortals_xhx_apply_log`
ADD COLUMN `watermarkUrl` varchar(255) DEFAULT '' COMMENT '水印图片地址'
AFTER annexUrl ;
ALTER TABLE `mortals_xhx_child_license`
ADD COLUMN `originalWaterMarkPath` varchar(255) DEFAULT '' COMMENT '水印图片地址',
ADD COLUMN `copyWaterMarkPath` varchar(255) DEFAULT '' COMMENT '水印图片地址'
AFTER copyFilePath ;
ALTER TABLE `mortals_xhx_certificate_industry`
ADD COLUMN `ancestors` varchar(255) DEFAULT '' COMMENT '祖级列表,逗号分割'
AFTER siteId ;
...@@ -55,9 +55,8 @@ ...@@ -55,9 +55,8 @@
<id>product</id> <id>product</id>
<properties> <properties>
<profiles.active>product</profiles.active> <profiles.active>product</profiles.active>
<profiles.server.debug>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=15506</profiles.server.debug>
<profiles.filepath>/mortals/app/data/one</profiles.filepath> <profiles.filepath>/mortals/app/data/one</profiles.filepath>
<profiles.nacos.server-addr>192.168.0.252:8848</profiles.nacos.server-addr> <profiles.nacos.server-addr>192.168.0.250:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group> <profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace> <profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
</properties> </properties>
......
...@@ -56,7 +56,7 @@ public class UploadController extends BaseController { ...@@ -56,7 +56,7 @@ public class UploadController extends BaseController {
@RequestMapping(value = "commonupload") @RequestMapping(value = "commonupload")
@UnAuth @UnAuth
public String doFileUpload(MultipartFile file, @RequestParam(value = "prePath",defaultValue = "file/fileupload") String prePath) { public String doFileUpload(MultipartFile file, @RequestParam(value = "prePath",defaultValue = "/file/fileupload") String prePath) {
Map<String, Object> model = new HashMap<>(); Map<String, Object> model = new HashMap<>();
String jsonStr = ""; String jsonStr = "";
try { try {
......
package com.mortals.xhx.busiz.web;
import cn.hutool.core.io.FileUtil;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.utils.WatermarkImgUtils;
import com.mortals.xhx.module.certificate.model.CertificateIndustryTreeSelect;
import com.mortals.xhx.module.certificate.service.CertificateIndustryService;
import com.mortals.xhx.module.child.model.ChildLicenseEntity;
import com.mortals.xhx.module.child.model.ChildLicenseQuery;
import com.mortals.xhx.module.child.service.ChildLicenseService;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.record.model.ApplyLogEntity;
import com.mortals.xhx.module.record.model.ApplyLogQuery;
import com.mortals.xhx.module.record.service.ApplyLogService;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@RestController
@Slf4j
@RequestMapping("test")
public class TestSendMsgController {
@Autowired
private ApplyLogService applyLogService;
@Autowired
private UploadService uploadService;
@Autowired
private ChildLicenseService childLicenseService;
@Autowired
private CertificateIndustryService certificateIndustryService;
@GetMapping("refreshWaterMark")
public Rest<Void> updateDevice() {
String WarterMark = GlobalSysInfo.getParamValue(Constant.Param_waterMark, "");
ApplyLogQuery applyLogQuery = new ApplyLogQuery();
applyLogQuery.setAnnexUrlNotList(Arrays.asList(""));
List<ApplyLogEntity> applyLogEntities = applyLogService.find(applyLogQuery);
for (ApplyLogEntity applyLogEntity : applyLogEntities) {
if (!ObjectUtils.isEmpty(WarterMark)) {
//生成水印图片
String annexUrl = applyLogEntity.getAnnexUrl();
String annexUrlAllPath = uploadService.getFilePath(annexUrl);
String targetPath = "/file/fileupload/" + new Date().getTime() + "_watermark.jpg";
String targetAllPath = uploadService.getFilePath(targetPath);
if (FileUtil.exist(annexUrlAllPath)) {
WatermarkImgUtils.addWatermark(annexUrlAllPath,
targetAllPath,
WarterMark, "jpg");
}
applyLogEntity.setWatermarkUrl(targetPath);
}
}
if (!ObjectUtils.isEmpty(applyLogEntities)) {
applyLogService.update(applyLogEntities);
}
ChildLicenseQuery childLicenseQuery = new ChildLicenseQuery();
childLicenseQuery.setOriginalFilePathNotList(Arrays.asList(""));
List<ChildLicenseEntity> childLicenseEntities = childLicenseService.find(childLicenseQuery);
for (ChildLicenseEntity childLicenseEntity : childLicenseEntities) {
if (!ObjectUtils.isEmpty(WarterMark)) {
String originalFilePath = childLicenseEntity.getOriginalFilePath();
String originalAllPath = uploadService.getFilePath(originalFilePath);
String targetPath = "/file/fileupload/" + new Date().getTime() + "_watermark.jpg";
String targetAllPath = uploadService.getFilePath(targetPath);
if (FileUtil.exist(originalAllPath)) {
WatermarkImgUtils.addWatermark(originalAllPath,
targetAllPath,
WarterMark, "jpg");
}
childLicenseEntity.setOriginalWaterMarkPath(targetPath);
}
}
if (!ObjectUtils.isEmpty(childLicenseEntities)) {
childLicenseService.update(childLicenseEntities);
}
childLicenseQuery = new ChildLicenseQuery();
childLicenseQuery.setCopyFilePathNotList(Arrays.asList(""));
childLicenseEntities = childLicenseService.find(childLicenseQuery);
for (ChildLicenseEntity childLicenseEntity : childLicenseEntities) {
if (!ObjectUtils.isEmpty(WarterMark)) {
String originalFilePath = childLicenseEntity.getOriginalFilePath();
String originalAllPath = uploadService.getFilePath(originalFilePath);
String targetPath = "/file/fileupload/" + new Date().getTime() + "_watermark.jpg";
String targetAllPath = uploadService.getFilePath(targetPath);
if (FileUtil.exist(originalAllPath)) {
WatermarkImgUtils.addWatermark(originalAllPath,
targetAllPath,
WarterMark, "jpg");
}
childLicenseEntity.setCopyWaterMarkPath(targetPath);
}
}
if (!ObjectUtils.isEmpty(childLicenseEntities)) {
childLicenseService.update(childLicenseEntities);
}
return Rest.ok();
}
@GetMapping("subtree")
public Rest<Object> subtree(Long parentId) {
List<CertificateIndustryTreeSelect> allListByParentList = certificateIndustryService.getAllListByParentId(parentId, null);
return Rest.ok(allListByParentList);
}
public static void main(String[] args) {
}
}
...@@ -29,6 +29,7 @@ public final class Constant { ...@@ -29,6 +29,7 @@ public final class Constant {
public final static String Param_jianmMs = "jianmMs"; public final static String Param_jianmMs = "jianmMs";
public final static String Param_sealWay = "sealWay"; public final static String Param_sealWay = "sealWay";
public final static String Param_typeOptions = "typeOptions"; public final static String Param_typeOptions = "typeOptions";
public final static String Param_waterMark = "waterMark";
/** 登录用户类型为客户 */ /** 登录用户类型为客户 */
public final static int CUSTOMER_USER = 99; public final static int CUSTOMER_USER = 99;
......
package com.mortals.xhx.common.utils;
import com.mortals.xhx.module.record.web.ApplyLogController;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
public class WatermarkImgUtils {
/**
* @description
* @param sourceImgPath 源图片路径
* @param tarImgPath 保存的图片路径
* @param waterMarkContent 水印内容
* @param fileExt 图片格式
* @return void
*/
public static void addWatermark(String sourceImgPath, String tarImgPath, String waterMarkContent,String fileExt){
Font font = new Font("宋体", Font.BOLD, 100);//水印字体,大小
Color markContentColor = Color.red;//水印颜色
Integer degree = 45;//设置水印文字的旋转角度
float alpha = 0.5f;//设置水印透明度
OutputStream outImgStream = null;
try {
File srcImgFile = new File(sourceImgPath);//得到文件
Image srcImg = ImageIO.read(srcImgFile);//文件转化为图片
int srcImgWidth = srcImg.getWidth(null);//获取图片的宽
int srcImgHeight = srcImg.getHeight(null);//获取图片的高
// 加水印
BufferedImage bufImg = new BufferedImage(srcImgWidth, srcImgHeight, BufferedImage.TYPE_INT_RGB);
Graphics2D g = bufImg.createGraphics();//得到画笔
g.drawImage(srcImg, 0, 0, srcImgWidth, srcImgHeight, null);
g.setColor(markContentColor); //设置水印颜色
g.setFont(font); //设置字体
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));//设置水印文字透明度
if (null != degree) {
g.rotate(Math.toRadians(degree));//设置水印旋转
}
JLabel label = new JLabel(waterMarkContent);
FontMetrics metrics = label.getFontMetrics(font);
int width = metrics.stringWidth(label.getText());//文字水印的宽
int rowsNumber = srcImgHeight/width;// 图片的高 除以 文字水印的宽 ——> 打印的行数(以文字水印的宽为间隔)
int columnsNumber = srcImgWidth/width;//图片的宽 除以 文字水印的宽 ——> 每行打印的列数(以文字水印的宽为间隔)
//防止图片太小而文字水印太长,所以至少打印一次
if(rowsNumber < 1){
rowsNumber = 1;
}
if(columnsNumber < 1){
columnsNumber = 1;
}
g.drawString(waterMarkContent, width + width/2, width- width/2);
/* for(int j=0;j<rowsNumber;j++){
boolean bool=false;
for(int i=0;i<columnsNumber;i++){
g.drawString(waterMarkContent, i*width + j*width, -i*width + j*width);//画出水印,并设置水印位置
bool=true;
break;
}
if (bool) break;
}*/
g.dispose();// 释放资源
// 输出图片
outImgStream = new FileOutputStream(tarImgPath);
ImageIO.write(bufImg, fileExt, outImgStream);
} catch (Exception e) {
e.printStackTrace();
e.getMessage();
} finally{
try {
if(outImgStream != null){
outImgStream.flush();
outImgStream.close();
}
} catch (Exception e) {
e.printStackTrace();
e.getMessage();
}
}
}
public static void main(String[] args) {
WatermarkImgUtils.addWatermark("E:\\pic\\back.jpg", "E:\\pic\\back_water1.jpg", "你好,世界!", "jpg");
}
}
...@@ -8,9 +8,17 @@ import java.util.List; ...@@ -8,9 +8,17 @@ import java.util.List;
* 行业目录 DAO接口 * 行业目录 DAO接口
* *
* @author zxfei * @author zxfei
* @date 2022-10-14 * @date 2024-08-08
*/ */
public interface CertificateIndustryDao extends ICRUDDao<CertificateIndustryEntity,Long>{ public interface CertificateIndustryDao extends ICRUDDao<CertificateIndustryEntity,Long>{
/**
* 查询子节点
*
* @param
* @return
*/
List<CertificateIndustryEntity> selectChildrenCertificateIndustryById(String certificateIndustryId);
} }
...@@ -11,11 +11,15 @@ import java.util.List; ...@@ -11,11 +11,15 @@ import java.util.List;
* 行业目录DaoImpl DAO接口 * 行业目录DaoImpl DAO接口
* *
* @author zxfei * @author zxfei
* @date 2022-10-14 * @date 2024-08-08
*/ */
@Repository("certificateIndustryDao") @Repository("certificateIndustryDao")
public class CertificateIndustryDaoImpl extends BaseCRUDDaoMybatis<CertificateIndustryEntity,Long> implements CertificateIndustryDao { public class CertificateIndustryDaoImpl extends BaseCRUDDaoMybatis<CertificateIndustryEntity,Long> implements CertificateIndustryDao {
@Override
public List<CertificateIndustryEntity> selectChildrenCertificateIndustryById(String certificateIndustryId) {
return getSqlSession().selectList(getSqlId("selectChildrenCertificateIndustryById"), certificateIndustryId);
}
} }
...@@ -13,7 +13,7 @@ import lombok.Data; ...@@ -13,7 +13,7 @@ import lombok.Data;
* 行业目录实体对象 * 行业目录实体对象
* *
* @author zxfei * @author zxfei
* @date 2024-07-27 * @date 2024-08-08
*/ */
@Data @Data
public class CertificateIndustryEntity extends CertificateIndustryVo { public class CertificateIndustryEntity extends CertificateIndustryVo {
...@@ -31,6 +31,10 @@ public class CertificateIndustryEntity extends CertificateIndustryVo { ...@@ -31,6 +31,10 @@ public class CertificateIndustryEntity extends CertificateIndustryVo {
* 行业名称 * 行业名称
*/ */
private String industryName; private String industryName;
/**
* 祖级列表,逗号分割
*/
private String ancestors;
@Override @Override
public int hashCode() { public int hashCode() {
return this.getId().hashCode(); return this.getId().hashCode();
...@@ -51,5 +55,6 @@ public class CertificateIndustryEntity extends CertificateIndustryVo { ...@@ -51,5 +55,6 @@ public class CertificateIndustryEntity extends CertificateIndustryVo {
this.siteId = null; this.siteId = null;
this.parentId = null; this.parentId = null;
this.industryName = ""; this.industryName = "";
this.ancestors = "";
} }
} }
\ No newline at end of file
...@@ -6,7 +6,7 @@ import com.mortals.xhx.module.certificate.model.CertificateIndustryEntity; ...@@ -6,7 +6,7 @@ import com.mortals.xhx.module.certificate.model.CertificateIndustryEntity;
* 行业目录查询对象 * 行业目录查询对象
* *
* @author zxfei * @author zxfei
* @date 2024-07-27 * @date 2024-08-08
*/ */
public class CertificateIndustryQuery extends CertificateIndustryEntity { public class CertificateIndustryQuery extends CertificateIndustryEntity {
/** 开始 序号,主键,自增长 */ /** 开始 序号,主键,自增长 */
...@@ -101,6 +101,11 @@ public class CertificateIndustryQuery extends CertificateIndustryEntity { ...@@ -101,6 +101,11 @@ public class CertificateIndustryQuery extends CertificateIndustryEntity {
/** 结束 更新时间 */ /** 结束 更新时间 */
private String updateTimeEnd; private String updateTimeEnd;
/** 祖级列表,逗号分割 */
private List<String> ancestorsList;
/** 祖级列表,逗号分割排除列表 */
private List <String> ancestorsNotList;
/** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */ /** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */
private List<CertificateIndustryQuery> orConditionList; private List<CertificateIndustryQuery> orConditionList;
...@@ -610,6 +615,38 @@ public class CertificateIndustryQuery extends CertificateIndustryEntity { ...@@ -610,6 +615,38 @@ public class CertificateIndustryQuery extends CertificateIndustryEntity {
this.updateTimeEnd = updateTimeEnd; this.updateTimeEnd = updateTimeEnd;
} }
/**
* 获取 祖级列表,逗号分割
* @return ancestorsList
*/
public List<String> getAncestorsList(){
return this.ancestorsList;
}
/**
* 设置 祖级列表,逗号分割
* @param ancestorsList
*/
public void setAncestorsList(List<String> ancestorsList){
this.ancestorsList = ancestorsList;
}
/**
* 获取 祖级列表,逗号分割
* @return ancestorsNotList
*/
public List<String> getAncestorsNotList(){
return this.ancestorsNotList;
}
/**
* 设置 祖级列表,逗号分割
* @param ancestorsNotList
*/
public void setAncestorsNotList(List<String> ancestorsNotList){
this.ancestorsNotList = ancestorsNotList;
}
/** /**
* 设置 序号,主键,自增长 * 设置 序号,主键,自增长
* @param id * @param id
...@@ -901,6 +938,25 @@ public class CertificateIndustryQuery extends CertificateIndustryEntity { ...@@ -901,6 +938,25 @@ public class CertificateIndustryQuery extends CertificateIndustryEntity {
} }
/**
* 设置 祖级列表,逗号分割
* @param ancestors
*/
public CertificateIndustryQuery ancestors(String ancestors){
setAncestors(ancestors);
return this;
}
/**
* 设置 祖级列表,逗号分割
* @param ancestorsList
*/
public CertificateIndustryQuery ancestorsList(List<String> ancestorsList){
this.ancestorsList = ancestorsList;
return this;
}
/** /**
* 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) * 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* @return orConditionList * @return orConditionList
......
package com.mortals.xhx.module.certificate.model;
import java.lang.reflect.Type;
import java.util.List;
import java.util.ArrayList;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.JSONToken;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import org.springframework.util.ObjectUtils;
import java.io.Serializable;
import java.util.stream.Collectors;
/**
* 行业目录前端映射树结构实体类
*
* @author zxfei
* @date 2024-08-08
*/
@Data
public class CertificateIndustryTreeSelect implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 节点ID
*/
private Long id;
/**
* 父节点ID
*/
private Long parentId;
/**
* 节点名称
*/
private String label;
/**
* 子节点
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<CertificateIndustryTreeSelect> children;
public CertificateIndustryTreeSelect() {
}
public CertificateIndustryTreeSelect(CertificateIndustryEntity entity) {
this.id = entity.getId();
this.parentId = entity.getParentId();
this.label = entity.getIndustryName();
if(!ObjectUtils.isEmpty(entity.getChildren())){
this.children = entity.getChildren().stream().map(CertificateIndustryTreeSelect::new).collect(Collectors.toList());
}
}
// 反序列化器
public class Deserializer implements ObjectDeserializer {
@Override
public CertificateIndustryTreeSelect deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
CertificateIndustryTreeSelect node = new CertificateIndustryTreeSelect();
JSONObject jsonObject = parser.parseObject();
node.setId(jsonObject.getLong("id"));
node.setLabel(jsonObject.getString("label"));
JSONArray jsonArray = jsonObject.getJSONArray("children");
List<CertificateIndustryTreeSelect> children = new ArrayList<>();
if(!ObjectUtils.isEmpty(jsonArray)){
for (int i = 0; i < jsonArray.size(); i++) {
CertificateIndustryTreeSelect child = JSON.parseObject(jsonArray.getJSONObject(i).toJSONString(), CertificateIndustryTreeSelect.class);
children.add(child);
}
}
node.setChildren(children);
return node;
}
@Override
public int getFastMatchToken() {
return JSONToken.LBRACE;
}
}
public static void main(String[] args) {
String json="{\n" +
" \"children\": [\n" +
" {\n" +
" \"children\": [\n" +
" {\n" +
" \"id\": 10,\n" +
" \"label\": \"小餐馆\"\n" +
" },\n" +
" {\n" +
" \"id\": 11,\n" +
" \"label\": \"奶茶店\"\n" +
" },\n" +
" {\n" +
" \"id\": 14,\n" +
" \"label\": \"咖啡店\"\n" +
" }\n" +
" ],\n" +
" \"id\": 1,\n" +
" \"label\": \"餐饮类\"\n" +
" },\n" +
" {\n" +
" \"children\": [\n" +
" {\n" +
" \"id\": 16,\n" +
" \"label\": \"超市\"\n" +
" },\n" +
" {\n" +
" \"id\": 17,\n" +
" \"label\": \"便利店\"\n" +
" }\n" +
" ],\n" +
" \"id\": 15,\n" +
" \"label\": \"购物类\"\n" +
" },\n" +
" {\n" +
" \"children\": [\n" +
" {\n" +
" \"id\": 19,\n" +
" \"label\": \"茶楼\"\n" +
" },\n" +
" {\n" +
" \"id\": 20,\n" +
" \"label\": \"酒吧\"\n" +
" },\n" +
" {\n" +
" \"id\": 21,\n" +
" \"label\": \"游艺厅\"\n" +
" },\n" +
" {\n" +
" \"id\": 22,\n" +
" \"label\": \"电玩城\"\n" +
" },\n" +
" {\n" +
" \"id\": 23,\n" +
" \"label\": \"KTV\"\n" +
" },\n" +
" {\n" +
" \"id\": 24,\n" +
" \"label\": \"洗浴场所\"\n" +
" },\n" +
" {\n" +
" \"id\": 25,\n" +
" \"label\": \"网吧\"\n" +
" },\n" +
" {\n" +
" \"id\": 26,\n" +
" \"label\": \"游乐场\"\n" +
" },\n" +
" {\n" +
" \"id\": 27,\n" +
" \"label\": \"电影院\"\n" +
" }\n" +
" ],\n" +
" \"id\": 18,\n" +
" \"label\": \"娱乐类\"\n" +
" }\n" +
" ],\n" +
" \"id\": -1,\n" +
" \"label\": \"全部行业\"\n" +
"}";
CertificateIndustryTreeSelect certificateIndustryTreeSelect = JSONObject.parseObject(json, CertificateIndustryTreeSelect.class);
System.out.println(JSONObject.toJSONString(certificateIndustryTreeSelect));
}
}
\ No newline at end of file
...@@ -19,5 +19,10 @@ public class CertificateDocumentVo extends BaseEntityLong { ...@@ -19,5 +19,10 @@ public class CertificateDocumentVo extends BaseEntityLong {
/** 序号,主键,自增长列表 */ /** 序号,主键,自增长列表 */
private List <Long> idList; private List <Long> idList;
/**
* 证照目录id
*/
private Long catalogId;
} }
\ No newline at end of file
package com.mortals.xhx.module.certificate.service; package com.mortals.xhx.module.certificate.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.certificate.dao.CertificateIndustryDao;
import com.mortals.xhx.module.certificate.model.CertificateIndustryEntity; import com.mortals.xhx.module.certificate.model.CertificateIndustryEntity;
import com.mortals.xhx.module.certificate.model.CertificateIndustryTreeSelect;
import java.util.List;
/** /**
* CertificateIndustryService * CertificateIndustryService
* * <p>
* 行业目录 service接口 * 行业目录 service接口
* *
* @author zxfei * @author zxfei
* @date 2022-10-14 * @date 2022-10-14
*/ */
public interface CertificateIndustryService extends ICRUDService<CertificateIndustryEntity,Long>{ public interface CertificateIndustryService extends ICRUDService<CertificateIndustryEntity, Long> {
CertificateIndustryDao getDao();
/**
* 是否存在行业目录节点
*
* @param certificateIndustryId 行业目录ID
* @return 结果
*/
boolean hasChildByCertificateIndustryId(Long certificateIndustryId);
/**
* 构建前端所需要下拉树结构
*
* @param certificateIndustryList 行业目录列表
* @return 下拉树结构列表
*/
List<CertificateIndustryTreeSelect> buildCertificateIndustryTreeSelect(List<CertificateIndustryEntity> certificateIndustryList);
/**
* 根据父id查询子节点
*
* @param parentId
* @param context
* @return
*/
List<CertificateIndustryTreeSelect> getListByParentId(Long parentId, Context context);
/**
* 根据父id查询子节点
*
* @param parentId
* @param context
* @return
*/
List<CertificateIndustryTreeSelect> getAllListByParentId(Long parentId, Context context);
} }
\ No newline at end of file
...@@ -20,10 +20,7 @@ import com.mortals.xhx.common.pdu.gen.component.ComponentCons; ...@@ -20,10 +20,7 @@ import com.mortals.xhx.common.pdu.gen.component.ComponentCons;
import com.mortals.xhx.common.utils.ExcelUtil; import com.mortals.xhx.common.utils.ExcelUtil;
import com.mortals.xhx.common.utils.StringUtils; import com.mortals.xhx.common.utils.StringUtils;
import com.mortals.xhx.module.certificate.dao.CertificateCatalogDao; import com.mortals.xhx.module.certificate.dao.CertificateCatalogDao;
import com.mortals.xhx.module.certificate.model.CertificateCatalogEntity; import com.mortals.xhx.module.certificate.model.*;
import com.mortals.xhx.module.certificate.model.CertificateChildEntity;
import com.mortals.xhx.module.certificate.model.CertificateChildQuery;
import com.mortals.xhx.module.certificate.model.CertificateClassifyEntity;
import com.mortals.xhx.module.certificate.service.CertificateCatalogService; import com.mortals.xhx.module.certificate.service.CertificateCatalogService;
import com.mortals.xhx.module.certificate.service.CertificateChildService; import com.mortals.xhx.module.certificate.service.CertificateChildService;
import com.mortals.xhx.module.certificate.service.CertificateClassifyService; import com.mortals.xhx.module.certificate.service.CertificateClassifyService;
...@@ -34,6 +31,7 @@ import org.springframework.stereotype.Service; ...@@ -34,6 +31,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -83,20 +81,20 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi ...@@ -83,20 +81,20 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
@Override @Override
protected void saveBefore(CertificateCatalogEntity entity, Context context) throws AppException { protected void saveBefore(CertificateCatalogEntity entity, Context context) throws AppException {
validData(entity,context); validData(entity, context);
entity.setStatus(StatusEnum.ENABLE.getValue()); entity.setStatus(StatusEnum.ENABLE.getValue());
if(StringUtils.isNotEmpty(entity.getTemplateFileUrl())){ if (StringUtils.isNotEmpty(entity.getTemplateFileUrl())) {
//entity.setFormContent(parseDocxToJson(entity.getTemplateUrl())); //entity.setFormContent(parseDocxToJson(entity.getTemplateUrl()));
parseDocxToJson(entity,false); parseDocxToJson(entity, false);
} }
} }
@Override @Override
protected void updateBefore(CertificateCatalogEntity entity, Context context) throws AppException { protected void updateBefore(CertificateCatalogEntity entity, Context context) throws AppException {
validData(entity,context); validData(entity, context);
CertificateCatalogEntity old = this.get(entity.getId()); CertificateCatalogEntity old = this.get(entity.getId());
if(!old.getTemplateFileUrl().equals(entity.getTemplateFileUrl())) { if (!old.getTemplateFileUrl().equals(entity.getTemplateFileUrl())) {
if (StringUtils.isNotEmpty(entity.getTemplateFileUrl())) { if (StringUtils.isNotEmpty(entity.getTemplateFileUrl())) {
//entity.setFormContent(parseDocxToJson(entity.getTemplateUrl())); //entity.setFormContent(parseDocxToJson(entity.getTemplateUrl()));
parseDocxToJson(entity, false); parseDocxToJson(entity, false);
...@@ -116,8 +114,15 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi ...@@ -116,8 +114,15 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
@Override @Override
protected void findAfter(CertificateCatalogEntity params, PageInfo pageInfo, Context context, List<CertificateCatalogEntity> list) throws AppException { protected void findAfter(CertificateCatalogEntity params, PageInfo pageInfo, Context context, List<CertificateCatalogEntity> list) throws AppException {
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
List<Long> classifIdList = list.parallelStream().map(CertificateCatalogEntity::getClassifyId).collect(Collectors.toList());
CertificateClassifyQuery certificateClassifyQuery = new CertificateClassifyQuery();
certificateClassifyQuery.setIdList(classifIdList);
Map<Long, CertificateClassifyEntity> collect = certificateClassifyService.find(certificateClassifyQuery, context).parallelStream()
.collect(Collectors.toMap(CertificateClassifyEntity::getId, Function.identity(), (n1, n2) -> n1));
for (CertificateCatalogEntity entity : list) { for (CertificateCatalogEntity entity : list) {
CertificateClassifyEntity certificateClassifyEntity = certificateClassifyService.get(entity.getClassifyId()); CertificateClassifyEntity certificateClassifyEntity = collect.get(entity.getClassifyId());
// CertificateClassifyEntity certificateClassifyEntity = certificateClassifyService.get(entity.getClassifyId());
if (certificateClassifyEntity != null) { if (certificateClassifyEntity != null) {
entity.setClassifyType(certificateClassifyEntity.getClassifyType()); entity.setClassifyType(certificateClassifyEntity.getClassifyType());
} else { } else {
...@@ -136,9 +141,10 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi ...@@ -136,9 +141,10 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
private void fillSubData(List<CertificateCatalogEntity> list) { private void fillSubData(List<CertificateCatalogEntity> list) {
List<Long> idList = list.stream().map(i -> i.getId()).collect(Collectors.toList()); List<Long> idList = list.stream().map(i -> i.getId()).collect(Collectors.toList());
if(ObjectUtils.isEmpty(idList))return;
CertificateChildQuery certificateChildQuery = new CertificateChildQuery(); CertificateChildQuery certificateChildQuery = new CertificateChildQuery();
certificateChildQuery.setCatalogIdList(idList); certificateChildQuery.setCatalogIdList(idList);
Map<Long, List<CertificateChildEntity>> certificateChildListMap = certificateChildService.find(certificateChildQuery).stream().collect(Collectors.groupingBy(CertificateChildEntity::getCatalogId)); Map<Long, List<CertificateChildEntity>> certificateChildListMap = certificateChildService.find(certificateChildQuery).parallelStream().collect(Collectors.groupingBy(CertificateChildEntity::getCatalogId));
list.forEach(item -> item.setCertificateChildList(certificateChildListMap.get(item.getId()))); list.forEach(item -> item.setCertificateChildList(certificateChildListMap.get(item.getId())));
} }
...@@ -147,6 +153,7 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi ...@@ -147,6 +153,7 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
if (!ObjectUtils.isEmpty(entity.getCertificateChildList())) { if (!ObjectUtils.isEmpty(entity.getCertificateChildList())) {
entity.getCertificateChildList().stream().peek(item -> { entity.getCertificateChildList().stream().peek(item -> {
item.setCatalogId(entity.getId()); item.setCatalogId(entity.getId());
item.setCatalogName(entity.getCatalogName());
item.setCreateUserId(this.getContextUserId(context)); item.setCreateUserId(this.getContextUserId(context));
item.setCreateTime(new Date()); item.setCreateTime(new Date());
}).count(); }).count();
...@@ -179,7 +186,7 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi ...@@ -179,7 +186,7 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
super.removeAfter(ids, context, result); super.removeAfter(ids, context, result);
} }
private void parseDocxToJson(CertificateCatalogEntity entity,boolean onlyExcel) { private void parseDocxToJson(CertificateCatalogEntity entity, boolean onlyExcel) {
String rootPath = this.filePath.endsWith("/") ? this.filePath : this.filePath + "/"; String rootPath = this.filePath.endsWith("/") ? this.filePath : this.filePath + "/";
String filepath = rootPath + entity.getTemplateFileUrl(); String filepath = rootPath + entity.getTemplateFileUrl();
ConfigureBuilder builder = Configure.builder(); ConfigureBuilder builder = Configure.builder();
...@@ -206,9 +213,9 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi ...@@ -206,9 +213,9 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
// excelList.add("持有者证件号码"); // excelList.add("持有者证件号码");
// excelList.add("企业名称"); // excelList.add("企业名称");
for (MetaTemplate item : template.getElementTemplates()) { for (MetaTemplate item : template.getElementTemplates()) {
if(hs.contains(item.variable())){ if (hs.contains(item.variable())) {
continue; continue;
}else { } else {
hs.add(item.variable()); hs.add(item.variable());
} }
//识别简单输入 //识别简单输入
...@@ -236,9 +243,9 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi ...@@ -236,9 +243,9 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
XWPFTemplate templateTable = XWPFTemplate.compile(filepath, builderTable.build()); XWPFTemplate templateTable = XWPFTemplate.compile(filepath, builderTable.build());
for (MetaTemplate col : templateTable.getElementTemplates()) { for (MetaTemplate col : templateTable.getElementTemplates()) {
if(dhs.contains(col.variable())){ if (dhs.contains(col.variable())) {
continue; continue;
}else { } else {
dhs.add(col.variable()); dhs.add(col.variable());
} }
String colVal = StrUtil.strip(col.variable(), "[", "]"); String colVal = StrUtil.strip(col.variable(), "[", "]");
...@@ -266,18 +273,18 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi ...@@ -266,18 +273,18 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
} }
DesignComponent designComponent = DesignComponent.createType(type); DesignComponent designComponent = DesignComponent.createType(type);
ListItem listItem = designComponent.buildDefaultComponent(cons); ListItem listItem = designComponent.buildDefaultComponent(cons);
if(type.equals(ComponentEnum.QRCODE.getValue())){ if (type.equals(ComponentEnum.QRCODE.getValue())) {
listItem.setValue(qrcode); listItem.setValue(qrcode);
} }
collect.add(listItem); collect.add(listItem);
} }
} }
root.setList(collect); root.setList(collect);
String fileName = "file/fileupload/excel/"+entity.getCatalogName()+"_批量导入模板.xls"; String fileName = "file/fileupload/excel/" + entity.getCatalogName() + "_批量导入模板.xls";
String excelFilePath = rootPath + fileName; String excelFilePath = rootPath + fileName;
ExcelUtil.createCatalogTemplate(excelFilePath, excelList); ExcelUtil.createCatalogTemplate(excelFilePath, excelList);
entity.setExcelFile(fileName); entity.setExcelFile(fileName);
if(!onlyExcel) { if (!onlyExcel) {
entity.setFormContent(JSON.toJSONString(root)); entity.setFormContent(JSON.toJSONString(root));
} }
} }
...@@ -286,7 +293,7 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi ...@@ -286,7 +293,7 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
@Override @Override
public void generateExcel(Long id, Context context) { public void generateExcel(Long id, Context context) {
CertificateCatalogEntity entity = dao.get(id); CertificateCatalogEntity entity = dao.get(id);
parseDocxToJson(entity,true); parseDocxToJson(entity, true);
CertificateCatalogEntity updata = new CertificateCatalogEntity(); CertificateCatalogEntity updata = new CertificateCatalogEntity();
updata.setId(entity.getId()); updata.setId(entity.getId());
updata.setExcelFile(entity.getExcelFile()); updata.setExcelFile(entity.getExcelFile());
......
package com.mortals.xhx.module.certificate.service.impl; package com.mortals.xhx.module.certificate.service.impl;
import com.mortals.xhx.common.utils.StringUtils; import com.mortals.xhx.common.utils.StringUtils;
import com.mortals.xhx.module.certificate.model.CertificateCatalogEntity; import com.mortals.xhx.module.certificate.model.CertificateCatalogEntity;
import com.mortals.xhx.module.certificate.model.CertificateIndustryQuery;
import com.mortals.xhx.module.certificate.model.CertificateIndustryTreeSelect;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
...@@ -9,39 +12,182 @@ import com.mortals.framework.model.Context; ...@@ -9,39 +12,182 @@ import com.mortals.framework.model.Context;
import com.mortals.xhx.module.certificate.dao.CertificateIndustryDao; import com.mortals.xhx.module.certificate.dao.CertificateIndustryDao;
import com.mortals.xhx.module.certificate.model.CertificateIndustryEntity; import com.mortals.xhx.module.certificate.model.CertificateIndustryEntity;
import com.mortals.xhx.module.certificate.service.CertificateIndustryService; import com.mortals.xhx.module.certificate.service.CertificateIndustryService;
import org.springframework.util.ObjectUtils;
import java.util.HashMap; import java.util.*;
import java.util.List; import java.util.stream.Collectors;
import java.util.Map;
/** /**
* CertificateIndustryService * CertificateIndustryService
* 行业目录 service实现 * 行业目录 service实现
* *
* @author zxfei * @author zxfei
* @date 2022-10-14 * @date 2022-10-14
*/ */
@Service("certificateIndustryService") @Service("certificateIndustryService")
public class CertificateIndustryServiceImpl extends AbstractCRUDServiceImpl<CertificateIndustryDao, CertificateIndustryEntity, Long> implements CertificateIndustryService { public class CertificateIndustryServiceImpl extends AbstractCRUDServiceImpl<CertificateIndustryDao, CertificateIndustryEntity, Long> implements CertificateIndustryService {
@Override @Override
protected void validData(CertificateIndustryEntity entity, Context context) throws AppException { protected void validData(CertificateIndustryEntity entity, Context context) throws AppException {
if(StringUtils.isEmpty(entity.getIndustryName())){ if (StringUtils.isEmpty(entity.getIndustryName())) {
throw new AppException("行业名称不能为空"); throw new AppException("行业名称不能为空");
} }
Map<String,Object> condition = new HashMap<>(); Map<String, Object> condition = new HashMap<>();
condition.put("industryName",entity.getIndustryName()); condition.put("industryName", entity.getIndustryName());
List<CertificateIndustryEntity> list = this.dao.getList(condition); List<CertificateIndustryEntity> list = this.dao.getList(condition);
if(CollectionUtils.isNotEmpty(list)){ if (CollectionUtils.isNotEmpty(list)) {
throw new AppException("行业名称重复"); throw new AppException("行业名称重复");
} }
} }
@Override @Override
protected void saveBefore(CertificateIndustryEntity entity, Context context) throws AppException { protected void saveBefore(CertificateIndustryEntity entity, Context context) throws AppException {
super.saveBefore(entity,context); super.saveBefore(entity, context);
if(entity.getParentId()==null){ if (entity.getParentId() == null) {
entity.setParentId(-1l); entity.setParentId(-1l);
} }
CertificateIndustryEntity parentCertificateIndustryEntity = this.get(entity.getParentId());
if (!ObjectUtils.isEmpty(parentCertificateIndustryEntity)) {
entity.setAncestors(parentCertificateIndustryEntity.getAncestors() + "," + entity.getParentId());
}
}
@Override
protected void updateBefore(CertificateIndustryEntity entity, Context context) throws AppException {
CertificateIndustryEntity newParentEntity = this.get(entity.getParentId());
CertificateIndustryEntity oldEntity = this.get(entity.getId());
if (!ObjectUtils.isEmpty(newParentEntity) && !ObjectUtils.isEmpty(oldEntity)) {
String newAncestors = newParentEntity.getAncestors() + "," + newParentEntity.getId();
String oldAncestors = oldEntity.getAncestors();
entity.setAncestors(newAncestors);
updateCertificateIndustryChildren(entity.getId(), newAncestors, oldAncestors, context);
}
super.updateBefore(entity, context);
}
/**
* 修改子元素关系
*
* @param certificateIndustryId 被修改的行业目录ID
* @param newAncestors 新的父ID集合
* @param oldAncestors 旧的父ID集合
*/
public void updateCertificateIndustryChildren(Long certificateIndustryId, String newAncestors, String oldAncestors, Context context) {
List<CertificateIndustryEntity> children = getDao().selectChildrenCertificateIndustryById(certificateIndustryId.toString());
for (CertificateIndustryEntity child : children) {
child.setAncestors(child.getAncestors().replace(oldAncestors, newAncestors));
}
if (children.size() > 0) {
this.updateAfter(children, context);
}
}
@Override
protected void removeBefore(Long[] ids, Context context) throws AppException {
//有子节点 禁止删除
if (hasChildByCertificateIndustryId(ids[0])) {
throw new AppException("存在下级行业目录,不允许删除");
}
super.removeBefore(ids, context);
}
@Override
public boolean hasChildByCertificateIndustryId(Long certificateIndustryId) {
List<CertificateIndustryEntity> list = this.find(new CertificateIndustryQuery().parentId(certificateIndustryId));
return list.size() > 0 ? true : false;
}
@Override
public List<CertificateIndustryTreeSelect> buildCertificateIndustryTreeSelect(List<CertificateIndustryEntity> list) {
List<CertificateIndustryEntity> returnList = new ArrayList<>();
List<Long> tempList = list.stream().map(CertificateIndustryEntity::getId).collect(Collectors.toList());
Iterator<CertificateIndustryEntity> iterator = list.iterator();
while (iterator.hasNext()) {
CertificateIndustryEntity certificateIndustryEntity = iterator.next();
if (!tempList.contains(certificateIndustryEntity.getParentId())) {
recursionFn(list, certificateIndustryEntity);
returnList.add(certificateIndustryEntity);
}
} }
if (returnList.isEmpty()) {
returnList = list;
}
return returnList.stream().map(CertificateIndustryTreeSelect::new).collect(Collectors.toList());
}
/**
* 递归列表
*/
private void recursionFn(List<CertificateIndustryEntity> list, CertificateIndustryEntity t) {
// 得到子节点列表
List<CertificateIndustryEntity> childList = getChildList(list, t);
t.setChildren(childList);
for (CertificateIndustryEntity tChild : childList) {
if (hasChild(list, tChild)) {
recursionFn(list, tChild);
}
}
}
/**
* 判断是否有子节点
*/
private boolean hasChild(List<CertificateIndustryEntity> list, CertificateIndustryEntity t) {
return getChildList(list, t).size() > 0 ? true : false;
}
/**
* 得到子节点列表
*/
private List<CertificateIndustryEntity> getChildList(List<CertificateIndustryEntity> list, CertificateIndustryEntity t) {
return list.stream().map(item -> {
if (!ObjectUtils.isEmpty(item.getParentId()) && item.getParentId() == t.getId()) {
return item;
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
}
@Override
public List<CertificateIndustryTreeSelect> getListByParentId(Long parentId, Context context) {
if (ObjectUtils.isEmpty(parentId)) {
parentId = -1L;
}
List<CertificateIndustryTreeSelect> collect = this.find(new CertificateIndustryQuery().parentId(parentId), context)
.stream().map(item -> new CertificateIndustryTreeSelect(item))
.collect(Collectors.toList());
return collect;
}
@Override
public List<CertificateIndustryTreeSelect> getAllListByParentId(Long parentId, Context context) {
List<CertificateIndustryEntity> returnList = new ArrayList<>();
//获取子树列表
List<CertificateIndustryEntity> childsList = this.getDao().selectChildrenCertificateIndustryById(parentId.toString());
CertificateIndustryEntity certificateIndustryEntity = this.get(parentId, context);
childsList.add(certificateIndustryEntity);
recursionFn(childsList, certificateIndustryEntity);
returnList.add(certificateIndustryEntity);
/* List<CertificateIndustryEntity> list = this.find(new CertificateIndustryQuery());
List<CertificateIndustryEntity> returnList = new ArrayList<>();
List<Long> tempList = list.stream().map(CertificateIndustryEntity::getId).collect(Collectors.toList());
if (!tempList.contains(parentId)) {
CertificateIndustryEntity certificateIndustryEntity = this.get(parentId, context);
recursionFn(list, certificateIndustryEntity);
returnList.add(certificateIndustryEntity);
}*/
return returnList.stream().map(CertificateIndustryTreeSelect::new).collect(Collectors.toList());
}
} }
\ No newline at end of file
...@@ -5,30 +5,37 @@ import com.mortals.framework.model.Context; ...@@ -5,30 +5,37 @@ import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.StatusEnum; import com.mortals.xhx.common.code.StatusEnum;
import com.mortals.xhx.module.certificate.model.CertificateChildEntity;
import com.mortals.xhx.module.certificate.model.CertificateChildQuery;
import com.mortals.xhx.module.certificate.model.CertificateDocumentEntity; import com.mortals.xhx.module.certificate.model.CertificateDocumentEntity;
import com.mortals.xhx.module.certificate.service.CertificateChildService;
import com.mortals.xhx.module.certificate.service.CertificateDocumentService; import com.mortals.xhx.module.certificate.service.CertificateDocumentService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* * 子证配置
* 子证配置 *
* * @author zxfei
* @author zxfei * @date 2024-07-27
* @date 2024-07-27 */
*/
@RestController @RestController
@RequestMapping("certificate/document") @RequestMapping("certificate/document")
public class CertificateDocumentController extends BaseCRUDJsonBodyMappingController<CertificateDocumentService,CertificateDocumentEntity,Long> { public class CertificateDocumentController extends BaseCRUDJsonBodyMappingController<CertificateDocumentService, CertificateDocumentEntity, Long> {
@Autowired @Autowired
private ParamService paramService; private CertificateChildService certificateChildService;
public CertificateDocumentController(){ public CertificateDocumentController() {
super.setModuleDesc( "子证配置"); super.setModuleDesc("子证配置");
} }
@Override @Override
...@@ -38,9 +45,23 @@ public class CertificateDocumentController extends BaseCRUDJsonBodyMappingContro ...@@ -38,9 +45,23 @@ public class CertificateDocumentController extends BaseCRUDJsonBodyMappingContro
} }
@Override
protected void doListBefore(CertificateDocumentEntity query, Map<String, Object> model, Context context) throws AppException {
if (!ObjectUtils.isEmpty(query.getCatalogId())) {
List<Long> documentIdList = certificateChildService.find(new CertificateChildQuery().catalogId(query.getCatalogId())).stream()
.map(CertificateChildEntity::getDocumentId).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(documentIdList)) {
query.setIdList(documentIdList);
} else {
query.setIdList(Arrays.asList(-1L));
}
}
super.doListBefore(query, model, context);
}
@Override @Override
protected void doListAfter(CertificateDocumentEntity query, List<CertificateDocumentEntity> list, Context context) throws AppException { protected void doListAfter(CertificateDocumentEntity query, List<CertificateDocumentEntity> list, Context context) throws AppException {
list.forEach(item->{ list.forEach(item -> {
item.setFormContent(""); item.setFormContent("");
}); });
......
package com.mortals.xhx.module.certificate.web; package com.mortals.xhx.module.certificate.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth; import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.annotation.DataPermission; import com.mortals.xhx.annotation.DataPermission;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.certificate.model.CertificateIndustryEntity; import com.mortals.xhx.module.certificate.model.CertificateIndustryEntity;
import com.mortals.xhx.module.certificate.model.CertificateIndustryQuery;
import com.mortals.xhx.module.certificate.model.CertificateIndustryTreeSelect;
import com.mortals.xhx.module.certificate.service.CertificateIndustryService; import com.mortals.xhx.module.certificate.service.CertificateIndustryService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collector;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.mortals.framework.ap.SysConstains.RESULT_KEY;
/** /**
* * 行业目录
* 行业目录 *
* * @author zxfei
* @author zxfei * @date 2022-10-14
* @date 2022-10-14 */
*/
@RestController @RestController
@RequestMapping("certificate/industry") @RequestMapping("certificate/industry")
public class CertificateIndustryController extends BaseCRUDJsonBodyMappingController<CertificateIndustryService,CertificateIndustryEntity,Long> { public class CertificateIndustryController extends BaseCRUDJsonBodyMappingController<CertificateIndustryService, CertificateIndustryEntity, Long> {
@Autowired @Autowired
private ParamService paramService; private ParamService paramService;
public CertificateIndustryController(){ public CertificateIndustryController() {
super.setModuleDesc( "行业目录"); super.setModuleDesc("行业目录");
} }
@Override @Override
...@@ -47,59 +42,53 @@ public class CertificateIndustryController extends BaseCRUDJsonBodyMappingContro ...@@ -47,59 +42,53 @@ public class CertificateIndustryController extends BaseCRUDJsonBodyMappingContro
super.init(model, context); super.init(model, context);
} }
@Override /**
@DataPermission * 获取站点下拉树列表
public Rest<Object> list(CertificateIndustryEntity query) { */
return super.list(query); @GetMapping("treeselect")
}
@PostMapping({"treeList"})
@UnAuth @UnAuth
public Rest<Object> treeList(@RequestBody CertificateIndustryEntity query) { public String treeselect() {
Rest<Object> ret = new Rest(); Map<String, Object> model = new HashMap<>();
Map<String, Object> model = new HashMap(); JSONObject ret = new JSONObject();
Context context = this.getContext();
String busiDesc = "查询" + this.getModuleDesc(); String busiDesc = "查询" + this.getModuleDesc();
int code; int code = VALUE_RESULT_SUCCESS;
try { try {
List<CertificateIndustryEntity> result = this.getService().find(query, context); List<CertificateIndustryEntity> list = this.service.find(new CertificateIndustryQuery());
if(CollectionUtils.isNotEmpty(result)){ List<CertificateIndustryTreeSelect> treeSelects = this.service.buildCertificateIndustryTreeSelect(list);
List<CertificateIndustryEntity> collect = result.stream().filter(t -> t.getParentId() == -1).map( model.put("data", treeSelects);
m -> { recordSysLog(request, busiDesc + " 【成功】");
m.setChildren(getChildren(m, result)); } catch (Exception e) {
return m; code = VALUE_RESULT_FAILURE;
this.doException(request, busiDesc, model, e);
} }
).collect(Collectors.toList()); ret.put(KEY_RESULT_DATA, model);
model.put("data", collect); ret.put(KEY_RESULT_CODE, code);
}else { return ret.toJSONString();
model.put("data", result);
}
code = this.doListAfter(query, (Map)model, context);
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
} }
this.init(model, context);
ret.setCode(code);
ret.setData(model);
ret.setDict(model.get("dict"));
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
private static List<CertificateIndustryEntity> getChildren(CertificateIndustryEntity root, List<CertificateIndustryEntity> all) { /**
List<CertificateIndustryEntity> children = all.stream().filter(t -> { * 根据parentId查询子信息
return Objects.equals(t.getParentId(), root.getId()); */
}).map( @GetMapping(value = "getListByParentId")
m -> { public String getListByParentId(Long parentId) {
m.setChildren(getChildren(m, all)); JSONObject ret = new JSONObject();
return m; Map<String, Object> model = new HashMap<>();
String busiDesc = "查询" + this.getModuleDesc() + "子节点";
try {
List<CertificateIndustryTreeSelect> treeList = this.service.getListByParentId(parentId, getContext());
model.put(RESULT_KEY, treeList);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_DATA, model);
recordSysLog(request, busiDesc + "【成功】");
} catch (Exception e) {
log.error("根据parentId查询子信息错误", e);
this.doException(request, busiDesc, model, e);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, e.getMessage());
} }
).collect(Collectors.toList()); return ret.toJSONString();
return children;
} }
} }
\ No newline at end of file
...@@ -14,7 +14,7 @@ import lombok.Data; ...@@ -14,7 +14,7 @@ import lombok.Data;
* 行业许可子证实体对象 * 行业许可子证实体对象
* *
* @author zxfei * @author zxfei
* @date 2024-07-30 * @date 2024-08-08
*/ */
@Data @Data
public class ChildLicenseEntity extends ChildLicenseVo { public class ChildLicenseEntity extends ChildLicenseVo {
...@@ -192,6 +192,14 @@ public class ChildLicenseEntity extends ChildLicenseVo { ...@@ -192,6 +192,14 @@ public class ChildLicenseEntity extends ChildLicenseVo {
* 子证状态(0.禁用,1.启用) * 子证状态(0.禁用,1.启用)
*/ */
private Integer childStatus; private Integer childStatus;
/**
* 正本文件水印相对路径地址
*/
private String originalWaterMarkPath;
/**
* 副本文件水印相对路径地址
*/
private String copyWaterMarkPath;
@Override @Override
public int hashCode() { public int hashCode() {
return this.getId().hashCode(); return this.getId().hashCode();
...@@ -252,5 +260,7 @@ public class ChildLicenseEntity extends ChildLicenseVo { ...@@ -252,5 +260,7 @@ public class ChildLicenseEntity extends ChildLicenseVo {
this.ext7 = ""; this.ext7 = "";
this.ext8 = ""; this.ext8 = "";
this.childStatus = 1; this.childStatus = 1;
this.originalWaterMarkPath = "";
this.copyWaterMarkPath = "";
} }
} }
\ No newline at end of file
...@@ -7,7 +7,7 @@ import com.mortals.xhx.module.child.model.ChildLicenseEntity; ...@@ -7,7 +7,7 @@ import com.mortals.xhx.module.child.model.ChildLicenseEntity;
* 行业许可子证查询对象 * 行业许可子证查询对象
* *
* @author zxfei * @author zxfei
* @date 2024-07-30 * @date 2024-08-08
*/ */
public class ChildLicenseQuery extends ChildLicenseEntity { public class ChildLicenseQuery extends ChildLicenseEntity {
/** 开始 主键ID,主键,自增长 */ /** 开始 主键ID,主键,自增长 */
...@@ -374,6 +374,16 @@ public class ChildLicenseQuery extends ChildLicenseEntity { ...@@ -374,6 +374,16 @@ public class ChildLicenseQuery extends ChildLicenseEntity {
/** 子证状态(0.禁用,1.启用)排除列表 */ /** 子证状态(0.禁用,1.启用)排除列表 */
private List <Integer> childStatusNotList; private List <Integer> childStatusNotList;
/** 正本文件水印相对路径地址 */
private List<String> originalWaterMarkPathList;
/** 正本文件水印相对路径地址排除列表 */
private List <String> originalWaterMarkPathNotList;
/** 副本文件水印相对路径地址 */
private List<String> copyWaterMarkPathList;
/** 副本文件水印相对路径地址排除列表 */
private List <String> copyWaterMarkPathNotList;
/** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */ /** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */
private List<ChildLicenseQuery> orConditionList; private List<ChildLicenseQuery> orConditionList;
...@@ -2506,6 +2516,70 @@ public class ChildLicenseQuery extends ChildLicenseEntity { ...@@ -2506,6 +2516,70 @@ public class ChildLicenseQuery extends ChildLicenseEntity {
} }
/**
* 获取 正本文件水印相对路径地址
* @return originalWaterMarkPathList
*/
public List<String> getOriginalWaterMarkPathList(){
return this.originalWaterMarkPathList;
}
/**
* 设置 正本文件水印相对路径地址
* @param originalWaterMarkPathList
*/
public void setOriginalWaterMarkPathList(List<String> originalWaterMarkPathList){
this.originalWaterMarkPathList = originalWaterMarkPathList;
}
/**
* 获取 正本文件水印相对路径地址
* @return originalWaterMarkPathNotList
*/
public List<String> getOriginalWaterMarkPathNotList(){
return this.originalWaterMarkPathNotList;
}
/**
* 设置 正本文件水印相对路径地址
* @param originalWaterMarkPathNotList
*/
public void setOriginalWaterMarkPathNotList(List<String> originalWaterMarkPathNotList){
this.originalWaterMarkPathNotList = originalWaterMarkPathNotList;
}
/**
* 获取 副本文件水印相对路径地址
* @return copyWaterMarkPathList
*/
public List<String> getCopyWaterMarkPathList(){
return this.copyWaterMarkPathList;
}
/**
* 设置 副本文件水印相对路径地址
* @param copyWaterMarkPathList
*/
public void setCopyWaterMarkPathList(List<String> copyWaterMarkPathList){
this.copyWaterMarkPathList = copyWaterMarkPathList;
}
/**
* 获取 副本文件水印相对路径地址
* @return copyWaterMarkPathNotList
*/
public List<String> getCopyWaterMarkPathNotList(){
return this.copyWaterMarkPathNotList;
}
/**
* 设置 副本文件水印相对路径地址
* @param copyWaterMarkPathNotList
*/
public void setCopyWaterMarkPathNotList(List<String> copyWaterMarkPathNotList){
this.copyWaterMarkPathNotList = copyWaterMarkPathNotList;
}
/** /**
* 设置 主键ID,主键,自增长 * 设置 主键ID,主键,自增长
* @param id * @param id
...@@ -3766,6 +3840,44 @@ public class ChildLicenseQuery extends ChildLicenseEntity { ...@@ -3766,6 +3840,44 @@ public class ChildLicenseQuery extends ChildLicenseEntity {
return this; return this;
} }
/**
* 设置 正本文件水印相对路径地址
* @param originalWaterMarkPath
*/
public ChildLicenseQuery originalWaterMarkPath(String originalWaterMarkPath){
setOriginalWaterMarkPath(originalWaterMarkPath);
return this;
}
/**
* 设置 正本文件水印相对路径地址
* @param originalWaterMarkPathList
*/
public ChildLicenseQuery originalWaterMarkPathList(List<String> originalWaterMarkPathList){
this.originalWaterMarkPathList = originalWaterMarkPathList;
return this;
}
/**
* 设置 副本文件水印相对路径地址
* @param copyWaterMarkPath
*/
public ChildLicenseQuery copyWaterMarkPath(String copyWaterMarkPath){
setCopyWaterMarkPath(copyWaterMarkPath);
return this;
}
/**
* 设置 副本文件水印相对路径地址
* @param copyWaterMarkPathList
*/
public ChildLicenseQuery copyWaterMarkPathList(List<String> copyWaterMarkPathList){
this.copyWaterMarkPathList = copyWaterMarkPathList;
return this;
}
/** /**
* 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) * 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* @return orConditionList * @return orConditionList
......
package com.mortals.xhx.module.child.service.impl; package com.mortals.xhx.module.child.service.impl;
import cn.hutool.core.io.FileUtil;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.code.ProcessStatusEnum; import com.mortals.xhx.common.code.ProcessStatusEnum;
import com.mortals.xhx.common.code.StatusEnum; import com.mortals.xhx.common.code.StatusEnum;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.utils.WatermarkImgUtils;
import com.mortals.xhx.module.certificate.model.CertificateChildEntity; import com.mortals.xhx.module.certificate.model.CertificateChildEntity;
import com.mortals.xhx.module.certificate.model.CertificateChildQuery; import com.mortals.xhx.module.certificate.model.CertificateChildQuery;
import com.mortals.xhx.module.certificate.model.CertificateDocumentEntity; import com.mortals.xhx.module.certificate.model.CertificateDocumentEntity;
...@@ -25,13 +31,15 @@ import com.mortals.xhx.module.child.dao.ChildLicenseDao; ...@@ -25,13 +31,15 @@ import com.mortals.xhx.module.child.dao.ChildLicenseDao;
import com.mortals.xhx.module.child.model.ChildLicenseEntity; import com.mortals.xhx.module.child.model.ChildLicenseEntity;
import com.mortals.xhx.module.child.service.ChildLicenseService; import com.mortals.xhx.module.child.service.ChildLicenseService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
/** /**
* ChildLicenseService * ChildLicenseService
* 行业许可子证 service实现 * 行业许可子证 service实现
* *
* @author zxfei * @author zxfei
* @date 2024-07-28 * @date 2024-07-28
*/ */
@Service("childLicenseService") @Service("childLicenseService")
@Slf4j @Slf4j
public class ChildLicenseServiceImpl extends AbstractCRUDServiceImpl<ChildLicenseDao, ChildLicenseEntity, Long> implements ChildLicenseService { public class ChildLicenseServiceImpl extends AbstractCRUDServiceImpl<ChildLicenseDao, ChildLicenseEntity, Long> implements ChildLicenseService {
...@@ -40,25 +48,29 @@ public class ChildLicenseServiceImpl extends AbstractCRUDServiceImpl<ChildLicens ...@@ -40,25 +48,29 @@ public class ChildLicenseServiceImpl extends AbstractCRUDServiceImpl<ChildLicens
private CertificateChildService certificateChildService; private CertificateChildService certificateChildService;
@Autowired @Autowired
private CertificateDocumentService certificateDocumentService; private CertificateDocumentService certificateDocumentService;
@Autowired
private UploadService uploadService;
@Override @Override
public int createChildLicense(ApplyLogEntity applyLogEntity, Long oldId, Context context) throws AppException { public int createChildLicense(ApplyLogEntity applyLogEntity, Long oldId, Context context) throws AppException {
int result = 0; int result = 0;
if(applyLogEntity.getCatalogId()!=null) { if (applyLogEntity.getCatalogId() != null) {
Map<Long,Long> documentIdMap = new HashMap<>(); Map<Long, Long> documentIdMap = new HashMap<>();
if(CollectionUtils.isNotEmpty(applyLogEntity.getChildCertificate())){ if (CollectionUtils.isNotEmpty(applyLogEntity.getChildCertificate())) {
applyLogEntity.getChildCertificate().forEach(i->{ applyLogEntity.getChildCertificate().forEach(i -> {
if(i.getStatus()==1){ if (i.getStatus() == 1) {
documentIdMap.put(i.getId(),i.getId()); documentIdMap.put(i.getId(), i.getId());
} }
}); });
} }
boolean isAdd = true; boolean isAdd = true;
if(oldId!=null){ if (oldId != null) {
List<ChildLicenseEntity> oldChildList = this.find(new ChildLicenseQuery().applyId(oldId)); List<ChildLicenseEntity> oldChildList = this.find(new ChildLicenseQuery().applyId(oldId));
if(CollectionUtils.isNotEmpty(oldChildList)){ if (CollectionUtils.isNotEmpty(oldChildList)) {
isAdd = false; isAdd = false;
} }
for(ChildLicenseEntity child:oldChildList){ for (ChildLicenseEntity child : oldChildList) {
child.setApplyId(applyLogEntity.getId()); child.setApplyId(applyLogEntity.getId());
if (documentIdMap.size() > 0 && documentIdMap.containsKey(child.getDocumentId())) { if (documentIdMap.size() > 0 && documentIdMap.containsKey(child.getDocumentId())) {
child.setChildStatus(StatusEnum.ENABLE.getValue()); child.setChildStatus(StatusEnum.ENABLE.getValue());
...@@ -68,11 +80,13 @@ public class ChildLicenseServiceImpl extends AbstractCRUDServiceImpl<ChildLicens ...@@ -68,11 +80,13 @@ public class ChildLicenseServiceImpl extends AbstractCRUDServiceImpl<ChildLicens
} }
this.update(oldChildList); this.update(oldChildList);
} }
if(isAdd) { if (isAdd) {
// List<CertificateChildEntity> childEntityList = certificateChildService.find(new CertificateChildQuery().catalogId(applyLogEntity.getCatalogId())); List<CertificateChildEntity> childEntityList = certificateChildService.find(new CertificateChildQuery().catalogId(applyLogEntity.getCatalogId()));
// List<Long> documentIdList = childEntityList.stream().map(CertificateChildEntity::getDocumentId).collect(Collectors.toList()); List<Long> documentIdList = childEntityList.stream().map(CertificateChildEntity::getDocumentId).collect(Collectors.toList());
// if (ObjectUtils.isEmpty(documentIdList)) return result;
List<CertificateDocumentEntity> documentEntityList = certificateDocumentService.find(new CertificateDocumentQuery().status(StatusEnum.ENABLE.getValue())); CertificateDocumentQuery certificateDocumentQuery = new CertificateDocumentQuery();
certificateDocumentQuery.setIdList(documentIdList);
List<CertificateDocumentEntity> documentEntityList = certificateDocumentService.find(certificateDocumentQuery);
if (CollectionUtils.isNotEmpty(documentEntityList)) { if (CollectionUtils.isNotEmpty(documentEntityList)) {
List<ChildLicenseEntity> childLicense = new ArrayList<>(); List<ChildLicenseEntity> childLicense = new ArrayList<>();
for (CertificateDocumentEntity item : documentEntityList) { for (CertificateDocumentEntity item : documentEntityList) {
...@@ -115,6 +129,34 @@ public class ChildLicenseServiceImpl extends AbstractCRUDServiceImpl<ChildLicens ...@@ -115,6 +129,34 @@ public class ChildLicenseServiceImpl extends AbstractCRUDServiceImpl<ChildLicens
return result; return result;
} }
@Override
protected void updateBefore(ChildLicenseEntity entity, Context context) throws AppException {
String WarterMark = GlobalSysInfo.getParamValue(Constant.Param_waterMark, "");
if (ObjectUtils.isEmpty(WarterMark)) return;
if (!ObjectUtils.isEmpty(entity.getOriginalFilePath())) {
String originalFilePath = entity.getOriginalFilePath();
String targetPath = getWaterPath(WarterMark, originalFilePath);
entity.setOriginalWaterMarkPath(targetPath);
}
if (!ObjectUtils.isEmpty(entity.getCopyFilePath())) {
String originalFilePath = entity.getCopyFilePath();
String targetPath = getWaterPath(WarterMark, originalFilePath);
entity.setCopyWaterMarkPath(targetPath);
}
super.updateBefore(entity, context);
}
private String getWaterPath(String WarterMark, String originalFilePath) {
String originalAllPath = uploadService.getFilePath(originalFilePath);
String targetPath = "/file/fileupload/" + new Date().getTime() + "_watermark.jpg";
String targetAllPath = uploadService.getFilePath(targetPath);
if (FileUtil.exist(originalAllPath)) {
WatermarkImgUtils.addWatermark(originalAllPath,
targetAllPath,
WarterMark, "jpg");
}
return targetPath;
}
} }
\ No newline at end of file
...@@ -120,7 +120,6 @@ public class ChildLicenseController extends BaseCRUDJsonBodyMappingController<Ch ...@@ -120,7 +120,6 @@ public class ChildLicenseController extends BaseCRUDJsonBodyMappingController<Ch
childLicenseEntity.setReportTime(new Date()); childLicenseEntity.setReportTime(new Date());
childLicenseEntity.setProcessStatus(ProcessStatusEnum.已处理.getValue()); childLicenseEntity.setProcessStatus(ProcessStatusEnum.已处理.getValue());
this.service.update(childLicenseEntity, getContext()); this.service.update(childLicenseEntity, getContext());
recordSysLog(request, busiDesc + " 【成功】"); recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_DATA, model); jsonObject.put(KEY_RESULT_DATA, model);
......
...@@ -14,7 +14,7 @@ import lombok.Data; ...@@ -14,7 +14,7 @@ import lombok.Data;
* 证照申请实体对象 * 证照申请实体对象
* *
* @author zxfei * @author zxfei
* @date 2024-07-31 * @date 2024-08-08
*/ */
@Data @Data
public class ApplyLogEntity extends ApplyLogVo { public class ApplyLogEntity extends ApplyLogVo {
...@@ -160,6 +160,10 @@ public class ApplyLogEntity extends ApplyLogVo { ...@@ -160,6 +160,10 @@ public class ApplyLogEntity extends ApplyLogVo {
* 附件地址 * 附件地址
*/ */
private String annexUrl; private String annexUrl;
/**
* 水印图片地址
*/
private String watermarkUrl;
@Override @Override
public int hashCode() { public int hashCode() {
return this.getId().hashCode(); return this.getId().hashCode();
...@@ -212,5 +216,6 @@ public class ApplyLogEntity extends ApplyLogVo { ...@@ -212,5 +216,6 @@ public class ApplyLogEntity extends ApplyLogVo {
this.authority = ""; this.authority = "";
this.annexName = ""; this.annexName = "";
this.annexUrl = ""; this.annexUrl = "";
this.watermarkUrl = "";
} }
} }
\ No newline at end of file
...@@ -7,7 +7,7 @@ import com.mortals.xhx.module.record.model.ApplyLogEntity; ...@@ -7,7 +7,7 @@ import com.mortals.xhx.module.record.model.ApplyLogEntity;
* 证照申请查询对象 * 证照申请查询对象
* *
* @author zxfei * @author zxfei
* @date 2024-07-31 * @date 2024-08-08
*/ */
public class ApplyLogQuery extends ApplyLogEntity { public class ApplyLogQuery extends ApplyLogEntity {
/** 开始 序号,主键,自增长 */ /** 开始 序号,主键,自增长 */
...@@ -325,6 +325,11 @@ public class ApplyLogQuery extends ApplyLogEntity { ...@@ -325,6 +325,11 @@ public class ApplyLogQuery extends ApplyLogEntity {
/** 附件地址排除列表 */ /** 附件地址排除列表 */
private List <String> annexUrlNotList; private List <String> annexUrlNotList;
/** 水印图片地址 */
private List<String> watermarkUrlList;
/** 水印图片地址排除列表 */
private List <String> watermarkUrlNotList;
/** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */ /** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */
private List<ApplyLogQuery> orConditionList; private List<ApplyLogQuery> orConditionList;
...@@ -2152,6 +2157,38 @@ public class ApplyLogQuery extends ApplyLogEntity { ...@@ -2152,6 +2157,38 @@ public class ApplyLogQuery extends ApplyLogEntity {
this.annexUrlNotList = annexUrlNotList; this.annexUrlNotList = annexUrlNotList;
} }
/**
* 获取 水印图片地址
* @return watermarkUrlList
*/
public List<String> getWatermarkUrlList(){
return this.watermarkUrlList;
}
/**
* 设置 水印图片地址
* @param watermarkUrlList
*/
public void setWatermarkUrlList(List<String> watermarkUrlList){
this.watermarkUrlList = watermarkUrlList;
}
/**
* 获取 水印图片地址
* @return watermarkUrlNotList
*/
public List<String> getWatermarkUrlNotList(){
return this.watermarkUrlNotList;
}
/**
* 设置 水印图片地址
* @param watermarkUrlNotList
*/
public void setWatermarkUrlNotList(List<String> watermarkUrlNotList){
this.watermarkUrlNotList = watermarkUrlNotList;
}
/** /**
* 设置 序号,主键,自增长 * 设置 序号,主键,自增长
* @param id * @param id
...@@ -3207,6 +3244,25 @@ public class ApplyLogQuery extends ApplyLogEntity { ...@@ -3207,6 +3244,25 @@ public class ApplyLogQuery extends ApplyLogEntity {
return this; return this;
} }
/**
* 设置 水印图片地址
* @param watermarkUrl
*/
public ApplyLogQuery watermarkUrl(String watermarkUrl){
setWatermarkUrl(watermarkUrl);
return this;
}
/**
* 设置 水印图片地址
* @param watermarkUrlList
*/
public ApplyLogQuery watermarkUrlList(List<String> watermarkUrlList){
this.watermarkUrlList = watermarkUrlList;
return this;
}
/** /**
* 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) * 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* @return orConditionList * @return orConditionList
......
...@@ -32,4 +32,12 @@ public class ApplyLogVo extends BaseEntityLong { ...@@ -32,4 +32,12 @@ public class ApplyLogVo extends BaseEntityLong {
private List<CertificateDocumentPdu> childCertificate; private List<CertificateDocumentPdu> childCertificate;
/**
* 行业id
*/
private Long industryId;
private List <Long> catalogIdList;
} }
\ No newline at end of file
package com.mortals.xhx.module.record.web; package com.mortals.xhx.module.record.web;
import cn.hutool.core.img.ImgUtil;
import cn.hutool.core.io.FileUtil;
import com.mortals.framework.annotation.UnAuth; import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.IBaseEnum; import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
...@@ -14,10 +16,11 @@ import com.mortals.xhx.base.system.user.service.UserService; ...@@ -14,10 +16,11 @@ import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.*; import com.mortals.xhx.common.code.*;
import com.mortals.xhx.common.utils.ImportExcelUtil; import com.mortals.xhx.common.utils.ImportExcelUtil;
import com.mortals.xhx.common.utils.ReadExcelPictureUtil; import com.mortals.xhx.common.utils.ReadExcelPictureUtil;
import com.mortals.xhx.module.certificate.model.CertificateDocumentEntity; import com.mortals.xhx.module.certificate.model.*;
import com.mortals.xhx.module.certificate.model.CertificateDocumentQuery;
import com.mortals.xhx.module.certificate.model.vo.CertificateDocumentPdu; import com.mortals.xhx.module.certificate.model.vo.CertificateDocumentPdu;
import com.mortals.xhx.module.certificate.service.CertificateCatalogService;
import com.mortals.xhx.module.certificate.service.CertificateDocumentService; import com.mortals.xhx.module.certificate.service.CertificateDocumentService;
import com.mortals.xhx.module.certificate.service.CertificateIndustryService;
import org.apache.poi.ss.usermodel.PictureData; import org.apache.poi.ss.usermodel.PictureData;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -27,15 +30,25 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -27,15 +30,25 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.swing.*;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.record.model.ApplyLogEntity; import com.mortals.xhx.module.record.model.ApplyLogEntity;
import com.mortals.xhx.module.record.service.ApplyLogService; import com.mortals.xhx.module.record.service.ApplyLogService;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils; import com.mortals.framework.util.StringUtils;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.*; import java.util.*;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -61,6 +74,11 @@ public class ApplyLogController extends BaseCRUDJsonBodyMappingController<ApplyL ...@@ -61,6 +74,11 @@ public class ApplyLogController extends BaseCRUDJsonBodyMappingController<ApplyL
private CertificateDocumentService certificateDocumentService; private CertificateDocumentService certificateDocumentService;
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired
private CertificateIndustryService certificateIndustryService;
@Autowired
private CertificateCatalogService certificateCatalogService;
public ApplyLogController(){ public ApplyLogController(){
super.setModuleDesc( "证照申请"); super.setModuleDesc( "证照申请");
...@@ -76,6 +94,42 @@ public class ApplyLogController extends BaseCRUDJsonBodyMappingController<ApplyL ...@@ -76,6 +94,42 @@ public class ApplyLogController extends BaseCRUDJsonBodyMappingController<ApplyL
super.init(model, context); super.init(model, context);
} }
@Override
protected void doListBefore(ApplyLogEntity query, Map<String, Object> model, Context context) throws AppException {
if(!ObjectUtils.isEmpty(query.getIndustryId())){
//获取行业与子行业
CertificateIndustryEntity industryEntity = certificateIndustryService.get(query.getIndustryId());
if(ObjectUtils.isEmpty(industryEntity)){
query.setCatalogId(-1L);
return;
}
List<CertificateIndustryEntity> childsEntities = certificateIndustryService.getDao().selectChildrenCertificateIndustryById(query.getIndustryId().toString());
List<Long> industryIdList = childsEntities.stream().map(x -> x.getId()).collect(Collectors.toList());
industryIdList.add(query.getIndustryId());
/* List<Long> industryIdList = certificateIndustryService.find(new CertificateIndustryQuery()
.ancestors(industryEntity.getAncestors() + "%"))
.stream().map(x -> x.getId()).collect(Collectors.toList());
if(ObjectUtils.isEmpty(industryIdList)) {
query.setCatalogId(-1L);
return;
}*/
List<Long> catalogIdlist = certificateCatalogService.find(new CertificateCatalogQuery().industryIdList(industryIdList))
.stream().map(x -> x.getId()).collect(Collectors.toList());
if(ObjectUtils.isEmpty(catalogIdlist)) {
query.setCatalogId(-1L);
return;
}
query.setCatalogIdList(catalogIdlist);
}
super.doListBefore(query, model, context);
}
/** /**
* 预览正本 * 预览正本
*/ */
...@@ -252,4 +306,20 @@ public class ApplyLogController extends BaseCRUDJsonBodyMappingController<ApplyL ...@@ -252,4 +306,20 @@ public class ApplyLogController extends BaseCRUDJsonBodyMappingController<ApplyL
return ret.toJSONString(); return ret.toJSONString();
} }
public static void main(String[] args) {
ImgUtil.pressText(//
FileUtil.file("E:\\pic\\back.jpg"), //
FileUtil.file("E:\\pic\\back_water.jpg"), //
"南方者@版权所有", Color.RED, //文字
new Font("宋体", Font.BOLD, 100), //字体
0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
0, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
0.5f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
);
}
} }
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd"> "mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.certificate.dao.ibatis.CertificateIndustryDaoImpl"> <mapper namespace="com.mortals.xhx.module.certificate.dao.ibatis.CertificateIndustryDaoImpl">
<!-- 字段和属性映射 --> <!-- 字段和属性映射 -->
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<result property="createTime" column="createTime" /> <result property="createTime" column="createTime" />
<result property="updateUserId" column="updateUserId" /> <result property="updateUserId" column="updateUserId" />
<result property="updateTime" column="updateTime" /> <result property="updateTime" column="updateTime" />
<result property="ancestors" column="ancestors" />
</resultMap> </resultMap>
<!-- 表所有列 --> <!-- 表所有列 -->
...@@ -42,23 +43,26 @@ ...@@ -42,23 +43,26 @@
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateTime') or colPickMode == 1 and data.containsKey('updateTime')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateTime') or colPickMode == 1 and data.containsKey('updateTime')))">
a.updateTime, a.updateTime,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('ancestors') or colPickMode == 1 and data.containsKey('ancestors')))">
a.ancestors,
</if>
</trim> </trim>
</sql> </sql>
<!-- 新增 区分主键自增加还是业务插入 --> <!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="CertificateIndustryEntity" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="CertificateIndustryEntity" useGeneratedKeys="true" keyProperty="id">
insert into mortals_xhx_certificate_industry insert into mortals_xhx_certificate_industry
(siteId,parentId,industryName,createUserId,createTime,updateUserId,updateTime) (siteId,parentId,industryName,createUserId,createTime,updateUserId,updateTime,ancestors)
VALUES VALUES
(#{siteId},#{parentId},#{industryName},#{createUserId},#{createTime},#{updateUserId},#{updateTime}) (#{siteId},#{parentId},#{industryName},#{createUserId},#{createTime},#{updateUserId},#{updateTime},#{ancestors})
</insert> </insert>
<!-- 批量新增 --> <!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto"> <insert id="insertBatch" parameterType="paramDto">
insert into mortals_xhx_certificate_industry insert into mortals_xhx_certificate_industry
(siteId,parentId,industryName,createUserId,createTime,updateUserId,updateTime) (siteId,parentId,industryName,createUserId,createTime,updateUserId,updateTime,ancestors)
VALUES VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," > <foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.siteId},#{item.parentId},#{item.industryName},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime}) (#{item.siteId},#{item.parentId},#{item.industryName},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime},#{item.ancestors})
</foreach> </foreach>
</insert> </insert>
...@@ -101,6 +105,9 @@ ...@@ -101,6 +105,9 @@
<if test="(colPickMode==0 and data.containsKey('updateTime')) or (colPickMode==1 and !data.containsKey('updateTime'))"> <if test="(colPickMode==0 and data.containsKey('updateTime')) or (colPickMode==1 and !data.containsKey('updateTime'))">
a.updateTime=#{data.updateTime}, a.updateTime=#{data.updateTime},
</if> </if>
<if test="(colPickMode==0 and data.containsKey('ancestors')) or (colPickMode==1 and !data.containsKey('ancestors'))">
a.ancestors=#{data.ancestors},
</if>
</trim> </trim>
<trim suffixOverrides="where" suffix=""> <trim suffixOverrides="where" suffix="">
where where
...@@ -182,6 +189,13 @@ ...@@ -182,6 +189,13 @@
</if> </if>
</foreach> </foreach>
</trim> </trim>
<trim prefix="ancestors=(case" suffix="ELSE ancestors end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('ancestors')) or (colPickMode==1 and !item.containsKey('ancestors'))">
when a.id=#{item.id} then #{item.ancestors}
</if>
</foreach>
</trim>
</trim> </trim>
where id in where id in
<foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")"> <foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")">
...@@ -244,6 +258,10 @@ ...@@ -244,6 +258,10 @@
</select> </select>
<!-- 获取子节点 -->
<select id="selectChildrenCertificateIndustryById" parameterType="String" resultMap="CertificateIndustryEntity-Map">
select * from mortals_xhx_certificate_industry as a where find_in_set(#{certificateIndustryId}, ancestors)
</select>
<!-- 获取 --> <!-- 获取 -->
<select id="getListCount" parameterType="paramDto" resultType="int"> <select id="getListCount" parameterType="paramDto" resultType="int">
...@@ -488,6 +506,27 @@ ...@@ -488,6 +506,27 @@
<if test="conditionParamRef.containsKey('updateTimeEnd') and conditionParamRef.updateTimeEnd != null and conditionParamRef.updateTimeEnd!=''"> <if test="conditionParamRef.containsKey('updateTimeEnd') and conditionParamRef.updateTimeEnd != null and conditionParamRef.updateTimeEnd!=''">
${_conditionType_} a.updateTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.updateTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s') ${_conditionType_} a.updateTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.updateTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
</if> </if>
<if test="conditionParamRef.containsKey('ancestors')">
<if test="conditionParamRef.ancestors != null and conditionParamRef.ancestors != ''">
${_conditionType_} a.ancestors like #{${_conditionParam_}.ancestors}
</if>
<if test="conditionParamRef.ancestors == null">
${_conditionType_} a.ancestors is null
</if>
</if>
<if test="conditionParamRef.containsKey('ancestorsList') and conditionParamRef.ancestorsList.size() > 0">
${_conditionType_} a.ancestors in
<foreach collection="conditionParamRef.ancestorsList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('ancestorsNotList') and conditionParamRef.ancestorsNotList.size() > 0">
${_conditionType_} a.ancestors not in
<foreach collection="conditionParamRef.ancestorsNotList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
</sql> </sql>
<sql id="_orderCols_"> <sql id="_orderCols_">
<if test="orderColList != null and !orderColList.isEmpty()"> <if test="orderColList != null and !orderColList.isEmpty()">
...@@ -611,6 +650,11 @@ ...@@ -611,6 +650,11 @@
<if test='orderCol.updateTime != null and "DESC".equalsIgnoreCase(orderCol.updateTime)'>DESC</if> <if test='orderCol.updateTime != null and "DESC".equalsIgnoreCase(orderCol.updateTime)'>DESC</if>
, ,
</if> </if>
<if test="orderCol.containsKey('ancestors')">
a.ancestors
<if test='orderCol.ancestors != null and "DESC".equalsIgnoreCase(orderCol.ancestors)'>DESC</if>
,
</if>
</trim> </trim>
</if> </if>
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
<result property="authority" column="authority" /> <result property="authority" column="authority" />
<result property="annexName" column="annexName" /> <result property="annexName" column="annexName" />
<result property="annexUrl" column="annexUrl" /> <result property="annexUrl" column="annexUrl" />
<result property="watermarkUrl" column="watermarkUrl" />
</resultMap> </resultMap>
<!-- 表所有列 --> <!-- 表所有列 -->
...@@ -170,23 +171,26 @@ ...@@ -170,23 +171,26 @@
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('annexUrl') or colPickMode == 1 and data.containsKey('annexUrl')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('annexUrl') or colPickMode == 1 and data.containsKey('annexUrl')))">
a.annexUrl, a.annexUrl,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('watermarkUrl') or colPickMode == 1 and data.containsKey('watermarkUrl')))">
a.watermarkUrl,
</if>
</trim> </trim>
</sql> </sql>
<!-- 新增 区分主键自增加还是业务插入 --> <!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="ApplyLogEntity" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="ApplyLogEntity" useGeneratedKeys="true" keyProperty="id">
insert into mortals_xhx_apply_log insert into mortals_xhx_apply_log
(siteId,recordId,catalogId,catalogCode,catalogName,certificateCode,certificateName,issueTime,pickerName,pickerIDCardNo,mobile,holderType,holderIdType,holderName,holderIDCardNo,enterpriseName,legalPerson,socialCode,validityStart,validityEnd,privateID,certificateUrl,previewUrl,formContent,formTemplate,generateStatus,operType,recordStatus,qRCode,createUserId,createTime,updateUserId,updateTime,industryName,businessPlace,licenseProject,authority,annexName,annexUrl) (siteId,recordId,catalogId,catalogCode,catalogName,certificateCode,certificateName,issueTime,pickerName,pickerIDCardNo,mobile,holderType,holderIdType,holderName,holderIDCardNo,enterpriseName,legalPerson,socialCode,validityStart,validityEnd,privateID,certificateUrl,previewUrl,formContent,formTemplate,generateStatus,operType,recordStatus,qRCode,createUserId,createTime,updateUserId,updateTime,industryName,businessPlace,licenseProject,authority,annexName,annexUrl,watermarkUrl)
VALUES VALUES
(#{siteId},#{recordId},#{catalogId},#{catalogCode},#{catalogName},#{certificateCode},#{certificateName},#{issueTime},#{pickerName},#{pickerIDCardNo},#{mobile},#{holderType},#{holderIdType},#{holderName},#{holderIDCardNo},#{enterpriseName},#{legalPerson},#{socialCode},#{validityStart},#{validityEnd},#{privateID},#{certificateUrl},#{previewUrl},#{formContent},#{formTemplate},#{generateStatus},#{operType},#{recordStatus},#{qRCode},#{createUserId},#{createTime},#{updateUserId},#{updateTime},#{industryName},#{businessPlace},#{licenseProject},#{authority},#{annexName},#{annexUrl}) (#{siteId},#{recordId},#{catalogId},#{catalogCode},#{catalogName},#{certificateCode},#{certificateName},#{issueTime},#{pickerName},#{pickerIDCardNo},#{mobile},#{holderType},#{holderIdType},#{holderName},#{holderIDCardNo},#{enterpriseName},#{legalPerson},#{socialCode},#{validityStart},#{validityEnd},#{privateID},#{certificateUrl},#{previewUrl},#{formContent},#{formTemplate},#{generateStatus},#{operType},#{recordStatus},#{qRCode},#{createUserId},#{createTime},#{updateUserId},#{updateTime},#{industryName},#{businessPlace},#{licenseProject},#{authority},#{annexName},#{annexUrl},#{watermarkUrl})
</insert> </insert>
<!-- 批量新增 --> <!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto"> <insert id="insertBatch" parameterType="paramDto">
insert into mortals_xhx_apply_log insert into mortals_xhx_apply_log
(siteId,recordId,catalogId,catalogCode,catalogName,certificateCode,certificateName,issueTime,pickerName,pickerIDCardNo,mobile,holderType,holderIdType,holderName,holderIDCardNo,enterpriseName,legalPerson,socialCode,validityStart,validityEnd,privateID,certificateUrl,previewUrl,formContent,formTemplate,generateStatus,operType,recordStatus,qRCode,createUserId,createTime,updateUserId,updateTime,industryName,businessPlace,licenseProject,authority,annexName,annexUrl) (siteId,recordId,catalogId,catalogCode,catalogName,certificateCode,certificateName,issueTime,pickerName,pickerIDCardNo,mobile,holderType,holderIdType,holderName,holderIDCardNo,enterpriseName,legalPerson,socialCode,validityStart,validityEnd,privateID,certificateUrl,previewUrl,formContent,formTemplate,generateStatus,operType,recordStatus,qRCode,createUserId,createTime,updateUserId,updateTime,industryName,businessPlace,licenseProject,authority,annexName,annexUrl,watermarkUrl)
VALUES VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," > <foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.siteId},#{item.recordId},#{item.catalogId},#{item.catalogCode},#{item.catalogName},#{item.certificateCode},#{item.certificateName},#{item.issueTime},#{item.pickerName},#{item.pickerIDCardNo},#{item.mobile},#{item.holderType},#{item.holderIdType},#{item.holderName},#{item.holderIDCardNo},#{item.enterpriseName},#{item.legalPerson},#{item.socialCode},#{item.validityStart},#{item.validityEnd},#{item.privateID},#{item.certificateUrl},#{item.previewUrl},#{item.formContent},#{item.formTemplate},#{item.generateStatus},#{item.operType},#{item.recordStatus},#{item.qRCode},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime},#{item.industryName},#{item.businessPlace},#{item.licenseProject},#{item.authority},#{item.annexName},#{item.annexUrl}) (#{item.siteId},#{item.recordId},#{item.catalogId},#{item.catalogCode},#{item.catalogName},#{item.certificateCode},#{item.certificateName},#{item.issueTime},#{item.pickerName},#{item.pickerIDCardNo},#{item.mobile},#{item.holderType},#{item.holderIdType},#{item.holderName},#{item.holderIDCardNo},#{item.enterpriseName},#{item.legalPerson},#{item.socialCode},#{item.validityStart},#{item.validityEnd},#{item.privateID},#{item.certificateUrl},#{item.previewUrl},#{item.formContent},#{item.formTemplate},#{item.generateStatus},#{item.operType},#{item.recordStatus},#{item.qRCode},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime},#{item.industryName},#{item.businessPlace},#{item.licenseProject},#{item.authority},#{item.annexName},#{item.annexUrl},#{item.watermarkUrl})
</foreach> </foreach>
</insert> </insert>
...@@ -343,6 +347,9 @@ ...@@ -343,6 +347,9 @@
<if test="(colPickMode==0 and data.containsKey('annexUrl')) or (colPickMode==1 and !data.containsKey('annexUrl'))"> <if test="(colPickMode==0 and data.containsKey('annexUrl')) or (colPickMode==1 and !data.containsKey('annexUrl'))">
a.annexUrl=#{data.annexUrl}, a.annexUrl=#{data.annexUrl},
</if> </if>
<if test="(colPickMode==0 and data.containsKey('watermarkUrl')) or (colPickMode==1 and !data.containsKey('watermarkUrl'))">
a.watermarkUrl=#{data.watermarkUrl},
</if>
</trim> </trim>
<trim suffixOverrides="where" suffix=""> <trim suffixOverrides="where" suffix="">
where where
...@@ -678,6 +685,13 @@ ...@@ -678,6 +685,13 @@
</if> </if>
</foreach> </foreach>
</trim> </trim>
<trim prefix="watermarkUrl=(case" suffix="ELSE watermarkUrl end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('watermarkUrl')) or (colPickMode==1 and !item.containsKey('watermarkUrl'))">
when a.id=#{item.id} then #{item.watermarkUrl}
</if>
</foreach>
</trim>
</trim> </trim>
where id in where id in
<foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")"> <foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")">
...@@ -1674,6 +1688,27 @@ ...@@ -1674,6 +1688,27 @@
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="conditionParamRef.containsKey('watermarkUrl')">
<if test="conditionParamRef.watermarkUrl != null and conditionParamRef.watermarkUrl != ''">
${_conditionType_} a.watermarkUrl like #{${_conditionParam_}.watermarkUrl}
</if>
<if test="conditionParamRef.watermarkUrl == null">
${_conditionType_} a.watermarkUrl is null
</if>
</if>
<if test="conditionParamRef.containsKey('watermarkUrlList') and conditionParamRef.watermarkUrlList.size() > 0">
${_conditionType_} a.watermarkUrl in
<foreach collection="conditionParamRef.watermarkUrlList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('watermarkUrlNotList') and conditionParamRef.watermarkUrlNotList.size() > 0">
${_conditionType_} a.watermarkUrl not in
<foreach collection="conditionParamRef.watermarkUrlNotList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
</sql> </sql>
<sql id="_orderCols_"> <sql id="_orderCols_">
<if test="orderColList != null and !orderColList.isEmpty()"> <if test="orderColList != null and !orderColList.isEmpty()">
...@@ -2041,6 +2076,11 @@ ...@@ -2041,6 +2076,11 @@
<if test='orderCol.annexUrl != null and "DESC".equalsIgnoreCase(orderCol.annexUrl)'>DESC</if> <if test='orderCol.annexUrl != null and "DESC".equalsIgnoreCase(orderCol.annexUrl)'>DESC</if>
, ,
</if> </if>
<if test="orderCol.containsKey('watermarkUrl')">
a.watermarkUrl
<if test='orderCol.watermarkUrl != null and "DESC".equalsIgnoreCase(orderCol.watermarkUrl)'>DESC</if>
,
</if>
</trim> </trim>
</if> </if>
......
import java.util.Arrays;
import java.util.Map;
public class ParamUtil {
public static String sort(Map<String, String> params, String[] args) {
Arrays.sort(args);
StringBuffer paramStr = new StringBuffer();
for (String s : args) {
if (paramStr.length() >= 1) {
paramStr.append("&");
}
paramStr.append(s).append("=").append(params.get(s));
}
return paramStr.toString();
}
}
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.Signature;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import javax.crypto.Cipher;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* RSA签名算法工具
*
* @author WuBin
*
*/
public class RsaUtil {
private static Logger logger = LoggerFactory.getLogger(RsaUtil.class);
/**
* RSA最大加密明文大小
*/
private static final int MAX_ENCRYPT_BLOCK = 117;
/**
* RSA最大解密密文大小
*/
private static final int MAX_DECRYPT_BLOCK = 128;
/**
* 转换私钥
*
* @param key
* 私钥字符
* @return 私钥
*/
public static PrivateKey parsePrivateKey(String key) {
try {
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(
Base64.decodeBase64(key));
KeyFactory kf = KeyFactory.getInstance("RSA");
return kf.generatePrivate(keySpec);
} catch (Exception e) {
throw new RuntimeException("转换私钥失败", e);
}
}
/**
* 转换私钥
*
* @param is
* 私钥文件流
* @return 私钥
*/
public static PrivateKey parsePrivateKey(InputStream is) {
try {
byte[] encodedKey = new byte[is.available()];
is.read(encodedKey);
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encodedKey);
KeyFactory kf = KeyFactory.getInstance("RSA");
return kf.generatePrivate(keySpec);
} catch (Exception e) {
throw new RuntimeException("转换私钥失败", e);
} finally {
try {
if (is != null) {
is.close();
}
} catch (IOException e) {
logger.error("关闭文件流失败", e);
}
}
}
/**
* 签名Sha1WithRSA
*
* @param privateKey
* 私钥
* @param data
* 待签名数据
* @return 签名数据
*/
public static byte[] sign(PrivateKey privateKey, byte[]... data) {
return sign(privateKey, "Sha1WithRSA", data);
}
/**
* 签名Sha256WithRSA
*
* @param privateKey
* 私钥
* @param data
* 待签名数据
* @return 签名数据
*/
public static byte[] sign256(PrivateKey privateKey, byte[]... data) {
return sign(privateKey, "Sha256WithRSA", data);
}
/**
* 签名
*
* @param privateKey
* 私钥
* @param algorithm
* 签名算法
* @param data
* 待签名数据
* @return 签名数据
*/
public static byte[] sign(PrivateKey privateKey, String algorithm,
byte[]... data) {
try {
Signature signObject = Signature.getInstance(algorithm);
signObject.initSign(privateKey);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (byte[] sub : data) {
if (sub != null) {
baos.write(sub);
}
}
signObject.update(baos.toByteArray());
return signObject.sign();
} catch (Exception e) {
throw new RuntimeException("签名失败", e);
}
}
/**
* 解密
*
* @param privateKey
* 私钥
* @param data
* 待解密数据
* @return 解密数据
*/
public static byte[] decrypt(PrivateKey privateKey, byte[]... data) {
try {
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.DECRYPT_MODE, privateKey);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (byte[] sub : data) {
if (sub != null) {
baos.write(sub);
}
}
byte[] encryptedData = baos.toByteArray();
int inputLen = baos.toByteArray().length;
ByteArrayOutputStream out = new ByteArrayOutputStream();
int offSet = 0;
byte[] cache;
int i = 0;
while (inputLen - offSet > 0) {
if (inputLen - offSet > MAX_DECRYPT_BLOCK) {
cache = cipher.doFinal(encryptedData, offSet,
MAX_DECRYPT_BLOCK);
} else {
cache = cipher.doFinal(encryptedData, offSet, inputLen
- offSet);
}
out.write(cache, 0, cache.length);
i++;
offSet = i * MAX_DECRYPT_BLOCK;
}
return out.toByteArray();
} catch (Exception e) {
throw new RuntimeException("解密失败", e);
}
}
/**
* 转换公钥
*
* @param key
* 公钥字符
* @return 公钥
*/
public static PublicKey parsePublicKey(String key) {
try {
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(
Base64.decodeBase64(key));
KeyFactory kf = KeyFactory.getInstance("RSA");
return kf.generatePublic(keySpec);
} catch (Exception e) {
throw new RuntimeException("转换公钥失败", e);
}
}
/**
* 验签Sha1WithRSA
*
* @param publicKey
* 公钥
* @param sign
* 签名
* @param data
* 待验签数据
* @return 是否通过
*/
public static boolean verify(PublicKey publicKey, byte[] sign,
byte[]... data) {
return verify(publicKey, "Sha1WithRSA", sign, data);
}
/**
* 验签Sha256WithRSA
*
* @param publicKey
* 公钥
* @param sign
* 签名
* @param data
* 待验签数据
* @return 是否通过
*/
public static boolean verify256(PublicKey publicKey, byte[] sign,
byte[]... data) {
return verify(publicKey, "Sha256WithRSA", sign, data);
}
/**
* 验签
*
* @param publicKey
* 公钥
* @param algorithm
* 签名算法
* @param sign
* 签名
* @param data
* 待验签数据
* @return 是否通过
*/
public static boolean verify(PublicKey publicKey, String algorithm,
byte[] sign, byte[]... data) {
try {
Signature signObject = Signature.getInstance(algorithm);
signObject.initVerify(publicKey);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (byte[] sub : data) {
if (sub != null) {
baos.write(sub);
}
}
signObject.update(baos.toByteArray());
return signObject.verify(sign);
} catch (Exception e) {
throw new RuntimeException("验签失败", e);
}
}
/**
* 加密
*
* @param publicKey
* 公钥
* @param data
* 待加密数据
* @return 加密数据
*/
public static byte[] encrypt(PublicKey publicKey, byte[]... data) {
try {
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (byte[] sub : data) {
if (sub != null) {
baos.write(sub);
}
}
byte[] originalData = baos.toByteArray();
int inputLen = baos.toByteArray().length;
ByteArrayOutputStream out = new ByteArrayOutputStream();
int offSet = 0;
byte[] cache;
int i = 0;
while (inputLen - offSet > 0) {
if (inputLen - offSet > MAX_ENCRYPT_BLOCK) {
cache = cipher.doFinal(originalData, offSet,
MAX_ENCRYPT_BLOCK);
} else {
cache = cipher.doFinal(originalData, offSet, inputLen
- offSet);
}
out.write(cache, 0, cache.length);
i++;
offSet = i * MAX_ENCRYPT_BLOCK;
}
return out.toByteArray();
} catch (Exception e) {
throw new RuntimeException("加密失败", e);
}
}
}
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
public class ZjptTest {
/**
*
* 接口访问地址
*/
public static final String URL= "http://103.203.218.240:8003/ScrsGgfwService/inf/api.do";
/**
* 编码格式
*/
public static final String ENCODING = "UTF-8";
/**
* 服务端公钥
*/
public static final String SERVER_PUBLICKEY="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC6Yp7i1otL0vowUTrFpCbrTXKy09L6zp4VpNWsCsU4daddfGzkCA5nr/7rt5to77qXx0cEGafqCMNHe9ru4cDjbmjq6MUFzlRB0ezI8RXs1MiewGh3nRPufdKid8uPzWGo4VAGZkv2keum+GT2W5OVBnaHiZMtLQiaSMXXHNwcawIDAQAB";
/**
* 客户端私钥
*/
public static final String CLIENT_PRIKEY = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAMC2J7I7udTnJdWwarWYpdG6BEVl8YV4iTmSKAjah0/673HtgXjzwJEf7gjVYE2Rf+fOTUX6zUQZXkI6hlt+B8GlgeJGFdMUcAAbqF5gqsB5X6/NBwq1SQF5mpTSeQSHRgMRnGAayCNWohgE9mnnyKcGYQK9iPoI71+MGHL34+x1AgMBAAECgYEAtspQ3uN+Ae76WTWMEhHnfwY1VOo8bACIEP6MUNGPNZLsmiDRBTwXtNAXhXN3dDwFmYd6jl01ZFm3qZQ/qvrhOOx4EMNgO6C7qUd4OhDtarEC0Brg5awjuMCDBd25t/cJg7GgFv5ccGYwz9K96AhCVj/Zsd55eXDH2TH+9baPpwECQQDfmgn1lzycwBaHEGJhLZ2wBVWkhMqZ/F0LPcjWVIwoook55ihaXqPw33GiF2JMUPfOSsfIRapXdUaXcdbaTXRBAkEA3KJSCurcBz0FzluQYFWsNZPJzuR724cAeNcSsQHsgQtRTnpEOlikj8xRxoEKdNdipPfiaF+kCpK4Z6z/lJgbNQJBANQPOObL2dYnbrYFWegj5OrtBD4VGjhT2MIyhGiQoqRfEZnxp8+c9goZP6GkX7tVBs+EqFhNibGMLbivZD6BOoECQGmV2JNW77MbFeM6WG5xsXb2YdZ763YUNjqeGljRJeBfjSp0QqB1eVNDoULQ0DM4PAHciuIOGw/gRRWAadMvs50CQQCCXRywZhSvVTuWnj6Wy3D77wac4ckLVahIMahNoy/UNqdoCEnO168C7m9BpwUjnb+ipGx6/nhY9BZAogfWygV1";
public static String HttpPostWithJson(String url, String json) {
String returnValue = "这是默认返回值,接口调用失败";
CloseableHttpClient httpClient = HttpClients.createDefault();
ResponseHandler<String> responseHandler = new BasicResponseHandler();
try{
//第一步:创建HttpClient对象
httpClient = HttpClients.createDefault();
//第二步:创建httpPost对象
HttpPost httpPost = new HttpPost(url);
//第三步:给httpPost设置JSON格式的参数
StringEntity requestEntity = new StringEntity(json,"utf-8");
requestEntity.setContentEncoding("UTF-8");
httpPost.setHeader("Content-type", "application/json");
httpPost.setEntity(requestEntity);
//第四步:发送HttpPost请求,获取返回值
returnValue = httpClient.execute(httpPost,responseHandler); //调接口获取返回值时,必须用此方法
}
catch(Exception e){
e.printStackTrace();
}finally {
try {
httpClient.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//第五步:处理返回值
return returnValue;
}
/**
*
* @Title: sentPOST
* @Description: 处理参数及发起请求
* @param @param method
* @param @param params
* @param @return 参数
* @return String 返回类型
* @throws
*/
public static String sentPOST(String method,String params){
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd/HHmmss/");
Map<String, String> map = new HashMap<String, String>();
//公共参数
map.put("sysCode", "CdsbPdjhXt"); //系统编号
map.put("channelName", "成都社保排队叫号系统"); //渠道
map.put("callCode", "I01046"); //系统代码
map.put("method", method); //方法
map.put("identityFlag", "3");
map.put("timestamp", sdf.format(new Date()));//时间格式"yyyyMMdd/HHmmss/"
map.put("params", params);
try {
//加签
String[] args = new String[] {"sysCode", "channelName", "method", "timestamp", "params", "identityFlag"};
String paramStr = ParamUtil.sort(map, args);
byte[] signByte = RsaUtil.sign(RsaUtil.parsePrivateKey(CLIENT_PRIKEY), paramStr.getBytes(ENCODING));
String signStr = Base64.encodeBase64String(signByte);
map.put("sign", signStr);
//转为json格式
//JSONObject jsonObject = JSONObject.(map);
//发起http请求
String returnValue = HttpPostWithJson(URL, JSONObject.toJSONString(map));
return returnValue;
}catch(Exception e ){
e.printStackTrace();
return null;
}
}
/**
*
* @Title: main
* @Description: test
* @param @param args
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
public static void main(String[] args) throws Exception {
//请求参数
Map<String, Object> map = new HashMap<String, Object>();
//接口参数
map.put("sfz","511181198903042414");
map.put("dwbm","1212");
JSONObject jsonObject = new JSONObject();
jsonObject.put("id","");
jsonObject.put("name","社保综合业务");
jsonObject.put("describe","社保综合业务,综合A,B业务");
map.put("type",jsonObject);
//JSONObject jsonObject = JSONObject.fromObject(map);
String p =JSONObject.toJSONString(map);
//参数加密
String encStr = Base64.encodeBase64String(RsaUtil.encrypt(RsaUtil.parsePublicKey(SERVER_PUBLICKEY), p.getBytes()));
System.out.println("加密后的字符串为:" + encStr);
String returnValue = sentPOST("接口名",encStr);
//返回数据
System.out.println(returnValue);
}
}
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"baseUrl": "http://127.0.0.1:17500/attendance" "baseUrl": "http://127.0.0.1:17500/attendance"
}, },
"test": { "test": {
"baseUrl": "http://192.168.0.250:11011/onecert" "baseUrl": "http://192.168.0.98:11011/onecert"
}, },
"test-remote": { "test-remote": {
"baseUrl": "http://8.136.255.30:11011/onecert" "baseUrl": "http://8.136.255.30:11011/onecert"
......
...@@ -43,3 +43,21 @@ POST {{baseUrl}}/param/interlist ...@@ -43,3 +43,21 @@ POST {{baseUrl}}/param/interlist
Content-Type: application/json Content-Type: application/json
{} {}
###获取行业树
GET {{baseUrl}}/certificate/industry/treeselect
Content-Type: application/json
{}
###获取参数列表
POST {{baseUrl}}/apply/log/interlist
Content-Type: application/json
{
"industryId": 18
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment