forked from dyf/fys-Multi-tenant
提交
This commit is contained in:
@ -14,6 +14,7 @@ import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper;
|
||||
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
||||
import com.fuyuanshen.common.core.exception.ServiceException;
|
||||
import com.fuyuanshen.common.core.utils.*;
|
||||
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
@ -62,12 +63,10 @@ public class AppDeviceBJQBizService {
|
||||
if (device == null) {
|
||||
throw new ServiceException("设备不存在" + deviceId);
|
||||
}
|
||||
|
||||
try {
|
||||
ClassPathResource resource = new ClassPathResource("image/background.png");
|
||||
InputStream inputStream = resource.getInputStream();
|
||||
|
||||
// String backgroundImagePath = "D:\\background.png"; // 替换为实际背景图片路径
|
||||
byte[] largeData = ImageWithTextGenerate.generate160x80ImageWithText2(bo.getSendMsg(), inputStream, 25600);
|
||||
int[] ints = convertHexToDecimal(largeData);
|
||||
RedisUtils.setCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + ":app_send_message_data" , Arrays.toString(ints), Duration.ofSeconds(30 * 60L));
|
||||
@ -77,7 +76,6 @@ public class AppDeviceBJQBizService {
|
||||
byte[] arr = ImageToCArrayConverter.convertStringToByteArray(data);
|
||||
byte[] specificChunk = ImageToCArrayConverter.getChunk(arr, 0, 512);
|
||||
log.info("发送信息第0块数据大小: {} 字节",specificChunk.length);
|
||||
// log.info("第0块数据: {}", Arrays.toString(specificChunk));
|
||||
|
||||
ArrayList<Integer> intData = new ArrayList<>();
|
||||
intData.add(6);
|
||||
@ -167,6 +165,7 @@ public class AppDeviceBJQBizService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean registerPersonInfo(AppPersonnelInfoBo bo) {
|
||||
Long deviceId = bo.getDeviceId();
|
||||
Device deviceObj = deviceMapper.selectById(deviceId);
|
||||
@ -212,6 +211,7 @@ public class AppDeviceBJQBizService {
|
||||
|
||||
}
|
||||
|
||||
@FunctionAccessAnnotation("uploadDeviceLogo")
|
||||
public void uploadDeviceLogo(AppDeviceLogoUploadDto bo) {
|
||||
try {
|
||||
Device device = deviceMapper.selectById(bo.getDeviceId());
|
||||
@ -256,6 +256,7 @@ public class AppDeviceBJQBizService {
|
||||
* 灯光模式
|
||||
* 0(关灯),1(强光模式),2(弱光模式), 3(爆闪模式), 4(泛光模式)
|
||||
*/
|
||||
|
||||
public void lightModeSettings(DeviceInstructDto params) {
|
||||
try {
|
||||
Long deviceId = params.getDeviceId();
|
||||
@ -280,6 +281,7 @@ public class AppDeviceBJQBizService {
|
||||
}
|
||||
|
||||
//灯光亮度设置
|
||||
@FunctionAccessAnnotation("lightBrightnessSettings")
|
||||
public void lightBrightnessSettings(DeviceInstructDto params) {
|
||||
try {
|
||||
Long deviceId = params.getDeviceId();
|
||||
@ -312,6 +314,7 @@ public class AppDeviceBJQBizService {
|
||||
}
|
||||
|
||||
//激光模式设置
|
||||
@FunctionAccessAnnotation("laserModeSettings")
|
||||
public void laserModeSettings(DeviceInstructDto params) {
|
||||
try {
|
||||
Long deviceId = params.getDeviceId();
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
package com.fuyuanshen.app.service.device.status;
|
||||
|
||||
import com.fuyuanshen.app.domain.dto.AppRealTimeStatusDto;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
// 规则接口
|
||||
public interface DeviceStatusRule {
|
||||
|
||||
/**
|
||||
* 获取命令类型
|
||||
* @return 命令类型
|
||||
*/
|
||||
String getCommandType();
|
||||
|
||||
boolean supports(String deviceType);
|
||||
|
||||
Map<String, Object> getStatus(AppRealTimeStatusDto statusDto);
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.fuyuanshen.app.service.device.status.constants;
|
||||
|
||||
public class DeviceTypeConstants {
|
||||
public static final String TYPE_BJQ6170 = "BJQ6170";
|
||||
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
package com.fuyuanshen.app.service.device.status.jbq;
|
||||
|
||||
import com.fuyuanshen.app.domain.dto.AppRealTimeStatusDto;
|
||||
import com.fuyuanshen.app.service.device.status.DeviceStatusRule;
|
||||
import com.fuyuanshen.app.service.device.status.constants.DeviceTypeConstants;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AlarmStatusRule implements DeviceStatusRule {
|
||||
@Override
|
||||
public String getCommandType() {
|
||||
return DeviceTypeConstants.TYPE_BJQ6170+"_5";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(String deviceType) {
|
||||
return true; // 适用于所有设备类型
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getStatus(AppRealTimeStatusDto dto) {
|
||||
Map<String, Object> status = new HashMap<>();
|
||||
String functionAccess = RedisUtils.getCacheObject(
|
||||
|
||||
FUNCTION_ACCESS_KEY + dto.getDeviceImei());
|
||||
if(functionAccess==null){
|
||||
status.put("functionAccess", "OK");
|
||||
}else{
|
||||
status.put("functionAccess", "ACTIVE");
|
||||
}
|
||||
//
|
||||
|
||||
// String alarmStatus = RedisUtils.getCacheObject(
|
||||
// GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + dto.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX);
|
||||
//
|
||||
// if (StringUtils.isNotBlank(alarmStatus)) {
|
||||
// status.put("alarmStatus", alarmStatus);
|
||||
// }
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package com.fuyuanshen.app.service.device.status.jbq;
|
||||
|
||||
import com.fuyuanshen.app.domain.dto.AppRealTimeStatusDto;
|
||||
import com.fuyuanshen.app.service.device.status.DeviceStatusRule;
|
||||
import com.fuyuanshen.app.service.device.status.constants.DeviceTypeConstants;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
|
||||
|
||||
// 上传开机图片
|
||||
@Slf4j
|
||||
@Component
|
||||
public class BootLogoStatusRule implements DeviceStatusRule {
|
||||
@Override
|
||||
public String getCommandType() {
|
||||
return DeviceTypeConstants.TYPE_BJQ6170+"_3";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(String deviceType) {
|
||||
return true; // 适用于所有设备类型
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getStatus(AppRealTimeStatusDto dto) {
|
||||
Map<String, Object> status = new HashMap<>();
|
||||
String functionAccess = RedisUtils.getCacheObject(
|
||||
FUNCTION_ACCESS_KEY + dto.getDeviceImei());
|
||||
if(functionAccess==null){
|
||||
status.put("functionAccess", "OK");
|
||||
}else{
|
||||
status.put("functionAccess", "ACTIVE");
|
||||
}
|
||||
// String location = RedisUtils.getCacheObject(
|
||||
// GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + dto.getDeviceImei() + DEVICE_LOCATION_KEY_PREFIX);
|
||||
//
|
||||
// if (StringUtils.isNotBlank(location)) {
|
||||
// JSONObject jsonObject = JSONObject.parseObject(location);
|
||||
// status.put("latitude", jsonObject.getString("latitude"));
|
||||
// status.put("longitude", jsonObject.getString("longitude"));
|
||||
// }
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package com.fuyuanshen.app.service.device.status.jbq;
|
||||
|
||||
import com.fuyuanshen.app.domain.dto.AppRealTimeStatusDto;
|
||||
import com.fuyuanshen.app.service.device.status.DeviceStatusRule;
|
||||
import com.fuyuanshen.app.service.device.status.constants.DeviceTypeConstants;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
|
||||
|
||||
// 激光模式设置
|
||||
@Slf4j
|
||||
@Component
|
||||
public class LaserModeSettingsStatusRule implements DeviceStatusRule {
|
||||
@Override
|
||||
public String getCommandType() {
|
||||
return DeviceTypeConstants.TYPE_BJQ6170+"_2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(String deviceType) {
|
||||
return true; // 适用于所有设备类型
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getStatus(AppRealTimeStatusDto dto) {
|
||||
Map<String, Object> status = new HashMap<>();
|
||||
String functionAccess = RedisUtils.getCacheObject(
|
||||
FUNCTION_ACCESS_KEY + dto.getDeviceImei());
|
||||
if(functionAccess==null){
|
||||
status.put("functionAccess", "OK");
|
||||
}else{
|
||||
status.put("functionAccess", "ACTIVE");
|
||||
}
|
||||
// String onlineStatus = RedisUtils.getCacheObject(
|
||||
// GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + dto.getDeviceImei() + DEVICE_ONLINE_STATUS_KEY_PREFIX);
|
||||
// status.put("onlineStatus", StringUtils.isNotBlank(onlineStatus) ? 1 : 0);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package com.fuyuanshen.app.service.device.status.jbq;
|
||||
|
||||
import com.fuyuanshen.app.domain.dto.AppRealTimeStatusDto;
|
||||
import com.fuyuanshen.app.service.device.status.DeviceStatusRule;
|
||||
import com.fuyuanshen.app.service.device.status.constants.DeviceTypeConstants;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
|
||||
|
||||
// 灯光状态
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ModeStatusRule implements DeviceStatusRule {
|
||||
|
||||
@Override
|
||||
public String getCommandType() {
|
||||
return DeviceTypeConstants.TYPE_BJQ6170+"_1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(String deviceType) {
|
||||
return true; // 适用于所有设备类型
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getStatus(AppRealTimeStatusDto dto) {
|
||||
Map<String, Object> status = new HashMap<>();
|
||||
String functionAccess = RedisUtils.getCacheObject(
|
||||
FUNCTION_ACCESS_KEY + dto.getDeviceImei());
|
||||
status.put("functionAccess", functionAccess);
|
||||
// String deviceStatus = RedisUtils.getCacheObject(
|
||||
// GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + dto.getDeviceImei() + DEVICE_STATUS_KEY_PREFIX);
|
||||
//
|
||||
// if (StringUtils.isNotBlank(deviceStatus)) {
|
||||
// JSONObject jsonObject = JSONObject.parseObject(deviceStatus);
|
||||
// status.put("battery", jsonObject.getString("batteryPercentage"));
|
||||
// } else {
|
||||
// status.put("battery", "0");
|
||||
// }
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package com.fuyuanshen.app.service.device.status.jbq;
|
||||
|
||||
import com.fuyuanshen.app.domain.dto.AppRealTimeStatusDto;
|
||||
import com.fuyuanshen.app.service.device.status.DeviceStatusRule;
|
||||
import com.fuyuanshen.app.service.device.status.constants.DeviceTypeConstants;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class RegisterPersonInfoStatusRule implements DeviceStatusRule {
|
||||
@Override
|
||||
public String getCommandType() {
|
||||
return DeviceTypeConstants.TYPE_BJQ6170+"_4";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(String deviceType) {
|
||||
return true; // 适用于所有设备类型
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getStatus(AppRealTimeStatusDto dto) {
|
||||
Map<String, Object> status = new HashMap<>();
|
||||
String functionAccess = RedisUtils.getCacheObject(
|
||||
FUNCTION_ACCESS_KEY + dto.getDeviceImei());
|
||||
if(functionAccess==null){
|
||||
status.put("functionAccess", "OK");
|
||||
}else{
|
||||
status.put("functionAccess", "ACTIVE");
|
||||
}
|
||||
// String alarmStatus = RedisUtils.getCacheObject(
|
||||
// GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + dto.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX);
|
||||
//
|
||||
// if (StringUtils.isNotBlank(alarmStatus)) {
|
||||
// status.put("alarmStatus", alarmStatus);
|
||||
// }
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package com.fuyuanshen.app.service.device.status.jbq;
|
||||
|
||||
import com.fuyuanshen.app.domain.dto.AppRealTimeStatusDto;
|
||||
import com.fuyuanshen.app.service.device.status.DeviceStatusRule;
|
||||
import com.fuyuanshen.app.service.device.status.constants.DeviceTypeConstants;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SendMessageStatusRule implements DeviceStatusRule {
|
||||
@Override
|
||||
public String getCommandType() {
|
||||
return DeviceTypeConstants.TYPE_BJQ6170+"_6";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(String deviceType) {
|
||||
return true; // 适用于所有设备类型
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getStatus(AppRealTimeStatusDto dto) {
|
||||
Map<String, Object> status = new HashMap<>();
|
||||
List<String> functionAccess = RedisUtils.getCacheObject(
|
||||
FUNCTION_ACCESS_KEY + dto.getBatchId());
|
||||
if(functionAccess==null){
|
||||
status.put("functionAccess", "OK");
|
||||
}else{
|
||||
status.put("functionAccess", "ACTIVE");
|
||||
}
|
||||
// String alarmStatus = RedisUtils.getCacheObject(
|
||||
// GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + dto.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX);
|
||||
//
|
||||
// if (StringUtils.isNotBlank(alarmStatus)) {
|
||||
// status.put("alarmStatus", alarmStatus);
|
||||
// }
|
||||
return status;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user