From 962d1b2fb12dd90a661748c952825b8cebdcb35d Mon Sep 17 00:00:00 2001
From: zjh <zjh@888>
Date: 星期四, 13 六月 2024 16:22:29 +0800
Subject: [PATCH] zjh 本地 2024/06/13 --2

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java |  156 +++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 111 insertions(+), 45 deletions(-)

diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java
index d24c32c..baf6870 100644
--- a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java
+++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java
@@ -4,7 +4,9 @@
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.LocalTime;
 import java.time.OffsetTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
@@ -23,6 +25,7 @@
 import cn.hutool.extra.pinyin.PinyinUtil;
 import com.alibaba.fastjson2.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fasterxml.jackson.databind.BeanProperty;
@@ -35,6 +38,7 @@
 import com.ltkj.common.utils.PDFDocumentUtil;
 import com.ltkj.common.utils.SecurityUtils;
 import com.ltkj.framework.config.MatchUtils;
+import com.ltkj.framework.config.ThreadPoolConfig;
 import com.ltkj.framework.config.UserHoder;
 import com.ltkj.framework.datasource.DynamicDataSourceContextHolder;
 import com.ltkj.hosp.domain.*;
@@ -57,6 +61,9 @@
 import com.ltkj.system.service.ISysConfigService;
 import com.ltkj.system.service.ISysDeptService;
 import com.ltkj.system.service.ISysUserService;
+import com.ltkj.web.controller.his.HisApiGetMethodService;
+import com.ltkj.web.controller.his.HisApiMethod;
+import com.ltkj.web.controller.his.HisMzJysqController;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -65,8 +72,10 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpRequest;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.util.DigestUtils;
 import org.springframework.web.bind.annotation.*;
 import com.ltkj.common.annotation.Log;
@@ -164,6 +173,16 @@
     private LtkjMiddleHeadService headService;
     @Resource
     private TjvLtkjvtjpatService tjvLtkjvtjpatService;
+    @Autowired
+    private ThreadPoolConfig threadPoolConfig;
+
+    @Autowired
+    private HisApiMethod hisApiMethod;
+
+    @Autowired
+    private HisMzJysqController hisMzJysqController;
+    @Autowired
+    private HisApiGetMethodService hisApiGetMethodService;
 
 
     /**
@@ -845,8 +864,8 @@
         wq1.eq(TjReservation::getIsExpire, 2);
         TjReservation tjReservation = tjReservationService.getOne(wq1);
         MallOrder mallOrder = null;
-        if (tjReservation != null) {
-            order.setReservationId(tjReservation.getId());
+        if (null != tjReservation) {
+            tjOrder.setReservationId(tjReservation.getId());
             mallOrder = mallOrderService.getOne(new LambdaQueryWrapper<MallOrder>().eq(MallOrder::getReservationId, tjReservation.getId()));
             if (DateUtil.endOfDay(new Date()).before(tjReservation.getReservationTime())) {
                 return AjaxResult.error("鏈埌棰勭害鏃堕棿");
@@ -901,6 +920,7 @@
         tjOrder.setStatus(TjConstants.TJ_BEGIN);
         tjOrder.setCardId(tjCustomer.getCardId());
         if (tjOrderService.save(tjOrder)) {
+
             //淇濆瓨鏀惰揣鍦板潃
             if ("2".equals(tjOrder.getGetType())) {
                 final TjReportGetAddress address = tjOrder.getAddAddress();
@@ -1008,8 +1028,16 @@
 //
 //                }
 //            }
+
+
+            /*璋冪敤his鎺ュ彛*/
+            String config = configService.selectConfigByKey("sfkqdyhis");
+            if(null !=config && config.equals("Y")){
+                hisApiMethod.HisApiMethods(tjCustomer,tjOrder.getOrderId());
+            }
             tjCustomer.setCardId("0");
             tjCustomerService.updateById(tjCustomer);
+
             return AjaxResult.success(tjNumber);
         }
         return AjaxResult.error();
@@ -1037,7 +1065,8 @@
             wq.in(TjCustomer::getCusIdcard, cusIds);
             List<Long> list = tjCustomerService.list(wq).stream().map(TjCustomer::getCusId).collect(Collectors.toList());
             if (list.size() > 0) {
-                ExecutorService threadPool = Executors.newFixedThreadPool(list.size());
+//                ExecutorService threadPool = Executors.newFixedThreadPool(list.size());
+                ThreadPoolTaskExecutor executor = threadPoolConfig.threadPoolTaskExecutor();
                 for (Long aLong : list) {
 //                    threadPool.execute(new Runnable() {
 //                        @Override
@@ -1050,7 +1079,7 @@
 //                            }
 //                        }
 //                    });
-                    Future<AjaxResult> future = threadPool.submit(new Callable<AjaxResult>() {
+                    Future<AjaxResult> future = executor.submit(new Callable<AjaxResult>() {
                         @Override
                         public AjaxResult call() throws Exception {
                             return getAjaxResult(aLong, sysUser, daoDto.getTjCategory());
@@ -1064,10 +1093,9 @@
                         e.printStackTrace();
                     }
                 }
-                threadPool.shutdown();
+                threadPools.shutdown();
             }
         }
-        System.out.println("tjNumbers = " + tjNumbers);
         // TODO 鍥犱负鏈変綋妫�鍙蜂細鏌ュ嚭绌烘暟鎹� 鍏堜娇鐢ㄦ鏁版嵁
         tjNumbers = new ArrayList<>();
         tjNumbers.add("02095240229171627");
@@ -1086,11 +1114,14 @@
                 try {
                     List<Map<String, String>> djdInfos = tjOrderService.selectDjdInfo(tjNumbers.get(i));
                     Map<String, Object> userInfo = tjOrderService.selectDjdUserInfo(tjNumbers.get(i));
-                    System.out.println(userInfo);
                     LocalDateTime tjsj = (LocalDateTime) userInfo.get("tjsj");
                     DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
+                    String time = null;
+                    if (tjsj != null) {
+                        time = dateFormat.format(tjsj);
+                    }
                     PDFDocumentUtil.makeUserInfoTable(document, (String) userInfo.get("tjname"), (String) userInfo.get("sex")
-                            , (String) userInfo.get("tjh"), (String) userInfo.get("lxdh"), (String) userInfo.get("tjname"), dateFormat.format(tjsj));
+                            , (String) userInfo.get("tjh"), (String) userInfo.get("lxdh"), (String) userInfo.get("tjname"), time);
                     PDFDocumentUtil.makeTjInfo(document, djdInfos);
                     // 澶氭潯鍒欐崲椤�
                     if (i + 1 < tjNumbers.size()) {
@@ -1101,13 +1132,9 @@
                 }
             }
             document.close();
-            // TODO 淇敼杩斿洖鏂囦欢base64
             ByteArrayOutputStream outputStream = (ByteArrayOutputStream) map.get("stream");
-            // 璁剧疆HTTP鍝嶅簲澶�
-            response.setContentType("application/pdf");
-            response.setHeader("Content-Disposition", "inline; filename=\"downloaded.pdf\"");
-            response.getOutputStream().write(outputStream.toByteArray());
-            response.getOutputStream().flush();
+            String encodeToString = java.util.Base64.getEncoder().encodeToString(outputStream.toByteArray());
+            return AjaxResult.success().put("file", encodeToString);
         } catch (IOException | DocumentException e) {
             e.printStackTrace();
         }
@@ -1504,7 +1531,7 @@
                 if (null != ppList && ppList.size() > 0) {
                     //寮傛淇濆瓨鏁版嵁搴�
 //                    asyncService.addRedisTransitionPac(cusId, pacId, ppList);
-                    asyncService.saveRedisTransitionByPacId(cusId, pacId, null);
+                    asyncService.saveRedisTransitionByPacId(cusId,cardId, pacId, null);
                     for (TjPackageProject tjPackageProject : ppList) {
                         TjProject project = projectService.getTjProjectById(String.valueOf(tjPackageProject.getProId()));
                         if (null != project) {
@@ -1549,7 +1576,7 @@
         //鍗曢」
         if (null != proIds && proIds.size() > 0) {
             //寮傛淇濆瓨鏁版嵁搴撹〃
-            asyncService.saveRedisTransitionByPacId(cusId, null, proIds);
+            asyncService.saveRedisTransitionByPacId(cusId,cardId,null, proIds);
             for (Long proId : proIds) {
                 List<TbTransition> transitions = transitionService.getTbTransitionListByCusIdAndPacIdAndProId(cusId, String.valueOf(proId));
                 if (null != transitions && transitions.size() > 0) {
@@ -2296,6 +2323,33 @@
             tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId()));
             transitionService.deletedTbTransitionByTjNum(tjNum);
             transitionService.updateTbTransitionByTjNum(tjNum);
+            String configByKey = configService.selectConfigByKey("sfkqdyhis");
+            if (configByKey.equals("Y")){
+                HashMap<String, Object> map = new HashMap<>();
+                map.put("cardtype","4");
+                map.put("input",order.getCardId());
+                LocalDate currentDate = LocalDate.now();
+                LocalDateTime startOfDay = currentDate.atStartOfDay();
+                LocalDateTime nineteenOClock = currentDate.atTime(LocalTime.of(19, 0));
+                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+                String ksrq = startOfDay.format(formatter);
+                String jsrq = nineteenOClock.format(formatter);
+                map.put("ksrq",ksrq);
+                map.put("jsrq",jsrq);
+                AjaxResult result = hisApiGetMethodService.getHISDataNew("Getoutpatientcostinfo", map);
+                if (Integer.parseInt(String.valueOf(result.get("code"))) == 200){
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return AjaxResult.error("鎾ら攢澶辫触,闂ㄨ瘖鎮h�呰垂鐢ㄦ竻鍗曚俊鎭笉涓虹┖");
+                }else {
+                    boolean zfHisApiMethods = hisApiMethod.ZfHisApiMethods(null, order);
+                    if (zfHisApiMethods) {
+                        return AjaxResult.success("鎾ら攢鎴愬姛", map);
+                    }else {
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return AjaxResult.error("鎾ら攢澶辫触,璋冪敤浣滃簾鍑虹幇澶辫触");
+                    }
+                }
+            }
             return AjaxResult.success("鎾ら攢鎴愬姛!!!");
         }
         return AjaxResult.success("绛惧埌璁板綍涓嶅瓨鍦�!");
@@ -2372,34 +2426,46 @@
         return AjaxResult.error("璇烽�夋嫨瑕佹挙閿�鐨勪汉鍛�!");
     }
 
-//    @PostMapping("makeTjPDF1")
-//    @ApiOperation(value = "鏍规嵁浣撴鍙风敓鎴怭DF")
-//    public AjaxResult makeTjPDF(@RequestBody List<String> tjNumbers, HttpServletResponse response) {
-//        System.out.println("tjNumbers = " + tjNumbers);
-//        Map<String, Object> map = null;
-//        try {
-//            map = PDFDocumentUtil.getDocument();
-//            Document document = (Document) map.get("document");
-//            for (int i = 0; i < tjNumbers.size(); i++) {
-//                try {
-//                    List<Map<String, String>> djdInfos = tjOrderService.selectDjdInfo(tjNumbers.get(i));
-//                    Map<String, Object> userInfo = tjOrderService.selectDjdUserInfo(tjNumbers.get(i));
-//                    PDFDocumentUtil.makeUserInfoTable(document, userInfo.get("tjname"), userInfo.get("sex"), userInfo.get("tjh"), userInfo.get("lxdh"), userInfo.get("tjname"), userInfo.get("tjsj"));
-//                    PDFDocumentUtil.makeTjInfo(document, djdInfos);
-//                    // 澶氭潯鍒欐崲椤�
-//                    if (i + 1 < tjNumbers.size()) {
-//                        document.newPage();
-//                    }
-//                } catch (DocumentException | IOException e) {
-//                    e.printStackTrace();
-//                }
-//            }
-//            document.close();
-//        } catch (IOException | DocumentException e) {
-//            e.printStackTrace();
-//        }
-//        return AjaxResult.success();
-//    }
-
+    @PostMapping("makeTjPDF")
+    @ApiOperation(value = "鎵归噺鐢熸垚PDF")
+    public AjaxResult makeTjPDF(@RequestBody List<String> reservations) {
+        QueryWrapper<TjOrder> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in("reservation_id",reservations);
+        List<TjOrder> tjNumbers = tjOrderService.list(queryWrapper);
+        Map<String, Object> map = null;
+        try {
+            map = PDFDocumentUtil.getDocument();
+            Document document = (Document) map.get("document");
+            for (int i = 0; i < tjNumbers.size(); i++) {
+                String tjNumber = tjNumbers.get(i).getTjNumber();
+                try {
+                    List<Map<String, String>> djdInfos = tjOrderService.selectDjdInfo(tjNumber);
+                    Map<String, Object> userInfo = tjOrderService.selectDjdUserInfo(tjNumber);
+                    LocalDateTime tjsj = (LocalDateTime) userInfo.get("tjsj");
+                    DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
+                    String time = null;
+                    if (tjsj != null) {
+                        time = dateFormat.format(tjsj);
+                    }
+                    PDFDocumentUtil.makeUserInfoTable(document, (String) userInfo.get("tjname"), (String) userInfo.get("sex")
+                            , (String) userInfo.get("tjh"), (String) userInfo.get("lxdh"), (String) userInfo.get("tjname"), time);
+                    PDFDocumentUtil.makeTjInfo(document, djdInfos);
+                    // 澶氭潯鍒欐崲椤�
+                    if (i + 1 < tjNumbers.size()) {
+                        document.newPage();
+                    }
+                } catch (DocumentException | IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            document.close();
+            ByteArrayOutputStream outputStream = (ByteArrayOutputStream) map.get("stream");
+            String encodeToString = java.util.Base64.getEncoder().encodeToString(outputStream.toByteArray());
+            return AjaxResult.success().put("file", encodeToString);
+        } catch (IOException | DocumentException e) {
+            e.printStackTrace();
+            return AjaxResult.error(e.getMessage());
+        }
+    }
 }
 

--
Gitblit v1.8.0