| | |
| | | package com.zy.api.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.api.controller.params.ReceviceTaskParams; |
| | | import com.zy.api.service.WcsApiService; |
| | | import com.zy.asrs.entity.BasDevice; |
| | | import com.zy.asrs.entity.LocAroundBind; |
| | | import com.zy.asrs.service.BasDeviceService; |
| | | import com.zy.asrs.service.LocAroundBindService; |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class WcsApiServiceImpl implements WcsApiService { |
| | | |
| | | @Autowired |
| | | private BasDeviceService basDeviceService; |
| | | @Autowired |
| | | private LocAroundBindService locAroundBindService; |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | |
| | | /** |
| | | * 通知WCS锁定库位,及禁止当前库位的一切操作 |
| | |
| | | * @return com.core.common.R |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R lockLocs(ReceviceTaskParams params) { |
| | | BasDevice basDevice = basDeviceService.selectOne(new EntityWrapper<BasDevice>() |
| | | .eq("status", 1) |
| | | .eq("dev_no", params.getDeviceNo())); |
| | | if (Objects.isNull(basDevice)) { |
| | | throw new CoolException("机台信息不存在或已禁用!!"); |
| | | } |
| | | List<LocAroundBind> binds = locAroundBindService.selectList(new EntityWrapper<LocAroundBind>().eq("dev_no", basDevice.getDevNo())); |
| | | if (Objects.isNull(binds) || binds.isEmpty()) { |
| | | throw new CoolException("机台未绑定工作站台!!"); |
| | | } |
| | | Set<String> locs = binds.stream().map(LocAroundBind::getBLocNo).collect(Collectors.toSet()); |
| | | |
| | | reportLockLocs(locs); |
| | | |
| | | return R.ok("上报成功!!"); |
| | | } |
| | | |
| | | /** |
| | | * 搬运回库指令 |
| | | * @author Ryan |
| | | * @date 2026/1/10 13:11 |
| | | * @param params |
| | | * @return com.core.common.R |
| | | */ |
| | | @Override |
| | | public R backLocs(ReceviceTaskParams params) { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 上报锁定库位信息 |
| | | * @author Ryan |
| | | * @date 2026/1/10 12:50 |
| | | * @param locs |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void reportLockLocs(Set<String> locs) { |
| | | String response; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(MesConstant.URL) |
| | | .setPath(MesConstant.LOCK_LOCS_URL) |
| | | .setJson(JSON.toJSONString(locs)) |
| | | .build() |
| | | .doPost(); |
| | | R result = JSON.parseObject(response, R.class); |
| | | |
| | | if (result.get("code").equals("200")) { |
| | | //TODO 上报是否成功 |
| | | } |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | } |
| | | } |