From bee4498fa81628df133d950b2599d0c0ba598aa5 Mon Sep 17 00:00:00 2001 From: x_z Date: Mon, 24 Apr 2023 10:41:03 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=90=8C=E6=AD=A5=E8=B4=A7=E4=BD=8D=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/glxp/api/dao/auth/InvSpaceDao.java | 16 +++++++ .../purchase/SupCertRemindMsgResponse.java | 1 + .../auth/impl/InvSpaceServiceImpl.java | 43 +++++++++++-------- .../mybatis/mapper/auth/InvSpaceDao.xml | 26 +++++++++++ 4 files changed, 68 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/glxp/api/dao/auth/InvSpaceDao.java b/src/main/java/com/glxp/api/dao/auth/InvSpaceDao.java index c123caa5..7ee32b2a 100644 --- a/src/main/java/com/glxp/api/dao/auth/InvSpaceDao.java +++ b/src/main/java/com/glxp/api/dao/auth/InvSpaceDao.java @@ -87,4 +87,20 @@ public interface InvSpaceDao extends BaseMapperPlus selectByInvCode(@Param("invStorageCode") String invStorageCode, @Param("invWarehouseCode") String invWarehouseCode, @Param("invSpaceCode") String invSpaceCode); + + /** + * 查询此仓库下,货位名称是否重复 + * + * @param invSpace + * @return + */ + List selectExistByName(InvSpace invSpace); + + /** + * 查询仓库下最大的货位编码 + * + * @param invCode + * @return + */ + String getMaxSpaceCode(@Param("invCode") String invCode); } \ No newline at end of file diff --git a/src/main/java/com/glxp/api/res/purchase/SupCertRemindMsgResponse.java b/src/main/java/com/glxp/api/res/purchase/SupCertRemindMsgResponse.java index 7d0f6238..03bf9dc0 100644 --- a/src/main/java/com/glxp/api/res/purchase/SupCertRemindMsgResponse.java +++ b/src/main/java/com/glxp/api/res/purchase/SupCertRemindMsgResponse.java @@ -92,6 +92,7 @@ public class SupCertRemindMsgResponse { * 资质证书名称 */ private String certName; + /** * 提醒次数 */ diff --git a/src/main/java/com/glxp/api/service/auth/impl/InvSpaceServiceImpl.java b/src/main/java/com/glxp/api/service/auth/impl/InvSpaceServiceImpl.java index e2510653..0a3b051c 100644 --- a/src/main/java/com/glxp/api/service/auth/impl/InvSpaceServiceImpl.java +++ b/src/main/java/com/glxp/api/service/auth/impl/InvSpaceServiceImpl.java @@ -53,6 +53,15 @@ public class InvSpaceServiceImpl implements InvSpaceService { if (!"success".equals(result)) { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, result); } + + + //获取当前仓库下的最大货位编码 + String maxSpaceCode = invSpaceDao.getMaxSpaceCode(invSpace.getInvWarehouseCode()); + if (StrUtil.isBlank(maxSpaceCode)) { + maxSpaceCode = "0000"; + } + String spaceCode = getSpaceCode(maxSpaceCode); + invSpace.setCode(spaceCode); Date date = new Date(); AuthAdmin user = customerService.getUserBean(); invSpace.setCreateTime(date); @@ -71,8 +80,8 @@ public class InvSpaceServiceImpl implements InvSpaceService { */ private static BaseResponse verifySpaceParams(InvSpace invSpace) { //校验参数 - if (StrUtil.isBlank(invSpace.getCode()) || StrUtil.isBlank(invSpace.getName())) { - return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "货位名称和货位号不能为空!"); + if (StrUtil.isBlank(invSpace.getName())) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "货位名称不能为空!"); } if (StrUtil.isBlank(invSpace.getInvStorageCode()) || StrUtil.isBlank(invSpace.getInvWarehouseCode())) { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "请指定所属仓库和分库!"); @@ -142,22 +151,8 @@ public class InvSpaceServiceImpl implements InvSpaceService { * @return */ public String verifyExist(InvSpace invSpace) { - //先检查货位号是否重复 - List invSpaces = invSpaceDao.selectByInvCode(invSpace.getInvStorageCode(), invSpace.getInvWarehouseCode(), invSpace.getCode()); - if (CollUtil.isNotEmpty(invSpaces)) { - //判断ID是否为空,如果为空表示数据为新增货位,是重复添加- - if (null == invSpace.getId()) { - return "货位信息已存在"; - } - - //此分库下,货位号重复,判断ID是否与当前货位相同 - for (InvSpace space : invSpaces) { - if (!space.getId().equals(invSpace.getId())) { - return "货位信息已存在"; - } - } - } - List list = invSpaceDao.selectExist(invSpace); + //判断此货位名称是否重复 + List list = invSpaceDao.selectExistByName(invSpace); if (CollUtil.isNotEmpty(list)) { if (null == invSpace.getId()) { return "货位信息已存在"; @@ -171,4 +166,16 @@ public class InvSpaceServiceImpl implements InvSpaceService { return "success"; } + /** + * 获取新的货位编码,基于传入的最大编码参数+1,并拼接成4位数返回 + * + * @param maxSpaceCode 当前最大货位编码 + * @return + */ + public String getSpaceCode(String maxSpaceCode) { + Long l = Long.parseLong(maxSpaceCode) + 1L; + return String.format("%04d", l); + } + + } diff --git a/src/main/resources/mybatis/mapper/auth/InvSpaceDao.xml b/src/main/resources/mybatis/mapper/auth/InvSpaceDao.xml index c0872f73..951a85e7 100644 --- a/src/main/resources/mybatis/mapper/auth/InvSpaceDao.xml +++ b/src/main/resources/mybatis/mapper/auth/InvSpaceDao.xml @@ -382,4 +382,30 @@ + + + + \ No newline at end of file