|
@ -1,14 +1,17 @@
|
|
|
package com.yihu.jw.hospital.module.common.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.wlyy.service.WlyyBusinessService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* Created by yeshijie on 2024/6/3.
|
|
@ -17,6 +20,163 @@ import java.util.Map;
|
|
|
public class StatisticsService {
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private WlyyBusinessService wlyyBusinessService;
|
|
|
|
|
|
//服务情况明细
|
|
|
public List<Map<String,Object>> serviceSituationDetail(HttpServletRequest request){
|
|
|
String sql = "SELECT DISTINCT d.idcard,d.name,h.dept_code dept,h.dept_name deptName,0 collaborateNum,0 inviteNum" +
|
|
|
",0 replyNum,0 turnUpNum,0 turnDownNum from base_doctor_hospital h,base_doctor d " +
|
|
|
"WHERE h.del='1' and d.del='1' and h.doctor_code=d.id and d.idcard is not null and h.dept_name is not null order by h.dept_name";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
JSONObject jsonObject = wlyyBusinessService.commonGet(request,"serviceSituationDetail");
|
|
|
JSONArray jsonArray = null;
|
|
|
int collaborateNumTotal = 0;
|
|
|
int inviteNumTotal = 0;
|
|
|
int replyNumTotal = 0;
|
|
|
int turnUpNumTotal = 0;
|
|
|
int turnDownNumTotal = 0;
|
|
|
List<Map<String,Object>> listTmp = new ArrayList<>();
|
|
|
Map<String, List<Map<String,Object>>> deptMap = new HashMap<>();
|
|
|
if(jsonObject!=null&&jsonObject.getInteger("status")==200){
|
|
|
jsonArray = jsonObject.getJSONArray("list");
|
|
|
for (Map<String,Object> map:list){
|
|
|
String idcard1 = map.get("idcard")+"";
|
|
|
for (int i=0;i<jsonArray.size();i++){
|
|
|
JSONObject json = jsonArray.getJSONObject(i);
|
|
|
String idcard = json.getString("code");
|
|
|
int collaborateNum = json.getInteger("collaborateNum");
|
|
|
int inviteNum = json.getInteger("inviteNum");
|
|
|
int replyNum = json.getInteger("replyNum");
|
|
|
int turnUpNum = json.getInteger("turnUpNum");
|
|
|
int turnDownNum = json.getInteger("turnDownNum");
|
|
|
int total = collaborateNum + inviteNum + replyNum + turnUpNum + turnDownNum;
|
|
|
if(total==0){
|
|
|
jsonArray.remove(i);
|
|
|
break;
|
|
|
}
|
|
|
collaborateNumTotal += collaborateNum;
|
|
|
inviteNumTotal += inviteNum;
|
|
|
replyNumTotal += replyNum;
|
|
|
turnUpNumTotal += turnUpNum;
|
|
|
turnDownNumTotal += turnDownNum;
|
|
|
if(idcard1.equals(idcard)){
|
|
|
String dept = map.get("dept")+"";
|
|
|
map.put("collaborateNum",collaborateNum);
|
|
|
map.put("inviteNum",inviteNum);
|
|
|
map.put("replyNum",replyNum);
|
|
|
map.put("turnUpNum",turnUpNum);
|
|
|
map.put("turnDownNum",turnDownNum);
|
|
|
map.put("replyRate",getRange(replyNum, inviteNum));
|
|
|
listTmp.add(map);
|
|
|
jsonArray.remove(i);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Map<String,Object> totalMap = new HashMap<>();
|
|
|
totalMap.put("code","");
|
|
|
totalMap.put("name","合计");
|
|
|
totalMap.put("collaborateNum",collaborateNumTotal);
|
|
|
totalMap.put("inviteNum",inviteNumTotal);
|
|
|
totalMap.put("replyNum",replyNumTotal);
|
|
|
totalMap.put("turnUpNum",turnUpNumTotal);
|
|
|
totalMap.put("turnDownNum",turnDownNumTotal);
|
|
|
totalMap.put("replyRate",getRange(replyNumTotal, inviteNumTotal));
|
|
|
totalMap.put("list",new ArrayList<>());
|
|
|
|
|
|
List<Map<String,Object>> result = new ArrayList<>();
|
|
|
result.add(totalMap);
|
|
|
Map<String, List<Map<String,Object>>> resList = listTmp.stream().collect(Collectors.groupingBy(e -> e.get("deptName").toString()));
|
|
|
for (Map.Entry<String, List<Map<String,Object>>> entry:resList.entrySet()){
|
|
|
String key = entry.getKey();
|
|
|
int collaborateNumDept = 0;
|
|
|
int inviteNumDept = 0;
|
|
|
int replyNumDept = 0;
|
|
|
int turnUpNumDept = 0;
|
|
|
int turnDownNumDept = 0;
|
|
|
Map<String,Object> deptTmp = new HashMap<>();
|
|
|
List<Map<String,Object>> value = entry.getValue();
|
|
|
String dept = "";
|
|
|
for (Map<String,Object> map:value){
|
|
|
dept = map.get("dept")+"";
|
|
|
int collaborateNum = Integer.parseInt(map.get("collaborateNum")+"");
|
|
|
int inviteNum = Integer.parseInt(map.get("inviteNum")+"");
|
|
|
int replyNum = Integer.parseInt(map.get("replyNum")+"");
|
|
|
int turnUpNum = Integer.parseInt(map.get("turnUpNum")+"");
|
|
|
int turnDownNum = Integer.parseInt(map.get("turnDownNum")+"");
|
|
|
|
|
|
collaborateNumDept += collaborateNum;
|
|
|
inviteNumDept += inviteNum;
|
|
|
replyNumDept += replyNum;
|
|
|
turnUpNumDept += turnUpNum;
|
|
|
turnDownNumDept += turnDownNum;
|
|
|
}
|
|
|
deptTmp.put("code",dept);
|
|
|
deptTmp.put("name",key);
|
|
|
deptTmp.put("collaborateNum",collaborateNumDept);
|
|
|
deptTmp.put("inviteNum",inviteNumDept);
|
|
|
deptTmp.put("replyNum",replyNumDept);
|
|
|
deptTmp.put("turnUpNum",turnUpNumDept);
|
|
|
deptTmp.put("turnDownNum",turnDownNumDept);
|
|
|
deptTmp.put("replyRate",getRange(replyNumDept, inviteNumDept));
|
|
|
value.sort(Comparator.comparingInt(a->Integer.parseInt(a.get("replyNum")+"")));
|
|
|
deptTmp.put("list",value);
|
|
|
result.add(deptTmp);
|
|
|
}
|
|
|
List<Map<String,Object>> other = new ArrayList<>();
|
|
|
if(jsonArray!=null&&jsonArray.size()>0){
|
|
|
int collaborateNumOther = 0;
|
|
|
int inviteNumOther = 0;
|
|
|
int replyNumOther = 0;
|
|
|
int turnUpNumOther = 0;
|
|
|
int turnDownNumOther = 0;
|
|
|
for (int i=0;i<jsonArray.size();i++){
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
JSONObject json = jsonArray.getJSONObject(i);
|
|
|
String idcard = json.getString("code");
|
|
|
String name = json.getString("name");
|
|
|
int collaborateNum = json.getInteger("collaborateNum");
|
|
|
int inviteNum = json.getInteger("inviteNum");
|
|
|
int replyNum = json.getInteger("replyNum");
|
|
|
int turnUpNum = json.getInteger("turnUpNum");
|
|
|
int turnDownNum = json.getInteger("turnDownNum");
|
|
|
|
|
|
map.put("code",idcard);
|
|
|
map.put("name",name);
|
|
|
map.put("collaborateNum",collaborateNum);
|
|
|
map.put("inviteNum",inviteNum);
|
|
|
map.put("replyNum",replyNum);
|
|
|
map.put("turnUpNum",turnUpNum);
|
|
|
map.put("turnDownNum",turnDownNum);
|
|
|
map.put("replyRate",getRange(replyNum, inviteNum));
|
|
|
other.add(map);
|
|
|
|
|
|
collaborateNumOther += collaborateNum;
|
|
|
inviteNumOther += inviteNum;
|
|
|
replyNumOther += replyNum;
|
|
|
turnUpNumOther += turnUpNum;
|
|
|
turnDownNumOther += turnDownNum;
|
|
|
}
|
|
|
|
|
|
Map<String,Object> otherMap = new HashMap<>();
|
|
|
otherMap.put("code","-");
|
|
|
otherMap.put("name","其他");
|
|
|
otherMap.put("collaborateNum",collaborateNumOther);
|
|
|
otherMap.put("inviteNum",inviteNumOther);
|
|
|
otherMap.put("replyNum",replyNumOther);
|
|
|
otherMap.put("turnUpNum",turnUpNumOther);
|
|
|
otherMap.put("turnDownNum",turnDownNumOther);
|
|
|
otherMap.put("replyRate",getRange(replyNumOther, inviteNumOther));
|
|
|
other.sort(Comparator.comparingInt(a->Integer.parseInt(a.get("replyNum")+"")));
|
|
|
otherMap.put("list",other);
|
|
|
result.add(otherMap);
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设备上传次数趋势
|