فهرست منبع

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

8 سال پیش
والد
کامیت
ea68cbc237
55فایلهای تغییر یافته به همراه1723 افزوده شده و 1126 حذف شده
  1. 3 3
      patient-co-figure/src/main/java/com/yihu/figure/config/SwaggerConfig.java
  2. 4 0
      patient-co-figure/src/main/java/com/yihu/figure/config/war/ServletInitializer.java
  3. 0 20
      patient-co-figure/src/main/java/com/yihu/figure/controller/DietController.java
  4. 102 1
      patient-co-figure/src/main/java/com/yihu/figure/controller/DiseaseController.java
  5. 0 20
      patient-co-figure/src/main/java/com/yihu/figure/controller/MedicinalController.java
  6. 0 20
      patient-co-figure/src/main/java/com/yihu/figure/controller/SportsController.java
  7. 40 0
      patient-co-figure/src/main/java/com/yihu/figure/controller/SuggestController.java
  8. 4 3
      patient-co-figure/src/main/java/com/yihu/figure/web/HealthIndexController.java
  9. 88 0
      patient-co-figure/src/main/java/com/yihu/figure/controller/patient/PatientController.java
  10. 161 0
      patient-co-figure/src/main/java/com/yihu/figure/controller/patient/PortraitController.java
  11. 0 23
      patient-co-figure/src/main/java/com/yihu/figure/dao/PatientDao.java
  12. 0 10
      patient-co-figure/src/main/java/com/yihu/figure/dao/PatientInfoDao.java
  13. 17 0
      patient-co-figure/src/main/java/com/yihu/figure/dao/SuggestDao.java
  14. 16 0
      patient-co-figure/src/main/java/com/yihu/figure/dao/disease/InspectionDao.java
  15. 16 0
      patient-co-figure/src/main/java/com/yihu/figure/dao/disease/VisitDao.java
  16. 2 2
      patient-co-figure/src/main/java/com/yihu/figure/dao/HealthIndexDao.java
  17. 2 2
      patient-co-figure/src/main/java/com/yihu/figure/dao/HealthIndexStatisticsDao.java
  18. 21 0
      patient-co-figure/src/main/java/com/yihu/figure/dao/patient/PatientInfoDao.java
  19. 19 0
      patient-co-figure/src/main/java/com/yihu/figure/dao/patient/portrait/UserPortraitDao.java
  20. 0 343
      patient-co-figure/src/main/java/com/yihu/figure/model/Patient.java
  21. 169 0
      patient-co-figure/src/main/java/com/yihu/figure/model/disease/Inspection.java
  22. 127 0
      patient-co-figure/src/main/java/com/yihu/figure/model/disease/Visit.java
  23. 2 1
      patient-co-figure/src/main/java/com/yihu/figure/model/HealthIndex.java
  24. 2 1
      patient-co-figure/src/main/java/com/yihu/figure/model/HealthIndexStatistics.java
  25. 102 2
      patient-co-figure/src/main/java/com/yihu/figure/model/PatientInfo.java
  26. 79 0
      patient-co-figure/src/main/java/com/yihu/figure/model/patient/portrait/UserPortrait.java
  27. 51 0
      patient-co-figure/src/main/java/com/yihu/figure/model/suggest/Suggest.java
  28. 0 10
      patient-co-figure/src/main/java/com/yihu/figure/service/DietService.java
  29. 167 0
      patient-co-figure/src/main/java/com/yihu/figure/service/DiseaseService.java
  30. 0 10
      patient-co-figure/src/main/java/com/yihu/figure/service/MedicinalService.java
  31. 43 2
      patient-co-figure/src/main/java/com/yihu/figure/service/PatientInfoService.java
  32. 192 0
      patient-co-figure/src/main/java/com/yihu/figure/service/PortraitService.java
  33. 0 10
      patient-co-figure/src/main/java/com/yihu/figure/service/SportsService.java
  34. 45 0
      patient-co-figure/src/main/java/com/yihu/figure/service/SuggestService.java
  35. 6 5
      patient-co-figure/src/main/java/com/yihu/figure/service/HealthIndexService.java
  36. 2 1
      patient-co-figure/src/main/java/com/yihu/figure/service/HealthIndexStatisticsService.java
  37. 0 511
      patient-co-figure/src/main/java/com/yihu/figure/web/BaseController.java
  38. 1 1
      patient-co-figure/src/main/resources/application.yml
  39. BIN
      patient-co-figure/文档/tomcat部署.docx
  40. BIN
      patient-co-figure/文档/接口文档.docx
  41. 8 6
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientReservation.java
  42. 37 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  43. 45 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/job/SignEndJob.java
  44. 2 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientReservationDao.java
  45. 52 51
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java
  46. 14 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/HealthEduArticleService.java
  47. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reservation/PatientReservationService.java
  48. 0 10
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/util/ManageUtilService.java
  49. 16 8
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java
  50. 2 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  51. 42 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/Html2Text.java
  52. 15 36
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java
  53. 2 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java
  54. 1 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java
  55. 3 0
      patient-co-wlyy/src/main/resources/system.properties

+ 3 - 3
patient-co-figure/src/main/java/com/yihu/figure/config/SwaggerConfig.java

@ -40,10 +40,10 @@ public class SwaggerConfig extends WebMvcConfigurerAdapter {
                .pathMapping("/")
                .select()
                .paths(or(
                        regex("/medicinal/.*"),
                        regex("/diet/.*"),
                        regex("/suggest/.*"),
                        regex("/portrait/.*"),
                        regex("/patient/.*"),
                        regex("/disease/.*"),
                        regex("/data/.*"),
                        regex("/health/.*")
                ))
                .build()

+ 4 - 0
patient-co-figure/src/main/java/com/yihu/figure/config/war/ServletInitializer.java

@ -1,5 +1,9 @@
package com.yihu.figure.config.war;
import com.yihu.figure.Application;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
/**
 * Created by Administrator on 2016.10.14.
 */

+ 0 - 20
patient-co-figure/src/main/java/com/yihu/figure/controller/DietController.java

@ -1,20 +0,0 @@
package com.yihu.figure.controller;
import com.yihu.figure.service.DietService;
import io.swagger.annotations.Api;
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.RestController;
/**
 * Created by chenweida on 2017/3/6.
 * 饮食
 */
@RestController
@RequestMapping(value = "/diet", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "饮食")
public class DietController {
    @Autowired
    private DietService dietService;
}

+ 102 - 1
patient-co-figure/src/main/java/com/yihu/figure/controller/DiseaseController.java

@ -1,12 +1,23 @@
package com.yihu.figure.controller;
import com.yihu.figure.model.disease.Inspection;
import com.yihu.figure.model.disease.Visit;
import com.yihu.figure.service.DiseaseService;
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.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;
import java.util.List;
/**
 * Created by chenweida on 2017/3/6.
 * 近期疾病
@ -14,7 +25,97 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/disease", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "近期疾病")
public class DiseaseController {
public class DiseaseController extends BaseController {
    @Autowired
    private DiseaseService diseaseService;
    /**
     * 根据健康卡号抓取数据某个病人的全部就诊事件列表接口
     * /smjk/GetResidentEventListJson
     *
     * @param strSSID 健康卡号
     * @return
     */
    @ApiOperation(value = "根据健康卡号生成数据某个病人的全部就诊事件")
    @RequestMapping(value = "GetResidentEventListJson", method = RequestMethod.GET)
    public String getResidentEventListJson(
            @ApiParam(name = "strSSID", value = "健康卡号", required = true) @RequestParam(value = "strSSID", required = true) String strSSID,
            @ApiParam(name = "patientCode", value = "患者code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode) {
        try {
            diseaseService.getResidentEventListJson(strSSID,patientCode);
            return success("成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }
    /**
     * 根据健康卡号抓取数据某个病人的全部检查检验事件
     * /smjk/GetResidentEventListJson
     *
     * @param strSSID 健康卡号
     * @return
     */
    @ApiOperation(value = "根据健康卡号抓取数据某个病人的全部检查检验事件")
    @RequestMapping(value = "GetRecordListByCatalogcodesJson", method = RequestMethod.GET)
    public String GetRecordListByCatalogcodesJson(
            @ApiParam(name = "strSSID", value = "健康卡号", required = true) @RequestParam(value = "strSSID", required = true) String strSSID,
            @ApiParam(name = "patientCode", value = "患者code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode) {
        try {
            diseaseService.GetRecordListByCatalogcodesJson(strSSID,patientCode);
            return success("成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }
    @ApiOperation(value = "根据code查询患者的就诊事件")
    @RequestMapping(value = "getVisits", method = RequestMethod.GET)
    public String getVisits(
            @ApiParam(name = "patientCode", value = "患者code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode,
            @ApiParam(name = "icdName", value = "主诊断(高血压或者糖尿病)", required = false) @RequestParam(value = "icdName", required = false) String icdName,
            @ApiParam(name = "time", value = "时间", required = false) @RequestParam(value = "time", required = false) String time) {
        try {
            List<Visit> visitList = diseaseService.getVisits(patientCode,time,icdName);
            JSONArray ja=new JSONArray();
            visitList.stream().forEach( v->{
                JSONObject jo=new JSONObject();
                jo.put("orgName",v.getOrgName());
                jo.put("typeName",v.getTypeName());//住院或者门诊
                jo.put("time", DateUtil.dateToStr(v.getEndTime(),"yyyy-MM-dd"));
                ja.put(jo);
            });
            return write(200, "获取列表成功!", "list", ja);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }
    @ApiOperation(value = "根据code查询患者的检查检验")
    @RequestMapping(value = "getInspections", method = RequestMethod.GET)
    public String getInspections(
            @ApiParam(name = "patientCode", value = "患者code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode,
            @ApiParam(name = "type", value = "类型(1高血压 2糖尿病)", required = false) @RequestParam(value = "type", required = false) String type,
            @ApiParam(name = "time", value = "时间", required = false) @RequestParam(value = "time", required = false) String time) {
        try {
            List<Inspection> inspections = diseaseService.getInspections(patientCode,time,type);
            JSONArray ja=new JSONArray();
            inspections.stream().forEach( v->{
                JSONObject jo=new JSONObject();
                jo.put("orgName",v.getOrgName());
                jo.put("cataLogCodeName",v.getCataLogCodeName());//检查或者检验
                jo.put("time", DateUtil.dateToStr(v.getEndTime(),"yyyy-MM-dd"));
                ja.put(jo);
            });
            return write(200, "获取列表成功!", "list", ja);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }
}

+ 0 - 20
patient-co-figure/src/main/java/com/yihu/figure/controller/MedicinalController.java

@ -1,20 +0,0 @@
package com.yihu.figure.controller;
import com.yihu.figure.service.MedicinalService;
import io.swagger.annotations.Api;
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.RestController;
/**
 * Created by chenweida on 2017/3/6.
 * 用药建议
 */
@RestController
@RequestMapping(value = "/medicinal", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "用药建议")
public class MedicinalController {
    @Autowired
    private MedicinalService medicinalService;
}

+ 0 - 20
patient-co-figure/src/main/java/com/yihu/figure/controller/SportsController.java

@ -1,20 +0,0 @@
package com.yihu.figure.controller;
import com.yihu.figure.service.SportsService;
import io.swagger.annotations.Api;
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.RestController;
/**
 * Created by chenweida on 2017/3/6.
 * 运动
 */
@RestController
@RequestMapping(value = "/sports", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "运动")
public class SportsController {
    @Autowired
    private SportsService sportsService;
}

+ 40 - 0
patient-co-figure/src/main/java/com/yihu/figure/controller/SuggestController.java

@ -0,0 +1,40 @@
package com.yihu.figure.controller;
import com.yihu.figure.model.suggest.Suggest;
import com.yihu.figure.service.SuggestService;
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;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/3/7.
 */
@RestController
@RequestMapping(value = "/suggest", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "建议")
public class SuggestController extends BaseController {
    @Autowired
    private SuggestService suggestService;
    @ApiOperation(value = "获取患者建议")
    @RequestMapping(value = "getPatientSuggest", method = RequestMethod.GET)
    public String getPatientInfo(
            @ApiParam(name = "patientCode", value = "患者code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode) {
        try {
            Map<String, List<Suggest>> patientInfo = suggestService.getPatientSuggest(patientCode);
            return write(200, "获取成功!", "suggest", patientInfo);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }
}

+ 4 - 3
patient-co-figure/src/main/java/com/yihu/figure/web/HealthIndexController.java

@ -1,6 +1,7 @@
package com.yihu.figure.web;
package com.yihu.figure.controller.health;
import com.yihu.figure.service.HealthIndexService;
import com.yihu.figure.controller.BaseController;
import com.yihu.figure.service.health.HealthIndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -18,7 +19,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping(value = "/health/")
@Api(description = "自动生成体征数据接口")
public class HealthIndexController extends BaseController{
public class HealthIndexController extends BaseController {
    @Autowired
    private HealthIndexService healthIndexService;

+ 88 - 0
patient-co-figure/src/main/java/com/yihu/figure/controller/patient/PatientController.java

@ -0,0 +1,88 @@
package com.yihu.figure.controller.patient;
import com.yihu.figure.controller.BaseController;
import com.yihu.figure.model.patient.PatientInfo;
import com.yihu.figure.service.PatientInfoService;
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.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;
import java.util.List;
/**
 * Created by chenweida on 2017/3/7.
 */
@RestController
@RequestMapping(value = "/patient", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "患者信息")
public class PatientController extends BaseController {
    @Autowired
    private PatientInfoService patientInfoService;
    @ApiOperation(value = "获取患者信息")
    @RequestMapping(value = "getPatientInfo", method = RequestMethod.GET)
    public String getPatientInfo(
            @ApiParam(name = "patientCode", value = "患者code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode) {
        try {
            PatientInfo patientInfo = patientInfoService.getPatientInfo(patientCode);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("name", patientInfo.getName());
            jsonObject.put("code", patientInfo.getCode());
            jsonObject.put("sex", patientInfo.getSex());
            jsonObject.put("xbs", patientInfo.getXbs());
            jsonObject.put("jws", patientInfo.getJws());
            jsonObject.put("grs", patientInfo.getGrs());
            jsonObject.put("jzs", patientInfo.getJzs());
            jsonObject.put("hys", patientInfo.getHys());
            jsonObject.put("age", DateUtil.getAgeByBirthday(patientInfo.getBirthday()));
            jsonObject.put("userPortraits", patientInfo.getUserPortraits());
            jsonObject.put("suggests", patientInfo.getSuggests());
            return write(200, "获取成功!", "patient", jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }
    @ApiOperation(value = "获取示例患者信息列表")
    @RequestMapping(value = "getPatientList", method = RequestMethod.GET)
    public String getPatientInfo() {
        try {
            JSONArray ja=new JSONArray();
            List<PatientInfo> patientInfos = patientInfoService.getPatientList();
            patientInfos.stream().forEach( patientInfo->{
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("name", patientInfo.getName());
                jsonObject.put("code", patientInfo.getCode());
                //jsonObject.put("sex", patientInfo.getSex());
                //jsonObject.put("xbs", patientInfo.getXbs());
                //jsonObject.put("jws", patientInfo.getJws());
               // jsonObject.put("grs", patientInfo.getGrs());
               // jsonObject.put("jzs", patientInfo.getJzs());
               // jsonObject.put("hys", patientInfo.getHys());
              //  jsonObject.put("age", DateUtil.getAgeByBirthday(patientInfo.getBirthday()));
              //  jsonObject.put("userPortraits", patientInfo.getUserPortraits());
              //  jsonObject.put("suggests", patientInfo.getSuggests());
                ja.put(jsonObject);
            });
            return write(200, "获取成功!", "patient", ja);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }
}

+ 161 - 0
patient-co-figure/src/main/java/com/yihu/figure/controller/patient/PortraitController.java

@ -0,0 +1,161 @@
package com.yihu.figure.controller.patient;
import com.yihu.figure.controller.BaseController;
import com.yihu.figure.model.patient.portrait.UserPortrait;
import com.yihu.figure.service.PortraitService;
import com.yihu.figure.util.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
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;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/3/8.
 * 用户标签
 */
@RestController
@RequestMapping(value = "/portrait", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "用户标签")
public class PortraitController extends BaseController {
    @Autowired
    private PortraitService portraitService;
    @ApiOperation(value = " 生成用户标签")
    @RequestMapping(value = "newPortrait", method = RequestMethod.POST)
    public String newPortrait(
            @ApiParam(name = "category", value = "标签父类", required = true) @RequestParam(value = "category", required = true) String category,
            @ApiParam(name = "subCategory", value = "标签子类", required = true) @RequestParam(value = "subCategory", required = true) String subCategory,
            @ApiParam(name = "value", value = "标签值", required = false) @RequestParam(value = "value", required = false) String value) {
        try {
            portraitService.newPortrait(category, subCategory);
            return success("成功");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    @ApiOperation(value = " 根据标签ID查找标签信息")
    @RequestMapping(value = "/findPortraitById", method = RequestMethod.GET)
    public String findPortraitById(
            @ApiParam(name = "id", value = "标签id", required = true) @RequestParam(value = "id", required = true) Long id) {
        try {
            UserPortrait up= portraitService.findPortraitById(id);
            return write(200, "获取成功!", "data", up);
        } 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<>();
            for (Map.Entry<String, Integer> one : data.entrySet()) {
                if (!one.getKey().equals("allSize")) {
                    returnData.put(one.getKey(), round(one.getValue(), data.get("allSize"), 2) + "");
                }
            }
            return write(200, "获取成功!", "data", returnData);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    @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<>();
            for (Map.Entry<String, Integer> one : data.entrySet()) {
                if (!one.getKey().equals("allSize")) {
                    returnData.put(one.getKey(), round(one.getValue(), data.get("allSize"), 2) + "");
                }
            }
            return write(200, "获取成功!", "data", returnData);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    @ApiOperation(value = "获取疾病-所在性别")
    @RequestMapping(value = "getPortraitsSex", method = RequestMethod.GET)
    public String getPortraits1001001(
            @ApiParam(name = "value", value = "疾病名称(糖尿病,高血压)", required = true) @RequestParam(value = "value", required = true) String value) {
        try {
            Map<String, Integer> data = portraitService.getPortraits("1001001", value);
            Map<String, String> returnData = new HashMap<>();
            for (Map.Entry<String, Integer> one : data.entrySet()) {
                if (!one.getKey().equals("allSize")) {
                    returnData.put(one.getKey(), round(one.getValue(), data.get("allSize"), 2) + "");
                }
            }
            return write(200, "获取成功!", "data", returnData);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    @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 return1 = new JSONObject();
            for (Map.Entry<String, Integer> one : data.entrySet()) {
                if (!one.getKey().equals("allSize")) {
                    JSONObject return2 = new JSONObject();
                    return2.put("count", one.getValue());
                    return2.put("scale ", round(one.getValue(), data.get("allSize"), 2) + "");
                    return1.put(one.getKey(), return2);
                }
            }
            return write(200, "获取成功!", "data", return1);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    public static double round(Integer up, Integer down, int scale) {
        try {
            if (scale < 0) {
                throw new IllegalArgumentException(
                        "The scale must be a positive integer or zero");
            }
            BigDecimal upB = new BigDecimal(up);
            BigDecimal downB = new BigDecimal(down);
            return upB.divide(downB, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
        } catch (Exception e) {
            return 0;
        }
    }
}

+ 0 - 23
patient-co-figure/src/main/java/com/yihu/figure/dao/PatientDao.java

@ -1,23 +0,0 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.figure.dao;
import com.yihu.figure.model.Patient;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
    // 查询患者姓名
    @Query("select p.name from Patient p where p.code=?1 and p.status=1")
    String findNameByCode(String code);
}

+ 0 - 10
patient-co-figure/src/main/java/com/yihu/figure/dao/PatientInfoDao.java

@ -1,10 +0,0 @@
package com.yihu.figure.dao;
import com.yihu.figure.model.PatientInfo;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2017/3/6.
 */
public interface PatientInfoDao extends PagingAndSortingRepository<PatientInfo, Long> {
}

+ 17 - 0
patient-co-figure/src/main/java/com/yihu/figure/dao/SuggestDao.java

@ -0,0 +1,17 @@
package com.yihu.figure.dao;
import com.yihu.figure.model.disease.Inspection;
import com.yihu.figure.model.suggest.Suggest;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by chenweida on 2017/3/7.
 */
public interface SuggestDao  extends PagingAndSortingRepository<Suggest, Long>, JpaSpecificationExecutor<Suggest> {
   @Query("from Suggest s where s.keyword like ?1")
    List<Suggest> findByKeyword(String keyword);
}

+ 16 - 0
patient-co-figure/src/main/java/com/yihu/figure/dao/disease/InspectionDao.java

@ -0,0 +1,16 @@
package com.yihu.figure.dao.disease;
import com.yihu.figure.model.disease.Inspection;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by chenweida on 2017/3/6.
 */
public interface InspectionDao extends PagingAndSortingRepository<Inspection, Long>, JpaSpecificationExecutor<Inspection> {
    @Query(" from Inspection i where i.patientCode=?1 ")
    List<Inspection> findByPatientCode(String patientCode);
}

+ 16 - 0
patient-co-figure/src/main/java/com/yihu/figure/dao/disease/VisitDao.java

@ -0,0 +1,16 @@
package com.yihu.figure.dao.disease;
import com.yihu.figure.model.disease.Visit;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by chenweida on 2017/3/6.
 */
public interface VisitDao extends PagingAndSortingRepository<Visit, Long>, JpaSpecificationExecutor<Visit> {
    @Query(" from Visit v where v.patientCode=?1 ")
    List<Visit> findByPatientCode(String patientCode);
}

+ 2 - 2
patient-co-figure/src/main/java/com/yihu/figure/dao/HealthIndexDao.java

@ -3,9 +3,9 @@
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.figure.dao;
package com.yihu.figure.dao.health;
import com.yihu.figure.model.HealthIndex;
import com.yihu.figure.model.health.HealthIndex;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

+ 2 - 2
patient-co-figure/src/main/java/com/yihu/figure/dao/HealthIndexStatisticsDao.java

@ -1,6 +1,6 @@
package com.yihu.figure.dao;
package com.yihu.figure.dao.health;
import com.yihu.figure.model.HealthIndexStatistics;
import com.yihu.figure.model.health.HealthIndexStatistics;
import org.springframework.data.repository.PagingAndSortingRepository;
/**

+ 21 - 0
patient-co-figure/src/main/java/com/yihu/figure/dao/patient/PatientInfoDao.java

@ -0,0 +1,21 @@
package com.yihu.figure.dao.patient;
import com.yihu.figure.model.patient.PatientInfo;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by yeshijie on 2017/3/6.
 */
public interface PatientInfoDao extends PagingAndSortingRepository<PatientInfo, Long> {
    @Query("from PatientInfo p where p.code=?1 ")
    PatientInfo findByCode(String patientCode);
    @Query("from PatientInfo p ")
    List<PatientInfo> findAllPatient();
    @Query("from PatientInfo p where (p.code='test1' or p.code='test2'or p.code='test3') ")
    List<PatientInfo> findByHasCode();
}

+ 19 - 0
patient-co-figure/src/main/java/com/yihu/figure/dao/patient/portrait/UserPortraitDao.java

@ -0,0 +1,19 @@
package com.yihu.figure.dao.patient.portrait;
import com.yihu.figure.model.patient.portrait.UserPortrait;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by chenweida on 2017/3/7.
 */
public interface UserPortraitDao extends PagingAndSortingRepository<UserPortrait, Long>, JpaSpecificationExecutor<UserPortrait> {
   @Query(" from UserPortrait u where u.userCode=?1  ")
    List<UserPortrait> findByPatientCode(String patientCode);
    @Query(" from UserPortrait u where u.subCategory=?1  ")
    List<UserPortrait> findBySubCategory(String key);
}

+ 0 - 343
patient-co-figure/src/main/java/com/yihu/figure/model/Patient.java

@ -1,343 +0,0 @@
package com.yihu.figure.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * 患者信息
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_patient")
public class Patient extends IdEntity implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 8358924836164389434L;
	// 业务主键
	private String code;
	// 身份证号
	private String idcard;
	// 登录密码
	private String password;
	private String salt;
	// 姓名
	private String name;
	// 生日
	private Date birthday;
	// 性別,1男,2女
	private Integer sex;
	// 手機號
	private String mobile;
	// (基卫)手機號
	private String mobileRemarks;
	// 聯繫電話
	private String phone;
	// 社保卡號
	private String ssc;
	// 頭像HTTP地址
	private String photo;
	// 省代碼
	private String province;
	// 城市代碼
	private String city;
	// 區縣代碼
	private String town;
	// 街道代码
	private String street;
	// 省名
	private String provinceName;
	// 市名
	private String cityName;
	// 區縣名
	private String townName;
	// 街道名称
	private String streetName;
	// 地址
	private String address;
	// 疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病
	private Integer disease;
	// 病情:0绿标,1黄标,2红标
	private Integer diseaseCondition;
	// 病历记录总数
	private Integer recordAmount;
	// 總積分
	private Integer points;
	// 更新時間
	private Date czrq;
	// 微信编号
	private String openid;
	//微信时间
	private Date openidTime;
	// 用户状态:1正常,0禁用,-1恶意注册,2审核中
	private Integer status;
	public Patient() {
	}
	public Patient(Long id) {
		this.id = id;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getIdcard() {
		return idcard;
	}
	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getSalt() {
		return salt;
	}
	public void setSalt(String salt) {
		this.salt = salt;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	public Date getBirthday() {
		return birthday;
	}
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}
	public Integer getSex() {
		return sex;
	}
	public void setSex(Integer sex) {
		this.sex = sex;
	}
	public String getMobile() {
		return mobile;
	}
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getSsc() {
		return ssc;
	}
	public void setSsc(String ssc) {
		this.ssc = ssc;
	}
	@Column(name = "photo", insertable = false)
	public String getPhoto() {
		return photo;
	}
	public void setPhoto(String photo) {
		this.photo = photo;
	}
	public String getProvince() {
		return province;
	}
	public void setProvince(String province) {
		this.province = province;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getTown() {
		return town;
	}
	public void setTown(String town) {
		this.town = town;
	}
	public String getStreet() {
		return street;
	}
	public void setStreet(String street) {
		this.street = street;
	}
	@Column(name = "province_name")
	public String getProvinceName() {
		return provinceName;
	}
	public void setProvinceName(String provinceName) {
		this.provinceName = provinceName;
	}
	@Column(name = "city_name")
	public String getCityName() {
		return cityName;
	}
	public void setCityName(String cityName) {
		this.cityName = cityName;
	}
	@Column(name = "town_name")
	public String getTownName() {
		return townName;
	}
	public void setTownName(String townName) {
		this.townName = townName;
	}
	@Column(name = "street_name")
	public String getStreetName() {
		return streetName;
	}
	public void setStreetName(String streetName) {
		this.streetName = streetName;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public Integer getDisease() {
		return disease;
	}
	public void setDisease(Integer disease) {
		this.disease = disease;
	}
	@Column(name = "disease_condition")
	public Integer getDiseaseCondition() {
		return diseaseCondition;
	}
	public void setDiseaseCondition(Integer diseaseCondition) {
		this.diseaseCondition = diseaseCondition;
	}
	@Column(name = "record_amount")
	public Integer getRecordAmount() {
		return recordAmount;
	}
	public void setRecordAmount(Integer recordAmount) {
		this.recordAmount = recordAmount;
	}
	public Integer getPoints() {
		return points;
	}
	public void setPoints(Integer points) {
		this.points = points;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	public String getOpenid() {
		return openid;
	}
	public void setOpenid(String openid) {
		this.openid = openid;
	}
	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	public String getMobileRemarks() {
		return mobileRemarks;
	}
	public void setMobileRemarks(String mobileRemarks) {
		this.mobileRemarks = mobileRemarks;
	}
	public Date getOpenidTime() {
		return openidTime;
	}
	public void setOpenidTime(Date openidTime) {
		this.openidTime = openidTime;
	}
}

+ 169 - 0
patient-co-figure/src/main/java/com/yihu/figure/model/disease/Inspection.java

@ -0,0 +1,169 @@
package com.yihu.figure.model.disease;
import com.yihu.figure.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/**
 * Created by chenweida on 2017/3/6.
 * 检查检验表
 */
@Entity
@Table(name = "figure_inspection")
public class Inspection extends IdEntity {
    private String serial;//'文档序号'
    private String item;//''检查项目名称''
    private Integer orgId;//'机构ID'
    private String catalogCode;//''档案类型''
    private Integer r;//''排序号''
    private Date endTime;//''事件时间''
    private String orgName;//''机构名称''
    private String unionssid;//'文档序号'
    private Date ehrCommitTime;//''提交时间''
    private String type;//''事件类型1门诊2住院3体检''
    private String event;//''事件号''
    private String xmanId;//
    private String patientCode;//患者code
    private String cataLogCodeName;//类别名称
    public Inspection() {
    }
    public Inspection(String patientCode) {
        this.patientCode = patientCode;
    }
    @Transient
    public String getCataLogCodeName() {
        switch (this.catalogCode) {
            case "0131": {
                //门诊检查报告单
                return "检查";
            }
            case "0121": {
                //门诊检验报告单
                return "检验";
            }
            case "0221": {
                //住院检验报告
                return "检验";
            }
            case "0231": {
                //住院检查报告
                return "检查";
            }
        }
        return "未知";
    }
    public void setCataLogCodeName(String cataLogCodeName) {
        this.cataLogCodeName = cataLogCodeName;
    }
    public String getPatientCode() {
        return patientCode;
    }
    public void setPatientCode(String patientCode) {
        this.patientCode = patientCode;
    }
    public String getSerial() {
        return serial;
    }
    public void setSerial(String serial) {
        this.serial = serial;
    }
    public String getItem() {
        return item;
    }
    public void setItem(String item) {
        this.item = item;
    }
    public Integer getOrgId() {
        return orgId;
    }
    public void setOrgId(Integer orgId) {
        this.orgId = orgId;
    }
    public String getCatalogCode() {
        return catalogCode;
    }
    public void setCatalogCode(String catalogCode) {
        this.catalogCode = catalogCode;
    }
    public Integer getR() {
        return r;
    }
    public void setR(Integer r) {
        this.r = r;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    public String getUnionssid() {
        return unionssid;
    }
    public void setUnionssid(String unionssid) {
        this.unionssid = unionssid;
    }
    public Date getEhrCommitTime() {
        return ehrCommitTime;
    }
    public void setEhrCommitTime(Date ehrCommitTime) {
        this.ehrCommitTime = ehrCommitTime;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getEvent() {
        return event;
    }
    public void setEvent(String event) {
        this.event = event;
    }
    public String getXmanId() {
        return xmanId;
    }
    public void setXmanId(String xmanId) {
        this.xmanId = xmanId;
    }
}

+ 127 - 0
patient-co-figure/src/main/java/com/yihu/figure/model/disease/Visit.java

@ -0,0 +1,127 @@
package com.yihu.figure.model.disease;
import com.yihu.figure.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/**
 * Created by chenweida on 2017/3/6.
 * 就诊事件表
 */
@Entity
@Table(name = "figure_visit")
public class Visit extends IdEntity {
    private String diagnosis;//'主诊断名称'
    private Integer orgId;//'机构id'
    private String r;//''排序号''
    private Date endTime;//''事件时间''
    private String orgName;//'机构名称'
    private String type;//'事件类型1门诊2住院3体检',
    private String event;//''事件号''
    private String icdCode;// 主诊断编码
    private String patientCode;//患者code
    private String typeName;//类别名称
    public Visit(String patientCode) {
        this.patientCode = patientCode;
    }
    public Visit() {
    }
    public String getIcdCode() {
        return icdCode;
    }
    public void setIcdCode(String icdCode) {
        this.icdCode = icdCode;
    }
    public String getDiagnosis() {
        return diagnosis;
    }
    public void setDiagnosis(String diagnosis) {
        this.diagnosis = diagnosis;
    }
    public Integer getOrgId() {
        return orgId;
    }
    public void setOrgId(Integer orgId) {
        this.orgId = orgId;
    }
    public String getR() {
        return r;
    }
    public void setR(String r) {
        this.r = r;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getEvent() {
        return event;
    }
    public void setEvent(String event) {
        this.event = event;
    }
    public String getPatientCode() {
        return patientCode;
    }
    public void setPatientCode(String patientCode) {
        this.patientCode = patientCode;
    }
    @Transient
    public String getTypeName() {
        switch (this.type) {
            case "1": {
                return "门诊";
            }
            case "2": {
                return "住院";
            }
            case "3": {
                return "体检";
            }
        }
        return "未知";
    }
    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }
}

+ 2 - 1
patient-co-figure/src/main/java/com/yihu/figure/model/HealthIndex.java

@ -1,6 +1,7 @@
package com.yihu.figure.model;
package com.yihu.figure.model.health;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.figure.model.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;

+ 2 - 1
patient-co-figure/src/main/java/com/yihu/figure/model/HealthIndexStatistics.java

@ -1,6 +1,7 @@
package com.yihu.figure.model;
package com.yihu.figure.model.health;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.figure.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;

+ 102 - 2
patient-co-figure/src/main/java/com/yihu/figure/model/PatientInfo.java

@ -1,17 +1,23 @@
package com.yihu.figure.model;
package com.yihu.figure.model.patient;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.figure.model.IdEntity;
import com.yihu.figure.model.patient.portrait.UserPortrait;
import com.yihu.figure.model.suggest.Suggest;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by yeshijie on 2017/3/6.
 */
@Entity
@Table(name = "wlyy_patient")
@Table(name = "wlyy_patient_info")
public class PatientInfo extends IdEntity implements Serializable{
    // 业务主键
    private String code;
@ -33,6 +39,60 @@ public class PatientInfo extends IdEntity implements Serializable{
    private String address;
    // 更新時間
    private Date createTime;
    //区代码
    private String town;
    //区名称
    private String townName;
    //现病史
    private String xbs;
    //既往史
    private String jws;
    //个人史
    private String grs;
    //家族史
    private String jzs;
    //婚育史
    private String hys;
    public String getTown() {
        return town;
    }
    public void setTown(String town) {
        this.town = town;
    }
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
    //标签列表
    private List<UserPortrait> userPortraits;
    //建议列表
    private Map<String,List<Suggest>> suggests;
    @Transient
    public Map<String, List<Suggest>> getSuggests() {
        return suggests;
    }
    public void setSuggests(Map<String, List<Suggest>> suggests) {
        this.suggests = suggests;
    }
    @Transient
    public List<UserPortrait> getUserPortraits() {
        return userPortraits;
    }
    public void setUserPortraits(List<UserPortrait> userPortraits) {
        this.userPortraits = userPortraits;
    }
    public String getCode() {
        return code;
@ -115,4 +175,44 @@ public class PatientInfo extends IdEntity implements Serializable{
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getXbs() {
        return xbs;
    }
    public void setXbs(String xbs) {
        this.xbs = xbs;
    }
    public String getJws() {
        return jws;
    }
    public void setJws(String jws) {
        this.jws = jws;
    }
    public String getGrs() {
        return grs;
    }
    public void setGrs(String grs) {
        this.grs = grs;
    }
    public String getJzs() {
        return jzs;
    }
    public void setJzs(String jzs) {
        this.jzs = jzs;
    }
    public String getHys() {
        return hys;
    }
    public void setHys(String hys) {
        this.hys = hys;
    }
}

+ 79 - 0
patient-co-figure/src/main/java/com/yihu/figure/model/patient/portrait/UserPortrait.java

@ -0,0 +1,79 @@
package com.yihu.figure.model.patient.portrait;
import com.yihu.figure.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by chenweida on 2017/3/7.
 */
@Entity
@Table(name = "figure_user_portrait")
public class UserPortrait extends IdEntity {
    private String userCode;//用户code
    private String category;//标签类别
    private String categoryName;//类别名称
    private String subCategory;//标签子类别
    private String subCategoryName;//标签子类别名称
    private String value;//标签名称
    private Date czrq;//
    public String getUserCode() {
        return userCode;
    }
    public String getCategoryName() {
        return categoryName;
    }
    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }
    public void setUserCode(String userCode) {
        this.userCode = userCode;
    }
    public String getCategory() {
        return category;
    }
    public void setCategory(String category) {
        this.category = category;
    }
    public String getSubCategory() {
        return subCategory;
    }
    public void setSubCategory(String subCategory) {
        this.subCategory = subCategory;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
    public String getSubCategoryName() {
        return subCategoryName;
    }
    public void setSubCategoryName(String subCategoryName) {
        this.subCategoryName = subCategoryName;
    }
}

+ 51 - 0
patient-co-figure/src/main/java/com/yihu/figure/model/suggest/Suggest.java

@ -0,0 +1,51 @@
package com.yihu.figure.model.suggest;
import com.yihu.figure.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by chenweida on 2017/3/7.
 * 建议表
 */
@Entity
@Table(name = "figure_suggest")
public class Suggest extends IdEntity {
    private String content;//建议内容
    private String type;//建议类型 (字典表SUGGEST)1:生活方式 2:饮食 3运动 4用药
    private String typeName;//
    private String keyword;//关键字 匹配居民标签
    public String getTypeName() {
        return typeName;
    }
    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getKeyword() {
        return keyword;
    }
    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }
}

+ 0 - 10
patient-co-figure/src/main/java/com/yihu/figure/service/DietService.java

@ -1,10 +0,0 @@
package com.yihu.figure.service;
import org.springframework.stereotype.Service;
/**
 * Created by chenweida on 2017/3/6.
 */
@Service
public class DietService {
}

+ 167 - 0
patient-co-figure/src/main/java/com/yihu/figure/service/DiseaseService.java

@ -1,10 +1,177 @@
package com.yihu.figure.service;
import com.yihu.figure.dao.disease.InspectionDao;
import com.yihu.figure.dao.disease.VisitDao;
import com.yihu.figure.model.disease.Inspection;
import com.yihu.figure.model.disease.Visit;
import com.yihu.figure.util.DateUtil;
import com.yihu.figure.util.HttpClientUtil;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.net.URLEncoder;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/3/6.
 */
@Service
public class DiseaseService {
    private String baseurl = "http://120.41.252.108:8181/figure/";
    @Autowired
    private VisitDao visitDao;
    @Autowired
    private InspectionDao inspectionDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 造就诊事件的数据
     *
     * @param strSSID
     */
    @Transactional
    public void getResidentEventListJson(String strSSID,String patientCode) {
        String url = baseurl + "data/getResidentEventListJson?strSSID=" + strSSID;
        String response = HttpClientUtil.get(url, "UTF-8");
        JSONObject obj = new JSONObject(response);
        if (obj.has("门诊")) {
            List<Visit> visits = new ArrayList<>();
            JSONArray ja = obj.getJSONArray("门诊");
            for (int i = 0; i < ja.length(); i++) {
                JSONObject jo = ja.getJSONObject(i);
                Visit visit = new Visit(patientCode);
                visit.setDiagnosis(jo.getString("DIAGNOSIS"));
                visit.setEndTime(DateUtil.strToDate(jo.getString("END_TIME"), "yyyy-MM-dd HH:mm:ss"));
                visit.setEvent(jo.getString("EVENT"));
                visit.setOrgId(jo.getInt("ORG_ID"));
                visit.setOrgName(jo.getString("ORG_NAME"));
                visit.setR(jo.getInt("R") + "");
                visit.setType(jo.getInt("TYPE") + "");
                visit.setIcdCode(jo.getString("ICD_CODE"));
                visits.add(visit);
            }
            visitDao.save(visits);
        }
        if (obj.has("住院")) {
            List<Visit> visits = new ArrayList<>();
            JSONArray ja = obj.getJSONArray("住院");
            for (int i = 0; i < ja.length(); i++) {
                JSONObject jo = ja.getJSONObject(i);
                Visit visit = new Visit();
                visit.setDiagnosis(jo.getString("DIAGNOSIS"));
                visit.setEndTime(DateUtil.strToDate(jo.getString("END_TIME"), "yyyy-MM-dd HH:mm:ss"));
                visit.setEvent(jo.getString("EVENT"));
                visit.setOrgId(jo.getInt("ORG_ID"));
                visit.setOrgName(jo.getString("ORG_NAME"));
                visit.setR(jo.getInt("R") + "");
                visit.setType(jo.getInt("TYPE") + "");
                visit.setIcdCode(jo.getString("ICD_CODE"));
                visits.add(visit);
            }
            visitDao.save(visits);
        }
    }
    /**
     * 造检查检验的数据
     *
     * @param strSSID
     */
    @Transactional
    public void GetRecordListByCatalogcodesJson(String strSSID,String patientCode) {
        String url = baseurl + "data/GetRecordListByCatalogcodesJson?strSSID=" + strSSID;
        String response = HttpClientUtil.get(url, "UTF-8");
        JSONObject obj = new JSONObject(response);
        if (obj.has("检查")) {
            List<Inspection> inspections = new ArrayList<>();
            JSONArray ja = obj.getJSONArray("检查");
            for (int i = 0; i < ja.length(); i++) {
                JSONObject jo = ja.getJSONObject(i);
                Inspection inspection = new Inspection(patientCode);
                inspection.setCatalogCode(jo.getString("CATALOG_CODE"));
                inspection.setEhrCommitTime(DateUtil.strToDate(jo.getString("EHR_COMMIT_TIME"), "yyyy-MM-dd HH:mm:ss"));
                inspection.setEndTime(DateUtil.strToDate(jo.getString("END_TIME"), "yyyy-MM-dd HH:mm:ss"));
                inspection.setEvent(jo.getString("EVENT"));
                inspection.setItem(jo.getString("ITEM"));
                inspection.setOrgId(jo.getInt("ORG_ID"));
                inspection.setOrgName(jo.getString("ORG_NAME"));
                inspection.setR(jo.getInt("R"));
                inspection.setSerial(jo.getInt("SERIAL")+"");
                inspection.setType(jo.getInt("TYPE")+"");
                inspection.setUnionssid(jo.getString("UNIONSSID"));
                inspection.setXmanId(jo.getString("XMAN_ID"));
                inspections.add(inspection);
            }
            inspectionDao.save(inspections);
        }
    }
    /**
     *
     * @param patientCode
     * @param time  2015
      * @return
     */
    public List<Visit> getVisits(String patientCode,String time,String icdName) {
        StringBuffer sql=new StringBuffer("select * from figure_visit f where 1=1 and  f.patient_code =? ");
        List<Object> params=new ArrayList<>();
        params.add(patientCode);
        if(!StringUtils.isEmpty(time)){
            sql.append(" and f.end_time >= ? ");
            params.add( LocalDate.of(Integer.valueOf(time),1,1).toString());
            sql.append(" and f.end_time < ? ");
            params.add( LocalDate.of(Integer.valueOf(time),1,1).plusYears(1).toString());
        }
        if(!StringUtils.isEmpty(icdName)){
            sql.append(" and f.diagnosis like ? ");
            params.add("%"+icdName+"%");
        }
        sql.append(" order by f.end_time desc ");
        List<Visit> visisList= jdbcTemplate.query(sql.toString(),params.toArray(),new BeanPropertyRowMapper(Visit.class));
        return visisList;
    }
    public List<Inspection> getInspections(String patientCode,String time,String type) {
        StringBuffer sql=new StringBuffer("select * from figure_inspection f where 1=1 and  f.patient_code =? ");
        List<Object> params=new ArrayList<>();
        params.add(patientCode);
        if(!StringUtils.isEmpty(time)){
            sql.append(" and f.end_time >= ? ");
            params.add( LocalDate.of(Integer.valueOf(time),1,1).toString());
            sql.append(" and f.end_time < ? ");
            params.add( LocalDate.of(Integer.valueOf(time),1,1).plusYears(1).toString());
        }
        if(!StringUtils.isEmpty(type))
        {
            sql.append(" and ( " +
                    " f.item like '%血常规%' or " +
                    " f.item like '%血糖%' or " +
                    " f.item like '%糖化%' or " +
                    " f.item like '%蛋白%' or " +
                    " f.item like '%眼底%' or " +
                    " f.item like '%肝功%'  ) ");
        }
        sql.append(" order by f.end_time desc ");
        List<Inspection> inspectionList= jdbcTemplate.query(sql.toString(),params.toArray(),new BeanPropertyRowMapper(Inspection.class));
        return inspectionList;
    }
}

+ 0 - 10
patient-co-figure/src/main/java/com/yihu/figure/service/MedicinalService.java

@ -1,10 +0,0 @@
package com.yihu.figure.service;
import org.springframework.stereotype.Service;
/**
 * Created by chenweida on 2017/3/6.
 */
@Service
public class MedicinalService {
}

+ 43 - 2
patient-co-figure/src/main/java/com/yihu/figure/service/PatientInfoService.java

@ -1,15 +1,56 @@
package com.yihu.figure.service;
import com.yihu.figure.dao.PatientInfoDao;
import com.yihu.figure.dao.patient.PatientInfoDao;
import com.yihu.figure.dao.SuggestDao;
import com.yihu.figure.dao.patient.portrait.UserPortraitDao;
import com.yihu.figure.model.patient.PatientInfo;
import com.yihu.figure.model.patient.portrait.UserPortrait;
import com.yihu.figure.model.suggest.Suggest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by yeshijie on 2017/3/6.
 */
@Service
public class PatientInfoService extends BaseService{
public class PatientInfoService extends BaseService {
    @Autowired
    private PatientInfoDao patientInfoDao;
    @Autowired
    private UserPortraitDao userPortraitDao;
    @Autowired
    private SuggestDao suggesdao;
    public PatientInfo getPatientInfo(String patientCode) {
        PatientInfo patient = patientInfoDao.findByCode(patientCode);
        //得到用户标签
        List<UserPortrait> userPortraits = userPortraitDao.findByPatientCode(patientCode);
        patient.setUserPortraits(userPortraits);
        //根据用户的标签得到建议
        Map<String, List<Suggest>> map = new HashMap<>();
        userPortraits.stream().forEach(u -> {
            List<Suggest> ss = suggesdao.findByKeyword("%" + u.getValue() + "%");
            ss.stream().forEach(s -> {
                if (map.containsKey(s.getTypeName())) {
                    map.get(s.getTypeName()).add(s);
                } else {
                    List<Suggest> suggests=new ArrayList<Suggest>();
                    suggests.add(s);
                    map.put(s.getTypeName(), suggests);
                }
            });
        });
        patient.setSuggests(map);
        return patient;
    }
    public List<PatientInfo> getPatientList() {
        List<PatientInfo>  pas=patientInfoDao.findByHasCode();
        return pas;
    }
}

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

@ -0,0 +1,192 @@
package com.yihu.figure.service;
import com.yihu.figure.dao.patient.PatientInfoDao;
import com.yihu.figure.dao.patient.portrait.UserPortraitDao;
import com.yihu.figure.model.disease.Visit;
import com.yihu.figure.model.patient.PatientInfo;
import com.yihu.figure.model.patient.portrait.UserPortrait;
import com.yihu.figure.util.DateUtil;
import com.yihu.figure.util.IdCardUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.*;
/**
 * Created by chenweida on 2017/3/8.
 */
@Service
public class PortraitService {
    @Autowired
    private UserPortraitDao userPortraitDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientInfoDao patientDao;
    public List<UserPortrait> getPatientInfo(String category, String subCategory, String value) {
        StringBuffer sql = new StringBuffer("select * from figure_user_portrait f where 1=1");
        List params = new ArrayList<>();
        if (!StringUtils.isEmpty(category)) {
            sql.append(" and f.category = ? ");
            params.add(category);
        }
        if (!StringUtils.isEmpty(subCategory)) {
            sql.append(" and f.sub_category = ? ");
            params.add(subCategory);
        }
        if (!StringUtils.isEmpty(value)) {
            sql.append(" and f.value like ? ");
            params.add("%" + value + "%");
        }
        List<UserPortrait> userPortraits = jdbcTemplate.query(sql.toString(), params.toArray(), new BeanPropertyRowMapper(UserPortrait.class));
        return userPortraits;
    }
    @Transactional
    public void newPortrait(String category, String subCategory) {
        List<PatientInfo> patient = patientDao.findAllPatient();
        List<UserPortrait> ups = new ArrayList<>();
        patient.stream().forEach(p -> {
            UserPortrait u = new UserPortrait();
            u.setCategory(category);
            u.setSubCategory(subCategory);
            u.setCzrq(new Date());
            u.setUserCode(p.getCode());
            //年龄
            //ups.add(age(DateUtil.getAgeByBirthday(p.getBirthday()),u));
            //市
            //ups.add(city("厦门市",u));
            //区
            //ups.add(town(p.getTownName(),u));
            //性别标签
            //ups.add(sex(p.getSex(),u));
            //疾病标签
            // ups.add(jibing(p,u));
            //健康分布
            ups.add(jkfb(p, u));
        });
        userPortraitDao.save(ups);
    }
    private UserPortrait jkfb(PatientInfo p, UserPortrait u) {
        Integer age = DateUtil.getAgeByBirthday(p.getBirthday());
        if (age > 25)
            u.setValue("患病人群");
        return u;
    }
    private UserPortrait jibing(PatientInfo p, UserPortrait u) {
        Integer age = DateUtil.getAgeByBirthday(p.getBirthday());
        if (age > 25)
            u.setValue("糖尿病");
        return u;
    }
    private UserPortrait city(String townName, UserPortrait u) {
        u.setValue(townName);
        return u;
    }
    private UserPortrait sex(Integer sex, UserPortrait u) {
        if (sex != null && sex == 2) {
            u.setValue("女");
        } else {
            u.setValue("男");
        }
        return u;
    }
    private UserPortrait town(String townName, UserPortrait u) {
        u.setValue(townName);
        return u;
    }
    private UserPortrait age(int age, UserPortrait u) {
        if (age <= 20) {
            u.setValue("20岁以下");
        } else if (age > 20 && age <= 40) {
            u.setValue("20-40岁");
        } else if (age > 40 && age <= 65) {
            u.setValue("40-65岁");
        } else {
            u.setValue("65岁以上");
        }
        return u;
    }
    /**
     * 根据疾病获取病人区域分布
     *
     * @param subcategory 二级指标的维度
     * @param value       疾病名称 糖尿病 高血压
     * @return
     */
    public Map<String, Integer> getPortraits(String subcategory, String value) {
        //查找除子类别是1002001中的其他类别 例如 查找高血压下的各个年龄段的患者
        String sql = " select * from " +
                " (select DISTINCT(u.user_code) user_code from figure_user_portrait u where u.sub_category='1002001' and u.`value` like ? ) jb," +
                " (select DISTINCT(u.user_code) user_code,u.`value` from figure_user_portrait u where u.sub_category= ?  ) q " +
                " where jb.user_code=q.user_code ";
        List params = new ArrayList<>();
        params.add("%" + value + "%");
        params.add(subcategory);
        List<UserPortrait> userPortraits = jdbcTemplate.query(sql, params.toArray(), new BeanPropertyRowMapper(UserPortrait.class));
        Map<String, Integer> data = new HashMap<>();
        userPortraits.stream().forEach(u -> {
            Integer sum = 1;
            if (data.containsKey(u.getValue())) {
                sum = data.get(u.getValue()) + 1;
            }
            data.put(u.getValue(), sum);
        });
        //总数 用于控制层计算
        data.put("allSize", userPortraits.size());
        return data;
    }
    /**
     * @param key 1 疾病 2 健康分布
     * @return
     */
    public Map<String, Integer> getPortraitsLevel1(String key) {
        //找出对应的子类别代码
        String subCategory = getSubCategory(key);
        //根据子类别找出所有的用户标签
        List<UserPortrait> ups = userPortraitDao.findBySubCategory(subCategory);
        Map<String, Integer> returnMap = new HashMap<>();
        ups.stream().forEach(up -> {
            Integer sum = 1;
            if (returnMap.containsKey(up.getValue())) {
                sum = returnMap.get(up.getValue()) + 1;
            }
            returnMap.put(up.getValue(), sum);
        });
        //总数 用于控制层计算
        returnMap.put("allSize", ups.size());
        return returnMap;
    }
    private String getSubCategory(String key) {
        switch (key) {
            case "1": {
                return "1002001";
            }
            case "2": {
                return "1002006";
            }
        }
        return "";
    }
    public UserPortrait findPortraitById(Long id) {
        return userPortraitDao.findOne(id);
    }
}

+ 0 - 10
patient-co-figure/src/main/java/com/yihu/figure/service/SportsService.java

@ -1,10 +0,0 @@
package com.yihu.figure.service;
import org.springframework.stereotype.Service;
/**
 * Created by chenweida on 2017/3/6.
 */
@Service
public class SportsService {
}

+ 45 - 0
patient-co-figure/src/main/java/com/yihu/figure/service/SuggestService.java

@ -0,0 +1,45 @@
package com.yihu.figure.service;
import com.yihu.figure.dao.SuggestDao;
import com.yihu.figure.dao.patient.portrait.UserPortraitDao;
import com.yihu.figure.model.patient.portrait.UserPortrait;
import com.yihu.figure.model.suggest.Suggest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/3/7.
 */
@Service
public class SuggestService {
    @Autowired
    private UserPortraitDao userPortraitDao;
    @Autowired
    private SuggestDao suggesdao;
    public Map<String, List<Suggest>> getPatientSuggest(String patientCode) {
        //得到用户标签
        List<UserPortrait> userPortraits = userPortraitDao.findByPatientCode(patientCode);
        //根据用户的标签得到建议
        Map<String, List<Suggest>> map = new HashMap<>();
        userPortraits.stream().forEach(u -> {
            List<Suggest> ss = suggesdao.findByKeyword("%" + u.getValue() + "%");
            ss.stream().forEach(s -> {
                if (map.containsKey(s.getTypeName())) {
                    map.get(s.getTypeName()).add(s);
                } else {
                    List<Suggest> suggests = new ArrayList<Suggest>();
                    suggests.add(s);
                    map.put(s.getTypeName(), suggests);
                }
            });
        });
        return map;
    }
}

+ 6 - 5
patient-co-figure/src/main/java/com/yihu/figure/service/HealthIndexService.java

@ -1,9 +1,10 @@
package com.yihu.figure.service;
package com.yihu.figure.service.health;
import com.yihu.figure.dao.HealthIndexDao;
import com.yihu.figure.dao.HealthIndexStatisticsDao;
import com.yihu.figure.model.HealthIndex;
import com.yihu.figure.model.HealthIndexStatistics;
import com.yihu.figure.dao.health.HealthIndexDao;
import com.yihu.figure.dao.health.HealthIndexStatisticsDao;
import com.yihu.figure.model.health.HealthIndex;
import com.yihu.figure.model.health.HealthIndexStatistics;
import com.yihu.figure.service.BaseService;
import com.yihu.figure.util.DateUtil;
import com.yihu.figure.util.ETLConstantData;
import com.yihu.figure.util.IdCardUtil;

+ 2 - 1
patient-co-figure/src/main/java/com/yihu/figure/service/HealthIndexStatisticsService.java

@ -1,5 +1,6 @@
package com.yihu.figure.service;
package com.yihu.figure.service.health;
import com.yihu.figure.service.BaseService;
import org.springframework.stereotype.Component;
import javax.transaction.Transactional;

+ 0 - 511
patient-co-figure/src/main/java/com/yihu/figure/web/BaseController.java

@ -1,511 +0,0 @@
package com.yihu.figure.web;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.figure.model.IdEntity;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.util.ReflectionUtils;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;
import java.util.*;
public class BaseController {
    private static Logger logger = LoggerFactory.getLogger(BaseController.class);
    @Autowired
    protected HttpServletRequest request;
    /**
     * 獲取髮送請求用戶的uid
     *
     * @return
     */
    public String getUID() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("uid");
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 獲取髮送請求用戶的uid
     *
     * @return
     */
    public String getLastUid() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("lastUid");
        } catch (Exception e) {
            return null;
        }
    }
    public String getOpenid() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("openid");
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 获取用户ID
     *
     * @return
     */
    public long getId() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getLong("id");
        } catch (Exception e) {
            return 0;
        }
    }
    public String getIMEI() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("imei");
        } catch (Exception e) {
            return null;
        }
    }
    public String getToken() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("token");
        } catch (Exception e) {
            return null;
        }
    }
    public void error(Exception e) {
        logger.error(getClass().getName() + ":", e.getMessage());
        e.printStackTrace();
    }
    public void warn(Exception e) {
        logger.warn(getClass().getName() + ":", e.getMessage());
        e.printStackTrace();
    }
    public void infoMessage(String message) {
        logger.info(message);
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String error(int code, String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return null;
        }
    }
    /**
     * 接口处理成功
     *
     * @param msg
     * @return
     */
    public String success(String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", 200);
            map.put("msg", msg);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return null;
        }
    }
    public String write(int code, String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return null;
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param key 结果数据
     * @return
     */
    public String write(int code, String msg, String key, List<?> list) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, list);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, JSONObject value) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            json.put(key, value);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, JSONArray value) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            json.put(key, value);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param total 总数
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, int total, String key, JSONArray value) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            json.put("total", total);
            json.put(key, value);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Object value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param key 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Page<?> list) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            // 是否为第一页
            map.put("isFirst", list.isFirst());
            // 是否为最后一页
            map.put("isLast", list.isLast());
            // 总条数
            map.put("total", list.getTotalElements());
            // 总页数
            map.put("totalPages", list.getTotalPages());
            map.put(key, list.getContent());
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param key 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Page<?> page, JSONArray array) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            // 是否为第一页
            json.put("isFirst", page == null ? false : page.isFirst());
            // 是否为最后一页
            json.put("isLast", page == null ? true : page.isLast());
            // 总条数
            json.put("total", page == null ? 0 : page.getTotalElements());
            // 总页数
            json.put("totalPages", page == null ? 0 : page.getTotalPages());
            json.put(key, array);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Map<?, ?> value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, String value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param key 结果数据
     * @return
     */
    public String write(int code, String msg, String key, IdEntity entity) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, entity);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param key 结果数据
     * @return
     */
    public String write(int code, String msg, boolean isFirst, boolean isLast, long total, int totalPages, String key, Object values) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            // 是否为第一页
            json.put("isFirst", isFirst);
            // 是否为最后一页
            json.put("isLast", isLast);
            // 总条数
            json.put("total", total);
            // 总页数
            json.put("totalPages", totalPages);
            json.put(key, values);
            return json.toString();
        } catch (Exception e) {
            logger.error("BaseController:", e.getMessage());
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    public String trimEnd(String param, String trimChars) {
        if (param.endsWith(trimChars)) {
            param = param.substring(0, param.length() - trimChars.length());
        }
        return param;
    }
    /**
     * 无效用户消息返回
     *
     * @param e
     * @param defaultCode
     * @param defaultMsg
     * @return
     */
    public String invalidUserException(Exception e, int defaultCode, String defaultMsg) {
        try {
            // if (e instanceof UndeclaredThrowableException) {
            // UndeclaredThrowableException ute = (UndeclaredThrowableException) e;
            // InvalidUserException iue = (InvalidUserException) ute.getUndeclaredThrowable();
            // if (iue != null) {
            // return error(iue.getCode(), iue.getMsg());
            // }
            // }
            return error(defaultCode, defaultMsg);
        } catch (Exception e2) {
            return null;
        }
    }
    public List<Map<String, Object>> copyBeans(Collection<? extends Object> beans, String... propertyNames) {
        List<Map<String, Object>> result = new ArrayList<>();
        for (Object bean : beans) {
            result.add(copyBeanProperties(bean, propertyNames));
        }
        return result;
    }
    /**
     * 复制特定属性。
     *
     * @param bean
     * @param propertyNames
     * @return
     */
    public Map<String, Object> copyBeanProperties(Object bean, String... propertyNames) {
        Map<String, Object> simplifiedBean = new HashMap<>();
        for (String propertyName : propertyNames) {
            Field field = ReflectionUtils.findField(bean.getClass(), propertyName);
            if (field != null) {
                field.setAccessible(true);
                Object value = ReflectionUtils.getField(field, bean);
                simplifiedBean.put(propertyName, value == null ? "" : value);
            } else {
                simplifiedBean.put(propertyName, "");
            }
        }
        return simplifiedBean;
    }
}

+ 1 - 1
patient-co-figure/src/main/resources/application.yml

@ -59,7 +59,7 @@ spring:
  profiles: dev
  datasource:
    url: jdbc:mysql://172.19.103.77/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
    url: jdbc:mysql://172.19.103.77/figure?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
    username: root
    password: 123456

BIN
patient-co-figure/文档/tomcat部署.docx


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


+ 8 - 6
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientReservation.java

@ -42,9 +42,9 @@ public class PatientReservation extends IdEntity {
	// 预约时间段:AM (上午)或者PM (下午)
	private String sectionType;
	// 一次预约段的开始时间
	private String startTime;
	private Date startTime;
	// 一次预约段的结束时间
	private String endTime;
	private Date endTime;
	// 医生所在医疗机构编码
	private String orgCode;
	// 医疗机构名称
@ -154,20 +154,22 @@ public class PatientReservation extends IdEntity {
	}
	@Column(name = "start_time")
	public String getStartTime() {
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getStartTime() {
		return startTime;
	}
	public void setStartTime(String startTime) {
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}
	@Column(name = "end_time")
	public String getEndTime() {
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getEndTime() {
		return endTime;
	}
	public void setEndTime(String endTime) {
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

+ 37 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -0,0 +1,37 @@
package com.yihu.wlyy.event;
import com.yihu.wlyy.job.QuartzHelper;
import com.yihu.wlyy.job.SignEndJob;
import com.yihu.wlyy.util.SystemConf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Service;
import java.util.HashMap;
/**
 * Created by lyr-pc on 2017/3/10.
 */
@Service
public class ApplicationEvent implements ApplicationListener<ContextRefreshedEvent>{
    @Autowired
    QuartzHelper quartzHelper;
    @Override
    public void onApplicationEvent(ContextRefreshedEvent ContextRefreshedEvent) {
        try {
            // 启动签约到期处理JOB
            if (!quartzHelper.isExistJob("sign_end_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("sign_end_job_trigger");
                quartzHelper.addJob(SignEndJob.class, trigger, "sign_end_job", new HashMap<String, Object>());
                System.out.println("sign end job start success");
            } else {
                System.out.println("sign end job exist");
            }
        } catch (Exception e) {
            System.out.println("sign end job start failed");
        }
    }
}

+ 45 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/job/SignEndJob.java

@ -0,0 +1,45 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.service.app.followup.FollowUpService;
import com.yihu.wlyy.util.DateUtil;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Calendar;
import java.util.Date;
/**
 * Created by lyr-pc on 2017/3/9.
 */
public class SignEndJob implements Job {
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        try {
            System.out.println("sign end job start");
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            Calendar today = Calendar.getInstance();
            today.add(Calendar.DATE, -1);
            String date = DateUtil.dateToStrShort(today.getTime());
            String start = date + " 00:00:00";
            String end = date + " 23:59:59";
            String sql = "update wlyy_sign_family set status = -4 where end >= ? and end <= ? and status > 0";
            int sucess = jdbcTemplate.update(sql, start, end);
            String sqlT = "update wlyy_doctor_team set del = '0' where del = '1' and code in (select team_code from wlyy_sign_family where end >= ? and end <= ? and status > 0)";
            String sqlTm = "update wlyy_doctor_team_member set del = '0' where del = '1' and team in (select team_code from wlyy_sign_family where end >= ? and end <= ? and status > 0)";
            int sucessT = jdbcTemplate.update(sqlT, start, end);
            int sucessTm = jdbcTemplate.update(sqlTm, start, end);
            System.out.println("sign end job end");
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("sign end job failed");
        }
    }
}

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

@ -35,6 +35,6 @@ public interface PatientReservationDao extends PagingAndSortingRepository<Patien
	PatientReservation findByPatientAndCancelerAndCancelTime(String patient,String canceler,String cancelerTime);
	//根据患者医获取近三个月的已取消的预约记录
	@Query("select a from PatientReservation a where a.patient = ?1 and (a.startTime between ?2 and ?3 or a.startTime between ?4 and ?5 ) and a.status = 0 order by a.startTime desc")
	List<PatientReservation> findByPatientAndStartTime(String patientCode, String strStart, String strEnd,String startTime,String endTime);
	@Query("select a from PatientReservation a where a.patient = ?1 and a.startTime between ?2 and ?3 and a.status = 0 order by a.startTime desc")
	List<PatientReservation> findByPatientAndStartTime(String patientCode,Date startTime,Date endTime);
}

+ 52 - 51
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java

@ -4,7 +4,6 @@ import com.yihu.wlyy.entity.device.Device;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeamMember;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.deviece.DeviceDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao;
@ -68,65 +67,67 @@ public class PatientDeviceService extends BaseService {
	 * 保存患者设备
	 */
	public boolean saveDevice(PatientDevice patientDevice) throws Exception {
		//判断sn码是否被使用
		String sn = patientDevice.getDeviceSn();
		String type =  patientDevice.getCategoryCode();
		Long deviceId =  patientDevice.getDeviceId();
		String userType = patientDevice.getUserType();
		if(userType == null)
		{
			userType = "-1";
			patientDevice.setUserType("-1");
		}
		synchronized (patientDevice.getDeviceSn()){
			//判断sn码是否被使用
			String sn = patientDevice.getDeviceSn();
			String type =  patientDevice.getCategoryCode();
			Long deviceId =  patientDevice.getDeviceId();
			String userType = patientDevice.getUserType();
			if(userType == null)
			{
				userType = "-1";
				patientDevice.setUserType("-1");
			}
		boolean needVerify = true;
		//修改操作
		if(patientDevice.getId()!=null)
		{
			PatientDevice deviceOld =  patientDeviceDao.findOne(patientDevice.getId());
			if(deviceOld!=null)
			boolean needVerify = true;
			//修改操作
			if(patientDevice.getId()!=null)
			{
				if(deviceOld.getDeviceSn().equals(sn))
				PatientDevice deviceOld =  patientDeviceDao.findOne(patientDevice.getId());
				if(deviceOld!=null)
				{
					needVerify = false;
					if(deviceOld.getDeviceSn().equals(sn))
					{
						needVerify = false;
					}
				}
				else{
					throw new Exception("不存在该条记录!");
				}
			}
			else{
				throw new Exception("不存在该条记录!");
			}
		}
		//校验sn码是否被使用
		if(needVerify) {
			PatientDevice device = patientDeviceDao.findByDeviceIdAndDeviceSnAndUserTypeAndDel(deviceId, sn, userType,0);
			if (device != null && !device.getId().equals(patientDevice.getId())) {
				throw new Exception("sn码" + sn + "已被使用!");
			//校验sn码是否被使用
			if(needVerify) {
				PatientDevice device = patientDeviceDao.findByDeviceIdAndDeviceSnAndUserTypeAndDel(deviceId, sn, userType,0);
				if (device != null && !device.getId().equals(patientDevice.getId())) {
					throw new Exception("sn码" + sn + "已被使用!");
				}
			}
			patientDevice.setCzrq(clock.getCurrentDate());
			//当前用户的身份证
			Patient patient = patientDao.findByCode(patientDevice.getUser());
			patientDevice.setUserIdcard(patient.getIdcard());
			//注册设备
			Map<String, String> params = new HashMap<>();
			params.put("deviceSn", sn);
			//调用服务
			String response = HttpClientUtil.httpPost(url + registerDevice,HttpClientUtil.getSecretParams(params,appid,secret));
			System.out.println("注册设备="+response);
			JSONObject json = new JSONObject(response);
			String code = json.get("Code").toString();
			//10000注册成功 10001已注册 -10000参数不通过(没传参数) -10001设备不存在 -10002设备未出库
			if("10000".equals(code)||"10001".equals(code))
			{
				patientDeviceDao.save(patientDevice);
			}else{
				String message = json.get("Message").toString();
				throw new Exception(message);
			}
		}
		patientDevice.setCzrq(clock.getCurrentDate());
		//当前用户的身份证
		Patient patient = patientDao.findByCode(patientDevice.getUser());
		patientDevice.setUserIdcard(patient.getIdcard());
		//注册设备
		Map<String, String> params = new HashMap<>();
		params.put("deviceSn", sn);
		//调用服务
		String response = HttpClientUtil.httpPost(url + registerDevice,HttpClientUtil.getSecretParams(params,appid,secret));
		System.out.println("注册设备="+response);
		JSONObject json = new JSONObject(response);
		String code = json.get("Code").toString();
		//10000注册成功 10001已注册 -10000参数不通过(没传参数) -10001设备不存在 -10002设备未出库
		if("10000".equals(code)||"10001".equals(code))
		{
			patientDeviceDao.save(patientDevice);
		}else{
			String message = json.get("Message").toString();
			throw new Exception(message);
			return true;
		}
		return true;
	}
	/**

+ 14 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/HealthEduArticleService.java

@ -6,9 +6,7 @@ import com.yihu.wlyy.entity.education.HealthEduArticlePatient;
import com.yihu.wlyy.repository.education.HealthEduArticleDao;
import com.yihu.wlyy.repository.education.HealthEduArticlePatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.Xml2ListMap;
import com.yihu.wlyy.util.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
@ -54,6 +52,7 @@ public class HealthEduArticleService extends BaseService {
        String content = null;
        String keyWord = null;
        String type = null;
        String summary = null;
        int rows = 0;
        for(Map<String,String> temp : listmap){
            code = temp.get("xml.Result.MessageId");
@ -61,6 +60,14 @@ public class HealthEduArticleService extends BaseService {
            imgUrl = temp.get("xml.Result.ImageUrlSmall");
            content = temp.get("xml.Result.MessageContent");
            keyWord = temp.get("xml.Result.MessageType");
            String str = Html2Text.Html2Text(content);
            if(str.length()>50){
            summary = str.substring(0,50).replace("\n","").replace(" ","").replace("&nbsp;","");
            }else {
                summary = str.replace("\n","").replace(" ","").replace("&nbsp;","");
            }
            switch (keyWord){
                case "1":
                    keyWord = "高血压";
@ -101,8 +108,10 @@ public class HealthEduArticleService extends BaseService {
            }
            String sql = "INSERT INTO wlyy_health_edu_article  " +
                    "VALUES(NULL,?,?,?,?,NULL,?,?)";
            rows = jdbcTemplate.update(sql,code,title,imgUrl,content,keyWord,type);
                    "VALUES(NULL,?,?,?,?,?,NULL,?,?)";
           /* String sql = "INSERT INTO wlyy_health_article  " +
                    "VALUES(NULL,?,?,?,?,?,NULL,?,?)";*/
            rows = jdbcTemplate.update(sql,code,title,summary,imgUrl,content,keyWord,type);
            rows+=rows;
        }
        return rows;

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reservation/PatientReservationService.java

@ -179,7 +179,7 @@ public class PatientReservationService extends BaseService {
            reservation.setPhone(phone);
            reservation.setSectionType(section_type);
            reservation.setSsc(ssc);
            reservation.setStartTime(start_time);
            reservation.setStartTime(DateUtil.strToDate(start_time,DateUtil.YYYY_M_D_HH_MM_SS));
            reservation.setStatus(1);
            // 保存记录
            PatientReservation temp = patientReservationDao.save(reservation);

+ 0 - 10
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/util/ManageUtilService.java

@ -536,15 +536,5 @@ public class ManageUtilService extends BaseService {
                    .replaceAll("&nbsp;", "").replaceAll(" ",""); //剔出<html>的标签
            article.setSummary(content.length() > 50 ? content.substring(0, 49) : content);
        }
        Iterable<HealthEduArticlePatient> articlesPatient = healthEduArticlePatientDao.findAll();
        for (HealthEduArticlePatient article : articlesPatient) {
            String content = article.getContent();
            content = content.replaceAll("</?[^>]+>", "")
                    .replaceAll("<a>\\s*|\t|\r|\n</a>", "")
                    .replaceAll("&nbsp;", "").replaceAll(" ",""); //剔出<html>的标签
            article.setSummary(content.length() > 50 ? content.substring(0, 49) : content);
        }
    }
}

+ 16 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java

@ -100,8 +100,8 @@ public class GuahaoXMService implements IGuahaoService {
        reservation.setPhone(patientPhone);
        reservation.setSectionType(sectionType);
        reservation.setSsc(clinicCard);
        reservation.setStartTime(startTime);
        reservation.setEndTime(endTime);
        reservation.setStartTime(DateUtil.strToDate(startTime,DateUtil.YYYY_M_D_HH_MM_SS));
        reservation.setEndTime(DateUtil.strToDate(endTime,DateUtil.YYYY_M_D_HH_MM_SS));
        reservation.setStatus(1);
        if (StringUtils.isNotEmpty(dcode)) {
            SignFamily signFamily = signFamilyDao.findByjiatingPatient(patient);
@ -868,7 +868,7 @@ public class GuahaoXMService implements IGuahaoService {
    /**
     * 根据患者医保卡获取近三个月的预约记录
     */
    public List<PatientReservation> GetRegList(String patientCode, String strStart, String strEnd,String strStartTime,String strEndTime) throws Exception {
    public List<PatientReservation> GetRegList(String patientCode, String strStart, String strEnd,Date strStartTime,Date strEndTime) throws Exception {
        Patient patient = patientService.findByCode(patientCode);
        if (patient == null) {
            throw new Exception("不存在该用户!");
@ -947,8 +947,8 @@ public class GuahaoXMService implements IGuahaoService {
                patientReservation.setDeptName(dept);
                patientReservation.setDoctorCode(DoctorCode);
                patientReservation.setDoctorName(doctor);
                patientReservation.setStartTime(regBegin);
                patientReservation.setEndTime(regEnd);
                patientReservation.setStartTime(DateUtil.strToDate(regBegin,DateUtil.YYYY_M_D_HH_MM_SS));
                patientReservation.setEndTime(DateUtil.strToDate(regEnd,DateUtil.YYYY_M_D_HH_MM_SS));
                patientReservation.setOrgCode(OrgCode);
                patientReservation.setOrgName(org);
                patientReservation.setType("1");
@ -982,9 +982,17 @@ public class GuahaoXMService implements IGuahaoService {
        }
        //根据患者医保卡获取近三个月的已取消的预约记录
        List<PatientReservation> list = patientReservationDao.findByPatientAndStartTime(patientCode,strStart,strEnd,strStartTime,strEndTime);
        List<PatientReservation> list = patientReservationDao.findByPatientAndStartTime(patientCode,strStartTime,strEndTime);
        if(list.size()>0){
            patientRegList.addAll(list);
            patientRegList.sort(new Comparator<PatientReservation>() {
                public int compare(PatientReservation o1, PatientReservation o2) {
                    Date startTime1 = o1.getStartTime();
                    Date startTime2 = o2.getStartTime();
                    return startTime2.compareTo(startTime1);
                }
            });
        }
        //保存http日志
@ -1072,8 +1080,8 @@ public class GuahaoXMService implements IGuahaoService {
            patientReservation.setDeptName(dept);
            patientReservation.setDoctorCode(DoctorCode);
            patientReservation.setDoctorName(doctor);
            patientReservation.setStartTime(regBegin);
            patientReservation.setEndTime(regEnd);
            patientReservation.setStartTime(DateUtil.strToDate(regBegin,DateUtil.YYYY_M_D_HH_MM_SS));
            patientReservation.setEndTime(DateUtil.strToDate(regEnd,DateUtil.YYYY_M_D_HH_MM_SS));
            patientReservation.setOrgCode(OrgCode);
            patientReservation.setOrgName(org);
            patientReservation.setType("1");

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -23,6 +23,8 @@ public class DateUtil {
	public static final String YYYY_MM_DD_HH = "yyyy-MM-dd HH";
	public static final String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
	public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
	public static final String YYYY_M_D_HH_MM_SS = "yyyy/M/d HH:mm:ss";
	/**
	 * 字符串转时间格式

+ 42 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/Html2Text.java

@ -0,0 +1,42 @@
package com.yihu.wlyy.util;
import java.util.regex.Pattern;
/**
 * Created by Reece on 2017/3/6.
 */
public class Html2Text {
    public static String Html2Text(String inputString){
        String htmlStr = inputString; //含html标签的字符串
        String textStr ="";
        java.util.regex.Pattern p_script;
        java.util.regex.Matcher m_script;
        java.util.regex.Pattern p_style;
        java.util.regex.Matcher m_style;
        java.util.regex.Pattern p_html;
        java.util.regex.Matcher m_html;
        try{
            String regEx_script = "<[\\s]*?script[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?script[\\s]*?>"; //定义script的正则表达式{或<script[^>]*?>[\\s\\S]*?<\\/script> }
            String regEx_style = "<[\\s]*?style[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?style[\\s]*?>"; //定义style的正则表达式{或<style[^>]*?>[\\s\\S]*?<\\/style> }
            String regEx_html = "<[^>]+>"; //定义HTML标签的正则表达式
            p_script = Pattern.compile(regEx_script,Pattern.CASE_INSENSITIVE);
            m_script = p_script.matcher(htmlStr);
            htmlStr = m_script.replaceAll(""); //过滤script标签
            p_style = Pattern.compile(regEx_style,Pattern.CASE_INSENSITIVE);
            m_style = p_style.matcher(htmlStr);
            htmlStr = m_style.replaceAll(""); //过滤style标签
            p_html = Pattern.compile(regEx_html,Pattern.CASE_INSENSITIVE);
            m_html = p_html.matcher(htmlStr);
            htmlStr = m_html.replaceAll(""); //过滤html标签
            textStr = htmlStr;
        }catch(Exception e){
//            Manager.log.debug("neiNewsAction","Html2Text: " + e.getMessage());
        }
        return textStr;//返回文本字符串
    }
}

+ 15 - 36
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.web.common.util;
import com.yihu.wlyy.job.QuartzHelper;
import com.yihu.wlyy.job.SignEndJob;
import com.yihu.wlyy.job.consult.FamousConsultTimesJob;
import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
@ -245,45 +246,23 @@ public class ManagerUtilController extends BaseController {
        }
    }
    @RequestMapping(value = "/patient")
    public String getPatientInfo() {
        try {
            OutputStream out = new FileOutputStream("D:\\city.properties");
            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
            try {
                String sql = "select code, name from dm_city";
                List<Map<String, Object>> patients = jdbcTemplate.queryForList(sql);
                for (Map<String, Object> map : patients) {
                    writer.write(map.get("code").toString() + "=" + map.get("name").toString());
                    writer.newLine();
                }
//                JSONObject log = new JSONObject();
//
//                log.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date()));
//                log.put("logType", 2);
//                log.put("caller", "");
//
//                JSONObject data = new JSONObject();
//
//                data.put("businessType", 6);
//                data.put("patient", map.get("code"));
//                data.put("data", new JSONObject(map));
//
//                log.put("data", data);
                writer.flush();
            } catch (Exception e) {
                throw new Exception(e.getMessage());
            } finally {
                writer.close();
                out.close();
    /**
     * 开始名医咨询剩余次数统计任务
     *
     * @return
     */
    @RequestMapping(value = "/start_sign_end_job")
    public String startSignEndJob() {
        try {
            if (!quartzHelper.isExistJob("sign_end_job")) {
                quartzHelper.addJob(SignEndJob.class, "0 45 10 * * ?", "sign_end_job", new HashMap<String, Object>());
                return write(200, "启动成功");
            } else {
                return write(200, "任务已存在");
            }
            return write(200, "成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "失败");
            return error(-1, "启动失败");
        }
    }
}

+ 2 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -251,11 +251,9 @@ public class StatisticsController extends BaseController {
                        String amount = "";
                        if (map1.get("code").equals(map2.get("code"))) {
                            amount = map1.get("amount").toString() + "," + map2.get("amount").toString();
                        } else {
                            amount = map1.get("amount").toString() + ",0";
                            map1.put("amount", amount);
                            returnJa.put(map1);
                        }
                        map1.put("amount", amount);
                        returnJa.put(map1);
                    }
                }
            }

+ 1 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java

@ -574,11 +574,10 @@ public class BookingController extends WeixinBaseController {
                             @RequestParam(value = "patient", required = false) String patient) {
        try {
            SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat sm2 = new SimpleDateFormat("yyyy/M/d");
            Date nowDate = new Date();
            Date oneMonthAfter = getMonthBefore(nowDate, -1);
            Date threeMonthBefore = getMonthBefore(nowDate, 3);        //三个月历史记录
            List<PatientReservation> list = guahaoXM.GetRegList(patient, sm.format(threeMonthBefore), sm.format(oneMonthAfter), sm2.format(threeMonthBefore), sm2.format(oneMonthAfter));
            List<PatientReservation> list = guahaoXM.GetRegList(patient, sm.format(threeMonthBefore), sm.format(oneMonthAfter), threeMonthBefore, oneMonthAfter);
            return write(200, "获取患者预约信息列表成功!", "data", list);
        } catch (Exception e) {
            return error(-1, e.getMessage());

+ 3 - 0
patient-co-wlyy/src/main/resources/system.properties

@ -49,6 +49,9 @@ chat_file_path=/var/local/upload/chat
admin_uid=admin
admin_token=0a5c5258-8863-4b07-a3f9-88c768528ab4
# 签约到期JOB触发时间
sign_end_job_trigger=0 0 0 * * ?
#-------------------------开发环境配置-------------------------#
# 服务器基本配置
server_ip=weixin.xmtyw.cn