Sfoglia il codice sorgente

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

humingfen 7 anni fa
parent
commit
54ea6c0ba9
21 ha cambiato i file con 855 aggiunte e 149 eliminazioni
  1. 33 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyScreenResult.java
  2. 10 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/team/admin/AdminTeamMember.java
  3. 2 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java
  4. 100 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/specialist/PatientDiseaseServer.java
  5. 68 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/specialist/SpecialDisease.java
  6. 73 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/specialist/TeamDiseaseRelation.java
  7. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorAdminTeamMemberDao.java
  8. 16 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/specialist/PatientDiseaseServerDao.java
  9. 15 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/specialist/SpecialDiseaseDao.java
  10. 16 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/specialist/TeamDiseaseRelationDao.java
  11. 11 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/DeviceDetailService.java
  12. 38 14
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java
  13. 4 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java
  14. 9 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/QrcodeService.java
  15. 313 118
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java
  16. 6 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/qrcode/QrCodeController.java
  17. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java
  18. 10 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  19. 28 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistController.java
  20. 91 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/specialist/PatientSpecialistController.java
  21. 9 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java

+ 33 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyScreenResult.java

@ -16,6 +16,8 @@ import java.util.Date;
@Table(name = "wlyy_survey_screen_result")
public class SurveyScreenResult extends IdEntity implements Serializable{
    //唯一标识
    private String code;
    //模板编码
    private String templateCode;
    //模板标题
@ -58,6 +60,37 @@ public class SurveyScreenResult extends IdEntity implements Serializable{
    public SurveyScreenResult() {
    }
    public SurveyScreenResult(String code, String templateCode, String templateTitle, int disease, String doctor, String patientCode, String openId, String patientName, int screenResultScore, String screenResult, int order, int following, int over, String reservationCode, Date czrq, int isAgain, String parentCode, String originCode, String adviceCode, String otherAdvice) {
        this.code = code;
        this.templateCode = templateCode;
        this.templateTitle = templateTitle;
        this.disease = disease;
        this.doctor = doctor;
        this.patientCode = patientCode;
        this.openId = openId;
        this.patientName = patientName;
        this.screenResultScore = screenResultScore;
        this.screenResult = screenResult;
        this.order = order;
        this.following = following;
        this.over = over;
        this.reservationCode = reservationCode;
        this.czrq = czrq;
        this.isAgain = isAgain;
        this.parentCode = parentCode;
        this.originCode = originCode;
        this.adviceCode = adviceCode;
        this.otherAdvice = otherAdvice;
    }
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "template_code")
    public String getTemplateCode() {

+ 10 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/team/admin/AdminTeamMember.java

@ -20,6 +20,7 @@ public class AdminTeamMember extends IdEntity {
    private String doctorCode;
    private Date joinTime;
    private boolean available;
    private String qrcode;
    public long getTeamId() {
        return teamId;
@ -57,4 +58,13 @@ public class AdminTeamMember extends IdEntity {
    public void setAvailable(boolean available) {
        this.available = available;
    }
    @Column(name = "qrcode")
    public String getQrcode() {
        return qrcode;
    }
    public void setQrcode(String qrcode) {
        this.qrcode = qrcode;
    }
}

+ 2 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java

@ -30,6 +30,7 @@ public class Message extends IdEntity {
	/** type
	 *  消息类型(1.是家庭签约信息  2.体征消息  3分配健管师 4.随访提醒 5.咨询回复提醒,6.续方咨询待审核提醒,7.续方消息待取药
	 *  8.续方支付成功后团队长分配健管师,9线下调整完成,10意见反馈 11账号申诉,12.协同服务 13.孕检提醒 14.文章提交审核消息  15、健康文章审核结果
	 *  16.专科医生申请签约消息
	 *  101患者申请取消签约、102患者同意取消签约、103患者拒绝取消签约、104患者填写了血糖记录、105患者填写了血压记录、106患者填写了体重记录、
	 *  107患者填写了腰围记录、108患者填写了运动记录、109患者填写了用药记录、110患者填写了饮食记录、111患者提交了问卷随访、112请求添加好友消息、
	 *  113入群消息、114群解散消息、115踢出群消息、116新的网络咨询、117网络咨询追问、
@ -57,7 +58,7 @@ public class Message extends IdEntity {
	private String tzType;//体征类别
	private String tzCode;//体征code
	private Integer sex;//患者性别
	private String relationCode;//业务关联code,type=6时为咨询code,type=7、8、9时为续方code type = 10\11时为申诉和反馈ID 12.协同服务code,14和15是文章审核功能是(0未认证1已认证2未通过)
	private String relationCode;//业务关联code,type=6时为咨询code,type=7、8、9时为续方code type = 10\11时为申诉和反馈ID 12.协同服务code,14和15是文章审核功能是(0未认证1已认证2未通过)16.专科医生申请签约消息
	private String prescriptionStatus;//type=6续方审核状态 0待审核,1审核通过,2审核失败,3居民取消|type=7续方状态 0待取药,1已取药
	public String getCode() {

+ 100 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/specialist/PatientDiseaseServer.java

@ -0,0 +1,100 @@
package com.yihu.wlyy.entity.specialist;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2018/7/4.
 */
@Entity
@Table(name = "wlyy_patient_disease_server")
public class PatientDiseaseServer extends IdEntity {
    private String code;
    private String specialistRelationCode;//专科医生团队签约关系code',
    private String patient;//居民',
    private String patientName;//居民名字',
    private String disease;//疾病',
    private String diseaseName;//疾病名称',
    private String del;//1正常;0删除',
    private Date updateTime;
    private Date createTime;
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getSpecialistRelationCode() {
        return specialistRelationCode;
    }
    public void setSpecialistRelationCode(String specialistRelationCode) {
        this.specialistRelationCode = specialistRelationCode;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public String getDisease() {
        return disease;
    }
    public void setDisease(String disease) {
        this.disease = disease;
    }
    public String getDiseaseName() {
        return diseaseName;
    }
    public void setDiseaseName(String diseaseName) {
        this.diseaseName = diseaseName;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 68 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/specialist/SpecialDisease.java

@ -0,0 +1,68 @@
package com.yihu.wlyy.entity.specialist;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2018/7/4.
 */
@Entity
@Table(name = "wlyy_special_disease")
public class SpecialDisease extends IdEntity {
    private String code;//专病code',
    private String name;//专病名称',
    private String del;//正常:1,删除:0',
    private Date updateTime;
    private Date createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

+ 73 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/specialist/TeamDiseaseRelation.java

@ -0,0 +1,73 @@
package com.yihu.wlyy.entity.specialist;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2018/7/4.
 */
@Entity
@Table(name = "wlyy_special_disease")
public class TeamDiseaseRelation extends IdEntity {
    private Long teamCode;//团队id',
    private String diseaseCode;//专病code',
    private String diseaseName;//专病名称',
    private String del;//正常:1;删除:0',
    private Date updateTime;
    private Date createTime;
    public Long getTeamCode() {
        return teamCode;
    }
    public void setTeamCode(Long teamCode) {
        this.teamCode = teamCode;
    }
    public String getDiseaseCode() {
        return diseaseCode;
    }
    public void setDiseaseCode(String diseaseCode) {
        this.diseaseCode = diseaseCode;
    }
    public String getDiseaseName() {
        return diseaseName;
    }
    public void setDiseaseName(String diseaseName) {
        this.diseaseName = diseaseName;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

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

@ -65,4 +65,6 @@ public interface DoctorAdminTeamMemberDao extends
    @Query("SELECT d FROM AdminTeamMember m, AdminTeam t, Doctor d WHERE t.id = ?1 AND t.id = m.teamId " +
            "AND m.doctorCode = d.code AND t.available = true AND m.available = true AND d.level=3 ORDER BY d.level")
    List<Doctor> findJGSMembers(long teamId);
    AdminTeamMember findByTeamIdAndDoctorCodeAndAvailable(Long teamId,String doctorCode,Boolean Available);
}

+ 16 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/specialist/PatientDiseaseServerDao.java

@ -0,0 +1,16 @@
package com.yihu.wlyy.repository.specialist;
import com.yihu.wlyy.entity.specialist.PatientDiseaseServer;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2018/7/4.
 */
public interface PatientDiseaseServerDao extends
        PagingAndSortingRepository<PatientDiseaseServer, Long>,
        JpaSpecificationExecutor<PatientDiseaseServer> {
    List<PatientDiseaseServer> findByPatientAndDel(String patient,String del);
}

+ 15 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/specialist/SpecialDiseaseDao.java

@ -0,0 +1,15 @@
package com.yihu.wlyy.repository.specialist;
import com.yihu.wlyy.entity.specialist.SpecialDisease;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2018/7/4.
 */
public interface SpecialDiseaseDao extends
        PagingAndSortingRepository<SpecialDisease, Long>,
        JpaSpecificationExecutor<SpecialDisease> {
    SpecialDisease findByCode(String code);
}

+ 16 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/specialist/TeamDiseaseRelationDao.java

@ -0,0 +1,16 @@
package com.yihu.wlyy.repository.specialist;
import com.yihu.wlyy.entity.specialist.TeamDiseaseRelation;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2018/7/4.
 */
public interface TeamDiseaseRelationDao extends
        PagingAndSortingRepository<TeamDiseaseRelation, Long>,
        JpaSpecificationExecutor<TeamDiseaseRelation> {
    List<TeamDiseaseRelation> findByTeamCodeAndDel(Long teamCode,String del);
}

+ 11 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/DeviceDetailService.java

@ -77,7 +77,7 @@ public class DeviceDetailService extends BaseService {
		}
		//设备表没有数据则插入一条数据
		if (deviceDetail==null){
			insertDevice(patientDevice,String.valueOf(adminTeam),hospitalName,hospital,"");
			insertDevice(patientDevice,String.valueOf(adminTeam),hospitalName,hospital,"",1);
			deviceDetail = deviceDetailDao.findBySn(patientDevice.getDeviceSn());
		}
@ -114,9 +114,11 @@ public class DeviceDetailService extends BaseService {
	 * @param adminTeam
	 * @param orgName
	 * @param orgCode
	 * @param bindCount
	 * @param isBind 0未绑定  1已绑定
	 * @throws Exception
	 */
	public void insertDevice(PatientDevice patientDevice, String adminTeam, String orgName, String orgCode,String bindCount)throws Exception{
	public void insertDevice(PatientDevice patientDevice, String adminTeam, String orgName, String orgCode,String bindCount,int isBind)throws Exception{
		//获取原始数据
		DeviceDetail deviceDetail = new DeviceDetail();
		Patient patient = patientDao.findByCode(patientDevice.getUser());
@ -126,13 +128,18 @@ public class DeviceDetailService extends BaseService {
		deviceDetail.setDeviceCode(patientDevice.getDeviceSn());
		deviceDetail.setDeviceName(patientDevice.getDeviceName());
		deviceDetail.setSim(patientDevice.getSim());
		deviceDetail.setIsGrant(1);
		deviceDetail.setGrantAdminTeam(adminTeam);
		deviceDetail.setGrantOrgCode(orgCode);
		deviceDetail.setIsBinding(1);
		deviceDetail.setGrantTime(patientDevice.getCzrq());
		deviceDetail.setApplyDate(DateUtil.getStringDate("yyyy-MM-dd HH:mm:ss"));
		deviceDetail.setOrgName(orgName);
		if (isBind>0){
			deviceDetail.setIsGrant(1);
			deviceDetail.setIsBinding(1);
		}else {
			deviceDetail.setIsGrant(0);
			deviceDetail.setIsBinding(0);
		}
		if (device!=null){
			deviceDetail.setDeviceModel(device.getModel());

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

@ -2,6 +2,7 @@ package com.yihu.wlyy.service.app.device;
import com.yihu.device.entity.DeviceDetail;
import com.yihu.wlyy.entity.device.*;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
@ -13,6 +14,7 @@ import com.yihu.wlyy.repository.deviece.DeviceDao;
import com.yihu.wlyy.repository.deviece.PatientBloodSuggerDao;
import com.yihu.wlyy.repository.deviece.PatientHealthTimeDao;
import com.yihu.wlyy.repository.dict.Icd10DictDao;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelInfoDao;
@ -110,6 +112,10 @@ public class PatientDeviceService extends BaseService {
    private Icd10DictDao icd10DictDao;
    @Autowired
    private PatientDeviceLogDao patientDeviceLogDao;
    @Autowired
    private DeviceDetailService deviceDetailService;
    @Autowired
    private SystemDictDao systemDictDao;
    //健康问题 高血压
    private static final String gxy = "HP0093";
    //健康问题 糖尿病
@ -1202,6 +1208,24 @@ public class PatientDeviceService extends BaseService {
            keyType = "2";
        }
        DeviceDetail deviceDetail = deviceDetailDao.findBySn(deviceSn);
        if(deviceDetail==null){
            SignFamily signFamily = signFamilyDao.findByPatient(patientDevice.getUser());
            Long adminTeam=0L;
            String orgCode ="";
            String orgName="";
            String bingCount="";
            if (Integer.valueOf(userType)>0){
                bingCount="{\"1\":\"0\",\"2\":\"0\"}";
            }else {
                bingCount="{\"1\":\"0\"}";
            }
            if (signFamily!=null){
                adminTeam = signFamily.getAdminTeamId();
                orgCode = signFamily.getHospital();
                orgName=signFamily.getHospitalName();
            }
            deviceDetailService.insertDevice(patientDevice,String.valueOf(adminTeam),orgName,orgCode,bingCount,0);
        }
        if (deviceDetail!=null && StringUtils.isNotEmpty(deviceDetail.getBindingCount())){
            JSONObject jsonObject =new JSONObject(String.valueOf(deviceDetail.getBindingCount()));
            if (jsonObject.getInt(keyType)>0){
@ -1209,10 +1233,6 @@ public class PatientDeviceService extends BaseService {
                msg="设备不是首次绑定";
                code = -20000;
            }
        }else {
            flag=false;
            msg="数据有问题!";
            code= -30000;
        }
        resultMap.put("flag",flag);
        resultMap.put("msg",msg);
@ -1228,7 +1248,7 @@ public class PatientDeviceService extends BaseService {
     */
    public Map<String,Object> checkBindingDeviceSn(String deviceSn) throws Exception{
        Boolean flag = false;
        String message = "";
        String message = "设备不存在!";
        Integer resultCode = 200;
        Map<String, String> params = new HashMap<>();
        params.put("deviceSn", deviceSn);
@ -1244,13 +1264,17 @@ public class PatientDeviceService extends BaseService {
            if ("10000".equals(code) || "10001".equals(code)) {
                flag = true;
            }else {
                String sql ="select count(*) num from device.wlyy_devices where device_code = '"+deviceSn+"'";
                Map<String,Object> map  = jdbcTemplate.queryForMap(sql);
                if (Integer.valueOf(String.valueOf(map.get("num")))>0){
                    flag = true ;
                }else {
                    resultCode = -10001;
                    message="没有该设备!";
                String systemValue = systemDictDao.findByDictNameAndCode("ACTIVITY_RANGE","2");
                if (StringUtils.isNotEmpty(systemValue) && "350205".equals(systemValue)){
                    //活动范围在海沧区
                    String sql ="select count(*) num from device.wlyy_devices where device_code = '"+deviceSn+"'";
                    Map<String,Object> map  = jdbcTemplate.queryForMap(sql);
                    if (Integer.valueOf(String.valueOf(map.get("num")))>0){
                        flag = true ;
                    }else {
                        resultCode = -10001;
                        message="没有该设备!";
                    }
                }
            }
        }else {
@ -1259,14 +1283,14 @@ public class PatientDeviceService extends BaseService {
            flag = false;
        }
        String sql ="select count(*) num from device.wlyy_devices where device_code = '"+deviceSn+"'";
        /*String sql ="select count(*) num from device.wlyy_devices where device_code = '"+deviceSn+"'";
        Map<String,Object> map  = jdbcTemplate.queryForMap(sql);
        if (Integer.valueOf(String.valueOf(map.get("num")))>0){
            flag = true ;
        }else {
            resultCode = -10001;
            message="没有该设备!";
        }
        }*/
        Map<String,Object> map1 = new HashedMap();
        map1.put("code",resultCode);

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

@ -63,6 +63,10 @@ public class AdminTeamService extends BaseService {
    @Autowired
    JdbcTemplate jdbcTemplate;
    public AdminTeamMember findByTeamIdAndDoctorCode(Long teamCode,String doctor){
      return  memberDao.findByTeamIdAndDoctorCodeAndAvailable(teamCode,doctor,true);
    }
    /**
     * 根据医生code返回所有团队的医生
     * (pc端im使用)

+ 9 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/QrcodeService.java

@ -1,11 +1,13 @@
package com.yihu.wlyy.service.common;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeamMember;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.address.Town;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.repository.address.TownDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.service.BaseService;
@ -44,6 +46,8 @@ public class QrcodeService extends BaseService {
    private String server_url;
    @Autowired
    private DoctorAdminTeamDao doctorAdminTeamDao;
    @Autowired
    private DoctorAdminTeamMemberDao memberDao;
    /**
     * 所有医生二维码生成
     *
@ -88,20 +92,21 @@ public class QrcodeService extends BaseService {
     * @return
     * @throws Exception
     */
    public boolean makeSpecialistQrcode(Doctor doc,Long teamCode, String token) throws Exception {
    public boolean makeSpecialistQrcode(AdminTeamMember doc, Long teamCode, String token) throws Exception {
        AdminTeam adminTeam = doctorAdminTeamDao.findOne(teamCode);
        Doctor d = doctorDao.findByCode(doc.getDoctorCode());
        if (doc != null&&adminTeam!=null) {
            // 二维码内容
            String content = "sp_disease_" + doc.getCode() +"_"+teamCode+ "_" + doc.getName();
            String content = "sp_disease_" + d.getCode() +"_"+teamCode+ "_" + d.getName();
            // 二维码图片文件名
            String fileName = doc.getMobile();
            String fileName = teamCode+"_"+d.getMobile();
            String path = QrcodeService.class.getResource("/").getPath().replace("/WEB-INF/classes/", "")
                    + File.separator + "qrcode";
            // 通过微信接口生成医生二维码
            makeQrcodeFromWeiXin(content, fileName.replaceAll("\r\n", ""), path, token);
            doc.setQrcode(fileName + ".png");
            doctorDao.save(doc);
            memberDao.save(doc);
            return true;
        } else {
            throw new Exception("找不到对应医生信息!");

+ 313 - 118
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java

@ -4,11 +4,21 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.specialist.PatientDiseaseServer;
import com.yihu.wlyy.entity.specialist.SpecialDisease;
import com.yihu.wlyy.entity.specialist.TeamDiseaseRelation;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelInfoDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.specialist.PatientDiseaseServerDao;
import com.yihu.wlyy.repository.specialist.SpecialDiseaseDao;
import com.yihu.wlyy.repository.specialist.TeamDiseaseRelationDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
@ -29,6 +39,8 @@ import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import static com.yihu.wlyy.service.common.util.ManageUtilService.page;
/**
 * Created by Trick on 2018/5/31.
 */
@ -36,6 +48,9 @@ import java.util.logging.Logger;
@Transactional
public class SpecialistService extends BaseService {
    private static org.slf4j.Logger logger = LoggerFactory.getLogger(SpecialistService.class);
    @Autowired
    private SignPatientLabelDao signPatientLabelDao;
    @Autowired
@ -48,12 +63,22 @@ public class SpecialistService extends BaseService {
    private String specialistUrl;
    @Autowired
    private DoctorAdminTeamDao doctorAdminTeamDao;
    @Autowired
    private TeamDiseaseRelationDao teamDiseaseRelationDao;
    @Autowired
    private PatientDiseaseServerDao patientDiseaseServerDao;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private SpecialDiseaseDao specialDiseaseDao;
    @Autowired
    private MessageDao messageDao;
    public String setPatientLabelInfo(List<SignPatientLabelInfo> list){
        if(list!=null&&list.size()>0){
            for(SignPatientLabelInfo signPatientLabelInfo : list){
                List<SignPatientLabelInfo> s =  signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(signPatientLabelInfo.getPatient(),signPatientLabelInfo.getLabelType(),1);
                if(s==null||s.size()==0){
    public String setPatientLabelInfo(List<SignPatientLabelInfo> list) {
        if (list != null && list.size() > 0) {
            for (SignPatientLabelInfo signPatientLabelInfo : list) {
                List<SignPatientLabelInfo> s = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(signPatientLabelInfo.getPatient(), signPatientLabelInfo.getLabelType(), 1);
                if (s == null || s.size() == 0) {
                    signPatientLabelInfo.setCzrq(new Date());
                    signPatientLabelInfo.setStatus(1);
                    signPatientLabelInfoDao.save(signPatientLabelInfo);
@ -63,9 +88,9 @@ public class SpecialistService extends BaseService {
        return "1";
    }
    public List<Map<String,Object>> findHealthAssistant(String doctor){
    public List<Map<String, Object>> findHealthAssistant(String doctor) {
        String sql="SELECT " +
        String sql = "SELECT " +
                " d.`code`, " +
                " d.`name`, " +
                " d.photo, " +
@ -83,172 +108,173 @@ public class SpecialistService extends BaseService {
                "  FROM " +
                "   wlyy_admin_team t " +
                "  WHERE " +
                "   t.leader_code = '"+doctor+"' " +
                "   t.leader_code = '" + doctor + "' " +
                " )";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    public List<Map<String,Object>> findHealthAssistantPatientCount(String doctor)throws Exception{
        List<Map<String,Object>> list = findHealthAssistant(doctor);
        if(list!=null&&list.size()>0){
            for(Map<String,Object> map:list){
                map.put("count",getAssistantPatientCount(doctor,map.get("code").toString()));
    public List<Map<String, Object>> findHealthAssistantPatientCount(String doctor) throws Exception {
        List<Map<String, Object>> list = findHealthAssistant(doctor);
        if (list != null && list.size() > 0) {
            for (Map<String, Object> map : list) {
                map.put("count", getAssistantPatientCount(doctor, map.get("code").toString()));
            }
        }
        return list;
    }
    public Long getAssistantPatientCount(String doctor,String assistant)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        param.put("assistant",assistant);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"svr-specialist/getAssistantPatientCount",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
    public Long getAssistantPatientCount(String doctor, String assistant) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("doctor", doctor);
        param.put("assistant", assistant);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/getAssistantPatientCount", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
            return rs.getLong("obj");
        }
        return 0L;
    }
    public JSONObject findPatientNoAssistant(String doctor,Integer page,Integer size)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        param.put("page",page);
        param.put("size",size);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"svr-specialist/findPatientNoAssistant",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
    public JSONObject findPatientNoAssistant(String doctor, Integer page, Integer size) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("doctor", doctor);
        param.put("page", page);
        param.put("size", size);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/findPatientNoAssistant", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
            return rs;
        }
        return rs;
    }
    public List<SignPatientLabel> findLabelbyType(String type,Long teamCode){
    public List<SignPatientLabel> findLabelbyType(String type, Long teamCode) {
        //自定义标签
        if("4".equals(type)){
            List<SignPatientLabel> list = signPatientLabelDao.findByLabelTypeAndStatusAndTeamCode(type,1,teamCode);
        if ("4".equals(type)) {
            List<SignPatientLabel> list = signPatientLabelDao.findByLabelTypeAndStatusAndTeamCode(type, 1, teamCode);
            return list;
        }else{
        } else {
            //非自定义标签
            List<SignPatientLabel> list = signPatientLabelDao.findByLabelTypeAndStatus(type,1);
            List<SignPatientLabel> list = signPatientLabelDao.findByLabelTypeAndStatus(type, 1);
            return list;
        }
    }
    public List<Map<String,Object>> findLabelAndPatientCount(String doctor,String type,Long teamCode)throws Exception{
    public List<Map<String, Object>> findLabelAndPatientCount(String doctor, String type, Long teamCode) throws Exception {
        //自定义标签
        if("4".equals(type)){
            List<SignPatientLabel> list = signPatientLabelDao.findByLabelTypeAndStatusAndTeamCode(type,1,teamCode);
        if ("4".equals(type)) {
            List<SignPatientLabel> list = signPatientLabelDao.findByLabelTypeAndStatusAndTeamCode(type, 1, teamCode);
            return setPatientCount(list,doctor);
        }else{
            return setPatientCount(list, doctor);
        } else {
            //非自定义标签
            List<SignPatientLabel> list = signPatientLabelDao.findByLabelTypeAndStatus(type,1);
            List<SignPatientLabel> list = signPatientLabelDao.findByLabelTypeAndStatus(type, 1);
            return setPatientCount(list,doctor);
            return setPatientCount(list, doctor);
        }
    }
    public List<Map<String,Object>> setPatientCount(List<SignPatientLabel> list,String doctor)throws Exception{
        List<Map<String,Object>> rs = new ArrayList<>();
        if(list!=null&&list.size()>0){
            for(SignPatientLabel label:list){
                Map<String,Object> map = new HashedMap();
                map.put("label",label.getLabelCode());
                map.put("labelName",label.getLabelName());
                map.put("labelType",label.getLabelType());
                map.put("count",getLabelpatientCount(doctor,label.getLabelCode(),label.getLabelType()));
    public List<Map<String, Object>> setPatientCount(List<SignPatientLabel> list, String doctor) throws Exception {
        List<Map<String, Object>> rs = new ArrayList<>();
        if (list != null && list.size() > 0) {
            for (SignPatientLabel label : list) {
                Map<String, Object> map = new HashedMap();
                map.put("label", label.getLabelCode());
                map.put("labelName", label.getLabelName());
                map.put("labelType", label.getLabelType());
                map.put("count", getLabelpatientCount(doctor, label.getLabelCode(), label.getLabelType()));
                rs.add(map);
            }
        }
        return rs;
    }
    public Long getLabelpatientCount(String doctor,String labelType,String labelCode)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        param.put("labelType",labelType);
        param.put("labelCode",labelCode);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"svr-specialist/getLabelpatientCount",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
    public Long getLabelpatientCount(String doctor, String labelType, String labelCode) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("doctor", doctor);
        param.put("labelType", labelType);
        param.put("labelCode", labelCode);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/getLabelpatientCount", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
            return rs.getLong("obj");
        }
        return 0L;
    }
    public Long findSpecialistPatientRelationCout(String doctor)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"svr-specialist/findSpecialistPatientRelationCout",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
    public Long findSpecialistPatientRelationCout(String doctor) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("doctor", doctor);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/findSpecialistPatientRelationCout", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
            return rs.getLong("obj");
        }
        return 0L;
    }
    public JSONArray findNoLabelPatientRelation(String doctor)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"svr-specialist/findNoLabelPatientRelation",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
    public JSONArray findNoLabelPatientRelation(String doctor) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("doctor", doctor);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/findNoLabelPatientRelation", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
            return rs.getJSONArray("obj");
        }
        return null;
    }
    public JSONArray findPatientRelatioByAssistant(String doctor,String assistant,Integer page,Integer size)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        param.put("assistant",assistant);
        param.put("page",page);
        param.put("size",size);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"svr-specialist/findPatientRelatioByAssistant",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
    public JSONArray findPatientRelatioByAssistant(String doctor, String assistant, Integer page, Integer size) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("doctor", doctor);
        param.put("assistant", assistant);
        param.put("page", page);
        param.put("size", size);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/findPatientRelatioByAssistant", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
            return rs.getJSONArray("obj");
        }
        return null;
    }
    public Boolean saveHealthAssistant(String json)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("json",json);
        HttpResponse response = HttpUtils.doPost(specialistUrl+"svr-specialist/saveHealthAssistant",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
    public Boolean saveHealthAssistant(String json) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("json", json);
        HttpResponse response = HttpUtils.doPost(specialistUrl + "svr-specialist/saveHealthAssistant", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
            return rs.getBoolean("obj");
        }
        return false;
    }
    public JSONArray getPatientByLabel(String doctor,String labelType,String labelCode,Integer page,Integer size)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        param.put("labelType",labelType);
        param.put("labelCode",labelCode);
        param.put("page",page);
        param.put("size",size);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"svr-specialist/getPatientByLabel",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
    public JSONArray getPatientByLabel(String doctor, String labelType, String labelCode, Integer page, Integer size) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("doctor", doctor);
        param.put("labelType", labelType);
        param.put("labelCode", labelCode);
        param.put("page", page);
        param.put("size", size);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/getPatientByLabel", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
            return rs.getJSONArray("obj");
        }
        return null;
    }
    public Map<String,Object> findDoctorTeamMenmber(String doctor){
    public Map<String, Object> findDoctorTeamMenmber(String doctor) {
        Map<String,Object> rs = new HashedMap();
        Map<String, Object> rs = new HashedMap();
        AdminTeam adminTeam =  doctorAdminTeamDao.findByLeaderCode(doctor);
        AdminTeam adminTeam = doctorAdminTeamDao.findByLeaderCode(doctor);
        rs.put("adminTeam",adminTeam);
        rs.put("adminTeam", adminTeam);
        String sql = "SELECT " +
                " d.`code`, " +
@ -269,16 +295,16 @@ public class SpecialistService extends BaseService {
                "  FROM " +
                "   wlyy_admin_team t " +
                "  WHERE " +
                "   t.leader_code = '"+doctor+"' " +
                "   t.leader_code = '" + doctor + "' " +
                " )";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        rs.put("member",list);
        rs.put("member", list);
        return rs;
    }
    public List<Map<String,Object>> getDoctorInHospital(String doctor,String name,Integer page,Integer size){
    public List<Map<String, Object>> getDoctorInHospital(String doctor, String name, Integer page, Integer size) {
        String sql = "SELECT " +
                " d. name, " +
                " d. code, " +
@ -296,31 +322,200 @@ public class SpecialistService extends BaseService {
                "  FROM " +
                "   wlyy_doctor dd " +
                "  WHERE " +
                "   dd. CODE = '"+doctor+"' " +
                " ) " ;
        if(StringUtils.isNotBlank(name)){
            sql = sql +" AND d.`name` LIKE '%"+name+"%'";
                "   dd. CODE = '" + doctor + "' " +
                " ) ";
        if (StringUtils.isNotBlank(name)) {
            sql = sql + " AND d.`name` LIKE '%" + name + "%'";
        }
        sql = sql +" LIMIT "+(page-1)*size+","+size;
        sql = sql + " LIMIT " + (page - 1) * size + "," + size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    public JSONArray getDoctorPatientByName(String doctor,String nameKey,Integer page,Integer size) throws Exception{
    public JSONArray getDoctorPatientByName(String doctor, String nameKey, Integer page, Integer size) throws Exception {
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        param.put("nameKey",nameKey);
        param.put("page",page);
        param.put("size",size);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"svr-specialist/getDoctorPatientByName",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
        Map<String, Object> param = new HashedMap();
        param.put("doctor", doctor);
        param.put("nameKey", nameKey);
        param.put("page", page);
        param.put("size", size);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/getDoctorPatientByName", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
            return rs.getJSONArray("obj");
        }
        return null;
    }
    public List<Map<String, Object>> getSpecialistTeamList(String doctor) {
        String sql = "SELECT " +
                " t.id, " +
                " t.name, " +
                " d.photo " +
                " FROM " +
                " wlyy_admin_team t " +
                " JOIN wlyy_admin_team_member m ON t.id = m.team_id " +
                " JOIN wlyy_doctor d ON d.code = t.leader_code " +
                " WHERE " +
                " m.doctor_code = '" + doctor + "' " +
                " AND t.available ='1' " +
                " AND m.available ='1' ";
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
        if (rs != null && rs.size() > 0) {
            for (Map<String, Object> team : rs) {
                Integer id = (Integer) team.get("id");
                String sqlMember = "SELECT " +
                        " d.name, " +
                        " d.code " +
                        " FROM " +
                        " wlyy_admin_team_member m " +
                        " JOIN wlyy_doctor d ON m.doctor_code = d.`code` " +
                        " WHERE " +
                        " m.team_id =" + id +
                        " AND m.available='1'";
                List<Map<String, Object>> list = jdbcTemplate.queryForList(sqlMember);
                team.put("doctors", list);
            }
            return rs;
        }
        return rs;
    }
    public Map<String, Object> findSpecialistTeamInfo(String doctor, Long teamCode) {
        String sql = "SELECT t.id, " +
                " t. NAME, " +
                " d.photo " +
                " FROM " +
                " wlyy_admin_team t " +
                " JOIN wlyy_admin_team_member m ON t.id = m.team_id " +
                " JOIN wlyy_doctor d ON d. CODE = t.leader_code " +
                " WHERE " +
                " m.doctor_code = '" + doctor + "' " +
                " AND t.available = '1' " +
                " AND m.available = '1' " +
                " ANd m.team_id=" + teamCode;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        if (list != null && list.size() > 0) {
            Map<String, Object> map = list.get(0);
            String sqlMember = "SELECT " +
                    " d.name, " +
                    " d.code " +
                    " FROM " +
                    " wlyy_admin_team_member m " +
                    " JOIN wlyy_doctor d ON m.doctor_code = d.`code` " +
                    " WHERE " +
                    " m.team_id =" + teamCode +
                    " AND m.available='1'";
            List<Map<String, Object>> members = jdbcTemplate.queryForList(sqlMember);
            map.put("doctors", members);
            return map;
        }
        return null;
    }
    public List<TeamDiseaseRelation> findTeamDiseaseRelation(Long teamCode) {
        return teamDiseaseRelationDao.findByTeamCodeAndDel(teamCode, "1");
    }
    public List<PatientDiseaseServer> findPatientDiseaseServerList(String patient) {
        return patientDiseaseServerDao.findByPatientAndDel(patient, "1");
    }
    public Map<String, Object> signSpecialist(String patient, String doctor, String disease, Long teamCode) throws Exception {
        Map<String, Object> mes = new HashedMap();
        Patient p = patientDao.findByCode(patient);
        Doctor d = doctorDao.findByCode(doctor);
        SpecialDisease dis = specialDiseaseDao.findByCode(disease);
        if (p != null && d != null && dis != null) {
            Map<String, Object> param = new HashedMap();
            param.put("doctor", doctor);
            param.put("doctorName", d.getName());
            param.put("patient", patient);
            param.put("patientName", p.getName());
            param.put("teamCode", teamCode);
            HttpResponse response = HttpUtils.doPost(specialistUrl + "svr-specialist/signSpecialistTeam", param);
            JSONObject rs = new JSONObject(response.getContent());
            if ("succes".equals(rs.getString("message"))) {
                // 保存居民病种
                PatientDiseaseServer server = new PatientDiseaseServer();
                server.setCode(getCode());
                server.setDel("1");
                server.setSpecialistRelationCode(rs.getString("obj"));
                server.setPatient(patient);
                server.setPatientName(p.getName());
                server.setDisease(dis.getCode());
                server.setDiseaseName(dis.getName());
                server.setCreateTime(new Date());
                patientDiseaseServerDao.save(server);
                // 添加签约申请消息
                Message message = new Message();
                message.setCzrq(new Date());
                message.setCreateTime(new Date());
                message.setContent("您有一个居民申请共管服务!");
                message.setRead(1);//设置未读
                message.setReceiver(doctor);//设置接受医生的code
                message.setSender(patient);//设置发送的用户
                message.setSenderName(p.getName());
                message.setCode(getCode());
                message.setSenderPhoto(p.getPhoto());
                message.setTitle("专科医生共管申请");
                message.setType(16);//家庭签约取消信息
                message.setReadonly(1);//是否只读消息
                message.setSex(p.getSex());
                message.setOver("1");//未处理
                message.setRelationCode(rs.getString("obj"));
                message.setDel("1");
                message.setState(1);
                messageDao.save(message);
                mes.put("code", 1);
                mes.put("mes", "签约成功!");
                mes.put("data", "");
                return mes;
            } else if ("doctor_exist".equals(rs.getString("message"))) {
                mes.put("code", -1);
                mes.put("mes", "医生与患者已经签约");
                mes.put("data", rs.getJSONObject("obj"));
            } else if ("team_exist".equals(rs.getString("message"))){
                mes.put("code", -2);
                mes.put("mes", "团队与患者已经签约");
                mes.put("data", rs.getJSONObject("obj"));
            } else {
                logger.info(response.getContent());
            }
        }
        mes.put("code",-3);
        mes.put("mes","获取居民信息失败");
        mes.put("data", "");
        return mes;
    }
    public String agreeSpecialistTeam(String state,String relationCode,String remark,Long mesId)throws Exception{
        Map<String, Object> param = new HashedMap();
        param.put("state", state);
        param.put("relationCode", relationCode);
        param.put("remark", remark);
        HttpResponse response = HttpUtils.doPost(specialistUrl + "svr-specialist/agreeSpecialistTeam", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
            if(mesId!=null){
                Message m = messageDao.findOne(mesId);
                m.setOver("0");
                m.setRead(0);
                messageDao.save(m);
            }
            return "1";
        }
        return "0";
    }
}

+ 6 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/qrcode/QrCodeController.java

@ -1,6 +1,8 @@
package com.yihu.wlyy.web.common.qrcode;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeamMember;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.common.QrcodeService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.web.WeixinBaseController;
@ -36,6 +38,8 @@ public class QrCodeController extends WeixinBaseController {
    private QrcodeService qrcodeService;
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private AdminTeamService adminTeamService;
    @RequestMapping(value = "/doctors",method = {RequestMethod.GET,RequestMethod.POST})
    @ResponseBody
@ -304,7 +308,7 @@ public class QrCodeController extends WeixinBaseController {
    /**
     * 下载某个医生的二维码
     * 下载专科医生团队二维码
     *
     * @param doctor
     * @param response
@ -315,7 +319,7 @@ public class QrCodeController extends WeixinBaseController {
                                        HttpServletResponse response) {
        try {
            //logger.info("------------------specialist_img:" + doctor);
            Doctor doc = doctorService.findDoctorByCode(doctor);
            AdminTeamMember doc = adminTeamService.findByTeamIdAndDoctorCode(teamCode,doctor);
            if (doc != null) {
                if (StringUtils.isEmpty(doc.getQrcode())) {

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

@ -409,7 +409,7 @@ public class DataHandingService {
                }else if (Integer.valueOf(patientDevice.getUserType())<0){
                    bindCount = "{\"1\":\"1\"}";
                }
                deviceDetailService.insertDevice(patientDevice,String.valueOf(patientDeviceMap.get("admin_team_code")),String.valueOf(patientDeviceMap.get("hospital_name")),String.valueOf(patientDeviceMap.get("hospital")),bindCount);
                deviceDetailService.insertDevice(patientDevice,String.valueOf(patientDeviceMap.get("admin_team_code")),String.valueOf(patientDeviceMap.get("hospital_name")),String.valueOf(patientDeviceMap.get("hospital")),bindCount,1);
            }
        }
        String[] sqlStr = new String[sqlList.size()];

+ 10 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -1087,12 +1087,20 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                }
                //查找患者最近的一次到期记录
                SignFamily jtSign = familyContractService.findOutTimeSigningByPatient(patient);
                JSONObject jtjson = new JSONObject(jtSign);
                //1.4.9新增健管师判断
                if(StringUtils.isNotBlank(jtSign.getDoctorHealth())){
                    Doctor doctor =  doctorService.findDoctorByCode(jtSign.getDoctorHealth());
                    if("0".equals(doctor.getDel())){
                        jtjson.put("doctorHealth","");
                        jtjson.put("doctorHealthName","");
                    }
                }
                // 家庭签约
                if (jtSign != null) {
                    json.put("applySurrDate", jtSign.getPatientApplyUnsignDate());
                    json.put("applyDate", jtSign.getPatientApplyDate());
                    json.put("jtSign", new JSONObject(jtSign));
                    json.put("jtSign",jtjson);
                }
                json.put("countryCode", temp.getSickVillage() == null ? "" : temp.getSickVillage());

+ 28 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistController.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.web.doctor.specialist;
import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.service.specialist.SpecialistService;
import com.yihu.wlyy.web.BaseController;
@ -124,6 +125,7 @@ public class SpecialistController extends BaseController {
    @RequestMapping(value = "saveHealthAssistant", method = RequestMethod.POST)
    @ApiOperation("分配计管师居民")
    @ObserverRequired
    public String saveHealthAssistant(String json) {
        try {
            return write(200, "获取成功", "data", specialistService.saveHealthAssistant(json));
@ -199,4 +201,30 @@ public class SpecialistController extends BaseController {
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "getSpecialistTeamList", method = RequestMethod.GET)
    @ApiOperation(value = "获取专科医生所在团队信息列表")
    public String getSpecialistTeamList(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor) {
        try {
            return write(200, "获取成功", "data", specialistService.getSpecialistTeamList(doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/agreeSpecialistTeam", method = RequestMethod.GET)
    @ApiOperation(value = "医生审核")
    @ObserverRequired
    public String agreeSpecialistTeam(@ApiParam(name = "state", value = "状态0为拒绝,1为同意") @RequestParam(required = true)String state,
                                      @ApiParam(name = "relationCode", value = "关联code") @RequestParam(required = true)String relationCode,
                                      @ApiParam(name = "remark", value = "审核失败原因") @RequestParam(required = false)String remark,
                                      @ApiParam(name = "mesId", value = "消息Id") @RequestParam(required = false)Long mesId)throws Exception {
        try {
            return write(200, "获取成功", "data", specialistService.agreeSpecialistTeam( state, relationCode, remark, mesId));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
}

+ 91 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/specialist/PatientSpecialistController.java

@ -0,0 +1,91 @@
package com.yihu.wlyy.web.patient.specialist;
import com.yihu.wlyy.entity.specialist.PatientDiseaseServer;
import com.yihu.wlyy.entity.specialist.TeamDiseaseRelation;
import com.yihu.wlyy.service.specialist.SpecialistService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
 * Created by Trick on 2018/7/3.
 */
@RestController
@RequestMapping(value = "/patient/specialist", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "患者端-专病管理")
public class PatientSpecialistController extends BaseController{
    @Autowired
    private SpecialistService specialistService;
    @RequestMapping(value = "/findSpecialistTeamInfo", method = RequestMethod.GET)
    @ApiOperation(value = "获取专科医生所在团队信息")
    public String findSpecialistTeamInfo(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor,
                                         @ApiParam(name = "teamCode", value = "团队code") @RequestParam(required = true)Long teamCode){
        try {
            return write(200, "获取成功", "data", specialistService.findSpecialistTeamInfo(doctor,teamCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/findTeamDiseaseRelation", method = RequestMethod.GET)
    @ApiOperation(value = "获取团队专病服务信息")
    public String findTeamDiseaseRelation(@ApiParam(name = "teamCode", value = "团队code") @RequestParam(required = true)Long teamCode) {
        try {
            return write(200, "获取成功", "data", specialistService.findTeamDiseaseRelation(teamCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/findPatientDiseaseServerList", method = RequestMethod.GET)
    @ApiOperation(value = "获取居民专病服务信息")
    public String findPatientDiseaseServerList(@ApiParam(name = "patient", value = "患者code") @RequestParam(required = true)String patient) {
        try {
            return write(200, "获取成功", "data", specialistService.findPatientDiseaseServerList(patient));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/signSpecialist", method = RequestMethod.GET)
    @ApiOperation(value = "居民提交专科医生团队签约申请")
    public String signSpecialist(@ApiParam(name = "patient", value = "患者code") @RequestParam(required = true)String patient,
                                 @ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor,
                                 @ApiParam(name = "disease", value = "疾病code") @RequestParam(required = true)String disease,
                                 @ApiParam(name = "teamCode", value = "团队code") @RequestParam(required = true)Long teamCode) throws Exception {
        try {
            return write(200, "获取成功", "data", specialistService.signSpecialist(patient,doctor,disease,teamCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/agreeSpecialistTeam", method = RequestMethod.GET)
    @ApiOperation(value = "医生审核")
    public String agreeSpecialistTeam(String state,String relationCode,String remark,Long mesId)throws Exception {
        try {
            return write(200, "获取成功", "data", specialistService.agreeSpecialistTeam( state, relationCode, remark, mesId));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
//----
}

+ 9 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java

@ -112,9 +112,15 @@ public class OnePayController extends WeixinBaseController {
                ssc = people.getSsc();
            }
            if("undefined".equals(openid)||StringUtils.isEmpty(openid)){
                people.setOpenid(null);
                patientDao.save(people);
                return write(-1, "用户微信信息格式不正确!");
                if(StringUtils.isBlank(getOpenid())){
                    people.setOpenid(null);
                    patientDao.save(people);
                    return write(998, "用户微信信息格式不正确!");
                }else {
                    openid = getOpenid();
                    people.setOpenid(getOpenid());
                    patientDao.save(people);
                }
            }
//            BindCard bindCard = pay.bindCard(patient, openid);