Search in sources :

Example 6 with MobileCertificateExample

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

the class MobileCertificateService method selectById.

// 根据证书id查出对应的证书信息
public MobileCertificate selectById(Long id) {
    MobileCertificateExample certificateExample = new MobileCertificateExample();
    MobileCertificateExample.Criteria cfe = certificateExample.createCriteria();
    cfe.andIdEqualTo(id);
    MobileCertificate certificate = sqlSession.selectOne("com.itrus.portal.db.MobileCertificateMapper.selectByExample", certificateExample);
    return certificate;
}
Also used : MobileCertificate(com.itrus.portal.db.MobileCertificate) MobileCertificateExample(com.itrus.portal.db.MobileCertificateExample)

Example 7 with MobileCertificateExample

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

the class MobileWebSocketHandler method handleMessage.

@Override
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
    log.info("成功接收到消息");
    // 把客户端的消息解析为JSON对象
    if (message instanceof TextMessage) {
        // String appId =session.getAttributes().get("appId").toString();
        log.info("信息为:" + message.getPayload());
        // 针对ios系统做出的心跳处理
        if (message.getPayload().equals("heart")) {
            // 连云盾
            KeySegmentationTask.buildTask(session, message);
            return;
        }
        JSONObject msg = JSON.parseObject(message.getPayload().toString());
        try {
            if (msg.containsKey("certSn")) {
                log.error("签名");
                String deviceSerialNumber = msg.get("certSn").toString();
                log.error(deviceSerialNumber);
                MobileCertificateExample certificateExample = new MobileCertificateExample();
                MobileCertificateExample.Criteria criteria = certificateExample.createCriteria();
                criteria.andSequenceNumberEqualTo(deviceSerialNumber);
                MobileCertificate certificate = mobileCertificateService.selectByExample(certificateExample);
                log.error("" + certificate);
                log.error(" -------------------------------------------------------------");
                if (certificate != null) {
                    Long uId = certificate.getUserId();
                    MobileUser mobileUser = mobileUserService.selectMobileUserById(uId);
                    if (mobileUser != null) {
                        msg.put("uid", mobileUser.getUserId());
                    }
                }
                // System.out.println(mobileUser.getUserId());
                if (certificate.getLockStatus() == 1) {
                    // 如果锁定
                    // Map<String, Object> result=new HashMap<String,
                    // Object>();
                    // MobileApplyConfigManage
                    // applyConfigManage=mobileApplyConfigService.selectMobileApplyConfigManageById(certificate.getApplyConfigId());
                    msg.put("LockCause", certificate.getLockCause());
                    // msg.put("appId", appId);
                    msg.put("LockStatus", certificate.getLockStatus());
                    // result.put("PinTime", applyCo
                    // nfigManage.getPinTime());
                    session.sendMessage(new TextMessage(JSON.toJSONString(msg)));
                    return;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (msg.containsKey("service")) {
            /*
				 * service:certApply 申请证书移动端需要传过来的参数 1.设备信息 device
				 * equipmentCategory String 设备型号 appId Long 应用的名称
				 * operatingSystem String 操作系统 userId Long 和用户关联的字段 createTime
				 * date 创建时间 updateTime date 修改时间 deviceSerialNumber string
				 * 设备序列号 唯一标识 2.用户的信息 即 注册信息 user name String 用户姓名 phone String
				 * 手机号 idNumber String 身份证号 appId Long 和应用关联的字段 email String
				 * 电子邮件 registrationTime date 注册时间 createTime date 创建时间
				 * updateTime date 修改时间 userCod String 用户编码
				 */
            // msg.put("appId",msg );
            // msg.put("uid",mobileUser.getUserId());
            MobileService mobileService = SpringContextHolder.getBean(msg.getString("service"));
            Map<String, Object> result = mobileService.execute(msg.toJSONString());
            session.sendMessage(new TextMessage(JSON.toJSONString(result)));
            return;
        }
        // String deviceSerialNumber = msg.get("certSn").toString();
        // TextMessage msg = new TextMessage(session.getAttributes() +
        // "发送的数据"+message.getPayload());
        // this.handleTextMessage(session, (TextMessage)message);
        // 连云盾
        KeySegmentationTask.buildTask(session, message);
    } 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 : MobileCertificate(com.itrus.portal.db.MobileCertificate) MobileCertificateExample(com.itrus.portal.db.MobileCertificateExample) MobileUser(com.itrus.portal.db.MobileUser) JSONObject(com.alibaba.fastjson.JSONObject) JSONObject(com.alibaba.fastjson.JSONObject) MobileService(com.itrus.portal.mobile.service.MobileService)

Aggregations

MobileCertificate (com.itrus.portal.db.MobileCertificate)7 MobileCertificateExample (com.itrus.portal.db.MobileCertificateExample)7 Date (java.util.Date)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 Calendar (java.util.Calendar)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 JSONObject (com.alibaba.fastjson.JSONObject)1 MobileUser (com.itrus.portal.db.MobileUser)1 MobileService (com.itrus.portal.mobile.service.MobileService)1 ArrayList (java.util.ArrayList)1