| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.dto.HistoryDto; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author Administrator |
| | |
| | | private WarehouseCellService warehouseCellService; |
| | | |
| | | private InsSampleMapper insSampleMapper; |
| | | |
| | | private InsOrderStateMapper insOrderStateMapper; |
| | | |
| | | private InsProductMapper insProductMapper; |
| | | |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int upShelf(WarehouseShelf warehouseShelf) { |
| | | warehouseCellMapper.update(null, Wrappers.<WarehouseCell>lambdaUpdate() |
| | | .eq(WarehouseCell::getShelfId, warehouseShelf.getWarehouseId()) |
| | | .gt(WarehouseCell::getRow, warehouseShelf.getRow()) |
| | | .gt(WarehouseCell::getCol, warehouseShelf.getCol()) |
| | | .set(WarehouseCell::getState, 0)); |
| | | WarehouseShelf shelf = warehouseShelfMapper.selectById(warehouseShelf.getId()); |
| | | if (shelf.getCol()>=warehouseShelf.getCol() && shelf.getRow() >= warehouseShelf.getRow()) { |
| | | //如果维护的数据小于原有的行列数可以进行修改 |
| | | warehouseCellMapper.update(null, Wrappers.<WarehouseCell>lambdaUpdate() |
| | | .eq(WarehouseCell::getShelfId, warehouseShelf.getId()) |
| | | .and(true, wrapper -> wrapper.gt(WarehouseCell::getRow, warehouseShelf.getRow()) |
| | | .or() |
| | | .gt(WarehouseCell::getCol, warehouseShelf.getCol())) |
| | | .set(WarehouseCell::getState, 0)); |
| | | }else { |
| | | //如果维护的数据大于原有的行列数需要进行额外添加 |
| | | List<WarehouseCell> cells = new ArrayList<>(); |
| | | for (int i = 1; i < warehouseShelf.getRow() + 1; i++) { |
| | | for (int a = 1; a < warehouseShelf.getCol() + 1; a++) { |
| | | WarehouseCell cell = new WarehouseCell(); |
| | | cell.setRow(i); |
| | | cell.setCol(a); |
| | | cell.setState(1); |
| | | cell.setShelfId(warehouseShelf.getId()); |
| | | WarehouseCell warehouseCell = warehouseCellMapper.selectOne(Wrappers.<WarehouseCell>lambdaQuery() |
| | | .eq(WarehouseCell::getShelfId, warehouseShelf.getId()) |
| | | .eq(WarehouseCell::getRow, i) |
| | | .eq(WarehouseCell::getCol, a)); |
| | | if (ObjectUtils.isNotEmpty(warehouseCell)){ |
| | | cell.setId(warehouseCell.getId()); |
| | | } |
| | | cells.add(cell); |
| | | } |
| | | } |
| | | warehouseCellService.saveOrUpdateBatch(cells); |
| | | } |
| | | warehouseShelfMapper.updateById(warehouseShelf); |
| | | return 0; |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public int outWarehouse(String sampleCode) { |
| | | public int outWarehouse(String sampleCode, boolean a) { |
| | | List<InsSample> samples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getSampleCode, sampleCode).select(InsSample::getId,InsSample::getCellId)); |
| | | if(samples.size()!=1){ |
| | | throw new ErrorException("样品编号输入有误"); |
| | |
| | | if(samples.get(0).getCellId()==null){ |
| | | throw new ErrorException("样品 " + sampleCode + " 未入库"); |
| | | } |
| | | if (!a) { |
| | | //判断该订单是否站点任务有(继续试验或者是结束试验) |
| | | List<InsOrderState> orderStates = insOrderStateMapper.selectList(Wrappers.<InsOrderState>lambdaQuery() |
| | | .eq(InsOrderState::getInsOrderId, samples.get(0).getInsOrderId()) |
| | | .eq(InsOrderState::getInsState, 5)); |
| | | List<Integer> orderIds = new ArrayList<Integer>(); |
| | | orderIds.add(6); |
| | | if (CollectionUtils.isEmpty(orderStates)) { |
| | | List<Integer> collect = insOrderStateMapper.selectList(Wrappers.<InsOrderState>lambdaQuery() |
| | | .eq(InsOrderState::getInsOrderId, samples.get(0).getInsOrderId())).stream().map(InsOrderState::getInsState).distinct().collect(Collectors.toList()); |
| | | if (collect.size()!=0 && !collect.containsAll(orderIds)) { |
| | | throw new ErrorException("该样品的检验任务还没有结束试验或继续试验,暂时无法出库!"); |
| | | } |
| | | } |
| | | } |
| | | WarehouseHistory history = new WarehouseHistory(); |
| | | history.setState(2); |
| | | history.setInsSampleId(samples.get(0).getId()); |