Browse Source

修改bug

wangzhinan 5 months ago
parent
commit
36b8da5b9a

+ 59 - 8
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/DsyyPrescriptionService.java

@ -11,6 +11,7 @@ import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalIcdDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalMxDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationInvoiceDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
@ -19,6 +20,7 @@ import com.yihu.jw.entity.order.BusinessOrderDO;
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.YlzMedicailRelationInvoiceDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
@ -76,14 +78,6 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
    private PatientRegisterDao patientRegisterDao;
    @Autowired
    private WlyyHttpLogDao wlyyHttpLogDao;
    @Autowired
    private PrescriptionEmrDao prescriptionEmrDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    //请求内网服务
    public static String entranceUrl = "http://192.168.101.2:10024/dsyy/";
@ -106,6 +100,8 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
    private BusinessOrderDao businessOrderDao;
    @Autowired
    private PrescriptionLogDao prescriptionLogDao;
    @Autowired
    private YlzMedicailRelationInvoiceDao invoiceDao;
    //=============查询视图========================
    /**
@ -1269,6 +1265,61 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        return object;
    }
    /**
     * 电票下载
     *
     * @return
     */
    public JSONObject queryDzfp(String settleNo) throws Exception {
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLog_no(settleNo);
        YlzMedicalRelationInvoiceDO invoiceDO = invoiceDao.findByMedicalId(ylzMedicalRelationDO.getId());
        JSONObject object = new JSONObject();
        if (invoiceDO==null){
            JSONArray array = dsyyEntranceService.findInvoiceInfo(settleNo);
            for (int i=0;i<array.size();i++){
                invoiceDO = new YlzMedicalRelationInvoiceDO();
                invoiceDO.setMedicalId(ylzMedicalRelationDO.getId());
                invoiceDO.setStatus(1);
                invoiceDO.setInvoiceNo(array.getJSONObject(i).getString("randomnumber"));
                invoiceDO.setInvoiceSerialNum(array.getJSONObject(i).getString("einvoicenumber"));
                invoiceDO.setInvoiceCode(array.getJSONObject(i).getString("einvoicecode"));
                invoiceDO.setCreateTime(new Date());
                invoiceDO = invoiceDao.save(invoiceDO);
                String url = entranceUrl +"queryDzfp";
                Map<String,Object> params = new HashedMap();
                params.put("id",ylzMedicalRelationDO.getId());
                params.put("invoiceNo",invoiceDO.getInvoiceNo());
                params.put("invoiceCode",invoiceDO.getInvoiceCode());
                params.put("invoiceSerialNum",invoiceDO.getInvoiceSerialNum());
                HttpResponse response = HttpUtils.doGet(url,params);
                String content = response.getContent();
                logger.info("response:"+content);
                JSONObject rs = JSON.parseObject(content);
                Integer status = rs.getInteger("status");
                if (status==200){
                    object = rs.getJSONObject("message");
                }
            }
        }else {
            String url = entranceUrl +"queryDzfp";
            Map<String,Object> params = new HashedMap();
            params.put("id",ylzMedicalRelationDO.getId());
            params.put("invoiceNo",invoiceDO.getInvoiceNo());
            params.put("invoiceCode",invoiceDO.getInvoiceCode());
            params.put("invoiceSerialNum",invoiceDO.getInvoiceSerialNum());
            HttpResponse response = HttpUtils.doGet(url,params);
            String content = response.getContent();
            logger.info("response:"+content);
            JSONObject rs = JSON.parseObject(content);
            Integer status = rs.getInteger("status");
            if (status==200){
                object = rs.getJSONObject("message");
            }
        }
        return object;
    }
    //=====================合理用药内网调用接口=======================

+ 73 - 20
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/DsyyEntranceService.java

@ -1488,6 +1488,28 @@ public class DsyyEntranceService {
        return buffer.toString();
    }
    /**
     * 根据结算号获取his开票信息
     *
     * @throws Exception
     */
    public JSONArray findInvoiceInfo(String settleNo) throws Exception {
        String sql = "select einvoicecode as \"einvoicecode\",einvoicenumber as \"einvoicenumber\",randomnumber as \"randomnumber\",sick_id from v_hlwyydp where settle_no='"+settleNo+"' ";
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("hlwyydp:"+sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            array = rs.getJSONArray("detailModelList");
        }
        return array;
    }
    //=============his webservice 调用开始 =============================
    /**
@ -3885,13 +3907,17 @@ public class DsyyEntranceService {
    //============================电子发票开始====================================
    String dsfp = "http://10.95.8.94:20017/service/invoice/perform";
    String dsfp = "http://10.95.8.48:20017/service/invoice/perform";
    String appId ="862e18c18c5e4d72";
    String appKey ="d756d7778c43e3c5b8bbcb301c48fe25";
    String msgNo ="8901";
    String organ = "401039";
    String organ = "5676";
    String user = "hisbizadmin";
    String org= "123502124266188956";
    public String getAccessToken() throws Exception {
        long timestamp = new Date().getTime() * 1000000;
        String accessToken = "";
        String msg = "<Voucher>\n" +
                "<AppId>"+appId+"</AppId>\n" +
                "<AppKey>"+appKey+"</AppKey>\n" +
@ -3900,14 +3926,14 @@ public class DsyyEntranceService {
        String params ="<?xml version='1.0' encoding='UTF-8'?>\n" +
                "<Invoice>\n" +
                "<Head>\n" +
                "<MsgNo>"+msgNo+"</MsgNo>\n" +
                "<MsgNo>8901</MsgNo>\n" +
                "<Organ>"+organ+"</Organ>\n" +
                "<User>"+user+"</User>\n" +
                "<Version>1.0</Version>\n" +
                "<AppId>"+appId+"</AppId>\n" +
                "<MsgId>5676"+randomStr+"</MsgId>\n" +
                "<MsgRef>5676"+randomStr+"</MsgRef>\n" +
                "<DateTime>"+new Date().getTime()+"</DateTime>\n" +
                "<DateTime>"+timestamp+"</DateTime>\n" +
                "<Reserve></Reserve>\n" +
                "</Head>\n" +
                "<Msg>"+ Base64.encodeBase64String(msg.getBytes("utf-8"))+"</Msg>\n" +
@ -3915,7 +3941,20 @@ public class DsyyEntranceService {
        logger.info("请求前入参:"+params);
        String result = httpClientUtil.sendPost(dsfp,params);
        logger.info("请求结果:"+result);
        return result;
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(result).toString();
        logger.info("请求后出参:"+json);
        JSONObject resObj = JSONObject.parseObject(json);
        String msgResult = resObj.getString("Msg");
        if (StringUtils.isNoneBlank(msgResult)){
            byte[] msgBase64 = Base64.decodeBase64(msgResult);
            String msgText = new String(msgBase64, "utf-8");
            System.out.println("msgText"+msgText);
            String msgTexts = xmlSerializer.read(msgText).toString();
            JSONObject msgObj = JSONObject.parseObject(msgTexts);
            accessToken = msgObj.getString("AccessToken");
        }
        return accessToken;
    }
@ -4032,7 +4071,7 @@ public class DsyyEntranceService {
        String params ="<?xml version='1.0' encoding='UTF-8'?>\n" +
                "<Invoice>\n" +
                "<Head>\n" +
                "<MsgNo>"+msgNo+"</MsgNo>\n" +
                "<MsgNo>8213</MsgNo>\n" +
                "<Organ>"+organ+"</Organ>\n" +
                "<User>"+user+"</User>\n" +
                "<Version>1.0</Version>\n" +
@ -4059,37 +4098,51 @@ public class DsyyEntranceService {
     * @return
     * @throws Exception
     */
    public String queryDzfp(String medicalId) throws Exception {
        YlzMedicalRelationInvoiceDO invoiceDO = invoiceDao.findByMedicalId(medicalId);
    public String queryDzfp(String medicalId,String invoiceNo,String invoiceCode,String invoiceSerialNum) throws Exception {
        String resultResponse = "";
        long timestamp = new Date().getTime() * 1000000;
        String msg = "<Voucher>\n" +
                "<AgencyCode>401039</AgencyCode>\n" +
                "<AgencyCode>"+org+"</AgencyCode>\n" +
                "<AgencyName>厦门市第三医院</AgencyName>\n" +
                "<EInvoiceCode>"+invoiceDO.getInvoiceCode()+"</EInvoiceCode>\n" +
                "<EInvoiceNumber>"+invoiceDO.getInvoiceSerialNum()+"</EInvoiceNumber>\n" +
                "<RandomNumber>"+invoiceDO.getInvoiceNo()+"</RandomNumber>\n" +
                "<EInvoiceCode>"+invoiceCode+"</EInvoiceCode>\n" +
                "<EInvoiceNumber>"+invoiceSerialNum+"</EInvoiceNumber>\n" +
                "<RandomNumber>"+invoiceNo+"</RandomNumber>\n" +
                "</Voucher>\n";
        logger.info("发票下载入参未加密:"+msg);
        String randomStr = System.currentTimeMillis()+(int)(Math.random()*900)+100+"";
        String params ="<?xml version='1.0' encoding='UTF-8'?>\n" +
                "<Invoice>\n" +
                "<Head>\n" +
                "<MsgNo>"+msgNo+"</MsgNo>\n" +
                "<MsgNo>8213</MsgNo>\n" +
                "<Organ>"+organ+"</Organ>\n" +
                "<User>"+user+"</User>\n" +
                "<Version>1.0</Version>\n" +
                "<AppId>"+appId+"</AppId>\n" +
                "<AccessToken>aaaabbbbb11111333333</AccessToken>"+
                "<AppId>862e18c18c5e4d72</AppId>\n" +
                "<AccessToken>"+getAccessToken()+"</AccessToken>"+
                "<MsgId>5676"+randomStr+"</MsgId>\n" +
                "<MsgRef>5676"+randomStr+"</MsgRef>\n" +
                "<DateTime>"+new Date().getTime()+"</DateTime>\n" +
                "<DateTime>"+timestamp+"</DateTime>\n" +
                "<Reserve></Reserve>\n" +
                "</Head>\n" +
                "<Msg>"+ Base64.encodeBase64String(msg.getBytes("utf-8"))+"</Msg>\n" +
                "</Invoice>";
        logger.info("开具电子发票入参:"+params);
        logger.info("发票下载入参:"+params);
        String result = httpClientUtil.sendPost(dsfp,params);
        logger.info("开具电子发票请求结果:"+result);
        return result;
        logger.info("发票下载请求结果:"+result);
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(result).toString();
        logger.info("请求后出参:"+json);
        JSONObject resObj = JSONObject.parseObject(json);
        String msgResult = resObj.getString("Msg");
        if (StringUtils.isNoneBlank(msgResult)){
            byte[] msgBase64 = Base64.decodeBase64(msgResult);
            String msgText = new String(msgBase64, "utf-8");
            System.out.println("msgText"+msgText);
            String msgTexts = xmlSerializer.read(msgText).toString();
            JSONObject msgObj = JSONObject.parseObject(msgTexts);
            resultResponse = msgObj.toJSONString();
        }
        return resultResponse;
    }

+ 11 - 5
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/DsyyController.java

@ -568,7 +568,7 @@ public class DsyyController extends EnvelopRestEndpoint {
        }catch (Exception e){
            e.printStackTrace();
        }
        return Envelop.getError("发送失败");
        return Envelop.getError("获取token");
    }
    @GetMapping(value = "/dsfpkj")
@ -580,7 +580,7 @@ public class DsyyController extends EnvelopRestEndpoint {
        }catch (Exception e){
            e.printStackTrace();
        }
        return Envelop.getError("发送失败");
        return Envelop.getError("电子票据开具");
    }
    @PostMapping(value = "/dzblSave")
@ -698,13 +698,19 @@ public class DsyyController extends EnvelopRestEndpoint {
    @GetMapping(value = "/queryDzfp")
    @ApiOperation(value = "电子发票查询")
    public Envelop queryDzfp(@ApiParam(name = "id", value = "结算id", required = false)
                                      @RequestParam(value = "id",required = false)String id) throws Exception {
                                      @RequestParam(value = "id",required = false)String id,
                             @ApiParam(name = "invoiceNo", value = "发票号码", required = false)
                             @RequestParam(value = "invoiceNo",required = false)String invoiceNo,
                             @ApiParam(name = "invoiceCode", value = "发票代码", required = false)
                                 @RequestParam(value = "invoiceCode",required = false)String invoiceCode,
                             @ApiParam(name = "invoiceSerialNum", value = "校验码", required = false)
                                 @RequestParam(value = "invoiceSerialNum",required = false)String invoiceSerialNum) throws Exception {
        try {
            return success(dsyyEntranceService.queryDzfp(id));
            return success(dsyyEntranceService.queryDzfp(id,invoiceNo,invoiceCode,invoiceSerialNum));
        }catch (Exception e){
            e.printStackTrace();
        }
        return Envelop.getError("发送失败");
        return Envelop.getError("电子发票下载");
    }
    @GetMapping(value = "/callServiceHC")

+ 7 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -3957,6 +3957,13 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        return success("请求成功",dsyyPrescriptionService.selectInspectReportList(idcard,cardNo,startTime,endTime,reportId,page,size));
    }
    @PostMapping(value = "/queryDzfp")
    @ApiOperation(value = "下载电子发票")
    public ObjEnvelop queryDzfp(@ApiParam(name = "settleNo", value = "结算号", required = false)
                                              @RequestParam(value = "settleNo",required = false)String settleNo) throws Exception {
        return success("请求成功",dsyyPrescriptionService.queryDzfp(settleNo));
    }
    @GetMapping("/aIassistant")
    @ApiOperation(value = "ai助手", notes = "ai助手")