diff --git a/epmet-module/data-statistical/data-statistical-server/pom.xml b/epmet-module/data-statistical/data-statistical-server/pom.xml
index 6d9b40adcd..a69f4c06b4 100644
--- a/epmet-module/data-statistical/data-statistical-server/pom.xml
+++ b/epmet-module/data-statistical/data-statistical-server/pom.xml
@@ -99,33 +99,33 @@
-
+
epmet_data_statistical_user
EpmEt-db-UsEr
-
+
epmet_gov_org_user
EpmEt-db-UsEr
-
+
epmet_gov_issue_user
EpmEt-db-UsEr
-
+
epmet_gov_project_user
EpmEt-db-UsEr
0
- 118.190.150.119
- 47379
+ 192.168.1.130
+ 6379
123456
false
@@ -140,8 +140,8 @@
false
- 10
- 20
+ 5
+ 8
10
30
@@ -198,8 +198,8 @@
true
- 10
- 30
+ 5
+ 8
10
30
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java
index 6a33c586ae..9c53f16bab 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java
@@ -1,6 +1,7 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
+import com.epmet.service.StatsDimService;
import com.epmet.service.stats.DimDateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
@@ -14,14 +15,27 @@ public class DimController {
@Autowired
private DimDateService dimDateService;
+ @Autowired
+ private StatsDimService statsDimService;
+
/**
* 初始化按日维度
* @return
*/
@PostMapping("/date/init")
- public Result initDim() {
+ public Result initDateDim() {
dimDateService.initDimDate();
return new Result();
}
+ /**
+ * 初始化网格维度
+ * @return
+ */
+ @PostMapping("/grid/init")
+ public Result initGridDim() {
+ statsDimService.initGridDim();
+ return new Result();
+ }
+
}
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
new file mode 100644
index 0000000000..ee1547a190
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.dao.org;
+
+import com.epmet.commons.mybatis.dao.BaseDao;
+import com.epmet.entity.org.CustomerGridEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 客户网格表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-03-16
+ */
+@Mapper
+public interface CustomerGridDao extends BaseDao {
+
+ /**
+ * 根据创建时间,截取时间段内的网格
+ * @param start
+ * @param end
+ * @return
+ */
+ List listGridsByCreateTime(@Param("start") Date start, @Param("end") Date end);
+}
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java
index 4a8129f98e..a2d36e2481 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java
@@ -18,9 +18,13 @@
package com.epmet.dao.stats;
import com.epmet.commons.mybatis.dao.BaseDao;
+import com.epmet.entity.org.CustomerGridEntity;
import com.epmet.entity.stats.DimGridEntity;
import org.apache.ibatis.annotations.Mapper;
+import java.util.Date;
+import java.util.List;
+
/**
* 客户网格维度
*
@@ -29,5 +33,7 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface DimGridDao extends BaseDao {
-
+
+ DimGridEntity getLastCreatedGridDimEntity();
+
}
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/org/CustomerGridEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/org/CustomerGridEntity.java
new file mode 100644
index 0000000000..6c01df7df8
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/org/CustomerGridEntity.java
@@ -0,0 +1,82 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.entity.org;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 客户网格表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-03-16
+ */
+@Data
+@EqualsAndHashCode(callSuper=false)
+@TableName("customer_grid")
+public class CustomerGridEntity extends BaseEpmetEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 客户ID
+ */
+ private String customerId;
+
+ /**
+ * 网格名称
+ */
+ private String gridName;
+
+ /**
+ * 中心位置经度
+ */
+ private String longitude;
+
+ /**
+ * 中心位置纬度
+ */
+ private String latitude;
+
+ /**
+ * 所属地区码(所属组织地区码)
+ */
+ private String areaCode;
+
+ /**
+ * 管辖区域
+ */
+ private String manageDistrict;
+
+ /**
+ * 当前网格总人数
+ */
+ private Integer totalUser;
+
+ /**
+ * 所属组织机构ID(customer_organization.id)
+ */
+ private String pid;
+
+ /**
+ * 所有上级组织ID
+ */
+ private String pids;
+}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsDimService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsDimService.java
new file mode 100644
index 0000000000..d678c16447
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsDimService.java
@@ -0,0 +1,7 @@
+package com.epmet.service;
+
+public interface StatsDimService {
+
+ void initGridDim();
+
+}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java
new file mode 100644
index 0000000000..50a83f3489
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java
@@ -0,0 +1,68 @@
+package com.epmet.service.impl;
+
+import com.epmet.commons.tools.utils.DateUtils;
+import com.epmet.entity.org.CustomerGridEntity;
+import com.epmet.entity.stats.DimGridEntity;
+import com.epmet.service.StatsDimService;
+import com.epmet.service.org.CustomerGridService;
+import com.epmet.service.stats.DimGridService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+public class StatsDimServiceImpl implements StatsDimService {
+
+ @Autowired
+ private DimGridService dimGridService;
+
+ @Autowired
+ private CustomerGridService customerGridService;
+
+ @Override
+ public void initGridDim() {
+ DimGridEntity lastCreatedGridDim = dimGridService.getLastCreatedGridDim();
+ List grids;
+ if (lastCreatedGridDim == null) {
+ // 首次初始化
+ grids = customerGridService.listGridsByCreateTime(null, null);
+ } else {
+ // 非首次初始化
+ // 结束时间边界与开始时间边界,包含开始时间不包含结束时间。结束时间可以为空,则查询从开始时间往后的所有新创建网格
+ //Date endTimeBorder = DateUtils.parse(DateUtils.format(new Date(), DateUtils.DATE_PATTERN_YYYYMMDD), DateUtils.DATE_PATTERN_YYYYMMDD);
+ Date startTimeBorder = DateUtils.parse(DateUtils.format(lastCreatedGridDim.getCreatedTime(), DateUtils.DATE_PATTERN_YYYYMMDD), DateUtils.DATE_PATTERN_YYYYMMDD);
+
+ grids = customerGridService.listGridsByCreateTime(startTimeBorder, null);
+ }
+
+ List gridDims = convertCustomerGrid2GridDim(grids);
+ dimGridService.addGridDims(gridDims);
+ }
+
+ /**
+ * 将网格信息转换成网格维度信息
+ * @param grids
+ * @return
+ */
+ private List convertCustomerGrid2GridDim(List grids) {
+ Date now = new Date();
+ return grids.stream().map(grid -> {
+ DimGridEntity dimGrid = new DimGridEntity();
+ dimGrid.setAgencyId(grid.getPid());
+ dimGrid.setAreaCode(grid.getAreaCode());
+ dimGrid.setCustomerId(grid.getCustomerId());
+ dimGrid.setGridName(grid.getGridName());
+ dimGrid.setCreatedBy("APP_USER");
+ dimGrid.setCreatedTime(now);
+ dimGrid.setDelFlag("0");
+ dimGrid.setId(grid.getId());
+ dimGrid.setRevision(0);
+ dimGrid.setUpdatedBy("APP_USER");
+ dimGrid.setUpdatedTime(now);
+ return dimGrid;
+ }).collect(Collectors.toList());
+ }
+}
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
new file mode 100644
index 0000000000..b8308aede1
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java
@@ -0,0 +1,17 @@
+package com.epmet.service.org;
+
+import com.epmet.entity.org.CustomerGridEntity;
+
+import java.util.Date;
+import java.util.List;
+
+public interface CustomerGridService {
+ /**
+ * 根据创建时间,截取时间段内的网格
+ * @param start
+ * @param end
+ * @return
+ * @Param("start") Date start, @Param("end") Date end
+ */
+ List listGridsByCreateTime(Date start, Date end);
+}
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
new file mode 100644
index 0000000000..191b074d19
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java
@@ -0,0 +1,25 @@
+package com.epmet.service.org.impl;
+
+import com.epmet.commons.dynamic.datasource.annotation.DataSource;
+import com.epmet.constant.DataSourceConstant;
+import com.epmet.dao.org.CustomerGridDao;
+import com.epmet.entity.org.CustomerGridEntity;
+import com.epmet.service.org.CustomerGridService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+
+@Service
+@DataSource(DataSourceConstant.GOV_ORG)
+public class CustomerGridServiceImpl implements CustomerGridService {
+
+ @Autowired
+ private CustomerGridDao customerGridDao;
+
+ @Override
+ public List listGridsByCreateTime(Date start, Date end) {
+ return customerGridDao.listGridsByCreateTime(start, end);
+ }
+}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java
index dbb255500b..989d20704b 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java
@@ -20,8 +20,11 @@ package com.epmet.service.stats;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.stats.DimGridDTO;
+import com.epmet.entity.org.CustomerGridEntity;
import com.epmet.entity.stats.DimGridEntity;
+import org.apache.ibatis.annotations.Param;
+import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -92,4 +95,8 @@ public interface DimGridService extends BaseService {
* @date 2020-06-16
*/
void delete(String[] ids);
+
+ DimGridEntity getLastCreatedGridDim();
+
+ void addGridDims(List gridDims);
}
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java
index 1a30850b2c..10f4dd0db2 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java
@@ -28,7 +28,6 @@ import com.epmet.dto.stats.DimGridDTO;
import com.epmet.entity.stats.DimGridEntity;
import com.epmet.service.stats.DimGridService;
import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -97,4 +96,18 @@ public class DimGridServiceImpl extends BaseServiceImpl gridDims) {
+ for (DimGridEntity gridDim : gridDims) {
+ baseDao.insert(gridDim);
+ }
+ }
+
+
}
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml
index 1fa687b8a9..4d0a2dce64 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml
@@ -61,19 +61,6 @@ spring:
baseline-on-migrate: true
baseline-version: 0
-#stats:
-# datasources:
-# - name: statsDatasource
-# driver-class-name: com.mysql.cj.jdbc.Driver
-# url: @datasource.druid.stats.url@
-# username: @datasource.druid.stats.username@
-# password: @datasource.druid.stats.password@
-# - name: orgDatasource
-# driver-class-name: com.mysql.cj.jdbc.Driver
-# url: @datasource.druid.org.url@
-# username: @datasource.druid.org.username@
-# password: @datasource.druid.org.password@
-
management:
endpoints:
web:
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
new file mode 100644
index 0000000000..54e81a8d69
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+ SELECT *
+ FROM customer_grid
+
+ DEL_FLAG = 0
+
+ AND CREATED_TIME >= #{start}
+
+
+ AND CREATED_TIME #{end}
+
+
+ ORDER BY CREATED_TIME ASC;
+
+
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml
index 6c1d1f28ca..67d130dfde 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml
@@ -3,7 +3,13 @@
-
+
+ SELECT *
+ FROM dim_grid
+ WHERE DEL_FLAG = 0
+ ORDER BY CREATED_TIME DESC
+ LIMIT 1
+
\ No newline at end of file