|  | @@ -242,15 +242,16 @@ public class BswServerImpl implements BswServer {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          String requestId = null;
 | 
	
		
			
				|  |  |          if (CollUtil.isNotEmpty(mzDzfpUploadList)) {
 | 
	
		
			
				|  |  | -            if (StrUtil.isNotBlank(mzDzfpUploadList.get(0).getFpNo())) {
 | 
	
		
			
				|  |  | -                return R.ok().put("data", mzDzfpUploadList.get(0));
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +//            if (StrUtil.isNotBlank(mzDzfpUploadList.get(0).getFpNo())) {
 | 
	
		
			
				|  |  | +//                return R.ok().put("data", mzDzfpUploadList.get(0));
 | 
	
		
			
				|  |  | +//            }
 | 
	
		
			
				|  |  |              MzDzfpUpload mzDzfpUpload = getDzfpState(mzDzfpUploadList.get(0), 1);
 | 
	
		
			
				|  |  |              if (mzDzfpUpload != null) {
 | 
	
		
			
				|  |  |                  return R.ok().put("data", mzDzfpUpload);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              requestId = mzDzfpUploadList.get(0).getRequestId();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +//        return R.ok();
 | 
	
		
			
				|  |  |          MzInvoiceInfo mzInvoiceInfo;
 | 
	
		
			
				|  |  |          requestId = Convert.toStr(requestId, OptimalLimitDigitGenerator.generate().toString());
 | 
	
		
			
				|  |  |          if (ghFlag) {
 | 
	
	
		
			
				|  | @@ -274,14 +275,14 @@ public class BswServerImpl implements BswServer {
 | 
	
		
			
				|  |  |          if (!ResultInfo.SUCCESS_CODE.equals(resultInfo.getData().get("result"))) {
 | 
	
		
			
				|  |  |              return R.error(resultInfo.getMessage());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        mzReceiptSerial.setOperatorId(StrUtil.isNotBlank(uploadParam.getOpId()) ? uploadParam.getOpId() : TokenUtil.getUser().getUserIdCode());
 | 
	
		
			
				|  |  | +//        mzReceiptSerial.setOperatorId(StrUtil.isNotBlank(uploadParam.getOpId()) ? uploadParam.getOpId() : TokenUtil.getUser().getUserIdCode());
 | 
	
		
			
				|  |  |          return saveMzDzfpUpload(mzReceiptSerial, mzInvoiceInfo, resultInfo, 1);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private MzDzfpUpload getDzfpState(MzDzfpUpload mzDzfpUpload, int requestTimes) {
 | 
	
		
			
				|  |  |          for (int i = 1; i <= requestTimes; i++) {
 | 
	
		
			
				|  |  | -            ResultInfo issuedState = queryIssuedState(mzDzfpUpload.getReceiptNo());
 | 
	
		
			
				|  |  | +            ResultInfo issuedState = queryIssuedState(mzDzfpUpload.getRequestId());
 | 
	
		
			
				|  |  |              if (issuedState == null || issuedState.getCode() == null) {
 | 
	
		
			
				|  |  |                  throw new BizException("电子发票系统内部错误!");
 | 
	
		
			
				|  |  |              }
 | 
	
	
		
			
				|  | @@ -294,12 +295,12 @@ public class BswServerImpl implements BswServer {
 | 
	
		
			
				|  |  |  //                if (Convert.toInt(NumberEnum.ThREE.getCode()).equals(Convert.toInt(data.get("issuedState")))) {
 | 
	
		
			
				|  |  |  //                    mzDzfpUpload.setResMessage((String) data.get("errMsg"));
 | 
	
		
			
				|  |  |  //                }
 | 
	
		
			
				|  |  | -                if ("01".equals(Convert.toInt(data.get("issuedState"))) || "04".equals(Convert.toInt(data.get("issuedState")))) {
 | 
	
		
			
				|  |  | -                    Map msg = (Map) data.get("message");
 | 
	
		
			
				|  |  | -                    log.info("电子发票信息={}", msg);
 | 
	
		
			
				|  |  | -                    mzDzfpUpload.setFpNo(Convert.toStr(msg.get("invoice_number")));
 | 
	
		
			
				|  |  | -                    mzDzfpUpload.setOpCode(Convert.toStr(msg.get("invoice_code")));
 | 
	
		
			
				|  |  | -                    mzDzfpUpload.setBlueIssueDate(Convert.toStr(msg.get("issue_date")));
 | 
	
		
			
				|  |  | +                if ("01".equals(Convert.toStr(data.get("invoice_status"))) || "04".equals(Convert.toStr(data.get("invoice_status")))) {
 | 
	
		
			
				|  |  | +//                    Map msg = (Map) data.get("message");
 | 
	
		
			
				|  |  | +//                    log.info("电子发票信息={}", msg);
 | 
	
		
			
				|  |  | +                    mzDzfpUpload.setFpNo(Convert.toStr(data.get("invoice_number")));
 | 
	
		
			
				|  |  | +                    mzDzfpUpload.setOpCode(Convert.toStr(data.get("invoice_code")));
 | 
	
		
			
				|  |  | +                    mzDzfpUpload.setBlueIssueDate(Convert.toStr(data.get("issue_date")));
 | 
	
		
			
				|  |  |                      mzDzfpUpload.setResCode(2);
 | 
	
		
			
				|  |  |                      mzDzfpUploadMapper.updateFpNo(mzDzfpUpload);
 | 
	
		
			
				|  |  |                      if (mzDzfpUpload.getTypeFlag() == 2 || mzDzfpUpload.getTypeFlag() == 4) {
 | 
	
	
		
			
				|  | @@ -474,6 +475,8 @@ public class BswServerImpl implements BswServer {
 | 
	
		
			
				|  |  |                  .patientName(mzPatientMi.getName())
 | 
	
		
			
				|  |  |                  .deptCode(zdUnitCode.getCode())
 | 
	
		
			
				|  |  |                  .deptName(zdUnitCode.getName())
 | 
	
		
			
				|  |  | +                .sex(GenderEnum.getGenderByCode(mzPatientMi.getSex()).name)
 | 
	
		
			
				|  |  | +                .age(String.valueOf(mzPatientMi.getAge()))
 | 
	
		
			
				|  |  |                  .patientIdTypeCode(gePatientIdTypeCode(mzPatientMi.getCertificateType()))
 | 
	
		
			
				|  |  |                  .patientIdNo(mzPatientMi.getSocialNo())
 | 
	
		
			
				|  |  |                  .gender(Convert.toStr(mzPatientMi.getSex()))
 | 
	
	
		
			
				|  | @@ -536,7 +539,7 @@ public class BswServerImpl implements BswServer {
 | 
	
		
			
				|  |  |                  .patientId(mzReceiptSerial.getPatientId())
 | 
	
		
			
				|  |  |                  .times(mzReceiptSerial.getTimes())
 | 
	
		
			
				|  |  |                  .receiptNo(mzReceiptSerial.getReceiptNo())
 | 
	
		
			
				|  |  | -                .serialNo(String.valueOf(mzReceiptSerial.getReceiptSn()))
 | 
	
		
			
				|  |  | +                .serialNo(String.valueOf(mzReceiptSerial.getSerialNo()))
 | 
	
		
			
				|  |  |                  .fpNo(resultInfo.getData().get("invoice_code").toString())
 | 
	
		
			
				|  |  |                  .opCode(resultInfo.getData().get("invoice_number").toString())
 | 
	
		
			
				|  |  |                  .requestId(mzInvoiceInfo.getRequestId())
 | 
	
	
		
			
				|  | @@ -544,7 +547,7 @@ public class BswServerImpl implements BswServer {
 | 
	
		
			
				|  |  |                  .delFlag(0)
 | 
	
		
			
				|  |  |                  .opId(mzReceiptSerial.getOperatorId())
 | 
	
		
			
				|  |  |                  .build();
 | 
	
		
			
				|  |  | -        if (ResultInfo.SUCCESS_CODE.equals(resultInfo.getCode()) && Convert.toBool(jsonData.get("success"))) {
 | 
	
		
			
				|  |  | +        if (ResultInfo.SUCCESS_CODE.equals(resultInfo.getData().get("result"))) {
 | 
	
		
			
				|  |  |  //            mzDzfpUpload.setQrcode(Convert.toStr(jsonData.get("qrcode")));
 | 
	
		
			
				|  |  |              mzDzfpUpload.setResUrl(Convert.toStr(jsonData.get("invoice_url")));
 | 
	
		
			
				|  |  |              mzDzfpUpload.setResCode(2);
 | 
	
	
		
			
				|  | @@ -1204,7 +1207,7 @@ public class BswServerImpl implements BswServer {
 | 
	
		
			
				|  |  |       * -sellerUsciCode				销方纳税人识别号	开具成功有此值
 | 
	
		
			
				|  |  |       * -sellerUsciName				销方纳税人名称	开具成功有此值
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public ResultInfo queryIssuedState(Integer busseqno) {
 | 
	
		
			
				|  |  | +    public ResultInfo queryIssuedState(String busseqno) {
 | 
	
		
			
				|  |  |          String url = getUrl() + "public/ebill/invoicequery";
 | 
	
		
			
				|  |  |          Map<String, Object> param = new HashMap<>();
 | 
	
		
			
				|  |  |          param.put("busseqno", busseqno);
 |