Commit 597cac39 authored by 赵啸非's avatar 赵啸非

添加水印图片

parent 5f8623d5
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.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.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;
@GetMapping("refreshWaterMark")
public Rest<Void> updateDevice() {
String WarterMark = GlobalSysInfo.getParamValue(Constant.Param_waterMark, "");
List<ApplyLogEntity> applyLogEntities = applyLogService.find(new ApplyLogQuery().watermarkUrlList(Arrays.asList("")));
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);
}
return Rest.ok();
}
public static void main(String[] args) {
}
}
......@@ -308,6 +308,7 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
recordDao.insert(recordEntity);
applyLogEntity.setRecordId(recordEntity.getId());
}
genWaterMark(applyLogEntity);
dao.insert(applyLogEntity);
if (is_record) {
ApplyLogEntity updata = new ApplyLogEntity();
......@@ -407,23 +408,8 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
recordDao.insert(recordEntity);
applyLogEntity.setRecordId(recordEntity.getId());
}
//生成水印图片
String WarterMark = GlobalSysInfo.getParamValue(Constant.Param_waterMark, "");
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);
}
genWaterMark(applyLogEntity);
dao.insert(applyLogEntity);
if (is_record) {
......@@ -443,6 +429,23 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
}
private void genWaterMark(ApplyLogEntity applyLogEntity) {
String WarterMark = GlobalSysInfo.getParamValue(Constant.Param_waterMark, "");
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);
}
}
private String preview(DocTemplateVO docTemplate, Context context, boolean hasPDF) {
String rootPath = this.filePath.endsWith("/") ? this.filePath : this.filePath + "/";
//转换表单参数为map集合
......
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