diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/FineExampleFormDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/FineExampleFormDTO.java index 5ed5b9fc1a..938c15bdf4 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/FineExampleFormDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/FineExampleFormDTO.java @@ -3,6 +3,7 @@ package com.epmet.evaluationindex.screen.dto.form; import lombok.Data; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.io.Serializable; /** @@ -21,4 +22,6 @@ public class FineExampleFormDTO implements Serializable { */ @NotBlank(message = "机关ID不能为空",groups = {FineExample.class}) private String agencyId; + + private String customerId; } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/PartyMemberLeadController.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/PartyMemberLeadController.java index ca1104f534..9a0d67f2b2 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/PartyMemberLeadController.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/PartyMemberLeadController.java @@ -6,10 +6,7 @@ import com.epmet.datareport.service.evaluationindex.screen.PartyMemberLeadServic import com.epmet.evaluationindex.screen.dto.form.*; import com.epmet.evaluationindex.screen.dto.result.*; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -33,7 +30,7 @@ public class PartyMemberLeadController { * @date 2020/8/20 1:56 下午 */ @PostMapping("fineexample") - public Result fineExample(@RequestBody FineExampleFormDTO fineExampleFormDTO){ + public Result fineExample(@RequestHeader("CustomerId") String customerId, @RequestBody FineExampleFormDTO fineExampleFormDTO){ ValidatorUtils.validateEntity(fineExampleFormDTO, FineExampleFormDTO.FineExample.class); return new Result().ok(partyMemberLeadService.fineExample(fineExampleFormDTO)); } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenPioneerDataDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenPioneerDataDao.java index 92177ec52c..5bc3077e85 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenPioneerDataDao.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenPioneerDataDao.java @@ -21,6 +21,8 @@ import com.epmet.evaluationindex.screen.dto.result.FineExampleResultDTO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * 党建引领-先锋模范数据 * @@ -37,5 +39,16 @@ public interface ScreenPioneerDataDao{ * @date 2020/8/20 5:22 下午 */ FineExampleResultDTO selectFineExample(@Param("agencyId")String agencyId); + + /** + * @Description 根据地区码查询先锋模范 + * @param areaCode + * @param customerId + * @param customerIds - 子级客户列表 + * @return com.epmet.evaluationindex.screen.dto.result.FineExampleResultDTO + * @author wangc + * @date 2021.02.24 15:39 + */ + FineExampleResultDTO selectFineExampleByAreaCode(@Param("areaCode")String areaCode,@Param("customerId")String customerId,@Param("list") List customerIds); } \ 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/impl/PartyMemberLeadServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/PartyMemberLeadServiceImpl.java index 941a294e49..2de292f6ea 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/PartyMemberLeadServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/PartyMemberLeadServiceImpl.java @@ -2,18 +2,22 @@ package com.epmet.datareport.service.evaluationindex.screen.impl; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; import com.epmet.constant.DataSourceConstant; import com.epmet.datareport.dao.evaluationindex.screen.*; import com.epmet.datareport.service.evaluationindex.screen.PartyMemberLeadService; import com.epmet.datareport.utils.DateUtils; import com.epmet.datareport.utils.ModuleConstant; +import com.epmet.dto.result.ScreenCustomerAgencyDTO; import com.epmet.evaluationindex.screen.constant.ScreenConstant; import com.epmet.evaluationindex.screen.dto.form.AgencyAndNumFormDTO; import com.epmet.evaluationindex.screen.dto.form.ContactMassLineChartFormDTO; import com.epmet.evaluationindex.screen.dto.form.FineExampleFormDTO; import com.epmet.evaluationindex.screen.dto.form.VolunteerServiceFormDTO; import com.epmet.evaluationindex.screen.dto.result.*; +import com.epmet.feign.OperCrmOpenFeignClient; import com.github.pagehelper.PageHelper; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -48,7 +52,10 @@ public class PartyMemberLeadServiceImpl implements PartyMemberLeadService { private DateUtils dateUtils; @Autowired private ScreenPartyUserRankDataDao screenPartyUserRankDataDao; - + @Autowired + private ScreenCustomerAgencyDao customerAgencyDao; + @Autowired + private OperCrmOpenFeignClient operCrmOpenFeignClient; /** * @Description 1、先锋模范 * @param fineExampleFormDTO @@ -58,17 +65,35 @@ public class PartyMemberLeadServiceImpl implements PartyMemberLeadService { @DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true) @Override public FineExampleResultDTO fineExample(FineExampleFormDTO fineExampleFormDTO) { - FineExampleResultDTO fineExampleResultDTO = screenPioneerDataDao.selectFineExample(fineExampleFormDTO.getAgencyId()); - if (null == fineExampleResultDTO){ - return new FineExampleResultDTO(); + String customerId = fineExampleFormDTO.getCustomerId(); + String areaCode = null; + if(StringUtils.isBlank(customerId)){ + ScreenCustomerAgencyDTO agencyInfo = customerAgencyDao.selectByAgencyId(fineExampleFormDTO.getAgencyId()); + if(null == agencyInfo) throw new RenException("未找到对应的机关"); + customerId = agencyInfo.getCustomerId(); + areaCode = agencyInfo.getAreaCode(); } - fineExampleResultDTO.setIssueRatio(this.getRatio(fineExampleResultDTO.getIssueRatioA())); - fineExampleResultDTO.setPublishIssueRatio(this.getRatio(fineExampleResultDTO.getPublishIssueRatioA())); - fineExampleResultDTO.setResolvedProjectRatio(this.getRatio(fineExampleResultDTO.getResolvedProjectRatioA())); - fineExampleResultDTO.setTopicRatio(this.getRatio(fineExampleResultDTO.getTopicRatioA())); - fineExampleResultDTO.setShiftProjectRatio(this.getRatio(fineExampleResultDTO.getShiftProjectRatioA())); - fineExampleResultDTO.setPlatJoinPartyRatio(this.getRatio(Double.valueOf(fineExampleResultDTO.getPlatJoinPartyRatio()))); - return fineExampleResultDTO; + Result> crmResponse = operCrmOpenFeignClient.getAllSubCustomerIds(customerId); + if(null == crmResponse || !crmResponse.success()){ + throw new RenException("获取子客户列表失败"); + } + List subCustomers = crmResponse.getData(); + FineExampleResultDTO fineExampleResultDTO; + if(CollectionUtils.isEmpty(subCustomers)) + fineExampleResultDTO = screenPioneerDataDao.selectFineExample(fineExampleFormDTO.getAgencyId()); + else + fineExampleResultDTO = screenPioneerDataDao.selectFineExampleByAreaCode(areaCode,customerId,subCustomers); + + if (null == fineExampleResultDTO) { + return new FineExampleResultDTO(); + } + fineExampleResultDTO.setIssueRatio(this.getRatio(fineExampleResultDTO.getIssueRatioA())); + fineExampleResultDTO.setPublishIssueRatio(this.getRatio(fineExampleResultDTO.getPublishIssueRatioA())); + fineExampleResultDTO.setResolvedProjectRatio(this.getRatio(fineExampleResultDTO.getResolvedProjectRatioA())); + fineExampleResultDTO.setTopicRatio(this.getRatio(fineExampleResultDTO.getTopicRatioA())); + fineExampleResultDTO.setShiftProjectRatio(this.getRatio(fineExampleResultDTO.getShiftProjectRatioA())); + fineExampleResultDTO.setPlatJoinPartyRatio(this.getRatio(Double.valueOf(fineExampleResultDTO.getPlatJoinPartyRatio()))); + return fineExampleResultDTO; } /** diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPioneerDataDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPioneerDataDao.xml index c1a5570113..afbddb095b 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPioneerDataDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPioneerDataDao.xml @@ -26,4 +26,39 @@ ORDER BY data_end_time DESC LIMIT 1 + + + + + +