| | |
| | | package com.zy.asrs.wms.asrs.service.impl;
|
| | |
|
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
| | | import com.baomidou.mybatisplus.core.metadata.IPage;
|
| | | import com.zy.asrs.framework.exception.CoolException;
|
| | | import com.zy.asrs.wms.asrs.entity.*;
|
| | | import com.zy.asrs.wms.asrs.entity.dto.PickSheetDetlDto;
|
| | | import com.zy.asrs.wms.asrs.entity.enums.*;
|
| | | import com.zy.asrs.wms.asrs.entity.enums.OrderType;
|
| | | import com.zy.asrs.wms.asrs.entity.param.BatchMergeOrdersParam;
|
| | | import com.zy.asrs.wms.asrs.entity.param.GeneratePakInParam;
|
| | | import com.zy.asrs.wms.asrs.entity.param.PageRequest;
|
| | | import com.zy.asrs.wms.asrs.entity.param.PakinOnShelvesParams;
|
| | | import com.zy.asrs.wms.asrs.mapper.CacheSiteMapper;
|
| | | import com.zy.asrs.wms.asrs.service.*;
|
| | | import com.zy.asrs.wms.system.entity.Host;
|
| | | import com.zy.asrs.wms.system.service.HostService;
|
| | |
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Objects;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.*;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | @Service
|
| | |
| | | @Autowired
|
| | | private OrderService orderService;
|
| | | @Autowired
|
| | | private OrderDetlService orderDetlService;
|
| | | @Autowired
|
| | | private OrderLogService orderLogService;
|
| | | @Autowired
|
| | | private LocService locService;
|
| | |
| | | private LocAreaService locAreaService;
|
| | | @Autowired
|
| | | private LocAreaTypeService locAreaTypeService;
|
| | |
|
| | | @Autowired
|
| | | private PickSheetService pickSheetService;
|
| | | @Autowired
|
| | | private PickSheetDetlService pickSheetDetlService;
|
| | | @Autowired
|
| | | private MatService matService;
|
| | | @Autowired
|
| | | private WaveService waveService;
|
| | | @Autowired
|
| | | private WaveDetlService waveDetlService;
|
| | | @Autowired
|
| | | private CacheSiteMapper cacheSiteMapper;
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | |
| | | LocDetl locDetl = new LocDetl();
|
| | | locDetl.setAnfme(pakin.getAnfme());
|
| | | locDetl.setBatch(pakin.getBatch());
|
| | | locDetl.setMatnr(pakin.getMatnr());
|
| | | locDetl.setMatId(pakin.getMatnrId$());
|
| | | locDetl.setCreateTime(new Date());
|
| | | locDetl.setOrderNo(pakin.getOrderNo());
|
| | | locDetl.setLocNo(loc.getLocNo());
|
| | | locDetl.setLocId(loc.getLocStsId());
|
| | | locDetl.setLocId(loc.getId());
|
| | | locDetl.setMatnr(pakin.getMatnr());
|
| | | Mat one = matService.getOne(new LambdaQueryWrapper<Mat>().eq(Mat::getMatnr, pakin.getMatnr()));
|
| | | if (!Objects.isNull(one)) {
|
| | | throw new CoolException("当前物料不存在!!");
|
| | | }
|
| | | locDetl.setMatId(one.getId());
|
| | | locDetl.setMemo(pakin.getMemo());
|
| | | locDetl.setUpdateTime(new Date());
|
| | | if (!locDetlService.saveOrUpdate(locDetl)) {
|
| | |
| | | });
|
| | |
|
| | | //删除组拖档,加入历史组拖档
|
| | | List<WaitPakinLog> waitPakinLogs = new ArrayList<>();
|
| | | waitPakins.forEach(waitPakin -> {
|
| | | WaitPakinLog pakinLog = new WaitPakinLog();
|
| | | BeanUtils.copyProperties(waitPakin, pakinLog);
|
| | |
| | | if (!waitPakinService.removeBatchByIds(waitPakins)) {
|
| | | throw new CoolException("组拖档删除失败!!");
|
| | | }
|
| | |
|
| | | //通过组拖订单ID获取订单,并删除原单据,加入单据历史档
|
| | | List<Long> list = waitPakins.stream().map(WaitPakin::getOrderId).collect(Collectors.toList());
|
| | | List<Order> orders = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getId, list));
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | // /**
|
| | | // * 获取当前库位是否存在
|
| | | // * @param shelvesParams
|
| | | // * @return
|
| | | // */
|
| | | // @Override
|
| | | // public Loc selectPakinLocs(PakinOnShelvesParams shelvesParams) {
|
| | | // return locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, shelvesParams.getLoc()));
|
| | | // }
|
| | | @Override
|
| | | public PickSheetDetlDto outFlatSheet(String code) {
|
| | | PickSheetDetlDto pickDetlDto = new PickSheetDetlDto();
|
| | | PickSheet pickSheet = pickSheetService.getOne(new LambdaQueryWrapper<PickSheet>()
|
| | | .eq(PickSheet::getPickNo, code)
|
| | | .eq(PickSheet::getDeleted, 0)
|
| | | .eq(PickSheet::getStatus, 1)
|
| | | );
|
| | | BeanUtils.copyProperties(pickSheet, pickDetlDto);
|
| | | if (Objects.isNull(pickDetlDto)) {
|
| | | throw new CoolException("对象复制失败!!");
|
| | | }
|
| | | List<PickSheetDetl> sheetDetls = pickSheetDetlService.list(new LambdaQueryWrapper<PickSheetDetl>()
|
| | | .eq(PickSheetDetl::getPickId, pickSheet.getId())
|
| | | .eq(PickSheetDetl::getStatus, 1)
|
| | | .eq(PickSheetDetl::getDeleted, 0));
|
| | | pickDetlDto.setPickSheetDetlList(sheetDetls);
|
| | | return pickDetlDto;
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public boolean confirmFlatSheet(String code) {
|
| | | PickSheet pickSheet = pickSheetService.getOne(new LambdaQueryWrapper<PickSheet>().eq(PickSheet::getPickNo, code));
|
| | | if (Objects.isNull(pickSheet)) {
|
| | | throw new CoolException("拣货单不存在!!");
|
| | | }
|
| | | if (pickSheet.getStatus() == 1) {
|
| | | //状态修改为: 已转历史档
|
| | | pickSheet.setStatus(3);
|
| | | if (!pickSheetService.updateById(pickSheet)) {
|
| | | throw new CoolException("转历史档失败!!");
|
| | | } else{
|
| | | if (!pickSheetDetlService.update(new LambdaUpdateWrapper<PickSheetDetl>().eq(PickSheetDetl::getPickId, pickSheet.getId()).set(PickSheetDetl::getStatus, 3))) {
|
| | | throw new CoolException("拣货单明细转历史档失败!!");
|
| | | }
|
| | | }
|
| | | } else {
|
| | | throw new CoolException("请勿操作历史档数据!!");
|
| | | }
|
| | | List<PickSheetDetl> sheetDetls = pickSheetDetlService.list(new LambdaQueryWrapper<PickSheetDetl>().eq(PickSheetDetl::getPickId, pickSheet.getId()));
|
| | | Map<Long, List<PickSheetDetl>> listMap = sheetDetls.stream().collect(Collectors.groupingBy(PickSheetDetl::getLocId));
|
| | | listMap.keySet().forEach(key -> {
|
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getId, key));
|
| | | listMap.get(key).forEach(pickDetl -> {
|
| | | LocDetl detl = locDetlService.getOne(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getId, pickDetl.getLocDetlId()));
|
| | | if (Objects.isNull(detl)) {
|
| | | throw new CoolException("数据错误!!");
|
| | | }
|
| | | //更新锁定库存
|
| | | BigDecimal workQty = BigDecimal.valueOf(detl.getAnfme()).subtract(pickDetl.getAnfme());
|
| | | detl.setWorkQty(workQty.doubleValue());
|
| | | //计算结果小于等于零,移出库存明细
|
| | | BigDecimal qty = BigDecimal.valueOf(detl.getAnfme()).subtract(pickDetl.getAnfme());
|
| | | detl.setAnfme(qty.doubleValue());
|
| | | if (qty.compareTo(new BigDecimal("0.00")) <= 0) {
|
| | | detl.setDeleted(1);
|
| | | if (!locDetlService.removeById(detl)) {
|
| | | throw new CoolException("库存明细删除失败!!");
|
| | | }
|
| | | } else { //结果大于零,更新库存明细
|
| | | if (!locDetlService.updateById(detl)) {
|
| | | throw new CoolException("库存明细更新失败!!");
|
| | | }
|
| | | }
|
| | | });
|
| | | /**明细更新完成后,判断是否为空,为空更新主单状态为空库,拖盘码清空,不为空不做更新**/
|
| | | List<LocDetl> list = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, loc.getId()).eq(LocDetl::getDeleted, 0));
|
| | | if (list.isEmpty()) {
|
| | | boolean update = locService.update(new LambdaUpdateWrapper<Loc>()
|
| | | .eq(Loc::getId, loc.getId())
|
| | | .set(Loc::getBarcode, null)
|
| | | .set(Loc::getUpdateTime, new Date())
|
| | | .set(Loc::getLocStsId, LocStsType.O.val()));
|
| | | if (update) {
|
| | | throw new CoolException("库存更新失败!! ");
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | //删除波次及对应明细信息
|
| | | if (!waveService.remove(new LambdaQueryWrapper<Wave>().eq(Wave::getId, pickSheet.getWaveId()))) {
|
| | | throw new CoolException("波次列表单据删除失败!!");
|
| | | }
|
| | |
|
| | | if (!waveDetlService.remove(new LambdaQueryWrapper<WaveDetl>().eq(WaveDetl::getWaveId, pickSheet.getWaveId()))) {
|
| | | throw new CoolException("波次明细列表删除失败!!");
|
| | | }
|
| | |
|
| | | List<Order> orders = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getWaveId, pickSheet.getWaveId()));
|
| | | List<Long> list = orders.stream().map(Order::getId).collect(Collectors.toList());
|
| | | boolean remove = orderDetlService.remove(new LambdaQueryWrapper<OrderDetl>().in(OrderDetl::getOrderId, list));
|
| | | if (!remove) {
|
| | | throw new CoolException("原始订单明细删除失败!!");
|
| | | }
|
| | | if (orderService.remove(new LambdaQueryWrapper<Order>().in(Order::getId, list))) {
|
| | | throw new CoolException("原始订单删除失败!!");
|
| | | }
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<CacheSite> getSeedLocs() {
|
| | | return cacheSiteMapper.selectList(new LambdaQueryWrapper<>());
|
| | | }
|
| | |
|
| | | /**
|
| | | * 订单绑定播种墙
|
| | | * @param param
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public boolean bindOrderBySite(Map<String, Object> param) {
|
| | | // return cacheSiteMapper.bindOrderBySite(param);
|
| | | return false;
|
| | | }
|
| | |
|
| | | }
|