diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocStallServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocStallServiceImpl.java index e8b033c..523e031 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocStallServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocStallServiceImpl.java @@ -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.mapper.AllocStallMapper; 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.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; @@ -24,6 +29,10 @@ import org.springframework.util.CollectionUtils; public class AllocStallServiceImpl implements IAllocStallService { @Autowired private AllocStallMapper allocStallMapper; + @Autowired + DeviceBindMapper deviceBindMapper; + @Autowired + private MenuRecipeMapper menuRecipeMapper; /** * 查询档口信息 @@ -114,10 +123,27 @@ public class AllocStallServiceImpl implements IAllocStallService { */ @Override public int deleteAllocStallByStallIds(Long[] stallIds) { + int count = 0; for (int i = 0; i < stallIds.length; i++) { - allocStallMapper.deleteMealtimeByStallId(stallIds[i]); + Long stallId = stallIds[i]; + //判断档口是否含有设备 + DeviceBind deviceBind = new DeviceBind(); + deviceBind.setStallId(stallId); + List deviceBindList = deviceBindMapper.selectDeviceBindList(deviceBind); + if (!CollectionUtils.isEmpty(deviceBindList) && deviceBindList.size() > 0) { + throw new ServiceException("此档口已绑定设备,不能删除"); + } + //判断档口是否含有菜谱 + MenuRecipeParamDTO menuRecipeParamDTO = new MenuRecipeParamDTO(); + menuRecipeParamDTO.setStallId(stallId); + List 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; } /** diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/controller/DeviceBindController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/controller/DeviceBindController.java new file mode 100644 index 0000000..4965679 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/controller/DeviceBindController.java @@ -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 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 list = deviceBindService.selectDeviceBindList(deviceBind); + ExcelUtil util = new ExcelUtil(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)); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/domain/DeviceBind.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/domain/DeviceBind.java index 2c2825f..430d058 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/domain/DeviceBind.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/domain/DeviceBind.java @@ -10,7 +10,7 @@ import com.bonus.common.core.web.domain.BaseEntity; * 设备绑定多档口子对象 device_bind * * @author xsheng - * @date 2025-04-03 + * @date 2025-05-13 */ diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/domain/DeviceInfo.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/domain/DeviceInfo.java index a773136..c44e91f 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/domain/DeviceInfo.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/domain/DeviceInfo.java @@ -10,7 +10,7 @@ import com.bonus.common.core.web.domain.BaseEntity; * 设备资料对象 device_info * * @author xsheng - * @date 2025-04-03 + * @date 2025-05-13 */ @@ -311,5 +311,10 @@ public class DeviceInfo extends BaseEntity { @ApiModelProperty(value = "乐观锁 ") private Long revision; + /** 上次更新时间 */ + @Excel(name = "上次更新时间") + @ApiModelProperty(value = "上次更新时间") + private Long lastUpdateTime; + } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/mapper/DeviceBindMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/mapper/DeviceBindMapper.java new file mode 100644 index 0000000..e0cf746 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/mapper/DeviceBindMapper.java @@ -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 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); +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/IDeviceBindService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/IDeviceBindService.java new file mode 100644 index 0000000..fbb1c3c --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/IDeviceBindService.java @@ -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 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); +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/impl/DeviceBindServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/impl/DeviceBindServiceImpl.java new file mode 100644 index 0000000..d18e08c --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/impl/DeviceBindServiceImpl.java @@ -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 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); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/device/DeviceBindMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/device/DeviceBindMapper.xml new file mode 100644 index 0000000..08639e4 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/device/DeviceBindMapper.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + + + + insert into device_bind + + 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, + + + #{deviceId}, + #{canteenId}, + #{stallId}, + #{roomId}, + #{ifUsePrint}, + #{mealLineId}, + #{areaId}, + #{revision}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update device_bind + + device_id = #{deviceId}, + canteen_id = #{canteenId}, + stall_id = #{stallId}, + room_id = #{roomId}, + if_use_print = #{ifUsePrint}, + meal_line_id = #{mealLineId}, + area_id = #{areaId}, + revision = #{revision}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from device_bind where id = #{id} + + + + delete from device_bind where id in + + #{id} + + + \ No newline at end of file