2 changed files with 0 additions and 125 deletions
			
			
		| @ -1,21 +0,0 @@ | |||||
| package com.epmet.service.evaluationindex.extract.todata; |  | ||||
| 
 |  | ||||
| import com.epmet.dto.extract.form.ExtractOriginFormDTO; |  | ||||
| 
 |  | ||||
| /** |  | ||||
|  * @Desc 业务数据抽取 - 项目节点历时 |  | ||||
|  * @Author wangc |  | ||||
|  * @DateTime 2020/9/14 5:07 下午 |  | ||||
|  */ |  | ||||
| public interface ProjectPeriodExtractService { |  | ||||
| 
 |  | ||||
|     /** |  | ||||
|      * @param param |  | ||||
|      * @return |  | ||||
|      * @Description 抽取项目节点历时逻辑 |  | ||||
|      * @author wangc |  | ||||
|      * @date 2020.09.17 14:05 |  | ||||
|      **/ |  | ||||
|     void extractProjectPeriodData(ExtractOriginFormDTO param); |  | ||||
| 
 |  | ||||
| } |  | ||||
| @ -1,104 +0,0 @@ | |||||
| package com.epmet.service.evaluationindex.extract.todata.impl; |  | ||||
| 
 |  | ||||
| import com.epmet.commons.tools.constant.NumConstant; |  | ||||
| import com.epmet.commons.tools.utils.ConvertUtils; |  | ||||
| import com.epmet.commons.tools.utils.DateUtils; |  | ||||
| import com.epmet.dao.evaluationindex.extract.FactOriginProjectOrgPeriodDailyDao; |  | ||||
| import com.epmet.dto.extract.form.ExtractOriginFormDTO; |  | ||||
| import com.epmet.dto.project.result.ProjectOrgPeriodResultDTO; |  | ||||
| import com.epmet.entity.evaluationindex.extract.FactOriginProjectOrgPeriodDailyEntity; |  | ||||
| import com.epmet.service.evaluationindex.extract.todata.ProjectPeriodExtractService; |  | ||||
| import com.epmet.service.project.ProjectProcessService; |  | ||||
| import lombok.extern.slf4j.Slf4j; |  | ||||
| import org.apache.commons.lang3.StringUtils; |  | ||||
| import org.springframework.beans.factory.annotation.Autowired; |  | ||||
| import org.springframework.stereotype.Service; |  | ||||
| import org.springframework.util.CollectionUtils; |  | ||||
| 
 |  | ||||
| import java.text.SimpleDateFormat; |  | ||||
| import java.util.Date; |  | ||||
| import java.util.LinkedList; |  | ||||
| import java.util.List; |  | ||||
| import java.util.stream.Collectors; |  | ||||
| 
 |  | ||||
| /** |  | ||||
|  * @Description 业务数据抽取 - 项目节点历时 |  | ||||
|  * @ClassName ProjectPeriodExtractServiceImpl |  | ||||
|  * @Auth wangc |  | ||||
|  * @Date 2020-09-17 13:52 |  | ||||
|  */ |  | ||||
| @Service |  | ||||
| @Slf4j |  | ||||
| public class ProjectPeriodExtractServiceImpl implements ProjectPeriodExtractService { |  | ||||
| 
 |  | ||||
|     @Autowired |  | ||||
|     private FactOriginProjectOrgPeriodDailyDao factOriginProjectOrgPeriodDailyDao; |  | ||||
|     @Autowired |  | ||||
|     private ProjectProcessService projectProcessService; |  | ||||
| 
 |  | ||||
|     /** |  | ||||
|      * @param param |  | ||||
|      * @return |  | ||||
|      * @Description 抽取项目节点历时逻辑 |  | ||||
|      * @author wangc |  | ||||
|      * @date 2020.09.17 14:05 |  | ||||
|      **/ |  | ||||
|     @Override |  | ||||
|     public void extractProjectPeriodData(ExtractOriginFormDTO param) { |  | ||||
|         int trace = factOriginProjectOrgPeriodDailyDao.selectIfExisted(param.getCustomerId()); |  | ||||
|         Boolean isFirst = trace <= NumConstant.ZERO ? true : false; |  | ||||
|         if (StringUtils.isBlank(param.getDateId())) { |  | ||||
|             Date yesterday = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24); |  | ||||
|             SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD); |  | ||||
|             param.setDateId(format.format(yesterday)); |  | ||||
|         } |  | ||||
|         List<ProjectOrgPeriodResultDTO> extractData = |  | ||||
|                 projectProcessService.getProjectPeriod(isFirst, param.getCustomerId(), param.getDateId()); |  | ||||
|         List<FactOriginProjectOrgPeriodDailyEntity> formattingData = new LinkedList<>(); |  | ||||
|         extractData.forEach(original -> { |  | ||||
|             FactOriginProjectOrgPeriodDailyEntity dest |  | ||||
|                     = ConvertUtils.sourceToTarget(original,FactOriginProjectOrgPeriodDailyEntity.class); |  | ||||
|             if(StringUtils.isNotBlank(original.getDepartmentId())){ |  | ||||
|                 dest.setOrgType("dept"); |  | ||||
|                 dest.setPid(original.getOrgId()); |  | ||||
|                 dest.setPids(original.getOrgIdPath()); |  | ||||
|             }else if(StringUtils.isNotBlank(original.getGridId())){ |  | ||||
|                 dest.setOrgType("grid"); |  | ||||
|                 dest.setPid(original.getOrgId()); |  | ||||
|                 dest.setPids(original.getOrgIdPath()); |  | ||||
|             }else{ |  | ||||
|                 dest.setOrgType("agency"); |  | ||||
|                 dest.setPids(""); |  | ||||
|                 String[] array = original.getOrgIdPath().split(":"); |  | ||||
|                 if(null == array || array.length <= NumConstant.ZERO){ |  | ||||
|                     dest.setPid(NumConstant.ZERO_STR); |  | ||||
|                 } |  | ||||
|                 if(array[NumConstant.ZERO] == original.getOrgId() && array.length == NumConstant.ONE){ |  | ||||
|                     dest.setPid(NumConstant.ZERO_STR); |  | ||||
|                 } |  | ||||
|                 if(array.length > NumConstant.ONE && original.getOrgId() == array[array.length - NumConstant.ONE]){ |  | ||||
|                     dest.setPid(array[array.length - NumConstant.TWO]); |  | ||||
|                     dest.setPids(original.getOrgIdPath().replace(original.getOrgId(),"")); |  | ||||
|                 } |  | ||||
|                 if(StringUtils.isNotBlank(dest.getPids())){ |  | ||||
|                     while(dest.getPids().endsWith(":")){ |  | ||||
|                         dest.setPids(dest.getPids().substring(NumConstant.ZERO,dest.getPids().length() - NumConstant.ONE)); |  | ||||
|                     } |  | ||||
|                     while(dest.getPids().startsWith(":")){ |  | ||||
|                         dest.setPids(dest.getPids().replaceFirst(":","")); |  | ||||
|                     } |  | ||||
|                 } |  | ||||
|                 dest.setPids(dest.getPids().replaceAll(" ","")); |  | ||||
|             } |  | ||||
| 
 |  | ||||
|             formattingData.add(dest); |  | ||||
|         }); |  | ||||
|         if(!CollectionUtils.isEmpty(formattingData)) { |  | ||||
|             List<String> projectIds = formattingData.stream().map(FactOriginProjectOrgPeriodDailyEntity::getProjectId).distinct().collect(Collectors.toList()); |  | ||||
|             if (!CollectionUtils.isEmpty(projectIds)) { |  | ||||
|                 factOriginProjectOrgPeriodDailyDao.deleteByProjectId(projectIds); |  | ||||
|                 factOriginProjectOrgPeriodDailyDao.insertBatch(formattingData); |  | ||||
|             } |  | ||||
|         } |  | ||||
|     } |  | ||||
| } |  | ||||
					Loading…
					
					
				
		Reference in new issue