package com.slcf.service.impl; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletResponse; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.slcf.bean.LocChartPie; import com.slcf.bean.WorkChartAxis; import com.slcf.dao.ReportQueryDao; import com.slcf.pojo.AdjDetailBean; import com.slcf.pojo.PlcCommandBean; import com.slcf.pojo.ViewInOutBean; import com.slcf.pojo.ViewLocMapBean; import com.slcf.pojo.ViewStayTimeBean; import com.slcf.pojo.ViewStockUseBean; import com.slcf.pojo.ViewWorkInBean; import com.slcf.service.ReportQueryService; import com.slcf.util.DateTimeUtil; /** * 日志统计接口实现 * @author admin * @date 2018年11月23日 */ @Service public class ReportQueryServiceImpl implements ReportQueryService { @Autowired ReportQueryDao reportQueryDao; //------------------库位使用统计-------------------------------------- public Map queryViewStockUseList(ViewStockUseBean viewStockUse) { try { Map map=new HashMap(); List list=reportQueryDao.queryViewStockUseList(viewStockUse); int count =reportQueryDao.getViewStockUseCount(viewStockUse); map.put("rows", list); map.put("total", count); return map; }catch(Exception e) { System.out.println(e.getMessage()); System.out.println(e.getMessage()); return null; } } //导出excel public void ExportViewStockUseList(ViewStockUseBean viewStockUse, HttpServletResponse response) { // 输出Excel文件 try { // HSSFWorkbook对象(excel的文档对象) HSSFWorkbook workBook = new HSSFWorkbook(); // sheet对象(excel的表单) HSSFSheet sheet = workBook.createSheet("库位使用信息"); sheet.setColumnWidth(0, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(1, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(2, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(3, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(4, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(5, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(6, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(7, (int) ((15 + 0.72) * 256)); HSSFRow rows = sheet.createRow(0);// 第二行 // 创建单元格并设置单元格内容 rows.createCell(0).setCellValue("钢架号"); rows.createCell(1).setCellValue("库位总数"); rows.createCell(2).setCellValue("在库数量"); rows.createCell(3).setCellValue("空库位数量"); rows.createCell(4).setCellValue("禁用库位数量"); rows.createCell(5).setCellValue("空容器数量"); rows.createCell(6).setCellValue("在库率(%)"); rows.createCell(7).setCellValue("使用率(%)"); List list = reportQueryDao.getViewStockUseAll(viewStockUse); for (int i = 0; i < list.size(); i++) { HSSFRow row = sheet.createRow(i + 1);// 从第三行开始 // 创建单元格并设置单元格内容 row.createCell(0).setCellValue(list.get(i).getRow1()); row.createCell(1).setCellValue(list.get(i).getTotal_qty()); row.createCell(2).setCellValue(list.get(i).getFull_qty()); row.createCell(3).setCellValue(list.get(i).getNull_qty()); row.createCell(4).setCellValue(list.get(i).getForbid_qty()); row.createCell(5).setCellValue(list.get(i).getEmpty_qty()); row.createCell(6).setCellValue(list.get(i).getFull_rate()); row.createCell(7).setCellValue(list.get(i).getOcc_rate()); } // //输出Excel文件 // try { OutputStream output = response.getOutputStream(); response.reset(); response.setHeader("Content-disposition", "attachment; filename=StockUse" + DateTimeUtil.getStringDateTime(14) + ".xls"); response.setContentType("application/msexcel"); workBook.write(output); output.close(); } catch (IOException e) { e.printStackTrace(); } } //------------------库存滞留统计-------------------------------------- public Map queryViewStayTimeList(ViewStayTimeBean viewStayTime) { try { Map map=new HashMap(); List list=reportQueryDao.queryViewStayTimeList(viewStayTime); int count =reportQueryDao.getViewStayTimeCount(viewStayTime); map.put("rows", list); map.put("total", count); return map; }catch(Exception e) { System.out.println(e.getMessage()); System.out.println(e.getMessage()); return null; } } //导出excel public void ExportViewStayTimeList(ViewStayTimeBean viewStayTime, HttpServletResponse response) { // 输出Excel文件 try { // HSSFWorkbook对象(excel的文档对象) HSSFWorkbook workBook = new HSSFWorkbook(); // sheet对象(excel的表单) HSSFSheet sheet = workBook.createSheet("库存滞留时间统计"); sheet.setColumnWidth(0, (int) ((20 + 0.72) * 256)); sheet.setColumnWidth(1, (int) ((10 + 0.72) * 256)); sheet.setColumnWidth(2, (int) ((10 + 0.72) * 256)); sheet.setColumnWidth(3, (int) ((20 + 0.72) * 256)); sheet.setColumnWidth(4, (int) ((25 + 0.72) * 256)); sheet.setColumnWidth(5, (int) ((10 + 0.72) * 256)); sheet.setColumnWidth(6, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(7, (int) ((5 + 0.72) * 256)); sheet.setColumnWidth(8, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(9, (int) ((10 + 0.72) * 256)); HSSFRow rows = sheet.createRow(0);// 第二行 // 创建单元格并设置单元格内容 rows.createCell(0).setCellValue("入库时间"); rows.createCell(1).setCellValue("滞留天数"); rows.createCell(2).setCellValue("库位号"); rows.createCell(3).setCellValue("物料"); rows.createCell(4).setCellValue("物料描述"); rows.createCell(5).setCellValue("工厂"); rows.createCell(6).setCellValue("数量"); rows.createCell(7).setCellValue("单位"); rows.createCell(8).setCellValue("托盘码"); rows.createCell(9).setCellValue("用户ID"); List list = reportQueryDao.getViewStayTimeAll(viewStayTime); for (int i = 0; i < list.size(); i++) { HSSFRow row = sheet.createRow(i + 1);// 从第三行开始 // 创建单元格并设置单元格内容 row.createCell(0).setCellValue(list.get(i).getAppe_time()); row.createCell(1).setCellValue(list.get(i).getStay_time()); row.createCell(2).setCellValue(list.get(i).getLoc_no()); row.createCell(3).setCellValue(list.get(i).getMatnr()); row.createCell(4).setCellValue(list.get(i).getMaktx()); row.createCell(5).setCellValue(list.get(i).getWerks()); row.createCell(6).setCellValue(list.get(i).getAnfme()); row.createCell(7).setCellValue(list.get(i).getAltme()); row.createCell(8).setCellValue(list.get(i).getZpallet()); row.createCell(9).setCellValue(list.get(i).getBname()); } // //输出Excel文件 // try { OutputStream output = response.getOutputStream(); response.reset(); response.setHeader("Content-disposition", "attachment; filename=StayTime" + DateTimeUtil.getStringDateTime(14) + ".xls"); response.setContentType("application/msexcel"); workBook.write(output); output.close(); } catch (IOException e) { e.printStackTrace(); } } //------------------库存调整记录-------------------------------------- public Map queryAdjDetailList(AdjDetailBean adjDetail) { try { Map map=new HashMap(); List list=reportQueryDao.queryAdjDetailList(adjDetail); int count =reportQueryDao.getAdjDetailCount(adjDetail); map.put("rows", list); map.put("total", count); return map; }catch(Exception e) { System.out.println(e.getMessage()); System.out.println(e.getMessage()); return null; } } //导出excel public void ExportAdjDetailList(AdjDetailBean adjDetail, HttpServletResponse response) { // 输出Excel文件 try { // HSSFWorkbook对象(excel的文档对象) HSSFWorkbook workBook = new HSSFWorkbook(); // sheet对象(excel的表单) HSSFSheet sheet = workBook.createSheet("库存调整统计"); sheet.setColumnWidth(0, (int) ((10 + 0.72) * 256)); sheet.setColumnWidth(1, (int) ((20 + 0.72) * 256)); sheet.setColumnWidth(2, (int) ((20 + 0.72) * 256)); sheet.setColumnWidth(3, (int) ((10 + 0.72) * 256)); sheet.setColumnWidth(4, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(5, (int) ((10 + 0.72) * 256)); sheet.setColumnWidth(6, (int) ((10 + 0.72) * 256)); sheet.setColumnWidth(7, (int) ((10 + 0.72) * 256)); sheet.setColumnWidth(8, (int) ((10 + 0.72) * 256)); sheet.setColumnWidth(9, (int) ((20 + 0.72) * 256)); sheet.setColumnWidth(10, (int) ((6 + 0.72) * 256)); sheet.setColumnWidth(11, (int) ((20 + 0.72) * 256)); HSSFRow rows = sheet.createRow(0);// 第二行 // 创建单元格并设置单元格内容 rows.createCell(0).setCellValue("库位号"); rows.createCell(1).setCellValue("物料编码"); rows.createCell(2).setCellValue("物料名称"); rows.createCell(3).setCellValue("原数量"); rows.createCell(4).setCellValue("调整数量"); rows.createCell(5).setCellValue("调整后数量"); rows.createCell(6).setCellValue("原箱数"); rows.createCell(7).setCellValue("调整箱数"); rows.createCell(8).setCellValue("调整后箱数"); rows.createCell(9).setCellValue("备注"); rows.createCell(10).setCellValue("调整人员"); rows.createCell(11).setCellValue("调整时间"); List list = reportQueryDao.getAdjDetailAll(adjDetail); for (int i = 0; i < list.size(); i++) { HSSFRow row = sheet.createRow(i + 1);// 从第三行开始 // 创建单元格并设置单元格内容 row.createCell(0).setCellValue(list.get(i).getLoc_no()); row.createCell(1).setCellValue(list.get(i).getMat_no()); row.createCell(2).setCellValue(list.get(i).getMat_name()); row.createCell(3).setCellValue(list.get(i).getS_qty()); row.createCell(4).setCellValue(list.get(i).getAdj_qty()); row.createCell(5).setCellValue(list.get(i).getQty()); row.createCell(6).setCellValue(list.get(i).getS_ctns()); row.createCell(7).setCellValue(list.get(i).getAdj_ctns()); row.createCell(8).setCellValue(list.get(i).getCtns()); row.createCell(9).setCellValue(list.get(i).getMemo()); row.createCell(10).setCellValue(list.get(i).getModi_user()); row.createCell(11).setCellValue(list.get(i).getModi_time()); } // //输出Excel文件 // try { OutputStream output = response.getOutputStream(); response.reset(); response.setHeader("Content-disposition", "attachment; filename=AdjDetail" + DateTimeUtil.getStringDateTime(14) + ".xls"); response.setContentType("application/msexcel"); workBook.write(output); output.close(); } catch (IOException e) { e.printStackTrace(); } } //------------------站点日入出库次数统计-------------------------------------- public Map queryViewInOutList(ViewInOutBean viewInOut) { try { Map map=new HashMap(); List list=reportQueryDao.queryViewInOutList(viewInOut); int count =reportQueryDao.getViewInOutCount(viewInOut); map.put("rows", list); map.put("total", count); return map; }catch(Exception e) { System.out.println(e.getMessage()); System.out.println(e.getMessage()); return null; } } //导出excel public void ExportViewInOutList(ViewInOutBean viewInOut, HttpServletResponse response) { // 输出Excel文件 try { // HSSFWorkbook对象(excel的文档对象) HSSFWorkbook workBook = new HSSFWorkbook(); // sheet对象(excel的表单) HSSFSheet sheet = workBook.createSheet("日入出库次数统计"); sheet.setColumnWidth(0, (int) ((20 + 0.72) * 256)); sheet.setColumnWidth(1, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(2, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(3, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(4, (int) ((15 + 0.72) * 256)); HSSFRow rows = sheet.createRow(0);// 第二行 // 创建单元格并设置单元格内容 rows.createCell(0).setCellValue("日期"); rows.createCell(1).setCellValue("站点编号"); rows.createCell(2).setCellValue("入库次数"); rows.createCell(3).setCellValue("出库次数"); rows.createCell(4).setCellValue("总次数"); List list = reportQueryDao.getViewInOutAll(viewInOut); for (int i = 0; i < list.size(); i++) { HSSFRow row = sheet.createRow(i + 1);// 从第三行开始 // 创建单元格并设置单元格内容 row.createCell(0).setCellValue(list.get(i).getYmd()); row.createCell(1).setCellValue(list.get(i).getSource_sta_no()); row.createCell(2).setCellValue(list.get(i).getSto_qty()); row.createCell(3).setCellValue(list.get(i).getRet_qty()); row.createCell(4).setCellValue(list.get(i).getTotal_qty()); } // //输出Excel文件 // try { OutputStream output = response.getOutputStream(); response.reset(); response.setHeader("Content-disposition", "attachment; filename=InOutCount" + DateTimeUtil.getStringDateTime(14) + ".xls"); response.setContentType("application/msexcel"); workBook.write(output); output.close(); } catch (IOException e) { e.printStackTrace(); } } //------------------日入库明细记录-------------------------------------- public Map queryViewWorkInList(ViewWorkInBean viewWorkIn) { try { Map map=new HashMap(); List list=reportQueryDao.queryViewWorkInList(viewWorkIn); int count =reportQueryDao.getViewWorkInCount(viewWorkIn); map.put("rows", list); map.put("total", count); return map; }catch(Exception e) { System.out.println(e.getMessage()); System.out.println(e.getMessage()); return null; } } //导出excel public void ExportViewWorkInList(ViewWorkInBean viewWorkIn, HttpServletResponse response) { // 输出Excel文件 try { // HSSFWorkbook对象(excel的文档对象) HSSFWorkbook workBook = new HSSFWorkbook(); // sheet对象(excel的表单) HSSFSheet sheet = workBook.createSheet("日入库明细查询"); sheet.setColumnWidth(0, (int) ((20 + 0.72) * 256)); sheet.setColumnWidth(1, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(2, (int) ((20 + 0.72) * 256)); sheet.setColumnWidth(3, (int) ((25 + 0.72) * 256)); sheet.setColumnWidth(4, (int) ((38 + 0.72) * 256)); sheet.setColumnWidth(5, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(6, (int) ((45 + 0.72) * 256)); sheet.setColumnWidth(7, (int) ((8 + 0.72) * 256)); sheet.setColumnWidth(8, (int) ((20 + 0.72) * 256)); HSSFRow rows = sheet.createRow(0);// 第二行 // 创建单元格并设置单元格内容 rows.createCell(0).setCellValue("入库时间"); rows.createCell(1).setCellValue("库位号"); rows.createCell(2).setCellValue("物料"); rows.createCell(3).setCellValue("物料描述"); rows.createCell(4).setCellValue("工厂"); rows.createCell(5).setCellValue("数量"); rows.createCell(6).setCellValue("单位"); rows.createCell(7).setCellValue("托盘码"); rows.createCell(8).setCellValue("用户ID"); List list = reportQueryDao.getViewWorkInAll(viewWorkIn); for (int i = 0; i < list.size(); i++) { HSSFRow row = sheet.createRow(i + 1);// 从第三行开始 // 创建单元格并设置单元格内容 row.createCell(0).setCellValue(list.get(i).getIo_time()); row.createCell(1).setCellValue(list.get(i).getLoc_no()); row.createCell(2).setCellValue(list.get(i).getMatnr()); row.createCell(3).setCellValue(list.get(i).getMaktx()); row.createCell(4).setCellValue(list.get(i).getWerks()); row.createCell(5).setCellValue(list.get(i).getAnfme()); row.createCell(6).setCellValue(list.get(i).getAltme()); row.createCell(7).setCellValue(list.get(i).getZpallet()); row.createCell(8).setCellValue(list.get(i).getBname()); } // //输出Excel文件 // try { OutputStream output = response.getOutputStream(); response.reset(); response.setHeader("Content-disposition", "attachment; filename=DailyStore" + DateTimeUtil.getStringDateTime(14) + ".xls"); response.setContentType("application/msexcel"); workBook.write(output); output.close(); } catch (IOException e) { e.printStackTrace(); } } //------------------日出库明细记录-------------------------------------- public Map queryViewWorkOutList(ViewWorkInBean viewWorkOut) { try { Map map=new HashMap(); List list=reportQueryDao.queryViewWorkOutList(viewWorkOut); int count =reportQueryDao.getViewWorkOutCount(viewWorkOut); map.put("rows", list); map.put("total", count); return map; }catch(Exception e) { System.out.println(e.getMessage()); System.out.println(e.getMessage()); return null; } } //导出excel public void ExportViewWorkOutList(ViewWorkInBean viewWorkOut, HttpServletResponse response) { // 输出Excel文件 try { // HSSFWorkbook对象(excel的文档对象) HSSFWorkbook workBook = new HSSFWorkbook(); // sheet对象(excel的表单) HSSFSheet sheet = workBook.createSheet("日出库明细查询"); sheet.setColumnWidth(0, (int) ((20 + 0.72) * 256)); sheet.setColumnWidth(1, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(2, (int) ((20 + 0.72) * 256)); sheet.setColumnWidth(3, (int) ((25 + 0.72) * 256)); sheet.setColumnWidth(4, (int) ((38 + 0.72) * 256)); sheet.setColumnWidth(5, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(6, (int) ((45 + 0.72) * 256)); sheet.setColumnWidth(7, (int) ((8 + 0.72) * 256)); sheet.setColumnWidth(8, (int) ((20 + 0.72) * 256)); HSSFRow rows = sheet.createRow(0);// 第二行 // 创建单元格并设置单元格内容 rows.createCell(0).setCellValue("出库时间"); rows.createCell(1).setCellValue("库位号"); rows.createCell(2).setCellValue("物料"); rows.createCell(3).setCellValue("物料描述"); rows.createCell(4).setCellValue("工厂"); rows.createCell(5).setCellValue("数量"); rows.createCell(6).setCellValue("单位"); rows.createCell(7).setCellValue("托盘码"); rows.createCell(8).setCellValue("用户ID"); List list = reportQueryDao.getViewWorkOutAll(viewWorkOut); for (int i = 0; i < list.size(); i++) { HSSFRow row = sheet.createRow(i + 1);// 从第三行开始 // 创建单元格并设置单元格内容 row.createCell(0).setCellValue(list.get(i).getIo_time()); row.createCell(1).setCellValue(list.get(i).getLoc_no()); row.createCell(2).setCellValue(list.get(i).getMatnr()); row.createCell(3).setCellValue(list.get(i).getMaktx()); row.createCell(4).setCellValue(list.get(i).getWerks()); row.createCell(5).setCellValue(list.get(i).getAnfme()); row.createCell(6).setCellValue(list.get(i).getAltme()); row.createCell(7).setCellValue(list.get(i).getZpallet()); row.createCell(8).setCellValue(list.get(i).getBname()); } // //输出Excel文件 // try { OutputStream output = response.getOutputStream(); response.reset(); response.setHeader("Content-disposition", "attachment; filename=DailyRetrieve" + DateTimeUtil.getStringDateTime(14) + ".xls"); response.setContentType("application/msexcel"); workBook.write(output); output.close(); } catch (IOException e) { e.printStackTrace(); } } //------------------库存MAP图-------------------------------------- public Map queryViewLocMapList(ViewLocMapBean viewLocMap) { try { Map map=new HashMap(); List list = new ArrayList(); String row1 = String.format("%02d", Integer.parseInt(viewLocMap.getRow1())); List levList = reportQueryDao.getViewLocLevCount(Integer.parseInt(row1)); for(String lev1 : levList) { List bayList= reportQueryDao.getViewLocBays(Integer.parseInt(row1),Integer.parseInt(lev1)); ViewLocMapBean locMap = new ViewLocMapBean(); locMap.setRowlev(row1+String.format("%02d", Integer.parseInt(lev1))); int i=0; // if(Integer.parseInt(lev1)>3){ // i = i+1; // locMap.setL001(bayList.get(i-1).getLoc_sts()); // locMap.setL087(bayList.get(i+85).getLoc_sts()); // } locMap.setL002(bayList.get(i).getLoc_sts()); locMap.setL003(bayList.get(i+1).getLoc_sts()); locMap.setL004(bayList.get(i+2).getLoc_sts()); locMap.setL005(bayList.get(i+3).getLoc_sts()); locMap.setL006(bayList.get(i+4).getLoc_sts()); locMap.setL007(bayList.get(i+5).getLoc_sts()); locMap.setL008(bayList.get(i+6).getLoc_sts()); locMap.setL009(bayList.get(i+7).getLoc_sts()); locMap.setL010(bayList.get(i+8).getLoc_sts()); locMap.setL011(bayList.get(i+9).getLoc_sts()); locMap.setL012(bayList.get(i+10).getLoc_sts()); locMap.setL013(bayList.get(i+11).getLoc_sts()); locMap.setL014(bayList.get(i+12).getLoc_sts()); locMap.setL015(bayList.get(i+13).getLoc_sts()); locMap.setL016(bayList.get(i+14).getLoc_sts()); locMap.setL017(bayList.get(i+15).getLoc_sts()); locMap.setL018(bayList.get(i+16).getLoc_sts()); locMap.setL019(bayList.get(i+17).getLoc_sts()); locMap.setL020(bayList.get(i+18).getLoc_sts()); locMap.setL021(bayList.get(i+19).getLoc_sts()); locMap.setL022(bayList.get(i+20).getLoc_sts()); locMap.setL023(bayList.get(i+21).getLoc_sts()); locMap.setL024(bayList.get(i+22).getLoc_sts()); locMap.setL025(bayList.get(i+23).getLoc_sts()); locMap.setL026(bayList.get(i+24).getLoc_sts()); locMap.setL027(bayList.get(i+25).getLoc_sts()); locMap.setL028(bayList.get(i+26).getLoc_sts()); locMap.setL029(bayList.get(i+27).getLoc_sts()); locMap.setL030(bayList.get(i+28).getLoc_sts()); locMap.setL031(bayList.get(i+29).getLoc_sts()); locMap.setL032(bayList.get(i+30).getLoc_sts()); locMap.setL033(bayList.get(i+31).getLoc_sts()); locMap.setL034(bayList.get(i+32).getLoc_sts()); locMap.setL035(bayList.get(i+33).getLoc_sts()); locMap.setL036(bayList.get(i+34).getLoc_sts()); locMap.setL037(bayList.get(i+35).getLoc_sts()); locMap.setL038(bayList.get(i+36).getLoc_sts()); locMap.setL039(bayList.get(i+37).getLoc_sts()); locMap.setL040(bayList.get(i+38).getLoc_sts()); locMap.setL041(bayList.get(i+39).getLoc_sts()); locMap.setL042(bayList.get(i+40).getLoc_sts()); locMap.setL043(bayList.get(i+41).getLoc_sts()); locMap.setL044(bayList.get(i+42).getLoc_sts()); locMap.setL045(bayList.get(i+43).getLoc_sts()); locMap.setL046(bayList.get(i+44).getLoc_sts()); locMap.setL047(bayList.get(i+45).getLoc_sts()); // locMap.setL048(bayList.get(i+46).getLoc_sts()); // locMap.setL049(bayList.get(i+47).getLoc_sts()); // locMap.setL050(bayList.get(i+48).getLoc_sts()); // locMap.setL051(bayList.get(i+49).getLoc_sts()); // locMap.setL052(bayList.get(i+50).getLoc_sts()); // locMap.setL053(bayList.get(i+51).getLoc_sts()); // locMap.setL054(bayList.get(i+52).getLoc_sts()); // locMap.setL055(bayList.get(i+53).getLoc_sts()); // locMap.setL056(bayList.get(i+54).getLoc_sts()); // locMap.setL057(bayList.get(i+55).getLoc_sts()); // locMap.setL058(bayList.get(i+56).getLoc_sts()); // locMap.setL059(bayList.get(i+57).getLoc_sts()); // locMap.setL060(bayList.get(i+58).getLoc_sts()); // locMap.setL061(bayList.get(i+59).getLoc_sts()); // locMap.setL062(bayList.get(i+60).getLoc_sts()); // locMap.setL063(bayList.get(i+61).getLoc_sts()); // locMap.setL064(bayList.get(i+62).getLoc_sts()); // locMap.setL065(bayList.get(i+63).getLoc_sts()); // locMap.setL066(bayList.get(i+64).getLoc_sts()); // locMap.setL067(bayList.get(i+65).getLoc_sts()); // locMap.setL068(bayList.get(i+66).getLoc_sts()); // locMap.setL069(bayList.get(i+67).getLoc_sts()); // locMap.setL070(bayList.get(i+68).getLoc_sts()); // locMap.setL071(bayList.get(i+69).getLoc_sts()); // locMap.setL072(bayList.get(i+70).getLoc_sts()); // locMap.setL073(bayList.get(i+71).getLoc_sts()); // locMap.setL074(bayList.get(i+72).getLoc_sts()); // locMap.setL075(bayList.get(i+73).getLoc_sts()); // locMap.setL076(bayList.get(i+74).getLoc_sts()); // locMap.setL077(bayList.get(i+75).getLoc_sts()); // locMap.setL078(bayList.get(i+76).getLoc_sts()); // locMap.setL079(bayList.get(i+77).getLoc_sts()); // locMap.setL080(bayList.get(i+78).getLoc_sts()); // locMap.setL081(bayList.get(i+79).getLoc_sts()); // locMap.setL082(bayList.get(i+80).getLoc_sts()); // locMap.setL083(bayList.get(i+81).getLoc_sts()); // locMap.setL084(bayList.get(i+82).getLoc_sts()); // locMap.setL085(bayList.get(i+83).getLoc_sts()); // locMap.setL086(bayList.get(i+84).getLoc_sts()); list.add(locMap); } map.put("rows", list); map.put("total", levList.size()); return map; }catch(Exception e) { System.out.println(e.getMessage()); System.out.println(e.getMessage()); return null; } } // public Map queryViewLocMapList(ViewLocMapBean viewLocMap) { // try { // Map map=new HashMap(); // List list=reportQueryDao.queryViewLocMapList(viewLocMap); // int count =reportQueryDao.getViewLocMapCount(viewLocMap); // map.put("rows", list); // map.put("total", count); // return map; // }catch(Exception e) { // System.out.println(e.getMessage()); // System.out.println(e.getMessage()); // return null; // } // } /** * 库位占用图表 */ public LocChartPie getLocUseRate() { try { LocChartPie locUseRate = reportQueryDao.getLocUseRate(); return locUseRate; }catch(Exception e) { System.out.println(e.getMessage()); return null; } } /** * 入出曲线统计图 */ public List getChartAxis(){ List list = new ArrayList(); try { list = reportQueryDao.getChartAxis(); }catch(Exception e) { System.out.println(e.getMessage()); } return list; } //------------------堆垛机异常记录-------------------------------------- public Map queryCrnErrorList(PlcCommandBean plcCommand) { try { Map map=new HashMap(); List list=reportQueryDao.queryCrnErrorList(plcCommand); int count =reportQueryDao.getCrnErrorCount(plcCommand); map.put("rows", list); map.put("total", count); return map; }catch(Exception e) { System.out.println(e.getMessage()); System.out.println(e.getMessage()); return null; } } //导出excel public void ExportCrnErrorList(PlcCommandBean plcCommand, HttpServletResponse response) { // 输出Excel文件 try { // HSSFWorkbook对象(excel的文档对象) HSSFWorkbook workBook = new HSSFWorkbook(); // sheet对象(excel的表单) HSSFSheet sheet = workBook.createSheet("堆垛机异常记录"); sheet.setColumnWidth(0, (int) ((10 + 0.72) * 256)); sheet.setColumnWidth(1, (int) ((20 + 0.72) * 256)); sheet.setColumnWidth(2, (int) ((20 + 0.72) * 256)); sheet.setColumnWidth(3, (int) ((10 + 0.72) * 256)); sheet.setColumnWidth(4, (int) ((15 + 0.72) * 256)); sheet.setColumnWidth(5, (int) ((10 + 0.72) * 256)); sheet.setColumnWidth(6, (int) ((10 + 0.72) * 256)); sheet.setColumnWidth(7, (int) ((10 + 0.72) * 256)); HSSFRow rows = sheet.createRow(0);// 第二行 // 创建单元格并设置单元格内容 rows.createCell(0).setCellValue("日期时间"); rows.createCell(1).setCellValue("堆垛机号"); rows.createCell(2).setCellValue("工作号"); rows.createCell(3).setCellValue("异常码"); rows.createCell(4).setCellValue("异常描述"); rows.createCell(5).setCellValue("库位号"); rows.createCell(6).setCellValue("发生时间"); rows.createCell(7).setCellValue("工作档时间"); List list = reportQueryDao.getCrnErrorAll(plcCommand); for (int i = 0; i < list.size(); i++) { HSSFRow row = sheet.createRow(i + 1);// 从第三行开始 // 创建单元格并设置单元格内容 row.createCell(0).setCellValue(list.get(i).getIo_time()); row.createCell(1).setCellValue(list.get(i).getDev_no()); row.createCell(2).setCellValue(list.get(i).getWrk_no()); row.createCell(3).setCellValue(list.get(i).getS_location()); row.createCell(4).setCellValue(list.get(i).getErr_name()); row.createCell(5).setCellValue(list.get(i).getO_location()); row.createCell(6).setCellValue(list.get(i).getModi_time()); row.createCell(7).setCellValue(list.get(i).getWrk_time()); } // //输出Excel文件 // try { OutputStream output = response.getOutputStream(); response.reset(); response.setHeader("Content-disposition", "attachment; filename=CrnError" + DateTimeUtil.getStringDateTime(14) + ".xls"); response.setContentType("application/msexcel"); workBook.write(output); output.close(); } catch (IOException e) { e.printStackTrace(); } } }