Bläddra i källkod

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

wangzhinan 7 år sedan
förälder
incheckning
cc9ad8274c

+ 2 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/device/DeviceHealthIndexService.java

@ -69,8 +69,8 @@ public class DeviceHealthIndexService extends BaseDeviceJpaService<DeviceHealthI
        StringBuilder filter = new StringBuilder();
        String sql =" SELECT i.* ,s.name userName FROM device.wlyy_patient_health_index i , wlyy.wlyy_sign_family s WHERE s. STATUS > 0  and i.user=s.patient ";
        String countSql =" SELECT count(1) as num FROM device.wlyy_patient_health_index i, wlyy.wlyy_sign_family s WHERE s. STATUS > 0  and i.user=s.patient ";
        String sql =" SELECT i.* ,s.name userName FROM device.wlyy_patient_health_index i , wlyy.wlyy_patient s WHERE  i.user=s.code ";
        String countSql =" SELECT count(1) as num FROM device.wlyy_patient_health_index i, wlyy.wlyy_patient s WHERE  i.user=s.code ";
        //1、管理员  2、医生 0、其他
        if(loginUser.getType()==2){
            Doctor doctor = doctorDao.findByCode(loginUser.getCode());

+ 10 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/model/PatientHealthIndex.java

@ -48,6 +48,8 @@ public class PatientHealthIndex extends IdEntity {
	//设备编号
	private String deviceSn;
	private String button;//按键号
	private Integer status;//状态:0为标准,1为异常
	private Integer manageResult;//异常数据处理 0未干预 1异常有效干预 2异常无效干预
@ -203,4 +205,12 @@ public class PatientHealthIndex extends IdEntity {
	public void setManageResult(Integer manageResult) {
		this.manageResult = manageResult;
	}
	public String getButton() {
		return button;
	}
	public void setButton(String button) {
		this.button = button;
	}
}

+ 1 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java

@ -506,6 +506,7 @@ public class DeviceService extends BaseService{
            String user = device.getUser();
            obj.setUser(user);
            obj.setButton(userType);
            obj.setIdcard(device.getUserIdcard());
            obj.setStatus(0);
            //  1血糖 2血压 3体重 4腰围

+ 14 - 4
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/DeviceTypeConvert.java

@ -37,12 +37,22 @@ public class DeviceTypeConvert implements Convert {
        return oneList;
    }
    //1、血糖,2、血压
    public String getKey(DataModel dataModel,List<Map<String,Object>> dict){
        for (Map<String,Object> one : dict){
            String result = one.get("name")+"";
            if(dataModel.getServerType().equals(result)||dataModel.getServerType().indexOf(result)>=0){
                return one.get("code")+"";
        if("1".equals(dataModel.getServerType())){
             for (Map<String,Object> one : dict){
                String result = one.get("name")+"";
                if(result.equals("血糖")){
                    return one.get("code")+"";
                }
            }
        }else if("2".equals(dataModel.getServerType())){
            for (Map<String,Object> one : dict){
                String result = one.get("name")+"";
                if(result.equals("血压")){
                    return one.get("code")+"";
                }
            }
        }
        return "";

+ 4 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java

@ -437,4 +437,8 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    //查看团队内医生签约人数
    @Query("select count(1) from SignFamily a where a.status > 0 and a.adminTeamId = ?1 and (a.doctor = ?2 or a.doctorHealth = ?2)")
    int countByAdminTeamId(Long adminTeamId, String doctor);
    //根据居民和医生找出居民签约团队
    @Query("select f from SignFamily f where f.status > 0 and f.patient = ?1 and ( f.doctor = ?2 or doctorHealth = ?2  )")
    SignFamily findSignFamilyByPatientAndDoctor(String patient, String doctor);
}

+ 4 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyService.java

@ -450,4 +450,8 @@ public class FamilyService {
        String salt= "c89233bd15994b68ab3708ce79d5c2c4";
        System.out.println(MD5.GetMD5Code(password+salt));
    }
    public SignFamily findByPatientAndDoctor(String patient, String doctor) {
        return signFamilyDao.findSignFamilyByPatientAndDoctor(patient, doctor);
    }
}

+ 216 - 13
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java

@ -20,6 +20,7 @@ import com.yihu.wlyy.util.ElasticsearchUtil;
import com.yihu.wlyy.web.quota.vo.SaveModel;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.type.StringClobType;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -5573,15 +5574,15 @@ public class StatisticsESService {
                    int map1value = 0;
                    int map2value = 0;
                    if(sortType==1){
                        map1value = (int) o1.get("allNum");
                        map2value = (int) o2.get("allNum");
                        map1value = Integer.valueOf(o1.get("allNum").toString());
                        map2value = Integer.valueOf(o2.get("allNum").toString());
                    }else if(sortType==2){
                        map1value = (int) o1.get("bindingNum");
                        map2value = (int) o2.get("bindingNum");
                        map1value = Integer.valueOf(o1.get("bindingNum").toString());
                        map2value = Integer.valueOf(o2.get("bindingNum").toString());
                    }else {
                        map1value = (int) o1.get("rateNum");
                        map2value = (int) o2.get("rateNum");
                        map1value = Integer.valueOf(o1.get("rateNum").toString());
                        map2value = Integer.valueOf(o2.get("rateNum").toString());
                    }
                    if (map1value - map2value > 0) {
                        return sort == 1 ? -1 : 1;
@ -5624,7 +5625,7 @@ public class StatisticsESService {
                    }
//                    String sql = " select count(DISTINCT p.doctor,p.device_sn) AS amount,p.doctor as doctorCode,r.name as doctorName from wlyy.wlyy_patient_device p JOIN wlyy.wlyy_doctor r on p.doctor is not null and  p.doctor =r.code  LEFT JOIN device.wlyy_devices d on p.device_sn=d.device_code where p.del=0 and p.doctor is not null and d.grant_org_code ='" + hos.getCode() + "'  group by p.doctor,r.name";
                    String sql = " select count(*) as amount,if(a.doctor is null,'other',a.doctor) as doctorCode,if(a.NAME is null,'其他',a.NAME) as doctorName " +
                            " from (select  DISTINCT p.doctor,r.name,p.device_sn FROM wlyy.wlyy_patient_device p left join device.wlyy_devices d on p.device_sn=d.device_code left JOIN wlyy.wlyy_doctor r ON  p.doctor = r. CODE " +
                            " from (select  DISTINCT p.doctor,r.name,p.device_sn FROM wlyy.wlyy_patient_device p RIGHT join device.wlyy_devices d on p.device_sn=d.device_code left JOIN wlyy.wlyy_doctor r ON  p.doctor = r. CODE " +
                            "where p.del=0 and d.is_binding in (1,2) and p.category_code in('1','2') and d.grant_org_code ='" + hos.getCode() + "') a " +
                            " GROUP BY a.doctor,a.name";
                    List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
@ -6202,7 +6203,7 @@ public class StatisticsESService {
        return rsJs;
    }*/
    public JSONArray getDeviceLowLevelTotal(String date, String area, int level, String index, int sort, String lowLevel, String year) throws Exception {
    /*public JSONArray getDeviceLowLevelTotal(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<>();
@ -6212,7 +6213,8 @@ public class StatisticsESService {
        List<SaveModel> esModelList = new ArrayList<>();
        if ((level == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".equals(lowLevel))) {
            String time = DateUtil.getStringDateShort();
            //String time = DateUtil.getStringDateShort();
            String time= elasticsearchUtil.getQuotaTime();
            String sql ="SELECT" +
                    " pd.doctor team," +
                    " pd.doctor_name teamName," +
@ -6225,8 +6227,8 @@ public class StatisticsESService {
                    " AND pd.del = 0" +
                    " AND pd.category_code IN (1, 2)" +
                    " AND pd.czrq>='2018-06-30 17:00:00'"+
                    " AND pd.czrq < '"+time+" 17:00:00'" +
                    " AND LEFT(pd.czrq,4)= '"+year+"'";
                    " AND pd.czrq <= '"+time+"'" +
                    " AND LEFT(pd.czrq,4)= '"+year+"' AND grant_admin_team NOT IN(SELECT id FROM wlyy_admin_team WHERE LENGTH(org_code)!=10)";
            if(level==3){
                sql +=" AND LEFT(dw.grant_org_code,6)= '"+area+"'";
            }else if (level==4){
@ -6235,7 +6237,7 @@ public class StatisticsESService {
            sql +=" GROUP BY team";
            esModelList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SaveModel.class));
        }else {
            esModelList = (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0(date, area, level, index, SaveModel.timeLevel_DDL, low_level);
            esModelList = (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0("2018-07-01",date, area, level, index, SaveModel.timeLevel_ZL, low_level);
        }
        if (esModelList != null && esModelList.size() > 0) {
@ -6267,10 +6269,135 @@ public class StatisticsESService {
        }
        // 结果为空时,自建结果集
        if (resultList == null || resultList.size() < 1) {
        *//*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("5")) {
                    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 == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".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();
        }
    }*/
    public JSONArray getDeviceLowLevelTotal(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<>();
        if (date.compareTo(dateFormat.format(new Date())) >= 0) {
            date = elasticsearchUtil.getQuotaTime();
        }
        List<SaveModel> esModelList = new ArrayList<>();
        List<Map<String,Object>> sqlList = new ArrayList<>();
        if ((level == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".equals(lowLevel))) {
            //String time = DateUtil.getStringDateShort();
            String time=  redisTemplate.opsForValue().get("quota:date");
            String sql ="SELECT" +
                    " d.device_code," +
                    " pd.doctor," +
                    " pd.doctor_name," +
                    " pd.user_type" +
                    " FROM" +
                    " device.wlyy_devices d" +
                    " LEFT JOIN wlyy.wlyy_patient_device pd ON d.device_code = pd.device_sn" +
                    " WHERE" +
                    " d.is_binding IN (1, 2)" +
                    " AND pd.category_code IN ('1', '2')" +
                    " AND d.grant_time <= '"+time+"'" +
                    " AND d.grant_admin_team NOT IN(SELECT id FROM wlyy_admin_team WHERE LENGTH(org_code)!=10)"+
                    " ";
            if(level==3){
                sql +=" AND d.grant_admin_team IN(SELECT id FROM wlyy_admin_team WHERE LEFT(org_code,6) = '"+area+"'AND available = 1) AND LEFT(d.grant_org_code,6)= '"+area+"'";
            }else if (level==4){
                sql +=" AND d.grant_admin_team IN(SELECT id FROM wlyy_admin_team WHERE org_code = '"+area+"'AND available = 1) AND d.grant_org_code = '"+area+"'";
            }else if (level==2){
                sql +=" AND d.grant_admin_team IN(SELECT id FROM wlyy_admin_team WHERE available = 1)";
            }
            sqlList = jdbcTemplate.queryForList(sql);
        }else {
            esModelList = (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0(year+"-07-01",date, area, level, index, SaveModel.timeLevel_ZL, low_level);
        }
        esModelList = getDeviceBindToTeam(sqlList);
        //到绑定人的封装数据
        if (esModelList != null && esModelList.size() > 0) {
            for (SaveModel one : esModelList) {
                Map<String, Object> maps = new HashMap<String, Object>();
                maps.put("amount", one.getResult1().intValue());
                if (low_level.equals("3")) {
                    maps.put("code", one.getTown());
                    maps.put("name", one.getTownName());
                } else if (low_level.equals("4")) {
                    maps.put("code", one.getHospital());
                    maps.put("name", one.getHospitalName());
                } else if (low_level.equals("5")) {
                    if (StringUtils.isNotEmpty(one.getTeam())){
                        maps.put("code", one.getTeam());
                        if (StringUtils.isEmpty(one.getTeamName())){
                            Doctor doctor = doctorDao.findByCode(one.getTeam());
                            if (doctor!=null){
                                maps.put("name", doctor.getName());
                            }
                        }else {
                            maps.put("name", one.getTeamName());
                        }
                    }
                    if (StringUtils.isEmpty(one.getTeam())){
                        maps.put("code","0");
                        maps.put("name", "其他");
                    }
                }
                resultList.add(maps);
            }
        }
        // 结果为空时,自建结果集
        /*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) {
@ -6315,4 +6442,80 @@ public class StatisticsESService {
            return new JSONArray();
        }
    }
    public List<SaveModel> getDeviceBindToTeam(List<Map<String,Object>> dataList) throws Exception{
        if (dataList==null && dataList.size()==0){
            return  null;
        }
        Map<String,Object> resultMap = new HashedMap();
        List<SaveModel> resultList = new ArrayList<>();
        //如果有两个键,则取a键
        for (Map<String,Object> map : dataList){
            String deviceSn = String.valueOf(map.get("device_code"));
            List<Map<String,Object>> deviceList =  null;
            if (resultMap.containsKey(deviceSn)){
                deviceList = (List<Map<String,Object>>)resultMap.get(deviceSn);
                String userType = String.valueOf(deviceList.get(0).get("user_type"));
                if (Integer.parseInt(String.valueOf(map.get("user_type")))<Integer.parseInt(userType)){
                    deviceList.clear();
                    deviceList.add(map);
                }
            }else {
                deviceList = new ArrayList<>();
                deviceList.add(map);
            }
            resultMap.put(deviceSn,deviceList);
        }
        //遍历map
        List<Map<String,Object>> mapList = new ArrayList<>();
        resultMap.forEach((key, value) -> {
            mapList.addAll((List<Map<String,Object>>)value);
        });
        //根据医生code聚合返回页面所需要结果
         Map<String,Object> doctorMap = new HashedMap();
         for (Map<String,Object> map2 : mapList){
             String key = "";
             String doctor = "";
             String doctorName = "";
             if (map2.get("doctor")!= null){
                 doctor = String.valueOf(map2.get("doctor"));
             }
             if (map2.get("doctor_name")!=null){
                 doctorName = String.valueOf(map2.get("doctor_name"));
             }
             if (StringUtils.isEmpty(doctor)){
                 key ="qita,";
             }else if (StringUtils.isNotBlank(doctor)){
                 key =doctor+","+doctorName;
             }
             int count = 0;
             if (doctorMap.containsKey(key)){
                 count = Integer.valueOf(String.valueOf(doctorMap.get(key)));
             }
             count++;
             doctorMap.put(key,count);
         }
         //遍历map
        for (Map.Entry<String,Object> entry : doctorMap.entrySet()){
             SaveModel saveModel = new SaveModel();
             String key = entry.getKey();
             String[] keyStr = key.split(",");
             if(keyStr[0].equals("qita")){
                 saveModel.setTeam("");
             }else {
                 saveModel.setTeam(keyStr[0]);
             }
             if (keyStr.length>1){
                 saveModel.setTeamName(keyStr[1]);
             }
             saveModel.setResult1(Double.valueOf(String.valueOf(entry.getValue())));
             resultList.add(saveModel);
        }
        return  resultList;
    }
}

+ 142 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/RehabilitationPlanService.java

@ -0,0 +1,142 @@
package com.yihu.wlyy.service.specialist;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
 * Created by Trick on 2018/8/22.
 */
@Service
@Transactional
public class RehabilitationPlanService extends BaseService {
    @Value("${specialist.url}")
    private String specialistUrl;
    public JSONObject findTemplateInfo(Long teamId) {
        Map<String, Object> param = new HashedMap();
        param.put("adminTeamCode", teamId);
        HttpResponse response = null;
        try {
            response = HttpUtils.doGet(specialistUrl + "svr-specialist/findRehabilitationPlanTemplate", param);
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject rs = new JSONObject(response.getContent());
        return rs;
    }
    public JSONObject findTemplateDetailInfo(String templateId) {
        Map<String, Object> param = new HashedMap();
        param.put("templateId", templateId);
        HttpResponse response = null;
        try {
            response = HttpUtils.doGet(specialistUrl + "svr-specialist/findTemplateDetailByTemplateId", param);
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject rs = new JSONObject(response.getContent());
        return rs;
    }
    public String createTemplate(String title, Doctor doctor, Long teamId) {
        JSONObject json = new JSONObject();
        json.put("title", title);
        json.put("adminTeamCode", teamId);
        json.put("hospital", doctor.getHospital());
        json.put("hospitalName", doctor.getHospitalName());
        json.put("createUser", doctor.getCode());
        json.put("createUserName", doctor.getName());
        Map<String, Object> param = new HashedMap();
        param.put("rehabilitationTemplate", json.toString());
        HttpResponse response = null;
        try {
            response = HttpUtils.doPost(specialistUrl + "svr-specialist/createRehabilitationPlanTemplate", param);
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject rs = new JSONObject(response.getContent());
        if ("success".equals(rs.getString("message"))) {
            return rs.getString("obj");
        }
        return rs.getString("message");
    }
    public String createTemplateDetail(String json, String type, Doctor doctor) {
        JSONObject object = new JSONObject(json);
        JSONArray details = new JSONArray();
        String templateId = object.get("templateId").toString();
        String serviceItemIds = object.get("hospitalServiceItemIds").toString();
        if(serviceItemIds.contains(",")) {
            String [] itemIds = serviceItemIds.split(",");
            int len = itemIds.length;
            while (len > 0){
                len --;
                JSONObject j = new JSONObject();
                j.put("templateId", templateId);
                j.put("hospitalServiceItemId", itemIds[len]);
                j.put("createUser", doctor.getCode());
                j.put("createUserName", doctor.getName());
                details.put(len, j);
            }
        }
        Map<String, Object> param = new HashedMap();
        param.put("rehabilitationTemplateDetail", details.toString());
        HttpResponse response = null;
        try {
            if(type.equals("create")) {
                response = HttpUtils.doPost(specialistUrl + "svr-specialist/createRehabilitationTemplateDetail", param);
            }else if(type.equals("edit")) {
                response = HttpUtils.doPost(specialistUrl + "svr-specialist/updateRehabilitationTemplateDetail", param);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject rs = new JSONObject(response.getContent());
        return rs.getString("message");
    }
    public JSONObject findServiceItemsByHospital(SignFamily signFamily, Doctor doctor) {
        List<String> hospitals = null;
        hospitals.add(doctor.getHospital());
        hospitals.add(signFamily.getHospital());
        Map<String, Object> param = new HashedMap();
        param.put("hospitals", hospitals);
        HttpResponse response = null;
        try {
            response = HttpUtils.doPost(specialistUrl + "svr-specialist/", param);
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject rs = new JSONObject(response.getContent());
        return rs;
    }
    public String createRehabilitationPlan(String json, Doctor doctor) {
        JSONObject object = new JSONObject(json);
        object.put("createUser", doctor.getCode());
        object.put("createUserName", doctor.getName());
        Map<String, Object> param = new HashedMap();
        param.put("rehabilitationPlan", json.toString());
        HttpResponse response = null;
        try {
            response = HttpUtils.doPost(specialistUrl + "svr-specialist/createPatientRehabilitationPlan", param);
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject rs = new JSONObject(response.getContent());
        return rs.getString("message");
    }
}

+ 12 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -517,6 +517,11 @@ public class EsStatisticsController extends BaseController {
                    if ("13".equals(idx)) {
                        idx = "1";
                    }
                    //20指标一个键绑定一条数据 2018年开始所以改用86指标. 2018-08-27 zd
                    String thisYear = Constant.getNowYearByDate(endDate);
                    if ("20".equals(idx) && Integer.valueOf(thisYear)>=2018){
                        idx="86";
                    }
                    JSONObject json = statisticsESService.getDateTotal(startDate, endDate, interval, area, level, idx, lowCode, year,SaveModel.timeLevel_DDL);
                    result.put("index_" + idx, json);
                }
@ -531,7 +536,7 @@ public class EsStatisticsController extends BaseController {
    }
    /**
     * 指标截止日期累积量 到达量
     * 指标截止日期累积量 到达量.
     *
     * @param date
     * @param area
@ -592,7 +597,8 @@ public class EsStatisticsController extends BaseController {
                    } else if (idx.equals("72")) {
                        result.put("index_" + idx, statisticsESService.getLowLevelTotalOnlineTeamLeader(date, area, level, idx, sort, lowLevel, year, ""));
                    }else if (idx.equals("20") && Integer.valueOf(year)>=2018){
                        result.put("index_" + idx, statisticsESService.getDeviceLowLevelTotal(date, area, level, idx, sort, lowLevel, year));
                        //20指标是一个键绑定一条数据 所以2018年开始使用86指标 2018-08-27 zd
                        result.put("index_" + idx, statisticsESService.getDeviceLowLevelTotal(date, area, level, "86", sort, lowLevel, year));
                    }else {
                        result.put("index_" + idx, statisticsESService.getLowLevelTotal(date, area, level, idx, sort, lowLevel, year));
                    }
@ -659,7 +665,10 @@ public class EsStatisticsController extends BaseController {
            JSONObject result = new JSONObject();
            for (String idx : indexes) {
                Long total = statisticsESService.getIndexTotal(endDate, area, level, idx, "2");
                if ("20".equals(idx) && Integer.valueOf(year)>=2018){
                    idx = "86";
                }
                Long total=statisticsESService.getIndexTotal(endDate, area, level, idx, "2");
                result.put("index_" + idx, total);
            }

+ 134 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/specialist/ThirdRehabilitationPlanController.java

@ -0,0 +1,134 @@
package com.yihu.wlyy.web.third.specialist;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.service.app.family.FamilyService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.specialist.RehabilitationPlanService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by humingfen on 2018/8/22.
 */
@RestController
@RequestMapping(value = "/third/rehabilitaionPlan",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "康复服务套餐管理")
public class ThirdRehabilitationPlanController extends BaseController {
    @Autowired
    private RehabilitationPlanService rehabilitationPlanService;
    @Autowired
    private AdminTeamService teamService;
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private FamilyService familyService;
    @RequestMapping(value = "/findTemplateList", method = RequestMethod.GET)
    @ApiOperation(value = "获取康复服务套餐模板列表")
    public String templateList(@ApiParam(name = "patient", value = "居民标识")
                                   @RequestParam(required = false)String patient){
        try {
            Long adminTeamId = null;
            if(StringUtils.isNotBlank(patient)) {
                SignFamily signFamily = familyService.findByPatientAndDoctor(patient, getUID());
                adminTeamId = signFamily.getAdminTeamId();
            }else {
                AdminTeam team = teamService.findByLeaderCode(getUID());
                adminTeamId = team.getId();
            }
            return write(200, "获取成功", "data", rehabilitationPlanService.findTemplateInfo(adminTeamId));
//            return write(200, "获取成功", "data", rehabilitationPlanService.findTemplateInfo((long) 646));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/findTemplateDetail", method = RequestMethod.GET)
    @ApiOperation(value = "获取康复服务套餐模板明细")
    public String findTemplateDetail(@ApiParam(name = "templateId", value = "模板id")
                                         @RequestParam(required = true)String templateId){
        try {
            return write(200, "获取成功", "data", rehabilitationPlanService.findTemplateDetailInfo(templateId));
//            return write(200, "获取成功", "data", rehabilitationPlanService.findTemplateInfo((long) 646));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/createTemplate", method = RequestMethod.POST)
    @ApiOperation(value = "创建康复服务套餐模板")
    public String createTemplate(@ApiParam(name = "title", value = "康复服务模板名称")
                                 @RequestParam(required = true) String title){
        try {
            AdminTeam team = teamService.findByLeaderCode(getUID());
            Doctor doctor = doctorService.findDoctorByCode(getUID());
            return write(200, "获取成功", "data", rehabilitationPlanService.createTemplate(title,doctor,team.getId()));
//            Doctor doctor = doctorService.findDoctorByCode("0272469a6dcf11e69f7c005056850d66");
//            return write(200, "获取成功", "data", rehabilitationPlanService.createTemplate(title,doctor,(long) 646));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/createTemplateDetail", method = RequestMethod.POST)
    @ApiOperation(value = "创建康复服务套餐模板明细")
    public String createTemplateDetail(@ApiParam(name = "json", value = "康复服务模板明细")
                                 @RequestParam(required = true) String json,
                                       @ApiParam(name = "type", value = "create或者edit")
                                       @RequestParam(required = true) String type){
        try {
//            Doctor doctor = doctorService.findDoctorByCode(getUID());
//            return write(200, "获取成功", "data", rehabilitationPlanService.createTemplate(title,doctor,team.getId()));
            Doctor doctor = doctorService.findDoctorByCode("0272469a6dcf11e69f7c005056850d66");
            return write(200, "获取成功", "data", rehabilitationPlanService.createTemplateDetail(json,type,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/findServiceItemsByHospital", method = RequestMethod.GET)
    @ApiOperation(value = "根据机构查找服务项目列表")
    public String findServiceItemsByHospital(@ApiParam(name = "patient", value = "居民标识")
                                                 @RequestParam(required = true)String patient){
        try {
//            Doctor doctor = doctorService.findDoctorByCode(getUID());
            SignFamily signFamily = familyService.findByPatientAndDoctor(patient, getUID());
            Doctor doctor = doctorService.findDoctorByCode("0272469a6dcf11e69f7c005056850d66");
            return write(200, "获取成功", "data", rehabilitationPlanService.findServiceItemsByHospital(signFamily,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/createRehabilitationPlan", method = RequestMethod.POST)
    @ApiOperation(value = "创建居民康复计划")
    public String createRehabilitationPlan(@ApiParam(name = "json", value = "康复计划json")
                                 @RequestParam(required = true) String json){
        try {
//            Doctor doctor = doctorService.findDoctorByCode(getUID());
            Doctor doctor = doctorService.findDoctorByCode("0272469a6dcf11e69f7c005056850d66");
            return write(200, "获取成功", "data", rehabilitationPlanService.createRehabilitationPlan(json,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
}