瀏覽代碼

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

chenweida 8 年之前
父節點
當前提交
6aa4d22531
共有 25 個文件被更改,包括 469 次插入143 次删除
  1. 33 33
      patient-co-wlyy/src/main/java/com/yihu/wlyy/job/RenewToSignJob.java
  2. 4 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/consult/ConsultDao.java
  3. 5 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java
  4. 6 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java
  5. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyRenewDao.java
  6. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/template/DoctorTeamGuidanceTemplateDao.java
  7. 1 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java
  8. 12 16
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultService.java
  9. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  10. 5 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  11. 116 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  12. 3 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/PatientRemindService.java
  13. 177 10
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  14. 30 44
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java
  15. 2 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  16. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/common/Configure.java
  17. 10 11
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java
  18. 2 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  19. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  20. 7 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java
  21. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  22. 23 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java
  23. 16 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/PatientSignController.java
  24. 4 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/survey/PatientQuestionnaireController.java
  25. 3 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java

+ 33 - 33
patient-co-wlyy/src/main/java/com/yihu/wlyy/job/RenewToSignJob.java

@ -22,39 +22,39 @@ public class RenewToSignJob implements Job {
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        try {
            Calendar cal = Calendar.getInstance();
            int year = cal.get(Calendar.YEAR)-1;
            int month = cal.get(Calendar.MONTH)+1;
            if(month >=7){
                //设置已过期
                String sql = "UPDATE wlyy_sign_family t SET t.status = -4,t.apply_unsign_date='"+ DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss")+"'  WHERE t.status>=0 AND t.sign_year='"+year+"'";
//                //数据迁移
                String sql2 ="INSERT INTO wlyy_sign_family(" +
                        "code,lw_code,type,patient,openid,name,idcard,ssc," +
                        "mobile,emer_mobile,hospital,hospital_name,doctor," +
                        "doctor_name,begin,end,images,group_code,status,reason," +
                        "czrq,team_code,sign_type,apply_date,release_speak," +
                        "doctor_health_name,doctor_health,family_code,patient_apply_date," +
                        "expenses,expenses_status,sign_source,sign_doctor_code,sign_doctor_name," +
                        "sign_doctor_level,patient_apply_unsgin_date,apply_unsign_date,expenses_type," +
                        "sign_year,medical_insurance_num,agent_doctor_code,agent_doctor_name," +
                        "agent_doctor_level,admin_team_code,expenses_time,server_type,server_type_name,special_population,special_population_name,renew_flag,renew_change_reason) " +
                        "SELECT code,lw_code,type,patient,openid,name,idcard,ssc," +
                        "mobile,emer_mobile,hospital,hospital_name,doctor,doctor_name," +
                        "begin,end,images,group_code,status,reason,czrq,team_code," +
                        "sign_type,apply_date,release_speak,doctor_health_name," +
                        "doctor_health,family_code,patient_apply_date,expenses," +
                        "expenses_status,sign_source,sign_doctor_code,sign_doctor_name," +
                        "sign_doctor_level,patient_apply_unsgin_date,apply_unsign_date," +
                        "expenses_type,sign_year,medical_insurance_num,agent_doctor_code," +
                        "agent_doctor_name,agent_doctor_level,admin_team_code,expenses_time,server_type,server_type_name,special_population,special_population_name,renew_flag,renew_change_reason " +
                        "FROM wlyy_sign_family_renew t WHERE t.is_valid =0 AND t.sign_year='"+(year+1)+"'";
                //更改迁移状态
                String sql3 = "UPDATE wlyy_sign_family_renew t SET t.is_valid =1 WHERE t.is_valid =0 AND t.sign_year='"+(year+1)+"'";
                jdbcTemplate.execute(sql);
                jdbcTemplate.execute(sql2);
                jdbcTemplate.execute(sql3);
            }
//            Calendar cal = Calendar.getInstance();
//            int year = cal.get(Calendar.YEAR)-1;
//            int month = cal.get(Calendar.MONTH)+1;
//            if(month >=7){
//                //设置已过期
//                String sql = "UPDATE wlyy_sign_family t SET t.status = -4,t.apply_unsign_date='"+ DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss")+"'  WHERE t.status>=0 AND t.sign_year='"+year+"'";
////                //数据迁移
//                String sql2 ="INSERT INTO wlyy_sign_family(" +
//                        "code,lw_code,type,patient,openid,name,idcard,ssc," +
//                        "mobile,emer_mobile,hospital,hospital_name,doctor," +
//                        "doctor_name,begin,end,images,group_code,status,reason," +
//                        "czrq,team_code,sign_type,apply_date,release_speak," +
//                        "doctor_health_name,doctor_health,family_code,patient_apply_date," +
//                        "expenses,expenses_status,sign_source,sign_doctor_code,sign_doctor_name," +
//                        "sign_doctor_level,patient_apply_unsgin_date,apply_unsign_date,expenses_type," +
//                        "sign_year,medical_insurance_num,agent_doctor_code,agent_doctor_name," +
//                        "agent_doctor_level,admin_team_code,expenses_time,server_type,server_type_name,special_population,special_population_name,renew_flag,renew_change_reason) " +
//                        "SELECT code,lw_code,type,patient,openid,name,idcard,ssc," +
//                        "mobile,emer_mobile,hospital,hospital_name,doctor,doctor_name," +
//                        "begin,end,images,group_code,status,reason,czrq,team_code," +
//                        "sign_type,apply_date,release_speak,doctor_health_name," +
//                        "doctor_health,family_code,patient_apply_date,expenses," +
//                        "expenses_status,sign_source,sign_doctor_code,sign_doctor_name," +
//                        "sign_doctor_level,patient_apply_unsgin_date,apply_unsign_date," +
//                        "expenses_type,sign_year,medical_insurance_num,agent_doctor_code," +
//                        "agent_doctor_name,agent_doctor_level,admin_team_code,expenses_time,server_type,server_type_name,special_population,special_population_name,renew_flag,renew_change_reason " +
//                        "FROM wlyy_sign_family_renew t WHERE t.is_valid =0 AND t.sign_year='"+(year+1)+"'";
//                //更改迁移状态
//                String sql3 = "UPDATE wlyy_sign_family_renew t SET t.is_valid =1 WHERE t.is_valid =0 AND t.sign_year='"+(year+1)+"'";
//                jdbcTemplate.execute(sql);
//                jdbcTemplate.execute(sql2);
//                jdbcTemplate.execute(sql3);
//            }
            System.out.println("RenewToSign end");
        } catch (Exception e) {

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

@ -13,19 +13,19 @@ public interface ConsultDao extends PagingAndSortingRepository<Consult, Long>, J
    Consult findByCode(String code);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.symptoms like ?2 order by a.czrq desc")
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.symptoms like ?2 order by a.czrq desc")
    Page<Object> findByPatient(String patient, String title, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?3 and a.del = '1'and a.symptoms like ?2 order by a.czrq desc")
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?3 and a.del = '1'and a.symptoms like ?2 order by a.czrq desc")
    Page<Object> findByPatient(String patient, String title, long id, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' order by a.czrq desc")
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' order by a.czrq desc")
    Page<Object> findByPatient(String patient, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?2 and a.del = '1'order by a.czrq desc")
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?2 and a.del = '1'order by a.czrq desc")
    Page<Object> findByPatient(String patient, long id, Pageable pageRequest);
    @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")

+ 5 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java

@ -34,12 +34,15 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query("update Message a set a.read = 0,a.over='0' where a.id = ?1")
    int read(long msgid);
    @Query("SELECT a FROM Message a WHERE a.sender=?1 AND a.receiver = ?2 and a.signStatus = ?3 and a.read=1")
    Message findUnreadSign(String sender, String receiver, String signStatus);
    @Query("SELECT a FROM Message a WHERE a.sender=?1 AND a.receiver = ?2 and a.signStatus = ?3 and a.read=1 ORDER BY czrq DESC")
    List<Message> findUnreadSign(String sender, String receiver, String signStatus);
    @Query(" from Message a where a.read = 1 and over ='1' and a.sender = ?1 and a.receiver=?2 and a.signStatus='1'")
    Message findByPatient(String patient,String doctor);
    @Query(" from Message a where a.read = 1 and over ='1' and a.sender = ?1 and a.receiver=?2 ")
    Message findByPatientRenew(String patient,String doctor);
    @Query("select a from Message a where a.receiver = ?1 and a.sender=?2 and a.tzType=?3 order by a.createTime desc")
    List<Message> getHealthIndexMessageByPatient(String doctor,String patient,String type,Pageable pageRequest);

+ 6 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java

@ -305,6 +305,9 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status >= 0")
    SignFamily findByPatient(String patient);
    @Query("select a from SignFamily a where a.teamCode = ?1 and a.type =2 and a.status >= 0")
    SignFamily findByTeam(String teamCode);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status >= 0")
    List<SignFamily> findByPatients(String patient);
@ -395,4 +398,7 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    @Query(value = " select a.*  from wlyy_sign_family a where a.patient = ?1  and a.status = -4 order by a.apply_date desc limit 0,1", nativeQuery = true)
    SignFamily findOutTimeSigningByPatient(String patient);
    @Query(value = " select a.*  from wlyy_sign_family a where a.patient = ?1  and a.status = -4 and a.team_code = ?2 order by a.apply_date desc limit 0,1", nativeQuery = true)
    SignFamily findOutTimeSigningByPatientAndTeamCode(String patient,String teamCode);
}

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

@ -56,4 +56,7 @@ public interface SignFamilyRenewDao extends PagingAndSortingRepository<SignFamil
    @Query("select a from SignFamilyRenew a where a.patient = ?1 and a.type = ?2 and a.status > 0")
    SignFamilyRenew findSignByPatient(String patient, int type);
    @Query("select a from SignFamilyRenew a where a.doctor = ?1 and a.patient = ?2 and a.type = 2 and a.status >= 0")
    SignFamilyRenew findByDoctorPatient(String doctor, String patient);
}

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

@ -15,7 +15,7 @@ import java.util.List;
public interface DoctorTeamGuidanceTemplateDao extends PagingAndSortingRepository<DoctorTeamGuidanceTemplate, Long>, JpaSpecificationExecutor<DoctorTeamGuidanceTemplate> {
    //    新增团队模板时团队内标题排重
    @Query("select t from DoctorTeamGuidanceTemplate t where t.title = ?1 and t.teamId = ?2 ")
    @Query("select t from DoctorTeamGuidanceTemplate t where t.del = 1 and t.title = ?1 and t.teamId = ?2 ")
    List<DoctorTeamGuidanceTemplate> distinctByTeamTitle(String title, int teamId);
    //    根据团队ID获取团队内的模板列表(带分页和创建时间倒序)

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

@ -843,6 +843,7 @@ public class DoctorInfoService extends BaseService {
        JSONObject data = new JSONObject();
        if (StringUtils.isNotEmpty(oldDoctorCode)) {
            data.put("toUser", patient);
            data.put("represented",patient);//被代理人
            data.put("doctor", newD.getCode());
            data.put("doctorName", newD.getName());
            data.put("first", p.getName() + ",您好!因签约团队内分工调整,您的责任医生有变动," + oldDoctorHealthName +

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

@ -1,12 +1,14 @@
package com.yihu.wlyy.service.app.consult;
import java.util.Date;
import java.util.List;
import com.yihu.wlyy.entity.consult.Consult;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.consult.*;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.SendPatientUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -14,22 +16,13 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import com.yihu.wlyy.entity.consult.Consult;
import com.yihu.wlyy.repository.consult.ConsultCommunicationDao;
import com.yihu.wlyy.repository.consult.ConsultCommunicationReplyDao;
import com.yihu.wlyy.repository.consult.ConsultDao;
import com.yihu.wlyy.repository.consult.ConsultMoViDao;
import com.yihu.wlyy.repository.consult.ConsultPublicDao;
import com.yihu.wlyy.repository.consult.ConsultPublicReplyDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.List;
@Component
@Transactional
public class ConsultService extends BaseService {
@ -76,7 +69,10 @@ public class ConsultService extends BaseService {
		consult.setSymptoms(symptoms);
		consult.setImages(images);
		consult.setType(type);
		consult.setSignCode(patientService.getSignCodeByPatient(patient));
		SignFamily signFamily = signFamilyDao.findByPatient(patient);
		if(signFamily!=null){
			consult.setSignCode(signFamily.getCode());
		}
		return consultDao.save(consult);
	}

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

@ -290,7 +290,7 @@ public class SignPatientLabelInfoService extends BaseService {
                args = new Object[]{doctor, doctor, teamCode};
            }else{
                sql = "SELECT " +
                        "    t1.* " +
                        "    t1.* "+
                        " FROM " +
                        "    wlyy_sign_family t1 " +
                        " WHERE (t1.doctor = ? or t1.doctor_health = ?) " +

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

@ -226,8 +226,11 @@ public class MessageService extends BaseService {
     * 未读签约信息
     */
    public Message findUnreadSign(String sender, String receiver, String signStatus) {
        return messageDao.findUnreadSign(sender, receiver, signStatus);
        List<Message> messages = messageDao.findUnreadSign(sender, receiver, signStatus);
        if(messages!=null&&messages.size()>0){
            return messages.get(0);
        }
        return null;
    }
    public Page<Message> find(String doctor, String type, long id, int pagesize) {

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

@ -665,6 +665,38 @@ public class FamilyContractService extends BaseService {
        return 200;
    }
    /**
     * 取消续签
     * @param patient
     * @param doctor
     * @return
     * @throws Exception
     */
    public int unsignRenew(String patient, String doctor) throws Exception {
        if(DateUtil.getNowMonth()<7){
            SignFamilyRenew  sf = signFamilyRenewDao.findByDoctorPatient(doctor, patient);
            if (sf!=null&&sf.getStatus() != 0 && sf.getStatus() != 2) {
                return -2;
            }
            sf.setStatus(-1);
        }else{
            SignFamily  sf = signFamilyDao.findByDoctorPatient(doctor, patient);
            if (sf!=null&&sf.getStatus() != 0 && sf.getStatus() != 2) {
                return -2;
            }
            sf.setStatus(-1);
        }
        Message message = messageDao.findByPatientRenew(patient, doctor);
        //修改信息为无效
        if (message != null) {
            message.setRead(0);
            message.setOver("0");
        }
        return 200;
    }
    /**
     * 申请解约
     *
@ -3509,7 +3541,7 @@ public class FamilyContractService extends BaseService {
                " wlyy_sign_family s " +
                " WHERE " +
                " s.`status` >= 0 " +
                " AND s.server_type IS NOT NULL AMD s.server_type <>'3' "+
                " AND s.server_type IS NOT NULL AND s.server_type <>'3' "+
                " AND s.admin_team_code =" +teamCode+
                " AND s.doctor_health IS NULL";
        List<Map<String,Object>> patientList = jdbcTemplate.queryForList(patientSql);
@ -3554,6 +3586,89 @@ public class FamilyContractService extends BaseService {
        return rs;
    }
    public JSONObject getServerPatientListNum(Long teamCode,String level, String oldDoctorCode){
        String serverSql="SELECT " +
                " d.`code` As labelCode, " +
                " d.`name` AS label " +
                " FROM " +
                " wlyy_sign_dict d " +
                " WHERE " +
                " d.type IN ('1', '2') " +
                " AND d. YEAR = '"+DateUtil.getSignYear()+"' " +
                " AND d.`code` NOT IN ( " +
                " SELECT " +
                "  LEFT ( " +
                "   d. CODE, " +
                "   (INSTR(d. CODE, '-') - 1) " +
                "  ) AS CODE " +
                " FROM " +
                "  wlyy_sign_dict d " +
                " WHERE " +
                "  d. CODE LIKE '%-%' " +
                " GROUP BY " +
                "  CODE " +
                ")";
        String patientSql =" SELECT " +
                " s.patient, " +
                " s.server_type AS serverType, " +
                " s.special_population AS specialPopulation, " +
                " s.sign_year " +
                " FROM " +
                " wlyy_sign_family s " +
                " WHERE " +
                " s.`status` >= 0 " +
                " AND s.server_type IS NOT NULL AND s.server_type <>'3' "+
                " AND s.admin_team_code =" +teamCode;
        //1查询全科,其他查询健管师
        if("2".equals(level)){
            patientSql =  patientSql+" AND s.doctor ='"+oldDoctorCode+"'";
        }else{
            patientSql =  patientSql+" AND s.doctor_health ='"+oldDoctorCode+"'";
        }
        List<Map<String,Object>> patientList = jdbcTemplate.queryForList(patientSql);
        JSONObject rs = new JSONObject();
        rs.put("count",(patientList!=null&&patientList.size()>0)?patientList.size():0);
        List<Map<String,Object>> serlist = jdbcTemplate.queryForList(serverSql);
        if(serlist!=null&&serlist.size()>0){
            if(patientList!=null){
                for(Map<String,Object> map :serlist){
                    String labelCode = (String)map.get("labelCode");
                    List<Map<String,String>> codes = new ArrayList<>();
                    Iterator iterator = patientList.iterator();
                    while(iterator.hasNext()){
                        Map<String,Object> p =  ( Map<String,Object>)iterator.next();
                        String serverType = ((String)p.get("serverType"))==null?"":((String)p.get("serverType"));
                        if(labelCode.indexOf("-")==-1){
                            if(labelCode.equals(serverType)){
                                Map<String,String> code = new HashMap<>();
                                code.put("code",(String)p.get("patient"));
                                codes.add(code);
                                iterator.remove();
                            }
                        }else{
                            String[] key = labelCode.split("-");
                            if(key[0].equals(serverType)){
                                Map<String,String> code = new HashMap<>();
                                code.put("code",(String)p.get("patient"));
                                codes.add(code);
                                iterator.remove();
                            }
                        }
                    }
                    map.put("codes",codes);
                    map.put("number",(codes!=null&&codes.size()>0)?codes.size():0);
                }
            }
        }
        rs.put("patients",serlist);
        return rs;
    }
    public List<Map<String,Object>> patientGroupByServerType(String doctor) {
        // 先根据server_type分组查找wlyy_sign_family表中该医生的签约的患者,然后wlyy_sign_dict left join 得到全部的类型

+ 3 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/PatientRemindService.java

@ -228,6 +228,7 @@ public class PatientRemindService extends BaseService {
                isOpenIdExist = true;
                // 添加到发送队列
                PushMsgTask.getInstance().putWxMsg(tokenUtils.getAccessToken(), 8, p.getOpenid(), p.getName(), json);
                wFlag = true;
            }
//                else{
//                    JSONObject j  = weiXinOpenIdUtils.getFamilyOpenId(p.getCode());
@ -254,10 +255,11 @@ public class PatientRemindService extends BaseService {
                    data.remove("doctorName");
                    data.put("doctorName", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), p.getName()) +"\n"+first);
                    PushMsgTask.getInstance().putWxMsg(tokenUtils.getAccessToken(), 8, member.getOpenid(), p.getName(), data);
                    wFlag = true;
                }
            }
                wFlag = true;
//            }
            //发送IM
            consultService.sendMucMessageBySingnType(doc.getCode(), doc.getName(), p.getCode(), doc.getName() + "医生提醒您:为完成家庭医生签约," +

+ 177 - 10
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.service.app.sign;
import com.yihu.wlyy.entity.consult.Consult;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
@ -7,6 +8,7 @@ import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.*;
import com.yihu.wlyy.repository.consult.ConsultDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
@ -82,6 +84,8 @@ public class SignWebService extends BaseService {
    private DoctorTeamMemberDao doctorTeamMemberDao;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private ConsultDao consultDao;
    /**
     * 根据医生代码及签约状态编码 获取该医生签约患者的信息列表
@ -485,7 +489,11 @@ public class SignWebService extends BaseService {
            jsonObject.put("createTime", signFamily.getCzrq());
            jsonObject.put("type", signFamily.getType());
            jsonObject.put("typeName", signFamily.getType() == 1 ? "三师签约" : "家庭签约");
            jsonObject.put("isRenew", "0");
            if(StringUtils.isNotBlank(signFamily.getRenewFlag())){
                jsonObject.put("isRenew", "1");
            }else{
                jsonObject.put("isRenew", "0");
            }
            String statusName = "";
            switch (jsonObject.getInt("status")) {
                case -4:
@ -530,6 +538,112 @@ public class SignWebService extends BaseService {
        return jsonArray;
    }
    /**
     * 进行中的咨询获取服务团队信息
     * @param teamCode
     * @param code
     * @return
     */
    public JSONObject getConsultSignInfoOrRenewInfo(String teamCode, String code,String patient,String consultCode) {
        //签约或续签参数
        String patientCode = null;
        Long adminTeamId = null;
        String doctorHealth = null;
        String doctor = null;
        //先查找续签表有没有记录
        List<SignFamilyRenew> renews = signFamilyRenewDao.findByTeamCodeIsValid(teamCode, code);
        if (renews == null || renews.size() == 0) {
            //再查找签约表记录
            List<SignFamily> signFamilys = signFamilyDao.findByTeamCodeIsValid(teamCode, code);
            SignFamily signFamily = null;
            if (signFamilys == null || signFamilys.size() == 0) {
                signFamily = signFamilyDao.findByTeam(teamCode);
                if(signFamily==null){
                    signFamily = signFamilyDao.findOutTimeSigningByPatientAndTeamCode(patient,teamCode);
                    if(signFamily==null){
                        throw new RuntimeException("找不到签约关系!");
                    }
                }else {
                    Consult consult = consultDao.findByCode(consultCode);
                    if(signFamily.getApplyDate().getTime()-consult.getCzrq().getTime()>0){// 判断咨询是否在签约之后
                        signFamily = signFamilyDao.findOutTimeSigningByPatientAndTeamCode(patient,teamCode);
                        if(signFamily==null){
                            throw new RuntimeException("找不到签约关系!");
                        }
                    }
                }
            } else {
                signFamily = signFamilys.get(0);
            }
            patientCode = signFamily.getPatient();
            adminTeamId = signFamily.getAdminTeamId();
            doctorHealth = signFamily.getDoctorHealth();
            doctor = signFamily.getDoctor();
        } else {
            SignFamilyRenew renew = renews.get(0);
            patientCode = renew.getPatient();
            adminTeamId = renew.getAdminTeamId();
            doctorHealth = renew.getDoctorHealth();
            doctor = renew.getDoctor();
        }
        Patient p = patientService.findByCode(patientCode);
        JSONObject resultObject = new JSONObject();
        AdminTeam adminTeam = adminTeamService.getTeam(adminTeamId);
        //查找到团队领导
        Doctor leader = doctorService.findDoctorByCode(adminTeam.getLeaderCode());
        JSONObject leaderObj = this.doctorParse(leader);
        resultObject.put("leader", leaderObj);
        //签约团队的健管师
        if (StringUtils.isNotBlank(doctorHealth)) {
            Doctor health = doctorService.findDoctorByCode(doctorHealth);
            if (health != null) {
                JSONObject healthObj = this.doctorParse(health);
                resultObject.put("doctorHealth", healthObj);
            } else {
                resultObject.put("doctorHealth", "");
            }
        }
        //签约团队的全科医生
        if (StringUtils.isNotBlank(doctor)) {
            Doctor qk = doctorService.findDoctorByCode(doctor);
            if (qk != null) {
                JSONObject healthObj = this.doctorParse(qk);
                resultObject.put("doctor", healthObj);
            } else {
                resultObject.put("doctor", "");
            }
        }
        Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+08:00"));
        int year = calendar.get(Calendar.YEAR);
        //统计当年咨询数量
        String consult_sql = "select count(1) as count from wlyy_consult_team  w where w.doctor = ? and w.patient =? and YEAR(w.czrq) = ? ";
        //统计随访数量
        String followup_sql = "select count(1) as count from wlyy_followup  w where (w.doctor_code = ? or w.doctor_code =?) and w.patient_code =? and YEAR(w.create_time) = ?  and w.followup_class is not null ";
        //统计待预约数量
        String reservation_sql = "select count(1) as count from wlyy_patient_reservation  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        //统计健康教育数量
        String article_sql = "select count(1) as count from wlyy_health_edu_article_patient  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        //统计健康指导数量
        String guidance_sql = "select count(1) as count from wlyy_patient_health_guidance  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        StringBuffer countSql = new StringBuffer();
        countSql.append(consult_sql).append(" union all ").append(followup_sql).append(" union all ").append(reservation_sql).append(" union all ").append(article_sql).append(" union all ").append(guidance_sql);
        List<Map<String, Object>> resultCount = jdbcTemplate.queryForList(countSql.toString(), new Object[]{doctorHealth, patient, year, doctorHealth, doctor, patient, year, doctorHealth, doctor, patient, year, doctorHealth, doctor, patient, year, doctorHealth, doctor, patient, year});
        resultObject.put("consultNum", resultCount.get(0).get("count"));
        resultObject.put("followupNum", resultCount.get(1).get("count"));
        resultObject.put("reservationNum", resultCount.get(2).get("count"));
        resultObject.put("articleNum", resultCount.get(3).get("count"));
        resultObject.put("guidanceNum", resultCount.get(4).get("count"));
        return resultObject;
    }
    /**
     * 已过时,启用getSignInfoOrRenewInfo
     *
@ -573,7 +687,7 @@ public class SignWebService extends BaseService {
        //统计当年咨询数量
        String consult_sql = "select count(1) as count from wlyy_consult_team  w where w.doctor = ? and w.patient =? and YEAR(w.czrq) = ? ";
        //统计随访数量
        String followup_sql = "select count(1) as count from wlyy_followup  w where (w.doctor_code = ? or w.doctor_code =?) and w.patient_code =? and YEAR(w.create_time) = ?  and w.followup_class is not null ";
        String followup_sql = "select count(1) as count from wlyy_followup  w where (w.doctor_code = ? or w.doctor_code =?) and w.patient_code =? and YEAR(w.create_time) = ? ";
        //统计待预约数量
        String reservation_sql = "select count(1) as count from wlyy_patient_reservation  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        //统计健康教育数量
@ -615,7 +729,7 @@ public class SignWebService extends BaseService {
        //获取咨询
        String consult_sql = "select w.consult,w.symptoms,w.czrq,w.status,1 as type from wlyy_consult_team  w where w.doctor = ? and w.patient =? and YEAR(w.czrq) = ? ";
        //获取随访
        String followup_sql = "select w.id,w.followup_type,w.followup_class,w.followup_date as czrq,w.followup_manager_status,w.status,2 as type from wlyy_followup  w where (w.doctor_code = ? or w.doctor_code =?) and w.patient_code =? and YEAR(w.create_time) = ? and w.followup_class is not null ";
        String followup_sql = "select w.id,w.followup_type,w.followup_class,w.followup_date as czrq,w.followup_manager_status,w.status,2 as type from wlyy_followup  w where (w.doctor_code = ? or w.doctor_code =?) and w.patient_code =? and YEAR(w.create_time) = ?  ";
        //获取待预约
        String reservation_sql = "select w.code,w.id, w.doctor_name,w.doctor_code,w.doctor_job,w.doctor,w.dname,w.org_code,w.status,w.start_time as czrq,3 as type from wlyy_patient_reservation  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        //获取健康教育
@ -1020,7 +1134,7 @@ public class SignWebService extends BaseService {
                " AND a.sign_year = '"+DateUtil.getSignYear()+"' " +
                ")";
        List<Map<String, Object>> signFamilies = jdbcTemplate.queryForList(sql, new Object[]{doctor});
        List<Map<String, Object>> signFamilies = jdbcTemplate.queryForList(sql);
        if (signFamilies != null && signFamilies.size() > 0) {
            for (Map<String, Object> signFamily : signFamilies) {
@ -1116,15 +1230,18 @@ public class SignWebService extends BaseService {
                    }
                }
                renew.setApplyDate(new Date());
                //1.3.3.2 加入统计日志
                if ("1".equals(state)) {
                    setRenewLog(renew);
                }
                //1.3.3.4 根据团队设置标识
                setRenewFlag(renew,teamCode);
                signFamilyRenewDao.save(renew);
                setMessState(mesId);
                //1.3.3.2 加入统计日志
                if ("1".equals(state)) {
                   setRenewLog(renew);
                }
                //发送微信模板消息
@ -1252,6 +1369,9 @@ public class SignWebService extends BaseService {
                    }
                }
                renew.setApplyDate(new Date());
                //1.3.3.4 根据团队设置标识
                setRenewFlag(renew,teamCode);
                signFamilyDao.save(renew);
                //消息设为已读
                setMessState(mesId);
@ -1268,6 +1388,7 @@ public class SignWebService extends BaseService {
                data.put("doctor", dotorCode);
                data.put("toUser", patientCode);
                data.put("toName", renew.getName());
                data.put("isRenew","1");//表示为续签操作
                Patient patient = patientService.findByCode(renew.getPatient());
                if (patient != null && StringUtils.isNotBlank(patient.getOpenid())) {
@ -1603,7 +1724,7 @@ public class SignWebService extends BaseService {
        //统计当年咨询数量
        String consult_sql = "select count(1) as count from wlyy_consult_team  w where w.doctor = ? and w.patient =? and YEAR(w.czrq) = ? ";
        //统计随访数量
        String followup_sql = "select count(1) as count from wlyy_followup  w where (w.doctor_code = ? or w.doctor_code =?) and w.patient_code =? and YEAR(w.create_time) = ?  and w.followup_class is not null ";
        String followup_sql = "select count(1) as count from wlyy_followup  w where (w.doctor_code = ? or w.doctor_code =?) and w.patient_code =? and YEAR(w.create_time) = ? ";
        //统计待预约数量
        String reservation_sql = "select count(1) as count from wlyy_patient_reservation  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        //统计健康教育数量
@ -1867,7 +1988,7 @@ public class SignWebService extends BaseService {
        hdmb.setDel("1");
        hdmb.setCzrq(new Date());
        hdmb.setTeam(team.getCode());
        hdmb.setType(hd.getLevel());
        hdmb.setType(3);
        hdmb.setSignType("2");
        //新增团队成员
        doctorTeamMemberDao.save(hdmb);
@ -1898,4 +2019,50 @@ public class SignWebService extends BaseService {
        }
        return new JSONObject();
    }
    public void setRenewFlag(SignFamily renew,Long teamCode){
        if(teamCode==null){
            return ;
        }
        String sql = "SELECT * FROM wlyy_sign_family f WHERE f.patient ='"+renew.getPatient()+"' AND (f.`status` =-4 OR f.`status`>0) AND f.expenses_status ='1' AND f.sign_year >='"+(Integer.parseInt(renew.getSignYear())-1)+"' ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        Map<String,Object> sign = null;
        if(list!=null&&list.size()>0){
            sign = list.get(0);
        }
        Integer i = (Integer)sign.get("admin_team_code");
        Long id = i.longValue();
        if(id==null){
            renew.setRenewFlag("2");
        }else{
            if(id==teamCode){
                renew.setRenewFlag("1");
            }else{
                renew.setRenewFlag("2");
            }
        }
    }
    public void setRenewFlag(SignFamilyRenew renew,Long teamCode){
        if(teamCode==null){
            return ;
        }
        String sql = "SELECT * FROM wlyy_sign_family f WHERE f.patient ='"+renew.getPatient()+"' AND (f.`status` =-4 OR f.`status`>0) AND f.expenses_status ='1' AND f.sign_year >='"+(Integer.parseInt(renew.getSignYear())-1)+"' ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        Map<String,Object> sign = null;
        if(list!=null&&list.size()>0){
            sign = list.get(0);
        }
        Integer i = (Integer)sign.get("admin_team_code");
        Long id = i.longValue();
        if(id==null){
            renew.setRenewFlag("2");
        }else{
            if(id==teamCode){
                renew.setRenewFlag("1");
            }else{
                renew.setRenewFlag("2");
            }
        }
    }
}

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

@ -2204,18 +2204,18 @@ public class StatisticsService extends BaseService {
     * @return
     */
    public Map<String, Object> getConsultByteam(Long id, String startDate, String endDate) {
         String imDataBaseName = SystemConf.getInstance().getImDataBaseName();
//        startDate = startDate + " 00:00:00";
//        endDate = endDate + " 23:59:59";
        //咨询量
        String consult_sql = "SELECT " +
                "  COUNT(1) consultCount " +
                "  FROM " +
                "  im_new.Topics t, " +
                "  im_new.Participants p, " +
                "  im_new.Doctors d, " +
                "  "+imDataBaseName+".Topics t, " +
                "  "+imDataBaseName+".Participants p, " +
                "  "+imDataBaseName+".Doctors d, " +
                "  Wlyy_Consult_Team c, " +
                "  im_new.Patients s " +
                "  "+imDataBaseName+".Patients s " +
                "  WHERE " +
                "  d.id = p.participant_id " +
                " AND c.consult = t.id " +
@ -2275,7 +2275,7 @@ public class StatisticsService extends BaseService {
//        startDate = startDate + " 00:00:00";
//        endDate = endDate + " 23:59:59";
        //随访数目
        String followup_sql = "SELECT COUNT(1) AS followupCount from wlyy_followup w WHERE w.admin_team_code=" + id + " AND  w.create_time >='" + startDate + "' AND w.create_time<='" + endDate + "' AND w.followup_class IS NOT NULL ";
        String followup_sql = "SELECT COUNT(1) AS followupCount from wlyy_followup w WHERE w.admin_team_code=" + id + " AND  w.create_time >='" + startDate + "' AND w.create_time<='" + endDate + "' ";
        //随访数目
        Map<String, Object> followupCout = jdbcTemplate.queryForMap(followup_sql);
        if (followupCout.get("followupCount") == null) {
@ -2406,11 +2406,11 @@ public class StatisticsService extends BaseService {
                    "  (DATE_FORMAT(t.create_time, '%v') - DATE_FORMAT('"+startDate+"', '%v') + 1) AS weekOfMonth, " +
                    "  COUNT(1) AS noRely " +
                    "  FROM " +
                    "  im_new.Topics t, " +
                    "  im_new.Participants p, " +
                    "  im_new.Doctors d, " +
                    "  "+imDataBaseName+".Topics t, " +
                    "  "+imDataBaseName+".Participants p, " +
                    "  "+imDataBaseName+".Doctors d, " +
                    "  Wlyy_Consult_Team c, " +
                    "  im_new.Patients s " +
                    "  "+imDataBaseName+".Patients s " +
                    "  WHERE " +
                    "  d.id = p.participant_id " +
                    "  AND c.consult = t.id " +
@ -2426,11 +2426,11 @@ public class StatisticsService extends BaseService {
                    "  (DATE_FORMAT(t.create_time, '%v') - DATE_FORMAT('"+startDate+"', '%v') + 1) AS weekOfMonth, " +
                    "  COUNT(1) AS total " +
                    "  FROM " +
                    "  im_new.Topics t, " +
                    "  im_new.Participants p, " +
                    "  im_new.Doctors d, " +
                    "  "+imDataBaseName+".Topics t, " +
                    "  "+imDataBaseName+".Participants p, " +
                    "  "+imDataBaseName+".Doctors d, " +
                    "  Wlyy_Consult_Team c, " +
                    "  im_new.Patients s " +
                    "  "+imDataBaseName+".Patients s " +
                    "  WHERE " +
                    "  d.id = p.participant_id " +
                    "  AND c.consult = t.id " +
@ -2513,11 +2513,11 @@ public class StatisticsService extends BaseService {
                    "  (DATE_FORMAT(t.create_time, '%v') - DATE_FORMAT('"+startDate+"', '%v') + 1) AS weekOfMonth, " +
                    "  COUNT(1) AS noRely " +
                    "  FROM " +
                    "  im_new.Topics t, " +
                    "  im_new.Participants p, " +
                    "  im_new.Doctors d, " +
                    "  "+imDataBaseName+".Topics t, " +
                    "  "+imDataBaseName+".Participants p, " +
                    "  "+imDataBaseName+".Doctors d, " +
                    "  Wlyy_Consult_Team c, " +
                    "  im_new.Patients s " +
                    "  "+imDataBaseName+".Patients s " +
                    "  WHERE " +
                    "  d.id = p.participant_id " +
                    "  AND c.consult = t.id " +
@ -2534,11 +2534,11 @@ public class StatisticsService extends BaseService {
                    "  (DATE_FORMAT(t.create_time, '%v') - DATE_FORMAT('"+startDate+"', '%v') + 1) AS weekOfMonth, " +
                    "  COUNT(1) AS total " +
                    "  FROM " +
                    "  im_new.Topics t, " +
                    "  im_new.Participants p, " +
                    "  im_new.Doctors d, " +
                    "  "+imDataBaseName+".Topics t, " +
                    "  "+imDataBaseName+".Participants p, " +
                    "  "+imDataBaseName+".Doctors d, " +
                    "  Wlyy_Consult_Team c, " +
                    "  im_new.Patients s " +
                    "  "+imDataBaseName+".Patients s " +
                    "  WHERE " +
                    "  d.id = p.participant_id " +
                    "  AND c.consult = t.id " +
@ -2917,7 +2917,6 @@ public class StatisticsService extends BaseService {
                    " AND w.doctor_code ='" + doctor + "'" +
                    " AND w.create_time >= '" + startDate + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.followup_class IS NOT NULL " +
                    " GROUP BY dateNo";
            planSQL = "SELECT " +
@ -2930,7 +2929,6 @@ public class StatisticsService extends BaseService {
                    " AND w.create_time >= '" + startDate + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.status ='2'" +
                    " AND w.followup_class IS NOT NULL " +
                    " GROUP BY dateNo";
        } else {
            //按月
@ -2945,7 +2943,6 @@ public class StatisticsService extends BaseService {
                    " AND w.doctor_code ='" + doctor + "'" +
                    " AND w.create_time >= '" + startDate + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.followup_class IS NOT NULL " +
                    " GROUP BY weekOfMonth";
            planSQL = "SELECT " +
                    " ( " +
@ -2959,7 +2956,6 @@ public class StatisticsService extends BaseService {
                    " AND w.create_time >= '" + startDate + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.status ='2'" +
                    " AND w.followup_class IS NOT NULL " +
                    " GROUP BY weekOfMonth";
        }
        List<Map<String, Object>> totalList = jdbcTemplate.queryForList(totalSQL);
@ -2985,7 +2981,6 @@ public class StatisticsService extends BaseService {
                    " w.admin_team_code =" + teamCode +
                    " AND w.create_time >= '" + startDate + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.followup_class IS NOT NULL " +
                    " GROUP BY dateNo";
            planSQL = "SELECT " +
@ -2999,7 +2994,6 @@ public class StatisticsService extends BaseService {
                    " AND w.create_time >= '" + startDate + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.status ='2'" +
                    " AND w.followup_class IS NOT NULL " +
                    " GROUP BY weekOfMonth";
        } else {
            //按月
@ -3013,7 +3007,6 @@ public class StatisticsService extends BaseService {
                    " w.admin_team_code =" + teamCode +
                    " AND w.create_time >= '" + startDate + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.followup_class IS NOT NULL " +
                    " GROUP BY weekOfMonth";
            planSQL = "SELECT " +
                    " ( " +
@ -3026,7 +3019,6 @@ public class StatisticsService extends BaseService {
                    " AND w.create_time >= '" + startDate + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.status ='2'" +
                    " AND w.followup_class IS NOT NULL " +
                    " GROUP BY weekOfMonth";
        }
        List<Map<String, Object>> totalList = jdbcTemplate.queryForList(totalSQL);
@ -3056,7 +3048,6 @@ public class StatisticsService extends BaseService {
                " WHERE " +
                " w.admin_team_code =" + teamCode +
                " AND w.create_time <= '" + endDate + "' " +
                " AND w.followup_class IS NOT NULL " +
                " GROUP BY " +
                "  w.doctor_code " +
                " ) c ON c.doctor_code =m.doctor_code, " +
@ -3088,7 +3079,6 @@ public class StatisticsService extends BaseService {
                " w.admin_team_code =" + teamCode +
                " AND w.create_time >= '" + startDate + "' " +
                " AND w.create_time <= '" + endDate + "' " +
                " AND w.followup_class IS NOT NULL " +
                " GROUP BY " +
                "  w.doctor_code " +
                " ) c ON c.doctor_code =m.doctor_code, " +
@ -3121,7 +3111,6 @@ public class StatisticsService extends BaseService {
                " AND w.create_time >= '" + startDate + "' " +
                " AND w.create_time <= '" + endDate + "' " +
                " AND w.status ='2'" +
                " AND w.followup_class IS NOT NULL " +
                " GROUP BY " +
                "  w.doctor_code " +
                " ) c ON c.doctor_code =m.doctor_code, " +
@ -3257,8 +3246,7 @@ public class StatisticsService extends BaseService {
                " WHERE " +
                " w.admin_team_code =" + teamCode +
                " AND w.doctor_code ='" + doctor + "' " +
                " AND w.create_time <= '" + endDate + "' " +
                " AND w.followup_class IS NOT NULL";
                " AND w.create_time <= '" + endDate + "' ";
        String addSql = "SELECT " +
                " COUNT(1) AS addCount " +
                " FROM " +
@ -3267,8 +3255,7 @@ public class StatisticsService extends BaseService {
                " w.admin_team_code =" + teamCode +
                " AND w.doctor_code ='" + doctor + "' " +
                " AND w.create_time >= '" + startDate + "' " +
                " AND w.create_time <= '" + endDate + "' " +
                " AND w.followup_class IS NOT NULL";
                " AND w.create_time <= '" + endDate + "' ";
        String planSql = "SELECT " +
                " COUNT(1) AS planCount " +
                " FROM " +
@ -3278,8 +3265,7 @@ public class StatisticsService extends BaseService {
                " AND w.doctor_code ='" + doctor + "' " +
                " AND w.create_time >= '" + startDate + "' " +
                " AND w.create_time <= '" + endDate + "' " +
                " AND w.status ='2'" +
                " AND w.followup_class IS NOT NULL";
                " AND w.status ='2'";
        JSONObject rs = new JSONObject();
        List<Map<String, Object>> totalList = jdbcTemplate.queryForList(totalSql);
@ -4422,7 +4408,7 @@ public class StatisticsService extends BaseService {
        Integer coutYear = Integer.parseInt(year)+1;
        //及时回复数
        JSONArray rely = getQuotaList(level,lowlevel,area,coutYear,23);
         JSONArray rely = getQuotaList(level,lowlevel,area,coutYear,23);
        if(rely==null){
            return null;
        }
@ -4579,23 +4565,23 @@ public class StatisticsService extends BaseService {
                //市 区
                sql =" SELECT t.result As num,t.town_name AS name,t.town AS code,t.create_time AS date" +
                        " FROM wlyy_quota_result t " +
                        " WHERE t.city ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='3'AND LEFT(t.create_time,10)='"+year+"-06-30'";
                        " WHERE t.city ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='3'AND t.quota_date='"+year+"-06-30'";
            }else{
                //市 机构
                sql = "SELECT t.result As num,t.org_name AS name,t.org_code AS code,t.create_time AS date" +
                        " FROM wlyy_quota_result t " +
                        " WHERE t.city ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='2' AND LEFT(t.create_time,10)='"+year+"-06-30'";
                        " WHERE t.city ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='2' AND t.quota_date='"+year+"-06-30'";
            }
        }else if (level ==3){
            //区 机构
            sql = "SELECT t.result As num,t.org_name AS name,t.org_code AS code,t.create_time AS date " +
                    "FROM wlyy_quota_result t " +
                    "WHERE t.town ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='2' AND LEFT(t.create_time,10)='"+year+"-06-30'";
                    "WHERE t.town ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='2' AND t.quota_date='"+year+"-06-30'";
        }else{
            //机构 团队
            sql ="SELECT t.result As num,t.qkdoctor_name AS name,t.qkdoctor_code AS code,t.create_time AS date " +
                    " FROM wlyy_quota_result t " +
                    " WHERE t.org_code ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='1' AND LEFT(t.create_time,10)='"+year+"-06-30'";
                    " WHERE t.org_code ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='1' AND t.quota_date='"+year+"-06-30'";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list!=null&&list.size()>0){

文件差異過大導致無法顯示
+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java


+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/common/Configure.java

@ -18,7 +18,7 @@ public class Configure {
	private String bindCardType = "onepay.sicard.bind.info";
	private String chargeType = "onepay.trade.medical.charge";
	private String chargeQueryType = "onepay.trade.medical.charge.query";
	private String createSicardType = "";
	private String createSicardType = "onepay.sicard.createurl";
	public String getOnepayApi() {
		return onepayApi;

+ 10 - 11
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java

@ -105,7 +105,7 @@ public class OnePayService {
            // 请求报文体参数,详见接口文档各接口——请求参数定义
            // 如医保绑卡信息请求参数
            JSONObject params = new JSONObject();
            params.put("userId", openid);
            params.put("openId", openid);
            params.put("accId", SystemConf.getInstance().getAppId());  //微信公众号开发者ID
            requestParams.setParam(params);
            requestParams.setTransType(config.getBindCardType());
@ -187,14 +187,6 @@ public class OnePayService {
        charge.setPatient(patient);     //  用户
        charge.setOpenid(openid);     //  用戶微信openid
        try {
            BindCard card= bindCard(openid);
            String name = card.getUserName();
            String ssc = card.getCardNo();
            String idType = card.getIdType();
            String idNo = card.getIdNo();
            charge.setName(name);
            charge.setIdType(idType);
            charge.setIdNo(idNo);
            charge.setHospital(orgCode);
            charge.setHospitalName(orgName);
            charge.setChannel(channel);
@ -205,7 +197,14 @@ public class OnePayService {
            charge.setInsuranceAmount(insuranceAmount);  //  医保支付金额
            charge.setFeeDetail(feeDetail);  //  费用明细
            BindCard card= bindCard(openid);
            String name = card.getUserName();
            String ssc = card.getCardNo();
            String idType = card.getIdType();
            String idNo = card.getIdNo();
            charge.setName(name);
            charge.setIdType(idType);
            charge.setIdNo(idNo);
            SimpleDateFormat formatter =   new SimpleDateFormat("yyyyMMddHHmmss");
            String currentDateTime = formatter.format(now);
@ -372,7 +371,7 @@ public class OnePayService {
            // 请求报文体参数,详见接口文档各接口——请求参数定义
            // 如医保绑卡信息请求参数
            JSONObject params = new JSONObject();
            params.put("userId", openid);
            params.put("openId", openid);
            params.put("accId", SystemConf.getInstance().getAppId());  //微信公众号开发者ID
            requestParams.setParam(params);
            requestParams.setTransType(config.getCreateSicardType());

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

@ -460,6 +460,8 @@ public class SignPatientLabelInfoController extends BaseController {
        }
    }
    @RequestMapping(value = "/patient_search_all", method = RequestMethod.GET)
    @ApiOperation("根据姓名搜索所有团队下居民(根据团队和当前医生)")
    public String searchPatients(@RequestParam(required = true) String filter,

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

@ -227,7 +227,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            //修改年度服务类型1.3.4需求
            if("1".equals(labelType)){
                JSONObject  rs =  familyContractService.getServerPatientList(teamCode);
                JSONObject  rs =  familyContractService.getServerPatientListNum(teamCode,level,oldDoctorCode);
                return write(200, "查询成功!", "data", rs);
            }

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

@ -482,11 +482,13 @@ public class DoctorSignController extends WeixinBaseController {
                rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode,health,disease,custom,sevId,healthDoctor,teamCode,expenses);
//            int rs =signWebService.agreeRenew(getAccessToken(),"test00000000005",patient,state);
            }else{
                rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode,health,disease,custom,sevId,healthDoctor,teamCode,expenses);
                //如果没有续签记录,走签约记录
                if(rs!=0){
                    rs =signWebService.agreeRenewOverDue(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode,health,disease,custom,sevId,healthDoctor,teamCode,expenses);
                }
//                rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode,health,disease,custom,sevId,healthDoctor,teamCode,expenses);
//                //如果没有续签记录,走签约记录
//                if(rs!=0){
//                    rs =signWebService.agreeRenewOverDue(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode,health,disease,custom,sevId,healthDoctor,teamCode,expenses);
//                }
                rs =signWebService.agreeRenewOverDue(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode,health,disease,custom,sevId,healthDoctor,teamCode,expenses);
            }
            if(rs != 1){
                //设置代码为已读

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

@ -103,6 +103,9 @@ public class ConsultController extends WeixinBaseController {
                    json.put("evaluate", result[9]);
                    //签约code
                    json.put("signCode", result[10]);
                    array.put(json);
                }
            }

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

@ -567,6 +567,29 @@ public class FamilyContractController extends BaseController {
        }
    }
    @RequestMapping(value = "unsignRenew")
    @ResponseBody
    public String unsignRenew(
            String doctor,
            @RequestParam(required = false) String patientCode
    ) {
        try {
            patientCode = StringUtils.isNoneBlank(patientCode) ? patientCode : getRepUID();
//            patientCode = StringUtils.isNoneBlank(patientCode) ? patientCode : getUID();
            int res = familyContractService.unsignRenew(patientCode, doctor);
            if (res == -1) {
                return error(-1, "取消签约失败!");
            } else if (res == 200) {
                return success("签约申请已取消!");
            } else {
                return error(-1, "签约状态已变化,无法申请取消签约!");
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "取消签约失败!");
        }
    }
    /**
     * 申请解约
     *

+ 16 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/PatientSignController.java

@ -4,6 +4,7 @@ import com.yihu.wlyy.entity.patient.SignWeb;
import com.yihu.wlyy.service.app.sign.SignWebService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -261,6 +262,21 @@ public class PatientSignController extends BaseController {
		}
	}
	@RequestMapping(value = "/consult_sign_doctor_info")
	@ResponseBody
	@ApiOperation(value = "获取咨询的服务团队")
	public String consult_sign_doctor(@RequestParam(required = true,value = "team")String teamCode,
									  @RequestParam(required = true)String code,@RequestParam(required = true)String consultCode){
		try{
			JSONObject resultObj =  signWebService.getConsultSignInfoOrRenewInfo(teamCode,code,getRepUID(),consultCode);
			return write(200, "查询成功!", "data", resultObj);
		}catch (Exception e){
			error(e);
			return error(-1, "签约状态查询失败!");
		}
	}
	@RequestMapping("/sign_service_info")
	public String getSignServiceInfo(@RequestParam(required = true,value = "team")String teamCode) {
		try {

+ 4 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/survey/PatientQuestionnaireController.java

@ -5,12 +5,9 @@ import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@ -33,7 +30,8 @@ public class PatientQuestionnaireController extends BaseController {
            @ApiParam(value = "问卷编码")
            @RequestParam String id) {
        try {
            String patient = getUID();
            String patient = getRepUID();
//            String patient = getUID();
            JSONObject jsonObject = patientQuestionnaireService.getSurveySummary(patient, id);
            return write(200, "查询成功!", "data", jsonObject);
        } catch (Exception e) {
@ -65,7 +63,8 @@ public class PatientQuestionnaireController extends BaseController {
    public String saveAnswer(
            @RequestParam String jsonData) {
        try {
            String patient = getUID();
            String patient = getRepUID();
//            String patient = getUID();
            JSONObject json = new JSONObject(jsonData);
            patientQuestionnaireService.saveAnswer(patient, json);
            return write(200, "保存成功!");

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

@ -44,7 +44,7 @@ public class OnePayController extends WeixinBaseController {
    @ResponseBody
    public String bindCard() throws Exception {
        try {
            BindCard bindCard = pay.bindCard("patient","ohNH9sh4uwuJCxIwcLJtGTX-BaSk");         //ohNH9sh4uwuJCxIwcLJtGTX-BaSk  //o4Ma2t5665rS7uNfA9EF-VnOJx30      getUID()getOpenid()
            BindCard bindCard = pay.bindCard("915cc456-5b1d-11e6-8344-fa163e8aee56","o4Ma2t5665rS7uNfA9EF-VnOJx30");         //ohNH9sh4uwuJCxIwcLJtGTX-BaSk  //o4Ma2t5665rS7uNfA9EF-VnOJx30      getUID()getOpenid()
            return write(200, "查询绑卡信息成功!","data",bindCard);
        }
        catch (Exception e)
@ -72,7 +72,7 @@ public class OnePayController extends WeixinBaseController {
                         @ApiParam(name="feeDetail",value="费用明细",defaultValue = "[{\"itemName\":\"家庭医生签约支付\",\"itemDesc\":\"家庭医生签约支付\",\"itemOrigPrice\":\"1\",\"itemNowPrice\":\"1\",\"itemNum\":\"1\",\"itemTotalAmt\":\"1\"}]")
                         @RequestParam String feeDetail) throws Exception {
        try {
            String settleNo = pay.charge(orgCode,chargeType,chargeRelation,totalAmount, selfpayAmount, insuranceAmount, feeDetail,"patient","ohNH9sh4uwuJCxIwcLJtGTX-BaSk");  //ohNH9sh4uwuJCxIwcLJtGTX-BaSk    getUID(),getOpenid()
            String settleNo = pay.charge(orgCode,chargeType,chargeRelation,totalAmount, selfpayAmount, insuranceAmount, feeDetail,"915cc456-5b1d-11e6-8344-fa163e8aee56","o4Ma2t5665rS7uNfA9EF-VnOJx30");  //ohNH9sh4uwuJCxIwcLJtGTX-BaSk    getUID(),getOpenid()
            return write(200, "家庭医生签约支付成功!","data",settleNo);
        }
        catch (Exception e)
@ -102,7 +102,7 @@ public class OnePayController extends WeixinBaseController {
    @ResponseBody
    public String createSicard() throws Exception {
        try {
            String sicardUrl = pay.createSicard("patient","ohNH9sh4uwuJCxIwcLJtGTX-BaSk");         //ohNH9sh4uwuJCxIwcLJtGTX-BaSk  //o4Ma2t5665rS7uNfA9EF-VnOJx30  getUID(),getOpenid()
            String sicardUrl = pay.createSicard("915cc456-5b1d-11e6-8344-fa163e8aee56","o4Ma2t5665rS7uNfA9EF-VnOJx30");         //ohNH9sh4uwuJCxIwcLJtGTX-BaSk  //o4Ma2t5665rS7uNfA9EF-VnOJx30  getUID(),getOpenid()
            return write(200, "生成电子社保卡成功!","data",sicardUrl);
        }
        catch (Exception e)