From 2f4b942050feffe52e9e4a7b9be757027f6bd91a Mon Sep 17 00:00:00 2001 From: liuxiaoxu <1793812695@qq.com> Date: Fri, 7 Jun 2024 12:15:13 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=E4=BB=93=E5=BA=93=E7=AE=A1=E7=90=86:=20?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E7=9B=98=E7=82=B9=20=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E7=9B=98=E7=82=B9=E6=96=B0=E5=A2=9E=E8=87=AA=E5=8A=A8=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E4=B8=80=E5=AE=9A=E8=A7=84=E5=88=99=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=9B=98=E7=82=B9=E5=8D=95=E5=8F=B7=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=9B=98=E7=82=B9=E5=8D=95=E5=8F=B7=E6=96=B0=E5=A2=9E=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=20=E4=BF=AE=E6=94=B9=E5=BA=93=E5=AD=98=E7=9B=98?= =?UTF-8?q?=E7=82=B9=E6=96=B0=E5=A2=9E=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WarehouseInventoryCheckController.java | 35 --------- .../mapper/WarehouseInventoryCheckMapper.java | 3 + .../IWarehouseInventoryCheckService.java | 29 -------- .../WarehouseInventoryCheckServiceImpl.java | 73 ++++++++----------- .../WarehouseInventoryCheckMapper.xml | 5 ++ .../warehouse/inventoryCheck/add.html | 6 -- 6 files changed, 40 insertions(+), 111 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseInventoryCheckController.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseInventoryCheckController.java index ee0d970c..684f538a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseInventoryCheckController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseInventoryCheckController.java @@ -112,40 +112,5 @@ public class WarehouseInventoryCheckController extends BaseController return toAjax(warehouseInventoryCheckService.updateWarehouseInventoryCheck(warehouseInventoryCheck)); } - /** - * 删除仓库库存盘点 - */ - @RequiresPermissions("warehouse:inventoryCheck:remove") - @Log(title = "仓库库存盘点", businessType = BusinessType.DELETE) - @PostMapping( "/remove") - @ResponseBody - public AjaxResult remove(String ids) - { - return toAjax(warehouseInventoryCheckService.deleteWarehouseInventoryCheckByIds(ids)); - } - - /** - * 作废仓库库存盘点 - */ - @RequiresPermissions("warehouse:inventoryCheck:cancel") - @Log(title = "仓库库存盘点", businessType = BusinessType.CANCEL) - @GetMapping( "/cancel/{id}") - @ResponseBody - public AjaxResult cancel(@PathVariable("id") Long id){ - return toAjax(warehouseInventoryCheckService.cancelWarehouseInventoryCheckById(id)); - } - - /** - * 恢复仓库库存盘点 - */ - @RequiresPermissions("warehouse:inventoryCheck:restore") - @Log(title = "仓库库存盘点", businessType = BusinessType.RESTORE) - @GetMapping( "/restore/{id}") - @ResponseBody - public AjaxResult restore(@PathVariable("id")Long id) - { - return toAjax(warehouseInventoryCheckService.restoreWarehouseInventoryCheckById(id)); - } - } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/mapper/WarehouseInventoryCheckMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/mapper/WarehouseInventoryCheckMapper.java index dc8238cf..8cfff5db 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/mapper/WarehouseInventoryCheckMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/mapper/WarehouseInventoryCheckMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.warehouse.mapper; import java.util.List; import com.ruoyi.warehouse.domain.WarehouseInventoryCheck; +import org.apache.ibatis.annotations.Param; /** * 仓库库存盘点Mapper接口 @@ -74,4 +75,6 @@ public interface WarehouseInventoryCheckMapper * @return 结果 */ public int restoreWarehouseInventoryCheckById(Long inventoryCheckId); + + public String findMaxRoundCode(@Param("prefix") String prefix); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseInventoryCheckService.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseInventoryCheckService.java index bcf541aa..178ce8fa 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseInventoryCheckService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseInventoryCheckService.java @@ -43,33 +43,4 @@ public interface IWarehouseInventoryCheckService */ public int updateWarehouseInventoryCheck(WarehouseInventoryCheck warehouseInventoryCheck); - /** - * 批量删除仓库库存盘点 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - public int deleteWarehouseInventoryCheckByIds(String ids); - - /** - * 删除仓库库存盘点信息 - * - * @param inventoryCheckId 仓库库存盘点ID - * @return 结果 - */ - public int deleteWarehouseInventoryCheckById(Long inventoryCheckId); - - /** - * 作废仓库库存盘点 - * @param inventoryCheckId 仓库库存盘点ID - * @return - */ - int cancelWarehouseInventoryCheckById(Long inventoryCheckId); - - /** - * 恢复仓库库存盘点 - * @param inventoryCheckId 仓库库存盘点ID - * @return - */ - int restoreWarehouseInventoryCheckById(Long inventoryCheckId); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryCheckServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryCheckServiceImpl.java index f41a5577..642fea59 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryCheckServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryCheckServiceImpl.java @@ -1,8 +1,14 @@ package com.ruoyi.warehouse.service.impl; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; + +import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.common.utils.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.warehouse.mapper.WarehouseInventoryCheckMapper; @@ -55,6 +61,14 @@ public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCh @Override public int insertWarehouseInventoryCheck(WarehouseInventoryCheck warehouseInventoryCheck) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String prefix = "KCPD" + simpleDateFormat.format(new Date()).replace("-", ""); + + String maxCode = warehouseInventoryCheckMapper.findMaxRoundCode(prefix); + + String newCode = generateCode(prefix,maxCode); + + warehouseInventoryCheck.setInventoryCheckCode(newCode); warehouseInventoryCheck.setCreateTime(DateUtils.getNowDate()); String loginName = ShiroUtils.getLoginName(); warehouseInventoryCheck.setCreateBy(loginName); @@ -76,51 +90,28 @@ public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCh return warehouseInventoryCheckMapper.updateWarehouseInventoryCheck(warehouseInventoryCheck); } - /** - * 删除仓库库存盘点对象 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - @Override - public int deleteWarehouseInventoryCheckByIds(String ids) - { - return warehouseInventoryCheckMapper.deleteWarehouseInventoryCheckByIds(Convert.toStrArray(ids)); - } - - /** - * 删除仓库库存盘点信息 - * - * @param inventoryCheckId 仓库库存盘点ID - * @return 结果 - */ - @Override - public int deleteWarehouseInventoryCheckById(Long inventoryCheckId) - { - return warehouseInventoryCheckMapper.deleteWarehouseInventoryCheckById(inventoryCheckId); - } /** - * 作废仓库库存盘点 + *库存盘点单号生成规则 + *系统自动生成,按照特定编码,编码暂用【KCPD+年月日+001】, + *自增长,如:KCPD20231111001,KCPD20231111002 * - * @param inventoryCheckId 仓库库存盘点ID - * @return 结果 */ - @Override - public int cancelWarehouseInventoryCheckById(Long inventoryCheckId) - { - return warehouseInventoryCheckMapper.cancelWarehouseInventoryCheckById(inventoryCheckId); - } + public static String generateCode(String prefix, String maxCode){ + if (StringUtils.isEmpty(maxCode)){ + return prefix + "001"; + } - /** - * 恢复仓库库存盘点信息 - * - * @param inventoryCheckId 仓库库存盘点ID - * @return 结果 - */ - @Override - public int restoreWarehouseInventoryCheckById(Long inventoryCheckId) - { - return warehouseInventoryCheckMapper.restoreWarehouseInventoryCheckById(inventoryCheckId); + //解析并递增编号 + int sequence = Integer.parseInt(maxCode.substring(4)) + 1; + + //检查序列号是否溢出 + if (sequence > 999){ + throw new BusinessException("当前编号已达到最大值999,请检查或调整策略"); + } + + //格式化序列号,自动补零至三位 + DecimalFormat df = new DecimalFormat("000"); + return prefix + df.format(sequence); } } diff --git a/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseInventoryCheckMapper.xml b/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseInventoryCheckMapper.xml index d92a3cb6..fda1d2b7 100644 --- a/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseInventoryCheckMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseInventoryCheckMapper.xml @@ -119,4 +119,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update warehouse_inventory_check set del_flag = '0' where inventory_check_id = #{inventoryCheckId} + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/add.html b/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/add.html index 5ab7b036..bdde0e9f 100644 --- a/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/add.html +++ b/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/add.html @@ -7,12 +7,6 @@