From 7f4d00ca008a5127e8ca8922a9aea27187d01f81 Mon Sep 17 00:00:00 2001 From: "liang.chao" <1360241448@qq.com> Date: Fri, 30 Jan 2026 17:42:57 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E9=A2=84=E8=AD=A6=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WEB-INF/views/warning/warningInfo.jsp | 431 ++++++++------- .../mybatis/index/IndexHomeDetailsMapper.xml | 509 +++++++++--------- .../IndexHomeDetailsController.java | 73 ++- 3 files changed, 575 insertions(+), 438 deletions(-) diff --git a/WebContent/WEB-INF/views/warning/warningInfo.jsp b/WebContent/WEB-INF/views/warning/warningInfo.jsp index 3938d65..13e1ff3 100644 --- a/WebContent/WEB-INF/views/warning/warningInfo.jsp +++ b/WebContent/WEB-INF/views/warning/warningInfo.jsp @@ -11,7 +11,6 @@ 预警信息 -<%-- --%> -
-
-
计划到期
-
库存不足
-
检验周期
-
长期占用
-
保有量变化
-
- - -
- -
-
- - -
- -
-
- - -
- -
-
- - -
- -
-
- - -
- -
-
+
+
+
计划到期
+
库存不足
+
检验周期
+
长期占用
+
保有量变化
- - +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+
+ + + + - \ No newline at end of file + diff --git a/resources/mybatis/index/IndexHomeDetailsMapper.xml b/resources/mybatis/index/IndexHomeDetailsMapper.xml index d945984..647a6ab 100644 --- a/resources/mybatis/index/IndexHomeDetailsMapper.xml +++ b/resources/mybatis/index/IndexHomeDetailsMapper.xml @@ -3,14 +3,14 @@ - - + + - - - + + + - - + + - + - + - - - + + + - + - + - - + + - + - - + + - - + + - + - - + + - + - + - - + + - + - + - + - + - - + + - - + + - + - - + + - + - - + + - + - + - + - + - \ No newline at end of file + diff --git a/src/com/bonus/index/controller/IndexHomeDetailsController.java b/src/com/bonus/index/controller/IndexHomeDetailsController.java index 46b4f3a..1f12598 100644 --- a/src/com/bonus/index/controller/IndexHomeDetailsController.java +++ b/src/com/bonus/index/controller/IndexHomeDetailsController.java @@ -1,7 +1,19 @@ package com.bonus.index.controller; +import java.io.OutputStream; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletResponse; + +import com.bonus.ma.beans.pickDetailsBean; +import com.bonus.sys.*; +import com.bonus.sys.beans.UserBean; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -9,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; +import com.bonus.exp.POIOutputHelper; import com.bonus.index.beans.IndexCheckWarnBean; import com.bonus.index.beans.IndexHomeCalendarBean; import com.bonus.index.beans.IndexHomeDetailsBean; @@ -19,9 +32,6 @@ import com.bonus.index.beans.IndexStorageWarnBean; import com.bonus.index.beans.IndexTodoWarnBean; import com.bonus.index.beans.IndexTotalWarnBean; import com.bonus.index.service.IndexHomeDetailsService; -import com.bonus.sys.AjaxRes; -import com.bonus.sys.BaseController; -import com.bonus.sys.GlobalConst; @Controller @RequestMapping("/backstage/indexHomeDetails/") @@ -235,6 +245,63 @@ public class IndexHomeDetailsController extends BaseController list = service.getStorageWarn(o); + expOutExcel(response, list, "库存不足预警导出"); + } catch (Exception e) { + logger.error(e.toString(), e); + } + } + + private void expOutExcel(HttpServletResponse response, List list, String filename) + throws Exception { + if (list != null) { + List> results = new ArrayList>(); + int size = list.size(); + for (int i = 0; i < size; i++) { + IndexStorageWarnBean bean = list.get(i); + Map maps = outMaLeaseBeanToMap(i, bean); + results.add(maps); + } + + List headers = reportHeader(); + HSSFWorkbook workbook = POIOutputHelper.excel(results, headers, filename); + OutputStream out = null; + response.setContentType("application/vnd.ms-excel;charset=UTF-8"); + response.addHeader("Content-Disposition", + "attachment;filename=" + URLEncoder.encode(filename, "UTF-8") + ".xls"); + response.setHeader("Pragma", "No-cache"); + out = response.getOutputStream(); + workbook.write(out); + out.flush(); + out.close(); + } + } + + private Map outMaLeaseBeanToMap(int i, IndexStorageWarnBean o) { + Map maps = new LinkedHashMap(); + maps.put("id", i + 1); + maps.put("isCount", o.getIsCount().equals("0")?"设备":"机具"); + maps.put("maType", o.getMaType()); + maps.put("maName", o.getMaName()); + maps.put("storageNum", o.getStorageNum()); + maps.put("maUnit", o.getMaUnit()); + return maps; + } + + private List reportHeader() { + ArrayList list = new ArrayList(); + list.add("序号"); + list.add("机具类别"); + list.add("机具名称"); + list.add("规格型号"); + list.add("库存量"); + list.add("单位"); + return list; + } // 检验周期 @RequestMapping(value = "getCheckWarn", method = RequestMethod.POST)