Null
2021-03-15 6eb15cf8338db833dcc00648fc80b05729b86676
bug修改
2个文件已修改
89 ■■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/CommunityConvenientApi.java 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComCvtBusinessServiceImpl.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/CommunityConvenientApi.java
@@ -1,17 +1,21 @@
package com.panzhihua.community_backstage.api;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.fastjson.JSONArray;
import com.jcraft.jsch.SftpException;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.model.dtos.community.ComCvtBusinessDTO;
import com.panzhihua.common.model.dtos.community.ComCvtServeDTO;
import com.panzhihua.common.model.dtos.community.PageComCvtBusinessDTO;
import com.panzhihua.common.model.dtos.community.PageComCvtServeDTO;
import com.panzhihua.common.model.dtos.community.*;
import com.panzhihua.common.model.dtos.user.EexcelUserDTO;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.*;
import com.panzhihua.common.service.community.CommunityService;
import com.panzhihua.common.listen.ComCvtServeExcelListen;
import com.panzhihua.common.utlis.SFTPUtil;
import com.panzhihua.community_backstage.excel.CustomSheetWriteHandler;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@@ -22,8 +26,12 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.UUID;
/**
 * @description: 社区便民服务商家接口
@@ -41,6 +49,10 @@
    @Value("${excel.convenientUrl}")
    private String excelConvenientUrl="http://panzhihua.nhys.cdnhxx.com/web/bianminfuwudaoru.xlsx";
    @Value("${excel.userurl}")
    private String excelUrl;
    // FTP 登录用户名
    @Value("${ftp.username}")
    private String userName;
@@ -160,4 +172,60 @@
        }
        return R.ok();
    }
    @ApiOperation(value = "导出" )
    @PostMapping("export")
    public R export(@RequestBody ExportUserDTO exportUserDTO){
        /*Long communityId = this.getCommunityId();
        exportUserDTO.setCommunityId(communityId);
        String url=excelUrl;
        String uuid= UUID.randomUUID().toString().replace("-","");
        String name=uuid+".xlsx";
        String ftpUrl="/mnt/data/web/excel/";
//        用户搜索了就下载搜索的用户否则下载所有用户
        R r=userService.export(exportUserDTO);
        if (R.isOk(r)) {
            List<EexcelUserDTO> eexcelUserDTOS= JSONArray.parseArray(JSONArray.toJSONString(r.getData()),EexcelUserDTO.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, EexcelUserDTO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build();
                        WriteSheet writeSheet = EasyExcel.writerSheet("模板").build();
                        excelWriter.write(eexcelUserDTOS, 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(url+name);
            } catch (Exception e) {
                e.printStackTrace();
                log.error("文件传输失败【{}】", e.getMessage());
                return R.fail();
            }
        }*/
        return R.fail("未查询到用户");
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComCvtBusinessServiceImpl.java
@@ -150,8 +150,17 @@
        }
        ComCvtBusinessVO comCvtBusinessVO = new ComCvtBusinessVO();
        BeanUtils.copyProperties(comCvtBusinessDO, comCvtBusinessVO);
        List<Long> areaIds = comCvtBusinessAreaService.getBusinessServiceAreaIds(comCvtBusinessDO.getId());
        List<ComActDO> comActDOS = comActDAO.selectBatchIds(areaIds);
        List<ComActDO> comActDOS = new ArrayList<>();
        if(comCvtBusinessDO.getAreaFlag()==1){
            comActDOS = comActDAO.selectList(new QueryWrapper<ComActDO>().lambda().eq(ComActDO::getState,0));
        }else{
            List<Long> areaIds = comCvtBusinessAreaService.getBusinessServiceAreaIds(comCvtBusinessDO.getId());
            if(!ObjectUtils.isEmpty(areaIds)){
                comActDOS = comActDAO.selectBatchIds(areaIds);
            }
        }
        if (!ObjectUtils.isEmpty(comActDOS)) {
            List<ComActVO> comActVOS = new ArrayList<>();
            comActDOS.forEach(comActDO -> {