mitao
2025-03-28 b44b174f656aac1fe03e7f96851e564c3982f67d
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
package com.sinata.web.controller.applet;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.google.common.collect.Lists;
import java.util.Date;
 
import com.sinata.common.core.domain.R;
import com.sinata.common.core.domain.entity.SysUser;
import com.sinata.common.entity.PageDTO;
import com.sinata.common.utils.SecurityUtils;
import com.sinata.system.domain.*;
import com.sinata.system.domain.dto.CheckOutDto;
import com.sinata.system.domain.dto.CollectTotalUpDto;
import com.sinata.system.domain.query.CheckoutRecordQuery;
import com.sinata.system.domain.query.MwCheckoutRecordItemQuery;
import com.sinata.system.domain.query.MwTransitRecordQuery;
import com.sinata.system.domain.vo.MwCheckoutRecordVO;
import com.sinata.system.domain.vo.MwMedicalWasteBoxVO;
import com.sinata.system.domain.vo.MwTransitRecordVO;
import com.sinata.system.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.naming.ldap.PagedResultsControl;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
 
/**
 * <p>
 * 暂存间出库记录 前端控制器
 * </p>
 *
 * @author mitao
 * @since 2024-12-02
 */
@Api(tags = {"医院工作人员"})
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/applet/mwCheckoutRecord")
public class AppMwCheckoutRecordController {
    private final MwCheckoutRecordService mwCheckoutRecordService;
    private final ISysUserService userService;
    private final MwTransitCarService carService;
    private final MwDisposalRecordService disposalRecordService;
    private final MwDisposalHandleRecordService handleRecordService;
    private final SysDepartmentService departmentService;
 
 
    @ApiOperation(value = "出库统计上")
    @PostMapping("/total")
    public R<List<CollectTotalUpDto>> total(@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)LocalDate date) {
        SysUser sysUser = SecurityUtils.getLoginUser().getUser();
        SysUser byId = userService.getById(sysUser.getUserId());
        return R.ok(mwCheckoutRecordService.totalUp(date,byId.getDepartmentId()));
    }
 
    @ApiOperation(value = "接收统计上",tags = "处置人员")
    @PostMapping("/out/total")
    public R<List<CollectTotalUpDto>> outtotal(@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)LocalDate date) {
        SysUser sysUser = SecurityUtils.getLoginUser().getUser();
        return R.ok(mwCheckoutRecordService.totalUp2(date,sysUser.getUserId()));
    }
    @ApiOperation(value = "接收统计下",tags = "处置人员")
    @PostMapping("/out/record")
    public R<List<CheckOutDto>> record1(@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date) {
        SysUser sysUser1 = SecurityUtils.getLoginUser().getUser();
        SysUser sysUser = userService.getById(sysUser1.getUserId());
        LocalDate now = LocalDate.now();
        List<MwDisposalRecord> list = disposalRecordService.lambdaQuery().ge(date!=null,MwDisposalRecord::getReceiveTime, date.atStartOfDay()).le(date!=null,MwDisposalRecord::getReceiveTime,date.atTime(23,59,59)).eq(MwDisposalRecord::getDepartmentId, sysUser.getDepartmentId()).orderByDesc(MwDisposalRecord::getReceiveTime).list();
        List<CheckOutDto> backList = new ArrayList<>();
        for (MwDisposalRecord mwCheckoutRecord : list) {
            CheckOutDto checkOutDto = new CheckOutDto();
            SysUser byId = userService.getById(mwCheckoutRecord.getDriverId());
            checkOutDto.setDriverName(byId.getNickName());
            MwTransitCar byId1 = carService.getById(mwCheckoutRecord.getCarId());
            checkOutDto.setLicensePlateNumber(byId1.getLicensePlateNumber());
            checkOutDto.setCheckoutTime(mwCheckoutRecord.getReceiveTime());
            List<CollectTotalUpDto> records =  mwCheckoutRecordService.totalUp6(mwCheckoutRecord.getId());
            checkOutDto.setRecords(records);
            backList.add(checkOutDto);
        }
        return R.ok(backList);
    }
 
    @ApiOperation(value = "处置统计上",tags = "处置人员")
    @PostMapping("/end/total")
    public R<List<CollectTotalUpDto>> outtotal1(@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)LocalDate date) {
        SysDepartment myDepartment = departmentService.getMyDepartment();
        List<CollectTotalUpDto> collectTotalUpDtos = mwCheckoutRecordService.totalUp2(date, myDepartment.getId());
        return R.ok(collectTotalUpDtos);
    }
 
    @ApiOperation(value = "处置统下",tags = "处置人员")
    @PostMapping("/end/record")
    public R<List<CheckOutDto>> record2(@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date) {
        SysDepartment myDepartment = departmentService.getMyDepartment();
        LocalDate now = LocalDate.now();
        List<MwDisposalHandleRecord> list = handleRecordService.lambdaQuery().ge(date!=null,MwDisposalHandleRecord::getDisposalTime, date.atStartOfDay()).le(date!=null,MwDisposalHandleRecord::getDisposalTime,date.atTime(23,59,59)).eq(MwDisposalHandleRecord::getDepartmentId, myDepartment.getId()).orderByDesc(MwDisposalHandleRecord::getDisposalTime).list();
        List<CheckOutDto> backList = new ArrayList<>();
        for (MwDisposalHandleRecord mwCheckoutRecord : list) {
            CheckOutDto checkOutDto = new CheckOutDto();
            SysUser byId = userService.getById(mwCheckoutRecord.getDriverId());
            checkOutDto.setDriverName(byId.getNickName());
            MwTransitCar byId1 = carService.getById(mwCheckoutRecord.getCarId());
            if (byId1!=null){
                checkOutDto.setLicensePlateNumber(byId1.getLicensePlateNumber());
            }
            checkOutDto.setCheckoutTime(mwCheckoutRecord.getDisposalTime());
            List<CollectTotalUpDto> records =  mwCheckoutRecordService.totalUp1(mwCheckoutRecord.getId());
            checkOutDto.setRecords(records);
            backList.add(checkOutDto);
        }
        return R.ok(backList);
    }
 
 
 
 
    @ApiOperation(value = "出库统计下")
    @PostMapping("/record")
    public R<List<CheckOutDto>> record(@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)LocalDate date) {
        SysUser sysUser = SecurityUtils.getLoginUser().getUser();
        SysUser byId2 = userService.getById(sysUser.getUserId());
        LocalDate now = LocalDate.now();
        List<MwCheckoutRecord> list = mwCheckoutRecordService.lambdaQuery().ge(MwCheckoutRecord::getCreateTime, date.atStartOfDay())
                .le(MwCheckoutRecord::getCreateTime, date.atTime(23,59,59)).eq(MwCheckoutRecord::getDepartmentId, byId2.getDepartmentId()).orderByDesc(MwCheckoutRecord::getCheckoutTime).list();
        List<CheckOutDto> backList = new ArrayList<>();
        for (MwCheckoutRecord mwCheckoutRecord : list) {
            CheckOutDto checkOutDto = new CheckOutDto();
            SysUser byId = userService.getById(mwCheckoutRecord.getDriverId());
            checkOutDto.setDriverName(byId.getNickName());
            MwTransitCar byId1 = carService.getById(mwCheckoutRecord.getCarId());
            checkOutDto.setLicensePlateNumber(byId1.getLicensePlateNumber());
            checkOutDto.setCheckoutTime(mwCheckoutRecord.getCheckoutTime());
            List<CollectTotalUpDto> records =  mwCheckoutRecordService.totalUp1(mwCheckoutRecord.getId());
            checkOutDto.setRecords(records);
            backList.add(checkOutDto);
        }
        return R.ok(backList);
    }
 
 
}