8 changed files with 262 additions and 11 deletions
			
			
		- 
					3archives/src/main/java/com/storeroom/modules/archives/service/ArchivesTagService.java
- 
					8archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesTagServiceImpl.java
- 
					89common/src/main/java/com/storeroom/utils/ExcelUtil.java
- 
					69storeroom/src/main/java/com/storeroom/modules/storeroom3d/controller/SecurityDoorController.java
- 
					21storeroom/src/main/java/com/storeroom/modules/storeroom3d/domain/SecurityDoor.java
- 
					41storeroom/src/main/java/com/storeroom/modules/storeroom3d/repository/SecurityDoorRepository.java
- 
					6storeroom/src/main/java/com/storeroom/modules/storeroom3d/service/SecurityDoorService.java
- 
					36storeroom/src/main/java/com/storeroom/modules/storeroom3d/service/impl/SecurityDoorServiceImpl.java
| @ -0,0 +1,89 @@ | |||||
|  | package com.storeroom.utils; | ||||
|  | 
 | ||||
|  | import org.apache.poi.hssf.usermodel.*; | ||||
|  | import org.apache.poi.ss.usermodel.BorderStyle; | ||||
|  | import org.apache.poi.ss.usermodel.HorizontalAlignment; | ||||
|  | import org.apache.poi.ss.usermodel.VerticalAlignment; | ||||
|  | import org.apache.poi.ss.util.CellRangeAddress; | ||||
|  | import org.apache.poi.xssf.usermodel.*; | ||||
|  | 
 | ||||
|  | import javax.servlet.http.HttpServletResponse; | ||||
|  | import java.io.UnsupportedEncodingException; | ||||
|  | import java.net.URLEncoder; | ||||
|  | import java.sql.Timestamp; | ||||
|  | import java.text.SimpleDateFormat; | ||||
|  | import java.util.Date; | ||||
|  | import java.util.List; | ||||
|  | 
 | ||||
|  | public class ExcelUtil { | ||||
|  | 
 | ||||
|  |     private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||||
|  |     private static SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); | ||||
|  | 
 | ||||
|  |     /** | ||||
|  |      * 导出Excel | ||||
|  |      * @param sheetName sheet名称 | ||||
|  |      * @param title 标题 | ||||
|  |      * @param values 内容 | ||||
|  |      * @param wb HSSFWorkbook对象 | ||||
|  |      * @return | ||||
|  |      */ | ||||
|  |     public static HSSFWorkbook getHSSFWorkbook(String sheetName,String []title,String [][]values, HSSFWorkbook wb){ | ||||
|  | 
 | ||||
|  |         // 第一步,创建一个HSSFWorkbook,对应一个Excel文件 | ||||
|  |         if(wb == null){ | ||||
|  |             wb = new HSSFWorkbook(); | ||||
|  |         } | ||||
|  | 
 | ||||
|  |         // 第二步,在workbook中添加一个sheet,对应Excel文件中的sheet | ||||
|  |         HSSFSheet sheet = wb.createSheet(sheetName); | ||||
|  | 
 | ||||
|  |         // 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制 | ||||
|  |         HSSFRow row = sheet.createRow(0); | ||||
|  | 
 | ||||
|  |         // 第四步,创建单元格,并设置值表头 设置表头居中 | ||||
|  |         HSSFCellStyle style = wb.createCellStyle(); | ||||
|  |         style.setAlignment(HorizontalAlignment.CENTER); // 创建一个居中格式 | ||||
|  |         style.setVerticalAlignment(VerticalAlignment.CENTER); | ||||
|  | 
 | ||||
|  |         //声明列对象 | ||||
|  |         HSSFCell cell = null; | ||||
|  | 
 | ||||
|  |         //创建标题 | ||||
|  |         for(int i=0;i<title.length;i++){ | ||||
|  |             cell = row.createCell(i); | ||||
|  |             cell.setCellValue(title[i]); | ||||
|  |             cell.setCellStyle(style); | ||||
|  |         } | ||||
|  | 
 | ||||
|  |         //创建内容 | ||||
|  |         for(int i=0;i<values.length;i++){ | ||||
|  |             row = sheet.createRow(i + 1); | ||||
|  |             for(int j=0;j<values[i].length;j++){ | ||||
|  |                 HSSFCell newCell = row.createCell(j); | ||||
|  |                 //将内容按顺序赋给对应的列对象 | ||||
|  |                 newCell.setCellValue(values[i][j]); | ||||
|  |                 newCell.setCellStyle(style); | ||||
|  |             } | ||||
|  |         } | ||||
|  |         return wb; | ||||
|  |     } | ||||
|  | 
 | ||||
|  |     //发送响应流方法 | ||||
|  |     public static void setResponseHeader(HttpServletResponse response, String fileName) { | ||||
|  |         try { | ||||
|  |             try { | ||||
|  |                 fileName = new String(fileName.getBytes(),"UTF-8"); | ||||
|  |             } catch (UnsupportedEncodingException e) { | ||||
|  |                 // TODO Auto-generated catch block | ||||
|  |                 e.printStackTrace(); | ||||
|  |             } | ||||
|  |             response.setContentType("application/octet-stream;charset=UTF-8"); | ||||
|  |             response.setHeader("Content-Disposition", "attachment;filename="+ URLEncoder.encode(fileName,"utf-8")+".xls"); | ||||
|  |             response.addHeader("Pargam", "no-cache"); | ||||
|  |             response.addHeader("Cache-Control", "no-cache"); | ||||
|  |         } catch (Exception ex) { | ||||
|  |             ex.printStackTrace(); | ||||
|  |         } | ||||
|  |     } | ||||
|  | } | ||||
| @ -1,12 +1,18 @@ | |||||
| package com.storeroom.modules.storeroom3d.service; | package com.storeroom.modules.storeroom3d.service; | ||||
| 
 | 
 | ||||
| import com.storeroom.modules.storeroom3d.domain.SecurityDoor; | import com.storeroom.modules.storeroom3d.domain.SecurityDoor; | ||||
|  | import org.springframework.data.domain.Pageable; | ||||
| 
 | 
 | ||||
| import java.util.List; | import java.util.List; | ||||
|  | import java.util.Map; | ||||
| 
 | 
 | ||||
| public interface SecurityDoorService { | public interface SecurityDoorService { | ||||
| 
 | 
 | ||||
|     void create(SecurityDoor securityDoor); |     void create(SecurityDoor securityDoor); | ||||
| 
 | 
 | ||||
|     List<SecurityDoor> queryStoreroom(); |     List<SecurityDoor> queryStoreroom(); | ||||
|  | 
 | ||||
|  |     //门禁日志记录 | ||||
|  |     Object initSecurityDoorLog(String roomName, String deviceName,String startTime,String endTime, Pageable page); | ||||
|  |     List<Map<String,Object>> initSecurityDoorLog(String roomName, String deviceName,String startTime,String endTime); | ||||
| } | } | ||||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue