|
@ -9,6 +9,7 @@ import com.yihu.wlyy.entity.statistics.PopulationBase;
|
|
|
import com.yihu.wlyy.repository.address.TownDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
|
|
|
import com.yihu.wlyy.repository.organization.HospitalDao;
|
|
|
import com.yihu.wlyy.service.system.SystemDictService;
|
|
|
import com.yihu.wlyy.util.Constant;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.ElasticsearchUtil;
|
|
@ -49,6 +50,8 @@ public class StatisticsESService {
|
|
|
HospitalDao hospitalDao;
|
|
|
@Autowired
|
|
|
TownDao townDao;
|
|
|
@Autowired
|
|
|
private SystemDictService systemDictService;
|
|
|
|
|
|
/**
|
|
|
* 获取上次统计时间
|
|
@ -950,6 +953,191 @@ public class StatisticsESService {
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
public JSONArray getLevelTwoLowLevelTotalTeamLeader(String date, String area, int level, String index, int sort, String lowLevel, String lowCode, String year) throws Exception {
|
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String low_level = String.valueOf(org.springframework.util.StringUtils.isEmpty(lowLevel) ? (level - 1) : lowLevel);
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
|
|
|
List<SaveModel> esModelList= (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel1(date,area,level,index,SaveModel.timeLevel_DDL,lowLevel,lowCode);
|
|
|
|
|
|
if(esModelList!=null&&esModelList.size()>0){
|
|
|
esModelList.stream().forEach(one->{
|
|
|
Map<String, Object> maps=new HashMap<String, Object>();
|
|
|
maps.put("amount",one.getResult1());
|
|
|
if (low_level.equals("3")) {
|
|
|
maps.put("code",one.getTown());
|
|
|
maps.put("name",one.getTownName());
|
|
|
} else if (low_level.equals("2")) {
|
|
|
maps.put("code",one.getHospital());
|
|
|
maps.put("name",one.getHospitalName());
|
|
|
} else if (low_level.equals("1")) {
|
|
|
maps.put("code",one.getTeam());
|
|
|
maps.put("name",one.getTeamName());
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
// 结果为空时,自建结果集
|
|
|
if (resultList == null || resultList.size() < 1) {
|
|
|
resultList = getLowLevelMapKey(level, low_level, area);
|
|
|
}
|
|
|
|
|
|
if (resultList != null) {
|
|
|
String signTaskNum = systemDictService.getDictValueNoRedis("SIGN_TASKNUM_17", year);//目标量
|
|
|
String signRegulationNum = systemDictService.getDictValueNoRedis("SIGN_TEAM_REGULATION_NUM", year);//调控量
|
|
|
DecimalFormat df = new DecimalFormat("0.0000");
|
|
|
for (Map<String, Object> map : resultList) {
|
|
|
map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
|
|
|
map.put("signTaskNum", signTaskNum);//目标量
|
|
|
map.put("signRegulationNum", signRegulationNum);//调控量
|
|
|
if (!low_level.equals("1")) {
|
|
|
PopulationBase peopleNum = getPopulationBase(map.get("code").toString(), year);
|
|
|
if (peopleNum != null) {
|
|
|
int num = 0;
|
|
|
int taskNum = 0;
|
|
|
|
|
|
if (lowCode.equals("3")) {
|
|
|
num = peopleNum.getSixFiveNum();
|
|
|
taskNum = peopleNum.getSixFiveTaskNum();
|
|
|
} else if (lowCode.equals("1")) {
|
|
|
num = peopleNum.getGxyNum();
|
|
|
taskNum = peopleNum.getGxyTaskNum();
|
|
|
} else if (lowCode.equals("2")) {
|
|
|
num = peopleNum.getTnbNum();
|
|
|
taskNum = peopleNum.getTnbTaskNum();
|
|
|
}
|
|
|
map.put("rate", df.format(((long) map.get("amount") * 1.0000) / num * 100));
|
|
|
map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / taskNum * 100));
|
|
|
map.put("targetRate", df.format(taskNum * 1.0000 / num * 100));
|
|
|
map.put("rateString", map.get("amount") + "/" + num);
|
|
|
map.put("taskRateString", map.get("amount") + "/" + taskNum);
|
|
|
map.put("targetRateString", taskNum + "/" + num);
|
|
|
map.put("num", num);
|
|
|
map.put("task", taskNum);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if ((level == 4 && "1".equals(lowLevel)) || (level == 2) || (level == 3 && "1".equals(lowLevel))) {
|
|
|
translateTeamLeaderName(resultList);
|
|
|
}
|
|
|
|
|
|
Collections.sort(resultList, new Comparator<Map<String, Object>>() {
|
|
|
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
|
|
long map1value = (long) o1.get("amount");
|
|
|
long map2value = (long) o2.get("amount");
|
|
|
|
|
|
if (map1value - map2value > 0) {
|
|
|
return sort == 1 ? -1 : 1;
|
|
|
} else if (map1value - map2value < 0) {
|
|
|
return sort == 1 ? 1 : -1;
|
|
|
} else {
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return new JSONArray(resultList);
|
|
|
} else {
|
|
|
return new JSONArray();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取团队长队长名字
|
|
|
*
|
|
|
* @param leaders
|
|
|
* @param teamCode
|
|
|
* @return
|
|
|
*/
|
|
|
public String getTeamLeaderNameByTeamCode(Map<Integer, Map<String, Object>> leaders, int teamCode) {
|
|
|
if (leaders != null && leaders.size() > 0 && teamCode != 0) {
|
|
|
Map<String, Object> leader = leaders.get(teamCode);
|
|
|
if (leader != null) {
|
|
|
return (String) leader.get("name");
|
|
|
}
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> translateTeamLeaderName(List<Map<String, Object>> rs) {
|
|
|
Map<Integer, Map<String, Object>> leaders = getAllTeamLeaders();
|
|
|
if (rs != null && rs.size() > 0) {
|
|
|
for (Map<String, Object> r : rs) {
|
|
|
String id = (String) r.get("code");
|
|
|
String name = getTeamLeaderNameByTeamCode(leaders, Integer.parseInt(id));
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(name)) {
|
|
|
r.put("name", name);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
public JSONArray translateTeamLeaderName(JSONArray rs) {
|
|
|
Map<Integer, Map<String, Object>> leaders = getAllTeamLeaders();
|
|
|
if (rs != null) {
|
|
|
for (int i = 0; i < rs.length(); i++) {
|
|
|
JSONObject r = rs.getJSONObject(i);
|
|
|
Integer id = (Integer) r.get("id");
|
|
|
String name = getTeamLeaderNameByTeamCode(leaders, id);
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(name)) {
|
|
|
r.put("name", name);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
public JSONArray translateTeamLeaderNameByCode(JSONArray rs) {
|
|
|
Map<Integer, Map<String, Object>> leaders = getAllTeamLeaders();
|
|
|
if (rs != null) {
|
|
|
for (int i = 0; i < rs.length(); i++) {
|
|
|
JSONObject r = rs.getJSONObject(i);
|
|
|
String id = (String) r.get("code");
|
|
|
String name = getTeamLeaderNameByTeamCode(leaders, Integer.parseInt(id));
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(name)) {
|
|
|
r.put("name", name);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
public List<AdminTeam> translateAdminTeamLeaderName(List<AdminTeam> rs) {
|
|
|
Map<Integer, Map<String, Object>> leaders = getAllTeamLeaders();
|
|
|
if (rs != null && rs.size() > 0) {
|
|
|
for (AdminTeam team : rs) {
|
|
|
Integer id = team.getId().intValue();
|
|
|
String name = getTeamLeaderNameByTeamCode(leaders, id);
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(name)) {
|
|
|
team.setName(name);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return rs;
|
|
|
}
|
|
|
/**
|
|
|
* 获取所有团队长信息
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<Integer, Map<String, Object>> getAllTeamLeaders() {
|
|
|
String sql = " select t.leader_code,t.id,d.name " +
|
|
|
" from wlyy_admin_team t " +
|
|
|
" LEFT JOIN wlyy_doctor d " +
|
|
|
" on t.leader_code = d.code ";
|
|
|
List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
|
|
|
//将结果集转换为 map减小循环层
|
|
|
Map<Integer, Map<String, Object>> rsMap = new HashMap<>();
|
|
|
if (rs != null && rs.size() > 0) {
|
|
|
for (Map<String, Object> map : rs) {
|
|
|
rsMap.put((Integer) map.get("id"), map);
|
|
|
}
|
|
|
}
|
|
|
return rsMap;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询某个级别的某个指标到达量
|
|
|
*
|
|
@ -962,8 +1150,442 @@ public class StatisticsESService {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
// public JSONArray getLevelTwoLowLevelTotalTeamLeader(String date, String area, int level, String index, int sort, String lowLevel, String lowCode, String year) throws Exception {
|
|
|
//
|
|
|
//
|
|
|
// }
|
|
|
public JSONArray getLevelTwoLowLevelTotal(String date, String area, int level, String index, int sort, String lowLevel, String lowCode, String year) throws Exception {
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String low_level = String.valueOf(org.springframework.util.StringUtils.isEmpty(lowLevel) ? (level - 1) : lowLevel);
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
|
|
|
List<SaveModel> esModelList= (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel1(date,area,level,index,SaveModel.timeLevel_DDL,lowLevel,lowCode);
|
|
|
|
|
|
if(esModelList!=null&&esModelList.size()>0){
|
|
|
esModelList.stream().forEach(one->{
|
|
|
Map<String, Object> maps=new HashMap<String, Object>();
|
|
|
maps.put("amount",one.getResult1());
|
|
|
if (low_level.equals("3")) {
|
|
|
maps.put("code",one.getTown());
|
|
|
maps.put("name",one.getTownName());
|
|
|
} else if (low_level.equals("2")) {
|
|
|
maps.put("code",one.getHospital());
|
|
|
maps.put("name",one.getHospitalName());
|
|
|
} else if (low_level.equals("1")) {
|
|
|
maps.put("code",one.getTeam());
|
|
|
maps.put("name",one.getTeamName());
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 结果为空时,自建结果集
|
|
|
if (resultList == null || resultList.size() < 1) {
|
|
|
resultList = getLowLevelMapKey(level, low_level, area);
|
|
|
}
|
|
|
|
|
|
if (resultList != null) {
|
|
|
DecimalFormat df = new DecimalFormat("0.0000");
|
|
|
for (Map<String, Object> map : resultList) {
|
|
|
map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
|
|
|
|
|
|
if (!low_level.equals("1")) {
|
|
|
PopulationBase peopleNum = getPopulationBase(area, year);
|
|
|
if (peopleNum != null) {
|
|
|
int num = 0;
|
|
|
int taskNum = 0;
|
|
|
|
|
|
if (lowCode.equals("3")) {
|
|
|
num = peopleNum.getSixFiveNum();
|
|
|
taskNum = peopleNum.getSixFiveTaskNum();
|
|
|
} else if (lowCode.equals("1")) {
|
|
|
num = peopleNum.getGxyNum();
|
|
|
taskNum = peopleNum.getGxyTaskNum();
|
|
|
} else if (lowCode.equals("2")) {
|
|
|
num = peopleNum.getTnbNum();
|
|
|
taskNum = peopleNum.getTnbTaskNum();
|
|
|
}
|
|
|
map.put("rate", df.format(((long) map.get("amount") * 1.0000) / num * 100));
|
|
|
map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / taskNum * 100));
|
|
|
map.put("targetRate", df.format(taskNum * 1.0000 / num * 100));
|
|
|
map.put("rateString", map.get("amount") + "/" + num);
|
|
|
map.put("taskRateString", map.get("amount") + "/" + taskNum);
|
|
|
map.put("targetRateString", taskNum + "/" + num);
|
|
|
map.put("num", num);
|
|
|
map.put("task", taskNum);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ((level == 4 && "1".equals(lowLevel)) || (level == 2) || (level == 3 && "1".equals(lowLevel))) {
|
|
|
translateTeamLeaderName(resultList);
|
|
|
}
|
|
|
|
|
|
Collections.sort(resultList, new Comparator<Map<String, Object>>() {
|
|
|
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
|
|
long map1value = (long) o1.get("amount");
|
|
|
long map2value = (long) o2.get("amount");
|
|
|
|
|
|
if (map1value - map2value > 0) {
|
|
|
return sort == 1 ? -1 : 1;
|
|
|
} else if (map1value - map2value < 0) {
|
|
|
return sort == 1 ? 1 : -1;
|
|
|
} else {
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return new JSONArray(resultList);
|
|
|
} else {
|
|
|
return new JSONArray();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询某个级别的某个指标到达量
|
|
|
*
|
|
|
* @param date
|
|
|
* @param area
|
|
|
* @param level
|
|
|
* @param index
|
|
|
* @param sort
|
|
|
* @param lowLevel
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONArray getLowLevelTotal2(String date, String area, int level, String index, int sort, String lowLevel) throws Exception {
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String low_level = String.valueOf(org.springframework.util.StringUtils.isEmpty(lowLevel) ? (level - 1) : lowLevel);
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
//获取微信关注的未交费
|
|
|
Map<String, Integer> expenseStatus0 = getByIndex(date, area, level, "49", sort, lowLevel, dateFormat);
|
|
|
//获取微信关注的已交费
|
|
|
Map<String, Integer> expenseStatus1 = getByIndex(date, area, level, "50", sort, lowLevel, dateFormat);
|
|
|
//获取已缴费的签约数
|
|
|
Map<String, Integer> expenseStatus1Sigjn = getByIndex(date, area, level, "1", sort, lowLevel, dateFormat);
|
|
|
|
|
|
|
|
|
// 结果为空时,自建结果集
|
|
|
if (resultList == null || resultList.size() < 1) {
|
|
|
resultList = getLowLevelMapKey(level, low_level, area);
|
|
|
}
|
|
|
|
|
|
if (resultList != null) {
|
|
|
DecimalFormat df = new DecimalFormat("0.0000");
|
|
|
Iterator iterator = resultList.iterator();
|
|
|
while (iterator.hasNext()){
|
|
|
Map<String, Object> map = (Map<String, Object>)iterator.next();
|
|
|
|
|
|
Integer expenseStatus0amountNum = expenseStatus0.get(map.get("code").toString());
|
|
|
Integer expenseStatus1amountNum = expenseStatus1.get(map.get("code").toString());
|
|
|
Integer expenseStatus1SigjnNum = expenseStatus1Sigjn.get(map.get("code").toString());
|
|
|
if(expenseStatus0amountNum==null||expenseStatus1amountNum==null||expenseStatus1SigjnNum==null){
|
|
|
iterator.remove();
|
|
|
continue;
|
|
|
}
|
|
|
if (expenseStatus0amountNum == null) {
|
|
|
expenseStatus0amountNum = 0;
|
|
|
}
|
|
|
if (expenseStatus1amountNum == null) {
|
|
|
expenseStatus1amountNum = 0;
|
|
|
}
|
|
|
map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
|
|
|
map.put("weChatAmount0", expenseStatus0amountNum);//微信关注未交费数
|
|
|
map.put("weChatAmount1", expenseStatus1amountNum);//微信关注已交费数
|
|
|
map.put("signAccount", expenseStatus1SigjnNum);//签约已缴费的数目
|
|
|
map.put("bindRate", getRangeDouuble(expenseStatus1amountNum, expenseStatus1SigjnNum, 2));//微信关注率
|
|
|
}
|
|
|
|
|
|
if ((level == 4 && "1".equals(lowLevel)) || (level == 2)) {
|
|
|
translateTeamLeaderName(resultList);
|
|
|
}
|
|
|
// 排序 按绑定率来排序
|
|
|
resultList.sort(new Comparator<Map<String, Object>>() {
|
|
|
@Override
|
|
|
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
|
|
if ((double) o1.get("bindRate") >= (double) o2.get("bindRate")) {
|
|
|
return -1;
|
|
|
} else if ((double) o1.get("bindRate") < (double) o2.get("bindRate")) {
|
|
|
return 1;
|
|
|
} else {
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return new JSONArray(resultList);
|
|
|
} else {
|
|
|
return new JSONArray();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public double getRangeDouuble(int first, int second, int i) {
|
|
|
if (second == 0 && first > 0) {
|
|
|
//如果分母为0 分子不为0 返回100%
|
|
|
return 100;
|
|
|
} else if (second == 0 && first == 0) {
|
|
|
//如果分母为0 分子为0 返回0%
|
|
|
return 0;
|
|
|
}
|
|
|
float size = (float) (first * 100) / second;
|
|
|
DecimalFormat df = new DecimalFormat("0.00");//格式化小数,不足的补0
|
|
|
String filesize = df.format(size);
|
|
|
return Double.valueOf(filesize);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取某个指标某一天某一level的值 到达量
|
|
|
*
|
|
|
* @param date
|
|
|
* @param area
|
|
|
* @param level
|
|
|
* @param index
|
|
|
* @param sort
|
|
|
* @param lowLevel
|
|
|
* @param dateFormat
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
private Map<String, Integer> getByIndex(String date, String area, int level, String index, int sort, String lowLevel, SimpleDateFormat dateFormat) throws Exception {
|
|
|
Map<String, Integer> returnMap = new HashMap<>();
|
|
|
List<SaveModel> esModelList= (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0(date,area,level,index,SaveModel.timeLevel_DDL,lowLevel);
|
|
|
if(esModelList!=null&&esModelList.size()>0){
|
|
|
esModelList.stream().forEach(one->{
|
|
|
Map<String, Object> maps=new HashMap<String, Object>();
|
|
|
maps.put("amount",one.getResult1());
|
|
|
if (lowLevel.equals("3")) {
|
|
|
returnMap.put(one.getTown(),one.getResult1());
|
|
|
} else if (lowLevel.equals("2")) {
|
|
|
returnMap.put(one.getHospital(),one.getResult1());
|
|
|
} else if (lowLevel.equals("1")) {
|
|
|
returnMap.put(one.getTeam(),one.getResult1());
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return returnMap;
|
|
|
}
|
|
|
|
|
|
public String getAvgAllInfo(int level, String area, String lowLevel) throws Exception {
|
|
|
JSONObject returnJo=new JSONObject();
|
|
|
JSONArray ja=new JSONArray();
|
|
|
//市级
|
|
|
if (level == 4) {
|
|
|
if (StringUtils.isBlank(lowLevel)) {
|
|
|
List<SaveModel> esModelList= (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0(DateUtil.dateToStrShort(new Date()),area,level,"28",SaveModel.timeLevel_DDL,"3");
|
|
|
esModelList.forEach(one->{
|
|
|
JSONObject jo=new JSONObject();
|
|
|
jo.put("name",one.getTownName());
|
|
|
jo.put("code",one.getTown());
|
|
|
jo.put("avgCount",getRangeDouuble(one.getResult1(),one.getResult2(),2));
|
|
|
ja.put(jo);
|
|
|
});
|
|
|
} else {
|
|
|
List<SaveModel> esModelList= (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0(DateUtil.dateToStrShort(new Date()),area,level,"28",SaveModel.timeLevel_DDL,"2");
|
|
|
esModelList.forEach(one->{
|
|
|
JSONObject jo=new JSONObject();
|
|
|
jo.put("name",one.getHospitalName());
|
|
|
jo.put("code",one.getHospital());
|
|
|
jo.put("avgCount",getRangeDouuble(one.getResult1(),one.getResult2(),2));
|
|
|
ja.put(jo);
|
|
|
});
|
|
|
}
|
|
|
} else if (level == 3) {
|
|
|
List<SaveModel> esModelList= (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0(DateUtil.dateToStrShort(new Date()),area,level,"28",SaveModel.timeLevel_DDL,"2");
|
|
|
esModelList.forEach(one->{
|
|
|
JSONObject jo=new JSONObject();
|
|
|
jo.put("name",one.getHospitalName());
|
|
|
jo.put("code",one.getHospital());
|
|
|
jo.put("avgCount",getRangeDouuble(one.getResult1(),one.getResult2(),2));
|
|
|
ja.put(jo);
|
|
|
});
|
|
|
} else if (level == 2) {
|
|
|
|
|
|
List<SaveModel> esModelList= (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0(DateUtil.dateToStrShort(new Date()),area,level,"28",SaveModel.timeLevel_DDL,"1");
|
|
|
esModelList.forEach(one->{
|
|
|
JSONObject jo=new JSONObject();
|
|
|
jo.put("name",one.getTeam());
|
|
|
jo.put("code",one.getTeamName());
|
|
|
jo.put("avgCount",getRangeDouuble(one.getResult1(),one.getResult2(),2));
|
|
|
ja.put(jo);
|
|
|
});
|
|
|
translateTeamLeaderName(ja);
|
|
|
}
|
|
|
returnJo.put("data",ja);
|
|
|
return returnJo.toString();
|
|
|
}
|
|
|
/**
|
|
|
* 13.17两个指标团队显示团队长
|
|
|
* 查询某个级别的某个指标到达量
|
|
|
*
|
|
|
* @param date
|
|
|
* @param area
|
|
|
* @param level
|
|
|
* @param index
|
|
|
* @param sort
|
|
|
* @param lowLevel
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONArray getLowLevelTotalTeamLeader(String date, String area, int level, String index, int sort, String lowLevel, String year) throws Exception {
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String low_level = String.valueOf(org.springframework.util.StringUtils.isEmpty(lowLevel) ? (level - 1) : lowLevel);
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
|
|
|
List<SaveModel> esModelList= (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0(date,area,level,index,SaveModel.timeLevel_DDL,lowLevel);
|
|
|
|
|
|
if(esModelList!=null&&esModelList.size()>0){
|
|
|
esModelList.stream().forEach(one->{
|
|
|
Map<String, Object> maps=new HashMap<String, Object>();
|
|
|
maps.put("amount",one.getResult1());
|
|
|
if (low_level.equals("3")) {
|
|
|
maps.put("code",one.getTown());
|
|
|
maps.put("name",one.getTownName());
|
|
|
} else if (low_level.equals("2")) {
|
|
|
maps.put("code",one.getHospital());
|
|
|
maps.put("name",one.getHospitalName());
|
|
|
} else if (low_level.equals("1")) {
|
|
|
maps.put("code",one.getTeam());
|
|
|
maps.put("name",one.getTeamName());
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 结果为空时,自建结果集
|
|
|
if (resultList == null || resultList.size() < 1) {
|
|
|
resultList = getLowLevelMapKey(level, low_level, area);
|
|
|
}
|
|
|
//获取目标量和团队的调控量
|
|
|
String signTaskNum = systemDictService.getDictValueNoRedis("SIGN_TASKNUM_13", year);//目标量
|
|
|
String signRegulationNum = systemDictService.getDictValueNoRedis("SIGN_TEAM_REGULATION_NUM", year);//调控量
|
|
|
if (resultList != null) {
|
|
|
DecimalFormat df = new DecimalFormat("0.0000");
|
|
|
for (int i = 0; i < resultList.size(); i++) {
|
|
|
Map<String, Object> map = resultList.get(i);
|
|
|
map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
|
|
|
map.put("signTaskNum", signTaskNum);//目标量
|
|
|
map.put("signRegulationNum", signRegulationNum);//调控量
|
|
|
|
|
|
if (!low_level.equals("1")) {
|
|
|
String code = map.get("code").toString();
|
|
|
PopulationBase peopleNum = getPopulationBase(code, year);
|
|
|
if (peopleNum != null) {
|
|
|
map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
|
|
|
map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getTaskNum() * 100));
|
|
|
map.put("targetRate", df.format(peopleNum.getTaskNum() * 1.0000 / peopleNum.getNum() * 100));
|
|
|
map.put("rateString", map.get("amount") + "/" + peopleNum.getNum());
|
|
|
map.put("taskRateString", map.get("amount") + "/" + peopleNum.getTaskNum());
|
|
|
map.put("targetRateString", peopleNum.getTaskNum() + "/" + peopleNum.getNum());
|
|
|
map.put("num", peopleNum.getNum());
|
|
|
map.put("task", peopleNum.getTaskNum());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ((level == 4 && "1".equals(lowLevel)) || (level == 2) || (level == 3 && "1".equals(lowLevel))) {
|
|
|
translateTeamLeaderName(resultList);
|
|
|
}
|
|
|
|
|
|
Collections.sort(resultList, new Comparator<Map<String, Object>>() {
|
|
|
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
|
|
long map1value = (long) o1.get("amount");
|
|
|
long map2value = (long) o2.get("amount");
|
|
|
|
|
|
if (map1value - map2value > 0) {
|
|
|
return sort == 1 ? -1 : 1;
|
|
|
} else if (map1value - map2value < 0) {
|
|
|
return sort == 1 ? 1 : -1;
|
|
|
} else {
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
return new JSONArray(resultList);
|
|
|
} else {
|
|
|
return new JSONArray();
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 查询某个级别的某个指标到达量
|
|
|
*
|
|
|
* @param date
|
|
|
* @param area
|
|
|
* @param level
|
|
|
* @param index
|
|
|
* @param sort
|
|
|
* @param lowLevel
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONArray getLowLevelTotal(String date, String area, int level, String index, int sort, String lowLevel, String year) throws Exception {
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String low_level = String.valueOf(org.springframework.util.StringUtils.isEmpty(lowLevel) ? (level - 1) : lowLevel);
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
|
|
|
List<SaveModel> esModelList= (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0(date,area,level,index,SaveModel.timeLevel_DDL,lowLevel);
|
|
|
|
|
|
if(esModelList!=null&&esModelList.size()>0){
|
|
|
esModelList.stream().forEach(one->{
|
|
|
Map<String, Object> maps=new HashMap<String, Object>();
|
|
|
maps.put("amount",one.getResult1());
|
|
|
if (low_level.equals("3")) {
|
|
|
maps.put("code",one.getTown());
|
|
|
maps.put("name",one.getTownName());
|
|
|
} else if (low_level.equals("2")) {
|
|
|
maps.put("code",one.getHospital());
|
|
|
maps.put("name",one.getHospitalName());
|
|
|
} else if (low_level.equals("1")) {
|
|
|
maps.put("code",one.getTeam());
|
|
|
maps.put("name",one.getTeamName());
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 结果为空时,自建结果集
|
|
|
if (resultList == null || resultList.size() < 1) {
|
|
|
resultList = getLowLevelMapKey(level, low_level, area);
|
|
|
}
|
|
|
|
|
|
if (resultList != null) {
|
|
|
DecimalFormat df = new DecimalFormat("0.0000");
|
|
|
for (Map<String, Object> map : resultList) {
|
|
|
map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
|
|
|
|
|
|
if (!low_level.equals("1")) {
|
|
|
PopulationBase peopleNum = getPopulationBase(area, year);
|
|
|
if (peopleNum != null) {
|
|
|
map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
|
|
|
map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getTaskNum() * 100));
|
|
|
map.put("targetRate", df.format(peopleNum.getTaskNum() * 1.0000 / peopleNum.getNum() * 100));
|
|
|
map.put("rateString", map.get("amount") + "/" + peopleNum.getNum());
|
|
|
map.put("taskRateString", map.get("amount") + "/" + peopleNum.getTaskNum());
|
|
|
map.put("targetRateString", peopleNum.getTaskNum() + "/" + peopleNum.getNum());
|
|
|
map.put("num", peopleNum.getNum());
|
|
|
map.put("task", peopleNum.getTaskNum());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ((level == 4 && "1".equals(lowLevel)) || (level == 2) || (level == 3 && "1".equals(lowLevel))) {
|
|
|
translateTeamLeaderName(resultList);
|
|
|
}
|
|
|
|
|
|
Collections.sort(resultList, new Comparator<Map<String, Object>>() {
|
|
|
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
|
|
long map1value = (long) o1.get("amount");
|
|
|
long map2value = (long) o2.get("amount");
|
|
|
|
|
|
if (map1value - map2value > 0) {
|
|
|
return sort == 1 ? -1 : 1;
|
|
|
} else if (map1value - map2value < 0) {
|
|
|
return sort == 1 ? 1 : -1;
|
|
|
} else {
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return new JSONArray(resultList);
|
|
|
} else {
|
|
|
return new JSONArray();
|
|
|
}
|
|
|
}
|
|
|
}
|