Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
fcbde4322d | |||
832234269d | |||
7e87971c0b | |||
ebd8668178 |
@ -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.permission(bo));
|
return toAjax(deviceShareService.deviceShare(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,13 +61,15 @@ public class HomePageController {
|
|||||||
/**
|
/**
|
||||||
* 获取设备使用数据
|
* 获取设备使用数据
|
||||||
*
|
*
|
||||||
* @param deviceId 设备ID
|
* @param deviceTypeId 设备ID (可选)
|
||||||
* @param range 时间范围 1:半年 2:一年
|
* @param range 时间范围 1:半年 2:一年
|
||||||
* @return 每月使用数据列表
|
* @return 每月使用数据列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/getEquipmentUsageData/{deviceId}/{range}")
|
@GetMapping("/getEquipmentUsageData/{range}")
|
||||||
public R<List<Map<String, Object>>> getEquipmentUsageData(@PathVariable Long deviceId, @PathVariable Integer range) {
|
public R<List<Map<String, Object>>> getEquipmentUsageData(@PathVariable Integer range,
|
||||||
return R.ok(deviceService.getEquipmentUsageData(deviceId, range));
|
@RequestParam(required = false) Long deviceTypeId) {
|
||||||
|
return R.ok(deviceService.getEquipmentUsageData(deviceTypeId, range));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -212,46 +212,6 @@ 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<>();
|
||||||
|
@ -60,7 +60,7 @@ public class AppDeviceShareBo extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 分享时间
|
* 分享时间
|
||||||
*/
|
*/
|
||||||
private String shareStartTime;
|
private Date shareStartTime;
|
||||||
private String shareEndTime;
|
private Date shareEndTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -109,9 +109,4 @@ public class AppDeviceShareVo implements Serializable {
|
|||||||
* 告警状态(0解除告警,1告警)
|
* 告警状态(0解除告警,1告警)
|
||||||
*/
|
*/
|
||||||
private String alarmStatus;
|
private String alarmStatus;
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
private String createTime;
|
|
||||||
}
|
}
|
||||||
|
@ -72,12 +72,9 @@
|
|||||||
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 ad.phonenumber like concat('%',#{bo.shareUser},'%')
|
and u.user_name = #{bo.shareUser}
|
||||||
</if>
|
</if>
|
||||||
<if test="bo.phonenumber != null">
|
<if test="bo.shareStartTime != null and bo.hareEndTime != 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>
|
||||||
|
@ -21,6 +21,18 @@ public class AlarmInformationVo {
|
|||||||
*/
|
*/
|
||||||
private Integer processingAlarm = 0;
|
private Integer processingAlarm = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日报警总数
|
||||||
|
*/
|
||||||
|
private Integer alarmsTotalToday = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日总处理报警
|
||||||
|
*/
|
||||||
|
private Integer processingAlarmToday = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 强制报警
|
* 强制报警
|
||||||
*/
|
*/
|
||||||
|
@ -26,4 +26,24 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -99,11 +99,11 @@ public interface DeviceMapper extends BaseMapper<Device> {
|
|||||||
/**
|
/**
|
||||||
* 获取设备使用数据
|
* 获取设备使用数据
|
||||||
*
|
*
|
||||||
* @param deviceId 设备ID
|
* @param deviceTypeId 设备ID
|
||||||
* @param range 时间范围 1:半年 2:一年
|
* @param range 时间范围 1:半年 2:一年
|
||||||
* @return 每月使用数据列表
|
* @return 每月使用数据列表
|
||||||
*/
|
*/
|
||||||
List<Map<String, Object>> getEquipmentUsageData(Long deviceId, Integer range);
|
List<Map<String, Object>> getEquipmentUsageData(@Param("deviceTypeId") Long deviceTypeId, @Param("range") Integer range);
|
||||||
|
|
||||||
// 在DeviceMapper.java中添加方法
|
// 在DeviceMapper.java中添加方法
|
||||||
int getUsageDataForMonth(@Param("deviceId") Long deviceId,
|
int getUsageDataForMonth(@Param("deviceId") Long deviceId,
|
||||||
|
@ -139,9 +139,9 @@ public interface DeviceService extends IService<Device> {
|
|||||||
/**
|
/**
|
||||||
* 获取设备使用数据
|
* 获取设备使用数据
|
||||||
*
|
*
|
||||||
* @param deviceId
|
* @param deviceTypeId
|
||||||
* @param range
|
* @param range
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Map<String, Object>> getEquipmentUsageData(Long deviceId, Integer range);
|
List<Map<String, Object>> getEquipmentUsageData(Long deviceTypeId, Integer range);
|
||||||
}
|
}
|
||||||
|
@ -630,6 +630,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -648,13 +649,13 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
/**
|
/**
|
||||||
* 获取设备使用数据
|
* 获取设备使用数据
|
||||||
*
|
*
|
||||||
* @param deviceId 设备ID
|
* @param deviceTypeId 设备ID
|
||||||
* @param range 时间范围 1:半年 2:一年
|
* @param range 时间范围 1:半年 2:一年
|
||||||
* @return 每月使用数据列表
|
* @return 每月使用数据列表
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> getEquipmentUsageData(Long deviceId, Integer range) {
|
public List<Map<String, Object>> getEquipmentUsageData(Long deviceTypeId, Integer range) {
|
||||||
List<Map<String, Object>> equipmentUsageData = deviceMapper.getEquipmentUsageData(deviceId, range);
|
List<Map<String, Object>> equipmentUsageData = deviceMapper.getEquipmentUsageData(deviceTypeId, range);
|
||||||
return equipmentUsageData;
|
return equipmentUsageData;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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 device_status = 1) AS equipmentOnline,
|
(SELECT COUNT(1) FROM device WHERE online_status = 1) AS equipmentOnline,
|
||||||
(SELECT COUNT(1) FROM device WHERE DATE (create_time) = CURDATE()) AS bindingNew, (
|
(SELECT COUNT(1) FROM device WHERE DATE (create_time) = CURDATE() AND binding_status = 1 ) AS bindingNew, (
|
||||||
SELECT COUNT (1)
|
SELECT COUNT (1)
|
||||||
FROM device
|
FROM device
|
||||||
WHERE device_status = 2) AS equipmentAbnormal
|
WHERE online_status = 2) AS equipmentAbnormal
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 获取设备分类 -->
|
<!-- 获取设备分类 -->
|
||||||
@ -347,30 +347,38 @@
|
|||||||
|
|
||||||
<!-- 获取告警信息 -->
|
<!-- 获取告警信息 -->
|
||||||
<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 AND DATE (create_time) = CURDATE()) AS alarmsTotal, (
|
SELECT (SELECT COUNT(1) FROM device_alarm WHERE treatment_state = 0) 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 processingAlarm
|
AND DATE (create_time) = CURDATE()) AS processingAlarmToday
|
||||||
, (
|
, (
|
||||||
SELECT COUNT (1)
|
SELECT COUNT (1)
|
||||||
FROM device_alarm
|
FROM device_alarm
|
||||||
WHERE device_action = 0
|
WHERE device_action = 0
|
||||||
AND DATE (create_time) = CURDATE()) AS alarmForced
|
) AS alarmForced
|
||||||
, (
|
, (
|
||||||
SELECT COUNT (1)
|
SELECT COUNT (1)
|
||||||
FROM device_alarm
|
FROM device_alarm
|
||||||
WHERE device_action = 1
|
WHERE device_action = 1
|
||||||
AND DATE (create_time) = CURDATE()) AS intrusionImpact
|
) AS intrusionImpact
|
||||||
, (
|
, (
|
||||||
SELECT COUNT (1)
|
SELECT COUNT (1)
|
||||||
FROM device_alarm
|
FROM device_alarm
|
||||||
WHERE device_action = 2
|
WHERE device_action = 2
|
||||||
AND DATE (create_time) = CURDATE()) AS alarmManual
|
) AS alarmManual
|
||||||
, (
|
, (
|
||||||
SELECT COUNT (1)
|
SELECT COUNT (1)
|
||||||
FROM device_alarm
|
FROM device_alarm
|
||||||
WHERE device_action = 3 AND DATE (create_time) = CURDATE()) AS fenceElectronic
|
WHERE device_action = 3) AS fenceElectronic
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@ -391,11 +399,15 @@
|
|||||||
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 dt.id = #{deviceId}
|
<where>
|
||||||
|
<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">
|
||||||
|
Reference in New Issue
Block a user