Kaynağa Gözat

人员导出

jz.kai 5 yıl önce
ebeveyn
işleme
bbc0a90fd6

+ 65 - 10
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonInfoController.java

@@ -656,21 +656,76 @@ public class PersonInfoController {
 
     @ApiOperation(value="导出人员")
     @PostMapping("exportXls")
-    public MessageResult<String> exportXls(HttpServletRequest request, HttpServletResponse response){
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "ids",value = "人员ids", required = false, paramType = "form",dataType = "String")
+    })
+    public MessageResult<String> exportXls(@RequestParam(value="ids",defaultValue="") String ids){
         MessageResult<String> msgResult = new MessageResult<>();
 
         try {
-            //创建hssfWorkbook
             HSSFWorkbook workbook = new HSSFWorkbook();
-
-            //创建工作簿
             HSSFSheet sheet = workbook.createSheet();
-
-            //创建标题
-            HSSFRow row = sheet.createRow(0);
-            HSSFCell cell = row.createCell(0);
-            cell.setCellValue("商品信息汇总");
-
+            //表头
+            HSSFRow rowTitle = sheet.createRow(0);
+            HSSFCell cellTitle1 = rowTitle.createCell(0);
+            cellTitle1.setCellValue("序号");
+            HSSFCell cellTitle2 = rowTitle.createCell(1);
+            cellTitle2.setCellValue("姓名");
+            HSSFCell cellTitle3 = rowTitle.createCell(2);
+            cellTitle3.setCellValue("身份证");
+            HSSFCell cellTitle4 = rowTitle.createCell(3);
+            cellTitle4.setCellValue("手机号");
+            HSSFCell cellTitle5 = rowTitle.createCell(4);
+            cellTitle5.setCellValue("位置1");
+            HSSFCell cellTitle6 = rowTitle.createCell(5);
+            cellTitle6.setCellValue("位置2");
+            HSSFCell cellTitle7 = rowTitle.createCell(6);
+            cellTitle7.setCellValue("位置3");
+            HSSFCell cellTitle8 = rowTitle.createCell(7);
+            cellTitle8.setCellValue("位置4");
+            HSSFCell cellTitle9 = rowTitle.createCell(8);
+            cellTitle9.setCellValue("位置5");
+            HSSFCell cellTitle10 = rowTitle.createCell(9);
+            cellTitle10.setCellValue("人脸开关");
+            HSSFCell cellTitle11 = rowTitle.createCell(10);
+            cellTitle11.setCellValue("刷卡开关");
+            HSSFCell cellTitle12 = rowTitle.createCell(11);
+            cellTitle12.setCellValue("手机开关");
+            HSSFCell cellTitle13 = rowTitle.createCell(12);
+            cellTitle13.setCellValue("访客开关");
+            //表内容
+            String[] idArray = ids.split(",");
+            for(int i=0; i<idArray.length; i++){
+                PersonInfo personInfo = personInfoService.get(Long.getLong(idArray[i]));
+
+                HSSFRow rowContent = sheet.createRow(0);
+                HSSFCell cellContent1 = rowContent.createCell(0);
+                cellContent1.setCellValue(i+1);
+                HSSFCell cellContent2 = rowContent.createCell(1);
+                cellContent2.setCellValue(personInfo.getName());
+                HSSFCell cellContent3 = rowContent.createCell(2);
+                cellContent3.setCellValue(personInfo.getIdCard());
+                HSSFCell cellContent4 = rowContent.createCell(3);
+                cellContent4.setCellValue(personInfo.getPhone());
+                HSSFCell cellContent5 = rowContent.createCell(4);
+                cellContent5.setCellValue(personInfo.getPosition1());
+                HSSFCell cellContent6 = rowContent.createCell(5);
+                cellContent6.setCellValue(personInfo.getPosition2());
+                HSSFCell cellContent7 = rowContent.createCell(6);
+                cellContent7.setCellValue(personInfo.getPosition3());
+                HSSFCell cellContent8 = rowContent.createCell(7);
+                cellContent8.setCellValue(personInfo.getPosition4());
+                HSSFCell cellContent9 = rowContent.createCell(8);
+                cellContent9.setCellValue(personInfo.getPosition5());
+                HSSFCell cellContent10 = rowContent.createCell(9);
+                cellContent10.setCellValue(personInfo.getFaceEnabled());
+                HSSFCell cellContent11 = rowContent.createCell(10);
+                cellContent11.setCellValue(personInfo.getCardEnabled());
+                HSSFCell cellContent12 = rowContent.createCell(11);
+                cellContent12.setCellValue(personInfo.getAppEnabled());
+                HSSFCell cellContent13 = rowContent.createCell(12);
+                cellContent13.setCellValue(personInfo.getGuestEnabled());
+            }
 
             //todo 将wb保存到oss
             ByteArrayOutputStream output = new ByteArrayOutputStream();