¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.web.service.impl; |
| | | |
| | | import com.vci.common.qt.object.Symbol; |
| | | import com.vci.constant.IRightConstant; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.framework.data.GrandValue; |
| | | import com.vci.corba.omd.btm.BizType; |
| | | import com.vci.corba.omd.lcm.LifeCycle; |
| | | import com.vci.corba.omd.lcm.TransitionVO; |
| | | import com.vci.corba.omd.ltm.LinkType; |
| | | import com.vci.corba.portal.data.PLAction; |
| | | import com.vci.dto.OsDataAuthDTO; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.BaseResult; |
| | | import com.vci.web.service.OsDataAuthServiceI; |
| | | import com.vci.web.util.PlatformClientUtil; |
| | | import com.vci.web.util.WebUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * æ°æ®æéçæ§å¶å¨ |
| | | * @author yuxc |
| | | * @date 2024-11-25 |
| | | */ |
| | | @Service |
| | | public class OsDataAuthServiceImpl implements OsDataAuthServiceI { |
| | | |
| | | @Autowired |
| | | private PlatformClientUtil platformClientUtil; |
| | | |
| | | @Override |
| | | public BaseResult getData(String typeName) throws PLException { |
| | | GrandValue[] grandValues = platformClientUtil.getFrameworkService().queryGrand(typeName); |
| | | // 设置Tableåå¤´ä¿¡æ¯ |
| | | List<String> tableHeader = new ArrayList<String>(); |
| | | //è·åè¡¨å¤´æ°æ® |
| | | getTableHeader(grandValues, tableHeader, typeName); |
| | | //åè¡¨æ°æ® |
| | | List<Map> rowList = new ArrayList<>(); |
| | | //è·ååè¡¨æ°æ® |
| | | getTableData(grandValues, tableHeader, typeName, rowList); |
| | | Map<String, String> actionsMap = getAllActionsByType2(typeName, "business"); |
| | | OsDataAuthDTO tableData = new OsDataAuthDTO(); |
| | | tableData.setTableHeader(tableHeader); |
| | | tableData.setRowList(rowList); |
| | | tableData.setActionMap(actionsMap); |
| | | return BaseResult.success(tableData); |
| | | } |
| | | /** |
| | | * ä¿åæ°æ®æéæ°æ® |
| | | * @return ä¿åç»æ |
| | | */ |
| | | @Override |
| | | public BaseResult saveGrand(List<GrandValue> grandValues) throws PLException { |
| | | boolean isTrue = false; |
| | | isTrue = platformClientUtil.getFrameworkService() |
| | | .deleteTypeRuleGrand(grandValues.get(0).identifier.split("_")[0], grandValues.get(0).ruleName); |
| | | if(!isTrue){ |
| | | throw new VciBaseException("æ°æ®æéå é¤å¤±è´¥ï¼"); |
| | | } |
| | | // save |
| | | boolean isTrue_add = false; |
| | | try { |
| | | isTrue_add = platformClientUtil.getFrameworkService() |
| | | .saveGrand(grandValues.toArray(new GrandValue[grandValues.size()])); |
| | | } catch (Exception e) { |
| | | throw new VciBaseException("æ°æ®æéä¿å失败ï¼"); |
| | | } |
| | | if (isTrue_add) { |
| | | return BaseResult.success("ä¿åæåï¼"); |
| | | } |
| | | return BaseResult.success("ä¿å失败ï¼"); |
| | | } |
| | | /** |
| | | * å 餿°æ®æé |
| | | * @param typeName ä¸å¡ç±»å |
| | | * @param ruleName è§ååç§° |
| | | * @return å é¤ç»æ |
| | | */ |
| | | @Override |
| | | public BaseResult deleteTypeRuleGrand(String typeName, String ruleName) throws PLException { |
| | | // DataBase |
| | | boolean isTrue = platformClientUtil.getFrameworkService().deleteTypeRuleGrand(typeName, |
| | | ruleName); |
| | | if (!isTrue) { |
| | | return BaseResult.success("å é¤å¤±è´¥ï¼"); |
| | | } |
| | | return BaseResult.success("å 餿åï¼"); |
| | | } |
| | | |
| | | //add by caill start 2015 12.18 å°æ¥è¯¢åºæ¥çactionæ¾å
¥å°mapä¸ |
| | | private Map<String, String> getAllActionsByType2(String typeName, String type) throws PLException { |
| | | Map<String,String> boActions2 = new HashMap<String,String>(); |
| | | boActions2.put("æ¥è¯¢", "query"); |
| | | PLAction[] allActions = platformClientUtil.getUIService().getAllPLActionEntityByType(typeName); |
| | | if (allActions == null || allActions.length == 0) { |
| | | return boActions2; |
| | | } |
| | | for (int i = 0; i < allActions.length; i++) { |
| | | if(allActions[i].plTypeType.equals(type)){ |
| | | boActions2.put(allActions[i].plName,allActions[i].plCode); //å°ä¸ææ¾ç¤ºä½ä¸ºkey,è±ææ¾ç¤ºä½ä¸ºvalueæ¾å°mapä¸ |
| | | } |
| | | } |
| | | return boActions2; |
| | | } |
| | | |
| | | private void getTableData(GrandValue[] grandValues, List<String> tableHeader, String typeName, List<Map> rowList) throws PLException { |
| | | // 便®è§ååç§°ï¼è§ååç±» |
| | | Map<String, List<GrandValue>> splitRuleMap = splitRuleByName(grandValues); |
| | | // 便®è§ååç§° |
| | | // int row = 0; |
| | | // 设置è§åè®°å½è¡æ° |
| | | // ruleModel.setRowCount(splitRuleMap.size()); |
| | | // add by caill start 2016.1.11 å¾å°btmãlinkãlifeCyles |
| | | LinkType[] links = null; |
| | | LifeCycle lifeCycle = null; |
| | | BizType btm = null; |
| | | try { |
| | | btm = platformClientUtil.getBtmService().getBizTypeByName(typeName); |
| | | links = platformClientUtil.getLinkTypeService().getLinkTypeByBtmName(btm.name, Symbol.FROM); |
| | | LifeCycle[] lifeCyles = platformClientUtil.getLifeCycleService().getLifeCycles(); |
| | | for (int m = 0; m < lifeCyles.length; m++) { |
| | | if (lifeCyles[m].name.equals(btm.lifeCycle)) { |
| | | lifeCycle = lifeCyles[m]; |
| | | break; |
| | | } |
| | | } |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | // add by caill end |
| | | // ActionConstants act = new ActionConstants(); |
| | | PLAction[] allActions = platformClientUtil.getUIService().getAllPLActionEntityByType(typeName); |
| | | // platformClientUtil.getUIService().getAllPLActionEntityByType(typeName); |
| | | for (Iterator<Map.Entry<String, List<GrandValue>>> iter = splitRuleMap.entrySet().iterator(); iter.hasNext();) { |
| | | Map.Entry<String, List<GrandValue>> entry = iter.next(); |
| | | List<GrandValue> rules = entry.getValue(); |
| | | |
| | | Map<Object, Object> columnData = new HashMap<>(); |
| | | // å¢å 页é¢ç¼å |
| | | // ruleModel.setConditionValue(row, rules); |
| | | columnData.put("rules",rules.get(0)); |
| | | // add by caill start 2015 12.18 å°æ¥åºçactionæ¾å°mapä¸ï¼æ³¨æä¸è¦è½ä¸âæ¥è¯¢â |
| | | Map<String, String> actionMap = new HashMap<String, String>(); |
| | | actionMap.put("query", "æ¥è¯¢"); // å°æä½ä¸çqueryæ¾å
¥actionMapä¸ |
| | | for (int i = 0; i < allActions.length; i++) { |
| | | if (allActions[i].plTypeType.equals("business")) { |
| | | actionMap.put(allActions[i].plCode, allActions[i].plName); // 尿使¾å
¥actionMapä¸ |
| | | } |
| | | } |
| | | for (int j = 0; j < links.length; j++) { |
| | | for (int i = 0; i < allActions.length; i++) { |
| | | if (allActions[i].plTypeType.equals("link")) { |
| | | actionMap.put(links[j].name + "." + allActions[i].plCode, |
| | | links[j].name + "." + allActions[i].plName);// å°å
³ç³»æ¾å
¥actionMapä¸ |
| | | } |
| | | } |
| | | actionMap.put(links[j].name + "." + "query", links[j].name + "." + "æ¥è¯¢"); // å°å
³ç³»ä¸çqueryæ¾å
¥actionMapä¸ |
| | | } |
| | | |
| | | TransitionVO[] transitions = lifeCycle != null ? lifeCycle.routes : new TransitionVO[0]; |
| | | for (int j = 0; j < transitions.length; j++) { |
| | | String name = lifeCycle.name + "." + transitions[j].connect; |
| | | actionMap.put(name, name); // å°è·è¿æ¾å
¥actionMapä¸ |
| | | } |
| | | // add by caill end |
| | | for (int j = 0; j < rules.size(); j++) { |
| | | // è§åååç±»å |
| | | // ruleModel.setValueAt(rules.get(j).ruleName, row, 0); |
| | | columnData.put(0, rules.get(j).ruleName); |
| | | if (rules.get(j).ruleType.equals(IRightConstant.RULETYPE__HAS)) { |
| | | columnData.put(1, "å
许è§å"); |
| | | } else if (rules.get(j).ruleType.equals(IRightConstant.RULETYPE__NOTHAS)) { |
| | | columnData.put(1, "æç»è§å"); |
| | | } else if (rules.get(j).ruleType.equals(IRightConstant.RULETYPE_ALL_HAS)) { |
| | | columnData.put(1, "å
¨é¨ææ"); |
| | | } else { |
| | | columnData.put(1, "å
¨é¨æ æ"); |
| | | } |
| | | // æå®çæä½èµå¼ |
| | | // TableColumnModel columnModel = funclet.getRightMainPanel().getRuleTable().getColumnModel(); |
| | | int start = rules.get(j).identifier.lastIndexOf("_") + 1; |
| | | String op = rules.get(j).identifier.substring(start, rules.get(j).identifier.length()); |
| | | // add by caill start 2015.12.18 éåmapï¼æ ¹æ®è±æåç§°æ¾å°ç¸åºç䏿åç§°ï¼å¹¶æ ¹æ®ä¸æåç§°æ¾å°å¯¹åºçå |
| | | String headerName = null; |
| | | Set<String> keys = null; |
| | | if (actionMap.size() > 0) { |
| | | keys = actionMap.keySet(); |
| | | } |
| | | if (keys.size() != 0) { |
| | | for (Iterator<String> iterator = keys.iterator(); iterator.hasNext();) { |
| | | String key = iterator.next(); |
| | | if (op.equals(key)) { |
| | | headerName = actionMap.get(key); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int columnIndex = -1; |
| | | if (headerName != null) { |
| | | // columnIndex = columnModel.getColumnIndex(headerName); |
| | | columnIndex = tableHeader.indexOf(headerName); |
| | | } |
| | | // add by caill end |
| | | // int columnIndex = columnModel.getColumnIndex(op); |
| | | if (columnIndex >= 0) { |
| | | // ruleModel.setValueAt(rules.get(j).isGrand == '1' ? true : false, row, columnIndex); |
| | | columnData.put(columnIndex, rules.get(j).isGrand == '1' ? true : false); |
| | | } |
| | | |
| | | } |
| | | // ++row; |
| | | rowList.add(columnData); |
| | | } |
| | | } |
| | | |
| | | private void getTableHeader(GrandValue[] grandValues, List<String> tableHeader, String typeName) throws PLException { |
| | | // æä½ä¿¡æ¯ |
| | | List<String> ops = new ArrayList<String>(); |
| | | for (int i = 0; i < grandValues.length; i++) { |
| | | int start = grandValues[i].identifier.lastIndexOf("_") + 1; |
| | | String op = grandValues[i].identifier.substring(start, grandValues[i].identifier.length()); |
| | | if (!ops.contains(op)) { |
| | | ops.add(op); |
| | | } |
| | | } |
| | | // æä½ä¿¡æ¯ |
| | | String[] operations = ops.toArray(new String[ops.size()]); |
| | | // List<String> tablerule = new ArrayList<String>(); |
| | | tableHeader.add("è§ååç§°"); |
| | | tableHeader.add("è§åç±»å"); |
| | | PLAction[] allActions = platformClientUtil.getUIService().getAllPLActionEntityByType(typeName); |
| | | |
| | | for (int m = 0; m < operations.length; m++) { |
| | | if (allActions != null && allActions.length != 0) { |
| | | for (int i = 0; i < allActions.length; i++) { |
| | | if (allActions[i].plCode.equals(operations[m])) { |
| | | tableHeader.add(allActions[i].plName); |
| | | break; |
| | | } else if (operations[m].endsWith("." + allActions[i].plCode)) { |
| | | int index = operations[m].indexOf("." + allActions[i].plCode); |
| | | StringBuilder sb = new StringBuilder(operations[m]); |
| | | StringBuilder actionChina = sb.replace(index + 1, operations[m].length(), allActions[i].plName); |
| | | tableHeader.add(actionChina.toString()); |
| | | break; |
| | | } else if (operations[m].equals("query")) { |
| | | tableHeader.add("æ¥è¯¢"); // 注æä¸è¦è½ä¸åæ»çâæ¥è¯¢â |
| | | break; |
| | | } else if (operations[m].endsWith(".query")) { |
| | | int index = operations[m].indexOf(".query"); |
| | | StringBuilder sb = new StringBuilder(operations[m]); |
| | | StringBuilder actionChina = sb.replace(index + 1, operations[m].length(), "æ¥è¯¢"); |
| | | tableHeader.add(actionChina.toString()); |
| | | break; |
| | | } |
| | | |
| | | } |
| | | } else { |
| | | if (operations[m].equals("query")) { |
| | | tableHeader.add("æ¥è¯¢"); // 注æä¸è¦è½ä¸åæ»çâæ¥è¯¢â |
| | | } |
| | | if (operations[m].endsWith(".query")) { |
| | | int index = operations[m].indexOf(".query"); |
| | | StringBuilder sb = new StringBuilder(operations[m]); |
| | | StringBuilder actionChina = sb.replace(index + 1, operations[m].length(), "æ¥è¯¢"); |
| | | tableHeader.add(actionChina.toString()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | LifeCycle lifeCycle = null; |
| | | BizType btm = null; |
| | | try { |
| | | btm = platformClientUtil.getBtmService().getBizTypeByName(typeName); |
| | | LifeCycle[] lifeCyles = platformClientUtil.getLifeCycleService().getLifeCycles(); |
| | | for (int j = 0; j < lifeCyles.length; j++) { |
| | | if (lifeCyles[j].name.equals(btm.lifeCycle)) { |
| | | lifeCycle = lifeCyles[j]; |
| | | break; |
| | | } |
| | | } |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | } |
| | | TransitionVO[] transitions = lifeCycle != null ? lifeCycle.routes : new TransitionVO[0]; |
| | | for (int j = 0; j < transitions.length; j++) { |
| | | tableHeader.add(lifeCycle.name + "." + transitions[j].connect); |
| | | } |
| | | } |
| | | |
| | | private Map<String, List<GrandValue>> splitRuleByName(GrandValue[] values) { |
| | | Map<String, List<GrandValue>> splitRuleMap = new HashMap<String, List<GrandValue>>(); |
| | | for (int i = 0; i < values.length; i++) { |
| | | if (splitRuleMap.get(values[i].ruleName) == null) { |
| | | List<GrandValue> ruleOfOneName = new ArrayList<GrandValue>(); |
| | | ruleOfOneName.add(values[i]); |
| | | splitRuleMap.put(values[i].ruleName, ruleOfOneName); |
| | | } else { |
| | | splitRuleMap.get(values[i].ruleName).add(values[i]); |
| | | } |
| | | |
| | | } |
| | | return splitRuleMap; |
| | | |
| | | } |
| | | |
| | | |
| | | } |