From d0ae279ff3b83358d1c07f4481a041c4ad335026 Mon Sep 17 00:00:00 2001 From: dangsn <dangsn@chicecm.com> Date: 星期二, 03 十二月 2024 11:57:38 +0800 Subject: [PATCH] 提取业务系统使用的功能,独立出一个单独的模块 --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebBtmTypeController.java | 372 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 351 insertions(+), 21 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebBtmTypeController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebBtmTypeController.java index ff9459a..6ae0bdc 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebBtmTypeController.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebBtmTypeController.java @@ -1,7 +1,11 @@ package com.vci.web.controller; import com.vci.corba.common.PLException; -import com.vci.starter.web.annotation.controller.VciUnCheckRight; +import com.vci.dto.OsBtmTypeDTO; +import com.vci.model.IndexObject; +import com.vci.pagemodel.OsBtmTypeAttributeVO; +import com.vci.pagemodel.OsBtmTypeVO; +import com.vci.pagemodel.OsERVO; import com.vci.starter.web.annotation.log.VciBusinessLog; import com.vci.starter.web.enumpck.BooleanEnum; import com.vci.starter.web.exception.VciBaseException; @@ -9,15 +13,13 @@ import com.vci.starter.web.pagemodel.BaseResult; import com.vci.starter.web.pagemodel.DataGrid; import com.vci.starter.web.pagemodel.Tree; -import com.vci.starter.web.util.BeanUtil; +import com.vci.starter.web.util.BeanUtilForVCI; import com.vci.starter.web.util.ControllerUtil; import com.vci.starter.web.util.LangBaseUtil; import com.vci.starter.web.util.VciBaseUtil; -import com.vci.pagemodel.OsBtmTypeAttributeVO; -import com.vci.pagemodel.OsBtmTypeVO; -import com.vci.pagemodel.OsERVO; import com.vci.web.service.OsAttributeServiceI; import com.vci.web.service.OsBtmServiceI; +import com.vci.web.service.OsLinkTypeServiceI; import com.vci.web.service.WebBtmIOServiceI; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -25,11 +27,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.FileNotFoundException; import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.text.ParseException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -57,6 +61,12 @@ */ @Autowired private OsBtmServiceI btmService; + + /** + * 杩炴帴绫诲瀷鐨勬湇鍔� + */ + @Autowired + private OsLinkTypeServiceI linkTypeService; /** * 涓氬姟绫诲瀷瀵煎叆瀵煎嚭鏈嶅姟 @@ -89,7 +99,6 @@ */ @GetMapping( "/getBizTypes") @VciBusinessLog(operateName = "涓氬姟绫诲瀷鍒楄〃(涓昏鐢ㄤ簬瀵硅瘽妗嗕娇鐢�)") - @VciUnCheckRight public BaseResult getBizTypes(String btmName){ try { return BaseResult.dataList(Arrays.asList(btmService.getBizTypes(btmName))); @@ -101,35 +110,326 @@ } } - /** * 鑾峰彇鎵�鏈変笟鍔$被鍨嬶紙鏍戝舰缁撴瀯锛� * @return 鏌ヨ缁撴灉 */ @GetMapping( "/getTreeBizTypes") @VciBusinessLog(operateName = "鑾峰彇鎵�鏈変笟鍔$被鍨嬶紙鏍戝舰缁撴瀯锛�") - @VciUnCheckRight public BaseResult<List<Tree>> getTreeBizTypes(){ try { - return btmService.getTreeBizTypes(); + return BaseResult.dataList(btmService.getTreeBizTypes()); }catch (Exception e) { e.printStackTrace(); - String exceptionMessage = "鑾峰彇涓氬姟绫诲瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + String exceptionMessage = "鏌ヨ涓氬姟绫诲瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); logger.error(exceptionMessage); return BaseResult.fail(exceptionMessage); } } /** - * 鑾峰彇涓氬姟绫诲瀷鍖呭惈鐨勫睘鎬� + * 鑾峰彇涓氬姟绫诲瀷浣跨敤鑼冨洿 + * @param btmName + * @return 鏌ヨ缁撴灉 + */ + @GetMapping( "/getUsedBtmLinkList") + @VciBusinessLog(operateName = "鑾峰彇涓氬姟绫诲瀷浣跨敤鑼冨洿") + public BaseResult<List<String>> getUsedBtmLinkList(String btmName){ + try { + return BaseResult.dataList(linkTypeService.getUsedBtmLinkList(btmName)); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鑾峰彇涓氬姟绫诲瀷浣跨敤鑼冨洿鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鍒涘缓涓氬姟绫诲瀷 + * btmTypeDTO 閾炬帴绫诲瀷鐨勪繚瀛樺璞� + * @return 淇濆瓨缁撴灉 + */ + @PostMapping("/addBtmType") + public BaseResult addBtmType(@RequestBody OsBtmTypeDTO btmTypeDTO){ + try { + return btmService.addBtmType(btmTypeDTO) ? BaseResult.success("涓氬姟绫诲瀷鍒涘缓鎴愬姛锛�"):BaseResult.fail("涓氬姟绫诲瀷鍒涘缓澶辫触锛�"); + } catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鍒涘缓涓氬姟绫诲瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鎵归噺鍒涘缓涓氬姟绫诲瀷 + * btmTypeDTO 閾炬帴绫诲瀷鐨勪繚瀛樺璞� + * @return 淇濆瓨缁撴灉 + */ + /*@PostMapping("/addBtmTypes") + public BaseResult addBtmTypes(@RequestBody List<BizType> bizTypes){ + try { + return btmService.addBtmTypes(bizTypes) ? BaseResult.success("涓氬姟绫诲瀷鎵归噺鍒涘缓鎴愬姛锛�"):BaseResult.fail("涓氬姟绫诲瀷鎵归噺鍒涘缓澶辫触锛�"); + } catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鎵归噺鍒涘缓涓氬姟绫诲瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + }*/ + + /** + * 淇敼涓氬姟绫诲瀷 + * btmTypeDTO 閾炬帴绫诲瀷淇敼鐨勫璞� + * @return 淇濆瓨缁撴灉 + */ + @PutMapping("/updateBtmType") + public BaseResult updateBtmType(@RequestBody OsBtmTypeDTO btmTypeDTO){ + try { + return btmService.updateBtmType(btmTypeDTO) ? BaseResult.success("涓氬姟绫诲瀷淇敼鎴愬姛锛�"):BaseResult.fail("涓氬姟绫诲瀷淇敼澶辫触锛�"); + } catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "淇敼涓氬姟绫诲瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 涓氬姟绫诲瀷鍒犻櫎 + * btmTypeDTO 涓氬姟绫诲瀷瀵硅薄 + * @return 鍒犻櫎缁撴灉 + */ + @DeleteMapping("/deleteBtmType") + public BaseResult deleteLink(@RequestBody OsBtmTypeDTO btmTypeDTO){ + try { + return btmService.deleteBtmType(btmTypeDTO) ? BaseResult.success("鍒犻櫎涓氬姟绫诲瀷鎴愬姛锛�"):BaseResult.fail("鍒犻櫎涓氬姟绫诲瀷澶辫触锛�"); + } catch (PLException e) { + e.printStackTrace(); + String exceptionMessage = "鍒犻櫎涓氬姟绫诲瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 涓�鑷存�ф鏌� + * @return 妫�鏌ョ粨鏋� + */ + @GetMapping("/checkBtmConsistency") + public BaseResult checkBtmConsistency(){ + try { + return btmService.checkBtmConsistency(); + } catch (PLException e) { + e.printStackTrace(); + String exceptionMessage = "涓氬姟绫诲瀷涓�鑷存�ф鏌ユ椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 涓�鑷存�ф鏌ワ紝涓氬姟绫诲瀷淇 + * @return 鍒犻櫎缁撴灉 + */ + @PostMapping("/executeRepair") + public BaseResult executeRepair(@RequestBody String repairData){ + try { + return btmService.executeRepair(repairData); + } catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "涓氬姟绫诲瀷淇鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鍒涘缓瑙嗗浘 + * @return + */ + @PostMapping("/createView") + public BaseResult createView(){ + try { + return btmService.createView() ? BaseResult.success("鍒涘缓瑙嗗浘鎴愬姛!"):BaseResult.fail("鍒涘缓瑙嗗浘澶辫触!"); + } catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鍒涘缓瑙嗗浘鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鍒犻櫎鏁版嵁鐣岄潰鐨勬暟鎹煡璇� + * @return + */ + @GetMapping("/getObjectData") + public BaseResult getObjectData(){ + try { + return btmService.getObjectData(); + } catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鏁版嵁瀵硅薄鏌ヨ鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鍒犻櫎鏁版嵁 + * @param btmNames 涓氬姟绫诲瀷鍚� + * @param linkNames 閾炬帴绫诲瀷鍚� + * @return + * @throws PLException + */ + @DeleteMapping("/truncateTable") + public BaseResult truncateTable(String[] btmNames,String[] linkNames){ + try { + return BaseResult.dataList(btmService.truncateTable(btmNames,linkNames)); + } catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鍒犻櫎鏁版嵁鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鍒犻櫎鍏ㄩ儴绫诲瀷 + * @return + * @throws PLException + */ + @DeleteMapping("/deleteAllType") + public BaseResult deleteAllType(){ + try { + return BaseResult.dataList(btmService.deleteAllType()); + } catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鍒犻櫎鍏ㄩ儴绫诲瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鑾峰彇褰撳墠涓氬姟绫诲瀷涓嬬殑绱㈠紩 + * @return + * @throws PLException + */ + @GetMapping("/getIndexByCondition") + public BaseResult getIndexByCondition(BaseQueryObject baseQueryObject){ + try { + return BaseResult.dataList(btmService.getIndexByCondition(baseQueryObject.getConditionMap())); + } catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鏌ヨ褰撳墠涓氬姟绫诲瀷涓嬬殑绱㈠紩鏃舵椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鍒涘缓绱㈠紩 + * @param indexObjectList + * @return + */ + @PostMapping("/addIndex") + public BaseResult addIndex(@RequestBody List<IndexObject> indexObjectList){ + try { + return btmService.addIndex(indexObjectList) ? BaseResult.success("鍒涘缓绱㈠紩鎴愬姛!"):BaseResult.fail("鍒涘缓绱㈠紩澶辫触!"); + } catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鍒涘缓绱㈠紩鏃舵椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鍒犻櫎绱㈠紩 + * @param btmName + * @param indexName + * @return + */ + @DeleteMapping("/delIndex") + public BaseResult delIndex(String btmName,String indexName){ + try { + return btmService.delIndex(btmName,indexName) ? BaseResult.success("鍒犻櫎绱㈠紩鎴愬姛!"):BaseResult.fail("鍒犻櫎绱㈠紩澶辫触!"); + } catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鍒犻櫎绱㈠紩鏃舵椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 瀵煎嚭涓氬姟绫诲瀷 + * name 閾炬帴绫诲瀷鍚嶇О + * @return + */ + @GetMapping("/expData") + public void expData(String name,HttpServletResponse response) throws PLException, IOException { + btmService.expData(name, response); + } + + /** + * 瀵煎叆涓氬姟绫诲瀷 + * @param file 涓婁紶鐨勬枃浠� + * @return + */ + @PostMapping("/impData") + public BaseResult impData(MultipartFile file){try { + return btmService.impData(file); + }catch (Throwable e) { + throw new VciBaseException(VciBaseUtil.getExceptionMessage(e),new String[0],e); + } + } + + /** + * 鑾峰彇涓氬姟绫诲瀷鍖呭惈鐨勫睘鎬у叏閮ㄤ负灏忓啓 * @param btmId 涓氬姟绫诲瀷鍚嶇О * @return 灞炴�х殑淇℃伅 */ @GetMapping(value = "/getAllAttributesByBtmId") @VciBusinessLog(operateName = "鏌ョ湅涓氬姟绫诲瀷鐨勫睘鎬�") public BaseResult<List<OsBtmTypeAttributeVO>> getAllAttributesByBtmId(String btmId){ - List<OsBtmTypeAttributeVO> osBtmTypeAttributeVOS = btmService.listAttributeByBtmIdHasDefault(btmId); + List<OsBtmTypeAttributeVO> osBtmTypeAttributeVOS = null; + try { + osBtmTypeAttributeVOS = btmService.listAttributeByBtmIdHasDefault(btmId); + } catch (PLException e) { + e.printStackTrace(); + String exceptionMessage = VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + throw new VciBaseException(exceptionMessage); + } return BaseResult.dataList(osBtmTypeAttributeVOS); + } + + /** + * 鑾峰彇涓氬姟鍏ㄩ儴灞炴�х被鍨� + * @param btmName 涓氬姟绫诲瀷鍚嶇О + * @return 灞炴�х殑淇℃伅 + */ + @GetMapping(value = "/getBizTypeQTDs") + @VciBusinessLog(operateName = "鏌ョ湅涓氬姟绫诲瀷鐨勫睘鎬�") + public BaseResult<List<OsBtmTypeAttributeVO>> getBizTypeQTDs(String btmName){ + try { + List<OsBtmTypeAttributeVO> osBtmTypeAttributeVOS = btmService.getBizTypeQTDs(btmName); + return BaseResult.dataList(osBtmTypeAttributeVOS); + } catch (PLException e) { + BaseResult objectBaseResult = new BaseResult<>(); + objectBaseResult.setCode(Integer.parseInt(e.code)); + objectBaseResult.setMsg(Arrays.toString(e.messages)); + return objectBaseResult; + } catch (ParseException e) { + BaseResult objectBaseResult = new BaseResult<>(); + objectBaseResult.setCode(500); + objectBaseResult.setMsg(e.getMessage()); + return objectBaseResult; + } } /** @@ -158,7 +458,15 @@ String hasDefaultAttr = baseQueryObject.getConditionMap().getOrDefault("hasDefaultAttr","false"); String attrId = baseQueryObject.getConditionMap().containsKey("name")?baseQueryObject.getConditionMap().get("name").replace("*",""):""; String attrName = baseQueryObject.getConditionMap().containsKey("label") ? baseQueryObject.getConditionMap().get("label").replace("*","") : ""; - List<OsBtmTypeAttributeVO> boAttrs = btmService.listAttributeByBtmId(btmTypeId); + List<OsBtmTypeAttributeVO> boAttrs = null; + try { + boAttrs = btmService.listAttributeByBtmId(btmTypeId); + } catch (PLException e) { + e.printStackTrace(); + String exceptionMessage = VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + throw new VciBaseException(exceptionMessage); + } if(boAttrs == null){ boAttrs = new ArrayList<>(); } @@ -167,9 +475,9 @@ List<OsBtmTypeAttributeVO> finalBoAttrs = boAttrs; attributeService.getDefaultAttributeVOs().stream().forEach(attr->{ OsBtmTypeAttributeVO attributeVO = new OsBtmTypeAttributeVO(); - BeanUtil.convert(attr,attributeVO); + BeanUtilForVCI.convert(attr,attributeVO); attributeVO.setAttributeLength(attr.getAttrLength()); - attributeVO.setAttrDataType(attr.getAttributeDataType()); + attributeVO.setAttributeDataType(attr.getAttributeDataType()); attributeVO.setReferBtmTypeId(attr.getBtmTypeId()); attributeVO.setReferBtmTypeName(attr.getBtmTypeName()); finalBoAttrs.add(attributeVO); @@ -192,7 +500,6 @@ return dataGrid; } - /** * 浣跨敤涓婚敭鑾峰彇涓氬姟绫诲瀷鍖呭惈鐨勫睘鎬э紝涓嶅垎椤� * @param baseQueryObject 鏌ヨ瀵硅薄 @@ -207,7 +514,15 @@ String attrId = baseQueryObject.getConditionMap().containsKey("name")?baseQueryObject.getConditionMap().get("name").replace("*",""):""; String attrName = baseQueryObject.getConditionMap().containsKey("label") ? baseQueryObject.getConditionMap().get("label").replace("*","") : ""; OsBtmTypeVO btmTypeVO = btmService.selectByOid(btmTypeOid); - List<OsBtmTypeAttributeVO> boAttrs = btmService.listAttributeByBtmId(btmTypeVO.getId()); + List<OsBtmTypeAttributeVO> boAttrs = null; + try { + boAttrs = btmService.listAttributeByBtmId(btmTypeVO.getId()); + } catch (PLException e) { + e.printStackTrace(); + String exceptionMessage = VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + throw new VciBaseException(exceptionMessage); + } List<OsBtmTypeAttributeVO> attrList = boAttrs.stream().filter(s->{ boolean usedFlag = true; if(StringUtils.isNotBlank(attrId) && !s.getId().contains(attrId)){ @@ -224,7 +539,6 @@ return dataGrid; } - /** * 浣跨敤涓婚敭鑾峰彇涓氬姟绫诲瀷鐨勫璞� * @param oid 涓婚敭 @@ -238,6 +552,7 @@ } return BaseResult.success(btmTypeVO); } + /** * 瀵煎嚭涓氬姟绫诲瀷鐨勪俊鎭埌word涓� * @param btmTypeIds 涓氬姟绫诲瀷鐨勭紪鍙凤紝鐢ㄩ�楀彿鍒嗗壊 @@ -294,8 +609,15 @@ */ @GetMapping("/createERDiagram") public BaseResult createERDiagram(String id){ - OsERVO osERVO = btmService.createERDiagram(id); - return BaseResult.success(osERVO); + try { + OsERVO osERVO = btmService.createERDiagram(id); + return BaseResult.success(osERVO); + }catch (Exception e){ + e.printStackTrace(); + String msg = "鐢熸垚涓氬姟绫诲瀷浣跨敤鐨凟R鍥炬椂鍑虹幇閿欒锛屽師鍥狅細"+VciBaseUtil.getExceptionMessage(e); + logger.error(msg); + return BaseResult.fail(msg); + } } /** @@ -305,6 +627,14 @@ */ @GetMapping("/createERUsed") public BaseResult createERUsed(String id){ - return BaseResult.success(btmService.createERUsed(id)); + try { + return BaseResult.success(btmService.createERUsed(id)); + } catch (PLException e) { + e.printStackTrace(); + String msg = "鍙栦娇鐢ㄨ繖涓笟鍔$被鍨嬬殑E-R鍥炬椂鍑虹幇閿欒锛屽師鍥狅細"+VciBaseUtil.getExceptionMessage(e); + logger.error(msg); + return BaseResult.fail(msg); + } } + } -- Gitblit v1.9.3