luodangjia
2025-01-01 aded6d51dd8cc3b7d2b5a9a0be54378c5b2ee924
medicalWaste-admin/src/main/java/com/sinata/web/controller/applet/AppMwCollectRecordController.java
@@ -52,13 +52,29 @@
    private final MwDisposalRecordItemService disposalRecordItemService;
    private final MwDisposalHandleRecordService disposalHandleRecordService;
    private final MwDisposalHandleRecordItemService disposalHandleRecordItemService;
    private final MwStagingRoomService roomService;
    @ApiOperation("新增医废记录")
    @PostMapping("/add")
    public R<?> add(@Valid @RequestBody MwCollectRecord mwCollectRecord) {
        SysUser  sysUser = SecurityUtils.getLoginUser().getUser();
        MwBox one = boxService.lambdaQuery().eq(MwBox::getBoxNumber, mwCollectRecord.getBoxNumber()).one();
        mwCollectRecord.setBoxId(one.getId());
        MwStagingRoom one1 = roomService.lambdaQuery().eq(MwStagingRoom::getDepartmentId, sysUser.getDepartmentId()).one();
        if (one1==null){
            return R.fail("当前单位没有暂存间");
        }
        mwCollectRecord.setStagingRoomId(one1.getId());
        mwCollectRecord.setDepartmentId(sysUser.getDepartmentId());
        // 创建一个随机数生成器实例
        Random random = new Random();
        // 生成一个6位数范围内的随机整数(100000 到 999999)
        int randomNumber = 10000000 + random.nextInt(90000000);
        mwCollectRecord.setMedicalWasteNumber(String.valueOf(randomNumber));
        collectRecordService.save(mwCollectRecord);
        return R.ok();
    }
@@ -160,7 +176,9 @@
    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();
        if (one==null){
            return R.ok();
        }
        //先获取医院ids
        List<MwCollectRecord> list = collectRecordService.lambdaQuery().eq(MwCollectRecord::getStatus,2).eq(MwCollectRecord::getCheckoutUserId, one.getCheckoutUserId()).groupBy(MwCollectRecord::getDepartmentId).list();
        //循环医院,然后放入