From 971162978842f8cf87d34f99da8c529e2e945da8 Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期二, 15 四月 2025 08:46:57 +0800
Subject: [PATCH] zjh20250415

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java | 1779 +++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 1,192 insertions(+), 587 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 e237f9c..82e0ab3 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
@@ -2,31 +2,24 @@
 
 import java.io.*;
 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.*;
 import java.util.concurrent.locks.ReentrantLock;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import cn.hutool.core.codec.Base64;
 import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.IdUtil;
-import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
-import cn.hutool.crypto.symmetric.DES;
 import cn.hutool.extra.pinyin.PinyinUtil;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
@@ -34,10 +27,7 @@
 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.conditions.update.LambdaUpdateWrapper;
-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.annotation.RepeatSubmit;
@@ -53,11 +43,11 @@
 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.dto.UpdateTransitionnewPriceDto;
 import com.ltkj.hosp.hisDto.OutpinmedicapplyDto;
+import com.ltkj.hosp.mapper.TbTransitionMapper;
 import com.ltkj.hosp.mapper.TestMapper;
 import com.ltkj.hosp.mapper.TjSamplingMapper;
-import com.ltkj.hosp.pacsDto.SavePacsApply;
 import com.ltkj.hosp.service.*;
 import com.ltkj.hosp.sqlDomain.LtkjMiddleDetail;
 import com.ltkj.hosp.sqlDomain.LtkjMiddleHead;
@@ -74,23 +64,19 @@
 import com.ltkj.mall.service.IMallOrderService;
 import com.ltkj.system.domain.TjDjdDyjl;
 import com.ltkj.system.service.*;
+import com.ltkj.hosp.idutil.IdUtils;
 import com.ltkj.web.controller.his.*;
 import com.ltkj.web.controller.lis.LisApiMethod;
 import com.ltkj.web.controller.pacs.PacsApiMethodService;
-import com.ltkj.web.controller.service.TjSysAsyncServiceImpl;
 import com.ltkj.web.wxUtils.HttpClientUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import jodd.util.StringUtil;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.time.DateFormatUtils;
-import org.aspectj.weaver.ast.Var;
 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.Isolation;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
@@ -114,7 +100,7 @@
  */
 @RestController
 @RequestMapping("/hosp/order")
-@Api(tags = "PC绔� ----浣撴璁板綍鎺ュ彛")
+@Api(tags = "PC绔� ----浣撴璁板綍鎺ュ彛 OrderController")
 @Slf4j
 public class TjOrderController extends BaseController {
     @Resource
@@ -231,6 +217,14 @@
     private ISysDictDataService sysDictDataService;
     @Autowired
     private TjFlowingWaterHisService tjFlowingWaterHisService;
+    @Resource
+    private ITjXdPictureService xdPictureService;
+    @Autowired
+    private TjOrderYcxmService ycxmService;
+    @Autowired
+    private TbTransitionMapper tbTransitionMapper;
+
+    private static final String TJH = "tjhs:tjh";
 
     //灏嗘柟娉曡繑鍥炲�艰В鏋愭垚json鏍煎紡
     public JSONObject getJSONObject(String builder) {
@@ -297,7 +291,7 @@
             wqq.like(TjCustomer::getCusName, name);
             List<TjCustomer> customerList = tjCustomerService.list(wqq);
             List<TjOrder> list2 = new ArrayList<>();
-            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<>();
@@ -308,13 +302,13 @@
                     list.addAll(tjOrderService.list(wq));
                 }
                 List<TjOrder> collect = null;
-                if (list.size() > 0) {
+                if (!list.isEmpty()) {
                     for (TjOrder order : list) {
                         //绛涢�夋湁璋冩煡闂嵎鐨�
                         LambdaQueryWrapper<TjSurveyRecord> wqq1 = new LambdaQueryWrapper<>();
                         wqq1.eq(TjSurveyRecord::getTjnumber, order.getTjNumber());
                         List<TjSurveyRecord> one = surveyRecordService.list(wqq1);
-                        if (one.size() == 0) {
+                        if (one.isEmpty()) {
                             TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId());
                             if (null != tjCustomer) {
                                 order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
@@ -375,7 +369,7 @@
                 LambdaQueryWrapper<TjSurveyRecord> wqq = new LambdaQueryWrapper<>();
                 wqq.eq(TjSurveyRecord::getTjnumber, order.getTjNumber());
                 List<TjSurveyRecord> one = surveyRecordService.list(wqq);
-                if (one.size() == 0) {
+                if (one.isEmpty()) {
                     TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId());
                     if (null != tjCustomer) {
                         order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
@@ -456,32 +450,32 @@
             wq.in(TjOrder::getUserId, cusIds);
         }
 
-        if(null !=zt && (zt==0 || zt==1 || zt==2)){
-            List<TjOrder> orders=new ArrayList<>();
-            List<TjOrder> tjOrders=null;
+        if (null != zt && (zt == 0 || zt == 1 || zt == 2)) {
+            List<TjOrder> orders = new ArrayList<>();
+            List<TjOrder> tjOrders = null;
             List<TjOrder> orderList = tjOrderService.list(wq);
-            if(null !=orderList && !orderList.isEmpty()){
+            if (null != orderList && !orderList.isEmpty()) {
                 for (TjOrder order : orderList) {
                     int czwj = remarkService.panduaniscunzaiweijian(order.getTjNumber());
                     int sfwc = remarkService.panduaniswancheng(order.getTjNumber());
-                    if (zt==0 && czwj == 0) {
+                    if (zt == 0 && czwj == 0) {
                         //鏈0
                         order.setZt("鏈");
                         orders.add(order);
                     }
-                    if (zt==1 && czwj > 0) {
+                    if (zt == 1 && czwj > 0) {
                         //鍦ㄦ1
                         order.setZt("鍦ㄦ");
                         orders.add(order);
                     }
-                    if (zt==2 && sfwc == 0 && order.getCheckStatus()==0 && order.getCheckTime()==null && order.getHeshouStatus()==0 && order.getPrintLastTime()==null) {
+                    if (zt == 2 && sfwc == 0 && order.getCheckStatus() == 0 && order.getCheckTime() == null && order.getHeshouStatus() == 0 && order.getPrintLastTime() == null) {
                         //宸插畬鎴�2
                         order.setZt("宸插畬鎴�");
                         orders.add(order);
                     }
                 }
-                if(!orders.isEmpty()){
-                    tjOrders=orders.stream().sorted(Comparator.comparing(TjOrder::getCreateTime).reversed())
+                if (!orders.isEmpty()) {
+                    tjOrders = orders.stream().sorted(Comparator.comparing(TjOrder::getCreateTime).reversed())
                             .skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
                     for (TjOrder order : tjOrders) {
                         TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId());
@@ -495,13 +489,9 @@
                             order.setIdType(tjCustomer.getIdType());
                             order.setAgeUnit(tjCustomer.getAgeUnit());
                             order.setTjCount(String.valueOf(tjCustomer.getCusNumber()));
-                            if (null != tjCustomer.getCompName()) {
-                                order.setDictCompName(tjCustomer.getCompName());
-                            } else {
-                                String firmId = order.getFirmId();
-                                if (firmId != null && null != iDictCompService.getById(String.valueOf(order.getFirmId()))) {
-                                    order.setDictCompName(iDictCompService.getById(String.valueOf(order.getFirmId())).getCnName());
-                                }
+                            String firmName = order.getFirmName();
+                            if (StringUtil.isNotBlank(firmName)) {
+                                order.setDictCompName(firmName);
                             }
                             if (null != order.getPacId()) {
                                 if (null != tjPackageService.getById(order.getPacId())) {
@@ -521,31 +511,31 @@
             return AjaxResult.success(map);
         }
 
-        if(null !=zt){
-            if(zt==3){
+        if (null != zt) {
+            if (zt == 3) {
                 //宸插鏍�
                 wq.isNotNull(TjOrder::getCheckTime);
-                wq.eq(TjOrder::getCheckStatus,1);
+                wq.eq(TjOrder::getCheckStatus, 1);
                 wq.isNull(TjOrder::getHeshouTime);
                 wq.isNull(TjOrder::getPrintLastTime);
-                wq.eq(TjOrder::getHeshouStatus,0);
+                wq.eq(TjOrder::getHeshouStatus, 0);
             }
-            if(zt==4){
+            if (zt == 4) {
                 //鐢熸垚鎶ュ憡
                 wq.isNotNull(TjOrder::getReportTime);
                 wq.isNull(TjOrder::getHeshouTime);
                 wq.isNull(TjOrder::getPrintLastTime);
-                wq.eq(TjOrder::getHeshouStatus,0);
+                wq.eq(TjOrder::getHeshouStatus, 0);
             }
-            if(zt==5){
+            if (zt == 5) {
                 //鎶ュ憡鏍告敹
-                wq.eq(TjOrder::getHeshouStatus,1);
+                wq.eq(TjOrder::getHeshouStatus, 1);
                 wq.isNull(TjOrder::getPrintLastTime);
             }
-            if(zt==6){
-                //宸插嚭鎶ュ憡
+            if (zt == 6) {
+                //宸叉墦鍗�
                 wq.isNotNull(TjOrder::getPrintLastTime);
-                wq.eq(TjOrder::getHeshouStatus,1);
+                wq.eq(TjOrder::getHeshouStatus, 1);
                 wq.isNotNull(TjOrder::getPrintLastTime);
             }
         }
@@ -591,20 +581,20 @@
                 Integer heshouStatus = order.getHeshouStatus();
                 Date lastTime = order.getPrintLastTime();
 
-                if(null !=zt){
-                    if(zt==3){
+                if (null != zt) {
+                    if (zt == 3) {
                         order.setZt("宸插鏍�");
                     }
-                    if(zt==4){
+                    if (zt == 4) {
                         order.setZt("鐢熸垚鎶ュ憡");
                     }
-                    if(zt==5){
+                    if (zt == 5) {
                         order.setZt("鎶ュ憡鏍告敹");
                     }
-                    if(zt==6){
-                        order.setZt("宸插嚭鎶ュ憡");
+                    if (zt == 6) {
+                        order.setZt("宸叉墦鍗�");
                     }
-                }else {
+                } else {
                     if (czwj == 0) {
                         //鏈0
                         order.setZt("鏈");
@@ -625,13 +615,13 @@
                         //鐢熸垚鎶ュ憡4
                         order.setZt("鐢熸垚鎶ュ憡");
                     }
-                    if (1== heshouStatus) {
+                    if (1 == heshouStatus) {
                         //鎶ュ憡鏍告敹5
                         order.setZt("鎶ュ憡鏍告敹");
                     }
                     if (null != lastTime) {
-                        //宸插嚭鎶ュ憡6
-                        order.setZt("宸插嚭鎶ュ憡");
+                        //宸叉墦鍗�6
+                        order.setZt("宸叉墦鍗�");
                     }
                 }
             }
@@ -730,7 +720,7 @@
 
         if (djbeginTime == null) djbeginTime = "";
         if (djendTime == null) djendTime = "";
-        Map<String, Object> map=  tjOrderService.getTjBgdyList(pageNum,pageSize,dyzt,tjNum,name,dw,djbeginTime,djendTime);
+        Map<String, Object> map = tjOrderService.getTjBgdyList(pageNum, pageSize, dyzt, tjNum, name, dw, djbeginTime, djendTime);
         return AjaxResult.success(map);
     }
 
@@ -988,18 +978,18 @@
         TjCustomer tjCustomer = tjCustomerService.getOne(wq);
         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());
+//        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());
+////        }
+//        TjOrder order = tjOrderService.getOne(wqq);
+//        if (null != order) {
+//            transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(), tjCustomer.getCardId());
+//            return AjaxResult.error("涓嶅彲閲嶅鐧昏");
 //        }
-        TjOrder order = tjOrderService.getOne(wqq);
-        if (null != order) {
-            transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(), tjCustomer.getCardId());
-            return AjaxResult.error("涓嶅彲閲嶅鐧昏");
-        }
         TjFlowingWater tjFlowingWater = new TjFlowingWater();
         LambdaQueryWrapper<TjReservation> wq1 = new LambdaQueryWrapper<>();
         wq1.eq(TjReservation::getIdCard, tjCustomer.getCusIdcard());
@@ -1018,8 +1008,8 @@
                 return AjaxResult.error("瀵逛笉璧锋偍鐨勯绾﹀凡瓒呮椂璇烽噸鏂伴绾�");
             }
             if (null != tjReservation.getTeamNo()) tjOrder.setTeamNo(tjReservation.getTeamNo());
-//            if (null != tjReservation.getCompanyId()) tjOrder.setFirmId(tjReservation.getCompanyId());
-//            if (null != tjReservation.getCompany()) tjOrder.setFirmName(tjReservation.getCompany());
+            if (null != tjReservation.getCompanyId()) tjOrder.setFirmId(tjReservation.getCompanyId());
+            if (null != tjReservation.getCompany()) tjOrder.setFirmName(tjReservation.getCompany());
             if (null != tjReservation.getDepartment()) tjOrder.setFirmDeptName(tjReservation.getDepartment());
             if (null != tjReservation.getJobNo()) tjOrder.setFirmWorkId(tjReservation.getJobNo());
             if (null != tjReservation.getPacId()) tjOrder.setPacId(tjReservation.getPacId());
@@ -1030,22 +1020,15 @@
             }
             tjReservation.setIsExpire(1);
             tjReservationService.updateById(tjReservation);
-            if (null != tjReservation.getTeamNo() && tjOrder.getTjType().equals("1")) {
+            if (null != tjReservation.getTeamNo()) {
                 tjOrder.setTjType("1");
             } else if (tjOrder.getTjType().equals("2")) {
                 tjOrder.setTjType("2");
             }
         }
-
-        if (null != tjCustomer.getCompName()) {
-            tjOrder.setFirmName(tjCustomer.getCompName());
-        }
-        if (null != tjCustomer.getDictCompId()) {
-            tjOrder.setFirmId(String.valueOf(tjCustomer.getDictCompId()));
-        } else {
+        if (StringUtil.isBlank(tjOrder.getFirmId())) {
             tjOrder.setFirmId("0");
         }
-
 
         if (null != tjOrder.getPhoto()) {
             File file = new File(tjOrder.getPhoto());
@@ -1085,19 +1068,66 @@
                 tjOrderService.tjQiandaodengji(tjOrder.getTjNumber());
                 return result;
             }
-        } finally {
+        }catch (Exception e){
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            log.error(String.valueOf(e));
+        }
+        finally {
             lock.unlock();
         }
         return AjaxResult.error();
     }
 
-    @Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
+//    @Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
+    @Transactional(propagation = Propagation.REQUIRED) // 鍏变韩浜嬪姟
     public AjaxResult processOrderWithTransaction(TjOrder tjOrder, TjCustomer tjCustomer, TjReservation tjReservation, TjFlowingWater tjFlowingWater, MallOrder mallOrder, SysUser sysUser) {
-        //鐢熸垚浣撴鍙�
-        String tjNumber = (SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmss").format(new Date()));
-        tjOrder.setTjNumber(tjNumber);
-        BigDecimal discount = BigDecimal.valueOf(Double.parseDouble(tjOrder.getTjFlowingWater().getDiscount()));
 
+        //鑾峰彇鎷兼帴鍓嶇紑
+        String sfkqtjhqz = configService.selectConfigByKey("sfkqtjhqz");
+        String makeLisTmhPrefix = "";
+        if(sfkqtjhqz.equalsIgnoreCase("Y")){
+             makeLisTmhPrefix = configService.selectConfigByKey("make_lis_tmh_prefix");
+        }
+
+        //鐢熸垚浣撴鍙�
+//        String tjNumber = (SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmss").format(new Date()));
+//        if(StringUtil.isNotBlank(makeLisTmhPrefix)) tjNumber=makeLisTmhPrefix+tjNumber;
+//        String tjNumber = (SecurityUtils.getUsername() + idUtils.getTjNumber());
+//        String tjNumber = idUtils.getTjNumber();
+        String tjNumber = null;
+
+        int a =0;
+        while (tjNumber ==null){
+            if(a>3){
+                throw new RuntimeException("鍓嶆柟鎷ユ尋,璇风◢绛�!!!");
+            }
+            try {
+                String newTjNumberRedisLockAndMysql = idUtils.getNewTjNumberRedisLockAndMysql();
+                if (StringUtil.isNotBlank(makeLisTmhPrefix)){
+                 String tjh=  makeLisTmhPrefix + newTjNumberRedisLockAndMysql;
+                 int countByTjNum = tjOrderService.getOrderCountByTjNum(tjh);
+                 if(countByTjNum==0){
+                     tjNumber=tjh;
+                 }
+                }else {
+                    int countByTjNum = tjOrderService.getOrderCountByTjNum(newTjNumberRedisLockAndMysql);
+                    if(countByTjNum==0){
+                        tjNumber=newTjNumberRedisLockAndMysql;
+                    }
+                }
+            } catch (Exception e) {
+                log.error(e.getMessage());
+            }finally {
+                a++;
+            }
+        }
+
+        if(StringUtil.isBlank(tjNumber)) return AjaxResult.error("鐧昏澶辫触 閲嶆柊鎿嶄綔");
+
+        tjOrder.setTjNumber(tjNumber);
+
+
+        BigDecimal discount = BigDecimal.valueOf(Double.parseDouble(tjOrder.getTjFlowingWater().getDiscount()));
         tjOrder.setDiscount(discount.toString());
         if (tjOrderService.save(tjOrder)) {
             //淇濆瓨鏀惰揣鍦板潃
@@ -1132,11 +1162,18 @@
             Date date1 = new Date(System.currentTimeMillis());
             String s1 = SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmssSSS").format(date1);
             tjFlowingWater.setWaterId(PinyinUtil.getFirstLetter(tjCustomer.getCusName(), "").toUpperCase() + s1);
+            BigDecimal copeWith = tjOrder.getTjFlowingWater().getCopeWith();
+            BigDecimal paidIn = tjOrder.getTjFlowingWater().getPaidIn();
 
+            tjFlowingWater.setCopeWith(copeWith);
+            tjFlowingWater.setPaidIn(paidIn);
+            tjFlowingWater.setDiscount(discount.toString());
 
-            tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith());
-            tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn());
-            tjFlowingWater.setDiscount(tjOrder.getTjFlowingWater().getDiscount());
+            BigDecimal subtract = paidIn.subtract(copeWith.multiply(discount.divide(BigDecimal.valueOf(10))));
+            log.info("绛惧埌鐧昏浣撴浜�: " + tjOrder.getTjNumber() + " 搴斾粯: " + copeWith);
+            log.info("绛惧埌鐧昏浣撴浜�: " + tjOrder.getTjNumber() + " 鎶樻墸: " + discount);
+            log.info("绛惧埌鐧昏浣撴浜�: " + tjOrder.getTjNumber() + " 瀹炰粯: " + paidIn);
+            log.info("绛惧埌鐧昏浣撴浜�: " + tjOrder.getTjNumber() + " 鐩稿樊: " + subtract);
 
             if (isPay.equals("true")) {
                 if (null != mallOrder) {
@@ -1166,13 +1203,27 @@
                     //                    tjFlowingWater.setPayStasus(0L);
                 }
             }
+
+            //淇敼姣忛」鐨勫師浠风幇浠�
+//            transitionService.updateTbTransitionPriceByCusId(tjCustomer.getCusIdcard(), discount, tjOrder.getTjNumber());
+            //淇敼涓存椂琛ㄤ綋妫�鍙�
+            transitionService.updateTbTransitionTjNumByCusId(tjCustomer.getCusIdcard(), tjOrder.getTjNumber());
+            //琛ュ樊浠�
+    /*        if(subtract.compareTo(BigDecimal.ZERO)>0){
+                tjFlowingWater.setPaidIn(paidIn.add(subtract));
+                TbTransition onwTbTransition = transitionService.getOnwTbTransition(tjCustomer.getCusIdcard(),tjOrder.getTjNumber());
+                if(null !=onwTbTransition){
+                    log.info("绛惧埌鐧昏浣撴浜�: "+tjOrder.getTjNumber()+"缁�: "+onwTbTransition.getParentProName()+" "+onwTbTransition.getNowPrice()
+                            +" 琛ュ樊浠� "+subtract+" 鏈�缁堝緱 "+onwTbTransition.getNowPrice().add(subtract));
+                    onwTbTransition.setNowPrice(onwTbTransition.getNowPrice().add(subtract));
+                    transitionService.updateById(onwTbTransition);
+                }
+            }*/
+
             if (tjFlowingWaterService.save(tjFlowingWater)) {
                 tjOrder.setTjSerialNumber(String.valueOf(tjFlowingWater.getTjSerialNumber()));
                 tjOrderService.updateById(tjOrder);
             }
-
-            //淇敼姣忛」鐨勫師浠风幇浠� //淇敼涓存椂琛ㄤ綋妫�鍙�
-            transitionService.updateTbTransitionPriceByCusId(tjCustomer.getCusIdcard(), discount, tjOrder.getTjNumber());
 
             /*璋冪敤his鎺ュ彛*/
             String config = configService.selectConfigByKey("sfkqdyhis");
@@ -1185,33 +1236,52 @@
                         hisApiMethod.ZfHisApiMethod(jzh.toString());
                     }
                     log.info("璇ョ櫥璁颁汉鎸傚彿澶辫触, 灏辫瘖鍙蜂负: " + tjOrder.getCardId());
-                    return AjaxResult.error("鎸傚彿澶辫触!" + result.get("msg").toString());
+//                    return AjaxResult.error("鎸傚彿澶辫触!" + result.get("msg").toString());
+                    throw new IllegalStateException("鎸傚彿澶辫触!" + result.get("msg").toString());
                 }
 
                 log.info("璇ョ櫥璁颁汉鐨刪is灏辫瘖鍙锋槸: " + tjOrder.getCardId());
                 //鍥綋
-                if ("1".equals(tjOrder.getTjType())) {
+/*                if ("1".equals(tjOrder.getTjType())) {
 //                            asyncService.ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
                     ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
-                }
+                }*/
                 //涓汉
-                if ("2".equals(tjOrder.getTjType())) {
+         /*       if ("2".equals(tjOrder.getTjType())) {
                     //asyncService.newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                     newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
-                }
+                }*/
                 // 鏌ヨ 瀵规帴Lis銆丳acs鐢宠濡傛灉绫诲瀷鍖呭惈鍦ㄩ厤缃唴鍒欎娇鐢ㄥ鎺is銆乸acs
-                if (lisApiMethod.isUseLisAndPacsRegister(tjOrder)) {
-                    // 杩欐槸涓婇潰涓汉鏂规硶寮曞叆鏁版嵁
-                    tjFlowingWater.setPayStasus(1L);
-                    newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
-                    AjaxResult ajaxResult = hisApiMethod.tijianshenqing(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder, sysUser, result);
-                    if (!ajaxResult.get("code").toString().equals("200")) return ajaxResult;
-                    tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
-                            sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
-                } else {
-                    hisApiMethod.tijianshenqing(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder.getCardId());
+                try {
+                    if (lisApiMethod.isUseLisAndPacsRegister(tjOrder)) {
+                        log.info("璋冪敤his寮�鍚� 杩涘叆涓嶆敹璐规柟娉� 璇ヤ綋妫�浜哄憳涓嶆敹璐�:"+tjOrder.getTjNumber());
+                        // 杩欐槸涓婇潰涓汉鏂规硶寮曞叆鏁版嵁
+                        tjFlowingWater.setPayStasus(1L);
+                        newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
+                        AjaxResult ajaxResult = hisApiMethod.tijianshenqing(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder, sysUser, result);
+                        if (!ajaxResult.get("code").toString().equals("200")) return ajaxResult;
+                        tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
+                                sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
+                        remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString());
+                        List<TjXdPicture> xdPictureList = xdPictureService.saveTjXdPicture(tjOrder.getTjNumber());
+                        xdPictureService.saveBatch(xdPictureList);
+                        List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
+                        addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
+                        log.info("璋冪敤his寮�鍚� 杩涘叆涓嶆敹璐规柟娉� 璇ユ柟娉曟墽琛屽畬姣�");
+                    } else {
+                        log.info("璋冪敤his寮�鍚� 杩涘叆鏀惰垂鏂规硶 璇ヤ綋妫�浜哄憳涓嶆敹璐�:"+tjOrder.getTjNumber());
+                        newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
+                        List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
+                        addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
+                        String isUseMx = configService.selectConfigByKey("jcxhis_is_use_mx");
+                        if (isUseMx.equalsIgnoreCase("Y"))
+                            hisApiMethod.tijianshenqing(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder.getCardId());
+                        else hisApiMethod.tijianshenqingJinchuanNew(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder.getCardId());
+                    }
+                } catch (Exception e) {
+                    log.error(e.getMessage());
+                    throw new IllegalStateException();
                 }
-//                        hisApiMethod.tijianshenqing(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder.getCardId());
                 return AjaxResult.success(tjNumber);
             } else {
                 tjCustomer.setCardId(tjOrder.getTjNumber());
@@ -1222,197 +1292,344 @@
             }
 
             //鍥綋
-            if ("1".equals(tjOrder.getTjType())) {
-//                        asyncService.ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
-                asyncService.ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
-            }
+//            if ("1".equals(tjOrder.getTjType())) {
+//                ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
+////                asyncService.ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
+//                List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
+//                addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
+//                return AjaxResult.success(tjNumber);
+//            }
             //涓汉
-            if ("2".equals(tjOrder.getTjType())) {
-                //asyncService.newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
-                newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
-                List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
-                addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
+//            if ("2".equals(tjOrder.getTjType())) {
+//                //asyncService.newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
+//                newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
+//                List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
+//                addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
+//
+//                String s = configService.selectConfigByKey("is_request_common_his_api");
+//                if (null != s && s.equals("Y")) {
+//                    String apiUrl = configService.selectConfigByKey("common_api_url");
+//                    String hospbm = configService.selectConfigByKey("common_api_service_hospbm");
+//                    HashMap<String, Object> map = new HashMap<>();
+//                    map.put("pationId", tjCustomer.getPationId());
+//                    map.put("cardId", tjCustomer.getHisJzkh());
+//                    map.put("tjNum", tjFlowingWater.getTjSerialNumber());
+//                    map.put("kaiDanKs", "7805");
+//                    // 鏀惰垂鏍囧織 1寰呭敭璐� 2寰呴��璐�
+//                    map.put("shouTuiStatus", "1");
+//
+//                    JSONArray array = JSONUtil.createArray();
+//                    LambdaQueryWrapper<TbTransition> wrapper = new LambdaQueryWrapper<>();
+//                    wrapper.eq(TbTransition::getTjNum, tjOrder.getTjNumber());
+//                    wrapper.eq(TbTransition::getCusId, tjCustomer.getCusIdcard());
+//                    wrapper.eq(TbTransition::getCardId, tjCustomer.getCardId());
+//                    wrapper.isNotNull(TbTransition::getOrdPrice);
+//                    wrapper.gt(TbTransition::getOrdPrice, 0);
+//
+//                    List<TbTransition> list = tbTransitionService.list(wrapper);
+//                    for (TbTransition transition : list) {
+//                        LambdaQueryWrapper<TjProject> wrapper1 = new LambdaQueryWrapper<>();
+//                        wrapper1.eq(TjProject::getProId, transition.getProId());
+//                        TjProject project = projectService.getOne(wrapper1);
+//
+//                        LambdaQueryWrapper<SysDept> wrapper2 = new LambdaQueryWrapper<>();
+//                        wrapper2.eq(SysDept::getDeptId, project.getDeptId());
+//                        SysDept dept = sysDeptService.getOne(wrapper2);
+//
+//                        JSONObject obj = JSONUtil.createObj();
+//                        Integer sl = project.getSl();
+//                        BigDecimal danjia = transition.getOrdPrice();
+//                        BigDecimal allPrice = danjia.multiply(new BigDecimal(sl));
+//                        obj.putOpt("danJia", danjia);
+//                        obj.putOpt("jieSuanJe", allPrice);
+//                        obj.putOpt("shuliang", sl);
+//                        obj.putOpt("zhiXingKs", dept.getDeptId());
+//                        obj.putOpt("zhiXingKsMc", dept.getDeptName());
+//                        obj.putOpt("shouFeiXmId", project.getHisXmbm());
+//                        obj.putOpt("shouFeiXmMc", project.getHisXmmc());
+//
+////                        obj.putOpt("zhiXingKs","7805");
+////                        obj.putOpt("zhiXingKsMc","浣撴绉�");
+////                        obj.putOpt("shouFeiXmId","4735346");
+////                        obj.putOpt("shouFeiXmMc","浣撴璐�");
+//                        array.add(obj);
+//                    }
+//                    map.put("feiYongInfoList", array);
+//
+//                    String post = HttpClientUtils.sendPost(apiUrl + "/api/his/" + hospbm + "/creatCostInfo", map);
+//                    JSONObject object = JSONUtil.parseObj(post);
+//                    if (object.getInt("code") == 200) {
+//                        JSONObject data = object.getJSONObject("data");
+//                        tjFlowingWater.setHisWaterId(data.getStr("feiYongId"));
+//                        JSONArray mxList = data.getJSONArray("mxList");
+//                        if (mxList != null && !mxList.isEmpty()) {
+//                            List<TjFlowingWaterHis> his = mxList.toList(TjFlowingWaterHis.class);
+//                            tjFlowingWaterHisService.saveBatch(his);
+//                        }
+//                        tjFlowingWaterService.updateById(tjFlowingWater);
+//                    } else {
+//                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+//                        return AjaxResult.error();
+//                    }
+//                }
+//                return AjaxResult.success(tjNumber);
+//            }
 
-
-                String s = configService.selectConfigByKey("is_request_common_his_api");
-                if (null != s && s.equals("Y")) {
-                    String apiUrl = configService.selectConfigByKey("common_api_url");
-                    String hospbm = configService.selectConfigByKey("common_api_service_hospbm");
-                    HashMap<String, Object> map = new HashMap<>();
-                    map.put("pationId",tjCustomer.getPationId());
-                    map.put("cardId",tjCustomer.getHisJzkh());
-                    map.put("tjNum",tjFlowingWater.getTjSerialNumber());
-                    map.put("kaiDanKs","7805");
-                    // 鏀惰垂鏍囧織 1寰呭敭璐� 2寰呴��璐�
-                    map.put("shouTuiStatus","1");
-
-                    JSONArray array = JSONUtil.createArray();
-                    LambdaQueryWrapper<TbTransition> wrapper = new LambdaQueryWrapper<>();
-                    wrapper.eq(TbTransition::getTjNum,tjOrder.getTjNumber());
-                    wrapper.eq(TbTransition::getCusId,tjCustomer.getCusIdcard());
-                    wrapper.eq(TbTransition::getCardId,tjCustomer.getCardId());
-                    wrapper.isNotNull(TbTransition::getOrdPrice);
-                    wrapper.gt(TbTransition::getOrdPrice,0);
-
-                    List<TbTransition> list = tbTransitionService.list(wrapper);
-                    for (TbTransition transition : list) {
-                        LambdaQueryWrapper<TjProject> wrapper1 = new LambdaQueryWrapper<>();
-                        wrapper1.eq(TjProject::getProId,transition.getProId());
-                        TjProject project = projectService.getOne(wrapper1);
-
-                        LambdaQueryWrapper<SysDept> wrapper2 = new LambdaQueryWrapper<>();
-                        wrapper2.eq(SysDept::getDeptId,project.getDeptId());
-                        SysDept dept = sysDeptService.getOne(wrapper2);
-
-                        JSONObject obj = JSONUtil.createObj();
-                        Integer sl = project.getSl();
-                        BigDecimal danjia = transition.getOrdPrice();
-                        BigDecimal allPrice = danjia.multiply(new BigDecimal(sl));
-                        obj.putOpt("danJia",danjia);
-                        obj.putOpt("jieSuanJe",allPrice);
-                        obj.putOpt("shuliang",sl);
-                        obj.putOpt("zhiXingKs",dept.getDeptId());
-                        obj.putOpt("zhiXingKsMc",dept.getDeptName());
-                        obj.putOpt("shouFeiXmId",project.getHisXmbm());
-                        obj.putOpt("shouFeiXmMc",project.getHisXmmc());
-
-//                        obj.putOpt("zhiXingKs","7805");
-//                        obj.putOpt("zhiXingKsMc","浣撴绉�");
-//                        obj.putOpt("shouFeiXmId","4735346");
-//                        obj.putOpt("shouFeiXmMc","浣撴璐�");
-                        array.add(obj);
-                    }
-                    map.put("feiYongInfoList",array);
-
-                    String post = HttpClientUtils.sendPost(apiUrl + "/api/his/"+hospbm+"/creatCostInfo", map);
-                    JSONObject object = JSONUtil.parseObj(post);
-                    if (object.getInt("code") == 200) {
-                        JSONObject data = object.getJSONObject("data");
-                        tjFlowingWater.setHisWaterId(data.getStr("feiYongId"));
-                        JSONArray mxList = data.getJSONArray("mxList");
-                        if (mxList != null && mxList.size() > 0) {
-                            List<TjFlowingWaterHis> his = mxList.toList(TjFlowingWaterHis.class);
-                            tjFlowingWaterHisService.saveBatch(his);
-                        }
-                        tjFlowingWaterService.updateById(tjFlowingWater);
-                    }else {
-                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                        return AjaxResult.error();
-                    }
-                }
-            }
             // 鏌ヨ 瀵规帴Lis銆丳acs鐢宠濡傛灉绫诲瀷鍖呭惈鍦ㄩ厤缃唴鍒欎娇鐢ㄥ鎺is銆乸acs
+
+            log.info("绛惧埌鐧昏鎺ュ彛璇ヤ汉鍛�: "+tjOrder.getTjNumber()+" 鐨勪綋妫�绫诲瀷鏄�:"+tjOrder.getTjType());
             if (lisApiMethod.isUseLisAndPacsRegister(tjOrder)) {
-                // 杩欐槸涓婇潰涓汉鏂规硶寮曞叆鏁版嵁
-                tjFlowingWater.setPayStasus(1L);
-                newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
-//                AjaxResult ajaxResult = hisApiMethod.tijianshenqing(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder, sysUser, result);
-//                if (!ajaxResult.get("code").toString().equals("200")) return ajaxResult;
-                tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
-                        sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
-
-                List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
-                addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
-
+                try {
+                    log.info(tjOrder.getTjNumber()+"绛惧埌鐧昏杩涘叆鏈敹璐规柟娉�");
+                    // 杩欐槸涓婇潰涓汉鏂规硶寮曞叆鏁版嵁
+                    tjFlowingWater.setPayStasus(1L);
+                    newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
+                    tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
+                            sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
+                    remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString());
+                    List<TjXdPicture> xdPictureList = xdPictureService.saveTjXdPicture(tjOrder.getTjNumber());
+                    xdPictureService.saveBatch(xdPictureList);
+                    List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
+                    log.info(tjOrder.getTjNumber()+"绛惧埌鐧昏:閲囨牱鏁版嵁鏌ヨ涓暟"+detailList.size());
+                    addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
+                    return AjaxResult.success(tjNumber);
+                } catch (Exception e) {
+                    log.error(e.getMessage());
+                    throw new IllegalStateException(e);
+                }
+            } else {
+                try {
+                    log.info(tjOrder.getTjNumber()+"else绛惧埌鐧昏杩涘叆鏀惰垂鏂规硶");
+                    newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
+                    isRequestCommonHisApi(tjOrder, tjCustomer, tjFlowingWater);
+                } catch (Exception e) {
+//                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    log.error("processOrderWithTransaction 鏂规硶寮傚父"+e.getMessage());
+                    throw new RuntimeException("璋冪敤鍏叡鏂规硶澶辫触 寮哄埗瑙﹀彂鍥炴粴");
+//                    return AjaxResult.error();
+                }
+//                if (error != null) return error;
+//                List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
+//                addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
             }
-//            pacsApiMethodService.OrderAdd(tjCustomer,tjOrder);
+
             return AjaxResult.success(tjNumber);
+//            pacsApiMethodService.OrderAdd(tjCustomer,tjOrder);
+//            return AjaxResult.success(tjNumber);
         }
-        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-        return AjaxResult.error();
+//        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+        throw new RuntimeException("浣撴璁板綍淇濆瓨澶辫触 寮哄埗瑙﹀彂鍥炴粴");
     }
 
-    public void addCaiYangDengJi(List<TjOrderDetail> detailList, boolean detailList1, TjOrder order, SysUser sysUser, String jxbz) {
-        if (null != detailList && detailList1) {
-            Date date = new Date();
-            String format = DateUtil.format(date, "yyMMddHHmmssSSS");
-            for (TjOrderDetail detail : detailList) {
-                TjSampling sampling = new TjSampling();
-                if (null == projectService.getById(detail.getProId())) continue;
-                TjProject project = projectService.getById(detail.getProId());
-                Long proParentId = project.getProParentId();
-                String dictLabel = sysDictDataService.selectDictLabel("sys_dict_specimen", project.getSpecimenType());
-                if (null != proParentId && proParentId == 0) {
-                    sampling.setJyxh(idUtils.generateLisID());
-                    sampling.setSpecimenTypeCode(project.getSpecimenType());
-                    sampling.setSpecimenType(dictLabel);
-                    sampling.setJyxmdm(project.getProId().toString());
-                } else {
-                    TjProject project1 = projectService.getById(proParentId);
-                    sampling.setJyxh(idUtils.generateLisID());
+    @Transactional(propagation = Propagation.REQUIRED) // 鍏变韩浜嬪姟
+    public void isRequestCommonHisApi(TjOrder tjOrder, TjCustomer tjCustomer, TjFlowingWater tjFlowingWater) {
+        String s = configService.selectConfigByKey("is_request_common_his_api");
+        if (null != s && s.equals("Y")) {
+            String apiUrl = configService.selectConfigByKey("common_api_url");
+            String hospbm = configService.selectConfigByKey("common_api_service_hospbm");
+            HashMap<String, Object> map = new HashMap<>();
+            map.put("pationId", tjCustomer.getPationId());
+            map.put("cardId", tjCustomer.getHisJzkh());
+            map.put("tjNum", tjFlowingWater.getTjSerialNumber());
+            map.put("kaiDanKs", "7805");
+            // 鏀惰垂鏍囧織 1寰呭敭璐� 2寰呴��璐�
+            map.put("shouTuiStatus", "1");
 
-                    sampling.setSpecimenTypeCode(project1.getSpecimenType());
-                    sampling.setSpecimenType(dictLabel);
-                    sampling.setJyxmdm(project.getProId().toString());
+            JSONArray array = JSONUtil.createArray();
+            LambdaQueryWrapper<TbTransition> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(TbTransition::getTjNum, tjOrder.getTjNumber());
+            wrapper.eq(TbTransition::getCusId, tjCustomer.getCusIdcard());
+            wrapper.eq(TbTransition::getCardId, tjCustomer.getCardId());
+            wrapper.isNotNull(TbTransition::getNowPrice);
+            wrapper.gt(TbTransition::getNowPrice, 0);
 
+            List<TbTransition> list = tbTransitionService.list(wrapper);
+            BigDecimal zongjia = new BigDecimal("0.0");
+            for (TbTransition transition : list) {
+                LambdaQueryWrapper<TjProject> wrapper1 = new LambdaQueryWrapper<>();
+                wrapper1.eq(TjProject::getProId, transition.getProId());
+                TjProject project = projectService.getOne(wrapper1);
+
+                LambdaQueryWrapper<SysDept> wrapper2 = new LambdaQueryWrapper<>();
+                wrapper2.eq(SysDept::getDeptId, project.getDeptId());
+                SysDept dept = sysDeptService.getOne(wrapper2);
+
+                JSONObject obj = JSONUtil.createObj();
+//                Integer sl = project.getSl();
+                int sl = 1;
+                BigDecimal danjia = transition.getNowPrice();
+                BigDecimal allPrice = danjia.multiply(new BigDecimal(sl));
+                obj.putOpt("danJia", danjia);
+                obj.putOpt("jieSuanJe", allPrice);
+                obj.putOpt("shuliang", sl);
+                obj.putOpt("zhiXingKs", dept.getDeptId());
+                obj.putOpt("zhiXingKsMc", dept.getDeptName());
+                obj.putOpt("shouFeiXmId", project.getHisXmbm());
+                obj.putOpt("shouFeiXmMc", project.getHisXmmc());
+                array.add(obj);
+                zongjia = zongjia.add(allPrice);
+            }
+            map.put("feiYongInfoList", array);
+            log.info("璋冪敤His鎺ュ彛鍓� 鏀惰垂鎬讳环:{}", zongjia.toString());
+
+            String post = HttpClientUtils.sendPost(apiUrl + "/api/his/" + hospbm + "/creatCostInfo", map);
+            JSONObject object = JSONUtil.parseObj(post);
+            if (object.getInt("code") == 200) {
+                JSONObject data = object.getJSONObject("data");
+                tjFlowingWater.setHisWaterId(data.getStr("feiYongId"));
+                JSONArray mxList = data.getJSONArray("mxList");
+                if (mxList != null && !mxList.isEmpty()) {
+                    List<TjFlowingWaterHis> his = mxList.toList(TjFlowingWaterHis.class);
+                    tjFlowingWaterHisService.saveBatch(his);
                 }
-                sampling.setSamplingNumber(format);
-                sampling.setTjNum(order.getTjNumber());
-                sampling.setCusId(String.valueOf(order.getUserId()));
-                if (tjCustomerService.getById(String.valueOf(order.getUserId())) != null) {
-                    sampling.setCusName(tjCustomerService.getById(String.valueOf(order.getUserId())).getCusName());
-                }
-                sampling.setApplicationTime(date);
-                sampling.setTjTime(order.getCreateTime());
-                sampling.setProId(String.valueOf(detail.getProId()));
-                sampling.setProName(projectService.getById(detail.getProId()).getProName());
-                sampling.setCreateBy(sysUser.getNickName());
-                sampling.setCreateTime(date);
-                sampling.setUpdateBy(sysUser.getNickName());
-                sampling.setUpdateTime(date);
-                sampling.setCreateId(String.valueOf(sysUser.getUserId()));
-                sampling.setUpdateId(String.valueOf(sysUser.getUserId()));
-                sampling.setJxbz(jxbz);
-                samplingService.save(sampling);
+                tjFlowingWaterService.updateById(tjFlowingWater);
+            } else {
+//                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                log.error("isRequestCommonHisApi 鏂规硶寮傚父");
+                throw new RuntimeException("is_request_common_his_api 寮哄埗瑙﹀彂鍥炴粴");
+//                return AjaxResult.error();
             }
         }
-        String config = configService.selectConfigByKey("sfkqdyhis");
-        if (lisApiMethod.isUseLisAndPacsRegister(order) && (null != config && config.equals("Y"))) {
-            AjaxResult ajaxResult = lisApiMethod.getJyFlHb();
-            if (ajaxResult.get("code").toString().equals("200")) {
-                String str = ajaxResult.get("data").toString();
-                str = str.replace("=", ":");
-                JSONArray array = JSONUtil.parseArray(str);
-                for (Object o : array) {
-                    JSONObject object = (JSONObject) o;
-                    LisJyflhb lisJyflhb = new LisJyflhb();
-                    lisJyflhb.setHbhxm(object.getStr("hbhxm"));
-                    lisJyflhb.setFlmc(object.getStr("flmc"));
-                    lisJyflhb.setMc(object.getStr("mc"));
-                    lisJyflhb.setFlbm(object.getStr("flbm"));
-                    LambdaQueryWrapper<LisJyflhb> wrapper = new LambdaQueryWrapper<>();
-                    wrapper.eq(LisJyflhb::getFlbm, lisJyflhb.getFlbm());
-                    LisJyflhb jyflhb = lisJyflhbService.getOne(wrapper);
-                    if (jyflhb == null) {
-                        lisJyflhb.setId(IdUtil.getSnowflake().nextId());
-                        lisJyflhbService.save(lisJyflhb);
+//        return null;
+    }
+
+    @Transactional(propagation = Propagation.REQUIRED) // 鍏变韩浜嬪姟
+    public void addCaiYangDengJi(List<TjOrderDetail> detailList, boolean detailList1, TjOrder order, SysUser sysUser, String jxbz) {
+        try {
+            String lis_tmh_prefix = configService.selectConfigByKey("make_lis_tmh_prefix");
+            String config = configService.selectConfigByKey("sfkqdyhis");
+            Boolean lisAndPacsRegister = lisApiMethod.isUseLisAndPacsRegister(order);
+            if (null != detailList && detailList1) {
+                Date date = new Date();
+                String format = DateUtil.format(date, "yyMMddHHmmssSSS");
+                for (TjOrderDetail detail : detailList) {
+                    int i = samplingService.isExistProId(order.getTjNumber(), String.valueOf(detail.getProId()));
+                    if(i>0) continue;
+                    TjSampling sampling = new TjSampling();
+                    if (null == projectService.getById(detail.getProId())) continue;
+                    TjProject project = projectService.getById(detail.getProId());
+                    Long proParentId = project.getProParentId();
+                    String dictLabel = sysDictDataService.selectDictLabel("sys_dict_specimen", project.getSpecimenType());
+                    if (null != proParentId && proParentId == 0) {
+                        sampling.setJyxh(idUtils.generateLisID(lis_tmh_prefix));
+                        sampling.setSpecimenTypeCode(project.getSpecimenType());
+                        sampling.setSpecimenType(dictLabel);
+                        if (config.equals("Y") && lisAndPacsRegister)
+                            sampling.setJyxmdm(project.getLisXmbm());
+                        else sampling.setJyxmdm(project.getProId().toString());
                     } else {
-                        lisJyflhb.setId(jyflhb.getId());
-                        lisJyflhbService.updateById(lisJyflhb);
+                        TjProject project1 = projectService.getById(proParentId);
+                        sampling.setJyxh(idUtils.generateLisID(lis_tmh_prefix));
+
+                        sampling.setSpecimenTypeCode(project1.getSpecimenType());
+                        sampling.setSpecimenType(dictLabel);
+                        if (config.equals("Y") && lisAndPacsRegister)
+                            sampling.setJyxmdm(project1.getLisXmbm());
+                        else sampling.setJyxmdm(project1.getProId().toString());
+
+                    }
+                    sampling.setSamplingNumber(format);
+                    sampling.setTjNum(order.getTjNumber());
+                    sampling.setCusId(String.valueOf(order.getUserId()));
+                    if (tjCustomerService.getById(String.valueOf(order.getUserId())) != null) {
+                        sampling.setCusName(tjCustomerService.getById(String.valueOf(order.getUserId())).getCusName());
+                    }
+                    sampling.setApplicationTime(date);
+                    sampling.setTjTime(order.getCreateTime());
+                    sampling.setProId(String.valueOf(detail.getProId()));
+                    sampling.setProName(projectService.getById(detail.getProId()).getProName());
+                    sampling.setCreateBy(sysUser.getNickName());
+                    sampling.setCreateTime(date);
+                    sampling.setUpdateBy(sysUser.getNickName());
+                    sampling.setUpdateTime(date);
+                    sampling.setCreateId(String.valueOf(sysUser.getUserId()));
+                    sampling.setUpdateId(String.valueOf(sysUser.getUserId()));
+                    sampling.setJxbz(jxbz);
+                    samplingService.save(sampling);
+                }
+            }
+            if (lisApiMethod.isUseLisAndPacsRegister(order) && (null != config && config.equals("Y"))) {
+                AjaxResult ajaxResult = lisApiMethod.getJyFlHb();
+                if (ajaxResult.get("code").toString().equals("200")) {
+                    String str = ajaxResult.get("data").toString();
+                    str = str.replace("=", ":");
+                    JSONArray array = JSONUtil.parseArray(str);
+                    for (Object o : array) {
+                        JSONObject object = (JSONObject) o;
+                        LisJyflhb lisJyflhb = new LisJyflhb();
+                        lisJyflhb.setHbhxm(object.getStr("hbhxm"));
+                        lisJyflhb.setFlmc(object.getStr("flmc"));
+                        lisJyflhb.setMc(object.getStr("mc"));
+                        lisJyflhb.setFlbm(object.getStr("flbm"));
+                        LambdaQueryWrapper<LisJyflhb> wrapper = new LambdaQueryWrapper<>();
+                        wrapper.eq(LisJyflhb::getFlbm, lisJyflhb.getFlbm());
+                        LisJyflhb jyflhb = lisJyflhbService.getOne(wrapper);
+                        if (jyflhb == null) {
+                            lisJyflhb.setId(IdUtil.getSnowflake().nextId());
+                            lisJyflhbService.save(lisJyflhb);
+                        } else {
+                            lisJyflhb.setId(jyflhb.getId());
+                            lisJyflhbService.updateById(lisJyflhb);
+                        }
                     }
                 }
-            }
 
+            }
+            if (StrUtil.isNotBlank(jxbz)) {
+                tjSamplingMapper.updateUserIdByTjNumAndJxbz(order.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), jxbz);
+            } else {
+                tjSamplingMapper.updateUserIdByTjNum(order.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()));
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage());
         }
+    }
+
+
+
+    @GetMapping("/addCaiYangDengJi")
+    @ApiOperation(value = "鎵嬪姩娣诲姞閲囨牱璁板綍鎺ュ彛")
+    public AjaxResult addCaiYangDengJi(@RequestParam("tjNum") String tjNum){
+
+        try {
+            TjOrder order = tjOrderService.getOrderByTjNum(tjNum);
+            if(null !=order){
+                Long userId = Long.valueOf(SecurityUtils.getLoginUser().getUserId());
+                SysUser sysUser = userService.getById(userId);
+                List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(order.getOrderId());
+                log.info("绛惧埌鐧昏:閲囨牱鏁版嵁鏌ヨ涓暟"+detailList.size());
+                addCaiYangDengJi(detailList, !detailList.isEmpty(), order, sysUser, null);
+            }
+        } catch (NumberFormatException e) {
+            log.error(String.valueOf(e));
+        }
+
+        return AjaxResult.success();
     }
 
 
     @PostMapping("/addPlOrderAndDetail")
     @ApiOperation(value = "浣撴鎵归噺绛惧埌鐧昏鎺ュ彛")
-    @Transactional  //(鍒囨崲鏁版嵁搴撳嚭閿欙紝鎵�浠ユ敞閲�)
+//    @Transactional  //(鍒囨崲鏁版嵁搴撳嚭閿欙紝鎵�浠ユ敞閲�)
     public AjaxResult addPlOrderAndDetail(@RequestBody QianDaoDto daoDto, HttpServletResponse response) {
         SysUser sysUser = UserHoder.getLoginUser().getUser();
         List<String> cusIds = daoDto.getCusIds();
         ArrayList<String> tjNumbers = new ArrayList<>();
+        ArrayList<String> errTjh = new ArrayList<>();
         if (null != cusIds && !cusIds.isEmpty()) {
             ExecutorService threadPools = Executors.newFixedThreadPool(cusIds.size());
             for (String cusId : cusIds) {
-                threadPools.execute(new Runnable() {
-                    @Override
-                    public void run() {
-                        getAjaxResults(cusId);
-                    }
-                });
+
+//                threadPools.execute(new Runnable() {
+//                    @Override
+//                    public void run() {
+                        try {
+                            getAjaxResults(cusId);
+                        } catch (Exception e) {
+
+                        }
+//                    }
+//                });
             }
             LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>();
             wq.in(TjCustomer::getCusIdcard, cusIds);
@@ -1432,6 +1649,7 @@
 //                            }
 //                        }
 //                    });
+
                     Future<AjaxResult> future = executor.submit(new Callable<AjaxResult>() {
                         @Override
                         public AjaxResult call() throws Exception {
@@ -1440,61 +1658,106 @@
                     });
                     try {
                         AjaxResult result = future.get();
-                        String tjNumber = result.get("tjNumber").toString();
-                        tjNumbers.add(tjNumber);
+                        String code = result.get("code").toString();
+                        if (code.equals("200")) {
+                            String tjNumber = result.get("tjNumber").toString();
+                            tjNumbers.add(tjNumber);
+                        }else {
+                            String userId = result.get("userId").toString();
+                            errTjh.add(userId);
+                        }
                     } catch (InterruptedException | ExecutionException e) {
+//                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                         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++) {
+            // TODO 鍥犱负鏈変綋妫�鍙蜂細鏌ュ嚭绌烘暟鎹� 鍏堜娇鐢ㄦ鏁版嵁  鎵撳嵃瀵艰瘖鍗�
+            if (!tjNumbers.isEmpty()) {
+            /*    Map<String, Object> map = null;
                 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);
+                    map = PDFDocumentUtil.getDocument();
+                    Document document = (Document) map.get("document");
+//                    for (int i = 0; i < tjNumbers.size(); i++) {
+                    int i = 0;
+                    for (String tjNumber : tjNumbers) {
+                        try {
+                            List<Map<String, Object>> djdInfos = tjOrderService.selectDjdInfo(tjNumber);
+                            Map<String, Object> userInfo = tjOrderService.selectDjdUserInfo(tjNumber);
+                            if(null !=userInfo && null !=djdInfos && !djdInfos.isEmpty()){
+                                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) {
+                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                            //杩欓噷鍒犻櫎鐨勬槸杩欎釜浜烘墍鏈夐」鐩寘鎷ˉ褰曢」鐩�
+                            TjOrder order = tjOrderService.getOrderByTjNum(tjNumber);
+                            tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
+                            tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId()));
+                            remarkService.deletedOrderRemarkByTjNum(tjNumber);
+                            tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId()));
+//                transitionService.deletedTbTransitionByTjNum(tjNum);
+                            tjSamplingMapper.deleteByTjNumAndCusId(order.getTjNumber(), order.getUserId());
+
+                            TjReservation reservation = tjReservationService.getById(order.getReservationId());
+                            if(null !=reservation){
+                                reservation.setIsExpire(2);
+                                tjReservationService.updateById(reservation);
+                                transitionService.updateTbTransitionByTjNum(tjNumber);
+                            }
+                            e.printStackTrace();
+                        }
                     }
-                    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) {
+
+//                    }
+                    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) {
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                     e.printStackTrace();
-                }
+                }*/
+                Map<String,Object> map=new HashMap<>();
+                map.put("tjh",tjNumbers);
+                return AjaxResult.success("鎿嶄綔鎴愬姛",map);
             }
-            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();
+            if (!errTjh.isEmpty()){
+                Map<String,Object> map=new HashMap<>();
+                map.put("errtjh",errTjh);
+                return AjaxResult.success("浠ヤ笂浜哄憳绛惧埌澶辫触",map);
+            }
+            return AjaxResult.error();
         }
-        return AjaxResult.success("鎿嶄綔鎴愬姛");
+//        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+        return AjaxResult.error();
     }
 
-    private void getAjaxResults(String cusIdcard) {
+    @GetMapping("/signOrderInfo")
+    public AjaxResult signOrderInfo(@RequestParam("tjNum") String tjNum){
+        List<Map<String, Object>> djdInfos = tjOrderService.selectDjdInfo(tjNum);
+        Map<String, Object> userInfo = tjOrderService.selectDjdUserInfo(tjNum);
+        HashMap<String, Object> hashMap = new HashMap<>();
+        hashMap.put("djd",djdInfos);
+        hashMap.put("user",userInfo);
+        return AjaxResult.success(hashMap);
+    }
+
+    @Transactional
+    public void getAjaxResults(String cusIdcard) {
         if (!"".equals(cusIdcard) && cusIdcard != null) {
             //鏍规嵁閰嶇疆璋冨彇瀛樺偍杩囩▼ 灏嗕复鏃惰〃鏁版嵁瀛樺叆棰勭害琛�2023.12.12
             final String getInfoFromSqlData = configService.selectConfigByKey("getInfoFromSqlData");
@@ -1556,51 +1819,59 @@
                     tjReservationService.updateById(tjReservation);
 //                    return AjaxResult.error("瀵逛笉璧锋偍鐨勯绾﹀凡瓒呮椂璇烽噸鏂伴绾�");
                 }*/
-                LambdaQueryWrapper<TjCustomer> qw = new LambdaQueryWrapper<>();
-                qw.eq(TjCustomer::getCusIdcard, cusIdcard);
-                TjCustomer tjCustomer1 = tjCustomerService.getOne(qw);
-                if (tjCustomer1 != null) {
-                    tjCustomer1.setTjType(tjReservation.getTjType());
-                    tjCustomer1.setCusName(tjReservation.getName());
-                    tjCustomer1.setCusSex(Long.valueOf(tjReservation.getSex()));
-                    tjCustomer1.setCusBrithday(tjReservation.getBirthday());
-                    tjCustomer1.setCusPhone(tjReservation.getPhoe());
-                    tjCustomer1.setCusEmail(tjReservation.getEmail());
-                    tjCustomer1.setCusAddr(tjReservation.getAddress());
-                    tjCustomer1.setCusMarryStatus(String.valueOf(tjReservation.getMarriage()));
-                    tjCustomer1.setCusNational(String.valueOf(tjReservation.getNation()));
-                    tjCustomer1.setIdType(tjReservation.getIdType());
-                    tjCustomer1.setAge(tjReservation.getAge());
-                    tjCustomer1.setAgeUnit(tjReservation.getAgeUnit());
-                    tjCustomer1.setCareer(tjReservation.getCareer());
-                    tjCustomerService.updateById(tjCustomer1);
-                } else {
-                    TjCustomer tjCustomer = new TjCustomer();
-                    tjCustomer.setCusIdcard(tjReservation.getIdCard());
-                    tjCustomer.setCusName(tjReservation.getName());
-                    tjCustomer.setCusSex(Long.valueOf(tjReservation.getSex()));
-                    tjCustomer.setCusBrithday(tjReservation.getBirthday());
-                    tjCustomer.setCusPhone(tjReservation.getPhoe());
-                    tjCustomer.setCusEmail(tjReservation.getEmail());
-                    tjCustomer.setCusAddr(tjReservation.getAddress());
-                    tjCustomer.setCusMarryStatus(String.valueOf(tjReservation.getMarriage()));
-                    tjCustomer.setCusNational(String.valueOf(tjReservation.getNation()));
-                    tjCustomer.setIdType(tjReservation.getIdType());
-                    tjCustomer.setAge(tjReservation.getAge());
-                    tjCustomer.setAgeUnit(tjReservation.getAgeUnit());
-                    tjCustomer.setCareer(tjReservation.getCareer());
-                    tjCustomer.setDwPhone(tjReservation.getDwPhone());
-                    tjCustomer.setCardId(tjReservation.getCardId());
-                    tjCustomer.setIndexCard(tjReservation.getIndexCard());
-                    //鎴彇瀵嗙爜鑷姩鐢熸垚set杩涘幓
-                    String substring = cusIdcard.substring(cusIdcard.length() - 6);
-                    substring = DigestUtils.md5DigestAsHex(substring.getBytes());
-                    tjCustomer.setCusPassword(substring);
-                    tjCustomer.setTjType(tjReservation.getTjType());
-                    tjCustomerService.save(tjCustomer);
+                try {
+                    LambdaQueryWrapper<TjCustomer> qw = new LambdaQueryWrapper<>();
+                    qw.eq(TjCustomer::getCusIdcard, cusIdcard);
+                    TjCustomer tjCustomer1 = tjCustomerService.getOne(qw);
+                    if (tjCustomer1 != null) {
+                        tjCustomer1.setTjType(tjReservation.getTjType());
+                        tjCustomer1.setCusName(tjReservation.getName());
+                        tjCustomer1.setCusSex(Long.valueOf(tjReservation.getSex()));
+                        tjCustomer1.setCusBrithday(tjReservation.getBirthday());
+                        tjCustomer1.setCusPhone(tjReservation.getPhoe());
+                        tjCustomer1.setCusEmail(tjReservation.getEmail());
+                        tjCustomer1.setCusAddr(tjReservation.getAddress());
+                        tjCustomer1.setCusMarryStatus(String.valueOf(tjReservation.getMarriage()));
+                        tjCustomer1.setCusNational(String.valueOf(tjReservation.getNation()));
+                        tjCustomer1.setIdType(tjReservation.getIdType());
+                        tjCustomer1.setAge(tjReservation.getAge());
+                        tjCustomer1.setAgeUnit(tjReservation.getAgeUnit());
+                        tjCustomer1.setCareer(tjReservation.getCareer());
+                        tjCustomerService.updateById(tjCustomer1);
+                    } else {
+                        TjCustomer tjCustomer = new TjCustomer();
+                        tjCustomer.setCusIdcard(tjReservation.getIdCard());
+                        tjCustomer.setCusName(tjReservation.getName());
+                        tjCustomer.setCusSex(Long.valueOf(tjReservation.getSex()));
+                        tjCustomer.setCusBrithday(tjReservation.getBirthday());
+                        tjCustomer.setCusPhone(tjReservation.getPhoe());
+                        tjCustomer.setCusEmail(tjReservation.getEmail());
+                        tjCustomer.setCusAddr(tjReservation.getAddress());
+                        tjCustomer.setCusMarryStatus(String.valueOf(tjReservation.getMarriage()));
+                        tjCustomer.setCusNational(String.valueOf(tjReservation.getNation()));
+                        tjCustomer.setIdType(tjReservation.getIdType());
+                        tjCustomer.setAge(tjReservation.getAge());
+                        tjCustomer.setAgeUnit(tjReservation.getAgeUnit());
+                        tjCustomer.setCareer(tjReservation.getCareer());
+                        tjCustomer.setDwPhone(tjReservation.getDwPhone());
+                        tjCustomer.setCardId(tjReservation.getCardId());
+                        tjCustomer.setIndexCard(tjReservation.getIndexCard());
+                        //鎴彇瀵嗙爜鑷姩鐢熸垚set杩涘幓
+                        String substring = cusIdcard.substring(cusIdcard.length() - 6);
+                        substring = DigestUtils.md5DigestAsHex(substring.getBytes());
+                        tjCustomer.setCusPassword(substring);
+                        tjCustomer.setTjType(tjReservation.getTjType());
+                        tjCustomerService.save(tjCustomer);
+                    }
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
                 }
+            }else {
+                throw new RuntimeException();
             }
 
+        }else {
+            throw new RuntimeException();
         }
     }
 
@@ -1628,25 +1899,13 @@
         DynamicDataSourceContextHolder.clearDataSourceType();
     }
 
-    private AjaxResult getAjaxResult(Long userId, SysUser sysUser, String tjCategory) throws IOException {
+    @Transactional
+    public AjaxResult getAjaxResult(Long userId, SysUser sysUser, String tjCategory) throws IOException {
 
         LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>();
         wq.eq(TjCustomer::getCusId, userId);
         TjCustomer tjCustomer = tjCustomerService.getOne(wq);
         if (tjCustomer == null) return AjaxResult.error("璇ュ鎴锋湭鐧昏鎴栦笉瀛樺湪");
-
-        LambdaQueryWrapper<TjOrder> wqq = new LambdaQueryWrapper<>();
-        wqq.eq(TjOrder::getUserId, userId);
-        wqq.eq(TjOrder::getCheckStatus, 0);
-        wqq.isNull(TjOrder::getFinishTime);
-        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("涓嶅彲閲嶅鐧昏");
-        }
         TjOrder tjOrder = new TjOrder();
         Date date = new Date();
         tjOrder.setCreateTime(date);
@@ -1663,16 +1922,17 @@
         if (tjReservation != null) {
             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())) {
-                tjReservation.setIsExpire(1);
-                tjReservationService.updateById(tjReservation);
-                return AjaxResult.error("瀵逛笉璧锋偍鐨勯绾﹀凡瓒呮椂璇烽噸鏂伴绾�");
-            }
+//            if (DateUtil.endOfDay(new Date()).before(tjReservation.getReservationTime())) {
+//                return AjaxResult.error("鏈埌棰勭害鏃堕棿");
+//            }
+//            if (DateUtil.endOfDay(tjReservation.getReservationTime()).before(new Date())) {
+//                tjReservation.setIsExpire(1);
+//                tjReservationService.updateById(tjReservation);
+//                return AjaxResult.error("瀵逛笉璧锋偍鐨勯绾﹀凡瓒呮椂璇烽噸鏂伴绾�");
+//            }
             if (null != tjReservation.getTeamNo()) tjOrder.setTeamNo(tjReservation.getTeamNo());
             if (null != tjReservation.getCompanyId()) tjOrder.setFirmId(tjReservation.getCompanyId());
+            if (null != tjReservation.getCompany()) tjOrder.setFirmName(tjReservation.getCompany());
             if (null != tjReservation.getDepartment()) tjOrder.setFirmDeptName(tjReservation.getDepartment());
             if (null != tjReservation.getJobNo()) tjOrder.setFirmWorkId(tjReservation.getJobNo());
             if (null != tjReservation.getPacId()) tjOrder.setPacId(tjReservation.getPacId());
@@ -1683,12 +1943,48 @@
             }
             tjReservation.setIsExpire(1);
             tjReservationService.updateById(tjReservation);
+            if (null != tjReservation.getTeamNo()) {
+                tjOrder.setTjType("1");
+            } else{
+                tjOrder.setTjType("2");
+            }
+
+        if (StringUtil.isBlank(tjOrder.getFirmId())) {
+            tjOrder.setFirmId("0");
+        }
+//
+//            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(".{6}$", userId.toString().substring(userId.toString().length() - 6));
 
-            tjNumber = tjNumber.replaceAll(".{4}$", userId.toString().substring(userId.toString().length() - 4));
 
+            //鑾峰彇鎷兼帴鍓嶇紑
+            String makeLisTmhPrefix = configService.selectConfigByKey("make_lis_tmh_prefix");
+//            String tjNumber = (sysUser.getUserName() + idUtils.getTjNumber());
+//            String tjNumber = idUtils.getTjNumber();
+            String tjNumber = idUtils.getNewTjNumberRedisLockAndMysql();
+            if (StringUtil.isNotBlank(makeLisTmhPrefix)) tjNumber = makeLisTmhPrefix + tjNumber;
+
+
+//            if (redisCache.hasKey(TJH)) {
+//                while (true){
+//                    List<String> tjh = redisCache.getCacheList(TJH);
+//                    if(tjh.contains(tjNumber)){
+//                        tjNumber =(sysUser.getUserName() + IdUtils.getTjNumber());
+//                        if (StringUtil.isNotBlank(makeLisTmhPrefix)) tjNumber = makeLisTmhPrefix + tjNumber;
+//                    }else {
+//                        tjh.add(tjNumber);
+//                    }
+//                }
+//            }else {
+//                List<String> stringList = tjOrderService.
+//                        list(new LambdaQueryWrapper<TjOrder>().select(TjOrder::getTjNumber)).stream().map(TjOrder::getTjNumber).collect(Collectors.toList());
+//                stringList.add(tjNumber);
+//                redisCache.setCacheList(TJH,stringList);
+//            }
             tjOrder.setTjNumber(tjNumber);
             if (null != tjOrder.getPhoto()) {
                 File file = new File(tjOrder.getPhoto());
@@ -1729,6 +2025,21 @@
                 tjCustomer.setCusNumber(cusNumber);
 //            BigDecimal discount = BigDecimal.valueOf(Double.parseDouble(tjOrder.getTjFlowingWater().getDiscount())).divide(BigDecimal.valueOf(10));
                 TjFlowingWater tjFlowingWater = new TjFlowingWater();
+                tjFlowingWater.setCreateTime(date);
+                tjFlowingWater.setCreateTime(date);
+                tjFlowingWater.setUpdateTime(date);
+                tjFlowingWater.setCreateBy(sysUser.getNickName());
+                tjFlowingWater.setUpdateBy(sysUser.getNickName());
+//                BigDecimal bigDecimal = tbTransitionMapper.sumTbTransitionOrdPriceByTjNum(tjOrder.getTjNumber());
+                BigDecimal bigDecimal = tbTransitionMapper.sumTbTransitionOrdPriceByTjNumIsNull(tjCustomer.getCusIdcard());
+                tjFlowingWater.setCopeWith(bigDecimal);
+//                BigDecimal bigDecimal1 = tbTransitionMapper.sumTbTransitionNowPriceByTjNum(tjOrder.getTjNumber());
+                BigDecimal bigDecimal1 = tbTransitionMapper.sumTbTransitionNowPriceByTjNumIsNull(tjCustomer.getCusIdcard());
+                tjFlowingWater.setPaidIn(bigDecimal1);
+                tjFlowingWater.setDiscount(String.valueOf(10));
+                tjFlowingWater.setPayStasus(1L);
+                tjFlowingWater.setPayType(3L);
+
                 tjFlowingWater.setPayStasus(0L);
                 if ("1".equals(tjOrder.getTjType())) {
                     if (tjReservation.getPayType() == 1) {
@@ -1777,18 +2088,38 @@
                 if (tjFlowingWaterService.save(tjFlowingWater)) {
                     tjOrder.setTjSerialNumber(String.valueOf(tjFlowingWater.getTjSerialNumber()));
                     tjOrderService.updateById(tjOrder);
-
-
                 }
-                asyncService.ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
+                transitionService.updateTbTransitionTjNumByCusId(tjCustomer.getCusIdcard(), tjOrder.getTjNumber());
+                tjCustomer.setCardId(tjOrder.getTjNumber());
+                tjCustomerService.updateById(tjCustomer);
+                transitionService.updateCardIdByTjNumAndIdCard(tjCustomer.getCusIdcard(), tjOrder.getTjNumber(), tjOrder.getTjNumber());
+                tjOrder.setCardId(tjOrder.getTjNumber());
+                tjOrderService.updateById(tjOrder);
 
+//                asyncService.ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
+
+                if (lisApiMethod.isUseLisAndPacsRegister(tjOrder)) {
+                    // 杩欐槸涓婇潰涓汉鏂规硶寮曞叆鏁版嵁
+                    tjFlowingWater.setPayStasus(1L);
+                    tjOrder.setTjFlowingWater(tjFlowingWater);
+                    newSaveextracted(tjOrder, tjCustomer, BigDecimal.valueOf(10), sysUser, tjReservation, tjFlowingWater);
+                    tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
+                            sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
+                    remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString());
+                    List<TjXdPicture> xdPictureList = xdPictureService.saveTjXdPicture(tjOrder.getTjNumber());
+                    xdPictureService.saveBatch(xdPictureList);
+                    List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
+                    addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
+//                    return AjaxResult.success(tjNumber);
+                }
 
                 tjCustomer.setCardId("0");
                 tjCustomerService.updateById(tjCustomer);
                 return AjaxResult.success().put("tjNumber", tjNumber);
             }
         }
-        return AjaxResult.error();
+        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+        return AjaxResult.error().put("userId",userId);
     }
 
 
@@ -1876,6 +2207,17 @@
                         return AjaxResult.error("鎿嶄綔澶辫触! 浠ヤ笅椤圭洰宸插瓨鍦�: " + string);
                     }
                     transitionService.saveRedisTransitionByPacId(cusId, cardId, pacId);
+
+                    //琛ュ樊浠�
+                    List<Map<String, Object>> cjMaps = transitionService.addTbhuoquxiangmuchajia(pacId.toString(), cusId);
+                    if (null != cjMaps && !cjMaps.isEmpty()) {
+                        log.info("璇ュ椁�"+pacId+"涓湁宸环:"+cjMaps.size()+"涓�");
+                        for (Map<String, Object> cjMap : cjMaps) {
+                            log.info("娣诲姞涓存椂琛ㄥ椁愭暟鎹椂鎵�閫夌殑宸环涓�:"+ cjMap.get("cj").toString());
+                            transitionService.buxiangmuchajia(cusId, pacId.toString(), cjMap.get("xmid").toString(), new BigDecimal(cjMap.get("cj").toString()));
+                        }
+                    }
+
                 }
             }
         }
@@ -2187,11 +2529,7 @@
     private List<Map<String, Object>> getMaps(String cusId, String cardId) {
 
         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<>();
@@ -2201,23 +2539,26 @@
             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", transitionService.getTbTransitionDxPriceByPac(cusId, entry.getKey(), cardId, pacId));
+                if (null != aPackage) {
+                    map.put("tjCategory", aPackage.getTjCategory());
+                    map.put("pacName", aPackage.getPacName());
+                    TjProject tjProject = projectService.getById(entry.getKey());
+                    map.put("ordPrice", tjProject.getProPrice());
+                    map.put("nowPrice", transitionService.getTbTransitionDxPriceByPac(cusId, entry.getKey(), cardId, pacId));
+                } else {
+                    TjDwGrouping grouping = dwGroupingService.getById(pacId);
+                    map.put("tjCategory", null);
+                    map.put("pacName", grouping.getGroupingName());
+                    TjProject tjProject = projectService.getById(entry.getKey());
+                    map.put("ordPrice", tjProject.getProPrice());
+                    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) {
+                if (null != tbTransitionList && !tbTransitionList.isEmpty()) {
                     BigDecimal money1 = new BigDecimal("0.00");
                     BigDecimal money2 = new BigDecimal("0.00");
                     for (TbTransition tbTransition : tbTransitionList) {
@@ -2506,9 +2847,9 @@
     @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")
+        wrapper.select("parent_pro_id", "parent_pro_name", "sum(now_price) as ord_price")
                 .eq("tj_num", tjNumber)
-                .groupBy("parent_pro_name");
+                .groupBy("parent_pro_id");
         List<TbTransition> list = transitionService.list(wrapper);
         List<Long> parentProIds = list.stream().map(item -> item.getParentProId()).collect(Collectors.toList());
         LambdaQueryWrapper<TjProject> projectQueryWrapper = new LambdaQueryWrapper<>();
@@ -2562,40 +2903,51 @@
     }
 
 
+    @Transactional(propagation = Propagation.REQUIRED) // 鍏变韩浜嬪姟
     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()));
-        if (null != tjOrder.getTjCategory() && tjOrder.getTjCategory().equals("13")) {
-            tjOrderDetailService.saveJSYTjOrderDetailsByCusId(tjCustomer.getCusIdcard(),
-                    String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), tjOrder.getCardId(), String.valueOf(tjFlowingWater.getTjSerialNumber()));
-        } else {
-            tjOrderDetailService.saveTjOrderDetailsByCusId(tjCustomer.getCusIdcard(), String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), tjOrder.getCardId());
-        }
+        try {
+            tjAskMedicalHistoryService.updateTjAskMedicalHistoryByCusId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjCustomer.getCusId()));
+            if (null != tjOrder.getTjCategory() && tjOrder.getTjCategory().equals("13")) {
+                tjOrderDetailService.saveJSYTjOrderDetailsByCusId(tjCustomer.getCusIdcard(),
+                        String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), tjOrder.getCardId(), String.valueOf(tjFlowingWater.getTjSerialNumber()));
+            } 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());
+            tjOrderDetailService.saveTjPureToneTesByCusId(tjCustomer.getCusIdcard(), tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), tjOrder.getCardId());
 
-        //娣诲姞remark琛ㄦ暟鎹�
-        if (null != tjOrder.getTjCategory() && tjOrder.getTjCategory().equals("13")) {
-            remarkService.saveJSYTjOrderRemarkByOrderId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjOrder.getOrderId()));
+            //娣诲姞remark琛ㄦ暟鎹�
+            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()));
+            } 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) {
+            }
+            //鍒ゆ柇鏄惁浜ら挶
+            if ("1".equals(tjOrder.getTjType())) {
+                if (null != tjReservation && tjReservation.getPayType() == 1) {
+                    tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
+                            sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
+                    remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString());
+                    List<TjXdPicture> xdPictureList = xdPictureService.saveTjXdPicture(tjOrder.getTjNumber());
+                    xdPictureService.saveBatch(xdPictureList);
+                }
+            }
+            if (tjFlowingWater.getPayStasus() == 1L) {
                 tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
                         sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
+                tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn());
+                tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith());
+                tjFlowingWater.setPayType(4L);
+                tjFlowingWaterService.updateById(tjFlowingWater);
+                remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString());
+    //            asyncService.addTjChargingStandard(tjOrder, transitionService.getTbTransitionListByCusId(tjCustomer.getCusIdcard(), tjOrder.getCardId()), sysUser);
+                List<TjXdPicture> xdPictureList = xdPictureService.saveTjXdPicture(tjOrder.getTjNumber());
+                xdPictureService.saveBatch(xdPictureList);
             }
-        }
-        if (tjFlowingWater.getPayStasus() == 1L) {
-            tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
-                    sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
-            tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn());
-            tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith());
-            tjFlowingWater.setPayType(4L);
-            tjFlowingWaterService.updateById(tjFlowingWater);
-//            asyncService.addTjChargingStandard(tjOrder, transitionService.getTbTransitionListByCusId(tjCustomer.getCusIdcard(), tjOrder.getCardId()), sysUser);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
         }
     }
 
@@ -2605,49 +2957,49 @@
         tjAskMedicalHistoryService.updateTjAskMedicalHistoryByCusId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjCustomer.getCusId()));
         boolean b = tjOrderDetailService.saveTjOrderDetailsByCusId(tjCustomer.getCusIdcard(), String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(),
                 String.valueOf(sysUser.getUserId()), tjOrder.getCardId());
-        if (!b) {
-            List<TjGroupingPro> proList = groupingProService.list(new LambdaQueryWrapper<TjGroupingPro>().eq(TjGroupingPro::getGroupingId, tjOrder.getGroupId()));
-            if (null != proList && !proList.isEmpty()) {
-                for (TjGroupingPro groupingPro : proList) {
-                    TjOrderDetail detail = new TjOrderDetail();
-                    TjProject tjProject = projectService.selectTjProjectByProId(Long.valueOf(groupingPro.getProId()));
-                    detail.setIsSampling(String.valueOf(tjProject.getIsSampling()));
-                    detail.setOrderId(tjOrder.getOrderId());
-                    detail.setProId(Long.valueOf(groupingPro.getProId()));
-                    detail.setTjStatus(0L);
-                    detail.setCreateBy(sysUser.getNickName());
-                    detail.setCreateTime(new Date());
-                    detail.setUpdateBy(sysUser.getNickName());
-                    detail.setUpdateTime(new Date());
-                    detail.setCreateId(String.valueOf(sysUser.getUserId()));
-                    detail.setUpdateId(String.valueOf(sysUser.getUserId()));
-                    tjOrderDetailService.save(detail);
-                }
-                List<String> list = proList.stream().map(TjGroupingPro::getProId).collect(Collectors.toList());
-                List<TjProject> projectList = projectService.list(new LambdaQueryWrapper<TjProject>().in(TjProject::getProParentId, list));
-                for (TjProject project : projectList) {
-                    TjOrderDetail detail = new TjOrderDetail();
-                    detail.setOrderId(tjOrder.getOrderId());
-                    detail.setProId(project.getProId());
-                    detail.setTjStatus(0L);
-                    detail.setCreateBy(sysUser.getNickName());
-                    detail.setCreateTime(new Date());
-                    detail.setUpdateBy(sysUser.getNickName());
-                    detail.setUpdateTime(new Date());
-                    detail.setCreateId(String.valueOf(sysUser.getUserId()));
-                    detail.setUpdateId(String.valueOf(sysUser.getUserId()));
-                    //鑾峰彇璇ラ」鐩殑榛樿鍊艰祴鍊肩粰缁撴灉
-                    if (null != project.getProDefault()) {
-                        detail.setProResult(project.getProDefault());
-                    } else {
-                        detail.setProResult(null);
-                    }
-                    detail.setIsSampling(String.valueOf(project.getIsSampling()));
-
-                    tjOrderDetailService.save(detail);
-                }
-            }
-        }
+//        if (!b) {
+//            List<TjGroupingPro> proList = groupingProService.list(new LambdaQueryWrapper<TjGroupingPro>().eq(TjGroupingPro::getGroupingId, tjOrder.getGroupId()));
+//            if (null != proList && !proList.isEmpty()) {
+//                for (TjGroupingPro groupingPro : proList) {
+//                    TjOrderDetail detail = new TjOrderDetail();
+//                    TjProject tjProject = projectService.selectTjProjectByProId(Long.valueOf(groupingPro.getProId()));
+//                    detail.setIsSampling(String.valueOf(tjProject.getIsSampling()));
+//                    detail.setOrderId(tjOrder.getOrderId());
+//                    detail.setProId(Long.valueOf(groupingPro.getProId()));
+//                    detail.setTjStatus(0L);
+//                    detail.setCreateBy(sysUser.getNickName());
+//                    detail.setCreateTime(new Date());
+//                    detail.setUpdateBy(sysUser.getNickName());
+//                    detail.setUpdateTime(new Date());
+//                    detail.setCreateId(String.valueOf(sysUser.getUserId()));
+//                    detail.setUpdateId(String.valueOf(sysUser.getUserId()));
+//                    tjOrderDetailService.save(detail);
+//                }
+//                List<String> list = proList.stream().map(TjGroupingPro::getProId).collect(Collectors.toList());
+//                List<TjProject> projectList = projectService.list(new LambdaQueryWrapper<TjProject>().in(TjProject::getProParentId, list));
+//                for (TjProject project : projectList) {
+//                    TjOrderDetail detail = new TjOrderDetail();
+//                    detail.setOrderId(tjOrder.getOrderId());
+//                    detail.setProId(project.getProId());
+//                    detail.setTjStatus(0L);
+//                    detail.setCreateBy(sysUser.getNickName());
+//                    detail.setCreateTime(new Date());
+//                    detail.setUpdateBy(sysUser.getNickName());
+//                    detail.setUpdateTime(new Date());
+//                    detail.setCreateId(String.valueOf(sysUser.getUserId()));
+//                    detail.setUpdateId(String.valueOf(sysUser.getUserId()));
+//                    //鑾峰彇璇ラ」鐩殑榛樿鍊艰祴鍊肩粰缁撴灉
+//                    if (null != project.getProDefault()) {
+//                        detail.setProResult(project.getProDefault());
+//                    } else {
+//                        detail.setProResult(null);
+//                    }
+//                    detail.setIsSampling(String.valueOf(project.getIsSampling()));
+//
+//                    tjOrderDetailService.save(detail);
+//                }
+//            }
+//        }
 
         //娣诲姞remark琛ㄦ暟鎹�
         remarkService.saveTjOrderRemarkByOrderId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjOrder.getOrderId()));
@@ -2657,11 +3009,13 @@
             if (null != tjReservation && tjReservation.getPayType() == 1) {
                 tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
                         sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
+                remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString());
             }
         }
         if (tjFlowingWater.getPayStasus() == 1) {
             tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
                     sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
+            remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString());
         }
         if (tjFlowingWater.getDiscount() == null) {
             transitionService.updateTbTransitionPriceByCusId(tjCustomer.getCusIdcard(), new BigDecimal(10), tjOrder.getTjNumber());
@@ -2710,11 +3064,11 @@
     @Transactional
     @RepeatSubmit
     public AjaxResult heXiaoByIds(@RequestBody List<String> orderIds) {
-        if(null !=orderIds && !orderIds.isEmpty()){
-        Date date = new Date();
-        for (String orderId : orderIds) {
-            TjOrder byId = tjOrderService.getById(orderId);
-            if (null != byId) {
+        if (null != orderIds && !orderIds.isEmpty()) {
+            Date date = new Date();
+            for (String orderId : orderIds) {
+                TjOrder byId = tjOrderService.getById(orderId);
+                if (null != byId) {
 
                 /*if (byId.getReportTime() == null) {
                     LambdaQueryWrapper<TjReportTemplate> tjReportTemplateLambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -2753,15 +3107,15 @@
                         return AjaxResult.error("鐢熸垚鎶ュ憡寮傚父,鏍告敹澶辫触");
                     }
                 }*/
-                byId.setHeshouStatus(1);
-                byId.setHeshouDoctor(UserHoder.getLoginUser().getUserId());
-                byId.setHeshouTime(date);
-                final boolean b = tjOrderService.updateById(byId);
-                if (!b) {
-                    return AjaxResult.error("鏍告敹澶辫触");
+                    byId.setHeshouStatus(1);
+                    byId.setHeshouDoctor(UserHoder.getLoginUser().getUserId());
+                    byId.setHeshouTime(date);
+                    final boolean b = tjOrderService.updateById(byId);
+                    if (!b) {
+                        return AjaxResult.error("鏍告敹澶辫触");
+                    }
                 }
             }
-        }
         }
         return AjaxResult.success("鏍告敹鎴愬姛");
     }
@@ -2779,8 +3133,8 @@
             tjReport.setTjNumber(String.valueOf(tjNumber));
             tjReport.setPath(urlValue + outputFileName1);
             String outputPath1 = value + File.separator;
-            String pdfBinary = getPDFBinary(outputPath1 + outputFileName1);
-            tjReport.setReport(pdfBinary);
+//            String pdfBinary = getPDFBinary(outputPath1 + outputFileName1);
+//            tjReport.setReport(pdfBinary);
             tjReport.setType("浣撴鎶ュ憡");
             tjReport.setPrint("pdf");
             tjReportService.save(tjReport);
@@ -2917,8 +3271,11 @@
 //            }
             if (null != order.getFinishTime()) return AjaxResult.error("璇ヤ汉鍛樺凡绛剧,涓嶅彲鎾ら攢!!!");
 
+            Boolean useLisAndPacsRegister = lisApiMethod.isUseLisAndPacsRegister(order);
+
             String s = configService.selectConfigByKey("is_request_common_his_api");
-            if (null != s && s.equals("Y") && "2".equals(order.getTjType())){
+//            if (null != s && s.equals("Y") && "2".equals(order.getTjType())) {
+            if (null != s && s.equals("Y") && !useLisAndPacsRegister) {
                 String apiUrl = configService.selectConfigByKey("common_api_url");
                 String hospbm = configService.selectConfigByKey("common_api_service_hospbm");
 
@@ -2926,35 +3283,37 @@
                 ArrayList<TjFlowingWater> yizhifu = new ArrayList<>();
                 LambdaQueryWrapper<TjFlowingWater> wrapper1 = new LambdaQueryWrapper<>();
                 wrapper1.eq(TjFlowingWater::getOrderId, order.getOrderId());
+                wrapper1.orderByDesc(TjFlowingWater::getJxbz);
                 List<TjFlowingWater> list = tjFlowingWaterService.list(wrapper1);
                 LambdaQueryWrapper<TjCustomer> wrapper = new LambdaQueryWrapper<>();
-                wrapper.eq(TjCustomer::getCusId,order.getUserId());
+                wrapper.eq(TjCustomer::getCusId, order.getUserId());
                 TjCustomer tjCustomer = tjCustomerService.getOne(wrapper);
 
                 for (TjFlowingWater water : list) {
-                    if (water.getPayStasus() == 0L){
+                    if (water.getPayStasus() == 0L) {
                         weizhifu.add(water);
-                    }else {
+                    } else {
                         yizhifu.add(water);
                     }
                 }
 
-                AjaxResult error = zuofeiWeiZhifu(weizhifu, tjCustomer, apiUrl, hospbm, order,true,tjNum);
+                AjaxResult error = zuofeiWeiZhifu(weizhifu, tjCustomer, apiUrl, hospbm, order, true, tjNum);
                 if (error != null && !error.get("code").toString().equals("200")) return error;
 
-                AjaxResult error1 = zuofeiYiZhifu(yizhifu, tjCustomer, order, apiUrl, hospbm,false,tjNum);
+                AjaxResult error1 = zuofeiYiZhifu(yizhifu, tjCustomer, order, apiUrl, hospbm, false, tjNum);
                 if (error1 != null && !error.get("code").toString().equals("200")) return error1;
-            }else {
+            } else {
                 tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
                 tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId()));
                 remarkService.deletedOrderRemarkByTjNum(tjNum);
                 tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId()));
                 transitionService.deletedTbTransitionByTjNum(tjNum);
+                ycxmService.delOrderYcXmJyByTjh(tjNum);
 
                 TjCustomer customer = tjCustomerService.getById(order.getUserId());
                 customer.setCardId("0");
                 tjCustomerService.updateById(customer);
-
+                xdPictureService.deleteTjXdPictureBytjNum(tjNum);
                 tjSamplingMapper.deleteByTjNumAndCusId(tjNum, order.getUserId());
             }
 
@@ -3007,11 +3366,11 @@
         if (null != reservationTime)
             wq.between(TjReservation::getReservationTime, DateUtil.beginOfDay(reservationTime), DateUtil.endOfDay(reservationTime));
         List<TjReservation> reservationList = tjReservationService.list(wq);
-        if (null != reservationList && reservationList.size() > 0) {
+        if (null != reservationList && !reservationList.isEmpty()) {
             LambdaQueryWrapper<TjOrder> wq1 = new LambdaQueryWrapper<>();
             wq1.in(TjOrder::getReservationId, reservationList.stream().map(TjReservation::getId).collect(Collectors.toList()));
             List<TjOrder> orderList = tjOrderService.list(wq1);
-            if (null != orderList && orderList.size() > 0) {
+            if (null != orderList && !orderList.isEmpty()) {
                 LambdaQueryWrapper<TjReservation> wq3 = new LambdaQueryWrapper<>();
                 wq3.in(TjReservation::getId, orderList.stream().map(TjOrder::getReservationId).collect(Collectors.toList()));
 //                    wq3.eq(TjReservation::getTeamNo,reservationList.get(0).getTeamNo());
@@ -3028,11 +3387,11 @@
     @ApiOperation(value = "鏍规嵁瀹㈡埛浣撴鍙锋壒閲忔挙閿�浣撴璁板綍")
     @Transactional
     public AjaxResult plRevokeTjOrderByTjNum(@RequestBody @ApiParam(value = "棰勭害涓婚敭id闆嗗悎") List<String> reservationIds) {
-        if (null != reservationIds && reservationIds.size() > 0) {
+        if (null != reservationIds && !reservationIds.isEmpty()) {
             LambdaQueryWrapper<TjOrder> wq1 = new LambdaQueryWrapper<>();
             wq1.in(TjOrder::getReservationId, reservationIds);
             List<TjOrder> orderList = tjOrderService.list(wq1);
-            if (null != orderList && orderList.size() > 0) {
+            if (null != orderList && !orderList.isEmpty()) {
                 for (TjOrder order : orderList) {
 //                TjOrder order = tjOrderService.getOrderByTjNum(tjNum);
                     if (null != order) {
@@ -3045,7 +3404,7 @@
                         remarkService.deletedOrderRemarkByTjNum(order.getTjNumber());
                         tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId()));
                         transitionService.deletedTbTransitionByTjNum(order.getTjNumber());
-                        transitionService.updateTbTransitionByTjNum(order.getTjNumber());
+//                        transitionService.updateTbTransitionByTjNum(order.getTjNumber());
                     }
                 }
                 for (String id : reservationIds) {
@@ -3074,7 +3433,7 @@
             for (int i = 0; i < tjNumbers.size(); i++) {
                 String tjNumber = tjNumbers.get(i).getTjNumber();
                 try {
-                    List<Map<String, String>> djdInfos = tjOrderService.selectDjdInfo(tjNumber);
+                    List<Map<String, Object>> 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");
@@ -3158,7 +3517,7 @@
 
 
     @GetMapping("/revokeTjOrderByTjh")
-    @ApiOperation(value = "鏍规嵁灏变綋妫�鍙峰垹闄よ褰�")
+    @ApiOperation(value = "寮哄埗鎾ら攢鎺ュ彛鏍规嵁灏变綋妫�鍙峰垹闄よ褰�")
     @Transactional
     public AjaxResult revokeTjOrderByTjh(@RequestParam @ApiParam(value = "浣撴鍙�") String tjNum) {
 
@@ -3168,11 +3527,13 @@
 //            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);
+            tjSamplingMapper.deleteByTjNumAndCusId(order.getTjNumber(), order.getUserId());
         }
         return AjaxResult.success();
     }
@@ -3188,12 +3549,12 @@
             LambdaQueryWrapper<TjProBl> wq = new LambdaQueryWrapper<>();
             wq.eq(TjProBl::getTjh, tjNum);
             List<TjProBl> blList = blService.list(wq);
-            if (null != blList && blList.size() > 0) {
+            if (null != blList && !blList.isEmpty()) {
                 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) {
+                    if (null != remarkList && !remarkList.isEmpty()) {
                         List<Long> collect = remarkList.stream().map(TjOrderRemark::getProId).collect(Collectors.toList());
                         LambdaQueryWrapper<TjProject> wqp = new LambdaQueryWrapper<>();
                         wqp.in(TjProject::getProId, collect);
@@ -3217,7 +3578,7 @@
 //    @Transactional
     public AjaxResult revokeBlProByBldhAndTjh(@RequestBody TjProBlDto dto) {
 
-        if (null == dto.getBldhs() || dto.getBldhs().size() == 0) {
+        if (null == dto.getBldhs() || dto.getBldhs().isEmpty()) {
             log.info("璇烽�夋嫨瑕佹挙閿�鐨勮ˉ褰曢」鐩�");
             return AjaxResult.error("璇烽�夋嫨瑕佹挙閿�鐨勮ˉ褰曢」鐩�");
         }
@@ -3264,31 +3625,33 @@
                 }
             }
             String s = configService.selectConfigByKey("is_request_common_his_api");
-            if (null != s && s.equals("Y") && "2".equals(order.getTjType())) {
+            Boolean useLisAndPacsRegister = lisApiMethod.isUseLisAndPacsRegister(order);
+//            if (null != s && s.equals("Y") && "2".equals(order.getTjType())) {
+            if (null != s && s.equals("Y") && !useLisAndPacsRegister) {
                 ArrayList<TjFlowingWater> weizhifu = new ArrayList<>();
                 ArrayList<TjFlowingWater> yizhifu = new ArrayList<>();
                 for (String bldh : dto.getBldhs()) {
                     LambdaQueryWrapper<TjFlowingWater> wrapper = new LambdaQueryWrapper<>();
-                    wrapper.eq(TjFlowingWater::getJxbz,bldh);
+                    wrapper.eq(TjFlowingWater::getJxbz, bldh);
                     TjFlowingWater water = tjFlowingWaterService.getOne(wrapper);
-                    if (water.getPayStasus() == 0L){
+                    if (water.getPayStasus() == 0L) {
                         weizhifu.add(water);
-                    }else {
+                    } else {
                         yizhifu.add(water);
                     }
                 }
                 String apiUrl = configService.selectConfigByKey("common_api_url");
                 String hospbm = configService.selectConfigByKey("common_api_service_hospbm");
                 LambdaQueryWrapper<TjCustomer> wrapper = new LambdaQueryWrapper<>();
-                wrapper.eq(TjCustomer::getCusId,order.getUserId());
+                wrapper.eq(TjCustomer::getCusId, order.getUserId());
                 TjCustomer tjCustomer = tjCustomerService.getOne(wrapper);
-                AjaxResult error = zuofeiWeiZhifu(weizhifu, tjCustomer, apiUrl, hospbm, order,true,dto.getTjh());
+                AjaxResult error = zuofeiWeiZhifu(weizhifu, tjCustomer, apiUrl, hospbm, order, true, dto.getTjh());
                 if (error != null && !error.get("code").toString().equals("200")) return error;
 
-                AjaxResult error1 = zuofeiYiZhifu(yizhifu, tjCustomer, order, apiUrl, hospbm,false,dto.getTjh());
+                AjaxResult error1 = zuofeiYiZhifu(yizhifu, tjCustomer, order, apiUrl, hospbm, false, dto.getTjh());
                 if (error1 != null && !error.get("code").toString().equals("200")) return error1;
                 return AjaxResult.success();
-            }else {
+            } else {
                 try {
                     extracted(dto, order);
                 } catch (Exception e) {
@@ -3301,56 +3664,56 @@
         return AjaxResult.error();
     }
 
-    private AjaxResult zuofeiYiZhifu(ArrayList<TjFlowingWater> yizhifu, TjCustomer tjCustomer, TjOrder order, String apiUrl, String hospbm,Boolean isDelete,String tjNum) {
-        if (!yizhifu.isEmpty()){
+    private AjaxResult zuofeiYiZhifu(ArrayList<TjFlowingWater> yizhifu, TjCustomer tjCustomer, TjOrder order, String apiUrl, String hospbm, Boolean isDelete, String tjNum) {
+        if (!yizhifu.isEmpty()) {
             for (TjFlowingWater water : yizhifu) {
                 HashMap<String, Object> map = new HashMap<>();
                 map.put("pationId", tjCustomer.getPationId());
                 map.put("cardId", tjCustomer.getHisJzkh());
                 map.put("tjNum", water.getTjSerialNumber());
-                map.put("kaiDanKs","7805");
-                // 鏀惰垂鏍囧織 1寰呭敭璐� 2寰呴��璐�
-                map.put("shouTuiStatus","2");
+                map.put("kaiDanKs", "7805");
+                // 鏀惰垂鏍囧織 1寰呮敹璐� 2寰呴��璐�
+                map.put("shouTuiStatus", "2");
                 JSONArray array = JSONUtil.createArray();
                 String bldh = water.getJxbz();
                 List<TbTransition> list;
-                if (bldh != null){
+                if (bldh != null) {
                     LambdaQueryWrapper<TbTransition> wrapper1 = new LambdaQueryWrapper<>();
-                    wrapper1.eq(TbTransition::getJxbz,bldh);
-                    wrapper1.gt(TbTransition::getOrdPrice,0);
+                    wrapper1.eq(TbTransition::getJxbz, bldh);
+                    wrapper1.gt(TbTransition::getOrdPrice, 0);
                     list = tbTransitionService.list(wrapper1);
-                }else {
+                } else {
                     LambdaQueryWrapper<TbTransition> wrapper1 = new LambdaQueryWrapper<>();
                     wrapper1.isNull(TbTransition::getJxbz);
-                    wrapper1.eq(TbTransition::getTjNum,tjNum);
-                    wrapper1.gt(TbTransition::getOrdPrice,0);
+                    wrapper1.eq(TbTransition::getTjNum, tjNum);
+                    wrapper1.gt(TbTransition::getOrdPrice, 0);
                     list = tbTransitionService.list(wrapper1);
                 }
                 for (TbTransition transition : list) {
                     LambdaQueryWrapper<TjProject> queryWrapper = new LambdaQueryWrapper<>();
-                    queryWrapper.eq(TjProject::getProId,transition.getProId());
+                    queryWrapper.eq(TjProject::getProId, transition.getProId());
                     TjProject project = projectService.getOne(queryWrapper);
                     LambdaQueryWrapper<TjFlowingWaterHis> wrapper2 = new LambdaQueryWrapper<>();
-                    wrapper2.eq(TjFlowingWaterHis::getParentId,water.getHisWaterId());
-                    wrapper2.eq(TjFlowingWaterHis::getXmId,project.getHisXmbm());
+                    wrapper2.eq(TjFlowingWaterHis::getParentId, water.getHisWaterId());
+                    wrapper2.eq(TjFlowingWaterHis::getXmId, project.getHisXmbm());
                     List<TjFlowingWaterHis> list1 = tjFlowingWaterHisService.list(wrapper2);
                     for (TjFlowingWaterHis waterHis : list1) {
                         LambdaQueryWrapper<SysDept> wrapper = new LambdaQueryWrapper<>();
-                        wrapper.eq(SysDept::getDeptId,project.getDeptId());
+                        wrapper.eq(SysDept::getDeptId, project.getDeptId());
                         SysDept dept = sysDeptService.getOne(wrapper);
                         JSONObject obj = JSONUtil.createObj();
                         BigDecimal danjia = transition.getOrdPrice();
                         Integer sl = project.getSl();
                         BigDecimal allPrice = danjia.multiply(new BigDecimal(sl));
-                        obj.putOpt("danJia",danjia);
-                        obj.putOpt("jieSuanJe",allPrice.negate());
-                        obj.putOpt("shuliang",Math.negateExact(sl));
-                        obj.putOpt("feiYongMxId",waterHis.getCurrentId());
-                        obj.putOpt("feiYongId",water.getHisWaterId());
-                        obj.putOpt("zhiXingKs",dept.getDeptId());
-                        obj.putOpt("zhiXingKsMc",dept.getDeptName());
-                        obj.putOpt("shouFeiXmId",project.getHisXmbm());
-                        obj.putOpt("shouFeiXmMc",project.getHisXmmc());
+                        obj.putOpt("danJia", danjia);
+                        obj.putOpt("jieSuanJe", allPrice.negate());
+                        obj.putOpt("shuliang", Math.negateExact(sl));
+                        obj.putOpt("feiYongMxId", waterHis.getCurrentId());
+                        obj.putOpt("feiYongId", water.getHisWaterId());
+                        obj.putOpt("zhiXingKs", dept.getDeptId());
+                        obj.putOpt("zhiXingKsMc", dept.getDeptName());
+                        obj.putOpt("shouFeiXmId", project.getHisXmbm());
+                        obj.putOpt("shouFeiXmMc", project.getHisXmmc());
 
 //                    obj.putOpt("zhiXingKs","7805");
 //                    obj.putOpt("zhiXingKsMc","浣撴绉�");
@@ -3360,52 +3723,65 @@
                     }
 
                 }
-                map.put("feiYongInfoList",array);
-                log.info("閫�璐圭敵璇� 鍏ュ弬 -> {}",JSONUtil.toJsonStr(map));
-                String post = HttpClientUtils.sendPost(apiUrl + "/api/his/"+ hospbm +"/creatCostInfo", map);
-                log.info("閫�璐圭敵璇� 杩斿洖 -> {}",JSONUtil.toJsonStr(post));
-                JSONObject jsonObject = JSONUtil.parseObj(post);
-                if (jsonObject.getStr("code").equals("200")) {
-                    // hisTfWaterId
-                    String tfid = jsonObject.getJSONObject("data").getStr("feiYongId");
-                    water.setHisTfWaterId(tfid);
-                    tjFlowingWaterService.updateById(water);
-                    if (isDelete) {
-                        for (TjFlowingWater water1 : yizhifu) {
-                            String bldh1 = water1.getJxbz();
-                            remarkService.deleteTjOrderDetailByjxbz(bldh1);
-                            tjOrderDetailService.deleteTjOrderDetailByjxbz(bldh1);
-                            tjFlowingWaterService.deleteTjOrderDetailByjxbz(bldh1);
-                            transitionService.deleteTjOrderDetailByjxbz(bldh1);
-                            blService.remove(new LambdaQueryWrapper<TjProBl>().eq(TjProBl::getTjh, tjNum).eq(TjProBl::getBldh, bldh1));
-                            tjSamplingMapper.deleteByTjNumAndCusIdAndJxbzo(tjNum, order.getUserId(), bldh1);
+                map.put("feiYongInfoList", array);
+                log.info("閫�璐圭敵璇� 鍏ュ弬 -> {}", JSONUtil.toJsonStr(map));
+                String post = HttpClientUtils.sendPost(apiUrl + "/api/his/" + hospbm + "/creatCostInfo", map);
+                log.info("閫�璐圭敵璇� 杩斿洖 -> {}", JSONUtil.toJsonStr(post));
+                if (null != post) {
+                    JSONObject jsonObject = JSONUtil.parseObj(post);
+                    if (jsonObject.getStr("code").equals("200")) {
+                        // hisTfWaterId
+                        String tfid = jsonObject.getJSONObject("data").getStr("feiYongId");
+                        water.setHisTfWaterId(tfid);
+                        tjFlowingWaterService.updateById(water);
+                        if (isDelete) {
+                            for (TjFlowingWater water1 : yizhifu) {
+                                String bldh1 = water1.getJxbz();
+                                remarkService.deleteTjOrderDetailByjxbz(bldh1);
+                                tjOrderDetailService.deleteTjOrderDetailByjxbz(bldh1);
+                                tjFlowingWaterService.deleteTjOrderDetailByjxbz(bldh1);
+                                transitionService.deleteTjOrderDetailByjxbz(bldh1);
+                                blService.remove(new LambdaQueryWrapper<TjProBl>().eq(TjProBl::getTjh, tjNum).eq(TjProBl::getBldh, bldh1));
+                                tjSamplingMapper.deleteByTjNumAndCusIdAndJxbzo(tjNum, order.getUserId(), bldh1);
+                            }
                         }
-                    }
-                }else return AjaxResult.error();
+                    } else return AjaxResult.error();
+                }
             }
         }
         return null;
     }
 
-    private AjaxResult zuofeiWeiZhifu(ArrayList<TjFlowingWater> weizhifu, TjCustomer tjCustomer, String apiUrl, String hospbm, TjOrder order,Boolean isDelete,String tjNum) {
-        if (!weizhifu.isEmpty()){
+    private AjaxResult zuofeiWeiZhifu(ArrayList<TjFlowingWater> weizhifu, TjCustomer tjCustomer, String apiUrl, String hospbm, TjOrder order, Boolean isDelete, String tjNum) {
+        if (!weizhifu.isEmpty()) {
             HashMap<String, Object> chexiaoMap = new HashMap<>();
             chexiaoMap.put("pationId", tjCustomer.getPationId());
             chexiaoMap.put("cardId", tjCustomer.getHisJzkh());
             String feiyongList = weizhifu.stream().map(TjFlowingWater::getHisWaterId).collect(Collectors.joining(","));
-            chexiaoMap.put("feiYongIdList",feiyongList.trim().replaceAll(" ",""));
+            chexiaoMap.put("feiYongIdList", feiyongList.trim().replaceAll(" ", ""));
 
-            String post = HttpClientUtils.sendPost(apiUrl + "/api/his/"+ hospbm +"/revokeCost", chexiaoMap);
+            String post = HttpClientUtils.sendPost(apiUrl + "/api/his/" + hospbm + "/revokeCost", chexiaoMap);
             if (JSONUtil.parseObj(post).getStr("code").equals("200")) {
                 if (isDelete) {
                     for (TjFlowingWater water : weizhifu) {
                         String bldh = water.getJxbz();
-                        remarkService.deleteTjOrderDetailByjxbz(bldh);
-                        tjOrderDetailService.deleteTjOrderDetailByjxbz(bldh);
-                        tjFlowingWaterService.deleteTjOrderDetailByjxbz(bldh);
-                        transitionService.deleteTjOrderDetailByjxbz(bldh);
-                        blService.remove(new LambdaQueryWrapper<TjProBl>().eq(TjProBl::getTjh, tjNum).eq(TjProBl::getBldh, bldh));
-                        tjSamplingMapper.deleteByTjNumAndCusIdAndJxbzo(tjNum, order.getUserId(), bldh);
+                        if (StrUtil.isNotBlank(bldh)) {
+                            remarkService.deleteTjOrderDetailByjxbz(bldh);
+                            tjOrderDetailService.deleteTjOrderDetailByjxbz(bldh);
+                            tjFlowingWaterService.deleteTjOrderDetailByjxbz(bldh);
+                            transitionService.deleteTjOrderDetailByjxbz(bldh);
+                            blService.remove(new LambdaQueryWrapper<TjProBl>().eq(TjProBl::getTjh, tjNum).eq(TjProBl::getBldh, bldh));
+                            tjSamplingMapper.deleteByTjNumAndCusIdAndJxbzo(tjNum, order.getUserId(), bldh);
+                        } else {
+                            //杩欓噷鍒犻櫎鐨勬槸杩欎釜浜烘墍鏈夐」鐩寘鎷ˉ褰曢」鐩�
+                            tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
+                            tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId()));
+                            remarkService.deletedOrderRemarkByTjNum(tjNum);
+                            tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId()));
+                            transitionService.deletedTbTransitionByTjNum(tjNum);
+                            tjSamplingMapper.deleteByTjNumAndCusId(order.getTjNumber(), order.getUserId());
+                        }
+
                     }
                 }
             } else return AjaxResult.error();
@@ -3455,15 +3831,29 @@
     }
 
 
+    @GetMapping("/chushenyemianyijianjiekou")
+    @ApiOperation(value = "鍒濆椤甸潰寮冩鎺ュ彛")
+    @Transactional
+    public AjaxResult chushenyemianyijianjiekou(@RequestParam String tjNUm, @RequestParam String proId) {
+        LambdaQueryWrapper<TjOrderRemark> wq = new LambdaQueryWrapper<>();
+        wq.eq(TjOrderRemark::getTjNumber, tjNUm);
+        wq.eq(TjOrderRemark::getProId, proId);
+        TjOrderRemark remark = remarkService.getOne(wq);
+        remark.setType(1);
+        remarkService.updateById(remark);
+        return AjaxResult.success("鎿嶄綔鎴愬姛!");
+    }
+
+
     @PostMapping("/zongjanyemianshjianzhou")
     @ApiOperation(value = "鎬绘鑾峰彇鏃堕棿杞存帴鍙�")
     @Transactional
     public AjaxResult zongjanyemianshjianzhou(@RequestBody List<String> tjNUms) {
 
-        if(null !=tjNUms && !tjNUms.isEmpty()){
-            List<Map<String,Object>> list=new ArrayList<>();
+        if (null != tjNUms && !tjNUms.isEmpty()) {
+            List<Map<String, Object>> list = new ArrayList<>();
             for (String tjNUm : tjNUms) {
-                Map<String,Object> map=new HashMap<>();
+                Map<String, Object> map = new HashMap<>();
                 TjOrder order = tjOrderService.getOrderByTjNum(tjNUm);
                 if (null != order) {
                     int czwj = remarkService.panduaniscunzaiweijian(tjNUm);
@@ -3472,45 +3862,44 @@
                     Date reportTime = order.getReportTime();
                     Integer heshouStatus = order.getHeshouStatus();
                     Date lastTime = order.getPrintLastTime();
-                    int a=0;
+                    int a = 0;
                     if (czwj == 0) {
                         //鏈
-                        a=0;
+                        a = 0;
                     }
                     if (czwj > 0) {
                         //鍦ㄦ
-                        a=1;
+                        a = 1;
                     }
                     if (sfwc == 0) {
                         //宸插畬鎴�
-                        a=2;
+                        a = 2;
                     }
                     if (null != checkTime) {
                         //宸插鏍�
-                        a=3;
+                        a = 3;
                     }
                     if (null != reportTime) {
                         //鐢熸垚鎶ュ憡
-                        a=4;
+                        a = 4;
                     }
-                    if (heshouStatus==1) {
+                    if (heshouStatus == 1) {
                         //鎶ュ憡鏍告敹
-                        a=5;
+                        a = 5;
                     }
                     if (null != lastTime) {
-                        //宸插嚭鎶ュ憡
-                        a=6;
+                        //宸叉墦鍗�
+                        a = 6;
                     }
-                    map.put("tjNUm",tjNUm);
-                    map.put("sjz",a);
+                    map.put("tjNUm", tjNUm);
+                    map.put("sjz", a);
                     list.add(map);
+                }
             }
-        }
             return AjaxResult.success(list);
         }
         return AjaxResult.error();
     }
-
 
 
     @PostMapping("/heshouchexiao")
@@ -3518,7 +3907,7 @@
     @Transactional
     public AjaxResult heshouchexiao(@RequestBody List<String> tjNUms) {
 
-        if(null !=tjNUms && !tjNUms.isEmpty()){
+        if (null != tjNUms && !tjNUms.isEmpty()) {
 
             // 涓嶅湪浣跨敤閫昏緫鍒犻櫎 閫昏緫鍒犻櫎瀵艰嚧鎵撳嵃鎶ュ憡鐢熸垚 鏌ヨsql缂撴參
             //閫昏緫鍒犻櫎鏁版嵁搴撻噷鐨勬姤鍛�
@@ -3529,7 +3918,7 @@
             List<Long> list = tjReportService.list(wq1).stream().map(TjReport::getReId).collect(Collectors.toList());
             for (String tjNUm : tjNUms) {
                 TjOrder order = tjOrderService.getOrderByTjNum(tjNUm);
-                if(null !=order){
+                if (null != order) {
                     order.setHeshouStatus(0);
                     order.setHeshouTime(null);
                     order.setHeshouDoctor(null);
@@ -3542,9 +3931,11 @@
                     }
                 }
             }
-            int i = tjReportService.deleteTjReportByReIds(list.toArray(new Long[]{}));
-            if (i == 0) {
-                return AjaxResult.error("鎾ゅ洖澶辫触锛�");
+            if (!list.isEmpty()) {
+                int i = tjReportService.deleteTjReportByReIds(list.toArray(new Long[]{}));
+                if (i == 0) {
+                    return AjaxResult.error("鎾ゅ洖澶辫触锛�");
+                }
             }
             return AjaxResult.success("鎿嶄綔鎴愬姛");
         }
@@ -3552,5 +3943,219 @@
     }
 
 
+    @GetMapping("/qiandaodengjitianjiaxiangmubydanweifenzu")
+    @ApiOperation(value = "绛惧埌鐧昏鏍规嵁鍗曚綅鍒嗙粍鑾峰彇浣撴椤圭洰")
+    @Transactional
+    public AjaxResult qiandaodengjitianjiaxiangmubydanweifenzu(@RequestParam String cusIdcard, @RequestParam String groupingId) {
+        try {
+            transitionService.saveTemoTransitionByGroupingId(cusIdcard, groupingId);
+            return AjaxResult.success("鎿嶄綔鎴愬姛!");
+        } catch (Exception e) {
+            e.printStackTrace();
+            return AjaxResult.error();
+        }
+    }
+
+    @PostMapping("/ttaddtTransition")
+    @ApiOperation(value = "鍥綋娣诲姞杩囨浮琛ㄦ暟鎹�")
+    @Transactional
+    public AjaxResult ttaddtTransition(@RequestBody Map<String, Object> map) {
+        Object packId = map.get("pacId");
+        if (null == map.get("cusId")) return AjaxResult.error("璇烽�夋嫨浣撴浜�");
+        String cusId = map.get("cusId").toString();
+        Object proIds1 = map.get("proIds");
+        List<Long> proIds = null;
+        if (null != proIds1 && !proIds1.equals("")) {
+            proIds = JSON.parseArray(proIds1.toString(), Long.class);
+        }
+        TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(cusId);
+        String cardId = "0";
+        if (null != tjCustomer) {
+            cardId = tjCustomer.getCardId();
+        }
+        if ((null == proIds || proIds.isEmpty()) && (null == packId || packId.equals(""))) {
+            transitionService.deletedTbTransitionByCusId(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.isEmpty()) {
+                transitionService.deletedTbTransitionListByCusIdAndPac(cusId, cardId);
+                String string = transitionService.ttpanduantaocanshifouchongfu(cusId, pacId);
+                if (!StringUtils.isBlank(string)) {
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return AjaxResult.error("鎿嶄綔澶辫触! 浠ヤ笅椤圭洰宸插瓨鍦�: " + string);
+                }
+                transitionService.ttsaveTemoTransitionByGroupingId(cusId, cardId, pacId.toString());
+                //琛ュ樊浠�
+                List<Map<String, Object>> cjMaps = groupingProService.huoquxiangmuchajia(pacId.toString(), cusId);
+                if (null != cjMaps && !cjMaps.isEmpty()) {
+                    for (Map<String, Object> cjMap : cjMaps) {
+                        transitionService.buxiangmuchajia(cusId, pacId.toString(), cjMap.get("xmid").toString(), new BigDecimal(cjMap.get("cj").toString()));
+                    }
+                }
+
+            }
+        }
+
+        //鍗曢」
+        if (null != proIds && !proIds.isEmpty()) {
+            //寮傛淇濆瓨鏁版嵁搴撹〃
+            for (Long proId : proIds) {
+                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);
+                    }
+                }
+            }
+        }
+        return AjaxResult.success();
+    }
+
+
+    @GetMapping(value = "newgetTransitionList")
+    @ApiOperation(value = "鏈�鏂版煡璇㈣繃娓¤〃鏁版嵁")
+    public AjaxResult newgetTransitionList(@RequestParam @ApiParam(value = "瀹㈡埛id") String cusId) {
+//        String pacId = transitionService.getTbTransitionPacId(cusId);
+//        if(StringUtil.isNotBlank(pacId)){
+//            //琛ュ樊浠�
+//            List<Map<String,Object>> cjMaps = groupingProService.huoquxiangmuchajia(pacId, cusId);
+//            if(null !=cjMaps && !cjMaps.isEmpty()){
+//                for (Map<String, Object> cjMap : cjMaps) {
+//                    transitionService.buxiangmuchajia(cusId,pacId,cjMap.get("xmid").toString(),new BigDecimal(cjMap.get("cj").toString()));
+//                }
+//            }
+//        }
+        List<TbTransition> list = transitionService.newgetTransitionList(cusId);
+        return AjaxResult.success(list);
+    }
+
+    @PostMapping(value = "updateTransitionnewPrice")
+    @ApiOperation(value = "绛惧埌鐧昏椤甸潰鏍规嵁鎶樻墸淇敼椤圭洰鐜颁环")
+    @Transactional
+    public AjaxResult updateTransitionnewPrice(@RequestBody List<UpdateTransitionnewPriceDto> dtos) {
+
+        if (null != dtos && !dtos.isEmpty()) {
+            int index = 0;
+            boolean flag = false;
+            for (UpdateTransitionnewPriceDto dto : dtos) {
+                index++;
+                LambdaQueryWrapper<TbTransition> wq = new LambdaQueryWrapper<>();
+                wq.eq(TbTransition::getCusId, dto.getCusIdCard());
+                wq.eq(TbTransition::getParentProId, dto.getParentProId());
+                wq.isNull(TbTransition::getTjNum);
+                List<TbTransition> list = transitionService.list(wq);
+                log.info("淇敼鐨勫鎴疯韩浠借瘉鍙蜂负: " + dto.getCusIdCard());
+                log.info("鐖堕」鐩甶d涓�: " + dto.getParentProId());
+                log.info("鎶樻墸涓�: " + new BigDecimal(dto.getDiscount()));
+                if (null != list && !list.isEmpty()) {
+
+                    for (TbTransition transition : list) {
+                        BigDecimal ordPrice = transition.getOrdPrice();
+                        BigDecimal multiply = ordPrice.multiply((new BigDecimal(dto.getDiscount()).divide(BigDecimal.valueOf(10))));
+                        log.info("鍚庣璁$畻鐨勯噾棰�: " + multiply.toString());
+                        transition.setNowPrice(multiply);
+                        transition.setDiscount(new BigDecimal(dto.getDiscount()));
+                        transitionService.updateById(transition);
+                    }
+
+                    BigDecimal dxzj = transitionService.getTbTransitionPriceAndOrdPrice(dto.getCusIdCard(), dto.getParentProId());
+
+                    BigDecimal yhj = dto.getYhj();
+                    log.info("鍓嶇浼犻�掔殑浠锋牸锛歿}",yhj.toString());
+                    BigDecimal cj = yhj.subtract(dxzj);
+                    log.info("璁$畻鐨勫樊浠凤細{}",cj.toString());
+                    for (TbTransition transition : list) {
+                        BigDecimal result = transition.getNowPrice().add(cj);
+                        log.info("琛ヤ笂宸环鍓嶇殑浠锋牸涓猴細{}",transition.getNowPrice().toString());
+                        if (result.compareTo(BigDecimal.ZERO)>0 && !flag && cj.compareTo(BigDecimal.ZERO) != 0){
+                            transition.setNowPrice(result);
+                            transitionService.updateById(transition);
+                            log.info("淇敼 琛ヤ笂宸环鍚庣殑浠锋牸涓猴細{}",result.toString());
+                            flag = true;
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+        return AjaxResult.success();
+    }
+
+
+
+    @PostMapping("/huifuyuyuejilu")
+    @ApiOperation(value = "浣撴璁板綍椤甸潰鎭㈠棰勭害璁板綍鎺ュ彛")
+    @Transactional
+    public AjaxResult huifuyuyuejilu(@RequestBody List<String> tjNUms) {
+
+        if (null != tjNUms && !tjNUms.isEmpty()) {
+            for (String tjNUm : tjNUms) {
+                TjOrder order = tjOrderService.getOrderByTjNum(tjNUm);
+                if(null !=order && StringUtil.isNotBlank(order.getReservationId())){
+                    //杩欓噷鍒犻櫎鐨勬槸杩欎釜浜烘墍鏈夐」鐩寘鎷ˉ褰曢」鐩�
+                    tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
+                    tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId()));
+                    remarkService.deletedOrderRemarkByTjNum(tjNUm);
+                    tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId()));
+//                transitionService.deletedTbTransitionByTjNum(tjNum);
+                    tjSamplingMapper.deleteByTjNumAndCusId(order.getTjNumber(), order.getUserId());
+
+                    TjReservation reservation = tjReservationService.getById(order.getReservationId());
+                    if(null !=reservation){
+                        reservation.setIsExpire(2);
+                        tjReservationService.updateById(reservation);
+                        transitionService.updateTbTransitionByTjNum(tjNUm);
+                    }
+
+                }
+            }
+
+            return AjaxResult.success();
+        }
+        return AjaxResult.error();
+    }
+
+
+
+    @PostMapping("/addBlTransition")
+    @ApiOperation(value = "琛ュ綍娣诲姞杩囨浮琛ㄦ暟鎹�")
+    @Transactional
+    public AjaxResult addBlTransition(@RequestBody Map<String, Object> map) {
+        Object packId = map.get("pacId");
+        if (null == map.get("cusId")) return AjaxResult.error("璇烽�夋嫨浣撴浜�");
+        String cusId = map.get("cusId").toString();
+        Object proIds1 = map.get("proIds");
+        List<Long> proIds = null;
+        if (null != proIds1 && !proIds1.equals("")) {
+            proIds = JSON.parseArray(proIds1.toString(), Long.class);
+        }
+        TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(cusId);
+        String cardId = "0";
+        if (null != tjCustomer) {
+            cardId = tjCustomer.getCardId();
+        }
+        if ((null == proIds || proIds.isEmpty()) && (null == packId || packId.equals(""))) {
+            transitionService.deletedTbTransitionByCusId(cusId);
+        }
+
+        //鍗曢」
+        if (null != proIds && !proIds.isEmpty()) {
+            //寮傛淇濆瓨鏁版嵁搴撹〃
+            for (Long proId : proIds) {
+                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);
+                    }
+                }
+            }
+        }
+        return AjaxResult.success();
+    }
 }
 

--
Gitblit v1.8.0