Commit 4db4908b authored by 赵啸非's avatar 赵啸非

添加水印图片

parent e360cee1
...@@ -86,4 +86,11 @@ ALTER TABLE mortals_xhx_certificate_child ...@@ -86,4 +86,11 @@ ALTER TABLE mortals_xhx_certificate_child
ALTER TABLE `mortals_xhx_apply_log` ALTER TABLE `mortals_xhx_apply_log`
ADD COLUMN `watermarkUrl` varchar(255) DEFAULT '' COMMENT '水印图片地址' ADD COLUMN `watermarkUrl` varchar(255) DEFAULT '' COMMENT '水印图片地址'
AFTER annexUrl ; AFTER annexUrl ;
\ No newline at end of file
ALTER TABLE `mortals_xhx_child_license`
ADD COLUMN `originalWaterMarkPath` varchar(255) DEFAULT '' COMMENT '水印图片地址',
ADD COLUMN `copyWaterMarkPath` varchar(255) DEFAULT '' COMMENT '水印图片地址'
AFTER copyFilePath ;
\ No newline at end of file
...@@ -6,12 +6,16 @@ import com.mortals.framework.common.Rest; ...@@ -6,12 +6,16 @@ import com.mortals.framework.common.Rest;
import com.mortals.xhx.base.system.upload.service.UploadService; import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.key.Constant; import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.utils.WatermarkImgUtils; import com.mortals.xhx.common.utils.WatermarkImgUtils;
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.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery; import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.record.model.ApplyLogEntity; import com.mortals.xhx.module.record.model.ApplyLogEntity;
import com.mortals.xhx.module.record.model.ApplyLogQuery; import com.mortals.xhx.module.record.model.ApplyLogQuery;
import com.mortals.xhx.module.record.service.ApplyLogService; import com.mortals.xhx.module.record.service.ApplyLogService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -31,6 +35,9 @@ public class TestSendMsgController { ...@@ -31,6 +35,9 @@ public class TestSendMsgController {
private ApplyLogService applyLogService; private ApplyLogService applyLogService;
@Autowired @Autowired
private UploadService uploadService; private UploadService uploadService;
@Autowired
private ChildLicenseService childLicenseService;
@GetMapping("refreshWaterMark") @GetMapping("refreshWaterMark")
public Rest<Void> updateDevice() { public Rest<Void> updateDevice() {
...@@ -38,7 +45,7 @@ public class TestSendMsgController { ...@@ -38,7 +45,7 @@ public class TestSendMsgController {
String WarterMark = GlobalSysInfo.getParamValue(Constant.Param_waterMark, ""); String WarterMark = GlobalSysInfo.getParamValue(Constant.Param_waterMark, "");
ApplyLogQuery applyLogQuery = new ApplyLogQuery(); ApplyLogQuery applyLogQuery = new ApplyLogQuery();
applyLogQuery.setAnnexUrlNotList(Arrays.asList("")); applyLogQuery.setAnnexUrlNotList(Arrays.asList(""));
List<ApplyLogEntity> applyLogEntities = applyLogService.find(applyLogQuery.watermarkUrlList(Arrays.asList(""))); List<ApplyLogEntity> applyLogEntities = applyLogService.find(applyLogQuery);
for (ApplyLogEntity applyLogEntity : applyLogEntities) { for (ApplyLogEntity applyLogEntity : applyLogEntities) {
if (!ObjectUtils.isEmpty(WarterMark)) { if (!ObjectUtils.isEmpty(WarterMark)) {
//生成水印图片 //生成水印图片
...@@ -58,6 +65,55 @@ public class TestSendMsgController { ...@@ -58,6 +65,55 @@ public class TestSendMsgController {
if (!ObjectUtils.isEmpty(applyLogEntities)) { if (!ObjectUtils.isEmpty(applyLogEntities)) {
applyLogService.update(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(); return Rest.ok();
} }
......
...@@ -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;
...@@ -28,12 +34,12 @@ import lombok.extern.slf4j.Slf4j; ...@@ -28,12 +34,12 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils; 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 {
...@@ -42,25 +48,29 @@ public class ChildLicenseServiceImpl extends AbstractCRUDServiceImpl<ChildLicens ...@@ -42,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());
...@@ -70,10 +80,10 @@ public class ChildLicenseServiceImpl extends AbstractCRUDServiceImpl<ChildLicens ...@@ -70,10 +80,10 @@ 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; if (ObjectUtils.isEmpty(documentIdList)) return result;
CertificateDocumentQuery certificateDocumentQuery = new CertificateDocumentQuery(); CertificateDocumentQuery certificateDocumentQuery = new CertificateDocumentQuery();
certificateDocumentQuery.setIdList(documentIdList); certificateDocumentQuery.setIdList(documentIdList);
List<CertificateDocumentEntity> documentEntityList = certificateDocumentService.find(certificateDocumentQuery); List<CertificateDocumentEntity> documentEntityList = certificateDocumentService.find(certificateDocumentQuery);
...@@ -119,6 +129,34 @@ public class ChildLicenseServiceImpl extends AbstractCRUDServiceImpl<ChildLicens ...@@ -119,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
...@@ -119,6 +119,8 @@ public class ChildLicenseController extends BaseCRUDJsonBodyMappingController<Ch ...@@ -119,6 +119,8 @@ public class ChildLicenseController extends BaseCRUDJsonBodyMappingController<Ch
childLicenseEntity.setReportUserName(this.getContext().getUser().getRealName()); childLicenseEntity.setReportUserName(this.getContext().getUser().getRealName());
childLicenseEntity.setReportTime(new Date()); childLicenseEntity.setReportTime(new Date());
childLicenseEntity.setProcessStatus(ProcessStatusEnum.已处理.getValue()); childLicenseEntity.setProcessStatus(ProcessStatusEnum.已处理.getValue());
childLicenseEntity.setFormContent("");
childLicenseEntity.setFormStyleContent("");
this.service.update(childLicenseEntity, getContext()); this.service.update(childLicenseEntity, getContext());
......
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