From de42c7075ba5a474ba74d8833e9830dfa1312464 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期三, 28 八月 2024 15:20:17 +0800 Subject: [PATCH] 业务类型查询模板接口上传 --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebBtmTypeController.java | 402 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 391 insertions(+), 11 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 6801931..10c2d5c 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,5 +1,10 @@ package com.vci.web.controller; +import com.vci.corba.common.PLException; +import com.vci.corba.omd.btm.BizType; +import com.vci.corba.omd.ltm.LinkType; +import com.vci.dto.OsBtmTypeDTO; +import com.vci.model.IndexObject; import com.vci.starter.web.annotation.controller.VciUnCheckRight; import com.vci.starter.web.annotation.log.VciBusinessLog; import com.vci.starter.web.enumpck.BooleanEnum; @@ -7,32 +12,39 @@ 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.pagemodel.Tree; import com.vci.starter.web.util.BeanUtil; import com.vci.starter.web.util.ControllerUtil; import com.vci.starter.web.util.LangBaseUtil; import com.vci.starter.web.util.VciBaseUtil; -import com.vci.web.pageModel.OsBtmTypeAttributeVO; -import com.vci.web.pageModel.OsBtmTypeVO; -import com.vci.web.pageModel.OsERVO; +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 com.vci.web.service.impl.OsAttributeServiceImpl; +import feign.Param; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; -import org.springframework.util.CollectionUtils; 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; +import java.util.Map; import java.util.stream.Collectors; -import static com.vci.frameworkcore.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST; +import static com.vci.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST; /** * 涓氬姟绫诲瀷鐨勬帶鍒跺櫒 @@ -45,10 +57,21 @@ public class WebBtmTypeController { /** + * 鏃ュ織 + */ + private Logger logger = LoggerFactory.getLogger(getClass()); + + /** * 涓氬姟绫诲瀷鐨勬湇鍔� */ @Autowired private OsBtmServiceI btmService; + + /** + * 杩炴帴绫诲瀷鐨勬湇鍔� + */ + @Autowired + private OsLinkTypeServiceI linkTypeService; /** * 涓氬姟绫诲瀷瀵煎叆瀵煎嚭鏈嶅姟 @@ -74,6 +97,347 @@ return btmService.referDataGrid(baseQueryObject.getConditionMap(),baseQueryObject.getPageHelper()); } + /** + * 鑾峰彇鍚嶅瓧浠ilter寮�濮嬬殑涓氬姟绫诲瀷(for 鏌ヨ)锛屼富瑕佺敤浜庡睘鎬ф睜鐨勪笟鍔$被鍨嬮�夋嫨瀵硅瘽妗� + * @param btmName 鏌ヨ鏉′欢 + * @return 鍒楄〃鐨勫唴瀹� + */ + @GetMapping( "/getBizTypes") + @VciBusinessLog(operateName = "涓氬姟绫诲瀷鍒楄〃(涓昏鐢ㄤ簬瀵硅瘽妗嗕娇鐢�)") + @VciUnCheckRight + public BaseResult getBizTypes(String btmName){ + try { + return BaseResult.dataList(Arrays.asList(btmService.getBizTypes(btmName))); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鑾峰彇涓氬姟绫诲瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鑾峰彇鎵�鏈変笟鍔$被鍨嬶紙鏍戝舰缁撴瀯锛� + * @return 鏌ヨ缁撴灉 + */ + @GetMapping( "/getTreeBizTypes") + @VciBusinessLog(operateName = "鑾峰彇鎵�鏈変笟鍔$被鍨嬶紙鏍戝舰缁撴瀯锛�") + public BaseResult<List<Tree>> getTreeBizTypes(){ + try { + return BaseResult.dataList(btmService.getTreeBizTypes()); + }catch (Exception e) { + e.printStackTrace(); + 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") + @VciUnCheckRight + 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 = 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; + } + } /** * 鍙傜収鐨勪笟鍔$被鍨� @@ -101,7 +465,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<>(); } @@ -112,7 +484,7 @@ OsBtmTypeAttributeVO attributeVO = new OsBtmTypeAttributeVO(); BeanUtil.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); @@ -135,7 +507,6 @@ return dataGrid; } - /** * 浣跨敤涓婚敭鑾峰彇涓氬姟绫诲瀷鍖呭惈鐨勫睘鎬э紝涓嶅垎椤� * @param baseQueryObject 鏌ヨ瀵硅薄 @@ -150,7 +521,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)){ @@ -167,7 +546,6 @@ return dataGrid; } - /** * 浣跨敤涓婚敭鑾峰彇涓氬姟绫诲瀷鐨勫璞� * @param oid 涓婚敭 @@ -181,6 +559,7 @@ } return BaseResult.success(btmTypeVO); } + /** * 瀵煎嚭涓氬姟绫诲瀷鐨勪俊鎭埌word涓� * @param btmTypeIds 涓氬姟绫诲瀷鐨勭紪鍙凤紝鐢ㄩ�楀彿鍒嗗壊 @@ -250,4 +629,5 @@ public BaseResult createERUsed(String id){ return BaseResult.success(btmService.createERUsed(id)); } + } -- Gitblit v1.9.3