【笔记】SSM批量删除、POI导出
来源:互联网 发布:反汇编软件 编辑:程序博客网 时间:2024/05/16 23:38
【页面】
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE html><html> <head> <base href="<%=basePath%>"> <title>智能管理系统</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="./style/googleapis.css" rel="stylesheet"> <!--Bootstrap Stylesheet [ REQUIRED ]--> <link href="./style/bootstrap.min.css" rel="stylesheet"> <link href="./style/themify-icons.min.css" rel="stylesheet"> <link href="./style/font-awesome.min.css" rel="stylesheet"> <link href="./style/ionicons.min.css" rel="stylesheet"> <link href="./style/premium-line-icons.min.css" rel="stylesheet"> <link href="./style/premium-solid-icons.min.css" rel="stylesheet"> <link href="./style/nifty-demo-icons.min.css" rel="stylesheet"> <!--Morris.js [ OPTIONAL ]--> <link href="./style/morris.min.css" rel="stylesheet"> <!--Magic Checkbox [ OPTIONAL ]--> <link href="./style/magic-check.min.css" rel="stylesheet"> <!--Switchery [ OPTIONAL ]--> <link href="./style/switchery.min.css" rel="stylesheet"> <!--Nifty Stylesheet [ REQUIRED ]--> <link href="./style/nifty.css" rel="stylesheet"> <!--Demo [ DEMONSTRATION ]--> <link href="./style/nifty-demo.min.css" rel="stylesheet"> <link href="./style/theme-light.min.css" rel="stylesheet" id="theme"> <!--Pace - Page Load Progress Par [OPTIONAL]--> <link href="./style/pace.min.css" rel="stylesheet"> <script src="./style/pace.min.js"></script> <!--jQuery [ REQUIRED ]--> <script src="./style/jquery-2.2.4.min.js"></script> <!--BootstrapJS [ RECOMMENDED ]--> <script src="./style/bootstrap.min.js"></script> <div id="content-container"><link href="./style/bootstrap-table-sm-5.css" rel="stylesheet"><link rel="stylesheet" href="./style/bootstrap-datetimepicker.min.css"><style>table { table-layout: fixed;}td { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; height: 15px;}.bootstrap-control-tableww { font-size: 13px; height: 100%; border-radius: 0; box-shadow: none; border: 1px solid #e9e9e9; transition-duration: .5s;}.bootstrap-control-tableww:focus { border-color: #42a5f5; box-shadow: none; transition-duration: .5s;}.bootstrap-control-tableww:focus-feedback { z-index: 10;}.has-error .bootstrap-control-tableww,.has-warning .bootstrap-control-tableww,.has-success .bootstrap-control-tableww { box-shadow: none !important;}.has-error{ border-color: #F54244;}</style><script src="./style/bootstrap-datetimepicker.min.js"></script><script src="./style/bootstrap-datetimepicker.zh-CN.js"></script><script src="./style/jquery.maskedinput.min.js"></script><script src="./style/bootstrap-table-sm-5.js"></script><script src="./style/bootstrap-table-zh-CN.min.js"></script><script src="./style/base64.js"></script><script src="./style/assetInfo.js"></script><!--Page content--><div id="page-content"> <input type="hidden" id="page_name" value="asset_basic_info"> <div class="panel"> <!--Panel heading--> <div class="panel-heading"> <!-- 定义div,id为 user_btn_group固定不可变更,存放当前用户该页面可操作按钮--> <div class="panel-control" id="user_btn_group"> <a href="add.jsp"><button id="syswidget_add" class="btn btn-primary" style="margin-right:2px"><i class="ti-plus"></i> 添加</button></a> <button id="syswidget_upd" class="btn btn-mint" onclick="javascript:updateOK();" style="margin-right:2px"><i class="ti-pencil-alt"></i> 修改</button> <button id="syswidget_del" class="btn btn-danger" onclick="javascript:deleteOK();" style="margin-right:2px"><i class="ti-close"></i> 删除</button> <button id="ass_export" class="btn btn-mint" style="margin-right:2px"><i class="ti-export"></i> 导出</button> <button id="ass_import" class="btn btn-info" style="margin-right:2px"><i class="ti-import"></i> 导入</button> </div> <h3 class="panel-title">PC资产信息</h3> </div> <div class="panel-body"> <form action="${pageContext.request.contextPath }/findInfoPage.htm" method="get"> <div class="row"> <div class="form-group"> <div class="input-group date col-sm-2 pull-left"> <span class="input-group-addon">资产编号:</span> <input type="text" class="form-control input-sm" style="width: 180px;" name="querynumber" placeholder="资产编号,资产编号..."> </div> <div class="input-group date col-sm-2 pull-left"> <input type="text" class="form-control input-sm" id="updateTimeStart" name="querybegindate" placeholder="开始时间"> <!-- <span class="input-group-addon"><i class="demo-pli-calendar-4"></i></span> --> </div> <div class="input-group date col-sm-2 pull-left"> <input type="text" class="form-control input-sm" id="updateTimeEnd" name="queryenddate" placeholder="结束时间"> <!-- <span class="input-group-addon"><i class="demo-pli-calendar-4"></i></span> --> <span class="input-group-btn"> <button class="btn btn-primary input-sm" type="submit">搜索</button> </span> </div> </form> <!-- <div class="col-sm-3 input-group pull-right"> <input type="text" name="searchParam" id="searchParam" placeholder="Search..." class="form-control input-sm" width="300px"> <span class="input-group-btn"> <button class="btn btn-primary input-sm" type="button" onclick="queryPcAsset()">搜索</button> </span> </div> --> </div> </div> <form id="form" action="${pageContext.request.contextPath }/deleteInfoArray.htm" method="post"> <div class="row"> <div class="bootstrap-table"> <div class="fixed-table-toolbar"> </div><div class="fixed-table-container" style="padding-bottom: 0px;"> <div class="fixed-table-header" style="display: none;"> <table> </table> </div> <div class="fixed-table-body"> <div class="fixed-table-loading" style="top: 35px; display: none;">正在努力地加载数据中,请稍候……</div> <table id="asset-table" class="table table-hover"> <thead> <tr> <th class="bs-checkbox " style="text-align: center; width: 36px; " data-field="state" tabindex="0"><div class="th-inner "> <input class="sel" onclick="sel()" type="checkbox"></div> <div class="fht-cell"></div> </th> <!-- 序号、资产编号、设备类型、资产所属公司名称、资产状态、资产更新时间(数据根据更新日期降序) --> <th style="text-align: center; width: 150px; " data-field="devManageNum" tabindex="0"> <div class="th-inner ">序号</div> <div class="fht-cell"></div> </th> <th style="text-align: center; " data-field="assetNum" tabindex="0"> <div class="th-inner ">资产编号</div> <div class="fht-cell"></div> </th> <th style="text-align: center; " data-field="devTypeA" tabindex="0"> <div class="th-inner ">设备类型</div> <div class="fht-cell"></div> </th> <th style="text-align: center; " data-field="oneOrgName" tabindex="0"> <div class="th-inner ">公司</div> <div class="fht-cell"></div> </th> <th style="text-align: center; " data-field="assetStatus" tabindex="0"> <div class="th-inner ">资产状态</div> <div class="fht-cell"></div> </th> <th style="text-align: center; width: 150px; " data-field="updateTime" tabindex="0"> <div class="th-inner ">更新时间[降序]</div> <div class="fht-cell"></div> </th></tr></thead><tbody> <c:forEach items="${list }" varStatus="vs" var="info"> <tr data-index="0" data-uniqueid="${info.ass_id }"> <td class="bs-checkbox "><input data-index="0" class="assIds" name="assIds" type="checkbox" value="${info.ass_id }"></td> <td style="text-align: center; width: 150px; ">${vs.count }</td> <td style="text-align: center; width: 150px; ">${info.ass_number }</td> <td style="text-align: center; ">${info.ass_type }</td> <td style="text-align: center; ">${info.company_name }</td> <td style="text-align: center; "> <c:if test="${info.ass_status==0 }"> 在用 </c:if> <c:if test="${info.ass_status==1 }"> 废弃 </c:if> <c:if test="${info.ass_status==2 }"> 报修 </c:if> </td> <td style="text-align: center; width: 150px; ">${info.ass_update_time }</td> </tr> </c:forEach> </tbody> </table> </div> <div class="fixed-table-footer" style="display: none;"><table><tbody><tr></tr></tbody></table></div><div class="fixed-table-pagination" style="display: block;"><div class="pull-left pagination-detail"><span class="pagination-info">${group}</span><span class="page-list" style="display: none;">每页显示 <span class="btn-group dropup"><button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><span class="page-size">10</span> <span class="caret"></span></button><ul class="dropdown-menu" role="menu"><li class="active"><a href="javascript:void(0)">10</a></li></ul></span> 条记录</span></div><div class="pull-right pagination" style="display: none;"><ul class="pagination pagination-sm"><li class="page-pre"><a href="javascript:void(0)">‹</a></li><li class="page-number active"><a href="javascript:void(0)" style="z-index:1">1</a></li><li class="page-next"><a href="javascript:void(0)">›</a></li></ul></div></div></div></div><div class="clearfix"></div> </div> </div></form> </div></div></div></head><script type="text/javascript"> function updateOK(){ var chk_value =[];//定义一个数组 $('.assIds:checked').each(function(){ chk_value.push($(this).val()); }); if(chk_value.length==1){ location.href="${pageContext.request.contextPath }/findInfoById.htm?ass_id="+chk_value[0]; }else{ alert("请选择一条要修改的信息!"); } }; function sel(){ var flag=$('.sel').prop('checked'); $('.assIds').prop('checked',flag); }; function deleteOK(){ var chk_value =[];//定义一个数组 $('.assIds:checked').each(function(){ chk_value.push($(this).val()); }); if(chk_value.length>0){ var r=confirm("是否删除一下N条数据?"); if (r==true) { $('#form').submit(); } }else{ alert("请选择至少一条数据!"); } }; $("#ass_export").click(function() { location.href = "${pageContext.request.contextPath }/exportExcel.htm"; }); $("#ass_import").click(function() { var aa = $("#upload").val(); if (aa != "") { kkk.submit(); } else { alert("请选择Excel文件!"); } });</script></html>
【Action】
package com.athl.action;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.annotation.Resource;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.RequestMapping;import com.athl.entity.Info;import com.athl.service.IInfoService;import com.athl.utils.ExportExcel;import com.athl.utils.PageUtils;@Controllerpublic class InfoAction { Map<String,Object> dataMap =null; @Resource(name = "infoService") private IInfoService infoService; @RequestMapping("/findInfoPage.htm") public String findInfoPage(HttpServletRequest request){ String cp = request.getParameter("currentPage"); if(cp==null || "".equals(cp)){ cp="1"; } Map<String,Object> map = new HashMap<String,Object>(); String temp =request.getParameter("querynumber"); String[] number=null; if(temp!=null && !("".equals(temp))){ number=temp.split(","); map.put("number", number); } String begindate=request.getParameter("querybegindate"); if(begindate!=null && !("".equals(begindate))){ map.put("begindate", begindate); } String enddate=request.getParameter("queryenddate"); if(enddate!=null && !("".equals(enddate))){ map.put("enddate", enddate); } Integer currentPage = Integer.valueOf(cp); int dataCount = infoService.findCount(map); map.put("begain", (currentPage-1)*5); map.put("count", 5); dataMap=map; PageUtils.page(request, currentPage, 5, infoService.findInfoPage(map), dataCount); return "/index.jsp"; } @RequestMapping("/findInfoAll.htm") public String findInfoAll(Model m){ m.addAttribute("infoList", infoService.findInfoAll()); return "/index.jsp"; } @RequestMapping("/insertInfo.htm") public String insertInfo(Info info){ infoService.insertInfo(info); return "redirect:findInfoPage.htm"; } @RequestMapping("/deleteInfoArray.htm") public String deleteInfoArray(HttpServletRequest request){ String[] ids=request.getParameterValues("assIds"); if(ids.length!=0){ infoService.deleteInfoArray(ids); } return "redirect:findInfoPage.htm"; } @RequestMapping("/findInfoById.htm") public String findInfoById(Model m,Integer ass_id){ m.addAttribute("info", infoService.findInfoById(ass_id)); return "/update.jsp"; } @RequestMapping("/updateInfo.htm") public String updateInfo(Info info){ infoService.updateInfo(info); return "redirect:findInfoPage.htm"; } @RequestMapping("/exportExcel.htm") public void exportExcel(HttpServletResponse response) throws Exception { // 定义表的标题 String title = "资产信息列表一览"; //定义表的列名 String[] rowsName = new String[] { "资产编号", "设备类型", "公司", "资产状态", "更新时间"}; //定义表的内容 List<Object[]> dataList = new ArrayList<Object[]>(); Object[] objs = null; List<Info> list = infoService.findInfoPage(dataMap); for (int i = 0; i < list.size(); i++) { Info per = list.get(i); objs = new Object[rowsName.length]; objs[0] = per.getAss_number(); objs[1] = per.getAss_type(); objs[2] = per.getCompany_name(); if(per.getAss_status()==0){ objs[3] ="在用"; }else if(per.getAss_status()==1){ objs[3] ="报废"; }else{ objs[3] ="维修"; } /*objs[3] = per.getAss_status();*/ objs[4] = per.getAss_update_time(); /*SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); String date = df.format(per.getJobtime());*/ dataList.add(objs); } // 创建ExportExcel对象 ExportExcel ex = new ExportExcel(title, rowsName, dataList); // 输出Excel文件 try { OutputStream output = response.getOutputStream(); response.reset(); response.setHeader("Content-disposition", "attachment; filename=List.xls"); response.setContentType("application/msexcel"); ex.export(output); output.close(); } catch (IOException e) { e.printStackTrace(); } }}
【mapper】
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="InfoNamespace"> <resultMap type="Info" id="InfoMap"> <id property="ass_id" column="ass_id" /> <result property="ass_number" column="ass_number" /> <result property="ass_type" column="ass_type" /> <result property="company_id" column="company_id" /> <result property="ass_status" column="ass_status" /> <result property="ass_update_time" column="ass_update_time" /> </resultMap> <select id="findInfoAll" resultType="com.athl.entity.Info"> SELECT ass_id,ass_number,ass_type,company_name,ass_status,ass_update_time FROM asset_manage_info info INNER JOIN company com ON com.company_id=info.company_id ORDER BY ass_update_time DESC </select> <insert id="insertInfo" parameterType="com.athl.entity.Info"> insert into asset_manage_info(ass_number,ass_type,company_id,ass_update_time) values(#{ass_number},#{ass_type},#{company_id},now()) </insert> <delete id="deleteInfoArray" > delete from asset_manage_info where ass_id in <foreach collection="array" open="(" close=")" separator="," item="ids"> #{ids} </foreach> </delete> <select id="findInfoById" parameterType="int" resultType="com.athl.entity.Info"> SELECT ass_id,ass_number,ass_type,company_name,ass_status,ass_update_time FROM asset_manage_info info INNER JOIN company com ON com.company_id=info.company_id where ass_id=#{ass_id} </select> <update id="updateInfo" parameterType="com.athl.entity.Info"> update asset_manage_info set ass_number=#{ass_number}, ass_update_time=now() where ass_id=#{ass_id} </update> <select id="findCount" resultType="int"> select count(*) from asset_manage_info <where> <if test="number!=null and number.length>0 "> <foreach collection="number" item="item"> or ass_number like '%' #{item} '%' </foreach> </if> <if test="begindate!=null and begindate!=''"> and ass_update_time >= #{begindate} </if> <if test="enddate!=null and enddate!=''"> and ass_update_time <= #{enddate} </if> </where> </select> <select id="findInfoPage" resultType="com.athl.entity.Info"> SELECT ass_id,ass_number,ass_type,company_name,ass_status,ass_update_time FROM asset_manage_info info INNER JOIN company com ON com.company_id=info.company_id <where> <if test="number!=null and number.length>0 "> <foreach collection="number" item="item"> or ass_number like '%' #{item} '%' </foreach> </if> <if test="begindate!=null and begindate!=''"> and ass_update_time >= #{begindate} </if> <if test="enddate!=null and enddate!=''"> and ass_update_time <= #{enddate} </if> </where> ORDER BY ass_update_time DESC limit #{begain},#{count} </select></mapper>
3 0
- 【笔记】SSM批量删除、POI导出
- (SSM)POI导出Excel
- POI批量导出数据
- POI批量导出
- SSM做批量删除
- SSM SpringMVC 批量删除
- ssm中用poi导出excel
- POI批量导出Excel JAVA
- SSM 框架的批量删除
- POI:数据批量导出、按模板导出
- SSM框架使用POI导出EXCEL
- SSM POI---导出(含工具类)
- POI导出Excel笔记
- SSM中的JS之文档批量导出
- java poi 实现Excel的批量导出
- ssm框架的细枝末节之批量删除
- ssm批量删除和模糊查询
- Apache POI 导出Excel笔记
- html标签label元素
- 第三章 DispatcherServlet详解
- 利用Eclipse-Python简单爬取京东商城书籍信息进行可视化
- 面试经历(一)
- win10 10240专业版升级15063微软官方最新版
- 【笔记】SSM批量删除、POI导出
- bzoj 1150 CTSC: [CTSC2007]数据备份Backup
- 还是畅通工程
- leetcode---Fizz Buzz
- part-24 输出阻抗Ro和Rout
- 向量类操作
- 进程之间、线程之间的通信方式
- poj 1860 Currency Exchange (spfa或Bellman-Ford)
- 分类算法评价