From 45f239cd69fdc44cf36b4b2b0c9171114e890ae3 Mon Sep 17 00:00:00 2001
From: 101captain <237651143@qq.com>
Date: 星期一, 15 十一月 2021 17:53:27 +0800
Subject: [PATCH] 1115修改提交

---
 springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/excel/Custemhandler.java       |    7 
 springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComActReserveApi.java      |  210 ++++++++++++++++++++++
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActReserveAnswerContentMapper.xml                   |    4 
 springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/excel/CustemSecondhandler.java |   73 ++++++++
 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/HomeQuarantineUtil.java                            |  220 ++++++++++++++++++++++++
 5 files changed, 502 insertions(+), 12 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/HomeQuarantineUtil.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/HomeQuarantineUtil.java
new file mode 100644
index 0000000..47a4947
--- /dev/null
+++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/HomeQuarantineUtil.java
@@ -0,0 +1,220 @@
+package com.panzhihua.common.utlis;
+
+import cn.hutool.core.date.DateUtil;
+import com.panzhihua.common.model.vos.community.ComActQuestnaireAnswerContentVO;
+import lombok.extern.slf4j.Slf4j;
+
+import javax.xml.bind.DatatypeConverter;
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author zzj
+ */
+@Slf4j
+public class HomeQuarantineUtil {
+    /**
+     * 数据转换--登记明细用户填写答案导出数据格式转换
+     *
+     * @param answerContentVOList 用户答题记录
+     * @return 用户填写答案数据
+     */
+    public static List<List<Object>> ReserveData(List<ComActQuestnaireAnswerContentVO> answerContentVOList) {
+        //结果数据集合
+        List<List<Object>> resultList = new ArrayList<>();
+        //构建单个用户数据
+        List<Object> userData = new ArrayList<>();
+
+        String noExport = "以上信息仅用于";
+        //遍历答案列表
+        Long reserveRecordId = 0L;
+        Long reserveSubId = 0L;
+        Integer count=0;
+        StringBuffer conditions=new StringBuffer();
+        Boolean isOldDuo = false;
+        StringBuffer sb = new StringBuffer();
+        if (answerContentVOList != null && answerContentVOList.size() > 0) {
+            for (ComActQuestnaireAnswerContentVO userAnswers : answerContentVOList) {
+                if(count%16==0){
+                   conditions.append(DateUtils.format(userAnswers.getTime(),new SimpleDateFormat("yyyy-MM-dd")) +" "+"上午体温"+userAnswers.getAnswerContent()+"℃"+"\n");
+                   count++;
+                   continue;
+                }
+                if(count%16==1){
+                    conditions.append(DateUtils.format(userAnswers.getTime(),new SimpleDateFormat("yyyy-MM-dd"))+" "+"下午体温"+userAnswers.getAnswerContent()+"℃"+"\n");
+                    count++;
+                    continue;
+                }
+                if(count%16==2){
+                    conditions.append(DateUtils.format(userAnswers.getTime(),new SimpleDateFormat("yyyy-MM-dd"))+" "+"当日隔离情况:"+userAnswers.getAnswerContent()+"\n");
+                    conditions.append("————————"+"\n");
+                    count++;
+                    continue;
+                }
+                count++;
+                //判断是文字描述直接跳过
+                if (userAnswers.getOptionType().equals(5) || userAnswers.getOptionType().equals(11)
+                        || (StringUtils.isNotEmpty(userAnswers.getAnswerContent()) && userAnswers.getAnswerContent().contains(noExport))) {
+                    continue;
+                }
+                //判断reserveRecordId为空则为第一条记录,默认加上昵称和灯谜是
+                if (reserveRecordId.equals(0L)) {
+                    reserveRecordId = userAnswers.getReserveRecordId();
+                    userData.add(userAnswers.getNickName());
+                    userData.add(DateUtils.format(userAnswers.getTime(), DateUtils.ymdhms_format));
+                }
+                //根据reserveRecordId判断是否是第二条填报记录
+                if (!reserveRecordId.equals(userAnswers.getReserveRecordId())) {
+                    reserveSubId = 0L;
+
+                    if(isOldDuo){
+                        String answer = sb.toString();
+                        userData.add(answer.substring(0, answer.length() - 1));
+                        sb = new StringBuffer();
+                        isOldDuo = false;
+                    }
+                    for(List<Object> result:resultList){
+                            if(result.get(4).equals(userData.get(4))){
+                                String condition=result.get(result.size()-1)+userData.get(userData.size()-1).toString();
+                                result.set(result.size()-1,condition);
+                                userData.set(userData.size()-1,null);
+                            break;
+                        }
+                    }
+                    if(userData.get(userData.size()-1)!=null){
+                        resultList.add(userData);
+                    }
+                    userData = new ArrayList<>();
+                    reserveRecordId = userAnswers.getReserveRecordId();
+                    userData.add(userAnswers.getNickName());
+                    userData.add(DateUtils.format(userAnswers.getTime(), DateUtils.ymdhms_format));
+                    if(StringUtils.isNotEmpty(userAnswers.getAnswerContent())){
+                        userData.add(userAnswers.getAnswerContent());
+                    }else{
+                        userData.add(" ");
+                    }
+
+                }else{
+                    if(reserveSubId.equals(0L)){
+                        reserveSubId = userAnswers.getReserveSubId();
+                    }
+
+                    if(!reserveSubId.equals(userAnswers.getReserveSubId())){
+                        reserveSubId = userAnswers.getReserveSubId();
+
+                        //如果是承诺字段则不导出
+                        if(StringUtils.isNotEmpty(userAnswers.getAnswerContent()) && userAnswers.getAnswerContent().contains(noExport)){
+                            continue;
+                        }
+
+                        //判断当前的组件类型是否是图片上传,导出时需要导出图片
+                        if(userAnswers.getOptionType().equals(11)){
+                            reserveSubId = userAnswers.getReserveSubId();
+                            try {
+                                userData.add(new URL(userAnswers.getAnswerContent()));
+                            }catch (Exception e){
+                                userData.add(" ");
+                                log.error("导出转换图片失败!");
+                            }
+                            continue;
+                        }
+                        //判断当前组件类型是否签名
+                        if(userAnswers.getOptionType().equals(12)){
+                            reserveSubId = userAnswers.getReserveSubId();
+                            try {
+                                userData.add(DatatypeConverter.parseBase64Binary(userAnswers.getAnswerContent().substring(userAnswers.getAnswerContent().indexOf(",") + 1)));
+                            }catch (Exception e){
+                                userData.add(" ");
+                                log.error("导出转换图片失败!");
+                            }
+                            continue;
+                        }
+
+                        if(userAnswers.getOptionType().equals(1)){
+                            isOldDuo = true;
+                            sb.append(userAnswers.getAnswerContent()==null?"无":userAnswers.getAnswerContent() + ",");
+                            continue;
+                        }else{
+                            if(isOldDuo){
+                                String answer = sb.toString();
+                                userData.add(answer.substring(0, answer.length() - 1));
+                                sb = new StringBuffer();
+                            }
+                            isOldDuo = false;
+                        }
+                        sb.append(userAnswers.getAnswerContent()==null?"无":userAnswers.getAnswerContent() + ",");
+                        String answer = sb.toString();
+                        userData.add(answer.substring(0, answer.length() - 1));
+                        sb = new StringBuffer();
+                    }else{
+                        //如果是承诺字段则不导出
+                        if(StringUtils.isNotEmpty(userAnswers.getAnswerContent()) && userAnswers.getAnswerContent().contains(noExport)){
+                            continue;
+                        }
+                        //判断当前的组件类型是否是图片上传,导出时需要导出图片
+                        if(userAnswers.getOptionType().equals(11)){
+                            reserveSubId = userAnswers.getReserveSubId();
+                            try {
+                                userData.add(new URL(userAnswers.getAnswerContent()));
+                            }catch (Exception e){
+                                userData.add(" ");
+                                log.error("导出转换图片失败!");
+                            }
+                            continue;
+                        }
+                        //判断当前组件类型是否签名
+                        if(userAnswers.getOptionType().equals(12)){
+                            reserveSubId = userAnswers.getReserveSubId();
+                            try {
+                                //userData.add(new URL("http://image.panzhihua.nhys.cdnhxx.com//idcard/967dbdef3ef3465a9169fbea204f9aa7.jpg"));
+                                userData.add(DatatypeConverter.parseBase64Binary(userAnswers.getAnswerContent().substring(userAnswers.getAnswerContent().indexOf(",") + 1)));
+                            }catch (Exception e){
+                                userData.add(" ");
+                                log.error("导出转换图片失败!");
+                            }
+                            continue;
+                        }
+                        if(userAnswers.getOptionType().equals(1)){
+                            isOldDuo = true;
+                            sb.append(userAnswers.getAnswerContent()==null?"无":userAnswers.getAnswerContent() + ",");
+                            continue;
+                        }else{
+                            if(isOldDuo){
+                                String answer = sb.toString();
+                                userData.add(answer.substring(0, answer.length() - 1));
+                                sb = new StringBuffer();
+                            }
+                            isOldDuo = false;
+                        }
+                        sb.append(userAnswers.getAnswerContent()==null?"无":userAnswers.getAnswerContent() + ",");
+                        String answer = sb.toString();
+                        userData.add(answer.substring(0, answer.length() - 1));
+                        sb = new StringBuffer();
+                    }
+                }
+                if(count%16==0){
+                    userData.add(conditions.toString());
+                    conditions=new StringBuffer();
+                }
+            }
+            if(isOldDuo){
+                String answer = sb.toString();
+                userData.add(answer.substring(0, answer.length() - 1));
+            }
+            for(List<Object> result:resultList){
+                if(result.get(4).equals(userData.get(4))){
+                    String condition=result.get(result.size()-1)+userData.get(userData.size()-1).toString();
+                    result.set(result.size()-1,condition);
+                    userData.set(userData.size()-1,null);
+                    break;
+                }
+            }
+            if(userData.get(userData.size()-1)!=null){
+                resultList.add(userData);
+            }
+        }
+        return resultList;
+    }
+}
diff --git a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComActReserveApi.java b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComActReserveApi.java
index de304d4..62edaf9 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComActReserveApi.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComActReserveApi.java
@@ -23,11 +23,9 @@
 import com.panzhihua.common.model.vos.community.reserve.*;
 import com.panzhihua.common.service.community.CommunityService;
 import com.panzhihua.common.service.user.UserService;
-import com.panzhihua.common.utlis.AssemblyUtils;
-import com.panzhihua.common.utlis.DateUtils;
-import com.panzhihua.common.utlis.SFTPUtil;
-import com.panzhihua.common.utlis.StringUtils;
+import com.panzhihua.common.utlis.*;
 import com.panzhihua.community_backstage.config.SFTPConfig;
+import com.panzhihua.community_backstage.excel.CustemSecondhandler;
 import com.panzhihua.community_backstage.excel.Custemhandler;
 import com.panzhihua.community_backstage.excel.CustomSheetWriteHandler;
 import io.swagger.annotations.Api;
@@ -45,6 +43,7 @@
 import java.net.URL;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @description: 预约登记接口
@@ -468,6 +467,197 @@
     @ApiOperation(value = "导出登记明细")
     @PostMapping("/register/list/export")
     public R exportRegister(@RequestBody PageReserveRegisterDetailedAdminDTO pageReserveRegisterDetailedAdminDTO) {
+        String name="";
+        R r=communityService.detailReserveAdmin(pageReserveRegisterDetailedAdminDTO.getReserveId());
+        ComActReserveDetailAdminVO comActReserveDetailAdminVO=JSON.parseObject(JSON.toJSONString(r.getData()),ComActReserveDetailAdminVO.class);
+        if(comActReserveDetailAdminVO.getTitle().contains("居家隔离")){
+            name = "居家隔离导出数据.xlsx";
+        }
+        else {
+            name = "登记明细导出数据.xlsx";
+        }
+        String ftpUrl = "/mnt/data/web/excel/";
+        String noHaed = "承诺";
+        List<List<Object>> datalist=new ArrayList<>();
+        try {
+            SFTPUtil sftp = new SFTPUtil(sftpConfig.getUserName(), sftpConfig.getPassword(), sftpConfig.getHost(), sftpConfig.getPort());
+            sftp.login();
+            boolean existDir = sftp.isExistDir(ftpUrl + name);
+            if (!existDir) {
+                String property = System.getProperty("user.dir");
+                String fileName = property + File.separator + name;
+                ExcelWriter excelWriter = null;
+                InputStream inputStream = null;
+                try {
+                    /**
+                     * 组合导出数据
+                     * 用户问卷答案
+                     */
+                    R QuestnaireAnswersDTOR = communityService.exportRegisterAdmin(pageReserveRegisterDetailedAdminDTO);
+                    QuestnaireAnswersDTO questnaireAnswersDTOS = JSON.parseObject(JSON.toJSONString(QuestnaireAnswersDTOR.getData()), QuestnaireAnswersDTO.class);
+                    List<ComActQuestnaireSubVO> subVOList = questnaireAnswersDTOS.getSubs();
+                    //构造表头
+                    List<List<String>> headList = new ArrayList<List<String>>();
+                    if(comActReserveDetailAdminVO.getTitle().contains("居家隔离")){
+                        String firstRowContent = "重点地区或高风险地区来攀返攀人员信息统计表(居家隔离表)";
+                        List<String> head0 = new ArrayList<>();
+                        head0.add(firstRowContent);
+                        head0.add("登记人昵称");
+                        headList.add(head0);
+                        List<String> head1 = new ArrayList<>();
+                        head1.add(firstRowContent);
+                        head1.add("登记时间");
+                        headList.add(head1);
+                        subVOList.forEach(sub -> {
+                            if (sub.getType() != 5 && sub.getType() != 11&&!sub.getContent().contains("今日上午")&&!sub.getContent().contains("今日下午")&&!sub.getContent().contains("今日隔离情况")) {
+                                List<String> headn = new ArrayList<>();
+                                headn.add(firstRowContent);
+                                if(!sub.getContent().equals(noHaed)){
+                                    if(sub.getType() == 11){
+                                        headn.add(sub.getContent().substring(0, sub.getContent().indexOf("(")));
+                                    }else{
+                                        headn.add(sub.getContent());
+                                    }
+                                    headList.add(headn);
+                                }
+                            }
+                        });
+                        List<String> head2 = new ArrayList<>();
+                        head2.add(firstRowContent);
+                        head2.add("隔离体温情况");
+                        headList.add(head2);
+                        //数据转换
+                        datalist = HomeQuarantineUtil.ReserveData(questnaireAnswersDTOS.getAnswers());
+                        WriteCellStyle headWriteCellStyle = new WriteCellStyle();
+                        //设置头居中
+                        headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
+                        //设置头字体
+                        WriteFont headWriteFont = new WriteFont();
+                        headWriteFont.setFontHeightInPoints((short)6);
+                        headWriteFont.setBold(true);
+                        headWriteCellStyle.setWriteFont(headWriteFont);
+
+
+                        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
+                        //设置表格内容字体
+                        WriteFont writeFont = new WriteFont();
+                        writeFont.setFontHeightInPoints((short)6);
+                        //设置 水平居中
+                        contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.LEFT);
+                        //设置 垂直居中
+                        contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+                        contentWriteCellStyle.setWriteFont(writeFont);
+
+                        contentWriteCellStyle.setWrapped(true);
+                        HorizontalCellStyleStrategy horizontalCellStyleStrategy =
+                                new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
+
+
+                        excelWriter = EasyExcel.write(fileName)
+                                .registerWriteHandler(horizontalCellStyleStrategy).registerWriteHandler(new CustemSecondhandler())
+                                .build();
+                        WriteSheet writeSheet = EasyExcel.writerSheet("登记明细导出数据").head(headList).build();
+                        excelWriter.write(datalist, writeSheet);
+                        excelWriter.finish();
+                        File file = new File(fileName);
+                        inputStream = new FileInputStream(file);
+                        sftp.uploadMore(ftpUrl, name, inputStream);
+                        sftp.logout();
+                        inputStream.close();
+                        String absolutePath = file.getAbsolutePath();
+                        boolean delete = file.delete();
+                        log.info("删除excel【{}】结果【{}】", absolutePath, delete);
+                    }
+                    else {
+                        String firstRowContent = "登记明细";
+                        List<String> head0 = new ArrayList<>();
+                        head0.add(firstRowContent);
+                        head0.add("登记人昵称");
+                        headList.add(head0);
+                        List<String> head1 = new ArrayList<>();
+                        head1.add(firstRowContent);
+                        head1.add("登记时间");
+                        headList.add(head1);
+                        subVOList.forEach(sub -> {
+                            if (sub.getType() != 5 && sub.getType() != 11) {
+                                List<String> headn = new ArrayList<>();
+                                headn.add(firstRowContent);
+                                if(!sub.getContent().equals(noHaed)){
+                                    if(sub.getType() == 11){
+                                        headn.add(sub.getContent().substring(0, sub.getContent().indexOf("(")));
+                                    }else{
+                                        headn.add(sub.getContent());
+                                    }
+                                    headList.add(headn);
+                                }
+                            }
+                        });
+                        //数据转换
+                        datalist = AssemblyUtils.ReserveData(questnaireAnswersDTOS.getAnswers());
+                        WriteCellStyle headWriteCellStyle = new WriteCellStyle();
+                        //设置头居中
+                        headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
+                        //设置头字体
+                        WriteFont headWriteFont = new WriteFont();
+                        headWriteFont.setFontHeightInPoints((short)5);
+                        headWriteFont.setBold(true);
+                        headWriteCellStyle.setWriteFont(headWriteFont);
+
+
+                        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
+                        //设置表格内容字体
+                        WriteFont writeFont = new WriteFont();
+                        writeFont.setFontHeightInPoints((short)5);
+                        //设置 水平居中
+                        contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
+                        //设置 垂直居中
+                        contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+                        contentWriteCellStyle.setWriteFont(writeFont);
+
+                        contentWriteCellStyle.setWrapped(true);
+                        HorizontalCellStyleStrategy horizontalCellStyleStrategy =
+                                new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
+
+
+                        excelWriter = EasyExcel.write(fileName)
+                                .registerWriteHandler(horizontalCellStyleStrategy).registerWriteHandler(new Custemhandler())
+                                .build();
+                        WriteSheet writeSheet = EasyExcel.writerSheet("登记明细导出数据").head(headList).build();
+                        excelWriter.write(datalist, writeSheet);
+                        excelWriter.finish();
+                        File file = new File(fileName);
+                        inputStream = new FileInputStream(file);
+                        sftp.uploadMore(ftpUrl, name, inputStream);
+                        sftp.logout();
+                        inputStream.close();
+                        String absolutePath = file.getAbsolutePath();
+                        boolean delete = file.delete();
+                        log.info("删除excel【{}】结果【{}】", absolutePath, delete);
+                    }
+
+
+
+                } finally {
+                    // 千万别忘记finish 会帮忙关闭流
+                    if (inputStream != null) {
+                        inputStream.close();
+                    }
+                    if (excelWriter != null) {
+                        excelWriter.finish();
+                    }
+                }
+            }
+            return R.ok(sftpConfig.getExcelUrl() + name);
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("文件传输失败【{}】", e.getMessage());
+            return R.fail();
+        }
+    }
+
+    @ApiOperation(value = "导出登记明细")
+    @PostMapping("/register/list/export/homeQuarantine")
+    public R exportRegisterHomeQuarantine(@RequestBody PageReserveRegisterDetailedAdminDTO pageReserveRegisterDetailedAdminDTO) {
 
         String ftpUrl = "/mnt/data/web/excel/";
         String name = "登记明细导出数据.xlsx";
@@ -492,7 +682,7 @@
                     List<ComActQuestnaireSubVO> subVOList = questnaireAnswersDTOS.getSubs();
                     //构造表头
                     List<List<String>> headList = new ArrayList<List<String>>();
-                    String firstRowContent = "登记明细";
+                    String firstRowContent = "重点地区或高风险地区来攀返攀人员信息统计表(居家隔离表)";
                     List<String> head0 = new ArrayList<>();
                     head0.add(firstRowContent);
                     head0.add("登记人昵称");
@@ -502,7 +692,7 @@
                     head1.add("登记时间");
                     headList.add(head1);
                     subVOList.forEach(sub -> {
-                        if (sub.getType() != 5 && sub.getType() != 11) {
+                        if (sub.getType() != 5 && sub.getType() != 11&&!sub.getContent().contains("今日上午")&&!sub.getContent().contains("今日下午")&&!sub.getContent().contains("今日隔离情况")) {
                             List<String> headn = new ArrayList<>();
                             headn.add(firstRowContent);
                             if(!sub.getContent().equals(noHaed)){
@@ -515,8 +705,12 @@
                             }
                         }
                     });
+                    List<String> head2 = new ArrayList<>();
+                    head2.add(firstRowContent);
+                    head2.add("隔离体温情况");
+                    headList.add(head2);
                     //数据转换
-                    List<List<Object>> datalist = AssemblyUtils.ReserveData(questnaireAnswersDTOS.getAnswers());
+                    List<List<Object>> datalist = HomeQuarantineUtil.ReserveData(questnaireAnswersDTOS.getAnswers());
 
                     WriteCellStyle headWriteCellStyle = new WriteCellStyle();
                     //设置头居中
@@ -545,7 +739,7 @@
 
                     excelWriter = EasyExcel.write(fileName)
                             .registerWriteHandler(horizontalCellStyleStrategy).registerWriteHandler(new Custemhandler())
-                            .registerWriteHandler(new CustomSheetWriteHandler()).build();
+                            .build();
                     WriteSheet writeSheet = EasyExcel.writerSheet("登记明细导出数据").head(headList).build();
                     excelWriter.write(datalist, writeSheet);
                     excelWriter.finish();
diff --git a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/excel/CustemSecondhandler.java b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/excel/CustemSecondhandler.java
new file mode 100644
index 0000000..021592d
--- /dev/null
+++ b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/excel/CustemSecondhandler.java
@@ -0,0 +1,73 @@
+package com.panzhihua.community_backstage.excel;
+
+import com.alibaba.excel.enums.CellDataTypeEnum;
+import com.alibaba.excel.metadata.CellData;
+import com.alibaba.excel.metadata.Head;
+import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
+import com.alibaba.excel.write.style.column.AbstractColumnWidthStyleStrategy;
+import org.apache.poi.ss.usermodel.Cell;
+import org.springframework.util.CollectionUtils;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class CustemSecondhandler extends AbstractColumnWidthStyleStrategy {
+
+    private  Map<Integer, Map<Integer, Integer>> CACHE = new HashMap(8);
+
+    public CustemSecondhandler() {
+    }
+
+    @Override
+    protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List<CellData> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
+        boolean needSetWidth = isHead || !CollectionUtils.isEmpty(cellDataList);
+        if (needSetWidth) {
+            Map<Integer, Integer> maxColumnWidthMap = (Map)CACHE.get(writeSheetHolder.getSheetNo());
+            if (maxColumnWidthMap == null) {
+                maxColumnWidthMap = new HashMap(16);
+                CACHE.put(writeSheetHolder.getSheetNo(), maxColumnWidthMap);
+            }
+
+            Integer columnWidth = this.dataLength(cellDataList, cell, isHead);
+            if (columnWidth >= 0) {
+                if (columnWidth > 25) {
+                    columnWidth = 25;
+                }
+
+                Integer maxColumnWidth = (Integer)((Map)maxColumnWidthMap).get(cell.getColumnIndex());
+                if (maxColumnWidth == null || columnWidth > maxColumnWidth) {
+                    ((Map)maxColumnWidthMap).put(cell.getColumnIndex(), columnWidth);
+                    writeSheetHolder.getSheet().setColumnWidth(cell.getColumnIndex(), columnWidth * 75);
+                }
+                if(cell.getStringCellValue().equals("隔离体温情况")){
+                    writeSheetHolder.getSheet().setColumnWidth(cell.getColumnIndex(),70*75);
+                }
+
+            }
+        }
+    }
+
+    private Integer dataLength(List<CellData> cellDataList, Cell cell, Boolean isHead) {
+        if (isHead) {
+            return cell.getStringCellValue().getBytes().length;
+        } else {
+            CellData cellData = cellDataList.get(0);
+            CellDataTypeEnum type = cellData.getType();
+            if (type == null) {
+                return -1;
+            } else {
+                switch(type) {
+                    case STRING:
+                        return cellData.getStringValue().getBytes().length;
+                    case BOOLEAN:
+                        return cellData.getBooleanValue().toString().getBytes().length;
+                    case NUMBER:
+                        return cellData.getNumberValue().toString().getBytes().length;
+                    default:
+                        return -1;
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/excel/Custemhandler.java b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/excel/Custemhandler.java
index 2076a94..1ca545d 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/excel/Custemhandler.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/excel/Custemhandler.java
@@ -33,8 +33,8 @@
 
             Integer columnWidth = this.dataLength(cellDataList, cell, isHead);
             if (columnWidth >= 0) {
-                if (columnWidth > 25) {
-                    columnWidth = 25;
+                if (columnWidth > 20) {
+                    columnWidth = 20;
                 }
 
                 Integer maxColumnWidth = (Integer)((Map)maxColumnWidthMap).get(cell.getColumnIndex());
@@ -42,6 +42,9 @@
                     ((Map)maxColumnWidthMap).put(cell.getColumnIndex(), columnWidth);
                     writeSheetHolder.getSheet().setColumnWidth(cell.getColumnIndex(), columnWidth * 75);
                 }
+                if(cell.getStringCellValue().equals("有无")){
+                    writeSheetHolder.getSheet().setColumnWidth(cell.getColumnIndex(),30*75);
+                }
 
             }
         }
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActReserveAnswerContentMapper.xml b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActReserveAnswerContentMapper.xml
index b7b990b..6602f07 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActReserveAnswerContentMapper.xml
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActReserveAnswerContentMapper.xml
@@ -64,7 +64,7 @@
         <if test="detailedAdminDTO.keyword!=null and detailedAdminDTO.keyword != &quot;&quot;">
             AND carac.answer_content like concat ('%',#{detailedAdminDTO.keyword},'%')
         </if>
-        group by carr.id
+        group by carr.id order by carr.id desc
     </select>
 
     <select id="getRegisterDetailedAnswerList" resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveRegisterDetailedAnswerVO">
@@ -136,6 +136,6 @@
         </if>
         )
         GROUP BY ac.id ) ac left join sys_user t on ac.user_id = t.user_id
-        order by ac.reserve_record_id asc,ac.id asc
+        order by ac.reserve_record_id desc,ac.id asc
     </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.7.1