| | |
| | | package com.zy.asrs.wms.asrs.service.impl;
|
| | |
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
| | | 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.apis.wcs.entity.request.SlapLightControlParam;
|
| | | import com.zy.asrs.wms.apis.wcs.entity.response.CommonReponse;
|
| | | import com.zy.asrs.wms.apis.wcs.utils.HttpEssUtils;
|
| | | import com.zy.asrs.wms.asrs.entity.*;
|
| | | import com.zy.asrs.wms.asrs.entity.dto.MatnrDetlDto;
|
| | | 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.system.entity.Host;
|
| | | import com.zy.asrs.wms.system.service.HostService;
|
| | | import io.netty.util.internal.StringUtil;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.springframework.beans.BeanUtils;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | |
| | | import java.util.stream.Collectors;
|
| | |
|
| | | @Service
|
| | | @Slf4j
|
| | | public class MobileServiceImpl implements MobileService {
|
| | |
|
| | | @Autowired
|
| | |
| | | @Autowired
|
| | | private OrderDetlMapper orderDetlMapper;
|
| | | @Autowired
|
| | | private WaveSeedMapper waveSeedMapper;
|
| | | private WaveSeedService waveSeedMapper;
|
| | | @Autowired
|
| | | private WaveSeedLogService waveSeedLogService;
|
| | | @Autowired
|
| | | private OrderDetlLogService orderDetlLogService;
|
| | |
|
| | | @Autowired
|
| | | private PlatformDetlService platformDetlService;
|
| | | @Autowired
|
| | | private PlatformDetlLogService platformDetlLogService;
|
| | |
|
| | |
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public boolean batchMergeOrders(BatchMergeOrdersParam ordersParam) {
|
| | | Loc locServiceOne = locService.getOne(new LambdaQueryWrapper<Loc>()
|
| | | .eq(Loc::getLocStsId, 1)
|
| | | .eq(Loc::getBarcode, ordersParam.getMergeNo()), false);
|
| | | if (!Objects.isNull(locServiceOne)) {
|
| | | throw new CoolException("托盘已入库,不能再组托!!");
|
| | | }
|
| | |
|
| | | Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNo, ordersParam.getOrderNo()));
|
| | | if (Objects.isNull(order)) {
|
| | | throw new CoolException("订单不存在!!");
|
| | |
| | | if (!locService.updateById(loc)) {
|
| | | throw new CoolException("库位更新失败!!");
|
| | | }
|
| | |
|
| | | List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, shelvesParams.getBarcode()));
|
| | | if (waitPakins.isEmpty()) {
|
| | | throw new CoolException("当前拖盘没有组拖档!!");
|
| | |
| | | }
|
| | | //修改状态为入库中
|
| | | pakin.setIoStatus(1);
|
| | |
|
| | | OrderDetl detl = orderDetlService.getById(pakin.getDetlId());
|
| | | if (Objects.isNull(detl)) {
|
| | | throw new CoolException("数据错误:单据明细不存在!!");
|
| | | }
|
| | | Double qty = Math.round((detl.getQty() + pakin.getAnfme()) * 1000) / 1000.0;
|
| | | detl.setQty(qty);
|
| | | if (!orderDetlService.updateById(detl)) {
|
| | | throw new CoolException("单据明细修改失败!!");
|
| | | }
|
| | | });
|
| | |
|
| | | //删除组拖档,加入历史组拖档
|
| | |
| | | }
|
| | | });
|
| | |
|
| | | if (!waitPakinService.removeBatchByIds(waitPakins)) {
|
| | | throw new CoolException("组拖档删除失败!!");
|
| | | }
|
| | | //通过组拖订单ID获取订单,并删除原单据,加入单据历史档
|
| | | 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);
|
| | | orderLog.setId(null);
|
| | | if (!orderLogService.save(orderLog)) {
|
| | | throw new CoolException("历史单据更新失败!!");
|
| | | List<OrderDetl> detls = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>().eq(OrderDetl::getOrderId, order.getId()));
|
| | | Double sum = detls.stream().mapToDouble(OrderDetl::getQty).sum();
|
| | | Double summed = detls.stream().mapToDouble(OrderDetl::getWorkQty).sum();
|
| | | Double v = Math.round((sum + summed) * 1000) / 1000.0;
|
| | | Double anfme = detls.stream().mapToDouble(OrderDetl::getAnfme).sum();
|
| | | if (v.compareTo(anfme) == 0.0) {
|
| | | order.setOrderSettle(OrderSettleType.COMPLETE.val());
|
| | | if (!orderService.updateById(order)) {
|
| | | throw new CoolException("单据状态修改失败!!");
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | //删除订单数据
|
| | | if (!orderService.removeBatchByIds(orders)) {
|
| | | throw new CoolException("订单删除失败!!");
|
| | | // //订单入历史档
|
| | | // 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);
|
| | | // orderLog.setId(null);
|
| | | // if (!orderLogService.save(orderLog)) {
|
| | | // throw new CoolException("历史单据更新失败!!");
|
| | | // }
|
| | | // });
|
| | | // //删除订单数据
|
| | | // 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);
|
| | | // detlLog.setId(null);
|
| | | // detlLogs.add(detlLog);
|
| | | // });
|
| | | // //订单明细转历史档
|
| | | // if (!orderDetlLogService.saveBatch(detlLogs)) {
|
| | | // throw new CoolException("订单明细转历史失败!!");
|
| | | // }
|
| | | //
|
| | | // //删除订单明细数据
|
| | | // if (!orderDetlService.remove(new LambdaQueryWrapper<OrderDetl>().in(OrderDetl::getOrderId, list))) {
|
| | | // throw new CoolException("订单明细删除失败!!");
|
| | | // }
|
| | | if (!waitPakinService.removeBatchByIds(waitPakins)) {
|
| | | 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);
|
| | | detlLog.setId(null);
|
| | | 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;
|
| | | }
|
| | |
|
| | |
| | | pickSheet.setStatus(3);
|
| | | if (!pickSheetService.updateById(pickSheet)) {
|
| | | throw new CoolException("转历史档失败!!");
|
| | | } else{
|
| | | } else {
|
| | | if (!pickSheetDetlService.update(new LambdaUpdateWrapper<PickSheetDetl>().eq(PickSheetDetl::getPickId, pickSheet.getId()).set(PickSheetDetl::getStatus, 3))) {
|
| | | throw new CoolException("拣货单明细转历史档失败!!");
|
| | | }
|
| | |
| | |
|
| | | /**
|
| | | * 获取播种墙站点
|
| | | *
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | |
| | |
|
| | | /**
|
| | | * 订单绑定播种墙站点+
|
| | | *
|
| | | * @param param
|
| | | * @return
|
| | | */
|
| | |
| | | .setOrderId(order.getId())
|
| | | .setSiteStatus(CacheSiteStatusType.R.id)
|
| | | .setBarcode(param.get("barcode").toString());
|
| | | if (cacheSiteMapper.updateById(siteNo) < 1) {
|
| | | throw new CoolException("订单播种位绑定失败!!" );
|
| | | if (!cacheSiteService.saveOrUpdate(siteNo)) {
|
| | | throw new CoolException("订单播种位绑定失败!!");
|
| | | }
|
| | |
|
| | | int update = waveSeedMapper.update(new LambdaUpdateWrapper<WaveSeed>()
|
| | | if (!waveSeedMapper.update(new LambdaUpdateWrapper<WaveSeed>()
|
| | | .eq(WaveSeed::getOrderNo, order.getOrderNo())
|
| | | .set(WaveSeed::getSiteId, siteNo.getId())
|
| | | .set(WaveSeed::getSiteNo, siteNo.getSiteNo()));
|
| | | if (update < 1) {
|
| | | .set(WaveSeed::getSiteNo, siteNo.getSiteNo()))) {
|
| | | throw new CoolException("播种站点更新失败!!");
|
| | | }
|
| | | //绑定成功,播种墙亮灯
|
| | | sowLightMange(siteNo.getSiteNo(), order, "LIGHT");
|
| | | } else {
|
| | | if (StringUtil.isNullOrEmpty(siteNo.getOrderNo())) {
|
| | | throw new CoolException("当前播种站点未绑定订单!!");
|
| | | }
|
| | | siteNo.setOrderId(null).setOrderNo(null).setBarcode(null).setSiteNo("0");
|
| | | siteNo.setOrderId(null).setOrderNo(null).setBarcode(null).setSiteNo("0");
|
| | | if (cacheSiteMapper.updateById(siteNo) < 1) {
|
| | | throw new CoolException("订单与播种位解绑失败!!" );
|
| | | throw new CoolException("订单与播种位解绑失败!!");
|
| | | }
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | /**
|
| | | * @author Ryan
|
| | | * @date 2025/7/11
|
| | | * @description: 绑定播种墙亮灯
|
| | | * @version 1.0
|
| | | */
|
| | | public void sowLightMange(String siteNo, Order order, String light) {
|
| | | // 到达拣选位,控制播种墙亮灯
|
| | | CacheSite cacheSite = cacheSiteService.getOne(new LambdaQueryWrapper<CacheSite>()
|
| | | .eq(CacheSite::getSiteNo, siteNo));
|
| | | if (Objects.isNull(cacheSite)) {
|
| | | log.error("条码:{},未找到播种墙亮灯", siteNo);
|
| | | throw new CoolException("未找到播种墙");
|
| | | }
|
| | | List<OrderDetl> detls = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>().eq(OrderDetl::getOrderId, order.getId()));
|
| | | if (Objects.isNull(detls)) {
|
| | | throw new CoolException("数据错误,订单明细不存在!!");
|
| | | }
|
| | | int anfme = (int) detls.stream().mapToDouble(OrderDetl::getAnfme).sum();
|
| | | SlapLightControlParam slapLightControlParam = new SlapLightControlParam();
|
| | | slapLightControlParam
|
| | | .setControllerCode(cacheSite.getMemo())
|
| | | .setTagCode(cacheSite.getSiteNo())
|
| | | .setColor("GREEN")
|
| | | .setIndex(cacheSite.getIndex())
|
| | | // .setMode("LIGHT")
|
| | | .setMode(light)
|
| | | .setDisplay(anfme + "");
|
| | | // 发起亮灯请求
|
| | | log.info("播种墙亮灯下发", JSONObject.toJSONString(slapLightControlParam));
|
| | | CommonReponse response = HttpEssUtils.post("到达拣选位,播种墙亮灯", HttpEssUtils.PLT_SEND_COMMAND, slapLightControlParam);
|
| | | if (response.getCode().equals(0)) {
|
| | | log.info("播种墙{}亮灯成功", cacheSite.getSiteNo());
|
| | | } else {
|
| | | log.info("播种墙{}亮灯失败", cacheSite.getSiteNo());
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public R selectShippingDetl(Map<String, Object> params) {
|
| | |
| | | * 1. 出库修改订单完成状态,判断订单是否完成,完成加入历史档,未完成修改订单已完成数量
|
| | | * 2. 删除订单已完成播种明细信息
|
| | | * 3. 清除集货区绑定数据
|
| | | *
|
| | | * @param params
|
| | | * @return
|
| | | */
|
| | |
| | | throw new CoolException("订单明细不存在!!");
|
| | | }
|
| | | } else { //部分拣货
|
| | | byId.setQty(order.getWorkQty() + byId.getQty());
|
| | | byId.setQty(Math.round((order.getWorkQty() + byId.getQty()) * 1000) / 1000.0);
|
| | | byId.setWorkQty(0.0);
|
| | | if (!orderDetlService.updateById(byId)) {
|
| | | throw new CoolException("部分拣料明细更新失败!!");
|
| | | }
|
| | | }
|
| | |
|
| | | List<WaveSeed> waveSeeds = waveSeedMapper.selectList(new LambdaQueryWrapper<WaveSeed>().eq(WaveSeed::getOrderDetlId, order.getId()));
|
| | | List<WaveSeed> waveSeeds = waveSeedMapper.list(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);
|
| | | WaveSeedLog waveSeedLog = new WaveSeedLog();
|
| | | BeanUtils.copyProperties(seed, waveSeedLog);
|
| | | waveSeedLog.setId(null);
|
| | | waveSeedLogs.add(waveSeedLog);
|
| | | });
|
| | | });
|
| | | if (!waveSeedLogService.saveBatch(waveSeedLogs)) {
|
| | | throw new CoolException("波明历史档保存失败!!");
|
| | | }
|
| | |
|
| | | List<Long> list = waveSeeds.stream().map(WaveSeed::getId).collect(Collectors.toList());
|
| | | //删除播种明细信息
|
| | | if (!waveSeedMapper.removeByIds(list)) {
|
| | | throw new CoolException("播种明细删除携程!!");
|
| | | }
|
| | |
|
| | | }
|
| | | //删除播种明细信息
|
| | | if (waveSeedMapper.deleteByIds(waveSeeds) < 1) {
|
| | | throw new CoolException("播种明细删除携程!!");
|
| | | }
|
| | |
|
| | | });
|
| | |
|
| | | orderList.forEach(one -> {
|
| | |
| | | }
|
| | | } else { //不为空,修改订单状态,可重新组拖
|
| | | one.setOrderSettle(OrderSettleType.INIT.val());
|
| | | if (orderService.updateById(one));
|
| | | if (orderService.updateById(one)) ;
|
| | | }
|
| | | });
|
| | |
|
| | |
| | | return R.ok().add(matService.list(new LambdaQueryWrapper<Mat>().eq(Mat::getMatnr, matnr)));
|
| | | }
|
| | |
|
| | | /**
|
| | | * @author Ryan
|
| | | * @date 2025/7/10
|
| | | * @description: 获取库位明细
|
| | | * @version 1.0
|
| | | */
|
| | | @Override
|
| | | public List<LocDetl> getDetlsByCode(String barcode) {
|
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, barcode));
|
| | | if (Objects.isNull(loc)) {
|
| | | throw new CoolException("库位不存在!!");
|
| | | }
|
| | | LocArea locArea = locAreaService.getOne(new LambdaQueryWrapper<LocArea>()
|
| | | .eq(LocArea::getLocId, loc.getId())
|
| | | .eq(LocArea::getTypeId, LocAreaTypeSts.LOC_AREA_TYPE_FLAT.id));
|
| | | if (Objects.isNull(locArea)) {
|
| | | throw new CoolException("非平库库位不可执行此操作!!");
|
| | | }
|
| | | List<LocDetl> detls = locDetlService.list(new LambdaQueryWrapper<LocDetl>()
|
| | | .eq(LocDetl::getLocNo, barcode));
|
| | | for (int i = 0; i < detls.size(); i++) {
|
| | | Mat mat = matService.getOne(new LambdaQueryWrapper<Mat>().eq(Mat::getId, detls.get(i).getMatId()));
|
| | | MatnrDetlDto detlDto = new MatnrDetlDto();
|
| | | detlDto.setTspec(mat.getSpecs())
|
| | | .setType(mat.getModel())
|
| | | .setMatnrName(mat.getMaktx())
|
| | | .setMatnrNo(mat.getMatnr());
|
| | | detls.get(i).setMats(detlDto);
|
| | | }
|
| | | return detls;
|
| | | }
|
| | |
|
| | | /**
|
| | | * @author Ryan
|
| | | * @date 2025/7/11
|
| | | * @description: 平库库位转移
|
| | | * @version 1.0
|
| | | */
|
| | | @Override
|
| | | public R transferLocs(Map<String, String> param) {
|
| | | Loc barcode = locService.getOne(new LambdaQueryWrapper<Loc>()
|
| | | .eq(Loc::getLocStsId, LocStsType.F.val())
|
| | | .eq(Loc::getLocNo, param.get("barcode")));
|
| | | if (Objects.isNull(barcode)) {
|
| | | throw new CoolException(param.get("barcode") + "库位状态不可执行此操作!!");
|
| | | }
|
| | | Loc tarCode = locService.getOne(new LambdaQueryWrapper<Loc>()
|
| | | .eq(Loc::getLocStsId, LocStsType.O.val())
|
| | | .eq(Loc::getLocNo, param.get("tarCode")));
|
| | | if (Objects.isNull(tarCode)) {
|
| | | throw new CoolException("请检查目标为唯位是否存在或是否为空库!!");
|
| | | }
|
| | |
|
| | | List<Long> ids = Arrays.asList(barcode.getId(), tarCode.getId());
|
| | |
|
| | | List<LocArea> locAreas = locAreaService.list(new LambdaQueryWrapper<LocArea>()
|
| | | .in(LocArea::getLocId, ids)
|
| | | .eq(LocArea::getTypeId, LocAreaTypeSts.LOC_AREA_TYPE_FLAT.id));
|
| | | if (!locAreas.isEmpty() && locAreas.size() != ids.size()) {
|
| | | throw new CoolException("非平库不可执行此操作!!");
|
| | | }
|
| | |
|
| | | List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocNo, barcode.getLocNo()));
|
| | | if (locDetls.isEmpty()) {
|
| | | return R.error("库位明细不存在!!");
|
| | | }
|
| | |
|
| | | if (!locService.update(new LambdaUpdateWrapper<Loc>()
|
| | | .eq(Loc::getLocNo, barcode.getLocNo())
|
| | | .set(Loc::getBarcode, null)
|
| | | .set(Loc::getLocStsId, LocStsType.O.val()))) {
|
| | | throw new CoolException("源库位状态修改失败!!");
|
| | | }
|
| | |
|
| | | if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getLocNo, tarCode.getLocNo())
|
| | | .set(Loc::getBarcode, barcode.getBarcode())
|
| | | .set(Loc::getLocStsId, LocStsType.F.val()))) {
|
| | | throw new CoolException("目标库位修改失败!!");
|
| | | }
|
| | |
|
| | | if (!locDetlService.update(new LambdaUpdateWrapper<LocDetl>()
|
| | | .eq(LocDetl::getLocId, barcode.getId())
|
| | | .set(LocDetl::getLocId, tarCode.getId())
|
| | | .set(LocDetl::getLocNo, tarCode.getLocNo()))) {
|
| | | throw new CoolException("库位明细修改失败!!");
|
| | | }
|
| | |
|
| | | return R.ok();
|
| | | }
|
| | |
|
| | |
|
| | | }
|