diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/AgencyInfoDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/AgencyInfoDTO.java new file mode 100644 index 0000000000..04d4896995 --- /dev/null +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/AgencyInfoDTO.java @@ -0,0 +1,20 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 描述一下 + * + * @author yinzuomei@elink-cn.com + * @date 2021/2/27 17:52 + */ +@Data +public class AgencyInfoDTO implements Serializable { + private String agencyId; + private String areaCode; + private List subAgencyIds; + private List subGridIds; +} diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/plugins/form/WorkRecordRankFormDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/plugins/form/WorkRecordRankFormDTO.java index 3bbcb2973b..a4e5e0b9f4 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/plugins/form/WorkRecordRankFormDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/plugins/form/WorkRecordRankFormDTO.java @@ -35,4 +35,7 @@ public class WorkRecordRankFormDTO implements Serializable { @NotBlank(message = "customerId不能为空") private String customerId; + + @NotBlank(message = "areaCode不能为空,目前只有平阴在传,默认赋值:370124") + private String areaCode; } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java index d0a4f459a6..498f57309c 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java @@ -151,4 +151,6 @@ public interface ScreenCustomerAgencyDao { List selectGridList(@Param("areaCode") String areaCode,@Param("agencyId") String agencyId); List getNextAgencyIds(@Param("areaCode")String areaCode,@Param("agencyId")String agencyId); + + List selectSubAgencyIds(@Param("areaCode")String areaCode,@Param("agencyId")String agencyId); } \ No newline at end of file diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerGridDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerGridDao.java index a024d60791..e0484794e6 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerGridDao.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerGridDao.java @@ -80,5 +80,6 @@ public interface ScreenCustomerGridDao { * @date 2020/8/26 5:29 下午 */ List selectGridInfo(@Param("agencyId")String agencyId); - + + List selectSubGridIds(@Param("areaCode")String areaCode, @Param("agencyId")String agencyId); } \ No newline at end of file diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/plugins/ScreenWorkRecordOrgDailyDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/plugins/ScreenWorkRecordOrgDailyDao.java index a8aee6c4ed..d88c5627b2 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/plugins/ScreenWorkRecordOrgDailyDao.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/plugins/ScreenWorkRecordOrgDailyDao.java @@ -35,23 +35,26 @@ import java.util.List; @Mapper public interface ScreenWorkRecordOrgDailyDao extends BaseDao { /** - * @param areaCode 当前组织对应的areaCode; - * @param dataType - * @param topRow * @return com.epmet.plugins.result.WorkRecordRankResultDTO * @author yinzuomei * @description 5、【工作日志】本机及下级排名 * @Date 2021/2/23 23:37 **/ - List selectSubList(@Param("areaCode") String areaCode, - @Param("agencyId") String agencyId, - @Param("dataType") String dataType, - @Param("topRow") Integer topRow, + List selectSubList(@Param("subAgencyIds") List subAgencyIds, + // @Param("subGridIds")List subGridIds, + @Param("dataType")String dataType, + @Param("customerId")String customerId, @Param("dateId")String dateId); - String selectLatestDateId(String customerId); + List selectSubGridList(@Param("subGridIds")List subGridIds, + @Param("dataType")String dataType, + @Param("customerId")String customerId, + @Param("dateId")String dateId); - List selectCurrentAgency(@Param("areaCode") String areaCode, + String selectLatestDateId(@Param("customerIds")List customerIds); + + WorkRecordRankResultDTO selectCurrentAgency(@Param("areaCode") String areaCode, @Param("dataType") String dataType, @Param("dateId")String dateId); + } \ No newline at end of file diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/AgencyService.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/AgencyService.java index f637a0e942..4f11f160ab 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/AgencyService.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/AgencyService.java @@ -1,5 +1,6 @@ package com.epmet.datareport.service.evaluationindex.screen; +import com.epmet.dto.AgencyInfoDTO; import com.epmet.dto.form.AddAreaCodeDictFormDTO; import com.epmet.dto.form.AreaCodeDictFormDTO; import com.epmet.dto.result.AreaCodeDictResultDTO; @@ -70,4 +71,6 @@ public interface AgencyService { * @Date 2021/2/25 16:52 **/ List getNextAgencyIds(String areaCode,String agencyId); + + AgencyInfoDTO getAgencyInfoDTO(String areaCode, String agencyId); } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java index 9731353c92..bf3f8dbdcc 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java @@ -10,6 +10,7 @@ import com.epmet.constant.DataSourceConstant; import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerAgencyDao; import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerGridDao; import com.epmet.datareport.service.evaluationindex.screen.AgencyService; +import com.epmet.dto.AgencyInfoDTO; import com.epmet.dto.form.AddAreaCodeDictFormDTO; import com.epmet.dto.form.AreaCodeDictFormDTO; import com.epmet.dto.result.AreaCodeDictResultDTO; @@ -310,4 +311,15 @@ public class AgencyServiceImpl implements AgencyService { public List getNextAgencyIds(String areaCode,String agencyId) { return screenCustomerAgencyDao.getNextAgencyIds(areaCode,agencyId); } + + @DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true) + @Override + public AgencyInfoDTO getAgencyInfoDTO(String areaCode, String agencyId) { + AgencyInfoDTO agencyInfoDTO=new AgencyInfoDTO(); + agencyInfoDTO.setAgencyId(agencyId); + agencyInfoDTO.setAreaCode(areaCode); + agencyInfoDTO.setSubAgencyIds(screenCustomerAgencyDao.selectSubAgencyIds(areaCode,agencyId)); + agencyInfoDTO.setSubGridIds(screenCustomerGridDao.selectSubGridIds(areaCode,agencyId)); + return agencyInfoDTO; + } } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/plugins/impl/ScreenWorkRecordOrgDailyServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/plugins/impl/ScreenWorkRecordOrgDailyServiceImpl.java index 3b3f424ed2..6b8d0ca44f 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/plugins/impl/ScreenWorkRecordOrgDailyServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/plugins/impl/ScreenWorkRecordOrgDailyServiceImpl.java @@ -26,6 +26,7 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; import com.epmet.constant.DataSourceConstant; import com.epmet.datareport.dao.plugins.ScreenCustomerWorkRecordDictDao; import com.epmet.datareport.dao.plugins.ScreenWorkRecordOrgDailyDao; @@ -34,18 +35,20 @@ import com.epmet.datareport.entity.plugins.ScreenWorkRecordOrgDailyEntity; import com.epmet.datareport.service.evaluationindex.screen.AgencyService; import com.epmet.datareport.service.plugins.ScreenWorkRecordOrgDailyService; import com.epmet.datareport.utils.DateUtils; -import com.epmet.dto.result.ScreenCustomerAgencyDTO; +import com.epmet.dto.AgencyInfoDTO; +import com.epmet.feign.OperCrmOpenFeignClient; import com.epmet.plugins.ScreenWorkRecordOrgDailyDTO; import com.epmet.plugins.form.WorkRecordRankFormDTO; import com.epmet.plugins.form.WorkRecordTrendFormDTO; import com.epmet.plugins.result.WorkRecordRankResultDTO; +import com.epmet.plugins.result.WorkRecordSubRank; import com.epmet.plugins.result.WorkRecordTrendResultDTO; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; 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.time.LocalDate; import java.time.format.DateTimeFormatter; @@ -71,7 +74,8 @@ public class ScreenWorkRecordOrgDailyServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( @@ -124,30 +128,46 @@ public class ScreenWorkRecordOrgDailyServiceImpl extends BaseServiceImpl customerIds=new ArrayList<>(); + Result> result=operCrmOpenFeignClient.getAllSubCustomerIds(formDTO.getCustomerId()); + if (result.success() && CollectionUtils.isNotEmpty(result.getData())) { + log.info("包含子客户"); + customerIds.add(formDTO.getCustomerId()); + customerIds.addAll(result.getData()); + } + String dateId= baseDao.selectLatestDateId(customerIds); + if(StringUtils.isBlank(dateId)){ + throw new RenException("dateId is null"); } - String dateId = baseDao.selectLatestDateId(formDTO.getCustomerId()); - log.info(String.format("最近一次上传dateId:%s", dateId)); - if (agencyDTO.getLevel().equals("community")) { - log.warn("【工作日志】本机及下级排名接口待完善"); - //todo - return new WorkRecordRankResultDTO(0, 0, new ArrayList<>()); - } else { - //非社区的 - List resultDTOList = baseDao.selectCurrentAgency(agencyDTO.getAreaCode(), formDTO.getDataType(), dateId); - if(!CollectionUtils.isEmpty(resultDTOList)){ - WorkRecordRankResultDTO resultDTO=resultDTOList.get(0); - resultDTO.setSubRankList(baseDao.selectSubList(agencyDTO.getAreaCode(), agencyDTO.getAgencyId(), formDTO.getDataType(), formDTO.getTopRow(), dateId)); - return resultDTO; - } + WorkRecordRankResultDTO returnDto = new WorkRecordRankResultDTO(); + //当前组织的自身的数据 + AgencyInfoDTO agencyInfoDTO = agencyService.getAgencyInfoDTO(formDTO.getAreaCode(), formDTO.getAgencyId()); + List subAgencyRankList = baseDao.selectSubList( + CollectionUtils.isNotEmpty(agencyInfoDTO.getSubAgencyIds()) ? agencyInfoDTO.getSubAgencyIds() : new ArrayList<>(), + formDTO.getDataType(), + formDTO.getCustomerId(), + dateId); + List subGridList = baseDao.selectSubGridList( + CollectionUtils.isNotEmpty(agencyInfoDTO.getSubGridIds()) ? agencyInfoDTO.getSubGridIds() : new ArrayList<>(), + formDTO.getDataType(), + formDTO.getCustomerId(), + dateId); + returnDto.getSubRankList().addAll(subAgencyRankList); + returnDto.getSubRankList().addAll(subGridList); + int participateUserTotal = 0; + int participateTotal = 0; + for (WorkRecordSubRank subAgency : returnDto.getSubRankList()) { + participateUserTotal += subAgency.getParticipateUserTotal(); + participateTotal += subAgency.getParticipateTotal(); } - return new WorkRecordRankResultDTO(); + returnDto.setParticipateTotal(participateTotal); + returnDto.setParticipateUserTotal(participateUserTotal); + returnDto.setSubRankList(CollectionUtils.isNotEmpty(returnDto.getSubRankList()) && returnDto.getSubRankList().size() >= formDTO.getTopRow() ? + returnDto.getSubRankList().subList(NumConstant.ZERO, formDTO.getTopRow()) : returnDto.getSubRankList()); + return returnDto; } /** diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/plugins/ScreenWorkRecordOrgDailyDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/plugins/ScreenWorkRecordOrgDailyDao.xml index d0eace34dc..e3215147f0 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/plugins/ScreenWorkRecordOrgDailyDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/plugins/ScreenWorkRecordOrgDailyDao.xml @@ -3,49 +3,92 @@ - SELECT max( m.DATE_ID ) AS maxDateId FROM screen_work_record_org_daily m WHERE m.DEL_FLAG = '0' - AND m.CUSTOMER_ID = #{customerId} + AND m.CUSTOMER_ID in + + #{customerId} + + + + + diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml index 0262675182..16b7d3d554 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml @@ -122,4 +122,19 @@ GROUP BY scg.PARENT_AGENCY_ID + \ No newline at end of file