|
|
@ -5,16 +5,21 @@ import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
|
|
|
import com.epmet.constant.PingYinConstant; |
|
|
import com.epmet.constant.ProjectConstant; |
|
|
import com.epmet.constant.ProjectConstant; |
|
|
|
|
|
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao; |
|
|
import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryGridDailyDao; |
|
|
import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryGridDailyDao; |
|
|
import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryOrgDailyDao; |
|
|
import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryOrgDailyDao; |
|
|
import com.epmet.dao.evaluationindex.screen.ScreenProjectDataDao; |
|
|
import com.epmet.dao.evaluationindex.screen.ScreenProjectDataDao; |
|
|
|
|
|
import com.epmet.dto.screen.ScreenProjectOrgDailyDTO; |
|
|
import com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO; |
|
|
import com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO; |
|
|
import com.epmet.entity.crm.CustomerRelationEntity; |
|
|
import com.epmet.entity.crm.CustomerRelationEntity; |
|
|
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryGridDailyEntity; |
|
|
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryGridDailyEntity; |
|
|
|
|
|
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryOrgDailyEntity; |
|
|
import com.epmet.service.crm.CustomerRelationService; |
|
|
import com.epmet.service.crm.CustomerRelationService; |
|
|
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryGridAndOrgDailyService; |
|
|
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryGridAndOrgDailyService; |
|
|
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryGridDailyService; |
|
|
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryGridDailyService; |
|
|
|
|
|
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryOrgDailyService; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.collections4.ListUtils; |
|
|
import org.apache.commons.collections4.ListUtils; |
|
|
@ -45,7 +50,11 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr |
|
|
@Autowired |
|
|
@Autowired |
|
|
private ScreenProjectCategoryGridDailyService gridDailyService; |
|
|
private ScreenProjectCategoryGridDailyService gridDailyService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
|
|
|
private ScreenProjectCategoryOrgDailyService orgDailyService; |
|
|
|
|
|
@Autowired |
|
|
private ScreenProjectCategoryOrgDailyDao orgDailyDao; |
|
|
private ScreenProjectCategoryOrgDailyDao orgDailyDao; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ScreenCustomerAgencyDao screenCustomerAgencyDao; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Description 分类下的项目数【grid】 |
|
|
* @Description 分类下的项目数【grid】 |
|
|
@ -110,6 +119,8 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Description 分类下的项目数【org】 |
|
|
* @Description 分类下的项目数【org】 |
|
|
|
|
|
* 项目分类来源 |
|
|
|
|
|
* 本级【直接立项】 + 下级 + 直属网格 |
|
|
* @param customerId |
|
|
* @param customerId |
|
|
* @param dateId |
|
|
* @param dateId |
|
|
* @author zxc |
|
|
* @author zxc |
|
|
@ -120,5 +131,64 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr |
|
|
List<CustomerRelationEntity> relationInfo = relationService.selectSubCustomer(customerId); |
|
|
List<CustomerRelationEntity> relationInfo = relationService.selectSubCustomer(customerId); |
|
|
List<String> customerIds = new ArrayList<>(); |
|
|
List<String> customerIds = new ArrayList<>(); |
|
|
customerIds.add(customerId); |
|
|
customerIds.add(customerId); |
|
|
|
|
|
List<GridAndOrgCategoryCountResultDTO> result = new ArrayList<>(); |
|
|
|
|
|
if (CollectionUtils.isEmpty(relationInfo)){ |
|
|
|
|
|
// one customer
|
|
|
|
|
|
List<ScreenProjectOrgDailyDTO> agencies = screenCustomerAgencyDao.selectAgencyByCustomer(customerId); |
|
|
|
|
|
List<GridAndOrgCategoryCountResultDTO> allAgencies = ConvertUtils.sourceToTarget(agencies, GridAndOrgCategoryCountResultDTO.class); |
|
|
|
|
|
result = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.FOUR, allAgencies); |
|
|
|
|
|
List<GridAndOrgCategoryCountResultDTO> closedList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.FOUR, allAgencies); |
|
|
|
|
|
result.forEach(r -> closedList.stream().filter(c -> r.getOrgId().equals(c.getOrgId()) && r.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> r.setClosedProjectTotal(c.getClosedProjectTotal()))); |
|
|
|
|
|
}else { |
|
|
|
|
|
// more customers
|
|
|
|
|
|
// 去除孔村的客户ID,孔村镇的单独查😡
|
|
|
|
|
|
List<String> subCustomerIds = relationInfo.stream().map(CustomerRelationEntity::getCustomerId).collect(Collectors.toList()); |
|
|
|
|
|
for (int i = NumConstant.ZERO; i < subCustomerIds.size(); i++) { |
|
|
|
|
|
if (subCustomerIds.get(i).equals(PingYinConstant.KONG_CUN_CUSTOMER_ID)){ |
|
|
|
|
|
customerIds.remove(i); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
List<GridAndOrgCategoryCountResultDTO> allAgencies = screenCustomerAgencyDao.selectParentSonAgency(subCustomerIds, PingYinConstant.KONG_CUN_CUSTOMER_ID); |
|
|
|
|
|
List<List<GridAndOrgCategoryCountResultDTO>> partition = ListUtils.partition(allAgencies, NumConstant.FIFTY); |
|
|
|
|
|
List<GridAndOrgCategoryCountResultDTO> allOrgCategoryList = result; |
|
|
|
|
|
partition.forEach(p -> { |
|
|
|
|
|
List<GridAndOrgCategoryCountResultDTO> allOrgList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.TWO, p); |
|
|
|
|
|
List<GridAndOrgCategoryCountResultDTO> closedOrgList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.TWO, p); |
|
|
|
|
|
allOrgList.forEach(a -> closedOrgList.stream().filter(c -> a.getOrgId().equals(c.getOrgId()) && a.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal()))); |
|
|
|
|
|
allOrgCategoryList.addAll(allOrgList); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
orgDel(customerId,dateId); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description 项目分类组织删除 |
|
|
|
|
|
* @param customerId |
|
|
|
|
|
* @param dateId |
|
|
|
|
|
* @author zxc |
|
|
|
|
|
* @date 2021/11/10 4:58 下午 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void orgDel(String customerId,String dateId){ |
|
|
|
|
|
Integer num = NumConstant.ZERO; |
|
|
|
|
|
do { |
|
|
|
|
|
num = orgDailyDao.deleteByDateIdAndCustomerId(customerId, dateId); |
|
|
|
|
|
}while (num > NumConstant.ZERO && num == NumConstant.ONE_THOUSAND); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description 项目分类组织插入 |
|
|
|
|
|
* @param needInsert |
|
|
|
|
|
* @author zxc |
|
|
|
|
|
* @date 2021/11/10 5:03 下午 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void orgInsert(List<GridAndOrgCategoryCountResultDTO> needInsert){ |
|
|
|
|
|
List<List<GridAndOrgCategoryCountResultDTO>> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED); |
|
|
|
|
|
partition.forEach(p -> { |
|
|
|
|
|
orgDailyService.insertBatch(ConvertUtils.sourceToTarget(p, ScreenProjectCategoryOrgDailyEntity.class)); |
|
|
|
|
|
log.info("插入的组织项目分类为" + JSON.toJSONString(p)); |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|