101captain
2022-03-18 8ffd580f4b7090cff75100adbb9475f2f1331bb0
党员认证Bug修改
2个文件已修改
1个文件已添加
98 ■■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComActActRegistExcelNewVO.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComActActRegistExcelVO.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/CommunityActivityApi.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComActActRegistExcelNewVO.java
New file
@@ -0,0 +1,42 @@
package com.panzhihua.common.model.vos.community;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.util.Date;
/**
 * title: ComActActRegistExcelVO  社区活动签到表
 * projectName 成都呐喊信息技术有限公司-智慧社区项目
 * description: 记录和展示社区活动签到内容
 *
 * @author txb
 * @date 2021/8/24 10:21
 */
@Data
@ApiModel("社区活动签到表")
public class ComActActRegistExcelNewVO {
    @ExcelProperty(value = "姓名", index = 3)
    private String name;
    @ExcelProperty(value = "身份", index = 4)
    private String identity;
    @ExcelProperty(value = "电话", index = 6)
    private String phone;
    @ExcelProperty(value = "签到时间", index = 0)
    private Date startTime;
    @ExcelProperty(value = "人群标签", index = 5)
    private String tags;
    @ExcelProperty(value = "签到地点", index = 1)
    private String position;
    @ExcelProperty(value = "参加次数序号", index = 2)
    private Integer times;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComActActRegistExcelVO.java
@@ -40,6 +40,6 @@
    @ExcelProperty(value = "签到地点", index = 2)
    private String position;
    @ExcelProperty(value = "签到次数", index = 3)
    @ExcelProperty(value = "参加次数序号", index = 3)
    private Integer times;
}
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/CommunityActivityApi.java
@@ -477,6 +477,60 @@
        return R.fail("未查询到用户");
    }
    @ApiOperation(value = "excel导出-活动签到居民志愿者")
    @PostMapping("regist/export/new")
    public R activityExportRegistNew(@RequestBody ComActActRegistVO comActActRegistVO) {
        String name = "活动签到导出数据.xlsx";
        String ftpUrl = "/mnt/data/web/excel/";
        R r = communityService.getRegistLists(comActActRegistVO);
        if (R.isOk(r)) {
            List<ComActActRegistExcelNewVO> excelVOS =
                    JSONArray.parseArray(JSONArray.toJSONString(r.getData()), ComActActRegistExcelNewVO.class);
            try {
                SFTPUtil sftp = new SFTPUtil(userName, password, host, port);
                sftp.login();
                boolean existDir = sftp.isExistDir(ftpUrl + name);
                if (!existDir) {
                    String property = System.getProperty("user.dir");
                    String fileName = property + File.separator + name;
                    // 这里 需要指定写用哪个class去写
                    ExcelWriter excelWriter = null;
                    InputStream inputStream = null;
                    try {
                        excelWriter = EasyExcel.write(fileName, ComActActRegistExcelNewVO.class)
                                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                                .registerWriteHandler(new CustomSheetWriteHandler()).build();
                        WriteSheet writeSheet = EasyExcel.writerSheet("活动签到导出数据").build();
                        excelWriter.write(excelVOS, 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(excelUrl + name);
            } catch (Exception e) {
                e.printStackTrace();
                log.error("文件传输失败【{}】", e.getMessage());
                return R.fail();
            }
        }
        return R.fail("未查询到用户");
    }
    @ApiOperation(value = "社区活动数据统计", response = ComActActivityStatisticsVO.class)
    @GetMapping("statistics")
    public R activityStatistics(@RequestParam("activityId") Long activityId){