ソースを参照

定期体检 参数类型

wujunjie 7 年 前
コミット
2d030e41bc

+ 7 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java

@ -14,6 +14,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.patient.Patient;
import java.util.Date;
import java.util.List;
public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
@ -67,4 +68,10 @@ public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
    @Query(value=" select p.* from wlyy_patient p LEFT JOIN wlyy_sign_family s on s.patient = p.code WHERE s.status > 0  and p.disease >0 and p.status>0 and s.admin_team_code = ?1 and (s.doctor = ?2 or s.doctor_health =?2)",nativeQuery = true)
    List<Patient> findAllSignPatientTeamcode(String teamcode, String  doctorcode);
    @Query(value="SELECT DISTINCT t.*FROM wlyy_sign_family t1,wlyy_patient t WHERE t.`code`=t1.patient AND t1.STATUS>0 AND " +
            " t1.admin_team_code= ?1 AND(YEAR(curdate())-IF(length(t.idcard)=18,substring(t.idcard,7,4),IF(length(t.idcard)=15,concat('19',substring(t.idcard,7,2)),NULL)))>65 " +
            " AND t1.idcard NOT IN(SELECT DISTINCT s.idcard FROM wlyy_sign_family s,wlyy_old_people_physical_examination o WHERE s.admin_team_code=?1 AND s.`status`>0 AND s.idcard=o.id_card " +
            " AND o.medical_time>?2 )ORDER BY t1.openid DESC,CONVERT(t1.NAME USING gbk)",nativeQuery = true)
    List<Patient> findExaminationRemind(long teamcode, Date medicalTime);
}

+ 39 - 36
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PhysicalExaminationRemindService.java

@ -14,10 +14,12 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
 * Created by Reece on 2017/10/19/019.
@ -96,7 +98,8 @@ public class PhysicalExaminationRemindService extends BaseService {
     * @param doctName 医生姓名
     * @return
     */
    public void sendBatchNotice(String teamId, String doctName) throws Exception {
    @Async
    public void sendBatchNotice(long teamId, String doctName) throws Exception {
        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
        String accessToken = accessTokenUtils.getAccessToken();
        // 推送消息给微信端
@ -107,41 +110,41 @@ public class PhysicalExaminationRemindService extends BaseService {
        json.put("url", "");
        json.put("remark", "为了您和您的家庭医生了解您近期的健康状况,请及时到您签约的社区体检哟~");
        String sql = "SELECT DISTINCT\n" +
                "\tt1.*\n" +
                "FROM\n" +
                "\twlyy_sign_family t1\n" +
                "WHERE\n" +
                "\tt1. STATUS > 0\n" +
                "AND t1.admin_team_code = 485\n" +
                "AND (\n" +
                "\tYEAR (curdate()) -\n" +
                "\tIF (\n" +
                "\t\tlength(idcard) = 18,\n" +
                "\t\tsubstring(idcard, 7, 4),\n" +
                "\n" +
                "\tIF (\n" +
                "\t\tlength(idcard) = 15,\n" +
                "\t\tconcat('19', substring(idcard, 7, 2)),\n" +
                "\t\tNULL\n" +
                "\t)\n" +
                "\t)\n" +
                ") > 65\n" +
                "AND t1.idcard NOT IN (\n" +
                "\tSELECT DISTINCT\n" +
                "\t\ts.idcard\n" +
                "\tFROM\n" +
                "\t\twlyy_sign_family s,\n" +
                "\t\twlyy_old_people_physical_examination o\n" +
                "\tWHERE\n" +
                "\t\ts.admin_team_code =485\n" +
                "\tAND s.`status` > 0\n" +
                "\tAND s.idcard = o.id_card\n" +
                "\tAND o.medical_time >'2016-10-19 15:12:11'\n" +
                ")\n" +
                "ORDER BY\n" +
                "\tt1.openid DESC,\n" +
                "\tCONVERT (t1. NAME USING gbk)";
        String sql = "SELECT DISTINCT " +
                " t1.* " +
                " FROM" +
                " wlyy_sign_family t1 " +
                " WHERE " +
                " t1. STATUS > 0 " +
                " AND t1.admin_team_code = 485 " +
                " AND ( " +
                " YEAR (curdate()) - " +
                " IF ( " +
                " length(idcard) = 18, " +
                " substring(idcard, 7, 4), " +
                " IF ( " +
                " length(idcard) = 15, " +
                " concat('19', substring(idcard, 7, 2)), " +
                " NULL " +
                " ) " +
                " ) " +
                " ) > 65 " +
                " AND t1.idcard NOT IN ( " +
                " SELECT DISTINCT " +
                " s.idcard " +
                " FROM " +
                " wlyy_sign_family s, " +
                " wlyy_old_people_physical_examination o " +
                " WHERE " +
                " s.admin_team_code =485 " +
                " AND s.`status` > 0 " +
                " AND s.idcard = o.id_card " +
                " AND o.medical_time >'2016-10-19 15:12:11' " +
                " )" +
                " ORDER BY " +
                " t1.openid DESC, " +
                " CONVERT (t1. NAME USING gbk)";
        List<Patient>patients = patientDao.findExaminationRemind(485,new Date());
        Patient patient = patientDao.findByCode("");
        if (StringUtils.isNotBlank(patient.getOpenid())) {
            pushMsgTask.putWxMsg(accessToken, 11, patient.getOpenid(), patient.getName(), json);