设备管理问题修改

This commit is contained in:
jjLv 2025-05-08 15:43:56 +08:00
parent 7b32e20de7
commit 402c5f2e1b
4 changed files with 50 additions and 16 deletions

View File

@ -13,6 +13,7 @@ import com.bonus.canteen.core.alloc.mapper.AllocStallMapper;
import com.bonus.canteen.core.device.dto.DeviceDTO;
import com.bonus.canteen.core.device.dto.DeviceSearchDTO;
import com.bonus.canteen.core.device.service.IDoubleScreenMachineService;
import com.bonus.canteen.core.device.vo.DeviceFullInfoVO;
import com.bonus.common.core.exception.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -42,8 +43,8 @@ public class DoubleScreenMachineController extends BaseController {
value = "分页查询设备信息",
notes = "page分页信息objectcanteenId:食堂ID, stallId:店铺档口id, deviceState:1在线2离线, "
)
@PostMapping({"/getDoubleScreenMachineList"})
public TableDataInfo getDoubleScreenMachineList(@RequestBody DeviceSearchDTO dto) {
@GetMapping({"/getDoubleScreenMachineList"})
public TableDataInfo getDoubleScreenMachineList(DeviceSearchDTO dto) {
List<Long> canteenIds;
List<Long> stallIds;
if (ObjectUtil.isNotEmpty(dto.getAreaId()) && ObjectUtil.isEmpty(dto.getCanteenId())) {
@ -69,7 +70,9 @@ public class DoubleScreenMachineController extends BaseController {
return getDataTable(new ArrayList<>());
}
}
return getDataTable(screenMachineService.getDoubleScreenMachineList(dto));
startPage();
List<DeviceFullInfoVO> list = screenMachineService.getDoubleScreenMachineList(dto);
return getDataTable(list);
}
@ApiOperation(

View File

@ -28,13 +28,7 @@ public interface DoubleScreenMachineMapper {
int insertMachine(DeviceDTO dto);
int insertMachineBind(DeviceDTO dto);
/**
* 校验设备sn名称编号是否已存在
*
* @param keyWord 设备编号/设备名称/设备sn码
* @return 结果
*/
int checkIsExist(@Param("keyWord") String keyWord, @Param("deviceId") String deviceId);
/**
* 删除设备绑定多档口子信息
*
@ -74,4 +68,17 @@ public interface DoubleScreenMachineMapper {
int insertDeviceRecipe(DeviceDTO dto);
int updateDeviceRecipe(DeviceDTO dto);
/**
* 校验设备sn名称编号是否已存在
*
* @param keyWord 设备编号/设备名称/设备sn码
* @return 结果
*/
int checkIsExist(@Param("keyWord") String keyWord, @Param("deviceId") String deviceId);
int checkIsExistDeviceNum(@Param("deviceNum") @NotBlank(message = "设备编号必填") String deviceNum,@Param("deviceId") String deviceId);
int checkIsExistDeviceName(@Param("deviceName") @NotBlank(message = "设备名称必填") String deviceName,@Param("deviceId") String deviceId);
int checkIsExistDeviceSn(@Param("deviceSn") @NotBlank(message = "设备sn码必填") String deviceSn,@Param("deviceId") String deviceId);
}

View File

@ -59,15 +59,15 @@ public class DoubleScreenMachineServiceImpl implements IDoubleScreenMachineServi
dto.setTenantId(GlobalConstants.TENANT_ID);
dto.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
//判断设备sn设备编号设备名称是否存在
int count = mapper.checkIsExist(dto.getDeviceNum(),null);
int count = mapper.checkIsExistDeviceNum(dto.getDeviceNum(),null);
if (count > 0){
throw new RuntimeException("设备编号已存在");
}
count = mapper.checkIsExist(dto.getDeviceName(),null);
count = mapper.checkIsExistDeviceName(dto.getDeviceName(),null);
if (count > 0){
throw new RuntimeException("设备名称已存在");
}
count = mapper.checkIsExist(dto.getDeviceSn(),null);
count = mapper.checkIsExistDeviceSn(dto.getDeviceSn(),null);
if (count > 0){
throw new RuntimeException("设备sn已存在");
}
@ -105,15 +105,15 @@ public class DoubleScreenMachineServiceImpl implements IDoubleScreenMachineServi
throw new RuntimeException("请先讲填写所有必填项,再提交相关数据!");
}
//判断设备sn设备编号设备名称是否存在
int count = mapper.checkIsExist(dto.getDeviceNum(), dto.getDeviceId());
int count = mapper.checkIsExistDeviceNum(dto.getDeviceNum(), dto.getDeviceId());
if (count > 0){
throw new RuntimeException("设备编号已存在");
}
count = mapper.checkIsExist(dto.getDeviceName(), dto.getDeviceId());
count = mapper.checkIsExistDeviceName(dto.getDeviceName(), dto.getDeviceId());
if (count > 0){
throw new RuntimeException("设备名称已存在");
}
count = mapper.checkIsExist(dto.getDeviceSn(), dto.getDeviceId());
count = mapper.checkIsExistDeviceSn(dto.getDeviceSn(), dto.getDeviceId());
if (count > 0){
throw new RuntimeException("设备sn已存在");
}

View File

@ -156,6 +156,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</select>
<select id="checkIsExistDeviceNum" resultType="java.lang.Integer">
select count(1)
from device_info
where device_num = #{deviceNum}
<if test="deviceId != null and deviceId != ''">
and device_id != #{deviceId}
</if>
</select>
<select id="checkIsExistDeviceName" resultType="java.lang.Integer">
select count(1)
from device_info
where device_name = #{deviceName}
<if test="deviceId != null and deviceId != ''">
and device_id != #{deviceId}
</if>
</select>
<select id="checkIsExistDeviceSn" resultType="java.lang.Integer">
select count(1)
from device_info
where device_sn = #{deviceSn}
<if test="deviceId != null and deviceId != ''">
and device_id != #{deviceId}
</if>
</select>
<insert id="insertDeviceRecipe">
insert into device_recipe(id,device_id, canteen_id,stall_id,