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 @@