예제 #1
0
 /**
  * @param request
  * @return
  */
 @RequestMapping
 public @ResponseBody JsonResult index(HttpServletRequest request) {
   JsonResult result = new JsonResult();
   try {
     Page<LocalTransaction> page = SpringMVCUtils.getPage(request);
     page.addOrder("beginTime", "desc");
     List<PropertyFilter> filters = SpringMVCUtils.getParameters(request);
     filters.add(new PropertyFilter("ALIAS_superTransactionL_NULLI_id", "0"));
     filters.add(new PropertyFilter("ALIAS_taskI_NOTNULLL_id", "0"));
     page = localTransactionManager.findPage(page, filters);
     // page =
     // localTransactionManager.findPage(page,ServletRequestUtils.getStringParameter(request,
     // "search_LIKES_mobileNo"),
     // ServletRequestUtils.getLongParameter(request,
     // "search_EQL_id",-1));
     List<LocalTransaction> requistionList = page.getResult();
     List<Map<String, Object>> mappedLocalTransactions = localTransactionResult(requistionList);
     Page<Map<String, Object>> pageMap = page.getMappedPage();
     pageMap.setResult(mappedLocalTransactions);
     result.setPage(pageMap);
   } catch (PlatformException e) {
     e.printStackTrace();
     result.setSuccess(Boolean.FALSE);
     result.setMessage(e.getMessage());
   } catch (Exception e) {
     e.printStackTrace();
     result.setSuccess(Boolean.FALSE);
     result.setMessage(e.getMessage());
   }
   return result;
 }
예제 #2
0
 @RequestMapping
 public @ResponseBody JsonResult execute(HttpServletRequest request) {
   JsonResult result = new JsonResult();
   try {
     String ids = ServletRequestUtils.getStringParameter(request, "ids");
     localTransactionManager.changeStatus(ids, "1");
   } catch (PlatformException e) {
     e.printStackTrace();
     result.setSuccess(Boolean.FALSE);
     result.setMessage(e.getMessage());
   } catch (Exception e) {
     e.printStackTrace();
     result.setSuccess(Boolean.FALSE);
     result.setMessage(e.getMessage());
   }
   return result;
 }
예제 #3
0
 @RequestMapping
 public @ResponseBody JsonMessage get(@RequestParam("id") Long id) {
   JsonMessage message = new JsonMessage();
   try {
     LocalTransaction lt = localTransactionManager.load(id);
     Map<String, Object> map = lt.toMap(null, null);
     message.setMessage(map);
   } catch (PlatformException e) {
     e.printStackTrace();
     message.setSuccess(Boolean.FALSE);
     message.setMessage(e.getMessage());
   } catch (Exception e) {
     e.printStackTrace();
     message.setSuccess(Boolean.FALSE);
     message.setMessage(e.getMessage());
   }
   return message;
 }
예제 #4
0
 @RequestMapping
 public @ResponseBody JsonMessage checkCardOptFinish(HttpServletRequest request) {
   JsonMessage message = new JsonMessage();
   try {
     String sessionId = ServletRequestUtils.getStringParameter(request, "sessionId");
     boolean flag = localTransactionManager.checkCardOptFinish(sessionId);
     if (!flag) {
       message.setSuccess(flag);
     }
   } catch (PlatformException e) {
     e.printStackTrace();
     message.setSuccess(Boolean.FALSE);
     message.setMessage(e.getMessage());
   } catch (Exception e) {
     e.printStackTrace();
     message.setSuccess(Boolean.FALSE);
     message.setMessage(e.getMessage());
   }
   return message;
 }
예제 #5
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;
 }