6 changed files with 292 additions and 0 deletions
@ -0,0 +1,69 @@ |
|||
package com.epmet.dto.screen.result; |
|||
|
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/11/10 10:36 上午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class GridAndOrgCategoryCountResultDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -5167964547464983118L; |
|||
|
|||
/** |
|||
* 组织ID |
|||
*/ |
|||
private String orgId; |
|||
|
|||
/** |
|||
* 网格ID |
|||
*/ |
|||
private String gridId; |
|||
|
|||
/** |
|||
* 上级组织ID |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* 所有上级组织ID |
|||
*/ |
|||
private String pids; |
|||
|
|||
private String dateId; |
|||
|
|||
private String customerId; |
|||
|
|||
/** |
|||
* 分类CODE |
|||
*/ |
|||
private String categoryCode; |
|||
|
|||
/** |
|||
* 分类CODE级别 |
|||
*/ |
|||
private Integer level; |
|||
|
|||
/** |
|||
* 项目总数 |
|||
*/ |
|||
private Integer projectTotal; |
|||
|
|||
/** |
|||
* 关闭【结案】项目总数 |
|||
*/ |
|||
private Integer closedProjectTotal; |
|||
|
|||
public GridAndOrgCategoryCountResultDTO() { |
|||
this.orgId = ""; |
|||
this.categoryCode = ""; |
|||
this.level = NumConstant.ZERO; |
|||
this.projectTotal = NumConstant.ZERO; |
|||
this.closedProjectTotal = NumConstant.ZERO; |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
package com.epmet.service.evaluationindex.screen; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dto.screen.ScreenProjectCategoryOrgDailyDTO; |
|||
import com.epmet.dto.screencoll.ScreenCollFormDTO; |
|||
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryOrgDailyEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 项目(事件)分类按 组织——组织——按天统计 |
|||
*/ |
|||
public interface ScreenProjectCategoryGridAndOrgDailyService { |
|||
|
|||
/** |
|||
* @Description 分类下的项目数【grid】 |
|||
* @param customerId |
|||
* @param dateId |
|||
* @author zxc |
|||
* @date 2021/11/10 10:23 上午 |
|||
*/ |
|||
void extractCategoryProjectGridData(String customerId, String dateId); |
|||
|
|||
/** |
|||
* @Description 分类下的项目数【org】 |
|||
* @param customerId |
|||
* @param dateId |
|||
* @author zxc |
|||
* @date 2021/11/10 10:23 上午 |
|||
*/ |
|||
void extractCategoryProjectOrgData(String customerId, String dateId); |
|||
} |
|||
@ -0,0 +1,123 @@ |
|||
package com.epmet.service.evaluationindex.screen.impl; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.constant.DataSourceConstant; |
|||
import com.epmet.constant.ProjectConstant; |
|||
import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryGridDailyDao; |
|||
import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryOrgDailyDao; |
|||
import com.epmet.dao.evaluationindex.screen.ScreenProjectDataDao; |
|||
import com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO; |
|||
import com.epmet.entity.crm.CustomerRelationEntity; |
|||
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryGridDailyEntity; |
|||
import com.epmet.service.crm.CustomerRelationService; |
|||
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryGridAndOrgDailyService; |
|||
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryGridDailyService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.collections4.CollectionUtils; |
|||
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 java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/11/10 10:25 上午 |
|||
* @DESC |
|||
*/ |
|||
@Service |
|||
@DataSource(DataSourceConstant.EVALUATION_INDEX) |
|||
@Slf4j |
|||
public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenProjectCategoryGridAndOrgDailyService{ |
|||
|
|||
@Autowired |
|||
private ScreenProjectDataDao screenProjectDataDao; |
|||
@Autowired |
|||
private CustomerRelationService relationService; |
|||
@Autowired |
|||
private ScreenProjectCategoryGridDailyDao gridDailyDao; |
|||
@Autowired |
|||
private ScreenProjectCategoryGridDailyService gridDailyService; |
|||
@Autowired |
|||
private ScreenProjectCategoryOrgDailyDao orgDailyDao; |
|||
|
|||
/** |
|||
* @Description 分类下的项目数【grid】 |
|||
* @param customerId |
|||
* @param dateId |
|||
* @author zxc |
|||
* @date 2021/11/10 10:23 上午 |
|||
*/ |
|||
@Override |
|||
public void extractCategoryProjectGridData(String customerId, String dateId) { |
|||
List<CustomerRelationEntity> relationInfo = relationService.selectSubCustomer(customerId); |
|||
List<String> customerIds = new ArrayList<>(); |
|||
customerIds.add(customerId); |
|||
List<GridAndOrgCategoryCountResultDTO> allList = new ArrayList<>(); |
|||
List<GridAndOrgCategoryCountResultDTO> closedList = new ArrayList<>(); |
|||
if (CollectionUtils.isNotEmpty(relationInfo)){ |
|||
// 单客户
|
|||
allList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_ALL,customerId, NumConstant.FOUR); |
|||
closedList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_CLOSED,customerId, NumConstant.FOUR); |
|||
|
|||
}else { |
|||
// 多客户
|
|||
List<String> subCustomerIds = relationInfo.stream().map(CustomerRelationEntity::getCustomerId).collect(Collectors.toList()); |
|||
customerIds.addAll(subCustomerIds); |
|||
allList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_ALL,customerId, NumConstant.TWO); |
|||
closedList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_CLOSED,customerId, NumConstant.TWO); |
|||
} |
|||
List<GridAndOrgCategoryCountResultDTO> finalClosedList = closedList; |
|||
allList.forEach(a -> finalClosedList.stream().filter(c -> c.getOrgId().equals(a.getOrgId()) && c.getCategoryCode().equals(a.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal()))); |
|||
gridDel(customerId,dateId); |
|||
gridInsert(allList); |
|||
} |
|||
|
|||
/** |
|||
* @Description 项目分类网格删除 |
|||
* @param customerId |
|||
* @param dateId |
|||
* @author zxc |
|||
* @date 2021/11/10 1:55 下午 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void gridDel(String customerId,String dateId){ |
|||
Integer num = NumConstant.ZERO; |
|||
do { |
|||
num = gridDailyDao.deleteByDateIdAndCustomerId(customerId, dateId); |
|||
}while (num > NumConstant.ZERO && num == NumConstant.ONE_THOUSAND); |
|||
} |
|||
|
|||
/** |
|||
* @Description 项目分类网格添加 |
|||
* @param needInsert |
|||
* @author zxc |
|||
* @date 2021/11/10 1:55 下午 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void gridInsert(List<GridAndOrgCategoryCountResultDTO> needInsert){ |
|||
List<List<GridAndOrgCategoryCountResultDTO>> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED); |
|||
partition.forEach(p -> { |
|||
gridDailyService.insertBatch(ConvertUtils.sourceToTarget(p,ScreenProjectCategoryGridDailyEntity.class)); |
|||
log.info("插入的网格项目分类为" + JSON.toJSONString(p)); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* @Description 分类下的项目数【org】 |
|||
* @param customerId |
|||
* @param dateId |
|||
* @author zxc |
|||
* @date 2021/11/10 10:23 上午 |
|||
*/ |
|||
@Override |
|||
public void extractCategoryProjectOrgData(String customerId, String dateId) { |
|||
|
|||
} |
|||
} |
|||
Loading…
Reference in new issue