소스 검색

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

yeshijie 7 년 전
부모
커밋
bb41d88759
31개의 변경된 파일1456개의 추가작업 그리고 184개의 파일을 삭제
  1. 18 15
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java
  2. 3 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionLog.java
  3. 69 2
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/medicine/PhysicalExaminationController.java
  4. 88 0
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/dao/PatientDao.java
  5. 425 0
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/entity/Patient.java
  6. 27 0
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/PatientService.java
  7. 16 0
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/PhysicalExaminationService.java
  8. 127 0
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/util/HttpClientUtil.java
  9. 1 0
      patient-co-customization/patient-co-modern-medicine/src/main/resources/application.yml
  10. 62 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/config/RepositoryMedicineConfig.java
  11. 12 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/common/account/CustomerController.java
  12. 15 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/yueren/YueRenController.java
  13. 16 7
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/Doctor.java
  14. 44 6
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/Patient.java
  15. 10 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/SignFamily.java
  16. 5 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/filter/SessionOutTimeFilter.java
  17. 69 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/medicine/entity/WlyyMedicineKey.java
  18. 11 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/medicine/repository/WlyyMedicineKeyDao.java
  19. 20 27
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/account/CustomerService.java
  20. 49 73
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/family/FamilyMemberService.java
  21. 31 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/medicine/WlyyMedicineKeyService.java
  22. 205 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/query/BasemedicineJpaService.java
  23. 26 0
      patient-co-manage/wlyy-manage/src/main/resources/application.yml
  24. 4 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDispensaryCodeDao.java
  25. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionLogDao.java
  26. 34 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  27. 3 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionLogService.java
  28. 26 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java
  29. 19 22
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionLogController.java
  30. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionController.java
  31. 18 17
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionLogController.java

+ 18 - 15
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java

@ -348,21 +348,6 @@ public class Prescription extends IdEntity {
        this.prescriptionType = prescriptionType;
        this.prescriptionType = prescriptionType;
    }
    }
    @Transient
    public String getTypeName() {
        switch (type) {
            case 1: {
                return "自取";
            }
            case 2: {
                return "快递配送";
            }
            case 3: {
                return "健管师配送";
            }
        }
        return "";
    }
    @Transient
    @Transient
    public String getStatusName() {
    public String getStatusName() {
@ -612,4 +597,22 @@ public class Prescription extends IdEntity {
    public void setJwHospital(String jwHospital) {
    public void setJwHospital(String jwHospital) {
        this.jwHospital = jwHospital;
        this.jwHospital = jwHospital;
    }
    }
    @Transient
    public String getDispensaryTypeName() {
        switch (type) {
            case 1: {
                return "自取";
            }
            case 2: {
                return "快递配送";
            }
            case 3: {
                return "健管师配送";
            }
        }
        return "";
    }
}
}

+ 3 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionLog.java

@ -16,6 +16,9 @@ import java.util.Date;
@Entity
@Entity
@Table(name = "wlyy_prescription_log")
@Table(name = "wlyy_prescription_log")
public class PrescriptionLog extends IdEntity {
public class PrescriptionLog extends IdEntity {
    public enum PrescriptionLogType {
    public enum PrescriptionLogType {
        zy("智业对接", 1),
        zy("智业对接", 1),
        ylz("易联众对接", 2),
        ylz("易联众对接", 2),

+ 69 - 2
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/medicine/PhysicalExaminationController.java

@ -1,7 +1,13 @@
package com.yihu.mm.controller.medicine;
package com.yihu.mm.controller.medicine;
import com.yihu.mm.controller.BaseController;
import com.yihu.mm.controller.BaseController;
import com.yihu.mm.entity.Patient;
import com.yihu.mm.service.PatientService;
import com.yihu.mm.service.PhysicalExaminationService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseBody;
@ -11,9 +17,70 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping(value = "/medicine/physicalExamination")
@RequestMapping(value = "/medicine/physicalExamination")
public class PhysicalExaminationController extends BaseController {
public class PhysicalExaminationController extends BaseController {
    @RequestMapping(value = "/findTest",produces="application/json;charset=UTF-8")
    @Value("${examCode}")
    private String examCode;
    @Autowired
    private PatientService patientService;
    @Autowired
    private PhysicalExaminationService physicalExaminationService;
    @ApiOperation(value = "获取试卷列表")
    @RequestMapping(value = "/findExames",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String findExames(@ApiParam(name = "tp_type", value = "'问卷类型',(备选值:1,2,4)1:初筛问卷,2:助理问卷,4:现场问卷", required = true)@RequestParam(required = false, name = "tp_type") String tp_type) {
        physicalExaminationService.findExames(tp_type,examCode);
        return null;
    }
    @ApiOperation(value = "新增预约单/获取咨询编号等信息")
    @RequestMapping(value = "/insertslip",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String insertslip(@ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode){
        Patient patient = patientService.findByCode(patientCode);
        return physicalExaminationService.insertslip(patient);
    }
    @ApiOperation(value = "获取试题")
    @RequestMapping(value = "/findExames",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String findQuestion(@ApiParam(name = "tp_id", value = "试卷id", required = true)@RequestParam(required = false, name = "tp_id") String tp_id,
                               @ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = false, name = "pb_id") String pb_id,
                               @ApiParam(name = "pb_id", value = "咨询编号", required = true)@RequestParam(required = false, name = "pb_id") String ct_id){
        return null;
    }
    @ApiOperation(value = "提交试卷答案")
    @RequestMapping(value = "/handleExam",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String handleExam(@ApiParam(name = "tp_id", value = "试卷id", required = true)@RequestParam(required = true, name = "tp_id") String tp_id,
                               @ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
                               @ApiParam(name = "dc_answer", value = "问题答案", required = true)@RequestParam(required = true, name = "dc_answer") String dc_answer,
                             @ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id){
        return null;
    }
    @ApiOperation(value = "四诊资料采集")
    @RequestMapping(value = "/dillphoneimgdata",produces="application/json;charset=UTF-8")
    @ResponseBody
    @ResponseBody
    public String login(@ApiParam(name = "type", value = "账号", required = true)@RequestParam(required = false, name = "type") String type) throws Exception {
    public String dillphoneimgdata(@ApiParam(name = "tp_id", value = "试卷id", required = true)@RequestParam(required = true, name = "tp_id") String tp_id,
                             @ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
                             @ApiParam(name = "dc_answer", value = "问题答案", required = true)@RequestParam(required = true, name = "dc_answer") String dc_answer,
                             @ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id){
        return null;
        return null;
    }
    }
    @ApiOperation(value = "查找报告单")
    @RequestMapping(value = "/findconconhealth",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String findconconhealth(@ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id){
        return null;
    }
}
}

+ 88 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/dao/PatientDao.java

@ -0,0 +1,88 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.mm.dao;
import com.yihu.mm.entity.Patient;
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;
import java.util.List;
public interface PatientDao extends PagingAndSortingRepository<Patient, Long>,JpaSpecificationExecutor<Patient> {
	// 查询患者姓名
	@Query("select p.name from Patient p where p.code=?1")
	String findNameByCode(String code);
    // 根据姓名查询
    @Query("select p.code from Patient p where p.name=?1")
    String[] findByName(String name);
	// 根據患者標識查詢患者信息
	@Query("select p from Patient p where p.code=?1")
	Patient findByCode(String code);
    // 根據患者標識查詢患者信息
    @Query("select p from Patient p where p.code=?1 and p.idcard =?2")
    Patient findByCodeAndIdcard(String code, String idcard);
	// 根據身份證號查詢患者信息
	@Query("select p from Patient p where p.idcard=?1")
	Patient findByIdcard(String idcard);
	@Query("select p from Patient p where p.ssc=?1")
	Patient findBySsc(String ssc);
	// 根據手机号查詢患者信息
	@Query("select p from Patient p where p.mobile=?1")
	Patient findByMobile(String mobile);
	// 根據病情等级获取患者信息
	@Query("select p from Patient p where p.diseaseCondition=?1")
	Iterable<Patient> findInfoByLevel(int level);
	@Query("select p from Patient p where p.openid=?1")
	Patient findByOpenid(String openid);
	@Query("select count(1) from Patient p where p.openid=?1")
	int countByOpenid(String openid);
	//清空openid
	@Modifying
	@Query("update Patient p set p.openid = null where p.code <> ?1 and p.openid = ?2")
	int clearOpenid(String patient, String openid);
    @Modifying
    @Query(value = "update Patient p set p.status=?1 where p.id=?2 ")
    int updateStatus(Integer status, Long id);
    @Modifying
    @Query(value = "update Patient p set p.password=?1,p.salt=?2 where p.id=?3 ")
    int initPassword(String password, String salt, Long id);
    @Query(value = "select count(1) from Patient p where p.mobile = ?1")
    int isMobileExist(String mobile);
    @Query(value = "select count(1) from Patient p where p.idcard = ?1")
    int isIdCardExist(String idcard);
    @Query(value = "select count(1) from Patient p where p.ssc = ?1")
    int isSscExist(String ssc);
	@Query("select p from Patient p where p.city = ?1 and p.mobile is not null and p.mobile!='' ")
	List<Patient> findByCity(String city);
	@Query("select p from Patient p where p.city = ?1 and p.mobile is not null and p.mobile!=''  and p.town in ?2 ")
	List<Patient> findByCityAndTowns(String city, String towns[]);
	@Query(value = "SELECT DISTINCT p.* from wlyy_patient p LEFT JOIN wlyy_sign_family f on p.code = f.patient WHERE p.city = ?1 and p.mobile is not null and p.mobile!=''  and f.hospital in ?2 ",nativeQuery = true)
	List<Patient> findByCityAndHospital(String city, String hospital[]);
	@Query("select p from Patient p where p.idcard=?1 and p.ssc=?2")
	Patient findByIdcardAndSsc(String idcard, String ssc);
}

+ 425 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/entity/Patient.java

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

+ 27 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/PatientService.java

@ -0,0 +1,27 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.mm.service;
import com.yihu.mm.dao.PatientDao;
import com.yihu.mm.entity.Patient;
import org.springframework.stereotype.Service;
/**
 * 患者基本信息类.
 *
 * @author George
 */
@Service
public class PatientService {
    private PatientDao patientDao;
    public Patient findByCode(String code) {
        return patientDao.findByCode(code);
    }
}

+ 16 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/PhysicalExaminationService.java

@ -1,4 +1,20 @@
package com.yihu.mm.service;
package com.yihu.mm.service;
import com.yihu.mm.entity.Patient;
import org.springframework.stereotype.Service;
@Service
public class PhysicalExaminationService {
public class PhysicalExaminationService {
    public void findExames(String type, String examCode) {
    }
    public String insertslip(Patient patient) {
        return null;
    }
}
}

+ 127 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/util/HttpClientUtil.java

@ -0,0 +1,127 @@
package com.yihu.mm.util;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
public class HttpClientUtil {
	/**
	 * 发送post请求
	 * @param url 请求地址
	 * @param params 请求参数
	 * @param chatSet 编码格式
	 * @return
	 */
	public static String post(String url, List<NameValuePair> params, String chatSet) {
		// 创建默认的httpClient实例.
		CloseableHttpClient httpclient = HttpClients.createDefault();
		// 创建httppost
		HttpPost httppost = new HttpPost(url);
		UrlEncodedFormEntity uefEntity;
		try {
			uefEntity = new UrlEncodedFormEntity(params, chatSet);
			httppost.setEntity(uefEntity);
			CloseableHttpResponse response = httpclient.execute(httppost);
			try {
				HttpEntity entity = response.getEntity();
				if (entity != null) {
					return EntityUtils.toString(entity, chatSet);
				}
			} finally {
				response.close();
			}
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e1) {
			e1.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			// 关闭连接,释放资源
			try {
				httpclient.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
	/**
	 * 发送get请求
	 * @param url 请求地址
	 * @param chatSet 编码格式
	 * @return
	 */
	public static String get(String url, String chatSet) {
		CloseableHttpClient httpclient = HttpClients.createDefault();
		try {
			// 创建httpget.
			HttpGet httpget = new HttpGet(url);
			// 执行get请求.
			CloseableHttpResponse response = httpclient.execute(httpget);
			try {
				// 获取响应实体
				HttpEntity entity = response.getEntity();
				if (entity != null) {
					return EntityUtils.toString(entity, chatSet);
				}
			} finally {
				response.close();
			}
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (ParseException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			// 关闭连接,释放资源
			try {
				httpclient.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
	public static String postBody(String url,JSONObject params){
		RestTemplate restTemplate = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
		headers.setContentType(type);
		headers.add("Accept", MediaType.APPLICATION_JSON.toString());
		org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params.toString(), headers);
		String ret = restTemplate.postForObject(url, formEntity, String.class);
		return ret;
	}
	public static void putBody(String url,JSONObject params){
		RestTemplate restTemplate = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
		headers.setContentType(type);
		headers.add("Accept", MediaType.APPLICATION_JSON.toString());
		org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params.toString(), headers);
		restTemplate.put(url, formEntity, String.class);
	}
}

+ 1 - 0
patient-co-customization/patient-co-modern-medicine/src/main/resources/application.yml

@ -1,6 +1,7 @@
server:
server:
  port: 8080
  port: 8080
examCode:         #越人试卷题目code
security:
security:
  basic:
  basic:

+ 62 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/config/RepositoryMedicineConfig.java

@ -0,0 +1,62 @@
package com.yihu.wlyy.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManager;
import javax.sql.DataSource;
import java.util.Map;
/**
 * Created by Administrator on 2017/08/14.
 * medicine数据库jpa支持配置
 */
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
        entityManagerFactoryRef="entityManagerFactoryMedicine",
        transactionManagerRef="transactionManagerMedicine",
        basePackages= { "com.yihu.wlyy.medicine.repository" })
public class RepositoryMedicineConfig {
    @Autowired
    private JpaProperties jpaProperties;
    @Autowired
    @Qualifier("deviceDataSource")
    private DataSource deviceDataSource;
    @Bean(name = "entityManagerMedicine")
    public EntityManager entityManager(EntityManagerFactoryBuilder builder) {
        return entityManagerFactory(builder).getObject().createEntityManager();
    }
    @Bean(name = "entityManagerFactoryMedicine")
    public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder) {
        return builder
                .dataSource(deviceDataSource)
                .properties(getVendorProperties(deviceDataSource))
                .packages("com.yihu.wlyy.medicine.entity")
                .persistenceUnit("threeTimePersistenceUnit")
                .build();
    }
    private Map<String, String> getVendorProperties(DataSource dataSource) {
        return jpaProperties.getHibernateProperties(dataSource);
    }
    @Bean(name = "transactionManagerMedicine")
    PlatformTransactionManager transactionManager(EntityManagerFactoryBuilder builder) {
        return new JpaTransactionManager(entityManagerFactory(builder).getObject());
    }
}

+ 12 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/common/account/CustomerController.java

@ -62,10 +62,22 @@ public class CustomerController extends BaseController {
            req.getSession().setAttribute("code",curUser.getCode());
            req.getSession().setAttribute("code",curUser.getCode());
            req.getSession().setAttribute("name",curUser.getName());
            req.getSession().setAttribute("name",curUser.getName());
            req.getSession().setAttribute("isLogin", "true");
            req.getSession().setAttribute("isLogin", "true");
            req.getSession().setMaxInactiveInterval(-1);//设置session用不过期
            return write(1,"登入成功","user",curUser);
            return write(1,"登入成功","user",curUser);
        }
        }
    }
    }
    @RequestMapping(value = "/logout",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String logout(HttpServletRequest req) throws Exception {
        req.getSession().removeAttribute("userInfo");
        req.getSession().removeAttribute("mobile");
        req.getSession().removeAttribute("code");
        req.getSession().removeAttribute("name");
        req.getSession().removeAttribute("isLogin");
        return write(1,"退出成功");
    }
    /**
    /**
     *通过社保卡号或者身份证查找服务对象
     *通过社保卡号或者身份证查找服务对象
     * @return
     * @return

+ 15 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/yueren/YueRenController.java

@ -1,10 +1,11 @@
package com.yihu.wlyy.controller.manager.yueren;
package com.yihu.wlyy.controller.manager.yueren;
import com.google.gson.Gson;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.service.manager.medicine.WlyyMedicineKeyService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import org.json.JSONObject;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -25,6 +26,8 @@ public class YueRenController extends BaseController {
    @Value("${yueren.api}")
    @Value("${yueren.api}")
    private String api;
    private String api;
    @Autowired
    private WlyyMedicineKeyService wlyyMedicineKeyService;
    //--预约模块 begin
    //--预约模块 begin
    /**
    /**
     * 获取每个接口需要传递的key值
     * 获取每个接口需要传递的key值
@ -34,6 +37,13 @@ public class YueRenController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String getPhoneKey() {
    public String getPhoneKey() {
        String postStr = remoteCall("/yueren/phonekey", new JSONObject());
        String postStr = remoteCall("/yueren/phonekey", new JSONObject());
        JSONObject jsonObject = new JSONObject(postStr);
        String status = jsonObject.get("status").toString();
        if ("200".equals(status)) {
            JSONObject recordset = jsonObject.getJSONObject("recordset");
            String key = recordset.getString("key");
            this.saveKey(key);
        }
        return postStr;
        return postStr;
    }
    }
@ -276,4 +286,8 @@ public class YueRenController extends BaseController {
            return "{\"status\":500,\"exception\":\"连接出错\"}";
            return "{\"status\":500,\"exception\":\"连接出错\"}";
        }
        }
    }
    }
    public void saveKey(String key) {
        wlyyMedicineKeyService.saveKey(key);
    }
}
}

+ 16 - 7
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/Doctor.java

@ -1,17 +1,16 @@
package com.yihu.wlyy.entity;
package com.yihu.wlyy.entity;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import javax.persistence.Column;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.Transient;
import org.apache.commons.lang3.builder.ToStringBuilder;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
/**
 * 医生信息
 * 医生信息
@ -363,6 +362,16 @@ public class Doctor extends IdEntity {
    @Transient
    @Transient
    public String getLevelName() {
    public String getLevelName() {
		// 类型:1专科医生,2全科医生,3健康管理师
		if(1==level){
			levelName = "专科医生";
		}else if(2==level){
			levelName = "全科医生";
		}else if(level==3){
			levelName = "健康管理所";
		}else{
			levelName = "";
		}
        return levelName;
        return levelName;
    }
    }

+ 44 - 6
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/Patient.java

@ -1,15 +1,13 @@
package com.yihu.wlyy.entity;
package com.yihu.wlyy.entity;
import java.io.Serializable;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.persistence.Column;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Table;
import org.apache.commons.lang3.builder.ToStringBuilder;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
/**
/**
 * 患者信息
 * 患者信息
@ -66,8 +64,10 @@ public class Patient extends IdEntity implements Serializable {
	private String address;
	private String address;
	// 疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病
	// 疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病
	private Integer disease;
	private Integer disease;
	private String diseaseName;
	// 病情:0绿标,1黄标,2红标
	// 病情:0绿标,1黄标,2红标
	private Integer diseaseCondition;
	private Integer diseaseCondition;
	private String diseaseConditionName;
	// 病历记录总数
	// 病历记录总数
	private Integer recordAmount;
	private Integer recordAmount;
	// 總積分
	// 總積分
@ -324,4 +324,42 @@ public class Patient extends IdEntity implements Serializable {
    public void setMobileRemarks(String mobileRemarks) {
    public void setMobileRemarks(String mobileRemarks) {
        this.mobileRemarks = mobileRemarks;
        this.mobileRemarks = mobileRemarks;
    }
    }
    @Transient
	public String getDiseaseName() {//0健康,1高血压,2糖尿病,3高血压+糖尿病
		if(0==disease) {
			this.diseaseName = "健康";
		}else if(1==disease) {
			this.diseaseName = "高血压";
		}else if(2==disease) {
			this.diseaseName = "糖尿病";
		}else if(3==disease) {
			this.diseaseName = "高血压+糖尿病";
		}else{
			this.diseaseName = "";
		}
		return diseaseName;
	}
	public void setDiseaseName(String diseaseName) {
		this.diseaseName = diseaseName;
	}
	@Transient
	public String getDiseaseConditionName() {
		if(0==diseaseCondition) {
			this.diseaseConditionName = "绿标";
		}else if(1==diseaseCondition) {
			this.diseaseConditionName = "黄标";
		}else if(2==diseaseCondition) {
			this.diseaseConditionName = "红标";
		}else{
			this.diseaseConditionName = "";
		}
		return diseaseConditionName;
	}
	public void setDiseaseConditionName(String diseaseConditionName) {
		this.diseaseConditionName = diseaseConditionName;
	}
}
}

+ 10 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/SignFamily.java

@ -39,6 +39,7 @@ public class SignFamily extends IdEntity {
    private Date begin;         // 签约开始日期
    private Date begin;         // 签约开始日期
    private Date end;           // 签约结束日期
    private Date end;           // 签约结束日期
    private Integer status;     // 签约状态(-1患者已取消,-2已拒绝,-3已解约,-4已到期,0待签约,1已签约,2患者申请取消签约
    private Integer status;     // 签约状态(-1患者已取消,-2已拒绝,-3已解约,-4已到期,0待签约,1已签约,2患者申请取消签约
    private String statusName;
    private String images;      // 签约图片附件URL,多图以逗号分隔
    private String images;      // 签约图片附件URL,多图以逗号分隔
    private String reason;      // 解约原因
    private String reason;      // 解约原因
    private Date czrq;          // 操作时间
    private Date czrq;          // 操作时间
@ -502,4 +503,13 @@ public class SignFamily extends IdEntity {
    public void setReleaseSpeak(String releaseSpeak) {
    public void setReleaseSpeak(String releaseSpeak) {
        this.releaseSpeak = releaseSpeak;
        this.releaseSpeak = releaseSpeak;
    }
    }
    @Transient
    public String getStatusName() {
        return statusName;
    }
    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }
}
}

+ 5 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/filter/SessionOutTimeFilter.java

@ -32,6 +32,11 @@ public class SessionOutTimeFilter extends OncePerRequestFilter {
        Object isLogin = httpServletRequest.getSession().getAttribute("isLogin");
        Object isLogin = httpServletRequest.getSession().getAttribute("isLogin");
        if (isLogin == null || (String) isLogin != "true") {
        if (isLogin == null || (String) isLogin != "true") {
//            request.setAttribute(FormAuthenticationFilter.DEFAULT_ERROR_KEY_ATTRIBUTE_NAME,"请重新登入");
//            request.setAttribute(FormAuthenticationFilter.DEFAULT_ERROR_KEY_ATTRIBUTE_NAME,"请重新登入");
            if(path.indexOf("customer")>-1){
                httpServletResponse.getOutputStream().write("{\"code\":-200}".getBytes());//-200   客服未登录
                return ;
            }
            httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + "/login");
            httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + "/login");
            return;
            return;
        }
        }

+ 69 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/medicine/entity/WlyyMedicineKey.java

@ -0,0 +1,69 @@
package com.yihu.wlyy.medicine.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
 * Created by Administrator on 2017/8/14.
 */
@Entity
@Table(name = "wlyy_medicine_key", schema = "", catalog = "medicine")
public class WlyyMedicineKey implements Serializable {
    private Long id;
    private String accessKey;
    private Long addTimestamp;
    private Long expiresIn;
    private Date creataTime;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    @Column(name = "access_key", nullable = false)
    public String getAccessKey() {
        return accessKey;
    }
    public void setAccessKey(String accessKey) {
        this.accessKey = accessKey;
    }
    @Column(name = "add_timestamp", nullable = false)
    public Long getAddTimestamp() {
        return addTimestamp;
    }
    public void setAddTimestamp(Long addTimestamp) {
        this.addTimestamp = addTimestamp;
    }
    @Column(name = "expires_in", nullable = false)
    public Long getExpiresIn() {
        return expiresIn;
    }
    public void setExpiresIn(Long expiresIn) {
        this.expiresIn = expiresIn;
    }
    @Column(name = "creata_time", nullable = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreataTime() {
        return creataTime;
    }
    public void setCreataTime(Date creataTime) {
        this.creataTime = creataTime;
    }
}

+ 11 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/medicine/repository/WlyyMedicineKeyDao.java

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

+ 20 - 27
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/account/CustomerService.java

@ -5,14 +5,15 @@ import com.yihu.wlyy.entity.Patient;
import com.yihu.wlyy.entity.SignFamily;
import com.yihu.wlyy.entity.SignFamily;
import com.yihu.wlyy.service.manager.family.FamilyMemberService;
import com.yihu.wlyy.service.manager.family.FamilyMemberService;
import com.yihu.wlyy.service.manager.hos.HosDoctorService;
import com.yihu.wlyy.service.manager.hos.HosDoctorService;
import com.yihu.wlyy.service.manager.sign.SignFamilyService;
import com.yihu.wlyy.service.manager.sign.FamilyContractService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Service
public class CustomerService{
public class CustomerService{
@ -20,45 +21,37 @@ public class CustomerService{
	@Autowired
	@Autowired
	private FamilyMemberService familyMemberService;
	private FamilyMemberService familyMemberService;
	@Autowired
	@Autowired
	private SignFamilyService signFamilyService;
	private FamilyContractService contractService;
	@Autowired
	@Autowired
	private HosDoctorService hosDoctorService;
	private HosDoctorService hosDoctorService;
	public Map<String,Object> findServerInfo(Patient patient) throws Exception {
	public Map<String,Object> findServerInfo(Patient patient) throws Exception {
		Map<String, Object> resp = new HashMap<>();
		Map<String, Object> resp = new HashMap<>();
		//查找家庭成员关系
		//查找家庭成员关系
		JSONArray familyMembers = familyMemberService.getAllFamilyMembers(patient.getCode());
		resp.put("family",familyMembers.toString());
		List<Map<String, Object>> familyMembers = familyMemberService.getAllFamilyMembers(patient.getCode());
		resp.put("family",familyMembers);
		//查询签约信息
		SignFamily signInfo = contractService.findSignByPatient(patient.getCode());
		if(signInfo!=null){
			signInfo.setStatusName("已签约");
		}
		//查询家庭成员的每个签约信息    以及签约医生
		//查询家庭成员的每个签约信息    以及签约医生
		List signFamilys = new ArrayList<SignFamily>();
		List doctors = new ArrayList<Doctor>();
		List doctors = new ArrayList<Doctor>();
		Iterator<Object> familyMember = familyMembers.iterator();
		while (familyMember.hasNext()) {
			JSONObject jsonObjectbject = (JSONObject) familyMember.next();
			String code = jsonObjectbject.getString("code");//居民code
			SignFamily signFamily = signFamilyService.findByPatientCode(code);
			if(signFamily!=null){
				signFamilys.add(signFamily);
			}
		for(Map<String, Object> familyMember:familyMembers) {
			//查找签约的医生信息
			//查找签约的医生信息
			if(jsonObjectbject.has("doctor")){
				String doctor = jsonObjectbject.getString("doctor");//医生code
				if(StringUtils.isNotBlank(doctor)){
					Doctor doctorInfo = hosDoctorService.getDoctorByCode(doctor);
					if(null!=doctorInfo){
						doctors.add(doctorInfo);
					}
			String doctor = (String) familyMember.get("doctor");//医生code
			if(StringUtils.isNotBlank(doctor)){
				Doctor doctorInfo = hosDoctorService.getDoctorByCode(doctor);
				if(null!=doctorInfo){
					doctors.add(doctorInfo);
				}
				}
			}
			}
		}
		}
		resp.put("signFamilys",signFamilys);
		resp.put("signInfo",signInfo);
		resp.put("doctors",doctors);
		resp.put("doctors",doctors);
		//查找签约医生
		return resp;
		return resp;
	}
	}
}
}

+ 49 - 73
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/family/FamilyMemberService.java

@ -9,12 +9,12 @@ import com.yihu.wlyy.service.manager.sign.FamilyContractService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.CommonUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashMap;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
@ -54,15 +54,14 @@ public class FamilyMemberService extends BaseService {
    }
    }
    /**
    /**
     * 获取所有家庭成员,包括自己
     * 获取所有家庭成员,包括自己
     * @param patient
     * @param patient
     * @return
     * @return
     */
     */
    public JSONArray getAllFamilyMembers(String patient){
        JSONArray resultArray = new JSONArray();
        resultArray.put(getPatient(patient));
    public List<Map<String,Object>> getAllFamilyMembers(String patient){
        List<Map<String,Object>> list = new ArrayList<>();
        list.add(getPatient(patient));
        String sql = "select * " +
        String sql = "select * " +
                " from " +
                " from " +
@ -78,105 +77,82 @@ public class FamilyMemberService extends BaseService {
        if (result != null && result.size() > 0) {
        if (result != null && result.size() > 0) {
            JSONArray tem = new JSONArray();//存储其他
            JSONArray tem = new JSONArray();//存储其他
            for (Map<String, Object> map : result) {
            for (Map<String, Object> map : result) {
                JSONObject obj = new JSONObject();
                Map<String,Object> map1 = new HashMap();
                SignFamily sign = contractService.findSignByPatient(map.get("code").toString());
                SignFamily sign = contractService.findSignByPatient(map.get("code").toString());
                boolean ssSign = false;
                boolean ssSign = false;
                boolean jtSign = false;
                boolean jtSign = false;
                map.put("statusName","未签约");
                if(sign!=null){
                if(sign!=null){
                    if (sign.getType() == 1 ) {
                    if (sign.getType() == 1 ) {
                        ssSign = true;
                        ssSign = true;
                    } else if (sign.getType() == 2 ) {
                    } else if (sign.getType() == 2 ) {
                        jtSign = true;
                        jtSign = true;
                    }
                    }
                    obj.put("doctor",sign.getDoctor());
                    obj.put("doctorName",sign.getDoctorName());
                    map1.put("statusName","已签约");
                    map1.put("doctor",sign.getDoctor());
                    map1.put("doctorName",sign.getDoctorName());
                }
                }
                Integer family_relation = Integer.valueOf(map.get("family_relation").toString());
                Integer family_relation = Integer.valueOf(map.get("family_relation").toString());
                obj.put("code", map.get("code"));
                obj.put("name", map.get("name"));
                obj.put("sex", map.get("sex"));
                obj.put("isAuthorize", map.get("is_authorize"));//0:未授权,1:已授权
                obj.put("birthday", map.get("birthday"));
                obj.put("idcard", StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString());
                obj.put("photo", map.get("photo"));
                obj.put("mobile", map.get("mobile"));
                obj.put("address", StringUtils.isEmpty(String.valueOf(map.get("address"))) ? "" : map.get("address"));
                obj.put("familyRelation", family_relation);
                obj.put("familyRelationName", relations.get(map.get("family_relation")));
                if (ssSign && jtSign) {
                    obj.put("signType", 3);
                } else if (!ssSign && jtSign) {
                    obj.put("signType", 2);
                } else if (ssSign && !jtSign) {
                    obj.put("signType", 1);
                } else {
                    obj.put("signType", 0);
                }
                map1.put("code", map.get("code"));
                map1.put("name", map.get("name"));
                map1.put("sex", map.get("sex"));
                map1.put("isAuthorize", map.get("is_authorize"));//0:未授权,1:已授权
                map1.put("birthday", map.get("birthday"));
                map1.put("idcard", StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString());
                map1.put("photo", map.get("photo"));
                map1.put("mobile", map.get("mobile"));
                map1.put("address", StringUtils.isEmpty(String.valueOf(map.get("address"))) ? "" : map.get("address"));
                map1.put("familyRelation", family_relation);
                map1.put("familyRelationName", relations.get(map.get("family_relation")));
                if(family_relation==0){
                if(family_relation==0){
                    tem.put(obj);
                    tem.put(map1);
                }else {
                }else {
                    resultArray.put(obj);
                    list.add(map1);
                }
                }
            }
            if(tem.length()>0){
                for(int i =0;i<tem.length();i++){
                    resultArray.put(tem.get(i));
                if(family_relation==0){
                    tem.put(map1);
                }else {
                    list.add(map1);
                }
                }
            }
            }
        }
        }
        return resultArray;
        return list;
    }
    }
    public JSONObject getPatient(String patient){
    public Map getPatient(String patient){
        Patient p = patientDao.findByCode(patient);
        Patient p = patientDao.findByCode(patient);
        //查询签约信息
        //查询签约信息
        JSONObject obj = new JSONObject();
        Map map = new HashMap<String,Object>();
        SignFamily sign = contractService.findSignByPatient(p.getCode());
        SignFamily sign = contractService.findSignByPatient(p.getCode());
        boolean ssSign = false;
        boolean ssSign = false;
        boolean jtSign = false;
        boolean jtSign = false;
        String doctor = null;
        String doctor = null;
        String doctorName = null;
        String doctorName = null;
        map.put("statusName","未签约");
        if (sign != null) {
        if (sign != null) {
            if (sign.getType() == 1 ) {
                ssSign = true;
            } else if (sign.getType() == 2 ) {
                jtSign = true;
            }
            doctor = sign.getDoctor();
            doctor = sign.getDoctor();
            doctorName = sign.getDoctorName();
            doctorName = sign.getDoctorName();
            map.put("statusName","已签约");
        }
        }
        obj.put("doctor",doctor);
        obj.put("doctorName",doctorName);
        obj.put("code", p.getCode());
        obj.put("name", p.getName());
        obj.put("sex", p.getSex());
        obj.put("birthday", p.getBirthday());
        obj.put("isAuthorize", 1);
        map.put("doctor",doctor);
        map.put("doctorName",doctorName);
        map.put("code", p.getCode());
        map.put("name", p.getName());
        map.put("sex", p.getSex());
        map.put("birthday", p.getBirthday());
        map.put("isAuthorize", 1);
        String idCard = StringUtils.isEmpty(p.getIdcard()) ? "" : p.getIdcard();
        String idCard = StringUtils.isEmpty(p.getIdcard()) ? "" : p.getIdcard();
        obj.put("idcard", CommonUtil.getIdcardEncode(idCard));
        obj.put("idcardAll", idCard);
        obj.put("ssc", p.getSsc());
        obj.put("photo", StringUtils.isEmpty(p.getPhoto()) ? "" : p.getPhoto());
        obj.put("mobile", StringUtils.isEmpty(p.getMobile()) ? "" : p.getMobile());
        obj.put("address", StringUtils.isEmpty(p.getAddress()) ? "" : p.getAddress());
        obj.put("familyRelation", -1);
        obj.put("familyRelationName", "自己");
        obj.put("isAuthorize", 1);//0:未授权,1:已授权
        if (ssSign && jtSign) {
            obj.put("signType", 3);
        } else if (!ssSign && jtSign) {
            obj.put("signType", 2);
        } else if (ssSign && !jtSign) {
            obj.put("signType", 1);
        } else {
            obj.put("signType", 0);
        }
        return obj;
        map.put("idcard", CommonUtil.getIdcardEncode(idCard));
        map.put("idcardAll", idCard);
        map.put("ssc", p.getSsc());
        map.put("photo", StringUtils.isEmpty(p.getPhoto()) ? "" : p.getPhoto());
        map.put("mobile", StringUtils.isEmpty(p.getMobile()) ? "" : p.getMobile());
        map.put("address", StringUtils.isEmpty(p.getAddress()) ? "" : p.getAddress());
        map.put("familyRelation", -1);
        map.put("familyRelationName", "自己");
        map.put("isAuthorize", 1);//0:未授权,1:已授权
        return map;
    }
    }
}
}

+ 31 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/medicine/WlyyMedicineKeyService.java

@ -0,0 +1,31 @@
package com.yihu.wlyy.service.manager.medicine;
import com.yihu.wlyy.medicine.entity.WlyyMedicineKey;
import com.yihu.wlyy.medicine.repository.WlyyMedicineKeyDao;
import com.yihu.wlyy.util.query.BaseJpaService;
import com.yihu.wlyy.util.query.BasemedicineJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springside.modules.utils.Clock;
import javax.annotation.Resource;
/**
 * Created by Administrator on 2017/8/14.
 */
@Service
public class WlyyMedicineKeyService extends BasemedicineJpaService<WlyyMedicineKey, WlyyMedicineKeyDao> {
    @Autowired
    private WlyyMedicineKeyDao wlyyMedicineKeyDao;
    private Clock clock = Clock.DEFAULT;
    public void saveKey(String key) {
        WlyyMedicineKey medicineKey = new WlyyMedicineKey();
        medicineKey.setAccessKey(key);
        medicineKey.setAddTimestamp(System.currentTimeMillis());
        medicineKey.setExpiresIn(Long.valueOf(14400));
        medicineKey.setCreataTime(clock.getCurrentDate());
        wlyyMedicineKeyDao.save(medicineKey);
    }
}

+ 205 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/query/BasemedicineJpaService.java

@ -0,0 +1,205 @@
package com.yihu.wlyy.util.query;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.metamodel.EntityType;
import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
 * Created by yww on 2017/08/14.
 * medicine数据库通用查询
 */
@Transactional(propagation = Propagation.SUPPORTS)
public class BasemedicineJpaService<T,R> {
    Class<R> repoClass;
    @PersistenceContext(
            name = "entityManagerMedicine",
            unitName = "threeTimePersistenceUnit"
    )
    protected EntityManager entityManager;
    public BasemedicineJpaService(){
        Type genType = getClass().getGenericSuperclass();
        if ((genType instanceof ParameterizedType)) {
            Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
            if (params.length==2) {
                repoClass = (Class) params[1];
            }
        }
    }
    public T save(T entity) {
        return (T) getRepository().save(entity);
    }
    public T retrieve(Serializable id) {
        return (T) getRepository().findOne(id);
    }
    public void delete(Serializable id) {
        getRepository().delete(id);
    }
    public void delete(T entity) {
        getRepository().delete(entity);
    }
    public void delete(Iterable ids) {
        Iterable list = getRepository().findAll(ids);
        getRepository().delete(list);
    }
    public Class<T> getEntityClass() {
        Type genType = this.getClass().getGenericSuperclass();
        Type[] parameters = ((ParameterizedType) genType).getActualTypeArguments();
        return (Class) parameters[0];
    }
    public List search(String fields, String filters, String sorts, Integer page, Integer size) throws ParseException {
        URLQueryParser queryParser = createQueryParser(fields, filters, sorts);
        CriteriaQuery query = queryParser.makeCriteriaQuery();
        if (page == null || page <= 0) page = 1;
        if (size == null || size <= 0 || size > 10000) size = 15;
        return entityManager
                .createQuery(query)
                .setFirstResult((page - 1) * size)
                .setMaxResults(size)
                .getResultList();
    }
    public List search(String filters) throws ParseException {
        URLQueryParser queryParser = createQueryParser("", filters, "");
        CriteriaQuery query = queryParser.makeCriteriaQuery();
        return entityManager
                .createQuery(query)
                .getResultList();
    }
    public long getCount(String filters) throws ParseException {
        URLQueryParser queryParser = createQueryParser(filters);
        CriteriaQuery query = queryParser.makeCriteriaCountQuery();
        return (long) entityManager.createQuery(query).getSingleResult();
    }
    protected <T> URLQueryParser createQueryParser(String fields, String filters, String orders) {
        URLQueryParser queryParser = new URLQueryParser<T>(fields, filters, orders)
                .setEntityManager(entityManager)
                .setEntityClass(getEntityClass());
        return queryParser;
    }
    protected <T> URLQueryParser createQueryParser(String filters) {
        URLQueryParser queryParser = new URLQueryParser<T>(filters)
                .setEntityManager(entityManager)
                .setEntityClass(getEntityClass());
        return queryParser;
    }
    protected Sort parseSorts(String sorter){
        if (StringUtils.isNotEmpty(sorter)) {
            String[] orderArray = sorter.split(",");
            List<Sort.Order> orderList = new ArrayList<Sort.Order>(orderArray.length);
            Arrays.stream(orderArray).forEach(
                    elem -> orderList.add(
                            elem.startsWith("+") ? new Sort.Order(Sort.Direction.ASC, elem.substring(1)):
                                    new Sort.Order(Sort.Direction.DESC, elem.substring(1))));
            return new Sort(orderList);
        }
        return null;
    }
    protected Session currentSession() {
        return entityManager.unwrap(Session.class);
    }
    public PagingAndSortingRepository getRepository() {
        return (PagingAndSortingRepository) SpringContext.getService(repoClass);
    }
    public JpaRepository getJpaRepository(){
        return (JpaRepository) SpringContext.getService(repoClass);
    }
    public List<T> findByField(String field, Object value){
        return findByFields(
                new String[]{field},
                new Object[]{value}
        );
    }
    public List<T> findByFields(String[] fields, Object[] values){
        CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
        CriteriaQuery query = criteriaBuilder.createQuery(getEntityClass());
        Root<T> root = query.from(getEntityClass());
        List<Predicate> ls = new ArrayList<Predicate>();
        for(int i=0; i< fields.length; i++){
            if(values[i].getClass().isArray())
                ls.add(criteriaBuilder.in(root.get(fields[i]).in((Object[])values[i])));
            else
                ls.add(criteriaBuilder.equal(root.get(fields[i]), values[i]));
        }
        query.where(ls.toArray(new Predicate[ls.size()]));
        return entityManager
                .createQuery(query)
                .getResultList() ;
    }
    public String getClzName(){
        return getEntityClass().getName();
    }
    public String getEntityIdFiled(){
        EntityType entityType = entityManager.getMetamodel().entity(getEntityClass());
        javax.persistence.metamodel.Type type = entityType.getIdType();
        String s = entityType.getId(type.getJavaType()).getName();
        return s;
    }
    public int delete(Object[] ids){
        String hql = " DELETE FROM "+getEntityClass().getName()+" WHERE "+getEntityIdFiled()+" in(:ids)";
        Query query = currentSession().createQuery(hql);
        query.setParameterList("ids", ids);
        return query.executeUpdate();
    }
    public void batchInsert(List list) {
        for (int i = 0; i < list.size(); i++) {
            entityManager.persist(list.get(i));
            if (i % 30 == 0) {
                entityManager.flush();
                entityManager.clear();
            }
        }
    }
}

+ 26 - 0
patient-co-manage/wlyy-manage/src/main/resources/application.yml

@ -29,6 +29,18 @@ spring:
      test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
      test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
      min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
      min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
      time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
      time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
    medicine:
      driver-class-name: com.mysql.jdbc.Driver
      max-active: 10
      max-idle: 10
      min-idle: 6
      idle-timeout: 3000
      testOnBorrow: true
      validationQuery: SELECT 1
      num-tests-per-eviction-run: 10 #在每次空闲连接回收器线程(如果有)运行时检查的连接数量,最好和maxActive
      test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
      min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
      time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
  jpa:
  jpa:
    database-platform: org.hibernate.dialect.MySQL5Dialect
    database-platform: org.hibernate.dialect.MySQL5Dialect
    hibernate.dialect: org.hibernate.dialect.MySQL5Dialect
    hibernate.dialect: org.hibernate.dialect.MySQL5Dialect
@ -46,6 +58,10 @@ spring:
      url: jdbc:mysql://172.19.103.85:3306/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      url: jdbc:mysql://172.19.103.85:3306/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: linzhou
      username: linzhou
      password: linzhou
      password: linzhou
    medicine:
      url: jdbc:mysql://172.19.103.77:3306/medicine?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: root
      password: 123456
  sms: # SMS短信配置
  sms: # SMS短信配置
    yihu_sms_url: https://smsapi.ums86.com:9600/sms/Api/Send.do
    yihu_sms_url: https://smsapi.ums86.com:9600/sms/Api/Send.do
    yihu_sms_code: 229336
    yihu_sms_code: 229336
@ -70,11 +86,17 @@ spring:
      url: jdbc:mysql://172.19.103.77:3306/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      url: jdbc:mysql://172.19.103.77:3306/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: root
      username: root
      password: 123456
      password: 123456
    medicine:
      url: jdbc:mysql://172.19.103.77:3306/medicine?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: root
      password: 123456
  sms: # SMS短信配置
  sms: # SMS短信配置
    yihu_sms_url: https://smsapi.ums86.com:9600/sms/Api/Send.do
    yihu_sms_url: https://smsapi.ums86.com:9600/sms/Api/Send.do
    yihu_sms_code: 229336
    yihu_sms_code: 229336
    yihu_sms_name: jkzldxjr
    yihu_sms_name: jkzldxjr
    yihu_sms_password: jkzldxjrpwd123
    yihu_sms_password: jkzldxjrpwd123
service-gateway:
service-gateway:
  update-team-url: http://172.19.103.87:8011/wlyy_service/third/doctor/LoadTeamInfo
  update-team-url: http://172.19.103.87:8011/wlyy_service/third/doctor/LoadTeamInfo
im-service:
im-service:
@ -94,6 +116,10 @@ spring:
      url: jdbc:mysql://59.61.92.94:3306/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      url: jdbc:mysql://59.61.92.94:3306/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: wlyy
      username: wlyy
      password: jkzlehr@123
      password: jkzlehr@123
    medicine:
      url: jdbc:mysql://172.19.103.77:3306/medicine?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: root
      password: 123456
  sms: # SMS短信配置
  sms: # SMS短信配置
    yihu_sms_url: https://smsapi.ums86.com:9600/sms/Api/Send.do
    yihu_sms_url: https://smsapi.ums86.com:9600/sms/Api/Send.do
    yihu_sms_code: 229336
    yihu_sms_code: 229336

+ 4 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDispensaryCodeDao.java

@ -15,20 +15,20 @@ import java.util.List;
 * 处方取码
 * 处方取码
 */
 */
public interface PrescriptionDispensaryCodeDao extends PagingAndSortingRepository<PrescriptionDispensaryCode, Long>, JpaSpecificationExecutor<PrescriptionDispensaryCode> {
public interface PrescriptionDispensaryCodeDao extends PagingAndSortingRepository<PrescriptionDispensaryCode, Long>, JpaSpecificationExecutor<PrescriptionDispensaryCode> {
    @Query("from PrescriptionDispensaryCode where code=?1")
    @Query(nativeQuery = true, value = "select * from wlyy_prescription_dispensary_code  where code=?1 order by create_time desc limit 0,1 ")
    PrescriptionDispensaryCode finByCode(String code);
    PrescriptionDispensaryCode finByCode(String code);
//    @Query("select  count(1) from wlyy_prescription_dispensary_code p1 \n" +
    //    @Query("select  count(1) from wlyy_prescription_dispensary_code p1 \n" +
//            "LEFT JOIN wlyy_prescription p2 on p1.prescription_Code = p2.code where p2.status in(21,20,100) and p2.patient =?1 ")
//            "LEFT JOIN wlyy_prescription p2 on p1.prescription_Code = p2.code where p2.status in(21,20,100) and p2.patient =?1 ")
//    int dispensaryCodeCount(String patientCode);
//    int dispensaryCodeCount(String patientCode);
    @Query("select count(1) from PrescriptionDispensaryCode a where a.code= ?1 and a.isUse =0")
    @Query("select count(1) from PrescriptionDispensaryCode a where a.code= ?1 and a.isUse =0")
    Integer getResidentQRCodeCount(String code);
    Integer getResidentQRCodeCount(String code);
    @Query("select a.code from PrescriptionDispensaryCode a where a.prescriptionCode= ?1 and a.type =?2 ")
    @Query("select a.code from PrescriptionDispensaryCode a where a.prescriptionCode= ?1 and a.type =?2 ")
    String getCodeByPrescriptionCodeAndType(String prescriptionCode,Integer type);
    String getCodeByPrescriptionCodeAndType(String prescriptionCode, Integer type);
//    @Query("select p1 from PrescriptionInfo p1 left join Prescription p2 on p1.prescriptionCode=p2.code where p1.prescriptionCode = ?1")
//    @Query("select p1 from PrescriptionInfo p1 left join Prescription p2 on p1.prescriptionCode=p2.code where p1.prescriptionCode = ?1")
//    List<PrescriptionInfo> getPrescriptionInfo(String prescriptionCode);
//    List<PrescriptionInfo> getPrescriptionInfo(String prescriptionCode);
    PrescriptionDispensaryCode findByCodeAndIsUse(String code,Integer isUse);
    PrescriptionDispensaryCode findByCodeAndIsUse(String code, Integer isUse);
}
}

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

@ -12,6 +12,6 @@ import java.util.List;
 */
 */
public interface PrescriptionLogDao extends PagingAndSortingRepository<PrescriptionLog, Long>, JpaSpecificationExecutor<PrescriptionLog> {
public interface PrescriptionLogDao extends PagingAndSortingRepository<PrescriptionLog, Long>, JpaSpecificationExecutor<PrescriptionLog> {
    @Query("select l.status,l.createTime from PrescriptionLog l where l.prescriptionCode=?1 and l.type in ?2 order by createTime desc")
    @Query("select l.status,l.createTime from PrescriptionLog l where l.prescriptionCode=?1 and l.status in ?2 order by createTime desc")
    List<PrescriptionLog> findPrescriptionLogsByPrescriptionCode(String prescriptionCode, Integer[] types);
    List<PrescriptionLog> findPrescriptionLogsByPrescriptionCode(String prescriptionCode, Integer[] types);
}
}

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

@ -32,6 +32,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
import java.lang.reflect.Array;
import java.util.*;
import java.util.*;
/**
/**
@ -1063,4 +1064,37 @@ public class PrescriptionInfoService extends BaseService {
        com.alibaba.fastjson.JSONArray rs =  presModeAdapter.modeTopresInfo(rp);
        com.alibaba.fastjson.JSONArray rs =  presModeAdapter.modeTopresInfo(rp);
        return rs;
        return rs;
    }
    }
    /**
     * 获取医生挂号费用
     * @param jwHospital
     * @param jwDoctorCode
     * @return
     */
   public JSONArray getRegisterRee(String jwHospital,String jwDoctorCode){
        StringBuffer sql = new StringBuffer(" SELECT t.register_fee AS registerFee FROM zy_iv_staff_reg_type_allot_dict t " +
                " WHERE t.org_code =? AND t.staff_code =? ");
       List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql.toString(),new Object[]{jwHospital,jwDoctorCode});
       return new JSONArray(rs);
   }
    /**
     * 获取医生科室
     * @param jwHospital
     * @param jwDoctorCode
     * @return
     */
    public JSONArray getDeptList(String jwHospital,String jwDoctorCode){
        StringBuffer sql = new StringBuffer(" SELECT " +
                " d.dept_code AS deptCode, " +
                " d.dept_name AS deptName " +
                " FROM " +
                " zy_iv_dept_staff_allot_dict t " +
                " JOIN zy_iv_dept_dict d ON t.dept_code = d.dept_code " +
                " WHERE  " +
                " t.org_code = ?  " +
                " AND t.staff_code = ?");
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql.toString(),new Object[]{jwHospital,jwDoctorCode});
        return new JSONArray(rs);
    }
}
}

+ 3 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionLogService.java

@ -22,11 +22,11 @@ public class PrescriptionLogService extends BaseService {
     * 根据处方code 和 types查询处方的流程日志 时间倒叙
     * 根据处方code 和 types查询处方的流程日志 时间倒叙
     *
     *
     * @param prescriptionCode 处方code
     * @param prescriptionCode 处方code
     * @param types            需要查询的types
     * @param status            需要查询的status
     * @return
     * @return
     */
     */
    public List<PrescriptionLog> findPrescriptionLogsByPrescriptionCode(String prescriptionCode, Integer[] types) {
        return prescriptionLogDao.findPrescriptionLogsByPrescriptionCode(prescriptionCode, types);
    public List<PrescriptionLog> findPrescriptionLogsByPrescriptionCode(String prescriptionCode, Integer[] status) {
        return prescriptionLogDao.findPrescriptionLogsByPrescriptionCode(prescriptionCode, status);
    }
    }
    /**
    /**

+ 26 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java

@ -176,8 +176,8 @@ public class PrescriptionInfoController extends BaseController{
            jo.put("prescriptionPay", prescriptionPay);
            jo.put("prescriptionPay", prescriptionPay);
            jo.put("prescriptionExpressage", new JSONObject(prescriptionExpressage));
            jo.put("prescriptionExpressage", new JSONObject(prescriptionExpressage));
            jo.put("prescriptionHospital", prescription.getHospitalName());//出药机构
            jo.put("prescriptionHospital", prescription.getHospitalName());//出药机构
            jo.put("dispensaryDispensaryType", prescription.getType());//处方配送方式
            jo.put("dispensaryDispensaryTypeName", prescription.getTypeName());//处方配送方式
            jo.put("dispensaryDispensaryType", prescription.getDispensaryType());//处方配送方式
            jo.put("dispensaryDispensaryTypeName", prescription.getDispensaryTypeName());//处方配送方式
            jo.put("prescriptionStatus", prescription.getStatus());//处方状态
            jo.put("prescriptionStatus", prescription.getStatus());//处方状态
            jo.put("prescriptionStatusName", prescription.getStatusName(prescription.getStatus(),""));//处方状态名称
            jo.put("prescriptionStatusName", prescription.getStatusName(prescription.getStatus(),""));//处方状态名称
@ -376,7 +376,6 @@ public class PrescriptionInfoController extends BaseController{
    }
    }
    @RequestMapping(value = "/getPrescription" ,method = RequestMethod.GET)
    @RequestMapping(value = "/getPrescription" ,method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取长处方详细信息")
    @ApiOperation(value = "获取长处方详细信息")
    public String getPrescription(@RequestParam(required = true)@ApiParam(name="code",value="处方CODE")String code){
    public String getPrescription(@RequestParam(required = true)@ApiParam(name="code",value="处方CODE")String code){
        try {
        try {
@ -388,7 +387,6 @@ public class PrescriptionInfoController extends BaseController{
    }
    }
    @RequestMapping(value = "/getRateList" ,method = RequestMethod.GET)
    @RequestMapping(value = "/getRateList" ,method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "查询频次列表")
    @ApiOperation(value = "查询频次列表")
    public String getRateList(){
    public String getRateList(){
        try {
        try {
@ -399,4 +397,28 @@ public class PrescriptionInfoController extends BaseController{
        }
        }
    }
    }
    @RequestMapping(value = "/getRegisterRee" ,method = RequestMethod.GET)
    @ApiOperation(value = "获取挂号费+诊察费下拉列表")
    public String getRegisterRee(@RequestParam(required = true)@ApiParam(name="jwHospital",value="开方机构")String jwHospital,
                                 @RequestParam(required = true)@ApiParam(name="jwDoctorCode",value="开方医生Code")String jwDoctorCode){
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getRegisterRee(jwHospital,jwDoctorCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getDeptList" ,method = RequestMethod.GET)
    @ApiOperation(value = "获取医生科室列表")
    public String getDeptList(@RequestParam(required = true)@ApiParam(name="jwHospital",value="开方机构")String jwHospital,
                                 @RequestParam(required = true)@ApiParam(name="jwDoctorCode",value="开方医生Code")String jwDoctorCode){
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getDeptList(jwHospital,jwDoctorCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
}
}

+ 19 - 22
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionLogController.java

@ -1,16 +1,13 @@
package com.yihu.wlyy.web.doctor.prescription;
package com.yihu.wlyy.web.doctor.prescription;
import com.yihu.wlyy.entity.doctor.reply.DoctorQuickReply;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressageLog;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressageLog;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageLogService;
import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageLogService;
import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageService;
import com.yihu.wlyy.service.app.prescription.PrescriptionLogService;
import com.yihu.wlyy.service.app.prescription.PrescriptionLogService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -21,7 +18,6 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.Collections;
import java.util.Collections;
import java.util.Comparator;
import java.util.Comparator;
import java.util.List;
import java.util.List;
import java.util.Map;
/**
/**
 * Created by chenweida on 2017/7/27.
 * Created by chenweida on 2017/7/27.
@ -42,7 +38,7 @@ public class PrescriptionLogController extends BaseController {
        try {
        try {
            // (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 ,
            // (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 ,
            //  40配药成功/待配送  41配送失败  42配送中   43配送到服务站  100配送到患者手中/已完成)
            //  40配药成功/待配送  41配送失败  42配送中   43配送到服务站  100配送到患者手中/已完成)
            Integer[] types = new Integer[]{
            Integer[] status = new Integer[]{
                    PrescriptionLog.PrescriptionLogStatus.revieweding.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.revieweding.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.changeing.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.changeing.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.reviewed_success.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.reviewed_success.getValue(),
@ -51,7 +47,7 @@ public class PrescriptionLogController extends BaseController {
                    PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.expressageing.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.expressageing.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.finish.getValue()};
                    PrescriptionLog.PrescriptionLogStatus.finish.getValue()};
            List<PrescriptionLog> prescriptionLogs = prescriptionLogService.findPrescriptionLogsByPrescriptionCode(prescriptionCode, types);
            List<PrescriptionLog> prescriptionLogs = prescriptionLogService.findPrescriptionLogsByPrescriptionCode(prescriptionCode, status);
            if (prescriptionLogs != null) {
            if (prescriptionLogs != null) {
                return write(200, "获取处方流程成功", "data", new JSONArray(copyBeans(prescriptionLogs, "statusName", "createTime")));
                return write(200, "获取处方流程成功", "data", new JSONArray(copyBeans(prescriptionLogs, "statusName", "createTime")));
            } else {
            } else {
@ -71,18 +67,19 @@ public class PrescriptionLogController extends BaseController {
    @RequestMapping(value = "/orderFollow", method = RequestMethod.GET)
    @RequestMapping(value = "/orderFollow", method = RequestMethod.GET)
    @ApiOperation(value = "订单状态跟踪")
    @ApiOperation(value = "订单状态跟踪")
    public String orderFollow(
    public String orderFollow(
            @ApiParam(value = "处方code", name = "prescriptionCode") @RequestParam(required = true, name = "prescriptionCode") String prescriptionCode,
            @ApiParam(value = "1是倒叙 0是正序 默认是正序", name = "sort", required = false, defaultValue = "0") @RequestParam(required = false, defaultValue = "0", name = "sort") Integer sort) {
            @ApiParam(value = "处方code", name = "prescriptionCode") @RequestParam(required = true, name = "prescriptionCode") String prescriptionCode) {
        try {
        try {
            // (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 ,
            // (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 ,
            //  40配药成功/待配送  41配送失败  42配送中   43配送到服务站  100配送到患者手中/已完成)
            //  40配药成功/待配送  41配送失败  42配送中   43配送到服务站  100配送到患者手中/已完成)
            Integer[] types = new Integer[]{
            Integer[] status = new Integer[]{
                    PrescriptionLog.PrescriptionLogStatus.reviewed_success.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.adding.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.pay_success.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.pay_success.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.expressageing.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.expressageing.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.finish.getValue()};
                    PrescriptionLog.PrescriptionLogStatus.finish.getValue()};
            List<PrescriptionLog> prescriptionLogs = prescriptionLogService.findPrescriptionLogsByPrescriptionCode(prescriptionCode, types);
            List<PrescriptionLog> prescriptionLogs = prescriptionLogService.findPrescriptionLogsByPrescriptionCode(prescriptionCode, status);
            //加上快递的log
            //加上快递的log
            List<PrescriptionExpressageLog> expressageLogs = prescriptionExpressageLogService.findByPrescriptionCode(prescriptionCode);
            List<PrescriptionExpressageLog> expressageLogs = prescriptionExpressageLogService.findByPrescriptionCode(prescriptionCode);
@ -97,26 +94,26 @@ public class PrescriptionLogController extends BaseController {
                prescriptionLogs.add(prescriptionLog);
                prescriptionLogs.add(prescriptionLog);
            }
            }
            //排序
            //排序
            Collections.sort(prescriptionLogs, new Comparator<PrescriptionLog>() {
                public int compare(PrescriptionLog o1, PrescriptionLog o2) {
                    long map1value = o1.getCreateTime().getTime();
                    long map2value = o2.getCreateTime().getTime();
            //排序
            expressageLogs.sort((o1, o2) -> {
                long map1value = o1.getCreateTime().getTime();
                long map2value = o2.getCreateTime().getTime();
                    if (map1value - map2value > 0) {
                        return sort == 1 ? -1 : 1;
                    } else if (map1value - map2value < 0) {
                        return sort == 1 ? 1 : -1;
                    } else {
                        return 0;
                    }
                if (map1value - map2value > 0) {
                    return 1;
                } else if (map1value - map2value < 0) {
                    return -1;
                } else {
                    return 0;
                }
                }
            });
            });
            if (prescriptionLogs != null) {
            if (prescriptionLogs != null) {
                return write(200, "获取处方流程成功", "data", new JSONArray(copyBeans(prescriptionLogs, "statusName", "createTime")));
                return write(200, "获取处方流程成功", "data", new JSONArray(prescriptionLogs));
            } else {
            } else {
                return error(-1, "获取失败");
                return error(-1, "获取失败");
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "获取失败");
            return error(-1, "获取失败");
        }
        }
    }
    }

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionController.java

@ -233,8 +233,8 @@ public class PatientPrescriptionController extends WeixinBaseController {
            jo.put("prescriptionInfos", prescriptionInfos);
            jo.put("prescriptionInfos", prescriptionInfos);
            jo.put("prescriptionPay", prescriptionPay);
            jo.put("prescriptionPay", prescriptionPay);
            jo.put("prescriptionHospital", prescription.getHospitalName());//出药机构
            jo.put("prescriptionHospital", prescription.getHospitalName());//出药机构
            jo.put("prescriptionDispensaryType", prescription.getType());//处方配送方式
            jo.put("prescriptionDispensaryTypeName", prescription.getTypeName());//处方配送方式
            jo.put("prescriptionDispensaryType", prescription.getDispensaryType());//处方配送方式
            jo.put("prescriptionDispensaryTypeName", prescription.getDispensaryTypeName());//处方配送方式
            jo.put("prescriptionStatus", prescription.getStatus());//处方状态
            jo.put("prescriptionStatus", prescription.getStatus());//处方状态
            jo.put("prescriptionStatusName", prescription.getStatusName(prescription.getStatus(),""));//处方状态名称
            jo.put("prescriptionStatusName", prescription.getStatusName(prescription.getStatus(),""));//处方状态名称
            return write(200, "查询成功", "data", jo);
            return write(200, "查询成功", "data", jo);

+ 18 - 17
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionLogController.java

@ -42,18 +42,17 @@ public class PatientPrescriptionLogController extends BaseController {
    @RequestMapping(value = "/orderFollow", method = RequestMethod.GET)
    @RequestMapping(value = "/orderFollow", method = RequestMethod.GET)
    @ApiOperation(value = "订单状态跟踪")
    @ApiOperation(value = "订单状态跟踪")
    public String orderFollow(
    public String orderFollow(
            @ApiParam(value = "处方code", name = "prescriptionCode") @RequestParam(required = true, name = "prescriptionCode") String prescriptionCode,
            @ApiParam(value = "1是倒叙 0是正序 默认是正序", name = "sort", required = false, defaultValue = "0") @RequestParam(required = false, defaultValue = "0", name = "sort") Integer sort) {
            @ApiParam(value = "处方code", name = "prescriptionCode") @RequestParam(required = true, name = "prescriptionCode") String prescriptionCode) {
        try {
        try {
            // (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 ,
            // (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 ,
            // 40配药成功/待配送  41配送失败 42分配健管师 45配送中   49配送到服务站  100配送到患者手中/已完成)
            // 40配药成功/待配送  41配送失败 42分配健管师 45配送中   49配送到服务站  100配送到患者手中/已完成)
            Integer[] types = new Integer[]{
            Integer[] status = new Integer[]{
                    PrescriptionLog.PrescriptionLogStatus.pay_success.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.pay_success.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.expressageing.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.expressageing.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.finish.getValue()};
                    PrescriptionLog.PrescriptionLogStatus.finish.getValue()};
            List<PrescriptionLog> prescriptionLogs = prescriptionLogService.findPrescriptionLogsByPrescriptionCode(prescriptionCode, types);
            List<PrescriptionLog> prescriptionLogs = prescriptionLogService.findPrescriptionLogsByPrescriptionCode(prescriptionCode, status);
            //加上快递的log
            //加上快递的log
            List<PrescriptionExpressageLog> expressageLogs = prescriptionExpressageLogService.findByPrescriptionCode(prescriptionCode);
            List<PrescriptionExpressageLog> expressageLogs = prescriptionExpressageLogService.findByPrescriptionCode(prescriptionCode);
@ -68,26 +67,28 @@ public class PatientPrescriptionLogController extends BaseController {
                prescriptionLogs.add(prescriptionLog);
                prescriptionLogs.add(prescriptionLog);
            }
            }
            //排序
            //排序
            Collections.sort(prescriptionLogs, new Comparator<PrescriptionLog>() {
                public int compare(PrescriptionLog o1, PrescriptionLog o2) {
                    long map1value = o1.getCreateTime().getTime();
                    long map2value = o2.getCreateTime().getTime();
            expressageLogs.sort((o1, o2) -> {
                long map1value = o1.getCreateTime().getTime();
                long map2value = o2.getCreateTime().getTime();
                    if (map1value - map2value > 0) {
                        return sort == 1 ? -1 : 1;
                    } else if (map1value - map2value < 0) {
                        return sort == 1 ? 1 : -1;
                    } else {
                        return 0;
                    }
                if (map1value - map2value > 0) {
                    return 1;
                } else if (map1value - map2value < 0) {
                    return -1;
                } else {
                    return 0;
                }
                }
            });
            });
            if (prescriptionLogs != null) {
            if (prescriptionLogs != null) {
                return write(200, "获取处方流程成功", "data", new JSONArray(copyBeans(prescriptionLogs, "statusName", "createTime")));
                return write(200, "获取处方流程成功", "data", new JSONArray(prescriptionLogs));
            } else {
            } else {
                return error(-1, "获取失败");
                return error(-1, "获取失败");
            }
            }
        } catch (Exception e) {
        } catch (
                Exception e
                )
        {
            return error(-1, "获取失败");
            return error(-1, "获取失败");
        }
        }
    }
    }