Explorar o código

Merge branch 'medicare' of liubing/wlyy2.0 into medicare

liubing %!s(int64=2) %!d(string=hai) anos
pai
achega
401824bdf1

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/healthCare/YlzMedicalRelationDO.java

@ -81,7 +81,7 @@ public class YlzMedicalRelationDO extends UuidIdentityEntity {
    private String otherPay;//其中:其他基金支付
    private String enterpriseSupplement;//其中:企业补充
    private String jtgjPay;//家庭共济账户支付
    private String collector;//收费人
    private String collector;//收费人 //开单医生编码
    private String pageCode;//结算code
    private String insuranceType;//险种类型(医保类型)
    private String insuranceTypeName;//险种类型名称

+ 33 - 5
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineOrderDrugsEndpoint.java

@ -41,6 +41,28 @@ public class MedicineOrderDrugsEndpoint extends EnvelopRestEndpoint {
        return failed(map.get("failed").toString());
    }
    @GetMapping("/open/readCardInfo")
    @ApiOperation(value = "封装读卡参数,患者用医保凭证是改接口与getSettlementInfoList前调用", notes = "封装读卡参数")
    public Envelop readCardInfo(
            @ApiParam(name = "orgCode", value = "orgCode")
            @RequestParam(value = "orgCode", required = true) String orgCode,
            @ApiParam(name = "mdtrt_cert_type", value = "凭证类型01扫医保凭证02身份证03医保卡")
            @RequestParam(value = "mdtrt_cert_type", defaultValue = "01",required = false) String mdtrt_cert_type,
            @ApiParam(name = "cardNo", value = "卡识别码")
            @RequestParam(value = "cardNo", required = false) String cardNo,
            @ApiParam(name = "card_sn", value = "卡识别码")
            @RequestParam(value = "card_sn", required = false) String card_sn,
            @ApiParam(name = "idcard", value = "身份证")
            @RequestParam(value = "idcard", required = false) String idcard){
        try {
            return success("操作成功", medOrderService.readCardInfo(orgCode,cardNo,card_sn,mdtrt_cert_type,idcard));
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping("/open/getSettlementInfoList")
    @ApiOperation(value = "获取患者待结算信息", notes = "获取患者待结算信息")
    public Envelop getSettlementInfoList(
@ -62,11 +84,15 @@ public class MedicineOrderDrugsEndpoint extends EnvelopRestEndpoint {
    public Envelop getSettlementInfoFirst(
            @ApiParam(name = "recipe_no", value = "recipe_no")
            @RequestParam(value = "recipe_no", required = true) String recipe_no,
            @ApiParam(name = "mdtrt_cert_type", value = "凭证类型01扫医保凭证02身份证03医保卡")
            @RequestParam(value = "mdtrt_cert_type", defaultValue = "03",required = false) String mdtrt_cert_type,
            @ApiParam(name = "card_sn", value = "卡识别码")
            @RequestParam(value = "card_sn", required = false) String card_sn){
            @RequestParam(value = "card_sn", required = false) String card_sn,
            @ApiParam(name = "idcard", value = "身份证")
            @RequestParam(value = "idcard", required = false) String idcard){
        try {
            return success("操作成功", medOrderService.getSettlementInfoFirst(recipe_no,card_sn));
            return success("操作成功", medOrderService.getSettlementInfoFirst(recipe_no,card_sn,mdtrt_cert_type,idcard));
        } catch (Exception e) {
           e.printStackTrace();
            return Envelop.getError(e.getMessage());
@ -109,11 +135,13 @@ public class MedicineOrderDrugsEndpoint extends EnvelopRestEndpoint {
    @GetMapping("/open/executeSickSettleMultiNew")
    @ApiOperation(value = "续方确认结算-智业", notes = "续方确认结算-智业")
    public Envelop getSettlementInfo(
    public Envelop executeSickSettleMultiNew(
            @ApiParam(name = "recipe_no", value = "处方号")
            @RequestParam(value = "recipe_no", required = true) String recipe_no){
            @RequestParam(value = "recipe_no", required = true) String recipe_no,
            @ApiParam(name="equ_num",value="药柜设备号",defaultValue = "")
            @RequestParam(value = "equ_num",required = true) String equ_num){
        try {
            return success("结算成功", medOrderService.executeSickSettleMultiNew(recipe_no));
            return success("结算成功", medOrderService.executeSickSettleMultiNew(recipe_no,equ_num));
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());

+ 57 - 28
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/JwService.java

@ -1,6 +1,5 @@
package com.yihu.jw.base.service.a3service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalIcdDO;
@ -8,13 +7,11 @@ import com.yihu.jw.entity.hospital.healthCare.YlzMedicalMxDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalResponse;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.hospital.healthCare.YlzMedicailIcdDao;
import com.yihu.jw.hospital.healthCare.YlzMedicailMxDao;
import com.yihu.jw.hospital.healthCare.YlzMedicailRelationDao;
import com.yihu.jw.hospital.healthCare.YlzMedicalResponseDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wlyy.wlyyhttp.WlyyHttpService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -83,6 +80,31 @@ public class JwService {
        return re;
    }
    /**
     * 获取结算科室
     * @param equ_num
     * @return
     */
    public JSONObject getSettleDept(String equ_num){
        Map<String,String> param = new HashMap<>();
        param.put("equ_num",equ_num);
        JSONObject re =null;
        if ("jwZnygProd".equals(springProfiles)){
            re = wlyyHttpService.sendWlyyMes("getSettleDept_OUT", null,param);
        } else {
            re = wlyyHttpService.sendWlyyMes("getSettleDept", null,param);
        }
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        wlyyHttpLogDO.setCode("getSettleDept");
        wlyyHttpLogDO.setRequest(param.toString());
        wlyyHttpLogDO.setResponse(re.toJSONString());
        wlyyHttpLogDO.setName("获取结算科室");
        wlyyHttpLogDO.setStatus("1");
        wlyyHttpLogDO.setCreateTime(new Date());
        httpLogDao.save(wlyyHttpLogDO);
        return re;
    }
    /**
     * 获取预缴金余额
     * @param cardNo 卡号
@ -124,7 +146,7 @@ public class JwService {
     */
    @Transactional(propagation= Propagation.NOT_SUPPORTED)
    public boolean executeSickSettleMultiNew(String recipe_no) throws Exception {
    public boolean executeSickSettleMultiNew(String recipe_no,String equ_num) throws Exception {
        String   sql = " select dict_code,dict_value from wlyy_hospital_sys_dict where dict_name='his_settlement' ";
        List<Map<String,Object>> AnalogFlags = jdbcTemplate.queryForList(sql);
        String AnalogFlag = "0";
@ -155,8 +177,17 @@ public class JwService {
        JSONArray insurVisitInfo = new JSONArray();
        JSONArray insurResult = new JSONArray(); //自费病人没有产生医保收费记录,insurResult节点不传自费结算信息
        msgBody.put("cardNo",ylzMedicalRelationDO.getCardNo());//病人卡号
        msgBody.put("settleDept",ylzMedicalRelationDO.getDeptCode());//结算科室编码
        msgBody.put("settleOperator",ylzMedicalRelationDO.getCollector());//结算人员编码
        /**
         * 获取结算科室编码
         */
        JSONObject settleDeptResponse  = getSettleDept(equ_num);
        if (settleDeptResponse.getString("status").equalsIgnoreCase("200")) {
            JSONObject settleDeptObj = settleDeptResponse.getJSONObject("data");
            msgBody.put("settleDept",settleDeptObj.getString("settleDept"));//结算科室编码
            msgBody.put("settleOperator",settleDeptObj.getString("settleOperator"));//结算人员编码
        }else {
            throw new Exception("未找到结算科室编码");
        }
        msgBody.put("visitNo","");//结算人员编码
        if (0==ylzMedicalRelationDO.getMedicalState()){//自费
@ -248,9 +279,9 @@ public class JwService {
                        JSONObject outPutSetldetailTmp = outPutSetldetail.getJSONObject(j);
                        JSONObject setldetailTmp = new JSONObject();
                        setldetailTmp.put("fund_pay_type",null==outPutSetldetailTmp.get("fund_pay_type")?"":outPutSetldetailTmp.get("fund_pay_type").toString());  //基金支付类型
                        setldetailTmp.put("inscp_scp_amt",null==outPutSetldetailTmp.get("inscp_scp_amt")?"":outPutSetldetailTmp.get("inscp_scp_amt").toString());  //符合政策范围金额
                        setldetailTmp.put("crt_payb_lmt_amt",null==outPutSetldetailTmp.get("crt_payb_lmt_amt")?"":outPutSetldetailTmp.get("crt_payb_lmt_amt").toString());   //本次可支付限额金额
                        setldetailTmp.put("fund_payamt",null==outPutSetldetailTmp.get("fund_payamt")?"":outPutSetldetailTmp.get("fund_payamt").toString());    //基金支付金额
                        setldetailTmp.put("inscp_scp_amt",null==outPutSetldetailTmp.get("inscp_scp_amt")?"0":outPutSetldetailTmp.get("inscp_scp_amt").toString());  //符合政策范围金额
                        setldetailTmp.put("crt_payb_lmt_amt",null==outPutSetldetailTmp.get("crt_payb_lmt_amt")?"0":outPutSetldetailTmp.get("crt_payb_lmt_amt").toString());   //本次可支付限额金额
                        setldetailTmp.put("fund_payamt",null==outPutSetldetailTmp.get("fund_payamt")?"0":outPutSetldetailTmp.get("fund_payamt").toString());    //基金支付金额
                        setldetailTmp.put("fund_pay_type_name",null==outPutSetldetailTmp.get("fund_pay_type_name")?"":outPutSetldetailTmp.get("fund_pay_type_name").toString()); //基金支付类型名称
                        setldetailTmp.put("setl_proc_info",null==outPutSetldetailTmp.get("setl_proc_info")?"":outPutSetldetailTmp.get("setl_proc_info").toString()); //结算过程信息
                        setldetail.add(setldetailTmp);
@ -263,11 +294,11 @@ public class JwService {
                        JSONObject fpdetailTmp  = new JSONObject();
                        fpdetailTmp.put("chrgitmType",null==fplistTmp.get("medChrgitmType")?"":fplistTmp.get("medChrgitmType").toString()); //发票项目类别
                        fpdetailTmp.put("chrgitmTypeName",null==fplistTmp.get("medChrgitmName")?"":fplistTmp.get("medChrgitmName").toString());  //发票项目类别名称
                        fpdetailTmp.put("itemSumamt",null==fplistTmp.get("itemSumamt")?"":fplistTmp.get("itemSumamt").toString());   //发票项目费用
                        fpdetailTmp.put("itemClaaAmt",null==fplistTmp.get("itemClaaAmt")?"":fplistTmp.get("itemClaaAmt").toString());  //医保发票费用
                        fpdetailTmp.put("itemClabAmt",null==fplistTmp.get("itemClabAmt")?"":fplistTmp.get("itemClabAmt").toString());  //医保个人费用
                        fpdetailTmp.put("itemOthAmt",null==fplistTmp.get("itemOthAmt")?"":fplistTmp.get("itemOthAmt").toString());   //特殊项目发票费用
                        fpdetailTmp.put("itemOwnpayAmt",null==fplistTmp.get("itemOwnpayAmt")?"":fplistTmp.get("itemOwnpayAmt").toString());    //非医保发票费用
                        fpdetailTmp.put("itemSumamt",null==fplistTmp.get("itemSumamt")?"0":fplistTmp.get("itemSumamt").toString());   //发票项目费用
                        fpdetailTmp.put("itemClaaAmt",null==fplistTmp.get("itemClaaAmt")?"0":fplistTmp.get("itemClaaAmt").toString());  //医保发票费用
                        fpdetailTmp.put("itemClabAmt",null==fplistTmp.get("itemClabAmt")?"0":fplistTmp.get("itemClabAmt").toString());  //医保个人费用
                        fpdetailTmp.put("itemOthAmt",null==fplistTmp.get("itemOthAmt")?"0":fplistTmp.get("itemOthAmt").toString());   //特殊项目发票费用
                        fpdetailTmp.put("itemOwnpayAmt",null==fplistTmp.get("itemOwnpayAmt")?"0":fplistTmp.get("itemOwnpayAmt").toString());    //非医保发票费用
                        fpdetail.add(fpdetailTmp);
                    }
@ -308,14 +339,24 @@ public class JwService {
            }
        }
        JSONObject insurVisitTmp = new JSONObject();
        insurVisitTmp.put("visit_msgid",ylzMedicalRelationDO.getHisSettleNo());//发送方报文ID"
        insurVisitTmp.put("visit_msgid",ylzMedicalRelationDO.getVisitMsgid());//发送方报文ID"
        insurVisitTmp.put("insuplc_admdvs",ylzMedicalRelationDO.getRegionCode());//参保地医保区划【窗口冲销有用】
        insurVisitTmp.put("insutype","310");//险种类型【挂号时用的险种,医保目前以此为准】
        insurVisitTmp.put("mdtrt_id",ylzMedicalRelationDO.getHisSerial());//就诊ID  医保挂号接口返回
        insurVisitTmp.put("psn_no",ylzMedicalRelationDO.getPsnNo());//人员编号   医保人员基本信息获取接口返回
        insurVisitTmp.put("ipt_otp_no",ylzMedicalRelationDO.getRelationCode());//门诊号
        insurVisitTmp.put("exp_content","");//字段扩展【应需要解决转义字符反斜杠被过滤问题,否则要将里面的扩展节点独立字段出
        insurVisitInfo.add(insurVisitTmp);
        sql = " select dict_code,dict_value from wlyy_hospital_sys_dict where dict_name='insurVisitInfo' ";
        AnalogFlags = jdbcTemplate.queryForList(sql);
        AnalogFlag = "0";
        if (AnalogFlags.size()>0){
            AnalogFlag = AnalogFlags.get(0).get("dict_code").toString();
        }
        if ("1".equals(AnalogFlag)) {//获取调式模拟数据
        }else {
            insurVisitInfo.add(insurVisitTmp);
        }
        msgBody.put("insurVisitInfo",insurVisitInfo);
        Map<String,String> param = new HashMap<>();
@ -485,16 +526,4 @@ public class JwService {
        httpLogDao.save(wlyyHttpLogDO);
        return re;
    }
    public static void main(String[] args) {
        JSONObject object = new JSONObject();
        object.put("deviceId","14912202111000001000000000000000");
        object.put("pickUpNum","70214");
        try {
            System.out.println(object.toJSONString());
            System.out.println(AesEncryptUtils.agEncrypt(object.toJSONString()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

+ 226 - 133
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedOrderService.java

@ -171,6 +171,78 @@ public class MedOrderService {
        return null;
    }
    public JSONObject readCardInfo(String orgCode,String cardNo ,String card_sn,String mdtrt_cert_type,String idcard) throws Exception {
        JSONObject result = new JSONObject();
        String sql = " select dp.* from t_mediicine_device de INNER JOIN t_mediicine_device_param dp on de.id = dp.device_id  " +
                "where de.del=1 and dp.del=1 and de.belong_community='"+orgCode+"' ";
        List<Map<String,Object>> deviceParams =  jdbcTemplate.queryForList(sql);
        if (deviceParams.size()==0){
            throw new Exception("药柜参数获取错误");
        }
        Map<String,Object> deviceParam = deviceParams.get(0);
        JSONObject strinObj = JSONObject.parseObject(deviceParam.get("yb_strin").toString());
        JSONObject netData = new JSONObject();
        netData.put("opter","010XXX");
        netData.put("msgid",strinObj.getString("outBizNo")+ DateUtil.getYyyymmddhhmmss(new Date()));
        netData.put("opmsgidter","123123");
        netData.put("fixmedins_code",strinObj.getString("outBizNo"));
        netData.put("opter_name","XX");
        netData.put("infver","V1.0");
        netData.put("opter_type","1");
        netData.put("mdtrtarea_admvs","350200");
        netData.put("fixmedins_name","XX");
        netData.put("signtype","SM2");
        netData.put("recer_sys_code","0");
        netData.put("dev_no",strinObj.getString("serialNo"));
        JSONObject input = new JSONObject();
        JSONObject inputDetail = new JSONObject();
        JSONObject dataDetail = new JSONObject();
        inputDetail.put("mdtrt_cert_type",mdtrt_cert_type);
        if ("01".equals(mdtrt_cert_type)){
        }else if ("02".equals(mdtrt_cert_type)){
            inputDetail.put("mdtrt_cert_no",idcard);
        }
        else if ("03".equals(mdtrt_cert_type)){//社保卡时需要传入卡识别码
            inputDetail.put("mdtrt_cert_no",cardNo);
            if (StringUtils.isNotBlank(card_sn)){
                inputDetail.put("card_sn",card_sn);
            }else{
                sql = " select dict_code,dict_value from wlyy_hospital_sys_dict where dict_name='ylz_card_sn' ";
                List<Map<String,Object>> AnalogFlags = jdbcTemplate.queryForList(sql);
                String AnalogFlag = "0";
                inputDetail.put("mdtrt_cert_no",cardNo);
                if (AnalogFlags.size()>0){
                    AnalogFlag = AnalogFlags.get(0).get("dict_code").toString();
                }
                if ("1".equals(AnalogFlag)) {//获取调式模拟数据
                    card_sn = AnalogFlags.get(0).get("dict_value").toString();
                    inputDetail.put("card_sn",card_sn);
                }else {
                    throw new Exception("卡识别码未传入");
                }
            }
        }
        input.put("data",inputDetail);
        dataDetail.put("input",input);
        dataDetail.put("net_data",netData);
        strinObj.put("func","fsi.terminal.readcard");
        strinObj.put("data",dataDetail);
        result.put("readcardParam",strinObj.toJSONString());
        WlyyHttpLogDO logDO = new WlyyHttpLogDO();
        logDO.setCode("fsi.terminal.readcard");
        logDO.setName("药柜医保读卡请求参数");
        logDO.setPatient(inputDetail.getString("mdtrt_cert_no"));
        logDO.setRequest(strinObj.toJSONString());
        logDO.setResponse(null);
        logDO.setCreateTime(new Date());
        httpLogDao.save(logDO);
        return result;
    }
    /**
     * 获取患者待结算信息
     * 医保个人信息、挂号接口封装
@ -220,7 +292,7 @@ public class MedOrderService {
     * @throws Exception
     */
    @Transactional(rollbackFor = Exception.class)
    public com.alibaba.fastjson.JSONArray getSettlementInfoFirst(String recipe_no,String card_sn) throws Exception {
    public com.alibaba.fastjson.JSONArray getSettlementInfoFirst(String recipe_no,String card_sn,String mdtrt_cert_type,String idcard) throws Exception {
        JSONArray result = new JSONArray();
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLog_no(recipe_no);
        if (null==ylzMedicalRelationDO){
@ -279,25 +351,37 @@ public class MedOrderService {
        JSONObject input = new JSONObject();
        JSONObject inputDetail = new JSONObject();
        JSONObject dataDetail = new JSONObject();
        inputDetail.put("mdtrt_cert_type","03");
        inputDetail.put("mdtrt_cert_no",cardNo);
        if (StringUtils.isNotBlank(card_sn)){
            inputDetail.put("card_sn",card_sn);
        }else {
            sql = " select dict_code,dict_value from wlyy_hospital_sys_dict where dict_name='ylz_card_sn' ";
            List<Map<String,Object>> AnalogFlags = jdbcTemplate.queryForList(sql);
            String AnalogFlag = "0";
            if (AnalogFlags.size()>0){
                AnalogFlag = AnalogFlags.get(0).get("dict_code").toString();
            }
            if ("1".equals(AnalogFlag)) {//获取调式模拟数据
                card_sn = AnalogFlags.get(0).get("dict_value").toString();
        inputDetail.put("mdtrt_cert_type",mdtrt_cert_type);
        if ("01".equals(mdtrt_cert_type)){
        }else if ("02".equals(mdtrt_cert_type)){
            inputDetail.put("mdtrt_cert_no",idcard);
        }
        else if ("03".equals(mdtrt_cert_type)){//社保卡时需要传入卡识别码
            inputDetail.put("mdtrt_cert_no",cardNo);
            if (StringUtils.isNotBlank(card_sn)){
                inputDetail.put("card_sn",card_sn);
            }else {
                throw new Exception("卡识别码未传入");
            }else{
                sql = " select dict_code,dict_value from wlyy_hospital_sys_dict where dict_name='ylz_card_sn' ";
                List<Map<String,Object>> AnalogFlags = jdbcTemplate.queryForList(sql);
                String AnalogFlag = "0";
                inputDetail.put("mdtrt_cert_no",cardNo);
                if (AnalogFlags.size()>0){
                    AnalogFlag = AnalogFlags.get(0).get("dict_code").toString();
                }
                if ("1".equals(AnalogFlag)) {//获取调式模拟数据
                    card_sn = AnalogFlags.get(0).get("dict_value").toString();
                    inputDetail.put("card_sn",card_sn);
                }else {
                    throw new Exception("卡识别码未传入");
                }
            }
        }
        ylzMedicalRelationDO.setCardSn(card_sn);
        if (StringUtils.isNotBlank(card_sn)){
            ylzMedicalRelationDO.setCardSn(card_sn);
        }if (StringUtils.isNotBlank(idcard)){
            ylzMedicalRelationDO.setIdcard(idcard);
        }
        ylzMedicailRelationDao.save(ylzMedicalRelationDO);
        input.put("data",inputDetail);
        dataDetail.put("input",input);
@ -331,8 +415,14 @@ public class MedOrderService {
               inputDetail.put("psn_no","");//人员编码  前端封装
               inputDetail.put("insutype","310");
               inputDetail.put("begntime",DateUtil.dateToStrLong(ylzMedicalRelationDO.getDate()));
               inputDetail.put("mdtrt_cert_type","03");
               inputDetail.put("mdtrt_cert_no",cardNo);
               if ("02".equals(mdtrt_cert_type)){
                   inputDetail.put("mdtrt_cert_no",idcard);
               }
               else{
                   inputDetail.put("mdtrt_cert_no",cardNo);
               }
               inputDetail.put("mdtrt_cert_type",mdtrt_cert_type);
               inputDetail.put("ipt_otp_no",ylzMedicalRelationDO.getRelationCode());
               inputDetail.put("atddr_no",ylzMedicalRelationDO.getAtddrNo());
               inputDetail.put("dr_name",ylzMedicalRelationDO.getDrName());
@ -453,7 +543,7 @@ public class MedOrderService {
                throw new Exception("医保挂号接口失败"+registerObject.getString("retCode"));
            }
        }
        ylzMedicailRelationDao.save(ylzMedicalRelationDO);
        ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
        if (0==ylzMedicalRelationDO.getMedicalState()){
            resultTmp.put("needCharge",false);
            result.add(resultTmp);
@ -788,7 +878,6 @@ public class MedOrderService {
                                        deptCode = visitDetail.getString("VISIT_DEPT");
                                        deptName = visitDetail.getString("VISIT_DEPT_NAME");
                                        //收费明细
                                        JSONArray SETTLE_DETAILS = visitDetail.getJSONArray("SETTLE_DETAIL");
                                        if (SETTLE_DETAILS!=null&&SETTLE_DETAILS.size()>0) {
@ -801,6 +890,7 @@ public class MedOrderService {
                                            }
                                            ylzMedicalRelationDO = ylzMedicailRelationDao.findByLog_no(prescription_code);
                                            //新的记录
                                            if (null==ylzMedicalRelationDO){
                                                newYlzRelation = true;
                                                ylzMedicalRelationDO = new YlzMedicalRelationDO();
@ -808,79 +898,80 @@ public class MedOrderService {
                                                ylzMedicalRelationDO.setStatus(0);
                                                ylzMedicalRelationDO.setState(0);
                                                ylzMedicalRelationDO =  ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                                            }
                                            if (!newYlzRelation){
                                                ylzMedicailMxDao.deleteByMedicalId(ylzMedicalRelationDO.getId());
                                            }
                                            for (int j = 0; j < SETTLE_DETAILS.size(); j++) {
                                                SETTLE_DETAIL_OBJ = SETTLE_DETAILS.getJSONObject(j);
                                                YlzMedicalMxDO ylzMedicalMxDO = new YlzMedicalMxDO();
                                                ylzMedicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());//医保关联表id
                                                ylzMedicalMxDO.setPrescriptionCode(prescription_code);//处方code
                                                ylzMedicalMxDO.setHisDetailSn(SETTLE_DETAIL_OBJ.getString("feedetl_sn"));//his处方明细流水号
                                                ylzMedicalMxDO.setItemCode(SETTLE_DETAIL_OBJ.getString("INSUR_ITEM_CODE"));//医保项目编码
                                                ylzMedicalMxDO.setItemName(SETTLE_DETAIL_OBJ.getString("INSUR_ITEM_NAME"));//医保项目名称
                                                ylzMedicalMxDO.setInvoiceType(SETTLE_DETAIL_OBJ.getString("INSUR_INVOICE_TYPE_CODE"));//发票项目类别
                                                ylzMedicalMxDO.setSpecificationType(SETTLE_DETAIL_OBJ.getString("ITEM_SPEC"));//规格型号
                                                ylzMedicalMxDO.setDosageForm(SETTLE_DETAIL_OBJ.getString("PHYSIC_FORM"));//剂型
                                                ylzMedicalMxDO.setChargeUnit(SETTLE_DETAIL_OBJ.getString("ITEM_UNIT"));//单位
                                                ylzMedicalMxDO.setChargeUnitName(SETTLE_DETAIL_OBJ.getString("ITEM_UNIT_NAME"));//单位名称
                                                ylzMedicalMxDO.setPrice(null==SETTLE_DETAIL_OBJ.get("INSUR_ITEM_PRICE")?"0.0":SETTLE_DETAIL_OBJ.getString("INSUR_ITEM_PRICE"));//单价
                                                ylzMedicalMxDO.setAmount(SETTLE_DETAIL_OBJ.getString("ITEM_QUANTITY"));//数量
                                                ylzMedicalMxDO.setTotalMoney(amountDf.format(Double.valueOf(SETTLE_DETAIL_OBJ.getString("COST"))));//金额
                                                totalAmount +=Double.valueOf(SETTLE_DETAIL_OBJ.getString("COST"));
                                                ownPay +=Double.valueOf(SETTLE_DETAIL_OBJ.getString("CHARGE"));
                                                if (null!=SETTLE_DETAIL_OBJ.get("INSUR_ITEM_PRICE")){
                                                    INSUR_ITEM_PRICE += Double.valueOf(SETTLE_DETAIL_OBJ.getString("INSUR_ITEM_PRICE"));//医保项目单价
                                                }
                                                ylzMedicalMxDO.setSingleDose(SETTLE_DETAIL_OBJ.getString("PHYSIC_DOSE"));//每次用量
                                                ylzMedicalMxDO.setUseFrequency(SETTLE_DETAIL_OBJ.getString("FREQUENCY"));//使用频率
                                                ylzMedicalMxDO.setMedicalWay(SETTLE_DETAIL_OBJ.getString("PHYSIC_USAGE"));//给药途径
                                                ylzMedicalMxDO.setPrescriptionDate(SETTLE_DETAIL_OBJ.getDate("prescription_date"));//处方日期
                                                ylzMedicalMxDO.setMedicationDays(SETTLE_DETAIL_OBJ.getString("DAY_COUNT"));//执行天数
                                                ylzMedicalMxDO.setDeptCode(SETTLE_DETAIL_OBJ.getString("APPLY_DEPT"));//科室编码
                                                ylzMedicalMxDO.setDeptName(SETTLE_DETAIL_OBJ.getString("APPLY_DEPT_NAME"));//科室名称
                                                ylzMedicalMxDO.setHisDeptCode(SETTLE_DETAIL_OBJ.getString("APPLY_DEPT"));//his内部科室编码
                                                ylzMedicalMxDO.setHisDeptName(SETTLE_DETAIL_OBJ.getString("APPLY_DEPT_NAME"));//his内部科室名称
                                                if (StringUtils.isBlank(hisDeptCode)){
                                                    hisDeptCode = SETTLE_DETAIL_OBJ.getString("APPLY_DEPT");
                                                }
                                                if (StringUtils.isBlank(APPLY_TIME)){
                                                    APPLY_TIME = SETTLE_DETAIL_OBJ.getString("APPLY_TIME");
                                                }
                                                if (StringUtils.isBlank(hisDeptName)){
                                                    hisDeptName = SETTLE_DETAIL_OBJ.getString("APPLY_DEPT_NAME");
                                                }
                                                ylzMedicalMxDO.setMedicalPerName(SETTLE_DETAIL_OBJ.getString("APPLY_OPERATOR_NAME"));//医疗服务人员姓名  开单医生姓名
                                                ylzMedicalMxDO.setMedicalPerId(SETTLE_DETAIL_OBJ.getString("APPLY_OPERATOR"));//医疗服务人员证件号码  开单医生编码
                                                if (StringUtils.isBlank(collector)){
                                                    collector = SETTLE_DETAIL_OBJ.getString("APPLY_OPERATOR");
                                                for (int j = 0; j < SETTLE_DETAILS.size(); j++) {
                                                    SETTLE_DETAIL_OBJ = SETTLE_DETAILS.getJSONObject(j);
                                                    YlzMedicalMxDO ylzMedicalMxDO = new YlzMedicalMxDO();
                                                    ylzMedicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());//医保关联表id
                                                    ylzMedicalMxDO.setPrescriptionCode(prescription_code);//处方code
                                                    ylzMedicalMxDO.setHisDetailSn(SETTLE_DETAIL_OBJ.getString("feedetl_sn"));//his处方明细流水号
                                                    ylzMedicalMxDO.setItemCode(SETTLE_DETAIL_OBJ.getString("INSUR_ITEM_CODE"));//医保项目编码
                                                    ylzMedicalMxDO.setItemName(SETTLE_DETAIL_OBJ.getString("INSUR_ITEM_NAME"));//医保项目名称
                                                    ylzMedicalMxDO.setInvoiceType(SETTLE_DETAIL_OBJ.getString("INSUR_INVOICE_TYPE_CODE"));//发票项目类别
                                                    ylzMedicalMxDO.setSpecificationType(SETTLE_DETAIL_OBJ.getString("ITEM_SPEC"));//规格型号
                                                    ylzMedicalMxDO.setDosageForm(SETTLE_DETAIL_OBJ.getString("PHYSIC_FORM"));//剂型
                                                    ylzMedicalMxDO.setChargeUnit(SETTLE_DETAIL_OBJ.getString("ITEM_UNIT"));//单位
                                                    ylzMedicalMxDO.setChargeUnitName(SETTLE_DETAIL_OBJ.getString("ITEM_UNIT_NAME"));//单位名称
                                                    ylzMedicalMxDO.setPrice(null==SETTLE_DETAIL_OBJ.get("INSUR_ITEM_PRICE")?"0.0":SETTLE_DETAIL_OBJ.getString("INSUR_ITEM_PRICE"));//单价
                                                    ylzMedicalMxDO.setAmount(SETTLE_DETAIL_OBJ.getString("ITEM_QUANTITY"));//数量
                                                    ylzMedicalMxDO.setTotalMoney(amountDf.format(Double.valueOf(SETTLE_DETAIL_OBJ.getString("COST"))));//金额
                                                    totalAmount +=Double.valueOf(SETTLE_DETAIL_OBJ.getString("COST"));
                                                    ownPay +=Double.valueOf(SETTLE_DETAIL_OBJ.getString("CHARGE"));
                                                    if (null!=SETTLE_DETAIL_OBJ.get("INSUR_ITEM_PRICE")){
                                                        INSUR_ITEM_PRICE += Double.valueOf(SETTLE_DETAIL_OBJ.getString("INSUR_ITEM_PRICE"));//医保项目单价
                                                    }
                                                    ylzMedicalMxDO.setSingleDose(SETTLE_DETAIL_OBJ.getString("PHYSIC_DOSE"));//每次用量
                                                    ylzMedicalMxDO.setUseFrequency(SETTLE_DETAIL_OBJ.getString("FREQUENCY"));//使用频率
                                                    ylzMedicalMxDO.setMedicalWay(SETTLE_DETAIL_OBJ.getString("PHYSIC_USAGE"));//给药途径
                                                    ylzMedicalMxDO.setPrescriptionDate(SETTLE_DETAIL_OBJ.getDate("prescription_date"));//处方日期
                                                    ylzMedicalMxDO.setMedicationDays(SETTLE_DETAIL_OBJ.getString("DAY_COUNT"));//执行天数
                                                    ylzMedicalMxDO.setDeptCode(SETTLE_DETAIL_OBJ.getString("APPLY_DEPT"));//科室编码
                                                    ylzMedicalMxDO.setDeptName(SETTLE_DETAIL_OBJ.getString("APPLY_DEPT_NAME"));//科室名称
                                                    ylzMedicalMxDO.setHisDeptCode(SETTLE_DETAIL_OBJ.getString("APPLY_DEPT"));//his内部科室编码
                                                    ylzMedicalMxDO.setHisDeptName(SETTLE_DETAIL_OBJ.getString("APPLY_DEPT_NAME"));//his内部科室名称
                                                    if (StringUtils.isBlank(hisDeptCode)){
                                                        hisDeptCode = SETTLE_DETAIL_OBJ.getString("APPLY_DEPT");
                                                    }
                                                    if (StringUtils.isBlank(APPLY_TIME)){
                                                        APPLY_TIME = SETTLE_DETAIL_OBJ.getString("APPLY_TIME");
                                                    }
                                                    if (StringUtils.isBlank(hisDeptName)){
                                                        hisDeptName = SETTLE_DETAIL_OBJ.getString("APPLY_DEPT_NAME");
                                                    }
                                                    ylzMedicalMxDO.setMedicalPerName(SETTLE_DETAIL_OBJ.getString("APPLY_OPERATOR_NAME"));//医疗服务人员姓名  开单医生姓名
                                                    ylzMedicalMxDO.setMedicalPerId(SETTLE_DETAIL_OBJ.getString("APPLY_OPERATOR"));//医疗服务人员证件号码  开单医生编码
                                                    if (StringUtils.isBlank(collector)){
                                                        collector = SETTLE_DETAIL_OBJ.getString("APPLY_OPERATOR");
                                                    }
                                                    ylzMedicalMxDO.setLimitType(SETTLE_DETAIL_OBJ.getString("INSUR_FLAG"));//限制范围类别
                                                    ylzMedicalMxDO.setActgDate(SETTLE_DETAIL_OBJ.getDate("fee_ocur_time"));//记帐日期
                                                    ylzMedicalMxDO.setHisItemCode(SETTLE_DETAIL_OBJ.getString("ITEM_CODE"));//HIS院内项目编码
                                                    ylzMedicalMxDO.setHisItemName(SETTLE_DETAIL_OBJ.getString("ITEM_NAME"));//HIS院内项目名称
                                                    ylzMedicalMxDO.setClerkDays(SETTLE_DETAIL_OBJ.getDate("fee_ocur_time"));//记帐日期
                                                    ylzMedicalMxDO.setPrescriptionDate(visitDate);
                                                    ylzMedicalMxDO.setPeopleType(null);//医保服务人员类别 todo
                                                    ylzMedicalMxDO.setDel(1);
                                                    ylzMedicalMxDO.setCreateTime(new Date());
                                                    ylzMedicalMxDO.setSetlMsgid(SETTLE_DETAIL_OBJ.getString("setl_msgid"));
                                                    ylzMedicalMxDO.setFeeMsgid(SETTLE_DETAIL_OBJ.getString("fee_msgid"));
                                                    ylzMedicalMxDO.setInsurSettleSort(SETTLE_DETAIL_OBJ.getString("INSUR_SETTLE_SORT"));
                                                    ylzMedicalMxDO.setChrgBchno(SETTLE_DETAIL_OBJ.getString("chrg_bchno"));
                                                    ylzMedicalMxDO.setRxCircFlag(SETTLE_DETAIL_OBJ.getString("rx_circ_flag"));
                                                    ylzMedicalMxDO.setBilgDeptCodg(SETTLE_DETAIL_OBJ.getString("bilg_dept_codg"));
                                                    ylzMedicalMxDO.setBilgDeptName(SETTLE_DETAIL_OBJ.getString("bilg_dept_name"));
                                                    ylzMedicalMxDO.setBilgDrCodg(SETTLE_DETAIL_OBJ.getString("APPLY_OPERATOR"));
                                                    ylzMedicalMxDO.setBilgDrName(SETTLE_DETAIL_OBJ.getString("APPLY_OPERATOR_NAME"));
                                                    ylzMedicalMxDO.setHospApprFlag(SETTLE_DETAIL_OBJ.getString("hosp_appr_flag"));
                                                    ylzMedicalMxDO.setRxno(SETTLE_DETAIL_OBJ.getString("APPLY_NO"));
                                                    ylzMedicalMxDO.setPsnSetlway(SETTLE_DETAIL_OBJ.getString("psn_setlway"));
                                                    ylzMedicailMxDao.save(ylzMedicalMxDO);
                                                    mxDOList.add(ylzMedicalMxDO);
                                                }
                                                ylzMedicalMxDO.setLimitType(SETTLE_DETAIL_OBJ.getString("INSUR_FLAG"));//限制范围类别
                                                ylzMedicalMxDO.setActgDate(SETTLE_DETAIL_OBJ.getDate("fee_ocur_time"));//记帐日期
                                                ylzMedicalMxDO.setHisItemCode(SETTLE_DETAIL_OBJ.getString("ITEM_CODE"));//HIS院内项目编码
                                                ylzMedicalMxDO.setHisItemName(SETTLE_DETAIL_OBJ.getString("ITEM_NAME"));//HIS院内项目名称
                                                ylzMedicalMxDO.setClerkDays(SETTLE_DETAIL_OBJ.getDate("fee_ocur_time"));//记帐日期
                                                ylzMedicalMxDO.setPrescriptionDate(visitDate);
                                                ylzMedicalMxDO.setPeopleType(null);//医保服务人员类别 todo
                                                ylzMedicalMxDO.setDel(1);
                                                ylzMedicalMxDO.setCreateTime(new Date());
                                                ylzMedicalMxDO.setSetlMsgid(SETTLE_DETAIL_OBJ.getString("setl_msgid"));
                                                ylzMedicalMxDO.setFeeMsgid(SETTLE_DETAIL_OBJ.getString("fee_msgid"));
                                                ylzMedicalMxDO.setInsurSettleSort(SETTLE_DETAIL_OBJ.getString("INSUR_SETTLE_SORT"));
                                                ylzMedicalMxDO.setChrgBchno(SETTLE_DETAIL_OBJ.getString("chrg_bchno"));
                                                ylzMedicalMxDO.setRxCircFlag(SETTLE_DETAIL_OBJ.getString("rx_circ_flag"));
                                                ylzMedicalMxDO.setBilgDeptCodg(SETTLE_DETAIL_OBJ.getString("bilg_dept_codg"));
                                                ylzMedicalMxDO.setBilgDeptName(SETTLE_DETAIL_OBJ.getString("bilg_dept_name"));
                                                ylzMedicalMxDO.setBilgDrCodg(SETTLE_DETAIL_OBJ.getString("APPLY_OPERATOR"));
                                                ylzMedicalMxDO.setBilgDrName(SETTLE_DETAIL_OBJ.getString("APPLY_OPERATOR_NAME"));
                                                ylzMedicalMxDO.setHospApprFlag(SETTLE_DETAIL_OBJ.getString("hosp_appr_flag"));
                                                ylzMedicalMxDO.setRxno(SETTLE_DETAIL_OBJ.getString("APPLY_NO"));
                                                ylzMedicalMxDO.setPsnSetlway(SETTLE_DETAIL_OBJ.getString("psn_setlway"));
                                                ylzMedicailMxDao.save(ylzMedicalMxDO);
                                                mxDOList.add(ylzMedicalMxDO);
                                            }else {
                                                List<YlzMedicalMxDO> ylzMedicalMxDOList = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
                                                mxDOList.addAll(ylzMedicalMxDOList);
                                            }
                                        }
@ -888,25 +979,27 @@ public class MedOrderService {
                                        JSONArray DIAGNOSIS_DETAIL = visitDetail.getJSONArray("DIAGNOSIS_DETAIL");
                                        if (DIAGNOSIS_DETAIL!=null&&DIAGNOSIS_DETAIL.size()>0){
                                            if (!newYlzRelation){
                                                ylzMedicailIcdDao.deleteByMedicalId(ylzMedicalRelationDO.getId());
                                            }
                                            for (int j=0;j<DIAGNOSIS_DETAIL.size();j++){
                                                JSONObject DIAGNOSIS_DETAIL_OBJ = DIAGNOSIS_DETAIL.getJSONObject(j);
                                                YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                                                ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());//医保关联表id
                                                ylzMedicalIcdDO.setDiseaseCodeIcd10(DIAGNOSIS_DETAIL_OBJ.getString("diag_code"));
                                                ylzMedicalIcdDO.setDiseaseNameIcd10(DIAGNOSIS_DETAIL_OBJ.getString("diag_name"));
                                                ylzMedicalIcdDO.setDiseaseType(DIAGNOSIS_DETAIL_OBJ.getString("diag_type"));//诊断或症状类型
                                                ylzMedicalIcdDO.setDiseaseOrder(DIAGNOSIS_DETAIL_OBJ.getString("diag_srt_no"));//诊断或症状序号
                                                ylzMedicalIcdDO.setCreateTime(new Date());
                                                ylzMedicalIcdDO.setDiseMsgid(DIAGNOSIS_DETAIL_OBJ.getString("dise_msgid"));
                                                ylzMedicalIcdDO.setDiagDept(DIAGNOSIS_DETAIL_OBJ.getString("diag_dept"));
                                                ylzMedicalIcdDO.setDiseDorNo(DIAGNOSIS_DETAIL_OBJ.getString("dise_dor_no"));
                                                ylzMedicalIcdDO.setDiseDorName(DIAGNOSIS_DETAIL_OBJ.getString("dise_dor_name"));
                                                ylzMedicalIcdDO.setDiagTime(DIAGNOSIS_DETAIL_OBJ.getString("diag_time"));
                                                ylzMedicalIcdDO.setDel(Integer.valueOf(DIAGNOSIS_DETAIL_OBJ.getString("vali_flag")));
                                                ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                                                icdDOList.add(ylzMedicalIcdDO);
                                                List<YlzMedicalIcdDO> ylzMedicalIcdDOList = ylzMedicailIcdDao.findByMedicalId(ylzMedicalRelationDO.getId());
                                                icdDOList.addAll(ylzMedicalIcdDOList);
                                            }else {
                                                for (int j=0;j<DIAGNOSIS_DETAIL.size();j++){
                                                    JSONObject DIAGNOSIS_DETAIL_OBJ = DIAGNOSIS_DETAIL.getJSONObject(j);
                                                    YlzMedicalIcdDO ylzMedicalIcdDO = new YlzMedicalIcdDO();
                                                    ylzMedicalIcdDO.setMedicalId(ylzMedicalRelationDO.getId());//医保关联表id
                                                    ylzMedicalIcdDO.setDiseaseCodeIcd10(DIAGNOSIS_DETAIL_OBJ.getString("diag_code"));
                                                    ylzMedicalIcdDO.setDiseaseNameIcd10(DIAGNOSIS_DETAIL_OBJ.getString("diag_name"));
                                                    ylzMedicalIcdDO.setDiseaseType(DIAGNOSIS_DETAIL_OBJ.getString("diag_type"));//诊断或症状类型
                                                    ylzMedicalIcdDO.setDiseaseOrder(DIAGNOSIS_DETAIL_OBJ.getString("diag_srt_no"));//诊断或症状序号
                                                    ylzMedicalIcdDO.setCreateTime(new Date());
                                                    ylzMedicalIcdDO.setDiseMsgid(DIAGNOSIS_DETAIL_OBJ.getString("dise_msgid"));
                                                    ylzMedicalIcdDO.setDiagDept(DIAGNOSIS_DETAIL_OBJ.getString("diag_dept"));
                                                    ylzMedicalIcdDO.setDiseDorNo(DIAGNOSIS_DETAIL_OBJ.getString("dise_dor_no"));
                                                    ylzMedicalIcdDO.setDiseDorName(DIAGNOSIS_DETAIL_OBJ.getString("dise_dor_name"));
                                                    ylzMedicalIcdDO.setDiagTime(DIAGNOSIS_DETAIL_OBJ.getString("diag_time"));
                                                    ylzMedicalIcdDO.setDel(Integer.valueOf(DIAGNOSIS_DETAIL_OBJ.getString("vali_flag")));
                                                    ylzMedicailIcdDao.save(ylzMedicalIcdDO);
                                                    icdDOList.add(ylzMedicalIcdDO);
                                                }
                                            }
                                        }
@ -914,7 +1007,7 @@ public class MedOrderService {
                                    if(!amountDf.format(totalAmount).equals(SUM_COST)||!amountDf.format(ownPay).equals(SUM_CHARGE)){
                                        throw new Exception("金额不对无法结算");
                                    }
                                    if (ylzMedicalRelationDO.getStatus()!=1){
                                    if (newYlzRelation){
                                        ylzMedicalRelationDO.setLogNo(prescription_code);
                                        ylzMedicalRelationDO.setOrgCode(orgCode);
                                        ylzMedicalRelationDO.setRegionCode("350200");
@ -938,21 +1031,6 @@ public class MedOrderService {
                                        ylzMedicalRelationDO.setTotalAmount(SUM_COST);
                                        ylzMedicalRelationDO.setPreCharges("0");//预扣费金额
                                        ylzMedicalRelationDO.setDataSource("53");
                                        String balance =null;
                                        JSONObject balanceObj = jwService.getSickDispBalance(ylzMedicalRelationDO.getCardNo(),ylzMedicalRelationDO.getOrgCode());
                                        if (balanceObj.getString("status").equalsIgnoreCase("200")) {//i健康返回值
                                            JSONObject responseDataTmp = balanceObj.getJSONObject("data");
                                            String codeTMP = responseDataTmp.getString("CODE");//智业返回值 0失败 1成功
                                            if (codeTMP.equalsIgnoreCase("1")) {
                                                JSONArray byRefParaData = responseDataTmp.getJSONArray("byRefParaData");
                                                if (byRefParaData.size()>0){
                                                    balance = byRefParaData.getJSONObject(0).getString("dispBalance");
                                                }
                                            }
                                        }
                                        ylzMedicalRelationDO.setBalance(balance);//预缴金余额
                                        ylzMedicalRelationDO.setPreCount(presItemCount);//处方项目数
                                        ylzMedicalRelationDO.setDoctorLevel("02");
                                        ylzMedicalRelationDO.setRelationCode(VISIT_NO);
@ -977,6 +1055,21 @@ public class MedOrderService {
                                        ylzMedicalRelationDO.setDrName(dr_name);
                                        ylzMedicalRelationDO.setVisitMsgid(visit_msgid);
                                    }
                                    if (ylzMedicalRelationDO.getStatus()!=1){
                                        String balance =null;
                                        JSONObject balanceObj = jwService.getSickDispBalance(ylzMedicalRelationDO.getCardNo(),ylzMedicalRelationDO.getOrgCode());
                                        if (balanceObj.getString("status").equalsIgnoreCase("200")) {//i健康返回值
                                            JSONObject responseDataTmp = balanceObj.getJSONObject("data");
                                            String codeTMP = responseDataTmp.getString("CODE");//智业返回值 0失败 1成功
                                            if (codeTMP.equalsIgnoreCase("1")) {
                                                JSONArray byRefParaData = responseDataTmp.getJSONArray("byRefParaData");
                                                if (byRefParaData.size()>0){
                                                    balance = byRefParaData.getJSONObject(0).getString("dispBalance");
                                                }
                                            }
                                        }
                                        ylzMedicalRelationDO.setBalance(balance);//预缴金余额
                                    }
                                    if (1==ylzMedicalRelationDO.getMedicalState()&&0.0==Double.valueOf(ylzMedicalRelationDO.getTotalAmount())){
                                        //费用为0的医保结算也需要当作自费处理
                                        ylzMedicalRelationDO.setMedicalState(0);
@ -1028,7 +1121,7 @@ public class MedOrderService {
            personCash.add(personCashTmp);//个人现金支付
            if (0==personCashTmp.doubleValue()){//费用为0
                try {
                  if (!jwService.executeSickSettleMultiNew(recipe_no)){
                  if (!jwService.executeSickSettleMultiNew(recipe_no,equ_num)){
                      chargeSettle.add(recipe_no);
                  }
                }catch (Exception e){
@ -1072,7 +1165,7 @@ public class MedOrderService {
        else{
            for (String recipe_no:chargeSettle){
                try {
                    if (jwService.executeSickSettleMultiNew(recipe_no)){
                    if (jwService.executeSickSettleMultiNew(recipe_no,equ_num)){
                        if (settledErrors.contains(recipe_no)){
                            settledErrors.remove(recipe_no);
                        }
@ -1127,7 +1220,7 @@ public class MedOrderService {
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean executeSickSettleMultiNew(String recipe_no) throws Exception {
    public boolean executeSickSettleMultiNew(String recipe_no,String equ_num) throws Exception {
        String   sql = " select dict_code,dict_value from wlyy_hospital_sys_dict where dict_name='his_settlement' ";
        List<Map<String,Object>> AnalogFlags = jdbcTemplate.queryForList(sql);
        String AnalogFlag = "0";
@ -1143,7 +1236,7 @@ public class MedOrderService {
            ylzMedicailRelationDao.save(ylzMedicalRelationDO);
            return true;
        }
        return jwService.executeSickSettleMultiNew(recipe_no);
        return jwService.executeSickSettleMultiNew(recipe_no,equ_num);
    }
    /**
@ -1177,7 +1270,7 @@ public class MedOrderService {
     */
    public List<Map<String,Object>> getYjjChargeList(String cardNo,String startTime,String endTime) throws Exception {
        List<Map<String,Object>> list = new ArrayList<>();
        String sql = "select *,CAST(DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') as char) create_time from base_ylz_medical_recharge where ssc='"+cardNo+"' and charge_result<>'ing' ";
        String sql = "select *,CAST(DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') as char) create_time from base_ylz_medical_recharge where ssc='"+cardNo+"' ";
        if (StringUtils.isNotBlank(startTime)){
            sql +=" and create_time>='"+startTime+" 00:00:00' ";
        }

+ 11 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/YlzService.java

@ -25,6 +25,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
@ -52,6 +53,8 @@ public class YlzService {
    MedOrderService medOrderService;
    @Autowired
    HospitalDao hospitalDao;
    @Autowired
    MedicineServive medicineServive;
    private final String entranceUrl="http://10.90.32.3:22174/cityihealth/base/";
@ -360,6 +363,13 @@ public class YlzService {
                    if ("exp".equals(result)){
                    }else {
                        /**
                         * 支付状态确认 通知药柜结算状态是什么情况
                         */
                        JSONObject chargeNotice = new JSONObject();
                        chargeNotice.put("result",result);
                        chargeNotice.put("resultName",resultName);
                        medicineServive.sendSocketMessage(ylzMedicalRecharge.getEquNum()+"_T","medical_recharge", URLEncoder.encode(chargeNotice.toJSONString(),"UTF-8"));
                        ylzMedicalRecharge.setChargeResult(result);
                        ylzMedicalRecharge.setChargeResultName(resultName);
                        ylzMedicalRechargeDao.save(ylzMedicalRecharge);
@ -369,7 +379,7 @@ public class YlzService {
                                String[] recipeNos = recipeNoStr.split(",");
                                try {
                                    for (String recipeNo:recipeNos){
                                        medOrderService.executeSickSettleMultiNew(recipeNo);
                                        medOrderService.executeSickSettleMultiNew(recipeNo,ylzMedicalRecharge.getEquNum());
                                    }
                                }catch (Exception e){
                                    e.printStackTrace();

+ 37 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/YJJChargeResultOverTimeJob.java

@ -0,0 +1,37 @@
package com.yihu.jw.job;
import com.yihu.jw.util.DateUtil;
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.jdbc.core.JdbcTemplate;
/**
 * 药柜预交金充值超时job
 */
public class YJJChargeResultOverTimeJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(YJJChargeResultOverTimeJob.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("START========YJJChargeResultOverTimeJob========");
        try {
            String nowTime = DateUtil.getStringDate();
            String prTime = DateUtil.getPreTime(nowTime,"-5");
            String sql = " update base_ylz_medical_recharge set charge_result='overTime',charge_result_name='支付超时' where charge_result='ing' and  create_time<='"+prTime+"' ";
            jdbcTemplate.execute(sql);
            logger.info("END========YJJChargeResultOverTimeJob========");
        }catch (Exception e) {
            e.printStackTrace();
            logger.info("END========YJJChargeResultOverTimeJob ERROR: " + e.getMessage());
        }
    }
}

+ 24 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java

@ -281,6 +281,15 @@ public class JobController extends BaseController {
                    } else {
                        logger.info("data_ykupload_job_2  job exist");
                    }
                case "YJJChargeResultOverTimeJob" :
                    //互联网医院 监管平台上报
                    if (!quartzHelper.isExistJob("YJJChargeResultOverTimeJob")) {
                        String trigger = SystemConf.getInstance().getSystemProperties().getProperty("YJJChargeResultOverTimeJob");
                        quartzHelper.addJob(YJJChargeResultOverTimeJob.class, trigger, "YJJChargeResultOverTimeJob", new HashMap<String, Object>());
                        logger.info("YJJChargeResultOverTimeJob  job success");
                    } else {
                        logger.info("YJJChargeResultOverTimeJob  job exist");
                    }
                    break;
                default :
@ -900,4 +909,19 @@ public class JobController extends BaseController {
        }
    }
    @RequestMapping(value = "/testNow", method = RequestMethod.POST)
    @ApiOperation("立即执行")
    public String executeSignFamilyPayResultJob(String className) {
        try {
            String uuid = getUID();
            Class c1 = Class.forName(className);//com.yihu.jw.care.job.consult.FinishConsultJob
            quartzHelper.startNow(c1, uuid, null);
            quartzHelper.removeJob(uuid);
            return write(200, "启动成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
}

+ 2 - 0
svr/svr-internet-hospital-job/src/main/resources/system.properties

@ -33,4 +33,6 @@ syn_physic_storage = 0 0 4 * * ? *
medicine_order_status=0 * * * * ? *
YJJChargeResultOverTimeJob=0 0/5 * * * ? *