From e982425493b0ce56255f2603a129f1a2bea62320 Mon Sep 17 00:00:00 2001 From: zxc <954985706@qq.com> Date: Mon, 22 Jun 2020 16:53:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E5=B0=8F=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dao/org/CustomerGridDao.java | 8 ++++++++ .../service/impl/StatsGroupServiceImpl.java | 19 ++++++++++++++++++- .../service/org/CustomerGridService.java | 8 ++++++++ .../org/impl/CustomerGridServiceImpl.java | 11 +++++++++++ .../resources/mapper/org/CustomerGridDao.xml | 12 ++++++++++++ 5 files changed, 57 insertions(+), 1 deletion(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java index 4b2c3621b3..846dde48e8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java @@ -50,4 +50,12 @@ public interface CustomerGridDao extends BaseDao { * @author zxc */ List selectAgencyGridTotalCount(@Param("formDto") List formDto, @Param("dateId")String dateId); + + /** + * @Description 获取客户下某个时间点以前的网格ID + * @param customerId + * @param dateId + * @author zxc + */ + List getCustomerGridIdList(@Param("customerId") String customerId, @Param("dateId") String dateId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java index 7c2d74e34e..15ad3e0b3a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java @@ -9,6 +9,7 @@ import com.epmet.entity.stats.DimAgencyEntity; import com.epmet.entity.stats.DimGridEntity; import com.epmet.service.StatsGroupService; import com.epmet.service.group.GroupDataService; +import com.epmet.service.org.CustomerGridService; import com.epmet.service.stats.*; import com.epmet.util.DimIdGenerator; import com.epmet.util.ModuleConstant; @@ -21,6 +22,7 @@ import java.time.LocalDate; import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.*; +import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; /** @@ -44,6 +46,8 @@ public class StatsGroupServiceImpl implements StatsGroupService { private FactGroupAgencyMonthlyService factGroupAgencyMonthlyService; @Autowired private DimCustomerService dimCustomerService; + @Autowired + private CustomerGridService customerGridService; /** * @Description 统计【网格-日】 @@ -132,7 +136,20 @@ public class StatsGroupServiceImpl implements StatsGroupService { String pidByAgencyId = dimAgencyService.getPidByAgencyId(agencyId); agencyResult.setPid(StringUtils.isBlank(pidByAgencyId)?"0":pidByAgencyId); // TODO 1. 机关下有多少网格 - agencyResult.setGridTotal(allGrid.size()); + List customerGridIdList = customerGridService.getCustomerGridIdList(customerId, dateId); + AtomicReference gridSize = new AtomicReference<>(0); + if (customerGridIdList.size() != NumConstant.ZERO){ + customerGridIdList.forEach(gridId -> { + allGrid.forEach(allAgencyGrid -> { + if (gridId.equals(allAgencyGrid)){ + gridSize.updateAndGet(v -> v + NumConstant.ONE); + } + }); + }); + agencyResult.setGridTotal(gridSize.get()); + }else { + agencyResult.setGridTotal(NumConstant.ZERO); + } // TODO 2. 机关下有多少小组,只算 state = ‘approved’ List agencyGroupTotalCount = groupDataService.getAgencyGroupTotalCount(allGrid,dateId); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java index 2c7c0f523c..cd82c81628 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java @@ -23,4 +23,12 @@ public interface CustomerGridService { * @author zxc */ List selectAgencyGridTotalCount(List community, String dateId); + + /** + * @Description 获取客户下某个时间点以前的网格ID + * @param customerId + * @param dateId + * @author zxc + */ + List getCustomerGridIdList(String customerId,String dateId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java index 3e2c071400..d3e7a51087 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java @@ -34,4 +34,15 @@ public class CustomerGridServiceImpl implements CustomerGridService { public List selectAgencyGridTotalCount(List community, String dateId) { return customerGridDao.selectAgencyGridTotalCount(community,dateId); } + + /** + * @Description 获取客户下某个时间点以前的网格ID + * @param customerId + * @param dateId + * @author zxc + */ + @Override + public List getCustomerGridIdList(String customerId, String dateId) { + return customerGridDao.getCustomerGridIdList(customerId, dateId); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml index e31a36a40a..0eb2f74b45 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml @@ -34,4 +34,16 @@ AND DATE_FORMAT(CREATED_TIME,'%Y-%m-%d') #{dateId} + + + \ No newline at end of file