Exemplo n.º 1
0
 private List<Map<String, Object>> localTransactionResult(List<LocalTransaction> requistionList) {
   List<Map<String, Object>> mappedApplications =
       new ArrayList<Map<String, Object>>(requistionList.size());
   List<PropertyFilter> propertyFilters = new ArrayList<PropertyFilter>();
   List<Application> apps = new ArrayList<Application>();
   List<SecurityDomain> sds = new ArrayList<SecurityDomain>();
   for (LocalTransaction localTransaction : requistionList) {
     propertyFilters.clear();
     apps.clear();
     sds.clear();
     Map<String, Object> mappedLocalTransaction = localTransaction.toMap(null, null);
     String formatValue = "";
     if (localTransaction.getBeginTime() != null) {
       formatValue =
           DateFormatUtils.format(
               (Calendar) localTransaction.getBeginTime(), "yyyy-MM-dd HH:mm:ss");
     }
     mappedLocalTransaction.put("beginTime", formatValue);
     formatValue = "";
     if (localTransaction.getEndTime() != null) {
       formatValue =
           DateFormatUtils.format((Calendar) localTransaction.getEndTime(), "yyyy-MM-dd HH:mm:ss");
     }
     mappedLocalTransaction.put("endTime", formatValue);
     mappedLocalTransaction.put(
         "failMessage",
         localTransaction.getFailMessage() == null ? "" : localTransaction.getFailMessage());
     // propertyFilters.add(new PropertyFilter("aid", MatchType.EQ,
     // PropertyType.S, localTransaction.getAid()));
     if (localTransaction.getProcedureName().equals(Operation.CREATE_SD.toString())
         || localTransaction.getProcedureName().equals(Operation.DELETE_SD.toString())
         || localTransaction.getProcedureName().equals(Operation.LOCK_SD.toString())
         || localTransaction.getProcedureName().equals(Operation.UNLOCK_SD.toString())
         || localTransaction.getProcedureName().equals(Operation.SYNC_CARD_SD.toString())
         || localTransaction.getProcedureName().equals(Operation.UPDATE_KEY.toString())) {
       propertyFilters.add(
           new PropertyFilter("aid", MatchType.EQ, PropertyType.S, localTransaction.getAid()));
       sds = securityDomainManager.find(propertyFilters);
       if (sds != null && sds.size() != 0) {
         mappedLocalTransaction.put("appName", sds.get(0).getSdName());
         mappedLocalTransaction.put("showType", "sd");
       }
     } else if (localTransaction.getProcedureName().equals("LOCK_CARD")
         || localTransaction.getProcedureName().equals("UNLOCK_CARD")) {
       propertyFilters.add(
           new PropertyFilter(
               "mobileNo", MatchType.EQ, PropertyType.S, localTransaction.getMobileNo()));
       List<CustomerCardInfo> ccis = this.customerCardInfoManager.find(propertyFilters);
       CustomerCardInfo cci = null;
       for (CustomerCardInfo _cci : ccis) {
         if (_cci.getCard()
             .getCardNo()
             .equals(localTransaction.getCardNo())) { // 根据卡号和手机号查找CustomerCardInfo,并且列出最新的终端名
           if (cci == null || cci.getId() < _cci.getId()) {
             cci = _cci;
           }
         }
       }
       if (null != cci) {
         mappedLocalTransaction.put("appName", cci.getName());
         mappedLocalTransaction.put("cciIconId", cci.getMobileType().getId());
         mappedLocalTransaction.put("showType", "termial");
       }
     } else {
       propertyFilters.add(
           new PropertyFilter("aid", MatchType.EQ, PropertyType.S, localTransaction.getAid()));
       apps = applicationManager.find(propertyFilters);
       if (apps != null && apps.size() != 0) {
         mappedLocalTransaction.put("appName", apps.get(0).getName());
         mappedLocalTransaction.put("application_id", apps.get(0).getId());
         mappedLocalTransaction.put("showType", "app");
       }
     }
     if (PlatformMessage.SUCCESS.getCode().equals(localTransaction.getResult())) {
       mappedLocalTransaction.put("result", PlatformMessage.SUCCESS.getMessage());
     } else if (PlatformMessage.TRANS_EXCESSIVING.getCode().equals(localTransaction.getResult())) {
       mappedLocalTransaction.put("result", PlatformMessage.TRANS_EXCESSIVING.getMessage());
     } else if (PlatformMessage.TRANS_EXCEPTION_CLOSED
         .getCode()
         .equals(localTransaction.getResult())) {
       mappedLocalTransaction.put("result", PlatformMessage.TRANS_EXCEPTION_CLOSED.getMessage());
     } else {
       //				for (PlatformErrorCode pe : PlatformErrorCode.values()) {
       //					if (pe.getErrorCode().equals(localTransaction.getResult())) {
       //						mappedLocalTransaction.put("result", pe.getDefaultMessage());
       //					}
       //				}
       mappedLocalTransaction.put("result", localTransaction.getFailMessage());
     }
     mappedApplications.add(mappedLocalTransaction);
   }
   return mappedApplications;
 }
Exemplo n.º 2
0
 private List<Map<String, Object>> desiredOperationResult(
     List<DesiredOperation> requistionList, String executionStatus) {
   List<Map<String, Object>> mappedApplications =
       new ArrayList<Map<String, Object>>(requistionList.size());
   List<PropertyFilter> propertyFilters = new ArrayList<PropertyFilter>();
   List<Application> apps = new ArrayList<Application>();
   List<SecurityDomain> sds = new ArrayList<SecurityDomain>();
   Task task = null;
   for (DesiredOperation desiredOperation : requistionList) {
     if (desiredOperation.getPreProcess().intValue() == DesiredOperation.PREPROCESS_TURE
         && desiredOperation.getIsExcuted().intValue() == DesiredOperation.NOT_EXCUTED) {
       continue;
     }
     if (desiredOperation.getTaskId() != null) {
       task = taskManager.load(desiredOperation.getTaskId());
     } else {
       task = new Task();
     }
     CustomerCardInfo customerCardInfo = null;
     if (null != desiredOperation.getCustomerCardId()
         && 0 != desiredOperation.getCustomerCardId()) {
       customerCardInfo = customerCardInfoManager.load(desiredOperation.getCustomerCardId());
     }
     propertyFilters.clear();
     apps.clear();
     sds.clear();
     Map<String, Object> mappedDesiredOperation = desiredOperation.toMap(null, null);
     mappedDesiredOperation.put("cardNo", "");
     Long cciId;
     if (null != (cciId = desiredOperation.getCustomerCardId())) {
       CustomerCardInfo cci = customerCardInfoManager.load(cciId);
       mappedDesiredOperation.put("cardNo", cci.getCard().getCardNo());
     }
     mappedDesiredOperation.put("idStr", String.valueOf(desiredOperation.getId()));
     mappedDesiredOperation.put(
         "beginTime",
         CalendarUtils.parsefomatCalendar(task.getBeginTime(), CalendarUtils.LONG_FORMAT_LINE));
     if (null != customerCardInfo) {
       mappedDesiredOperation.put("cciName", customerCardInfo.getName());
     } else {
       mappedDesiredOperation.put("cciName", "");
     }
     mappedDesiredOperation.put(
         "endTime",
         CalendarUtils.parsefomatCalendar(task.getEndTime(), CalendarUtils.LONG_FORMAT_LINE));
     String result = desiredOperation.getResult();
     if (StringUtils.isBlank(result)) {
       LocalTransaction localTransaction =
           localTransactionManager.getBySessionId(desiredOperation.getSessionId());
       if (localTransaction != null) {
         mappedDesiredOperation.put("failMessage", localTransaction.getFailMessage());
       }
     } else {
       mappedDesiredOperation.put("failMessage", result);
     }
     // if (executionStatus != null && Integer.parseInt(executionStatus)
     // == DesiredOperation.NOT_FINISH_EXCUTED){
     // List<LocalTransaction> localTransactions =
     // task.getLocalTransactions();
     // for (LocalTransaction lt : localTransactions){
     // if(!StringUtils.isEmpty(lt.getFailMessage())){
     // mappedDesiredOperation.put("failMessage", lt.getFailMessage());
     // break;
     // }
     // }
     // }
     propertyFilters.add(
         new PropertyFilter("aid", MatchType.EQ, PropertyType.S, desiredOperation.getAid()));
     if (desiredOperation.getProcedureName().equals(Operation.CREATE_SD.toString())
         || desiredOperation.getProcedureName().equals(Operation.DELETE_SD.toString())
         || desiredOperation.getProcedureName().equals(Operation.LOCK_SD.toString())
         || desiredOperation.getProcedureName().equals(Operation.UNLOCK_SD.toString())
         || desiredOperation.getProcedureName().equals(Operation.SYNC_CARD_SD.toString())
         || desiredOperation.getProcedureName().equals(Operation.UPDATE_KEY.toString())) {
       sds = securityDomainManager.find(propertyFilters);
       if (sds != null && sds.size() != 0) {
         mappedDesiredOperation.put("appName", sds.get(0).getSdName());
         mappedDesiredOperation.put("hasIcon", "sd");
       }
     } else if (desiredOperation.getProcedureName().equals("LOCK_CARD")) {
       CustomerCardInfo cci = customerCardInfoManager.load(desiredOperation.getCustomerCardId());
       mappedDesiredOperation.put("appName", "");
       if (null != cci) {
         mappedDesiredOperation.put("cciIconId", cci.getMobileType().getId());
         mappedDesiredOperation.put("hasIcon", "LOCK_CARD");
       }
     } else if (desiredOperation.getProcedureName().equals("UNLOCK_CARD")) {
       CustomerCardInfo cci = customerCardInfoManager.load(desiredOperation.getCustomerCardId());
       mappedDesiredOperation.put("appName", "");
       if (null != cci) {
         mappedDesiredOperation.put("cciIconId", cci.getMobileType().getId());
         mappedDesiredOperation.put("hasIcon", "UNLOCK_CARD");
       }
     } else {
       apps = applicationManager.find(propertyFilters);
       if (apps != null && apps.size() != 0) {
         mappedDesiredOperation.put("appName", apps.get(0).getName());
         mappedDesiredOperation.put("application_id", apps.get(0).getId());
         mappedDesiredOperation.put("hasIcon", apps.get(0).getPcIcon() != null);
         boolean hasClient = false;
         List<ApplicationVersion> versions = apps.get(0).getVersions();
         for (ApplicationVersion av : versions) {
           if (av.getClients().size() != 0) {
             hasClient = true;
             break;
           }
         }
         mappedDesiredOperation.put("hasClient", hasClient);
       }
     }
     mappedApplications.add(mappedDesiredOperation);
     final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
     if (Integer.valueOf(executionStatus) != 0) {
       Collections.sort(
           mappedApplications,
           new Comparator<Map<String, Object>>() {
             @Override
             public int compare(Map<String, Object> m1, Map<String, Object> m2) {
               if (StringUtils.isNotBlank((String) m1.get("beginTime"))
                   && StringUtils.isNotBlank((String) m2.get("beginTime"))) {
                 try {
                   Date date1 = sdf.parse((String) m1.get("beginTime"));
                   Date date2 = sdf.parse((String) m2.get("beginTime"));
                   return 0 - date1.compareTo(date2);
                 } catch (ParseException e) {
                   e.printStackTrace();
                 }
                 return 0;
               } else {
                 return 0;
               }
             }
           });
     }
   }
   return mappedApplications;
 }