InventoryTotalController.java 2.08 KB
package com.huaheng.api.logistics.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.huaheng.api.general.domain.Receipt;
import com.huaheng.api.general.service.ReceiptService;
import com.huaheng.mobile.shipment.Shipment;
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
import com.huaheng.pc.receipt.receiptHeader.service.ReceiptHeaderService;
import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.management.Query;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * 出入库曲线接口
 * @author mahua
 */
@RestController
@RequestMapping("/API/inventoryTotal")
public class InventoryTotalController {

    @Resource
    private InventoryDetailService inventoryDetailService;
    @Resource
    private ReceiptHeaderService receiptHeaderService;
    @Resource
    private ShipmentHeaderService shipmentHeaderService;

    public Map<String, Object> inventoryTotal() {
        Map<String, Object> resultMap = new HashMap<>();
        QueryWrapper<InventoryDetail> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("count(DISTINCT materialCode) as materialType, sum(qty) as quantity");
        Map<String, Object> materialMap = inventoryDetailService.getMap(queryWrapper);
        resultMap.put("materialType", materialMap.get("materialType"));
        resultMap.put("quantity", materialMap.get("quantity"));
        int receiptCount = receiptHeaderService.count();
        int shipmentCount = shipmentHeaderService.count();
        resultMap.put("ordersNumber", receiptCount+shipmentCount);
        return resultMap;
    }
}