From f2e6e77dc5a984e2fec4416717baa7c47118fcb1 Mon Sep 17 00:00:00 2001 From: yuxc <653031404@qq.com> Date: 星期五, 14 四月 2023 17:26:58 +0800 Subject: [PATCH] 主题库相关的代码实现功能,包括excel导入导出,树形查看等功能 --- Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/constant/ExcelLangCodeConstant.java | 23 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/enumpck/VciEnum.java | 20 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/WriteExcelOption.java | 85 + Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/ExcelColumnMap.java | 71 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeOsbtmtypeDTO.java | 10 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/ControllerUtil.java | 248 +++ Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/LangBaseUtil.java | 32 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/CodeOsbtmtypeClient.java | 20 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeOsbtmtypeServiceImpl.java | 42 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/CodeOsbtmtypeVO.java | 12 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/ReadExcelOption.java | 69 Source/UBCS/ubcs-service-api/ubcs-dict-api/src/main/java/com/vci/ubcs/system/feign/IDictBizClient.java | 2 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/entity/CodeOsattributeEntity.java | 102 + Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/bo/WriteExcelData.java | 244 +++ Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/toolmodel/DateConverter.java | 188 ++ Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/annotation/VciFieldType.java | 15 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeOsbtmtypeController.java | 126 + Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/lCodeClstemplateClient.java | 6 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeOsattributeService.java | 43 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeClassifyController.java | 124 + Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/ICodeOsbtmtypeClient.java | 16 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTOAllcode.java | 4 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/CodeOsattributeVO.java | 13 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeOsbtmtypeService.java | 44 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/util/ExcelUtil.java | 1485 ++++++++++++++++++++ Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/SheetDataSet.java | 43 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/CodeClstemplateClient.java | 4 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/util/LocalFileUtil.java | 318 ++++ Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/mapper/CodeClassifyMapper.java | 24 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/AppendDataExcelOption.java | 60 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/entity/CodeOsbtmtypeEntity.java | 118 + Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeKeyattrrepeatServiceImpl.java | 80 + Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/annotation/ExcelColumn.java | 28 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/enumpck/VciFieldTypeEnum.java | 93 + Source/UBCS/ubcs-service-api/ubcs-dict-api/src/main/java/com/vci/ubcs/system/cache/DictBizCache.java | 2 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/CodeOsattributeDTO.java | 10 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/SheetRowData.java | 33 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/annotation/ExcelTitle.java | 12 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/mapper/CodeOsbtmtypeMapper.java | 43 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/wrapper/CodeOsbtmtypeWrapper.java | 50 Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IDictBizClient.java | 3 Source/UBCS/ubcs-service-api/ubcs-code-api/pom.xml | 12 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java | 64 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/util/PoiImportProcesser.java | 8 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/DownloadTempOption.java | 42 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/util/PoiTemplateProcesser.java | 10 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/CodeOsbtmtypeDTO.java | 10 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeKeyattrrepeatService.java | 27 Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeCLassifyMapper.xml | 15 Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeOsbtmtypeMapper.xml | 42 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/wrapper/CodeButtonWrapper.java | 6 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/CodeOsbtmtypeattributeVO.java | 13 Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/DictBizServiceImpl.java | 10 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeClassifyService.java | 53 54 files changed, 4,194 insertions(+), 83 deletions(-) diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/pom.xml b/Source/UBCS/ubcs-service-api/ubcs-code-api/pom.xml index 05b7282..57b0083 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-code-api/pom.xml +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/pom.xml @@ -58,6 +58,18 @@ <artifactId>staxon</artifactId> <version>1.3</version> </dependency>--> + <!-- poi --> + <dependency> + <groupId>org.apache.poi</groupId> + <artifactId>poi</artifactId> + <version>4.1.0</version> + </dependency> + + <dependency> + <groupId>org.apache.poi</groupId> + <artifactId>poi-ooxml</artifactId> + <version>4.1.0</version> + </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/CodeOsattributeDTO.java similarity index 82% copy from Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java copy to Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/CodeOsattributeDTO.java index 4a775a4..db37b16 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/CodeOsattributeDTO.java @@ -16,19 +16,19 @@ */ package com.vci.ubcs.code.dto; -import com.vci.ubcs.code.entity.CodeAllCode; +import com.vci.ubcs.code.entity.CodeOsattributeEntity; import lombok.Data; import lombok.EqualsAndHashCode; /** - * 鍏ㄩ儴鐮佸�� 鏁版嵁浼犺緭瀵硅薄瀹炰綋绫� + * 灞炴�ф樉绀哄璞� 鏁版嵁浼犺緭瀵硅薄瀹炰綋绫� * - * @author ludc - * @since 2023-04-03 + * @author yuxc + * @since 2023-04-14 */ @Data @EqualsAndHashCode(callSuper = true) -public class CodeCodeAllcodeDTO extends CodeAllCode { +public class CodeOsattributeDTO extends CodeOsattributeEntity { private static final long serialVersionUID = 1L; } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/CodeOsbtmtypeDTO.java similarity index 83% copy from Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java copy to Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/CodeOsbtmtypeDTO.java index 4a775a4..69aca75 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/CodeOsbtmtypeDTO.java @@ -16,19 +16,19 @@ */ package com.vci.ubcs.code.dto; -import com.vci.ubcs.code.entity.CodeAllCode; +import com.vci.ubcs.code.entity.CodeOsbtmtypeEntity; import lombok.Data; import lombok.EqualsAndHashCode; /** - * 鍏ㄩ儴鐮佸�� 鏁版嵁浼犺緭瀵硅薄瀹炰綋绫� + * 涓氬姟绫诲瀷 鏁版嵁浼犺緭瀵硅薄瀹炰綋绫� * - * @author ludc - * @since 2023-04-03 + * @author yuxc + * @since 2023-04-13 */ @Data @EqualsAndHashCode(callSuper = true) -public class CodeCodeAllcodeDTO extends CodeAllCode { +public class CodeOsbtmtypeDTO extends CodeOsbtmtypeEntity { private static final long serialVersionUID = 1L; } diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/entity/CodeOsattributeEntity.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/entity/CodeOsattributeEntity.java new file mode 100644 index 0000000..e547826 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/entity/CodeOsattributeEntity.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.code.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Date; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +/** + * 灞炴�ф樉绀哄璞� 瀹炰綋绫� + * + * @author yuxc + * @since 2023-04-14 + */ +@Data +@TableName("PL_CODE_OSATTRIBUTE") +@ApiModel(value = "CodeOsattribute瀵硅薄", description = "灞炴�ф樉绀哄璞�") +@EqualsAndHashCode(callSuper = true) +public class CodeOsattributeEntity extends BaseModel { + + + /** + * 灞炴�х被鍨嬶紝浣跨敤鏋氫妇VCIFIELDTYPEENUM + */ + @ApiModelProperty(value = "灞炴�х被鍨嬶紝浣跨敤鏋氫妇VCIFIELDTYPEENUM") + private String attributedatatype; + /** + * 灞炴�х被鍨嬫樉绀烘枃鏈� + */ + @ApiModelProperty(value = "灞炴�х被鍨嬫樉绀烘枃鏈�") + private String attributedatatypetext; + /** + * 鏄惁鍙互涓虹┖ + */ + @ApiModelProperty(value = "鏄惁鍙互涓虹┖") + private String nullableflag; + /** + * 榛樿鍊� + */ + @ApiModelProperty(value = "榛樿鍊�") + private String defaultvalue; + /** + * 浣跨敤鏋氫妇鑻辨枃鍚嶇О + */ + @ApiModelProperty(value = "浣跨敤鏋氫妇鑻辨枃鍚嶇О") + private String enumid; + /** + * 浣跨敤鏋氫妇鐨勪腑鏂囧悕绉� + */ + @ApiModelProperty(value = "浣跨敤鏋氫妇鐨勪腑鏂囧悕绉�") + private String enumname; + /** + * 鍙傜収鐨勪笟鍔$被鍨嬬紪鍙� + */ + @ApiModelProperty(value = "鍙傜収鐨勪笟鍔$被鍨嬬紪鍙�") + private String btmtypeid; + /** + * 鍙傜収鐨勪笟鍔$被鍨嬪悕绉� + */ + @ApiModelProperty(value = "鍙傜収鐨勪笟鍔$被鍨嬪悕绉�") + private String btmtypename; + /** + * 灞炴�х殑闀垮害 + */ + @ApiModelProperty(value = "灞炴�х殑闀垮害") + private Short attrlength; + /** + * 灏忔暟绮惧害浣嶆暟 + */ + @ApiModelProperty(value = "灏忔暟绮惧害浣嶆暟") + private Short precisionlength; + /** + * 灏忔暟鍒诲害浣嶆暟 + */ + @ApiModelProperty(value = "灏忔暟鍒诲害浣嶆暟") + private Short scalelength; + /** + * 鍙栧�艰寖鍥� + */ + @ApiModelProperty(value = "鍙栧�艰寖鍥�") + private String range; + + +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/entity/CodeOsbtmtypeEntity.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/entity/CodeOsbtmtypeEntity.java new file mode 100644 index 0000000..401da89 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/entity/CodeOsbtmtypeEntity.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.code.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.EqualsAndHashCode; + +/** + * 涓氬姟绫诲瀷 瀹炰綋绫� + * + * @author yuxc + * @since 2023-04-13 + */ +@Data +@TableName("PL_CODE_OSBTMTYPE") +@ApiModel(value = "PLCodeOsbtmtype瀵硅薄", description = "涓氬姟绫诲瀷") +@EqualsAndHashCode(callSuper = true) +public class CodeOsbtmtypeEntity extends BaseModel { + + /** + * 搴忓垪鍖� + */ + private static final long serialVersionUID = -7142347409100551299L; + + /** + * 鏁版嵁搴撹〃鐨勫悕绉� + */ + @ApiModelProperty(value = "鏁版嵁搴撹〃鐨勫悕绉�") + private String tableName; + /** + * 鐗堟湰瑙勫垯鐨勭紪鍙� + */ + @ApiModelProperty(value = "鐗堟湰瑙勫垯鐨勭紪鍙�") + private String revisionruleid; + /** + * 鐗堟湰瑙勫垯鐨勫悕绉� + */ + @ApiModelProperty(value = "鐗堟湰瑙勫垯鐨勫悕绉�") + private String revisionrulename; + /** + * 鍒嗛殧绗� + */ + @ApiModelProperty(value = "鍒嗛殧绗�") + private Short revisionsep; + /** + * 鏄惁鎵嬪姩杈撳叆鐗堟湰 + */ + @ApiModelProperty(value = "鏄惁鎵嬪姩杈撳叆鐗堟湰") + private String inputrevisionflag; + /** + * 鏄惁鎺у埗瀵嗙骇 + */ + @ApiModelProperty(value = "鏄惁鎺у埗瀵嗙骇") + private String secretflag; + /** + * 鏄惁鎶借薄鍖� + */ + @ApiModelProperty(value = "鏄惁鎶借薄鍖�") + private String abstractflag; + /** + * 瀹炰緥鍖栫被 + */ + @ApiModelProperty(value = "瀹炰緥鍖栫被") + private String implclass; + /** + * C# + */ + @ApiModelProperty(value = "C#") + private String shape; + /** + * 鐢熷懡鍛ㄦ湡鐨勮嫳鏂囧悕绉� + */ + @ApiModelProperty(value = "鐢熷懡鍛ㄦ湡鐨勮嫳鏂囧悕绉�") + private String lifecycleid; + /** + * 鐢熷懡鍛ㄦ湡鐨勪腑鏂囧悕绉� + */ + @ApiModelProperty(value = "鐢熷懡鍛ㄦ湡鐨勪腑鏂囧悕绉�") + private String lifecyclename; + /** + * 澶囩敤鐢熷懡鍛ㄦ湡鑻辨枃鍚嶇О + */ + @ApiModelProperty(value = "澶囩敤鐢熷懡鍛ㄦ湡鑻辨枃鍚嶇О") + private String sublifecycleid; + /** + * 澶囩敤鐢熷懡鍛ㄦ湡涓枃鍚嶇О + */ + @ApiModelProperty(value = "澶囩敤鐢熷懡鍛ㄦ湡涓枃鍚嶇О") + private String sublifecyclename; + /** + * 鏄惁涓鸿鍥� + */ + @ApiModelProperty(value = "鏄惁涓鸿鍥�") + private String viewflag; + /** + * 瑙嗗浘鍒涘缓鐨凷QL璇彞 + */ + @ApiModelProperty(value = "瑙嗗浘鍒涘缓鐨凷QL璇彞") + private String viewcreatesql; + +} diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/CodeOsattributeVO.java similarity index 78% copy from Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java copy to Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/CodeOsattributeVO.java index 4a775a4..e2c97b0 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/CodeOsattributeVO.java @@ -14,21 +14,22 @@ * this software without specific prior written permission. * Author: Chill 搴勯獮 (smallchill@163.com) */ -package com.vci.ubcs.code.dto; +package com.vci.ubcs.code.vo; -import com.vci.ubcs.code.entity.CodeAllCode; +import com.vci.ubcs.code.entity.CodeOsattributeEntity; +import org.springblade.core.tool.node.INode; import lombok.Data; import lombok.EqualsAndHashCode; /** - * 鍏ㄩ儴鐮佸�� 鏁版嵁浼犺緭瀵硅薄瀹炰綋绫� + * 灞炴�ф樉绀哄璞� 瑙嗗浘瀹炰綋绫� * - * @author ludc - * @since 2023-04-03 + * @author yuxc + * @since 2023-04-14 */ @Data @EqualsAndHashCode(callSuper = true) -public class CodeCodeAllcodeDTO extends CodeAllCode { +public class CodeOsattributeVO extends CodeOsattributeEntity { private static final long serialVersionUID = 1L; } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/CodeOsbtmtypeVO.java similarity index 81% copy from Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java copy to Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/CodeOsbtmtypeVO.java index 4a775a4..96d3530 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/CodeOsbtmtypeVO.java @@ -14,21 +14,21 @@ * this software without specific prior written permission. * Author: Chill 搴勯獮 (smallchill@163.com) */ -package com.vci.ubcs.code.dto; +package com.vci.ubcs.code.vo; -import com.vci.ubcs.code.entity.CodeAllCode; +import com.vci.ubcs.code.entity.CodeOsbtmtypeEntity; import lombok.Data; import lombok.EqualsAndHashCode; /** - * 鍏ㄩ儴鐮佸�� 鏁版嵁浼犺緭瀵硅薄瀹炰綋绫� + * 涓氬姟绫诲瀷 瑙嗗浘瀹炰綋绫� * - * @author ludc - * @since 2023-04-03 + * @author yuxc + * @since 2023-04-13 */ @Data @EqualsAndHashCode(callSuper = true) -public class CodeCodeAllcodeDTO extends CodeAllCode { +public class CodeOsbtmtypeVO extends CodeOsbtmtypeEntity { private static final long serialVersionUID = 1L; } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/CodeOsbtmtypeattributeVO.java similarity index 76% copy from Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java copy to Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/CodeOsbtmtypeattributeVO.java index 4a775a4..05b1140 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/CodeOsbtmtypeattributeVO.java @@ -14,21 +14,22 @@ * this software without specific prior written permission. * Author: Chill 搴勯獮 (smallchill@163.com) */ -package com.vci.ubcs.code.dto; +package com.vci.ubcs.code.vo; -import com.vci.ubcs.code.entity.CodeAllCode; +import com.vci.ubcs.code.entity.CodeOsbtmtypeattributeEntity; +import org.springblade.core.tool.node.INode; import lombok.Data; import lombok.EqualsAndHashCode; /** - * 鍏ㄩ儴鐮佸�� 鏁版嵁浼犺緭瀵硅薄瀹炰綋绫� + * 涓氬姟绫诲瀷鍖呭惈鐨勫睘鎬� 瑙嗗浘瀹炰綋绫� * - * @author ludc - * @since 2023-04-03 + * @author yuxc + * @since 2023-04-14 */ @Data @EqualsAndHashCode(callSuper = true) -public class CodeCodeAllcodeDTO extends CodeAllCode { +public class CodeOsbtmtypeattributeVO extends CodeOsbtmtypeattributeEntity { private static final long serialVersionUID = 1L; } diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/bo/WriteExcelData.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/bo/WriteExcelData.java new file mode 100644 index 0000000..b8f13ac --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/bo/WriteExcelData.java @@ -0,0 +1,244 @@ +package com.vci.ubcs.com.vci.starter.bo; + +import java.util.List; + +public class WriteExcelData { + private int row; + private int col; + private Object obj; + private boolean merged = false; + private int rowTo; + private int colTo; + private boolean copyStyle = false; + private int copyStyleRow; + private int copyStyleCol; + private boolean center; + private boolean formula = false; + private boolean nameRefer = false; + private boolean validation = false; + private List<String> validationDataList; + private String validationErrorMsg; + private String fontColor; + private String align; + private String dateFormat; + private boolean readOnly; + private Integer width; + + public String getFontColor() { + return this.fontColor; + } + + public void setFontColor(String fontColor) { + this.fontColor = fontColor; + } + + public String getAlign() { + return this.align; + } + + public void setAlign(String align) { + this.align = align; + } + + public List<String> getValidationDataList() { + return this.validationDataList; + } + + public void setValidationDataList(List<String> validationDataList) { + this.validationDataList = validationDataList; + } + + public WriteExcelData() { + } + + public WriteExcelData(int row, int col, Object obj) { + this.row = row; + this.col = col; + this.obj = obj; + } + + public void writeFormula(int row, int col, String foumula) { + this.row = row; + this.col = col; + this.obj = foumula; + this.formula = true; + } + + public void writeNameRefer(int row, int col, int rowTo, int colTo, String name) { + this.row = row; + this.col = col; + this.obj = name; + this.nameRefer = true; + this.rowTo = rowTo; + this.colTo = colTo; + } + + public void writeComboBox(List<String> comboBoxData, int row, int col, int rowTo, int colTo) { + this.writeComboBox(comboBoxData, (String)null, row, col, rowTo, colTo); + } + + public void writeComboBox(List<String> comboBoxData, String errorMsg, int row, int col, int rowTo, int colTo) { + this.validationDataList = comboBoxData; + this.validation = true; + this.validationErrorMsg = errorMsg; + this.row = row; + this.col = col; + this.rowTo = rowTo; + this.colTo = colTo; + } + + public void writeUseRefer(String referFormula, int row, int col, int rowTo, int colTo) { + this.writeUseRefer(referFormula, (String)null, row, col, rowTo, colTo); + } + + public void writeUseRefer(String referFormula, String errorMsg, int row, int col, int rowTo, int colTo) { + this.validation = true; + this.obj = referFormula; + this.validationErrorMsg = errorMsg; + this.row = row; + this.col = col; + this.rowTo = rowTo; + this.colTo = colTo; + } + + public boolean isReadOnly() { + return this.readOnly; + } + + public void setReadOnly(boolean readOnly) { + this.readOnly = readOnly; + } + + public int getRow() { + return this.row; + } + + public void setRow(int row) { + this.row = row; + } + + public int getCol() { + return this.col; + } + + public void setCol(int col) { + this.col = col; + } + + public Object getObj() { + return this.obj; + } + + public void setObj(Object obj) { + this.obj = obj; + } + + public boolean isMerged() { + return this.merged; + } + + public void setMerged(boolean merged) { + this.merged = merged; + } + + public int getRowTo() { + return this.rowTo; + } + + public void setRowTo(int rowTo) { + this.rowTo = rowTo; + } + + public int getColTo() { + return this.colTo; + } + + public void setColTo(int colTo) { + this.colTo = colTo; + } + + public boolean isCopyStyle() { + return this.copyStyle; + } + + public void setCopyStyle(boolean copyStyle) { + this.copyStyle = copyStyle; + } + + public int getCopyStyleRow() { + return this.copyStyleRow; + } + + public void setCopyStyleRow(int copyStyleRow) { + this.copyStyleRow = copyStyleRow; + } + + public int getCopyStyleCol() { + return this.copyStyleCol; + } + + public void setCopyStyleCol(int copyStyleCol) { + this.copyStyleCol = copyStyleCol; + } + + public boolean isCenter() { + return this.center; + } + + public void setCenter(boolean center) { + this.center = center; + } + + public boolean isFormula() { + return this.formula; + } + + public void setFormula(boolean formula) { + this.formula = formula; + } + + public boolean isNameRefer() { + return this.nameRefer; + } + + public void setNameRefer(boolean nameRefer) { + this.nameRefer = nameRefer; + } + + public boolean isValidation() { + return this.validation; + } + + public void setValidation(boolean validation) { + this.validation = validation; + } + + public String getValidationErrorMsg() { + return this.validationErrorMsg; + } + + public void setValidationErrorMsg(String validationErrorMsg) { + this.validationErrorMsg = validationErrorMsg; + } + + public String getDateFormat() { + return this.dateFormat; + } + + public void setDateFormat(String dateFormat) { + this.dateFormat = dateFormat; + } + + public Integer getWidth() { + return this.width; + } + + public void setWidth(Integer width) { + this.width = width; + } + + public String toString() { + return "WriteExcelData{row=" + this.row + ", col=" + this.col + ", obj=" + this.obj + ", merged=" + this.merged + ", rowTo=" + this.rowTo + ", colTo=" + this.colTo + ", copyStyle=" + this.copyStyle + ", copyStyleRow=" + this.copyStyleRow + ", copyStyleCol=" + this.copyStyleCol + ", center=" + this.center + ", formula=" + this.formula + ", nameRefer=" + this.nameRefer + ", validation=" + this.validation + ", validationDataList=" + this.validationDataList + ", validationErrorMsg='" + this.validationErrorMsg + '\'' + ", fontColor='" + this.fontColor + '\'' + ", align='" + this.align + '\'' + ", dateFormat='" + this.dateFormat + '\'' + ", readOnly=" + this.readOnly + '}'; + } +} + diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/annotation/ExcelColumn.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/annotation/ExcelColumn.java new file mode 100644 index 0000000..846e998 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/annotation/ExcelColumn.java @@ -0,0 +1,28 @@ +package com.vci.ubcs.com.vci.starter.poi.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface ExcelColumn { + String value(); + + boolean nullable() default true; + + String enumId() default ""; + + String regExg() default ""; + + String regExgTitle() default ""; + + String group() default ""; + + boolean rowIndexColumn() default false; + + boolean readOnly() default false; + + int width() default 0; +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/annotation/ExcelTitle.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/annotation/ExcelTitle.java new file mode 100644 index 0000000..f5f6359 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/annotation/ExcelTitle.java @@ -0,0 +1,12 @@ +package com.vci.ubcs.com.vci.starter.poi.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface ExcelTitle { + int rowIndexForTitle() default 1; +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/AppendDataExcelOption.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/AppendDataExcelOption.java new file mode 100644 index 0000000..19c179d --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/AppendDataExcelOption.java @@ -0,0 +1,60 @@ +package com.vci.ubcs.com.vci.starter.poi.bo; + +import java.io.Serializable; +import java.util.List; + +public class AppendDataExcelOption implements Serializable { + private int titleRowIndex = 0; + private String sheetName; + private List<String> writeFields; + private List<String> readOnlyFields; + private boolean readOnlyFromField = false; + + public AppendDataExcelOption() { + } + + public int getTitleRowIndex() { + return this.titleRowIndex; + } + + public void setTitleRowIndex(int titleRowIndex) { + this.titleRowIndex = titleRowIndex; + } + + public String getSheetName() { + return this.sheetName; + } + + public void setSheetName(String sheetName) { + this.sheetName = sheetName; + } + + public List<String> getWriteFields() { + return this.writeFields; + } + + public void setWriteFields(List<String> writeFields) { + this.writeFields = writeFields; + } + + public List<String> getReadOnlyFields() { + return this.readOnlyFields; + } + + public void setReadOnlyFields(List<String> readOnlyFields) { + this.readOnlyFields = readOnlyFields; + } + + public boolean isReadOnlyFromField() { + return this.readOnlyFromField; + } + + public void setReadOnlyFromField(boolean readOnlyFromField) { + this.readOnlyFromField = readOnlyFromField; + } + + public String toString() { + return "AppendDataExcelOption{titleRowIndex=" + this.titleRowIndex + ", sheetName='" + this.sheetName + '\'' + ", writeFields=" + this.writeFields + ", readOnlyFields=" + this.readOnlyFields + ", readOnlyFromField=" + this.readOnlyFromField + '}'; + } +} + diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/DownloadTempOption.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/DownloadTempOption.java new file mode 100644 index 0000000..6637221 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/DownloadTempOption.java @@ -0,0 +1,42 @@ +package com.vci.ubcs.com.vci.starter.poi.bo; + + +import java.io.Serializable; + +public class DownloadTempOption implements Serializable { + private Integer defaultRowSize = 1000; + private String excelName; + private String sheetName; + + public DownloadTempOption(String excelName) { + this.excelName = excelName; + } + + public String getExcelName() { + return this.excelName; + } + + public void setExcelName(String excelName) { + this.excelName = excelName; + } + + public Integer getDefaultRowSize() { + return this.defaultRowSize; + } + + public void setDefaultRowSize(Integer defaultRowSize) { + this.defaultRowSize = defaultRowSize; + } + + public String getSheetName() { + return this.sheetName; + } + + public void setSheetName(String sheetName) { + this.sheetName = sheetName; + } + + public String toString() { + return "DownloadTempOption{defaultRowSize=" + this.defaultRowSize + '}'; + } +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/ExcelColumnMap.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/ExcelColumnMap.java new file mode 100644 index 0000000..48b5c29 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/ExcelColumnMap.java @@ -0,0 +1,71 @@ +package com.vci.ubcs.com.vci.starter.poi.bo; + +public class ExcelColumnMap { + private String title; + private String columnName; + private boolean nullable = true; + private String regExg; + private String regExgTitle; + private String group; + + public ExcelColumnMap() { + } + + public ExcelColumnMap(String title, String columnName) { + this.title = title; + this.columnName = columnName; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getColumnName() { + return this.columnName; + } + + public void setColumnName(String columnName) { + this.columnName = columnName; + } + + public boolean isNullable() { + return this.nullable; + } + + public void setNullable(boolean nullable) { + this.nullable = nullable; + } + + public String getRegExg() { + return this.regExg; + } + + public void setRegExg(String regExg) { + this.regExg = regExg; + } + + public String getRegExgTitle() { + return this.regExgTitle; + } + + public void setRegExgTitle(String regExgTitle) { + this.regExgTitle = regExgTitle; + } + + public String getGroup() { + return this.group; + } + + public void setGroup(String group) { + this.group = group; + } + + public String toString() { + return "ExcelColumnMap{title='" + this.title + '\'' + ", columnName='" + this.columnName + '\'' + ", nullable=" + this.nullable + ", regExg='" + this.regExg + '\'' + ", regExgTitle='" + this.regExgTitle + '\'' + ", group='" + this.group + '\'' + '}'; + } +} + diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/ReadExcelOption.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/ReadExcelOption.java new file mode 100644 index 0000000..909ea59 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/ReadExcelOption.java @@ -0,0 +1,69 @@ +package com.vci.ubcs.com.vci.starter.poi.bo; + + +import java.util.List; +import java.util.Map; + +public class ReadExcelOption { + private int fristRow = 1; + private int sheetIndex = 0; + private String sheetName; + private boolean readAllSheet = false; + private Map<String, List<ExcelColumnMap>> extendAttrMap; + + public String getSheetName() { + return this.sheetName; + } + + public void setSheetName(String sheetName) { + this.sheetName = sheetName; + } + + public ReadExcelOption() { + } + + public ReadExcelOption(int fristRow) { + this.fristRow = fristRow; + } + + public ReadExcelOption(int fristRow, boolean readAllSheet) { + this.fristRow = fristRow; + this.readAllSheet = readAllSheet; + } + + public int getFristRow() { + return this.fristRow; + } + + public void setFristRow(int fristRow) { + this.fristRow = fristRow; + } + + public int getSheetIndex() { + return this.sheetIndex; + } + + public void setSheetIndex(int sheetIndex) { + this.sheetIndex = sheetIndex; + } + + public boolean isReadAllSheet() { + return this.readAllSheet; + } + + public void setReadAllSheet(boolean readAllSheet) { + this.readAllSheet = readAllSheet; + } + + public Map<String, List<ExcelColumnMap>> getExtendAttrMap() { + return this.extendAttrMap; + } + + public void setExtendAttrMap(Map<String, List<ExcelColumnMap>> extendAttrMap) { + this.extendAttrMap = extendAttrMap; + } + + public String toString() { + return "ReadExcelOption{fristRow=" + this.fristRow + ", sheetIndex=" + this.sheetIndex + ", sheetName='" + this.sheetName + '\'' + ", readAllSheet=" + this.readAllSheet + ", extendAttrMap=" + this.extendAttrMap + '}'; + } +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/SheetDataSet.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/SheetDataSet.java new file mode 100644 index 0000000..21061da --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/SheetDataSet.java @@ -0,0 +1,43 @@ +package com.vci.ubcs.com.vci.starter.poi.bo; + + +import java.util.ArrayList; +import java.util.List; + +public class SheetDataSet { + private String sheetName; + private List<String> colName = new ArrayList(); + private List<SheetRowData> rowData = new ArrayList(); + + public SheetDataSet() { + } + + public String getSheetName() { + return this.sheetName; + } + + public void setSheetName(String sheetName) { + this.sheetName = sheetName; + } + + public List<SheetRowData> getRowData() { + return this.rowData; + } + + public void setRowData(List<SheetRowData> rowData) { + this.rowData = rowData; + } + + public List<String> getColName() { + return this.colName; + } + + public void setColName(List<String> colName) { + this.colName = colName; + } + + public String toString() { + return "SheetDataSet{sheetName='" + this.sheetName + '\'' + ", colName=" + this.colName + ", rowData=" + this.rowData + '}'; + } +} + diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/SheetRowData.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/SheetRowData.java new file mode 100644 index 0000000..590a2f2 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/SheetRowData.java @@ -0,0 +1,33 @@ +package com.vci.ubcs.com.vci.starter.poi.bo; + +import java.util.HashMap; +import java.util.Map; + +public class SheetRowData { + private String rowIndex; + private Map<Integer, String> data = new HashMap(); + + public SheetRowData() { + } + + public String getRowIndex() { + return this.rowIndex; + } + + public void setRowIndex(String rowIndex) { + this.rowIndex = rowIndex; + } + + public Map<Integer, String> getData() { + return this.data; + } + + public void setData(Map<Integer, String> data) { + this.data = data; + } + + public String toString() { + return "SheetRowData{rowIndex='" + this.rowIndex + '\'' + ", data=" + this.data + '}'; + } +} + diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/WriteExcelOption.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/WriteExcelOption.java new file mode 100644 index 0000000..19dcd25 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/bo/WriteExcelOption.java @@ -0,0 +1,85 @@ +package com.vci.ubcs.com.vci.starter.poi.bo; + + +import com.vci.ubcs.com.vci.starter.bo.WriteExcelData; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class WriteExcelOption { + private Map<String, List<WriteExcelData>> writeDataMap; + private List<String> hideSheetList; + private boolean append = false; + private boolean revision07 = false; + private Map<String, List<ExcelColumnMap>> extendAttrMap; + + public WriteExcelOption() { + } + + public WriteExcelOption(List<WriteExcelData> excelDataList) { + this.writeDataMap = new HashMap(); + this.writeDataMap.put("Sheet1", excelDataList); + } + + public void addSheetDataList(String sheetName, List<WriteExcelData> excelDataList) { + if (this.writeDataMap == null) { + this.writeDataMap = new HashMap(); + } + + this.writeDataMap.put(sheetName, excelDataList); + } + + public void addHideSheet(String sheetName) { + if (this.hideSheetList == null) { + this.hideSheetList = new ArrayList(); + } + + this.hideSheetList.add(sheetName); + } + + public Map<String, List<WriteExcelData>> getWriteDataMap() { + return this.writeDataMap; + } + + public void setWriteDataMap(Map<String, List<WriteExcelData>> writeDataMap) { + this.writeDataMap = writeDataMap; + } + + public List<String> getHideSheetList() { + return this.hideSheetList; + } + + public void setHideSheetList(List<String> hideSheetList) { + this.hideSheetList = hideSheetList; + } + + public boolean isAppend() { + return this.append; + } + + public void setAppend(boolean append) { + this.append = append; + } + + public boolean isRevision07() { + return this.revision07; + } + + public void setRevision07(boolean revision07) { + this.revision07 = revision07; + } + + public Map<String, List<ExcelColumnMap>> getExtendAttrMap() { + return this.extendAttrMap; + } + + public void setExtendAttrMap(Map<String, List<ExcelColumnMap>> extendAttrMap) { + this.extendAttrMap = extendAttrMap; + } + + public String toString() { + return "WriteExcelOption{writeDataMap=" + this.writeDataMap + ", hideSheetList=" + this.hideSheetList + ", append=" + this.append + ", revision07=" + this.revision07 + ", extendAttrMap=" + this.extendAttrMap + '}'; + } +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/constant/ExcelLangCodeConstant.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/constant/ExcelLangCodeConstant.java new file mode 100644 index 0000000..5edd706 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/constant/ExcelLangCodeConstant.java @@ -0,0 +1,23 @@ +package com.vci.ubcs.com.vci.starter.poi.constant; + +public class ExcelLangCodeConstant { + public static final String READ_IMPORT_FILE_FAIL = "readImportFileFail"; + public static final String IMPORT_CONTENT_NULL = "importContentNull"; + public static final String FILE_NOT_FOUND = "fileNotFound"; + public static final String FILE_IO_EXCEPTION = "fileIoException"; + public static final String FILE_CREATE_EXCEPTION = "fileCreateException"; + public static final String INPUT_STREAM_IS_NULL = "inputStreamIsNull"; + public static final String OUTPUT_STREAM_IS_NULL = "outputStreamIsNull"; + public static final String WORKBOOK_INIT_FAIL = "workBookInitFail"; + public static final String CELL_VALUE_CAN_NOT_NULL = "cellValueCanNotNull"; + public static final String CELL_VALUE_CAN_NOT_NULL_FOR_REG = "cellValueCanNotNullForReg"; + public static final String CELL_VALUE_NOT_EQUAL_REG = "cellValueNotEqualReg"; + public static final String CELL_NOT_DATE_FORMATE = "cellNotDateFormate"; + + public ExcelLangCodeConstant() { + } +} + + + + diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/util/ExcelUtil.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/util/ExcelUtil.java new file mode 100644 index 0000000..f4b549d --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/util/ExcelUtil.java @@ -0,0 +1,1485 @@ +package com.vci.ubcs.com.vci.starter.poi.util; + +import com.vci.ubcs.com.vci.starter.bo.WriteExcelData; +import com.vci.ubcs.com.vci.starter.exception.VciBaseException; +import com.vci.ubcs.com.vci.starter.poi.annotation.ExcelColumn; +import com.vci.ubcs.com.vci.starter.poi.annotation.ExcelTitle; +import com.vci.ubcs.com.vci.starter.poi.bo.*; +import com.vci.ubcs.com.vci.starter.util.LocalFileUtil; +import com.vci.ubcs.com.vci.starter.web.annotation.VciFieldType; +import com.vci.ubcs.com.vci.starter.web.enumpck.VciFieldTypeEnum; +import com.vci.ubcs.com.vci.starter.web.util.LangBaseUtil; +import com.vci.ubcs.com.vci.starter.web.util.VciBaseUtil; +import org.apache.commons.io.IOUtils; +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.CellRangeAddressList; +import org.apache.poi.xssf.usermodel.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.util.CollectionUtils; + +import java.io.*; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.nio.channels.FileChannel; +import java.util.*; +import java.util.stream.Collectors; + +public class ExcelUtil { + private static Logger logger = LoggerFactory.getLogger(ExcelUtil.class); + public static final String KEY_ATTR_CHAR = "鈽�"; + public static final String REQUIRED_CHAR = "*"; + + public ExcelUtil() { + } + + public static void copyFile(File source, File target) throws VciBaseException { + VciBaseUtil.alertNotNull(new Object[]{source, "鏉ユ簮鏂囦欢", target, "鐩爣鏂囦欢"}); + if (!source.exists()) { + throw new VciBaseException("fileNotFound", new String[]{source.getName()}); + } else { + File is; + if (!target.exists()) { + is = target.getParentFile(); + is.mkdirs(); + + try { + target.createNewFile(); + } catch (IOException var17) { + throw new VciBaseException("fileIoException", new String[]{target.getName()}); + } + } + + is = null; + FileOutputStream os = null; + + FileInputStream isF; + try { + isF = new FileInputStream(source); + } catch (FileNotFoundException var16) { + throw new VciBaseException("fileNotFound", new String[]{source.getName()}); + } + + try { + os = new FileOutputStream(target); + } catch (FileNotFoundException var15) { + IOUtils.closeQuietly(isF); + throw new VciBaseException("fileNotFound", new String[]{target.getName()}); + } + + try { + copyFile(isF, os); + } catch (VciBaseException var12) { + throw var12; + } catch (Throwable var13) { + throw new VciBaseException(LangBaseUtil.getErrorMsg(var13), new String[]{source.getName(), target.getName()}, var13); + } finally { + IOUtils.closeQuietly(isF); + IOUtils.closeQuietly(os); + } + + } + } + + public static void copyFile(FileInputStream in, FileOutputStream os) throws VciBaseException { + try { + FileChannel sourceChannel = in.getChannel(); + FileChannel targetChannel = os.getChannel(); + int i = 0; + int length = 2097152; + + while(true) { + if (sourceChannel.position() == sourceChannel.size()) { + sourceChannel.close(); + targetChannel.close(); + } + + if (sourceChannel.size() - sourceChannel.position() < 20971520L) { + length = (int)(sourceChannel.size() - sourceChannel.position()); + } else { + length = 20971520; + } + + sourceChannel.transferTo(sourceChannel.position(), (long)length, targetChannel); + sourceChannel.position(sourceChannel.position() + (long)length); + ++i; + } + } catch (IOException var10) { + if (logger.isErrorEnabled()) { + logger.error("鎷疯礉婧愭枃浠跺埌鐩爣鏂囦欢鍑虹幇浜嗛敊璇�", var10); + } + + throw new VciBaseException(LangBaseUtil.getErrorMsg(var10), new String[0], var10); + } catch (Throwable var11) { + if (logger.isErrorEnabled()) { + logger.error("鎷疯礉婧愭枃浠跺埌鐩爣鏂囦欢鍑虹幇浜嗛敊璇�", var11); + } + + throw new VciBaseException(LangBaseUtil.getErrorMsg(var11), new String[0], var11); + } finally { + IOUtils.closeQuietly(in); + IOUtils.closeQuietly(os); + } + } + + public static void copyFileFromJar(String filePathInJar, File targetFile) throws VciBaseException { + VciBaseUtil.alertNotNull(new Object[]{filePathInJar, "鏉ユ簮鏂囦欢", targetFile, "鐩爣鏂囦欢"}); + File os; + if (!targetFile.exists()) { + os = targetFile.getParentFile(); + os.mkdirs(); + + try { + targetFile.createNewFile(); + } catch (IOException var12) { + throw new VciBaseException("fileIoException", new String[]{targetFile.getName()}); + } + } + + os = null; + InputStream ins = null; + + FileOutputStream osF; + try { + osF = new FileOutputStream(targetFile); + } catch (FileNotFoundException var11) { + throw new VciBaseException("fileNotFound", new String[]{targetFile.getName()}); + } + + try { + ins = ExcelUtil.class.getResourceAsStream(filePathInJar); + IOUtils.copy(ins, osF); + } catch (IOException var13) { + if (logger.isErrorEnabled()) { + logger.error("鎷疯礉婧愭枃浠跺埌鐩爣鏂囦欢鍑虹幇浜嗛敊璇�", var13); + } + + throw new VciBaseException(LangBaseUtil.getErrorMsg(var13), new String[0], var13); + } catch (Throwable var14) { + if (logger.isErrorEnabled()) { + logger.error("鎷疯礉婧愭枃浠跺埌鐩爣鏂囦欢鍑虹幇浜嗛敊璇�", var14); + } + + throw new VciBaseException(LangBaseUtil.getErrorMsg(var14), new String[0], var14); + } finally { + IOUtils.closeQuietly(ins); + IOUtils.closeQuietly(osF); + } + + } + + public static void writeDataToFile(String fileName, WriteExcelOption writeExcelOption) throws VciBaseException { + writeDataToFile(new File(fileName), writeExcelOption); + } + + public static void writeDataToFile(File file, WriteExcelOption writeExcelOption) throws VciBaseException { + if (file == null) { + throw new VciBaseException("鏂囦欢涓虹┖锛屾棤娉曟壘鍒版枃浠�"); + } else { + if (!file.exists()) { + File folder = file.getParentFile(); + if (!folder.exists()) { + folder.mkdirs(); + } + + try { + file.createNewFile(); + } catch (IOException var14) { + throw new VciBaseException("fileNotFound", new String[]{file.getName()}); + } + } + + Workbook workbook = null; + if (writeExcelOption != null && writeExcelOption.isAppend()) { + try { + if (file.length() == 0L) { + workbook = createWorkbook(false); + } else { + workbook = getWorkbookByInputStream(new FileInputStream(file)); + } + } catch (FileNotFoundException var13) { + throw new VciBaseException("fileNotExist", new String[]{file.getName()}, var13); + } + } + + OutputStream os = null; + + try { + os = new FileOutputStream(file); + } catch (FileNotFoundException var12) { + throw new VciBaseException("fileNotFound", new String[]{var12.getMessage()}, var12); + } + + try { + writeDataToFile(os, writeExcelOption, workbook); + } catch (VciBaseException var15) { + if (logger.isErrorEnabled()) { + logger.error("鍐欏叆鏁版嵁鍒癳xcel鍑洪敊", var15); + } + + throw var15; + } catch (Throwable var16) { + if (logger.isErrorEnabled()) { + logger.error("鍐欏叆鏁版嵁鍒癳xcel鍑洪敊", var16); + } + + throw new VciBaseException(LangBaseUtil.getErrorMsg(var16), new String[0], var16); + } finally { + IOUtils.closeQuietly(os); + } + + } + } + + public static void writeDataToFile(OutputStream os, WriteExcelOption writeExcelOption) throws VciBaseException { + writeDataToFile(os, writeExcelOption, (Workbook)null); + } + + public static void writeDataToFile(OutputStream os, WriteExcelOption writeExcelOption, Workbook workbook) throws VciBaseException { + if (os == null) { + throw new VciBaseException("outputStreamIsNull"); + } else { + if (writeExcelOption == null) { + IOUtils.closeQuietly(os); + } else { + Workbook wb = null; + if (writeExcelOption.isAppend() && workbook != null) { + wb = workbook; + } else { + wb = createWorkbook(writeExcelOption.isRevision07()); + } + + Workbook finalWb = wb; + writeExcelOption.getWriteDataMap().forEach((sheetName, excelDataList) -> { + Sheet sheet = getSheetByWorkbook(finalWb, sheetName); + + try { + writeDataToCell(sheet, excelDataList); + } catch (VciBaseException var6) { + IOUtils.closeQuietly(os); + throw var6; + } catch (Throwable var7) { + if (logger.isErrorEnabled()) { + logger.error("鍐欏叆鏁版嵁鍒板伐浣滅翱鍑洪敊", var7); + } + + IOUtils.closeQuietly(os); + throw new VciBaseException(LangBaseUtil.getErrorMsg(var7), new String[0], var7); + } + }); + if (!CollectionUtils.isEmpty(writeExcelOption.getHideSheetList())) { + Workbook finalWb1 = wb; + writeExcelOption.getHideSheetList().stream().forEach((sheetName) -> { + Sheet sheet = getSheetByWorkbook(finalWb1, sheetName); + finalWb1.setSheetHidden(finalWb1.getSheetIndex(sheet), true); + }); + } + + try { + wb.write(os); + } catch (IOException var13) { + if (logger.isErrorEnabled()) { + logger.error("鎶婂伐浣滅翱涓婄殑鏁版嵁鍐欏叆鍒版枃浠跺嚭閿�", var13); + } + + throw new VciBaseException(LangBaseUtil.getErrorMsg(var13), new String[0], var13); + } finally { + IOUtils.closeQuietly(os); + + try { + wb.close(); + } catch (Throwable var12) { + if (logger.isErrorEnabled()) { + logger.error("鍏抽棴宸ヤ綔绨�", var12); + } + } + + } + } + + } + } + + public static int getCellIndexForPoField(String excelFileName, String sheetName, Class<?> poClass, String poFieldName) throws VciBaseException { + return getCellIndexForPoField(new File(excelFileName), sheetName, poClass, poFieldName); + } + + public static int getCellIndexForPoField(File excelFile, String sheetName, Class<?> poClass, String poFieldName) throws VciBaseException { + VciBaseUtil.alertNotNull(new Object[]{excelFile, "excel鐨勬枃浠�", poClass, "poi瀵煎叆瀵煎嚭瀵硅薄鎵�灞炵殑绫�", poFieldName, "灞炴�х殑鍚嶇О"}); + if (!excelFile.exists()) { + throw new VciBaseException("fileNotExist", new String[]{excelFile.getAbsolutePath()}); + } else { + if (StringUtil.isBlank(sheetName)) { + sheetName = "Sheet1"; + } + + Field field = VciBaseUtil.getFieldForObject(poFieldName, poClass); + if (field == null) { + throw new VciBaseException("瀵硅薄涓笉瀛樺湪姝ゅ睘鎬э紝{0}锛寋1}", new String[]{poFieldName, poClass.getName()}); + } else { + if (field.isAnnotationPresent(ExcelColumn.class)) { + ExcelColumn ec = getExcelColumnAnnotation(field); + String columnName = ec.value(); + Workbook workbook = null; + + try { + workbook = getWorkbookByInputStream(new FileInputStream(excelFile)); + } catch (FileNotFoundException var15) { + throw new VciBaseException("fileNotExist", new String[]{excelFile.getAbsolutePath()}); + } + + if (workbook != null) { + Sheet sheet = workbook.getSheet(sheetName); + if (sheet != null) { + Row row = sheet.getRow(getRowIndexForTitle(poClass)); + if (row != null) { + short lastCellNum = row.getLastCellNum(); + + for(short i = 0; i < lastCellNum; ++i) { + Cell cell = row.getCell(i); + if (columnName.equals(cell.getStringCellValue())) { + try { + workbook.close(); + } catch (IOException var14) { + logger.error("鍏抽棴宸ヤ綔琛ㄥ嚭鐜伴敊璇�", var14); + } + + return i; + } + } + } + } + } + } + + return -1; + } + } + } + + public static Map<String, Integer> listCellIndexForPO(File excelFile, String sheetName, Class<?> poClass) throws VciBaseException { + VciBaseUtil.alertNotNull(new Object[]{excelFile, "excel鐨勬枃浠�", poClass, "poi瀵煎叆瀵煎嚭瀵硅薄鎵�灞炵殑绫�"}); + if (!excelFile.exists()) { + throw new VciBaseException("fileNotExist", new String[]{excelFile.getAbsolutePath()}); + } else { + if (StringUtil.isBlank(sheetName)) { + sheetName = "Sheet1"; + } + + List<Field> fields = VciBaseUtil.getAllFieldForObj(poClass); + Map<String, Integer> cellIndexMap = new HashMap(); + if (!CollectionUtils.isEmpty(fields)) { + Workbook workbook = null; + + try { + workbook = getWorkbookByInputStream(new FileInputStream(excelFile)); + } catch (FileNotFoundException var14) { + throw new VciBaseException("fileNotExist", new String[]{excelFile.getAbsolutePath()}); + } + + if (workbook != null) { + Sheet sheet = workbook.getSheet(sheetName); + if (sheet != null) { + Row row = sheet.getRow(getRowIndexForTitle(poClass)); + if (row != null) { + Map<String, String> columnNamesMap = new HashMap(); + fields.stream().forEach((field) -> { + if (field.isAnnotationPresent(ExcelColumn.class)) { + ExcelColumn ec = getExcelColumnAnnotation(field); + String columnName = ec.value(); + columnNamesMap.put(columnName, field.getName()); + } + + }); + short lastCellNum = row.getLastCellNum(); + + for(short i = 0; i < lastCellNum; ++i) { + Cell cell = row.getCell(i); + String cellName = cell.getStringCellValue(); + if (columnNamesMap.containsKey(cellName)) { + cellIndexMap.put(columnNamesMap.get(cellName), Integer.valueOf(i)); + } + } + } + } + + try { + workbook.close(); + } catch (IOException var13) { + logger.error("鍏抽棴宸ヤ綔琛ㄥ嚭鐜伴敊璇�", var13); + } + } + } + + return cellIndexMap; + } + } + + public static int getRowIndexForTitle(Class<?> poClass) { + if (poClass.isAnnotationPresent(ExcelTitle.class)) { + ExcelTitle ec = (ExcelTitle)poClass.getAnnotation(ExcelTitle.class); + if (ec == null) { + ec = (ExcelTitle)poClass.getDeclaredAnnotation(ExcelTitle.class); + } + + if (ec != null) { + return ec.rowIndexForTitle(); + } + } + + return 0; + } + + public static String getCellNameByIndex(int colIndex) { + if (colIndex < 26) { + return String.valueOf((char)(65 + colIndex)); + } else { + int balance = colIndex % 26; + int multiple = (colIndex - balance) / 26; + String prefix = String.valueOf((char)(65 + (multiple - 1))); + String suffix = String.valueOf((char)(65 + balance)); + return prefix + suffix; + } + } + + public static Workbook createWorkbook(boolean is07) { + Workbook wb = null; + if (is07) { + wb = new XSSFWorkbook(); + } else { + wb = new HSSFWorkbook(); + } + + return (Workbook)wb; + } + + public static Workbook getWorkbookByInputStream(InputStream ins) throws VciBaseException { + Workbook wb = null; + + try { + wb = WorkbookFactory.create(ins); + return wb; + } catch (IOException var3) { + IOUtils.closeQuietly(ins); + throw new VciBaseException("workBookInitFail", new String[]{LangBaseUtil.getErrorMsg(var3)}); + } + } + + private static Sheet getSheetByWorkbook(Workbook wb, String sheetName) { + if (StringUtil.isBlank(sheetName)) { + sheetName = "Sheet1"; + } + + Sheet sheet = wb.getSheet(sheetName); + if (sheet == null) { + sheet = wb.createSheet(sheetName); + } + + return sheet; + } + + private static Row getRowBySheet(Sheet sheet, int rowIndex) { + Row row = sheet.getRow(rowIndex); + if (row == null) { + row = sheet.createRow(rowIndex); + } + + return row; + } + + private static Cell getCellByRow(Row row, int cellIndex) { + Cell cell = row.getCell(cellIndex); + if (cell == null) { + cell = row.createCell(cellIndex); + } + + return cell; + } + + private static void writeDataToCell(Sheet sheet, List<WriteExcelData> excelDataList) throws VciBaseException { + if (sheet != null && !CollectionUtils.isEmpty(excelDataList)) { + List<WriteExcelData> mergedDataList = new ArrayList(); + excelDataList.stream().forEach((ed) -> { + Row row = getRowBySheet(sheet, ed.getRow()); + Cell cell = getCellByRow(row, ed.getCol()); + if (ed.isMerged() && (ed.getRowTo() > ed.getRow() || ed.getColTo() > ed.getCol())) { + mergedDataList.add(ed); + } + + copyStyle(sheet, cell, ed); + if (ed.isReadOnly() && ed.getObj() != null && !(ed.getObj() instanceof RichTextString) && CollectionUtils.isEmpty(ed.getValidationDataList())) { + List<String> list = new ArrayList(); + list.add(ed.getObj().toString()); + ed.setValidationDataList(list); + setValidation(sheet, ed); + } + + centerCell(cell, ed); + Object value = ed.getObj(); + if (StringUtil.isNotBlank(ed.getFontColor())) { + String rtsValue = value == null ? "" : value.toString(); + RichTextString ts = cell instanceof HSSFCell ? new HSSFRichTextString(rtsValue) : new XSSFRichTextString(rtsValue); + Font font = sheet.getWorkbook().createFont(); + font.setColor(VciBaseUtil.getShort(ed.getFontColor())); + ((RichTextString)ts).applyFont(font); + value = ts; + } + + if (ed.isFormula()) { + setFormula(cell, ed); + } else if (ed.isNameRefer()) { + setNameRefer(sheet, ed); + } else if (ed.isValidation()) { + setValidation(sheet, ed); + } else { + setCellValue(cell, value); + } + + if (ed.getWidth() != null && ed.getWidth() > 0) { + sheet.setColumnWidth(cell.getColumnIndex(), (int)((double)ed.getWidth() + 0.72) * 256); + } + + }); + mergedRegion(sheet, mergedDataList); + } + + } + + private static void setFormula(Cell cell, WriteExcelData ed) { + if (ed.getObj() != null) { + cell.setCellFormula(ed.getObj().toString()); + } + + } + + private static void setNameRefer(Sheet sheet, WriteExcelData ed) { + if (ed.getObj() != null) { + Name name = sheet.getWorkbook().createName(); + name.setNameName(ed.getObj().toString()); + name.setRefersToFormula(sheet.getSheetName() + "!" + getRange(ed)); + } + + } + + private static void setValidation(Sheet sheet, WriteExcelData ed) { + if (ed.getRowTo() < ed.getRow()) { + ed.setRowTo(ed.getRow()); + } + + if (ed.getColTo() < ed.getCol()) { + ed.setColTo(ed.getCol()); + } + + CellRangeAddressList regions = new CellRangeAddressList(ed.getRow(), ed.getRowTo(), ed.getCol(), ed.getColTo()); + DataValidation validation = null; + XSSFDataValidationConstraint dvConstraint; + if (sheet instanceof XSSFSheet) { + XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper((XSSFSheet)sheet); + dvConstraint = null; + if (!CollectionUtils.isEmpty(ed.getValidationDataList())) { + dvConstraint = (XSSFDataValidationConstraint)dvHelper.createExplicitListConstraint((String[])ed.getValidationDataList().toArray(new String[0])); + } else { + VciBaseUtil.alertNotNull(new Object[]{ed.getObj(), "鍐欏叆鏈夋晥鎬х殑鏃跺�欙紝娌℃湁璁剧疆鏈夋晥鎬х殑鍏紡琛ㄨ揪寮�"}); + dvConstraint = (XSSFDataValidationConstraint)dvHelper.createFormulaListConstraint(ed.getObj().toString()); + } + + validation = (XSSFDataValidation)dvHelper.createValidation(dvConstraint, regions); + } else { + HSSFDataValidationHelper dvHelper = new HSSFDataValidationHelper((HSSFSheet)sheet); + dvConstraint = null; + DataValidationConstraint dvConstraintF; + if (!CollectionUtils.isEmpty(ed.getValidationDataList())) { + dvConstraintF = dvHelper.createExplicitListConstraint((String[])ed.getValidationDataList().toArray(new String[0])); + } else { + VciBaseUtil.alertNotNull(new Object[]{ed.getObj(), "鍐欏叆鏈夋晥鎬х殑鏃跺�欙紝娌℃湁璁剧疆鏈夋晥鎬х殑鍏紡琛ㄨ揪寮�"}); + dvConstraintF = dvHelper.createFormulaListConstraint(ed.getObj().toString()); + } + + validation = new HSSFDataValidation(regions, dvConstraintF); + } + + if (validation instanceof XSSFDataValidation) { + ((DataValidation)validation).setSuppressDropDownArrow(true); + ((DataValidation)validation).setShowErrorBox(true); + } else { + ((DataValidation)validation).setSuppressDropDownArrow(false); + } + + if (StringUtil.isNotBlank(ed.getValidationErrorMsg())) { + ((DataValidation)validation).createErrorBox("error", ed.getValidationErrorMsg()); + } + + sheet.addValidationData((DataValidation)validation); + } + + private static String getRange(WriteExcelData excelData) { + char start = (char)(65 + excelData.getCol()); + int rowId = excelData.getRow() + 1; + int endRowId = excelData.getRowTo() + 1; + char endPrefix; + if (excelData.getColTo() <= 25) { + endPrefix = (char)(65 + excelData.getColTo()); + return "$" + start + "$" + rowId + ":$" + endPrefix + "$" + endRowId; + } else { + endPrefix = 'A'; +// boolean endSuffix = true; + char endSuffix; + if ((excelData.getColTo() - 25) / 26 != 0 && excelData.getColTo() != 51) { + if ((excelData.getColTo() - 25) % 26 == 0) { + endSuffix = 'Z'; + endPrefix = (char)(endPrefix + (excelData.getColTo() - 25) / 26 - 1); + } else { + endSuffix = (char)(65 + (excelData.getColTo() - 25) % 26 - 1); + endPrefix = (char)(endPrefix + (excelData.getColTo() - 25) / 26); + } + } else if ((excelData.getColTo() - 25) % 26 == 0) { + endSuffix = 'Z'; + } else { + endSuffix = (char)(65 + (excelData.getColTo() - 25) % 26 - 1); + } + + return "$" + start + "$" + rowId + ":$" + endPrefix + endSuffix + "$" + endRowId; + } + } + + private static void setCellValue(Cell cell, Object value) { + if (value != null) { + if (value instanceof Date) { + cell.setCellValue((Date)value); + } else if (value instanceof String) { + cell.setCellValue(value.toString()); + } else if (value instanceof Boolean) { + cell.setCellValue((Boolean)value); + } else if (value instanceof Integer) { + cell.setCellValue((double)(Integer)value); + } else if (value instanceof Long) { + cell.setCellValue((double)(Long)value); + } else if (value instanceof BigDecimal) { + cell.setCellValue(((BigDecimal)value).doubleValue()); + } else if (value instanceof Double) { + cell.setCellValue((Double)value); + } else if (value instanceof RichTextString) { + cell.setCellValue((RichTextString)value); + } else { + cell.setCellValue(value.toString()); + } + } + + } + + private static void copyStyle(Sheet sheet, Cell cell, WriteExcelData excelData) { + if (excelData.isCopyStyle()) { + Row copyStyleRow = sheet.getRow(excelData.getCopyStyleRow()); + if (copyStyleRow != null) { + Cell copyStyleCell = copyStyleRow.getCell(excelData.getCopyStyleCol()); + copyStyleForCell(copyStyleCell, cell); + if (StringUtil.isNotBlank(excelData.getDateFormat())) { + HSSFDataFormat format = (HSSFDataFormat)sheet.getWorkbook().createDataFormat(); + cell.getCellStyle().setDataFormat(format.getFormat(excelData.getDateFormat())); + } + } + } + + } + + private static void copyStyleForCell(Cell fromCell, Cell toCell) { + CellStyle cellStyle = toCell.getCellStyle(); + CellStyle fromStyle = fromCell.getCellStyle(); + cellStyle.cloneStyleFrom(fromStyle); + cellStyle.setAlignment(fromStyle.getAlignment()); + cellStyle.setBorderBottom(fromStyle.getBorderBottom()); + cellStyle.setBorderLeft(fromStyle.getBorderLeft()); + cellStyle.setBorderRight(fromStyle.getBorderRight()); + cellStyle.setBorderTop(fromStyle.getBorderTop()); + cellStyle.setDataFormat(fromStyle.getDataFormat()); + cellStyle.setFillBackgroundColor(fromStyle.getFillBackgroundColor()); + cellStyle.setFillForegroundColor(fromStyle.getFillForegroundColor()); + cellStyle.setFillPattern(fromStyle.getFillPattern()); + cellStyle.setVerticalAlignment(fromStyle.getVerticalAlignment()); + cellStyle.setWrapText(fromStyle.getWrapText()); + cellStyle.setLocked(fromStyle.getLocked()); + cellStyle.setBottomBorderColor(fromStyle.getBottomBorderColor()); + cellStyle.setLeftBorderColor(fromStyle.getLeftBorderColor()); + cellStyle.setTopBorderColor(fromStyle.getTopBorderColor()); + cellStyle.setRightBorderColor(fromStyle.getRightBorderColor()); + } + + private static void centerCell(Cell cell, WriteExcelData excelData) { + if (excelData.isCenter()) { + CellStyle cellStyle = cell.getCellStyle(); + cellStyle.setAlignment(HorizontalAlignment.CENTER); + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); + } + + } + + private static void mergedRegion(Sheet sheet, Collection<WriteExcelData> mergedDataList) { + if (!CollectionUtils.isEmpty(mergedDataList)) { + mergedDataList.stream().forEach((ed) -> { + if (ed.getRowTo() < ed.getRow()) { + ed.setRowTo(ed.getRow()); + } + + if (ed.getColTo() < ed.getCol()) { + ed.setColTo(ed.getCol()); + } + + sheet.addMergedRegion(new CellRangeAddress(ed.getRow(), ed.getRowTo(), ed.getCol(), ed.getColTo())); + }); + } + + } + + public static List<SheetDataSet> readDataObjectFromExcel(File file) throws VciBaseException { + return readDataObjectFromExcel(file, SheetDataSet.class); + } + + public static <T> List<T> readDataObjectFromExcel(File file, Class<T> doClass) throws VciBaseException { + return readDataObjectFromExcel(file, doClass, (ReadExcelOption)null); + } + + public static <T> List<T> readDataObjectFromExcel(File file, Class<T> doClass, ReadExcelOption excelOption) throws VciBaseException { + return readDataObjectFromExcel((File)file, doClass, excelOption, (PoiImportProcesser)null); + } + + public static <T> List<T> readDataObjectFromExcel(File file, Class<T> doClass, ReadExcelOption excelOption, PoiImportProcesser<T> processer) throws VciBaseException { + InputStream ins = null; + + try { + ins = new FileInputStream(file); + } catch (Throwable var15) { + String msg = "readImportFileFail"; + if (logger.isErrorEnabled()) { + logger.error(msg, var15); + } + + throw new VciBaseException(msg + LangBaseUtil.getErrorMsg(var15), new String[0], var15); + } + + List var5; + try { + var5 = readDataObjectFromExcel((InputStream)ins, doClass, excelOption, processer); + } catch (VciBaseException var12) { + throw var12; + } catch (Throwable var13) { + throw new VciBaseException(LangBaseUtil.getErrorMsg(var13), new String[0], var13); + } finally { + IOUtils.closeQuietly(ins); + } + + return var5; + } + + public static <T> List<T> readDataObjectFromExcel(InputStream ins, Class<T> doClass, ReadExcelOption excelOption, PoiImportProcesser<T> processer) throws VciBaseException { + if (ins == null) { + throw new VciBaseException("inputStreamIsNull"); + } else { + if (doClass == null) { + doClass = (Class<T>) SheetDataSet.class; + } + + boolean isDataSet = false; + if (doClass.equals(SheetDataSet.class)) { + isDataSet = true; + } + + Map<Field, ExcelColumn> excelColumnSet = getExcelColumnAnnotations(doClass); + Map<String, ExcelColumn> excelTitleMap = (Map)((Map)Optional.of(excelColumnSet).get()).values().stream().collect(Collectors.toMap((s) -> { +// return s.value(); + return s; + }, (t) -> { + return t; + })); + Map<String, Field> excelTitleFieldMap = new HashMap(); + Map<String, ExcelColumnMap> extendAttrTitleMap = new HashMap(); + Field[] rowIndexFields = new Field[]{null}; + ReadExcelOption finalExcelOption = excelOption; + excelColumnSet.forEach((field, excelColumnx) -> { + excelTitleFieldMap.put(excelColumnx.value(), field); + if (excelColumnx.rowIndexColumn()) { + rowIndexFields[0] = field; + } + + field.setAccessible(true); + if ((field.getType().equals(Map.class) || field.getType().getSuperclass().equals(Map.class)) && !CollectionUtils.isEmpty(finalExcelOption.getExtendAttrMap()) && finalExcelOption.getExtendAttrMap().containsKey(excelColumnx.value())) { + List<ExcelColumnMap> excelColumnMaps = (List) finalExcelOption.getExtendAttrMap().get(excelColumnx.value()); + if (!CollectionUtils.isEmpty(excelColumnMaps)) { + excelColumnMaps.stream().forEach((ss) -> { + excelTitleFieldMap.put(ss.getTitle(), field); + extendAttrTitleMap.put(ss.getTitle(), ss); + }); + } + } + + }); + Field rowIndexField = null; + if (rowIndexFields[0] != null) { + rowIndexField = rowIndexFields[0]; + } + + Workbook workbook = getWorkbookByInputStream(ins); + if (excelOption == null) { + excelOption = new ReadExcelOption(); + } + + FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); + List<T> dataSet = new ArrayList(); + + try { + for(int sheetIndex = 0; sheetIndex < workbook.getNumberOfSheets(); ++sheetIndex) { + Sheet sheet = workbook.getSheetAt(sheetIndex); + if (StringUtil.isNotBlank(excelOption.getSheetName())) { + if (!sheet.getSheetName().equalsIgnoreCase(excelOption.getSheetName())) { + continue; + } + } else if (!excelOption.isReadAllSheet() && sheetIndex != excelOption.getSheetIndex()) { + continue; + } + + SheetDataSet sheetDataSet = new SheetDataSet(); + sheetDataSet.setSheetName(sheet.getSheetName()); + if (isDataSet) { + dataSet.add((T) sheetDataSet); + } + + Map<Integer, String> colsNameIndexMap = new HashMap(); + int rowIndex; + if (excelOption.getFristRow() > 0) { + try { + Row titleRow = sheet.getRow(excelOption.getFristRow() - 1); + rowIndex = titleRow.getLastCellNum(); + List<String> titleList = new LinkedList(); + + for(int i = 0; i < rowIndex; ++i) { + String title = VciBaseUtil.getStringValueFromObject(getCellValue(titleRow.getCell(i), evaluator)); + if (StringUtil.isNotBlank(title)) { + title = title.replace("*", "").replace("鈽�", ""); + colsNameIndexMap.put(i, title); + titleList.add(title); + } + } + + if (isDataSet) { + sheetDataSet.setColName(titleList); + } + } catch (Exception var52) { + if (logger.isErrorEnabled()) { + logger.error("璇诲彇excel鏂囦欢涓殑鏍囬淇℃伅鍑虹幇浜嗛敊璇�", var52); + } + + throw var52; + } + } + + List<SheetRowData> rowDataList = new LinkedList(); + if (sheet.getLastRowNum() > 0) { + for(rowIndex = excelOption.getFristRow(); rowIndex <= sheet.getLastRowNum(); ++rowIndex) { + Row rowDataSet = sheet.getRow(rowIndex); + if (rowDataSet != null) { + boolean notValue = false; + + for(int i = 0; i < rowDataSet.getLastCellNum(); ++i) { + Cell cellTemp = rowDataSet.getCell(i); + Object valueTemp = getCellValue(cellTemp, evaluator); + if (valueTemp != null && !(valueTemp instanceof String) || valueTemp instanceof String && valueTemp != null && StringUtil.isNotBlank(valueTemp.toString())) { + notValue = true; + break; + } + } + + if (notValue) { + SheetRowData rd = isDataSet ? new SheetRowData() : null; + T obj = null; + if (!isDataSet) { + try { + obj = doClass.newInstance(); + } catch (Throwable var49) { + if (logger.isErrorEnabled()) { + logger.error("瀹炰緥鍖栨暟鎹璞�", var49); + } + + throw new VciBaseException("瀹炰緥鍖栨暟鎹璞�," + LangBaseUtil.getErrorMsg(var49)); + } + } + + if (isDataSet) { + rd.setRowIndex(String.valueOf(rowIndex)); + } + + if (!isDataSet && rowIndexField != null) { + VciBaseUtil.setValueForField(rowIndexField, obj, String.valueOf(rowIndex)); + } + + Map<Integer, String> rowDataMap = new HashMap(); + + for(int columnIndex = 0; columnIndex < rowDataSet.getLastCellNum(); ++columnIndex) { + Cell cell = rowDataSet.getCell(columnIndex); + Object value = getCellValue(cell, evaluator); + String title = colsNameIndexMap.containsKey(columnIndex) ? (String)colsNameIndexMap.get(columnIndex) : ""; + boolean isMapField = false; + Field thisField = null; + if (StringUtil.isNotBlank(title) && excelTitleFieldMap.containsKey(title)) { + thisField = (Field)excelTitleFieldMap.get(title); + } + + if (thisField != null) { + thisField.setAccessible(true); + if (thisField.getType().equals(Map.class) || thisField.getType().getSuperclass().equals(Map.class)) { + isMapField = true; + } + } + + ExcelColumn excelColumn = null; + if (StringUtil.isNotBlank(title) && excelTitleMap.containsKey(title)) { + excelColumn = (ExcelColumn)excelTitleMap.get(title); + } + + ExcelColumnMap columnMap = null; + if (isMapField) { + columnMap = (ExcelColumnMap)extendAttrTitleMap.get(title); + } + + boolean isNull = false; + if (value == null || value instanceof String && StringUtil.isBlank(value.toString())) { + isNull = true; + } + + if (!isNull) { + if (!isDataSet) { + if (thisField != null && (excelColumn != null || columnMap != null)) { + if (isMapField) { + Object fieldValue = thisField.get(obj); + Object data; + if (fieldValue == null) { + data = new HashMap(); + } else { + data = (Map)fieldValue; + } + + ((Map)data).put(columnMap.getColumnName(), value == null ? "" : value.toString()); + + try { + thisField.set(obj, data); + } catch (IllegalAccessException var50) { + if (logger.isErrorEnabled()) { + logger.error("璁剧疆map绫诲瀷鐨勬暟鎹椂鍊欏嚭鐜颁簡閿欒", var50); + } + } + } else { + if (value.getClass().equals(thisField.getType())) { + try { + thisField.set(obj, value); + } catch (IllegalAccessException var51) { + if (logger.isErrorEnabled()) { + logger.error("璇诲彇excel鐨勫崟鍏冩牸鐨勫�煎悗锛屼负瀵硅薄璧嬪�煎嚭鐜颁簡閿欒", var51); + } + } + } else { + VciBaseUtil.setValueForField(thisField, obj, VciBaseUtil.getStringValueFromObject(value)); + } + + if (thisField.getType().equals(Date.class) && thisField.get(obj) == null) { + throw new VciBaseException("cellNotDateFormate", new String[]{title, rowIndex + 1 + ""}); + } + + if (StringUtil.isNotBlank(excelColumn.regExg()) && !VciBaseUtil.getStringValueFromObject(value).matches(excelColumn.regExg())) { + throw new VciBaseException("cellValueNotEqualReg", new String[]{title, rowIndex + 1 + "", excelColumn.regExgTitle()}); + } + } + } + + if (processer != null && thisField != null) { + processer.process(value, obj, thisField); + } + } else { + rowDataMap.put(columnIndex, VciBaseUtil.getStringValueFromObject(value)); + } + } else if (!isDataSet && thisField != null && excelColumn != null) { + if (!excelColumn.nullable()) { + throw new VciBaseException("cellValueCanNotNull", new String[]{title, rowIndex + 1 + ""}); + } + + if (StringUtil.isNotBlank(excelColumn.regExg())) { + throw new VciBaseException("cellValueCanNotNullForReg", new String[]{title, rowIndex + 1 + ""}); + } + } + } + + if (isDataSet) { + rd.setData(rowDataMap); + rowDataList.add(rd); + } else { + dataSet.add(obj); + } + } + } + } + } + + if (isDataSet) { + sheetDataSet.setRowData(rowDataList); + } + } + } catch (Throwable var53) { + throw new VciBaseException(LangBaseUtil.getErrorMsg(var53), new String[0], var53); + } finally { + IOUtils.closeQuietly(ins); + + try { + workbook.close(); + } catch (IOException var48) { + if (logger.isErrorEnabled()) { + logger.error("鍏抽棴宸ヤ綔绨垮嚭鐜颁簡閿欒", var48); + } + } + + } + + return dataSet; + } + } + + private static Object getCellValue(Cell cell, FormulaEvaluator evaluator) { + if (cell != null) { + Object cellValue = null; + CellType cellTypeEnum = cell.getCellType(); + switch (cellTypeEnum) { + case STRING: + String thisCellValue = cell.getStringCellValue(); + cellValue = StringUtil.isEmpty(thisCellValue) ? "" : thisCellValue.trim(); + break; + case BOOLEAN: + boolean boolValue = cell.getBooleanCellValue(); + cellValue = boolValue; + break; + case FORMULA: + cellValue = getCellValue(evaluator.evaluate(cell)); + break; + case NUMERIC: + if (DateUtil.isCellDateFormatted(cell)) { + cellValue = cell.getDateCellValue(); + } else { + cellValue = cell.getNumericCellValue(); + } + break; + default: + cellValue = ""; + } + + return cellValue; + } else { + return null; + } + } + + private static Object getCellValue(CellValue cell) { + Object cellValue = null; + switch (cell.getCellTypeEnum()) { + case STRING: + String thisCellValue = cell.getStringValue(); + cellValue = StringUtil.isEmpty(thisCellValue) ? "" : thisCellValue.trim(); + break; + case NUMERIC: + cellValue = cell.getNumberValue(); + } + + return cellValue; + } + + public static <T> Map<Field, ExcelColumn> getExcelColumnAnnotations(Class<T> doClass) { + Map<Field, ExcelColumn> excelColumnMap = new HashMap(); + if (!doClass.equals(SheetDataSet.class)) { + List<Field> allFields = VciBaseUtil.getAllFieldForObj(doClass); + List<Field> hasExcelColumnFields = (List)allFields.stream().filter((field) -> { + return field.isAnnotationPresent(ExcelColumn.class); + }).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(hasExcelColumnFields)) { + hasExcelColumnFields.stream().forEach((field) -> { + ExcelColumn ec = getExcelColumnAnnotation(field); + excelColumnMap.put(field, ec); + }); + } + } + + return excelColumnMap; + } + + public static ExcelColumn getExcelColumnAnnotation(Field field) { + ExcelColumn ec = (ExcelColumn)field.getAnnotation(ExcelColumn.class); + if (ec == null) { + ec = (ExcelColumn)field.getDeclaredAnnotation(ExcelColumn.class); + } + + return ec; + } + + public static <T> String downloadImportTempByClass(Class<T> doClass, DownloadTempOption downloadTempOption, PoiTemplateProcesser<T> processer) { + if (downloadTempOption == null) { + downloadTempOption = new DownloadTempOption(""); + } + + String excelName = LocalFileUtil.getDefaultTempFolder() + File.separator + (StringUtil.isNotBlank(downloadTempOption.getExcelName()) ? downloadTempOption.getExcelName() : "瀵煎叆妯℃澘.xls"); + + try { + (new File(excelName)).createNewFile(); + } catch (Throwable var22) { + throw new VciBaseException(LangBaseUtil.getErrorMsg(var22), new String[]{excelName}, var22); + } + + List<WriteExcelData> excelDataList = new ArrayList(); + Map<Field, ExcelColumn> fieldExcelColumnMap = getExcelColumnAnnotations(doClass); + Map<String, ExcelColumn> fieldNameExcelColumnMap = new HashMap(); + fieldExcelColumnMap.forEach((fieldx, ec) -> { + fieldx.setAccessible(true); + fieldNameExcelColumnMap.put(fieldx.getName(), ec); + }); + Field[] fields = doClass.getDeclaredFields(); + Set<String> finedFields = new HashSet(); + new HSSFWorkbook(); + int index = 0; + + for(int i = 0; i < fields.length; ++i) { + Field field = fields[i]; + field.setAccessible(true); + String fieldName = field.getName(); + if (fieldNameExcelColumnMap.containsKey(fieldName)) { + finedFields.add(fieldName); + ExcelColumn column = (ExcelColumn)fieldNameExcelColumnMap.get(fieldName); + if (!column.rowIndexColumn()) { + WriteExcelData excelData = new WriteExcelData(0, index, StringUtil.isNotBlank(column.value()) ? column.value() : fieldName); + if (!column.nullable()) { + excelData.setFontColor(String.valueOf(HSSFColor.HSSFColorPredefined.RED.getIndex())); + excelData.setObj(excelData.getObj() + "*"); + } + + excelData.setReadOnly(true); + excelData.setCenter(true); + if (column.width() > 0) { + excelData.setWidth(column.width()); + } + + List<WriteExcelData> thisRowNextDatas = new ArrayList(); + if (downloadTempOption.getDefaultRowSize() == null || downloadTempOption.getDefaultRowSize() < 0) { + downloadTempOption.setDefaultRowSize(1); + } + + Integer defaultRowSize = downloadTempOption.getDefaultRowSize(); + + for(int j = 0; j < defaultRowSize; ++j) { + thisRowNextDatas.add(new WriteExcelData(1 + j, index, "")); + } + + if (StringUtil.isNotBlank(column.enumId()) && processer != null) { + Map<String, String> enumMap = processer.wrapperEnumMap(column.enumId(), doClass, field); + if (!CollectionUtils.isEmpty(enumMap)) { + WriteExcelData thisRowNext = (WriteExcelData)thisRowNextDatas.get(0); + thisRowNext.setValidation(true); + thisRowNext.setRowTo(defaultRowSize); + thisRowNext.setColTo(thisRowNext.getCol()); + thisRowNext.setValidationDataList((List)enumMap.values().stream().collect(Collectors.toList())); + } + } + + if (field.isAnnotationPresent(VciFieldType.class)) { + VciFieldType fieldType = (VciFieldType)field.getDeclaredAnnotation(VciFieldType.class); + if (fieldType == null) { + fieldType = (VciFieldType)field.getAnnotation(VciFieldType.class); + } + + if (fieldType != null) { + String dateFormat; + if (VciFieldTypeEnum.VTDateTime.equals(fieldType.value())) { + dateFormat = "yyyy-MM-dd HH:mm:ss"; + } else if (VciFieldTypeEnum.VTDate.equals(fieldType.value())) { + dateFormat = "yyyy-MM-dd"; + } else if (VciFieldTypeEnum.VTTime.equals(fieldType.value())) { + dateFormat = "HH:mm:ss"; + } else { + dateFormat = ""; + } + + if (StringUtil.isNotBlank(dateFormat)) { + thisRowNextDatas.stream().forEach((thisRowNextx) -> { + thisRowNextx.setDateFormat(dateFormat); + }); + } + + if (VciFieldTypeEnum.VTBoolean.equals(fieldType.value())) { + List<String> trueFlase = new ArrayList(); + trueFlase.add("鏄�"); + trueFlase.add("鍚�"); + WriteExcelData thisRowNext = (WriteExcelData)thisRowNextDatas.get(0); + thisRowNext.setValidation(true); + thisRowNext.setRowTo(defaultRowSize); + thisRowNext.setColTo(thisRowNext.getCol()); + thisRowNext.setValidationDataList(trueFlase); + } + } + } + + excelDataList.addAll(thisRowNextDatas); + excelDataList.add(excelData); + ++index; + } + } + } + + WriteExcelOption excelOption = new WriteExcelOption(); + excelOption.addSheetDataList(StringUtil.isNotBlank(downloadTempOption.getSheetName()) ? downloadTempOption.getSheetName() : "Sheet1", excelDataList); + writeDataToFile(excelName, excelOption); + return excelName; + } + + public static void mergeExcel(List<String> files, String excelName) { + Workbook newExcelCreat = excelName.toLowerCase(Locale.ROOT).endsWith(".xlsx") ? new XSSFWorkbook() : new HSSFWorkbook(); + + for(int i = 0; i < files.size(); ++i) { + String fromExcelName = (String)files.get(i); + + try { + InputStream in = new FileInputStream(fromExcelName); + Throwable var6 = null; + + try { + Workbook fromExcel = null; + if (fromExcelName.toLowerCase(Locale.ROOT).endsWith(".xlsx")) { + fromExcel = new XSSFWorkbook(in); + } else { + fromExcel = new HSSFWorkbook(in); + } + + int length = ((Workbook)fromExcel).getNumberOfSheets(); + Sheet oldSheet; + if (length <= 1) { + oldSheet = ((Workbook)fromExcel).getSheetAt(0); + oldSheet = ((Workbook)newExcelCreat).getSheet(oldSheet.getSheetName()); + String newSheetName = oldSheet.getSheetName(); + if (oldSheet != null) { + newSheetName = newSheetName + "_" + i; + } + + Sheet newSheet = ((Workbook)newExcelCreat).createSheet(newSheetName); + copySheet((Workbook)newExcelCreat, oldSheet, newSheet); + } else { + for(int j = 0; j < length; ++j) { + oldSheet = ((Workbook)fromExcel).getSheetAt(j); + Sheet existSheet = ((Workbook)newExcelCreat).getSheet(oldSheet.getSheetName()); + String newSheetName = oldSheet.getSheetName(); + if (existSheet != null) { + newSheetName = newSheetName + "_" + i + "_" + j; + } + + Sheet newSheet = ((Workbook)newExcelCreat).createSheet(newSheetName); + copySheet((Workbook)newExcelCreat, oldSheet, newSheet); + } + } + + List<? extends Name> allNames = ((Workbook)fromExcel).getAllNames(); + if (!CollectionUtils.isEmpty(allNames)) { + allNames.stream().forEach((name) -> { + Name name1 = newExcelCreat.createName(); + name1.setNameName(name.getNameName()); + name1.setRefersToFormula(name.getRefersToFormula()); + }); + } + } catch (Throwable var64) { + var6 = var64; + throw var64; + } finally { + if (in != null) { + if (var6 != null) { + try { + in.close(); + } catch (Throwable var58) { + var6.addSuppressed(var58); + } + } else { + in.close(); + } + } + + } + } catch (IOException var66) { + throw new VciBaseException("鍚堝苟excel鍑洪敊鐨勪簡", new String[0], var66); + } + } + + String allFileName = excelName; + + try { + FileOutputStream fileOut = new FileOutputStream(allFileName); + Throwable var69 = null; + + try { + ((Workbook)newExcelCreat).write(fileOut); + fileOut.flush(); + } catch (Throwable var60) { + var69 = var60; + throw var60; + } finally { + if (fileOut != null) { + if (var69 != null) { + try { + fileOut.close(); + } catch (Throwable var59) { + var69.addSuppressed(var59); + } + } else { + fileOut.close(); + } + } + + } + } catch (IOException var62) { + var62.printStackTrace(); + } finally { + try { + ((Workbook)newExcelCreat).close(); + } catch (IOException var57) { + var57.printStackTrace(); + } + + } + + } + + private static void mergeSheetAllRegion(Sheet fromSheet, Sheet toSheet) { + int num = fromSheet.getNumMergedRegions(); + CellRangeAddress cellR = null; + + for(int i = 0; i < num; ++i) { + cellR = fromSheet.getMergedRegion(i); + toSheet.addMergedRegion(cellR); + } + + } + + private static void copyCell(Cell fromCell, Cell toCell) { + copyStyleForCell(fromCell, toCell); + if (fromCell.getCellComment() != null) { + toCell.setCellComment(fromCell.getCellComment()); + } + + CellType fromCellType = fromCell.getCellType(); + toCell.setCellType(fromCellType); + if (fromCellType == CellType.NUMERIC) { + if (DateUtil.isCellDateFormatted(fromCell)) { + toCell.setCellValue(fromCell.getDateCellValue()); + } else { + toCell.setCellValue(fromCell.getNumericCellValue()); + } + } else if (fromCellType == CellType.STRING) { + RichTextString value = fromCell.getRichStringCellValue(); + if (value != null && StringUtil.isNotBlank(value.toString())) { + Font fontAt = fromCell.getSheet().getWorkbook().getFontAt(fromCell.getCellStyle().getFontIndexAsInt()); + value.applyFont(fontAt); + } + + toCell.setCellValue(value); + } else if (fromCellType != CellType.BLANK) { + if (fromCellType == CellType.BOOLEAN) { + toCell.setCellValue(fromCell.getBooleanCellValue()); + } else if (fromCellType == CellType.ERROR) { + toCell.setCellErrorValue(fromCell.getErrorCellValue()); + } else if (fromCellType == CellType.FORMULA) { + toCell.setCellFormula(fromCell.getCellFormula()); + } + } + + } + + private static void copyRow(Workbook wb, Row oldRow, Row toRow) { + toRow.setHeight(oldRow.getHeight()); + Iterator cellIt = oldRow.cellIterator(); + + while(cellIt.hasNext()) { + Cell tmpCell = (Cell)cellIt.next(); + Cell newCell = toRow.createCell(tmpCell.getColumnIndex()); + copyCell(tmpCell, newCell); + } + + } + + private static void copySheet(Workbook wb, Sheet fromSheet, Sheet toSheet) { + mergeSheetAllRegion(fromSheet, toSheet); + int length = fromSheet.getRow(fromSheet.getFirstRowNum()).getLastCellNum(); + + for(int i = 0; i <= length; ++i) { + toSheet.setColumnWidth(i, fromSheet.getColumnWidth(i)); + } + + Iterator rowIt = fromSheet.rowIterator(); + + while(rowIt.hasNext()) { + Row oldRow = (Row)rowIt.next(); + Row newRow = toSheet.createRow(oldRow.getRowNum()); + copyRow(wb, oldRow, newRow); + } + + List<? extends DataValidation> dataValidations = fromSheet.getDataValidations(); + if (!CollectionUtils.isEmpty(dataValidations)) { + dataValidations.stream().forEach((dv) -> { + toSheet.addValidationData(dv); + }); + } + + } + + public static <T> void appendDataToExcel(Collection<T> data, String excelName, AppendDataExcelOption excelOption) { + if (!CollectionUtils.isEmpty(data)) { + T t1 = data.stream().findFirst().get(); + Map<Field, ExcelColumn> excelColumnSet = getExcelColumnAnnotations(t1.getClass()); + Map<String, String> excelTitleFieldNameMap = new HashMap(); + Set<String> readOnlyFields = new HashSet(); + excelColumnSet.forEach((field, excelColumn) -> { + excelTitleFieldNameMap.put(excelColumn.value(), field.getName()); + if (excelColumn.readOnly()) { + readOnlyFields.add(field.getName()); + } + + }); + ReadExcelOption readExcelOption = new ReadExcelOption(); + readExcelOption.setSheetName(excelOption.getSheetName()); + readExcelOption.setFristRow(excelOption.getTitleRowIndex() + 1); + List<SheetDataSet> sheetDataSets = readDataObjectFromExcel(new File(excelName), SheetDataSet.class, readExcelOption); + if (!CollectionUtils.isEmpty(sheetDataSets)) { + SheetDataSet sheetDataSet = (SheetDataSet)sheetDataSets.get(0); + Map<String, Integer> fieldColumnMap = new HashMap(); + List<String> colName = sheetDataSet.getColName(); + if (!CollectionUtils.isEmpty(colName)) { + for(int i = 0; i < colName.size(); ++i) { + String col = ((String)colName.get(i)).replace("*", "").replace("鈽�", ""); + if (excelTitleFieldNameMap.containsKey(col)) { + fieldColumnMap.put(excelTitleFieldNameMap.get(col), i); + } + } + + List<WriteExcelData> writeExcelDataList = new ArrayList(); + Integer[] index = new Integer[]{excelOption.getTitleRowIndex() + 1}; + data.stream().forEach((d) -> { + Map<String, String> dataMap = VciBaseUtil.objectToMapString(d); + fieldColumnMap.forEach((field, col) -> { + if (CollectionUtils.isEmpty(excelOption.getWriteFields()) || excelOption.getWriteFields().contains(field)) { + WriteExcelData excelData = new WriteExcelData(index[0], col, dataMap.getOrDefault(field, "")); + excelData.setReadOnly(excelOption.isReadOnlyFromField() && readOnlyFields.contains(field) || !CollectionUtils.isEmpty(excelOption.getReadOnlyFields()) && excelOption.getReadOnlyFields().contains(field)); + writeExcelDataList.add(excelData); + } + + }); + Integer var7 = index[0]; + Integer var8 = index[0] = index[0] + 1; + }); + WriteExcelOption writeExcelOption = new WriteExcelOption(); + writeExcelOption.addSheetDataList(excelOption.getSheetName(), writeExcelDataList); + writeExcelOption.setAppend(true); + writeDataToFile(excelName, writeExcelOption); + } + } + } + + } +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/util/PoiImportProcesser.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/util/PoiImportProcesser.java new file mode 100644 index 0000000..bd32f6c --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/util/PoiImportProcesser.java @@ -0,0 +1,8 @@ +package com.vci.ubcs.com.vci.starter.poi.util; + +import java.lang.reflect.Field; + +@FunctionalInterface +public interface PoiImportProcesser<T> { + void process(Object var1, T var2, Field var3); +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/util/PoiTemplateProcesser.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/util/PoiTemplateProcesser.java new file mode 100644 index 0000000..143d945 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/poi/util/PoiTemplateProcesser.java @@ -0,0 +1,10 @@ +package com.vci.ubcs.com.vci.starter.poi.util; + +import java.lang.reflect.Field; +import java.util.Map; + +@FunctionalInterface +public interface PoiTemplateProcesser<T> { + Map<String, String> wrapperEnumMap(String var1, Class<T> var2, Field var3); +} + diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/util/LocalFileUtil.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/util/LocalFileUtil.java new file mode 100644 index 0000000..0350790 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/util/LocalFileUtil.java @@ -0,0 +1,318 @@ +package com.vci.ubcs.com.vci.starter.util; + + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.channels.FileChannel; +import java.nio.charset.StandardCharsets; +import java.rmi.ServerException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; + +import com.vci.ubcs.com.vci.starter.exception.VciBaseException; +import org.apache.commons.io.IOUtils; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.boot.system.ApplicationHome; + +public class LocalFileUtil { + public static Class mainClass = null; + + public LocalFileUtil() { + } + + public static void deleteFile(File file) { + if (file != null && file.exists()) { + if (file.isDirectory()) { + File[] files = file.listFiles(); + + for(int i = 0; i < files.length; ++i) { + deleteFile(files[i]); + } + } + + file.delete(); + } + } + + public static void copyFile(File source, File target) { + FileInputStream is = null; + FileOutputStream os = null; + + try { + is = new FileInputStream(source); + os = new FileOutputStream(target); + FileChannel sourceChannel = is.getChannel(); + FileChannel targetChannel = os.getChannel(); + int i = 0; + + for(int length = 2097152; sourceChannel.position() != sourceChannel.size(); ++i) { + if (sourceChannel.size() - sourceChannel.position() < 20971520L) { + length = (int)(sourceChannel.size() - sourceChannel.position()); + } else { + length = 20971520; + } + + sourceChannel.transferTo(sourceChannel.position(), (long)length, targetChannel); + sourceChannel.position(sourceChannel.position() + (long)length); + } + + sourceChannel.close(); + targetChannel.close(); + } catch (Throwable var11) { + throw new VciBaseException("鎷疯礉鏂囦欢鍑洪敊", new String[0], var11); + } finally { + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + } + } + + public static String getDefaultTempFolder() { + String path = getProjectFolder(); + path = path + File.separator + "tempFolder" + File.separator + UUID.randomUUID().toString(); + File folder = new File(path); + if (!folder.exists()) { + folder.mkdirs(); + } + + return path; + } + + public static String getProjectFolder() { + return getProjectFolder(LocalFileUtil.class); + } + + public static String getProjectFolder(Class classObj) { + String path = ""; + + try { + ApplicationHome h = new ApplicationHome(classObj == null ? (mainClass == null ? LocalFileUtil.class : mainClass) : classObj); + File jarF = h.getSource(); + if (jarF == null) { + jarF = h.getDir(); + } + + path = jarF.getParentFile().toString(); + if (path.contains("!")) { + path = (new File(path)).getParentFile().getParent(); + } + } catch (Throwable var4) { + var4.printStackTrace(); + throw new VciBaseException("鑾峰彇褰撳墠鏈嶅姟鎵�鍦ㄧ殑鏂囦欢澶瑰嚭鐜颁簡閿欒", new String[0], var4); + } + + if (path.startsWith("file:\\")) { + path = path.substring(6); + } + + if (System.getProperty("os.name").toLowerCase().startsWith("win") && path.startsWith("/")) { + path = path.substring(path.indexOf("/") + 1); + } + + System.out.println("椤圭洰鐨勮矾寰勬槸:" + path); + return path; + } + + public static void deleteTempFile(File tempFile, boolean deleteRandomFolder) { + if (tempFile != null) { + tempFile.delete(); + if (deleteRandomFolder) { + tempFile.getParentFile().delete(); + } + } + + } + + public static void alertNotNull(Object... s) { + if (s != null && s.length > 0) { + for(int i = 0; i < s.length; ++i) { + Object obj = s[i]; + if (obj == null || StringUtil.isBlank(obj.toString())) { + String param = ""; + + try { + ++i; + param = s[i].toString(); + } catch (Exception var5) { + } + + throw new VciBaseException("鍙傛暟[" + param + "]涓嶈兘涓虹┖"); + } + } + } + + } + + public static String getFileExtension(File file) { + return file != null ? getFileExtensionByName(file.getName()) : ""; + } + + public static String getFileExtensionByName(String name) { + return StringUtil.isNotBlank(name) && name.contains(".") ? name.substring(name.lastIndexOf(".") + 1) : ""; + } + + public static String getFileNameForIE(String name) { + if (StringUtil.isBlank(name)) { + return name; + } else if (name.contains(File.separator)) { + return name.substring(name.lastIndexOf(File.separator) + 1); + } else { + return name.contains("\\") ? name.substring(name.lastIndexOf("\\") + 1) : name; + } + } + + public static String readContentForFileInJar(String fileName) { + if (StringUtil.isBlank(fileName)) { + throw new VciBaseException("鏂囦欢鍚嶄负绌�"); + } else { + if (!fileName.startsWith("/")) { + fileName = "/" + fileName; + } + + InputStream in = null; + ByteArrayOutputStream os = null; + + String var3; + try { + in = LocalFileUtil.class.getResourceAsStream(fileName); + if (in == null) { + in = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); + } + + os = new ByteArrayOutputStream(); + IOUtils.copy(in, os); + var3 = new String(os.toByteArray(), "UTF-8"); + } catch (Throwable var7) { + throw new VciBaseException("璇诲彇鏂囦欢鐨勫唴瀹瑰嚭鐜颁簡閿欒", new String[0], var7); + } finally { + IOUtils.closeQuietly(in); + IOUtils.closeQuietly(os); + } + + return var3; + } + } + + public static String readContentForFile(String fileName) { + File file = new File(fileName); + if (!file.exists()) { + throw new VciBaseException("鏂囦欢鏈壘鍒帮紝{0}", new String[]{fileName}); + } else { + InputStream in = null; + ByteArrayOutputStream os = null; + + String var4; + try { + in = new FileInputStream(file); + os = new ByteArrayOutputStream(); + IOUtils.copy(in, os); + var4 = new String(os.toByteArray(), "UTF-8"); + } catch (Throwable var8) { + throw new VciBaseException("璇诲彇鏂囦欢鐨勫唴瀹瑰嚭鐜颁簡閿欒", new String[0], var8); + } finally { + IOUtils.closeQuietly(in); + IOUtils.closeQuietly(os); + } + + return var4; + } + } + + public static void writeContentToFile(String content, String fileName) { + File file = new File(fileName); + if (!file.exists()) { + File parentFile = file.getParentFile(); + if (!parentFile.exists()) { + parentFile.mkdirs(); + } + + try { + file.createNewFile(); + } catch (IOException var11) { + throw new VciBaseException("鍐欏叆鏂囦欢鐨勫唴瀹规椂鍊欏嚭鐜颁簡鍒涘缓鏂囦欢澶辫触鐨勯棶棰�,{}", new String[]{fileName}, var11); + } + } + + if (content == null) { + content = ""; + } + + OutputStream os = null; + + try { + os = new FileOutputStream(file); + os.write(content.getBytes(StandardCharsets.UTF_8)); + os.flush(); + } catch (Throwable var9) { + throw new VciBaseException("鍐欏叆鏂囦欢鐨勫唴瀹规椂鍊欏嚭鐜颁簡鍒涢敊璇�,{}", new String[]{fileName}, var9); + } finally { + IOUtils.closeQuietly(os); + } + + } + + public static void copyFileInJar(String fileInJar, String target) { + VciBaseUtil.alertNotNull(new Object[]{fileInJar, "婧愭枃浠�", target, "鐩爣鏂囦欢"}); + File targetFile = new File(target); + File folder = targetFile.getParentFile(); + if (!folder.exists()) { + folder.mkdirs(); + } + + if (!targetFile.exists()) { + try { + targetFile.createNewFile(); + } catch (IOException var11) { + throw new VciBaseException("鍒涘缓鐩爣鏂囦欢鐨勫嚭鐜颁簡閿欒", new String[0], var11); + } + } + + if (!fileInJar.startsWith("/")) { + fileInJar = "/" + fileInJar; + } + + InputStream in = null; + FileOutputStream os = null; + + try { + in = LocalFileUtil.class.getResourceAsStream(fileInJar); + if (in == null) { + in = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileInJar); + } + + os = new FileOutputStream(target); + IOUtils.copy(in, os); + } catch (Throwable var12) { + throw new VciBaseException("鎷疯礉鏂囦欢鐨勫唴瀹瑰嚭鐜颁簡閿欒.{0},{1}", new String[]{fileInJar, target}, var12); + } finally { + IOUtils.closeQuietly(in); + IOUtils.closeQuietly(os); + } + + } + + public static List<String> fileToPatch(Collection<File> fileList) { + VciBaseUtil.alertNotNull(new Object[]{"鏂囦欢鍒楄〃", fileList}); + List<String> filePath = new ArrayList(); + Iterator var2 = fileList.iterator(); + + while(var2.hasNext()) { + File file = (File)var2.next(); + if (!file.exists()) { + throw new VciBaseException(file.getAbsolutePath() + "鏂囦欢娌℃湁鎵惧埌" + new String[0]); + } + + filePath.add(file.getAbsolutePath()); + } + + return filePath; + } +} + diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/annotation/VciFieldType.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/annotation/VciFieldType.java new file mode 100644 index 0000000..5794349 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/annotation/VciFieldType.java @@ -0,0 +1,15 @@ +package com.vci.ubcs.com.vci.starter.web.annotation; + +import com.vci.ubcs.com.vci.starter.web.enumpck.VciFieldTypeEnum; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface VciFieldType { + VciFieldTypeEnum value() default VciFieldTypeEnum.VTString; +} + diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/enumpck/VciEnum.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/enumpck/VciEnum.java new file mode 100644 index 0000000..6f31821 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/enumpck/VciEnum.java @@ -0,0 +1,20 @@ +package com.vci.ubcs.com.vci.starter.web.enumpck; + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface VciEnum { + String name() default ""; + + Class valueType() default String.class; + + String text() default ""; + + String description() default ""; +} + diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/enumpck/VciFieldTypeEnum.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/enumpck/VciFieldTypeEnum.java new file mode 100644 index 0000000..22b3695 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/enumpck/VciFieldTypeEnum.java @@ -0,0 +1,93 @@ +package com.vci.ubcs.com.vci.starter.web.enumpck; + + +@VciEnum( + name = "VciFieldType", + text = "灞炴�х被鍨�" +) +public enum VciFieldTypeEnum { + VTString, + VTInteger, + VTLong, + VTDouble, + VTBoolean, + VTDate, + VTDateTime, + VTTime, + VTFilePath, + VTClob; + + private VciFieldTypeEnum() { + } + + public static String getValueByText(String text) { + if (text != null && text.trim().length() != 0) { + if ("甯冨皵鍨�".equalsIgnoreCase(text)) { + return VTBoolean.name(); + } else if ("闀挎枃鏈�".equalsIgnoreCase(text)) { + return VTClob.name(); + } else if ("鏃ユ湡".equalsIgnoreCase(text)) { + return VTDate.name(); + } else if ("鏃ユ湡鏃堕棿".equalsIgnoreCase(text)) { + return VTDateTime.name(); + } else if ("鏃堕棿".equalsIgnoreCase(text)) { + return VTTime.name(); + } else if ("闀挎暣鍨�".equalsIgnoreCase(text)) { + return VTLong.name(); + } else if ("閲戦/鍙岀簿搴�".equalsIgnoreCase(text)) { + return VTDouble.name(); + } else if ("鏁村舰".equalsIgnoreCase(text)) { + return VTInteger.name(); + } else { + return "鏂囦欢".equalsIgnoreCase(text) ? VTFilePath.name() : VTString.name(); + } + } else { + return ""; + } + } + + public static String getTextByValue(String value) { + VciFieldTypeEnum wenum = forValue(value); + if (wenum == null) { + return ""; + } else { + switch (wenum) { + case VTBoolean: + return "甯冨皵鍨�"; + case VTClob: + return "闀挎枃鏈�"; + case VTDate: + return "鏃ユ湡"; + case VTDateTime: + return "鏃ユ湡鏃堕棿"; + case VTTime: + return "鏃堕棿"; + case VTLong: + return "闀挎暣鍨�"; + case VTDouble: + return "閲戦/鍙岀簿搴�"; + case VTInteger: + return "鏁村舰"; + case VTFilePath: + return "鏂囦欢"; + default: + return "瀛楃涓�"; + } + } + } + + public static VciFieldTypeEnum forValue(String value) { + VciFieldTypeEnum[] var1 = values(); + int var2 = var1.length; + + for(int var3 = 0; var3 < var2; ++var3) { + VciFieldTypeEnum wenum = var1[var3]; + if (wenum.name().equalsIgnoreCase(value)) { + return wenum; + } + } + + return null; + } +} + diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/toolmodel/DateConverter.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/toolmodel/DateConverter.java new file mode 100644 index 0000000..b942198 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/toolmodel/DateConverter.java @@ -0,0 +1,188 @@ +package com.vci.ubcs.com.vci.starter.web.toolmodel; + +import com.vci.ubcs.com.vci.starter.exception.VciBaseException; +import com.vci.ubcs.com.vci.starter.web.util.VciDateUtil; +import org.springblade.core.tool.utils.StringUtil; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class DateConverter { + private DateFormat dateFormat; + private int exactDateLength; + private Date value; + + public DateConverter() { + } + + public DateFormat getDateFormat() { + return this.dateFormat; + } + + public void setDateFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public int getExactDateLength() { + return this.exactDateLength; + } + + public void setExactDateLength(int exactDateLength) { + this.exactDateLength = exactDateLength; + } + + public Date getValue() { + return this.value; + } + + public void setValue(Date value) { + this.value = value; + } + + public void setAsText(String text) throws VciBaseException { + if (StringUtil.isBlank(text)) { + this.setValue((Date)null); + } else { + text = text.trim(); + text = text.replace("骞�", "-").replace("鏈�", "-").replace("鏃�", "").replace("鏃�", ":").replace("鍒�", ":"); + String pattern = "\\d{2,4}([^\\d]?)\\d{1,2}\\1\\d{1,2}( \\d{1,2}([^\\d])\\d{1,2})?"; + Pattern r = Pattern.compile(pattern); + Matcher m = r.matcher(text); + if (!m.find()) { + throw new VciBaseException("涓嶆槸鍚堟牸鐨勬椂闂存牸寮忓瓧绗︿覆,{0}", new String[]{text}); + } + + String dateSplit = m.group(1); + String timeSplit = m.group(3); + String formateStr = String.format("yyyy%sMM%sdd", dateSplit, dateSplit); + String yearMD; + if (StringUtil.isNotBlank(timeSplit)) { + yearMD = text.substring(text.indexOf(" ")); + String[] split = yearMD.split(timeSplit); + if (split.length == 2) { + formateStr = formateStr + String.format(" HH%smm", timeSplit); + } + + if (split.length > 2) { + formateStr = formateStr + String.format(" HH%smm%sss", timeSplit, timeSplit); + } + + if (yearMD.contains(".")) { + formateStr = formateStr + ".SSS"; + } + } + + yearMD = text.contains(" ") ? text.substring(0, text.indexOf(" ")) : text; + if (StringUtil.isNotBlank(dateSplit)) { + String year = text.substring(0, text.indexOf(dateSplit)); + if (StringUtil.isNotBlank(year) && year.length() == 2) { + formateStr = formateStr.replace("yyyy", "yy"); + } + + String[] split = yearMD.split(dateSplit); + if (split.length == 2) { + formateStr = formateStr.replace("dd", ""); + } + } else if (!text.matches("^[0-9]*$")) { + if (text.length() == 5) { + formateStr = formateStr.replace("yyyyMMdd", "yy" + text.substring(2, 3) + "MM"); + } + + if (text.length() == 7) { + formateStr = formateStr.replace("yyyyMMdd", "yyyy" + text.substring(4, 5) + "MM"); + } + } else if (text.length() == 2 && text.matches("^[0-9]*$")) { + formateStr = "yy"; + } else if (text.length() == 4 && text.matches("^[0-9]*$")) { + formateStr = "yyyy"; + } else if (text.length() == 6 && text.matches("^[0-9]*$")) { + formateStr = "yyyyMM"; + } else if (StringUtil.isNotBlank(yearMD) && yearMD.length() < 6) { + formateStr = formateStr.replace("yyyy", "yy"); + } + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(formateStr); + + try { + this.setValue(simpleDateFormat.parse(text)); + } catch (ParseException var13) { + formateStr = formateStr.replace("yyyy", "yy"); + simpleDateFormat = new SimpleDateFormat(formateStr); + + try { + this.setValue(simpleDateFormat.parse(text)); + } catch (ParseException var12) { + if (text.length() == 2 && text.matches("^[0-9]*$")) { + formateStr = "yy"; + } + + throw new VciBaseException("涓嶈兘鏍煎紡鍖栨棩鏈�: {0}", new String[]{text}, var13); + } + } + } + + } + + private String fillNano(String text) { + String nano = text.substring(text.lastIndexOf(".") + 1); + if (nano.length() < 3) { + for(int i = 0; i < 3 - nano.length(); ++i) { + nano = nano + "0"; + } + } + + return text.substring(0, text.lastIndexOf(".")) + "." + nano; + } + + public static void main(String[] args) { + List<String> list = new ArrayList<String>() { + { + this.add("2020-11-12 12:12:03"); + this.add("2020-1-2 2:2:3"); + this.add("2020-11-12 12:12:03.232"); + this.add("2020/11/12 12:12:03"); + this.add("2020/1/2 2:2:3"); + this.add("2020/11/12 12:12:03.232"); + this.add("20/11/12 12:12:03"); + this.add("20/1/2 2:2:3"); + this.add("20/11/12 12:12:03.232"); + this.add("2020"); + this.add("2020-11"); + this.add("202011"); + this.add("12:02:12"); + this.add("2:2:3"); + this.add("20201112"); + this.add("202012"); + this.add("202012"); + this.add("2020骞�11鏈�12鏃� 12鏃�12鍒�03绉�"); + this.add("2020骞�1鏈�2鏃� 2:2:3"); + this.add("2020骞�11鏈�12鏃� 12鏃�12鍒�03绉�232姣"); + } + }; + list.stream().forEach((t) -> { + try { + DateConverter dateConverter = new DateConverter(); + dateConverter.setAsText(t); + System.out.println("杞崲鍓�:" + t + "; 杞崲鍚�:" + VciDateUtil.date2Str(dateConverter.getValue(), "yyyy-MM-dd HH:mm:ss.SSS")); + } catch (Throwable var2) { + var2.printStackTrace(); + } + + }); + } + + public String getAsText(String dateFormat) { + Date value = this.getValue(); + if (StringUtil.isEmpty(dateFormat)) { + dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"; + } + + return value != null ? (new SimpleDateFormat(dateFormat)).format(value) : ""; + } +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/ControllerUtil.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/ControllerUtil.java new file mode 100644 index 0000000..314b441 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/ControllerUtil.java @@ -0,0 +1,248 @@ +package com.vci.ubcs.com.vci.starter.web.util; + +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springblade.core.tool.utils.StringUtil; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.net.URLEncoder; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class ControllerUtil { + private static Logger logger = LoggerFactory.getLogger(ControllerUtil.class); + public static final Map<String, String> tempFileForDownloadMap = new ConcurrentHashMap(); + + public ControllerUtil() { + } + + public static void writeFileToResponse(HttpServletResponse response, String fileName) throws FileNotFoundException, IOException { + writeFileToResponse(response, fileName, true); + } + + public static void writeFileToResponse(HttpServletResponse response, String fileName, boolean deleteFile) throws FileNotFoundException, IOException { + writeFileToResponse(response, (String)fileName, (String)null, deleteFile); + } + + public static void writeFileToResponse(HttpServletResponse response, String fileName, String showName, boolean deleteFile) throws FileNotFoundException, IOException { + File file = new File(fileName); + if (!file.exists()) { + throw new FileNotFoundException(fileName); + } else { + writeFileToResponse(response, file, showName, deleteFile); + } + } + + public static void writeFileToResponse(HttpServletResponse response, File file) throws FileNotFoundException, IOException { + writeFileToResponse(response, file, true); + } + + public static void writeFileToResponse(HttpServletResponse response, File file, boolean deleteFile) throws FileNotFoundException, IOException { + writeFileToResponse(response, (File)file, (String)null, deleteFile); + } + + public static void writeFileToResponse(HttpServletResponse response, File file, String showName, boolean deleteFile) throws FileNotFoundException, IOException { + writeFileToResponse(response, file, showName, deleteFile, (String)null); + } + + public static void writeFileToResponse(HttpServletResponse response, File file, String showName, boolean deleteFile, String contentType) throws FileNotFoundException, IOException { + VciBaseUtil.alertNotNull(new Object[]{file, "鏂囦欢瀵硅薄"}); + if (!file.exists()) { + throw new FileNotFoundException(file.getName()); + } else { + if (StringUtil.isBlank(showName)) { + showName = file.getName(); + } + + FileInputStream in = null; + boolean var11 = false; + + File parentFile; + label96: { + try { + var11 = true; + in = new FileInputStream(file); + writeFileToResponse(response, in, showName, contentType); + var11 = false; + break label96; + } catch (IOException var12) { + if (logger.isErrorEnabled()) { + logger.error("鍐欏叆鏂囦欢鍒板搷搴旀祦鍑洪敊", var12); + var11 = false; + } else { + var11 = false; + } + } finally { + if (var11) { + IOUtils.closeQuietly(in); + if (deleteFile) { + File parentFile1 = file.getParentFile(); + file.delete(); + parentFile1.delete(); + } + + } + } + + IOUtils.closeQuietly(in); + if (deleteFile) { + parentFile = file.getParentFile(); + file.delete(); + parentFile.delete(); + } + + return; + } + + IOUtils.closeQuietly(in); + if (deleteFile) { + parentFile = file.getParentFile(); + file.delete(); + parentFile.delete(); + } + + } + } + + public static void writeFileToResponse(HttpServletResponse response, InputStream ins, String showName) throws IOException { + writeFileToResponse(response, ins, showName, (String)null); + } + + public static void writeFileToResponse(HttpServletResponse response, InputStream ins, String showName, String contentType) throws IOException { + if (StringUtil.isBlank(contentType)) { + contentType = "application/force-download"; + } + + if (StringUtil.isBlank(showName)) { + showName = "涓嬭浇鏂囦欢"; + } + + response.setContentType(contentType); + + try { + String fileName = URLEncoder.encode(showName, "UTF8"); + response.addHeader("Content-Disposition", "attachment; filename=" + fileName + ";filename*=utf-8''" + fileName); + } catch (Exception var12) { + if (logger.isErrorEnabled()) { + logger.error("璁剧疆鏂囦欢鐨勫悕绉板埌鍝嶅簲娴佺殑鏃跺�欏嚭閿�", var12); + } + } + + response.setCharacterEncoding("UTF-8"); + Cookie cookie = new Cookie("fileDownload", "true"); + cookie.setPath("/"); + response.addCookie(cookie); + + try { + IOUtils.copy(ins, response.getOutputStream()); + } catch (IOException var10) { + if (logger.isErrorEnabled()) { + logger.error("鍐欏叆鏂囦欢鍒板搷搴旀祦鍑洪敊", var10); + } + + throw var10; + } finally { + IOUtils.closeQuietly(ins); + } + + } + + public static void writeDataToResponse(HttpServletResponse response, byte[] data, String contentType) throws IOException { + if (StringUtil.isBlank(contentType)) { + contentType = "application/force-download"; + } + + response.setContentType(contentType); + response.setCharacterEncoding("UTF-8"); + Cookie cookie = new Cookie("fileDownload", "true"); + cookie.setPath("/"); + response.addCookie(cookie); + + try { + response.getOutputStream().write(data); + } catch (IOException var5) { + if (logger.isErrorEnabled()) { + logger.error("鍐欏叆鏂囦欢鍒板搷搴旀祦鍑洪敊", var5); + } + + throw var5; + } + } + + public static void writeClasspathFileToResponse(HttpServletResponse response, String classPathFileName) throws FileNotFoundException, IOException { + writeClasspathFileToResponse(response, classPathFileName, (String)null); + } + + public static void writeClasspathFileToResponse(HttpServletResponse response, String classPathFileName, String showName) throws FileNotFoundException, IOException { + InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(classPathFileName); + if (StringUtil.isBlank(showName)) { + showName = classPathFileName.contains("/") ? classPathFileName.substring(classPathFileName.lastIndexOf("/") + 1) : classPathFileName; + } + + try { + writeFileToResponse(response, in, showName); + } catch (IOException var8) { + throw var8; + } finally { + IOUtils.closeQuietly(in); + } + + } + + public static String getClientInfo(HttpServletRequest request) { + String ip = request.getHeader("X-Forwarded-For"); + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_CLIENT_IP"); + } + + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + + if (ip == null || ip.length() == 0 || ip.indexOf("0:0:0:0:0:0:0:1") > -1) { + ip = "127.0.0.1"; + } + + return ip; + } + + public static void setQueryTotal(HttpServletRequest request, boolean isQueryTotal) { + WebThreadLocalUtil.getNeedQueryTotalInThread().set(isQueryTotal ? "true" : "false"); + } + + public static String putErrorFile(String errorFile) { + String uuid = VciBaseUtil.getPk(); + tempFileForDownloadMap.put(uuid, errorFile); + return uuid; + } + + public static void downloadErrorFile(HttpServletResponse response, String uuid) throws IOException { + String errorFile = (String)tempFileForDownloadMap.getOrDefault(uuid, ""); + + try { + if (StringUtil.isNotBlank(errorFile)) { + writeFileToResponse(response, new File(errorFile), (String)null, true, "application/msexcel"); + } + } finally { + tempFileForDownloadMap.remove(uuid); + } + + } +} + diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/LangBaseUtil.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/LangBaseUtil.java new file mode 100644 index 0000000..9739921 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/LangBaseUtil.java @@ -0,0 +1,32 @@ +package com.vci.ubcs.com.vci.starter.web.util; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +public class LangBaseUtil { + public LangBaseUtil() { + } + + public static String getErrorMsg(Throwable e) { + if (e == null) { + return "鏈煡閿欒"; + } else { + if (e.getClass() != null && e.getClass().getSuperclass() != null && (e.getClass().getSuperclass().equals(RuntimeException.class) || e.getClass().getSuperclass().getName().endsWith(".VciBaseException") || e.getClass().getName().endsWith(".VciBaseException"))) { + try { + Method errorMethod = e.getClass().getMethod("getErrorMsg"); + if (errorMethod != null) { + return (String)errorMethod.invoke(e); + } + } catch (NoSuchMethodException var2) { + return e.getMessage(); + } catch (IllegalAccessException var3) { + return e.getMessage(); + } catch (InvocationTargetException var4) { + return e.getMessage(); + } + } + + return e.getMessage(); + } + } +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java index bc3a1ff..58336f4 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java @@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.vci.ubcs.com.vci.starter.exception.VciBaseException; import com.vci.ubcs.com.vci.starter.web.pagemodel.SessionInfo; +import com.vci.ubcs.com.vci.starter.web.toolmodel.DateConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.CollectionUtils; @@ -1142,6 +1143,69 @@ return listHasList; } } + public static short getShort(String s) { +// short i = false; + if (s == null) { + return 0; + } else { + try { + short i = Short.parseShort(s); + return i; + } catch (Exception var3) { + return 0; + } + } + } + + public static void setValueForField(Field field, Object obj, String value) { + try { + if (field != null && StringUtils.isNotBlank(value)) { + field.setAccessible(true); + Method setMethod = getSetmethod(field.getDeclaringClass(), field.getName()); + Class type = field.getType(); + Object valueObj = null; + if (!type.equals(Integer.TYPE) && !type.equals(Integer.class)) { + if (!type.equals(Float.TYPE) && !type.equals(Float.class)) { + if (!type.equals(Long.TYPE) && !type.equals(Long.class)) { + if (!type.equals(Double.class) && !type.equals(Double.TYPE)) { + if (type.equals(Date.class)) { + DateConverter dateConverter = new DateConverter(); + dateConverter.setAsText(value); + valueObj = dateConverter.getValue(); + } else if (type.equals(String.class)) { + valueObj = value; + } else { + valueObj = value; + if (log.isErrorEnabled()) { + log.error("涓嶆敮鎸佺殑绫诲瀷" + type.toString()); + } + } + } else { + valueObj = getDouble(value); + } + } else { + valueObj = getLong(value); + } + } else { + valueObj = getFloat(value); + } + } else { + valueObj = getInt(value); + } + + if (setMethod != null) { + setMethod.invoke(obj, valueObj); + } else { + field.set(obj, valueObj); + } + } + } catch (Throwable var7) { + if (log.isErrorEnabled()) { + log.error("璁剧疆灞炴�х殑鍊煎嚭閿欎簡閿欒", var7); + } + } + + } } diff --git a/Source/UBCS/ubcs-service-api/ubcs-dict-api/src/main/java/com/vci/ubcs/system/cache/DictBizCache.java b/Source/UBCS/ubcs-service-api/ubcs-dict-api/src/main/java/com/vci/ubcs/system/cache/DictBizCache.java index 06c34d1..ea1e9c8 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-dict-api/src/main/java/com/vci/ubcs/system/cache/DictBizCache.java +++ b/Source/UBCS/ubcs-service-api/ubcs-dict-api/src/main/java/com/vci/ubcs/system/cache/DictBizCache.java @@ -110,7 +110,7 @@ */ public static String getValue(String code, String dictKey) { String keyPrefix = DICT_VALUE.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); - return CacheUtil.get(DICT_CACHE, keyPrefix + code + StringPool.COLON, dictKey, () -> { + return CacheUtil.get(DICT_CACHE+"Biz", keyPrefix + code + StringPool.COLON, dictKey, () -> { R<String> result = getDictClient().getValue(code, dictKey); return result.getData(); }); diff --git a/Source/UBCS/ubcs-service-api/ubcs-dict-api/src/main/java/com/vci/ubcs/system/feign/IDictBizClient.java b/Source/UBCS/ubcs-service-api/ubcs-dict-api/src/main/java/com/vci/ubcs/system/feign/IDictBizClient.java index 8d10154..03954e4 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-dict-api/src/main/java/com/vci/ubcs/system/feign/IDictBizClient.java +++ b/Source/UBCS/ubcs-service-api/ubcs-dict-api/src/main/java/com/vci/ubcs/system/feign/IDictBizClient.java @@ -32,7 +32,7 @@ * @author Chill */ @FeignClient( - value = AppConstant.APPLICATION_SYSTEM_NAME, + value = AppConstant.APPLICATION_NAME_OMD, fallback = IDictBizClientFallback.class ) public interface IDictBizClient { diff --git a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IDictBizClient.java b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IDictBizClient.java index 777821c..898b720 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IDictBizClient.java +++ b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IDictBizClient.java @@ -18,6 +18,7 @@ import com.vci.ubcs.omd.entity.DictBizM; +import org.springblade.core.launch.constant.AppConstant; import org.springblade.core.tool.api.R; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; @@ -33,7 +34,7 @@ * @author Chill */ @FeignClient( - value = "blade-omd", + value = AppConstant.APPLICATION_NAME_OMD, fallback = IDictBizClientFallback.class ) public interface IDictBizClient { diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeClassifyController.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeClassifyController.java index add68b8..8232b33 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeClassifyController.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeClassifyController.java @@ -20,9 +20,15 @@ import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; import com.vci.ubcs.code.entity.CodeClassify; import com.vci.ubcs.code.mapper.CodeClassifyMapper; +import com.vci.ubcs.code.vo.CodeOsattributeVO; import com.vci.ubcs.code.vo.pagemodel.CodeClassifyVO; import com.vci.ubcs.code.vo.pagemodel.TreeQueryObject; +import com.vci.ubcs.com.vci.starter.util.LocalFileUtil; +import com.vci.ubcs.com.vci.starter.web.pagemodel.BaseQueryObject; +import com.vci.ubcs.com.vci.starter.web.pagemodel.DataGrid; import com.vci.ubcs.com.vci.starter.web.pagemodel.Tree; +import com.vci.ubcs.com.vci.starter.web.util.ControllerUtil; +import com.vci.ubcs.com.vci.starter.web.util.LangBaseUtil; import com.vci.ubcs.com.vci.starter.web.util.VciBaseUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -39,13 +45,16 @@ import org.springblade.core.tool.api.IResultCode; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.web.bind.annotation.*; import com.vci.ubcs.code.wrapper.CodeClassifyWrapper; import com.vci.ubcs.code.service.ICodeClassifyService; import org.springblade.core.boot.ctrl.BladeController; +import org.springframework.web.multipart.MultipartFile; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.Date; import java.util.List; @@ -78,6 +87,17 @@ CodeClassify detail = codeClassifyMapper.selectOne(Condition.getQueryWrapper(codeClassify)); return R.data(CodeClassifyWrapper.build().entityVO(detail)); } + + /** + * 涓婚搴撳垎绫绘爲 + * @param treeQueryObject 鏍戝舰鏌ヨ瀵硅薄 + * @return 涓婚搴撳垎绫绘樉绀烘爲 + */ + @GetMapping("/treeCodeClassify") + public List<Tree> treeCodeClassify(TreeQueryObject treeQueryObject) { + return codeClassifyService. treeCodeClassify(treeQueryObject); + } + /** * 涓婚搴撳畾涔夎〃 鍒嗛〉 */ @@ -217,14 +237,100 @@ @GetMapping("/exportClassify") public void exportClassify(String oid, HttpServletResponse response) throws IOException { String excelName = codeClassifyService.exportClassify(oid); -// try { -// ControllerUtil.writeFileToResponse(response,excelName); -// } catch (Throwable e) { -// //濡傛灉鍑洪敊,鎶婇敊璇俊鎭啓鍒皌ext -// String msg = LangBaseUtil.getErrorMsg(e); -// String errorFile = LocalFileUtil.getDefaultTempFolder() + File.separator + "閿欒.txt"; -// LocalFileUtil.writeContentToFile(msg,errorFile); -// ControllerUtil.writeFileToResponse(response,errorFile); -// } + try { + ControllerUtil.writeFileToResponse(response,excelName); + } catch (Throwable e) { + //濡傛灉鍑洪敊,鎶婇敊璇俊鎭啓鍒皌ext + String msg = LangBaseUtil.getErrorMsg(e); + String errorFile = LocalFileUtil.getDefaultTempFolder() + File.separator + "閿欒.txt"; + LocalFileUtil.writeContentToFile(msg,errorFile); + ControllerUtil.writeFileToResponse(response,errorFile); + } + } + + /** + * 涓嬭浇瀵煎叆鐨勬ā鏉� + * @param response 鍝嶅簲瀵硅薄 + * @throws IOException 鎶涘嚭寮傚父 + */ + @GetMapping("/downloadImportExcel") + public void downloadImportExcel(HttpServletResponse response) throws IOException{ + String excelName = codeClassifyService.createImportExcel(); + try { + ControllerUtil.writeFileToResponse(response,excelName); + } catch (Throwable e) { + //濡傛灉鍑洪敊,鎶婇敊璇俊鎭啓鍒皌ext + String msg = LangBaseUtil.getErrorMsg(e); + if(StringUtil.isBlank(msg)){ + msg = "鏈煡閿欒"; + } + ControllerUtil.writeDataToResponse(response,msg.getBytes(StandardCharsets.UTF_8),null); + } + } + + /** + * 瀵煎叆鍒嗙被 + * @param file excel鐨勫唴瀹� + * @return 鎵ц缁撴灉锛宱bj鏈夊�艰〃绀烘湁閿欒淇℃伅锛岄渶瑕佽闂甦ownloadErrorFile鏉ヤ笅杞� + */ + @PostMapping("/importClassify") + public R importClassify(MultipartFile file) { + String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + LocalFileUtil.getFileNameForIE(file.getOriginalFilename()); + File file1 = new File(excelFileName); + try { + file.transferTo(new File(excelFileName)); + codeClassifyService.importClassify(file1); + return R.success("瀵煎叆鎴愬姛锛�"); + }catch (Throwable e) { + String errorFile = LocalFileUtil.getDefaultTempFolder() + File.separator + "閿欒淇℃伅.txt"; + LocalFileUtil.writeContentToFile(LangBaseUtil.getErrorMsg(e),errorFile); + //鏀惧埌map閲� +// R result = R.fail("瀵煎叆澶辫触"); +// result.(ControllerUtil.putErrorFile(errorFile)); + return R.data(400,errorFile,"瀵煎叆澶辫触"); + }finally { + file1.delete(); + } + } + + /** + * 涓嬭浇閿欒鐨勬枃浠朵俊鎭� + * @param uuid 鍞竴鏍囪瘑 + * @param response 鍝嶅簲瀵硅薄 + * @throws IOException 鎶涘嚭寮傚父 + */ + @GetMapping("/downloadErrorFile") + public void downloadErrorFile(String uuid, HttpServletResponse response) throws IOException { + ControllerUtil.downloadErrorFile(response,uuid); + } + + /** + * 鑾峰彇鍒嗙被鍏宠仈鐨勫睘鎬� + * @param baseQueryObject 鏌ヨ瀵硅薄锛屽繀椤绘湁codeClassifyOid锛屾敮鎸乮d鍜宯ame涓ょ鏌ヨ鏉′欢(涓嶆敮鎸佸垎椤�) + * @return 灞炴�х殑淇℃伅锛屽寘鍚粯璁ょ殑灞炴�� + */ + @GetMapping("/listClassifyLinkAttr") + public DataGrid<CodeOsattributeVO> listClassifyLinkAttr(BaseQueryObject baseQueryObject){ + return codeClassifyService.listClassifyLinkAttr(baseQueryObject); + } + + /** + * 浣跨敤缂栧彿鐨勮矾寰勮幏鍙栧璞� + * @param idPath 缂栧彿鐨勮矾寰勶紝涓�瀹氳浠庢渶椤跺眰鑺傜偣寮�濮嬶紝鏍煎紡涓簒xx/yyy/zz 杩欐牱 + * @return 鍒嗙被鐨勬樉绀哄璞� + */ + @GetMapping("/getObjectByIdPath") + public CodeClassifyVO getObjectByIdPath(String idPath){ + return codeClassifyService.getObjectByIdPath(idPath); + } + + /** + * 涓婚搴撶殑鏍� + * @param treeQueryObject 鏍戝舰鏌ヨ瀵硅薄 + * @return 涓婚搴撴樉绀烘爲 + */ + @GetMapping("/treeTopCodeClassify") + public List<Tree> treeTopCodeClassify(TreeQueryObject treeQueryObject){ + return codeClassifyService.treeTopCodeClassify(treeQueryObject); } } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeOsbtmtypeController.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeOsbtmtypeController.java new file mode 100644 index 0000000..e8fc199 --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeOsbtmtypeController.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.code.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import lombok.AllArgsConstructor; +import javax.validation.Valid; + +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.vci.ubcs.code.entity.CodeOsbtmtypeEntity; +import com.vci.ubcs.code.vo.CodeOsbtmtypeVO; +import com.vci.ubcs.code.wrapper.CodeOsbtmtypeWrapper; +import com.vci.ubcs.code.service.ICodeOsbtmtypeService; +import org.springblade.core.boot.ctrl.BladeController; + +/** + * 涓氬姟绫诲瀷 鎺у埗鍣� + * + * @author yuxc + * @since 2023-04-13 + */ +@RestController +@AllArgsConstructor +@RequestMapping("ubcs-code/PLCodeOsbtmtype") +@Api(value = "涓氬姟绫诲瀷", tags = "涓氬姟绫诲瀷鎺ュ彛") +public class CodeOsbtmtypeController extends BladeController { + + private final ICodeOsbtmtypeService PLCodeOsbtmtypeService; + + /** + * 涓氬姟绫诲瀷 璇︽儏 + */ + @GetMapping("/detail") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "璇︽儏", notes = "浼犲叆PLCodeOsbtmtype") + public R<CodeOsbtmtypeVO> detail(CodeOsbtmtypeEntity PLCodeOsbtmtype) { + CodeOsbtmtypeEntity detail = PLCodeOsbtmtypeService.getOne(Condition.getQueryWrapper(PLCodeOsbtmtype)); + return R.data(CodeOsbtmtypeWrapper.build().entityVO(detail)); + } + /** + * 涓氬姟绫诲瀷 鍒嗛〉 + */ + @GetMapping("/list") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "鍒嗛〉", notes = "浼犲叆PLCodeOsbtmtype") + public R<IPage<CodeOsbtmtypeVO>> list(CodeOsbtmtypeEntity PLCodeOsbtmtype, Query query) { + IPage<CodeOsbtmtypeEntity> pages = PLCodeOsbtmtypeService.page(Condition.getPage(query), Condition.getQueryWrapper(PLCodeOsbtmtype)); + return R.data(CodeOsbtmtypeWrapper.build().pageVO(pages)); + } + + /** + * 涓氬姟绫诲瀷 鑷畾涔夊垎椤� + */ + @GetMapping("/page") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "鍒嗛〉", notes = "浼犲叆PLCodeOsbtmtype") + public R<IPage<CodeOsbtmtypeVO>> page(CodeOsbtmtypeVO PLCodeOsbtmtype, Query query) { + IPage<CodeOsbtmtypeVO> pages = PLCodeOsbtmtypeService.selectPLCodeOsbtmtypePage(Condition.getPage(query), PLCodeOsbtmtype); + return R.data(pages); + } + + /** + * 涓氬姟绫诲瀷 鏂板 + */ + @PostMapping("/save") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "鏂板", notes = "浼犲叆PLCodeOsbtmtype") + public R save(@Valid @RequestBody CodeOsbtmtypeEntity PLCodeOsbtmtype) { + return R.status(PLCodeOsbtmtypeService.save(PLCodeOsbtmtype)); + } + + /** + * 涓氬姟绫诲瀷 淇敼 + */ + @PostMapping("/update") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "淇敼", notes = "浼犲叆PLCodeOsbtmtype") + public R update(@Valid @RequestBody CodeOsbtmtypeEntity PLCodeOsbtmtype) { + return R.status(PLCodeOsbtmtypeService.updateById(PLCodeOsbtmtype)); + } + + /** + * 涓氬姟绫诲瀷 鏂板鎴栦慨鏀� + */ + @PostMapping("/submit") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "鏂板鎴栦慨鏀�", notes = "浼犲叆PLCodeOsbtmtype") + public R submit(@Valid @RequestBody CodeOsbtmtypeEntity PLCodeOsbtmtype) { + return R.status(PLCodeOsbtmtypeService.saveOrUpdate(PLCodeOsbtmtype)); + } + + /** + * 涓氬姟绫诲瀷 鍒犻櫎 + */ + @PostMapping("/remove") + @ApiOperationSupport(order = 7) + @ApiOperation(value = "閫昏緫鍒犻櫎", notes = "浼犲叆ids") + public R remove(@ApiParam(value = "涓婚敭闆嗗悎", required = true) @RequestParam String ids) { + return null; +// return R.status(PLCodeOsbtmtypeService.deleteLogic(Func.toLongList(ids))); + } + + +} diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTOAllcode.java similarity index 90% rename from Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java rename to Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTOAllcode.java index 4a775a4..74150ad 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTOAllcode.java @@ -16,7 +16,7 @@ */ package com.vci.ubcs.code.dto; -import com.vci.ubcs.code.entity.CodeAllCode; +import com.vci.ubcs.code.entity.CodeAllcode; import lombok.Data; import lombok.EqualsAndHashCode; @@ -28,7 +28,7 @@ */ @Data @EqualsAndHashCode(callSuper = true) -public class CodeCodeAllcodeDTO extends CodeAllCode { +public class CodeCodeAllcodeDTOAllcode extends CodeAllcode { private static final long serialVersionUID = 1L; } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeOsbtmtypeDTO.java similarity index 83% copy from Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java copy to Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeOsbtmtypeDTO.java index 4a775a4..69aca75 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeCodeAllcodeDTO.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/dto/CodeOsbtmtypeDTO.java @@ -16,19 +16,19 @@ */ package com.vci.ubcs.code.dto; -import com.vci.ubcs.code.entity.CodeAllCode; +import com.vci.ubcs.code.entity.CodeOsbtmtypeEntity; import lombok.Data; import lombok.EqualsAndHashCode; /** - * 鍏ㄩ儴鐮佸�� 鏁版嵁浼犺緭瀵硅薄瀹炰綋绫� + * 涓氬姟绫诲瀷 鏁版嵁浼犺緭瀵硅薄瀹炰綋绫� * - * @author ludc - * @since 2023-04-03 + * @author yuxc + * @since 2023-04-13 */ @Data @EqualsAndHashCode(callSuper = true) -public class CodeCodeAllcodeDTO extends CodeAllCode { +public class CodeOsbtmtypeDTO extends CodeOsbtmtypeEntity { private static final long serialVersionUID = 1L; } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/PlCodeClstemplateClient.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/CodeClstemplateClient.java similarity index 91% rename from Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/PlCodeClstemplateClient.java rename to Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/CodeClstemplateClient.java index 41b77e6..550910f 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/PlCodeClstemplateClient.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/CodeClstemplateClient.java @@ -16,10 +16,8 @@ */ package com.vci.ubcs.code.feign; -import com.baomidou.mybatisplus.core.metadata.IPage; import lombok.AllArgsConstructor; import org.springblade.core.mp.support.BladePage; -import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import com.vci.ubcs.code.entity.CodeClstemplateEntity; import com.vci.ubcs.code.service.ICodeClstemplateService; @@ -36,7 +34,7 @@ @ApiIgnore() @RestController @AllArgsConstructor -public class PlCodeClstemplateClient implements IPlCodeClstemplateClient { +public class CodeClstemplateClient implements lCodeClstemplateClient { private final ICodeClstemplateService plCodeClstemplateService; diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/PlCodeClstemplateClient.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/CodeOsbtmtypeClient.java similarity index 70% copy from Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/PlCodeClstemplateClient.java copy to Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/CodeOsbtmtypeClient.java index 41b77e6..f3be4b3 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/PlCodeClstemplateClient.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/CodeOsbtmtypeClient.java @@ -16,39 +16,37 @@ */ package com.vci.ubcs.code.feign; -import com.baomidou.mybatisplus.core.metadata.IPage; import lombok.AllArgsConstructor; import org.springblade.core.mp.support.BladePage; -import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; -import com.vci.ubcs.code.entity.CodeClstemplateEntity; -import com.vci.ubcs.code.service.ICodeClstemplateService; +import com.vci.ubcs.code.entity.CodeOsbtmtypeEntity; +import com.vci.ubcs.code.service.ICodeOsbtmtypeService; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import springfox.documentation.annotations.ApiIgnore; /** - * 缂栫爜搴撳畾涔�-妯℃澘绠$悊 Feign瀹炵幇绫� + * 涓氬姟绫诲瀷 Feign瀹炵幇绫� * * @author yuxc - * @since 2023-04-10 + * @since 2023-04-13 */ @ApiIgnore() @RestController @AllArgsConstructor -public class PlCodeClstemplateClient implements IPlCodeClstemplateClient { +public class CodeOsbtmtypeClient implements ICodeOsbtmtypeClient { - private final ICodeClstemplateService plCodeClstemplateService; + private final ICodeOsbtmtypeService PLCodeOsbtmtypeService; @Override @GetMapping(TOP) - public BladePage<CodeClstemplateEntity> top(Integer current, Integer size) { + public BladePage<CodeOsbtmtypeEntity> top(Integer current, Integer size) { Query query = new Query(); query.setCurrent(current); query.setSize(size); -// IPage<CodeClstemplateEntity> page = service.page(Condition.getPage(query)); -// return BladePage.of(page); +// IPage<CodeOsbtmtypeEntity> page = service.page(Condition.getPage(query)); return null; +// return BladePage.of(page); } } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/IPlCodeClstemplateClient.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/ICodeOsbtmtypeClient.java similarity index 75% copy from Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/IPlCodeClstemplateClient.java copy to Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/ICodeOsbtmtypeClient.java index 3e86d69..0aef291 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/IPlCodeClstemplateClient.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/ICodeOsbtmtypeClient.java @@ -17,33 +17,33 @@ package com.vci.ubcs.code.feign; import org.springblade.core.mp.support.BladePage; -import com.vci.ubcs.code.entity.CodeClstemplateEntity; +import com.vci.ubcs.code.entity.CodeOsbtmtypeEntity; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; /** - * 缂栫爜搴撳畾涔�-妯℃澘绠$悊 Feign鎺ュ彛绫� + * 涓氬姟绫诲瀷 Feign鎺ュ彛绫� * * @author yuxc - * @since 2023-04-10 + * @since 2023-04-13 */ @FeignClient( - value = "blade-plCodeClstemplate" + value = "ubcs-code" ) -public interface IPlCodeClstemplateClient { +public interface ICodeOsbtmtypeClient { String API_PREFIX = "/client"; - String TOP = API_PREFIX + "/top"; + String TOP = API_PREFIX + "/getOsbtmPage"; /** - * 鑾峰彇缂栫爜搴撳畾涔�-妯℃澘绠$悊鍒楄〃 + * 鑾峰彇涓氬姟绫诲瀷鍒楄〃 * * @param current 椤靛彿 * @param size 椤垫暟 * @return BladePage */ @GetMapping(TOP) - BladePage<CodeClstemplateEntity> top(@RequestParam("current") Integer current, @RequestParam("size") Integer size); + BladePage<CodeOsbtmtypeEntity> top(@RequestParam("current") Integer current, @RequestParam("size") Integer size); } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/IPlCodeClstemplateClient.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/lCodeClstemplateClient.java similarity index 93% rename from Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/IPlCodeClstemplateClient.java rename to Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/lCodeClstemplateClient.java index 3e86d69..9848e93 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/IPlCodeClstemplateClient.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/feign/lCodeClstemplateClient.java @@ -29,12 +29,12 @@ * @since 2023-04-10 */ @FeignClient( - value = "blade-plCodeClstemplate" + value = "ubcs-code" ) -public interface IPlCodeClstemplateClient { +public interface lCodeClstemplateClient { String API_PREFIX = "/client"; - String TOP = API_PREFIX + "/top"; + String TOP = API_PREFIX + "/getClstempPage"; /** * 鑾峰彇缂栫爜搴撳畾涔�-妯℃澘绠$悊鍒楄〃 diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/mapper/CodeClassifyMapper.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/mapper/CodeClassifyMapper.java index f6ad771..c860143 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/mapper/CodeClassifyMapper.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/mapper/CodeClassifyMapper.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ package com.vci.ubcs.code.mapper; import com.vci.ubcs.code.entity.CodeClassify; @@ -60,4 +76,12 @@ */ List<CodeClassify> selectAllLevelChildHasPath(String oid); + + @MapKey("oid") + List<Map<String,Object>> selectAllLevelParentByOid(String oid); + + + @MapKey("oid") + List<Map<String,Object>> selectByFieldPath(String fieldPath); + } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/mapper/CodeOsbtmtypeMapper.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/mapper/CodeOsbtmtypeMapper.java new file mode 100644 index 0000000..25e0424 --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/mapper/CodeOsbtmtypeMapper.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.code.mapper; + +import com.vci.ubcs.code.entity.CodeOsbtmtypeEntity; +import com.vci.ubcs.code.vo.CodeOsbtmtypeVO; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import java.util.List; + +/** + * 涓氬姟绫诲瀷 Mapper 鎺ュ彛 + * + * @author yuxc + * @since 2023-04-13 + */ +public interface CodeOsbtmtypeMapper extends BaseMapper<CodeOsbtmtypeEntity> { + + /** + * 鑷畾涔夊垎椤� + * + * @param page + * @param PLCodeOsbtmtype + * @return + */ + List<CodeOsbtmtypeVO> selectPLCodeOsbtmtypePage(IPage page, CodeOsbtmtypeVO PLCodeOsbtmtype); + + +} diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeClassifyService.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeClassifyService.java index 3c41c4c..e07b507 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeClassifyService.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeClassifyService.java @@ -4,11 +4,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.vci.ubcs.code.entity.CodeClassify; +import com.vci.ubcs.code.vo.CodeOsattributeVO; import com.vci.ubcs.code.vo.pagemodel.CodeClassifyVO; import com.vci.ubcs.code.vo.pagemodel.TreeQueryObject; +import com.vci.ubcs.com.vci.starter.web.pagemodel.BaseQueryObject; +import com.vci.ubcs.com.vci.starter.web.pagemodel.DataGrid; import com.vci.ubcs.com.vci.starter.web.pagemodel.Tree; import org.springblade.core.tool.api.R; +import java.io.File; import java.util.Collection; import java.util.List; @@ -145,4 +149,53 @@ * @return 鍒嗙被鐨勬樉绀哄璞� */ List<CodeClassifyVO> listChildrenClassify(String codeClassifyOid, boolean allLevel, String fieldInPath, boolean enable); + + /** + * 鍒涘缓瀵煎叆妯℃澘 + * @return excel鏂囦欢璺緞 + */ + String createImportExcel(); + + /** + * 瀵煎叆鍒嗙被 + * @param file1 鏂囦欢鐨勪俊鎭� + */ + void importClassify(File file1); + + /** + * 鑾峰彇鍒嗙被鍏宠仈鐨勫睘鎬� + * @param baseQueryObject 鏌ヨ瀵硅薄锛屽繀椤绘湁codeClassifyOid锛屾敮鎸乮d鍜宯ame涓ょ鏌ヨ鏉′欢 + * @return 灞炴�х殑淇℃伅锛屽寘鍚粯璁ょ殑灞炴�� + */ + DataGrid<CodeOsattributeVO> listClassifyLinkAttr(BaseQueryObject baseQueryObject); + + /** + * 鑾峰彇褰撳墠鍒嗙被鐨勯《灞傚垎绫� + * + * @param codeClassifyOid 鍒嗙被鐨勪富閿� + * @return 椤跺眰鍒嗙被鐨勪俊鎭� + */ + CodeClassifyVO getTopClassifyVO(String codeClassifyOid); + + /** + * 鑾峰彇褰撳墠鍒嗙被鐨勬墍鏈変笂绾у垎绫伙紙鍚湰娆℃煡璇㈠眰绾у彿锛� + * @param oid 涓婚敭 + * @return 鎵�鏈夌殑涓婄骇 + */ + List<CodeClassify> selectAllLevelParentByOid(String oid); + + /** + * 浣跨敤缂栧彿鐨勮矾寰勮幏鍙栧璞� + * @param idPath 缂栧彿鐨勮矾寰勶紝涓�瀹氳浠庢渶椤跺眰鑺傜偣寮�濮嬶紝鏍煎紡涓簒xx/yyy/zz 杩欐牱 + * @return 鍒嗙被鐨勬樉绀哄璞� + */ + CodeClassifyVO getObjectByIdPath(String idPath); + + + /** + * 涓婚搴撶殑鏍� + * @param treeQueryObject 鏍戝舰鏌ヨ瀵硅薄 + * @return 涓婚搴撴樉绀烘爲 + */ + List<Tree> treeTopCodeClassify(TreeQueryObject treeQueryObject); } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeKeyattrrepeatService.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeKeyattrrepeatService.java index 45724be..6587533 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeKeyattrrepeatService.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeKeyattrrepeatService.java @@ -16,8 +16,13 @@ */ package com.vci.ubcs.code.service; -import com.baomidou.mybatisplus.core.metadata.IPage; +import com.vci.ubcs.code.entity.CodeKeyattrrepeatEntity; import com.vci.ubcs.code.vo.CodeKeyattrrepeatVO; +import com.vci.ubcs.code.vo.pagemodel.CodeKeyAttrRepeatRuleVO; +import com.baomidou.mybatisplus.core.metadata.IPage; + +import java.util.Collection; +import java.util.List; /** * 鍏抽敭灞炴�ф煡閲嶈鍒� 鏈嶅姟绫� @@ -36,5 +41,25 @@ */ IPage<CodeKeyattrrepeatVO> selectPlCodeKeyattrrepeatPage(IPage<CodeKeyattrrepeatVO> page, CodeKeyattrrepeatVO plCodeKeyattrrepeat); + /** + * 涓婚敭鎵归噺鑾峰彇鍏抽敭鏁版嵁鏌ラ噸瑙勫垯 + * + * @param oidCollections 涓婚敭闆嗗悎锛屼絾鏄彈鎬ц兘褰卞搷锛屽缓璁竴娆℃煡璇笉瓒呰繃10000涓� + * @return 鍏抽敭鏁版嵁鏌ラ噸瑙勫垯鏄剧ず瀵硅薄 + */ + List<CodeKeyAttrRepeatRuleVO> listCodeKeyAttrRepeatRuleByOids(Collection<String> oidCollections) ; + /** + * 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞� + * @param codeKeyattrrepeatEntityS 鏁版嵁瀵硅薄鍒楄〃 + * @return 鏄剧ず瀵硅薄 + */ + List<CodeKeyAttrRepeatRuleVO> codeKeyAttrRepeatRuleDO2VOs(Collection<CodeKeyattrrepeatEntity> codeKeyattrrepeatEntityS); + + /** + * 鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞� + * @param codeKeyattrrepeatEntity 鏁版嵁瀵硅薄 + * @return 鏄剧ず瀵硅薄 + */ + CodeKeyAttrRepeatRuleVO codeKeyAttrRepeatRuleDO2VO(CodeKeyattrrepeatEntity codeKeyattrrepeatEntity); } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeOsattributeService.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeOsattributeService.java new file mode 100644 index 0000000..45e9723 --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeOsattributeService.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.code.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.vci.ubcs.code.entity.CodeOsattributeEntity; +import com.vci.ubcs.code.vo.CodeOsattributeVO; +import org.springblade.core.mp.base.BaseService; +import com.baomidou.mybatisplus.core.metadata.IPage; + +/** + * 灞炴�ф樉绀哄璞� 鏈嶅姟绫� + * + * @author yuxc + * @since 2023-04-14 + */ +public interface ICodeOsattributeService extends IService<CodeOsattributeEntity> { + + /** + * 鑷畾涔夊垎椤� + * + * @param page + * @param CodeOsattribute + * @return + */ + IPage<CodeOsattributeVO> selectCodeOsattributePage(IPage<CodeOsattributeVO> page, CodeOsattributeVO CodeOsattribute); + + +} diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeOsbtmtypeService.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeOsbtmtypeService.java new file mode 100644 index 0000000..e9a92a7 --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeOsbtmtypeService.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.code.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.vci.ubcs.code.entity.CodeOsbtmtypeEntity; +import com.vci.ubcs.code.vo.CodeOsbtmtypeVO; +import org.springblade.core.mp.base.BaseService; +import com.baomidou.mybatisplus.core.metadata.IPage; + +/** + * 涓氬姟绫诲瀷 鏈嶅姟绫� + * + * @author yuxc + * @since 2023-04-13 + */ +public interface ICodeOsbtmtypeService extends IService<CodeOsbtmtypeEntity> { + + /** + * 鑷畾涔夊垎椤� + * + * @param page + * @param PLCodeOsbtmtype + * @return + */ + IPage<CodeOsbtmtypeVO> selectPLCodeOsbtmtypePage(IPage<CodeOsbtmtypeVO> page, CodeOsbtmtypeVO PLCodeOsbtmtype); + + +} diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeKeyattrrepeatServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeKeyattrrepeatServiceImpl.java index f6b6551..7c44be8 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeKeyattrrepeatServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeKeyattrrepeatServiceImpl.java @@ -16,12 +16,22 @@ */ package com.vci.ubcs.code.service.impl; -import com.baomidou.mybatisplus.core.metadata.IPage; +import com.vci.ubcs.code.entity.CodeKeyattrrepeatEntity; +import com.vci.ubcs.code.enumpack.FrameworkDataLCStatus; +import com.vci.ubcs.code.vo.CodeKeyattrrepeatVO; import com.vci.ubcs.code.mapper.CodeKeyattrrepeatMapper; import com.vci.ubcs.code.service.ICodeKeyattrrepeatService; -import com.vci.ubcs.code.vo.CodeKeyattrrepeatVO; +import com.vci.ubcs.code.vo.pagemodel.CodeKeyAttrRepeatRuleVO; +import com.vci.ubcs.com.vci.starter.web.util.BeanUtilForVCI; +import com.vci.ubcs.com.vci.starter.web.util.VciBaseUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; /** * 鍏抽敭灞炴�ф煡閲嶈鍒� 鏈嶅姟瀹炵幇绫� @@ -40,5 +50,71 @@ return page.setRecords(codeKeyattrrepeatMapper.selectPlCodeKeyattrrepeatPage(page, plCodeKeyattrrepeat)); } + /** + * 涓婚敭鎵归噺鑾峰彇鍏抽敭鏁版嵁鏌ラ噸瑙勫垯 + * + * @param oidCollections 涓婚敭闆嗗悎锛屼絾鏄彈鎬ц兘褰卞搷锛屽缓璁竴娆℃煡璇笉瓒呰繃10000涓� + * @return 鍏抽敭鏁版嵁鏌ラ噸瑙勫垯鏄剧ず瀵硅薄 + */ + @Override + public List<CodeKeyAttrRepeatRuleVO> listCodeKeyAttrRepeatRuleByOids(Collection<String> oidCollections) { + VciBaseUtil.alertNotNull(oidCollections,"鏁版嵁瀵硅薄涓婚敭闆嗗悎"); + List<CodeKeyattrrepeatEntity> codeKeyAttrRepeatRuleDOList = listCodeKeyAttrRepeatRuleDOByOidCollections(oidCollections); + return codeKeyAttrRepeatRuleDO2VOs(codeKeyAttrRepeatRuleDOList); + } + /** + * 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞� + * @param codeKeyattrrepeatEntityS 鏁版嵁瀵硅薄鍒楄〃 + * @return 鏄剧ず瀵硅薄 + */ + @Override + public List<CodeKeyAttrRepeatRuleVO> codeKeyAttrRepeatRuleDO2VOs(Collection<CodeKeyattrrepeatEntity> codeKeyattrrepeatEntityS){ + List<CodeKeyAttrRepeatRuleVO> voList = new ArrayList<CodeKeyAttrRepeatRuleVO>(); + if(!CollectionUtils.isEmpty(codeKeyattrrepeatEntityS)){ + for(CodeKeyattrrepeatEntity s: codeKeyattrrepeatEntityS){ + CodeKeyAttrRepeatRuleVO vo = codeKeyAttrRepeatRuleDO2VO(s); + if(vo != null){ + voList.add(vo); + } + } + } + return voList; + } + + /** + * 浣跨敤涓婚敭闆嗗悎鏌ヨ鏁版嵁瀵硅薄 + * @param oidCollections 涓婚敭鐨勯泦鍚� + * @return 鏁版嵁瀵硅薄鍒楄〃 + */ + private List<CodeKeyattrrepeatEntity> listCodeKeyAttrRepeatRuleDOByOidCollections(Collection<String> oidCollections){ + List<CodeKeyattrrepeatEntity> codeKeyAttrRepeatRuleDOList = new ArrayList<CodeKeyattrrepeatEntity>(); + if(!CollectionUtils.isEmpty(oidCollections)){ + Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections); + for(Collection<String> oids: oidCollectionsList){ + List<CodeKeyattrrepeatEntity> tempDOList = codeKeyattrrepeatMapper.selectBatchIds(oids); + if(!CollectionUtils.isEmpty(tempDOList)){ + codeKeyAttrRepeatRuleDOList.addAll(tempDOList); + } + } + } + return codeKeyAttrRepeatRuleDOList; + } + + + /** + * 鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞� + * @param codeKeyattrrepeatEntity 鏁版嵁瀵硅薄 + * @return 鏄剧ず瀵硅薄 + */ + @Override + public CodeKeyAttrRepeatRuleVO codeKeyAttrRepeatRuleDO2VO(CodeKeyattrrepeatEntity codeKeyattrrepeatEntity) { + CodeKeyAttrRepeatRuleVO vo = new CodeKeyAttrRepeatRuleVO(); + if(codeKeyattrrepeatEntity != null) { + BeanUtilForVCI.copyPropertiesIgnoreCase(codeKeyattrrepeatEntity, vo); + //濡傛灉鏈塴cstatus鐨勭被鐨勮瘽 + vo.setLcStatusText(FrameworkDataLCStatus.getTextByValue(vo.getLcStatus())); + } + return vo; + } } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeOsbtmtypeServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeOsbtmtypeServiceImpl.java new file mode 100644 index 0000000..1639b77 --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeOsbtmtypeServiceImpl.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.code.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.vci.ubcs.code.entity.CodeOsbtmtypeEntity; +import com.vci.ubcs.code.vo.CodeOsbtmtypeVO; +import com.vci.ubcs.code.mapper.CodeOsbtmtypeMapper; +import com.vci.ubcs.code.service.ICodeOsbtmtypeService; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.core.metadata.IPage; + +/** + * 涓氬姟绫诲瀷 鏈嶅姟瀹炵幇绫� + * + * @author yuxc + * @since 2023-04-13 + */ +@Service +public class CodeOsbtmtypeServiceImpl extends ServiceImpl<CodeOsbtmtypeMapper, CodeOsbtmtypeEntity> implements ICodeOsbtmtypeService { + + @Override + public IPage<CodeOsbtmtypeVO> selectPLCodeOsbtmtypePage(IPage<CodeOsbtmtypeVO> page, CodeOsbtmtypeVO PLCodeOsbtmtype) { + return page.setRecords(baseMapper.selectPLCodeOsbtmtypePage(page, PLCodeOsbtmtype)); + } + + +} diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/wrapper/CodeButtonWrapper.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/wrapper/CodeButtonWrapper.java index 98d2be8..08d3bb8 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/wrapper/CodeButtonWrapper.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/wrapper/CodeButtonWrapper.java @@ -18,9 +18,11 @@ import com.vci.ubcs.code.entity.CodeButtonEntity; import com.vci.ubcs.code.vo.CodeButtonVO; +import com.vci.ubcs.system.cache.DictBizCache; import com.vci.ubcs.system.cache.DictCache; import com.vci.ubcs.system.enums.DictEnum; import org.springblade.core.mp.support.BaseEntityWrapper; +import org.springblade.core.redis.cache.BladeRedis; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; import org.springframework.boot.autoconfigure.security.SecurityProperties; @@ -43,8 +45,8 @@ @Override public CodeButtonVO entityVO(CodeButtonEntity codebutton) { CodeButtonVO codebuttonVO = Objects.requireNonNull(BeanUtil.copy(codebutton, CodeButtonVO.class)); - codebuttonVO.setUsedpositiontypeName(DictCache.getValue("codeButtonPosition", codebutton.getUsedpositiontype())); - codebuttonVO.setLcstatusName(DictCache.getValue("codeLcstatus", codebutton.getLcstatus())); + codebuttonVO.setUsedpositiontypeName(DictBizCache.getValue("codeButtonPosition", codebutton.getUsedpositiontype())); + codebuttonVO.setLcstatusName(DictBizCache.getValue("codeLcstatus", codebutton.getLcstatus())); return codebuttonVO; } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/wrapper/CodeOsbtmtypeWrapper.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/wrapper/CodeOsbtmtypeWrapper.java new file mode 100644 index 0000000..46a9b4e --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/wrapper/CodeOsbtmtypeWrapper.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.code.wrapper; + +import org.springblade.core.mp.support.BaseEntityWrapper; +import org.springblade.core.tool.utils.BeanUtil; +import com.vci.ubcs.code.entity.CodeOsbtmtypeEntity; +import com.vci.ubcs.code.vo.CodeOsbtmtypeVO; +import java.util.Objects; + +/** + * 涓氬姟绫诲瀷 鍖呰绫�,杩斿洖瑙嗗浘灞傛墍闇�鐨勫瓧娈� + * + * @author yuxc + * @since 2023-04-13 + */ +public class CodeOsbtmtypeWrapper extends BaseEntityWrapper<CodeOsbtmtypeEntity, CodeOsbtmtypeVO> { + + public static CodeOsbtmtypeWrapper build() { + return new CodeOsbtmtypeWrapper(); + } + + @Override + public CodeOsbtmtypeVO entityVO(CodeOsbtmtypeEntity PLCodeOsbtmtype) { + CodeOsbtmtypeVO PLCodeOsbtmtypeVO = Objects.requireNonNull(BeanUtil.copy(PLCodeOsbtmtype, CodeOsbtmtypeVO.class)); + + //User createUser = UserCache.getUser(PLCodeOsbtmtype.getCreateUser()); + //User updateUser = UserCache.getUser(PLCodeOsbtmtype.getUpdateUser()); + //PLCodeOsbtmtypeVO.setCreateUserName(createUser.getName()); + //PLCodeOsbtmtypeVO.setUpdateUserName(updateUser.getName()); + + return PLCodeOsbtmtypeVO; + } + + +} diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeCLassifyMapper.xml b/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeCLassifyMapper.xml index 761683d..32e88c9 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeCLassifyMapper.xml +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeCLassifyMapper.xml @@ -137,10 +137,23 @@ codeclassify0.parentCodeClassifyOid = #{oid} </if> <if test="oid = null or oid = ''"> - codeclassify0.parentCodeClassifyOid = is null + codeclassify0.parentCodeClassifyOid is null </if> </where> CONNECT BY PRIOR codeclassify0.OID = codeclassify0.parentCodeClassifyOid </select> + <select id="selectAllLevelParentByOid" resultType="java.util.HashMap"> + select oid,level from pl_code_classify start with oid= #{oid} connect by prior PARENTCODECLASSIFYOID = oid + </select> + + <select id="selectByFieldPath" resultType="java.util.HashMap"> + select * + from (select oid, SYS_CONNECT_BY_PATH(id, '/') as paths + from pl_code_classify + START WITH parentCodeClassifyOid is null + CONNECT BY PRIOR OID = parentCodeClassifyOid) a + where a.paths = #{fieldPath} + </select> + </mapper> diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeOsbtmtypeMapper.xml b/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeOsbtmtypeMapper.xml new file mode 100644 index 0000000..4cfba03 --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeOsbtmtypeMapper.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.vci.ubcs.code.mapper.CodeOsbtmtypeMapper"> + + <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> + <resultMap id="PLCodeOsbtmtypeResultMap" type="com.vci.ubcs.code.entity.CodeOsbtmtypeEntity"> + <result column="OID" property="oid"/> + <result column="ID" property="id"/> + <result column="NAME" property="name"/> + <result column="TABLENAME" property="tablename"/> + <result column="DESCRIPTION" property="description"/> + <result column="REVISIONRULEID" property="revisionruleid"/> + <result column="REVISIONRULENAME" property="revisionrulename"/> + <result column="REVISIONSEP" property="revisionsep"/> + <result column="INPUTREVISIONFLAG" property="inputrevisionflag"/> + <result column="SECRETFLAG" property="secretflag"/> + <result column="ABSTRACTFLAG" property="abstractflag"/> + <result column="IMPLCLASS" property="implclass"/> + <result column="SHAPE" property="shape"/> + <result column="LIFECYCLEID" property="lifecycleid"/> + <result column="LIFECYCLENAME" property="lifecyclename"/> + <result column="VERSIONRULE" property="versionrule"/> + <result column="SUBLIFECYCLEID" property="sublifecycleid"/> + <result column="SUBLIFECYCLENAME" property="sublifecyclename"/> + <result column="VIEWFLAG" property="viewflag"/> + <result column="VIEWCREATESQL" property="viewcreatesql"/> + <result column="BTMNAME" property="btmname"/> + <result column="OWNER" property="owner"/> + <result column="CREATOR" property="creator"/> + <result column="CREATETIME" property="createtime"/> + <result column="LASTMODIFIER" property="lastmodifier"/> + <result column="LASTMODIFYTIME" property="lastmodifytime"/> + <result column="TS" property="ts"/> + </resultMap> + + + <select id="selectPLCodeOsbtmtypePage" resultMap="PLCodeOsbtmtypeResultMap"> + select * from PL_CODE_OSBTMTYPE where is_deleted = 0 + </select> + + +</mapper> diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/DictBizServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/DictBizServiceImpl.java index 9b3eba4..1a4d958 100644 --- a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/DictBizServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/DictBizServiceImpl.java @@ -4,15 +4,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.vci.ubcs.common.constant.CommonConstant; -import com.vci.ubcs.omd.cache.DictBizCache; -import com.vci.ubcs.omd.entity.DictBizM; +import com.vci.ubcs.core.log.exception.ServiceException; import com.vci.ubcs.omd.mapper.DictBizMapper; import com.vci.ubcs.omd.service.IDictBizService; -import com.vci.ubcs.omd.vo.DictBizMVO; import com.vci.ubcs.omd.wrapper.DictBizWrapper; +import com.vci.ubcs.common.constant.CommonConstant; import org.springblade.core.cache.utils.CacheUtil; -import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; @@ -20,6 +17,9 @@ import org.springblade.core.tool.node.ForestNodeMerger; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringPool; +import com.vci.ubcs.omd.cache.DictBizCache; +import com.vci.ubcs.omd.entity.DictBizM; +import com.vci.ubcs.omd.vo.DictBizMVO; import org.springframework.stereotype.Service; import java.util.ArrayList; -- Gitblit v1.9.3