|  |  | @ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.dynamic.datasource.annotation.DataSource; | 
			
		
	
		
			
				
					|  |  |  | 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.constant.DataSourceConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.evaluationindex.extract.FactOriginProjectCategoryDailyDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.ProjectCategoryDTO; | 
			
		
	
	
		
			
				
					|  |  | @ -32,13 +33,14 @@ import com.epmet.service.Issue.IssueProjectCategoryDictService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.evaluationindex.extract.todata.FactOriginProjectCategoryDailyService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.project.ProjectService; | 
			
		
	
		
			
				
					|  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.collections4.ListUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.util.CollectionUtils; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import java.util.ArrayList; | 
			
		
	
		
			
				
					|  |  |  | import java.util.HashSet; | 
			
		
	
		
			
				
					|  |  |  | import java.util.List; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | /** | 
			
		
	
	
		
			
				
					|  |  | @ -73,26 +75,41 @@ public class FactOriginProjectCategoryDailyServiceImpl extends BaseServiceImpl<F | 
			
		
	
		
			
				
					|  |  |  |             dateString = null; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         List<ProjectCategoryDTO> projectCategoryData = projectService.getProjectCategoryData(customerId, dateString); | 
			
		
	
		
			
				
					|  |  |  |         HashSet<String> projectIdSet=new HashSet<>(); | 
			
		
	
		
			
				
					|  |  |  |         if (!CollectionUtils.isEmpty(projectCategoryData)){ | 
			
		
	
		
			
				
					|  |  |  |             projectCategoryData.forEach(data->{ | 
			
		
	
		
			
				
					|  |  |  |                 FactOriginProjectCategoryDailyEntity insertEntity = new FactOriginProjectCategoryDailyEntity(); | 
			
		
	
		
			
				
					|  |  |  |                 IssueProjectCategoryDictEntity categoryDictEntity = issueProjectCategoryDictService.getById(customerId, data.getCategoryId()); | 
			
		
	
		
			
				
					|  |  |  |                 if (categoryDictEntity == null){ | 
			
		
	
		
			
				
					|  |  |  |                     log.warn("categoryDict not found : customerId:{},categoryId:{}",customerId,data.getCategoryId()); | 
			
		
	
		
			
				
					|  |  |  |                     log.error("categoryDict not found : customerId:{},categoryId:{}",customerId,data.getCategoryId()); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 insertEntity.setProjectId(data.getProjectId()); | 
			
		
	
		
			
				
					|  |  |  |                 insertEntity.setCategoryCode(categoryDictEntity.getCategoryCode()); | 
			
		
	
		
			
				
					|  |  |  |                 insertEntity.setCategoryCode(null != categoryDictEntity ? categoryDictEntity.getCategoryCode() : StrConstant.EPMETY_STR); | 
			
		
	
		
			
				
					|  |  |  |                 insertEntity.setParentCategoryCode(categoryDictEntity.getParentCategoryCode()); | 
			
		
	
		
			
				
					|  |  |  |                 insertEntity.setCustomerId(customerId); | 
			
		
	
		
			
				
					|  |  |  |                 insertEntity.setLevel(Integer.valueOf(categoryDictEntity.getCategoryType())); | 
			
		
	
		
			
				
					|  |  |  |                 insertEntity.setCreatedTime(data.getCreatedTime()); | 
			
		
	
		
			
				
					|  |  |  |                 entities.add(insertEntity); | 
			
		
	
		
			
				
					|  |  |  |                 if (NumConstant.ZERO != count){ | 
			
		
	
		
			
				
					|  |  |  |                     projectIdSet.add(data.getProjectId()); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |             if (!CollectionUtils.isEmpty(entities)){ | 
			
		
	
		
			
				
					|  |  |  |                 // 项目分类在项目结案前,都可以修改。所以要保证将之前的分类删除
 | 
			
		
	
		
			
				
					|  |  |  |                 //1、这些项目可能之前已经有分类,先删除
 | 
			
		
	
		
			
				
					|  |  |  |                 if(!CollectionUtils.isEmpty(projectIdSet)){ | 
			
		
	
		
			
				
					|  |  |  |                     List<String> projectIdList = new ArrayList<String>(projectIdSet); | 
			
		
	
		
			
				
					|  |  |  |                     List<List<String>> partionList= ListUtils.partition(projectIdList, 100); | 
			
		
	
		
			
				
					|  |  |  |                     partionList.forEach(list->{ | 
			
		
	
		
			
				
					|  |  |  |                         baseDao.deleteByProjectIds(list); | 
			
		
	
		
			
				
					|  |  |  |                     }); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 //2、先删除后增
 | 
			
		
	
		
			
				
					|  |  |  |                 delAndInsert(customerId,dateString,entities); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description category表删除插入 | 
			
		
	
		
			
				
					|  |  |  |      * @param customerId | 
			
		
	
	
		
			
				
					|  |  | 
 |