From 9155df2aeab5b0d95c89dd928dbaefbfbaeae9d1 Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期四, 05 九月 2024 17:10:35 +0800
Subject: [PATCH] zjh 2024-09-05

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java | 1244 ++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 846 insertions(+), 398 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 5a6dff8..eb79a5f 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,11 +4,14 @@
 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.*;
 import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
+import java.util.concurrent.*;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import javax.annotation.Resource;
@@ -20,21 +23,32 @@
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.crypto.symmetric.DES;
 import cn.hutool.extra.pinyin.PinyinUtil;
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
 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;
+import com.itextpdf.text.Document;
+import com.itextpdf.text.DocumentException;
 import com.ltkj.common.core.domain.entity.SysDept;
 import com.ltkj.common.core.domain.entity.SysUser;
 import com.ltkj.common.core.redis.RedisCache;
 import com.ltkj.common.enums.DataSourceType;
+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.*;
 import com.ltkj.hosp.dto.QianDaoDto;
+import com.ltkj.hosp.dto.TjProBlDto;
+import com.ltkj.hosp.hisDto.OutpinimpapplyDto;
+import com.ltkj.hosp.hisDto.OutpinmedicapplyDto;
 import com.ltkj.hosp.mapper.TestMapper;
 import com.ltkj.hosp.service.*;
 import com.ltkj.hosp.sqlDomain.LtkjMiddleDetail;
@@ -53,6 +67,10 @@
 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.HisApiMethodService;
+import com.ltkj.web.controller.his.HisMzJysqController;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -61,8 +79,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;
@@ -79,8 +99,8 @@
  * @date 2022-11-21
  */
 @RestController
-@RequestMapping("/hosp/order")
-@Api(tags = "PC绔� ----浣撴璁板綍鎺ュ彛")
+@RequestMapping ("/hosp/order")
+@Api (tags = "PC绔� ----浣撴璁板綍鎺ュ彛")
 @Slf4j
 public class TjOrderController extends BaseController {
     @Resource
@@ -105,7 +125,7 @@
     private ITbTransitionService transitionService;
     @Resource
     private ISysConfigService configService;
-    @Value("${path.filePath}")
+    @Value ("${path.filePath}")
     private String value;
     @Resource
     private ITjOrderRemarkService remarkService;
@@ -160,14 +180,45 @@
     private LtkjMiddleHeadService headService;
     @Resource
     private TjvLtkjvtjpatService tjvLtkjvtjpatService;
+    @Autowired
+    private ThreadPoolConfig threadPoolConfig;
 
+    @Autowired
+    private HisApiMethod hisApiMethod;
+
+    @Autowired
+    private HisMzJysqController hisMzJysqController;
+    @Autowired
+    private HisApiGetMethodService hisApiGetMethodService;
+    @Autowired
+    private ISysDeptService sysDeptService;
+    @Autowired
+    private HisApiMethodService controller;
+    @Autowired
+    private TjProBlService blService;
+    @Autowired
+    private LtkjJianchajianyanTreeService ltkjJianchajianyanTreeService;
+
+    @Autowired
+    private TjCfService cfService;
+
+    //灏嗘柟娉曡繑鍥炲�艰В鏋愭垚json鏍煎紡
+    public JSONObject getJSONObject(String builder) {
+        String Response = JSONUtil.parseObj(builder).getStr("Response");
+        return JSONUtil.parseObj(Response);
+    }
+
+    //鑾峰彇鏂规硶杩斿洖鍊间俊鎭�
+    public String getAjaxResult(AjaxResult result) {
+        return result.get("data").toString();
+    }
 
     /**
      * 鏌ヨ浣撴璁板綍鍒楄〃
      */
 //    @PreAuthorize("@ss.hasPermi('hosp:order:list')")
-    @GetMapping("/list")
-    @ApiOperation(value = "鏌ヨ浣撴璁板綍鍒楄〃(榛樿)")
+    @GetMapping ("/list")
+    @ApiOperation (value = "鏌ヨ浣撴璁板綍鍒楄〃(榛樿)")
     public TableDataInfo list(TjOrder tjOrder) {
         startPage();
         startOrderBy();
@@ -200,16 +251,16 @@
     }
 
 
-    @GetMapping("/getWenJuanList")
-    @ApiOperation(value = "鏌ヨ浣撴璁板綍鍒楄〃")
-    public AjaxResult getWenJuanList(@ApiParam(value = "椤电爜鏁�(榛樿1)") @RequestParam(defaultValue = "1") Integer pageNum,
-                                     @ApiParam(value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam(defaultValue = "10") Integer pageSize,
-                                     @ApiParam(value = "浣撴鍙�") @RequestParam(required = false) String tjNum,
-                                     @ApiParam(value = "濮撳悕") @RequestParam(required = false) String name,
-                                     @ApiParam(value = "鐧昏寮�濮嬫椂闂�") @RequestParam(required = false) Date djbeginTime,
-                                     @ApiParam(value = "鐧昏缁撴潫鏃堕棿") @RequestParam(required = false) Date djendTime,
-                                     @ApiParam(value = "鎶ュ憡寮�濮嬫椂闂�") @RequestParam(required = false) Date bgbeginTime,
-                                     @ApiParam(value = "鎶ュ憡缁撴潫鏃堕棿") @RequestParam(required = false) Date bgendTime) {
+    @GetMapping ("/getWenJuanList")
+    @ApiOperation (value = "鏌ヨ浣撴璁板綍鍒楄〃")
+    public AjaxResult getWenJuanList(@ApiParam (value = "椤电爜鏁�(榛樿1)") @RequestParam (defaultValue = "1") Integer pageNum,
+                                     @ApiParam (value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam (defaultValue = "10") Integer pageSize,
+                                     @ApiParam (value = "浣撴鍙�") @RequestParam (required = false) String tjNum,
+                                     @ApiParam (value = "濮撳悕") @RequestParam (required = false) String name,
+                                     @ApiParam (value = "鐧昏寮�濮嬫椂闂�") @RequestParam (required = false) Date djbeginTime,
+                                     @ApiParam (value = "鐧昏缁撴潫鏃堕棿") @RequestParam (required = false) Date djendTime,
+                                     @ApiParam (value = "鎶ュ憡寮�濮嬫椂闂�") @RequestParam (required = false) Date bgbeginTime,
+                                     @ApiParam (value = "鎶ュ憡缁撴潫鏃堕棿") @RequestParam (required = false) Date bgendTime) {
         Map<String, Object> map = new HashMap<>();
         if (null != name) {
             LambdaQueryWrapper<TjCustomer> wqq = new LambdaQueryWrapper<>();
@@ -329,16 +380,17 @@
     }
 
 
-    @GetMapping("/getOrderList")
-    @ApiOperation(value = "鏌ヨ浣撴璁板綍鍒楄〃")
-    public AjaxResult getOrderList(@ApiParam(value = "椤电爜鏁�(榛樿1)") @RequestParam(defaultValue = "1") Integer pageNum,
-                                   @ApiParam(value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam(defaultValue = "10") Integer pageSize,
-                                   @ApiParam(value = "浣撴鍙�)") @RequestParam(required = false) String tjNum,
-                                   @ApiParam(value = "濮撳悕)") @RequestParam(required = false) String name,
-                                   @ApiParam(value = "鐧昏寮�濮嬫椂闂�") @RequestParam(required = false) Date djbeginTime,
-                                   @ApiParam(value = "鐧昏缁撴潫鏃堕棿") @RequestParam(required = false) Date djendTime,
-                                   @ApiParam(value = "鎶ュ憡寮�濮嬫椂闂�") @RequestParam(required = false) Date bgbeginTime,
-                                   @ApiParam(value = "鎶ュ憡缁撴潫鏃堕棿") @RequestParam(required = false) Date bgendTime) {
+    @GetMapping ("/getOrderList")
+    @ApiOperation (value = "鏌ヨ浣撴璁板綍鍒楄〃")
+    public AjaxResult getOrderList(@ApiParam (value = "椤电爜鏁�(榛樿1)") @RequestParam (defaultValue = "1") Integer pageNum,
+                                   @ApiParam (value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam (defaultValue = "10") Integer pageSize,
+                                   @ApiParam (value = "浣撴鍙�)") @RequestParam (required = false) String tjNum,
+                                   @ApiParam (value = "濮撳悕)") @RequestParam (required = false) String name,
+                                   @ApiParam (value = "椤圭洰鍚�)") @RequestParam (required = false) String xmmc,
+                                   @ApiParam (value = "鐧昏寮�濮嬫椂闂�") @RequestParam (required = false) Date djbeginTime,
+                                   @ApiParam (value = "鐧昏缁撴潫鏃堕棿") @RequestParam (required = false) Date djendTime,
+                                   @ApiParam (value = "鎶ュ憡寮�濮嬫椂闂�") @RequestParam (required = false) Date bgbeginTime,
+                                   @ApiParam (value = "鎶ュ憡缁撴潫鏃堕棿") @RequestParam (required = false) Date bgendTime) {
         Map<String, Object> map = new HashMap<>();
         if (null != name) {
             LambdaQueryWrapper<TjCustomer> wqq = new LambdaQueryWrapper<>();
@@ -408,6 +460,12 @@
         if (null != tjNum) {
             wq.eq(TjOrder::getTjNumber, tjNum);
         }
+
+
+        if (null != xmmc) {
+            wq.in(TjOrder::getTjNumber, projectService.getTjNumLIstByXmmx(xmmc));
+        }
+
         wq.orderByDesc(TjOrder::getCreateTime);
         Page<TjOrder> page2 = tjOrderService.page(page1, wq);
         List<TjOrder> list = page2.getRecords();
@@ -417,10 +475,8 @@
                 if (null != tjCustomer) {
                     order.setTjCustomerSex(tjCustomer.getCusSex());
                     order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
-                    order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
                     order.setTjCustomerName(tjCustomer.getCusName());
-                    order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
-//                    order.setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard()));
+                    order.setTjCustomerPhone(tjCustomer.getCusPhone());
                     order.setTjCusIdCard(tjCustomer.getCusIdcard());
                     order.setCareer(tjCustomer.getCareer());
                     order.setIdType(tjCustomer.getIdType());
@@ -434,7 +490,7 @@
                 if (null != order.getPacId()) {
                     if (null != tjPackageService.getById(order.getPacId())) {
                         order.setPacName(tjPackageService.getById(order.getPacId()).getPacName());
-                    }
+                    }else
                     if (null != dwDeptService.getById(order.getPacId())) {
                         order.setPacName(dwDeptService.getById(order.getPacId()).getDwDeptName());
                     }
@@ -447,20 +503,20 @@
     }
 
 
-    @GetMapping("/getOrderListOO")
-    @ApiOperation(value = "浣撴鎶ュ憡椤甸潰鈥斺�斾綋妫�璁板綍鍒楄〃")
-    public AjaxResult getOrderListOO(@ApiParam(value = "椤电爜鏁�(榛樿1)") @RequestParam(defaultValue = "1") Integer pageNum,
-                                     @ApiParam(value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam(defaultValue = "10") Integer pageSize,
-                                     @ApiParam(value = "浣撴鍙�)") @RequestParam(required = false) String tjNum,
-                                     @ApiParam(value = "濮撳悕)") @RequestParam(required = false) String name,
-                                     @ApiParam(value = "鎶ュ憡寮�濮嬫椂闂�") @RequestParam(required = false) Date bgbeginTime,
-                                     @ApiParam(value = "鎶ュ憡缁撴潫鏃堕棿") @RequestParam(required = false) Date bgendTime) {
+    @GetMapping ("/getOrderListOO")
+    @ApiOperation (value = "浣撴鎶ュ憡椤甸潰鈥斺�斾綋妫�璁板綍鍒楄〃")
+    public AjaxResult getOrderListOO(@ApiParam (value = "椤电爜鏁�(榛樿1)") @RequestParam (defaultValue = "1") Integer pageNum,
+                                     @ApiParam (value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam (defaultValue = "10") Integer pageSize,
+                                     @ApiParam (value = "浣撴鍙�)") @RequestParam (required = false) String tjNum,
+                                     @ApiParam (value = "濮撳悕)") @RequestParam (required = false) String name,
+                                     @ApiParam (value = "鎶ュ憡寮�濮嬫椂闂�") @RequestParam (required = false) Date bgbeginTime,
+                                     @ApiParam (value = "鎶ュ憡缁撴潫鏃堕棿") @RequestParam (required = false) Date bgendTime) {
         Map<String, Object> map = new HashMap<>();
         if (null != name) {
             LambdaQueryWrapper<TjCustomer> wqq = new LambdaQueryWrapper<>();
             wqq.like(TjCustomer::getCusName, name);
             List<TjCustomer> customerList = tjCustomerService.list(wqq);
-            if (null != customerList && customerList.size() > 0) {
+            if (null != customerList && !customerList.isEmpty()) {
                 List<TjOrder> list = new ArrayList<>();
                 for (TjCustomer customer : customerList) {
                     LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>();
@@ -470,7 +526,7 @@
                     list.addAll(tjOrderService.list(wq));
                 }
                 List<TjOrder> collect = null;
-                if (list.size() > 0) {
+                if (!list.isEmpty()) {
 
                     for (int i = 0; i < list.size(); i++) {
                         TjCustomer tjCustomer = tjCustomerService.getById(list.get(i).getUserId());
@@ -480,7 +536,7 @@
                         }
                         list.get(i).setTjCustomerSex(tjCustomer.getCusSex());
                         list.get(i).setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
-                        list.get(i).setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
+                        list.get(i).setTjCustomerName(tjCustomer.getCusName());
                         list.get(i).setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
                         list.get(i).setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard()));
 
@@ -541,7 +597,7 @@
                 }
                 list.get(i).setTjCustomerSex(tjCustomer.getCusSex());
                 list.get(i).setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
-                list.get(i).setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
+                list.get(i).setTjCustomerName(tjCustomer.getCusName());
                 list.get(i).setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
                 if (tjCustomer.getCusIdcard() != null) {
                     list.get(i).setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard()));
@@ -576,15 +632,15 @@
     }
 
 
-    @GetMapping("/getPrintOrderList")
-    @ApiOperation(value = "浣撴鍙戠エ鎵撳嵃鎺ュ彛")
-    public AjaxResult getPrintOrderList(@ApiParam(value = "椤电爜鏁�(榛樿1)") @RequestParam(defaultValue = "1") Integer pageNum,
-                                        @ApiParam(value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam(defaultValue = "10") Integer pageSize,
-                                        @ApiParam(value = "浣撴鍙�)") @RequestParam(required = false) String tjNum,
-                                        @ApiParam(value = "宸叉墦鍗版湭鎵撳嵃0鏈墦鍗�1宸叉墦鍗�)") @RequestParam(required = false) Integer type,
-                                        @ApiParam(value = "濮撳悕") @RequestParam(required = false) String name,
-                                        @ApiParam(value = "鎶ュ憡寮�濮嬫椂闂�") @RequestParam(required = false) Date bgbeginTime,
-                                        @ApiParam(value = "鎶ュ憡缁撴潫鏃堕棿") @RequestParam(required = false) Date bgendTime) {
+    @GetMapping ("/getPrintOrderList")
+    @ApiOperation (value = "浣撴鍙戠エ鎵撳嵃鎺ュ彛")
+    public AjaxResult getPrintOrderList(@ApiParam (value = "椤电爜鏁�(榛樿1)") @RequestParam (defaultValue = "1") Integer pageNum,
+                                        @ApiParam (value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam (defaultValue = "10") Integer pageSize,
+                                        @ApiParam (value = "浣撴鍙�)") @RequestParam (required = false) String tjNum,
+                                        @ApiParam (value = "宸叉墦鍗版湭鎵撳嵃0鏈墦鍗�1宸叉墦鍗�)") @RequestParam (required = false) Integer type,
+                                        @ApiParam (value = "濮撳悕") @RequestParam (required = false) String name,
+                                        @ApiParam (value = "鎶ュ憡寮�濮嬫椂闂�") @RequestParam (required = false) Date bgbeginTime,
+                                        @ApiParam (value = "鎶ュ憡缁撴潫鏃堕棿") @RequestParam (required = false) Date bgendTime) {
         Map<String, Object> map = new HashMap<>();
         List<TjOrder> collect = null;
         if (null != name) {
@@ -775,9 +831,9 @@
      * 瀵煎嚭浣撴璁板綍鍒楄〃
      */
 //    @PreAuthorize("@ss.hasPermi('hosp:order:export')")
-    @Log(title = "浣撴璁板綍", businessType = BusinessType.EXPORT)
-    @PostMapping("/export")
-    @ApiOperation(value = "瀵煎嚭浣撴璁板綍鍒楄〃")
+    @Log (title = "浣撴璁板綍", businessType = BusinessType.EXPORT)
+    @PostMapping ("/export")
+    @ApiOperation (value = "瀵煎嚭浣撴璁板綍鍒楄〃")
     public void export(HttpServletResponse response, TjOrder tjOrder) {
         //List<TjOrder> list = tjOrderService.selectTjOrderList(tjOrder);
         List<TjOrder> list = tjOrderService.selectExportOrderList(tjOrder);
@@ -789,15 +845,15 @@
      * 鑾峰彇浣撴璁板綍璇︾粏淇℃伅
      */
 //    @PreAuthorize("@ss.hasPermi('hosp:order:query')")
-    @GetMapping(value = "/{orderId}")
-    @ApiOperation(value = "鑾峰彇浣撴璁板綍璇︾粏淇℃伅")
-    public AjaxResult getInfo(@PathVariable("orderId") Long orderId) {
+    @GetMapping (value = "/{orderId}")
+    @ApiOperation (value = "鑾峰彇浣撴璁板綍璇︾粏淇℃伅")
+    public AjaxResult getInfo(@PathVariable ("orderId") Long orderId) {
         return success(tjOrderService.selectTjOrderByOrderId(orderId));
     }
 
 
-    @GetMapping("/getIsRequired")
-    @ApiOperation(value = "鏍规嵁鍙傛暟閰嶇疆鑾峰彇鏄惁蹇呭~椤癸紙韬唤璇併�佹�у埆銆佺數璇濄�佺収鐗囥�佹槸鍚︾洿鎺ヤ笅鍗曪級")
+    @GetMapping ("/getIsRequired")
+    @ApiOperation (value = "鏍规嵁鍙傛暟閰嶇疆鑾峰彇鏄惁蹇呭~椤癸紙韬唤璇併�佹�у埆銆佺數璇濄�佺収鐗囥�佹槸鍚︾洿鎺ヤ笅鍗曪級")
     public AjaxResult getIsRequired() {
         Map<String, String> res = new HashMap<>();
         res.put("has_idcard", configService.selectConfigByKey("has_idcard"));
@@ -813,7 +869,7 @@
      * 浣撴绛惧埌鐧昏鎺ュ彛
      */
     @PostMapping
-    @ApiOperation(value = "浣撴绛惧埌鐧昏鎺ュ彛")
+    @ApiOperation (value = "浣撴绛惧埌鐧昏鎺ュ彛")
     @Transactional  //(鍒囨崲鏁版嵁搴撳嚭閿欙紝鎵�浠ユ敞閲�)
     public AjaxResult addOrderAndDetail(@RequestBody TjOrder tjOrder) throws Exception {
         Long userId = Long.valueOf(SecurityUtils.getLoginUser().getUserId());
@@ -822,32 +878,34 @@
         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());
             return AjaxResult.error("涓嶅彲閲嶅鐧昏");
         }
+
+
         LambdaQueryWrapper<TjReservation> wq1 = new LambdaQueryWrapper<>();
         wq1.eq(TjReservation::getIdCard, tjCustomer.getCusIdcard());
         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("鏈埌棰勭害鏃堕棿");
-            }
-            if (DateUtil.endOfDay(tjReservation.getReservationTime()).before(new Date())) {
+//            if (DateUtil.endOfDay(new Date()).before(tjReservation.getReservationTime())) {
+//                return AjaxResult.error("鏈埌棰勭害鏃堕棿");
+//            }
+            if (DateUtil.endOfDay(DateUtil.offsetDay(tjReservation.getReservationTime(),tjReservation.getYxts())).before(new Date())) {
                 tjReservation.setIsExpire(1);
                 tjReservationService.updateById(tjReservation);
                 return AjaxResult.error("瀵逛笉璧锋偍鐨勯绾﹀凡瓒呮椂璇烽噸鏂伴绾�");
@@ -896,7 +954,13 @@
         if (null != mallOrder) tjOrder.setMallOrderId(String.valueOf(mallOrder.getId()));
         tjOrder.setStatus(TjConstants.TJ_BEGIN);
         tjOrder.setCardId(tjCustomer.getCardId());
+        if (null != tjOrder.getTjCategory() && tjOrder.getTjCategory().equals("13")) {
+            tjOrder.setFinishTime(new Date());
+            tjOrder.setCheckStatus(1);
+            tjOrder.setStatus(TjConstants.TJ_WAIT);
+        }
         if (tjOrderService.save(tjOrder)) {
+
             //淇濆瓨鏀惰揣鍦板潃
             if ("2".equals(tjOrder.getGetType())) {
                 final TjReportGetAddress address = tjOrder.getAddAddress();
@@ -908,7 +972,7 @@
             Long cusNumber = tjCustomer.getCusNumber();
             cusNumber += 1;
             tjCustomer.setCusNumber(cusNumber);
-            BigDecimal discount = BigDecimal.valueOf(Double.parseDouble(tjOrder.getTjFlowingWater().getDiscount())).divide(BigDecimal.valueOf(10));
+            BigDecimal discount = BigDecimal.valueOf(Double.parseDouble(tjOrder.getTjFlowingWater().getDiscount()));
             TjFlowingWater tjFlowingWater = new TjFlowingWater();
             tjFlowingWater.setPayStasus(0L);
             if ("1".equals(tjOrder.getTjType())) {
@@ -972,6 +1036,44 @@
 
             }
 
+            //淇敼姣忛」鐨勫師浠风幇浠� //淇敼涓存椂琛ㄤ綋妫�鍙�
+            transitionService.updateTbTransitionPriceByCusId(tjCustomer.getCusIdcard(), discount, tjOrder.getTjNumber());
+
+            /*璋冪敤his鎺ュ彛*/
+            String config = configService.selectConfigByKey("sfkqdyhis");
+            if (null != config && config.equals("Y")) {
+                AjaxResult result = hisApiMethod.HisApiMethods(tjCustomer,tjOrder);
+                if (!result.get("code").toString().equals("200")) {
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    Object jzh = result.get("jzh");
+                    if(null !=jzh && null !=jzh.toString()){
+                        hisApiMethod.ZfHisApiMethod(jzh.toString());
+                    }
+                    return AjaxResult.error("鎸傚彿澶辫触!" + result.get("msg").toString());
+                }
+
+                log.info("璇ョ櫥璁颁汉鐨刪is灏辫瘖鍙锋槸: "+tjOrder.getCardId());
+                //鍥綋
+                if ("1".equals(tjOrder.getTjType())) {
+                    asyncService.ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
+                }
+                //涓汉
+                if ("2".equals(tjOrder.getTjType())) {
+                    //asyncService.newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
+                    newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
+                }
+                hisApiMethod.tijianshenqing(tjCustomer,DateUtil.format(date1,"yyyy-MM-dd HH:mm:ss"),tjOrder.getCardId());
+
+                return AjaxResult.success(tjNumber);
+            } else {
+                tjCustomer.setCardId(tjOrder.getTjNumber());
+                tjCustomerService.updateById(tjCustomer);
+                transitionService.updateCardIdByTjNumAndIdCard(tjCustomer.getCusIdcard(), tjOrder.getTjNumber(), tjOrder.getTjNumber());
+                tjOrder.setCardId(tjOrder.getTjNumber());
+                tjOrderService.updateById(tjOrder);
+            }
+
+
             //鍥綋
             if ("1".equals(tjOrder.getTjType())) {
                 asyncService.ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
@@ -981,43 +1083,19 @@
                 //asyncService.newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                 newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
             }
-
-            //璋冪敤SQL server鎷垮彇鏀惰垂鎯呭喌
-            //鏍规嵁閰嶇疆璋冨彇瀛樺偍杩囩▼ 灏嗕复鏃惰〃鏁版嵁瀛樺叆棰勭害琛�2023.12.12
-//            final String getInfoFromSqlData = configService.selectConfigByKey("getInfoFromSqlData");
-//            if ("Y".equals(getInfoFromSqlData)){
-//                List<LtkjMiddleHead> one = testMapper.saveMiddleHeadByPatId(tjCustomer.getCusIdcard());
-//                if (one!=null){
-//                    for (LtkjMiddleHead ltkjMiddleHead : one) {
-//                        DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.MASTER.name());
-//                        headService.save(ltkjMiddleHead);
-//                        DynamicDataSourceContextHolder.clearDataSourceType();
-//                        List<LtkjMiddleDetail> detailList = testMapper.getMiddleDetailByHeadId(ltkjMiddleHead.getFeadId());
-//                        if (detailList!=null){
-//                            for (LtkjMiddleDetail ltkjMiddleDetail : detailList) {
-//                                DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.MASTER.name());
-//                                middleDetailService.save(ltkjMiddleDetail);
-//                                DynamicDataSourceContextHolder.clearDataSourceType();
-//                            }
-//                        }
-//                    }
-//
-//                }
-//            }
-            tjCustomer.setCardId("0");
-            tjCustomerService.updateById(tjCustomer);
             return AjaxResult.success(tjNumber);
         }
         return AjaxResult.error();
     }
 
 
-    @PostMapping("/addPlOrderAndDetail")
-    @ApiOperation(value = "浣撴鎵归噺绛惧埌鐧昏鎺ュ彛")
+    @PostMapping ("/addPlOrderAndDetail")
+    @ApiOperation (value = "浣撴鎵归噺绛惧埌鐧昏鎺ュ彛")
     @Transactional  //(鍒囨崲鏁版嵁搴撳嚭閿欙紝鎵�浠ユ敞閲�)
-    public AjaxResult addPlOrderAndDetail(@RequestBody QianDaoDto daoDto) {
+    public AjaxResult addPlOrderAndDetail(@RequestBody QianDaoDto daoDto, HttpServletResponse response) {
         SysUser sysUser = UserHoder.getLoginUser().getUser();
         List<String> cusIds = daoDto.getCusIds();
+        ArrayList<String> tjNumbers = new ArrayList<>();
         if (null != cusIds && cusIds.size() > 0) {
             ExecutorService threadPools = Executors.newFixedThreadPool(cusIds.size());
             for (String cusId : cusIds) {
@@ -1032,21 +1110,78 @@
             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() {
+//                    threadPool.execute(new Runnable() {
+//                        @Override
+//                        public void run() {
+//                            try {
+//                                AjaxResult result = getAjaxResult(aLong, sysUser, daoDto.getTjCategory());
+//                                threadPool.shutdown();
+//                            } catch (IOException e) {
+//                                e.printStackTrace();
+//                            }
+//                        }
+//                    });
+                    Future<AjaxResult> future = executor.submit(new Callable<AjaxResult>() {
                         @Override
-                        public void run() {
-                            try {
-                                getAjaxResult(aLong, sysUser, daoDto.getTjCategory());
-                                threadPool.shutdown();
-                            } catch (IOException e) {
-                                e.printStackTrace();
-                            }
+                        public AjaxResult call() throws Exception {
+                            return getAjaxResult(aLong, sysUser, daoDto.getTjCategory());
                         }
                     });
+                    try {
+                        AjaxResult result = future.get();
+                        String tjNumber = result.get("tjNumber").toString();
+                        tjNumbers.add(tjNumber);
+                    } catch (InterruptedException | ExecutionException e) {
+                        e.printStackTrace();
+                    }
+                }
+                threadPools.shutdown();
+            }
+        }
+        // TODO 鍥犱负鏈変綋妫�鍙蜂細鏌ュ嚭绌烘暟鎹� 鍏堜娇鐢ㄦ鏁版嵁
+        tjNumbers = new ArrayList<>();
+        tjNumbers.add("02095240229171627");
+        tjNumbers.add("02095240229173104");
+        tjNumbers.add("10001240524172002");
+        tjNumbers.add("10001240304124410");
+        tjNumbers.add("00325240304160123");
+        tjNumbers.add("02095240304162044");
+        tjNumbers.add("02095240304162152");
+        tjNumbers.add("10001240304163505");
+        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));
+                    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.success("鎿嶄綔鎴愬姛");
     }
@@ -1241,108 +1376,110 @@
             tjReservation.setIsExpire(1);
             tjReservationService.updateById(tjReservation);
 
-        //鐢熸垚浣撴鍙�
-        String tjNumber = (sysUser.getUserName() + new SimpleDateFormat("yyMMddHHmmss").format(new Date()));
+            //鐢熸垚浣撴鍙�
+            String tjNumber = (sysUser.getUserName() + new SimpleDateFormat("yyMMddHHmmss").format(new Date()));
 
-        tjNumber = tjNumber.replaceAll(".{4}$", userId.toString().substring(userId.toString().length() - 4));
+            tjNumber = tjNumber.replaceAll(".{4}$", userId.toString().substring(userId.toString().length() - 4));
 
-        tjOrder.setTjNumber(tjNumber);
-        if (null != tjOrder.getPhoto()) {
-            File file = new File(tjOrder.getPhoto());
-            if (file.isFile()) {
-                FileInputStream fileInputStream = new FileInputStream(file);
-                byte[] bytes = new byte[fileInputStream.available()];
-                fileInputStream.read(bytes); // 璇诲彇鍒� byte 閲岄潰
-                fileInputStream.close();
-                // 寰楀埌鏂囦欢 涔嬪悗杞垚beye 鐒跺悗浣跨敤base64杞爜
-                String encode = Base64.encode(bytes);
-                tjOrder.setPhoto(encode);
-            }
-        }
-        if (tjOrder.getFirmId() == null) {
-            tjOrder.setFirmId("0");
-        }
-        if (null == tjOrder.getPacId() && null != transitionService.getTbTransitionPacIdByCusIdAndPac(String.valueOf(tjOrder.getUserId()))) {
-            tjOrder.setPacId(transitionService.getTbTransitionPacIdByCusIdAndPac(String.valueOf(tjOrder.getUserId())));
-        }
-        //鍒ゆ柇灏忕▼搴忎笂棰勭害鏄惁浠橀挶
-        if (null != mallOrder) tjOrder.setMallOrderId(String.valueOf(mallOrder.getId()));
-        tjOrder.setStatus(TjConstants.TJ_BEGIN);
-        tjOrder.setCardId(tjCustomer.getCardId());
-        tjOrder.setTjType("1");
-        if (tjOrderService.save(tjOrder)) {
-            //淇濆瓨鏀惰揣鍦板潃
-            if ("2".equals(tjOrder.getGetType())) {
-                final TjReportGetAddress address = tjOrder.getAddAddress();
-                if (address != null) {
-                    address.setTjNumber(tjNumber);
-                    tjReportGetAddressService.save(address);
+            tjOrder.setTjNumber(tjNumber);
+            if (null != tjOrder.getPhoto()) {
+                File file = new File(tjOrder.getPhoto());
+                if (file.isFile()) {
+                    FileInputStream fileInputStream = new FileInputStream(file);
+                    byte[] bytes = new byte[fileInputStream.available()];
+                    fileInputStream.read(bytes); // 璇诲彇鍒� byte 閲岄潰
+                    fileInputStream.close();
+                    // 寰楀埌鏂囦欢 涔嬪悗杞垚beye 鐒跺悗浣跨敤base64杞爜
+                    String encode = Base64.encode(bytes);
+                    tjOrder.setPhoto(encode);
                 }
             }
-            Long cusNumber = tjCustomer.getCusNumber();
-            cusNumber += 1;
-            tjCustomer.setCusNumber(cusNumber);
-//            BigDecimal discount = BigDecimal.valueOf(Double.parseDouble(tjOrder.getTjFlowingWater().getDiscount())).divide(BigDecimal.valueOf(10));
-            TjFlowingWater tjFlowingWater = new TjFlowingWater();
-            tjFlowingWater.setPayStasus(0L);
-            if ("1".equals(tjOrder.getTjType())) {
-                if (tjReservation.getPayType() == 1) {
-                    tjFlowingWater.setPayStasus(3L);
-                }
+            if (tjOrder.getFirmId() == null) {
+                tjOrder.setFirmId("0");
             }
-
-            //璋冪敤SQL server鎷垮彇鏀惰垂鎯呭喌
-            //鏍规嵁閰嶇疆璋冨彇瀛樺偍杩囩▼ 灏嗕复鏃惰〃鏁版嵁瀛樺叆棰勭害琛�2023.12.12
-            String getInfoFromSqlData = configService.selectConfigByKey("getInfoFromSqlData");
-            String isPay = configService.selectConfigByKey("isPay");
-            if ("Y".equals(getInfoFromSqlData)) {
-                LtkjMiddleHead middleHead = headService.getMiddleHeadByPartId(tjCustomer.getCardId());
-                if (null != middleHead) {
-                    tjFlowingWater.setPayStasus(1L);
-                }
+            if (null == tjOrder.getPacId() && null != transitionService.getTbTransitionPacIdByCusIdAndPac(String.valueOf(tjOrder.getUserId()))) {
+                tjOrder.setPacId(transitionService.getTbTransitionPacIdByCusIdAndPac(String.valueOf(tjOrder.getUserId())));
             }
-            tjFlowingWater.setOrderId(tjOrder.getOrderId());
-            Date date1 = new Date(System.currentTimeMillis());
-            String s1 = sysUser.getUserName() + new SimpleDateFormat("yyMMddHHmmssSSS").format(date1);
-            tjFlowingWater.setWaterId(PinyinUtil.getFirstLetter(tjCustomer.getCusName(), "").toUpperCase() + s1);
+            //鍒ゆ柇灏忕▼搴忎笂棰勭害鏄惁浠橀挶
+            if (null != mallOrder) tjOrder.setMallOrderId(String.valueOf(mallOrder.getId()));
+            tjOrder.setStatus(TjConstants.TJ_BEGIN);
+            tjOrder.setCardId(tjCustomer.getCardId());
+            tjOrder.setTjType("1");
 
-            if (isPay.equals("true")) {
-                if (null != mallOrder) {
-                    if (mallOrder.getOrderStatus().equals(201L)) {
-                        tjFlowingWater.setCopeWith(mallOrder.getActualPrice());
-                        tjFlowingWater.setPaidIn(mallOrder.getActualPrice());
-                        tjFlowingWater.setDiscount(String.valueOf(1));
-                        tjFlowingWater.setPayStasus(1L);
-                        tjFlowingWater.setPayType(3L);
-                        MallCheckLog checkLog = new MallCheckLog();
-                        checkLog.setCheckBy(sysUser.getNickName());
-                        checkLog.setUserId(mallOrder.getUserId());
-                        checkLog.setConsignee(mallOrder.getConsignee());
-                        checkLog.setIdCard(mallOrder.getIdCard());
-                        checkLog.setOrderId(String.valueOf(mallOrder.getId()));
-                        checkLog.setOrderSn(mallOrder.getOrderSn());
-                        checkLog.setCheckTime(new Date());
-                        checkLog.setShipSn("HX" + s1);
-                        mallCheckLogService.save(checkLog);
-                        mallOrder.setOrderStatus(301L);
-                        mallOrderService.updateById(mallOrder);
+            if (tjOrderService.save(tjOrder)) {
+
+                //淇濆瓨鏀惰揣鍦板潃
+                if ("2".equals(tjOrder.getGetType())) {
+                    final TjReportGetAddress address = tjOrder.getAddAddress();
+                    if (address != null) {
+                        address.setTjNumber(tjNumber);
+                        tjReportGetAddressService.save(address);
                     }
                 }
+                Long cusNumber = tjCustomer.getCusNumber();
+                cusNumber += 1;
+                tjCustomer.setCusNumber(cusNumber);
+//            BigDecimal discount = BigDecimal.valueOf(Double.parseDouble(tjOrder.getTjFlowingWater().getDiscount())).divide(BigDecimal.valueOf(10));
+                TjFlowingWater tjFlowingWater = new TjFlowingWater();
+                tjFlowingWater.setPayStasus(0L);
+                if ("1".equals(tjOrder.getTjType())) {
+                    if (tjReservation.getPayType() == 1) {
+                        tjFlowingWater.setPayStasus(3L);
+                    }
+                }
+
+                //璋冪敤SQL server鎷垮彇鏀惰垂鎯呭喌
+                //鏍规嵁閰嶇疆璋冨彇瀛樺偍杩囩▼ 灏嗕复鏃惰〃鏁版嵁瀛樺叆棰勭害琛�2023.12.12
+                String getInfoFromSqlData = configService.selectConfigByKey("getInfoFromSqlData");
+                String isPay = configService.selectConfigByKey("isPay");
+                if ("Y".equals(getInfoFromSqlData)) {
+                    LtkjMiddleHead middleHead = headService.getMiddleHeadByPartId(tjCustomer.getCardId());
+                    if (null != middleHead) {
+                        tjFlowingWater.setPayStasus(1L);
+                    }
+                }
+                tjFlowingWater.setOrderId(tjOrder.getOrderId());
+                Date date1 = new Date(System.currentTimeMillis());
+                String s1 = sysUser.getUserName() + new SimpleDateFormat("yyMMddHHmmssSSS").format(date1);
+                tjFlowingWater.setWaterId(PinyinUtil.getFirstLetter(tjCustomer.getCusName(), "").toUpperCase() + s1);
+
+                if (isPay.equals("true")) {
+                    if (null != mallOrder) {
+                        if (mallOrder.getOrderStatus().equals(201L)) {
+                            tjFlowingWater.setCopeWith(mallOrder.getActualPrice());
+                            tjFlowingWater.setPaidIn(mallOrder.getActualPrice());
+                            tjFlowingWater.setDiscount(String.valueOf(1));
+                            tjFlowingWater.setPayStasus(1L);
+                            tjFlowingWater.setPayType(3L);
+                            MallCheckLog checkLog = new MallCheckLog();
+                            checkLog.setCheckBy(sysUser.getNickName());
+                            checkLog.setUserId(mallOrder.getUserId());
+                            checkLog.setConsignee(mallOrder.getConsignee());
+                            checkLog.setIdCard(mallOrder.getIdCard());
+                            checkLog.setOrderId(String.valueOf(mallOrder.getId()));
+                            checkLog.setOrderSn(mallOrder.getOrderSn());
+                            checkLog.setCheckTime(new Date());
+                            checkLog.setShipSn("HX" + s1);
+                            mallCheckLogService.save(checkLog);
+                            mallOrder.setOrderStatus(301L);
+                            mallOrderService.updateById(mallOrder);
+                        }
+                    }
+                }
+                if (tjFlowingWaterService.save(tjFlowingWater)) {
+                    tjOrder.setTjSerialNumber(String.valueOf(tjFlowingWater.getTjSerialNumber()));
+                    tjOrderService.updateById(tjOrder);
+
+
+                }
+                asyncService.ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
+
+
+                tjCustomer.setCardId("0");
+                tjCustomerService.updateById(tjCustomer);
+                return AjaxResult.success().put("tjNumber", tjNumber);
             }
-            if (tjFlowingWaterService.save(tjFlowingWater)) {
-                tjOrder.setTjSerialNumber(String.valueOf(tjFlowingWater.getTjSerialNumber()));
-                tjOrderService.updateById(tjOrder);
-
-
-            }
-            asyncService.ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
-
-
-            tjCustomer.setCardId("0");
-            tjCustomerService.updateById(tjCustomer);
-            return AjaxResult.success(tjNumber);
         }
-      }
         return AjaxResult.error();
     }
 
@@ -1351,9 +1488,9 @@
      * 淇敼浣撴璁板綍
      */
 //    @PreAuthorize("@ss.hasPermi('hosp:order:edit')")
-    @Log(title = "浣撴璁板綍", businessType = BusinessType.UPDATE)
+    @Log (title = "浣撴璁板綍", businessType = BusinessType.UPDATE)
     @PutMapping
-    @ApiOperation(value = "淇敼浣撴璁板綍")
+    @ApiOperation (value = "淇敼浣撴璁板綍")
     public AjaxResult edit(@RequestBody TjOrder tjOrder) {
         return toAjax(tjOrderService.updateTjOrder(tjOrder));
     }
@@ -1362,16 +1499,16 @@
      * 鍒犻櫎浣撴璁板綍
      */
 //    @PreAuthorize("@ss.hasPermi('hosp:order:remove')")
-    @Log(title = "浣撴璁板綍", businessType = BusinessType.DELETE)
-    @DeleteMapping("/{orderIds}")
-    @ApiOperation(value = "鍒犻櫎浣撴璁板綍")
+    @Log (title = "浣撴璁板綍", businessType = BusinessType.DELETE)
+    @DeleteMapping ("/{orderIds}")
+    @ApiOperation (value = "鍒犻櫎浣撴璁板綍")
     public AjaxResult remove(@PathVariable Long[] orderIds) {
         return toAjax(tjOrderService.deleteTjOrderByOrderIds(orderIds));
     }
 
-    @GetMapping("/getOrderDetailByTjNumber")
-    @ApiOperation(value = "鏍规嵁浣撴鍙疯幏鍙栦綋妫�璇︽儏")
-    public AjaxResult getOrderDetailByTjNumber(@RequestParam @ApiParam(value = "浣撴鍙�") String tjNumber) {
+    @GetMapping ("/getOrderDetailByTjNumber")
+    @ApiOperation (value = "鏍规嵁浣撴鍙疯幏鍙栦綋妫�璇︽儏")
+    public AjaxResult getOrderDetailByTjNumber(@RequestParam @ApiParam (value = "浣撴鍙�") String tjNumber) {
         LambdaQueryWrapper<TjOrder> wq0 = new LambdaQueryWrapper<>();
         wq0.eq(TjOrder::getTjNumber, tjNumber);
         TjOrder tjOrder = tjOrderService.getOne(wq0);
@@ -1391,8 +1528,8 @@
         return AjaxResult.success("鏆傛棤鏁版嵁");
     }
 
-    @PostMapping("/addtTransition")
-    @ApiOperation(value = "娣诲姞杩囨浮琛ㄦ暟鎹�")
+    @PostMapping ("/addtTransition")
+    @ApiOperation (value = "娣诲姞杩囨浮琛ㄦ暟鎹�")
     @Transactional
     public AjaxResult addtTransition(@RequestBody Map<String, Object> map) {
         Object packId = map.get("pacId");
@@ -1417,136 +1554,39 @@
                 redisCache.deleteCacheMapValue(cardId + cusId + "cusId", cardId + cusId);
             }
         }
-        List<TbTransition> tbTransitionList = null;
-        if (!redisCache.hasKey(cardId + cusId)) {
-            tbTransitionList = new ArrayList<>();
-        } else {
-            tbTransitionList = redisCache.getCacheList(cardId + cusId);
-        }
-        //濂楅
+        /*濂楅*/
         if (null != packId && !packId.equals("")) {
             Long pacId = Long.valueOf(packId.toString());
             List<TbTransition> list = transitionService.getTbTransitionListByCusIdAndPac(cusId, String.valueOf(pacId));
-            if (null == list || list.size() == 0) {
+            if (null == list || list.isEmpty()) {
                 transitionService.deletedTbTransitionListByCusIdAndPac(cusId, cardId);
-                if (redisCache.hasKey(cardId + cusId + "cusId"))
-                    redisCache.deleteCacheMapValue(cardId + cusId + "cusId", cardId + cusId);
-                if (redisCache.hasKey(cardId + cusId)) {
-                    tbTransitionList = new ArrayList<>();
-                    redisCache.deleteObject(cardId + cusId);
-                }
                 List<TjPackageProject> ppList = tjPackageProjectService.getTjPackageProjectListByPacId(String.valueOf(pacId));
-                if (null != ppList && ppList.size() > 0) {
-                    //寮傛淇濆瓨鏁版嵁搴�
-//                    asyncService.addRedisTransitionPac(cusId, pacId, ppList);
-                    asyncService.saveRedisTransitionByPacId(cusId, pacId, null);
-                    for (TjPackageProject tjPackageProject : ppList) {
-                        TjProject project = projectService.getTjProjectById(String.valueOf(tjPackageProject.getProId()));
-                        if (null != project) {
-
-                            BigDecimal divide = BigDecimal.valueOf(0);
-                            if (tjPackageProject.getPriceNow().compareTo(BigDecimal.valueOf(0)) == 0 || project.getProPrice().compareTo(BigDecimal.valueOf(0)) == 0) {
-                                divide = BigDecimal.valueOf(0);
-                            } else {
-                                divide = tjPackageProject.getPriceNow().divide(project.getProPrice(), 5, RoundingMode.HALF_DOWN);
-                            }
-                            List<TjProject> tjProSonList = projectService.getTjProjectListBySoneId(String.valueOf(project.getProId()));
-                            if (null != tjProSonList && tjProSonList.size() > 0) {
-                                //addRedisTransitionPac(cusId, tbTransitionList, pacId, tjPackageProject, project, divide, tjProSonList);
-                                for (TjProject tjProject : tjProSonList) {
-                                    TbTransition tbTransition = new TbTransition();
-                                    tbTransition.setCusId(cusId);
-                                    tbTransition.setPacId(pacId);
-                                    if (null != tjPackageProject.getPriceNow() && divide.compareTo(BigDecimal.valueOf(0)) > 0) {
-                                        tbTransition.setNowPrice(tjProject.getProPrice().multiply(divide).setScale(2, RoundingMode.HALF_DOWN));
-                                        tbTransition.setOrdPrice(tjProject.getProPrice().multiply(divide).setScale(2, RoundingMode.HALF_DOWN));
-                                    } else {
-                                        tbTransition.setNowPrice(BigDecimal.valueOf(0.00));
-                                        tbTransition.setOrdPrice(BigDecimal.valueOf(0.00));
-                                    }
-                                    tbTransition.setParentProId(project.getProId());
-                                    tbTransition.setParentProName(project.getProName());
-                                    tbTransition.setProId(tjProject.getProId());
-                                    tbTransition.setProName(tjProject.getProName());
-                                    tbTransition.setPacName(tjPackageService.getById(tbTransition.getPacId()).getPacName());
-                                    tbTransition.setProType(tjProject.getProType());
-                                    tbTransition.setProCheckMethod(tjProject.getProCheckMethod());
-                                    tbTransitionList.add(tbTransition);
-                                }
-
-                            }
-                        }
-                    }
+                if (null != ppList && !ppList.isEmpty()) {
+                    transitionService.saveRedisTransitionByPacId(cusId, cardId, pacId);
                 }
             }
         }
 
         //鍗曢」
-        if (null != proIds && proIds.size() > 0) {
+        if (null != proIds && !proIds.isEmpty()) {
             //寮傛淇濆瓨鏁版嵁搴撹〃
-            asyncService.saveRedisTransitionByPacId(cusId, null, proIds);
             for (Long proId : proIds) {
-                List<TbTransition> transitions = transitionService.getTbTransitionListByCusIdAndPacIdAndProId(cusId, String.valueOf(proId));
-                if (null != transitions && transitions.size() > 0) {
-                    continue;
-                }
-                TjProject tjProject = projectService.getTjProjectById(String.valueOf(proId));
-                if (null != tjProject) {
-//                    List<TjProject> tjProSonList = projectService.getTjProjectListBySoneId(String.valueOf(project.getProId()));
-//                    if (null != tjProSonList && tjProSonList.size() > 0) {
-//                        for (TjProject tjProject : tjProSonList) {
-//                    List<TbTransition> transitionss = transitionService.getTbTransitionListByCusIdAndPacIdAndProId(cusId, String.valueOf(tjProject.getProId()));
-//                    if (null != transitionss && transitionss.size() > 0) {
-//                        continue;
-//                    }
-                    TbTransition tbTransition = new TbTransition();
-                    tbTransition.setCusId(cusId);
-                    tbTransition.setPacId(null);
-                    if (null != tjProject.getProPrice()) {
-                        tbTransition.setOrdPrice(tjProject.getProPrice());
-                        tbTransition.setNowPrice(tjProject.getProPrice());
-                    } else {
-                        tbTransition.setOrdPrice(BigDecimal.valueOf(0.00));
-                        tbTransition.setNowPrice(BigDecimal.valueOf(0.00));
+                TjProject project = projectService.selectTjProjectByProId(proId);
+                if (null != project) {
+                    List<TbTransition> transitionList = transitionService.getTbTransitionListByCusIdAndPacIdAndProId(cusId, String.valueOf(proId));
+                    if (null == transitionList || transitionList.isEmpty()) {
+                        transitionService.saveRedisTransitionByProId(cusId, cardId, proId);
                     }
-                    tbTransition.setParentProId(tjProject.getProParentId());
-                    if (tjProject.getProParentId() != null) {
-                        TjProject byId = projectService.getById(tjProject.getProParentId());
-                        if (null != byId) {
-                            tbTransition.setParentProName(byId.getProName());
-                        }
-                    }
-                    tbTransition.setParentProName("");
-
-                    tbTransition.setProId(tjProject.getProId());
-                    tbTransition.setProName(tjProject.getProName());
-                    tbTransition.setProType(tjProject.getProType());
-                    tbTransition.setProCheckMethod(tjProject.getProCheckMethod());
-                    tbTransitionList.add(tbTransition);
-//                        }
-//                    }
                 }
-            }
-        }
-
-
-        if (null != tbTransitionList && tbTransitionList.size() > 0) {
-            if (redisCache.hasKey(cardId + cusId)) {
-                redisCache.deleteObject(cardId + cusId);
-                redisCache.setCacheList(cardId + cusId, tbTransitionList);
-                redisCache.setCacheMapValue(cardId + cusId + "cusId", cardId + cusId, getMaps(cusId, cardId));
-            } else {
-                redisCache.setCacheList(cardId + cusId, tbTransitionList);
-                redisCache.setCacheMapValue(cardId + cusId + "cusId", cardId + cusId, getMaps(cusId, cardId));
             }
         }
         return AjaxResult.success();
     }
 
 
-    @GetMapping("/getTransitionList")
-    @ApiOperation(value = "鏌ヨ杩囨浮琛ㄦ暟鎹�")
-    public AjaxResult getTransitionList(@RequestParam @ApiParam(value = "瀹㈡埛id") String cusId) {
+    @GetMapping ("/getTransitionList")
+    @ApiOperation (value = "鏌ヨ杩囨浮琛ㄦ暟鎹�")
+    public AjaxResult getTransitionList(@RequestParam @ApiParam (value = "瀹㈡埛id") String cusId) {
         if (redisCache.hasKey(cusId + "cusId")) {
             List<Map<String, Object>> list = redisCache.getCacheMapValue(cusId + "cusId", cusId);
             return AjaxResult.success(list);
@@ -1561,16 +1601,16 @@
     }
 
 
-    @GetMapping("/getQianLiList")
-    @ApiOperation(value = "鏌ヨ浣撴璁板綍鍒楄〃")
-    public AjaxResult getQianLiList(@ApiParam(value = "椤电爜鏁�(榛樿1)") @RequestParam(defaultValue = "1") Integer pageNum,
-                                    @ApiParam(value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam(defaultValue = "10") Integer pageSize,
-                                    @ApiParam(value = "浣撴鍙�") @RequestParam(required = false) String tjNum,
-                                    @ApiParam(value = "濮撳悕") @RequestParam(required = false) String name,
-                                    @ApiParam(value = "鐧昏寮�濮嬫椂闂�") @RequestParam(required = false) Date djbeginTime,
-                                    @ApiParam(value = "鐧昏缁撴潫鏃堕棿") @RequestParam(required = false) Date djendTime,
-                                    @ApiParam(value = "鎶ュ憡寮�濮嬫椂闂�") @RequestParam(required = false) Date bgbeginTime,
-                                    @ApiParam(value = "鎶ュ憡缁撴潫鏃堕棿") @RequestParam(required = false) Date bgendTime) {
+    @GetMapping ("/getQianLiList")
+    @ApiOperation (value = "鏌ヨ浣撴璁板綍鍒楄〃")
+    public AjaxResult getQianLiList(@ApiParam (value = "椤电爜鏁�(榛樿1)") @RequestParam (defaultValue = "1") Integer pageNum,
+                                    @ApiParam (value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam (defaultValue = "10") Integer pageSize,
+                                    @ApiParam (value = "浣撴鍙�") @RequestParam (required = false) String tjNum,
+                                    @ApiParam (value = "濮撳悕") @RequestParam (required = false) String name,
+                                    @ApiParam (value = "鐧昏寮�濮嬫椂闂�") @RequestParam (required = false) Date djbeginTime,
+                                    @ApiParam (value = "鐧昏缁撴潫鏃堕棿") @RequestParam (required = false) Date djendTime,
+                                    @ApiParam (value = "鎶ュ憡寮�濮嬫椂闂�") @RequestParam (required = false) Date bgbeginTime,
+                                    @ApiParam (value = "鎶ュ憡缁撴潫鏃堕棿") @RequestParam (required = false) Date bgendTime) {
         Map<String, Object> map = new HashMap<>();
         if (null != name) {
             LambdaQueryWrapper<TjCustomer> wqq = new LambdaQueryWrapper<>();
@@ -1592,7 +1632,7 @@
                     for (TjOrder order : list) {
                         TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId());
                         if (null != tjCustomer) {
-                            order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
+                            order.setTjCustomerName(tjCustomer.getCusName());
                             order.setTjCustomerSex(tjCustomer.getCusSex());
                             order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
                             order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
@@ -1646,7 +1686,7 @@
             for (TjOrder order : list) {
                 TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId());
                 if (null != tjCustomer) {
-                    order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
+                    order.setTjCustomerName(tjCustomer.getCusName());
                     order.setTjCustomerSex(tjCustomer.getCusSex());
                     order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
                     order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
@@ -1679,9 +1719,9 @@
     /**
      * 绛剧寮冩纭杩斿洖鏁版嵁
      */
-    @GetMapping("/abandon")
-    @ApiOperation(value = "绛剧寮冩纭杩斿洖鏁版嵁")
-    public AjaxResult abandon(@RequestParam @ApiParam(value = "浣撴鍙�") String tjNumber) {
+    @GetMapping ("/abandon")
+    @ApiOperation (value = "绛剧寮冩纭杩斿洖鏁版嵁")
+    public AjaxResult abandon(@RequestParam @ApiParam (value = "浣撴鍙�") String tjNumber) {
         LambdaQueryWrapper<TjOrderRemark> wq = new LambdaQueryWrapper<>();
         wq.eq(TjOrderRemark::getTjNumber, tjNumber);
         List<TjOrderRemark> remarkList = remarkService.list(wq);
@@ -1706,8 +1746,9 @@
      *
      * @ApiParam(value = "浣撴鍙�") String tjNumber
      */
-    @PostMapping("/tjGoOut")
-    @ApiOperation(value = "浣撴绛剧")
+    @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);
@@ -1715,6 +1756,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) {
@@ -1728,7 +1770,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);
@@ -1738,6 +1779,40 @@
                 }
             }
             asyncService.tjGoutAsync(domainVos, sysUser, list);
+
+            TjCustomer customer = tjCustomerService.selectTjCustomerByCusId(tjOrder.getUserId());
+            customer.setCardId("0");
+            tjCustomerService.updateById(customer);
+          /*  String config = configService.selectConfigByKey("sfkqdyhis");
+            if(null !=config && config.equals("Y")){
+                final String date = DateUtil.format(tjOrder.getCreateTime(), "yyyy-MM-dd HH:mm:ss");
+                OutpinimpapplyDto dto=new OutpinimpapplyDto();
+                dto.setHisRegistrationId(tjOrder.getCardId());
+                dto.setMzzdid(1);
+                dto.setSqysbm("00029");
+                dto.setMzksbm("0101");
+                dto.setFbrq(date);
+                dto.setZdrq(date);
+                dto.setCzybm("00029");
+                dto.setCzyksbm("0101");
+                dto.setZs("鍋ュ悍鏌ヤ綋");
+                dto.setBs("涓嶈");
+                dto.setClyz("");
+                dto.setJws("");
+                dto.setTgjc("");
+                dto.setGms("");
+                dto.setJbbm("Z00.001");
+                dto.setJbbm1("");
+                dto.setJbbm2("");
+                dto.setFzbz("1");
+                dto.setHzqx("6");
+                dto.setSfqc("0");
+                dto.setQchs("");
+                dto.setSfqj("0");
+                dto.setJzqk(9);
+                controller.Outpinimpapply(dto);
+            }*/
+
             return AjaxResult.success("绛剧鎴愬姛锛�");
         } else {
             return getAjaxResult(tjNumber);
@@ -1748,9 +1823,10 @@
     /**
      * 绛剧
      */
-    @GetMapping("/goOut")
-    @ApiOperation(value = "绛剧")
-    public AjaxResult goOut(@RequestParam @ApiParam(value = "浣撴鍙�") String tjNumber) {
+    @GetMapping ("/goOut")
+    @ApiOperation (value = "绛剧")
+    @Transactional
+    public AjaxResult goOut(@RequestParam @ApiParam (value = "浣撴鍙�") String tjNumber) {
         return getAjaxResult(tjNumber);
     }
 
@@ -1758,9 +1834,9 @@
     /**
      * 鏍搁攢璁㈠崟鎺ュ彛
      */
-    @GetMapping("/orderShip")
-    @ApiOperation(value = "PC绔墜鍔ㄦ牳閿�璁㈠崟鎺ュ彛")
-    public AjaxResult orderShip(@RequestParam @ApiParam(value = "浣撴鍙�") String tjNum) {
+    @GetMapping ("/orderShip")
+    @ApiOperation (value = "PC绔墜鍔ㄦ牳閿�璁㈠崟鎺ュ彛")
+    public AjaxResult orderShip(@RequestParam @ApiParam (value = "浣撴鍙�") String tjNum) {
         if (tjNum == null) {
             return AjaxResult.error();
         }
@@ -1808,8 +1884,10 @@
         for (Map.Entry<Long, List<TbTransition>> entry : collect.entrySet()) {
             Map<String, Object> map = new HashMap<>();
             Long pacId = entry.getValue().get(0).getPacId();
+            map.put("proPrantId", entry.getKey().toString());
             if (null != pacId) {
                 TjPackage aPackage = tjPackageService.getById(entry.getValue().get(0).getPacId());
+                map.put("tjCategory", aPackage.getTjCategory());
                 map.put("pacName", aPackage.getPacName());
                 TjProject tjProject = projectService.getById(entry.getKey());
 //                TjPackageProject project = tjPackageProjectService.getOne(new LambdaQueryWrapper<TjPackageProject>().eq(TjPackageProject::getPacId, pacId)
@@ -1822,6 +1900,59 @@
 //                }
                 map.put("nowPrice", transitionService.getTbTransitionDxPriceByPac(cusId, entry.getKey(), cardId, pacId));
             } else {
+                map.put("tjCategory", null);
+                map.put("pacName", "鍗曢」");
+                List<TbTransition> tbTransitionList = entry.getValue();
+                if (null != tbTransitionList && tbTransitionList.size() > 0) {
+                    BigDecimal money1 = new BigDecimal("0.00");
+                    BigDecimal money2 = new BigDecimal("0.00");
+                    for (TbTransition tbTransition : tbTransitionList) {
+                        money1 = money1.add(tbTransition.getOrdPrice());
+                        money2 = money2.add(tbTransition.getNowPrice());
+                    }
+                    map.put("ordPrice", money1);
+                    map.put("nowPrice", money2);
+                }
+            }
+            map.put("parentName", projectService.getById(entry.getKey()).getProName());
+            map.put("list", entry.getValue());
+            list.add(map);
+        }
+        return list;
+    }
+
+
+    private List<Map<String, Object>> getMap(String cusId, String cardId, List<TbTransition> transitionList) {
+
+//        List<TbTransition> transitionList = null;
+//        if (redisCache.hasKey(cardId + cusId)) {
+//            transitionList = redisCache.getCacheList(cardId + cusId);
+//        } else {
+//        transitionList = transitionService.getTbTransitionListByCusId(cusId, cardId);
+//        }
+        if (null == transitionList) return null;
+        Map<Long, List<TbTransition>> collect = transitionList.stream().collect(Collectors.groupingBy(TbTransition::getParentProId));
+        List<Map<String, Object>> list = new ArrayList<>();
+        for (Map.Entry<Long, List<TbTransition>> entry : collect.entrySet()) {
+            Map<String, Object> map = new HashMap<>();
+            Long pacId = entry.getValue().get(0).getPacId();
+            map.put("proPrantId", entry.getKey().toString());
+            if (null != pacId) {
+                TjPackage aPackage = tjPackageService.getById(entry.getValue().get(0).getPacId());
+                map.put("tjCategory", aPackage.getTjCategory());
+                map.put("pacName", aPackage.getPacName());
+                TjProject tjProject = projectService.getById(entry.getKey());
+//                TjPackageProject project = tjPackageProjectService.getOne(new LambdaQueryWrapper<TjPackageProject>().eq(TjPackageProject::getPacId, pacId)
+//                        .eq(TjPackageProject::getProId, entry.getKey()));
+                map.put("ordPrice", tjProject.getProPrice());
+//                if (null != project) {
+//                    map.put("nowPrice", project.getPriceNow());
+//                } else {
+//                    map.put("nowPrice", tjProject.getProPrice());
+//                }
+                map.put("nowPrice", tjProject.getProPrice());
+            } else {
+                map.put("tjCategory", null);
                 map.put("pacName", "鍗曢」");
                 List<TbTransition> tbTransitionList = entry.getValue();
                 if (null != tbTransitionList && tbTransitionList.size() > 0) {
@@ -1846,13 +1977,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);
@@ -1868,15 +2003,15 @@
     }
 
 
-    @GetMapping("/tuanTiListById")
-    @ApiOperation(value = "鏌ヨ鍥綋浣撴鐘舵��")
-    public AjaxResult tuanTiListById(@ApiParam(value = "椤电爜鏁�(榛樿1)") @RequestParam(defaultValue = "1") Integer pageNum,
-                                     @ApiParam(value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam(defaultValue = "10") Integer pageSize,
-                                     @ApiParam(value = "鍗曚綅") @RequestParam String firmId,
-                                     @ApiParam(value = "閮ㄩ棬") @RequestParam(required = false) String dwDeptId,
-                                     @ApiParam(value = "鍒嗙粍") @RequestParam(required = false) String groupId,
-                                     @ApiParam(value = "鐧昏寮�濮嬫椂闂�") @RequestParam Date beginTime,
-                                     @ApiParam(value = "鐧昏缁撴潫鏃堕棿") @RequestParam Date endTime) {
+    @GetMapping ("/tuanTiListById")
+    @ApiOperation (value = "鏌ヨ鍥綋浣撴鐘舵��")
+    public AjaxResult tuanTiListById(@ApiParam (value = "椤电爜鏁�(榛樿1)") @RequestParam (defaultValue = "1") Integer pageNum,
+                                     @ApiParam (value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam (defaultValue = "10") Integer pageSize,
+                                     @ApiParam (value = "鍗曚綅") @RequestParam String firmId,
+                                     @ApiParam (value = "閮ㄩ棬") @RequestParam (required = false) String dwDeptId,
+                                     @ApiParam (value = "鍒嗙粍") @RequestParam (required = false) String groupId,
+                                     @ApiParam (value = "鐧昏寮�濮嬫椂闂�") @RequestParam Date beginTime,
+                                     @ApiParam (value = "鐧昏缁撴潫鏃堕棿") @RequestParam Date endTime) {
         Map<String, Object> map = new HashMap<>();
         int a = 0;
         int b = 0;
@@ -1941,11 +2076,11 @@
     }
 
 
-    @GetMapping("/tuanTiBingById")
-    @ApiOperation(value = "鏌ヨ鍥綋浣撴鐥呯璇︾粏淇℃伅")
-    public AjaxResult tuanTiBingById(@ApiParam(value = "鍗曚綅") @RequestParam String firmId,
-                                     @ApiParam(value = "閮ㄩ棬") @RequestParam String firmDeptId,
-                                     @ApiParam(value = "鐥呯") @RequestParam(required = false) String bingZhong) {
+    @GetMapping ("/tuanTiBingById")
+    @ApiOperation (value = "鏌ヨ鍥綋浣撴鐥呯璇︾粏淇℃伅")
+    public AjaxResult tuanTiBingById(@ApiParam (value = "鍗曚綅") @RequestParam String firmId,
+                                     @ApiParam (value = "閮ㄩ棬") @RequestParam String firmDeptId,
+                                     @ApiParam (value = "鐥呯") @RequestParam (required = false) String bingZhong) {
         List<TjOrderDetailRules> res1 = new ArrayList<>();
         List<BingZhongVO> res = new ArrayList<>();
 
@@ -2004,8 +2139,8 @@
     }
 
 
-    @PostMapping("/tuanTiBingChart")
-    @ApiOperation(value = "鏌ヨ鍥綋浣撴鐥呯缁熻鍥�")
+    @PostMapping ("/tuanTiBingChart")
+    @ApiOperation (value = "鏌ヨ鍥綋浣撴鐥呯缁熻鍥�")
     public AjaxResult tuanTiBingChart(@RequestBody BingZhongVO bingZhongVO) {
         List<TjOrderDetailRules> res1 = new ArrayList<>();
 
@@ -2044,23 +2179,92 @@
     }
 
 
-    @PostMapping("/deletedTbTransitionByCusId")
-    @ApiOperation(value = "鏍规嵁韬唤璇佸彿鍒犻櫎涓存椂琛ㄦ暟鎹�")
-    public AjaxResult deletedTbTransitionByCusId(@RequestParam @ApiParam(value = "韬唤璇佸彿") String cusId) {
+    @PostMapping ("/deletedTbTransitionByCusId")
+    @ApiOperation (value = "鏍规嵁韬唤璇佸彿鍒犻櫎涓存椂琛ㄦ暟鎹�")
+    public AjaxResult deletedTbTransitionByCusId(@RequestParam @ApiParam (value = "韬唤璇佸彿") String cusId) {
         LambdaQueryWrapper<TbTransition> wq = new LambdaQueryWrapper<>();
         wq.between(TbTransition::getCreateTime, transitionService.getTbTransitionCreateTimeByCusId(cusId), new Date());
         wq.eq(TbTransition::getCusId, cusId);
         return AjaxResult.success(transitionService.remove(wq));
     }
 
+    @GetMapping ("/getTransitionInfo")
+    @ApiOperation (value = "鏍规嵁浣撴鍙疯幏鍙栨眹鎬诲拰鏄庣粏鐨勬暟鎹�")
+    public AjaxResult getTransitionInfo(@RequestParam ("tjNumber") String tjNumber) {
+        QueryWrapper<TbTransition> wrapper = new QueryWrapper<>();
+        wrapper.select("parent_pro_id", "parent_pro_name", "sum(ord_price) as ord_price")
+                .eq("tj_num", tjNumber)
+                .groupBy("parent_pro_name");
+        List<TbTransition> list = transitionService.list(wrapper);
+        List<Long> parentProIds = list.stream().map(item -> item.getParentProId()).collect(Collectors.toList());
+        LambdaQueryWrapper<TjProject> projectQueryWrapper = new LambdaQueryWrapper<>();
+        projectQueryWrapper.in(TjProject::getProId, parentProIds);
+        List<TjProject> projects = projectService.list(projectQueryWrapper);
+        JSONArray huiZong = JSONUtil.createArray();
+        int index = 1;
+        for (TjProject project : projects) {
+            LambdaQueryWrapper<SysDept> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(SysDept::getDeptId, project.getDeptId());
+            SysDept dept = sysDeptService.getOne(queryWrapper);
+            for (TbTransition tbTransition : list) {
+                if (tbTransition.getParentProId().toString().equals(project.getProId().toString())) {
+                    JSONObject obj = JSONUtil.createObj();
+                    obj.putOpt("index", index++);
+                    obj.putOpt("parent_pro_name", tbTransition.getParentProName());
+                    obj.putOpt("price", tbTransition.getOrdPrice());
+                    obj.putOpt("ks", dept.getDeptName());
+                    huiZong.add(obj);
+                }
+            }
+        }
+        wrapper = new QueryWrapper<>();
+        wrapper.eq("tj_num", tjNumber);
+        list = transitionService.list(wrapper);
+        JSONArray info = JSONUtil.createArray();
+        index = 1;
+        for (TbTransition tbTransition : list) {
+            JSONObject obj = JSONUtil.createObj();
+            obj.putOpt("index", index++);
+            obj.putOpt("parent_pro_name", tbTransition.getParentProName());
+            obj.putOpt("pro_name", tbTransition.getProName());
+            BigDecimal ordPrice = tbTransition.getOrdPrice();
+            obj.putOpt("zongjia", ordPrice);
+            QueryWrapper<TjProject> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("pro_id", tbTransition.getProId());
+            TjProject tjProject = projectService.getOne(queryWrapper);
+            Integer num = tjProject.getSl();
+            obj.putOpt("num", num);
+            BigDecimal price = ordPrice.divide(new BigDecimal(num));
+            obj.putOpt("danjia", price);
+            Date createTime = tbTransition.getCreateTime();
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            obj.putOpt("time", dateFormat.format(createTime));
+            info.put(obj);
+        }
+        HashMap<String, Object> map = new HashMap<>();
+        map.put("huizong", huiZong);
+        map.put("info", info);
+        return AjaxResult.success().put("data", map);
+    }
+
     public void newSaveextracted(TjOrder tjOrder, TjCustomer tjCustomer, BigDecimal discount, SysUser sysUser, TjReservation tjReservation, TjFlowingWater tjFlowingWater) {
         tjAskMedicalHistoryService.updateTjAskMedicalHistoryByCusId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjCustomer.getCusId()));
-        tjOrderDetailService.saveTjOrderDetailsByCusId(tjCustomer.getCusIdcard(), String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()));
-        tjOrderDetailService.saveTjPureToneTesByCusId(tjCustomer.getCusIdcard(), tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()));
-        //淇敼姣忛」鐨勫師浠风幇浠� //淇敼涓存椂琛ㄤ綋妫�鍙�
-        transitionService.updateTbTransitionPriceByCusId(tjCustomer.getCusIdcard(), discount, tjOrder.getTjNumber());
+        if (null != tjOrder.getTjCategory() && tjOrder.getTjCategory().equals("13")) {
+            tjOrderDetailService.saveJSYTjOrderDetailsByCusId(tjCustomer.getCusIdcard(), String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()),tjOrder.getCardId());
+        } else {
+            tjOrderDetailService.saveTjOrderDetailsByCusId(tjCustomer.getCusIdcard(), String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()),tjOrder.getCardId());
+        }
+
+        tjOrderDetailService.saveTjPureToneTesByCusId(tjCustomer.getCusIdcard(), tjOrder.getTjNumber(), sysUser.getNickName(),String.valueOf(sysUser.getUserId()),tjOrder.getCardId());
+
         //娣诲姞remark琛ㄦ暟鎹�
-        remarkService.saveTjOrderRemarkByOrderId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjOrder.getOrderId()));
+        if (null != tjOrder.getTjCategory() && tjOrder.getTjCategory().equals("13")) {
+            remarkService.saveJSYTjOrderRemarkByOrderId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjOrder.getOrderId()));
+
+        } else {
+            remarkService.saveTjOrderRemarkByOrderId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjOrder.getOrderId()));
+
+        }
         //鍒ゆ柇鏄惁浜ら挶
         if ("1".equals(tjOrder.getTjType())) {
             if (null != tjReservation && tjReservation.getPayType() == 1) {
@@ -2077,12 +2281,11 @@
             tjFlowingWaterService.updateById(tjFlowingWater);
             asyncService.addTjChargingStandard(tjOrder, transitionService.getTbTransitionListByCusId(tjCustomer.getCusIdcard(), tjOrder.getCardId()), sysUser);
         }
-//        System.out.println("杩欐浠g爜鏃堕棿" + (System.currentTimeMillis() - l));
     }
 
 
-    @PostMapping("/heXiaoByIds/{orderIds}")
-    @ApiOperation(value = "鏍告敹鎶ュ憡鈥斺�斺�斺�斺�斺�旀�绘瀹℃牳閫氳繃鍚庡彲浠ユ牳閿�锛屾牳鏀跺悗鎵嶈兘鎵撳嵃")
+    @PostMapping ("/heXiaoByIds/{orderIds}")
+    @ApiOperation (value = "鏍告敹鎶ュ憡鈥斺�斺�斺�斺�斺�旀�绘瀹℃牳閫氳繃鍚庡彲浠ユ牳閿�锛屾牳鏀跺悗鎵嶈兘鎵撳嵃")
     @Transactional
     public AjaxResult heXiaoByIds(@PathVariable String[] orderIds) {
         for (String orderId : orderIds) {
@@ -2098,8 +2301,8 @@
         return AjaxResult.success("鏍告敹鎴愬姛");
     }
 
-    @GetMapping("/getHistryTjOrderByCusIdCard")
-    @ApiOperation(value = "鏍规嵁韬唤璇佸彿鏌ョ湅鍘嗗彶浣撴璁板綍")
+    @GetMapping ("/getHistryTjOrderByCusIdCard")
+    @ApiOperation (value = "鏍规嵁韬唤璇佸彿鏌ョ湅鍘嗗彶浣撴璁板綍")
     @Transactional
     public AjaxResult getHistryTjOrderByCusIdCard(@RequestParam String cusIdCard) {
         TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(cusIdCard);
@@ -2119,8 +2322,8 @@
     }
 
 
-    @GetMapping("/getHistryTjOrderProByCusIdCard")
-    @ApiOperation(value = "鏍规嵁韬唤璇佸彿鏌ョ湅鍘嗗彶浣撴椤圭洰璁板綍")
+    @GetMapping ("/getHistryTjOrderProByCusIdCard")
+    @ApiOperation (value = "鏍规嵁韬唤璇佸彿鏌ョ湅鍘嗗彶浣撴椤圭洰璁板綍")
     @Transactional
     public AjaxResult getHistryTjOrderProByCusIdCard(@RequestParam String cusIdCard) {
         TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(cusIdCard);
@@ -2179,8 +2382,8 @@
     }
 
 
-    @GetMapping("/getHistryTjOrderByCusId")
-    @ApiOperation(value = "鏍规嵁瀹㈡埛id鏌ョ湅鍘嗗彶浣撴璁板綍")
+    @GetMapping ("/getHistryTjOrderByCusId")
+    @ApiOperation (value = "鏍规嵁瀹㈡埛id鏌ョ湅鍘嗗彶浣撴璁板綍")
     @Transactional
     public AjaxResult getHistryTjOrderByCusId(@RequestParam String cusId) {
         TjCustomer tjCustomer = tjCustomerService.getById(cusId);
@@ -2214,37 +2417,68 @@
     }
 
 
-    @GetMapping("/revokeTjOrderByTjNum")
-    @ApiOperation(value = "鏍规嵁瀹㈡埛浣撴鍙锋挙閿�浣撴璁板綍")
+    @GetMapping ("/revokeTjOrderByTjNum")
+    @ApiOperation (value = "鏍规嵁瀹㈡埛浣撴鍙锋挙閿�浣撴璁板綍")
     @Transactional
-    public AjaxResult revokeTjOrderByTjNum(@RequestParam @ApiParam(value = "浣撴鍙�") String tjNum) {
+    public AjaxResult revokeTjOrderByTjNum(@RequestParam @ApiParam (value = "浣撴鍙�") String tjNum) {
 
         TjOrder order = tjOrderService.getOrderByTjNum(tjNum);
         if (null != order) {
-            String payByTjNum = tjOrderService.isPayByTjNum(String.valueOf(order.getOrderId()));
-            if (null != payByTjNum) {
-                return AjaxResult.success("璇ョ敤鎴峰凡鏀惰垂涓嶅彲鎾ら攢绛惧埌!");
-            }
+//            String payByTjNum = tjOrderService.isPayByTjNum(String.valueOf(order.getOrderId()));
+//            if (null != payByTjNum) {
+//                return AjaxResult.error("璇ョ敤鎴峰凡鏀惰垂涓嶅彲鎾ら攢绛惧埌!");
+//            }
             tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
             tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId()));
             remarkService.deletedOrderRemarkByTjNum(tjNum);
             tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId()));
             transitionService.deletedTbTransitionByTjNum(tjNum);
-            transitionService.updateTbTransitionByTjNum(tjNum);
+
+            TjCustomer customer = tjCustomerService.getById(order.getUserId());
+            customer.setCardId("0");
+            tjCustomerService.updateById(customer);
+            String configByKey = configService.selectConfigByKey("sfkqdyhis");
+            if (configByKey.equals("Y")) {
+
+                HashMap<String, Object> hisRequestParams = new HashMap<>();
+                hisRequestParams.put("patientId", order.getCardId());
+                AjaxResult queryPay = hisApiGetMethodService.getHISDataNew("QueryPay", hisRequestParams);
+                if (Integer.parseInt(queryPay.get("code").toString()) == 200) {
+                    List<Map<String, String>> data = (List<Map<String, String>>) queryPay.get("data");
+
+                    BigDecimal cateFeeAll = BigDecimal.ZERO;
+                    for (Map<String, String> datum : data) {
+                        BigDecimal cateFee = new BigDecimal(datum.get("CateFee"));
+                        cateFeeAll = cateFeeAll.add(cateFee);
+                    }
+                    if (cateFeeAll.compareTo(BigDecimal.ZERO) != 0) {
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return AjaxResult.error("鎾ら攢澶辫触,璇ヤ汉鍛樺凡缂磋垂,璇峰厛閫�璐�!");
+                    }
+                }
+                boolean zfHisApiMethods = hisApiMethod.ZfHisApiMethods(null, order);
+                if (zfHisApiMethods) {
+                    return AjaxResult.success("鎾ら攢鎴愬姛");
+                } else {
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return AjaxResult.error("鎾ら攢澶辫触,璋冪敤浣滃簾鍑虹幇澶辫触");
+                }
+
+            }
             return AjaxResult.success("鎾ら攢鎴愬姛!!!");
         }
         return AjaxResult.success("绛惧埌璁板綍涓嶅瓨鍦�!");
     }
 
 
-    @GetMapping("/getCusTomterListByCompId")
-    @ApiOperation(value = "鑾峰彇鍗曚綅id浣撴浜轰俊鎭帴鍙�")
-    public AjaxResult getCusTomterListByCompId(@RequestParam(required = false) @ApiParam(value = "鍗曚綅id") String compId,
-                                               @RequestParam(required = false) @ApiParam(value = "鍚嶅瓧") String name,
-                                               @RequestParam(required = false) @ApiParam(value = "閮ㄩ棬id") String deptId,
-                                               @RequestParam(required = false) @ApiParam(value = "棰勭害鏃堕棿") Date reservationTime,
-                                               @RequestParam(defaultValue = "1") Integer page,
-                                               @RequestParam(defaultValue = "10") Integer pageSize) {
+    @GetMapping ("/getCusTomterListByCompId")
+    @ApiOperation (value = "鑾峰彇鍗曚綅id浣撴浜轰俊鎭帴鍙�")
+    public AjaxResult getCusTomterListByCompId(@RequestParam (required = false) @ApiParam (value = "鍗曚綅id") String compId,
+                                               @RequestParam (required = false) @ApiParam (value = "鍚嶅瓧") String name,
+                                               @RequestParam (required = false) @ApiParam (value = "閮ㄩ棬id") String deptId,
+                                               @RequestParam (required = false) @ApiParam (value = "棰勭害鏃堕棿") Date reservationTime,
+                                               @RequestParam (defaultValue = "1") Integer page,
+                                               @RequestParam (defaultValue = "10") Integer pageSize) {
         Page<TjReservation> pages = new Page<>(page, pageSize);
         LambdaQueryWrapper<TjReservation> wq = new LambdaQueryWrapper<>();
         if (null != compId) wq.eq(TjReservation::getCompanyId, compId);
@@ -2270,10 +2504,10 @@
     }
 
 
-    @PostMapping("/plRevokeTjOrderByTjNum")
-    @ApiOperation(value = "鏍规嵁瀹㈡埛浣撴鍙锋壒閲忔挙閿�浣撴璁板綍")
+    @PostMapping ("/plRevokeTjOrderByTjNum")
+    @ApiOperation (value = "鏍规嵁瀹㈡埛浣撴鍙锋壒閲忔挙閿�浣撴璁板綍")
     @Transactional
-    public AjaxResult plRevokeTjOrderByTjNum(@RequestBody @ApiParam(value = "棰勭害涓婚敭id闆嗗悎") List<String> reservationIds) {
+    public AjaxResult plRevokeTjOrderByTjNum(@RequestBody @ApiParam (value = "棰勭害涓婚敭id闆嗗悎") List<String> reservationIds) {
         if (null != reservationIds && reservationIds.size() > 0) {
             LambdaQueryWrapper<TjOrder> wq1 = new LambdaQueryWrapper<>();
             wq1.in(TjOrder::getReservationId, reservationIds);
@@ -2296,7 +2530,7 @@
                 }
                 for (String id : reservationIds) {
                     TjReservation reservation = tjReservationService.getById(id);
-                    if(null !=reservation){
+                    if (null != reservation) {
                         reservation.setIsExpire(2);
                         tjReservationService.updateById(reservation);
                     }
@@ -2307,5 +2541,219 @@
         return AjaxResult.error("璇烽�夋嫨瑕佹挙閿�鐨勪汉鍛�!");
     }
 
+    @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());
+        }
+    }
+
+
+    @GetMapping ("/delTbBycusCardIdAndProId")
+    @ApiOperation (value = "鏍规嵁瀹㈡埛韬唤璇佸彿鍜岄」鐩埗椤筰d鍒犻櫎涓存椂琛ㄦ暟鎹�")
+    @Transactional
+    public AjaxResult delTbBycusCardIdAndProId(@RequestParam @ApiParam (value = "韬唤璇佸彿") String cusCardId,
+                                               @RequestParam @ApiParam (value = "鐖堕」id") String proId) {
+
+        if (transitionService.delTbBycusCardIdAndProId(cusCardId, proId)) {
+            return AjaxResult.success();
+        }
+        return AjaxResult.error("璁板綍涓嶅瓨鍦�!");
+    }
+
+
+    @GetMapping ("/revokeTjOrderByTjCardId")
+    @ApiOperation (value = "鏍规嵁灏辫瘖鍙锋挙閿�鐢宠璁板綍")
+    @Transactional
+    public AjaxResult revokeTjOrderByTjCardId(@RequestParam @ApiParam (value = "灏辫瘖鍙�") String cardId) {
+
+        TjOrder order = new TjOrder();
+        order.setCardId(cardId);
+        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();
+    }
+
+
+    @GetMapping ("/revokeTjOrderByTjh")
+    @ApiOperation (value = "鏍规嵁灏变綋妫�鍙峰垹闄よ褰�")
+    @Transactional
+    public AjaxResult revokeTjOrderByTjh(@RequestParam @ApiParam (value = "浣撴鍙�") String tjNum) {
+
+        TjOrder order = tjOrderService.getOrderByTjNum(tjNum);
+        if (null != order) {
+//            String payByTjNum = tjOrderService.isPayByTjNum(String.valueOf(order.getOrderId()));
+//            if (null != payByTjNum) {
+//                return AjaxResult.error("璇ョ敤鎴峰凡鏀惰垂涓嶅彲鎾ら攢绛惧埌!");
+//            }
+            tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
+            tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId()));
+            remarkService.deletedOrderRemarkByTjNum(tjNum);
+            tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId()));
+            transitionService.deletedTbTransitionByTjNum(tjNum);
+        }
+        return AjaxResult.success();
+    }
+
+
+    @GetMapping ("/getBlproByTjh")
+    @ApiOperation (value = "鏍规嵁浣撴鍙疯幏鍙栬ˉ褰曢」鐩褰�")
+    @Transactional
+    public AjaxResult getBlproByTjh(@RequestParam @ApiParam (value = "浣撴鍙�") String tjNum) {
+
+        TjOrder order = tjOrderService.getOrderByTjNum(tjNum);
+        if (null != order) {
+            LambdaQueryWrapper<TjProBl> wq = new LambdaQueryWrapper<>();
+            wq.eq(TjProBl::getTjh, tjNum);
+            List<TjProBl> blList = blService.list(wq);
+            if (null != blList && blList.size() > 0) {
+                for (TjProBl bl : blList) {
+                    LambdaQueryWrapper<TjOrderRemark> wqr = new LambdaQueryWrapper<>();
+                    wqr.eq(TjOrderRemark::getJxbz, bl.getBldh());
+                    List<TjOrderRemark> remarkList = remarkService.list(wqr);
+                    if (null != remarkList && remarkList.size() > 0) {
+                        List<Long> collect = remarkList.stream().map(TjOrderRemark::getProId).collect(Collectors.toList());
+                        LambdaQueryWrapper<TjProject> wqp = new LambdaQueryWrapper<>();
+                        wqp.in(TjProject::getProId, collect);
+                        List<TjProject> projectList = projectService.list(wqp);
+                        for (TjProject project : projectList) {
+                            project.setChildren(projectService.getTjProjectListBySoneId(String.valueOf(project.getProId())));
+                        }
+                        bl.setProjectList(projectList);
+                    }
+                }
+                return AjaxResult.success(blList);
+            }
+            return AjaxResult.success(null);
+        }
+        return AjaxResult.error("鏆傛棤浣撴璁板綍");
+    }
+
+
+    @PostMapping ("/revokeBlProByBldhAndTjh")
+    @ApiOperation (value = "鏍规嵁琛ュ綍鍗曞彿鍜屼綋妫�鍙峰垹闄よ褰�")
+    @Transactional
+    public AjaxResult revokeBlProByBldhAndTjh(@RequestBody TjProBlDto dto) {
+
+        if (null == dto.getBldhs() || dto.getBldhs().size() == 0) {
+            return AjaxResult.error("璇烽�夋嫨瑕佹挙閿�鐨勮ˉ褰曢」鐩�");
+        }
+
+        TjOrder order = tjOrderService.getOrderByTjNum(dto.getTjh());
+        if (null != order) {
+            String configByKey = configService.selectConfigByKey("sfkqdyhis");
+            if (null != configByKey && configByKey.equals("Y")) {
+                HashMap<String, Object> hisRequestParams = new HashMap<>();
+                hisRequestParams.put("patientId", order.getCardId());
+                AjaxResult queryPay = hisApiGetMethodService.getHISDataNew("QueryPay", hisRequestParams);
+                if (Integer.parseInt(queryPay.get("code").toString()) == 200) {
+                    List<Map<String, String>> data = (List<Map<String, String>>) queryPay.get("data");
+                    BigDecimal cateFeeAll = BigDecimal.ZERO;
+                    List<String> advIds = new ArrayList<>();
+                    for (Map<String, String> datum : data) {
+                        String advId = datum.get("Adv_Id").split("_")[1];
+                        BigDecimal cateFee = new BigDecimal(datum.get("CateFee"));
+                        cateFeeAll = cateFeeAll.add(cateFee);
+                        advIds.add(advId);
+                    }
+                    if (advIds.containsAll(dto.getBldhs()) && cateFeeAll.compareTo(BigDecimal.ZERO) != 0) {
+                        return AjaxResult.error("鏀归」鐩凡缂磋垂涓嶅彲鎾ら攢!!!");
+                    }
+
+                }
+                boolean b = hisApiMethod.ZfBlXm(dto.getBldhs(), order);
+                if(!b){
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return AjaxResult.error("鎾ら攢澶辫触,璋冪敤浣滃簾鍑虹幇澶辫触");
+                }
+            }
+            for (String bldh : dto.getBldhs()) {
+                remarkService.deleteTjOrderDetailByjxbz(bldh);
+                tjOrderDetailService.deleteTjOrderDetailByjxbz(bldh);
+                tjFlowingWaterService.deleteTjOrderDetailByjxbz(bldh);
+                transitionService.deleteTjOrderDetailByjxbz(bldh);
+                blService.remove(new LambdaQueryWrapper<TjProBl>().eq(TjProBl::getTjh, dto.getTjh()).eq(TjProBl::getBldh, bldh));
+            }
+            return AjaxResult.success();
+        }
+        return AjaxResult.error();
+    }
+
+
+    @PostMapping ("/addYaoPinShenQing")
+    @ApiOperation (value = "鑽搧淇℃伅鐢宠")
+    @Transactional
+    public AjaxResult addYaoPinShenQing(@RequestBody OutpinmedicapplyDto dto) {
+        AjaxResult result = controller.Outpinmedicapply(dto);
+        String result1 = getAjaxResult(result);
+        JSONObject object = getJSONObject(result1);
+        String code = object.getStr("ResultCode");
+        if (null != code && code.equals("0")) {
+
+        }
+        return AjaxResult.success();
+    }
+
+
 }
 

--
Gitblit v1.8.0