| | |
| | | import com.zy.api.entity.dto.LocMastDto; |
| | | import com.zy.api.service.WcsApiService; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.CompleteParam; |
| | | import com.zy.asrs.enums.LocStsType; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.service.impl.LocDetlServiceImpl; |
| | | import com.zy.asrs.service.impl.MatServiceImpl; |
| | | import com.zy.asrs.service.impl.RowLastnoServiceImpl; |
| | | import com.zy.asrs.service.impl.WrkDetlServiceImpl; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.utils.HttpHandler; |
| | | 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.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static jdk.nashorn.internal.runtime.regexp.joni.Config.log; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class WcsApiServiceImpl implements WcsApiService { |
| | | |
| | |
| | | private MatService matService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private RowLastnoService rowLastnoService; |
| | | |
| | | /** |
| | | * 通知WCS锁定库位,及禁止当前库位的一切操作 |
| | |
| | | if (Objects.isNull(params.getTaskNo())) { |
| | | return R.error("任务号不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getBarcode())) { |
| | | return R.error("托盘码不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getLocNo())) { |
| | | return R.error("目标库位不能为空!!"); |
| | | } |
| | | // if (params.getType().equals("in")) |
| | | // if (Objects.isNull(params.getBarcode())) { |
| | | // return R.error("托盘码不能为空!!"); |
| | | // } |
| | | // if (Objects.isNull(params.getLocNo())) { |
| | | // return R.error("目标库位不能为空!!"); |
| | | // } |
| | | String url = MesConstant.PUB_TASK_IN; |
| | | if (Objects.isNull(params.getType()) && params.getType().equals("out")) { |
| | | if (!Objects.isNull(params.getType()) && params.getType().equals("out")) { |
| | | url = MesConstant.PUB_TASK_OUT; |
| | | } |
| | | |
| | | log.info("出库任务下发参数:{}", JSON.toJSONString(params)); |
| | | String response; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(MesConstant.URL) |
| | | .setUri(MesConstant.WCS_URL) |
| | | .setPath(url) |
| | | .setJson(JSON.toJSONString(params)) |
| | | .build() |
| | | .doPost(); |
| | | R result = JSON.parseObject(response, R.class); |
| | | Map<String, Object> result = JSON.parseObject(response, Map.class); |
| | | |
| | | if (result.get("code").equals("200")) { |
| | | if (result.get("code").equals(200)) { |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", params.getTaskNo())); |
| | | wrkMast.setWrkSts(12L); |
| | | wrkMastService.updateById(wrkMast); |
| | | //TODO 上报是否成功 |
| | | } else { |
| | | return R.error().add(result); |
| | | } |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 堆垛机执行状态上报 |
| | | * |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R receviceTaskFromWcs(ReceviceTaskParams params) { |
| | | if (Objects.isNull(params.getWrkNo())) { |
| | | if (Objects.isNull(params.getSuperTaskNo())) { |
| | | throw new CoolException("WMS任务号不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getNotifyType())) { |
| | | throw new CoolException("动作类型不能为空!!"); |
| | | } |
| | | WrkMast mast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", params.getWrkNo())); |
| | | WrkMast mast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", params.getSuperTaskNo())); |
| | | if (Objects.isNull(mast)) { |
| | | throw new CoolException("任务档不存在!!"); |
| | | } |
| | | log.info("任务执行参数回写:{}", JSON.toJSONString(params)); |
| | | if (params.getNotifyType().equals("task")) { |
| | | //任务 |
| | | if (params.getMsgType().equals("task_complete")) { |
| | | if (mast.getIoType() == 1) { |
| | | if (mast.getIoType() == 1 || mast.getIoType() == 10 || mast.getIoType() == 53 || mast.getIoType() == 54 || mast.getIoType() == 57) { |
| | | mast.setWrkSts(4L); |
| | | } else if (mast.getIoType() == 101) { |
| | | } else if (mast.getIoType() == 101 || mast.getIoType() == 110 || mast.getIoType() == 103 || mast.getIoType() == 104 || mast.getIoType() == 107) { |
| | | mast.setWrkSts(14L); |
| | | } |
| | | if (!wrkMastService.updateById(mast)) { |
| | |
| | | |
| | | /** |
| | | * 獲取庫位信息 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | |
| | | public R getStations(Map<String, String> params) { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 条码站入库申请 |
| | | * |
| | | * @param combParam |
| | | * @param l |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R combInPub(CompleteParam combParam, long l) { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * WCS申请任务重新分配入库 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R repeatLoc(CompleteParam params) { |
| | | if (Objects.isNull(params.getTaskNo())) { |
| | | return R.error("工作号不能为空!!"); |
| | | } |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", params.getTaskNo())); |
| | | if (Objects.isNull(wrkMast)) { |
| | | return R.error("任务档不存在,或已加入历史档"); |
| | | } |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | if (Objects.isNull(locMast)) { |
| | | return R.error("库位信息不存在!!"); |
| | | } |
| | | |
| | | Integer whsType = Utils.GetWhsType(Integer.parseInt(wrkMast.getSourceStaNo())); |
| | | if (whsType.equals(1)) { |
| | | RowLastno lastno = rowLastnoService.selectById(whsType); |
| | | if (Objects.isNull(lastno)) { |
| | | return R.error("堆垛要策略不存在!!"); |
| | | } |
| | | if (locMast.getRow1().equals(141)) { |
| | | LocMast selectOne = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .ne("row1", 141) |
| | | .ge("crn_no", lastno.getsCrnNo()) |
| | | .le("crn_no", lastno.geteCrnNo()) |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | | .orderAsc(Arrays.asList("row1", "bay1", "lev1"))); |
| | | if (!Objects.isNull(selectOne)) { |
| | | Map<String, Object> response = new HashMap<>(); |
| | | response.put("locNo", selectOne.getLocNo()); |
| | | |
| | | //原库位置空 |
| | | locMast.setLocSts(LocStsType.LOC_STS_TYPE_O.type); |
| | | locMastService.updateById(locMast); |
| | | |
| | | //新库位预约入库 |
| | | selectOne.setLocSts(LocStsType.LOC_STS_TYPE_S.type); |
| | | locMastService.updateById(selectOne); |
| | | |
| | | wrkMast.setLocNo(selectOne.getLocNo()); |
| | | wrkMastService.updateById(wrkMast); |
| | | |
| | | return R.ok().add(response); |
| | | } else { |
| | | return R.error("暂无可用库位!!"); |
| | | } |
| | | } else { |
| | | LocMast selectOne = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("crn_no", wrkMast.getCrnNo()) |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | | .orderAsc(Arrays.asList("row1", "bay1", "lev1"))); |
| | | if (!Objects.isNull(selectOne)) { |
| | | Map<String, Object> response = new HashMap<>(); |
| | | response.put("locNo", selectOne.getLocNo()); |
| | | |
| | | //原库位置空 |
| | | locMast.setLocSts(LocStsType.LOC_STS_TYPE_O.type); |
| | | locMastService.updateById(locMast); |
| | | |
| | | //新库位预约入库 |
| | | selectOne.setLocSts(LocStsType.LOC_STS_TYPE_S.type); |
| | | locMastService.updateById(selectOne); |
| | | |
| | | wrkMast.setLocNo(selectOne.getLocNo()); |
| | | wrkMastService.updateById(wrkMast); |
| | | |
| | | return R.ok().add(response); |
| | | } else { |
| | | return R.error("暂无可用库位!!"); |
| | | } |
| | | } |
| | | } else { |
| | | LocMast selectOne = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("crn_no", wrkMast.getCrnNo()) |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | | .orderAsc(Arrays.asList("row1", "bay1", "lev1"))); |
| | | if (!Objects.isNull(selectOne)) { |
| | | Map<String, Object> response = new HashMap<>(); |
| | | response.put("locNo", selectOne.getLocNo()); |
| | | |
| | | //原库位置空 |
| | | locMast.setLocSts(LocStsType.LOC_STS_TYPE_O.type); |
| | | locMastService.updateById(locMast); |
| | | |
| | | //新库位预约入库 |
| | | selectOne.setLocSts(LocStsType.LOC_STS_TYPE_S.type); |
| | | locMastService.updateById(selectOne); |
| | | |
| | | wrkMast.setLocNo(selectOne.getLocNo()); |
| | | wrkMastService.updateById(wrkMast); |
| | | |
| | | return R.ok().add(response); |
| | | } else { |
| | | return R.error("暂无可用库位!!"); |
| | | } |
| | | } |
| | | } |
| | | } |