Search in sources :

Example 1 with MobileLogmanagementLog

use of com.itrus.portal.db.MobileLogmanagementLog in project portal by ixinportal.

the class KeySegmentationWebSocketHandler method handleMessage.

@Override
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
    logger.info("成功接收到消息");
    // 把客户端的消息解析为JSON对象
    if (message instanceof TextMessage) {
        String appId = webSocketSession.getAttributes().get("appId").toString();
        // String
        // userid=webSocketSession.getAttributes().get("uid").toString();
        // System.out.println(userid);
        logger.info("信息为:" + message.getPayload());
        MobileLogmanagementLog logmanagementLog = new MobileLogmanagementLog();
        // 发送数据
        webSocketSession.sendMessage(message);
        logger.error("appId=" + appId);
        // MobileLogmanagementLog logmanagementLog=new
        // MobileLogmanagementLog();
        JSONObject msg = JSON.parseObject(message.getPayload().toString());
        // ApplicationInfo
        // applicationInfo=applicationInfoServiceImpl.getApplicationInfo(appId);
        ApplicationInfo applicationInfo = applicationInfoServiceImpl.getApplicationInfo(appId);
        logger.error("msg=" + msg);
        MobileLogmanagementLog log = new MobileLogmanagementLog();
        if (msg.containsKey("q2")) {
            String q2 = msg.getString("q2");
            if (q2 != null) {
                log.setUserName(msg.getString("uid"));
                log.setContenu("签名成功");
                log.setServiceType("签名");
                log.setAppName(applicationInfo.getName());
                log.setCreateTime(new Date());
                mobileLogmanagementLogService.insertMobileLogmanagementLog(log);
            } else {
                log.setUserName(msg.getString("uid"));
                log.setContenu("签名失败");
                log.setServiceType("签名");
                log.setAppName(applicationInfo.getName());
                log.setCreateTime(new Date());
                mobileLogmanagementLogService.insertMobileLogmanagementLog(log);
            }
        }
        // JSONObject msg1 = JSON.parseObject(message.getPayload().toString());
        if (msg.containsKey("q2")) {
            // 签名计费
            String q2 = msg.getString("q2");
            if (/*!sign2.contains("ERROR")*/
            q2 != null) {
                logger.error("签名");
                if (!appServiceChargingService.checkTransInfo(appId, applicationInfo)) {
                    // 判断是否有有效的计费
                    logger.error("计费规则检查失败,无可用计费规则");
                } else {
                    logger.error("开始计费,记流水");
                    appServiceChargingService.charging(appId, applicationInfo, /*log.getId(),*/
                    "签名");
                }
            }
        }
        if (msg.containsKey("sign4")) {
            String p2 = msg.getString("sign4");
            if (p2 != null && !p2.equals("ERROR:-1")) {
                logger.error("密钥分割");
                if (!appServiceChargingService.checkTransInfo(appId, applicationInfo)) {
                    // 判断是否有有效的计费
                    logger.error("计费规则检查失败,无可用计费规则");
                } else {
                    // 计费(记流水)
                    logger.error("开始计费,记流水");
                    appServiceChargingService.charging(appId, applicationInfo, /*log.getId(),*/
                    "密钥分割");
                }
            }
        }
    // log.setServiceType("2");
    /*
			 * if(q2!=null){ log.setContenu("签名成功"); }else{
			 * log.setContenu("签名失败"); }
			 */
    // String appId=msg.getString("appId");
    // ApplicationInfo applicationInfo =
    // applicationInfoServiceImpl.getApplicationInfo(appId);
    /*
			 * log.setServiceType("签名");
			 * log.setAppName(applicationInfo.getName()); log.setCreateTime(new
			 * Date());
			 * mobileLogmanagementLogService.insertMobileLogmanagementLog(log);
			 */
    } else // else if(message instanceof BinaryMessage) {
    // BinaryMessage msg = new BinaryMessage((byte[]) message.getPayload());
    // this.handleBinaryMessage(session, (BinaryMessage)message);
    // }
    {
        if (!(message instanceof PongMessage)) {
            throw new IllegalStateException("Unexpected WebSocket message type: " + message);
        }
        this.handlePongMessage(session, (PongMessage) message);
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) MobileLogmanagementLog(com.itrus.portal.db.MobileLogmanagementLog) Date(java.util.Date)

Example 2 with MobileLogmanagementLog

use of com.itrus.portal.db.MobileLogmanagementLog in project portal by ixinportal.

the class MobileAffaireEnregistrerLogController method list.

// 列表展示
@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "appName", required = false) String appName, @RequestParam(value = "userId", required = false) String userId, @RequestParam(value = "type", required = false) String type, @RequestParam(value = "contenu", required = false) String contenu, @RequestParam(value = "queryDate1", required = false) Date queryDate1, @RequestParam(value = "queryDate2", required = false) Date queryDate2, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
    if (queryDate1 == null && queryDate2 == null) {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DATE, 1);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        calendar.add(Calendar.MILLISECOND, -1);
        queryDate2 = calendar.getTime();
        calendar.add(Calendar.MILLISECOND, 1);
        calendar.add(Calendar.MONTH, -1);
        queryDate1 = calendar.getTime();
    }
    if (page == null || page < 1) {
        page = 1;
    }
    if (size == null || size < 1) {
        size = 10;
    }
    MobileLogmanagementLogExample example = new MobileLogmanagementLogExample();
    MobileLogmanagementLogExample.Criteria eam = example.createCriteria();
    if (StringUtils.isNotBlank(appName)) {
        eam.andAppNameLike("%" + appName + "%");
    }
    if (StringUtils.isNotBlank(userId)) {
        eam.andUserNameLike("%" + userId + "%");
    }
    if (StringUtils.isNotBlank(type)) {
        eam.andServiceTypeLike("%" + type + "%");
    }
    if (StringUtils.isNotBlank(contenu)) {
        eam.andContenuLike("%" + contenu + "+");
    }
    if (queryDate1 != null) {
        eam.andCreateTimeGreaterThanOrEqualTo(queryDate1);
    }
    if (queryDate2 != null) {
        eam.andCreateTimeLessThanOrEqualTo(queryDate2);
    }
    Integer count = sqlSession.selectOne("com.itrus.portal.db.MobileLogmanagementLogMapper.countByExample", example);
    uiModel.addAttribute("count", count);
    if (page > 1 && size * (page - 1) >= count) {
        page = (count + size - 1) / size;
    }
    Integer offset = size * (page - 1);
    example.setOffset(offset);
    example.setLimit(size);
    example.setOrderByClause("create_time desc");
    List<MobileLogmanagementLog> logmanagementLogs = sqlSession.selectList("com.itrus.portal.db.MobileLogmanagementLogMapper.selectByExample", example);
    uiModel.addAttribute("logmanagementLogs", logmanagementLogs);
    uiModel.addAttribute("appName", appName);
    uiModel.addAttribute("userId", userId);
    uiModel.addAttribute("type", type);
    uiModel.addAttribute("contenu", contenu);
    uiModel.addAttribute("queryDate1", queryDate1);
    uiModel.addAttribute("queryDate2", queryDate2);
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    uiModel.addAttribute("size", size);
    return "mobileaffaireenregistrerlog/list";
}
Also used : MobileLogmanagementLogExample(com.itrus.portal.db.MobileLogmanagementLogExample) Calendar(java.util.Calendar) MobileLogmanagementLog(com.itrus.portal.db.MobileLogmanagementLog) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

MobileLogmanagementLog (com.itrus.portal.db.MobileLogmanagementLog)2 JSONObject (com.alibaba.fastjson.JSONObject)1 ApplicationInfo (com.itrus.portal.db.ApplicationInfo)1 MobileLogmanagementLogExample (com.itrus.portal.db.MobileLogmanagementLogExample)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1