HomeController.java 4.99 KB
package com.huaheng.pc.system.user.controller;

import com.huaheng.framework.config.HuaHengConfig;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.report.excelReport.mapper.ExcelReportMapper;
import com.huaheng.pc.system.menu.domain.Menu;
import com.huaheng.pc.system.menu.service.IMenuService;
import com.huaheng.pc.system.user.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.*;
/**
 * @author
 */
@Controller
@RequestMapping("/admin")
public class HomeController extends BaseController {
    @Autowired
    private IMenuService menuService;
    @Autowired
    private HuaHengConfig huahengConfig;
    @Resource
    ExcelReportMapper mapper;




    private String prefix = "admin";

    //6个显示后台
    @GetMapping("home/getCommonData")
    @ResponseBody
    public AjaxResult getCommonData(){
//        String condition = " and warehouseId = " + ShiroUtils.getWarehouseId();
        String bllCount = "SELECT ifnull(sum(t.a),0) 'total' from (\n" +
                "SELECT COUNT(*) 'a' FROM receipt_header WHERE DATEDIFF(NOW(), created)=0 "  +
                " UNION \n" +
                "SELECT COUNT(*) 'a' FROM shipment_header WHERE DATEDIFF(NOW(), created)=0 " +
                ") t";
        String receiptTotal = "SELECT ifnull(sum(t.qty),0) 'total' from task_detail t\n" +
                "inner join receipt_header r on t.billCode=r.code and\n" +
                "t.status>100 and DATEDIFF(NOW(), t.lastUpdated)=0;";
        String shipmentTotal = "SELECT ifnull(sum(t.qty),0) 'total' from task_detail t\n" +
                "inner join shipment_header s on t.billCode=s.code and\n" +
                "t.status>100 and DATEDIFF(NOW(), t.lastUpdated)=0;";
        String inventoryTotal = "SELECT IFNULL(SUM(qty),0) 'total' from inventory_detail where 1=1 " ;
        String materialCount = "SELECT count(DISTINCT materialCode) 'total' from inventory_detail WHERE 1=1";
        String taskUncompletedTotal = "SELECT COUNT(*) 'total' from task_header WHERE status < 100 " ;

        Map<String, Object> map = new HashMap<>();
        /*List<LinkedHashMap<String, Object>> temp1 = mapper.selectCommon(bllCount);
        map.put("bllCount",temp1.get(0).entrySet().iterator().next().getValue());

        List<LinkedHashMap<String, Object>> temp2 = mapper.selectCommon(receiptTotal);
        map.put("receiptTotal",temp2.get(0).entrySet().stream().findFirst().get().getValue());

        List<LinkedHashMap<String, Object>> temp3 = mapper.selectCommon(shipmentTotal);
        map.put("shipmentTotal",temp3.get(0).entrySet().stream().findFirst().get().getValue());

        List<LinkedHashMap<String, Object>> temp4 = mapper.selectCommon(inventoryTotal);
        map.put("inventoryTotal",temp4.get(0).entrySet().stream().findFirst().get().getValue());

        List<LinkedHashMap<String, Object>> temp5 = mapper.selectCommon(materialCount);
        map.put("materialCount",temp5.get(0).entrySet().stream().findFirst().get().getValue());

        List<LinkedHashMap<String, Object>> temp6 = mapper.selectCommon(taskUncompletedTotal);
        map.put("taskUncompletedTotal",temp6.get(0).entrySet().stream().findFirst().get().getValue());
*/
        return AjaxResult.success(map);
    }

    //库龄展示
    @GetMapping("home/getInventoryStatus")
    @ResponseBody
    public AjaxResult getInventoryStatus(String type){
        List<Map<String, Object>> list=new ArrayList<>();

    return AjaxResult.success(list);
    }

    //获得七天的出入库量
    @GetMapping("home/getShipmentsLast7Days")
    @ResponseBody
    public AjaxResult getQtyLast7Days(String type){
        Map map=new ModelMap();
        return AjaxResult.success(map);
    }

    //库存分布
    @GetMapping("home/getInventoryProp")
    @ResponseBody
    public AjaxResult getInventoryProp(String type){
        List<Map<String, Object>> list=new ArrayList<>();

        return AjaxResult.success(list);
    }

    //库位利用率
    @GetMapping("home/getLocationProp")
    @ResponseBody
    public AjaxResult getLocationProp(){
        return AjaxResult.success();
    }

    @GetMapping("/home")
    public String home(ModelMap mmap)
    {
        // 取身份信息
        User user = getUser();
        // 根据用户id取出菜单
        List<Menu> menus = menuService.selectMenusByUserId(user.getId());
        mmap.put("menus", menus);
        mmap.put("user", user);
        mmap.put("copyrightYear", huahengConfig.getCopyrightYear());
        return prefix + "/home";
    }


    // 系统介绍
    @GetMapping("/main")
    public String main(ModelMap mmap) {
        mmap.put("version", huahengConfig.getVersion());
        return prefix + "/main";
    }
}