Browse Source

[fix]仓库管理:

库存盘点
库存盘点新增自动安装一定规则生成盘点单号
修改盘点单号新增字段
修改库存盘点新增接口
dev
liuxiaoxu 5 months ago
parent
commit
2f4b942050
  1. 35
      ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseInventoryCheckController.java
  2. 3
      ruoyi-admin/src/main/java/com/ruoyi/warehouse/mapper/WarehouseInventoryCheckMapper.java
  3. 29
      ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseInventoryCheckService.java
  4. 73
      ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryCheckServiceImpl.java
  5. 5
      ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseInventoryCheckMapper.xml
  6. 6
      ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/add.html

35
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)); 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));
}
} }

3
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 java.util.List;
import com.ruoyi.warehouse.domain.WarehouseInventoryCheck; import com.ruoyi.warehouse.domain.WarehouseInventoryCheck;
import org.apache.ibatis.annotations.Param;
/** /**
* 仓库库存盘点Mapper接口 * 仓库库存盘点Mapper接口
@ -74,4 +75,6 @@ public interface WarehouseInventoryCheckMapper
* @return 结果 * @return 结果
*/ */
public int restoreWarehouseInventoryCheckById(Long inventoryCheckId); public int restoreWarehouseInventoryCheckById(Long inventoryCheckId);
public String findMaxRoundCode(@Param("prefix") String prefix);
} }

29
ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseInventoryCheckService.java

@ -43,33 +43,4 @@ public interface IWarehouseInventoryCheckService
*/ */
public int updateWarehouseInventoryCheck(WarehouseInventoryCheck warehouseInventoryCheck); 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);
} }

73
ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryCheckServiceImpl.java

@ -1,8 +1,14 @@
package com.ruoyi.warehouse.service.impl; package com.ruoyi.warehouse.service.impl;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List; import java.util.List;
import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.warehouse.mapper.WarehouseInventoryCheckMapper; import com.ruoyi.warehouse.mapper.WarehouseInventoryCheckMapper;
@ -55,6 +61,14 @@ public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCh
@Override @Override
public int insertWarehouseInventoryCheck(WarehouseInventoryCheck warehouseInventoryCheck) 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()); warehouseInventoryCheck.setCreateTime(DateUtils.getNowDate());
String loginName = ShiroUtils.getLoginName(); String loginName = ShiroUtils.getLoginName();
warehouseInventoryCheck.setCreateBy(loginName); warehouseInventoryCheck.setCreateBy(loginName);
@ -76,51 +90,28 @@ public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCh
return warehouseInventoryCheckMapper.updateWarehouseInventoryCheck(warehouseInventoryCheck); 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
*自增长:KCPD20231111001KCPD20231111002
* *
* @param inventoryCheckId 仓库库存盘点ID
* @return 结果
*/ */
@Override public static String generateCode(String prefix, String maxCode){
public int cancelWarehouseInventoryCheckById(Long inventoryCheckId) if (StringUtils.isEmpty(maxCode)){
{ return prefix + "001";
return warehouseInventoryCheckMapper.cancelWarehouseInventoryCheckById(inventoryCheckId); }
}
/** //解析并递增编号
* 恢复仓库库存盘点信息 int sequence = Integer.parseInt(maxCode.substring(4)) + 1;
*
* @param inventoryCheckId 仓库库存盘点ID //检查序列号是否溢出
* @return 结果 if (sequence > 999){
*/ throw new BusinessException("当前编号已达到最大值999,请检查或调整策略");
@Override }
public int restoreWarehouseInventoryCheckById(Long inventoryCheckId)
{ //格式化序列号,自动补零至三位
return warehouseInventoryCheckMapper.restoreWarehouseInventoryCheckById(inventoryCheckId); DecimalFormat df = new DecimalFormat("000");
return prefix + df.format(sequence);
} }
} }

5
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} update warehouse_inventory_check set del_flag = '0' where inventory_check_id = #{inventoryCheckId}
</update> </update>
<select id="findMaxRoundCode" resultType="String">
select max(substring(inventory_check_code,9)) from warehouse_inventory_check where inventory_check_code like concat(#{prefix},'%')
</select>
</mapper> </mapper>

6
ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/add.html

@ -7,12 +7,6 @@
<body class="white-bg"> <body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> <div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-inventoryCheck-add"> <form class="form-horizontal m" id="form-inventoryCheck-add">
<div class="form-group">
<label class="col-sm-3 control-label">库存盘点单号:</label>
<div class="col-sm-8">
<input name="inventoryCheckCode" class="form-control" type="text">
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">库存盘点人名:</label> <label class="col-sm-3 control-label">库存盘点人名:</label>
<div class="col-sm-8"> <div class="col-sm-8">

Loading…
Cancel
Save