浏览代码

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

wangzhinan 7 年之前
父节点
当前提交
54201de28b
共有 39 个文件被更改,包括 1883 次插入125 次删除
  1. 52 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/dict/SignDict.java
  2. 107 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/kit/KitDrugDetail.java
  3. 129 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/kit/KitDrugUseRecord.java
  4. 110 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/kit/KitUseRemindRecord.java
  5. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/MvcConfig.java
  6. 4 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/GateWayInterceptor.java
  7. 14 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/dict/SignDictDao.java
  8. 4 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorAdminTeamMemberDao.java
  9. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorDao.java
  10. 16 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/kit/KitDrugDetailDao.java
  11. 31 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/kit/KitDrugUseRecordDao.java
  12. 14 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/kit/KitUseRemindRecordDao.java
  13. 3 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientCertificateDao.java
  14. 3 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDeviceDao.java
  15. 4 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java
  16. 3 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/BaseService.java
  17. 28 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthRecordService.java
  18. 36 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  19. 31 11
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  20. 16 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java
  21. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  22. 19 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/gateway/GcClientDetailsService.java
  23. 10 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/gateway/GcTokenService.java
  24. 490 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/kit/KitService.java
  25. 233 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/kit/JyKitService.java
  26. 105 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/kit/DoctorKitController.java
  27. 156 90
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java
  28. 10 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java
  29. 44 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/kit/PatientKitController.java
  30. 30 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java
  31. 25 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/GcTokenController.java
  32. 40 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/vo/GcClientDetailsModel.java
  33. 91 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/kit/JyKitController.java
  34. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java
  35. 4 0
      patient-co/patient-co-wlyy/src/main/resources/application-dev.yml
  36. 6 2
      patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml
  37. 5 0
      patient-co/patient-co-wlyy/src/main/resources/application-prod.yml
  38. 5 0
      patient-co/patient-co-wlyy/src/main/resources/application-test.yml
  39. 二进制
      patient-co/patient-co-wlyy/src/main/webapp/images/activity.png

+ 52 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/dict/SignDict.java

@ -0,0 +1,52 @@
package com.yihu.wlyy.entity.dict;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * add by hzp 20170608
 * 签约字典
 */
@Entity
@Table(name = "wlyy_sign_dict")
public class SignDict extends IdEntity {
    private String year;
    private String type;
    private String code;
    private String name;
    public String getYear() {
        return year;
    }
    public void setYear(String year) {
        this.year = year;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}

+ 107 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/kit/KitDrugDetail.java

@ -0,0 +1,107 @@
package com.yihu.wlyy.entity.kit;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by 刘文彬 on 2018/7/18.
 * 用药记录药品清单
 */
@Entity
@Table(name = "kit_drug_detail")
public class KitDrugDetail extends IdEntity {
    private String code;//业务code
    private String deviceSn;//药盒的sn码
    private String drugName;//药品名称
    private String drugCode;//药品编码(巨烨暂无提供)
    private String unit;//药品计量单位(药盒默认“粒”)
    private String measure;//药品计量
    private Date insertTime;//记录添加时间
    private String relationCode;//用药记录表、用药提醒(即关联的)的code
    private String drugImgUrl;//药品图片地址
    private Integer type;//清单类型(1、用药记录药品清单、2、用药提醒药品清单)
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public String getDrugName() {
        return drugName;
    }
    public void setDrugName(String drugName) {
        this.drugName = drugName;
    }
    public String getDrugCode() {
        return drugCode;
    }
    public void setDrugCode(String drugCode) {
        this.drugCode = drugCode;
    }
    public String getUnit() {
        return unit;
    }
    public void setUnit(String unit) {
        this.unit = unit;
    }
    public String getMeasure() {
        return measure;
    }
    public void setMeasure(String measure) {
        this.measure = measure;
    }
    public Date getInsertTime() {
        return insertTime;
    }
    public void setInsertTime(Date insertTime) {
        this.insertTime = insertTime;
    }
    public String getRelationCode() {
        return relationCode;
    }
    public void setRelationCode(String relationCode) {
        this.relationCode = relationCode;
    }
    public String getDrugImgUrl() {
        return drugImgUrl;
    }
    public void setDrugImgUrl(String drugImgUrl) {
        this.drugImgUrl = drugImgUrl;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
}

+ 129 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/kit/KitDrugUseRecord.java

@ -0,0 +1,129 @@
package com.yihu.wlyy.entity.kit;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by 刘文彬 on 2018/7/18.
 * 药盒用药记录
 */
@Entity
@Table(name = "kit_drug_use_record")
public class KitDrugUseRecord extends IdEntity {
    private String code;//业务code
    private Date insertTime;//记录添加时间
    private Date useTime; //居民用药时间
    private Date normalTime; //居民计划用药时间
    private Integer recordType; //记录类型(1、手动,2、设备)
    private Integer useDrugStatus;//用药状态(1、按时,2、超时,3、漏用)
    private String deviceSn;//药盒的sn码
    private String deviceModel;//药盒型号
    private String patientCode;//居民code
    private String patientName;//居民姓名
    private String kitAccountId;//药盒账号id
    private String drugDetail;//药品清单json串
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getInsertTime() {
        return insertTime;
    }
    public void setInsertTime(Date insertTime) {
        this.insertTime = insertTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getUseTime() {
        return useTime;
    }
    public void setUseTime(Date useTime) {
        this.useTime = useTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getNormalTime() {
        return normalTime;
    }
    public void setNormalTime(Date normalTime) {
        this.normalTime = normalTime;
    }
    public Integer getRecordType() {
        return recordType;
    }
    public void setRecordType(Integer recordType) {
        this.recordType = recordType;
    }
    public Integer getUseDrugStatus() {
        return useDrugStatus;
    }
    public void setUseDrugStatus(Integer useDrugStatus) {
        this.useDrugStatus = useDrugStatus;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public String getKitAccountId() {
        return kitAccountId;
    }
    public void setKitAccountId(String kitAccountId) {
        this.kitAccountId = kitAccountId;
    }
    public String getDrugDetail() {
        return drugDetail;
    }
    public void setDrugDetail(String drugDetail) {
        this.drugDetail = drugDetail;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getDeviceModel() {
        return deviceModel;
    }
    public void setDeviceModel(String deviceModel) {
        this.deviceModel = deviceModel;
    }
    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;
    }
}

+ 110 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/kit/KitUseRemindRecord.java

@ -0,0 +1,110 @@
package com.yihu.wlyy.entity.kit;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by 刘文彬 on 2018/7/19.
 * 用药提醒记录
 */
@Entity
@Table(name = "kit_use_remind_record")
public class KitUseRemindRecord extends IdEntity {
    private String code;//业务code
    private Date normalTime; //居民计划用药时间
    private Date insertTime;//记录添加时间
    private Integer remindType;//提醒类型(1、到点,2、超时,3、漏用)
    private String kitAccountId;//药盒账号id
    private String deviceModel;//药盒型号
    private String patientCode;//居民code
    private String patientName;//居民姓名
    private String drugDetail;//药品清单json串
    private String deviceSn;//药盒sn码
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getNormalTime() {
        return normalTime;
    }
    public void setNormalTime(Date normalTime) {
        this.normalTime = normalTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getInsertTime() {
        return insertTime;
    }
    public void setInsertTime(Date insertTime) {
        this.insertTime = insertTime;
    }
    public Integer getRemindType() {
        return remindType;
    }
    public void setRemindType(Integer remindType) {
        this.remindType = remindType;
    }
    public String getKitAccountId() {
        return kitAccountId;
    }
    public void setKitAccountId(String kitAccountId) {
        this.kitAccountId = kitAccountId;
    }
    public String getDeviceModel() {
        return deviceModel;
    }
    public void setDeviceModel(String deviceModel) {
        this.deviceModel = deviceModel;
    }
    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 getDrugDetail() {
        return drugDetail;
    }
    public void setDrugDetail(String drugDetail) {
        this.drugDetail = drugDetail;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/MvcConfig.java

@ -36,7 +36,7 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
        // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则
        // excludePathPatterns 用户排除拦截
        registry.addInterceptor(gateWayInterceptor).addPathPatterns("/wlyygc/**").excludePathPatterns("/wlyygc/doctor/**", "/wlyygc/patient/**");
        registry.addInterceptor(gateWayInterceptor).addPathPatterns("/wlyygc/**","/third/juye/kit/**").excludePathPatterns("/wlyygc/doctor/**", "/wlyygc/patient/**");
        registry.addInterceptor(doctorInterceptor).addPathPatterns("/doctor/**", "/statistics/province/**", "/statistics/**", "wlyygc/doctor/**");
        registry.addInterceptor(patientInterceptor).addPathPatterns("/patient/**", "/wlyygc/patient/**");

+ 4 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/GateWayInterceptor.java

@ -62,6 +62,7 @@ public class GateWayInterceptor implements HandlerInterceptor {
                //没权限
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.statusEm.token_null.getCode(), BaseResultModel.statusEm.token_null.getMessage());
                response.getOutputStream().write(JSONObject.fromObject(baseResultModel).toString().getBytes());
                flag = false;
            }
            GcToken gcToken = gcTokenDaoDao.findByToken(accesstoken);
            if (gcToken == null) {
@ -69,18 +70,21 @@ public class GateWayInterceptor implements HandlerInterceptor {
                //没权限
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.statusEm.token_no_power.getCode(), BaseResultModel.statusEm.token_no_power.getMessage());
                response.getOutputStream().write(JSONObject.fromObject(baseResultModel).toString().getBytes());
                flag = false;
            }
            if (gcToken.getDel() == null || gcToken.getDel() == 0) {
                saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.statusEm.token_out_effect.getMessage());
                //token无效
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.statusEm.token_out_effect.getCode(), BaseResultModel.statusEm.token_out_effect.getMessage());
                response.getOutputStream().write(JSONObject.fromObject(baseResultModel).toString().getBytes());
                flag = false;
            }
            if (System.currentTimeMillis() > gcToken.getOutTime().getTime()) {
                saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.statusEm.token_out_time.getMessage());
                //token过期
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.statusEm.token_out_time.getCode(), BaseResultModel.statusEm.token_out_time.getMessage());
                response.getOutputStream().write(JSONObject.fromObject(baseResultModel).toString().getBytes());
                flag = false;
            }
        } catch (Exception e) {
            saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), e.getMessage());

+ 14 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/dict/SignDictDao.java

@ -0,0 +1,14 @@
package com.yihu.wlyy.repository.dict;
import com.yihu.wlyy.entity.dict.SignDict;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2018/7/23.
 */
public interface SignDictDao  extends PagingAndSortingRepository<SignDict, Long>, JpaSpecificationExecutor<SignDict> {
    List<SignDict> findByYear(String year);
}

+ 4 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorAdminTeamMemberDao.java

@ -36,6 +36,10 @@ public interface DoctorAdminTeamMemberDao extends
            "AND m.doctorCode = d.code AND t.available = true AND m.available = true ORDER BY d.level")
    List<Doctor> findAllMembers(@Param(value = "teamId") long teamId);
    @Query("SELECT d,m.available as available FROM AdminTeamMember m, AdminTeam t, Doctor d WHERE t.id = :teamId AND t.id = m.teamId " +
            "AND m.doctorCode = d.code AND t.available = true ORDER BY d.level")
    List<Object[]> findMembers(@Param(value = "teamId") long teamId);
    @Query("SELECT case when count(A) > 0 then true else false END FROM AdminTeamMember A WHERE A.teamId = :teamId " +
            "AND A.doctorCode = :doctorCode AND A.available = true")
    Boolean isMemberExist(@Param(value = "teamId") long teamId, @Param(value = "doctorCode") String doctorCode);

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

@ -30,7 +30,7 @@ public interface DoctorDao extends PagingAndSortingRepository<Doctor, Long>, Jpa
    @Query("select p from Doctor p where p.code = ?1")
    Doctor findByCode(String code);
    Doctor findByCodeAndDel(String code,String del);
    Doctor findByCodeAndDel(String code,Integer del);
    @Query("select d from Doctor d where d.del = 1")
    List<Doctor> findAllDoctors();

+ 16 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/kit/KitDrugDetailDao.java

@ -0,0 +1,16 @@
package com.yihu.wlyy.repository.kit;
import com.yihu.wlyy.entity.kit.KitDrugDetail;
import com.yihu.wlyy.entity.kit.KitDrugUseRecord;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by yeshijie on 2017/8/11.
 */
public interface KitDrugDetailDao extends PagingAndSortingRepository<KitDrugDetail, Long>, JpaSpecificationExecutor<KitDrugDetail> {
    List<KitDrugDetail> findByRelationCodeAndType(String relationCode,Integer type);
}

+ 31 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/kit/KitDrugUseRecordDao.java

@ -0,0 +1,31 @@
package com.yihu.wlyy.repository.kit;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.kit.KitDrugUseRecord;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
 * Created by yeshijie on 2017/8/11.
 */
public interface KitDrugUseRecordDao extends PagingAndSortingRepository<KitDrugUseRecord, Long>, JpaSpecificationExecutor<KitDrugUseRecord> {
    @Query(" select count(1) from KitDrugUseRecord u where u.patientCode=?1 and u.useDrugStatus=?2 and u.deviceSn=?3 and u.useTime>=?4 and u.useTime<=?5")
    int findStatisticsCount(String patientCode,Integer useDrugStatus,String deviceSn,Date monthStart,Date monthEnd);
    @Query(value = " select u.* from kit_drug_use_record u where u.patient_code=?1 and u.use_drug_status=?2 and u.device_sn=?3 and u.use_time>=?4 and u.use_time<=?5 order by DATE_FORMAT(u.use_time,'%c-%d') desc,u.use_drug_status desc",nativeQuery = true)
    List<KitDrugUseRecord> findStatistics(String patientCode,Integer useDrugStatus,String deviceSn,Date monthStart,Date monthEnd);
    @Query(value = " select u.* from kit_drug_use_record u where u.patient_code=?1 and u.device_sn=?2 and u.use_time>=?3 and u.use_time<=?4 order by DATE_FORMAT(u.use_time,'%c-%d') desc,u.use_drug_status desc",nativeQuery = true)
    List<KitDrugUseRecord> findStatistics(String patientCode,String deviceSn,Date monthStart,Date monthEnd);
    @Query("SELECT a FROM KitDrugUseRecord a WHERE a.patientCode = ?1  ORDER BY a.useTime DESC")
    Page<KitDrugUseRecord> findRecentByPatient(String patient, Pageable pageRequest);
}

+ 14 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/kit/KitUseRemindRecordDao.java

@ -0,0 +1,14 @@
package com.yihu.wlyy.repository.kit;
import com.yihu.wlyy.entity.kit.KitDrugUseRecord;
import com.yihu.wlyy.entity.kit.KitUseRemindRecord;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2017/8/11.
 */
public interface KitUseRemindRecordDao extends PagingAndSortingRepository<KitUseRemindRecord, Long>, JpaSpecificationExecutor<KitUseRemindRecord> {
}

+ 3 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientCertificateDao.java

@ -12,4 +12,7 @@ import java.util.List;
public interface PatientCertificateDao extends PagingAndSortingRepository<PatientCertificate, Long>, JpaSpecificationExecutor<PatientCertificate> {
    List<PatientCertificate> findByPatientAndSignYearAndDel(String patient,String signYear,String del);
    List<PatientCertificate> findByPatientAndSignYearAndDelAndSignDictCode(String patient,String signYear,String del,String signCode);
}

+ 3 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDeviceDao.java

@ -20,6 +20,9 @@ public interface PatientDeviceDao extends PagingAndSortingRepository<PatientDevi
    @Query("select a from PatientDevice a where a.user = ?1 ")
    List<PatientDevice> findByPatient(String user);
    @Query("select a from PatientDevice a where a.user = ?1 and a.del=0 and a.deviceName like '%药盒%'")
    List<PatientDevice> findByPatientAndDel(String user);
    @Query("select a from PatientDevice a where a.user = ?1 and a.deviceSn=?2 ")
    List<PatientDevice> findByPatientAndDeviceSn(String user, String deviceSn);

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

@ -433,4 +433,8 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    //根据patient查找有效签约的hospital
    @Query("select a.hospital from SignFamily a where a.patient = ?1 and a.status = 1 and a.expensesStatus = '1'")
    String getHospital(String patient);
    //查看团队内医生签约人数
    @Query("select count(1) from SignFamily a where a.status >= 0 and a.adminTeamId = ?1 and (a.doctor = ?2 or a.doctorHealth = ?2)")
    int countByAdminTeamId(Long adminTeamId, String doctor);
}

+ 3 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/BaseService.java

@ -23,6 +23,9 @@ public class BaseService {
	public String getCode() {
		return UUID.randomUUID().toString().replaceAll("-", "");
	}
	public String getUUID() {
		return UUID.randomUUID().toString();
	}
	@Autowired
	private CommonUtil CommonUtil;

+ 28 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthRecordService.java

@ -3,12 +3,16 @@ package com.yihu.wlyy.service.app.health;
import com.yihu.wlyy.entity.dict.Medicines;
import com.yihu.wlyy.entity.education.Sports;
import com.yihu.wlyy.entity.education.SportsType;
import com.yihu.wlyy.entity.kit.KitDrugDetail;
import com.yihu.wlyy.entity.kit.KitDrugUseRecord;
import com.yihu.wlyy.entity.patient.PatientHealthRecordDiet;
import com.yihu.wlyy.entity.patient.PatientHealthRecordMedication;
import com.yihu.wlyy.entity.patient.PatientHealthRecordSports;
import com.yihu.wlyy.repository.dict.MedicinesDao;
import com.yihu.wlyy.repository.education.SportsDao;
import com.yihu.wlyy.repository.education.SportsTypeDao;
import com.yihu.wlyy.repository.kit.KitDrugDetailDao;
import com.yihu.wlyy.repository.kit.KitDrugUseRecordDao;
import com.yihu.wlyy.repository.patient.PatientHealthRecordDietDao;
import com.yihu.wlyy.repository.patient.PatientHealthRecordMedicationDao;
import com.yihu.wlyy.repository.patient.PatientHealthRecordSportsDao;
@ -19,6 +23,7 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
@ -31,6 +36,7 @@ import org.springside.modules.persistence.SearchFilter.Operator;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
@ -55,6 +61,12 @@ public class PatientHealthRecordService extends BaseService {
	@Autowired
	private PatientHealthRecordSportsDao patientHealthRecordSportsDao;
	@Autowired
	private KitDrugUseRecordDao kitDrugUseRecordDao;
	@Autowired
	private KitDrugDetailDao kitDrugDetailDao;
	/**
	 * 更改保健记录(包括手动记录的修改和所有的删除)
	 *
@ -304,6 +316,8 @@ public class PatientHealthRecordService extends BaseService {
		Page<PatientHealthRecordMedication> medication = patientHealthRecordMedicationDao.findRecentByPatient(patient, new PageRequest(0, 1));
		// 查询最近的饮食
		Page<PatientHealthRecordDiet> diet = patientHealthRecordDietDao.findRecentByPatient(patient, new PageRequest(0, 1));
		// 查询最近的药盒使用记录
		Page<KitDrugUseRecord> kitDrugUseRecords = kitDrugUseRecordDao.findRecentByPatient(patient, new PageRequest(0, 1));
		if (sports != null && sports.getSize() > 0) {
			JSONObject sportObject = new JSONObject();
			for (PatientHealthRecordSports temp : sports) {
@ -340,6 +354,20 @@ public class PatientHealthRecordService extends BaseService {
			jsonObject.put("diet",dietObject);
		}
		if(kitDrugUseRecords!=null){
			JSONObject dietObject = new JSONObject();
			for (KitDrugUseRecord temp : kitDrugUseRecords) {
				dietObject.put("recordDate",DateUtil.dateToStr(temp.getUseTime(), DateUtil.YYYY_MM_DD));
				dietObject.put("deviceSn",temp.getDeviceSn());
				List<KitDrugDetail> kitDrugDetailList = kitDrugDetailDao.findByRelationCodeAndType(temp.getCode(),1);
				if(kitDrugDetailList.size()>0){
					dietObject.put("drugDetail",kitDrugDetailList.get(0).getDrugName());
				}else{
					dietObject.put("drugDetail","");
				}
			}
			jsonObject.put("kitDrugUseRecords",dietObject);
		}
		return jsonObject;
	}

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

@ -2,6 +2,7 @@ package com.yihu.wlyy.service.app.sign;
import com.yihu.wlyy.entity.consult.Consult;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.dict.SignDict;
import com.yihu.wlyy.entity.doctor.OperatorLog;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.profile.DoctorService;
@ -18,6 +19,7 @@ import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.consult.ConsultDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.dict.SignDictDao;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.*;
import com.yihu.wlyy.repository.message.MessageDao;
@ -38,6 +40,7 @@ import com.yihu.wlyy.task.SignUploadTask;
import com.yihu.wlyy.util.*;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import io.swagger.models.auth.In;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
@ -171,7 +174,10 @@ public class FamilyContractService extends BaseService {
    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private PatientCertificateDao patientCertificateDao;
    @Autowired
    private SignDictDao signDictDao;
    @Autowired
    private SignFamilyServerDao signFamilyServerDao;
    public SignFamily findSignFamilyByCode(String code) {
        return signFamilyDao.findByCode(code);
@ -3988,8 +3994,8 @@ public class FamilyContractService extends BaseService {
        if (jtSignFamily != null) {
            //家庭签约只找全科医生
            Doctor doctor = doctorDao.findByCodeAndDel(jtSignFamily.getDoctor(),"1");
            Doctor doctorHealth = doctorDao.findByCodeAndDel(jtSignFamily.getDoctorHealth(),"1");
            Doctor doctor = doctorDao.findByCodeAndDel(jtSignFamily.getDoctor(),1);
            Doctor doctorHealth = doctorDao.findByCodeAndDel(jtSignFamily.getDoctorHealth(),1);
            if (doctor != null) {
                JSONObject jo = new JSONObject();
                jo.put("code", doctor.getCode());
@ -4534,7 +4540,15 @@ public class FamilyContractService extends BaseService {
        }
    }
    public String  saveCertificate(String patient,String imgPath,String sevId){
    /**
     * 新增更新证明接口
     * @param patient
     * @param imgPath
     * @param sevId
     * @param imgId
     * @return
     */
    public String  saveCertificate(String patient,String imgPath,String sevId,String imgId){
        try{
            if (StringUtils.isNotBlank(sevId)) {
                String[] sevIds = sevId.split(",");
@ -4559,13 +4573,31 @@ public class FamilyContractService extends BaseService {
                        patientCertificate.setCertificatePath(im);
                        patientCertificate.setDel("1");
                        patientCertificate.setCreateTime(new Date());
                        //设置签约年度
                        patientCertificate.setSignYear(DateUtil.getSignYear()+"");
                        patientCertificateDao.save(patientCertificate);
                    }
                }
                //删除修改图片
                if(StringUtils.isNotBlank(imgId)){
                    String[] ids = imgId.split(",");
                    for(int i =0;i<ids.length;i++){
                        Long id = Long.parseLong(ids[i]);
                        patientCertificateDao.delete(id);
                    }
                }
            }
        }catch (Exception e){
            logger.info(e.getMessage()+"___:"+e.toString());
        }
        return "1";
    }
    public List<SignDict> getSignDict(){
        return signDictDao.findByYear(DateUtil.getSignYear()+"");
    }
    public List<SignFamilyServer> findPatientSignServerBySignCode(String signCode){
       return signFamilyServerDao.findBySignCode(signCode);
    }
}

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

@ -147,6 +147,8 @@ public class SignWebService extends BaseService {
    public static String city = "350200";
    @Autowired
    private ServiceStatisticsService serviceStatisticsService;
    @Autowired
    private PatientCertificateDao patientCertificateDao;
    /**
     * 根据医生代码及签约状态编码 获取该医生签约患者的信息列表
@ -157,7 +159,7 @@ public class SignWebService extends BaseService {
     * @param pageSize
     * @return
     */
    public List<Map<String, Object>> getSignWebByDoctor(String doctor, int status, int page, int pageSize) {
    public List<Map<String, Object>> getSignWebByDoctor(String doctor, int status, String patientInfo, int page, int pageSize) {
        Doctor d = doctorDao.findByCode(doctor);
        String sql;
@ -169,6 +171,7 @@ public class SignWebService extends BaseService {
                    "    ,b.code  as  patient" +
                    "    ,b.idcard " +
                    "    ,b.name " +
                    "    ,b.mobile" +
                    "    ,b.province_name  as provinceName" +
                    "    ,b.city_name  as cityName" +
                    "    ,b.town_name  as townName" +
@ -186,7 +189,8 @@ public class SignWebService extends BaseService {
                    " ( select renew_flag,code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin from wlyy_sign_family where doctor_health = ? and doctor is null  and status = ? and type = 2" +
                    (status == 3 ? " and expenses_status = '1'" : "") + " order by begin desc ) a " +
                    " ,wlyy_patient b " +
                    " where a.patient = b.code  order by applyDate desc limit " + page * pageSize + "," + pageSize;
                    " where a.patient = b.code and (b.`name` like ? or b.code LIKE ? ) "+
                    " order by applyDate desc limit " + page * pageSize + "," + pageSize;
        } else {
            // 查询语句
            sql = "select " +
@ -195,6 +199,7 @@ public class SignWebService extends BaseService {
                    "    ,b.code  as  patient" +
                    "    ,b.idcard " +
                    "    ,b.name " +
                    "    ,b.mobile" +
                    "    ,b.province_name  as provinceName" +
                    "    ,b.city_name  as cityName" +
                    "    ,b.town_name  as townName" +
@ -212,7 +217,8 @@ public class SignWebService extends BaseService {
                    " ( select renew_flag,code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin from wlyy_sign_family where doctor = ?  and status = ? and type = 2" +
                    (status == 3 ? " and expenses_status = '1'" : "") + " order by begin desc ) a " +
                    " ,wlyy_patient b " +
                    " where a.patient = b.code  order by applyDate desc limit " + page * pageSize + "," + pageSize;
                    " where a.patient = b.code  and (b.`name` like ? or b.code LIKE ? ) "+
                    "order by applyDate desc limit " + page * pageSize + "," + pageSize;
        }
        // 查询已经签约语句
@ -222,6 +228,7 @@ public class SignWebService extends BaseService {
                "    ,b.code  as  patient" +
                "    ,b.idcard " +
                "    ,b.name " +
                "    ,b.mobile" +
                "    ,b.province_name  as provinceName" +
                "    ,b.city_name  as cityName" +
                "    ,b.town_name  as townName" +
@ -239,13 +246,15 @@ public class SignWebService extends BaseService {
                " ( select renew_flag,code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin from wlyy_sign_family where (doctor = ? or doctor_health = ?)  and status = ? and type = 2" +
                (status == 3 ? " and expenses_status = '1'" : "") + " order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code  order by applyDate desc limit " + page * pageSize + "," + pageSize;
                " where a.patient = b.code  and (b.`name` like ? or b.code LIKE ? ) "+
                "order by applyDate desc limit " + page * pageSize + "," + pageSize;
        // 未缴费查询语句
        String sqlExpenses = "select " +
                "    a.code " +
                "    ,a.doctor " +
                "    ,b.code  as  patient" +
                "    ,b.name " +
                "    ,b.mobile" +
                "    ,b.idcard " +
                "    ,b.province_name  as provinceName" +
                "    ,b.city_name  as cityName" +
@ -263,7 +272,8 @@ public class SignWebService extends BaseService {
                " from " +
                " ( select patient_apply_date,renew_flag,code,patient,doctor,status,id,apply_date,reason,begin,expenses_status,LENGTH(trim(ifnull(expenses_status,''))) len from wlyy_sign_family where (doctor = ? or doctor_health = ?)  and status > ? and type = 2 order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code and (a.expenses_status = '0' or a.len < 1) order by applyDate desc limit " + page * pageSize + "," + pageSize;
                " where a.patient = b.code and (a.expenses_status = '0' or a.len < 1) and (b.`name` like ? or b.code LIKE ? ) "+
                "order by applyDate desc limit " + page * pageSize + "," + pageSize;
        // 已解约查询语句
        String surrSql = "select " +
@ -271,6 +281,7 @@ public class SignWebService extends BaseService {
                "    ,a.doctor " +
                "    ,b.code  as  patient" +
                "    ,b.name " +
                "    ,b.mobile" +
                "    ,b.idcard " +
                "    ,b.province_name  as provinceName" +
                "    ,b.city_name  as cityName" +
@ -288,7 +299,8 @@ public class SignWebService extends BaseService {
                " from " +
                " ( select patient_apply_date,renew_flag,code,patient,doctor,status,id,apply_date,apply_unsign_date,reason,begin from wlyy_sign_family where (doctor = ? or doctor_health = ?)  and ( status = ? or status = ? ) and type = 2 order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code  order by applyDate desc limit " + page * pageSize + "," + pageSize;
                " where a.patient = b.code  and (b.`name` or b.code like ? ) " +
                "order by applyDate desc limit " + page * pageSize + "," + pageSize;
        // 分页信息
        //PageRequest pageRequest = new PageRequest(page - 1, pageSize);
@ -297,19 +309,19 @@ public class SignWebService extends BaseService {
        List<Map<String, Object>> patients = null;
        switch (status) {
            case 1:// 待签约
                patients = jdbcTemplate.queryForList(sql, new Object[]{doctor, 0});
                patients = StringUtils.isBlank(patientInfo) ? jdbcTemplate.queryForList(sql, new Object[]{doctor, 0, "%%", "%%"}):jdbcTemplate.queryForList(sql, new Object[]{doctor, 0, "%"+patientInfo + "%", "%"+patientInfo + "%"});
                break;
            case 2:// 待解约
                patients = jdbcTemplate.queryForList(sql, new Object[]{doctor, 2});
                patients = StringUtils.isBlank(patientInfo) ? jdbcTemplate.queryForList(sql, new Object[]{doctor, 2, "%%", "%%"}) : jdbcTemplate.queryForList(sql, new Object[]{doctor, 2, "%"+patientInfo + "%", "%"+patientInfo + "%"});
                break;
            case 3:// 已签约
                patients = jdbcTemplate.queryForList(isSignSql, new Object[]{doctor, doctor, 1});
                patients = StringUtils.isBlank(patientInfo) ? jdbcTemplate.queryForList(isSignSql, new Object[]{doctor, doctor, 1, "%%", "%%"}) : jdbcTemplate.queryForList(isSignSql, new Object[]{doctor, doctor, 1, "%"+patientInfo + "%", "%"+patientInfo + "%"});
                break;
            case 4:// 4已经解约
                patients = jdbcTemplate.queryForList(surrSql, new Object[]{doctor, doctor, -3, -4});
                patients = StringUtils.isBlank(patientInfo) ? jdbcTemplate.queryForList(surrSql, new Object[]{doctor, doctor, -3, -4, "%%", "%%"}) : jdbcTemplate.queryForList(surrSql, new Object[]{doctor, doctor, -3, -4, "%"+patientInfo + "%", "%"+patientInfo + "%"});
                break;
            case 5: // 未缴费
                patients = jdbcTemplate.queryForList(sqlExpenses, new Object[]{doctor, doctor, 0});
                patients = StringUtils.isBlank(patientInfo) ? jdbcTemplate.queryForList(sqlExpenses, new Object[]{doctor, doctor, 0, "%%", "%%"}) : jdbcTemplate.queryForList(sqlExpenses, new Object[]{doctor, doctor, 0, "%"+patientInfo + "%", "%"+patientInfo + "%"});
        }
        return patients;
@ -2941,5 +2953,13 @@ public class SignWebService extends BaseService {
    }
    public List<PatientCertificate> findPatientCertificate(String patient){
       List<PatientCertificate>  list =  patientCertificateDao.findByPatientAndSignYearAndDel(patient,DateUtil.getSignYear()+"","1");
       return list;
    }
    public List<PatientCertificate> findByPatientAndSignYearAndDelAndSignDictCode(String patient,String signCode){
        List<PatientCertificate>  list =  patientCertificateDao.findByPatientAndSignYearAndDelAndSignDictCode(patient,DateUtil.getSignYear()+"","1",signCode);
        return list;
    }
}

+ 16 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java

@ -436,6 +436,22 @@ public class AdminTeamService extends BaseService {
        return memberDao.findAllMembers(teamId);
    }
    public List<Object[]> findMembers(long teamId) {
        List<Object[]> members= new ArrayList<>();
        List<Object[]> list= new ArrayList<>();
        int count = 0;
        members = memberDao.findMembers(teamId);
        for(Object[] member : members){
            Object[] obj = new Object[member.length + 1];
            System.arraycopy(member, 0, obj, 0, member.length);
            Doctor d = (Doctor) member[0];
            count = signFamilyDao.countByAdminTeamId(teamId, d.getCode());
            obj[obj.length - 1] = count;
            list.add(obj);
        }
        return list;
    }
    public List<Doctor> getMembers(long teamId, String doctorCode) {
        return memberDao.findAllHeathExcludeThis(teamId, doctorCode);
    }

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -456,6 +456,7 @@ public class PatientService extends TokenService {
     * @param patient
     * @return
     */
    @Deprecated
    public JSONObject checkCanSignRenew(String patient) {
        JSONObject rs = new JSONObject();

+ 19 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/gateway/GcClientDetailsService.java

@ -2,18 +2,36 @@ package com.yihu.wlyy.service.gateway;
import com.yihu.wlyy.entity.gateway.GcClientDetails;
import com.yihu.wlyy.repository.gateway.GcClientDetailsDao;
import com.yihu.wlyy.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
/**
 * Created by chenweida on 2017/8/17.
 */
@Service
public class GcClientDetailsService {
public class GcClientDetailsService extends BaseService{
    @Autowired
    private GcClientDetailsDao gtClientDetailsDao;
    public GcClientDetails findByAppId(String appid) {
        return gtClientDetailsDao.findByAppid(appid);
    }
    @Transactional
    public GcClientDetails createClientDetails(String appUri,String createUserName,String creatieUser,String remark) throws Exception{
        GcClientDetails gcClientDetails = new GcClientDetails();
        gcClientDetails.setAppId(getUUID());
        gcClientDetails.setAppSecret(getUUID());
        gcClientDetails.setAppUri(appUri);
        gcClientDetails.setCreateUserName(createUserName);
        gcClientDetails.setCreatieUser(creatieUser);
        gcClientDetails.setCreatieTime(new Date());
        gcClientDetails.setDel(1);
        gcClientDetails.setRemark(remark);
        return gtClientDetailsDao.save(gcClientDetails);
    }
}

+ 10 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/gateway/GcTokenService.java

@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.UUID;
@ -33,7 +34,7 @@ public class GcTokenService {
     * @return
     */
    @Transactional
    public GcToken createToken(String appid, String appSecret, String ip) {
    public GcToken createToken(String appid, String appSecret, String ip,String overTime) {
        try {
            //把该用户之前有效的token设置为无效
            tokenDao.updateDel(appid);
@ -47,10 +48,15 @@ public class GcTokenService {
            gc.setAppid(appid);
            gc.setCreateTime(date);
            //2小时过期
            if(tokenTime==null){
                tokenTime=2;
            if(StringUtils.isEmpty(overTime)){
                if(tokenTime==null){
                    tokenTime=2;
                }
                gc.setOutTime(DateUtil.getNextMin(date, tokenTime*60));
            }else{
                gc.setOutTime(DateUtil.strToDate(overTime));
            }
            gc.setOutTime(DateUtil.getNextMin(date, tokenTime*60));
            gc.setAccesstoken(token);
            gc.setDel(1);
            tokenDao.save(gc);

+ 490 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/kit/KitService.java

@ -0,0 +1,490 @@
package com.yihu.wlyy.service.kit;
import com.yihu.device.entity.DeviceDetail;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.kit.KitDrugDetail;
import com.yihu.wlyy.entity.kit.KitDrugUseRecord;
import com.yihu.wlyy.entity.kit.KitUseRemindRecord;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.health.repository.DeviceDetailDao;
import com.yihu.wlyy.repository.kit.KitDrugDetailDao;
import com.yihu.wlyy.repository.kit.KitDrugUseRecordDao;
import com.yihu.wlyy.repository.kit.KitUseRemindRecordDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.kit.JyKitService;
import com.yihu.wlyy.util.DateUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.*;
/**
 * Created by 刘文彬 on 2018/7/18.
 * i健康药盒
 */
@Service
public class KitService extends BaseService {
    @Autowired
    private JyKitService jyKitService;
    @Autowired
    private PatientService patientService;
    @Autowired
    private KitDrugDetailDao kitDrugDetailDao;
    @Autowired
    private KitDrugUseRecordDao kitDrugUseRecordDao;
    @Autowired
    private KitUseRemindRecordDao kitUseRemindRecordDao;
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    private String format = "yyyy-MM-dd HH:mm";
    private String format2 = "HH:mm" ;
    /**
     * 药盒绑定
     * @param deviceSn
     * @param type
     * @throws Exception
     */
    @Transactional
    public void kitBinding(String deviceSn,String type,String patientCode) throws Exception{
        Patient patient = patientService.findByCode(patientCode);
        JSONObject dataJSONStr = jyKitService.kitBinding(deviceSn,patient.getMobile(),type);
        PatientDevice patientDevice = null;
        if("1".equals(type)){
            //绑定成功,设备添加到device库
            String sn = dataJSONStr.getString("device_sn");//设备编码
            String deviceType = dataJSONStr.getString("device_type");//设备型号
            String maxAlarm = dataJSONStr.getString("max_alarm");//设备闹钟数
            String maxDrugs = dataJSONStr.getString("max_drugs");//设备药格数
            System.out.println("sn:"+sn+",deviceType:"+deviceType+",maxAlarm:"+maxAlarm+",maxDrugs:"+maxDrugs);
            //添加设备
            DeviceDetail deviceDetail = new DeviceDetail();
            deviceDetail.setDeviceModel(deviceType);//设备型号
            deviceDetail.setDeviceName("巨烨科技智能药盒");
            deviceDetail.setDeviceCode(sn);
            deviceDetail.setLinkman(patient.getName());
            String sql = " select f.* from wlyy_sign_family f where f.patient='"+patientCode+"' and f.status=1 ";
            List<Map<String, Object>> signFamilys1 = jdbcTemplate.queryForList(sql);
            if(signFamilys1.size()>0){
                deviceDetail.setOrgName(signFamilys1.get(0).get("hospital_name")+"");
                deviceDetail.setTel(patient.getMobile());
                deviceDetail.setGrantAdminTeam(signFamilys1.get(0).get("admin_team_code")+"");
                deviceDetail.setGrantOrgCode(signFamilys1.get(0).get("hospital")+"");
                deviceDetail.setGrantTime(new Date());
            }
            deviceDetail = deviceDetailDao.save(deviceDetail);
            patientDevice = new PatientDevice();
            patientDevice.setDeviceId(deviceDetail.getId());
            patientDevice.setDeviceSn(deviceDetail.getDeviceCode());
            patientDevice.setDeviceName(deviceDetail.getDeviceName());
            patientDevice.setUser(patientCode);
            patientDevice.setCategoryCode("3");
            patientDevice.setUserType("-1");
            patientDevice.setUserIdcard(patient.getIdcard());
            patientDevice.setCzrq(new Date());
        }else {
            List<PatientDevice> list = patientDeviceDao.findByDeviceSn(deviceSn);
            if(list.size()>0){
                patientDevice = list.get(0);
            }else{
                throw new Exception(" 数据库中没有该设备!");
            }
        }
        //添加绑定关系
//        PatientDevice patientDevice = new PatientDevice();
//        patientDevice.setDeviceId(deviceDetail.getId());
//        patientDevice.setDeviceSn(deviceDetail.getDeviceCode());
//        patientDevice.setDeviceName(deviceDetail.getDeviceName());
//        patientDevice.setUser(patientCode);
//        patientDevice.setCategoryCode("3");
//        patientDevice.setUserType("-1");
//        patientDevice.setUserIdcard(patient.getIdcard());
//        patientDevice.setCzrq(new Date());
        if("1".equals(type)){
            type="0";
        }else if("2".equals(type)){
            type="1";
        }
        patientDevice.setDel(Integer.valueOf(type));
        patientDeviceDao.save(patientDevice);
    }
    /**
     * 用药提醒
     * @param normalTime 居民计划用药时间
     * @param remindType 提醒类型(1、到点,2、超时,3、漏用)
     * @param deviveSn 药盒的sn码
     * @param kitAccountId 药盒账号id
     * @param drugDetail 药品清单json串
     */
    @Transactional
    public void drugUseRemind(String normalTime,String remindType,
                              String deviveSn,String kitAccountId,String drugDetail){
        //保存用药提醒记录
        Date currentTime = new Date();
        KitUseRemindRecord kitUseRemindRecord = new KitUseRemindRecord();
        kitUseRemindRecord.setCode(getCode());
        kitUseRemindRecord.setNormalTime(DateUtil.strToDate(normalTime, format));
        kitUseRemindRecord.setRemindType(Integer.valueOf(remindType));
        kitUseRemindRecord.setInsertTime(currentTime);
        kitUseRemindRecord.setKitAccountId(kitAccountId);
        DeviceDetail deviceDetail = deviceDetailDao.findBySn(deviveSn);
        kitUseRemindRecord.setDeviceModel(deviceDetail!=null?deviceDetail.getDeviceModel():null);//药盒型号
        kitUseRemindRecord.setDeviceSn(deviveSn);
        //根据药盒sn码和居民的绑定关系表,获取居民信息
        List<PatientDevice> patientDeviceList = patientDeviceDao.findByDeviceSn(deviveSn);
        if(patientDeviceList.size()>0){
            kitUseRemindRecord.setPatientCode(patientDeviceList.get(0).getUser());
            Patient patient = patientService.findByCode(patientDeviceList.get(0).getUser());
            kitUseRemindRecord.setPatientName(patient.getName());
        }
        kitUseRemindRecord.setDrugDetail(drugDetail);
        kitUseRemindRecordDao.save(kitUseRemindRecord);
        //保存药品清单信息
        JSONArray dataJSONStr = JSONArray.fromObject(drugDetail);
        List<KitDrugDetail> result = new ArrayList<KitDrugDetail>();
        for(int i =0; i<dataJSONStr.size();i++){
            KitDrugDetail kitDrugDetail = new KitDrugDetail();
            String drugName =  dataJSONStr.getJSONObject(i).getString("drugName");
            String measure = dataJSONStr.getJSONObject(i).getString("measure");
            String drugImgUrl = dataJSONStr.getJSONObject(i).getString("drugImgUrl");
            kitDrugDetail.setCode(getCode());
            kitDrugDetail.setDeviceSn(deviveSn);
            kitDrugDetail.setDrugName(drugName);
            kitDrugDetail.setUnit("粒");
            kitDrugDetail.setMeasure(measure);
            kitDrugDetail.setInsertTime(currentTime);
            kitDrugDetail.setRelationCode(kitUseRemindRecord.getCode());
            kitDrugDetail.setDrugImgUrl(drugImgUrl);
            kitDrugDetail.setType(2);//清单类型(1、用药记录药品清单、2、用药提醒药品清单)
            result.add(kitDrugDetail);
        }
        kitDrugDetailDao.save(result);
    }
    /**
     * 同步居民用药记录
     * @param useTime 居民用药时间
     * @param normalTime 居民计划用药时间
     * @param recordType 记录类型(1、手动,2、设备)
     * @param useDrugStatus 用药状态(1、按时,2、超时,3、漏用)
     * @param deviveSn 药盒的sn码
     * @param kitAccountId 药盒账号id
     * @param drugDetail 药品清单json串
     */
    @Transactional
    public void useDrugRecord(String useTime,String normalTime,String recordType,String useDrugStatus,
                              String deviveSn,String kitAccountId,String drugDetail) throws Exception{
        //保存用药信息
        Date currentTime = new Date();
        KitDrugUseRecord kitDrugUseRecord = new KitDrugUseRecord();
        kitDrugUseRecord.setCode(getCode());
        kitDrugUseRecord.setInsertTime(currentTime);
        kitDrugUseRecord.setUseTime(DateUtil.strToDate(useTime, format));
        kitDrugUseRecord.setNormalTime(DateUtil.strToDate(normalTime, format));
        kitDrugUseRecord.setRecordType(Integer.valueOf(recordType));
        kitDrugUseRecord.setUseDrugStatus(Integer.valueOf(useDrugStatus));
        kitDrugUseRecord.setDeviceSn(deviveSn);
        kitDrugUseRecord.setKitAccountId(kitAccountId);
        kitDrugUseRecord.setDrugDetail(drugDetail);
        //根据药盒sn码和居民的绑定关系表,获取居民信息
        List<PatientDevice> patientDeviceList = patientDeviceDao.findByDeviceSn(deviveSn);
        if(patientDeviceList.size()>0){
            kitDrugUseRecord.setPatientCode(patientDeviceList.get(0).getUser());
            Patient patient = patientService.findByCode(patientDeviceList.get(0).getUser());
            kitDrugUseRecord.setPatientName(patient.getName());
        }
        kitDrugUseRecord.setDrugDetail(drugDetail);
        kitDrugUseRecordDao.save(kitDrugUseRecord);
        //保存药品清单信息
        JSONArray dataJSONStr = JSONArray.fromObject(drugDetail);
        List<KitDrugDetail> result = new ArrayList<KitDrugDetail>();
        for(int i =0; i<dataJSONStr.size();i++){
            KitDrugDetail kitDrugDetail = new KitDrugDetail();
            String drugName =  dataJSONStr.getJSONObject(i).getString("drugName");
            String measure = dataJSONStr.getJSONObject(i).getString("measure");
            String drugImgUrl = dataJSONStr.getJSONObject(i).getString("drugImgUrl");
            kitDrugDetail.setCode(getCode());
            kitDrugDetail.setDeviceSn(deviveSn);
            kitDrugDetail.setDrugName(drugName);
            kitDrugDetail.setUnit("粒");
            kitDrugDetail.setMeasure(measure);
            kitDrugDetail.setInsertTime(currentTime);
            kitDrugDetail.setRelationCode(kitDrugUseRecord.getCode());
            kitDrugDetail.setDrugImgUrl(drugImgUrl);
            kitDrugDetail.setType(1);//清单类型(1、用药记录药品清单、2、用药提醒药品清单)
            result.add(kitDrugDetail);
        }
        kitDrugDetailDao.save(result);
    }
    /**
     * 获取居民的用药记录
     * @param patientCode 居民code
     * @param recordType 记录方式 1、手动,2、设备
     * @param startTime 时间搜索的开始时间
     * @param endTime 时间搜索的结束时间
     */
    public List<Map<String,Object>> getUseDrugRecordInfo(String patientCode,Integer recordType,String startTime,String endTime,Integer page,Integer pageSize) throws Exception{
        Date startDate = DateUtil.strToDate(startTime);
        Date endDate = DateUtil.strToDate(endTime);
        Specification specification = new Specification<KitDrugUseRecord>() {
            @Override
            public Predicate toPredicate(Root<KitDrugUseRecord> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
                List<Predicate> predicates = new ArrayList<>();
                predicates.add(criteriaBuilder.equal(root.get("patientCode"), patientCode));
                if(recordType!=null){
                    predicates.add(criteriaBuilder.equal(root.get("recordType"), recordType));
                }
                if(!StringUtils.isEmpty(startTime)){
                    predicates.add(criteriaBuilder.greaterThanOrEqualTo(root.get("useTime"), startDate));
                }
                if(!StringUtils.isEmpty(endTime)){
                    predicates.add(criteriaBuilder.lessThanOrEqualTo(root.get("useTime"), endDate));
                }
                criteriaQuery.orderBy(criteriaBuilder.desc(root.get("useTime")));//按时间降序排序
                criteriaQuery.where(criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()])));//条件
                return criteriaQuery.getRestriction();
            }
        };
        List<Map<String,Object>> reuslt = new ArrayList<>();
        List<KitDrugUseRecord> resutlList = null;
        if(page!=null&&pageSize!=null){
            page = page-1;
            Pageable pageRequest = new PageRequest(page, pageSize);
            Page<KitDrugUseRecord> resutlTemp = kitDrugUseRecordDao.findAll(specification,pageRequest);
            resutlList = resutlTemp.getContent();
//            return resutlList.getContent();
        }else{
            resutlList = kitDrugUseRecordDao.findAll(specification);
//            return resutlList;
        }
        for(KitDrugUseRecord one :resutlList){
            Map<String,Object> map = new HashMap<>();
            map.put("useTime",one.getUseTime());
            map.put("recordType",one.getRecordType());
            map.put("drugDetail",JSONArray.fromObject(one.getDrugDetail()));
            reuslt.add(map);
        }
        return reuslt;
    }
    /**
     * 获取某个居民的所绑定的所有药盒设备信息
     * @param patientCode
     */
    public List<Map<String,Object>> getAllKitDevice(String patientCode){
        List<PatientDevice> list = patientDeviceDao.findByPatientAndDel(patientCode);
        List<Map<String,Object>> result = new ArrayList<>();
        for(PatientDevice one:list){
            Map<String,Object> map = new HashMap<>();
            map.put("deviceSn",one.getDeviceSn());
            map.put("deviceName",one.getDeviceName());
            result.add(map);
        }
        return result;
    }
    /**
     * 统计分析--近期使用药品,药品用法
     * @param deviceSn
     * @return
     * @throws Exception
     */
    public Map<String,Object> drugUseRecordStatistics(String deviceSn) throws Exception{
        JSONArray dataJSONStr = jyKitService.getKitSetInfo(deviceSn);
        if(dataJSONStr.size()>0){
            JSONArray recentDrugInfo = dataJSONStr.getJSONObject(0).getJSONArray("drug_info");//近期使用药品
            JSONArray oneAlarmInfo = dataJSONStr.getJSONObject(0).getJSONArray("one_alarm_info");//一天的所有闹钟信息
            Map<String,Object> resultMap = new HashMap<>();
            List<JSONObject> list = new ArrayList<JSONObject> ();
            JSONObject jsonObj = null;
            resultMap.put("recentDrugInfo",recentDrugInfo);
            for (int i = 0; i < oneAlarmInfo.size(); i++) {
                jsonObj = (JSONObject)oneAlarmInfo.get(i);
                list.add(jsonObj);
            }
            //按闹钟时间排序
            Collections.sort(list, new Comparator<JSONObject>() {
                @Override
                public int compare(JSONObject o1, JSONObject o2) {
                    Long alarmTime1 =  DateUtil.strToDate(o1.get("alarm_time").toString(), format2).getTime();
                    Long alarmTime2 =  DateUtil.strToDate(o1.get("alarm_time").toString(), format2).getTime();
                    if(alarmTime1-alarmTime2>0){
                        return -1;
                    }else if(alarmTime1-alarmTime2<0){
                        return 1;
                    }
                    return 0;
                }
            });
            resultMap.put("oneAlarmInfo",list);
            return resultMap;
        }else{
            throw new Exception("请求的sn码巨烨无返回设备设置信息!");
        }
    }
    /**
     * 本月用药情况
     * @param useDrugStatus (1、按时,2、超时,3、漏用)
     */
    public Map<String,Object> currentMonthDrugUse(String patientCode,Integer useDrugStatus,String deviceSn) throws Exception{
        Map<String,Object> resultMap = new HashMap<>();
        Date monthStart = DateUtil.strToDate(DateUtil.getFristDayOfMonthThisDate(new Date()));
        Date monthEnd = new Date();
        Integer onTimeCount = kitDrugUseRecordDao.findStatisticsCount(patientCode,1,deviceSn,monthStart,monthEnd);//按时次数
        Integer overTimeCount = kitDrugUseRecordDao.findStatisticsCount(patientCode,2,deviceSn,monthStart,monthEnd);//超时次数
        Integer leakageCount = kitDrugUseRecordDao.findStatisticsCount(patientCode,3,deviceSn,monthStart,monthEnd);//漏用次数
        Specification specification = new Specification<KitDrugUseRecord>() {
            @Override
            public Predicate toPredicate(Root<KitDrugUseRecord> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
                List<Predicate> predicates = new ArrayList<>();
                predicates.add(criteriaBuilder.equal(root.get("patientCode"), patientCode));
                predicates.add(criteriaBuilder.greaterThanOrEqualTo(root.get("useTime"), monthStart));
                predicates.add(criteriaBuilder.lessThanOrEqualTo(root.get("useTime"), monthEnd));
                if(useDrugStatus!=null){
                    predicates.add(criteriaBuilder.equal(root.get("useDrugStatus"), useDrugStatus));
                }
                if(!StringUtils.isEmpty(deviceSn)){
                    predicates.add(criteriaBuilder.equal(root.get("deviceSn"), deviceSn));
                }
                criteriaQuery.orderBy(criteriaBuilder.desc(root.get("useDrugStatus")),criteriaBuilder.desc(root.get("useTime")));//按时间降序排序
                criteriaQuery.where(criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()])));//条件
                return criteriaQuery.getRestriction();
            }
        };
        List<KitDrugUseRecord> list  = kitDrugUseRecordDao.findAll(specification);
//        if(useDrugStatus==null){
//            list = kitDrugUseRecordDao.findStatistics(patientCode,deviceSn,monthStart,monthEnd);
//        }else{
//            list = kitDrugUseRecordDao.findStatistics(patientCode,useDrugStatus,deviceSn,monthStart,monthEnd);
//        }
        Map<String,Map<String,Object>> map = new LinkedHashMap<>();
        for(KitDrugUseRecord one:list){
            String dateStr = DateUtil.dateToStr(one.getUseTime(),"MM-dd");
            Map<String,Object> oneMap = null;
            if(map.containsKey(dateStr)){
                oneMap = map.get(dateStr);
            }else{
                oneMap = new LinkedHashMap<>();
            }
            Integer useDrugStatusTemp = one.getUseDrugStatus();
            if(oneMap.containsKey(useDrugStatusTemp.toString())){
                oneMap.put(useDrugStatusTemp.toString(),((Integer)oneMap.get(useDrugStatusTemp.toString()))+1);
            }else{
                if(!oneMap.isEmpty()){
                    continue;
                }
                oneMap.put(useDrugStatusTemp.toString(),1);
            }
            map.put(dateStr,oneMap);
        }
        List<Map<String,Object>> resultList = new ArrayList<>();
        for(String key:map.keySet()){
            Map<String,Object> temp = new HashMap<>();
            Map<String,Object> m = map.get(key);
            temp.put("day",key);
            for(String key2:m.keySet()){
                temp.put("statusType",key2);
                temp.put("count",m.get(key2));
            }
            resultList.add(temp);
        }
        //按用药日期排序
        Collections.sort(resultList, new Comparator<Map<String,Object>>() {
            @Override
            public int compare(Map<String,Object> o1, Map<String,Object> o2) {
                Long day1 =  DateUtil.strToDate(o1.get("day").toString(), "MM-dd").getTime();
                Long day2 =  DateUtil.strToDate(o2.get("day").toString(), "MM-dd").getTime();
                if(day1-day2>0){
                    return -1;
                }else if(day1-day2<0){
                    return 1;
                }
                return 0;
            }
        });
        resultMap.put("onTimeCount",onTimeCount);//按时
        resultMap.put("overTimeCount",overTimeCount);//超时
        resultMap.put("leakageCount",leakageCount);//漏用
        resultMap.put("resultList",resultList);
        return resultMap;
    }
    /**
     * 某天的用药记录
     * @param patientCode
     * @param useDrugStatus
     * @param deviceSn
     * @param date 某天的日期 格式:yyyy-MM-dd
     */
    public List<Map<String,Object>> oneDayDrugUse(String patientCode,Integer useDrugStatus,String deviceSn,String date) throws Exception{
        Date dayStart = DateUtil.strToDate(date+" 00:00:00");
        Date dayEnd = DateUtil.strToDate(date+" 23:59:59");
        Specification specification = new Specification<KitDrugUseRecord>() {
            @Override
            public Predicate toPredicate(Root<KitDrugUseRecord> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
                List<Predicate> predicates = new ArrayList<>();
                predicates.add(criteriaBuilder.equal(root.get("patientCode"), patientCode));
                predicates.add(criteriaBuilder.greaterThanOrEqualTo(root.get("useTime"), dayStart));
                predicates.add(criteriaBuilder.lessThanOrEqualTo(root.get("useTime"), dayEnd));
                if(useDrugStatus!=null){
                    predicates.add(criteriaBuilder.equal(root.get("useDrugStatus"), useDrugStatus));
                }
                if(!StringUtils.isEmpty(deviceSn)){
                    predicates.add(criteriaBuilder.equal(root.get("deviceSn"), deviceSn));
                }
                criteriaQuery.orderBy(criteriaBuilder.asc(root.get("useTime")));//按时间降序排序
                criteriaQuery.where(criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()])));//条件
                return criteriaQuery.getRestriction();
            }
        };
        List<KitDrugUseRecord> list  = kitDrugUseRecordDao.findAll(specification);
        List<Map<String,Object>> resultList = new ArrayList<>();
        for(KitDrugUseRecord one:list){
            Map<String,Object> temp = new HashMap<>();
            temp.put("useTime",DateUtil.dateToStr(one.getUseTime(),"HH:mm"));
            temp.put("drugDetail",JSONArray.fromObject(one.getDrugDetail()));
            resultList.add(temp);
        }
        return resultList;
    }
}

+ 233 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/kit/JyKitService.java

@ -0,0 +1,233 @@
package com.yihu.wlyy.service.third.kit;
import com.yihu.device.entity.DeviceDetail;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.health.repository.DeviceDetailDao;
import com.yihu.wlyy.util.HttpClientUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
 * Created by 刘文彬 on 2018/7/18.
 * 巨烨药盒接口
 */
@Service
public class JyKitService {
    @Value("${juye.companyCode}")
    private String companyCode;
    @Value("${juye.url}")
    private String jyUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private StringRedisTemplate redisTemplate;
    private String timeTermRedisKey = "juye:getToken:time_term";
    private String tokenRedisKey = "juye:getToken:token";
    /****************************************接口路径 start**************************************************/
    private String kitBinding = "companyBindDevice";//药盒绑定接口
    private String getKitSetInfo = "getInfoByDeviceSn";//获取药盒设置信息接口
    private String getKitToken = "getToken";//获取巨烨token
    /****************************************接口路径 end**************************************************/
    /**
     * 设备绑定
     * @param deviceSn
     * @param tel
     * @param type
     * @throws Exception
     */
    public JSONObject kitBinding(String deviceSn,String tel,String type) throws Exception{
        String token = tokenExpire();//获取token
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("token", token));
        params.add(new BasicNameValuePair("device_sn", deviceSn));
        params.add(new BasicNameValuePair("tel", tel));
        params.add(new BasicNameValuePair("type", type));
        String response = getRequestPost(params,jyUrl+kitBinding);
        JSONObject returnJson = JSONObject.fromObject(response);
        if (!"200".equals(returnJson.getString("code"))) {
            returnStatus(returnJson.getString("code"));
        }
        if("2".equals(type)){//解绑就不解析data数据
            return new JSONObject();
        }
        JSONObject dataJSONStr = null ;
        if (returnJson.containsKey("data")) {
            dataJSONStr = returnJson.getJSONObject("data");//返回设备信息
            return dataJSONStr;
        }
        throw new Exception("jy kitBinding error data not ");
    }
    /**
     * 获取智能药盒的设置情况
     * 1、当前使用药品清单,应包含药品名称、药品编码。
     * 2、当前设置用药提醒(用药方式):用药时间、药品清单(药品名称、药品编码、使用计量)。
     * @param deviceSn 多个sn以“,”分隔
     * @throws Exception
     */
    public JSONArray getKitSetInfo(String deviceSn) throws Exception{
        String token = tokenExpire();//获取token
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("token", token));
        params.add(new BasicNameValuePair("device_sn", deviceSn));
        String response = getRequestPost(params,jyUrl+getKitSetInfo);
        JSONObject returnJson = JSONObject.fromObject(response);
        if (!"200".equals(returnJson.getString("code"))) {
            returnStatus(returnJson.getString("code"));
        }
        JSONArray dataJSONStr = null ;
        if (returnJson.containsKey("data")) {
            dataJSONStr = returnJson.getJSONArray("data");//多个设备信息
            return dataJSONStr;
        }else {
            throw new Exception("jy kitInfo error not data");
        }
    }
    /**
     * 解析智能药盒的设置情况返回的data数据
     * @param deviceSn 多个sn以“,”分隔
     */
    public void analysisKitSetInfo(String deviceSn) throws Exception{
        JSONArray dataJSONStr = getKitSetInfo(deviceSn);
        for(int i=0 ;i<dataJSONStr.size();i++){
//            JSONObject drugInfo = dataJSONStr.getJSONObject(i).getJSONObject("drug_info");//当前药品信息,即处方信息
            JSONArray recentDrugInfo = dataJSONStr.getJSONObject(i).getJSONArray("drug_info");//近期使用的药品
            JSONArray alarmInfo = dataJSONStr.getJSONObject(i).getJSONArray("alarm_info");//闹钟信息(设置的全部闹钟列表),即当前用药详情
            JSONObject oneAlarmInfo = dataJSONStr.getJSONObject(i).getJSONObject("one_alarm_info");//一天的所有闹钟信息
            for(int j=0 ;j<alarmInfo.size();j++){
                JSONArray drugs = alarmInfo.getJSONObject(j).getJSONArray("drugs");//某个闹钟药品信息列表
                String alarmTime = alarmInfo.getJSONObject(j).getString("alarm_time");
                for(int k=0 ;k<drugs.size();k++){
                    String drugName = drugs.getJSONObject(k).getString("drug_name");
                    String drugAmount = drugs.getJSONObject(k).getString("drug_amount");
                    String drugImgUrl = drugs.getJSONObject(k).getString("drug_imgurl");
                }
            }
        }
    }
    /**
     * 获取巨烨的token
     */
    public String getJuyeToken() throws Exception{
        List<NameValuePair> params = new ArrayList<>();
        String response = getRequestPost(params,jyUrl+getKitToken);
        JSONObject returnJson = JSONObject.fromObject(response);
        if (!"200".equals(returnJson.getString("code"))) {
            returnStatus(returnJson.getString("code"));
        }
        String token = null;
        JSONObject dataJSONStr = null ;
        if (returnJson.containsKey("data")) {
            dataJSONStr = returnJson.getJSONObject("data");
            token = dataJSONStr.getString("token");//token
            String timeTerm = dataJSONStr.getString("time_term");//token过期时间戳
            Long temp = new Date().getTime()/1000;
            Long overTime = Long.valueOf(timeTerm) - temp;
            //存储在redis中
            redisTemplate.opsForValue().set(timeTermRedisKey,timeTerm,overTime,TimeUnit.SECONDS);
            redisTemplate.opsForValue().set(tokenRedisKey,token,overTime,TimeUnit.SECONDS);
        }else {
            throw new Exception("jy kitInfo error not data");
        }
        return token;
    }
    /**
     * 判断巨烨token是否过期,有效则返回token,否则返回null
     * @return
     */
    public String tokenExpire() throws Exception{
       String timeTerm = redisTemplate.opsForValue().get(timeTermRedisKey);
       String token = null;
       if(StringUtils.isEmpty(timeTerm)){
           token = getJuyeToken();
           return token;
       }
       Long timeTermLong = Long.valueOf(timeTerm);
       if(new Date().getTime()>timeTermLong){
           token = redisTemplate.opsForValue().get(tokenRedisKey);
           return token;
       }else{
           token = getJuyeToken();
           return token;
       }
    }
    /**
     * post请求
     * @param params
     * @param url
     * @return
     * @throws Exception
     */
    public String getRequestPost(List<NameValuePair> params,String url) throws Exception{
        params.add(new BasicNameValuePair("company_code", companyCode));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * get请求
     * @param params
     * @param url
     * @return
     * @throws Exception
     */
    public String getRequestGet(List<NameValuePair> params,String url) throws Exception{
        String paramStr="?company_code="+companyCode;
        for(NameValuePair one : params){
            paramStr += "&"+one.getName()+"="+one.getValue();
        }
        String response = httpClientUtil.get(url+paramStr,  "UTF-8");
        return response;
    }
    /**
     * 巨烨返回的错误code解析
     * @param code
     * @throws Exception
     */
    public void returnStatus(String code) throws Exception{
        //当秘钥token错误的时候,重新请求获取新的token,下次请求就可以
        if("601".equals(code)){
            this.getJuyeToken();
        }
        switch (code){
            case "601": {throw new Exception("601 秘钥错误");}
            case "602": {throw new Exception("602 设备编码为空");}
            case "603": {throw new Exception("603 设备编码位数不对,正确的为19位字符串(utf-8)");}
            case "604": {throw new Exception("604 设备不存在");}
            case "605": {throw new Exception("605 设备已存在于企业设备列表");}
            case "606": {throw new Exception("606 企业编码为空");}
            case "607": {throw new Exception("607 操作类型参数错误,1绑定,2解绑");}
            case "608": {throw new Exception("608 此设备不属于当前企业");}
            case "701": {throw new Exception("701 存在不属于企业的设备编码");}
            case "702": {throw new Exception("702 无效的企业编码");}
            case "703": {throw new Exception("703 秘钥失效");}
        }
    }
}

+ 105 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/kit/DoctorKitController.java

@ -0,0 +1,105 @@
package com.yihu.wlyy.web.doctor.kit;
import com.yihu.wlyy.entity.kit.KitDrugUseRecord;
import com.yihu.wlyy.service.kit.KitService;
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;
import java.util.List;
import java.util.Map;
/**
 * Created by 刘文彬 on 2018/7/25.
 */
@RestController
@RequestMapping(value = "/doctor/kit", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "药盒医生端")
public class DoctorKitController extends BaseController {
    @Autowired
    private KitService kitService;
    @RequestMapping(value = "/getUseDrugRecordInfo", method = RequestMethod.GET)
    @ApiOperation("获取居民的用药记录")
    public String getUseDrugRecordInfo(
            @ApiParam(name = "patientCode", value = "居民code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode,
            @ApiParam(name = "recordType", value = "记录方式 1、手动,2、设备", required = false) @RequestParam(value = "recordType", required = false) Integer recordType,
            @ApiParam(name = "startTime", value = "时间搜索的开始时间", required = false) @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "时间搜索的结束时间", required = false) @RequestParam(value = "endTime", required = false) String endTime,
            @ApiParam(name = "page", value = "起始页数", required = false) @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "pageSize", value = "每页总数", required = false) @RequestParam(value = "pageSize", required = false) Integer pageSize){
        try {
            List<Map<String,Object>> result = kitService.getUseDrugRecordInfo(patientCode,recordType,startTime,endTime,page,pageSize);
            return write(200,"获取信息成功!","data",result);
        }catch (Exception e) {
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
    @RequestMapping(value = "/drugUseRecordStatistics", method = RequestMethod.GET)
    @ApiOperation("药盒统计分析--近期使用药品,药品用法")
    public String drugUseRecordStatistics(
            @ApiParam(name = "deviceSn", value = "药盒设备sn码", required = true) @RequestParam(value = "deviceSn", required = true) String deviceSn){
        try {
            Map<String,Object> result =  kitService.drugUseRecordStatistics(deviceSn);
            return write(200,"获取信息成功!","data",result);
        }catch (Exception e) {
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
    @RequestMapping(value = "/currentMonthDrugUse", method = RequestMethod.GET)
    @ApiOperation("药盒统计分析--本月用药情况")
    public String currentMonthDrugUse(
            @ApiParam(name = "patientCode", value = "居民code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode,
            @ApiParam(name = "useDrugStatus", value = "居民用药记录情况(1、按时,2、超时,3、漏用)", required = false) @RequestParam(value = "useDrugStatus", required = false) Integer useDrugStatus,
            @ApiParam(name = "deviceSn", value = "药盒设备sn码", required = false) @RequestParam(value = "deviceSn", required = false) String deviceSn){
        try {
            Map<String,Object> result =  kitService.currentMonthDrugUse(patientCode,useDrugStatus,deviceSn);
            return write(200,"获取信息成功!","data",result);
        }catch (Exception e) {
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
    @RequestMapping(value = "/getAllKitDevice", method = RequestMethod.GET)
    @ApiOperation("药盒统计分析--获取某个居民的所绑定的所有药盒设备信息")
    public String getAllKitDevice(
            @ApiParam(name = "patientCode", value = "居民code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode){
        try {
            List<Map<String,Object>> result =  kitService.getAllKitDevice(patientCode);
            return write(200,"获取信息成功!","data",result);
        }catch (Exception e) {
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
    @RequestMapping(value = "/oneDayDrugUse", method = RequestMethod.GET)
    @ApiOperation("药盒统计分析--获取某个居民的所绑定的所有药盒设备信息")
    public String oneDayDrugUse(
            @ApiParam(name = "patientCode", value = "居民code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode,
            @ApiParam(name = "useDrugStatus", value = "居民用药记录情况(1、按时,2、超时,3、漏用)", required = false) @RequestParam(value = "useDrugStatus", required = false) Integer useDrugStatus,
            @ApiParam(name = "deviceSn", value = "药盒设备sn码", required = false) @RequestParam(value = "deviceSn", required = false) String deviceSn,
            @ApiParam(name = "date", value = "某天的日期 格式:yyyy-MM-dd", required = true) @RequestParam(value = "date", required = true) String date){
        try {
            List<Map<String,Object>> result =  kitService.oneDayDrugUse(patientCode,useDrugStatus,deviceSn,date);
            return write(200,"获取信息成功!","data",result);
        }catch (Exception e) {
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
}

+ 156 - 90
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java

@ -4,6 +4,7 @@ import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.app.sign.SignWebService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.jw.JwSignService;
@ -53,20 +54,22 @@ public class DoctorSignController extends WeixinBaseController {
    StringRedisTemplate redisTemplate;
    @Autowired
    private PatientService patientService;
    @Autowired
    private FamilyContractService familyContractService;
    @RequestMapping(value = "getPatientFamilyServer",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取居民慢病服务类型")
    public String getPatientFamilyServer(@ApiParam(name = "patient", value = "居民code") @RequestParam(required = true) String patient){
    public String getPatientFamilyServer(@ApiParam(name = "patient", value = "居民code") @RequestParam(required = true) String patient) {
        try {
            JSONObject json = signWebService.getPatientFamilyServer(patient);
            if(json.has("msg")){
                return error(-1,json.getString("msg"));
            if (json.has("msg")) {
                return error(-1, json.getString("msg"));
            }
            return write(200,"获取成功","data",json);
        }catch (Exception e){
            return write(200, "获取成功", "data", json);
        } catch (Exception e) {
            error(e);
            return error(-1,"请求失败");
            return error(-1, "请求失败");
        }
    }
@ -127,14 +130,14 @@ public class DoctorSignController extends WeixinBaseController {
            String doctor = getUID();
            Page<Object> page = infoService.findPatientByDoctorSign(doctor, id, pagesize, patientName);
            JSONArray array = new JSONArray();
            Map<Object,Object> exitMap = new HashMap<>();
            Map<Object, Object> exitMap = new HashMap<>();
            if (page != null) {
                for (Object obj : page) {
                    Object[] temp = (Object[]) obj;
                    if (temp == null) {
                        continue;
                    }
                    if(exitMap.get(temp[9])!=null){//防止患者既有三师签约也有家庭签约导致数据重复
                    if (exitMap.get(temp[9]) != null) {//防止患者既有三师签约也有家庭签约导致数据重复
                        continue;
                    }
                    JSONObject json = new JSONObject();
@ -159,7 +162,7 @@ public class DoctorSignController extends WeixinBaseController {
                    //患者联系方式
                    json.put("mobile", temp[10]);
                    array.put(json);
                    exitMap.put(temp[9],temp);
                    exitMap.put(temp[9], temp);
                }
            }
            return write(200, "查询成功!", "list", array);
@ -229,12 +232,14 @@ public class DoctorSignController extends WeixinBaseController {
     */
    @RequestMapping("/sign_info")
    public String getSignInfoByDoctor(
            @RequestParam(required = false)Integer status,
            @RequestParam(required = false)Integer doctorType,
            @RequestParam(required = false)Integer page,
            @RequestParam(required = false)Integer pageSize) {
        try {page = page > 0 ? page -1 : 0;
            List<Map<String, Object>> listSign = signWebService.getSignWebByDoctor(getUID(), status, page, pageSize);
            @RequestParam(required = false) Integer status,
            @RequestParam(required = false) Integer doctorType,
            @RequestParam(required = false) String patientInfo,
            @RequestParam(required = false) Integer page,
            @RequestParam(required = false) Integer pageSize) {
        try {
            page = page > 0 ? page -1 : 0;
            List<Map<String, Object>> listSign = signWebService.getSignWebByDoctor(getUID(), status, patientInfo, page, pageSize);
            JSONObject data = new JSONObject();
            List<JSONObject> jsonArray = new ArrayList<>();
@ -249,6 +254,7 @@ public class DoctorSignController extends WeixinBaseController {
                    json.put("doctorCode", temp.get("doctor"));
                    json.put("patientCode", temp.get("patient"));
                    json.put("patientName", temp.get("name"));
                    json.put("mobile", temp.get("mobile"));
                    json.put("age", IdCardUtil.getAgeForIdcard(String.valueOf(temp.get("idcard"))));
                    json.put("provinceName", temp.get("provinceName"));
                    json.put("cityName", temp.get("cityName"));
@ -296,7 +302,7 @@ public class DoctorSignController extends WeixinBaseController {
                    if (status == 3) {
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.hasKey("wechat:focus:remind:flag:"+temp.get("patient"));
                            epTime = redisTemplate.hasKey("wechat:focus:remind:flag:" + temp.get("patient"));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
@ -339,12 +345,12 @@ public class DoctorSignController extends WeixinBaseController {
    @RequestMapping("/sign_info_count")
    @ApiOperation(value = "签约居民数目")
    public String getSignWebByDoctorCount(){
        try{
    public String getSignWebByDoctorCount() {
        try {
            //hxmD201703150222
            return write(200,"查询成功","data",signWebService.getSignWebByDoctorCount(getUID()));
        }catch (Exception e){
            return error(-1,"查询失败");
            return write(200, "查询成功", "data", signWebService.getSignWebByDoctorCount(getUID()));
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
    }
@ -355,11 +361,11 @@ public class DoctorSignController extends WeixinBaseController {
     */
    @RequestMapping(value = "/is_remind_focus_all")
    @ApiOperation(value = "今天是否已全部提醒关注")
    public String isRemindFocusAllToday(){
        try{
            return write(200,"查询成功","data",signWebService.isRemindFocusAll(getUID()));
        }catch (Exception e){
            return error(-1,"查询失败");
    public String isRemindFocusAllToday() {
        try {
            return write(200, "查询成功", "data", signWebService.isRemindFocusAll(getUID()));
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
    }
@ -370,29 +376,29 @@ public class DoctorSignController extends WeixinBaseController {
     */
    @RequestMapping(value = "/is_remind_expenses_all")
    @ApiOperation(value = "今天是否已全部提醒缴费")
    public String isRemindFExpensesAllToday(){
        try{
            return write(200,"查询成功","data",signWebService.isRemindExpensesAll(getUID()));
        }catch (Exception e){
    public String isRemindFExpensesAllToday() {
        try {
            return write(200, "查询成功", "data", signWebService.isRemindExpensesAll(getUID()));
        } catch (Exception e) {
            error(e);
            return error(-1,"查询失败");
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取续签约患者信息
     *
     * @param status     签约状态 1:待签约 2 待缴费 3 已签约
     * @param status 签约状态 1:待签约 2 待缴费 3 已签约
     * @return
     */
    @RequestMapping("/sign_info_renew")
    @ApiOperation(value = "医生获取获取列表")
    public String getSignRenewInfoByDoctor(
            @RequestParam(required = true)int status,
            @RequestParam(required = true)int page,
            @RequestParam(required = true)int pageSize) {
            @RequestParam(required = true) int status,
            @RequestParam(required = true) int page,
            @RequestParam(required = true) int pageSize) {
        try {
            page = page > 0 ? page -1 : 0;
            page = page > 0 ? page - 1 : 0;
            List<Map<String, Object>> listSign = signWebService.getSignRenewWebByDoctor(getUID(), status, page, pageSize);
            //List<Map<String, Object>> listSign = signWebService.getSignRenewWebByDoctor("64de930c-5b15-11e6-8344-fa163e8aee56", status, page, pageSize);
            JSONObject data = new JSONObject();
@ -417,7 +423,7 @@ public class DoctorSignController extends WeixinBaseController {
                    json.put("status", temp.get("status"));
                    json.put("openid", temp.get("openid"));
                    json.put("renewTime", temp.get("czrq"));
                    json.put("renewFlag",temp.get("renewFlag"));
                    json.put("renewFlag", temp.get("renewFlag"));
                    String statusName = "";
                    switch (Integer.parseInt(temp.get("status").toString())) {
                        case 0:
@ -453,24 +459,25 @@ public class DoctorSignController extends WeixinBaseController {
    /**
     * 批量提醒居民续签
     *
     * @return
     */
    @RequestMapping("/sendRenewToPatients")
    @ApiOperation(value = "提醒用户签约接口")
    @ObserverRequired
    public String sendRenewToPatients(){
        try{
            int rs ;
            if(DateUtil.getNowMonth()>=7){
                rs = signWebService.sendRenewOverToPatients(getAccessToken(),getUID());
            }else{
                rs = signWebService.sendRenewToPatients(getAccessToken(),getUID());
    public String sendRenewToPatients() {
        try {
            int rs;
            if (DateUtil.getNowMonth() >= 7) {
                rs = signWebService.sendRenewOverToPatients(getAccessToken(), getUID());
            } else {
                rs = signWebService.sendRenewToPatients(getAccessToken(), getUID());
            }
            //int rs = signWebService.sendRenewToPatients(getAccessToken(),"zbqD201703150222");
            if(rs == 0){
            if (rs == 0) {
                return write(200, "您当前签约用户无需提醒!", "data", rs);
            }else{
            } else {
                return write(200, "提醒成功!", "data", rs);
            }
        }catch (Exception e){
@ -481,18 +488,18 @@ public class DoctorSignController extends WeixinBaseController {
    /**
     * 同意或拒绝
     *
     * @param state
     * @param refuseReason 医生拒签原因
     *
     * @return
     */
    @RequestMapping("/agreeRenew")
    @ApiOperation(value = "医生处理签约")
    @ObserverRequired
    public String agreeRenew(@RequestParam(required = true)String state,
                             @RequestParam(required = true)String patient,
    public String agreeRenew(@RequestParam(required = true) String state,
                             @RequestParam(required = true) String patient,
                             @RequestParam(required = false) Long mesId,
                             @RequestParam(required = false)String signCode,
                             @RequestParam(required = false) String signCode,
                             @RequestParam(required = false) String health,
                             @RequestParam(required = false) String disease,
                             @RequestParam(required = false) String custom,
@ -500,16 +507,16 @@ public class DoctorSignController extends WeixinBaseController {
                             @RequestParam(required = false) String healthDoctor,
                             @RequestParam(required = false) Long teamCode,
                             @RequestParam(required = false) String expenses,
                             @RequestParam(required = false) String refuseReason){
        try{
                             @RequestParam(required = false) String refuseReason) {
        try {
            //屏蔽了预签约
            int rs = 0;
            rs =signWebService.agreeRenewOverDue(getAccessToken(),getUID(),patient,state,mesId,"",signCode,health,disease,custom,sevId,healthDoctor,teamCode,expenses,refuseReason);
            if(rs != 1){
            rs = signWebService.agreeRenewOverDue(getAccessToken(), getUID(), patient, state, mesId, "", signCode, health, disease, custom, sevId, healthDoctor, teamCode, expenses, refuseReason);
            if (rs != 1) {
                //设置代码为已读
                signWebService.setMessState(mesId);
                return  write(200, "未找到签约记录", "data", rs);
            }else{
                return write(200, "未找到签约记录", "data", rs);
            } else {
                return write(200, "操作成功!", "data", rs);
            }
@ -544,7 +551,7 @@ public class DoctorSignController extends WeixinBaseController {
//            }else{
//                return write(200, "操作成功!", "data", rs);
//            }
        }catch (Exception e){
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
@ -590,19 +597,19 @@ public class DoctorSignController extends WeixinBaseController {
//    }
    /**
     *
     *统计
     * 统计
     * 咨询量、获取待预约、获取健康教育、获取健康指导
     *
     * @return
     */
    @RequestMapping("/getSignCountInfoInYear")
    @ApiOperation(value = "统计咨询量、获取待预约、获取健康教育、获取健康指导")
    public String getSignCountInfoInYear(@RequestParam(required = true)String patient){
        try{
            JSONObject rs =signWebService.getSignCountInfoInYear(patient);
    public String getSignCountInfoInYear(@RequestParam(required = true) String patient) {
        try {
            JSONObject rs = signWebService.getSignCountInfoInYear(patient);
            //JSONObject rs =signWebService.getRenewYearCount("64de930c-5b15-11e6-8344-fa163e8aee56");
            return write(200, "操作成功!", "data", rs);
        }catch (Exception e){
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
@ -611,19 +618,19 @@ public class DoctorSignController extends WeixinBaseController {
    @RequestMapping("/remindPatientRenew")
    @ApiOperation(value = "提醒居民续签")
    @ObserverRequired
    public String remindPatientRenew(@RequestParam(required = true)String patient){
        try{
            int rs =signWebService.remainPatientRenew(getAccessToken(),patient,getUID());
    public String remindPatientRenew(@RequestParam(required = true) String patient) {
        try {
            int rs = signWebService.remainPatientRenew(getAccessToken(), patient, getUID());
            //int rs =signWebService.remainPatientRenew(getAccessToken(),patient,"zbqD201703150222");
            if(rs==-1){
            if (rs == -1) {
                return error(-1, "提醒失败");
            }else if(rs ==1){
            } else if (rs == 1) {
                return write(200, "微信提醒成功!", "data", rs);
            }else if(rs ==2){
            } else if (rs == 2) {
                return write(200, "短信提醒成功!", "data", rs);
            }
            return error(-1, "提醒失败");
        }catch (Exception e){
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
@ -631,12 +638,13 @@ public class DoctorSignController extends WeixinBaseController {
    /**
     * 验证是否允许签约
     *
     * @param patient
     * @return
     */
    @RequestMapping(value = "/checkCanRenew", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String checkCanRenew(@RequestParam(required = true) String patient){
    public String checkCanRenew(@RequestParam(required = true) String patient) {
        try {
            //JSONObject result = patientService.checkCanSignRenew(patient);
            JSONObject result = patientService.checkCanRenewNew(patient);
@ -649,11 +657,12 @@ public class DoctorSignController extends WeixinBaseController {
    /**
     * 获取签约字典数据
     *
     * @return
     */
    @RequestMapping(value = "/getSigndict", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String getSigndict(@RequestParam(required = false) String signYear){
    public String getSigndict(@RequestParam(required = false) String signYear) {
        try {
            JSONArray result = patientService.getSigndict(signYear);
            return write(200, "查询成功", "data", result);
@ -665,11 +674,12 @@ public class DoctorSignController extends WeixinBaseController {
    /**
     * 获取签约字典数据
     *
     * @return
     */
    @RequestMapping(value = "/getSigndictTree", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String getSigndictTree(@RequestParam(required = true) Long teamCode){
    public String getSigndictTree(@RequestParam(required = true) Long teamCode) {
        try {
            JSONArray result = patientService.getSignByTeamCodeGpbyServer(teamCode);
            return write(200, "查询成功", "data", result);
@ -681,13 +691,14 @@ public class DoctorSignController extends WeixinBaseController {
    /**
     * 获取当前医生签约关系分组
     *
     * @return
     */
    @RequestMapping(value = "/getSignByDoctorCodeGpbyServer", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String getSignByDoctorCodeGpbyServer(){
    public String getSignByDoctorCodeGpbyServer() {
        try {
            JSONArray result = patientService.getSignByDoctorCodeGpbyServer(getUID(),null, false, "");
            JSONArray result = patientService.getSignByDoctorCodeGpbyServer(getUID(), null, false, "");
            //JSONArray result = patientService.getSignByDoctorCodeGpbyServer("xh1D201703150222");
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
@ -697,12 +708,13 @@ public class DoctorSignController extends WeixinBaseController {
    }
    /**
     *  获取团队名称
     * 获取团队名称
     *
     * @return
     */
    @RequestMapping(value = "/getTeamNameByTeamCode", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String getTeamNameByTeamCode(@RequestParam(required = true) Long teamCode){
    public String getTeamNameByTeamCode(@RequestParam(required = true) Long teamCode) {
        try {
            String result = patientService.getTeamNameByTeamCode(teamCode);
            return write(200, "查询成功", "data", result);
@ -713,7 +725,7 @@ public class DoctorSignController extends WeixinBaseController {
    @RequestMapping(value = "/getPatientSignLogInfo", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String getPatientSignLogInfo(@RequestParam(required = true)String patient){
    public String getPatientSignLogInfo(@RequestParam(required = true) String patient) {
        try {
            JSONObject result = signWebService.getPatientSignLogInfo(patient);
            return write(200, "查询成功", "data", result);
@ -725,12 +737,12 @@ public class DoctorSignController extends WeixinBaseController {
    @RequestMapping(value = "/updateSignServerByCode", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    @ObserverRequired
    public String updateSignServerByCode(@RequestParam(required = true)String signCode,@RequestParam(required = true)String sevId){
    public String updateSignServerByCode(@RequestParam(required = true) String signCode, @RequestParam(required = true) String sevId) {
        try {
            int result = signWebService.updateSignServerByCode(signCode,sevId);
            if(result==1){
            int result = signWebService.updateSignServerByCode(signCode, sevId);
            if (result == 1) {
                return write(200, "保存成功", "data", result);
            }else{
            } else {
                return write(200, "保存失败", "data", result);
            }
        } catch (Exception e) {
@ -741,11 +753,12 @@ public class DoctorSignController extends WeixinBaseController {
    /**
     * 获取厦门市区
     *
     * @return
     */
    @RequestMapping(value = "/getTownList", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String getTownList(){
    public String getTownList() {
        try {
            return write(200, "查询成功", "data", signWebService.getTownList());
        } catch (Exception e) {
@ -756,12 +769,13 @@ public class DoctorSignController extends WeixinBaseController {
    /**
     * 获取区域下街道
     *
     * @param town
     * @return
     */
    @RequestMapping(value = "/getStreetListByTown", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String getStreetListByTown(@RequestParam(required = true)String town){
    public String getStreetListByTown(@RequestParam(required = true) String town) {
        try {
            return write(200, "查询成功", "data", signWebService.getStreetListByTown(town));
        } catch (Exception e) {
@ -773,12 +787,13 @@ public class DoctorSignController extends WeixinBaseController {
    /**
     * 获取街道下居委会
     *
     * @param street
     * @return
     */
    @RequestMapping(value = "/getCountryListByStreet", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String getCountryListByStreet(@RequestParam(required = true)String street){
    public String getCountryListByStreet(@RequestParam(required = true) String street) {
        try {
            return write(200, "查询成功", "data", signWebService.getCountryListByStreet(street));
        } catch (Exception e) {
@ -789,35 +804,86 @@ public class DoctorSignController extends WeixinBaseController {
    /**
     * 获取居委会字段
     *
     * @param countryCode
     * @return
     */
    @RequestMapping(value = "/updatePatientCountry", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String setPatientCountry(@RequestParam(required = true)String countryCode){
    public String setPatientCountry(@RequestParam(required = true) String countryCode) {
        try {
            return write(200, "保存成功", "data", signWebService.setPatientCountry(countryCode,getRepUID()));
            return write(200, "保存成功", "data", signWebService.setPatientCountry(countryCode, getRepUID()));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    
    /**
     * 根据身份证号同步居民签约信息
     *
     * @param idcard
     * @return
     */
    @RequestMapping(value = "/loadSignFamilyByIdcard", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String loadSignFamilyByIdcard(@RequestParam(required = true)String idcard){
    public String loadSignFamilyByIdcard(@RequestParam(required = true) String idcard) {
        try {
            String re = jwSignService.LoadSignFamilyByIdcard(idcard);
            Patient patient = patientService.findByIdcard(idcard);
            return write(200, "更新签约成功","patient",patient);
            return write(200, "更新签约成功", "patient", patient);
        } catch (Exception e) {
            error(e);
            return error(-1, "更新签约失败!");
        }
    }
    @RequestMapping(value = "/findPatientCertificate", method = {RequestMethod.GET})
    @ResponseBody
    @ApiOperation("获取居民服务类型凭证")
    public String findPatientCertificate(@ApiParam(name = "patient", value = "居民code") @RequestParam(required = true)String patient) {
        try {
            return write(200, "查询成功", "data", signWebService.findPatientCertificate(patient));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/findPatientCertificateByType", method = {RequestMethod.GET})
    @ResponseBody
    @ApiOperation("获取居民服务类型凭证")
    public String findPatientCertificate(@ApiParam(name = "patient", value = "居民code") @RequestParam(required = true)String patient,
                                         @ApiParam(name = "type", value = "服务类型code") @RequestParam(required = true)String type) {
        try {
            return write(200, "查询成功", "data", signWebService.findByPatientAndSignYearAndDelAndSignDictCode(patient,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping("/getSignDict")
    @ApiOperation(value = "获取当前年度服务类型")
    @ResponseBody
    public String getSignDict() {
        try{
            return write(200, "操作成功!", "data", familyContractService.getSignDict());
        }catch (Exception e){
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping("/findPatientSignServerBySignCode")
    @ApiOperation(value = "获取患者申请的服务类型")
    @ResponseBody
    public String findPatientSignServerBySignCode(String signCode){
        try{
            return write(200, "操作成功!", "data", familyContractService.findPatientSignServerBySignCode(signCode));
        }catch (Exception e){
            error(e);
            return error(-1, "请求失败");
        }
    }
}

+ 10 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java

@ -174,10 +174,16 @@ public class AdminTeamController extends BaseController {
    @ApiOperation(value = "获取团队成员")
    public String getTeamMembers(@PathVariable("team_id") long teamId) {
        try {
            List<Doctor> members = memberService.getMembers(teamId);
            return write(200, "OK", "data", new JSONArray(copyBeans(members, "id", "code", "name", "hospital",
                    "jobName", "level", "sex", "photo")));
            List<Object[]> members = memberService.findMembers(teamId);
            List<Map<String,Object>> list = new ArrayList<>();
            Map<String, Object> map = new HashMap();
            for(Object[] member : members){
                map = copyBeanProperties(member[0], "id", "code", "name", "hospital", "jobName", "level", "sex", "photo");
                map.put("available",member[1]);
                map.put("count",member[2]);
                list.add(map);
            }
            return write(200, "OK", "data", new JSONArray(list));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());

+ 44 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/kit/PatientKitController.java

@ -0,0 +1,44 @@
package com.yihu.wlyy.web.patient.kit;
import com.yihu.wlyy.service.kit.KitService;
import com.yihu.wlyy.service.third.kit.JyKitService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by 刘文彬 on 2018/7/18.
 */
@RestController
@RequestMapping(value = "/patient/kit", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "药盒居民端")
public class PatientKitController extends BaseController {
    @Autowired
    private KitService kitService;
    @Autowired
    private JyKitService jyKitService;
    @RequestMapping(value = "/kitBinding", method = RequestMethod.POST)
    @ApiOperation("药盒绑定 ")
    public String kitBinding(
            @ApiParam(name = "deviceSn", value = "药盒设备sn码", required = true) @RequestParam(value = "deviceSn", required = true) String deviceSn,
            @ApiParam(name = "type", value = "1、绑定,2、解绑", required = true) @RequestParam(value = "type", required = true) String type){
        try {
            kitService.kitBinding(deviceSn,type,getUID());
            return write(200,"绑定成功!");
        }catch (Exception e) {
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
}

+ 30 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java

@ -426,7 +426,8 @@ public class FamilyContractController extends WeixinBaseController {
                       @RequestParam(required = false)String patient,
                       @RequestParam(required = false)String countryCode,
                       @RequestParam(required = true)String medicareNumber,
                       @RequestParam(required = false)String sevId) {
                       @RequestParam(required = false)String sevId,
                       @RequestParam(required = false)String imgId) {
        try {
            if (StringUtils.isEmpty(doctor)) {
                return error(-1, "签约医生不能为空");
@ -455,7 +456,7 @@ public class FamilyContractController extends WeixinBaseController {
                if (StringUtils.isNotEmpty(content)) {
                    content = CommonUtil.copyTempImage(content);
                    if (StringUtils.isNotEmpty(content)) {
                        familyContractService.saveCertificate(patient,content,sevId);
                        familyContractService.saveCertificate(patient,content,sevId,imgId);
                    }
                }
@ -482,7 +483,8 @@ public class FamilyContractController extends WeixinBaseController {
                            @RequestParam(required = false) String reason,
                            @RequestParam(required = false) String countryCode,
                            @RequestParam(required = true) String medicareNumber,
                            @RequestParam(required = false)String sevId) {
                            @RequestParam(required = false)String sevId,
                            @RequestParam(required = false)String imgId) {
        try {
            if (StringUtils.isEmpty(doctor)) {
                return error(-1, "签约医生不能为空");
@ -518,7 +520,7 @@ public class FamilyContractController extends WeixinBaseController {
                if (StringUtils.isNotEmpty(content)) {
                    content = CommonUtil.copyTempImage(content);
                    if (StringUtils.isNotEmpty(content)) {
                        familyContractService.saveCertificate(patient,content,sevId);
                        familyContractService.saveCertificate(patient,content,sevId,imgId);
                    }
                }
                return write(200, "签约申请成功");
@ -753,5 +755,29 @@ public class FamilyContractController extends WeixinBaseController {
        }
    }
    @RequestMapping("/getSignDict")
    @ApiOperation(value = "获取当前年度服务类型")
    @ResponseBody
    public String getSignDict() {
        try{
            return write(200, "操作成功!", "data", familyContractService.getSignDict());
        }catch (Exception e){
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/findPatientCertificateByType", method = {RequestMethod.GET})
    @ResponseBody
    @ApiOperation("获取居民服务类型凭证")
    public String findPatientCertificate(@ApiParam(name = "patient", value = "居民code") @RequestParam(required = true)String patient,
                                         @ApiParam(name = "type", value = "服务类型code") @RequestParam(required = true)String type) {
        try {
            return write(200, "查询成功", "data", signWebService.findByPatientAndSignYearAndDelAndSignDictCode(patient,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
}

+ 25 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/GcTokenController.java

@ -7,6 +7,7 @@ import com.yihu.wlyy.repository.gateway.GcHttpLogDao;
import com.yihu.wlyy.service.gateway.GcClientDetailsService;
import com.yihu.wlyy.service.gateway.GcTokenService;
import com.yihu.wlyy.util.NetworkUtil;
import com.yihu.wlyy.web.third.gateway.vo.GcClientDetailsModel;
import com.yihu.wlyy.web.third.gateway.vo.GcTokenModel;
import com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel;
import com.yihu.wlyy.web.third.gateway.vo.base.ResultOneModel;
@ -45,6 +46,7 @@ public class GcTokenController {
    public ResultOneModel<GcTokenModel> getToken(
            @ApiParam(name = "appid", value = "appid", required = true) @RequestParam(required = true, value = "appid") String appid,
            @ApiParam(name = "appSecret", value = "appSecret", required = true) @RequestParam(required = true, value = "appSecret") String appSecret,
            @ApiParam(name = "过期时间 yyyy-MM-dd", value = "overTime", required = false) @RequestParam(required = false, value = "overTime") String overTime,
            HttpServletRequest request) {
        String ip = "";
        try {
@ -69,7 +71,7 @@ public class GcTokenController {
            //生成token
            GcToken gcToken = null;
            try {
                gcToken = gcTokenService.createToken(appid, appSecret, NetworkUtil.getIpAddress(request));
                gcToken = gcTokenService.createToken(appid, appSecret, NetworkUtil.getIpAddress(request),overTime);
                saveHttpLog(ip, new JSONObject(request.getParameterMap()).toString(), new JSONObject(gcToken).toString(), gcToken.getAccesstoken(), request.getRequestURI(), 1, "成功");
            } catch (IOException e) {
                e.printStackTrace();
@ -83,6 +85,28 @@ public class GcTokenController {
        }
    }
    @ApiOperation("生成appId,appSecret")
    @RequestMapping(value = "createGcClientDetails", method = RequestMethod.POST)
    public ResultOneModel<GcClientDetailsModel> createClientDetails(
            @ApiParam(name = "appUri", value = "appUri", required = false) @RequestParam(required = false, value = "appUri") String appUri,
            @ApiParam(name = "createUserName", value = "createUserName", required = false) @RequestParam(required = false, value = "createUserName") String createUserName,
            @ApiParam(name = "creatieUser", value = "creatieUser", required = false) @RequestParam(required = false, value = "creatieUser") String creatieUser,
            @ApiParam(name = "remark", value = "remark", required = false) @RequestParam(required = false, value = "remark") String remark
    ){
        try {
            GcClientDetails gcClientDetails = clientDetailsService.createClientDetails(appUri,createUserName,creatieUser,remark);
            if(gcClientDetails==null){
                return new ResultOneModel(BaseResultModel.statusEm.login_system_error.getCode(), BaseResultModel.statusEm.login_system_error.getMessage());
            }
            GcClientDetailsModel gcClientDetailsModel = new GcClientDetailsModel();
            BeanUtils.copyProperties(gcClientDetails, gcClientDetailsModel);
            return new ResultOneModel(gcClientDetailsModel);
        }catch (Exception e) {
            return new ResultOneModel(BaseResultModel.statusEm.login_system_error.getCode(), BaseResultModel.statusEm.login_system_error.getMessage());
        }
    }
    private void saveHttpLog(String ip, String input, String output, String token, String method, Integer flag, String message) {
        GcHttpLog gcHttpLog = new GcHttpLog();

+ 40 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/vo/GcClientDetailsModel.java

@ -0,0 +1,40 @@
package com.yihu.wlyy.web.third.gateway.vo;
import com.yihu.wlyy.entity.IdEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.sql.Timestamp;
import java.util.Date;
/**
 * GtClientDetails entity. @author MyEclipse Persistence Tools
 */
@ApiModel(description = "")
public class GcClientDetailsModel{
    // Fields
    @ApiModelProperty(value = "appId", required = false, access = "response")
    private String appId;
    @ApiModelProperty(value = "appSecret", required = false, access = "response")
    private String appSecret;
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    public String getAppSecret() {
        return appSecret;
    }
    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }
}

+ 91 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/kit/JyKitController.java

@ -0,0 +1,91 @@
package com.yihu.wlyy.web.third.kit;
import com.yihu.wlyy.service.ZyDictDataService;
import com.yihu.wlyy.service.kit.KitService;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import com.yihu.wlyy.service.third.kit.JyKitService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONArray;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
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;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/8/10.
 * 巨烨药盒接口
 */
@RestController
@RequestMapping("/third/juye/kit/")
public class JyKitController extends BaseController {
    @Autowired
    private JyKitService jyKitService;
    @Autowired
    private KitService kitService;
    @ApiOperation("同步居民用药记录")
    @RequestMapping(value = "/drug/useDrugRecord", method = RequestMethod.POST)
    public String useDrugRecord(
            @ApiParam(name = "useTime", value = "居民用药时间 yyyy-MM-dd HH:mm")@RequestParam(value = "useTime", required = true) String useTime,
            @ApiParam(name = "normalTime", value = "居民计划用药时间 yyyy-MM-dd HH:mm")@RequestParam(value = "normalTime", required = true) String normalTime,
            @ApiParam(name = "recordType", value = "记录类型(1、手动,2、设备)")@RequestParam(value = "recordType", required = true) String recordType,
            @ApiParam(name = "useDrugStatus", value = "用药状态(1、按时,2、超时,3、漏用)")@RequestParam(value = "useDrugStatus", required = true) String useDrugStatus,
            @ApiParam(name = "kitSn", value = "药盒的sn码")@RequestParam(value = "kitSn", required = true) String kitSn,
            @ApiParam(name = "kitAccountId", value = "药盒账号id")@RequestParam(value = "kitAccountId", required = true) String kitAccountId,
            @ApiParam(name = "drugDetail", value = "药品清单json串 例如:[{\"drugName\":\"\\u6c2f\\u9709\\u7d20\\u6ef4\\u773c\\u6db2\",\"measure\":\"1.0\",\"drugImgUrl\":\"\"}]")@RequestParam(value = "drugDetail", required = true) String drugDetail) {
        try {
            System.out.println("useDrugRecord-->useTime:"+useTime+"normalTime:"+normalTime+"recordType:"+recordType+"useDrugStatus:"+useDrugStatus+"kitSn:"+kitSn+"kitAccountId:"+kitAccountId+"drugDetail:"+drugDetail);
            kitService.useDrugRecord(useTime,normalTime,recordType,useDrugStatus,kitSn,kitAccountId,drugDetail);
            return write(200, "请求成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"请求失败!");
        }
    }
    @ApiOperation("用药提醒")
    @RequestMapping(value = "/drug/useRemindRecord", method = RequestMethod.POST)
    public String synchronousDict(
            @ApiParam(name = "normalTime", value = "计划用药时间 yyyy-MM-dd HH:mm")
            @RequestParam(value = "normalTime", required = true) String normalTime,
            @ApiParam(name = "kitSn", value = "药盒sn码")
            @RequestParam(value = "kitSn", required = true) String kitSn,
            @ApiParam(name = "kitAccountId", value = "药盒账号id")
            @RequestParam(value = "kitAccountId", required = true) String kitAccountId,
            @ApiParam(name = "remindType", value = "提醒类型(1、到点,2、超时,3、漏用)")
            @RequestParam(value = "remindType", required = true) String remindType,
            @ApiParam(name = "drugDetail", value = "药品清单json串 例如:[{\"drugName\":\"\\u6c2f\\u9709\\u7d20\\u6ef4\\u773c\\u6db2\",\"measure\":\"1.0\",\"drugImgUrl\":\"\"}]")
            @RequestParam(value = "drugDetail", required = true) String drugDetail) {
        try {
            System.out.println("useRemindRecord-->normalTime:"+normalTime+"kitSn:"+kitSn+"kitAccountId:"+kitAccountId+"remindType:"+remindType+"drugDetail:"+drugDetail);
            kitService.drugUseRemind(normalTime,remindType,kitSn,kitAccountId,drugDetail);
            return write(200, "请求成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"请求失败!");
        }
    }
    @RequestMapping(value = "/getKitSetInfo", method = RequestMethod.GET)
    @ApiOperation("获取智能药盒的设置情况")
    public String kitBinding(
            @ApiParam(name = "deviceSn", value = "药盒设备sn码", required = true) @RequestParam(value = "deviceSn", required = true) String deviceSn){
        try {
            JSONArray result = jyKitService.getKitSetInfo(deviceSn);
            return write(200,"获取信息成功!","data",result);
        }catch (Exception e) {
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java

@ -922,8 +922,8 @@ public class WeiXinEventProcess {
            Map<String, String> articleConsult = new HashMap<>();
            articleConsult.put("Url", d.getActivityPath());
            articleConsult.put("Title", "家庭医生线上签约指引");
            articleConsult.put("Description", "贴心家庭医生为居民提供健康指导、随访等服务\n");
            articleConsult.put("Title", "家庭医生签约,红包来助力");
            articleConsult.put("Description", "数量有限,先到先得");
            articleConsult.put("PicUrl", activityPath);
            articles.add(articleConsult);
        }

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

@ -179,3 +179,7 @@ ylz:
  termId: 01
  gateway:
    url: http://www.mstpay.com:1300/huangsb
juye:
  url: http://api.zayata.com/index.php?s=/Company/Device/
  token: YTgzYjc2YWIzZjdjOTA1MTE0ODY2YjcyOGNkYWFmZWR6YXlhdGFjb21wYW55
  companyCode: 86350206000000001

+ 6 - 2
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -152,8 +152,8 @@ es:
jkEdu:
  web:
#    articleBaseUrl: http://yihu.com:9088/
#    articleBaseUrl: http://172.19.103.78:9092/
    articleBaseUrl: http://172.19.103.87:9088/
    articleBaseUrl: http://172.19.103.78:9092/
#    articleBaseUrl: http://172.19.103.87:9088/
#消息队列
activemq:
@ -186,3 +186,7 @@ ylz:
  gateway:
    url: http://www.mstpay.com:1300/huangsb
#药盒请求巨烨的域名以及巨烨给予的公司编号
juye:
  url: http://zayata.oicp.net:30080/index.php?s=/Company/Device/
  companyCode: 86350206000000001

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

@ -187,3 +187,8 @@ ylz:
  termId: aaa
  gateway:
    url: http://120.42.37.94:1301/ehc-empi-web/gateway
#药盒请求巨烨的域名以及巨烨给予的公司编号
juye:
  url: http://api.zayata.com/index.php?s=/Company/Device/
  companyCode: 86350206000000001

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

@ -171,3 +171,8 @@ ylz:
  termId: 01
  gateway:
    url: http://www.mstpay.com:1300/huangsb
juye:
#  url: http://api.zayata.com/index.php?s=/Company/Device/
  url: zayata.ocip.net:30080/index.php?s=/Company/Device/
  token: YTgzYjc2YWIzZjdjOTA1MTE0ODY2YjcyOGNkYWFmZWR6YXlhdGFjb21wYW55
  companyCode: 86350206000000001

二进制
patient-co/patient-co-wlyy/src/main/webapp/images/activity.png