From 894a0ce49bab4add5dd9208539dbc03c1c85414b Mon Sep 17 00:00:00 2001 From: 田源 <lastanimals@163.com> Date: 星期四, 29 八月 2024 17:50:39 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/PLActionParamDTO.java | 37 +++ Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebPortalVIController.java | 6 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsActionServiceI.java | 23 + Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLinkTypeController.java | 24 ++ Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsPortalVIServiceImpl.java | 268 +++++++++++++++++++------- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsAttributeServiceI.java | 8 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsLinkTypeServiceI.java | 9 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsActionServiceImpl.java | 72 ++++++ Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsActionController.java | 55 +++++ Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java | 25 ++ Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java | 26 ++ 11 files changed, 467 insertions(+), 86 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/PLActionParamDTO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/PLActionParamDTO.java new file mode 100644 index 0000000..070f307 --- /dev/null +++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/PLActionParamDTO.java @@ -0,0 +1,37 @@ +package com.vci.dto; + +import lombok.Data; + +/** + * Action鍙傛暟鍒楄〃浼犺緭瀵硅薄 + * @author yuxc + * @date 2024/8/28 16:40 + */ +@Data +public class PLActionParamDTO implements java.io.Serializable{ + + /** + * 绂佹淇敼杩欎釜鍊� + */ + private static final long serialVersionUID = 2009350578651813260L; + /** + * 涓婚敭 + */ + public String oid; + /** + * 鍙傛暟鍚嶇О + */ + public String name; + /** + * 榛樿鍊� + */ + public String defaultValue; + /** + * 鎻愮ず淇℃伅 + */ + public String description; + /** + * 鐖禷ction鐨処D + */ + public String action; +} diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsActionController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsActionController.java index fa65c57..56ff805 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsActionController.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsActionController.java @@ -1,10 +1,7 @@ package com.vci.web.controller; import com.vci.corba.common.PLException; -import com.vci.dto.PLActionClsDTO; -import com.vci.dto.PLActionDTO; -import com.vci.dto.PLActionExpDTO; -import com.vci.dto.PLActionQueryDTO; +import com.vci.dto.*; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.pagemodel.BaseResult; import com.vci.starter.web.util.VciBaseUtil; @@ -185,6 +182,56 @@ osActionServiceI.exportAction(plActionExpDTO, response); }catch (Throwable e) { throw new VciBaseException(VciBaseUtil.getExceptionMessage(e),new String[0],e); + } } + + /** + * 淇濆瓨Action鍙傛暟鏁版嵁 + * dto action浼犺緭瀵硅薄 + * @return 淇濆瓨缁撴灉 + */ + @PostMapping("/savePLActionParam") + public BaseResult savePLActionParam(@RequestBody PLActionParamDTO dto){ + try { + return osActionServiceI.savePLActionParam(dto); + } catch (PLException e) { + BaseResult objectBaseResult = new BaseResult<>(); + objectBaseResult.setCode(Integer.parseInt(e.code)); + objectBaseResult.setMsg(Arrays.toString(e.messages)); + return objectBaseResult; + } + } + + /** + * 淇敼Action鍙傛暟鏁版嵁 + * dto action浼犺緭瀵硅薄 + * @return 淇濆瓨缁撴灉 + */ + @PostMapping("/updatePLActionParam") + public BaseResult updatePLActionParam(@RequestBody PLActionParamDTO dto){ + try { + return osActionServiceI.updatePLActionParam(dto); + } catch (PLException e) { + BaseResult objectBaseResult = new BaseResult<>(); + objectBaseResult.setCode(Integer.parseInt(e.code)); + objectBaseResult.setMsg(Arrays.toString(e.messages)); + return objectBaseResult; + } + } + /** + * 鍒犻櫎Action鍙傛暟鏁版嵁 + * oid 鍙傛暟涓婚敭 + * @return 淇濆瓨缁撴灉 + */ + @DeleteMapping("/deletePLActionParam") + public BaseResult deletePLActionParam(String oid){ + try { + return osActionServiceI.deletePLActionParam(oid); + } catch (PLException e) { + BaseResult objectBaseResult = new BaseResult<>(); + objectBaseResult.setCode(Integer.parseInt(e.code)); + objectBaseResult.setMsg(Arrays.toString(e.messages)); + return objectBaseResult; + } } } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLinkTypeController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLinkTypeController.java index cb3bc49..9bbe900 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLinkTypeController.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLinkTypeController.java @@ -279,4 +279,28 @@ throw new VciBaseException(VciBaseUtil.getExceptionMessage(e),new String[0],e); } } + + + /** + * 鑾峰彇璁剧疆鎺掑簭瀛楁鐨勬帓搴忓瓧娈� + * @param linkType 閾炬帴绫诲瀷鐨勭紪鍙� + * @param btmType 涓氬姟绫诲瀷鐨勭紪鍙� + * @param direction 姝�/鍙嶅悜 + * @return 灞炴�х殑淇℃伅 + */ + @GetMapping("/getAllOrderbyAttributeByLink") + public BaseResult<List<String>> getAllOrderbyAttributeByLink(String linkType, String btmType, String direction){ + + try { + List<String> osLinkTypeAttributes = linkTypeService.getAllOrderbyAttributeByLink(linkType, btmType, direction); + return BaseResult.dataList(osLinkTypeAttributes); + } catch (PLException e) { + BaseResult objectBaseResult = new BaseResult<>(); + objectBaseResult.setCode(Integer.parseInt(e.code)); + objectBaseResult.setMsg(Arrays.toString(e.messages)); + return objectBaseResult; + } catch (ParseException e) { + throw new RuntimeException(e); + } + } } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebPortalVIController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebPortalVIController.java index e9d431e..3d37d4c 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebPortalVIController.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebPortalVIController.java @@ -149,12 +149,12 @@ /** * 瀵煎嚭鏁版嵁搴撶殑琛ㄤ俊鎭埌excel * @param response 鍝嶅簲瀵硅薄 - * @param btmTypeIds 涓氬姟绫诲瀷鐨勭紪鍙凤紝鐢ㄩ�楀彿鍒嗗壊 + * @param ids 涓氬姟绫诲瀷鐨勭紪鍙凤紝鐢ㄩ�楀彿鍒嗗壊 */ @PostMapping("/exportExcel") @VciBusinessLog(operateName = "瀵煎嚭琛ㄥ崟/琛ㄦ牸鍒癳xcel涓�") - public void exportExcel(String btmTypeIds,HttpServletResponse response){ - String excelFileName = portalVIServiceI.exportToExcel(VciBaseUtil.str2List(btmTypeIds)); + public void exportExcel(String ids,HttpServletResponse response){ + String excelFileName = portalVIServiceI.exportToExcel(VciBaseUtil.str2List(ids)); try { ControllerUtil.writeFileToResponse(response,excelFileName); } catch (IOException e) { diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsActionServiceI.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsActionServiceI.java index 07d7105..95e28e9 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsActionServiceI.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsActionServiceI.java @@ -1,10 +1,7 @@ package com.vci.web.service; import com.vci.corba.common.PLException; -import com.vci.dto.PLActionClsDTO; -import com.vci.dto.PLActionDTO; -import com.vci.dto.PLActionExpDTO; -import com.vci.dto.PLActionQueryDTO; +import com.vci.dto.*; import com.vci.starter.web.pagemodel.BaseResult; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.multipart.MultipartFile; @@ -78,4 +75,22 @@ * @param plActionExpDTO 瀵煎嚭灞炴�ц缃璞� */ void exportAction(PLActionExpDTO plActionExpDTO, HttpServletResponse response) throws PLException, IOException; + /** + * 淇濆瓨Action鍙傛暟鏁版嵁 + * dto action浼犺緭瀵硅薄 + * @return 淇濆瓨缁撴灉 + */ + BaseResult savePLActionParam(PLActionParamDTO dto) throws PLException; + /** + * 淇敼Action鍙傛暟鏁版嵁 + * dto action浼犺緭瀵硅薄 + * @return 淇濆瓨缁撴灉 + */ + BaseResult updatePLActionParam(PLActionParamDTO dto) throws PLException; + /** + * 鍒犻櫎Action鍙傛暟鏁版嵁 + * oid 鍙傛暟涓婚敭 + * @return 淇濆瓨缁撴灉 + */ + BaseResult deletePLActionParam(String oid) throws PLException; } 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 f2c91dc..96ffd58 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 @@ -178,4 +178,12 @@ */ boolean isDefaultAttr(String attr); + /** + * 鏍规嵁涓氬姟绫诲瀷/閾炬帴绫诲瀷鑾峰彇灞炴�т俊鎭� + * @param btName 涓氬姟绫诲瀷/閾炬帴绫诲瀷 + * @param typeFlag 0:涓氬姟绫诲瀷,1:閾炬帴绫诲瀷 + * @return + */ + List<OsAttributeVO> getOsAttributeVOSByBtName(String btName,int typeFlag)throws Exception; + } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsLinkTypeServiceI.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsLinkTypeServiceI.java index 63ee265..adf9e4b 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsLinkTypeServiceI.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsLinkTypeServiceI.java @@ -173,4 +173,13 @@ * @return 灞炴�х殑淇℃伅 */ List<OsLinkTypeAttributeVO> getAllAttributeByLink(String name) throws PLException, ParseException; + + /** + * 鑾峰彇璁剧疆鎺掑簭瀛楁鐨勬帓搴忓瓧娈� + * @param linkType 閾炬帴绫诲瀷鐨勭紪鍙� + * @param btmType 涓氬姟绫诲瀷鐨勭紪鍙� + * @param direction 姝�/鍙嶅悜 + * @return 灞炴�х殑淇℃伅 + */ + List<String> getAllOrderbyAttributeByLink(String linkType, String btmType, String direction) throws PLException, ParseException; } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsActionServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsActionServiceImpl.java index 8d8e922..fd3d7b9 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsActionServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsActionServiceImpl.java @@ -6,11 +6,7 @@ import com.vci.corba.portal.data.PLAction; import com.vci.corba.portal.data.PLActionCls; import com.vci.corba.portal.data.PLActionParam; -import com.vci.dto.PLActionClsDTO; -import com.vci.dto.PLActionDTO; -import com.vci.dto.PLActionExpDTO; -import com.vci.dto.PLActionQueryDTO; -import com.vci.pagemodel.OsAttributeVO; +import com.vci.dto.*; import com.vci.starter.poi.bo.WriteExcelData; import com.vci.starter.poi.bo.WriteExcelOption; import com.vci.starter.poi.util.ExcelUtil; @@ -503,6 +499,72 @@ ControllerUtil.writeFileToResponse(response,excelPath); FileUtil.del(defaultTempFolder + File.separator); } + /** + * 淇濆瓨Action鍙傛暟鏁版嵁 + * dto action浼犺緭瀵硅薄 + * @return 淇濆瓨缁撴灉 + */ + @Override + public BaseResult savePLActionParam(PLActionParamDTO dto) throws PLException { + if(dto.getName() == null || dto.getName().equals("")) { + throw new PLException("500",new String[]{"鍙傛暟鍚嶇О涓嶈兘涓虹┖"}); + } + PLActionParam param = new PLActionParam(); + param.oid = ""; + param.name = dto.getName(); + param.defaultValue = dto.getDefaultValue(); + param.description = dto.getDescription(); + param.action = dto.getAction(); + String message = platformClientUtil.getUIService().createPLActionParam(param); + + if(message.startsWith("0")) { + if(message.equals("01")) { + throw new PLException("500",new String[]{"鍙傛暟鍚嶅凡缁忓瓨鍦紒"}); + } else { + throw new PLException("500",new String[]{"娣诲姞鎸夐挳鍙傛暟鏃跺彂鐢熷紓甯革細" + message.substring(1)}); + } + } + return BaseResult.success(); + } + + @Override + public BaseResult updatePLActionParam(PLActionParamDTO dto) throws PLException { + if(dto.getName() == null || dto.getName().equals("")) { + throw new PLException("500",new String[]{"鍙傛暟鍚嶇О涓嶈兘涓虹┖"}); + } + PLActionParam param = new PLActionParam(); + param.oid = dto.getOid(); + param.name = dto.getName(); + param.defaultValue = dto.getDefaultValue(); + param.description = dto.getDescription(); + param.action = dto.getAction(); + String message = platformClientUtil.getUIService().editPLActionParam(param); + + if(message.startsWith("0")) { + if(message.equals("01")) { + throw new PLException("500",new String[]{"鍙傛暟鍚嶅凡缁忓瓨鍦紒"}); + } else { + throw new PLException("500",new String[]{"娣诲姞鎸夐挳鍙傛暟鏃跺彂鐢熷紓甯革細" + message.substring(1)}); + } + } + return BaseResult.success(); + } + /** + * 鍒犻櫎Action鍙傛暟鏁版嵁 + * oid 鍙傛暟涓婚敭 + * @return 淇濆瓨缁撴灉 + */ + @Override + public BaseResult deletePLActionParam(String oid) throws PLException { + if(StringUtils.isBlank(oid)){ + throw new PLException("500", new String[]{"鍙傛暟涓婚敭涓嶈兘涓虹┖"}); + } + String message = platformClientUtil.getUIService().deletePLActionParam(oid); + if (message.startsWith("0")) { + throw new PLException("500", new String[]{"鍒犻櫎鎸夐挳鍙傛暟鏃跺彂鐢熷紓甯革細" + message.substring(1)}); + } + return BaseResult.success(); + } public boolean isValidPageForamt(PLActionExpDTO plActionExpDTO) throws PLException { 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 302d878..c8facba 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 @@ -1136,6 +1136,31 @@ } /** + * 鏍规嵁涓氬姟绫诲瀷鑾峰彇灞炴�т俊鎭� + * @param btName 涓氬姟绫诲瀷/閾炬帴绫诲瀷 + * @param typeFlag 0:涓氬姟绫诲瀷,1:閾炬帴绫诲瀷 + * @return + */ + @Override + public List<OsAttributeVO> getOsAttributeVOSByBtName(String btName, int typeFlag) throws Exception{ + VciBaseUtil.alertNotNull(btName,"鍙傛暟涓嶅厑璁镐负绌�",typeFlag,"鍙傛暟涓嶅厑璁镐负绌�"); + List<OsAttributeVO> attributeVOS=new ArrayList<>(); + try { + AttributeDef[] attributeDefs=new AttributeDef[]{}; + if(typeFlag==0){ + attributeDefs= platformClientUtil.getBtmService().getAttributeDefs(btName); + }else{ + attributeDefs=platformClientUtil.getLinkTypeService().getAttributes(btName); + } + attributeVOS=attributeDO2VOs(Arrays.asList(attributeDefs)); + }catch (PLException e){ + throw new Exception("鏍规嵁涓氬姟绫诲瀷鑾峰彇灞炴�у紓甯�"+e.getMessage()); + } + + return attributeVOS; + } + + /** * 鏄惁涓哄弬鐓у睘鎬� * @param other 閰嶇疆鐨勫叾浠� * @return true 鏄弬鐓� diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java index f69df86..4bd9c0c 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.util.ZipUtil; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import com.vci.common.qt.object.QTConstants; import com.vci.constant.FrameWorkLangCodeConstant; import com.vci.corba.common.PLException; import com.vci.corba.omd.atm.AttributeDef; @@ -752,6 +753,31 @@ } return links; } + /** + * 鑾峰彇璁剧疆鎺掑簭瀛楁鐨勬帓搴忓瓧娈� + * @param linkType 閾炬帴绫诲瀷鐨勭紪鍙� + * @param btmType 涓氬姟绫诲瀷鐨勭紪鍙� + * @param direction 姝�/鍙嶅悜 + * @return 灞炴�х殑淇℃伅 + */ + @Override + public List<String> getAllOrderbyAttributeByLink(String linkType, String btmType, String direction) throws PLException, ParseException { + List<String> abNames = new ArrayList<>(Arrays.asList("OID", "Creator", "CreateTime", "LastModifier", "LASTMODIFYTIME", "F_OID", + "F_REVISIONOID", "F_NAMEOID", "F_BtwName", "T_OID", "T_REVISIONOID", "T_NAMEOID", "T_BtwName", "TS" )); + AttributeDef[] attributes = platformClientUtil.getLinkTypeService().getAttributes(linkType); + for (AttributeDef attribute : attributes) { + abNames.add(String.valueOf(attribute.name)); + } + String wrapper = "T_OID."; + if(direction.equals(QTConstants.DIRECTION_OPPOSITE)){ + wrapper = "F_OID."; + } + List<OsBtmTypeAttributeVO> bizTypeQTDs = btmService.getBizTypeQTDs(btmType); + for (OsBtmTypeAttributeVO bizTypeQTD : bizTypeQTDs) { + abNames.add(wrapper + bizTypeQTD.getId()); + } + return abNames; + } /** * 淇閾炬帴绫诲瀷鐨剎ml鏂囦欢 diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsPortalVIServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsPortalVIServiceImpl.java index 486c5bc..b8a46a6 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsPortalVIServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsPortalVIServiceImpl.java @@ -1,26 +1,37 @@ package com.vci.web.service.impl; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.ZipUtil; import com.vci.bo.ItemSeniorQueryBO; import com.vci.common.utility.ObjectUtility; import com.vci.corba.common.PLException; +import com.vci.corba.omd.qtm.QTD; +import com.vci.corba.omd.qtm.QTInfo; import com.vci.corba.portal.PortalService.GetPagePortalVIArrayByPageInfoResult; import com.vci.corba.portal.data.PortalVI; import com.vci.dto.*; import com.vci.model.*; import com.vci.pagemodel.*; import com.vci.starter.poi.bo.WriteExcelData; -import com.vci.starter.web.enumpck.VciFieldTypeEnum; +import com.vci.starter.poi.bo.WriteExcelOption; +import com.vci.starter.poi.util.ExcelUtil; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.pagemodel.BaseQueryObject; import com.vci.starter.web.pagemodel.BaseResult; import com.vci.starter.web.pagemodel.DataGrid; +import com.vci.starter.web.util.LocalFileUtil; import com.vci.starter.web.util.VciBaseUtil; +import com.vci.starter.word.bo.WordMergeStartTableDataBO; +import com.vci.starter.word.util.WordUtil; import com.vci.web.enumpck.ItemTypeEnum; import com.vci.web.enumpck.PortalVIType; import com.vci.web.enumpck.PortalVITypeFlag; +import com.vci.web.service.OsAttributeServiceI; import com.vci.web.service.OsPortalVIServiceI; +import com.vci.web.service.OsQuereyTemplateServiceI; import com.vci.web.util.PlatformClientUtil; import com.vci.web.util.UITools; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,8 +40,9 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import java.io.*; import java.util.*; -import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; import java.util.stream.Collectors; @@ -51,13 +63,22 @@ @Autowired(required = false) @Lazy private OsPortalVIServiceI self; - + /** + * 鍔犺浇鑷韩 + */ + @Autowired(required = false) + private OsAttributeServiceI osAttributeService; /** * 骞冲彴鐨勮皟鐢ㄥ伐鍏风被 */ @Autowired private PlatformClientUtil platformClientUtil; + /** + * 鏌ヨ妯℃澘鏈嶅姟 + */ + @Autowired + private OsQuereyTemplateServiceI quereyTemplateServiceI; @Override public void clearCache() { @@ -134,7 +155,7 @@ */ @Override public PortalVIVO getPortalVIById(String id,String viType) throws PLException { - VciBaseUtil.alertNotNull(id,"涓婚敭涓虹┖锛�"); + VciBaseUtil.alertNotNull(id,"涓婚敭"); String lableName=PortalVIType.Form.getLabel(); if(PortalVIType.Table.getName()==viType){ lableName=PortalVIType.Table.getLabel(); @@ -159,7 +180,8 @@ @Override public boolean delete(DeletePortalVIDTOList portalVIDTOList) throws PLException { if(portalVIDTOList==null||CollectionUtils.isEmpty(portalVIDTOList.getPortalVIDTOList())){ - VciBaseUtil.alertNotNull("璇烽�夋嫨瑕佸垹闄ょ殑瀵硅薄!"); + // VciBaseUtil.alertNotNull("鍒犻櫎鐨勫璞�"); + throw new PLException("1001",new String[]{"璇烽�夋嫨瑕佸垹闄ょ殑瀵硅薄锛亇"}); } try { for(PortalVIDTO portalVIDTO:portalVIDTOList.getPortalVIDTOList()) { @@ -235,6 +257,7 @@ short typeFlag = clonedestObject.getTypeFlag(); if (viName != null) { VciBaseUtil.alertNotNull(viName, "鍏嬮殕鍚嶇О涓嶅厑璁镐负绌�"); + //throw new PLException("1001",new String[]{"璇烽�夋嫨瑕佸垹闄ょ殑瀵硅薄锛亇"}); if( PortalVIMap.containsKey(viName)){ throw new VciBaseException("鍏嬮殕鍚嶇О"+viName+"宸插瓨鍦紝璇锋牳瀵癸紒"); } @@ -260,77 +283,175 @@ @Override public String exportToExcel(Collection<String> idList) { - /*List<PortalVIVO> portalVIVOList= listByIds(idList); + String defaultTempFolder = LocalFileUtil.getDefaultTempFolder(); + String xfileName="export.xls"; List<WriteExcelData> rowDataList = new ArrayList<>(); - final int[] index = {0}; - if(!CollectionUtils.isEmpty(portalVIVOList)) { - portalVIVOList.stream().forEach(PortalVIVO -> { - //鍏堟槸鍚嶇О - int rowIndex = index[0]; - WriteExcelData idED = new WriteExcelData(rowIndex, 0, btmId); - idED.setMerged(true); - if (attributeVOS.size() > 0) { - idED.setRowTo(rowIndex + attributeVOS.size() - 1 + 3); - } - rowDataList.add(idED); + List<WriteExcelData> qtRowDataList = new ArrayList<>(); + //VciBaseUtil.alertNotNull(idList); + List<PortalVIDTO> portalVIDTOList= listByIds(idList); + final int index=0; - WriteExcelData nameED = new WriteExcelData(rowIndex, 1, btmTypeVO.getName()); - nameED.setMerged(true); - if (attributeVOS.size() > 0) { - nameED.setRowTo(rowIndex + attributeVOS.size() - 1 + 3); - } - rowDataList.add(nameED); + String excelFileName = defaultTempFolder + File.separator + xfileName; + File excelFile = new File(excelFileName); + try { + excelFile.createNewFile(); + }catch (Throwable e){ + String msg = "鍦ㄥ垱寤篹xcel鏂囦欢鐨勬椂鍊欏嚭鐜颁簡閿欒"; + if(logger.isErrorEnabled()){ + logger.error(msg,e); + } + throw new VciBaseException(msg+",{0}",new String[]{excelFileName},e); + } - rowDataList.add(new WriteExcelData(rowIndex, 2, "id")); - rowDataList.add(new WriteExcelData(rowIndex, 3, "缂栧彿")); - rowDataList.add(new WriteExcelData(rowIndex, 4, "瀛楃涓�")); - rowDataList.add(new WriteExcelData(rowIndex, 5, "鏄�")); - rowDataList.add(new WriteExcelData(rowIndex, 6, "50")); - rowIndex++; - rowDataList.add(new WriteExcelData(rowIndex, 2, "name")); - rowDataList.add(new WriteExcelData(rowIndex, 3, "鍚嶇О")); - rowDataList.add(new WriteExcelData(rowIndex, 4, "瀛楃涓�")); - rowDataList.add(new WriteExcelData(rowIndex, 5, "鏄�")); - rowDataList.add(new WriteExcelData(rowIndex, 6, "50")); - rowIndex++; - rowDataList.add(new WriteExcelData(rowIndex, 2, "description")); - rowDataList.add(new WriteExcelData(rowIndex, 3, "鎻忚堪")); - rowDataList.add(new WriteExcelData(rowIndex, 4, "瀛楃涓�")); - rowDataList.add(new WriteExcelData(rowIndex, 5, "鏄�")); - rowDataList.add(new WriteExcelData(rowIndex, 6, "150")); - //澶勭悊灞炴�� - rowIndex++; - for (int i = 0; i < attributeVOS.size(); i++) { - OsBtmTypeAttributeVO attributeVO = attributeVOS.get(i); - //鍏堟槸灞炴�х殑鑻辨枃鍚嶇О - rowDataList.add(new WriteExcelData(rowIndex, 2, attributeVO.getId())); - //鐒跺悗灞炴�х殑涓枃鍚嶇О - rowDataList.add(new WriteExcelData(rowIndex, 3, attributeVO.getName())); - //灞炴�х殑绫诲瀷 - rowDataList.add(new WriteExcelData(rowIndex, 4, VciFieldTypeEnum.getTextByValue(attributeVO.getAttributeDataType()))); - //鏄惁鍙互涓虹┖ - rowDataList.add(new WriteExcelData(rowIndex, 5, attributeVO.isNullableFlag() ? "鏄�" : "鍚�")); - //灞炴�ч暱搴� - String length = attributeVO.getAttributeLength()==null?"":attributeVO.getAttributeLength() + "" ; - if (attributeVO.getPrecisionLength() != null) { - length = length + "(" + attributeVO.getPrecisionLength() + "," + attributeVO.getScaleLength() == null ? "2" : (attributeVO.getScaleLength() + "") + ")" ; + + rowDataList.add(new WriteExcelData(index, 0, "涓氬姟绫诲瀷鍚嶇О")); + rowDataList.add(new WriteExcelData(index, 1, "鍚嶇О")); + rowDataList.add(new WriteExcelData(index, 2, "涓氬姟绫诲瀷")); + rowDataList.add(new WriteExcelData(index, 3, "琛ㄥ崟绫诲瀷")); + rowDataList.add(new WriteExcelData(index, 4, "閰嶇疆鏂囨湰")); + rowDataList.add(new WriteExcelData(index, 5, "灞炴��")); + rowDataList.add(new WriteExcelData(index, 6, "鏌ヨ妯℃澘鍚嶇О")); + rowDataList.add(new WriteExcelData(index, 7, "鏌ヨ妯℃澘閰嶇疆鏂囨湰")); + rowDataList.add(new WriteExcelData(index, 8, "鏌ヨ妯℃澘涓氬姟绫诲瀷")); + + + qtRowDataList.add(new WriteExcelData(index, 0, "涓氬姟绫诲瀷鍚嶇О")); + qtRowDataList.add(new WriteExcelData(index, 1, "閾炬帴绫诲瀷鍚嶇О")); + qtRowDataList.add(new WriteExcelData(index, 2, "鏌ヨ妯℃澘瀹氫箟鍚嶇О")); + qtRowDataList.add(new WriteExcelData(index, 3, "灞炴��")); + + if(!CollectionUtils.isEmpty(portalVIDTOList)){ + final int[] rowIndex = {1}; + boolean isLink=PortalVITypeFlag.LinkType.getIntVal()== portalVIDTOList.get(0).getTypeFlag()?true:false; + try { + BaseResult baseResult= quereyTemplateServiceI.queryTemplateList( portalVIDTOList.get(0).getTypeName(),isLink); + if(baseResult.isSuccess()){ + final int[] rowIndex1 = {1}; + Collection< QTD> qtdList= baseResult.getData(); + if(!CollectionUtils.isEmpty(qtdList)){ + qtdList.stream().forEach(qtd -> { + qtRowDataList.add(new WriteExcelData(rowIndex1[0], 0, qtd.btmName)); + qtRowDataList.add(new WriteExcelData(rowIndex1[0], 1, qtd.linkTypeName)); + qtRowDataList.add(new WriteExcelData(rowIndex1[0], 2, qtd.name)); + qtRowDataList.add(new WriteExcelData(rowIndex1[0], 3, VciBaseUtil.array2String(qtd.abNames))); + rowIndex1[0]++; + }); + } - rowDataList.add(new WriteExcelData(rowIndex, 6, length)); - //澶囨敞 - rowDataList.add(new WriteExcelData(rowIndex, 7, attributeVO.getDescription() == null ? "" : attributeVO.getDescription())); - rowIndex++; + } + } catch (PLException e) { + e.printStackTrace(); + } + portalVIDTOList.stream().forEach(portalVIDTO -> { + //鍏堟槸鍚嶇О + rowDataList.add(new WriteExcelData(rowIndex[0], 0, portalVIDTO.getTypeName()));//涓氬姟绫诲瀷鍚嶇О + rowDataList.add(new WriteExcelData(rowIndex[0], 1, portalVIDTO.getViName()));//鍚嶇О + rowDataList.add(new WriteExcelData(rowIndex[0], 2, PortalVITypeFlag.getByIntVal(portalVIDTO.getTypeFlag()).getLabel()));//涓氬姟绫诲瀷 + rowDataList.add(new WriteExcelData(rowIndex[0], 3,PortalVIType.getByIntVal(portalVIDTO.getViType()).getLabel()));//琛ㄥ崟绫诲瀷 + try { + String prmText=UITools.getPRMText(prmDOO2VIS(portalVIDTO.getPrm(),portalVIDTO.getViType())); + String prmTextFileName= ObjectUtility.getNewObjectID36() + ".txt"; + String prmTextFileNameAllName = xfileName + "." + prmTextFileName; + writeDataToFile(defaultTempFolder,prmTextFileNameAllName,prmText); + rowDataList.add(new WriteExcelData(rowIndex[0], 4,prmTextFileName));//閰嶇疆鏂囨湰 + + } catch (Throwable e) { + e.printStackTrace(); + } + String attributeStr=""; + try { + List<OsAttributeVO> osAttributeVOList=osAttributeService.getOsAttributeVOSByBtName(portalVIDTO.getTypeName(),portalVIDTO.getTypeFlag()); + if(!CollectionUtils.isEmpty(osAttributeVOList)){ + List<String> filedList= osAttributeVOList.stream().map(OsAttributeVO::getId).collect(Collectors.toList()); + attributeStr=VciBaseUtil.array2String(filedList.toArray(new String[]{})); + } + } catch (Exception e) { + e.printStackTrace(); + } + rowDataList.add(new WriteExcelData(rowIndex[0], 5, attributeStr));//灞炴�� + String qtName=""; + try { + QTInfo qt = platformClientUtil.getQTDService().getQT(portalVIDTO.getPrm().getFormQtName()); + qtName=qt.qtName; + rowDataList.add(new WriteExcelData(rowIndex[0], 6,qtName));//鏌ヨ妯℃澘鍚嶇О + String qtFileName = ObjectUtility.getNewObjectID36() + ".txt"; + String qtFileNameAllName = xfileName + "." + qtFileName; + writeDataToFile(defaultTempFolder,qtFileNameAllName,qt.qtText); + rowDataList.add(new WriteExcelData(rowIndex[0], 7, qtFileName));//鏌ヨ妯℃澘閰嶇疆鏂囨湰 + rowDataList.add(new WriteExcelData(rowIndex[0], 8, qt.btmName));//鏌ヨ妯℃澘涓氬姟绫诲瀷 + } catch (PLException e) { + e.printStackTrace(); } - index[0] = rowIndex; + rowIndex[0]++; }); } -*/ - return null; + + /* String excelTemplateFileName = "/excelTemplate/dataBaseExport.xls"; + if(this.getClass().getResource(excelTemplateFileName) == null){ + throw new VciBaseException("璇疯仈绯荤鐞嗗憳锛岀郴缁熶腑缂哄皯{0}杩欎釜妯℃澘鏂囦欢",new String[]{excelTemplateFileName}); + } + try { + ExcelUtil.copyFileFromJar(excelTemplateFileName,excelFile); + //杩欎釜鏂规硶浼氬叧闂枃浠舵祦 + }catch (Throwable e){ + String msg = "浠庢ā鏉挎枃浠舵嫹璐濆埌鐩爣鏂囦欢鍑虹幇浜嗛敊璇�"; + if(logger.isErrorEnabled()){ + logger.error(msg,e); + } + throw new VciBaseException(msg+",{0}",new String[]{excelFileName},e); + }*/ + try{ + WriteExcelOption excelOption = new WriteExcelOption(); + excelOption.addSheetDataList("portalvi",rowDataList); + excelOption.addSheetDataList("QTD",qtRowDataList); + ExcelUtil.writeDataToFile(excelFile,excelOption); + }catch (Throwable e){ + String msg = "鎶婃暟鎹啓鍏ュ埌excel鏂囦欢涓嚭鐜伴敊璇�"; + if(logger.isErrorEnabled()){ + logger.error(msg,e); + } + throw new VciBaseException(msg+",{0}",new String[]{excelFileName},e); + } + File zip = ZipUtil.zip(defaultTempFolder); + FileUtil.del(defaultTempFolder + File.separator); + //鏈�鍚庤繑鍥瀍xcel鏂囦欢鍚嶇О + return zip.getAbsoluteFile().getAbsolutePath(); } - public List<PortalVIVO> listByIds(Collection idList){ - List<PortalVIVO> portalVIVOList=new ArrayList<>(); + /** + * 鎷疯礉鏁版嵁鍒皐ord妯℃澘涓� + * @param fileName 瑕佸啓鍏ョ殑鏁版嵁 + * @return word 鏂囦欢璺緞 + */ + public String writeDataToFile(String defaultTempFolder,String fileName,String str){ + String tempFolder = LocalFileUtil.getDefaultTempFolder(); + //鎷疯礉鏂囦欢 + String filePath = tempFolder + File.separator + fileName; + File file = new File(filePath); + FileOutputStream out = null; + try { + file.createNewFile(); + out= new FileOutputStream(file); + IOUtils.write(str,out); + }catch (Throwable e){ + IOUtils.closeQuietly(out); + String msg = "鍦ㄥ垱寤烘枃浠剁殑鏃跺�欏嚭鐜颁簡閿欒"; + if(logger.isErrorEnabled()){ + logger.error(msg,e); + } + throw new VciBaseException(msg+",{0}",new String[]{filePath},e); + }finally { + IOUtils.closeQuietly(out); + //绉诲姩灞炴�у埌閾炬帴绫诲瀷鏂囦欢澶归噷闈㈠幓 + FileUtil.move(file, new File(defaultTempFolder),true); + FileUtil.del(tempFolder); + } + return filePath; + } + public List<PortalVIDTO> listByIds(Collection idList){ + List<PortalVIDTO> portalVIVOList=new ArrayList<>(); if(CollectionUtils.isEmpty(idList)){ throw new VciBaseException("璇烽�夋嫨闇�瑕佸鍑虹殑鏁版嵁"); } @@ -343,7 +464,7 @@ e.printStackTrace(); } }); - portalVIVOList= portalVIDOO2VOS(portalVIList); + portalVIVOList= portalVIO2DTOS(portalVIList); return portalVIVOList; } private BaseResult savePortalVIDTO(PortalVIDTO portalVIDTO,boolean isEdit) { @@ -870,8 +991,12 @@ List<String> itemSelectoutFieldList= allKeyList.stream().filter(s ->!itemOutFieldList.stream().map(s1 -> s1).collect(Collectors.toList()).contains(s) ).collect(Collectors.toList()); prmItemDTO.setItemSelectoutFieldList(itemSelectoutFieldList);//寰呴�夋嫨鐨勫睘鎬у瓧娈� prmItemDTO.setItemOutFieldList(itemOutFieldList);//闇�瑕佷娇鐢ㄧ殑闆嗗悎 - List<String> itemSearchFieldList= itemOutFieldList.stream().filter(s ->!itemKeyFieldList.stream().map(s1 -> s1).collect(Collectors.toList()).contains(s) ).collect(Collectors.toList()); - prmItemDTO.setItemSearchFieldList(itemSearchFieldList);//寰呮悳绱㈠瓧娈� + List<String> itemSearchFieldList=new ArrayList<>(); + if(!CollectionUtils.isEmpty(itemKeyFieldList)){ + itemSearchFieldList= itemOutFieldList.stream().filter(s ->!itemKeyFieldList.contains(s)).collect(Collectors.toList()); + }else{ + itemSearchFieldList=itemOutFieldList; + } prmItemDTO.setItemSearchFieldList(itemSearchFieldList);//寰呮悳绱㈠瓧娈� prmItemDTO.setItemKeyFieldList(itemKeyFieldList);//鎼滅储瀛楁 } /** @@ -915,11 +1040,14 @@ private List<KeyValue> initItemFieldWidthList(String itemOutFields,String itemFieldWidth){ List<KeyValue> keyValueList=new ArrayList<>(); List<String>itemOutFieldList= VciBaseUtil.str2List(itemOutFields); - List<String>itemFieldWidthList= VciBaseUtil.str2List(itemFieldWidth,":"); + List<String>itemFieldWidthList= VciBaseUtil.str2List(itemFieldWidth,","); if(itemOutFieldList.size()>0) { for (int i = 0; i < itemOutFieldList.size(); i++) { KeyValue keyValue = new KeyValue(); - String with = itemFieldWidthList.get(i); + String with="250"; + if(i<itemFieldWidthList.size()) { + with = itemFieldWidthList.get(i); + } keyValue.setKey(itemOutFieldList.get(i)); keyValue.setValue(StringUtils.isBlank(with) ? "250" : with); keyValueList.add(keyValue); -- Gitblit v1.9.3