Browse Source

Merge remote-tracking branch 'origin/dev_bugfix_ljj' into dev

master
yinzuomei 4 years ago
parent
commit
30e8711868
  1. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectCategoryDailyDao.java
  2. 23
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginProjectCategoryDailyServiceImpl.java
  3. 12
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectCategoryDailyDao.xml

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectCategoryDailyDao.java

@ -51,4 +51,6 @@ public interface FactOriginProjectCategoryDailyDao extends BaseDao<FactOriginPro
* @date 2021/4/13 下午4:36 * @date 2021/4/13 下午4:36
*/ */
List<ScreenProjectCategoryGridDailyDTO> selectListProjectCategoryByOrg(@Param("orgIds")List<String> orgIds,@Param("customerId") String customerId); List<ScreenProjectCategoryGridDailyDTO> selectListProjectCategoryByOrg(@Param("orgIds")List<String> orgIds,@Param("customerId") String customerId);
int deleteByProjectIds(@Param("list") List<String> list);
} }

23
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginProjectCategoryDailyServiceImpl.java

@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.constant.DataSourceConstant; import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.evaluationindex.extract.FactOriginProjectCategoryDailyDao; import com.epmet.dao.evaluationindex.extract.FactOriginProjectCategoryDailyDao;
import com.epmet.dto.ProjectCategoryDTO; 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.evaluationindex.extract.todata.FactOriginProjectCategoryDailyService;
import com.epmet.service.project.ProjectService; import com.epmet.service.project.ProjectService;
import lombok.extern.slf4j.Slf4j; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
/** /**
@ -73,26 +75,41 @@ public class FactOriginProjectCategoryDailyServiceImpl extends BaseServiceImpl<F
dateString = null; dateString = null;
} }
List<ProjectCategoryDTO> projectCategoryData = projectService.getProjectCategoryData(customerId, dateString); List<ProjectCategoryDTO> projectCategoryData = projectService.getProjectCategoryData(customerId, dateString);
HashSet<String> projectIdSet=new HashSet<>();
if (!CollectionUtils.isEmpty(projectCategoryData)){ if (!CollectionUtils.isEmpty(projectCategoryData)){
projectCategoryData.forEach(data->{ projectCategoryData.forEach(data->{
FactOriginProjectCategoryDailyEntity insertEntity = new FactOriginProjectCategoryDailyEntity(); FactOriginProjectCategoryDailyEntity insertEntity = new FactOriginProjectCategoryDailyEntity();
IssueProjectCategoryDictEntity categoryDictEntity = issueProjectCategoryDictService.getById(customerId, data.getCategoryId()); IssueProjectCategoryDictEntity categoryDictEntity = issueProjectCategoryDictService.getById(customerId, data.getCategoryId());
if (categoryDictEntity == null){ 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.setProjectId(data.getProjectId());
insertEntity.setCategoryCode(categoryDictEntity.getCategoryCode()); insertEntity.setCategoryCode(null != categoryDictEntity ? categoryDictEntity.getCategoryCode() : StrConstant.EPMETY_STR);
insertEntity.setParentCategoryCode(categoryDictEntity.getParentCategoryCode()); insertEntity.setParentCategoryCode(categoryDictEntity.getParentCategoryCode());
insertEntity.setCustomerId(customerId); insertEntity.setCustomerId(customerId);
insertEntity.setLevel(Integer.valueOf(categoryDictEntity.getCategoryType())); insertEntity.setLevel(Integer.valueOf(categoryDictEntity.getCategoryType()));
insertEntity.setCreatedTime(data.getCreatedTime()); insertEntity.setCreatedTime(data.getCreatedTime());
entities.add(insertEntity); entities.add(insertEntity);
if (NumConstant.ZERO != count){
projectIdSet.add(data.getProjectId());
}
}); });
if (!CollectionUtils.isEmpty(entities)){ 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); delAndInsert(customerId,dateString,entities);
} }
} }
} }
/** /**
* @Description category表删除插入 * @Description category表删除插入
* @param customerId * @param customerId

12
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectCategoryDailyDao.xml

@ -14,6 +14,18 @@
</if> </if>
</delete> </delete>
<delete id="deleteByProjectIds" parameterType="map">
DELETE
FROM
fact_origin_project_category_daily
WHERE del_flag='0'
<if test="list != null and list.size() > 0">
AND PROJECT_ID in
<foreach item="projectId" collection="list" open="(" separator="," close=")">
#{projectId}
</foreach>
</if>
</delete>
<!-- 计算当前客户下,各个网格内,各项目分类下项目数量 --> <!-- 计算当前客户下,各个网格内,各项目分类下项目数量 -->
<!-- 先算出二级分类的 + 一级分类 --> <!-- 先算出二级分类的 + 一级分类 -->
<select id="selectListProjectCategoryGridDailyDTO" parameterType="map" resultType="com.epmet.dto.screen.ScreenProjectCategoryGridDailyDTO"> <select id="selectListProjectCategoryGridDailyDTO" parameterType="map" resultType="com.epmet.dto.screen.ScreenProjectCategoryGridDailyDTO">

Loading…
Cancel
Save