|
@@ -10,8 +10,10 @@ import com.boman.common.core.utils.obj.ObjectUtils;
|
|
import com.boman.common.core.utils.sql.SqlUtil;
|
|
import com.boman.common.core.utils.sql.SqlUtil;
|
|
import com.boman.common.core.web.page.PageDomain;
|
|
import com.boman.common.core.web.page.PageDomain;
|
|
import com.boman.common.core.web.page.TableSupport;
|
|
import com.boman.common.core.web.page.TableSupport;
|
|
|
|
+import com.boman.common.redis.service.RedisService;
|
|
import com.boman.domain.*;
|
|
import com.boman.domain.*;
|
|
import com.boman.domain.dto.AjaxResult;
|
|
import com.boman.domain.dto.AjaxResult;
|
|
|
|
+import com.boman.domain.utils.ThreadPoolService;
|
|
import com.boman.system.api.RemoteDeptService;
|
|
import com.boman.system.api.RemoteDeptService;
|
|
import com.boman.system.api.RemoteDictDataService;
|
|
import com.boman.system.api.RemoteDictDataService;
|
|
import com.boman.web.core.mapper.StandardlyMapper;
|
|
import com.boman.web.core.mapper.StandardlyMapper;
|
|
@@ -24,6 +26,7 @@ import com.boman.web.core.utils.AuthUtils;
|
|
import com.boman.web.core.utils.IdUtils;
|
|
import com.boman.web.core.utils.IdUtils;
|
|
import com.boman.web.core.utils.VaccineUtils;
|
|
import com.boman.web.core.utils.VaccineUtils;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
+import org.apache.commons.lang3.BooleanUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -37,11 +40,13 @@ import java.sql.Timestamp;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
import static com.boman.common.core.utils.StringUtils.isNotEmpty;
|
|
import static com.boman.common.core.utils.StringUtils.isNotEmpty;
|
|
import static com.boman.common.core.utils.obj.ObjectUtils.*;
|
|
import static com.boman.common.core.utils.obj.ObjectUtils.*;
|
|
|
|
+import static com.boman.common.redis.RedisKey.STS_CZRK_;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 疫苗信息Service业务层处理
|
|
* 疫苗信息Service业务层处理
|
|
@@ -57,6 +62,7 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
|
|
private static final String INSERT = "insert";
|
|
private static final String INSERT = "insert";
|
|
private static final String EDIT = "edit";
|
|
private static final String EDIT = "edit";
|
|
private static final String DELETE = "delete";
|
|
private static final String DELETE = "delete";
|
|
|
|
+ private static JSONObject QIANSHANSHI = null, ZHEN = null, QIANSHANSHI_SINGEL = null;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private VaccineInfoMapper vaccineInfoMapper;
|
|
private VaccineInfoMapper vaccineInfoMapper;
|
|
@@ -72,6 +78,8 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
|
|
private IBaseSaveService saveService;
|
|
private IBaseSaveService saveService;
|
|
@Resource
|
|
@Resource
|
|
private StandardlyMapper standardlyMapper;
|
|
private StandardlyMapper standardlyMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private RedisService redisService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询疫苗信息
|
|
* 查询疫苗信息
|
|
@@ -1173,13 +1181,11 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public JSONObject stsByCzrk() {
|
|
public JSONObject stsByCzrk() {
|
|
- JSONObject result = new JSONObject(6);
|
|
|
|
- // 当前登陆人的deptId
|
|
|
|
|
|
+ JSONObject result = new JSONObject(16);
|
|
SysUser sysUser = AuthUtils.getLoginUser().getSysUser();
|
|
SysUser sysUser = AuthUtils.getLoginUser().getSysUser();
|
|
String deptName = sysUser.getDept().getDeptName();
|
|
String deptName = sysUser.getDept().getDeptName();
|
|
- Long deptId = sysUser.getDeptId();
|
|
|
|
- // 当前单位
|
|
|
|
- result.put("dqdw", deptName);
|
|
|
|
|
|
+ Long deptId = sysUser.getDeptId(); // 当前登陆人的deptId
|
|
|
|
+ result.put("dqdw", deptName); // 当前单位
|
|
|
|
|
|
List<SysRole> roles = sysUser.getRoles();
|
|
List<SysRole> roles = sysUser.getRoles();
|
|
List<String> roleKeySets = map(roles, SysRole::getRoleKey);
|
|
List<String> roleKeySets = map(roles, SysRole::getRoleKey);
|
|
@@ -1188,8 +1194,14 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
|
|
VaccineInfoOperation condition = new VaccineInfoOperation();
|
|
VaccineInfoOperation condition = new VaccineInfoOperation();
|
|
condition.setStartTime(todayStart);
|
|
condition.setStartTime(todayStart);
|
|
condition.setEndTime(todayEnd);
|
|
condition.setEndTime(todayEnd);
|
|
|
|
+ condition.setRyrl(true);
|
|
// 市领导
|
|
// 市领导
|
|
if (roleKeySets.contains("city") || roleKeySets.contains("admin") || roleKeySets.contains("yanshi")) {
|
|
if (roleKeySets.contains("city") || roleKeySets.contains("admin") || roleKeySets.contains("yanshi")) {
|
|
|
|
+ JSONObject jsonObject = redisService.getCacheObject(packRedisKey("single:" + deptId));
|
|
|
|
+ if (isNotEmpty(jsonObject)) {
|
|
|
|
+ return jsonObject;
|
|
|
|
+ }
|
|
|
|
+
|
|
List<SysDept> allDepts = remoteDeptService.listChildrenDepts(1L);
|
|
List<SysDept> allDepts = remoteDeptService.listChildrenDepts(1L);
|
|
List<SysDept> townsDepts = new ArrayList<>(16);
|
|
List<SysDept> townsDepts = new ArrayList<>(16);
|
|
for (SysDept allDept : allDepts) {
|
|
for (SysDept allDept : allDepts) {
|
|
@@ -1220,38 +1232,171 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
result.put("zu", isEmpty(zuDept) ? 0 : zuDept.size());
|
|
result.put("zu", isEmpty(zuDept) ? 0 : zuDept.size());
|
|
|
|
+ int xz = vaccineInfoMapper.countByXz(condition);
|
|
|
|
+ int js = vaccineInfoMapper.countByJs(condition);
|
|
|
|
+ result.put("xz", xz);
|
|
|
|
+ result.put("js", js);
|
|
|
|
+ result.put("czrk", vaccineInfoMapper.countCzrk(condition));
|
|
|
|
+ redisService.setCacheObject(packRedisKey("single:" + deptId), result, 1L, TimeUnit.DAYS);
|
|
} else if (roleKeySets.contains("sys:town")) {
|
|
} else if (roleKeySets.contains("sys:town")) {
|
|
- // 乡镇以下的所有部门
|
|
|
|
- List<SysDept> depts = remoteDeptService.listChildrenDepts(deptId);
|
|
|
|
|
|
+ JSONObject jsonObject = redisService.getCacheObject(packRedisKey("town:" + deptId));
|
|
|
|
+ if (isNotEmpty(jsonObject)) {
|
|
|
|
+ return jsonObject;
|
|
|
|
+ }
|
|
|
|
|
|
- List<SysDept> cunDepts = new ArrayList<>(16);
|
|
|
|
- for (SysDept dept : depts) {
|
|
|
|
- if (isEmpty(dept.getParentId())) continue;
|
|
|
|
- if (deptId.equals(dept.getParentId())) {
|
|
|
|
- cunDepts.add(dept);
|
|
|
|
- }
|
|
|
|
|
|
+ townSts(result, condition, deptId, deptName, true);
|
|
|
|
+ redisService.setCacheObject(packRedisKey("town:" + deptId), result, 1L, TimeUnit.DAYS);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 功能描述: 项目首页统计信息,
|
|
|
|
+ * 当前单位:镇,村:7个,组:300个,常住人口:5000人,新增 2人 减少 2人
|
|
|
|
+ *
|
|
|
|
+ * @return com.boman.domain.dto.AjaxResult
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public JSONObject stsByCzrkHomePage() {
|
|
|
|
+ JSONObject result = new JSONObject(16);
|
|
|
|
+ // 当前登陆人的deptId
|
|
|
|
+ SysUser sysUser = AuthUtils.getLoginUser().getSysUser();
|
|
|
|
+ String deptName = sysUser.getDept().getDeptName();
|
|
|
|
+ result.put("dqdw", deptName); // 当前单位
|
|
|
|
+
|
|
|
|
+ List<String> roleKeySets = map(sysUser.getRoles(), SysRole::getRoleKey);
|
|
|
|
+
|
|
|
|
+ VaccineInfoOperation condition = new VaccineInfoOperation();
|
|
|
|
+ condition.setStartTime(DateUtils.getTodayStartStr());
|
|
|
|
+ condition.setEndTime(DateUtils.getTodayEndStr());
|
|
|
|
+ condition.setRyrl(true);
|
|
|
|
+ Long deptId = sysUser.getDeptId();
|
|
|
|
+
|
|
|
|
+ // 市领导 todo 此处不应该写死
|
|
|
|
+ if (roleKeySets.contains("city") || roleKeySets.contains("admin") || roleKeySets.contains("yanshi")) {
|
|
|
|
+ JSONObject jsonObject = redisService.getCacheObject(packRedisKey(deptId + ""));
|
|
|
|
+ if (isNotEmpty(jsonObject)) {
|
|
|
|
+ QIANSHANSHI = jsonObject;
|
|
|
|
+ return jsonObject;
|
|
}
|
|
}
|
|
- result.put("cun", isEmpty(cunDepts) ? 0 : cunDepts.size());
|
|
|
|
|
|
|
|
- List<SysDept> zuDept = new ArrayList<>(16);
|
|
|
|
- for (SysDept cunDept : cunDepts) {
|
|
|
|
- for (SysDept dept : depts) {
|
|
|
|
- if (cunDept.getId().equals(dept.getParentId())) {
|
|
|
|
- zuDept.add(dept);
|
|
|
|
|
|
+ ThreadPoolService.execute(()->{
|
|
|
|
+ List<SysDept> allDepts = remoteDeptService.listChildrenDepts(1L);
|
|
|
|
+ List<SysDept> townsDepts = new ArrayList<>(16);
|
|
|
|
+ for (SysDept allDept : allDepts) {
|
|
|
|
+ if (isEmpty(allDept.getParentId())) continue;
|
|
|
|
+ if (allDept.getParentId() == (1L)) {
|
|
|
|
+ townsDepts.add(allDept);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ result.put("zhen", townsDepts.size()); // 镇
|
|
|
|
+
|
|
|
|
+ List<SysDept> cunDepts = new ArrayList<>(16);
|
|
|
|
+ for (SysDept townsDept : townsDepts) {
|
|
|
|
+ for (SysDept allDept : allDepts) {
|
|
|
|
+ if (isEmpty(allDept.getParentId())) continue;
|
|
|
|
+ if (townsDept.getId().equals(allDept.getParentId())) {
|
|
|
|
+ cunDepts.add(allDept);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ 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 = vaccineInfoMapper.countCzrk(condition); // 常住人口
|
|
|
|
+ result.put("czrk", czrk);
|
|
|
|
+
|
|
|
|
+ int xz = vaccineInfoMapper.countByXz(condition); // 新增
|
|
|
|
+ int js = vaccineInfoMapper.countByJs(condition);// 减少
|
|
|
|
+ result.put("xz", xz);
|
|
|
|
+ result.put("js", js);
|
|
|
|
+
|
|
|
|
+ condition.setRyrl(null); // 查全部
|
|
|
|
+ int zrs = vaccineInfoMapper.countCzrk(condition);
|
|
|
|
+ String bfb = NumberUtils.percent(czrk, zrs);
|
|
|
|
+ result.put("bfb", bfb);
|
|
|
|
+ result.put("zrs", zrs);
|
|
|
|
+
|
|
|
|
+ // 以各个镇为单位单独处理 townsDepts
|
|
|
|
+ ArrayList<JSONObject> towsDataList = new ArrayList<>(20);
|
|
|
|
+ for (SysDept townsDept : townsDepts) {
|
|
|
|
+ JSONObject townsResult = new JSONObject(16);
|
|
|
|
+ townSts(townsResult, condition, townsDept.getId(), townsDept.getDeptName(), false);
|
|
|
|
+ towsDataList.add(townsResult);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ result.put("townDatas", towsDataList);
|
|
|
|
+ redisService.setCacheObject(packRedisKey(deptId + ""), result, 1L, TimeUnit.DAYS);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return QIANSHANSHI;
|
|
|
|
+ } else if (roleKeySets.contains("sys:town")) {
|
|
|
|
+ JSONObject jsonObject = redisService.getCacheObject(packRedisKey("town:" + deptId));
|
|
|
|
+ if (isNotEmpty(jsonObject)) {
|
|
|
|
+ ZHEN = jsonObject;
|
|
|
|
+ return jsonObject;
|
|
}
|
|
}
|
|
|
|
|
|
- result.put("zu", isEmpty(zuDept) ? 0 : zuDept.size());
|
|
|
|
- condition.setDeptIdList(map(depts, SysDept::getId));
|
|
|
|
|
|
+ ThreadPoolService.execute(() -> {
|
|
|
|
+ townSts(result, condition, deptId, deptName, true);
|
|
|
|
+ redisService.setCacheObject(packRedisKey("town:" + deptId), result, 1L, TimeUnit.DAYS);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return ZHEN;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void townSts(JSONObject result, VaccineInfoOperation condition, Long deptId, String deptName, boolean percent) {
|
|
|
|
+ // 乡镇以下的所有部门
|
|
|
|
+ List<SysDept> depts = remoteDeptService.listChildrenDepts(deptId);
|
|
|
|
+ List<SysDept> cunDepts = new ArrayList<>(16);
|
|
|
|
+ for (SysDept dept : depts) {
|
|
|
|
+ if (isEmpty(dept.getParentId())) continue;
|
|
|
|
+ if (deptId.equals(dept.getParentId())) {
|
|
|
|
+ cunDepts.add(dept);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ result.put("cun", isEmpty(cunDepts) ? 0 : cunDepts.size());
|
|
|
|
+
|
|
|
|
+ List<SysDept> zuDept = new ArrayList<>(16);
|
|
|
|
+ for (SysDept cunDept : cunDepts) {
|
|
|
|
+ for (SysDept dept : depts) {
|
|
|
|
+ if (cunDept.getId().equals(dept.getParentId())) {
|
|
|
|
+ zuDept.add(dept);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ result.put("zu", isEmpty(zuDept) ? 0 : zuDept.size());
|
|
|
|
+ condition.setDeptIdList(map(depts, SysDept::getId));
|
|
|
|
+ int czrk = vaccineInfoMapper.countCzrk(condition);
|
|
|
|
+ result.put("czrk", czrk);
|
|
|
|
+
|
|
|
|
+ // 常住人口占总人口的百分比
|
|
|
|
+ if (BooleanUtils.isTrue(percent)) {
|
|
|
|
+ condition.setRyrl(null); // 查全部
|
|
|
|
+ int zrs = vaccineInfoMapper.countCzrk(condition);
|
|
|
|
+ String bfb = NumberUtils.percent(czrk, zrs);
|
|
|
|
+ result.put("bfb", bfb);
|
|
}
|
|
}
|
|
|
|
|
|
int xz = vaccineInfoMapper.countByXz(condition);
|
|
int xz = vaccineInfoMapper.countByXz(condition);
|
|
int js = vaccineInfoMapper.countByJs(condition);
|
|
int js = vaccineInfoMapper.countByJs(condition);
|
|
result.put("xz", xz);
|
|
result.put("xz", xz);
|
|
result.put("js", js);
|
|
result.put("js", js);
|
|
- result.put("czrk", vaccineInfoMapper.countCzrk(condition));
|
|
|
|
- return result;
|
|
|
|
|
|
+ result.put("zhen", deptName);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -1451,4 +1596,8 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
|
|
|
|
|
|
return infoOperations;
|
|
return infoOperations;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private String packRedisKey(String deptId){
|
|
|
|
+ return STS_CZRK_ + ":" + deptId + ":" + DateUtils.getDate();
|
|
|
|
+ }
|
|
}
|
|
}
|