diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/kitchen/service/impl/KitchenStaffInfoServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/kitchen/service/impl/KitchenStaffInfoServiceImpl.java index 8e75e46..960141b 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/kitchen/service/impl/KitchenStaffInfoServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/kitchen/service/impl/KitchenStaffInfoServiceImpl.java @@ -20,6 +20,7 @@ import com.bonus.common.core.utils.StringUtils; import com.bonus.common.houqin.constant.DeviceTypeEnum; import com.bonus.common.houqin.utils.SM4EncryptUtils; import com.bonus.common.security.utils.SecurityUtils; +import com.mysql.cj.x.protobuf.MysqlxDatatypes; import org.apache.catalina.security.SecurityUtil; import org.apache.commons.compress.utils.Lists; import org.springframework.beans.factory.annotation.Autowired; @@ -137,7 +138,16 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService { kitchenStaffInfo.setCreateTime(DateUtils.getNowDate()); kitchenStaffInfo.setCreateBy(SecurityUtils.getUsername()); kitchenStaffInfo.setStaffId(null); + kitchenStaffInfo.setMobile(StringUtils.defaultIfBlank(kitchenStaffInfo.getMobile(), null)); try { + if(Objects.nonNull(kitchenStaffInfo.getMobile())) { + KitchenStaffInfo kitchenStaffInfoDTO = new KitchenStaffInfo(); + kitchenStaffInfoDTO.setMobile(kitchenStaffInfo.getMobile()); + List oldKitchenStaffInfoList = kitchenStaffInfoMapper.selectKitchenStaffInfoList(kitchenStaffInfoDTO); + if(CollUtil.isNotEmpty(oldKitchenStaffInfoList)) { + throw new ServiceException("手机号已存在"); + } + } if(StringUtils.isNotBlank(kitchenStaffInfo.getHealthCertFrontImg()) && Objects.isNull(kitchenStaffInfo.getHealthCertExpire())) { throw new ServiceException("健康证有效期不能为空"); @@ -167,12 +177,29 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService { */ @Override public int updateKitchenStaffInfo(KitchenStaffInfo kitchenStaffInfo) { - kitchenStaffInfo.setUpdateTime(DateUtils.getNowDate()); - kitchenStaffInfo.setUpdateBy(SecurityUtils.getUsername()); - if(Objects.isNull(kitchenStaffInfo.getStaffNo())) { - throw new ServiceException("员工编号不能为空"); - } try { + if(Objects.isNull(kitchenStaffInfo.getStaffId())) { + throw new ServiceException("员工ID不能为空"); + } + kitchenStaffInfo.setMobile(StringUtils.defaultIfBlank(kitchenStaffInfo.getMobile(), null)); + if(Objects.nonNull(kitchenStaffInfo.getMobile())) { + kitchenStaffInfo.setMobile(kitchenStaffInfo.getMobile().trim()); + KitchenStaffInfo staffInfo = kitchenStaffInfoMapper.selectKitchenStaffInfoByStaffId(kitchenStaffInfo.getStaffId()); + if(Objects.nonNull(staffInfo) && !kitchenStaffInfo.getMobile().equals(staffInfo.getMobile())) { + KitchenStaffInfo kitchenStaffInfoDTO = new KitchenStaffInfo(); + kitchenStaffInfoDTO.setMobile(kitchenStaffInfo.getMobile()); + List oldKitchenStaffInfoList = kitchenStaffInfoMapper.selectKitchenStaffInfoList(kitchenStaffInfoDTO); + if(CollUtil.isNotEmpty(oldKitchenStaffInfoList)) { + throw new ServiceException("手机号已存在"); + } + } + } + + kitchenStaffInfo.setUpdateTime(DateUtils.getNowDate()); + kitchenStaffInfo.setUpdateBy(SecurityUtils.getUsername()); + if(Objects.isNull(kitchenStaffInfo.getStaffNo())) { + throw new ServiceException("员工编号不能为空"); + } checkUser(kitchenStaffInfo); kitchenStaffInfoMapper.updateKitchenStaffInfo(kitchenStaffInfo); kitchenStaffDevicePrivilegeMapper.deleteKitchenStaffDevicePrivilegeByStaffId(kitchenStaffInfo.getStaffId()); diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/kitchen/KitchenStaffInfoMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/kitchen/KitchenStaffInfoMapper.xml index 663fd09..b743707 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/kitchen/KitchenStaffInfoMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/kitchen/KitchenStaffInfoMapper.xml @@ -50,6 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and health_cert_expire = #{healthCertExpire} and nutrity_cert_expire = #{nutrityCertExpire} and safety_cert_expire = #{safetyCertExpire} + mobile = #{mobile} and ksf.face_state = #{faceState}