设备类型、查询设备下拉框和设备类型接口

This commit is contained in:
liux 2025-06-19 11:06:43 +08:00
parent 4bc462feb9
commit 3d929972d9
21 changed files with 342 additions and 18 deletions

View File

@ -2,6 +2,10 @@ package com.bonus.common.houqin.constant;
import lombok.Generated;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public enum DeviceTypeEnum {
OTHER(0, "其他"),
CAMERA(1, "摄像头"),
@ -48,6 +52,14 @@ public enum DeviceTypeEnum {
this.value = value;
}
public static Map<Integer, String> toMap() {
return Stream.of(DeviceTypeEnum.values())
.collect(Collectors.toMap(
DeviceTypeEnum::getKey,
DeviceTypeEnum::getValue
));
}
public Integer getKey() {
return this.key;
}

View File

@ -45,7 +45,6 @@ public class KitchenDeviceInfoController extends BaseController {
* 查询厨房设备基础信息列表
*/
@ApiOperation(value = "查询厨房设备基础信息列表")
//@RequiresPermissions("kitchen:info:list")
@GetMapping("/list")
public TableDataInfo list(KitchenDeviceListDTO kitchenDeviceInfo) {
startPage();
@ -53,6 +52,28 @@ public class KitchenDeviceInfoController extends BaseController {
return getDataTable(list);
}
@ApiOperation(value = "查询厨房设备基础信息列表")
@GetMapping("/select")
public AjaxResult select(KitchenDeviceListDTO kitchenDeviceInfo) {
try{
List<KitchenDeviceInfo> list = kitchenDeviceInfoService.selectKitchenDeviceInfoSelect(kitchenDeviceInfo);
return success(list);
}catch (Exception e) {
return error(e.getMessage());
}
}
@ApiOperation(value = "查询厨房设备基础信息列表")
//@RequiresPermissions("kitchen:info:list")
@GetMapping("/deviceType")
public AjaxResult deviceType() {
try{
return success(kitchenDeviceInfoService.deviceType());
}catch (Exception e) {
return error(e.getMessage());
}
}
/**
* 导出厨房设备基础信息列表
*/

View File

@ -1,13 +1,18 @@
package com.bonus.canteen.core.kitchen.controller;
import com.bonus.canteen.core.kitchen.dto.IndexHomePageDTO;
import com.bonus.canteen.core.kitchen.dto.KitchenDeviceListDTO;
import com.bonus.canteen.core.kitchen.service.IKitchenHomePageService;
import com.bonus.canteen.core.kitchen.vo.IndexHomePageInformationVO;
import com.bonus.canteen.core.kitchen.vo.KitchenDeviceListVO;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
@ -21,13 +26,19 @@ import java.util.List;
@RequestMapping("/kitchen_home_page")
public class KitchenHomePageController extends BaseController {
@Resource
private IKitchenHomePageService kitchenHomePageService;
@ApiOperation(value = "获取首页信息")
//@RequiresPermissions("kitchen:info:list")
@GetMapping("/information")
public TableDataInfo list(KitchenDeviceListDTO kitchenDeviceInfo) {
return null;
public AjaxResult list(IndexHomePageDTO indexHomePageDTO) {
try {
IndexHomePageInformationVO indexHomePageInformationVO = kitchenHomePageService.getIndexHomePageInformation(indexHomePageDTO);
return success(indexHomePageInformationVO);
} catch (Exception e) {
return error(e.getMessage());
}
}
}

View File

@ -0,0 +1,20 @@
package com.bonus.canteen.core.kitchen.dto;
import lombok.Data;
import lombok.ToString;
import java.time.LocalDateTime;
/**
* @author xliu
* @date 2025/6/18 17:51
*/
@Data
@ToString
public class IndexHomePageDTO {
private LocalDateTime startTime; // 当前时间
private LocalDateTime endTime; // 厨房名称
}

View File

@ -40,7 +40,7 @@ public class KitchenDeviceListDTO {
/** 设备类型(1-摄像头 2-传感器 3-门禁 4-仪表 5-仪器, 参考DeviceTypeEnum) */
@ApiModelProperty(value = "设备类型(1-摄像头 2-传感器 3-门禁 4-仪表 5-仪器, 参考DeviceTypeEnum)")
private Integer deviceType;
private Integer deviceType = 0;
/** 设备类型 */
@ApiModelProperty(value = "设备类型")

View File

@ -22,6 +22,8 @@ public interface KitchenDeviceInfoMapper extends BaseMapper<KitchenDeviceInfo> {
*/
public KitchenDeviceListVO selectKitchenDeviceInfoByDeviceId(Long deviceId);
public KitchenDeviceInfo selectKitchenDeviceInfoByDeviceIdk(Long deviceId);
/**
* 查询厨房设备基础信息列表
*

View File

@ -1,6 +1,7 @@
package com.bonus.canteen.core.kitchen.service;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bonus.canteen.core.kitchen.domain.KitchenDeviceInfo;
@ -61,4 +62,8 @@ public interface IKitchenDeviceInfoService extends IService<KitchenDeviceInfo> {
* @return 结果
*/
public int deleteKitchenDeviceInfoByDeviceId(Long deviceId);
List<KitchenDeviceInfo> selectKitchenDeviceInfoSelect(KitchenDeviceListDTO kitchenDeviceInfo);
Map<Integer, String> deviceType();
}

View File

@ -2,7 +2,9 @@ package com.bonus.canteen.core.kitchen.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bonus.canteen.core.kitchen.domain.KitchenDeviceInfo;
import com.bonus.canteen.core.kitchen.dto.IndexHomePageDTO;
import com.bonus.canteen.core.kitchen.dto.KitchenDeviceListDTO;
import com.bonus.canteen.core.kitchen.vo.IndexHomePageInformationVO;
import com.bonus.canteen.core.kitchen.vo.KitchenDeviceListVO;
import java.util.List;
@ -15,4 +17,5 @@ import java.util.List;
*/
public interface IKitchenHomePageService{
IndexHomePageInformationVO getIndexHomePageInformation(IndexHomePageDTO indexHomePageDTO);
}

View File

@ -2,7 +2,8 @@ package com.bonus.canteen.core.kitchen.service.impl;
import java.io.IOException;
import java.net.InetAddress;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -11,6 +12,9 @@ import com.bonus.canteen.core.kitchen.dto.KitchenDeviceListDTO;
import com.bonus.canteen.core.kitchen.vo.KitchenDeviceListVO;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.houqin.constant.DelFlagEnum;
import com.bonus.common.houqin.constant.DeviceTypeEnum;
import org.hibernate.validator.internal.util.StringHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -196,4 +200,30 @@ public class KitchenDeviceInfoServiceImpl extends ServiceImpl<KitchenDeviceInfoM
public int deleteKitchenDeviceInfoByDeviceId(Long deviceId) {
return kitchenDeviceInfoMapper.deleteKitchenDeviceInfoByDeviceId(deviceId);
}
@Override
public List<KitchenDeviceInfo> selectKitchenDeviceInfoSelect(KitchenDeviceListDTO kitchenDeviceInfo) {
return kitchenDeviceInfoMapper.selectList(
Wrappers.<KitchenDeviceInfo>lambdaQuery()
.like(StringUtils.isNotEmpty(kitchenDeviceInfo.getDeviceName()), KitchenDeviceInfo::getDeviceName, kitchenDeviceInfo.getDeviceName())
.like(StringUtils.isNotEmpty(kitchenDeviceInfo.getDeviceNo()), KitchenDeviceInfo::getDeviceNo, kitchenDeviceInfo.getDeviceNo())
.like(StringUtils.isNotEmpty(kitchenDeviceInfo.getDeviceSn()), KitchenDeviceInfo::getDeviceSn, kitchenDeviceInfo.getDeviceSn())
.eq(kitchenDeviceInfo.getDeviceType() != 0, KitchenDeviceInfo::getDeviceType, kitchenDeviceInfo.getDeviceType())
.eq(KitchenDeviceInfo::getDelFlag, DelFlagEnum.DEL_TRUE.key()) // 仅查询未删除的设备
);
}
@Override
public Map<Integer, String> deviceType() {
Map<Integer, String> deviceMap = DeviceTypeEnum.toMap();
String [] stringArray = new String[]{"摄像头","门禁","留样秤","留样柜","温湿度传感器","烟雾检测传感器","水表","电表","智能称重货架","智能厨余秤"};
// stringArray 转为 Set 便于快速查找
Set<String> validValues = new HashSet<>(Arrays.asList(stringArray));
// 使用 Stream 过滤只保留 value 存在于 validValues 中的条目
Map<Integer, String> filteredMap = deviceMap.entrySet().stream()
.filter(entry -> validValues.contains(entry.getValue()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
return filteredMap;
}
}

View File

@ -3,14 +3,17 @@ package com.bonus.canteen.core.kitchen.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bonus.canteen.core.kitchen.domain.KitchenDeviceInfo;
import com.bonus.canteen.core.kitchen.dto.IndexHomePageDTO;
import com.bonus.canteen.core.kitchen.dto.KitchenDeviceListDTO;
import com.bonus.canteen.core.kitchen.mapper.KitchenDeviceInfoMapper;
import com.bonus.canteen.core.kitchen.mapper.KitchenHomePageMapper;
import com.bonus.canteen.core.kitchen.service.IKitchenDeviceInfoService;
import com.bonus.canteen.core.kitchen.service.IKitchenHomePageService;
import com.bonus.canteen.core.kitchen.vo.IndexHomePageInformationVO;
import com.bonus.canteen.core.kitchen.vo.KitchenDeviceListVO;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.houqin.constant.DelFlagEnum;
import org.hibernate.validator.internal.util.StringHelper;
import org.springframework.stereotype.Service;
@ -30,5 +33,18 @@ public class KitchenHomePageerviceImpl implements IKitchenHomePageService {
@Resource
private KitchenHomePageMapper kitchenHomePageMapper;
@Resource
private KitchenDeviceInfoMapper kitchenDeviceInfoMapper;
@Override
public IndexHomePageInformationVO getIndexHomePageInformation(IndexHomePageDTO indexHomePageDTO) {
Long deviceInfoCount = kitchenDeviceInfoMapper.selectCount(
Wrappers.<KitchenDeviceInfo>lambdaQuery()
.eq(KitchenDeviceInfo::getDelFlag, DelFlagEnum.DEL_FALSE.key())
);
System.err.println("设备总数: " + deviceInfoCount);
return null;
}
}

View File

@ -0,0 +1,21 @@
package com.bonus.canteen.core.kitchen.vo;
import lombok.Data;
import lombok.ToString;
/**
* 告警日志统计信息
* @author xliu
* @date 2025/6/18 17:11
*/
@Data
@ToString
public class IndexAlarmLogCountVO {
private Integer environmentalAlarmCount; // 环境告警记录
private Integer accessControlAlarmCount; // 门禁告警记录
private Integer monitoringAlarmCount; // 监控告警记录
}

View File

@ -0,0 +1,19 @@
package com.bonus.canteen.core.kitchen.vo;
import lombok.Data;
import lombok.ToString;
/**
* 设备状态统计信息
* @author xliu
* @date 2025/6/18 17:17
*/
@Data
@ToString
public class IndexDeviceStatusCountVO {
private Integer normalCount; // 正常设备总数
private Integer offlineCount; // 离线设备总数
}

View File

@ -0,0 +1,21 @@
package com.bonus.canteen.core.kitchen.vo;
import lombok.Data;
import lombok.ToString;
/**
* 员工违规统计信息
* @author xliu
* @date 2025/6/18 17:31
*/
@Data
@ToString
public class IndexEmployeeViolationVO {
private Integer callUpCount; // 打电话
private Integer smokeCount; // 抽烟
private Integer withoutGlovesCount; // 未带手套
private Integer withoutKitchenCapCount; // 未戴厨房帽
private Integer withoutMaskCount; // 未带口罩
}

View File

@ -0,0 +1,20 @@
package com.bonus.canteen.core.kitchen.vo;
import lombok.Data;
import lombok.ToString;
/**
* @author xliu
* @date 2025/6/18 17:47
*/
@Data
@ToString
public class IndexEnvironmentaAlarm {
private Integer personRushCount; // 未授权人进入
private Integer personLeavingCount; // 动火离人
private Integer findAnimalsCount; // 发现老鼠
private Integer wasteCount; // 垃圾桶未加盖
}

View File

@ -0,0 +1,22 @@
package com.bonus.canteen.core.kitchen.vo;
import io.swagger.models.auth.In;
import lombok.Data;
import lombok.ToString;
/**
* 环境预警
* @author xliu
* @date 2025/6/18 17:41
*/
@Data
@ToString
public class IndexEnvironmentalWarning {
private Integer temperatureHighCount; // 温度过高总数
private Integer temperatureLowCount; // 温度过低总数
private Integer humidityHighCount; // 湿度过高总数
private Integer humidityLowCount; // 湿度过低总数
private Integer smokeHighCount; // 烟雾浓度过高总数
}

View File

@ -0,0 +1,20 @@
package com.bonus.canteen.core.kitchen.vo;
import lombok.Data;
import lombok.ToString;
/**
* 健康证统计信息
* @author xliu
* @date 2025/6/18 17:09
*/
@Data
@ToString
public class IndexHealthCertificateCountVO {
private Integer normalCount; // 正常证总数
private Integer lackCount; // 缺失总数
private Integer adventCount; // 临期总数
private Integer expireCount; // 过期总数
}

View File

@ -0,0 +1,36 @@
package com.bonus.canteen.core.kitchen.vo;
import lombok.Data;
import lombok.ToString;
/**
* @author xliu
* @date 2025/6/18 17:04
*/
@Data
@ToString
public class IndexHomePageInformationVO {
private Integer staffCount; // 员工总数
private Integer deviceCount; // 设备总数
private Integer todayWarningCount; // 今日预警
private Integer historicalWarningCount; // 历史预警
private IndexHealthCertificateCountVO healthCertificateCount; // 健康证统计信息
private IndexAlarmLogCountVO alarmLog; // 告警日志信息
private IndexDeviceStatusCountVO deviceStatus; // 设备状态信息
private IndexSampleRetentionCount sampleRetention; // 留样机数据统计信息
private IndexEmployeeViolationVO employeeViolation; // 员工违规统计信息
private IndexEnvironmentalWarning environmentalWarning; // 环境预警统计信息
private IndexEnvironmentaAlarm environmentalAlarm; // 环境告警信息
}

View File

@ -0,0 +1,19 @@
package com.bonus.canteen.core.kitchen.vo;
import lombok.Data;
import lombok.ToString;
/**
* 留样机数据统计
* @author xliu
* @date 2025/6/18 17:19
*/
@Data
@ToString
public class IndexSampleRetentionCount {
private Integer retentionCount; // 正常留样总数
private Integer unRetentionCount; // 缺失留样总数
}

View File

@ -3,6 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.canteen.core.kitchen.mapper.KitchenDeviceInfoMapper">
<resultMap type="com.bonus.canteen.core.kitchen.vo.KitchenDeviceListVO" id="KitchenDeviceInfoResult">
<result property="deviceId" column="device_id" />
<result property="deviceNo" column="device_no" />
@ -23,6 +24,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="canteenName" column="canteenName" />
</resultMap>
<resultMap type="com.bonus.canteen.core.kitchen.domain.KitchenDeviceInfo" id="KitchenDeviceInfoResultk">
<result property="deviceId" column="device_id" />
<result property="deviceNo" column="device_no" />
<result property="canteenId" column="canteen_id" />
<result property="areaId" column="area_id" />
<result property="devicePwd" column="device_pwd" />
<result property="deviceType" column="device_type" />
<result property="deviceCategory" column="device_category" />
<result property="deviceSize" column="device_size" />
<result property="deviceName" column="device_name" />
<result property="deviceSn" column="device_sn" />
<result property="subPlace" column="sub_place" />
<result property="deviceNetworkState" column="device_network_state" />
<result property="deviceRepairPeriod" column="device_repair_period" />
<result property="deviceExtendInfo" column="device_extend_info" />
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="selectKitchenDeviceInfoVo">
SELECT
device_id,
@ -51,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN v_area_canteen vac on vac.vAreaId = kit.area_id and vac.vCanteenId = kit.canteen_id
</sql>
<select id="selectKitchenDeviceInfoList" parameterType="com.bonus.canteen.core.kitchen.dto.KitchenDeviceListDTO" resultMap="KitchenDeviceInfoResult">
<include refid="selectKitchenDeviceInfoVo"/>
<where>
@ -72,6 +92,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where device_id = #{deviceId}
</select>
<select id="selectKitchenDeviceInfoByDeviceIdk" parameterType="Long" resultMap="KitchenDeviceInfoResultk">
<include refid="selectKitchenDeviceInfoVo"/>
where device_id = #{deviceId}
</select>
<insert id="insertKitchenDeviceInfo" parameterType="com.bonus.canteen.core.kitchen.domain.KitchenDeviceInfo" useGeneratedKeys="true" keyProperty="deviceId">
insert into kitchen_device_info
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -27,11 +27,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
device_type,
area_id,
canteen_id,
CASE
WHEN kdu.work_state = 1 THEN '工作中'
WHEN kdu.work_state = 0 THEN '离线'
ELSE '未知状态'
END as work_state,
work_state,
<!-- CASE-->
<!-- WHEN kdu.work_state = 1 THEN '工作中'-->
<!-- WHEN kdu.work_state = 0 THEN '离线'-->
<!-- ELSE '未知状态'-->
<!-- END as work_state,-->
start_use_time,
end_use_time,
use_time,