package cn.besteam.modules.api.controller;
|
|
import cn.besteam.common.api.vo.Result;
|
import cn.besteam.common.aspect.annotation.AutoLog;
|
import cn.besteam.common.aspect.annotation.LogApi;
|
import cn.besteam.common.constant.CommonConstant;
|
import cn.besteam.common.constant.ErrorCode;
|
import cn.besteam.common.constant.MedicalWasteEnum;
|
import cn.besteam.common.dto.CodeDTO;
|
import cn.besteam.common.dto.IdDTO;
|
import cn.besteam.common.exception.BusinessException;
|
import cn.besteam.modules.medical.dto.*;
|
import cn.besteam.modules.medical.entity.MwBox;
|
import cn.besteam.modules.medical.entity.MwBoxItem;
|
import cn.besteam.modules.medical.entity.MwCollectRecord;
|
import cn.besteam.modules.medical.entity.MwTransitConfig;
|
import cn.besteam.modules.medical.service.*;
|
import cn.besteam.modules.medical.vo.ApiMedicalBoxingDetailsVO;
|
import cn.besteam.modules.medical.vo.MwCollectRecordVO;
|
import cn.besteam.modules.shiro.authc.util.EnvUtils;
|
import cn.besteam.modules.system.entity.SysDict;
|
import cn.besteam.modules.system.entity.SysDictItem;
|
import cn.besteam.modules.system.entity.SysUser;
|
import cn.besteam.modules.system.service.ISysDictItemService;
|
import cn.besteam.modules.system.service.ISysDictService;
|
import cn.besteam.modules.system.service.ISysUserService;
|
import cn.besteam.modules.system.vo.SysDictItemVO;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletRequest;
|
import java.util.ArrayList;
|
import java.util.Arrays;
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
@RestController
|
@RequestMapping("/api/medical")
|
@Api(value = "医废相关")
|
public class ApiMedicalWasteController {
|
|
@Autowired
|
private ISysDictService sysDictService;
|
|
@Autowired
|
private ISysDictItemService sysDictItemService;
|
|
@Autowired
|
private IMwCollectRecordService mwCollectRecordService;
|
|
@Autowired
|
private IMwBoxService mwBoxService;
|
|
@Autowired
|
private IMwCheckoutRecordService mwCheckoutRecordService;
|
|
@Autowired
|
private IMwTransitConfigService mwTransitConfigService;
|
|
@Autowired
|
private IMwBoxItemService mwBoxItemService;
|
//############################################################### 收集 ##################################################################
|
|
@GetMapping("/getWasteTypeList")
|
@ApiOperation(value = "获取医废类型列表(type=1:医废类型,type=2:备注选项)")
|
@LogApi(value = "获取医废类型列表")
|
public Result<List<SysDictItemVO>> getMedicalWasteTypeList(Integer type) {
|
SysDict sysDict = null;
|
if(type==null){
|
sysDict = sysDictService.getOne(new QueryWrapper<SysDict>().lambda().eq(SysDict::getDictCode, "MEDICAL_WASTE_TYPE"));
|
}else {
|
sysDict = sysDictService.getOne(new QueryWrapper<SysDict>().lambda().eq(SysDict::getDictCode, "NOTE_OPTIONS"));
|
}
|
if (sysDict == null) {
|
return Result.ok(new ArrayList<SysDictItemVO>());
|
}
|
List<SysDictItem> sysDictItemList = sysDictItemService.list(new QueryWrapper<SysDictItem>().lambda()//
|
.eq(SysDictItem::getDictId, sysDict.getId())//
|
.eq(SysDictItem::getStatus, 1)//
|
.orderByAsc(SysDictItem::getSortOrder));
|
List<SysDictItemVO> voList = new ArrayList<>();
|
for (SysDictItem sysDictItem : sysDictItemList) {
|
SysDictItemVO vo = new SysDictItemVO();
|
BeanUtils.copyProperties(sysDictItem, vo);
|
voList.add(vo);
|
}
|
return Result.ok(voList);
|
}
|
|
@GetMapping("/getCollectList")
|
@ApiOperation(value = "获取已收集列表")
|
@LogApi(value = "获取已收集列表")
|
public Result<List<MwCollectRecordVO>> getCollectList(HttpServletRequest request) {
|
String accessToken = request.getHeader("X-Access-Token");
|
SysUser sysUser=sysUserService.getByAppToken(accessToken);
|
// 获取自己收集的
|
List<MwCollectRecord> list = mwCollectRecordService.list(new QueryWrapper<MwCollectRecord>().lambda()//
|
.eq(MwCollectRecord::getCreateBy, EnvUtils.getUser().getId())//
|
.eq(MwCollectRecord::getStatus, MedicalWasteEnum.MedicalWasteStatusEnum.COLLECT.getStatus())//
|
.eq(MwCollectRecord::getDelFlag, CommonConstant.DEL_FLAG_0)//
|
.eq(MwCollectRecord::getAuditStatus, MedicalWasteEnum.MedicalWasteAuditStatusEnum.PASS.getStatus())//
|
.eq(sysUser.getHospitalId()!=null,MwCollectRecord::getHospitalId,sysUser.getHospitalId())
|
.orderByDesc(MwCollectRecord::getCreateTime)//
|
.orderByAsc(MwCollectRecord::getDepartmentId)//
|
.orderByAsc(MwCollectRecord::getDepartmentUserId)//
|
.orderByAsc(MwCollectRecord::getWasteType)//
|
.orderByAsc(MwCollectRecord::getWeight));
|
List<MwCollectRecordVO> voList = new ArrayList<>();
|
for (MwCollectRecord mwCollectRecord : list) {
|
MwCollectRecordVO vo = new MwCollectRecordVO();
|
BeanUtils.copyProperties(mwCollectRecord, vo);
|
voList.add(vo);
|
}
|
return Result.ok(voList);
|
}
|
|
@PostMapping("/addCollect")
|
@ApiOperation(value = "新增收集")
|
@LogApi(value = "新增收集")
|
@AutoLog(value = "新增收集", logType = 4)
|
public Result<Integer> addCollect(@Validated @RequestBody MwCollectRecordSaveDTO dto) {
|
|
return Result.ok(mwCollectRecordService.addCollect(dto));
|
}
|
|
@PostMapping("/addCollectBatch")
|
@ApiOperation(value = "批量新增收集")
|
@LogApi(value = "批量新增收集")
|
@AutoLog(value = "批量新增收集", logType = 4)
|
public Result<?> addCollectBatch(@Validated @RequestBody MwCollectRecordSaveBatchDTO dto) {
|
|
return Result.ok(mwCollectRecordService.addCollectBatch(dto.getList()));
|
}
|
|
@PostMapping("/deleteCollect")
|
@ApiOperation(value = "删除收集")
|
@LogApi(value = "删除收集")
|
@AutoLog(value = "删除收集", logType = 4)
|
public Result<?> deleteCollect(@Validated @RequestBody IdDTO dto) {
|
|
return Result.ok(mwCollectRecordService.delete(dto.getId()));
|
}
|
|
@PostMapping("/deleteCollectByCode")
|
@ApiOperation(value = "通过code删除收集")
|
@LogApi(value = "通过code删除收集")
|
public Result<?> deleteCollectByCode(@Validated @RequestBody CodeDTO dto) {
|
|
return Result.ok(mwCollectRecordService.deleteByCode(dto.getCode()));
|
}
|
//############################################################### 入库 ##################################################################
|
|
@GetMapping("/getStoreList")
|
@ApiOperation(value = "获取未出库清单")
|
@LogApi(value = "获取未出库清单")
|
public Result<List<MwCollectRecordVO>> getStoreList(Integer warehouseId, Integer transitConfigId,HttpServletRequest request) {
|
String accessToken = request.getHeader("X-Access-Token");
|
SysUser sysUser=sysUserService.getByAppToken(accessToken);
|
// 获取自己收集的
|
QueryWrapper<MwCollectRecord> queryWrapper = new QueryWrapper<>();
|
queryWrapper.lambda()//
|
// .eq(MwCollectRecord::getCreateBy, EnvUtils.getUser().getId())//
|
.eq(MwCollectRecord::getStatus, MedicalWasteEnum.MedicalWasteStatusEnum.STORE.getStatus())//
|
.eq(MwCollectRecord::getDelFlag, CommonConstant.DEL_FLAG_0)//
|
.eq(MwCollectRecord::getAuditStatus, MedicalWasteEnum.MedicalWasteAuditStatusEnum.PASS.getStatus())//
|
.eq(sysUser.getHospitalId()!=null,MwCollectRecord::getHospitalId,sysUser.getHospitalId())
|
.orderByDesc(MwCollectRecord::getCreateTime);
|
if (warehouseId != null) {
|
queryWrapper.lambda().eq(MwCollectRecord::getWarehouseId, warehouseId);
|
}
|
if (transitConfigId != null) {
|
MwTransitConfig mwTransitConfig = mwTransitConfigService.getById(transitConfigId);
|
if (mwTransitConfig != null && StringUtils.isNotEmpty(mwTransitConfig.getWasteType())) {
|
queryWrapper.lambda().in(MwCollectRecord::getWasteType, Arrays.asList(mwTransitConfig.getWasteType().split(",")));
|
}
|
}
|
List<MwCollectRecord> list = mwCollectRecordService.list(queryWrapper);
|
List<MwCollectRecordVO> voList = new ArrayList<>();
|
for (MwCollectRecord mwCollectRecord : list) {
|
MwCollectRecordVO vo = new MwCollectRecordVO();
|
BeanUtils.copyProperties(mwCollectRecord, vo);
|
voList.add(vo);
|
}
|
return Result.ok(voList);
|
}
|
|
@PostMapping("/scanStore")
|
@ApiOperation(value = "扫码入库")
|
@LogApi(value = "扫码入库")
|
public Result<?> scanStore(@Validated @RequestBody MwCollectRecordStoreDTO dto) {
|
|
return Result.ok(mwCollectRecordService.storeCollect(dto));
|
}
|
|
@PostMapping("/storeBatch")
|
@ApiOperation(value = "批量入库")
|
@LogApi(value = "批量入库")
|
public Result<?> batchStore(@Validated @RequestBody MwCollectRecordStoreBatchDTO dto) {
|
|
return Result.ok(mwCollectRecordService.storeCollectBatch(dto.getList()));
|
}
|
|
@GetMapping("/getBoxingList")
|
@ApiOperation(value = "获取未装箱清单列表")
|
@LogApi(value = "获取未装箱清单列表")
|
public Result<?> getBoxingList(@RequestParam @ApiParam("暂存间ID") Integer warehouseId) {
|
|
return Result.ok(mwCollectRecordService.getUnBoxingList(warehouseId, EnvUtils.getUser().getId()));
|
}
|
|
@GetMapping("/getBoxingListNew")
|
@ApiOperation(value = "获取未装箱清单列表(新)")
|
@LogApi(value = "获取未装箱清单列表(新)")
|
public Result<?> getBoxingListNew(@RequestParam @ApiParam("暂存间ID") Integer warehouseId,HttpServletRequest request) {
|
String accessToken = request.getHeader("X-Access-Token");
|
SysUser sysUser=sysUserService.getByAppToken(accessToken);
|
return Result.ok(mwCollectRecordService.getUnBoxingListNew(warehouseId, EnvUtils.getUser().getId(),sysUser.getHospitalId()));
|
}
|
@GetMapping("/getUnBoxingListTotal")
|
@ApiOperation(value = "获取已装箱列表(箱装)")
|
@LogApi(value = "获取已装箱列表(箱装)")
|
public Result<?> getUnBoxingListTotal(@RequestParam @ApiParam("暂存间ID") Integer warehouseId,HttpServletRequest request) {
|
String accessToken = request.getHeader("X-Access-Token");
|
SysUser sysUser=sysUserService.getByAppToken(accessToken);
|
return Result.ok(mwCollectRecordService.getUnBoxingListTotal(warehouseId, EnvUtils.getUser().getId(),sysUser.getHospitalId()));
|
}
|
|
@PostMapping("/autoBoxing")
|
@ApiOperation(value = "自动装箱")
|
@LogApi(value = "自动装箱")
|
public Result<?> autoBoxing(@Validated @RequestBody ApiMedicalBoxingDTO dto) {
|
|
return Result.ok(mwBoxService.autoBoxing(dto));
|
}
|
|
@PostMapping("/boxingAndPrinting")
|
@ApiOperation(value = "手动装箱并打印")
|
@LogApi(value = "手动装箱并打印")
|
public Result<ApiMedicalBoxingDetailsVO> boxingAndPrinting(@Validated @RequestBody ApiMedicalBoxingDTO dto) {
|
|
return Result.ok(mwBoxService.boxingAndPrinting(dto));
|
}
|
|
@PostMapping("/boxingAndPrintingNew")
|
@ApiOperation(value = "手动装箱并打印(新)")
|
@LogApi(value = "手动装箱并打印(新)")
|
public Result<ApiMedicalBoxingDetailsVO> boxingAndPrintingNew(@Validated @RequestBody ApiMedicalBoxingDTO dto) {
|
|
return Result.ok(mwBoxService.boxingAndPrintingNew(dto));
|
}
|
|
@Autowired
|
private ISysUserService sysUserService;
|
@GetMapping("/getBoxItemList")
|
@ApiOperation(value = "获取转运箱中的医废列表")
|
@LogApi(value = "获取转运箱中的医废列表")
|
public Result<List<MwCollectRecordVO>> getBoxItemList(@RequestParam(name = "boxCode") String boxCode,HttpServletRequest request) {
|
|
MwBox mwBox = mwBoxService.getOne(new QueryWrapper<MwBox>().lambda().eq(MwBox::getCode, boxCode));
|
if (mwBox == null) {
|
throw new BusinessException(ErrorCode.ERR_500, "转运箱不存在");
|
}
|
List<MwBoxItem> mwBoxItemList = mwBoxItemService.list(new QueryWrapper<MwBoxItem>().lambda().eq(MwBoxItem::getBoxId, mwBox.getId()));
|
if (CollectionUtils.isEmpty(mwBoxItemList)) {
|
return Result.ok(new ArrayList<>());
|
}
|
// 获取自己收集的
|
QueryWrapper<MwCollectRecord> queryWrapper = new QueryWrapper<>();
|
String accessToken = request.getHeader("X-Access-Token");
|
SysUser sysUser=sysUserService.getByAppToken(accessToken);
|
queryWrapper.lambda()//
|
//.eq(MwCollectRecord::getCreateBy, EnvUtils.getUser().getId())//
|
.in(MwCollectRecord::getId, mwBoxItemList.stream().map(MwBoxItem::getCollectRecordId).collect(Collectors.toList()))
|
// .eq(MwCollectRecord::getStatus, MedicalWasteEnum.MedicalWasteStatusEnum.STORE.getStatus())//
|
.eq(MwCollectRecord::getDelFlag, CommonConstant.DEL_FLAG_0)//
|
.eq(sysUser.getHospitalId()!=null,MwCollectRecord::getHospitalId,sysUser.getHospitalId())
|
// .eq(MwCollectRecord::getAuditStatus, MedicalWasteEnum.MedicalWasteAuditStatusEnum.PASS.getStatus())//
|
.orderByDesc(MwCollectRecord::getCreateTime);
|
List<MwCollectRecord> list = mwCollectRecordService.list(queryWrapper);
|
List<MwCollectRecordVO> voList = new ArrayList<>();
|
for (MwCollectRecord mwCollectRecord : list) {
|
MwCollectRecordVO vo = new MwCollectRecordVO();
|
BeanUtils.copyProperties(mwCollectRecord, vo);
|
voList.add(vo);
|
}
|
return Result.ok(voList);
|
}
|
//############################################################### 出库 ##################################################################
|
|
@PostMapping("/checkout")
|
@ApiOperation(value = "出库出库")
|
@LogApi(value = "出库出库")
|
public Result<?> checkout(@Validated @RequestBody ApiMedicalCheckoutDTO dto) {
|
|
return Result.ok(mwCheckoutRecordService.checkout(dto));
|
}
|
|
@PostMapping("/checkoutBatch")
|
@ApiOperation(value = "批量出库")
|
@LogApi(value = "批量出库")
|
public Result<?> checkoutBatch(@Validated @RequestBody ApiMedicalCheckoutBatchDTO dto) {
|
|
return Result.ok(mwCheckoutRecordService.checkoutBatch(dto));
|
}
|
//############################################################### 统计 ##################################################################
|
|
@GetMapping("/collectStatistics")
|
@ApiOperation("统计-收集统计")
|
@LogApi(value = "统计-收集统计")
|
public Result<?> collectStatistics(ApiStatisticsDTO dto, HttpServletRequest request) {
|
|
return Result.ok(mwCollectRecordService.collectStatistics(dto,request));
|
}
|
|
@GetMapping("/storeAndCheckoutStatistics")
|
@ApiOperation("统计-入库和出库统计")
|
@LogApi(value = "统计-入库和出库统计")
|
public Result<?> storeAndCheckoutStatistics(ApiStatisticsDTO dto,HttpServletRequest request) {
|
|
return Result.ok(mwCollectRecordService.storeAndCheckoutStatistics(dto,request));
|
}
|
|
}
|