From 0eee56cbf79bfb2f2c4942ab7fe8e00f66a4d11a Mon Sep 17 00:00:00 2001 From: zxc <954985706@qq.com> Date: Tue, 23 Jun 2020 14:08:57 +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/constant/GroupConstant.java | 4 +++ .../result/GridIdListByCustomerResultDTO.java | 25 ++++++++++++++ .../com/epmet/dao/org/CustomerGridDao.java | 3 +- .../epmet/service/group/GroupDataService.java | 3 +- .../group/impl/GroupDataServiceImpl.java | 4 +-- .../service/impl/StatsGroupServiceImpl.java | 33 +++++++++++++------ .../service/org/CustomerGridService.java | 3 +- .../org/impl/CustomerGridServiceImpl.java | 3 +- .../resources/mapper/org/CustomerGridDao.xml | 5 +-- 9 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/GridIdListByCustomerResultDTO.java diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/GroupConstant.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/GroupConstant.java index 255b463cdb..f7eccf24b1 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/GroupConstant.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/GroupConstant.java @@ -29,4 +29,8 @@ public interface GroupConstant { String CITY = "city"; String PROVINCE = "province"; + String ERRORGRIDDAILY = "groupGridDaily ==>【网格小组统计出错了... 维度:网格-日】customerId为:"; + + String ERRORAGENCYDAILY = "groupAgencyDaily ==>【网格小组统计出错了... 维度:机关-日】customerId为:"; + } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/GridIdListByCustomerResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/GridIdListByCustomerResultDTO.java new file mode 100644 index 0000000000..4c2f1033c7 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/GridIdListByCustomerResultDTO.java @@ -0,0 +1,25 @@ +package com.epmet.dto.group.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @CreateTime 2020/6/23 13:54 + */ +@Data +public class GridIdListByCustomerResultDTO implements Serializable { + + private static final long serialVersionUID = -4170349451726088582L; + + /** + * 网格ID + */ + private String GridId; + + /** + * 机关ID + */ + private String agencyId; +} 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 846dde48e8..faccf553a2 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 @@ -20,6 +20,7 @@ package com.epmet.dao.org; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.group.AgencyDTO; import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO; +import com.epmet.dto.group.result.GridIdListByCustomerResultDTO; import com.epmet.entity.org.CustomerGridEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -57,5 +58,5 @@ public interface CustomerGridDao extends BaseDao { * @param dateId * @author zxc */ - List getCustomerGridIdList(@Param("customerId") String customerId, @Param("dateId") String dateId); + 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/group/GroupDataService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/GroupDataService.java index be00cca1dd..a6d61a756e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/GroupDataService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/GroupDataService.java @@ -1,7 +1,6 @@ package com.epmet.service.group; import com.epmet.dto.group.result.*; -import com.epmet.entity.stats.DimGridEntity; import com.epmet.util.DimIdGenerator; import org.apache.ibatis.annotations.Param; @@ -18,7 +17,7 @@ public interface GroupDataService { * @param customerId * @author zxc */ - List groupGridDaily(String customerId, DimIdGenerator.DimIdBean dimIdBean, List gridsInfo); + List groupGridDaily(String customerId, DimIdGenerator.DimIdBean dimIdBean, List gridsInfo); /** * @Description 获取同级机关下网格下的小组数量 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java index 0aa22e72ec..1cdc3acdcf 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java @@ -36,7 +36,7 @@ public class GroupDataServiceImpl implements GroupDataService { * @author zxc */ @Override - public List groupGridDaily(String customerId, DimIdGenerator.DimIdBean dimTime, List gridsInfo) { + public List groupGridDaily(String customerId, DimIdGenerator.DimIdBean dimTime, List gridsInfo) { List result = new ArrayList<>(); if (gridsInfo.size() == NumConstant.ZERO){ return new ArrayList<>(); @@ -46,7 +46,7 @@ public class GroupDataServiceImpl implements GroupDataService { GroupGridDailyResultDTO dailyResult = new GroupGridDailyResultDTO(); BeanUtils.copyProperties(dimTime,dailyResult); dailyResult.setAgencyId(grid.getAgencyId()); - dailyResult.setGridId(grid.getId()); + dailyResult.setGridId(grid.getGridId()); dailyResult.setCustomerId(customerId); result.add(dailyResult); }); 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 e4447e07ba..f91f0124b4 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 @@ -1,18 +1,19 @@ package com.epmet.service.impl; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.constant.GroupConstant; import com.epmet.dto.AgencySubTreeDto; import com.epmet.dto.group.form.AgencyMonthlyFormDTO; import com.epmet.dto.group.result.*; import com.epmet.dto.stats.DimAgencyDTO; 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; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -30,6 +31,7 @@ import java.util.stream.Collectors; * @CreateTime 2020/6/16 14:14 */ @Service +@Slf4j public class StatsGroupServiceImpl implements StatsGroupService { @Autowired @@ -63,10 +65,17 @@ public class StatsGroupServiceImpl implements StatsGroupService { customerIds = dimCustomerService.selectCustomerIdPage(pageNo,pageSize); if (customerIds.size() != NumConstant.ZERO){ customerIds.forEach(customerId -> { - DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(date); - List gridsInfo = dimGridService.getGridListByCustomerId(customerId); - List resultDTOS = groupDataService.groupGridDaily(customerId,dimIdBean,gridsInfo); - factGroupGridDailyService.statisticsGroupGridDaily(resultDTOS,customerId); + try { + DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(date); + +// List gridsInfo = dimGridService.getGridListByCustomerId(customerId); + List gridsInfo = customerGridService.getCustomerGridIdList(customerId, dimIdBean.getDateId()); + + List resultDTOS = groupDataService.groupGridDaily(customerId,dimIdBean,gridsInfo); + factGroupGridDailyService.statisticsGroupGridDaily(resultDTOS,customerId); + } catch (Exception e) { + log.error(GroupConstant.ERRORGRIDDAILY+customerId,e); + } }); } @@ -87,9 +96,13 @@ public class StatsGroupServiceImpl implements StatsGroupService { if (customerIds.size() != NumConstant.ZERO){ DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(date); customerIds.forEach(customerId -> { - List customerAgencyInfos = dimAgencyService.getAgencyInfoByCustomerId(customerId); - List agencyGroupDaily = this.getAgencyGroupDaily(customerAgencyInfos, dimIdBean, customerId); - factGroupAgencyDailyService.insertGroupAgencyDaily(agencyGroupDaily,customerId); + try { + List customerAgencyInfos = dimAgencyService.getAgencyInfoByCustomerId(customerId); + List agencyGroupDaily = this.getAgencyGroupDaily(customerAgencyInfos, dimIdBean, customerId); + factGroupAgencyDailyService.insertGroupAgencyDaily(agencyGroupDaily,customerId); + } catch (Exception e) { + log.error(GroupConstant.ERRORAGENCYDAILY+customerId,e); + } }); } }while (customerIds.size() != NumConstant.ZERO && customerIds.size() == pageSize); @@ -139,12 +152,12 @@ public class StatsGroupServiceImpl implements StatsGroupService { String pidByAgencyId = dimAgencyService.getPidByAgencyId(agencyId); agencyResult.setPid(StringUtils.isBlank(pidByAgencyId)?"0":pidByAgencyId); // TODO 1. 机关下有多少网格 - List customerGridIdList = customerGridService.getCustomerGridIdList(customerId, dateId); + 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)){ + if (gridId.getGridId().equals(allAgencyGrid)){ gridSize.updateAndGet(v -> v + NumConstant.ONE); } }); 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 cd82c81628..00b46e8b75 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 @@ -2,6 +2,7 @@ package com.epmet.service.org; import com.epmet.dto.group.AgencyDTO; import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO; +import com.epmet.dto.group.result.GridIdListByCustomerResultDTO; import com.epmet.entity.org.CustomerGridEntity; import java.util.Date; @@ -30,5 +31,5 @@ public interface CustomerGridService { * @param dateId * @author zxc */ - List getCustomerGridIdList(String customerId,String dateId); + 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 d3e7a51087..fc95a3de29 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 @@ -5,6 +5,7 @@ import com.epmet.constant.DataSourceConstant; import com.epmet.dao.org.CustomerGridDao; import com.epmet.dto.group.AgencyDTO; import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO; +import com.epmet.dto.group.result.GridIdListByCustomerResultDTO; import com.epmet.entity.org.CustomerGridEntity; import com.epmet.service.org.CustomerGridService; import org.springframework.beans.factory.annotation.Autowired; @@ -42,7 +43,7 @@ public class CustomerGridServiceImpl implements CustomerGridService { * @author zxc */ @Override - public List getCustomerGridIdList(String customerId, String dateId) { + 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 0eb2f74b45..6a5253e473 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 @@ -36,9 +36,10 @@ - SELECT - id AS gridId + id AS gridId, + pid AS agencyId FROM customer_grid WHERE