1 Commits

Author SHA1 Message Date
801b0267e6 设备分享3 2025-09-09 17:01:51 +08:00
12 changed files with 89 additions and 88 deletions

View File

@ -67,7 +67,7 @@ public class DeviceShareController extends BaseController {
@RepeatSubmit() @RepeatSubmit()
@PostMapping("/permission") @PostMapping("/permission")
public R<Void> permission(@Validated(AddGroup.class) @RequestBody AppDeviceShareBo bo) { public R<Void> permission(@Validated(AddGroup.class) @RequestBody AppDeviceShareBo bo) {
return toAjax(deviceShareService.deviceShare(bo)); return toAjax(deviceShareService.permission(bo));
} }
/** /**

View File

@ -61,15 +61,13 @@ public class HomePageController {
/** /**
* 获取设备使用数据 * 获取设备使用数据
* *
* @param deviceTypeId 设备ID (可选) * @param deviceId 设备ID
* @param range 时间范围 1:半年 2:一年 * @param range 时间范围 1:半年 2:一年
* @return 每月使用数据列表 * @return 每月使用数据列表
*/ */
@GetMapping("/getEquipmentUsageData/{range}") @GetMapping("/getEquipmentUsageData/{deviceId}/{range}")
public R<List<Map<String, Object>>> getEquipmentUsageData(@PathVariable Integer range, public R<List<Map<String, Object>>> getEquipmentUsageData(@PathVariable Long deviceId, @PathVariable Integer range) {
@RequestParam(required = false) Long deviceTypeId) { return R.ok(deviceService.getEquipmentUsageData(deviceId, range));
return R.ok(deviceService.getEquipmentUsageData(deviceTypeId, range));
} }
} }

View File

@ -212,6 +212,46 @@ public class DeviceShareService {
LambdaQueryWrapper<AppDeviceBindRecord> qw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<AppDeviceBindRecord> qw = new LambdaQueryWrapper<>();
qw.eq(AppDeviceBindRecord::getDeviceId, bo.getDeviceId()); qw.eq(AppDeviceBindRecord::getDeviceId, bo.getDeviceId());
AppDeviceBindRecord bindRecord = appDeviceBindRecordMapper.selectOne(qw); AppDeviceBindRecord bindRecord = appDeviceBindRecordMapper.selectOne(qw);
if (bindRecord == null) {
throw new ServiceException("设备未绑定");
}
Long userId = bindRecord.getBindingUserId();
LambdaQueryWrapper<AppDeviceShare> lqw = new LambdaQueryWrapper<>();
lqw.eq(AppDeviceShare::getDeviceId, bo.getDeviceId());
lqw.eq(AppDeviceShare::getPhonenumber, bo.getPhonenumber());
Long count = appDeviceShareMapper.selectCount(lqw);
if (count > 0) {
UpdateWrapper<AppDeviceShare> uw = new UpdateWrapper<>();
uw.eq("device_id", bo.getDeviceId());
uw.eq("phonenumber", bo.getPhonenumber());
uw.set("permission", bo.getPermission());
uw.set("update_by", userId);
uw.set("update_time", new Date());
return appDeviceShareMapper.update(uw);
} else {
AppDeviceShare appDeviceShare = new AppDeviceShare();
appDeviceShare.setDeviceId(bo.getDeviceId());
appDeviceShare.setPhonenumber(bo.getPhonenumber());
appDeviceShare.setPermission(bo.getPermission());
appDeviceShare.setCreateBy(userId);
return appDeviceShareMapper.insert(appDeviceShare);
}
}
public int permission(AppDeviceShareBo bo) {
Device device = deviceMapper.selectById(bo.getDeviceId());
if (device == null) {
throw new ServiceException("设备不存在");
}
LambdaQueryWrapper<AppDeviceBindRecord> qw = new LambdaQueryWrapper<>();
qw.eq(AppDeviceBindRecord::getDeviceId, bo.getDeviceId());
AppDeviceBindRecord bindRecord = appDeviceBindRecordMapper.selectOne(qw);
if (bindRecord == null) {
throw new ServiceException("设备未绑定");
}
Long userId = bindRecord.getBindingUserId(); Long userId = bindRecord.getBindingUserId();
LambdaQueryWrapper<AppDeviceShare> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<AppDeviceShare> lqw = new LambdaQueryWrapper<>();

View File

@ -60,7 +60,7 @@ public class AppDeviceShareBo extends BaseEntity {
/** /**
* 分享时间 * 分享时间
*/ */
private Date shareStartTime; private String shareStartTime;
private Date shareEndTime; private String shareEndTime;
} }

View File

@ -109,4 +109,9 @@ public class AppDeviceShareVo implements Serializable {
* 告警状态(0解除告警1告警) * 告警状态(0解除告警1告警)
*/ */
private String alarmStatus; private String alarmStatus;
/**
* 创建时间
*/
private String createTime;
} }

View File

@ -72,9 +72,12 @@
and ad.device_id = #{bo.deviceId} and ad.device_id = #{bo.deviceId}
</if> </if>
<if test="bo.shareUser != null"> <if test="bo.shareUser != null">
and u.user_name = #{bo.shareUser} and ad.phonenumber like concat('%',#{bo.shareUser},'%')
</if> </if>
<if test="bo.shareStartTime != null and bo.hareEndTime != null"> <if test="bo.phonenumber != null">
and ad.phonenumber like concat('%',#{bo.phonenumber},'%')
</if>
<if test="bo.shareStartTime != null and bo.shareEndTime != null">
and ad.create_time between #{bo.shareStartTime} and #{bo.shareEndTime} and ad.create_time between #{bo.shareStartTime} and #{bo.shareEndTime}
</if> </if>
</where> </where>

View File

@ -21,18 +21,6 @@ public class AlarmInformationVo {
*/ */
private Integer processingAlarm = 0; private Integer processingAlarm = 0;
/**
* 今日报警总数
*/
private Integer alarmsTotalToday = 0;
/**
* 今日总处理报警
*/
private Integer processingAlarmToday = 0;
/** /**
* 强制报警 * 强制报警
*/ */

View File

@ -26,24 +26,4 @@ public class EquipmentClassificationVo {
*/ */
private Integer devices4GAndBluetooth = 0; private Integer devices4GAndBluetooth = 0;
/**
* 设备总数
*/
private Integer total;
/**
* 计算设备总数
*
* @return 设备总数
*/
public Integer getTotal() {
if (total == null) {
total = (equipment4G == null ? 0 : equipment4G) +
(deviceBluetooth == null ? 0 : deviceBluetooth) +
(devices4GAndBluetooth == null ? 0 : devices4GAndBluetooth);
}
return total;
}
} }

View File

@ -99,11 +99,11 @@ public interface DeviceMapper extends BaseMapper<Device> {
/** /**
* 获取设备使用数据 * 获取设备使用数据
* *
* @param deviceTypeId 设备ID * @param deviceId 设备ID
* @param range 时间范围 1:半年 2:一年 * @param range 时间范围 1:半年 2:一年
* @return 每月使用数据列表 * @return 每月使用数据列表
*/ */
List<Map<String, Object>> getEquipmentUsageData(@Param("deviceTypeId") Long deviceTypeId, @Param("range") Integer range); List<Map<String, Object>> getEquipmentUsageData(Long deviceId, Integer range);
// 在DeviceMapper.java中添加方法 // 在DeviceMapper.java中添加方法
int getUsageDataForMonth(@Param("deviceId") Long deviceId, int getUsageDataForMonth(@Param("deviceId") Long deviceId,

View File

@ -139,9 +139,9 @@ public interface DeviceService extends IService<Device> {
/** /**
* 获取设备使用数据 * 获取设备使用数据
* *
* @param deviceTypeId * @param deviceId
* @param range * @param range
* @return * @return
*/ */
List<Map<String, Object>> getEquipmentUsageData(Long deviceTypeId, Integer range); List<Map<String, Object>> getEquipmentUsageData(Long deviceId, Integer range);
} }

View File

@ -630,7 +630,6 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
@Override @Override
public EquipmentClassificationVo getEquipmentClassification() { public EquipmentClassificationVo getEquipmentClassification() {
EquipmentClassificationVo equipmentClassification = deviceMapper.getEquipmentClassification(); EquipmentClassificationVo equipmentClassification = deviceMapper.getEquipmentClassification();
equipmentClassification.getTotal();
return equipmentClassification; return equipmentClassification;
} }
@ -649,13 +648,13 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
/** /**
* 获取设备使用数据 * 获取设备使用数据
* *
* @param deviceTypeId 设备ID * @param deviceId 设备ID
* @param range 时间范围 1:半年 2:一年 * @param range 时间范围 1:半年 2:一年
* @return 每月使用数据列表 * @return 每月使用数据列表
*/ */
@Override @Override
public List<Map<String, Object>> getEquipmentUsageData(Long deviceTypeId, Integer range) { public List<Map<String, Object>> getEquipmentUsageData(Long deviceId, Integer range) {
List<Map<String, Object>> equipmentUsageData = deviceMapper.getEquipmentUsageData(deviceTypeId, range); List<Map<String, Object>> equipmentUsageData = deviceMapper.getEquipmentUsageData(deviceId, range);
return equipmentUsageData; return equipmentUsageData;
} }

View File

@ -321,11 +321,11 @@
<!-- 获取数据总览 --> <!-- 获取数据总览 -->
<select id="getDataOverview" resultType="com.fuyuanshen.equipment.domain.vo.DataOverviewVo"> <select id="getDataOverview" resultType="com.fuyuanshen.equipment.domain.vo.DataOverviewVo">
SELECT (SELECT COUNT(1) FROM device) AS devicesNumber, SELECT (SELECT COUNT(1) FROM device) AS devicesNumber,
(SELECT COUNT(1) FROM device WHERE online_status = 1) AS equipmentOnline, (SELECT COUNT(1) FROM device WHERE device_status = 1) AS equipmentOnline,
(SELECT COUNT(1) FROM device WHERE DATE (create_time) = CURDATE() AND binding_status = 1 ) AS bindingNew, ( (SELECT COUNT(1) FROM device WHERE DATE (create_time) = CURDATE()) AS bindingNew, (
SELECT COUNT (1) SELECT COUNT (1)
FROM device FROM device
WHERE online_status = 2) AS equipmentAbnormal WHERE device_status = 2) AS equipmentAbnormal
</select> </select>
<!-- 获取设备分类 --> <!-- 获取设备分类 -->
@ -347,38 +347,30 @@
<!-- 获取告警信息 --> <!-- 获取告警信息 -->
<select id="getAlarmInformation" resultType="com.fuyuanshen.equipment.domain.vo.AlarmInformationVo"> <select id="getAlarmInformation" resultType="com.fuyuanshen.equipment.domain.vo.AlarmInformationVo">
SELECT (SELECT COUNT(1) FROM device_alarm WHERE treatment_state = 0) AS alarmsTotal 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) AS processingAlarm
, (SELECT COUNT(1)
FROM device_alarm
WHERE treatment_state = 0 AND
DATE (create_time) = CURDATE()) AS alarmsTotalToday
, (
SELECT COUNT (1) SELECT COUNT (1)
FROM device_alarm FROM device_alarm
WHERE treatment_state = 0 WHERE treatment_state = 0
AND DATE (create_time) = CURDATE()) AS processingAlarmToday AND DATE (create_time) = CURDATE()) AS processingAlarm
, ( , (
SELECT COUNT (1) SELECT COUNT (1)
FROM device_alarm FROM device_alarm
WHERE device_action = 0 WHERE device_action = 0
) AS alarmForced AND DATE (create_time) = CURDATE()) AS alarmForced
, ( , (
SELECT COUNT (1) SELECT COUNT (1)
FROM device_alarm FROM device_alarm
WHERE device_action = 1 WHERE device_action = 1
) AS intrusionImpact AND DATE (create_time) = CURDATE()) AS intrusionImpact
, ( , (
SELECT COUNT (1) SELECT COUNT (1)
FROM device_alarm FROM device_alarm
WHERE device_action = 2 WHERE device_action = 2
) AS alarmManual AND DATE (create_time) = CURDATE()) AS alarmManual
, ( , (
SELECT COUNT (1) SELECT COUNT (1)
FROM device_alarm FROM device_alarm
WHERE device_action = 3) AS fenceElectronic WHERE device_action = 3 AND DATE (create_time) = CURDATE()) AS fenceElectronic
</select> </select>
@ -399,15 +391,11 @@
FROM device_log dl FROM device_log dl
LEFT JOIN device d ON dl.device_id = d.id LEFT JOIN device d ON dl.device_id = d.id
LEFT JOIN device_type dt ON d.device_type = dt.id LEFT JOIN device_type dt ON d.device_type = dt.id
<where> WHERE dt.id = #{deviceId}
<if test="deviceTypeId != null">
dt.id = #{deviceTypeId}
</if>
AND ( AND (
(#{range} = 1 AND dl.create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH)) OR (#{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)) (#{range} = 2 AND dl.create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH))
) )
</where>
</select> </select>
<select id="getUsageDataForMonth" resultType="java.lang.Integer"> <select id="getUsageDataForMonth" resultType="java.lang.Integer">