处理统计页面报错问题

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>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<version>1.18.24</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

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

View File

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