bug
luoyisheng
2025-03-27 fe9a623b42b02e7fcd112f6a85d55b3beeb58d2e
medicalWaste-admin/src/main/java/com/sinata/web/controller/applet/AppMwCollectRecordController.java
@@ -1,34 +1,74 @@
package com.sinata.web.controller.applet;
import java.util.Date;
import java.math.BigDecimal;
import java.util.*;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson2.JSONArray;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.sinata.common.core.domain.R;
import com.sinata.common.core.domain.entity.SysDictData;
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.*;
import com.sinata.system.domain.query.MwCollectRecordQuery;
import com.sinata.system.domain.vo.MedicalWasteProcessVO;
import com.sinata.system.domain.vo.MwCollectRecordVO;
import com.sinata.system.service.*;
import com.sinata.system.domain.MwBox;
import com.sinata.system.domain.MwCheckoutRecord;
import com.sinata.system.domain.MwCheckoutRecordItem;
import com.sinata.system.domain.MwCollectRecord;
import com.sinata.system.domain.MwDisposalHandleRecord;
import com.sinata.system.domain.MwDisposalHandleRecordItem;
import com.sinata.system.domain.MwDisposalRecord;
import com.sinata.system.domain.MwDisposalRecordItem;
import com.sinata.system.domain.MwStagingRoom;
import com.sinata.system.domain.MwTransitCar;
import com.sinata.system.domain.MwTransitCarCollectPoint;
import com.sinata.system.domain.MwTransitRoute;
import com.sinata.system.domain.SysDepartment;
import com.sinata.system.domain.dto.BoxListDto;
import com.sinata.system.domain.dto.CarDto;
import com.sinata.system.domain.dto.CollectCarTotalUpDto;
import com.sinata.system.domain.dto.CollectDto;
import com.sinata.system.domain.dto.CollectTotalDto;
import com.sinata.system.domain.dto.CollectTotalUpDto;
import com.sinata.system.domain.dto.HospitalCollectTotalUp1Dto;
import com.sinata.system.domain.dto.HospitalCollectTotalUpDto;
import com.sinata.system.domain.dto.SignCollectDto;
import com.sinata.system.service.ISysDictDataService;
import com.sinata.system.service.ISysUserService;
import com.sinata.system.service.MwBoxService;
import com.sinata.system.service.MwCheckoutRecordItemService;
import com.sinata.system.service.MwCheckoutRecordService;
import com.sinata.system.service.MwCollectRecordService;
import com.sinata.system.service.MwDisposalHandleRecordItemService;
import com.sinata.system.service.MwDisposalHandleRecordService;
import com.sinata.system.service.MwDisposalRecordItemService;
import com.sinata.system.service.MwDisposalRecordService;
import com.sinata.system.service.MwStagingRoomService;
import com.sinata.system.service.MwTransitCarCollectPointService;
import com.sinata.system.service.MwTransitCarService;
import com.sinata.system.service.MwTransitRouteService;
import com.sinata.system.service.SysDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;
import javax.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.time.LocalDate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * <p>
@@ -58,14 +98,24 @@
    private final MwDisposalHandleRecordItemService disposalHandleRecordItemService;
    private final MwStagingRoomService roomService;
    private final ISysDictDataService dictDataService;
    private final MwTransitCarService carService;
    private final MwTransitCarCollectPointService mwTransitCarCollectPointService;
    private final MwTransitRouteService transitRouteService;
    @ApiOperation(value = "新增医废记录")
    @PostMapping("/add")
    public R<?> add(@Valid @RequestBody MwCollectRecord mwCollectRecord) {
        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
        SysUser  sysUser1 = SecurityUtils.getLoginUser().getUser();
        SysUser  sysUser = userService.getById(sysUser1.getUserId());
        MwBox one = boxService.lambdaQuery().eq(MwBox::getBoxNumber, mwCollectRecord.getBoxNumber()).one();
        if (one==null){
            return R.fail("当前转运箱不存在");
        }
        one.setLink(1);
        one.setLastUseTime(new Date());
        boxService.updateById(one);
        mwCollectRecord.setBoxId(one.getId());
        MwStagingRoom one1 = roomService.lambdaQuery().eq(MwStagingRoom::getDepartmentId, sysUser.getDepartmentId()).one();
        if (one1==null){
@@ -74,6 +124,7 @@
        mwCollectRecord.setStagingRoomId(one1.getId());
        mwCollectRecord.setDepartmentId(sysUser.getDepartmentId());
        mwCollectRecord.setBoxTime(new Date());
        mwCollectRecord.setCollectUserId(sysUser.getUserId());
        // 创建一个随机数生成器实例
        Random random = new Random();
@@ -99,14 +150,18 @@
        }
        Long departmentId = list.get(0).getDepartmentId();
        List<CollectDto> collectDtos =  collectRecordService.getGroup1(boxNumber,departmentId);
        for (CollectDto collectDto : collectDtos) {
            collectDto.setDepartmentName(departmentService.getById(departmentId).getDepartmentName());
        }
        return R.ok(collectDtos);
    }
    @ApiOperation(value = "装车",tags = "运输人员")
    @PostMapping("/box/collect")
    @Transactional(rollbackFor = Exception.class)
    public R<List<CollectDto>> collect(@RequestBody SignCollectDto signCollectDto) {
        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
        SysUser  sysUser1 = SecurityUtils.getLoginUser().getUser();
        SysUser sysUser = userService.getById(sysUser1.getUserId());
        //将收集记录的状态改变
        List<MwCollectRecord> list = collectRecordService.lambdaQuery().eq(MwCollectRecord::getStatus,1).in(MwCollectRecord::getBoxNumber, signCollectDto.getBoxNumbers()).list();
       if (list.isEmpty()){
@@ -117,6 +172,7 @@
        for (MwCollectRecord mwCollectRecord : list) {
            mwCollectRecord.setStatus(2);
            mwCollectRecord.setCheckoutUserId(sysUser.getUserId());
            mwCollectRecord.setCheckoutTime(new Date());
            mwCollectRecord.setDriverId(sysUser.getUserId());
            mwCollectRecord.setCarId(sysUser.getCarId());
            boxes.add(mwCollectRecord.getBoxNumber());
@@ -145,31 +201,62 @@
        }
        checkoutRecordItemService.saveBatch(recordItems);
        collectRecordService.updateBatchById(list);
        MwBox byId = boxService.getById(list.get(0).getStagingRoomId());
        byId.setLink(2);
        boxService.updateById(byId);
        //查询当前医废收集路线
        Long departmentId = list.get(0).getDepartmentId();
        MwTransitRoute route = transitRouteService.queryRouteByDepartmentId(departmentId);
        if (Objects.nonNull(route)){
            //查询当前车辆已运输路线记录
            MwTransitCarCollectPoint carCollectPoint = mwTransitCarCollectPointService.lambdaQuery().eq(MwTransitCarCollectPoint::getCarId, sysUser.getCarId())
                    .eq(MwTransitCarCollectPoint::getRouteId, route.getId())
                    .eq(MwTransitCarCollectPoint::getTransitDate, DateUtil.format(new Date(), DatePattern.NORM_DATE_PATTERN))
                    .last("LIMIT 1").one();
            List<Long> departmentIdList = new ArrayList<>();
            //如果当前收集医院不是第一家且当前收集医院未被记录
            if (Objects.nonNull(carCollectPoint) && !carCollectPoint.getPointList().contains(departmentId.toString())){
                departmentIdList = JSONArray.parseArray(carCollectPoint.getPointList(), Long.class);
                departmentIdList.add(departmentId);
            }else if (Objects.isNull(carCollectPoint) ){//当前医院为第一个收集的医院
                carCollectPoint = new MwTransitCarCollectPoint();
                carCollectPoint.setCarId(carCollectPoint.getCarId());
                carCollectPoint.setRouteId(route.getId());
                carCollectPoint.setTransitDate(new Date());
                departmentIdList.add(departmentId);
            }
            carCollectPoint.setPointList(JSONArray.toJSONString(departmentIdList));
            mwTransitCarCollectPointService.saveOrUpdate(carCollectPoint);
        }
        return R.ok();
    }
    @ApiOperation(value = "运输统计上",tags = "运输人员")
    @PostMapping("/trans/collect/total")
    public R<List<CollectTotalUpDto>> tanscollecttotal1(LocalDate date) {
    public R<List<CollectTotalUpDto>> tanscollecttotal1(@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)LocalDate date) {
        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
        return R.ok(collectRecordService.collectTotal1(date,sysUser.getUserId(),null));
    }
    @ApiOperation(value = "运输统计上(医院数量)",tags = "运输人员")
    @PostMapping("/trans/collect/hospital/count")
    public R<Long> tanscollecttotal12(LocalDate date) {
    public R<Integer> tanscollecttotal12(@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)LocalDate date) {
        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
        Long count = collectRecordService.lambdaQuery().eq(date!=null,MwCollectRecord::getCheckoutTime,date).eq(MwCollectRecord::getCheckoutUserId, sysUser.getUserId()).groupBy(MwCollectRecord::getDepartmentId).count();
        return R.ok(count);
        List<MwCollectRecord> list = collectRecordService.lambdaQuery().ge(date != null, MwCollectRecord::getCheckoutTime, date.atStartOfDay()).le(date != null, MwCollectRecord::getCheckoutTime, date.atTime(23, 59, 59)).eq(MwCollectRecord::getCheckoutUserId, sysUser.getUserId()).groupBy(MwCollectRecord::getDepartmentId).list();
        return R.ok(list.size());
    }
    @ApiOperation(value = "运输统计下",tags = "运输人员")
    @PostMapping("/trans/down/collect/total")
    public R<List<HospitalCollectTotalUpDto>> tanscollecttotal2(LocalDate date) {
    public R<List<HospitalCollectTotalUpDto>> tanscollecttotal2(@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)LocalDate date) {
        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
        //先获取医院ids
        List<MwCollectRecord> list = collectRecordService.lambdaQuery().eq(date!=null,MwCollectRecord::getCheckoutTime,date).eq(MwCollectRecord::getCheckoutUserId, sysUser.getUserId()).groupBy(MwCollectRecord::getDepartmentId).list();
        List<MwCollectRecord> list = collectRecordService.lambdaQuery().ge(MwCollectRecord::getCheckoutTime, date.atStartOfDay())
                .le(MwCollectRecord::getCheckoutTime, date.atTime(23,59,59))
                .eq(MwCollectRecord::getCheckoutUserId, sysUser.getUserId()).groupBy(MwCollectRecord::getDepartmentId).list();
        //循环医院,然后放入
        List<HospitalCollectTotalUpDto> list1 = new ArrayList<>();
        for (MwCollectRecord mwCollectRecord : list) {
@@ -185,7 +272,6 @@
    @ApiOperation(value = "扫码接收列表",tags = "处置人员")
    @PostMapping("/end/down/collect/total")
    public R<List<HospitalCollectTotalUp1Dto>> tanscollecttotal3(String boxNum) {
        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
        MwCollectRecord one = collectRecordService.lambdaQuery().eq(MwCollectRecord::getBoxNumber, boxNum).eq(MwCollectRecord::getStatus, 2).last("limit 1").one();
        if (one==null){
            return R.ok();
@@ -195,7 +281,7 @@
        //循环医院,然后放入
        List<HospitalCollectTotalUp1Dto> list1 = new ArrayList<>();
        for (MwCollectRecord mwCollectRecord : list) {
            List<CollectDto> collectTotalUpDtos = collectRecordService.getGroup1(null, mwCollectRecord.getDepartmentId());
            List<CollectDto> collectTotalUpDtos = collectRecordService.getGroup2(null, mwCollectRecord.getDepartmentId());
            HospitalCollectTotalUp1Dto hospitalCollectTotalUpDto = new HospitalCollectTotalUp1Dto();
            hospitalCollectTotalUpDto.setHospitalName(mwCollectRecord.getHospitalName());
            hospitalCollectTotalUpDto.setCollectTotalUpDtos(collectTotalUpDtos);
@@ -204,13 +290,46 @@
        return R.ok(list1);
    }
    @ApiOperation(value = "获取车辆",tags = "处置人员")
    @PostMapping("/end/down/collect/car")
    public R<CarDto> tanscollecttotal7(String boxNum) {
        MwCollectRecord one = collectRecordService.lambdaQuery().eq(MwCollectRecord::getBoxNumber, boxNum).eq(MwCollectRecord::getStatus, 2).last("limit 1").one();
        if (one == null) {
            return R.ok();
        }
        MwTransitCar byId = carService.getById(one.getCarId());
        SysUser one1 = userService.lambdaQuery().eq(SysUser::getCarId, byId.getId()).last("limit 1").one();
        CarDto carDto = new CarDto();
        carDto.setLicensePlateNumber(byId.getLicensePlateNumber());
        carDto.setUserName(one1.getNickName());
        return R.ok(carDto);
    }
    @ApiOperation(value = "扫码接收列表上获取医院",tags = "处置人员")
    @PostMapping("/end/down/collect/up")
    public R<SysDepartment> tanscollecttotal4(String boxNum) {
        MwCollectRecord one = collectRecordService.lambdaQuery().eq(MwCollectRecord::getBoxNumber, boxNum).eq(MwCollectRecord::getStatus, 2).last("limit 1").one();
        if (one == null) {
            return R.ok();
        }
        SysDepartment byId = departmentService.getById(one.getDepartmentId());
        return R.ok(byId);
    }
    @ApiOperation(value = "确认接受",tags = "处置人员")
    @PostMapping("/end/down/collect/confirm")
    public R tanscollecttotal4(String boxNum) {
        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
    @Transactional(rollbackFor = Exception.class)
    public R tanscollecttotal4(@RequestBody BoxListDto boxListDto) {
        Long userId = SecurityUtils.getUserId();
        SysUser sysUser = userService.getById(userId);
        SysDepartment byId = departmentService.getById(sysUser.getDepartmentId());
        //将record变为已接受
        List<MwCollectRecord> list = collectRecordService.lambdaQuery().eq(MwCollectRecord::getStatus,2).eq(MwCollectRecord::getBoxNumber, boxNum).list();
        List<MwCollectRecord> list = collectRecordService.lambdaQuery().eq(MwCollectRecord::getStatus,2).in(MwCollectRecord::getBoxNumber, boxListDto.getBoxNum()).list();
      if (list.isEmpty()){
          return R.ok();
      }
        Set<String> boxes = new HashSet<>();
        BigDecimal receiveQuantity = BigDecimal.ZERO;
        for (MwCollectRecord mwCollectRecord : list) {
@@ -247,6 +366,21 @@
            items.add(mwDisposalRecordItem);
        }
        disposalRecordItemService.saveBatch(items);
        MwTransitRoute route = transitRouteService.queryRouteByDepartmentId(list.get(0).getDepartmentId());
        if (Objects.nonNull(route)) {
            //查询当前车辆已运输路线记录
            MwTransitCarCollectPoint carCollectPoint = mwTransitCarCollectPointService.lambdaQuery().eq(MwTransitCarCollectPoint::getCarId, sysUser.getCarId())
                    .eq(MwTransitCarCollectPoint::getRouteId, route.getId())
                    .eq(MwTransitCarCollectPoint::getTransitDate, DateUtil.format(new Date(), DatePattern.NORM_DATE_PATTERN))
                    .last("LIMIT 1").one();
            List<Long> departmentIdList = new ArrayList<>();
            if (Objects.nonNull(carCollectPoint)) {
                departmentIdList = JSONArray.parseArray(carCollectPoint.getPointList(), Long.class);
                departmentIdList.add(byId.getId());
                carCollectPoint.setPointList(JSONArray.toJSONString(departmentIdList));
                mwTransitCarCollectPointService.updateById(carCollectPoint);
            }
        }
        return R.ok();
    }
@@ -254,16 +388,22 @@
    @PostMapping("/wait/list")
    public R<List<CollectDto>> list1(String boxNumber) {
        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
        List<CollectDto> collectDtos =  collectRecordService.getGroupWithStatus(boxNumber,sysUser.getDepartmentId(),3);
        SysUser byId = userService.getById(sysUser.getUserId());
        List<CollectDto> collectDtos =  collectRecordService.getGroupWithStatus(boxNumber,byId.getDepartmentId(),3);
        return R.ok(collectDtos);
    }
    @Transactional(rollbackFor = Exception.class)
    @ApiOperation(value = "处置操作",tags = "处置人员")
    @PostMapping("/wait/out")
    public R<List<CollectDto>> list2(String boxNumber) {
        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
    public R<List<CollectDto>> list2(@RequestBody BoxListDto boxListDto) {
        Long userId = SecurityUtils.getUserId();
        SysUser sysUser = userService.getById(userId);
        SysDepartment byId = departmentService.getById(sysUser.getDepartmentId());
        List<MwCollectRecord> list = collectRecordService.lambdaQuery().eq(MwCollectRecord::getStatus, 3).eq(MwCollectRecord::getBoxNumber, boxNumber).list();
        List<MwCollectRecord> list = collectRecordService.lambdaQuery().eq(MwCollectRecord::getStatus, 3).in(MwCollectRecord::getBoxNumber, boxListDto.getBoxNum()).list();
        if (list.isEmpty()){
            return R.ok();
        }
        //新增处置记录
        MwDisposalHandleRecord mwDisposalHandleRecord  = new MwDisposalHandleRecord();
        mwDisposalHandleRecord.setDepartmentId(byId.getId());
@@ -273,42 +413,52 @@
        mwDisposalHandleRecord.setDriverId(list.get(0).getDriverId());
        mwDisposalHandleRecord.setCarId(list.get(0).getCarId());
        disposalHandleRecordService.save(mwDisposalHandleRecord);
        List<Long> collectIdList = list.stream().map(MwCollectRecord::getId).collect(Collectors.toList());
        //查询收集记录对应的接收记录
        List<MwDisposalRecordItem> disposalRecordItems = disposalRecordItemService.lambdaQuery().in(MwDisposalRecordItem::getCollectRecordId, collectIdList).list();
        Map<Long, Long> disposalRecordItemMap = disposalRecordItems.stream().collect(Collectors.toMap(MwDisposalRecordItem::getCollectRecordId, MwDisposalRecordItem::getDisposalRecordId));
        //将收集记录以及子表改变为已处置
        if (!list.isEmpty()) {
            List<Long> ids = new ArrayList<>();
            List<MwDisposalHandleRecordItem> mwDisposalHandleRecordItems = new ArrayList<>();
            for (MwCollectRecord mwCollectRecord : list) {
                    ids.add(mwCollectRecord.getId());
                ids.add(mwCollectRecord.getId());
                mwCollectRecord.setStatus(4);
                mwCollectRecord.setDisposalUserId(sysUser.getUserId());
                mwCollectRecord.setDisposalTime(new Date());
                MwDisposalHandleRecordItem mwDisposalHandleRecordItem = new MwDisposalHandleRecordItem();
                mwDisposalHandleRecordItem.setCollectRecordId(mwCollectRecord.getId());
                mwDisposalHandleRecordItem.setDisposalRecordId(mwDisposalHandleRecord.getId());
                mwDisposalHandleRecordItem.setDisposalHandleRecordId(mwDisposalHandleRecord.getId());
                mwDisposalHandleRecordItem.setDisposalRecordId(disposalRecordItemMap.getOrDefault(mwCollectRecord.getId(), null));
                mwDisposalHandleRecordItems.add(mwDisposalHandleRecordItem);
            }
            disposalHandleRecordItemService.saveBatch(mwDisposalHandleRecordItems);
            collectRecordService.updateBatchById(list);
            //将接收记录以及子表变为已处置
            List<MwDisposalRecordItem> list1 = disposalRecordItemService.lambdaQuery().in(MwDisposalRecordItem::getCollectRecordId, ids).list();
            if (!list1.isEmpty()){
                List<Long> ids2 = new ArrayList<>();
                for (MwDisposalRecordItem mwDisposalRecordItem : list1) {
                    mwDisposalRecordItem.setDisposalFlag(1);
                    mwDisposalRecordItem.setDisposalUserId(sysUser.getUserId());
                    mwDisposalRecordItem.setDisposalTime(new Date());
                    ids2.add(mwDisposalRecordItem.getId());
                }
                disposalRecordItemService.updateBatchById(list1);
                List<MwDisposalRecord> list2 = disposalRecordService.lambdaQuery().in(MwDisposalRecord::getId, ids2).list();
                for (MwDisposalRecord mwDisposalRecord : list2) {
                    mwDisposalRecord.setDisposalFlag(1);
                    mwDisposalRecord.setDisposalTime(new Date());
                    mwDisposalRecord.setDisposalUserId(sysUser.getUserId());
                }
                disposalRecordService.updateBatchById(list2);
            }
        }
//            //将接收记录以及子表变为已处置
//            List<MwDisposalRecordItem> list1 = disposalRecordItemService.lambdaQuery().in(MwDisposalRecordItem::getCollectRecordId, ids).list();
//            if (!list1.isEmpty()){
//                List<Long> ids2 = new ArrayList<>();
//                for (MwDisposalRecordItem mwDisposalRecordItem : list1) {
//                    mwDisposalRecordItem.setDisposalFlag(1);
//                    mwDisposalRecordItem.setDisposalUserId(sysUser.getUserId());
//                    mwDisposalRecordItem.setDisposalTime(new Date());
//                    ids2.add(mwDisposalRecordItem.getId());
//                }
//                disposalRecordItemService.updateBatchById(list1);
//                List<MwDisposalRecord> list2 = disposalRecordService.lambdaQuery().in(MwDisposalRecord::getId, ids2).list();
//                for (MwDisposalRecord mwDisposalRecord : list2) {
//                    mwDisposalRecord.setDisposalFlag(1);
//                    mwDisposalRecord.setDisposalTime(new Date());
//                    mwDisposalRecord.setDisposalUserId(sysUser.getUserId());
//                }
//                disposalRecordService.updateBatchById(list2);
//            }
//        }
//        MwBox byId1 = boxService.getById(list.get(0).getStagingRoomId());
//        byId1.setLink(4);
//        boxService.updateById(byId1);
        return R.ok();
    }
@@ -317,26 +467,29 @@
    @ApiOperation(value = "已装车列表",tags = "运输人员")
    @PostMapping("/box/has/collect")
    public R<List<CollectCarTotalUpDto>> hascollect() {
    public R<List<CollectCarTotalUpDto>> hascollect(String name) {
        //获取车辆id
        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
        SysUser byId = userService.getById(sysUser.getUserId());
        //通过车辆id查询列表
        List<CollectCarTotalUpDto> list = collectRecordService.carGroup(sysUser.getCarId());
        List<CollectCarTotalUpDto> list = collectRecordService.carGroup(byId.getCarId(),name);
        return R.ok(list);
    }
    @ApiOperation(value = "已装车列表详情",tags = "运输人员")
    @PostMapping("/box/has/collect/detail")
    public R<List<CollectDto>> hascollectdetail(@RequestParam Long hospitalId) {
        List<CollectDto> collectDtos =  collectRecordService.getGroup1("",hospitalId);
        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
        SysUser byId = userService.getById(sysUser.getUserId());
        List<CollectDto> collectDtos =  collectRecordService.getGroup3(null,hospitalId,byId.getCarId());
        return R.ok(collectDtos);
    }
    @ApiOperation("库存信息")
    @PostMapping("/list")
    public R<List<CollectDto>> list(String boxNumber) {
        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
        Long userId = SecurityUtils.getUserId();
        SysUser sysUser = userService.getById(userId);
        List<CollectDto> collectDtos =  collectRecordService.getGroup(boxNumber,sysUser.getDepartmentId());
        return R.ok(collectDtos);
    }
@@ -351,13 +504,23 @@
    @PostMapping("/collect/total")
    public R<List<CollectTotalUpDto>> collecttotal1(@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)LocalDate date) {
        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
        return R.ok(collectRecordService.collectTotal(date,sysUser.getDepartmentId()));
        SysUser byId = userService.getById(sysUser.getUserId());
        if (date==null){
            date = LocalDate.now();
        }
        return R.ok(collectRecordService.collectTotal(date,byId.getDepartmentId()));
    }
    @ApiOperation("收集统计下")
    @PostMapping("/collect/down/total")
    public R<Page<MwCollectRecord>> collecttotal2(@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)LocalDate date,@RequestParam Integer pageNum, @RequestParam Integer pageSize) {
        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
        Page<MwCollectRecord> page = collectRecordService.lambdaQuery().eq(date!=null,MwCollectRecord::getCollectTime,date).eq(MwCollectRecord::getDepartmentId, sysUser.getDepartmentId()).orderByDesc(MwCollectRecord::getCollectTime).page(Page.of(pageNum, pageSize));
        SysUser byId = userService.getById(sysUser.getUserId());
        Page<MwCollectRecord> page = collectRecordService.lambdaQuery()
                .ge(MwCollectRecord::getCollectTime, date.atStartOfDay())
                .le(MwCollectRecord::getCollectTime, date.atTime(23,59,59))
            .eq(MwCollectRecord::getDepartmentId, byId.getDepartmentId())
            .orderByDesc(MwCollectRecord::getCollectTime)
            .page(Page.of(pageNum, pageSize));
        return R.ok(page);
    }
@@ -366,9 +529,9 @@
    @PostMapping("/total")
    public R<CollectTotalDto> total(String boxNumber) {
        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
        SysUser byId = userService.getById(sysUser.getUserId());
        CollectTotalDto collectTotalDto = new CollectTotalDto();
        List<CollectDto> collectDtos =  collectRecordService.getGroup(boxNumber,sysUser.getDepartmentId());
        List<CollectDto> collectDtos =  collectRecordService.getGroup(boxNumber,byId.getDepartmentId());
        for (CollectDto collectDto : collectDtos) {
            collectTotalDto.setBoxNum(collectTotalDto.getBoxNum()+1);
            collectTotalDto.setCarNum(collectTotalDto.getCarNum()+collectDto.getNum());