| | |
| | | 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.TaskStsType; |
| | | import com.zy.asrs.wms.asrs.entity.param.SeedCompleteParam; |
| | | import com.zy.asrs.wms.asrs.mapper.CacheSiteMapper; |
| | | 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.*; |
| | | |
| | | @Service("cacheSiteService") |
| | | public class CacheSiteServiceImpl extends ServiceImpl<CacheSiteMapper, CacheSite> implements CacheSiteService { |
| | | |
| | | @Autowired |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private WaveSeedService waveSeedService; |
| | | @Autowired |
| | | private WaveSeedLogService waveSeedLogService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private TaskDetlService taskDetlService; |
| | | @Autowired |
| | | private PlatformService platformService; |
| | | @Autowired |
| | | private PlatformDetlService platformDetlService; |
| | | |
| | | |
| | | @Override |
| | | public List<String> getChannelList() { |
| | | return this.baseMapper.getChannelList(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean seedCompletePreview(SeedCompleteParam param) { |
| | | if (param == null) { |
| | | throw new CoolException("参数不能为空"); |
| | | } |
| | | |
| | | String siteNo = param.getSiteNo(); |
| | | if (siteNo == null) { |
| | | throw new CoolException("播种站点编号不能为空"); |
| | | } |
| | | |
| | | CacheSite cacheSite = this.getOne(new LambdaQueryWrapper<CacheSite>().eq(CacheSite::getSiteNo, siteNo)); |
| | | if(cacheSite == null){ |
| | | throw new CoolException("播种站点不存在"); |
| | | } |
| | | |
| | | if (cacheSite.getSiteStatus().equals(CacheSiteStatusType.O.id)) { |
| | | throw new CoolException("站点状态异常"); |
| | | } |
| | | |
| | | Long orderId = cacheSite.getOrderId(); |
| | | Order order = orderService.getById(orderId); |
| | | if (order == null) { |
| | | throw new CoolException("订单不存在"); |
| | | } |
| | | |
| | | HashMap<Long, Double> stockMap = new HashMap<>(); |
| | | List<WaveSeed> waveSeeds = waveSeedService.list(new LambdaQueryWrapper<WaveSeed>().eq(WaveSeed::getOrderId, orderId)); |
| | | for (WaveSeed waveSeed : waveSeeds) { |
| | | Double anfme = stockMap.get(waveSeed.getOrderDetlId()); |
| | | if (anfme == null) { |
| | | anfme = 0.0D; |
| | | } |
| | | anfme += waveSeed.getWorkQty(); |
| | | stockMap.put(waveSeed.getOrderDetlId(), anfme); |
| | | } |
| | | |
| | | List<OrderDetl> orderDetls = orderDetlService.getOrderDetlByOrderId(orderId); |
| | | boolean check = true; |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | Double anfme = Optional.of(orderDetl.getAnfme() - orderDetl.getQty()).orElse(0.0D); |
| | | Double workQty = stockMap.get(orderDetl.getId()); |
| | | if (!anfme.equals(workQty)) { |
| | | check = false; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | return check; |
| | | } |
| | | |
| | | @Override |
| | | public void seedComplete(SeedCompleteParam param) { |
| | | if (param == null) { |
| | | throw new CoolException("参数不能为空"); |
| | | } |
| | | |
| | | String siteNo = param.getSiteNo(); |
| | | if (siteNo == null) { |
| | | throw new CoolException("播种站点编号不能为空"); |
| | | } |
| | | |
| | | CacheSite cacheSite = this.getOne(new LambdaQueryWrapper<CacheSite>().eq(CacheSite::getSiteNo, siteNo)); |
| | | if(cacheSite == null){ |
| | | throw new CoolException("播种站点不存在"); |
| | | } |
| | | |
| | | if (cacheSite.getSiteStatus().equals(CacheSiteStatusType.O.id)) { |
| | | throw new CoolException("站点状态异常"); |
| | | } |
| | | |
| | | if (cacheSite.getPlatformId() == null) { |
| | | throw new CoolException("集货区域未绑定"); |
| | | } |
| | | |
| | | Long orderId = cacheSite.getOrderId(); |
| | | Order order = orderService.getById(orderId); |
| | | if (order == null) { |
| | | throw new CoolException("订单不存在"); |
| | | } |
| | | Long waveId = order.getWaveId(); |
| | | |
| | | boolean check = this.seedCompletePreview(param); |
| | | if (!check) {//订单未处理完成 |
| | | List<Long> taskIds = new ArrayList<>(); |
| | | List<TaskDetl> taskDetls = taskDetlService.list(new LambdaQueryWrapper<TaskDetl>().eq(TaskDetl::getWaveId, waveId)); |
| | | for (TaskDetl taskDetl : taskDetls) { |
| | | if(!taskIds.contains(taskDetl.getTaskId())){ |
| | | taskIds.add(taskDetl.getTaskId()); |
| | | } |
| | | } |
| | | |
| | | if (!taskIds.isEmpty()) { |
| | | List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().in(Task::getId, taskIds).notIn(Task::getTaskSts, TaskStsType.COMPLETE_OUT.id, TaskStsType.UPDATED_OUT.id)); |
| | | if (!tasks.isEmpty()) { |
| | | throw new CoolException("存在未完成任务"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | Platform platform = platformService.getById(cacheSite.getPlatformId()); |
| | | if(platform == null){ |
| | | throw new CoolException("集货区域不存在"); |
| | | } |
| | | |
| | | List<WaveSeed> waveSeeds = waveSeedService.list(new LambdaQueryWrapper<WaveSeed>().eq(WaveSeed::getOrderId, orderId)); |
| | | if (waveSeeds.isEmpty()) { |
| | | throw new CoolException("播种数据不存在"); |
| | | } |
| | | |
| | | for (WaveSeed waveSeed : waveSeeds) { |
| | | PlatformDetl platformDetl = new PlatformDetl(); |
| | | platformDetl.setPlatformId(platform.getId()); |
| | | platformDetl.setPlatformNo(platform.getPlatformNo()); |
| | | platformDetl.setOrderId(orderId); |
| | | platformDetl.setOrderDetlId(waveSeed.getOrderDetlId()); |
| | | platformDetl.setTaskDetlId(waveSeed.getTaskDetlId()); |
| | | platformDetl.setMatnr(waveSeed.getMatnr()); |
| | | platformDetl.setBatch(waveSeed.getBatch()); |
| | | platformDetl.setFieldParams(waveSeed.getFieldParams()); |
| | | platformDetl.setAnfme(waveSeed.getAnfme()); |
| | | platformDetl.setQty(waveSeed.getWorkQty()); |
| | | |
| | | if (!platformDetlService.save(platformDetl)) { |
| | | throw new CoolException("集货区域库存插入失败"); |
| | | } |
| | | |
| | | |
| | | WaveSeedLog waveSeedLog = new WaveSeedLog(); |
| | | waveSeedLog.sync(waveSeed); |
| | | waveSeedLog.setId(null); |
| | | if (!waveSeedLogService.save(waveSeedLog)) { |
| | | throw new CoolException("播种数据转历史失败"); |
| | | } |
| | | |
| | | if (!waveSeedService.removeById(waveSeed.getId())) { |
| | | throw new CoolException("播种数据删除失败"); |
| | | } |
| | | } |
| | | |
| | | cacheSite.setSiteStatus(CacheSiteStatusType.O.id); |
| | | cacheSite.setOrderId(null); |
| | | cacheSite.setOrderNo(null); |
| | | cacheSite.setPlatformId(null); |
| | | cacheSite.setPlatformNo(null); |
| | | cacheSite.setUpdateTime(new Date()); |
| | | if (!this.updateById(cacheSite)) { |
| | | throw new CoolException("更新播种站点数据失败"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | 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.TaskStsType;
|
| | | import com.zy.asrs.wms.asrs.entity.param.SeedCompleteParam;
|
| | | import com.zy.asrs.wms.asrs.mapper.CacheSiteMapper;
|
| | | 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.*;
|
| | |
|
| | | @Service("cacheSiteService")
|
| | | public class CacheSiteServiceImpl extends ServiceImpl<CacheSiteMapper, CacheSite> implements CacheSiteService {
|
| | |
|
| | | @Autowired
|
| | | private OrderService orderService;
|
| | | @Autowired
|
| | | private OrderDetlService orderDetlService;
|
| | | @Autowired
|
| | | private WaveSeedService waveSeedService;
|
| | | @Autowired
|
| | | private WaveSeedLogService waveSeedLogService;
|
| | | @Autowired
|
| | | private TaskService taskService;
|
| | | @Autowired
|
| | | private TaskDetlService taskDetlService;
|
| | | @Autowired
|
| | | private PlatformService platformService;
|
| | | @Autowired
|
| | | private PlatformDetlService platformDetlService;
|
| | |
|
| | |
|
| | | @Override
|
| | | public List<String> getChannelList() {
|
| | | return this.baseMapper.getChannelList();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean seedCompletePreview(SeedCompleteParam param) {
|
| | | if (param == null) {
|
| | | throw new CoolException("参数不能为空");
|
| | | }
|
| | |
|
| | | String siteNo = param.getSiteNo();
|
| | | if (siteNo == null) {
|
| | | throw new CoolException("播种站点编号不能为空");
|
| | | }
|
| | |
|
| | | CacheSite cacheSite = this.getOne(new LambdaQueryWrapper<CacheSite>().eq(CacheSite::getSiteNo, siteNo));
|
| | | if(cacheSite == null){
|
| | | throw new CoolException("播种站点不存在");
|
| | | }
|
| | |
|
| | | if (cacheSite.getSiteStatus().equals(CacheSiteStatusType.O.id)) {
|
| | | throw new CoolException("站点状态异常");
|
| | | }
|
| | |
|
| | | Long orderId = cacheSite.getOrderId();
|
| | | Order order = orderService.getById(orderId);
|
| | | if (order == null) {
|
| | | throw new CoolException("订单不存在");
|
| | | }
|
| | |
|
| | | HashMap<Long, Double> stockMap = new HashMap<>();
|
| | | List<WaveSeed> waveSeeds = waveSeedService.list(new LambdaQueryWrapper<WaveSeed>().eq(WaveSeed::getOrderId, orderId));
|
| | | for (WaveSeed waveSeed : waveSeeds) {
|
| | | Double anfme = stockMap.get(waveSeed.getOrderDetlId());
|
| | | if (anfme == null) {
|
| | | anfme = 0.0D;
|
| | | }
|
| | | anfme += waveSeed.getWorkQty();
|
| | | stockMap.put(waveSeed.getOrderDetlId(), anfme);
|
| | | }
|
| | |
|
| | | List<OrderDetl> orderDetls = orderDetlService.getOrderDetlByOrderId(orderId);
|
| | | boolean check = true;
|
| | | for (OrderDetl orderDetl : orderDetls) {
|
| | | Double anfme = Optional.of(orderDetl.getAnfme() - orderDetl.getQty()).orElse(0.0D);
|
| | | Double workQty = stockMap.get(orderDetl.getId());
|
| | | if (!anfme.equals(workQty)) {
|
| | | check = false;
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | return check;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void seedComplete(SeedCompleteParam param) {
|
| | | if (param == null) {
|
| | | throw new CoolException("参数不能为空");
|
| | | }
|
| | |
|
| | | String siteNo = param.getSiteNo();
|
| | | if (siteNo == null) {
|
| | | throw new CoolException("播种站点编号不能为空");
|
| | | }
|
| | |
|
| | | CacheSite cacheSite = this.getOne(new LambdaQueryWrapper<CacheSite>().eq(CacheSite::getSiteNo, siteNo));
|
| | | if(cacheSite == null){
|
| | | throw new CoolException("播种站点不存在");
|
| | | }
|
| | |
|
| | | if (cacheSite.getSiteStatus().equals(CacheSiteStatusType.O.id)) {
|
| | | throw new CoolException("站点状态异常");
|
| | | }
|
| | |
|
| | | if (cacheSite.getPlatformId() == null) {
|
| | | throw new CoolException("集货区域未绑定");
|
| | | }
|
| | |
|
| | | Long orderId = cacheSite.getOrderId();
|
| | | Order order = orderService.getById(orderId);
|
| | | if (order == null) {
|
| | | throw new CoolException("订单不存在");
|
| | | }
|
| | | Long waveId = order.getWaveId();
|
| | |
|
| | | boolean check = this.seedCompletePreview(param);
|
| | | if (!check) {//订单未处理完成
|
| | | List<Long> taskIds = new ArrayList<>();
|
| | | List<TaskDetl> taskDetls = taskDetlService.list(new LambdaQueryWrapper<TaskDetl>().eq(TaskDetl::getWaveId, waveId));
|
| | | for (TaskDetl taskDetl : taskDetls) {
|
| | | if(!taskIds.contains(taskDetl.getTaskId())){
|
| | | taskIds.add(taskDetl.getTaskId());
|
| | | }
|
| | | }
|
| | |
|
| | | if (!taskIds.isEmpty()) {
|
| | | List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().in(Task::getId, taskIds).notIn(Task::getTaskSts, TaskStsType.COMPLETE_OUT.id, TaskStsType.UPDATED_OUT.id));
|
| | | if (!tasks.isEmpty()) {
|
| | | throw new CoolException("存在未完成任务");
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | Platform platform = platformService.getById(cacheSite.getPlatformId());
|
| | | if(platform == null){
|
| | | throw new CoolException("集货区域不存在");
|
| | | }
|
| | |
|
| | | List<WaveSeed> waveSeeds = waveSeedService.list(new LambdaQueryWrapper<WaveSeed>().eq(WaveSeed::getOrderId, orderId));
|
| | | if (waveSeeds.isEmpty()) {
|
| | | throw new CoolException("播种数据不存在");
|
| | | }
|
| | |
|
| | | for (WaveSeed waveSeed : waveSeeds) {
|
| | | PlatformDetl platformDetl = new PlatformDetl();
|
| | | platformDetl.setPlatformId(platform.getId());
|
| | | platformDetl.setPlatformNo(platform.getPlatformNo());
|
| | | platformDetl.setOrderId(orderId);
|
| | | platformDetl.setOrderDetlId(waveSeed.getOrderDetlId());
|
| | | platformDetl.setTaskDetlId(waveSeed.getTaskDetlId());
|
| | | platformDetl.setMatnr(waveSeed.getMatnr());
|
| | | platformDetl.setBatch(waveSeed.getBatch());
|
| | | platformDetl.setFieldParams(waveSeed.getFieldParams());
|
| | | platformDetl.setAnfme(waveSeed.getAnfme());
|
| | | platformDetl.setQty(waveSeed.getWorkQty());
|
| | |
|
| | | if (!platformDetlService.save(platformDetl)) {
|
| | | throw new CoolException("集货区域库存插入失败");
|
| | | }
|
| | |
|
| | |
|
| | | WaveSeedLog waveSeedLog = new WaveSeedLog();
|
| | | waveSeedLog.sync(waveSeed);
|
| | | waveSeedLog.setId(null);
|
| | | if (!waveSeedLogService.save(waveSeedLog)) {
|
| | | throw new CoolException("播种数据转历史失败");
|
| | | }
|
| | |
|
| | | if (!waveSeedService.removeById(waveSeed.getId())) {
|
| | | throw new CoolException("播种数据删除失败");
|
| | | }
|
| | | }
|
| | |
|
| | | cacheSite.setSiteStatus(CacheSiteStatusType.O.id);
|
| | | cacheSite.setOrderId(null);
|
| | | cacheSite.setOrderNo(null);
|
| | | cacheSite.setPlatformId(null);
|
| | | cacheSite.setPlatformNo(null);
|
| | | cacheSite.setUpdateTime(new Date());
|
| | | if (!this.updateById(cacheSite)) {
|
| | | throw new CoolException("更新播种站点数据失败");
|
| | | }
|
| | |
|
| | | }
|
| | | }
|