| | |
| | | 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.DateUtils; |
| | | import com.sinata.common.utils.SecurityUtils; |
| | | import com.sinata.common.utils.StringUtils; |
| | | import com.sinata.system.domain.*; |
| | | import com.sinata.system.domain.dto.*; |
| | | import com.sinata.system.domain.query.MwCollectRecordQuery; |
| | |
| | | import javax.validation.Valid; |
| | | import java.io.IOException; |
| | | import java.time.LocalDate; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private final MwStagingRoomService roomService; |
| | | private final ISysDictDataService dictDataService; |
| | | private final MwTransitCarService carService; |
| | | private final MwTransitCarCollectPointService mwTransitCarCollectPointService; |
| | | private final MwTransitRouteService transitRouteService; |
| | | |
| | | |
| | | @ApiOperation(value = "新增医废记录") |
| | |
| | | mwCollectRecord.setStagingRoomId(one1.getId()); |
| | | mwCollectRecord.setDepartmentId(sysUser.getDepartmentId()); |
| | | mwCollectRecord.setBoxTime(new Date()); |
| | | mwCollectRecord.setCollectUserId(sysUser.getUserId()); |
| | | |
| | | // 创建一个随机数生成器实例 |
| | | Random random = new Random(); |
| | |
| | | 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(); |
| | | |
| | | } |
| | |
| | | mwDisposalRecordItem.setDisposalRecordId(mwDisposalRecord.getId()); |
| | | 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(); |
| | | } |
| | | |
| | |
| | | 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<>(); |
| | |
| | | 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); |
| | | disposalHandleRecordItemService.saveBatch(mwDisposalHandleRecordItems); |
| | | collectRecordService.updateBatchById(list); |
| | | } |
| | | // //将接收记录以及子表变为已处置 |