Compare commits
5 Commits
f2d74b8f17
...
dyf-device
| Author | SHA1 | Date | |
|---|---|---|---|
| ca11ef0e35 | |||
| ef2dc6a6f6 | |||
| dff37b245a | |||
| d7c4d22de3 | |||
| 6a058318f2 |
@ -15,11 +15,14 @@ import org.springframework.messaging.MessageHandler;
|
|||||||
@Configuration
|
@Configuration
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class MqttOutboundConfiguration {
|
public class MqttOutboundConfiguration {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MqttPropertiesConfig mqttPropertiesConfig;
|
private MqttPropertiesConfig mqttPropertiesConfig;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MqttPahoClientFactory mqttPahoClientFactory;
|
private MqttPahoClientFactory mqttPahoClientFactory;
|
||||||
|
|
||||||
|
|
||||||
// 消息通道
|
// 消息通道
|
||||||
@Bean
|
@Bean
|
||||||
public MessageChannel mqttOutboundChannel(){
|
public MessageChannel mqttOutboundChannel(){
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.fuyuanshen.global.mqtt.constants;
|
package com.fuyuanshen.global.mqtt.constants;
|
||||||
|
|
||||||
public class DeviceRedisKeyConstants {
|
public class DeviceRedisKeyConstants {
|
||||||
|
|
||||||
public static final String DEVICE_KEY_PREFIX = "device:";
|
public static final String DEVICE_KEY_PREFIX = "device:";
|
||||||
// 设备上报状态
|
// 设备上报状态
|
||||||
public static final String DEVICE_STATUS_KEY_PREFIX = ":status";
|
public static final String DEVICE_STATUS_KEY_PREFIX = ":status";
|
||||||
@ -52,4 +53,5 @@ public class DeviceRedisKeyConstants {
|
|||||||
* 告警信息
|
* 告警信息
|
||||||
*/
|
*/
|
||||||
public static final String DEVICE_ALARM_MESSAGE_KEY_PREFIX = ":alarmMessage";
|
public static final String DEVICE_ALARM_MESSAGE_KEY_PREFIX = ":alarmMessage";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,6 @@ public class LightingCommandTypeConstants {
|
|||||||
*/
|
*/
|
||||||
public static final String SEND_MESSAGE = "Light_6";
|
public static final String SEND_MESSAGE = "Light_6";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报警模式
|
* 报警模式
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -57,12 +57,12 @@ public class BjqAlarmRule implements MqttMessageRule {
|
|||||||
if (StringUtils.isNotBlank(convertValue)) {
|
if (StringUtils.isNotBlank(convertValue)) {
|
||||||
// 将设备状态信息存储到Redis中
|
// 将设备状态信息存储到Redis中
|
||||||
String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + context.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX;
|
String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + context.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX;
|
||||||
String sendMessageIng = GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + context.getDeviceImei() + ":messageSending";
|
String sendMessageIng = GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + context.getDeviceImei() + ":messageSending";
|
||||||
if ("1".equals(convertValue)) {
|
if ("1".equals(convertValue)) {
|
||||||
RedisUtils.setCacheObject(sendMessageIng, "1", Duration.ofDays(1));
|
RedisUtils.setCacheObject(sendMessageIng, "1", Duration.ofDays(1));
|
||||||
// 存储到Redis
|
// 存储到Redis
|
||||||
RedisUtils.setCacheObject(deviceRedisKey, "1");
|
RedisUtils.setCacheObject(deviceRedisKey, "1");
|
||||||
}else if ("0".equals(convertValue)){
|
} else if ("0".equals(convertValue)) {
|
||||||
RedisUtils.deleteObject(sendMessageIng);
|
RedisUtils.deleteObject(sendMessageIng);
|
||||||
RedisUtils.deleteObject(deviceRedisKey);
|
RedisUtils.deleteObject(deviceRedisKey);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,5 +71,4 @@ public class BjqLaserModeSettingsRule implements MqttMessageRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,6 +45,7 @@ public class BjqModeRule implements MqttMessageRule {
|
|||||||
return LightingCommandTypeConstants.LIGHT_MODE;
|
return LightingCommandTypeConstants.LIGHT_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(MqttRuleContext context) {
|
public void execute(MqttRuleContext context) {
|
||||||
String functionAccess = FUNCTION_ACCESS_KEY + context.getDeviceImei();
|
String functionAccess = FUNCTION_ACCESS_KEY + context.getDeviceImei();
|
||||||
|
|||||||
@ -1,32 +1,18 @@
|
|||||||
package com.fuyuanshen.global.mqtt.rule.bjq;
|
package com.fuyuanshen.global.mqtt.rule.bjq;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
|
||||||
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
|
||||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
|
||||||
import com.fuyuanshen.common.json.utils.JsonUtils;
|
|
||||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||||
import com.fuyuanshen.equipment.utils.map.GetAddressFromLatUtil;
|
|
||||||
import com.fuyuanshen.equipment.utils.map.LngLonUtil;
|
|
||||||
import com.fuyuanshen.global.mqtt.base.MqttMessageRule;
|
import com.fuyuanshen.global.mqtt.base.MqttMessageRule;
|
||||||
import com.fuyuanshen.global.mqtt.base.MqttRuleContext;
|
import com.fuyuanshen.global.mqtt.base.MqttRuleContext;
|
||||||
import com.fuyuanshen.global.mqtt.config.MqttGateway;
|
import com.fuyuanshen.global.mqtt.config.MqttGateway;
|
||||||
import com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants;
|
|
||||||
import com.fuyuanshen.global.mqtt.constants.LightingCommandTypeConstants;
|
import com.fuyuanshen.global.mqtt.constants.LightingCommandTypeConstants;
|
||||||
import com.fuyuanshen.global.mqtt.constants.MqttConstants;
|
|
||||||
import com.fuyuanshen.global.mqtt.listener.domain.FunctionAccessStatus;
|
import com.fuyuanshen.global.mqtt.listener.domain.FunctionAccessStatus;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
|
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
|
||||||
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定位数据命令处理
|
* 定位数据命令处理
|
||||||
@ -55,4 +41,5 @@ public class BjqPersonnelInfoDataRule implements MqttMessageRule {
|
|||||||
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.FAILED.getCode(), Duration.ofSeconds(30));
|
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.FAILED.getCode(), Duration.ofSeconds(30));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,7 @@ public class MqttMessageConsumer {
|
|||||||
private ExecutorService messageConsumerPool = Executors.newFixedThreadPool(3);
|
private ExecutorService messageConsumerPool = Executors.newFixedThreadPool(3);
|
||||||
private ExecutorService messageProcessorPool = Executors.newFixedThreadPool(10);
|
private ExecutorService messageProcessorPool = Executors.newFixedThreadPool(10);
|
||||||
|
|
||||||
|
|
||||||
// 初始化方法,启动消息监听
|
// 初始化方法,启动消息监听
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void start() {
|
public void start() {
|
||||||
@ -130,4 +131,5 @@ public class MqttMessageConsumer {
|
|||||||
log.error("业务处理线程 {} 处理消息时发生错误: {}", threadName, message, e);
|
log.error("业务处理线程 {} 处理消息时发生错误: {}", threadName, message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,8 @@ public class OnlineStatusTask {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceMapper deviceMapper;
|
private DeviceMapper deviceMapper;
|
||||||
|
|
||||||
|
|
||||||
// 使用cron表达式,每分钟的第0秒执行
|
// 使用cron表达式,每分钟的第0秒执行
|
||||||
@Scheduled(cron = "0 */3 * * * ?")
|
@Scheduled(cron = "0 */3 * * * ?")
|
||||||
public void cronTask() {
|
public void cronTask() {
|
||||||
@ -37,4 +39,5 @@ public class OnlineStatusTask {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,6 +98,7 @@ public class DeviceControlCenterController extends BaseController {
|
|||||||
return R.ok(appDeviceService.getDeviceInfo(deviceMac));
|
return R.ok(appDeviceService.getDeviceInfo(deviceMac));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 指令下发记录
|
* 指令下发记录
|
||||||
*/
|
*/
|
||||||
@ -106,6 +107,7 @@ public class DeviceControlCenterController extends BaseController {
|
|||||||
return appDeviceService.getInstructionRecord(dto, pageQuery);
|
return appDeviceService.getInstructionRecord(dto, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出
|
* 导出
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -739,6 +739,7 @@ public class DeviceXinghanBizService {
|
|||||||
device.setCreateByName(loginUser.getNickname());
|
device.setCreateByName(loginUser.getNickname());
|
||||||
device.setTypeName(deviceTypes.getTypeName());
|
device.setTypeName(deviceTypes.getTypeName());
|
||||||
device.setDeviceType(deviceTypes.getId());
|
device.setDeviceType(deviceTypes.getId());
|
||||||
|
device.setDevicePic(deviceTypes.getDevicePic());
|
||||||
if (device.getDeviceImei() != null) {
|
if (device.getDeviceImei() != null) {
|
||||||
device.setPubTopic("A/" + device.getDeviceImei());
|
device.setPubTopic("A/" + device.getDeviceImei());
|
||||||
device.setSubTopic("B/" + device.getDeviceImei());
|
device.setSubTopic("B/" + device.getDeviceImei());
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,7 +51,7 @@ public class DeviceTypeController {
|
|||||||
// @Log("新增设备类型")
|
// @Log("新增设备类型")
|
||||||
@Operation(summary = "新增设备类型")
|
@Operation(summary = "新增设备类型")
|
||||||
@PostMapping(value = "/add")
|
@PostMapping(value = "/add")
|
||||||
public R<Void> createDeviceType(@Validated @RequestBody DeviceType resources) {
|
public R<Void> createDeviceType(@Validated @ModelAttribute DeviceTypeForm resources) throws IOException {
|
||||||
deviceTypeService.create(resources);
|
deviceTypeService.create(resources);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
@ -59,7 +60,7 @@ public class DeviceTypeController {
|
|||||||
// @Log("修改设备类型")
|
// @Log("修改设备类型")
|
||||||
@Operation(summary = "修改设备类型")
|
@Operation(summary = "修改设备类型")
|
||||||
@PutMapping(value = "/update")
|
@PutMapping(value = "/update")
|
||||||
public R<Void> updateDeviceType(@Validated @RequestBody DeviceTypeForm resources) {
|
public R<Void> updateDeviceType(@Validated @ModelAttribute DeviceTypeForm resources) throws IOException {
|
||||||
deviceTypeService.update(resources);
|
deviceTypeService.update(resources);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
@ -79,7 +80,6 @@ public class DeviceTypeController {
|
|||||||
public R<DeviceType> getCommunicationMode(@Parameter(name = "设备类型ID", required = true) Long id) {
|
public R<DeviceType> getCommunicationMode(@Parameter(name = "设备类型ID", required = true) Long id) {
|
||||||
DeviceType communicationMode = deviceTypeService.getCommunicationMode(id);
|
DeviceType communicationMode = deviceTypeService.getCommunicationMode(id);
|
||||||
return R.ok(communicationMode);
|
return R.ok(communicationMode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,5 +85,8 @@ public class DeviceType extends TenantEntity {
|
|||||||
@Schema(title = "型号字典用于PC页面跳转")
|
@Schema(title = "型号字典用于PC页面跳转")
|
||||||
private String pcModelDictionary;
|
private String pcModelDictionary;
|
||||||
|
|
||||||
|
@Schema(title = "设备图片")
|
||||||
|
private String devicePic;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.fuyuanshen.equipment.domain.form;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 设备类型
|
* @Description: 设备类型
|
||||||
@ -48,5 +49,10 @@ public class DeviceTypeForm {
|
|||||||
*/
|
*/
|
||||||
@Schema(title = "型号字典用于PC页面跳转")
|
@Schema(title = "型号字典用于PC页面跳转")
|
||||||
private String pcModelDictionary;
|
private String pcModelDictionary;
|
||||||
|
@Schema(title = "设备图片")
|
||||||
|
private String devicePic;
|
||||||
|
|
||||||
|
@Schema(title = "设备图片")
|
||||||
|
private MultipartFile file;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import com.fuyuanshen.equipment.domain.DeviceType;
|
|||||||
import com.fuyuanshen.equipment.domain.dto.DeviceExcelImportDTO;
|
import com.fuyuanshen.equipment.domain.dto.DeviceExcelImportDTO;
|
||||||
import com.fuyuanshen.equipment.domain.dto.ImportResult;
|
import com.fuyuanshen.equipment.domain.dto.ImportResult;
|
||||||
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
||||||
|
import com.fuyuanshen.equipment.domain.form.DeviceTypeForm;
|
||||||
import com.fuyuanshen.equipment.handler.ImageWriteHandler;
|
import com.fuyuanshen.equipment.handler.ImageWriteHandler;
|
||||||
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -437,8 +438,10 @@ public class UploadDeviceDataListener implements ReadListener<DeviceExcelImportD
|
|||||||
newDeviceType.setAppModelDictionary(originalDto.getAppModelDictionary());
|
newDeviceType.setAppModelDictionary(originalDto.getAppModelDictionary());
|
||||||
newDeviceType.setPcModelDictionary(originalDto.getPcModelDictionary());
|
newDeviceType.setPcModelDictionary(originalDto.getPcModelDictionary());
|
||||||
|
|
||||||
|
DeviceTypeForm deviceTypeForm = new DeviceTypeForm();
|
||||||
|
BeanUtil.copyProperties(newDeviceType, deviceTypeForm, true);
|
||||||
// 创建新的设备类型
|
// 创建新的设备类型
|
||||||
params.getDeviceTypeService().create(newDeviceType);
|
params.getDeviceTypeService().create(deviceTypeForm);
|
||||||
|
|
||||||
// 重新查询确保获取到正确的ID
|
// 重新查询确保获取到正确的ID
|
||||||
deviceType = params.getDeviceTypeService().queryByName(device.getTypeName());
|
deviceType = params.getDeviceTypeService().queryByName(device.getTypeName());
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import com.fuyuanshen.equipment.domain.DeviceType;
|
|||||||
import com.fuyuanshen.equipment.domain.form.DeviceTypeForm;
|
import com.fuyuanshen.equipment.domain.form.DeviceTypeForm;
|
||||||
import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria;
|
import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,14 +64,14 @@ public interface DeviceTypeService extends IService<DeviceType> {
|
|||||||
*
|
*
|
||||||
* @param resources /
|
* @param resources /
|
||||||
*/
|
*/
|
||||||
void create(DeviceType resources);
|
void create(DeviceTypeForm resources) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改设备类型
|
* 修改设备类型
|
||||||
*
|
*
|
||||||
* @param resources /
|
* @param resources /
|
||||||
*/
|
*/
|
||||||
void update(DeviceTypeForm resources);
|
void update(DeviceTypeForm resources) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多选删除
|
* 多选删除
|
||||||
|
|||||||
@ -19,12 +19,16 @@ import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
|||||||
import com.fuyuanshen.equipment.mapper.DeviceTypeGrantsMapper;
|
import com.fuyuanshen.equipment.mapper.DeviceTypeGrantsMapper;
|
||||||
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
||||||
import com.fuyuanshen.equipment.service.DeviceTypeService;
|
import com.fuyuanshen.equipment.service.DeviceTypeService;
|
||||||
|
import com.fuyuanshen.equipment.utils.FileHashUtil;
|
||||||
|
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
||||||
import com.fuyuanshen.system.domain.vo.SysRoleVo;
|
import com.fuyuanshen.system.domain.vo.SysRoleVo;
|
||||||
|
import com.fuyuanshen.system.service.ISysOssService;
|
||||||
import com.fuyuanshen.system.service.ISysRoleService;
|
import com.fuyuanshen.system.service.ISysRoleService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -46,6 +50,8 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
private final DeviceAssignmentsMapper deviceAssignmentsMapper;
|
private final DeviceAssignmentsMapper deviceAssignmentsMapper;
|
||||||
|
|
||||||
private final ISysRoleService roleService;
|
private final ISysRoleService roleService;
|
||||||
|
private final ISysOssService ossService;
|
||||||
|
private final FileHashUtil fileHashUtil;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -181,24 +187,38 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void create(DeviceType resources) {
|
public void create(DeviceTypeForm resources) throws IOException {
|
||||||
|
|
||||||
// 校验设备类型名称
|
// 校验设备类型名称
|
||||||
List<DeviceType> typeName = deviceTypeMapper.selectList(new QueryWrapper<DeviceType>().eq("type_name", resources.getTypeName()));
|
List<DeviceType> typeName = deviceTypeMapper.selectList(new QueryWrapper<DeviceType>().eq("type_name", resources.getTypeName()));
|
||||||
if (CollectionUtil.isNotEmpty(typeName)) {
|
if (CollectionUtil.isNotEmpty(typeName)) {
|
||||||
throw new RuntimeException("设备类型名称已存在,无法新增!!!");
|
throw new RuntimeException("设备类型名称已存在,无法新增!!!");
|
||||||
}
|
}
|
||||||
|
// 保存图片并获取URL
|
||||||
|
if (resources.getFile() != null) {
|
||||||
|
String fileHash = fileHashUtil.hash(resources.getFile());
|
||||||
|
SysOssVo upload = ossService.updateHash(resources.getFile(), fileHash);
|
||||||
|
// 强制将HTTP替换为HTTPS
|
||||||
|
if (upload.getUrl() != null && upload.getUrl().startsWith("http://")) {
|
||||||
|
upload.setUrl(upload.getUrl().replaceFirst("^http://", "https://"));
|
||||||
|
}
|
||||||
|
// 设置图片路径
|
||||||
|
resources.setDevicePic(upload.getUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceType deviceType = new DeviceType();
|
||||||
|
BeanUtil.copyProperties(resources, deviceType, true);
|
||||||
|
|
||||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||||
resources.setCustomerId(loginUser.getUserId());
|
deviceType.setCustomerId(loginUser.getUserId());
|
||||||
resources.setOwnerCustomerId(loginUser.getUserId());
|
deviceType.setOwnerCustomerId(loginUser.getUserId());
|
||||||
resources.setOriginalOwnerId(loginUser.getUserId());
|
deviceType.setOriginalOwnerId(loginUser.getUserId());
|
||||||
resources.setCreateByName(loginUser.getNickname());
|
deviceType.setCreateByName(loginUser.getNickname());
|
||||||
deviceTypeMapper.insert(resources);
|
deviceTypeMapper.insert(deviceType);
|
||||||
|
|
||||||
// 自动授权给自己
|
// 自动授权给自己
|
||||||
DeviceTypeGrants deviceTypeGrants = new DeviceTypeGrants();
|
DeviceTypeGrants deviceTypeGrants = new DeviceTypeGrants();
|
||||||
deviceTypeGrants.setDeviceTypeId(resources.getId());
|
deviceTypeGrants.setDeviceTypeId(deviceType.getId());
|
||||||
deviceTypeGrants.setCustomerId(loginUser.getUserId());
|
deviceTypeGrants.setCustomerId(loginUser.getUserId());
|
||||||
deviceTypeGrants.setGrantorCustomerId(loginUser.getUserId());
|
deviceTypeGrants.setGrantorCustomerId(loginUser.getUserId());
|
||||||
deviceTypeGrants.setGrantedAt(new Date());
|
deviceTypeGrants.setGrantedAt(new Date());
|
||||||
@ -213,7 +233,7 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(DeviceTypeForm resources) {
|
public void update(DeviceTypeForm resources) throws IOException {
|
||||||
DeviceTypeGrants deviceTypeGrants = deviceTypeGrantsMapper.selectById(resources.getId());
|
DeviceTypeGrants deviceTypeGrants = deviceTypeGrantsMapper.selectById(resources.getId());
|
||||||
if (deviceTypeGrants == null) {
|
if (deviceTypeGrants == null) {
|
||||||
throw new RuntimeException("设备类型不存在");
|
throw new RuntimeException("设备类型不存在");
|
||||||
@ -224,22 +244,13 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
throw new RuntimeException("设备类型不存在");
|
throw new RuntimeException("设备类型不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!deviceType.getTypeName().equals(resources.getTypeName())) {
|
if (!deviceType.getTypeName().equals(resources.getTypeName())) {
|
||||||
int count = deviceMapper.countByDeviceTypeId(deviceType.getId());
|
int count = deviceMapper.countByDeviceTypeId(deviceType.getId());
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
throw new RuntimeException("该设备类型下已有绑定设备,无法修改设备类型名称!!!");
|
throw new RuntimeException("该设备类型下已有设备,无法修改设备类型名称!!!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// List<Device> devices = deviceMapper.selectList(new QueryWrapper<Device>()
|
|
||||||
// .eq("device_type", deviceTypeGrants.getDeviceTypeId()));
|
|
||||||
// if (CollectionUtil.isNotEmpty(devices)) {
|
|
||||||
// throw new RuntimeException("该设备类型已绑定设备,无法修改!!!");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 校验设备类型名称
|
// 校验设备类型名称
|
||||||
DeviceType dt = deviceTypeMapper.selectOne(new QueryWrapper<DeviceType>().eq("type_name", resources.getTypeName()));
|
DeviceType dt = deviceTypeMapper.selectOne(new QueryWrapper<DeviceType>().eq("type_name", resources.getTypeName()));
|
||||||
if (dt != null && !dt.getId().equals(deviceType.getId())) {
|
if (dt != null && !dt.getId().equals(deviceType.getId())) {
|
||||||
@ -253,6 +264,17 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
throw new RuntimeException("无权修改该设备类型");
|
throw new RuntimeException("无权修改该设备类型");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 保存图片并获取URL
|
||||||
|
if (resources.getFile() != null) {
|
||||||
|
String fileHash = fileHashUtil.hash(resources.getFile());
|
||||||
|
SysOssVo upload = ossService.updateHash(resources.getFile(), fileHash);
|
||||||
|
// 强制将HTTP替换为HTTPS
|
||||||
|
if (upload.getUrl() != null && upload.getUrl().startsWith("http://")) {
|
||||||
|
upload.setUrl(upload.getUrl().replaceFirst("^http://", "https://"));
|
||||||
|
}
|
||||||
|
// 设置图片路径
|
||||||
|
resources.setDevicePic(upload.getUrl());
|
||||||
|
}
|
||||||
|
|
||||||
BeanUtil.copyProperties(resources, deviceType);
|
BeanUtil.copyProperties(resources, deviceType);
|
||||||
deviceTypeMapper.updateById(deviceType);
|
deviceTypeMapper.updateById(deviceType);
|
||||||
|
|||||||
@ -13,8 +13,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
a.content,
|
a.content,
|
||||||
a.create_time AS createTime
|
a.create_time AS createTime
|
||||||
FROM
|
FROM
|
||||||
device_log a left join device b on a.device_id = b.id
|
device_log a inner join device b on a.device_id = b.id
|
||||||
left join device_type c on b.device_type = c.id
|
inner join device_type c on b.device_type = c.id
|
||||||
WHERE 1 = 1
|
WHERE 1 = 1
|
||||||
<if test="bo.deviceType != null">
|
<if test="bo.deviceType != null">
|
||||||
AND c.id = #{bo.deviceType}
|
AND c.id = #{bo.deviceType}
|
||||||
|
|||||||
Reference in New Issue
Block a user