InventoryController.java 5.19 KB
package com.huaheng.api.general.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.api.general.domain.CycCountDomain;
import com.huaheng.api.general.domain.InventoryDomain;
import com.huaheng.api.general.domain.InventoryQueryDomain;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.inventory.InventoryMaterialSummary.domain.InventoryMaterialSummary;
import com.huaheng.pc.inventory.InventoryMaterialSummary.service.InventoryMaterialSummaryService;
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
import com.huaheng.pc.inventory.inventoryHeader.service.InventoryHeaderService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.List;

@RestController
@RequestMapping("/api/inventory")
public class InventoryController {

    @Resource
    private InventoryDetailService inventoryHeaderService;
    @Resource
    private InventoryMaterialSummaryService inventoryMaterialSummaryService;

    /**
     * 查询库存
     */
    @Log(title = "查询库存", action = BusinessType.INSERT)
    @PostMapping("/searchInventory")
    @ApiOperation("查询库存系统库存")
    @ResponseBody
//    @ApiLogger(apiName = "查询库存", from="ERP")
    public AjaxResult searchInventory(@RequestBody InventoryQueryDomain inventoryQueryDomain)
    {
        LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
        inventoryDetailLambdaQueryWrapper.eq(StringUtils.isNotEmpty(inventoryQueryDomain.getWarehouseCode()),
                                        InventoryDetail::getWarehouseCode, inventoryQueryDomain.getWarehouseCode())
                                        .eq(StringUtils.isNotEmpty(inventoryQueryDomain.getContainerCode()),
                                        InventoryDetail::getContainerCode, inventoryQueryDomain.getContainerCode())
                                        .eq(StringUtils.isNotEmpty(inventoryQueryDomain.getLocationCode()),
                                        InventoryDetail::getLocationCode, inventoryQueryDomain.getLocationCode())
                                        .eq(StringUtils.isNotEmpty(inventoryQueryDomain.getCompanyCode()),
                                        InventoryDetail::getCompanyCode, inventoryQueryDomain.getCompanyCode())
                                        .eq(StringUtils.isNotEmpty(inventoryQueryDomain.getMaterialCode()),
                                        InventoryDetail::getMaterialCode, inventoryQueryDomain.getMaterialCode());
        List<InventoryDetail> inventoryDetailList = inventoryHeaderService.list(inventoryDetailLambdaQueryWrapper);
        return AjaxResult.success(inventoryDetailList);
    }

    /**
     * 查询库存
     */
    @Log(title = "查询库存", action = BusinessType.INSERT)
    @PostMapping("/searchTotalInventory")
    @ApiOperation("查询库存系统库存")
    @ResponseBody
//    @ApiLogger(apiName = "查询库存", from="ERP")
    public AjaxResult searchTotalInventory(@RequestBody InventoryMaterialSummary inventoryMaterialSummary)
    {
        LambdaQueryWrapper<InventoryMaterialSummary> lambdaQueryWrapper = Wrappers.lambdaQuery();

        lambdaQueryWrapper
                .eq(StringUtils.isNotEmpty(inventoryMaterialSummary.getWarehouseCode()),
                        InventoryMaterialSummary::getWarehouseCode, inventoryMaterialSummary.getWarehouseCode())
                //物料编码
                .eq(StringUtils.isNotEmpty(inventoryMaterialSummary.getMaterialCode()), InventoryMaterialSummary::getMaterialCode, inventoryMaterialSummary.getMaterialCode())
                //物料名称
                .eq(StringUtils.isNotEmpty(inventoryMaterialSummary.getMaterialName()), InventoryMaterialSummary::getMaterialName, inventoryMaterialSummary.getMaterialName())
                .eq(StringUtils.isNotEmpty(inventoryMaterialSummary.getZoneCode()), InventoryMaterialSummary::getZoneCode, inventoryMaterialSummary.getZoneCode())
                //货主
                .eq(!StringUtils.isEmpty(inventoryMaterialSummary.getCompanyCode()),InventoryMaterialSummary::getCompanyCode, inventoryMaterialSummary.getCompanyCode());
        //.orderByAsc(InventoryMaterialSummary::getMaterialCode);

        List<InventoryMaterialSummary> list = inventoryMaterialSummaryService.list(lambdaQueryWrapper);
        if (list == null) {
            list = Collections.emptyList();
        }
        //筛选库存汇总数据的专用方法
        List<InventoryMaterialSummary> details = inventoryMaterialSummaryService.duplicateRemoval(list);

        return AjaxResult.success(details);
    }
}