首页数据
This commit is contained in:
@ -1,27 +1,27 @@
|
||||
package com.fuyuanshen.web.controller.device;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
|
||||
import com.fuyuanshen.common.log.annotation.Log;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||
import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.common.log.enums.BusinessType;
|
||||
import com.fuyuanshen.common.excel.utils.ExcelUtil;
|
||||
import com.fuyuanshen.equipment.domain.vo.DeviceGroupVo;
|
||||
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
|
||||
import com.fuyuanshen.common.log.annotation.Log;
|
||||
import com.fuyuanshen.common.log.enums.BusinessType;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.equipment.domain.bo.DeviceGroupBo;
|
||||
import com.fuyuanshen.equipment.domain.vo.DeviceGroupVo;
|
||||
import com.fuyuanshen.equipment.service.IDeviceGroupService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备分组
|
||||
@ -51,6 +51,24 @@ public class DeviceGroupController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询设备分组列表(分页)
|
||||
*/
|
||||
@Operation(summary = "查询设备分组列表(分页)")
|
||||
@SaCheckPermission("fys-equipment:group:list")
|
||||
@GetMapping("/listPage")
|
||||
public TableDataInfo<DeviceGroupVo> listPage(DeviceGroupBo bo) {
|
||||
List<DeviceGroupVo> list = deviceGroupService.queryList(bo);
|
||||
// return R.ok(list);
|
||||
return null;
|
||||
}
|
||||
|
||||
// @GetMapping("/list")
|
||||
// public TableDataInfo<DeviceAlarmVo> list(DeviceAlarmBo bo, PageQuery pageQuery) {
|
||||
// return deviceAlarmService.queryPageList(bo, pageQuery);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 导出设备分组列表
|
||||
*/
|
||||
@ -110,7 +128,7 @@ public class DeviceGroupController extends BaseController {
|
||||
@SaCheckPermission("fys-equipment:group:remove")
|
||||
@Log(title = "设备分组", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) {
|
||||
public R<Void> remove(@NotNull(message = "主键不能为空") @PathVariable Long[] ids) {
|
||||
return toAjax(deviceGroupService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
|
||||
@ -124,11 +142,25 @@ public class DeviceGroupController extends BaseController {
|
||||
@Operation(summary = "绑定设备分组")
|
||||
// @SaCheckPermission("fys-equipment:group:remove")
|
||||
@Log(title = "绑定设备分组", businessType = BusinessType.DELETE)
|
||||
@GetMapping("/groupId/{deviceId}")
|
||||
public R<Void> bindingDevice(@NotEmpty(message = "分组id 不能为空") @PathVariable Long groupId,
|
||||
@NotEmpty(message = "设备id 不能为空") @PathVariable Long[] deviceId) {
|
||||
@GetMapping("/groupId/{groupId}/{deviceId}")
|
||||
public R<Void> bindingDevice(@NotNull(message = "分组id 不能为空") @PathVariable Long groupId,
|
||||
@NotNull(message = "设备id 不能为空") @PathVariable Long[] deviceId) {
|
||||
return toAjax(deviceGroupService.bindingDevice(groupId, deviceId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解绑设备分组
|
||||
*
|
||||
* @param deviceId 设备id
|
||||
*/
|
||||
@Operation(summary = "解绑设备分组")
|
||||
// @SaCheckPermission("fys-equipment:group:remove")
|
||||
@Log(title = "解绑设备分组", businessType = BusinessType.DELETE)
|
||||
@GetMapping("/groupUnbind/{deviceId}")
|
||||
public R<Void> groupUnbind(@NotNull(message = "设备id 不能为空") @PathVariable Long[] deviceId) {
|
||||
return toAjax(deviceGroupService.groupUnbind(deviceId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
package com.fuyuanshen.web.controller.device;
|
||||
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.equipment.domain.vo.DataOverviewVo;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 首页数据
|
||||
*
|
||||
* @author: 默苍璃
|
||||
* @date: 2025-09-0113:46
|
||||
*/
|
||||
@Tag(name = "首页数据", description = "首页数据")
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/api/device/homepage")
|
||||
public class HomePageController {
|
||||
|
||||
private final DeviceService deviceService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取 数据总览
|
||||
* DataOverview
|
||||
*/
|
||||
@GetMapping("/getDataOverview")
|
||||
public R<DataOverviewVo> getDataOverview() {
|
||||
return R.ok(deviceService.getDataOverview());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 获取设备使用数据
|
||||
@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;
|
||||
}
|
||||
}
|
@ -53,7 +53,7 @@ public class WEBDeviceController extends BaseController {
|
||||
*/
|
||||
@Operation(summary = "设备详情")
|
||||
@GetMapping(value = "/pc/detail/{id}")
|
||||
public R<WebDeviceVo> getDevice(@PathVariable Long id) {
|
||||
public R<WebDeviceVo> getDeviceDetail(@PathVariable Long id) {
|
||||
WebDeviceVo device = deviceService.getDevice(id);
|
||||
return R.ok(device);
|
||||
}
|
||||
@ -101,7 +101,6 @@ public class WEBDeviceController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -382,7 +382,7 @@ public class DeviceBizService {
|
||||
detailVo.setDeviceName(device.getDeviceName());
|
||||
detailVo.setStartLocation(entry.getValue().get(0).getString("address"));
|
||||
detailVo.setEndLocation(entry.getValue().get(entry.getValue().size()-1).getString("address"));
|
||||
detailVo.setDetailList(entry.getValue());
|
||||
// detailVo.setDetailList(entry.getValue());
|
||||
result.add(detailVo);
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,13 @@ public class Device extends TenantEntity {
|
||||
@Schema(title = "ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@Schema(title = "设备ID")
|
||||
private Long deviceId;
|
||||
|
||||
@Schema(title = "设备记录ID")
|
||||
@TableField(exist = false)
|
||||
private Long assignId;
|
||||
|
@ -101,13 +101,11 @@ public class DeviceQueryCriteria extends BaseEntity {
|
||||
*/
|
||||
private Boolean isAdmin = false;
|
||||
|
||||
|
||||
/**
|
||||
* 设备所属分组
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
|
||||
/**
|
||||
* 设备地区
|
||||
*/
|
||||
|
@ -0,0 +1,44 @@
|
||||
package com.fuyuanshen.equipment.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 报警信息
|
||||
*
|
||||
* @author: 默苍璃
|
||||
* @date: 2025-09-0114:24
|
||||
*/
|
||||
@Data
|
||||
public class AlarmInformationVo {
|
||||
|
||||
/**
|
||||
* 报警总数
|
||||
*/
|
||||
private Integer alarmsTotal = 0;
|
||||
|
||||
/**
|
||||
* 总处理报警
|
||||
*/
|
||||
private Integer processingAlarm = 0;
|
||||
|
||||
/**
|
||||
* 强制报警
|
||||
*/
|
||||
private Integer alarmForced = 0;
|
||||
|
||||
/**
|
||||
* 撞击闯入
|
||||
*/
|
||||
private Integer intrusionImpact = 0;
|
||||
|
||||
/**
|
||||
* 手动报警
|
||||
*/
|
||||
private Integer alarmManual = 0;
|
||||
|
||||
/**
|
||||
* 电子围栏
|
||||
*/
|
||||
private Integer fenceElectronic = 0;
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.fuyuanshen.equipment.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 数据总览
|
||||
*
|
||||
* @author: 默苍璃
|
||||
* @date: 2025-09-0114:24
|
||||
*/
|
||||
@Data
|
||||
public class DataOverviewVo {
|
||||
|
||||
/**
|
||||
* 设备数据量
|
||||
*/
|
||||
private Integer devicesNumber = 0;
|
||||
|
||||
/**
|
||||
* 在线设备
|
||||
*/
|
||||
private Integer equipmentOnline = 0;
|
||||
|
||||
/**
|
||||
* 新增绑定设备
|
||||
*/
|
||||
private Integer bindingNew = 0;
|
||||
|
||||
/**
|
||||
* 异常设备
|
||||
*/
|
||||
private Integer equipmentAbnormal = 0;
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.fuyuanshen.equipment.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 设备分类
|
||||
*
|
||||
* @author: 默苍璃
|
||||
* @date: 2025-09-0114:24
|
||||
*/
|
||||
@Data
|
||||
public class EquipmentClassificationVo {
|
||||
|
||||
/**
|
||||
* 4G设备
|
||||
*/
|
||||
private Integer equipment4G = 0;
|
||||
|
||||
/**
|
||||
* 蓝牙设备
|
||||
*/
|
||||
private Integer deviceBluetooth = 0;
|
||||
|
||||
/**
|
||||
* 4G & 蓝牙 设备
|
||||
*/
|
||||
private Integer devices4GAndBluetooth = 0;
|
||||
|
||||
}
|
@ -32,10 +32,10 @@ public class LocationHistoryDetailVo {
|
||||
@ExcelProperty(value = "结束地点")
|
||||
private String endLocation;
|
||||
|
||||
/**
|
||||
* 轨迹详情
|
||||
*/
|
||||
@ExcelProperty(value = "轨迹详情")
|
||||
private List<JSONObject> detailList;
|
||||
// /**
|
||||
// * 轨迹详情
|
||||
// */
|
||||
// @ExcelProperty(value = "轨迹详情")
|
||||
// private List<JSONObject> detailList;
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ 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 java.io.IOException;
|
||||
import java.util.List;
|
||||
@ -115,4 +116,10 @@ public interface DeviceService extends IService<Device> {
|
||||
*/
|
||||
int webUnBindDevice(Long id);
|
||||
|
||||
/**
|
||||
* 获取数据总览
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
DataOverviewVo getDataOverview();
|
||||
}
|
||||
|
@ -66,5 +66,13 @@ public interface IDeviceGroupService {
|
||||
* @param deviceId 设备id
|
||||
* @return 是否绑定成功
|
||||
*/
|
||||
Boolean bindingDevice(@NotEmpty(message = "分组id 不能为空") Long groupId, @NotEmpty(message = "设备id 不能为空") Long[] deviceId);
|
||||
Boolean bindingDevice(Long groupId, Long[] deviceId);
|
||||
|
||||
/**
|
||||
* 解绑设备分组
|
||||
*
|
||||
* @param deviceId 设备id
|
||||
* @return 是否解绑成功
|
||||
*/
|
||||
Boolean groupUnbind( Long[] deviceId);
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
vo.setId(group.getId());
|
||||
vo.setGroupName(group.getGroupName());
|
||||
vo.setStatus(group.getStatus() == 1 ? "正常" : "禁用");
|
||||
vo.setParentId(group.getParentId());
|
||||
vo.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(group.getCreateTime()));
|
||||
return vo;
|
||||
}
|
||||
@ -124,10 +125,12 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
throw new RuntimeException("分组名称已存在,请勿重复添加!!!");
|
||||
}
|
||||
|
||||
// 验证父分组是否存在(如果提供了parentId)
|
||||
DeviceGroup pDeviceGroup = baseMapper.selectById(bo.getParentId());
|
||||
if (bo.getParentId() != null && pDeviceGroup == null) {
|
||||
throw new RuntimeException("父分组不存在!!!");
|
||||
if (bo.getParentId() != null) {
|
||||
// 验证父分组是否存在(如果提供了parentId)
|
||||
DeviceGroup pDeviceGroup = baseMapper.selectById(bo.getParentId());
|
||||
if (bo.getParentId() != null && pDeviceGroup == null) {
|
||||
throw new RuntimeException("父分组不存在!!!");
|
||||
}
|
||||
}
|
||||
|
||||
DeviceGroup add = MapstructUtils.convert(bo, DeviceGroup.class);
|
||||
@ -199,4 +202,27 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解绑设备分组
|
||||
*
|
||||
* @param deviceId 设备id
|
||||
* @return 是否解绑成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean groupUnbind( Long[] deviceId) {
|
||||
|
||||
if (deviceId != null && deviceId.length > 0) {
|
||||
// 创建更新条件
|
||||
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.in("id", Arrays.asList(deviceId));
|
||||
updateWrapper.set("group_id", null);
|
||||
|
||||
// 执行批量更新
|
||||
deviceMapper.update(updateWrapper);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ 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.enums.BindingStatusEnum;
|
||||
import com.fuyuanshen.equipment.enums.CommunicationModeEnum;
|
||||
import com.fuyuanshen.equipment.enums.DeviceActiveStatusEnum;
|
||||
@ -595,6 +596,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询设备MAC号
|
||||
*
|
||||
@ -613,4 +616,14 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取数据总览
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public DataOverviewVo getDataOverview() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -157,11 +157,11 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
||||
throw new RuntimeException("设备类型不存在");
|
||||
}
|
||||
|
||||
List<Device> devices = deviceMapper.selectList(new QueryWrapper<Device>()
|
||||
.eq("device_type", deviceTypeGrants.getDeviceTypeId()));
|
||||
if (CollectionUtil.isNotEmpty(devices)) {
|
||||
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()));
|
||||
|
@ -41,7 +41,7 @@
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT
|
||||
da.id AS id, d.device_name, d.bluetooth_name,
|
||||
da.id AS id, d.id AS deviceId, d.device_name, d.bluetooth_name,
|
||||
d.pub_topic, d.sub_topic, d.device_pic,
|
||||
d.device_mac, d.device_sn, d.update_by,
|
||||
d.device_imei, d.update_time, dg.id AS device_type,
|
||||
@ -71,6 +71,9 @@
|
||||
<if test="criteria.deviceStatus != null">
|
||||
and da.active = #{criteria.deviceStatus}
|
||||
</if>
|
||||
<if test="criteria.groupId != null">
|
||||
and d.group_id = #{criteria.groupId}
|
||||
</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>
|
||||
|
Reference in New Issue
Block a user