| | |
| | | if (StringUtils.isEmpty(ser.getCompanyId())) { |
| | | ser.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | if (StringUtils.isEmpty(ser.getDeptId())) { |
| | | ser.setDeptId(ContextUtil.subDeptId(null)); |
| | | |
| | | //判断接口路径 |
| | | if (StringUtils.isEmpty(ser.getPlateNumUrl())) { |
| | | ser.setPlateNumUrl("/open/api/get-plateNum"); |
| | | } |
| | | if (StringUtils.isEmpty(ser.getPlayUrl())) { |
| | | ser.setPlayUrl("/open/api/get-media"); |
| | | } |
| | | if (StringUtils.isEmpty(ser.getSnapUrl())) { |
| | | ser.setSnapUrl("/open/api/snap-img"); |
| | | } |
| | | if (StringUtils.isEmpty(ser.getPtzUrl())) { |
| | | ser.setPtzUrl("/open/api/ptz-media"); |
| | | } |
| | | |
| | | ser.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | ser.setUpdateTime(new Date()); |
| | | if (StringUtils.isBlank(ser.getCreateBy())) { |
| | | ser.setHeartbeatTime(new Date()); |
| | | ser.setCreateBy(ContextUtil.getLoginUserName()); |
| | | ser.setCreateTime(new Date()); |
| | | gatewaySerMapper.insert(ser); |
| | |
| | | /** |
| | | * 根据分机ID获取分机信息 |
| | | * |
| | | * @param deptId |
| | | * @return |
| | | */ |
| | | public GatewaySer getCacheSerByDeptId(String deptId) { |
| | | if (StringUtils.isEmpty(deptId)) { |
| | | return null; |
| | | } |
| | | |
| | | String patten = RedisConst.buildKey(ContextUtil.getCompanyId(), RedisConst.KEY_GATEWAY_SER_LIST) + "*"; |
| | | Collection<String> keys = redisCache.keys(patten); |
| | | if (null == keys) { |
| | | return null; |
| | | } |
| | | |
| | | GatewaySer ser = null; |
| | | for (String key : keys) { |
| | | ser = (GatewaySer) redisCache.getCacheObject(key); |
| | | if(deptId.equals(ser.getDeptId())){ |
| | | return ser; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 根据分机ID获取分机信息 |
| | | * |
| | | * @param companyId |
| | | * @param id |
| | | * @return |
| | |
| | | if (StringUtils.isEmpty(companyId)) { |
| | | companyId = ContextUtil.getCompanyId(); |
| | | } |
| | | String patten = RedisConst.buildKey(companyId, RedisConst.KEY_DEVICE_SER_LIST) + "*"; |
| | | Collection<String> keys = redisCache.keys(patten); |
| | | if (null == keys) { |
| | | return null; |
| | | } |
| | | |
| | | GatewaySer result = null; |
| | | GatewaySer ser = null; |
| | | for (String key : keys) { |
| | | ser = (GatewaySer) redisCache.getCacheObject(key); |
| | | if(id.equals(ser.getId())){ |
| | | break; |
| | | String patten = RedisConst.buildKey(companyId, RedisConst.KEY_GATEWAY_SER_LIST) + "*"; |
| | | Collection<String> keys = redisCache.keys(patten); |
| | | if (null != keys && !keys.isEmpty()) { |
| | | for (String key : keys) { |
| | | ser = (GatewaySer) redisCache.getCacheObject(key); |
| | | if(id.equals(ser.getId())){ |
| | | result = ser; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(null == ser){ |
| | | ser = getById(id); |
| | | this.setCacheSer(ser); |
| | | if(null == result){ |
| | | result = getById(id); |
| | | this.setCacheSer(result); |
| | | } |
| | | |
| | | return ser; |
| | | return result; |
| | | } |
| | | |
| | | /** |