Quellcode durchsuchen

Merge branch 'dev' of chenweida/patient-co-management into dev

chenweida vor 8 Jahren
Ursprung
Commit
899290ced4

+ 123 - 11
patient-co-figure/src/main/java/com/yihu/figure/controller/patient/PortraitController.java

@ -1,15 +1,19 @@
package com.yihu.figure.controller.patient;
import com.yihu.figure.controller.BaseController;
import com.yihu.figure.model.dict.SystemDict;
import com.yihu.figure.model.patient.portrait.UserPortrait;
import com.yihu.figure.service.PortraitService;
import com.yihu.figure.service.dict.SystemDictService;
import com.yihu.figure.util.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@ -31,6 +35,9 @@ public class PortraitController extends BaseController {
    @Autowired
    private PortraitService portraitService;
    @Autowired
    private SystemDictService systemDictService;
    @ApiOperation(value = " 生成用户标签")
    @RequestMapping(value = "newPortrait", method = RequestMethod.POST)
    public String newPortrait(
@ -57,47 +64,108 @@ public class PortraitController extends BaseController {
            return error(-1, e.getMessage());
        }
    }
    @ApiOperation(value = " 获取患者的全部标签的全部服务")
    @RequestMapping(value = "/findPortraitServices", method = RequestMethod.GET)
    public String findPortraitServices(
            @ApiParam(name = "userCode", value = "用户code", required = true) @RequestParam(value = "userCode", required = true) String userCode) {
        try {
            List<UserPortrait> ups= portraitService.findPortraits(userCode);
            JSONArray jsonArray=new JSONArray();
            ups.stream().forEach(userPortrait->{
                if(!StringUtils.isEmpty(userPortrait.getRecommendService())){
                    JSONArray second=new JSONArray(userPortrait.getRecommendService());
                    jsonArray.put(second);
                }
            });
            return write(200, "获取成功!", "data", jsonArray);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }
    @ApiOperation(value = "获取疾病-所在区域")
    @RequestMapping(value = "getPortraitsTown", method = RequestMethod.GET)
    public String getPortraits1002001(
            @ApiParam(name = "value", value = "疾病名称(糖尿病,高血压)", required = true) @RequestParam(value = "value", required = true) String value) {
        try {
            Map<String, Integer> data = portraitService.getPortraits("1001005", value);
            Map<String, String> returnData = new HashMap<>();
            JSONObject returnjo=new JSONObject();
            JSONObject return1 = new JSONObject();
            for (Map.Entry<String, Integer> one : data.entrySet()) {
                if (!one.getKey().equals("allSize")) {
                    returnData.put(one.getKey(), round(one.getValue(), data.get("allSize"), 2) + "");
                    return1.put(one.getKey(), round(one.getValue(), data.get("allSize"), 2) + "");
                }
            }
            return write(200, "获取成功!", "data", returnData);
            returnjo.put("data",return1);
            String name=getNameTownByKey(value);
            List<SystemDict> systemDicts = systemDictService.getDictByDictName(name);
            if(systemDicts!=null&&systemDicts.size()==1){
                returnjo.put("message",systemDicts.get(0).getValue());//文字
            }
            return write(200, "获取成功!", "data", returnjo);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    private String getNameTownByKey(String value) {
        switch (value){
            case "高血压":{
                return "TOWN_GXY";
            }
            case "糖尿病":{
                return "TOWN_TNB";
            }
        }
        return "";
    }
    @ApiOperation(value = "获取疾病-所在年龄")
    @RequestMapping(value = "getPortraitsAge", method = RequestMethod.GET)
    public String getPortraits1002003(
            @ApiParam(name = "value", value = "疾病名称(糖尿病,高血压)", required = true) @RequestParam(value = "value", required = true) String value) {
        try {
            Map<String, Integer> data = portraitService.getPortraits("1001003", value);
            Map<String, String> returnData = new HashMap<>();
            JSONObject returnjo=new JSONObject();
            JSONObject return1 = new JSONObject();
            for (Map.Entry<String, Integer> one : data.entrySet()) {
                if (!one.getKey().equals("allSize")) {
                    returnData.put(one.getKey(), round(one.getValue(), data.get("allSize"), 2) + "");
                    return1.put(one.getKey(), round(one.getValue(), data.get("allSize"), 2) + "");
                }
            }
            return write(200, "获取成功!", "data", returnData);
            returnjo.put("data",return1);
            String name=getNameAgeByKey(value);
            List<SystemDict> systemDicts = systemDictService.getDictByDictName(name);
            if(systemDicts!=null&&systemDicts.size()==1){
                returnjo.put("message",systemDicts.get(0).getValue());//文字
            }
            return write(200, "获取成功!", "data", returnjo);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    private String getNameAgeByKey(String value) {
        switch (value){
            case "高血压":{
                return "AGE_GXY";
            }
            case "糖尿病":{
                return "AGE_TNB";
            }
        }
        return "";
    }
    @ApiOperation(value = "获取疾病-所在性别")
    @RequestMapping(value = "getPortraitsSex", method = RequestMethod.GET)
    public String getPortraits1001001(
@ -105,26 +173,48 @@ public class PortraitController extends BaseController {
        try {
            Map<String, Integer> data = portraitService.getPortraits("1001001", value);
            Map<String, String> returnData = new HashMap<>();
            JSONObject returnjo=new JSONObject();
            JSONObject return1 = new JSONObject();
            for (Map.Entry<String, Integer> one : data.entrySet()) {
                if (!one.getKey().equals("allSize")) {
                    returnData.put(one.getKey(), round(one.getValue(), data.get("allSize"), 2) + "");
                    return1.put(one.getKey(), round(one.getValue(), data.get("allSize"), 2) + "");
                }
            }
            return write(200, "获取成功!", "data", returnData);
            returnjo.put("data",return1);
            String name=getNameSexByKey(value);
            List<SystemDict> systemDicts = systemDictService.getDictByDictName(name);
            if(systemDicts!=null&&systemDicts.size()==1){
                returnjo.put("message",systemDicts.get(0).getValue());//文字
            }
            return write(200, "获取成功!", "data", returnjo);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    private String getNameSexByKey(String value) {
        switch (value){
            case "高血压":{
                return "SEX_GXY";
            }
            case "糖尿病":{
                return "SEX_TNB";
            }
        }
        return "";
    }
    @ApiOperation(value = "获取一级的标签信息")
    @RequestMapping(value = "getPortraitsLevel1", method = RequestMethod.GET)
    public String getPortraitsLevel1(
            @ApiParam(name = "key", value = "1 疾病 2 健康分布", required = true) @RequestParam(value = "key", required = true) String key) {
        try {
            Map<String, Integer> data = portraitService.getPortraitsLevel1(key);
            JSONObject returnjo=new JSONObject();
            JSONObject return1 = new JSONObject();
            for (Map.Entry<String, Integer> one : data.entrySet()) {
@ -135,13 +225,35 @@ public class PortraitController extends BaseController {
                    return1.put(one.getKey(), return2);
                }
            }
            return write(200, "获取成功!", "data", return1);
            returnjo.put("data",return1);//数据
            String name=getNameByKey(key);
            List<SystemDict> systemDicts = systemDictService.getDictByDictName(name);
            if(systemDicts!=null&&systemDicts.size()==1){
                returnjo.put("message",systemDicts.get(0).getValue());//文字
            }
            return write(200, "获取成功!", "data", returnjo);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    private String getNameByKey(String key) {
        switch (key){
            case "1":{
                return "DISEASE_MESSAGE";
            }
            case "2":{
                return "HEALTH_MESSAGE";
            }
        }
        return "";
    }
    /**
     * 计算百分比的函数
     * @param up  分子

+ 4 - 0
patient-co-figure/src/main/java/com/yihu/figure/service/PortraitService.java

@ -152,6 +152,9 @@ public class PortraitService {
        return data;
    }
    public List<UserPortrait> findPortraits(String userCode) {
        return userPortraitDao.findByPatientCode(userCode);
    }
    /**
     * @param key 1 疾病 2 健康分布
     * @return
@ -190,4 +193,5 @@ public class PortraitService {
        return userPortraitDao.findOne(id);
    }
}

BIN
patient-co-figure/文档/接口文档.docx