| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.entity.param.ShuttleMoveTask; |
| | | import com.zy.asrs.entity.param.ShuttleOutTask; |
| | | import com.zy.asrs.entity.param.ShuttleTask; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.service.impl.LocMastServiceImpl; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.task.handler.WorkMastHandler; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private String shuttleWcsUrl; |
| | | @Autowired |
| | | private LocMastServiceImpl locMastService; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | |
| | | @Scheduled(cron = "0/3 * * * * ? ") |
| | | private void execute(){ |
| | | private void execute() { |
| | | List<WrkMast> wrkMasts = wrkMastService.selectToBeCompleteData(); |
| | | if (wrkMasts.isEmpty()) { |
| | | return; |
| | |
| | | } |
| | | } |
| | | |
| | | // @Scheduled(cron = "0/3 * * * * ? ") |
| | | private void ShuttleTaskSend(){ |
| | | List<WrkMast> wrkMasts = wrkMastService.selectToShuttleTask(); |
| | | if (wrkMasts.isEmpty()) { |
| | | @Scheduled(cron = "0/3 * * * * ? ") //入库任务下发 |
| | | private void ShuttleInTaskSend() { |
| | | procesMode(); |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .eq("wrk_sts", 2).in("io_type", 1, 10, 53, 54, 57).eq("crn_no", 7)); |
| | | if (Cools.isEmpty(wrkMasts)) { |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | if (wrkMast.getStaNo() == 1031) { |
| | | Config config = configService.selectConfigByCode("2.5F_Mode"); |
| | | if (Cools.isEmpty(config) || config.getValue().equals("false")) { |
| | | return; |
| | | } |
| | | if (config.getValue().equalsIgnoreCase("1")) { |
| | | log.info("模式不对2"); |
| | | return; |
| | | } |
| | | } |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", wrkMast.getLocNo())); |
| | | if (locMast == null) { |
| | | throw new CoolException("下发四向车wcs任务失败"); |
| | | } |
| | | String loc = (locMast.getRow1()-16)+"-"+locMast.getBay1()+"-"+locMast.getLev1(); |
| | | |
| | | String loc; |
| | | if ((locMast.getRow1() - 4) >= 10) { |
| | | loc = (locMast.getRow1() - 4) + locMast.getLocNo().substring(2); |
| | | } else { |
| | | loc = "0" + (locMast.getRow1() - 4) + locMast.getLocNo().substring(2); |
| | | } |
| | | //String loc = (locMast.getRow1() - 4) + "-" + locMast.getBay1() + "-" + locMast.getLev1(); |
| | | ShuttleTask param = new ShuttleTask(); |
| | | param.setTaskNo(wrkMast.getWrkNo().toString()); |
| | | param.setDestLoc(loc); |
| | | param.setOriginSite("31002"); |
| | | param.setLocNo(loc); |
| | | param.setSourceStaNo(wrkMast.getSourceStaNo()); |
| | | param.setStaNo(wrkMast.getStaNo()); |
| | | param.setBarcode(wrkMast.getBarcode()); |
| | | param.setPriority("11"); |
| | | //param.setPriority("11"); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(shuttleWcsUrl) |
| | | .setPath("/openapi/createInTask") |
| | |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | wrkMast.setWrkSts(1L); |
| | | wrkMast.setWrkSts(105L); |
| | | wrkMast.setModiTime(new Date()); |
| | | if (!wrkMastService.updateById(wrkMast)) { |
| | | log.error("工作档[workNo={}]标记待处理失败", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | throw new CoolException("下发四向车wcs任务失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Scheduled(cron = "0/3 * * * * ? ") //出库库任务下发 |
| | | private void ShuttleOutTaskSend() { |
| | | procesMode(); |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .in("io_type", 101, 110, 103, 104, 107) |
| | | .eq("wrk_sts", 11).eq("crn_no", 7)); |
| | | if (Cools.isEmpty(wrkMasts)) { |
| | | return; |
| | | } |
| | | try { |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | if (wrkMast.getStaNo() == 1031) { |
| | | Config config = configService.selectConfigByCode("2.5F_Mode"); |
| | | if (Cools.isEmpty(config) || config.getValue().equals("false")) { |
| | | return; |
| | | } |
| | | if (config.getValue().equalsIgnoreCase("2")) { |
| | | log.info("模式不对2"); |
| | | return; |
| | | } |
| | | } |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", wrkMast.getSourceLocNo())); |
| | | if (locMast == null) { |
| | | throw new CoolException("下发四向车wcs任务失败"); |
| | | } |
| | | String loc; |
| | | if ((locMast.getRow1() - 4) >= 10) { |
| | | loc = (locMast.getRow1() - 4) + locMast.getLocNo().substring(2); |
| | | } else { |
| | | loc = "0" + (locMast.getRow1() - 4) + locMast.getLocNo().substring(2); |
| | | } |
| | | //String loc = (locMast.getRow1() - 4) + "-" + locMast.getBay1() + "-" + locMast.getLev1(); |
| | | ShuttleOutTask param = new ShuttleOutTask(); |
| | | param.setTaskNo(wrkMast.getWrkNo().toString()); |
| | | param.setSourceLocNo(loc); |
| | | param.setStaNo(wrkMast.getStaNo()); |
| | | //param.setPriority("11"); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(shuttleWcsUrl) |
| | | .setPath("/openapi/createOutTask") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | wrkMast.setWrkSts(105L); |
| | | wrkMast.setModiTime(new Date()); |
| | | if (!wrkMastService.updateById(wrkMast)) { |
| | | log.error("工作档[workNo={}]标记待处理失败", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | throw new CoolException("下发四向车wcs任务失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | | // @Scheduled(cron = "0/3 * * * * ? ") //移库任务下发 |
| | | private void ShuttleMoveTaskSend() { |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 11).eq("io_type", 11)); |
| | | if (wrkMasts.isEmpty()) { |
| | | return; |
| | | } |
| | | try { |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | LocMast destLoc = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", wrkMast.getLocNo())); |
| | | LocMast originLoc = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", wrkMast.getSourceLocNo())); |
| | | if (originLoc == null || destLoc == null) { |
| | | throw new CoolException("下发四向车wcs任务失败"); |
| | | } |
| | | String originLoc1 = (originLoc.getRow1() - 16) + "-" + originLoc.getBay1() + "-" + originLoc.getLev1(); |
| | | String destLoc1 = (destLoc.getRow1() - 16) + "-" + destLoc.getBay1() + "-" + destLoc.getLev1(); |
| | | ShuttleMoveTask param = new ShuttleMoveTask(); |
| | | param.setTaskNo(wrkMast.getWrkNo().toString()); |
| | | param.setOriginLoc(originLoc1); |
| | | param.setDestLoc(destLoc1); |
| | | param.setRecord(true); |
| | | param.setPriority("11"); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(shuttleWcsUrl) |
| | | .setPath("/openapi/createLadenMoveTakeTask") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | wrkMast.setWrkSts(105L); |
| | | if (!wrkMastService.updateById(wrkMast)) { |
| | | log.error("工作档[workNo={}]标记待处理失败", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | throw new CoolException("下发四向车wcs任务失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | | //@Scheduled(cron = "0/3 * * * * ? ") //移库任务下发 |
| | | public void switchMode() { |
| | | procesMode(); |
| | | } |
| | | |
| | | //1:从四向库到堆垛机库 |
| | | //2:从堆垛机库到四向库 |
| | | private void procesMode() { |
| | | Config config = configService.selectConfigByCode("2.5F_Mode"); |
| | | if (Cools.isEmpty(config) || config.getValue().equals("false")) { |
| | | return; |
| | | } |
| | | List<WrkMast> wrkMastList1 = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .in("io_type", 1, 10).eq("crn_no", 1).eq("sta_no", 1131)); |
| | | List<WrkMast> wrkMastList2 = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .in("io_type", 101, 110).eq("crn_no", 7).eq("sta_no", 1031)); |
| | | if (wrkMastList1.isEmpty() && wrkMastList2.isEmpty()) { |
| | | List<WrkMast> wrkMastList3 = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .in("io_type", 101, 110).eq("crn_no", 1).eq("sta_no", 1135)); |
| | | List<WrkMast> wrkMastList4 = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .in("io_type", 1, 10).eq("crn_no", 7).eq("sta_no", 1032)); |
| | | if (!wrkMastList3.isEmpty() || !wrkMastList4.isEmpty()) { |
| | | if (!config.getValue().equalsIgnoreCase("2")) { |
| | | log.info("存在调拨任务去四向库,切换模式"); |
| | | config.setValue("2"); |
| | | configService.updateById(config); |
| | | } |
| | | } else { |
| | | if (!config.getValue().equalsIgnoreCase("0")) { |
| | | log.info("不存在任务"); |
| | | config.setValue("0"); |
| | | configService.updateById(config); |
| | | } |
| | | } |
| | | } else { |
| | | List<WrkMast> wrkMastList3 = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .in("io_type", 101, 110).eq("crn_no", 1).eq("sta_no", 1135)); |
| | | List<WrkMast> wrkMastList4 = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .in("io_type", 1, 10).eq("crn_no", 7).eq("sta_no", 1032)); |
| | | if (wrkMastList3.isEmpty() && wrkMastList4.isEmpty()) { |
| | | if (!config.getValue().equalsIgnoreCase("1")) { |
| | | log.info("存在调拨任务去duiduo,切换模式"); |
| | | config.setValue("1"); |
| | | configService.updateById(config); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |