| | |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.SubTablePageInfoUtil; |
| | | import com.whyc.util.ThreadLocalUtil; |
| | | import org.apache.poi.ss.usermodel.ClientAnchor; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.apache.poi.xssf.usermodel.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | XSSFWorkbook wb = new XSSFWorkbook(); |
| | | XSSFSheet sheet = wb.createSheet("锁的基础信息"); |
| | | // 创建一个单元格样式,并设置字体大小为5 |
| | | sheet.setDefaultColumnWidth(20); |
| | | sheet.setDefaultRowHeightInPoints(20); |
| | | |
| | | XSSFDrawing patriarch = sheet.createDrawingPatriarch(); |
| | | int rowNumSheet = 0; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("所属区域:"+linf.getAreaName()); |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("锁的名称:"+linf.getLockName()); |
| | | sheet.getRow(rowNumSheet).createCell(2).setCellValue("锁的类型:实体锁"); |
| | | Row row1 = sheet.createRow(rowNumSheet); |
| | | row1.setHeightInPoints(20.0f); |
| | | row1.createCell(0).setCellValue("所属区域:"+linf.getAreaName()); |
| | | row1.createCell(1).setCellValue("锁的名称:"+linf.getLockName()); |
| | | row1.createCell(2).setCellValue("锁的类型:实体锁"); |
| | | rowNumSheet++; |
| | | |
| | | sheet.createRow(rowNumSheet); |
| | | Row row2 = sheet.createRow(rowNumSheet); |
| | | row2.setHeightInPoints(20.0f); |
| | | switch (linf.getLockState()){ |
| | | case -1:sheet.getRow(rowNumSheet).createCell(0).setCellValue("锁的状态:未安装");break; |
| | | case 0:sheet.getRow(rowNumSheet).createCell(0).setCellValue("锁的状态:闭锁");break; |
| | | case 1:sheet.getRow(rowNumSheet).createCell(0).setCellValue("锁的状态:开锁");break; |
| | | case -1:row2.createCell(0).setCellValue("锁的状态:未安装");break; |
| | | case 0:row2.createCell(0).setCellValue("锁的状态:闭锁");break; |
| | | case 1:row2.createCell(0).setCellValue("锁的状态:开锁");break; |
| | | } |
| | | switch (linf.getLockOnline()){ |
| | | case 0:sheet.getRow(rowNumSheet).createCell(1).setCellValue("锁的状态:离线");break; |
| | | case 1:sheet.getRow(rowNumSheet).createCell(1).setCellValue("锁的状态:在线");break; |
| | | case 0:row2.createCell(1).setCellValue("锁的状态:离线");break; |
| | | case 1:row2.createCell(1).setCellValue("锁的状态:在线");break; |
| | | } |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("锁具开启次数:"+linf.getLockOpenCount()); |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("上一次开锁时间:"+ThreadLocalUtil.format(linf.getLastUpdateTime(),1)); |
| | | Row row3 = sheet.createRow(rowNumSheet); |
| | | row3.setHeightInPoints(20.0f); |
| | | row3.createCell(0).setCellValue("锁具开启次数:"+linf.getLockOpenCount()); |
| | | row3.createCell(1).setCellValue("上一次开锁时间:"+ThreadLocalUtil.format(linf.getLastUpdateTime(),1)); |
| | | |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("屏柜类型:"+linf.getScreenBoxType()); |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("屏柜品牌:"+linf.getScreenBoxProduct()); |
| | | Row row4 = sheet.createRow(rowNumSheet); |
| | | row4.setHeightInPoints(20.0f); |
| | | row4.createCell(0).setCellValue("屏柜类型:"+linf.getScreenBoxType()); |
| | | row4.createCell(1).setCellValue("屏柜品牌:"+linf.getScreenBoxProduct()); |
| | | |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("开始时间:"+startTime); |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("结束时间:"+endTime); |
| | | Row row5 = sheet.createRow(rowNumSheet); |
| | | row5.setHeightInPoints(20.0f); |
| | | row5.createCell(0).setCellValue("开始时间:"+startTime); |
| | | row5.createCell(1).setCellValue("结束时间:"+endTime); |
| | | |
| | | XSSFSheet sheet1 = wb.createSheet("历史数据"); |
| | | sheet1.setDefaultColumnWidth(20); |
| | | sheet1.setDefaultRowHeightInPoints(20); |
| | | //抬头 |
| | | int rowNum = 0; |
| | | XSSFRow row = sheet1.createRow(rowNum); |
| | | row.createCell(0).setCellValue("记录时间(yyyy-MM-dd HH:mm:ss)"); |
| | | row.createCell(1).setCellValue("锁具状态"); |
| | | row.createCell(2).setCellValue("开锁方式"); |
| | | Row row6 = sheet1.createRow(rowNum); |
| | | row6.setHeightInPoints(20.0f); |
| | | row6.createCell(0).setCellValue("记录时间(yyyy-MM-dd HH:mm:ss)"); |
| | | row6.createCell(1).setCellValue("锁具状态"); |
| | | row6.createCell(2).setCellValue("开锁方式"); |
| | | rowNum++; |
| | | //数据栏 |
| | | for (int i = 0; i < list.size(); i++) { |
| | | sheet1.createRow(rowNum); //创建行 |
| | | Row row=sheet1.createRow(rowNum); //创建行 |
| | | LockHis lock=list.get(i); |
| | | sheet1.getRow(rowNum).createCell(0).setCellValue(ThreadLocalUtil.format(lock.getRecordTime(),1)); |
| | | sheet1.getRow(rowNum).createCell(1).setCellValue(lock.getLockState()==0?"闭锁":lock.getLockState()==1?"开锁":"未知"); |
| | | row.createCell(0).setCellValue(ThreadLocalUtil.format(lock.getRecordTime(),1)); |
| | | row.createCell(1).setCellValue(lock.getLockState()==0?"闭锁":lock.getLockState()==1?"开锁":"未知"); |
| | | switch (lock.getUnlockType()){ |
| | | case 0:sheet1.getRow(rowNum).createCell(2).setCellValue("485开锁");break; |
| | | case 1:sheet1.getRow(rowNum).createCell(2).setCellValue("刷卡开锁");break; |
| | | case 2:sheet1.getRow(rowNum).createCell(2).setCellValue("蓝牙开锁");break; |
| | | case 3:sheet1.getRow(rowNum).createCell(2).setCellValue("DI开锁");break; |
| | | case 0:row.createCell(2).setCellValue("485开锁");break; |
| | | case 1:row.createCell(2).setCellValue("刷卡开锁");break; |
| | | case 2:row.createCell(2).setCellValue("蓝牙开锁");break; |
| | | case 3:row.createCell(2).setCellValue("DI开锁");break; |
| | | } |
| | | rowNum++; |
| | | } |