forked from dyf/fys-Multi-tenant
merge upstream
This commit is contained in:
@ -0,0 +1,119 @@
|
||||
package com.fuyuanshen.web.controller.device;
|
||||
|
||||
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo;
|
||||
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
|
||||
import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
|
||||
import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
|
||||
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
|
||||
import com.fuyuanshen.web.service.device.DeviceBJQBizService;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* BJQ6170设备控制类
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/api/bjq/device")
|
||||
public class DeviceBJQController extends BaseController {
|
||||
|
||||
private final DeviceBJQBizService appDeviceService;
|
||||
|
||||
/**
|
||||
* 获取设备详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R<AppDeviceDetailVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(appDeviceService.getInfo(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 人员信息登记
|
||||
*/
|
||||
@PostMapping(value = "/registerPersonInfo")
|
||||
// @FunctionAccessAnnotation("registerPersonInfo")
|
||||
public R<Void> registerPersonInfo(@Validated(AddGroup.class) @RequestBody AppPersonnelInfoBo bo) {
|
||||
return toAjax(appDeviceService.registerPersonInfo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送信息
|
||||
*/
|
||||
@PostMapping(value = "/sendMessage")
|
||||
@FunctionAccessBatcAnnotation(value = "sendMessage", timeOut = 30, batchMaxTimeOut = 40)
|
||||
public R<Void> sendMessage(@RequestBody AppDeviceSendMsgBo bo) {
|
||||
return toAjax(appDeviceService.sendMessage(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送报警信息
|
||||
*/
|
||||
@PostMapping(value = "/sendAlarmMessage")
|
||||
@FunctionAccessBatcAnnotation(value = "sendAlarmMessage", timeOut = 5, batchMaxTimeOut = 10)
|
||||
public R<Void> sendAlarmMessage(@RequestBody AppDeviceSendMsgBo bo) {
|
||||
return toAjax(appDeviceService.sendAlarmMessage(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传设备logo图片
|
||||
*/
|
||||
@PostMapping("/uploadLogo")
|
||||
@FunctionAccessAnnotation("uploadLogo")
|
||||
public R<Void> upload(@Validated @ModelAttribute AppDeviceLogoUploadDto bo) {
|
||||
|
||||
MultipartFile file = bo.getFile();
|
||||
if(file.getSize()>1024*1024*2){
|
||||
return R.warn("图片不能大于2M");
|
||||
}
|
||||
appDeviceService.uploadDeviceLogo(bo);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 灯光模式
|
||||
* 0(关灯),1(强光模式),2(弱光模式), 3(爆闪模式), 4(泛光模式)
|
||||
*/
|
||||
// @FunctionAccessAnnotation("lightModeSettings")
|
||||
@PostMapping("/lightModeSettings")
|
||||
public R<Void> lightModeSettings(@RequestBody DeviceInstructDto params) {
|
||||
// params 转 JSONObject
|
||||
appDeviceService.lightModeSettings(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 灯光亮度设置
|
||||
*
|
||||
*/
|
||||
// @FunctionAccessAnnotation("lightBrightnessSettings")
|
||||
@PostMapping("/lightBrightnessSettings")
|
||||
public R<Void> lightBrightnessSettings(@RequestBody DeviceInstructDto params) {
|
||||
appDeviceService.lightBrightnessSettings(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 激光模式设置
|
||||
*
|
||||
*/
|
||||
@PostMapping("/laserModeSettings")
|
||||
// @FunctionAccessAnnotation("laserModeSettings")
|
||||
public R<Void> laserModeSettings(@RequestBody DeviceInstructDto params) {
|
||||
appDeviceService.laserModeSettings(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -1,16 +1,27 @@
|
||||
package com.fuyuanshen.web.controller.device;
|
||||
|
||||
|
||||
import com.fuyuanshen.app.domain.dto.APPReNameDTO;
|
||||
import com.fuyuanshen.app.domain.dto.AppRealTimeStatusDto;
|
||||
import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
|
||||
import com.fuyuanshen.web.service.WEBDeviceService;
|
||||
import com.fuyuanshen.web.service.device.DeviceBizService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
@ -25,6 +36,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class WEBDeviceController extends BaseController {
|
||||
|
||||
private final WEBDeviceService deviceService;
|
||||
private final DeviceBizService appDeviceService;
|
||||
|
||||
|
||||
/**
|
||||
@ -41,6 +53,66 @@ public class WEBDeviceController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询设备列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<AppDeviceVo> list(DeviceQueryCriteria bo, PageQuery pageQuery) {
|
||||
return appDeviceService.queryAppDeviceList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定设备
|
||||
*/
|
||||
@PostMapping("/bind")
|
||||
public R<Void> bind(@RequestBody AppDeviceBo bo) {
|
||||
return toAjax(appDeviceService.bindDevice(bo));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解绑设备
|
||||
*/
|
||||
@DeleteMapping("/unBind")
|
||||
public R<Void> unBind(Long id) {
|
||||
return toAjax(appDeviceService.unBindDevice(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备类型列表
|
||||
*/
|
||||
@GetMapping(value = "/typeList")
|
||||
public R<List<APPDeviceTypeVo>> getTypeList() {
|
||||
List<APPDeviceTypeVo> typeList = appDeviceService.getTypeList();
|
||||
return R.ok(typeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重命名设备
|
||||
*
|
||||
* @param reNameDTO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/reName")
|
||||
public R<String> reName(@Validated @RequestBody APPReNameDTO reNameDTO) {
|
||||
appDeviceService.reName(reNameDTO);
|
||||
return R.ok("重命名成功!!!");
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/realTimeStatus")
|
||||
public R<Map<String, Object>> getRealTimeStatus(AppRealTimeStatusDto statusDto) {
|
||||
Map<String, Object> status = appDeviceService.getRealTimeStatus(statusDto);
|
||||
return R.ok(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据mac查询设备信息
|
||||
*/
|
||||
@GetMapping("/getDeviceInfoByDeviceMac")
|
||||
public R<AppDeviceVo> getDeviceInfo(String deviceMac) {
|
||||
return R.ok(appDeviceService.getDeviceInfo(deviceMac));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,8 +1,13 @@
|
||||
package com.fuyuanshen.web.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuyuanshen.app.domain.AppDeviceBindRecord;
|
||||
import com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.DeviceAssignments;
|
||||
import com.fuyuanshen.equipment.enums.BindingStatusEnum;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceAssignmentsMapper;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||
import com.fuyuanshen.web.service.WEBDeviceService;
|
||||
@ -10,6 +15,7 @@ import com.fuyuanshen.web.service.device.DeviceBizService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
@ -25,6 +31,10 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
|
||||
|
||||
private final DeviceAssignmentsMapper deviceAssignmentsMapper;
|
||||
|
||||
private final AppDeviceBindRecordMapper appDeviceBindRecordMapper;
|
||||
|
||||
private final DeviceMapper deviceMapper;
|
||||
|
||||
|
||||
/**
|
||||
* WEB端解绑设备
|
||||
@ -33,6 +43,7 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int webUnBindDevice(Long id, Long userId) {
|
||||
// 设备端解绑 0:设备端解绑 1:web端解绑
|
||||
int type = 1;
|
||||
@ -44,7 +55,18 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
|
||||
id = deviceAssignments.getDeviceId();
|
||||
type = 0;
|
||||
}
|
||||
return appDeviceService.unBindDevice(id, userId, type);
|
||||
|
||||
QueryWrapper<AppDeviceBindRecord> deviceId = new QueryWrapper<AppDeviceBindRecord>().eq("device_id", id);
|
||||
|
||||
// appDeviceService.unBindDevice(id, userId, type);
|
||||
UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
|
||||
deviceUpdateWrapper.eq("id", id)
|
||||
.set("binding_user_id", null)
|
||||
.set("binding_status", BindingStatusEnum.UNBOUND.getCode())
|
||||
.set("binding_time", null);
|
||||
deviceMapper.update(null, deviceUpdateWrapper);
|
||||
|
||||
return appDeviceBindRecordMapper.delete(deviceId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,7 +24,7 @@ import com.fuyuanshen.app.service.IAppUserService;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* APP用户信息
|
||||
* WebApp用户信息
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
@ -32,8 +32,8 @@ import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/app/user")
|
||||
public class AppUserController extends BaseController {
|
||||
@RequestMapping("/WebApp/user")
|
||||
public class WebAppUserController extends BaseController {
|
||||
|
||||
private final IAppUserService appUserService;
|
||||
|
@ -222,11 +222,9 @@
|
||||
dt.type_name,
|
||||
dt.communication_mode,
|
||||
d.bluetooth_name,
|
||||
dt.model_dictionary detailPageUrl,
|
||||
c.binding_time
|
||||
dt.model_dictionary detailPageUrl
|
||||
from device d
|
||||
inner join device_type dt on d.device_type = dt.id
|
||||
inner join app_device_bind_record c on d.id = c.device_id
|
||||
where d.device_mac = #{deviceMac}
|
||||
</select>
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.fuyuanshen.system.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fuyuanshen.common.core.constant.CacheNames;
|
||||
import com.fuyuanshen.common.log.annotation.Log;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
@ -14,10 +15,12 @@ import com.fuyuanshen.system.domain.vo.SysDictDataVo;
|
||||
import com.fuyuanshen.system.service.ISysDictDataService;
|
||||
import com.fuyuanshen.system.service.ISysDictTypeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -73,6 +76,8 @@ public class SysDictDataController extends BaseController {
|
||||
*/
|
||||
@GetMapping(value = "/type/{dictType}")
|
||||
public R<List<SysDictDataVo>> dictType(@PathVariable String dictType) {
|
||||
// 使用时先清除缓存再查询
|
||||
dictTypeService.clearDictTypeCache(dictType);
|
||||
List<SysDictDataVo> data = dictTypeService.selectDictDataByType(dictType);
|
||||
if (ObjectUtil.isNull(data)) {
|
||||
data = new ArrayList<>();
|
||||
@ -94,6 +99,7 @@ public class SysDictDataController extends BaseController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改保存字典类型
|
||||
*/
|
||||
@ -105,6 +111,7 @@ public class SysDictDataController extends BaseController {
|
||||
return R.fail("修改字典数据'" + dict.getDictValue() + "'失败,字典键值已存在");
|
||||
}
|
||||
dictDataService.updateDictData(dict);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
@ -73,4 +73,9 @@ public interface ISysDictDataService {
|
||||
*/
|
||||
boolean checkDictDataUnique(SysDictDataBo dict);
|
||||
|
||||
/**
|
||||
* 清空字典缓存
|
||||
*/
|
||||
void clearDictTypeCache(String dictType);
|
||||
|
||||
}
|
||||
|
@ -92,4 +92,9 @@ public interface ISysDictTypeService {
|
||||
* @return 结果
|
||||
*/
|
||||
boolean checkDictTypeUnique(SysDictTypeBo dictType);
|
||||
|
||||
/**
|
||||
* 清空字典缓存
|
||||
*/
|
||||
void clearDictTypeCache(String dictType);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import com.fuyuanshen.system.domain.vo.SysDictDataVo;
|
||||
import com.fuyuanshen.system.mapper.SysDictDataMapper;
|
||||
import com.fuyuanshen.system.service.ISysDictDataService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -154,4 +155,12 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// 清除指定dictType的缓存
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DICT, key = "#dictType")
|
||||
public void clearDictTypeCache(String dictType) {
|
||||
// 仅用于清除缓存
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import com.fuyuanshen.system.domain.vo.SysDictTypeVo;
|
||||
import com.fuyuanshen.system.mapper.SysDictDataMapper;
|
||||
import com.fuyuanshen.system.mapper.SysDictTypeMapper;
|
||||
import com.fuyuanshen.system.service.ISysDictTypeService;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -294,4 +295,11 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
return BeanUtil.copyToList(list, DictDataDTO.class);
|
||||
}
|
||||
|
||||
|
||||
// 清除指定dictType的缓存
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DICT, key = "#dictType")
|
||||
public void clearDictTypeCache(String dictType) {
|
||||
// 仅用于清除缓存
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user