From 4dc5a1ece2a58f768dea5c829bff9da842a6de95 Mon Sep 17 00:00:00 2001
From: zjh <zjh@888>
Date: 星期六, 15 六月 2024 15:02:22 +0800
Subject: [PATCH] zjh 本地 2024/06/15 --2

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java |  742 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 705 insertions(+), 37 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 8e170b0..756bb53 100644
--- a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java
+++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java
@@ -4,12 +4,18 @@
 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.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;
@@ -19,21 +25,29 @@
 import cn.hutool.extra.pinyin.PinyinUtil;
 import com.alibaba.fastjson2.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fasterxml.jackson.databind.BeanProperty;
+import com.itextpdf.text.Document;
+import com.itextpdf.text.DocumentException;
 import com.ltkj.common.core.domain.entity.SysDept;
 import com.ltkj.common.core.domain.entity.SysUser;
 import com.ltkj.common.core.redis.RedisCache;
 import com.ltkj.common.enums.DataSourceType;
+import com.ltkj.common.utils.PDFDocumentUtil;
 import com.ltkj.common.utils.SecurityUtils;
 import com.ltkj.framework.config.MatchUtils;
+import com.ltkj.framework.config.ThreadPoolConfig;
 import com.ltkj.framework.config.UserHoder;
 import com.ltkj.framework.datasource.DynamicDataSourceContextHolder;
 import com.ltkj.hosp.domain.*;
+import com.ltkj.hosp.dto.QianDaoDto;
 import com.ltkj.hosp.mapper.TestMapper;
 import com.ltkj.hosp.service.*;
 import com.ltkj.hosp.sqlDomain.LtkjMiddleDetail;
 import com.ltkj.hosp.sqlDomain.LtkjMiddleHead;
+import com.ltkj.hosp.sqlDomain.LtkjTjPat;
 import com.ltkj.hosp.vodomain.BingZhongVO;
 import com.ltkj.hosp.vodomain.HistoryTjOrder;
 import com.ltkj.hosp.vodomain.QjDomainVo;
@@ -47,14 +61,22 @@
 import com.ltkj.system.service.ISysConfigService;
 import com.ltkj.system.service.ISysDeptService;
 import com.ltkj.system.service.ISysUserService;
+import com.ltkj.web.controller.his.HisApiGetMethodService;
+import com.ltkj.web.controller.his.HisApiMethod;
+import com.ltkj.web.controller.his.HisMzJysqController;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.extern.slf4j.Slf4j;
+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.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
+import org.springframework.util.DigestUtils;
 import org.springframework.web.bind.annotation.*;
 import com.ltkj.common.annotation.Log;
 import com.ltkj.common.core.controller.BaseController;
@@ -149,6 +171,18 @@
 
     @Resource
     private LtkjMiddleHeadService headService;
+    @Resource
+    private TjvLtkjvtjpatService tjvLtkjvtjpatService;
+    @Autowired
+    private ThreadPoolConfig threadPoolConfig;
+
+    @Autowired
+    private HisApiMethod hisApiMethod;
+
+    @Autowired
+    private HisMzJysqController hisMzJysqController;
+    @Autowired
+    private HisApiGetMethodService hisApiGetMethodService;
 
 
     /**
@@ -407,7 +441,7 @@
                     order.setTjCustomerSex(tjCustomer.getCusSex());
                     order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
                     order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
-                    order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
+                    order.setTjCustomerName(tjCustomer.getCusName());
                     order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
 //                    order.setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard()));
                     order.setTjCusIdCard(tjCustomer.getCusIdcard());
@@ -811,26 +845,29 @@
         LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>();
         wq.eq(TjCustomer::getCusId, tjOrder.getUserId());
         TjCustomer tjCustomer = tjCustomerService.getOne(wq);
-        if (tjCustomer == null) return AjaxResult.error("璇ュ鎴锋湭鐧昏鎴栦笉瀛樺湪");
+        if (tjCustomer == null) return AjaxResult.error("璇ュ鎴锋湭鐧昏");
 
         LambdaQueryWrapper<TjOrder> wqq = new LambdaQueryWrapper<>();
         wqq.eq(TjOrder::getUserId, tjOrder.getUserId());
         wqq.eq(TjOrder::getCheckStatus, 0);
         wqq.isNull(TjOrder::getFinishTime);
-        if (!tjCustomer.getCardId().equals("0")) {
-            wqq.eq(TjOrder::getCardId, tjCustomer.getCardId());
-        }
+//        if (!tjCustomer.getCardId().equals("0")) {
+        wqq.eq(TjOrder::getCardId, tjCustomer.getCardId());
+//        }
         TjOrder order = tjOrderService.getOne(wqq);
         if (null != order) {
-            transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(), tjCustomer.getCardId());
+            transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(),tjCustomer.getCardId());
             return AjaxResult.error("涓嶅彲閲嶅鐧昏");
         }
+
+
         LambdaQueryWrapper<TjReservation> wq1 = new LambdaQueryWrapper<>();
         wq1.eq(TjReservation::getIdCard, tjCustomer.getCusIdcard());
         wq1.eq(TjReservation::getIsExpire, 2);
         TjReservation tjReservation = tjReservationService.getOne(wq1);
         MallOrder mallOrder = null;
-        if (tjReservation != null) {
+        if (null != tjReservation) {
+            tjOrder.setReservationId(tjReservation.getId());
             mallOrder = mallOrderService.getOne(new LambdaQueryWrapper<MallOrder>().eq(MallOrder::getReservationId, tjReservation.getId()));
             if (DateUtil.endOfDay(new Date()).before(tjReservation.getReservationTime())) {
                 return AjaxResult.error("鏈埌棰勭害鏃堕棿");
@@ -885,6 +922,7 @@
         tjOrder.setStatus(TjConstants.TJ_BEGIN);
         tjOrder.setCardId(tjCustomer.getCardId());
         if (tjOrderService.save(tjOrder)) {
+
             //淇濆瓨鏀惰揣鍦板潃
             if ("2".equals(tjOrder.getGetType())) {
                 final TjReportGetAddress address = tjOrder.getAddAddress();
@@ -919,6 +957,12 @@
             Date date1 = new Date(System.currentTimeMillis());
             String s1 = SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmssSSS").format(date1);
             tjFlowingWater.setWaterId(PinyinUtil.getFirstLetter(tjCustomer.getCusName(), "").toUpperCase() + s1);
+
+
+            tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith());
+            tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn());
+            tjFlowingWater.setDiscount(tjOrder.getTjFlowingWater().getDiscount());
+
             if (isPay.equals("true")) {
                 if (null != mallOrder) {
                     if (mallOrder.getOrderStatus().equals(201L)) {
@@ -950,17 +994,16 @@
             if (tjFlowingWaterService.save(tjFlowingWater)) {
                 tjOrder.setTjSerialNumber(String.valueOf(tjFlowingWater.getTjSerialNumber()));
                 tjOrderService.updateById(tjOrder);
+
+
             }
 
             //鍥綋
             if ("1".equals(tjOrder.getTjType())) {
                 asyncService.ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
             }
-
-
             //涓汉
             if ("2".equals(tjOrder.getTjType())) {
-
                 //asyncService.newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                 newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
             }
@@ -987,9 +1030,412 @@
 //
 //                }
 //            }
-            tjCustomer.setCardId("0");
-            tjCustomerService.updateById(tjCustomer);
+
+
+            /*璋冪敤his鎺ュ彛*/
+            String config = configService.selectConfigByKey("sfkqdyhis");
+            if(null !=config && config.equals("Y")){
+                hisApiMethod.HisApiMethods(tjCustomer,tjOrder.getOrderId());
+            }
+//            tjCustomer.setCardId("0");
+//            tjCustomerService.updateById(tjCustomer);
+
             return AjaxResult.success(tjNumber);
+        }
+        return AjaxResult.error();
+    }
+
+
+    @PostMapping("/addPlOrderAndDetail")
+    @ApiOperation(value = "浣撴鎵归噺绛惧埌鐧昏鎺ュ彛")
+    @Transactional  //(鍒囨崲鏁版嵁搴撳嚭閿欙紝鎵�浠ユ敞閲�)
+    public AjaxResult addPlOrderAndDetail(@RequestBody QianDaoDto daoDto,HttpServletResponse response) {
+        SysUser sysUser = UserHoder.getLoginUser().getUser();
+        List<String> cusIds = daoDto.getCusIds();
+        ArrayList<String> tjNumbers = new ArrayList<>();
+        if (null != cusIds && cusIds.size() > 0) {
+            ExecutorService threadPools = Executors.newFixedThreadPool(cusIds.size());
+            for (String cusId : cusIds) {
+                threadPools.execute(new Runnable() {
+                    @Override
+                    public void run() {
+                        getAjaxResults(cusId);
+                    }
+                });
+            }
+            LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>();
+            wq.in(TjCustomer::getCusIdcard, cusIds);
+            List<Long> list = tjCustomerService.list(wq).stream().map(TjCustomer::getCusId).collect(Collectors.toList());
+            if (list.size() > 0) {
+//                ExecutorService threadPool = Executors.newFixedThreadPool(list.size());
+                ThreadPoolTaskExecutor executor = threadPoolConfig.threadPoolTaskExecutor();
+                for (Long aLong : list) {
+//                    threadPool.execute(new Runnable() {
+//                        @Override
+//                        public void run() {
+//                            try {
+//                                AjaxResult result = getAjaxResult(aLong, sysUser, daoDto.getTjCategory());
+//                                threadPool.shutdown();
+//                            } catch (IOException e) {
+//                                e.printStackTrace();
+//                            }
+//                        }
+//                    });
+                    Future<AjaxResult> future = executor.submit(new Callable<AjaxResult>() {
+                        @Override
+                        public AjaxResult call() throws Exception {
+                            return getAjaxResult(aLong, sysUser, daoDto.getTjCategory());
+                        }
+                    });
+                    try {
+                        AjaxResult result = future.get();
+                        String tjNumber = result.get("tjNumber").toString();
+                        tjNumbers.add(tjNumber);
+                    } catch (InterruptedException | ExecutionException e) {
+                        e.printStackTrace();
+                    }
+                }
+                threadPools.shutdown();
+            }
+        }
+        // TODO 鍥犱负鏈変綋妫�鍙蜂細鏌ュ嚭绌烘暟鎹� 鍏堜娇鐢ㄦ鏁版嵁
+        tjNumbers = new ArrayList<>();
+        tjNumbers.add("02095240229171627");
+        tjNumbers.add("02095240229173104");
+        tjNumbers.add("10001240524172002");
+        tjNumbers.add("10001240304124410");
+        tjNumbers.add("00325240304160123");
+        tjNumbers.add("02095240304162044");
+        tjNumbers.add("02095240304162152");
+        tjNumbers.add("10001240304163505");
+        Map<String, Object> map = null;
+        try {
+            map = PDFDocumentUtil.getDocument();
+            Document document = (Document) map.get("document");
+            for (int i = 0; i < tjNumbers.size(); i++) {
+                try {
+                    List<Map<String, String>> djdInfos = tjOrderService.selectDjdInfo(tjNumbers.get(i));
+                    Map<String, Object> userInfo = tjOrderService.selectDjdUserInfo(tjNumbers.get(i));
+                    LocalDateTime tjsj = (LocalDateTime) userInfo.get("tjsj");
+                    DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
+                    String time = null;
+                    if (tjsj != null) {
+                        time = dateFormat.format(tjsj);
+                    }
+                    PDFDocumentUtil.makeUserInfoTable(document, (String) userInfo.get("tjname"), (String) userInfo.get("sex")
+                            , (String) userInfo.get("tjh"), (String) userInfo.get("lxdh"), (String) userInfo.get("tjname"), time);
+                    PDFDocumentUtil.makeTjInfo(document, djdInfos);
+                    // 澶氭潯鍒欐崲椤�
+                    if (i + 1 < tjNumbers.size()) {
+                        document.newPage();
+                    }
+                } catch (DocumentException | IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            document.close();
+            ByteArrayOutputStream outputStream = (ByteArrayOutputStream) map.get("stream");
+            String encodeToString = java.util.Base64.getEncoder().encodeToString(outputStream.toByteArray());
+            return AjaxResult.success().put("file", encodeToString);
+        } catch (IOException | DocumentException e) {
+            e.printStackTrace();
+        }
+        return AjaxResult.success("鎿嶄綔鎴愬姛");
+    }
+
+    private void getAjaxResults(String cusIdcard) {
+        if (!"".equals(cusIdcard) && cusIdcard != null) {
+            //鏍规嵁閰嶇疆璋冨彇瀛樺偍杩囩▼ 灏嗕复鏃惰〃鏁版嵁瀛樺叆棰勭害琛�2023.12.12
+            final String getInfoFromSqlData = configService.selectConfigByKey("getInfoFromSqlData");
+            if ("Y".equals(getInfoFromSqlData)) {
+                //鏍规嵁韬唤璇佸彿浠巋is鏌ヤ俊鎭�
+                LtkjTjPat tjPatByIdCard = testMapper.getTjPatByIdCard(cusIdcard);
+                if (null != tjPatByIdCard) {
+                    String fcardNo = tjPatByIdCard.getFcardNo();
+                    if (null != fcardNo && !fcardNo.equals("")) {
+                        fcardNo = fcardNo.trim();
+                        tjPatByIdCard.setFcardNo(fcardNo);
+                    } else {
+                        fcardNo = cusIdcard.trim();
+                        tjPatByIdCard.setFcardNo(fcardNo);
+                    }
+                    //鏍规嵁韬唤璇佸彿浠庢暟鎹簱鎷夸俊鎭� 娌℃湁鐨勮瘽淇濆瓨
+                    LtkjTjPat ltkjTjPat = tjvLtkjvtjpatService.getLtkjTjPatByCusIdCard(cusIdcard);
+                    if (null == ltkjTjPat) {
+                        tjvLtkjvtjpatService.save(tjPatByIdCard);
+                    }
+                    DynamicDataSourceContextHolder.clearDataSourceType();
+                    //鍐嶆牴鎹韩浠借瘉鍙峰啓customer琛�
+                    TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(tjPatByIdCard.getFcardNo());
+                    if (null == tjCustomer) {
+                        //涓虹┖鐨勮瘽鎺夊瓨鍌ㄨ繃绋嬩繚瀛樺埌瀹㈡埛琛�
+                        testMapper.getTjPatByCusId(cusIdcard);
+                        LambdaQueryWrapper<TjCustomer> qw = new LambdaQueryWrapper<>();
+                        qw.eq(TjCustomer::getCusIdcard, tjPatByIdCard.getFcardNo());
+                        TjCustomer customer = tjCustomerService.getOne(qw);
+                        customer.setReservationId(customer.getCardId());
+                        extracteds(customer);
+                    } else {
+                        String cardId = tjPatByIdCard.getFcardId();
+                        if (null != cardId && !cardId.equals("0")) {
+                            int i = tjOrderService.selectTjOrderByCardId(cardId);
+                            if (i > 0) {
+//                                return AjaxResult.error("涓嶅彲閲嶅绛惧埌");
+                            }
+                        }
+                        tjCustomer.setReservationId(tjCustomer.getCardId());
+                        tjCustomer.setCardId(tjPatByIdCard.getFcardId());
+                        tjCustomerService.updateById(tjCustomer);
+                        extracteds(tjCustomer);
+                    }
+
+                }
+            }
+            //end====2023.12.12
+            LambdaQueryWrapper<TjReservation> wq = new LambdaQueryWrapper<>();
+            wq.eq(TjReservation::getIdCard, cusIdcard);
+            wq.eq(TjReservation::getIsExpire, 2);
+            TjReservation tjReservation = tjReservationService.getOne(wq);
+            if (tjReservation != null) {
+/*                if (DateUtil.endOfDay(new Date()).before(tjReservation.getReservationTime())) {
+//                    return AjaxResult.error("鏈埌棰勭害鏃堕棿");
+                }
+                if (null != tjReservation.getReservationTime() && DateUtil.endOfDay(tjReservation.getReservationTime()).before(new Date())) {
+                    tjReservation.setIsExpire(1);
+                    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);
+                }
+            }
+
+        }
+    }
+
+    private void extracteds(TjCustomer customer) {
+        //浠巋is琛ㄦ姄鏁版嵁
+        LtkjMiddleHead pat = testMapper.getMiddleHeadByPartId(customer.getCardId());
+        if (null != pat) {
+            LambdaQueryWrapper<LtkjMiddleHead> wq1 = new LambdaQueryWrapper<>();
+            wq1.eq(LtkjMiddleHead::getFeadId, customer.getCardId());
+            headService.remove(wq1);
+            LambdaQueryWrapper<LtkjMiddleDetail> wq0 = new LambdaQueryWrapper<>();
+            wq0.eq(LtkjMiddleDetail::getFheadId, pat.getFeadId());
+            middleDetailService.remove(wq0);
+            List<LtkjMiddleDetail> list = testMapper.getMiddleDetailByFeadId(pat.getFeadId());
+            DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.MASTER.name());
+            LtkjMiddleHead o = headService.getMiddleHeadByPartId(customer.getCardId());
+            if (o == null) {
+                headService.save(pat);
+                for (LtkjMiddleDetail ltkjMiddleDetail : list) {
+                    middleDetailService.save(ltkjMiddleDetail);
+                }
+            }
+            testMapper.saveTjProByCusId(customer.getCardId(), customer.getCusIdcard());
+        }
+        DynamicDataSourceContextHolder.clearDataSourceType();
+    }
+
+    private 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);
+        tjOrder.setUpdateTime(date);
+        tjOrder.setCreateBy(sysUser.getNickName());
+        tjOrder.setUpdateBy(sysUser.getNickName());
+        tjOrder.setUserId(userId);
+        tjOrder.setTjCategory(tjCategory);
+        LambdaQueryWrapper<TjReservation> wq1 = new LambdaQueryWrapper<>();
+        wq1.eq(TjReservation::getIdCard, tjCustomer.getCusIdcard());
+        wq1.eq(TjReservation::getIsExpire, 2);
+        TjReservation tjReservation = tjReservationService.getOne(wq1);
+        MallOrder mallOrder = null;
+        if (tjReservation != null) {
+            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 (null != tjReservation.getTeamNo()) tjOrder.setTeamNo(tjReservation.getTeamNo());
+            if (null != tjReservation.getCompanyId()) tjOrder.setFirmId(tjReservation.getCompanyId());
+            if (null != tjReservation.getDepartment()) tjOrder.setFirmDeptName(tjReservation.getDepartment());
+            if (null != tjReservation.getJobNo()) tjOrder.setFirmWorkId(tjReservation.getJobNo());
+            if (null != tjReservation.getPacId()) tjOrder.setPacId(tjReservation.getPacId());
+            if (null != tjReservation.getTjCategory()) tjOrder.setTjCategory(tjReservation.getTjCategory());
+            if (null != tjReservation.getGroupingId()) {
+                tjOrder.setGroupId(tjReservation.getGroupingId());
+                tjOrder.setFirmDeptId(tjReservation.getPacId());
+            }
+            tjReservation.setIsExpire(1);
+            tjReservationService.updateById(tjReservation);
+
+            //鐢熸垚浣撴鍙�
+            String tjNumber = (sysUser.getUserName() + new SimpleDateFormat("yyMMddHHmmss").format(new Date()));
+
+            tjNumber = tjNumber.replaceAll(".{4}$", userId.toString().substring(userId.toString().length() - 4));
+
+            tjOrder.setTjNumber(tjNumber);
+            if (null != tjOrder.getPhoto()) {
+                File file = new File(tjOrder.getPhoto());
+                if (file.isFile()) {
+                    FileInputStream fileInputStream = new FileInputStream(file);
+                    byte[] bytes = new byte[fileInputStream.available()];
+                    fileInputStream.read(bytes); // 璇诲彇鍒� byte 閲岄潰
+                    fileInputStream.close();
+                    // 寰楀埌鏂囦欢 涔嬪悗杞垚beye 鐒跺悗浣跨敤base64杞爜
+                    String encode = Base64.encode(bytes);
+                    tjOrder.setPhoto(encode);
+                }
+            }
+            if (tjOrder.getFirmId() == null) {
+                tjOrder.setFirmId("0");
+            }
+            if (null == tjOrder.getPacId() && null != transitionService.getTbTransitionPacIdByCusIdAndPac(String.valueOf(tjOrder.getUserId()))) {
+                tjOrder.setPacId(transitionService.getTbTransitionPacIdByCusIdAndPac(String.valueOf(tjOrder.getUserId())));
+            }
+            //鍒ゆ柇灏忕▼搴忎笂棰勭害鏄惁浠橀挶
+            if (null != mallOrder) tjOrder.setMallOrderId(String.valueOf(mallOrder.getId()));
+            tjOrder.setStatus(TjConstants.TJ_BEGIN);
+            tjOrder.setCardId(tjCustomer.getCardId());
+            tjOrder.setTjType("1");
+
+            if (tjOrderService.save(tjOrder)) {
+
+                //淇濆瓨鏀惰揣鍦板潃
+                if ("2".equals(tjOrder.getGetType())) {
+                    final TjReportGetAddress address = tjOrder.getAddAddress();
+                    if (address != null) {
+                        address.setTjNumber(tjNumber);
+                        tjReportGetAddressService.save(address);
+                    }
+                }
+                Long cusNumber = tjCustomer.getCusNumber();
+                cusNumber += 1;
+                tjCustomer.setCusNumber(cusNumber);
+//            BigDecimal discount = BigDecimal.valueOf(Double.parseDouble(tjOrder.getTjFlowingWater().getDiscount())).divide(BigDecimal.valueOf(10));
+                TjFlowingWater tjFlowingWater = new TjFlowingWater();
+                tjFlowingWater.setPayStasus(0L);
+                if ("1".equals(tjOrder.getTjType())) {
+                    if (tjReservation.getPayType() == 1) {
+                        tjFlowingWater.setPayStasus(3L);
+                    }
+                }
+
+                //璋冪敤SQL server鎷垮彇鏀惰垂鎯呭喌
+                //鏍规嵁閰嶇疆璋冨彇瀛樺偍杩囩▼ 灏嗕复鏃惰〃鏁版嵁瀛樺叆棰勭害琛�2023.12.12
+                String getInfoFromSqlData = configService.selectConfigByKey("getInfoFromSqlData");
+                String isPay = configService.selectConfigByKey("isPay");
+                if ("Y".equals(getInfoFromSqlData)) {
+                    LtkjMiddleHead middleHead = headService.getMiddleHeadByPartId(tjCustomer.getCardId());
+                    if (null != middleHead) {
+                        tjFlowingWater.setPayStasus(1L);
+                    }
+                }
+                tjFlowingWater.setOrderId(tjOrder.getOrderId());
+                Date date1 = new Date(System.currentTimeMillis());
+                String s1 = sysUser.getUserName() + new SimpleDateFormat("yyMMddHHmmssSSS").format(date1);
+                tjFlowingWater.setWaterId(PinyinUtil.getFirstLetter(tjCustomer.getCusName(), "").toUpperCase() + s1);
+
+                if (isPay.equals("true")) {
+                    if (null != mallOrder) {
+                        if (mallOrder.getOrderStatus().equals(201L)) {
+                            tjFlowingWater.setCopeWith(mallOrder.getActualPrice());
+                            tjFlowingWater.setPaidIn(mallOrder.getActualPrice());
+                            tjFlowingWater.setDiscount(String.valueOf(1));
+                            tjFlowingWater.setPayStasus(1L);
+                            tjFlowingWater.setPayType(3L);
+                            MallCheckLog checkLog = new MallCheckLog();
+                            checkLog.setCheckBy(sysUser.getNickName());
+                            checkLog.setUserId(mallOrder.getUserId());
+                            checkLog.setConsignee(mallOrder.getConsignee());
+                            checkLog.setIdCard(mallOrder.getIdCard());
+                            checkLog.setOrderId(String.valueOf(mallOrder.getId()));
+                            checkLog.setOrderSn(mallOrder.getOrderSn());
+                            checkLog.setCheckTime(new Date());
+                            checkLog.setShipSn("HX" + s1);
+                            mallCheckLogService.save(checkLog);
+                            mallOrder.setOrderStatus(301L);
+                            mallOrderService.updateById(mallOrder);
+                        }
+                    }
+                }
+                if (tjFlowingWaterService.save(tjFlowingWater)) {
+                    tjOrder.setTjSerialNumber(String.valueOf(tjFlowingWater.getTjSerialNumber()));
+                    tjOrderService.updateById(tjOrder);
+
+
+                }
+                asyncService.ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
+
+
+                tjCustomer.setCardId("0");
+                tjCustomerService.updateById(tjCustomer);
+                return AjaxResult.success().put("tjNumber",tjNumber);
+            }
         }
         return AjaxResult.error();
     }
@@ -1087,11 +1533,17 @@
                 if (null != ppList && ppList.size() > 0) {
                     //寮傛淇濆瓨鏁版嵁搴�
 //                    asyncService.addRedisTransitionPac(cusId, pacId, ppList);
-                    asyncService.saveRedisTransitionByPacId(cusId, pacId, null);
+                    asyncService.saveRedisTransitionByPacId(cusId,cardId, pacId, null);
                     for (TjPackageProject tjPackageProject : ppList) {
                         TjProject project = projectService.getTjProjectById(String.valueOf(tjPackageProject.getProId()));
                         if (null != project) {
-                            BigDecimal divide = tjPackageProject.getPriceNow().divide(project.getProPrice(), 5, RoundingMode.HALF_DOWN);
+
+                            BigDecimal divide = BigDecimal.valueOf(0);
+                            if (tjPackageProject.getPriceNow().compareTo(BigDecimal.valueOf(0)) == 0 || project.getProPrice().compareTo(BigDecimal.valueOf(0)) == 0) {
+                                divide = BigDecimal.valueOf(0);
+                            } else {
+                                divide = tjPackageProject.getPriceNow().divide(project.getProPrice(), 5, RoundingMode.HALF_DOWN);
+                            }
                             List<TjProject> tjProSonList = projectService.getTjProjectListBySoneId(String.valueOf(project.getProId()));
                             if (null != tjProSonList && tjProSonList.size() > 0) {
                                 //addRedisTransitionPac(cusId, tbTransitionList, pacId, tjPackageProject, project, divide, tjProSonList);
@@ -1126,7 +1578,7 @@
         //鍗曢」
         if (null != proIds && proIds.size() > 0) {
             //寮傛淇濆瓨鏁版嵁搴撹〃
-            asyncService.saveRedisTransitionByPacId(cusId, null, proIds);
+            asyncService.saveRedisTransitionByPacId(cusId,cardId,null, proIds);
             for (Long proId : proIds) {
                 List<TbTransition> transitions = transitionService.getTbTransitionListByCusIdAndPacIdAndProId(cusId, String.valueOf(proId));
                 if (null != transitions && transitions.size() > 0) {
@@ -1170,6 +1622,8 @@
                 }
             }
         }
+
+
         if (null != tbTransitionList && tbTransitionList.size() > 0) {
             if (redisCache.hasKey(cardId + cusId)) {
                 redisCache.deleteObject(cardId + cusId);
@@ -1232,7 +1686,7 @@
                     for (TjOrder order : list) {
                         TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId());
                         if (null != tjCustomer) {
-                            order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
+                            order.setTjCustomerName(tjCustomer.getCusName());
                             order.setTjCustomerSex(tjCustomer.getCusSex());
                             order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
                             order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
@@ -1286,7 +1740,7 @@
             for (TjOrder order : list) {
                 TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId());
                 if (null != tjCustomer) {
-                    order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
+                    order.setTjCustomerName(tjCustomer.getCusName());
                     order.setTjCustomerSex(tjCustomer.getCusSex());
                     order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
                     order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
@@ -1348,6 +1802,7 @@
      */
     @PostMapping("/tjGoOut")
     @ApiOperation(value = "浣撴绛剧")
+    @Transactional
     public AjaxResult tjGoOut(@RequestBody Map<String, Object> map) {
         Long userId = Long.valueOf(SecurityUtils.getLoginUser().getUserId());
         SysUser sysUser = userService.getById(userId);
@@ -1355,6 +1810,7 @@
         String jsonString = com.alibaba.fastjson.JSON.toJSONString(domainVos1);
         List<QjDomainVo> domainVos = com.alibaba.fastjson.JSON.parseArray(jsonString, QjDomainVo.class);
         String tjNumber = map.get("tjNumber").toString();
+        TjOrder tjOrder = tjOrderService.getOrderByTjNum(tjNumber);
         if (null != domainVos && domainVos.size() > 0) {
             Set<String> list = new HashSet<>();
             for (QjDomainVo domainVo : domainVos) {
@@ -1368,7 +1824,6 @@
                     if (domainVo.getType() == 3) {
                         list.add(String.valueOf(domainVo.getTjNumber()));
                     } else {
-                        TjOrder tjOrder = tjOrderService.getOrderByTjNum(remark.getTjNumber());
                         if (null != tjOrder) {
                             tjOrder.setFinishTime(new Date());
                             tjOrder.setStatus(TjConstants.TJ_CONFIRM);
@@ -1378,6 +1833,11 @@
                 }
             }
             asyncService.tjGoutAsync(domainVos, sysUser, list);
+
+            TjCustomer customer = tjCustomerService.selectTjCustomerByCusId(tjOrder.getUserId());
+            customer.setCardId("0");
+            tjCustomerService.updateById(customer);
+
             return AjaxResult.success("绛剧鎴愬姛锛�");
         } else {
             return getAjaxResult(tjNumber);
@@ -1390,6 +1850,7 @@
      */
     @GetMapping("/goOut")
     @ApiOperation(value = "绛剧")
+    @Transactional
     public AjaxResult goOut(@RequestParam @ApiParam(value = "浣撴鍙�") String tjNumber) {
         return getAjaxResult(tjNumber);
     }
@@ -1413,19 +1874,20 @@
         if (!handleOption.isCanship()) {
             return AjaxResult.error("璁㈠崟涓嶈兘鏍搁攢");
         }
+        Date date = new Date();
         order.setOrderStatus(OrderUtil.STATUS_SHIP.longValue());
-        order.setShipTime(new Date());
-        order.setConfirmTime(new Date());
+        order.setShipTime(date);
+        order.setConfirmTime(date);
 
         MallCheckLog checkLog = new MallCheckLog();
-        String s1 = SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmssSSS").format(new Date());
+        String s1 = SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmssSSS").format(date);
         checkLog.setCheckBy(String.valueOf(SecurityUtils.getUserId()));
         checkLog.setUserId(order.getUserId());
         checkLog.setConsignee(order.getConsignee());
         checkLog.setIdCard(order.getIdCard());
         checkLog.setOrderId(String.valueOf(order.getId()));
         checkLog.setOrderSn(order.getOrderSn());
-        checkLog.setCheckTime(new Date());
+        checkLog.setCheckTime(date);
         checkLog.setShipSn("HX" + s1);
         mallCheckLogService.save(checkLog);
         mallOrderService.updateById(order);
@@ -1436,11 +1898,11 @@
     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 (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<>();
@@ -1451,14 +1913,15 @@
                 TjPackage aPackage = tjPackageService.getById(entry.getValue().get(0).getPacId());
                 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()));
+//                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());
-                }
+//                if (null != project) {
+//                    map.put("nowPrice", project.getPriceNow());
+//                } else {
+//                    map.put("nowPrice", tjProject.getProPrice());
+//                }
+                map.put("nowPrice", transitionService.getTbTransitionDxPriceByPac(cusId, entry.getKey(), cardId, pacId));
             } else {
                 map.put("pacName", "鍗曢」");
                 List<TbTransition> tbTransitionList = entry.getValue();
@@ -1475,8 +1938,6 @@
             }
             map.put("parentName", projectService.getById(entry.getKey()).getProName());
             map.put("list", entry.getValue());
-
-
             list.add(map);
         }
         return list;
@@ -1486,13 +1947,17 @@
         LambdaQueryWrapper<TjOrder> wq0 = new LambdaQueryWrapper<>();
         wq0.eq(TjOrder::getTjNumber, tjNumber);
         TjOrder tjOrder = tjOrderService.getOne(wq0);
+
         if (null != tjOrder) {
+            TjCustomer customer = tjCustomerService.selectTjCustomerByCusId(tjOrder.getUserId());
+            customer.setCardId("0");
+            tjCustomerService.updateById(customer);
+
             LambdaQueryWrapper<TjOrderDetail> wq11 = new LambdaQueryWrapper<>();
             wq11.eq(TjOrderDetail::getOrderId, tjOrder.getOrderId());
             wq11.eq(TjOrderDetail::getTjStatus, 0);
             wq11.isNotNull(TjOrderDetail::getFlowingWaterId);
             List<TjOrderDetail> list = tjOrderDetailService.list(wq11);
-
             if (list != null) {
                 Long userId = Long.valueOf(SecurityUtils.getLoginUser().getUserId());
                 SysUser sysUser = userService.getById(userId);
@@ -1711,6 +2176,11 @@
         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);
         }
 //        System.out.println("杩欐浠g爜鏃堕棿" + (System.currentTimeMillis() - l));
     }
@@ -1813,4 +2283,202 @@
         return AjaxResult.success("鏆傛棤鍘嗗彶璁板綍");
     }
 
+
+    @GetMapping("/getHistryTjOrderByCusId")
+    @ApiOperation(value = "鏍规嵁瀹㈡埛id鏌ョ湅鍘嗗彶浣撴璁板綍")
+    @Transactional
+    public AjaxResult getHistryTjOrderByCusId(@RequestParam String cusId) {
+        TjCustomer tjCustomer = tjCustomerService.getById(cusId);
+        List<HistoryTjOrder> list = new ArrayList<>();
+        if (null != tjCustomer) {
+            List<TjOrder> orderList = tjOrderService.getTjOrderListByCusId(tjCustomer.getCusId());
+            for (TjOrder order : orderList) {
+                HistoryTjOrder historyTjOrder = new HistoryTjOrder();
+                historyTjOrder.setUserName(tjCustomer.getCusName());
+                historyTjOrder.setTjNum(order.getTjNumber());
+                historyTjOrder.setTjTime(order.getCreateTime());
+                historyTjOrder.setTjProName(tjOrderService.getHistoryTjOrderProByTjNum(order.getTjNumber()));
+
+                //鏌ユ祦姘�
+                BigDecimal res = new BigDecimal(0);
+                LambdaQueryWrapper<TjFlowingWater> wqq = new LambdaQueryWrapper<>();
+                wqq.eq(TjFlowingWater::getOrderId, order.getOrderId());
+                final List<TjFlowingWater> list1 = tjFlowingWaterService.list(wqq);
+                if (list1 != null) {
+                    for (TjFlowingWater tjFlowingWater : list1) {
+                        if (tjFlowingWater != null && tjFlowingWater.getPaidIn() != null) {
+                            res.add(tjFlowingWater.getPaidIn());
+                        }
+                    }
+                }
+                historyTjOrder.setPaidIn(res);
+                list.add(historyTjOrder);
+            }
+        }
+        return AjaxResult.success(list);
+    }
+
+
+    @GetMapping("/revokeTjOrderByTjNum")
+    @ApiOperation(value = "鏍规嵁瀹㈡埛浣撴鍙锋挙閿�浣撴璁板綍")
+    @Transactional
+    public AjaxResult revokeTjOrderByTjNum(@RequestParam @ApiParam(value = "浣撴鍙�") String tjNum) {
+
+        TjOrder order = tjOrderService.getOrderByTjNum(tjNum);
+        if (null != order) {
+            String payByTjNum = tjOrderService.isPayByTjNum(String.valueOf(order.getOrderId()));
+            if (null != payByTjNum) {
+                return AjaxResult.success("璇ョ敤鎴峰凡鏀惰垂涓嶅彲鎾ら攢绛惧埌!");
+            }
+            tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
+            tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId()));
+            remarkService.deletedOrderRemarkByTjNum(tjNum);
+            tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId()));
+            transitionService.deletedTbTransitionByTjNum(tjNum);
+            transitionService.updateTbTransitionByTjNum(tjNum);
+            String configByKey = configService.selectConfigByKey("sfkqdyhis");
+            if (configByKey.equals("Y")){
+                HashMap<String, Object> map = new HashMap<>();
+                map.put("cardtype","4");
+                map.put("input",order.getCardId());
+                LocalDate currentDate = LocalDate.now();
+                LocalDateTime startOfDay = currentDate.atStartOfDay();
+                LocalDateTime nineteenOClock = currentDate.atTime(LocalTime.of(19, 0));
+                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+                String ksrq = startOfDay.format(formatter);
+                String jsrq = nineteenOClock.format(formatter);
+                map.put("ksrq",ksrq);
+                map.put("jsrq",jsrq);
+                AjaxResult result = hisApiGetMethodService.getHISDataNew("Getoutpatientcostinfo", map);
+                if (Integer.parseInt(String.valueOf(result.get("code"))) == 200){
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return AjaxResult.error("鎾ら攢澶辫触,闂ㄨ瘖鎮h�呰垂鐢ㄦ竻鍗曚俊鎭笉涓虹┖");
+                }else {
+                    boolean zfHisApiMethods = hisApiMethod.ZfHisApiMethods(null, order);
+                    if (zfHisApiMethods) {
+                        return AjaxResult.success("鎾ら攢鎴愬姛", map);
+                    }else {
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return AjaxResult.error("鎾ら攢澶辫触,璋冪敤浣滃簾鍑虹幇澶辫触");
+                    }
+                }
+            }
+            return AjaxResult.success("鎾ら攢鎴愬姛!!!");
+        }
+        return AjaxResult.success("绛惧埌璁板綍涓嶅瓨鍦�!");
+    }
+
+
+    @GetMapping("/getCusTomterListByCompId")
+    @ApiOperation(value = "鑾峰彇鍗曚綅id浣撴浜轰俊鎭帴鍙�")
+    public AjaxResult getCusTomterListByCompId(@RequestParam(required = false) @ApiParam(value = "鍗曚綅id") String compId,
+                                               @RequestParam(required = false) @ApiParam(value = "鍚嶅瓧") String name,
+                                               @RequestParam(required = false) @ApiParam(value = "閮ㄩ棬id") String deptId,
+                                               @RequestParam(required = false) @ApiParam(value = "棰勭害鏃堕棿") Date reservationTime,
+                                               @RequestParam(defaultValue = "1") Integer page,
+                                               @RequestParam(defaultValue = "10") Integer pageSize) {
+        Page<TjReservation> pages = new Page<>(page, pageSize);
+        LambdaQueryWrapper<TjReservation> wq = new LambdaQueryWrapper<>();
+        if (null != compId) wq.eq(TjReservation::getCompanyId, compId);
+        if (null != name) wq.eq(TjReservation::getName, name);
+        if (null != deptId) wq.eq(TjReservation::getDepartment, deptId);
+        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) {
+            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) {
+                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());
+                Page<TjReservation> page1 = tjReservationService.page(pages, wq3);
+                return AjaxResult.success(page1);
+
+            }
+        }
+        return AjaxResult.success("鏆傛棤淇℃伅");
+    }
+
+
+    @PostMapping("/plRevokeTjOrderByTjNum")
+    @ApiOperation(value = "鏍规嵁瀹㈡埛浣撴鍙锋壒閲忔挙閿�浣撴璁板綍")
+    @Transactional
+    public AjaxResult plRevokeTjOrderByTjNum(@RequestBody @ApiParam(value = "棰勭害涓婚敭id闆嗗悎") List<String> reservationIds) {
+        if (null != reservationIds && reservationIds.size() > 0) {
+            LambdaQueryWrapper<TjOrder> wq1 = new LambdaQueryWrapper<>();
+            wq1.in(TjOrder::getReservationId, reservationIds);
+            List<TjOrder> orderList = tjOrderService.list(wq1);
+            if (null != orderList && orderList.size() > 0) {
+                for (TjOrder order : orderList) {
+//                TjOrder order = tjOrderService.getOrderByTjNum(tjNum);
+                    if (null != order) {
+//                        String payByTjNum = tjOrderService.isPayByTjNum(String.valueOf(order.getOrderId()));
+//                        if (null != payByTjNum) {
+//                            return AjaxResult.success("璇ョ敤鎴峰凡鏀惰垂涓嶅彲鎾ら攢绛惧埌!");
+//                        }
+                        tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
+                        tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId()));
+                        remarkService.deletedOrderRemarkByTjNum(order.getTjNumber());
+                        tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId()));
+                        transitionService.deletedTbTransitionByTjNum(order.getTjNumber());
+                        transitionService.updateTbTransitionByTjNum(order.getTjNumber());
+                    }
+                }
+                for (String id : reservationIds) {
+                    TjReservation reservation = tjReservationService.getById(id);
+                    if (null != reservation) {
+                        reservation.setIsExpire(2);
+                        tjReservationService.updateById(reservation);
+                    }
+                }
+            }
+            return AjaxResult.success("鎾ら攢鎴愬姛!!!");
+        }
+        return AjaxResult.error("璇烽�夋嫨瑕佹挙閿�鐨勪汉鍛�!");
+    }
+
+    @PostMapping("makeTjPDF")
+    @ApiOperation(value = "鎵归噺鐢熸垚PDF")
+    public AjaxResult makeTjPDF(@RequestBody List<String> reservations) {
+        QueryWrapper<TjOrder> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in("reservation_id",reservations);
+        List<TjOrder> tjNumbers = tjOrderService.list(queryWrapper);
+        Map<String, Object> map = null;
+        try {
+            map = PDFDocumentUtil.getDocument();
+            Document document = (Document) map.get("document");
+            for (int i = 0; i < tjNumbers.size(); i++) {
+                String tjNumber = tjNumbers.get(i).getTjNumber();
+                try {
+                    List<Map<String, String>> djdInfos = tjOrderService.selectDjdInfo(tjNumber);
+                    Map<String, Object> userInfo = tjOrderService.selectDjdUserInfo(tjNumber);
+                    LocalDateTime tjsj = (LocalDateTime) userInfo.get("tjsj");
+                    DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
+                    String time = null;
+                    if (tjsj != null) {
+                        time = dateFormat.format(tjsj);
+                    }
+                    PDFDocumentUtil.makeUserInfoTable(document, (String) userInfo.get("tjname"), (String) userInfo.get("sex")
+                            , (String) userInfo.get("tjh"), (String) userInfo.get("lxdh"), (String) userInfo.get("tjname"), time);
+                    PDFDocumentUtil.makeTjInfo(document, djdInfos);
+                    // 澶氭潯鍒欐崲椤�
+                    if (i + 1 < tjNumbers.size()) {
+                        document.newPage();
+                    }
+                } catch (DocumentException | IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            document.close();
+            ByteArrayOutputStream outputStream = (ByteArrayOutputStream) map.get("stream");
+            String encodeToString = java.util.Base64.getEncoder().encodeToString(outputStream.toByteArray());
+            return AjaxResult.success().put("file", encodeToString);
+        } catch (IOException | DocumentException e) {
+            e.printStackTrace();
+            return AjaxResult.error(e.getMessage());
+        }
+    }
 }
+

--
Gitblit v1.8.0