101captain
2022-03-14 148e0b4c914b9be4cd7ddfc24047dc50240c1efa
Merge branch 'hemenkou_dev' into dev
1个文件已添加
1个文件已修改
98 ■■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComActActSignExcelNewVO.java 44 ●●●●● 补丁 | 查看 | 原始文档 | 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/ComActActSignExcelNewVO.java
New file
@@ -0,0 +1,44 @@
package com.panzhihua.common.model.vos.community;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.util.Date;
/**
 * title: ComActActSignExcelVO  社区活动报名名单
 * projectName 成都呐喊信息技术有限公司-智慧社区项目
 * description: 记录和展示社区活动报名名单
 *
 * @author txb
 * @date 2021/8/24 10:21
 */
@Data
@ApiModel("社区活动签到表")
public class ComActActSignExcelNewVO {
    @ExcelProperty(value = "姓名", index = 1)
    private String name;
    @ExcelProperty(value = "身份", index = 2)
    private String identity;
    @ExcelProperty(value = "电话", index = 3)
    private String phone;
    @ExcelProperty(value = "报名时间", index = 0)
    private Date createAt;
    @ExcelProperty(value = "报名状态",index = 4)
    private String status;
    @ExcelProperty(value = "取消原因", index = 5)
    private String reason;
    @ExcelProperty(value = "报名次数序号", index = 6)
    private Integer times;
}
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/CommunityActivityApi.java
@@ -298,6 +298,60 @@
        return R.fail("未查询到用户");
    }
    @ApiOperation(value = "excel导出-党员活动报名名单")
    @PostMapping("sign/export/new")
    public R activityExportSignNew(@RequestBody ActivitySignVO activitySignVO) {
        String name = "活动报名名单导出数据.xlsx";
        String ftpUrl = "/mnt/data/web/excel/";
        R r = communityService.getSignLists(activitySignVO);
        if (R.isOk(r)) {
            List<ComActActSignExcelVO> excelVOS =
                    JSONArray.parseArray(JSONArray.toJSONString(r.getData()), ComActActSignExcelVO.class);
            excelVOS.forEach(e -> e.generateCondition());
            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, ComActActSignExcelNewVO.class)
                                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).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 = ComActActEvaluateVO.class)
    @PostMapping("evaluate/page")
    public R pageActivityEvaluates(@RequestBody ComActActEvaluateVO comActActEvaluateVO) {