Browse Source

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

liuwenbin 7 years ago
parent
commit
fea0c0e22d
24 changed files with 1302 additions and 315 deletions
  1. 395 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/vo/PatientVO.java
  2. 0 23
      patient-co/patient-co-statistics-es/doc/sql/system_dict.sql
  3. 0 25
      patient-co/patient-co-statistics-es/doc/sql/wlyy_dimension.sql
  4. 0 21
      patient-co/patient-co-statistics-es/doc/sql/wlyy_dimension_quota.sql
  5. 0 56
      patient-co/patient-co-statistics-es/doc/sql/wlyy_job_config.sql
  6. 192 0
      patient-co/patient-co-statistics-es/doc/sql/统计相关表数据备份20171121.txt
  7. 44 2
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/controller/JobController.java
  8. 94 2
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/service/JobService.java
  9. 5 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorWorkWeekDao.java
  10. 2 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  11. 161 65
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  12. 4 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionFollowupContentService.java
  13. 52 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  14. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsAllService.java
  15. 113 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java
  16. 183 85
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  17. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  18. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  19. 5 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java
  20. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/HealthEduArticleController.java
  21. 19 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java
  22. 24 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java
  23. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java
  24. 2 2
      patient-co/patient-co-wlyy/src/main/resources/application-prod.yml

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

@ -0,0 +1,395 @@
package com.yihu.wlyy.entity.patient.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
 * 居民VO类
 * @author huangwenjie
 * @date 2017/11/21 08:57
 */
public class PatientVO {
	
	// 业务主键
	private String code;
	// 身份证号
	private String idcard;
	// 登录密码
	private String password;
	private String salt;
	// 姓名
	private String name;
	// 生日
	private Date birthday;
	// 性別,1男,2女
	private Integer sex;
	// 手機號
	private String mobile;
	// (基卫)手機號
	private String mobileRemarks;
	// 聯繫電話
	private String phone;
	// 社保卡號
	private String ssc;
	// 頭像HTTP地址
	private String photo;
	// 省代碼
	private String province;
	// 城市代碼
	private String city;
	// 區縣代碼
	private String town;
	// 街道代码
	private String street;
	// 省名
	private String provinceName;
	// 市名
	private String cityName;
	// 區縣名
	private String townName;
	// 街道名称
	private String streetName;
	// 地址
	private String address;
	// 疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病
	private Integer disease;
	// 病情:0绿标,1黄标,2红标
	private Integer diseaseCondition;
	// 病历记录总数
	private Integer recordAmount;
	// 總積分
	private Integer points;
	// 更新時間
	private Date czrq;
	// 微信编号
	private String openid;
	//微信时间
	private Date openidTime;
	// 用户状态:1正常,0禁用,-1恶意注册,2审核中
	private Integer status;
	// 居委会字段id
	private String sickVillage;
	// 居委会字段名称
	private String sickVillageName;
	//	绑定电子社保卡主体(本人为本人code,共济为操作人code)
	private String principalCode;
	//	是否绑定电子社保卡
	private Integer sicardStatus;
	//	绑定电子社保卡时间
	private Date sicardTime;
	//是否分配过微信标签  1分配过 0或者空没有
	private Integer isWxtag;
	//微信iagId
	private Integer wxtagid;
	//居民预警状态:0为标准,1为预警状态
	private Integer standardStatus;
	
	//设备类型(1血糖,2血压,3血糖+血压)
	private Integer deviceType;
	
	public String getCode() {
		return code;
	}
	
	public void setCode(String code) {
		this.code = code;
	}
	
	public String getIdcard() {
		return idcard;
	}
	
	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}
	
	public String getPassword() {
		return password;
	}
	
	public void setPassword(String password) {
		this.password = password;
	}
	
	public String getSalt() {
		return salt;
	}
	
	public void setSalt(String salt) {
		this.salt = salt;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	public Date getBirthday() {
		return birthday;
	}
	
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}
	
	public Integer getSex() {
		return sex;
	}
	
	public void setSex(Integer sex) {
		this.sex = sex;
	}
	
	public String getMobile() {
		return mobile;
	}
	
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	
	public String getMobileRemarks() {
		return mobileRemarks;
	}
	
	public void setMobileRemarks(String mobileRemarks) {
		this.mobileRemarks = mobileRemarks;
	}
	
	public String getPhone() {
		return phone;
	}
	
	public void setPhone(String phone) {
		this.phone = phone;
	}
	
	public String getSsc() {
		return ssc;
	}
	
	public void setSsc(String ssc) {
		this.ssc = ssc;
	}
	
	public String getPhoto() {
		return photo;
	}
	
	public void setPhoto(String photo) {
		this.photo = photo;
	}
	
	public String getProvince() {
		return province;
	}
	
	public void setProvince(String province) {
		this.province = province;
	}
	
	public String getCity() {
		return city;
	}
	
	public void setCity(String city) {
		this.city = city;
	}
	
	public String getTown() {
		return town;
	}
	
	public void setTown(String town) {
		this.town = town;
	}
	
	public String getStreet() {
		return street;
	}
	
	public void setStreet(String street) {
		this.street = street;
	}
	
	public String getProvinceName() {
		return provinceName;
	}
	
	public void setProvinceName(String provinceName) {
		this.provinceName = provinceName;
	}
	
	public String getCityName() {
		return cityName;
	}
	
	public void setCityName(String cityName) {
		this.cityName = cityName;
	}
	
	public String getTownName() {
		return townName;
	}
	
	public void setTownName(String townName) {
		this.townName = townName;
	}
	
	public String getStreetName() {
		return streetName;
	}
	
	public void setStreetName(String streetName) {
		this.streetName = streetName;
	}
	
	public String getAddress() {
		return address;
	}
	
	public void setAddress(String address) {
		this.address = address;
	}
	
	public Integer getDisease() {
		return disease;
	}
	
	public void setDisease(Integer disease) {
		this.disease = disease;
	}
	
	public Integer getDiseaseCondition() {
		return diseaseCondition;
	}
	
	public void setDiseaseCondition(Integer diseaseCondition) {
		this.diseaseCondition = diseaseCondition;
	}
	
	public Integer getRecordAmount() {
		return recordAmount;
	}
	
	public void setRecordAmount(Integer recordAmount) {
		this.recordAmount = recordAmount;
	}
	
	public Integer getPoints() {
		return points;
	}
	
	public void setPoints(Integer points) {
		this.points = points;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	
	public String getOpenid() {
		return openid;
	}
	
	public void setOpenid(String openid) {
		this.openid = openid;
	}
	
	public Date getOpenidTime() {
		return openidTime;
	}
	
	public void setOpenidTime(Date openidTime) {
		this.openidTime = openidTime;
	}
	
	public Integer getStatus() {
		return status;
	}
	
	public void setStatus(Integer status) {
		this.status = status;
	}
	
	public String getSickVillage() {
		return sickVillage;
	}
	
	public void setSickVillage(String sickVillage) {
		this.sickVillage = sickVillage;
	}
	
	public String getSickVillageName() {
		return sickVillageName;
	}
	
	public void setSickVillageName(String sickVillageName) {
		this.sickVillageName = sickVillageName;
	}
	
	public String getPrincipalCode() {
		return principalCode;
	}
	
	public void setPrincipalCode(String principalCode) {
		this.principalCode = principalCode;
	}
	
	public Integer getSicardStatus() {
		return sicardStatus;
	}
	
	public void setSicardStatus(Integer sicardStatus) {
		this.sicardStatus = sicardStatus;
	}
	
	public Date getSicardTime() {
		return sicardTime;
	}
	
	public void setSicardTime(Date sicardTime) {
		this.sicardTime = sicardTime;
	}
	
	public Integer getIsWxtag() {
		return isWxtag;
	}
	
	public void setIsWxtag(Integer isWxtag) {
		this.isWxtag = isWxtag;
	}
	
	public Integer getWxtagid() {
		return wxtagid;
	}
	
	public void setWxtagid(Integer wxtagid) {
		this.wxtagid = wxtagid;
	}
	
	public Integer getStandardStatus() {
		return standardStatus;
	}
	
	public void setStandardStatus(Integer standardStatus) {
		this.standardStatus = standardStatus;
	}
	
	public Integer getDeviceType() {
		return deviceType;
	}
	
	public void setDeviceType(Integer deviceType) {
		this.deviceType = deviceType;
	}
}

+ 0 - 23
patient-co/patient-co-statistics-es/doc/sql/system_dict.sql

@ -1,23 +0,0 @@
INSERT INTO `data_for_stats`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES (''462'', ''RENEW_CHANGE_REASON'', ''1'', ''常住地变更'', NULL, ''1'');
INSERT INTO `data_for_stats`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES (''463'', ''RENEW_CHANGE_REASON'', ''2'', ''医生专业度不够'', NULL, ''2'');
INSERT INTO `data_for_stats`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES (''464'', ''RENEW_CHANGE_REASON'', ''3'', ''咨询回复慢'', NULL, ''3'');
INSERT INTO `data_for_stats`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES (''465'', ''RENEW_CHANGE_REASON'', ''4'', ''无获得感'', NULL, ''4'');
INSERT INTO `data_for_stats`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES (''466'', ''RENEW_CHANGE_REASON'', ''5'', ''医生服务态度差'', NULL, ''5'');
INSERT INTO `data_for_stats`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES (''467'', ''RENEW_CHANGE_REASON'', ''6'', ''其它'', NULL, ''6'');
INSERT INTO `wlyy_quota`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES ('1000', 'QUOTA_SEX_DICT', '1', '男', '', '1');
INSERT INTO `wlyy_quota`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES ('1001', 'QUOTA_SEX_DICT', '2', '女', '', '2');
INSERT INTO `wlyy_quota`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES ('1003', 'QUOTA_SEX_DICT', '3', '未知', '', '3');
INSERT INTO `wlyy_quota`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES ('1004', 'QUOTA_AGE_DICT', '1', '0~6', '', '1');
INSERT INTO `wlyy_quota`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES ('1006', 'QUOTA_AGE_DICT', '2', '7~18', '', '2');
INSERT INTO `wlyy_quota`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES ('1007', 'QUOTA_AGE_DICT', '3', '19~30', '', '3');
INSERT INTO `wlyy_quota`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES ('1008', 'QUOTA_AGE_DICT', '4', '31~50', '', '4');
INSERT INTO `wlyy_quota`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES ('1009', 'QUOTA_AGE_DICT', '5', '51~65', '', '5');
INSERT INTO `wlyy_quota`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES ('1010', 'QUOTA_AGE_DICT', '6', '>65', '', '6');
INSERT INTO `wlyy_quota`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES ('1011', 'QUOTA_SIGN_EXPESEX', '0', '已扣费', '', '1');
INSERT INTO `wlyy_quota`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES ('1012', 'QUOTA_SIGN_EXPESEX', '1', '已缴费', '', '2');
INSERT INTO `wlyy_quota`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES ('1013', 'QUOTA_SIGN_EXPESEX', '2', '已退费', '', '3');
INSERT INTO `wlyy_quota`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES ('1014', 'QUOTA_CONSULT_TIME', '1', '0~8', '', NULL);
INSERT INTO `wlyy_quota`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES ('1015', 'QUOTA_CONSULT_TIME', '2', '8~12', '', NULL);
INSERT INTO `wlyy_quota`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES ('1016', 'QUOTA_CONSULT_TIME', '3', '12~13', '', NULL);
INSERT INTO `wlyy_quota`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES ('1017', 'QUOTA_CONSULT_TIME', '4', '13~18', '', NULL);
INSERT INTO `wlyy_quota`.`system_dict` (`id`, `dict_name`, `code`, `value`, `py_code`, `sort`) VALUES ('1018', 'QUOTA_CONSULT_TIME', '5', '18~24', '', NULL);

+ 0 - 25
patient-co/patient-co-statistics-es/doc/sql/wlyy_dimension.sql

@ -1,25 +0,0 @@
CREATE TABLE `wlyy_dimension` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键(uuid)',
  `code` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '业务代码',
  `type` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '类型:1 性别 2 年龄 ',
  `name` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '指标名称',
  `status` int(2) DEFAULT NULL COMMENT '1: 正常 0:不可以用 -1 已删除',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_user` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_user_name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人名',
  `update_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '修改时间',
  `update_user` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人',
  `update_user_name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人名',
  `remark` varchar(1500) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `wlyy_quota`.`wlyy_dimension` (`id`, `code`, `type`, `name`, `status`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `remark`) VALUES ('1', '1', '1', '患者性别维度', '1', '2017-07-11 09:42:33', NULL, NULL, '2017-06-02 14:19:25', NULL, NULL, NULL);
INSERT INTO `wlyy_quota`.`wlyy_dimension` (`id`, `code`, `type`, `name`, `status`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `remark`) VALUES ('2', '2', '2', '患者年龄维度', '1', '2017-07-11 09:42:34', NULL, NULL, '2017-06-02 14:19:27', NULL, NULL, NULL);
INSERT INTO `wlyy_quota`.`wlyy_dimension` (`id`, `code`, `type`, `name`, `status`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `remark`) VALUES ('3', '3', '3', '患者健康分布标签', '1', '2017-07-12 14:07:59', NULL, NULL, '2017-06-02 15:01:56', NULL, NULL, NULL);
INSERT INTO `wlyy_quota`.`wlyy_dimension` (`id`, `code`, `type`, `name`, `status`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `remark`) VALUES ('4', '4', '4', '签约扣费状态', '1', '2017-07-11 09:42:18', NULL, NULL, '2017-07-11 09:41:14', NULL, NULL, NULL);
INSERT INTO `wlyy_quota`.`wlyy_dimension` (`id`, `code`, `type`, `name`, `status`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `remark`) VALUES ('5', '5', '5', '签约服务类别', '1', '2017-07-12 12:05:40', NULL, NULL, '2017-07-11 09:41:44', NULL, NULL, NULL);
INSERT INTO `wlyy_quota`.`wlyy_dimension` (`id`, `code`, `type`, `name`, `status`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `remark`) VALUES ('6', '6', '6', '续签转签原因', '1', '2017-07-12 17:29:43', NULL, NULL, '2017-07-12 17:28:37', NULL, NULL, NULL);
INSERT INTO `wlyy_quota`.`wlyy_dimension` (`id`, `code`, `type`, `name`, `status`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `remark`) VALUES ('7', '7', '7', '咨询回复时间分布', '1', '2017-07-12 17:29:45', NULL, NULL, '2017-07-12 17:28:39', NULL, NULL, NULL);
INSERT INTO `wlyy_quota`.`wlyy_dimension` (`id`, `code`, `type`, `name`, `status`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `remark`) VALUES ('8', '8', '8', '患者疾病标签', '1', '2017-07-19 16:53:44', NULL, NULL, '2017-07-19 16:53:46', NULL, NULL, NULL);

+ 0 - 21
patient-co/patient-co-statistics-es/doc/sql/wlyy_dimension_quota.sql

@ -1,21 +0,0 @@
CREATE TABLE `wlyy_dimension_quota` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `quota_code` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '关联 wlyy_quota code',
  `dimension_code` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '关联 wlyy_dimension',
  `dict_sql` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL,
  `convert_clazz` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '数据转换的类',
  `sort` int(2) DEFAULT NULL COMMENT '维度顺序',
  `key` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '查询出来的key',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `wlyy_quota`.`wlyy_dimension_quota` (`id`, `quota_code`, `dimension_code`, `dict_sql`, `convert_clazz`, `sort`, `key`) VALUES ('1', '6', '1', 'select s.code code,s.value name from system_dict s where  s.dict_name=\'QUOTA_SEX_DICT\'', 'com.yihu.wlyy.statistics.etl.convert.wlyy.SexConvert', '1', 'Idcard');
INSERT INTO `wlyy_quota`.`wlyy_dimension_quota` (`id`, `quota_code`, `dimension_code`, `dict_sql`, `convert_clazz`, `sort`, `key`) VALUES ('2', '7', '3', NULL, NULL, NULL, NULL);
INSERT INTO `wlyy_quota`.`wlyy_dimension_quota` (`id`, `quota_code`, `dimension_code`, `dict_sql`, `convert_clazz`, `sort`, `key`) VALUES ('3', '8', '2', 'select s.code code,s.value name from system_dict s where  s.dict_name=\'QUOTA_AGE_DICT\'', 'com.yihu.wlyy.statistics.etl.convert.wlyy.AgeConvert', '1', 'Idcard');
INSERT INTO `wlyy_quota`.`wlyy_dimension_quota` (`id`, `quota_code`, `dimension_code`, `dict_sql`, `convert_clazz`, `sort`, `key`) VALUES ('4', '30', '6', 'select s.code code,s.value name from system_dict s where  s.dict_name=\'RENEW_CHANGE_REASON\'', 'com.yihu.wlyy.statistics.etl.convert.wlyy.SimpleConvert', '1', 'SlaveKey1');
INSERT INTO `wlyy_quota`.`wlyy_dimension_quota` (`id`, `quota_code`, `dimension_code`, `dict_sql`, `convert_clazz`, `sort`, `key`) VALUES ('6', '36', '5', 'select DISTINCT code,name from wlyy_sign_dict where type=1', 'com.yihu.wlyy.statistics.etl.convert.wlyy.SimpleConvert', '1', 'ServerType');
INSERT INTO `wlyy_quota`.`wlyy_dimension_quota` (`id`, `quota_code`, `dimension_code`, `dict_sql`, `convert_clazz`, `sort`, `key`) VALUES ('7', '15', '3', 'select label_code code,label_name name from wlyy_sign_patient_label where label_type=\'2\' and status=1', 'com.yihu.wlyy.statistics.etl.convert.wlyy.HealthLableConvert', '1', '');
INSERT INTO `wlyy_quota`.`wlyy_dimension_quota` (`id`, `quota_code`, `dimension_code`, `dict_sql`, `convert_clazz`, `sort`, `key`) VALUES ('8', '24', '7', 'select s.code code,s.value name from system_dict s where  s.dict_name=\'QUOTA_CONSULT_TIME\'', 'com.yihu.wlyy.statistics.etl.convert.wlyy.ConsultTimeConvert', '1', 'SlaveKey1');
INSERT INTO `wlyy_quota`.`wlyy_dimension_quota` (`id`, `quota_code`, `dimension_code`, `dict_sql`, `convert_clazz`, `sort`, `key`) VALUES ('9', '12', '2', 'select s.code code,s.value name from system_dict s where  s.dict_name=\'QUOTA_AGE_DICT\'', 'com.yihu.wlyy.statistics.etl.convert.wlyy.AgeConvert', '1', 'Idcard');
INSERT INTO `wlyy_quota`.`wlyy_dimension_quota` (`id`, `quota_code`, `dimension_code`, `dict_sql`, `convert_clazz`, `sort`, `key`) VALUES ('10', '12', '8', 'select label_code code,label_name name from wlyy_sign_patient_label where label_type=\'3\' and status=1', 'com.yihu.wlyy.statistics.etl.convert.wlyy.DiseaseLableConvert', '2', NULL);

File diff suppressed because it is too large
+ 0 - 56
patient-co/patient-co-statistics-es/doc/sql/wlyy_job_config.sql


File diff suppressed because it is too large
+ 192 - 0
patient-co/patient-co-statistics-es/doc/sql/统计相关表数据备份20171121.txt


+ 44 - 2
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/controller/JobController.java

@ -110,10 +110,10 @@ public class JobController extends BaseController {
    @RequestMapping(value = "productDataByDayToDayAndId", method = RequestMethod.GET)
    public String productDataByDayToDayAndId( @ApiParam(name = "start", value = "yyyy-MM-dd")@RequestParam(value = "start", required = true)String start,
                                         @ApiParam(name = "end", value = "yyyy-MM-dd")@RequestParam(value = "end", required = true)String end,
                                              @ApiParam(name = "id", value = "任务id")@RequestParam(value = "id", required = true)String id) {
                                         @ApiParam(name = "ids", value = "任务ids多个逗号分割")@RequestParam(value = "ids", required = true)String ids) {
        try {
            
            jobService.productDataByDayToDayAndId(start,end,id);
            jobService.productDataByDayToDayAndId(start,end,ids);
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
@ -240,4 +240,46 @@ public class JobController extends BaseController {
        }
    }
    //================================================没有休眠时间=============================================================
    /**
     * 生成过去某一天到某一天的某个指标的数据
     *
     * @param start
     * @param end
     * @return
     */
    @ApiOperation(value = "生成过去某一天到某一天的某个指标的数据(包含头尾)没有休眠时间")
    @RequestMapping(value = "productDataByDayToDayAndIdNoSleep", method = RequestMethod.GET)
    public String productDataByDayToDayAndIdNoSleep( @ApiParam(name = "start", value = "yyyy-MM-dd")@RequestParam(value = "start", required = true)String start,
                                                     @ApiParam(name = "end", value = "yyyy-MM-dd")@RequestParam(value = "end", required = true)String end,
                                                     @ApiParam(name = "id", value = "任务id")@RequestParam(value = "id", required = true)String id,
                                                     @ApiParam(name = "sleepTime", value = "任务间隔时间(秒)")@RequestParam(value = "sleepTime", required = true)Long sleepTime) {
        try {
            jobService.productDataByDayToDayAndIdNoSleep(start,end,id,sleepTime);
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    /**
     * 生成过去某一天的全部的数据
     *
     * @param day
     * @return
     */
    @ApiOperation(value = "生成过去某一天的全部的数据")
    @RequestMapping(value = "productDataByOneDayNoSleep", method = RequestMethod.GET)
    public String productDataByOneDayNoSleep( @ApiParam(name = "day", value = "yyyy-MM-dd")@RequestParam(value = "day", required = true)String day,
                                              @ApiParam(name = "sleepTime", value = "任务间隔时间(秒)")@RequestParam(value = "sleepTime", required = true)Long sleepTime) {
        try {
            jobService.productDataByOneDayNoSleep(day,sleepTime);
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
}

+ 94 - 2
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/service/JobService.java

@ -245,6 +245,7 @@ public class JobService {
        }
    }
    public void productDataByDayAndId(Integer day, String id) throws Exception {
        QuartzJobConfig quartzJobConfig = wlyyJobConfigDao.findById(id);
        if (quartzJobConfig == null) {
@ -306,7 +307,7 @@ public class JobService {
    }
    public void productDataByDayToDayAndId(String start, String end, String id) throws Exception {
    public void productDataByDayToDayAndId(String start, String end, String ids) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date startDate = sdf.parse(start);
        Date endDate = sdf.parse(end);
@ -314,10 +315,101 @@ public class JobService {
            throw new Exception("日期参数错误");
        }
        int day = daysBetween(startDate, endDate);
        String [] idStr=ids.split(",");
        for (int i = 0; i < day; i++) {
            Cache.cleanCache();//清空缓存
            productDataByOneDayWithId(getYesterday(i, startDate), id);
            for(String id:idStr){
                productDataByOneDayWithId(getYesterday(i, startDate), id);
            }
        }
    }
    //================================================没有休眠时间=============================================================
    public void productDataByDayToDayAndIdNoSleep(String start, String end, String id,Long sleepTime) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date startDate = sdf.parse(start);
        Date endDate = sdf.parse(end);
        if (startDate.after(endDate)) {
            throw new Exception("日期参数错误");
        }
        int day = daysBetween(startDate, endDate);
        for (int i = 0; i < day; i++) {
            Cache.cleanCache();//清空缓存
            productDataByOneDayWithIdNoSleep(getYesterday(i, startDate), id,sleepTime);
        }
    }
    public void productDataByOneDayWithIdNoSleep(String yesterday, String id,Long sleepTime) throws Exception {
        SimpleDateFormat dataSimple = new SimpleDateFormat("yyyy-MM-dd");
        Date date = dataSimple.parse(yesterday);
        if (date == null) {
            throw new Exception("时间格式错误");
        }
        Calendar calendar = new GregorianCalendar();
        calendar.setTime(date);
        calendar.add(calendar.DATE, -1);//把日期往后增加一天.整数往后推,负数往前移动
        Date nowDate = calendar.getTime();   //这个时间就是日期往后推一天的结果
        String daybefore = new SimpleDateFormat("yyyy-MM-dd").format(nowDate.getTime());
        QuartzJobConfig quartzJobConfig = wlyyJobConfigDao.findById(id);
        if (quartzJobConfig == null) {
            throw new Exception("id不存在");
        }
        WlyyJobConfigVO wlyyJobConfigVO = new WlyyJobConfigVO();
        BeanUtils.copyProperties(quartzJobConfig, wlyyJobConfigVO);
        Map<String, String> params = new HashMap<String, String>();
        params.put("jobConfig", wlyyJobConfigVO.getId());
        //往quartz框架添加任务
        params.put("startTime", daybefore);
        params.put("endTime", yesterday);
        for (int j = 1; j <= 2; j++) {
            params.put("timeLevel", j + "");
            if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
                quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
            }
            Thread.sleep(sleepTime*1000L);
        }
    }
    public void productDataByOneDayNoSleep(String yesterday,Long sleepTime) throws Exception {
        String sql="select * from wlyy_job_config_new a where  a.del='1' and a.id !=11 order by a.id asc";
        SimpleDateFormat dataSimple = new SimpleDateFormat("yyyy-MM-dd");
        Date date = dataSimple.parse(yesterday);
        if (date == null) {
            throw new Exception("时间格式错误");
        }
        Calendar calendar = new GregorianCalendar();
        calendar.setTime(date);
        calendar.add(calendar.DATE, -1);//把日期往后增加一天.整数往后推,负数往前移动
        Date nowDate = calendar.getTime();   //这个时间就是日期往后推一天的结果
        String daybefore = new SimpleDateFormat("yyyy-MM-dd").format(nowDate.getTime());
        List<QuartzJobConfig> quartzJobConfigs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(QuartzJobConfig.class));
        for (QuartzJobConfig quartzJobConfig : quartzJobConfigs) {
            WlyyJobConfigVO wlyyJobConfigVO = new WlyyJobConfigVO();
            BeanUtils.copyProperties(quartzJobConfig, wlyyJobConfigVO);
            Map<String, String> params = new HashMap<String, String>();
            params.put("jobConfig", wlyyJobConfigVO.getId());
            //往quartz框架添加任务
            params.put("startTime", daybefore);
            params.put("endTime", yesterday);
            for (int j = 1; j <= 2; j++) {
                params.put("timeLevel", j + "");
                if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
                    quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
                }
                Thread.sleep(sleepTime*1000L);
            }
        }
    }
}

+ 5 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorWorkWeekDao.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkWeek;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -31,10 +32,8 @@ public interface DoctorWorkWeekDao extends PagingAndSortingRepository<WlyyDoctor
    @Query("select a from WlyyDoctorWorkWeek a where a.doctor = ?1 and a.week = ?2")
    WlyyDoctorWorkWeek findDoctorWorkWeek(String doctor,String week);
    /**
     * 删除医生的排班信息
     *
     * @param doctor
     */
    void deleteByDoctor(String doctor);
    //删除医生的排班信息
    @Modifying
    @Query("delete WlyyDoctorWorkWeek a where a.doctor = ?1")
    int deleteByDoctor(String doctor);
}

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

@ -625,52 +625,47 @@ public class PatientHealthIndexService extends BaseService {
                        obj.put("value1", data);
                        obj.put("time1", recordDate);
                        obj.put("id1", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn1", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("2")) {
                        obj.put("value2", data);
                        obj.put("time2", recordDate);
                        obj.put("id2", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn2", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("3")) {
                        obj.put("value3", data);
                        obj.put("time3", recordDate);
                        obj.put("id3", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn3", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("4")) {
                        obj.put("value4", data);
                        obj.put("time4", recordDate);
                        obj.put("id4", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn4", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("5")) {
                        obj.put("value5", data);
                        obj.put("time5", recordDate);
                        obj.put("id5", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn5", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("6")) {
                        obj.put("value6", data);
                        obj.put("time6", recordDate);
                        obj.put("id6", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn6", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("7")) {
                        obj.put("value7", data);
                        obj.put("time7", recordDate);
                        obj.put("id7", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn7", deviceSn);
                        hadData = true;
                    }
                    obj.put("healthindexid", id);
                    obj.put("dataType",dataType);
                }
            }
        }

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

@ -9,6 +9,8 @@ import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientDisease;
import com.yihu.wlyy.entity.patient.PatientRemindRecords;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.vo.PatientVO;
import com.yihu.wlyy.entity.statistics.WlyyQuotaResult;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientGroupInfoDao;
@ -27,6 +29,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -319,6 +322,33 @@ public class SignPatientLabelInfoService extends BaseService {
                    " f. CODE = s.sign_code " +
                    " AND s.server_type ='"+labelCode+"'  ORDER BY f.ptOpenid DESC";
            args = new Object[]{doctor, doctor, teamCode};
        }else if("3".equals(labelType) && isSlowDisease){
            //慢病管理
            sql = "SELECT " +
                    "    DISTINCT t1.* " +
                    " FROM " +
                    "    wlyy_sign_family t1, " +
                    "    wlyy_sign_patient_label_info t2 ";
            if(StringUtils.isNotBlank(diseaseCondition)) {
                sql = sql + ", wlyy_patient p ";
            }
            sql = sql + " WHERE t2.label = ?";
    
            if(StringUtils.isNotBlank(diseaseCondition)) {
                sql = sql + " AND p.disease_condition = ? ";
            }
    
            sql = sql + "    AND t2.label_type = ? " +
                    "    AND t2.status = 1 " +
                    "    AND t1.patient = t2.patient " +
                    "    AND (t1.doctor = ? or t1.doctor_health = ?)" +
                    "    AND t1.status > 0 " +
                    "    AND t1.admin_team_code = ? order by t1.openid desc,convert(t1.name using gbk) ";
            if(StringUtils.isNotBlank(diseaseCondition)) {
                args = new Object[]{labelCode, diseaseCondition, labelType, doctor, doctor, teamCode};
            }else{
                args = new Object[]{labelCode, labelType, doctor, doctor,  teamCode};
            }
        } else {
            if (labelCode.equals("0")) {
                sql = "SELECT " +
@ -371,9 +401,22 @@ public class SignPatientLabelInfoService extends BaseService {
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                if (p == null) {
//                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
//
//                if (p == null) {
//                    continue;
//                }
    
                PatientVO p = new PatientVO();
                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 patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3" +
                            " 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()+"'";
        
                    p = (PatientVO)jdbcTemplate.queryForObject(patientsql,new BeanPropertyRowMapper(PatientVO.class));
                }else{
                    continue;
                }
@ -980,7 +1023,7 @@ public class SignPatientLabelInfoService extends BaseService {
     * @param teamCode  标签类型为4时,不能为空
     * @return
     */
    public JSONArray getPatientAmountByLabelType(String doctor, String labelType, Long teamCode) throws Exception {
    public JSONArray getPatientAmountByLabelType(String doctor, String labelType, Long teamCode, boolean isSlowDisease, String diseaseCondition) throws Exception {
        Doctor doc = doctorDao.findByCode(doctor);
        if (doc == null) {
@ -1014,18 +1057,19 @@ public class SignPatientLabelInfoService extends BaseService {
                int amount = 0;
                String sql = "";
                Object[] args = null;
                Calendar today = Calendar.getInstance();
                Calendar startDate = Calendar.getInstance();
                SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
                if (labelType.equals("5")) {
                    Calendar today = Calendar.getInstance();
                    Calendar startDate = Calendar.getInstance();
                    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    
                    sql = "select count(DISTINCT t1.patient) count" +
                            " from " +
                            "     wlyy_sign_family t1," +
                            "     wlyy_patient t3 " +
                            " where t1.patient = t3.code AND (t1.doctor = ? or t1.doctor_health = ?) and t1.status > 0 " +
                            (teamCode > 0 ? " and t1.admin_team_code = ? " : "");
    
                    if (label.getLabelCode().equals("1")) {
                        int week = today.get(Calendar.DAY_OF_WEEK) - 2;
                        if (week == -1) {
@ -1050,6 +1094,28 @@ public class SignPatientLabelInfoService extends BaseService {
                    } else {
                        args = new Object[]{doctor, doctor};
                    }
                }else if(labelType.equals("3") && isSlowDisease) {
                    sql = " SELECT " +
                            "     count(DISTINCT t1.patient) count" +
                            " FROM" +
                            "     wlyy_sign_family t1, " +
                            "     wlyy_sign_patient_label_info t2, " +
                            "     wlyy_patient t3 " +
                            " WHERE" +
                            "     t1.patient = t2.patient " +
                            "     AND t1.patient = t3.code "+
                            "     AND t2.label = ? " +
                            "     AND t2.label_type = ? " +
                            "     AND t2.status = 1 " +
                            "     AND (t1.doctor = ? or t1.doctor_health = ?)" +
                            "     AND t1.status > 0 " +
                            (teamCode > 0 ? "    AND t1.admin_team_code = ? " : "");
    
                    if (teamCode > 0) {
                        args = new Object[]{label.getLabelCode(), labelType, doctor, doctor, teamCode};
                    } else {
                        args = new Object[]{label.getLabelCode(), labelType, doctor, doctor};
                    }
                } else {
                    if (label.getLabelCode().equals("0")) {
                        sql = " SELECT " +
@ -3586,7 +3652,7 @@ public class SignPatientLabelInfoService extends BaseService {
        Map<String, JSONObject> result = new TreeMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
//        Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
        int start = page * pagesize;
        String sql = "";
        Object[] args = null;
@ -3652,7 +3718,32 @@ public class SignPatientLabelInfoService extends BaseService {
                    " AND s.server_type ='"+labelCode+"' " +
                    " ORDER BY " +
                    " f.ptOpenid DESC";
        }else if("3".equals(labelType) && isSlowDisease){
            //慢病管理
            sql = "SELECT " +
                    "    DISTINCT t1.* " +
                    " FROM " +
                    "    wlyy_sign_family t1, " +
                    "    wlyy_sign_patient_label_info t2 ";
            if(StringUtils.isNotBlank(diseaseCondition)) {
                sql = sql + ", wlyy_patient p ";
            }
            sql = sql + " WHERE t2.label = ?";
    
            if(StringUtils.isNotBlank(diseaseCondition)) {
                sql = sql + " AND p.disease_condition = ? ";
            }
    
            sql = sql + "    AND t2.label_type = ? " +
                    "    AND t2.status = 1 " +
                    "    AND t1.patient = t2.patient " +
                    "    AND t1.status > 0 " +
                    "    AND t1.admin_team_code = ? order by t1.openid desc,convert(t1.name using gbk) ";
            if(StringUtils.isNotBlank(diseaseCondition)) {
                args = new Object[]{labelCode,diseaseCondition, labelType, teamCode};
            }else{
                args = new Object[]{labelCode, labelType, teamCode};
            }
        }else {
            if ("0".equals(labelCode)) {
                sql = "SELECT " +
@ -3700,23 +3791,36 @@ 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);
            }
        }
//        //查询患者设备绑定情况
//        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) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                if (p == null) {
            
//                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
//                if (p == null) {
//                    continue;
//                }
                //查找居民 改造成获取绑定的设备和疾病类型--huangwenjie-2017.11.21
                PatientVO p = new PatientVO();
                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 patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3" +
                            " 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()+"'";
    
                    p = (PatientVO)jdbcTemplate.queryForObject(patientsql,new BeanPropertyRowMapper(PatientVO.class));
                }else{
                    continue;
                }
@ -3825,12 +3929,13 @@ public class SignPatientLabelInfoService extends BaseService {
                json.put("diseaseCondition",p.getDiseaseCondition());
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
//
//                String deviceType = "";
//                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
//                    deviceType = (String) patientDeviceTypeMap.get(p.getCode());
//                }
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                String deviceType = "";
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (String) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
                json.put("deviceType",p.getDeviceType());
                boolean epTime = false;
@ -4067,8 +4172,6 @@ public class SignPatientLabelInfoService extends BaseService {
                                                           int page, int pagesize) throws Exception {
        Doctor doc = doctorDao.findByCode(doctor);
        Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
        if (doc == null) {
            throw new Exception("doctor info can not find");
        }
@ -4099,7 +4202,7 @@ public class SignPatientLabelInfoService extends BaseService {
                (StringUtils.isNotEmpty(labelCode) ? " AND t2.label = ? " : "") +
                (StringUtils.isNotEmpty(labelType) ? " AND t2.label_type = ? " : "") +
                (teamCode > 0 ? (" AND admin_team_code = " + teamCode) : "");
        sql = sql + " AND t3.disease > 0 AND t3.status > 0 ";
        sql = sql + " AND t3.status > 0 and t2.label_type = '3' and ( t2.label =1 or t2.lable = 2) ";
        if (matcher.find()) {
            sql = sql + "  AND (t1.idcard like ?) ";
@ -4122,16 +4225,22 @@ public class SignPatientLabelInfoService extends BaseService {
        }
        sql = sql + " order by t3.standard_status,t3.disease_condition,t3.disease,t3.openid desc limit " + page + "," + pagesize;
        sql = sql + " order by t3.standard_status,t3.disease_condition,t2.label,t3.openid desc limit " + page + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                System.out.println("1111");
                if (p == null) {
                PatientVO p = new PatientVO();
                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 patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3" +
                            " 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()+"'";
        
                    p = (PatientVO)jdbcTemplate.queryForObject(patientsql,new BeanPropertyRowMapper(PatientVO.class));
                }else{
                    continue;
                }
@ -4264,11 +4373,7 @@ public class SignPatientLabelInfoService extends BaseService {
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                String deviceType = "";
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (String) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
                json.put("deviceType",p.getDeviceType());
                boolean epTime = false;
                try {
@ -4301,7 +4406,6 @@ public class SignPatientLabelInfoService extends BaseService {
    public JSONArray searchSlowDiseaseTeamsPatients(String filter, long teamCode, int page, int pagesize, String diseaseCondition) throws Exception {
        Map<String, JSONObject> result = new HashMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
        page = page * pagesize;
        //String reg = "(^\\d{15}$)|(^\\d{17}([0-9]|X)$)";
@ -4316,6 +4420,7 @@ public class SignPatientLabelInfoService extends BaseService {
                " FROM " +
                "    wlyy_sign_family t1 " +
                " JOIN wlyy_patiend t2 ON t1.patient = t2.code " +
                " JOIN wlyy_sign_patient_label_info t3 on t1.patient = t3.patient " +
                " WHERE " +
                (isIdcard ? " t1.patient = t2.code  and " : "") +
                "    t1.status > 0 " +
@ -4323,28 +4428,23 @@ public class SignPatientLabelInfoService extends BaseService {
                "  AND" +
                (isIdcard ? " t2.idcard like ? " : " t1.name like ? ");
        sqlTemp = sqlTemp + " AND t2.disease_condition = "+diseaseCondition+" AND t2.disease >0 AND t2.status >0 ";
        sqlTemp = sqlTemp + " AND t2.disease_condition = "+diseaseCondition+" AND t2.status >0 and t3.label_type = 3 and (t3.label = 1 or t3.label = 2)";
        String sql = sqlTemp + " order by t2.standard_status,t2.disease_condition,t2.disease,t2.openid desc  limit " + page + "," + pagesize;
        String sql = sqlTemp + " order by t2.standard_status,t2.disease_condition,t3.label,t2.openid desc  limit " + page + "," + 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) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                if (p == null) {
                PatientVO p = new PatientVO();
                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 patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3" +
                            " 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()+"'";
        
                    p = (PatientVO)jdbcTemplate.queryForObject(patientsql,new BeanPropertyRowMapper(PatientVO.class));
                }else{
                    continue;
                }
@ -4460,11 +4560,7 @@ public class SignPatientLabelInfoService extends BaseService {
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                String deviceType = "";
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (String) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
                json.put("deviceType",p.getDeviceType());
                boolean epTime = false;
                try {

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

@ -314,14 +314,17 @@ public class PrescriptionFollowupContentService extends BaseService {
		if(StringUtils.isNotBlank(healthindexid) || !list.isEmpty()){
			
			JSONObject obj = new JSONObject();
			Integer valueType = 0;
			
			//如果有传体征ID,则查体征数据
			if(StringUtils.isNotBlank(healthindexid)){
				DevicePatientHealthIndex devicePatientHealthIndex = devicePatientHealthIndexDao.findOne(new Long(healthindexid));
				obj = (JSONObject)JSON.toJSON(devicePatientHealthIndex);
				valueType = obj.getInteger("value2");
			}else{
				//如果没传体征ID,则获取最近的一条
				obj = (JSONObject)list.get(0);
				valueType = obj.getInteger("dataType");
			}
			
			imBloodSugarDate = obj.getDate("recordDate");
@ -330,7 +333,7 @@ public class PrescriptionFollowupContentService extends BaseService {
			if(StringUtils.isNotBlank(obj.getString("value1"))){
				
				
				Integer valueType = obj.getInteger("value2");
				
				
				//餐前
				if(1 == valueType || 3 == valueType || 5 == valueType){

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

@ -377,7 +377,7 @@ public class FamilyContractService extends BaseService {
     * @param patient 患者标识
     * @return
     */
    public JSONObject findJiMeiDoctorMainPage(String patient, String doctor) {
    public JSONObject findJiMeiDoctorMainPage(String patient, String doctor,Integer page,Integer pagesize) {
        JSONObject json = new JSONObject();
        // 查询医生基本信息
        Doctor d = doctorDao.findByCode(doctor);
@ -394,14 +394,30 @@ public class FamilyContractService extends BaseService {
        json.put("expertise", d.getExpertise());
        json.put("level", d.getLevel());
        SignFamily sf = signFamilyDao.findByjiatingPatient(patient);
        if (sf == null) {
            // 没有签约信息
            json.put("sign", -1);
            json.put("isjimei", 0);
        } else {
            // 有签约信息
            json.put("sign", sf.getStatus());
            if(sf.getHospital().startsWith("350211")){
                json.put("isjimei", 1);
            }else {
                json.put("isjimei", 0);
            }
        }
        //获取健康文章
        com.alibaba.fastjson.JSONArray jsonArray = new com.alibaba.fastjson.JSONArray();
        try {
            jsonArray = healthEducationArticleService.getDoctorArticalByUserId(null,1,null,0,3,doctor);
            jsonArray = healthEducationArticleService.getDoctorArticalByUserId(null,1,null,page,pagesize,doctor);
        }catch (Exception e){
            logger.error("获取福州健康文章失败,"+e.getMessage());
        }
        json.put("healthEduArticles",jsonArray);
        return json;
    }
@ -2051,6 +2067,40 @@ public class FamilyContractService extends BaseService {
        return result;
    }
    /**
     * 获取签约医生
     * @param patientCode
     * @return
     */
    public com.alibaba.fastjson.JSONArray getSignDoctors(String patientCode){
        com.alibaba.fastjson.JSONArray jsonArray = new com.alibaba.fastjson.JSONArray();
        SignFamily jtSignFamily = signFamilyDao.findFamilySignByPatient(patientCode);
        if (jtSignFamily != null) {
            Patient patient = patientDao.findByCode(patientCode);
            Doctor doctor = doctorDao.findByCode(jtSignFamily.getDoctor());
            if (doctor != null) {
                com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
                jo.put("code", doctor.getCode());
                jo.put("sex", doctor.getSex());
                jo.put("name", doctor.getName());
                jo.put("photo", doctor.getPhoto());
                jo.put("hosptialName", doctor.getHospitalName());
                jo.put("level", doctor.getLevel());
                jo.put("signType", "2");//2是家庭
                jo.put("signStatus", jtSignFamily.getStatus());
                jo.put("jobName", doctor.getJobName());
                jo.put("disease", patient.getDisease());//0健康,1高血压,2糖尿病,3高血压+糖尿病
                if (jtSignFamily.getStatus() == 0) {
                    jo.put("sqDate", DateUtil.dateToStrShort(jtSignFamily.getPatientApplyDate()));//申请时间
                } else {
                    jo.put("qyDate", DateUtil.dateToStrShort(jtSignFamily.getBegin()));//签约时间
                    jo.put("endDate", DateUtil.dateToStrShort(jtSignFamily.getEnd()));//结束时间
                }
                jsonArray.add(jo);
            }
        }
        return jsonArray;
    }
    public JSONArray getSignDoctorMessage(String patientCode) {
        JSONArray jsonArray = new JSONArray();
        //找出患者的三师签约信息

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsAllService.java

@ -2823,6 +2823,7 @@ public class StatisticsAllService extends BaseService {
                            num = peopleNum.getTnbNum();
                            taskNum = peopleNum.getTnbTaskNum();
                        }
                        map.put("rate", df.format(((long) map.get("amount") * 1.0000) / num * 100));
                        map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / taskNum * 100));
                        map.put("targetRate", df.format(taskNum * 1.0000 / num * 100));

+ 113 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -2609,6 +2609,7 @@ public class StatisticsService extends BaseService {
                    " AND c.patient = s.id " +
                    " AND t. STATUS <> 10 " +
                    " AND t.`reply` = 0 " +
                    " AND c.type = 2 "+
                    " AND p.session_id = t.session_id " +
                    " AND d.id ='" + doctor + "'" +
                    " AND c.admin_team_code = " + teamCode +
@ -2631,6 +2632,7 @@ public class StatisticsService extends BaseService {
                    " AND p.session_id = t.session_id " +
                    " AND d.id ='" + doctor + "'" +
                    " AND c.admin_team_code = " + teamCode +
                    " AND c.type = 2 "+
                    " AND t.create_time >= '" + startDate + "' " +
                    " AND t.create_time <= '" + endDate + "' " +
                    " GROUP BY dateNo";
@ -2654,6 +2656,7 @@ public class StatisticsService extends BaseService {
                    "  AND d.id ='" + doctor + "'" +
                    "  AND t. STATUS <> 10  " +
                    "  AND t.`reply` = 0  " +
                    "  AND c.type = 2 "+
                    "  AND t.create_time >= '" + startDate + "' " +
                    "  AND t.create_time <= '" + endDate + "' " +
                    "  GROUP BY weekOfMonth";
@ -2673,6 +2676,7 @@ public class StatisticsService extends BaseService {
                    "  AND p.session_id = t.session_id " +
                    "  AND d.id ='" + doctor + "'" +
                    "  AND c.admin_team_code = " + teamCode +
                    "  AND c.type = 2 "+
                    "  AND t.create_time >= '" + startDate + "' " +
                    "  AND t.create_time <= '" + endDate + "' " +
                    "  GROUP BY weekOfMonth";
@ -2928,6 +2932,7 @@ public class StatisticsService extends BaseService {
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.type <> 8"+
                " AND c.type = 2"+
                " AND c.admin_team_code =" + teamCode +
                " AND d.id='" + doctor + "'" +
                " AND t.create_time <= '" + endDate + "'";
@ -2946,6 +2951,7 @@ public class StatisticsService extends BaseService {
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.type <> 8"+
                " AND c.type = 2"+
                " AND t.`reply`=1 " +
                " AND c.admin_team_code =" + teamCode +
                " AND d.id='" + doctor + "'" +
@ -2966,6 +2972,7 @@ public class StatisticsService extends BaseService {
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.type <> 8"+
                " AND c.type = 2"+
                " AND c.admin_team_code =" + teamCode +
                " AND d.id='" + doctor + "'" +
                " AND t.create_time >= '" + startDate + "' " +
@ -2985,6 +2992,7 @@ public class StatisticsService extends BaseService {
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.type <> 8"+
                " AND c.type = 2"+
                " AND t. STATUS <> 10  " +
                " AND t.`reply` = 0  " +
                " AND c.admin_team_code =" + teamCode +
@ -3733,8 +3741,8 @@ public class StatisticsService extends BaseService {
                " wlyy_patient_health_guidance w " +
                " WHERE " +
                " w.admin_team_code =  " + teamCode +
                " AND w.czrq <= '" + endDate + "' " +
                " AND w.czrq >= '" + startDate + "' " +
                //" AND w.czrq <= '" + endDate + "' " +
                //" AND w.czrq >= '" + startDate + "' " +
                " GROUP BY w.doctor " +
                " ) c ON c.doctor = m.doctor_code, " +
                " wlyy_doctor d " +
@ -4093,7 +4101,8 @@ public class StatisticsService extends BaseService {
                " w.admin_team_code =" + teamCode +
                " AND w.doctor ='" + doctor + "'" +
                " AND w.czrq <= '" + endDate + "' " +
                " AND w.czrq >= '" + startDate + "'";
                " AND w.czrq >= '" + startDate + "'"+
                " GROUP BY w.batch_no";
        List<Map<String, Object>> totalList = jdbcTemplate.queryForList(totalSql);
        List<Map<String, Object>> addList = jdbcTemplate.queryForList(addSql);
        JSONObject rs = new JSONObject();
@ -6660,5 +6669,106 @@ public class StatisticsService extends BaseService {
        }
        return null;
    }
    /**
     * esController里的getRayStatByTeam求咨询总数
     * 2017-11-21
     * zhangdan
     * @param startDate
     * @param endDate
     * @param id
     * @return
     */
    public Long getConsultTotalForEsGetRayStatByTeam(String startDate,String endDate,long id){
        String imDataBaseName = im_dataBase_name;
        //startDate = startDate + " 00:00:00";
        //endDate = endDate + " 23:59:59";
        String totalSql = "SELECT " +
                "  COUNT(1) total " +
                "  FROM " +
                "  " + imDataBaseName + ".Topics t, " +
                "  " + imDataBaseName + ".Participants p, " +
                "  " + imDataBaseName + ".Doctors d, " +
                "  Wlyy_Consult_Team c, " +
                "  " + imDataBaseName + ".Patients s " +
                "  WHERE " +
                "  d.id = p.participant_id " +
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND c.type = 2 " +
                " AND p.session_id = t.session_id " +
                " AND c.admin_team_code =" + id +
                " AND t.create_time >= '" + startDate + "' " +
                " AND t.create_time <= '" + endDate + "'";
        List<Map<String, Object>> totalList = jdbcTemplate.queryForList(totalSql);
        Long totalCount = 0L;
        if (totalList != null && totalList.size() > 0) {
            Map<String, Object> total = totalList.get(0);
            totalCount = (Long) total.get("total");
        }
        return totalCount;
    }
    /**
     * esController里的getTeamConsultCount求咨询总数
     * 2017-11-21
     * zhangdan
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param type
     * @return
     */
    public List<Map<String, Object>> getCousultTotalForEsGetTeamConsultCount(String teamCode, String startDate, String endDate, String type) {
        String imDataBaseName = im_dataBase_name;
        String totalSql;
        startDate = startDate + " 00:00:00";
        endDate = endDate + " 23:59:59";
        if ("0".equals(type)) {
            //按周统计
            totalSql = "SELECT " +
                    "  left(t.create_time,10) AS dateNo, COUNT(1) total " +
                    " FROM " +
                    "  " + imDataBaseName + ".Topics t, " +
                    "  " + imDataBaseName + ".Participants p, " +
                    "  " + imDataBaseName + ".Doctors d, " +
                    "  Wlyy_Consult_Team c, " +
                    "  " + imDataBaseName + ".Patients s " +
                    " WHERE " +
                    "  d.id = p.participant_id " +
                    " AND c.consult = t.id " +
                    " AND c.patient = s.id " +
                    " AND p.session_id = t.session_id " +
                    " AND c.type <> 8" +
                    " AND c.admin_team_code = " + teamCode +
                    " AND t.create_time >= '" + startDate + "' " +
                    " AND t.create_time <= '" + endDate + "' " +
                    " GROUP BY dateNo";
        } else {
            //按月统计
            totalSql = "SELECT " +
                    "  (DATE_FORMAT(t.create_time, '%v') - DATE_FORMAT('" + startDate + "', '%v') + 1) AS weekOfMonth, " +
                    "  COUNT(1) AS total " +
                    "  FROM " +
                    "  " + imDataBaseName + ".Topics t, " +
                    "  " + imDataBaseName + ".Participants p, " +
                    "  " + imDataBaseName + ".Doctors d, " +
                    "  Wlyy_Consult_Team c, " +
                    "  " + imDataBaseName + ".Patients s " +
                    "  WHERE " +
                    "  d.id = p.participant_id " +
                    "  AND c.consult = t.id " +
                    "  AND c.patient = s.id " +
                    "  AND p.session_id = t.session_id " +
                    "  AND c.type <> 8" +
                    "  AND c.admin_team_code = " + teamCode +
                    "  AND t.create_time >= '" + startDate + "' " +
                    "  AND t.create_time <= '" + endDate + "' " +
                    "  GROUP BY weekOfMonth";
        }
        List<Map<String, Object>> totalList = jdbcTemplate.queryForList(totalSql);
        return totalList;
    }
}

+ 183 - 85
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.service.app.statisticsES;
import com.yihu.wlyy.config.es.ElasticFactory;
import com.yihu.wlyy.entity.address.Town;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDispensaryCode;
@ -9,8 +10,10 @@ import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.entity.statistics.PopulationBase;
import com.yihu.wlyy.repository.address.TownDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.service.app.statistics.StatisticsAllService;
import com.yihu.wlyy.service.app.statistics.StatisticsService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.util.Constant;
import com.yihu.wlyy.util.DateUtil;
@ -57,14 +60,21 @@ public class StatisticsESService {
    @Autowired
    TownDao townDao;
    @Autowired
    DoctorDao doctorDao;
    @Autowired
    private SystemDictService systemDictService;
    @Autowired
    private StatisticsAllService statisticsAllService;
    @Autowired
    private StatisticsService statisticsService;
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXX");
    SimpleDateFormat dateFormat3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    DecimalFormat decimalFormat = new DecimalFormat("0.00");
    @Autowired
    private StringRedisTemplate redisTemplate;
    /**
     * 获取上次统计时间
@ -75,16 +85,7 @@ public class StatisticsESService {
        String date = DateUtil.dateToStrLong(new Date());
        try {
//            date = redisTemplate.opsForValue().get("quota:date");
//            JestClient jestClient = elasticFactory.getJestClient();
//
//            Bulk.Builder bulk = new Bulk.Builder().defaultIndex("health_edu_article_patient_test").defaultType("health_edu_article_patient_test");
//            PrescriptionDispensaryCode ap = new PrescriptionDispensaryCode();
//            ap.setCode("aaaa");
//            ap.setType(2);
//            Index index = new Index.Builder(ap).build();
//            bulk.addAction(index);
//            BulkResult br = jestClient.execute(bulk.build());
            date = redisTemplate.opsForValue().get("quota:date");
        } catch (Exception e) {
            e.printStackTrace();
        }
@ -209,13 +210,23 @@ public class StatisticsESService {
        SaveModel saveModel = null;
        if (StringUtils.isNotEmpty(level2_type)) {
            saveModel = elasticsearchUtil.findOneDateQuotaLevel1(startDate, endDate, area, level, index, "1", level2_type);
            saveModel = elasticsearchUtil.findOneDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, level2_type);
        } else {
            saveModel = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, area, level, index, "1");
            saveModel = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL);
        }
        return saveModel.getResult2().longValue();
    }
    public long getTotalAmount3(String startDate, String endDate, String area, int level, String index, String level2_type) throws Exception {
        SaveModel saveModel = null;
        if (StringUtils.isNotEmpty(level2_type)) {
            saveModel = elasticsearchUtil.findOneDateQuotaLevel1(endDate, endDate, area, level, index,SaveModel.timeLevel_DDL, level2_type);
        } else {
            saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL);
        }
        return saveModel.getResult2().longValue();
    }
    /**
     * 查询截止某个日期某个区域后机构各下级指标累计情况
     *
@ -269,7 +280,7 @@ public class StatisticsESService {
                }
                PopulationBase peopleNum = getPopulationBase(area, year);
                if (peopleNum != null) {
                    map.put("rate", df.format((saveModel.getResult2() * 1.0000) / peopleNum.getNum() * 100));
                    map.put("rate", (peopleNum.getNum() > 0 ? df.format((saveModel.getResult2() * 1.0000) / peopleNum.getNum() * 100) : 0));
                    map.put("rateString", saveModel.getResult2().longValue() + "/" + peopleNum.getNum());
                }
            }
@ -406,7 +417,7 @@ public class StatisticsESService {
                SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, area, level, "1", "2");
                Long num = saveModel.getResult2().longValue();
                for (Map<String, Object> map : resultList) {
                    double rateG = (total > 0 ? ((long) map.get("amount")) * 1.0000 / num * 100 : 0);
                    double rateG = (num > 0 ? ((long) map.get("amount")) * 1.0000 / num * 100 : 0);
                    map.put("rate", df.format(rateG));
                    map.put("rateString", ((long) map.get("amount")) + "/" + num);
                }
@ -447,7 +458,7 @@ public class StatisticsESService {
     */
    public JSONArray getPayPremiums(String endDate, String area, int level) throws Exception {
        //已缴费
        SaveModel paidSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, "1", "2");
        SaveModel paidSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, "1", SaveModel.timeLevel_DDL);
        //未交费
        SaveModel noPaySaveModel =null;
        //因为14的指标 16年度是分为 已缴费 未交费 已退费  17年度过后就只有未交费  所以16年度用1级指标 17年度用0级指标
@ -467,23 +478,25 @@ public class StatisticsESService {
        //求签约总数
        long totalNum = paidTotal + noPayTotal;
        map2.put("code", "0");
        map2.put("amount", noPayTotal);
        map2.put("name", "未缴费人数");
        double rateG2 = (noPayTotal > 0 ? noPayTotal * 1.0000 / totalNum * 100 : 0);
        map2.put("rate", df.format(rateG2));
        map2.put("rateString", noPayTotal + "/" + totalNum);
        resultList.add(map2);
        map1.put("code", "1");
        map1.put("amount", paidTotal);
        map1.put("name", "已缴费人数");
        double rateG = (paidTotal > 0 ? paidTotal * 1.0000 / totalNum * 100 : 0);
        map1.put("rate", df.format(rateG));
        ;
        map1.put("rateString", paidTotal + "/" + totalNum);
        resultList.add(map1);
        map2.put("code", "0");
        map2.put("amount", noPayTotal);
        map2.put("name", "未缴费人数");
        double rateG2 = (noPayTotal > 0 ? noPayTotal * 1.0000 / totalNum * 100 : 0);
        map2.put("rate", df.format(rateG2));
        ;
        map2.put("rateString", noPayTotal + "/" + totalNum);
        resultList.add(map2);
        return new JSONArray(resultList);
    }
@ -1243,7 +1256,7 @@ public class StatisticsESService {
                map.put("signTaskNum", signTaskNum);//目标量
                map.put("signRegulationNum", signRegulationNum);//调控量
                if (!low_level.equals("5")) {
                    PopulationBase peopleNum = getPopulationBase(map.get("code").toString(), year);
                    PopulationBase peopleNum = getPopulationBase(String.valueOf(map.get("code")), year);
                    if (peopleNum != null) {
                        int num = 0;
                        int taskNum = 0;
@ -1251,16 +1264,16 @@ public class StatisticsESService {
                        if (lowCode.equals("3")) {
                            num = peopleNum.getSixFiveNum();
                            taskNum = peopleNum.getSixFiveTaskNum();
                        } else if (lowCode.equals("5")) {
                        } else if (lowCode.equals("1")) {
                            num = peopleNum.getGxyNum();
                            taskNum = peopleNum.getGxyTaskNum();
                        } else if (lowCode.equals("4")) {
                        } else if (lowCode.equals("2")) {
                            num = peopleNum.getTnbNum();
                            taskNum = peopleNum.getTnbTaskNum();
                        }
                        map.put("rate", df.format(((long) map.get("amount") * 1.0000) / num * 100));
                        map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / taskNum * 100));
                        map.put("targetRate", df.format(taskNum * 1.0000 / num * 100));
                        map.put("rate", (num > 0 ? df.format(((long) map.get("amount") * 1.0000) / num * 100) : 0));
                        map.put("taskRate", (taskNum > 0 ? df.format(((long) map.get("amount") * 1.0000) / taskNum * 100) : 0));
                        map.put("targetRate", (num > 0 ? df.format(taskNum * 1.0000 / num * 100) : 0));
                        map.put("rateString", map.get("amount") + "/" + num);
                        map.put("taskRateString", map.get("amount") + "/" + taskNum);
                        map.put("targetRateString", taskNum + "/" + num);
@ -1460,10 +1473,10 @@ public class StatisticsESService {
                        if (lowCode.equals("3")) {
                            num = peopleNum.getSixFiveNum();
                            taskNum = peopleNum.getSixFiveTaskNum();
                        } else if (lowCode.equals("5")) {
                        } else if (lowCode.equals("1")) {
                            num = peopleNum.getGxyNum();
                            taskNum = peopleNum.getGxyTaskNum();
                        } else if (lowCode.equals("4")) {
                        } else if (lowCode.equals("2")) {
                            num = peopleNum.getTnbNum();
                            taskNum = peopleNum.getTnbTaskNum();
                        }
@ -2281,6 +2294,66 @@ public class StatisticsESService {
        return resultMaps;
    }
    /**
     * 团队报告团队详情中健康教育折线图
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param type
     * @return
     */
    public JSONArray getTeamEduLine(String teamCode, String startDate, String endDate, String type)throws Exception {
        startDate = startDate + " 00:00:00";
        endDate = endDate + " 23:59:59";
        List<Map<String,Object>> dateList = DateUtil.findDates(dateFormat.parse(startDate),dateFormat.parse(endDate));
        Integer interval = Integer.parseInt(type) + 1;
        List<SaveModel> articleCountList = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate,endDate,teamCode,Integer.valueOf(SaveModel.teamLevel),"59",SaveModel.timeLevel_ZL,String.valueOf(interval));
        List<SaveModel> batchNoCountList = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate,endDate,teamCode,Integer.valueOf(SaveModel.teamLevel),"71",SaveModel.timeLevel_ZL,String.valueOf(interval));
        List<Map<String, Object>> list = new ArrayList<>();
        if(articleCountList!=null){
            //循环人数集合
            for (SaveModel one1:articleCountList){
                String date = "";
                if(one1.getQuotaDate()!=null){
                    date=dateFormat.format(one1.getQuotaDate());
                }
                if (one1.getResult2().intValue()!=0){
                    Map<String,Object> map = new HashedMap();
                    map.put("articleCount",one1.getResult2().intValue());
                    //查看批次集合里是否有同时间的数据
                    for (SaveModel one2:batchNoCountList) {
                        if (one2.getQuotaDate()!=null && dateFormat.format(one2.getQuotaDate()).equals(date)){
                            map.put("batchCount",one2.getResult2().intValue());
                        }
                    }
                    if ("0".equals(type)) {
                        map.put("dateNo",date);
                    } else {
                        map.put("weekOfMonth", DateUtil.getWeekOfMonth(date));
                    }
                    list.add(map);
                }else{
                    //循环批次
                    for (SaveModel one2:batchNoCountList) {
                        if (one2.getResult2().intValue()!=0 && one2.getQuotaDate()!=null && dateFormat.format(one2.getQuotaDate()).equals(date)){
                            Map<String,Object> map = new HashedMap();
                            map.put("articleCount",0);
                            map.put("batchCount",one2.getResult2().intValue());
                            if ("0".equals(type)) {
                                map.put("dateNo",dateFormat.format(date));
                            } else {
                                map.put("weekOfMonth", DateUtil.getWeekOfMonth(date));
                            }
                            list.add(map);
                        }
                    }
                }
            }
        }
        return new JSONArray(list);
    }
    public JSONObject getRenewPercentAndChangePercent(String index, Integer level, String area, String year, String lowCode) {
        JSONObject jo = new JSONObject();
        String switchIndex = "";//转签index
@ -2468,13 +2541,13 @@ public class StatisticsESService {
//        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        //获取微信关注的未交费
//        Map<String, Object> expenseStatus0 = getByIndexSingle(date, area, level, "49",dateFormat);
        SaveModel expenseStatus0 = elasticsearchUtil.findOneDateQuotaLevel0(date, area, level, "49", "2");
        SaveModel expenseStatus0 = elasticsearchUtil.findOneDateQuotaLevel0(date, area, level, "49", SaveModel.timeLevel_DDL);
        //获取微信关注的已交费
//        Map<String, Object> expenseStatus1 = getByIndexSingle(date, area, level, "50",dateFormat);
        SaveModel expenseStatus1 = elasticsearchUtil.findOneDateQuotaLevel0(date, area, level, "50", "2");
        SaveModel expenseStatus1 = elasticsearchUtil.findOneDateQuotaLevel0(date, area, level, "50", SaveModel.timeLevel_DDL);
        //获取已缴费的签约数
//        Map<String, Object> expenseStatus1Sigjn = getByIndexSingle(date, area, level, "1",dateFormat);
        SaveModel expenseStatus1Sigjn = elasticsearchUtil.findOneDateQuotaLevel0(date, area, level, "1", "2");
        SaveModel expenseStatus1Sigjn = elasticsearchUtil.findOneDateQuotaLevel0(date, area, level, "1", SaveModel.timeLevel_DDL);
        JSONObject jsonObject = new JSONObject();
        if (Integer.valueOf(SaveModel.teamLevel) == level) {
            jsonObject.put("name", expenseStatus1Sigjn.getTeamName());
@ -2738,10 +2811,11 @@ public class StatisticsESService {
        rs.put(signTotal);
        //4.获取咨詢數
        SaveModel saveModel3 = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, admin.getId() + "", Integer.parseInt(SaveModel.teamLevel), "3", SaveModel.timeLevel_ZL);
        Map<String, Object> consultCout = new HashMap<>();
        consultCout.put("consultCount", saveModel3.getResult2().longValue());
        //4.获取咨詢數(先使用旧版)
        Map<String, Object> consultCout = statisticsService.getConsultByteam(admin.getId(),startDate,endDate);
        //SaveModel saveModel3 = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, admin.getId() + "", Integer.parseInt(SaveModel.teamLevel), "3", SaveModel.timeLevel_ZL);
        //Map<String, Object> consultCout = new HashMap<>();
        //consultCout.put("consultCount", saveModel3.getResult2().longValue());
        rs.put(consultCout);
        //5.获取待预约
@ -2770,9 +2844,6 @@ public class StatisticsESService {
        //3.平均满意度
        SaveModel saveModel2 = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, admin.getId() + "", Integer.parseInt(SaveModel.teamLevel), "28", SaveModel.timeLevel_ZL);
//        String sql = "SELECT count(1) as num FROM wlyy_consult_team d WHERE d.czrq>= ? and d.czrq<=? and d.admin_team_code =? ";
//        Map<String, Object> map = jdbcTemplate.queryForMap(sql, startDate, endDate,admin.getId());
        //SaveModel saveModel21 = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, admin.getId() + "", Integer.parseInt(SaveModel.teamLevel), "3", SaveModel.timeLevel_ZL);
        Double avgCout = 0.0;
        String avgCoutStr="";
        DecimalFormat df = new DecimalFormat("#.0");
@ -2780,10 +2851,6 @@ public class StatisticsESService {
            avgCout = saveModel2.getResult1()/saveModel2.getResult2();
            avgCoutStr=df.format(avgCout);
        }
//        if (saveModel21.getResult2().intValue()!=0){
//            avgCout = saveModel2.getResult1() / saveModel21.getResult2();
//            avgCoutStr = df.format(avgCout);
//        }
        Map<String, Object> avgScore = new HashMap<>();
        avgScore.put("avgScore", avgCoutStr);
        rs.put(avgScore);
@ -2869,9 +2936,10 @@ public class StatisticsESService {
        endDate = endDate + " 23:59:59";
        String quotaTime = elasticsearchUtil.getQuotaTime();
        Long id = admin.getId();
        //家庭医生、健康咨询增量
        SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, id + "", Integer.parseInt(SaveModel.teamLevel), "3", SaveModel.timeLevel_ZL);
        Long totalCount = saveModel.getResult2().longValue();
        //家庭医生、健康咨询增量(先使用旧版 17-11-21)
        Long totalCount = statisticsService.getConsultTotalForEsGetRayStatByTeam(startDate,endDate,id);
        /*SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, id + "", Integer.parseInt(SaveModel.teamLevel), "3", SaveModel.timeLevel_ZL);
        Long totalCount = saveModel.getResult2().longValue();*/
        //健康咨询量  未回复当天的到达量
        SaveModel saveModel2 = elasticsearchUtil.findOneDateQuotaLevel0(quotaTime, quotaTime, id + "", Integer.parseInt(SaveModel.teamLevel), "22", SaveModel.timeLevel_DDL);
@ -2940,9 +3008,11 @@ public class StatisticsESService {
        //咨询未回复
        Integer interval = Integer.parseInt(type) + 1;
        List<SaveModel> list = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, teamCode, Integer.parseInt(SaveModel.teamLevel), "22", SaveModel.timeLevel_ZL, interval + "");
        //咨询总数
        List<SaveModel> list2 = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, teamCode, Integer.parseInt(SaveModel.teamLevel), "3", SaveModel.timeLevel_ZL, interval + "");
        //咨询总数(先使用旧版17-11-21)
        //List<SaveModel> list2 = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, teamCode, Integer.parseInt(SaveModel.teamLevel), "3", SaveModel.timeLevel_ZL, interval + "");
        List<Map<String,Object>> totalList = statisticsService.getCousultTotalForEsGetTeamConsultCount(teamCode,startDate,endDate,type);
        Map<String, Object> map = null;
        //遍历未回复集合
        List<Map<String, Object>> noReyList = new ArrayList<>();
        for (SaveModel one : list) {
            if (one.getResult2().intValue()!=0){
@ -2950,14 +3020,14 @@ public class StatisticsESService {
                if ("0".equals(type)) {
                    map.put("dateNo",dateFormat.format(one.getQuotaDate()));
                } else {
                    map.put("dateNo", dateFormat.format(one.getQuotaDate()));
                    map.put("weekOfMonth", DateUtil.getWeekOfMonth(dateFormat.format(one.getQuotaDate())));
                }
                map.put("noRely", one.getResult2().longValue());
                noReyList.add(map);
            }
        }
        List<Map<String, Object>> totalList = new ArrayList<>();
        /*List<Map<String, Object>> totalList = new ArrayList<>();
        for (SaveModel one : list2) {
            if (one.getResult2().intValue()!=0){
                map = new HashMap<>();
@ -2969,7 +3039,7 @@ public class StatisticsESService {
                map.put("total", one.getResult2().longValue());
                totalList.add(map);
            }
        }
        }*/
        JSONObject result = new JSONObject();
        result.put("noReyList", noReyList);
        result.put("totalList", totalList);
@ -2977,7 +3047,7 @@ public class StatisticsESService {
    }
    /**
     * 获取团队随访量折线统计图(弃用)
     * 获取团队随访量折线统计图
     *
     * @param type
     * @param teamCode
@ -2987,22 +3057,40 @@ public class StatisticsESService {
     */
    public JSONObject getTeamFollowupLine(String teamCode, String startDate, String endDate, String type) throws Exception {
        Integer interval = Integer.parseInt(type) + 2;
        List<SaveModel> list = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, teamCode, Integer.parseInt(SaveModel.teamLevel), "4", "2", interval + "");
        Integer interval = Integer.parseInt(type) + 1;
        List<SaveModel> list1 = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, teamCode, Integer.parseInt(SaveModel.teamLevel), "69", SaveModel.timeLevel_ZL, interval + "");
        List<SaveModel> list2 = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, teamCode, Integer.parseInt(SaveModel.teamLevel), "70", SaveModel.timeLevel_ZL, interval + "");
        Map<String, Object> map = null;
        List<Map<String, Object>> totalList = new ArrayList<>();
        for (SaveModel one : list) {
            map = new HashMap<>();
            if ("0".equals(type)) {
                map.put("dateNo", dateFormat.format(one.getQuotaDate()));
            } else {
                map.put("weekOfMonth", DateUtil.getWeekOfMonth(dateFormat.format(one.getQuotaDate())));
        for (SaveModel one : list1) {
            if(one.getResult2().intValue()!=0){
                map = new HashMap<>();
                if ("0".equals(type)) {
                    map.put("dateNo", dateFormat.format(one.getQuotaDate()));
                } else {
                    map.put("weekOfMonth", DateUtil.getWeekOfMonth(dateFormat.format(one.getQuotaDate())));
                }
                map.put("followupCount", one.getResult2().longValue());
                totalList.add(map);
            }
            map.put("followupCount", one.getResult2().longValue());
            totalList.add(map);
        }
        return null;
        List<Map<String, Object>> planList = new ArrayList<>();
        for (SaveModel one : list2) {
            if (one.getResult2().intValue()!=0){
                map = new HashMap<>();
                if ("0".equals(type)) {
                    map.put("dateNo", dateFormat.format(one.getQuotaDate()));
                } else {
                    map.put("weekOfMonth", DateUtil.getWeekOfMonth(dateFormat.format(one.getQuotaDate())));
                }
                map.put("planCount", one.getResult2().longValue());
                planList.add(map);
            }
        }
        JSONObject result = new JSONObject();
        result.put("planList", planList);
        result.put("totalList", totalList);
        return result;
    }
    /**
@ -3018,19 +3106,21 @@ public class StatisticsESService {
        startDate = elasticsearchUtil.changeTime(startDate + " 00:00:00");
        endDate = elasticsearchUtil.changeTime(endDate + " 23:59:59");
        Integer interval = Integer.parseInt(type) + 2;
        List<SaveModel> list = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, teamCode, Integer.parseInt(SaveModel.teamLevel), "27", "2", interval + "");
        Integer interval = Integer.parseInt(type) + 1;
        List<SaveModel> list = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, teamCode, Integer.parseInt(SaveModel.teamLevel), "27", SaveModel.timeLevel_ZL, interval + "");
        Map<String, Object> map = null;
        List<Map<String, Object>> totalList = new ArrayList<>();
        for (SaveModel one : list) {
            map = new HashMap<>();
            if ("0".equals(type)) {
                map.put("dateNo", dateFormat.format(one.getQuotaDate()));
            } else {
                map.put("weekOfMonth", DateUtil.getWeekOfMonth(dateFormat.format(one.getQuotaDate())));
            if (one.getResult2().intValue()!=0){
                map = new HashMap<>();
                if ("0".equals(type)) {
                    map.put("dateNo", dateFormat.format(one.getQuotaDate()));
                } else {
                    map.put("weekOfMonth", DateUtil.getWeekOfMonth(dateFormat.format(one.getQuotaDate())));
                }
                map.put("reservationCount", one.getResult2().longValue());
                totalList.add(map);
            }
            map.put("reservationCount", one.getResult2().longValue());
            totalList.add(map);
        }
        return new JSONArray(totalList);
    }
@ -3196,19 +3286,21 @@ public class StatisticsESService {
        startDate = elasticsearchUtil.changeTime(startDate + " 00:00:00");
        endDate = elasticsearchUtil.changeTime(endDate + " 23:59:59");
        Integer interval = Integer.parseInt(type) + 2;
        List<SaveModel> list = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, teamCode, Integer.parseInt(SaveModel.teamLevel), "5", "2", interval + "");
        Integer interval = Integer.parseInt(type) + 1;
        List<SaveModel> list = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, teamCode, Integer.parseInt(SaveModel.teamLevel), "5", SaveModel.timeLevel_ZL, interval + "");
        Map<String, Object> map = null;
        List<Map<String, Object>> totalList = new ArrayList<>();
        for (SaveModel one : list) {
            map = new HashMap<>();
            if ("0".equals(type)) {
                map.put("dateNo", dateFormat.format(one.getQuotaDate()));
            } else {
                map.put("weekOfMonth", DateUtil.getWeekOfMonth(dateFormat.format(one.getQuotaDate())));
            if (one.getResult2().intValue()!=0){
                map = new HashMap<>();
                if ("0".equals(type)) {
                    map.put("dateNo", dateFormat.format(one.getQuotaDate()));
                } else {
                    map.put("weekOfMonth", DateUtil.getWeekOfMonth(dateFormat.format(one.getQuotaDate())));
                }
                map.put("guidanceCount", one.getResult2().longValue());
                totalList.add(map);
            }
            map.put("guidanceCount", one.getResult2().longValue());
            totalList.add(map);
        }
        return new JSONArray(totalList);
    }
@ -3331,6 +3423,10 @@ public class StatisticsESService {
                }
            }
        }
        //团队翻译
        if(SaveModel.teamLevel.equals(lowlevel)){
            translateTeamLeaderName(rs);
        }
        Collections.sort(rs, new Comparator<Map<String, Object>>() {
            public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                Integer map1value = Integer.valueOf(String.valueOf(o1.get("val")));
@ -4088,4 +4184,6 @@ public class StatisticsESService {
        resultJSON.put("rs", json);
        return resultJSON;
    }
}

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

@ -314,7 +314,7 @@ public class SignPatientLabelInfoController extends BaseController {
                return write(200, "查询成功", "data", r);
            }
            JSONArray result = labelInfoService.getPatientAmountByLabelType(getUID(), labelType, teamCode);
            JSONArray result = labelInfoService.getPatientAmountByLabelType(getUID(), labelType, teamCode,isSlowDisease,diseaseCondition);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {

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

@ -805,7 +805,7 @@ public class ConsultController extends WeixinBaseController {
                    failed.add(String.valueOf(resObj.get("data")));
                    try {
                        //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                        Doctor doctor = doctorDao.findByCode(log.getDoctor());
                        Doctor doctor = doctorDao.findByCode(consultModel.getDoctor());
                        String doctorOpenID = doctor.getOpenid();
                        if (StringUtils.isNotEmpty(doctorOpenID)) {
                                String title = "";
@ -825,7 +825,7 @@ public class ConsultController extends WeixinBaseController {
                                    params.add(new BasicNameValuePair("url", targetUrl));
                                    params.add(new BasicNameValuePair("first",  first));
                                    params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                                    String keywords = title + "," + content +","+ log.getDoctorName();
                                    String keywords = title + "," + content +","+ doctor.getName();
                                    params.add(new BasicNameValuePair("keywords", keywords));
                                    httpClientUtil.post(url, params, "UTF-8");

+ 5 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java

@ -186,6 +186,7 @@ public class PatientDeviceController extends BaseController {
            return success("设备保存成功!");
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
@ -208,6 +209,7 @@ public class PatientDeviceController extends BaseController {
            return write(200, "查询成功", "data", list);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
@ -228,6 +230,7 @@ public class PatientDeviceController extends BaseController {
            mapList.put("device", device);
            return write(200, "查询成功", "data", mapList);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
@ -247,6 +250,7 @@ public class PatientDeviceController extends BaseController {
            List<Map<String, String>> list = patientDeviceService.getDeviceUser(getRepUID(), deviceSn, type);
            return write(200, "获取设备绑定信息成功!", "data", list);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
@ -274,6 +278,7 @@ public class PatientDeviceController extends BaseController {
                return error(-1, "不存在该设备!");
            }
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }

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

@ -222,6 +222,7 @@ public class HealthEduArticleController extends BaseController {
    @RequestMapping(value = "getDoctorArticalByUserId",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取医生发表的文章列表")
    @ResponseBody
    public String getDoctorArticalByUserId(@ApiParam(name = "doctorCode", value = "医生code")
                                           @RequestParam(value = "doctorCode", required = true) String doctorCode,
                                           @ApiParam(name = "articleTitle", value = "文章标题")

+ 19 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java

@ -81,6 +81,19 @@ public class FamilyContractController extends BaseController {
        }
    }
    @RequestMapping(value = "getSignDoctors")
    @ResponseBody
    @ApiOperation("获取签约医生")
    public String getSignDoctors(){
        try {
            com.alibaba.fastjson.JSONArray array = familyContractService.getSignDoctors(getRepUID());
            return write(200, "获取列表成功!", "list", array);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取列表失败!");
        }
    }
    @RequestMapping(value = "getSignMessageOverdue")
    @ResponseBody
    @ApiOperation("")
@ -227,9 +240,13 @@ public class FamilyContractController extends BaseController {
    @ResponseBody
    @ApiOperation("集美家签医生主页")
    public String jimeiHomepage(@ApiParam(name = "doctor", value = "医生编码")
                                @RequestParam(value = "doctor", required = true) String doctor){
                                @RequestParam(value = "doctor", required = true) String doctor,
                                @ApiParam(name = "pageIndex", value = "起始页数 0开始,默认0")
                                @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
                                @ApiParam(name = "pageSize", value = "每页显示数 ,默认5")
                                @RequestParam(value = "pageSize", required = false) Integer pageSize){
        try{
            JSONObject json = familyContractService.findJiMeiDoctorMainPage(getRepUID(), doctor);
            JSONObject json = familyContractService.findJiMeiDoctorMainPage(getRepUID(), doctor,pageIndex,pageSize);
            return write(200, "医生主页查询成功!", "data", json);
        }catch (Exception e){
            error(e);

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

@ -29,10 +29,10 @@ import java.util.Map;
import java.util.TreeMap;
/**
 * Created by chenweida on 2017/10/13.
 * Created by chenweida on 2017/10/13
 */
@Controller
@RequestMapping(value = "/statistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = {RequestMethod.GET, RequestMethod.POST})
@RequestMapping(value = "/esstatistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = {RequestMethod.GET, RequestMethod.POST})
@Api(description = "ES统计查询")
public class EsStatisticsController extends BaseController {
@ -164,8 +164,12 @@ public class EsStatisticsController extends BaseController {
            JSONObject result = new JSONObject();
            for (String idx : indexes) {
//                result.put("index_" + idx, statisticsService.getTotalAmount(startDate, endDate, area, level, idx, level2_type));
                result.put("index_" + idx, statisticsESService.getTotalAmount(startDate, endDate, area, level, idx, level2_type));
                if("3".equals(idx)){
                    //为了确保之前是咨询量是准确的 所以咨询量用到达量不用增量累加
                    result.put("index_" + idx, statisticsESService.getTotalAmount3(startDate, endDate, area, level, idx, level2_type));
                }else{
                    result.put("index_" + idx, statisticsESService.getTotalAmount(startDate, endDate, area, level, idx, level2_type));
                }
            }
            return write(200, "查询成功", "data", result);
@ -650,12 +654,16 @@ public class EsStatisticsController extends BaseController {
     * ②未回复数(数、率)----------当前未回复咨询数、以及相应比例
     * ③处理咨询回复时间分布---------全部咨询的首次回复咨询时间分布
     *
     * 备注:注解为Deprecated是因为前端代码全局搜索没有,并且本地代码没有调用该方法
     * 视为无效(2017-11-21)
     *
     * @param level 查询的等级,按市、区、机构
     * @param area  查询的等级对应Code
     * @return
     */
    @RequestMapping("/Consulting_Stat")
    @ResponseBody
    @Deprecated
    public String getConsultingStatistics(@RequestParam(required = true) Integer level,
                                          @RequestParam(required = true) String area) {
@ -766,11 +774,13 @@ public class EsStatisticsController extends BaseController {
     * 获取绑定率
     * 1、选定绑定微信指标,下面排行内,在绑定微信数后新增:"绑定率:xx.22%"
     * 2、绑定率=绑定数/已签约数
     *
     *备注:注解为Deprecated是因为前端代码全局搜索没有,并且本地代码没有调用该方法
     * 视为无效(2017-11-21)
     * @return
     */
    @RequestMapping("/bindingRate_stat")
    @ResponseBody
    @Deprecated
    public String getBindingRate() {
        try {
            return write(200, "查询成功", "data", statisticsESService.getBindingRate());
@ -1050,7 +1060,7 @@ public class EsStatisticsController extends BaseController {
    }
    /**
     * 获取团队随访量折线统计图(弃用)
     * 获取团队随访量折线统计图
     *
     * @param type
     * @param teamCode
@ -1065,7 +1075,7 @@ public class EsStatisticsController extends BaseController {
                                      @RequestParam(required = true) String startDate,
                                      @RequestParam(required = true) String endDate) {
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamFollowupLine(teamCode, startDate, endDate, type));
            return write(200, "查询成功", "data", statisticsESService.getTeamFollowupLine(teamCode, startDate, endDate, type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
@ -1343,7 +1353,7 @@ public class EsStatisticsController extends BaseController {
                                 @RequestParam(required = true) String endDate,
                                 @RequestParam(required = true) String type) {
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamEduLine(teamCode, startDate, endDate, type));
            return write(200, "查询成功", "data", statisticsESService.getTeamEduLine(teamCode, startDate, endDate, type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
@ -1446,8 +1456,14 @@ public class EsStatisticsController extends BaseController {
        }
    }
    /**
     * 备注:注解为Deprecated是因为前端代码全局搜索没有,并且本地代码没有调用该方法
     * 视为无效(2017-11-21).
     * @return
     */
    @RequestMapping("/cleanDoctorScore")
    @ResponseBody
    @Deprecated
    public String cleanDoctorScore() {
        try {
            return write(200, "清洗完成", "data", statisticsAllService.cleanDoctorScore());

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

@ -26,10 +26,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
import java.util.*;
/**
 * Created by lyr on 2016/08/16.
 * Created by lyr on 2016/08/16
 */
@Controller
@RequestMapping(value = "/oldstatistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,method = {RequestMethod.GET,RequestMethod.POST})
@RequestMapping(value = "/statistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,method = {RequestMethod.GET,RequestMethod.POST})
@Api(description = "统计")
public class StatisticsController extends BaseController {

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

@ -3,11 +3,11 @@ spring:
  profiles: prod
  datasource:
    wlyy:
      url: jdbc:mysql://59.61.92.90:8079/wlyy?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      url: jdbc:mysql://59.61.92.90:9069/wlyy?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      username: wlyy
      password: jkzlehr@123
    health:
      url: jdbc:mysql://59.61.92.90:8079/device?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      url: jdbc:mysql://59.61.92.90:9069/device?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      username: wlyy
      password: jkzlehr@123