Pārlūkot izejas kodu

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

liuwenbin 7 gadi atpakaļ
vecāks
revīzija
04e2266529
38 mainītis faili ar 1943 papildinājumiem un 1101 dzēšanām
  1. 43 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/device/DeviceHealthyInfoMapping.java
  2. 223 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/archive/Archive.java
  3. 1 199
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/archive/ArchiveInfo.java
  4. 4 3
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientSchemeList.java
  5. 9 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/vo/PatientArchivesDto.java
  6. 3 3
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/vo/PatientVO.java
  7. 177 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/GuahaoController.java
  8. 286 2
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/guahao/GuahaoService.java
  9. 5 2
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/ChargeZYService.java
  10. 0 101
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/redis/RedisMsgPubSubListener.java
  11. 0 44
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/redis/RedisThread.java
  12. 15 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/archive/PatientArchiveDao.java
  13. 1 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/archive/PatientArchiveInfoDao.java
  14. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/consult/ConsultTeamDao.java
  15. 15 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/deviece/DeviceHealthyInfoMappingDao.java
  16. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctoreSchemeBloodPressureDao.java
  17. 3 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDeviceDao.java
  18. 119 87
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java
  19. 48 21
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/archives/PatientArchiveInfoService.java
  20. 16 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  21. 12 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java
  22. 243 371
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  23. 31 32
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  24. 0 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  25. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PhysicalExaminationRemindService.java
  26. 20 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java
  27. 34 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java
  28. 491 48
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/iot/IotDeviceService.java
  29. 18 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/HttpClientUtil.java
  30. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/BaseController.java
  31. 1 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  32. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/scheme/DoctroSchemeController.java
  33. 6 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  34. 0 91
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthController.java
  35. 24 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/scheme/PatientSchemeController.java
  36. 62 52
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/iot/IotDeviceController.java
  37. 6 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/service/EduArticleService.java
  38. 20 0
      patient-co/patient-co-wlyy/src/main/resources/logback.xml

+ 43 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/device/DeviceHealthyInfoMapping.java

@ -0,0 +1,43 @@
package com.yihu.wlyy.entity.device;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * @author yeshijie on 2018/1/12.
 */
@Entity
@Table(name = "wlyy_device_healthy_info_mapping")
public class DeviceHealthyInfoMapping extends IdEntity {
    private Long indexId;//如果和id不一致,那是旧体征信息表id
    private String rid;//es的rowkey
    private Date createTime;//创建时间
    public Long getIndexId() {
        return indexId;
    }
    public void setIndexId(Long indexId) {
        this.indexId = indexId;
    }
    public String getRid() {
        return rid;
    }
    public void setRid(String rid) {
        this.rid = rid;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 223 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/archive/Archive.java

@ -0,0 +1,223 @@
package com.yihu.wlyy.entity.doctor.archive;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by zhangdan on 2018/1/4.
 */
@Entity
@Table(name = "wlyy_archive")
public class Archive extends IdEntity {
    private String code;//唯一标识code
    private String archiveCode;//基卫档案code
    private String sickName;//姓名
    private String archiveOperatorName;// 建档人姓名
    private String doctorCode;// 医生code
    private int archiveStatus;//档案状态【1.未管理 2.死亡 3.正常 4.高危】【必填】
    private String archiveTime;//建档时间
    private int signStatus;// 签约状态【0未签约,1已签约】
    private String birthday;// 生日
    private int sickSex;//性别【1.男 2.女 9 未知】
    private String jwZoneCode;//所属社区
    private int identityType;//证件类型
    private String identityCardNo;//身份证号
    private String homePhone;// 本人电话
    private String homeAddress;//现住地址
    private String orgId;//新增默认传0
    private int residence;//户籍【1.户籍 2.非户籍】
    private String national;//民族
    private String origo;//户口所在地
    private int blood;//血型【1.A型 2.3.O型4.AB型 5.不详】
    private int bloodRh;//  RH阴性【1.否 2.是 3.不详】
    private int marriage;//  婚姻状况【10.未婚 20.已婚 30.丧偶 40.离婚 90.未说明的婚姻状况】
    private String insurCardNo;//  医保卡号
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getArchiveCode() {
        return archiveCode;
    }
    public void setArchiveCode(String archiveCode) {
        this.archiveCode = archiveCode;
    }
    public String getSickName() {
        return sickName;
    }
    public void setSickName(String sickName) {
        this.sickName = sickName;
    }
    public String getArchiveOperatorName() {
        return archiveOperatorName;
    }
    public void setArchiveOperatorName(String archiveOperatorName) {
        this.archiveOperatorName = archiveOperatorName;
    }
    public String getDoctorCode() {
        return doctorCode;
    }
    public void setDoctorCode(String doctorCode) {
        this.doctorCode = doctorCode;
    }
    public int getArchiveStatus() {
        return archiveStatus;
    }
    public void setArchiveStatus(int archiveStatus) {
        this.archiveStatus = archiveStatus;
    }
    public String getArchiveTime() {
        return archiveTime;
    }
    public void setArchiveTime(String archiveTime) {
        this.archiveTime = archiveTime;
    }
    public int getSignStatus() {
        return signStatus;
    }
    public void setSignStatus(int signStatus) {
        this.signStatus = signStatus;
    }
    public String getBirthday() {
        return birthday;
    }
    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }
    public int getSickSex() {
        return sickSex;
    }
    public void setSickSex(int sickSex) {
        this.sickSex = sickSex;
    }
    public String getJwZoneCode() {
        return jwZoneCode;
    }
    public void setJwZoneCode(String jwZoneCode) {
        this.jwZoneCode = jwZoneCode;
    }
    public int getIdentityType() {
        return identityType;
    }
    public void setIdentityType(int identityType) {
        this.identityType = identityType;
    }
    public String getIdentityCardNo() {
        return identityCardNo;
    }
    public void setIdentityCardNo(String identityCardNo) {
        this.identityCardNo = identityCardNo;
    }
    public String getHomePhone() {
        return homePhone;
    }
    public void setHomePhone(String homePhone) {
        this.homePhone = homePhone;
    }
    public String getHomeAddress() {
        return homeAddress;
    }
    public void setHomeAddress(String homeAddress) {
        this.homeAddress = homeAddress;
    }
    public String getOrgId() {
        return orgId;
    }
    public void setOrgId(String orgId) {
        this.orgId = orgId;
    }
    public int getResidence() {
        return residence;
    }
    public void setResidence(int residence) {
        this.residence = residence;
    }
    public String getNational() {
        return national;
    }
    public void setNational(String national) {
        this.national = national;
    }
    public String getOrigo() {
        return origo;
    }
    public void setOrigo(String origo) {
        this.origo = origo;
    }
    public int getBlood() {
        return blood;
    }
    public void setBlood(int blood) {
        this.blood = blood;
    }
    public int getBloodRh() {
        return bloodRh;
    }
    public void setBloodRh(int bloodRh) {
        this.bloodRh = bloodRh;
    }
    public int getMarriage() {
        return marriage;
    }
    public void setMarriage(int marriage) {
        this.marriage = marriage;
    }
    public String getInsurCardNo() {
        return insurCardNo;
    }
    public void setInsurCardNo(String insurCardNo) {
        this.insurCardNo = insurCardNo;
    }
}

+ 1 - 199
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/archive/ArchiveInfo.java

@ -12,29 +12,7 @@ import javax.persistence.Table;
@Table(name = "wlyy_archive_info")
public class ArchiveInfo extends IdEntity {
    private String code;//唯一标识code
    private String archiveCode;//基卫档案code
    private String sickName;//姓名
    private String archiveOperatorName;// 建档人姓名
    private String doctorCode;// 医生code
    private int archiveStatus;//档案状态【1.未管理 2.死亡 3.正常 4.高危】【必填】
    private String archiveTime;//建档时间
    private int signStatus;// 签约状态【0未签约,1已签约】
    private String birthday;// 生日
    private int sickSex;//性别【1.男 2.女 9 未知】
    private String jwZoneCode;//所属社区
    private int identityType;//证件类型
    private String identityCardNo;//身份证号
    private String homePhone;// 本人电话
    private String homeAddress;//现住地址
    private String orgId;//新增默认传0
    private int residence;//户籍【1.户籍 2.非户籍】
    private String national;//民族
    private String origo;//户口所在地
    private int blood;//血型【1.A型 2.3.O型4.AB型 5.不详】
    private int bloodRh;//  RH阴性【1.否 2.是 3.不详】
    private int marriage;//  婚姻状况【10.未婚 20.已婚 30.丧偶 40.离婚 90.未说明的婚姻状况】
    private String insurCardNo;//  医保卡号
    private String archiveCode;//wlyy_archive的唯一标识code
    private int education;//  文化程度【1.文盲及半文盲 2.小学 3.初中 4.高中/技校/中专 5.大学大专及以上 6.不详】
    private int occupation;//  职业【1、国家机关、党群组织、企业、事业单位负责人 2、专业技术人员 3、办事人员和有关人员 4、商业、服务业员工 5、农、林、牧、渔、水利生产人员 6、生产、运输设备操作人员及有关人员 7、军人 8、不便分类的其他从业人员】
    private int medicalExpenses;//  支付方式【7.贫困救助 5.商业医疗保险 1.全公费 8.全自费 99.其它】
@ -53,14 +31,6 @@ public class ArchiveInfo extends IdEntity {
    private String  familyBrothers;//  家族史--兄弟姐妹【0无 1高血压 2糖尿病 3冠心病 4慢性阻塞性肺疾病 5恶性肿瘤 6脑卒中 7重性精神疾病 8结核病 9肝炎 10先天畸形 11其他】
    private String  familyChildren;//  家族史--子女【0无 1高血压 2糖尿病 3冠心病 4慢性阻塞性肺疾病 5恶性肿瘤 6脑卒中 7重性精神疾病 8结核病 9肝炎 10先天畸形 11其他】
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getArchiveCode() {
        return archiveCode;
    }
@ -69,174 +39,6 @@ public class ArchiveInfo extends IdEntity {
        this.archiveCode = archiveCode;
    }
    public String getSickName() {
        return sickName;
    }
    public void setSickName(String sickName) {
        this.sickName = sickName;
    }
    public String getArchiveOperatorName() {
        return archiveOperatorName;
    }
    public void setArchiveOperatorName(String archiveOperatorName) {
        this.archiveOperatorName = archiveOperatorName;
    }
    public String getDoctorCode() {
        return doctorCode;
    }
    public void setDoctorCode(String doctorCode) {
        this.doctorCode = doctorCode;
    }
    public int getArchiveStatus() {
        return archiveStatus;
    }
    public void setArchiveStatus(int archiveStatus) {
        this.archiveStatus = archiveStatus;
    }
    public String getArchiveTime() {
        return archiveTime;
    }
    public void setArchiveTime(String archiveTime) {
        this.archiveTime = archiveTime;
    }
    public int getSignStatus() {
        return signStatus;
    }
    public void setSignStatus(int signStatus) {
        this.signStatus = signStatus;
    }
    public String getBirthday() {
        return birthday;
    }
    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }
    public int getSickSex() {
        return sickSex;
    }
    public void setSickSex(int sickSex) {
        this.sickSex = sickSex;
    }
    public String getJwZoneCode() {
        return jwZoneCode;
    }
    public void setJwZoneCode(String jwZoneCode) {
        this.jwZoneCode = jwZoneCode;
    }
    public int getIdentityType() {
        return identityType;
    }
    public void setIdentityType(int identityType) {
        this.identityType = identityType;
    }
    public String getIdentityCardNo() {
        return identityCardNo;
    }
    public void setIdentityCardNo(String identityCardNo) {
        this.identityCardNo = identityCardNo;
    }
    public String getHomePhone() {
        return homePhone;
    }
    public void setHomePhone(String homePhone) {
        this.homePhone = homePhone;
    }
    public String getHomeAddress() {
        return homeAddress;
    }
    public void setHomeAddress(String homeAddress) {
        this.homeAddress = homeAddress;
    }
    public String getOrgId() {
        return orgId;
    }
    public void setOrgId(String orgId) {
        this.orgId = orgId;
    }
    public int getResidence() {
        return residence;
    }
    public void setResidence(int residence) {
        this.residence = residence;
    }
    public String getNational() {
        return national;
    }
    public void setNational(String national) {
        this.national = national;
    }
    public String getOrigo() {
        return origo;
    }
    public void setOrigo(String origo) {
        this.origo = origo;
    }
    public int getBlood() {
        return blood;
    }
    public void setBlood(int blood) {
        this.blood = blood;
    }
    public int getBloodRh() {
        return bloodRh;
    }
    public void setBloodRh(int bloodRh) {
        this.bloodRh = bloodRh;
    }
    public int getMarriage() {
        return marriage;
    }
    public void setMarriage(int marriage) {
        this.marriage = marriage;
    }
    public String getInsurCardNo() {
        return insurCardNo;
    }
    public void setInsurCardNo(String insurCardNo) {
        this.insurCardNo = insurCardNo;
    }
    public int getEducation() {
        return education;
    }

+ 4 - 3
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientSchemeList.java

@ -4,6 +4,7 @@ import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date;
/**
 * 患者-医生监测方案关联关系表
@ -18,7 +19,7 @@ public class PatientSchemeList extends IdEntity {
    private String schemecode;
    private Integer type;//方案类型:1为血糖,2为血压
    private String doctorcode;
    private Timestamp createTime;
    private Date createTime;
    @Basic
@ -71,11 +72,11 @@ public class PatientSchemeList extends IdEntity {
    @Basic
    @Column(name = "create_time")
    public Timestamp getCreateTime() {
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Timestamp createTime) {
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

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

@ -18,6 +18,7 @@ public class PatientArchivesDto {
    private String blood; // 血型
    private String marry; //结婚
    private String adress;  //地址
    private String orgGo;//户口所在地
    private String education; //教育水平
    private String occupation; //职业
@ -106,6 +107,14 @@ public class PatientArchivesDto {
        this.adress = adress;
    }
    public String getOrgGo() {
        return orgGo;
    }
    public void setOrgGo(String orgGo) {
        this.orgGo = orgGo;
    }
    public String getEducation() {
        return education;
    }

+ 3 - 3
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/vo/PatientVO.java

@ -87,7 +87,7 @@ public class PatientVO {
	private Integer standardStatus;
	
	//设备类型(1血糖,2血压,3血糖+血压)
	private Integer deviceType;
	private String deviceType;
	//医疗保险号
	private String medicareNumber;
	
@ -380,11 +380,11 @@ public class PatientVO {
		this.standardStatus = standardStatus;
	}
	
	public Integer getDeviceType() {
	public String getDeviceType() {
		return deviceType;
	}
	
	public void setDeviceType(Integer deviceType) {
	public void setDeviceType(String deviceType) {
		this.deviceType = deviceType;
	}
	

+ 177 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/GuahaoController.java

@ -245,4 +245,181 @@ public class GuahaoController {
			return Result.error(ex.getMessage());
		}
	}
	
	/**
	 * =============================计免预约挂号相关接口======================================START
	 */
	@RequestMapping(value = "/imm/GetChildrenInfo",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("计免:获取免疫接种儿童信息")
	public Result GetChildrenInfo(@ApiParam(name="barCode",value="条形编码",defaultValue = "0052248552")
								@RequestParam String barCode)
	{
		try {
			
			String data = guahaoService.GetChildrenInfo(barCode);
			
			return Result.success("获取儿童信息成功!",data);
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
		}
	}
	
	@RequestMapping(value = "/imm/GetOrgImmuneList",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("计免:获取免疫接种机构列表")
	public Result GetOrgImmuneList(@ApiParam(name="Condition",value="",defaultValue = "")
	                              @RequestParam String Condition)
	{
		try {
			
			String data = guahaoService.GetOrgImmuneList(Condition);
			
			return Result.success("获取免疫接种机构列表!",data);
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
		}
	}
	
	@RequestMapping(value = "/imm/GetOrgNumberList",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("计免:获取免疫接种号源")
	public Result GetOrgNumberList(@ApiParam(name="orgId",value="机构编码",defaultValue = "")
	                               @RequestParam String orgId,
	                               @ApiParam(name="ScheduleId",value="排班ID",defaultValue = "")
	                               @RequestParam String ScheduleId)
	{
		try {
			
			String data = guahaoService.GetOrgNumberList(orgId,ScheduleId);
			
			return Result.success("获取免疫接种号源!",data);
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
		}
	}
	
	@RequestMapping(value = "/imm/GetOrgScheduleList",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("计免:获取免疫接种排班信息")
	public Result GetOrgScheduleList(@ApiParam(name="OrgCode",value="机构编码",defaultValue = "")
	                               @RequestParam String OrgCode,
	                               @ApiParam(name="strStart",value="开始日期",defaultValue = "")
	                               @RequestParam String strStart,
	                               @ApiParam(name="strEnd",value="结束日期",defaultValue = "")
	                               @RequestParam String strEnd)
	{
		try {
			
			String data = guahaoService.GetOrgScheduleList(OrgCode,strStart,strEnd);
			
			return Result.success("获取免疫接种排班信息!",data);
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
		}
	}
	
	@RequestMapping(value = "/imm/GetOrgScheduleAndNumberList",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("计免:获取免疫接种排班信息和号源信息")
	public Result GetOrgScheduleAndNumberList(@ApiParam(name="OrgCode",value="条形编码",defaultValue = "")
	                                          @RequestParam String OrgCode)
	{
		try {
			
			String data = guahaoService.GetOrgScheduleAndNumberList(OrgCode);
			
			return Result.success("获取免疫接种排班信息和号源信息!",data);
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
		}
	}
	
	@RequestMapping(value = "/imm/GetResImmuneListWithBarCode",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("计免:根据条形码获取预约记录")
	public Result GetResImmuneListWithBarCode(@ApiParam(name="BarCode",value="条形编码",defaultValue = "")
	                                 @RequestParam String BarCode)
	{
		try {
			
			String data = guahaoService.GetResImmuneListWithBarCode(BarCode);
			
			return Result.success("根据条形码获取预约记录!",data);
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
		}
	}
	
	@RequestMapping(value = "/imm/RegisterImmune",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("计免:免疫接种确认预约")
	public Result RegisterImmune(@ApiParam(name="BarCode",value="条形编码",defaultValue = "")
	                             @RequestParam String BarCode,
	                             @ApiParam(name="OrgCode",value="机构编码",defaultValue = "")
	                             @RequestParam String OrgCode,
	                             @ApiParam(name="SectionType",value="坐诊类型",defaultValue = "")
	                             @RequestParam String SectionType,
	                             @ApiParam(name="strStart",value="日期:第一次坐诊开始日期",defaultValue = "")
	                             @RequestParam String strStart,
	                             @ApiParam(name="SSID",value="市民社保卡号",defaultValue = "")
	                             @RequestParam String SSID,
	                             @ApiParam(name="PatientName",value="儿童姓名",defaultValue = "")
	                             @RequestParam String PatientName,
	                             @ApiParam(name="PatientID",value="儿童身份证号",defaultValue = "")
	                             @RequestParam String PatientID,
	                             @ApiParam(name="PatientPhone",value="市民手机号",defaultValue = "")
	                             @RequestParam String PatientPhone)
	{
		try {
			
			String data = guahaoService.RegisterImmune(BarCode,OrgCode,SectionType,strStart,SSID,PatientName,PatientID,PatientPhone);
			
			return Result.success("免疫接种确认预约成功!",data);
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
		}
	}
	
	@RequestMapping(value = "/imm/UnResRegisterImmune",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("计免:免疫接种取消预约")
	public Result UnResRegisterImmune(@ApiParam(name="BarCode",value="条形编码",defaultValue = "")
	                             @RequestParam String BarCode,
	                             @ApiParam(name="OrgCode",value="机构编码",defaultValue = "")
	                             @RequestParam String OrgCode,
	                             @ApiParam(name="SectionType",value="坐诊类型",defaultValue = "")
	                             @RequestParam String SectionType,
	                             @ApiParam(name="strStart",value="日期:第一次坐诊开始日期",defaultValue = "")
	                             @RequestParam String strStart,
	                             @ApiParam(name="SSID",value="市民社保卡号",defaultValue = "")
	                             @RequestParam String SSID,
	                             @ApiParam(name="PatientName",value="儿童姓名",defaultValue = "")
	                             @RequestParam String PatientName,
	                             @ApiParam(name="PatientID",value="儿童身份证号",defaultValue = "")
	                             @RequestParam String PatientID,
	                             @ApiParam(name="PatientPhone",value="市民手机号",defaultValue = "")
	                             @RequestParam String PatientPhone)
	{
		try {
			
			String data = guahaoService.UnResRegisterImmune(BarCode,OrgCode,SectionType,strStart,SSID,PatientName,PatientID,PatientPhone);
			
			return Result.success("免疫接种取消预约成功!",data);
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
		}
	}
	
	/**
	 * =============================计免预约挂号相关接口======================================END
	 */
}

+ 286 - 2
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/guahao/GuahaoService.java

@ -1,13 +1,19 @@
package com.yihu.wlyy.service.service.guahao;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.service.common.http.HttpApiException;
import com.yihu.wlyy.service.common.util.DateUtil;
import com.yihu.wlyy.service.common.util.SOAPUtil;
import com.yihu.wlyy.service.common.util.StringUtil;
import com.yihu.wlyy.service.dao.*;
import com.yihu.wlyy.service.entity.Patient;
import com.yihu.wlyy.service.entity.PatientReservation;
import com.yihu.wlyy.service.entity.SignFamily;
import com.yihu.wlyy.service.service.LogService;
import com.yihu.wlyy.service.service.ZysoftApi;
import com.zoe.phip.ssp.sdk.ApiException;
import org.apache.commons.lang3.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
@ -15,8 +21,11 @@ import org.dom4j.Element;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.*;
@ -58,6 +67,9 @@ public class GuahaoService {
    @Autowired
    private ObjectMapper objectMapper;
    
    @Value("${zyapi.openCrypto}")
    private Boolean openCrypto;
    /**
     * 解析挂号后
@ -1138,6 +1150,278 @@ public class GuahaoService {
            return null;
        }
    }
    
    /**
     * =============================计免预约挂号相关接口==========================================START
     */
    
    
    /**
     * 计免预约Post接口
     */
    private String immPostSecond(String api,String content, Map<String,String> params) throws Exception
    {
        String re = "";
        
        //新增日志
        String method = "POST";
        Boolean isSuccess = true;
        String error = "";
        
        int times = 0;
        try {
            re = ZysoftApi.getSingleton().post("imm/"+api, params, null,openCrypto);
    
            //---结果验证,并保存日志 ---START
            if (StringUtils.isEmpty(re)) {
                // 请求失败
                //保存http日志
                logService.saveHttpLog(isSuccess,api,content,method,api,net.sf.json.JSONObject.fromObject(params).toString(),re,error);
                throw new Exception(error);
            } else if (StringUtils.startsWith(re, "System-Error")) {
                // 调用失败
                //保存http日志
                error = re.substring(re.indexOf(":") + 1, re.length());
                logService.saveHttpLog(isSuccess,api,content,method,api,net.sf.json.JSONObject.fromObject(params).toString(),re,error);
                throw new Exception(error);
            } else if (StringUtils.startsWith(re, "Error")) {
                // 调用失败
                //保存http日志
                error = re.substring(re.indexOf(":") + 1, re.length());
                logService.saveHttpLog(isSuccess,api,content,method,api,net.sf.json.JSONObject.fromObject(params).toString(),re,error);
                throw new Exception(error);
            }
            //---结果验证,并保存日志 ---END
            
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,api, net.sf.json.JSONObject.fromObject(params).toString(),re,error);
        }
        catch (Exception ex)
        {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            error = sw.toString();
            isSuccess = false;
            
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,api,net.sf.json.JSONObject.fromObject(params).toString(),re,error);
            
            if(ex instanceof ApiException)
            {
                ApiException apiEx = (ApiException) ex;
                throw new HttpApiException(apiEx.errorCode(),ex.getMessage());
            }
            else{
                throw new HttpApiException(-1,ex.getMessage());
            }
        }
        
        return re;
    }
    
    
    /**
     * 计免请求结果验证,并保存日志
     * @param url
     * @param content
     * @param method
     * @param msgBody
     * @param res
     */
    private void  verificationImmResult(String result,String title,String url,String content,String method,String msgBody,String res) throws Exception{
        String error = "";
        Boolean isSuccess = false;
        if (StringUtils.isEmpty(result)) {
            // 请求失败
            //保存http日志
            error = title;
            logService.saveHttpLog(isSuccess,url,content,method,null,msgBody,res,error,logService.archiveType);
            throw new Exception(error);
        } else if (StringUtils.startsWith(result, "System-Error")) {
            // 调用失败
            //保存http日志
            error = result.substring(result.indexOf(":") + 1, result.length());
            logService.saveHttpLog(isSuccess,url,content,method,null,msgBody,res,error,logService.archiveType);
            throw new Exception(error);
        } else if (StringUtils.startsWith(result, "Error")) {
            // 调用失败
            //保存http日志
            error = result.substring(result.indexOf(":") + 1, result.length());
            logService.saveHttpLog(isSuccess,url,content,method,null,msgBody,res,error,logService.archiveType);
            throw new Exception(error);
        }
    }
    
    /**
     * 获取免疫接种儿童信息
     * @param credential 条形编码
     * @return
     */
    public String GetChildrenInfo(String credential)throws Exception  {
        String result = "";
        Map<String,String> params = new HashMap<>();
        params.put("BarCode", credential);
        result = immPostSecond("GetChildrenInfo","计免预约-获取儿童信息成功",params);
    
        com.alibaba.fastjson.JSONObject data = com.alibaba.fastjson.JSONObject.parseObject(result);
        
        if(data.containsKey("OK")){
            result = data.getString("OK");
        }
        
        return result;
    }
    
    /**
     * 获取免疫接种机构列表
     * @param condition
     * @return
     */
    public String GetOrgImmuneList(String condition)throws Exception  {
        String result = "";
        Map<String,String> params = new HashMap<>();
        params.put("Condition", condition);
        return immPostSecond("GetOrgImmuneList","计免预约-获取免疫接种机构列表",params);
    }
    
    /**
     * 获取免疫接种号源
     * @param orgId 机构编码
     * @param scheduleId 排班ID
     * @return
     */
    public String GetOrgNumberList(String orgId, String scheduleId) throws Exception  {
        String result = "";
        Map<String,String> params = new HashMap<>();
        params.put("orgId", orgId);
        params.put("ScheduleId", scheduleId);
        return immPostSecond("GetOrgNumberList","计免预约-获取免疫接种号源",params);
    }
    
    /**
     * 获取免疫接种排班信息
     * @param orgCode 机构编码
     * @param strStart 开始时间
     * @param strEnd 结束时间
     * @return
     * @throws Exception
     */
    public String GetOrgScheduleList(String orgCode, String strStart, String strEnd) throws Exception {
        String result = "";
        Map<String,String> params = new HashMap<>();
        params.put("OrgCode", orgCode);
        params.put("strStart", strStart);
        params.put("strEnd", strEnd);
        return immPostSecond("GetOrgScheduleList","计免预约-获取免疫接种排班信息",params);
    }
    
    /**
     * 根据条形编码获取预约记录
     * @param barCode
     * @return
     * @throws Exception
     */
    public String GetResImmuneListWithBarCode(String barCode) throws Exception{
        String result = "";
        Map<String,String> params = new HashMap<>();
        params.put("BarCode", barCode);
        return immPostSecond("GetResImmuneListWithBarCode","计免预约-根据条形编码获取预约记录",params);
    }
    
    /**
     * 获取免疫接种排班信息和号源信息
     * @param orgCode
     * @return
     * @throws Exception
     */
    public String GetOrgScheduleAndNumberList(String orgCode)throws Exception {
        String result = "";
        Map<String,String> params = new HashMap<>();
        params.put("OrgCode", orgCode);
        return immPostSecond("GetOrgScheduleAndNumberList","计免预约-获取免疫接种排班信息和号源信息",params);
    }
    
    /**
     *免疫接种确认预约
     * @param barCode
     * @param orgCode
     * @param sectionType
     * @param strStart
     * @param ssid
     * @param patientName
     * @param patientID
     * @param patientPhone
     * @return
     */
    public String RegisterImmune(String barCode,
                                 String orgCode,
                                 String sectionType,
                                 String strStart,
                                 String ssid,
                                 String patientName,
                                 String patientID,
                                 String patientPhone)throws Exception {
        String result = "";
        Map<String,String> params = new HashMap<>();
        params.put("BarCode", barCode);
        params.put("OrgCode", orgCode);
        params.put("SectionType", sectionType);
        params.put("strStart", strStart);
        params.put("SSID", ssid);
        params.put("PatientName", patientName);
        params.put("PatientID", patientID);
        params.put("PatientPhone", patientPhone);
        result = immPostSecond("RegisterImmune","计免预约-免疫接种确认预约",params);
    
        com.alibaba.fastjson.JSONObject data = com.alibaba.fastjson.JSONObject.parseObject(result);
    
        if(data.containsKey("OK")){
            result = data.getString("OK");
        }
    
        return result;
    }
    
    /**
     * 免疫接种取消预约
     * @param barCode
     * @param orgCode
     * @param sectionType
     * @param strStart
     * @param ssid
     * @param patientName
     * @param patientID
     * @param patientPhone
     * @return
     * @throws Exception
     */
    public String UnResRegisterImmune(String barCode,
                                      String orgCode,
                                      String sectionType,
                                      String strStart,
                                      String ssid,
                                      String patientName,
                                      String patientID,
                                      String patientPhone) throws Exception {
        String result = "";
        Map<String,String> params = new HashMap<>();
        params.put("BarCode", barCode);
        params.put("OrgCode", orgCode);
        params.put("SectionType", sectionType);
        params.put("strStart", strStart);
        params.put("SSID", ssid);
        params.put("PatientName", patientName);
        params.put("PatientID", patientID);
        params.put("PatientPhone", patientPhone);
        result = immPostSecond("UnResRegisterImmune","计免预约-免疫接种确认预约",params);
    
        com.alibaba.fastjson.JSONObject data = com.alibaba.fastjson.JSONObject.parseObject(result);
    
        if(data.containsKey("OK")){
            result = data.getString("OK");
        }
    
        return result;
    }
}

+ 5 - 2
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/ChargeZYService.java

@ -220,14 +220,17 @@ public class ChargeZYService {
                }
                infoobj.put("kfdjh0",misettleno);//扣费单据号
                
                
                infoobj.put("zje000",NumberUtil.feeToYuan(charge.getTotalAmount()));//扣费总额
                
                //--huangwenjie--2018.01.12--扣费总额需要扣除政府补贴
                if(StringUtils.isNotBlank(charge.getCadresPay())){
                    infoobj.put("zfbtzf", NumberUtil.feeToYuan(Integer.parseInt(charge.getCadresPay().trim())));//政府补贴支付
    
                    infoobj.put("zje000",NumberUtil.feeToYuan(charge.getTotalAmount()-Integer.parseInt(charge.getCadresPay().trim())));//扣费总额
                }else{
                    infoobj.put("zfbtzf","0.00");//政府补贴支付
    
                    infoobj.put("zje000",NumberUtil.feeToYuan(charge.getTotalAmount()));//扣费总额
                }
    
                if(StringUtils.isNotBlank(charge.getHealthCarePay())){

+ 0 - 101
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/redis/RedisMsgPubSubListener.java

@ -1,101 +0,0 @@
//package com.yihu.wlyy.redis;
//
//import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
//import com.yihu.wlyy.service.app.prescription.PrescriptionService;
//import com.yihu.wlyy.util.HttpUtil;
//import org.json.JSONObject;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import redis.clients.jedis.JedisPubSub;
//
///**
// * Created by Trick on 2017/8/7.
// */
//@Component
//public class RedisMsgPubSubListener extends JedisPubSub {
//
//    @Autowired
//    private PrescriptionInfoService prescriptionInfoService;
//    @Autowired
//    private PrescriptionService prescriptionService;
//
//    private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
//
//    @Override
//    public void unsubscribe() {
//        super.unsubscribe();
//    }
//
//    @Override
//    public void unsubscribe(String... channels) {
//        super.unsubscribe(channels);
//    }
//
//    @Override
//    public void subscribe(String... channels) {
//        super.subscribe(channels);
//    }
//
//    @Override
//    public void psubscribe(String... patterns) {
//        super.psubscribe(patterns);
//    }
//
//    @Override
//    public void punsubscribe() {
//        super.punsubscribe();
//    }
//
//    @Override
//    public void punsubscribe(String... patterns) {
//        super.punsubscribe(patterns);
//    }
//
//    @Override
//    public void onMessage(String channel, String message) {
//        logger.info("redis_onMessage...:"+message);
//        //this.unsubscribe();
//        try{
//            JSONObject json = new JSONObject(message);
//            String title =  json.getString("title");
//            if("redisAddPrescription".equals(title)){
//                logger.info(json.toString());
//                //审核消息发送
//                prescriptionInfoService.onMesSquareState(message);
//            }else if("dispensingComplete".equals(title)){//配药完成
//                //药品配送完成,提醒取药
//                String prescriptionCode = json.getString("prescription");
//                prescriptionService.dispensingComplete(prescriptionCode);
//            }
//        }catch (Exception e){
//            logger.error("redis_error...",e);
//        }
//    }
//
//    @Override
//    public void onPMessage(String pattern, String channel, String message) {
//
//    }
//
//    @Override
//    public void onSubscribe(String channel, int subscribedChannels) {
//        //System.out.println("channel:" + channel + "is been subscribed:" + subscribedChannels);
//    }
//
//    @Override
//    public void onPUnsubscribe(String pattern, int subscribedChannels) {
//
//    }
//
//    @Override
//    public void onPSubscribe(String pattern, int subscribedChannels) {
//
//    }
//
//    @Override
//    public void onUnsubscribe(String channel, int subscribedChannels) {
//        System.out.println("channel:" + channel + "is been unsubscribed:" + subscribedChannels);
//    }
//}

+ 0 - 44
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/redis/RedisThread.java

@ -1,44 +0,0 @@
//package com.yihu.wlyy.redis;
//
//import com.yihu.wlyy.service.app.prescription.PrescriptionService;
//import com.yihu.wlyy.util.SystemConf;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.stereotype.Component;
//
///**
// * Created by Trick on 2017/8/7.
// */
//@Component
//public class RedisThread implements Runnable {
//
//    @Value("${spring.redis.host}")
//    private String url;
//    @Autowired
//    private RedisMsgPubSubListener redisMsgPubSubListener;
//    @Autowired
//    private StringRedisTemplate redisTemplate;
//    @Autowired
//    private PrescriptionService prescriptionService;
//
//    @Override
//    public void run() {
//        String key = SystemConf.getInstance().getSystemProperties().getProperty("redisMessage");
//        while (true){
//            redisTemplate.watch(key);
//            String message = redisTemplate.opsForList().rightPop(key);
//            redisTemplate.unwatch();
//            if(StringUtils.isEmpty(message)){
//                try{
//                    Thread.sleep(1000L);//如果没有读取到记录,等待1秒
//                }catch (Exception e){
//                    e.printStackTrace();
//                }
//            }else {
//                prescriptionService.redisMessage(message);
//            }
//        }
//    }
//}

+ 15 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/archive/PatientArchiveDao.java

@ -0,0 +1,15 @@
package com.yihu.wlyy.repository.archive;
import com.yihu.wlyy.entity.doctor.archive.Archive;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Administrator on 2018/1/4.
 */
public interface PatientArchiveDao extends PagingAndSortingRepository<Archive, Long>, JpaSpecificationExecutor<Archive> {
    @Query("select a from Archive a where a.code=?1")
    Archive findArchiveDetailsByCode(String code);
}

+ 1 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/archive/PatientArchiveInfoDao.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.repository.archive;
import com.yihu.wlyy.entity.doctor.archive.Archive;
import com.yihu.wlyy.entity.doctor.archive.ArchiveInfo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
@ -10,6 +11,4 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 */
public interface PatientArchiveInfoDao extends PagingAndSortingRepository<ArchiveInfo, Long>, JpaSpecificationExecutor<ArchiveInfo> {
    @Query("select a from ArchiveInfo a where a.code=?1")
    ArchiveInfo findArchiveDetailsByCode(String code);
}

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

@ -299,6 +299,6 @@ public interface ConsultTeamDao extends PagingAndSortingRepository<ConsultTeam,
	List<ConsultTeam> findUnfinishedConsultPrescription(String code);
	//按时间、类型、咨询时间统计居民咨询数量
	@Query("SELECT COUNT(1) FROM ConsultTeam a WHERE a.patient = ?1 AND a.type = ?2 AND a.czrq >= ?3 AND a.status = 1 AND a.del = '1' ")
	int countRemainConsult(String patient, int type, Date consultTime);
	@Query("SELECT COUNT(1) FROM ConsultTeam a WHERE a.patient = ?1 AND a.type = ?2 AND a.czrq >= ?3 AND a.czrq <= ?4 AND a.status = 1 AND a.del = '1' ")
	int countRemainConsult(String patient, int type, Date begin,Date end);
}

+ 15 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/deviece/DeviceHealthyInfoMappingDao.java

@ -0,0 +1,15 @@
package com.yihu.wlyy.repository.deviece;
import com.yihu.wlyy.entity.device.DeviceHealthyInfoMapping;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2018/1/12.
 */
public interface DeviceHealthyInfoMappingDao extends PagingAndSortingRepository<DeviceHealthyInfoMapping, Long>, JpaSpecificationExecutor<DeviceHealthyInfoMapping> {
    @Query("select a from DeviceHealthyInfoMapping a where a.id = ?1 or a.indexId=?2 ")
    DeviceHealthyInfoMapping findByIndexId(Long id,Long indexId);
}

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

@ -26,4 +26,5 @@ public interface DoctoreSchemeBloodPressureDao extends
    @Modifying
    @Query("update DoctorSchemeBloodPressure set del=?1 where doctorcode=?2 and code=?3")
    void updateDelStatus(int del, String doctorcode, String schemecode);
}

+ 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.deviceSn=?2 ")
    List<PatientDevice> findByPatientAndDeviceSn(String user,String deviceSn);
    List<PatientDevice> findByUser(String user, Pageable pageRequest);
    List<PatientDevice> findByUserAndDoctor(String user, String doctor, Pageable pageRequest);

+ 119 - 87
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java

@ -1,10 +1,10 @@
package com.yihu.wlyy.service.app.account;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.wlyy.entity.address.*;
import com.yihu.wlyy.entity.demographic.DemographicInfo;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.archive.Archive;
import com.yihu.wlyy.entity.doctor.archive.ArchiveInfo;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.login.LoginLog;
@ -17,6 +17,7 @@ import com.yihu.wlyy.entity.patient.vo.PatientArchivesDto;
import com.yihu.wlyy.entity.patient.vo.PatientVO;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.repository.address.*;
import com.yihu.wlyy.repository.archive.PatientArchiveDao;
import com.yihu.wlyy.repository.archive.PatientArchiveInfoDao;
import com.yihu.wlyy.repository.demographic.TblBasicDao;
import com.yihu.wlyy.repository.dict.SystemDictDao;
@ -27,21 +28,18 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.service.app.family.FamilyMemberService;
import com.yihu.wlyy.service.app.family.FamilyService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.TokenService;
import com.yihu.wlyy.service.common.login.LoginLogService;
import com.yihu.wlyy.service.third.jw.JwArchivesService;
import com.yihu.wlyy.util.*;
import io.swagger.models.auth.In;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.objenesis.ObjenesisBase;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -102,6 +100,8 @@ public class PatientInfoService extends BaseService {
    @Autowired
    DoctorDao doctorDao;
    @Autowired
    PatientArchiveDao patientArchiveDao;
    @Autowired
    PatientArchiveInfoDao patientArchiveInfoDao;
    /**
     * 患者更换手机号
@ -423,38 +423,42 @@ public class PatientInfoService extends BaseService {
        //保存建档信息到服务器数据库
        Doctor doctorObj = doctorDao.findByCode(doctorCode);
        ArchiveInfo archiveInfo = new ArchiveInfo();
        archiveInfo.setCode(getCode());
        archiveInfo.setArchiveCode(response);
        archiveInfo.setSickName(p.getName());
        archiveInfo.setDoctorCode(doctorCode);
        Archive archive = new Archive();
        String code = getCode();
        archive.setCode(code);
        archive.setArchiveCode(response);
        archive.setSickName(p.getName());
        archive.setDoctorCode(doctorCode);
        if (doctorObj!=null){
            archiveInfo.setArchiveOperatorName(doctorObj.getName());
            archive.setArchiveOperatorName(doctorObj.getName());
        }
        archiveInfo.setArchiveTime(DateUtil.getStringDateShort());
        archive.setArchiveTime(DateUtil.getStringDateShort());
        int isSign = signFamilyDao.hasSingStatus(p.getIdcard());
        if (isSign>0){
            archiveInfo.setSignStatus(1);
            archive.setSignStatus(1);
        }else{
            archiveInfo.setSignStatus(0);
            archive.setSignStatus(0);
        }
        archiveInfo.setArchiveStatus(3);
        archiveInfo.setSickSex(p.getSex());
        archiveInfo.setBirthday(brithday);
        archiveInfo.setJwZoneCode(jwCountryCode);
        archiveInfo.setIdentityType(1);
        archiveInfo.setIdentityCardNo(p.getIdcard());
        archiveInfo.setHomePhone(p.getMobile());
        archiveInfo.setHomeAddress(adress);
        archiveInfo.setOrgId("0");
        archiveInfo.setResidence(1);
        archiveInfo.setNational(nation);
        archiveInfo.setOrigo("350200");
        archiveInfo.setBlood(Integer.valueOf(blood));
        archiveInfo.setBloodRh(1);
        archiveInfo.setMarriage(Integer.valueOf(marry));
        archiveInfo.setInsurCardNo(p.getSsc());
        archive.setArchiveStatus(3);
        archive.setSickSex(p.getSex());
        archive.setBirthday(brithday);
        archive.setJwZoneCode(jwCountryCode);
        archive.setIdentityType(1);
        archive.setIdentityCardNo(p.getIdcard());
        archive.setHomePhone(p.getMobile());
        archive.setHomeAddress(adress);
        archive.setOrgId("0");
        archive.setResidence(1);
        archive.setNational(nation);
        archive.setOrigo("350200");
        archive.setBlood(Integer.valueOf(blood));
        archive.setBloodRh(1);
        archive.setMarriage(Integer.valueOf(marry));
        archive.setInsurCardNo(p.getSsc());
        patientArchiveDao.save(archive);
        //补充参数
        ArchiveInfo archiveInfo = new ArchiveInfo();
        archiveInfo.setArchiveCode(code);
        archiveInfo.setAllergic("0");
        archiveInfo.setPast("0");
        archiveInfo.setGenetic(0);
@ -465,7 +469,6 @@ public class PatientInfoService extends BaseService {
        archiveInfo.setFamilyChildren("0");
        archiveInfo.setDisability("1");
        patientArchiveInfoDao.save(archiveInfo);
        return 1;
    }
    public int createProfile(String archiveJson) throws Exception{
@ -473,6 +476,7 @@ public class PatientInfoService extends BaseService {
        PatientArchivesDto archive = (PatientArchivesDto) net.sf.json.JSONObject.toBean(j,PatientArchivesDto.class);
        Patient p = patientDao.findByCode(archive.getPatient());
        Archive archiveDateBase = new Archive();
        ArchiveInfo archiveInfo = new ArchiveInfo();
        Doctor doctorObj = doctorDao.findByCode(archive.getDoctorCode());
@ -490,41 +494,50 @@ public class PatientInfoService extends BaseService {
        json.put("ORG_ID","0");//新增默认传0
        json.put("RESIDENCE","1");//户籍【1.户籍 2.非户籍】
        json.put("NATIONAL",archive.getNation());//民族【NATION_DICT】
        json.put("ORIGO","350200");//户口所在地【ZONE_DICT】
        //json.put("ORIGO","350200");//户口所在地【ZONE_DICT】
        if (StringUtils.isEmpty(archive.getOrgGo())){
            json.put("ORIGO","350200");//户口所在地【ZONE_DICT】
        }else{
            json.put("ORIGO",archive.getOrgGo());//户口所在地【ZONE_DICT】
        }
        json.put("BLOOD",archive.getBlood());//血型【1.A型 2.3.O型4.AB型 5.不详】
        json.put("BLOOD_RH","1");//RH阴性【1.否 2.是 3.不详】
        json.put("MARRIAGE",archive.getMarry());//婚姻状况【10.未婚 20.已婚 30.丧偶 40.离婚 90.未说明的婚姻状况】
        json.put("INSUR_CARD_NO",p.getSsc());//医保卡号
        //保存建档记录信息
        archiveInfo.setSickName(p.getName());
        archiveInfo.setDoctorCode(archive.getDoctorCode());
        archiveDateBase.setSickName(p.getName());
        archiveDateBase.setDoctorCode(archive.getDoctorCode());
        if (doctorObj!=null){
            archiveInfo.setArchiveOperatorName(doctorObj.getName());
            archiveDateBase.setArchiveOperatorName(doctorObj.getName());
        }
        archiveInfo.setArchiveTime(DateUtil.getStringDateShort());
        archiveDateBase.setArchiveTime(DateUtil.getStringDateShort());
        int isSign = signFamilyDao.hasSingStatus(p.getIdcard());
        if (isSign>0){
            archiveInfo.setSignStatus(1);
            archiveDateBase.setSignStatus(1);
        }else{
            archiveInfo.setSignStatus(0);
            archiveDateBase.setSignStatus(0);
        }
        archiveInfo.setArchiveStatus(3);
        archiveInfo.setSickSex(p.getSex());
        archiveInfo.setBirthday(archive.getBrithday());
        archiveInfo.setJwZoneCode(archive.getJwCountryCode());
        archiveInfo.setIdentityType(1);
        archiveInfo.setIdentityCardNo(p.getIdcard());
        archiveInfo.setHomePhone(p.getMobile());
        archiveInfo.setHomeAddress(archive.getAdress());
        archiveInfo.setOrgId("0");
        archiveInfo.setResidence(1);
        archiveInfo.setNational(archive.getNation());
        archiveInfo.setOrigo("350200");
        archiveInfo.setBlood(Integer.valueOf(archive.getBlood()));
        archiveInfo.setBloodRh(1);
        archiveInfo.setMarriage(Integer.valueOf(archive.getMarry()));
        archiveInfo.setInsurCardNo(p.getSsc());
        archiveDateBase.setArchiveStatus(3);
        archiveDateBase.setSickSex(p.getSex());
        archiveDateBase.setBirthday(archive.getBrithday());
        archiveDateBase.setJwZoneCode(archive.getJwCountryCode());
        archiveDateBase.setIdentityType(1);
        archiveDateBase.setIdentityCardNo(p.getIdcard());
        archiveDateBase.setHomePhone(p.getMobile());
        archiveDateBase.setHomeAddress(archive.getAdress());
        archiveDateBase.setOrgId("0");
        archiveDateBase.setResidence(1);
        archiveDateBase.setNational(archive.getNation());
        if (StringUtils.isEmpty(archive.getOrgGo())){
            archiveDateBase.setOrigo("350200");
        }else{
            archiveDateBase.setOrigo(archive.getOrgGo());
        }
        archiveDateBase.setBlood(Integer.valueOf(archive.getBlood()));
        archiveDateBase.setBloodRh(1);
        archiveDateBase.setMarriage(Integer.valueOf(archive.getMarry()));
        archiveDateBase.setInsurCardNo(p.getSsc());
        //补充参数
@ -930,8 +943,11 @@ public class PatientInfoService extends BaseService {
        socialSecurityInfoDao.save(info);
        //保存建档记录信息到服务器数据库
        archiveInfo.setCode(getCode());
        archiveInfo.setArchiveCode(response);
        String code = getCode();
        archiveDateBase.setCode(code);
        archiveDateBase.setArchiveCode(response);//基卫code
        archiveInfo.setArchiveCode(code);//详细信息表关联建档记录表code
        patientArchiveDao.save(archiveDateBase);
        patientArchiveInfoDao.save(archiveInfo);
        return 1;
@ -940,6 +956,7 @@ public class PatientInfoService extends BaseService {
    public int createProfile(PatientArchivesDto archive) throws Exception{
        Patient p = patientDao.findByCode(archive.getPatient());
        Archive archiveDataBase = new Archive();
        ArchiveInfo archiveInfo = new ArchiveInfo();
        Doctor doctorObj = doctorDao.findByCode(archive.getDoctorCode());
@ -957,41 +974,49 @@ public class PatientInfoService extends BaseService {
        json.put("ORG_ID","0");//新增默认传0
        json.put("RESIDENCE","1");//户籍【1.户籍 2.非户籍】
        json.put("NATIONAL",archive.getNation());//民族【NATION_DICT】
        json.put("ORIGO","350200");//户口所在地【ZONE_DICT】
        if (StringUtils.isEmpty(archive.getOrgGo())){
            json.put("ORIGO","350200");//户口所在地【ZONE_DICT】
        }else{
            json.put("ORIGO",archive.getOrgGo());//户口所在地【ZONE_DICT】
        }
        json.put("BLOOD",archive.getBlood());//血型【1.A型 2.3.O型4.AB型 5.不详】
        json.put("BLOOD_RH","1");//RH阴性【1.否 2.是 3.不详】
        json.put("MARRIAGE",archive.getMarry());//婚姻状况【10.未婚 20.已婚 30.丧偶 40.离婚 90.未说明的婚姻状况】
        json.put("INSUR_CARD_NO",p.getSsc());//医保卡号
        //保存建档记录信息
        archiveInfo.setSickName(p.getName());
        archiveInfo.setDoctorCode(archive.getDoctorCode());
        archiveDataBase.setSickName(p.getName());
        archiveDataBase.setDoctorCode(archive.getDoctorCode());
        if (doctorObj!=null){
            archiveInfo.setArchiveOperatorName(doctorObj.getName());
            archiveDataBase.setArchiveOperatorName(doctorObj.getName());
        }
        archiveInfo.setArchiveTime(DateUtil.getStringDateShort());
        archiveDataBase.setArchiveTime(DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
        int isSign = signFamilyDao.hasSingStatus(p.getIdcard());
        if (isSign>0){
            archiveInfo.setSignStatus(1);
            archiveDataBase.setSignStatus(1);
        }else{
            archiveInfo.setSignStatus(0);
            archiveDataBase.setSignStatus(0);
        }
        archiveDataBase.setArchiveStatus(3);
        archiveDataBase.setSickSex(p.getSex());
        archiveDataBase.setBirthday(archive.getBrithday());
        archiveDataBase.setJwZoneCode(archive.getJwCountryCode());
        archiveDataBase.setIdentityType(1);
        archiveDataBase.setIdentityCardNo(p.getIdcard());
        archiveDataBase.setHomePhone(p.getMobile());
        archiveDataBase.setHomeAddress(archive.getAdress());
        archiveDataBase.setOrgId("0");
        archiveDataBase.setResidence(1);
        archiveDataBase.setNational(archive.getNation());
        if (StringUtils.isEmpty(archive.getOrgGo())){
            archiveDataBase.setOrigo("350200");
        }else {
            archiveDataBase.setOrigo(archive.getOrgGo());
        }
        archiveInfo.setArchiveStatus(3);
        archiveInfo.setSickSex(p.getSex());
        archiveInfo.setBirthday(archive.getBrithday());
        archiveInfo.setJwZoneCode(archive.getJwCountryCode());
        archiveInfo.setIdentityType(1);
        archiveInfo.setIdentityCardNo(p.getIdcard());
        archiveInfo.setHomePhone(p.getMobile());
        archiveInfo.setHomeAddress(archive.getAdress());
        archiveInfo.setOrgId("0");
        archiveInfo.setResidence(1);
        archiveInfo.setNational(archive.getNation());
        archiveInfo.setOrigo("350200");
        archiveInfo.setBlood(Integer.valueOf(archive.getBlood()));
        archiveInfo.setBloodRh(1);
        archiveInfo.setMarriage(Integer.valueOf(archive.getMarry()));
        archiveInfo.setInsurCardNo(p.getSsc());
        archiveDataBase.setBlood(Integer.valueOf(archive.getBlood()));
        archiveDataBase.setBloodRh(1);
        archiveDataBase.setMarriage(Integer.valueOf(archive.getMarry()));
        archiveDataBase.setInsurCardNo(p.getSsc());
        //补充参数
        json.put("ALLERGIC_WITHOUT","1");//药物过敏史--无【0不勾选 1勾选】(同一类别,新增时,默认勾选)",
@ -1016,7 +1041,8 @@ public class PatientInfoService extends BaseService {
        }
        //药物过敏史
        if(StringUtils.isNotBlank(archive.getDrugAllergys())){
        //if(StringUtils.isNotBlank(archive.getDrugAllergys())){
        if (archive.getDrugAllergys()!=null){
            String allergicStr = "";
            json.put("ALLERGIC_WITHOUT","0");//药物过敏历史
            String as[] = archive.getDrugAllergys().split(",");
@ -1033,7 +1059,8 @@ public class PatientInfoService extends BaseService {
                    json.put("ALLERGIC_STREPTOMYCIN","1");//药物过敏史--链霉素
                    allergicStr +="3,";
                }
                if("4".equals(str)){
                //if("4".equals(str)){
                if (StringUtils.isBlank(str)){
                    json.put("ALLERGIC_OTHER","1");//药物过敏史--其它
                    allergicStr +="4,";
                    archiveInfo.setAllergicOtherContent(archive.getDrugOtherContent());
@ -1048,7 +1075,8 @@ public class PatientInfoService extends BaseService {
            archiveInfo.setAllergic("0");
        }
        //既往史
        if(StringUtils.isNotBlank(archive.getPastHistorys())){
        //if(StringUtils.isNotBlank(archive.getPastHistorys())){
        if (archive.getPastHistorys() != null){
            String pastStr = "";
            String pastDateStr = "";
            json.put("PAST_NONE","0");//既往史
@ -1076,7 +1104,8 @@ public class PatientInfoService extends BaseService {
//                        json.put("PAST_HYPERTENSION_DATE",dates[i]);//既往史--疾病--高血压日期
//                    }
//                }
                else if("4".equals(phs[i])){
                //else if("4".equals(phs[i])){
                else if(StringUtils.isBlank(phs[i])){
                    json.put("PAST_OTHER","1");//既往史--疾病--其它【0不勾选 1勾选】
                    pastStr +="4,";
                    if(!"0".equals(dates[i])){
@ -1319,10 +1348,10 @@ public class PatientInfoService extends BaseService {
            }
            //子女
            if(StringUtils.isNotBlank(archive.getFamilyBrotherHistorys())){
            if(StringUtils.isNotBlank(archive.getFamilyChildrenHistorys())){
                String chidrenStr = "";
                json.put("FAMILY_CHILDREN_NONE","0");//家族史--兄弟姐妹--无【0不勾选 1勾选】
                String bhs[] = archive.getFamilyBrotherHistorys().split(",");
                json.put("FAMILY_CHILDREN_NONE","0");//家族史--子女--无【0不勾选 1勾选】
                String bhs[] = archive.getFamilyChildrenHistorys().split(",");
                for(String bh : bhs){
                    if("1".equals(bh)){
                        json.put("FAMILY_CHILDREN_HYPERTENSION","1");//家族史--子女--高血压【0不勾选 1勾选】
@ -1402,8 +1431,11 @@ public class PatientInfoService extends BaseService {
        socialSecurityInfoDao.save(info);
        //保存建档记录信息到服务器数据库
        archiveInfo.setCode(getCode());
        archiveInfo.setArchiveCode(response);
        String code = getCode();
        archiveDataBase.setCode(code);
        archiveDataBase.setArchiveCode(response);//基卫返回的建档code
        archiveInfo.setArchiveCode(code);//详细信息表关联建档记录的唯一标识code
        patientArchiveDao.save(archiveDataBase);
        patientArchiveInfoDao.save(archiveInfo);
        return 1;

+ 48 - 21
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/archives/PatientArchiveInfoService.java

@ -3,15 +3,16 @@ package com.yihu.wlyy.service.app.archives;
import com.yihu.wlyy.entity.address.City;
import com.yihu.wlyy.entity.address.Country;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.archive.ArchiveInfo;
import com.yihu.wlyy.entity.doctor.archive.Archive;
import com.yihu.wlyy.entity.doctor.archive.vo.ArchiveInfoDto;
import com.yihu.wlyy.repository.address.CityDao;
import com.yihu.wlyy.repository.address.CountryDao;
import com.yihu.wlyy.repository.archive.PatientArchiveInfoDao;
import com.yihu.wlyy.repository.archive.PatientArchiveDao;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -28,7 +29,7 @@ public class PatientArchiveInfoService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientArchiveInfoDao patientArchiveInfoDao;
    private PatientArchiveDao patientArchiveDao;
    @Autowired
    private SystemDictDao systemDictDao;
    @Autowired
@ -51,45 +52,71 @@ public class PatientArchiveInfoService {
    public List<Map<String,Object>> findArchiveList(String doctorCode, String signStatus, String startTime, String endTime, String keyWord, int pageNo, int pageSize){
        List<Map<String,Object>> archiveInfoList = new ArrayList<>();
        String sql = "SELECT " +
                " ai.code AS code, " +
                " ai.sick_name AS sickName, " +
                " ai.identity_card_no AS identityCardNo, " +
                " ai.archive_time archiveTime, " +
                " ai.sign_status AS signStatus, " +
                " a.code AS code, " +
                " a.sick_name AS sickName, " +
                " a.identity_card_no AS identityCardNo, " +
                " a.archive_time archiveTime, " +
                " a.sign_status AS signStatus, " +
                " c.name AS zoneName, " +
                " c.code AS zoneCode, " +
                " c.jw_code AS jwZoneCode " +
                " FROM " +
                " wlyy_archive_info ai " +
                " LEFT JOIN dm_country c ON ai.jw_zone_code = c.jw_code " +
                " wlyy_archive a " +
                " LEFT JOIN dm_country c ON a.jw_zone_code = c.jw_code " +
                " WHERE " +
                " doctor_code ='"+doctorCode+"'";
                " a.doctor_code ='"+doctorCode+"'";
        if (StringUtils.isNotBlank(signStatus)){
            sql += " AND ai.sign_status = "+signStatus;
            sql += " AND a.sign_status = "+signStatus;
        }
        if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
            startTime += " 00:00:00";
            endTime += " 23:59:59";
            sql += " AND ai.archive_time >= '"+startTime+"'" +
                    " AND ai.archive_time <= '"+endTime+"'";
            sql += " AND a.archive_time >= '"+startTime+"'" +
                    " AND a.archive_time <= '"+endTime+"'";
        }
        if (StringUtils.isNotBlank(keyWord)){
            sql += " AND (" +
                    " ai.sick_name LIKE '%"+keyWord+"%'" +
                    " OR ai.identity_card_no LIKE '%"+keyWord+"%'" +
                    " a.sick_name LIKE '%"+keyWord+"%'" +
                    " OR a.identity_card_no LIKE '%"+keyWord+"%'" +
                    " )";
        }
        int start = (pageNo-1)*pageSize;
        sql += " ORDER BY ai.archive_time DESC limit ?,?";
        sql += " ORDER BY a.archive_time DESC limit ?,?";
        archiveInfoList = jdbcTemplate.queryForList(sql,new Object[]{start,pageSize});
        return  archiveInfoList;
    }
    public ArchiveInfoDto findArchiveDetailsByCode(String code){
        ArchiveInfo archiveInfo = patientArchiveInfoDao.findArchiveDetailsByCode(code);
        String detailSql ="SELECT" +
                " a.*, i.allergic," +
                " i.allergic_other_content," +
                " i.disability," +
                " i.disability_other_content," +
                " i.education," +
                " i.family_brothers," +
                " i.family_children," +
                " i.family_father," +
                " i.family_mother," +
                " i.family_none," +
                " i.genetic," +
                " i.genetic_disease_name," +
                " i.medical_expenses," +
                " i.occupation," +
                " i.past," +
                " i.past_date," +
                " i.past_other_content" +
                " FROM" +
                " wlyy_archive a" +
                " LEFT JOIN wlyy_archive_info i ON a.code = i.archive_code" +
                " WHERE" +
                " a.code = '"+code+"'";
        List<ArchiveInfoDto> archiveInfoDtoList = jdbcTemplate.query(detailSql,new BeanPropertyRowMapper(ArchiveInfoDto.class));
        ArchiveInfoDto archiveInfoDto = new ArchiveInfoDto();
        BeanUtils.copyProperties(archiveInfo,archiveInfoDto);
        if (archiveInfoDtoList!=null && archiveInfoDtoList.size()>0){
            archiveInfoDto = archiveInfoDtoList.get(0);
        }
        List<SystemDict> bloodType = systemDictDao.findByDictName("BLOOD_TYPE");
        List<SystemDict> marryState = systemDictDao.findByDictName("MARRY_STATE");
        String sql = "SELECT t.NATION_CODE,t.NATION_NAME FROM zy_nation_dict t ";
@ -112,14 +139,14 @@ public class PatientArchiveInfoService {
        }
        //设置所属社区具体地址
        Country country = countryDao.findByJwCode(archiveInfo.getJwZoneCode());
        Country country = countryDao.findByJwCode(archiveInfoDto.getJwZoneCode());
        if (country != null){
            archiveInfoDto.setZoneCode(country.getCode());
            archiveInfoDto.setZoneName(country.getName());
        }
        //设置户口所在地具体地址
        City city = cityDao.findByCode(archiveInfo.getOrigo());
        City city = cityDao.findByCode(archiveInfoDto.getOrigo());
        if (city!=null){
            archiveInfoDto.setOrigoStr(city.getName());
        }

+ 16 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -2728,18 +2728,26 @@ public class ConsultTeamService extends ConsultService {
     * @return
     * @throws Exception
     */
    public int countRemainConsult(String patient) throws Exception{
        int count = 10;
    public JSONObject countRemainConsult(String patient) throws Exception{
        JSONObject json = new JSONObject();
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String versionTime = systemDictDao.findByDictNameAndCode("VERSION_TIME","1.4.2");
            int amount = consultTeamDao.countRemainConsult(patient,2,format.parse(versionTime));
            count -= amount;
            String consultTimes = systemDictDao.findByDictNameAndCode("CONSULT_TIMES","1.4.2");
            int count = Integer.valueOf(consultTimes);
            json.put("count",count);
            SignFamily signFamily = signFamilyDao.findByjiatingPatient(patient);
            if (signFamily == null){
                return json;
            }
            int amount = consultTeamDao.countRemainConsult(patient,2,signFamily.getBegin(),signFamily.getEnd());
            amount = count - amount;
            if (amount<0){
                amount = 0;
            }
            json.put("amount",amount);
        }catch (Exception e){
            e.printStackTrace();
            count = -1;
        }
        return count;
        return json;
    }
}

+ 12 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java

@ -166,11 +166,15 @@ public class FamilyMemberService extends BaseService {
        //设置家人openid 加入undefined 判断
        if(StringUtils.isBlank(m.getOpenid())&&StringUtils.isNotBlank(p.getOpenid())&&!"undefined".equals(p.getOpenid())){
            m.setOpenid(p.getOpenid());
            m.setOpenidTime(new Date());
            if(m.getOpenidTime()==null){
                m.setOpenidTime(new Date());
            }
            patientDao.save(m);
        }else if(StringUtils.isBlank(p.getOpenid())&&StringUtils.isNotBlank(m.getOpenid())&&!"undefined".equals(m.getOpenid())){
            p.setOpenid(m.getOpenid());
            p.setOpenidTime(new Date());
            if(p.getOpenidTime()==null){
                p.setOpenidTime(new Date());
            }
            patientDao.save(p);
        }
//        if(StringUtils.isBlank(m.getOpenid())){
@ -1141,11 +1145,15 @@ public class FamilyMemberService extends BaseService {
        //设置家人openid
        if(StringUtils.isBlank(m.getOpenid())&&StringUtils.isNotBlank(p.getOpenid())&&!"undefined".equals(p.getOpenid())){
            m.setOpenid(p.getOpenid());
            m.setOpenidTime(new Date());
            if(m.getOpenidTime()==null){
                m.setOpenidTime(new Date());
            }
            patientDao.save(m);
        }else if(StringUtils.isBlank(p.getOpenid())&&StringUtils.isNotBlank(m.getOpenid())&&!"undefined".equals(m.getOpenid())){
            p.setOpenid(m.getOpenid());
            p.setOpenidTime(new Date());
            if(p.getOpenidTime()==null){
                p.setOpenidTime(new Date());
            }
            patientDao.save(p);
        }

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

@ -1,28 +1,27 @@
package com.yihu.wlyy.service.app.health;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.doctor.DoctorSwitch;
import com.yihu.wlyy.entity.doctor.health.DoctorHealthStandard;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientAimSports;
import com.yihu.wlyy.entity.patient.PatientHealthStandard;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.*;
import com.yihu.wlyy.entity.patient.vo.PatientVO;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorSwitchDao;
import com.yihu.wlyy.repository.doctor.health.DoctorHealthStandardDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.third.iot.IotDeviceService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.*;
import org.apache.commons.lang3.StringUtils;
@ -33,17 +32,12 @@ import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.persistence.DynamicSpecifications;
import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.persistence.SearchFilter.Operator;
import org.springside.modules.utils.Clock;
import java.text.DecimalFormat;
@ -96,6 +90,12 @@ public class PatientHealthIndexService extends BaseService {
    private ConsultTeamDao consultTeamDao;
    @Autowired
    private MessageService messageService;
    @Autowired
    private DoctorSwitchDao doctorSwitchDao;
    @Autowired
    private TrackPatientDao trackPatientDao;
    @Autowired
    private IotDeviceService iotDeviceService;
    /**
     * 获取居民标准预警值
@ -169,7 +169,7 @@ public class PatientHealthIndexService extends BaseService {
    //更改接口(包括手动记录的修改和所有的删除)
    public void modify(long id, String recordDate, String value1, String value2, String value3, String value4) throws Exception {
        DevicePatientHealthIndex result = patientHealthIndexDao.findOne(id);
        DevicePatientHealthIndex result = findOne(id);
        if (result != null) {
            //字段值均为空为删除
            if (StringUtils.isEmpty(value1) && StringUtils.isEmpty(value2) && StringUtils.isEmpty(value3) && StringUtils.isEmpty(value4)) {
@ -196,7 +196,7 @@ public class PatientHealthIndexService extends BaseService {
                }
            }
            patientHealthIndexDao.save(result);
            update(result);
            if ("1".equals(result.getType()) || "2".equals(result.getType())) {
                verifyHealthIndex(result.getId());
            }
@ -266,143 +266,6 @@ public class PatientHealthIndexService extends BaseService {
        return map;
    }
    /**
     * 保存患者健康指标  (旧)
     */
    public DevicePatientHealthIndex save(DevicePatientHealthIndex model, int index, double value, String patientCode) throws Exception {
        model.setCzrq(clock.getCurrentDate());
        model.setDel("1");
        PatientHealthStandard standard = null;
        // 当前值/收缩压,正数为高,负数为低
        double value1 = 0;
        // 上次值/舒张压,正数为高,负数为低
        double value2 = 0;
        if (model.getType() == 1) {
            // 血糖记录,查询患者血糖预警值
            standard = patientHealthStandardDao.findByPatientType(model.getUser(), 1);
            if (index % 2 == 0) {
                // 餐后
                value1 = CommonUtil.checkHealthIndex(value, standard != null && standard.getMaxValue2() > 0 ? standard.getMaxValue2() : SystemConf.HEALTH_STANDARD_ST_MAX_AFTER, standard != null && standard.getMinValue2() > 0 ? standard.getMinValue2() : SystemConf.HEALTH_STANDARD_ST_MIN_AFTER);
            } else {
                // 餐前
                value1 = CommonUtil.checkHealthIndex(value, standard != null && standard.getMaxValue1() > 0 ? standard.getMaxValue1() : SystemConf.HEALTH_STANDARD_ST_MAX_BEFORE, standard != null && standard.getMinValue1() > 0 ? standard.getMinValue1() : SystemConf.HEALTH_STANDARD_ST_MIN_BEFORE);
            }
            // 查询上一次的血糖值
            if (value1 != 0) {
                value2 = NumberUtils.toDouble(findPreValue(model.getUser(), model.getType(), index, model.getRecordDate()), 0);
            }
        } else if (model.getType() == 2) {
            // 血压记录,查询患者血压预警值
            standard = patientHealthStandardDao.findByPatientType(model.getUser(), 2);
            // 收缩压
            value1 = CommonUtil.checkHealthIndex(NumberUtils.toDouble(model.getValue1(), 0), standard != null && standard.getMaxValue1() > 0 ? standard.getMaxValue1() : SystemConf.HEALTH_STANDARD_SSY_MAX, standard != null && standard.getMinValue1() > 0 ? standard.getMinValue1() : SystemConf.HEALTH_STANDARD_SSY_MIN);
            // 舒张压
            value2 = CommonUtil.checkHealthIndex(NumberUtils.toDouble(model.getValue2(), 0), standard != null && standard.getMaxValue2() > 0 ? standard.getMaxValue2() : SystemConf.HEALTH_STANDARD_SZY_MAX, standard != null && standard.getMinValue2() > 0 ? standard.getMinValue2() : SystemConf.HEALTH_STANDARD_SZY_MIN);
            if (value1 > 0 || value2 > 0) {
                value1 = NumberUtils.toDouble(model.getValue1(), 0);
                value2 = NumberUtils.toDouble(model.getValue2(), 0);
            } else if (value1 < 0 || value2 < 0) {
                value1 = -NumberUtils.toDouble(model.getValue1(), 0);
                value2 = -NumberUtils.toDouble(model.getValue2(), 0);
            }
        }
        // 保存到数据库
        model = patientHealthIndexDao.save(model);
        if (value1 != 0) {
            // 消息接收者
            List<String> receivers = new ArrayList<String>();
            // 查询患者信息
            Patient p = patientDao.findByCode(model.getUser());
            // 查询病人家庭签约的健康管理师
            SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(p.getCode());
            String healthDoctorFamily = "";
            if (signFamily != null) {
                healthDoctorFamily = signFamily.getDoctorHealth();
                if (StringUtils.isNotEmpty(healthDoctorFamily)) {
                    // 添加到消息接收人列表
                    receivers.add(healthDoctorFamily);
                }
            }
            // 查询病人三师签约中的健康管理师
            SignFamily signFamilySS = signFamilyDao.findBySanshiPatientYes(p.getCode());
            if (signFamilySS != null) {
                String healthDoctorTeam = signFamilySS.getDoctorHealth();
                // 判断是否是否是同一个健康管理师
                if (StringUtils.isNotEmpty(healthDoctorTeam) && !StringUtils.equals(healthDoctorFamily, healthDoctorTeam)) {
                    // 添加到消息接收人列表
                    receivers.add(healthDoctorTeam);
                }
            }
            List<Message> messages = new ArrayList<Message>();
            JSONArray array = new JSONArray();
            for (String receiver : receivers) {
                if (StringUtils.isEmpty(receiver)) {
                    continue;
                }
                Patient patient = patientDao.findByCode(patientCode);
                // 保存异常消息
                Message message = new Message();
                message.setCzrq(new Date());
                message.setCreateTime(new Date());
                message.setRead(1);
                message.setOver("1");
                message.setReceiver(receiver);
                message.setSender(p.getCode());
                message.setCode(getCode());
                message.setSex(patient.getSex());
                message.setSenderName(p.getName());
                message.setSenderPhoto(p.getPhoto());
                message.setTitle("预警值信息");
                String typeName = "";
                switch (model.getType()) {
                    case 1: {
                        typeName = "血糖";
                        break;
                    }
                    case 2: {
                        typeName = "血压";
                        break;
                    }
                    case 3: {
                        typeName = "体重";
                        break;
                    }
                    case 4: {
                        typeName = "腰围";
                        break;
                    }
                }
                message.setContent(patient.getName() + typeName + "超过预警值");
                message.setType(2);
                message.setValue1(value1);
                message.setValue2(value2);
                message.setTzCode(model.getId() + "");//消息关联的体征id
                message.setTzType(model.getType() + "");//体征类别 (1血糖,2血压,3体重,4腰围)
                messages.add(message);
                if(messageService.getMessageNoticeSettingByMessageType(receiver,"1",MessageNoticeSetting.MessageTypeEnum.healthSignSwitch.getValue())){
                    // 异常通知
                    JSONObject json = new JSONObject();
                    json.put("receiver", receiver);
                    json.put("type", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.D_HI_01.name());
                    json.put("title", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.体征指标.name());
                    json.put("msg", p.getName() + "的体征指标出现异常,请及时处理!");
                    json.put("data", "");
                    JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(receiver);
                    if (jsonObject.getString("status").equals("1")) {
                        //如果在工作时间内就推送
                        array.put(json);
                    }
                }
            }
            // 批量保存消息
            messageDao.save(messages);
            // 推送消息给医生
            pushMsgTask.put(array);
        }
        return model;
    }
    /**
     * 判断当前值是否在区间内
@ -526,61 +389,6 @@ public class PatientHealthIndexService extends BaseService {
        pushMsgTask.put(array);
    }
    /**
     * 获取患者某天血糖值
     *
     * @return
     */
    private DevicePatientHealthIndex getPatientXT(String patient, String dateString) {
        DevicePatientHealthIndex obj = new DevicePatientHealthIndex();
        obj.setUser(patient);
        boolean hadData = false;
        Date date = DateUtil.strToDateShort(dateString);
        /***************** 按时间排序 ***************************/
        List<DevicePatientHealthIndex> list = patientHealthIndexDao.findByDate(patient, dateString);
        if (list != null && list.size() > 0) {
            obj.setType(1);
            obj.setCzrq(date);
            obj.setRecordDate(date);
            obj.setSortDate(date);
            for (DevicePatientHealthIndex item : list) {
                String data = item.getValue1();
                String dataType = item.getValue2();
                Date recordDate = item.getRecordDate();
                obj.setId(item.getId());
                if (data != null && dataType != null) {
                    if (dataType.equals("1")) {
                        obj.setValue1(data);
                        hadData = true;
                    } else if (dataType.equals("2")) {
                        obj.setValue2(data);
                        hadData = true;
                    } else if (dataType.equals("3")) {
                        obj.setValue3(data);
                        hadData = true;
                    } else if (dataType.equals("4")) {
                        obj.setValue4(data);
                        hadData = true;
                    } else if (dataType.equals("5")) {
                        obj.setValue5(data);
                        hadData = true;
                    } else if (dataType.equals("6")) {
                        obj.setValue6(data);
                        hadData = true;
                    } else if (dataType.equals("7")) {
                        obj.setValue7(data);
                        hadData = true;
                    }
                }
            }
        }
        if (hadData) {
            return obj;
        } else {
            return null;
        }
    }
    /**
     * 获取患者某天血糖值
     *
@ -616,8 +424,6 @@ public class PatientHealthIndexService extends BaseService {
                " GROUP BY user,value1,value2,value3,value4,value5,value6,value7,type,record_date,sort_date " +
                " order by record_date,id desc ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
//        List<DevicePatientHealthIndex> list = patientHealthIndexDao.findByDateNative(patient, dateString);
        if (list != null && list.size() > 0) {
            obj.put("type", 1);
            obj.put("czrq", date);
@ -691,7 +497,7 @@ public class PatientHealthIndexService extends BaseService {
     */
    public void verifyHealthIndex(Long id) {
        //指标信息
        DevicePatientHealthIndex data = patientHealthIndexDao.findOne(id);
        DevicePatientHealthIndex data = findOne(id);
        String patientCode = data.getUser();
        //患者信息
        Patient patient = patientDao.findByCode(patientCode);
@ -727,14 +533,12 @@ public class PatientHealthIndexService extends BaseService {
                if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueAfter, minValueAfter)) {
                    msgContent += patient.getName() + "血糖异常(" + value1 + "mmol/L)";
                    //体征异常,更新体征数据状态
                    data.setStatus(1);
                    patientHealthIndexDao.save(data);
                    updateStatus(data);
                }
            } else { //餐前
                if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueBefore, minValueBefore)) {
                    msgContent += patient.getName() + "血糖异常(" + value1 + "mmol/L)";
                    data.setStatus(1);
                    patientHealthIndexDao.save(data);
                    updateStatus(data);
                }
            }
        }
@ -765,8 +569,7 @@ public class PatientHealthIndexService extends BaseService {
            // 收缩压/舒张压校验
            if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueSSY, minValueSSY) || !checkHealthIndex(NumberUtils.toDouble(value2), maxValueSZY, minValueSZY)) {
                msgContent = patient.getName() + "血压异常(舒张压 " + value2 + "mmHg、收缩压 " + value1 + "mmHg)";
                data.setStatus(1);
                patientHealthIndexDao.save(data);
                updateStatus(data);
            }
        }
@ -776,6 +579,63 @@ public class PatientHealthIndexService extends BaseService {
        }
    }
    /********************************************物联网 start***********************************************************/
    /**
     * 修改体征异常状态
     * @param data
     */
    public void updateStatus(DevicePatientHealthIndex data){
        if(iotDeviceService.isUploadIot()){
            //物联网更新
            iotDeviceService.updateStatus(data.getId());
        }else {
            data.setStatus(1);
            patientHealthIndexDao.save(data);
        }
    }
    /**
     * 按id查找体征记录
     * @param id
     * @return
     */
    public DevicePatientHealthIndex findOne(Long id){
        if(iotDeviceService.isUploadIot()){
            return iotDeviceService.getById(id);
        }else {
            return patientHealthIndexDao.findOne(id);
        }
    }
    /**
     * 体征保存
     * @param data
     * @return
     */
    public DevicePatientHealthIndex save(DevicePatientHealthIndex data){
        if(iotDeviceService.isUploadIot()){
            return iotDeviceService.save(data);
        }else {
            return patientHealthIndexDao.save(data);
        }
    }
    /**
     * 体征修改
     * @param data
     * @return
     */
    public DevicePatientHealthIndex update(DevicePatientHealthIndex data){
        if(iotDeviceService.isUploadIot()){
            return iotDeviceService.update(data);
        }else {
            return patientHealthIndexDao.save(data);
        }
    }
    /********************************************物联网 end***********************************************************/
    /**
     * 新增患者指标
     * 【血糖】{"time":"2016-09-09 17:00:00","gi":"血糖值(mmol/L)"}
@ -907,7 +767,7 @@ public class PatientHealthIndexService extends BaseService {
                }
            }
    
            obj = patientHealthIndexDao.save(obj);
            obj = save(obj);
            //判断是否有未结束的续方咨询,发送消息给对应的医生
            sendPrescriptionHealthIndexMsgresult(obj,patient);
@ -1000,6 +860,8 @@ public class PatientHealthIndexService extends BaseService {
	    //连续3次异常,修改用户为预警状态
	    if ((bloodPressureBbnormalCount >= 3 || bloodSuggurBbnormalCount >= 3) && (patient.getStandardStatus() == null || 0 == patient.getStandardStatus())) {
		    p.setStandardStatus(1);
            //1.4.2加入重点关注逻辑
            setTrackPatientByDoctor(patientCode);
	    } else {
		    Date end = new Date();
		    Date start = DateUtil.setDateTime(end, -7);
@ -1007,6 +869,8 @@ public class PatientHealthIndexService extends BaseService {
		    int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start, end, 1, patientCode);
		    if (errorCount >= 5) {//超过5次,记为预警状态
			    p.setStandardStatus(1);
                //1.4.2加入重点关注逻辑
                setTrackPatientByDoctor(patientCode);
		    }
	    }
	
@ -1015,24 +879,162 @@ public class PatientHealthIndexService extends BaseService {
		    if ("1".equals(patientdisease)) {
			    if (0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())) {
				    p.setStandardStatus(0);
                    //1.4.2加入重点关注逻辑
                    cancalTrackPatientByDoctor(patientCode);
			    }
		    } else if ("2".equals(patientdisease)) {
			    if (0 == bloodSuggurBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())) {
				    p.setStandardStatus(0);
                    //1.4.2加入重点关注逻辑
                    cancalTrackPatientByDoctor(patientCode);
			    }
		    } else if ("1,2".equals(patientdisease) || "2,1".equals(patientdisease)) {
			    if (0 == bloodSuggurBbnormalCount && 0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())) {
				    p.setStandardStatus(0);
                    //1.4.2加入重点关注逻辑
                    cancalTrackPatientByDoctor(patientCode);
			    }
		    }
	    } else {
		    p.setStandardStatus(0);
            //1.4.2加入重点关注逻辑
            cancalTrackPatientByDoctor(patientCode);
	    }
	
	    patientDao.save(p);
	    //连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----END
    }
    /**
     * 设置
     * @param patient
     * @return
     */
    public int setTrackPatientByDoctor(String patient){
        SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(patient);
        if(signFamily==null){
            return -1;
        }
        Patient p = patientDao.findByCode(patient);
        if(p==null){
            return -1;
        }
        //医生是否自动追踪居民
        DoctorSwitch sw =  doctorSwitchDao.findByDoctor(signFamily.getDoctor());
        DoctorSwitch swh =  doctorSwitchDao.findByDoctor(signFamily.getDoctorHealth());
        if(sw!=null){
            if("1".equals(sw.getAlertPatientSwitch())){
                //查询是否与医生建立重点跟踪关系,诺无关系则建立
                TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctor(),patient);
                if(trackPatient == null){
                    TrackPatient t = new TrackPatient();
                    t.setCreateTime(new Date());
                    t.setDoctorCode(signFamily.getDoctor());
                    t.setDoctorName(signFamily.getDoctorName());
                    t.setIdcard(signFamily.getIdcard());
                    t.setSsc(signFamily.getSsc());
                    t.setTeamCode(signFamily.getAdminTeamId().intValue());
                    t.setPatientCode(patient);
                    t.setPatientName(p.getName());
                    t.setDel("1");
                    trackPatientDao.save(t);
                }else{
                    trackPatient.setDel("1");
                    trackPatientDao.save(trackPatient);
                }
            }
        }
        if(swh!=null){
            if("1".equals(sw.getAlertPatientSwitch())){
                //查询是否与医生建立重点跟踪关系,诺无关系则建立
                TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctorHealth(),patient);
                if(trackPatient == null){
                    TrackPatient t = new TrackPatient();
                    t.setCreateTime(new Date());
                    t.setDoctorCode(signFamily.getDoctorHealth());
                    t.setDoctorName(signFamily.getDoctorHealthName());
                    t.setIdcard(signFamily.getIdcard());
                    t.setSsc(signFamily.getSsc());
                    t.setTeamCode(signFamily.getAdminTeamId().intValue());
                    t.setPatientCode(patient);
                    t.setPatientName(p.getName());
                    t.setDel("1");
                    trackPatientDao.save(t);
                }else{
                    trackPatient.setDel("1");
                    trackPatientDao.save(trackPatient);
                }
            }
        }
        return 1;
    }
    public int cancalTrackPatientByDoctor(String patient){
        SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(patient);
        if(signFamily==null){
            return -1;
        }
        Patient p = patientDao.findByCode(patient);
        if(p==null){
            return -1;
        }
        //医生是否自动追踪居民
        DoctorSwitch sw =  doctorSwitchDao.findByDoctor(signFamily.getDoctor());
        DoctorSwitch swh =  doctorSwitchDao.findByDoctor(signFamily.getDoctorHealth());
        if(sw!=null){
            if("1".equals(sw.getAlertPatientSwitch())){
                //查询是否与医生建立重点跟踪关系,诺无关系则建立
                TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctor(),patient);
                if(trackPatient == null){
                    TrackPatient t = new TrackPatient();
                    t.setCreateTime(new Date());
                    t.setDoctorCode(signFamily.getDoctor());
                    t.setDoctorName(signFamily.getDoctorName());
                    t.setIdcard(signFamily.getIdcard());
                    t.setSsc(signFamily.getSsc());
                    t.setTeamCode(signFamily.getAdminTeamId().intValue());
                    t.setPatientCode(patient);
                    t.setPatientName(p.getName());
                    t.setDel("0");
                    trackPatientDao.save(t);
                }else{
                    trackPatient.setDel("0");
                    trackPatientDao.save(trackPatient);
                }
            }
        }
        if(swh!=null){
            if("1".equals(sw.getAlertPatientSwitch())){
                //查询是否与医生建立重点跟踪关系,诺无关系则建立
                TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctorHealth(),patient);
                if(trackPatient == null){
                    TrackPatient t = new TrackPatient();
                    t.setCreateTime(new Date());
                    t.setDoctorCode(signFamily.getDoctorHealth());
                    t.setDoctorName(signFamily.getDoctorHealthName());
                    t.setIdcard(signFamily.getIdcard());
                    t.setSsc(signFamily.getSsc());
                    t.setTeamCode(signFamily.getAdminTeamId().intValue());
                    t.setPatientCode(patient);
                    t.setPatientName(p.getName());
                    t.setDel("0");
                    trackPatientDao.save(t);
                }else{
                    trackPatient.setDel("0");
                    trackPatientDao.save(trackPatient);
                }
            }
        }
        return 1;
    }
    /**
     * 按录入时间和患者标识查询健康记录
@ -1053,32 +1055,32 @@ public class PatientHealthIndexService extends BaseService {
     * @param end   结束时间
     * @return
     */
    public List<DevicePatientHealthIndex> findChartByPatien(String patient, int type, String begin, String end) {
        List<DevicePatientHealthIndex> re = new ArrayList<>();
        Date startDate = DateUtil.strToDate(begin, DateUtil.YYYY_MM_DD_HH_MM_SS);
        Date endDate = DateUtil.strToDate(end, DateUtil.YYYY_MM_DD_HH_MM_SS);
        if (type == 1)   //血糖特殊处理
        {
            //根据时间过滤排序
            List<String> dateList = patientHealthIndexDao.findDateList(patient, startDate, endDate, null);
            if (dateList != null && dateList.size() > 0) {
                for (int i = dateList.size() - 1; i >= 0; i--) {
                    String dateString = dateList.get(i);
                    DevicePatientHealthIndex obj = getPatientXT(patient, dateString);
                    if (obj != null) {
                        re.add(obj);
                    }
                }
            }
        } else {
            // 排序
            Sort sort = new Sort(Direction.ASC, "recordDate");
            PageRequest pageRequest = new PageRequest(0, 1000, sort);
            re = patientHealthIndexDao.findIndexByPatient(patient, type, startDate, endDate, pageRequest).getContent();
        }
        return re;
    }
//    public List<DevicePatientHealthIndex> findChartByPatien(String patient, int type, String begin, String end) {
//        List<DevicePatientHealthIndex> re = new ArrayList<>();
//
//        Date startDate = DateUtil.strToDate(begin, DateUtil.YYYY_MM_DD_HH_MM_SS);
//        Date endDate = DateUtil.strToDate(end, DateUtil.YYYY_MM_DD_HH_MM_SS);
//        if (type == 1)   //血糖特殊处理
//        {
//            //根据时间过滤排序
//            List<String> dateList = patientHealthIndexDao.findDateList(patient, startDate, endDate, null);
//            if (dateList != null && dateList.size() > 0) {
//                for (int i = dateList.size() - 1; i >= 0; i--) {
//                    String dateString = dateList.get(i);
//                    DevicePatientHealthIndex obj = getPatientXT(patient, dateString);
//                    if (obj != null) {
//                        re.add(obj);
//                    }
//                }
//            }
//        } else {
//            // 排序
//            Sort sort = new Sort(Direction.ASC, "recordDate");
//            PageRequest pageRequest = new PageRequest(0, 1000, sort);
//            re = patientHealthIndexDao.findIndexByPatient(patient, type, startDate, endDate, pageRequest).getContent();
//        }
//        return re;
//    }
    /**
     * 按时间段查询患者健康指标
@ -1148,19 +1150,6 @@ public class PatientHealthIndexService extends BaseService {
            re.put(json);
        }
//        if (gi_type != 0) {
//            Sort sort = new Sort(Direction.ASC, "recordDate");
//            PageRequest pageRequest = new PageRequest(0, 1000, sort);
//            re = patientHealthIndexDao.findIndexByPatientNative(patient, type, gi_type + "", startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
//
//        } else {
//            // 排序
//            Sort sort = new Sort(Direction.ASC, "recordDate");
//            PageRequest pageRequest = new PageRequest(0, 1000, sort);
//            re = patientHealthIndexDao.findIndexByPatientNative(patient, type, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
//        }
        return re;
    }
@ -1180,22 +1169,9 @@ public class PatientHealthIndexService extends BaseService {
        if (page > 0) {
            page = page - 1;
        }
        Date startDate = DateUtil.strToDate(start, DateUtil.YYYY_MM_DD_HH_MM_SS);
        Date endDate = DateUtil.strToDate(end, DateUtil.YYYY_MM_DD_HH_MM_SS);
        if (type == 1)   //血糖特殊处理
        {
//            PageRequest pageRequest = new PageRequest(page, pageSize);
//            //根据时间过滤排序
//            List<String> dateList = patientHealthIndexDao.findDateList(patient, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
//            if (dateList != null && dateList.size() > 0) {
//                for (String dateString : dateList) {
//                    DevicePatientHealthIndex obj = getPatientXT(patient, dateString);
//                    if (obj != null) {
//                        re.add(obj);
//                    }
//                }
//            }
        } else {
            // 排序
            Sort sort = new Sort(Direction.DESC, "recordDate");
@ -1250,10 +1226,6 @@ public class PatientHealthIndexService extends BaseService {
                re.put(json);
            }
//            List<DevicePatientHealthIndex> list = patientHealthIndexDao.findIndexByPatientNative(patient, type, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
//            re = list;
        }
        return re;
    }
@ -1298,39 +1270,6 @@ public class PatientHealthIndexService extends BaseService {
        return re;
    }
    /**
     * 根据患者标志获取健康指标
     *
     * @param patientCode 患者标志
     * @param pageSize    页数
     * @return 健康指标列表
     */
    public Page<DevicePatientHealthIndex> findByPatien(String patientCode, int type, Date sortDate, Date begin, Date end, int pageSize) {
        if (pageSize <= 0) {
            pageSize = 10;
        }
        // 排序
        Sort sort = new Sort(Direction.DESC, "sortDate");
        // 分页信息
        PageRequest pageRequest = new PageRequest(0, pageSize, sort);
        // 设置查询条件
        Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
        // 患者标志
        filters.put("user", new SearchFilter("user", Operator.EQ, patientCode));
        if (sortDate != null) {
            filters.put("sortDate", new SearchFilter("sortDate", Operator.LT, sortDate));
        }
        filters.put("recordDate1", new SearchFilter("recordDate", Operator.GTE, begin));
        filters.put("recordDate2", new SearchFilter("recordDate", Operator.LTE, end));
        filters.put("type", new SearchFilter("type", Operator.EQ, type));
        // 未作废
        filters.put("del", new SearchFilter("del", Operator.EQ, "1"));
        Specification<DevicePatientHealthIndex> spec = DynamicSpecifications.bySearchFilter(filters.values(), DevicePatientHealthIndex.class);
        return patientHealthIndexDao.findAll(spec, pageRequest);
    }
    /**
     * 查询患者健康指标预警值
     *
@ -1433,48 +1372,6 @@ public class PatientHealthIndexService extends BaseService {
        return array;
    }
    /**
     * 查询上一次的值
     *
     * @param patient 患者标识
     * @param type    类型:1血糖,2血压
     * @param index   第几个值,1~7
     * @return
     */
    private String findPreValue(String patient, int type, int index, Date recordDate) {
        // 分页信息
        PageRequest pageRequest = new PageRequest(0, 1);
        Page<String> page = null;
        switch (index) {
            case 1:
                page = patientHealthIndexDao.findValue1ByPatient(patient, type, recordDate, pageRequest);
                break;
            case 2:
                page = patientHealthIndexDao.findValue2ByPatient(patient, type, recordDate, pageRequest);
                break;
            case 3:
                page = patientHealthIndexDao.findValue3ByPatient(patient, type, recordDate, pageRequest);
                break;
            case 4:
                page = patientHealthIndexDao.findValue4ByPatient(patient, type, recordDate, pageRequest);
                break;
            case 5:
                page = patientHealthIndexDao.findValue5ByPatient(patient, type, recordDate, pageRequest);
                break;
            case 6:
                page = patientHealthIndexDao.findValue6ByPatient(patient, type, recordDate, pageRequest);
                break;
            case 7:
                page = patientHealthIndexDao.findValue7ByPatient(patient, type, recordDate, pageRequest);
                break;
        }
        if (page != null && page.getNumberOfElements() > 0) {
            return page.getContent().get(0);
        }
        return "0";
    }
    /**
     * 根据患者标志获取健康指标
     *
@ -1485,12 +1382,6 @@ public class PatientHealthIndexService extends BaseService {
        //最新血糖指标
        if (type == 1) {
            DevicePatientHealthIndex obj = patientHealthIndexDao.findLastData(patientCode, 1);
//            if (obj != null) {
//                String dateString = DateUtil.dateToStrShort(obj.getRecordDate());
//                return getPatientXT(patientCode, dateString);
//            } else {
//                return null;
//            }
            return obj;
        } else if (type == 2) {  //其他指标
            return patientHealthIndexDao.findLastData(patientCode, 2);
@ -1499,25 +1390,6 @@ public class PatientHealthIndexService extends BaseService {
        }
    }
    public com.alibaba.fastjson.JSONObject findLastBypatient(String patientCode, int type) {
        if (type == 1) {
            DevicePatientHealthIndex obj = patientHealthIndexDao.findLastData(patientCode, 1);
            if (obj != null) {
                String dateString = DateUtil.dateToStrShort(obj.getRecordDate());
                return getPatientXT_Json(patientCode, dateString);
            } else {
                return null;
            }
        } else {
            DevicePatientHealthIndex obj = patientHealthIndexDao.findLastData(patientCode, type);
            if (obj != null) {
                return JSON.parseObject(JSON.toJSONString(obj));
            } else {
                return null;
            }
        }
    }
    /**
     * 获取患者健康指标历史记录
     * 1血糖,2血压,3体重,4腰围

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

@ -488,7 +488,7 @@ public class SignPatientLabelInfoService extends BaseService {
                List<PatientVO> plist = new ArrayList<>();
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select user,group_concat(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
@ -609,7 +609,7 @@ public class SignPatientLabelInfoService extends BaseService {
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                json.put("deviceType",p.getDeviceType());
                json.put("deviceType",p.getDeviceType()==null?"":p.getDeviceType());
                boolean epTime = false;
                try {
@ -1210,8 +1210,10 @@ public class SignPatientLabelInfoService extends BaseService {
                                "     AND t2.status = 1 " +
                                "     AND (t1.doctor = ? or t1.doctor_health = ?)" +
                                "     AND t1.status > 0 " +
                                (teamCode > 0 ? "    AND t1.admin_team_code = ? " : "")+
                                "     AND t3.disease_condition = ? ";
                                (teamCode > 0 ? "    AND t1.admin_team_code = ? " : "");
                                if(StringUtils.isNotBlank(diseaseCondition)){
                                   sql+=" AND t3.disease_condition = ? ";
                                }
                                //1.4.2新增重点居民跟踪过滤
                                if(StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
                                    sql = sql + " AND tp.del='1' AND tp.doctor_code='"+doctor+"' AND tp.team_code ="+teamCode;
@ -1221,9 +1223,17 @@ public class SignPatientLabelInfoService extends BaseService {
                                }
                        if (teamCode > 0) {
                            args = new Object[]{label.getLabelCode(), labelType, doctor, doctor, teamCode,diseaseCondition};
                            if(StringUtils.isNotBlank(diseaseCondition)){
                                args = new Object[]{label.getLabelCode(), labelType, doctor, doctor, teamCode,diseaseCondition};
                            }else {
                                args = new Object[]{label.getLabelCode(), labelType, doctor, doctor, teamCode};
                            }
                        } else {
                            args = new Object[]{label.getLabelCode(), labelType, doctor, doctor,diseaseCondition};
                            if(StringUtils.isNotBlank(diseaseCondition)){
                                args = new Object[]{label.getLabelCode(), labelType, doctor, doctor,diseaseCondition};
                            }else{
                                args = new Object[]{label.getLabelCode(), labelType, doctor, doctor};
                            }
                        }
                    }else{
                        continue;
@ -2412,7 +2422,7 @@ public class SignPatientLabelInfoService extends BaseService {
                List<PatientVO> plist = new ArrayList<>();
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select user,group_concat(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
@ -2556,7 +2566,7 @@ public class SignPatientLabelInfoService extends BaseService {
                //预警状态
                json.put("standardStatus", p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                json.put("deviceType",p.getDeviceType());
                json.put("deviceType",p.getDeviceType()==null?"":p.getDeviceType());
                
                
                boolean epTime = false;
@ -2690,7 +2700,7 @@ public class SignPatientLabelInfoService extends BaseService {
                List<PatientVO> plist = new ArrayList<>();
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select user,group_concat(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
@ -2834,7 +2844,7 @@ public class SignPatientLabelInfoService extends BaseService {
                //预警状态
                json.put("standardStatus", p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                json.put("deviceType",p.getDeviceType());
                json.put("deviceType",p.getDeviceType()==null?"":p.getDeviceType());
                
                boolean epTime = false;
                try {
@ -3518,7 +3528,7 @@ public class SignPatientLabelInfoService extends BaseService {
                List<PatientVO> plist = new ArrayList<>();
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select user,group_concat(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
@ -3646,7 +3656,7 @@ public class SignPatientLabelInfoService extends BaseService {
                //预警状态
                json.put("standardStatus", p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                json.put("deviceType",p.getDeviceType());
                json.put("deviceType",p.getDeviceType()==null?"":p.getDeviceType());
                
                boolean epTime = false;
                try {
@ -3707,7 +3717,7 @@ public class SignPatientLabelInfoService extends BaseService {
                List<PatientVO> plist = new ArrayList<>();
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select user,group_concat(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
@ -3835,7 +3845,7 @@ public class SignPatientLabelInfoService extends BaseService {
                //预警状态
                json.put("standardStatus", p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                json.put("deviceType",p.getDeviceType());
                json.put("deviceType",p.getDeviceType()==null?"":p.getDeviceType());
                
                boolean epTime = false;
                try {
@ -4013,17 +4023,6 @@ public class SignPatientLabelInfoService extends BaseService {
        sql = sql + " limit " + start + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
//        //查询患者设备绑定情况
//        String _pdsql = "select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user";
//        List<Map<String,Object>> patientCodeDeviceTypes =  jdbcTemplate.queryForList(_pdsql);
//
//        if(!patientCodeDeviceTypes.isEmpty()){
//            for (Map<String,Object> patientCodeDeviceType : patientCodeDeviceTypes) {
//                String user = String.valueOf(patientCodeDeviceType.get("user"));
//                String sum = String.valueOf(patientCodeDeviceType.get("deviceType"));
//                patientDeviceTypeMap.put(user,sum);
//            }
//        }
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
@ -4036,8 +4035,8 @@ public class SignPatientLabelInfoService extends BaseService {
                PatientVO p = new PatientVO();
                List<PatientVO> plist = new ArrayList<>();
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                    String patientsql = "select a.*,b. as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,group_concat(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
@ -4164,7 +4163,7 @@ public class SignPatientLabelInfoService extends BaseService {
//                    deviceType = (String) patientDeviceTypeMap.get(p.getCode());
//                }
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                json.put("deviceType",p.getDeviceType());
                json.put("deviceType",p.getDeviceType()==null?"":p.getDeviceType());
                boolean epTime = false;
@ -4488,7 +4487,7 @@ public class SignPatientLabelInfoService extends BaseService {
                List<PatientVO> plist = new ArrayList<>();
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select user,group_concat(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
@ -4633,7 +4632,7 @@ public class SignPatientLabelInfoService extends BaseService {
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                json.put("deviceType",p.getDeviceType());
                json.put("deviceType",p.getDeviceType()==null?"":p.getDeviceType());
                boolean epTime = false;
                try {
@ -4699,7 +4698,7 @@ public class SignPatientLabelInfoService extends BaseService {
                List<PatientVO> plist = new ArrayList<>();
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select user,group_concat(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
@ -4827,7 +4826,7 @@ public class SignPatientLabelInfoService extends BaseService {
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                json.put("deviceType",p.getDeviceType());
                json.put("deviceType",p.getDeviceType()==null?"":p.getDeviceType());
                boolean epTime = false;
                try {

+ 0 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -452,12 +452,6 @@ public class MessageService extends BaseService {
                    map.put("value1", data.getValue1());
                    String value2 = Integer.valueOf(data.getValue2()).toString();
                    map.put("value2",value2);
                    /*//获取上次血糖值
                    if("1".equals(type))
                    {
                        String preValue = devicePatientHealthIndexDao.getPreValue(item.getSender(),Long.valueOf(item.getTzCode()),value2);
                        map.put("preValue",preValue);
                    }*/
                }
                re.add(map);

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PhysicalExaminationRemindService.java

@ -194,7 +194,7 @@ public class PhysicalExaminationRemindService extends BaseService {
                List<PatientVO> plist = new ArrayList<>();
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select user,group_concat(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
@ -271,7 +271,7 @@ public class PhysicalExaminationRemindService extends BaseService {
                //预警状态
                json.put("standardStatus", p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                json.put("deviceType",p.getDeviceType());
                json.put("deviceType",p.getDeviceType()==null?"":p.getDeviceType());
                boolean epTime = false;
                try {

+ 20 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java

@ -483,14 +483,30 @@ public class PrescriptionService extends BaseService {
     * @return
     */
    public List<Map<String,Object>> getPrescriptionByKeyWord(String keyWord,int pageNo,int pageSize){
        String sql = "SELECT p.code,p.patient_name,p.doctor_name,p.hospital_name,p.dispensary_type,p.status," +
                "p.create_time,GROUP_CONCAT(d.health_problem) AS health_problem, GROUP_CONCAT(d.health_problem_name) AS health_problem_name " +
                "FROM wlyy_prescription p LEFT JOIN wlyy_prescription_diagnosis d ON p.code = d.prescription_code WHERE 1=1 " ;
        String sql = "SELECT" +
                " p. CODE," +
                " p.patient_name," +
                " p.doctor_name," +
                " p.hospital_name," +
                " p.dispensary_type," +
                " p. STATUS," +
                " p.create_time," +
                " GROUP_CONCAT(d.health_problem) AS health_problem," +
                " GROUP_CONCAT(d.health_problem_name) AS health_problem_name"+
                " FROM" +
                " wlyy_prescription p" +
                " LEFT JOIN wlyy_prescription_diagnosis d ON p. CODE = d.prescription_code" +
                //" LEFT JOIN wlyy_prescription_pay a ON p.code = a.prescription_code" +
                " WHERE" +
                " 1 = 1 " ;
        //判断关键字
        if (StringUtils.isNotBlank(keyWord)){
            sql += " AND (p.patient_name like '%"+keyWord+"%' or p.doctor_name like '%"+keyWord+"%')";
        }
        sql += " GROUP BY p.code ORDER  BY p.create_time DESC limit ?,?";
        sql += " GROUP BY p.code ORDER  BY p.create_time DESC ";
        sql+=" limit ?,?";
        int start = (pageNo-1)*pageSize;
        List<Map<String,Object>> resultList = jdbcTemplate.queryForList(sql,new Object[]{start,pageSize});
        return resultList;

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

@ -1945,4 +1945,38 @@ public class DoctorSchemeService extends BaseService{
        sql += " ORDER BY highCount DESC LIMIT "+(page-1)*size+","+size;
        return sql;
    }
    public Map<String,Object> getDefaultScheme(String type){
        Map<String,Object> rs = new HashedMap();
        //1. 血糖2.血压
        if("1".equals(type)){
            List<DoctorSchemeBloodSugger> list =  doctroSchemeBloodSuggerDao.findByCode("default");
            rs.put("code","default");
            rs.put("name",list.get(0).getName());
            rs.put("content",list.get(0).getContent());
            rs.put("list",list);
        }else{
            List<DoctorSchemeBloodPressure> list =  doctoreSchemeBloodPressureDao.findByCode("default");
            rs.put("code","default");
            rs.put("name",list.get(0).getName());
            rs.put("content",list.get(0).getContent());
            rs.put("list",list);
        }
        return rs;
    }
    public String setPatientDefaultScheme(String patient,String type){
        PatientSchemeList pl = new PatientSchemeList();
        pl.setPatientcode(patient);
        pl.setCode(getCode());
        if("0".equals(type)){
            pl.setType(1);
        }else{
            pl.setType(2);
        }
        pl.setSchemecode("default");
        pl.setCreateTime(new Date());
        patientSchemeListDao.save(pl);
        return "0";
    }
}

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

@ -3,15 +3,31 @@ package com.yihu.wlyy.service.third.iot;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.entity.device.DeviceHealthyInfoMapping;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.deviece.DeviceHealthyInfoMappingDao;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.stereotype.Service;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@ -21,8 +37,10 @@ import java.util.List;
@Service
public class IotDeviceService {
    private Logger logger = LoggerFactory.getLogger(IotDeviceService.class);
//    @Value("${}")
    private String baseUrl = "http://192.168.131.24:8080/svr-iot/";
    private String baseUrl = "http://192.168.131.24:8080/svr-iot-ysj/";
    private String grantType = "client_credentials";
    private String clientId = "Va5yQRHlA4Fq4eR3LT0vuXV4";
    private String clientSecret = "0rDSjzQ20XUj5itV7WRtznPQSzr5pVw2";
@ -37,20 +55,401 @@ public class IotDeviceService {
    private String waistUnit = "cm";
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private SystemDictDao systemDictDao;
    @Autowired
    private DeviceHealthyInfoMappingDao deviceHealthyInfoMappingDao;
    /**
     * 判断是否数据上传到物联网
     * @return
     */
    public Boolean isUploadIot(){
        String value = systemDictDao.findByDictNameAndCode("SYSTEM_PARAMS","DEVICE_UPLOAD_IOT");
        return "1".equals(value)?true:false;
    }
    public JSONObject test(){
//        String sql = "select response from wlyy_http_log_detail where id = 1";
//        List<String> list = jdbcTemplate.queryForList(sql,String.class);
        String sql = "SELECT i.id,i.user,i.value1,i.value2,i.value3,i.value4,i.type,i.record_date,i.device_sn,i.status,i.del,d.device_name,d.user_type,p.name,p.idcard " +
                "from device.wlyy_patient_health_index i " +
                "LEFT JOIN wlyy_patient_device d on i.`user` = d.`user` and i.device_sn = d.device_sn " +
                "LEFT JOIN wlyy_patient p on i.`user` = p.code order by i.id limit 1";
        List<JSONObject> list = jdbcTemplate.query(sql, new ResultSetExtractor<List<JSONObject>>() {
            @Override
            public List<JSONObject> extractData(ResultSet resultSet) throws SQLException, DataAccessException {
                ResultSetMetaData rsd = resultSet.getMetaData();
                int clength = rsd.getColumnCount();
                List<JSONObject> li = new ArrayList<JSONObject>();
                String columnName;
                try {
                    while (resultSet.next()) {
                        JSONObject jo = new JSONObject();
                        for (int i = 0; i < clength; i++) {
                            columnName = rsd.getColumnLabel(i + 1);
                            jo.put(columnName, resultSet.getObject(i + 1));
                        }
                        li.add(jo);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return li;
            }
        });
        if(list.size()>0){
            JSONObject one = list.get(0);
            String response = initUpload(one);
            return JSONObject.parseObject(response);
        }
        return null;
    }
    public String getAccessToken(){
        String url = baseUrl+"/oauth/2.0/token";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("grant_type",grantType));
        params.add(new BasicNameValuePair("client_id",clientId));
        params.add(new BasicNameValuePair("client_secret",clientSecret));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return null;
    }
    /**
     * 设备注册及绑定
     * @return
     */
    public String registedevice(JSONObject json){
        json.put("access_token",accessToken);
        json.put("data_source",dataSource);
        String url = baseUrl+"/dataInput/userBind";
        String response = httpClientUtil.iotPostBody(url, json.toString());
        return response;
    }
    /**
     * 数据上传
     * @param json
     * @return
     */
    public String upload(JSONObject json){
        json.put("access_token",accessToken);
        json.put("data_source",dataSource);
        String url = baseUrl+"/dataInput/input";
        String response = httpClientUtil.iotPostBody(url, json.toString());
        return response;
    }
    /**
     *  查询重复数据
     * @return
     */
    public String findRepeat(String user,String deviceSn,String value1,String value2,String type,String time){
        JSONArray jsonArray = new JSONArray();
        JSONObject jsonUser = new JSONObject();
        jsonUser.put("andOr","and");
        jsonUser.put("filed","usercode");
        jsonUser.put("condition","=");
        jsonUser.put("value",user);
        jsonArray.add(jsonUser);
        JSONObject jsonSn = new JSONObject();
        jsonSn.put("andOr","and");
        jsonSn.put("filed","sn");
        jsonSn.put("condition","=");
        jsonSn.put("value",deviceSn);
        jsonArray.add(jsonSn);
        if("1".equals(type)){
            //血糖
            JSONObject jsonValue1 = new JSONObject();
            jsonValue1.put("andOr","and");
            jsonValue1.put("filed","blood_sugar");
            jsonValue1.put("condition","=");
            jsonValue1.put("value",value1);
            jsonArray.add(jsonValue1);
        }else {
            //血压
            JSONObject jsonValue1 = new JSONObject();
            jsonValue1.put("andOr","and");
            jsonValue1.put("filed","systolic");
            jsonValue1.put("condition","=");
            jsonValue1.put("value",value1);
            JSONObject jsonValue2 = new JSONObject();
            jsonValue2.put("andOr","and");
            jsonValue2.put("filed","diastolic");
            jsonValue2.put("condition","=");
            jsonValue2.put("value",value2);
            jsonArray.add(jsonValue1);
            jsonArray.add(jsonValue2);
        }
        JSONObject jsonTime = new JSONObject();
        jsonTime.put("andOr","and");
        jsonTime.put("filed","measure_time");
        jsonTime.put("condition","=");
        jsonTime.put("value",time);
        String url = baseUrl+"/findById";
        String response = httpClientUtil.iotPostBody(url, jsonArray.toString());
        return response;
    }
    /**
     * 查询单条
     * @param rid
     * @return
     */
    public String getById(String rid){
        JSONObject json = new JSONObject();
        json.put("andOr","and");
        json.put("filed","rid");
        json.put("condition","=");
        json.put("value",rid);
        String url = baseUrl+"/getById";
        String response = httpClientUtil.iotPostBody(url, json.toString());
        return response;
    }
    /**
     * 查询
     * filter
     * - 参数格式:[{"andOr":"and|or","condition":">|=|<|>=|<=|?","field":"<filed>","value":"<value>"},<{...}>]
     * - 参数说明:andOr跟数据库的中的AND和OR相似;condition指条件匹配程度,?相当于数据库中的like;filed指检索的字段;value为检索的值
     * page - 参数说明:页码
     * size - 参数说明:分页大小
     * @param json
     * @return
     */
    public String searchList(JSONObject json){
        String url = baseUrl+"/searchList";
        String response = httpClientUtil.iotPostBody(url, json.toString());
        return response;
    }
    /**
     *
     * @param json
     * @return
     */
    public String listPage(JSONObject json){
        String url = baseUrl+"/listPage";
        String response = httpClientUtil.iotPostBody(url, json.toString());
        return response;
    }
    /**
     * 获取最近5条数据
     * @param json
     * @param sort
     * @return
     */
    public String recent5(JSONObject json,JSONObject sort){
        json.put("access_token",accessToken);
        String url = baseUrl+"/recent5";
        String response = httpClientUtil.iotPostBody(url, json.toString());
        return response;
    }
    /**
     * 获取居民一周内体征数据异常次数
     * @param json
     * @param sort
     * @return
     */
    public String recent1(JSONObject json,JSONObject sort){
        json.put("access_token",accessToken);
        String url = baseUrl+"/recent1";
        String response = httpClientUtil.iotPostBody(url, json.toString());
        return response;
    }
    /**
     * 初始化迁移数据
     * @return
     */
    public String initData(){
        Integer page = 1;
        Integer size = 1000;
        Integer start = (page-1)*size;
        String sql = "SELECT i.id,i.user,i.value1,i.value2,i.value3,i.value4,i.type,i.record_date,i.device_sn,i.status,i.del,d.device_name,d.user_type,p.name,p.idcard " +
                "from device.wlyy_patient_health_index i " +
                "LEFT JOIN wlyy_patient_device d on i.`user` = d.`user` and i.device_sn = d.device_sn " +
                "LEFT JOIN wlyy_patient p on i.`user` = p.code order by i.id limit ?,1000";
        List<JSONObject> list = jdbcTemplate.query(sql,new Object[]{start}, new ResultSetExtractor<List<JSONObject>>() {
            @Override
            public List<JSONObject> extractData(ResultSet resultSet) throws SQLException, DataAccessException {
                ResultSetMetaData rsd = resultSet.getMetaData();
                int clength = rsd.getColumnCount();
                List<JSONObject> li = new ArrayList<JSONObject>();
                String columnName;
                try {
                    while (resultSet.next()) {
                        JSONObject jo = new JSONObject();
                        for (int i = 0; i < clength; i++) {
                            columnName = rsd.getColumnLabel(i + 1);
                            jo.put(columnName, resultSet.getObject(i + 1));
                        }
                        li.add(jo);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return li;
            }
        });
        while (list.size()>0){
            List<DeviceHealthyInfoMapping> infos = new ArrayList<>();
            list.stream().forEach(one->{
                String response = initUpload(one);
                JSONObject re = JSONObject.parseObject(response);
                String errorMsg = re.getString("errorMsg");//错误信息(请求失败才有错误消息)
                if(StringUtils.isNotBlank(errorMsg)){
                    logger.error("id:"+one.getInteger("id")+" "+errorMsg);
                }else {
                    //保存映射关系
                    DeviceHealthyInfoMapping info = new DeviceHealthyInfoMapping();
                    info.setCreateTime(new Date());
                    info.setIndexId(one.getLong("id"));
                    infos.add(info);
                }
            });
            deviceHealthyInfoMappingDao.save(infos);
            logger.info("上传成功:"+(page*size));
            //下一次
            page++;
            start = (page-1)*size;
            list = jdbcTemplate.queryForList(sql,new Object[]{start},JSONObject.class);
        }
        return null;
    }
    /**
     * 初始化上传
     * @param jsonObject
     * @return
     */
    public String initUpload(JSONObject jsonObject){
        JSONObject json = new JSONObject();
        Integer type = jsonObject.getInteger("type");
        json.put("sn",StringUtils.trimToEmpty(jsonObject.getString("device_sn")));
        json.put("ext_code",StringUtils.trimToEmpty(jsonObject.getString("user_type")));
        json.put("device_name",transfor(jsonObject.getString("device_name"),1,type));
        json.put("device_model",transfor(jsonObject.getString("device_name"),2,type));
        json.put("idcard",StringUtils.trimToEmpty(jsonObject.getString("idcard")));
        json.put("username",StringUtils.trimToEmpty(jsonObject.getString("name")));
        json.put("usercode",StringUtils.trimToEmpty(jsonObject.getString("user")));
        JSONArray jsonArray = new JSONArray();
        JSONObject js = new JSONObject();
//        js.put("id",String.valueOf(jsonObject.getInteger("id")));
        js.put("measure_time",subStringTime(jsonObject.getString("record_date")));
        js.put("del",StringUtils.trimToEmpty(jsonObject.getString("del")));
        js.put("status",StringUtils.trimToEmpty(jsonObject.getString("status")));
        switch (type){
            case 1:
                //血糖
                js.put("blood_sugar",jsonObject.getString("value1"));
                js.put("blood_sugar_unit",bloodSugarUnit);
                js.put("blood_sugar_result",jsonObject.getString("value2"));
                break;
            case 2:
                //血压
                js.put("systolic",jsonObject.getString("value1"));
                js.put("systolic_unit",bloodPressureUnit);
                js.put("diastolic",jsonObject.getString("value2"));
                js.put("diastolic_unit",bloodPressureUnit);
                if(StringUtils.isNotBlank(jsonObject.getString("value3"))){
                    js.put("pulse",jsonObject.getString("value3"));
                    js.put("pulse_unit",pulseUnit);
                }
                break;
            case 3:
                //体重/身高/BMI
                js.put("height",jsonObject.getString("value1"));
                js.put("height_unit",heightUnit);
                js.put("weight",jsonObject.getString("value2"));
                js.put("weight_unit",weightUnit);
                if(StringUtils.isNotBlank(jsonObject.getString("value3"))){
                    js.put("bmi",jsonObject.getString("value3"));
                    js.put("bmi_unit",bmiUnit);
                }
                break;
            case 4:
                //腰围
                js.put("waist",jsonObject.getString("value1"));
                js.put("waist_unit",waistUnit);
                break;
            default:
                break;
        }
        jsonArray.add(js);
        json.put("data",jsonArray);
        //上传
        return upload(json);
    }
    /************************************i健康业务相关 start************************************************************/
    /**
     * 更新状态
     * @param id
     */
    public void updateStatus(Long id){
        DeviceHealthyInfoMapping mapping = deviceHealthyInfoMappingDao.findByIndexId(id,id);
        if(mapping == null){
            logger.info("未找到映射关系,id:"+id);
        }else {
            JSONObject json = new JSONObject();
            String url = baseUrl+"/dataInput/updateRecord";
            String response = httpClientUtil.iotPostBody(url, json.toString());
        }
    }
    /**
     * 将上传数据转换成标准的json传
     * 查询单条
     * @param id
     * @return
     */
    public DevicePatientHealthIndex getById(Long id){
        DeviceHealthyInfoMapping mapping = deviceHealthyInfoMappingDao.findByIndexId(id,id);
        if(mapping == null){
            logger.info("未找到映射关系,id:"+id);
            return null;
        }else {
            return transforOne(getById(mapping.getRid()),id);
        }
    }
    /**
     * 体征上传
     * @param obj
     * @param userType
     * @return
     */
    public DevicePatientHealthIndex upload(DevicePatientHealthIndex obj,String userType,String deviceName,String deviceModel,Patient patient){
    public DevicePatientHealthIndex save(DevicePatientHealthIndex obj){
        JSONObject json = new JSONObject();
        json.put("sn",obj.getDeviceSn());
        json.put("ext_code",userType);
        json.put("device_name",deviceName);
        json.put("device_model",deviceModel);
        if(StringUtils.isNotBlank(obj.getDeviceSn())){
            json.put("sn",obj.getDeviceSn());
            List<PatientDevice> devices = patientDeviceDao.findByPatientAndDeviceSn(obj.getUser(),obj.getDeviceSn());
            if(devices!=null&&devices.size()>0){
                PatientDevice device = devices.get(0);
                json.put("ext_code",device.getUserType());
                json.put("device_name",transfor(device.getDeviceName(),1,obj.getType()));
                json.put("device_model",transfor(device.getDeviceName(),2,obj.getType()));
            }
        }
        Patient patient = patientDao.findByCode(obj.getUser());
        json.put("idcard",patient.getIdcard());
        json.put("username",patient.getName());
        json.put("usercode",patient.getCode());
@ -101,67 +500,111 @@ public class IotDeviceService {
        String response = upload(json);
        JSONObject re = JSONObject.parseObject(response);
        String errorMsg = re.getString("errorMsg");//错误信息(请求失败才有错误消息)
        String successMsg = re.getString("successMsg");//成功信息(请求成功才有成功消息)
        if(StringUtils.isBlank(errorMsg)){
            re.getJSONObject("obj").getString("id");
            String rid = re.getJSONObject("obj").getJSONArray("rid").getString(0);
            DeviceHealthyInfoMapping mapping = new DeviceHealthyInfoMapping();
            mapping.setCreateTime(new Date());
            mapping.setRid(rid);
            deviceHealthyInfoMappingDao.save(mapping);
            obj.setId(mapping.getId());
        }else {
            logger.error(errorMsg);
            return null;
        }
        return obj;
    }
    public String getAccessToken(){
        String url = baseUrl+"/oauth/2.0/token";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("grant_type",grantType));
        params.add(new BasicNameValuePair("client_id",clientId));
        params.add(new BasicNameValuePair("client_secret",clientSecret));
        String response = httpClientUtil.post(url, params, "UTF-8");
    /**
     * 更新
     * @param obj
     * @return
     */
    public DevicePatientHealthIndex update(DevicePatientHealthIndex obj){
        return null;
        return obj;
    }
    /************************************i健康业务相关 end  ************************************************************/
    /*****************************************工具方法 start************************************************************/
    /**
     * 设备注册及绑定
     * 单条转换
     * @param res
     * @return
     */
    public String registedevice(JSONObject json){
        json.put("access_token",accessToken);
        json.put("data_source",dataSource);
        String url = baseUrl+"/dataInput/userBind";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("json",json.toString()));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return null;
    public DevicePatientHealthIndex transforOne(String res,Long id){
        if(StringUtils.isBlank(res)){
            return null;
        }
        JSONObject jsonObject = JSONObject.parseObject(res);
        if(jsonObject.getString("errorMsg")!=null){
            logger.error(jsonObject.getString("errorMsg"));
            return null;
        }
        JSONObject obj = jsonObject.getJSONArray("obj").getJSONObject(0);
        DevicePatientHealthIndex index = new DevicePatientHealthIndex();
        index.setId(id);
        index.setDeviceSn(obj.getString("sn"));
        index.setUser(obj.getString("usercode"));
        index.setIdcard(obj.getString("idcard"));
        index.setRecordDate(DateUtil.strToDate(obj.getString("measure_time")));
        index.setSortDate(index.getRecordDate());
        if(obj.getString("blood_sugar")==null){
            index.setType(1);
            index.setValue1(obj.getString("blood_sugar"));
            index.setValue2(obj.getString("blood_sugar_result"));
        }else if(obj.getString("systolic")==null){
            index.setType(2);
            index.setValue1(obj.getString("systolic"));
            index.setValue2(obj.getString("diastolic"));
            index.setValue3(obj.getString("pulse"));
        }else if(obj.getString("height")==null){
            index.setType(3);
            index.setValue1(obj.getString("height"));
            index.setValue2(obj.getString("weight"));
            index.setValue3(obj.getString("bmi"));
        }else if(obj.getString("waist")==null){
            index.setType(4);
            index.setValue1(obj.getString("waist"));
        }
        return index;
    }
    /**
     * 数据上传
     * @param json
     * 字符串分割
     * @param name
     * @param type 1品牌,2 型号
     * @param deviceType 1血糖,2 血压
     * @return
     */
    public String upload(JSONObject json){
        json.put("access_token",accessToken);
        json.put("data_source",dataSource);
        String url = baseUrl+"/dataInput/input";
        org.json.JSONObject params = new org.json.JSONObject();
        params.put("json_data",json.toString());
        String response = httpClientUtil.postBody(url, params);
        return response;
    private String transfor(String name,Integer type,Integer deviceType){
        String re = "";
        String[] brand = {"康为","爱奥乐","优瑞恩","三诺","云湃"};
        String[] model = {"A206G","G-777G","U80EH","亲智","RBP-980"};
        String model2 = "G-426-3";
        if(StringUtils.isBlank(name)){
            return re;
        }
        for(int i=0;i<brand.length;i++){
            String one = brand[i];
            if(name.contains(one)){
                re = type == 1? one:((i==0&&deviceType==1)?model2:model[i]);
            }
        }
        return re;
    }
    /**
     * 查询
     * @param json
     * 时间处理
     * @param time
     * @return
     */
    public String search(JSONObject json){
        json.put("access_token",accessToken);
        String url = baseUrl+"/upload";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("json",json.toString()));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return null;
    private String subStringTime(String time){
        return StringUtils.isBlank(time)? "":time.substring(0,19);
    }
    /*****************************************工具方法 end  ************************************************************/
}

+ 18 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/HttpClientUtil.java

@ -198,4 +198,22 @@ public class HttpClientUtil {
        restTemplate.put(url, formEntity, String.class);
    }
    /**
     * 发送post请求
     *
     * @param url     请求地址
     * @param params  请求参数
     * @return
     */
    public String iotPostBody(String url, String params) {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params, headers);
        String ret = restTemplate.postForObject(url, formEntity, String.class);
        return ret;
    }
}

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

@ -30,7 +30,7 @@ import java.util.*;
})
public class BaseController {
    private static Logger logger = LoggerFactory.getLogger(BaseController.class);
    private static Logger logger = LoggerFactory.getLogger("error_logger");
    @Autowired
    protected HttpServletRequest request;

+ 1 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -443,9 +443,7 @@ public class SignPatientLabelInfoController extends BaseController {
            if (StringUtils.isEmpty(health)) {
                return error(-1, "健康情况标签不能为空");
            }
            //xh1D201703150222
            int result = labelInfoService.setPatientLabels(patient, "", "", health, disease, custom, getUID(), getUID());
//            int result = labelInfoService.setPatientLabels(patient, "", "", health, disease, custom, "xh1D201703150222", "xh1D201703150222");
            if (result == 0) {
                return error(-1, "查不到患者信息");
@ -490,9 +488,7 @@ public class SignPatientLabelInfoController extends BaseController {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "患者不能为空");
            }
            //D2016008240002
            JSONArray labels = labelInfoService.getPatientLabelByLabelTypeAndTeamCode(patient, labelType, teamCode, getUID());
            //JSONArray labels = labelInfoService.getPatientLabelByLabelTypeAndTeamCode(patient, labelType, teamCode, "xh1D201703150222");
            return write(200, "查询成功", "data", labels);
        } catch (Exception e) {
            e.printStackTrace();
@ -884,7 +880,7 @@ public class SignPatientLabelInfoController extends BaseController {
            @ApiParam(name="startdate", value="体征数据开始时间yyyy-mm-dd hh:mm:ss") @RequestParam(value = "startdate",required = false,defaultValue = "2017-9-10 00:00:00")  String startdate,
            @ApiParam(name="enddate", value="体征数据结束时间yyyy-mm-dd hh:mm:ss") @RequestParam(value = "enddate",required = false,defaultValue = "2017-9-16 23:59:59")  String enddate){
        try {
            com.alibaba.fastjson.JSONObject result = doctorSchemeService.getSlowDiseaseTeaminfos(teamCode,getcolor,getstands,gethealthindex,startdate,enddate,"xh1D2017031503333");
            com.alibaba.fastjson.JSONObject result = doctorSchemeService.getSlowDiseaseTeaminfos(teamCode,getcolor,getstands,gethealthindex,startdate,enddate,getUID());
            return write(200, "查询成功", "data", result);
        }catch (Exception e){
            //日志文件中记录异常信息

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

@ -241,7 +241,7 @@ public class DoctroSchemeController extends BaseController {
                                            @ApiParam(name="startDate", value="开始时间") @RequestParam(value = "startDate",required = true)String startDate,
                                            @ApiParam(name="endDate", value="结束时间") @RequestParam(value = "endDate",required = true)String endDate){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getTrackPatientCountTitle(teamCode,"xh1D2017031503333",startDate,endDate));
            return write(200, "查询成功", "data",doctorSchemeService.getTrackPatientCountTitle(teamCode,getUID(),startDate,endDate));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果

+ 6 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -1229,11 +1229,13 @@ public class ConsultController extends WeixinBaseController {
    public String countRemainConsult(){
        try {
            String patient = getRepUID();
            int count = consultTeamService.countRemainConsult(patient);
            if (count>=0){
                return write(200, "查询成功!", "data", count);
            JSONObject result = consultTeamService.countRemainConsult(patient);
            if (result.has("count") && result.has("amount")){
                return write(200, "查询成功!", "data", result);
            }else if (result.has("count") && !result.has("amount")){
                return error(-1, "查询已签约记录失败!");
            }else {
                return error(-1, "已缴费用户无家庭咨询次数限制!");
                return error(-1, "查询失败!");
            }
        }catch (Exception e){
            error(e);

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

@ -289,96 +289,6 @@ public class PatientHealthController extends BaseController {
    }
    /*@RequestMapping(value = "add")
    @ResponseBody
    @ApiOperation("保存患者健康指标(旧)")
    public String add(@RequestParam(required = false) String intervene, String time, String value1, String value2, String value3, String value4, String value5, String value6, String value7, int type) {
        try {
            DevicePatientHealthIndex healthIndex = null;
            if (type == 1) {
                // 血糖等一天只能存在一条数据
                Iterable<DevicePatientHealthIndex> list = healthIndexService.findByPatienDate(getUID(), type, DateUtil.strToDate(time, DateUtil.YYYY_MM_DD));
                if (list != null) {
                    for (DevicePatientHealthIndex model : list) {
                        healthIndex = model;
                    }
                }
            }
            if (healthIndex == null) {
                healthIndex = new DevicePatientHealthIndex();
            }
            // 设置患者标识
            healthIndex.setUser(getUID());
            // 设置干预标识,默认为NULL
            healthIndex.setIntervene(intervene);
            int index = 0;
            double value = 0;
            // 设置血糖/收缩压/体重/腰围/早餐前空腹
            if (NumberUtils.toDouble(value1, 0) > 0) {
                healthIndex.setValue1(value1);
                index = 1;
                value = NumberUtils.toDouble(value1, 0);
            }
            // 设置 舒张压/早餐后血糖
            if (NumberUtils.toDouble(value2, 0) > 0) {
                healthIndex.setValue2(value2);
                index = 2;
                value = NumberUtils.toDouble(value2, 0);
            }
            // 设置午餐前血糖
            if (NumberUtils.toDouble(value3, 0) > 0) {
                healthIndex.setValue3(value3);
                index = 3;
                value = NumberUtils.toDouble(value3, 0);
            }
            // 设置午餐后血糖
            if (NumberUtils.toDouble(value4, 0) > 0) {
                healthIndex.setValue4(value4);
                index = 4;
                value = NumberUtils.toDouble(value4, 0);
            }
            // 设置晚餐前血糖
            if (NumberUtils.toDouble(value5, 0) > 0) {
                healthIndex.setValue5(value5);
                index = 5;
                value = NumberUtils.toDouble(value5, 0);
            }
            // 设置晚餐后血糖
            if (NumberUtils.toDouble(value6, 0) > 0) {
                healthIndex.setValue6(value6);
                index = 6;
                value = NumberUtils.toDouble(value6, 0);
            }
            // 设置睡前血糖
            if (NumberUtils.toDouble(value7, 0) > 0) {
                healthIndex.setValue7(value7);
                index = 7;
                value = NumberUtils.toDouble(value7, 0);
            }
            // 设置健康指标类型(1血糖,2血压,3体重,4腰围)
            healthIndex.setType(type);
            // 设置记录时间
            if (type == 2) {
                healthIndex.setRecordDate(DateUtil.strToDate(time, DateUtil.YYYY_MM_DD_HH_MM_SS));
            } else {
                healthIndex.setRecordDate(DateUtil.strToDate(time, DateUtil.YYYY_MM_DD));
            }
            healthIndex.setSortDate(DateUtil.strToDateAppendNowTime(time, DateUtil.YYYY_MM_DD_HH_MM_SS));
            // 保存到数据库
            healthIndex = healthIndexService.save(healthIndex, index, value, getUID());
            if (healthIndex == null) {
                return error(-1, "保存失败!");
            }
            return success("保存成功!");
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "保存失败!");
        }
    }
*/
    @RequestMapping(value = "addPatientHealthIndex", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("新增患者指标")
@ -389,7 +299,6 @@ public class PatientHealthController extends BaseController {
                                        @ApiParam(name = "patient", value = "patient", defaultValue = "1")
                                        @RequestParam(value = "patient", required = false) String patient) {
        try {
//            DevicePatientHealthIndex obj = healthIndexService.addPatientHealthIndex(data, type, getUID(), null);
            if(StringUtils.isBlank(patient)){
                patient = getRepUID();
//                patient = getUID();

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

@ -105,4 +105,28 @@ public class PatientSchemeController extends BaseController {
        }
    }
    @RequestMapping(value="getDefaultScheme",method = RequestMethod.GET)
    @ApiOperation("获取默认监测列表")
    public String getDefaultScheme(@ApiParam(name="type", value="1.糖尿病,2.高血压") @RequestParam(value = "type",required = true)String type){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getDefaultScheme(type));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value="setPatientDefaultScheme",method = RequestMethod.POST)
    @ApiOperation("设置居民监测列表")
    public String setPatientDefaultScheme(@ApiParam(name="type", value="1.糖尿病,2.高血压") @RequestParam(value = "type",required = true)String type){
        try {
            return write(200, "设置成功", "data",doctorSchemeService.setPatientDefaultScheme(getUID(),type));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "设置失败");
        }
    }
}

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

@ -2,6 +2,8 @@ package com.yihu.wlyy.web.third.iot;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.service.third.iot.IotDeviceService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
@ -24,6 +26,7 @@ public class IotDeviceController extends BaseController{
    @Autowired
    private IotDeviceService iotDeviceService;
    private ObjectMapper objectMapper = new ObjectMapper();
    @RequestMapping(value = "/registedevice",method = RequestMethod.POST)
    @ApiOperation("注册设备")
@ -62,74 +65,81 @@ public class IotDeviceController extends BaseController{
    public String upload(@ApiParam(name = "jsonStr",value = "jsonStr",defaultValue = "")
                         @RequestParam(value = "jsonStr",required = true) String jsonStr){
        try {
            JSONObject json = JSONObject.parseObject(jsonStr);
            String re = iotDeviceService.upload(json);
            return write(200, "体征数据上传成功!", "data", re);
            DevicePatientHealthIndex index = objectMapper.readValue(jsonStr, DevicePatientHealthIndex.class);
            return write(200, "体征数据上传成功!", "data", iotDeviceService.save(index));
        }catch (Exception e){
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/upload1",method = RequestMethod.POST)
    @ApiOperation("不含居民身份的数据上传协议")
    public String upload1(){
    @RequestMapping(value = "/test",method = RequestMethod.GET)
    @ApiOperation("test")
    public String upload(){
        try {
            JSONObject json = new JSONObject();
            JSONObject js = new JSONObject();
            js.put("measure_time","2018-01-01 01:01:01");
            js.put("systolic","111");
            js.put("systolic_unit","mmHg");
            js.put("diastolic","60");
            js.put("diastolic_unit","mmHg");
            js.put("pulse","66");
            js.put("pulse_unit","bpm");
            js.put("del","1");
            js.put("status","0");
            return write(200, "test成功!", "data", iotDeviceService.test());
        }catch (Exception e){
            error(e);
            return error(-1, e.getMessage());
        }
    }
            JSONArray jsonArray = new JSONArray();
            jsonArray.add(js);
            json.put("data",jsonArray);
            json.put("sn","2638234828");
            json.put("ext_code","1");
            json.put("device_name","血压计-康为A206G");
            json.put("device_model","血压计-康为A206G");
    @RequestMapping(value = "/init",method = RequestMethod.POST)
    @ApiOperation("初始化迁移数据")
    public String init(){
        try {
            iotDeviceService.initData();
            return success("初始化成功");
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    @RequestMapping(value = "/findById",method = RequestMethod.GET)
    @ApiOperation("按id查询")
    public String findById(@ApiParam(name = "id",value = "id",defaultValue = "LggM5iaSi6u18TUmeDoaeSnyFxntPMA2NPGXBRyPTwFsg+oRn3bHgg==")
                           @RequestParam(name="id",required = true) String id){
        try {
            return write(200,"查询成功","data",iotDeviceService.getById(id));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
            String re = iotDeviceService.upload(json);
            return write(200, "上传成功!", "data", re);
        } catch (Exception e) {
    @RequestMapping(value = "/getById",method = RequestMethod.GET)
    @ApiOperation("按id查询")
    public String getById(@ApiParam(name = "id",value = "id",defaultValue = "123")
                           @RequestParam(name="id",required = true) Long id){
        try {
            return write(200,"查询成功","data",iotDeviceService.getById(id));
        }catch (Exception e){
            error(e);
            return error(-1, e.getMessage());
            return error(-1,e.getMessage());
        }
    }
    @RequestMapping(value = "/upload2",method = RequestMethod.POST)
    @ApiOperation("含居民身份的数据上传协议")
    public String upload2(){
    @RequestMapping(value = "/findRepeat",method = RequestMethod.GET)
    @ApiOperation("查找重复数据")
    public String findRepeat(@ApiParam(name = "user",value = "user",defaultValue = "aduiojdajkdlsd")
                             @RequestParam(name="user",required = true) String user,
                             @ApiParam(name = "deviceSn",value = "deviceSn",defaultValue = "84645414")
                             @RequestParam(name="deviceSn",required = true) String deviceSn,
                             @ApiParam(name = "value1",value = "value1",defaultValue = "7.5")
                             @RequestParam(name="value1",required = true) String value1,
                             @ApiParam(name = "value2",value = "value2",defaultValue = "")
                             @RequestParam(name="value2",required = false) String value2,
                             @ApiParam(name = "type",value = "type",defaultValue = "1")
                             @RequestParam(name="type",required = true) String type,
                             @ApiParam(name = "time",value = "time",defaultValue = "2017-07-02 12:21:44")
                             @RequestParam(name="time",required = true) String time){
        try {
            JSONObject json = new JSONObject();
            JSONObject js = new JSONObject();
            js.put("measure_time","2018-01-01 11:01:01");
            js.put("blood_sugar","6.7");
            js.put("blood_sugar_unit","mmol/L");
            js.put("del","1");
            js.put("status","0");
            JSONArray jsonArray = new JSONArray();
            jsonArray.add(js);
            json.put("data",jsonArray);
            json.put("sn","2638234828");
            json.put("ext_code","1");
            json.put("device_name","血压计-康为A206G");
            json.put("device_model","血压计-康为A206G");
            json.put("idcard","350429198905194016");
            json.put("username","小李");
            String re = iotDeviceService.upload(json);
            return write(200, "上传成功!", "data", re);
        } catch (Exception e) {
            return write(200,"查询成功","data",iotDeviceService.findRepeat(user,deviceSn,value1,value2,type,time));
        }catch (Exception e){
            error(e);
            return error(-1, e.getMessage());
            return error(-1,e.getMessage());
        }
    }
}

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

@ -757,7 +757,7 @@ public class EduArticleService {
            int i = 0;
            jestClient = elasticFactory.getJestClient();
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            String sql = "select id from " + esIndex + " where batchNo='" + batchNo + "'";
            String sql = "select id from " + esIndex + " where batchNo='" + batchNo + "' limit 0,50000";
            List<Map<String, Object>> returnList = elasticsearchUtil.excuteDataModel(sql);
            //根据id批量删除
            for (Map<String, Object> obj : returnList) {
@ -810,8 +810,8 @@ public class EduArticleService {
        final String firstId = firstIdStr;
        //4.获取同一个批次号的推送记录,基本同一个批次号是同一个医生发送的,也是同一篇文章
        String sql = "select * from wlyy_health_edu_article_patient_copy where admin_team_code IS NOT NULL AND batch_no IS NOT NULL AND batch_no='" + batchNo + "'";
        List<HealthEduArticlePatient> healthEduArticlePatients = jdbcTemplate.query(sql, new BeanPropertyRowMapper(HealthEduArticlePatient.class));
        String sql = "select ap.*,p.name AS patientName from wlyy_health_edu_article_patient_copy ap LEFT JOIN wlyy_patient p ON ap.patient = p.code where ap.admin_team_code IS NOT NULL AND ap.batch_no IS NOT NULL AND ap.batch_no='" + batchNo + "'";
        List<HealthEduArticlePatientDTO> healthEduArticlePatients = jdbcTemplate.query(sql, new BeanPropertyRowMapper(HealthEduArticlePatientDTO.class));
        //5.转换成新的健康教育需要的数据
        List<HealthEduArticleES> healthEduArticleESSaveList = new ArrayList<>();
@ -820,12 +820,12 @@ public class EduArticleService {
            Doctor doctor = doctorDao.findByCode(doctorCode);
            AdminTeam adminTeam = doctorAdminTeamDao.findOne(healthEduArticlePatients.get(0).getAdminTeamCode());
            HealthEduArticle healthEduArticle = healthEduArticleDao.findByCode(healthEduArticlePatients.get(0).getArticle());
            for (HealthEduArticlePatient healthEduArticlePatient : healthEduArticlePatients) {
            for (HealthEduArticlePatientDTO healthEduArticlePatient : healthEduArticlePatients) {
                HealthEduArticleES healthEduArticleES = new HealthEduArticleES();
                healthEduArticleES.setBatchNo(batchNo);
                healthEduArticleES.setPatientCode(healthEduArticlePatient.getPatient());
                healthEduArticleES.setPatientName(patientDao.findByCode(healthEduArticlePatient.getPatient()).getName());
                healthEduArticleES.setPatientName(healthEduArticlePatient.getPatientName());
                //医生
                healthEduArticleES.setDoctorCode(doctor.getCode());
@ -988,7 +988,7 @@ public class EduArticleService {
        //4.获取医生的推送记录
        //String sql = "select * from wlyy_health_edu_article_patient_copy where admin_team_code IS NOT NULL AND batch_no IS NOT NULL AND doctor='" + doctorCode + "'";
        String sql = "select ap.*,p.name AS patienName from wlyy_health_edu_article_patient_copy ap LEFT JOIN wlyy_patient p ON ap.patient = p.code where ap.admin_team_code IS NOT NULL AND ap.batch_no IS NOT NULL AND ap.doctor='"+doctorCode+"'";
        String sql = "select ap.*,p.name AS patientName from wlyy_health_edu_article_patient_copy ap LEFT JOIN wlyy_patient p ON ap.patient = p.code where ap.admin_team_code IS NOT NULL AND ap.batch_no IS NOT NULL AND ap.doctor='"+doctorCode+"'";
        List<HealthEduArticlePatientDTO> healthEduArticlePatients = jdbcTemplate.query(sql, new BeanPropertyRowMapper(HealthEduArticlePatientDTO.class));
        //推送记录按照批次号分组
        Map<String, List<HealthEduArticlePatientDTO>> healthEduArticlePatientMap = new HashMap<>();

+ 20 - 0
patient-co/patient-co-wlyy/src/main/resources/logback.xml

@ -106,8 +106,28 @@
    </logger>
    <!--处方支付日志 end-->
    <appender name="error_rollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>/datadisk/wlyy_logs/error/error.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>/datadisk/wlyy_logs/error/error.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>30</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%d %level %C.%M %m%n</pattern> <!-- %C.%M 可能会影响效率-->
            <charset class="java.nio.charset.Charset">UTF-8</charset>
        </encoder>
    </appender>
    <logger name="error_logger" level="ERROR" additivity="false">
        <appender-ref ref="error_rollingFile" />
    </logger>
    <root level="INFO">
        <!--<appender-ref ref="console" />-->
        <appender-ref ref="rollingFile" />
    </root>
</configuration>