trick9191 7 лет назад
Родитель
Сommit
0c8a43f41a

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/team/sign/SignPatientLabel.java

@ -16,7 +16,7 @@ public class SignPatientLabel extends IdEntity {
    private String labelCode;
    // 标签名称
    private String labelName;
    // 标签类型 1:服务类型 2:健康情况 3:疾病类型 4:自定义
    // 标签类型 1:服务类型 2:健康情况 3:疾病类型 4:自定义,5.周月标签 6.老年人标识 7.专病类型,8.健康情况
    private String labelType;
    // 是否系统标签
    private Integer isSystem;

+ 174 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java

@ -0,0 +1,174 @@
package com.yihu.wlyy.service.specialist;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelInfoDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
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.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by Trick on 2018/5/31.
 */
@Service
public class SpecialistService extends BaseService {
    @Autowired
    private SignPatientLabelDao signPatientLabelDao;
    @Autowired
    private SignPatientLabelInfoDao signPatientLabelInfoDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Value("${specialist.url}")
    private String specialistUrl;
    public String setPatientLabelInfo(List<SignPatientLabelInfo> list){
        if(list!=null&&list.size()>0){
            for(SignPatientLabelInfo signPatientLabelInfo : list){
                signPatientLabelInfo.setCzrq(new Date());
                signPatientLabelInfo.setStatus(1);
            }
            signPatientLabelInfoDao.save(list);
        }
        return "1";
    }
    public List<Map<String,Object>> findHealthAssistant(){
        String sql="SELECT " +
                " d.`code`, " +
                " d.`name`, " +
                " d.photo " +
                " FROM " +
                " wlyy_doctor d " +
                " WHERE " +
                " d.`level` = '5' " +
                " AND `status` = 1";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    public List<SignPatientLabel> findLabelbyType(String type,Long teamCode){
        //自定义标签
        if("4".equals(type)){
            List<SignPatientLabel> list = signPatientLabelDao.findByLabelTypeAndStatusAndTeamCode(type,1,teamCode);
            return list;
        }else{
            //非自定义标签
            List<SignPatientLabel> list = signPatientLabelDao.findByLabelTypeAndStatus(type,1);
            return list;
        }
    }
    public Long findSpecialistPatientRelationCout(String doctor)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"findSpecialistPatientRelationCout",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
            return rs.getLong("obj");
        }
        return 0L;
    }
    public JSONArray findNoLabelPatientRelation(String doctor)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"findNoLabelPatientRelation",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
            return rs.getJSONArray("obj");
        }
        return null;
    }
    public JSONArray findPatientRelatioByAssistant(String assistant,Integer page,Integer size)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("assistant",assistant);
        param.put("page",page);
        param.put("size",size);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"findPatientRelatioByAssistant",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
            return rs.getJSONArray("obj");
        }
        return null;
    }
    public String saveHealthAssistant(String json)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("json",json);
        HttpResponse response = HttpUtils.doPost(specialistUrl+"saveHealthAssistant",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
            return rs.getString("obj");
        }
        return "";
    }
    public List<Map<String,Object>> getPatientByLabel(String labelType,String labelCode,Integer page,Integer size){
        String sql="SELECT " +
                " p. NAME, " +
                " p. CODE, " +
                " IFNULL( " +
                "  YEAR ( " +
                "   from_days(datediff(now(), p.birthday)) " +
                "  ), " +
                "  '未知' " +
                " ) age, " +
                " lb.labelName, " +
                " lb.labelType, " +
                " lb.label, " +
                " p.photo, " +
                " h.label_name as health, " +
                " h.label AS healthcode " +
                " FROM " +
                " ( " +
                "  SELECT " +
                "   i.label_type AS labelType, " +
                "   i.label, " +
                "   i.label_name AS labelName, " +
                "   i.patient " +
                "  FROM " +
                "   wlyy_sign_patient_label_info i " +
                "  WHERE " +
                "   i.label = '"+labelCode+"' " +
                "  AND i.label_type = '"+labelType+"' " +
                "  AND i.`status` = '1' " +
                " ) lb " +
                " JOIN wlyy_patient p ON p. CODE = lb.patient " +
                " LEFT JOIN ( " +
                " SELECT " +
                "  t.label, " +
                "  t.label_name, " +
                "  t.patient " +
                " FROM " +
                "  wlyy_sign_patient_label_info t " +
                " WHERE " +
                "  t.label_type = '8' " +
                " AND t.`status` = '1' " +
                " ) h ON h.patient = lb.patient " +
                " LIMIT LIMIT "+(page-1)*size+","+size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
}

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

@ -0,0 +1,129 @@
package com.yihu.wlyy.web.doctor.specialist;
import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
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.*;
import java.util.List;
/**
 * Created by Trick on 2018/5/31.
 */
@RestController
@RequestMapping(value = "/doctor/specialist", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-专病管理")
public class SpecialistController extends BaseController {
    @Autowired
    private SpecialistService specialistService;
    @RequestMapping(value = "setPatientLabelInfo",method = RequestMethod.POST)
    @ApiOperation("设置居民标签")
    public String setPatientLabelInfo(@ApiParam(name = "json", value = "居民标签实体") @RequestParam(required = true) String json){
        try {
            List<SignPatientLabelInfo> info = (List<SignPatientLabelInfo>) JSONArray.parseArray(json, SignPatientLabelInfo.class);
            return write(200,"获取成功","data",specialistService.setPatientLabelInfo(info));
        }catch (Exception e){
            error(e);
            return error(-1,"请求失败");
        }
    }
    @RequestMapping(value = "findHealthAssistant",method = RequestMethod.GET)
    @ApiOperation("获取所有计管师")
    public String findHealthAssistant(){
        try {
            return write(200,"获取成功","data",specialistService.findHealthAssistant());
        }catch (Exception e){
            error(e);
            return error(-1,"请求失败");
        }
    }
    @RequestMapping(value = "findLabelbyType",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取标签")
    public String findLabelbyType(@ApiParam(name = "type", value = "标签类型") @RequestParam(required = true)String type,
                                  @ApiParam(name = "teamCode", value = "团队id") @RequestParam(required = false)Long teamCode){
        try {
            return write(200,"获取成功","data",specialistService.findLabelbyType(type,teamCode));
        }catch (Exception e){
            error(e);
            return error(-1,"请求失败");
        }
    }
    @RequestMapping(value = "findSpecialistPatientRelationCout",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取专科医生下未分配标签居民数目")
    public String findSpecialistPatientRelationCout(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor){
        try {
            return write(200,"获取成功","data",specialistService.findSpecialistPatientRelationCout(doctor));
        }catch (Exception e){
            error(e);
            return error(-1,"请求失败");
        }
    }
    @RequestMapping(value = "findNoLabelPatientRelation",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取专科医生下未分配标签居民")
    public  String findNoLabelPatientRelation(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor){
        try {
            return write(200,"获取成功","data",specialistService.findNoLabelPatientRelation(doctor));
        }catch (Exception e){
            error(e);
            return error(-1,"请求失败");
        }
    }
    @RequestMapping(value = "findNoLabelPatientRelation",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取专科医生下未分配标签居民")
    public String findPatientRelatioByAssistant(@ApiParam(name = "assistant", value = "计管师") @RequestParam(required = true)String assistant,
                                                @ApiParam(name = "page", value = "第几页,1开始") @RequestParam(required = true)Integer page,
                                                @ApiParam(name = "size", value = "每页大小") @RequestParam(required = true)Integer size)throws Exception {
        try {
            return write(200,"获取成功","data",specialistService.findPatientRelatioByAssistant(assistant,page,size));
        }catch (Exception e){
            error(e);
            return error(-1,"请求失败");
        }
    }
    @RequestMapping(value = "saveHealthAssistant",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("分配计管师居民")
    public String saveHealthAssistant(String json){
        try {
            return write(200,"获取成功","data",specialistService.saveHealthAssistant(json));
        }catch (Exception e){
            error(e);
            return error(-1,"请求失败");
        }
    }
    @RequestMapping(value = "getPatientByLabel",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("获取标签下居民")
    public String getPatientByLabel(@ApiParam(name = "labelType", value = "标签类型")String labelType,
                                    @ApiParam(name = "labelCode", value = "标签code")String labelCode,
                                    @ApiParam(name = "page", value = "第几页,1开始")Integer page,
                                    @ApiParam(name = "size", value = "每页大小")Integer size) {
        try {
            return write(200,"获取成功","data",specialistService.getPatientByLabel(labelType,labelCode,page,size));
        }catch (Exception e){
            error(e);
            return error(-1,"请求失败");
        }
    }
}

+ 3 - 0
patient-co/patient-co-wlyy/src/main/resources/application-dev.yml

@ -33,6 +33,9 @@ im:
  im_list_get: http://172.19.103.88:3000/
  data_base_name: ichat
#专病配置
specialist:
  url: http://localhost:10051/svr-specialist/
#物联网配置
iot:
  url: http://192.168.131.24:8088/svr-iot/

+ 3 - 0
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -33,6 +33,9 @@ im:
  im_list_get: http://172.19.103.88:3000/
  data_base_name: im_new
#专病配置
specialist:
  url: http://localhost:10051/svr-wlyy-specialist/
#物联网配置
iot:
#  url: http://192.168.131.24:8088/svr-iot/

+ 4 - 0
patient-co/patient-co-wlyy/src/main/resources/application-local.yml

@ -29,6 +29,10 @@ im:
  im_list_get: http://10.95.22.138:3000/
  data_base_name: im
#专病配置
specialist:
  url: http://localhost:10051/svr-wlyy-specialist/
#物联网配置
iot:
  url: http://192.168.131.24:8088/svr-iot/

+ 3 - 0
patient-co/patient-co-wlyy/src/main/resources/application-localtest.yml

@ -29,6 +29,9 @@ im:
  im_list_get: http://172.19.103.88:3000/
  data_base_name: im_new
#专病配置
specialist:
  url: http://localhost:10051/svr-wlyy-specialist/
#物联网配置
iot:
  url: http://192.168.131.24:8088/svr-iot/

+ 3 - 0
patient-co/patient-co-wlyy/src/main/resources/application-prod.yml

@ -32,6 +32,9 @@ im:
  im_list_get: http://27.155.101.77:3000/
  data_base_name: im
#专病配置
specialist:
  url: http://localhost:10051/svr-wlyy-specialist/
#物联网配置
iot:
  url: http://192.168.131.24:8088/svr-iot/

+ 3 - 0
patient-co/patient-co-wlyy/src/main/resources/application-test.yml

@ -28,6 +28,9 @@ im:
  im_list_get: http://172.19.103.88:3000/
  data_base_name: im_new
#专病配置
specialist:
  url: http://localhost:10051/svr-wlyy-specialist/
#物联网配置
iot:
  url: http://172.19.103.33:8088/svr-iot/