From 887824662344ef267e171dbfae2b8ef2145a61c6 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期五, 26 七月 2024 10:45:17 +0800
Subject: [PATCH] 属性池所有接口完善上传(待联调)
---
Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java | 2
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java | 2
Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsAttributeVO.java | 26 +++
Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsAttributeDTO.java | 26 +++
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java | 2
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsAttributeServiceI.java | 18 ++
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java | 6
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsAttributeController.java | 59 ++++++
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java | 216 ++++++++++++++++++++++++--
Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsAttributePO.java | 118 ++++++++++++++
10 files changed, 442 insertions(+), 33 deletions(-)
diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsAttributeDTO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsAttributeDTO.java
index 0f50ec0..3731204 100644
--- a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsAttributeDTO.java
+++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsAttributeDTO.java
@@ -70,6 +70,16 @@
private String btmTypeName;
/**
+ * 鍙傜収鐨勯摼鎺ョ被鍨嬪悕绉�
+ */
+ private String linkTypeName;
+
+ /**
+ * 閫夋嫨浜嗛摼鎺ョ被鍨嬫椂閫夋嫨鐨勭増鏈�
+ */
+ private Integer version;
+
+ /**
* 灞炴�х殑闀垮害
*/
private Integer attrLength;
@@ -114,6 +124,22 @@
*/
private Date lastModifyTime;
+ public String getLinkTypeName() {
+ return linkTypeName;
+ }
+
+ public void setLinkTypeName(String linkTypeName) {
+ this.linkTypeName = linkTypeName;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
+
+ public Integer getVersion() {
+ return version;
+ }
+
public void setCreator(String creator) {
this.creator = creator;
}
diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsAttributeVO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsAttributeVO.java
index 8df8068..1cad6e4 100644
--- a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsAttributeVO.java
+++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsAttributeVO.java
@@ -75,6 +75,16 @@
private String btmTypeName;
/**
+ * 鍙傜収鐨勯摼鎺ョ被鍨嬪悕绉�
+ */
+ private String linkTypeName;
+
+ /**
+ * 閫夋嫨浜嗛摼鎺ョ被鍨嬫椂閫夋嫨鐨勭増鏈�
+ */
+ private Integer version;
+
+ /**
* 灞炴�х殑闀垮害
*/
private Integer attrLength;
@@ -238,6 +248,22 @@
this.btmTypeName = btmTypeName;
}
+ public String getLinkTypeName() {
+ return linkTypeName;
+ }
+
+ public void setLinkTypeName(String linkTypeName) {
+ this.linkTypeName = linkTypeName;
+ }
+
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
+
public Integer getAttrLength() {
return attrLength;
}
diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsAttributePO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsAttributePO.java
new file mode 100644
index 0000000..71aa533
--- /dev/null
+++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsAttributePO.java
@@ -0,0 +1,118 @@
+package com.vci.po;
+
+import com.vci.dto.OsEnumItemDTO;
+import com.vci.starter.poi.annotation.ExcelColumn;
+import com.vci.starter.web.pagemodel.BaseModelVO;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 灞炴�ф睜瀵煎叆瀵硅薄
+ * @author ludc
+ * @date 2024/7/19 11:11
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class OsAttributePO extends BaseModelVO {
+
+ /**
+ * 绂佹淇敼杩欎釜鍊�
+ */
+ private static final long serialVersionUID = -2239512786206928201L;
+
+ /**
+ * 鎵�鍦ㄦ暟鎹
+ */
+ @ExcelColumn(rowIndexColumn = true,value = "")
+ private String rowIndex;
+
+ /**
+ * 灞炴�ц嫳鏂囧悕绉�
+ */
+ @ExcelColumn(value="灞炴�у悕",nullable = false)
+ private String id;
+
+ /**
+ * 鏍囩
+ */
+ @ExcelColumn(value="鏍囩")
+ private String name;
+
+ /**
+ * 鎻忚堪
+ */
+ @ExcelColumn(value="鎻忚堪")
+ private String description;
+
+ /**
+ * 灞炴�х被鍨�
+ */
+ @ExcelColumn(value="灞炴�х被鍨�",nullable = false)
+ private String attributeDataType;
+
+ /**
+ * 鍏佽涓虹┖
+ */
+ @ExcelColumn(value="鍏佽涓虹┖(鏄�/鍚�)")
+ private String nullableFlag;
+
+ /**
+ * 榛樿鍊�
+ */
+ @ExcelColumn(value="榛樿鍊�")
+ private String defaultValue;
+
+ /**
+ * 鏋氫妇鍚�
+ */
+ @ExcelColumn(value="浣跨敤鐨勬灇涓捐嫳鏂囧悕绉�")
+ private String enumId;
+
+ /**
+ * 鍙傜収鐨勪笟鍔$被鍨嬬紪鍙�
+ */
+ @ExcelColumn(value="鍙傜収鐨勪笟鍔$被鍨嬬紪鍙�")
+ private String btmTypeId;
+
+ /**
+ * 鍙傜収鐨勯摼鎺ョ被鍨嬬紪鍙�
+ */
+ @ExcelColumn(value="鍙傜収鐨勯摼鎺ョ被鍨嬬紪鍙�")
+ private String linkTypeName;
+
+ /**
+ * 鐗堟湰
+ */
+ @ExcelColumn(value="鐗堟湰鐗堟")
+ private Integer version;
+
+ /**
+ * 灞炴�ч暱搴�
+ */
+ @ExcelColumn(value="灞炴�ч暱搴�")
+ private Integer attrLength;
+
+ /**
+ * 灏忔暟杩涘害浣嶆暟
+ */
+ @ExcelColumn(value="灏忔暟绮惧害浣嶆暟")
+ private Integer precisionLength;
+
+ /**
+ * 灞炴�ч暱搴�
+ */
+ @ExcelColumn(value="灏忔暟鍒诲害浣嶆暟")
+ private Integer scaleLength;
+
+ /**
+ * 灞炴�ч暱搴�
+ */
+ @ExcelColumn(value="鍙栧�艰寖鍥�")
+ private String range;
+
+}
diff --git a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java
index 6d17c4f..1b3525c 100644
--- a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java
+++ b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java
@@ -57,7 +57,7 @@
* @param e
* @return
*/
- public static String getExceptionMessage(Exception e){
+ public static String getExceptionMessage(Throwable e){
String exceptionStr = VciExceptionTool.getExceptionStr(e);
if(exceptionStr.contains("VciBaseException")){
return e.getMessage();
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java
index 637ca30..bbffffa 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java
@@ -70,7 +70,7 @@
/**
* 蹇呭~鍒�
*/
- private ArrayList<Integer> ColumnNameisRed = new ArrayList<Integer>();
+ private List<Integer> ColumnNameisRed = new ArrayList<Integer>();
/**
* 鏃ュ織
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsAttributeController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsAttributeController.java
index a8fb24f..f33a04a 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsAttributeController.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsAttributeController.java
@@ -1,12 +1,15 @@
package com.vci.web.controller;
+import com.vci.constant.FrameWorkLangCodeConstant;
import com.vci.dto.OsAttributeDTO;
import com.vci.starter.web.annotation.controller.VciUnCheckRight;
import com.vci.starter.web.annotation.log.VciBusinessLog;
+import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.BaseQueryObject;
import com.vci.starter.web.pagemodel.BaseResult;
import com.vci.pagemodel.OsAttributeVO;
import com.vci.starter.web.util.ControllerUtil;
+import com.vci.starter.web.util.LocalFileUtil;
import com.vci.starter.web.util.VciBaseUtil;
import com.vci.web.service.OsAttributeServiceI;
import com.vci.web.util.Func;
@@ -15,8 +18,10 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
+import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.List;
@@ -65,6 +70,7 @@
* @return
*/
@GetMapping("/getByAttributeNames")
+ @VciBusinessLog(operateName = "鏍规嵁澶氫釜灞炴�у悕绉版煡璇㈠睘鎬�")
public BaseResult getByAttributeNames(String[] attrNames){
try {
return BaseResult.dataList(attributeService.getByAttributeNames(attrNames));
@@ -83,13 +89,12 @@
*/
@PostMapping( "/addAttribute")
@VciBusinessLog(operateName = "娣诲姞灞炴��")
- @VciUnCheckRight
public BaseResult addAttribute(@RequestBody OsAttributeDTO osAttributeDTO) {
try {
return attributeService.addAttribute(osAttributeDTO) ? BaseResult.success("灞炴�ф坊鍔犳垚鍔燂紒"):BaseResult.fail("灞炴�ф坊鍔犲け璐ワ紒");
}catch (Exception e) {
e.printStackTrace();
- String exceptionMessage = "澧炲姞灞炴�у瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+ String exceptionMessage = "澧炲姞灞炴�ф椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e);
logger.error(exceptionMessage);
return BaseResult.fail(exceptionMessage);
}
@@ -102,6 +107,7 @@
*/
@PutMapping( "/updateAttribute")
@VciBusinessLog(operateName = "淇敼灞炴��")
+ @VciUnCheckRight
public BaseResult updateAttribute(@RequestBody OsAttributeDTO osAttributeDTO) {
try {
return attributeService.updateAttribute(osAttributeDTO) ? BaseResult.success("灞炴�т慨鏀规垚鍔燂紒"):BaseResult.fail("灞炴�т慨鏀瑰け璐ワ紒");
@@ -156,8 +162,7 @@
* @param response
*/
@GetMapping( "/exportAttributes")
- @VciBusinessLog(operateName = "瀵煎嚭鏋氫妇绫诲瀷")
- @VciUnCheckRight
+ @VciBusinessLog(operateName = "瀵煎嚭灞炴��")
public void exportAttributes(String exportFileName,String attrNames, HttpServletResponse response){
try {
String excelPath = attributeService.exportAttributes(exportFileName,attrNames);
@@ -174,5 +179,51 @@
}
}
+ /**
+ * 涓嬭浇灞炴�у鍏ユā鏉�
+ * @param exportFileName
+ * @param response
+ */
+ @GetMapping( "/downloadAttributeTemplate")
+ @VciBusinessLog(operateName = "瀵煎嚭灞炴��")
+ public void downloadAttributeTemplate(String exportFileName, HttpServletResponse response){
+ try {
+ String excelPath = attributeService.downloadAttributeTemplate(exportFileName);
+ ControllerUtil.writeFileToResponse(response,excelPath);
+ } catch (Exception e) {
+ String msg = "涓嬭浇鏋氫妇瀵煎叆妯℃澘鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+ try {
+ //鍑洪敊鏃�
+ e.printStackTrace();
+ ControllerUtil.writeDataToResponse(response,"error_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss") + ".txt", StringUtils.isNotBlank(msg)?msg.getBytes():new byte[0],null);
+ } catch (IOException ioException) {
+ ioException.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 瀵煎叆灞炴��
+ * @param file
+ * @return
+ */
+ @PostMapping("/importAttributes")
+ @VciUnCheckRight
+ public BaseResult importAttributes(MultipartFile file){
+ String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + LocalFileUtil.getFileNameForIE(file.getOriginalFilename());
+ File file1 = new File(excelFileName);
+ try {
+ file.transferTo(new File(excelFileName));
+ if (file != null) {
+ return attributeService.importAttributes(file1);
+ } else {
+ return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"鏃犲鍏ョ殑鏂囦欢"});
+ }
+ }catch (Throwable e) {
+ throw new VciBaseException(VciBaseUtil.getExceptionMessage(e),new String[0],e);
+ }finally {
+ file1.delete();
+ }
+ }
}
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java
index e5c3025..a8048f4 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java
@@ -270,7 +270,7 @@
return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"鏃犲鍏ョ殑鏂囦欢"});
}
}catch (Throwable e) {
- throw new VciBaseException(e.getMessage(),new String[0],e);
+ throw new VciBaseException(VciBaseUtil.getExceptionMessage(e),new String[0],e);
}finally {
file1.delete();
}
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsAttributeServiceI.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsAttributeServiceI.java
index 5931650..b1e782f 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsAttributeServiceI.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsAttributeServiceI.java
@@ -4,9 +4,12 @@
import com.vci.corba.omd.atm.AttributeDef;
import com.vci.dto.OsAttributeDTO;
import com.vci.starter.web.pagemodel.BaseQueryObject;
+import com.vci.starter.web.pagemodel.BaseResult;
import com.vci.starter.web.pagemodel.DataGrid;
import com.vci.pagemodel.OsAttributeVO;
+import org.springframework.web.multipart.MultipartFile;
+import java.io.File;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -152,6 +155,21 @@
String exportAttributes(String exportFileName,String attrNames) throws PLException;
/**
+ * 涓嬭浇灞炴�у鍏ユā鏉�
+ * @param exportFileName
+ * @return
+ * @throws PLException
+ */
+ String downloadAttributeTemplate(String exportFileName) throws Exception;
+
+ /**
+ * 瀵煎叆灞炴��
+ * @param file
+ * @return
+ */
+ BaseResult importAttributes(File file) throws Exception;
+
+ /**
* 鏄惁榛樿鐨勫睘鎬�
* @param attr 灞炴�х紪鍙�
* @return true琛ㄧず鏄粯璁ゅ睘鎬�
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java
index b2d484d..2d0e461 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java
@@ -8,17 +8,24 @@
import com.vci.corba.common.PLException;
import com.vci.corba.omd.atm.AttributeDef;
import com.vci.dto.OsAttributeDTO;
+import com.vci.dto.OsEnumDTO;
+import com.vci.dto.OsEnumItemDTO;
import com.vci.omd.dataType.VTDataType;
import com.vci.pagemodel.OsEnumItemVO;
import com.vci.pagemodel.OsEnumVO;
import com.vci.pagemodel.OsUsedAttributeVO;
+import com.vci.po.OsAttributePO;
+import com.vci.po.OsEnumPO;
+import com.vci.starter.poi.bo.ReadExcelOption;
import com.vci.starter.poi.bo.WriteExcelData;
import com.vci.starter.poi.bo.WriteExcelOption;
+import com.vci.starter.poi.constant.ExcelLangCodeConstant;
import com.vci.starter.poi.util.ExcelUtil;
import com.vci.starter.web.annotation.log.VciUnLog;
import com.vci.starter.web.enumpck.VciFieldTypeEnum;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.BaseQueryObject;
+import com.vci.starter.web.pagemodel.BaseResult;
import com.vci.starter.web.pagemodel.DataGrid;
import com.vci.starter.web.util.*;
import com.vci.model.OsAttributeDO;
@@ -31,12 +38,14 @@
import com.vci.web.util.PlatformClientUtil;
import com.vci.web.util.WebUtil;
import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.util.HSSFColor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
+import org.springframework.web.multipart.MultipartFile;
import javax.swing.*;
import java.awt.*;
@@ -102,6 +111,11 @@
@Autowired(required = false)
@Lazy
private OsBtmServiceImpl osBtmService;
+
+ /**
+ * 蹇呭~鍒�
+ */
+ private List<Integer> ColumnNameisRed = new ArrayList<Integer>();
/**
* 榛樿鐨勫睘鎬�
@@ -185,7 +199,7 @@
VciBaseUtil.alertNotNull(attrNames,"灞炴�у悕");
List<OsAttributeVO> osAttributeVOS = new ArrayList<>();
for (int i = 0; i < attrNames.length; i++) {
- AttributeDef[] attributeDefs = platformClientUtil.getAttributeService().getAttributeDefs(attrNames[i],1,1);
+ AttributeDef[] attributeDefs = platformClientUtil.getAttributeService().getAttributeDefs(attrNames[i].toLowerCase(Locale.ROOT),1,1);
if(Func.isNotEmpty(attributeDefs)){
Arrays.stream(attributeDefs).forEach(attributeDef -> {
osAttributeVOS.add(attributeDO2VO(attributeDef));
@@ -224,8 +238,8 @@
attributeVO.setId(attribItem.name);
attributeVO.setCreator(attribItem.creator);
try {
- attributeVO.setCreateTime(VciDateUtil.str2Date(String.valueOf(attribItem.createTime),VciDateUtil.DateTimeFormat));
- attributeVO.setLastModifyTime(VciDateUtil.str2Date(String.valueOf(attribItem.modifyTime),VciDateUtil.DateTimeFormat));
+ attributeVO.setCreateTime(new Date(attribItem.createTime));
+ attributeVO.setLastModifyTime(new Date(attribItem.modifyTime));
attributeVO.setTs(VciDateUtil.str2Date(attribItem.ts,VciDateUtil.DateTimeMillFormat));
}catch (Throwable e){
@@ -236,7 +250,11 @@
attributeVO.setAttributeDataType(attribItem.vtDataType);
attributeVO.setAttributeDataTypeText(VciFieldTypeEnum.getTextByValue(attribItem.vtDataType));
attributeVO.setDefaultValue(attribItem.defValue);
- attributeVO.setRange(attribItem.rage);
+ if(Func.isNotBlank(attribItem.rage)){
+ attributeVO.setRange(attribItem.rage.replace("<","<"));
+ }else{
+ attributeVO.setRange(attribItem.rage);
+ }
attributeVO.setOther(attribItem.other);
//澶勭悊鍙傜収鐩稿叧灞炴��
if(StringUtils.isNotBlank(attribItem.other)) {
@@ -248,6 +266,12 @@
attributeVO.setBtmTypeId(s.split("=")[1].trim());
}
//閾炬帴绫诲瀷涓嶆敮鎸�
+ if (s.toLowerCase().contains("link") && s.split("=").length > 1) {//蹇呴』瑕佸垽鏂暱搴︼紝鍥犱负鏋氫妇鐨勬椂鍊欎篃鏄寘鍚繖涓猙tm鐨�
+ attributeVO.setLinkTypeName(s.split("=")[1].trim());
+ }
+ if (s.toLowerCase().contains("version") && s.split("=").length > 1) {//蹇呴』瑕佸垽鏂暱搴︼紝鍥犱负鏋氫妇鐨勬椂鍊欎篃鏄寘鍚繖涓猙tm鐨�
+ attributeVO.setVersion(WebUtil.getInt(s.split("=")[1].trim()));
+ }
}
}
//蹇呰緭鍜岄暱搴�
@@ -453,6 +477,7 @@
//妫�鏌ラ粯璁ゅ�间笌灞炴�х被鍨嬫槸鍚﹀尮閰�
checkDefValue(osAttributeDTO);
//dto瀵硅薄杞崲涓哄瓨鍌ㄦ墍闇�瀵硅薄
+ osAttributeDTO.setOid(VciBaseUtil.getPk().toUpperCase(Locale.ROOT));
AttributeDef attributeDef = this.osAttributeDTO2AttributeDef(osAttributeDTO);
return platformClientUtil.getAttributeService().addAttributeDef(attributeDef);
}
@@ -486,7 +511,7 @@
if(hasInstance && !compatible){
throw new PLException("500",new String[]{"鏃犳晥鍙樻洿, 涓嶅吋瀹瑰凡浜х敓鐨勬暟鎹紒"});
}
- String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
+ String userId = "developer";//WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
osAttributeDTO.setLastModifier(userId);
osAttributeDTO.setCreator(osAttributeVO.getCreator());
osAttributeDTO.setCreateTime(osAttributeVO.getCreateTime());
@@ -519,16 +544,22 @@
*/
private AttributeDef osAttributeDTO2AttributeDef(OsAttributeDTO osAttributeDTO) {
AttributeDef attributeDef = new AttributeDef();
+ attributeDef.oid = osAttributeDTO.getOid();
attributeDef.name = osAttributeDTO.getId().toLowerCase().replaceAll(" ", "");
attributeDef.label = osAttributeDTO.getName();
attributeDef.description = osAttributeDTO.getDescription();
attributeDef.vtDataType = (String)osAttributeDTO.getAttributeDataType();
attributeDef.defValue = Func.isBlank(osAttributeDTO.getDefaultValue()) ? "" : osAttributeDTO.getDefaultValue();
- attributeDef.rage = Func.isBlank(osAttributeDTO.getRange()) ? "" : osAttributeDTO.getRange();
- attributeDef.creator = Func.isBlank(osAttributeDTO.getCreator()) ? WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId():osAttributeDTO.getCreator();
+ if(Func.isBlank(osAttributeDTO.getRange())){
+ attributeDef.rage = "";
+ }else{
+ //鐗规畩瀛楃澶勭悊锛岀洿鎺ュ瓨鍌�<浼氭姤閿�
+ attributeDef.rage = osAttributeDTO.getRange().replace("<","<");
+ }
attributeDef.ts = Func.format((Func.isNotEmpty(osAttributeDTO.getTs()) ? osAttributeDTO.getTs():new Date()),VciDateUtil.DateTimeMillFormat);
+ attributeDef.creator = "developer";//Func.isBlank(osAttributeDTO.getCreator()) ? WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId():osAttributeDTO.getCreator();
attributeDef.createTime = Func.isEmpty(osAttributeDTO.getCreateTime()) ? System.currentTimeMillis():osAttributeDTO.getCreateTime().getTime();
- attributeDef.modifier = Func.isBlank(osAttributeDTO.getLastModifier()) ? WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId():osAttributeDTO.getLastModifier();
+ attributeDef.modifier = "developer";//Func.isBlank(osAttributeDTO.getLastModifier()) ? WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId():osAttributeDTO.getLastModifier();
attributeDef.modifyTime = System.currentTimeMillis();
//other闇�瑕佽嚜琛屽鐞�
StringBuffer sb = new StringBuffer();
@@ -563,9 +594,12 @@
break;
case VTString:
if (StringUtils.isNotBlank(osAttributeDTO.getBtmTypeId())) {
- //鍙傜収
+ //鍙傜収涓氬姟绫诲瀷
sb.append(BTM).append(" = ").append(osAttributeDTO.getBtmTypeId()).append(";");
- //閾炬帴绫诲瀷鏆傛椂涓嶆敮鎸�
+ }
+ if(StringUtils.isNotBlank(osAttributeDTO.getLinkTypeName())){
+ //鍙傜収閾炬帴绫诲瀷
+ sb.append(LINKTYPENAME).append(" = ").append(osAttributeDTO.getLinkTypeName()).append(";");
}
sb.append(LENGTH).append(" = ").append(length > osAttributeDTO.getAttrLength()?length:osAttributeDTO.getAttrLength()).append(";");
if (StringUtils.isNotBlank(osAttributeDTO.getEnumId())) {
@@ -636,12 +670,12 @@
}
if(!attributeName.matches("[a-z A-Z]*")){
- throw new PLException("500",new String[]{"娉ㄦ剰锛氬睘鎬у悕鍙兘涓鸿嫳鏂囧瓧姣�!"+ NAME_MAX_LENGTH});
+ throw new PLException("500",new String[]{"娉ㄦ剰锛氬睘鎬у悕鍙兘涓鸿嫳鏂囧瓧姣�!"});
}
int length = attributeName.length();
if(length > NAME_MAX_LENGTH){
- throw new PLException("500",new String[]{"灞炴�у悕杩囬暱,灞炴�у悕闀垮害涓嶈兘瓒呰繃!"+ NAME_MAX_LENGTH});
+ throw new PLException("500",new String[]{"灞炴�у悕杩囬暱,灞炴�у悕闀垮害涓嶈兘瓒呰繃"+ NAME_MAX_LENGTH});
}
String abName = attributeName.toLowerCase();
@@ -692,7 +726,6 @@
if(rages == null || rages.equals("")){
return;
}
-
VTInteger obj = new VTInteger(Integer.valueOf(defValue));
boolean flag = obj.checkRageValueByRage(rages);
if(!flag){
@@ -707,7 +740,6 @@
if(rages == null || rages.equals("")){
return;
}
-
VTLong obj = new VTLong(Long.valueOf(defValue));
boolean flag = obj.checkRageValueByRage(rages);
if(!flag){
@@ -727,7 +759,6 @@
if(!flag){
throw new PLException("500",new String[]{"榛樿鍊间笌鍊煎煙鍐茬獊锛�"});
}
-
}
}
}
@@ -840,7 +871,7 @@
Arrays.asList("灞炴�у悕", "鏍囩", "鎻忚堪",
"灞炴�х被鍨�", "鍏佽涓虹┖", "榛樿鍊�", "浣跨敤鐨勬灇涓捐嫳鏂囧悕绉�(鏋氫妇鍚�)",
"浣跨敤鐨勬灇涓句腑鏂囧悕绉�(鏍囩)", "鍙傜収鐨勪笟鍔$被鍨嬬紪鍙�", "鍙傜収鐨勪笟鍔$被鍨嬪悕绉�",
- "灞炴�ч暱搴�", "灏忔暟绮惧害浣嶆暟","灏忔暟鍒诲害浣嶆暟","鍙栧�艰寖鍥�","鍒涘缓鏃堕棿")
+ "鍙傜収鐨勯摼鎺ョ被鍨嬪悕绉�","鐗堟湰鐗堟","灞炴�ч暱搴�", "灏忔暟绮惧害浣嶆暟","灏忔暟鍒诲害浣嶆暟","鍙栧�艰寖鍥�","鍒涘缓鏃堕棿")
);
//鍐檈xcel
@@ -869,7 +900,7 @@
excelDataList.add(new WriteExcelData(i+1,0, osAttributeVO.getId()));
excelDataList.add(new WriteExcelData(i+1,1, osAttributeVO.getName()));
excelDataList.add(new WriteExcelData(i+1,2, osAttributeVO.getDescription()));
- excelDataList.add(new WriteExcelData(i+1,3, osAttributeVO.getAttributeDataTypeText()+(osAttributeVO.getAttributeDataType())));
+ excelDataList.add(new WriteExcelData(i+1,3, osAttributeVO.getAttributeDataTypeText()+"("+osAttributeVO.getAttributeDataType()+")"));
excelDataList.add(new WriteExcelData(i+1,4, osAttributeVO.isNullableFlag()));
excelDataList.add(new WriteExcelData(i+1,5, osAttributeVO.getDefaultValue()));
excelDataList.add(new WriteExcelData(i+1,6, osAttributeVO.getEnumId()));
@@ -877,15 +908,154 @@
excelDataList.add(new WriteExcelData(i+1,8, osAttributeVO.getBtmTypeId()));
excelDataList.add(new WriteExcelData(i+1,9, osAttributeVO.getBtmTypeName()));
excelDataList.add(new WriteExcelData(i+1,10, osAttributeVO.getAttrLength()));
- excelDataList.add(new WriteExcelData(i+1,11, osAttributeVO.getPrecisionLength()));
- excelDataList.add(new WriteExcelData(i+1,12, osAttributeVO.getScaleLength()));
- excelDataList.add(new WriteExcelData(i+1,13, osAttributeVO.getRange()));
- excelDataList.add(new WriteExcelData(i+1,14, osAttributeVO.getCreateTime()));
+ excelDataList.add(new WriteExcelData(i+1,11, osAttributeVO.getLinkTypeName()));
+ excelDataList.add(new WriteExcelData(i+1,12, osAttributeVO.getVersion()));
+ excelDataList.add(new WriteExcelData(i+1,13, osAttributeVO.getPrecisionLength()));
+ excelDataList.add(new WriteExcelData(i+1,14, osAttributeVO.getScaleLength()));
+ excelDataList.add(new WriteExcelData(i+1,15, osAttributeVO.getRange()));
+ excelDataList.add(new WriteExcelData(i+1,16, osAttributeVO.getCreateTime()));
}
}
WriteExcelOption excelOption = new WriteExcelOption(excelDataList);
ExcelUtil.writeDataToFile(excelPath, excelOption);
return excelPath;
+ }
+
+ /**
+ * 涓嬭浇灞炴�у鍏ユā鏉�
+ * @param exportFileName
+ * @return
+ * @throws PLException
+ */
+ @Override
+ public String downloadAttributeTemplate(String exportFileName) throws Exception {
+ //鐣岄潰娌′紶鍚嶇О锛屼娇鐢ㄩ粯璁ゅ鍑哄悕绉�
+ exportFileName = Func.isBlank(exportFileName) ? "灞炴�ф睜瀵煎叆妯℃澘_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss"):exportFileName;
+ //璁剧疆鍒楀悕
+ List<String> columns = new ArrayList<>(
+ Arrays.asList("灞炴�у悕", "鏍囩", "鎻忚堪",
+ "灞炴�х被鍨�", "鍏佽涓虹┖(鏄�/鍚�)", "榛樿鍊�", "浣跨敤鐨勬灇涓捐嫳鏂囧悕绉�", "鍙傜収鐨勪笟鍔$被鍨嬬紪鍙�",
+ "鍙傜収鐨勯摼鎺ョ被鍨嬬紪鍙�","鐗堟湰鐗堟","灞炴�ч暱搴�", "灏忔暟绮惧害浣嶆暟","灏忔暟鍒诲害浣嶆暟","鍙栧�艰寖鍥�")
+ );
+ //璁剧疆蹇呭~鍒�
+ ColumnNameisRed.clear();
+ ColumnNameisRed.add(0);
+ ColumnNameisRed.add(3);
+ ColumnNameisRed.add(10);
+
+ //鍐檈xcel
+ String excelPath = LocalFileUtil.getDefaultTempFolder() + File.separator + exportFileName + ".xls";
+ try {
+ new File(excelPath).createNewFile();
+ } catch (Throwable e) {
+ throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[]{excelPath}, e);
+ }
+ //璁剧疆鍒�
+ List<WriteExcelData> excelDataList = new ArrayList<>();
+ //璁剧疆鍒楀ご
+ for (int index = 0; index < columns.size(); index++) {
+ //鍒ゆ柇鏄惁涓哄繀濉垪锛岀粰蹇呭~鍒楄缃鑹�
+ if(ColumnNameisRed.contains(index)){
+ WriteExcelData excelData = new WriteExcelData(0, index, columns.get(index));
+ excelData.setFontColor(String.valueOf(HSSFColor.HSSFColorPredefined.RED.getIndex()));
+ excelDataList.add(excelData);
+ }else{
+ excelDataList.add(new WriteExcelData(0,index, columns.get(index)));
+ }
+ }
+ WriteExcelOption excelOption = new WriteExcelOption(excelDataList);
+ ExcelUtil.writeDataToFile(excelPath, excelOption);
+ return excelPath;
+ }
+
+ /**
+ * 瀵煎叆灞炴��
+ * @param file
+ * @return
+ */
+ @Override
+ public BaseResult importAttributes(File file) throws Exception{
+ VciBaseUtil.alertNotNull(file,"excel鏂囦欢");
+ if(!file.exists()){
+ throw new VciBaseException("瀵煎叆鐨別xcel鏂囦欢涓嶅瓨鍦�,{0}",new String[]{file.getPath()});
+ }
+ try{
+ //1銆佽鍙杄xcel涓殑鏁版嵁锛岀粍鎴愬璞�
+ ReadExcelOption excelOption = new ReadExcelOption();
+ List<OsAttributePO> poList = ExcelUtil.readDataObjectFromExcel(file, OsAttributePO.class,excelOption,(value, po, fieldName)->{});
+ //鍘婚櫎閮芥槸绌虹殑鎯呭喌
+ if(CollectionUtils.isEmpty(poList)){
+ return BaseResult.fail(ExcelLangCodeConstant.IMPORT_CONTENT_NULL,new String[]{});
+ }
+ //excel鍒ら噸锛屾暟鎹牎楠岋紝dto瀵硅薄杞崲锛屽瓨鍌ㄥ璞¤浆鎹紝鎵ц淇濆瓨
+ List<OsAttributeDTO> dtoList = new ArrayList<>();
+ //褰撳墠excel涓槸鍚﹂噸澶嶇敤鐨勫垽閲峂ap:锛坘ey锛氬垽閲嶅睘鎬э紝value锛氳鍙凤級
+ Map<String, String> excelReapeat = new HashMap<>();
+ //鍒ゆ柇蹇呭~灞炴�ф槸鍚︿负绌猴紝鐢ㄦ埛鏄惁宸插瓨鍦紝浠ュ強閮ㄩ棬鏄惁濉敊绛夋牎楠岄�昏緫
+ poList.stream().forEach(osAttributePO -> {
+ if(Func.isBlank(osAttributePO.getId())){//灞炴�у悕鍒ょ┖
+ throw new VciBaseException("绗��"+osAttributePO.getRowIndex()+"銆戣锛宔numnameerror");
+ }else if(Func.isBlank(osAttributePO.getAttributeDataType())){
+ throw new VciBaseException("绗��"+osAttributePO.getRowIndex()+"銆戣锛宼ypeerror");
+ }else if(excelReapeat.containsKey(osAttributePO.getId())){//灞炴�у悕琛ㄦ牸涓垽閲�
+ throw new VciBaseException("绗��"+excelReapeat.get(osAttributePO.getId())+"銆戣鍜岀銆�"+osAttributePO.getRowIndex()+"銆戣鏁版嵁锛屽睘鎬у悕閲嶅");
+ }
+ //灞炴�у悕鏍¢獙
+ try {
+ checkName(osAttributePO.getId());
+ } catch (PLException e) {
+ e.printStackTrace();
+ throw new VciBaseException(VciBaseUtil.getExceptionMessage(e));
+ }
+ //灞炴�у悕excel涓垽閲嶅鐞�
+ excelReapeat.put(osAttributePO.getId(),osAttributePO.getRowIndex());
+ OsAttributeDTO osAttributeDTO = new OsAttributeDTO();
+ osAttributeDTO.setOid(VciBaseUtil.getPk().toUpperCase(Locale.ROOT));
+ osAttributeDTO.setId(osAttributePO.getId());
+ osAttributeDTO.setName(osAttributePO.getName());
+ osAttributeDTO.setDescription(osAttributePO.getDescription());
+ osAttributeDTO.setDefaultValue(osAttributePO.getDefaultValue());
+ osAttributeDTO.setAttrLength(osAttributePO.getAttrLength());
+ osAttributeDTO.setAttributeDataType(osAttributePO.getAttributeDataType());
+ osAttributeDTO.setBtmTypeId(osAttributePO.getBtmTypeId());
+ //osAttributeDTO.setBtmTypeName(osAttributePO.getBtmname());
+ osAttributeDTO.setLinkTypeName(osAttributePO.getLinkTypeName());
+ osAttributeDTO.setVersion(osAttributePO.getVersion());
+ osAttributeDTO.setEnumId(osAttributePO.getEnumId());
+ //osAttributeDTO.setEnumName(osAttributePO.getEnumId());
+ osAttributeDTO.setPrecisionLength(osAttributePO.getPrecisionLength());
+ osAttributeDTO.setScaleLength(osAttributePO.getScaleLength());
+ osAttributeDTO.setRange(osAttributePO.getRange());
+ osAttributeDTO.setNullableFlag("鏄�".equals(osAttributePO.getNullableFlag()) ? true:false);
+ try {
+ //妫�鏌ラ粯璁ゅ�间笌灞炴�х被鍨嬫槸鍚﹀尮閰�
+ checkDefValue(osAttributeDTO);
+ } catch (PLException e) {
+ e.printStackTrace();
+ throw new VciBaseException(e.getMessage());
+ }
+ dtoList.add(osAttributeDTO);
+ });
+ //鎵ц淇濆瓨鎿嶄綔
+ dtoList.stream().forEach(dto->{
+ try {
+ boolean b = platformClientUtil.getAttributeService().addAttributeDef(osAttributeDTO2AttributeDef(dto));
+ if(!b){
+ throw new VciBaseException("save and return false");
+ }
+ } catch (PLException e) {
+ e.printStackTrace();
+ throw new VciBaseException("鎵ц淇濆瓨鏃跺嚭鐜伴敊璇紝閿欒灞炴�у璞″悕涓猴細銆�" + dto.getId() + "銆戯紝鍘熷洜锛�"+e.getMessage());
+ }
+ });
+ }catch (Exception e){
+ if(logger.isErrorEnabled()){
+ logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨鐢ㄦ埛淇℃伅鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",VciBaseUtil.getExceptionMessage(e));
+ }
+ e.printStackTrace();
+ return BaseResult.fail(VciBaseUtil.getExceptionMessage(e),new String[]{},e);
+ }
+ return BaseResult.success("鏋氫妇瀵煎叆鎴愬姛锛�");
}
/**
@@ -909,11 +1079,11 @@
*/
private boolean isReferAttr(String other){
if(StringUtils.isNotBlank(other)
- && (other.toLowerCase().contains("btm") || other.toLowerCase().contains("ltm"))){
+ && (other.toLowerCase().contains("btm") || other.toLowerCase().contains("link"))){
//杩樹笉鑳界‘瀹氾紝鍥犱负鏋氫妇鐨勬椂鍊欎篃浼氳缃産tm
String[] temp = other.split(";");
for(String s : temp){
- if((s.contains("btm") || s.contains("ltm")) && s.split("=").length>1){
+ if((s.contains("btm") || s.contains("link")) && s.split("=").length>1){
return true;
}
}
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java
index e81815d..97f5267 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java
@@ -86,7 +86,7 @@
/**
* 蹇呭~鍒�
*/
- private ArrayList<Integer> ColumnNameisRed = new ArrayList<Integer>();
+ private List<Integer> ColumnNameisRed = new ArrayList<Integer>();
/**
* 鏃ュ織
@@ -567,7 +567,7 @@
if(Func.isNotEmpty(osEnumVOList)){
repeatEnumId = osEnumVOList.stream().map(OsEnumVO::getId).collect(Collectors.toList());
}
- //褰撳墠excel涓槸鍚﹂噸澶嶇敤鐨勫垽閲峂ap:锛坘ey锛氳处鍙凤紝value锛氳鍙凤級
+ //褰撳墠excel涓槸鍚﹂噸澶嶇敤鐨勫垽閲峂ap:锛坘ey锛氬垽閲嶅睘鎬э紝value锛氳鍙凤級
Map<String, String> excelReapeat = new HashMap<>();
//鍒ゆ柇蹇呭~灞炴�ф槸鍚︿负绌猴紝鐢ㄦ埛鏄惁宸插瓨鍦紝浠ュ強閮ㄩ棬鏄惁濉敊绛夋牎楠岄�昏緫
List<String> finalRepeatEnumId = repeatEnumId;
@@ -585,7 +585,7 @@
}else if (Func.isNotEmpty(osEnumVOList) && finalRepeatEnumId.contains(osEnumPO.getId())){//2銆佸垽鏂灇涓惧悕鏄惁涓庣郴缁熶腑閲嶅
throw new VciBaseException("绗��"+osEnumPO.getRowIndex()+"銆戣锛屾灇涓惧悕鍦ㄧ郴缁熶腑宸茬粡瀛樺湪,璇蜂慨鏀�!");
}
- //鍏堝蹇呭~灞炴�у垽绌哄鐞�
+ //鍏堝鏋氫妇鍚峞xcel涓渶瑕佸垽閲嶅鐞�
excelReapeat.put(osEnumPO.getId(),osEnumPO.getRowIndex());
});
//淇濆瓨閫昏緫
--
Gitblit v1.9.3