| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.OpenOrderCompleteParam; |
| | | import com.zy.asrs.entity.param.OpenOrderPakinParam; |
| | | import com.zy.asrs.entity.param.OpenOrderPakoutParam; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.entity.result.OpenOrderCompeteResult; |
| | | import com.zy.asrs.entity.result.StockVo; |
| | | import com.zy.asrs.mapper.TagMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.utils.MatUtils; |
| | | import com.zy.asrs.utils.OrderInAndOutUtil; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.constant.AgvConstant; |
| | | import com.zy.common.constant.ArmConstant; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.model.LocDetlDto; |
| | | import com.zy.common.model.enums.WorkNoType; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.utils.NodeUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import javax.rmi.CORBA.Util; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Created by vincent on 2022/4/9 |
| | |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private PackService packService; |
| | | @Autowired |
| | | private TagService tagService; |
| | | @Autowired |
| | | private TagMapper tagMapper; |
| | | @Autowired |
| | | private BasArmService basArmService; |
| | | @Autowired |
| | | private BasArmMastService basArmMastService; |
| | | @Autowired |
| | | private BasAgvLocDetlService basAgvLocDetlService; |
| | | @Autowired |
| | | private BasArmMastSignService basArmMastSignService; |
| | | @Autowired |
| | | private BasAgvMastService basAgvMastService; |
| | | @Autowired |
| | | private LocOwnerService locOwnerService; |
| | | @Autowired |
| | | private CommonService commonService; |
| | | @Autowired |
| | | private LocMastServiceImpl locMastService; |
| | | @Autowired |
| | | private WrkDetlService wrkDetlService; |
| | | @Autowired |
| | | private BasDevpServiceImpl basDevpService; |
| | | @Autowired |
| | | private StaDescServiceImpl staDescService; |
| | | @Value("${mes.url}") |
| | | private String mesUrl; |
| | | @Value("${mes.stationaddress}") |
| | | private String stationAddress; |
| | | @Autowired |
| | | private WaitPakinService waitPakinService; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | } |
| | | DocType docType = docTypeService.selectOrAdd(param.getOrderType(), Boolean.TRUE); |
| | | Date now = new Date(); |
| | | LocOwner locOwner = null; |
| | | if (!Cools.isEmpty(param.getOwnerId())) { |
| | | locOwner = locOwnerService.selectById(param.getOwnerId()); |
| | | } else { |
| | | locOwner = locOwnerService.selectById(1); |
| | | } |
| | | // 单据主档 |
| | | order = new Order( |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 编号[非空] |
| | |
| | | DateUtils.convert(now), // 单据日期 |
| | | docType.getDocId(), // 单据类型 |
| | | null, // 项目编号 |
| | | null, // |
| | | param.getStandby1(), //项目名称 客户PO号 |
| | | null, // 调拨项目编号 |
| | | null, // 初始票据号 |
| | | null, // 票据号 |
| | | null, // 客户编号 |
| | | null, // 客户 |
| | | locOwner.getOwner(), // 客户 |
| | | null, // 联系方式 |
| | | null, // 操作人员 |
| | | null, // 合计金额 |
| | |
| | | now, // 添加时间 |
| | | 9527L, // 修改人员 |
| | | now, // 修改时间 |
| | | null // 备注 |
| | | null, // 备注 |
| | | 1 |
| | | ); |
| | | if (!orderService.insert(order)) { |
| | | throw new CoolException("生成单据主档失败,请联系管理员"); |
| | |
| | | List<DetlDto> list = new ArrayList<>(); |
| | | List<DetlDto> orderDetails = param.getOrderDetails(); |
| | | for (DetlDto detail : orderDetails) { |
| | | DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getAnfme()); |
| | | if (DetlDto.has(list, dto)) { |
| | | DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch()); |
| | | DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getBrand(), detail.getStandby1(), detail.getStandby2(), detail.getStandby3(), detail.getLineNumber(), detail.getBoxType1(), detail.getBoxType2(), detail.getBoxType3(), detail.getAnfme()); |
| | | if (DetlDto.hasLineNumber(list, dto)) { |
| | | DetlDto detlDto = DetlDto.findLineNumber(list, dto.getMatnr(), dto.getBatch(), dto.getBrand(), dto.getStandby1(), dto.getStandby2(), dto.getStandby3(), dto.getLineNumber(), dto.getBoxType1(), dto.getBoxType2(), dto.getBoxType3()); |
| | | assert detlDto != null; |
| | | detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme()); |
| | | } else { |
| | |
| | | } |
| | | OrderDetl orderDetl = new OrderDetl(); |
| | | orderDetl.sync(mat); |
| | | orderDetl.setLineNumber(detlDto.getLineNumber()); |
| | | orderDetl.setBatch(detlDto.getBatch()); |
| | | orderDetl.setAnfme(detlDto.getAnfme()); |
| | | orderDetl.setBrand(detlDto.getBrand()); |
| | | orderDetl.setStandby1(detlDto.getStandby1()); |
| | | orderDetl.setStandby2(detlDto.getStandby2()); |
| | | orderDetl.setStandby3(detlDto.getStandby3()); |
| | | orderDetl.setBoxType1(detlDto.getBoxType1()); |
| | | orderDetl.setBoxType2(detlDto.getBoxType2()); |
| | | orderDetl.setBoxType3(detlDto.getBoxType3()); |
| | | orderDetl.setOrderId(order.getId()); |
| | | orderDetl.setOrderNo(order.getOrderNo()); |
| | | orderDetl.setCreateBy(9527L); |
| | |
| | | orderDetl.setUpdateTime(now); |
| | | orderDetl.setStatus(1); |
| | | orderDetl.setQty(0.0D); |
| | | orderDetl.setPakinPakoutStatus(1); |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("生成单据明细失败,请联系管理员"); |
| | | } |
| | |
| | | if (!Cools.isEmpty(param) && !Cools.isEmpty(param.getOrderNo())) { |
| | | // 指定订单 |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | |
| | | // Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE,param.getOrderNo()); |
| | | |
| | | if (null != order) { |
| | | OpenOrderCompeteResult result = new OpenOrderCompeteResult(); |
| | | results.add(result); |
| | |
| | | result.setOrderTime(order.getOrderTime()); |
| | | result.setOrderType(order.getDocType$()); |
| | | List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); |
| | | // List<OrderDetl> orderDetls = OrderInAndOutUtil.selectByOrderId(order.getPakinPakoutStatus$(), order.getId()); |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | result.getOrderDetails().add(new DetlDto(orderDetl.getOrderNo(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getQty())); |
| | | result.getOrderDetails().add(new DetlDto(orderDetl.getOrderNo(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getBrand(), |
| | | orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), orderDetl.getLineNumber(), |
| | | orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3(), orderDetl.getQty())); |
| | | } |
| | | if (order.getSettle() == 4L) { |
| | | // 修改订单状态 4.完成 ===>> 6.已上报 |
| | | if (!orderService.updateSettle(order.getId(), 6L, null)) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | // if (!orderService.updateSettle(order.getId(), 6L, null)) { |
| | | // throw new CoolException("服务器内部错误,请联系管理员"); |
| | | // } |
| | | OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(), order.getId(), 6L, null); |
| | | } |
| | | } |
| | | } else { |
| | | // 所有订单 |
| | | List<Order> orders = orderService.selectList(new EntityWrapper<Order>().eq("settle", 4L)); |
| | | // List<Order> orders = orderService.selectBySettle(4L); |
| | | List<Order> orders = OrderInAndOutUtil.selectBySettle(null, 4L); |
| | | if (orders.isEmpty()) { |
| | | orders = new ArrayList<>(); |
| | | } |
| | | for (Order order : orders) { |
| | | OpenOrderCompeteResult result = new OpenOrderCompeteResult(); |
| | | results.add(result); |
| | |
| | | result.setOrderTime(order.getOrderTime()); |
| | | result.setOrderType(order.getDocType$()); |
| | | List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); |
| | | // List<OrderDetl> orderDetls = OrderInAndOutUtil.selectByOrderId(order.getPakinPakoutStatus$(), order.getId()); |
| | | |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | result.getOrderDetails().add(new DetlDto(orderDetl.getOrderNo(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getQty())); |
| | | result.getOrderDetails().add(new DetlDto(orderDetl.getOrderNo(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getBrand(), |
| | | orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), orderDetl.getLineNumber(), |
| | | orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3(), |
| | | orderDetl.getQty())); |
| | | } |
| | | // 修改订单状态 4.完成 ===>> 6.已上报 |
| | | if (!orderService.updateSettle(order.getId(), 6L, null)) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | // // 修改订单状态 4.完成 ===>> 6.已上报 |
| | | // if (!orderService.updateSettle(order.getId(), 6L, null)) { |
| | | // throw new CoolException("服务器内部错误,请联系管理员"); |
| | | // } |
| | | OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(), order.getId(), 6L, null); |
| | | |
| | | } |
| | | } |
| | | return results; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void pakoutOrderCreate(OpenOrderPakoutParam param) { |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | // 如果单据不存在则添加;如果单据存在,作业中无法修改,反之则修改单据 |
| | | if (!Cools.isEmpty(order)) { |
| | | throw new CoolException(param.getOrderNo() + "单据已存在,请勿重复提交"); |
| | | if (order.getSettle() > 1L) { |
| | | throw new CoolException(param.getOrderNo() + "正在出库,无法修改单据"); |
| | | } |
| | | orderService.remove(order.getId()); |
| | | } |
| | | DocType docType = docTypeService.selectOrAdd(param.getOrderType(), Boolean.FALSE); |
| | | Date now = new Date(); |
| | | LocOwner locOwner = null; |
| | | if (!Cools.isEmpty(param.getOwnerId())) { |
| | | locOwner = locOwnerService.selectById(param.getOwnerId()); |
| | | } else { |
| | | locOwner = locOwnerService.selectById(1); |
| | | } |
| | | // 单据主档 |
| | | order = new Order( |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 编号[非空] |
| | |
| | | DateUtils.convert(now), // 单据日期 |
| | | docType.getDocId(), // 单据类型 |
| | | null, // 项目编号 |
| | | null, // |
| | | param.getStandby1(), //项目名称 客户PO号 |
| | | null, // 调拨项目编号 |
| | | null, // 初始票据号 |
| | | null, // 票据号 |
| | | null, // 客户编号 |
| | | null, // 客户 |
| | | locOwner.getOwner(), // 客户 |
| | | null, // 联系方式 |
| | | null, // 操作人员 |
| | | null, // 合计金额 |
| | |
| | | now, // 添加时间 |
| | | 9527L, // 修改人员 |
| | | now, // 修改时间 |
| | | null // 备注 |
| | | null, // 备注 |
| | | 2 |
| | | ); |
| | | if (!orderService.insert(order)) { |
| | | throw new CoolException("生成单据主档失败,请联系管理员"); |
| | |
| | | List<DetlDto> list = new ArrayList<>(); |
| | | List<DetlDto> orderDetails = param.getOrderDetails(); |
| | | for (DetlDto detail : orderDetails) { |
| | | DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getAnfme()); |
| | | if (DetlDto.has(list, dto)) { |
| | | DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch()); |
| | | DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getBrand(), detail.getStandby1(), detail.getStandby2(), detail.getStandby3(), detail.getLineNumber(), |
| | | detail.getBoxType1(), detail.getBoxType2(), detail.getBoxType3(), detail.getAnfme()); |
| | | if (DetlDto.hasLineNumber(list, dto)) { |
| | | DetlDto detlDto = DetlDto.findLineNumber(list, dto.getMatnr(), dto.getBatch(), dto.getBrand(), dto.getStandby1(), dto.getStandby2(), dto.getStandby3(), dto.getLineNumber(), |
| | | dto.getBoxType1(), dto.getBoxType2(), dto.getBoxType3()); |
| | | assert detlDto != null; |
| | | detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme()); |
| | | } else { |
| | |
| | | } |
| | | OrderDetl orderDetl = new OrderDetl(); |
| | | orderDetl.sync(mat); |
| | | orderDetl.setLineNumber(detlDto.getLineNumber()); |
| | | orderDetl.setBatch(detlDto.getBatch()); |
| | | orderDetl.setAnfme(detlDto.getAnfme()); |
| | | orderDetl.setBrand(detlDto.getBrand()); |
| | | orderDetl.setStandby1(detlDto.getStandby1()); |
| | | orderDetl.setStandby2(detlDto.getStandby2()); |
| | | orderDetl.setStandby3(detlDto.getStandby3()); |
| | | orderDetl.setBoxType1(detlDto.getBoxType1()); |
| | | orderDetl.setBoxType2(detlDto.getBoxType2()); |
| | | orderDetl.setBoxType3(detlDto.getBoxType3()); |
| | | orderDetl.setOrderId(order.getId()); |
| | | orderDetl.setOrderNo(order.getOrderNo()); |
| | | orderDetl.setCreateBy(9527L); |
| | |
| | | orderDetl.setUpdateTime(now); |
| | | orderDetl.setStatus(1); |
| | | orderDetl.setQty(0.0D); |
| | | orderDetl.setPakinPakoutStatus(2); |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("生成单据明细失败,请联系管理员"); |
| | | } |
| | |
| | | if (!Cools.isEmpty(param) && !Cools.isEmpty(param.getOrderNo())) { |
| | | // 指定订单 |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | // Order order = OrderInAndOutUtil.selectByNo(Boolean.FALSE, param.getOrderNo()); |
| | | if (null != order) { |
| | | OpenOrderCompeteResult result = new OpenOrderCompeteResult(); |
| | | results.add(result); |
| | |
| | | result.setOrderTime(order.getOrderTime()); |
| | | result.setOrderType(order.getDocType$()); |
| | | List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); |
| | | // List<OrderDetl> orderDetls = OrderInAndOutUtil.selectByOrderId(order.getPakinPakoutStatus$(),order.getId()); |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | result.getOrderDetails().add(new DetlDto(orderDetl.getOrderNo(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getQty())); |
| | | result.getOrderDetails().add(new DetlDto(orderDetl.getOrderNo(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getBrand(), |
| | | orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), orderDetl.getLineNumber(), |
| | | orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3(), orderDetl.getQty())); |
| | | } |
| | | if (order.getSettle() == 4L) { |
| | | // 修改订单状态 4.完成 ===>> 6.已上报 |
| | | if (!orderService.updateSettle(order.getId(), 6L, null)) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | // if (!orderService.updateSettle(order.getId(), 6L, null)) { |
| | | // throw new CoolException("服务器内部错误,请联系管理员"); |
| | | // } |
| | | OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(), order.getId(), 6L, null); |
| | | } |
| | | } |
| | | } else { |
| | | // 所有订单 |
| | | List<Order> orders = orderService.selectList(new EntityWrapper<Order>().eq("settle", 4L)); |
| | | // List<Order> orders = orderService.selectList(new EntityWrapper<Order>().eq("settle", 4L)); |
| | | List<Order> orders = OrderInAndOutUtil.selectBySettle(null, 4L); |
| | | for (Order order : orders) { |
| | | OpenOrderCompeteResult result = new OpenOrderCompeteResult(); |
| | | results.add(result); |
| | |
| | | result.setOrderTime(order.getOrderTime()); |
| | | result.setOrderType(order.getDocType$()); |
| | | List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); |
| | | // List<OrderDetl> orderDetls = OrderInAndOutUtil.selectByOrderId(order.getPakinPakoutStatus$(), order.getId()); |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | result.getOrderDetails().add(new DetlDto(orderDetl.getOrderNo(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getQty())); |
| | | result.getOrderDetails().add(new DetlDto(orderDetl.getOrderNo(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getBrand(), |
| | | orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), orderDetl.getLineNumber(), |
| | | orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3(), orderDetl.getQty())); |
| | | } |
| | | // 修改订单状态 4.完成 ===>> 6.已上报 |
| | | if (!orderService.updateSettle(order.getId(), 6L, null)) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | // if (!orderService.updateSettle(order.getId(), 6L, null)) { |
| | | // throw new CoolException("服务器内部错误,请联系管理员"); |
| | | // } |
| | | OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(), order.getId(), 6L, null); |
| | | } |
| | | } |
| | | return results; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void packageUp(String barcode) { |
| | | Pack pack = packService.selectByBarcode(barcode); |
| | | @Transactional |
| | | public void packageUp(PackParam param) { |
| | | if (Cools.isEmpty(param.getBarcode())) { |
| | | throw new CoolException("barcode不能为空"); |
| | | } |
| | | Mat analyse = MatUtils.analyseMat(param.getBarcode()); |
| | | Pack pack = packService.selectByBarcode(param.getBarcode()); |
| | | if (null != pack) { |
| | | throw new CoolException(barcode + "重复提交"); |
| | | throw new CoolException(param.getBarcode() + "重复提交"); |
| | | } |
| | | Date now = new Date(); |
| | | // todo:luxiaotao 解析条码规则,获取物料代码 |
| | | pack = new Pack( |
| | | barcode, // 条码[非空] |
| | | null, // 商品编号 |
| | | null, // 批号 |
| | | param.getBarcode(), // 条码[非空] |
| | | analyse.getMatnr(), // 商品编号 |
| | | analyse.getBarcode(), // 序列码 |
| | | 1L, // 订单状态 |
| | | 1, // 状态 |
| | | now, // 添加时间 |
| | |
| | | if (!packService.insert(pack)) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | |
| | | Mat mat = matService.selectByMatnr(analyse.getMatnr()); |
| | | if (mat == null) { |
| | | mat = new Mat(); |
| | | // 分类 |
| | | Long tagId; |
| | | // 一级分类 |
| | | if (!Cools.isEmpty(param.getGroupCode()) && !Cools.isEmpty(param.getGroupName())) { |
| | | Tag priTag = tagService.selectByName(param.getGroupCode(), 2); |
| | | if (priTag == null) { |
| | | Tag top = tagService.getTop(); |
| | | NodeUtils nodeUtils = new NodeUtils(); |
| | | nodeUtils.executePath(top.getId()); |
| | | priTag = new Tag( |
| | | null, // 编号 |
| | | param.getGroupCode(), // 名称 |
| | | top.getId(), // 父级 |
| | | top.getName(), // 父级名称 |
| | | nodeUtils.path.toString(), // 关联路径 |
| | | nodeUtils.pathName.toString(), // 关联路径名 |
| | | 0, // 类型 |
| | | null, // 负责人 |
| | | null, // 图片 |
| | | null, // 简要描述 |
| | | null, // 数量 |
| | | 2, // 等级 |
| | | null, // 排序 |
| | | 1, // 状态 |
| | | now, // 添加时间 |
| | | null, // 添加人员 |
| | | now, // 修改时间 |
| | | null, // 修改人员 |
| | | null // 备注 |
| | | ); |
| | | if (tagMapper.insert(priTag) == 0) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | } |
| | | // 二级分类 |
| | | Tag secTag = tagService.selectByName(param.getGroupName(), 3); |
| | | if (secTag == null) { |
| | | NodeUtils nodeUtils = new NodeUtils(); |
| | | nodeUtils.executePath(priTag.getId()); |
| | | secTag = new Tag( |
| | | null, // 编号 |
| | | param.getGroupName(), // 名称 |
| | | priTag.getId(), // 父级 |
| | | priTag.getName(), // 父级名称 |
| | | nodeUtils.path.toString(), // 关联路径 |
| | | nodeUtils.pathName.toString(), // 关联路径名 |
| | | 0, // 类型 |
| | | null, // 负责人 |
| | | null, // 图片 |
| | | null, // 简要描述 |
| | | null, // 数量 |
| | | 3, // 等级 |
| | | null, // 排序 |
| | | 1, // 状态 |
| | | now, // 添加时间 |
| | | null, // 添加人员 |
| | | now, // 修改时间 |
| | | null, // 修改人员 |
| | | null // 备注 |
| | | ); |
| | | if (tagMapper.insert(secTag) == 0) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | } |
| | | tagId = secTag.getId(); |
| | | } else { |
| | | tagId = tagService.getTop().getId(); |
| | | } |
| | | mat.setTagId(tagId); |
| | | mat.setMatnr(analyse.getMatnr()); |
| | | mat.setMaktx(param.getMaterialName()); |
| | | mat.setSpecs(param.getConfigureDesc()); |
| | | mat.setModel(analyse.getModel()); |
| | | mat.setStatus(1); |
| | | mat.setCreateTime(now); |
| | | mat.setUpdateTime(now); |
| | | if (!matService.insert(mat)) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } else { |
| | | log.info("打包上线添加新物料[商品编号:{}]", mat.getMatnr()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void syncMat(MatSyncParam param) { |
| | | if (param.getMatDetails().get(0).getOperateType() == 3) { |
| | | Mat mat1 = matService.selectByMatnr(param.getMatDetails().get(0).getMatnr()); |
| | | if (Cools.isEmpty(mat1)) { |
| | | throw new CoolException("商品不存在无法禁用"); |
| | | } |
| | | } |
| | | |
| | | if (Cools.isEmpty(param.getMatDetails()) || param.getMatDetails().size() <= 0) { |
| | | throw new CoolException("商品数据为空"); |
| | | } |
| | | |
| | | for (MatSyncParam.MatParam matParam : param.getMatDetails()) { |
| | | if (Cools.isEmpty(matParam.getMatnr())) { |
| | | throw new CoolException("商品编码不能为空"); |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | Mat mat = matService.selectByMatnr(matParam.getMatnr()); |
| | | if (mat == null) { |
| | | mat = new Mat(); |
| | | // 分类 |
| | | Long tagId; |
| | | // 一级分类 |
| | | if (!Cools.isEmpty(matParam.getGroupCode()) && !Cools.isEmpty(matParam.getGroupName())) { |
| | | Tag priTag = tagService.selectByName(matParam.getGroupCode(), 2); |
| | | if (priTag == null) { |
| | | Tag top = tagService.getTop(); |
| | | NodeUtils nodeUtils = new NodeUtils(); |
| | | nodeUtils.executePath(top.getId()); |
| | | priTag = new Tag( |
| | | null, // 编号 |
| | | matParam.getGroupCode(), // 名称 |
| | | top.getId(), // 父级 |
| | | top.getName(), // 父级名称 |
| | | nodeUtils.path.toString(), // 关联路径 |
| | | nodeUtils.pathName.toString(), // 关联路径名 |
| | | 0, // 类型 |
| | | null, // 负责人 |
| | | null, // 图片 |
| | | null, // 简要描述 |
| | | null, // 数量 |
| | | 2, // 等级 |
| | | null, // 排序 |
| | | 1, // 状态 |
| | | now, // 添加时间 |
| | | null, // 添加人员 |
| | | now, // 修改时间 |
| | | null, // 修改人员 |
| | | null // 备注 |
| | | ); |
| | | if (tagMapper.insert(priTag) == 0) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | } |
| | | // 二级分类 |
| | | Tag secTag = tagService.selectByName(matParam.getGroupName(), 3); |
| | | if (secTag == null) { |
| | | NodeUtils nodeUtils = new NodeUtils(); |
| | | nodeUtils.executePath(priTag.getId()); |
| | | secTag = new Tag( |
| | | null, // 编号 |
| | | matParam.getGroupName(), // 名称 |
| | | priTag.getId(), // 父级 |
| | | priTag.getName(), // 父级名称 |
| | | nodeUtils.path.toString(), // 关联路径 |
| | | nodeUtils.pathName.toString(), // 关联路径名 |
| | | 0, // 类型 |
| | | null, // 负责人 |
| | | null, // 图片 |
| | | null, // 简要描述 |
| | | null, // 数量 |
| | | 3, // 等级 |
| | | null, // 排序 |
| | | 1, // 状态 |
| | | now, // 添加时间 |
| | | null, // 添加人员 |
| | | now, // 修改时间 |
| | | null, // 修改人员 |
| | | null // 备注 |
| | | ); |
| | | if (tagMapper.insert(secTag) == 0) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | } |
| | | tagId = secTag.getId(); |
| | | } else { |
| | | tagId = tagService.getTop().getId(); |
| | | } |
| | | mat.sync(matParam); |
| | | // mat.setMatnr(param.getMatnr()); |
| | | // mat.setMaktx(param.getMaktx()); |
| | | // mat.setSpecs(param.getSpecs()); |
| | | // mat.setModel(param.getModel()); |
| | | |
| | | mat.setTagId(tagId); |
| | | mat.setStatus(1); |
| | | mat.setCreateTime(now); |
| | | mat.setUpdateTime(now); |
| | | if (!matService.insert(mat)) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } else { |
| | | log.info("同步新物料[商品编号:{}]", mat.getMatnr()); |
| | | } |
| | | } else { |
| | | mat.sync(matParam); |
| | | if (!matService.update(mat, new EntityWrapper<Mat>().eq("matnr", matParam.getMatnr()))) { |
| | | throw new CoolException("更新已存在商品信息失败,请联系管理员"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void taskArmReport(TaskArmReportParam param) { |
| | | BasArmMast basArmMast = new BasArmMast(param); |
| | | List<BasArm> basArmList = basArmService.selectList(new EntityWrapper<BasArm>().eq("sorting_line_sou", basArmMast.getSortingLine())); |
| | | for (BasArm basArm : basArmList) { |
| | | if (basArm.getStatus() != 1) { |
| | | continue; |
| | | } |
| | | basArmMast.setArmNo(basArm.getArmNo()); |
| | | basArmMast.setStaNo(basArm.getStaNoSou()); |
| | | break; |
| | | } |
| | | BasArmMast basArmMastOld = basArmMastService.selectOne( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("sorting_line", basArmMast.getSortingLine()) |
| | | .eq("arm_no", basArmMast.getArmNo()) |
| | | .eq("status", 0) |
| | | ); |
| | | if (Cools.isEmpty(basArmMastOld)) { |
| | | basArmMastService.insert(basArmMast); |
| | | } else { |
| | | throw new CoolException("等待前边货物抓取!!!" + JSON.toJSONString(param)); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void taskArmCycleResult(TaskArmCycleResultParam param) { |
| | | BasArm basArm = basArmService.selectOne(new EntityWrapper<BasArm>() |
| | | .eq("arm_no", param.getArm_no()) |
| | | .eq("sorting_line", Integer.parseInt(param.getStaNo())) |
| | | .eq("status", 1) |
| | | ); |
| | | if (Cools.isEmpty(basArm)) { |
| | | return; |
| | | // throw new CoolException("机械臂配置异常,查询不到机械臂数据!!!"+ JSON.toJSONString(param)); |
| | | } |
| | | |
| | | try { |
| | | BasArmMastSign basArmMastSign = basArmMastSignService.selectOne( |
| | | new EntityWrapper<BasArmMastSign>() |
| | | .eq("matnr", param.getMatnr()) |
| | | .eq("order_no", param.getOrderNo()) |
| | | .eq("create_time", param.getBindingTags()) |
| | | ); |
| | | if (!Cools.isEmpty(basArmMastSign)) { |
| | | basArmMastSign.setStatus(1); |
| | | basArmMastSignService.updateById(basArmMastSign); |
| | | } |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | BasArmMast basArmMastListError = basArmMastService.selectOne( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("sorting_line", basArm.getSortingLineSou()) |
| | | .eq("arm_no", param.getArm_no()) |
| | | .eq("status", 9) |
| | | ); |
| | | if (!Cools.isEmpty(basArmMastListError)) { |
| | | if (Integer.parseInt(param.getPick_num()) == 1) { |
| | | basArmMastListError.setStatus(2); |
| | | basArmMastService.updateById(basArmMastListError); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | |
| | | BasArmMast basArmMast = basArmMastService.selectOne( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("sorting_line", basArm.getSortingLineSou()) |
| | | .eq("arm_no", param.getArm_no()) |
| | | .eq("status", 1) |
| | | ); |
| | | if (Cools.isEmpty(basArmMast)) { |
| | | return; |
| | | // throw new CoolException("未查询到相关机械臂拆码垛任务!!!"+ JSON.toJSONString(param)); |
| | | } |
| | | if (Integer.parseInt(param.getPick_num()) != 1) { |
| | | basArmMast.setStatus(9); |
| | | basArmMastService.updateById(basArmMast); |
| | | } else { |
| | | basArmMast.setStatus(2); |
| | | basArmMastService.updateById(basArmMast); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public boolean TaskArmLocStatus(ArmOKParam param) { |
| | | BasArm basArm = basArmService.selectOne(new EntityWrapper<BasArm>() |
| | | .eq("arm_no", param.getArmNo()) |
| | | .eq("sta_no", param.getStaNo()) |
| | | .eq("status", 1) |
| | | ); |
| | | if (Cools.isEmpty(basArm)) { |
| | | log.error("机械臂配置异常,查询不到机械臂数据!!!" + JSON.toJSONString(param)); |
| | | return false; |
| | | } |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", basArm.getStaNoSou())); |
| | | if (Cools.isEmpty(locMast)) { |
| | | log.error("查询不到locMast数据!!!" + JSON.toJSONString(param)); |
| | | return false; |
| | | } |
| | | if (locMast.getLocSts().equals("D")) { |
| | | BasArmMast basArmMast = basArmMastService.selectOne( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("sta_no", basArm.getStaNoSou()) |
| | | .eq("arm_no", param.getArmNo()) |
| | | .eq("status", 3) |
| | | ); |
| | | if (Cools.isEmpty(basArmMast)) { |
| | | return true; |
| | | } |
| | | log.error("未查询到相关机械臂拆码垛任务!!!" + JSON.toJSONString(param)); |
| | | } else { |
| | | log.error("locMast状态不为D!!!" + JSON.toJSONString(param)); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void taskArmWorkspaceStatus(TaskArmWorkspaceStatusParam param) { |
| | | BasArm basArm = basArmService.selectOne(new EntityWrapper<BasArm>() |
| | | .eq("arm_no", param.getArm_no()) |
| | | .eq("sta_no", Integer.parseInt(param.getId())) |
| | | .eq("status", 1) |
| | | ); |
| | | if (Cools.isEmpty(basArm)) { |
| | | throw new CoolException("机械臂配置异常,查询不到机械臂数据!!!" + JSON.toJSONString(param)); |
| | | } |
| | | BasArmMast basArmMast = basArmMastService.selectOne( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("sta_no", basArm.getStaNoSou()) |
| | | .eq("arm_no", param.getArm_no()) |
| | | .eq("status", 2) |
| | | ); |
| | | if (Cools.isEmpty(basArmMast)) { |
| | | throw new CoolException("未查询到相关机械臂拆码垛任务!!!" + JSON.toJSONString(param)); |
| | | } |
| | | // basArmMastService.updateArmMastStatus(param.getArm_no(),basArmMast.getSortingLine(),basArmMast.getStaNo(),1,3); |
| | | basArmMastService.updateArmMastStatus(param.getArm_no(), basArmMast.getSortingLine(), basArmMast.getStaNo(), 2, 3); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void taskArmWorkOrderStatus(OrderArmEndParam param) { |
| | | BasArm basArm = basArmService.selectOne(new EntityWrapper<BasArm>() |
| | | .eq("arm_no", param.getArm_no()) |
| | | .eq("sorting_line", Integer.parseInt(param.getStaNo())) |
| | | .eq("status", 1) |
| | | ); |
| | | if (Cools.isEmpty(basArm)) { |
| | | throw new CoolException("机械臂配置异常,查询不到机械臂数据!!!" + JSON.toJSONString(param)); |
| | | } |
| | | BasArmMast basArmMast = basArmMastService.selectOne( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("sorting_line", basArm.getSortingLineSou()) |
| | | .eq("arm_no", param.getArm_no()) |
| | | .eq("status", 5) |
| | | ); |
| | | if (!Cools.isEmpty(basArmMast)) { |
| | | basArmMastService.updateArmMastStatus(param.getArm_no(), basArmMast.getSortingLine(), basArmMast.getStaNo(), 5, 6); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public boolean taskArmOrderResult(OrderArmEndParam param) { |
| | | if (param.getDone_num() == 0) { |
| | | if (basArmMastService.delete(new EntityWrapper<BasArmMast>().eq("arm_no", param.getArm_no()) |
| | | .eq("status", 1))) { |
| | | return true; |
| | | } |
| | | } |
| | | if (param.getDone_num() == 1) { |
| | | return true; |
| | | } |
| | | log.error("未找到对应任务" + param); |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public List<PickWrkDetlListParam> getPickList(PdaPickListParam param) { |
| | | List<WrkDetl> wrkDetls = wrkDetlService.findByBarcode(param.getBarcode()); |
| | | List<PickWrkDetlListParam> result = new ArrayList<>(); |
| | | wrkDetls.forEach(wrkDetl -> { |
| | | Double total; |
| | | EntityWrapper<LocDetl> wrapper = new EntityWrapper<>(); |
| | | LocDetl locDetl = locDetlService.selectOne( |
| | | wrapper.eq("zpallet", wrkDetl.getZpallet()) |
| | | .eq("matnr", wrkDetl.getMatnr()) |
| | | ); |
| | | // 可拣总量:优先取库存表,否则取作业数量 |
| | | if (Cools.isEmpty(locDetl)) { |
| | | total = wrkDetl.getAnfme(); |
| | | } else { |
| | | total = locDetl.getAnfme(); |
| | | } |
| | | // ===== 组装返回对象 ===== |
| | | PickWrkDetlListParam dto = new PickWrkDetlListParam(); |
| | | dto.setMatnr(wrkDetl.getMatnr()); |
| | | dto.setMaknx(wrkDetl.getMaktx()); |
| | | dto.setOrderNo(wrkDetl.getOrderNo()); |
| | | dto.setBoxType3(wrkDetl.getBoxType3()); |
| | | dto.setStandby1(wrkDetl.getStandby1()); |
| | | dto.setStandby2(wrkDetl.getStandby2()); |
| | | dto.setStandby3(wrkDetl.getStandby3()); |
| | | dto.setManu(wrkDetl.getManu()); |
| | | dto.setMemo(wrkDetl.getMemo()); |
| | | // 当前拣货数量 |
| | | dto.setCount(wrkDetl.getAnfme()); |
| | | // 可拣总数量 |
| | | dto.setTotal(total); |
| | | result.add(dto); |
| | | }); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public List<AgvLocListDetlParam> getAgvLocList(AgvLocListParam param) { |
| | | List<AgvLocListDetlParam> result = new ArrayList<>(); |
| | | |
| | | if (Cools.isEmpty(param.getLocNo())) { |
| | | EntityWrapper<LocMast> locMastEntityWrapper = new EntityWrapper<>(); |
| | | locMastEntityWrapper.setSqlSelect("TOP 5 loc_no as locNo,loc_sts as locSts") |
| | | .where("loc_sts in ('F','D','S','R') and whs_type = '5'"); |
| | | List<LocMast> locMasts = locMastService.selectList(locMastEntityWrapper); |
| | | |
| | | for (LocMast locMast : locMasts) { |
| | | result.add(buildAgvLocListDetlParam(locMast.getLocNo(), locMast.getLocSts$())); |
| | | } |
| | | } else { |
| | | LocMast locMast = locMastService.selectOne( |
| | | new EntityWrapper<LocMast>().eq("loc_no", param.getLocNo()) |
| | | ); |
| | | result.add(buildAgvLocListDetlParam(param.getLocNo(), locMast.getLocSts$())); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | private AgvLocListDetlParam buildAgvLocListDetlParam(String locNo, String locSts) { |
| | | List<BasAgvLocDetl> detlList = basAgvLocDetlService.selectList( |
| | | new EntityWrapper<BasAgvLocDetl>().eq("loc_no", locNo) |
| | | ); |
| | | |
| | | AgvLocListDetlParam dto = new AgvLocListDetlParam(); |
| | | dto.setLocNo(locNo); |
| | | dto.setLocSys(locSts); |
| | | dto.setAgvDetlList(detlList); |
| | | return dto; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public boolean bindCtnrAndBin(bindCtnrAndBinParam param) { |
| | | // 参数检查 |
| | | if (param == null) { |
| | | throw new CoolException("参数不能为空"); |
| | | } |
| | | if (param.getFloorNo() == 1) { |
| | | AgvBindCtnrAndBinParam agvBindCtnrAndBinParam = new AgvBindCtnrAndBinParam(); |
| | | BasAgvLocNoService basAgvLocNoService = SpringUtils.getBean(BasAgvLocNoService.class); |
| | | BasAgvLocNo basAgvLocNoSou = basAgvLocNoService.selectOne(new EntityWrapper<BasAgvLocNo>().eq("loc_no", param.getLocNo())); |
| | | BasAgvLocNo basAgvLocNoEnd = basAgvLocNoService.selectOne(new EntityWrapper<BasAgvLocNo>().eq("sta_no", param.getStaNo())); |
| | | agvBindCtnrAndBinParam.setReqCode(String.valueOf(System.currentTimeMillis())); |
| | | agvBindCtnrAndBinParam.setCtnrCode(param.getBarcode()); |
| | | agvBindCtnrAndBinParam.setCtnrTyp("1"); |
| | | if (basAgvLocNoEnd != null && basAgvLocNoEnd.getAgvLocNo() != null) { |
| | | agvBindCtnrAndBinParam.setStgBinCode(basAgvLocNoEnd.getAgvLocNo()); |
| | | } |
| | | if (basAgvLocNoSou != null && basAgvLocNoSou.getAgvLocNo() != null) { |
| | | agvBindCtnrAndBinParam.setStgBinCode(basAgvLocNoSou.getAgvLocNo()); |
| | | } |
| | | agvBindCtnrAndBinParam.setIndBind(param.getIndBind()); |
| | | try { |
| | | String URL = AgvConstant.AGV_URL + "/" + AgvConstant.AGV_hikRpcService; // AGV接口地址 |
| | | String mesPath = AgvConstant.getAGVADAPTOR(param.getFloorNo()); // 接口路径 |
| | | String response = ""; |
| | | boolean success = false; |
| | | try { |
| | | log.info("AGV绑定容器接口请求参数: {}", JSON.toJSONString(agvBindCtnrAndBinParam)); |
| | | |
| | | response = new HttpHandler.Builder() |
| | | .setUri(URL) |
| | | .setPath(mesPath) |
| | | .setJson(JSON.toJSONString(agvBindCtnrAndBinParam)) |
| | | .build() |
| | | .doPost(); |
| | | |
| | | log.info("AGV绑定容器接口响应: {}", response); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | |
| | | if (jsonObject.getInteger("code") != null && jsonObject.getInteger("code").equals(0)) { |
| | | success = true; |
| | | } else { |
| | | log.error("AGV绑定容器失败!!!url:{};request:{};response:{}", URL + "/" + mesPath, JSON.toJSONString(agvBindCtnrAndBinParam), response); |
| | | throw new CoolException("AGV绑定容器失败: " + jsonObject.getString("msg")); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("AGV绑定容器接口调用异常!!!url:{};request:{};response:{}", URL + "/" + mesPath, JSON.toJSONString(agvBindCtnrAndBinParam), response, e); |
| | | throw new CoolException("AGV绑定容器接口调用异常: " + e.getMessage()); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } else { |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public R stationAll() { |
| | | List<StationParam> stationParams = new ArrayList<>(); |
| | | List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<BasDevp>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | StationParam stationParam = new StationParam(); |
| | | Boolean boo1 = false; |
| | | Boolean boo2 = false; |
| | | StaDesc staDescIn = staDescService.selectOne(new EntityWrapper<StaDesc>().eq("stn_no", basDevp.getDevNo()).eq("type_no", 1)); |
| | | if (!Cools.isEmpty(staDescIn)) { |
| | | stationParam.setStationId(basDevp.getDevNo() + ""); |
| | | stationParam.setStationType("1"); |
| | | stationParam.setStationName(basDevp.getDevNo() + ""); |
| | | stationParam.setOperateType(1); |
| | | boo1 = true; |
| | | } |
| | | StaDesc staDescOut = staDescService.selectOne(new EntityWrapper<StaDesc>().eq("stn_no", basDevp.getDevNo()).eq("type_no", 101)); |
| | | if (!Cools.isEmpty(staDescOut)) { |
| | | stationParam.setStationId(basDevp.getDevNo() + ""); |
| | | stationParam.setStationType("1"); |
| | | stationParam.setStationName(basDevp.getDevNo() + ""); |
| | | stationParam.setOperateType(2); |
| | | if (boo1) { |
| | | stationParam.setOperateType(3); |
| | | } |
| | | boo2 = true; |
| | | } |
| | | if (boo1 || boo2) { |
| | | stationParams.add(stationParam); |
| | | } |
| | | } |
| | | String response = ""; |
| | | try { |
| | | //获取Cookie值 |
| | | HashMap<String, Object> headers = new HashMap<>(); |
| | | // headers.put("accesstoken", erpSecret.getAccessToken()); |
| | | // headers.put("x-acgw-identity", xAcfwIdentity); // 自定义请求头 |
| | | response = new HttpHandler.Builder() |
| | | .setHeaders(headers) |
| | | .setUri(mesUrl) |
| | | .setPath(stationAddress) |
| | | .setJson(JSON.toJSONString(stationParams)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonResponse = JSON.parseObject(response); |
| | | if (jsonResponse.getInteger("code") == 200) { |
| | | |
| | | } else { |
| | | return R.error(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public R mesToComb(MesToCombParam param) { |
| | | if (Cools.isEmpty(param.getPalletId())) { |
| | | throw new CoolException(BaseRes.PARAM); |
| | | } |
| | | Date now = new Date(); |
| | | |
| | | Mat mat = matService.selectByMatnr(param.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | if (param.getFull()==1){ |
| | | //满托盘 |
| | | mat = matService.selectByMatnr("1"); |
| | | }else if (param.getFull()==0){ |
| | | //空托盘 |
| | | mat = matService.selectByMatnr("0"); |
| | | } |
| | | |
| | | } |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.sync(mat); |
| | | waitPakin.setBatch(String.valueOf(param.getBatchId())); |
| | | waitPakin.setZpallet(param.getPalletId()); // 托盘码 |
| | | waitPakin.setIoStatus("N"); // 入出状态 |
| | | waitPakin.setAnfme(param.getAnfme()); // 数量 |
| | | waitPakin.setStatus("Y"); // 状态 |
| | | waitPakin.setAppeUser(9995L); |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(9995L); |
| | | waitPakin.setModiTime(now); |
| | | waitPakin.setOrderNo(String.valueOf(param.getOrderId())); |
| | | waitPakin.setOrigin(String.valueOf(param.getStorageArea()));//建议入库区域 |
| | | waitPakin.setManu(String.valueOf(param.getLocId()));//mes具体库位编号 |
| | | waitPakin.setThreeCode(param.getBizNo()); |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public R outOrder(OutTaskParam param) { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_sts", "F").eq("barcode", param.getPalletId())); |
| | | if (locMast == null) { |
| | | return R.error("没有找到托盘码="+param.getPalletId()+"对应的库位"); |
| | | } |
| | | Integer ioType = 101; |
| | | // 获取路径 |
| | | StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), Integer.valueOf(param.getStationId())); |
| | | Date now = new Date(); |
| | | // 生成工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(ioType); // 入出库状态 |
| | | wrkMast.setIoPri(13D); // 优先级:13 |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 源站 |
| | | wrkMast.setStaNo(staDesc.getStnNo()); // 目标站 |
| | | wrkMast.setSourceLocNo(locMast.getLocNo()); // 源库位 |
| | | wrkMast.setBarcode(locMast.getBarcode()); |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("N"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setUserNo(param.getOrderId());//订单号 |
| | | wrkMast.setPltType(param.getSeq());//出库顺序,从1开始 |
| | | wrkMast.setTakeNone("0"); //0非自动 |
| | | wrkMast.setAppeUser(9995L); // 操作人员数据 |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(9995L); |
| | | wrkMast.setModiTime(now); |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:"+locMast.getLocNo()); |
| | | } |
| | | List<LocDetl> locNo = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo())); |
| | | if (locNo == null || locNo.size() == 0) { |
| | | throw new CoolException("查询库存明细失败,出库库位号:"+locMast.getLocNo()); |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDetl locDetl : locNo) { |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(locDetl); |
| | | wrkDetl.setOrderNo(param.getOrderId()); // 手动出库不需要带出库存中的单据编号 |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(now); |
| | | Double anfme = locDetl.getAnfme(); |
| | | wrkDetl.setAnfme(anfme); // 数量 |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setAppeUser(9995L); |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setModiUser(9995L); |
| | | |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | } |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.selectById(locMast.getLocNo()); |
| | | if (locMast.getLocSts().equals("F")) { |
| | | locMast.setLocSts("R"); |
| | | locMast.setModiUser(9995L); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("预约库位状态失败,库位号:"+locMast.getLocNo()); |
| | | } |
| | | } else { |
| | | log.error(locMast.getLocNo() + "库位不是在库状态"); |
| | | throw new CoolException(locMast.getLocNo() + "库位不是在库状态"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | } |