Browse Source

长处方相关接口

trick9191 7 years ago
parent
commit
753ddda117

+ 10 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java

@ -98,6 +98,8 @@ public class Prescription extends IdEntity {
    private Integer jwPayStatus;//处方结算状态,0为未结算,1为结算成功,默认为0
    private Integer zyCancelState; //智业同步取消表示:0 位同步取消 1已经同步取消
    @Column(name = "code", unique = true, nullable = false)
    public String getCode() {
        return code;
@ -688,4 +690,12 @@ public class Prescription extends IdEntity {
    public void setPresCreateTime(Date presCreateTime) {
        this.presCreateTime = presCreateTime;
    }
    public Integer getZyCancelState() {
        return zyCancelState;
    }
    public void setZyCancelState(Integer zyCancelState) {
        this.zyCancelState = zyCancelState;
    }
}

+ 86 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PrescriptionPayOverdueJob.java

@ -1,15 +1,28 @@
package com.yihu.wlyy.job;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
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;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created by Trick on 2017/8/2.
 */
@ -17,13 +30,48 @@ import org.springframework.stereotype.Component;
public class PrescriptionPayOverdueJob implements Job {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Value("${sign.check_upload}")
    private String jwUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        try {
            logger.info("Prescription_Pay_Overdue_Job_start");
            String getPresSql = "SELECT t.code FROM wlyy_prescription t "+
                    " JOIN wlyy_prescription_reviewed r ON r.prescription_code = t. CODE " +
                    " WHERE " +
                    " (t.`status` = " + PrescriptionLog.PrescriptionLogStatus.wait_pay.getValue() +
                    " OR t.`status` = "+PrescriptionLog.PrescriptionLogStatus.pay_outtime.getValue()+")" +
                    " AND t.zy_cancel_state = 0 "+//未同步成功为0
                    " AND TIMESTAMPDIFF( " +
                    " SECOND, " +
                    " r.reviewed_time, " +
                    " NOW() " +
                    " ) >= 86400 " +
                    " AND TIMESTAMPDIFF( " +
                    " SECOND, " +
                    " r.reviewed_time, " +
                    " NOW() " +
                    " ) <= 604800 ";
            List<Map<String,Object>> pres = jdbcTemplate.queryForList(getPresSql);
            if(pres!=null&&pres.size()>0){
                for(Map<String,Object> m : pres){
                    String code = (String)m.get("code");
                    //挂号作废处方接口
                    try{
                        fadeRecipe(code);
                    }catch (Exception e){
                        logger.error(e.getMessage());
                    }
                }
            }
            //支付超时
            StringBuffer sql = new StringBuffer("UPDATE wlyy_prescription " +
                    " JOIN wlyy_prescription_reviewed ON wlyy_prescription_reviewed.prescription_code = wlyy_prescription. CODE " +
                    " SET wlyy_prescription.`status` = -3 " +
@ -41,4 +89,41 @@ public class PrescriptionPayOverdueJob implements Job {
            logger.info("Prescription_Pay_Overdue_Job_error");
        }
    }
    /**
     * 挂号作废处方接口
     * @param prescriptionCode 续方号码
     * @return
     * @throws Exception
     */
    public String fadeRecipe(String prescriptionCode)throws Exception{
        Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
        if(StringUtils.isNotBlank(prescription.getVisitNo())){
            String url = jwUrl + "/third/prescription/fadeRecipe";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("visitNo", prescription.getVisitNo()));//挂号号
            params.add(new BasicNameValuePair("fadeDept", prescription.getJwDeptCode()));//作废科室编码
            params.add(new BasicNameValuePair("fadeOperator", prescription.getJwDoctorCode()));//作废人员编码
            params.add(new BasicNameValuePair("recipeNo", prescription.getRecipeNo()));//基卫处方号
            String response = httpClientUtil.post(url, params, "UTF-8");
            if(StringUtils.isNotBlank(response)){
                JSONObject reobj =  JSON.parseObject(response);
                Integer status = reobj.getInteger("status");
                String errmsg = reobj.getString("msg");
                if(-1 == status){
                    throw new Exception("基卫接口(挂号作废)请求失败,"+errmsg);
                }
                prescription.setZyCancelState(1);
                prescriptionDao.save(prescription);
            }else{
                throw new Exception("基卫接口(挂号作废)请求失败,无数据返回!");
            }
            return response;
        }
        return "";
    }
}

+ 2 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java

@ -273,6 +273,8 @@ public class JwPrescriptionService {
                if(-1 == status){
                    throw new Exception("基卫接口(挂号作废)请求失败,"+errmsg);
                }
                prescription.setZyCancelState(1);
                prescriptionDao.save(prescription);
            }else{
                throw new Exception("基卫接口(挂号作废)请求失败,无数据返回!");
            }