Forráskód Böngészése

电子发票完成

lighter 3 hónapja
szülő
commit
4fbbfe1921

+ 13 - 0
src/main/java/thyyxxk/wxservice_server/config/properties/YmlConfig.java

@@ -0,0 +1,13 @@
+package thyyxxk.wxservice_server.config.properties;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Data
+@Component
+@ConfigurationProperties(prefix = "thyy.config")
+public class YmlConfig {
+    private String dzfpdir;
+    private String dzfpurl;
+}

+ 20 - 0
src/main/java/thyyxxk/wxservice_server/dao/PayMzFeeDao.java

@@ -1,11 +1,31 @@
 package thyyxxk.wxservice_server.dao;
 
+import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Insert;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
 import thyyxxk.wxservice_server.entity.paymzfee.MedinsSettle;
 
+import java.util.List;
+import java.util.Map;
+
 @Mapper
 public interface PayMzFeeDao {
     @Select("select * from t_si_setlinfo where pat_no=#{patNo} and times=#{times} and revoked=0")
     MedinsSettle selectSettleinfo(String patNo, int times);
+
+    @Insert("insert into t_wx_file2del (id,path,type) values (#{id},#{path},'DZFP')")
+    void insertWx2del(String id, String path);
+
+    @Select("select id,path from t_wx_file2del where type='DZFP' and " +
+            "datediff(second,create_time,getdate())>=1800")
+    List<Map<String, String>> getDzfp2del();
+
+    @Delete("<script>" +
+            "delete from t_wx_file2del where id in (" +
+            "<foreach collection='list' item='id' separator=','>" +
+            "#{id}" +
+            "</foreach>)" +
+            "</script>")
+    void deleteWx2del(List<String> list);
 }

+ 3 - 5
src/main/java/thyyxxk/wxservice_server/factory/thmz/ThmzService.java

@@ -15,10 +15,7 @@ import thyyxxk.wxservice_server.entity.hrgresponse.*;
 import thyyxxk.wxservice_server.entity.patientcards.CreatCardParam;
 import thyyxxk.wxservice_server.factory.thmz.model.*;
 import thyyxxk.wxservice_server.service.RedisLikeService;
-import thyyxxk.wxservice_server.utils.CastUtil;
-import thyyxxk.wxservice_server.utils.ResultVoUtil;
-import thyyxxk.wxservice_server.utils.StringUtil;
-import thyyxxk.wxservice_server.utils.ThmzUtil;
+import thyyxxk.wxservice_server.utils.*;
 
 import java.util.*;
 import java.util.concurrent.TimeUnit;
@@ -332,7 +329,8 @@ public class ThmzService {
         }
         if (code == 0) {
             JSONObject data = response.getJSONObject("data");
-            return ResultVoUtil.success(data.getString("pdfFileStr"));
+            String pdfFileStr = data.getString("pdfFileStr");
+            return ResultVoUtil.success(DzfpUtil.savePdfToDisk(pdfFileStr));
         }
         return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, response.getString("message"));
     }

+ 35 - 0
src/main/java/thyyxxk/wxservice_server/scheduled/DelFileTask.java

@@ -0,0 +1,35 @@
+package thyyxxk.wxservice_server.scheduled;
+
+import cn.hutool.core.io.FileUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import thyyxxk.wxservice_server.dao.PayMzFeeDao;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Component
+public class DelFileTask {
+    private final PayMzFeeDao dao;
+
+    @Autowired
+    public DelFileTask(PayMzFeeDao dao) {
+        this.dao = dao;
+    }
+
+    @Scheduled(fixedRate = 1000 * 60 * 5)
+    public void delDzfp() {
+        List<Map<String, String>> list = dao.getDzfp2del();
+        List<String> ids = new ArrayList<>();
+        for (Map<String, String> map : list) {
+            if (FileUtil.del(map.get("path"))) {
+                ids.add(map.get("id"));
+            }
+        }
+        dao.deleteWx2del(ids);
+    }
+}

+ 12 - 2
src/main/java/thyyxxk/wxservice_server/service/PayMzFeeService.java

@@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
+import thyyxxk.wxservice_server.config.properties.YmlConfig;
 import thyyxxk.wxservice_server.constant.medins.Insutype;
 import thyyxxk.wxservice_server.constant.medins.MedType;
 import thyyxxk.wxservice_server.dao.PayMzFeeDao;
@@ -27,12 +28,14 @@ public class PayMzFeeService {
     private final ElectronicHealthCardService healthCardService;
     private final ThmzService thmzService;
     private final PayMzFeeDao dao;
+    private final YmlConfig config;
 
     @Autowired
-    public PayMzFeeService(ElectronicHealthCardService healthCardService, ThmzService thmzService, PayMzFeeDao dao) {
+    public PayMzFeeService(ElectronicHealthCardService healthCardService, ThmzService thmzService, PayMzFeeDao dao, YmlConfig config) {
         this.healthCardService = healthCardService;
         this.thmzService = thmzService;
         this.dao = dao;
+        this.config = config;
     }
 
     public ResultVo<List<Map<String, Object>>> getUnPaidFee(String patientId) {
@@ -89,6 +92,13 @@ public class PayMzFeeService {
         QueryDzfpRequest request = QueryDzfpRequest.builder()
                 .patientId(patNo).times(times).receiptNo(receiptNum)
                 .typeFlag(QueryDzfpRequest.Type.MZLZ).build();
-        return thmzService.queryInvoiceFile(request);
+
+         ResultVo<String> res = thmzService.queryInvoiceFile(request);
+         if (res.getCode() == ExceptionEnum.SUCCESS.getCode()) {
+             String filename = res.getData();
+             dao.insertWx2del(filename, config.getDzfpdir() + "/" + filename);
+             res.setData(config.getDzfpurl() + "/" + filename);
+         }
+         return res;
     }
 }

+ 19 - 0
src/main/java/thyyxxk/wxservice_server/utils/DzfpUtil.java

@@ -0,0 +1,19 @@
+package thyyxxk.wxservice_server.utils;
+
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import thyyxxk.wxservice_server.config.properties.YmlConfig;
+
+import java.util.Base64;
+
+public class DzfpUtil {
+    private static final YmlConfig config = SpringUtil.getBean(YmlConfig.class);
+
+    public static String savePdfToDisk(String pdfStr) {
+        String fileName = IdUtil.fastSimpleUUID() + ".pdf";
+        byte[] pdfBytes = Base64.getDecoder().decode(pdfStr);
+        FileUtil.writeBytes(pdfBytes, config.getDzfpdir() + "/" + fileName);
+        return fileName;
+    }
+}

+ 0 - 2
src/main/java/thyyxxk/wxservice_server/utils/PhysicalCheckPDFUtil.java

@@ -20,8 +20,6 @@ import java.util.UUID;
 public class PhysicalCheckPDFUtil {
     private static final String PDF_PATH = "/home/medical-report-pdf/";
     private static final String LOGO_PATH = "/home/images/thyylogo.png";
-//    private static final String PDF_PATH = "D:\\";
-//    private static final String LOGO_PATH = "D:\\thyylogo.png";
 
     public static void createPDF(HttpServletResponse response, JSONObject tjIndex, JSONObject tjResult) {
         try {

+ 4 - 0
src/main/resources/application-8083.yml

@@ -86,4 +86,8 @@ thyy:
     chronic-api: http://172.16.32.160:8077/chronicDisease
     physical-check-api: http://172.16.32.183:8888/bdp/dataservice/api
     add-face-api: http://172.16.32.167:20923/thyy/api/haikang/door/addFaceRecognition
+  config:
+    dzfpdir: /home/dzfp
+    dzfpurl: https://staticweb.hnthyy.cn/dzfp
+
 production: true

+ 4 - 0
src/main/resources/application-8085.yml

@@ -87,4 +87,8 @@ thyy:
     chronic-api: http://172.16.32.160:8077/chronicDisease
     physical-check-api: http://172.16.32.183:8888/bdp/dataservice/api
     add-face-api: http://172.16.32.167:20923/thyy/api/haikang/door/addFaceRecognition
+  config:
+    dzfpdir: /home/dzfp
+    dzfpurl: https://staticweb.hnthyy.cn/dzfp
+
 production: true

+ 3 - 0
src/main/resources/application-dev.yml

@@ -48,5 +48,8 @@ thyy:
     chronic-api: http://172.16.32.160:8077/chronicDisease
     physical-check-api: http://172.16.32.183:8888/bdp/dataservice/api
     add-face-api: http://172.16.30.66:20923/thyy/api/haikang/door/addFaceRecognition
+  config:
+    dzfpdir: D:/dzfp
+    dzfpurl: https://staticweb.hnthyy.cn/dzfp
 
 production: false

+ 4 - 1
src/main/resources/application-prod.yml

@@ -4,7 +4,7 @@ server:
     context-path: /wxserver
 spring:
   application:
-    name: wxservice-server
+    name: wxservice-server-dev
   thymeleaf:
     cache: false
   datasource:
@@ -48,5 +48,8 @@ thyy:
     chronic-api: http://172.16.32.160:8077/chronicDisease
     physical-check-api: http://172.16.32.183:8888/bdp/dataservice/api
     add-face-api: http://172.16.32.167:20923/thyy/api/haikang/door/addFaceRecognition
+  config:
+    dzfpdir: D:\\
+    dzfpurl: https://staticweb.hnthyy.cn/dzfp
 
 production: false