package org.jeecg.modules.lsw.controller;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.modules.lsw.entity.LswMaterialInventory;
|
import org.jeecg.modules.lsw.enums.MaterialInventoryStatusEnum;
|
import org.jeecg.modules.lsw.service.ILswMaterialInventoryService;
|
import org.jeecg.modules.lsw.vo.MaterialInventoryStatisticsVO;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.List;
|
|
/**
|
* @Description: 物料库存信息
|
* @Author: jeecg-boot
|
* @Date: 2025-06-30
|
* @Version: V1.0
|
*/
|
@Api(tags = "物料库存信息")
|
@RestController
|
@RequestMapping("/lsw/materialInventory")
|
@Slf4j
|
public class LswMaterialInventoryController extends JeecgController<LswMaterialInventory, ILswMaterialInventoryService> {
|
@Autowired
|
private ILswMaterialInventoryService lswMaterialInventoryService;
|
|
/**
|
* 分页列表查询
|
*
|
* @param materialId
|
* @param pageNo
|
* @param pageSize
|
* @return
|
*/
|
@ApiOperation(value = "物料库存信息-分页列表查询", notes = "物料库存信息-分页列表查询")
|
@GetMapping(value = "/list")
|
public Result<IPage<LswMaterialInventory>> queryPageList(@RequestParam(name = "materialId") String materialId,
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
LambdaQueryWrapper<LswMaterialInventory> queryWrapper = new LambdaQueryWrapper<>();
|
queryWrapper.eq(LswMaterialInventory::getMaterialId, materialId);
|
queryWrapper.eq(LswMaterialInventory::getInventoryStatus, MaterialInventoryStatusEnum.NORMAL.name());
|
queryWrapper.orderByDesc(LswMaterialInventory::getCreateTime);
|
Page<LswMaterialInventory> page = new Page<LswMaterialInventory>(pageNo, pageSize);
|
IPage<LswMaterialInventory> pageList = lswMaterialInventoryService.page(page, queryWrapper);
|
return Result.OK(pageList);
|
}
|
|
@ApiOperation(value = "物料库存信息-统计各线边库物料个数", notes = "物料库存信息-统计各线边库物料个数")
|
@GetMapping(value = "/statisticsInventory")
|
public Result<String> statisticsInventory(@RequestParam(name = "materialId") String materialId) {
|
//库存统计数量
|
List<MaterialInventoryStatisticsVO> list = lswMaterialInventoryService.statisticsInventory(materialId);
|
if(CollectionUtil.isEmpty(list)){
|
return Result.OK("0");
|
}
|
StringBuilder sb = new StringBuilder();
|
for(MaterialInventoryStatisticsVO vo : list){
|
sb.append(vo.getWarehouseName()).append(": ").append(vo.getMaterialQuantity().stripTrailingZeros().toPlainString()).append(" | ");
|
}
|
return Result.OK(sb.toString());
|
}
|
}
|