Parcourir la source

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

liuwenbin il y a 7 ans
Parent
commit
f1906bd941
55 fichiers modifiés avec 2563 ajouts et 368 suppressions
  1. 202 0
      common/common-entity/src/main/java/com/yihu/device/entity/DeviceDetail.java
  2. 169 0
      common/common-entity/src/main/java/com/yihu/edu/entity/dataClean/NewCategoryModel.java
  3. 15 20
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientAimBloodSugger.java
  4. 6 3
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientAimSports.java
  5. 9 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/TrackPatient.java
  6. 9 18
      patient-co-manage/redis-cache/src/main/java/com/yihu/wlyy/task/RedisScheduledTask.java
  7. 6 5
      patient-co-manage/redis-cache/src/main/resources/application.yml
  8. 2 1
      patient-co-manage/redis-cache/src/main/webapp/WEB-INF/views/redis/cache/category/listJs.jsp
  9. 5 0
      patient-co-service/wlyy_device/pom.xml
  10. 12 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/dao/DoctorSwitchDao.java
  11. 17 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/dao/TrackPatientDao.java
  12. 50 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/model/DoctorSwitch.java
  13. 104 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/model/TrackPatient.java
  14. 239 1
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java
  15. 4 1
      patient-co-service/wlyy_device/src/main/resources/application.yml
  16. 1 1
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java
  17. 1 1
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java
  18. 2 2
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/common/thread/LoadThread.java
  19. 1 1
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/SignZYService.java
  20. 97 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/SignToRenewJob.java
  21. 9 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java
  22. 5 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyMappingDao.java
  23. 17 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/quota/JobController.java
  24. 15 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/health/repository/DeviceDetailDao.java
  25. 15 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/jkedu/repository/JkeduCategoryDao.java
  26. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/TrackPatientDao.java
  27. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/scheme/PatientSchemeListDao.java
  28. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/template/DoctorTeamGuidanceTemplateDao.java
  29. 51 14
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java
  30. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  31. 21 10
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  32. 71 12
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionDispensaryCodeService.java
  33. 549 46
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java
  34. 3 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  35. 13 13
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/jimeiJkEdu/JMJkEduArticleService.java
  36. 4 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorGuidanceTempService.java
  37. 95 10
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/iot/IotDeviceService.java
  38. 23 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java
  39. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/FileUploadController.java
  40. 27 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandlingController.java
  41. 18 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  42. 34 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/scheme/DoctroSchemeController.java
  43. 1 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorGuidanceTempController.java
  44. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java
  45. 27 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/booking/PatientBookingController.java
  46. 19 15
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java
  47. 34 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/family/FamilyMemberController.java
  48. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthController.java
  49. 108 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/scheme/PatientSchemeController.java
  50. 8 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java
  51. 29 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/iot/IotDeviceController.java
  52. 397 144
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/service/EduArticleService.java
  53. 0 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/vo/save/ElastricSearchSaveEduArticle.java
  54. 8 0
      patient-co/patient-co-wlyy/src/main/resources/application-prod.yml
  55. 1 1
      patient-co/patient-co-wlyy/src/main/resources/system.properties

+ 202 - 0
common/common-entity/src/main/java/com/yihu/device/entity/DeviceDetail.java

@ -0,0 +1,202 @@
package com.yihu.device.entity;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by ysj on 2018/01/10.
 */
@Entity
@Table(name = "wlyy_devices")
public class DeviceDetail extends IdEntity{
    private String deviceName;
    private String deviceModel;
    private String deviceCode;
    private String manufacturer;
    private String applyDate;;
    private String orgName;
    private String linkman;
    private String tel;
    private String serverIp;
    private String manufacturerCode;
    private String address;
    private String representative;
    private String applicantName;
    private String applicantIdentity;
    private String applicantTel;
    private String applicantMail;
    /** default constructor */
    public DeviceDetail() {
    }
    /** full constructor */
    public DeviceDetail(String deviceName, String deviceModel, String deviceCode, String manufacturer, String applyDate
            , String orgName, String linkman, String tel, String serverIp, String manufacturerCode, String address
            , String representative, String applicantName, String applicantIdentity, String applicantTel, String applicantMail) {
        this.deviceName = deviceName;
        this.deviceModel = deviceModel;
        this.deviceCode = deviceCode;
        this.manufacturer = manufacturer;
        this.applyDate = applyDate;
        this.orgName = orgName;
        this.linkman = linkman;
        this.tel = tel;
        this.serverIp = serverIp;
        this.manufacturerCode = manufacturerCode;
        this.address = address;
        this.representative = representative;
        this.applicantName = applicantName;
        this.applicantIdentity = applicantIdentity;
        this.applicantTel = applicantTel;
        this.applicantMail = applicantMail;
    }
    @Column(name = "device_name")
    public String getDeviceName() {
        return deviceName;
    }
    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }
    @Column(name = "device_model")
    public String getDeviceModel() {
        return deviceModel;
    }
    public void setDeviceModel(String deviceModel) {
        this.deviceModel = deviceModel;
    }
    @Column(name = "device_code")
    public String getDeviceCode() {
        return deviceCode;
    }
    public void setDeviceCode(String deviceCode) {
        this.deviceCode = deviceCode;
    }
    @Column(name = "manufacturer")
    public String getManufacturer() {
        return manufacturer;
    }
    public void setManufacturer(String manufacturer) {
        this.manufacturer = manufacturer;
    }
    @Column(name = "apply_date")
    public String getApplyDate() {
        return applyDate;
    }
    public void setApplyDate(String applyDate) {
        this.applyDate = applyDate;
    }
    @Column(name = "org_name")
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    @Column(name = "linkman")
    public String getLinkman() {
        return linkman;
    }
    public void setLinkman(String linkman) {
        this.linkman = linkman;
    }
    @Column(name = "tel")
    public String getTel() {
        return tel;
    }
    public void setTel(String tel) {
        this.tel = tel;
    }
    @Column(name = "server_ip")
    public String getServerIp() {
        return serverIp;
    }
    public void setServerIp(String serverIp) {
        this.serverIp = serverIp;
    }
    @Column(name = "manufacturerCode")
    public String getManufacturerCode() {
        return manufacturerCode;
    }
    public void setManufacturerCode(String manufacturerCode) {
        this.manufacturerCode = manufacturerCode;
    }
    @Column(name = "address")
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    @Column(name = "representative")
    public String getRepresentative() {
        return representative;
    }
    public void setRepresentative(String representative) {
        this.representative = representative;
    }
    @Column(name = "applicant_name")
    public String getApplicantName() {
        return applicantName;
    }
    public void setApplicantName(String applicantName) {
        this.applicantName = applicantName;
    }
    @Column(name = "applicant_identity")
    public String getApplicantIdentity() {
        return applicantIdentity;
    }
    public void setApplicantIdentity(String applicantIdentity) {
        this.applicantIdentity = applicantIdentity;
    }
    @Column(name = "applicant_tel")
    public String getApplicantTel() {
        return applicantTel;
    }
    public void setApplicantTel(String applicantTel) {
        this.applicantTel = applicantTel;
    }
    @Column(name = "applicant_mail")
    public String getApplicantMail() {
        return applicantMail;
    }
    public void setApplicantMail(String applicantMail) {
        this.applicantMail = applicantMail;
    }
}

+ 169 - 0
common/common-entity/src/main/java/com/yihu/edu/entity/dataClean/NewCategoryModel.java

@ -0,0 +1,169 @@
package com.yihu.edu.entity.dataClean;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
/**
 * Created by zhangdan on 2017/9/29.
 */
@Entity
@Table(name = "org_category")
public class NewCategoryModel {
    //类别ID
    private String categoryId;
    //类别名称
    private String categoryName;
    //1、一级类别 2、二级
    private int categoryLevel;
    //二级类别ID
    private String secondLevelId;
    //一级类别ID
    private String firstLevelId;
    //操作人所属机构
    private String orgName;
    //文章所属单位名称
    private String orgId;
    //类别状态1、正常、2删除
    private int categoryState;
    //插入时间
    private Date insertTime;
    //最后更新时间
    private Date updateTime;
    //操作人
    private String operatorName;
    //操作人ID
    private String operatorId;
    @Column(name="CategoryId")
    @Id
    @GeneratedValue(generator="system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    public String getCategoryId() {
        return categoryId;
    }
    public void setCategoryId(String categoryId) {
        this.categoryId = categoryId;
    }
    @Column(name="CategoryName")
    public String getCategoryName() {
        return categoryName;
    }
    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }
    @Column(name="CategoryLevel")
    public int getCategoryLevel() {
        return categoryLevel;
    }
    public void setCategoryLevel(int categoryLevel) {
        this.categoryLevel = categoryLevel;
    }
    @Column(name="SecondLevelId")
    public String getSecondLevelId() {
        return secondLevelId;
    }
    public void setSecondLevelId(String secondLevelId) {
        this.secondLevelId = secondLevelId;
    }
    @Column(name="FirstLevelId")
    public String getFirstLevelId() {
        return firstLevelId;
    }
    public void setFirstLevelId(String firstLevelId) {
        this.firstLevelId = firstLevelId;
    }
    @Column(name="CategoryState")
    public int getCategoryState() {
        return categoryState;
    }
    public void setCategoryState(int categoryState) {
        this.categoryState = categoryState;
    }
    @Column(name="OrgName")
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    @Column(name="OrgId")
    public String getOrgId() {
        return orgId;
    }
    public void setOrgId(String orgId) {
        this.orgId = orgId;
    }
    @Column(name="InsertTime")
    public Date getInsertTime() {
        return insertTime;
    }
    public void setInsertTime(Date insertTime) {
        this.insertTime = insertTime;
    }
    @Column(name="UpdateTime")
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    @Column(name="OperatorName")
    public String getOperatorName() {
        return operatorName;
    }
    public void setOperatorName(String operatorName) {
        this.operatorName = operatorName;
    }
    @Column(name="OperatorId")
    public String getOperatorId() {
        return operatorId;
    }
    public void setOperatorId(String operatorId) {
        this.operatorId = operatorId;
    }
}

+ 15 - 20
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientAimBloodSugger.java

@ -15,16 +15,16 @@ import java.util.Date;
@Entity
@Table(name = "wlyy_patient_aim_blood_sugger")
public class PatientAimBloodSugger extends IdEntity {
    private String code;
    private String patientcode;
    private String fbg;
    private String hpg;
    private String minimum;
    private String fbgMin;
    private String hpgMin;
    private String unit;
    private Date createTime;
    @Basic
    @Column(name = "code")
    public String getCode() {
        return code;
    }
@ -33,8 +33,6 @@ public class PatientAimBloodSugger extends IdEntity {
        this.code = code;
    }
    @Basic
    @Column(name = "patientcode")
    public String getPatientcode() {
        return patientcode;
    }
@ -43,8 +41,6 @@ public class PatientAimBloodSugger extends IdEntity {
        this.patientcode = patientcode;
    }
    @Basic
    @Column(name = "fbg")
    public String getFbg() {
        return fbg;
    }
@ -53,8 +49,6 @@ public class PatientAimBloodSugger extends IdEntity {
        this.fbg = fbg;
    }
    @Basic
    @Column(name = "hpg")
    public String getHpg() {
        return hpg;
    }
@ -63,18 +57,22 @@ public class PatientAimBloodSugger extends IdEntity {
        this.hpg = hpg;
    }
    @Basic
    @Column(name = "minimum")
    public String getMinimum() {
        return minimum;
    public String getHpgMin() {
        return hpgMin;
    }
    public void setHpgMin(String hpgMin) {
        this.hpgMin = hpgMin;
    }
    public void setMinimum(String minimum) {
        this.minimum = minimum;
    public String getFbgMin() {
        return fbgMin;
    }
    public void setFbgMin(String fbgMin) {
        this.fbgMin = fbgMin;
    }
    @Basic
    @Column(name = "unit")
    public String getUnit() {
        return unit;
    }
@ -83,8 +81,6 @@ public class PatientAimBloodSugger extends IdEntity {
        this.unit = unit;
    }
    @Basic
    @Column(name = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
@ -93,5 +89,4 @@ public class PatientAimBloodSugger extends IdEntity {
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 6 - 3
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientAimSports.java

@ -1,9 +1,11 @@
package com.yihu.wlyy.entity.patient;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date;
/**
 * 患者监测目标-运动
@ -18,7 +20,7 @@ public class PatientAimSports extends IdEntity {
    private Integer dailyStepCount;     //运动步数
    private String bmiMax;              //bmi标准上限
    private String bmiMin;              //bmi标准下线
    private Timestamp createTime;       //创建时间
    private Date createTime;       //创建时间
    @Basic
@ -73,11 +75,12 @@ public class PatientAimSports extends IdEntity {
    @Basic
    @Column(name = "create_time")
    public Timestamp getCreateTime() {
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Timestamp createTime) {
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

+ 9 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/TrackPatient.java

@ -20,6 +20,7 @@ public class TrackPatient extends IdEntity {
    private Integer teamCode;//居民签约团队
    private String idcard;//身份证号
    private String ssc;//社保卡号
    private String del;//删除
    private Date createTime;//创建时间
    private Date updateTime;//更新时间
@ -94,4 +95,12 @@ public class TrackPatient extends IdEntity {
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 9 - 18
patient-co-manage/redis-cache/src/main/java/com/yihu/wlyy/task/RedisScheduledTask.java

@ -36,9 +36,6 @@ import java.util.List;
 * @date 2017/12/6 09:22
 */
@Component
//@RestController
//@RequestMapping(value = ApiVersion.Version1_0)
//@Api(description = "定时任务", tags = {"缓存服务管理--定时任务"})
public class RedisScheduledTask {
    Logger logger = LoggerFactory.getLogger(RedisScheduledTask.class);
@ -48,18 +45,14 @@ public class RedisScheduledTask {
    @Value("${ehr-redis.cache.memory.outFilePath}")
    private String outFilePath;
    // 生产环境服务器不允许代码直接通过SSH访问服务器,故暂时注释,另寻方法。
//    @Value("${ehr-redis.server.host}")
//    private String redisServerHost;
//    @Value("${ehr-redis.server.username}")
//    private String redisServerUsername;
//    @Value("${ehr-redis.server.password}")
//    private String redisServerPwd;
//    @Value("${ehr-redis.server.ssh-port}")
//    private int redisServerSshPort;
    private String redisServerHost = "";
    private String redisServerUsername = "";
    private String redisServerPwd = "";
    private int redisServerSshPort = 22;
    @Value("${ehr-redis.server.host}")
    private String redisServerHost;
    @Value("${ehr-redis.server.username}")
    private String redisServerUsername;
    @Value("${ehr-redis.server.password}")
    private String redisServerPwd;
    @Value("${ehr-redis.server.ssh-port}")
    private int redisServerSshPort;
    @Autowired
    private RedisCacheKeyMemoryService redisCacheKeyMemoryService;
@ -69,7 +62,6 @@ public class RedisScheduledTask {
    /**
     * 生成 Redis 快照
     */
//    @RequestMapping(value = "/redis/cache/statistics/backupRedis", method = RequestMethod.GET)
    @Scheduled(cron = "0 0 0 15 * ?")
    public void backupRedis() {
        redisTemplate.execute(new RedisCallback() {
@ -85,14 +77,13 @@ public class RedisScheduledTask {
    /**
     * 导出 redis 内存分析报告,并导入到数据库
     */
//    @RequestMapping(value = "/redis/cache/statistics/exportAndImportRedisMemoryData", method = RequestMethod.GET)
    @Scheduled(cron = "0 30 0 15 * ?")
    public void exportAndImportRedisMemoryData() {
        long start = System.currentTimeMillis();
        try {
            // 导出内存分析报告CSV文件(得到的内存值是近似值,比实际略小)
            // 生产环境服务器不允许代码直接通过SSH访问服务器,故暂时注释,另寻方法。
//            exportRedisMemoryReport();
            exportRedisMemoryReport();
            long export = System.currentTimeMillis();
            logger.info("成功导出Redis内存分析报告,耗时:" + (export - start) + " 毫秒");

+ 6 - 5
patient-co-manage/redis-cache/src/main/resources/application.yml

@ -43,9 +43,9 @@ spring:
      password: 123456
  redis:
    host: 172.19.103.47 # Redis server host.
    host: 172.19.103.88 # Redis server host.
    port: 6379
    password: redis!@456
    password:
fast-dfs:
  tracker-server: 172.19.103.13:22122
@ -57,13 +57,14 @@ ehr-redis:
      responseTimeChannel: redis.cache.reponse-time
  cache:
    memory:
      rdbFilePath: /usr/local/bin/dump.rdb
#      rdbFilePath: /usr/local/bin/dump.rdb
      rdbFilePath: /usr/local/redis/bin/dump.rdb
      outFilePath: /usr/local/ehr/redisReport/
      filename: memory.csv
  server:
    host: 172.19.103.47
    host: 172.19.103.88
    username: root
    password: jkzl
    password: ceshi
    ssh-port: 22
---
spring:

+ 2 - 1
patient-co-manage/redis-cache/src/main/webapp/WEB-INF/views/redis/cache/category/listJs.jsp

@ -112,10 +112,11 @@
        /*-- 与明细 Dialog 页面间回调的函数 --*/
        window.reloadMasterGrid = function() {
            reloadGrid();
        };
        window.closeDetailDialog = function (type, msg) {
            detailDialog.close();
            reloadGrid();
            msg && $.Notice.success(msg);
        };
    });

+ 5 - 0
patient-co-service/wlyy_device/pom.xml

@ -145,6 +145,11 @@
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>patient-co-wlyy</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>

+ 12 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/dao/DoctorSwitchDao.java

@ -0,0 +1,12 @@
package com.yihu.hos.device.common.dao;
import com.yihu.hos.device.model.DoctorSwitch;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2018/1/8.
 */
public interface DoctorSwitchDao extends PagingAndSortingRepository<DoctorSwitch, Long>, JpaSpecificationExecutor<DoctorSwitch> {
    public DoctorSwitch findByDoctor(String doctor);
}

+ 17 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/dao/TrackPatientDao.java

@ -0,0 +1,17 @@
package com.yihu.hos.device.common.dao;
import com.yihu.hos.device.model.TrackPatient;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2018/1/4.
 */
public interface TrackPatientDao extends PagingAndSortingRepository<TrackPatient, String>, JpaSpecificationExecutor<TrackPatient> {
    public TrackPatient findByDoctorCodeAndPatientCode(String doctorCode, String patientCode);
    public List<TrackPatient> findByDoctorCodeAndTeamCode(String doctorCode, Integer teamCode);
}

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

@ -0,0 +1,50 @@
package com.yihu.hos.device.model;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2018/1/4.
 */
@Entity
@Table(name = "wlyy_doctor_switch")
public class DoctorSwitch extends IdEntity{
    private String doctor;//关联医生
    private String alertPatientSwitch;//0不自动跟踪居民,1自动跟踪预警居民
    private Date createTime;//创建时间
    private Date updateTime;//更新时间
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getAlertPatientSwitch() {
        return alertPatientSwitch;
    }
    public void setAlertPatientSwitch(String alertPatientSwitch) {
        this.alertPatientSwitch = alertPatientSwitch;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

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

@ -0,0 +1,104 @@
package com.yihu.hos.device.model;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2018/1/4.
 */
@Entity
@Table(name = "wlyy_track_patient")
public class TrackPatient extends IdEntity {
    private String patientCode;//关联居民code,医生的重点关注对象
    private String patientName;//患者姓名
    private String doctorCode;//所属医生
    private String doctorName;//所属医生名
    private Integer teamCode;//居民签约团队
    private String idcard;//身份证号
    private String ssc;//社保卡号
    private String del;//1正常,0删除
    private Date createTime;//创建时间
    private Date updateTime;//更新时间
    public String getPatientCode() {
        return patientCode;
    }
    public void setPatientCode(String patientCode) {
        this.patientCode = patientCode;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public String getDoctorCode() {
        return doctorCode;
    }
    public void setDoctorCode(String doctorCode) {
        this.doctorCode = doctorCode;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public Integer getTeamCode() {
        return teamCode;
    }
    public void setTeamCode(Integer teamCode) {
        this.teamCode = teamCode;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getSsc() {
        return ssc;
    }
    public void setSsc(String ssc) {
        this.ssc = ssc;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

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

@ -16,6 +16,7 @@ import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -68,6 +69,12 @@ public class DeviceService {
    private ImUtill ImUtill;
    @Autowired
    private MessageService messageService;
    @Autowired
    private DoctorSwitchDao doctorSwitchDao;
    @Autowired
    private TrackPatientDao trackPatientDao;
    @Value("${systemConfig.server_url}")
    private String wlyyService;
    private ObjectMapper objectMapper = new ObjectMapper();
    private Integer aStart;
@ -511,6 +518,8 @@ public class DeviceService {
            //连续3次异常,修改用户为预警状态
            if( (bloodPressureBbnormalCount >=3 || bloodSuggurBbnormalCount >=3) && (patient.getStandardStatus() == null || 0 == patient.getStandardStatus())){
                patient.setStandardStatus(1);
                //1.4.2加入重点关注逻辑
                setTrackPatientByDoctor(patientCode);
            }else{
                Date end = new Date();
                Date start = DateUtil.setDateTime(end,-7);
@ -518,6 +527,8 @@ public class DeviceService {
                int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start,end,1,patientCode);
                if(errorCount >= 5){//超过5次,记为预警状态
                    patient.setStandardStatus(1);
                    //1.4.2加入重点关注逻辑
                    setTrackPatientByDoctor(patientCode);
                }
            }
@ -526,18 +537,26 @@ public class DeviceService {
                if("1".equals(patientdisease)){
                    if(0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                        patient.setStandardStatus(0);
                        //1.4.2加入重点关注逻辑
                        cancalTrackPatientByDoctor(patientCode);
                    }
                }else if("2".equals(patientdisease)){
                    if(0 == bloodSuggurBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                        patient.setStandardStatus(0);
                        //1.4.2加入重点关注逻辑
                        cancalTrackPatientByDoctor(patientCode);
                    }
                }else if( "1,2".equals(patientdisease) || "2,1".equals(patientdisease)){
                    if( 0 == bloodSuggurBbnormalCount && 0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                        patient.setStandardStatus(0);
                        //1.4.2加入重点关注逻辑
                        cancalTrackPatientByDoctor(patientCode);
                    }
                }
            }else{
                patient.setStandardStatus(0);
                //1.4.2加入重点关注逻辑
                cancalTrackPatientByDoctor(patientCode);
            }
            patientDao.save(patient);
@ -547,7 +566,134 @@ public class DeviceService {
        }
    }
    
    /**
     * 设置
     * @param patient
     * @return
     */
    public int setTrackPatientByDoctor(String patient){
        SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(patient);
        if(signFamily==null){
            return -1;
        }
        Patient p = patientDao.findByCode(patient);
        if(p==null){
            return -1;
        }
        //医生是否自动追踪居民
        DoctorSwitch sw =  doctorSwitchDao.findByDoctor(signFamily.getDoctor());
        DoctorSwitch swh =  doctorSwitchDao.findByDoctor(signFamily.getDoctorHealth());
        if(sw!=null){
            if("1".equals(sw.getAlertPatientSwitch())){
                //查询是否与医生建立重点跟踪关系,诺无关系则建立
                TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctor(),patient);
                if(trackPatient == null){
                    TrackPatient t = new TrackPatient();
                    t.setCreateTime(new Date());
                    t.setDoctorCode(signFamily.getDoctor());
                    t.setDoctorName(signFamily.getDoctorName());
                    t.setIdcard(signFamily.getIdcard());
                    t.setSsc(signFamily.getSsc());
                    t.setTeamCode(signFamily.getAdminTeamId().intValue());
                    t.setPatientCode(patient);
                    t.setPatientName(p.getName());
                    t.setDel("1");
                    trackPatientDao.save(t);
                }else{
                    trackPatient.setDel("1");
                    trackPatientDao.save(trackPatient);
                }
            }
        }
        if(swh!=null){
            if("1".equals(sw.getAlertPatientSwitch())){
                //查询是否与医生建立重点跟踪关系,诺无关系则建立
                TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctorHealth(),patient);
                if(trackPatient == null){
                    TrackPatient t = new TrackPatient();
                    t.setCreateTime(new Date());
                    t.setDoctorCode(signFamily.getDoctorHealth());
                    t.setDoctorName(signFamily.getDoctorHealthName());
                    t.setIdcard(signFamily.getIdcard());
                    t.setSsc(signFamily.getSsc());
                    t.setTeamCode(signFamily.getAdminTeamId().intValue());
                    t.setPatientCode(patient);
                    t.setPatientName(p.getName());
                    t.setDel("1");
                    trackPatientDao.save(t);
                }else{
                    trackPatient.setDel("1");
                    trackPatientDao.save(trackPatient);
                }
            }
        }
        return 1;
    }
    public int cancalTrackPatientByDoctor(String patient){
        SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(patient);
        if(signFamily==null){
            return -1;
        }
        Patient p = patientDao.findByCode(patient);
        if(p==null){
            return -1;
        }
        //医生是否自动追踪居民
        DoctorSwitch sw =  doctorSwitchDao.findByDoctor(signFamily.getDoctor());
        DoctorSwitch swh =  doctorSwitchDao.findByDoctor(signFamily.getDoctorHealth());
        if(sw!=null){
            if("1".equals(sw.getAlertPatientSwitch())){
                //查询是否与医生建立重点跟踪关系,诺无关系则建立
                TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctor(),patient);
                if(trackPatient == null){
                    TrackPatient t = new TrackPatient();
                    t.setCreateTime(new Date());
                    t.setDoctorCode(signFamily.getDoctor());
                    t.setDoctorName(signFamily.getDoctorName());
                    t.setIdcard(signFamily.getIdcard());
                    t.setSsc(signFamily.getSsc());
                    t.setTeamCode(signFamily.getAdminTeamId().intValue());
                    t.setPatientCode(patient);
                    t.setPatientName(p.getName());
                    t.setDel("0");
                    trackPatientDao.save(t);
                }else{
                    trackPatient.setDel("0");
                    trackPatientDao.save(trackPatient);
                }
            }
        }
        if(swh!=null){
            if("1".equals(sw.getAlertPatientSwitch())){
                //查询是否与医生建立重点跟踪关系,诺无关系则建立
                TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctorHealth(),patient);
                if(trackPatient == null){
                    TrackPatient t = new TrackPatient();
                    t.setCreateTime(new Date());
                    t.setDoctorCode(signFamily.getDoctorHealth());
                    t.setDoctorName(signFamily.getDoctorHealthName());
                    t.setIdcard(signFamily.getIdcard());
                    t.setSsc(signFamily.getSsc());
                    t.setTeamCode(signFamily.getAdminTeamId().intValue());
                    t.setPatientCode(patient);
                    t.setPatientName(p.getName());
                    t.setDel("0");
                    trackPatientDao.save(t);
                }else{
                    trackPatient.setDel("0");
                    trackPatientDao.save(trackPatient);
                }
            }
        }
        return 1;
    }
    /**
     * 保存设备数据
     */
@ -1007,4 +1153,96 @@ public class DeviceService {
        }
    }
    /******************************体征上传 start**************************************************/
    private String bloodSugarUnit = "mmol/L";
    private String bloodPressureUnit = "mmHg";
    private String pulseUnit = "bpm";
    private String heightUnit = "cm";
    private String weightUnit = "kg";
    private String bmiUnit = "kg/m^2";
    private String waistUnit = "cm";
    public void upload(PatientDevice patientDevice,PatientHealthIndex obj,String userType){
        com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
        if(patientDevice!=null){
            //未绑定居民
            Patient patient = patientDao.findByCode(patientDevice.getUser());
            json.put("idcard",patient.getIdcard());
            json.put("username",patient.getName());
            json.put("usercode",patient.getCode());
            json.put("device_name",patientDevice.getDeviceName());
            json.put("device_model",patientDevice.getDeviceName());
        }
        json.put("sn",obj.getDeviceSn());
        json.put("ext_code",userType);
        com.alibaba.fastjson.JSONArray jsonArray = new com.alibaba.fastjson.JSONArray();
        com.alibaba.fastjson.JSONObject js = new com.alibaba.fastjson.JSONObject();
        js.put("measure_time",obj.getRecordDate());
        switch (obj.getType()){
            case 1:
                //血糖
                js.put("blood_sugar",obj.getValue1());
                js.put("blood_sugar_unit",bloodSugarUnit);
                js.put("blood_sugar_result",obj.getValue2());
                break;
            case 2:
                //血压
                js.put("systolic",obj.getValue1());
                js.put("systolic_unit",bloodPressureUnit);
                js.put("diastolic",obj.getValue2());
                js.put("diastolic_unit",bloodPressureUnit);
                if(StringUtils.isNotBlank(obj.getValue3())){
                    js.put("pulse",obj.getValue3());
                    js.put("pulse_unit",pulseUnit);
                }
                break;
            case 3:
                //体重/身高/BMI
                js.put("height",obj.getValue1());
                js.put("height_unit",heightUnit);
                js.put("weight",obj.getValue2());
                js.put("weight_unit",weightUnit);
                if(StringUtils.isNotBlank(obj.getValue3())){
                    js.put("bmi",obj.getValue3());
                    js.put("bmi_unit",bmiUnit);
                }
                break;
            case 4:
                //腰围
                js.put("waist",obj.getValue1());
                js.put("waist_unit",waistUnit);
                break;
            default:
                break;
        }
        jsonArray.add(js);
        json.put("data",jsonArray);
        try {
            String url = wlyyService + "/iot/upload";
            Map<String, Object> params = new HashedMap();
            params.put("jsonStr", json.toString());
            HttpResponse response = httpHelper.post(url, params);
            if (response != null && response.getStatusCode() == 200) {
                JSONObject jsonObject = JSONObject.fromObject(response.getBody());
                if (!"200".equals(jsonObject.optString("status"))) {
                    throw new Exception(jsonObject.optString("msg"));
                }
            } else {
                throw new Exception("接口调用错误!" + response.getBody());
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    /******************************体征上传 end****************************************************/
}

+ 4 - 1
patient-co-service/wlyy_device/src/main/resources/application.yml

@ -59,6 +59,7 @@ systemConfig:
  msg_push_server: http://127.0.0.1:3000/system/sendmsg.im
  jw_server: http://172.19.103.87:8011/wlyy_service
  socket_server: http://192.168.131.102:3008
  server_url: http://192.168.131.24:8080/
# Specify the DBMS
---
@ -97,6 +98,7 @@ systemConfig:
  msg_push_server: http://127.0.0.1:3000/system/sendmsg.im
  jw_server: http://172.19.103.88:8011/wlyy_service-1.0-SNAPSHOT
  socket_server: http://172.19.103.88:3000
  server_url: http://ehr.yihu.com/wlyy/
---
spring:
  profiles: production
@ -131,4 +133,5 @@ healthStandard:
systemConfig:
  msg_push_server: http://127.0.0.1:3000/system/sendmsg.im
  jw_server: http://59.61.92.90:8072/wlyy_service
  socket_server: http://27.155.101.77:3000
  socket_server: http://27.155.101.77:3000
  server_url: http://www.yihu.com/wlyy/

Fichier diff supprimé car celui-ci est trop grand
+ 1 - 1
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java


+ 1 - 1
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java

@ -1250,7 +1250,7 @@ public class PrescriptionService extends ZysoftBaseService{
                String recipeNo = json.getString("recipeNo");//处方编号
            
                Prescription prescription = prescriptionDao.findByVisitNoAndRecipeNo(orderNo,recipeNo);
                if(prescription.getStatus().equals(PrescriptionLog.PrescriptionLogStatus.pay_success.getValue())){
                if(prescription.getStatus().equals(PrescriptionLog.PrescriptionLogStatus.wait_pay.getValue())){
                    if(2 == prescription.getDispensaryType()){//如果是快递配送,则直接修改成配送中
                        prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
                    } else{

+ 2 - 2
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/common/thread/LoadThread.java

@ -20,7 +20,7 @@ public class LoadThread implements Runnable {
    Integer morningHours = 6;
    //默认线程间隔
    Integer sleepTime = 600;
    Integer sleepTime = 180;
    @Override
    public void run() {
@ -51,7 +51,7 @@ public class LoadThread implements Runnable {
                            System.out.print(DateUtil.dateToStrLong(new Date()) + " 采集签约结束。\r\n");
                        }
                        Thread.sleep(sleepTime*1000);
                        Thread.sleep(sleepTime*1000);//间隔三分钟
                        continue;
                    }
                    else{

+ 1 - 1
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/SignZYService.java

@ -580,7 +580,7 @@ public class SignZYService {
                else{
                    boolean needSave = false;
                    //社保卡号(为空填值)
                    if(!StringUtil.isEmpty(patientCardNo) && StringUtil.isEmpty(patient.getSsc()))
                    if(!StringUtil.isEmpty(patientCardNo) && ( StringUtil.isEmpty(patient.getSsc()) || !patientCardNo.equals(patient.getSsc())))
                    {
                        patient.setSsc(patientCardNo);
                        needSave = true;

+ 97 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/SignToRenewJob.java

@ -0,0 +1,97 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyMapping;
import com.yihu.wlyy.entity.patient.SignFamilyRenewLog;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SignFamilyMappingDao;
import com.yihu.wlyy.repository.patient.SignFamilyRenewLogDao;
import com.yihu.wlyy.util.DateUtil;
import org.apache.commons.lang3.StringUtils;
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.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 处理家庭签约到期数据未迁移到续签表数据
 * Created by Reece on 2018/1/9/029.
 */
@Component
public class SignToRenewJob implements Job {
    @Autowired
    private SignFamilyRenewLogDao RenewLogDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private SignFamilyMappingDao mappingDao;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        System.out.println("SignToRenewJob start");
        try {
            //1.查询wlyy_sign_family有续签却未同步到wlyy_sign_family_renew_log数据(过滤掉已到期)
            List<SignFamily> totalSign = signFamilyDao.findRenew();
            for (SignFamily sign:totalSign) {
                String idcard = sign.getIdcard();
                if (idcard == null){
                    continue;
                }
                //2.根据身份证号查询最近的已到期签约数据
                SignFamily latelySign = signFamilyDao.findLatelyRenew(idcard);
                if (latelySign != null){
                    SignFamilyRenewLog renewLog = new SignFamilyRenewLog();
                    renewLog.setSignCode(sign.getCode());
//                    renewLog.setRenewSignCode();
                    renewLog.setIdcard(sign.getIdcard()) ;
                    renewLog.setHospital(sign.getHospital());
                    renewLog.setAdminTeamId(sign.getAdminTeamId());
                    renewLog.setDoctor(sign.getDoctor());
                    renewLog.setOldSignCode(latelySign.getSignDoctorCode());
                    renewLog.setOldHospital(latelySign.getHospital());
                    renewLog.setOldAdminTeamId(latelySign.getAdminTeamId());
                    renewLog.setOldDoctor(latelySign.getDoctor());
                    SignFamilyMapping signMapping = mappingDao.findByCode(sign.getCode());
                    if (signMapping != null){
                        String proId = signMapping.getProId();
                        if (StringUtils.isNotEmpty(proId)){
                            renewLog.setNeedUpload("0");
                        }else {
                            renewLog.setNeedUpload("1");
                        }
                        renewLog.setSignYear(signMapping.getSignYear());
                        renewLog.setRenewProId(signMapping.getRenewProId());
                        renewLog.setProId(signMapping.getProId());
                    }
                    SignFamilyMapping renewMapping = mappingDao.findByCode(latelySign.getCode());
                    if (renewMapping != null){
                        renewLog.setOldProId(renewMapping.getProId());
                    }
//                    renewLog.setUploadLog() ;
                    renewLog.setCreateTime(new Date());
                    renewLog.setUpdateTime(new Date());
                    renewLog.setStatus(sign.getStatus());
                    renewLog.setApplyDate(sign.getApplyDate());
                    renewLog.setRenewChangeReason(sign.getRenewChangeReason());
                    renewLog.setExpensesStatus(sign.getExpensesStatus());
                    renewLog.setPatient(sign.getPatient());
                    RenewLogDao.save(renewLog);
                }
            }
            System.out.println("SignToRenewJob end");
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("SignToRenewJob failed");
        }
    }
}

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

@ -422,4 +422,13 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
            " AND o.medical_time>?2 )ORDER BY t1.openid DESC,CONVERT(t1.NAME USING gbk) ",nativeQuery = true)
    List<SignFamily> findExaminationByHospital(String hospital,Date examinationTime);
    //查询wlyy_sign_family有续签却未同步到wlyy_sign_family_renew_log数据
    @Query(value = "SELECT f.* FROM wlyy_sign_family f LEFT JOIN wlyy_sign_family_renew_log r ON f.`code` = r.sign_code WHERE r.sign_code IS NULL  " +
            " AND f.renew_flag IN (1, 2) and f.`status`!=-4  ",nativeQuery = true)
    List<SignFamily> findRenew();
    //根据身份证号查询最近的已到期签约数据
    @Query(value = "SELECT f.* FROM wlyy_sign_family f WHERE f.idcard = ?1 and f.`status` = -4 ORDER BY sign_year desc LIMIT 0,1 ",nativeQuery = true)
    SignFamily findLatelyRenew(String idcard);
}

+ 5 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyMappingDao.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.SignFamilyMapping;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
@ -9,4 +10,8 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 */
public interface SignFamilyMappingDao extends PagingAndSortingRepository<SignFamilyMapping, Long>, JpaSpecificationExecutor<SignFamilyMapping> {
    //根据签约code查询映射数据
    @Query(value = "select a from SignFamilyMapping a where a.code = ?1 ")
    SignFamilyMapping findByCode(String code);
}

+ 17 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/quota/JobController.java

@ -729,4 +729,21 @@ public class JobController extends BaseController {
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    /**
     * 签约数据wlyy_sign_family清洗到续签表wlyy_sign_family_renew_log
     * @return
     */
    @RequestMapping(value = "startSignToRenewJob", method = RequestMethod.GET)
    @ApiOperation("签约续签数据清洗")
    public String startSignToRenewJob() {
        try {
            quartzHelper.startNow(SignToRenewJob.class, "SignToRenewJob", null);
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
}

+ 15 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/health/repository/DeviceDetailDao.java

@ -0,0 +1,15 @@
package com.yihu.wlyy.health.repository;
import com.yihu.device.entity.DeviceDetail;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2018/1/10.
 */
public interface DeviceDetailDao extends PagingAndSortingRepository<DeviceDetail, Long>, JpaSpecificationExecutor<DeviceDetail> {
    @Query(value = "select a.* from device.wlyy_devices a where a.device_code=?1 limit 0,1",nativeQuery = true)
    DeviceDetail findBySn(String sn);
}

+ 15 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/jkedu/repository/JkeduCategoryDao.java

@ -0,0 +1,15 @@
package com.yihu.wlyy.jkedu.repository;
import com.yihu.edu.entity.dataClean.NewArticleModel;
import com.yihu.edu.entity.dataClean.NewCategoryModel;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface JkeduCategoryDao
		extends PagingAndSortingRepository<NewCategoryModel, Long>, JpaSpecificationExecutor<NewCategoryModel> {
	@Query("select c from NewCategoryModel c where c.categoryLevel=?1 and c.categoryState=1")
	List<NewCategoryModel> findCategory(int level);
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/TrackPatientDao.java

@ -13,5 +13,5 @@ public interface TrackPatientDao extends PagingAndSortingRepository<TrackPatient
    public TrackPatient findByDoctorCodeAndPatientCode(String doctorCode,String patientCode);
    public List<TrackPatient> findByDoctorCodeAndTeamCode(String doctorCode,Integer teamCode);
    public List<TrackPatient> findByDoctorCodeAndTeamCodeAndDel(String doctorCode,Integer teamCode,String del);
}

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

@ -16,6 +16,6 @@ public interface PatientSchemeListDao extends
        JpaSpecificationExecutor<PatientSchemeList> {
    @Modifying
    @Query("delete PatientSchemeList where patientcode=?1 and type=?2 and schemecode=?3")
    void delByPatientCodeAndSchemeCode(String patientcode, int i, String code);
    @Query("delete PatientSchemeList where patientcode=?1 and type=?2")
    void delByPatientCode(String patientcode, int i);
}

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

@ -49,7 +49,7 @@ public interface DoctorTeamGuidanceTemplateDao extends PagingAndSortingRepositor
    // 根据模板文章标题模糊搜索团队指导模板
    @Query("SELECT b FROM DoctorTeamGuidanceDetail a, DoctorTeamGuidanceTemplate b WHERE a.code = b.teamTemplateCode  " +
            " AND b.del = 1 AND b.teamId = ?1 AND b.title LIKE ?2 order by b.useTimes desc  ")
    Page<DoctorTeamGuidanceTemplate> listByTile(int teamId, String owner, Pageable pageRequest);
            " AND b.del = 1 AND b.title LIKE ?1 order by b.useTimes desc  ")
    Page<DoctorTeamGuidanceTemplate> listByTile(String title, Pageable pageRequest);
}

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

@ -1,5 +1,6 @@
package com.yihu.wlyy.service.app.device;
import com.yihu.device.entity.DeviceDetail;
import com.yihu.wlyy.entity.device.Device;
import com.yihu.wlyy.entity.device.PatientBloodSugger;
import com.yihu.wlyy.entity.device.PatientDevice;
@ -7,6 +8,7 @@ import com.yihu.wlyy.entity.device.PatientHealthTime;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.health.repository.DeviceDetailDao;
import com.yihu.wlyy.repository.deviece.DeviceDao;
import com.yihu.wlyy.repository.deviece.PatientBloodSuggerDao;
import com.yihu.wlyy.repository.deviece.PatientHealthTimeDao;
@ -57,7 +59,8 @@ public class PatientDeviceService extends BaseService {
    @Autowired
    private DoctorAdminTeamMemberDao doctorAdminTeamMemberDao;
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    @Autowired
    private AdminTeamService adminTeamService;
    @Autowired
@ -76,6 +79,34 @@ public class PatientDeviceService extends BaseService {
    private String registerDevice = "DeviceGateway/DeviceApi/registerDevice";//注册设备
    /**
     * 验证sn码 先调总部接口 未注册才查询本地数据库,如果也没有才不能绑定
     * @param deviceSn
     * @return
     * @throws Exception
     */
    public Boolean checkDeviceSn(String deviceSn) throws Exception{
        Boolean flag = false;
        Map<String, String> params = new HashMap<>();
        params.put("deviceSn", deviceSn);
        //调用服务
        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)) {
            flag = true;
        } else {
            DeviceDetail deviceDetail = deviceDetailDao.findBySn(deviceSn);
            if(deviceDetail != null){
                flag = true;
            }
        }
        return flag;
    }
    /**
     * 保存患者设备
     */
@ -117,20 +148,26 @@ public class PatientDeviceService extends BaseService {
            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)) {
//            //注册设备
//            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);
//            }
            if(checkDeviceSn(sn)){
                patientDeviceDao.save(patientDevice);
            } else {
                String message = json.get("Message").toString();
            }else {
                String message = "设备不存在";
                throw new Exception(message);
            }

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java

@ -908,7 +908,7 @@ public class PatientHealthIndexService extends BaseService {
            }
    
            obj = patientHealthIndexDao.save(obj);
    
            //判断是否有未结束的续方咨询,发送消息给对应的医生
            sendPrescriptionHealthIndexMsgresult(obj,patient);
    

+ 21 - 10
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -133,7 +133,7 @@ public class SignPatientLabelInfoService extends BaseService {
        //预警状态
        json.put("standardStatus",p.getStandardStatus());
        //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
        json.put("deviceType",p.getDeviceType());
        json.put("deviceType",p.getDeviceType()==null?"":p.getDeviceType());
        SignFamily ssSign = signFamilyDao.findSignByPatient(patient, 1);
        SignFamily familySign = signFamilyDao.findSignByPatient(patient, 2);
@ -251,10 +251,9 @@ public class SignPatientLabelInfoService extends BaseService {
        //1.4.2 是否追踪居民健康体征
        if(StringUtils.isNotBlank(doctor)){
            String trackSql = "SELECT t.id FROM wlyy_track_patient t WHERE t,patient_code = '"+patient+"' AND t.doctor_code ='"+doctor+"'";
            List<Map<String,Object>> list = jdbcTemplate.queryForList(trackSql);
            if(list!=null&&list.size()>0){
                json.put("isTrack","1");
            TrackPatient tp = trackPatientDao.findByDoctorCodeAndPatientCode(doctor,patient);
            if(tp!=null){
                json.put("isTrack",tp.getDel());
            }else{
                json.put("isTrack","0");
            }
@ -262,10 +261,11 @@ public class SignPatientLabelInfoService extends BaseService {
        return json;
    }
    public String setTrackPatient(String patient,String doctor){
    public String setTrackPatient(String patient,String doctor,String state){
        TrackPatient tp  = trackPatientDao.findByDoctorCodeAndPatientCode(doctor,patient);
        if(tp!=null){
            trackPatientDao.delete(tp);
            tp.setDel(state);
            trackPatientDao.save(tp);
        }else{
            Doctor d = doctorDao.findByCode(doctor);
            Patient p = patientDao.findByCode(patient);
@ -277,6 +277,7 @@ public class SignPatientLabelInfoService extends BaseService {
            tkp.setPatientName(p.getName());
            tkp.setSsc(p.getSsc());
            tkp.setIdcard(p.getIdcard());
            tkp.setDel(state);
            String signSql = "SELECT f.admin_team_code FROM wlyy_sign_family f WHERE (f.doctor = '"+doctor+"' OR f.doctor_health ='"+doctor+"') AND f.patient = '"+patient+"' AND f.status >0 ";
            List<Map<String,Object>> list = jdbcTemplate.queryForList(signSql);
            if(list!=null&&list.size()>0){
@ -286,9 +287,19 @@ public class SignPatientLabelInfoService extends BaseService {
            }else{
                return "-1";
            }
            trackPatientDao.save(tkp);
        }
        return "1";
    }
    public String getTrackFlag(String patient,String doctor){
        TrackPatient tp  = trackPatientDao.findByDoctorCodeAndPatientCode(doctor,patient);
        if(tp!=null){
            return  tp.getDel();
        }else{
            return "0";
        }
    }
    /**
     * 根据标签查询患者信息
     *
@ -385,7 +396,7 @@ public class SignPatientLabelInfoService extends BaseService {
                    "  LEFT JOIN wlyy_patient p on p.code = t1.patient  "+
                    "  RIGHT JOIN wlyy_sign_patient_label_info t2 on t2.patient = t1.patient ";
            if(StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
                sql = sql +" JOIN wlyy_track_patient tp WHERE tp.patient_code = p.code";
                sql = sql +" JOIN wlyy_track_patient tp ON tp.patient_code = p.code";
            }
            sql = sql + " WHERE t2.label = ?";
@ -404,7 +415,7 @@ public class SignPatientLabelInfoService extends BaseService {
                sql += "  AND p.openid IS NOT NULL AND p.openid <>'' ";
            }
            if(StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
                sql = sql + " AND tp.doctor_code ='"+doctor+"' AND tp.team_code"+teamCode;
                sql = sql + " AND tp.del='1'  AND tp.doctor_code ='"+doctor+"' AND tp.team_code ="+teamCode;
            }
    
            sql = sql + " order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,t1.openid DESC ,convert(t1.name using gbk) ";
@ -1200,7 +1211,7 @@ public class SignPatientLabelInfoService extends BaseService {
                                "     AND t3.disease_condition = ? ";
                                //1.4.2新增重点居民跟踪过滤
                                if(StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
                                    sql = sql + " AND tp.doctor_code='"+doctor+"' AND tp.team_code ="+teamCode;
                                    sql = sql + " AND tp.del='1' AND tp.doctor_code='"+doctor+"' AND tp.team_code ="+teamCode;
                                }
                        if (teamCode > 0) {

+ 71 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionDispensaryCodeService.java

@ -8,6 +8,7 @@ import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.QrcodeUtil;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -46,13 +47,17 @@ public class PrescriptionDispensaryCodeService extends BaseService {
    private PrescriptionExpressageLogDao prescriptionExpressageLogDao;
    @Autowired
    private PrescriptionExpressageService prescriptionExpressageService;
    
    @Autowired
    private com.yihu.wlyy.util.CommonUtil CommonUtil;
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    @Value("${neiwang.enable}")
    private Boolean isneiwang = false;  //如果不是内网项目要转到到内网wlyy在上传
    private static Object obj = new Object();
    private static Object obj2 = new Object();
    @Value("${fastDFS.fastdfs_file_url}")
    String fastdfs_file_url;
    //获取居民端取药码列表
    public  JSONArray findByStatusAndTime(Integer timeType, String patientCode, Integer status, Integer page, Integer pagesize,Integer type) {
        // 分页信息
@ -172,12 +177,39 @@ public class PrescriptionDispensaryCodeService extends BaseService {
            }
        }
        // 生成二维码
//        InputStream ipt = QrcodeUtil.createQrcode(Base64.encode(code.getBytes()),300,"png");
        InputStream ipt = QrcodeUtil.createQrcode(code,300,"png");
        ObjectNode imgNode = FastDFSUtil.upload(ipt,"png","QRCode_"+System.currentTimeMillis());
//        Prescription类  取药类型:1 自取 2快递配送 3健管师配送
        String fileUrl = fastdfs_file_url + imgNode.get("groupName").toString().replaceAll("\"","")
                + "/" + imgNode.get("remoteFileName").toString().replaceAll("\"","");
    
        String fileUrl = "";
    
        if (isneiwang) {
            // 圖片列表
            List<String> tempPaths = new ArrayList<String>();
            try {
                ObjectNode imgNode = FastDFSUtil.upload(ipt,"png","QRCode_"+System.currentTimeMillis());
                com.alibaba.fastjson.JSONObject json = com.alibaba.fastjson.JSONObject.parseObject(imgNode.toString());
                tempPaths.add(json.getString("fid"));
                String urls = "";
                for (String image : tempPaths) {
                    if (urls.length() == 0) {
                        urls = image;
                    } else {
                        urls += "," + image;
                    }
                }
                fileUrl = fastdfs_file_url + urls;
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            try {
                fileUrl = fastdfs_file_url + CommonUtil.PrescriptionQRCodetoNeiWang(ipt);
            }catch (Exception e){
                e.printStackTrace();
            }
            
        }
        //新增居民处方取码记录
        PrescriptionDispensaryCode prescriptionDispensaryCode = new PrescriptionDispensaryCode();
@ -205,12 +237,39 @@ public class PrescriptionDispensaryCodeService extends BaseService {
        //String jgsID= "";//配送员用户ID后4位
//        String jgsCode = code+"1234";//code+jgsID.substring(jgsID.length()-4);
        // 生成二维码
//        InputStream ipt = QrcodeUtil.createQrcode(Base64.encode(jgsCode.getBytes()),300,"png");
        InputStream ipt = QrcodeUtil.createQrcode(jgsCode,300,"png");
        ObjectNode imgNode = FastDFSUtil.upload(ipt,"png","QRCode_"+System.currentTimeMillis());
        InputStream ipt = QrcodeUtil.createQrcode(code,300,"png");
//        Prescription类  取药类型:1 自取 2快递配送 3健管师配送
        String fileUrl = fastdfs_file_url + imgNode.get("groupName").toString().replaceAll("\"","")
                + "/" + imgNode.get("remoteFileName").toString().replaceAll("\"","");
    
        String fileUrl = "";
    
        if (isneiwang) {
            // 圖片列表
            List<String> tempPaths = new ArrayList<String>();
            try {
                ObjectNode imgNode = FastDFSUtil.upload(ipt,"png","QRCode_"+System.currentTimeMillis());
                com.alibaba.fastjson.JSONObject json = com.alibaba.fastjson.JSONObject.parseObject(imgNode.toString());
                tempPaths.add(json.getString("fid"));
                String urls = "";
                for (String image : tempPaths) {
                    if (urls.length() == 0) {
                        urls = image;
                    } else {
                        urls += "," + image;
                    }
                }
                fileUrl = fastdfs_file_url + urls;
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            try {
                fileUrl = fastdfs_file_url + CommonUtil.PrescriptionQRCodetoNeiWang(ipt);
            }catch (Exception e){
                e.printStackTrace();
            }
        
        }
        //新增配送员处方取码记录
        PrescriptionDispensaryCode prescriptionDispensaryCode = new PrescriptionDispensaryCode();
        prescriptionDispensaryCode.setCode(jgsCode);

+ 549 - 46
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java

@ -14,6 +14,7 @@ import com.yihu.wlyy.entity.patient.*;
import com.yihu.wlyy.entity.patient.vo.PatientVO;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.doctor.*;
import com.yihu.wlyy.repository.patient.PatientAimSportsDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.TrackPatientDao;
import com.yihu.wlyy.repository.patient.scheme.PatientSchemeListDao;
@ -43,6 +44,7 @@ import java.util.*;
 * @date 2017/9/13 15:46
 */
@Service
@Transactional
public class DoctorSchemeService extends BaseService{
    private static Logger logger = LoggerFactory.getLogger(DoctorSchemeService.class);
@ -79,6 +81,9 @@ public class DoctorSchemeService extends BaseService{
    @Autowired
    private TrackPatientDao trackPatientDao;
    @Autowired
    private PatientAimSportsDao patientAimSportsDao;
    @Value("${im.data_base_name}")
    private String im_dataBase_name;
@ -99,7 +104,7 @@ public class DoctorSchemeService extends BaseService{
        //1.4.2加入跟踪居民过滤
        if(StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
            sql = sql + " JOIN wlyy_track_patient tp ON tp.patientCode = p.code ";
            sql = sql + " JOIN wlyy_track_patient tp ON tp.patient_code = p.code ";
        }
        if(-1 != deviceType){
@ -136,7 +141,7 @@ public class DoctorSchemeService extends BaseService{
        //1.4.2加入跟踪居民过滤
        if(StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
            sql = sql + " AND pt.doctor_code = '"+doctorcode+"' AND pt.teamCode = "+teamCode;
            sql = sql + " AND tp.del='1' AND tp.doctor_code = '"+doctorcode+"' AND tp.team_code = "+teamCode;
        }
@ -392,7 +397,7 @@ public class DoctorSchemeService extends BaseService{
            try {
                for (String patientcode : patientcodeList) {
                    patientSchemeListDao.delByPatientCodeAndSchemeCode(patientcode, Integer.parseInt(type), schemecode);
                    patientSchemeListDao.delByPatientCode(patientcode, Integer.parseInt(type));
                    PatientSchemeList patientSchemeListObj = new PatientSchemeList();
                    patientSchemeListObj.setCode(UUID.randomUUID().toString());
                    patientSchemeListObj.setPatientcode(patientcode);
@ -564,7 +569,7 @@ public class DoctorSchemeService extends BaseService{
        }
        //1.4.2 重点关注居民
        List<TrackPatient> list = trackPatientDao.findByDoctorCodeAndTeamCode(doctorcode,Integer.parseInt(teamCode));
        List<TrackPatient> list = trackPatientDao.findByDoctorCodeAndTeamCodeAndDel(doctorcode,Integer.parseInt(teamCode),"1");
        if(list!=null&&list.size()>0){
            result.put("trackPatientCount",list.size());
        }else{
@ -737,13 +742,13 @@ public class DoctorSchemeService extends BaseService{
                rs.put("highCount",h.get("highCount"));
            }
            //2.正常
            List<Map<String,Object>> std = jdbcTemplate.queryForList(pStdSql);
            List<Map<String,Object>> std = jdbcTemplate.queryForList(stdSql);
            if(std!=null&&std.size()>0){
                Map<String,Object> st = std.get(0);
                rs.put("stdCount",st.get("stdCount"));
            }
            //3.偏低
            List<Map<String,Object>> low = jdbcTemplate.queryForList(pLowSql);
            List<Map<String,Object>> low = jdbcTemplate.queryForList(lowSql);
            if(low!=null&&low.size()>0){
                Map<String,Object> lw = low.get(0);
                rs.put("lowCount",lw.get("lowCount"));
@ -757,13 +762,13 @@ public class DoctorSchemeService extends BaseService{
                rs.put("highCount",h.get("highCount"));
            }
            //2.正常
            List<Map<String,Object>> std = jdbcTemplate.queryForList(stdSql);
            List<Map<String,Object>> std = jdbcTemplate.queryForList(pStdSql);
            if(std!=null&&std.size()>0){
                Map<String,Object> st = std.get(0);
                rs.put("stdCount",st.get("stdCount"));
            }
            //3.偏低
            List<Map<String,Object>> low = jdbcTemplate.queryForList(lowSql);
            List<Map<String,Object>> low = jdbcTemplate.queryForList(pLowSql);
            if(low!=null&&low.size()>0){
                Map<String,Object> lw = low.get(0);
                rs.put("lowCount",lw.get("lowCount"));
@ -792,7 +797,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 > 6.1 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " ) bf, " +
                " (  " +
                " SELECT " +
@ -806,7 +811,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 > 7.8 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " ) aft";
        String stdSql ="SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS stdCount " +
@ -824,7 +829,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 >= 3.9 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " ) bf, " +
                " (  " +
                " SELECT " +
@ -839,7 +844,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 >= 4.4 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " ) aft";
        String lowSql ="SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS lowCount " +
@ -856,7 +861,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 <= 3.9 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " ) bf, " +
                " (  " +
                " SELECT " +
@ -870,7 +875,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 <= 4.4 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" +
                " ) aft";
        String pHighSql ="SELECT " +
@ -883,7 +888,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 >= 139 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
        String  pStdSql ="SELECT " +
                " count(1) AS stdCount " +
                " FROM " +
@ -895,7 +900,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 >= 90 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
        String pLowSql ="SELECT " +
                " count(1) AS lowCount " +
                " FROM " +
@ -906,7 +911,7 @@ public class DoctorSchemeService extends BaseService{
                " AND i.value1 <= 90 " +
                " AND i.record_date >='"+startDate+"'" +
                " AND i.record_date <='"+endDate+"'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")";
        Map<String,Object> rs = new HashedMap();
        //0血檀
@ -918,13 +923,13 @@ public class DoctorSchemeService extends BaseService{
                rs.put("highCount",h.get("highCount"));
            }
            //2.正常
            List<Map<String,Object>> std = jdbcTemplate.queryForList(pStdSql);
            List<Map<String,Object>> std = jdbcTemplate.queryForList(stdSql);
            if(std!=null&&std.size()>0){
                Map<String,Object> st = std.get(0);
                rs.put("stdCount",st.get("stdCount"));
            }
            //3.偏低
            List<Map<String,Object>> low = jdbcTemplate.queryForList(pLowSql);
            List<Map<String,Object>> low = jdbcTemplate.queryForList(lowSql);
            if(low!=null&&low.size()>0){
                Map<String,Object> lw = low.get(0);
                rs.put("lowCount",lw.get("lowCount"));
@ -938,13 +943,13 @@ public class DoctorSchemeService extends BaseService{
                rs.put("highCount",h.get("highCount"));
            }
            //2.正常
            List<Map<String,Object>> std = jdbcTemplate.queryForList(stdSql);
            List<Map<String,Object>> std = jdbcTemplate.queryForList(pStdSql);
            if(std!=null&&std.size()>0){
                Map<String,Object> st = std.get(0);
                rs.put("stdCount",st.get("stdCount"));
            }
            //3.偏低
            List<Map<String,Object>> low = jdbcTemplate.queryForList(lowSql);
            List<Map<String,Object>> low = jdbcTemplate.queryForList(pLowSql);
            if(low!=null&&low.size()>0){
                Map<String,Object> lw = low.get(0);
                rs.put("lowCount",lw.get("lowCount"));
@ -972,16 +977,18 @@ public class DoctorSchemeService extends BaseService{
                " ORDER BY " +
                " i.record_date DESC LIMIT 1,1";
        String xtSchSql="SELECT " +
                " l.id " +
                " l.*," +
                " s.name " +
                " FROM " +
                " wlyy_patient_scheme_list l " +
                " wlyy_patient_scheme_list l JOIN wlyy_doctor_scheme_blood_sugger s ON s.code = l.schemecode  " +
                " WHERE " +
                " l.type = 1 " +
                " AND l.patientcode = '"+patient+"'";
        String xySchSql="SELECT " +
                " l.id " +
                " l.*," +
                " s.name " +
                " FROM " +
                " wlyy_patient_scheme_list l " +
                " wlyy_patient_scheme_list l JOIN wlyy_doctor_scheme_blood_pressure s ON s.code = l.schemecode" +
                " WHERE " +
                " l.type = 2 " +
                " AND l.patientcode = '"+patient+"'";
@ -996,16 +1003,16 @@ public class DoctorSchemeService extends BaseService{
        List<Map<String,Object>> xtList = jdbcTemplate.queryForList(xtSchSql);
        if(xtList!=null&&xtList.size()>0){
            rs.put("sugger","1");
            rs.put("sugger",xtList.get(0));
        }else{
            rs.put("sugger","0");
            rs.put("sugger",null);
        }
        List<Map<String,Object>> xyList = jdbcTemplate.queryForList(xySchSql);
        if(xyList!=null&&xyList.size()>0){
            rs.put("pressure","1");
            rs.put("pressure",xyList.get(0));
        }else{
            rs.put("pressure","0");
            rs.put("pressure",null);
        }
        return  rs;
@ -1017,8 +1024,10 @@ public class DoctorSchemeService extends BaseService{
        Map<String,Object> rs = new HashedMap();
        PatientAimBloodSugger patientAimBloodSugger =  patientAimBloodSuggerDao.findByPatientcode(patient);
        PatientAimBloodPressure patientAimBloodPressure = patientAimBloodPressureDao.findByPatientcode(patient);
        PatientAimSports patientAimSports = patientAimSportsDao.getPatientAimSportsByPatientCode(patient);
        rs.put("patientAimBloodSugger",patientAimBloodSugger);
        rs.put("patientAimBloodPressure",patientAimBloodPressure);
        rs.put("patientAimSports",patientAimSports);
        return rs;
    }
@ -1066,7 +1075,7 @@ public class DoctorSchemeService extends BaseService{
    }
    public Map<String,Object> getTrackPatientCountTitle(Integer teamCode,String doctor,String startDate,String endDate){
        List<TrackPatient> trackPatients = trackPatientDao.findByDoctorCodeAndTeamCode(doctor,teamCode);
        List<TrackPatient> trackPatients = trackPatientDao.findByDoctorCodeAndTeamCodeAndDel(doctor,teamCode,"1");
        Map<String,Object> rs = new HashedMap();
        rs.put("trackPatientCount",trackPatients.size());
        String sql = "SELECT " +
@ -1074,8 +1083,9 @@ public class DoctorSchemeService extends BaseService{
                " FROM " +
                " wlyy_track_patient t " +
                " WHERE " +
                " t.doctor_code = '"+doctor+"' " +
                " AND t.team_code = '"+teamCode+"' " +
                " t.del='1' " +
                " AND t.doctor_code = '"+doctor+"' " +
                " AND t.team_code = "+teamCode +
                " AND t.create_time >= '"+startDate+"' " +
                " AND t.create_time <= '"+endDate+"'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
@ -1089,7 +1099,7 @@ public class DoctorSchemeService extends BaseService{
    }
    public  Map<String,Object> getTrackPatientServerCount(Long teamCode,String patient,String doctor,String startDate,String endDate){
    public  Map<String,Object> getTrackPatientServerCount(Long teamCode,String doctor,String startDate,String endDate){
        startDate = startDate + " 00:00:00";
        endDate = endDate + " 23:59:59";
@ -1140,12 +1150,12 @@ public class DoctorSchemeService extends BaseService{
                " AND t.create_time >= '" + startDate + "' " +
                " AND t.create_time <= '" + endDate + "'" +
                " AND c.patient IN(" +
                "  SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+
                "  SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +id+
                " )" +
                " )c ON c.id = m.doctor_code " +
                " WHERE " +
                " m.team_id = "  + id+
                " m.doctor_code ='"+doctor+"'" ;
                " AND m.doctor_code ='"+doctor+"'" ;
        //获取咨詢數
        Map<String, Object> consultCout = jdbcTemplate.queryForMap(consult_sql);
        if (consultCout.get("consultCount") == null) {
@ -1157,7 +1167,7 @@ public class DoctorSchemeService extends BaseService{
    public Long getReservationByteam(Long id,String doctor, String startDate, String endDate) {
        //获取待预约
        String reservation_sql = "SELECT COUNT(1) AS reservationCount FROM wlyy_patient_reservation  w WHERE w.admin_team_code =" + id + " AND w.czrq <='" + endDate + "' AND w.czrq >='" + startDate + "' " +
                " AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
                " AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
        //获取待预约
        Map<String, Object> reservationCout = jdbcTemplate.queryForMap(reservation_sql);
        if (reservationCout.get("reservationCount") == null) {
@ -1169,7 +1179,7 @@ public class DoctorSchemeService extends BaseService{
    public Long getEduArticleByTeam(Long id,String doctor, String startDate, String endDate) {
        //获取健康教育
        String article_sql = "SELECT COUNT(1) AS articleCount FROM wlyy_health_edu_article_patient w WHERE  w.admin_team_code =" + id + " AND w.czrq <='" + endDate + "' AND w.czrq >='" + startDate + "'" +
                " AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
                " AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
        //获取健康教育
        Map<String, Object> articleCout = jdbcTemplate.queryForMap(article_sql);
        if (articleCout.get("articleCount") == null) {
@ -1181,7 +1191,7 @@ public class DoctorSchemeService extends BaseService{
    public Long getGuidanceByTeam(Long id,String doctor, String startDate, String endDate) {
        //获取健康指导
        String guidance_sql = "SELECT COUNT(1) AS guidanceCount  FROM wlyy_patient_health_guidance w WHERE w.admin_team_code =" + id + " AND w.czrq <='" + endDate + "' AND w.czrq >='" + startDate + "' " +
                " AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
                " AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
        //获取健康指导
        Map<String, Object> guidanceCout = jdbcTemplate.queryForMap(guidance_sql);
        if (guidanceCout.get("guidanceCount") == null) {
@ -1194,7 +1204,7 @@ public class DoctorSchemeService extends BaseService{
    public Long getFollowByTeam(Long id,String doctor, String startDate, String endDate) {
        //随访数目
        String followup_sql = "SELECT COUNT(1) AS followupCount from wlyy_followup w WHERE w.admin_team_code=" + id + " AND  w.create_time >='" + startDate + "' AND w.create_time<='" + endDate + "' " +
                " AND w.doctor_code ='"+doctor+"' AND w.patient_code IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
                " AND w.doctor_code ='"+doctor+"' AND w.patient_code IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") ";
        //随访数目
        Map<String, Object> followupCout = jdbcTemplate.queryForMap(followup_sql);
        if (followupCout.get("followupCount") == null) {
@ -1217,7 +1227,7 @@ public class DoctorSchemeService extends BaseService{
                " AND p.patient IN ( " +
                " SELECT t.patient_code " +
                " FROM wlyy_track_patient t " +
                " WHERE t.doctor_code ='"+doctor+"' " +
                " WHERE t.del='1' AND t.doctor_code ='"+doctor+"' " +
                " AND t.team_code = " +id+")";
        //审核数目
        Map<String, Object> reviewedCount = jdbcTemplate.queryForMap(sql);
@ -1243,7 +1253,7 @@ public class DoctorSchemeService extends BaseService{
                "    WHERE  " +
                "   i.`user` in  " +
                "    ( " +
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
                "    ) " +
                "  AND i.del ='1' " +
                "  AND i.type = 2  " +
@ -1263,7 +1273,7 @@ public class DoctorSchemeService extends BaseService{
                " WHERE " +
                "  i.`user` in  " +
                "    ( " +
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
                "    ) " +
                "  AND " +
                "  i.value1 <= p.sbp  " +
@ -1335,7 +1345,7 @@ public class DoctorSchemeService extends BaseService{
                "    WHERE  " +
                "   i.`user` in  " +
                "    ( " +
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
                "    ) " +
                "  AND i.del ='1' " +
                "  AND i.type = 1  " +
@ -1355,7 +1365,7 @@ public class DoctorSchemeService extends BaseService{
                " WHERE " +
                "  i.`user` in  " +
                "    ( " +
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
                "    ) " +
                "  AND " +
                "  i.value1 <= p.fbg  " +
@ -1380,7 +1390,8 @@ public class DoctorSchemeService extends BaseService{
                " wlyy_patient_device d JOIN  " +
                " wlyy_track_patient t ON t.patient_code = d.`user` " +
                " WHERE  " +
                " d.category_code = ? " +
                " t.del='1' " +
                " AND d.category_code = ? " +
                " AND t.doctor_code = '"+doctor+"' " +
                " AND t.team_code = "+teamCode;
        Map<String,Object> rs = new HashedMap();
@ -1401,23 +1412,515 @@ public class DoctorSchemeService extends BaseService{
        return rs;
    }
    public String setPatientAim(String patients ,String suggerJson,String presJson){
    public String setSinglePatientAim(String patient ,String suggerJson,String presJson,String sportJson ){
        PatientAimBloodSugger sugger = patientAimBloodSuggerDao.findByPatientcode(patient);
        if(sugger!=null){
            patientAimBloodSuggerDao.delete(sugger);
        }
        PatientAimBloodPressure pres = patientAimBloodPressureDao.findByPatientcode(patient);
        if(pres!=null){
            patientAimBloodPressureDao.delete(pres);
        }
        PatientAimSports sport = patientAimSportsDao.getPatientAimSportsByPatientCode(patient);
        if(sport!=null){
            patientAimSportsDao.delete(sport);
        }
        net.sf.json.JSONObject sj  = net.sf.json.JSONObject.fromObject(suggerJson);
        net.sf.json.JSONObject pj  = net.sf.json.JSONObject.fromObject(presJson);
        net.sf.json.JSONObject spj  = net.sf.json.JSONObject.fromObject(sportJson);
        PatientAimBloodSugger patientAimBloodSugger = (PatientAimBloodSugger)net.sf.json.JSONObject.toBean(sj,PatientAimBloodSugger.class);
        PatientAimBloodPressure patientAimBloodPressure = (PatientAimBloodPressure)net.sf.json.JSONObject.toBean(pj,PatientAimBloodPressure.class);
        PatientAimSports patientAimSports = (PatientAimSports)net.sf.json.JSONObject.toBean(spj,PatientAimSports.class);
        patientAimBloodSugger.setPatientcode(patient);
        patientAimBloodSugger.setCode(getCode());
        patientAimBloodSugger.setCreateTime(new Date());
        patientAimBloodSuggerDao.save(patientAimBloodSugger);
        patientAimBloodPressure.setPatientcode(patient);
        patientAimBloodPressure.setCode(getCode());
        patientAimBloodPressure.setCreateTime(new Date());
        patientAimBloodPressureDao.save(patientAimBloodPressure);
        patientAimSports.setPatientcode(patient);
        patientAimSports.setCode(getCode());
        patientAimSports.setCreateTime(new Date());
        patientAimSportsDao.save(patientAimSports);
        return "1";
    }
    public String setPatientAim(String patients ,String suggerJson,String presJson,String sportJson){
        if(StringUtils.isNotBlank(patients)){
            String[] patient = patients.split(",");
            for(String p : patient){
                PatientAimBloodSugger sugger = patientAimBloodSuggerDao.findByPatientcode(p);
                if(sugger!=null){
                    patientAimBloodSuggerDao.delete(sugger);
                }
                PatientAimBloodPressure pres = patientAimBloodPressureDao.findByPatientcode(p);
                if(pres!=null){
                    patientAimBloodPressureDao.delete(pres);
                }
                PatientAimSports sport = patientAimSportsDao.getPatientAimSportsByPatientCode(p);
                if(sport!=null){
                    patientAimSportsDao.delete(sport);
                }
                net.sf.json.JSONObject sj  = net.sf.json.JSONObject.fromObject(suggerJson);
                net.sf.json.JSONObject pj  = net.sf.json.JSONObject.fromObject(presJson);
                net.sf.json.JSONObject spj  = net.sf.json.JSONObject.fromObject(sportJson);
                PatientAimBloodSugger patientAimBloodSugger = (PatientAimBloodSugger)net.sf.json.JSONObject.toBean(sj,PatientAimBloodSugger.class);
                PatientAimBloodPressure patientAimBloodPressure = (PatientAimBloodPressure)net.sf.json.JSONObject.toBean(pj,PatientAimBloodPressure.class);
                PatientAimSports patientAimSports = (PatientAimSports)net.sf.json.JSONObject.toBean(spj,PatientAimSports.class);
                patientAimBloodSugger.setPatientcode(p);
                patientAimBloodSugger.setCode(getCode());
                patientAimBloodSugger.setCreateTime(new Date());
                patientAimBloodSuggerDao.save(patientAimBloodSugger);
                patientAimBloodPressure.setPatientcode(p);
                patientAimBloodPressure.setCode(getCode());
                patientAimBloodPressure.setCreateTime(new Date());
                patientAimBloodPressureDao.save(patientAimBloodPressure);
                patientAimSports.setPatientcode(p);
                patientAimSports.setCode(getCode());
                patientAimSports.setCreateTime(new Date());
                patientAimSportsDao.save(patientAimSports);
            }
        }
        return "0";
    }
    public List<Map<String,Object>> getPatientScheme(String patient,String type){
        String sql =null;
        if("1".equals(type)){
            sql =  "SELECT " +
                    " s.* " +
                    " FROM " +
                    " wlyy_patient_scheme_list l " +
                    " JOIN wlyy_doctor_scheme_blood_sugger s ON s. CODE = l.schemecode " +
                    " WHERE " +
                    " l.type = 1  " +
                    " AND l.patientcode='"+patient+"'" +
                    " ORDER BY s.dayofweek ASC";
        }else{
            sql =  "SELECT " +
                    " s.* " +
                    " FROM " +
                    " wlyy_patient_scheme_list l " +
                    " JOIN wlyy_doctor_scheme_blood_pressure s ON s. CODE = l.schemecode " +
                    " WHERE " +
                    " l.type = 2 " +
                    " AND l.patientcode='"+patient+"'" +
                    " ORDER BY s.dayofweek ASC";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    public List<Map<String,Object>> getTrackPatientIndexCountList(String doctor,Integer teamCode,String type,String startDate,String endDate,String keyword,Integer page,Integer size){
        startDate = startDate+" 00:00:00";
        endDate = endDate + " 23:59:59";
        // /血糖查询
        if("1".equals(type)){
            List<Map<String,Object>> list = jdbcTemplate.queryForList(getXTTrackPatientIndexCountListSql(doctor,teamCode,startDate,endDate,keyword, page, size));
            return list;
        }else{
            List<Map<String,Object>> list = jdbcTemplate.queryForList(getXYTrackPatientIndexCountListSql(doctor,teamCode,startDate,endDate,keyword, page, size));
            return list;
        }
    }
    public String getXTTrackPatientIndexCountListSql(String doctor,Integer teamCode,String startDate,String endDate,String keyword,Integer page,Integer size){
        String sql = "SELECT  " +
                " tt1.patient_code, " +
                " tt1.highCount, " +
                " tt2.lowCount, " +
                " tt3.stdCount, " +
                " p.`name`, " +
                " IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
                " p.photo, " +
                " p.idcard " +
                " FROM " +
                " " +
                "( " +
                " " +
                " SELECT " +
                " t1.patient_code, " +
                " t2.total + t1.total AS highCount " +
                " FROM " +
                " ( " +
                "  SELECT " +
                "   t.patient_code, " +
                "   IFNULL(pid.total, 0) AS total " +
                "  FROM " +
                "   ( " +
                "    SELECT " +
                "     tp.patient_code " +
                "    FROM " +
                "     wlyy_track_patient tp " +
                "    WHERE " +
                "     tp.del = '1' " +
                "    AND tp.doctor_code = '"+doctor+"' " +
                "    AND tp.team_code = " +teamCode+
                "   ) t " +
                "  LEFT JOIN ( " +
                "   SELECT " +
                "    i. USER, " +
                "    COUNT(1) AS total " +
                "   FROM " +
                "    device.wlyy_patient_health_index i " +
                "   WHERE " +
                "    i.del = '1' " +
                "   AND i.type = 1 " +
                "   AND i.value2 IN (2, 4, 6) " +
                "   AND i.value1 > 7.8 " +
                "   AND i.i.record_date >='"+startDate+"'" +
                "   AND i.i.record_date <='"+endDate+"'" +
                "   GROUP BY " +
                "    i. USER " +
                "  ) pid ON pid. USER = t.patient_code " +
                " ) t1  " +
                " " +
                " JOIN  " +
                " " +
                " ( " +
                " SELECT " +
                "  t.patient_code, " +
                "  IFNULL(pid.total, 0) AS total " +
                " FROM " +
                "  ( " +
                "   SELECT " +
                "    tp.patient_code " +
                "   FROM " +
                "    wlyy_track_patient tp " +
                "   WHERE " +
                "    tp.del = '1' " +
                "   AND tp.doctor_code = '"+doctor+"' " +
                "   AND tp.team_code =" +teamCode+
                "  ) t " +
                " LEFT JOIN ( " +
                "  SELECT " +
                "   i. USER, " +
                "   COUNT(1) AS total " +
                "  FROM " +
                "   device.wlyy_patient_health_index i " +
                "  WHERE " +
                "   i.del = '1' " +
                "  AND i.type = 1 " +
                "  AND i.value2 IN (1, 3, 5, 7) " +
                "  AND i.value1 > 6.1 " +
                "  AND i.i.record_date >='"+startDate+"'" +
                "  AND i.i.record_date <='"+endDate+"'" +
                "  GROUP BY " +
                "   i. USER " +
                " ) pid ON pid. USER = t.patient_code " +
                ") t2 ON t1.patient_code = t2.patient_code " +
                " " +
                ") tt1  " +
                " " +
                " JOIN  " +
                " " +
                "( " +
                "  SELECT " +
                " t1.patient_code, " +
                " t1.total + t2.total AS lowCount " +
                " FROM " +
                " ( " +
                "  SELECT " +
                "   t.patient_code, " +
                "   IFNULL(pid.total, 0) AS total " +
                "  FROM " +
                "   ( " +
                "    SELECT " +
                "     tp.patient_code " +
                "    FROM " +
                "     wlyy_track_patient tp " +
                "    WHERE " +
                "     tp.del = '1' " +
                "    AND tp.doctor_code = '"+doctor+"' " +
                "    AND tp.team_code =  " +teamCode+
                "   ) t " +
                "  LEFT JOIN ( " +
                "   SELECT " +
                "    i. USER, " +
                "    COUNT(1) AS total " +
                "   FROM " +
                "    device.wlyy_patient_health_index i " +
                "   WHERE " +
                "    i.del = '1' " +
                "   AND i.type = 1 " +
                "   AND i.value2 IN (2, 4, 6) " +
                "   AND i.value1 < 4.4 " +
                "  AND i.i.record_date >='"+startDate+"'" +
                "  AND i.i.record_date <='"+endDate+"'" +
                "   GROUP BY " +
                "    i. USER " +
                "  ) pid ON pid. USER = t.patient_code " +
                " ) t1  " +
                " " +
                " JOIN  " +
                " " +
                "( " +
                " SELECT " +
                "  t.patient_code, " +
                "  IFNULL(pid.total, 0) AS total " +
                " FROM " +
                "  ( " +
                "   SELECT " +
                "    tp.patient_code " +
                "   FROM " +
                "    wlyy_track_patient tp " +
                "   WHERE " +
                "    tp.del = '1' " +
                "   AND tp.doctor_code = '"+doctor+"' " +
                "   AND tp.team_code =  " +teamCode+
                "  ) t " +
                " LEFT JOIN ( " +
                "  SELECT " +
                "   i. USER, " +
                "   COUNT(1) AS total " +
                "  FROM " +
                "   device.wlyy_patient_health_index i " +
                "  WHERE " +
                "   i.del = '1' " +
                "  AND i.type = 1 " +
                "  AND i.value2 IN (1, 3, 5, 7) " +
                "  AND i.value1 < 3.9 " +
                "  AND i.i.record_date >='"+startDate+"'" +
                "  AND i.i.record_date <='"+endDate+"'" +
                "  GROUP BY " +
                "   i. USER " +
                " ) pid ON pid. USER = t.patient_code " +
                ") t2 ON t1.patient_code = t2.patient_code " +
                " " +
                ") tt2 ON tt1.patient_code = tt2.patient_code  " +
                " " +
                "JOIN  " +
                " " +
                "( " +
                "   " +
                " SELECT " +
                " t1.patient_code, " +
                " t1.total + t2.total AS stdCount " +
                " FROM " +
                " ( " +
                "  SELECT " +
                "   t.patient_code, " +
                "   IFNULL(pid.total, 0) AS total " +
                "  FROM " +
                "   ( " +
                "    SELECT " +
                "     tp.patient_code " +
                "    FROM " +
                "     wlyy_track_patient tp " +
                "    WHERE " +
                "     tp.del = '1' " +
                "    AND tp.doctor_code = '"+doctor+"' " +
                "    AND tp.team_code = " +teamCode +
                "   ) t " +
                "  LEFT JOIN ( " +
                "   SELECT " +
                "    i. USER, " +
                "    COUNT(1) AS total " +
                "   FROM " +
                "    device.wlyy_patient_health_index i " +
                "   WHERE " +
                "    i.del = '1' " +
                "   AND i.type = 1 " +
                "   AND i.value2 IN (2, 4, 6) " +
                "   AND i.value1 >= 4.4 " +
                "   AND i.value1 <= 7.8 " +
                "  AND i.i.record_date >='"+startDate+"'" +
                "  AND i.i.record_date <='"+endDate+"'" +
                "   GROUP BY " +
                "    i. USER " +
                "  ) pid ON pid. USER = t.patient_code " +
                " ) t1  " +
                " " +
                " JOIN  " +
                " " +
                " ( " +
                " SELECT " +
                "  t.patient_code, " +
                "  IFNULL(pid.total, 0) AS total " +
                " FROM " +
                "  ( " +
                "   SELECT " +
                "    tp.patient_code " +
                "   FROM " +
                "    wlyy_track_patient tp " +
                "   WHERE " +
                "    tp.del = '1' " +
                "   AND tp.doctor_code = '"+doctor+"' " +
                "   AND tp.team_code = " +teamCode+
                "  ) t " +
                " LEFT JOIN ( " +
                "  SELECT " +
                "   i. USER, " +
                "   COUNT(1) AS total " +
                "  FROM " +
                "   device.wlyy_patient_health_index i " +
                "  WHERE " +
                "   i.del = '1' " +
                "  AND i.type = 1 " +
                "  AND i.value2 IN (1, 3, 5, 7) " +
                "  AND i.value1 >= 3.9 " +
                "  AND i.value1 <= 6.1 " +
                "  AND i.i.record_date >='"+startDate+"'" +
                "  AND i.i.record_date <='"+endDate+"'" +
                "  GROUP BY " +
                "   i. USER " +
                " ) pid ON pid. USER = t.patient_code " +
                " ) t2 ON t1.patient_code = t2.patient_code " +
                " " +
                " )tt3 ON tt1.patient_code = tt3.patient_code " +
                " " +
                " JOIN wlyy_patient p On tt1.patient_code =p.code";
        if(StringUtils.isNotBlank(keyword)){
            Patient p = patientDao.findByIdcard(keyword);
            if(p!=null){
                sql =sql + " WHERE p.idcard ='"+keyword+"'";
            }else{
                sql =sql + " WHERE p.name like '%"+keyword+"%' ";
            }
        }
        sql += " ORDER BY highCount DESC LIMIT "+(page-1)*size+","+size;
        return sql ;
    }
    public String getXYTrackPatientIndexCountListSql(String doctor,Integer teamCode,String startDate,String endDate,String keyword,Integer page,Integer size){
        String sql ="SELECT  " +
                " t1.patient_code, " +
                " t1.total AS lowCount, " +
                " t2.total AS stdCount, " +
                " t3.total AS highCount, " +
                " p.`name`, " +
                " IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
                " p.photo " +
                " FROM " +
                " " +
                " ( " +
                "  SELECT " +
                "   t.patient_code, " +
                "   IFNULL(pid.total, 0) AS total " +
                "  FROM " +
                "   ( " +
                "    SELECT " +
                "     tp.patient_code " +
                "    FROM " +
                "     wlyy_track_patient tp " +
                "    WHERE " +
                "     tp.del = '1' " +
                "   AND tp.doctor_code = '"+doctor+"' " +
                "   AND tp.team_code = " +teamCode+
                "   ) t " +
                "  LEFT JOIN ( " +
                "   SELECT " +
                "    i. USER, " +
                "    COUNT(1) AS total " +
                "   FROM " +
                "    device.wlyy_patient_health_index i " +
                "   WHERE " +
                "    i.del = '1' " +
                "   AND i.type = 2 " +
                "   AND i.value1 < 90 " +
                "  AND i.i.record_date >='"+startDate+"'" +
                "  AND i.i.record_date <='"+endDate+"'" +
                "   GROUP BY " +
                "    i. USER " +
                "  ) pid ON pid. USER = t.patient_code " +
                " ) t1  " +
                " JOIN " +
                " ( " +
                "  SELECT " +
                "   t.patient_code, " +
                "   IFNULL(pid.total, 0) AS total " +
                "  FROM " +
                "   ( " +
                "    SELECT " +
                "     tp.patient_code " +
                "    FROM " +
                "     wlyy_track_patient tp " +
                "    WHERE " +
                "     tp.del = '1' " +
                "   AND tp.doctor_code = '"+doctor+"' " +
                "   AND tp.team_code = " +teamCode+
                "   ) t " +
                "  LEFT JOIN ( " +
                "   SELECT " +
                "    i. USER, " +
                "    COUNT(1) AS total " +
                "   FROM " +
                "    device.wlyy_patient_health_index i " +
                "   WHERE " +
                "    i.del = '1' " +
                "   AND i.type = 2 " +
                "   AND i.value1 >= 90 " +
                "   AND i.value1 <=139 " +
                "  AND i.i.record_date >='"+startDate+"'" +
                "  AND i.i.record_date <='"+endDate+"'" +
                "   GROUP BY " +
                "    i. USER " +
                "  ) pid ON pid. USER = t.patient_code " +
                "  " +
                " ) t2 ON t1.patient_code = t2.patient_code " +
                " JOIN  " +
                " ( " +
                "  SELECT " +
                "   t.patient_code, " +
                "   IFNULL(pid.total, 0) AS total " +
                "  FROM " +
                "   ( " +
                "    SELECT " +
                "     tp.patient_code " +
                "    FROM " +
                "     wlyy_track_patient tp " +
                "    WHERE " +
                "     tp.del = '1' " +
                "   AND tp.doctor_code = '"+doctor+"' " +
                "   AND tp.team_code = " +teamCode+
                "   ) t " +
                "  LEFT JOIN ( " +
                "   SELECT " +
                "    i. USER, " +
                "    COUNT(1) AS total " +
                "   FROM " +
                "    device.wlyy_patient_health_index i " +
                "   WHERE " +
                "    i.del = '1' " +
                "   AND i.type = 2 " +
                "   AND i.value1 >139 " +
                "  AND i.i.record_date >='"+startDate+"'" +
                "  AND i.i.record_date <='"+endDate+"'" +
                "   GROUP BY " +
                "    i. USER " +
                "  ) pid ON pid. USER = t.patient_code " +
                " ) t3 ON t1.patient_code = t3.patient_code " +
                " JOIN wlyy_patient p ON t1.patient_code = p.`code`";
        if(StringUtils.isNotBlank(keyword)){
            Patient p = patientDao.findByIdcard(keyword);
            if(p!=null){
                sql =sql + " WHERE p.idcard ='"+keyword+"'";
            }else{
                sql =sql + " WHERE p.name like '%"+keyword+"%' ";
            }
        }
        sql += " ORDER BY highCount DESC LIMIT "+(page-1)*size+","+size;
        return sql;
    }
}

+ 3 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -862,6 +862,7 @@ public class SignWebService extends BaseService {
        Long adminTeamId = null;
        String doctorHealth = null;
        String doctor = null;
        JSONObject resultObject = new JSONObject();
        //先查找续签表有没有记录
        List<SignFamilyRenew> renews = signFamilyRenewDao.findByTeamCodeIsValid(teamCode, code);
@ -888,6 +889,7 @@ public class SignWebService extends BaseService {
            adminTeamId = signFamily.getAdminTeamId();
            doctorHealth = signFamily.getDoctorHealth();
            doctor = signFamily.getDoctor();
            resultObject.put("expensesStatus", signFamily.getExpensesStatus());
        } else {
            SignFamilyRenew renew = renews.get(0);
@ -895,12 +897,9 @@ public class SignWebService extends BaseService {
            adminTeamId = renew.getAdminTeamId();
            doctorHealth = renew.getDoctorHealth();
            doctor = renew.getDoctor();
            resultObject.put("expensesStatus",renew.getExpensesStatus() );
        }
//        Patient p = patientService.findByCode(patientCode);
        JSONObject resultObject = new JSONObject();
        AdminTeam adminTeam = adminTeamService.getTeam(adminTeamId);
        //查找到团队领导
        Doctor leader = doctorService.findDoctorByCode(adminTeam.getLeaderCode());

+ 13 - 13
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/jimeiJkEdu/JMJkEduArticleService.java

@ -1221,20 +1221,20 @@ public class JMJkEduArticleService extends BaseService {
            heapm.setSendName(one.getSendName());
            heapm.setSendCode(one.getDoctorCode());
            heapm.setCreateTime(DateUtil.dateToStrLong(one.getCreateTime()));
            heapm.setArticleId(article.getString("articleId"));
            heapm.setAttachedTitle(article.getString("articleTitle"));
            heapm.setAttachedContent(article.getString("articleContent"));
            heapm.setArticleType(article.getString("articleType"));
            heapm.setLevel1Type(article.getString("firstLevelCategoryId"));
            heapm.setLevel2Type(article.getString("secondLevelCategoryId"));
            heapm.setLevel(article.getString("articlelevel"));
            heapm.setArticleId(article.containsKey("articleId")?article.getString("articleId"):"");
            heapm.setAttachedTitle(article.containsKey("articleTitle")?article.getString("articleTitle"):"");
            heapm.setAttachedContent(article.containsKey("articleContent")?article.getString("articleContent"):"");
            heapm.setArticleType(article.containsKey("articleType")?article.getString("articleType"):"");
            heapm.setLevel1Type(article.containsKey("firstLevelCategoryId")?article.getString("firstLevelCategoryId"):"");
            heapm.setLevel2Type(article.containsKey("secondLevelCategoryId")?article.getString("secondLevelCategoryId"):"");
            heapm.setLevel(article.containsKey("articlelevel")?article.getString("articlelevel"):"");
//            heapm.setAllCount(heapm.getAllCount() + one.getPatients().size());
            heapm.setBrowseNumbere(Integer.valueOf(article.getString("browseNumber")));//文章浏览数
            heapm.setCommentNumber(Integer.valueOf(article.getString("commentNumber")));//文章评论数
            heapm.setPointNumber(Integer.valueOf(article.getString("pointNumber")));//文章点赞数
            heapm.setArticleCover(article.getString("articleCover"));//封面
            heapm.setComputeTime(computeTime(article.getString("insertTime")));
            heapm.setOperatorName(article.getString("operatorName"));
            heapm.setBrowseNumbere(Integer.valueOf(article.containsKey("browseNumber")?article.getString("browseNumber"):"0"));//文章浏览数
            heapm.setCommentNumber(Integer.valueOf(article.containsKey("commentNumber")?article.getString("commentNumber"):"0"));//文章评论数
            heapm.setPointNumber(Integer.valueOf(article.containsKey("pointNumber")?article.getString("pointNumber"):"0"));//文章点赞数
            heapm.setArticleCover(article.containsKey("articleCover")?article.getString("articleCover"):"");//封面
            heapm.setComputeTime(article.containsKey("insertTime")?computeTime(article.getString("insertTime")):"");
            heapm.setOperatorName(article.containsKey("operatorName")?article.getString("operatorName"):"");
            heapm.setSendType(one.getSendType());//发送类型
            heapm.setIsread(String.valueOf(one.getIsRead()));//已读未读标识,1已读,2未读
            heapm.setLeaveWords(one.getLeaveWords());//医生留言

+ 4 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorGuidanceTempService.java

@ -261,7 +261,7 @@ public class DoctorGuidanceTempService extends BaseService {
     * @return
     * @throws Exception
     */
    public List<Map<String, Object>> listByTitle(String filter,String type, Integer teamId, int pageSize, int pageNo) throws Exception {
    public List<Map<String, Object>> listByTitle(String filter,String type, int pageSize, int pageNo) throws Exception {
        PageRequest pageRequest = new PageRequest(pageNo, pageSize);
        List<Map<String, Object>> listMap = new ArrayList<>();
@ -293,14 +293,15 @@ public class DoctorGuidanceTempService extends BaseService {
                tem.put("modelName", dgt.getModelName());
                listMap.add(tem);
            }
        } else if("3".equals(type) && teamId!=null){
            Page<DoctorTeamGuidanceTemplate> temps = doctorTeamGuidanceTemplateDao.listByTile(teamId,"%"+filter+"%", pageRequest);
        } else if("3".equals(type)){
            Page<DoctorTeamGuidanceTemplate> temps = doctorTeamGuidanceTemplateDao.listByTile("%"+filter+"%", pageRequest);
            List<DoctorTeamGuidanceTemplate> list = temps.getContent();
            for (int i = 0; i < list.size(); i++) {
                DoctorTeamGuidanceTemplate dgt = list.get(i);
                Map<String, Object> tem = new HashMap<>();
                tem.put("teamId", dgt.getTeamId());
                tem.put("teamName", dgt.getTeamName());
                tem.put("code", dgt.getTeamTemplateCode());
                tem.put("owner", dgt.getCreater());
                tem.put("sendTimes", dgt.getUseTimes());

+ 95 - 10
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/iot/IotDeviceService.java

@ -1,7 +1,11 @@
package com.yihu.wlyy.service.third.iot;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
@ -18,13 +22,92 @@ import java.util.List;
public class IotDeviceService {
//    @Value("${}")
    private String baseUrl = "https://iot.xmtyw.cn/";
    private String grantType = "client_credentials&";
    private String clientId = "Va5yQRHlA4Fq4eR3LT0vuXV4&";
    private String baseUrl = "http://192.168.131.24:8080/svr-iot/";
    private String grantType = "client_credentials";
    private String clientId = "Va5yQRHlA4Fq4eR3LT0vuXV4";
    private String clientSecret = "0rDSjzQ20XUj5itV7WRtznPQSzr5pVw2";
    private String dataSource = "iHealth";
    private String accessToken = "test";
    private String bloodSugarUnit = "mmol/L";
    private String bloodPressureUnit = "mmHg";
    private String pulseUnit = "bpm";
    private String heightUnit = "cm";
    private String weightUnit = "kg";
    private String bmiUnit = "kg/m^2";
    private String waistUnit = "cm";
    @Autowired
    private HttpClientUtil httpClientUtil;
    private String accessToken = "";
    /**
     * 将上传数据转换成标准的json传
     * @param obj
     * @param userType
     * @return
     */
    public DevicePatientHealthIndex upload(DevicePatientHealthIndex obj,String userType,String deviceName,String deviceModel,Patient patient){
        JSONObject json = new JSONObject();
        json.put("sn",obj.getDeviceSn());
        json.put("ext_code",userType);
        json.put("device_name",deviceName);
        json.put("device_model",deviceModel);
        json.put("idcard",patient.getIdcard());
        json.put("username",patient.getName());
        json.put("usercode",patient.getCode());
        JSONArray jsonArray = new JSONArray();
        JSONObject js = new JSONObject();
        js.put("measure_time",obj.getRecordDate());
        switch (obj.getType()){
            case 1:
                //血糖
                js.put("blood_sugar",obj.getValue1());
                js.put("blood_sugar_unit",bloodSugarUnit);
                js.put("blood_sugar_result",obj.getValue2());
                break;
            case 2:
                //血压
                js.put("systolic",obj.getValue1());
                js.put("systolic_unit",bloodPressureUnit);
                js.put("diastolic",obj.getValue2());
                js.put("diastolic_unit",bloodPressureUnit);
                if(StringUtils.isNotBlank(obj.getValue3())){
                    js.put("pulse",obj.getValue3());
                    js.put("pulse_unit",pulseUnit);
                }
                break;
            case 3:
                //体重/身高/BMI
                js.put("height",obj.getValue1());
                js.put("height_unit",heightUnit);
                js.put("weight",obj.getValue2());
                js.put("weight_unit",weightUnit);
                if(StringUtils.isNotBlank(obj.getValue3())){
                    js.put("bmi",obj.getValue3());
                    js.put("bmi_unit",bmiUnit);
                }
                break;
            case 4:
                //腰围
                js.put("waist",obj.getValue1());
                js.put("waist_unit",waistUnit);
                break;
            default:
                break;
        }
        jsonArray.add(js);
        json.put("data",jsonArray);
        //上传
        String response = upload(json);
        JSONObject re = JSONObject.parseObject(response);
        String errorMsg = re.getString("errorMsg");//错误信息(请求失败才有错误消息)
        String successMsg = re.getString("successMsg");//成功信息(请求成功才有成功消息)
        if(StringUtils.isBlank(errorMsg)){
            re.getJSONObject("obj").getString("id");
        }
        return obj;
    }
    public String getAccessToken(){
@ -44,7 +127,8 @@ public class IotDeviceService {
     */
    public String registedevice(JSONObject json){
        json.put("access_token",accessToken);
        String url = baseUrl+"/registedevice";
        json.put("data_source",dataSource);
        String url = baseUrl+"/dataInput/userBind";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("json",json.toString()));
        String response = httpClientUtil.post(url, params, "UTF-8");
@ -58,11 +142,12 @@ public class IotDeviceService {
     */
    public String upload(JSONObject json){
        json.put("access_token",accessToken);
        String url = baseUrl+"/upload";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("json",json.toString()));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return null;
        json.put("data_source",dataSource);
        String url = baseUrl+"/dataInput/input";
        org.json.JSONObject params = new org.json.JSONObject();
        params.put("json_data",json.toString());
        String response = httpClientUtil.postBody(url, params);
        return response;
    }
    /**

+ 23 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java

@ -590,4 +590,27 @@ public class CommonUtil {
        System.out.println("aaa,aaa,".substring(0,"aaa,aaa,".length()-2));
    }
    
    
    /**
     * 长处方生成取药码,生成取药二维码
     * 如果是外网那是发送到内网的服务器
     * @param ipt
     * @return
     */
    public String PrescriptionQRCodetoNeiWang(InputStream ipt) throws FileNotFoundException {
        String filename = "QRCode_"+System.currentTimeMillis();
        String fileUrls = "";
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        String returnStr = request(request, ipt,filename );
        logger.info("returnStr :" + returnStr);
        logger.info("fileName :" + filename);
        logger.info("result :" + returnStr.toString());
        if (returnStr != null) {
            //1.3.7去掉前缀
            fileUrls += returnStr+",";
        }
        
        return fileUrls.substring(0,fileUrls.length()-1);
    }
}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/FileUploadController.java

@ -577,8 +577,8 @@ public class FileUploadController extends BaseController {
                return error(-1, "上传失败");
            }
        } else {
            String result  = CommonUtil.toNeiWang(request, response);
            logger.info("fastDFSImag reslt :" + result);
//            String result  = CommonUtil.toNeiWang(request, response);
//            logger.info("fastDFSImag reslt :" + result);
            return CommonUtil.toNeiWang(request, response);
        }
    }

+ 27 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandlingController.java

@ -1,9 +1,7 @@
package com.yihu.wlyy.web.data;
import com.yihu.wlyy.entity.organization.HospitalDept;
import com.yihu.wlyy.service.app.consult.ConsultTeamService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.third.jkedu.service.EduArticleService;
import io.swagger.annotations.Api;
@ -11,7 +9,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -166,7 +163,6 @@ public class DataHandlingController extends BaseController {
        }
    }
    @RequestMapping(value = "/getArticleSendToEsByDoctor", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("根据医生去把Mysql数据抽到区ES数据")
@ -183,4 +179,31 @@ public class DataHandlingController extends BaseController {
        return write(200, "数据更新成功!","data",flag);
    }
    @RequestMapping(value = "/deleteEsOldArticlePateint",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("删除Es里转移过去的文章发送记录")
    public String deleteEsOldArticlePatient(){
        Map<String, Object> flag = null;
        try {
            flag = eduArticleService.deleteEsOldArticlePatient();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return write(200, "数据更新成功!","data",flag);
    }
    @RequestMapping(value = "/addBatchNo",method = RequestMethod.GET)
    @ResponseBody
    @Deprecated
    @ApiOperation("给空的batchNo赋值")
    public String addBatchNo(String doctor){
        Map<String, Object> flag = null;
        try {
            flag = eduArticleService.addBatchNo(doctor);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return write(200, "数据更新成功!","data",flag);
    }
}

+ 18 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -137,17 +137,32 @@ public class SignPatientLabelInfoController extends BaseController {
        }
    }
    @RequestMapping(value = "/getTrackFlag", method = RequestMethod.POST)
    @ApiOperation("获取重点关注居民状态")
    public String getTrackFlag(@ApiParam(name="patient",value="患者Code")@RequestParam(required = true)String patient){
        try {
            String rs =  labelInfoService.getTrackFlag(patient,getUID());
            return write(200, "查询成功", "data", rs);
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value = "/setTrackPatient", method = RequestMethod.POST)
    @ApiOperation("设置居民重点关注")
    public String setTrackPatient(@ApiParam(name="patient",value="患者Code")@RequestParam(required = false)String patient){
    @ObserverRequired
    public String setTrackPatient(@ApiParam(name="patient",value="患者Code")@RequestParam(required = true)String patient,
                                  @ApiParam(name="state",value="1开启,0删除")@RequestParam(required = true)String state){
        try {
            String rs =  labelInfoService.setTrackPatient(patient,getUID());
            String rs =  labelInfoService.setTrackPatient(patient,getUID(),state);
            if("-1".equals(rs)){
                return error(-1, "查询失败,未找到签约关系");
            }
            return write(200, "查询成功", "data", rs);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -864,7 +879,7 @@ public class SignPatientLabelInfoController extends BaseController {
            @ApiParam(name="startdate", value="体征数据开始时间yyyy-mm-dd hh:mm:ss") @RequestParam(value = "startdate",required = false,defaultValue = "2017-9-10 00:00:00")  String startdate,
            @ApiParam(name="enddate", value="体征数据结束时间yyyy-mm-dd hh:mm:ss") @RequestParam(value = "enddate",required = false,defaultValue = "2017-9-16 23:59:59")  String enddate){
        try {
            com.alibaba.fastjson.JSONObject result = doctorSchemeService.getSlowDiseaseTeaminfos(teamCode,getcolor,getstands,gethealthindex,startdate,enddate,getUID());
            com.alibaba.fastjson.JSONObject result = doctorSchemeService.getSlowDiseaseTeaminfos(teamCode,getcolor,getstands,gethealthindex,startdate,enddate,"xh1D2017031503333");
            return write(200, "查询成功", "data", result);
        }catch (Exception e){
            //日志文件中记录异常信息

+ 34 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/scheme/DoctroSchemeController.java

@ -209,7 +209,7 @@ public class DoctroSchemeController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value="setDoctorSwitchTrackPatient",method = RequestMethod.GET)
    @RequestMapping(value="setDoctorSwitchTrackPatient",method = RequestMethod.POST)
    @ApiOperation("医生跟踪预警居民开关接口")
    @ObserverRequired
    public String setDoctorSwitchTrackPatient(@ApiParam(name="state", value="0不自动跟踪居民,1自动跟踪预警居民") @RequestParam(value = "state",required = true)String state){
@ -252,11 +252,10 @@ public class DoctroSchemeController extends BaseController {
    @RequestMapping(value="getTrackPatientServerCount",method = RequestMethod.GET)
    @ApiOperation("团队医生下,居民近一周服务情况接口")
    public String getTrackPatientServerCount(@ApiParam(name="teamCode", value="团队ID") @RequestParam(value = "teamCode",required = true)Long teamCode,
                                             @ApiParam(name="patient", value="居民Code") @RequestParam(value = "patient",required = true)String patient,
                                             @ApiParam(name="startDate", value="开始时间") @RequestParam(value = "startDate",required = true)String startDate,
                                             @ApiParam(name="endDate", value="结束时间") @RequestParam(value = "endDate",required = true)String endDate){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getTrackPatientServerCount(teamCode,patient,getUID(),startDate,endDate));
            return write(200, "查询成功", "data",doctorSchemeService.getTrackPatientServerCount(teamCode,getUID(),startDate,endDate));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
@ -266,8 +265,7 @@ public class DoctroSchemeController extends BaseController {
    @RequestMapping(value="getPatientHealthIndexByTeam",method = RequestMethod.GET)
    @ApiOperation("获取医生团队最近一周血糖情况/血压情况")
    public String getPatientHealthIndexByTeam(@ApiParam(name="patient", value="居民code") @RequestParam(value = "patient",required = true) String patient,
                                        @ApiParam(name="startDate", value="开始时间,YYYY-MM-dd") @RequestParam(value = "startDate",required = true)String startDate,
    public String getPatientHealthIndexByTeam(@ApiParam(name="startDate", value="开始时间,YYYY-MM-dd") @RequestParam(value = "startDate",required = true)String startDate,
                                        @ApiParam(name="endDate", value="结束时间,YYYY-MM-dd") @RequestParam(value = "endDate",required = true)String endDate,
                                        @ApiParam(name="type", value="0血糖,1.血压") @RequestParam(value = "type",required = true)String type,
                                        @ApiParam(name="teamCode", value="团队code") @RequestParam(value = "teamCode",required = true)Long teamCode){
@ -305,13 +303,15 @@ public class DoctroSchemeController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value="setPatientAim",method = RequestMethod.GET)
    @RequestMapping(value="setPatientAim",method = RequestMethod.POST)
    @ApiOperation("批量控制目标设置")
    @ObserverRequired
    public String setPatientAim(@ApiParam(name="patient", value="患者code,用“,”分割") @RequestParam(value = "patient",required = true)String patient,
                                @ApiParam(name="suggerJson", value="血糖目标实体") @RequestParam(value = "suggerJson",required = true)String suggerJson,
                                @ApiParam(name="pressureJson", value="血压目标实体") @RequestParam(value = "pressureJson",required = true)String pressureJson){
                                @ApiParam(name="pressureJson", value="血压目标实体") @RequestParam(value = "pressureJson",required = true)String pressureJson,
                                @ApiParam(name="sportJson", value="运动目标实体") @RequestParam(value = "sportJson",required = true)String sportJson){
        try {
            return write(200, "操作成功", "data",doctorSchemeService.setPatientAim(patient,suggerJson,pressureJson));
            return write(200, "操作成功", "data",doctorSchemeService.setPatientAim(patient,suggerJson,pressureJson,sportJson));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
@ -319,5 +319,31 @@ public class DoctroSchemeController extends BaseController {
        }
    }
    @RequestMapping(value="setSinglePatientAim",method = RequestMethod.POST)
    @ApiOperation("批量控制目标设置")
    @ObserverRequired
    public String setSinglePatientAim(@ApiParam(name="patient", value="患者code") @RequestParam(value = "patient",required = true)String patient,
                                      @ApiParam(name="suggerJson", value="血糖目标实体") @RequestParam(value = "suggerJson",required = true)String suggerJson,
                                      @ApiParam(name="pressureJson", value="血压目标实体") @RequestParam(value = "pressureJson",required = true)String pressureJson,
                                      @ApiParam(name="sportJson", value="运动目标实体") @RequestParam(value = "sportJson",required = true)String sportJson){
        try {
            return write(200, "操作成功", "data",doctorSchemeService.setSinglePatientAim(patient,suggerJson,pressureJson,sportJson));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "操作失败");
        }
    }
    @RequestMapping(value="getTrackPatientIndexCountList",method = RequestMethod.GET)
    @ApiOperation("获取关注居民测量数据列表")
    public String getTrackPatientIndexCountList(Integer teamCode,String type,String startDate,String endDate,String keyword,Integer page,Integer size){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getTrackPatientIndexCountList(getUID(), teamCode, type, startDate, endDate, keyword, page, size));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "查询失败");
        }
    }
}

+ 1 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorGuidanceTempController.java

@ -207,8 +207,6 @@ public class DoctorGuidanceTempController extends BaseController {
                        @ApiParam(value = "搜索关键字") String filter,
                        @RequestParam(required = true, defaultValue = "")
                        @ApiParam(value = "模板类型 1:系统 2:个人 3:团队摸版") String type,
                        @RequestParam(required = false)
                        @ApiParam(value = "3:团队摸版时 团队ID") Integer teamId,
                        @RequestParam(defaultValue = "10")
                        @ApiParam(value = "页展示数量") String pageSize,
                        @RequestParam(defaultValue = "1") @ApiParam(value = "当前页码") String pageNo) {
@ -217,7 +215,7 @@ public class DoctorGuidanceTempController extends BaseController {
            int pageno = Integer.parseInt(pageNo) - 1;
            List<Map<String, Object>> temps = null;
            if (StringUtils.isNotEmpty(type) && StringUtils.isNotEmpty(filter)){
                temps = guidanceTempService.listByTitle(filter,type,teamId,pagesize, pageno);
                temps = guidanceTempService.listByTitle(filter,type,pagesize, pageno);
            }else {
                return error(-1, "模板类型不能为空!");
            }

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -779,6 +779,7 @@ public class PatientController extends WeixinBaseController {
                json.put("street", temp.getStreet());        // 设置街道
                json.put("streetName", temp.getStreetName());// 设置街道名称
                json.put("address", temp.getAddress());// 设置地址
                json.put("medicareNumber",temp.getMedicareNumber());
                return write(200, "患者信息查询成功!", "data", json);
            } else {
                return error(-1, "患者信息查询失败!");

+ 27 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/booking/PatientBookingController.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.web.patient.booking;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientReservation;
import com.yihu.wlyy.service.app.reservation.PatientReservationService;
@ -129,4 +130,30 @@ public class PatientBookingController extends WeixinBaseController{
            return error(-1, e.getMessage());
        }
    }
    
    //-----------------计划免疫预约相关接口--------------START
    
    @RequestMapping(value = "getChildrenInfo", method = RequestMethod.POST)
    @ResponseBody
    @ObserverRequired
    @ApiOperation("根据条形编码获取儿童信息")
    public String getChildrenInfo (@ApiParam(name = "barCode", value = "条形编码", defaultValue = "")
                                   @RequestParam(value = "barCode", required = true) String barCode){
    
        try{
            return "";
//            String
////            PatientReservation obj = patientReservationService.findById(orderId);
//            if(obj != null){
//
//            }else{
//                return error(-1, "该条码对应的儿童信息不存在");
//            }
        }catch (Exception e){
            error(e);
            return error(-1, e.getMessage());
        }
    }
    
    //-----------------计划免疫预约相关接口--------------END
}

+ 19 - 15
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java

@ -123,22 +123,26 @@ public class PatientDeviceController extends BaseController {
                        throw new Exception("sn码" + newDeviceSN + "已被使用!");
                    }
                    //注册设备
                    Map<String, String> params = new HashMap<>();
                    params.put("deviceSn", newDeviceSN);
                    //调用服务
                    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)) {
                    } else {
                        String message = json.get("Message").toString();
                        return error(-1,message);
                    if(!patientDeviceService.checkDeviceSn(newDeviceSN)){
                        return error(-1,"设备不存在");
                    }
//                    //注册设备
//                    Map<String, String> params = new HashMap<>();
//                    params.put("deviceSn", newDeviceSN);
//
//                    //调用服务
//                    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)) {
//
//                    } else {
//                        String message = json.get("Message").toString();
//                        return error(-1,message);
//                    }
                }
                if ("1".equals(categoryCode)) {
//                        先修改患者设备绑定表

+ 34 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/family/FamilyMemberController.java

@ -204,7 +204,12 @@ public class FamilyMemberController extends WeixinBaseController {
            } else  {
                result = familyMemberService.getPatientFamilyMembers(getUID(), "",null);
            }
            return write(200, "查询成功", "data", result);
            
            JSONObject data = new JSONObject();
            data.put("normalmembers",result);//家人关系
            data.put("immunemembers","");//免疫关系
            
            return write(200, "查询成功", "data", data);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
@ -456,4 +461,32 @@ public class FamilyMemberController extends WeixinBaseController {
        String loginPassword = MD5.GetMD5Code(pw + "1");
        return write(200,loginPassword);
    }
    
    @RequestMapping(value = "/addImmuneMenberByBarCode", method = RequestMethod.POST)
    @ApiOperation(value = "根据儿童编码绑定家人免疫关系")
    public String addImmuneMenberByBarCode(@ApiParam(name = "barCode", value = "条形编码", defaultValue = "")
                                        @RequestParam(value = "barCode", required = true) String barCode){
        try {
            
            int result = 0;
            
            if(result==0){
                return error(-1, "不能添加自己");
            }else if(result==-1){
                return error(-1, "居民信息查询失败");
            }else if(result==-2){
                return error(-1, "该成员未注册");
            }else if (result == -4) {
                return error(-1, "该家庭成员已存在");
            }else if(result==-5){
                return error(-1, "该家庭关系已存在成员");
            }else if(result ==2) {
                return write(200, "拒绝成功");
            }else{
                return write(200, "添加成功");
            }
        } catch (Exception e) {
            return error(-1, "绑定失败");
        }
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthController.java

@ -39,7 +39,7 @@ public class PatientHealthController extends BaseController {
     */
    @RequestMapping(value = "/modify", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("患者最近的各项健康信息")
    @ApiOperation("更改接口(包括手动记录的修改和所有的删除)")
    public String modify(@RequestParam long id,
                         @RequestParam(required = false) String recordDate,
                         @RequestParam(required = false) String value1,

+ 108 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/scheme/PatientSchemeController.java

@ -0,0 +1,108 @@
package com.yihu.wlyy.web.patient.scheme;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.app.scheme.DoctorSchemeService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Trick on 2018/1/9.
 */
@RestController
@RequestMapping(value = "/patient/scheme")
@Api(description = "患者端-监测方案相关接口")
public class PatientSchemeController extends BaseController {
    @Autowired
    private SignPatientLabelInfoService labelInfoService;
    @Autowired
    private DoctorSchemeService doctorSchemeService;
    @RequestMapping(value = "/patient",method = RequestMethod.GET)
    @ApiOperation("查询居民信息")
    public String getPatient(String patient) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "居民不能为空");
            }
            JSONObject p = labelInfoService.getPatient(getUID(),null);
            return write(200, "查询成功", "data", p);
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value="getPatientHealthIndex",method = RequestMethod.GET)
    @ApiOperation("获取最近一周血糖情况/血压情况")
    public String getPatientHealthIndex(@ApiParam(name="startDate", value="开始时间,YYYY-MM-dd") @RequestParam(value = "startDate",required = true)String startDate,
                                        @ApiParam(name="endDate", value="结束时间,YYYY-MM-dd") @RequestParam(value = "endDate",required = true)String endDate,
                                        @ApiParam(name="type", value="0血糖,1.血压") @RequestParam(value = "type",required = true)String type){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getPatientHealthIndex(getUID(),startDate, endDate, type));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value="getTrackPatientInfo",method = RequestMethod.GET)
    @ApiOperation("获取:微信运动,身高体重,血糖监测方案,血压监测方案")
    public String getTrackPatientInfo(){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getTrackPatientInfo(getUID()));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value="getControlObjectives",method = RequestMethod.GET)
    @ApiOperation("获取控制目标,血压,血糖")
    public String getControlObjectives(){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getControlObjectives(getUID()));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value="getBodyInfo",method = RequestMethod.GET)
    @ApiOperation("获取身高体重详情列表")
    public String getBodyInfo(@ApiParam(name="startDate", value="开始时间,YYYY-MM-dd") @RequestParam(value = "startDate",required = true)String startDate,
                              @ApiParam(name="endDate", value="结束时间,YYYY—MM-dd") @RequestParam(value = "endDate",required = true)String endDate,
                              @ApiParam(name="page", value="起始页") @RequestParam(value = "page",required = true)Integer page,
                              @ApiParam(name="size", value="每页大小") @RequestParam(value = "size",required = true)Integer size){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getBodyInfo(getUID(),startDate,endDate,page,size));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value="getPatientScheme",method = RequestMethod.GET)
    @ApiOperation("获取患者监控计划")
    public String getPatientScheme(@ApiParam(name="type", value="1血糖,2血压") @RequestParam(value = "type",required = true)String type){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getPatientScheme(getUID(),type));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "查询失败");
        }
    }
}

+ 8 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -23,10 +23,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.*;
/**
 * Created by chenweida on 2017/10/13
@ -273,13 +270,17 @@ public class EsStatisticsController extends BaseController {
            /**旧版统计代码start**/
            //未回复-22 到达量
            JSONArray jsonArray2 = null;
            /*if (DateUtil.getYear(endDate, "yyyy-MM-dd").equals(year)) {
            /*Date startTime = DateUtil.strToDate(year +"-07-01","yyyy-MM-dd");
            Date endTime = DateUtil.strToDate(Integer.valueOf(year) + 1 + "-06-30","yyyy-MM-dd");*/
            String lastSixMonthDate = DateUtil.getNextMonth(DateUtil.strToDate(endDate),-6);
            if (DateUtil.getYear(lastSixMonthDate,"yyyy-MM-dd").equals(year)) {
                jsonArray2 = statisticsESService.getLowLevelIncrementDetail(endDate, endDate, area, level, indexes[1], sort, lowLevel);
            } else {
                String date = Integer.valueOf(year) + 1 + "-06-30";
                jsonArray2 = statisticsESService.getLowLevelIncrementDetail(date, date, area, level, indexes[1], sort, lowLevel);
            }*/
            jsonArray2 = statisticsESService.getLowLevelIncrementDetail(endDate, endDate, area, level, indexes[1], sort, lowLevel);
            }
           // jsonArray2 = statisticsESService.getLowLevelIncrementDetail(endDate, endDate, area, level, indexes[1], sort, lowLevel);
            jsonArrays.add(jsonArray2);
            /**旧版统计代码end**/

+ 29 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/iot/IotDeviceController.java

@ -6,10 +6,12 @@ import com.yihu.wlyy.service.third.iot.IotDeviceService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
@ -34,7 +36,7 @@ public class IotDeviceController extends BaseController{
            js.put("device_name","血压计-康为A206G");
            js.put("device_model","血压计-康为A206G");
            js.put("idcard","350429198905194016");
            js.put("username","邹林");
            js.put("username","小李");
            js.put("manufacture_code","");
            js.put("manufacture_name","");
            js.put("owner_org_code","");
@ -55,6 +57,20 @@ public class IotDeviceController extends BaseController{
        }
    }
    @RequestMapping(value = "/upload",method = RequestMethod.POST)
    @ApiOperation("体征数据上传")
    public String upload(@ApiParam(name = "jsonStr",value = "jsonStr",defaultValue = "")
                         @RequestParam(value = "jsonStr",required = true) String jsonStr){
        try {
            JSONObject json = JSONObject.parseObject(jsonStr);
            String re = iotDeviceService.upload(json);
            return write(200, "体征数据上传成功!", "data", re);
        }catch (Exception e){
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/upload1",method = RequestMethod.POST)
    @ApiOperation("不含居民身份的数据上传协议")
    public String upload1(){
@ -64,8 +80,13 @@ public class IotDeviceController extends BaseController{
            js.put("measure_time","2018-01-01 01:01:01");
            js.put("systolic","111");
            js.put("systolic_unit","mmHg");
            js.put("diastolic","60");
            js.put("diastolic_unit","mmHg");
            js.put("pulse","66");
            js.put("pulse_unit","bpm");
            js.put("del","1");
            js.put("status","0");
            JSONArray jsonArray = new JSONArray();
            jsonArray.add(js);
@ -77,7 +98,7 @@ public class IotDeviceController extends BaseController{
            String re = iotDeviceService.upload(json);
            return write(200, "注册设备成功!", "data", re);
            return write(200, "上传成功!", "data", re);
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
@ -85,25 +106,27 @@ public class IotDeviceController extends BaseController{
    }
    @RequestMapping(value = "/upload2",method = RequestMethod.POST)
    @ApiOperation("不含居民身份的数据上传协议")
    @ApiOperation("含居民身份的数据上传协议")
    public String upload2(){
        try {
            JSONObject json = new JSONObject();
            JSONObject js = new JSONObject();
            js.put("measure_time","2018-01-01 11:01:01");
            js.put("blood_sugar","6.7");
            js.put("blood_sugar_unit","mmol/L");
            js.put("del","1");
            js.put("status","0");
            JSONArray jsonArray = new JSONArray();
            jsonArray.add(js);
            json.put("data",jsonArray);
            json.put("data",jsonArray);
            json.put("sn","2638234828");
            json.put("ext_code","1");
            json.put("device_name","血压计-康为A206G");
            json.put("device_model","血压计-康为A206G");
            json.put("idcard","350429198905194016");
            json.put("username","邹林");
            json.put("username","小李");
            String re = iotDeviceService.upload(json);
            return write(200, "注册设备成功!", "data", re);
            return write(200, "上传成功!", "data", re);
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());

+ 397 - 144
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/service/EduArticleService.java

@ -6,20 +6,20 @@ import com.yihu.edu.entity.dataClean.*;
import com.yihu.es.entity.HealthEduArticleES;
import com.yihu.es.entity.HealthEduArticleESResult;
import com.yihu.wlyy.config.es.ElasticFactory;
import com.yihu.wlyy.config.es.ElastricSearchSave;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.education.HealthEduArticle;
import com.yihu.wlyy.entity.education.HealthEduArticleDoctor;
import com.yihu.wlyy.entity.education.HealthEduArticlePatient;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.jkedu.repository.JkeduArticleDao;
import com.yihu.wlyy.jkedu.repository.JkeduBehaviorArticleDao;
import com.yihu.wlyy.jkedu.repository.JkeduCategoryDao;
import com.yihu.wlyy.jkedu.repository.JkeduCollectionArticleDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorRoleDao;
import com.yihu.wlyy.repository.education.HealthEduArticleDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.common.account.RoleService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ElasticsearchUtil;
import com.yihu.wlyy.util.MapListUtils;
@ -28,11 +28,8 @@ import com.yihu.wlyy.web.third.gateway.service.GcLabelService;
import com.yihu.wlyy.web.third.jkedu.vo.save.SaveEduArticleHelper;
import io.searchbox.client.JestClient;
import io.searchbox.core.*;
import org.apache.axis.utils.Admin;
import org.apache.commons.collections.list.AbstractLinkedList;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
@ -75,12 +72,17 @@ public class EduArticleService {
    @Autowired
    private JkeduBehaviorArticleDao jkeduBehaviorArticleDao;
    @Autowired
    private JkeduCategoryDao jkeduCategoryDao;
    @Autowired
    private ElasticsearchUtil elasticsearchUtil;
    @Autowired
    private ElasticFactory elasticFactory;
    @Autowired
    private GcLabelService gcLabelService;
    @Autowired
    private RoleService roleService;
    @Autowired
    private DoctorRoleDao doctorRoleDao;
    @Value("${es.type.HealthEduArticlePatient}")
    private String esType;
@ -105,6 +107,20 @@ public class EduArticleService {
        if (delOldList != null && delOldList.size() > 0) {
            jkeduArticleDao.delete(delOldList);
        }
        //查询所有一级类别
        List<NewCategoryModel> firstList = jkeduCategoryDao.findCategory(1);
        //查询所有二级类别
        List<NewCategoryModel> secondList = jkeduCategoryDao.findCategory(2);
        String firstId = "";
        String firstName = "健康文章";
        if (firstList!=null && firstList.size()>0){
            for (NewCategoryModel newCategoryModel : firstList){
                if (newCategoryModel.getCategoryName().contains(firstName)){
                    firstId = newCategoryModel.getCategoryId();
                }
            }
        }
        //分页查询,执行插入
        String countSql = "select COUNT(1) AS num from wlyy_health_edu_article";
        Map<String, Object> countMap = jdbcTemplate.queryForMap(countSql);
@ -113,8 +129,8 @@ public class EduArticleService {
            double pageCount = Math.ceil(Double.valueOf(count) / Double.valueOf(pageSize));
            if (pageCount > 0) {
                String sql = "SELECT code AS ArticleId,title AS ArticleTitle,summary AS Summary,content AS ArticleContent, " +
                        "url AS URL, czrq AS InsertTime, czrq AS UpdateTime,whea_type AS FirstLevelCategoryId," +
                        " keyword AS KeyWord FROM wlyy_health_edu_article limit ?,?";
                        "url AS URL, czrq AS InsertTime, czrq AS UpdateTime,keyword AS KeyWord " +
                        "FROM wlyy_health_edu_article limit ?,?";
                for (int i = 1; i <= pageCount; i++) {
                    int start = (i - 1) * pageSize;
                    //分页查询数据
@ -130,7 +146,6 @@ public class EduArticleService {
                            newArticleModel.setArticleOrder(99);
                            newArticleModel.setArticleState(1);
                            newArticleModel.setOrgName("厦门市卫生与计划生育委员会");
                            //id
                            newArticleModel.setArticleSource(wjwCode);
                            newArticleModel.setArticlelevel(0);
                            newArticleModel.setOperatorName("厦门市卫生与计划生育委员会");
@ -141,9 +156,19 @@ public class EduArticleService {
                            newArticleModel.setArticleType("2");
                            newArticleModel.setOperatorRoleCode("350200");
                            newArticleModel.setOperatorRoleLevel("2");
                            newArticleModel.setFirstLevelCategoryId(firstId);
                            newArticleModel.setFirstLevelCategoryName(firstName);
                            newArticleModel.setRoleType(2);
                            newArticleModel.setUserScope(1);
                            newArticleModel.setIsOld(1);
                            if (secondList!=null && secondList.size()>0){
                                for (NewCategoryModel newCategoryModel : secondList){
                                    if (newCategoryModel.getCategoryName().equals(newArticleModel.getKeyWord())){
                                        newArticleModel.setSecondLevelCategoryId(newCategoryModel.getCategoryId());
                                        newArticleModel.setSecondLevelCategoryName(newCategoryModel.getCategoryName());
                                    }
                                }
                            }
                            newList.add(newArticleModel);
                        }
                        //执行插入新数据库
@ -306,15 +331,12 @@ public class EduArticleService {
    public boolean getArticleSendedListToEs() {
        boolean flag = true;
        try {
            //获取卫计委code
            //1.获取卫计委code
            String sql = "select code AS wjwCode from wlyy_role WHERE  name LIKE '%厦门市卫生与计划生育委员会%' and LENGTH(code)=6";
            Map<String, Object> result = jdbcTemplate.queryForMap(sql);
            String wjwCode = result.get("wjwCode") + "";
            //查询es最大的时间记录
            String timeSql = "select createTime from " + esType + " order by createTime desc limit 0,1";
            HealthEduArticleESResult healthEduArticleESResult = (HealthEduArticleESResult) elasticsearchUtil.excuteOneObject(timeSql, HealthEduArticleESResult.class, esType, esIndex);
            String startTimeForSql = DateUtil.dateToStr(healthEduArticleESResult.getCreateTime(), "yyyy-MM-dd HH:mm:ss");
            //查询出所有的医生
            //2.查询出所有的医生
            List<Doctor> doctorList = doctorDao.findAllCertifiedDoctors();
            Map<String, Doctor> doctorMap = new HashedMap();
            if (doctorList != null && doctorList.size() > 0) {
@ -322,7 +344,8 @@ public class EduArticleService {
                    doctorMap.put(doctor.getCode(), doctor);
                }
            }
            //查询出所有的文章列表
            //3.查询出所有的文章列表
            List<HealthEduArticle> healthEduArticleList = healthEduArticleDao.findAllArticle();
            Map<String, HealthEduArticle> articleMap = new HashedMap();
            if (healthEduArticleList != null && healthEduArticleList.size() > 0) {
@ -330,121 +353,187 @@ public class EduArticleService {
                    articleMap.put(healthEduArticle.getCode(), healthEduArticle);
                }
            }
            //获取所有的健康教育发送记录数量,分页,userType=1
            String countSql = "SELECT COUNT(id) AS num from wlyy_health_edu_article_patient WHERE admin_team_code IS NOT NULL";
            if (StringUtils.isNotBlank(startTimeForSql)) {
                countSql += " AND czrq > '" + startTimeForSql + "'";
            }
            Map<String, Object> countMap = jdbcTemplate.queryForMap(countSql);
            if (countMap != null) {
                int count = Integer.valueOf(String.valueOf(countMap.get("num")));
                double pageCount = Math.ceil(Double.valueOf(count) / Double.valueOf(pageSize * 20));
                if (pageCount > 0) {
                    String resultSql = "SELECT " +
                            " ap.patient AS patientCode, " +
                            " ap.article AS articleId, " +
                            " ap.doctor AS doctorCode, " +
                            " ap.is_read AS isRead, " +
                            " ap.czrq AS createTime, " +
                            " ap.admin_team_code AS adminTeamCode, " +
                            " ap.batch_no AS batchNo, " +
                            " ap.send_type AS sendSource," +
                            " p.name AS patientName," +
                            " t.name AS adminTeamName" +
                            " FROM " +
                            " wlyy_health_edu_article_patient ap " +
                            " LEFT JOIN wlyy_patient p ON ap.patient = p.code " +
                            " LEFT JOIN wlyy_admin_team t ON ap.admin_team_code = t.id " +
                            " WHERE " +
                            " ap.admin_team_code IS NOT NULL ";
                    if (StringUtils.isNotBlank(startTimeForSql)) {
                        resultSql += " AND ap.czrq > '" + startTimeForSql + "' ORDER BY ap.czrq ASC limit ?,? ";
                    } else {
                        resultSql += "  ORDER BY ap.czrq ASC limit ?,? ";
            //4.查询所有一级类别、二级类别
            List<NewCategoryModel> firstList = jkeduCategoryDao.findCategory(1);
            List<NewCategoryModel> secondList = jkeduCategoryDao.findCategory(2);
            String firstId = "";
            String firstName = "健康文章";
            if (firstList!=null && firstList.size()>0){
                for (NewCategoryModel newCategoryModel : firstList){
                    if (newCategoryModel.getCategoryName().contains(firstName)){
                        firstId = newCategoryModel.getCategoryId();
                    }
                }
            }
                    for (int i = 1; i <= pageCount; i++) {
                        int start = (i - 1) * (pageSize * 20);
                        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(resultSql, new Object[]{start, pageSize * 20});
                        if (CollectionUtils.isEmpty(resultList)) {
                            flag = false;
                            return flag;
                        }
                        List<HealthEduArticleES> esList = new ArrayList<>();
                        for (Map<String, Object> map : resultList) {
                            HealthEduArticleES healthEduArticleES = new HealthEduArticleES();
                            //Map转对象
                            healthEduArticleES = MapListUtils.convertMap2Bean(map, HealthEduArticleES.class);
                            healthEduArticleES = setDateToObj(healthEduArticleES, doctorMap, articleMap, wjwCode, 1);
                            if (StringUtils.isEmpty(healthEduArticleES.getDoctorName())) {
                                healthEduArticleES.setDoctorCode(wjwCode);
                                //卫计委发送
                                healthEduArticleES.setSendType(2);
                                healthEduArticleES.setSendName("厦门市卫生与计划生育委员会");
                                healthEduArticleES.setDoctorName("厦门市卫生与计划生育委员会");
                            }
                            esList.add(healthEduArticleES);
            //5.查询出根据batch_no聚合后的每个批次号的数量
            String batchNoCountSql = "SELECT batch_no,COUNT(*) batchCount FROM wlyy_health_edu_article_patient_copy where admin_team_code IS NOT NULL AND  batch_no IS NOT NULL GROUP BY batch_no ";
            List<Map<String,Object>> batchNoCountMapList = jdbcTemplate.queryForList(batchNoCountSql);
            //6.清洗数据
            flag = CleanDateToEs(doctorMap,articleMap,wjwCode,firstId,firstName,secondList,batchNoCountMapList);
        }catch (Exception e){
            e.printStackTrace();
            flag = false;
        }
        return flag;
    }
    /**
     * 清洗数据到es
     * @param doctorMap
     * @param articleMap
     * @param wjwCode
     * @param firstId
     * @param firstName
     * @param secondList
     * @param batchNoCountMapList
     * @return
     * @throws Exception
     */
    public boolean CleanDateToEs(Map<String,Doctor> doctorMap,Map<String,HealthEduArticle> articleMap,String wjwCode,String firstId,String firstName,List<NewCategoryModel> secondList,List<Map<String,Object>> batchNoCountMapList)throws Exception{
        boolean flag = true;
        //1.查询es最新的时间记录
        String timeSql = "select createTime from " + esType + " order by createTime desc limit 0,1";
        HealthEduArticleESResult healthEduArticleESResult = (HealthEduArticleESResult) elasticsearchUtil.excuteOneObject(timeSql, HealthEduArticleESResult.class, esType, esIndex);
        String startTimeForSql = DateUtil.dateToStr(healthEduArticleESResult.getCreateTime(), "yyyy-MM-dd HH:mm:ss");
        //2.获取batchNo不为空的健康教育发送记录数量进行分页,userType=1
        String countSql = "SELECT COUNT(id) AS num from wlyy_health_edu_article_patient_copy WHERE admin_team_code IS NOT NULL AND batch_no IS NOT NULL ";
        if (StringUtils.isNotBlank(startTimeForSql)) {
            countSql += " AND czrq > '" + startTimeForSql + "'";
        }
        Map<String, Object> countMap = jdbcTemplate.queryForMap(countSql);
        if (countMap != null) {
            int count = Integer.valueOf(String.valueOf(countMap.get("num")));
            double pageCount = Math.ceil(Double.valueOf(count) / Double.valueOf(pageSize * 20));
            if (pageCount > 0) {
                String resultSql = "SELECT " +
                        " ap.patient AS patientCode, " +
                        " ap.article AS articleId, " +
                        " ap.doctor AS doctorCode, " +
                        " ap.is_read AS isRead, " +
                        " ap.czrq AS czrq, " +
                        " ap.admin_team_code AS adminTeamCode, " +
                        " ap.batch_no AS batchNo, " +
                        " ap.send_type AS sendSource," +
                        " p.name AS patientName," +
                        " t.name AS adminTeamName" +
                        " FROM " +
                        " wlyy_health_edu_article_patient_copy ap " +
                        " LEFT JOIN wlyy_patient p ON ap.patient = p.code " +
                        " LEFT JOIN wlyy_admin_team t ON ap.admin_team_code = t.id " +
                        " WHERE " +
                        " ap.admin_team_code IS NOT NULL AND ap.batch_no IS NOT NULL";
                if (StringUtils.isNotBlank(startTimeForSql)) {
                    resultSql += " AND ap.czrq > '" + startTimeForSql + "' ORDER BY ap.czrq ASC limit ?,? ";
                } else {
                    resultSql += "  ORDER BY ap.czrq ASC limit ?,? ";
                }
                //分页查询
                for (int i = 1; i <= pageCount; i++) {
                    int start = (i - 1) * (pageSize * 20);
                    List<Map<String, Object>> resultList = jdbcTemplate.queryForList(resultSql, new Object[]{start, pageSize * 20});
                    if (CollectionUtils.isEmpty(resultList)) {
                        flag = false;
                        return flag;
                    }
                    List<HealthEduArticleES> esList = new ArrayList<>();
                    //循环结果,封装对象
                    for (Map<String, Object> map : resultList) {
                        HealthEduArticleES healthEduArticleES = new HealthEduArticleES();
                        //Map转对象
                        healthEduArticleES = MapListUtils.convertMap2Bean(map, HealthEduArticleES.class);
                        healthEduArticleES = setDateToObj(healthEduArticleES, doctorMap, articleMap, wjwCode, 1,firstId,firstName,secondList,batchNoCountMapList);
                        if (StringUtils.isEmpty(healthEduArticleES.getDoctorName())) {
                            healthEduArticleES.setDoctorCode(wjwCode);
                            //卫计委发送
                            healthEduArticleES.setSendType(2);
                            healthEduArticleES.setSendName("厦门市卫生与计划生育委员会");
                            healthEduArticleES.setDoctorName("厦门市卫生与计划生育委员会");
                        }
                        //保存到Es中
                        saveDate(esList);
                        esList.add(healthEduArticleES);
                    }
                    //保存到Es中
                    saveDate(esList);
                }
            }
            //按批次查询文章信息。userType=2
            //要先删除原来的数据。
            String batSql = "SELECT batch_no from wlyy_health_edu_article_patient WHERE admin_team_code IS NOT NULL GROUP BY batch_no ";
            List<Map<String, Object>> batchNoMap = jdbcTemplate.queryForList(batSql);
            if (batchNoMap != null && batchNoMap.size() > 0) {
                deleteData(2, batchNoMap);
        }
        //3.按批次查询文章信息。userType=2
        //要先删除原来的数据。
        String batSql = "SELECT batch_no from wlyy_health_edu_article_patient_copy WHERE admin_team_code IS NOT NULL AND batch_no IS NOT NULL GROUP BY batch_no ";
        List<Map<String, Object>> batchNoMap = jdbcTemplate.queryForList(batSql);
        List<String> batchNoList = new ArrayList<>();
        if (batchNoMap != null && batchNoMap.size() > 0) {
            for (Map<String,Object> map : batchNoMap){
                batchNoList.add(String.valueOf(map.get("batch_no")));
            }
            deleteData(2, batchNoList);
        }
            String BartchNoSql = "SELECT " +
                    " ap.patient AS patientCode, " +
                    " ap.article AS articleId, " +
                    " ap.doctor AS doctorCode, " +
                    " ap.is_read AS isRead, " +
                    " ap.czrq AS createTime, " +
                    " ap.admin_team_code AS adminTeamCode, " +
                    " ap.batch_no AS batchNo, " +
                    " ap.send_type AS sendSource," +
                    " p.name AS patientName," +
                    " t.name AS adminTeamName" +
                    " FROM " +
                    " wlyy_health_edu_article_patient ap " +
                    " LEFT JOIN wlyy_patient p ON ap.patient = p.code " +
                    " LEFT JOIN wlyy_admin_team t ON ap.admin_team_code = t.id" +
                    " WHERE " +
                    " ap.admin_team_code IS NOT NULL GROUP BY ap.batch_no ORDER BY createTime ASC ";
            System.out.println("userType2=========" + BartchNoSql);
            List<Map<String, Object>> batchList = jdbcTemplate.queryForList(BartchNoSql);
            List<HealthEduArticleES> batchEsList = new ArrayList<>();
            if (batchList != null && batchList.size() > 0) {
                for (Map<String, Object> map : batchList) {
                    HealthEduArticleES healthEduArticleES = new HealthEduArticleES();
                    healthEduArticleES.setNewArricleFlag(false);
                    //Map转对象
                    healthEduArticleES = MapListUtils.convertMap2Bean(map, HealthEduArticleES.class);
                    healthEduArticleES = setDateToObj(healthEduArticleES, doctorMap, articleMap, wjwCode, 2);
                    if (StringUtils.isEmpty(healthEduArticleES.getDoctorName())) {
                        healthEduArticleES.setDoctorCode(wjwCode);
                        //卫计委发送
                        healthEduArticleES.setSendType(2);
                        healthEduArticleES.setSendName("厦门市卫生与计划生育委员会");
                        healthEduArticleES.setDoctorName("厦门市卫生与计划生育委员会");
                    }
                    batchEsList.add(healthEduArticleES);
        String BartchNoSql = "SELECT " +
                " ap.patient AS patientCode, " +
                " ap.article AS articleId, " +
                " ap.doctor AS doctorCode, " +
                " ap.is_read AS isRead, " +
                " ap.czrq AS createTime, " +
                " ap.admin_team_code AS adminTeamCode, " +
                " ap.batch_no AS batchNo, " +
                " ap.send_type AS sendSource," +
                " p.name AS patientName," +
                " t.name AS adminTeamName" +
                " FROM " +
                " wlyy_health_edu_article_patient_copy ap " +
                " LEFT JOIN wlyy_patient p ON ap.patient = p.code " +
                " LEFT JOIN wlyy_admin_team t ON ap.admin_team_code = t.id" +
                " WHERE " +
                " ap.admin_team_code IS NOT NULL AND ap.batch_no IS NOT NULL GROUP BY ap.batch_no ORDER BY createTime ASC ";
        List<Map<String, Object>> batchList = jdbcTemplate.queryForList(BartchNoSql);
        List<HealthEduArticleES> batchEsList = new ArrayList<>();
        if (batchList != null && batchList.size() > 0) {
            //循环封装对象
            for (Map<String, Object> map : batchList) {
                HealthEduArticleES healthEduArticleES = new HealthEduArticleES();
                healthEduArticleES.setNewArricleFlag(false);
                //Map转对象
                healthEduArticleES = MapListUtils.convertMap2Bean(map, HealthEduArticleES.class);
                healthEduArticleES = setDateToObj(healthEduArticleES, doctorMap, articleMap, wjwCode, 2,firstId,firstName,secondList,batchNoCountMapList);
                if (StringUtils.isEmpty(healthEduArticleES.getDoctorName())) {
                    healthEduArticleES.setDoctorCode(wjwCode);
                    //卫计委发送
                    healthEduArticleES.setSendType(2);
                    healthEduArticleES.setSendName("厦门市卫生与计划生育委员会");
                    healthEduArticleES.setDoctorName("厦门市卫生与计划生育委员会");
                }
                //保存到Es中
                saveDate(batchEsList);
                batchEsList.add(healthEduArticleES);
            }
        } catch (Exception e) {
            e.printStackTrace();
            flag = false;
            //保存到Es中
            saveDate(batchEsList);
        }
        return flag;
    }
    public HealthEduArticleES setDateToObj(HealthEduArticleES healthEduArticleES, Map<String, Doctor> doctorMap, Map<String, HealthEduArticle> articleMap, String wjwCode, Integer userType) throws Exception {
    /**
     * 封装Es存储对象
     * @param healthEduArticleES
     * @param doctorMap
     * @param articleMap
     * @param wjwCode
     * @param userType
     * @param firstId
     * @param firstName
     * @param secondList
     * @param batchNoCountMapList
     * @return
     * @throws Exception
     */
    public HealthEduArticleES setDateToObj(HealthEduArticleES healthEduArticleES, Map<String, Doctor> doctorMap,
                                           Map<String, HealthEduArticle> articleMap, String wjwCode,
                                           Integer userType,String firstId,String firstName,
                                           List<NewCategoryModel> secondList,List<Map<String,Object>> batchNoCountMapList) throws Exception {
        //遍历医生
        Set<Map.Entry<String, Doctor>> doctorSet = doctorMap.entrySet();
        for (Map.Entry<String, Doctor> doctorEntry : doctorSet) {
@ -452,9 +541,8 @@ public class EduArticleService {
                Doctor doctor = doctorEntry.getValue();
                healthEduArticleES.setDoctorCode(doctor.getCode());
                healthEduArticleES.setDoctorName(doctor.getName());
                //healthEduArticleES.setSendCode(doctor.getCode());
                //医生发送
                healthEduArticleES.setSendName(doctor.getCode());
                healthEduArticleES.setSendName(doctor.getName());
                healthEduArticleES.setSendPic(doctor.getPhoto());
                healthEduArticleES.setSendSex(doctor.getSex() != null ? String.valueOf(doctor.getSex()) : "");
                healthEduArticleES.setHospital(doctor.getHospital());
@ -472,19 +560,66 @@ public class EduArticleService {
                HealthEduArticle healthEduArticle = articleEntry.getValue();
                healthEduArticleES.setArticleId(healthEduArticle.getCode());
                healthEduArticleES.setArticleTitle(healthEduArticle.getTitle());
                healthEduArticleES.setArticleContent(healthEduArticle.getSummary());
                if (healthEduArticle.getContent().length()>=100){
                    healthEduArticleES.setArticleContent(healthEduArticle.getContent().substring(0,100));
                }else {
                    healthEduArticleES.setArticleContent(healthEduArticle.getContent());
                }
                healthEduArticleES.setFirstLevelCategoryId(firstId);
                healthEduArticleES.setFirstLevelCategoryName(firstName);
                if (secondList!=null && secondList.size()>0){
                    for (NewCategoryModel newCategoryModel : secondList){
                        if (newCategoryModel.getCategoryName().equals(healthEduArticle.getKeyword())){
                            healthEduArticleES.setSecondLevelCategoryId(newCategoryModel.getCategoryId());
                            healthEduArticleES.setSecondLevelCategoryName(newCategoryModel.getCategoryName());
                        }
                    }
                }
            }
        }
        /*if (userType==2){
            healthEduArticleES.setUserType(userType);
        }*/
        //替换已读数据code
        if (userType==1){
            //数据库中的isRead 0已读,1未读--->Es中isRead 0未读 1已读
            if (healthEduArticleES.getIsRead()==0){
                healthEduArticleES.setIsRead(1);
            }else{
                healthEduArticleES.setCzrq(null);
                healthEduArticleES.setIsRead(0);
            }
        }
        //算出allCount
        if (batchNoCountMapList!=null && batchNoCountMapList.size()>0){
            for (Map<String,Object> map : batchNoCountMapList){
                if (healthEduArticleES.getBatchNo().equals(String.valueOf(map.get("batch_no")))){
                    healthEduArticleES.setAllCount(Integer.valueOf(String.valueOf(map.get("batchCount"))));
                }
            }
        }
        //如果是医生推送
        if (!StringUtils.isEmpty(healthEduArticleES.getDoctorName())){
            //List<DoctorRole> roleList = doctorRoleDao.findUserRole(healthEduArticleES.getDoctorCode());
            int resultLevel = 4;
            /*if (roleList != null && roleList.size() > 0) {
                for (DoctorRole role : roleList) {
                    if(resultLevel>=roleService.roleConverse(role.getCode())){
                        resultLevel=roleService.roleConverse(role.getCode());
                    }
                }
            }*/
            healthEduArticleES.setCurrentUserRoleCode(healthEduArticleES.getHospital());
            healthEduArticleES.setCurrentUserRoleLevel(String.valueOf(resultLevel));
        }else{
            healthEduArticleES.setCurrentUserRoleCode(wjwCode);
            healthEduArticleES.setCurrentUserRoleLevel("2");
        }
        healthEduArticleES.setCreateTime(new Date());
        healthEduArticleES.setUserType(userType);
        healthEduArticleES.setOperatorId(wjwCode);
        healthEduArticleES.setArticleSource("厦门市卫生与计划生育委员会");
        return healthEduArticleES;
    }
    /**
     * 保存数据
     *
@ -497,31 +632,34 @@ public class EduArticleService {
    /**
     * 删除数据
     */
    private void deleteData(int userType, List<Map<String, Object>> batchNoMap) {
    private void deleteData(int userType, List<String> batchNoList) {
        JestClient jestClient = null;
        List<HealthEduArticleES> saveModels = new ArrayList<>();
        //List<HealthEduArticleES> saveModels = new ArrayList<>();
        try {
            jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            for (Map<String, Object> map : batchNoMap) {
                SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
                BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
                boolQueryBuilder.must(QueryBuilders.matchQuery("userType", userType));
                boolQueryBuilder.must(QueryBuilders.matchQuery("batchNo", map.get("batch_no") + ""));
                searchSourceBuilder.query(boolQueryBuilder).size(100);//一次取10000条
                Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                        .build();
                SearchResult result = jestClient.execute(search);
                List<HealthEduArticleES> healthEduArticleESList = result.getSourceAsObjectList(HealthEduArticleES.class);
                if (healthEduArticleESList != null && healthEduArticleESList.size() > 0) {
                    for (HealthEduArticleES healthEduArticleES : healthEduArticleESList) {
                        saveModels.add(healthEduArticleES);
                    }
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
            boolQueryBuilder.must(QueryBuilders.matchQuery("userType", userType));
                /*if (StringUtils.isEmpty(batchNo) || "null".equals(batchNo)){
                    boolQueryBuilder.must(QueryBuilders.missingQuery("batchNo"));
                }else{
                    boolQueryBuilder.must(QueryBuilders.termsQuery("batchNo", batchNo));
                }*/
            boolQueryBuilder.must(QueryBuilders.termsQuery("batchNo", batchNoList));
            searchSourceBuilder.query(boolQueryBuilder).size(500000);//一次取10000条
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            List<HealthEduArticleES> healthEduArticleESList = result.getSourceAsObjectList(HealthEduArticleES.class);
            /*if (healthEduArticleESList != null && healthEduArticleESList.size() > 0) {
                for (HealthEduArticleES healthEduArticleES : healthEduArticleESList) {
                    saveModels.add(healthEduArticleES);
                }
            }
            }*/
            //根据id批量删除
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            for (HealthEduArticleES obj : saveModels) {
            for (HealthEduArticleES obj : healthEduArticleESList) {
                if (obj != null) {
                    Delete index = new Delete.Builder(obj.getId()).build();
                    bulk.addAction(index);
@ -529,7 +667,7 @@ public class EduArticleService {
            }
            BulkResult br = jestClient.execute(bulk.build());
            logger.info("delete data count:" + saveModels.size());
            logger.info("delete data count:" + healthEduArticleESList.size());
            logger.info("delete flag:" + br.isSucceeded());
        } catch (Exception e) {
            System.out.println("======error:" + e.getMessage());
@ -772,5 +910,120 @@ public class EduArticleService {
        return healthEduArticleESSaveList.size();
    }
    /**
     * 删除Es里所有的旧数据
     * @return
     * @throws Exception
     */
    public Map<String, Object> deleteEsOldArticlePatient () throws Exception {
        Map<String, Object> returnMap = new HashedMap();
        int resultSize = 0;
        String sql = "SELECT batch_no AS batchNo,COUNT(1) batchCount " +
                "FROM wlyy_health_edu_article_patient_copy " +
                "WHERE admin_team_code IS NOT NULL AND batch_no IS NOT NULL GROUP BY batch_no";
        List<Map<String,Object>> batchMapList = jdbcTemplate.queryForList(sql);
        List<String> batchNoList = new ArrayList<>();
        if (batchMapList!=null && batchMapList.size()>0){
            for (Map<String,Object> map : batchMapList){
               batchNoList.add(String.valueOf(map.get("batchNo")));
            }
            resultSize = deleteEsByBatchNo(batchNoList);
        }
        returnMap.put("deleteCount",Integer.valueOf(resultSize));
        return returnMap;
    }
    private int deleteEsByBatchNo(List<String> list) {
        JestClient jestClient = null;
        //List<HealthEduArticleES> saveModels = new ArrayList<>();
        try {
            jestClient = elasticFactory.getJestClient();
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
                    new BoolQueryBuilder().must(QueryBuilders.termsQuery("batchNo",list))
            ).size(500000);//一次取10000条
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType).build();
            SearchResult result = jestClient.execute(search);
            List<HealthEduArticleES> healthEduArticleESs = result.getSourceAsObjectList(HealthEduArticleES.class);
            /*if (healthEduArticleESs != null && healthEduArticleESs.size() > 0) {
                for (HealthEduArticleES healthEduArticleES : healthEduArticleESs) {
                    saveModels.add(healthEduArticleES);
                }
            }*/
            //根据id批量删除
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            for (HealthEduArticleES obj : healthEduArticleESs) {
                if (obj != null) {
                    Delete index = new Delete.Builder(obj.getId()).build();
                    bulk.addAction(index);
                }
            }
            BulkResult br = jestClient.execute(bulk.build());
            logger.info("delete data count:" + healthEduArticleESs.size());
            logger.info("delete flag:" + br.isSucceeded());
            return healthEduArticleESs.size();
        } catch (Exception e) {
            e.printStackTrace();
            return -1;
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
    }
    public Map<String ,Object> addBatchNo(String doctorCode){
        Map<String,Object> resultMap = new HashedMap();
        String sql ="SELECT " +
                "  id, " +
                "  patient, " +
                "  article, " +
                "  doctor, " +
                "  doctor_name, " +
                "  DATE_FORMAT(czrq,'%y-%m-%d')czrq, " +
                "  admin_team_code, " +
                "  batch_no " +
                "  FROM " +
                "  wlyy_health_edu_article_patient " +
                "  WHERE " +
                "  admin_team_code IS NOT NULL " +
                "  AND batch_no IS NULL " +
                "  AND doctor = '"+doctorCode+"' ORDER BY czrq ASC";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        List<Map<String,String>> sqlList = new ArrayList<>();
        if (list!=null && list.size()>0){
            String oldArticleId = "";
            String oldTime = "";
            for (Map<String,Object> map : list){
                if (!(map.get("article")+"").equals(oldArticleId) || !(map.get("czrq")+"").equals(oldTime)){
                    oldArticleId = map.get("article")+"";
                    oldTime = map.get("czrq")+"";
                    Map<String,String> sqlMap = new HashedMap();
                    sqlMap.put("id",oldArticleId);
                    sqlList.add(sqlMap);
                }
            }
        }
        int a = 0;
        if (sqlList!=null && sqlList.size()>0){
            for (Map<String,String> map : sqlList){
                String batchNo = String.valueOf(UUID.randomUUID());
                batchNo = batchNo.replace("-","");
                String id = map.get("id")+"";
                String updateSql ="UPDATE wlyy_health_edu_article_patient " +
                        " SET batch_no = '"+batchNo+"' " +
                        " WHERE " +
                        " admin_team_code IS NOT NULL " +
                        " AND batch_no IS NULL " +
                        " AND article = '"+id+"' " +
                        " AND doctor = '"+doctorCode+"'";
                a +=jdbcTemplate.update(updateSql);
            }
        }
        resultMap.put("count",a);
        return resultMap;
    }
}

+ 0 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/vo/save/ElastricSearchSaveEduArticle.java

@ -55,7 +55,6 @@ public class ElastricSearchSaveEduArticle {
                }
            }
            BulkResult br = jestClient.execute(bulk.build());
            logger.info("save flag:" + br.isSucceeded());
            logger.info("save success:" + success);
            logger.info("save error:" + error);

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

@ -133,3 +133,11 @@ activemq:
neiwang:
  enable: false
  wlyy: http://59.61.92.90:8072/
#解决swagger 通过nginx代理之后curl显示localhost的问题
springfox:
  documentation:
    swagger:
      v2:
        host: 27.155.100.191
        path: /swagger/api-docs

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

@ -31,7 +31,7 @@ patient_QRCode_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={ap
#居民wifi图片地址
patient_wifi_pic_url = {server}/images/wifi.png
#居民wifi链接
patient_wifi_url = https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fintroduction%2fhtml%2fyygh.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
patient_wifi_url = https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=http://www.baidu.com
#就诊记录
patient_visit_pic ={server}/images/visit.png
#检查检验