From c34375c1f233fbc4cf3e754d2c59e5abc65e87da Mon Sep 17 00:00:00 2001 From: dangsn <dangsn@vci-tech.com> Date: 星期五, 20 十二月 2024 23:13:41 +0800 Subject: [PATCH] 图标服务功能,以及AES加密 --- Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java | 4 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLifeCycleServiceImpl.java | 8 Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/PLIconGroupVO.java | 29 ++ Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/ClassUtilForVCI.java | 20 Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/PLIconDTO.java | 41 +++ Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/annotation/VciLifeCycleTrans.java | 2 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsLifeCycleServiceI.java | 4 Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/Lcm/Func.java | 12 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebIconServiceImpl.java | 267 ++++++++++++++++++++++ Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/annotation/VciEnum.java | 2 Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/Lcm/DigestUtil.java | 32 ++ Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/WebIconserviceI.java | 66 +++++ Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/PLIconVO.java | 46 +++ Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebIconController.java | 184 +++++++++++++++ 14 files changed, 692 insertions(+), 25 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/PLIconDTO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/PLIconDTO.java new file mode 100644 index 0000000..37fab25 --- /dev/null +++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/PLIconDTO.java @@ -0,0 +1,41 @@ +package com.vci.dto; + +import lombok.Data; + +/** + * @Description 鍥炬爣浼犺緭瀵硅薄 + * @Author dangsn + * @Date 2024/12/20 11:35 + */ +@Data +public class PLIconDTO implements java.io.Serializable{ + /** + * 绂佹淇敼杩欎釜鍊� + */ + private static final long serialVersionUID = -8274239331362353099L; + + /** + * 鍞竴鏍囪瘑 + */ + private String oid; + + /** + * 鍥炬爣鍚嶇О + */ + private String name; + + /** + * 鍥炬爣鍐呭 + */ + private String content; + + /** + * 鍥炬爣绫诲瀷 + */ + private String type; + + /** + * 鍥炬爣鍒嗙粍 + */ + private String groups; +} diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/PLIconGroupVO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/PLIconGroupVO.java new file mode 100644 index 0000000..ea4c674 --- /dev/null +++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/PLIconGroupVO.java @@ -0,0 +1,29 @@ +package com.vci.pagemodel; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Description + * @Author dangsn + * @Date 2024/12/20 17:35 + */ +@Data +public class PLIconGroupVO implements Serializable { + /** + * 绂佹淇敼杩欎釜鍊� + */ + private static final long serialVersionUID = -2130637697533772413L; + + /** + * 鍥炬爣鎵�灞炲簱 + */ + private String lable; + + /** + * 鍥炬爣 + */ + private List<PLIconVO> list; +} diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/PLIconVO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/PLIconVO.java new file mode 100644 index 0000000..fb7352e --- /dev/null +++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/PLIconVO.java @@ -0,0 +1,46 @@ +package com.vci.pagemodel; + +import lombok.Data; + +/** + * @Description 鍥炬爣鏄剧ず瀵硅薄 + * @Author dangsn + * @Date 2024/12/20 11:37 + */ +@Data +public class PLIconVO implements java.io.Serializable{ + /** + * 绂佹淇敼杩欎釜鍊� + */ + private static final long serialVersionUID = -8797180178702594251L; + + /** + * 鍞竴鏍囪瘑 + */ + private String oid; + + /** + * 鍥炬爣鍚嶇О + */ + private String name; + + /** + * 鍥炬爣鍐呭 + */ + private String content; + + /** + * 鍥炬爣绫诲瀷 + */ + private String type; + + /** + * 鍥炬爣鍒嗙粍 + */ + private String groups; + + /** + * 鍥炬爣鎵�灞炲簱 + */ + private String lable; +} diff --git a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/annotation/VciEnum.java b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/annotation/VciEnum.java index fbd0156..29bba35 100644 --- a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/annotation/VciEnum.java +++ b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/annotation/VciEnum.java @@ -22,7 +22,7 @@ * 鍊肩被鍨嬶紝榛樿涓哄瓧绗︿覆 * @return */ - Class valueType() default java.lang.String.class; + Class valueType() default String.class; /** * 鏄剧ず鏂囨湰 diff --git a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/annotation/VciLifeCycleTrans.java b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/annotation/VciLifeCycleTrans.java index 61b4653..cd0ca30 100644 --- a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/annotation/VciLifeCycleTrans.java +++ b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/annotation/VciLifeCycleTrans.java @@ -9,7 +9,7 @@ * 鐢熷懡鍛ㄦ湡鐘舵�佹祦鍚� * @author weidy */ -@Target({java.lang.annotation.ElementType.TYPE, ElementType.FIELD}) +@Target({ElementType.TYPE, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface VciLifeCycleTrans { diff --git a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/ClassUtilForVCI.java b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/ClassUtilForVCI.java index 645458e..384426f 100644 --- a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/ClassUtilForVCI.java +++ b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/ClassUtilForVCI.java @@ -35,16 +35,16 @@ /** * 鍒ゆ柇鍩烘湰绫诲瀷 - * @see java.lang.String - * @see java.lang.Boolean#TYPE - * @see java.lang.Character#TYPE - * @see java.lang.Byte#TYPE - * @see java.lang.Short#TYPE - * @see java.lang.Integer#TYPE - * @see java.lang.Long#TYPE - * @see java.lang.Float#TYPE - * @see java.lang.Double#TYPE - * @see java.lang.Boolean#TYPE + * @see String + * @see Boolean#TYPE + * @see Character#TYPE + * @see Byte#TYPE + * @see Short#TYPE + * @see Integer#TYPE + * @see Long#TYPE + * @see Float#TYPE + * @see Double#TYPE + * @see Boolean#TYPE * @see byte * @see short * @see int diff --git a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/Lcm/DigestUtil.java b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/Lcm/DigestUtil.java index b1012e8..ba11a14 100644 --- a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/Lcm/DigestUtil.java +++ b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/Lcm/DigestUtil.java @@ -9,6 +9,7 @@ import javax.crypto.SecretKey; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.StandardCharsets; import java.security.InvalidKeyException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -333,16 +334,16 @@ /** * aes瑙e瘑 * @param secretKey 绉橀挜 - * @param encryptedData Data + * @param encryptedData 瀵嗘枃 * @return digest as a hex string */ public static String decryptAes(String encryptedData, String secretKey) throws Exception { // AES 瀵嗛挜闀垮害闇�瑕佹槸 128, 192, 鎴� 256 浣嶏紙16, 24, 鎴� 32 瀛楄妭锛� - byte[] keyBytes = secretKey.getBytes("UTF-8"); + byte[] keyBytes = secretKey.getBytes(StandardCharsets.UTF_8); SecretKeySpec key = new SecretKeySpec(keyBytes, "AES"); // 鍒濆鍖栧悜閲� IV 涔熼渶瑕佹槸 128 浣嶏紙16 瀛楄妭锛� - byte[] ivBytes = secretKey.substring(0, 16).getBytes("UTF-8"); + byte[] ivBytes = secretKey.substring(0, 16).getBytes(StandardCharsets.UTF_8); IvParameterSpec iv = new IvParameterSpec(ivBytes); // 瑙e瘑 @@ -353,7 +354,30 @@ byte[] decodedValue = Base64.getDecoder().decode(encryptedData); byte[] decryptedBytes = cipher.doFinal(decodedValue); - return new String(decryptedBytes, "UTF-8"); + return new String(decryptedBytes, StandardCharsets.UTF_8); + } + + /** + * aes瑙e瘑 + * @param secretKey 绉橀挜 + * @param decryptData 鏄庢枃 + * @return digest as a hex string + */ + public static String encryptAes(String decryptData, String secretKey) throws Exception{ + // AES 瀵嗛挜闀垮害闇�瑕佹槸 128, 192, 鎴� 256 浣嶏紙16, 24, 鎴� 32 瀛楄妭锛� + byte[] keyBytes = secretKey.getBytes(StandardCharsets.UTF_8); + SecretKeySpec key = new SecretKeySpec(keyBytes, "AES"); + + // 鍒濆鍖栧悜閲� IV 涔熼渶瑕佹槸 128 浣嶏紙16 瀛楄妭锛� + byte[] ivBytes = secretKey.substring(0, 16).getBytes(StandardCharsets.UTF_8); + IvParameterSpec iv = new IvParameterSpec(ivBytes); + + // 鍔犲瘑 + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, key, iv); + + byte[] encryptBytes = cipher.doFinal(decryptData.getBytes(StandardCharsets.UTF_8)); + return Base64.getEncoder().encodeToString(encryptBytes); } /** diff --git a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/Lcm/Func.java b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/Lcm/Func.java index 6753fe1..500b110 100644 --- a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/Lcm/Func.java +++ b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/Lcm/Func.java @@ -395,7 +395,7 @@ * @param o2 second Object to compare * @return whether the given objects are equal * @see Object#equals(Object) - * @see java.util.Arrays#equals + * @see Arrays#equals */ public static boolean equalsSafe(@Nullable Object o1, @Nullable Object o2) { return ObjectUtil.nullSafeEquals(o1, o2); @@ -1243,6 +1243,16 @@ } /** + * AES 瑙e瘑 + * @param decryptData + * @param secretKey + * @return + */ + public static String encryptAes(String decryptData, String secretKey) throws Exception { + return DigestUtil.encryptAes(decryptData, secretKey); + } + + /** * hmacMd5 Hex * * @param bytes Data to digest diff --git a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java index 3418674..ee58816 100644 --- a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java +++ b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java @@ -1322,7 +1322,7 @@ Map<String,Object> map = new HashMap<String,Object>(); if(o!=null) { String jsonString = JSONObject.toJSONStringWithDateFormat(o, VciDateUtil.DateTimeMillFormat, SerializerFeature.WriteDateUseDateFormat); - if(org.apache.commons.lang3.StringUtils.isNotBlank(jsonString)) { + if(StringUtils.isNotBlank(jsonString)) { JSONObject jsonObject = JSONObject.parseObject(jsonString); if(jsonObject!=null){ for(String key : jsonObject.keySet()){ @@ -1343,7 +1343,7 @@ Map<String,String> map = new HashMap<String,String>(); if(o!=null) { String jsonString = JSONObject.toJSONStringWithDateFormat(o, VciDateUtil.DateTimeMillFormat, SerializerFeature.WriteDateUseDateFormat); - if(org.apache.commons.lang3.StringUtils.isNotBlank(jsonString)) { + if(StringUtils.isNotBlank(jsonString)) { JSONObject jsonObject = JSONObject.parseObject(jsonString); if(jsonObject!=null){ for(String key : jsonObject.keySet()){ diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebIconController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebIconController.java new file mode 100644 index 0000000..a700a6b --- /dev/null +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebIconController.java @@ -0,0 +1,184 @@ +package com.vci.web.controller; + +import com.vci.constant.FrameWorkLangCodeConstant; +import com.vci.dto.PLIconDTO; +import com.vci.pagemodel.PLIconGroupVO; +import com.vci.pagemodel.PLIconVO; +import com.vci.starter.web.annotation.log.VciBusinessLog; +import com.vci.starter.web.exception.VciBaseException; +import com.vci.starter.web.pagemodel.BaseQueryObject; +import com.vci.starter.web.pagemodel.BaseResult; +import com.vci.starter.web.pagemodel.DataGrid; +import com.vci.starter.web.util.LocalFileUtil; +import com.vci.starter.web.util.VciBaseUtil; +import com.vci.web.service.WebIconserviceI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.io.File; +import java.util.List; + +/** + * @Description 鍥炬爣鎺у埗鍣� + * @Author dangsn + * @Date 2024/12/20 10:24 + */ +@VciBusinessLog(modelName="鍥炬爣鎺у埗鍣�",notStore=true) +@RestController +@RequestMapping("/webIconController") +public class WebIconController { + + /** + * 鏃ュ織 + */ + private Logger logger = LoggerFactory.getLogger(getClass()); + + /** + * 鍥炬爣鏈嶅姟 + */ + @Resource + private WebIconserviceI iconserviceI; + + /** + * 瀵煎叆鍥炬爣 + * @param file 鍥炬爣鏂囦欢 + */ + @PostMapping("/importIcon") + @VciBusinessLog(operateName = "瀵煎叆鍥炬爣搴�", description = "瀵煎叆鍥炬爣搴�") + public BaseResult importIcon(String type, String groups, MultipartFile file){ + String fileName = LocalFileUtil.getDefaultTempFolder() + File.separator + LocalFileUtil.getFileNameForIE(file.getOriginalFilename()); + File iconFile = new File(fileName); + try { + file.transferTo(iconFile); + if (iconFile != null) { + iconserviceI.importIcon(type, groups, iconFile); + return BaseResult.successMsg("瀵煎叆鎴愬姛锛�"); + } else { + return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"鏃犲鍏ョ殑鏂囦欢"}); + } + }catch (Throwable e) { + throw new VciBaseException(VciBaseUtil.getExceptionMessage(e),new String[0],e); + }finally { + iconFile.delete(); + } + } + + /** + * 鏂板鍥炬爣 + * @param iconDTO 鍥炬爣浼犺緭瀵硅薄 + * @return 鎵ц缁撴灉 + */ + @PostMapping("/addIcon") + @VciBusinessLog(operateName = "鏂板鍥炬爣", description = "鏂板鍥炬爣") + public BaseResult addIcon(@RequestBody PLIconDTO iconDTO){ + try { + iconserviceI.addIcon(iconDTO); + return BaseResult.successMsg("鏂板鍥炬爣鎴愬姛锛�"); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鏂板鍥炬爣鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 淇敼鍥炬爣 + * @param iconDTO 鍥炬爣浼犺緭瀵硅薄 + * @return 鎵ц缁撴灉 + */ + @PutMapping("/editIcon") + @VciBusinessLog(operateName = "淇敼鍥炬爣", description = "淇敼鍥炬爣") + public BaseResult editIcon(@RequestBody PLIconDTO iconDTO){ + try { + iconserviceI.editIcon(iconDTO); + return BaseResult.successMsg("淇敼鍥炬爣鎴愬姛锛�"); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "淇敼鍥炬爣鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鍒犻櫎鍥炬爣 + * @param iconDTO 鍥炬爣浼犺緭瀵硅薄 + * @return 鎵ц缁撴灉 + */ + @DeleteMapping("/delIcon") + @VciBusinessLog(operateName = "鍒犻櫎鍥炬爣", description = "鍒犻櫎鍥炬爣") + public BaseResult delIcon(PLIconDTO iconDTO){ + try { + iconserviceI.delIcon(iconDTO); + return BaseResult.successMsg("鍒犻櫎鍥炬爣鎴愬姛锛�"); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鍒犻櫎鍥炬爣鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鑾峰彇鍥炬爣鍚嶇О + * @return 鍥炬爣鍚嶇О + */ + @VciBusinessLog(operateName = "鑾峰彇鍥炬爣鍚嶇О", description = "鑾峰彇鍥炬爣鍚嶇О") + @GetMapping("/getIconName") + public BaseResult<String> getIconName(){ + try{ + List<String> iconNameList = iconserviceI.getIconName(); + BaseResult baseResult = BaseResult.success(); + baseResult.setData(iconNameList); + return baseResult; + }catch (Exception e){ + e.printStackTrace(); + String exceptionMessage = "鑾峰彇鍥炬爣鍚嶇О鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鑾峰彇鎵�鏈夊浘鏍囦俊鎭� + * @param baseQueryObject 鏌ヨ瀵硅薄 + * @return 鍥炬爣淇℃伅 + */ + @VciBusinessLog(operateName = "鑾峰彇鎵�鏈夊浘鏍�", description = "鑾峰彇鎵�鏈夊浘鏍�") + @GetMapping("/getAllIcon") + public BaseResult<PLIconGroupVO> getAllIcon(BaseQueryObject baseQueryObject){ + try{ + List<PLIconGroupVO> iconList = iconserviceI.getAllIcon(baseQueryObject); + BaseResult baseResult = BaseResult.success(); + baseResult.setData(iconList); + return baseResult; + }catch (Exception e){ + e.printStackTrace(); + String exceptionMessage = "鑾峰彇鍥炬爣鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鑾峰彇鍥炬爣淇℃伅锛屽垎椤� + * @param baseQueryObject 鏌ヨ瀵硅薄 + * @return 鍥炬爣淇℃伅 + */ + @VciBusinessLog(operateName = "鑾峰彇鍥炬爣", description = "鑾峰彇鍥炬爣琛ㄦ牸鏁版嵁") + @GetMapping("/getGrid") + public DataGrid<PLIconVO> getGrid(BaseQueryObject baseQueryObject){ + try{ + return iconserviceI.getGrid(baseQueryObject); + }catch (Exception e){ + e.printStackTrace(); + String exceptionMessage = "鑾峰彇鍥炬爣鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return new DataGrid<>(exceptionMessage); + } + } +} diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsLifeCycleServiceI.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsLifeCycleServiceI.java index eebef67..e3dd04a 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsLifeCycleServiceI.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsLifeCycleServiceI.java @@ -129,7 +129,7 @@ * @param releaseStatus 鍙戝竷鐘舵�侊紝濡傛灉鐩爣鐘舵�佹槸鍙戝竷鐘舵�佹椂浼犻�掕繖涓�� * @throws VciBaseException 璺冭縼鍑洪敊鐨勬槸浼氭姏鍑哄紓甯� */ - void batchTransVo(com.vci.corba.omd.data.BusinessObject[] bos, OsLifeCycleLineVO[] lineVOs, + void batchTransVo(BusinessObject[] bos, OsLifeCycleLineVO[] lineVOs, String[] releaseStatus) throws VciBaseException; /** @@ -138,7 +138,7 @@ * @param vos 璺冭縼瀵硅薄 * @throws VciBaseException 璺冭縼鍑洪敊鐨勬槸浼氭姏鍑哄紓甯� */ - void batchTransVo(com.vci.corba.omd.data.BusinessObject[] bos, OsLifeCycleLineVO[] vos) + void batchTransVo(BusinessObject[] bos, OsLifeCycleLineVO[] vos) throws VciBaseException; /** diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/WebIconserviceI.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/WebIconserviceI.java new file mode 100644 index 0000000..6fb8379 --- /dev/null +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/WebIconserviceI.java @@ -0,0 +1,66 @@ +package com.vci.web.service; + +import com.vci.dto.PLIconDTO; +import com.vci.pagemodel.PLIconGroupVO; +import com.vci.pagemodel.PLIconVO; +import com.vci.starter.web.pagemodel.BaseQueryObject; +import com.vci.starter.web.pagemodel.DataGrid; + +import java.io.File; +import java.util.List; + +/** + * @Description 鍥炬爣鏈嶅姟 + * @Author dangsn + * @Date 2024/12/20 10:26 + */ +public interface WebIconserviceI { + + /** + * 瀵煎叆鍥炬爣 + * + * @param type 鍥炬爣绫诲瀷 + * @param groups 鍥炬爣鍒嗙粍 + * @param iconFile 鍥炬爣鏂囦欢 + * @return 鎵ц缁撴灉 + */ + void importIcon(String type, String groups, File iconFile); + + /** + * 鏂板鍥炬爣 + * @param iconDTO 鍥炬爣浼犺緭瀵硅薄 + */ + void addIcon(PLIconDTO iconDTO); + + /** + * 淇敼鍥炬爣 + * @param iconDTO 鍥炬爣浼犺緭瀵硅薄 + */ + void editIcon(PLIconDTO iconDTO); + + /** + * 鍒犻櫎鍥炬爣 + * @param iconDTO 鍥炬爣浼犺緭瀵硅薄 + */ + void delIcon(PLIconDTO iconDTO); + + /** + * 鑾峰彇鍥炬爣鍚嶇О + * @return 鍥炬爣鍚嶇О + */ + List<String> getIconName(); + + /** + * 鑾峰彇鍥炬爣 + * @param baseQueryObject 鏌ヨ瀵硅薄 + * @return 鍥炬爣淇℃伅 + */ + List<PLIconGroupVO> getAllIcon(BaseQueryObject baseQueryObject); + + /** + * 鑾峰彇鍥炬爣琛ㄦ牸鏁版嵁 + * @param baseQueryObject 鏌ヨ瀵硅薄 + * @return 鍥炬爣淇℃伅 + */ + DataGrid<PLIconVO> getGrid(BaseQueryObject baseQueryObject); +} diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLifeCycleServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLifeCycleServiceImpl.java index f6e0480..f05c4d7 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLifeCycleServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLifeCycleServiceImpl.java @@ -129,7 +129,7 @@ public void transStatus(List<BusinessObject> boList, String targetStatus) throws VciBaseException { WebUtil.alertNotNull(boList,"涓氬姟鏁版嵁瀵硅薄",targetStatus,"鐩爣瀵硅薄"); - transStatus(boList.toArray(new com.vci.corba.omd.data.BusinessObject[0]), targetStatus); + transStatus(boList.toArray(new BusinessObject[0]), targetStatus); } /** @@ -264,7 +264,7 @@ }else { OsLifeCycleLineEventVO[] eventVOs = new OsLifeCycleLineEventVO[route.transitionVOEvents.length]; for (int i = 0; i < route.transitionVOEvents.length; i++) { - com.vci.corba.omd.lcm.TransitionVOEvent event = route.transitionVOEvents[i]; + TransitionVOEvent event = route.transitionVOEvents[i]; OsLifeCycleLineEventVO eventVO = new OsLifeCycleLineEventVO(); eventVO.setOid(event.id); eventVO.setEventFullName(event.name); @@ -422,7 +422,7 @@ * @return 骞冲彴鐨勮繛鎺ョ嚎瀵硅薄 */ private TransitionVO lifeCycleLineVO2DO(OsLifeCycleLineVO lineVO) throws PLException { - com.vci.corba.omd.lcm.TransitionVO transitionVO = new com.vci.corba.omd.lcm.TransitionVO(); + TransitionVO transitionVO = new TransitionVO(); transitionVO.id = lineVO.getOid(); transitionVO.source = lineVO.getSourceLifeStatus(); transitionVO.destination = lineVO.getTargetLifeStatus(); @@ -1095,7 +1095,7 @@ releaseStatus[i] = ""; } } - com.vci.corba.omd.lcm.TransitionVO[] vos = new com.vci.corba.omd.lcm.TransitionVO[lineVOs.length]; + TransitionVO[] vos = new TransitionVO[lineVOs.length]; for(int i = 0 ; i < lineVOs.length; i ++){ vos[i] = lifeCycleLineVO2DO(lineVOs[i]); } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebIconServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebIconServiceImpl.java new file mode 100644 index 0000000..7e9ddda --- /dev/null +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebIconServiceImpl.java @@ -0,0 +1,267 @@ +package com.vci.web.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.vci.corba.portal.PortalServicePrx; +import com.vci.corba.portal.data.PLIcon; +import com.vci.dto.PLIconDTO; +import com.vci.pagemodel.PLIconGroupVO; +import com.vci.pagemodel.PLIconVO; +import com.vci.starter.web.exception.VciBaseException; +import com.vci.starter.web.pagemodel.BaseQueryObject; +import com.vci.starter.web.pagemodel.DataGrid; +import com.vci.starter.web.pagemodel.PageHelper; +import com.vci.web.service.WebIconserviceI; +import com.vci.web.util.PlatformClientUtil; +import com.vci.web.util.WebUtil; +import edu.stanford.smi.protege.util.HashList; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.io.File; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Description 鍥炬爣鏈嶅姟 + * @Author dangsn + * @Date 2024/12/20 10:27 + */ +@Service +public class WebIconServiceImpl implements WebIconserviceI { + + /** + * 瀹㈡埛绔伐鍏� + */ + @Resource + private PlatformClientUtil platformClientUtil; + + /** + * 瀵煎叆鍥炬爣 + * + * @param type + * @param groups + * @param iconFile 鍥炬爣鏂囦欢 + * @return 鎵ц缁撴灉 + */ + @Override + public void importIcon(String type, String groups, File iconFile) { + try { + String fileContent = FileUtils.readFileToString(iconFile, "UTF-8"); + JSONArray jsonArray = JSON.parseArray(fileContent); + + //鑾峰彇鎵�鏈夌殑鍥炬爣淇℃伅 + PortalServicePrx portalServicePrx = platformClientUtil.getPortalService(); + PLIcon[] iconArr = portalServicePrx.getAllPLIcon(); + List<String> nameList = new ArrayList<>(); + Map<String, PLIcon> iconMap = new HashMap<>(); + for(PLIcon icon : iconArr){ + nameList.add(icon.name); + iconMap.put(icon.name, icon); + } + + List<PLIcon> addList = new ArrayList<>(); + List<PLIcon> updateList = new ArrayList<>(); + + for(int i = 0; i<jsonArray.size(); i++){ + JSONObject jsonObject = jsonArray.getJSONObject(i); + String iconContent = jsonObject.getString("svg"); + String iconName = jsonObject.getString("name").toLowerCase(); + if(nameList.contains(iconName)){ + PLIcon icon = iconMap.get(iconName); + icon.content = iconContent; + icon.type = type; + icon.groups = groups; + updateList.add(icon); + }else{ + PLIcon icon = new PLIcon(); + icon.oid = WebUtil.getPk(); + icon.name = iconName; + icon.content = iconContent; + icon.type = type; + icon.groups = groups; + addList.add(icon); + } + } + + portalServicePrx.batchSavePLIcon(addList.toArray(new PLIcon[0])); + portalServicePrx.batchUpdatePLIcon(updateList.toArray(new PLIcon[0])); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * 鏂板鍥炬爣 + * + * @param iconDTO 鍥炬爣浼犺緭瀵硅薄 + */ + @Override + public void addIcon(PLIconDTO iconDTO) { + WebUtil.alertNotNull(iconDTO.getName(),"鍥炬爣鍚嶇О", iconDTO.getContent(),"鍥炬爣鍐呭"); + + PLIcon plIcon = new PLIcon(); + plIcon.oid = WebUtil.getPk(); + plIcon.name = iconDTO.getName().toLowerCase(); + plIcon.content = iconDTO.getContent(); + plIcon.type = iconDTO.getType(); + plIcon.groups = iconDTO.getGroups(); + + try { + PortalServicePrx portalServicePrx = platformClientUtil.getPortalService(); + portalServicePrx.savePLIcon(plIcon); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * 淇敼鍥炬爣 + * + * @param iconDTO 鍥炬爣浼犺緭瀵硅薄 + */ + @Override + public void editIcon(PLIconDTO iconDTO) { + WebUtil.alertNotNull(iconDTO.getName(),"鍥炬爣鍚嶇О", iconDTO.getContent(),"鍥炬爣鍐呭"); + try { + PortalServicePrx portalServicePrx = platformClientUtil.getPortalService(); + PLIcon plIcon = portalServicePrx.getPLIconByName(iconDTO.getName().toLowerCase()); + if(StringUtils.isBlank(plIcon.oid)){ + throw new VciBaseException("鏈幏鍙栧埌銆�"+iconDTO.getName()+"銆戝浘鏍囦俊鎭紒"); + } + plIcon.content = iconDTO.getContent(); + plIcon.type = iconDTO.getType(); + plIcon.groups = iconDTO.getGroups(); + portalServicePrx.updatePLIcon(plIcon); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * 鍒犻櫎鍥炬爣 + * + * @param iconDTO 鍥炬爣浼犺緭瀵硅薄 + */ + @Override + public void delIcon(PLIconDTO iconDTO) { + WebUtil.alertNotNull(iconDTO.getOid(),"鍥炬爣涓婚敭", iconDTO.getName(),"鍥炬爣鍚嶇О"); + try { + PortalServicePrx portalServicePrx = platformClientUtil.getPortalService(); + portalServicePrx.deletePLIconByName(iconDTO.getName()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * 鑾峰彇鍥炬爣鍚嶇О + * + * @return 鍥炬爣鍚嶇О + */ + @Override + public List<String> getIconName() { + try { + PortalServicePrx portalServicePrx = platformClientUtil.getPortalService(); + String[] nameArr = portalServicePrx.getPLIconName(); + return Arrays.asList(nameArr); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * @param baseQueryObject + * @return + */ + @Override + public List<PLIconGroupVO> getAllIcon(BaseQueryObject baseQueryObject) { + Map<String, String> conditionMap = baseQueryObject.getConditionMap(); + PLIcon plIcon = new PLIcon(); + String iconName = conditionMap.get("name"); + if(StringUtils.isNotBlank(iconName)){ + plIcon.name = iconName.toLowerCase(); + } + plIcon.type = conditionMap.get("type"); + plIcon.groups = conditionMap.get("groups"); + + try { + PortalServicePrx portalServicePrx = platformClientUtil.getPortalService(); + PLIcon[] iconArr = portalServicePrx.getPagePLIcon(plIcon, 0, -1); + + List<PLIconGroupVO> groupVOS = new ArrayList<>(); + List<PLIconVO> voList = COS2VOS(Arrays.asList(iconArr)); + Map<String, List<PLIconVO>> voMap = voList.stream().collect(Collectors.groupingBy(PLIconVO::getLable)); + voMap.forEach((key, value)->{ + PLIconGroupVO groupVO = new PLIconGroupVO(); + groupVO.setLable(key); + groupVO.setList(value); + groupVOS.add(groupVO); + }); + + return groupVOS; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private List<PLIconVO> COS2VOS(List<PLIcon> iconList){ + List<PLIconVO> voList = new ArrayList<>(); + if(!CollectionUtils.isEmpty(iconList)){ + iconList.forEach(co->{ + voList.add(CO2VO(co)); + }); + } + return voList; + } + + private PLIconVO CO2VO(PLIcon icon){ + PLIconVO vo = new PLIconVO(); + vo.setOid(icon.oid); + vo.setName(icon.name); + vo.setContent(icon.content); + vo.setType(icon.type); + vo.setGroups(icon.groups); + String[] nameArr = icon.name.split(":"); + if(nameArr.length > 1){ + vo.setLable(nameArr[0]); + } + return vo; + } + + /** + * 鑾峰彇鍥炬爣琛ㄦ牸鏁版嵁 + * + * @param baseQueryObject 鏌ヨ瀵硅薄 + * @return 鍥炬爣淇℃伅 + */ + @Override + public DataGrid<PLIconVO> getGrid(BaseQueryObject baseQueryObject) { + Map<String, String> conditionMap = baseQueryObject.getConditionMap(); + PageHelper pageHelper = baseQueryObject.getPageHelper(); + PLIcon plIcon = new PLIcon(); + String iconName = conditionMap.get("name"); + if(StringUtils.isNotBlank(iconName)){ + plIcon.name = iconName.toLowerCase(); + } + plIcon.type = conditionMap.get("type"); + plIcon.groups = conditionMap.get("groups"); + try { + PortalServicePrx portalServicePrx = platformClientUtil.getPortalService(); + PLIcon[] iconArr = portalServicePrx.getPagePLIcon(plIcon, pageHelper.getPage(), pageHelper.getLimit()); + List<PLIconVO> voList = COS2VOS(Arrays.asList(iconArr)); + DataGrid<PLIconVO> dataGrid = new DataGrid<>(); + dataGrid.setData(voList); + + long count = portalServicePrx.getCountPLIcon(plIcon); + dataGrid.setTotal(count); + return dataGrid; + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} -- Gitblit v1.9.3