| | |
| | | package com.zy.asrs.wms.asrs.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wms.asrs.entity.*; |
| | | import com.zy.asrs.wms.asrs.entity.enums.CacheSiteStatusType; |
| | | import com.zy.asrs.wms.asrs.entity.enums.OrderSettleType; |
| | | import com.zy.asrs.wms.asrs.entity.param.PlatformShippedParam; |
| | | import com.zy.asrs.wms.asrs.mapper.PlatformMapper; |
| | | import com.zy.asrs.wms.asrs.service.*; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service("platformService") |
| | | public class PlatformServiceImpl extends ServiceImpl<PlatformMapper, Platform> implements PlatformService { |
| | | |
| | | @Autowired |
| | | private PlatformDetlService platformDetlService; |
| | | @Autowired |
| | | private PlatformDetlLogService platformDetlLogService; |
| | | @Autowired |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private CacheSiteService cacheSiteService; |
| | | @Autowired |
| | | private WaveService waveService; |
| | | @Autowired |
| | | private WaveDetlService waveDetlService; |
| | | @Autowired |
| | | private WaveLogService waveLogService; |
| | | @Autowired |
| | | private WaveDetlLogService waveDetlLogService; |
| | | |
| | | @Override |
| | | public void shipped(PlatformShippedParam param) { |
| | | if (param == null) { |
| | | throw new CoolException("参数不能为空"); |
| | | } |
| | | |
| | | if (param.getPlatformId() == null) { |
| | | throw new CoolException("集货区域参数不能为空"); |
| | | } |
| | | |
| | | Platform platform = this.getById(param.getPlatformId()); |
| | | if(platform == null) { |
| | | throw new CoolException("集货区域数据不存在"); |
| | | } |
| | | |
| | | List<PlatformDetl> detls = platformDetlService.list(new LambdaQueryWrapper<PlatformDetl>().eq(PlatformDetl::getPlatformId, platform.getId())); |
| | | if (detls.isEmpty()) { |
| | | throw new CoolException("集货区域库存为空"); |
| | | } |
| | | |
| | | ArrayList<Long> orderIds = new ArrayList<>(); |
| | | for (PlatformDetl detl : detls) { |
| | | if (!orderIds.contains(detl.getOrderId())) { |
| | | orderIds.add(detl.getOrderId()); |
| | | } |
| | | } |
| | | |
| | | List<Order> orderList = orderService.listByIds(orderIds); |
| | | if(orderList.isEmpty()) { |
| | | throw new CoolException("订单数据不存在"); |
| | | } |
| | | |
| | | ArrayList<Long> waveIds = new ArrayList<>(); |
| | | for (Order order : orderList) { |
| | | waveIds.add(order.getWaveId()); |
| | | } |
| | | |
| | | if (waveIds.isEmpty()) { |
| | | throw new CoolException("波次不存在"); |
| | | } |
| | | |
| | | List<Task> waitTasks = taskService.selectWaitWaveOut(waveIds); |
| | | if (!waitTasks.isEmpty()) { |
| | | throw new CoolException("波次存在未完成任务"); |
| | | } |
| | | |
| | | for (PlatformDetl detl : detls) { |
| | | OrderDetl orderDetl = orderDetlService.getById(detl.getOrderDetlId()); |
| | | orderDetl.setQty(orderDetl.getQty() + detl.getQty()); |
| | | orderDetl.setWorkQty(orderDetl.getWorkQty() - detl.getAnfme()); |
| | | orderDetl.setUpdateTime(new Date()); |
| | | if (!orderDetlService.updateById(orderDetl)) { |
| | | throw new CoolException("订单明细更新失败"); |
| | | } |
| | | } |
| | | |
| | | List<Wave> waves = waveService.listByIds(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("波次删除失败"); |
| | | } |
| | | } |
| | | |
| | | List<Order> orders = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getWaveId, waveIds)); |
| | | for (Order order : orders) { |
| | | order.setOrderSettle(OrderSettleType.COMPLETE.val()); |
| | | order.setUpdateTime(new Date()); |
| | | if (!orderService.updateById(order)) { |
| | | throw new CoolException("订单更新失败"); |
| | | } |
| | | } |
| | | |
| | | List<CacheSite> cacheSites = cacheSiteService.list(new LambdaQueryWrapper<CacheSite>().eq(CacheSite::getPlatformId, platform.getId())); |
| | | for (CacheSite cacheSite : cacheSites) { |
| | | if (!cacheSite.getSiteStatus().equals(CacheSiteStatusType.O.id)) { |
| | | cacheSite.setSiteStatus(CacheSiteStatusType.O.id); |
| | | cacheSite.setOrderId(null); |
| | | cacheSite.setOrderNo(null); |
| | | cacheSite.setPlatformId(null); |
| | | cacheSite.setPlatformNo(null); |
| | | cacheSite.setUpdateTime(new Date()); |
| | | if (!cacheSiteService.updateById(cacheSite)) { |
| | | throw new CoolException("播种站点更新失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (PlatformDetl detl : detls) { |
| | | PlatformDetlLog platformDetlLog = new PlatformDetlLog(); |
| | | platformDetlLog.sync(detl); |
| | | platformDetlLog.setId(null); |
| | | if (!platformDetlLogService.save(platformDetlLog)) { |
| | | throw new CoolException("集货区域库存转历史失败"); |
| | | } |
| | | |
| | | if (!platformDetlService.removeById(detl.getId())) { |
| | | throw new CoolException("集货区域删除失败"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | package com.zy.asrs.wms.asrs.service.impl;
|
| | |
|
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
| | | 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.enums.CacheSiteStatusType;
|
| | | import com.zy.asrs.wms.asrs.entity.enums.OrderSettleType;
|
| | | import com.zy.asrs.wms.asrs.entity.param.BindPlatformParam;
|
| | | import com.zy.asrs.wms.asrs.entity.param.PlatformShippedParam;
|
| | | import com.zy.asrs.wms.asrs.mapper.PlatformMapper;
|
| | | import com.zy.asrs.wms.asrs.service.*;
|
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
| | | import org.springframework.beans.BeanUtils;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | 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;
|
| | |
|
| | | @Service("platformService")
|
| | | public class PlatformServiceImpl extends ServiceImpl<PlatformMapper, Platform> implements PlatformService {
|
| | |
|
| | | @Autowired
|
| | | private PlatformDetlService platformDetlService;
|
| | | @Autowired
|
| | | private PlatformDetlLogService platformDetlLogService;
|
| | | @Autowired
|
| | | private OrderService orderService;
|
| | | @Autowired
|
| | | private OrderDetlService orderDetlService;
|
| | | @Autowired
|
| | | private TaskService taskService;
|
| | | @Autowired
|
| | | private CacheSiteService cacheSiteService;
|
| | | @Autowired
|
| | | private WaveService waveService;
|
| | | @Autowired
|
| | | private WaveDetlService waveDetlService;
|
| | | @Autowired
|
| | | private WaveLogService waveLogService;
|
| | | @Autowired
|
| | | private WaveDetlLogService waveDetlLogService;
|
| | | @Autowired
|
| | | private WaveSeedService waveSeedService;
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void shipped(PlatformShippedParam param) {
|
| | | if (param == null) {
|
| | | throw new CoolException("参数不能为空");
|
| | | }
|
| | |
|
| | | if (param.getPlatformId() == null) {
|
| | | throw new CoolException("集货区域参数不能为空");
|
| | | }
|
| | |
|
| | | Platform platform = this.getById(param.getPlatformId());
|
| | | if(platform == null) {
|
| | | throw new CoolException("集货区域数据不存在");
|
| | | }
|
| | |
|
| | | List<PlatformDetl> detls = platformDetlService.list(new LambdaQueryWrapper<PlatformDetl>().eq(PlatformDetl::getPlatformId, platform.getId()));
|
| | | if (detls.isEmpty()) {
|
| | | throw new CoolException("集货区域库存为空");
|
| | | }
|
| | |
|
| | | ArrayList<Long> orderIds = new ArrayList<>();
|
| | | for (PlatformDetl detl : detls) {
|
| | | if (!orderIds.contains(detl.getOrderId())) {
|
| | | orderIds.add(detl.getOrderId());
|
| | | }
|
| | | }
|
| | |
|
| | | List<Order> orderList = orderService.listByIds(orderIds);
|
| | | if(orderList.isEmpty()) {
|
| | | throw new CoolException("订单数据不存在");
|
| | | }
|
| | |
|
| | | ArrayList<Long> waveIds = new ArrayList<>();
|
| | | for (Order order : orderList) {
|
| | | waveIds.add(order.getWaveId());
|
| | | }
|
| | |
|
| | | if (waveIds.isEmpty()) {
|
| | | throw new CoolException("波次不存在");
|
| | | }
|
| | |
|
| | | List<Task> waitTasks = taskService.selectWaitWaveOut(waveIds);
|
| | | if (!waitTasks.isEmpty()) {
|
| | | throw new CoolException("波次存在未完成任务");
|
| | | }
|
| | |
|
| | | for (PlatformDetl detl : detls) {
|
| | | OrderDetl orderDetl = orderDetlService.getById(detl.getOrderDetlId());
|
| | | orderDetl.setQty(orderDetl.getQty() + detl.getQty());
|
| | | orderDetl.setWorkQty(orderDetl.getWorkQty() - detl.getAnfme());
|
| | | orderDetl.setUpdateTime(new Date());
|
| | | if (!orderDetlService.updateById(orderDetl)) {
|
| | | throw new CoolException("订单明细更新失败");
|
| | | }
|
| | | }
|
| | |
|
| | | List<Wave> waves = waveService.listByIds(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("波次删除失败");
|
| | | }
|
| | | }
|
| | |
|
| | | List<Order> orders = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getWaveId, waveIds));
|
| | | for (Order order : orders) {
|
| | | order.setOrderSettle(OrderSettleType.COMPLETE.val());
|
| | | order.setUpdateTime(new Date());
|
| | | if (!orderService.updateById(order)) {
|
| | | throw new CoolException("订单更新失败");
|
| | | }
|
| | | }
|
| | |
|
| | | List<CacheSite> cacheSites = cacheSiteService.list(new LambdaQueryWrapper<CacheSite>().eq(CacheSite::getPlatformId, platform.getId()));
|
| | | for (CacheSite cacheSite : cacheSites) {
|
| | | if (!cacheSite.getSiteStatus().equals(CacheSiteStatusType.O.id)) {
|
| | | cacheSite.setSiteStatus(CacheSiteStatusType.O.id);
|
| | | cacheSite.setOrderId(null);
|
| | | cacheSite.setOrderNo(null);
|
| | | cacheSite.setPlatformId(null);
|
| | | cacheSite.setPlatformNo(null);
|
| | | cacheSite.setUpdateTime(new Date());
|
| | | if (!cacheSiteService.updateById(cacheSite)) {
|
| | | throw new CoolException("播种站点更新失败");
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | for (PlatformDetl detl : detls) {
|
| | | PlatformDetlLog platformDetlLog = new PlatformDetlLog();
|
| | | platformDetlLog.sync(detl);
|
| | | platformDetlLog.setId(null);
|
| | | if (!platformDetlLogService.save(platformDetlLog)) {
|
| | | throw new CoolException("集货区域库存转历史失败");
|
| | | }
|
| | |
|
| | | if (!platformDetlService.removeById(detl.getId())) {
|
| | | throw new CoolException("集货区域删除失败");
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public R bindShippingPlatform(BindPlatformParam platform) {
|
| | | if (Objects.isNull(platform.getPlatformId())) {
|
| | | throw new CoolException("集货区标识不能为空!!");
|
| | | }
|
| | | if (Objects.isNull(platform.getOrderId())) {
|
| | | throw new CoolException("订单编码不能为空!!");
|
| | | }
|
| | | if (Objects.isNull(platform.getWaveId())) {
|
| | | throw new CoolException("波次ID不能为空!!");
|
| | | }
|
| | | Platform pl = this.getById(platform.getPlatformId());
|
| | | if (Objects.isNull(pl)) {
|
| | | throw new CoolException("集货区不存在!!");
|
| | | }
|
| | | List<WaveSeed> waveSeeds = waveSeedService.list(new LambdaQueryWrapper<WaveSeed>().eq(WaveSeed::getWaveId, platform.getWaveId()).eq(WaveSeed::getOrderId, platform.getOrderId()));
|
| | | if (waveSeeds.isEmpty()) {
|
| | | throw new CoolException("分拣明细信息不存在,数据错误!!");
|
| | | }
|
| | | ArrayList<PlatformDetl> detls = new ArrayList<>();
|
| | | waveSeeds.forEach(waveSeed -> {
|
| | | PlatformDetl platformDetl = new PlatformDetl();
|
| | | BeanUtils.copyProperties(waveSeed, platformDetl);
|
| | | platformDetl.setPlatformId(pl.getId());
|
| | | platformDetl.setPlatformNo(pl.getPlatformNo());
|
| | |
|
| | | List<PlatformDetl> list = platformDetlService.list(new LambdaQueryWrapper<PlatformDetl>().eq(PlatformDetl::getTaskDetlId, waveSeed.getTaskDetlId()).eq(PlatformDetl::getOrderDetlId, waveSeed.getOrderDetlId()).eq(PlatformDetl::getMatnr, waveSeed.getMatnr()));
|
| | | if (!list.isEmpty()) {
|
| | | throw new CoolException("订单已入集货区!!");
|
| | | }
|
| | | detls.add(platformDetl);
|
| | | });
|
| | |
|
| | | if (!platformDetlService.saveOrUpdateBatch(detls)) {
|
| | | throw new CoolException("集货区明细保存失败!!");
|
| | | }
|
| | |
|
| | | List<CacheSite> list = cacheSiteService.list(new LambdaQueryWrapper<CacheSite>().eq(CacheSite::getOrderId, platform.getOrderId()));
|
| | | if (list.isEmpty()) {
|
| | | throw new CoolException("订单未绑定播种库位,请完成拣货后,再打印订单!!");
|
| | | }
|
| | |
|
| | | boolean update = cacheSiteService.update(new LambdaUpdateWrapper<CacheSite>()
|
| | | .eq(CacheSite::getOrderId, platform.getOrderId())
|
| | | .set(CacheSite::getPlatformId, pl.getId())
|
| | | .set(CacheSite::getPlatformNo, pl.getPlatformNo()));
|
| | |
|
| | | if (!update) {
|
| | | throw new CoolException("播种墙站点绑定集货区失败!!");
|
| | | }
|
| | |
|
| | | return R.ok("绑定成功!!");
|
| | | }
|
| | | }
|