use of com.itrus.portal.db.MobileUser 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);
}
}
Aggregations