Compare commits
19 Commits
main
...
dyf-device
Author | SHA1 | Date | |
---|---|---|---|
040e44984e | |||
f7a82ef138 | |||
91f787eec7 | |||
870f94b2d4 | |||
395b2957c1 | |||
64a4485ced | |||
1e4ee840a3 | |||
374a03b83d | |||
b945420446 | |||
c057af7cd0 | |||
452c37c4ca | |||
429c0f1307 | |||
ff4db34e2a | |||
377579dd14 | |||
00e345d5e5 | |||
98cb67b136 | |||
d97928b38a | |||
1d37bfb719 | |||
98ef841f18 |
@ -83,7 +83,7 @@ public class AppDeviceXinghanController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* SOS档位
|
||||
* SOS档位s
|
||||
* SOS档位,2,1,0, 分别表示红蓝模式/爆闪模式/关闭
|
||||
*/
|
||||
@PostMapping("/SOSGradeSettings")
|
||||
|
@ -1,23 +1,44 @@
|
||||
package com.fuyuanshen.global.mqtt.listener;
|
||||
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import com.baomidou.lock.LockInfo;
|
||||
import com.baomidou.lock.LockTemplate;
|
||||
import com.baomidou.lock.executor.RedissonLockExecutor;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||
import com.fuyuanshen.global.mqtt.listener.domain.FunctionAccessStatus;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.redis.connection.Message;
|
||||
import org.springframework.data.redis.connection.MessageListener;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_TIMEOUT_KEY;
|
||||
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX;
|
||||
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class RedisKeyExpirationListener implements MessageListener {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("threadPoolTaskExecutor")
|
||||
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
||||
|
||||
@Autowired
|
||||
private DeviceMapper deviceMapper;
|
||||
|
||||
@Autowired
|
||||
private LockTemplate lockTemplate;
|
||||
|
||||
@Override
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
String expiredKey = new String(message.getBody());
|
||||
@ -26,8 +47,44 @@ public class RedisKeyExpirationListener implements MessageListener {
|
||||
String element = expiredKey.substring(FUNCTION_ACCESS_KEY.length());
|
||||
handleFunctionAccessExpired(element);
|
||||
}
|
||||
}
|
||||
if(expiredKey.endsWith(DEVICE_ONLINE_STATUS_KEY_PREFIX)) {
|
||||
// threadPoolTaskExecutor.execute(() -> {
|
||||
// log.info("设备离线:{}", expiredKey);
|
||||
// String element = expiredKey.substring(GlobalConstants.GLOBAL_REDIS_KEY.length() + DEVICE_KEY_PREFIX.length(), expiredKey.length() - DEVICE_ONLINE_STATUS_KEY_PREFIX.length());
|
||||
// UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
|
||||
// deviceUpdateWrapper.eq("device_imei", element);
|
||||
// deviceUpdateWrapper.set("online_status", 0);
|
||||
// deviceMapper.update(deviceUpdateWrapper);
|
||||
// });
|
||||
|
||||
threadPoolTaskExecutor.execute(() -> {
|
||||
log.info("设备离线:{}", expiredKey);
|
||||
String element = expiredKey.substring(GlobalConstants.GLOBAL_REDIS_KEY.length() + DEVICE_KEY_PREFIX.length(), expiredKey.length() - DEVICE_ONLINE_STATUS_KEY_PREFIX.length());
|
||||
|
||||
// 构造设备锁键
|
||||
String deviceLockKey = GlobalConstants.GLOBAL_REDIS_KEY + ":device_lock:" + element;
|
||||
|
||||
// 尝试获取Redis锁
|
||||
LockInfo lockInfo = lockTemplate.lock(deviceLockKey, 30000L, 5000L, RedissonLockExecutor.class); // 30秒过期
|
||||
|
||||
if (lockInfo != null) {
|
||||
try {
|
||||
UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
|
||||
deviceUpdateWrapper.eq("device_imei", element);
|
||||
deviceUpdateWrapper.set("online_status", 0);
|
||||
deviceMapper.update(deviceUpdateWrapper);
|
||||
} finally {
|
||||
//释放锁
|
||||
lockTemplate.releaseLock(lockInfo);
|
||||
}
|
||||
} else {
|
||||
log.warn("无法获取设备锁,跳过设备离线处理: {}", element);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* 访问key过期事件
|
||||
* @param element 批次ID
|
||||
|
@ -117,28 +117,28 @@ public class BjqLocationDataRule implements MqttMessageRule {
|
||||
if(StringUtils.isBlank(latitude) || StringUtils.isBlank(longitude)){
|
||||
return;
|
||||
}
|
||||
String[] latArr = latitude.split("\\.");
|
||||
String[] lonArr = longitude.split("\\.");
|
||||
// 将位置信息存储到Redis中
|
||||
// String[] latArr = latitude.split("\\.");
|
||||
// String[] lonArr = longitude.split("\\.");
|
||||
// // 将位置信息存储到Redis中
|
||||
String redisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DEVICE_LOCATION_KEY_PREFIX;
|
||||
String redisObj = RedisUtils.getCacheObject(redisKey);
|
||||
JSONObject jsonOBj = JSONObject.parseObject(redisObj);
|
||||
if(jsonOBj != null){
|
||||
String str1 = latArr[0] +"."+ latArr[1].substring(0,4);
|
||||
String str2 = lonArr[0] +"."+ lonArr[1].substring(0,4);
|
||||
|
||||
String cacheLatitude = jsonOBj.getString("wgs84_latitude");
|
||||
String cacheLongitude = jsonOBj.getString("wgs84_longitude");
|
||||
String[] latArr1 = cacheLatitude.split("\\.");
|
||||
String[] lonArr1 = cacheLongitude.split("\\.");
|
||||
|
||||
String cacheStr1 = latArr1[0] +"."+ latArr1[1].substring(0,4);
|
||||
String cacheStr2 = lonArr1[0] +"."+ lonArr1[1].substring(0,4);
|
||||
if(str1.equals(cacheStr1) && str2.equals(cacheStr2)){
|
||||
log.info("位置信息未发生变化: device={}, lat={}, lon={}", deviceImei, latitude, longitude);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// String redisObj = RedisUtils.getCacheObject(redisKey);
|
||||
// JSONObject jsonOBj = JSONObject.parseObject(redisObj);
|
||||
// if(jsonOBj != null){
|
||||
// String str1 = latArr[0] +"."+ latArr[1].substring(0,4);
|
||||
// String str2 = lonArr[0] +"."+ lonArr[1].substring(0,4);
|
||||
//
|
||||
// String cacheLatitude = jsonOBj.getString("wgs84_latitude");
|
||||
// String cacheLongitude = jsonOBj.getString("wgs84_longitude");
|
||||
// String[] latArr1 = cacheLatitude.split("\\.");
|
||||
// String[] lonArr1 = cacheLongitude.split("\\.");
|
||||
//
|
||||
// String cacheStr1 = latArr1[0] +"."+ latArr1[1].substring(0,4);
|
||||
// String cacheStr2 = lonArr1[0] +"."+ lonArr1[1].substring(0,4);
|
||||
// if(str1.equals(cacheStr1) && str2.equals(cacheStr2)){
|
||||
// log.info("位置信息未发生变化: device={}, lat={}, lon={}", deviceImei, latitude, longitude);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// 构造位置信息对象
|
||||
Map<String, Object> locationInfo = new LinkedHashMap<>();
|
||||
|
@ -39,7 +39,7 @@ public class DeviceChargeDischargeController extends BaseController {
|
||||
/**
|
||||
* 查询设备充放电记录列表
|
||||
*/
|
||||
@SaCheckPermission("equipment:chargeDischarge:list")
|
||||
// @SaCheckPermission("equipment:chargeDischarge:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<DeviceChargeDischargeVo> list(DeviceChargeDischargeBo bo, PageQuery pageQuery) {
|
||||
return deviceChargeDischargeService.queryPageList(bo, pageQuery);
|
||||
@ -48,7 +48,7 @@ public class DeviceChargeDischargeController extends BaseController {
|
||||
/**
|
||||
* 设备充放电记录列表
|
||||
*/
|
||||
@SaCheckPermission("equipment:chargeDischarge:export")
|
||||
// @SaCheckPermission("equipment:chargeDischarge:export")
|
||||
@Log(title = "设备充放电记录", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(DeviceChargeDischargeBo bo, HttpServletResponse response) {
|
||||
@ -61,7 +61,7 @@ public class DeviceChargeDischargeController extends BaseController {
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("equipment:chargeDischarge:query")
|
||||
// @SaCheckPermission("equipment:chargeDischarge:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<DeviceChargeDischargeVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
@ -71,7 +71,7 @@ public class DeviceChargeDischargeController extends BaseController {
|
||||
/**
|
||||
* 新增设备充放电记录
|
||||
*/
|
||||
@SaCheckPermission("equipment:chargeDischarge:add")
|
||||
// @SaCheckPermission("equipment:chargeDischarge:add")
|
||||
@Log(title = "设备充放电记录", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
@ -82,7 +82,7 @@ public class DeviceChargeDischargeController extends BaseController {
|
||||
/**
|
||||
* 修改设备充放电记录
|
||||
*/
|
||||
@SaCheckPermission("equipment:chargeDischarge:edit")
|
||||
// @SaCheckPermission("equipment:chargeDischarge:edit")
|
||||
@Log(title = "设备充放电记录", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
@ -95,11 +95,13 @@ public class DeviceChargeDischargeController extends BaseController {
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("equipment:chargeDischarge:remove")
|
||||
// @SaCheckPermission("equipment:chargeDischarge:remove")
|
||||
@Log(title = "设备充放电记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(deviceChargeDischargeService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,18 +1,32 @@
|
||||
package com.fuyuanshen.web.controller.device;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.fuyuanshen.app.domain.bo.AppDeviceShareBo;
|
||||
import com.fuyuanshen.app.domain.vo.AppDeviceShareVo;
|
||||
import com.fuyuanshen.common.core.constant.Constants;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.ratelimiter.annotation.RateLimiter;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.equipment.domain.bo.DeviceAlarmBo;
|
||||
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
|
||||
import com.fuyuanshen.web.service.DeviceShareService;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.sms4j.api.SmsBlend;
|
||||
import org.dromara.sms4j.api.entity.SmsResponse;
|
||||
import org.dromara.sms4j.core.factory.SmsFactory;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.DEVICE_SHARE_CODES_KEY;
|
||||
|
||||
/**
|
||||
* 设备分享管理
|
||||
@ -30,14 +44,53 @@ public class DeviceShareController extends BaseController {
|
||||
|
||||
|
||||
/**
|
||||
*查询设备分享列表(web)
|
||||
* 分享管理列表
|
||||
*/
|
||||
// @SaCheckPermission("equipment:alarm:list")
|
||||
@GetMapping("/list")
|
||||
@GetMapping("/deviceShareList")
|
||||
public TableDataInfo<AppDeviceShareVo> list(AppDeviceShareBo bo, PageQuery pageQuery) {
|
||||
return appDeviceShareService.queryWebList(bo, pageQuery);
|
||||
return appDeviceShareService.queryWebPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增设备分享
|
||||
*/
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/deviceShare")
|
||||
public R<Void> deviceShare(@Validated(AddGroup.class) @RequestBody AppDeviceShareBo bo) {
|
||||
return toAjax(appDeviceShareService.deviceShare(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除分享用户
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(appDeviceShareService.remove(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 短信验证码
|
||||
*
|
||||
* @param phonenumber 用户手机号
|
||||
*/
|
||||
@SaIgnore
|
||||
@RateLimiter(key = "#phonenumber", time = 60, count = 1)
|
||||
@GetMapping("/sms/code")
|
||||
public R<Void> smsCode(@NotBlank(message = "{user.phonenumber.not.blank}") String phonenumber) {
|
||||
String key = DEVICE_SHARE_CODES_KEY + phonenumber;
|
||||
String code = RandomUtil.randomNumbers(4);
|
||||
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
||||
LinkedHashMap<String, String> map = new LinkedHashMap<>(1);
|
||||
map.put("code", code);
|
||||
SmsBlend smsBlend = SmsFactory.getSmsBlend("config1");
|
||||
SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, map);
|
||||
if (!smsResponse.isSuccess()) {
|
||||
return R.fail(smsResponse.getData().toString());
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,16 @@
|
||||
package com.fuyuanshen.web.controller.device;
|
||||
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.equipment.domain.vo.AlarmInformationVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.DataOverviewVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.EquipmentClassificationVo;
|
||||
import com.fuyuanshen.equipment.service.DeviceService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 首页数据
|
||||
@ -39,29 +38,36 @@ public class HomePageController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 获取设备使用数据
|
||||
@GetMapping("/{deviceId}")
|
||||
public Map<String, Object> getUsageData(
|
||||
@PathVariable String deviceId,
|
||||
@RequestParam String range) {
|
||||
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
|
||||
if ("halfYear".equals(range)) {
|
||||
response.put("months", Arrays.asList("1月", "2月", "3月", "4月", "5月", "6月"));
|
||||
response.put("data", Arrays.asList(45, 52, 38, 60, 56, 48));
|
||||
} else if ("oneYear".equals(range)) {
|
||||
response.put("months", Arrays.asList("7月", "8月", "9月", "10月", "11月", "12月",
|
||||
"1月", "2月", "3月", "4月", "5月", "6月"));
|
||||
response.put("data", Arrays.asList(42, 38, 45, 48, 52, 55, 45, 52, 38, 60, 56, 48));
|
||||
}
|
||||
|
||||
response.put("deviceId", deviceId);
|
||||
response.put("range", range);
|
||||
response.put("lastUpdate", new Date());
|
||||
|
||||
return response;
|
||||
/**
|
||||
* 获取 设备分类
|
||||
* DataOverview
|
||||
*/
|
||||
@GetMapping("/getEquipmentClassification")
|
||||
public R<EquipmentClassificationVo> getEquipmentClassification() {
|
||||
return R.ok(deviceService.getEquipmentClassification());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取 报警信息
|
||||
* DataOverview
|
||||
*/
|
||||
@GetMapping("/getAlarmInformation")
|
||||
public R<AlarmInformationVo> getAlarmInformation() {
|
||||
return R.ok(deviceService.getAlarmInformation());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取设备使用数据
|
||||
*
|
||||
* @param deviceId 设备ID
|
||||
* @param range 时间范围 1:半年 2:一年
|
||||
* @return 每月使用数据列表
|
||||
*/
|
||||
@GetMapping("/getEquipmentUsageData/{deviceId}/{range}")
|
||||
public R<List<Map<String, Object>>> getEquipmentUsageData(@PathVariable Long deviceId, @PathVariable Integer range) {
|
||||
return R.ok(deviceService.getEquipmentUsageData(deviceId, range));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package com.fuyuanshen.web.controller.device;
|
||||
|
||||
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
|
||||
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.DeviceLog;
|
||||
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
|
||||
@ -65,7 +67,7 @@ public class WEBDeviceController extends BaseController {
|
||||
* @param deviceId
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "设备详情")
|
||||
@Operation(summary = "设备用户详情")
|
||||
@GetMapping(value = "/getDeviceUser/{deviceId}")
|
||||
public R<List<AppPersonnelInfoRecords>> getDeviceUser(@PathVariable Long deviceId) {
|
||||
List<AppPersonnelInfoRecords> device = deviceService.getDeviceUser(deviceId);
|
||||
@ -77,13 +79,18 @@ public class WEBDeviceController extends BaseController {
|
||||
* 设备操作记录
|
||||
*
|
||||
* @param deviceId
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "设备操作记录")
|
||||
@GetMapping(value = "/getOperationRecord/{deviceId}")
|
||||
public R<List<DeviceLog>> getOperationRecord(@PathVariable Long deviceId) {
|
||||
List<DeviceLog> device = deviceService.getOperationRecord(deviceId);
|
||||
return R.ok(device);
|
||||
public TableDataInfo<DeviceLog> getOperationRecord(@PathVariable Long deviceId,
|
||||
@RequestParam(required = false) String startTime,
|
||||
@RequestParam(required = false) String endTime,
|
||||
PageQuery pageQuery) {
|
||||
TableDataInfo<DeviceLog> device = deviceService.getOperationRecord(deviceId, startTime, endTime,pageQuery);
|
||||
return device;
|
||||
}
|
||||
|
||||
|
||||
@ -91,13 +98,17 @@ public class WEBDeviceController extends BaseController {
|
||||
* 设备告警记录
|
||||
*
|
||||
* @param deviceId
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "设备告警记录")
|
||||
@GetMapping(value = "/getAlarmRecord/{deviceId}")
|
||||
public R<List<DeviceAlarmVo>> getAlarmRecord(@PathVariable Long deviceId) {
|
||||
List<DeviceAlarmVo> device = deviceService.getAlarmRecord(deviceId);
|
||||
return R.ok(device);
|
||||
public TableDataInfo<DeviceAlarmVo> getAlarmRecord(@PathVariable Long deviceId,
|
||||
@RequestParam(required = false) String startTime,
|
||||
@RequestParam(required = false) String endTime,
|
||||
PageQuery pageQuery) {
|
||||
return deviceService.getAlarmRecord(deviceId, startTime, endTime, pageQuery);
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,6 +60,16 @@ public class DeviceShareService {
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
public TableDataInfo<AppDeviceShareVo> queryWebPageList(AppDeviceShareBo bo, PageQuery pageQuery) {
|
||||
// Long userId = AppLoginHelper.getUserId();
|
||||
// bo.setCreateBy(userId);
|
||||
Page<AppDeviceShareVo> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
|
||||
Page<AppDeviceShareVo> result = appDeviceShareMapper.selectWebDeviceShareList(bo, page);
|
||||
List<AppDeviceShareVo> records = result.getRecords();
|
||||
records.forEach(DeviceShareService::buildDeviceStatus);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
private static void buildDeviceStatus(AppDeviceShareVo item) {
|
||||
// 设备在线状态
|
||||
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
|
||||
|
@ -53,16 +53,21 @@ public interface WEBDeviceService extends IService<Device> {
|
||||
* 设备操作记录
|
||||
*
|
||||
* @param deviceId
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return
|
||||
*/
|
||||
List<DeviceLog> getOperationRecord(Long deviceId);
|
||||
TableDataInfo<DeviceLog> getOperationRecord(Long deviceId, String startTime, String endTime, PageQuery pageQuery);
|
||||
|
||||
|
||||
/**
|
||||
* 设备告警记录
|
||||
*
|
||||
* @param deviceId
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return
|
||||
*/
|
||||
List<DeviceAlarmVo> getAlarmRecord(Long deviceId);
|
||||
TableDataInfo<DeviceAlarmVo> getAlarmRecord(Long deviceId, String startTime, String endTime, PageQuery pageQuery);
|
||||
|
||||
}
|
||||
|
@ -100,7 +100,6 @@ public class DeviceBJQBizService {
|
||||
|
||||
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("id", deviceId)
|
||||
.eq("binding_user_id", AppLoginHelper.getUserId())
|
||||
.set("send_msg", bo.getSendMsg());
|
||||
deviceMapper.update(updateWrapper);
|
||||
|
||||
@ -538,6 +537,6 @@ public class DeviceBJQBizService {
|
||||
|
||||
private boolean getDeviceStatus(String deviceImei) {
|
||||
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
|
||||
return StringUtils.isBlank(deviceOnlineStatusRedisKey);
|
||||
return RedisUtils.getCacheObject(deviceOnlineStatusRedisKey) == null;
|
||||
}
|
||||
}
|
||||
|
@ -330,10 +330,10 @@ public class DeviceXinghanBizService {
|
||||
AppLoginHelper.getUserId());
|
||||
}
|
||||
|
||||
private boolean isDeviceOffline(String imei) {
|
||||
// 原方法名语义相反,这里取反,使含义更清晰
|
||||
return getDeviceStatus(imei);
|
||||
}
|
||||
// private boolean isDeviceOffline(String imei) {
|
||||
// // 原方法名语义相反,这里取反,使含义更清晰
|
||||
// return getDeviceStatus(imei);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 记录设备操作日志
|
||||
@ -359,9 +359,9 @@ public class DeviceXinghanBizService {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean getDeviceStatus(String deviceImei) {
|
||||
private boolean isDeviceOffline(String deviceImei) {
|
||||
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
|
||||
return StringUtils.isBlank(deviceOnlineStatusRedisKey);
|
||||
return RedisUtils.getCacheObject(deviceOnlineStatusRedisKey)==null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,16 +1,20 @@
|
||||
package com.fuyuanshen.web.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuyuanshen.app.domain.AppDeviceBindRecord;
|
||||
import com.fuyuanshen.app.domain.AppDeviceShare;
|
||||
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
|
||||
import com.fuyuanshen.app.domain.vo.AppDeviceShareVo;
|
||||
import com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper;
|
||||
import com.fuyuanshen.app.mapper.AppDeviceShareMapper;
|
||||
import com.fuyuanshen.app.mapper.AppPersonnelInfoRecordsMapper;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.DeviceAlarm;
|
||||
import com.fuyuanshen.equipment.domain.DeviceAssignments;
|
||||
@ -23,7 +27,6 @@ import com.fuyuanshen.equipment.mapper.DeviceAssignmentsMapper;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceLogMapper;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||
import com.fuyuanshen.web.service.WEBDeviceService;
|
||||
import com.fuyuanshen.web.service.device.DeviceBizService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -129,11 +132,19 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DeviceLog> getOperationRecord(Long deviceId) {
|
||||
List<DeviceLog> logList = deviceLogMapper.selectList(
|
||||
new QueryWrapper<DeviceLog>().eq("device_id", deviceId)
|
||||
.orderByDesc("create_time"));
|
||||
return logList;
|
||||
public TableDataInfo<DeviceLog> getOperationRecord(Long deviceId, String startTime, String endTime, PageQuery pageQuery) {
|
||||
Page<DeviceLog> page = pageQuery.build();
|
||||
QueryWrapper<DeviceLog> queryWrapper = new QueryWrapper<DeviceLog>().eq("device_id", deviceId);
|
||||
|
||||
if (StrUtil.isNotEmpty(startTime)) {
|
||||
queryWrapper.ge("create_time", startTime);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(endTime)) {
|
||||
queryWrapper.le("create_time", endTime);
|
||||
}
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
IPage<DeviceLog> logList = deviceLogMapper.selectPage(page, queryWrapper);
|
||||
return TableDataInfo.build(logList);
|
||||
}
|
||||
|
||||
|
||||
@ -144,13 +155,23 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DeviceAlarmVo> getAlarmRecord(Long deviceId) {
|
||||
List<DeviceAlarm> alarmList = deviceAlarmMapper.selectList(
|
||||
new QueryWrapper<DeviceAlarm>().eq("device_id", deviceId)
|
||||
.orderByDesc("create_time"));
|
||||
List<DeviceAlarmVo> deviceAlarmVoList = BeanUtil.copyToList(alarmList, DeviceAlarmVo.class);
|
||||
return deviceAlarmVoList;
|
||||
public TableDataInfo getAlarmRecord(Long deviceId, String startTime, String endTime, PageQuery pageQuery) {
|
||||
Page<DeviceAlarm> page = pageQuery.build();
|
||||
QueryWrapper<DeviceAlarm> queryWrapper = new QueryWrapper<DeviceAlarm>().eq("device_id", deviceId);
|
||||
|
||||
if (StrUtil.isNotEmpty(startTime)) {
|
||||
queryWrapper.ge("start_time", startTime);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(endTime)) {
|
||||
queryWrapper.le("start_time", endTime);
|
||||
}
|
||||
queryWrapper.orderByDesc("start_time");
|
||||
IPage<DeviceAlarm> alarmPage = deviceAlarmMapper.selectPage(page, queryWrapper);
|
||||
|
||||
// List<DeviceAlarmVo> deviceAlarmVoList = BeanUtil.copyToList(alarmPage.getRecords(), DeviceAlarmVo.class);
|
||||
return TableDataInfo.build(alarmPage);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,8 +39,8 @@ public class EncryptUtilsTest {
|
||||
loginBody.setClientId("e5cd7e4891bf95d1d19206ce24a7b32e");
|
||||
loginBody.setGrantType("password");
|
||||
loginBody.setTenantId("894078");
|
||||
loginBody.setCode("9");
|
||||
loginBody.setUuid("d5be31eac1244cee851a9903f358bc6a");
|
||||
loginBody.setCode("0");
|
||||
loginBody.setUuid("1d6615668c7f410da77c4e002c601073");
|
||||
// loginBody.setUsername("admin");
|
||||
// loginBody.setPassword("admin123");
|
||||
loginBody.setUsername("dyf");
|
||||
|
@ -50,18 +50,32 @@
|
||||
|
||||
<!-- 查询设备分享列表(web) -->
|
||||
<select id="selectWebDeviceShareList" resultType="com.fuyuanshen.app.domain.vo.AppDeviceShareVo">
|
||||
select *
|
||||
select d.device_name,
|
||||
d.device_mac,
|
||||
d.device_sn,
|
||||
d.device_imei,
|
||||
d.device_pic,
|
||||
dt.type_name,
|
||||
dt.communication_mode,
|
||||
d.bluetooth_name,
|
||||
dt.app_model_dictionary detailPageUrl,
|
||||
c.binding_time,
|
||||
ad.*,u.user_name otherPhonenumber
|
||||
from
|
||||
app_device_share ad
|
||||
left join device d on ad.device_id = d.id
|
||||
left join app_user u on ad.create_by = u.user_id
|
||||
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>
|
||||
<if test="bo.deviceId != null">
|
||||
and ad.device_id = #{bo.deviceId}
|
||||
</if>
|
||||
<if test="bo.shareUser != null">
|
||||
and ad.share_user = #{bo.shareUser}
|
||||
and u.user_name = #{bo.shareUser}
|
||||
</if>
|
||||
<if test="criteria.shareStartTime != null and criteria.hareEndTime != null">
|
||||
and d.create_time between #{bo.shareStartTime} and #{bo.shareEndTime}
|
||||
and ad.create_time between #{bo.shareStartTime} and #{bo.shareEndTime}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
|
@ -126,26 +126,26 @@ public class DeviceController extends BaseController {
|
||||
|
||||
|
||||
// @Log("分配客户")
|
||||
@Operation(summary = "分配客户")
|
||||
@PutMapping(value = "/assignCustomer")
|
||||
public R<Void> assignCustomer(@Validated @RequestBody CustomerVo customerVo) {
|
||||
deviceService.assignCustomer(customerVo);
|
||||
return R.ok();
|
||||
}
|
||||
// @Operation(summary = "分配客户")
|
||||
// @PutMapping(value = "/assignCustomer")
|
||||
// public R<Void> assignCustomer(@Validated @RequestBody CustomerVo customerVo) {
|
||||
// deviceService.assignCustomer(customerVo);
|
||||
// return R.ok();
|
||||
// }
|
||||
|
||||
|
||||
// @Log("撤回设备")
|
||||
@Operation(summary = "撤回分配设备")
|
||||
@PostMapping(value = "/withdraw")
|
||||
public R<Void> withdrawDevice(@RequestBody List<Long> ids) {
|
||||
try {
|
||||
deviceService.withdrawDevice(ids);
|
||||
} catch (Exception e) {
|
||||
log.error("updateDevice error: " + e.getMessage());
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
// @Operation(summary = "撤回分配设备")
|
||||
// @PostMapping(value = "/withdraw")
|
||||
// public R<Void> withdrawDevice(@RequestBody List<Long> ids) {
|
||||
// try {
|
||||
// deviceService.withdrawDevice(ids);
|
||||
// } catch (Exception e) {
|
||||
// log.error("updateDevice error: " + e.getMessage());
|
||||
// return R.fail(e.getMessage());
|
||||
// }
|
||||
// return R.ok();
|
||||
// }
|
||||
|
||||
//
|
||||
// /**
|
||||
|
@ -162,7 +162,7 @@ public class Device extends TenantEntity {
|
||||
private Date productionDate;
|
||||
|
||||
/**
|
||||
* 在线状态(0离线,1在线)
|
||||
* 在线状态(0离线,1在线,2异常)
|
||||
*/
|
||||
private Integer onlineStatus;
|
||||
}
|
||||
|
@ -4,7 +4,9 @@ import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.io.Serial;
|
||||
@ -36,8 +38,10 @@ public class DeviceAlarm extends TenantEntity {
|
||||
|
||||
/**
|
||||
* 报警事项
|
||||
* 0-强制报警,1-撞击闯入,2-手动报警,3-电子围栏告警,4-强制告警
|
||||
* device_action
|
||||
*/
|
||||
private String deviceAction;
|
||||
private Integer deviceAction;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
@ -61,7 +65,6 @@ public class DeviceAlarm extends TenantEntity {
|
||||
|
||||
/**
|
||||
* 经度
|
||||
|
||||
*/
|
||||
private Long longitude;
|
||||
|
||||
@ -88,10 +91,11 @@ public class DeviceAlarm extends TenantEntity {
|
||||
/**
|
||||
* 报警持续时间
|
||||
*/
|
||||
private Long durationTime;
|
||||
private String durationTime;
|
||||
|
||||
/**
|
||||
* 0已处理,1未处理
|
||||
* treatment_state
|
||||
*/
|
||||
private Long treatmentState;
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class DeviceType extends TenantEntity {
|
||||
@Schema(title = "联网方式", example = "0:无;1:4G;2:WIFI")
|
||||
private String networkWay;
|
||||
|
||||
@Schema(title = "通讯方式", example = "0:4G;1:蓝牙")
|
||||
@Schema(title = "通讯方式", example = "0:4G;1:蓝牙,2 4G&蓝牙")
|
||||
private String communicationMode;
|
||||
|
||||
/**
|
||||
|
@ -35,4 +35,18 @@ public class DeviceTypeForm {
|
||||
@Schema(title = "型号字典用于APP页面跳转")
|
||||
private String modelDictionary;
|
||||
|
||||
/**
|
||||
* 型号字典用于APP页面跳转
|
||||
* app_model_dictionary
|
||||
*/
|
||||
@Schema(title = "型号字典用于APP页面跳转")
|
||||
private String appModelDictionary;
|
||||
|
||||
/**
|
||||
* 型号字典用于PC页面跳转
|
||||
* pc_model_dictionary
|
||||
*/
|
||||
@Schema(title = "型号字典用于PC页面跳转")
|
||||
private String pcModelDictionary;
|
||||
|
||||
}
|
||||
|
@ -83,6 +83,7 @@ public class DeviceQueryCriteria extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 通讯方式 0:4G;1:蓝牙
|
||||
* communication_mode
|
||||
*/
|
||||
private Integer communicationMode;
|
||||
|
||||
@ -113,4 +114,10 @@ public class DeviceQueryCriteria extends BaseEntity {
|
||||
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 设备在线状态
|
||||
* 0:离线;1:在线
|
||||
*/
|
||||
private Integer onlineStatus;
|
||||
|
||||
}
|
||||
|
@ -6,13 +6,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.dto.InstructionRecordDto;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.LocationHistoryVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.*;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
@ -72,7 +71,42 @@ public interface DeviceMapper extends BaseMapper<Device> {
|
||||
|
||||
AppDeviceVo getDeviceInfo(@Param("deviceMac") String deviceMac);
|
||||
|
||||
Page<WebDeviceVo> queryWebDeviceList(Page<Object> build,@Param("criteria") DeviceQueryCriteria criteria);
|
||||
Page<WebDeviceVo> queryWebDeviceList(Page<Object> build, @Param("criteria") DeviceQueryCriteria criteria);
|
||||
|
||||
Page<LocationHistoryVo> getLocationHistory(Page<Object> build, @Param("bo") InstructionRecordDto criteria);
|
||||
|
||||
/**
|
||||
* 获取数据总览
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
DataOverviewVo getDataOverview();
|
||||
|
||||
/**
|
||||
* 获取设备分类
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
EquipmentClassificationVo getEquipmentClassification();
|
||||
|
||||
/**
|
||||
* 获取告警信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
AlarmInformationVo getAlarmInformation();
|
||||
|
||||
/**
|
||||
* 获取设备使用数据
|
||||
*
|
||||
* @param deviceId 设备ID
|
||||
* @param range 时间范围 1:半年 2:一年
|
||||
* @return 每月使用数据列表
|
||||
*/
|
||||
List<Map<String, Object>> getEquipmentUsageData(Long deviceId, Integer range);
|
||||
|
||||
// 在DeviceMapper.java中添加方法
|
||||
int getUsageDataForMonth(@Param("deviceId") Long deviceId,
|
||||
@Param("year") int year,
|
||||
@Param("month") int month);
|
||||
}
|
||||
|
@ -9,12 +9,11 @@ import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
|
||||
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.CustomerVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.DataOverviewVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
@ -122,4 +121,27 @@ public interface DeviceService extends IService<Device> {
|
||||
* @return
|
||||
*/
|
||||
DataOverviewVo getDataOverview();
|
||||
|
||||
/**
|
||||
* 获取设备分类
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
EquipmentClassificationVo getEquipmentClassification();
|
||||
|
||||
/**
|
||||
* 获取告警信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
AlarmInformationVo getAlarmInformation();
|
||||
|
||||
/**
|
||||
* 获取设备使用数据
|
||||
*
|
||||
* @param deviceId
|
||||
* @param range
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> getEquipmentUsageData(Long deviceId, Integer range);
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ public class DeviceLogServiceImpl implements IDeviceLogService {
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询设备日志列表
|
||||
*
|
||||
@ -62,13 +63,12 @@ public class DeviceLogServiceImpl implements IDeviceLogService {
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<DeviceLogVo> queryPageList(DeviceLogBo bo, PageQuery pageQuery) {
|
||||
|
||||
|
||||
LambdaQueryWrapper<DeviceLog> lqw = buildQueryWrapper(bo);
|
||||
Page<DeviceLogVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备日志列表
|
||||
*
|
||||
@ -83,13 +83,17 @@ public class DeviceLogServiceImpl implements IDeviceLogService {
|
||||
|
||||
private LambdaQueryWrapper<DeviceLog> buildQueryWrapper(DeviceLogBo bo) {
|
||||
|
||||
Long userId = LoginHelper.getUserId();
|
||||
List<DeviceAssignments> assignments = deviceAssignmentsMapper.selectList(new QueryWrapper<DeviceAssignments>().eq("assignee_id", userId));
|
||||
List<Long> deviceIds = assignments.stream().map(DeviceAssignments::getDeviceId).collect(Collectors.toList());
|
||||
if (deviceIds.isEmpty()) {
|
||||
deviceIds.add(-1L);
|
||||
// 管理员
|
||||
String username = LoginHelper.getUsername();
|
||||
if (!username.equals("admin")) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
List<DeviceAssignments> assignments = deviceAssignmentsMapper.selectList(new QueryWrapper<DeviceAssignments>().eq("assignee_id", userId));
|
||||
List<Long> deviceIds = assignments.stream().map(DeviceAssignments::getDeviceId).collect(Collectors.toList());
|
||||
if (deviceIds.isEmpty()) {
|
||||
deviceIds.add(-1L);
|
||||
}
|
||||
bo.setDeviceIds(deviceIds);
|
||||
}
|
||||
bo.setDeviceIds(deviceIds);
|
||||
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<DeviceLog> lqw = Wrappers.lambdaQuery();
|
||||
@ -99,6 +103,7 @@ public class DeviceLogServiceImpl implements IDeviceLogService {
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getDataSource()), DeviceLog::getDataSource, bo.getDataSource());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getContent()), DeviceLog::getContent, bo.getContent());
|
||||
lqw.in(CollectionUtil.isNotEmpty(bo.getDeviceIds()), DeviceLog::getDeviceId, bo.getDeviceIds());
|
||||
lqw.orderByDesc(DeviceLog::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
@ -28,9 +28,7 @@ import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceAssignmentQuery;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria;
|
||||
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.CustomerVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.DataOverviewVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.*;
|
||||
import com.fuyuanshen.equipment.enums.BindingStatusEnum;
|
||||
import com.fuyuanshen.equipment.enums.CommunicationModeEnum;
|
||||
import com.fuyuanshen.equipment.enums.DeviceActiveStatusEnum;
|
||||
@ -53,11 +51,9 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
@ -596,8 +592,6 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询设备MAC号
|
||||
*
|
||||
@ -623,7 +617,46 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
*/
|
||||
@Override
|
||||
public DataOverviewVo getDataOverview() {
|
||||
return null;
|
||||
DataOverviewVo dataOverviewVo = deviceMapper.getDataOverview();
|
||||
return dataOverviewVo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取设备分类
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public EquipmentClassificationVo getEquipmentClassification() {
|
||||
EquipmentClassificationVo equipmentClassification = deviceMapper.getEquipmentClassification();
|
||||
return equipmentClassification;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取告警信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AlarmInformationVo getAlarmInformation() {
|
||||
AlarmInformationVo alarmInformation = deviceMapper.getAlarmInformation();
|
||||
return alarmInformation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备使用数据
|
||||
*
|
||||
* @param deviceId 设备ID
|
||||
* @param range 时间范围 1:半年 2:一年
|
||||
* @return 每月使用数据列表
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> getEquipmentUsageData(Long deviceId, Integer range) {
|
||||
List<Map<String, Object>> equipmentUsageData = deviceMapper.getEquipmentUsageData(deviceId, range);
|
||||
return equipmentUsageData;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -74,6 +74,9 @@
|
||||
<if test="criteria.groupId != null">
|
||||
and d.group_id = #{criteria.groupId}
|
||||
</if>
|
||||
<if test="criteria.communicationMode != null">
|
||||
and t.communication_mode = #{criteria.communicationMode}
|
||||
</if>
|
||||
<if test="criteria.params.beginTime != null and criteria.params.endTime != null">
|
||||
and da.create_time between #{criteria.params.beginTime} and #{criteria.params.endTime}
|
||||
</if>
|
||||
@ -278,9 +281,13 @@
|
||||
<if test="criteria.groupId != null">
|
||||
and d.group_id = #{criteria.groupId}
|
||||
</if>
|
||||
<if test="criteria.onlineStatus != null">
|
||||
and d.online_status = #{criteria.onlineStatus}
|
||||
</if>
|
||||
ORDER BY d.create_time DESC
|
||||
</select>
|
||||
<select id="getLocationHistory" resultType="com.fuyuanshen.equipment.domain.vo.LocationHistoryVo">
|
||||
select a.id,a.device_name,a.device_type,b.type_name deviceTypeName,a.device_imei,a.device_mac from device a
|
||||
select a.id,a.device_name,a.device_type,b.type_name deviceTypeName,a.device_imei,a.device_mac from device a
|
||||
inner join device_type b on a.device_type = b.id
|
||||
|
||||
<if test="bo.deviceType != null">
|
||||
@ -311,4 +318,93 @@
|
||||
a.create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 获取数据总览 -->
|
||||
<select id="getDataOverview" resultType="com.fuyuanshen.equipment.domain.vo.DataOverviewVo">
|
||||
SELECT (SELECT COUNT(1) FROM device) AS devicesNumber,
|
||||
(SELECT COUNT(1) FROM device WHERE device_status = 1) AS equipmentOnline,
|
||||
(SELECT COUNT(1) FROM device WHERE DATE (create_time) = CURDATE()) AS bindingNew, (
|
||||
SELECT COUNT (1)
|
||||
FROM device
|
||||
WHERE device_status = 2) AS equipmentAbnormal
|
||||
</select>
|
||||
|
||||
<!-- 获取设备分类 -->
|
||||
<select id="getEquipmentClassification"
|
||||
resultType="com.fuyuanshen.equipment.domain.vo.EquipmentClassificationVo">
|
||||
SELECT (SELECT COUNT(1)
|
||||
FROM device d
|
||||
INNER JOIN device_type dt ON d.device_type = dt.id
|
||||
WHERE dt.communication_mode = 0) AS equipment4G,
|
||||
(SELECT COUNT(1)
|
||||
FROM device d
|
||||
INNER JOIN device_type dt ON d.device_type = dt.id
|
||||
WHERE dt.communication_mode = 1) AS deviceBluetooth,
|
||||
(SELECT COUNT(1)
|
||||
FROM device d
|
||||
INNER JOIN device_type dt ON d.device_type = dt.id
|
||||
WHERE dt.communication_mode = 2) AS devices4GAndBluetooth
|
||||
</select>
|
||||
|
||||
<!-- 获取告警信息 -->
|
||||
<select id="getAlarmInformation" resultType="com.fuyuanshen.equipment.domain.vo.AlarmInformationVo">
|
||||
SELECT (SELECT COUNT(1) FROM device_alarm WHERE treatment_state = 0 AND DATE (create_time) = CURDATE()) AS alarmsTotal, (
|
||||
SELECT COUNT (1)
|
||||
FROM device_alarm
|
||||
WHERE treatment_state = 0
|
||||
AND DATE (create_time) = CURDATE()) AS processingAlarm
|
||||
, (
|
||||
SELECT COUNT (1)
|
||||
FROM device_alarm
|
||||
WHERE device_action = 0
|
||||
AND DATE (create_time) = CURDATE()) AS alarmForced
|
||||
, (
|
||||
SELECT COUNT (1)
|
||||
FROM device_alarm
|
||||
WHERE device_action = 1
|
||||
AND DATE (create_time) = CURDATE()) AS intrusionImpact
|
||||
, (
|
||||
SELECT COUNT (1)
|
||||
FROM device_alarm
|
||||
WHERE device_action = 2
|
||||
AND DATE (create_time) = CURDATE()) AS alarmManual
|
||||
, (
|
||||
SELECT COUNT (1)
|
||||
FROM device_alarm
|
||||
WHERE device_action = 3 AND DATE (create_time) = CURDATE()) AS fenceElectronic
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 获取设备使用数据 -->
|
||||
<select id="getEquipmentUsageData" resultType="map">
|
||||
SELECT COUNT(CASE WHEN MONTH (dl.create_time) = 1 THEN 1 END) AS m1,
|
||||
COUNT(CASE WHEN MONTH (dl.create_time) = 2 THEN 1 END) AS m2,
|
||||
COUNT(CASE WHEN MONTH (dl.create_time) = 3 THEN 1 END) AS m3,
|
||||
COUNT(CASE WHEN MONTH (dl.create_time) = 4 THEN 1 END) AS m4,
|
||||
COUNT(CASE WHEN MONTH (dl.create_time) = 5 THEN 1 END) AS m5,
|
||||
COUNT(CASE WHEN MONTH (dl.create_time) = 6 THEN 1 END) AS m6,
|
||||
COUNT(CASE WHEN MONTH (dl.create_time) = 7 THEN 1 END) AS m7,
|
||||
COUNT(CASE WHEN MONTH (dl.create_time) = 8 THEN 1 END) AS m8,
|
||||
COUNT(CASE WHEN MONTH (dl.create_time) = 9 THEN 1 END) AS m9,
|
||||
COUNT(CASE WHEN MONTH (dl.create_time) = 10 THEN 1 END) AS m10,
|
||||
COUNT(CASE WHEN MONTH (dl.create_time) = 11 THEN 1 END) AS m11,
|
||||
COUNT(CASE WHEN MONTH (dl.create_time) = 12 THEN 1 END) AS m12
|
||||
FROM device_log dl
|
||||
LEFT JOIN device d ON dl.device_id = d.id
|
||||
LEFT JOIN device_type dt ON d.device_type = dt.id
|
||||
WHERE dt.id = #{deviceId}
|
||||
AND (
|
||||
(#{range} = 1 AND dl.create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH)) OR
|
||||
(#{range} = 2 AND dl.create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH))
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="getUsageDataForMonth" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM device_log dl
|
||||
WHERE dl.device_id = #{deviceId}
|
||||
AND YEAR (
|
||||
dl.create_time) = #{year}
|
||||
AND MONTH (dl.create_time) = #{month}
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -56,7 +56,7 @@ public class ${ClassName}Controller extends BaseController {
|
||||
#end
|
||||
|
||||
/**
|
||||
* 导出${functionName}列表
|
||||
* ${functionName}列表
|
||||
*/
|
||||
@SaCheckPermission("${permissionPrefix}:export")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
||||
|
Reference in New Issue
Block a user