|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.task; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
|---|
|  |  |  | import com.core.common.Cools; | 
|---|
|  |  |  | import com.zy.asrs.domain.enums.NotifyMsgType; | 
|---|
|  |  |  | import com.zy.asrs.entity.LocMast; | 
|---|
|  |  |  | import com.zy.asrs.entity.WrkMast; | 
|---|
|  |  |  | import com.zy.asrs.service.LocMastService; | 
|---|
|  |  |  | import com.zy.asrs.service.WrkMastLogService; | 
|---|
|  |  |  | import com.zy.asrs.service.WrkMastService; | 
|---|
|  |  |  | import com.zy.asrs.utils.NotifyUtils; | 
|---|
|  |  |  | import com.zy.core.enums.LocStsType; | 
|---|
|  |  |  | import com.zy.core.enums.WrkIoType; | 
|---|
|  |  |  | import com.zy.core.enums.WrkStsType; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | 
|---|
|  |  |  | private WrkMastLogService wrkMastLogService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocMastService locMastService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NotifyUtils notifyUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron = "0/1 * * * * ? ") | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void executeIn(){ | 
|---|
|  |  |  | public void executeIn() { | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_INBOUND.sts)); | 
|---|
|  |  |  | if (wrkMasts.isEmpty()) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | 
|---|
|  |  |  | if (!wrkMastService.deleteById(wrkMast)) { | 
|---|
|  |  |  | log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //上报 | 
|---|
|  |  |  | if (!Cools.isEmpty(wrkMast.getWmsWrkNo())) { | 
|---|
|  |  |  | notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron = "0/1 * * * * ? ") | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void executeOut(){ | 
|---|
|  |  |  | public void executeOut() { | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_OUTBOUND.sts)); | 
|---|
|  |  |  | if (wrkMasts.isEmpty()) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | 
|---|
|  |  |  | if (!wrkMastService.deleteById(wrkMast)) { | 
|---|
|  |  |  | log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //上报 | 
|---|
|  |  |  | if (!Cools.isEmpty(wrkMast.getWmsWrkNo())) { | 
|---|
|  |  |  | notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron = "0/1 * * * * ? ") | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void executeLocMove(){ | 
|---|
|  |  |  | public void executeLocMove() { | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_LOC_MOVE.sts)); | 
|---|
|  |  |  | if (wrkMasts.isEmpty()) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LocMast sourceLocMast= locMastService.queryByLoc(sourceLocNo); | 
|---|
|  |  |  | LocMast sourceLocMast = locMastService.queryByLoc(sourceLocNo); | 
|---|
|  |  |  | if (sourceLocMast == null) { | 
|---|
|  |  |  | log.info("[workNo={}]库位不存在", wrkMast.getWrkNo()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | 
|---|
|  |  |  | if (!wrkMastService.deleteById(wrkMast)) { | 
|---|
|  |  |  | log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //上报 | 
|---|
|  |  |  | if (!Cools.isEmpty(wrkMast.getWmsWrkNo())) { | 
|---|
|  |  |  | notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron = "0/1 * * * * ? ") | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void executeMove(){ | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_MOVE.sts)); | 
|---|
|  |  |  | public void executeMove() { | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | .in("wrk_sts" | 
|---|
|  |  |  | , WrkStsType.COMPLETE_MOVE.sts | 
|---|
|  |  |  | , WrkStsType.COMPLETE_MOVE_TRANSPORT_LIFT.sts | 
|---|
|  |  |  | , WrkStsType.COMPLETE_MOVE_TRANSPORT_LIFT_OUT.sts | 
|---|
|  |  |  | , WrkStsType.MOVE_IN_NO_LIFT_14.sts | 
|---|
|  |  |  | , WrkStsType.MOVE_OUT_NO_LIFT_13.sts | 
|---|
|  |  |  | )); | 
|---|
|  |  |  | if (wrkMasts.isEmpty()) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (WrkMast wrkMast : wrkMasts) { | 
|---|
|  |  |  | WrkMast main = wrkMastService.selectByWorkNo(wrkMast.getMainWrkNo()); | 
|---|
|  |  |  | if (main != null) { | 
|---|
|  |  |  | if (main.getIoType() == WrkIoType.IN.id) { | 
|---|
|  |  |  | main.setWrkSts(WrkStsType.COMPLETE_INBOUND.sts); | 
|---|
|  |  |  | } else if (main.getIoType() == WrkIoType.OUT.id) { | 
|---|
|  |  |  | main.setShuttleNo(wrkMast.getShuttleNo()); | 
|---|
|  |  |  | main.setWrkSts(WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts); | 
|---|
|  |  |  | //那时候托盘在提升机里,则需要锁住 | 
|---|
|  |  |  | if (!(main.getStaNo() == 1013 || main.getStaNo() == 1024)) { | 
|---|
|  |  |  | main.setLiftNo(1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | main.setModiTime(new Date()); | 
|---|
|  |  |  | if (!wrkMastService.updateById(main)) { | 
|---|
|  |  |  | log.info("更新主工作档[workNo={}]失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 保存工作主档历史档 | 
|---|
|  |  |  | if (!wrkMastLogService.save(wrkMast.getWrkNo())) { | 
|---|
|  |  |  | log.info("保存工作历史档[workNo={}]失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron = "0/1 * * * * ? ") | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void executeCharge(){ | 
|---|
|  |  |  | public void executeCharge() { | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_CHARGE.sts)); | 
|---|
|  |  |  | if (wrkMasts.isEmpty()) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | 
|---|
|  |  |  | if (!wrkMastService.deleteById(wrkMast)) { | 
|---|
|  |  |  | log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //上报 | 
|---|
|  |  |  | if (!Cools.isEmpty(wrkMast.getWmsWrkNo())) { | 
|---|
|  |  |  | notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_CHARGE_COMPLETE, JSON.toJSONString(wrkMast)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron = "0/1 * * * * ? ") | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void executeCancelTask() { | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("mk", "taskCancel")); | 
|---|
|  |  |  | if (wrkMasts.isEmpty()) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (WrkMast wrkMast : wrkMasts) { | 
|---|
|  |  |  | // 保存工作主档历史档 | 
|---|
|  |  |  | if (!wrkMastLogService.save(wrkMast.getWrkNo())) { | 
|---|
|  |  |  | log.info("保存工作历史档[workNo={}]失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 删除工作主档 | 
|---|
|  |  |  | if (!wrkMastService.deleteById(wrkMast)) { | 
|---|
|  |  |  | log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (wrkMast.getIoType() == WrkIoType.IN.id) { | 
|---|
|  |  |  | LocMast locMast = locMastService.queryByLoc(wrkMast.getLocNo()); | 
|---|
|  |  |  | locMast.setLocSts(String.valueOf(LocStsType.O)); | 
|---|
|  |  |  | locMast.setModiTime(new Date()); | 
|---|
|  |  |  | locMastService.updateById(locMast); | 
|---|
|  |  |  | } else if (wrkMast.getIoType() == WrkIoType.OUT.id) { | 
|---|
|  |  |  | LocMast locMast = locMastService.queryByLoc(wrkMast.getSourceLocNo()); | 
|---|
|  |  |  | locMast.setLocSts(String.valueOf(LocStsType.F)); | 
|---|
|  |  |  | locMast.setModiTime(new Date()); | 
|---|
|  |  |  | locMastService.updateById(locMast); | 
|---|
|  |  |  | } else if (wrkMast.getIoType() == WrkIoType.LOC_MOVE.id) { | 
|---|
|  |  |  | LocMast sourceLocMast = locMastService.queryByLoc(wrkMast.getSourceLocNo()); | 
|---|
|  |  |  | LocMast locMast = locMastService.queryByLoc(wrkMast.getLocNo()); | 
|---|
|  |  |  | if (sourceLocMast.getLocSts().equals(String.valueOf(LocStsType.R))) { | 
|---|
|  |  |  | sourceLocMast.setLocSts(String.valueOf(LocStsType.F)); | 
|---|
|  |  |  | sourceLocMast.setModiTime(new Date()); | 
|---|
|  |  |  | locMastService.updateById(sourceLocMast); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (locMast.getLocSts().equals(String.valueOf(LocStsType.S))) { | 
|---|
|  |  |  | locMast.setLocSts(String.valueOf(LocStsType.O)); | 
|---|
|  |  |  | locMast.setModiTime(new Date()); | 
|---|
|  |  |  | locMastService.updateById(locMast); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //上报 | 
|---|
|  |  |  | if (!Cools.isEmpty(wrkMast.getWmsWrkNo())) { | 
|---|
|  |  |  | notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_CANCEL, JSON.toJSONString(wrkMast)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|