|
@@ -27,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.sql.Date;
|
|
|
+import java.sql.Timestamp;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
@@ -34,10 +35,10 @@ import java.util.Map;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import static com.boman.common.core.utils.StringUtils.isNotEmpty;
|
|
|
-import static com.boman.common.core.utils.fieldTranslator.IdCardUtils.getAge;
|
|
|
import static com.boman.common.core.utils.fieldTranslator.IdCardUtils.getSex;
|
|
|
import static com.boman.common.core.utils.obj.ObjectUtils.*;
|
|
|
import static com.boman.common.redis.RedisKey.STS_CZRK_;
|
|
|
+import static com.boman.web.core.utils.IdCardUtils.getAge;
|
|
|
import static com.google.common.base.Strings.nullToEmpty;
|
|
|
|
|
|
/**
|
|
@@ -459,10 +460,8 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
|
Long deptId = sysUser.getDeptId(); // 当前登陆人的deptId
|
|
|
result.put("dqdw", sysUser.getDept().getDeptName()); // 当前单位
|
|
|
|
|
|
- Czrk condition = new Czrk();
|
|
|
- condition.setStartTime(DateUtils.getTodayStartStr());
|
|
|
- condition.setEndTime(DateUtils.getTodayEndStr());
|
|
|
- condition.setIsRl("是");
|
|
|
+ String startTime = DateUtils.getTodayStartStr();
|
|
|
+ String endTime = DateUtils.getTodayEndStr();
|
|
|
|
|
|
// 市领导
|
|
|
List<String> roleKeySets = map(sysUser.getRoles(), SysRole::getRoleKey);
|
|
@@ -474,6 +473,7 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
|
}
|
|
|
|
|
|
ThreadPoolService.execute(() -> {
|
|
|
+ Long areaId = 340882000000L;
|
|
|
List<SysDept> allDepts = remoteDeptService.listChildrenDepts(1L);
|
|
|
List<SysDept> townsDepts = new ArrayList<>(16);
|
|
|
for (SysDept allDept : allDepts) {
|
|
@@ -493,8 +493,8 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- result.put("cun", isEmpty(cunDepts) ? 0 : cunDepts.size());
|
|
|
-
|
|
|
+ result.put("cun", isEmpty(cunDepts) ? 0 : cunDepts.size()); //村
|
|
|
+//
|
|
|
List<SysDept> zuDept = new ArrayList<>(16);
|
|
|
for (SysDept cunDept : cunDepts) {
|
|
|
for (SysDept allDept : allDepts) {
|
|
@@ -505,19 +505,40 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
|
}
|
|
|
|
|
|
result.put("zu", isEmpty(zuDept) ? 0 : zuDept.size()); // 组
|
|
|
- int czrk = czrkMapper.countCzrk(condition); // 常住人口
|
|
|
- result.put("czrk", czrk);
|
|
|
-
|
|
|
- int xz = czrkMapper.countByXz(condition); // 新增
|
|
|
- int js = czrkMapper.countByJs(condition);// 减少
|
|
|
- result.put("xz", xz);
|
|
|
- result.put("js", js);
|
|
|
-
|
|
|
- condition.setIsRl(null); // 查全部
|
|
|
- int zrs = czrkMapper.countCzrk(condition);
|
|
|
- String bfb = NumberUtils.percent(czrk, zrs);
|
|
|
- result.put("bfb", bfb);
|
|
|
+
|
|
|
+ // 常住人口信息 areaId 为潜山市的为常住人口
|
|
|
+ int type = 3;
|
|
|
+ int czzrs = czrkMapper.countCzrk(type, areaId); // 常住人口
|
|
|
+ result.put("czzrs", czzrs);
|
|
|
+
|
|
|
+ int czxz = czrkMapper.countByCzXz(startTime, endTime, type, areaId); // 新增
|
|
|
+ int czjs = czrkMapper.countByCzJs(startTime, endTime, type, areaId);// 减少
|
|
|
+ result.put("czxz", czxz);
|
|
|
+ result.put("czjs", czjs);
|
|
|
+
|
|
|
+ // condition.setIsRl(null); // 查全部
|
|
|
+ type = 0;
|
|
|
+ int zrs = czrkMapper.countCzrk(type, areaId);
|
|
|
+ String czbfb = NumberUtils.percent(czzrs, zrs);
|
|
|
+ result.put("czbfb", czbfb);
|
|
|
result.put("zrs", zrs);
|
|
|
+
|
|
|
+ // 户籍人口信息
|
|
|
+ // 户籍总人数
|
|
|
+ List<Czrk> hjzrsList = czrkMapper.countHj(startTime, endTime, type, areaId);
|
|
|
+ int hjzrs= isEmpty(hjzrsList) ? 0 : hjzrsList.size();
|
|
|
+ result.put("hjzrs", hjzrs);
|
|
|
+
|
|
|
+ // 户籍人口信息 新增 减少
|
|
|
+ type = 3; // regionId
|
|
|
+ List<Czrk> hjxzs = czrkMapper.countByHjXz(startTime, endTime, type, areaId); // 新增
|
|
|
+ List<Czrk> hjjss = czrkMapper.countByHjJs(startTime, endTime, type, areaId);// 减少
|
|
|
+ result.put("hjxz", isEmpty(hjxzs) ? 0 : hjxzs.size());
|
|
|
+ result.put("hjjs", isEmpty(hjjss) ? 0 : hjjss.size());
|
|
|
+
|
|
|
+ // 户籍人口信息 百分比
|
|
|
+ String hjbfb = NumberUtils.percent(hjzrs, zrs);
|
|
|
+ result.put("hjbfb", hjbfb);
|
|
|
setIntoRedis(packRedisKey("single:" + deptId), result);
|
|
|
QIANSHANSHI_SINGEL = result;
|
|
|
});
|
|
@@ -529,7 +550,7 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
- townSts(result, condition, deptId, sysUser.getDept().getDeptName(), true);
|
|
|
+ townSts(result, deptId, sysUser.getDept().getDeptName(), true);
|
|
|
// redisService.setCacheObject(packRedisKey("town:" + deptId), result, 1L, TimeUnit.DAYS);
|
|
|
setIntoRedis(packRedisKey("town:" + deptId), result);
|
|
|
}
|
|
@@ -553,10 +574,8 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
|
|
|
|
List<String> roleKeySets = map(sysUser.getRoles(), SysRole::getRoleKey);
|
|
|
|
|
|
- Czrk condition = new Czrk();
|
|
|
- condition.setStartTime(DateUtils.getTodayStartStr());
|
|
|
- condition.setEndTime(DateUtils.getTodayEndStr());
|
|
|
- condition.setIsRl("是");
|
|
|
+ String todayStart = DateUtils.getTodayStartStr();
|
|
|
+ String todayEnd = DateUtils.getTodayEndStr();
|
|
|
Long deptId = sysUser.getDeptId();
|
|
|
|
|
|
// 市领导 todo 此处不应该写死
|
|
@@ -568,6 +587,7 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
|
}
|
|
|
|
|
|
ThreadPoolService.execute(() -> {
|
|
|
+ Long areaId = 340882000000L;
|
|
|
List<SysDept> allDepts = remoteDeptService.listChildrenDepts(1L);
|
|
|
List<SysDept> townsDepts = new ArrayList<>(16);
|
|
|
for (SysDept allDept : allDepts) {
|
|
@@ -589,35 +609,45 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
|
}
|
|
|
result.put("cun", isEmpty(cunDepts) ? 0 : cunDepts.size());
|
|
|
|
|
|
- List<SysDept> zuDept = new ArrayList<>(16);
|
|
|
- for (SysDept cunDept : cunDepts) {
|
|
|
- for (SysDept allDept : allDepts) {
|
|
|
- if (cunDept.getId().equals(allDept.getParentId())) {
|
|
|
- zuDept.add(allDept);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- result.put("zu", isEmpty(zuDept) ? 0 : zuDept.size()); // 组
|
|
|
- int czrk = czrkMapper.countCzrk(condition); // 常住人口
|
|
|
- result.put("czrk", czrk);
|
|
|
-
|
|
|
- int xz = czrkMapper.countByXz(condition); // 新增
|
|
|
- int js = czrkMapper.countByJs(condition);// 减少
|
|
|
- result.put("xz", xz);
|
|
|
- result.put("js", js);
|
|
|
-
|
|
|
- condition.setIsRl(null); // 查全部
|
|
|
- int zrs = czrkMapper.countCzrk(condition);
|
|
|
- String bfb = NumberUtils.percent(czrk, zrs);
|
|
|
- result.put("bfb", bfb);
|
|
|
+ // 常住人口信息 areaId 为潜山市的为常住人口
|
|
|
+ int type = 3;
|
|
|
+ int czzrs = czrkMapper.countCzrk(type, areaId); // 常住人口
|
|
|
+ result.put("czzrs", czzrs);
|
|
|
+
|
|
|
+ int czxz = czrkMapper.countByCzXz(todayStart, todayEnd, type, areaId); // 新增
|
|
|
+ int czjs = czrkMapper.countByCzJs(todayStart, todayEnd, type, areaId);// 减少
|
|
|
+ result.put("czxz", czxz);
|
|
|
+ result.put("czjs", czjs);
|
|
|
+
|
|
|
+ // condition.setIsRl(null); // 查全部
|
|
|
+ type = 0;
|
|
|
+ int zrs = czrkMapper.countCzrk(type, areaId);
|
|
|
+ String czbfb = NumberUtils.percent(czzrs, zrs);
|
|
|
+ result.put("czbfb", czbfb);
|
|
|
result.put("zrs", zrs);
|
|
|
|
|
|
+ // 户籍人口信息
|
|
|
+ // 户籍总人数
|
|
|
+ List<Czrk> hjzrsList = czrkMapper.countHj(todayStart, todayEnd, type, areaId);
|
|
|
+ int hjzrs= isEmpty(hjzrsList) ? 0 : hjzrsList.size();
|
|
|
+ result.put("hjzrs", hjzrs);
|
|
|
+
|
|
|
+ // 户籍人口信息 新增 减少
|
|
|
+ type = 3; // regionId
|
|
|
+ List<Czrk> hjxzs = czrkMapper.countByHjXz(todayStart, todayEnd, type, areaId); // 新增
|
|
|
+ List<Czrk> hjjss = czrkMapper.countByHjJs(todayStart, todayEnd, type, areaId);// 减少
|
|
|
+ result.put("hjxz", isEmpty(hjxzs) ? 0 : hjxzs.size());
|
|
|
+ result.put("hjjs", isEmpty(hjjss) ? 0 : hjjss.size());
|
|
|
+
|
|
|
+ // 户籍人口信息 百分比
|
|
|
+ String hjbfb = NumberUtils.percent(hjzrs, zrs);
|
|
|
+ result.put("hjbfb", hjbfb);
|
|
|
+
|
|
|
// 以各个镇为单位单独处理 townsDepts
|
|
|
ArrayList<JSONObject> towsDataList = new ArrayList<>(20);
|
|
|
for (SysDept townsDept : townsDepts) {
|
|
|
JSONObject townsResult = new JSONObject(16);
|
|
|
- townSts(townsResult, condition, townsDept.getId(), townsDept.getDeptName(), false);
|
|
|
+ townSts(townsResult, townsDept.getId(), townsDept.getDeptName(), false);
|
|
|
towsDataList.add(townsResult);
|
|
|
}
|
|
|
|
|
@@ -636,7 +666,7 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
|
}
|
|
|
|
|
|
ThreadPoolService.execute(() -> {
|
|
|
- townSts(result, condition, deptId, deptName, true);
|
|
|
+ townSts(result, deptId, deptName, true);
|
|
|
// redisService.setCacheObject(packRedisKey("town:" + deptId), result, 1L, TimeUnit.DAYS);
|
|
|
setIntoRedis(packRedisKey("town:" + deptId), result);
|
|
|
});
|
|
@@ -647,31 +677,10 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 根据身份证号查询用户信息
|
|
|
- * @param czrk
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Override
|
|
|
- public Czrk findHjInfo(Czrk czrk) {
|
|
|
- Czrk hjInfo = czrkMapper.findHjInfo(czrk);
|
|
|
- if (hjInfo == null) {
|
|
|
- String idCard = czrk.getIdCard();
|
|
|
- if (StringUtils.isNotBlank(idCard)) {
|
|
|
- //根据身份证提取出生日和性别,年龄
|
|
|
- String sex = getSex(idCard);
|
|
|
- Integer age = getAge(idCard);
|
|
|
- String birthday = IdCardUtils.getBirthday(idCard);
|
|
|
- czrk.setAge(age);
|
|
|
- czrk.setGender(sex);
|
|
|
- czrk.setBirthday(birthday);
|
|
|
- return czrk;
|
|
|
- }
|
|
|
- }
|
|
|
- return hjInfo;
|
|
|
- }
|
|
|
-
|
|
|
- private void townSts(JSONObject result, Czrk condition, Long deptId, String deptName, boolean percent) {
|
|
|
+ private void townSts(JSONObject result, Long deptId, String deptName, boolean percent) {
|
|
|
+ String startTime = DateUtils.getTodayStartStr();
|
|
|
+ String endTime = DateUtils.getTodayEndStr();
|
|
|
+ Long areaId = deptId;
|
|
|
// 乡镇以下的所有部门
|
|
|
List<SysDept> depts = remoteDeptService.listChildrenDepts(deptId);
|
|
|
List<SysDept> cunDepts = new ArrayList<>(16);
|
|
@@ -693,23 +702,112 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
|
}
|
|
|
|
|
|
result.put("zu", isEmpty(zuDept) ? 0 : zuDept.size());
|
|
|
- condition.setDeptIdList(map(depts, SysDept::getId));
|
|
|
- int czrk = czrkMapper.countCzrk(condition);
|
|
|
- result.put("czrk", czrk);
|
|
|
|
|
|
+ // 常住人口信息 areaId 为潜山市的为常住人口
|
|
|
+ int type = 0;
|
|
|
+ int czzrs = czrkMapper.countCzrk(type, areaId); // 常住人口
|
|
|
+ result.put("czzrs", czzrs);
|
|
|
+
|
|
|
+ int zrs = 0;
|
|
|
// 常住人口占总人口的百分比
|
|
|
if (BooleanUtils.isTrue(percent)) {
|
|
|
- condition.setIsRl(null); // 查全部
|
|
|
- int zrs = czrkMapper.countCzrk(condition);
|
|
|
- String bfb = NumberUtils.percent(czrk, zrs);
|
|
|
- result.put("bfb", bfb);
|
|
|
+ // 查全部
|
|
|
+ zrs = czrkMapper.countCzrk(type, areaId);
|
|
|
+ String czbfb = NumberUtils.percent(czzrs, zrs);
|
|
|
+ result.put("czbfb", czbfb);
|
|
|
}
|
|
|
|
|
|
- int xz = czrkMapper.countByXz(condition);
|
|
|
- int js = czrkMapper.countByJs(condition);
|
|
|
- result.put("xz", xz);
|
|
|
- result.put("js", js);
|
|
|
+ type = 4;
|
|
|
+ int czxz = czrkMapper.countByCzXz(startTime, endTime, type, areaId);
|
|
|
+ int czjs = czrkMapper.countByCzJs(startTime, endTime, type, areaId);
|
|
|
+ result.put("czxz", czxz);
|
|
|
+ result.put("czjs", czjs);
|
|
|
+
|
|
|
result.put("zhen", deptName);
|
|
|
+
|
|
|
+ // 户籍人口信息
|
|
|
+ List<Czrk> hjxzs = czrkMapper.countByHjXz(startTime, endTime, type, areaId); // 新增
|
|
|
+ List<Czrk> hjjss = czrkMapper.countByHjJs(startTime, endTime, type, areaId);// 减少
|
|
|
+ result.put("hjxz", isEmpty(hjxzs) ? 0 : hjxzs.size());
|
|
|
+ result.put("hjjs", isEmpty(hjjss) ? 0 : hjjss.size());
|
|
|
+
|
|
|
+ // 户籍总人数
|
|
|
+ List<Czrk> hjzrsList = czrkMapper.countHj(startTime, endTime, type, areaId);
|
|
|
+ int hjzrs= isEmpty(hjzrsList) ? 0 : hjzrsList.size();
|
|
|
+ result.put("hjzrs", hjzrs);
|
|
|
+ String hjbfb = NumberUtils.percent(hjzrs, zrs);
|
|
|
+ result.put("hjbfb", hjbfb);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject hjczLine() {
|
|
|
+ // 统计范围 从今天往前推7天
|
|
|
+ java.util.Date startTimeDate = DateUtils.getTodayStart(), endTimeDate = DateUtils.addDays(startTimeDate, -7);
|
|
|
+ String startTime = DateUtils.dateTime1(startTimeDate), endTime = DateUtils.dateTime1(endTimeDate);
|
|
|
+ SysUser sysUser = AuthUtils.getLoginUser().getSysUser();
|
|
|
+ int type = 0;
|
|
|
+ Long areaId = null;
|
|
|
+
|
|
|
+ // 市领导 todo 此处不应该写死
|
|
|
+ List<String> roleKeySets = map(sysUser.getRoles(), SysRole::getRoleKey);
|
|
|
+ if (roleKeySets.contains("city") || roleKeySets.contains("admin") || roleKeySets.contains("yanshi")) {
|
|
|
+ type = 3;
|
|
|
+ areaId = 340882000000L;
|
|
|
+ } else if (roleKeySets.contains("sys:town")) {
|
|
|
+ type = 4;
|
|
|
+ areaId = sysUser.getDeptId();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> dateList = DateUtils.splitDate(startTimeDate, endTimeDate);
|
|
|
+
|
|
|
+ // 常住人口信息
|
|
|
+ List<Czrk> czxzs = czrkMapper.listByCzXz(startTime, endTime, type, areaId);
|
|
|
+ List<Czrk> czjss = czrkMapper.listByCzJs(startTime, endTime, type, areaId);
|
|
|
+
|
|
|
+ // 户籍人口信息
|
|
|
+ List<Czrk> hjxzs = czrkMapper.countByHjXz(startTime, endTime, type, areaId); // 新增
|
|
|
+ List<Czrk> hjjss = czrkMapper.countByHjJs(startTime, endTime, type, areaId);// 减少
|
|
|
+
|
|
|
+// String lastDate = dateList.get(dateList.size() - 1);
|
|
|
+ for (String week : dateList) {
|
|
|
+ JSONObject temp = new JSONObject();
|
|
|
+ temp.put("time", week);
|
|
|
+ for (Czrk czxz : czxzs) {
|
|
|
+ Timestamp createTime = czxz.getCreateTime();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Czrk czjs : czjss) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据身份证号查询用户信息
|
|
|
+ * @param czrk
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Czrk findHjInfo(Czrk czrk) {
|
|
|
+ Czrk hjInfo = czrkMapper.findHjInfo(czrk);
|
|
|
+ if (hjInfo == null) {
|
|
|
+ String idCard = czrk.getIdCard();
|
|
|
+ if (StringUtils.isNotBlank(idCard)) {
|
|
|
+ //根据身份证提取出生日和性别,年龄
|
|
|
+ String sex = getSex(idCard);
|
|
|
+ Integer age = getAge(idCard);
|
|
|
+ String birthday = IdCardUtils.getBirthday(idCard);
|
|
|
+ czrk.setAge(age);
|
|
|
+ czrk.setGender(sex);
|
|
|
+ czrk.setBirthday(birthday);
|
|
|
+ return czrk;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return hjInfo;
|
|
|
}
|
|
|
|
|
|
private String packRedisKey(String deptId) {
|