huanghongfa
2021-05-21 1cc8640943e9941c9051726a7906e3eba2104346
修改bug
2个文件已修改
32 ■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComCvtServeExcelListen.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComCvtServeServiceImpl.java 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComCvtServeExcelListen.java
@@ -31,7 +31,7 @@
    }
    private static final int BATCH_COUNT = 100;
    private static final int BATCH_COUNT = 5000;
    private List<ComCvtServeExcelVO> list = new ArrayList<>();
    @Override
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComCvtServeServiceImpl.java
@@ -1,5 +1,6 @@
package com.panzhihua.service_community.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -11,6 +12,7 @@
import com.panzhihua.common.model.vos.community.ComCvtBusinessCategoryServeVO;
import com.panzhihua.common.model.vos.community.ComCvtServeExcelVO;
import com.panzhihua.common.model.vos.community.ComCvtServeVO;
import com.panzhihua.common.model.vos.community.ComMngPopulationImportErrorVO;
import com.panzhihua.service_community.dao.ComCvtBusinessAreaDAO;
import com.panzhihua.service_community.dao.ComCvtBusinessDAO;
import com.panzhihua.service_community.dao.ComCvtCategoryDAO;
@@ -165,6 +167,7 @@
    @Override
    public R listSaveConvenientServeExcelVO(List<ComCvtServeExcelVO> list, Long communityId) {
        List<ComCvtServeDO> comCvtServeDOS = new ArrayList<>();
        List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>();
        List<ComCvtCategoryDO> categoryDOS = comCvtCategoryDAO.selectList(new QueryWrapper<ComCvtCategoryDO>().lambda().orderByDesc(ComCvtCategoryDO::getWeight));
        Map<String, Long> categoryMap = getCategoryMap(categoryDOS);
        List<ComCvtBusinessDO> comCvtBusinessDOS;
@@ -174,7 +177,6 @@
            comCvtBusinessDOS = comCvtBusinessDAO.selectList(new LambdaQueryWrapper<>());
        }
        Map<String, Long> businessMap = getBusinessMap(comCvtBusinessDOS);
        List<String> errorInfo = new ArrayList<>();
        int index = 2;
        for (ComCvtServeExcelVO comCvtServeExcelVO:list) {
            /**
@@ -189,27 +191,39 @@
                if(!checkRepeat(comCvtServeDO)){
                    comCvtServeDOS.add(comCvtServeDO);
                }else{
                    ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO();
                    importErrorVO.setErrorMsg(String.format("导入失败:商家【%s】下已有服务【%s】",comCvtServeExcelVO.getBusinessName(),comCvtServeExcelVO.getServiceName()));
                    importErrorVO.setErrorPosition("第" + index + "行");
                    populationImportErrorVOList.add(importErrorVO);
                    log.error(String.format("导入失败:商家【%s】下已有服务【%s】",comCvtServeExcelVO.getBusinessName(),comCvtServeExcelVO.getServiceName()));
                }
            }else{
                if(!categoryMap.containsKey(comCvtServeExcelVO.getCategoryName())) {
                    errorInfo.add(comCvtServeExcelVO.getCategoryName() +"导入失败: 服务分类不存在");
                    ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO();
                    importErrorVO.setErrorMsg("导入失败: 服务分类" + comCvtServeExcelVO.getCategoryName() +"不存在");
                    importErrorVO.setErrorPosition("第" + index + "行,第1列");
                    populationImportErrorVOList.add(importErrorVO);
//                    errorInfo.add(comCvtServeExcelVO.getCategoryName() +"导入失败: 服务分类不存在");
                }
                if(!businessMap.containsKey(comCvtServeExcelVO.getBusinessName())) {
                    errorInfo.add(comCvtServeExcelVO.getBusinessName() +"导入失败: 便民服务商家不存在");
                    ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO();
                    importErrorVO.setErrorMsg("导入失败: 便民服务商家" + comCvtServeExcelVO.getBusinessName() +"不存在");
                    importErrorVO.setErrorPosition("第" + index + "行,第5列");
                    populationImportErrorVOList.add(importErrorVO);
                }
            }
            index++;
        }
        boolean saveBatched = this.saveBatch(comCvtServeDOS);
        if(saveBatched) {
            if (comCvtServeDOS.size()>0 && errorInfo != null && errorInfo.size() > 0) {
                return R.fail("导入部分成功:" + errorInfo.toString());
            if (comCvtServeDOS.size()>0 && populationImportErrorVOList.size() > 0) {
                return R.fail(populationImportErrorVOList.toString());
            }
            if(comCvtServeDOS.size()==0  && errorInfo != null && errorInfo.size() > 0){
                return R.fail("导入失败:" + errorInfo.toString());
            if(comCvtServeDOS.size()==0 && populationImportErrorVOList.size() > 0){
                return R.fail(JSON.toJSONString(populationImportErrorVOList));
            }
        }else {
            return R.fail("导入失败:" + errorInfo.toString());
            return R.fail(JSON.toJSONString(populationImportErrorVOList));
        }
        return R.ok("共计导入服务数量:"+comCvtServeDOS.size());
    }