Kaynağa Gözat

电子发票版本

lihong 7 ay önce
ebeveyn
işleme
4f2f09fc63
35 değiştirilmiş dosya ile 2017 ekleme ve 185 silme
  1. 7 1
      src/main/java/cn/hnthyy/thmz/Utils/TokenUtil.java
  2. 66 25
      src/main/java/cn/hnthyy/thmz/Utils/Tools.java
  3. 4 0
      src/main/java/cn/hnthyy/thmz/common/Constants.java
  4. 42 2
      src/main/java/cn/hnthyy/thmz/controller/api/MedicalViewApiController.java
  5. 32 18
      src/main/java/cn/hnthyy/thmz/controller/mz/MzReceiptSerialController.java
  6. 40 7
      src/main/java/cn/hnthyy/thmz/controller/mz/MzyReqrecController.java
  7. 45 38
      src/main/java/cn/hnthyy/thmz/controller/mzdzfp/BswController.java
  8. 10 0
      src/main/java/cn/hnthyy/thmz/controller/zd/DictDataController.java
  9. 1 0
      src/main/java/cn/hnthyy/thmz/entity/his/mz/MzChargeDetail.java
  10. 6 0
      src/main/java/cn/hnthyy/thmz/entity/his/mz/MzDepositFile.java
  11. 4 0
      src/main/java/cn/hnthyy/thmz/entity/his/mz/MzReceiptSerial.java
  12. 111 0
      src/main/java/cn/hnthyy/thmz/entity/his/zd/ZdTaxClassCode.java
  13. 3 2
      src/main/java/cn/hnthyy/thmz/entity/mzdzfp/InvoiceDetail.java
  14. 47 0
      src/main/java/cn/hnthyy/thmz/entity/mzdzfp/MzDzfpUpload.java
  15. 6 0
      src/main/java/cn/hnthyy/thmz/entity/mzdzfp/MzInvoiceInfo.java
  16. 10 0
      src/main/java/cn/hnthyy/thmz/entity/mzdzfp/SetlInfo.java
  17. 74 0
      src/main/java/cn/hnthyy/thmz/enums/InsutypeEnum.java
  18. 3 0
      src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzChargeDetailMapper.java
  19. 17 4
      src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzDepositFileMapper.java
  20. 35 0
      src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzDzfpUploadMapper.java
  21. 34 0
      src/main/java/cn/hnthyy/thmz/mapper/his/mz/ZdTaxClassCodeMapper.java
  22. 2 0
      src/main/java/cn/hnthyy/thmz/service/his/mz/MzReceiptSerialService.java
  23. 56 2
      src/main/java/cn/hnthyy/thmz/service/his/mzdzfp/BswServer.java
  24. 7 0
      src/main/java/cn/hnthyy/thmz/service/his/zd/DictDataService.java
  25. 10 0
      src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzChargeDetailServiceImpl.java
  26. 54 0
      src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzReceiptSerialServiceImpl.java
  27. 6 1
      src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzyReqrecServiceImpl.java
  28. 977 15
      src/main/java/cn/hnthyy/thmz/service/impl/his/mzdzfp/BswServerImpl.java
  29. 7 0
      src/main/java/cn/hnthyy/thmz/service/impl/his/zd/DictDataServiceImpl.java
  30. 30 0
      src/main/resources/static/js/common/string-util.js
  31. 10 1
      src/main/resources/static/js/mz/clinic.js
  32. 46 28
      src/main/resources/static/js/mz/registration.js
  33. 116 34
      src/main/resources/static/js/mz/registration_list.js
  34. 89 6
      src/main/resources/static/js/mz/toll_administration.js
  35. 10 1
      src/main/resources/templates/mz/toll_administration.html

+ 7 - 1
src/main/java/cn/hnthyy/thmz/Utils/TokenUtil.java

@@ -79,7 +79,13 @@ public class TokenUtil {
         String token = TokenUtil.getToken(HttpContextUtils.getHttpServletRequest());
         AssertUtil.isNotBlank(token,"业务处理失败,用户token不存在");
         DecodedJWT decodedJWT = TokenUtil.parseJWT(token);
-        return (User) JsonUtil.jsontoObject(decodedJWT.getSubject(), User.class);
+        User user = (User) JsonUtil.jsontoObject(decodedJWT.getSubject(), User.class);
+        if(user == null){
+            user = new User();
+            user.setUserIdCode(Constants.BRZZJF_CODE);
+            user.setUserName("自助");
+        }
+        return user;
     }
 
 

+ 66 - 25
src/main/java/cn/hnthyy/thmz/Utils/Tools.java

@@ -1,13 +1,17 @@
 package cn.hnthyy.thmz.Utils;
 
+import cn.hnthyy.thmz.entity.his.mz.MzDepositFile;
 import cn.hnthyy.thmz.entity.his.mz.MzYjReq;
 import cn.hnthyy.thmz.entity.thmz.Config;
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.codec.Base64;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
@@ -748,56 +752,77 @@ public class Tools {
     public static String getAmPmDateDiff(Date requestDate,String ampm){
           if("a".equals(ampm)){
               if(DateUtil.isIn(requestDate,DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 08:00:00","yyyy-MM-dd HH:mm:ss"),DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 08:29:59","yyyy-MM-dd HH:mm:ss"))){
-                  return "08:00 ~ 08:30";
+                  return "08:00  08:30";
               }
               if(DateUtil.isIn(requestDate,DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 08:30:00","yyyy-MM-dd HH:mm:ss"),DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 08:59:59","yyyy-MM-dd HH:mm:ss"))){
-                  return "08:30 ~ 09:00";
+                  return "08:30  09:00";
               }
               if(DateUtil.isIn(requestDate,DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 09:00:00","yyyy-MM-dd HH:mm:ss"),DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 09:29:59","yyyy-MM-dd HH:mm:ss"))){
-                  return "09:00 ~ 09:30";
+                  return "09:00  09:30";
               }
               if(DateUtil.isIn(requestDate,DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 09:30:00","yyyy-MM-dd HH:mm:ss"),DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 09:59:59","yyyy-MM-dd HH:mm:ss"))){
-                  return "09:30 ~ 10:00";
+                  return "09:30  10:00";
               }
               if(DateUtil.isIn(requestDate,DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 10:00:00","yyyy-MM-dd HH:mm:ss"),DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 10:29:59","yyyy-MM-dd HH:mm:ss"))){
-                  return "10:00 ~ 10:30";
+                  return "10:00  10:30";
               }
               if(DateUtil.isIn(requestDate,DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 10:30:00","yyyy-MM-dd HH:mm:ss"),DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 11:00:00","yyyy-MM-dd HH:mm:ss"))){
-                  return "10:30 ~ 11:00";
+                  return "10:30  11:00";
               }
               if(DateUtil.isIn(requestDate,DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 11:00:00","yyyy-MM-dd HH:mm:ss"),DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 11:29:59","yyyy-MM-dd HH:mm:ss"))){
-                  return "11:00 ~ 11:30";
+                  return "11:00  11:30";
               }
               if(DateUtil.isIn(requestDate,DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 11:30:00","yyyy-MM-dd HH:mm:ss"),DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 12:00:00","yyyy-MM-dd HH:mm:ss"))){
-                  return "11:30 ~ 12:00";
+                  return "11:30  12:00";
               }
           }
           if("p".equals(ampm)){
               if(DateUtil.isIn(requestDate,DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 14:00:00","yyyy-MM-dd HH:mm:ss"),DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 14:29:59","yyyy-MM-dd HH:mm:ss"))){
-                  return "14:00 ~ 14:30";
+                  return "14:00  14:30";
               }
               if(DateUtil.isIn(requestDate,DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 14:30:00","yyyy-MM-dd HH:mm:ss"),DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 14:59:59","yyyy-MM-dd HH:mm:ss"))){
-                  return "14:30 ~ 15:00";
+                  return "14:30  15:00";
               }
               if(DateUtil.isIn(requestDate,DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 15:00:00","yyyy-MM-dd HH:mm:ss"),DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 15:29:59","yyyy-MM-dd HH:mm:ss"))){
-                  return "15:00 ~ 15:30";
+                  return "15:00  15:30";
               }
               if(DateUtil.isIn(requestDate,DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 15:30:00","yyyy-MM-dd HH:mm:ss"),DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 15:59:59","yyyy-MM-dd HH:mm:ss"))){
-                  return "15:30 ~ 16:00";
+                  return "15:30  16:00";
               }
               if(DateUtil.isIn(requestDate,DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 16:00:00","yyyy-MM-dd HH:mm:ss"),DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 16:29:59","yyyy-MM-dd HH:mm:ss"))){
-                  return "16:00 ~ 16:30";
+                  return "16:00  16:30";
               }
               if(DateUtil.isIn(requestDate,DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 16:30:00","yyyy-MM-dd HH:mm:ss"),DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 16:59:59","yyyy-MM-dd HH:mm:ss"))){
-                  return "16:30 ~ 17:00";
+                  return "16:30  17:00";
               }
               if(DateUtil.isIn(requestDate,DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 17:00:00","yyyy-MM-dd HH:mm:ss"),DateUtil.parse(DateUtil.format(requestDate,"yyyy-MM-dd")+" 17:30:00","yyyy-MM-dd HH:mm:ss"))){
-                  return "17:00 ~ 17:30";
+                  return "17:00  17:30";
               }
           }
           if("p4".equals(ampm)){
-              return "17:00 ~ 21:00";
+              return "17:00  21:00";
           }
+        if("n".equals(ampm)){
+            return "12:00 至 14:00";
+        }
+        if("d".equals(ampm)){
+            return "00:00 至 24:00";
+        }
+        if("e".equals(ampm)){
+            return "17:30 至 24:00";
+        }
+        if("l".equals(ampm)){
+            return "00:00 至 08:00";
+        }
+        if("a5".equals(ampm)){
+            return "08:00 至 15:00";
+        }
+        if("a6".equals(ampm)){
+            return "17:00 至 22:00";
+        }
+        if("a7".equals(ampm)){
+            return "22:00 至 08:00";
+        }
         return "";
     }
 
@@ -807,17 +832,31 @@ public class Tools {
     }
 
     public static void main(String[] args) {
-        //String date1 = "2025-03-25 08:00:00";
-        //String date2 = "2025-03-25 08:00:00";
-        //System.out.println(DateUtil.parseDateTime(date1).getTime()==DateUtil.parseDateTime(date2).getTime());
-        //System.out.println(DateUtil.between(DateUtil.parseDateTime(date1),DateUtil.parseDateTime(date2), DateUnit.SECOND));
-
-        //System.out.println(IdUtil.getSnowflake(2,2).nextIdStr());
-        //System.out.println(IdUtil.simpleUUID());
-
-        getCamelCaseInsertSql("yz_zy_patient_fee","inpatient_no, admiss_times, ledger_sn, detail_sn, charge_date, op_id_code, charge_code, infant_flag, charge_status, charge_fee, occ_time, act_order_no, dept_code, ward_code, order_count, exec_unit, zy_serial_no, op_flag, op_id, op_date, yb_self_flag");
+        //Syste/m.out.println(DateUtil.offsetSecond(now,-(60*2+RandomUtil.randomInt(0, 30)*60)));
+        //System.out.println(splitMoth("2025-03",5));
+        //getCamelCaseInsertSql("mz_medical_main","patient_id, times, name, sex, birth_day, marry_code, country, nation, certificate_type, social_no, adress, phone_no, gms, allergen_name, qtgms, qtgmy, gh_date, bd_date, visit_date, dept_code, doctor_name, doctor_zc, visit_type, first_or_not, sy_or_not, mz_mtb, mz_hz_fj, jz_hz_qx, zyz_date, emr_chief_complaint, icd_name, icd_code, icd_name1, icd_code1, icd_name2, icd_code2, icd_name3, icd_code3, icd_name4, icd_code4, icd_name5, icd_code5, icd_name6, icd_code6, icd_name7, icd_code7, icd_name8, icd_code8, icd_name9, icd_code9, icd_name10, icd_code10, opr_date1, opr_name1, opr_code1, opr_doctor1, mzfs1, mz_doctor1, opr_scale1, opr_date2, opr_name2, opr_code2, opr_doctor2, mzfs2, mz_doctor2, opr_scale2, opr_date3, opr_name3, opr_code3, opr_doctor3, mzfs3, mz_doctor3, opr_scale3, opr_date4, opr_name4, opr_code4, opr_doctor4, mzfs4, mz_doctor4, opr_scale4, opr_date5, opr_name5, opr_code5, opr_doctor5, mzfs5, mz_doctor5, opr_scale5, total_fee, zf_fee, fee1, fee2, fee3, fee4, fee5, fee6, fee7, fee8, fee901, fee902, fee1001, fee1002, fee1003, fee11, fee12, fee13, fee14, fee15, fee16, fee17, fee18, fee19, fee20, fee21, fee22, fee23, fee24, fee25");
+    }
 
+    public static List<Map<String,String>> splitMoth(String yearMoth ,int pageSize){
+        List<Map<String, String>> list = new ArrayList<>(10);
+        Date now = DateUtil.parseDate(yearMoth + "-01");
+        int lastDayOfMonth = DateUtil.getLastDayOfMonth(now);
+        List<Integer> arr = new ArrayList<>(31);
+        for (int i = 1; i <=lastDayOfMonth ; i++) {
+            arr.add(i);
+        }
+        List<List<Integer>> split = CollUtil.split(arr, pageSize);
+        for(List<Integer> item :split){
+            Map<String, String> map = new HashMap<>(2);
+            String startDay = item.get(0) >= 10 ? item.get(0)+"" : "0" +item.get(0) ;
+            String endDay = item.get(item.size()-1) >= 10 ? item.get(item.size()-1)+"" : "0" +item.get(item.size()-1) ;
+            map.put("startTime", yearMoth + "-" + startDay + " 00:00:00");
+            map.put("endTime", yearMoth + "-" + endDay + " 23:59:59");
+            list.add(map);
+        }
+        return list;
     }
+
     /**
      * @description: 获取药品编码
      * @author: lihong
@@ -905,4 +944,6 @@ public class Tools {
         return buffer.toString();
     }
 
+
+
 }

+ 4 - 0
src/main/java/cn/hnthyy/thmz/common/Constants.java

@@ -12,6 +12,10 @@ public class Constants {
      * 社会统一信用代码
      */
     public static final String USCI_CODE = "91430100663957823C";
+    /**
+     * 医疗服务 税收分类编码
+     */
+    public static final String TAX_SORT_CODE = "3070202000000000000";
     /**
      * 默认用户id
      */

+ 42 - 2
src/main/java/cn/hnthyy/thmz/controller/api/MedicalViewApiController.java

@@ -21,6 +21,7 @@ import cn.hnthyy.thmz.entity.his.zd.ZdMzClass;
 import cn.hnthyy.thmz.entity.his.zd.ZdUnitCode;
 import cn.hnthyy.thmz.entity.his.zy.ZyActpatient;
 import cn.hnthyy.thmz.entity.his.zy.ZyDepositFile;
+import cn.hnthyy.thmz.entity.mzdzfp.MzDzfpUpload;
 import cn.hnthyy.thmz.entity.thmz.Clinic;
 import cn.hnthyy.thmz.entity.thmz.Config;
 import cn.hnthyy.thmz.entity.thmz.DiscountVo;
@@ -39,6 +40,8 @@ import cn.hnthyy.thmz.pageDto.ZdUnitCodePageDto;
 import cn.hnthyy.thmz.service.his.RegionService;
 import cn.hnthyy.thmz.service.his.ResponceTypeService;
 import cn.hnthyy.thmz.service.his.mz.*;
+import cn.hnthyy.thmz.service.his.mzdzfp.BswServer;
+import cn.hnthyy.thmz.service.his.zd.DictDataService;
 import cn.hnthyy.thmz.service.his.zd.ZdEmpTitleService;
 import cn.hnthyy.thmz.service.his.zd.ZdMzClassService;
 import cn.hnthyy.thmz.service.his.zd.ZdUnitCodeService;
@@ -144,6 +147,10 @@ public class MedicalViewApiController {
     private RegionService regionService;
     @Resource
     private MzOrderDetailService mzOrderDetailService;
+    @Resource
+    private BswServer bswServer;
+    @Resource
+    private DictDataService dictDataService;
 
     //海慈身份证类型
     private static final String ID_CARD_TYPE = "11";
@@ -876,7 +883,13 @@ public class MedicalViewApiController {
                 BigDecimal tempCouponAmt = calcuCouponAmt(haiciCharge);
                 setAllDepositFile(mzDepositFiles,haiciCharge, Constants.DJZ,tempCouponAmt);
             }
-            mzChargeDetailService.chargeFee(whiteList.getOpId(), mzDepositFileVo, whiteList.getOpId());
+           int receiptNo = mzChargeDetailService.chargeFee(whiteList.getOpId(), mzDepositFileVo, whiteList.getOpId());
+            requestDzfp(MzDzfpUpload.builder()
+                    .patientId(mzDepositFileVo.getPatientId())
+                    .times(mzDepositFileVo.getTimes())
+                    .typeFlag(1)
+                    .receiptNo(receiptNo)
+                    .build(),false);
             results.put("resultCode", 0);
             results.put("resultMessage", "缴费成功");
             results.put("guideListInfo", "");
@@ -896,6 +909,15 @@ public class MedicalViewApiController {
         }
     }
 
+    private void requestDzfp(MzDzfpUpload mzDzfpUpload,boolean ghFlag){
+        if(dictDataService.queryFpVersion() == 1){
+            MzReceiptSerial mzReceiptSerial = new MzReceiptSerial(mzDzfpUpload.getPatientId(), mzDzfpUpload.getTimes());
+            mzReceiptSerial.setReceiptNo(mzDzfpUpload.getReceiptNo());
+            bswServer.asnyMzInvoice(mzReceiptSerial,ghFlag,mzDzfpUpload.getTypeFlag());
+        }
+    }
+
+
     private BigDecimal calcuCouponAmt(HaiciCharge haiciCharge) {
         BigDecimal temp = haiciCharge.getPayAmt().subtract(Convert.toBigDecimal(haiciCharge.getAcctpayAmt(), BigDecimal.ZERO)).subtract(Convert.toBigDecimal(haiciCharge.getCashpayAmt(), BigDecimal.ZERO)).subtract(Convert.toBigDecimal(haiciCharge.getFundpayAmt(), BigDecimal.ZERO));
         if(temp.compareTo(haiciCharge.getCouponAmt()) < 0 ){
@@ -1004,7 +1026,13 @@ public class MedicalViewApiController {
                 }
                 if (CollUtil.isNotEmpty(mzDepositFiles)) {
                     mzDepositFileVo.setMzDepositFiles(mzDepositFiles);
-                    mzChargeDetailService.chargeFee(Constants.BRZZJF_CODE, mzDepositFileVo, Constants.BRZZJF_CODE);
+                   int receiptNo = mzChargeDetailService.chargeFee(Constants.BRZZJF_CODE, mzDepositFileVo, Constants.BRZZJF_CODE);
+                    requestDzfp(MzDzfpUpload.builder()
+                            .patientId(mzDepositFileVo.getPatientId())
+                            .times(mzDepositFileVo.getTimes())
+                            .typeFlag(1)
+                            .receiptNo(receiptNo)
+                            .build(),false);
                 } else {
                     throw new BizException("获取医保费用失败");
                 }
@@ -1146,6 +1174,12 @@ public class MedicalViewApiController {
             mzDepositFileVo.setRefundType(YesNoEnum.YES.code);
             User tokenUser = userService.queryUserByUserIdCode(Constants.BRZZJF_CODE);
             mzChargeDetailService.refundFee(tokenUser.getUserIdCode(), mzDepositFileVo, Constants.BRZZJF_CODE);
+            requestDzfp(MzDzfpUpload.builder()
+                    .patientId(mzDepositFileVo.getPatientId())
+                    .times(mzDepositFileVo.getTimes())
+                    .typeFlag(2)
+                    .receiptNo(mzDepositFileVo.getReceiptNo())
+                    .build(),false);
             results.put("resultCode", 0);
             results.put("resultMessage", "退费成功");
             results.put("guideListInfo", "");
@@ -2371,6 +2405,12 @@ public class MedicalViewApiController {
             }
             mzyReqrec.setOpId(whiteList.getOpId());
             int num = mzyReqrecService.saveMzyReqrec(mzyReqrecPageDto, whiteList.getOpId());
+            requestDzfp(MzDzfpUpload.builder()
+                    .patientId(mzyReqrecPageDto.getMzyReqrec().getPatientId())
+                    .times(num)
+                    .typeFlag(1)
+                    .receiptNo(0)
+                    .build(),true);
             resultMap.put("resultCode", 0);
             resultMap.put("message", "保存挂号信息成功");
             return resultMap;

+ 32 - 18
src/main/java/cn/hnthyy/thmz/controller/mz/MzReceiptSerialController.java

@@ -1,5 +1,6 @@
 package cn.hnthyy.thmz.controller.mz;
 
+import cn.hnthyy.thmz.Utils.AssertUtil;
 import cn.hnthyy.thmz.Utils.R;
 import cn.hnthyy.thmz.Utils.TokenUtil;
 import cn.hnthyy.thmz.comment.UserLoginToken;
@@ -175,25 +176,7 @@ public class MzReceiptSerialController {
             resultMap.put("code", 0);
             resultMap.put("message", "根据病人编号和就诊次数查询其当次缴费对应的所有发票成功");
             //将打印标志改为已经打印
-            //mzChargeDetailService.modifyPrintFlag(patientId,timesList);
             List<MzReceiptSerial> mzReceiptSerials = mzReceiptSerialService.queryAllSerialForThisTime(patientId, times, receiptNo);
-//            if(mzReceiptSerial == null){
-//                mzReceiptSerialService.repairDataFromBack(patientId, times, receiptNo);
-//                mzReceiptSerial = mzReceiptSerialService.queryAllSerialForThisTime(patientId, times, receiptNo);
-//            }
-//            if (StringUtils.isBlank(mzReceiptSerial.getChequeType())) {
-//                resultMap.put("code", -1);
-//                resultMap.put("message", "当前病人发票表中的收费类型为空,无法打印发票,请及时联系管理员");
-//                log.info("当前病人发票表中的收费类型为空,无法打印发票,请及时联系管理员,patientId={},time={},receiptNo={}", patientId, times,receiptNo);
-//                return resultMap;
-//            }
-//            if(Arrays.asList(Constants.YBJZ,Constants.BYJZ).contains(mzReceiptSerial.getChequeType())){
-//                resultMap.put("code", -1);
-//                String type = Constants.YBJZ.equals(mzReceiptSerial.getChequeType())?"本院记账":"医保记账";
-//                resultMap.put("message", type+"发票无法打印发票,请及时联系管理员");
-//                log.info(type+"发票无法打印发票,请及时联系管理员,patientId={},time={},receiptNo={},chequeType={}", patientId, times,receiptNo,mzReceiptSerial.getChequeType());
-//                return resultMap;
-//            }
             MzReceiptSerial returnMzReceiptSerial = mzReceiptSerialService.printReceiptSerial(mzReceiptSerials, tokenUser);
             List<Integer> timesList = new ArrayList<>();
             List<MzReceiptSerialVo> mzReceiptSerialVos = mzReceiptSerialService.getMzReceiptSerialVos(returnMzReceiptSerial, timesList, returnMzReceiptSerial.getReceiptBill());
@@ -222,6 +205,37 @@ public class MzReceiptSerialController {
         }
     }
 
+    @UserLoginToken
+    @PostMapping("/getNewAllSerialForThisTime")
+    public R getNewAllSerialForThisTime(@RequestBody MzReceiptSerial mzReceiptSerial){
+        AssertUtil.isNotBlank(mzReceiptSerial.getPatientId(),"门诊号不能为空");
+        AssertUtil.isNotBlank(mzReceiptSerial.getTimes(),"就诊次数不能为空");
+        AssertUtil.isNotBlank(mzReceiptSerial.getReceiptNo(),"缴费次数能为空");
+        MzDepositFile mz = new MzDepositFile(mzReceiptSerial.getPatientId(), mzReceiptSerial.getTimes());
+        mz.setReceiptNo(mzReceiptSerial.getReceiptNo());
+        List<MzDepositFile> mzDepositFiles = mzDepositFileService.queryMzDepositFile(mz);
+        //非本院记账 和非医保记账金额
+        BigDecimal totalPay = BigDecimal.ZERO;
+        //所有付款方式总金额
+        BigDecimal fullTotalPay = BigDecimal.ZERO;
+        List<ZdChequeType> chequeTypes = zdChequeTypeService.queryAllZdChequeType();
+        Map<String, Integer> printFlagMap = chequeTypes.stream().collect(Collectors.toMap(ZdChequeType::getCode, ZdChequeType::getPrintFlag));
+        if (mzDepositFiles != null && mzDepositFiles.size() > 0) {
+            for (MzDepositFile mzDepositFile : mzDepositFiles) {
+                if (Convert.toInt(printFlagMap.get(mzDepositFile.getChequeType()),0) == 1) {
+                    totalPay = totalPay.add(mzDepositFile.getAmount());
+                }
+                fullTotalPay=fullTotalPay.add(mzDepositFile.getAmount());
+            }
+        }
+        if (BigDecimal.ZERO.compareTo(totalPay) == 0) {
+            return R.error("当前病人没有实际缴费,暂时不打印发票");
+        }
+        List<MzReceiptSerial> mzReceiptSerials = mzReceiptSerialService.queryAllSerialForThisTime(mzReceiptSerial.getPatientId(), mzReceiptSerial.getTimes(), mzReceiptSerial.getReceiptNo());
+        mzReceiptSerialService.printNewReceiptSerial(mzReceiptSerials);
+        return R.ok();
+    }
+
 //    /**
 //     * 将发票列表转换成发票视图列表
 //     *

+ 40 - 7
src/main/java/cn/hnthyy/thmz/controller/mz/MzyReqrecController.java

@@ -14,6 +14,8 @@ import cn.hnthyy.thmz.enums.PayMarkEnum;
 import cn.hnthyy.thmz.enums.YesNoEnum;
 import cn.hnthyy.thmz.pageDto.MzyReqrecPageDto;
 import cn.hnthyy.thmz.service.his.mz.*;
+import cn.hnthyy.thmz.service.his.mzdzfp.BswServer;
+import cn.hnthyy.thmz.service.his.zd.DictDataService;
 import cn.hnthyy.thmz.service.his.zd.ZdChequeTypeService;
 import cn.hnthyy.thmz.service.his.zd.ZdUnitCodeService;
 import cn.hnthyy.thmz.service.his.zy.ZyActpatientService;
@@ -23,7 +25,9 @@ import cn.hnthyy.thmz.service.thmz.WindowsService;
 import cn.hnthyy.thmz.vo.MzyReqrecVo;
 import cn.hnthyy.thmz.vo.PageViewVo;
 import cn.hnthyy.thmz.vo.ThmzmxsrParamsVo;
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.convert.Convert;
 import cn.hutool.core.util.StrUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -31,6 +35,7 @@ import org.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
@@ -65,6 +70,10 @@ public class MzyReqrecController {
     @SuppressWarnings("all")
     @Autowired
     private ZyActpatientService zyActpatientService;
+    @Resource
+    private BswServer bswServer;
+    @Resource
+    private DictDataService dictDataService;
 
     /**
      * 保存挂号信息
@@ -161,6 +170,16 @@ public class MzyReqrecController {
             mzyReqrec.setWebId(tokenUser.getUserIdCode());
             String ipAddress = HttpUtil.getIPAddress(httpServletRequest);
             int num = mzyReqrecService.saveMzyReqrec(mzyReqrecPageDto, ipAddress);
+            if(dictDataService.queryFpVersion() == 1){
+                if(PayMarkEnum.CHARGED.code.equals(mzyReqrecPageDto.getPayMark())){
+                    ZdChequeType zdChequeType = zdChequeTypeService.queryChequeTypeByCode(mzyReqrec.getPaymode());
+                    if (zdChequeType != null && zdChequeType.getPrintFlag() != null && zdChequeType.getPrintFlag() == 1) {
+                        MzReceiptSerial mzReceiptSerial = new MzReceiptSerial(mzyReqrecPageDto.getMzyReqrec().getPatientId(),num);
+                        mzReceiptSerial.setOperatorId(tokenUser.getUserName());
+                        bswServer.asnyMzInvoice(mzReceiptSerial,true,1);
+                    }
+                }
+            }
             resultMap.put("code", 0);
             resultMap.put("times", num);
             resultMap.put("message", "保存挂号信息成功");
@@ -701,6 +720,11 @@ public class MzyReqrecController {
                 resultMap.put("message", "打印当前挂号的发票信息失败,用户Token不存在");
                 return resultMap;
             }
+            if (Constants.HLWYY_CODE.equals(tokenUser.getUserIdCode())) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "互联网医院平台挂号无法在门诊窗口打印发票,请让患者联系互联网医院平台!");
+                return resultMap;
+            }
             MzyReqrec mzyReqrec;
             if (times == -1) {
                 mzyReqrec = mzyReqrecService.queryLastMzyReqrecByPatientId(patientId);
@@ -712,10 +736,13 @@ public class MzyReqrecController {
                 resultMap.put("message", "当前病人不存在挂号信息");
                 return resultMap;
             }
-            if (StringUtils.isNotBlank(mzyReqrec.getPrinterId())) {
-                resultMap.put("code", -1);
-                resultMap.put("message", "当前挂号信息已经打印过发票,请勿重复操作");
-                return resultMap;
+            int fpVersion = dictDataService.queryFpVersion();
+            if(fpVersion == 0){
+                if (StringUtils.isNotBlank(mzyReqrec.getPrinterId())) {
+                    resultMap.put("code", -1);
+                    resultMap.put("message", "当前挂号信息已经打印过发票,请勿重复操作");
+                    return resultMap;
+                }
             }
             if(StrUtil.isNotBlank(mzyReqrec.getPaymode())){
                 ZdChequeType zdChequeType = zdChequeTypeService.queryChequeTypeByCode(mzyReqrec.getPaymode());
@@ -734,7 +761,7 @@ public class MzyReqrecController {
                 if(Constants.NIGHT.equals(mzyReqrec.getAmpm()) && StrUtil.isNotBlank(zdUnitCode.getOfficePos1())){
                     officePos = zdUnitCode.getOfficePos1();
                 }
-                resultMap.put("officePos", officePos);
+                resultMap.put("officePos", Convert.toStr(officePos,""));
             }
             Employee employee = employeeService.queryByUserCode(mzyReqrec.getDoctorCode());
             if (employee != null) {
@@ -750,7 +777,11 @@ public class MzyReqrecController {
                 resultMap.put("message", "号段不存在");
                 return resultMap;
             }
-            mzyReqrec.setAmpm(mzZdWorkTime.getName());
+            if(fpVersion == 1){
+                mzyReqrec.setAmpm(Tools.getAmPmDateDiff(mzyReqrec.getRequestDay(),mzyReqrec.getAmpm()));
+            }else {
+                mzyReqrec.setAmpm(mzZdWorkTime.getName());
+            }
             BigDecimal totalFee = mzyReqrec.getReqFee().add(mzyReqrec.getClinicFee()).add(mzyReqrec.getOthFee()).add(mzyReqrec.getBrochureFee()).add(mzyReqrec.getBlbFee() == null ? BigDecimal.ZERO : mzyReqrec.getBlbFee()).add(mzyReqrec.getZlkFee() == null ? BigDecimal.ZERO : mzyReqrec.getZlkFee());
             if (totalFee.compareTo(BigDecimal.ZERO) == 0) {
                 resultMap.put("code", -2);
@@ -779,7 +810,9 @@ public class MzyReqrecController {
                 resultMap.put("day", day.toString());
             }
             mzyReqrec.setPrinterId(tokenUser.getUserIdCode());
-            mzyReqrecService.printMzyReqrecRecept(mzyReqrec);
+            if(fpVersion == 0){
+                mzyReqrecService.printMzyReqrecRecept(mzyReqrec);
+            }
             resultMap.put("code", 0);
             resultMap.put("data", mzyReqrec);
             resultMap.put("user", tokenUser);

+ 45 - 38
src/main/java/cn/hnthyy/thmz/controller/mzdzfp/BswController.java

@@ -2,7 +2,8 @@ package cn.hnthyy.thmz.controller.mzdzfp;
 
 import cn.hnthyy.thmz.Utils.AssertUtil;
 import cn.hnthyy.thmz.Utils.R;
-import cn.hnthyy.thmz.entity.mzdzfp.MzInvoiceInfo;
+import cn.hnthyy.thmz.entity.his.mz.MzReceiptSerial;
+import cn.hnthyy.thmz.entity.mzdzfp.MzDzfpUpload;
 import cn.hnthyy.thmz.entity.mzdzfp.ResultInfo;
 import cn.hnthyy.thmz.service.his.mzdzfp.BswServer;
 import cn.hutool.core.convert.Convert;
@@ -25,22 +26,9 @@ public class BswController {
     @Resource
     private BswServer server;
 
-    @PostMapping("/zyBlueInvoice")
-    public R zyBlueInvoice(@RequestBody MzInvoiceInfo mzInvoiceInfo){
-        ResultInfo resultInfo = server.zyBlueInvoice(mzInvoiceInfo);
-        if(ResultInfo.SUCCESS_CODE.equals(resultInfo.getResultCode())){
-            return R.ok().put("data",resultInfo.getData());
-        }
-        return R.error(resultInfo.getResultMessage());
-    }
-
-    @PostMapping("/zyRedInvoice")
-    public R zyRedInvoice(@RequestBody MzInvoiceInfo mzInvoiceInfo){
-        ResultInfo resultInfo = server.zyRedInvoice(mzInvoiceInfo);
-        if(ResultInfo.SUCCESS_CODE.equals(resultInfo.getResultCode())){
-            return R.ok().put("data",resultInfo.getData());
-        }
-        return R.error(resultInfo.getResultMessage());
+    @PostMapping("/uploadZyInvoice")
+    public R zyBlueInvoice(@RequestBody MzDzfpUpload mzDzfpUpload){
+        return server.uploadZyInvoice(mzDzfpUpload);
     }
 
     /**
@@ -56,11 +44,7 @@ public class BswController {
         AssertUtil.isNotBlank(usciCode,"社会统一信用代码不能为空");
         String timestamp = Convert.toStr(param.get("timestamp"));
         String taxAuthorityCode = Convert.toStr(param.get("taxAuthorityCode"));
-        ResultInfo resultInfo = server.queryTaxClassifyCode(usciCode,timestamp,taxAuthorityCode);
-        if(ResultInfo.SUCCESS_CODE.equals(resultInfo.getResultCode())){
-            return R.ok().put("data",resultInfo.getData());
-        }
-        return R.error(resultInfo.getResultMessage());
+        return server.queryTaxClassifyCode(usciCode,timestamp,taxAuthorityCode);
     }
 
     /**
@@ -70,20 +54,36 @@ public class BswController {
      * @param: param
      * @return: cn.hnthyy.thmz.Utils.R
      **/
-    @PostMapping("/queryLayoutFile")
-    public R queryLayoutFile(@RequestBody Map<String,Object> param){
-        String usciCode = Convert.toStr(param.get("usciCode"));
-        AssertUtil.isNotBlank(usciCode,"社会统一信用代码不能为空");
-        String invoiceNo = Convert.toStr(param.get("invoiceNo"));
-        AssertUtil.isNotBlank(invoiceNo,"发票号不能为空");
-        //获取版式文件类型(0:全部;1:xml;2:pdf)
-        Integer fileType = Convert.toInt(param.get("fileType"));
-        AssertUtil.isNotBlank(fileType,"文件类型不能为空");
-        ResultInfo resultInfo = server.queryLayoutFile(usciCode,invoiceNo,fileType);
-        if(ResultInfo.SUCCESS_CODE.equals(resultInfo.getResultCode())){
-            return R.ok().put("data",resultInfo.getData());
+    @PostMapping("/queryInvoiceFile")
+    public R queryInvoiceFile(@RequestBody MzDzfpUpload mzDzfpUpload){
+        return server.queryInvoiceFile(mzDzfpUpload);
+    }
+
+    /**
+     * @description: typeFlag  1 门诊蓝字发票  2 门诊红字发票  ghFlag true 挂号
+     * @author: lihong
+     * @date: 2025/3/20 15:45
+     * @param: param
+     * @return: cn.hnthyy.thmz.Utils.R
+     **/
+    @PostMapping("/uploadMzInvoice")
+    public R uploadMzInvoice(@RequestBody Map<String,Object> param){
+        String patientId = Convert.toStr(param.get("patientId"));
+        String times = Convert.toStr(param.get("times"));
+        AssertUtil.isNotBlank(patientId,"门诊号不能为空");
+        AssertUtil.isNotBlank(times,"就诊次数不能为空");
+        Integer typeFlag = Convert.toInt(param.get("typeFlag"));
+        Boolean ghFlag = Convert.toBool(param.get("ghFlag"));
+        AssertUtil.isNotBlank(ghFlag,"挂号类型标识不能为空");
+        AssertUtil.isNotBlank(typeFlag,"电子发票类型不能为空");
+        MzReceiptSerial mzReceiptSerial = new MzReceiptSerial(Convert.toStr(param.get("patientId")), Convert.toInt(param.get("times")));
+        mzReceiptSerial.setReceiptNo(Convert.toInt(param.get("receiptNo")));
+        if(typeFlag == 1){
+            return server.getMzBlueInvoice(mzReceiptSerial,ghFlag);
+        }else if(typeFlag == 2){
+            return server.getMzRedInvoice(mzReceiptSerial, ghFlag);
         }
-        return R.error(resultInfo.getResultMessage());
+        return R.error("电子发票类型不能不在范围内");
     }
 
     /**
@@ -97,12 +97,19 @@ public class BswController {
     public R queryIssuedState(@RequestBody Map<String,Object> param){
         String usciCode = Convert.toStr(param.get("usciCode"));
         AssertUtil.isNotBlank(usciCode,"社会统一信用代码不能为空");
-        String requestID = Convert.toStr(param.get("requestID"));
-        AssertUtil.isNotBlank(requestID,"发票开具请求ID不能为空");
-        ResultInfo resultInfo = server.queryIssuedState(usciCode,requestID);
+        String requestId = Convert.toStr(param.get("requestId"));
+        AssertUtil.isNotBlank(requestId,"发票开具请求ID不能为空");
+        ResultInfo resultInfo = server.queryIssuedState(usciCode,requestId);
         if(ResultInfo.SUCCESS_CODE.equals(resultInfo.getResultCode())){
             return R.ok().put("data",resultInfo.getData());
         }
         return R.error(resultInfo.getResultMessage());
     }
+
+
+    @PostMapping("/bsw/getToken")
+    public R getToken(){
+       String token =  server.getToken();
+        return R.ok().put("data",token);
+    }
 }

+ 10 - 0
src/main/java/cn/hnthyy/thmz/controller/zd/DictDataController.java

@@ -44,5 +44,15 @@ public class DictDataController {
         Map<String, Object> res = service.queryDictValueByYpCfPrint();
         return R.ok().put("data", res);
     }
+    /**
+     * @description: 查询发票版本
+     * @author: lihong
+     * @date: 2025/4/17 11:37
+     * @return: cn.hnthyy.thmz.Utils.R
+     **/
+    @GetMapping("/queryFpVersion")
+    public R queryFpVersion(){
+        return R.ok().put("data", service.queryFpVersion());
+    }
 
 }

+ 1 - 0
src/main/java/cn/hnthyy/thmz/entity/his/mz/MzChargeDetail.java

@@ -251,6 +251,7 @@ public class MzChargeDetail implements Serializable,Comparable<MzChargeDetail> {
     private String orderTypeName;
     //0-报销,2-自费
     private String hospApprFlag;
+    private Integer tfFlag;
     public MzChargeDetail(String patientId, Integer times) {
         this.patientId = patientId;
         this.times = times;

+ 6 - 0
src/main/java/cn/hnthyy/thmz/entity/his/mz/MzDepositFile.java

@@ -66,6 +66,12 @@ public class MzDepositFile extends PageBean implements Serializable {
     private String traceNo;
     //抖音团购号
     private String dyTgNo;
+    //退费标识  1退费
+    private Integer tfFlag;
+    //申请科室
+    private String warnCode;
+    //开处方医生
+    private String doctorCode;
     public MzDepositFile() {
     }
     public MzDepositFile(String patientId, Integer times) {

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

@@ -121,6 +121,10 @@ public class MzReceiptSerial implements Serializable {
     private String name;
     //做版本控制,防止发票号被并发修改
     private String bz;
+    //申请科室
+    private String warnCode;
+    //开处放医生
+    private String doctorCode;
 //    public void setCharge1(BigDecimal charge1) {
 //        this.charge1 = charge1;
 //        if(totalCharge==null){

+ 111 - 0
src/main/java/cn/hnthyy/thmz/entity/his/zd/ZdTaxClassCode.java

@@ -0,0 +1,111 @@
+package cn.hnthyy.thmz.entity.his.zd;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+/**
+ * 税收分类编码(ZdTaxClassCode)表实体类
+ *
+ * @author lihong
+ * @since 2025-03-21 09:37:49
+ */
+@SuppressWarnings("serial")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class ZdTaxClassCode  {
+    private String taxTimestamp;
+          
+    private Integer totalCount;
+          
+    private String parentCode;
+     /**
+     * 商品和服务税收分类合并编码
+     */     
+    private String taxSortCode;
+     /**
+     * 是否差额征税
+     */     
+    private String isDiffTax;
+     /**
+     * 是否征税
+     */     
+    private String isTax;
+     /**
+     * 商品和服务名称
+     */     
+    private String taxSortName;
+     /**
+     * 商品和服务分类简称
+     */     
+    private String taxShortName;
+     /**
+     * 说明
+     */     
+    private String remark;
+     /**
+     * 增值税税率
+     */     
+    private String vatRate;
+     /**
+     * 增值税政策依据
+     */     
+    private String vatPolicy;
+     /**
+     * 增值税特殊管理
+     */     
+    private String vatSpecialManage;
+     /**
+     * 征收率
+     */     
+    private String levyRate;
+     /**
+     * 增值税特殊内容代码
+     */     
+    private String vatSpecialCode;
+     /**
+     * 消费税管理
+     */     
+    private String consumTaxManage;
+     /**
+     * 消费税政策依据
+     */     
+    private String consumTaxPolicy;
+     /**
+     * 消费税特殊内容代码
+     */     
+    private String consumTaxSpecialCode;
+     /**
+     * 关键字
+     */     
+    private String keyword;
+     /**
+     * 是否汇总项
+     */     
+    private String isCollect;
+     /**
+     * 对应统计局编码 (2011年版)或国民行业代码
+     */     
+    private String statOfficeCode;
+     /**
+     * 停用日期
+     */     
+    private Date txEndDate;
+     /**
+     * 启用日期
+     */     
+    private Date txStartDate;
+     /**
+     * 海关进出口商品品目
+     */     
+    private String impoExpoCata;
+
+
+
+}
+

+ 3 - 2
src/main/java/cn/hnthyy/thmz/entity/mzdzfp/InvoiceDetail.java

@@ -19,7 +19,8 @@ import java.math.BigDecimal;
 @NoArgsConstructor
 public class InvoiceDetail implements Serializable {
   private static final long serialVersionUID =  1L;
-  private BigDecimal  serialNo ;//	明细序号	BigDecimal	8	是
+  private Integer blueSerialNo;//蓝字发票明细序号 开红字发票传
+  private Integer  serialNo ;//	明细序号	BigDecimal	8	是
   private String  itemTypeName;//	商品服务简称	String	120	是
   private String  itemName;//	项目名称	String	600	是
   private String  spec;//	规格型号	String	150	否
@@ -28,7 +29,7 @@ public class InvoiceDetail implements Serializable {
   private String  count;//	数量	String	25	否	如“单价”栏次 非空,则本栏次必须非空
   private String  price;//	单价	String	25	否	如“数量”栏次 非空,则本栏次必须非空
   private BigDecimal  amount;//	金额	BigDecimal	18,2	是
-  private String  taxRate;//	增值税税率/征收 率	BigDecimal	16,6	是
+  private BigDecimal  taxRate;//	增值税税率/征收 率	BigDecimal	16,6	是
   private BigDecimal  taxAmount;//	税额	BigDecimal	18,2	是
   private String  medicalCode;//	医疗服务贯标码	String	50	否
   private String  otherInfo;//	其他	String	100	否	1 个汉字占用 3 个字符,最多可以上传 33 个汉字。

+ 47 - 0
src/main/java/cn/hnthyy/thmz/entity/mzdzfp/MzDzfpUpload.java

@@ -0,0 +1,47 @@
+package cn.hnthyy.thmz.entity.mzdzfp;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @Description: 电子发票结果
+ * @Author:lihong
+ * @Date: 2025/3/13
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+@TableName("mz_dzfp_upload")
+public class MzDzfpUpload implements Serializable {
+    private static final long serialVersionUID =  1L;
+
+   private String patientId;
+   private Integer times;
+   private Integer receiptNo;
+    /** 发票类型 1 门诊蓝字发票  2 门诊红字发票 3住院蓝字发票 4住院红字发票 */
+   private Integer typeFlag;
+   private String requestId;
+    /** 0 待开具 1 开具中 2 开具成功  3失败 */
+   private Integer resCode;
+    /** 二维码 */
+   private String qrcode;
+    /** 下载地址 */
+   private String resUrl;
+    /** 发票号 */
+   private String fpNo;
+    /** 操作员 编码 */
+   private String opId;
+    /** 开具日期 blue_issue_date*/
+   private String blueIssueDate;
+   private String resMessage;
+    /** pdf文档 */
+   private String pdfFileStr;
+    /** 0 有效 1作废 */
+   private Integer delFlag;
+}

+ 6 - 0
src/main/java/cn/hnthyy/thmz/entity/mzdzfp/MzInvoiceInfo.java

@@ -34,6 +34,12 @@ public class MzInvoiceInfo implements Serializable {
     private	String buyerAgentName;	//	购买方经办人姓名	String	150	否
     private	String buyerAgentIdNo;	//	购买方经办人证件号码	String	30	否
     private	String buyerAgentPhone;	//	购买方经办人联系电话	String	60	否
+
+    private	String blueInvoiceNo;	//	蓝票发票号码	String	20	是
+
+    private	String blueIssueDate;	//	蓝字发票开票日期	datetime		是
+
+    private	String redOffsetCode;	//	红冲原因代码  01开票有误,02销货退回03服务终止,04销售折让
     private BigDecimal amount;	//	合计金额	BigDecimal	18,2	是
     private	BigDecimal taxAmount;	//	合计税额	BigDecimal	18,2	是
     private	BigDecimal totalAmount;	//	价税合计	BigDecimal	18,2	是

+ 10 - 0
src/main/java/cn/hnthyy/thmz/entity/mzdzfp/SetlInfo.java

@@ -30,4 +30,14 @@ public class SetlInfo implements Serializable {
    private String  mainDiagName;//	主要诊断名称	String	255	是
    private String  secDiagCode;//	次要诊断代码	String	30	否
    private String  secDiagName;//	次要诊断名称	String	255	否
+   private String  medType;//	医疗类别
+   private String  begntime;//	开始时间
+   private String  endtime;//	结束时间
+   private String  insutype;//	医保类型
+   private BigDecimal  insureFundPay;//	医保统筹基金支 付金额
+   private BigDecimal  otherPayAmount;//	其他支付金额
+   private BigDecimal  perAccoPayAmount;//	个人账户支付金 额
+   private BigDecimal  perCashPayAmount;//	个人现金支付金 额
+   private BigDecimal  perSelfPayAmount;//	个人自付金
+
 }

+ 74 - 0
src/main/java/cn/hnthyy/thmz/enums/InsutypeEnum.java

@@ -0,0 +1,74 @@
+package cn.hnthyy.thmz.enums;
+
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @description: 险种类型
+ * @author: DingJie
+ * @create: 2021/7/129:12
+ */
+public enum InsutypeEnum {
+
+    BASIC_MEDICAL_INSURANCE_FOR_EMPLOYEES("310","01", "职工基本医疗保险"),
+
+    MEDICAID_FOR_CIVIL_SERVANTS("320", "04","公务员医疗补助"),
+
+    LARGE_MEDICAL_EXPENSES_SUBSIDY("330", "04", "大额医疗费用补助"),
+
+    MEDICAL_SECURITY_FOR_RETIRED_PERSONNEL("340", "03", "离休人员医疗保障"),
+
+    MEDICAID_FOR_DISABLED_SOLDIERS("350", "04", "一至六级残废军人医疗补助"),
+
+    MEDICAID_FOR_ELDERLY_RED_ARMY("360", "04", "老红军医疗保障"),
+
+    ENTERPRISE_SUPPLEMENTARY_MEDICAL_INSURANCE("370", "04", "企业补充医疗保险"),
+
+    NEW_RURAL_COOPERATIVE_MEDICAL_SYSTEM("380", "04", "新型农村合作医疗"),
+
+    BASIC_MEDICAL_INSURANCE_FOR_RURAL_RESIDENTS("390", "02", "城乡居民基本医疗保险"),
+
+    BASIC_MEDICAL_INSURANCE_FOR_URBAN_RESIDENTS("391", "02", "城镇居民基本医疗保险"),
+
+    SERIOUS_ILLNESS_MEDICAL_INSURANCE_FOR_URBAN_AND_RURAL_RESIDENTS("392", "02", "城乡居民大病医疗保险"),
+
+    MEDICAL_SECURITY_FOR_OTHER_SPECIAL_PERSONNEL("399", "04", "其他特殊人员医疗保障"),
+
+    LONG_TERM_CARE_INSURANCE("410", "04", "长期照护保险"),
+
+    MATERNITY_INSURANCE("510", "04", "生育保险");
+
+    private final String code;
+    private final String dzfpCode;
+    private final String name;
+
+    InsutypeEnum(String code, String dzfpCode, String name) {
+        this.code = code;
+        this.dzfpCode = dzfpCode;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getDzfpCode() {
+        return dzfpCode;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public static InsutypeEnum getByCode(String code){
+        List<InsutypeEnum> insutypes= Arrays.asList(values());
+        for (InsutypeEnum insutype:insutypes){
+            if(insutype.code.equals(code)){
+                return insutype;
+            }
+        }
+        return null;
+    }
+
+}

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

@@ -1241,4 +1241,7 @@ public interface MzChargeDetailMapper {
             " where patient_id = #{patientId} " +
             "  and times = #{times} ")
     MzChargeDetail selectSumTotalFee(@Param("patientId") String patientId, @Param("times")Integer times);
+
+    @Update("update ${tableName} set tf_flag =#{tfFlag} where patient_id =#{patientId}  and times=#{times} and abs(receipt_no) =#{receiptNo} ")
+    int updateTfFlag(@Param("patientId") String patientId, @Param("times") Integer times, @Param("tfFlag") Integer tfFlag, @Param("receiptNo")Integer receiptNo, @Param("tableName") String tableName);
 }

+ 17 - 4
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzDepositFileMapper.java

@@ -20,11 +20,11 @@ public interface MzDepositFileMapper {
      * @return
      */
     @Insert("INSERT INTO  mz_deposit_file(patient_id,times,receipt_no,pay_mark,cheque_type,cheque_no,amount,charge_date,dcount_date,dcount_no," +
-            "op_id,receipt_sn,serial_no,responce_type,yb_jlh,yb_ywh,dept_no,psordnum,agtordnum,hisrefundnum,contract_id,par_channel,trans_date,trace_no) VALUES (#{patientId,jdbcType=CHAR}," +
+            "op_id,receipt_sn,serial_no,responce_type,yb_jlh,yb_ywh,dept_no,psordnum,agtordnum,hisrefundnum,contract_id,par_channel,trans_date,trace_no,warn_code,doctor_code) VALUES (#{patientId,jdbcType=CHAR}," +
             "#{times,jdbcType=INTEGER},#{receiptNo,jdbcType=SMALLINT},#{payMark,jdbcType=CHAR},#{chequeType,jdbcType=CHAR},#{chequeNo,jdbcType=CHAR}" +
             ",#{amountStr,jdbcType=DECIMAL},#{chargeDate,jdbcType=TIMESTAMP},#{dcountDate,jdbcType=TIMESTAMP},#{dcountNo,jdbcType=CHAR},#{opId,jdbcType=CHAR}," +
             "#{receiptSn,jdbcType=INTEGER},#{serialNo,jdbcType=INTEGER},#{responceType,jdbcType=CHAR},#{ybJlh,jdbcType=VARCHAR},#{ybYwh,jdbcType=VARCHAR}," +
-            "#{deptNo,jdbcType=VARCHAR},#{psordnum,jdbcType=VARCHAR},#{agtordnum,jdbcType=VARCHAR},#{hisrefundnum,jdbcType=VARCHAR},#{contractId},#{parChannel},#{transDate},#{traceNo})")
+            "#{deptNo,jdbcType=VARCHAR},#{psordnum,jdbcType=VARCHAR},#{agtordnum,jdbcType=VARCHAR},#{hisrefundnum,jdbcType=VARCHAR},#{contractId},#{parChannel},#{transDate},#{traceNo},#{warnCode},#{doctorCode})")
     int insertMzDepositFile(MzDepositFile mzDepositFile);
 
 
@@ -37,17 +37,29 @@ public interface MzDepositFileMapper {
     @Insert({
             "<script>",
             "INSERT INTO mz_deposit_file(patient_id,times,receipt_no,pay_mark,cheque_type,cheque_no,amount,charge_date,dcount_date,dcount_no,",
-            "op_id,receipt_sn,serial_no,responce_type,yb_jlh,yb_ywh,dept_no,psordnum,agtordnum,hisrefundnum,contract_id,par_channel,trans_date,trace_no) VALUES ",
+            "op_id,receipt_sn,serial_no,responce_type,yb_jlh,yb_ywh,dept_no,psordnum,agtordnum,hisrefundnum,contract_id,par_channel,trans_date,trace_no,warn_code,doctor_code) VALUES ",
             "<foreach collection='mzDepositFileList' item='item' index='index' separator=','>",
             " (#{item.patientId,jdbcType=CHAR},#{item.times,jdbcType=INTEGER},#{item.receiptNo,jdbcType=SMALLINT},#{item.payMark,jdbcType=CHAR},#{item.chequeType,jdbcType=CHAR},#{item.chequeNo,jdbcType=CHAR}",
             ",#{item.amountStr,jdbcType=DECIMAL},#{item.chargeDate,jdbcType=TIMESTAMP},#{item.dcountDate,jdbcType=TIMESTAMP},#{item.dcountNo,jdbcType=CHAR},#{item.opId,jdbcType=CHAR},",
             "#{item.receiptSn,jdbcType=INTEGER},#{item.serialNo,jdbcType=INTEGER},#{item.responceType,jdbcType=CHAR},#{item.ybJlh,jdbcType=VARCHAR},#{item.ybYwh,jdbcType=VARCHAR},",
-            "#{item.deptNo,jdbcType=VARCHAR},#{item.psordnum,jdbcType=VARCHAR},#{item.agtordnum,jdbcType=VARCHAR},#{item.hisrefundnum,jdbcType=VARCHAR},#{item.contractId},#{item.parChannel},#{item.transDate},#{item.traceNo}) ",
+            "#{item.deptNo,jdbcType=VARCHAR},#{item.psordnum,jdbcType=VARCHAR},#{item.agtordnum,jdbcType=VARCHAR},#{item.hisrefundnum,jdbcType=VARCHAR},#{item.contractId},#{item.parChannel},#{item.transDate},#{item.traceNo},#{item.warnCode},#{item.doctorCode}) ",
             "</foreach>",
             "</script>"
     })
     int batchInsertMzDepositFile(@Param(value = "mzDepositFileList") List<MzDepositFile> mzDepositFileList);
 
+    @Update(" update ${tableName}" +
+            " set warn_code   =b.warn_dept," +
+            "    doctor_code =b.doctor_code" +
+            " from (" +
+            "         select top 1 warn_dept, doctor_code, patient_id pat_no, times p_times" +
+            "         from mz_charge_detail" +
+            "         where patient_id = #{patientId}" +
+            "           and times = #{times}" +
+            "     ) b" +
+            " where patient_id = pat_no" +
+            "  and times = p_times ")
+    int updateWarnCodeAndDoctorCode(@Param("patientId") String patientId, @Param("times") Integer times,@Param("tableName") String tableName);
 
 //    /**
 //     * 查询所有的记账记录
@@ -382,4 +394,5 @@ public interface MzDepositFileMapper {
     void updateOpIdByPatientId(@Param("deptNo") String deptNo, @Param("userIdCode")String userIdCode, @Param("mzDepositFileVo") MzDepositFileVo mzDepositFileVo);
     @Select(" select sum(amount) from  mz_deposit_file where patient_id =#{patientId} and times =#{times} and abs(receipt_no) < #{receiptNo} ")
     BigDecimal selectBeforeReceiptNo(@Param("patientId") String patientId, @Param("times")Integer times, @Param("receiptNo")Integer receiptNo);
+
 }

+ 35 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzDzfpUploadMapper.java

@@ -0,0 +1,35 @@
+package cn.hnthyy.thmz.mapper.his.mz;
+
+import cn.hnthyy.thmz.entity.mzdzfp.MzDzfpUpload;
+import cn.hnthyy.thmz.entity.mzdzfp.SetlInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+
+import java.util.Map;
+
+/**
+ * @Description:
+ * @Author:lihong
+ * @Date: 2025/3/14
+ */
+public interface MzDzfpUploadMapper extends BaseMapper<MzDzfpUpload> {
+    @Select(" <script> " +
+            "select top 1 insuplc_admdvs fixBlngAdmdvs ,setl_id setlId,setl_time  setlDate ,psn_no psnCode,inscp_scp_amt inscpAmt ,med_type medType,convert(varchar(19),begntime,120) begntime ,convert(varchar(19),endtime,120) endtime,insutype,fund_pay_sumamt  insureFundPay, oth_pay otherPayAmount,acct_pay perAccoPayAmount,psn_cash_pay  perCashPayAmount,psn_part_amt  perSelfPayAmount   from t_si_setlinfo where pat_no=#{patientId} and times =#{times} and revoked =0 " +
+            "<if test =\" ledgerSn !=null \">"+
+            " and ledger_sn = #{ledgerSn}"+
+            "</if>"+
+            "</script>")
+    SetlInfo selectSetlInfo(@Param("patientId") String patientId, @Param("times")Integer times, @Param("ledgerSn")Integer ledgerSn);
+
+    @Select("select * from powersi_mip_setlinfo where med_org_ord ='${patientId}_${times}_1' and ord_state ='SETTLED' ")
+    Map<String, Object> selectpowersiMipSetlinfo(@Param("patientId") String patientId, @Param("times")Integer times);
+    @Update(" update mz_dzfp_upload set fp_no =#{fpNo} ,res_code=#{resCode},blue_issue_date=#{blueIssueDate} where patient_id = #{patientId} and times =#{times} and receipt_no=#{receiptNo} and type_flag =#{typeFlag} and del_flag =#{delFlag}")
+    int updateFpNo(MzDzfpUpload mzDzfpUpload);
+    @Select(" select dis_diag mainDiagCode ,dis_diag_comment mainDiagName from zy_dis_diag_yb where inpatient_no = #{patientId} and admiss_times =#{times} and dis_diag_no = 1 ")
+    Map<String,Object> selectYbDiag(MzDzfpUpload uploadParam);
+    @Select(" select code mainDiagCode,name mainDiagName from t_case_frontsheet_disdiag where bah = #{patientId} and  times = #{times} and no = 1")
+    Map<String,Object> selectCaseDisdiag(MzDzfpUpload uploadParam);
+
+}

+ 34 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/mz/ZdTaxClassCodeMapper.java

@@ -0,0 +1,34 @@
+package cn.hnthyy.thmz.mapper.his.mz;
+
+import cn.hnthyy.thmz.entity.his.zd.ZdTaxClassCode;
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+/**
+ * @Description: 税收分类字典
+ * @Author:lihong
+ * @Date: 2025/3/21
+ */
+public interface ZdTaxClassCodeMapper  {
+   @Insert("<script>" +
+           " insert into zd_tax_class_code(tax_timestamp, total_count, parent_code, tax_sort_code, is_diff_tax, is_tax, tax_sort_name, tax_short_name, remark, vat_rate, vat_policy, vat_special_manage, levy_rate, vat_special_code, consum_tax_manage, consum_tax_policy, consum_tax_special_code, keyword, is_collect, stat_office_code, tx_end_date, tx_start_date, impo_expo_cata) values "+
+           "<foreach collection='list' item='item' separator=','>"+
+           " (#{item.taxTimestamp}, #{item.totalCount}, #{item.parentCode}, #{item.taxSortCode}, #{item.isDiffTax}, #{item.isTax}, #{item.taxSortName}, #{item.taxShortName},#{item.remark} ,#{item.vatRate} , #{item.vatPolicy} ,#{item.vatSpecialManage} , #{item.levyRate}, #{item.vatSpecialCode}, #{item.consumTaxManage}, #{item.consumTaxPolicy},  #{item.consumTaxSpecialCode}, #{item.keyword},  #{item.isCollect}, #{item.statOfficeCode}, #{item.txEndDate,jdbcType=TIMESTAMP},  #{item.txStartDate,jdbcType=TIMESTAMP}, #{item.impoExpoCata} )"+
+           "</foreach>"+
+           "</script>")
+   int batchInserZdTaxClassCode(List<ZdTaxClassCode> list);
+    @Select("<script>" +
+            " select tax_timestamp, total_count, parent_code, tax_sort_code, is_diff_tax, is_tax, tax_sort_name, tax_short_name, remark, vat_rate, vat_policy, vat_special_manage, levy_rate, vat_special_code, consum_tax_manage, consum_tax_policy, consum_tax_special_code, keyword, is_collect, stat_office_code, tx_end_date, tx_start_date, impo_expo_cata from zd_tax_class_code " +
+            "<where>" +
+            "<if test=\" taxSortCode !=null and taxSortCode !=''  \">"+
+            " tax_sort_code = #{taxSortCode}"+
+            "</if>"+
+            "</where>"+
+            "</script>")
+    List<ZdTaxClassCode> selectByEntity(ZdTaxClassCode zdTaxClassCode);
+
+    @Select(" select count(*) from zd_tax_class_code")
+    int selectCount();
+}

+ 2 - 0
src/main/java/cn/hnthyy/thmz/service/his/mz/MzReceiptSerialService.java

@@ -183,4 +183,6 @@ public interface MzReceiptSerialService {
      * @param: response
      **/
     void exportUseReceiptBill(UseReceioVo useReceioVo, HttpServletRequest request, HttpServletResponse response);
+
+    void printNewReceiptSerial(List<MzReceiptSerial> mzReceiptSerials);
 }

+ 56 - 2
src/main/java/cn/hnthyy/thmz/service/his/mzdzfp/BswServer.java

@@ -1,7 +1,11 @@
 package cn.hnthyy.thmz.service.his.mzdzfp;
 
+import cn.hnthyy.thmz.Utils.R;
+import cn.hnthyy.thmz.entity.his.mz.MzReceiptSerial;
+import cn.hnthyy.thmz.entity.mzdzfp.MzDzfpUpload;
 import cn.hnthyy.thmz.entity.mzdzfp.MzInvoiceInfo;
 import cn.hnthyy.thmz.entity.mzdzfp.ResultInfo;
+import cn.hnthyy.thmz.vo.MzReceiptSerialVo;
 
 /**
  * @Description:乐企 电子发票
@@ -17,6 +21,36 @@ public interface BswServer {
      * @return: cn.hnthyy.thmz.entity.mzdzfp.ResultInfo
      **/
    ResultInfo mzBlueInvoice(MzInvoiceInfo mzInvoiceInfo);
+   /**
+    * @description: 获取门诊蓝字发票
+    * @author: lihong
+    * @date: 2025/3/13 16:04
+    * @param: patientId
+    * @param: times
+    * @param: receiptNo
+    * @param: ghFlag true 挂号 false 门诊发票
+    * @return: cn.hnthyy.thmz.entity.mzdzfp.ResultInfo
+    **/
+   R getMzBlueInvoice(MzReceiptSerial mzReceiptSerial, boolean ghFlag);
+   /**
+    * @description: 上传红字发票
+    * @author: lihong
+    * @date: 2025/3/14 16:43
+    * @param: mzReceiptSerial
+    * @param: ghFlag true 挂号 false 门诊发票
+    * @return: cn.hnthyy.thmz.entity.mzdzfp.ResultInfo
+    **/
+   R getMzRedInvoice(MzReceiptSerial mzReceiptSerial,boolean ghFlag);
+    /**
+     * @description:上传发票 异步
+     * @author: lihong
+     * @date: 2025/3/15 11:14
+     * @param: mzReceiptSerial
+     * @param: ghFlag
+     **/
+   void asnyMzInvoice(MzReceiptSerial mzReceiptSerial,boolean ghFlag,Integer typeFlag);
+
+
     /**
      * @description: 开具住院蓝字发票
      * @author: lihong
@@ -25,6 +59,17 @@ public interface BswServer {
      * @return: cn.hnthyy.thmz.entity.mzdzfp.ResultInfo
      **/
    ResultInfo zyBlueInvoice(MzInvoiceInfo mzInvoiceInfo);
+   /**
+    * @description: 上传电子发票
+    * @author: lihong
+    * @date: 2025/3/17 9:54
+    * @param: patientId 住院号
+    * @param: times 住院次数
+    * @param: typeFlag  3 住院蓝字发票 4住院红字发票(作废发票)
+    * @return: cn.hnthyy.thmz.Utils.R
+    **/
+   R uploadZyInvoice(MzDzfpUpload uploadParam);
+
     /**
      * @description: 开具门诊红字发票
      * @author: lihong
@@ -58,7 +103,7 @@ public interface BswServer {
     *  -sellerUsciName				销方纳税人名称	开具成功有此值
     *
     **/
-   ResultInfo queryIssuedState(String usciCode ,String requestID);
+   ResultInfo queryIssuedState(String usciCode ,String requestId);
 
    /**
     * @description: 发票版式文件查询
@@ -72,6 +117,14 @@ public interface BswServer {
     * pdfFileStr	String			Pdf文件base64
     **/
    ResultInfo queryLayoutFile(String usciCode ,String invoiceNo,Integer fileType);
+    /**
+     * @description: 查询电子发票文件 pdf文档
+     * @author: lihong
+     * @date: 2025/3/18 10:29
+     * @param: mzDzfpUpload
+     * @return: cn.hnthyy.thmz.Utils.R
+     **/
+    R queryInvoiceFile(MzDzfpUpload mzDzfpUpload);
    /**
     * @description:  税收分类编码查询
     * @author: lihong
@@ -85,7 +138,8 @@ public interface BswServer {
     * @param: taxAuthorityCode 非必填
     * @return: cn.hnthyy.thmz.entity.mzdzfp.ResultInfo
     **/
-   ResultInfo queryTaxClassifyCode(String usciCode ,String timestamp,String taxAuthorityCode);
+   R queryTaxClassifyCode(String usciCode ,String timestamp,String taxAuthorityCode);
 
 
+    String getToken();
 }

+ 7 - 0
src/main/java/cn/hnthyy/thmz/service/his/zd/DictDataService.java

@@ -31,4 +31,11 @@ public interface DictDataService {
      * @return: java.util.Map<java.lang.String,java.lang.Object>
      **/
     Map<String, Object> queryDictValueByYpCfPrint();
+    /**
+     * @description: 查询发票打印版本 0 纸质 1电子发票
+     * @author: lihong
+     * @date: 2025/4/17 11:35
+     * @return: int
+     **/
+    int queryFpVersion();
 }

+ 10 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzChargeDetailServiceImpl.java

@@ -1056,6 +1056,9 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
         newMzVisitTable.setReceiptNo(mzReceiptSerial.getReceiptNo());
         newMzVisitTable.setReceiveFlag(YesNoEnum.YES.code);
         mzVisitTableMapper.updateMzVisitTable(newMzVisitTable);
+        mzDepositFileMapper.updateWarnCodeAndDoctorCode(patientId, times, "mz_deposit_file");
+        mzDepositFileMapper.updateWarnCodeAndDoctorCode(patientId, times, "mz_receipt_serial");
+
     }
 
 //    private void resetParams(MzReceiptSerial jzMzReceiptSerial) {
@@ -4292,6 +4295,10 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
             List<MzReceiptSerial> newReceiptSerials = formatRefundReceiptSerial(mzReceiptSerials, opId, mzDepositFileVo.getRefundType());
             mzReceiptSerialMapper.batchInsertMzReceiptSerial(newReceiptSerials);
         }
+
+        mzChargeDetailMapper.updateTfFlag(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), 1,mzDepositFileVo.getReceiptNo(), "mz_deposit_file");
+        mzChargeDetailMapper.updateTfFlag(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), 1,mzDepositFileVo.getReceiptNo(), "mz_charge_detail");
+
         //将发票记录改为退费
         MzReceiptSerial updateMzReceiptSerial = new MzReceiptSerial(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes());
         //updateMzReceiptSerial.setPayMark(PayMarkEnum.RETURN_PREMIUM.code);
@@ -4465,6 +4472,9 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
             List<MzReceiptSerial> newReceiptSerials = formatRefundReceiptSerial(mzReceiptSerials, opId, mzDepositFileVo.getRefundType());
             mzReceiptSerialMapper.batchInsertMzReceiptSerial(newReceiptSerials);
         }
+
+        mzChargeDetailMapper.updateTfFlag(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), 1,mzDepositFileVo.getReceiptNo(), "mz_deposit_file");
+        mzChargeDetailMapper.updateTfFlag(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), 1,mzDepositFileVo.getReceiptNo(), "mz_charge_detail");
         //将发票记录改为退费
         MzReceiptSerial updateMzReceiptSerial = new MzReceiptSerial(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes());
         //updateMzReceiptSerial.setPayMark(PayMarkEnum.RETURN_PREMIUM.code);

+ 54 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzReceiptSerialServiceImpl.java

@@ -2,7 +2,9 @@ package cn.hnthyy.thmz.service.impl.his.mz;
 
 import cn.hnthyy.thmz.Utils.ExcelUtil;
 import cn.hnthyy.thmz.Utils.NumberToCN;
+import cn.hnthyy.thmz.Utils.TokenUtil;
 import cn.hnthyy.thmz.common.Constants;
+import cn.hnthyy.thmz.common.exception.BizException;
 import cn.hnthyy.thmz.entity.MzException;
 import cn.hnthyy.thmz.entity.his.mz.MzDepositFile;
 import cn.hnthyy.thmz.entity.his.mz.MzPatientMi;
@@ -603,6 +605,58 @@ public class MzReceiptSerialServiceImpl implements MzReceiptSerialService {
         return page;
     }
 
+    @Override
+    public void printNewReceiptSerial(List<MzReceiptSerial> mzReceiptSerials) {
+        if(mzReceiptSerials==null || mzReceiptSerials.size()==0){
+            throw new BizException("打印失败,发票为空!");
+        }
+        List<ZdChequeType> chequeTypes = zdChequeTypeService.queryAllZdChequeType();
+        Map<String, Integer> printFlagMap = chequeTypes.stream().collect(Collectors.toMap(ZdChequeType::getCode, ZdChequeType::getPrintFlag));
+        Map<String, String> nameMap = chequeTypes.stream().collect(Collectors.toMap(ZdChequeType::getCode, ZdChequeType::getName));
+        MzReceiptSerial returnMzReceiptSerial=null;
+        for (MzReceiptSerial mzReceiptSerial:mzReceiptSerials){
+            if(Constants.HLWYY_CODE.equals(mzReceiptSerial.getOperatorId())){
+                throw new BizException("互联网医院平台缴费无法在门诊窗口打印发票,请让患者联系互联网医院平台!");
+            }
+            if(StringUtils.isBlank(mzReceiptSerial.getChequeType())){
+                throw new BizException("当前病人发票表中的收费类型为空,无法打印发票,请及时联系管理员!");
+            }
+            Integer printFlag = printFlagMap.get(mzReceiptSerial.getChequeType());
+            if(Convert.toInt(printFlag,0) == 0){
+                throw new BizException(nameMap+"发票无法打印发票,请及时联系管理员");
+            }
+            if(returnMzReceiptSerial==null){
+                returnMzReceiptSerial=mzReceiptSerial;
+            }else {
+                MzReceiptSerial.setChargeFiled(returnMzReceiptSerial, mzReceiptSerial);
+            }
+            MzReceiptSerial updateMzReceiptSerial = new MzReceiptSerial(mzReceiptSerial.getPatientId(), mzReceiptSerial.getTimes());
+            updateMzReceiptSerial.setReceiptNo(mzReceiptSerial.getReceiptNo());
+            updateMzReceiptSerial.setChequeType(mzReceiptSerial.getChequeType());
+            updateMzReceiptSerial.setOperatorId(TokenUtil.getUser().getUserIdCode());
+            updateMzReceiptSerial.setPayId(mzReceiptSerial.getOperatorId());
+            if (mzReceiptSerial.getDcountDate() != null) {
+                //日结不为空,说明是手机自助缴费且已经日结过了,需要将原来日结时间设置到缴费日结字段,因为发票打印成功会重置原来的日结时间和日结状态
+                updateMzReceiptSerial.setChargeDcountDate(mzReceiptSerial.getDcountDate());
+                updateMzReceiptSerial.setChargeDcountNo(mzReceiptSerial.getDcountNo());
+            }
+            //如果是手机缴费,设置缴费方式为自助缴费
+            if (Constants.BRZZJF_CODE.equals(mzReceiptSerial.getOperatorId()) && Constants.BYJZ.equals(mzReceiptSerial.getChequeType())) {
+                MzDepositFile mzDepositFile = mzDepositFileMapper.selectMzDepositFileBySerialNo(mzReceiptSerial.getSerialNo(), null).get(0);
+                if (Constants.WX.equals(mzDepositFile.getChequeType())) {
+                    updateMzReceiptSerial.setNewChequeType(Constants.ZZWX);
+                } else if (Constants.ZFB.equals(mzDepositFile.getChequeType())) {
+                    updateMzReceiptSerial.setNewChequeType(Constants.ZZZFB);
+                }
+                mzDepositFileMapper.updateChequeType(updateMzReceiptSerial.getNewChequeType(), mzDepositFile.getReceiptSn(), null);
+            }
+            int num = mzReceiptSerialMapper.updateBzByReceiptNo(updateMzReceiptSerial);
+            if (num > 0) {
+                mzReceiptSerialMapper.updateMzReceiptSerialByReceiptNoAndChueType(updateMzReceiptSerial);
+            }
+        }
+    }
+
     @Override
     public void exportUseReceiptBill(UseReceioVo useReceioVo, HttpServletRequest request, HttpServletResponse response) {
         if(StrUtil.isBlank(useReceioVo.getReceiptBill()) || "null".equals(useReceioVo.getReceiptBill())){

+ 6 - 1
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzyReqrecServiceImpl.java

@@ -24,6 +24,7 @@ import cn.hnthyy.thmz.service.his.zd.ZdUnitCodeService;
 import cn.hnthyy.thmz.service.thmz.*;
 import cn.hnthyy.thmz.vo.MzyReqrecVo;
 import cn.hnthyy.thmz.vo.ThmzmxsrParamsVo;
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.util.DesensitizedUtil;
@@ -848,7 +849,11 @@ public class MzyReqrecServiceImpl implements MzyReqrecService {
 
     @Override
     public MzyReqrec queryLastMzyReqrecByPatientId(String patientId) {
-        return mzyReqrecMapper.selectLastMzyReqrecByPatientId(patientId);
+        MzyReqrec mzyReqrec = mzyReqrecMapper.selectLastMzyReqrecByPatientId(patientId);
+       if(mzyReqrec != null){
+           BeanUtil.trimStrFields(mzyReqrec);
+       }
+        return mzyReqrec;
     }
 
     @Override

Dosya farkı çok büyük olduğundan ihmal edildi
+ 977 - 15
src/main/java/cn/hnthyy/thmz/service/impl/his/mzdzfp/BswServerImpl.java


+ 7 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/zd/DictDataServiceImpl.java

@@ -6,6 +6,7 @@ import cn.hnthyy.thmz.entity.his.zd.DictData;
 import cn.hnthyy.thmz.mapper.his.zd.DictDataMapper;
 import cn.hnthyy.thmz.service.his.zd.DictDataService;
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.convert.Convert;
 import cn.hutool.core.util.StrUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -98,4 +99,10 @@ public class DictDataServiceImpl implements DictDataService {
         }
         return null;
     }
+
+    @Override
+    public int queryFpVersion() {
+        String fpVersion = queryDictValueNotCach("3.5", "fp_version", "0");
+        return Convert.toInt(fpVersion);
+    }
 }

+ 30 - 0
src/main/resources/static/js/common/string-util.js

@@ -194,4 +194,34 @@ function isInArray(data, array) {
  */
 function stringNotBlank(data) {
     return data != undefined && data != 'undefined' && data != null && data != 'null' && data != '';
+}
+
+
+function base64toPDF(data) {
+    var bufferArray = base64ToArrayBuffer(data);
+    var blobStore = new Blob([bufferArray], { type: "application/pdf" });
+    if (window.navigator && window.navigator.msSaveOrOpenBlob) {
+        window.navigator.msSaveOrOpenBlob(blobStore);
+        return;
+    }
+    var data = window.URL.createObjectURL(blobStore);
+    var link = document.createElement('a');
+    document.body.appendChild(link);
+    link.href = data;
+    var timestamp = Date.parse(new Date());
+    link.download = timestamp + ".pdf";
+    link.click();
+    window.URL.revokeObjectURL(data);
+    link.remove();
+}
+
+function base64ToArrayBuffer(data) {
+    var bString = window.atob(data);
+    var bLength = bString.length;
+    var bytes = new Uint8Array(bLength);
+    for (var i = 0; i < bLength; i++) {
+        var ascii = bString.charCodeAt(i);
+        bytes[i] = ascii;
+    }
+    return bytes;
 }

+ 10 - 1
src/main/resources/static/js/mz/clinic.js

@@ -8316,11 +8316,20 @@ function loadWpMedicineList(event) {
             }
         },
         columns: [
+            {
+                field: 'medListCodg',
+                title: '医保码',
+                align: "center",
+                valign: 'middle',
+                width: 250,
+                //  sortable: true
+            },
              {
                 field: 'genname',
-                title: '名称',
+                title: '药品名称',
                 align: "center",
                 valign: 'middle',
+                width: 150,
                 //  sortable: true
             }
             , {

+ 46 - 28
src/main/resources/static/js/mz/registration.js

@@ -7,6 +7,7 @@ var pageIndex = 0;
 var LODOP; //声明为全局变量
 //默认打印机下标
 var printIndex = -1;
+var fpVsesionNo =0;
 var TableInit = function () {
     var oTableInit = new Object();
     //初始化Table
@@ -95,6 +96,7 @@ var TableInit = function () {
 
 
 $(function () {
+    initFpVersion();
     initGenderSelect();
     initResponceTypeSelect();
     initCertificateTypeSelect();
@@ -384,6 +386,13 @@ function getNewPatientId(flag) {
     $('#newCardModal').modal('hide')
 }
 
+//初始化版本电子发票版本
+function initFpVersion() {
+    getAjaxRequst("/thmz/queryFpVersion",{},true,function (res) {
+        console.log('发票版本=',res.data)
+        fpVsesionNo = res.data;
+    })
+}
 
 /**
  * 初始化性别下拉选
@@ -1867,9 +1876,6 @@ function clearRegistration() {
 function prn1Print(patientId, times) {
     setPrint();
     var height = "93.15mm";
-    // if(countReceiot%2==0){
-    //     height ="93.2mm";
-    // }
     $.ajax({
         type: "GET",
         url: '/thmz/printMzyReqrecRecept?patientId=' + patientId + "&times=" + times,
@@ -1897,33 +1903,45 @@ function prn1Print(patientId, times) {
                 LODOP.SET_PRINT_MODE("CREATE_CUSTOM_PAGE_NAME", "门诊发票");//对新建的纸张重命名
                 LODOP.SET_PRINT_STYLE("FontSize", 11); //字体大小
                 LODOP.ADD_PRINT_TEXT("6mm", "0mm", "55mm", "3mm", "湖南泰和医院管理有限公司");
-                LODOP.ADD_PRINT_TEXT("6mm", "59mm", "30mm", "3mm", "流水号:");
-                LODOP.ADD_PRINT_TEXT("6mm", "72mm", "20mm", "3mm", temp.serialNo);
-                LODOP.ADD_PRINT_TEXT("19mm", "0mm", "35mm", "3mm", temp.receiptBill);
-                LODOP.ADD_PRINT_TEXT("25mm", "7mm", "50mm", "3mm", temp.name);
-                LODOP.ADD_PRINT_TEXT("25mm", "61mm", "27mm", "3mm", patientId);
-                LODOP.ADD_PRINT_TEXT("32mm", "6mm", "50mm", "3mm", "就诊科室:" + temp.unitCode);
-                LODOP.ADD_PRINT_TEXT("32mm", "56mm", "50mm", "3mm", "地点:" + res.officePos == null ? "" : res.officePos);
-                LODOP.ADD_PRINT_TEXT("37mm", "6mm", "50mm", "3mm", "看诊医生:" + temp.doctorCode);
-                LODOP.ADD_PRINT_TEXT("37mm", "56mm", "50mm", "3mm", "号段:" + temp.ampm);
-                LODOP.ADD_PRINT_TEXT("42mm", "6mm", "50mm", "3mm", "号别:" + temp.chargeType);
-                LODOP.ADD_PRINT_TEXT("42mm", "56mm", "50mm", "3mm", "挂号费:" + temp.reqFee);
-                LODOP.ADD_PRINT_TEXT("47mm", "6mm", "50mm", "3mm", "诊查费:" + temp.clinicFee);
-                LODOP.ADD_PRINT_TEXT("47mm", "56mm", "50mm", "3mm", "其他:" + temp.othFee);
-                var blbFee = temp.blbFee;
-                if (blbFee == null) {
-                    blbFee = 0;
+                if(fpVsesionNo == 0){
+                    LODOP.ADD_PRINT_TEXT("6mm", "59mm", "30mm", "3mm", "流水号:");
+                    LODOP.ADD_PRINT_TEXT("6mm", "72mm", "20mm", "3mm", temp.serialNo);
+                    LODOP.ADD_PRINT_TEXT("19mm", "0mm", "35mm", "3mm", temp.receiptBill);
+                    LODOP.ADD_PRINT_TEXT("25mm", "7mm", "50mm", "3mm", temp.name);
+                    LODOP.ADD_PRINT_TEXT("25mm", "61mm", "27mm", "3mm", patientId);
+                    LODOP.ADD_PRINT_TEXT("32mm", "6mm", "50mm", "3mm", "就诊科室:" + temp.unitCode);
+                    LODOP.ADD_PRINT_TEXT("32mm", "56mm", "50mm", "3mm", "地点:" + res.officePos == null ? "" : res.officePos);
+                    LODOP.ADD_PRINT_TEXT("37mm", "6mm", "50mm", "3mm", "看诊医生:" + temp.doctorCode);
+                    LODOP.ADD_PRINT_TEXT("37mm", "56mm", "50mm", "3mm", "号段:" + temp.ampm);
+                    LODOP.ADD_PRINT_TEXT("42mm", "6mm", "50mm", "3mm", "号别:" + temp.chargeType);
+                    LODOP.ADD_PRINT_TEXT("42mm", "56mm", "50mm", "3mm", "挂号费:" + temp.reqFee);
+                    LODOP.ADD_PRINT_TEXT("47mm", "6mm", "50mm", "3mm", "诊查费:" + temp.clinicFee);
+                    LODOP.ADD_PRINT_TEXT("47mm", "56mm", "50mm", "3mm", "其他:" + temp.othFee);
+                    var blbFee = temp.blbFee;
+                    if (blbFee == null) {
+                        blbFee = 0;
+                    }
+                    if (temp.zlkFee != null) {
+                        blbFee = blbFee + temp.zlkFee;
+                    }
+                    LODOP.ADD_PRINT_TEXT("52mm", "6mm", "50mm", "3mm", "工本费:" + blbFee);
+                    LODOP.ADD_PRINT_TEXT("65mm", "21mm", "60mm", "3mm", res.totalFee + " 元");
+                    LODOP.ADD_PRINT_TEXT("72mm", "19mm", "60mm", "3mm", res.totalFeeStr);
+                    LODOP.ADD_PRINT_TEXT("79mm", "0mm", "15mm", "3mm", res.year);//年
+                    LODOP.ADD_PRINT_TEXT("79mm", "13mm", "10mm", "3mm", res.month);//月
+                    LODOP.ADD_PRINT_TEXT("79mm", "25mm", "10mm", "3mm", res.day);//日
+                    LODOP.ADD_PRINT_TEXT("79mm", "53mm", "23mm", "3mm", res.user.userName);//收费员
                 }
-                if (temp.zlkFee != null) {
-                    blbFee = blbFee + temp.zlkFee;
+                else {
+                    LODOP.ADD_PRINT_TEXT("5mm", "3mm", "50mm", "3mm", "姓名:"+temp.name);
+                    LODOP.ADD_PRINT_TEXT("9mm", "3mm", "50mm", "3mm", "门诊号:"+patientId);
+                    LODOP.ADD_PRINT_TEXT("13mm", "3mm", "50mm", "3mm", "就诊科室:" + temp.unitCode);
+                    LODOP.ADD_PRINT_TEXT("17mm", "3mm", "70mm", "3mm", "地点:" + res.officePos);
+                    LODOP.ADD_PRINT_TEXT("21mm", "3mm", "50mm", "3mm", "看诊医生:" + temp.doctorCode);
+                    LODOP.ADD_PRINT_TEXT("25mm", "3mm", "70mm", "3mm", "号段:" + temp.ampm);
+                    LODOP.ADD_PRINT_TEXT("29mm", "3mm", "50mm", "3mm", "号别:" + temp.chargeType);
+                    LODOP.ADD_PRINT_TEXT("33mm", "3mm", "50mm", "3mm", "收费员:"+res.user.userName);//收费员
                 }
-                LODOP.ADD_PRINT_TEXT("52mm", "6mm", "50mm", "3mm", "工本费:" + blbFee);
-                LODOP.ADD_PRINT_TEXT("65mm", "21mm", "60mm", "3mm", res.totalFee + " 元");
-                LODOP.ADD_PRINT_TEXT("72mm", "19mm", "60mm", "3mm", res.totalFeeStr);
-                LODOP.ADD_PRINT_TEXT("79mm", "0mm", "15mm", "3mm", res.year);//年
-                LODOP.ADD_PRINT_TEXT("79mm", "13mm", "10mm", "3mm", res.month);//月
-                LODOP.ADD_PRINT_TEXT("79mm", "25mm", "10mm", "3mm", res.day);//日
-                LODOP.ADD_PRINT_TEXT("79mm", "53mm", "23mm", "3mm", res.user.userName);//收费员
                 //LODOP.PREVIEW();
                 LODOP.PRINT();
                 if (times > 0) {

+ 116 - 34
src/main/resources/static/js/mz/registration_list.js

@@ -11,6 +11,7 @@ var isTableListInit = false;
 var LODOP; //声明为全局变量pageIndex
 //默认打印机下标
 var printIndex = -1;
+var fpVsesionNo = 0;
 var TableInit = function () {
     var oTableInit = new Object();
     //初始化Table
@@ -99,6 +100,7 @@ var TableInit = function () {
 
 
 $(function () {
+    initFpVersion();
     initGenderSelect();
     initResponceTypeSelect();
 
@@ -234,6 +236,13 @@ function initCertificateTypeSelect() {
     });
 }
 
+//初始化版本电子发票版本
+function initFpVersion() {
+    getAjaxRequst("/thmz/queryFpVersion",{},true,function (res) {
+        console.log('发票版本=',res.data)
+        fpVsesionNo = res.data;
+    })
+}
 
 /**
  * 初始化性别下拉选
@@ -1095,7 +1104,10 @@ function loadCardList() {
                                 html += '                                <i class="fa fa-rmb"></i>';
                             } else {
                                 var printFlag = isEmpty(mzyReqrecVo.mzyReqrec.printerId);
-                                if (printFlag) {
+                                if(fpVsesionNo == 1){
+                                    html += '                            <button type="button" class="registration-no-color-foot-button"  title="打印并上传电子发票" onclick="prn1Print(\'' + mzyReqrecVo.mzyReqrec.patientId + '\',' + mzyReqrecVo.mzyReqrec.times + ')">';
+                                }
+                               else if (printFlag && fpVsesionNo == 0) {
                                     html += '                            <button type="button" class="registration-no-color-foot-button"  title="打印" onclick="prn1Print(\'' + mzyReqrecVo.mzyReqrec.patientId + '\',' + mzyReqrecVo.mzyReqrec.times + ')">';
                                 } else {
                                     html += '                            <button type="button" class="can-not-used" title="打印">';
@@ -1151,7 +1163,10 @@ function loadCardList() {
                                 html += '                                <i class="fa fa-rmb"></i>';
                             } else {
                                 var printFlag = isEmpty(mzyReqrecVo.mzyReqrec.printerId);
-                                if (printFlag) {
+                                if(fpVsesionNo == 1){
+                                    html += '                            <button type="button" class="registration-no-color-foot-button"  title="打印并上传电子发票" onclick="prn1Print(\'' + mzyReqrecVo.mzyReqrec.patientId + '\',' + mzyReqrecVo.mzyReqrec.times + ')">';
+                                }
+                               else if (printFlag && fpVsesionNo ==0) {
                                     html += '                            <button type="button" class="registration-no-color-foot-button"  title="打印" onclick="prn1Print(\'' + mzyReqrecVo.mzyReqrec.patientId + '\',' + mzyReqrecVo.mzyReqrec.times + ')">';
                                 } else {
                                     html += '                            <button type="button" class="can-not-used" title="打印">';
@@ -1376,6 +1391,10 @@ function loadTableList() {
                             if (!(buttonCodes == null || !isInArrayStr("cancel_clinic", buttonCodes))) {
                                 html += '<button type="button" class="can-not-used"  title="取消接诊"><i class="fa fa-mail-reply"></i></button>';
                             }
+                            if(fpVsesionNo == 1){
+                                html += '<button type="button" class="registration-no-color-foot-button" title="电子发票作废" onclick="uploadRedInvoice(\'' + row.mzyReqrec.patientId + '\',' + row.mzyReqrec.times + ')"><i class="fa fa-mail-reply-all"></i></button>';
+                                html += '  <button type="button" class="registration-no-color-foot-button"  title="下载红字电子发票" onclick="downloadInvoice(\'' + row.mzyReqrec.patientId + '\',' + row.mzyReqrec.times +',2'+ ')"><i class="fa fa-download"></i></button>';
+                            }
                             html += '<button type="button" class="can-not-used" title="退号"><i class="fa fa-minus-square-o"></i></button><button type="button" class="can-not-used" title="打印" ><i class="fa fa-print"></i></button>';
                             html += '<button type="button" class="registration-no-color-foot-button" title="智能支付参数与条形码" onclick="createBarcode(\'' + row.mzyReqrec.patientId + '\',' + row.mzyReqrec.times + ')"><i class="fa fa-barcode"></i></button>';
                             return html;
@@ -1394,13 +1413,20 @@ function loadTableList() {
                                 html += '<i class="fa fa-rmb"></i></button>';
                             } else {
                                 var printFlag = isEmpty(row.mzyReqrec.printerId);
-                                if (printFlag) {
+                                if(fpVsesionNo == 1){
+                                    html += '                            <button type="button" class="registration-no-color-foot-button"  title="打印并上传电子发票" onclick="prn1Print(\'' + row.mzyReqrec.patientId + '\',' + row.mzyReqrec.times + ')">';
+                                }
+                               else if (printFlag && fpVsesionNo == 0) {
                                     html += '                            <button type="button" class="registration-no-color-foot-button"  title="打印" onclick="prn1Print(\'' + row.mzyReqrec.patientId + '\',' + row.mzyReqrec.times + ')">';
                                 } else {
                                     html += '                            <button type="button" class="can-not-used" title="打印">';
                                 }
                                 html += '<i class="fa fa-print"></i></button>';
                             }
+                            if(fpVsesionNo == 1){
+                                html += '                            <button type="button" class="registration-no-color-foot-button"  title="上传电子发票" onclick="uploadBlueInvoice(\'' + row.mzyReqrec.patientId + '\',' + row.mzyReqrec.times + ')"><i class="fa fa-upload"></i></button>';
+                                html += '  <button type="button" class="registration-no-color-foot-button"  title="下载电子发票" onclick="downloadInvoice(\'' + row.mzyReqrec.patientId + '\',' + row.mzyReqrec.times +',1'+ ')"><i class="fa fa-download"></i></button>';
+                            }
                             html += '<button type="button" class="can-not-used" title="智能支付参数与条形码"><i class="fa fa-barcode"></i></button>';
                             // html += '<button type="button" class="registration-no-color-foot-button"  title="取消接诊" onclick="cancelClinic(\'' + row.mzyReqrec.patientId + '\',' + row.mzyReqrec.times + ')"><i class="fa fa-mail-reply"></i></button>';
                             return html;
@@ -1418,12 +1444,19 @@ function loadTableList() {
                             html += '<i class="fa fa-rmb"></i></button>';
                         } else {
                             var printFlag = isEmpty(row.mzyReqrec.printerId);
-                            if (printFlag) {
+                            if(fpVsesionNo == 1){
+                                html += '                            <button type="button" class="registration-no-color-foot-button"  title="打印并上传电子发票" onclick="prn1Print(\'' + row.mzyReqrec.patientId + '\',' + row.mzyReqrec.times + ')">';
+                            }
+                           else if (printFlag && fpVsesionNo == 0) {
                                 html += '                            <button type="button" class="registration-no-color-foot-button"  title="打印" onclick="prn1Print(\'' + row.mzyReqrec.patientId + '\',' + row.mzyReqrec.times + ')">';
                             } else {
                                 html += '                            <button type="button" class="can-not-used" title="打印">';
                             }
                             html += '<i class="fa fa-print"></i></button>';
+                           if(fpVsesionNo == 1){
+                               html += '                            <button type="button" class="registration-no-color-foot-button"  title="上传电子发票" onclick="uploadBlueInvoice(\'' + row.mzyReqrec.patientId + '\',' + row.mzyReqrec.times + ')"><i class="fa fa-upload"></i></button>';
+                               html += '  <button type="button" class="registration-no-color-foot-button"  title="下载电子发票" onclick="downloadInvoice(\'' + row.mzyReqrec.patientId + '\',' + row.mzyReqrec.times +',1'+ ')"><i class="fa fa-download"></i></button>';
+                           }
                         }
                         html += '<button type="button" class="registration-no-color-foot-button" title="智能支付参数与条形码" onclick="createBarcode(\'' + row.mzyReqrec.patientId + '\',' + row.mzyReqrec.times + ')"><i class="fa fa-barcode"></i></button>';
                         //html += '<button type="button" class="can-not-used"  title="取消接诊"><i class="fa fa-mail-reply"></i></button>';
@@ -1659,6 +1692,10 @@ function saveBackNo(refundType) {
                     $("#refundPayDetailForm").html(html);
                     $("#refundPayDetailModal").modal();
                 }
+                //电子发票作废
+                if(fpVsesionNo == 1){
+                    uploadRedInvoice($("#backNoPatientId").val(),$("#backNoTimes").val());
+                }
             } else if (res.code == -2) {
                 loadTableCount();
                 loadRegistrationList(true);
@@ -1687,6 +1724,40 @@ function chargeFeeForByjz(serialNo) {
 }
 
 
+//上传电子发票
+function uploadBlueInvoice(patientId,times) {
+    postAjaxJsonHttpRequst("/thmz/uploadMzInvoice",{patientId:patientId,times:times,receiptNo:0,ghFlag:true,typeFlag:1},true,function (rs) {
+        if(rs.code ==0){
+            successMesageSimaple("电子发票上传成功!")
+        }else {
+            errorMesage(rs);
+        }
+    })
+}
+
+//电子发票作废
+function uploadRedInvoice(patientId,times) {
+    postAjaxJsonHttpRequst("/thmz/uploadMzInvoice",{patientId:patientId,times:times,receiptNo:0,ghFlag:true,typeFlag:2},true,function (rs) {
+        if(rs.code ==0){
+            successMesageSimaple("电子发票作废成功!")
+        }else {
+            errorMesage(rs);
+        }
+    })
+}
+
+//下载电子发票
+function downloadInvoice(patientId,times,typeFlag) {
+    postAjaxJsonHttpRequst("/thmz/queryInvoiceFile",{patientId:patientId,times:times,typeFlag:typeFlag,receiptNo:0},true,function (res) {
+        if(res.code == 0){
+            base64toPDF(res.data.pdfFileStr)
+        }else {
+            errorMesage(res)
+        }
+    })
+}
+
+
 /**
  * 直接打印发票
  * @param patientId
@@ -1694,9 +1765,6 @@ function chargeFeeForByjz(serialNo) {
 function prn1Print(patientId, times) {
     setPrint();
     var height = "93.15mm";
-    // if(countReceiot%2==0){
-    //     height ="93.2mm";
-    // }
     $.ajax({
         type: "GET",
         url: '/thmz/printMzyReqrecRecept?patientId=' + patientId + "&times=" + times,
@@ -1725,35 +1793,49 @@ function prn1Print(patientId, times) {
                 LODOP.SET_PRINT_MODE("CREATE_CUSTOM_PAGE_NAME", "门诊发票");//对新建的纸张重命名
                 LODOP.SET_PRINT_STYLE("FontSize", 11); //字体大小
                 LODOP.ADD_PRINT_TEXT("6mm", "0mm", "55mm", "3mm", "湖南泰和医院管理有限公司");
-                LODOP.ADD_PRINT_TEXT("6mm", "59mm", "30mm", "3mm", "流水号:");
-                LODOP.ADD_PRINT_TEXT("6mm", "72mm", "20mm", "3mm", temp.serialNo);
-                LODOP.ADD_PRINT_TEXT("19mm", "0mm", "35mm", "3mm", temp.receiptBill);
-                LODOP.ADD_PRINT_TEXT("25mm", "7mm", "50mm", "3mm", temp.name);
-                LODOP.ADD_PRINT_TEXT("25mm", "61mm", "27mm", "3mm", patientId);
-                LODOP.ADD_PRINT_TEXT("32mm", "6mm", "50mm", "3mm", "就诊科室:" + temp.unitCode);
-                LODOP.ADD_PRINT_TEXT("32mm", "56mm", "50mm", "3mm", "地点:" + res.officePos);
-                LODOP.ADD_PRINT_TEXT("37mm", "6mm", "50mm", "3mm", "看诊医生:" + temp.doctorCode);
-                LODOP.ADD_PRINT_TEXT("37mm", "56mm", "50mm", "3mm", "号段:" + temp.ampm);
-                LODOP.ADD_PRINT_TEXT("42mm", "6mm", "50mm", "3mm", "号别:" + temp.chargeType);
-                LODOP.ADD_PRINT_TEXT("42mm", "56mm", "50mm", "3mm", "挂号费:" + temp.reqFee);
-                LODOP.ADD_PRINT_TEXT("47mm", "6mm", "50mm", "3mm", "诊查费:" + temp.clinicFee);
-                LODOP.ADD_PRINT_TEXT("47mm", "56mm", "50mm", "3mm", "其他:" + temp.othFee);
-                var blbFee=temp.blbFee;
-                if(blbFee==null){
-                    blbFee=0;
-                }
-                if (temp.zlkFee != null) {
-                    blbFee = blbFee + temp.zlkFee;
+                if(fpVsesionNo == 0){
+                    LODOP.ADD_PRINT_TEXT("6mm", "59mm", "30mm", "3mm", "流水号:");
+                    LODOP.ADD_PRINT_TEXT("6mm", "72mm", "20mm", "3mm", temp.serialNo);
+                    LODOP.ADD_PRINT_TEXT("19mm", "0mm", "35mm", "3mm", temp.receiptBill);
+                    LODOP.ADD_PRINT_TEXT("25mm", "7mm", "50mm", "3mm", temp.name);
+                    LODOP.ADD_PRINT_TEXT("25mm", "61mm", "27mm", "3mm", patientId);
+                    LODOP.ADD_PRINT_TEXT("32mm", "6mm", "50mm", "3mm", "就诊科室:" + temp.unitCode);
+                    LODOP.ADD_PRINT_TEXT("32mm", "56mm", "50mm", "3mm", "地点:" + res.officePos);
+                    LODOP.ADD_PRINT_TEXT("37mm", "6mm", "50mm", "3mm", "看诊医生:" + temp.doctorCode);
+                    LODOP.ADD_PRINT_TEXT("37mm", "56mm", "50mm", "3mm", "号段:" + temp.ampm);
+                    LODOP.ADD_PRINT_TEXT("42mm", "6mm", "50mm", "3mm", "号别:" + temp.chargeType);
+                    LODOP.ADD_PRINT_TEXT("42mm", "56mm", "50mm", "3mm", "挂号费:" + temp.reqFee);
+                    LODOP.ADD_PRINT_TEXT("47mm", "6mm", "50mm", "3mm", "诊查费:" + temp.clinicFee);
+                    LODOP.ADD_PRINT_TEXT("47mm", "56mm", "50mm", "3mm", "其他:" + temp.othFee);
+                    var blbFee=temp.blbFee;
+                    if(blbFee==null){
+                        blbFee=0;
+                    }
+                    if (temp.zlkFee != null) {
+                        blbFee = blbFee + temp.zlkFee;
+                    }
+                    LODOP.ADD_PRINT_TEXT("52mm", "6mm", "50mm", "3mm", "工本费:" + blbFee);
+                    LODOP.ADD_PRINT_TEXT("65mm", "21mm", "60mm", "3mm", res.totalFee + " 元");
+                    LODOP.ADD_PRINT_TEXT("72mm", "19mm", "60mm", "3mm", res.totalFeeStr);
+                    LODOP.ADD_PRINT_TEXT("79mm", "0mm", "15mm", "3mm", res.year);//年
+                    LODOP.ADD_PRINT_TEXT("79mm", "13mm", "10mm", "3mm", res.month);//月
+                    LODOP.ADD_PRINT_TEXT("79mm", "25mm", "10mm", "3mm", res.day);//日
+                    LODOP.ADD_PRINT_TEXT("79mm", "53mm", "23mm", "3mm", res.user.userName);//收费员
+                }else {
+                    LODOP.ADD_PRINT_TEXT("5mm", "3mm", "50mm", "3mm", "姓名:"+temp.name);
+                    LODOP.ADD_PRINT_TEXT("9mm", "3mm", "50mm", "3mm", "门诊号:"+patientId);
+                    LODOP.ADD_PRINT_TEXT("13mm", "3mm", "50mm", "3mm", "就诊科室:" + temp.unitCode);
+                    LODOP.ADD_PRINT_TEXT("17mm", "3mm", "70mm", "3mm", "地点:" +  res.officePos);
+                    LODOP.ADD_PRINT_TEXT("21mm", "3mm", "50mm", "3mm", "看诊医生:" + temp.doctorCode);
+                    LODOP.ADD_PRINT_TEXT("25mm", "3mm", "50mm", "3mm", "号段:" + temp.ampm);
+                    LODOP.ADD_PRINT_TEXT("29mm", "3mm", "50mm", "3mm", "号别:" + temp.chargeType);
+                    LODOP.ADD_PRINT_TEXT("33mm", "3mm", "50mm", "3mm", "收费员:"+res.user.userName);//收费员
                 }
-                LODOP.ADD_PRINT_TEXT("52mm", "6mm", "50mm", "3mm", "工本费:" + blbFee);
-                LODOP.ADD_PRINT_TEXT("65mm", "21mm", "60mm", "3mm", res.totalFee + " 元");
-                LODOP.ADD_PRINT_TEXT("72mm", "19mm", "60mm", "3mm", res.totalFeeStr);
-                LODOP.ADD_PRINT_TEXT("79mm", "0mm", "15mm", "3mm", res.year);//年
-                LODOP.ADD_PRINT_TEXT("79mm", "13mm", "10mm", "3mm", res.month);//月
-                LODOP.ADD_PRINT_TEXT("79mm", "25mm", "10mm", "3mm", res.day);//日
-                LODOP.ADD_PRINT_TEXT("79mm", "53mm", "23mm", "3mm", res.user.userName);//收费员
-                //LODOP.PREVIEW();
                 LODOP.PRINT();
+                if(fpVsesionNo == 1){
+                    //上传电子发票
+                    uploadBlueInvoice(patientId, times)
+                }
                 if (times > 0) {
                     loadTableCount();
                     loadRegistrationList(true);

+ 89 - 6
src/main/resources/static/js/mz/toll_administration.js

@@ -9,10 +9,12 @@ var mzjsdHost = null;
 
 var readPatientId ='';
 var readTimes = null
+var fpVsesionNo = 0;
 $(function () {
     //默认光标在卡号输入框
     $("#cardNo").focus();
     init_daterangepicker();
+    initFpVersion();
     initSelect();
     // initConsumeChequeType();
     initFeeTable();
@@ -142,6 +144,14 @@ function refundBillItemButtonChange(object) {
     initMzChargeDetailByBillItem(false);
 }
 
+//初始化版本电子发票版本
+function initFpVersion() {
+    getAjaxRequst("/thmz/queryFpVersion",{},true,function (res) {
+        console.log('发票版本=',res.data)
+        fpVsesionNo = res.data;
+    })
+}
+
 /**
  * 初始化下拉选
  */
@@ -501,12 +511,17 @@ function initFeeTable() {
                     if (payMarkGroup == 1) {
                         // 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>' ;
                         str += '<button type="button" class="registration-no-color-foot-button" title="退费" onclick="refundFee(\'' + row.patientId + '\',' + row.times + ',' + row.receiptNo + ',' + row.printFlag + ');"><i class="fa fa-reply"></i></button>';
-                        if (row.printFlag == 0) {
+                        if (row.printFlag == 0 && fpVsesionNo == 0) {
                             str += '<button type="button" id="button_' + row.realNo + '" class="registration-no-color-foot-button" title="发票打印" onclick="prn1PrintHand(\'' + row.patientId + '\',' + row.times + ',true,' + row.receiptNo + ',' + row.realNo + ');" style="color: #35D082;"><i class="fa fa-print"></i></button>';
-                        } else if (row.printFlag == 1) {
+                        } else if (row.printFlag == 1 && fpVsesionNo == 0) {
                             str += '<button type="button" class="registration-no-color-foot-button" title="发票重打" onclick="repPrint(\'' + row.patientId + '\',' + row.times + ',' + row.receiptNo + ');" style="color: #F4BD00;"><i class="fa fa-print"></i></button>';
                             str += '<button type="button" class="registration-no-color-foot-button" title="发票作废重打" onclick="obsoleteAndRepPrint(\'' + row.patientId + '\',' + row.times + ',' + row.receiptNo + ');" style="color: #E73E48;"><i class="fa fa-print"></i></button>';
                         }
+                        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="downloadDzfp(\'' + row.patientId + '\',' + row.times + ',' + row.receiptNo + ',1'+')"><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>';
                         //是否有权限设置合同编号
                         if (buttonCodes != null) {
@@ -529,6 +544,10 @@ function initFeeTable() {
                     }
                     if (payMarkGroup == 2) {
                         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="downloadDzfp(\'' + row.patientId + '\',' + row.times + ',' + row.receiptNo +',2'+ ')" style="color: red;"><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;
                     }
@@ -1678,7 +1697,11 @@ function saveConfirmFee() {
                 return;
             }
             if (res.code == 0) {
-                prn1Print(patientId, times, true, res.receiptNo);
+                if(fpVsesionNo == 0){
+                    prn1Print(patientId, times, true, res.receiptNo);
+                }else {
+                    printDzfp(patientId, times,res.receiptNo,0)
+                }
                 successMesage(res);
                 closeConfirmFeeModal();
                 //缴费成功后清空全局参数
@@ -1741,6 +1764,53 @@ function saveProject() {
 
 }
 
+//上传电子发票
+function printDzfp(patientId,times,receiptNo,loadingFlag) {
+    if(loadingFlag == 1){
+        $("#dzfpLoadingModal").modal('show');
+    }
+    postAjaxJsonHttpRequst("/thmz/getNewAllSerialForThisTime",{patientId:patientId,times:times,receiptNo:receiptNo},true,function (res) {
+        if(res.code == 0){
+            uploadMzInvoice(patientId,times,receiptNo,1)
+        }else {
+            $("#dzfpLoadingModal").modal('hide');
+            errorMesage(res)
+        }
+    })
+}
+
+/**
+ *
+ * @param patientId
+ * @param times
+ * @param receiptNo
+ * @param typeFlag 1 上传门诊蓝字发票 2上传红字发票 (作废)
+ */
+function uploadMzInvoice(patientId,times,receiptNo,typeFlag) {
+    postAjaxJsonHttpRequst("/thmz/uploadMzInvoice",{patientId:patientId,times:times,receiptNo:receiptNo,ghFlag:false,typeFlag:typeFlag},true,function (rs) {
+        if(typeFlag == 1){
+            $("#dzfpLoadingModal").modal('hide');
+        }
+        if(rs.code ==0){
+            successMesageSimaple("电子发票上传成功!")
+            if(typeFlag == 1){
+                initFeeTable();
+            }
+        }else {
+            errorMesage(rs);
+        }
+    })
+}
+//下载电子发票
+function downloadDzfp(patientId,times,receiptNo,typeFlag) {
+    postAjaxJsonHttpRequst("/thmz/queryInvoiceFile",{patientId:patientId,times:times,typeFlag:typeFlag,receiptNo:receiptNo},true,function (res) {
+        if(res.code == 0){
+            base64toPDF(res.data.pdfFileStr)
+        }else {
+            errorMesage(res)
+        }
+    })
+}
 
 /**
  * 直接打印发票
@@ -2708,9 +2778,18 @@ function saveRefundFee(refundType) {
                     $("#refundPayDetailForm").html(html);
                     $("#refundPayDetailModal").modal();
                 }
+                //作废电子发票
+                if(fpVsesionNo == 1){
+                    uploadMzInvoice(params.patientId, params.times,params.receiptNo,2);
+                }
                 if (res.times > 0) {
-                    if(confirm("是否打印发票?")){
-                        prn1Print(res.patientId, res.times, false, 1);
+                    let fpTitle = fpVsesionNo == 0 ? '打印' : '上传';
+                    if(confirm(`是否${fpTitle}发票?`)){
+                        if(fpVsesionNo == 0){
+                            prn1Print(res.patientId, res.times, false, 1);
+                        }else {
+                            printDzfp(res.patientId, res.times,1,0)
+                        }
                     }
                 } else {
                     initFeeTable();
@@ -3276,7 +3355,11 @@ function chargeFeeForMztcbl() {
             if (res.code == 0) {
                 $("#mzblModal").modal("hide");
                 clearMztcbl();
-                prn1Print(patientId, times, false, res.receiptNo);
+                if(fpVsesionNo == 0){
+                    prn1Print(patientId, times, false, res.receiptNo);
+                }else {
+                    printDzfp(patientId, times,res.receiptNo,0)
+                }
             } else {
                 errorMesage(res);
             }

+ 10 - 1
src/main/resources/templates/mz/toll_administration.html

@@ -851,7 +851,16 @@
     </div>
 </div>
 <!--医保结算弹窗结尾-->
-
+<!--电子发票弹窗-->
+<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true" id="dzfpLoadingModal" data-backdrop="static" data-keyboard="false" style="margin-top: 50px;">
+    <div class="modal-dialog modal-lg">
+        <div class="modal-content" style="width: 700px;margin-left: 200px;">
+            <div class="modal-body">
+                <h1 style="height: 200px;line-height: 200px;text-align: center;"> 电子发票上传中,请稍等... </h1>
+            </div>
+        </div>
+    </div>
+</div>
 
 
 

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor