瀏覽代碼

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

wangzhinan 7 年之前
父節點
當前提交
2e4a84ea48

+ 2 - 2
edu-article/JkEdu/src/Article.sql.xml

@ -31,8 +31,8 @@ User_ArticleStatistics n on aa.ArticleId=n.ArticleId where 1=1 @Condition
		</Sql>-->
		<Sql name='getCollectionArticleList'>
			<![CDATA[
select aa.* ,n.BrowseNumber,n.PointNumber,n.CollectionNumber,IFNULL(n.CommentNumber,0) as CommentNumber, IFNULL(n.PushNumber,0) as PushNumber,n.InsertTime as collectionInsertTime from (
select m.* from Org_Article m  INNER JOIN User_ArticleCollection n on  m.articleid=n.ArticleId and  1=1 and  m.ArticleState =1  @UserParam) as aa LEFT JOIN
select aa.* ,n.BrowseNumber,n.PointNumber,n.CollectionNumber,IFNULL(n.CommentNumber,0) as CommentNumber, IFNULL(n.PushNumber,0) as PushNumber from (
select m.*,n.InsertTime as collectionInsertTime from Org_Article m  INNER JOIN User_ArticleCollection n on  m.articleid=n.ArticleId and  1=1 and  m.ArticleState =1  @UserParam) as aa LEFT JOIN
User_ArticleStatistics n on aa.ArticleId=n.ArticleId where 1=1 @Condition
			]]>
		</Sql>

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyScreenResultDao.java

@ -18,8 +18,8 @@ public interface SurveyScreenResultDao extends PagingAndSortingRepository<Survey
    @Query(nativeQuery = true, value = "SELECT * FROM `wlyy_survey_screen_result` WHERE template_code=?1 and patient_code = ?2 and source=1 ORDER BY czrq DESC LIMIT 1")
    List<SurveyScreenResult> findNewOneByTemplateCode(String templateCode,String patientCode);
    @Query("select a from  SurveyScreenResult a where a.patientCode=?1 and a.templateCode=?2")
    List<SurveyScreenResult> getByPatientCodeAndTemplateCode(String patientCode,String templateCode);
    @Query("select a from  SurveyScreenResult a where a.patientCode=?1 and a.templateCode=?2 and a.source=?3")
    List<SurveyScreenResult> getByPatientCodeAndTemplateCode(String patientCode,String templateCode,int source);
    @Modifying
    @Query("update SurveyScreenResult s set s.isAgain=0 where s.code=?1")

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

@ -792,6 +792,15 @@ public class StatisticsESService {
        String filesize = df.format(size);
        return filesize + "%";
    }
    public int getRangeNum(int first, int second, int i) {
        if (second == 0 && first > 0) {
            return 100;
        } else if (second == 0 && first == 0) {
            return 0;
        }
        float size = (float) (first * 100) / second;
        return (int)(size*100);
    }
    public Double getRange2(int first, int second, int i) {
        if (second == 0 && first > 0) {
@ -5397,12 +5406,13 @@ public class StatisticsESService {
        return saveModel.getResult2().longValue();
    }
    public Map<String, Object> getLevelDeviceAndBinding(String area, int level, int sort, String lowLevel, String year, String deviceType) throws Exception {
    public Map<String, Object> getLevelDeviceAndBinding(String area, int level, int sort, String lowLevel, String year, String deviceType,int sortType) throws Exception {
        String index_85 = "85";//设备发放量统计指标
        String index_86 = "86";//设备绑定量统计指标
        String index_87 = "87";//设备使用量统计指标
        String index_88 = "88";//设备异常数据24H统计指标
        String index_96 = "96";//设备本周使用量
        String index_97 = "97";//设备本周使用量
        //String lastDate = year + "-06-30";
        //String timeKey = elasticsearchUtil.getQuotaTime();
        String timeKey = DateUtil.getStringDateShort();//当前时间
@ -5419,6 +5429,7 @@ public class StatisticsESService {
//        List<SaveModel> endUseSaveModel = null;
        SaveModel useSaveModel = null;
        SaveModel anomalySaveModel = null;
        SaveModel anomalyCountSaveModel = null;
        String allCountSql = "";
        String anomalyCountSql = "";
        String useCountSql = "";
@ -5443,7 +5454,8 @@ public class StatisticsESService {
//                startUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, "hemopiezometer", null, null);
//                endUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, "hemopiezometer", null, null);
                anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_88, SaveModel.timeLevel_DDL, "hemopiezometer");
                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where i.type =1 and i.status=1 and i.del=1 " + areaCondition;
                anomalyCountSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_97, SaveModel.timeLevel_DDL, "hemopiezometer");
//                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where i.type =1 and i.status=1 and i.del=1 " + areaCondition;
                allAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "hemopiezometer", "", low_level);
                bindingAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "hemopiezometer", "", low_level);
                break;
@ -5457,7 +5469,8 @@ public class StatisticsESService {
//                startUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, "glucometer", null, null);
//                endUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, "glucometer", null, null);
                anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_88, SaveModel.timeLevel_DDL, "glucometer");
                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where i.type =2 and i.status=1 and i.del=1 " + areaCondition;
                anomalyCountSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_97, SaveModel.timeLevel_DDL, "glucometer");
//                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where i.type =2 and i.status=1 and i.del=1 " + areaCondition;
                allAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "glucometer", "", low_level);
                bindingAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "glucometer", "", low_level);
                break;
@ -5469,7 +5482,8 @@ public class StatisticsESService {
                allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d where 1=1 " + areaCondition;
//                useCountSql = "SELECT COUNT(DISTINCT p.device_sn)  FROM device.wlyy_patient_health_index p LEFT JOIN device.wlyy_devices d on d.device_code=p.device_sn WHERE p.type IN (1, 2) and p.del=1  and p.czrq>= '"+mondayTime+"' AND p.czrq < '"+currentTime+"' "+areaCondition ;
                useSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(DateUtil.getSundayOfThisDate(new Date()), area, level, index_96, SaveModel.timeLevel_ZL);
                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where  i.status=1 and i.del=1 " + areaCondition;
                anomalyCountSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey, area, level, index_97, SaveModel.timeLevel_DDL);
//                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where  i.status=1 and i.del=1 " + areaCondition;
//                startUseSaveModel = elasticsearchUtil.findDateQuotaLevel0(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, null, null);
//                endUseSaveModel = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, null, null);
                allAmountList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "", low_level);
@ -5503,7 +5517,8 @@ public class StatisticsESService {
        } else {
            resultMap.put("totalUseRange", 0.0 + "%");//本周使用率
        }
        Integer totalAnomaly = jdbcTemplate.queryForObject(anomalyCountSql, Integer.class);
//        Integer totalAnomaly = jdbcTemplate.queryForObject(anomalyCountSql, Integer.class);
        Integer totalAnomaly = anomalyCountSaveModel!=null?anomalyCountSaveModel.getResult1().intValue():0;
        resultMap.put("totalAnomaly", totalAnomaly);//异常数据量
        resultMap.put("totalIntervene", anomalySaveModel.getResult1());//干预指导数
        if (totalAnomaly > 0) {
@ -5547,10 +5562,21 @@ public class StatisticsESService {
            }
            //对结果进行排序
            Collections.sort(resultList, new Comparator<Map<String, Object>>() {
                public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                    int map1value = (int) o1.get("allNum");
                    int map2value = (int) o2.get("allNum");
                public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                    int map1value = 0;
                    int map2value = 0;
                    if(sortType==1){
                        map1value = (int) o1.get("allNum");
                        map2value = (int) o2.get("allNum");
                    }else if(sortType==2){
                        map1value = (int) o1.get("bindingNum");
                        map2value = (int) o2.get("bindingNum");
                    }else {
                        map1value = (int) o1.get("rateNum");
                        map2value = (int) o2.get("rateNum");
                    }
                    if (map1value - map2value > 0) {
                        return sort == 1 ? -1 : 1;
                    } else if (map1value - map2value < 0) {
@ -5673,6 +5699,7 @@ public class StatisticsESService {
        reMap.put("allNum", allAmount);
        reMap.put("bindingNum", bindingAmount);
        reMap.put("rate", getRange(bindingAmount, allAmount, 2));//续签率是 续签量/去年的签约数
        reMap.put("rateNum", getRangeNum(bindingAmount, allAmount, 2));//续签率是 续签量/去年的签约数
        return reMap;
    }

+ 7 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/survey/SurveyScreenResultService.java

@ -296,12 +296,13 @@ public class SurveyScreenResultService extends BaseService {
        infoMap.put("sex",IdCardUtil.getSexForIdcard_new(idcard));
        infoMap.put("age",IdCardUtil.getAgeForIdcard(idcard));
        String templateCode = String.valueOf(infoMap.get("template_code"));
        //String doctorCode = String.valueOf(infoMap.get("doctor"));
        String doctorCode = String.valueOf(infoMap.get("doctor"));
        String patientCode = String.valueOf(infoMap.get("patient_code"));
       /* Doctor doctor = doctorDao.findByCode(doctorCode);
        Doctor doctor = doctorDao.findByCode(doctorCode);
        if (doctor!=null){
            infoMap.put("level",doctor.getLevel());
            infoMap.put("doctorName",doctor.getName());
        }*/
        }
        json.put("info",infoMap);
        /*String healthSql ="SELECT value1,value2 FROM device.wlyy_patient_health_index WHERE user='"+patientCode+"' AND type=3 ORDER BY record_date DESC LIMIT 1";
        List<Map<String,Object>> healthMapList = jdbcTemplate.queryForList(healthSql);
@ -386,7 +387,7 @@ public class SurveyScreenResultService extends BaseService {
        for (SurveyTemplates surveyTemplates : templates){
            Map<String,Object> sMap = new HashedMap();
            sMap.put("surveyTemplate",surveyTemplates);
            int count =  surveyScreenResultDao.getByPatientCodeAndTemplateCode(patientCode,surveyTemplates.getCode()).size();
            int count =  surveyScreenResultDao.getByPatientCodeAndTemplateCode(patientCode,surveyTemplates.getCode(),2).size();
            sMap.put("myRecordCount",count);
            mapList.add(sMap);
        }
@ -395,14 +396,14 @@ public class SurveyScreenResultService extends BaseService {
    }
    public List<SurveyScreenResult> patientGetResult(String patientCode){
        Map<String,Object> map = new HashedMap();
        String sql = "SELECT a.* FROM (SELECT * FROM wlyy_survey_screen_result WHERE patient_code='"+patientCode+"' ORDER BY czrq DESC) a  GROUP BY a.template_code";
        String sql = "SELECT a.* FROM (SELECT * FROM wlyy_survey_screen_result WHERE source=2 and patient_code='"+patientCode+"' ORDER BY czrq DESC) a  GROUP BY a.template_code";
        List<SurveyScreenResult> surveyScreenResultList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(SurveyScreenResult.class));
        return surveyScreenResultList;
    }
    public List<Map<String,Object>> getResultByTemplateCode(int pageNo,int pageSize,String templateCode,String patientCode){
        int start = (pageNo-1)*pageSize;
        String sql ="SELECT st.*,ssr.code screenCode,ssr.screen_result,ssr.screen_result_score,ssr.czrq as screenCzrq,ssr.is_again FROM wlyy_survey_templates st LEFT JOIN wlyy_survey_screen_result ssr ON st.code = ssr.template_code WHERE st.`code`='"+templateCode+"' AND ssr.patient_code='"+patientCode+"' order by ssr.czrq limit ?,?";
        String sql ="SELECT st.*,ssr.code screenCode,ssr.screen_result,ssr.screen_result_score,ssr.czrq as screenCzrq,ssr.is_again FROM wlyy_survey_templates st LEFT JOIN wlyy_survey_screen_result ssr ON st.code = ssr.template_code WHERE ssr.source=2 and st.`code`='"+templateCode+"' AND ssr.patient_code='"+patientCode+"' order by ssr.czrq limit ?,?";
        return jdbcTemplate.queryForList(sql,new Object[]{start,pageSize});
    }

+ 42 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java

@ -658,6 +658,22 @@ public class SpecialistService extends BaseService {
        return null;
    }
    public JSONObject findPatientSignSpecialistInfo(String patient,String doctor) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("patient", patient);
        param.put("doctor", doctor);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/findPatientSignSpecialistInfo", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
            JSONObject j =rs.getJSONObject("obj");
            String relationCode =  j.getString("relationCode");
            j.put("server",patientDiseaseServerDao.findBySpecialistRelationCodeAndDel(relationCode,"1"));
            return j;
        }
        return null;
    }
    public void pushWeiTemp(String token, String state, String remark, Patient patient, Doctor doctor) {
        logger.info("pushWeiTemp:"+patient.getCode()+"__openid:"+patient.getOpenid());
        if (StringUtils.isNotBlank(patient.getOpenid())) {
@ -669,11 +685,11 @@ public class SpecialistService extends BaseService {
                json.put("toUser", patient.getCode());
                json.put("keyword1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                json.put("keyword2", temp.getKeyword2().replace("key1", doctor.getName()));
                json.put("remark", temp.getRemark().replace("key1", remark));
                json.put("remark", temp.getRemark().replace("key1", StringUtils.isBlank(remark)?"详情请联系您的专科医生":remark));
                json.put("first", temp.getFirst().replace("key1", patient.getName()));
            } else {
                //同意
                temp = templateConfigDao.findByScene("template_deal_with", "tdwspref");
                temp = templateConfigDao.findByScene("template_deal_with", "tdwspagr");
                json.put("toUser", patient.getCode());
                json.put("keyword1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                json.put("keyword2", temp.getKeyword2().replace("key1", doctor.getName()));
@ -687,5 +703,29 @@ public class SpecialistService extends BaseService {
        }
    }
    public Long findMessagePatientCount(String doctor){
        String sql ="SELECT " +
                " COUNT(s.sender) AS total " +
                " FROM " +
                " ( " +
                "  SELECT DISTINCT " +
                "   m.sender " +
                "  FROM " +
                "   wlyy_message m " +
                "  WHERE " +
                "   m.type IN (16,17) " +
                "  AND m.receiver = '"+doctor+"' " +
                "  AND m.has_read = 1 " +
                "  AND m.over = 1 " +
                " ) s";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        Long total = 0L;
        if(list!=null&&list.size()>0){
            Map<String,Object> map = list.get(0);
            total = (Long)map.get("total");
        }
        return total;
    }
}

+ 36 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistController.java

@ -267,4 +267,39 @@ public class SpecialistController extends WeixinBaseController {
        }
    }
    }
    @RequestMapping(value = "/findPatientSignSpecialistInfo", method = RequestMethod.GET)
    @ApiOperation(value = "获取居民与当前专科医生有效签约信息")
    public String findPatientSignSpecialistInfo(@ApiParam(name = "patient", value = "居民code") @RequestParam(required = true)String patient,
                                                @ApiParam(name = "doctor", value = "专科医生code") @RequestParam(required = true)String doctor) {
        try {
            return write(200, "获取成功", "data", specialistService.findPatientSignSpecialistInfo(patient,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/findMessagePatientCount", method = RequestMethod.GET)
    @ApiOperation(value = "获取等待专科医生处理消息人数")
    public String findMessagePatientCount(String doctor) {
        try {
            return write(200, "获取成功", "data", specialistService.findMessagePatientCount(doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/findPatientDiseaseServerList", method = RequestMethod.GET)
    @ApiOperation(value = "获取居民专病服务信息")
    public String findPatientDiseaseServerList(@ApiParam(name = "patient", value = "患者code") @RequestParam(required = true)String patient) {
        try {
            return write(200, "获取成功", "data", specialistService.findPatientDiseaseServerList(patient));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
}

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

@ -2182,7 +2182,8 @@ public class EsStatisticsController extends BaseController {
            @RequestParam(required = true) int level,
            @RequestParam(required = true) int sort,
            @RequestParam(required = false) String lowLevel,
            @RequestParam(required = false) String year) {
            @RequestParam(required = false) String year,
            @RequestParam(required = false,defaultValue = "3") int sortType) {//1发放量 ,2绑定量,绑定率
        try {
            //如果年度是空,按当前时间计算是年度是属于那个年度
@ -2194,7 +2195,7 @@ public class EsStatisticsController extends BaseController {
                lowLevel = level - 1 + "";
            }
            return write(200, "查询成功", "data", statisticsESService.getLevelDeviceAndBinding(area, elasticsearchUtil.changeLevel(level), sort, String.valueOf(elasticsearchUtil.changeLevel(Integer.valueOf(lowLevel))), year,deviceType));
            return write(200, "查询成功", "data", statisticsESService.getLevelDeviceAndBinding(area, elasticsearchUtil.changeLevel(level), sort, String.valueOf(elasticsearchUtil.changeLevel(Integer.valueOf(lowLevel))), year,deviceType,sortType));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");

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

@ -0,0 +1,48 @@
package com.yihu.wlyy.web.third.specialist;
import com.yihu.wlyy.service.specialist.SpecialistService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
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 Trick on 2018/7/13.
 */
@RestController
@RequestMapping(value = "/third/specialist",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "专科医生信息")
public class ThirdSpecialistController extends BaseController{
    @Autowired
    private SpecialistService specialistService;
    @RequestMapping(value = "/findSpecialistTeamInfo", method = RequestMethod.GET)
    @ApiOperation(value = "获取专科医生所在团队信息")
    public String findSpecialistTeamInfo(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor,
                                         @ApiParam(name = "teamCode", value = "团队code") @RequestParam(required = true)Long teamCode){
        try {
            return write(200, "获取成功", "data", specialistService.findSpecialistTeamInfo(doctor,teamCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/findTeamDiseaseRelation", method = RequestMethod.GET)
    @ApiOperation(value = "获取团队专病服务信息")
    public String findTeamDiseaseRelation(@ApiParam(name = "teamCode", value = "团队code") @RequestParam(required = true)Long teamCode) {
        try {
            return write(200, "获取成功", "data", specialistService.findTeamDiseaseRelation(teamCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
}