|
|
@ -17,13 +17,27 @@ |
|
|
|
|
|
|
|
package com.epmet.service.evaluationindex.extract.todata.impl; |
|
|
|
|
|
|
|
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.constant.DataSourceConstant; |
|
|
|
import com.epmet.dao.evaluationindex.extract.FactOriginProjectCategoryDailyDao; |
|
|
|
import com.epmet.dto.ProjectCategoryDTO; |
|
|
|
import com.epmet.dto.extract.form.ExtractOriginFormDTO; |
|
|
|
import com.epmet.entity.evaluationindex.extract.FactOriginProjectCategoryDailyEntity; |
|
|
|
import com.epmet.entity.issue.IssueProjectCategoryDictEntity; |
|
|
|
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.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.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* 项目所属分类表 |
|
|
@ -33,6 +47,62 @@ import org.springframework.stereotype.Service; |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
@DataSource(DataSourceConstant.STATS) |
|
|
|
@Slf4j |
|
|
|
public class FactOriginProjectCategoryDailyServiceImpl extends BaseServiceImpl<FactOriginProjectCategoryDailyDao, FactOriginProjectCategoryDailyEntity> implements FactOriginProjectCategoryDailyService { |
|
|
|
|
|
|
|
} |
|
|
|
@Autowired |
|
|
|
private ProjectService projectService; |
|
|
|
@Autowired |
|
|
|
private IssueProjectCategoryDictService issueProjectCategoryDictService; |
|
|
|
/** |
|
|
|
* @param extractOriginFormDTO |
|
|
|
* @return void |
|
|
|
* @Description 将epmet_gov_project库中的项目分类信息(project_category)同步到统计库epmet_data_statistical |
|
|
|
* @Author liushaowen |
|
|
|
* @Date 2021/3/22 15:28 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void extractProjectCategory(ExtractOriginFormDTO extractOriginFormDTO) { |
|
|
|
String dateString = extractOriginFormDTO.getDateId(); |
|
|
|
String customerId = extractOriginFormDTO.getCustomerId(); |
|
|
|
List<FactOriginProjectCategoryDailyEntity> entities = new ArrayList<>(); |
|
|
|
Integer count = baseDao.selectCount(new QueryWrapper<FactOriginProjectCategoryDailyEntity>().eq("customer_id",customerId)); |
|
|
|
//如果count = 0 初始化该customer所有数据
|
|
|
|
if (NumConstant.ZERO == count){ |
|
|
|
dateString = null; |
|
|
|
} |
|
|
|
List<ProjectCategoryDTO> projectCategoryData = projectService.getProjectCategoryData(customerId, dateString); |
|
|
|
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()); |
|
|
|
} |
|
|
|
insertEntity.setProjectId(data.getProjectId()); |
|
|
|
insertEntity.setCategoryCode(categoryDictEntity.getCategoryCode()); |
|
|
|
insertEntity.setParentCategoryCode(categoryDictEntity.getParentCategoryCode()); |
|
|
|
insertEntity.setCustomerId(customerId); |
|
|
|
insertEntity.setLevel(Integer.valueOf(categoryDictEntity.getCategoryType())); |
|
|
|
insertEntity.setCreatedTime(data.getCreatedTime()); |
|
|
|
entities.add(insertEntity); |
|
|
|
}); |
|
|
|
if (!CollectionUtils.isEmpty(entities)){ |
|
|
|
delAndInsert(customerId,dateString,entities); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
/** |
|
|
|
* @Description category表删除插入 |
|
|
|
* @param customerId |
|
|
|
* @param dateId |
|
|
|
* @param result |
|
|
|
* @return void |
|
|
|
* @Author liushaowen |
|
|
|
* @Date 2021/3/22 17:01 |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delAndInsert(String customerId,String dateId,List<FactOriginProjectCategoryDailyEntity> result){ |
|
|
|
baseDao.deleteOldData(customerId, dateId); |
|
|
|
insertBatch(result); |
|
|
|
} |
|
|
|
} |
|
|
|