厨房问题修复,视频列表接口编写

This commit is contained in:
liux 2025-06-27 17:11:15 +08:00
parent e02b958d46
commit 806260b76b
12 changed files with 187 additions and 7 deletions

View File

@ -108,4 +108,7 @@ public class KitchenDeviceInfo extends Model<KitchenDeviceInfo> {
private Date updateTime;
private String ip;
private Integer channel;
}

View File

@ -117,6 +117,28 @@ public class KitchenDeviceInfoServiceImpl extends ServiceImpl<KitchenDeviceInfoM
if(bean !=null) {
throw new ServiceException("设备名称已存在,请检查后重新输入");
}
if(kitchenDeviceInfo.getDeviceType() == DeviceTypeEnum.CAMERA.getKey()) {
// 如果设备类型是摄像头IP地址不能为空
if (StringHelper.isNullOrEmptyString(kitchenDeviceInfo.getIp())) {
throw new ServiceException("摄像头设备的IP地址不能为空");
}
bean = kitchenDeviceInfoMapper.selectOne(
Wrappers.<KitchenDeviceInfo>lambdaQuery()
.eq(KitchenDeviceInfo::getIp, kitchenDeviceInfo.getIp()));
if(bean !=null) {
throw new ServiceException("设备IP已存在请检查后重新输入");
}
if (kitchenDeviceInfo.getChannel() == null || kitchenDeviceInfo.getChannel() < 1) {
throw new ServiceException("摄像头设备的IP地址不能为空或小于1");
}
bean = kitchenDeviceInfoMapper.selectOne(
Wrappers.<KitchenDeviceInfo>lambdaQuery()
.eq(KitchenDeviceInfo::getDeviceType, kitchenDeviceInfo.getDeviceType())
.eq(KitchenDeviceInfo::getChannel, kitchenDeviceInfo.getChannel()));
if(bean !=null) {
throw new ServiceException("改类型设备通道已存在,请检查后重新输入");
}
}
try {
return kitchenDeviceInfoMapper.insertKitchenDeviceInfo(kitchenDeviceInfo);
} catch (Exception e) {
@ -143,6 +165,14 @@ public class KitchenDeviceInfoServiceImpl extends ServiceImpl<KitchenDeviceInfoM
if(StringHelper.isNullOrEmptyString(kitchenDeviceInfo.getDeviceSn())){
throw new ServiceException("编设备sn号不能为空");
}
if(kitchenDeviceInfo.getDeviceType() == DeviceTypeEnum.CAMERA.getKey()) {
if(StringHelper.isNullOrEmptyString(kitchenDeviceInfo.getIp())){
throw new ServiceException("编设备ip号不能为空");
}
if(kitchenDeviceInfo.getCanteenId() == null){
throw new ServiceException("编设备通道号号不能为空");
}
}
KitchenDeviceInfo bean;
bean = kitchenDeviceInfoMapper.selectOne(
@ -159,15 +189,24 @@ public class KitchenDeviceInfoServiceImpl extends ServiceImpl<KitchenDeviceInfoM
.ne(KitchenDeviceInfo::getDeviceId, kitchenDeviceInfo.getDeviceId())
);
if(bean !=null){
throw new ServiceException("设备sn码已存在");
throw new ServiceException("设备sn码已存在");
}
bean = kitchenDeviceInfoMapper.selectOne(
Wrappers.<KitchenDeviceInfo>lambdaQuery()
.eq(KitchenDeviceInfo::getDeviceNo, kitchenDeviceInfo.getDeviceNo())
.eq(KitchenDeviceInfo::getIp, kitchenDeviceInfo.getIp())
.ne(KitchenDeviceInfo::getDeviceId, kitchenDeviceInfo.getDeviceId())
);
if(bean !=null){
throw new ServiceException("编设备编码已存在");
throw new ServiceException("设备ip已存在");
}
bean = kitchenDeviceInfoMapper.selectOne(
Wrappers.<KitchenDeviceInfo>lambdaQuery()
.eq(KitchenDeviceInfo::getChannel, kitchenDeviceInfo.getChannel())
.eq(KitchenDeviceInfo::getDeviceType, kitchenDeviceInfo.getDeviceType())
.ne(KitchenDeviceInfo::getDeviceId, kitchenDeviceInfo.getDeviceId())
);
if(bean !=null){
throw new ServiceException("改设备类型 设备通道号已存在");
}
try {
return kitchenDeviceInfoMapper.update(kitchenDeviceInfo,

View File

@ -105,9 +105,11 @@ public class KitchenHomePageerviceImpl implements IKitchenHomePageService {
int expireCount = 0;
for(KitchenStaffInfo kitchenStaffInfo : selectKitchenStaffInfoList){
LocalDate healthCertExpire = kitchenStaffInfo.getHealthCertExpire();
System.err.println("111: " + ChronoUnit.DAYS.between(healthCertExpire,LocalDate.now()));
System.err.println("222: " + ChronoUnit.DAYS.between(LocalDate.now(),healthCertExpire));
if(healthCertExpire == null){
lackCount ++;
}else if(ChronoUnit.DAYS.between(LocalDate.now(), healthCertExpire)>inemValue){
}else if(ChronoUnit.DAYS.between(LocalDate.now(), healthCertExpire)<inemValue && ChronoUnit.DAYS.between(LocalDate.now(), healthCertExpire)>0){
adventCount ++;
}else if (ChronoUnit.DAYS.between(LocalDate.now(),healthCertExpire)<0){
expireCount ++;

View File

@ -87,5 +87,8 @@ public class KitchenDeviceListVO {
private String canteenName;
private String ip;
private String channel;
}

View File

@ -1,5 +1,6 @@
package com.bonus.canteen.core.video.controller;
import com.bonus.canteen.core.video.dto.CameraByPlaceDTO;
import com.bonus.canteen.core.video.dto.PlaybackURLsDTO;
import com.bonus.canteen.core.video.dto.PreviewDTO;
import com.bonus.canteen.core.video.entity.VideoRequestBean;
@ -54,8 +55,8 @@ public class VideoController extends BaseController {
@ApiOperation(value = "根据位置分类摄像头")
@SysLog(title = "根据位置分类摄像头", businessType = OperaType.DELETE, logType = 1,module = "视频管理->根据位置分类摄像头")
@PostMapping("/getCameraByPlace")
public AjaxResult getCameraByPlace(@RequestBody PlaybackURLsDTO playbackURLsDTO) {
return success(videoService.playbackURLs(playbackURLsDTO));
public AjaxResult getCameraByPlace(@RequestBody CameraByPlaceDTO cameraByPlaceDTO) {
return success(videoService.getCameraByPlace(cameraByPlaceDTO));
}
}

View File

@ -0,0 +1,20 @@
package com.bonus.canteen.core.video.dto;
import lombok.Data;
/**
* @author xliu
* @date 2025/6/27 16:10
*/
@Data
public class CameraByPlaceDTO {
private String placeId; // 区域ID
private String placeName; // 区域名称
private String cameraName; // 摄像头名称
private Integer deviceType;
}

View File

@ -0,0 +1,19 @@
package com.bonus.canteen.core.video.mapper;
import com.bonus.canteen.core.screening.vo.EchartsVO;
import com.bonus.canteen.core.screening.vo.SingleModelVO;
import com.bonus.canteen.core.video.dto.CameraByPlaceDTO;
import com.bonus.canteen.core.video.vo.CameraByPlaceVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author 19814
*/
public interface VideoMapper {
List<CameraByPlaceVO> getPlace(CameraByPlaceDTO cameraByPlaceDTO);
List<CameraByPlaceVO> getDevice(CameraByPlaceDTO cameraByPlaceDTO);
}

View File

@ -1,8 +1,12 @@
package com.bonus.canteen.core.video.service;
import com.bonus.canteen.core.video.dto.CameraByPlaceDTO;
import com.bonus.canteen.core.video.dto.PlaybackURLsDTO;
import com.bonus.canteen.core.video.dto.PreviewDTO;
import com.bonus.canteen.core.video.entity.VideoRequestBean;
import com.bonus.canteen.core.video.vo.CameraByPlaceVO;
import java.util.List;
/**
* @author xliu
@ -15,4 +19,6 @@ public interface VideoService {
String previewURLs(PreviewDTO previewDTO);
String playbackURLs(PlaybackURLsDTO playbackURLsDTO);
List<CameraByPlaceVO> getCameraByPlace(CameraByPlaceDTO cameraByPlaceDTO);
}

View File

@ -1,16 +1,25 @@
package com.bonus.canteen.core.video.service.impl;
import com.alibaba.fastjson2.JSON;
import com.bonus.canteen.core.video.dto.CameraByPlaceDTO;
import com.bonus.canteen.core.video.dto.PlaybackURLsDTO;
import com.bonus.canteen.core.video.dto.PreviewDTO;
import com.bonus.canteen.core.video.entity.VideoRequestBean;
import com.bonus.canteen.core.video.mapper.VideoMapper;
import com.bonus.canteen.core.video.service.VideoService;
import com.bonus.canteen.core.video.utils.HCNetVedio;
import com.bonus.canteen.core.video.utils.HKRequest;
import com.bonus.canteen.core.video.vo.CameraByPlaceVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @author xliu
* @date 2025/6/23 15:27
@ -18,6 +27,9 @@ import org.springframework.stereotype.Service;
@Service
public class VideoServiceImpl implements VideoService {
public static Logger logger = LoggerFactory.getLogger(VideoServiceImpl.class);
@Resource
private VideoMapper videoMapper;
@Override
public String download(VideoRequestBean bean) {
String fileName = "";
@ -57,4 +69,22 @@ public class VideoServiceImpl implements VideoService {
String result = HKRequest.sendHttp(HKRequest.GET_VIDEO_HISTORY_URL, JSON.toJSONString(playbackURLsDTO));
return result;
}
@Override
public List<CameraByPlaceVO> getCameraByPlace(CameraByPlaceDTO cameraByPlaceDTO) {
List<CameraByPlaceVO> placeList = videoMapper.getPlace(cameraByPlaceDTO);
List<CameraByPlaceVO> deviceList = videoMapper.getDevice(cameraByPlaceDTO);
List<CameraByPlaceVO> allList = new ArrayList<>();
Set<String> placeIds = placeList.stream()
.map(CameraByPlaceVO::getId)
.collect(Collectors.toSet());
// 过滤 deviceList pId 存在于 placeIds 中的元素
List<CameraByPlaceVO> filteredDevices = deviceList.stream()
.filter(device -> placeIds.contains(device.getPId()))
.collect(Collectors.toList());
// placeList filteredDevices 合并
allList.addAll(placeList);
allList.addAll(filteredDevices);
return allList;
}
}

View File

@ -0,0 +1,17 @@
package com.bonus.canteen.core.video.vo;
import lombok.Data;
/**
* @author xliu
* @date 2025/6/27 16:12
*/
@Data
public class CameraByPlaceVO {
private String id;
private String name;
private String pId;
private String ip;
private String channel;
}

View File

@ -20,6 +20,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="deviceRepairPeriod" column="device_repair_period" />
<result property="deviceExtendInfo" column="device_extend_info" />
<result property="delFlag" column="del_flag" />
<result property="ip" column="ip" />
<result property="channel" column="channel" />
<result property="areaName" column="areaName" />
<result property="subPlaceName" column="sub_place_name" />
<result property="canteenName" column="canteenName" />
@ -42,6 +44,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="deviceExtendInfo" column="device_extend_info" />
<result property="subPlaceName" column="sub_place_name" />
<result property="delFlag" column="del_flag" />
<result property="ip" column="ip" />
<result property="channel" column="channel" />
</resultMap>
<sql id="selectKitchenDeviceInfoVo">
@ -62,6 +66,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
device_repair_period,
device_extend_info,
del_flag,
ip,
channel,
kit.create_by,
kit.create_time,
kit.update_by,
@ -125,6 +131,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="ip != null">ip,</if>
<if test="channel != null">channel,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceNo != null and deviceNo != ''">#{deviceNo},</if>
@ -145,6 +153,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="ip != null">#{ip},</if>
<if test="channel != null">#{channel},</if>
</trim>
</insert>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.canteen.core.video.mapper.VideoMapper">
<select id="getPlace" resultType="com.bonus.canteen.core.video.vo.CameraByPlaceVO">
select concat('a',sub_place_id) as id,sub_place_name as `name` ,'0' as pId
from kitchen_sub_place
<where>
<if test="placeId != null and placeId != ''">
and sub_place_id = #{placeId}
</if>
<if test="placeName != null and placeName != ''">
and sub_place_name like concat('%',#{placeName},'%')
</if>
</where>
</select>
<select id="getDevice" resultType="com.bonus.canteen.core.video.vo.CameraByPlaceVO">
select device_id as id,device_name as `name`,concat('a',sub_place) as pId,ip,channel
from kitchen_device_info
<where>
<if test="cameraName != null and cameraName != ''">
and device_name like concat('%',#{deviceName},'%')
</if>
</where>
</select>
</mapper>