From cd579ffc213ac45cf68b90d6e2592473cc9e8273 Mon Sep 17 00:00:00 2001 From: IT-xiaoXiong <774495953@qq.com> Date: Mon, 29 Nov 2021 10:15:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E5=91=98=E7=8A=B6=E6=80=81=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E3=80=81=E4=B8=93=E5=88=A9=E5=A2=99=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aiyh/utils/Util.java | 2 +- aiyh/utils/fileUtil/WritWatermark.java | 153 ++++++++------- .../Impl/ChangeStatusImpl.java | 184 ++++++++++++++++++ .../Impl/Util/ChangeStatusUtil.java | 88 +++++++++ .../service/WorkflowQueueService.java | 32 ++- .../controller/PatentWallController.java | 5 +- .../patentWall/dao/PatentWallMapping.java | 73 ++++++- .../aiyh_pcn/patentWall/dto/FilterWhere.java | 20 ++ .../patentWall/service/PatentWallService.java | 13 +- customization/test/AiyhUtilTest.java | 25 +++ .../aiyh_intercept/ChangeStatusIntercept.java | 11 ++ 11 files changed, 524 insertions(+), 82 deletions(-) create mode 100644 com/api/aiy_changeStatus/Impl/ChangeStatusImpl.java create mode 100644 com/api/aiy_changeStatus/Impl/Util/ChangeStatusUtil.java create mode 100644 com/api/aiyh_pcn/patentWall/dto/FilterWhere.java create mode 100644 weaver/aiyh_intercept/ChangeStatusIntercept.java diff --git a/aiyh/utils/Util.java b/aiyh/utils/Util.java index 1ff4300..5bd0543 100644 --- a/aiyh/utils/Util.java +++ b/aiyh/utils/Util.java @@ -677,7 +677,7 @@ public class Util extends weaver.general.Util { if (!Character.isUpperCase(chars[0])) { chars[0] -= 32; } - className = String.valueOf(chars) + "DTO"; + className = String.valueOf(chars) + "PO"; toStringBuilder.append("\tpublic String toString() {\n\t\treturn \"") .append(className) .append("{\" +\n"); diff --git a/aiyh/utils/fileUtil/WritWatermark.java b/aiyh/utils/fileUtil/WritWatermark.java index 1192799..26a6dfe 100644 --- a/aiyh/utils/fileUtil/WritWatermark.java +++ b/aiyh/utils/fileUtil/WritWatermark.java @@ -1,5 +1,7 @@ package aiyh.utils.fileUtil; +import aiyh.utils.zwl.common.ToolUtil; +import sun.font.FontDesignMetrics; import weaver.conn.RecordSet; import weaver.file.FileUpload; import weaver.file.ImageFileManager; @@ -25,6 +27,8 @@ import java.util.UUID; public class WritWatermark { + private static final ToolUtil toolUtil = new ToolUtil(); + /** * 根据系统中物理文件的id添加水印 * @@ -46,7 +50,7 @@ public class WritWatermark { ImageFileManager imageFileManager = new ImageFileManager(); // 通过文件id获取输入流 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. " + "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); int width = image.getWidth(null); int height = image.getHeight(null); - double lineHeight = fontSize * lineSpacing; // 创建bufferedImage BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = bufferedImage.createGraphics(); @@ -62,17 +65,6 @@ public class WritWatermark { graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); 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 maxStr = ""; int max = 0; @@ -83,6 +75,25 @@ public class WritWatermark { 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 Y; int fontWidth = graphics.getFontMetrics(graphics.getFont()).charsWidth(maxStr.toCharArray(), 0, max); @@ -188,7 +199,7 @@ public class WritWatermark { ImageFileManager imageFileManager = new ImageFileManager(); // 通过文件id获取输入流 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. " + "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)); // 获取水印图片 InputStream inputStreamImgIcon = ImageFileManager.getInputStreamById(picId); - if(inputStreamImgIcon == null){ + if (inputStreamImgIcon == null) { throw new RuntimeException("The obtained watermark logo image is empty"); } Image logoImg = ImageIO.read(inputStreamImgIcon); @@ -314,7 +325,7 @@ public class WritWatermark { ImageFileManager imageFileManager = new ImageFileManager(); // 通过文件id获取输入流 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. " + "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.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha)); - if(logoInput == null){ + if (logoInput == null) { throw new RuntimeException("The obtained watermark logo image is empty"); } // 获取水印图片 @@ -424,19 +435,18 @@ public class WritWatermark { } /** - * - * @param imageId 物理图片id - * @param pressText 水印文字 - * @param color 水印文字颜色 - * @param fontName 水印字体名字 - * @param fontStyle 水印字体样式 - * @param fontSize 水印字体大小 - * @param degree 水印旋转角度 - * @param alpha 水印透明度 + * @param imageId 物理图片id + * @param pressText 水印文字 + * @param color 水印文字颜色 + * @param fontName 水印字体名字 + * @param fontStyle 水印字体样式 + * @param fontSize 水印字体大小 + * @param degree 水印旋转角度 + * @param alpha 水印透明度 * @param lineSpacing 水印文字行间距(倍数) - * @param moveX 水印X轴偏移量 - * @param moveY 水印Y轴偏移量 - * @param randomX 水印X轴随机偏移量 + * @param moveX 水印X轴偏移量 + * @param moveY 水印Y轴偏移量 + * @param randomX 水印X轴随机偏移量 * @return 带水印的物理图片id * @throws IOException io异常 */ @@ -445,7 +455,7 @@ public class WritWatermark { ImageFileManager imageFileManager = new ImageFileManager(); // 通过文件id获取输入流 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. " + "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 mustX = fontWidth; int mustY = fontsHeight; - int start = - (width + height); + int start = -(width + height); int end = width + height; X = start; Y = start; int random = 0; // 循环Y,每次偏移防止重叠的最小偏移量加上自定义的偏移量 - for (; Y <= end; Y = Y + moveY + mustY ){ + for (; Y <= end; Y = Y + moveY + mustY) { // 循环X,每次偏移防止重叠的最小偏移量加上自定义偏移量 - for (; X <= end; X = X + moveX + mustX){ - for (int i = 0; i < pressTexts.length; i ++){ + for (; X <= end; X = X + moveX + mustX) { + for (int i = 0; i < pressTexts.length; i++) { // 防止重叠对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; - if(random == 0){ - random = - randomX; - }else { + if (random == 0) { + random = -randomX; + } else { random = 0; } } @@ -562,13 +572,12 @@ public class WritWatermark { } /** - * * @param imageId 物理图片id - * @param picId 水印物理文件id - * @param degree 水印旋转角度 - * @param alpha 水印透明度 - * @param moveX 水印X轴偏移量 - * @param moveY 水印Y轴偏移量 + * @param picId 水印物理文件id + * @param degree 水印旋转角度 + * @param alpha 水印透明度 + * @param moveX 水印X轴偏移量 + * @param moveY 水印Y轴偏移量 * @param randomX 水印X轴随机偏移量 * @return 带水印的物理图片id * @throws IOException io异常 @@ -578,7 +587,7 @@ public class WritWatermark { ImageFileManager imageFileManager = new ImageFileManager(); // 通过文件id获取输入流 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. " + "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)); // 获取水印图片 InputStream inputStreamImgIcon = ImageFileManager.getInputStreamById(picId); - if(inputStreamImgIcon == null){ + if (inputStreamImgIcon == null) { throw new RuntimeException("The obtained watermark logo image is empty"); } ImageIcon logoImgIcon = new ImageIcon(ImageIO.read(inputStreamImgIcon)); @@ -610,22 +619,22 @@ public class WritWatermark { int Y; int mustX = logoWidth; int mustY = logoHeight; - int start = - (width + height); + int start = -(width + height); int end = width + height; X = start; Y = start; int random = 0; // 循环Y,每次偏移防止重叠的最小偏移量加上自定义的偏移量 - for (; Y <= end; Y = Y + moveY + mustY ){ + for (; Y <= end; Y = Y + moveY + mustY) { // 循环X,每次偏移防止重叠的最小偏移量加上自定义偏移量 - for (; X <= end; X = X + moveX + mustX){ + for (; X <= end; X = X + moveX + mustX) { graphics.drawImage(logoImg, X + random, Y, null); } X = start; - if(random == 0){ - random = - randomX; - }else { + if (random == 0) { + random = -randomX; + } else { random = 0; } } @@ -684,23 +693,22 @@ public class WritWatermark { /** - * - * @param imageId 物理图片id + * @param imageId 物理图片id * @param logoInput 水印图片输入流 - * @param degree 水印旋转角度 - * @param alpha 水印透明度 - * @param moveX 水印X轴偏移位置 - * @param moveY 水印Y轴偏移位置 - * @param randomX 水印X轴随机偏移量 + * @param degree 水印旋转角度 + * @param alpha 水印透明度 + * @param moveX 水印X轴偏移位置 + * @param moveY 水印Y轴偏移位置 + * @param randomX 水印X轴随机偏移量 * @return 带水印的物理图片id * @throws IOException io异常 */ 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(); // 通过文件id获取输入流 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. " + "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.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha)); - if(logoInput == null){ + if (logoInput == null) { throw new RuntimeException("The obtained watermark logo image is empty"); } // 获取水印图片 @@ -731,22 +739,22 @@ public class WritWatermark { int Y; int mustX = logoWidth; int mustY = logoHeight; - int start = - (width + height); + int start = -(width + height); int end = width + height; X = start; Y = start; int random = 0; // 循环Y,每次偏移防止重叠的最小偏移量加上自定义的偏移量 - for (; Y <= end; Y = Y + moveY + mustY ){ + for (; Y <= end; Y = Y + moveY + mustY) { // 循环X,每次偏移防止重叠的最小偏移量加上自定义偏移量 - for (; X <= end; X = X + moveX + mustX){ + for (; X <= end; X = X + moveX + mustX) { graphics.drawImage(logoImg, X + random, Y, null); } X = start; - if(random == 0){ - random = - randomX; - }else { + if (random == 0) { + random = -randomX; + } else { random = 0; } } @@ -803,5 +811,14 @@ public class WritWatermark { 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; + } + } diff --git a/com/api/aiy_changeStatus/Impl/ChangeStatusImpl.java b/com/api/aiy_changeStatus/Impl/ChangeStatusImpl.java new file mode 100644 index 0000000..39ba7ab --- /dev/null +++ b/com/api/aiy_changeStatus/Impl/ChangeStatusImpl.java @@ -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 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+++++++++++++++++++++++++++++ + */ + +} diff --git a/com/api/aiy_changeStatus/Impl/Util/ChangeStatusUtil.java b/com/api/aiy_changeStatus/Impl/Util/ChangeStatusUtil.java new file mode 100644 index 0000000..dab5bb8 --- /dev/null +++ b/com/api/aiy_changeStatus/Impl/Util/ChangeStatusUtil.java @@ -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 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 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 paramMap = weaBeforeReplaceParam.getParamMap(); + List> datas = (List>) paramMap.get("datas"); + if (datas == null || datas.isEmpty()) { + return; + } + List ids = new ArrayList<>(); + for (Map 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 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); + } + + +} diff --git a/com/api/aiyh_guijiu/service/WorkflowQueueService.java b/com/api/aiyh_guijiu/service/WorkflowQueueService.java index 2c3bfe4..cc8c2dd 100644 --- a/com/api/aiyh_guijiu/service/WorkflowQueueService.java +++ b/com/api/aiyh_guijiu/service/WorkflowQueueService.java @@ -306,6 +306,7 @@ public class WorkflowQueueService { int id = rs.getInt(1); int newId; try { + toolUtil.writeDebuggerLog("开始添加水印,传递字体大小!"); newId = WritWatermark.addTextWatermarkById(id, pressText, color, fontName, Font.PLAIN, fontSize , new WatermarkPoint(WatermarkPointEnum.RIGHT_BOTTOM), 0, 1, 1.3); } catch (IOException e) { @@ -319,7 +320,7 @@ public class WorkflowQueueService { index++; } //复制原图的权限信息等 - // 复制原来的文件信息,并将现有的信息进行绑定 + //复制原来的文件信息,并将现有的信息进行绑定 DocManager docManager = new DocManager(); String[] picIdStrArr = fileIds.split(","); String[] newImgArr = newIds.toString().split(","); @@ -356,18 +357,34 @@ public class WorkflowQueueService { String fieldName = param.get("fieldName"); String tableName = param.get("tableName"); String isWrite = param.get("isWrite"); + String isAppend = param.get("isAppend"); // String sourceField = param.get("sourceField"); String requestId = param.get("requestId"); 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)) { // 不保存原来的图片 String update = "update " + tableName + " set " + fieldName + - " = " + + " = '" + newDocIds + - " where " + + "' where " + " requestid = ?"; rs.executeUpdate(update, requestId); } else { @@ -375,17 +392,18 @@ public class WorkflowQueueService { tableName + " set " + fieldName + - " = " + + " = '" + newDocIds + - " , " + + "' , " + sourceField + - " = " + + " = '" + fileIds + - " where " + + "' where " + " requestid = ?"; rs.executeUpdate(update, requestId); } } + // 查询新文件信息 String listType = Util.null2String(String.valueOf(param.get("listType")), "list"); int requestid = Util.getIntValue(Util.null2String(String.valueOf(param.get("requestid"))), -1); diff --git a/com/api/aiyh_pcn/patentWall/controller/PatentWallController.java b/com/api/aiyh_pcn/patentWall/controller/PatentWallController.java index 1c8b5c1..5e1c9d0 100644 --- a/com/api/aiyh_pcn/patentWall/controller/PatentWallController.java +++ b/com/api/aiyh_pcn/patentWall/controller/PatentWallController.java @@ -1,6 +1,7 @@ package com.api.aiyh_pcn.patentWall.controller; 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.vo.PatentVO; import io.swagger.v3.oas.annotations.parameters.RequestBody; @@ -24,8 +25,8 @@ public class PatentWallController { @Path("/getList") @POST - public String getPatentList(@RequestBody Map map){ - List result = patentWallService.getList(map); + public String getPatentList(@RequestBody List filterWheres){ + List result = patentWallService.getList(filterWheres); return ApiResult.success(result); } diff --git a/com/api/aiyh_pcn/patentWall/dao/PatentWallMapping.java b/com/api/aiyh_pcn/patentWall/dao/PatentWallMapping.java index 8c8103e..dda24be 100644 --- a/com/api/aiyh_pcn/patentWall/dao/PatentWallMapping.java +++ b/com/api/aiyh_pcn/patentWall/dao/PatentWallMapping.java @@ -1,7 +1,12 @@ 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 weaver.conn.RecordSet; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -12,7 +17,71 @@ import java.util.Map; public class PatentWallMapping { - public List> getList(Map map) { - return null; + private final ToolUtil toolUtil = new ToolUtil(); + + public List> getAllList(String tableName){ + RecordSet rs = new RecordSet(); + String query = "select * from " + tableName; + rs.executeQuery(query); + return Util.recordSet2MapList(rs); + } + public List> getListByFilterWhere(List filterWheres, String tableName) { + StringBuilder whereBuilder = new StringBuilder(" where "); + List 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); } } diff --git a/com/api/aiyh_pcn/patentWall/dto/FilterWhere.java b/com/api/aiyh_pcn/patentWall/dto/FilterWhere.java new file mode 100644 index 0000000..16ce5f2 --- /dev/null +++ b/com/api/aiyh_pcn/patentWall/dto/FilterWhere.java @@ -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; +} diff --git a/com/api/aiyh_pcn/patentWall/service/PatentWallService.java b/com/api/aiyh_pcn/patentWall/service/PatentWallService.java index b92df82..d4fa7f8 100644 --- a/com/api/aiyh_pcn/patentWall/service/PatentWallService.java +++ b/com/api/aiyh_pcn/patentWall/service/PatentWallService.java @@ -3,6 +3,7 @@ package com.api.aiyh_pcn.patentWall.service; import aiyh.utils.Util; import aiyh.utils.zwl.common.ToolUtil; 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 weaver.conn.RecordSet; @@ -24,9 +25,17 @@ public class PatentWallService { private final ToolUtil toolUtil = new ToolUtil(); private Map patentWallConf; - public List getList(Map map) { + public List getList(List filterWheres) { Map patentWallConf = getPatentWallConf(); - List> dataList = patentWallMapping.getList(map); + List> 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 list = new ArrayList<>(); List args = new ArrayList<>(); RecordSet rs = new RecordSet(); diff --git a/customization/test/AiyhUtilTest.java b/customization/test/AiyhUtilTest.java index 1efb093..2f29cea 100644 --- a/customization/test/AiyhUtilTest.java +++ b/customization/test/AiyhUtilTest.java @@ -16,6 +16,7 @@ import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl; import aiyh.utils.sqlUtil.whereUtil.Where; import com.api.aiyh_guijiu.service.WorkflowQueueService; 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.drew.imaging.ImageMetadataReader; import com.drew.imaging.ImageProcessingException; @@ -37,6 +38,7 @@ import org.h2.util.StringUtils; import org.json.JSONException; import org.json.JSONObject; import org.junit.Test; +import sun.font.FontDesignMetrics; import weaver.aiyh_quanshi.RequestApi; import weaver.aiyh_quanshi.entity.QsResponse; import weaver.conn.RecordSet; @@ -743,4 +745,27 @@ public class AiyhUtilTest extends BaseTest { public void testFormat(){ 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; + } } \ No newline at end of file diff --git a/weaver/aiyh_intercept/ChangeStatusIntercept.java b/weaver/aiyh_intercept/ChangeStatusIntercept.java new file mode 100644 index 0000000..55544f3 --- /dev/null +++ b/weaver/aiyh_intercept/ChangeStatusIntercept.java @@ -0,0 +1,11 @@ +package weaver.aiyh_intercept; + +/** + * @author EBU7-dev1-ayh + * @create 2021/11/27 0027 14:06 + * customer intercept + */ + + +public class ChangeStatusIntercept { +}