zjh
2025-02-17 206a888c39eed2c58f4dab3c5bfcac7f068a0ea9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package com.ltkj.web.controller.app;
 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.ltkj.common.core.domain.entity.SysDept;
import com.ltkj.common.utils.ip.IpUtils;
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.service.*;
import com.ltkj.system.service.ISysConfigService;
import com.ltkj.system.service.ISysDeptService;
import com.ltkj.web.payConfig.PayConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.io.IOUtils;
import org.apache.tomcat.util.http.ResponseUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import com.ltkj.common.annotation.Log;
import com.ltkj.common.core.controller.BaseController;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.common.enums.BusinessType;
import com.ltkj.common.utils.poi.ExcelUtil;
import com.ltkj.common.core.page.TableDataInfo;
import springfox.documentation.annotations.ApiIgnore;
 
/**
 * 小程序预约下单Controller
 *
 * @author ltkj_赵佳豪&李格
 * @date 2023-05-18
 */
@RestController
@RequestMapping("/cus/appOrder")
@Api(tags = "小程序体检记录订单接口")
public class TjAppOrderController extends BaseController {
//    @Autowired
//    private ITjAppOrderService tjAppOrderService;
    @Resource
    private ITjOrderService tjOrderService;
    @Resource
    private ITjCustomerService tjCustomerService;
    @Resource
    private ITjOrderDetailService tjOrderDetailService;
    @Resource
    private ITjPackageService tjPackageService;
    @Resource
    private ITjProjectService projectService;
    @Resource
    private ISysDeptService deptService;
 
 
    /**
     * 小程序端查询体检记录
     */
    @GetMapping("/getTiJianList")
    @ApiOperation(value = "小程序端查询体检记录")
    public AjaxResult getTiJianList(@RequestParam @ApiParam(value = "cusIdCard") String cusIdCard) {
        LambdaQueryWrapper<TjCustomer> wqqq = new LambdaQueryWrapper<>();
        wqqq.eq(TjCustomer::getCusIdcard, cusIdCard);
        TjCustomer one1 = tjCustomerService.getOne(wqqq);
        if (one1 != null) {
            LambdaQueryWrapper<TjOrder> wq0 = new LambdaQueryWrapper<>();
            wq0.eq(TjOrder::getUserId, one1.getCusId());
            List<TjOrder> tjOrders = tjOrderService.list(wq0);
 
            if (tjOrders != null && tjOrders.size() > 0) {
                for (TjOrder tjOrder : tjOrders) {
                    if (tjOrder.getFinishTime() != null) {
                        tjOrder.setTjFinishStatus("已完成");
                    } else {
                        tjOrder.setTjFinishStatus("未完成");
                    }
                }
            }
            return AjaxResult.success(tjOrders);
        }
        return AjaxResult.error("查无此人");
 
    }
 
    /**
     * 小程序端根据体检号查询体检项目信息
     */
    @GetMapping("/getPaiDuiList")
    @ApiOperation(value = "小程序端根据体检号查询体检项目信息")
    public AjaxResult getPaiDuiList(@RequestParam @ApiParam(value = "tjNumber") String tjNumber) {
        Map<String, Object> res = new HashMap<>();
        TjCustomer byId = new TjCustomer();
        List<SysDept> keshi = new ArrayList<>();
 
        LambdaQueryWrapper<TjOrder> wq0 = new LambdaQueryWrapper<>();
        wq0.eq(TjOrder::getTjNumber, tjNumber);
        TjOrder tjOrder = tjOrderService.getOne(wq0);
        if (tjOrder != null) {
            if (tjOrder.getUserId() != null) {
                byId = tjCustomerService.getById(tjOrder.getUserId());
            }
            res.put("customer", byId);
 
            LambdaQueryWrapper<TjOrderDetail> wq01 = new LambdaQueryWrapper<>();
            wq01.eq(TjOrderDetail::getOrderId, tjOrder.getOrderId());
            wq01.isNotNull(TjOrderDetail::getFlowingWaterId);
            List<TjOrderDetail> list = tjOrderDetailService.list(wq01);
 
            if (null != list && list.size() != 0) {
                for (TjOrderDetail tjOrderDetail : list) {
                    LambdaQueryWrapper<TjProject> wq1 = new LambdaQueryWrapper<>();
                    wq1.eq(TjProject::getProId, tjOrderDetail.getProId());
                    wq1.eq(TjProject::getProParentId, "0");
                    TjProject one = projectService.getOne(wq1);
                    if (one != null) {
                        //查出该项目所在科室名称
                        SysDept sysDept = deptService.getById(one.getDeptId());
                        if (sysDept != null) {
                            sysDept.setCheckStatus(tjOrderDetail.getTjStatus());
                            keshi.add(sysDept);
                        }
                    }
                }
            }
            //查询体检套餐
            if (tjOrder.getPacId() != null) {
                if(!"0".equals(tjOrder.getPacId())){
                    TjPackage byId1 = tjPackageService.getById(tjOrder.getPacId());
                    if (byId1 != null) {
                        tjOrder.setPacName(byId1.getPacName());
                    }
                }else {
                    tjOrder.setPacName("无");
                }
            } else {
                tjOrder.setPacName("无");
            }
        }
        List<SysDept> depts = keshi.stream().distinct().collect(Collectors.toList());
        res.put("depts", depts);
        res.put("tjorder", tjOrder);
        return AjaxResult.success(res);
    }
}