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