删除档口查询是否绑定设备或菜谱

This commit is contained in:
sxu 2025-05-13 15:48:31 +08:00
parent 7e2a7c8a71
commit bd161823f9
8 changed files with 482 additions and 4 deletions

View File

@ -7,6 +7,11 @@ import com.bonus.canteen.core.alloc.domain.AllocStall;
import com.bonus.canteen.core.alloc.domain.AllocStallMealtime; import com.bonus.canteen.core.alloc.domain.AllocStallMealtime;
import com.bonus.canteen.core.alloc.mapper.AllocStallMapper; import com.bonus.canteen.core.alloc.mapper.AllocStallMapper;
import com.bonus.canteen.core.alloc.service.IAllocStallService; import com.bonus.canteen.core.alloc.service.IAllocStallService;
import com.bonus.canteen.core.device.domain.DeviceBind;
import com.bonus.canteen.core.device.mapper.DeviceBindMapper;
import com.bonus.canteen.core.menu.dto.MenuRecipeParamDTO;
import com.bonus.canteen.core.menu.mapper.MenuRecipeMapper;
import com.bonus.canteen.core.menu.vo.MenuRecipeV2VO;
import com.bonus.canteen.core.utils.BnsConstants; import com.bonus.canteen.core.utils.BnsConstants;
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;
@ -24,6 +29,10 @@ import org.springframework.util.CollectionUtils;
public class AllocStallServiceImpl implements IAllocStallService { public class AllocStallServiceImpl implements IAllocStallService {
@Autowired @Autowired
private AllocStallMapper allocStallMapper; private AllocStallMapper allocStallMapper;
@Autowired
DeviceBindMapper deviceBindMapper;
@Autowired
private MenuRecipeMapper menuRecipeMapper;
/** /**
* 查询档口信息 * 查询档口信息
@ -114,10 +123,27 @@ public class AllocStallServiceImpl implements IAllocStallService {
*/ */
@Override @Override
public int deleteAllocStallByStallIds(Long[] stallIds) { public int deleteAllocStallByStallIds(Long[] stallIds) {
int count = 0;
for (int i = 0; i < stallIds.length; i++) { for (int i = 0; i < stallIds.length; i++) {
allocStallMapper.deleteMealtimeByStallId(stallIds[i]); Long stallId = stallIds[i];
//判断档口是否含有设备
DeviceBind deviceBind = new DeviceBind();
deviceBind.setStallId(stallId);
List<DeviceBind> deviceBindList = deviceBindMapper.selectDeviceBindList(deviceBind);
if (!CollectionUtils.isEmpty(deviceBindList) && deviceBindList.size() > 0) {
throw new ServiceException("此档口已绑定设备,不能删除");
}
//判断档口是否含有菜谱
MenuRecipeParamDTO menuRecipeParamDTO = new MenuRecipeParamDTO();
menuRecipeParamDTO.setStallId(stallId);
List<MenuRecipeV2VO> menuRecipeList = menuRecipeMapper.getDishesList(menuRecipeParamDTO);
if (!CollectionUtils.isEmpty(menuRecipeList) && menuRecipeList.size() > 0) {
throw new ServiceException("此档口含有菜谱,不能删除");
}
allocStallMapper.deleteMealtimeByStallId(stallId);
count += allocStallMapper.deleteAllocStallByStallId(stallId);
} }
return allocStallMapper.deleteAllocStallByStallIds(stallIds); return count;
} }
/** /**

View File

@ -0,0 +1,119 @@
package com.bonus.canteen.core.device.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.bonus.common.log.enums.OperaType;
import com.bonus.canteen.core.common.annotation.PreventRepeatSubmit;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.canteen.core.device.domain.DeviceBind;
import com.bonus.canteen.core.device.service.IDeviceBindService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.page.TableDataInfo;
/**
* 设备绑定多档口子Controller
*
* @author xsheng
* @date 2025-05-13
*/
@Api(tags = "设备绑定多档口子接口")
@RestController
@RequestMapping("/device_bind")
public class DeviceBindController extends BaseController {
@Autowired
private IDeviceBindService deviceBindService;
/**
* 查询设备绑定多档口子列表
*/
@ApiOperation(value = "查询设备绑定多档口子列表")
//@RequiresPermissions("device:bind:list")
@GetMapping("/list")
public TableDataInfo list(DeviceBind deviceBind) {
startPage();
List<DeviceBind> list = deviceBindService.selectDeviceBindList(deviceBind);
return getDataTable(list);
}
/**
* 导出设备绑定多档口子列表
*/
@ApiOperation(value = "导出设备绑定多档口子列表")
//@PreventRepeatSubmit
//@RequiresPermissions("device:bind:export")
@SysLog(title = "设备绑定多档口子", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出设备绑定多档口子")
@PostMapping("/export")
public void export(HttpServletResponse response, DeviceBind deviceBind) {
List<DeviceBind> list = deviceBindService.selectDeviceBindList(deviceBind);
ExcelUtil<DeviceBind> util = new ExcelUtil<DeviceBind>(DeviceBind.class);
util.exportExcel(response, list, "设备绑定多档口子数据");
}
/**
* 获取设备绑定多档口子详细信息
*/
@ApiOperation(value = "获取设备绑定多档口子详细信息")
//@RequiresPermissions("device:bind:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(deviceBindService.selectDeviceBindById(id));
}
/**
* 新增设备绑定多档口子
*/
@ApiOperation(value = "新增设备绑定多档口子")
//@PreventRepeatSubmit
//@RequiresPermissions("device:bind:add")
@SysLog(title = "设备绑定多档口子", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增设备绑定多档口子")
@PostMapping
public AjaxResult add(@RequestBody DeviceBind deviceBind) {
try {
return toAjax(deviceBindService.insertDeviceBind(deviceBind));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
}
}
/**
* 修改设备绑定多档口子
*/
@ApiOperation(value = "修改设备绑定多档口子")
//@PreventRepeatSubmit
//@RequiresPermissions("device:bind:edit")
@SysLog(title = "设备绑定多档口子", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改设备绑定多档口子")
@PostMapping("/edit")
public AjaxResult edit(@RequestBody DeviceBind deviceBind) {
try {
return toAjax(deviceBindService.updateDeviceBind(deviceBind));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
}
}
/**
* 删除设备绑定多档口子
*/
@ApiOperation(value = "删除设备绑定多档口子")
//@PreventRepeatSubmit
//@RequiresPermissions("device:bind:remove")
@SysLog(title = "设备绑定多档口子", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除设备绑定多档口子")
@PostMapping("/del/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(deviceBindService.deleteDeviceBindByIds(ids));
}
}

View File

@ -10,7 +10,7 @@ import com.bonus.common.core.web.domain.BaseEntity;
* 设备绑定多档口子对象 device_bind * 设备绑定多档口子对象 device_bind
* *
* @author xsheng * @author xsheng
* @date 2025-04-03 * @date 2025-05-13
*/ */

View File

@ -10,7 +10,7 @@ import com.bonus.common.core.web.domain.BaseEntity;
* 设备资料对象 device_info * 设备资料对象 device_info
* *
* @author xsheng * @author xsheng
* @date 2025-04-03 * @date 2025-05-13
*/ */
@ -311,5 +311,10 @@ public class DeviceInfo extends BaseEntity {
@ApiModelProperty(value = "乐观锁 ") @ApiModelProperty(value = "乐观锁 ")
private Long revision; private Long revision;
/** 上次更新时间 */
@Excel(name = "上次更新时间")
@ApiModelProperty(value = "上次更新时间")
private Long lastUpdateTime;
} }

View File

@ -0,0 +1,60 @@
package com.bonus.canteen.core.device.mapper;
import java.util.List;
import com.bonus.canteen.core.device.domain.DeviceBind;
/**
* 设备绑定多档口子Mapper接口
*
* @author xsheng
* @date 2025-05-13
*/
public interface DeviceBindMapper {
/**
* 查询设备绑定多档口子
*
* @param id 设备绑定多档口子主键
* @return 设备绑定多档口子
*/
public DeviceBind selectDeviceBindById(Long id);
/**
* 查询设备绑定多档口子列表
*
* @param deviceBind 设备绑定多档口子
* @return 设备绑定多档口子集合
*/
public List<DeviceBind> selectDeviceBindList(DeviceBind deviceBind);
/**
* 新增设备绑定多档口子
*
* @param deviceBind 设备绑定多档口子
* @return 结果
*/
public int insertDeviceBind(DeviceBind deviceBind);
/**
* 修改设备绑定多档口子
*
* @param deviceBind 设备绑定多档口子
* @return 结果
*/
public int updateDeviceBind(DeviceBind deviceBind);
/**
* 删除设备绑定多档口子
*
* @param id 设备绑定多档口子主键
* @return 结果
*/
public int deleteDeviceBindById(Long id);
/**
* 批量删除设备绑定多档口子
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteDeviceBindByIds(Long[] ids);
}

View File

@ -0,0 +1,60 @@
package com.bonus.canteen.core.device.service;
import java.util.List;
import com.bonus.canteen.core.device.domain.DeviceBind;
/**
* 设备绑定多档口子Service接口
*
* @author xsheng
* @date 2025-05-13
*/
public interface IDeviceBindService {
/**
* 查询设备绑定多档口子
*
* @param id 设备绑定多档口子主键
* @return 设备绑定多档口子
*/
public DeviceBind selectDeviceBindById(Long id);
/**
* 查询设备绑定多档口子列表
*
* @param deviceBind 设备绑定多档口子
* @return 设备绑定多档口子集合
*/
public List<DeviceBind> selectDeviceBindList(DeviceBind deviceBind);
/**
* 新增设备绑定多档口子
*
* @param deviceBind 设备绑定多档口子
* @return 结果
*/
public int insertDeviceBind(DeviceBind deviceBind);
/**
* 修改设备绑定多档口子
*
* @param deviceBind 设备绑定多档口子
* @return 结果
*/
public int updateDeviceBind(DeviceBind deviceBind);
/**
* 批量删除设备绑定多档口子
*
* @param ids 需要删除的设备绑定多档口子主键集合
* @return 结果
*/
public int deleteDeviceBindByIds(Long[] ids);
/**
* 删除设备绑定多档口子信息
*
* @param id 设备绑定多档口子主键
* @return 结果
*/
public int deleteDeviceBindById(Long id);
}

View File

@ -0,0 +1,98 @@
package com.bonus.canteen.core.device.service.impl;
import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.device.mapper.DeviceBindMapper;
import com.bonus.canteen.core.device.domain.DeviceBind;
import com.bonus.canteen.core.device.service.IDeviceBindService;
/**
* 设备绑定多档口子Service业务层处理
*
* @author xsheng
* @date 2025-05-13
*/
@Service
public class DeviceBindServiceImpl implements IDeviceBindService {
@Autowired
private DeviceBindMapper deviceBindMapper;
/**
* 查询设备绑定多档口子
*
* @param id 设备绑定多档口子主键
* @return 设备绑定多档口子
*/
@Override
public DeviceBind selectDeviceBindById(Long id) {
return deviceBindMapper.selectDeviceBindById(id);
}
/**
* 查询设备绑定多档口子列表
*
* @param deviceBind 设备绑定多档口子
* @return 设备绑定多档口子
*/
@Override
public List<DeviceBind> selectDeviceBindList(DeviceBind deviceBind) {
return deviceBindMapper.selectDeviceBindList(deviceBind);
}
/**
* 新增设备绑定多档口子
*
* @param deviceBind 设备绑定多档口子
* @return 结果
*/
@Override
public int insertDeviceBind(DeviceBind deviceBind) {
deviceBind.setCreateTime(DateUtils.getNowDate());
try {
return deviceBindMapper.insertDeviceBind(deviceBind);
} catch (Exception e) {
throw new ServiceException("错误信息描述, " + e.getMessage());
}
}
/**
* 修改设备绑定多档口子
*
* @param deviceBind 设备绑定多档口子
* @return 结果
*/
@Override
public int updateDeviceBind(DeviceBind deviceBind) {
deviceBind.setUpdateTime(DateUtils.getNowDate());
try {
return deviceBindMapper.updateDeviceBind(deviceBind);
} catch (Exception e) {
throw new ServiceException("错误信息描述, " + e.getMessage());
}
}
/**
* 批量删除设备绑定多档口子
*
* @param ids 需要删除的设备绑定多档口子主键
* @return 结果
*/
@Override
public int deleteDeviceBindByIds(Long[] ids) {
return deviceBindMapper.deleteDeviceBindByIds(ids);
}
/**
* 删除设备绑定多档口子信息
*
* @param id 设备绑定多档口子主键
* @return 结果
*/
@Override
public int deleteDeviceBindById(Long id) {
return deviceBindMapper.deleteDeviceBindById(id);
}
}

View File

@ -0,0 +1,110 @@
<?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.device.mapper.DeviceBindMapper">
<resultMap type="com.bonus.canteen.core.device.domain.DeviceBind" id="DeviceBindResult">
<result property="id" column="id" />
<result property="deviceId" column="device_id" />
<result property="canteenId" column="canteen_id" />
<result property="stallId" column="stall_id" />
<result property="roomId" column="room_id" />
<result property="ifUsePrint" column="if_use_print" />
<result property="mealLineId" column="meal_line_id" />
<result property="areaId" column="area_id" />
<result property="revision" column="revision" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectDeviceBindVo">
select id, device_id, canteen_id, stall_id, room_id, if_use_print, meal_line_id, area_id, revision, create_by, create_time, update_by, update_time, remark from device_bind
</sql>
<select id="selectDeviceBindList" parameterType="com.bonus.canteen.core.device.domain.DeviceBind" resultMap="DeviceBindResult">
<include refid="selectDeviceBindVo"/>
<where>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="canteenId != null "> and canteen_id = #{canteenId}</if>
<if test="stallId != null "> and stall_id = #{stallId}</if>
<if test="roomId != null "> and room_id = #{roomId}</if>
<if test="ifUsePrint != null "> and if_use_print = #{ifUsePrint}</if>
<if test="mealLineId != null "> and meal_line_id = #{mealLineId}</if>
<if test="areaId != null "> and area_id = #{areaId}</if>
<if test="revision != null "> and revision = #{revision}</if>
</where>
</select>
<select id="selectDeviceBindById" parameterType="Long" resultMap="DeviceBindResult">
<include refid="selectDeviceBindVo"/>
where id = #{id}
</select>
<insert id="insertDeviceBind" parameterType="com.bonus.canteen.core.device.domain.DeviceBind" useGeneratedKeys="true" keyProperty="id">
insert into device_bind
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceId != null">device_id,</if>
<if test="canteenId != null">canteen_id,</if>
<if test="stallId != null">stall_id,</if>
<if test="roomId != null">room_id,</if>
<if test="ifUsePrint != null">if_use_print,</if>
<if test="mealLineId != null">meal_line_id,</if>
<if test="areaId != null">area_id,</if>
<if test="revision != null">revision,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceId != null">#{deviceId},</if>
<if test="canteenId != null">#{canteenId},</if>
<if test="stallId != null">#{stallId},</if>
<if test="roomId != null">#{roomId},</if>
<if test="ifUsePrint != null">#{ifUsePrint},</if>
<if test="mealLineId != null">#{mealLineId},</if>
<if test="areaId != null">#{areaId},</if>
<if test="revision != null">#{revision},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateDeviceBind" parameterType="com.bonus.canteen.core.device.domain.DeviceBind">
update device_bind
<trim prefix="SET" suffixOverrides=",">
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="canteenId != null">canteen_id = #{canteenId},</if>
<if test="stallId != null">stall_id = #{stallId},</if>
<if test="roomId != null">room_id = #{roomId},</if>
<if test="ifUsePrint != null">if_use_print = #{ifUsePrint},</if>
<if test="mealLineId != null">meal_line_id = #{mealLineId},</if>
<if test="areaId != null">area_id = #{areaId},</if>
<if test="revision != null">revision = #{revision},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDeviceBindById" parameterType="Long">
delete from device_bind where id = #{id}
</delete>
<delete id="deleteDeviceBindByIds" parameterType="String">
delete from device_bind where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>