浏览代码

发票冲红

‘chenzhilei’ 3 月之前
父节点
当前提交
4c7813d1eb

+ 5 - 0
src/main/java/cn/hnthyy/thmz/entity/his/mz/MzReceiptSerial.java

@@ -165,6 +165,11 @@ public class MzReceiptSerial implements Serializable {
         this.patientId = patientId;
         this.times = times;
     }
+    public MzReceiptSerial(String patientId, Integer times,Integer serialNo) {
+        this.patientId = patientId;
+        this.times = times;
+        this.serialNo = serialNo;
+    }
 
     /**
      * 设置明细为0

+ 30 - 9
src/main/java/cn/hnthyy/thmz/entity/mzdzfp/JSMzInvoiceInfo.java

@@ -29,27 +29,31 @@ public class JSMzInvoiceInfo implements Serializable {
     private String patientId;	//	门诊号
     private String times;	//	就诊次数
     private String busseqno;	//	流水号
-    private	String bustype = "02";	//	业务类型
+    private	String bustype = "0";	//	业务类型
     private	BigDecimal totalAmount;	//	总金额
     private	String payerPartyType = "1";	//	交款人类型	1:个人2:单位
     private	String payerPartyName;	//	交款人姓名
     private	String bizcode;	//	医疗系统的业务流水号
     private	String handlingPerson;	//	开票人
     private	String checker;	//	复核人
+    private	String invoice_type_code;	//	票据种类代码
+    private String rec_name;        //	收款人姓名
     private List<DetailItemList> detail_item_list;
     private	HisInfo hisInfo;	//	医疗票相关信息
 
-    public JSMzInvoiceInfo transformFromMzInvoiceInfo(MzInvoiceInfo mzInvoiceInfo){
+    public JSMzInvoiceInfo transformFromMzInvoiceInfo(MzInvoiceInfo mzInvoiceInfo,String biztype){
+
         JSMzInvoiceInfo jsMzInvoiceInfo = new JSMzInvoiceInfo();
         jsMzInvoiceInfo.setPatientId(mzInvoiceInfo.getPatientId());
         jsMzInvoiceInfo.setTimes(mzInvoiceInfo.getTimes());
-        jsMzInvoiceInfo.setBusseqno(mzInvoiceInfo.getSpecialAttrDTO().getMedicalSerialNo());
+//        jsMzInvoiceInfo.setBusseqno(mzInvoiceInfo.getSpecialAttrDTO().getMedicalSerialNo());
         jsMzInvoiceInfo.setTotalAmount(mzInvoiceInfo.getTotalAmount());
         jsMzInvoiceInfo.setPayerPartyName(mzInvoiceInfo.getBuyerUsciName());
         jsMzInvoiceInfo.setBizcode(mzInvoiceInfo.getSpecialAttrDTO().getMedicalSerialNo());
         jsMzInvoiceInfo.setHandlingPerson(mzInvoiceInfo.getIssuer());
         jsMzInvoiceInfo.setChecker(mzInvoiceInfo.getIssuer());
         jsMzInvoiceInfo.setBusseqno(mzInvoiceInfo.getSpecialAttrDTO().getMedicalSerialNo());
+        jsMzInvoiceInfo.setRec_name(mzInvoiceInfo.getIssuer());
         HisInfo hisInfo = new HisInfo();
         hisInfo.setPayee(mzInvoiceInfo.getIssuer());
         TradeInfo tradeInfo = new TradeInfo();
@@ -104,13 +108,25 @@ public class JSMzInvoiceInfo implements Serializable {
         bizinfo.setSex(mzInvoiceInfo.getSpecialAttrDTO().getSex());
         bizinfo.setMed_inst_type("");
         bizinfo.setAge(mzInvoiceInfo.getSpecialAttrDTO().getAge());
-        MedOutinfo medOutinfo = new MedOutinfo();
-        medOutinfo.setCase_no(mzInvoiceInfo.getSpecialAttrDTO().getOutpatientNo());
-        medOutinfo.setCategory_code(mzInvoiceInfo.getSpecialAttrDTO().getDeptCode());
-        medOutinfo.setCategory(mzInvoiceInfo.getSpecialAttrDTO().getDeptName());
-        medOutinfo.setPatient_no(mzInvoiceInfo.getSpecialAttrDTO().getOutpatientNo());
+        bizinfo.setBiztype(biztype);
+        //医疗业务病人信息(住院)
+        if ("01".equals(biztype)) {
+            MedBedinfo medBedinfo = new MedBedinfo();
+            medBedinfo.setHospital_no(mzInvoiceInfo.getSpecialAttrDTO().getOutpatientNo());
 //        medOutinfo.setCase_no("");
-        bizinfo.setMed_outinfo(medOutinfo);
+            bizinfo.setMed_bedinfo(medBedinfo);
+            jsMzInvoiceInfo.setInvoice_type_code("320602");
+        } else {//门诊
+            MedOutinfo medOutinfo = new MedOutinfo();
+            medOutinfo.setCase_no(mzInvoiceInfo.getSpecialAttrDTO().getOutpatientNo());
+            medOutinfo.setCategory_code(mzInvoiceInfo.getSpecialAttrDTO().getDeptCode());
+            medOutinfo.setCategory(mzInvoiceInfo.getSpecialAttrDTO().getDeptName());
+            medOutinfo.setPatient_no(mzInvoiceInfo.getSpecialAttrDTO().getOutpatientNo());
+            jsMzInvoiceInfo.setInvoice_type_code("320601");
+//        medOutinfo.setCase_no("");
+            bizinfo.setMed_outinfo(medOutinfo);
+        }
+
         hisInfo.setBizinfo(bizinfo);
         hisInfo.setReimburse_info(new ReimburseInfo());
 
@@ -171,6 +187,7 @@ class Bizinfo {     //就诊信息明细
     private String sex;	//	性别:男、女
     private String med_inst_type;	//	医疗机构类型
     private MedOutinfo med_outinfo;	//	门诊信息
+    private MedBedinfo med_bedinfo;	//	门诊信息
     private String age;	//	年龄
 }
 @Data
@@ -192,4 +209,8 @@ class MedOutinfo {
     private String category;	//	就诊科室名称
     private String sp_dis_name;	//	特殊病种名称
 }
+@Data
+class MedBedinfo {
+    private String hospital_no;	//	患者住院号
+}
 

+ 1 - 1
src/main/java/cn/hnthyy/thmz/entity/mzdzfp/JSRedMzInvoiceInfo.java

@@ -36,7 +36,7 @@ public class JSRedMzInvoiceInfo implements Serializable {
     private	String checker;	//	复核人
     private List<DetailItemList> detail_item_list;
 
-    public JSRedMzInvoiceInfo transformFromMzInvoiceInfo(MzInvoiceInfo mzInvoiceInfo){
+    public JSRedMzInvoiceInfo transformFromMzInvoiceInfo(MzInvoiceInfo mzInvoiceInfo,String biztype){
         JSRedMzInvoiceInfo jsRedMzInvoiceInfo = new JSRedMzInvoiceInfo();
         jsRedMzInvoiceInfo.setBusseqno(mzInvoiceInfo.getSpecialAttrDTO().getMedicalSerialNo());
         jsRedMzInvoiceInfo.setTotalAmount(mzInvoiceInfo.getTotalAmount());

+ 2 - 2
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzChargeDetailMapper.java

@@ -166,7 +166,7 @@ public interface MzChargeDetailMapper {
             "<when test='mzChargeDetail.payMark eq 5'>",
             " price_time,",
             "</when>",
-            "real_no,sum(( case when convert(decimal(18,2),unit_price)=0.00 then 0.00 else convert(decimal(18,2),unit_price) end )*quantity*drug_win) amount",
+            "real_no,serial_no,sum(( case when convert(decimal(18,2),unit_price)=0.00 then 0.00 else convert(decimal(18,2),unit_price) end )*quantity*drug_win) amount",
             ",sum(( case when convert(decimal(18,2),orig_price)=0.00 then 0.00 else convert(decimal(18,2),orig_price) end )*quantity*drug_win) not_discount_amount ",
             " from ${tableName} WITH(NOLOCK)  where bill_item_code <![CDATA[<>]]> 'TC' ",
             "<when test='mzChargeDetail.payMark!=null'>",
@@ -220,7 +220,7 @@ public interface MzChargeDetailMapper {
             "<when test='filterSelfBilling!=null and filterSelfBilling eq 1'>",
             " and doctor_code <![CDATA[<>]]> '99999' ",
             "</when>",
-            " group by patient_id,times,receipt_no,name,",
+            " group by patient_id,times,receipt_no,name,serial_no,",
             "<when test='mzChargeDetail.payMark eq 0'>",
             " charge_date,",
             "</when>",

+ 1 - 1
src/main/java/cn/hnthyy/thmz/mapper/thmz/FileUploadMapper.java

@@ -35,7 +35,7 @@ public interface FileUploadMapper {
      * @return
      */
     @Insert("INSERT INTO t_file_upload(file_name, file_data, file_type, mime_type, create_time, create_user,square_file) VALUES " +
-            "(#{fileName,jdbcType=VARCHAR}, #{fileData}, #{fileType,jdbcType=VARCHAR}, #{mimeType,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},#{createUser,jdbcType=BIGINT}, #{squareFile}")
+            "(#{fileName,jdbcType=VARCHAR}, #{fileData}, #{fileType,jdbcType=VARCHAR}, #{mimeType,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},#{createUser,jdbcType=BIGINT}, #{squareFile})")
     @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
     int insertFileUpload(FileUpload fileUpload);
 

+ 25 - 16
src/main/java/cn/hnthyy/thmz/service/impl/his/mzdzfp/BswServerImpl.java

@@ -184,7 +184,7 @@ public class BswServerImpl implements BswServer {
      */
     public ResultInfo mzBlueInvoice(MzInvoiceInfo mzInvoiceInfo) {
         String url = getUrl() + "public/ebill/invoicehisissue";
-        JSMzInvoiceInfo jsMzInvoiceInfo = new JSMzInvoiceInfo().transformFromMzInvoiceInfo(mzInvoiceInfo);
+        JSMzInvoiceInfo jsMzInvoiceInfo = new JSMzInvoiceInfo().transformFromMzInvoiceInfo(mzInvoiceInfo,"02");
         String paramJson = JsonUtil.object2Json(jsMzInvoiceInfo);
 
         log.info("url:{}", url);
@@ -861,8 +861,8 @@ public class BswServerImpl implements BswServer {
             }
             requestId = mzDzfpUploadList.get(0).getRequestId();
         }
-        String blueInvoiceNo = "";
-        String blueIssueDate = "";
+        String relatedInvoiceNumber = "";
+        String relatedInvoiceCode = "";
         if (uploadParam.getTypeFlag() == 4) {
             MzDzfpUpload mzDzfpUpload = BeanUtil.copyProperties(uploadParam, MzDzfpUpload.class);
             mzDzfpUpload.setTypeFlag(3);
@@ -870,32 +870,32 @@ public class BswServerImpl implements BswServer {
             if (CollUtil.isEmpty(list) || StrUtil.isBlank(list.get(0).getFpNo())) {
                 throw new BizException("没有住院蓝字发票,无法上传红字发票");
             }
-            blueInvoiceNo = list.get(0).getFpNo();
-            blueIssueDate = list.get(0).getBlueIssueDate();
+            relatedInvoiceNumber = list.get(0).getFpNo();
+            relatedInvoiceCode = list.get(0).getOpCode();
         }
         requestId = Convert.toStr(requestId, OptimalLimitDigitGenerator.generate().toString());
         MzInvoiceInfo mzInvoiceInfo = createZyInvoiceInfo(uploadParam, requestId);
         //先插入记录
         mzDzfpUploadMapper.delete(getQueryWrapper(uploadParam));
         uploadParam.setRequestId(requestId);
-//        uploadParam.setReceiptNo(requestId);
+        uploadParam.setSerialNo(uploadParam.getSerialNo());
         mzDzfpUploadMapper.insert(uploadParam);
         ResultInfo resultInfo;
         if (uploadParam.getTypeFlag() == 3) {
             resultInfo = zyBlueInvoice(mzInvoiceInfo);
         } else {
             //作废
-            mzInvoiceInfo.setBlueInvoiceNo(blueInvoiceNo);
-            mzInvoiceInfo.setBlueIssueDate(blueIssueDate);
+            mzInvoiceInfo.setRelatedInvoiceNumber(relatedInvoiceNumber);
+            mzInvoiceInfo.setRelatedInvoiceCode(relatedInvoiceCode);
             mzInvoiceInfo.setRedOffsetCode("01");
             resultInfo = zyRedInvoice(mzInvoiceInfo);
         }
-        if (!ResultInfo.SUCCESS_CODE.equals(resultInfo.getCode())) {
+        if (!ResultInfo.SUCCESS_CODE.equals(resultInfo.getData().get("result"))) {
             return R.error(resultInfo.getMessage());
         }
-        MzReceiptSerial mzReceiptSerial = new MzReceiptSerial(uploadParam.getPatientId(), uploadParam.getTimes());
+        MzReceiptSerial mzReceiptSerial = new MzReceiptSerial(uploadParam.getPatientId(), uploadParam.getTimes(),Integer.parseInt(uploadParam.getSerialNo()));
         mzReceiptSerial.setReceiptNo(uploadParam.getReceiptNo());
-        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, uploadParam.getTypeFlag());
     }
 
@@ -949,7 +949,7 @@ public class BswServerImpl implements BswServer {
                 .outpatientNo(aPatientMi.getOutpatientNo())
                 .deptName(zdUnitCode.getName())
                 .deptCode(uploadParam.getPatientId())
-                .sex(aPatientMi.getSex())
+                .sex(GenderEnum.getGenderByCode(Integer.parseInt(aPatientMi.getSex())).name)
                 .age(aPatientMi.getAge().toString())
                 .patientName(employee.getEmployeeName())
                 .patientIdTypeCode(gePatientIdTypeCode(aPatientMi.getPsnCertType()))
@@ -1074,6 +1074,7 @@ public class BswServerImpl implements BswServer {
                             .serialNo(Convert.toInt(billItem.getCode()))
                             .itemTypeName(billItem.getName())
                             .itemName(billItem.getName())
+                            .itemCode(billItem.getCode())
                             .amount(typeFlag == 4 ? fee.negate() : fee)
                             .taxRate(BigDecimal.ZERO)
                             .taxAmount(BigDecimal.ZERO)
@@ -1109,7 +1110,7 @@ public class BswServerImpl implements BswServer {
 //        String paramJson = JsonUtil.object2Json(mzInvoiceInfo);
 //        return requestInvoice(paramJson, url, "开具住院蓝字发票");
         String url = getUrl() + "public/ebill/invoicehisissue";
-        JSMzInvoiceInfo jsMzInvoiceInfo = new JSMzInvoiceInfo().transformFromMzInvoiceInfo(mzInvoiceInfo);
+        JSMzInvoiceInfo jsMzInvoiceInfo = new JSMzInvoiceInfo().transformFromMzInvoiceInfo(mzInvoiceInfo,"01");
         String paramJson = JsonUtil.object2Json(jsMzInvoiceInfo);
 
         log.info("url:{}", url);
@@ -1125,9 +1126,17 @@ public class BswServerImpl implements BswServer {
      * @return: cn.hnthyy.thmz.entity.mzdzfp.ResultInfo
      */
     public ResultInfo zyRedInvoice(MzInvoiceInfo mzInvoiceInfo) {
-        String url = getUrl() + "bsw-server/evasp/api/nscs/hospital/redInvoice";
+//        String url = getUrl() + "bsw-server/evasp/api/nscs/hospital/redInvoice";
+//        String paramJson = JsonUtil.object2Json(mzInvoiceInfo);
+//        return requestInvoice(paramJson, url, "开具住院红字发票");
+        String url = getUrl() + "public/ebill/invoicehiswriteoff";
         String paramJson = JsonUtil.object2Json(mzInvoiceInfo);
-        return requestInvoice(paramJson, url, "开具住院红字发票");
+        JSRedMzInvoiceInfo jsRedMzInvoiceInfo = new JSRedMzInvoiceInfo().transformFromMzInvoiceInfo(mzInvoiceInfo,"01");
+        String paramJson1 = JsonUtil.object2Json(jsRedMzInvoiceInfo);
+
+        log.info("url:{}", url);
+        log.info("请求前参数:{}", paramJson);
+        return requestInvoice(paramJson1, url, "开具住院红字发票");
     }
 
     /**
@@ -1141,7 +1150,7 @@ public class BswServerImpl implements BswServer {
 //        String url = getUrl() + "bsw-server/evasp/api/nscs/outpatient/redInvoice";
         String url = getUrl() + "public/ebill/invoicehiswriteoff";
         String paramJson = JsonUtil.object2Json(mzInvoiceInfo);
-        JSRedMzInvoiceInfo jsRedMzInvoiceInfo = new JSRedMzInvoiceInfo().transformFromMzInvoiceInfo(mzInvoiceInfo);
+        JSRedMzInvoiceInfo jsRedMzInvoiceInfo = new JSRedMzInvoiceInfo().transformFromMzInvoiceInfo(mzInvoiceInfo,"01");
         String paramJson1 = JsonUtil.object2Json(jsRedMzInvoiceInfo);
 
         log.info("url:{}", url);

+ 3 - 3
src/main/resources/static/js/mz/toll_administration.js

@@ -632,9 +632,9 @@ function initFeeTable() {
                         if(fpVsesionNo == 1){
                             str += '<button type="button" class="registration-no-color-foot-button" title="上传电子发票" onclick="printDzfp(\'' + row.patientId + '\',' + row.times + ',' + row.receiptNo +',1'+ ');" style="color: #35D082;"><i class="fa fa-upload"></i></button>';
 //                            str += '<button type="button" class="registration-no-color-foot-button" title="开具电子发票" onclick="issueEBill(\'' + row.realNo + '\',' + row.amount + ',\'' + row.name + '\',\'' + row.doctorCode +'\'' + ');" style="color: #35D082;"><i class="fa fa-sign-in"></i></button>';
-                            str += '<button type="button" class="registration-no-color-foot-button"title="下载电子发票" onclick="onclick="openDzfpDownModal(\'' + row.mzyReqrec.patientId + '\',' + row.mzyReqrec.times +',\'' + row.mzyReqrec.serialNo + '\'' + ')"><i class="fa fa-download"></i></button>';
+                            str += '<button type="button" class="registration-no-color-foot-button"title="下载电子发票" onclick="openDzfpDownModal(\'' + row.patientId + '\',' + row.times +',\'' + row.serialNo + '\'' + ')"><i class="fa fa-download"></i></button>';
                             str += '<button type="button" class="registration-no-color-foot-button"title="查询电子发票" onclick="getEBill(\'' + row.serialNo+ '\',)"><i class="fa fa-search"></i></button>';
-                            str += '<button type="button" class="registration-no-color-foot-button"title="下载电子发票" onclick="downloadEBill(\'' + row.serialNo+ '\',)"><i class="fa fa-download"></i></button>';
+//                            str += '<button type="button" class="registration-no-color-foot-button"title="下载电子发票" onclick="downloadEBill(\'' + row.serialNo+ '\',)"><i class="fa fa-download"></i></button>';
                         }
 
                         str += '<button type="button" class="registration-no-color-foot-button"title="支付明细" onclick="depositFileList(\'' + row.patientId + '\',' + row.times + ',' + row.receiptNo + ')"><i class="fa fa-th-list"></i></button>';
@@ -661,7 +661,7 @@ function initFeeTable() {
                         str += '<button type="button" class="registration-no-color-foot-button"title="支付明细" onclick="depositFileList(\'' + row.patientId + '\',' + row.times + ',' + row.receiptNo + ')"><i class="fa fa-th-list"></i></button>';
                         if(fpVsesionNo == 1){
                             str += '<button type="button" class="registration-no-color-foot-button"title="电子发票作废" onclick="uploadMzInvoice(\'' + row.patientId + '\',' + row.times + ',' + row.receiptNo +',2'+ ')"><i class="fa fa-mail-reply-all"></i></button>';
-                            str += '<button type="button" class="registration-no-color-foot-button"title="下载已作废的电子发票" onclick="onclick="openDzfpDownModal(\'' + row.mzyReqrec.patientId + '\',' + row.mzyReqrec.times +',\'' + row.mzyReqrec.serialNo + '\'' + ')"><i class="fa fa-download"></i></button>';
+                            str += '<button type="button" class="registration-no-color-foot-button"title="下载已作废的电子发票" onclick="openDzfpDownModal(\'' + row.mzyReqrec.patientId + '\',' + row.mzyReqrec.times +',\'' + row.mzyReqrec.serialNo + '\'' + ')"><i class="fa fa-download"></i></button>';
                         }
                         // str += '<button type="button" class="registration-no-color-foot-button" title="修改收款方式" onclick="showChequType(\'' + row.patientId + '\','+row.times+','+row.receiptNo+')"><i class="fa fa-credit-card"></i></button>' ;
                         return str;