From 8f786ad420791b8765fbb044e281eabfc33512f6 Mon Sep 17 00:00:00 2001 From: TS-QD1 Date: Thu, 23 Mar 2023 17:57:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A4=9A=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=BA=90=EF=BC=8C=E5=A2=9E=E5=8A=A04=E3=80=815=E7=BA=A7?= =?UTF-8?q?=E7=BD=91=E6=A0=BC=E5=91=98=E6=97=A5=E9=80=9A=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 6 + .../com/cm/bigdata/BigdataApplication.java | 2 +- .../com/cm/bigdata/config/db/Db1Config.java | 87 ++++++ .../com/cm/bigdata/config/db/Db2Config.java | 87 ++++++ .../config/properties/db/Db1Properties.java | 64 ++++ .../config/properties/db/Db2Properties.java | 64 ++++ .../properties/db/DbCommonProperties.java | 127 ++++++++ .../controller/apis/kpi/KpiController.java | 28 ++ .../java/com/cm/bigdata/dao/kpi/IKpiDao.java | 19 ++ .../dao2/kpi/IBasePopulationInfoDao.java | 16 + .../bigdata/dao2/kpi/ICommunityBossDao.java | 14 + .../cm/bigdata/dao2/kpi/IUserLocationDao.java | 13 + .../com/cm/bigdata/dao2/kpi/IUserSignDao.java | 17 ++ .../pos/kpi/BasePopulationInfoCountPO.java | 23 ++ .../pojo/pos/kpi/BasePopulationInfoPO.java | 275 ++++++++++++++++++ .../pojo/pos/kpi/CommunityBossDayCountPO.java | 98 +++++++ .../bigdata/pojo/pos/kpi/CommunityBossPO.java | 107 +++++++ .../bigdata/pojo/pos/kpi/UserLocationPO.java | 89 ++++++ .../cm/bigdata/pojo/pos/kpi/UserSigninPO.java | 95 ++++++ .../bigdata/pojo/pos/kpi/UserSignoutPO.java | 98 +++++++ .../kpi/IBasePopulationInfoService.java | 16 + .../service/kpi/ICommunityBossService.java | 11 + .../cm/bigdata/service/kpi/IKpiService.java | 15 + .../service/kpi/IUserLocationService.java | 9 + .../bigdata/service/kpi/IUserSignService.java | 12 + .../impl/BasePopulationInfoServiceImpl.java | 42 +++ .../kpi/impl/CommunityBossServiceImpl.java | 25 ++ .../service/kpi/impl/KpiServiceImpl.java | 79 +++++ .../kpi/impl/UserLocationServiceImpl.java | 33 +++ .../service/kpi/impl/UserSignService.java | 35 +++ .../java/com/cm/bigdata/utils/KpiUtil.java | 118 ++++++++ src/main/resources/application.yml | 40 ++- .../db2-mapper/kpi/base-population-info.xml | 90 ++++++ .../db2-mapper/kpi/community-boss-mapper.xml | 42 +++ .../db2-mapper/kpi/user-location-mapper.xml | 42 +++ .../db2-mapper/kpi/user-sign-mapper.xml | 89 ++++++ .../mybatis/mapper/kpi/kpi-mapper.xml | 92 ++++++ 37 files changed, 2102 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/cm/bigdata/config/db/Db1Config.java create mode 100644 src/main/java/com/cm/bigdata/config/db/Db2Config.java create mode 100644 src/main/java/com/cm/bigdata/config/properties/db/Db1Properties.java create mode 100644 src/main/java/com/cm/bigdata/config/properties/db/Db2Properties.java create mode 100644 src/main/java/com/cm/bigdata/config/properties/db/DbCommonProperties.java create mode 100644 src/main/java/com/cm/bigdata/controller/apis/kpi/KpiController.java create mode 100644 src/main/java/com/cm/bigdata/dao/kpi/IKpiDao.java create mode 100644 src/main/java/com/cm/bigdata/dao2/kpi/IBasePopulationInfoDao.java create mode 100644 src/main/java/com/cm/bigdata/dao2/kpi/ICommunityBossDao.java create mode 100644 src/main/java/com/cm/bigdata/dao2/kpi/IUserLocationDao.java create mode 100644 src/main/java/com/cm/bigdata/dao2/kpi/IUserSignDao.java create mode 100644 src/main/java/com/cm/bigdata/pojo/pos/kpi/BasePopulationInfoCountPO.java create mode 100644 src/main/java/com/cm/bigdata/pojo/pos/kpi/BasePopulationInfoPO.java create mode 100644 src/main/java/com/cm/bigdata/pojo/pos/kpi/CommunityBossDayCountPO.java create mode 100644 src/main/java/com/cm/bigdata/pojo/pos/kpi/CommunityBossPO.java create mode 100644 src/main/java/com/cm/bigdata/pojo/pos/kpi/UserLocationPO.java create mode 100644 src/main/java/com/cm/bigdata/pojo/pos/kpi/UserSigninPO.java create mode 100644 src/main/java/com/cm/bigdata/pojo/pos/kpi/UserSignoutPO.java create mode 100644 src/main/java/com/cm/bigdata/service/kpi/IBasePopulationInfoService.java create mode 100644 src/main/java/com/cm/bigdata/service/kpi/ICommunityBossService.java create mode 100644 src/main/java/com/cm/bigdata/service/kpi/IKpiService.java create mode 100644 src/main/java/com/cm/bigdata/service/kpi/IUserLocationService.java create mode 100644 src/main/java/com/cm/bigdata/service/kpi/IUserSignService.java create mode 100644 src/main/java/com/cm/bigdata/service/kpi/impl/BasePopulationInfoServiceImpl.java create mode 100644 src/main/java/com/cm/bigdata/service/kpi/impl/CommunityBossServiceImpl.java create mode 100644 src/main/java/com/cm/bigdata/service/kpi/impl/KpiServiceImpl.java create mode 100644 src/main/java/com/cm/bigdata/service/kpi/impl/UserLocationServiceImpl.java create mode 100644 src/main/java/com/cm/bigdata/service/kpi/impl/UserSignService.java create mode 100644 src/main/java/com/cm/bigdata/utils/KpiUtil.java create mode 100644 src/main/resources/mybatis/db2-mapper/kpi/base-population-info.xml create mode 100644 src/main/resources/mybatis/db2-mapper/kpi/community-boss-mapper.xml create mode 100644 src/main/resources/mybatis/db2-mapper/kpi/user-location-mapper.xml create mode 100644 src/main/resources/mybatis/db2-mapper/kpi/user-sign-mapper.xml create mode 100644 src/main/resources/mybatis/mapper/kpi/kpi-mapper.xml diff --git a/pom.xml b/pom.xml index 321bf1b..36f6ee8 100644 --- a/pom.xml +++ b/pom.xml @@ -94,6 +94,12 @@ log4j 1.2.14 + + + org.projectlombok + lombok + compile + diff --git a/src/main/java/com/cm/bigdata/BigdataApplication.java b/src/main/java/com/cm/bigdata/BigdataApplication.java index ac59f18..c7db435 100644 --- a/src/main/java/com/cm/bigdata/BigdataApplication.java +++ b/src/main/java/com/cm/bigdata/BigdataApplication.java @@ -15,7 +15,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; @EnableSwagger2 @SpringBootApplication @ComponentScan("com.cm") -@MapperScan({"com.cm.**.dao"}) +//@MapperScan({"com.cm.**.dao"}) @EnableScheduling public class BigdataApplication { diff --git a/src/main/java/com/cm/bigdata/config/db/Db1Config.java b/src/main/java/com/cm/bigdata/config/db/Db1Config.java new file mode 100644 index 0000000..66bb886 --- /dev/null +++ b/src/main/java/com/cm/bigdata/config/db/Db1Config.java @@ -0,0 +1,87 @@ +package com.cm.bigdata.config.db; + +import com.alibaba.druid.pool.DruidDataSource; +import com.cm.bigdata.config.properties.db.Db1Properties; +import com.cm.bigdata.config.properties.db.DbCommonProperties; +import org.apache.ibatis.session.SqlSessionFactory; +import org.mybatis.spring.SqlSessionFactoryBean; +import org.mybatis.spring.SqlSessionTemplate; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; + +import javax.sql.DataSource; +import java.sql.SQLException; + +@Configuration +@MapperScan(basePackages = {"com.cm.**.dao"}, sqlSessionFactoryRef = "db1SqlSessionFactory") +public class Db1Config { + + @Autowired + private DbCommonProperties dbCommonProperties; + @Autowired + private Db1Properties db1Properties; + + @Bean(name = "db1DataSource") + public DataSource db1DataSource() throws SQLException { + DruidDataSource druid = new DruidDataSource(); + // 监控统计拦截的filters + druid.setFilters(dbCommonProperties.getFilters()); + + // 配置基本属性 + druid.setDriverClassName(db1Properties.getDriverClassName()); + druid.setUsername(db1Properties.getUsername()); + druid.setPassword(db1Properties.getPassword()); + druid.setUrl(db1Properties.getUrl()); + + //初始化时建立物理连接的个数 + druid.setInitialSize(dbCommonProperties.getInitialSize()); + //最大连接池数量 + druid.setMaxActive(dbCommonProperties.getMaxActive()); + //最小连接池数量 + druid.setMinIdle(dbCommonProperties.getMinIdle()); + //获取连接时最大等待时间,单位毫秒。 + druid.setMaxWait(dbCommonProperties.getMaxWait()); + //间隔多久进行一次检测,检测需要关闭的空闲连接 + druid.setTimeBetweenEvictionRunsMillis(dbCommonProperties.getTimeBetweenEvictionRunsMillis()); + //一个连接在池中最小生存的时间 + druid.setMinEvictableIdleTimeMillis(dbCommonProperties.getMinEvictableIdleTimeMillis()); + //用来检测连接是否有效的sql + druid.setValidationQuery(dbCommonProperties.getValidationQuery()); + //建议配置为true,不影响性能,并且保证安全性。 + druid.setTestWhileIdle(dbCommonProperties.isTestWhileIdle()); + //申请连接时执行validationQuery检测连接是否有效 + druid.setTestOnBorrow(dbCommonProperties.isTestOnBorrow()); + druid.setTestOnReturn(dbCommonProperties.isTestOnReturn()); + //是否缓存preparedStatement,也就是PSCache,oracle设为true,mysql设为false。分库分表较多推荐设置为false + druid.setPoolPreparedStatements(dbCommonProperties.isPoolPreparedStatements()); + // 打开PSCache时,指定每个连接上PSCache的大小 + druid.setMaxPoolPreparedStatementPerConnectionSize(dbCommonProperties.getMaxPoolPreparedStatementPerConnectionSize()); + return druid; + } + + @Bean(name = "db1TransactionManager") + @Primary + public DataSourceTransactionManager db1TransactionManager() throws SQLException { + return new DataSourceTransactionManager(db1DataSource()); + } + + @Bean(name = "db1SqlSessionFactory") + public SqlSessionFactory db1SqlSessionFactory(@Qualifier("db1DataSource") DataSource dataSource) throws Exception { + final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); + sessionFactory.setDataSource(dataSource); // 设置数据源bean + sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(db1Properties.getMapperLocations())); // 设置mapper文件路径 + return sessionFactory.getObject(); + } + + @Bean("db1SqlSessionTemplate") + public SqlSessionTemplate db1SqlSessionTemplate(@Qualifier("db1SqlSessionFactory") SqlSessionFactory sqlSessionFactory){ + return new SqlSessionTemplate(sqlSessionFactory); + } + +} diff --git a/src/main/java/com/cm/bigdata/config/db/Db2Config.java b/src/main/java/com/cm/bigdata/config/db/Db2Config.java new file mode 100644 index 0000000..52713c4 --- /dev/null +++ b/src/main/java/com/cm/bigdata/config/db/Db2Config.java @@ -0,0 +1,87 @@ +package com.cm.bigdata.config.db; + +import com.alibaba.druid.pool.DruidDataSource; +import com.cm.bigdata.config.properties.db.Db2Properties; +import com.cm.bigdata.config.properties.db.DbCommonProperties; +import org.apache.ibatis.session.SqlSessionFactory; +import org.mybatis.spring.SqlSessionFactoryBean; +import org.mybatis.spring.SqlSessionTemplate; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; + +import javax.sql.DataSource; +import java.sql.SQLException; + +@Configuration +@MapperScan(basePackages = {"com.cm.**.dao2"}, sqlSessionFactoryRef = "db2SqlSessionFactory") +public class Db2Config { + + @Autowired + private DbCommonProperties dbCommonProperties; + @Autowired + private Db2Properties db2Properties; + + @Bean(name = "db2DataSource") + public DataSource db2DataSource() throws SQLException { + DruidDataSource druid = new DruidDataSource(); + // 监控统计拦截的filters + druid.setFilters(dbCommonProperties.getFilters()); + + // 配置基本属性 + druid.setDriverClassName(db2Properties.getDriverClassName()); + druid.setUsername(db2Properties.getUsername()); + druid.setPassword(db2Properties.getPassword()); + druid.setUrl(db2Properties.getUrl()); + + //初始化时建立物理连接的个数 + druid.setInitialSize(dbCommonProperties.getInitialSize()); + //最大连接池数量 + druid.setMaxActive(dbCommonProperties.getMaxActive()); + //最小连接池数量 + druid.setMinIdle(dbCommonProperties.getMinIdle()); + //获取连接时最大等待时间,单位毫秒。 + druid.setMaxWait(dbCommonProperties.getMaxWait()); + //间隔多久进行一次检测,检测需要关闭的空闲连接 + druid.setTimeBetweenEvictionRunsMillis(dbCommonProperties.getTimeBetweenEvictionRunsMillis()); + //一个连接在池中最小生存的时间 + druid.setMinEvictableIdleTimeMillis(dbCommonProperties.getMinEvictableIdleTimeMillis()); + //用来检测连接是否有效的sql + druid.setValidationQuery(dbCommonProperties.getValidationQuery()); + //建议配置为true,不影响性能,并且保证安全性。 + druid.setTestWhileIdle(dbCommonProperties.isTestWhileIdle()); + //申请连接时执行validationQuery检测连接是否有效 + druid.setTestOnBorrow(dbCommonProperties.isTestOnBorrow()); + druid.setTestOnReturn(dbCommonProperties.isTestOnReturn()); + //是否缓存preparedStatement,也就是PSCache,oracle设为true,mysql设为false。分库分表较多推荐设置为false + druid.setPoolPreparedStatements(dbCommonProperties.isPoolPreparedStatements()); + // 打开PSCache时,指定每个连接上PSCache的大小 + druid.setMaxPoolPreparedStatementPerConnectionSize(dbCommonProperties.getMaxPoolPreparedStatementPerConnectionSize()); + return druid; + } + + @Bean(name = "db2TransactionManager") + public DataSourceTransactionManager db2TransactionManager() throws SQLException { + return new DataSourceTransactionManager(db2DataSource()); + } + + @Bean(name = "db2SqlSessionFactory") + public SqlSessionFactory db2SqlSessionFactory(@Qualifier("db2DataSource") DataSource dataSource) throws Exception { + final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); + sessionFactory.setDataSource(dataSource); // 设置数据源bean + sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(db2Properties.getMapperLocations())); // 设置mapper文件路径 + return sessionFactory.getObject(); + } + + @Bean("db2SqlSessionTemplate") + public SqlSessionTemplate db2SqlSessionTemplate(@Qualifier("db2SqlSessionFactory") SqlSessionFactory sqlSessionFactory){ + return new SqlSessionTemplate(sqlSessionFactory); + } + +} diff --git a/src/main/java/com/cm/bigdata/config/properties/db/Db1Properties.java b/src/main/java/com/cm/bigdata/config/properties/db/Db1Properties.java new file mode 100644 index 0000000..d02d608 --- /dev/null +++ b/src/main/java/com/cm/bigdata/config/properties/db/Db1Properties.java @@ -0,0 +1,64 @@ +package com.cm.bigdata.config.properties.db; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ConfigurationProperties(prefix = "spring.datasource.druid.db1") +public class Db1Properties { + + private String url; + private String dbType; + private String driverClassName; + private String username; + private String password; + private String mapperLocations; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getDbType() { + return dbType; + } + + public void setDbType(String dbType) { + this.dbType = dbType; + } + + public String getDriverClassName() { + return driverClassName; + } + + public void setDriverClassName(String driverClassName) { + this.driverClassName = driverClassName; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getMapperLocations() { + return mapperLocations; + } + + public void setMapperLocations(String mapperLocations) { + this.mapperLocations = mapperLocations; + } +} diff --git a/src/main/java/com/cm/bigdata/config/properties/db/Db2Properties.java b/src/main/java/com/cm/bigdata/config/properties/db/Db2Properties.java new file mode 100644 index 0000000..6580eb0 --- /dev/null +++ b/src/main/java/com/cm/bigdata/config/properties/db/Db2Properties.java @@ -0,0 +1,64 @@ +package com.cm.bigdata.config.properties.db; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ConfigurationProperties(prefix = "spring.datasource.druid.db2") +public class Db2Properties { + + private String url; + private String dbType; + private String driverClassName; + private String username; + private String password; + private String mapperLocations; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getDbType() { + return dbType; + } + + public void setDbType(String dbType) { + this.dbType = dbType; + } + + public String getDriverClassName() { + return driverClassName; + } + + public void setDriverClassName(String driverClassName) { + this.driverClassName = driverClassName; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getMapperLocations() { + return mapperLocations; + } + + public void setMapperLocations(String mapperLocations) { + this.mapperLocations = mapperLocations; + } +} diff --git a/src/main/java/com/cm/bigdata/config/properties/db/DbCommonProperties.java b/src/main/java/com/cm/bigdata/config/properties/db/DbCommonProperties.java new file mode 100644 index 0000000..785941a --- /dev/null +++ b/src/main/java/com/cm/bigdata/config/properties/db/DbCommonProperties.java @@ -0,0 +1,127 @@ +package com.cm.bigdata.config.properties.db; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ConfigurationProperties(prefix = "spring.datasource.druid") +public class DbCommonProperties { + + private String filters; + private int initialSize; + private int minIdle; + private int maxActive; + private long maxWait; + private long timeBetweenEvictionRunsMillis; + private long minEvictableIdleTimeMillis; + private String validationQuery; + private boolean testWhileIdle; + private boolean testOnBorrow; + private boolean testOnReturn; + private boolean poolPreparedStatements; + private int maxPoolPreparedStatementPerConnectionSize; + + public String getFilters() { + return filters; + } + + public void setFilters(String filters) { + this.filters = filters; + } + + public int getInitialSize() { + return initialSize; + } + + public void setInitialSize(int initialSize) { + this.initialSize = initialSize; + } + + public int getMinIdle() { + return minIdle; + } + + public void setMinIdle(int minIdle) { + this.minIdle = minIdle; + } + + public int getMaxActive() { + return maxActive; + } + + public void setMaxActive(int maxActive) { + this.maxActive = maxActive; + } + + public long getMaxWait() { + return maxWait; + } + + public void setMaxWait(long maxWait) { + this.maxWait = maxWait; + } + + public long getTimeBetweenEvictionRunsMillis() { + return timeBetweenEvictionRunsMillis; + } + + public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) { + this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis; + } + + public long getMinEvictableIdleTimeMillis() { + return minEvictableIdleTimeMillis; + } + + public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) { + this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis; + } + + public String getValidationQuery() { + return validationQuery; + } + + public void setValidationQuery(String validationQuery) { + this.validationQuery = validationQuery; + } + + public boolean isTestWhileIdle() { + return testWhileIdle; + } + + public void setTestWhileIdle(boolean testWhileIdle) { + this.testWhileIdle = testWhileIdle; + } + + public boolean isTestOnBorrow() { + return testOnBorrow; + } + + public void setTestOnBorrow(boolean testOnBorrow) { + this.testOnBorrow = testOnBorrow; + } + + public boolean isTestOnReturn() { + return testOnReturn; + } + + public void setTestOnReturn(boolean testOnReturn) { + this.testOnReturn = testOnReturn; + } + + public boolean isPoolPreparedStatements() { + return poolPreparedStatements; + } + + public void setPoolPreparedStatements(boolean poolPreparedStatements) { + this.poolPreparedStatements = poolPreparedStatements; + } + + public int getMaxPoolPreparedStatementPerConnectionSize() { + return maxPoolPreparedStatementPerConnectionSize; + } + + public void setMaxPoolPreparedStatementPerConnectionSize(int maxPoolPreparedStatementPerConnectionSize) { + this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize; + } +} diff --git a/src/main/java/com/cm/bigdata/controller/apis/kpi/KpiController.java b/src/main/java/com/cm/bigdata/controller/apis/kpi/KpiController.java new file mode 100644 index 0000000..b664a66 --- /dev/null +++ b/src/main/java/com/cm/bigdata/controller/apis/kpi/KpiController.java @@ -0,0 +1,28 @@ +package com.cm.bigdata.controller.apis.kpi; + +import com.cm.bigdata.service.kpi.IKpiService; +import com.cm.common.base.AbstractController; +import com.cm.common.constants.ISystemConstant; +import com.cm.common.result.SuccessResultData; +import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "KPI接口") +@RestController +@RequestMapping(ISystemConstant.API_PREFIX + "/kpi") +public class KpiController extends AbstractController { + + @Autowired + private IKpiService kpiService; + + @GetMapping("update-community-boss-day-count/{level}") + public SuccessResultData updateCommunityBossDayCount(@PathVariable("level") Integer level, + @RequestParam("dayDate") String dayDate) { + long startTime = System.currentTimeMillis(); + kpiService.updateCommunityBossDayCount(dayDate, level); + long endTime = System.currentTimeMillis(); + return new SuccessResultData<>("used " + (endTime - startTime) + " ms"); + } + +} diff --git a/src/main/java/com/cm/bigdata/dao/kpi/IKpiDao.java b/src/main/java/com/cm/bigdata/dao/kpi/IKpiDao.java new file mode 100644 index 0000000..8f7f09e --- /dev/null +++ b/src/main/java/com/cm/bigdata/dao/kpi/IKpiDao.java @@ -0,0 +1,19 @@ +package com.cm.bigdata.dao.kpi; + +import com.cm.bigdata.pojo.pos.kpi.CommunityBossDayCountPO; +import org.springframework.stereotype.Repository; + +import java.util.Map; + +@Repository +public interface IKpiDao { + + void saveCommunityBossDayCount(Map params); + + void deleteCommunityBossDayCount(Map params); + + void updateCommunityBossDayCount(Map params); + + CommunityBossDayCountPO getCommunityBossDayCountPO(Map params); + +} diff --git a/src/main/java/com/cm/bigdata/dao2/kpi/IBasePopulationInfoDao.java b/src/main/java/com/cm/bigdata/dao2/kpi/IBasePopulationInfoDao.java new file mode 100644 index 0000000..24e90fd --- /dev/null +++ b/src/main/java/com/cm/bigdata/dao2/kpi/IBasePopulationInfoDao.java @@ -0,0 +1,16 @@ +package com.cm.bigdata.dao2.kpi; + +import com.cm.bigdata.pojo.pos.kpi.BasePopulationInfoCountPO; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +@Repository +public interface IBasePopulationInfoDao { + + List listPopulationSaveCount(Map params); + + List listPopulationUpdateCount(Map params); + +} diff --git a/src/main/java/com/cm/bigdata/dao2/kpi/ICommunityBossDao.java b/src/main/java/com/cm/bigdata/dao2/kpi/ICommunityBossDao.java new file mode 100644 index 0000000..4e97bb7 --- /dev/null +++ b/src/main/java/com/cm/bigdata/dao2/kpi/ICommunityBossDao.java @@ -0,0 +1,14 @@ +package com.cm.bigdata.dao2.kpi; + +import com.cm.bigdata.pojo.pos.kpi.CommunityBossPO; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +@Repository +public interface ICommunityBossDao { + + List listPO(Map params); + +} diff --git a/src/main/java/com/cm/bigdata/dao2/kpi/IUserLocationDao.java b/src/main/java/com/cm/bigdata/dao2/kpi/IUserLocationDao.java new file mode 100644 index 0000000..54d60b6 --- /dev/null +++ b/src/main/java/com/cm/bigdata/dao2/kpi/IUserLocationDao.java @@ -0,0 +1,13 @@ +package com.cm.bigdata.dao2.kpi; + +import com.cm.bigdata.pojo.pos.kpi.UserLocationPO; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +@Repository +public interface IUserLocationDao { + List listPO(Map params); + +} diff --git a/src/main/java/com/cm/bigdata/dao2/kpi/IUserSignDao.java b/src/main/java/com/cm/bigdata/dao2/kpi/IUserSignDao.java new file mode 100644 index 0000000..75ababd --- /dev/null +++ b/src/main/java/com/cm/bigdata/dao2/kpi/IUserSignDao.java @@ -0,0 +1,17 @@ +package com.cm.bigdata.dao2.kpi; + +import com.cm.bigdata.pojo.pos.kpi.UserSigninPO; +import com.cm.bigdata.pojo.pos.kpi.UserSignoutPO; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +@Repository +public interface IUserSignDao { + + List listInPO(Map params); + + List listOutPO(Map params); + +} diff --git a/src/main/java/com/cm/bigdata/pojo/pos/kpi/BasePopulationInfoCountPO.java b/src/main/java/com/cm/bigdata/pojo/pos/kpi/BasePopulationInfoCountPO.java new file mode 100644 index 0000000..8bc1f81 --- /dev/null +++ b/src/main/java/com/cm/bigdata/pojo/pos/kpi/BasePopulationInfoCountPO.java @@ -0,0 +1,23 @@ +package com.cm.bigdata.pojo.pos.kpi; + +public class BasePopulationInfoCountPO { + + private String userId; + private Integer total; + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Integer getTotal() { + return total == null ? 0 : total; + } + + public void setTotal(Integer total) { + this.total = total; + } +} diff --git a/src/main/java/com/cm/bigdata/pojo/pos/kpi/BasePopulationInfoPO.java b/src/main/java/com/cm/bigdata/pojo/pos/kpi/BasePopulationInfoPO.java new file mode 100644 index 0000000..3c8def9 --- /dev/null +++ b/src/main/java/com/cm/bigdata/pojo/pos/kpi/BasePopulationInfoPO.java @@ -0,0 +1,275 @@ +package com.cm.bigdata.pojo.pos.kpi; + +public class BasePopulationInfoPO { + private Long id; + private String basePopulationInfoId; + private String idCardNumber; + private String fullName; + private String nameUsedBefore; + private String gender; + private String birthDate; + private String telephone; + private String nation; + private String religion; + private String education; + private String politicalStatus; + private String maritalStatus; + private String occupationCategory; + private String occupation; + private String nativePlace; + private String nativePlaceAddr; + private String serviceSpace; + private String registeredResidence; + private String registeredResidenceAddr; + private String currentResidence; + private String currentResidenceAddr; + private String creator; + private String gmtCreate; + private String modifier; + private String gmtModified; + private String areaId; + private String areaCode; + private String areaNames; + private String otherPeopleType; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getBasePopulationInfoId() { + return basePopulationInfoId; + } + + public void setBasePopulationInfoId(String basePopulationInfoId) { + this.basePopulationInfoId = basePopulationInfoId; + } + + public String getIdCardNumber() { + return idCardNumber; + } + + public void setIdCardNumber(String idCardNumber) { + this.idCardNumber = idCardNumber; + } + + public String getFullName() { + return fullName; + } + + public void setFullName(String fullName) { + this.fullName = fullName; + } + + public String getNameUsedBefore() { + return nameUsedBefore; + } + + public void setNameUsedBefore(String nameUsedBefore) { + this.nameUsedBefore = nameUsedBefore; + } + + public String getGender() { + return gender; + } + + public void setGender(String gender) { + this.gender = gender; + } + + public String getBirthDate() { + return birthDate; + } + + public void setBirthDate(String birthDate) { + this.birthDate = birthDate; + } + + public String getTelephone() { + return telephone; + } + + public void setTelephone(String telephone) { + this.telephone = telephone; + } + + public String getNation() { + return nation; + } + + public void setNation(String nation) { + this.nation = nation; + } + + public String getReligion() { + return religion; + } + + public void setReligion(String religion) { + this.religion = religion; + } + + public String getEducation() { + return education; + } + + public void setEducation(String education) { + this.education = education; + } + + public String getPoliticalStatus() { + return politicalStatus; + } + + public void setPoliticalStatus(String politicalStatus) { + this.politicalStatus = politicalStatus; + } + + public String getMaritalStatus() { + return maritalStatus; + } + + public void setMaritalStatus(String maritalStatus) { + this.maritalStatus = maritalStatus; + } + + public String getOccupationCategory() { + return occupationCategory; + } + + public void setOccupationCategory(String occupationCategory) { + this.occupationCategory = occupationCategory; + } + + public String getOccupation() { + return occupation; + } + + public void setOccupation(String occupation) { + this.occupation = occupation; + } + + public String getNativePlace() { + return nativePlace; + } + + public void setNativePlace(String nativePlace) { + this.nativePlace = nativePlace; + } + + public String getNativePlaceAddr() { + return nativePlaceAddr; + } + + public void setNativePlaceAddr(String nativePlaceAddr) { + this.nativePlaceAddr = nativePlaceAddr; + } + + public String getServiceSpace() { + return serviceSpace; + } + + public void setServiceSpace(String serviceSpace) { + this.serviceSpace = serviceSpace; + } + + public String getRegisteredResidence() { + return registeredResidence; + } + + public void setRegisteredResidence(String registeredResidence) { + this.registeredResidence = registeredResidence; + } + + public String getRegisteredResidenceAddr() { + return registeredResidenceAddr; + } + + public void setRegisteredResidenceAddr(String registeredResidenceAddr) { + this.registeredResidenceAddr = registeredResidenceAddr; + } + + public String getCurrentResidence() { + return currentResidence; + } + + public void setCurrentResidence(String currentResidence) { + this.currentResidence = currentResidence; + } + + public String getCurrentResidenceAddr() { + return currentResidenceAddr; + } + + public void setCurrentResidenceAddr(String currentResidenceAddr) { + this.currentResidenceAddr = currentResidenceAddr; + } + + public String getCreator() { + return creator; + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public String getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(String gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public String getModifier() { + return modifier; + } + + public void setModifier(String modifier) { + this.modifier = modifier; + } + + public String getGmtModified() { + return gmtModified; + } + + public void setGmtModified(String gmtModified) { + this.gmtModified = gmtModified; + } + + public String getAreaId() { + return areaId; + } + + public void setAreaId(String areaId) { + this.areaId = areaId; + } + + public String getAreaCode() { + return areaCode; + } + + public void setAreaCode(String areaCode) { + this.areaCode = areaCode; + } + + public String getAreaNames() { + return areaNames; + } + + public void setAreaNames(String areaNames) { + this.areaNames = areaNames; + } + + public String getOtherPeopleType() { + return otherPeopleType; + } + + public void setOtherPeopleType(String otherPeopleType) { + this.otherPeopleType = otherPeopleType; + } +} diff --git a/src/main/java/com/cm/bigdata/pojo/pos/kpi/CommunityBossDayCountPO.java b/src/main/java/com/cm/bigdata/pojo/pos/kpi/CommunityBossDayCountPO.java new file mode 100644 index 0000000..44bc8b5 --- /dev/null +++ b/src/main/java/com/cm/bigdata/pojo/pos/kpi/CommunityBossDayCountPO.java @@ -0,0 +1,98 @@ +package com.cm.bigdata.pojo.pos.kpi; + +import lombok.Data; +import lombok.ToString; + +public class CommunityBossDayCountPO { + + private Long id; + private String userId; + private String dayDate; + private Integer isSignin; + private Integer isSigninLate; + private Integer isSignout; + private Integer isSignoutEarly; + private Double workDistance; + private Integer savePopulationCount; + private Integer updatePopulationCount; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getDayDate() { + return dayDate; + } + + public void setDayDate(String dayDate) { + this.dayDate = dayDate; + } + + public Integer getIsSignin() { + return isSignin; + } + + public void setIsSignin(Integer isSignin) { + this.isSignin = isSignin; + } + + public Integer getIsSigninLate() { + return isSigninLate; + } + + public void setIsSigninLate(Integer isSigninLate) { + this.isSigninLate = isSigninLate; + } + + public Integer getIsSignout() { + return isSignout; + } + + public void setIsSignout(Integer isSignout) { + this.isSignout = isSignout; + } + + public Integer getIsSignoutEarly() { + return isSignoutEarly; + } + + public void setIsSignoutEarly(Integer isSignoutEarly) { + this.isSignoutEarly = isSignoutEarly; + } + + public Double getWorkDistance() { + return workDistance; + } + + public void setWorkDistance(Double workDistance) { + this.workDistance = workDistance; + } + + public Integer getSavePopulationCount() { + return savePopulationCount; + } + + public void setSavePopulationCount(Integer savePopulationCount) { + this.savePopulationCount = savePopulationCount; + } + + public Integer getUpdatePopulationCount() { + return updatePopulationCount; + } + + public void setUpdatePopulationCount(Integer updatePopulationCount) { + this.updatePopulationCount = updatePopulationCount; + } +} diff --git a/src/main/java/com/cm/bigdata/pojo/pos/kpi/CommunityBossPO.java b/src/main/java/com/cm/bigdata/pojo/pos/kpi/CommunityBossPO.java new file mode 100644 index 0000000..60bf52e --- /dev/null +++ b/src/main/java/com/cm/bigdata/pojo/pos/kpi/CommunityBossPO.java @@ -0,0 +1,107 @@ +package com.cm.bigdata.pojo.pos.kpi; + +import lombok.Data; +import lombok.ToString; + +public class CommunityBossPO { + + private Long id; + private String communityBossId; + private String communityBossUserId; + private String communityBossParentId; + private String communityBossParentUserId; + private Integer communityBossLevel; + private String areaId; + private String areaName; + private String gridSummary; + private String creator; + private String gmtCreate; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getCommunityBossId() { + return communityBossId; + } + + public void setCommunityBossId(String communityBossId) { + this.communityBossId = communityBossId; + } + + public String getCommunityBossUserId() { + return communityBossUserId; + } + + public void setCommunityBossUserId(String communityBossUserId) { + this.communityBossUserId = communityBossUserId; + } + + public String getCommunityBossParentId() { + return communityBossParentId; + } + + public void setCommunityBossParentId(String communityBossParentId) { + this.communityBossParentId = communityBossParentId; + } + + public String getCommunityBossParentUserId() { + return communityBossParentUserId; + } + + public void setCommunityBossParentUserId(String communityBossParentUserId) { + this.communityBossParentUserId = communityBossParentUserId; + } + + public Integer getCommunityBossLevel() { + return communityBossLevel; + } + + public void setCommunityBossLevel(Integer communityBossLevel) { + this.communityBossLevel = communityBossLevel; + } + + public String getAreaId() { + return areaId; + } + + public void setAreaId(String areaId) { + this.areaId = areaId; + } + + public String getAreaName() { + return areaName; + } + + public void setAreaName(String areaName) { + this.areaName = areaName; + } + + public String getGridSummary() { + return gridSummary; + } + + public void setGridSummary(String gridSummary) { + this.gridSummary = gridSummary; + } + + public String getCreator() { + return creator; + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public String getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(String gmtCreate) { + this.gmtCreate = gmtCreate; + } +} diff --git a/src/main/java/com/cm/bigdata/pojo/pos/kpi/UserLocationPO.java b/src/main/java/com/cm/bigdata/pojo/pos/kpi/UserLocationPO.java new file mode 100644 index 0000000..745bbc3 --- /dev/null +++ b/src/main/java/com/cm/bigdata/pojo/pos/kpi/UserLocationPO.java @@ -0,0 +1,89 @@ +package com.cm.bigdata.pojo.pos.kpi; + +import lombok.Data; +import lombok.ToString; + +public class UserLocationPO { + + private Long id; + private String userLocationId; + private String userLongitude; + private String userLatitude; + private String userLocation; + private Integer isOverstep; + private String userName; + private String creator; + private String gmtCreate; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUserLocationId() { + return userLocationId; + } + + public void setUserLocationId(String userLocationId) { + this.userLocationId = userLocationId; + } + + public String getUserLongitude() { + return userLongitude; + } + + public void setUserLongitude(String userLongitude) { + this.userLongitude = userLongitude; + } + + public String getUserLatitude() { + return userLatitude; + } + + public void setUserLatitude(String userLatitude) { + this.userLatitude = userLatitude; + } + + public String getUserLocation() { + return userLocation; + } + + public void setUserLocation(String userLocation) { + this.userLocation = userLocation; + } + + public Integer getIsOverstep() { + return isOverstep; + } + + public void setIsOverstep(Integer isOverstep) { + this.isOverstep = isOverstep; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getCreator() { + return creator; + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public String getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(String gmtCreate) { + this.gmtCreate = gmtCreate; + } +} diff --git a/src/main/java/com/cm/bigdata/pojo/pos/kpi/UserSigninPO.java b/src/main/java/com/cm/bigdata/pojo/pos/kpi/UserSigninPO.java new file mode 100644 index 0000000..5f00bf3 --- /dev/null +++ b/src/main/java/com/cm/bigdata/pojo/pos/kpi/UserSigninPO.java @@ -0,0 +1,95 @@ +package com.cm.bigdata.pojo.pos.kpi; + +public class UserSigninPO { + + private Long id; + private String userSigninId; + private String userName; + private String signinLongitude; + private String signinLatitude; + private Integer isLate; + private Integer isOutside; + private String amPm; + private String creator; + private String gmtCreate; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUserSigninId() { + return userSigninId; + } + + public void setUserSigninId(String userSigninId) { + this.userSigninId = userSigninId; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getSigninLongitude() { + return signinLongitude; + } + + public void setSigninLongitude(String signinLongitude) { + this.signinLongitude = signinLongitude; + } + + public String getSigninLatitude() { + return signinLatitude; + } + + public void setSigninLatitude(String signinLatitude) { + this.signinLatitude = signinLatitude; + } + + public Integer getIsLate() { + return isLate; + } + + public void setIsLate(Integer isLate) { + this.isLate = isLate; + } + + public Integer getIsOutside() { + return isOutside; + } + + public void setIsOutside(Integer isOutside) { + this.isOutside = isOutside; + } + + public String getAmPm() { + return amPm; + } + + public void setAmPm(String amPm) { + this.amPm = amPm; + } + + public String getCreator() { + return creator; + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public String getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(String gmtCreate) { + this.gmtCreate = gmtCreate; + } +} diff --git a/src/main/java/com/cm/bigdata/pojo/pos/kpi/UserSignoutPO.java b/src/main/java/com/cm/bigdata/pojo/pos/kpi/UserSignoutPO.java new file mode 100644 index 0000000..da94b62 --- /dev/null +++ b/src/main/java/com/cm/bigdata/pojo/pos/kpi/UserSignoutPO.java @@ -0,0 +1,98 @@ +package com.cm.bigdata.pojo.pos.kpi; + +import lombok.Data; +import lombok.ToString; + +public class UserSignoutPO { + + private Long id; + private String userSignoutId; + private String userName; + private String signoutLongitude; + private String signoutLatitude; + private Integer isEarly; + private Integer isOutside; + private String amPm; + private String creator; + private String gmtCreate; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUserSignoutId() { + return userSignoutId; + } + + public void setUserSignoutId(String userSignoutId) { + this.userSignoutId = userSignoutId; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getSignoutLongitude() { + return signoutLongitude; + } + + public void setSignoutLongitude(String signoutLongitude) { + this.signoutLongitude = signoutLongitude; + } + + public String getSignoutLatitude() { + return signoutLatitude; + } + + public void setSignoutLatitude(String signoutLatitude) { + this.signoutLatitude = signoutLatitude; + } + + public Integer getIsEarly() { + return isEarly; + } + + public void setIsEarly(Integer isEarly) { + this.isEarly = isEarly; + } + + public Integer getIsOutside() { + return isOutside; + } + + public void setIsOutside(Integer isOutside) { + this.isOutside = isOutside; + } + + public String getAmPm() { + return amPm; + } + + public void setAmPm(String amPm) { + this.amPm = amPm; + } + + public String getCreator() { + return creator; + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public String getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(String gmtCreate) { + this.gmtCreate = gmtCreate; + } +} diff --git a/src/main/java/com/cm/bigdata/service/kpi/IBasePopulationInfoService.java b/src/main/java/com/cm/bigdata/service/kpi/IBasePopulationInfoService.java new file mode 100644 index 0000000..db308bf --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/IBasePopulationInfoService.java @@ -0,0 +1,16 @@ +package com.cm.bigdata.service.kpi; + +import com.cm.bigdata.pojo.pos.kpi.BasePopulationInfoCountPO; + +import java.util.List; +import java.util.Map; + +public interface IBasePopulationInfoService { + + List listPopulationSaveCountByUserIds(List userIds); + + List listPopulationSaveCountByUserIdsAndDay(List userIds, String date); + + List listPopulationUpdateCountByUserIdsAndDay(List userIds, String date); + +} diff --git a/src/main/java/com/cm/bigdata/service/kpi/ICommunityBossService.java b/src/main/java/com/cm/bigdata/service/kpi/ICommunityBossService.java new file mode 100644 index 0000000..76ee668 --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/ICommunityBossService.java @@ -0,0 +1,11 @@ +package com.cm.bigdata.service.kpi; + +import com.cm.bigdata.pojo.pos.kpi.CommunityBossPO; + +import java.util.List; + +public interface ICommunityBossService { + + List listPOByLevel(int communityBossLevel); + +} diff --git a/src/main/java/com/cm/bigdata/service/kpi/IKpiService.java b/src/main/java/com/cm/bigdata/service/kpi/IKpiService.java new file mode 100644 index 0000000..01c4de7 --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/IKpiService.java @@ -0,0 +1,15 @@ +package com.cm.bigdata.service.kpi; + +/** + * 绩效考核 + */ +public interface IKpiService { + + /** + * 更新4、5级网格员日统计 + * @param date + */ + void updateCommunityBossDayCount(String date, int level); + + +} diff --git a/src/main/java/com/cm/bigdata/service/kpi/IUserLocationService.java b/src/main/java/com/cm/bigdata/service/kpi/IUserLocationService.java new file mode 100644 index 0000000..9cebf1a --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/IUserLocationService.java @@ -0,0 +1,9 @@ +package com.cm.bigdata.service.kpi; + +import com.cm.bigdata.pojo.pos.kpi.UserLocationPO; + +import java.util.List; + +public interface IUserLocationService { + List listPOByUserIdAndDate(String userId, String day); +} diff --git a/src/main/java/com/cm/bigdata/service/kpi/IUserSignService.java b/src/main/java/com/cm/bigdata/service/kpi/IUserSignService.java new file mode 100644 index 0000000..4f8e70c --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/IUserSignService.java @@ -0,0 +1,12 @@ +package com.cm.bigdata.service.kpi; + +import com.cm.bigdata.pojo.pos.kpi.UserSigninPO; +import com.cm.bigdata.pojo.pos.kpi.UserSignoutPO; + +import java.util.List; + +public interface IUserSignService { + List listInPOByUserIdsAndDay(List userIds, String day); + + List listOutPOByUserIdsAndDay(List userIds, String day); +} diff --git a/src/main/java/com/cm/bigdata/service/kpi/impl/BasePopulationInfoServiceImpl.java b/src/main/java/com/cm/bigdata/service/kpi/impl/BasePopulationInfoServiceImpl.java new file mode 100644 index 0000000..f6b1f77 --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/impl/BasePopulationInfoServiceImpl.java @@ -0,0 +1,42 @@ +package com.cm.bigdata.service.kpi.impl; + +import com.cm.bigdata.dao2.kpi.IBasePopulationInfoDao; +import com.cm.bigdata.pojo.pos.kpi.BasePopulationInfoCountPO; +import com.cm.bigdata.pojo.pos.kpi.BasePopulationInfoPO; +import com.cm.bigdata.service.kpi.IBasePopulationInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class BasePopulationInfoServiceImpl implements IBasePopulationInfoService { + + @Autowired + private IBasePopulationInfoDao basePopulationInfoDao; + + @Override + public List listPopulationSaveCountByUserIds(List userIds) { + Map params = new HashMap<>(); + params.put("userIds", userIds); + return basePopulationInfoDao.listPopulationSaveCount(params); + } + + @Override + public List listPopulationSaveCountByUserIdsAndDay(List userIds, String date) { + Map params = new HashMap<>(); + params.put("day", date); + params.put("userIds", userIds); + return basePopulationInfoDao.listPopulationSaveCount(params); + } + + @Override + public List listPopulationUpdateCountByUserIdsAndDay(List userIds, String date) { + Map params = new HashMap<>(); + params.put("day", date); + params.put("userIds", userIds); + return basePopulationInfoDao.listPopulationUpdateCount(params); + } +} diff --git a/src/main/java/com/cm/bigdata/service/kpi/impl/CommunityBossServiceImpl.java b/src/main/java/com/cm/bigdata/service/kpi/impl/CommunityBossServiceImpl.java new file mode 100644 index 0000000..24f60d6 --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/impl/CommunityBossServiceImpl.java @@ -0,0 +1,25 @@ +package com.cm.bigdata.service.kpi.impl; + +import com.cm.bigdata.dao2.kpi.ICommunityBossDao; +import com.cm.bigdata.pojo.pos.kpi.CommunityBossPO; +import com.cm.bigdata.service.kpi.ICommunityBossService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class CommunityBossServiceImpl implements ICommunityBossService { + + @Autowired + private ICommunityBossDao communityBossDao; + + @Override + public List listPOByLevel(int communityBossLevel) { + Map params = new HashMap<>(); + params.put("communityBossLevel", communityBossLevel); + return communityBossDao.listPO(params); + } +} diff --git a/src/main/java/com/cm/bigdata/service/kpi/impl/KpiServiceImpl.java b/src/main/java/com/cm/bigdata/service/kpi/impl/KpiServiceImpl.java new file mode 100644 index 0000000..afa77b0 --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/impl/KpiServiceImpl.java @@ -0,0 +1,79 @@ +package com.cm.bigdata.service.kpi.impl; + +import com.cm.bigdata.dao.kpi.IKpiDao; +import com.cm.bigdata.pojo.pos.kpi.*; +import com.cm.bigdata.service.kpi.*; +import com.cm.bigdata.utils.KpiUtil; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Service +public class KpiServiceImpl implements IKpiService { + + @Autowired + private IKpiDao kpiDao; + @Autowired + private ICommunityBossService communityBossService; + @Autowired + private IUserSignService userSignService; + @Autowired + private IUserLocationService userLocationService; + @Autowired + private IBasePopulationInfoService basePopulationInfoService; + + @Override + public void updateCommunityBossDayCount(String date, int level) { + // communityBoss表中的level位1-4,对应的是2-5级网格员 + final int communityBossLevel = level - 1; + List communityBoss4DTOList = communityBossService.listPOByLevel(communityBossLevel); + List userIds = communityBoss4DTOList.stream().map(CommunityBossPO::getCommunityBossUserId).filter(StringUtils::isNotBlank).collect(Collectors.toList()); + Map> userSigninMap = KpiUtil.mapSignin(userSignService, userIds, date); + Map> userSignoutMap = KpiUtil.mapSignout(userSignService, userIds, date); + Map populationCountMap = KpiUtil.mapPopulationCount(basePopulationInfoService, userIds); + Map populationSaveCountMap = KpiUtil.mapPopulationSaveCount(basePopulationInfoService, userIds, date); + Map populationUpdateCountMap = KpiUtil.mapPopulationUpdateCount(basePopulationInfoService, userIds, date); + // 删除当日数据 + deleteCommunityBossDayCount(date, communityBossLevel); + communityBoss4DTOList.forEach(communityBossDTO -> { + String userId = communityBossDTO.getCommunityBossUserId(); + List userSigninPO = userSigninMap.get(userId); + int isSignin = userSigninPO == null || userSigninPO.size() == 0 ? 0 : 1; + int isSigninLate = userSigninPO == null || userSigninPO.size() == 0 ? 0 : userSigninPO.get(0).getIsLate(); + List userSignoutPOS = userSignoutMap.get(userId); + int isSignout = userSignoutPOS == null || userSignoutPOS.size() == 0 ? 0 : 1; + int isSignoutEarly = userSignoutPOS == null || userSignoutPOS.size() == 0 ? 0 : userSignoutPOS.get(0).getIsEarly(); + double workDistance = KpiUtil.calculateWorkDistance(userLocationService, userId, date); + int populationCount = populationCountMap.get(userId) == null ? 0 : populationCountMap.get(userId); + int savePopulationCount = populationSaveCountMap.get(userId) == null ? 0 : populationSaveCountMap.get(userId); + int updatePopulationCount = populationUpdateCountMap.get(userId) == null ? 0 : populationUpdateCountMap.get(userId); + // 新增 + Map params = new HashMap<>(); + params.put("userId", userId); + params.put("dayDate", date); + params.put("isSignin", isSignin); + params.put("isSigninLate", isSigninLate); + params.put("isSignout", isSignout); + params.put("isSignoutEarly", isSignoutEarly); + params.put("workDistance", workDistance); + params.put("populationCount", populationCount); + params.put("savePopulationCount", savePopulationCount); + params.put("updatePopulationCount", updatePopulationCount); + params.put("level", communityBossLevel); + kpiDao.saveCommunityBossDayCount(params); + }); + } + + private void deleteCommunityBossDayCount(String date, int level) { + Map params = new HashMap<>(4); + params.put("dayDate", date); + params.put("level", level); + kpiDao.deleteCommunityBossDayCount(params); + } + +} diff --git a/src/main/java/com/cm/bigdata/service/kpi/impl/UserLocationServiceImpl.java b/src/main/java/com/cm/bigdata/service/kpi/impl/UserLocationServiceImpl.java new file mode 100644 index 0000000..befde0e --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/impl/UserLocationServiceImpl.java @@ -0,0 +1,33 @@ +package com.cm.bigdata.service.kpi.impl; + +import com.cm.bigdata.dao2.kpi.IUserLocationDao; +import com.cm.bigdata.pojo.pos.kpi.UserLocationPO; +import com.cm.bigdata.service.kpi.IUserLocationService; +import com.cm.common.constants.ISystemConstant; +import org.apache.commons.lang3.StringUtils; +import org.joda.time.LocalDateTime; +import org.joda.time.format.DateTimeFormat; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class UserLocationServiceImpl implements IUserLocationService { + + @Autowired + private IUserLocationDao userLocationDao; + + + @Override + public List listPOByUserIdAndDate(String userId, String day) { + String currentDay = LocalDateTime.now().toString(DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD)); + Map params = new HashMap<>(); + params.put("creator", userId); + params.put("day", day); + params.put("tableSuffix", StringUtils.equals(currentDay, day) ? "" : "_history"); + return userLocationDao.listPO(params); + } +} diff --git a/src/main/java/com/cm/bigdata/service/kpi/impl/UserSignService.java b/src/main/java/com/cm/bigdata/service/kpi/impl/UserSignService.java new file mode 100644 index 0000000..8a90997 --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/impl/UserSignService.java @@ -0,0 +1,35 @@ +package com.cm.bigdata.service.kpi.impl; + +import com.cm.bigdata.dao2.kpi.IUserSignDao; +import com.cm.bigdata.pojo.pos.kpi.UserSigninPO; +import com.cm.bigdata.pojo.pos.kpi.UserSignoutPO; +import com.cm.bigdata.service.kpi.IUserSignService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class UserSignService implements IUserSignService { + + @Autowired + private IUserSignDao userSignDao; + + @Override + public List listInPOByUserIdsAndDay(List userIds, String day) { + Map params = new HashMap<>(); + params.put("creators", userIds); + params.put("day", day); + return userSignDao.listInPO(params); + } + + @Override + public List listOutPOByUserIdsAndDay(List userIds, String day) { + Map params = new HashMap<>(); + params.put("creators", userIds); + params.put("day", day); + return userSignDao.listOutPO(params); + } +} diff --git a/src/main/java/com/cm/bigdata/utils/KpiUtil.java b/src/main/java/com/cm/bigdata/utils/KpiUtil.java new file mode 100644 index 0000000..3c389f0 --- /dev/null +++ b/src/main/java/com/cm/bigdata/utils/KpiUtil.java @@ -0,0 +1,118 @@ +package com.cm.bigdata.utils; + +import com.cm.bigdata.pojo.pos.kpi.BasePopulationInfoCountPO; +import com.cm.bigdata.pojo.pos.kpi.UserLocationPO; +import com.cm.bigdata.pojo.pos.kpi.UserSigninPO; +import com.cm.bigdata.pojo.pos.kpi.UserSignoutPO; +import com.cm.bigdata.service.kpi.IBasePopulationInfoService; +import com.cm.bigdata.service.kpi.IUserLocationService; +import com.cm.bigdata.service.kpi.IUserSignService; +import com.cm.common.utils.point.Point; +import com.cm.common.utils.point.PointUtil; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class KpiUtil { + + /** + * 签到map + * + * @param userSigninService + * @param userIds + * @return + */ + public static Map> mapSignin(IUserSignService userSignService, List userIds, String day) { + List userSigninDTOS = userSignService.listInPOByUserIdsAndDay(userIds, day); + Map> userSigninMap = new HashMap<>(); + userSigninDTOS.forEach(userSigninPO -> { + List userSigninDTOList = userSigninMap.get(userSigninPO.getCreator()); + if (userSigninDTOList == null) { + userSigninDTOList = new ArrayList<>(); + } + userSigninDTOList.add(userSigninPO); + userSigninMap.put(userSigninPO.getCreator(), userSigninDTOList); + }); + return userSigninMap; + } + + /** + * 签退map + * + * @param userSignoutService + * @param userIds + * @return + */ + public static Map> mapSignout(IUserSignService userSignService, List userIds, String day) { + List userSignoutDTOS = userSignService.listOutPOByUserIdsAndDay(userIds, day); + Map> userSigninMap = new HashMap<>(); + userSignoutDTOS.forEach(userSignoutPO -> { + List userSignoutDTOList = userSigninMap.get(userSignoutPO.getCreator()); + if (userSignoutDTOList == null) { + userSignoutDTOList = new ArrayList<>(); + } + userSignoutDTOList.add(userSignoutPO); + userSigninMap.put(userSignoutPO.getCreator(), userSignoutDTOList); + }); + return userSigninMap; + } + + /** + * 计算工作距离 + * + * @param userLocationService + * @param userId + * @param day af535c78-f0ba-4ccf-891b-cf7c6e42e9e8 + * @return + */ + public static Double calculateWorkDistance(IUserLocationService userLocationService, String userId, String day) { + double workDistance = 0D; + if (!StringUtils.equals(userId, "af535c78-f0ba-4ccf-891b-cf7c6e42e9e8")) { + return workDistance; + } + List userLocationPOS = userLocationService.listPOByUserIdAndDate(userId, day); + Point tempPoint = null; + for (UserLocationPO userLocationPO : userLocationPOS) { + Point point = new Point(Double.parseDouble(userLocationPO.getUserLatitude()), Double.parseDouble(userLocationPO.getUserLongitude())); + if (tempPoint == null) { + tempPoint = point; + continue; + } + workDistance += PointUtil.getDistance(tempPoint, point); + tempPoint = point; + } + return workDistance; + } + + public static Map mapPopulationCount(IBasePopulationInfoService basePopulationInfoService, List userIds) { + List basePopulationInfoCountPOS = basePopulationInfoService.listPopulationSaveCountByUserIds(userIds); + Map map = new HashMap<>(); + basePopulationInfoCountPOS.forEach(basePopulationInfoCountPO -> { + map.put(basePopulationInfoCountPO.getUserId(), basePopulationInfoCountPO.getTotal()); + }); + return map; + } + + public static Map mapPopulationSaveCount(IBasePopulationInfoService basePopulationInfoService, List userIds, String date) { + List basePopulationInfoCountPOS = basePopulationInfoService.listPopulationSaveCountByUserIdsAndDay(userIds, date); + Map map = new HashMap<>(); + basePopulationInfoCountPOS.forEach(basePopulationInfoCountPO -> { + map.put(basePopulationInfoCountPO.getUserId(), basePopulationInfoCountPO.getTotal()); + }); + return map; + } + + public static Map mapPopulationUpdateCount(IBasePopulationInfoService basePopulationInfoService, List userIds, String date) { + List basePopulationInfoCountPOS = basePopulationInfoService.listPopulationUpdateCountByUserIdsAndDay(userIds, date); + Map map = new HashMap<>(); + basePopulationInfoCountPOS.forEach(basePopulationInfoCountPO -> { + map.put(basePopulationInfoCountPO.getUserId(), basePopulationInfoCountPO.getTotal()); + }); + return map; + } + + +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 8065a77..a909316 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,6 +1,6 @@ server: port: 8087 - url: http://192.168.0.111:8087/bigdata + url: http://192.168.0.15:8087/bigdata title: bigdata servlet: context-path: /bigdata @@ -20,11 +20,20 @@ spring: max-request-size: 1GB datasource: druid: - url: jdbc:mysql://127.0.0.1:3306/db_bigdata?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false - db-type: mysql - driver-class-name: com.mysql.jdbc.Driver - username: root - password: 123456 + db1: + url: jdbc:mysql://192.168.0.151:3306/db_btgxq_bigdata?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false + db-type: mysql + driver-class-name: com.mysql.jdbc.Driver + username: root + password: root + mapper-locations: classpath*:mybatis/mapper/**/*.xml + db2: + url: jdbc:mysql://192.168.0.151:3306/db_btgxq_city?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false + db-type: mysql + driver-class-name: com.mysql.jdbc.Driver + username: root + password: root + mapper-locations: classpath*:mybatis/db2-mapper/**/*.xml initial-size: 2 min-idle: 2 max-active: 5 @@ -61,7 +70,7 @@ swagger: # 文件 file: - uploadPath: /Users/wenc/Desktop/filetest + uploadPath: C:\Users\TS-QD1\Desktop\UploadFiles\ imageTypes: png,jpg,jpeg,gif,blob videoTypes: mp4 audioTypes: mp3,wav,amr @@ -71,14 +80,11 @@ file: # 安全 security: oauth2: - # oauth-server: http://192.168.0.103:7001/usercenter - oauth-server: http://49.233.36.36:8868/usercenter + oauth-server: http://192.168.0.15:7021/usercenter oauth-logout: ${security.oauth2.oauth-server}/logout?redirect_uri=${server.url} client: - client-id: 23ee73bf31b54084b2eb977d58435be0 - client-secret: dnljSTJGLzdWSjBudTNyV2MxUXNudStsbndpMFpwbHRKRnlzRkFjNTgrVW1ac2wwZTJHWk5NbXh3L3h3U2c4Rg== - # client-id: 26c7aaa37d0f4137a0b4d3bd696d2afd - # client-secret: QWZXc0kvVzd2eXlaMXRYdUFlUVFUb2x4K1Y3Um1jNnFQSklZSkNFZ3lXQW1ac2wwZTJHWk5NbXh3L3h3U2c4Rg== + client-id: cc7dbe7d6d034b0e93a41f9256723ce3 + client-secret: eWJDNTUxN3Q0QU0wVHhmbGROM1hmZzFwdFlyQUxPa1E4bWtkL01PVGVuc21ac2wwZTJHWk5NbXh3L3h3U2c4Rg== user-authorization-uri: ${security.oauth2.oauth-server}/oauth_client/authorize access-token-uri: ${security.oauth2.oauth-server}/oauth_client/token grant-type: authorization_code @@ -96,7 +102,8 @@ api-path: # 访问控制 access-control: pass-paths: - - /index.html + - /old.html + - /old.html - /logout.html - /default.html - /assets/** @@ -121,6 +128,7 @@ access-control: logging: level: root: error + org.mybatis: debug com.cm: debug # 访问其他项目 @@ -131,8 +139,8 @@ server-other: # servicecity-url: http://192.168.0.111:8084/servicecity # party-url: http://192.168.0.111:8085/partybuilding # servicecity-url: http://192.168.0.109:8083/servicecity - servicecity-url: http://219.147.99.164:8082/servicecity - deptassesst-Url: http://219.147.99.164:8082/servicecity + servicecity-url: http://192.168.0.15:7022/servicecity + deptassesst-Url: http://192.168.0.15:7022/servicecity party-url: http://219.147.99.164:8082/partybuilding logo-url: http://219.147.99.164:8082/partybuilding population-url: http://219.147.99.164:8082/population diff --git a/src/main/resources/mybatis/db2-mapper/kpi/base-population-info.xml b/src/main/resources/mybatis/db2-mapper/kpi/base-population-info.xml new file mode 100644 index 0000000..49ef323 --- /dev/null +++ b/src/main/resources/mybatis/db2-mapper/kpi/base-population-info.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/db2-mapper/kpi/community-boss-mapper.xml b/src/main/resources/mybatis/db2-mapper/kpi/community-boss-mapper.xml new file mode 100644 index 0000000..194c7f6 --- /dev/null +++ b/src/main/resources/mybatis/db2-mapper/kpi/community-boss-mapper.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/db2-mapper/kpi/user-location-mapper.xml b/src/main/resources/mybatis/db2-mapper/kpi/user-location-mapper.xml new file mode 100644 index 0000000..e263a72 --- /dev/null +++ b/src/main/resources/mybatis/db2-mapper/kpi/user-location-mapper.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/db2-mapper/kpi/user-sign-mapper.xml b/src/main/resources/mybatis/db2-mapper/kpi/user-sign-mapper.xml new file mode 100644 index 0000000..b909969 --- /dev/null +++ b/src/main/resources/mybatis/db2-mapper/kpi/user-sign-mapper.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/kpi/kpi-mapper.xml b/src/main/resources/mybatis/mapper/kpi/kpi-mapper.xml new file mode 100644 index 0000000..97b7f01 --- /dev/null +++ b/src/main/resources/mybatis/mapper/kpi/kpi-mapper.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + INSERT INTO kpi_community_boss_${level}_day_count( + user_id, + day_date, + is_signin, + is_signin_late, + is_signout, + is_signout_early, + work_distance, + population_count, + save_population_count, + update_population_count + ) VALUES ( + #{userId}, + #{dayDate}, + #{isSignin}, + #{isSigninLate}, + #{isSignout}, + #{isSignoutEarly}, + #{workDistance}, + #{populationCount}, + #{savePopulationCount}, + #{updatePopulationCount} + ) + + + + + DELETE FROM + kpi_community_boss_${level}_day_count + WHERE + day_date = #{dayDate} + + + + + UPDATE + kpi_community_boss_${level}_day_count + SET + is_signin = #{isSignin}, + is_signin_late = #{isSigninLate}, + is_signout = #{isSignout}, + is_signout_early = #{isSignoutEarly}, + work_distance = #{workDistance}, + save_population_count = #{savePopulationCount}, + update_population_count = #{updatePopulationCount} + WHERE + user_id = #{userId} + AND + day_date = #{dayDate} + + + + + + \ No newline at end of file