首页统计数据

This commit is contained in:
liux 2025-06-20 18:06:21 +08:00
parent 7b37799469
commit df66e88ace
10 changed files with 415 additions and 17 deletions

View File

@ -0,0 +1,55 @@
package com.bonus.canteen.core.kitchen.domain.constants;
import com.bonus.common.houqin.constant.DeviceTypeEnum;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author xliu
* @date 2025/6/19 15:44
*/
public enum StaffWarningEnum {
//1=-未戴口罩,2=-垃圾桶未盖报警,3=-发现老鼠,4=-未穿厨师服,5=-未戴厨师帽,6=-未戴手套,7=-抽烟,8=-打电话,9=-地面巡检,1=0-设备归位,1=1-未授权人员进入,1=3-动火离人
UNWEAR_MASK(1, "未戴口罩"),
UNCOVER_TRASH(2, "垃圾桶未盖报警"),
FOUND_MOUSE(3, "发现老鼠"),
NOT_WEAR_COOK_CLOTHES(4, "未穿厨师服"),
NOT_WEAR_COOK_HAT(5, "未戴厨师帽"),
NOT_WEAR_GLOVES(6, "未戴手套"),
SMOKE(7, "抽烟"),
CALL_PHONE(8, "打电话"),
GROUND_INSPECTION(9, "地面巡检"),
DEVICE_RETURN(10, "设备归位"),
UNAUTHORIZED_PERSON_ENTER(11, "未授权人员进入"),
FIRE_ALARM(13, "动火离人");
private Integer key;
private String desc;
StaffWarningEnum(Integer key, String desc) {
this.key = key;
this.desc = desc;
}
public static Map<Integer, String> toMap() {
return Stream.of(StaffWarningEnum.values())
.collect(Collectors.toMap(
StaffWarningEnum::getKey,
StaffWarningEnum::getDesc
));
}
public Integer getKey() {
return this.key;
}
public String getDesc() {
return this.desc;
}
}

View File

@ -3,6 +3,7 @@ package com.bonus.canteen.core.kitchen.dto;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
@ -13,8 +14,12 @@ import java.time.LocalDateTime;
@ToString @ToString
public class IndexHomePageDTO { public class IndexHomePageDTO {
private LocalDateTime startTime; // 当前时间 private LocalDate deviceStartTime; // 当前时间
private LocalDateTime endTime; // 厨房名称 private LocalDate deviceEndTime; // 厨房名称
private LocalDate sampleStartTime; // 留样机开始时间
private LocalDate sampleEndTime; // 留样机结束时间
} }

View File

@ -2,9 +2,14 @@ package com.bonus.canteen.core.kitchen.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bonus.canteen.core.kitchen.domain.KitchenDeviceInfo; import com.bonus.canteen.core.kitchen.domain.KitchenDeviceInfo;
import com.bonus.canteen.core.kitchen.domain.KitchenDeviceSensorMetric;
import com.bonus.canteen.core.kitchen.dto.KitchenDeviceListDTO; import com.bonus.canteen.core.kitchen.dto.KitchenDeviceListDTO;
import com.bonus.canteen.core.kitchen.vo.IndexMapCountVO;
import com.bonus.canteen.core.kitchen.vo.KitchenDeviceListVO; import com.bonus.canteen.core.kitchen.vo.KitchenDeviceListVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.time.LocalDate;
import java.util.List; import java.util.List;
/** /**
@ -15,4 +20,18 @@ import java.util.List;
*/ */
public interface KitchenHomePageMapper { public interface KitchenHomePageMapper {
//员工总数
int getStaffInfo();
List<IndexMapCountVO> getEmployeeViolationCount(int warningType);
List<IndexMapCountVO> getDeviceStatusCount(@Param("startTime") String startTime, @Param("endTime")String endTime);
List<IndexMapCountVO> getSampleRetentionCount(@Param("startTime") String startTime, @Param("endTime")String endTime);
int getCountNum(@Param("beans") KitchenDeviceSensorMetric beans,@Param("type") String type);
int getAlarmCountNum(@Param("time")String time);
List<IndexMapCountVO> getDeviceAlarmMessage();
} }

View File

@ -1,12 +1,14 @@
package com.bonus.canteen.core.kitchen.service.impl; package com.bonus.canteen.core.kitchen.service.impl;
import java.util.List; import java.util.List;
import java.util.Map;
import com.bonus.canteen.core.kitchen.dto.KitchenDeviceListDTO; import com.bonus.canteen.core.kitchen.dto.KitchenDeviceListDTO;
import com.bonus.canteen.core.kitchen.dto.KitchenDeviceUsageListDTO; import com.bonus.canteen.core.kitchen.dto.KitchenDeviceUsageListDTO;
import com.bonus.canteen.core.kitchen.vo.KitchenDeviceUsageListVO; import com.bonus.canteen.core.kitchen.vo.KitchenDeviceUsageListVO;
import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.houqin.constant.DeviceTypeEnum;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.bonus.canteen.core.kitchen.mapper.KitchenDeviceUsageMapper; import com.bonus.canteen.core.kitchen.mapper.KitchenDeviceUsageMapper;
@ -43,7 +45,19 @@ public class KitchenDeviceUsageServiceImpl implements IKitchenDeviceUsageService
*/ */
@Override @Override
public List<KitchenDeviceUsageListVO> selectKitchenDeviceUsageList(KitchenDeviceUsageListDTO kitchenDeviceUsage) { public List<KitchenDeviceUsageListVO> selectKitchenDeviceUsageList(KitchenDeviceUsageListDTO kitchenDeviceUsage) {
return kitchenDeviceUsageMapper.selectKitchenDeviceUsageList(kitchenDeviceUsage); Map<Integer, String> deviceMap = DeviceTypeEnum.toMap();
List<KitchenDeviceUsageListVO> kitchenDeviceUsageList = kitchenDeviceUsageMapper.selectKitchenDeviceUsageList(kitchenDeviceUsage);
if(kitchenDeviceUsageList !=null && kitchenDeviceUsageList.size()>0){
for(KitchenDeviceUsageListVO bean : kitchenDeviceUsageList){
Long deviceType = bean.getDeviceType();
if (deviceType != null && deviceMap.containsKey(deviceType.intValue())) {
bean.setDeviceTypeName(deviceMap.get(deviceType.intValue()));
} else {
bean.setDeviceTypeName("未知设备类型");
}
}
}
return kitchenDeviceUsageList;
} }
/** /**

View File

@ -1,26 +1,38 @@
package com.bonus.canteen.core.kitchen.service.impl; package com.bonus.canteen.core.kitchen.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.bonus.canteen.core.basic.domain.BasicSetting;
import com.bonus.canteen.core.basic.mapper.BasicSettingMapper;
import com.bonus.canteen.core.kitchen.domain.KitchenDeviceInfo; import com.bonus.canteen.core.kitchen.domain.KitchenDeviceInfo;
import com.bonus.canteen.core.kitchen.domain.KitchenDeviceSensorMetric;
import com.bonus.canteen.core.kitchen.domain.KitchenStaffInfo;
import com.bonus.canteen.core.kitchen.domain.constants.StaffWarningEnum;
import com.bonus.canteen.core.kitchen.dto.IndexHomePageDTO; 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.KitchenDeviceInfoMapper;
import com.bonus.canteen.core.kitchen.mapper.KitchenDeviceSensorMetricMapper;
import com.bonus.canteen.core.kitchen.mapper.KitchenHomePageMapper; import com.bonus.canteen.core.kitchen.mapper.KitchenHomePageMapper;
import com.bonus.canteen.core.kitchen.service.IKitchenDeviceInfoService; import com.bonus.canteen.core.kitchen.mapper.KitchenStaffInfoMapper;
import com.bonus.canteen.core.kitchen.service.IKitchenHomePageService; import com.bonus.canteen.core.kitchen.service.IKitchenHomePageService;
import com.bonus.canteen.core.kitchen.vo.IndexHomePageInformationVO; import com.bonus.canteen.core.kitchen.vo.IndexHomePageInformationVO;
import com.bonus.canteen.core.kitchen.vo.KitchenDeviceListVO; import com.bonus.canteen.core.kitchen.vo.IndexMapCountVO;
import com.bonus.common.core.exception.ServiceException; 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.DelFlagEnum;
import org.hibernate.validator.internal.util.StringHelper; import com.bonus.common.houqin.constant.DeviceTypeEnum;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Map;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/** /**
* 厨房设备基础信息Service业务层处理 * 厨房设备基础信息Service业务层处理
@ -36,15 +48,214 @@ public class KitchenHomePageerviceImpl implements IKitchenHomePageService {
@Resource @Resource
private KitchenDeviceInfoMapper kitchenDeviceInfoMapper; private KitchenDeviceInfoMapper kitchenDeviceInfoMapper;
@Resource
private KitchenDeviceSensorMetricMapper kitchenDeviceSensorMetricMapper;
@Resource
private KitchenStaffInfoMapper kitchenStaffInfoMapper;
@Resource
private BasicSettingMapper basicSettingMapper;
@Override @Override
public IndexHomePageInformationVO getIndexHomePageInformation(IndexHomePageDTO indexHomePageDTO) { public IndexHomePageInformationVO getIndexHomePageInformation(IndexHomePageDTO indexHomePageDTO) {
IndexHomePageInformationVO indexHomePageInformationVO = new IndexHomePageInformationVO();
//设备总数
Long deviceInfoCount = kitchenDeviceInfoMapper.selectCount( Long deviceInfoCount = kitchenDeviceInfoMapper.selectCount(
Wrappers.<KitchenDeviceInfo>lambdaQuery() Wrappers.<KitchenDeviceInfo>lambdaQuery()
.eq(KitchenDeviceInfo::getDelFlag, DelFlagEnum.DEL_FALSE.key()) .eq(KitchenDeviceInfo::getDelFlag, DelFlagEnum.DEL_FALSE.key())
); );
//违章类型
Map<Integer,String> StaffWarningMap = StaffWarningEnum.toMap();
List<KitchenDeviceSensorMetric> kitchenDeviceSensorMetrics = kitchenDeviceSensorMetricMapper.selectKitchenDeviceSensorMetricList(null);
System.err.println("设备衡量指标: " + kitchenDeviceSensorMetrics);
//员工总数
int staffInfoCount = kitchenHomePageMapper.getStaffInfo();
System.err.println("设备总数: " + deviceInfoCount); System.err.println("设备总数: " + deviceInfoCount);
return null;
//今日预警数
int todayWarningCount = kitchenHomePageMapper.getAlarmCountNum(LocalDate.now().toString());
//历史预警说
int historicalWarningCount = kitchenHomePageMapper.getAlarmCountNum(null);
//健康证管理
List<KitchenStaffInfo> selectKitchenStaffInfoList = kitchenStaffInfoMapper.selectKitchenStaffInfoList(null);
//获取临期天数
BasicSetting basicSetting = basicSettingMapper.selectBasicSettingById(12L);
boolean tf = isInteger(basicSetting.getItemValue());
Integer inemValue = 30;
if(tf){
inemValue = Integer.valueOf(basicSetting.getItemValue());
}
System.err.println("厨房人员信息: " + selectKitchenStaffInfoList);
if(selectKitchenStaffInfoList !=null && selectKitchenStaffInfoList.size() > 0){
//正常状态
int normalCount = 0;
//缺失状态
int lackCount = 0;
//临期状态
int adventCount = 0;
//过期状态
int expireCount = 0;
for(KitchenStaffInfo kitchenStaffInfo : selectKitchenStaffInfoList){
LocalDate healthCertExpire = kitchenStaffInfo.getHealthCertExpire();
if(healthCertExpire == null){
lackCount ++;
}else if(ChronoUnit.DAYS.between(LocalDate.now(), healthCertExpire)>inemValue){
adventCount ++;
}else if (ChronoUnit.DAYS.between(LocalDate.now(), healthCertExpire)<0){
expireCount ++;
}else{
normalCount ++;
}
}
IndexMapCountVO normal = new IndexMapCountVO();
IndexMapCountVO lack = new IndexMapCountVO();
IndexMapCountVO advent = new IndexMapCountVO();
IndexMapCountVO expire = new IndexMapCountVO();
normal.setName("正常");
normal.setCount(normalCount);
lack.setName("缺失");
lack.setCount(lackCount);
advent.setName("临期");
advent.setCount(adventCount);
expire.setName("过期");
expire.setCount(expireCount);
List<IndexMapCountVO> healthCertificateCount = new ArrayList<>();
healthCertificateCount.add(normal);
healthCertificateCount.add(lack);
healthCertificateCount.add(advent);
healthCertificateCount.add(expire);
indexHomePageInformationVO.setHealthCertificateCount(healthCertificateCount);
}
//环境告警记录
//设备告警信息
List<IndexMapCountVO> deviceAlarmMessage = kitchenHomePageMapper.getDeviceAlarmMessage();
List<IndexMapCountVO> alarmCountList = new ArrayList<>();
IndexMapCountVO indexMapCountDoor = new IndexMapCountVO();
IndexMapCountVO indexMapCountCamera = new IndexMapCountVO();
IndexMapCountVO indexMapCountEn = new IndexMapCountVO();
indexMapCountDoor.setName("门禁报警记录");
indexMapCountCamera.setName("监控报警记录");
indexMapCountEn.setName("环境报警记录");
if(deviceAlarmMessage != null && deviceAlarmMessage.size() > 0){
for (IndexMapCountVO indexMapCountVO : deviceAlarmMessage ) {
if(String.valueOf(DeviceTypeEnum.DOOR.getKey()).equals(indexMapCountVO.getName())){
indexMapCountDoor.setCount(indexMapCountVO.getCount());
}
if(String.valueOf(DeviceTypeEnum.CAMERA.getKey()).equals(indexMapCountVO.getName())){
indexMapCountCamera.setCount(indexMapCountVO.getCount());
}
if("-1".equals(indexMapCountVO.getName())){
indexMapCountEn.setCount(indexMapCountVO.getCount());
}
}
}
alarmCountList.add(indexMapCountDoor);
alarmCountList.add(indexMapCountCamera);
alarmCountList.add(indexMapCountEn);
//设备状态数据分析
LocalDate deviceStartDate = indexHomePageDTO.getDeviceStartTime();
LocalDate deviceEndTime = indexHomePageDTO.getDeviceEndTime();
if(deviceStartDate != null && deviceEndTime != null){
if(deviceStartDate.isAfter(deviceEndTime)){
throw new ServiceException("开始时间不能大于结束时间");
}
}else{
deviceStartDate = LocalDate.now().plusDays(-1);
deviceEndTime = LocalDate.now();
}
List<IndexMapCountVO> deviceStatus = kitchenHomePageMapper.getDeviceStatusCount(deviceStartDate.toString(), deviceEndTime.toString());
//留样数据分析
LocalDate sampleStartDate = indexHomePageDTO.getSampleStartTime();
LocalDate sampleEndTime = indexHomePageDTO.getSampleEndTime();
if(sampleStartDate != null && sampleEndTime != null) {
if (sampleStartDate.isAfter(sampleEndTime)) {
throw new ServiceException("留样开始时间不能大于结束时间");
}
} else {
sampleStartDate = LocalDate.now().plusDays(-1);
sampleEndTime = LocalDate.now();
}
List<IndexMapCountVO> sampleRetention = kitchenHomePageMapper.getSampleRetentionCount(sampleStartDate.toString(), sampleEndTime.toString());
//报警数据分析-员工违规
List<IndexMapCountVO> employeeViolation = kitchenHomePageMapper.getEmployeeViolationCount(1);
for(IndexMapCountVO bean : employeeViolation ){
if (StringUtils.isNotEmpty(bean.getName())) {
bean.setName(StaffWarningMap.get(Integer.valueOf(bean.getName())));
}
}
if(kitchenDeviceSensorMetrics != null || kitchenDeviceSensorMetrics.size()>0){
List<IndexMapCountVO> environmentWarning = new ArrayList<>();
for(KitchenDeviceSensorMetric kitchenDeviceSensorMetric : kitchenDeviceSensorMetrics){
BigDecimal measureMaxValue = kitchenDeviceSensorMetric.getMeasureMaxValue();
BigDecimal measureMinValue = kitchenDeviceSensorMetric.getMeasureMinValue();
String name = kitchenDeviceSensorMetric.getMeasureName();
BigDecimal value = new BigDecimal("0.00");
boolean isZeroMax = value.compareTo(measureMaxValue) == 0;
boolean isZeroMin = value.compareTo(measureMinValue) == 0;
if(!isZeroMax){
IndexMapCountVO indexMapCountVO = new IndexMapCountVO();
int count = kitchenHomePageMapper.getCountNum(kitchenDeviceSensorMetric,"max" );
indexMapCountVO.setCount(count);
indexMapCountVO.setName(name + "过高");
environmentWarning.add(indexMapCountVO);
}
if(!isZeroMin){
IndexMapCountVO indexMapCountVO = new IndexMapCountVO();
int count = kitchenHomePageMapper.getCountNum(kitchenDeviceSensorMetric,"min" );
indexMapCountVO.setCount(count);
indexMapCountVO.setName(name + "过低");
environmentWarning.add(indexMapCountVO);
}
}
indexHomePageInformationVO.setEnvironmentalWarning(environmentWarning);
System.err.println("环境预警数据: " + environmentWarning);
}
//报警数据分析-环境告警
List<IndexMapCountVO> environmentaAlarm = kitchenHomePageMapper.getEmployeeViolationCount(2);
for(IndexMapCountVO bean : environmentaAlarm ){
if (StringUtils.isNotEmpty(bean.getName())) {
bean.setName(StaffWarningMap.get(Integer.valueOf(bean.getName())));
}
}
indexHomePageInformationVO.setDeviceCount(Integer.valueOf(deviceInfoCount.toString()));
indexHomePageInformationVO.setEmployeeViolation(employeeViolation);
indexHomePageInformationVO.setEnvironmentalAlarm(environmentaAlarm);
indexHomePageInformationVO.setHistoricalWarningCount(historicalWarningCount);
indexHomePageInformationVO.setTodayWarningCount(todayWarningCount);
indexHomePageInformationVO.setDeviceStatus(deviceStatus);
indexHomePageInformationVO.setSampleRetention(sampleRetention);
indexHomePageInformationVO.setStaffCount(staffInfoCount);
indexHomePageInformationVO.setAlarmLog(alarmCountList);
//indexHomePageInformationVO
return indexHomePageInformationVO;
}
public static boolean isInteger(String str) {
return str.matches("^-?\\d+$"); // 匹配正负整数
} }
} }

View File

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

View File

@ -0,0 +1,14 @@
package com.bonus.canteen.core.kitchen.vo;
import lombok.Data;
/**
* @author xliu
* @date 2025/6/19 17:17
*/
@Data
public class IndexMapCountVO {
private String name; // 名称
private Integer count = 0; // 数量
private Double percentage = 0.0; // 百分比
}

View File

@ -37,6 +37,9 @@ public class KitchenDeviceUsageListVO {
@ApiModelProperty(value = "设备类型") @ApiModelProperty(value = "设备类型")
private Long deviceType; private Long deviceType;
@ApiModelProperty(value = "设备类型名称")
private String deviceTypeName;
/** 区域id */ /** 区域id */
@ApiModelProperty(value = "区域id") @ApiModelProperty(value = "区域id")
private Long areaId; private Long areaId;
@ -73,5 +76,6 @@ public class KitchenDeviceUsageListVO {
@ApiModelProperty(value = "是否结束标志") @ApiModelProperty(value = "是否结束标志")
private Long endTag; private Long endTag;
private String deviceName;
} }

View File

@ -13,6 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="workState" column="work_state" /> <result property="workState" column="work_state" />
<result property="startUseTime" column="start_use_time" /> <result property="startUseTime" column="start_use_time" />
<result property="endUseTime" column="end_use_time" /> <result property="endUseTime" column="end_use_time" />
<result property="deviceName" column="device_name" />
<result property="useTime" column="use_time" /> <result property="useTime" column="use_time" />
<result property="endTag" column="end_tag" /> <result property="endTag" column="end_tag" />
<result property="areaName" column="areaName" /> <result property="areaName" column="areaName" />

View File

@ -4,4 +4,77 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.canteen.core.kitchen.mapper.KitchenHomePageMapper"> <mapper namespace="com.bonus.canteen.core.kitchen.mapper.KitchenHomePageMapper">
<select id="getStaffInfo" resultType="int">
select COUNT(staff_id) from kitchen_staff_info
</select>
<select id="getEmployeeViolationCount" resultType="com.bonus.canteen.core.kitchen.vo.IndexMapCountVO">
select alarm_type as `name`,count(illegal_warning_id) as `count` from kitchen_staff_illegal_warning
where illegal_warning_type =#{warningType}
GROUP BY alarm_type
</select>
<select id="getDeviceStatusCount" resultType="com.bonus.canteen.core.kitchen.vo.IndexMapCountVO" parameterType="string">
SELECT
CASE WHEN
device_network_state = 1 then '在线'
ELSE '离线'
end as 'name'
,COUNT(device_id) as count from kitchen_device_info
where del_flag = '0' and update_time between #{startTime} and #{endTime}
GROUP BY device_network_state
</select>
<select id="getSampleRetentionCount" resultType="com.bonus.canteen.core.kitchen.vo.IndexMapCountVO" parameterType="string">
SELECT
CASE WHEN
weight_standard = 1 and duration_standard =1 then '合格'
ELSE '不合格'
end as 'name'
,COUNT(record_id) as count from kitchen_sample_dishes_record
where create_time between #{startTime} and #{endTime}
GROUP BY `name`
</select>
<select id="getCountNum" resultType="int">
SELECT COUNT(record_id) FROM kitchen_device_sensor_record
WHERE device_type = #{beans.deviceType} AND measure_metric_id = #{beans.measureId}
<if test="type == 'max'">
and #{beans.measureMaxValue} > measure_data
</if>
<if test="type == 'min'">
and measure_data > #{beans.measureMinValue}
</if>
</select>
<select id="getAlarmCountNum" resultType="int">
SELECT
(SELECT COUNT(illegal_warning_id)
FROM kitchen_staff_illegal_warning
WHERE handle_state IN (2,3)
<if test="time !=null and time !=''">
AND DATE(create_time) = #{time}
</if>
) +
(SELECT COUNT(record_id)
FROM kitchen_device_sensor_record
WHERE is_alarm = 1
<if test="time !=null and time !=''">
AND DATE(create_time) = #{time}
</if>
) AS total_count;
</select>
<select id="getDeviceAlarmMessage" resultType="com.bonus.canteen.core.kitchen.vo.IndexMapCountVO">
select b.device_type as `name`,COUNT(a.illegal_warning_id) as `count` from (
select * from kitchen_staff_illegal_warning WHERE DATE(create_time) = CURRENT_DATE()
) a LEFT JOIN kitchen_device_info b on a.device_id = b.device_id
GROUP BY b.device_type
UNION
select '-1' as `name`, COUNT(record_id) as `count` from kitchen_device_sensor_record
where is_alarm = 1 and DATE(create_time) = CURRENT_DATE()
</select>
</mapper> </mapper>