From cf49f4f936a11b27de3f9ec3cbb50603f3b1cd5b Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期六, 28 十二月 2024 16:16:18 +0800
Subject: [PATCH] merge

---
 medicalWaste-admin/src/main/java/com/sinata/web/controller/applet/AppMwCollectRecordController.java |  188 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 178 insertions(+), 10 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 130754a..30ad0ed 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
@@ -1,20 +1,19 @@
 package com.sinata.web.controller.applet;
+import java.util.Date;
+import java.math.BigDecimal;
+import java.util.*;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 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.MwCollectRecord;
-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.MwCollectRecordDTO;
+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.ISysUserService;
-import com.sinata.system.service.MwCollectRecordService;
+import com.sinata.system.service.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -27,7 +26,6 @@
 import javax.validation.Valid;
 import java.io.IOException;
 import java.time.LocalDate;
-import java.util.List;
 
 /**
  * <p>
@@ -46,15 +44,185 @@
     private final MwCollectRecordService collectRecordService;
     @Autowired
     private ISysUserService userService;
-
+    private final MwBoxService boxService;
+    private final MwCheckoutRecordService checkoutRecordService;
+    private final MwCheckoutRecordItemService checkoutRecordItemService;
+    private final SysDepartmentService departmentService;
 
 
     @ApiOperation("新增医废记录")
     @PostMapping("/add")
-    public R<?> edit(@Valid @RequestBody MwCollectRecord mwCollectRecord) {
+    public R<?> add(@Valid @RequestBody MwCollectRecord mwCollectRecord) {
+        MwBox one = boxService.lambdaQuery().eq(MwBox::getBoxNumber, mwCollectRecord.getBoxNumber()).one();
+        mwCollectRecord.setBoxId(one.getId());
         collectRecordService.save(mwCollectRecord);
         return R.ok();
     }
+
+    @ApiOperation(value = "扫描箱号获取医废",tags = "运输人员")
+    @PostMapping("/box/list")
+    public R<List<CollectDto>> boxlist(@RequestParam String boxNumber) {
+        List<MwCollectRecord> list = collectRecordService.lambdaQuery().eq(MwCollectRecord::getStatus,1).eq(MwCollectRecord::getBoxNumber, boxNumber).list();
+        if (list.isEmpty()){
+            return R.ok();
+        }
+        Long departmentId = list.get(0).getDepartmentId();
+        List<CollectDto> collectDtos =  collectRecordService.getGroup1(boxNumber,departmentId);
+        return R.ok(collectDtos);
+    }
+
+    @ApiOperation(value = "装车",tags = "运输人员")
+    @PostMapping("/box/collect")
+    public R<List<CollectDto>> collect(@RequestBody SignCollectDto signCollectDto) {
+        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
+
+        //将收集记录的状态改变
+        List<MwCollectRecord> list = collectRecordService.lambdaQuery().eq(MwCollectRecord::getStatus,1).in(MwCollectRecord::getBoxNumber, signCollectDto.getBoxNumbers()).list();
+       if (list.isEmpty()){
+           return R.ok();
+       }
+        Set<String> boxes = new HashSet<>();
+        BigDecimal sum = new BigDecimal(0);
+        for (MwCollectRecord mwCollectRecord : list) {
+            mwCollectRecord.setStatus(2);
+            mwCollectRecord.setCheckoutUserId(sysUser.getUserId());
+            boxes.add(mwCollectRecord.getBoxNumber());
+            sum= sum.add(mwCollectRecord.getWeight());
+        }
+        //插入入库记录以及中间表数据
+        MwCheckoutRecord mwCheckoutRecord = new MwCheckoutRecord();
+        mwCheckoutRecord.setCheckoutTime(new Date());
+        mwCheckoutRecord.setDepartmentId(list.get(0).getDepartmentId());
+        mwCheckoutRecord.setHospitalName(list.get(0).getHospitalName());
+        mwCheckoutRecord.setStagingRoomId(list.get(0).getStagingRoomId());
+        mwCheckoutRecord.setHospitalSignature(signCollectDto.getSignUrl());
+        mwCheckoutRecord.setDriverId(sysUser.getUserId());
+        mwCheckoutRecord.setCarId(sysUser.getCarId());
+        mwCheckoutRecord.setBoxNum(boxes.size());
+        mwCheckoutRecord.setBagNum(list.size());
+        mwCheckoutRecord.setTotalWeight(sum);
+        checkoutRecordService.save(mwCheckoutRecord);
+        //插入中间表数据
+        List<MwCheckoutRecordItem> recordItems = new ArrayList<>();
+        for (MwCollectRecord mwCollectRecord : list) {
+            MwCheckoutRecordItem mwCheckoutRecordItem = new MwCheckoutRecordItem();
+            mwCheckoutRecordItem.setCollectRecordId(mwCollectRecord.getId());
+            mwCheckoutRecordItem.setCheckoutRecordId(mwCheckoutRecord.getId());
+            recordItems.add(mwCheckoutRecordItem);
+        }
+        checkoutRecordItemService.saveBatch(recordItems);
+        collectRecordService.updateBatchById(list);
+        return R.ok();
+
+    }
+
+    @ApiOperation(value = "运输统计上",tags = "运输人员")
+    @PostMapping("/trans/collect/total")
+    public R<List<CollectTotalUpDto>> tanscollecttotal1(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) {
+        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);
+    }
+
+    @ApiOperation(value = "运输统计下",tags = "运输人员")
+    @PostMapping("/trans/down/collect/total")
+    public R<List<HospitalCollectTotalUpDto>> tanscollecttotal2(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<HospitalCollectTotalUpDto> list1 = new ArrayList<>();
+        for (MwCollectRecord mwCollectRecord : list) {
+            List<CollectTotalUpDto> collectTotalUpDtos = collectRecordService.collectTotal1(date, sysUser.getUserId(), mwCollectRecord.getDepartmentId());
+            HospitalCollectTotalUpDto hospitalCollectTotalUpDto = new HospitalCollectTotalUpDto();
+            hospitalCollectTotalUpDto.setHospitalName(mwCollectRecord.getHospitalName());
+            hospitalCollectTotalUpDto.setCollectTotalUpDtos(collectTotalUpDtos);
+            list1.add(hospitalCollectTotalUpDto);
+        }
+        return R.ok(list1);
+    }
+
+    @ApiOperation(value = "扫码接收列表",tags = "处置人员")
+    @PostMapping("/end/down/collect/total")
+    public R<List<HospitalCollectTotalUpDto>> tanscollecttotal3(String boxNum) {
+        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
+        MwCollectRecord one = collectRecordService.lambdaQuery().eq(MwCollectRecord::getBoxNumber, boxNum).eq(MwCollectRecord::getStatus, 2).last("limit 1").one();
+
+        //先获取医院ids
+        List<MwCollectRecord> list = collectRecordService.lambdaQuery().eq(MwCollectRecord::getStatus,2).eq(MwCollectRecord::getCheckoutUserId, one.getCheckoutUserId()).groupBy(MwCollectRecord::getDepartmentId).list();
+        //循环医院,然后放入
+        List<HospitalCollectTotalUpDto> list1 = new ArrayList<>();
+        for (MwCollectRecord mwCollectRecord : list) {
+            List<CollectTotalUpDto> collectTotalUpDtos = collectRecordService.collectTotal1(null, sysUser.getUserId(), mwCollectRecord.getDepartmentId());
+            HospitalCollectTotalUpDto hospitalCollectTotalUpDto = new HospitalCollectTotalUpDto();
+            hospitalCollectTotalUpDto.setHospitalName(mwCollectRecord.getHospitalName());
+            hospitalCollectTotalUpDto.setCollectTotalUpDtos(collectTotalUpDtos);
+            list1.add(hospitalCollectTotalUpDto);
+        }
+        return R.ok(list1);
+    }
+
+    @ApiOperation(value = "确认接受",tags = "处置人员")
+    @PostMapping("/end/down/collect/confirm")
+    public R<List<HospitalCollectTotalUpDto>> tanscollecttotal4(String boxNum) {
+        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();
+        Set<String> boxes = new HashSet<>();
+        BigDecimal receiveQuantity = BigDecimal.ZERO;
+        for (MwCollectRecord mwCollectRecord : list) {
+            mwCollectRecord.setStatus(3);
+            boxes.add(mwCollectRecord.getBoxNumber());
+            receiveQuantity = receiveQuantity.add(mwCollectRecord.getWeight());
+        }
+        //插入处置记录以及子表
+        MwDisposalRecord mwDisposalRecord = new MwDisposalRecord();
+        mwDisposalRecord.setDepartmentId(sysUser.getDepartmentId());
+        mwDisposalRecord.setDisposalUnitName(byId.getDepartmentName());
+        mwDisposalRecord.setReceiveQuantity(boxes.size());
+        mwDisposalRecord.setReceiveTime(new Date());
+        mwDisposalRecord.setReceiveWeight(receiveQuantity);
+        mwDisposalRecord.setReceiverId(sysUser.getUserId());
+        mwDisposalRecord.setUnloadQuantity(boxes.size());
+        mwDisposalRecord.setUnloadWeight(receiveQuantity);
+        mwDisposalRecord.setTotalHandledQuantity(0);
+        mwDisposalRecord.setDisposalFlag(0);
+        mwDisposalRecord.setTotalHandledWeight(new BigDecimal("0"));
+
+
+        return null;
+
+
+    }
+
+
+
+    @ApiOperation(value = "已装车列表",tags = "运输人员")
+    @PostMapping("/box/has/collect")
+    public R<List<CollectCarTotalUpDto>> hascollect() {
+        //获取车辆id
+        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
+        //通过车辆id查询列表
+        List<CollectCarTotalUpDto> list = collectRecordService.carGroup(sysUser.getCarId());
+        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);
+        return R.ok(collectDtos);
+    }
+
     @ApiOperation("库存信息")
     @PostMapping("/list")
     public R<List<CollectDto>> list(String boxNumber) {

--
Gitblit v1.7.1