From dba27f21bc05c999ace46fe15be6e4c824ed9104 Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期五, 13 十二月 2024 18:40:09 +0800
Subject: [PATCH] zjh202412013

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java |   83 +++++++++++++++++++++++++++++++++++------
 ltkj-hosp/src/main/java/com/ltkj/hosp/service/IDictCompService.java            |    2 +
 ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/DictCompServiceImpl.java    |    6 +++
 ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/DictCompMapper.java               |    4 ++
 4 files changed, 83 insertions(+), 12 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 6f3db93..047ce66 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
@@ -80,6 +80,7 @@
 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;
@@ -547,10 +548,11 @@
                                      @ApiParam(value = "鎵撳嵃鏈墦鍗扮姸鎬� 0鏈墦鍗� 1宸叉墦鍗�") @RequestParam(defaultValue = "0") Integer dyzt,
                                      @ApiParam(value = "浣撴鍙�)") @RequestParam(required = false) String tjNum,
                                      @ApiParam(value = "濮撳悕)") @RequestParam(required = false) String name,
+                                     @ApiParam(value = "鍗曚綅") @RequestParam(required = false) String dw,
                                      @ApiParam(value = "鎶ュ憡寮�濮嬫椂闂�") @RequestParam(required = false) String djbeginTime,
                                      @ApiParam(value = "鎶ュ憡缁撴潫鏃堕棿") @RequestParam(required = false) String djendTime) {
         Map<String, Object> map = new HashMap<>();
-        if (null != name) {
+        if (StringUtil.isNotBlank(name)) {
             LambdaQueryWrapper<TjCustomer> wqq = new LambdaQueryWrapper<>();
             wqq.like(TjCustomer::getCusName, name);
             List<TjCustomer> customerList = tjCustomerService.list(wqq);
@@ -599,17 +601,6 @@
                                 list.get(i).setPacName(dwDeptService.getById(list.get(i).getPacId()).getDwDeptName());
                             }
                         }
-
-                        //浠庢墦鍗拌褰曟煡鍑烘渶鏂版墦鍗版椂闂�
-                        LambdaQueryWrapper<TjReportPrint> wqqq = new LambdaQueryWrapper<>();
-                        wqqq.eq(TjReportPrint::getTjNumber, list.get(i).getTjNumber());
-                        wqqq.orderByDesc(TjReportPrint::getPrintTime);
-                        wqqq.last("limit 1");
-                        TjReportPrint one = tjReportPrintService.getOne(wqqq);
-                        if (one != null) {
-                            list.get(i).setPrintLastTime(one.getPrintTime());
-                        }
-
                     }
                     collect = list.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
                 }
@@ -623,6 +614,74 @@
             }
 
         }
+        if (StringUtil.isNotBlank(dw)) {
+            LambdaQueryWrapper<TjCustomer> wqq = new LambdaQueryWrapper<>();
+            wqq.like(TjCustomer::getCompName,dw);
+            List<TjCustomer> customerList = tjCustomerService.list(wqq);
+            List<TjOrder> list = new ArrayList<>();
+            if (null != customerList && !customerList.isEmpty()) {
+                for (TjCustomer customer : customerList) {
+                    LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>();
+                    wq.eq(TjOrder::getUserId, customer.getCusId());
+                    if (dyzt == 0) {
+                        wq.isNull(TjOrder::getPrintLastTime);
+                        wq.eq(TjOrder::getHeshouStatus, 1);
+                    } else {
+                        wq.isNotNull(TjOrder::getPrintLastTime);
+                    }
+                    list.addAll(tjOrderService.list(wq));
+                }
+            }
+             List<String> dwIds=  iDictCompService.getdwIdByDwName(dw);
+
+            LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>();
+            wq.in(TjOrder::getFirmId,dwIds);
+            list.addAll(tjOrderService.list(wq));
+            List<TjOrder> collect = null;
+                if (!list.isEmpty()) {
+                    List<TjOrder> orders = list.stream().distinct().collect(Collectors.toList());
+                    for (int i = 0; i < orders.size(); i++) {
+                        TjCustomer tjCustomer = tjCustomerService.getById(list.get(i).getUserId());
+                        if (null == tjCustomer) {
+                            list.remove(list.get(i));
+                            continue;
+                        }
+                        list.get(i).setTjCustomerSex(tjCustomer.getCusSex());
+                        list.get(i).setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
+                        list.get(i).setTjCustomerName(tjCustomer.getCusName());
+                        list.get(i).setTjCustomerPhone(tjCustomer.getCusPhone());
+                        list.get(i).setTjCusIdCard(tjCustomer.getCusIdcard());
+
+                        if (null != tjCustomer.getCompName()) {
+                            list.get(i).setDictCompName(tjCustomer.getCompName());
+                        } else {
+                            String firmId = list.get(i).getFirmId();
+                            if (firmId != null && null != iDictCompService.getById(String.valueOf(list.get(i).getFirmId()))) {
+                                list.get(i).setDictCompName(iDictCompService.getById(String.valueOf(list.get(i).getFirmId())).getCnName());
+                            }
+                        }
+
+                        if (null != list.get(i).getPacId()) {
+                            if (null != tjPackageService.getById(list.get(i).getPacId())) {
+                                list.get(i).setPacName(tjPackageService.getById(list.get(i).getPacId()).getPacName());
+                            }
+                            if (null != dwDeptService.getById(list.get(i).getPacId())) {
+                                list.get(i).setPacName(dwDeptService.getById(list.get(i).getPacId()).getDwDeptName());
+                            }
+                        }
+                    }
+                    collect = list.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
+                }
+                if (null != collect) {
+                    map.put("total", collect.size());
+                } else {
+                    map.put("total", 0);
+                }
+                map.put("list", collect);
+                return AjaxResult.success(map);
+
+
+        }
         Page<TjOrder> page1 = new Page<>(pageNum, pageSize);
         LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>();
         if (dyzt == 0) {
diff --git a/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/DictCompMapper.java b/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/DictCompMapper.java
index afbfaf0..36e79c5 100644
--- a/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/DictCompMapper.java
+++ b/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/DictCompMapper.java
@@ -5,6 +5,7 @@
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ltkj.hosp.domain.DictComp;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
 
 /**
  * 浣撴鍗曚綅淇℃伅缁存姢Mapper鎺ュ彛
@@ -61,4 +62,7 @@
      * @return 缁撴灉
      */
     public int deleteDictCompByDrugManufacturerIds(String[] drugManufacturerIds);
+
+    @Select("SELECT a.drug_manufacturer_id FROM dict_comp a WHERE a.deleted=0 AND LOCATE(#{dw},a.cn_name)")
+    List<String> getdwIdByDwName(String dw);
 }
diff --git a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/IDictCompService.java b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/IDictCompService.java
index 33ce733..17bd7c8 100644
--- a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/IDictCompService.java
+++ b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/IDictCompService.java
@@ -59,4 +59,6 @@
      * @return 缁撴灉
      */
     public int deleteDictCompByDrugManufacturerId(String drugManufacturerId);
+
+    List<String> getdwIdByDwName(String dw);
 }
diff --git a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/DictCompServiceImpl.java b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/DictCompServiceImpl.java
index fb72771..6865917 100644
--- a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/DictCompServiceImpl.java
+++ b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/DictCompServiceImpl.java
@@ -1,5 +1,6 @@
 package com.ltkj.hosp.service.impl;
 
+import java.util.Collections;
 import java.util.List;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -88,4 +89,9 @@
     public int deleteDictCompByDrugManufacturerId(String drugManufacturerId) {
         return dictCompMapper.deleteDictCompByDrugManufacturerId(drugManufacturerId);
     }
+
+    @Override
+    public List<String> getdwIdByDwName(String dw) {
+        return dictCompMapper.getdwIdByDwName(dw);
+    }
 }

--
Gitblit v1.8.0