From 75aa42c51ae2a63d7c1e5e813c0a88fd303bdbf4 Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期五, 03 一月 2025 18:04:03 +0800
Subject: [PATCH] Merge remote-tracking branch 'gitee/master'

---
 medicalWaste-admin/src/main/java/com/sinata/web/controller/applet/AppMwCollectRecordController.java |  146 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 105 insertions(+), 41 deletions(-)

diff --git a/medicalWaste-admin/src/main/java/com/sinata/web/controller/applet/AppMwCollectRecordController.java b/medicalWaste-admin/src/main/java/com/sinata/web/controller/applet/AppMwCollectRecordController.java
index c5f21b9..097d264 100644
--- a/medicalWaste-admin/src/main/java/com/sinata/web/controller/applet/AppMwCollectRecordController.java
+++ b/medicalWaste-admin/src/main/java/com/sinata/web/controller/applet/AppMwCollectRecordController.java
@@ -58,14 +58,22 @@
     private final MwDisposalHandleRecordItemService disposalHandleRecordItemService;
     private final MwStagingRoomService roomService;
     private final ISysDictDataService dictDataService;
+    private final MwTransitCarService carService;
 
 
     @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){
@@ -99,14 +107,17 @@
         }
         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")
     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 +128,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,20 +157,23 @@
         }
         checkoutRecordItemService.saveBatch(recordItems);
         collectRecordService.updateBatchById(list);
+        MwBox byId = boxService.getById(list.get(0).getStagingRoomId());
+        byId.setLink(2);
+        boxService.updateById(byId);
         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<Long> 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);
@@ -166,7 +181,7 @@
 
     @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();
@@ -195,7 +210,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 +219,46 @@
         return R.ok(list1);
     }
 
+    @ApiOperation(value = "获取车辆",tags = "处置人员")
+    @PostMapping("/end/down/collect/car")
+    public R<CarDto> tanscollecttotal7(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();
+        }
+        MwTransitCar byId = carService.getById(one.getCarId());
+        SysUser one1 = userService.lambdaQuery().eq(SysUser::getCarId, byId.getId()).one();
+        CarDto carDto = new CarDto();
+        carDto.setLicensePlateNumber(byId.getLicensePlateNumber());
+        carDto.setUserName(one1.getUserName());
+        return R.ok(carDto);
+    }
+
+
+    @ApiOperation(value = "扫码接收列表上获取医院",tags = "处置人员")
+    @PostMapping("/end/down/collect/up")
+    public R<SysDepartment> tanscollecttotal4(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();
+        }
+        SysDepartment byId = departmentService.getById(one.getDepartmentId());
+        return R.ok(byId);
+    }
+
     @ApiOperation(value = "确认接受",tags = "处置人员")
     @PostMapping("/end/down/collect/confirm")
-    public R tanscollecttotal4(String boxNum) {
+    public R tanscollecttotal4(@RequestBody BoxListDto boxListDto) {
         SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
         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) {
@@ -246,6 +294,9 @@
             mwDisposalRecordItem.setDisposalRecordId(mwDisposalRecord.getId());
             items.add(mwDisposalRecordItem);
         }
+
+
+
         disposalRecordItemService.saveBatch(items);
         return R.ok();
     }
@@ -254,16 +305,19 @@
     @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);
     }
     @ApiOperation(value = "处置操作",tags = "处置人员")
     @PostMapping("/wait/out")
-    public R<List<CollectDto>> list2(String boxNumber) {
+    public R<List<CollectDto>> list2(@RequestBody BoxListDto boxListDto) {
         SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
         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());
@@ -278,7 +332,7 @@
             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());
@@ -287,28 +341,32 @@
                 mwDisposalHandleRecordItem.setDisposalRecordId(mwDisposalHandleRecord.getId());
                 mwDisposalHandleRecordItems.add(mwDisposalHandleRecordItem);
             }
-            disposalHandleRecordItemService.saveBatch(mwDisposalHandleRecordItems);
+//            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,11 +375,12 @@
 
     @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);
 
     }
@@ -329,7 +388,9 @@
     @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);
     }
 
@@ -351,13 +412,16 @@
     @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());
+        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().eq(date!=null,MwCollectRecord::getCollectTime,date).eq(MwCollectRecord::getDepartmentId, byId.getDepartmentId()).orderByDesc(MwCollectRecord::getCollectTime).page(Page.of(pageNum, pageSize));
         return R.ok(page);
     }
 
@@ -366,9 +430,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());

--
Gitblit v1.7.1