| | |
| | | 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.SpringUtils; |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.*; |
| | |
| | | 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 com.zy.erp.kingdee.utils.PostMesDataUtils; |
| | | 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 javax.rmi.CORBA.Util; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Created by vincent on 2022/4/9 |
| | |
| | | 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 |
| | | public void pakinOrderCreate(OpenOrderPakinParam param) { |
| | |
| | | List<DetlDto> list = new ArrayList<>(); |
| | | List<DetlDto> orderDetails = param.getOrderDetails(); |
| | | for (DetlDto detail : orderDetails) { |
| | | 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()); |
| | | 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()); |
| | | 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 { |
| | |
| | | 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.getBrand(), |
| | | orderDetl.getStandby1(),orderDetl.getStandby2(),orderDetl.getStandby3(),orderDetl.getLineNumber(), |
| | | orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3(), 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("服务器内部错误,请联系管理员"); |
| | | // } |
| | | OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(),order.getId(), 6L, null); |
| | | OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(), order.getId(), 6L, null); |
| | | } |
| | | } |
| | | } else { |
| | | // 所有订单 |
| | | // List<Order> orders = orderService.selectBySettle(4L); |
| | | List<Order> orders = OrderInAndOutUtil.selectBySettle(null, 4L); |
| | | if (orders.isEmpty()){ |
| | | if (orders.isEmpty()) { |
| | | orders = new ArrayList<>(); |
| | | } |
| | | for (Order order : orders) { |
| | |
| | | // 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.getBrand(), |
| | | orderDetl.getStandby1(),orderDetl.getStandby2(),orderDetl.getStandby3(),orderDetl.getLineNumber(), |
| | | orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3(), |
| | | 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("服务器内部错误,请联系管理员"); |
| | | // } |
| | | OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(),order.getId(),6L,null); |
| | | OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(), order.getId(), 6L, null); |
| | | |
| | | } |
| | | } |
| | |
| | | List<DetlDto> list = new ArrayList<>(); |
| | | List<DetlDto> orderDetails = param.getOrderDetails(); |
| | | for (DetlDto detail : orderDetails) { |
| | | 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()); |
| | | 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()); |
| | | 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 { |
| | |
| | | // 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.getBrand(), |
| | | orderDetl.getStandby1(),orderDetl.getStandby2(),orderDetl.getStandby3(),orderDetl.getLineNumber(), |
| | | orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3(), orderDetl.getQty())); |
| | | 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("服务器内部错误,请联系管理员"); |
| | | // } |
| | | OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(),order.getId(),6L,null); |
| | | OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(), order.getId(), 6L, null); |
| | | } |
| | | } |
| | | } else { |
| | |
| | | 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.getBrand(), |
| | | orderDetl.getStandby1(),orderDetl.getStandby2(),orderDetl.getStandby3(),orderDetl.getLineNumber(), |
| | | orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3(), 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("服务器内部错误,请联系管理员"); |
| | | // } |
| | | OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(),order.getId(),6L,null); |
| | | OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(), order.getId(), 6L, null); |
| | | } |
| | | } |
| | | return results; |
| | |
| | | @Override |
| | | @Transactional |
| | | public void syncMat(MatSyncParam param) { |
| | | if(param.getMatDetails().get(0).getOperateType()==3){ |
| | | if (param.getMatDetails().get(0).getOperateType() == 3) { |
| | | Mat mat1 = matService.selectByMatnr(param.getMatDetails().get(0).getMatnr()); |
| | | if(Cools.isEmpty(mat1)){ |
| | | if (Cools.isEmpty(mat1)) { |
| | | throw new CoolException("商品不存在无法禁用"); |
| | | } |
| | | } |
| | | |
| | | if (Cools.isEmpty(param.getMatDetails()) || param.getMatDetails().size() <=0 ) { |
| | | if (Cools.isEmpty(param.getMatDetails()) || param.getMatDetails().size() <= 0) { |
| | | throw new CoolException("商品数据为空"); |
| | | } |
| | | |
| | | for(MatSyncParam.MatParam matParam : param.getMatDetails()){ |
| | | if(Cools.isEmpty(matParam.getMatnr())){ |
| | | for (MatSyncParam.MatParam matParam : param.getMatDetails()) { |
| | | if (Cools.isEmpty(matParam.getMatnr())) { |
| | | throw new CoolException("商品编码不能为空"); |
| | | } |
| | | |
| | |
| | | } |
| | | } else { |
| | | mat.sync(matParam); |
| | | if (!matService.update(mat, new EntityWrapper<Mat>().eq("matnr",matParam.getMatnr()))) { |
| | | if (!matService.update(mat, new EntityWrapper<Mat>().eq("matnr", matParam.getMatnr()))) { |
| | | throw new CoolException("更新已存在商品信息失败,请联系管理员"); |
| | | } |
| | | } |
| | |
| | | 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){ |
| | | if (basArm.getStatus() != 1) { |
| | | continue; |
| | | } |
| | | basArmMast.setArmNo(basArm.getArmNo()); |
| | |
| | | .eq("arm_no", basArmMast.getArmNo()) |
| | | .eq("status", 0) |
| | | ); |
| | | if (Cools.isEmpty(basArmMastOld)){ |
| | | if (Cools.isEmpty(basArmMastOld)) { |
| | | basArmMastService.insert(basArmMast); |
| | | } else { |
| | | throw new CoolException("等待前边货物抓取!!!"+ JSON.toJSONString(param)); |
| | | throw new CoolException("等待前边货物抓取!!!" + JSON.toJSONString(param)); |
| | | } |
| | | } |
| | | |
| | |
| | | .eq("sorting_line", Integer.parseInt(param.getStaNo())) |
| | | .eq("status", 1) |
| | | ); |
| | | if (Cools.isEmpty(basArm)){ |
| | | if (Cools.isEmpty(basArm)) { |
| | | return; |
| | | // throw new CoolException("机械臂配置异常,查询不到机械臂数据!!!"+ JSON.toJSONString(param)); |
| | | } |
| | | |
| | | try{ |
| | | 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)){ |
| | | if (!Cools.isEmpty(basArmMastSign)) { |
| | | basArmMastSign.setStatus(1); |
| | | basArmMastSignService.updateById(basArmMastSign); |
| | | } |
| | | } catch (Exception e){ |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | BasArmMast basArmMastListError = basArmMastService.selectOne( |
| | |
| | | .eq("arm_no", param.getArm_no()) |
| | | .eq("status", 9) |
| | | ); |
| | | if (!Cools.isEmpty(basArmMastListError)){ |
| | | if (Integer.parseInt(param.getPick_num()) ==1){ |
| | | if (!Cools.isEmpty(basArmMastListError)) { |
| | | if (Integer.parseInt(param.getPick_num()) == 1) { |
| | | basArmMastListError.setStatus(2); |
| | | basArmMastService.updateById(basArmMastListError); |
| | | } |
| | |
| | | .eq("arm_no", param.getArm_no()) |
| | | .eq("status", 1) |
| | | ); |
| | | if (Cools.isEmpty(basArmMast)){ |
| | | if (Cools.isEmpty(basArmMast)) { |
| | | return; |
| | | // throw new CoolException("未查询到相关机械臂拆码垛任务!!!"+ JSON.toJSONString(param)); |
| | | } |
| | | if (Integer.parseInt(param.getPick_num()) !=1){ |
| | | if (Integer.parseInt(param.getPick_num()) != 1) { |
| | | basArmMast.setStatus(9); |
| | | basArmMastService.updateById(basArmMast); |
| | | } else { |
| | |
| | | .eq("sta_no", param.getStaNo()) |
| | | .eq("status", 1) |
| | | ); |
| | | if (Cools.isEmpty(basArm)){ |
| | | log.error("机械臂配置异常,查询不到机械臂数据!!!"+ JSON.toJSONString(param)); |
| | | 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)); |
| | | if (Cools.isEmpty(locMast)) { |
| | | log.error("查询不到locMast数据!!!" + JSON.toJSONString(param)); |
| | | return false; |
| | | } |
| | | if (locMast.getLocSts().equals("D")){ |
| | | 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)){ |
| | | if (Cools.isEmpty(basArmMast)) { |
| | | return true; |
| | | } |
| | | log.error("未查询到相关机械臂拆码垛任务!!!"+ JSON.toJSONString(param)); |
| | | log.error("未查询到相关机械臂拆码垛任务!!!" + JSON.toJSONString(param)); |
| | | } else { |
| | | log.error("locMast状态不为D!!!"+ JSON.toJSONString(param)); |
| | | log.error("locMast状态不为D!!!" + JSON.toJSONString(param)); |
| | | } |
| | | return false; |
| | | } |
| | |
| | | .eq("sta_no", Integer.parseInt(param.getId())) |
| | | .eq("status", 1) |
| | | ); |
| | | if (Cools.isEmpty(basArm)){ |
| | | throw new CoolException("机械臂配置异常,查询不到机械臂数据!!!"+ JSON.toJSONString(param)); |
| | | if (Cools.isEmpty(basArm)) { |
| | | throw new CoolException("机械臂配置异常,查询不到机械臂数据!!!" + JSON.toJSONString(param)); |
| | | } |
| | | BasArmMast basArmMast = basArmMastService.selectOne( |
| | | new EntityWrapper<BasArmMast>() |
| | |
| | | .eq("arm_no", param.getArm_no()) |
| | | .eq("status", 2) |
| | | ); |
| | | if (Cools.isEmpty(basArmMast)){ |
| | | throw new CoolException("未查询到相关机械臂拆码垛任务!!!"+ JSON.toJSONString(param)); |
| | | 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); |
| | | basArmMastService.updateArmMastStatus(param.getArm_no(), basArmMast.getSortingLine(), basArmMast.getStaNo(), 2, 3); |
| | | } |
| | | |
| | | @Override |
| | |
| | | .eq("sorting_line", Integer.parseInt(param.getStaNo())) |
| | | .eq("status", 1) |
| | | ); |
| | | if (Cools.isEmpty(basArm)){ |
| | | throw new CoolException("机械臂配置异常,查询不到机械臂数据!!!"+ JSON.toJSONString(param)); |
| | | if (Cools.isEmpty(basArm)) { |
| | | throw new CoolException("机械臂配置异常,查询不到机械臂数据!!!" + JSON.toJSONString(param)); |
| | | } |
| | | BasArmMast basArmMast = basArmMastService.selectOne( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("sorting_line",basArm.getSortingLineSou()) |
| | | .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); |
| | | 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))){ |
| | | 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){ |
| | | if (param.getDone_num() == 1) { |
| | | return true; |
| | | } |
| | | log.error("未找到对应任务"+ param); |
| | | log.error("未找到对应任务" + param); |
| | | return false; |
| | | } |
| | | |
| | |
| | | .eq("create_time", param.getBindingTags()) |
| | | .eq("status", 0) |
| | | ); |
| | | if (Cools.isEmpty(basArmMastSignNew)){ |
| | | if (Cools.isEmpty(basArmMastSignNew)) { |
| | | return false; |
| | | } |
| | | return true; |
| | |
| | | @Transactional |
| | | public boolean TaskAgvReport(TaskAgvReportParam param) { |
| | | BasAgvMast basAgvMast = basAgvMastService.selectOne(new EntityWrapper<BasAgvMast>().eq("task_no", param.getTaskNo())); |
| | | if (Cools.isEmpty(basAgvMast)){ |
| | | if (Cools.isEmpty(basAgvMast)) { |
| | | return false; |
| | | } |
| | | basAgvMast.setStatus(2); |
| | |
| | | basAgvMast.setModiTime(new Date()); |
| | | basAgvMast.setIoType(param.getIoType()); |
| | | basAgvMast.setFloorNo(param.getFloorNo()); |
| | | switch (basAgvMast.getIoType()){ |
| | | switch (basAgvMast.getIoType()) { |
| | | // AGV库位==》输送线站点 0 |
| | | // AGV库位==》AGV库位 1 |
| | | // 输送线站点==》AGV库位 2 |
| | |
| | | bindParam.setFloorNo(basAgvMast.getFloorNo()); |
| | | bindParam.setLocNo(locNo); |
| | | bindParam.setStaNo(staNo); |
| | | if(bindCtnrAndBin(bindParam)){ |
| | | if (bindCtnrAndBin(bindParam)) { |
| | | return true; |
| | | }else{ |
| | | } else { |
| | | throw new CoolException("未能绑定"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public List<PickWrkDetlListParam> getPickList(PdaPickListParam param) { |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public List<AgvLocListDetlParam> getAgvLocList(AgvLocListParam param) { |
| | |
| | | ); |
| | | result.add(buildAgvLocListDetlParam(param.getLocNo(), locMast.getLocSts$())); |
| | | } |
| | | |
| | | |
| | | return result; |
| | | } |
| | | |
| | |
| | | List<BasAgvLocDetl> detlList = basAgvLocDetlService.selectList( |
| | | new EntityWrapper<BasAgvLocDetl>().eq("loc_no", locNo) |
| | | ); |
| | | |
| | | |
| | | AgvLocListDetlParam dto = new AgvLocListDetlParam(); |
| | | dto.setLocNo(locNo); |
| | | dto.setLocSys(locSts); |
| | |
| | | if (param == null) { |
| | | throw new CoolException("参数不能为空"); |
| | | } |
| | | if (param.getFloorNo()==1){ |
| | | 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())); |
| | |
| | | agvBindCtnrAndBinParam.setReqCode(String.valueOf(System.currentTimeMillis())); |
| | | agvBindCtnrAndBinParam.setCtnrCode(param.getBarcode()); |
| | | agvBindCtnrAndBinParam.setCtnrTyp("1"); |
| | | if(basAgvLocNoEnd != null && basAgvLocNoEnd.getAgvLocNo() != null){ |
| | | if (basAgvLocNoEnd != null && basAgvLocNoEnd.getAgvLocNo() != null) { |
| | | agvBindCtnrAndBinParam.setStgBinCode(basAgvLocNoEnd.getAgvLocNo()); |
| | | } |
| | | if(basAgvLocNoSou != null && basAgvLocNoSou.getAgvLocNo() != null){ |
| | | 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 URL = AgvConstant.AGV_URL + "/" + AgvConstant.AGV_hikRpcService; // AGV接口地址 |
| | | String mesPath = AgvConstant.getAGVADAPTOR(param.getFloorNo()); // 接口路径 |
| | | String response = ""; |
| | | boolean success = false; |
| | |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } else {} |
| | | } else { |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public boolean agvApplicationPassedTheGrating(ArmAgvGratingParam arm) { |
| | | ReturnT<String> result = new PostMesDataUtils().postMesDataArmGrating("光栅请求下发:", ArmConstant.getArmUrl(arm.getArmNo()), ArmConstant.ARM_ADAPTOR_GRATING_AGVENTER, arm); |
| | | if (result.getCode()==200){ |
| | | if (result.getCode() == 200) { |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | agvGoParam.setReqCode(param.getReqCode()); |
| | | agvGoParam.setTaskCode(param.getTaskCode()); |
| | | ReturnT<String> result = new PostMesDataUtils().postMesDataArmGrating("光栅下发后继续任务:", URL, AGVPath, agvGoParam); |
| | | if (result.getCode()==200){ |
| | | if (result.getCode() == 200) { |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | public boolean agvBindAndBin(String taskNo) { |
| | | String URL = "http://10.10.10.200:8181"; // AGV接口地址 |
| | | String AGVPath = "rcms/services/rest/hikRpcService/bindCtnrAndBin"; // 接口路径 |
| | | BasAgvMast basAgvMast = basAgvMastService.selectOne(new EntityWrapper<BasAgvMast>().eq("task_no",taskNo)); |
| | | if (Cools.isEmpty(basAgvMast)){ |
| | | BasAgvMast basAgvMast = basAgvMastService.selectOne(new EntityWrapper<BasAgvMast>().eq("task_no", taskNo)); |
| | | if (Cools.isEmpty(basAgvMast)) { |
| | | return false; |
| | | } |
| | | if (basAgvMast.getFloorNo()==1){ |
| | | if (basAgvMast.getFloorNo() == 1) { |
| | | BasAgvLocNoService basAgvLocNoService = SpringUtils.getBean(BasAgvLocNoService.class); |
| | | BasAgvLocNo basAgvLocNoEnd = basAgvLocNoService.selectOne( |
| | | new EntityWrapper<BasAgvLocNo>().eq("sta_no", basAgvMast.getStaNo()) |
| | |
| | | String binCode = basAgvLocNoEnd != null |
| | | ? basAgvLocNoEnd.getAgvLocNo() |
| | | : (locNo != null ? locNo.getAgvLocNo() : null); |
| | | if (Cools.isEmpty(basAgvMast)){ |
| | | if (Cools.isEmpty(basAgvMast)) { |
| | | return false; |
| | | } |
| | | String ctnrCode = basAgvMast.getBarcode().length() > 1?basAgvMast.getBarcode():basAgvMast.getTimestamp().toString(); |
| | | String ctnrCode = basAgvMast.getBarcode().length() > 1 ? basAgvMast.getBarcode() : basAgvMast.getTimestamp().toString(); |
| | | AgvBindCtnrAndBinParam agvBindCtnrAndBinParam = new AgvBindCtnrAndBinParam(); |
| | | agvBindCtnrAndBinParam.setReqCode(basAgvMast.getTaskNo() + "-" + System.currentTimeMillis()); |
| | | agvBindCtnrAndBinParam.setCtnrCode(ctnrCode); |
| | | agvBindCtnrAndBinParam.setCtnrTyp("1"); |
| | | agvBindCtnrAndBinParam.setStgBinCode(binCode); |
| | | agvBindCtnrAndBinParam.setIndBind("0"); |
| | | ReturnT<String> resultBind = new PostMesDataUtils().postMesDataArmGrating("AGV容器解绑", URL,AGVPath, agvBindCtnrAndBinParam); |
| | | if (resultBind.getCode() ==200){ |
| | | ReturnT<String> resultBind = new PostMesDataUtils().postMesDataArmGrating("AGV容器解绑", URL, AGVPath, agvBindCtnrAndBinParam); |
| | | if (resultBind.getCode() == 200) { |
| | | basAgvMast.setStatus(4); |
| | | basAgvMastService.updateById(basAgvMast); |
| | | return true; |
| | | } |
| | | return false; |
| | | }else { |
| | | } else { |
| | | if (basAgvMast != null |
| | | && basAgvMast.getIoType() != null |
| | | && (basAgvMast.getIoType() == 0) |
| | | && (Objects.equals(basAgvMast.getSourceStaNo(), 2033) || Objects.equals(basAgvMast.getStaNo(), 2034) |
| | | || Objects.equals(basAgvMast.getStaNo(), 4003)|| Objects.equals(basAgvMast.getSourceStaNo(), 4006))){ |
| | | || Objects.equals(basAgvMast.getStaNo(), 4003) || Objects.equals(basAgvMast.getSourceStaNo(), 4006))) { |
| | | AgvBindCtnrAndBinTwoParam agvBindCtnrAndBinTwoParam = new AgvBindCtnrAndBinTwoParam(); |
| | | agvBindCtnrAndBinTwoParam.setReqCode(String.valueOf(snowflakeIdWorker.nextId())); |
| | | agvBindCtnrAndBinTwoParam.setPodcode(basAgvMast.getBarcode()); |
| | | agvBindCtnrAndBinTwoParam.setPositionCode(basAgvMast.getStaNo().toString()); |
| | | agvBindCtnrAndBinTwoParam.setIndBind("0");; |
| | | agvBindCtnrAndBinTwoParam.setIndBind("0"); |
| | | ; |
| | | ReturnT<String> resultBind = new PostMesDataUtils().postMesDataArmGrating("AGV容器解绑", |
| | | AgvConstant.AGV_URL+"/"+AgvConstant.AGV_hikRpcService,AgvConstant.getAGVADAPTOR(2), agvBindCtnrAndBinTwoParam); |
| | | if (resultBind.getCode()!=1){ |
| | | AgvConstant.AGV_URL + "/" + AgvConstant.AGV_hikRpcService, AgvConstant.getAGVADAPTOR(2), agvBindCtnrAndBinTwoParam); |
| | | if (resultBind.getCode() != 1) { |
| | | basAgvMast.setStatus(4); |
| | | basAgvMastService.updateById(basAgvMast); |
| | | 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(); |
| | | } |
| | | } |