Bladeren bron

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

8 jaren geleden
bovenliggende
commit
35e48c08ce
53 gewijzigde bestanden met toevoegingen van 2282 en 1871 verwijderingen
  1. 19 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/education/HealthEduArticlePatient.java
  2. 31 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/followup/Followup.java
  3. 10 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/Patient.java
  4. 19 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientHealthGuidance.java
  5. 18 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientReservation.java
  6. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/consult/ConsultDao.java
  7. 2 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java
  8. 8 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java
  9. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientHealthGuidanceDao.java
  10. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientReservationDao.java
  11. 35 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  12. 578 563
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  13. 127 89
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/HealthEduArticleService.java
  14. 44 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthGuidanceService.java
  15. 20 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  16. 3 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reservation/PatientReservationService.java
  17. 90 20
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  18. 5 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  19. 102 122
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java
  20. 4 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java
  21. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/area/AreaController.java
  22. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/hospital/HospitalCommonController.java
  23. 9 16
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/qrcode/QrCodeController.java
  24. 0 10
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java
  25. 0 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/WlyySerivceController.java
  26. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/verified/VerifiedController.java
  27. 0 9
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java
  28. 24 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java
  29. 0 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/discussion/DoctorDiscussionGroupController.java
  30. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/family/DoctorFamilyController.java
  31. 325 305
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java
  32. 443 364
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java
  33. 34 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthGuidanceController.java
  34. 291 273
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java
  35. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/DoctorPatientGroupController.java
  36. 0 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientDiseaseController.java
  37. 0 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelController.java
  38. 0 6
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  39. 0 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/reply/DoctorQuickReplyController.java
  40. 0 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/scheduling/DoctorWorkTimeController.java
  41. 18 10
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  42. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java
  43. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java
  44. 0 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java
  45. 0 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  46. 0 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/family/FamilyMemberController.java
  47. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthGuidanceController.java
  48. 0 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java
  49. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/quota/JobController.java
  50. 0 8
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java
  51. 4 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java
  52. 0 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/WechatCoreController.java
  53. 12 12
      patient-co-wlyy/src/main/webapp/WEB-INF/web.xml

+ 19 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/education/HealthEduArticlePatient.java

@ -41,6 +41,10 @@ public class HealthEduArticlePatient extends IdEntity {
	private Integer read;
	// 发布时间
	private Date czrq;
	// 签约类型 1三师 2家庭
	private Integer signType;
	// 行政团队
	private Long adminTeamCode;
	public String getPatient() {
		return patient;
@ -116,4 +120,19 @@ public class HealthEduArticlePatient extends IdEntity {
		this.czrq = czrq;
	}
	public Integer getSignType() {
		return signType;
	}
	public void setSignType(Integer signType) {
		this.signType = signType;
	}
	public Long getAdminTeamCode() {
		return adminTeamCode;
	}
	public void setAdminTeamCode(Long adminTeamCode) {
		this.adminTeamCode = adminTeamCode;
	}
}

+ 31 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/followup/Followup.java

@ -53,8 +53,14 @@ public class Followup extends IdEntity {
	private String followupContentPhone;
	//创建时间
	private Date createTime;
	//更新时间
	private Date updateTime;
	//创建者
	private String creater;
	// 签约类型 1三师 2家庭
	private Integer signType;
	// 行政团队
	private Long adminTeamCode;
	public Date getFollowupPlanDate() {
		return followupPlanDate;
@ -187,6 +193,15 @@ public class Followup extends IdEntity {
		this.createTime = createTime;
	}
	@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;
	}
	public String getStatus() {
		return status;
	}
@ -210,4 +225,20 @@ public class Followup extends IdEntity {
	public void setCreater(String creater) {
		this.creater = creater;
	}
	public Integer getSignType() {
		return signType;
	}
	public void setSignType(Integer signType) {
		this.signType = signType;
	}
	public Long getAdminTeamCode() {
		return adminTeamCode;
	}
	public void setAdminTeamCode(Long adminTeamCode) {
		this.adminTeamCode = adminTeamCode;
	}
}

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

@ -83,6 +83,8 @@ public class Patient extends IdEntity implements Serializable {
	private Date czrq;
	// 微信编号
	private String openid;
	//微信时间
	private Date openidTime;
	// 用户状态:1正常,0禁用,-1恶意注册,2审核中
	private Integer status;
@ -344,4 +346,12 @@ public class Patient extends IdEntity implements Serializable {
	public void setMobileRemarks(String mobileRemarks) {
		this.mobileRemarks = mobileRemarks;
	}
	public Date getOpenidTime() {
		return openidTime;
	}
	public void setOpenidTime(Date openidTime) {
		this.openidTime = openidTime;
	}
}

+ 19 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientHealthGuidance.java

@ -36,6 +36,10 @@ public class PatientHealthGuidance extends IdEntity {
	private String del;
	// 添加时间
	private Date czrq;
	// 签约类型 1三师 2家庭
	private Integer signType;
	// 行政团队
	private Long adminTeamCode;
	public String getPatient() {
		return patient;
@ -94,4 +98,19 @@ public class PatientHealthGuidance extends IdEntity {
		this.voice = voice;
	}
	public Integer getSignType() {
		return signType;
	}
	public void setSignType(Integer signType) {
		this.signType = signType;
	}
	public Long getAdminTeamCode() {
		return adminTeamCode;
	}
	public void setAdminTeamCode(Long adminTeamCode) {
		this.adminTeamCode = adminTeamCode;
	}
}

+ 18 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientReservation.java

@ -68,6 +68,10 @@ public class PatientReservation extends IdEntity {
	private Date czrq;
	// 0 健康之路 1智业
	private String type;
	// 签约类型 1三师 2家庭
	private Integer signType;
	// 行政团队
	private Long adminTeamCode;
	public String getCode() {
		return code;
@ -257,4 +261,18 @@ public class PatientReservation extends IdEntity {
		this.type = type;
	}
	public Integer getSignType() {
		return signType;
	}
	public void setSignType(Integer signType) {
		this.signType = signType;
	}
	public Long getAdminTeamCode() {
		return adminTeamCode;
	}
	public void setAdminTeamCode(Long adminTeamCode) {
		this.adminTeamCode = adminTeamCode;
	}
}

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

@ -30,4 +30,7 @@ public interface ConsultDao extends PagingAndSortingRepository<Consult, Long>, J
	@Query("select count(a) from Consult a,ConsultTeamDoctor b  where a.code = b.consult and a.patient=?1 and b.to=?2 and b.from is null")
	Integer findByPatient(String patientCode,String doctorCode);
	@Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.adminTeamId from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and b.adminTeamId = ?2 and a.del = '1' order by a.czrq desc")
	Page<Object> findByPatientAndTeam(String patient,Long team, Pageable pageRequest);
}

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java

@ -28,4 +28,6 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
    @Query(value = "select a.* from wlyy_followup a where a.doctor_code in ?1 and a.patient_code = ?2 and a.followup_class=?3 and a.status ='1' order by a.followup_date DESC limit 1",nativeQuery = true)
    Followup findLastFollowup(String[] doctors,String patientCode,String followClass) throws Exception;
    @Query("select d.code,d.name,d.photo,a.followupType,a.followupClass,a.status,a.createTime,a.updateTime from Followup a, Doctor d where a.doctorCode = d.code and a.patientCode = ?1 and a.adminTeamCode = ?2 ")
    Page<Object> findByPatientAndTeam(String patient, Long teamCode, Pageable pageable);
}

+ 8 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java

@ -53,4 +53,12 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query("select count(a) from Message a where a.read = 0 and a.over ='0'  and a.receiver=?1 and a.type=?2 ")
    int findMessageNum(String doctor, Integer type);
    @Query("update Message a set a.read = 0,a.over = '0' where a.receiver = ?1 and a.type = ?2")
    @Modifying
    int setMessageReaded(String doctor,Integer type);
    @Query("update Message a set a.read = 0,a.over = '0' where a.receiver = ?1 and a.type not in (1,2)")
    @Modifying
    int setSysMessageReaded(String doctor);
}

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

@ -54,4 +54,7 @@ public interface PatientHealthGuidanceDao extends PagingAndSortingRepository<Pat
	@Query("SELECT count(a) from PatientHealthGuidance a WHERE  a.patient=?2 and a.doctor=?1 ")
	Integer findbydoctorAndPatient(String doctor, String patientCode);
	@Query("select b.name, b.photo, a.id, a.content, a.czrq,b.level,b.code,a.adminTeamCode from PatientHealthGuidance a, Doctor b where a.doctor = b.code and a.patient = ?1 and a.adminTeamCode = ?2 and a.del = '1'")
	Page<Object> findByPatientAndTeamCode(String patient, Long teamCode, Pageable pageable);
}

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

@ -23,7 +23,7 @@ public interface PatientReservationDao extends PagingAndSortingRepository<Patien
	List<PatientReservation> findByPatient(String patient, Pageable page);
	List<PatientReservation> findByPatientAndDoctor(String patient,String doctor,Pageable page);
	List<PatientReservation> findByPatientAndAdminTeamCode(String patient,Long teamCode,Pageable page);
	List<PatientReservation> findByDoctor(String doctor,Pageable page);

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

@ -516,6 +516,41 @@ public class ConsultTeamService extends ConsultService {
        }
    }
    /**
     * 查询居民咨询记录
     *
     * @param patient
     * @param teamCode
     * @param page
     * @param pageSize
     * @return
     */
    public JSONArray findByPatientAndTeam(String patient, Long teamCode, int page, int pageSize) {
        PageRequest pageRequest = new PageRequest(page, pageSize);
        Patient p = patientDao.findByCode(patient);
        Page<Object> result = consultDao.findByPatientAndTeam(patient, teamCode, pageRequest);
        JSONArray array = new JSONArray();
        for (Object obj : result) {
            JSONObject consult = new JSONObject();
            Object[] objArr = (Object[]) obj;
            consult.put("id", objArr[0]);
            consult.put("code", objArr[2]);
            consult.put("type", objArr[1]);
            consult.put("title", objArr[3]);
            consult.put("symptoms", objArr[4]);
            consult.put("czrq", objArr[5]);
            consult.put("status", objArr[6]);
            consult.put("adminTeamCode", objArr[7]);
            consult.put("patient", patient);
            consult.put("patientName", p.getName());
            consult.put("patientPhoto", p.getPhoto());
            array.put(consult);
        }
        return array;
    }
    /**
     * 网络咨询咨询日志查询
     *

+ 578 - 563
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -21,8 +21,12 @@ import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.task.FollowupUploadTask;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
@ -36,589 +40,600 @@ import java.util.*;
/**
 * 随访服务
 * @author hzp add 2016-12-07
 *
 * @author hzp add 2016-12-07
 */
@Component
@Transactional(rollbackOn = Exception.class)
public class FollowUpService extends BaseService {
	@Autowired
	private DoctorDao doctorDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private PatientDao patientDao;
	@Autowired
	private PatientDao patientDao;
    @Autowired
    private FollowUpDao followupDao;
	@Autowired
	private FollowUpDao followupDao;
    @Autowired
    private FollowupContentDao followupContentDao;
	@Autowired
	private FollowupContentDao followupContentDao;
    @Autowired
    private SystemDictService systemDictService;
	@Autowired
	private SystemDictService systemDictService;
    @Autowired
    private ObjectMapper objectMapper;
	@Autowired
	private ObjectMapper objectMapper;
    @Autowired
    private SignFamilyDao signFamilyDao;
	@Autowired
	private SignFamilyDao signFamilyDao;
    @Autowired
    private DrHealthTeamService drHealthTeamService;
	@Autowired
	private DrHealthTeamService drHealthTeamService;
    @Autowired
    private MessageDao messageDao;
	@Autowired
	private MessageDao messageDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
	@Autowired
	private JdbcTemplate jdbcTemplate;
    @Autowired
    SystemDictService dictService;
	/**
	 * 转译随访信息
    /**
     * 转译随访信息
     */
    private Map<String, String> getFollowupDetail(Followup followup) throws Exception {
        Map<String, String> re = new HashMap<>();
        //患者信息
        String patientCode = followup.getPatientCode();
        Patient patient = patientDao.findByCode(patientCode);
        if (patient != null) {
            re.put("patientCode", patientCode);
            re.put("patientName", patient.getName());
            re.put("idcard", patient.getIdcard());
            String mobile = patient.getMobile();
            if (StringUtils.isEmpty(mobile)) {
                mobile = patient.getMobileRemarks();
            }
            re.put("mobile", mobile);
            re.put("sex", String.valueOf(patient.getSex()));
            re.put("birthday", DateUtil.dateToStrLong(patient.getBirthday()));
            re.put("photo", patient.getPhoto());
        } else {
            throw new Exception("not exit patient:" + patientCode);
        }
        re.put("id", String.valueOf(followup.getId()));
        re.put("followupNo", followup.getFollowupNo());
        re.put("followupDate", DateUtil.dateToStrLong(followup.getFollowupDate()));
        re.put("followupNextDate", DateUtil.dateToStrLong(followup.getFollowupNextDate()));
        //随访方式转译
        re.put("followupType", followup.getFollowupType());
        String followupTypeName = systemDictService.getDictValue("FOLLOWUP_WAY_DICT", followup.getFollowupType());
        re.put("followupTypeName", followupTypeName);
        //随访类别转译
        re.put("followupClass", followup.getFollowupClass());
        String followupClassName = systemDictService.getDictValue("FOLLOWUP_CLASS_DICT", followup.getFollowupClass());
        re.put("followupClassName", followupClassName);
        //随访管理状态转译
        re.put("followupManagerStatus", followup.getFollowupManagerStatus());
        String followupManagerStatusName = systemDictService.getDictValue("FOLLOWUP_MANAGER_STATUS", followup.getFollowupManagerStatus());
        re.put("followupManagerStatusName", followupManagerStatusName);
        re.put("doctorCode", followup.getDoctorCode());
        re.put("doctorName", followup.getDoctorName());
        re.put("orgCode", followup.getOrgCode());
        re.put("orgName", followup.getOrgName());
        re.put("dataFrom", followup.getDataFrom());
        re.put("status", followup.getStatus());
        re.put("followupContentPhone", followup.getFollowupContentPhone());
        re.put("createTime", DateUtil.dateToStrLong(followup.getCreateTime()));
        re.put("creater", followup.getCreater());
        return re;
    }
    /**
     * 获取医生随访列表
     */
    public List<Map<String, String>> getListByDoctor(String doctorCode, String startTime, String endTime, String page, String pageSize) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        // 排序
        Sort sort = new Sort(Sort.Direction.ASC, "followupDate");
        // 分页信息
        int pageInt = Integer.valueOf(page) - 1;
        int pageSizeInt = Integer.valueOf(pageSize);
        Pageable pageRequest = new PageRequest(pageInt, pageSizeInt, sort);
        List<Followup> list = followupDao.findByDoctor(doctorCode, DateUtil.strToDate(startTime), DateUtil.strToDate(endTime), pageRequest);
        if (list != null && list.size() > 0) {
            for (Followup followup : list) {
                Map<String, String> map = getFollowupDetail(followup);
                re.add(map);
            }
        }
        return re;
    }
    /**
     * 查询居民随访列表
     *
     * @param patient
     * @param teamCode
     * @param page
     * @param pageSize
     * @return
     */
    public JSONArray getListByPatientAndTeam(String patient, Long teamCode, int page, int pageSize) {
        PageRequest pageRequest = new PageRequest(page, pageSize);
        Page<Object> result = followupDao.findByPatientAndTeam(patient, teamCode, pageRequest);
        JSONArray array = new JSONArray();
        if (result != null && result.getContent().size() > 0) {
            Map<String, String> dictMap = new HashMap<>();
            Map<String, String> statusMap = new HashMap<>();
            List<SystemDict> dicts = dictService.getDictByDictName("FOLLOWUP_WAY_DICT");
            if (dicts != null) {
                for(SystemDict dict : dicts){
                    dictMap.put(dict.getCode(),dict.getValue());
                }
            }
            statusMap.put("0","取消");
            statusMap.put("1","已完成");
            statusMap.put("2","未开始");
            statusMap.put("3","进行中");
            for (Object obj : result) {
                JSONObject followup = new JSONObject();
                Object[] objArr = (Object[]) obj;
                followup.put("doctorCode", objArr[0]);
                followup.put("doctorName", objArr[1]);
                followup.put("doctorPhoto", objArr[2]);
                followup.put("followupType", objArr[3]);
                followup.put("followupTypeName", dictMap.get(objArr[3].toString()) != null ? dictMap.get(objArr[3].toString()) : "");
                followup.put("followupClass", objArr[4]);
                followup.put("followupClassName", objArr[4].toString().equals("1") ? "高血压" : "糖尿病");
                followup.put("status", objArr[5]);
                followup.put("statusName", statusMap.get(objArr[5].toString()) != null ? statusMap.get(objArr[5].toString()) : "");
                followup.put("createTime", objArr[6]);
                followup.put("updateTime", objArr[7]);
                array.put(followup);
            }
        }
        return array;
    }
    /**
     * 获取医生随访列表(创建者)
     */
    public List<Map<String, String>> getListByCreater(String doctorCode, String startTime, String endTime, String page, String pageSize) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        // 排序
        Sort sort = new Sort(Sort.Direction.ASC, "followupDate");
        // 分页信息
        int pageInt = Integer.valueOf(page) - 1;
        int pageSizeInt = Integer.valueOf(pageSize);
        Pageable pageRequest = new PageRequest(pageInt, pageSizeInt, sort);
        List<Followup> list = followupDao.findByCreater(doctorCode, DateUtil.strToDate(startTime), DateUtil.strToDate(endTime), pageRequest);
        if (list != null && list.size() > 0) {
            for (Followup followup : list) {
                Map<String, String> map = getFollowupDetail(followup);
                re.add(map);
            }
        }
        return re;
    }
    /**
     * 新增随访计划(批量)
     */
    @Transactional
    public void addFollowupPlan(String doctorCode, String patientCode, String data) throws Exception {
        //批量随访计划
        JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, Map.class);
        List<Map<String, String>> list = objectMapper.readValue(data, javaType);
        if (list != null && list.size() > 0) {
            //获取患者信息
            Patient patient = patientDao.findByCode(patientCode);
            if (patient == null) {
                throw new Exception("not exit patient:" + patientCode + ".\r\n");
            }
            SignFamily signFamily = signFamilyDao.findByjiatingPatient(patientCode);
            if(signFamily == null){
                throw new Exception("can not find patient's family sign info");
            }
            List<Followup> followupPlan = new ArrayList<>();
            for (Map<String, String> map : list) {
                //获取医生信息
                Doctor doctor = doctorDao.findByCode(map.get("doctor"));
                if (doctor == null) {
                    throw new Exception("not exit doctor:" + doctorCode + ".\r\n");
                }
                Followup followup = new Followup();
                followup.setFollowupType(map.get("type"));
                Date date = DateUtil.strToDate(map.get("date"));
                followup.setFollowupDate(date);
                followup.setFollowupPlanDate(date);
                followup.setDoctorCode(doctor.getCode());
                followup.setDoctorName(doctor.getName());
                followup.setOrgCode(doctor.getHospital());
                followup.setOrgName(doctor.getHospitalName());
                followup.setPatientCode(patientCode);
                followup.setPatientName(patient.getName());
                followup.setIdcard(patient.getIdcard());
                followup.setDataFrom("2");//数据来源 1基卫 2APP
                followup.setStatus("2");     //状态 0取消 1已完成 2未开始 3进行中
                followup.setCreateTime(new Date());
                followup.setCreater(doctorCode);
                followup.setAdminTeamCode(signFamily.getAdminTeamId());
                followup.setSignType(2);
                followupPlan.add(followup);
            }
            followupDao.save(followupPlan);
        }
    }
    /**
     * 编辑随访计划
     */
    public void editFollowupPlan(String doctorCode, String id, String date, String followupType) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            Date followupDate = DateUtil.strToDate(date);
            followup.setFollowupDate(followupDate);
            followup.setFollowupPlanDate(followupDate);
            followup.setFollowupType(followupType);
            followup.setCreater(doctorCode);
            followupDao.save(followup);
        } else {
            throw new Exception("not exit follow:" + id + ".\r\n");
        }
    }
    /**
     * 开始随访记录
     */
    public void startFollowup(String id, String date, String followupType, String followupClass, String followupManagerStatus) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            followup.setFollowupDate(DateUtil.strToDate(date));
            followup.setFollowupType(followupType);
            followup.setFollowupClass(followupClass);
            followup.setFollowupManagerStatus(followupManagerStatus);
            followup.setStatus("3");  //状态 0取消 1已完成 2未开始 3进行中
            followupDao.save(followup);
        } else {
            throw new Exception("not exit follow:" + id + ".\r\n");
        }
    }
    /**
     * 新增临时随访记录(返回ID)
     */
    public String addFollowup(String doctorCode, String patientCode, String date, String followupType, String followupClass, String followupManagerStatus) throws Exception {
        String re = "";
        //获取医生信息
        Doctor doctor = doctorDao.findByCode(doctorCode);
        if (doctor == null) {
            throw new Exception("not exit doctor:" + doctorCode + ".\r\n");
        }
        //获取患者信息
        Patient patient = patientDao.findByCode(patientCode);
        if (patient == null) {
            throw new Exception("not exit patient:" + patientCode + ".\r\n");
        }
        SignFamily signFamily = signFamilyDao.findByjiatingPatient(patientCode);
        if(signFamily == null){
            throw new Exception("can not find patient's family sign info");
        }
        Followup followup = new Followup();
        Date followDate = DateUtil.strToDate(date);
        followup.setFollowupDate(followDate);
        followup.setFollowupPlanDate(followDate);
        followup.setDoctorCode(doctorCode);
        followup.setDoctorName(doctor.getName());
        followup.setOrgCode(doctor.getHospital());
        followup.setOrgName(doctor.getHospitalName());
        followup.setPatientCode(patientCode);
        followup.setPatientName(patient.getName());
        followup.setIdcard(patient.getIdcard());
        followup.setFollowupType(followupType);
        followup.setFollowupClass(followupClass);
        followup.setFollowupManagerStatus(followupManagerStatus);
        followup.setDataFrom("2");//数据来源 1基卫 2APP
        followup.setStatus("3");     //状态 0取消 1已完成 2未开始 3进行中
        followup.setCreateTime(new Date());
        followup.setCreater(doctorCode);
        followup.setAdminTeamCode(signFamily.getAdminTeamId());
        followup.setSignType(2);
        followupDao.save(followup);
        re = String.valueOf(followup.getId());
        return re;
    }
    /**
     * 取消随访计划
     */
	private Map<String,String> getFollowupDetail(Followup followup) throws Exception
	{
		Map<String,String> re = new HashMap<>();
		//患者信息
		String patientCode = followup.getPatientCode();
		Patient patient = patientDao.findByCode(patientCode);
		if(patient!=null) {
			re.put("patientCode",patientCode);
			re.put("patientName",patient.getName());
			re.put("idcard",patient.getIdcard());
			String mobile = patient.getMobile();
			if(StringUtils.isEmpty(mobile))
			{
				mobile = patient.getMobileRemarks();
			}
			re.put("mobile", mobile);
			re.put("sex",String.valueOf(patient.getSex()));
			re.put("birthday",DateUtil.dateToStrLong(patient.getBirthday()));
			re.put("photo",patient.getPhoto());
		}
		else{
			throw new Exception("not exit patient:"+patientCode);
		}
		re.put("id",String.valueOf(followup.getId()));
		re.put("followupNo",followup.getFollowupNo());
		re.put("followupDate",DateUtil.dateToStrLong(followup.getFollowupDate()));
		re.put("followupNextDate",DateUtil.dateToStrLong(followup.getFollowupNextDate()));
		//随访方式转译
		re.put("followupType",followup.getFollowupType());
		String followupTypeName = systemDictService.getDictValue("FOLLOWUP_WAY_DICT",followup.getFollowupType());
		re.put("followupTypeName",followupTypeName);
		//随访类别转译
		re.put("followupClass",followup.getFollowupClass());
		String followupClassName = systemDictService.getDictValue("FOLLOWUP_CLASS_DICT",followup.getFollowupClass());
		re.put("followupClassName",followupClassName);
		//随访管理状态转译
		re.put("followupManagerStatus",followup.getFollowupManagerStatus());
		String followupManagerStatusName = systemDictService.getDictValue("FOLLOWUP_MANAGER_STATUS",followup.getFollowupManagerStatus());
		re.put("followupManagerStatusName",followupManagerStatusName);
		re.put("doctorCode",followup.getDoctorCode());
		re.put("doctorName",followup.getDoctorName());
		re.put("orgCode",followup.getOrgCode());
		re.put("orgName",followup.getOrgName());
		re.put("dataFrom",followup.getDataFrom());
		re.put("status",followup.getStatus());
		re.put("followupContentPhone",followup.getFollowupContentPhone());
		re.put("createTime",DateUtil.dateToStrLong(followup.getCreateTime()));
		re.put("creater",followup.getCreater());
		return re;
	}
	/**
	 * 获取医生随访列表
    public void cancelFollowupPlan(String id) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            followup.setStatus("0");  //状态 0取消 1已完成 2未开始 3进行中
            followupDao.save(followup);
        } else {
            throw new Exception("not exit follow:" + id + ".\r\n");
        }
    }
    /**
     * 完成随访记录,并上传随访记录
     */
    public void finishFollowup(String id) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            followup.setStatus("1");  //状态 0取消 1已完成 2未开始 3进行中
            followupDao.save(followup);
            //上传随访计划
            new Thread(new FollowupUploadTask(String.valueOf(followup.getId()))).start();
        } else {
            throw new Exception("not exit follow:" + id + ".\r\n");
        }
    }
    /*********************************** 随访详情 *******************************************************************/
    /**
     * 获取面访项目列表
     */
    public Map<String, String> getFollowup(String id) throws Exception {
        Map<String, String> re = new HashMap<>();
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            re = getFollowupDetail(followup);
        } else {
            throw new Exception("not exit follow:" + id + ".\r\n");
        }
        return re;
    }
    /**
     * 获取面访项目列表
     */
    public List<Map<String, String>> getFollowupProject(String id) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        //获取已填写的面访项目
        List<String> project = followupContentDao.findProjectByFollowupId(Long.valueOf(id));
        //获取所有面访项目
        List<SystemDict> dictList = systemDictService.getDictByDictName("FOLLOWUP_PROJECT");
        if (dictList != null && dictList.size() > 0) {
            for (SystemDict dict : dictList) {
                Map<String, String> map = new HashMap<>();
                String code = dict.getCode();
                map.put("projectCode", code);
                map.put("projectName", dict.getValue());
                if (project != null && project.contains(code)) {
                    map.put("status", "1"); //已填写
                } else {
                    map.put("status", "0");//未填写
                }
                re.add(map);
            }
        }
        return re;
    }
    /**
     * 获取面访项目数据
     */
    public Map<String, String> getFollowupProjectData(String id, String followupProject) throws Exception {
        Map<String, String> re = new HashMap<>();
        List<FollowupContent> dataList = followupContentDao.findByFollowupIdAndFollowupProject(Long.valueOf(id), followupProject);
        for (FollowupContent item : dataList) {
            re.put(item.getFollowupKey(), item.getFollowupValue());
        }
        return re;
    }
    /**
     * 保存面访项目数据
     */
    @Transactional
    public void saveFollowupProjectData(String id, String followupProject, String followupProjectData) throws Exception {
        List<FollowupContent> dataList = followupContentDao.findByFollowupIdAndFollowupProject(Long.valueOf(id), followupProject);
        //删除原有记录
        followupContentDao.delete(dataList);
        Map<String, String> data = objectMapper.readValue(followupProjectData, Map.class);
        if (data != null && data.keySet().size() > 0) {
            List<FollowupContent> newList = new ArrayList<>();
            for (String key : data.keySet()) {
                FollowupContent item = new FollowupContent();
                item.setFollowupId(Long.valueOf(id));
                item.setFollowupProject(followupProject);
                item.setFollowupKey(key);
                item.setFollowupValue(data.get(key));
                item.setCreateTime(new Date());
                newList.add(item);
            }
            followupContentDao.save(newList);
        }
    }
    /*********************************** 电话随访 *****************************************************************/
    /**
     * 获取电话随访内容
     */
    public String getFollowupPhone(String id) throws Exception {
        String re = "";
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            re = followup.getFollowupContentPhone();
        } else {
            throw new Exception("not exit followup:" + id + ".\r\n");
        }
        return re;
    }
    /**
     * 记录电话随访内容
     */
    public void saveFollowupPhone(String id, String content) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            followup.setFollowupContentPhone(content);
            followupDao.save(followup);
        } else {
            throw new Exception("not exit followup:" + id + ".\r\n");
        }
    }
    /*************************************** 上次随访 ********************************************/
    /**
     * 获取团队医生
     */
	public List<Map<String,String>> getListByDoctor(String doctorCode,String startTime,String endTime,String page,String pageSize) throws Exception
	{
		List<Map<String,String>> re = new ArrayList<>();
		// 排序
		Sort sort = new Sort(Sort.Direction.ASC, "followupDate");
		// 分页信息
		int pageInt = Integer.valueOf(page)-1;
		int pageSizeInt =  Integer.valueOf(pageSize);
		Pageable pageRequest = new PageRequest(pageInt, pageSizeInt, sort);
		List<Followup> list = followupDao.findByDoctor(doctorCode,DateUtil.strToDate(startTime),DateUtil.strToDate(endTime),pageRequest);
		if(list!=null && list.size()>0)
		{
		    for(Followup followup : list)
			{
				Map<String,String> map = getFollowupDetail(followup);
				re.add(map);
			}
		}
		return re;
	}
	/**
	 * 获取医生随访列表(创建者)
	 */
	public List<Map<String,String>> getListByCreater(String doctorCode,String startTime,String endTime,String page,String pageSize) throws Exception
	{
		List<Map<String,String>> re = new ArrayList<>();
		// 排序
		Sort sort = new Sort(Sort.Direction.ASC, "followupDate");
		// 分页信息
		int pageInt = Integer.valueOf(page)-1;
		int pageSizeInt =  Integer.valueOf(pageSize);
		Pageable pageRequest = new PageRequest(pageInt, pageSizeInt, sort);
		List<Followup> list = followupDao.findByCreater(doctorCode,DateUtil.strToDate(startTime),DateUtil.strToDate(endTime),pageRequest);
		if(list!=null && list.size()>0)
		{
			for(Followup followup : list)
			{
				Map<String,String> map = getFollowupDetail(followup);
				re.add(map);
			}
		}
		return re;
	}
	/**
	 *新增随访计划(批量)
	 */
	@Transactional
	public void addFollowupPlan(String doctorCode,String patientCode,String data) throws Exception {
		//批量随访计划
		JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, Map.class);
		List<Map<String,String>> list = objectMapper.readValue(data,javaType);
		if(list!=null && list.size()>0)
		{
			//获取患者信息
			Patient patient = patientDao.findByCode(patientCode);
			if(patient==null)
			{
				throw new Exception("not exit patient:"+patientCode+".\r\n");
			}
			List<Followup> followupPlan = new ArrayList<>();
			for(Map<String,String> map : list)
			{
				//获取医生信息
				Doctor doctor = doctorDao.findByCode(map.get("doctor"));
				if(doctor==null)
				{
					throw new Exception("not exit doctor:"+doctorCode+".\r\n");
				}
				Followup followup = new Followup();
				followup.setFollowupType(map.get("type"));
				Date date =  DateUtil.strToDate(map.get("date"));
				followup.setFollowupDate(date);
				followup.setFollowupPlanDate(date);
				followup.setDoctorCode(doctor.getCode());
				followup.setDoctorName(doctor.getName());
				followup.setOrgCode(doctor.getHospital());
				followup.setOrgName(doctor.getHospitalName());
				followup.setPatientCode(patientCode);
				followup.setPatientName(patient.getName());
				followup.setIdcard(patient.getIdcard());
				followup.setDataFrom("2");//数据来源 1基卫 2APP
				followup.setStatus("2");     //状态 0取消 1已完成 2未开始 3进行中
				followup.setCreateTime(new Date());
				followup.setCreater(doctorCode);
				followupPlan.add(followup);
			}
			followupDao.save(followupPlan);
		}
	}
	/**
	 *编辑随访计划
	 */
	public void editFollowupPlan(String doctorCode,String id,String date,String followupType) throws Exception {
		Followup followup = followupDao.findOne(Long.valueOf(id));
		if(followup!=null)
		{
			Date followupDate = DateUtil.strToDate(date);
			followup.setFollowupDate(followupDate);
			followup.setFollowupPlanDate(followupDate);
			followup.setFollowupType(followupType);
			followup.setCreater(doctorCode);
			followupDao.save(followup);
		}
		else{
			throw new Exception("not exit follow:"+id+".\r\n");
		}
	}
	/**
	 *开始随访记录
	 */
	public void startFollowup(String id,String date,String followupType,String followupClass,String followupManagerStatus) throws Exception {
		 Followup followup = followupDao.findOne(Long.valueOf(id));
		 if(followup!=null)
		 {
			 followup.setFollowupDate(DateUtil.strToDate(date));
			 followup.setFollowupType(followupType);
			 followup.setFollowupClass(followupClass);
			 followup.setFollowupManagerStatus(followupManagerStatus);
			 followup.setStatus("3");  //状态 0取消 1已完成 2未开始 3进行中
			 followupDao.save(followup);
		 }
		else{
			 throw new Exception("not exit follow:"+id+".\r\n");
		 }
	}
	/**
	 *新增临时随访记录(返回ID)
	 */
	public String addFollowup(String doctorCode,String patientCode,String date,String followupType,String followupClass,String followupManagerStatus) throws Exception {
		String re ="";
		//获取医生信息
		Doctor doctor = doctorDao.findByCode(doctorCode);
		if(doctor==null)
		{
			throw new Exception("not exit doctor:"+doctorCode+".\r\n");
		}
		//获取患者信息
		Patient patient = patientDao.findByCode(patientCode);
		if(patient==null)
		{
			throw new Exception("not exit patient:"+patientCode+".\r\n");
		}
		Followup followup = new Followup();
		Date followDate = DateUtil.strToDate(date);
		followup.setFollowupDate(followDate);
		followup.setFollowupPlanDate(followDate);
		followup.setDoctorCode(doctorCode);
		followup.setDoctorName(doctor.getName());
		followup.setOrgCode(doctor.getHospital());
		followup.setOrgName(doctor.getHospitalName());
		followup.setPatientCode(patientCode);
		followup.setPatientName(patient.getName());
		followup.setIdcard(patient.getIdcard());
		followup.setFollowupType(followupType);
		followup.setFollowupClass(followupClass);
		followup.setFollowupManagerStatus(followupManagerStatus);
		followup.setDataFrom("2");//数据来源 1基卫 2APP
		followup.setStatus("3");     //状态 0取消 1已完成 2未开始 3进行中
		followup.setCreateTime(new Date());
		followup.setCreater(doctorCode);
		followupDao.save(followup);
		re = String.valueOf(followup.getId());
		return re;
	}
	/**
	 *取消随访计划
	 */
	public void cancelFollowupPlan(String id) throws Exception {
		Followup followup = followupDao.findOne(Long.valueOf(id));
		if(followup!=null)
		{
			followup.setStatus("0");  //状态 0取消 1已完成 2未开始 3进行中
			followupDao.save(followup);
		}
		else{
			throw new Exception("not exit follow:"+id+".\r\n");
		}
	}
	/**
	 * 完成随访记录,并上传随访记录
    private List<Doctor> getTeamDoctors(String doctor, String patient) throws Exception {
        List<Doctor> doctors = new ArrayList<>();
        //获取医生团队成员
        SignFamily signFamily = signFamilyDao.findByFamilyDoctorAndPatient(doctor, patient);
        // 查询家庭医生团队
        if (signFamily != null) {
            doctors = drHealthTeamService.findTeamDoctors(signFamily.getTeamCode());
        }
        // 查询三师团队医生
        if (doctors == null || doctors.size() == 0) {
            SignFamily sanshiSign = signFamilyDao.findBySanshiDoctorAndPatient(doctor, patient);
            if (sanshiSign != null) {
                doctors = drHealthTeamService.findTeamDoctors(patient, 1);
            } else {
                doctors = new ArrayList<>();
            }
        }
        return doctors;
    }
    /**
     * 获取上次随访
     */
	public void finishFollowup(String id) throws Exception {
		Followup followup = followupDao.findOne(Long.valueOf(id));
		if(followup!=null)
		{
			followup.setStatus("1");  //状态 0取消 1已完成 2未开始 3进行中
			followupDao.save(followup);
			//上传随访计划
			new Thread(new FollowupUploadTask(String.valueOf(followup.getId()))).start();
		}
		else{
			throw new Exception("not exit follow:"+id+".\r\n");
		}
	}
	/*********************************** 随访详情 *******************************************************************/
	/**
	 * 获取面访项目列表
	 */
	public Map<String,String> getFollowup(String id) throws Exception
	{
		Map<String,String> re = new HashMap<>();
		Followup followup = followupDao.findOne(Long.valueOf(id));
		if(followup!=null)
		{
			re = getFollowupDetail(followup);
		}
		else{
			throw new Exception("not exit follow:"+id+".\r\n");
		}
		return re;
	}
	/**
	 * 获取面访项目列表
	 */
	public List<Map<String,String>> getFollowupProject(String id) throws Exception
	{
		List<Map<String,String>> re = new ArrayList<>();
		//获取已填写的面访项目
		List<String> project = followupContentDao.findProjectByFollowupId(Long.valueOf(id));
		//获取所有面访项目
		List<SystemDict> dictList = systemDictService.getDictByDictName("FOLLOWUP_PROJECT");
		if (dictList!=null && dictList.size()>0)
		{
			for(SystemDict dict:dictList)
			{
				Map<String,String> map = new HashMap<>();
				String code = dict.getCode();
				map.put("projectCode",code);
				map.put("projectName",dict.getValue());
				if(project!=null && project.contains(code))
				{
					map.put("status","1"); //已填写
				}
				else{
					map.put("status","0");//未填写
				}
				re.add(map);
			}
		}
		return re;
	}
	/**
	 * 获取面访项目数据
	 */
	public Map<String,String> getFollowupProjectData(String id,String followupProject) throws Exception
	{
		Map<String,String> re = new HashMap<>();
		List<FollowupContent> dataList =  followupContentDao.findByFollowupIdAndFollowupProject(Long.valueOf(id),followupProject);
		for(FollowupContent item:dataList)
		{
			re.put(item.getFollowupKey(),item.getFollowupValue());
		}
		return re;
	}
	/**
	 *保存面访项目数据
	 */
	@Transactional
	public void saveFollowupProjectData(String id,String followupProject,String followupProjectData) throws Exception {
		List<FollowupContent> dataList = followupContentDao.findByFollowupIdAndFollowupProject(Long.valueOf(id),followupProject);
		//删除原有记录
		followupContentDao.delete(dataList);
		Map<String,String> data =  objectMapper.readValue(followupProjectData,Map.class);
		if(data!=null && data.keySet().size()>0)
		{
			List<FollowupContent> newList = new ArrayList<>();
			for (String key : data.keySet()) {
				FollowupContent item = new FollowupContent();
				item.setFollowupId(Long.valueOf(id));
				item.setFollowupProject(followupProject);
				item.setFollowupKey(key);
				item.setFollowupValue(data.get(key));
				item.setCreateTime(new Date());
				newList.add(item);
			}
			followupContentDao.save(newList);
		}
	}
	/*********************************** 电话随访 *****************************************************************/
	/**
	 *获取电话随访内容
	 */
	public String getFollowupPhone(String id) throws Exception {
		String re = "";
		Followup followup = followupDao.findOne(Long.valueOf(id));
		if(followup!=null)
		{
			re = followup.getFollowupContentPhone();
		}
		else {
			throw new Exception("not exit followup:"+id+".\r\n");
		}
		return re;
	}
	/**
	 *记录电话随访内容
	 */
	public void saveFollowupPhone(String id,String content) throws Exception {
		Followup followup = followupDao.findOne(Long.valueOf(id));
		if(followup!=null)
		{
			followup.setFollowupContentPhone(content);
			followupDao.save(followup);
		}
		else {
			throw new Exception("not exit followup:"+id+".\r\n");
		}
	}
	/*************************************** 上次随访 ********************************************/
	/**
	 * 获取团队医生
    public Map<String, String> getLastFollowup(String doctor, String patient, String followClass) throws Exception {
        Map<String, String> re = new HashMap<>();
        //获取医生团队成员
        String[] doctors = new String[]{doctor};
        List<Doctor> doctorList = getTeamDoctors(doctor, patient);
        if (doctorList != null && doctorList.size() > 1) {
            doctors = new String[doctorList.size()];
            for (int i = 0; i < doctorList.size(); i++) {
                doctors[i] = doctorList.get(i).getCode();
            }
        }
        //获取最新的随访记录
        Followup followup = followupDao.findLastFollowup(doctors, patient, followClass);
        if (followup != null) {
            re.put("id", String.valueOf(followup.getId()));
            re.put("followupDate", DateUtil.dateToStrShort(followup.getFollowupDate()));
        } else {
            re = null;
        }
        return re;
    }
    /**
     * 获取上次随访
     */
	private List<Doctor>  getTeamDoctors(String doctor,String patient) throws Exception
	{
		List<Doctor> doctors = new ArrayList<>();
		//获取医生团队成员
		SignFamily signFamily = signFamilyDao.findByFamilyDoctorAndPatient(doctor, patient);
		// 查询家庭医生团队
		if (signFamily != null) {
			doctors = drHealthTeamService.findTeamDoctors(signFamily.getTeamCode());
		}
		// 查询三师团队医生
		if (doctors == null || doctors.size() == 0) {
			SignFamily sanshiSign = signFamilyDao.findBySanshiDoctorAndPatient(doctor, patient);
			if (sanshiSign != null) {
				doctors = drHealthTeamService.findTeamDoctors(patient, 1);
			} else {
				doctors = new ArrayList<>();
			}
		}
		return doctors;
	}
	/**
	 * 获取上次随访
	 */
	public Map<String,String> getLastFollowup(String doctor,String patient,String followClass) throws Exception
	{
		Map<String,String> re = new HashMap<>();
		//获取医生团队成员
		String[] doctors = new String[]{doctor};
		List<Doctor> doctorList = getTeamDoctors(doctor,patient);
		if(doctorList!=null&& doctorList.size()>1)
		{
			doctors = new String[doctorList.size()];
			for(int i=0;i<doctorList.size();i++)
			{
				doctors[i] = doctorList.get(i).getCode();
			}
		}
		//获取最新的随访记录
		Followup followup = followupDao.findLastFollowup(doctors,patient,followClass);
		if(followup!=null)
		{
			re.put("id",String.valueOf(followup.getId()));
			re.put("followupDate",DateUtil.dateToStrShort(followup.getFollowupDate()));
		}
		else{
			re = null;
		}
		return re;
	}
	/**
	 * 获取上次随访
	 */
	public void copyFollowup(Long id,Long fromId) throws Exception
	{
		List<FollowupContent> list = followupContentDao.findByFollowupId(fromId);
		if(list!=null && list.size()>0)
		{
			List<FollowupContent> copyList = new ArrayList<>();
			for (FollowupContent item :list)
			{
				FollowupContent copyItem = new FollowupContent();
				copyItem.setFollowupId(id);
				copyItem.setFollowupKey(item.getFollowupKey());
				copyItem.setFollowupValue(item.getFollowupValue());
				copyItem.setFollowupProject(item.getFollowupProject());
				copyItem.setCreateTime(new Date());
				copyList.add(copyItem);
			}
			followupContentDao.save(copyList);
		}
	}
	/**************************************** 随访计划消息 ******************************************/
	/**
	 * 每日发送随访计划提醒消息
    public void copyFollowup(Long id, Long fromId) throws Exception {
        List<FollowupContent> list = followupContentDao.findByFollowupId(fromId);
        if (list != null && list.size() > 0) {
            List<FollowupContent> copyList = new ArrayList<>();
            for (FollowupContent item : list) {
                FollowupContent copyItem = new FollowupContent();
                copyItem.setFollowupId(id);
                copyItem.setFollowupKey(item.getFollowupKey());
                copyItem.setFollowupValue(item.getFollowupValue());
                copyItem.setFollowupProject(item.getFollowupProject());
                copyItem.setCreateTime(new Date());
                copyList.add(copyItem);
            }
            followupContentDao.save(copyList);
        }
    }
    /**************************************** 随访计划消息 ******************************************/
    /**
     * 每日发送随访计划提醒消息
     */
	@Transactional
	public void sendMessage(String date)
	{
	    try{
			String start = date +" 00:00:00";
			String end = date +" 23:59:59";
			String sql = "select doctor_code,count(1) count from wlyy_followup where status not in ('0','1') and followup_plan_date>='"+start+"' and followup_plan_date<='"+end+"' group by doctor_code";
			//获取所有未执行随访计划
			List<Map<String,Object>> followupToday = jdbcTemplate.queryForList(sql);
			if(followupToday!=null)
			{
				List<Message> list = new ArrayList<>();
				for(Map<String,Object> map:followupToday)
				{
					String doctor = String.valueOf(map.get("doctor_code"));
					String count = String.valueOf(map.get("count"));
					// 添加签约消息
					String title = "随访计划提醒";
					String content = "您今日有" +count+"个随访计划待处理";
					Message message = new Message();
					message.setCode(getCode());
					message.setCzrq(new Date());
					message.setContent(content);
					message.setRead(1);//设置未读
					message.setReceiver(doctor);//设置接受医生的code
					message.setSender("system");//设置发送的用户
					message.setTitle(title);
					message.setType(4);//随访计划提醒
					message.setReadonly(1);//是否只读消息
					list.add(message);
					// 推送消息给医生
					PushMsgTask.getInstance().put(doctor,"4",title,content,"");
				}
				messageDao.save(list);
			}
		}
		catch (Exception e)
		{
		   e.printStackTrace();
		}
	}
    @Transactional
    public void sendMessage(String date) {
        try {
            String start = date + " 00:00:00";
            String end = date + " 23:59:59";
            String sql = "select doctor_code,count(1) count from wlyy_followup where status not in ('0','1') and followup_plan_date>='" + start + "' and followup_plan_date<='" + end + "' group by doctor_code";
            //获取所有未执行随访计划
            List<Map<String, Object>> followupToday = jdbcTemplate.queryForList(sql);
            if (followupToday != null) {
                List<Message> list = new ArrayList<>();
                for (Map<String, Object> map : followupToday) {
                    String doctor = String.valueOf(map.get("doctor_code"));
                    String count = String.valueOf(map.get("count"));
                    // 添加签约消息
                    String title = "随访计划提醒";
                    String content = "您今日有" + count + "个随访计划待处理";
                    Message message = new Message();
                    message.setCode(getCode());
                    message.setCzrq(new Date());
                    message.setContent(content);
                    message.setRead(1);//设置未读
                    message.setReceiver(doctor);//设置接受医生的code
                    message.setSender("system");//设置发送的用户
                    message.setTitle(title);
                    message.setType(4);//随访计划提醒
                    message.setReadonly(1);//是否只读消息
                    list.add(message);
                    // 推送消息给医生
                    PushMsgTask.getInstance().put(doctor, "4", title, content, "");
                }
                messageDao.save(list);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

+ 127 - 89
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/HealthEduArticleService.java

@ -27,107 +27,145 @@ import com.yihu.wlyy.service.BaseService;
/**
 * 健康教育业务控制类
 * @author George
 *
 * @author George
 */
@Component
@Transactional(rollbackFor = Exception.class)
public class HealthEduArticleService extends BaseService {
	@Autowired
	private HealthEduArticleDao healthEduArticleDao;
	@Autowired
	private HealthEduArticlePatientDao healthEduArticlePatientDao;
	@Autowired
	private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
	@Autowired
	private HealthEduArticleLabelService healthEduArticleLabelService;
	@Autowired
	private JdbcTemplate jdbcTemplate;
    @Autowired
    private HealthEduArticleDao healthEduArticleDao;
    @Autowired
    private HealthEduArticlePatientDao healthEduArticlePatientDao;
    @Autowired
    private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
    @Autowired
    private HealthEduArticleLabelService healthEduArticleLabelService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 查询文章信息
     *
     * @param code
     * @return
     */
    public HealthEduArticle findArticleByCode(String code) {
        return healthEduArticleDao.findByCode(code);
    }
    /**
     * 获取文章列表
     *
     * @param page     页码
     * @param pagesize 分页大小
     * @return 列表
     */
    public List<Map<String, Object>> findAll(int page, int pagesize, String filter, String doctor, String patient) {
        if (pagesize <= 0) {
            pagesize = 10;
        }
        if (page < 0) {
            page = 0;
        }
        List<Object> params = new ArrayList<Object>();
        StringBuffer sql = new StringBuffer();
        sql.append("select a.id,a.code,a.title,a.url,a.czrq,a.content,a.keyword");
        sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.code and c.status = 1) as readAmount");
        sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.code and c.status = 2) as collectionAmount");
        sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.code and c.status = 3) as repeatAmount");
        sql.append(",(select count(1) from wlyy_health_edu_article_doctor c where c.article = a.code and c.doctor =?) as collection");
        params.add(doctor);
        if (StringUtils.isNotBlank(patient)) {
            sql.append(",(select count(1) from wlyy_health_edu_article_patient c where c.article = a.code and c.doctor = ? and c.patient= ? ) as send");
            params.add(doctor);
            params.add(patient);
        }
        sql.append(" from wlyy_health_edu_article a ");//内联取文章内容
        String where = " ";
        if (StringUtils.isNotBlank(filter)) {
            //记录搜索记录
            healthEduArticleLabelService.saveOrUpdateLabel(filter, doctor);
            filter = "%" + filter + "%";
            where += " where ( a.title like ? or a.keyword like ? )";
            params.add(filter);
            params.add(filter);
        }
        int start = page * pagesize;
	/**
	 * 查询文章信息
	 * @param code
	 * @return
	 */
	public HealthEduArticle findArticleByCode(String code) {
		return healthEduArticleDao.findByCode(code);
	}
        String pageInfo = " limit " + start + "," + pagesize;
	/**
	 * 获取文章列表
	 * @param page 页码
	 * @param pagesize 分页大小
	 * @return 列表
	 */
	public List<Map<String, Object>> findAll(int page, int pagesize,String filter,String doctor,String patient) {
		if (pagesize <= 0) {
			pagesize = 10;
		}
		if(page<0){
			page = 0;
		}
		List<Object> params = new ArrayList<Object>();
		StringBuffer sql = new StringBuffer();
		sql.append("select a.id,a.code,a.title,a.url,a.czrq,a.content,a.keyword");
		sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.code and c.status = 1) as readAmount");
		sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.code and c.status = 2) as collectionAmount");
		sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.code and c.status = 3) as repeatAmount");
		sql.append(",(select count(1) from wlyy_health_edu_article_doctor c where c.article = a.code and c.doctor =?) as collection");
		params.add(doctor);
		if(StringUtils.isNotBlank(patient)) {
			sql.append(",(select count(1) from wlyy_health_edu_article_patient c where c.article = a.code and c.doctor = ? and c.patient= ? ) as send");
			params.add(doctor);
			params.add(patient);
		}
		sql.append(" from wlyy_health_edu_article a ");//内联取文章内容
		String where = " ";
		if(StringUtils.isNotBlank(filter)){
			//记录搜索记录
			healthEduArticleLabelService.saveOrUpdateLabel(filter,doctor);
			filter="%"+filter+"%";
			where+=" where ( a.title like ? or a.keyword like ? )";
			params.add(filter);
			params.add(filter);
		}
		int start = page * pagesize;
        String orderBy = " order by a.czrq,a.id desc";
		String pageInfo = " limit "+start+","+pagesize;
        sql.append(where).append(orderBy).append(pageInfo);
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql.toString(), params.toArray());
        return result;
    }
		String orderBy = " order by a.czrq,a.id desc";
    /**
     * 查询给患者发送的健康教育文章
     *
     * @param patient
     * @param teamCode
     * @param page
     * @param pageSize
     * @return
     */
    public List<Map<String, Object>> findByPatientAndTeam(String patient, long teamCode, int page, int pageSize) {
        List<Object> params = new ArrayList<Object>();
        String sql = "select " +
                "    a.article" +
                "    ,a.title" +
                "    ,a.url" +
                "    ,a.czrq" +
                "    ,a.content" +
                "    ,d.code" +
                "    ,d.name" +
                "    ,d.photo" +
                "    ,a.admin_team_code" +
                "  from" +
                "    wlyy_health_edu_article_patient a" +
                "    ,wlyy_doctor d" +
                "  where" +
                "    a.doctor = d.code " +
                "    and a.patient = ?" +
                "    and a.admin_team_code = ?" +
                "  order by a.czrq desc limit " + page*pageSize + "," + pageSize;
		sql.append(where).append(orderBy).append(pageInfo);
		List<Map<String, Object>> result = jdbcTemplate.queryForList(sql.toString(),params.toArray());
		return result;
	}
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql,new Object[]{patient,teamCode});
        return result;
    }
	/**
	 * 文章更新为已读
	 * @param patient
	 * @param article
	 * @return
	 */
	public int updateRead(String patient, String article) {
		return healthEduArticlePatientDao.updateRead(patient, article);
	}
    /**
     * 文章更新为已读
     *
     * @param patient
     * @param article
     * @return
     */
    public int updateRead(String patient, String article) {
        return healthEduArticlePatientDao.updateRead(patient, article);
    }
	/**
	 * 发送文章列表
	 * @param list
	 * @return
	 */
	public int send(List<HealthEduArticlePatient> list) {
		Iterable<HealthEduArticlePatient> iterable = healthEduArticlePatientDao.save(list);
		//记录转发量
		for(HealthEduArticlePatient healthEduArticlePatient:list){
			healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.REPEAT_STATUS,healthEduArticlePatient.getArticle(),healthEduArticlePatient.getTitle(),healthEduArticlePatient.getDoctor());
		}
		Iterator<HealthEduArticlePatient> iterator = iterable.iterator();
		if (iterator.hasNext()) {
			return 1;
		} else {
			return 0;
		}
    /**
     * 发送文章列表
     *
     * @param list
     * @return
     */
    public int send(List<HealthEduArticlePatient> list) {
        Iterable<HealthEduArticlePatient> iterable = healthEduArticlePatientDao.save(list);
        //记录转发量
        for (HealthEduArticlePatient healthEduArticlePatient : list) {
            healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.REPEAT_STATUS, healthEduArticlePatient.getArticle(), healthEduArticlePatient.getTitle(), healthEduArticlePatient.getDoctor());
        }
        Iterator<HealthEduArticlePatient> iterator = iterable.iterator();
        if (iterator.hasNext()) {
            return 1;
        } else {
            return 0;
        }
	}
    }
}

+ 44 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthGuidanceService.java

@ -2,6 +2,8 @@ package com.yihu.wlyy.service.app.health;
import java.util.Date;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -9,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -37,6 +40,8 @@ public class PatientHealthGuidanceService extends BaseService {
	private PatientDao patientDao;
	@Autowired
	private PatientHealthGuidanceDao patientHealthGuidanceDao;
	@Autowired
	SignFamilyDao signFamilyDao;
	public JSONObject findById(Long id){
		PatientHealthGuidance guidance = patientHealthGuidanceDao.findOne(id);
@ -63,12 +68,19 @@ public class PatientHealthGuidanceService extends BaseService {
	 * @param guidance
	 * @return
	 */
	public PatientHealthGuidance add(PatientHealthGuidance guidance, String accessToken) {
	public PatientHealthGuidance add(PatientHealthGuidance guidance, String accessToken) throws Exception {
		Doctor doctor = doctorDao.findByCode(guidance.getDoctor());
		Patient patient = patientDao.findByCode(guidance.getPatient());
		SignFamily signFamily = signFamilyDao.findByjiatingPatient(guidance.getPatient());
		if(signFamily == null){
			throw new Exception("can not find patient's family sign info");
		}
		guidance.setCzrq(new Date());
		guidance.setDel("1");
		guidance.setAdminTeamCode(signFamily.getAdminTeamId());
		guidance.setSignType(2);
		guidance = patientHealthGuidanceDao.save(guidance);
		if (guidance != null && StringUtils.isNotEmpty(patient.getOpenid())) {
			// 推送消息到微信端
@ -147,6 +159,37 @@ public class PatientHealthGuidanceService extends BaseService {
		return array;
	}
	/**
	 * 健康指导查询
	 *
	 * @param patient
	 * @param teamCode
	 * @param page
	 * @param pageSize
	 * @return
	 */
	public JSONArray findByPatientAndGuidanceAndTeam(String patient,long teamCode,int page,int pageSize){
		Sort sort = new Sort(Sort.Direction.DESC,"czrq");
		PageRequest pageRequest = new PageRequest(0, pageSize, sort);
		Page<Object> result = patientHealthGuidanceDao.findByPatientAndTeamCode(patient,teamCode,pageRequest);
		JSONArray array = new JSONArray();
		if (result != null) {
			for (Object obj : result) {
				Object[] temp = (Object[]) obj;
				JSONObject json = new JSONObject();
				json.put("doctorCode", temp[6]);
				json.put("doctorName", temp[0]);
				json.put("doctorPhoto", temp[1]);
				json.put("id", temp[2]);
				json.put("content", temp[3]);
				json.put("czrq", DateUtil.dateToStrLong((Date) temp[4]));
				json.put("adminTeamCode", temp[7]);
				array.put(json);
			}
		}
		return array;
	}
	/**
	 * 查询患者的健康指导
	 * @param patient 患者标识

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

@ -332,7 +332,10 @@ public class MessageService extends BaseService {
                map.put("value2", String.valueOf(item.getValue2()));
                map.put("czrq", DateUtil.dateToStrLong(item.getCzrq()));
                re.add(map);
                item.setRead(0);//把消息设置为已读
            }
            messageDao.save(list);
        }
        return re;
    }
@ -340,12 +343,25 @@ public class MessageService extends BaseService {
    /**
     * 获取系统消息
     */
    public List<Message> getSystemMessage(String doctor,Integer page,Integer pagesize) throws Exception
    {
    public List<Message> getSystemMessage(String doctor, Integer page, Integer pagesize) throws Exception {
        // 排序
        Sort sort = new Sort(Sort.Direction.DESC, "czrq");
        // 分页信息
        Pageable pageRequest = new PageRequest(page - 1, pagesize,sort);
        return messageDao.getSystemMessage(doctor,pageRequest);
        Pageable pageRequest = new PageRequest(page - 1, pagesize, sort);
        return messageDao.getSystemMessage(doctor, pageRequest);
    }
    /**
     * 设置某类消息已读
     *
     * @param doctor
     * @param type
     */
    public void setMessageReaded(String doctor, int type) {
        if (type == 3) {
            messageDao.setSysMessageReaded(doctor);
        } else {
            messageDao.setMessageReaded(doctor, type);
        }
    }
}

+ 3 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reservation/PatientReservationService.java

@ -181,15 +181,15 @@ public class PatientReservationService extends BaseService {
	 * 分页获取患者预约记录,医生为空查患者所有
     */
	@Transactional
	public List<PatientReservation> getReservationByPatient(String patient,String doctor, int page, int pagesize) throws Exception
	public List<PatientReservation> getReservationByPatient(String patient,Long teamCode, int page, int pagesize) throws Exception
	{
		List<PatientReservation> list = new ArrayList<>();
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(page-1, pagesize, sort);
		if(StringUtils.isNotBlank(doctor)){//传入医生查询医生帮此患者的预约记录
			list = patientReservationDao.findByPatientAndDoctor(patient, doctor, pageRequest);
		if(teamCode == null || teamCode < 1){//传入医生查询医生帮此患者的预约记录
			list = patientReservationDao.findByPatientAndAdminTeamCode(patient, teamCode, pageRequest);
		}else{
			list = patientReservationDao.findByPatient(patient, pageRequest);
		}

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

@ -869,18 +869,18 @@ public class FamilyContractService extends BaseService {
        Calendar begin = Calendar.getInstance();
        Calendar end = Calendar.getInstance();
        // 起始时间
        begin.set(Calendar.HOUR,0);
        begin.set(Calendar.MINUTE,0);
        end.set(Calendar.SECOND,0);
        begin.set(Calendar.MILLISECOND,0);
        begin.set(Calendar.HOUR, 0);
        begin.set(Calendar.MINUTE, 0);
        end.set(Calendar.SECOND, 0);
        begin.set(Calendar.MILLISECOND, 0);
        // 结束时间
        end.set(Calendar.HOUR,0);
        end.set(Calendar.MINUTE,0);
        end.set(Calendar.SECOND,0);
        end.set(Calendar.MILLISECOND,0);
        end.set(Calendar.HOUR, 0);
        end.set(Calendar.MINUTE, 0);
        end.set(Calendar.SECOND, 0);
        end.set(Calendar.MILLISECOND, 0);
        end.set(Calendar.MONTH, 5);
        end.set(Calendar.DATE,30);
        end.set(Calendar.DATE, 30);
        if (month < 2 || month > 5) {
            if (month > 5) {
@ -888,7 +888,7 @@ public class FamilyContractService extends BaseService {
            }
        } else {
            begin.set(Calendar.MONTH, 6);
            begin.set(Calendar.DATE,1);
            begin.set(Calendar.DATE, 1);
            end.add(Calendar.YEAR, 1);
        }
@ -1057,18 +1057,18 @@ public class FamilyContractService extends BaseService {
            Calendar begin = Calendar.getInstance();
            Calendar end = Calendar.getInstance();
            // 起始时间
            begin.set(Calendar.HOUR,0);
            begin.set(Calendar.MINUTE,0);
            end.set(Calendar.SECOND,0);
            begin.set(Calendar.MILLISECOND,0);
            begin.set(Calendar.HOUR, 0);
            begin.set(Calendar.MINUTE, 0);
            end.set(Calendar.SECOND, 0);
            begin.set(Calendar.MILLISECOND, 0);
            // 结束时间
            end.set(Calendar.HOUR,0);
            end.set(Calendar.MINUTE,0);
            end.set(Calendar.SECOND,0);
            end.set(Calendar.MILLISECOND,0);
            end.set(Calendar.HOUR, 0);
            end.set(Calendar.MINUTE, 0);
            end.set(Calendar.SECOND, 0);
            end.set(Calendar.MILLISECOND, 0);
            end.set(Calendar.MONTH, 5);
            end.set(Calendar.DATE,30);
            end.set(Calendar.DATE, 30);
            if (month < 2 || month > 5) {
                if (month > 5) {
@ -1076,7 +1076,7 @@ public class FamilyContractService extends BaseService {
                }
            } else {
                begin.set(Calendar.MONTH, 6);
                begin.set(Calendar.DATE,1);
                begin.set(Calendar.DATE, 1);
                end.add(Calendar.YEAR, 1);
            }
@ -2367,4 +2367,74 @@ public class FamilyContractService extends BaseService {
        Integer count = jdbcTemplate.queryForObject(sql, parms, Integer.class);
        return count;
    }
    /**
     * 查询医生与居民的团队
     *
     * @param patient
     * @param doctor
     * @return
     */
    public JSONObject getPatientAndDoctorTeams(String patient, String doctor) {
        JSONObject result = new JSONObject();
        SignFamily ssSign = signFamilyDao.findSignByPatient(patient, 1);
        SignFamily jtSign = signFamilyDao.findSignByPatient(patient, 2);
        if (ssSign != null && ssSign.getAdminTeamId() != null) {
            JSONObject ssTeam = new JSONObject();
            if (doctor.equals(ssSign.getDoctor()) || doctor.equals(ssSign.getDoctorHealth())) {
                ssTeam.put("hasSign", 1);
            } else {
                ssTeam.put("hasSign", 0);
            }
            AdminTeam team = adminTeamService.getTeam(ssSign.getAdminTeamId());
            if (team != null) {
                if (doctor.equals(team.getLeaderCode())) {
                    ssTeam.put("isLeader", 1);
                } else {
                    ssTeam.put("isLeader", 0);
                }
                ssTeam.put("team", new JSONObject(team));
                if (ssTeam.getInt("hasSign") == 1 || ssTeam.getInt("isLeader") == 1) {
                    result.put("ssTeam", ssTeam);
                }
            }
        }
        if (jtSign != null) {
            JSONObject jtTeam = new JSONObject();
            if (doctor.equals(jtSign.getDoctor()) || doctor.equals(jtSign.getDoctorHealth())) {
                jtTeam.put("hasSign", 1);
            } else {
                jtTeam.put("hasSign", 0);
            }
            AdminTeam team = adminTeamService.getTeam(jtSign.getAdminTeamId());
            if (team != null) {
                if (doctor.equals(team.getLeaderCode())) {
                    jtTeam.put("isLeader", 1);
                } else {
                    jtTeam.put("isLeader", 0);
                }
                jtTeam.put("team", new JSONObject(team));
                if (jtTeam.getInt("hasSign") == 1 || jtTeam.getInt("isLeader") == 1) {
                    result.put("jtTeam", jtTeam);
                }
            }
        }
        if (result.has("jtTeam") || result.has("ssTeam")) {
            result.put("hasSign",1);
        } else {
            result.put("hasSign",0);
        }
        return result;
    }
}

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

@ -1,6 +1,6 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.service.common.account;
@ -127,7 +127,10 @@ public class PatientService extends TokenService {
                break;
            }
        }
        //如果之前患者的openId为空并且openID有值更新时间
        if (!org.springframework.util.StringUtils.isEmpty(openid) && org.springframework.util.StringUtils.isEmpty(patient.getOpenid())) {
            patient.setOpenidTime(new Date());
        }
        patient.setOpenid(openid);
        Patient ps = patientDao.save(patient);
        System.out.print(new JSONObject(ps));

+ 102 - 122
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java

@ -3,8 +3,10 @@ package com.yihu.wlyy.service.third.guahao;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientReservation;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientReservationDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.jw.JwSmjkService;
import com.yihu.wlyy.util.DateUtil;
@ -38,7 +40,7 @@ public class GuahaoXMService implements IGuahaoService {
    private String ORDER_CREATE = "WebRegisterVerify";  //新建预约
    private String ORDER_CANCEL = "Unregister";   //取消预约
    private String ORDER_INFO = "GetReservationRecord";//预约信息
    private String REG_LIST ="GetRegList";//获取市民预约挂号信息
    private String REG_LIST = "GetRegList";//获取市民预约挂号信息
    @Autowired
    private PatientService patientService;
@ -49,31 +51,29 @@ public class GuahaoXMService implements IGuahaoService {
    @Autowired
    private PatientReservationDao patientReservationDao;
    @Autowired
    SignFamilyDao signFamilyDao;
    private ObjectMapper objectMapper = new ObjectMapper();
    /**
     * 解析挂号后
     */
    private String CreateOrderAfter(String response,String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String sectionType,String startTime,String endTime,String patient,String patientName,String cardNo,String clinicCard,String patientPhone,String dname,String dcode) throws Exception
    {
    private String CreateOrderAfter(String response, String hospitalId, String hospitalName, String hosDeptId, String hosDeptName, String doctorId, String doctorName, String sectionType, String startTime, String endTime, String patient, String patientName, String cardNo, String clinicCard, String patientPhone, String dname, String dcode) throws Exception {
        String code = "";
        if(response.startsWith("error")||response.startsWith("System-Error"))
        {
        if (response.startsWith("error") || response.startsWith("System-Error")) {
            throw new Exception(response);
        }
        else if (response.toLowerCase().startsWith("ok")) {      //预约成功
        } else if (response.toLowerCase().startsWith("ok")) {      //预约成功
            // 预约成功,获取预约号
            code = response.replace("OK:", "").replace("ok:", "");
        }
        else if(response.split("\\|").length==3){
        } else if (response.split("\\|").length == 3) {
            code = response.split("\\|")[0];
        }
        else{
        } else {
            throw new Exception(response);
        }
        // 查询医生职称和头像
        GuahaoDoctor doctor =  GetDoctorInfo(doctorId,hospitalId,hosDeptId);
        GuahaoDoctor doctor = GetDoctorInfo(doctorId, hospitalId, hosDeptId);
        // 保存预约记录
        PatientReservation reservation = new PatientReservation();
        reservation.setCode(code);
@ -96,12 +96,20 @@ public class GuahaoXMService implements IGuahaoService {
        reservation.setStartTime(startTime);
        reservation.setEndTime(endTime);
        reservation.setStatus(1);
        if(StringUtils.isNotBlank(dname)){
        if (StringUtils.isNotEmpty(dcode)) {
            SignFamily signFamily = signFamilyDao.findByjiatingPatient(patient);
            if (signFamily == null) {
                throw new Exception("can not find patient's family sign info");
            }
            reservation.setSignType(2);
            reservation.setAdminTeamCode(signFamily.getAdminTeamId());
        }
        if (StringUtils.isNotBlank(dname)) {
            reservation.setDname(dname);//代理签约维护待签约人名称
        }
        if(StringUtils.isNotBlank(dcode)){
        if (StringUtils.isNotBlank(dcode)) {
            reservation.setDoctor(dcode);//代理签约维护待签约人编码
            SendP2PUtil.sendP2Pmsg(dcode,patient,"1","我已成功为您预约:"+startTime+","+hospitalName+hosDeptName+doctorName+"医生的号源。您可直接前往医院就诊</br><a name='guahao' href='javascript:void(0)' data-id='"+code+"'>点击查看详情</a>");
            SendP2PUtil.sendP2Pmsg(dcode, patient, "1", "我已成功为您预约:" + startTime + "," + hospitalName + hosDeptName + doctorName + "医生的号源。您可直接前往医院就诊</br><a name='guahao' href='javascript:void(0)' data-id='" + code + "'>点击查看详情</a>");
        }
        // 保存预约记录
        patientReservationDao.save(reservation);
@ -112,22 +120,21 @@ public class GuahaoXMService implements IGuahaoService {
    /**
     * 预约排班xml转列表
     */
    private List<Map<String,Object>> xmlToList(String xml) throws Exception{
        List<Map<String,Object>> re = new ArrayList<>();
    private List<Map<String, Object>> xmlToList(String xml) throws Exception {
        List<Map<String, Object>> re = new ArrayList<>();
        if (StringUtils.isEmpty(xml)) {
            // 请求失败
            throw new Exception("获取医生排班表失败!");
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
        } else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        Document document = DocumentHelper.parseText(xml);
        Element root = document.getRootElement();
        if(root.element("doctor")!=null)     //包含doctor节点
        if (root.element("doctor") != null)     //包含doctor节点
        {
            root = root.element("doctor");
        }
@ -145,7 +152,7 @@ public class GuahaoXMService implements IGuahaoService {
            String used = e.attributeValue("used");
            // 1正常、2满号、3已过期
            String status = e.attributeValue("status");
            Map<String,Object> map = new HashMap<>();
            Map<String, Object> map = new HashMap<>();
            map.put("date", date);
            map.put("time", time);
            map.put("max", max);
@ -153,7 +160,7 @@ public class GuahaoXMService implements IGuahaoService {
            map.put("status", status);
            // 排班信息
            List<?> sections = e.elements();
            List<Map<String,String>> arrangeList = new ArrayList<>();
            List<Map<String, String>> arrangeList = new ArrayList<>();
            for (Object s : sections) {
                Element section = (Element) s;
                // 限号
@ -165,7 +172,7 @@ public class GuahaoXMService implements IGuahaoService {
                // 结束时间
                String end_time = section.attributeValue("end_time");
                Map<String,String> item = new HashMap<>();
                Map<String, String> item = new HashMap<>();
                item.put("max", s_max);
                item.put("used", s_used);
                item.put("startTime", start_time);
@ -184,23 +191,20 @@ public class GuahaoXMService implements IGuahaoService {
    /**
     * 获取医院列表
     */
    public List<Map<String,String>> GetOrgList(String city,String filter,String type,Integer pageIndex,Integer pageSize) throws Exception{
        List<Map<String,String>> re = new ArrayList<>();
    public List<Map<String, String>> GetOrgList(String city, String filter, String type, Integer pageIndex, Integer pageSize) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        String[] values = null;
        //医院列表
        if(type.equals("1"))
        {
        if (type.equals("1")) {
            values = SOAPUtil.getCredential("<?xml version=\"1.0\" encoding=\"utf-8\"?><root type=\"1\"></root>", true);
        }
        else if(type.equals("2")) //社区列表
        } else if (type.equals("2")) //社区列表
        {
            values = SOAPUtil.getCredential("<?xml version=\"1.0\" encoding=\"utf-8\"?><root type=\"2\"></root>", true);
        }
        if(values!=null && values.length==3)
        {
        if (values != null && values.length == 3) {
            JSONArray params = new JSONArray();
            JSONObject param1 = new JSONObject();
@ -225,8 +229,7 @@ public class GuahaoXMService implements IGuahaoService {
            } else if (StringUtils.startsWith(xml, "System-Error")) {
                // 调用失败
                throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
            }
            else if (StringUtils.startsWith(xml, "Error")) {
            } else if (StringUtils.startsWith(xml, "Error")) {
                // 调用失败
                throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
            }
@ -238,24 +241,24 @@ public class GuahaoXMService implements IGuahaoService {
                String shortName = e.attribute("short_name").getValue();
                String code = e.attribute("code").getValue();
                String name = e.getText();
                Map<String,String> map = new HashMap<>();
                Map<String, String> map = new HashMap<>();
                map.put("id", code);
                map.put("name", shortName);
                map.put("address", name);
                String photo = hospitalMappingDao.getPhotoByMappingCode(code,"1");
                String photo = hospitalMappingDao.getPhotoByMappingCode(code, "1");
                map.put("photo", photo);
                re.add(map);
            }
        }
        return  re;
        return re;
    }
    /**
     * 获取科室接口
     */
    public List<Map<String,String>> GetOrgDepList(String hospitalId,String filter,Integer pageIndex,Integer pageSize) throws Exception{
        List<Map<String,String>> re = new ArrayList<>();
    public List<Map<String, String>> GetOrgDepList(String hospitalId, String filter, Integer pageIndex, Integer pageSize) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        JSONArray params = new JSONArray();
        JSONObject param1 = new JSONObject();
@ -270,8 +273,7 @@ public class GuahaoXMService implements IGuahaoService {
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
        } else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
@ -280,24 +282,23 @@ public class GuahaoXMService implements IGuahaoService {
        List<?> child = root.elements();
        for (Object o : child) {
            Element e = (Element) o;
            if(e.getName().equals("dept"))
            {
            if (e.getName().equals("dept")) {
                String code = e.attribute("code").getValue();
                String name = e.attribute("name").getValue();
                Map<String,String> map = new HashMap<>();
                Map<String, String> map = new HashMap<>();
                map.put("id", code);
                map.put("name", name);
                map.put("hospitalId", hospitalId);
                re.add(map);
            }
        }
        return  re;
        return re;
    }
    /**
     * 获取医生列表接口
     */
    public List<GuahaoDoctor> GetDoctorList(String hospitalId,String hosDeptId,String filter,Integer pageIndex,Integer pageSize) throws Exception{
    public List<GuahaoDoctor> GetDoctorList(String hospitalId, String hosDeptId, String filter, Integer pageIndex, Integer pageSize) throws Exception {
        List<GuahaoDoctor> re = new ArrayList<>();
        JSONArray params = new JSONArray();
@ -319,7 +320,7 @@ public class GuahaoXMService implements IGuahaoService {
        JSONObject param4 = new JSONObject();
        param4.put("key", "?strEnd");
        param4.put("value", DateUtil.getNextDay(nowDate,nextDays));  //一周后时间
        param4.put("value", DateUtil.getNextDay(nowDate, nextDays));  //一周后时间
        params.put(param4);
        String xml = SOAPUtil.post(DOCTOR_LIST, params);
@ -329,8 +330,7 @@ public class GuahaoXMService implements IGuahaoService {
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
        } else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
@ -353,8 +353,7 @@ public class GuahaoXMService implements IGuahaoService {
            String name = e.attributeValue("name");
            // 照片
            String photo = "";
            if(e.attribute("photo")!=null)
            {
            if (e.attribute("photo") != null) {
                photo = e.attributeValue("photo");
            }
            // 挂号费
@ -382,14 +381,14 @@ public class GuahaoXMService implements IGuahaoService {
            doctor.setHospitalName(orgname);
            re.add(doctor);
        }
        return  re;
        return re;
    }
    /**
     * 获取医生排班接口(包含排班详细)
     * status 0 停诊、1正常、2满号、3已过期
     */
    public List<Map<String,Object>> GetDoctorArrange(String hospitalId,String hosDeptId,String doctorId) throws Exception{
    public List<Map<String, Object>> GetDoctorArrange(String hospitalId, String hosDeptId, String doctorId) throws Exception {
        JSONArray params = new JSONArray();
        JSONObject param1 = new JSONObject();
@ -415,20 +414,20 @@ public class GuahaoXMService implements IGuahaoService {
        JSONObject param5 = new JSONObject();
        param5.put("key", "?strEnd");
        param5.put("value", DateUtil.getNextDay(nowDate,nextDays));  //一周后时间
        param5.put("value", DateUtil.getNextDay(nowDate, nextDays));  //一周后时间
        params.put(param5);
        String xml = SOAPUtil.post(DOCTOR_ARRANGE, params);
        return  xmlToList(xml);
        return xmlToList(xml);
    }
    /**
     * 获取医生排班接口(一级)
     * status 0 停诊、1正常、2满号、3已过期
     */
    public List<Map<String,String>> GetDoctorArrangeSimple(String hospitalId,String hosDeptId,String doctorId) throws Exception{
        List<Map<String,String>> re = new ArrayList<>();
    public List<Map<String, String>> GetDoctorArrangeSimple(String hospitalId, String hosDeptId, String doctorId) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        JSONArray params = new JSONArray();
        JSONObject param1 = new JSONObject();
@ -454,7 +453,7 @@ public class GuahaoXMService implements IGuahaoService {
        JSONObject param5 = new JSONObject();
        param5.put("key", "?strEnd");
        param5.put("value", DateUtil.getNextDay(nowDate,nextDays));  //一周后时间
        param5.put("value", DateUtil.getNextDay(nowDate, nextDays));  //一周后时间
        params.put(param5);
        String xml = SOAPUtil.post(DOCTOR_ARRANGE_SIMPLE, params);
@ -464,8 +463,7 @@ public class GuahaoXMService implements IGuahaoService {
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
        } else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
@ -484,7 +482,7 @@ public class GuahaoXMService implements IGuahaoService {
            String used = e.attributeValue("used");
            // 1正常、2满号、3已过期
            String status = e.attributeValue("status");
            Map<String,String> map = new HashMap<>();
            Map<String, String> map = new HashMap<>();
            map.put("date", date);
            map.put("time", time);
            map.put("max", max);
@ -493,13 +491,13 @@ public class GuahaoXMService implements IGuahaoService {
            re.add(map);
        }
        return  re;
        return re;
    }
    /**
     * 创建挂号单
     */
    public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone) throws Exception{
    public String CreateOrder(String hospitalId, String hospitalName, String hosDeptId, String hosDeptName, String doctorId, String doctorName, String arrangeDate, String patient, String patientName, String cardNo, String clinicCard, String patientPhone) throws Exception {
        String re = "";
        Patient p = patientService.findByCode(patient);
@ -507,8 +505,8 @@ public class GuahaoXMService implements IGuahaoService {
            throw new Exception("患者信息不存在!");
        }
        Map<String,String> map = objectMapper.readValue(arrangeDate,Map.class);
        if(map.containsKey("sectionType") && map.containsKey("startTime")) {
        Map<String, String> map = objectMapper.readValue(arrangeDate, Map.class);
        if (map.containsKey("sectionType") && map.containsKey("startTime")) {
            String sectionType = map.get("sectionType");
            String startTime = map.get("startTime");
            String endTime = map.get("endTime");
@ -555,14 +553,13 @@ public class GuahaoXMService implements IGuahaoService {
            } else if (StringUtils.startsWith(response, "System-Error")) {
                // 调用失败
                throw new Exception(response.substring(response.indexOf(":") + 1, response.length()));
            }  else if (StringUtils.startsWith(response, "Error")) {
            } else if (StringUtils.startsWith(response, "Error")) {
                // 调用失败
                throw new Exception(response.substring(response.indexOf(":") + 1, response.length()));
            }
            re = CreateOrderAfter(response,hospitalId,hospitalName,hosDeptId,hosDeptName,doctorId,doctorName,sectionType,startTime,endTime,patient,patientName,cardNo,clinicCard,patientPhone,null,null);
        }
        else{
            re = CreateOrderAfter(response, hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, sectionType, startTime, endTime, patient, patientName, cardNo, clinicCard, patientPhone, null, null);
        } else {
            throw new Exception("该排班信息错误或者不存在!");
        }
@ -570,13 +567,10 @@ public class GuahaoXMService implements IGuahaoService {
    }
    /**
     * 取消挂号单
     */
    public boolean CancelOrder(String orderId,String clinicCard)   throws Exception
    {
    public boolean CancelOrder(String orderId, String clinicCard) throws Exception {
        JSONArray params = new JSONArray();
        JSONObject param1 = new JSONObject();
@ -608,8 +602,7 @@ public class GuahaoXMService implements IGuahaoService {
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
        } else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
@ -624,8 +617,7 @@ public class GuahaoXMService implements IGuahaoService {
    /**
     * 获取医生信息
     */
    public GuahaoDoctor GetDoctorInfo(String doctorId,String hospitalId,String hosDeptId) throws Exception
    {
    public GuahaoDoctor GetDoctorInfo(String doctorId, String hospitalId, String hosDeptId) throws Exception {
        GuahaoDoctor doctor = new GuahaoDoctor();
        JSONArray params = new JSONArray();
@ -644,7 +636,7 @@ public class GuahaoXMService implements IGuahaoService {
        params.put(param3);
        JSONObject param4 = new JSONObject();
        param4.put("key", "?strEnd");
        param4.put("value", DateUtil.getNextDay(nowDate,nextDays));  //一周后时间
        param4.put("value", DateUtil.getNextDay(nowDate, nextDays));  //一周后时间
        params.put(param4);
        String xml = SOAPUtil.post(DOCTOR_LIST, params);
@ -654,8 +646,7 @@ public class GuahaoXMService implements IGuahaoService {
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
        } else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
@ -667,8 +658,7 @@ public class GuahaoXMService implements IGuahaoService {
            // 医生编码
            String code = e.attributeValue("code");
            if(code.equals(doctorId))
            {
            if (code.equals(doctorId)) {
                // 性别
                String sex = e.attributeValue("sex");
                // 职称
@ -681,8 +671,7 @@ public class GuahaoXMService implements IGuahaoService {
                String name = e.attributeValue("name");
                // 照片
                String photo = "";
                if(e.attribute("photo")!=null)
                {
                if (e.attribute("photo") != null) {
                    photo = e.attributeValue("photo");
                }
                // 挂号费
@ -711,15 +700,14 @@ public class GuahaoXMService implements IGuahaoService {
                break;
            }
        }
        return  doctor;
        return doctor;
    }
    /**
     * 获取预约状态
     * 0 撤销 1 确认 2 已诊  3停诊
     */
    public Integer GetOrderStatus(String hospitalId,String orderId,String clinicCard) throws Exception
    {
    public Integer GetOrderStatus(String hospitalId, String orderId, String clinicCard) throws Exception {
        Integer re = null;
        try {
            StringBuffer sb = new StringBuffer();
@ -789,9 +777,7 @@ public class GuahaoXMService implements IGuahaoService {
            } else {
                throw new Exception("获取预约状态失败!");
            }
        }
        catch (Exception ex)
        {
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return re;
@ -800,10 +786,9 @@ public class GuahaoXMService implements IGuahaoService {
    /**
     * 根据患者医保卡获取近三个月的预约记录
     */
    public List<PatientReservation> GetRegList(String patientCode,String strStart,String strEnd) throws Exception
    {
    public List<PatientReservation> GetRegList(String patientCode, String strStart, String strEnd) throws Exception {
        Patient patient = patientService.findByCode(patientCode);
        if(patient==null){
        if (patient == null) {
            throw new Exception("不存在该用户!");
        }
@ -830,7 +815,7 @@ public class GuahaoXMService implements IGuahaoService {
        params.put(param4);
        JSONObject param5 = new JSONObject();
        param5.put("key", "?strKey");
        param5.put("value",values[2]);  //一周后时间
        param5.put("value", values[2]);  //一周后时间
        params.put(param5);
        String xml = SOAPUtil.post(REG_LIST, params);
        if (StringUtils.isEmpty(xml)) {
@ -839,8 +824,7 @@ public class GuahaoXMService implements IGuahaoService {
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
        } else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
@ -849,7 +833,7 @@ public class GuahaoXMService implements IGuahaoService {
        List<?> child = root.elements();
        if(child.size()>0) {
        if (child.size() > 0) {
            for (Object o : child) {
                Element e = (Element) o;
                // 医生编码
@ -918,8 +902,7 @@ public class GuahaoXMService implements IGuahaoService {
    /**
     * 根据患者,预约编号,机构编号获取单条记录预约记录
     */
    public PatientReservation getRegDetail(String patientCode,String orgCode,String regCode) throws Exception
    {
    public PatientReservation getRegDetail(String patientCode, String orgCode, String regCode) throws Exception {
        //获取签名信息
        Patient patient = patientService.findByCode(patientCode);
        StringBuffer sb = new StringBuffer();
@ -953,8 +936,7 @@ public class GuahaoXMService implements IGuahaoService {
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error"))  {
        } else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
@ -962,12 +944,11 @@ public class GuahaoXMService implements IGuahaoService {
        Element root = document.getRootElement();
        List<?> child = root.elements();
        if(patient==null){
        if (patient == null) {
            throw new Exception("获取挂号人员信息失败!");
        }
        if(child.size()>0)
        {
        if (child.size() > 0) {
            Element e = (Element) child.get(0);
            // 医生编码
            String regdate = e.attributeValue("regdate");//预约日期
@ -979,14 +960,14 @@ public class GuahaoXMService implements IGuahaoService {
            String OrgCode = e.attributeValue("org_code");//医疗机构编码
            String org = e.attributeValue("org_name");//医疗机构名称
            String DeptCode = e.attributeValue("dept_code");//科室代码
            String dept =e.attributeValue("dept_name");//科室
            String dept = e.attributeValue("dept_name");//科室
            String DoctorCode = e.attributeValue("doctor_code");//医生代码
            String doctor = e.attributeValue("doctor_name");//医生
            String Introduction = e.attributeValue("introduction");//医生简介
            String status = e.attributeValue("status");//状态:删除、新建、确认、已诊
            String enter_time = e.attributeValue("enter_time");//预约登记时间
            String notes = e.attributeValue("notes");//备注
            String code  = e.getText();//预约号
            String code = e.getText();//预约号
            PatientReservation patientReservation = new PatientReservation();
            patientReservation.setCode(code);
            patientReservation.setSectionType(time);
@ -1005,7 +986,7 @@ public class GuahaoXMService implements IGuahaoService {
            patientReservation.setName(patient.getName());
            patientReservation.setIdcard(patient.getIdcard());
            patientReservation.setPhone(patient.getMobile());
            switch (status){
            switch (status) {
                case "删除":
                    patientReservation.setStatus(0);
                    break;
@ -1018,30 +999,31 @@ public class GuahaoXMService implements IGuahaoService {
                case "已诊":
                    patientReservation.setStatus(3);
                    break;
                default:patientReservation.setStatus(4);
            };
                default:
                    patientReservation.setStatus(4);
            }
            ;
            patientReservation.setSsc(patient.getSsc());
            GuahaoDoctor guahaoDoctor = GetDoctorInfo(DoctorCode, OrgCode, DeptCode);
            patientReservation.setDoctorPhoto(guahaoDoctor.getPhoto());//照片
            patientReservation.setDoctorJob(guahaoDoctor.getTitle());//职称
            return patientReservation;
        }
        else{
        } else {
            return null;
        }
    }
    @Autowired
    JwSmjkService jwSmjkService;
    /******************************** 基卫内网服务 ************************************************/
    public List<Map<String,Object>> GetDoctorArrangeTenDay(String hospitalId,String hosDeptId,String doctorId) throws Exception {
    public List<Map<String, Object>> GetDoctorArrangeTenDay(String hospitalId, String hosDeptId, String doctorId) throws Exception {
        String strStart = DateUtil.getStringDateShort(); //当前时间;
        String strEnd = DateUtil.getNextDay(strStart,11);         //10天预约
        String strEnd = DateUtil.getNextDay(strStart, 11);         //10天预约
        String response = jwSmjkService.getRegDeptSpeDoctorSectionList(hospitalId,hosDeptId,strStart,strEnd,doctorId);
        String response = jwSmjkService.getRegDeptSpeDoctorSectionList(hospitalId, hosDeptId, strStart, strEnd, doctorId);
        return xmlToList(response);
    }
@ -1049,8 +1031,7 @@ public class GuahaoXMService implements IGuahaoService {
    /**
     * 转诊预约挂号
     */
    public String CreateOrderByDoctor(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone,String dname,String dcode) throws Exception
    {
    public String CreateOrderByDoctor(String hospitalId, String hospitalName, String hosDeptId, String hosDeptName, String doctorId, String doctorName, String arrangeDate, String patient, String patientName, String cardNo, String clinicCard, String patientPhone, String dname, String dcode) throws Exception {
        String re = "";
        Patient p = patientService.findByCode(patient);
@ -1058,17 +1039,16 @@ public class GuahaoXMService implements IGuahaoService {
            throw new Exception("患者信息不存在!");
        }
        Map<String,String> map = objectMapper.readValue(arrangeDate,Map.class);
        if(map.containsKey("sectionType") && map.containsKey("startTime")) {
        Map<String, String> map = objectMapper.readValue(arrangeDate, Map.class);
        if (map.containsKey("sectionType") && map.containsKey("startTime")) {
            String sectionType = map.get("sectionType");
            String startTime = map.get("startTime");
            String endTime = map.get("endTime");
            String response = jwSmjkService.webRegisterByFamily(cardNo,patientName,clinicCard,sectionType,startTime,hospitalId,hosDeptId,hosDeptName,doctorId,doctorName);
            String response = jwSmjkService.webRegisterByFamily(cardNo, patientName, clinicCard, sectionType, startTime, hospitalId, hosDeptId, hosDeptName, doctorId, doctorName);
            re = CreateOrderAfter(response,hospitalId,hospitalName,hosDeptId,hosDeptName,doctorId,doctorName,sectionType,startTime,endTime,patient,patientName,cardNo,clinicCard,patientPhone,dname,dcode);
        }
        else{
            re = CreateOrderAfter(response, hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, sectionType, startTime, endTime, patient, patientName, cardNo, clinicCard, patientPhone, dname, dcode);
        } else {
            throw new Exception("该排班信息错误或者不存在!");
        }

+ 4 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java

@ -198,7 +198,6 @@ public class WechatController extends WeixinBaseController {
            return write(200, "验证成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "验证失败");
        }
    }
@ -303,7 +302,10 @@ public class WechatController extends WeixinBaseController {
            password = StringUtils.reverse(password);
            patient.setPassword(MD5.GetMD5Code(password + salt));
            patient.setSsc(ssc);
            patient.setOpenid(openid);
            if(!org.springframework.util.StringUtils.isEmpty(openid)){
                patient.setOpenid(openid);
                patient.setOpenidTime(new Date());
            }
            JSONObject json = patientService.register(idcard, ssc, name, mobile, MD5.GetMD5Code(password + salt)
                    , salt, openid, 3);
            if (json != null) {

+ 0 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/area/AreaController.java

@ -37,7 +37,6 @@ public class AreaController extends BaseController {
            List<Town> towns = areaService.getCityTowns(city);
            return write(200, "查询成功", "data", towns == null ? new ArrayList<Town>() : towns);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

+ 0 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/hospital/HospitalCommonController.java

@ -29,7 +29,6 @@ public class HospitalCommonController extends BaseController {
            List<Hospital> hospitals = hospitalService.getHositalByTownCode(town);
            return write(200, "查询成功", "data", hospitals == null ? new ArrayList<Hospital>() : hospitals);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

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

@ -42,7 +42,6 @@ public class QrCodeController extends WeixinBaseController {
                return error(-1, "生成二维码失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "生成二维码失败!");
        }
    }
@ -63,7 +62,6 @@ public class QrCodeController extends WeixinBaseController {
                return error(-1, "生成二维码失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "生成二维码失败!");
        }
    }
@ -84,7 +82,6 @@ public class QrCodeController extends WeixinBaseController {
                return error(-1, "生成二维码失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "生成二维码失败!");
        }
    }
@ -105,7 +102,6 @@ public class QrCodeController extends WeixinBaseController {
                return error(-1, "生成二维码失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "生成二维码失败!");
        }
    }
@ -142,14 +138,14 @@ public class QrCodeController extends WeixinBaseController {
                while ((length = inputStream.read(b)) > 0) {
                    outputStream.write(b, 0, length);
                }
                outputStream.flush();
                outputStream.close();
                inputStream.close();
            } else {
                response.setStatus(404);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
@ -184,7 +180,7 @@ public class QrCodeController extends WeixinBaseController {
                while ((length = inputStream.read(b)) > 0) {
                    outputStream.write(b, 0, length);
                }
                outputStream.flush();
                outputStream.close();
                inputStream.close();
            } else {
@ -235,7 +231,7 @@ public class QrCodeController extends WeixinBaseController {
                while ((length = inputStream.read(b)) > 0) {
                    outputStream.write(b, 0, length);
                }
                outputStream.flush();
                outputStream.close();
                inputStream.close();
            } else {
@ -284,14 +280,14 @@ public class QrCodeController extends WeixinBaseController {
                while ((length = inputStream.read(b)) > 0) {
                    outputStream.write(b, 0, length);
                }
                outputStream.flush();
                outputStream.close();
                inputStream.close();
            } else {
                throw new Exception("医生信息不存在!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            response.setStatus(500);
        }
    }
@ -319,14 +315,13 @@ public class QrCodeController extends WeixinBaseController {
                while ((length = inputStream.read(b)) > 0) {
                    outputStream.write(b, 0, length);
                }
                outputStream.flush();
                outputStream.close();
                inputStream.close();
            } else {
                response.setStatus(500);
            }
        } catch (Exception e) {
            e.printStackTrace();
            response.setStatus(500);
        }
    }
@ -355,14 +350,13 @@ public class QrCodeController extends WeixinBaseController {
                while ((length = inputStream.read(b)) > 0) {
                    outputStream.write(b, 0, length);
                }
                outputStream.flush();
                outputStream.close();
                inputStream.close();
            } else {
                response.setStatus(500);
            }
        } catch (Exception e) {
            e.printStackTrace();
            response.setStatus(500);
        }
    }
@ -391,14 +385,13 @@ public class QrCodeController extends WeixinBaseController {
                while ((length = inputStream.read(b)) > 0) {
                    outputStream.write(b, 0, length);
                }
                outputStream.flush();
                outputStream.close();
                inputStream.close();
            } else {
                response.setStatus(500);
            }
        } catch (Exception e) {
            e.printStackTrace();
            response.setStatus(500);
        }
    }

+ 0 - 10
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java

@ -69,7 +69,6 @@ public class ManagerUtilController extends BaseController {
            diseaseService.updateToDisease();
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -85,7 +84,6 @@ public class ManagerUtilController extends BaseController {
        try {
            return write(200, "查询成功", "data", redisTemplate.opsForValue().get("disease:" + patient));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -106,7 +104,6 @@ public class ManagerUtilController extends BaseController {
                return write(200, "任务已存在");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "启动失败");
        }
    }
@ -122,7 +119,6 @@ public class ManagerUtilController extends BaseController {
            workTimeService.consultTimesRemain(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -139,7 +135,6 @@ public class ManagerUtilController extends BaseController {
            statisticsService.peopleNumToRedis();
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -155,7 +150,6 @@ public class ManagerUtilController extends BaseController {
            manageUtilService.signPatientSetGroup();
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -171,7 +165,6 @@ public class ManagerUtilController extends BaseController {
            manageUtilService.setSignTeamAndGroupByPage(page);
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -187,7 +180,6 @@ public class ManagerUtilController extends BaseController {
            manageUtilService.setSignTeamAndGroupById(id);
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -208,7 +200,6 @@ public class ManagerUtilController extends BaseController {
                return write(200, "查询成功","data",ManageUtilService.errorSigns);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -224,7 +215,6 @@ public class ManagerUtilController extends BaseController {
            new Thread(new SignTeamAndGroupRunnable(start,end)).start();
            return write(200,"启动成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "启动失败");
        }
    }

+ 0 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/WlyySerivceController.java

@ -52,7 +52,6 @@ public class WlyySerivceController extends BaseController{
                return write(200,"调用成功","data",jsonString);
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"调用失败");
        }
    }
@ -98,7 +97,6 @@ public class WlyySerivceController extends BaseController{
                return write(200,"调用成功","data",jsonString);
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"调用失败");
        }
    }
@ -145,7 +143,6 @@ public class WlyySerivceController extends BaseController{
                return write(200,"调用成功","data",jsonString);
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"调用失败");
        }
    }
@ -187,7 +184,6 @@ public class WlyySerivceController extends BaseController{
                return write(200,"调用成功","data",jsonString);
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"调用失败");
        }
    }

+ 0 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/verified/VerifiedController.java

@ -69,7 +69,6 @@ public class VerifiedController extends BaseController {
			return write(200, "人脸识别成功!");
		} catch (Exception e) {
			e.printStackTrace();
			return error(-1, e.getMessage());
		}
	}

+ 0 - 9
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java

@ -269,7 +269,6 @@ public class DoctorController extends BaseController {
            return write(200, "查询成功", "data", hos);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -330,7 +329,6 @@ public class DoctorController extends BaseController {
            JSONArray doctors = doctorInfoService.findWorkingDoctorListByDept(dept, hospital, level, key, page, pagesize);
            return write(200, "查询成功", "data", doctors);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -1435,7 +1433,6 @@ public class DoctorController extends BaseController {
            }
            return write(200, "查询成功!", "doctors", array);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }
@ -1481,7 +1478,6 @@ public class DoctorController extends BaseController {
                return error(-1, "更新失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -1529,7 +1525,6 @@ public class DoctorController extends BaseController {
                return error(-1, "更新失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -1602,7 +1597,6 @@ public class DoctorController extends BaseController {
        } catch (Exception e) {
            redisTemplate.opsForValue().set("jianguanshifenpei:" + getUID(), "0");
            redisTemplate.expire("jianguanshifenpei:" + getUID(), 10, TimeUnit.MINUTES);
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -1679,7 +1673,6 @@ public class DoctorController extends BaseController {
                return write(-1, "手机号更新失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "手机号更新失败");
        }
    }
@ -1734,7 +1727,6 @@ public class DoctorController extends BaseController {
            doctorInfoService.updatePassword(newPassword1, newPassword2, oldPassword, doctorCode);
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }
@ -1773,7 +1765,6 @@ public class DoctorController extends BaseController {
        try {
            return write(200, "成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

+ 24 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java

@ -15,6 +15,8 @@ import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.MessageType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -164,6 +166,28 @@ public class DoctorConsultController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "list_by_team", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value = "居民咨询列表查询")
    public String listByTeam(@RequestParam @ApiParam(value = "居民Code") String patient,
                             @RequestParam @ApiParam(value = "团队Code") Long teamCode,
                             @RequestParam @ApiParam(value = "第几页") int page,
                             @RequestParam @ApiParam(value = "页大小") int pagesize) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "请输入需查询的居民");
            }
            if (teamCode == null || teamCode < 1) {
                return error(-1, "请输入需查询的居民的团队");
            }
            page = page > 0 ? page - 1 : 0;
            JSONArray jsonArray = consultTeamService.findByPatientAndTeam(patient, teamCode, page, pagesize);
            return write(200, "查询成功", "data", jsonArray);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "查询失败!");
        }
    }
    /**
     * 获取三师家庭咨询
     *
@ -337,7 +361,6 @@ public class DoctorConsultController extends WeixinBaseController {
            List<Map<String, Object>> list = consultTeamService.getConsultSign(consults.split(","));
            return write(200, "查询成功", "data", new JSONArray(list));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -694,7 +717,6 @@ public class DoctorConsultController extends WeixinBaseController {
                return write(200, "查询成功", "data", "");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -906,7 +928,6 @@ public class DoctorConsultController extends WeixinBaseController {
            ConsultTeam ct = consultTeamService.findByConsultCode(consult);
            return write(200, "查询咨询状态成功", "data", ct.getStatus());
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询咨询状态失败");
        }
    }

+ 0 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/discussion/DoctorDiscussionGroupController.java

@ -363,7 +363,6 @@ public class DoctorDiscussionGroupController extends BaseController {
                return error(-1, "创建讨论组失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "创建讨论组失败");
        }
    }
@ -401,7 +400,6 @@ public class DoctorDiscussionGroupController extends BaseController {
            return write(200, "查询成功", "data", group);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -561,7 +559,6 @@ public class DoctorDiscussionGroupController extends BaseController {
            return write(200, "添加成员成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "添加成员失败!");
        }
    }

+ 0 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/family/DoctorFamilyController.java

@ -58,7 +58,6 @@ public class DoctorFamilyController extends WeixinBaseController {
            return write(200, "查询成功", "list", result.size() > 0 ? new JSONArray(result.values()) : new JSONArray());
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }

+ 325 - 305
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java

@ -13,10 +13,7 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
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.ResponseBody;
import org.springframework.web.bind.annotation.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
@ -26,313 +23,336 @@ import com.yihu.wlyy.web.BaseController;
/**
 * 医生端:随访接口
 * 
 * @author hzp add 2016-12-07
 *
 * @author hzp add 2016-12-07
 */
@Controller
@RequestMapping(value = "/doctor/followup", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-随访接口")
public class DoctorFollowUpController extends BaseController {
	@Autowired
	private FollowUpService followUpService;
	/*************************************** 随访计划 ****************************************************************************/
	@ApiOperation("获取随访列表")
	@RequestMapping(value = "/list", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getList(@ApiParam(name="startTime",value="开始时间",defaultValue = "2016-12-07 00:00:00")
							  @RequestParam(value="startTime",required = true) String startTime,
							  @ApiParam(name="endTime",value="结束时间",defaultValue = "2016-12-14 00:00:00")
							  @RequestParam(value="endTime",required = true) String endTime,
						      @ApiParam(name="page",value="第几页",defaultValue = "1")
							  @RequestParam(value="page",required = true) String page,
							  @ApiParam(name="pageSize",value="每页几行",defaultValue = "10")
							  @RequestParam(value="pageSize",required = true) String pageSize) {
		try {
			List<Map<String,String>> result = followUpService.getListByDoctor(getUID(),startTime,endTime,page,pageSize);     //"64de9952-5b15-11e6-8344-fa163e8aee56"
			return write(200, "获取随访列表成功!", "data", result);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取随访列表失败!"+e.getMessage());
		}
	}
	@ApiOperation("获取随访列表(创建者)")
	@RequestMapping(value = "/createrList", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getCreaterList(@ApiParam(name="startTime",value="开始时间",defaultValue = "2016-12-07 00:00:00")
						  @RequestParam(value="startTime",required = true) String startTime,
						  @ApiParam(name="endTime",value="结束时间",defaultValue = "2016-12-14 00:00:00")
						  @RequestParam(value="endTime",required = true) String endTime,
						  @ApiParam(name="page",value="第几页",defaultValue = "1")
						  @RequestParam(value="page",required = true) String page,
						  @ApiParam(name="pageSize",value="每页几行",defaultValue = "10")
						  @RequestParam(value="pageSize",required = true) String pageSize) {
		try {
			List<Map<String,String>> result = followUpService.getListByCreater(getUID(),startTime,endTime,page,pageSize);     //"64de9952-5b15-11e6-8344-fa163e8aee56"
			return write(200, "获取随访列表成功!", "data", result);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取随访列表失败!"+e.getMessage());
		}
	}
	@ApiOperation("新增随访计划(批量)")
	@RequestMapping(value = "/addFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String addFollowupPlan(@ApiParam(name="patient",value="患者代码",defaultValue = "443a196ef8744536a531260eb26c05d7")
						  @RequestParam(value="patient",required = true) String patient,
						  @ApiParam(name="data",value="随访计划列表json",defaultValue = "[{\"date\":\"2016-12-16 20:00:00\",\"type\":\"10\",\"doctor\":\"64de9952-5b15-11e6-8344-fa163e8aee56\"},{\"date\":\"2016-12-17 15:00:00\",\"type\":\"3\",\"doctor\":\"64de9952-5b15-11e6-8344-fa163e8aee56\"}]")
						  @RequestParam(value="data",required = true) String data) {
		try {
			followUpService.addFollowupPlan(getUID(),patient,data);
			return write(200, "新增随访计划成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "新增随访计划失败!"+e.getMessage());
		}
	}
	@ApiOperation("编辑随访计划")
	@RequestMapping(value = "/editFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String editFollowupPlan(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
								@RequestParam(value="id",required = true) String id,
								@ApiParam(name="planDate",value="随访计划时间",defaultValue = "2016-12-14 20:00:00")
								@RequestParam(value="planDate",required = true) String planDate,
								@ApiParam(name="followupType",value="随访方式【字典FOLLOWUP_WAY_DICT】",defaultValue = "12")
								@RequestParam(value="followupType",required = true) String followupType) {
		try {
			followUpService.editFollowupPlan(getUID(),id,planDate,followupType);
			return write(200, "编辑随访计划成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "编辑随访计划失败!"+e.getMessage());
		}
	}
	@ApiOperation("开始随访记录")
	@RequestMapping(value = "/startFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String startFollowup(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
								 @RequestParam(value="id",required = true) String id,
								 @ApiParam(name="date",value="随访时间",defaultValue = "2016-12-14 20:00:00")
								 @RequestParam(value="date",required = true) String date,
								 @ApiParam(name="followupType",value="随访方式【字典FOLLOWUP_WAY_DICT】",defaultValue = "12")
								 @RequestParam(value="followupType",required = true) String followupType,
								 @ApiParam(name="followupClass",value="随访类别【1.高血压 2.糖尿病】",defaultValue = "1")
								 @RequestParam(value="followupClass",required = true) String followupClass,
								 @ApiParam(name="followupManagerStatus",value="随访管理状态【字典FOLLOWUP_MANAGER_STATUS】",defaultValue = "1")
								 @RequestParam(value="followupManagerStatus",required = false) String followupManagerStatus) {
		try {
			followUpService.startFollowup(id,date,followupType,followupClass,followupManagerStatus);
			return write(200, "开始随访记录成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "开始随访记录失败!"+e.getMessage());
		}
	}
	@ApiOperation("新增临时随访记录(返回ID)")
	@RequestMapping(value = "/addFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String addFollowup(@ApiParam(name="patient",value="患者代码",defaultValue = "443a196ef8744536a531260eb26c05d7")
								@RequestParam(value="patient",required = true) String patient,
								@ApiParam(name="date",value="下次随访时间",defaultValue = "2016-12-15 20:00:00")
								@RequestParam(value="date",required = true) String date,
								@ApiParam(name="followupType",value="随访方式【字典FOLLOWUP_WAY_DICT】",defaultValue = "12")
								@RequestParam(value="followupType",required = true) String followupType,
								@ApiParam(name="followupClass",value="随访类别【1.高血压 2.糖尿病】",defaultValue = "1")
								@RequestParam(value="followupClass",required = true) String followupClass,
								@ApiParam(name="followupManagerStatus",value="随访管理状态【字典FOLLOWUP_MANAGER_STATUS】",defaultValue = "1")
								@RequestParam(value="followupManagerStatus",required = false) String followupManagerStatus) {
		try {
			String response = followUpService.addFollowup(getUID(),patient,date,followupType,followupClass,followupManagerStatus);
			return write(200, "新增临时随访记录成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "新增临时随访记录失败!"+e.getMessage());
		}
	}
	@ApiOperation("取消随访计划")
	@RequestMapping(value = "/cancelFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String cancelFollowupPlan(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
								      @RequestParam(value="id",required = true) String id)
	{
		try {
			followUpService.cancelFollowupPlan(id);
			return write(200, "取消随访计划成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "取消随访计划失败!"+e.getMessage());
		}
	}
	@ApiOperation("完成随访记录")
	@RequestMapping(value = "/finishFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String finishFollowup(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
									 @RequestParam(value="id",required = true) String id)
	{
		try {
			followUpService.finishFollowup(id);
			return write(200, "完成随访记录成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "完成随访记录失败!"+e.getMessage());
		}
	}
	/*********************************** 随访详情 *******************************************************************/
	@ApiOperation("获取随访信息")
	@RequestMapping(value = "/getFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getFollowup(@ApiParam(name="id",value="随访记录ID",defaultValue = "4")
									 @RequestParam(value="id",required = true) String id)
	{
		try {
			Map<String,String> response = followUpService.getFollowup(id);
			return write(200, "获取随访信息成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取随访信息失败!"+e.getMessage());
		}
	}
	@ApiOperation("获取随访项目列表")
	@RequestMapping(value = "/getFollowupProject", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getFollowupProject(@ApiParam(name="id",value="随访记录ID",defaultValue = "4")
									 @RequestParam(value="id",required = true) String id)
	{
		try {
			List<Map<String,String>> list = followUpService.getFollowupProject(id);
			return write(200, "获取随访项目列表成功!","data",list);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取随访项目列表失败!"+e.getMessage());
		}
	}
	@ApiOperation("获取随访项目数据")
	@RequestMapping(value = "/getFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getFollowupProjectData(@ApiParam(name="id",value="随访记录ID",defaultValue = "4")
									 @RequestParam(value="id",required = true) String id,
									 @ApiParam(name="followupProject",value="随访项目",defaultValue = "2")
									 @RequestParam(value="followupProject",required = true) String followupProject)
	{
		try {
			Map<String,String> response = followUpService.getFollowupProjectData(id,followupProject);
			return write(200, "获取随访项目数据成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取随访项目数据失败!"+e.getMessage());
		}
	}
	@ApiOperation("保存随访项目数据")
	@RequestMapping(value = "/saveFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String saveFollowupProjectData(@ApiParam(name="id",value="随访记录ID",defaultValue = "4")
								   @RequestParam(value="id",required = true) String id,
								   @ApiParam(name="followupProject",value="随访项目",defaultValue = "2")
								   @RequestParam(value="followupProject",required = true) String followupProject,
								   @ApiParam(name="followupProjectData",value="随访项目数据",defaultValue = "{\"WEIGHT\":\"76\",\"WEIGHT_EXP\":\"60\",\"BMI\":\"11\"}")
								   @RequestParam(value="followupProjectData",required = true) String followupProjectData)
	{
		try {
			followUpService.saveFollowupProjectData(id,followupProject,followupProjectData);
			return write(200, "保存随访项目数据成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "保存随访项目数据失败!"+e.getMessage());
		}
	}
	/*********************************** 电话随访 *****************************************************************/
	@ApiOperation("获取电话随访内容")
	@RequestMapping(value = "/getFollowupPhone", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getFollowupPhone(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
									@RequestParam(value="id",required = true) String id) {
		try {
			String response = followUpService.getFollowupPhone(id);
			return write(200, "获取电话随访内容成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取电话随访内容失败!"+e.getMessage());
		}
	}
	@ApiOperation("记录电话随访内容")
	@RequestMapping(value = "/saveFollowupPhone", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String saveFollowupPhone(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
								  @RequestParam(value="id",required = true) String id,
								  @ApiParam(name="content",value="电话随访内容",defaultValue = "")
								  @RequestParam(value="content",required = true) String content) {
		try {
			followUpService.saveFollowupPhone(id,content);
			return write(200, "记录电话随访内容成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "记录电话随访内容失败!"+e.getMessage());
		}
	}
	/*************************************** 上次随访 ********************************************/
	@ApiOperation("获取上次随访")
	@RequestMapping(value = "/getLastFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getLastFollowup(@ApiParam(name="patient",value="患者代码",defaultValue = "P20161008001")
								   @RequestParam(value="patient",required = true) String patient,
								   @ApiParam(name="followClass",value="随访类别",defaultValue = "1")
								   @RequestParam(value="followClass",required = true) String followClass)
	{
		try {
			Map<String,String> response = followUpService.getLastFollowup(getUID(),patient,followClass);
			return write(200, "获取上次随访成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取上次随访失败!"+e.getMessage());
		}
	}
	@ApiOperation("复制上次随访数据")
	@RequestMapping(value = "/copyFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String copyFollowup(@ApiParam(name="id",value="本地随访ID",defaultValue = "")
								  @RequestParam(value="id",required = true) Long id,
								  @ApiParam(name="fromId",value="拷贝随访记录ID",defaultValue = "")
								  @RequestParam(value="fromId",required = true) Long fromId)
	{
		try {
			followUpService.copyFollowup(id,fromId);
			return write(200, "复制上次随访成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "复制上次随访失败!"+e.getMessage());
		}
	}
	/*************************************** 发送随访计划消息 ********************************************/
	@ApiOperation("发送随访计划消息")
	@RequestMapping(value = "/sendMessage", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String sendMessage(@ApiParam(name="date",value="日期",defaultValue = "2017-01-05")
								  @RequestParam(value="date",required = true) String date)
	{
		try {
			followUpService.sendMessage(date);
			return write(200, "发送随访计划消息成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "发送随访计划消息失败!"+e.getMessage());
		}
	}
    @Autowired
    private FollowUpService followUpService;
    /*************************************** 随访计划 ****************************************************************************/
    @ApiOperation("获取随访列表")
    @RequestMapping(value = "/list", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getList(@ApiParam(name = "startTime", value = "开始时间", defaultValue = "2016-12-07 00:00:00")
                          @RequestParam(value = "startTime", required = true) String startTime,
                          @ApiParam(name = "endTime", value = "结束时间", defaultValue = "2016-12-14 00:00:00")
                          @RequestParam(value = "endTime", required = true) String endTime,
                          @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                          @RequestParam(value = "page", required = true) String page,
                          @ApiParam(name = "pageSize", value = "每页几行", defaultValue = "10")
                          @RequestParam(value = "pageSize", required = true) String pageSize) {
        try {
            List<Map<String, String>> result = followUpService.getListByDoctor(getUID(), startTime, endTime, page, pageSize);     //"64de9952-5b15-11e6-8344-fa163e8aee56"
            return write(200, "获取随访列表成功!", "data", result);
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取随访列表失败!" + e.getMessage());
        }
    }
    /**
     * 查询居民随访列表
     *
     * @param patient
     * @param teamCode
     * @param page
     * @param pagesize
     * @return
     */
    @RequestMapping(value = "/list_by_team")
    @ResponseBody
    @ApiOperation(value = "查询居民随访列表")
    public String getListByPatientAndTeam(@RequestParam @ApiParam(value = "居民Code") String patient,
                                          @RequestParam @ApiParam(value = "团队code") Long teamCode,
                                          @RequestParam @ApiParam(value = "第几页") int page,
                                          @RequestParam @ApiParam(value = "页大小") int pagesize) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "请输入需查询的居民");
            }
            if (teamCode == null || teamCode < 1) {
                return error(-1, "请输入需查询的居民的团队");
            }
            JSONArray result = followUpService.getListByPatientAndTeam(patient, teamCode, page, pagesize);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    @ApiOperation("获取随访列表(创建者)")
    @RequestMapping(value = "/createrList", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getCreaterList(@ApiParam(name = "startTime", value = "开始时间", defaultValue = "2016-12-07 00:00:00")
                                 @RequestParam(value = "startTime", required = true) String startTime,
                                 @ApiParam(name = "endTime", value = "结束时间", defaultValue = "2016-12-14 00:00:00")
                                 @RequestParam(value = "endTime", required = true) String endTime,
                                 @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                                 @RequestParam(value = "page", required = true) String page,
                                 @ApiParam(name = "pageSize", value = "每页几行", defaultValue = "10")
                                 @RequestParam(value = "pageSize", required = true) String pageSize) {
        try {
            List<Map<String, String>> result = followUpService.getListByCreater(getUID(), startTime, endTime, page, pageSize);     //"64de9952-5b15-11e6-8344-fa163e8aee56"
            return write(200, "获取随访列表成功!", "data", result);
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取随访列表失败!" + e.getMessage());
        }
    }
    @ApiOperation("新增随访计划(批量)")
    @RequestMapping(value = "/addFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String addFollowupPlan(@ApiParam(name = "patient", value = "患者代码", defaultValue = "443a196ef8744536a531260eb26c05d7")
                                  @RequestParam(value = "patient", required = true) String patient,
                                  @ApiParam(name = "data", value = "随访计划列表json", defaultValue = "[{\"date\":\"2016-12-16 20:00:00\",\"type\":\"10\",\"doctor\":\"64de9952-5b15-11e6-8344-fa163e8aee56\"},{\"date\":\"2016-12-17 15:00:00\",\"type\":\"3\",\"doctor\":\"64de9952-5b15-11e6-8344-fa163e8aee56\"}]")
                                  @RequestParam(value = "data", required = true) String data) {
        try {
            followUpService.addFollowupPlan(getUID(), patient, data);
            return write(200, "新增随访计划成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "新增随访计划失败!" + e.getMessage());
        }
    }
    @ApiOperation("编辑随访计划")
    @RequestMapping(value = "/editFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String editFollowupPlan(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                   @RequestParam(value = "id", required = true) String id,
                                   @ApiParam(name = "planDate", value = "随访计划时间", defaultValue = "2016-12-14 20:00:00")
                                   @RequestParam(value = "planDate", required = true) String planDate,
                                   @ApiParam(name = "followupType", value = "随访方式【字典FOLLOWUP_WAY_DICT】", defaultValue = "12")
                                   @RequestParam(value = "followupType", required = true) String followupType) {
        try {
            followUpService.editFollowupPlan(getUID(), id, planDate, followupType);
            return write(200, "编辑随访计划成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "编辑随访计划失败!" + e.getMessage());
        }
    }
    @ApiOperation("开始随访记录")
    @RequestMapping(value = "/startFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String startFollowup(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                @RequestParam(value = "id", required = true) String id,
                                @ApiParam(name = "date", value = "随访时间", defaultValue = "2016-12-14 20:00:00")
                                @RequestParam(value = "date", required = true) String date,
                                @ApiParam(name = "followupType", value = "随访方式【字典FOLLOWUP_WAY_DICT】", defaultValue = "12")
                                @RequestParam(value = "followupType", required = true) String followupType,
                                @ApiParam(name = "followupClass", value = "随访类别【1.高血压 2.糖尿病】", defaultValue = "1")
                                @RequestParam(value = "followupClass", required = true) String followupClass,
                                @ApiParam(name = "followupManagerStatus", value = "随访管理状态【字典FOLLOWUP_MANAGER_STATUS】", defaultValue = "1")
                                @RequestParam(value = "followupManagerStatus", required = false) String followupManagerStatus) {
        try {
            followUpService.startFollowup(id, date, followupType, followupClass, followupManagerStatus);
            return write(200, "开始随访记录成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "开始随访记录失败!" + e.getMessage());
        }
    }
    @ApiOperation("新增临时随访记录(返回ID)")
    @RequestMapping(value = "/addFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String addFollowup(@ApiParam(name = "patient", value = "患者代码", defaultValue = "443a196ef8744536a531260eb26c05d7")
                              @RequestParam(value = "patient", required = true) String patient,
                              @ApiParam(name = "date", value = "下次随访时间", defaultValue = "2016-12-15 20:00:00")
                              @RequestParam(value = "date", required = true) String date,
                              @ApiParam(name = "followupType", value = "随访方式【字典FOLLOWUP_WAY_DICT】", defaultValue = "12")
                              @RequestParam(value = "followupType", required = true) String followupType,
                              @ApiParam(name = "followupClass", value = "随访类别【1.高血压 2.糖尿病】", defaultValue = "1")
                              @RequestParam(value = "followupClass", required = true) String followupClass,
                              @ApiParam(name = "followupManagerStatus", value = "随访管理状态【字典FOLLOWUP_MANAGER_STATUS】", defaultValue = "1")
                              @RequestParam(value = "followupManagerStatus", required = false) String followupManagerStatus) {
        try {
            String response = followUpService.addFollowup(getUID(), patient, date, followupType, followupClass, followupManagerStatus);
            return write(200, "新增临时随访记录成功!", "data", response);
        } catch (Exception e) {
            return invalidUserException(e, -1, "新增临时随访记录失败!" + e.getMessage());
        }
    }
    @ApiOperation("取消随访计划")
    @RequestMapping(value = "/cancelFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String cancelFollowupPlan(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                     @RequestParam(value = "id", required = true) String id) {
        try {
            followUpService.cancelFollowupPlan(id);
            return write(200, "取消随访计划成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "取消随访计划失败!" + e.getMessage());
        }
    }
    @ApiOperation("完成随访记录")
    @RequestMapping(value = "/finishFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String finishFollowup(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                 @RequestParam(value = "id", required = true) String id) {
        try {
            followUpService.finishFollowup(id);
            return write(200, "完成随访记录成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "完成随访记录失败!" + e.getMessage());
        }
    }
    /*********************************** 随访详情 *******************************************************************/
    @ApiOperation("获取随访信息")
    @RequestMapping(value = "/getFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getFollowup(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "4")
                              @RequestParam(value = "id", required = true) String id) {
        try {
            Map<String, String> response = followUpService.getFollowup(id);
            return write(200, "获取随访信息成功!", "data", response);
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取随访信息失败!" + e.getMessage());
        }
    }
    @ApiOperation("获取随访项目列表")
    @RequestMapping(value = "/getFollowupProject", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getFollowupProject(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "4")
                                     @RequestParam(value = "id", required = true) String id) {
        try {
            List<Map<String, String>> list = followUpService.getFollowupProject(id);
            return write(200, "获取随访项目列表成功!", "data", list);
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取随访项目列表失败!" + e.getMessage());
        }
    }
    @ApiOperation("获取随访项目数据")
    @RequestMapping(value = "/getFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getFollowupProjectData(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "4")
                                         @RequestParam(value = "id", required = true) String id,
                                         @ApiParam(name = "followupProject", value = "随访项目", defaultValue = "2")
                                         @RequestParam(value = "followupProject", required = true) String followupProject) {
        try {
            Map<String, String> response = followUpService.getFollowupProjectData(id, followupProject);
            return write(200, "获取随访项目数据成功!", "data", response);
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取随访项目数据失败!" + e.getMessage());
        }
    }
    @ApiOperation("保存随访项目数据")
    @RequestMapping(value = "/saveFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String saveFollowupProjectData(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "4")
                                          @RequestParam(value = "id", required = true) String id,
                                          @ApiParam(name = "followupProject", value = "随访项目", defaultValue = "2")
                                          @RequestParam(value = "followupProject", required = true) String followupProject,
                                          @ApiParam(name = "followupProjectData", value = "随访项目数据", defaultValue = "{\"WEIGHT\":\"76\",\"WEIGHT_EXP\":\"60\",\"BMI\":\"11\"}")
                                          @RequestParam(value = "followupProjectData", required = true) String followupProjectData) {
        try {
            followUpService.saveFollowupProjectData(id, followupProject, followupProjectData);
            return write(200, "保存随访项目数据成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "保存随访项目数据失败!" + e.getMessage());
        }
    }
    /*********************************** 电话随访 *****************************************************************/
    @ApiOperation("获取电话随访内容")
    @RequestMapping(value = "/getFollowupPhone", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getFollowupPhone(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                   @RequestParam(value = "id", required = true) String id) {
        try {
            String response = followUpService.getFollowupPhone(id);
            return write(200, "获取电话随访内容成功!", "data", response);
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取电话随访内容失败!" + e.getMessage());
        }
    }
    @ApiOperation("记录电话随访内容")
    @RequestMapping(value = "/saveFollowupPhone", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String saveFollowupPhone(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                    @RequestParam(value = "id", required = true) String id,
                                    @ApiParam(name = "content", value = "电话随访内容", defaultValue = "")
                                    @RequestParam(value = "content", required = true) String content) {
        try {
            followUpService.saveFollowupPhone(id, content);
            return write(200, "记录电话随访内容成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "记录电话随访内容失败!" + e.getMessage());
        }
    }
    /*************************************** 上次随访 ********************************************/
    @ApiOperation("获取上次随访")
    @RequestMapping(value = "/getLastFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getLastFollowup(@ApiParam(name = "patient", value = "患者代码", defaultValue = "P20161008001")
                                  @RequestParam(value = "patient", required = true) String patient,
                                  @ApiParam(name = "followClass", value = "随访类别", defaultValue = "1")
                                  @RequestParam(value = "followClass", required = true) String followClass) {
        try {
            Map<String, String> response = followUpService.getLastFollowup(getUID(), patient, followClass);
            return write(200, "获取上次随访成功!", "data", response);
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取上次随访失败!" + e.getMessage());
        }
    }
    @ApiOperation("复制上次随访数据")
    @RequestMapping(value = "/copyFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String copyFollowup(@ApiParam(name = "id", value = "本地随访ID", defaultValue = "")
                               @RequestParam(value = "id", required = true) Long id,
                               @ApiParam(name = "fromId", value = "拷贝随访记录ID", defaultValue = "")
                               @RequestParam(value = "fromId", required = true) Long fromId) {
        try {
            followUpService.copyFollowup(id, fromId);
            return write(200, "复制上次随访成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "复制上次随访失败!" + e.getMessage());
        }
    }
    /*************************************** 发送随访计划消息 ********************************************/
    @ApiOperation("发送随访计划消息")
    @RequestMapping(value = "/sendMessage", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String sendMessage(@ApiParam(name = "date", value = "日期", defaultValue = "2017-01-05")
                              @RequestParam(value = "date", required = true) String date) {
        try {
            followUpService.sendMessage(date);
            return write(200, "发送随访计划消息成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "发送随访计划消息失败!" + e.getMessage());
        }
    }
}

+ 443 - 364
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java

@ -4,6 +4,8 @@ import java.util.*;
import com.yihu.wlyy.entity.education.*;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.health.*;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.common.account.PatientService;
@ -11,6 +13,8 @@ import com.yihu.wlyy.util.SendP2PUtil;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.web.doctor.message.DoctorMessageController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.htmlparser.Parser;
import org.htmlparser.beans.StringBean;
@ -36,375 +40,450 @@ import com.yihu.wlyy.web.BaseController;
/**
 * 医生端:健康教育控制类
 * @author George
 *
 * @author George
 */
@Controller
@RequestMapping(value = "/doctor/health/edu", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "健康教育")
public class DoctorHealthEduArticleController extends WeixinBaseController {
	@Autowired
	private HealthEduArticleService healthEduArticleService;
	@Autowired
	private DoctorService doctorService;
	@Autowired
	private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
	@Autowired
	private SignPatientLabelInfoService signPatientLabelInfoService;
	@Autowired
	private HealthEduArticlePatientService healthEduArticlePatientService;
	@Autowired
	private HealthEduArticleDoctorService healthEduArticleDoctorService;
	@Autowired
	private HealthEduArticleLabelService healthEduArticleLabelService;
	@Autowired
	private PatientService patientService;
	/**
	 * 查询
	 * @param pagesize 分页大小
	 * @return 列表
	 */
	@RequestMapping(value = "list")
	@ResponseBody
	public String list(@RequestParam(value = "page",required = true)int page, @RequestParam(value = "pagesize",required = true)int pagesize,@RequestParam(value = "filter",required = false)String filter,@RequestParam(value = "patient",required = false)String patient) {
		try {
			List<Map<String, Object>> list = healthEduArticleService.findAll(page, pagesize,filter,getUID(),patient);
			JSONArray jsonArray = new JSONArray();
			if (list != null) {
				for (Map<String, Object> map : list) {
					JSONObject json = new JSONObject();
					json.put("id", map.get("id"));
					// 文章标识
					json.put("code", map.get("code"));
					// 文章标题
					json.put("title", map.get("title"));
					// 文章查看URL
					json.put("url", map.get("url"));
					// 文章简介
					json.put("content", parsrHtml(map.get("content").toString()));
					// 添加日期
					json.put("czrq", DateUtil.dateToStrLong((Date)map.get("czrq")));
					json.put("keyword", map.get("keyword")==null?"":map.get("keyword"));
					json.put("send", map.get("send"));
					//阅读量
					json.put("readAmount", map.get("readAmount"));
					//收藏量
					json.put("collectionAmount", map.get("collectionAmount"));
					//转发量
					json.put("repeatAmount", map.get("repeatAmount"));
					json.put("collection",map.get("collection"));
					jsonArray.put(json);
				}
			}
			return write(200, "查询成功", "list", jsonArray);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
		}
	}
	/**
	 * 查询医生收藏列表
	 * @param pagesize 分页大小
	 * @return 列表
	 */
	@RequestMapping(value = "listDoctor")
	@ResponseBody
	public String listDoctor(@RequestParam(value = "page",required = true)int page, @RequestParam(value = "pagesize",required = true)int pagesize,@RequestParam(value = "filter",required = false)String filter,@RequestParam(value = "patient",required = false)String patient) {
		try {
			List<Map<String, Object>> list = healthEduArticleDoctorService.list(page, pagesize,filter,getUID(),patient);
			JSONArray jsonArray = new JSONArray();
			for(Map<String, Object> map:list){
				JSONObject json = new JSONObject();
				json.put("id", map.get("id"));
				// 文章标识
				json.put("code", map.get("article"));
				// 文章标题
				json.put("title", map.get("title"));
				// 文章查看URL
				json.put("url", map.get("url"));
				// 文章简介
				json.put("content", parsrHtml(map.get("content").toString()));
				// 添加日期
				json.put("czrq", DateUtil.dateToStrLong((Date)map.get("czrq")));
				json.put("keyword", map.get("keyword"));
				json.put("send", map.get("send"));
				//阅读量
				json.put("readAmount", map.get("readAmount"));
				//收藏量
				json.put("collectionAmount", map.get("collectionAmount"));
				//转发量
				json.put("repeatAmount", map.get("repeatAmount"));
				//是否收藏(医生收藏的列表肯定是收藏的无需额外校验)
				json.put("collection",1);
				jsonArray.put(json);
			}
			return write(200, "查询成功", "list", jsonArray);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
		}
	}
	/**
	 * 查询标签列表
	 * @param pagesize 分页大小
	 * @return 列表
	 */
	@RequestMapping(value = "listLabel")
	@ResponseBody
	public String listLabel(@RequestParam(value = "page",required = true)int page, @RequestParam(value = "pagesize",required = true)int pagesize,@RequestParam(value = "type",required = false,defaultValue = "0")int type) {
		try {
			Page<HealthEduArticleLabel> list = healthEduArticleLabelService.findAll(page,pagesize,type,getUID());
			return write(200, "查询成功", "list", list);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
		}
	}
	/**
	 * 查询文章列表
	 * @param code 数据文章唯一标示code
	 * @return 列表
	 */
	@RequestMapping(value = "article")
	@ResponseBody
	public String article(@RequestParam(value = "code",required = true) String code) {
		try {
			//获取单条文章记录
			HealthEduArticle healthEduArticle = healthEduArticleService.findArticleByCode(code);
			int isRead  = healthEduArticleOpHistoryService.countByUserStatus(getUID(), HealthEduArticleOpHistory.READ_STATUS);
			//插入文章读取状态第一次阅读记录浏览数量
			if(isRead==0){
				//更新浏览量
				healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.READ_STATUS,healthEduArticle.getCode(),healthEduArticle.getTitle(),getUID());
			}
			JSONObject json = new JSONObject();
			json.put("id", healthEduArticle.getId());
			// 文章标识
			json.put("code", healthEduArticle.getCode());
			// 文章标题
			json.put("title", healthEduArticle.getTitle());
			json.put("url", healthEduArticle.getUrl()==null?"":healthEduArticle.getUrl());
			// 文章内容
			json.put("content", healthEduArticle.getContent());
			// 添加日期
			json.put("czrq", DateUtil.dateToStrLong(healthEduArticle.getCzrq()));
			int readAmount = healthEduArticleOpHistoryService.countReadAmount(code);
			json.put("readAmount",readAmount);
			HealthEduArticleDoctor healthEduArticleDoctor = healthEduArticleDoctorService.findByArticle(healthEduArticle.getCode(), getUID());
			if(healthEduArticleDoctor==null){
				json.put("collection",0);
			}else{
				json.put("collection",1);
			}
			return write(200, "查询成功", "data", json);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
		}
	}
	/**
	 * 发送文章给患者
	 * @param code 文章标识,多个以逗号分隔
	 * @param patient 患者标识,多个以逗号分隔
	 * @param  group 所选群组,多个用逗号分隔
	 * @return
	 */
	@RequestMapping(value = "send")
	@ResponseBody
	public String send(@RequestParam(value = "code")String code,
					   @RequestParam(value = "patient",required = false)String patient,
					   @RequestParam(value = "group",required = false,defaultValue = "")String group,
					   @RequestParam(value = "labelType",required = false)String labelType,
					   @RequestParam(value = "teamCode",required = false)long teamCode) {
		try {
			List<HealthEduArticlePatient> list = new ArrayList<HealthEduArticlePatient>();
			if (StringUtils.isEmpty(code)) {
				return error(-1, "请至少选择一篇文章!");
			}
			if (StringUtils.isEmpty(patient)&&StringUtils.isEmpty(group)) {
				return error(-1, "请至少选择一个患者!");
			}
			String[] articles = code.split(",");
			String[] patients = patient.split(",");
			String[] groups = group.split(",");
			if (articles.length == 0) {
				return error(-1, "请至少选择一篇文章!");
			}
			if (patients.length == 0&&groups.length==0) {
				return error(-1, "请至少选择一个患者!");
			}
			Map<String, HealthEduArticle> maps = new HashMap<String, HealthEduArticle>();
			Set<String> patientSet = new HashSet<>();
			if(StringUtils.isNotBlank(group)&&groups.length>0){
				//递归患者数据
				for(String g :groups){
					getPatientByGroup(g,labelType,teamCode,patientSet,0,100);
				}
			}
			//去重操作
			for (String p : patients) {
				if(StringUtils.isNotBlank(p)){
					patientSet.add(p);
				}
			}
			if(patientSet.size()==0){
				return error(-1, "请至少选择一个患者!");
			}
			// 查询医生信息
			Doctor doctor = doctorService.findDoctorByCode(getUID());
			String msgHead =  doctor.getName()+"医生给您发来了一篇患教文章";
			String endMsg = "为了您的健康,"+doctor.getName()+"医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。";
			JSONArray messages = new JSONArray();
			for (String p : patientSet) {
				Patient patientTemp = patientService.findByCode(p);
				for (String a : articles) {
					// 查询文章信息
					HealthEduArticle temp = maps.get(a);
					if (temp == null) {
						temp = healthEduArticleService.findArticleByCode(a);
						// 添加到缓存
						maps.put(a, temp);
					}
					HealthEduArticlePatient heap = new HealthEduArticlePatient();
					// 设置文章标识
					heap.setArticle(a);
					// 设置文章简介
					heap.setContent(temp.getContent());
					// 设置文章标题
					heap.setTitle(temp.getTitle());
					// 设置文章查看URL
					heap.setUrl(temp.getUrl());
					// 设置发送时间
					heap.setCzrq(new Date());
					// 设置医生标识
					heap.setDoctor(doctor.getCode());
					// 设置医生姓名
					heap.setDoctorName(doctor.getName());
					// 设置患者标识
					heap.setPatient(p);
					// 设置为示读
					heap.setRead(1);
					list.add(heap);
					SendP2PUtil.sendP2Pmsg(doctor.getCode(), p, "4", "{\"title\":\"" + temp.getTitle() + "\",\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}");
					if (StringUtils.isNotEmpty(patientTemp.getOpenid())) {
						// 推送消息给微信端
						JSONObject json = new JSONObject();
						json.put("first", patientTemp.getName() + ",您好!\n" + msgHead);
						json.put("toUser",p);
						json.put("article",temp.getCode()+"");
						json.put("title",temp.getTitle());
						json.put("doctorName",doctor.getName());
						json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
						json.put("remark", endMsg);
						PushMsgTask.getInstance().putWxMsg(getAccessToken(), 9, patientTemp.getOpenid(), patientTemp.getName(), json);
					}
				}
			}
			// 保存到数据库
			int row = healthEduArticleService.send(list);
			if (row <= 0) {
				return error(-1, "发送失败!");
			} else {
				// 推送消息给患者
				PushMsgTask.getInstance().put(messages);
				return success("发送成功!");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "发送失败!");
		}
	}
	private void getPatientByGroup(String labelCode, String labelType, Long teamCode,Set<String> patientSet,int page,int pagesize) throws Exception{
		JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize);
		for(Object o : result){
			JSONObject json  = (JSONObject)o;
			String patient  = (String)json.get("code");
			patientSet.add(patient);
		}
		if(result.length()==100){
			getPatientByGroup(labelCode,labelType,teamCode,patientSet,page+1,pagesize);
		}
	}
	/**
	 * 文章收藏
	 * @param article 文章CODE
	 * @return
	 */
	@RequestMapping(value = "collectionArticle")
	@ResponseBody
	public String collectionArticle(@RequestParam(value = "article",required = true)String article){
		HealthEduArticleDoctor healthEduArticleDoctor = healthEduArticleDoctorService.findByArticle(article,getUID());
		if(healthEduArticleDoctor!=null){
			return error(-1, "收藏失败,该文章已经收藏!");
		}
		HealthEduArticle healthEduArticle =	healthEduArticleService.findArticleByCode(article);
		healthEduArticleDoctor = new HealthEduArticleDoctor();
		try{
			BeanUtils.copyProperties(healthEduArticle,healthEduArticleDoctor);
			healthEduArticleDoctor.setDoctor(getUID());
			healthEduArticleDoctor.setArticle(healthEduArticle.getCode());
			healthEduArticleDoctorService.save(healthEduArticleDoctor);
			//更新收藏量
			healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.COLLECTION_STATUS,healthEduArticle.getCode(),healthEduArticle.getTitle(),getUID());
			return success("收藏成功!");
		}catch (Exception e){
			error(e);
			return error(-1, "收藏失败!");
		}
	}
	/**
	 * 文章收藏
	 * @param article 文章CODE
	 * @return
	 */
	@RequestMapping(value = "uncollectionArticle")
	@ResponseBody
	public String uncollectionArticle(@RequestParam(value = "article",required = true)String article){
		try{
			healthEduArticleDoctorService.delete(article,getUID());
			return success("取消收藏成功!");
		}catch (Exception e){
			error(e);
			return error(-1, "取消收藏失败!");
		}
	}
	private String parsrHtml(String html) {
		html =("<span>"+html+"</span>");//拼接一个HTML标签,防止纯文字字符串转换在linux下面出现的异常。
		Parser parser = null;
		try{
			parser = new Parser(html);
			TextExtractingVisitor visitor = new TextExtractingVisitor();
			parser.visitAllNodesWith(visitor);
			return StringUtils.isNotBlank(visitor.getExtractedText())?visitor.getExtractedText():"内容为图集,请点击查看";
		}catch (ParserException e){
			return html;//纯文本内容会转换失败,直接返回文本内容
		}
	}
	public static void main(String arg[]){
		System.out.println(MessageType.MESSAGE_TYPE_PATIENT_HEALTH_EDU.P_HE_01.name());
	}
    @Autowired
    private HealthEduArticleService healthEduArticleService;
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
    @Autowired
    private SignPatientLabelInfoService signPatientLabelInfoService;
    @Autowired
    private HealthEduArticlePatientService healthEduArticlePatientService;
    @Autowired
    private HealthEduArticleDoctorService healthEduArticleDoctorService;
    @Autowired
    private HealthEduArticleLabelService healthEduArticleLabelService;
    @Autowired
    private PatientService patientService;
    @Autowired
    SignFamilyDao signFamilyDao;
    /**
     * 查询
     *
     * @param pagesize 分页大小
     * @return 列表
     */
    @RequestMapping(value = "list")
    @ResponseBody
    public String list(@RequestParam(value = "page", required = true) int page, @RequestParam(value = "pagesize", required = true) int pagesize, @RequestParam(value = "filter", required = false) String filter, @RequestParam(value = "patient", required = false) String patient) {
        try {
            List<Map<String, Object>> list = healthEduArticleService.findAll(page, pagesize, filter, getUID(), patient);
            JSONArray jsonArray = new JSONArray();
            if (list != null) {
                for (Map<String, Object> map : list) {
                    JSONObject json = new JSONObject();
                    json.put("id", map.get("id"));
                    // 文章标识
                    json.put("code", map.get("code"));
                    // 文章标题
                    json.put("title", map.get("title"));
                    // 文章查看URL
                    json.put("url", map.get("url"));
                    // 文章简介
                    json.put("content", parsrHtml(map.get("content").toString()));
                    // 添加日期
                    json.put("czrq", DateUtil.dateToStrLong((Date) map.get("czrq")));
                    json.put("keyword", map.get("keyword") == null ? "" : map.get("keyword"));
                    json.put("send", map.get("send"));
                    //阅读量
                    json.put("readAmount", map.get("readAmount"));
                    //收藏量
                    json.put("collectionAmount", map.get("collectionAmount"));
                    //转发量
                    json.put("repeatAmount", map.get("repeatAmount"));
                    json.put("collection", map.get("collection"));
                    jsonArray.put(json);
                }
            }
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    /**
     * 查询发送给居民的文章列表
     *
     * @param pagesize 分页大小
     * @return 列表
     */
    @RequestMapping(value = "list_by_team", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value = "查询发送给居民的文章列表")
    public String listByTeam(@RequestParam @ApiParam(value = "第几页") int page,
                             @RequestParam @ApiParam(value = "页大小") int pagesize,
                             @RequestParam @ApiParam(value = "居民code") String patient,
                             @RequestParam @ApiParam(value = "团队code") Long teamCode) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "请输入需查询的居民");
            }
            if (teamCode == null || teamCode < 1) {
                return error(-1, "请输入需查询的居民的团队");
            }
            List<Map<String, Object>> list = healthEduArticleService.findByPatientAndTeam(patient, teamCode, page, pagesize);
            JSONArray jsonArray = new JSONArray();
            if (list != null) {
                for (Map<String, Object> map : list) {
                    JSONObject json = new JSONObject();
                    // 文章标识
                    json.put("doctorCode", map.get("code"));
                    // 文章标识
                    json.put("doctorName", map.get("name"));
                    // 文章标识
                    json.put("doctorPhoto", map.get("photo"));
                    // 文章标识
                    json.put("code", map.get("article"));
                    // 文章标题
                    json.put("title", map.get("title"));
                    // 文章查看URL
                    json.put("url", map.get("url"));
                    // 文章简介
                    json.put("content", parsrHtml(map.get("content").toString()));
                    // 发送日期
                    json.put("czrq", DateUtil.dateToStrLong((Date) map.get("czrq")));
                    // 发送团队
                    json.put("adminTeamCode", map.get("admin_team_code"));
                    jsonArray.put(json);
                }
            }
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    /**
     * 查询医生收藏列表
     *
     * @param pagesize 分页大小
     * @return 列表
     */
    @RequestMapping(value = "listDoctor")
    @ResponseBody
    public String listDoctor(@RequestParam(value = "page", required = true) int page, @RequestParam(value = "pagesize", required = true) int pagesize, @RequestParam(value = "filter", required = false) String filter, @RequestParam(value = "patient", required = false) String patient) {
        try {
            List<Map<String, Object>> list = healthEduArticleDoctorService.list(page, pagesize, filter, getUID(), patient);
            JSONArray jsonArray = new JSONArray();
            for (Map<String, Object> map : list) {
                JSONObject json = new JSONObject();
                json.put("id", map.get("id"));
                // 文章标识
                json.put("code", map.get("article"));
                // 文章标题
                json.put("title", map.get("title"));
                // 文章查看URL
                json.put("url", map.get("url"));
                // 文章简介
                json.put("content", parsrHtml(map.get("content").toString()));
                // 添加日期
                json.put("czrq", DateUtil.dateToStrLong((Date) map.get("czrq")));
                json.put("keyword", map.get("keyword"));
                json.put("send", map.get("send"));
                //阅读量
                json.put("readAmount", map.get("readAmount"));
                //收藏量
                json.put("collectionAmount", map.get("collectionAmount"));
                //转发量
                json.put("repeatAmount", map.get("repeatAmount"));
                //是否收藏(医生收藏的列表肯定是收藏的无需额外校验)
                json.put("collection", 1);
                jsonArray.put(json);
            }
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    /**
     * 查询标签列表
     *
     * @param pagesize 分页大小
     * @return 列表
     */
    @RequestMapping(value = "listLabel")
    @ResponseBody
    public String listLabel(@RequestParam(value = "page", required = true) int page, @RequestParam(value = "pagesize", required = true) int pagesize, @RequestParam(value = "type", required = false, defaultValue = "0") int type) {
        try {
            Page<HealthEduArticleLabel> list = healthEduArticleLabelService.findAll(page, pagesize, type, getUID());
            return write(200, "查询成功", "list", list);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    /**
     * 查询文章列表
     *
     * @param code 数据文章唯一标示code
     * @return 列表
     */
    @RequestMapping(value = "article")
    @ResponseBody
    public String article(@RequestParam(value = "code", required = true) String code) {
        try {
            //获取单条文章记录
            HealthEduArticle healthEduArticle = healthEduArticleService.findArticleByCode(code);
            int isRead = healthEduArticleOpHistoryService.countByUserStatus(getUID(), HealthEduArticleOpHistory.READ_STATUS);
            //插入文章读取状态第一次阅读记录浏览数量
            if (isRead == 0) {
                //更新浏览量
                healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.READ_STATUS, healthEduArticle.getCode(), healthEduArticle.getTitle(), getUID());
            }
            JSONObject json = new JSONObject();
            json.put("id", healthEduArticle.getId());
            // 文章标识
            json.put("code", healthEduArticle.getCode());
            // 文章标题
            json.put("title", healthEduArticle.getTitle());
            json.put("url", healthEduArticle.getUrl() == null ? "" : healthEduArticle.getUrl());
            // 文章内容
            json.put("content", healthEduArticle.getContent());
            // 添加日期
            json.put("czrq", DateUtil.dateToStrLong(healthEduArticle.getCzrq()));
            int readAmount = healthEduArticleOpHistoryService.countReadAmount(code);
            json.put("readAmount", readAmount);
            HealthEduArticleDoctor healthEduArticleDoctor = healthEduArticleDoctorService.findByArticle(healthEduArticle.getCode(), getUID());
            if (healthEduArticleDoctor == null) {
                json.put("collection", 0);
            } else {
                json.put("collection", 1);
            }
            return write(200, "查询成功", "data", json);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    /**
     * 发送文章给患者
     *
     * @param code    文章标识,多个以逗号分隔
     * @param patient 患者标识,多个以逗号分隔
     * @param group   所选群组,多个用逗号分隔
     * @return
     */
    @RequestMapping(value = "send")
    @ResponseBody
    public String send(@RequestParam(value = "code") String code,
                       @RequestParam(value = "patient", required = false) String patient,
                       @RequestParam(value = "group", required = false, defaultValue = "") String group,
                       @RequestParam(value = "labelType", required = false) String labelType,
                       @RequestParam(value = "teamCode", required = false) long teamCode) {
        try {
            List<HealthEduArticlePatient> list = new ArrayList<HealthEduArticlePatient>();
            if (StringUtils.isEmpty(code)) {
                return error(-1, "请至少选择一篇文章!");
            }
            if (StringUtils.isEmpty(patient) && StringUtils.isEmpty(group)) {
                return error(-1, "请至少选择一个患者!");
            }
            String[] articles = code.split(",");
            String[] patients = patient.split(",");
            String[] groups = group.split(",");
            if (articles.length == 0) {
                return error(-1, "请至少选择一篇文章!");
            }
            if (patients.length == 0 && groups.length == 0) {
                return error(-1, "请至少选择一个患者!");
            }
            Map<String, HealthEduArticle> maps = new HashMap<String, HealthEduArticle>();
            Set<String> patientSet = new HashSet<>();
            if (StringUtils.isNotBlank(group) && groups.length > 0) {
                //递归患者数据
                for (String g : groups) {
                    getPatientByGroup(g, labelType, teamCode, patientSet, 0, 100);
                }
            }
            //去重操作
            for (String p : patients) {
                if (StringUtils.isNotBlank(p)) {
                    patientSet.add(p);
                }
            }
            if (patientSet.size() == 0) {
                return error(-1, "请至少选择一个患者!");
            }
            // 查询医生信息
            Doctor doctor = doctorService.findDoctorByCode(getUID());
            String msgHead = doctor.getName() + "医生给您发来了一篇患教文章";
            String endMsg = "为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。";
            JSONArray messages = new JSONArray();
            for (String p : patientSet) {
                Patient patientTemp = patientService.findByCode(p);
                SignFamily signFamily = signFamilyDao.findByjiatingPatient(p);
                if(signFamily == null){
                    throw new Exception("can not find patient's family sign info");
                }
                for (String a : articles) {
                    // 查询文章信息
                    HealthEduArticle temp = maps.get(a);
                    if (temp == null) {
                        temp = healthEduArticleService.findArticleByCode(a);
                        // 添加到缓存
                        maps.put(a, temp);
                    }
                    HealthEduArticlePatient heap = new HealthEduArticlePatient();
                    // 设置文章标识
                    heap.setArticle(a);
                    // 设置文章简介
                    heap.setContent(temp.getContent());
                    // 设置文章标题
                    heap.setTitle(temp.getTitle());
                    // 设置文章查看URL
                    heap.setUrl(temp.getUrl());
                    // 设置发送时间
                    heap.setCzrq(new Date());
                    // 设置医生标识
                    heap.setDoctor(doctor.getCode());
                    // 设置医生姓名
                    heap.setDoctorName(doctor.getName());
                    // 设置患者标识
                    heap.setPatient(p);
                    // 设置为示读
                    heap.setRead(1);
                    // 签约类型
                    heap.setSignType(2);
                    // 行政团队
                    heap.setAdminTeamCode(signFamily.getAdminTeamId());
                    list.add(heap);
                    SendP2PUtil.sendP2Pmsg(doctor.getCode(), p, "4", "{\"title\":\"" + temp.getTitle() + "\",\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}");
                    if (StringUtils.isNotEmpty(patientTemp.getOpenid())) {
                        // 推送消息给微信端
                        JSONObject json = new JSONObject();
                        json.put("first", patientTemp.getName() + ",您好!\n" + msgHead);
                        json.put("toUser", p);
                        json.put("article", temp.getCode() + "");
                        json.put("title", temp.getTitle());
                        json.put("doctorName", doctor.getName());
                        json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
                        json.put("remark", endMsg);
                        PushMsgTask.getInstance().putWxMsg(getAccessToken(), 9, patientTemp.getOpenid(), patientTemp.getName(), json);
                    }
                }
            }
            // 保存到数据库
            int row = healthEduArticleService.send(list);
            if (row <= 0) {
                return error(-1, "发送失败!");
            } else {
                // 推送消息给患者
                PushMsgTask.getInstance().put(messages);
                return success("发送成功!");
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "发送失败!");
        }
    }
    private void getPatientByGroup(String labelCode, String labelType, Long teamCode, Set<String> patientSet, int page, int pagesize) throws Exception {
        JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize);
        for (Object o : result) {
            JSONObject json = (JSONObject) o;
            String patient = (String) json.get("code");
            patientSet.add(patient);
        }
        if (result.length() == 100) {
            getPatientByGroup(labelCode, labelType, teamCode, patientSet, page + 1, pagesize);
        }
    }
    /**
     * 文章收藏
     *
     * @param article 文章CODE
     * @return
     */
    @RequestMapping(value = "collectionArticle")
    @ResponseBody
    public String collectionArticle(@RequestParam(value = "article", required = true) String article) {
        HealthEduArticleDoctor healthEduArticleDoctor = healthEduArticleDoctorService.findByArticle(article, getUID());
        if (healthEduArticleDoctor != null) {
            return error(-1, "收藏失败,该文章已经收藏!");
        }
        HealthEduArticle healthEduArticle = healthEduArticleService.findArticleByCode(article);
        healthEduArticleDoctor = new HealthEduArticleDoctor();
        try {
            BeanUtils.copyProperties(healthEduArticle, healthEduArticleDoctor);
            healthEduArticleDoctor.setDoctor(getUID());
            healthEduArticleDoctor.setArticle(healthEduArticle.getCode());
            healthEduArticleDoctorService.save(healthEduArticleDoctor);
            //更新收藏量
            healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.COLLECTION_STATUS, healthEduArticle.getCode(), healthEduArticle.getTitle(), getUID());
            return success("收藏成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "收藏失败!");
        }
    }
    /**
     * 文章收藏
     *
     * @param article 文章CODE
     * @return
     */
    @RequestMapping(value = "uncollectionArticle")
    @ResponseBody
    public String uncollectionArticle(@RequestParam(value = "article", required = true) String article) {
        try {
            healthEduArticleDoctorService.delete(article, getUID());
            return success("取消收藏成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "取消收藏失败!");
        }
    }
    private String parsrHtml(String html) {
        html = ("<span>" + html + "</span>");//拼接一个HTML标签,防止纯文字字符串转换在linux下面出现的异常。
        Parser parser = null;
        try {
            parser = new Parser(html);
            TextExtractingVisitor visitor = new TextExtractingVisitor();
            parser.visitAllNodesWith(visitor);
            return StringUtils.isNotBlank(visitor.getExtractedText()) ? visitor.getExtractedText() : "内容为图集,请点击查看";
        } catch (ParserException e) {
            return html;//纯文本内容会转换失败,直接返回文本内容
        }
    }
    public static void main(String arg[]) {
        System.out.println(MessageType.MESSAGE_TYPE_PATIENT_HEALTH_EDU.P_HE_01.name());
    }
}

+ 34 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthGuidanceController.java

@ -2,6 +2,8 @@ package com.yihu.wlyy.web.doctor.health;
import com.yihu.wlyy.util.SendP2PUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -48,7 +50,6 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
			JSONObject guidance = patientHealthGuidanceService.findById(id);
			return write(200,"查询成功","data",guidance);
		}catch (Exception e){
			e.printStackTrace();
			return error(-1,"查询失败");
		}
	}
@ -116,4 +117,36 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
		}
	}
	/**
	 * 查询患者的健康指导
	 *
	 * @param patient
	 * @param teamCode
	 * @param page
	 * @param pagesize
	 * @return
	 */
	@RequestMapping(value = "list_by_team", method = {RequestMethod.GET, RequestMethod.POST})
	@ResponseBody
	@ApiOperation(value = "查询居民健康指导记录")
	public String list(@RequestParam @ApiParam(value = "居民code") String patient,
					   @RequestParam @ApiParam(value = "团队Code") Long teamCode,
					   @RequestParam @ApiParam(value = "第几页") int page,
					   @RequestParam @ApiParam(value = "页大小") int pagesize) {
		try {
			if (StringUtils.isEmpty(patient)) {
				return error(-1, "请输入需查询的居民");
			}
			if (teamCode == null || teamCode < 1) {
				return error(-1, "请输入需查询的居民的团队");
			}
			JSONArray result = patientHealthGuidanceService.findByPatientAndGuidanceAndTeam(patient,teamCode,page,pagesize);
			return write(200, "查询成功!", "list", result);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
		}
	}
}

+ 291 - 273
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java

@ -28,297 +28,315 @@ import java.util.Map;
@Api(description = "医生端-消息")
public class DoctorMessageController extends BaseController {
	@Autowired
	private MessageService messageService;
    @Autowired
    private MessageService messageService;
	@RequestMapping(value = "messages")
	@ResponseBody
	@ApiOperation("查询医生未读消息和最后消息")
	public String messages() {
		try {
			JSONObject json = messageService.findDoctorAllMessage(getUID());
			return write(200, "获取消息总数成功!", "data", json);
		} catch (Exception e) {
			error(e);
			return error(-1, e.getMessage());
		}
	}
    @RequestMapping(value = "messages")
    @ResponseBody
    @ApiOperation("查询医生未读消息和最后消息")
    public String messages() {
        try {
            JSONObject json = messageService.findDoctorAllMessage(getUID());
            return write(200, "获取消息总数成功!", "data", json);
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
	/**
	 * 医生消息总数统计接口
	 * @return
	 */
	@RequestMapping(value = "amount")
	@ResponseBody
	public String amount() {
		try {
			JSONObject json = messageService.findDoctorAllMessageAmount(getUID());
			if (json == null) {
				return error(-1, "获取消息总数失败!");
			} else {
				return write(200, "获取消息总数成功!", "data", json);
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息总数失败!");
		}
	}
    /**
     * 医生消息总数统计接口
     *
     * @return
     */
    @RequestMapping(value = "amount")
    @ResponseBody
    public String amount() {
        try {
            JSONObject json = messageService.findDoctorAllMessageAmount(getUID());
            if (json == null) {
                return error(-1, "获取消息总数失败!");
            } else {
                return write(200, "获取消息总数成功!", "data", json);
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "获取消息总数失败!");
        }
    }
	/**
	 * 健康咨询消息列表查询接口
	 * @param id
	 * @param pagesize 分页大小
	 * @return
	 */
	@RequestMapping(value = "consults")
	@ResponseBody
	public String consultList(long id, int pagesize) {
		try {
			JSONArray array = new JSONArray();
			Page<ConsultTeam> list = messageService.findConsultListByDoctor(getUID(), id, pagesize);
			for (ConsultTeam consult : list) {
				if (consult == null) {
					continue;
				}
				JSONObject json = new JSONObject();
				json.put("id", consult.getId());
				// 设置咨询标识
				json.put("consult", consult.getConsult());
				// 设置患者标识
				json.put("patient", consult.getPatient());
				// 设置患者头像
				json.put("photo", consult.getPhoto());
				// 设置主要症状
				json.put("symptoms", consult.getSymptoms());
				// 设置患者姓名
				json.put("name", consult.getName());
				// 设置状态(0进行中,1已完成,-1患者取消)
				json.put("status", consult.getStatus());
				// 设置消息未读数量
				json.put("unread", consult.getDoctorRead());
				// 设置咨询时间
				json.put("time", DateUtil.dateToStr(consult.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
				array.put(json);
			}
			return write(200, "获取健康咨询列表成功!", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取健康咨询列表失败!");
		}
	}
    /**
     * 健康咨询消息列表查询接口
     *
     * @param id
     * @param pagesize 分页大小
     * @return
     */
    @RequestMapping(value = "consults")
    @ResponseBody
    public String consultList(long id, int pagesize) {
        try {
            JSONArray array = new JSONArray();
            Page<ConsultTeam> list = messageService.findConsultListByDoctor(getUID(), id, pagesize);
            for (ConsultTeam consult : list) {
                if (consult == null) {
                    continue;
                }
                JSONObject json = new JSONObject();
                json.put("id", consult.getId());
                // 设置咨询标识
                json.put("consult", consult.getConsult());
                // 设置患者标识
                json.put("patient", consult.getPatient());
                // 设置患者头像
                json.put("photo", consult.getPhoto());
                // 设置主要症状
                json.put("symptoms", consult.getSymptoms());
                // 设置患者姓名
                json.put("name", consult.getName());
                // 设置状态(0进行中,1已完成,-1患者取消)
                json.put("status", consult.getStatus());
                // 设置消息未读数量
                json.put("unread", consult.getDoctorRead());
                // 设置咨询时间
                json.put("time", DateUtil.dateToStr(consult.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
                array.put(json);
            }
            return write(200, "获取健康咨询列表成功!", "list", array);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取健康咨询列表失败!");
        }
    }
	/**
	 * 更新体征消息为已读
	 * @param msgid
	 * @return
	 */
	@RequestMapping(value = "read_health")
	@ResponseBody
	@ApiOperation("消息设置成已读")
	public String readHealth(long msgid) {
		try {
			messageService.readHealth(msgid);
			return success("操作成功!");
		} catch (Exception e) {
			error(e);
			return error(-1, "操作失败!");
		}
	}
    /**
     * 更新体征消息为已读
     *
     * @param msgid
     * @return
     */
    @RequestMapping(value = "read_health")
    @ResponseBody
    @ApiOperation("消息设置成已读")
    public String readHealth(long msgid) {
        try {
            messageService.readHealth(msgid);
            return success("操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
	/**
	 * 根据参数查询发送给我的消息
	 * @return
	 */
	@RequestMapping(value = "find")
	@ResponseBody
	@ApiOperation("查询发送给我的消息")
	public String findMyMessage(String sender, String signStatus) {
		try {
			Message msg = messageService.findUnreadSign(sender, getUID(), signStatus);
			JSONObject json = null;
			if (msg != null) {
				json = new JSONObject();
				json.put("id", msg.getId());
				json.put("sender", msg.getSender());
				json.put("senderName", msg.getSenderName());
				json.put("type", msg.getType());
				json.put("read", msg.getRead()); // 是否已读:1未读,0已读
				json.put("signStatus", msg.getSignStatus());
				json.put("status", msg.getOver());
				json.put("reason", msg.getReason());
			}
			return write(200, "获取消息成功!", "data", json);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息失败!");
		}
	}
    /**
     * 根据参数查询发送给我的消息
     *
     * @return
     */
    @RequestMapping(value = "find")
    @ResponseBody
    @ApiOperation("查询发送给我的消息")
    public String findMyMessage(String sender, String signStatus) {
        try {
            Message msg = messageService.findUnreadSign(sender, getUID(), signStatus);
            JSONObject json = null;
            if (msg != null) {
                json = new JSONObject();
                json.put("id", msg.getId());
                json.put("sender", msg.getSender());
                json.put("senderName", msg.getSenderName());
                json.put("type", msg.getType());
                json.put("read", msg.getRead()); // 是否已读:1未读,0已读
                json.put("signStatus", msg.getSignStatus());
                json.put("status", msg.getOver());
                json.put("reason", msg.getReason());
            }
            return write(200, "获取消息成功!", "data", json);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取消息失败!");
        }
    }
    /**
     * 系统消息(分配健管师 + 随访计划消息 )
     */
    @RequestMapping(value = "getSystemMessage", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取系统消息")
    public String getSystemMessage(@ApiParam(value = "第几页", defaultValue = "1")
                                   @RequestParam Integer page,
                                   @ApiParam(value = "每页几行", defaultValue = "10")
                                   @RequestParam Integer pagesize) {
        try {
            List<Message> list = messageService.getSystemMessage(getUID(), page, pagesize);
            return write(200, "获取消息成功!", "list", list);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取消息失败!");
        }
    }
	/**
	 * 系统消息(分配健管师 + 随访计划消息 )
	 */
	@RequestMapping(value = "getSystemMessage",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("获取系统消息")
	public String getSystemMessage(@ApiParam(value="第几页",defaultValue = "1")
							  @RequestParam Integer page,
							  @ApiParam(value="每页几行",defaultValue = "10")
							  @RequestParam Integer pagesize) {
		try {
			List<Message> list = messageService.getSystemMessage(getUID(),page,pagesize);
			return write(200, "获取消息成功!", "list", list);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息失败!");
		}
	}
    @RequestMapping(value = "getHealthIndexMessage", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取超标指标消息--根据患者分组")
    public String getHealthIndexMessage() throws Exception {
        try {
            List<Map<String, Object>> list = messageService.getHealthIndexMessage(getUID());     //"D20161008003"
	@RequestMapping(value = "getHealthIndexMessage",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("获取超标指标消息--根据患者分组")
	public String getHealthIndexMessage()throws Exception{
		try {
			List<Map<String,Object>> list = messageService.getHealthIndexMessage(getUID());     //"D20161008003"
            return write(200, "获取超标指标消息成功", "data", list);
        } catch (Exception ex) {
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
			return write(200, "获取超标指标消息成功", "data", list);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
    @RequestMapping(value = "getHealthIndexMessageByPatient", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取患者超标指标消息")
    public String getHealthIndexMessageByPatient(@ApiParam(name = "patient", value = "患者代码", defaultValue = "P20161008001")
                                                 @RequestParam(value = "patient", required = true) String patient,
                                                 @ApiParam(name = "type", value = "健康指标类型1血糖,2血压,3体重", defaultValue = "1")
                                                 @RequestParam(value = "type", required = true) String type,
                                                 @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                                                 @RequestParam(value = "page", required = true) Integer page,
                                                 @ApiParam(name = "pagesize", value = "每页几行", defaultValue = "10")
                                                 @RequestParam(value = "pagesize", required = true) Integer pagesize) throws Exception {
        try {
            List<Map<String, String>> list = messageService.getHealthIndexMessageByPatient(getUID(), patient, type, page, pagesize);
	@RequestMapping(value = "getHealthIndexMessageByPatient",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("获取患者超标指标消息")
	public String getHealthIndexMessageByPatient(@ApiParam(name="patient",value="患者代码",defaultValue = "P20161008001")
												 @RequestParam(value="patient",required = true) String patient,
												 @ApiParam(name="type",value="健康指标类型1血糖,2血压,3体重",defaultValue = "1")
												 @RequestParam(value="type",required = true) String type,
												 @ApiParam(name="page",value="第几页",defaultValue = "1")
												 @RequestParam(value="page",required = true) Integer page,
												 @ApiParam(name="pagesize",value="每页几行",defaultValue = "10")
												 @RequestParam(value="pagesize",required = true) Integer pagesize)throws Exception{
		try {
			List<Map<String,String>> list = messageService.getHealthIndexMessageByPatient(getUID(),patient,type,page,pagesize);
            return write(200, "获取超标指标消息成功", "data", list);
        } catch (Exception ex) {
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
			return write(200, "获取超标指标消息成功", "data", list);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
    /**
     * @param type 消息类型  1.是家庭签约信息  2.体征消息  3分配健管师
     */
    @RequestMapping(value = "findMessageNum")
    @ResponseBody
    @ApiOperation("获取未读消息数(1.2.8版本作废)")
    public String findMessageNum(@ApiParam(value = "消息类型", defaultValue = "3")
                                 @RequestParam Integer type) {
        try {
            JSONObject obj = messageService.findMessageNum(getUID(), type);
            return write(200, "获取消息成功!", "list", obj);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取消息失败!");
        }
    }
    /**
     * 体征指标消息查询接口
     *
     * @param isRead 1未读,0已读
     */
    @RequestMapping(value = "health")
    @ResponseBody
    @ApiOperation("体征指标消息查询接口(1.2.8版本作废)")
    public String health(long id, int pagesize, @RequestParam(required = false) String isRead) {
        try {
            JSONArray array = new JSONArray();
            Page<Message> list = messageService.findHealthListByDoctor(getUID(), id, pagesize, isRead);
            for (Message msg : list) {
                if (msg == null) {
                    continue;
                }
                JSONObject json = new JSONObject();
                // 消息ID
                json.put("id", msg.getId());
                // 发送人标识
                json.put("sender", msg.getSender());
                // 发送人姓名
                json.put("senderName", msg.getSenderName());
                // 发送人头像
                json.put("senderPhoto", msg.getSenderPhoto());
                // 消息类型:1血糖,2血压
                json.put("type", msg.getTzType());
                // 是否已读:1未读,0已读
                json.put("read", msg.getRead());
                // 是否已读:
                json.put("sex", msg.getSex());
                // 当前值/收缩压,正数为高,负数为低
                json.put("value1", msg.getValue1());
                // 上次值/舒张压,正数为高,负数为低
                json.put("value2", msg.getValue2());
                // 发送时间
                json.put("czrq", DateUtil.dateToStrLong(msg.getCzrq()));
                array.put(json);
            }
            return write(200, "获取体征消息成功!", "list", array);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取体征消息失败!");
        }
    }
    /**
     * @param type 消息类型  1.是家庭签约信息  2.体征消息  3系统消息(分配健管师 + 随访计划消息 )
     */
    @RequestMapping(value = "findMessage")
    @ResponseBody
    @ApiOperation("获取某类消息(1.2.8版本作废)")
    public String findMessage(String type,
                              long id,
                              int pagesize) {
        try {
            JSONArray array = new JSONArray();
            Page<Message> list = messageService.find(getUID(), type, id, pagesize);
            for (Message msg : list) {
                if (msg == null) {
                    continue;
                }
                JSONObject json = new JSONObject();
                // 消息ID
                json.put("id", msg.getId());
                // 发送人标识
                json.put("sender", msg.getSender());
                // 消息內容
                json.put("content", msg.getContent());
                // 发送人姓名
                json.put("senderName", msg.getSenderName());
                // 发送人头像
                json.put("senderPhoto", msg.getSenderPhoto());
                // 是否已读:1已读,0未读
                json.put("read", msg.getRead());
                // 是否已读:
                json.put("sex", msg.getSex());
                // 发送时间
                json.put("czrq", DateUtil.dateToStrNoSecond(msg.getCzrq()));
                array.put(json);
            }
            return write(200, "获取消息成功!", "list", array);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取消息失败!");
        }
    }
	/**
	 * @param type 消息类型  1.是家庭签约信息  2.体征消息  3分配健管师
	 */
	@RequestMapping(value = "findMessageNum")
	@ResponseBody
	@ApiOperation("获取未读消息数(1.2.8版本作废)")
	public String findMessageNum(@ApiParam(value="消息类型",defaultValue = "3")
								 @RequestParam Integer type) {
		try {
			JSONObject obj = messageService.findMessageNum(getUID(), type);
			return write(200, "获取消息成功!", "list", obj);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息失败!");
		}
	}
	/**
	 * 体征指标消息查询接口
	 * @param isRead 1未读,0已读
	 */
	@RequestMapping(value = "health")
	@ResponseBody
	@ApiOperation("体征指标消息查询接口(1.2.8版本作废)")
	public String health(long id, int pagesize, @RequestParam(required = false) String isRead) {
		try {
			JSONArray array = new JSONArray();
			Page<Message> list = messageService.findHealthListByDoctor(getUID(), id, pagesize, isRead);
			for (Message msg : list) {
				if (msg == null) {
					continue;
				}
				JSONObject json = new JSONObject();
				// 消息ID
				json.put("id", msg.getId());
				// 发送人标识
				json.put("sender", msg.getSender());
				// 发送人姓名
				json.put("senderName", msg.getSenderName());
				// 发送人头像
				json.put("senderPhoto", msg.getSenderPhoto());
				// 消息类型:1血糖,2血压
				json.put("type", msg.getTzType());
				// 是否已读:1未读,0已读
				json.put("read", msg.getRead());
				// 是否已读:
				json.put("sex", msg.getSex());
				// 当前值/收缩压,正数为高,负数为低
				json.put("value1", msg.getValue1());
				// 上次值/舒张压,正数为高,负数为低
				json.put("value2", msg.getValue2());
				// 发送时间
				json.put("czrq", DateUtil.dateToStrLong(msg.getCzrq()));
				array.put(json);
			}
			return write(200, "获取体征消息成功!", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取体征消息失败!");
		}
	}
	/**
	 * @param type 消息类型  1.是家庭签约信息  2.体征消息  3系统消息(分配健管师 + 随访计划消息 )
	 */
	@RequestMapping(value = "findMessage")
	@ResponseBody
	@ApiOperation("获取某类消息(1.2.8版本作废)")
	public String findMessage(String type,
							  long id,
							  int pagesize) {
		try {
			JSONArray array = new JSONArray();
			Page<Message> list = messageService.find(getUID(), type,id,pagesize);
			for (Message msg : list) {
				if (msg == null) {
					continue;
				}
				JSONObject json = new JSONObject();
				// 消息ID
				json.put("id", msg.getId());
				// 发送人标识
				json.put("sender", msg.getSender());
				// 消息內容
				json.put("content", msg.getContent());
				// 发送人姓名
				json.put("senderName", msg.getSenderName());
				// 发送人头像
				json.put("senderPhoto", msg.getSenderPhoto());
				// 是否已读:1已读,0未读
				json.put("read", msg.getRead());
				// 是否已读:
				json.put("sex", msg.getSex());
				// 发送时间
				json.put("czrq", DateUtil.dateToStrNoSecond(msg.getCzrq()));
				array.put(json);
			}
			return write(200, "获取消息成功!", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息失败!");
		}
	}
    /**
     * 设置某类消息已读
     *
     * @param type 消息类型
     * @return
     */
    @RequestMapping(value = "setMessageReaded")
    @ResponseBody
    @ApiOperation("设置某类消息已读")
    public String setMessageReaded(@RequestParam @ApiParam(value = "消息类型") Integer type) {
        try {
            messageService.setMessageReaded(getUID(),type);
            return write(200,"设置成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"设置失败");
        }
    }
}

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

@ -429,7 +429,6 @@ public class DoctorPatientGroupController extends BaseController {
            System.out.println("patients_disease_end:" + new Date());
            return write(200, "患者疾病分组列表查询成功!", "data", array);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }

+ 0 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientDiseaseController.java

@ -52,7 +52,6 @@ public class PatientDiseaseController extends BaseController {
                return write(200, "查询成功", "data", new JSONArray(redisTemplate.opsForValue().get("disease:" + patient)));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -114,7 +113,6 @@ public class PatientDiseaseController extends BaseController {
                return error(-1, "更新失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }

+ 0 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelController.java

@ -66,7 +66,6 @@ public class SignPatientLabelController extends BaseController {
                return error(-1, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "添加失败");
        }
    }
@ -132,7 +131,6 @@ public class SignPatientLabelController extends BaseController {
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -182,7 +180,6 @@ public class SignPatientLabelController extends BaseController {
            return write(200, "查询成功", "data", labels);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -238,7 +235,6 @@ public class SignPatientLabelController extends BaseController {
            return write(200, "查询成功", "data", labels);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

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

@ -41,7 +41,6 @@ public class SignPatientLabelInfoController extends BaseController {
            JSONObject p = labelInfoService.getPatient(patient);
            return write(200, "查询成功", "data", p);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -250,7 +249,6 @@ public class SignPatientLabelInfoController extends BaseController {
                return error(-1, "更新失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -317,7 +315,6 @@ public class SignPatientLabelInfoController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -379,7 +376,6 @@ public class SignPatientLabelInfoController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -438,7 +434,6 @@ public class SignPatientLabelInfoController extends BaseController {
                return error(-1, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "添加失败");
        }
    }
@ -509,7 +504,6 @@ public class SignPatientLabelInfoController extends BaseController {
                return error(-1, "删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "删除失败");
        }
    }

+ 0 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/reply/DoctorQuickReplyController.java

@ -42,7 +42,6 @@ public class DoctorQuickReplyController extends BaseController {
                return error(-1, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "添加失败");
        }
    }
@ -90,7 +89,6 @@ public class DoctorQuickReplyController extends BaseController {
                return error(-1, "删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "删除失败");
        }
    }
@ -144,7 +142,6 @@ public class DoctorQuickReplyController extends BaseController {
                return error(-1, "排序失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "排序失败");
        }
    }

+ 0 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/scheduling/DoctorWorkTimeController.java

@ -41,7 +41,6 @@ public class DoctorWorkTimeController extends BaseController {
            return write(200, "查询成功!", "data", workTime);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }
@ -112,7 +111,6 @@ public class DoctorWorkTimeController extends BaseController {
                return write(-1, "保存失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "保存失败!");
        }
    }
@ -167,7 +165,6 @@ public class DoctorWorkTimeController extends BaseController {
                return error(-1, "设置失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "设置失败");
        }
    }
@ -206,7 +203,6 @@ public class DoctorWorkTimeController extends BaseController {
            JSONObject result = doctorWorkTimeService.isFamousDoctorWorking(doctor);
            return write(200,result.getString("msg"),"data",result.getString("status"));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
@ -243,7 +239,6 @@ public class DoctorWorkTimeController extends BaseController {
            JSONObject json = doctorWorkTimeService.findDoctorWeekWorkTime(doctor, week);
            return write(200, "查询成功", "data", json);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

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

@ -123,7 +123,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject list = familyContractService.getPatientByLable(doctorcode, labelType, level, team);
            return write(200, "查询成功", "data", list);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -659,7 +658,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                return write(-1, "不存在该患者签约");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -763,7 +761,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            return write(200, "查询成功", "data", json);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -823,7 +820,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            }
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -864,7 +860,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject list = familyContractService.findNoHealthSignFamilyHealthByParams(getUID(), teamCode, params);
            return write(200, "签约数据加载成功!", "data", list);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -934,7 +929,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
        } catch (Exception e) {
            redisTemplate.opsForValue().set("expenses:remind:doctor:" + getUID(), "0");
            redisTemplate.expire("expenses:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
            e.printStackTrace();
            return error(-1, "提醒失败");
        }
    }
@ -987,7 +981,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.isPatientAndDoctorExistSign(patient, doctor);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -1033,7 +1026,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.getPatientDoctors(patient, getUID());
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -1056,6 +1048,23 @@ public class DoctorFamilyContractController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "/patient_doctor_teams", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value = "查询医生与居民的团队")
    public String getPatientAndDoctorTeams(@RequestParam @ApiParam(value = "居民code") String patient) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "居民不能为空");
            }
            JSONObject result = familyContractService.getPatientAndDoctorTeams(patient, getUID());
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value = "/wechat_focus_remind", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value = "微信关注提醒")
@ -1092,7 +1101,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
        } catch (Exception e) {
            redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + getUID(), "0");
            redisTemplate.expire("wechat:focus:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
            e.printStackTrace();
            return error(-1, "微信关注提醒失败");
        }
    }
@ -1105,7 +1113,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
     */
    @RequestMapping(value = "/is_patient_remind_focus")
    @ResponseBody
    public String isPatientRemindFocusToday(String patient){
    public String isPatientRemindFocusToday(String patient) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "患者不能为空");

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

@ -325,7 +325,6 @@ public class DoctorSignController extends BaseController {
        try{
            return write(200,"查询成功","data",signWebService.isRemindFocusAll(getUID()));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }

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

@ -309,7 +309,6 @@ public class AdminTeamController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

+ 0 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -750,7 +750,6 @@ public class PatientController extends WeixinBaseController {
                return write(-1, "手机号更新失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "手机号更新失败");
        }
    }
@ -801,7 +800,6 @@ public class PatientController extends WeixinBaseController {
            patientInfoService.updatePassword(newPassword1, newPassword2, oldPassword, getUID());
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }

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

@ -124,7 +124,6 @@ public class ConsultController extends WeixinBaseController {
            return write(200, "查询成功!", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }
@ -161,7 +160,6 @@ public class ConsultController extends WeixinBaseController {
            JSONObject result = doctorWorkTimeService.isDoctorWorking(doctor);
            return write(200, result.getString("msg"), "data", result.getString("status"));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -197,7 +195,6 @@ public class ConsultController extends WeixinBaseController {
            int result = doctorWorkTimeService.getDoctorConsultTimesRemain(doctor);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -239,7 +236,6 @@ public class ConsultController extends WeixinBaseController {
                return write(200, "查询成功", "data", "");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

+ 0 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/family/FamilyMemberController.java

@ -72,7 +72,6 @@ public class FamilyMemberController extends BaseController {
                return write(200, "添加成功");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "添加失败");
        }
    }
@ -134,7 +133,6 @@ public class FamilyMemberController extends BaseController {
                return write(200, "删除成功");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "删除失败");
        }
    }
@ -179,7 +177,6 @@ public class FamilyMemberController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

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

@ -61,7 +61,6 @@ public class PatientHealthGuidanceController extends BaseController {
			JSONObject guidance = patientHealthGuidanceService.findById(id);
			return write(200,"查询成功","data",guidance);
		}catch (Exception e){
			e.printStackTrace();
			return error(-1,"查询失败");
		}
	}

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

@ -463,7 +463,6 @@ public class FamilyContractController extends BaseController {
                return write(200, "签约申请成功");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "签约申请失败");
        }
    }
@ -614,7 +613,6 @@ public class FamilyContractController extends BaseController {
            JSONObject result = familyContractService.isPatientAndDoctorCanSign(getUID(),doctor);
            return write(200,"查询成功","data",result);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }

+ 0 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/quota/JobController.java

@ -237,7 +237,6 @@ public class JobController extends BaseController {
            diseaseService.updateToDisease();
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }

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

@ -43,7 +43,6 @@ public class StatisticsController extends BaseController {
        try {
            return write(200, "查询成功", "data", statisticsService.getStatisticsTime());
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -80,7 +79,6 @@ public class StatisticsController extends BaseController {
            return write(200, "查询成功!", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, tag + "查询失败!");
        }
    }
@ -142,7 +140,6 @@ public class StatisticsController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -208,7 +205,6 @@ public class StatisticsController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -279,7 +275,6 @@ public class StatisticsController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -340,7 +335,6 @@ public class StatisticsController extends BaseController {
            return write(200, "查询成功!", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }
@ -410,7 +404,6 @@ public class StatisticsController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -470,7 +463,6 @@ public class StatisticsController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

+ 4 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java

@ -453,7 +453,7 @@ public class BookingController extends WeixinBaseController {
    }
    /********************************************* 医生端查询 **************************************************************************/
    @RequestMapping(value = "GetPatientReservationList", method = RequestMethod.POST)
    @RequestMapping(value = "GetPatientReservationList", method = {RequestMethod.POST,RequestMethod.GET})
    @ResponseBody
    @ApiOperation("获取患者预约信息列表接口-医生端")
    public String GetPatientReservation(@ApiParam(name = "pageIndex", value = "第几页", defaultValue = "1")
@ -462,10 +462,10 @@ public class BookingController extends WeixinBaseController {
                                        @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                        @ApiParam(name = "patient", value = "患者编号", defaultValue = "4afdbce6194e412fbc770eb4dfbe7b00")
                                        @RequestParam(value = "patient", required = false) String patient,
                                        @ApiParam(name = "doctor", value = "医生编号", defaultValue = "shiliuD20160926005")
                                        @RequestParam(value = "doctor", required = false) String doctor) {
                                        @ApiParam(name = "teamCode", value = "行政团队", defaultValue = "shiliuD20160926005")
                                        @RequestParam(value = "teamCode", required = false) Long teamCode) {
        try {
            List<PatientReservation> list = patientReservationService.getReservationByPatient(patient, doctor, pageIndex, pageSize);
            List<PatientReservation> list = patientReservationService.getReservationByPatient(patient, teamCode, pageIndex, pageSize);
            return write(200, "获取患者预约信息列表成功!", "data", list);
        } catch (Exception e) {

+ 0 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/WechatCoreController.java

@ -55,7 +55,6 @@ public class WechatCoreController extends WeixinBaseController {
                response.setStatus(401);
            }
        } catch (Exception e) {
            e.printStackTrace();
            // 服务器错误
            response.setStatus(500);
        }
@ -180,7 +179,6 @@ public class WechatCoreController extends WeixinBaseController {
                return write(-1,"创建失败!","data",jsonStr);
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"创建失败");
        }
    }

+ 12 - 12
patient-co-wlyy/src/main/webapp/WEB-INF/web.xml

@ -77,16 +77,16 @@
  <session-config>
    <session-timeout>20</session-timeout>
  </session-config>
  <error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/WEB-INF/views/error/500.jsp</location>
  </error-page>
  <error-page>
    <error-code>500</error-code>
    <location>/WEB-INF/views/error/500.jsp</location>
  </error-page>
  <error-page>
    <error-code>404</error-code>
    <location>/WEB-INF/views/error/404.jsp</location>
  </error-page>
  <!--<error-page>-->
    <!--<exception-type>java.lang.Throwable</exception-type>-->
    <!--<location>/WEB-INF/views/error/500.jsp</location>-->
  <!--</error-page>-->
  <!--<error-page>-->
    <!--<error-code>500</error-code>-->
    <!--<location>/WEB-INF/views/error/500.jsp</location>-->
  <!--</error-page>-->
  <!--<error-page>-->
    <!--<error-code>404</error-code>-->
    <!--<location>/WEB-INF/views/error/404.jsp</location>-->
  <!--</error-page>-->
</web-app>