Explorar el Código

同步医疗保险号为空的居民签约信息

humingfen hace 7 años
padre
commit
a2c38510a1

+ 9 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -245,6 +245,15 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
            new Thread(redisThread).start();
            logger.info("redis message end");
            //慢病患者医疗保险号同步,每天6点执行一次
            if (!quartzHelper.isExistJob("patient_medicare_number_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("patient_medicare_number_job");
                quartzHelper.addJob(PatientMedicareNumberJob.class, trigger, "patient_medicare_number_job", new HashMap<String, Object>());
                logger.info("patient_medicare_number_job  job success");
            } else {
                logger.info("patient_medicare_number_job  job exist");
            }
        } catch (Exception e) {
            logger.info("sign end job start failed");
        }

+ 34 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PatientMedicareNumberJob.java

@ -0,0 +1,34 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.service.third.jw.JwPatientMedicareNumberService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * 慢病患者医疗保险号同步JOB
 * @author humingfen
 * @date 2018/5/22
 */
public class PatientMedicareNumberJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(PatientMedicareNumberJob.class);
    @Autowired
    private JwPatientMedicareNumberService jwPatientMedicareNumberService;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException
    {
        logger.info("START=====开始更新慢病患者医疗保险号的JOB");
        try {
            jwPatientMedicareNumberService.getEffectiveSignFamily();
        }catch (Exception e) {
            e.printStackTrace();
            logger.info("END===ERROR===开始更新慢病混着医疗保险号JOB,message:" +
                    e.getMessage());
        }
    }
}

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

@ -79,4 +79,13 @@ public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
    @Query(value = "SELECT DISTINCT openid FROM `wlyy_patient` WHERE `openid` IS NOT NULL AND `openid` <> ' ' AND `openid` <> 'undefined' " +
            " AND `sicard_status` IS NULL AND `sicard_time` >= ?1 ORDER BY `sicard_time`",nativeQuery = true)
    List<String> listNotupdatedByDate(String beginTime);
    //根据患者身份证和医疗保险号获取身份证
    @Query("select p.idcard from Patient p where p.medicareNumber is null and p.idcard in (?1)")
    List<String> findIdcardByMedicareNumber(List<String> idcards);
    //根据患者身份证号更新患者医疗保险号
    @Modifying
    @Query("update Patient p set p.medicareNumber = ?2 where p.idcard = ?1")
    void updatePatientMedicareNumberByIdcard(String idcard, String medicareNumber);
}

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

@ -431,4 +431,7 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    @Query(value = "SELECT f.* FROM wlyy_sign_family f WHERE f.idcard = ?1 and f.`status` = -4 ORDER BY sign_year desc LIMIT 0,1 ",nativeQuery = true)
    SignFamily findLatelyRenew(String idcard);
    //根据签约类型、签约状态、扣费状态查找居民身份证信息
    @Query("select a.idcard from SignFamily a where (a.type = 2 or a.type = 1) and a.status = 1 and a.expensesStatus = 1 ")
    List<String> findIdcardByStatus();
}

+ 28 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -1138,4 +1138,32 @@ public class PatientService extends TokenService {
        }
        return "1";
    }
    /**
     * 根据患者身份证号更新患者医疗保险号情况
     * @param idcard_medicare_number_map
     */
    @Transactional
    public void updatePatientMedicareNumberByIdcard(HashMap<String, String> idcard_medicare_number_map){
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
        TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
        try {
            for (String idcard : idcard_medicare_number_map.keySet()) {
                patientDao.updatePatientMedicareNumberByIdcard(idcard,idcard_medicare_number_map.get(idcard));
            }
            //事务提交
            transactionManager.commit(status);
        } catch (Exception ex) {
            logger.info("更新患者医疗保险号出错,从基卫获取的患者数据为:START");
            for (String idcard : idcard_medicare_number_map.keySet()) {
                logger.info("idcard:" + idcard);
                logger.info("idcard:" + idcard_medicare_number_map.get(idcard));
            }
            logger.info("更新患者医疗保险号出错,从基卫获取的患者数据为:END");
            //报错事务回滚
            transactionManager.rollback(status);
        }
    }
}

+ 50 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/JwPatientMedicareNumberService.java

@ -0,0 +1,50 @@
package com.yihu.wlyy.service.third.jw;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
 * 基位签约信息接口
 * Created by humingfen on 2018/5/22.
 */
@Service
public class JwPatientMedicareNumberService {
    private static final Logger logger = LoggerFactory.getLogger(JwPatientMedicareNumberService.class);
    //基卫服务地址
    @Value("${sign.zysoft}")
    private String jwUrl;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    /**
     * 查找所有有效签约居民的签约信息,并同步到本地数据库
     */
    public void getEffectiveSignFamily () throws Exception {
        List<String> idcards = signFamilyDao.findIdcardByStatus();
        List<String> newIdcards = patientDao.findIdcardByMedicareNumber(idcards);
        String url = jwUrl + "/third/zysoftservice/getSickCurrnetFamilySignInfo";
        //医疗保险号的居民集合
        HashMap<String, String> idcard_medicare_number_map = new HashMap<>();
        for (String idcard : newIdcards) {
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("idcard", idcard));
            httpClientUtil.post(url, params, "UTF-8");
        }
    }
}

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

@ -762,4 +762,20 @@ public class JobController extends BaseController {
        }
    }
    /**
     *立即执行慢病患者医疗保险号同步
     *@author humingfen
     *@date 2018/5/23
     */
    @RequestMapping(value = "/executePatientMedicareNumberJob", method = RequestMethod.POST)
    @ApiOperation("立即执行前一天的慢病患者医疗保险号同步")
    public String executePatientMedicareNumberJob() {
        try {
            quartzHelper.startNow(PatientMedicareNumberJob.class, UUID.randomUUID().toString(), null);
            return write(200, "启动成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
}

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/resources/application-dev.yml

@ -90,7 +90,7 @@ images:
sign:
  check_upload: http://172.19.103.88:8011/wlyy_service
  zysoft: http://59.61.92.90:8072/wlyy_sign
quartz:
  name: schedulerFactoryBean_dev

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/resources/application-devtest.yml

@ -86,7 +86,7 @@ images:
sign:
  check_upload: http://172.19.103.88:8011/wlyy_service
  zysoft: http://59.61.92.90:8072/wlyy_sign
quartz:
  name: schedulerFactoryBean_test_dev

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/resources/application-prod.yml

@ -88,7 +88,7 @@ images:
sign:
  check_upload: http://59.61.92.90:8087/wlyy_service
  zysoft: http://59.61.92.90:8072/wlyy_sign
quartz:

+ 3 - 0
patient-co/patient-co-wlyy-job/src/main/resources/system.properties

@ -131,6 +131,9 @@ doctor_prenatal_inspector_job=0 0 10 ? * MON-FRI
#续方订单自动确认job
patient_confirm_receipt_job=00 0 8,12,18,21 * * ?
# 病患者医疗保险号同步JOB (每天6点执行一次)
patient_medicare_number_job=0 0 6 * * ?
#统一支付平台支付成功后页面跳转地址
return_url={server}/wx/html/qygl/html/pay_result.html
#统一支付平台支付接口地址