List of usage examples for org.apache.commons.collections MapUtils getString
public static String getString(final Map map, final Object key)
From source file:com.boxiang.share.product.ccic.service.impl.CcicOrderInfoServiceImpl.java
@Override public String savePolicy(Map map) { Map orderInfo = getOrderInfo(map); String insuranceApplicantNo = MapUtils.getString(orderInfo, "insuranceApplicantNo"); String utmsn = MapUtils.getString(orderInfo, "utmsn"); CcicOrderInfo ccicOrderInfo = new CcicOrderInfo(); ccicOrderInfo.setInsuranceApplicantNo(insuranceApplicantNo); List<CcicOrderInfo> list = ccicOrderInfoDao.selectList(ccicOrderInfo); if (list == null || list.size() == 0) { return "<?xml version=\"1.0\" encoding=\"GBK\"?>" + "<response finishTime=\"" + DateUtil.getCurrDate(DateUtil.DATETIME_FORMAT) + "\">" + "<isSuccess>F</isSuccess>" + "<insuranceApplicantNo>" + insuranceApplicantNo + "</insuranceApplicantNo>" + "<errorCode>2000</errorCode>" + "<errorReason>????</errorReason>" + "</response>"; }/*from ww w .j av a 2s . com*/ if (orderMainService.queryById(utmsn) == null) { return "<?xml version=\"1.0\" encoding=\"GBK\"?>" + "<response finishTime=\"" + DateUtil.getCurrDate(DateUtil.DATETIME_FORMAT) + "\">" + "<isSuccess>F</isSuccess>" + "<insuranceApplicantNo>" + insuranceApplicantNo + "</insuranceApplicantNo>" + "<errorCode>2000</errorCode>" + "<errorReason>???</errorReason>" + "</response>"; } ccicOrderInfo = list.get(0); ccicOrderInfo.setPolicyNo(MapUtils.getString(orderInfo, "policyNo")); ccicOrderInfo.setEffectDate(MapUtils.getString(orderInfo, "effectdate")); ccicOrderInfo.setModified("admin"); ccicOrderInfo.setModifyDate(new Date()); ccicOrderInfoDao.update(ccicOrderInfo); return "<?xml version=\"1.0\" encoding=\"GBK\"?>" + "<response finishTime=\"" + DateUtil.getCurrDate(DateUtil.DATETIME_FORMAT) + "\">" + "<isSuccess>T</isSuccess>" + "<insuranceApplicantNo>" + insuranceApplicantNo + "</insuranceApplicantNo>" + "<errorCode></errorCode>" + "<errorReason></errorReason>" + "</response>"; }
From source file:com.ctrip.infosec.rule.rabbitmq.RabbitMqMessageHandler.java
public void handleMessage(Object message) throws Exception { RiskFact fact = null;/*from ww w . jav a2s .c o m*/ String factTxt; InternalRiskFact internalRiskFact = null; try { if (message instanceof byte[]) { factTxt = new String((byte[]) message, Constants.defaultCharset); } else if (message instanceof String) { factTxt = (String) message; } else { throw new IllegalArgumentException("????\"String\"\"byte[]\""); } logger.info("MQ: fact=" + factTxt); fact = JSON.parseObject((String) factTxt, RiskFact.class); Contexts.setAsync(true); Contexts.setLogPrefix("[" + fact.eventPoint + "][" + fact.eventId + "] "); SarsMonitorContext.setLogPrefix(Contexts.getLogPrefix()); boolean traceLoggerEnabled = MapUtils.getBoolean(fact.ext, Constants.key_traceLogger, true); TraceLogger.enabled(traceLoggerEnabled); RuleMonitorHelper.newTrans(fact, RuleMonitorType.CP_ASYNC); // ?? // S0 - ?? // S1 - ? // S2 - ?? // S3 - // ??GET try { RuleMonitorHelper.newTrans(fact, RuleMonitorType.GET); TraceLogger.beginTrans(fact.eventId, "S3"); TraceLogger.setLogPrefix("[??]"); eventDataMergeService.executeRedisGet(fact); } finally { TraceLogger.commitTrans(); RuleMonitorHelper.commitTrans(fact); } // ? try { RuleMonitorHelper.newTrans(fact, RuleMonitorType.PRE_RULE_WRAP); TraceLogger.beginTrans(fact.eventId, "S3"); TraceLogger.setLogPrefix("[?]"); preRulesExecutorService.executePreRules(fact, true); } finally { TraceLogger.commitTrans(); RuleMonitorHelper.commitTrans(fact); } // try { RuleMonitorHelper.newTrans(fact, RuleMonitorType.RULE_WRAP); TraceLogger.beginTrans(fact.eventId, "S3"); TraceLogger.setLogPrefix("[]"); rulesExecutorService.executeAsyncRules(fact); } finally { TraceLogger.commitTrans(); RuleMonitorHelper.commitTrans(fact); } // try { RuleMonitorHelper.newTrans(fact, RuleMonitorType.MODEL_RULE_WRAP); TraceLogger.beginTrans(fact.eventId, "S3"); TraceLogger.setLogPrefix("[]"); modelRulesExecutorService.executeModelRules(fact); } finally { TraceLogger.commitTrans(); RuleMonitorHelper.commitTrans(fact); } // ?? try { RuleMonitorHelper.newTrans(fact, RuleMonitorType.POST_RULE_WRAP); TraceLogger.beginTrans(fact.eventId, "S3"); TraceLogger.setLogPrefix("[??]"); postRulesExecutorService.executePostRules(fact, true); } finally { TraceLogger.commitTrans(); RuleMonitorHelper.commitTrans(fact); } // ??PUT try { RuleMonitorHelper.newTrans(fact, RuleMonitorType.PUT); TraceLogger.beginTrans(fact.eventId, "S3"); TraceLogger.setLogPrefix("[??]"); eventDataMergeService.executeRedisPut(fact); } finally { TraceLogger.commitTrans(); RuleMonitorHelper.commitTrans(fact); } //Counter?? try { RuleMonitorHelper.newTrans(fact, RuleMonitorType.PUSH_WRAP); TraceLogger.beginTrans(fact.eventId, "S3"); TraceLogger.setLogPrefix("[Counter?]"); counterPushRuleExrcutorService.executeCounterPushRules(fact, true); } finally { TraceLogger.commitTrans(); RuleMonitorHelper.commitTrans(fact); } RuleMonitorHelper.commitTrans(fact); // -------------------------------- ? -------------------------------------- // beforeInvoke("CardRiskDB.CheckResultLog.saveRuleResult"); Long riskReqId = MapUtils.getLong(fact.ext, Constants.key_reqId); boolean outerReqId = riskReqId != null; internalRiskFact = offline4jService.saveForOffline(fact); if (internalRiskFact != null && internalRiskFact.getReqId() > 0) { riskReqId = internalRiskFact.getReqId(); } // ? beforeInvoke("CardRiskDB.CheckResultLog.saveRuleResult"); try { TraceLogger.beginTrans(fact.eventId, "S3"); TraceLogger.setLogPrefix("[?CheckResultLog]"); if (riskReqId != null && riskReqId > 0) { TraceLogger.traceLog("reqId = " + riskReqId); saveRuleResult(riskReqId, fact, fact.whitelistResults, outerReqId); saveRuleResult(riskReqId, fact, fact.results, outerReqId); saveRuleResult(riskReqId, fact, fact.results4Async, outerReqId); saveRuleResult(riskReqId, fact, fact.resultsGroupByScene, outerReqId); saveRuleResult(riskReqId, fact, fact.resultsGroupByScene4Async, outerReqId); } } catch (Exception ex) { fault("CardRiskDB.CheckResultLog.saveRuleResult"); logger.error( Contexts.getLogPrefix() + "?[InfoSecurity_CheckResultLog]?.", ex); } finally { long usage = afterInvoke("CardRiskDB.CheckResultLog.saveRuleResult"); TraceLogger.traceLog(": " + usage + "ms"); TraceLogger.commitTrans(); } } catch (Throwable ex) { logger.error(Contexts.getLogPrefix() + "invoke handleMessage exception.", ex); } finally { if (fact != null) { // ??DataDispatcher try { beforeInvoke("DataDispatcher.sendMessage"); dispatcherMessageSender.sendToDataDispatcher(fact); } catch (Exception ex) { fault("DataDispatcher.sendMessage"); logger.error(Contexts.getLogPrefix() + "send dispatcher message fault.", ex); } finally { afterInvoke("DataDispatcher.sendMessage"); } int riskLevel = MapUtils.getInteger(fact.finalResult, Constants.riskLevel, 0); if (riskLevel > 0) { // ??Offline4J if (internalRiskFact != null && MapUtils.getBoolean(fact.ext, Offline4jService.PUSH_OFFLINE_WORK_ORDER_KEY, false)) { beforeInvoke("Offline.sendMessage"); try { Object eventObj = riskEventConvertor.convert(internalRiskFact, riskLevel, HeaderMappingBizType.Offline4J); offlineMessageSender.sendToOffline(eventObj); } catch (Exception ex) { fault("Offline.sendMessage"); logger.error(Contexts.getLogPrefix() + "send Offline4J message fault.", ex); } finally { afterInvoke("Offline.sendMessage"); } } } try { //??factresults0? boolean withScene = Constants.eventPointsWithScene.contains(fact.eventPoint); if (!withScene) { //? for (Entry<String, Map<String, Object>> entry : fact.results.entrySet()) { String ruleNo = entry.getKey(); int rLevel = NumberUtils .toInt(MapUtils.getString(entry.getValue(), Constants.riskLevel)); if (rLevel > 0) { //?? String distinct = getDistinctValue(fact, ruleNo); RuleMonitorRepository.increaseCounter(fact.getEventPoint(), ruleNo, distinct); } } for (Entry<String, Map<String, Object>> entry : fact.results4Async.entrySet()) { String ruleNo = entry.getKey(); int rLevel = NumberUtils .toInt(MapUtils.getString(entry.getValue(), Constants.riskLevel)); if (rLevel > 0) { //?? String distinct = getDistinctValue(fact, ruleNo); RuleMonitorRepository.increaseCounter(fact.getEventPoint(), ruleNo, distinct); } } } else { // for (Entry<String, Map<String, Object>> entry : fact.resultsGroupByScene.entrySet()) { String ruleNo = entry.getKey(); int rLevel = NumberUtils .toInt(MapUtils.getString(entry.getValue(), Constants.riskLevel)); if (rLevel > 0) { // RuleMonitorRepository.increaseCounter(fact.getEventPoint(), ruleNo); //?? String distinct = getDistinctValue(fact, ruleNo); RuleMonitorRepository.increaseCounter(fact.getEventPoint(), ruleNo, distinct); } } for (Entry<String, Map<String, Object>> entry : fact.resultsGroupByScene4Async.entrySet()) { String ruleNo = entry.getKey(); int rLevel = NumberUtils .toInt(MapUtils.getString(entry.getValue(), Constants.riskLevel)); if (rLevel > 0) { // RuleMonitorRepository.increaseCounter(fact.getEventPoint(), ruleNo); //?? String distinct = getDistinctValue(fact, ruleNo); RuleMonitorRepository.increaseCounter(fact.getEventPoint(), ruleNo, distinct); } } } } catch (Exception ex) { logger.error(Contexts.getLogPrefix() + "RuleMonitorRepository increaseCounter fault.", ex); } } } }
From source file:com.iisigroup.cap.rule.handler.RuleTbMntHandler.java
public File createDecisionTable(Request request) { // String packageName = "com.iisigroup.cap.service"; // String importClass = "com.iisigroup.cap.base.model.CaseInfo,com.iisigroup.cap.utils.CapDroolsUtil";r // String variablesName = "com.iisigroup.cap.utils.CapDroolsUtil comUtil"; String divRlNo = request.get("divRlNo"); String oid = request.get("oid"); DivRlItm rlItm = ruleTbMntService.getByRlItmNo(divRlNo); if (rlItm == null || rlItm.getDivRlDtls() == null) { return null; }/* w ww .ja va 2 s . c o m*/ // ??Rule List<DivRlDtl> rlDtls = ruleTbMntService.findRlDtlsByRlNoAndSort(rlItm.getDivRlNo());// rlItm.getDivRlDtls(); List<DivCtItm> ctItms = null; WritableWorkbook workbook = null; File relFile = null; try { File fileDir = new File("../Temp"); FileUtils.forceMkdir(fileDir); // Char(3.6) ? List<Map<String, Object>> lnf312Data = new ArrayList<Map<String, Object>>(); String BRNO = "", BRNM = ""; StringBuffer BRNoNm = new StringBuffer(); if (!CollectionUtils.isEmpty(lnf312Data)) { for (Map<String, Object> map : lnf312Data) { BRNO = MapUtils.getString(map, "BRNO") + " "; BRNM = MapUtils.getString(map, "BRNM") + " "; BRNoNm.append(BRNO).append(BRNM); } } relFile = new File(fileDir + File.separator + CapDate.getCurrentDate("yyyyMMdd") + "_ruleExport.xls"); relFile.createNewFile(); // 2. workbook workbook = Workbook.createWorkbook(relFile); WritableSheet sheet1 = workbook.createSheet("Tables", 0); WritableFont myFont = new WritableFont(WritableFont.createFont("Arial"), 12); WritableFont boldWhiteFnt = new WritableFont(WritableFont.createFont("Arial"), 12, WritableFont.BOLD); boldWhiteFnt.setColour(Colour.WHITE); WritableFont blackFnt = new WritableFont(WritableFont.createFont("Arial"), 12, WritableFont.NO_BOLD); blackFnt.setColour(Colour.BLACK); // 1---> // DecisionTable?() WritableCellFormat headCellFmt = new WritableCellFormat(); // ? headCellFmt.setWrap(false); // ? headCellFmt.setAlignment(Alignment.LEFT); // headCellFmt.setVerticalAlignment(VerticalAlignment.TOP); // headCellFmt.setFont(boldWhiteFnt); // ?() // headCellFmt.setBorder(Border.ALL,BorderLineStyle.THIN, Colour.BLACK); // ? headCellFmt.setBackground(Colour.GRAY_80); // DecisionTable WritableCellFormat setCellFmt = new WritableCellFormat(); // ? setCellFmt.setWrap(true); // ? setCellFmt.setAlignment(Alignment.LEFT); // setCellFmt.setVerticalAlignment(VerticalAlignment.TOP); // setCellFmt.setFont(myFont); // ?() setCellFmt.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK); // ?() setCellFmt.setBackground(Colour.TAN); // DecisionTable WritableCellFormat bodyCellFmt = new WritableCellFormat(); // ? bodyCellFmt.setWrap(false); // ? bodyCellFmt.setAlignment(Alignment.LEFT); // bodyCellFmt.setVerticalAlignment(VerticalAlignment.TOP); // bodyCellFmt.setFont(myFont); // ?() bodyCellFmt.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK); // ? // bodyCellFmt.setBackground(Colour.BLACK); // DecisionTable? WritableCellFormat blueCellFmt = new WritableCellFormat(); // ? blueCellFmt.setWrap(false); // ? blueCellFmt.setAlignment(Alignment.LEFT); // blueCellFmt.setVerticalAlignment(VerticalAlignment.TOP); // blueCellFmt.setFont(myFont); // ?() blueCellFmt.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK); blueCellFmt.setBackground(Colour.LIGHT_TURQUOISE); // DecisionTable WritableCellFormat yellowCellFmt = new WritableCellFormat(); // ? yellowCellFmt.setWrap(false); // ? yellowCellFmt.setAlignment(Alignment.LEFT); // yellowCellFmt.setVerticalAlignment(VerticalAlignment.TOP); // yellowCellFmt.setFont(myFont); // ?() yellowCellFmt.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK); yellowCellFmt.setBackground(Colour.YELLOW); // DecisionTable WritableCellFormat greenCellFmt = new WritableCellFormat(); // ? greenCellFmt.setWrap(false); // ? greenCellFmt.setAlignment(Alignment.LEFT); // greenCellFmt.setVerticalAlignment(VerticalAlignment.TOP); // greenCellFmt.setFont(myFont); // ?() greenCellFmt.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK); greenCellFmt.setBackground(Colour.LIGHT_GREEN); // // int row = 0; // sheet1.setRowView(row,450); // row100 // sheet1.setColumnView(row, 100); // ?x,y, x1,y2 // sheet1.mergeCells(0, row, 11, row); // sheet1.addCell(new Label(0, 0, "", bodyCellFmt)); // sheet1.setColumnView(0, 26); for (int i = 0; i < 65535; i++) { sheet1.setRowView(i + 1, 450); sheet1.setColumnView(i, 23); } sheet1.setRowView(12, 900); // DecisionTable-? NumberFormat nf = new DecimalFormat("#.00"); sheet1.addCell(new Label(1, 2, "RuleSet", headCellFmt)); sheet1.addCell(new Label(1, 3, "Import", headCellFmt)); sheet1.addCell(new Label(1, 4, "EscapeQuotes", headCellFmt)); sheet1.addCell(new Label(1, 5, "Variables", headCellFmt)); sheet1.addCell(new Label(1, 6, "Functions", headCellFmt)); sheet1.addCell(new Label(1, 7, "Notes", headCellFmt)); sheet1.addCell(new Label(1, 9, "RuleTable " + rlItm.getDivRlNm(), headCellFmt)); // DecisionTable- sheet1.addCell(new Label(2, 2, DroolsConstants.PACKAGE_NAME, headCellFmt)); sheet1.addCell(new Label(2, 3, DroolsConstants.IMPORT_CLASS, headCellFmt)); sheet1.addCell(new Label(2, 4, "false", headCellFmt)); sheet1.addCell(new Label(2, 5, DroolsConstants.VARIABLES_NAME, headCellFmt)); // ??? sheet1.addCell(new Label(2, 6, "", headCellFmt)); sheet1.addCell(new Label(2, 7, "This is decision table for " + rlItm.getDivRlNm(), headCellFmt)); sheet1.addCell(new Label(2, 9, "", headCellFmt)); // excel? for (int i = 0; i < 6; i++) { sheet1.mergeCells(2, 2 + i, 7, 2 + i); } // ? sheet1.mergeCells(2, 9, 7, 9); /* ?, */ // ?conditionaction // condition detail int conditionMaxCount = 0; // database table & column? List<String> tableNms = new ArrayList<String>(); Map<String, DivCtDtl> colNms = new LinkedHashMap<String, DivCtDtl>(); // ?????($param) List<DivCtItm> ctItmList = new ArrayList<DivCtItm>(); for (DivRlDtl rlDtl : rlDtls) { DivCtItm ctItm = conditionMntService.findByDivCtItmNo(rlDtl.getDivCtNo()); if (ctItm.getDivCtDtls() != null && ctItm.getDivCtDtls().size() > conditionMaxCount) { conditionMaxCount = ctItm.getDivCtDtls().size(); } // ?? List<DivCtDtl> ctDtls = conditionMntService.findCtDtlsByCtNoAndSort(ctItm.getDivCtNo()); // ?(??1to1) for (DivCtDtl ctDtl : ctDtls) { if (ctDtl.getDivFtDtl() != null && ctDtl.getDivFtDtl().getDivFtItm() != null) { DivFtItm ftItm = ctDtl.getDivFtDtl().getDivFtItm(); String tableNm = ftItm.getTableNm(); String colNm = ftItm.getColumnNm(); // ????CONDITION? if (!tableNms.contains(tableNm)) { tableNms.add(tableNm); } if (!colNms.containsKey(colNm)) { colNms.put(colNm, ctDtl); } } } ctItmList.add(ctItm); } // rule detail // RuleTable() int i = 0, j = 0; Map<String, Integer> colSortNo = new HashMap<String, Integer>(); for (String key : colNms.keySet()) { DivCtDtl ctDtl = colNms.get(key); // CONDITOIN? sheet1.addCell(new Label(1 + j, 10, DroolsConstants.CONDITION_COL, setCellFmt)); // sheet1.addCell(new Label(1 + j, 11, "beanClz:" + tableNms.get(0), setCellFmt)); // ? . + "?" + param/$1,$2 String operand = ""; if (ctDtl.getDivFtDtl() != null) { DivFtDtl ftDtl = ctDtl.getDivFtDtl(); if (!CapString.isEmpty(ftDtl.getRange1()) && !CapString.isEmpty(ftDtl.getRange2())) { operand = "$1<" + key + "&&" + key + "<=$2"; } else { operand = key + "==$param"; } } sheet1.addCell(new Label(1 + j, 12, operand, setCellFmt)); sheet1.addCell(new Label(1 + j, 13, key, blueCellFmt)); colSortNo.put(key, 1 + j); i++; j++; } // Bean ?? sheet1.mergeCells(1, 11, j, 11); // CONDITION?ACTIVITION-GROUP&NO-LOOP&PRIORITY int actGpColNo = 1 + j; sheet1.addCell(new Label(actGpColNo, 10, DroolsConstants.ACTIVATION_GROUP, setCellFmt)); sheet1.addCell(new Label(actGpColNo, 11, "", setCellFmt)); sheet1.addCell(new Label(actGpColNo, 12, "", setCellFmt)); sheet1.addCell(new Label(actGpColNo, 13, "activation group", blueCellFmt)); int noLpColNo = actGpColNo + 1; sheet1.addCell(new Label(noLpColNo, 10, DroolsConstants.NO_LOOP, setCellFmt)); sheet1.addCell(new Label(noLpColNo, 11, "", setCellFmt)); sheet1.addCell(new Label(noLpColNo, 12, "", setCellFmt)); sheet1.addCell(new Label(noLpColNo, 13, "no loop", blueCellFmt)); int priColNo = noLpColNo + 1; sheet1.addCell(new Label(priColNo, 10, DroolsConstants.PRIORITY, setCellFmt)); sheet1.addCell(new Label(priColNo, 11, "", setCellFmt)); sheet1.addCell(new Label(priColNo, 12, "", setCellFmt)); sheet1.addCell(new Label(priColNo, 13, "priority", blueCellFmt)); // ACTION int actColNo1 = priColNo + 1; sheet1.addCell(new Label(actColNo1, 10, DroolsConstants.ACTION_COL, setCellFmt)); sheet1.addCell(new Label(actColNo1, 11, "", setCellFmt)); sheet1.addCell(new Label(actColNo1, 12, "beanClz.setGrpUppId(\"$param\");", setCellFmt)); sheet1.addCell(new Label(actColNo1, 13, "", yellowCellFmt)); int actColNo2 = actColNo1 + 1; sheet1.addCell(new Label(actColNo2, 10, DroolsConstants.ACTION_COL, setCellFmt)); sheet1.addCell(new Label(actColNo2, 11, "", setCellFmt)); sheet1.addCell(new Label(actColNo2, 12, "beanClz.setDocStatus(\"$param\");", setCellFmt)); sheet1.addCell(new Label(actColNo2, 13, "", yellowCellFmt)); int actColNo3 = actColNo2 + 1; sheet1.addCell(new Label(actColNo3, 10, DroolsConstants.ACTION_COL, setCellFmt)); sheet1.addCell(new Label(actColNo3, 11, "", setCellFmt)); sheet1.addCell(new Label(actColNo3, 12, "System.out.println(\"$param\"+ \" CASEINFO IS " + "\" +beanClz.getCasNo()+\" ** ? = " + "\" +beanClz.getGrpUppId() );", setCellFmt)); sheet1.addCell(new Label(actColNo3, 13, "", yellowCellFmt)); sheet1.addCell(new Label(0, 13, "Base rules", greenCellFmt)); /* * condition-->factorExcel */ if (!ctItmList.isEmpty()) { int rowNo = 14, count = 0; for (DivCtItm ctItm : ctItmList) { if (ctItm.getDivCtDtls() != null) { // CtItm list?CtDtl,CtItmRule Row for (DivCtDtl ctDtl : ctItm.getDivCtDtls()) { ctItm = ctDtl.getDivCtItm(); // Action sheet1.addCell(new Label(actColNo1, rowNo, ctItm.getDivCtAction(), bodyCellFmt)); sheet1.addCell(new Label(actColNo2, rowNo, ctItm.getDivCtSetting(), bodyCellFmt)); sheet1.addCell(new Label(actColNo3, rowNo, "Test Condition::" + ctItm.getDivCtNm(), bodyCellFmt)); DivFtDtl ftDtl = ctDtl.getDivFtDtl(); String colNm = ftDtl.getDivFtItm().getColumnNm(); // ??cell Integer colNo = colSortNo.get(colNm); String rangeVal = ""; if (!CapString.isEmpty(ftDtl.getRange1())) { rangeVal = ftDtl.getRange1(); } if (!CapString.isEmpty(ftDtl.getRange2())) { rangeVal += "," + ftDtl.getRange2(); } // row??(rule name) sheet1.addCell(new Label(0, rowNo, ctDtl.getDivCtItm().getDivCtNm(), bodyCellFmt)); // sheet1.addCell(new Label(colNo, rowNo, rangeVal, bodyCellFmt)); } sheet1.addCell(new Label(actGpColNo, rowNo, "group", bodyCellFmt)); sheet1.addCell(new Label(noLpColNo, rowNo, "true", bodyCellFmt)); sheet1.addCell( new Label(priColNo, rowNo, String.valueOf(ctItmList.size() - count), bodyCellFmt)); rowNo++; count++; } } } /* END */ workbook.write(); workbook.close(); } catch (Exception e) { e.printStackTrace(); } return relFile; }
From source file:com.yougou.api.service.impl.ApiAnalyzeServiceImpl.java
public void createAppKeyUserCache() throws Exception { String appKey = null;/*from www .j a v a 2s. c o m*/ String metadataKey = null; String metadataVal = null; String appKeyUser = null; List<Map<String, Object>> list = this.getApiKeyMetadata(); for (Map<String, Object> map : list) { appKey = MapUtils.getString(map, "app_key"); metadataKey = MapUtils.getString(map, "metadata_key"); metadataVal = MapUtils.getString(map, "metadata_val"); if (StringUtils.equals(metadataKey, "MERCHANTS")) { try { SupplierVo vo = supplierService.getSupplierByMerchantCode(metadataVal); appKeyUser = vo.getSupplier(); } catch (Exception e) { //logger.info(" mct api"+metadataVal); //System.out.println(metadataVal); e.printStackTrace(); } } else { try { appKeyUser = apiDistributorService.queryAllDistributor().get(metadataVal); } catch (Exception ex) { ex.printStackTrace(); logger.error("dubbo??"); } } if (StringUtils.isNotEmpty(appKeyUser)) { hashOperations.put(RedisKeyUtils.API_APPKEY_HASH, appKey, appKeyUser + "(" + metadataVal + ")"); } } }
From source file:com.yougou.api.service.impl.ApiAnalyzeServiceImpl.java
public List<ApiMetadata> getApiMetadataByApiName(String apiName) { List<ApiMetadata> list = new ArrayList<ApiMetadata>(); StringBuffer sb = new StringBuffer(); sb.append(" SELECT t.id,t.api_name FROM tbl_merchant_api t"); sb.append(" WHERE t.api_name LIKE ? "); Object[] values = { "%" + apiName + "%" }; List<Map<String, Object>> mapList = JDBCUtils.getInstance().listResultMap(sb.toString(), values); if (CollectionUtils.isNotEmpty(mapList)) { for (Map<String, Object> map : mapList) { String id = MapUtils.getString(map, "id"); String name = MapUtils.getString(map, "api_name"); list.add(new ApiMetadata(id, name)); }/* ww w . j a v a 2 s. c o m*/ } return list; }
From source file:com.ctrip.infosec.rule.rabbitmq.RabbitMqMessageHandler.java
private Map<String, PersistColumnProperties> prepareRiskControlCheckResultLog(Long riskReqId, String ruleType, Entry<String, Map<String, Object>> entry, Long riskLevel, String eventPoint, Long orderId, Integer orderType, Integer subOrderType) { Map<String, PersistColumnProperties> map = Maps.newHashMap(); PersistColumnProperties props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DB_PK); props.setColumnType(DataUnitColumnType.Long); map.put("LogID", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DATA_UNIT); props.setColumnType(DataUnitColumnType.Long); props.setValue(riskReqId);/*from w ww .j a va2 s . co m*/ map.put("RID", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DATA_UNIT); props.setColumnType(DataUnitColumnType.String); props.setValue(ruleType); map.put("RuleType", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DATA_UNIT); props.setColumnType(DataUnitColumnType.Int); props.setValue(MapUtils.getInteger(entry.getValue(), Constants.ruleId, 0)); map.put("RuleID", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DATA_UNIT); props.setColumnType(DataUnitColumnType.String); if ("B".equals(valueAsString(entry.getValue(), Constants.ruleType))) { props.setValue(valueAsString(entry.getValue(), Constants.ruleName)); } else { props.setValue(entry.getKey()); } map.put("RuleName", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DATA_UNIT); props.setColumnType(DataUnitColumnType.Long); props.setValue(riskLevel); map.put("RiskLevel", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DATA_UNIT); props.setColumnType(DataUnitColumnType.String); props.setValue(MapUtils.getString(entry.getValue(), Constants.riskMessage)); map.put("RuleRemark", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.CUSTOMIZE); props.setColumnType(DataUnitColumnType.Data); props.setExpression("const:now:date"); map.put("DataChange_LastTime", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DATA_UNIT); props.setColumnType(DataUnitColumnType.String); props.setValue(eventPoint); map.put("EventPoint", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DATA_UNIT); props.setColumnType(DataUnitColumnType.Long); props.setValue(orderId); map.put("OrderId", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DATA_UNIT); props.setColumnType(DataUnitColumnType.Int); props.setValue(orderType); map.put("OrderType", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DATA_UNIT); props.setColumnType(DataUnitColumnType.Int); props.setValue(subOrderType); map.put("SubOrderType", props); return map; }
From source file:com.ctrip.infosec.rule.rabbitmq.RabbitMqMessageHandler.java
private Map<String, PersistColumnProperties> prepareInfoSecurityCheckResultLog(Long riskReqId, String ruleType, Entry<String, Map<String, Object>> entry, Long riskLevel) { Map<String, PersistColumnProperties> map = Maps.newHashMap(); PersistColumnProperties props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DB_PK); props.setColumnType(DataUnitColumnType.Long); map.put("LogID", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DATA_UNIT); props.setColumnType(DataUnitColumnType.Long); props.setValue(riskReqId);//from w w w.j a v a 2s . c om map.put("ReqID", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DATA_UNIT); props.setColumnType(DataUnitColumnType.String); props.setValue(ruleType); map.put("RuleType", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DATA_UNIT); props.setColumnType(DataUnitColumnType.Int); props.setValue(MapUtils.getInteger(entry.getValue(), Constants.ruleId, 0)); map.put("RuleID", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DATA_UNIT); props.setColumnType(DataUnitColumnType.String); if ("B".equals(valueAsString(entry.getValue(), Constants.ruleType))) { props.setValue(valueAsString(entry.getValue(), Constants.ruleName)); } else { props.setValue(entry.getKey()); } map.put("RuleName", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DATA_UNIT); props.setColumnType(DataUnitColumnType.Long); props.setValue(riskLevel); map.put("RiskLevel", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DATA_UNIT); props.setColumnType(DataUnitColumnType.String); props.setValue(MapUtils.getString(entry.getValue(), Constants.riskMessage)); map.put("RuleRemark", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.CUSTOMIZE); props.setColumnType(DataUnitColumnType.Data); props.setExpression("const:now:date"); map.put("CreateDate", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.CUSTOMIZE); props.setColumnType(DataUnitColumnType.Data); props.setExpression("const:now:date"); map.put("DataChange_LastTime", props); props = new PersistColumnProperties(); props.setPersistColumnSourceType(PersistColumnSourceType.DATA_UNIT); props.setColumnType(DataUnitColumnType.Int); props.setValue(0); map.put("IsHighlight", props); return map; }
From source file:com.mirth.connect.server.controllers.DefaultMessageObjectController.java
public void reprocessMessages(final MessageObjectFilter filter, final boolean replace, final List<String> destinations) throws ControllerException { try {// w w w .j ava 2 s. c o m // since get message by page expects a session, we'll make up a // session ID using a the current system time final String sessionId = String.valueOf(System.currentTimeMillis()); final int size = createMessagesTempTable(filter, sessionId, true); Thread reprocessThread = new Thread(new Runnable() { public void run() { try { int page = 0; int interval = 10; VMRouter router = new VMRouter(); while ((page * interval) < size) { List<MessageObject> messages = getMessagesByPage(page, interval, size, sessionId, false); try { for (MessageObject message : messages) { try { Thread.sleep(10); } catch (InterruptedException ie) { logger.debug(ie); } // get attachment for old message if (message.isAttachment()) { if (message.getRawDataProtocol().equals(MessageObject.Protocol.DICOM)) { String rawData = DICOMUtil.getDICOMRawData(message); message.setRawData(rawData); } else { String rawData = AttachmentUtil.reAttachMessage(message); message.setRawData(rawData); } } if (replace) { message.getContext().put("replace", "true"); if (!message.getConnectorName().equalsIgnoreCase("source")) { message.getContext().put("messageId", message.getCorrelationId()); } else { message.getContext().put("messageId", message.getId()); } } message.getContext().put("destinations", destinations); /* Keep the original filename if reprocessing * See MIRTH-1372 for more details */ if (message.getChannelMap().containsKey("originalFilename")) { message.getContext().put("originalFilename", MapUtils.getString(message.getChannelMap(), "originalFilename")); } router.routeMessageByChannelId(message.getChannelId(), message, true); } } catch (Exception e) { throw new ControllerException("could not reprocess message", e); } page++; } } catch (Exception e) { logger.error(e); } finally { // remove any temp tables we created removeFilterTable(sessionId); } } }); reprocessThread.start(); } catch (ControllerException e) { throw new ControllerException(e); } }
From source file:com.belle.yitiansystem.merchant.service.impl.MerchantsService.java
/** * ?ID???/*from w ww . j a v a2 s . co m*/ * * @author wang.m * @throws SQLException * @Date 2012-03-08 */ @Deprecated public String[] getSpLimitCatBysupplierId(String id) throws SQLException { String str[] = new String[2]; String catStr = ""; String catHide = ""; if (StringUtils.isNotBlank(id)) { /* CritMap critMap = new CritMap(); critMap.addEqual("supplyId", id); List<SpLimitCat> spLimitCat = spLimitCatDaoImpl.findByCritMap(critMap); if (null != spLimitCat && spLimitCat.size() > 0) { for (SpLimitCat spLimitCat2 : spLimitCat) { // ??3?? String threeCatName = this.getCatName(spLimitCat2.getCatNo()); // ?3??2?? String twoCatName = this.getTowCatName(threeCatName, spLimitCat2.getStructName()); // ?3??1?? String structName = spLimitCat2.getStructName().substring(0, 5); String OneCatName = this.getOneCatName(twoCatName, structName); catStr += OneCatName + "-" + twoCatName + "-" + threeCatName + ";"; catHide += spLimitCat2.getStructName() + ";" + spLimitCat2.getId() + "_"; } catStr = catStr.substring(0, catStr.length() - 1); catHide = catHide.substring(0, catHide.length() - 1); } */ List<Map<String, Object>> spLimitBrandMaps = sqlService.getDatasBySql( "select id, cat_no, struct_name from tbl_sp_limit_cat where supply_id = '" + id + "'"); if (null != spLimitBrandMaps && spLimitBrandMaps.size() > 0) { for (Map<String, Object> spLimitBrandMap : spLimitBrandMaps) { String cat_no = MapUtils.getString(spLimitBrandMap, "cat_no"); String struct_name = MapUtils.getString(spLimitBrandMap, "struct_name"); // ??3?? String threeCatName = this.getCatName(cat_no); // ?3??2?? String twoCatName = this.getTowCatName(threeCatName, struct_name); // ?3??1?? String structName = struct_name.substring(0, 5); String OneCatName = this.getOneCatName(twoCatName, structName); catStr += OneCatName + "-" + twoCatName + "-" + threeCatName + ";"; catHide += struct_name + ";" + spLimitBrandMap.get("id") + "_"; } catStr = catStr.substring(0, catStr.length() - 1); catHide = catHide.substring(0, catHide.length() - 1); } } str[0] = catStr; str[1] = catHide; return str; }
From source file:com.belle.yitiansystem.merchant.service.impl.MerchantsService.java
/** * ?ID??--??// www.j a va 2 s .c o m * @param id * @return * @throws SQLException */ @Deprecated public String[] getSpLimitBrandCatBysupplierId(String id) throws SQLException { String str[] = new String[2]; String catStr = ""; String catHide = ""; if (StringUtils.isNotBlank(id)) { List<Map<String, Object>> spLimitBrandMaps = sqlService.getDatasBySql( "SELECT bc.id, c.cat_no, c.struct_name, b.brand_no FROM tbl_sp_limit_cat c LEFT JOIN tbl_sp_limit_brand_cat bc ON c.id = bc.cat_id LEFT JOIN tbl_sp_limit_brand b ON bc.brand_id = b.id WHERE c.supply_id = '" + id + "'"); if (CollectionUtils.isNotEmpty(spLimitBrandMaps)) { for (Map<String, Object> spLimitBrandMap : spLimitBrandMaps) { String struct_name = MapUtils.getString(spLimitBrandMap, "struct_name"); String brand_no = MapUtils.getString(spLimitBrandMap, "brand_no"); if (StringUtils.isBlank(struct_name)) continue; Category cat = commodityBaseApiService.getCategoryByStructName(struct_name); com.yougou.pc.model.brand.Brand brand = null; if (StringUtils.isNotBlank(brand_no)) { brand = commodityBaseApiService.getBrandByNo(brand_no); } catStr += (brand == null ? "" : brand.getBrandName()) + "|" + cat.getStructCatName() + ";"; catHide += brand_no + ";" + struct_name + ";" + cat.getId() + "_"; } catStr = catStr.substring(0, catStr.length() - 1); catHide = catHide.substring(0, catHide.length() - 1); } } str[0] = catStr; str[1] = catHide; return str; }