trick9191 8 년 전
부모
커밋
2dfaa9c3f2

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

@ -286,6 +286,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.patient = ?1 and a.type =2 and a.status >= 0")
    List<SignFamily> findByPatients(String patient);
    @Query("select a from SignFamily a where a.idcard = ?1 and a.type = 1 and a.status >= 0")
    SignFamily findBySanshiIdcard(String idcard);

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

@ -4,9 +4,11 @@ import java.util.*;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SignFamilyRenewDao;
import com.yihu.wlyy.service.app.team.AdminTeamService;
@ -62,7 +64,6 @@ public class SignWebService extends BaseService {
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private SignFamilyRenewDao signFamilyRenewDao;
    /**
     * 根据医生代码及签约状态编码 获取该医生签约患者的信息列表
     *
@ -954,4 +955,80 @@ public class SignWebService extends BaseService {
        json.put("result",rs);
        return json;
    }
    /**
     * 统计
     * 咨询量、获取待预约、获取健康教育、获取健康指导
     * @param patient
     * @return
     */
    public JSONObject getSignCountInfoInYear(String patient){
        JSONObject rs = new JSONObject();
        List<SignFamily> signFamilys = signFamilyDao.findByPatients(patient);
        if(signFamilys==null||signFamilys.size()==0){
            throw new RuntimeException("找不到签约关系!");
        }
        SignFamily signFamily = signFamilys.get(0);
        String doctors_sql = "";
        if(StringUtils.isNotBlank(signFamily.getTeamCode())){
          doctors_sql = "SELECT t.member_code member,t.name FROM wlyy_doctor_team_member t WHERE t.team ='"+signFamily.getTeamCode()+"' AND t.type <>5";
        }else{
            throw new RuntimeException("找不到团队关系!");
        }
        List<Map<String,Object>> doctors = jdbcTemplate.queryForList(doctors_sql);
        String doctorCodeSql = "";
        if (doctors!=null&&doctors.size()>0){
            for(int i=0;i<doctors.size();i++){
                Map<String,Object> doctor = doctors.get(i);
                if(i==0){
                    doctorCodeSql = (String)doctor.get("member");
                }else{
                    doctorCodeSql +=","+(String)doctor.get("member");
                }
            }
        }
        Calendar cal = Calendar.getInstance();
        int year = cal.get(Calendar.YEAR);
        //咨询量
        String consult_sql = "SELECT COUNT(1) AS consultCount,d.doctorName FROM wlyy_consult_team t,wlyy_doctor d WHERE t.doctor = d.code AND t.patient ='"+patient+"' " +
                "AND t.czrq <='"+year+"-07-01' AND t.czrq >='"+(year-1)+"-07-01' GROUP BY t.doctor DESC ";
        //获取待预约
        String reservation_sql = "SELECT COUNT(1) AS reservationCount FROM wlyy_patient_reservation  w " +
                " WHERE w.doctor in("+doctorCodeSql+") AND w.patient ='"+patient+"'" +
                " AND t.czrq <='"+year+"-07-01' AND t.czrq >='"+(year-1)+"-07-01'  ";
        //获取健康教育
        String article_sql = "SELECT COUNT(1) AS articleCount FROM wlyy_health_edu_article_patient  w,wlyy_health_edu_article w2 WHERE w.article = w2.code " +
                "AND  w.doctor IN("+doctorCodeSql+") AND w.patient ='"+patient+"' " +
                "AND t.czrq <='"+year+"-07-01' AND t.czrq >='"+(year-1)+"-07-01'  ";
        //获取健康指导
        String guidance_sql = "SELECT COUNT(1) AS guidanceCount  FROM wlyy_patient_health_guidance  w " +
                "WHERE w.doctor IN("+doctorCodeSql+") and w.patient ='"+patient+"' and AND t.czrq <='"+year+"-07-01' AND t.czrq >='"+(year-1)+"-07-01'  ";
        //咨询量
        List<Map<String, Object>> consultResult = jdbcTemplate.queryForList(consult_sql);
        //待预约量
        List<Map<String, Object>> reservationResult = jdbcTemplate.queryForList(reservation_sql);
        //健康教育量
        List<Map<String, Object>> articleResult = jdbcTemplate.queryForList(article_sql);
        //健康指导量
        List<Map<String, Object>> guidanceResult = jdbcTemplate.queryForList(guidance_sql);
        Long consultTotal = 0L;
        if(consultResult!=null&&consultResult.size()>0){
            for(Map<String,Object> map :consultResult){
                Long c = (Long)map.get("consultCount");
                consultTotal+=c;
            }
        }
        rs.put("consultTotal",consultTotal);
        rs.put("consultResult",consultResult);
        rs.put("doctors",doctors);
        rs.put("reservationResult",reservationResult);
        rs.put("articleResult",articleResult);
        rs.put("guidanceResult",guidanceResult);
        return rs;
    }
}