智慧厨房

This commit is contained in:
gaowdong 2025-06-19 11:16:27 +08:00
parent 4bc462feb9
commit f410994c76
6 changed files with 50 additions and 16 deletions

View File

@ -36,7 +36,7 @@ public class KitchenStaffInfoController extends BaseController {
@ApiOperation(value = "查询厨房员工资料列表") @ApiOperation(value = "查询厨房员工资料列表")
//@RequiresPermissions("kitchen:info:list") //@RequiresPermissions("kitchen:info:list")
@PostMapping("/list") @PostMapping("/list")
public TableDataInfo list(@RequestBody @Valid KitchenStaffInfo kitchenStaffInfo) { public TableDataInfo list(@RequestBody KitchenStaffInfo kitchenStaffInfo) {
startPage(); startPage();
List<KitchenStaffInfo> list = kitchenStaffInfoService.selectKitchenStaffInfoList(kitchenStaffInfo); List<KitchenStaffInfo> list = kitchenStaffInfoService.selectKitchenStaffInfoList(kitchenStaffInfo);
return getDataTable(list); return getDataTable(list);

View File

@ -5,14 +5,14 @@ import com.bonus.canteen.core.kitchen.domain.KitchenStaffDevicePrivilege;
/** /**
* 厨房员工设备权限Mapper接口 * 厨房员工设备权限Mapper接口
* *
* @author xsheng * @author xsheng
* @date 2025-06-17 * @date 2025-06-17
*/ */
public interface KitchenStaffDevicePrivilegeMapper { public interface KitchenStaffDevicePrivilegeMapper {
/** /**
* 查询厨房员工设备权限 * 查询厨房员工设备权限
* *
* @param id 厨房员工设备权限主键 * @param id 厨房员工设备权限主键
* @return 厨房员工设备权限 * @return 厨房员工设备权限
*/ */
@ -28,7 +28,7 @@ public interface KitchenStaffDevicePrivilegeMapper {
/** /**
* 查询厨房员工设备权限列表 * 查询厨房员工设备权限列表
* *
* @param kitchenStaffDevicePrivilege 厨房员工设备权限 * @param kitchenStaffDevicePrivilege 厨房员工设备权限
* @return 厨房员工设备权限集合 * @return 厨房员工设备权限集合
*/ */
@ -36,7 +36,7 @@ public interface KitchenStaffDevicePrivilegeMapper {
/** /**
* 新增厨房员工设备权限 * 新增厨房员工设备权限
* *
* @param kitchenStaffDevicePrivilege 厨房员工设备权限 * @param kitchenStaffDevicePrivilege 厨房员工设备权限
* @return 结果 * @return 结果
*/ */
@ -44,7 +44,7 @@ public interface KitchenStaffDevicePrivilegeMapper {
/** /**
* 修改厨房员工设备权限 * 修改厨房员工设备权限
* *
* @param kitchenStaffDevicePrivilege 厨房员工设备权限 * @param kitchenStaffDevicePrivilege 厨房员工设备权限
* @return 结果 * @return 结果
*/ */
@ -52,7 +52,7 @@ public interface KitchenStaffDevicePrivilegeMapper {
/** /**
* 删除厨房员工设备权限 * 删除厨房员工设备权限
* *
* @param id 厨房员工设备权限主键 * @param id 厨房员工设备权限主键
* @return 结果 * @return 结果
*/ */
@ -60,11 +60,13 @@ public interface KitchenStaffDevicePrivilegeMapper {
/** /**
* 批量删除厨房员工设备权限 * 批量删除厨房员工设备权限
* *
* @param ids 需要删除的数据主键集合 * @param ids 需要删除的数据主键集合
* @return 结果 * @return 结果
*/ */
public int deleteKitchenStaffDevicePrivilegeByIds(Long[] ids); public int deleteKitchenStaffDevicePrivilegeByIds(Long[] ids);
public int deleteKitchenStaffDevicePrivilegeByStaffId(Long staffId); public int deleteKitchenStaffDevicePrivilegeByStaffId(Long staffId);
public int deleteKitchenStaffDevicePrivilegeByStaffIds(Long[] staffIds);
} }

View File

@ -56,12 +56,11 @@ public class KitchenStaffDevicePrivilegeServiceImpl implements IKitchenStaffDevi
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int insertKitchenStaffDevicePrivilege(List<KitchenStaffDevicePrivilege> kitchenStaffDevicePrivilege) { public int insertKitchenStaffDevicePrivilege(List<KitchenStaffDevicePrivilege> kitchenStaffDevicePrivilege) {
if(CollUtil.isNotEmpty(kitchenStaffDevicePrivilege)) { if(CollUtil.isNotEmpty(kitchenStaffDevicePrivilege)) {
kitchenStaffDevicePrivilegeMapper.deleteKitchenStaffDevicePrivilegeByStaffId(kitchenStaffDevicePrivilege.get(0).getStaffId());
for (KitchenStaffDevicePrivilege privilege : kitchenStaffDevicePrivilege) { for (KitchenStaffDevicePrivilege privilege : kitchenStaffDevicePrivilege) {
privilege.setCreateTime(DateUtils.getNowDate()); privilege.setCreateTime(DateUtils.getNowDate());
privilege.setCreateBy(SecurityUtils.getUsername()); privilege.setCreateBy(SecurityUtils.getUsername());
try { try {
return kitchenStaffDevicePrivilegeMapper.insertKitchenStaffDevicePrivilege(privilege); kitchenStaffDevicePrivilegeMapper.insertKitchenStaffDevicePrivilege(privilege);
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException(e.getMessage()); throw new ServiceException(e.getMessage());
} }

View File

@ -1,9 +1,6 @@
package com.bonus.canteen.core.kitchen.service.impl; package com.bonus.canteen.core.kitchen.service.impl;
import java.util.Arrays; import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.bonus.canteen.core.kitchen.domain.AccessAuthority; import com.bonus.canteen.core.kitchen.domain.AccessAuthority;
@ -61,6 +58,7 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
List<KitchenStaffDevicePrivilege> kitchenStaffDevicePrivilegeList = kitchenStaffDevicePrivilegeMapper List<KitchenStaffDevicePrivilege> kitchenStaffDevicePrivilegeList = kitchenStaffDevicePrivilegeMapper
.selectKitchenStaffDevicePrivilegeByStaffId(staffId); .selectKitchenStaffDevicePrivilegeByStaffId(staffId);
if(CollUtil.isNotEmpty(kitchenStaffDevicePrivilegeList)) { if(CollUtil.isNotEmpty(kitchenStaffDevicePrivilegeList)) {
List<AccessAuthority> accessAuthorityList = Lists.newArrayList();
AccessAuthority accessAuthority = new AccessAuthority(); AccessAuthority accessAuthority = new AccessAuthority();
for (KitchenStaffDevicePrivilege kitchenStaffDevicePrivilege : kitchenStaffDevicePrivilegeList) { for (KitchenStaffDevicePrivilege kitchenStaffDevicePrivilege : kitchenStaffDevicePrivilegeList) {
KitchenDeviceListVO deviceInfo = kitchenDeviceInfoMapper.selectKitchenDeviceInfoByDeviceId(kitchenStaffDevicePrivilege.getDeviceId()); KitchenDeviceListVO deviceInfo = kitchenDeviceInfoMapper.selectKitchenDeviceInfoByDeviceId(kitchenStaffDevicePrivilege.getDeviceId());
@ -71,7 +69,9 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
accessAuthority.setDeviceId(kitchenStaffDevicePrivilege.getDeviceId()); accessAuthority.setDeviceId(kitchenStaffDevicePrivilege.getDeviceId());
accessAuthority.setDeviceType(kitchenStaffDevicePrivilege.getDeviceType()); accessAuthority.setDeviceType(kitchenStaffDevicePrivilege.getDeviceType());
accessAuthority.setPrivilegeValue(kitchenStaffDevicePrivilege.getPrivilegeValue()); accessAuthority.setPrivilegeValue(kitchenStaffDevicePrivilege.getPrivilegeValue());
accessAuthorityList.add(accessAuthority);
} }
kitchenStaffInfo.setAccessAuthorityList(accessAuthorityList);
} }
} }
return kitchenStaffInfo; return kitchenStaffInfo;
@ -108,7 +108,9 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
public int insertKitchenStaffInfo(KitchenStaffInfo kitchenStaffInfo) { public int insertKitchenStaffInfo(KitchenStaffInfo kitchenStaffInfo) {
kitchenStaffInfo.setCreateTime(DateUtils.getNowDate()); kitchenStaffInfo.setCreateTime(DateUtils.getNowDate());
kitchenStaffInfo.setCreateBy(SecurityUtils.getUsername()); kitchenStaffInfo.setCreateBy(SecurityUtils.getUsername());
kitchenStaffInfo.setStaffId(null);
try { try {
checkUser(kitchenStaffInfo);
int result = kitchenStaffInfoMapper.insertKitchenStaffInfo(kitchenStaffInfo); int result = kitchenStaffInfoMapper.insertKitchenStaffInfo(kitchenStaffInfo);
addPrivileges(kitchenStaffInfo); addPrivileges(kitchenStaffInfo);
return result; return result;
@ -127,7 +129,11 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
public int updateKitchenStaffInfo(KitchenStaffInfo kitchenStaffInfo) { public int updateKitchenStaffInfo(KitchenStaffInfo kitchenStaffInfo) {
kitchenStaffInfo.setUpdateTime(DateUtils.getNowDate()); kitchenStaffInfo.setUpdateTime(DateUtils.getNowDate());
kitchenStaffInfo.setUpdateBy(SecurityUtils.getUsername()); kitchenStaffInfo.setUpdateBy(SecurityUtils.getUsername());
if(Objects.isNull(kitchenStaffInfo.getStaffId())) {
throw new ServiceException("员工编号不能为空");
}
try { try {
checkUser(kitchenStaffInfo);
kitchenStaffInfoMapper.updateKitchenStaffInfo(kitchenStaffInfo); kitchenStaffInfoMapper.updateKitchenStaffInfo(kitchenStaffInfo);
kitchenStaffDevicePrivilegeMapper.deleteKitchenStaffDevicePrivilegeByStaffId(kitchenStaffInfo.getStaffId()); kitchenStaffDevicePrivilegeMapper.deleteKitchenStaffDevicePrivilegeByStaffId(kitchenStaffInfo.getStaffId());
addPrivileges(kitchenStaffInfo); addPrivileges(kitchenStaffInfo);
@ -137,8 +143,24 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
return 1; return 1;
} }
private void checkUser(KitchenStaffInfo kitchenStaffInfo) {
KitchenStaffInfo kitchenStaffInfoByPhone = new KitchenStaffInfo();
kitchenStaffInfoByPhone.setUserId(kitchenStaffInfo.getUserId());
List<KitchenStaffInfo> staffInfoList = kitchenStaffInfoMapper.selectKitchenStaffInfoList(kitchenStaffInfoByPhone);
if(CollUtil.isNotEmpty(staffInfoList) && !Objects.equals(staffInfoList.get(0).getStaffId(), kitchenStaffInfo.getStaffId())) {
throw new ServiceException("该用户已存在");
}
kitchenStaffInfoByPhone = new KitchenStaffInfo();
kitchenStaffInfoByPhone.setStaffNo(kitchenStaffInfo.getStaffNo());
staffInfoList = kitchenStaffInfoMapper.selectKitchenStaffInfoList(kitchenStaffInfoByPhone);
if(CollUtil.isNotEmpty(staffInfoList) && !Objects.equals(staffInfoList.get(0).getStaffId(), kitchenStaffInfo.getStaffId())) {
throw new ServiceException("该用户编号已存在");
}
}
private void addPrivileges(KitchenStaffInfo kitchenStaffInfo) { private void addPrivileges(KitchenStaffInfo kitchenStaffInfo) {
if(CollUtil.isNotEmpty(kitchenStaffInfo.getAccessAuthorityList())) { if(CollUtil.isNotEmpty(kitchenStaffInfo.getAccessAuthorityList())) {
List<KitchenStaffDevicePrivilege> kitchenStaffDevicePrivilegeList = new ArrayList<>();
for(AccessAuthority access : kitchenStaffInfo.getAccessAuthorityList()) { for(AccessAuthority access : kitchenStaffInfo.getAccessAuthorityList()) {
KitchenStaffDevicePrivilege kitchenStaffDevicePrivilege = new KitchenStaffDevicePrivilege(); KitchenStaffDevicePrivilege kitchenStaffDevicePrivilege = new KitchenStaffDevicePrivilege();
kitchenStaffDevicePrivilege.setStaffId(kitchenStaffInfo.getStaffId()); kitchenStaffDevicePrivilege.setStaffId(kitchenStaffInfo.getStaffId());
@ -146,8 +168,9 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
kitchenStaffDevicePrivilege.setDeviceType(access.getDeviceType()); kitchenStaffDevicePrivilege.setDeviceType(access.getDeviceType());
kitchenStaffDevicePrivilege.setPrivilegeName("is_enable"); kitchenStaffDevicePrivilege.setPrivilegeName("is_enable");
kitchenStaffDevicePrivilege.setPrivilegeValue(access.getPrivilegeValue()); kitchenStaffDevicePrivilege.setPrivilegeValue(access.getPrivilegeValue());
kitchenStaffDevicePrivilegeService.insertKitchenStaffDevicePrivilege(Collections.singletonList(kitchenStaffDevicePrivilege)); kitchenStaffDevicePrivilegeList.add(kitchenStaffDevicePrivilege);
} }
kitchenStaffDevicePrivilegeService.insertKitchenStaffDevicePrivilege(kitchenStaffDevicePrivilegeList);
} }
} }
@ -159,6 +182,7 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
*/ */
@Override @Override
public int deleteKitchenStaffInfoByStaffIds(Long[] staffIds) { public int deleteKitchenStaffInfoByStaffIds(Long[] staffIds) {
kitchenStaffDevicePrivilegeMapper.deleteKitchenStaffDevicePrivilegeByStaffIds(staffIds);
return kitchenStaffInfoMapper.deleteKitchenStaffInfoByStaffIds(staffIds); return kitchenStaffInfoMapper.deleteKitchenStaffInfoByStaffIds(staffIds);
} }
@ -170,6 +194,7 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
*/ */
@Override @Override
public int deleteKitchenStaffInfoByStaffId(Long staffId) { public int deleteKitchenStaffInfoByStaffId(Long staffId) {
kitchenStaffDevicePrivilegeMapper.deleteKitchenStaffDevicePrivilegeByStaffId(staffId);
return kitchenStaffInfoMapper.deleteKitchenStaffInfoByStaffId(staffId); return kitchenStaffInfoMapper.deleteKitchenStaffInfoByStaffId(staffId);
} }
} }

View File

@ -96,4 +96,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<delete id="deleteKitchenStaffDevicePrivilegeByStaffId" parameterType="Long"> <delete id="deleteKitchenStaffDevicePrivilegeByStaffId" parameterType="Long">
delete from kitchen_staff_device_privilege where staff_id = #{staffId} delete from kitchen_staff_device_privilege where staff_id = #{staffId}
</delete> </delete>
<delete id="deleteKitchenStaffDevicePrivilegeByStaffIds">
delete from kitchen_staff_device_privilege where staff_id in
<foreach item="staffId" collection="array" open="(" separator="," close=")">
#{staffId}
</foreach>
</delete>
</mapper> </mapper>

View File

@ -42,7 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="nutrityCertExpire != null "> and nutrity_cert_expire = #{nutrityCertExpire}</if> <if test="nutrityCertExpire != null "> and nutrity_cert_expire = #{nutrityCertExpire}</if>
<if test="safetyCertExpire != null "> and safety_cert_expire = #{safetyCertExpire}</if> <if test="safetyCertExpire != null "> and safety_cert_expire = #{safetyCertExpire}</if>
<if test="sex != null "> and su.sex = #{sex}</if> <if test="sex != null "> and su.sex = #{sex}</if>
<if test="postIds != null and postIds.length() > 0"> <if test="postIds != null and postIds.length > 0">
and sup.post_id in and sup.post_id in
<foreach item="postId" collection="postIds" open="(" separator="," close=")"> <foreach item="postId" collection="postIds" open="(" separator="," close=")">
#{postId} #{postId}