diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookMaterialMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookMaterialMapper.java index 65f86c4..66e6065 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookMaterialMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookMaterialMapper.java @@ -6,14 +6,14 @@ import org.apache.ibatis.annotations.Param; /** * 原料信息Mapper接口 - * + * * @author xsheng * @date 2025-05-25 */ public interface CookMaterialMapper { /** * 查询原料信息 - * + * * @param materialId 原料信息主键 * @return 原料信息 */ @@ -21,7 +21,7 @@ public interface CookMaterialMapper { /** * 查询原料信息列表 - * + * * @param cookMaterial 原料信息 * @return 原料信息集合 */ @@ -29,7 +29,7 @@ public interface CookMaterialMapper { /** * 新增原料信息 - * + * * @param cookMaterial 原料信息 * @return 结果 */ @@ -37,7 +37,7 @@ public interface CookMaterialMapper { /** * 修改原料信息 - * + * * @param cookMaterial 原料信息 * @return 结果 */ @@ -45,7 +45,7 @@ public interface CookMaterialMapper { /** * 删除原料信息 - * + * * @param materialId 原料信息主键 * @return 结果 */ @@ -53,7 +53,7 @@ public interface CookMaterialMapper { /** * 批量删除原料信息 - * + * * @param materialIds 需要删除的数据主键集合 * @return 结果 */ @@ -80,5 +80,8 @@ public interface CookMaterialMapper { * @param materialIds 原料ID * @return 存在返回1 */ + public int checkIsUsecMaterial(@Param("materialIds") Long[] materialIds); + public int checkIsUse(@Param("materialIds") Long[] materialIds); + } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookMaterialServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookMaterialServiceImpl.java index b2d5fa7..bc13663 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookMaterialServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookMaterialServiceImpl.java @@ -3,6 +3,8 @@ package com.bonus.canteen.core.cook.service.impl; import java.util.List; import java.util.Objects; +import com.bonus.canteen.core.common.utils.FileUrlUtil; +import com.bonus.canteen.core.utils.SysUtil; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.StringUtils; @@ -14,7 +16,7 @@ import com.bonus.canteen.core.cook.service.ICookMaterialService; /** * 原料信息Service业务层处理 - * + * * @author xsheng * @date 2025-05-25 */ @@ -25,7 +27,7 @@ public class CookMaterialServiceImpl implements ICookMaterialService { /** * 查询原料信息 - * + * * @param materialId 原料信息主键 * @return 原料信息 */ @@ -36,18 +38,26 @@ public class CookMaterialServiceImpl implements ICookMaterialService { /** * 查询原料信息列表 - * + * * @param cookMaterial 原料信息 * @return 原料信息 */ @Override public List selectCookMaterialList(CookMaterial cookMaterial) { - return cookMaterialMapper.selectCookMaterialList(cookMaterial); + List cookMaterials = cookMaterialMapper.selectCookMaterialList(cookMaterial); + cookMaterials.forEach(item -> { + String imgUrl = item.getImgUrl(); + if (imgUrl != null && !imgUrl.isEmpty()) { + item.setImgUrl(FileUrlUtil.getFileUrl(imgUrl)); + } + }); + return cookMaterials; + } /** * 新增原料信息 - * + * * @param cookMaterial 原料信息 * @return 结果 */ @@ -83,7 +93,7 @@ public class CookMaterialServiceImpl implements ICookMaterialService { /** * 修改原料信息 - * + * * @param cookMaterial 原料信息 * @return 结果 */ @@ -122,7 +132,7 @@ public class CookMaterialServiceImpl implements ICookMaterialService { /** * 批量删除原料信息 - * + * * @param materialIds 需要删除的原料信息主键 * @return 结果 */ @@ -137,7 +147,7 @@ public class CookMaterialServiceImpl implements ICookMaterialService { /** * 删除原料信息信息 - * + * * @param materialId 原料信息主键 * @return 结果 */ diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/ims/mapper/WarehouseInfoMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/ims/mapper/WarehouseInfoMapper.java index 4ae71fc..c035f88 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/ims/mapper/WarehouseInfoMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/ims/mapper/WarehouseInfoMapper.java @@ -5,14 +5,14 @@ import com.bonus.canteen.core.ims.domain.WarehouseInfo; /** * 仓库信息Mapper接口 - * + * * @author xsheng * @date 2025-06-19 */ public interface WarehouseInfoMapper { /** * 查询仓库信息 - * + * * @param warehouseId 仓库信息主键 * @return 仓库信息 */ @@ -22,7 +22,7 @@ public interface WarehouseInfoMapper { /** * 查询仓库信息列表 - * + * * @param imsWarehouseInfo 仓库信息 * @return 仓库信息集合 */ @@ -30,7 +30,7 @@ public interface WarehouseInfoMapper { /** * 新增仓库信息 - * + * * @param imsWarehouseInfo 仓库信息 * @return 结果 */ @@ -38,7 +38,7 @@ public interface WarehouseInfoMapper { /** * 修改仓库信息 - * + * * @param imsWarehouseInfo 仓库信息 * @return 结果 */ @@ -46,7 +46,7 @@ public interface WarehouseInfoMapper { /** * 删除仓库信息 - * + * * @param warehouseId 仓库信息主键 * @return 结果 */ @@ -54,9 +54,11 @@ public interface WarehouseInfoMapper { /** * 批量删除仓库信息 - * + * * @param warehouseIds 需要删除的数据主键集合 * @return 结果 */ public int deleteImsWarehouseInfoByWarehouseIds(Long[] warehouseIds); + + int findWarehouseCode(String warehouseCode); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/ims/service/impl/ImsUnitServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/ims/service/impl/ImsUnitServiceImpl.java index 9e4cfa8..dffabce 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/ims/service/impl/ImsUnitServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/ims/service/impl/ImsUnitServiceImpl.java @@ -2,6 +2,8 @@ package com.bonus.canteen.core.ims.service.impl; import java.util.Collections; import java.util.List; + +import com.bonus.canteen.core.cook.mapper.CookMaterialMapper; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -12,7 +14,7 @@ import com.bonus.canteen.core.ims.service.IImsUnitService; /** * 计量单位Service业务层处理 - * + * * @author xsheng * @date 2025-06-19 */ @@ -20,10 +22,12 @@ import com.bonus.canteen.core.ims.service.IImsUnitService; public class ImsUnitServiceImpl implements IImsUnitService { @Autowired private ImsUnitMapper imsUnitMapper; + @Autowired + private CookMaterialMapper cookMaterialMapper; /** * 查询计量单位 - * + * * @param unitId 计量单位主键 * @return 计量单位 */ @@ -39,7 +43,7 @@ public class ImsUnitServiceImpl implements IImsUnitService { /** * 查询计量单位列表 - * + * * @param imsUnit 计量单位 * @return 计量单位 */ @@ -50,7 +54,7 @@ public class ImsUnitServiceImpl implements IImsUnitService { /** * 新增计量单位 - * + * * @param imsUnit 计量单位 * @return 结果 */ @@ -66,7 +70,7 @@ public class ImsUnitServiceImpl implements IImsUnitService { /** * 修改计量单位 - * + * * @param imsUnit 计量单位 * @return 结果 */ @@ -82,18 +86,22 @@ public class ImsUnitServiceImpl implements IImsUnitService { /** * 批量删除计量单位 - * + * * @param unitIds 需要删除的计量单位主键 * @return 结果 */ @Override public int deleteImsUnitByUnitIds(Long[] unitIds) { + //从原料表中去查询,如果存在,就不能进行删除 + if (cookMaterialMapper.checkIsUsecMaterial(unitIds) > 0){ + throw new ServiceException("该计量单位被使用,不允许删除!"); + } return imsUnitMapper.deleteImsUnitByUnitIds(unitIds); } /** * 删除计量单位信息 - * + * * @param unitId 计量单位主键 * @return 结果 */ diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/ims/service/impl/WarehouseInfoServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/ims/service/impl/WarehouseInfoServiceImpl.java index 44b36e9..1bac533 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/ims/service/impl/WarehouseInfoServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/ims/service/impl/WarehouseInfoServiceImpl.java @@ -11,7 +11,7 @@ import com.bonus.canteen.core.ims.service.IWarehouseInfoService; /** * 仓库信息Service业务层处理 - * + * * @author xsheng * @date 2025-06-19 */ @@ -22,7 +22,7 @@ public class WarehouseInfoServiceImpl implements IWarehouseInfoService { /** * 查询仓库信息 - * + * * @param warehouseId 仓库信息主键 * @return 仓库信息 */ @@ -33,7 +33,7 @@ public class WarehouseInfoServiceImpl implements IWarehouseInfoService { /** * 查询仓库信息列表 - * + * * @param imsWarehouseInfo 仓库信息 * @return 仓库信息 */ @@ -44,7 +44,7 @@ public class WarehouseInfoServiceImpl implements IWarehouseInfoService { /** * 新增仓库信息 - * + * * @param imsWarehouseInfo 仓库信息 * @return 结果 */ @@ -52,6 +52,11 @@ public class WarehouseInfoServiceImpl implements IWarehouseInfoService { public int insertImsWarehouseInfo(WarehouseInfo imsWarehouseInfo) { imsWarehouseInfo.setCreateTime(DateUtils.getNowDate()); try { + //检查仓库id是否唯一,唯一的话进行下面,否在返回进行提示 + int warehouseCode = imsWarehouseInfoMapper.findWarehouseCode(imsWarehouseInfo.getWarehouseCode()); + if (warehouseCode>0) { + throw new ServiceException("仓库编码已存在"); + } return imsWarehouseInfoMapper.insertImsWarehouseInfo(imsWarehouseInfo); } catch (Exception e) { throw new ServiceException(e.getMessage()); @@ -60,7 +65,7 @@ public class WarehouseInfoServiceImpl implements IWarehouseInfoService { /** * 修改仓库信息 - * + * * @param imsWarehouseInfo 仓库信息 * @return 结果 */ @@ -68,6 +73,10 @@ public class WarehouseInfoServiceImpl implements IWarehouseInfoService { public int updateImsWarehouseInfo(WarehouseInfo imsWarehouseInfo) { imsWarehouseInfo.setUpdateTime(DateUtils.getNowDate()); try { + int warehouseCode = imsWarehouseInfoMapper.findWarehouseCode(imsWarehouseInfo.getWarehouseCode()); + if (warehouseCode>0) { + throw new ServiceException("仓库编码已存在"); + } return imsWarehouseInfoMapper.updateImsWarehouseInfo(imsWarehouseInfo); } catch (Exception e) { throw new ServiceException(e.getMessage()); @@ -76,7 +85,7 @@ public class WarehouseInfoServiceImpl implements IWarehouseInfoService { /** * 批量删除仓库信息 - * + * * @param warehouseIds 需要删除的仓库信息主键 * @return 结果 */ @@ -87,7 +96,7 @@ public class WarehouseInfoServiceImpl implements IWarehouseInfoService { /** * 删除仓库信息信息 - * + * * @param warehouseId 仓库信息主键 * @return 结果 */ diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookMaterialMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookMaterialMapper.xml index 44857ef..5356b52 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookMaterialMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookMaterialMapper.xml @@ -135,6 +135,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + insert into cook_material diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/ims/WarehouseInfoMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/ims/WarehouseInfoMapper.xml index 4567ae7..398679a 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/ims/WarehouseInfoMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/ims/WarehouseInfoMapper.xml @@ -76,6 +76,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{areaId} + insert into ims_warehouse_info