| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -17,25 +17,20 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					package com.epmet.service.impl; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import cn.afterturn.easypoi.excel.ExcelExportUtil; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import cn.afterturn.easypoi.excel.entity.ExportParams; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.alibaba.excel.EasyExcel; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.baomidou.mybatisplus.core.toolkit.IdWorker; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.constant.NumConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.constant.StrConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.exception.ExceptionUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.exception.RenException; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.page.PageData; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.redis.common.CustomerOrgRedis; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.redis.common.CustomerStaffRedis; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.redis.common.bean.GridInfoCache; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.security.dto.TokenDto; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.utils.ConvertUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.utils.DateUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.utils.ExcelPoiUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.utils.Result; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.utils.*; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.constants.ImportTaskConstants; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dao.IcPartyActivityDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dto.IcPartyActivityDTO; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -49,7 +44,7 @@ import com.epmet.entity.IcActivityServiceRelationEntity; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.entity.IcActivityUnitRelationEntity; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.entity.IcPartyActivityEntity; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.excel.IcPartyActivityImportExcel; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.excel.IcPartyActivityImportFailedExcel; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.excel.handler.IcPartyActivityImportListener; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.feign.EpmetCommonServiceOpenFeignClient; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.feign.OssFeignClient; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.service.*; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -62,16 +57,15 @@ import org.apache.commons.fileupload.FileItemFactory; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.apache.commons.fileupload.disk.DiskFileItemFactory; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.apache.commons.lang3.StringUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.apache.http.entity.ContentType; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.apache.poi.ss.usermodel.Workbook; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.stereotype.Service; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.transaction.annotation.Transactional; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.web.multipart.MultipartFile; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.web.multipart.commons.CommonsMultipartFile; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.annotation.Resource; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.servlet.http.HttpServletResponse; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.io.IOException; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.io.OutputStream; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.nio.file.Files; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.nio.file.Path; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.*; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.concurrent.atomic.AtomicInteger; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.stream.Collectors; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -121,15 +115,17 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl<IcPartyActivityD | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            unitDTO.setAgencyId(formDTO.getAgencyId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // Map<String, String> option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            dtoList.forEach(dto -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                //联建单位ID与单位名匹配
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                List<String> unitIds = Arrays.asList(dto.getUnitId().split(StrConstant.COMMA)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                // List<String> unitNames = unitIds.stream().map(option::get).collect(Collectors.toList());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                // if(CollectionUtils.isEmpty(unitNames)){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                List<String> unitNames=icPartyUnitService.getUnitNames(unitIds); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                // }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                dto.setUnitIdList(unitIds); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                dto.setUnitName(StringUtils.join(unitNames, StrConstant.COMMA)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                dto.setUnitNameList(unitNames); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if(StringUtils.isNotBlank(dto.getUnitId())){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    //联建单位ID与单位名匹配
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    List<String> unitIds = Arrays.asList(dto.getUnitId().split(StrConstant.COMMA)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    // List<String> unitNames = unitIds.stream().map(option::get).collect(Collectors.toList());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    // if(CollectionUtils.isEmpty(unitNames)){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    List<String> unitNames=icPartyUnitService.getUnitNames(unitIds); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    // }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    dto.setUnitIdList(unitIds); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    dto.setUnitName(StringUtils.join(unitNames, StrConstant.COMMA)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    dto.setUnitNameList(unitNames); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (StringUtils.isNotEmpty(dto.getGridId())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(dto.getGridId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if (null != gridInfo) { | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -283,248 +279,6 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl<IcPartyActivityD | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        icActivityServiceRelationService.delete(id); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * 导入数据 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param tokenDto | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param response | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param file | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Param tokenDto | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Param response | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Param file | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Return | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Author zhaoqifeng | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Date 2021/11/29 11:01 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<IcPartyActivityImportFailedExcel> fileList = new ArrayList<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        ExcelImportResult<IcPartyActivityImportExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartyActivityImportExcel.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<IcPartyActivityImportExcel> failList = importResult.getFailList(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //存放错误数据行号
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (!org.springframework.util.CollectionUtils.isEmpty(failList)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            for (IcPartyActivityImportExcel entity : failList) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                //打印失败的行 和失败的信息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(entity, IcPartyActivityImportFailedExcel.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                failed.setErrorInfo(entity.getErrorMsg()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                fileList.add(failed); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<IcPartyActivityImportExcel> result = importResult.getList(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //获取服务事项
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<OptionDTO> serviceItemList = icServiceItemDictService.queryDictList(tokenDto.getCustomerId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Map<String, String> categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //获取联建单位
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        unitDTO.setAgencyId(staffInfoCache.getAgencyId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Map<String, String> option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getLabel, OptionDTO::getValue)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //1.数据校验
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Iterator<IcPartyActivityImportExcel> iterator = result.iterator(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        while (iterator.hasNext()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            IcPartyActivityImportExcel obj = iterator.next(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //单位名称校验
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (StringUtils.isBlank(obj.getUnitName())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                failed.setErrorInfo("单位名称为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                fileList.add(failed); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.warn(String.format("单位名称为空,行号->%s", obj.getRowNum())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                iterator.remove(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                List<String> unitList = Arrays.asList(obj.getUnitName().split(StrConstant.COMMA)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                unitList.forEach(unit -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if (null == option.get(unit)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        failed.setErrorInfo("单位名称不存在"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        fileList.add(failed); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        log.warn(String.format("单位名称不存在,行号->%s", obj.getRowNum())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        iterator.remove(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //服务事项校验
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (StringUtils.isBlank(obj.getServiceMatter())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                failed.setErrorInfo("服务事项为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                fileList.add(failed); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.warn(String.format("服务事项为空,行号->%s", obj.getRowNum())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                iterator.remove(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                List<String> serviceList = Arrays.asList(obj.getServiceMatter().split(StrConstant.SEMICOLON)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                serviceList.forEach(service -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if (null == categoryMap.get(service)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        failed.setErrorInfo("服务事项不存在"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        fileList.add(failed); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        log.warn(String.format("服务事项不存在,行号->%s", obj.getRowNum())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        iterator.remove(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //活动标题	活动目标	活动内容	活动时间	活动地址	活动地址经度	活动地址纬度	活动结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (StringUtils.isBlank(obj.getTitle())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                failed.setErrorInfo("活动标题为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                fileList.add(failed); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.warn(String.format("活动标题为空,行号->%s", obj.getRowNum())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                iterator.remove(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } else if (StringUtils.isBlank(obj.getTarget())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                failed.setErrorInfo("活动目标为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                fileList.add(failed); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.warn(String.format("活动目标为空,行号->%s", obj.getRowNum())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } else if (StringUtils.isBlank(obj.getContent())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                failed.setErrorInfo("活动内容为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                fileList.add(failed); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.warn(String.format("活动内容为空,行号->%s", obj.getRowNum())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } else if (StringUtils.isBlank(obj.getActivityTime())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                failed.setErrorInfo("活动时间为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                fileList.add(failed); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.warn(String.format("活动时间为空,行号->%s", obj.getRowNum())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } else if (StringUtils.isBlank(obj.getAddress())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                failed.setErrorInfo("活动地址为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                fileList.add(failed); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.warn(String.format("活动地址为空,行号->%s", obj.getRowNum())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } else if (StringUtils.isBlank(obj.getLatitude())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                failed.setErrorInfo("活动地址纬度为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                fileList.add(failed); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.warn(String.format("活动地址纬度为空,行号->%s", obj.getRowNum())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } else if (StringUtils.isBlank(obj.getLongitude())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                failed.setErrorInfo("活动地址经度为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                fileList.add(failed); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.warn(String.format("活动地址经度为空,行号->%s", obj.getRowNum())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } else if (StringUtils.isBlank(obj.getResult())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                failed.setErrorInfo("活动结果为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                fileList.add(failed); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.warn(String.format("活动结果为空,行号->%s", obj.getRowNum())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (CollectionUtils.isNotEmpty(result)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            result.forEach(item -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                IcPartyActivityEntity entity = new IcPartyActivityEntity(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                entity.setCustomerId(tokenDto.getCustomerId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                entity.setAgencyId(staffInfoCache.getAgencyId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                entity.setPids(staffInfoCache.getAgencyPIds()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                entity.setTitle(item.getTitle()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                entity.setTarget(item.getTarget()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                entity.setContent(item.getContent()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                entity.setPeopleCount(item.getPeopleCount()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                entity.setActivityTime(DateUtils.parse(item.getActivityTime(), DateUtils.DATE_TIME_PATTERN)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                entity.setAddress(item.getAddress()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                entity.setLatitude(item.getLatitude()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                entity.setLongitude(item.getLongitude()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                entity.setResult(item.getResult()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                insert(entity); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                //保存活动与单位关系
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                icActivityUnitRelationService.deleteByActivity(entity.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                AtomicInteger i = new AtomicInteger(NumConstant.ONE); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                List<IcActivityUnitRelationEntity> unitRelationList = Arrays.stream(item.getUnitName().split(StrConstant.COMMA)).map(unit -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    IcActivityUnitRelationEntity relation = new IcActivityUnitRelationEntity(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    relation.setCustomerId(entity.getCustomerId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    relation.setAgencyId(entity.getAgencyId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    relation.setPids(entity.getPids()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    relation.setActivityId(entity.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    relation.setUnitId(option.get(unit)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    relation.setSort(i.getAndIncrement()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    return relation; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                }).collect(Collectors.toList()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                icActivityUnitRelationService.insertBatch(unitRelationList); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                //保存活动与服务关系
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                icActivityServiceRelationService.deleteByActivity(entity.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                AtomicInteger j = new AtomicInteger(NumConstant.ONE); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                List<IcActivityServiceRelationEntity> serviceRelationList = Arrays.stream(item.getServiceMatter().split(StrConstant.SEMICOLON)).map(service -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    IcActivityServiceRelationEntity relation = new IcActivityServiceRelationEntity(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    relation.setCustomerId(entity.getCustomerId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    relation.setAgencyId(entity.getAgencyId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    relation.setPids(entity.getPids()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    relation.setActivityId(entity.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    relation.setServiceMatter(categoryMap.get(service)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    relation.setSort(j.getAndIncrement()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    return relation; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                }).collect(Collectors.toList()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                icActivityServiceRelationService.insertBatch(serviceRelationList); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String str = String.format("共%s条,成功导入%s条。", fileList.size() + result.size(), fileList.size() + result.size() - fileList.size()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (fileList.size() > NumConstant.ZERO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            List<Integer> numList = fileList.stream().map(IcPartyActivityImportFailedExcel::getRowNum).sorted().collect(Collectors.toList()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、")); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            log.warn(str + "第" + subList + "行未成功!"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //错误数据生成文件,修改导入任务状态
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        erroeImport(fileList, taskId, tokenDto.getUserId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private void erroeImport(List<IcPartyActivityImportFailedExcel> fileList, String importTaskId, String staffId) throws IOException { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String url = ""; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //1.有错误数据则生成错误数据存放文件传到阿里云服务
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (CollectionUtils.isNotEmpty(fileList)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的数据列表", "导入失败的数据列表"), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    IcPartyActivityImportFailedExcel.class, fileList); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // 文件名
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String resultDescFileName = UUID.randomUUID().toString().concat(".xlsx"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            FileItemFactory factory = new DiskFileItemFactory(16, null); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            OutputStream os = fileItem.getOutputStream(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Result<UploadImgResultDTO> uploadResult = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                workbook.write(os); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } catch (Exception e) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String errormsg = ExceptionUtils.getErrorStackTrace(e); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.error("【联建活动信息导入】上传错误描述文件:{}", errormsg); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } finally { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    os.close(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } catch (IOException e) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    String errormsg = ExceptionUtils.getErrorStackTrace(e); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    log.error("【联建活动信息导入】上传错误描述文件关闭输出流:{}", errormsg); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    fileItem.delete(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } catch (Exception e) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    String errormsg = ExceptionUtils.getErrorStackTrace(e); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    log.error("【联建活动信息导入】上传错误描述文件删除临时文件:{}", errormsg); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (uploadResult == null || !uploadResult.success()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.error("【联建活动信息导入】调用OSS上传结果描述文件失败"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                url = uploadResult.getData().getUrl(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //2.更新导入任务数据
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        importTaskForm.setOperatorId(staffId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_ACTIVITY); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        importTaskForm.setTaskId(importTaskId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        importTaskForm.setResultDescFilePath(url); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (CollectionUtils.isNotEmpty(fileList)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            importTaskForm.setResultDesc("联建活动导入存在错误数据"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Result result = commonServiceOpenFeignClient.finishImportTask(importTaskForm); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (!result.success()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            throw new RenException(result.getInternalMsg()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * 联建活动统计 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -656,4 +410,101 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl<IcPartyActivityD | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        formDTO.setEndTime(DateUtils.parse(end.concat(" 23:59:59"), DateUtils.DATE_TIME_PATTERN)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * 执行Excel导入 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param filePath | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param importTaskId | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param customerId | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param userId | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void execAsyncExcelImport(Path filePath, String importTaskId, String customerId, String userId) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //获取当前登录用户所属组织id
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            CustomerStaffInfoCacheResult staffInfo= SpringContextUtils.getBean(IcPartyUnitServiceImpl.class).queryCurrentStaff(customerId,userId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            IcPartyActivityImportListener listener = new IcPartyActivityImportListener(customerId,staffInfo, this); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            EasyExcel.read(filePath.toFile(), IcPartyActivityImportExcel.class, listener).headRowNumber(1).sheet(0).doRead(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Path errorDescFile = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String errorDesFileUrl = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            List<IcPartyActivityImportExcel.ErrorRow> errorRows = listener.getErrorRows(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            boolean failed = errorRows.size() > 0; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (failed) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                // 生成并上传错误文件
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    // 文件生成
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    Path errorDescDir = FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_party_activity", "import", "error_des"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    String fileName = UUID.randomUUID().toString().concat(".xlsx"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    errorDescFile = errorDescDir.resolve(fileName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    FileItemFactory factory = new DiskFileItemFactory(16, errorDescDir.toFile()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, fileName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    OutputStream os = fileItem.getOutputStream(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    EasyExcel.write(os, IcPartyActivityImportExcel.ErrorRow.class).sheet("导入失败列表").doWrite(errorRows); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    // 文件上传oss
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    Result<UploadImgResultDTO> errorDesFileUploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if (errorDesFileUploadResult.success()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        errorDesFileUrl = errorDesFileUploadResult.getData().getUrl(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } finally { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if (Files.exists(errorDescFile)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        Files.delete(errorDescFile); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            ImportTaskCommonFormDTO importFinishTaskForm = new ImportTaskCommonFormDTO(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            importFinishTaskForm.setTaskId(importTaskId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            importFinishTaskForm.setProcessStatus(failed ? ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL : ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            importFinishTaskForm.setOperatorId(userId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            importFinishTaskForm.setResultDesc(""); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            importFinishTaskForm.setResultDescFilePath(errorDesFileUrl); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Result result = commonServiceOpenFeignClient.finishImportTask(importFinishTaskForm); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (!result.success()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.error("【联建活动导入】finishImportTask失败"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } catch (Exception e) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String errorMsg = ExceptionUtils.getErrorStackTrace(e); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            log.error("【联建活动导入】出错:{}", errorMsg); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            ImportTaskCommonFormDTO importFinishTaskForm = new ImportTaskCommonFormDTO(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            importFinishTaskForm.setTaskId(importTaskId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            importFinishTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            importFinishTaskForm.setOperatorId(userId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            importFinishTaskForm.setResultDesc("导入失败"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Result result = commonServiceOpenFeignClient.finishImportTask(importFinishTaskForm); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (!result.success()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.error("【联建活动导入】导入记录状态修改为'完成'失败"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } finally { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // 删除临时文件
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (Files.exists(filePath)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    Files.delete(filePath); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } catch (IOException e) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    log.error("method exception", e); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * 批量持久化 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param entities | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void batchPersist(List<IcPartyActivityEntity> entities) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        entities.forEach(e -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String id = IdWorker.getIdStr(e); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            e.setId(id); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            baseDao.insert(e); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
					 | 
				
				 | 
				
					
  |