处理统计页面报错问题

This commit is contained in:
wanggeng 2022-12-25 16:41:36 +08:00
parent b7b58ab7bc
commit 2f44e2a77f
3 changed files with 53 additions and 42 deletions

View File

@ -152,7 +152,8 @@
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.16.18</version> <version>1.18.24</version>
<scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -103,45 +103,45 @@ public class DefaultHomePageAppController extends DefaultBaseController {
} }
@GetMapping("release/gender-age") @GetMapping("release/gender-age")
public Object getGenderAge() throws SearchException{ public Object getGenderAge() throws SearchException {
Map<String, Object> params = requestParams(); Map<String, Object> params = requestParams();
List<BasePopulationInfoDTO> population = basePopulationInfoService.listBasePopulationInfo(params); List<BasePopulationInfoDTO> population = basePopulationInfoService.listBasePopulationInfo(params);
Integer[] man = {0,0,0,0,0}; Integer[] man = {0, 0, 0, 0, 0};
Integer[] woMan = {0,0,0,0,0}; Integer[] woMan = {0, 0, 0, 0, 0};
for(BasePopulationInfoDTO item : population ){ for (BasePopulationInfoDTO item : population) {
String gender = IdCardVerifyUtil.getIdCardGender(item.getIdCardNumber()); String gender = IdCardVerifyUtil.getIdCardGender(item.getIdCardNumber());
Integer age = IdCardVerifyUtil.getAgeFromIdCardNumber(item.getIdCardNumber()); Integer age = IdCardVerifyUtil.getAgeFromIdCardNumber(item.getIdCardNumber());
if("1".equals(gender)){ if ("1".equals(gender)) {
if(age < 20){ if (age < 20) {
man[0]++; man[0]++;
} }
if(age >= 20 && age <30){ if (age >= 20 && age < 30) {
man[1]++; man[1]++;
} }
if(age >=30 && age < 45){ if (age >= 30 && age < 45) {
man[2]++; man[2]++;
} }
if(age >= 45 && age < 55){ if (age >= 45 && age < 55) {
man[3]++; man[3]++;
} }
if(age >= 55){ if (age >= 55) {
man[4]++; man[4]++;
} }
} }
if("0".equals(gender)){ if ("0".equals(gender)) {
if(age < 20){ if (age < 20) {
woMan[0]++; woMan[0]++;
} }
if(age >= 20 && age <30){ if (age >= 20 && age < 30) {
woMan[1]++; woMan[1]++;
} }
if(age >=30 && age < 45){ if (age >= 30 && age < 45) {
woMan[2]++; woMan[2]++;
} }
if(age >= 45 && age < 55){ if (age >= 45 && age < 55) {
woMan[3]++; woMan[3]++;
} }
if(age >= 55){ if (age >= 55) {
woMan[4]++; woMan[4]++;
} }
} }
@ -158,17 +158,17 @@ public class DefaultHomePageAppController extends DefaultBaseController {
Map<String, Object> query = new HashMap<>(8); Map<String, Object> query = new HashMap<>(8);
List<String> areaNames = new ArrayList<>(); List<String> areaNames = new ArrayList<>();
List<Integer> counts = new ArrayList<>(); List<Integer> counts = new ArrayList<>();
for (AreaDTO item : area){ for (AreaDTO item : area) {
String areaCoed = item.getAreaCode(); String areaCoed = item.getAreaCode();
String[] areaCodeSplit = IdCardVerifyUtil.splitStringByLength(areaCoed, 2); String[] areaCodeSplit = IdCardVerifyUtil.splitStringByLength(areaCoed, 2);
String areaCodeLike = ""; String areaCodeLike = "";
for(int i = 5 ; i >= 0; i--){ for (int i = 5; i >= 0; i--) {
if(!"00".equals(areaCodeSplit[i])){ if (!"00".equals(areaCodeSplit[i])) {
areaCodeLike = areaCoed.substring(0, (i + 1) * 2 ); areaCodeLike = areaCoed.substring(0, (i + 1) * 2);
break; break;
} }
} }
query.put("areaCodeLike",areaCodeLike); query.put("areaCodeLike", areaCodeLike);
List<BasePopulationInfoDTO> areaPeopleList = basePopulationInfoService.listBasePopulationInfo(query); List<BasePopulationInfoDTO> areaPeopleList = basePopulationInfoService.listBasePopulationInfo(query);
areaNames.add(item.getAreaName()); areaNames.add(item.getAreaName());
counts.add(areaPeopleList.size()); counts.add(areaPeopleList.size());
@ -180,19 +180,20 @@ public class DefaultHomePageAppController extends DefaultBaseController {
} }
@GetMapping("release/get-education") @GetMapping("release/get-education")
public Object getEducation() throws SearchException{ public Object getEducation() throws SearchException {
Map<String, Object> params = requestParams(); Map<String, Object> params = requestParams();
List<Map<String, Object>> list = basePopulationInfoService.getDefaultPageEducation(params); List<Map<String, Object>> list = basePopulationInfoService.getDefaultPageEducation(params);
if(list == null || list.size() == 0) { if (list == null || list.size() == 0) {
return new HashMap<>(0); return new HashMap<>(0);
} }
List<String> educationName = new ArrayList<>(); List<String> educationName = new ArrayList<>();
List<Integer> counts = new ArrayList<>(); List<Integer> counts = new ArrayList<>();
for(int i = 0; i < 10; i++){ int countsSize = Math.min(list.size(), 10);
for (int i = 0; i < countsSize; i++) {
Map<String, Object> item = list.get(i); Map<String, Object> item = list.get(i);
String educationId = item.get("education").toString(); String educationId = item.get("education").toString();
DataDTO dataDTO = mongoDataService.get(educationId); DataDTO dataDTO = mongoDataService.get(educationId);
if(dataDTO == null){ if (dataDTO == null) {
continue; continue;
} }
educationName.add(dataDTO.getDataName()); educationName.add(dataDTO.getDataName());
@ -205,19 +206,20 @@ public class DefaultHomePageAppController extends DefaultBaseController {
} }
@GetMapping("release/get-nation") @GetMapping("release/get-nation")
public Object getNation() throws SearchException{ public Object getNation() throws SearchException {
Map<String, Object> params = requestParams(); Map<String, Object> params = requestParams();
List<Map<String, Object>> list = basePopulationInfoService.getDefaultPageNation(params); List<Map<String, Object>> list = basePopulationInfoService.getDefaultPageNation(params);
if(list == null || list.size() == 0) { if (list == null || list.size() == 0) {
return new HashMap<>(0); return new HashMap<>(0);
} }
List<String> nationName = new ArrayList<>(); List<String> nationName = new ArrayList<>();
List<Integer> counts = new ArrayList<>(); List<Integer> counts = new ArrayList<>();
for(int i = 0; i < 9; i++){ int countSize = Math.min(list.size(), 10);
for (int i = 0; i < countSize; i++) {
Map<String, Object> item = list.get(i); Map<String, Object> item = list.get(i);
String nationId = item.get("nation").toString(); String nationId = item.get("nation").toString();
DataDTO dataDTO = mongoDataService.get(nationId); DataDTO dataDTO = mongoDataService.get(nationId);
if(dataDTO == null){ if (dataDTO == null) {
continue; continue;
} }
nationName.add(dataDTO.getDataName()); nationName.add(dataDTO.getDataName());

View File

@ -1,11 +1,12 @@
server: server:
port: 8080 port: 8080
url: http://192.168.0.109:8080/population url: http://127.0.0.1:8080/population
system-title: 人口信息平台 system-title: 人口信息平台
system-sub-title: 人口信息平台 system-sub-title: 人口信息平台
default-home-page: default.html default-home-page: default.html
servlet: servlet:
context-path: /population context-path: /population
# nav-page: http://121.36.71.250:58011/usercenter
nav-page: http://192.168.0.155:7011/usercenter nav-page: http://192.168.0.155:7011/usercenter
spring: spring:
@ -27,11 +28,11 @@ spring:
max-request-size: 1GB max-request-size: 1GB
datasource: datasource:
druid: druid:
url: jdbc:mysql://127.0.0.1:3306/db_cloud_population_v2?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=UTC url: jdbc:mysql://192.168.0.151:3306/db_smart_city_population?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=UTC
db-type: mysql db-type: mysql
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
username: root username: root
password: 123456 password: root
initial-size: 2 initial-size: 2
min-idle: 2 min-idle: 2
max-active: 5 max-active: 5
@ -54,11 +55,14 @@ spring:
use-global-data-source-stat: true use-global-data-source-stat: true
data: data:
mongodb: mongodb:
uri: mongodb://smartcity:smartcity@192.168.0.156:27017/smartcity # uri: mongodb://smartcity:smartcity@121.36.71.250:58022/smartcity
uri: mongodb://smartcity:smartcity@192.168.0.156:27017/smartcity
redis: redis:
database: 6 database: 6
host: 192.168.0.156 # host: 192.168.0.156
port: 6379 host: 121.36.71.250
# port: 6379
port: 58021
password: 666 password: 666
timeout: 3000ms timeout: 3000ms
jedis: jedis:
@ -68,7 +72,8 @@ spring:
max-idle: 8 max-idle: 8
min-idle: 0 min-idle: 0
kafka: kafka:
bootstrap-servers: 192.168.0.156:9093 # bootstrap-servers: 121.36.71.250:58025
bootstrap-servers: 192.168.0.156:9092
producer: producer:
# 写入失败时重试次数。当leader节点失效一个repli节点会替代成为leader节点此时可能出现写入失败 # 写入失败时重试次数。当leader节点失效一个repli节点会替代成为leader节点此时可能出现写入失败
# 当retris为0时produce不会重复。retirs重发此时repli节点完全成为leader节点不会产生消息丢失。 # 当retris为0时produce不会重复。retirs重发此时repli节点完全成为leader节点不会产生消息丢失。
@ -92,13 +97,14 @@ spring:
# 安全 # 安全
security: security:
oauth2: oauth2:
# oauth-server: http://121.36.71.250:58011/usercenter
oauth-server: http://192.168.0.155:7011/usercenter oauth-server: http://192.168.0.155:7011/usercenter
oauth-logout: ${security.oauth2.oauth-server}/logout?redirect_uri=${server.url} oauth-logout: ${security.oauth2.oauth-server}/logout?redirect_uri=${server.url}
client: client:
#client-id: c00491da506842ddb516d4b1e5ccd13e #client-id: c00491da506842ddb516d4b1e5ccd13e
client-id: 5bc261e8e21c40a4aade918ba12299c1 client-id: c2db96771c144803afbfedea1bfd11f7
#client-secret: bll3ZVZuUGZsSXBqckJjRVNEMkc3bklic0pOZDYyWkk0SFd2eDY3N3dhUGxIdG9KZmEyTjJIRnI0dG1McEdEVA== #client-secret: bll3ZVZuUGZsSXBqckJjRVNEMkc3bklic0pOZDYyWkk0SFd2eDY3N3dhUGxIdG9KZmEyTjJIRnI0dG1McEdEVA==
client-secret: a0oweWNraWNQRkprcDY4NURKKzFtSktOV08vUS9sclBxY0JmRStNNkNKN2xIdG9KZmEyTjJIRnI0dG1McEdEVA== client-secret: b3VwVndUU1BFbVNnOU1vSnRYTFJ1VTdieFdDRGZZVkhRdTJ2MFVxYytTRGxIdG9KZmEyTjJIRnI0dG1McEdEVA==
user-authorization-uri: ${security.oauth2.oauth-server}/oauth2_client/authorize user-authorization-uri: ${security.oauth2.oauth-server}/oauth2_client/authorize
access-token-uri: ${security.oauth2.oauth-server}/oauth2_client/token access-token-uri: ${security.oauth2.oauth-server}/oauth2_client/token
grant-type: authorization_code grant-type: authorization_code
@ -110,6 +116,7 @@ security:
authorization: authorization:
check-token-access: ${security.oauth2.oauth-server}/oauth2_client/token_key check-token-access: ${security.oauth2.oauth-server}/oauth2_client/token_key
api-path: api-path:
# user-center: http://121.36.71.250:58011/usercenter
user-center: http://192.168.0.155:7011/usercenter user-center: http://192.168.0.155:7011/usercenter
# 数据库 # 数据库
@ -128,7 +135,7 @@ swagger:
# 文件 # 文件
file: file:
# 文件的保存路径 # 文件的保存路径
upload-path: D:/ideaWorkspace/uploadfiles/population upload-path: /Users/wanggeng/Desktop/UploadFiles/
# 图片类型 # 图片类型
image-types: png,jpg,jpeg,gif,blob image-types: png,jpg,jpeg,gif,blob
# 视频类型 # 视频类型
@ -159,13 +166,14 @@ file:
use-min-io: true use-min-io: true
# 与use-min-io配套使用 # 与use-min-io配套使用
min-io: min-io:
endpoint: http://192.168.0.156:19001 # endpoint: http://121.36.71.250:58023
endpoint: http://192.168.0.156:19000
access-key: minioadmin access-key: minioadmin
secret-key: minioadmin secret-key: minioadmin
# 日志 # 日志
logging: logging:
file: file:
name: D:/ideaWorkspace/uploadfiles/population.log name: /Users/wanggeng/Desktop/UploadFiles/logs/population.log
level: level:
root: error root: error
ink.wgink: debug ink.wgink: debug