feat(receive): 添加库存报废功能接口
- 新增库存报废查询对象 InventoryScrappingQO - 创建 OAController 提供库存报废接口 - 实现库存报废业务逻辑,包括库存校验和出库操作 - 新增库存报废记录实体 WmsInventoryScrappingRecord - 添加库存报废记录服务接口及实现类 - 集成 FIFO 库存获取和批量出库功能
This commit is contained in:
parent
971b2a05ca
commit
828d33a724
|
|
@ -0,0 +1,64 @@
|
||||||
|
package com.nflg.wms.repository.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 库存报废记录
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 代码生成器生成
|
||||||
|
* @since 2025
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("wms_inventory_scrapping_record")
|
||||||
|
public class WmsInventoryScrappingRecord implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料编号
|
||||||
|
*/
|
||||||
|
private String materialNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工厂编号
|
||||||
|
*/
|
||||||
|
private String factoryNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库编号
|
||||||
|
*/
|
||||||
|
private String warehouseNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数量
|
||||||
|
*/
|
||||||
|
private BigDecimal num;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.nflg.wms.repository.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.nflg.wms.repository.entity.WmsInventoryScrappingRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 代码生成器生成
|
||||||
|
* @since 2025
|
||||||
|
*/
|
||||||
|
public interface WmsInventoryScrappingRecordMapper extends BaseMapper<WmsInventoryScrappingRecord> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.nflg.wms.repository.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.nflg.wms.repository.entity.WmsInventoryScrappingRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 代码生成器生成
|
||||||
|
* @since 2025
|
||||||
|
*/
|
||||||
|
public interface IWmsInventoryScrappingRecordService extends IService<WmsInventoryScrappingRecord> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.nflg.wms.repository.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.nflg.wms.repository.entity.WmsInventoryScrappingRecord;
|
||||||
|
import com.nflg.wms.repository.mapper.WmsInventoryScrappingRecordMapper;
|
||||||
|
import com.nflg.wms.repository.service.IWmsInventoryScrappingRecordService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 代码生成器生成
|
||||||
|
* @since 2025
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class WmsInventoryScrappingRecordServiceImpl extends ServiceImpl<WmsInventoryScrappingRecordMapper, WmsInventoryScrappingRecord> implements IWmsInventoryScrappingRecordService {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.nflg.wms.srm.receive.controller;
|
||||||
|
|
||||||
|
import com.nflg.wms.common.pojo.ApiResult;
|
||||||
|
import com.nflg.wms.common.pojo.dto.InventoryOutDTO;
|
||||||
|
import com.nflg.wms.common.util.VUtil;
|
||||||
|
import com.nflg.wms.repository.entity.WmsInventory;
|
||||||
|
import com.nflg.wms.repository.entity.WmsInventoryScrappingRecord;
|
||||||
|
import com.nflg.wms.repository.service.IWmsInventoryScrappingRecordService;
|
||||||
|
import com.nflg.wms.repository.service.IWmsInventoryService;
|
||||||
|
import com.nflg.wms.srm.receive.pojo.qo.InventoryScrappingQO;
|
||||||
|
import com.nflg.wms.starter.BaseController;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接收oa推送数据
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/oa")
|
||||||
|
public class OAController extends BaseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IWmsInventoryService inventoryService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IWmsInventoryScrappingRecordService inventoryScrappingRecordService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 库存报废
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
@PostMapping("/inventory/scrapping")
|
||||||
|
public ApiResult<Void> inventoryScrapping(@Valid @RequestBody @NotNull InventoryScrappingQO qo) {
|
||||||
|
List<WmsInventory> inventories = inventoryService.getForOutFIFO(qo.getFactoryNo(), qo.getWarehouseNo(), List.of(qo.getMaterialNo()));
|
||||||
|
VUtil.trueThrowBusinessError(inventories.stream().map(WmsInventory::getNum).reduce(BigDecimal.ZERO, BigDecimal::add).compareTo(qo.getNum()) < 0)
|
||||||
|
.throwMessage("库存不足");
|
||||||
|
inventoryService.out(inventories.stream()
|
||||||
|
.map(inventory -> new InventoryOutDTO()
|
||||||
|
.setFactoryNo(inventory.getFactoryNo())
|
||||||
|
.setWarehouseNo(inventory.getWarehouseNo())
|
||||||
|
.setBatchNo(inventory.getBatchNo())
|
||||||
|
.setBinLocation(inventory.getBinLocation())
|
||||||
|
.setSerialNo(inventory.getSerialNo())
|
||||||
|
.setNum(qo.getNum())
|
||||||
|
)
|
||||||
|
.toList()
|
||||||
|
);
|
||||||
|
inventoryScrappingRecordService.save(new WmsInventoryScrappingRecord()
|
||||||
|
.setFactoryNo(qo.getFactoryNo())
|
||||||
|
.setWarehouseNo(qo.getWarehouseNo())
|
||||||
|
.setMaterialNo(qo.getMaterialNo())
|
||||||
|
.setNum(qo.getNum())
|
||||||
|
.setRemark(qo.getRemark())
|
||||||
|
.setCreateTime(LocalDateTime.now())
|
||||||
|
);
|
||||||
|
return ApiResult.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.nflg.wms.srm.receive.pojo.qo;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class InventoryScrappingQO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工厂编码
|
||||||
|
*/
|
||||||
|
@NotBlank
|
||||||
|
private String factoryNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库编码
|
||||||
|
*/
|
||||||
|
@NotBlank
|
||||||
|
private String warehouseNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料编码
|
||||||
|
*/
|
||||||
|
@NotBlank
|
||||||
|
private String materialNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数量
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
private BigDecimal num;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue