人员状态变更、专利墙接口开发

dev
IT-xiaoXiong 2021-11-29 10:15:16 +08:00
parent 8ac1b5735b
commit cd579ffc21
11 changed files with 524 additions and 82 deletions

View File

@ -677,7 +677,7 @@ public class Util extends weaver.general.Util {
if (!Character.isUpperCase(chars[0])) { if (!Character.isUpperCase(chars[0])) {
chars[0] -= 32; chars[0] -= 32;
} }
className = String.valueOf(chars) + "DTO"; className = String.valueOf(chars) + "PO";
toStringBuilder.append("\tpublic String toString() {\n\t\treturn \"") toStringBuilder.append("\tpublic String toString() {\n\t\treturn \"")
.append(className) .append(className)
.append("{\" +\n"); .append("{\" +\n");

View File

@ -1,5 +1,7 @@
package aiyh.utils.fileUtil; package aiyh.utils.fileUtil;
import aiyh.utils.zwl.common.ToolUtil;
import sun.font.FontDesignMetrics;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.file.FileUpload; import weaver.file.FileUpload;
import weaver.file.ImageFileManager; import weaver.file.ImageFileManager;
@ -25,6 +27,8 @@ import java.util.UUID;
public class WritWatermark { public class WritWatermark {
private static final ToolUtil toolUtil = new ToolUtil();
/** /**
* id * id
* *
@ -46,7 +50,7 @@ public class WritWatermark {
ImageFileManager imageFileManager = new ImageFileManager(); ImageFileManager imageFileManager = new ImageFileManager();
// 通过文件id获取输入流 // 通过文件id获取输入流
InputStream inputStreamById = ImageFileManager.getInputStreamById(imageId); InputStream inputStreamById = ImageFileManager.getInputStreamById(imageId);
if(inputStreamById == null){ if (inputStreamById == null) {
throw new RuntimeException("Failed to obtain the image to which a watermark is to be added. " + throw new RuntimeException("Failed to obtain the image to which a watermark is to be added. " +
"Check whether the file exists in the system and ensure that the file is in the image format."); "Check whether the file exists in the system and ensure that the file is in the image format.");
} }
@ -54,7 +58,6 @@ public class WritWatermark {
Image image = ImageIO.read(inputStreamById); Image image = ImageIO.read(inputStreamById);
int width = image.getWidth(null); int width = image.getWidth(null);
int height = image.getHeight(null); int height = image.getHeight(null);
double lineHeight = fontSize * lineSpacing;
// 创建bufferedImage // 创建bufferedImage
BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = bufferedImage.createGraphics(); Graphics2D graphics = bufferedImage.createGraphics();
@ -62,17 +65,6 @@ public class WritWatermark {
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR); RenderingHints.VALUE_INTERPOLATION_BILINEAR);
graphics.drawImage(image, 0, 0, width, height, null); graphics.drawImage(image, 0, 0, width, height, null);
// 对字体进行限制
if(fontSize * pressText.length() >= width){
fontSize = (int) (width / (pressText.length() + 5));
}
Font font = new Font(fontName, fontStyle, fontSize);
graphics.setColor(color);
graphics.setFont(font);
// 设置旋转角度
graphics.rotate(Math.toRadians(degree), (double) width / 2, (double) height / 2);
// 设置透明度
graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
String[] pressTexts = pressText.split("\n"); String[] pressTexts = pressText.split("\n");
String maxStr = ""; String maxStr = "";
int max = 0; int max = 0;
@ -83,6 +75,25 @@ public class WritWatermark {
maxStr = press; maxStr = press;
} }
} }
String message = maxStr;
Font defaultFont = new Font(fontName,fontStyle,fontSize);
int wordWidth = getWordWidth(defaultFont, message);
// 对字体进行限制
if (wordWidth >= Math.min(width, height)) {
fontSize = (int) (Math.min(width, height) / (pressText.length() + 6));
}
toolUtil.writeDebuggerLog(String.format(
"图片宽度{%s},图片高度{%s},文字宽度{%s},文字{%s},字体大小{%s},字体数量{%s}"
,width,height,wordWidth,message,fontSize,message.length()));
double lineHeight = fontSize * lineSpacing;
Font font = new Font(fontName, fontStyle, fontSize);
graphics.setColor(color);
graphics.setFont(font);
// 设置旋转角度
graphics.rotate(Math.toRadians(degree), (double) width / 2, (double) height / 2);
// 设置透明度
graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
int X; int X;
int Y; int Y;
int fontWidth = graphics.getFontMetrics(graphics.getFont()).charsWidth(maxStr.toCharArray(), 0, max); int fontWidth = graphics.getFontMetrics(graphics.getFont()).charsWidth(maxStr.toCharArray(), 0, max);
@ -188,7 +199,7 @@ public class WritWatermark {
ImageFileManager imageFileManager = new ImageFileManager(); ImageFileManager imageFileManager = new ImageFileManager();
// 通过文件id获取输入流 // 通过文件id获取输入流
InputStream inputStreamById = ImageFileManager.getInputStreamById(imageId); InputStream inputStreamById = ImageFileManager.getInputStreamById(imageId);
if(inputStreamById == null){ if (inputStreamById == null) {
throw new RuntimeException("Failed to obtain the image to which a watermark is to be added. " + throw new RuntimeException("Failed to obtain the image to which a watermark is to be added. " +
"Check whether the file exists in the system and ensure that the file is in the image format."); "Check whether the file exists in the system and ensure that the file is in the image format.");
} }
@ -209,7 +220,7 @@ public class WritWatermark {
graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha)); graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
// 获取水印图片 // 获取水印图片
InputStream inputStreamImgIcon = ImageFileManager.getInputStreamById(picId); InputStream inputStreamImgIcon = ImageFileManager.getInputStreamById(picId);
if(inputStreamImgIcon == null){ if (inputStreamImgIcon == null) {
throw new RuntimeException("The obtained watermark logo image is empty"); throw new RuntimeException("The obtained watermark logo image is empty");
} }
Image logoImg = ImageIO.read(inputStreamImgIcon); Image logoImg = ImageIO.read(inputStreamImgIcon);
@ -314,7 +325,7 @@ public class WritWatermark {
ImageFileManager imageFileManager = new ImageFileManager(); ImageFileManager imageFileManager = new ImageFileManager();
// 通过文件id获取输入流 // 通过文件id获取输入流
InputStream inputStreamById = ImageFileManager.getInputStreamById(imageId); InputStream inputStreamById = ImageFileManager.getInputStreamById(imageId);
if(inputStreamById == null){ if (inputStreamById == null) {
throw new RuntimeException("Failed to obtain the image to which a watermark is to be added. " + throw new RuntimeException("Failed to obtain the image to which a watermark is to be added. " +
"Check whether the file exists in the system and ensure that the file is in the image format."); "Check whether the file exists in the system and ensure that the file is in the image format.");
} }
@ -333,7 +344,7 @@ public class WritWatermark {
graphics.rotate(Math.toRadians(degree), (double) width / 2, (double) height / 2); graphics.rotate(Math.toRadians(degree), (double) width / 2, (double) height / 2);
// 设置透明度 // 设置透明度
graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha)); graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
if(logoInput == null){ if (logoInput == null) {
throw new RuntimeException("The obtained watermark logo image is empty"); throw new RuntimeException("The obtained watermark logo image is empty");
} }
// 获取水印图片 // 获取水印图片
@ -424,7 +435,6 @@ public class WritWatermark {
} }
/** /**
*
* @param imageId id * @param imageId id
* @param pressText * @param pressText
* @param color * @param color
@ -445,7 +455,7 @@ public class WritWatermark {
ImageFileManager imageFileManager = new ImageFileManager(); ImageFileManager imageFileManager = new ImageFileManager();
// 通过文件id获取输入流 // 通过文件id获取输入流
InputStream inputStreamById = ImageFileManager.getInputStreamById(imageId); InputStream inputStreamById = ImageFileManager.getInputStreamById(imageId);
if(inputStreamById == null){ if (inputStreamById == null) {
throw new RuntimeException("Failed to obtain the image to which a watermark is to be added. " + throw new RuntimeException("Failed to obtain the image to which a watermark is to be added. " +
"Check whether the file exists in the system and ensure that the file is in the image format."); "Check whether the file exists in the system and ensure that the file is in the image format.");
} }
@ -484,26 +494,26 @@ public class WritWatermark {
int fontsHeight = (int) Math.round(lineHeight) * pressTexts.length; int fontsHeight = (int) Math.round(lineHeight) * pressTexts.length;
int mustX = fontWidth; int mustX = fontWidth;
int mustY = fontsHeight; int mustY = fontsHeight;
int start = - (width + height); int start = -(width + height);
int end = width + height; int end = width + height;
X = start; X = start;
Y = start; Y = start;
int random = 0; int random = 0;
// 循环Y每次偏移防止重叠的最小偏移量加上自定义的偏移量 // 循环Y每次偏移防止重叠的最小偏移量加上自定义的偏移量
for (; Y <= end; Y = Y + moveY + mustY ){ for (; Y <= end; Y = Y + moveY + mustY) {
// 循环X,每次偏移防止重叠的最小偏移量加上自定义偏移量 // 循环X,每次偏移防止重叠的最小偏移量加上自定义偏移量
for (; X <= end; X = X + moveX + mustX){ for (; X <= end; X = X + moveX + mustX) {
for (int i = 0; i < pressTexts.length; i ++){ for (int i = 0; i < pressTexts.length; i++) {
// 防止重叠对Y做文字偏移 // 防止重叠对Y做文字偏移
graphics.drawString(pressTexts[i], X + random, Y + (int) Math.ceil(lineHeight) * (i + 1) ); graphics.drawString(pressTexts[i], X + random, Y + (int) Math.ceil(lineHeight) * (i + 1));
} }
} }
X = start; X = start;
if(random == 0){ if (random == 0) {
random = - randomX; random = -randomX;
}else { } else {
random = 0; random = 0;
} }
} }
@ -562,7 +572,6 @@ public class WritWatermark {
} }
/** /**
*
* @param imageId id * @param imageId id
* @param picId id * @param picId id
* @param degree * @param degree
@ -578,7 +587,7 @@ public class WritWatermark {
ImageFileManager imageFileManager = new ImageFileManager(); ImageFileManager imageFileManager = new ImageFileManager();
// 通过文件id获取输入流 // 通过文件id获取输入流
InputStream inputStreamById = ImageFileManager.getInputStreamById(imageId); InputStream inputStreamById = ImageFileManager.getInputStreamById(imageId);
if(inputStreamById == null){ if (inputStreamById == null) {
throw new RuntimeException("Failed to obtain the image to which a watermark is to be added. " + throw new RuntimeException("Failed to obtain the image to which a watermark is to be added. " +
"Check whether the file exists in the system and ensure that the file is in the image format."); "Check whether the file exists in the system and ensure that the file is in the image format.");
} }
@ -599,7 +608,7 @@ public class WritWatermark {
graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha)); graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
// 获取水印图片 // 获取水印图片
InputStream inputStreamImgIcon = ImageFileManager.getInputStreamById(picId); InputStream inputStreamImgIcon = ImageFileManager.getInputStreamById(picId);
if(inputStreamImgIcon == null){ if (inputStreamImgIcon == null) {
throw new RuntimeException("The obtained watermark logo image is empty"); throw new RuntimeException("The obtained watermark logo image is empty");
} }
ImageIcon logoImgIcon = new ImageIcon(ImageIO.read(inputStreamImgIcon)); ImageIcon logoImgIcon = new ImageIcon(ImageIO.read(inputStreamImgIcon));
@ -610,22 +619,22 @@ public class WritWatermark {
int Y; int Y;
int mustX = logoWidth; int mustX = logoWidth;
int mustY = logoHeight; int mustY = logoHeight;
int start = - (width + height); int start = -(width + height);
int end = width + height; int end = width + height;
X = start; X = start;
Y = start; Y = start;
int random = 0; int random = 0;
// 循环Y每次偏移防止重叠的最小偏移量加上自定义的偏移量 // 循环Y每次偏移防止重叠的最小偏移量加上自定义的偏移量
for (; Y <= end; Y = Y + moveY + mustY ){ for (; Y <= end; Y = Y + moveY + mustY) {
// 循环X,每次偏移防止重叠的最小偏移量加上自定义偏移量 // 循环X,每次偏移防止重叠的最小偏移量加上自定义偏移量
for (; X <= end; X = X + moveX + mustX){ for (; X <= end; X = X + moveX + mustX) {
graphics.drawImage(logoImg, X + random, Y, null); graphics.drawImage(logoImg, X + random, Y, null);
} }
X = start; X = start;
if(random == 0){ if (random == 0) {
random = - randomX; random = -randomX;
}else { } else {
random = 0; random = 0;
} }
} }
@ -684,7 +693,6 @@ public class WritWatermark {
/** /**
*
* @param imageId id * @param imageId id
* @param logoInput * @param logoInput
* @param degree * @param degree
@ -700,7 +708,7 @@ public class WritWatermark {
ImageFileManager imageFileManager = new ImageFileManager(); ImageFileManager imageFileManager = new ImageFileManager();
// 通过文件id获取输入流 // 通过文件id获取输入流
InputStream inputStreamById = ImageFileManager.getInputStreamById(imageId); InputStream inputStreamById = ImageFileManager.getInputStreamById(imageId);
if(inputStreamById == null){ if (inputStreamById == null) {
throw new RuntimeException("Failed to obtain the image to which a watermark is to be added. " + throw new RuntimeException("Failed to obtain the image to which a watermark is to be added. " +
"Check whether the file exists in the system and ensure that the file is in the image format."); "Check whether the file exists in the system and ensure that the file is in the image format.");
} }
@ -719,7 +727,7 @@ public class WritWatermark {
graphics.rotate(Math.toRadians(degree), (double) width / 2, (double) height / 2); graphics.rotate(Math.toRadians(degree), (double) width / 2, (double) height / 2);
// 设置透明度 // 设置透明度
graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha)); graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
if(logoInput == null){ if (logoInput == null) {
throw new RuntimeException("The obtained watermark logo image is empty"); throw new RuntimeException("The obtained watermark logo image is empty");
} }
// 获取水印图片 // 获取水印图片
@ -731,22 +739,22 @@ public class WritWatermark {
int Y; int Y;
int mustX = logoWidth; int mustX = logoWidth;
int mustY = logoHeight; int mustY = logoHeight;
int start = - (width + height); int start = -(width + height);
int end = width + height; int end = width + height;
X = start; X = start;
Y = start; Y = start;
int random = 0; int random = 0;
// 循环Y每次偏移防止重叠的最小偏移量加上自定义的偏移量 // 循环Y每次偏移防止重叠的最小偏移量加上自定义的偏移量
for (; Y <= end; Y = Y + moveY + mustY ){ for (; Y <= end; Y = Y + moveY + mustY) {
// 循环X,每次偏移防止重叠的最小偏移量加上自定义偏移量 // 循环X,每次偏移防止重叠的最小偏移量加上自定义偏移量
for (; X <= end; X = X + moveX + mustX){ for (; X <= end; X = X + moveX + mustX) {
graphics.drawImage(logoImg, X + random, Y, null); graphics.drawImage(logoImg, X + random, Y, null);
} }
X = start; X = start;
if(random == 0){ if (random == 0) {
random = - randomX; random = -randomX;
}else { } else {
random = 0; random = 0;
} }
} }
@ -803,5 +811,14 @@ public class WritWatermark {
return i; return i;
} }
public static int getWordWidth(Font font, String content) {
FontDesignMetrics metrics = FontDesignMetrics.getMetrics(font);
int width = 0;
for (int i = 0; i < content.length(); i++) {
width += metrics.charWidth(content.charAt(i));
}
return width;
}
} }

View File

@ -0,0 +1,184 @@
package com.api.aiy_changeStatus.Impl;
import aiyh.utils.Util;
import aiyh.utils.zwl.common.ToolUtil;
import com.api.aiy_changeStatus.Impl.Util.ChangeStatusUtil;
import com.weaverboot.frame.ioc.anno.classAnno.WeaIocReplaceComponent;
import com.weaverboot.frame.ioc.anno.methodAnno.WeaReplaceAfter;
import com.weaverboot.frame.ioc.anno.methodAnno.WeaReplaceBefore;
import com.weaverboot.frame.ioc.handler.replace.weaReplaceParam.impl.WeaAfterReplaceParam;
import com.weaverboot.frame.ioc.handler.replace.weaReplaceParam.impl.WeaBeforeReplaceParam;
import org.h2.util.StringUtils;
import weaver.conn.RecordSet;
import java.util.Map;
/**
* @author EBU7-dev1-ayh
* @create 2021/11/27 0027 13:02
*
*/
@WeaIocReplaceComponent("ChangeStatusService")
public class ChangeStatusImpl {
/*
+++++++++++++++++++++++++++++++++++++++++++Start+++++++++++++++++++++++++++++
*/
@WeaReplaceBefore(value = "/api/hrm/finance/save", order = 1, description = "工资福利修改")
public void financeBefore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.changeHrmResourceStatus(weaBeforeReplaceParam, "id", 2);
}
@WeaReplaceBefore(value = "/api/hrm/systeminfo/save", order = 1, description = "系统信息修改")
public void systeminfoBefore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.changeHrmResourceStatus(weaBeforeReplaceParam, "id", 2);
}
@WeaReplaceBefore(value = "/api/hrm/resource/editResource", order = 1, description = "人员信息修改")
public void editResourceBefore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.changeHrmResourceStatus(weaBeforeReplaceParam, "id", 2);
}
/**
*
*
* @param weaBeforeReplaceParam
*/
@WeaReplaceBefore(value = "/api/hrm/batchMaintenanceAdjustEdit/resource/saveBatch", order = 1, description = "批量修改人员数据")
public void saveBatchBefore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.batchChangeHrmResourceStatus(weaBeforeReplaceParam, "id", 2);
}
@WeaReplaceBefore(value = "/api/hrm/batchMaintenanceAdjustEdit/saveBatchManagerid", order = 1, description = "批量修改直接上级")
public void saveBatchManageridBfore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.changeHrmResourceStatusByIds(weaBeforeReplaceParam, "ids", 2);
}
@WeaReplaceBefore(value = "/api/hrm/batchMaintenanceAdjustEdit/saveBatchJobtitle", order = 1, description = "批量调整职位")
public void saveBatchJobtitleBfore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.changeHrmResourceStatusByIds(weaBeforeReplaceParam, "ids", 2);
}
@WeaReplaceBefore(value = "/api/hrm/batchMaintenanceAdjustEdit/saveBatchResourceDeptid", order = 1, description = "批量调整部门")
public void saveBatchResourceDeptidBfore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.changeHrmResourceStatusByIds(weaBeforeReplaceParam, "ids", 2);
}
@WeaReplaceBefore(value = "/api/hrm/batchMaintenanceAdjustEdit/saveBatchAccounttype", order = 1, description = "批量修改主次账号")
public void saveBatchAccounttypeBfore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.changeHrmResourceStatusByIds(weaBeforeReplaceParam, "ids", 2);
}
@WeaReplaceBefore(value = "/api/hrm/batchMaintenanceAdjustEdit/saveBatchPassword", order = 1, description = "批量修改密码")
public void saveBatchPasswordBfore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.changeHrmResourceStatusByIds(weaBeforeReplaceParam, "ids", 2);
}
@WeaReplaceBefore(value = "/api/hrm/batchMaintenanceAdjustEdit/saveBatchDefaultPwd", order = 1, description = "批量重置密码")
public void saveBatchDefaultPwdBfore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.changeHrmResourceStatusByIds(weaBeforeReplaceParam, "resourceIds", 2);
}
@WeaReplaceBefore(value = "/api/hrm/statechange/saveHrmRedeploy", order = 1, description = "人员调动")
public void saveHrmRedeployBfore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.changeHrmResourceStatusByIds(weaBeforeReplaceParam, "tempresourceid", 2);
}
@WeaReplaceBefore(value = "/api/hrm/statechange/saveHrmExtend", order = 1, description = "人员续签")
public void saveHrmExtendBfore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.changeHrmResourceStatusByIds(weaBeforeReplaceParam, "tempresourceid", 2);
}
@WeaReplaceBefore(value = "/api/hrm/statechange/saveHrmHire", order = 1, description = "人员转正")
public void saveHrmHireBfore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.changeHrmResourceStatusByIds(weaBeforeReplaceParam, "tempresourceid", 2);
}
/* @WeaReplaceBefore(value = "/api/hrm/batchMaintenanceAdjustEdit/saveBatchUnlockStatus", order = 1, description = "批量解锁人员")
public void saveBatchUnlockStatusBfore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.changeHrmResourceStatusByIds(weaBeforeReplaceParam, "resourceIds", 2);
}*/
/*
+++++++++++++++++++++++++++++++++++++++++++END+++++++++++++++++++++++++++++
*/
/*
+++++++++++++++++++++++++++++++++++++++++++Start+++++++++++++++++++++++++++++
*/
@WeaReplaceBefore(value = "/api/hrm/statechange/saveHrmReHire", order = 1, description = "人员返聘")
public void saveHrmReHireBefore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.changeHrmResourceStatus(weaBeforeReplaceParam, "tempresourceid", 1);
}
@WeaReplaceAfter(value = "/api/hrm/resource/add/save", order = 1, description = "人员添加")
public String addResourceAfter(WeaAfterReplaceParam weaAfterReplaceParam) {
Map<String, Object> paramMap = weaAfterReplaceParam.getParamMap();
String loginId = Util.null2String(paramMap.get("loginid"));
String lastName = Util.null2String(paramMap.get("lastname"));
ToolUtil toolUtil = new ToolUtil();
toolUtil.writeErrorLog(weaAfterReplaceParam.getParamMap().toString());
toolUtil.writeErrorLog(loginId);
toolUtil.writeErrorLog(lastName);
if (StringUtils.isNullOrEmpty(loginId)) {
// 没有登录id
if (!StringUtils.isNullOrEmpty(lastName)) {
// 查询该名称的最后一名
String query = "select id from hrmresource where lastname = ? ORDER BY id desc limit 1";
RecordSet rs = new RecordSet();
rs.executeQuery(query, lastName);
if (rs.next()) {
toolUtil.writeErrorLog(rs.getString(1));
ChangeStatusUtil.changeStatus(rs.getString(1), 1);
}
}
} else {
String query = "select id from hrmresource where loginid = ? ";
RecordSet rs = new RecordSet();
rs.executeQuery(query, loginId);
if (rs.next()) {
toolUtil.writeErrorLog(rs.getString(1));
ChangeStatusUtil.changeStatus(rs.getString(1), 1);
}
}
return weaAfterReplaceParam.getData();
}
/*
+++++++++++++++++++++++++++++++++++++++++++END+++++++++++++++++++++++++++++
*/
/*
+++++++++++++++++++++++++++++++++++++++++++Start+++++++++++++++++++++++++++++
*/
@WeaReplaceBefore(value = "/api/hrm/statechange/saveHrmDismiss", order = 1, description = "人员离职")
public void saveHrmDismissBefore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.changeHrmResourceStatus(weaBeforeReplaceParam, "tempresourceid", 3);
}
@WeaReplaceBefore(value = "/api/hrm/statechange/saveHrmFire", order = 1, description = "人员解聘")
public void saveHrmFireBefore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.changeHrmResourceStatus(weaBeforeReplaceParam, "tempresourceid", 3);
}
/*
@WeaReplaceBefore(value = "/api/hrm/statechange/saveHrmRetire", order = 1, description = "人员退修")
public void saveHrmRetireBefore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
ChangeStatusUtil.changeHrmResourceStatus(weaBeforeReplaceParam, "tempresourceid", 3);
}*/
/*
+++++++++++++++++++++++++++++++++++++++++++END+++++++++++++++++++++++++++++
*/
}

View File

@ -0,0 +1,88 @@
package com.api.aiy_changeStatus.Impl.Util;
import aiyh.utils.Util;
import aiyh.utils.zwl.common.ToolUtil;
import com.alibaba.fastjson.JSON;
import com.weaverboot.frame.ioc.handler.replace.weaReplaceParam.impl.WeaBeforeReplaceParam;
import org.h2.util.StringUtils;
import weaver.conn.RecordSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author EBU7-dev1-ayh
* @create 2021/11/27 0027 13:28
* util
*/
// TODO 去除日志文件打印相关
public class ChangeStatusUtil {
private final static ToolUtil TOOL_UTIL = new ToolUtil();
private final static RecordSet rs = new RecordSet();
public static void changeHrmResourceStatus(WeaBeforeReplaceParam weaBeforeReplaceParam, String key, int status) {
String apiUrl = weaBeforeReplaceParam.getApiUrl();
Map<String, Object> paramMap = weaBeforeReplaceParam.getParamMap();
String id = Util.null2String(paramMap.get(key));
if (!StringUtils.isNullOrEmpty(id)) {
ChangeStatusUtil.changeStatus(id, status);
}
TOOL_UTIL.writeDebuggerLog(String.format("进入拦截请求方法获取到的api{%s},请求参数{%s}", apiUrl, JSON.toJSONString(paramMap)));
}
public static void changeHrmResourceStatusByIds(WeaBeforeReplaceParam weaBeforeReplaceParam, String key, int status) {
String apiUrl = weaBeforeReplaceParam.getApiUrl();
Map<String, Object> paramMap = weaBeforeReplaceParam.getParamMap();
String id = Util.null2String(paramMap.get(key));
if (!StringUtils.isNullOrEmpty(id)) {
ChangeStatusUtil.changeStatusByIds(id, status);
}
TOOL_UTIL.writeDebuggerLog(String.format("进入拦截请求方法获取到的api{%s},请求参数{%s}", apiUrl, JSON.toJSONString(paramMap)));
}
public static void batchChangeHrmResourceStatus(WeaBeforeReplaceParam weaBeforeReplaceParam, String key, int status) {
String apiUrl = weaBeforeReplaceParam.getApiUrl();
Map<String, Object> paramMap = weaBeforeReplaceParam.getParamMap();
List<Map<String, Object>> datas = (List<Map<String, Object>>) paramMap.get("datas");
if (datas == null || datas.isEmpty()) {
return;
}
List<String> ids = new ArrayList<>();
for (Map<String, Object> data : datas) {
String id = Util.null2String(data.get(key));
if (!StringUtils.isNullOrEmpty(id)) {
ids.add(id);
}
}
if (!ids.isEmpty()) {
ChangeStatusUtil.changeStatus(ids, status);
}
TOOL_UTIL.writeDebuggerLog(String.format("进入拦截请求方法获取到的api{%s},请求参数{%s}", apiUrl, JSON.toJSONString(paramMap)));
}
public static boolean changeStatus(List<String> ids, int status) {
String sql = "update hrmresource set changestatus = ? where id in ( " + String.join(",", ids) + ")";
TOOL_UTIL.writeDebuggerLog(sql + " ---------------> " + status);
return rs.executeUpdate(sql, status);
}
public static boolean changeStatusByIds(String ids, int status) {
String sql = "update hrmresource set changestatus = ? where id in ( " + ids + ")";
TOOL_UTIL.writeDebuggerLog(sql + " ---------------> " + status);
return rs.executeUpdate(sql, status);
}
public static boolean changeStatus(String id, int status) {
String sql = "update hrmresource set changestatus = ? where id = ?";
TOOL_UTIL.writeDebuggerLog(sql + " ---------------> " + id + "," + status);
return rs.executeUpdate(sql, status, id);
}
}

View File

@ -306,6 +306,7 @@ public class WorkflowQueueService {
int id = rs.getInt(1); int id = rs.getInt(1);
int newId; int newId;
try { try {
toolUtil.writeDebuggerLog("开始添加水印,传递字体大小!");
newId = WritWatermark.addTextWatermarkById(id, pressText, color, fontName, Font.PLAIN, fontSize newId = WritWatermark.addTextWatermarkById(id, pressText, color, fontName, Font.PLAIN, fontSize
, new WatermarkPoint(WatermarkPointEnum.RIGHT_BOTTOM), 0, 1, 1.3); , new WatermarkPoint(WatermarkPointEnum.RIGHT_BOTTOM), 0, 1, 1.3);
} catch (IOException e) { } catch (IOException e) {
@ -319,7 +320,7 @@ public class WorkflowQueueService {
index++; index++;
} }
//复制原图的权限信息等 //复制原图的权限信息等
// 复制原来的文件信息,并将现有的信息进行绑定 //复制原来的文件信息,并将现有的信息进行绑定
DocManager docManager = new DocManager(); DocManager docManager = new DocManager();
String[] picIdStrArr = fileIds.split(","); String[] picIdStrArr = fileIds.split(",");
String[] newImgArr = newIds.toString().split(","); String[] newImgArr = newIds.toString().split(",");
@ -356,18 +357,34 @@ public class WorkflowQueueService {
String fieldName = param.get("fieldName"); String fieldName = param.get("fieldName");
String tableName = param.get("tableName"); String tableName = param.get("tableName");
String isWrite = param.get("isWrite"); String isWrite = param.get("isWrite");
String isAppend = param.get("isAppend");
// String sourceField = param.get("sourceField"); // String sourceField = param.get("sourceField");
String requestId = param.get("requestId"); String requestId = param.get("requestId");
if ("true".equals(isWrite)) { if ("true".equals(isWrite)) {
if ("true".equals(isAppend)) {
// // 查询原字段是否存在图片
String queryStr = "";
try {
queryStr = "select " + fieldName + " from " + tableName + " where requestid = ?";
rs.executeQuery(queryStr, requestId);
rs.next();
String oldImg = Util.null2String(rs.getString(1));
if (!StringUtils.isNullOrEmpty(oldImg)) {
newDocIds.append(",").append(oldImg);
}
}catch (Exception e){
toolUtil.writeErrorLog("查询错误:" + queryStr);
}
}
if ("0".equals(isSaveResource)) { if ("0".equals(isSaveResource)) {
// 不保存原来的图片 // 不保存原来的图片
String update = "update " + String update = "update " +
tableName + tableName +
" set " + " set " +
fieldName + fieldName +
" = " + " = '" +
newDocIds + newDocIds +
" where " + "' where " +
" requestid = ?"; " requestid = ?";
rs.executeUpdate(update, requestId); rs.executeUpdate(update, requestId);
} else { } else {
@ -375,17 +392,18 @@ public class WorkflowQueueService {
tableName + tableName +
" set " + " set " +
fieldName + fieldName +
" = " + " = '" +
newDocIds + newDocIds +
" , " + "' , " +
sourceField + sourceField +
" = " + " = '" +
fileIds + fileIds +
" where " + "' where " +
" requestid = ?"; " requestid = ?";
rs.executeUpdate(update, requestId); rs.executeUpdate(update, requestId);
} }
} }
// 查询新文件信息 // 查询新文件信息
String listType = Util.null2String(String.valueOf(param.get("listType")), "list"); String listType = Util.null2String(String.valueOf(param.get("listType")), "list");
int requestid = Util.getIntValue(Util.null2String(String.valueOf(param.get("requestid"))), -1); int requestid = Util.getIntValue(Util.null2String(String.valueOf(param.get("requestid"))), -1);

View File

@ -1,6 +1,7 @@
package com.api.aiyh_pcn.patentWall.controller; package com.api.aiyh_pcn.patentWall.controller;
import aiyh.utils.ApiResult; import aiyh.utils.ApiResult;
import com.api.aiyh_pcn.patentWall.dto.FilterWhere;
import com.api.aiyh_pcn.patentWall.service.PatentWallService; import com.api.aiyh_pcn.patentWall.service.PatentWallService;
import com.api.aiyh_pcn.patentWall.vo.PatentVO; import com.api.aiyh_pcn.patentWall.vo.PatentVO;
import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.parameters.RequestBody;
@ -24,8 +25,8 @@ public class PatentWallController {
@Path("/getList") @Path("/getList")
@POST @POST
public String getPatentList(@RequestBody Map<String,Object> map){ public String getPatentList(@RequestBody List<FilterWhere> filterWheres){
List<PatentVO> result = patentWallService.getList(map); List<PatentVO> result = patentWallService.getList(filterWheres);
return ApiResult.success(result); return ApiResult.success(result);
} }

View File

@ -1,7 +1,12 @@
package com.api.aiyh_pcn.patentWall.dao; package com.api.aiyh_pcn.patentWall.dao;
import aiyh.utils.Util;
import aiyh.utils.zwl.common.ToolUtil;
import com.api.aiyh_pcn.patentWall.dto.FilterWhere;
import com.api.aiyh_pcn.patentWall.vo.PatentVO; import com.api.aiyh_pcn.patentWall.vo.PatentVO;
import weaver.conn.RecordSet;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -12,7 +17,71 @@ import java.util.Map;
public class PatentWallMapping { public class PatentWallMapping {
public List<Map<String,Object>> getList(Map<String, Object> map) { private final ToolUtil toolUtil = new ToolUtil();
return null;
public List<Map<String, Object>> getAllList(String tableName){
RecordSet rs = new RecordSet();
String query = "select * from " + tableName;
rs.executeQuery(query);
return Util.recordSet2MapList(rs);
}
public List<Map<String,Object>> getListByFilterWhere(List<FilterWhere> filterWheres, String tableName) {
StringBuilder whereBuilder = new StringBuilder(" where ");
List<String> args = new ArrayList<>();
for (FilterWhere filterWhere : filterWheres) {
whereBuilder.append(" add ");
if(filterWhere.getType() == 1){
// 等于
whereBuilder.append(filterWhere.getDbField())
.append(" = ? ");
args.add(filterWhere.getValue());
continue;
}
if(filterWhere.getType() == 2){
// 大于
whereBuilder.append(filterWhere.getDbField())
.append(" > ?");
args.add(filterWhere.getValue());
continue;
}
if(filterWhere.getType() == 3){
// 小于
whereBuilder.append(filterWhere.getDbField())
.append(" < ?");
args.add(filterWhere.getValue());
continue;
}
if(filterWhere.getType() == 4){
// in
whereBuilder.append(filterWhere.getDbField())
.append(" in ( ")
.append(filterWhere.getValue())
.append(") ");
continue;
}
if(filterWhere.getType() == 5){
// 日期大于
whereBuilder.append(" DATE_FORMAT(")
.append(filterWhere.getDbField())
.append(",'%y-%m-%d') > ")
.append("DATE_FORMAT(?,'%y-%m-%d')");
args.add(filterWhere.getValue());
continue;
}
if(filterWhere.getType() == 6){
// 日期小于
whereBuilder.append(" DATE_FORMAT(")
.append(filterWhere.getDbField())
.append(",'%y-%m-%d') < ")
.append("DATE_FORMAT(?,'%y-%m-%d')");
args.add(filterWhere.getValue());
continue;
}
}
RecordSet rs = new RecordSet();
String query = "select * from " + tableName + whereBuilder.toString().replace(" where add "," where ");
rs.executeQuery(query,args);
toolUtil.writeDebuggerLog(String.format("执行SQL {%s} ---> 参数: {%s}",query,args));
return Util.recordSet2MapList(rs);
} }
} }

View File

@ -0,0 +1,20 @@
package com.api.aiyh_pcn.patentWall.dto;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author EBU7-dev1-ayh
* @create 2021/11/26 0026 11:35
*
*/
@Setter
@Getter
@ToString
public class FilterWhere {
private int type;
private String dbField;
private String value;
}

View File

@ -3,6 +3,7 @@ package com.api.aiyh_pcn.patentWall.service;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.zwl.common.ToolUtil; import aiyh.utils.zwl.common.ToolUtil;
import com.api.aiyh_pcn.patentWall.dao.PatentWallMapping; import com.api.aiyh_pcn.patentWall.dao.PatentWallMapping;
import com.api.aiyh_pcn.patentWall.dto.FilterWhere;
import com.api.aiyh_pcn.patentWall.vo.PatentVO; import com.api.aiyh_pcn.patentWall.vo.PatentVO;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
@ -24,9 +25,17 @@ public class PatentWallService {
private final ToolUtil toolUtil = new ToolUtil(); private final ToolUtil toolUtil = new ToolUtil();
private Map<String, Object> patentWallConf; private Map<String, Object> patentWallConf;
public List<PatentVO> getList(Map<String, Object> map) { public List<PatentVO> getList(List<FilterWhere> filterWheres) {
Map<String, Object> patentWallConf = getPatentWallConf(); Map<String, Object> patentWallConf = getPatentWallConf();
List<Map<String, Object>> dataList = patentWallMapping.getList(map); List<Map<String, Object>> dataList;
if(filterWheres == null || filterWheres.isEmpty()){
// 查询全部
dataList = patentWallMapping.getAllList(Util.null2String(patentWallConf.get("dataResource")));
}else{
// 筛选查询
dataList = patentWallMapping.getListByFilterWhere(filterWheres
,Util.null2String(patentWallConf.get("dataResource")));
}
List<PatentVO> list = new ArrayList<>(); List<PatentVO> list = new ArrayList<>();
List<String> args = new ArrayList<>(); List<String> args = new ArrayList<>();
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();

View File

@ -16,6 +16,7 @@ import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl;
import aiyh.utils.sqlUtil.whereUtil.Where; import aiyh.utils.sqlUtil.whereUtil.Where;
import com.api.aiyh_guijiu.service.WorkflowQueueService; import com.api.aiyh_guijiu.service.WorkflowQueueService;
import com.api.aiyh_guijiu.vo.PicPsVO; import com.api.aiyh_guijiu.vo.PicPsVO;
import com.api.aiyh_pcn.patentWall.service.PatentWallService;
import com.api.aiyh_pcn.patentWall.vo.PatentVO; import com.api.aiyh_pcn.patentWall.vo.PatentVO;
import com.drew.imaging.ImageMetadataReader; import com.drew.imaging.ImageMetadataReader;
import com.drew.imaging.ImageProcessingException; import com.drew.imaging.ImageProcessingException;
@ -37,6 +38,7 @@ import org.h2.util.StringUtils;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.junit.Test; import org.junit.Test;
import sun.font.FontDesignMetrics;
import weaver.aiyh_quanshi.RequestApi; import weaver.aiyh_quanshi.RequestApi;
import weaver.aiyh_quanshi.entity.QsResponse; import weaver.aiyh_quanshi.entity.QsResponse;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
@ -743,4 +745,27 @@ public class AiyhUtilTest extends BaseTest {
public void testFormat(){ public void testFormat(){
System.out.printf("sql %s参数 %s%n","我是SQL","我是参数"); System.out.printf("sql %s参数 %s%n","我是SQL","我是参数");
} }
@Test
public void testGetList(){
PatentWallService patentWallService = new PatentWallService();
patentWallService.getList(null);
}
@Test
public void testWidth(){
Font font = new Font("微软雅黑", Font.PLAIN,10);
int wordWidth = getWordWidth(font, "我不知道具体是怎么回事,反正我不清楚");
System.out.println(wordWidth);
}
public int getWordWidth(Font font, String content) {
FontDesignMetrics metrics = FontDesignMetrics.getMetrics(font);
int width = 0;
for (int i = 0; i < content.length(); i++) {
width += metrics.charWidth(content.charAt(i));
}
return width;
}
} }

View File

@ -0,0 +1,11 @@
package weaver.aiyh_intercept;
/**
* @author EBU7-dev1-ayh
* @create 2021/11/27 0027 14:06
* customer intercept
*/
public class ChangeStatusIntercept {
}