|
@ -11,6 +11,7 @@ import com.yihu.wlyy.statistics.model.system.City;
|
|
|
import com.yihu.wlyy.statistics.model.system.Town;
|
|
|
import com.yihu.wlyy.statistics.model.team.AdminTeam;
|
|
|
import com.yihu.wlyy.statistics.util.DateUtil;
|
|
|
import org.apache.logging.log4j.message.StringFormattedMessage;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -53,19 +54,19 @@ public class RedisStorage {
|
|
|
public void saveByLevel1(List<Map<String, List<ETLModel>>> data,List<Map<String, List<ETLModel>>> deleteData, String wlyyQuotaId) throws Exception {
|
|
|
|
|
|
List<AdminTeam> adminTeams=doctorAdminTeamDao.findAllTeam();
|
|
|
Map<String, AdminTeam> adminTeamMap = new HashMap<String, AdminTeam>();
|
|
|
adminTeamMap = new HashMap<String, AdminTeam>();
|
|
|
for (AdminTeam adminTeam : adminTeams) {
|
|
|
adminTeamMap.put(adminTeam.getId()+"", adminTeam);
|
|
|
}
|
|
|
//查找出系统全部的机构
|
|
|
List<Hospital> hospitals = hospitalDao.findHospitalzxFWZ();
|
|
|
Map<String, Hospital> hospitalsMap = new HashMap<String, Hospital>();
|
|
|
hospitalsMap = new HashMap<String, Hospital>();
|
|
|
for (Hospital hospital : hospitals) {
|
|
|
hospitalsMap.put(hospital.getCode(), hospital);
|
|
|
}
|
|
|
//查找出厦门市全部的区
|
|
|
List<Town> towns = townDao.findByCityCode(Constant.city);
|
|
|
Map<String, Town> townsMap = new HashMap<String, Town>();
|
|
|
townsMap = new HashMap<String, Town>();
|
|
|
for (Town town : towns) {
|
|
|
townsMap.put(town.getCode(), town);
|
|
|
}
|
|
@ -90,14 +91,14 @@ public class RedisStorage {
|
|
|
//保存全科团队
|
|
|
saveLevel1Team(wlyyQuotaId,adminTeamMap, adminTeam);
|
|
|
}else{
|
|
|
//保存市
|
|
|
saveLevel1City(wlyyQuotaId, cityMap, cityTeam,deleteData.get(3));
|
|
|
//保存区
|
|
|
saveLevel1Town(wlyyQuotaId, townsMap, townTeam,deleteData.get(2));
|
|
|
//保存机构
|
|
|
saveLevel1Org(wlyyQuotaId, hospitalsMap, orgTeam,deleteData.get(1));
|
|
|
//保存全科团队
|
|
|
saveLevel1Team(wlyyQuotaId,adminTeamMap, adminTeam,deleteData.get(0));
|
|
|
// //保存市
|
|
|
// saveLevel1City(wlyyQuotaId, cityMap, cityTeam,deleteData.get(3));
|
|
|
// //保存区
|
|
|
// saveLevel1Town(wlyyQuotaId, townsMap, townTeam,deleteData.get(2));
|
|
|
// //保存机构
|
|
|
// saveLevel1Org(wlyyQuotaId, hospitalsMap, orgTeam,deleteData.get(1));
|
|
|
// //保存全科团队
|
|
|
// saveLevel1Team(wlyyQuotaId,adminTeamMap, adminTeam,deleteData.get(0));
|
|
|
}
|
|
|
}
|
|
|
|
|
@ -260,8 +261,8 @@ public class RedisStorage {
|
|
|
JSONObject jo=new JSONObject();
|
|
|
jo.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
jo.put("num", num);
|
|
|
jo.put("name", level3);
|
|
|
jo.put("code", getLevel3Name(level3,type3));
|
|
|
jo.put("name", getLevel3Name(level3,type3));
|
|
|
jo.put("code", level3);
|
|
|
|
|
|
StringBuffer sb=new StringBuffer("quota:"+wlyyQuotaId+":"+level1+":"+adminTeamObj.getId()+":"+level2+":"+":"+level3+":"+timeKey);
|
|
|
keys.add(sb.toString());
|
|
@ -369,8 +370,8 @@ public class RedisStorage {
|
|
|
JSONObject jo=new JSONObject();
|
|
|
jo.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
jo.put("num", num);
|
|
|
jo.put("name", level3);
|
|
|
jo.put("code", getLevel3Name(level3,type3));
|
|
|
jo.put("name", getLevel3Name(level3,type3));
|
|
|
jo.put("code", level3);
|
|
|
StringBuffer sb=new StringBuffer("quota:"+wlyyQuotaId+":"+level1+":"+":"+hospital.getCode()+":"+level2+":"+level3+":"+timeKey);
|
|
|
keys.add(sb.toString());
|
|
|
redisTemplate.opsForValue().set(sb.toString(), jo.toString());
|
|
@ -515,8 +516,8 @@ public class RedisStorage {
|
|
|
//jo.put("code", town.getCode());
|
|
|
jo.put("level2code", level2);
|
|
|
jo.put("level2name", getLevel2Name(level2,type2));
|
|
|
jo.put("name", level3);
|
|
|
jo.put("code", getLevel3Name(level3,type3));
|
|
|
jo.put("name", getLevel3Name(level3,type3));
|
|
|
jo.put("code",level3 );
|
|
|
StringBuffer sb=new StringBuffer("quota:"+wlyyQuotaId+":"+level1+":"+town.getCode()+":"+level2+":"+level3+":"+timeKey);
|
|
|
keys.add(sb.toString());
|
|
|
redisTemplate.opsForValue().set(sb.toString(), jo.toString());
|
|
@ -562,8 +563,8 @@ public class RedisStorage {
|
|
|
JSONObject jo=new JSONObject();
|
|
|
jo.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
jo.put("num", num);
|
|
|
jo.put("name", level3);
|
|
|
jo.put("code", getLevel3Name(level3,type3));
|
|
|
jo.put("name",getLevel3Name(level3,type3));
|
|
|
jo.put("code",level3);
|
|
|
|
|
|
StringBuffer sb=new StringBuffer("quota:"+wlyyQuotaId+":"+level1+":"+cityObj.getCode()+":"+level2+":"+level3+":"+timeKey);
|
|
|
keys.add(sb.toString());
|
|
@ -584,19 +585,19 @@ public class RedisStorage {
|
|
|
|
|
|
private void saveByLevel2Public(List<Map<String, Map<String, List<ETLModel>>>> data,List<Map<String, Map<String, List<ETLModel>>>> deleteData, String wlyyQuotaId, Integer foreachNum, Integer type, Integer start) {
|
|
|
List<AdminTeam> adminTeams=doctorAdminTeamDao.findAllTeam();
|
|
|
Map<String, AdminTeam> adminTeamMap = new HashMap<String, AdminTeam>();
|
|
|
adminTeamMap = new HashMap<String, AdminTeam>();
|
|
|
for (AdminTeam adminTeam : adminTeams) {
|
|
|
adminTeamMap.put(adminTeam.getId()+"", adminTeam);
|
|
|
}
|
|
|
//查找出系统全部的机构
|
|
|
List<Hospital> hospitals = hospitalDao.findHospitalzxFWZ();
|
|
|
Map<String, Hospital> hospitalsMap = new HashMap<String, Hospital>();
|
|
|
hospitalsMap = new HashMap<String, Hospital>();
|
|
|
for (Hospital hospital : hospitals) {
|
|
|
hospitalsMap.put(hospital.getCode(), hospital);
|
|
|
}
|
|
|
//查找出厦门市全部的区
|
|
|
List<Town> towns = townDao.findByCityCode(Constant.city);
|
|
|
Map<String, Town> townsMap = new HashMap<String, Town>();
|
|
|
townsMap = new HashMap<String, Town>();
|
|
|
for (Town town : towns) {
|
|
|
townsMap.put(town.getCode(), town);
|
|
|
}
|
|
@ -613,14 +614,14 @@ public class RedisStorage {
|
|
|
Map<String, Map<String, List<ETLModel>>> cityTeam=data.get(3);//市的数据
|
|
|
|
|
|
if(deleteData!=null){
|
|
|
//保存市
|
|
|
saveLevel2City(wlyyQuotaId, cityMap, cityTeam,deleteData.get(3),foreachNum,type,start);
|
|
|
//保存区
|
|
|
saveLevel2Town(wlyyQuotaId, townsMap, townTeam,deleteData.get(2),foreachNum,type,start);
|
|
|
//保存机构
|
|
|
saveLevel2Org(wlyyQuotaId, hospitalsMap, orgTeam,deleteData.get(1),foreachNum,type,start);
|
|
|
//保存全科团队
|
|
|
saveLevel2Team(wlyyQuotaId, adminTeamMap, adminTeam,deleteData.get(0),foreachNum,type,start);
|
|
|
// //保存市
|
|
|
// saveLevel2City(wlyyQuotaId, cityMap, cityTeam,deleteData.get(3),foreachNum,type,start);
|
|
|
// //保存区
|
|
|
// saveLevel2Town(wlyyQuotaId, townsMap, townTeam,deleteData.get(2),foreachNum,type,start);
|
|
|
// //保存机构
|
|
|
// saveLevel2Org(wlyyQuotaId, hospitalsMap, orgTeam,deleteData.get(1),foreachNum,type,start);
|
|
|
// //保存全科团队
|
|
|
// saveLevel2Team(wlyyQuotaId, adminTeamMap, adminTeam,deleteData.get(0),foreachNum,type,start);
|
|
|
}else{
|
|
|
//保存市
|
|
|
saveLevel2City(wlyyQuotaId, cityMap, cityTeam,foreachNum,type,start);
|
|
@ -681,8 +682,8 @@ public class RedisStorage {
|
|
|
jo.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
jo.put("num", num);
|
|
|
String key=i+"";
|
|
|
jo.put("name", key);
|
|
|
jo.put("code", Constant.getLevelSexName(key));
|
|
|
jo.put("name", getLevel2Name(key,type));
|
|
|
jo.put("code",key);
|
|
|
|
|
|
StringBuffer sb=new StringBuffer("quota:"+wlyyQuotaId+":1:"+adminTeam.getKey().toString()+":"+key+":"+timeKey);
|
|
|
keys.add(sb.toString());
|
|
@ -730,7 +731,7 @@ public class RedisStorage {
|
|
|
for(Map.Entry<String,Town> town:townsMap.entrySet()){
|
|
|
Map<String, List<ETLModel>> oneELTMap= eltModel.get(town.getKey());
|
|
|
JSONArray level2=new JSONArray();
|
|
|
for(int i=1;i<=foreachNum;i++){
|
|
|
for(int i=start;i<=foreachNum;i++){
|
|
|
JSONObject jo=new JSONObject();
|
|
|
int num=0;
|
|
|
if(oneELTMap!=null){
|
|
@ -742,13 +743,12 @@ public class RedisStorage {
|
|
|
jo.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
jo.put("num", num);
|
|
|
String key=i+"";
|
|
|
jo.put("name", key);
|
|
|
jo.put("code", Constant.getLevelSexName(key));
|
|
|
jo.put("name", getLevel2Name(key,type));
|
|
|
jo.put("code",key);
|
|
|
|
|
|
StringBuffer sb=new StringBuffer("quota:"+wlyyQuotaId+":3:"+town.getKey()+":"+key+":"+timeKey);
|
|
|
keys.add(sb.toString());
|
|
|
redisTemplate.opsForValue().set(sb.toString(), jo.toString());
|
|
|
|
|
|
level2.put(jo);
|
|
|
|
|
|
}
|
|
@ -776,14 +776,14 @@ public class RedisStorage {
|
|
|
jo.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
jo.put("num", num);
|
|
|
String key=i+"";
|
|
|
jo.put("name", key);
|
|
|
jo.put("code", Constant.getLevelSexName(key));
|
|
|
jo.put("name", getLevel2Name(key,type));
|
|
|
jo.put("code",key);
|
|
|
|
|
|
addJOLeval2(townjr,hospitalObj.getTown(),key,jo);
|
|
|
|
|
|
level2.put(jo);
|
|
|
StringBuffer sb=new StringBuffer("quota:"+wlyyQuotaId+":2:"+hospital.getKey().toString()+":"+key+":"+timeKey);
|
|
|
keys.add(sb.toString());
|
|
|
redisTemplate.opsForValue().set(sb.toString(), level2.toString());
|
|
|
redisTemplate.opsForValue().set(sb.toString(), jo.toString());
|
|
|
|
|
|
}
|
|
|
StringBuffer sb=new StringBuffer("quota:"+wlyyQuotaId+":2:"+hospital.getKey().toString()+":"+timeKey);
|
|
@ -896,7 +896,7 @@ public class RedisStorage {
|
|
|
jo.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
jo.put("num", num);
|
|
|
jo.put("name", adminTeamObj.getName());
|
|
|
jo.put("code", adminTeamObj.getId());
|
|
|
jo.put("code", adminTeamObj.getId()+"");
|
|
|
|
|
|
String orgKey=adminTeamObj.getOrgCode();
|
|
|
Hospital hospital=hospitalsMap.get(orgKey);
|
|
@ -922,14 +922,12 @@ public class RedisStorage {
|
|
|
keys.add(key.toString());
|
|
|
redisTemplate.opsForValue().set(key.toString(), entry.getValue().toString());
|
|
|
}
|
|
|
townjr.clear();
|
|
|
//保存机构下面全部的团队
|
|
|
for(Map.Entry<String,JSONArray> entry:orgjr.entrySet()){
|
|
|
key=new StringBuffer("quota:"+wlyyQuotaId+":2:"+entry.getKey()+":1:"+timeKey);
|
|
|
keys.add(key.toString());
|
|
|
redisTemplate.opsForValue().set(key.toString(), entry.getValue().toString());
|
|
|
}
|
|
|
orgjr.clear();
|
|
|
}
|
|
|
private void saveLevel1Team(String wlyyQuotaId, Map<String, AdminTeam> adminTeamMap, Map<String, List<ETLModel>> adminTeam, Map<String, List<ETLModel>> deleteAdminTeam) {
|
|
|
for(Map.Entry<String,AdminTeam> entry:adminTeamMap.entrySet()){
|
|
@ -990,7 +988,6 @@ public class RedisStorage {
|
|
|
keys.add(key.toString());
|
|
|
redisTemplate.opsForValue().set(key.toString(), entry.getValue().toString());
|
|
|
}
|
|
|
townjr.clear();
|
|
|
}
|
|
|
|
|
|
private void addJO(Map<String, JSONArray> townjr,String key, JSONObject jo) {
|
|
@ -1111,7 +1108,7 @@ public class RedisStorage {
|
|
|
jo.put("name", entry.getValue().getName());
|
|
|
jo.put("code", entry.getValue().getCode());
|
|
|
jr.put(jo);
|
|
|
StringBuffer key=new StringBuffer("quota:"+wlyyQuotaId+":"+entry.getKey()+":3:"+timeKey);
|
|
|
StringBuffer key=new StringBuffer("quota:"+wlyyQuotaId+":3:"+entry.getKey()+":"+timeKey);
|
|
|
keys.add(key.toString());
|
|
|
redisTemplate.opsForValue().set(key.toString(), jo.toString());
|
|
|
}
|
|
@ -1121,6 +1118,7 @@ public class RedisStorage {
|
|
|
redisTemplate.opsForValue().set(key.toString(), jr.toString());
|
|
|
}
|
|
|
private void saveLevel1City(String wlyyQuotaId, Map<String, City> cityMap, Map<String, List<ETLModel>> cityTeam, Map<String, List<ETLModel>> deleteCityTeam) {
|
|
|
JSONArray jr=new JSONArray();
|
|
|
for(Map.Entry<String,City> entry:cityMap.entrySet()){
|
|
|
JSONObject jo=new JSONObject();
|
|
|
Integer num=0;
|
|
@ -1138,8 +1136,11 @@ public class RedisStorage {
|
|
|
jo.put("num", num);
|
|
|
jo.put("name", entry.getValue().getName());
|
|
|
jo.put("code", entry.getValue().getCode());
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:"+wlyyQuotaId+":4:"+entry.getKey()).toString(), jo.toString());
|
|
|
jr.put(jo);
|
|
|
}
|
|
|
StringBuffer key=new StringBuffer("quota:"+wlyyQuotaId+":4:"+Constant.city+":");
|
|
|
keys.add(key.toString());
|
|
|
redisTemplate.opsForValue().set(key.toString(), jr.toString());
|
|
|
}
|
|
|
private void saveLevel1City(String wlyyQuotaId, Map<String, City> cityMap, Map<String, List<ETLModel>> cityTeam) {
|
|
|
for(Map.Entry<String,City> entry:cityMap.entrySet()){
|
|
@ -1153,10 +1154,11 @@ public class RedisStorage {
|
|
|
jo.put("num", num);
|
|
|
jo.put("name", entry.getValue().getName());
|
|
|
jo.put("code", entry.getValue().getCode());
|
|
|
StringBuffer key=new StringBuffer("quota:"+wlyyQuotaId+":4:"+entry.getKey()+":"+timeKey);
|
|
|
StringBuffer key=new StringBuffer("quota:"+wlyyQuotaId+":4:"+Constant.city+":"+timeKey);
|
|
|
keys.add(key.toString());
|
|
|
redisTemplate.opsForValue().set(key.toString(), jo.toString());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
private String getLevel2Name(String i, Integer type) {
|
|
|
switch (type){
|
|
@ -1177,6 +1179,10 @@ public class RedisStorage {
|
|
|
return Constant.getLevelDiseaseName(i);
|
|
|
}
|
|
|
case 5:{
|
|
|
//疾病
|
|
|
return Constant.getlevelHealthFbName(i);
|
|
|
}
|
|
|
case 6:{
|
|
|
//疾病
|
|
|
return Constant.getLevelExpenseName(i);
|
|
|
}
|