فهرست منبع

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

trick9191 7 سال پیش
والد
کامیت
1b2bc20039

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

@ -100,6 +100,16 @@ public class Prescription extends IdEntity {
    private Integer zyCancelState; //智业同步取消表示:0 位同步取消 1已经同步取消
    //1.4.0新增字段
    private Integer drugDeliveryflag;
    private String drugDeliveryReasonCode;
    private String drugDeliveryReasonValue;
    private String drugDeliveryReason;
    private String drugDeliveryOperator;
    private String drugDeliveryOperatorName;
    private Date drugDeliveryTime;
    @Column(name = "code", unique = true, nullable = false)
    public String getCode() {
        return code;
@ -698,4 +708,60 @@ public class Prescription extends IdEntity {
    public void setZyCancelState(Integer zyCancelState) {
        this.zyCancelState = zyCancelState;
    }
    public Integer getDrugDeliveryflag() {
        return drugDeliveryflag;
    }
    public void setDrugDeliveryflag(Integer drugDeliveryflag) {
        this.drugDeliveryflag = drugDeliveryflag;
    }
    public String getDrugDeliveryReasonCode() {
        return drugDeliveryReasonCode;
    }
    public void setDrugDeliveryReasonCode(String drugDeliveryReasonCode) {
        this.drugDeliveryReasonCode = drugDeliveryReasonCode;
    }
    public String getDrugDeliveryReasonValue() {
        return drugDeliveryReasonValue;
    }
    public void setDrugDeliveryReasonValue(String drugDeliveryReasonValue) {
        this.drugDeliveryReasonValue = drugDeliveryReasonValue;
    }
    public String getDrugDeliveryReason() {
        return drugDeliveryReason;
    }
    public void setDrugDeliveryReason(String drugDeliveryReason) {
        this.drugDeliveryReason = drugDeliveryReason;
    }
    public String getDrugDeliveryOperator() {
        return drugDeliveryOperator;
    }
    public void setDrugDeliveryOperator(String drugDeliveryOperator) {
        this.drugDeliveryOperator = drugDeliveryOperator;
    }
    public String getDrugDeliveryOperatorName() {
        return drugDeliveryOperatorName;
    }
    public void setDrugDeliveryOperatorName(String drugDeliveryOperatorName) {
        this.drugDeliveryOperatorName = drugDeliveryOperatorName;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getDrugDeliveryTime() {
        return drugDeliveryTime;
    }
    public void setDrugDeliveryTime(Date drugDeliveryTime) {
        this.drugDeliveryTime = drugDeliveryTime;
    }
}

+ 162 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/charge/Charge.java

@ -0,0 +1,162 @@
package com.yihu.wlyy.service.app.charge;
/**
 * 医保扣费
 * add by hzp at 20170524
 */
public class Charge {
    private String tradeStatus; //交易状态    0 成功 1 失败  2 已退款
    private String chargeNo;  //医保业务流水号
    private String chargeTime;  //  医保交易成功时间
    private String outChargeNo;  //  接入应用业务流水号
    private String outChargeTime;  //  接入应用内业务时间
    private String medOrgNo;  //  医疗机构编号
    private String medOrgName;  //  医疗机构名称
    private String billNo;  //  待结算费用单据号
    private String cardNo;  //  医保卡号
    private String totalAmount;  //  交易总金额
    private String insuranceAmount;  //  医保支付金额
    private String selfPayAmount;  //  自付金额
    private String userId;  // 用户openId
    private String userName;  // 用户姓名
    private String idType;  // 证件号码
    private String idNo;  // 证件类型
    private String responseContent;  //扣费详情
    public String getResponseContent() {
        return responseContent;
    }
    public void setResponseContent(String responseContent) {
        this.responseContent = responseContent;
    }
    public String getTradeStatus() {
        return tradeStatus;
    }
    public void setTradeStatus(String tradeStatus) {
        this.tradeStatus = tradeStatus;
    }
    public String getChargeNo() {
        return chargeNo;
    }
    public void setChargeNo(String chargeNo) {
        this.chargeNo = chargeNo;
    }
    public String getChargeTime() {
        return chargeTime;
    }
    public void setChargeTime(String chargeTime) {
        this.chargeTime = chargeTime;
    }
    public String getOutChargeNo() {
        return outChargeNo;
    }
    public void setOutChargeNo(String outChargeNo) {
        this.outChargeNo = outChargeNo;
    }
    public String getOutChargeTime() {
        return outChargeTime;
    }
    public void setOutChargeTime(String outChargeTime) {
        this.outChargeTime = outChargeTime;
    }
    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 String getBillNo() {
        return billNo;
    }
    public void setBillNo(String billNo) {
        this.billNo = billNo;
    }
    public String getCardNo() {
        return cardNo;
    }
    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    }
    public String getTotalAmount() {
        return totalAmount;
    }
    public void setTotalAmount(String totalAmount) {
        this.totalAmount = totalAmount;
    }
    public String getInsuranceAmount() {
        return insuranceAmount;
    }
    public void setInsuranceAmount(String insuranceAmount) {
        this.insuranceAmount = insuranceAmount;
    }
    public String getSelfPayAmount() {
        return selfPayAmount;
    }
    public void setSelfPayAmount(String selfPayAmount) {
        this.selfPayAmount = selfPayAmount;
    }
    public String getUserId() {
        return userId;
    }
    public void setUserId(String userId) {
        this.userId = userId;
    }
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    public String getIdType() {
        return idType;
    }
    public void setIdType(String idType) {
        this.idType = idType;
    }
    public String getIdNo() {
        return idNo;
    }
    public void setIdNo(String idNo) {
        this.idNo = idNo;
    }
}

+ 195 - 2
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/charge/OnePayService.java

@ -67,9 +67,9 @@ public class OnePayService {
    private static final Logger LOGGER = LoggerFactory.getLogger(OnePayService.class);
    /**
     * 家庭医生签约支付查询
     * 家庭医生签约支付查询(v1.4.0作废)
     */
    public String chargeQuery(String code, String accessToken) throws Exception {
    public String chargeQueryBak(String code, String accessToken) throws Exception {
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
@ -248,4 +248,197 @@ public class OnePayService {
        return result;
    }
    /**
     * 家庭医生签约支付查询
     */
    public String chargeQuery(String code, String accessToken) throws Exception {
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
        String error = "";
        String result = null;
        PayConfigura config = configuraDao.findWorkConfigura();
        try {
            WlyyCharge charge = chargeDao.findByCode(code);
            HospitalMapping hospitalMapping = hospitalMappingDao.findByCode(charge.getHospital());
            OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), hospitalMapping.getAppId(), hospitalMapping.getAppSecret(), signType, encryptType);
            RequestParams requestParams = new RequestParams();
            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);
            if (OnepayDefaultClient.isSuccessful(res)) {
                //业务处理*******************
                result = JSON.toJSONString(res.getParam());
                Charge chargeView = objectMapper.readValue(result, Charge.class);
                saveToWlyyCharge(chargeView);
                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;
    }
    /**
     * 只保存到家庭签约支付表
     *
     * @param chargeView 家庭签约支付展示类Charge
     * @throws Exception
     */
    public void saveToWlyyCharge(Charge chargeView) throws Exception {
        String outChargeNo = chargeView.getOutChargeNo();
        WlyyCharge chargePay = chargeDao.findByCode(outChargeNo);
        String tradeStatus = chargeView.getTradeStatus();
        String chargeNo = chargeView.getChargeNo();
        String chargeTime = chargeView.getChargeTime();
        String outChargeTime = chargeView.getOutChargeTime();
        String medOrgNo = chargeView.getMedOrgNo();
        String medOrgName = chargeView.getMedOrgName();
        String billNo = chargeView.getBillNo();
        String cardNo = chargeView.getCardNo();
        String totalAmount = chargeView.getTotalAmount();
        String insuranceAmount = chargeView.getInsuranceAmount();
        String selfPayAmount = chargeView.getSelfPayAmount();
        String userId = chargeView.getUserId();
        String userName = chargeView.getUserName();
        String idType = chargeView.getIdType();
        String idNo = chargeView.getIdNo();
        String responseContent = chargeView.getResponseContent();
        chargePay.setChargeNo(chargeNo);//支付流水号
        SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
        chargePay.setChargeTime(chargeTime);//支付平台交易成功时间
        chargePay.setCreateTime(formatDate.parse(outChargeTime));//接入应用内业务时间
        chargePay.setMedOrgNo(medOrgNo);//医疗机构编号
        chargePay.setMedOrgName(medOrgName);//医疗机构名称
        chargePay.setBillNo(billNo);//待结算费用单据号
        chargePay.setSsc(cardNo);//医保卡号
        chargePay.setTotalAmount(Integer.parseInt(totalAmount));//交易总金额
        chargePay.setInsuranceAmount(Integer.parseInt(insuranceAmount));//医保支付金额
        chargePay.setSelfpayAmount(Integer.parseInt(selfPayAmount));//自付金额
        chargePay.setOpenid(userId);
        chargePay.setName(userName);
        chargePay.setIdType(idType);//证件类型
        chargePay.setIdNo(idNo);//证件号码
        JSONObject response = JSON.parseObject(responseContent);
        String miRegisterNo = null;//医保挂号
        String miCollectDate = null;//收费日期
        String miCollectTime = null;//收费时间
        String miSettleNo = null;//医保收费单据号 (医保签约号)
        String miCollectStatus = null;//扣费状态
        String miRegisterStatus = null;//登记状态
        String cadresPay = "0";//公务员补助
        String miTotalFee = "0";//本次报销总额
        String healthCarePay = "0";//保健基金支付
        String heathPay = "0";//健康账户支付
        String accountPay = "0";//个人账户支付
        String selfPay = "0";//个人现金支付
        String civilPay = "0";//民政补助金额
        if (response != null && response.containsKey("miRegisterNo")) {
            miRegisterNo = response.getString("miRegisterNo");
        }
        if (response != null && response.containsKey("miCollectDate")) {
            miCollectDate = response.getString("miCollectDate");
        }
        if (response != null && response.containsKey("miCollectTime")) {
            miCollectTime = response.getString("miCollectTime");
        }
        if (response != null && response.containsKey("miSettleNo")) {
            miSettleNo = response.getString("miSettleNo");
        }
        if (response != null && response.containsKey("miCollectStatus")) {
            miCollectStatus = response.getString("miCollectStatus");
        }
        if (response != null && response.containsKey("miRegisterStatus")) {
            miRegisterStatus = response.getString("miRegisterStatus");
        }
        if (response != null && response.containsKey("cadresPay")) {
            cadresPay = response.getString("cadresPay");
        }
        if (response != null && response.containsKey("miTotalFee")) {
            miTotalFee = response.getString("miTotalFee");
        }
        if (response != null && response.containsKey("healthCarePay")) {
            healthCarePay = response.getString("healthCarePay");
        }
        if (response != null && response.containsKey("heathPay")) {
            heathPay = response.getString("heathPay");
        }
        if (response != null && response.containsKey("accountPay")) {
            accountPay = response.getString("accountPay");
        }
        if (response != null && response.containsKey("selfPay")) {
            selfPay = response.getString("selfPay");
        }
        if (response != null && response.containsKey("civilPay")) {
            civilPay = response.getString("civilPay");
        }
        chargePay.setMiRegisterNo(miRegisterNo);//医保挂号
        chargePay.setMiCollectDate(miCollectDate);
        chargePay.setMiCollectTime(miCollectTime);
        chargePay.setMiSettleNo(miSettleNo);
        chargePay.setMiCollectStatus(miCollectStatus);
        chargePay.setMiRegisterStatus(miRegisterStatus);
        chargePay.setCadresPay(cadresPay);
        chargePay.setMiTotalFee(miTotalFee);
        chargePay.setHealthCarePay(healthCarePay);
        chargePay.setHeathPay(heathPay);
        chargePay.setAccountPay(accountPay);
        chargePay.setSelfPay(selfPay);
        chargePay.setCivilPay(civilPay);
        //                判断是否需要更新数据 needUpload为0不需要更新
        LOGGER.info("before  goto " + chargePay.getNeedUpload() + " == " + outChargeNo);
        if (chargePay != null && !("0".equals(chargePay.getNeedUpload()))) {
            updateData(tradeStatus, formatDate.parse(chargeTime), chargeNo, chargePay);
            LOGGER.info("after  goto " + chargePay.getNeedUpload() + " == " + outChargeNo);
        }
    }
    /**
     * 更改数据 wlyy_sign_family wlyy_charge
     */
    public void updateData(String chargeStatus, Date chargeTime, String chargeNo, WlyyCharge charge) throws Exception {
        if ("0".equals(chargeStatus) || "SUCCESS".equals(chargeStatus)) {
            charge.setNeedUpload("1");
            charge.setTradeStatus("0");//交易状态 成功0 失败1
            //        成功支付根据wlyy_charge的code 去查找关联代码signCode在更新签约表
            signFamilyDao.updatePatientBegin(charge.getChargeRelation(), chargeTime, chargeNo, "1", 2);
        } else {
            charge.setTradeStatus("1");//交易状态 成功0 失败1
        }
        charge.setUpdateTime(new Date());
        chargeDao.save(charge);
    }
}

+ 202 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java

@ -8,21 +8,24 @@ import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
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.transaction.annotation.Transactional;
import java.util.Date;
import java.util.UUID;
import java.util.*;
/**
 * Created by chenweida on 2017/7/27.
 * 订单物流相关
 * 订单物流相关。
 */
@Service
public class PrescriptionExpressageService {
public class PrescriptionExpressageService extends BaseService {
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
@ -43,6 +46,8 @@ public class PrescriptionExpressageService {
    private DoctorDao doctorDao;
    @Autowired
    private HospitalDao hospitalDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientDao patientDao;
@ -247,8 +252,8 @@ public class PrescriptionExpressageService {
        prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
        //回填配送表的配送时间
        PrescriptionExpressage prescriptionExpressage=prescriptionExpressageDao.findByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
        prescriptionExpressage.setExpressageTime(expressageing );
        PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
        prescriptionExpressage.setExpressageTime(expressageing);
        //得到patient
        Patient patient = patientDao.findByCode(prescription.getPatient());
@ -458,4 +463,195 @@ public class PrescriptionExpressageService {
            prescriptionExpressage.setExpressageHospitalAddress(hospitalAddress);
        }
    }
    public List<Map<String, Object>> getDrugDeliveryState() {
        String sql = "SELECT * FROM system_dict t WHERE t.dict_name = 'DRUGDELIVERY_STATE' ORDER BY DESC";
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
        return rs;
    }
    public List<Map<String, Object>> getEsListByIDCardOrSSC(String keyWord, Integer page, Integer pageSize) {
        Patient p = null;
        if (StringUtils.isNotBlank(keyWord)) {
            p = patientDao.findByIdcard(keyWord);
            if (p == null) {
                p = patientDao.findBySsc(keyWord);
            }
            if (p != null) {
                int start = (page - 1) * pageSize;
                String sql = "SELECT " +
                        "  py.charge_no AS chargeNo, " +
                        "  p.patient_name AS patientName, " +
                        "  p.patient AS patientCode, " +
                        "  py.pay_time AS payTime, " +
                        "  p.dispensary_type AS dispensaryType, " +
                        "  p.`status` " +
                        " FROM " +
                        " wlyy_prescription p " +
                        " JOIN wlyy_prescription_pay py ON py.prescription_code = p.`code` " +
                        " WHERE " +
                        " p.patient = '" + p.getCode() + "' " +
                        " AND p.`status`>=50 " +
                        " ORDER BY p.`status` ASC " +
                        " LIMIT " + start + "," + pageSize;
                List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
                return list;
            }
        }
        return null;
    }
    public String saveDrugDelivery(String doctor, String prescriptionCode, String reasonCode, String reasonName, String reason) {
        Prescription p = prescriptionDao.findByCode(prescriptionCode);
        Doctor d = doctorDao.findByCode(doctor);
        if (p != null) {
            p.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
            p.setDrugDeliveryflag(1);
            p.setDrugDeliveryOperator(doctor);
            p.setDrugDeliveryOperatorName(d.getName());
            p.setDrugDeliveryReason(reason);
            p.setDrugDeliveryReasonCode(reasonCode);
            p.setDrugDeliveryOperatorName(reasonName);
            p.setDrugDeliveryTime(new Date());
            prescriptionDao.save(p);
            //更新日志
            PrescriptionLog prescriptionLog = new PrescriptionLog();
            prescriptionLog.setPrescriptionCode(p.getCode());
            prescriptionLog.setCode(getCode());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.finish.getValue());
            prescriptionLog.setCreateTime(new Date());
            prescriptionLog.setFlag(1);
            prescriptionLog.setUserCode(doctor);
            prescriptionLog.setUserName(d.getName());
            prescriptionLog.setUserType(2);
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
            prescriptionLogDao.save(prescriptionLog);
            //更新二维码(isUse)
            PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeDao.finByCode(prescriptionCode);
            //修改取药码code为已经使用
            prescriptionDispensaryCode.setIsUse(1);
            prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
            //更新配送信息
            PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
            prescriptionExpressage.setHospitalDoctor(doctor);
            prescriptionExpressage.setHospitalDoctorCode(d.getCode());
            prescriptionExpressage.setFetchingMedicineTime(new Date());
            prescriptionExpressageDao.save(prescriptionExpressage);
            return "1";
        }
        return "0";
    }
    public List<Map<String, Object>> getPresStatesList() {
        List<Map<String, Object>> rs = new ArrayList<>();
        Map<String, Object> map1 = new HashedMap();
        map1.put("code", PrescriptionLog.PrescriptionLogStatus.pay_success.getValue());
        map1.put("name", PrescriptionLog.PrescriptionLogStatus.pay_success.getName());
        rs.add(map1);
        Map<String, Object> map2 = new HashedMap();
        map2.put("code", PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue());
        map2.put("name", PrescriptionLog.PrescriptionLogStatus.wait_expressage.getName());
        rs.add(map2);
        Map<String, Object> map3 = new HashedMap();
        map3.put("code", PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
        map3.put("name", PrescriptionLog.PrescriptionLogStatus.expressageing.getName());
        rs.add(map3);
        Map<String, Object> map4 = new HashedMap();
        map4.put("code", PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getValue());
        map4.put("name", PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getName());
        rs.add(map4);
        Map<String, Object> map5 = new HashedMap();
        map5.put("code", PrescriptionLog.PrescriptionLogStatus.finish.getValue());
        map5.put("name", PrescriptionLog.PrescriptionLogStatus.finish.getName());
        rs.add(map5);
        return rs;
    }
    public List<Map<String, Object>> getPresEsPayList(String keyWord, String state, String type, String startDate, String endDate, String operator,String flag,Integer page, Integer pageSize) {
        int start = (page - 1) * pageSize;
        String sql = "SELECT " +
                "  py.charge_no AS chargeNo, " +
                "  p.patient_name AS patientName, " +
                "  p.patient AS patientCode, " +
                "  py.pay_time AS payTime, " +
                "  p.dispensary_type AS dispensaryType, " +
                "  p.drug_delivery_operator_name AS operatorName," +
                "  p.drug_delivery_flag AS drugDeliveryFlag, " +
                "  p.`status` " +
                " FROM " +
                " wlyy_prescription p " +
                " JOIN wlyy_prescription_pay py ON py.prescription_code = p.`code` " +
                " WHERE" +
                " 1=1 ";
        sql = setSQL( sql,keyWord,state,type,startDate,endDate,operator,flag);
        sql +=  " AND p.`status`>=50 " +
                " ORDER BY py.create_time DESC " +
                " LIMIT " + start + "," + pageSize;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    public String setSQL(String sql,String keyWord, String state, String type, String startDate, String endDate,String operator,String flag){
        //关键字搜索
        if(StringUtils.isNotBlank(keyWord)){
            Patient p = patientDao.findByIdcard(keyWord);
            if(p!=null){
                sql += " AND p.patient = '"+p.getCode()+"' ";
            }else{
                p = patientDao.findBySsc(keyWord);
                if(p!=null){
                    sql += " AND p.patient = '"+p.getCode()+"' ";
                }else{
                    sql += " AND ( py.charge_no = '"+keyWord+"' OR p.patient_name ='"+keyWord+"' )";
                }
            }
        }
        if(StringUtils.isNotBlank(state)){
            sql += " AND p.status = "+state ;
        }
        if(StringUtils.isNotBlank(type)){
            sql +=" AND p.dispensary_type =" +type;
        }
        if(StringUtils.isNotBlank(startDate)){
            startDate +=" 00:00:00";
            sql += " AND py.create_time >='"+startDate+"' ";
        }
        if(StringUtils.isNotBlank(endDate)){
            endDate +=" 23:59:59";
            sql += " AND py.create_time <='"+endDate+"' ";
        }
        if(StringUtils.isNotBlank(operator)){
            sql += " AND p.drug_delivery_operator ='"+operator+"' ";
        }
        if(StringUtils.isNotBlank(flag)){
            sql += " AND p.drug_delivery_flag ="+flag+" ";
        }
        return sql;
    }
    public List<Map<String,Object>> getHospitalOperator(String doctor){
        Doctor d = doctorDao.findByCode(doctor);
        String sql = "SELECT " +
                " p.drug_delivery_operator AS operator, " +
                " p.drug_delivery_operator_name AS operatorName " +
                " FROM " +
                " wlyy_prescription p " +
                " WHERE " +
                " p.hospital = '"+d.getHospital()+"' " +
                " GROUP BY " +
                " p.drug_delivery_operator ";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
        return rs;
    }
}

+ 193 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java

@ -392,9 +392,9 @@ public class OnePayService {
    }
    /**
     * 家庭医生签约支付查询
     * 家庭医生签约支付查询(v1.4.0作废)
     */
    public String chargeQuery(String code, String accessToken) throws Exception {
    public String chargeQueryBak(String code, String accessToken) throws Exception {
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
@ -538,9 +538,9 @@ public class OnePayService {
                }
                if ("0".equals(chargeStatus) || "SUCCESS".equals(chargeStatus)) {
                    chargePay.setTradeStatus("1");//交易状态 成功1 失败0
                    chargePay.setTradeStatus("0");//交易状态 成功0 失败1
                } else {
                    chargePay.setTradeStatus("0");//交易状态 成功1 失败0
                    chargePay.setTradeStatus("1");//交易状态 成功0 失败1
                }
                chargePay.setChargeNo(chargeNo);//支付流水号
                SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
@ -583,6 +583,68 @@ public class OnePayService {
        return result;
    }
    /**
     * 家庭医生签约支付查询
     */
    public String chargeQuery(String code, String accessToken) throws Exception {
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
        String error = "";
        String result = null;
        PayConfigura config = configuraDao.findWorkConfigura();
        try {
            WlyyCharge charge = chargeDao.findByCode(code);
            HospitalMapping hospitalMapping = hospitalMappingDao.findByCode(charge.getHospital());
            OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), hospitalMapping.getAppId(), hospitalMapping.getAppSecret(), signType, encryptType);
            RequestParams requestParams = new RequestParams();
            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());
                Charge chargeView = objectMapper.readValue(result, Charge.class);
                saveToWlyyCharge(chargeView);
                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();
        }
        //type = 3易联众接口保存http日志
        logService.saveHttpLog(isSuccess, config.getChargeType(), "家庭医生签约支付查询", "POST", null, msgBody, response, error, logService.onepayType);
        if (!isSuccess) {
            throw new Exception(error);
        }
        return result;
    }
    /**
     * 生成电子社保卡
     */
@ -712,12 +774,135 @@ public class OnePayService {
     * 更改数据 wlyy_sign_family wlyy_charge
     */
    public void updateData(String chargeStatus, Date chargeTime, String chargeNo, WlyyCharge charge) throws Exception {
        charge.setUploadLog("1");
        if ("0".equals(chargeStatus) || "SUCCESS".equals(chargeStatus)) {
            charge.setNeedUpload("1");
            charge.setTradeStatus("0");//交易状态 0 成功 1 失败
            //        成功支付根据wlyy_charge的code 去查找关联代码signCode在更新签约表
            signFamilyDao.updatePatientBegin(charge.getChargeRelation(), chargeTime, chargeNo, "1", 2);
        } else {
            charge.setTradeStatus("1");//交易状态 0 成功 1 失败
        }
        charge.setUpdateTime(new Date());
        chargeDao.save(charge);
//        成功支付根据wlyy_charge的code 去查找关联代码signCode在更新签约表
        if ("0".equals(chargeStatus)) {
            signFamilyDao.updatePatientBegin(charge.getChargeRelation(), chargeTime, chargeNo, "1", 2);
    }
    /**
     * 只保存到家庭签约支付表
     *
     * @param chargeView 家庭签约支付展示类Charge
     * @throws Exception
     */
    public void saveToWlyyCharge(Charge chargeView) throws Exception {
        String outChargeNo = chargeView.getOutChargeNo();
        WlyyCharge chargePay = chargeDao.findByCode(outChargeNo);
        String tradeStatus = chargeView.getTradeStatus();
        String chargeNo = chargeView.getChargeNo();
        String chargeTime = chargeView.getChargeTime();
        String outChargeTime = chargeView.getOutChargeTime();
        String medOrgNo = chargeView.getMedOrgNo();
        String medOrgName = chargeView.getMedOrgName();
        String billNo = chargeView.getBillNo();
        String cardNo = chargeView.getCardNo();
        String totalAmount = chargeView.getTotalAmount();
        String insuranceAmount = chargeView.getInsuranceAmount();
        String selfPayAmount = chargeView.getSelfPayAmount();
        String userId = chargeView.getUserId();
        String userName = chargeView.getUserName();
        String idType = chargeView.getIdType();
        String idNo = chargeView.getIdNo();
        String responseContent = chargeView.getResponseContent();
        chargePay.setChargeNo(chargeNo);//支付流水号
        SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
        chargePay.setChargeTime(chargeTime);//支付平台交易成功时间
        chargePay.setCreateTime(formatDate.parse(outChargeTime));//接入应用内业务时间
        chargePay.setMedOrgNo(medOrgNo);//医疗机构编号
        chargePay.setMedOrgName(medOrgName);//医疗机构名称
        chargePay.setBillNo(billNo);//待结算费用单据号
        chargePay.setSsc(cardNo);//医保卡号
        chargePay.setTotalAmount(Integer.parseInt(totalAmount));//交易总金额
        chargePay.setInsuranceAmount(Integer.parseInt(insuranceAmount));//医保支付金额
        chargePay.setSelfpayAmount(Integer.parseInt(selfPayAmount));//自付金额
        chargePay.setOpenid(userId);
        chargePay.setName(userName);
        chargePay.setIdType(idType);//证件类型
        chargePay.setIdNo(idNo);//证件号码
        JSONObject response = JSON.parseObject(responseContent);
        String miRegisterNo = null;//医保挂号
        String miCollectDate = null;//收费日期
        String miCollectTime = null;//收费时间
        String miSettleNo = null;//医保收费单据号 (医保签约号)
        String miCollectStatus = null;//扣费状态
        String miRegisterStatus = null;//登记状态
        String cadresPay = "0";//公务员补助
        String miTotalFee = "0";//本次报销总额
        String healthCarePay = "0";//保健基金支付
        String heathPay = "0";//健康账户支付
        String accountPay = "0";//个人账户支付
        String selfPay = "0";//个人现金支付
        String civilPay = "0";//民政补助金额
        if (response != null && response.containsKey("miRegisterNo")) {
            miRegisterNo = response.getString("miRegisterNo");
        }
        if (response != null && response.containsKey("miCollectDate")) {
            miCollectDate = response.getString("miCollectDate");
        }
        if (response != null && response.containsKey("miCollectTime")) {
            miCollectTime = response.getString("miCollectTime");
        }
        if (response != null && response.containsKey("miSettleNo")) {
            miSettleNo = response.getString("miSettleNo");
        }
        if (response != null && response.containsKey("miCollectStatus")) {
            miCollectStatus = response.getString("miCollectStatus");
        }
        if (response != null && response.containsKey("miRegisterStatus")) {
            miRegisterStatus = response.getString("miRegisterStatus");
        }
        if (response != null && response.containsKey("cadresPay")) {
            cadresPay = response.getString("cadresPay");
        }
        if (response != null && response.containsKey("miTotalFee")) {
            miTotalFee = response.getString("miTotalFee");
        }
        if (response != null && response.containsKey("healthCarePay")) {
            healthCarePay = response.getString("healthCarePay");
        }
        if (response != null && response.containsKey("heathPay")) {
            heathPay = response.getString("heathPay");
        }
        if (response != null && response.containsKey("accountPay")) {
            accountPay = response.getString("accountPay");
        }
        if (response != null && response.containsKey("selfPay")) {
            selfPay = response.getString("selfPay");
        }
        if (response != null && response.containsKey("civilPay")) {
            civilPay = response.getString("civilPay");
        }
        chargePay.setMiRegisterNo(miRegisterNo);//医保挂号
        chargePay.setMiCollectDate(miCollectDate);
        chargePay.setMiCollectTime(miCollectTime);
        chargePay.setMiSettleNo(miSettleNo);
        chargePay.setMiCollectStatus(miCollectStatus);
        chargePay.setMiRegisterStatus(miRegisterStatus);
        chargePay.setCadresPay(cadresPay);
        chargePay.setMiTotalFee(miTotalFee);
        chargePay.setHealthCarePay(healthCarePay);
        chargePay.setHeathPay(heathPay);
        chargePay.setAccountPay(accountPay);
        chargePay.setSelfPay(selfPay);
        chargePay.setCivilPay(civilPay);
        //                判断是否需要更新数据 needUpload为0不需要更新
        LOGGER.info("before  goto " + chargePay.getNeedUpload() + " == " + outChargeNo);
        if (chargePay != null && !("0".equals(chargePay.getNeedUpload()))) {
            updateData(tradeStatus, formatDate.parse(chargeTime), chargeNo, chargePay);
            LOGGER.info("after  goto " + chargePay.getNeedUpload() + " == " + outChargeNo);
        }
    }

+ 79 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionExpressageController.java

@ -74,4 +74,83 @@ public class PrescriptionExpressageController extends WeixinBaseController {
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/getDrugDeliveryState", method = RequestMethod.GET)
    @ApiOperation(value = "获取异常原因列表")
    public String getDrugDeliveryState(){
        try {
            return write(200, "获取成功", "data", expressageService.getDrugDeliveryState());
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/getEsListByIDCardOrSSC", method = RequestMethod.GET)
    @ApiOperation(value = "根据医保号和身份证查询订单")
    public String getEsListByIDCardOrSSC(@ApiParam(required = true, name = "keyWord", value = "医保号或身份证") @RequestParam(required = true)String keyWord,
                                         @ApiParam(required = true, name = "page", value = "起始页,重1开始") @RequestParam(required = true)Integer page,
                                         @ApiParam(required = true, name = "pageSize", value = "每页大小") @RequestParam(required = true)Integer pageSize){
        try {
            return write(200, "获取成功", "data", expressageService.getEsListByIDCardOrSSC( keyWord, page, pageSize));
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/saveDrugDelivery", method = RequestMethod.POST)
    @ApiOperation(value = "异常出操作")
    public String saveDrugDelivery(@ApiParam(required = true, name = "prescriptionCode", value = "续方code") @RequestParam(required = true)String prescriptionCode,
                                   @ApiParam(required = true, name = "reasonCode", value = "原因code") @RequestParam(required = true)String reasonCode,
                                   @ApiParam(required = true, name = "reasonName", value = "原因名称") @RequestParam(required = true)String reasonName,
                                   @ApiParam(required = true, name = "reason", value = "详细原因") @RequestParam(required = true)String reason){
        try {
            return write(200, "获取成功", "data", expressageService.saveDrugDelivery( getUID(), prescriptionCode, reasonCode, reasonName, reason));
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/getPresStatesList", method = RequestMethod.GET)
    @ApiOperation(value = "获取续方状态原因列表")
    public String getPresStatesList(){
        try {
            return write(200, "获取成功", "data", expressageService.getPresStatesList());
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/getPresEsPayList", method = RequestMethod.GET)
    @ApiOperation(value = "获取订单列表")
    public String getPresEsPayList(@ApiParam(required = true, name = "keyWord", value = "订单号,接收人,医保号或身份证") @RequestParam(required = false)String keyWord,
                                   @ApiParam(required = true, name = "state", value = "续方状态") @RequestParam(required = false)String state,
                                   @ApiParam(required = true, name = "type", value = "1 自取 2快递配送 3健管师配送") @RequestParam(required = false)String type,
                                   @ApiParam(required = true, name = "startDate", value = "开始时间yyyy-MM--dd") @RequestParam(required = false)String startDate,
                                   @ApiParam(required = true, name = "endDate", value = "结束时间yyyy-MM-dd") @RequestParam(required = false)String endDate,
                                   @ApiParam(required = true, name = "operator", value = "操作人") @RequestParam(required = false)String operator,
                                   @ApiParam(required = true, name = "flag", value = "1.扫描2.异常出药") @RequestParam(required = false)String flag,
                                   @ApiParam(required = true, name = "page", value = "页面") @RequestParam(required = false)Integer page,
                                   @ApiParam(required = true, name = "pageSize", value = "页面大小") @RequestParam(required = false)Integer pageSize){
        try {
            return write(200, "获取成功", "data", expressageService.getPresEsPayList(keyWord,state,type,startDate,endDate,operator,flag,page,pageSize));
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/getHospitalOperator", method = RequestMethod.GET)
    @ApiOperation(value = "获取操作人员下拉列表")
    public String getHospitalOperator(){
        try {
            return write(200, "获取成功", "data", expressageService.getHospitalOperator(getUID()));
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
}

+ 9 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.adapter.PresModeAdapter;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
@ -13,6 +14,7 @@ import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
import com.yihu.wlyy.service.app.prescription.PrescriptionPayService;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import com.yihu.wlyy.web.BaseController;
@ -48,6 +50,8 @@ public class PrescriptionInfoController extends BaseController {
    private ZyDictService zyDictService;
    @Autowired
    private AdminTeamService adminTeamService;
    @Autowired
    private PatientService patientService;
    @RequestMapping(value = "getRecipeMasterList" , method = RequestMethod.GET)
    @ResponseBody
@ -264,6 +268,11 @@ public class PrescriptionInfoController extends BaseController {
                jo.put("dispensaryDispensaryTypeName", prescription.getDispensaryTypeName());//处方配送方式
                jo.put("prescriptionStatus", prescription.getStatus());//处方状态
                jo.put("prescriptionStatusName", prescription.getStatusName(prescription.getStatus(), "",""));//处方状态名称
                Patient p =  patientService.findByCode(prescription.getPatient());
                jo.put("patient",p.getCode());
                jo.put("patientName",p.getName());
                jo.put("IdCard",p.getIdcard());
                jo.put("ssc",p.getSsc());
            }
            return write(200, "查询成功", "data", jo);
        } catch (Exception e) {

+ 13 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionLogController.java

@ -1,9 +1,11 @@
package com.yihu.wlyy.web.doctor.prescription;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressageLog;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageLogService;
import com.yihu.wlyy.service.app.prescription.PrescriptionLogService;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
@ -32,6 +34,8 @@ public class PrescriptionLogController extends BaseController {
    private PrescriptionLogService prescriptionLogService;
    @Autowired
    private PrescriptionExpressageLogService prescriptionExpressageLogService;
    @Autowired
    private PrescriptionService prescriptionService;
    @RequestMapping(value = "/getPrescriptionLogs", method = RequestMethod.GET)
    @ApiOperation(value = "获取处方流程")
@ -125,6 +129,15 @@ public class PrescriptionLogController extends BaseController {
                    JSONObject jo = new JSONObject();
                    jo.put("createTime", DateUtil.dateToStrLong(one.getCreateTime()));
                    jo.put("statusName", one.getStatusName());
                    jo.put("drugDeliveryflag", "0");
                    if(one.getStatus()==100){
                        Prescription prescription = prescriptionService.findByCode(one.getPrescriptionCode());
                        if(prescription!=null&&prescription.getDrugDeliveryflag()==1){
                            jo.put("drugDeliveryflag", "1");
                            jo.put("drugDeliveryOperatorName",prescription.getDrugDeliveryOperatorName());
                            jo.put("drugDelivery",prescription.getDrugDeliveryReasonValue()+","+prescription.getDrugDeliveryReason());
                        }
                    }
                    ja.put(jo);
                }
                return write(200, "获取处方流程成功", "data", ja);

+ 135 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java

@ -34,6 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.RequestMapping;
@ -81,6 +82,8 @@ public class OnePayController extends WeixinBaseController {
    private HospitalMappingDao mappingDao;
    @Autowired
    ObjectMapper objectMapper;
    @Autowired
    JdbcTemplate jdbcTemplate;
    @RequestMapping(value = "bindCard", method = RequestMethod.POST)
    @ApiOperation("查询绑卡信息")
@ -289,15 +292,15 @@ public class OnePayController extends WeixinBaseController {
    }
    /**
     * 页面回调更新数据
     * 页面回调更新数据(v1.4.0 作废)
     *
     * @param request
     * @param response
     * @throws IOException
     * @throws PayException
     */
    @RequestMapping(value = "/returnUrl")
    public void returnUrl(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
    @RequestMapping(value = "/returnUrlBak")
    public void returnUrlBak(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
        PayConfigura config = configuraDao.findWorkConfigura();
        Boolean isSuccess = false;
@ -437,15 +440,49 @@ public class OnePayController extends WeixinBaseController {
    }
    /**
     * 支付真正完成,异步回调返回支付参数 后台做数据操作
     * 页面回调更新数据
     *
     * @param request
     * @param response
     * @throws IOException
     * @throws PayException
     */
    @RequestMapping(value = "/receiveNotify")
    public void receiveNotify(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
    @RequestMapping(value = "/returnUrl")
    public void returnUrl(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
        PayConfigura config = configuraDao.findWorkConfigura();
        Boolean isSuccess = false;
        String error = "";
        String responses = "";
        response.setContentType("text/html;charset=utf-8");
        try {
            //		如:查询显示订单信息
            isSuccess = true;
            String outChargeNo = request.getParameter("outChargeNo");//接入应用业务流水号
            pay.chargeQuery(outChargeNo, getAccessToken());//业务出参
        } catch (Exception e) {
            isSuccess = false;
            response.getWriter().write(e.getMessage());
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            error = sw.toString();
        }
        //                记录log日志到数据库
        logService.saveHttpLog(isSuccess, config.getReturnUrl(), "支付页面跳转", "POST", null, "", responses, error, logService.onepayType);
    }
    /**
     * 支付真正完成,异步回调返回支付参数 后台做数据操作(v1.4.0作废)
     *
     * @param request
     * @param response
     * @throws IOException
     * @throws PayException
     */
    @RequestMapping(value = "/receiveNotifyBak")
    public void receiveNotifyBak(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
        PayConfigura config = configuraDao.findWorkConfigura();
        Boolean isSuccess = false;
@ -617,6 +654,74 @@ public class OnePayController extends WeixinBaseController {
        logService.saveHttpLog(isSuccess, config.getReceiveNotify(), "异步支付通知", "POST", null, params, responses, error, logService.onepayType);
    }
    /**
     * 支付真正完成,异步回调返回支付参数 后台做数据操作
     *
     * @param request
     * @param response
     * @throws IOException
     * @throws PayException
     */
    @RequestMapping(value = "/receiveNotify")
    public void receiveNotify(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
        PayConfigura config = configuraDao.findWorkConfigura();
        Boolean isSuccess = false;
        String error = "";
        String responses = "";
        response.setContentType("text/html;charset=utf-8");
        InputStream inputStream = request.getInputStream();
        String params = StreamUtils.copyToString(inputStream, Charset.forName("UTF-8"));
        try {
            JSONObject json = new JSONObject(params);
            String appId = json.getString("appId");
            HospitalMapping hospital = mappingDao.findByAppId(appId);
            String appSecret = hospital.getAppSecret();
            LOGGER.info("回调参数:{}", params);
            if (StringUtil.isEmpty(params)) {
                response.getWriter().write("empty");
                return;
            }
            // 参数转换
            ResponseParams<?> encryptRes = JSON.parseObject(params, ResponseParams.class);
            OnepayDefaultClient client = new OnepayDefaultClient("", appId, appSecret, encryptRes.getSignType(), encryptRes.getEncryptType());
            LOGGER.info("解密前:{}", JSON.toJSONString(encryptRes));
            ResponseParams<?> decryptRes = client.decryptNotifyResponse(encryptRes);
            LOGGER.info("解密后:{}", JSON.toJSONString(decryptRes));
            boolean isDecrypt = ("-1".equals(decryptRes.getRespCode()) ? false : true); // 是否解密失败
            if (!isDecrypt) {
                response.getWriter().write("DECRYPT FAILURE");
            } else {
                boolean isVerify = client.verifyResponseSign(decryptRes);
                LOGGER.info("验签结果:{}", isVerify);
                if (!isVerify) {
                    response.getWriter().write("FAILURE");
                } else {
//					业务逻辑代码
                    isSuccess = true;
                    responses = JSON.toJSONString(decryptRes);
                    JSONObject requestParam = new JSONObject(responses);//业务出参
                    JSONObject responseParam = requestParam.getJSONObject("param");
                    Charge chargeView = objectMapper.readValue(responseParam.toString(), Charge.class);
                    pay.saveToWlyyCharge(chargeView);
                    response.getWriter().write("SUCCESS");
                }
            }
        } catch (Exception e) {
            response.getWriter().write(e.getMessage());
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            error = sw.toString();
        }
        //                记录log日志到数据库
        logService.saveHttpLog(isSuccess, config.getReceiveNotify(), "异步支付通知", "POST", null, params, responses, error, logService.onepayType);
    }
    /**
     * 获取按月缴费总金额
     *
@ -641,4 +746,28 @@ public class OnePayController extends WeixinBaseController {
            return write(-1, "查询签约金额失败!");
        }
    }
    /**
     * 支付数据整理
     *
     * @throws IOException
     * @throws PayException
     */
    @RequestMapping(value = "/cleaData", method = RequestMethod.POST)
    @ApiOperation("支付数据整理")
    @ResponseBody
    public String cleaData() throws IOException, PayException {
        try {
            String sql = "SELECT t.code FROM wlyy_charge t WHERE (t.need_upload != '0' OR t.need_upload is null) AND (t.trade_status = '0' OR t.trade_status = '1')";
            List<Map<String, Object>> codes = jdbcTemplate.queryForList(sql);
            for (Map<String, Object> code :codes) {
                String outChargeNo = code.get("code").toString();
                pay.chargeQuery(outChargeNo,getAccessToken());
            }
            return write(200, "数据整理成功!");
        } catch (Exception e) {
            return write(-1, "数据整理成功失败!");
        }
    }
}