| | |
| | |
|
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
| | | import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
| | | import com.baomidou.mybatisplus.extension.service.IService;
|
| | | import com.zy.asrs.framework.common.R;
|
| | | 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.dto.ShippingOrderDetlDto;
|
| | | 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.PakinOnShelvesParams;
|
| | | import com.zy.asrs.wms.asrs.mapper.CacheSiteMapper;
|
| | | import com.zy.asrs.wms.asrs.mapper.SeedSitesMapper;
|
| | | import com.zy.asrs.wms.asrs.mapper.*;
|
| | | import com.zy.asrs.wms.asrs.service.*;
|
| | | import com.zy.asrs.wms.system.entity.Host;
|
| | | import com.zy.asrs.wms.system.service.HostService;
|
| | |
| | | @Autowired
|
| | | private WaveService waveService;
|
| | | @Autowired
|
| | | private WaveLogService waveLogService;
|
| | | @Autowired
|
| | | private CacheSiteService cacheSiteService;
|
| | | @Autowired
|
| | | WaveDetlLogService waveDetlLogService;
|
| | | @Autowired
|
| | | private WaveDetlService waveDetlService;
|
| | | @Autowired
|
| | | private CacheSiteMapper cacheSiteMapper;
|
| | |
|
| | | @Autowired
|
| | | private SeedSitesMapper seedSitesMapper;
|
| | | @Autowired
|
| | | private OrderDetlMapper orderDetlMapper;
|
| | | @Autowired
|
| | | private WaveSeedMapper waveSeedMapper;
|
| | | @Autowired
|
| | | private WaveSeedLogService waveSeedLogService;
|
| | | @Autowired
|
| | | private OrderDetlLogService orderDetlLogService;
|
| | |
|
| | | @Autowired
|
| | | private PlatformDetlService platformDetlService;
|
| | | @Autowired
|
| | | private PlatformDetlLogService platformDetlLogService;
|
| | |
|
| | |
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | |
| | | if (workService.generatePakIn(generatePakInParam)) {
|
| | | return true;
|
| | | }
|
| | | } else {
|
| | | //fixme 平库是否需要预约入库
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
| | | throw new CoolException("库位没有分配所属仓库区域!!");
|
| | | }
|
| | | locAreas.forEach(locArea -> {
|
| | | LocAreaType typeServiceOne = locAreaTypeService.getOne(new LambdaQueryWrapper<LocAreaType>().eq(LocAreaType::getId, locArea.getTypeId()), false);
|
| | | LocAreaType typeServiceOne = locAreaTypeService.getOne(new LambdaQueryWrapper<LocAreaType>().eq(LocAreaType::getId, locArea.getTypeId()));
|
| | | if (typeServiceOne.getParentId() != LocAreaTypeSts.LOC_AREA_TYPE_FLAT.id && typeServiceOne.getId() != LocAreaTypeSts.LOC_AREA_TYPE_FLAT.id) {
|
| | | throw new CoolException("请选择平库区库位,再操作!!");
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, shelvesParams.getBarcode()));
|
| | | if (waitPakins.isEmpty()) {
|
| | | throw new CoolException("当前拖盘没有组拖档!!");
|
| | | }
|
| | |
|
| | | waitPakins.forEach(pakin -> {
|
| | | LocDetl locDetl = new LocDetl();
|
| | | locDetl.setAnfme(pakin.getAnfme());
|
| | |
| | | waitPakins.forEach(waitPakin -> {
|
| | | WaitPakinLog pakinLog = new WaitPakinLog();
|
| | | BeanUtils.copyProperties(waitPakin, pakinLog);
|
| | | pakinLog.setIoStatus(1);
|
| | | if (!waitPakinLogService.saveOrUpdate(pakinLog)) {
|
| | | throw new CoolException("组拖历史档更新失败");
|
| | | }
|
| | |
| | | if (!waitPakinService.removeBatchByIds(waitPakins)) {
|
| | | throw new CoolException("组拖档删除失败!!");
|
| | | }
|
| | |
|
| | | //通过组拖订单ID获取订单,并删除原单据,加入单据历史档
|
| | | List<Long> list = waitPakins.stream().map(WaitPakin::getOrderId).collect(Collectors.toList());
|
| | | Set<Long> list = waitPakins.stream().map(WaitPakin::getOrderId).collect(Collectors.toSet());
|
| | | List<Order> orders = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getId, list));
|
| | | //订单入历史档
|
| | | orders.forEach(order -> {
|
| | | if (order.getOrderType() != OrderType.PK_IN_ORDER.id) {
|
| | | throw new CoolException("当前订单类型:" + order.getOrderType() + ",不可做平库上架操作!!");
|
| | | }
|
| | | //修改订单状态为已完成
|
| | | order.setOrderSettle(OrderSettleType.COMPLETE.val());
|
| | | OrderLog orderLog = new OrderLog();
|
| | | BeanUtils.copyProperties(order, orderLog);
|
| | | if (!orderLogService.save(orderLog)) {
|
| | |
| | | }
|
| | | });
|
| | |
|
| | | //删除订单数据
|
| | | if (!orderService.removeBatchByIds(orders)) {
|
| | | throw new CoolException("订单删除失败!!");
|
| | | }
|
| | |
|
| | | List<OrderDetl> detls = orderDetlMapper.selectList(new LambdaQueryWrapper<OrderDetl>().in(OrderDetl::getOrderId, list));
|
| | | List<OrderDetlLog> detlLogs = new ArrayList<>();
|
| | | detls.forEach(delt ->{
|
| | | OrderDetlLog detlLog = new OrderDetlLog();
|
| | | BeanUtils.copyProperties(delt, detlLog);
|
| | | detlLog.setQty(delt.getWorkQty());
|
| | | detlLog.setWorkQty(0.0);
|
| | | detlLogs.add(detlLog);
|
| | | });
|
| | |
|
| | | //订单明细转历史档
|
| | | if (!orderDetlLogService.saveBatch(detlLogs)) {
|
| | | throw new CoolException("订单明细转历史失败!!");
|
| | | }
|
| | |
|
| | | //删除订单明细数据
|
| | | if (!orderDetlService.remove(new LambdaQueryWrapper<OrderDetl>().in(OrderDetl::getOrderId, list))) {
|
| | | throw new CoolException("订单明细删除失败!!");
|
| | | }
|
| | |
|
| | | return true;
|
| | |
| | | .eq(PickSheet::getDeleted, 0)
|
| | | .eq(PickSheet::getStatus, 1)
|
| | | );
|
| | | BeanUtils.copyProperties(pickSheet, pickDetlDto);
|
| | | if (Objects.isNull(pickDetlDto)) {
|
| | | throw new CoolException("对象复制失败!!");
|
| | | if (Objects.isNull(pickSheet)) {
|
| | | throw new CoolException("拣货单不存在!!");
|
| | | }
|
| | | BeanUtils.copyProperties(pickSheet, pickDetlDto);
|
| | |
|
| | | List<PickSheetDetl> sheetDetls = pickSheetDetlService.list(new LambdaQueryWrapper<PickSheetDetl>()
|
| | | .eq(PickSheetDetl::getPickId, pickSheet.getId())
|
| | | .eq(PickSheetDetl::getStatus, 1)
|
| | |
| | | throw new CoolException("数据错误!!");
|
| | | }
|
| | | //更新锁定库存
|
| | | BigDecimal workQty = BigDecimal.valueOf(detl.getAnfme()).subtract(pickDetl.getAnfme());
|
| | | detl.setWorkQty(workQty.doubleValue());
|
| | | // BigDecimal workQty = BigDecimal.valueOf(detl.getAnfme()).subtract(pickDetl.getAnfme());
|
| | | detl.setWorkQty(0.0);
|
| | | //计算结果小于等于零,移出库存明细
|
| | | BigDecimal qty = BigDecimal.valueOf(detl.getAnfme()).subtract(pickDetl.getAnfme());
|
| | | detl.setAnfme(qty.doubleValue());
|
| | |
| | | .set(Loc::getBarcode, null)
|
| | | .set(Loc::getUpdateTime, new Date())
|
| | | .set(Loc::getLocStsId, LocStsType.O.val()));
|
| | | if (update) {
|
| | | if (!update) {
|
| | | throw new CoolException("库存更新失败!! ");
|
| | | }
|
| | | }
|
| | |
| | | if (!remove) {
|
| | | throw new CoolException("原始订单明细删除失败!!");
|
| | | }
|
| | | if (orderService.remove(new LambdaQueryWrapper<Order>().in(Order::getId, list))) {
|
| | | if (!orderService.remove(new LambdaQueryWrapper<Order>().in(Order::getId, list))) {
|
| | | throw new CoolException("原始订单删除失败!!");
|
| | | }
|
| | |
|
| | |
| | | if (Objects.isNull(order)) {
|
| | | throw new CoolException("绑定订单不存在!!");
|
| | | }
|
| | | siteNo.setOrderNo(order.getOrderNo()).setOrderId(order.getId()).setSiteStatus(CacheSiteStatusType.R.id);
|
| | | siteNo.setOrderNo(order.getOrderNo()).setOrderId(order.getId()).setSiteStatus(CacheSiteStatusType.R.id).setBarcode(param.get("barcode").toString());
|
| | | if (cacheSiteMapper.updateById(siteNo) < 1) {
|
| | | throw new CoolException("订单播种位绑定失败!!" );
|
| | | }
|
| | |
|
| | | int update = waveSeedMapper.update(new LambdaUpdateWrapper<WaveSeed>()
|
| | | .eq(WaveSeed::getOrderNo, order.getOrderNo())
|
| | | .set(WaveSeed::getSiteId, siteNo.getId())
|
| | | .set(WaveSeed::getSiteNo, siteNo.getSiteNo()));
|
| | | if (update < 1) {
|
| | | throw new CoolException("播种站点更新失败!!");
|
| | | }
|
| | | } else {
|
| | | if (StringUtil.isNullOrEmpty(siteNo.getOrderNo())) {
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public R selectShippingDetl(Map<String, Object> params) {
|
| | | //判断订单是否为空
|
| | | if (StringUtil.isNullOrEmpty((String) params.get("orderNo"))) {
|
| | | throw new CoolException("订单编码号不能为空!!");
|
| | | }
|
| | | String orderNo = params.get("orderNo").toString();
|
| | | Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNo, orderNo));
|
| | | if (Objects.isNull(order)) {
|
| | | throw new CoolException("订单不存在!!");
|
| | | }
|
| | | if (!order.getOrderType().equals(OrderType.UTC_OUT_ORDER.id)) {
|
| | | throw new CoolException("订单为入库单据,不能发货!!");
|
| | | }
|
| | |
|
| | | List<ShippingOrderDetlDto> waveSeeds = waveSeedMapper.selectShippingOrderDtel(orderNo);
|
| | |
|
| | | return R.ok(waveSeeds);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 发货单明细确认
|
| | | * 1. 出库修改订单完成状态,判断订单是否完成,完成加入历史档,未完成修改订单已完成数量
|
| | | * 2. 删除订单已完成播种明细信息
|
| | | * 3. 清除集货区绑定数据
|
| | | * @param params
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public R confirmShippingDetl(List<ShippingOrderDetlDto> params) {
|
| | | if (params.isEmpty()) {
|
| | | throw new CoolException("发货单据明细为空,不可执行发货操作!!");
|
| | | }
|
| | |
|
| | | //获取当前上传所有订单号
|
| | | Set<String> orderNoSet = params.stream().map(ShippingOrderDetlDto::getOrderNo).collect(Collectors.toSet());
|
| | | if (orderNoSet.isEmpty()) {
|
| | | throw new CoolException("主单信息不存在,请核对出库订单!!");
|
| | | }
|
| | |
|
| | | List<Order> orderList = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getOrderNo, orderNoSet));
|
| | | if (orderList.isEmpty()) {
|
| | | throw new CoolException("订单不存在!!");
|
| | | }
|
| | |
|
| | | params.forEach(order -> {
|
| | | OrderDetl byId = orderDetlService.getById(order.getId());
|
| | | if (Objects.isNull(byId)) {
|
| | | throw new CoolException("订单明细不存在!!");
|
| | | }
|
| | | OrderDetlLog orderDetlLog = new OrderDetlLog();
|
| | | BeanUtils.copyProperties(byId, orderDetlLog);
|
| | | orderDetlLog.setQty(order.getWorkQty());
|
| | | orderDetlLog.setWorkQty(0.0);
|
| | | if (!orderDetlLogService.save(orderDetlLog)) {
|
| | | throw new CoolException("订单明细转历史档失败!!");
|
| | | }
|
| | |
|
| | | //完全拣货,订单完成删除原始订单明细
|
| | | //new BigDecimal(order.getAnfme()).compareTo(new BigDecimal(order.getWorkQty())) == 0
|
| | | if (new BigDecimal(order.getAnfme()).compareTo(new BigDecimal(order.getWorkQty())) == 0) {
|
| | | if (!orderDetlService.removeById(byId)) {
|
| | | throw new CoolException("订单明细不存在!!");
|
| | | }
|
| | | } else { //部分拣货
|
| | | byId.setQty(order.getWorkQty() + byId.getQty());
|
| | | byId.setWorkQty(0.0);
|
| | | if (!orderDetlService.updateById(byId)) {
|
| | | throw new CoolException("部分拣料明细更新失败!!");
|
| | | }
|
| | | }
|
| | |
|
| | | List<WaveSeed> waveSeeds = waveSeedMapper.selectList(new LambdaQueryWrapper<WaveSeed>().eq(WaveSeed::getOrderDetlId, order.getId()));
|
| | | //fixme 订单明细未播种,默认可发货
|
| | | if (!waveSeeds.isEmpty()) {
|
| | | ArrayList<WaveSeedLog> waveSeedLogs = new ArrayList<>();
|
| | | waveSeeds.forEach(seed -> {
|
| | | WaveSeedLog waveSeedLog = new WaveSeedLog();
|
| | | BeanUtils.copyProperties(seed, waveSeedLog);
|
| | | waveSeedLog.setId(null);
|
| | | waveSeedLogs.add(waveSeedLog);
|
| | | });
|
| | | if (!waveSeedLogService.saveBatch(waveSeedLogs)) {
|
| | | throw new CoolException("波明历史档保存失败!!");
|
| | | }
|
| | | }
|
| | | //删除播种明细信息
|
| | | if (waveSeedMapper.deleteByIds(waveSeeds) < 1) {
|
| | | throw new CoolException("播种明细删除携程!!");
|
| | | }
|
| | | });
|
| | |
|
| | | orderList.forEach(one -> {
|
| | | OrderLog orderLog = new OrderLog();
|
| | | BeanUtils.copyProperties(one, orderLog);
|
| | | orderLog.setOrderSettle(OrderSettleType.COMPLETE.val());
|
| | |
|
| | | if (!orderLogService.save(orderLog)) {
|
| | | throw new CoolException("原始订单转历史档失败!!");
|
| | | }
|
| | | //查询当前订单下否还有明细存在
|
| | | List<OrderDetl> orders = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>().in(OrderDetl::getOrderNo, one.getOrderNo()));
|
| | | //订单明细为空,则删除主单
|
| | | if (orders.isEmpty()) {
|
| | | if (!orderService.remove(new LambdaQueryWrapper<Order>().eq(Order::getOrderNo, one.getOrderNo()))) {
|
| | | throw new CoolException("原始订单删除失败!!");
|
| | | }
|
| | | } else { //不为空,修改订单状态,可重新组拖
|
| | | one.setOrderSettle(OrderSettleType.INIT.val());
|
| | | if (orderService.updateById(one));
|
| | | }
|
| | | });
|
| | |
|
| | | Set<Long> waveIds = orderList.stream().map(Order::getWaveId).collect(Collectors.toSet());
|
| | | if (waveIds.isEmpty()) {
|
| | | throw new CoolException("波次信息为空!!");
|
| | | }
|
| | | List<Wave> waves = waveService.list(new LambdaQueryWrapper<Wave>().in(Wave::getId, waveIds));
|
| | | for (Wave wave : waves) {
|
| | | WaveLog waveLog = new WaveLog();
|
| | | waveLog.sync(wave);
|
| | | waveLog.setId(null);
|
| | | if (!waveLogService.save(waveLog)) {
|
| | | throw new CoolException("波次转历史失败");
|
| | | }
|
| | |
|
| | | List<WaveDetl> waveDetls = waveDetlService.list(new LambdaQueryWrapper<WaveDetl>().eq(WaveDetl::getWaveId, wave.getId()));
|
| | | for (WaveDetl waveDetl : waveDetls) {
|
| | | WaveDetlLog waveDetlLog = new WaveDetlLog();
|
| | | waveDetlLog.sync(waveDetl);
|
| | | waveDetlLog.setId(null);
|
| | | waveDetlLog.setWaveId(waveLog.getId());
|
| | | if (!waveDetlLogService.save(waveDetlLog)) {
|
| | | throw new CoolException("波次明细转历史失败");
|
| | | }
|
| | |
|
| | | if (!waveDetlService.removeById(waveDetl.getId())) {
|
| | | throw new CoolException("波次明细删除失败");
|
| | | }
|
| | | }
|
| | |
|
| | | if (!waveService.removeById(wave.getId())) {
|
| | | throw new CoolException("波次删除失败");
|
| | | }
|
| | | }
|
| | |
|
| | | Set<Long> ordersSet = orderList.stream().map(Order::getId).collect(Collectors.toSet());
|
| | | List<PlatformDetl> platDetls = platformDetlService.list(new LambdaQueryWrapper<PlatformDetl>().in(PlatformDetl::getOrderId, ordersSet));
|
| | | if (platDetls.isEmpty()) {
|
| | | throw new CoolException("订单信息未进集货区!!");
|
| | | }
|
| | | ArrayList<PlatformDetlLog> platformDetls = new ArrayList<>();
|
| | | platDetls.forEach(plat -> {
|
| | | PlatformDetlLog detl = new PlatformDetlLog();
|
| | | BeanUtils.copyProperties(plat, detl);
|
| | | detl.setId(null);
|
| | | platformDetls.add(detl);
|
| | | });
|
| | | //集货区转历史档
|
| | | if (!platformDetlLogService.saveBatch(platformDetls)) {
|
| | | throw new CoolException("集货区订单转历史档失败!!");
|
| | | }
|
| | |
|
| | | return R.ok("发货完成!!");
|
| | | }
|
| | |
|
| | | }
|