From d71460e89b4e556aa9f396100004fcdabe98a0ff Mon Sep 17 00:00:00 2001
From: zjh <zjh@888>
Date: 星期五, 14 六月 2024 21:30:39 +0800
Subject: [PATCH] zjh 本地 2024/06/14 --2

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java |   64 +++++++++++++++++++++++++++----
 1 files changed, 55 insertions(+), 9 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 67d8256..a720dbe 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.*;
@@ -59,6 +61,7 @@
 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;
@@ -72,6 +75,7 @@
 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;
@@ -177,6 +181,8 @@
 
     @Autowired
     private HisMzJysqController hisMzJysqController;
+    @Autowired
+    private HisApiGetMethodService hisApiGetMethodService;
 
 
     /**
@@ -839,20 +845,22 @@
         LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>();
         wq.eq(TjCustomer::getCusId, tjOrder.getUserId());
         TjCustomer tjCustomer = tjCustomerService.getOne(wq);
-        if (tjCustomer == null) return AjaxResult.error("璇ュ鎴锋湭鐧昏鎴栦笉瀛樺湪");
+        if (tjCustomer == null) return AjaxResult.error("璇ュ鎴锋湭鐧昏");
 
         LambdaQueryWrapper<TjOrder> wqq = new LambdaQueryWrapper<>();
         wqq.eq(TjOrder::getUserId, tjOrder.getUserId());
         wqq.eq(TjOrder::getCheckStatus, 0);
         wqq.isNull(TjOrder::getFinishTime);
-        if (!tjCustomer.getCardId().equals("0")) {
-            wqq.eq(TjOrder::getCardId, tjCustomer.getCardId());
-        }
+//        if (!tjCustomer.getCardId().equals("0")) {
+        wqq.eq(TjOrder::getCardId, tjCustomer.getCardId());
+//        }
         TjOrder order = tjOrderService.getOne(wqq);
         if (null != order) {
-            transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(), tjCustomer.getCardId());
+            transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(),tjCustomer.getCardId());
             return AjaxResult.error("涓嶅彲閲嶅鐧昏");
         }
+
+
         LambdaQueryWrapper<TjReservation> wq1 = new LambdaQueryWrapper<>();
         wq1.eq(TjReservation::getIdCard, tjCustomer.getCusIdcard());
         wq1.eq(TjReservation::getIsExpire, 2);
@@ -1029,8 +1037,8 @@
             if(null !=config && config.equals("Y")){
                 hisApiMethod.HisApiMethods(tjCustomer,tjOrder.getOrderId());
             }
-            tjCustomer.setCardId("0");
-            tjCustomerService.updateById(tjCustomer);
+//            tjCustomer.setCardId("0");
+//            tjCustomerService.updateById(tjCustomer);
 
             return AjaxResult.success(tjNumber);
         }
@@ -1794,6 +1802,7 @@
      */
     @PostMapping("/tjGoOut")
     @ApiOperation(value = "浣撴绛剧")
+    @Transactional
     public AjaxResult tjGoOut(@RequestBody Map<String, Object> map) {
         Long userId = Long.valueOf(SecurityUtils.getLoginUser().getUserId());
         SysUser sysUser = userService.getById(userId);
@@ -1801,6 +1810,7 @@
         String jsonString = com.alibaba.fastjson.JSON.toJSONString(domainVos1);
         List<QjDomainVo> domainVos = com.alibaba.fastjson.JSON.parseArray(jsonString, QjDomainVo.class);
         String tjNumber = map.get("tjNumber").toString();
+        TjOrder tjOrder = tjOrderService.getOrderByTjNum(tjNumber);
         if (null != domainVos && domainVos.size() > 0) {
             Set<String> list = new HashSet<>();
             for (QjDomainVo domainVo : domainVos) {
@@ -1814,7 +1824,6 @@
                     if (domainVo.getType() == 3) {
                         list.add(String.valueOf(domainVo.getTjNumber()));
                     } else {
-                        TjOrder tjOrder = tjOrderService.getOrderByTjNum(remark.getTjNumber());
                         if (null != tjOrder) {
                             tjOrder.setFinishTime(new Date());
                             tjOrder.setStatus(TjConstants.TJ_CONFIRM);
@@ -1824,6 +1833,11 @@
                 }
             }
             asyncService.tjGoutAsync(domainVos, sysUser, list);
+
+            TjCustomer customer = tjCustomerService.selectTjCustomerByCusId(tjOrder.getUserId());
+            customer.setCardId("0");
+            tjCustomerService.updateById(customer);
+
             return AjaxResult.success("绛剧鎴愬姛锛�");
         } else {
             return getAjaxResult(tjNumber);
@@ -1836,6 +1850,7 @@
      */
     @GetMapping("/goOut")
     @ApiOperation(value = "绛剧")
+    @Transactional
     public AjaxResult goOut(@RequestParam @ApiParam(value = "浣撴鍙�") String tjNumber) {
         return getAjaxResult(tjNumber);
     }
@@ -1932,13 +1947,17 @@
         LambdaQueryWrapper<TjOrder> wq0 = new LambdaQueryWrapper<>();
         wq0.eq(TjOrder::getTjNumber, tjNumber);
         TjOrder tjOrder = tjOrderService.getOne(wq0);
+
         if (null != tjOrder) {
+            TjCustomer customer = tjCustomerService.selectTjCustomerByCusId(tjOrder.getUserId());
+            customer.setCardId("0");
+            tjCustomerService.updateById(customer);
+
             LambdaQueryWrapper<TjOrderDetail> wq11 = new LambdaQueryWrapper<>();
             wq11.eq(TjOrderDetail::getOrderId, tjOrder.getOrderId());
             wq11.eq(TjOrderDetail::getTjStatus, 0);
             wq11.isNotNull(TjOrderDetail::getFlowingWaterId);
             List<TjOrderDetail> list = tjOrderDetailService.list(wq11);
-
             if (list != null) {
                 Long userId = Long.valueOf(SecurityUtils.getLoginUser().getUserId());
                 SysUser sysUser = userService.getById(userId);
@@ -2317,6 +2336,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("绛惧埌璁板綍涓嶅瓨鍦�!");

--
Gitblit v1.8.0