Forráskód Böngészése

Merge branch 'dev' of wujunjie/patient-co-management into dev

yeshijie 7 éve
szülő
commit
eeb9d989aa

+ 0 - 37
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionPay.java

@ -58,43 +58,6 @@ public class PrescriptionPay extends IdEntity {
    private String mxlist;//处方明细
    private Date createTime;//续方确认支付时间
    private Date czrq;//续方记录最后操作时间
    //    易联众新增查询返回字段v1.3.7
    private String medOrgNo;//医疗机构编号
    private String medOrgName;//医疗机构名称
    private Date traceTime;//交易成功时间
    private String traceNo;//支付平台跟踪号
    public Date getTraceTime() {
        return traceTime;
    }
    public void setTraceTime(Date traceTime) {
        this.traceTime = traceTime;
    }
    public String getTraceNo() {
        return traceNo;
    }
    public void setTraceNo(String traceNo) {
        this.traceNo = traceNo;
    }
    public String getMedOrgNo() {
        return medOrgNo;
    }
    public void setMedOrgNo(String medOrgNo) {
        this.medOrgNo = medOrgNo;
    }
    public String getMedOrgName() {
        return medOrgName;
    }
    public void setMedOrgName(String medOrgName) {
        this.medOrgName = medOrgName;
    }
    public Integer getAccountBalance() {
        return accountBalance;

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

@ -98,14 +98,6 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                logger.info("zy_execute_sick_settle_job reorder job job exist");
            }
            //处理当天支付,页面回调及异步回调失败的支付,每3分钟一次去主动查询并保存
            if (!quartzHelper.isExistJob("prescription_pay_query_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("prescription_pay_query_job");
                quartzHelper.addJob(PrescriptionPayQueryJob.class, trigger, "prescription_pay_query_job", new HashMap<String, Object>());
                logger.info("prescription_pay_query_job reorder job job success");
            } else {
                logger.info("prescription_pay_query_job reorder job job exist");
            }
            //居民24小时未回复的咨询自动关闭 每小时59分开始执行一次
            if (!quartzHelper.isExistJob("finish_consult_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("finish_consult_job");

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

@ -235,7 +235,7 @@ public class DoctorFeldsherTemplateJob implements Job {
        Date today = new Date();
        if (minutes <= 30 && minutes > 0) {
            PatientSchemeList patient = schemeListDao.findPatientBySchemecode(schemecode, (short) 1);
            PatientSchemeList patient = schemeListDao.findPatientBySchemecode(schemecode, (short) type);
            String patientCode = patient.getPatientcode();
            String day = formatDay.format(today);

+ 0 - 57
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PrescriptionPayQueryJob.java

@ -1,57 +0,0 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.repository.prescription.PrescriptionPayDao;
import com.yihu.wlyy.service.app.prescription.PatientPrescriptionPayService;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
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 java.util.List;
/**
 * 处理当天支付,页面回调及异步回调失败的支付,每3分钟一次去主动查询并保存
 * Created by Reece on 2017/8/29/029.
 */
public class PrescriptionPayQueryJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(PrescriptionPayQueryJob.class);
    @Autowired
    private PrescriptionPayDao prescriptionPayDao;
    @Autowired
    private PatientPrescriptionPayService payService;
    @Autowired
    WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("PrescriptionPayQueryJob start ..........");
        try {
            String accesstoken =  weiXinAccessTokenUtils.getAccessToken();
            //获取支付完成,院内结算失败的 处方CODE 集合
            List<String> prescriptionCodeList = prescriptionPayDao.findTodayUnpay();
            if (!prescriptionCodeList.isEmpty()) {
                for (String code : prescriptionCodeList) {
                    try {
                        payService.chargeQuery(code,accesstoken);
                    } catch (Exception e) {
                        logger.info("PrescriptionPayQueryJob error ..........continue this JOB,CODE:" + code + ",message:" + e.getMessage());
                        continue;
                    }
                }
            }
            logger.info("PrescriptionPayQueryJob end ..........");
        } catch (Exception e) {
            e.printStackTrace();
            logger.info("PrescriptionPayQueryJob error ..........,message:" + e.getMessage());
        }
    }
}

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/patient/PatientSchemeListDao.java

@ -18,7 +18,7 @@ public interface PatientSchemeListDao extends PagingAndSortingRepository<Patient
    List<DoctorSchemeBloodSugger> findSuggerPatient();
    //联合wlyy_patient_scheme_list和wlyy_doctor_scheme_blood_pressure查询有血压监测方案且在监测时间前十分钟未上传监测数据
    @Query(" select s from PatientSchemeList p,DoctorSchemeBloodPressure s where p.schemecode=s.code and p.type=0 and s.alertTag = 1 ")
    @Query(" select s from PatientSchemeList p,DoctorSchemeBloodPressure s where p.schemecode=s.code and p.type=2 and s.alertTag = 1 ")
    List<DoctorSchemeBloodPressure> findPressurePatient();
    //根据schemecode查询患者监测方案

+ 0 - 8
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionPayDao.java

@ -13,12 +13,4 @@ import java.util.List;
public interface PrescriptionPayDao extends PagingAndSortingRepository<PrescriptionPay, Long>, JpaSpecificationExecutor<PrescriptionPay> {
    @Query("from PrescriptionPay p where p.prescriptionCode=?1 ")
    PrescriptionPay findByPrescriptionPay(String prescriptionCode);
    //查询支付记录
    @Query("from PrescriptionPay p where p.code=?1 ")
    PrescriptionPay findByCode(String code);
    //   查询当天支付,页面回调及异步回调均失败的支付 tradeStatus为空
    @Query(value = "SELECT t.`code` FROM wlyy_prescription_pay t WHERE t.trade_status is null AND t.create_time >= date(now()) AND t.create_time < DATE_ADD(date(now()), INTERVAL 1 DAY)", nativeQuery = true)
    List<String> findTodayUnpay();
}

+ 0 - 249
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java

@ -1,249 +0,0 @@
package com.yihu.wlyy.service.app.prescription;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.*;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import com.yihu.wlyy.entity.zydict.ZyPushLog;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.repository.prescription.PrescriptionPayDao;
import com.yihu.wlyy.repository.ylz.PayConfiguraDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.SystemConf;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.utils.DateUtil;
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.Service;
import org.springframework.util.StreamUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.transaction.Transactional;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * Created by Reece on 2017/7/28/028.
 * 患者支付
 */
@Service
public class PatientPrescriptionPayService extends BaseService {
    private Logger logger=LoggerFactory.getLogger(PatientPrescriptionPayService.class);
    //公共配置文件
    Properties systemConf = SystemConf.getInstance().getSystemProperties();
    //    各环境对应配置
    @Value("${server.server_url}")
    private String serverUrl;
    @Value("${wechat.accId}")
    private String accId;
    //    Java配置文件 后续删除
    private String signType = "MD5";
    private String encryptType = "AES";
    //    引入实例
    @Autowired
    private PayConfiguraDao configuraDao;
    @Autowired
    private PrescriptionPayDao payDao;
    @Autowired
    private HospitalMappingDao mappingDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    /**
     * 家庭医生签约支付查询
     */
    public String chargeQuery(String code, String accessToken) throws Exception {
        PayConfigura config = configuraDao.findWorkConfigura();
        int flag = 0;
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
        String error = "";
        String result = null;
        PrescriptionPay charge = payDao.findByCode(code);
        String prescriptionCode = charge.getPrescriptionCode();
        Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
        HospitalMapping hospitalMapping = mappingDao.findByCode(prescription.getHospital());
//          ***************************  测通流程 ***************************************
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), hospitalMapping.getAppId(), hospitalMapping.getAppSecret(), signType, encryptType);
        try {
            RequestParams requestParams = new RequestParams();
//            requestParams.setVersion();
//            requestParams.setSign();
//            requestParams.setEncryptData();
//            requestParams.setAppId(appId);
            requestParams.setAppId(hospitalMapping.getAppId());
            requestParams.setTimestamp(DateUtil.getCurrentDateTime());
            requestParams.setSignType(signType);
            requestParams.setEncryptType(encryptType);
            requestParams.setTransType(config.getChargeQueryType());
            //业务参数
            JSONObject params = new JSONObject();
            params.put("outChargeNo", code);  //接入应用结算业务流水号
            params.put("wxToken", accessToken);
            requestParams.setParam(params);
            msgBody = JSON.toJSONString(requestParams);
//              ***************************  测通流程 ***************************************
            //执行支付 返回原生返回值
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            response = JSON.toJSONString(res);
            if (OnepayDefaultClient.isSuccessful(res)) {
                result = JSON.toJSONString(res.getParam());
//                新增保存数据
                JSONObject request = JSON.parseObject(result);
//                String tradeStatus = request.getString("tradeStatus");//交易状态
                String chargeStatus = request.getString("chargeStatus");//交易状态
                String chargeNo = request.getString("chargeNo");//支付平台流水号
                String chargeTime = request.getString("chargeTime");//支付平台交易成功时间
                String outChargeNo = request.getString("outChargeNo");//接入应用业务流水号
                String outChargeTime = request.getString("outChargeTime");//接入应用时间
                String medOrgNo = request.getString("medOrgNo");//医疗机构编号
                String medOrgName = request.getString("medOrgName");//医疗机构名称
                String billNo = request.getString("billNo");//待结算费用单据号
                String cardNo = request.getString("cardNo");//医保卡号
                String totalAmount = request.getString("totalAmount");//交易总金额
                String insuranceAmount = request.getString("insuranceAmount");//医保支付金额
                String selfPayAmount = request.getString("selfPayAmount");//自付金额
                String userId = request.getString("userId");//用户openID
                String userName = request.getString("userName");//用户名字
                String idNo = request.getString("idNo");//证件号码
                String idType = request.getString("idType");//证件类型
//                String appId = request.getString("appId");
//                String channel = request.getString("channel");//支付方式
//                String sign = request.getString("sign");
//                String signType = request.getString("signType");
//                String timestamp = request.getString("timestamp");
                JSONObject responseContents = request.getJSONObject("responseContent");//医保结构体
                PrescriptionPay prescriptionPay = payDao.findByCode(outChargeNo);
                if (responseContents != null) {
                    String miSettleNo = responseContents.getString("miSettleNo");//医保收费单据号 (医保签约号)
                    String miRegisterNo = responseContents.getString("miRegisterNo");//医保挂号
                    String miCollectDate = responseContents.getString("miCollectDate");//收费日期
                    String miCollectTime = responseContents.getString("miCollectTime");//收费时间
                    String miCollectorName = responseContents.getString("miCollectorName");//收费人姓名
                    String miTotalFee = responseContents.getString("miTotalFee");//本次报销总额
                    String selfPay = responseContents.getString("selfPay");//个人现金支付
                    String accountPay = responseContents.getString("accountPay");//个人账户支付
                    String heathPay = responseContents.getString("heathPay");//健康账户支付
                    String cadresPay = responseContents.getString("cadresPay");//公务员补助
                    String fundPay = responseContents.getString("fundPay");//基金支付
                    String healthCarePay = responseContents.getString("healthCarePay");//保健基金支付
                    String commercePay = responseContents.getString("commercePay");//商业保险支付
                    String familyPay = responseContents.getString("familyPay");//共济账户支付
                    String civilPay = responseContents.getString("civilPay");//民政补助金额
                    String civilZone = responseContents.getString("civilZone");//民政行政区号
                    String bdrugPay = responseContents.getString("bdrugPay");//乙类支付金额
                    String unlessAmount = responseContents.getString("unlessAmount");//非医保费用
                    String exceedAmount = responseContents.getString("exceedAmount");//超封顶线金额
                    String accountBalance = responseContents.getString("accountBalance");//个人账户余额
                    String healthBalance = responseContents.getString("healthBalance");//健康账户余额
                    prescriptionPay.setMiSettleNo(miSettleNo);//医保收费单据号
                    prescriptionPay.setMiRegisterNo(miRegisterNo);//医保挂号
                    SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMdd");
                    prescriptionPay.setMiCollectDate(formatDate.parse(miCollectDate));//收费日期
                    SimpleDateFormat formatTime = new SimpleDateFormat("HHmm");
                    prescriptionPay.setMiCollectTime(formatTime.parse(miCollectTime));//收费时间
                    prescriptionPay.setMiCollectorName(miCollectorName);//收费人姓名
                    prescriptionPay.setMiTotalFee(Integer.parseInt(miTotalFee));//本次报销总额
                    prescriptionPay.setSelfPay(Integer.parseInt(selfPay));//个人现金支付
                    prescriptionPay.setAccountPay(Integer.parseInt(accountPay));//个人账户支付
                    prescriptionPay.setHeathPay(Integer.parseInt(heathPay));//健康账户支付
                    prescriptionPay.setCadresPay(Integer.parseInt(cadresPay));//公务员补助
                    prescriptionPay.setFundPay(Integer.parseInt(fundPay));//基金支付
                    prescriptionPay.setHealthCarePay(Integer.parseInt(healthCarePay));//保健基金支付
                    prescriptionPay.setCommercePay(Integer.parseInt(commercePay));//商业保险支付
                    prescriptionPay.setFamilyPay(Integer.parseInt(familyPay));//共济账户支付
                    prescriptionPay.setCivilPay(Integer.parseInt(civilPay));//民政补助金额
                    prescriptionPay.setCivilZone(civilZone);//民政行政区号
                    prescriptionPay.setBdrugPay(Integer.parseInt(bdrugPay));//乙类支付金额
                    prescriptionPay.setUnlessAmount(Integer.parseInt(unlessAmount));//非医保费用
                    prescriptionPay.setExceedAmount(Integer.parseInt(exceedAmount));//超封顶线金额
                    prescriptionPay.setAccountBalance(Integer.parseInt(accountBalance));//个人账户余额
                    prescriptionPay.setHealthBalance(Integer.parseInt(healthBalance));//健康账户余额
                }
                if ("0".equals(chargeStatus) || "SUCCESS".equals(chargeStatus)) {
                    prescriptionPay.setTradeStatus("1");//交易状态 成功1 失败0
                }else {
                    prescriptionPay.setTradeStatus("0");//交易状态 成功1 失败0
                }
                prescriptionPay.setChargeNo(chargeNo);//支付流水号
                SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
                prescriptionPay.setChargeTime(formatDate.parse(chargeTime));//支付平台交易成功时间
                prescriptionPay.setOutChargeTime(formatDate.parse(outChargeTime));//接入应用内业务时间
                prescriptionPay.setMedOrgNo(medOrgNo);//医疗机构编号
                prescriptionPay.setMedOrgName(medOrgName);//医疗机构名称
                prescriptionPay.setBillNo(billNo);//待结算费用单据号
                prescriptionPay.setCardNo(cardNo);//医保卡号
                prescriptionPay.setTotalAmount(Integer.parseInt(totalAmount));//交易总金额
                prescriptionPay.setInsuranceAmount(Integer.parseInt(insuranceAmount));//医保支付金额
                prescriptionPay.setSelfPayAmount(Integer.parseInt(selfPayAmount));//自付金额
                prescriptionPay.setOpenid(userId);
                prescriptionPay.setUserName(userName);
                prescriptionPay.setIdType(idType);//证件类型
                prescriptionPay.setIdNo(idNo);//证件号码
                //        保存数据库更改记录
                payDao.save(prescriptionPay);
                logger.info("请求成功,返回参数: " + result);
            } else {
                isSuccess = false;
                error = "请求失败,返回结果:" + res.getRespCode() + "," + res.getRespMsg();
            }
        } catch (Exception ex) {
            isSuccess = false;
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            error = sw.toString();
        }
        if (!isSuccess) {
            throw new Exception(error);
        }
        return result;
    }
}

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

@ -445,23 +445,6 @@ public class JobController extends BaseController {
        }
    }
    /**
     * 遍历长处方支付但回调都失败的记录,主动查询易联众支付记录并保存
     *
     * @author wujunjie
     * @date 2017/8/30 14:16
     */
    @RequestMapping(value = "/prescriptionPayQueryJob", method = RequestMethod.POST)
    @ApiOperation("遍历长处方支付但回调都失败的记录,主动查询易联众支付记录并保存")
    public String PrescriptionPayQueryJob() {
        try {
            quartzHelper.startNow(PrescriptionPayQueryJob.class, "PRESCRIPTION-PAY_QUERY", null);
            return write(200, "启动成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    //******************************长处方 end********************************
    /**
     * 居民监测方案提醒通知