人员状态变更、专利墙接口开发
parent
8ac1b5735b
commit
cd579ffc21
|
@ -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");
|
||||||
|
|
|
@ -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,19 +435,18 @@ public class WritWatermark {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param imageId 物理图片id
|
||||||
* @param imageId 物理图片id
|
* @param pressText 水印文字
|
||||||
* @param pressText 水印文字
|
* @param color 水印文字颜色
|
||||||
* @param color 水印文字颜色
|
* @param fontName 水印字体名字
|
||||||
* @param fontName 水印字体名字
|
* @param fontStyle 水印字体样式
|
||||||
* @param fontStyle 水印字体样式
|
* @param fontSize 水印字体大小
|
||||||
* @param fontSize 水印字体大小
|
* @param degree 水印旋转角度
|
||||||
* @param degree 水印旋转角度
|
* @param alpha 水印透明度
|
||||||
* @param alpha 水印透明度
|
|
||||||
* @param lineSpacing 水印文字行间距(倍数)
|
* @param lineSpacing 水印文字行间距(倍数)
|
||||||
* @param moveX 水印X轴偏移量
|
* @param moveX 水印X轴偏移量
|
||||||
* @param moveY 水印Y轴偏移量
|
* @param moveY 水印Y轴偏移量
|
||||||
* @param randomX 水印X轴随机偏移量
|
* @param randomX 水印X轴随机偏移量
|
||||||
* @return 带水印的物理图片id
|
* @return 带水印的物理图片id
|
||||||
* @throws IOException io异常
|
* @throws IOException io异常
|
||||||
*/
|
*/
|
||||||
|
@ -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,13 +572,12 @@ public class WritWatermark {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param imageId 物理图片id
|
* @param imageId 物理图片id
|
||||||
* @param picId 水印物理文件id
|
* @param picId 水印物理文件id
|
||||||
* @param degree 水印旋转角度
|
* @param degree 水印旋转角度
|
||||||
* @param alpha 水印透明度
|
* @param alpha 水印透明度
|
||||||
* @param moveX 水印X轴偏移量
|
* @param moveX 水印X轴偏移量
|
||||||
* @param moveY 水印Y轴偏移量
|
* @param moveY 水印Y轴偏移量
|
||||||
* @param randomX 水印X轴随机偏移量
|
* @param randomX 水印X轴随机偏移量
|
||||||
* @return 带水印的物理图片id
|
* @return 带水印的物理图片id
|
||||||
* @throws IOException io异常
|
* @throws IOException io异常
|
||||||
|
@ -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,23 +693,22 @@ public class WritWatermark {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param imageId 物理图片id
|
||||||
* @param imageId 物理图片id
|
|
||||||
* @param logoInput 水印图片输入流
|
* @param logoInput 水印图片输入流
|
||||||
* @param degree 水印旋转角度
|
* @param degree 水印旋转角度
|
||||||
* @param alpha 水印透明度
|
* @param alpha 水印透明度
|
||||||
* @param moveX 水印X轴偏移位置
|
* @param moveX 水印X轴偏移位置
|
||||||
* @param moveY 水印Y轴偏移位置
|
* @param moveY 水印Y轴偏移位置
|
||||||
* @param randomX 水印X轴随机偏移量
|
* @param randomX 水印X轴随机偏移量
|
||||||
* @return 带水印的物理图片id
|
* @return 带水印的物理图片id
|
||||||
* @throws IOException io异常
|
* @throws IOException io异常
|
||||||
*/
|
*/
|
||||||
public static int addPicTileWatermarkById(int imageId, InputStream logoInput
|
public static int addPicTileWatermarkById(int imageId, InputStream logoInput
|
||||||
, double degree, float alpha, int moveX, int moveY, int randomX) throws IOException {
|
, double degree, float alpha, int moveX, int moveY, int randomX) throws IOException {
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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+++++++++++++++++++++++++++++
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -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);
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
|
@ -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();
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package weaver.aiyh_intercept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author EBU7-dev1-ayh
|
||||||
|
* @create 2021/11/27 0027 14:06
|
||||||
|
* customer intercept
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public class ChangeStatusIntercept {
|
||||||
|
}
|
Loading…
Reference in New Issue