package com.slcf.controller; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import com.slcf.bean.LocChartPie; import com.slcf.bean.WorkChartAxis; import com.slcf.service.ReportQueryService; import com.slcf.service.RoleService; import com.slcf.service.SysLogService; import com.slcf.service.WorkNoService; import com.slcf.util.AxisBean; import com.slcf.util.ChartBean; /** * 主页控制器层 * @author admin * @date 2018年12月10日 */ @Controller @RequestMapping("/basic") public class HomeController { @Resource WorkNoService workNoService; @Autowired SysLogService sysLogService; @Autowired RoleService roleService; @Autowired ReportQueryService reportQueryService; @RequestMapping("/goHome.action") public String goHomePage(HttpServletRequest request){ return "home"; } @ResponseBody @RequestMapping("/getChartPieInfo.action") public Map getChartPieInfo() { Map map=new HashMap(); List list = new ArrayList(); LocChartPie locUseRate = reportQueryService.getLocUseRate(); if(locUseRate!=null) { ChartBean fqty = new ChartBean(); fqty.setName("在库库位"); fqty.setY(locUseRate.getFqty()); list.add(fqty); ChartBean oqty = new ChartBean(); oqty.setName("空库位"); oqty.setY(locUseRate.getOqty()); list.add(oqty); ChartBean uqty = new ChartBean(); uqty.setName("使用库位"); uqty.setY(locUseRate.getUqty()); list.add(uqty); ChartBean xqty = new ChartBean(); xqty.setName("禁用库位"); xqty.setY(locUseRate.getXqty()); list.add(xqty); } map.put("rows",list); return map; } /** * 入出库统计曲线图表,显示12天内的入出库数量 * @return */ @ResponseBody @RequestMapping("/getChartAxisInfo.action") public Map getChartAxisInfo() { Map map=new HashMap(); List list = new ArrayList(); List listChart = reportQueryService.getChartAxis(); if(listChart!=null) { ArrayList data1 = new ArrayList(); ArrayList data2 = new ArrayList(); SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, -12); for(int i=0;i<12;i++) { boolean flag = true; calendar.add(Calendar.DATE, 1); String str = sf.format(calendar.getTime()); for(WorkChartAxis workChart : listChart) { if(str.equals(workChart.getYmd())) { data1.add(workChart.getInqty()); data2.add(workChart.getOutqty()); flag = false; break; } } if(flag) { data1.add(0); data2.add(0); } } AxisBean inqty = new AxisBean(); inqty.setName("入库数量"); Integer[] array1 = new Integer[data1.size()]; inqty.setData(data1.toArray(array1)); list.add(inqty); AxisBean outqty = new AxisBean(); outqty.setName("出库数量"); Integer[] array2 = new Integer[data2.size()]; outqty.setData(data2.toArray(array2)); list.add(outqty); } map.put("rows",list); return map; } }