|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.task; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
|---|
|  |  |  | 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.core.enums.WrkStsType; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.scheduling.annotation.Scheduled; | 
|---|
|  |  |  | import org.springframework.stereotype.Component; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | private WrkMastService wrkMastService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WrkMastLogService wrkMastLogService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocMastService locMastService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron = "0/1 * * * * ? ") | 
|---|
|  |  |  | private void executeIn(){ | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.SETTLE_INBOUND.sts)); | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void executeIn(){ | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_INBOUND.sts)); | 
|---|
|  |  |  | if (wrkMasts.isEmpty()) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (WrkMast wrkMast : wrkMasts) { | 
|---|
|  |  |  | String locNo = wrkMast.getLocNo(); | 
|---|
|  |  |  | LocMast locMast = locMastService.queryByLoc(locNo); | 
|---|
|  |  |  | if (locMast == null) { | 
|---|
|  |  |  | log.info("[workNo={}]库位不存在", wrkMast.getWrkNo()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!locMast.getLocSts().equals("S")) { | 
|---|
|  |  |  | log.info("[workNo={}]库位状态不处于S", wrkMast.getWrkNo()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | locMast.setLocSts("F"); | 
|---|
|  |  |  | locMast.setModiTime(new Date()); | 
|---|
|  |  |  | boolean result = locMastService.updateById(locMast); | 
|---|
|  |  |  | if (!result) { | 
|---|
|  |  |  | log.info("[workNo={}]库位状态F更新失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 保存工作主档历史档 | 
|---|
|  |  |  | if (!wrkMastLogService.save(wrkMast.getWrkNo())) { | 
|---|
|  |  |  | log.info("保存工作历史档[workNo={}]失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron = "0/1 * * * * ? ") | 
|---|
|  |  |  | private void executeOut(){ | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.SETTLE_OUTBOUND.sts)); | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void executeOut(){ | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_OUTBOUND.sts)); | 
|---|
|  |  |  | if (wrkMasts.isEmpty()) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (WrkMast wrkMast : wrkMasts) { | 
|---|
|  |  |  | String locNo = wrkMast.getSourceLocNo(); | 
|---|
|  |  |  | LocMast locMast = locMastService.queryByLoc(locNo); | 
|---|
|  |  |  | if (locMast == null) { | 
|---|
|  |  |  | log.info("[workNo={}]库位不存在", wrkMast.getWrkNo()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!locMast.getLocSts().equals("R")) { | 
|---|
|  |  |  | log.info("[workNo={}]库位状态不处于R", wrkMast.getWrkNo()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | locMast.setLocSts("O"); | 
|---|
|  |  |  | locMast.setModiTime(new Date()); | 
|---|
|  |  |  | boolean result = locMastService.updateById(locMast); | 
|---|
|  |  |  | if (!result) { | 
|---|
|  |  |  | log.info("[workNo={}]库位状态O更新失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 保存工作主档历史档 | 
|---|
|  |  |  | if (!wrkMastLogService.save(wrkMast.getWrkNo())) { | 
|---|
|  |  |  | log.info("保存工作历史档[workNo={}]失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron = "0/1 * * * * ? ") | 
|---|
|  |  |  | private void executeMove(){ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void executeLocMove(){ | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_LOC_MOVE.sts)); | 
|---|
|  |  |  | if (wrkMasts.isEmpty()) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (WrkMast wrkMast : wrkMasts) { | 
|---|
|  |  |  | String sourceLocNo = wrkMast.getSourceLocNo(); | 
|---|
|  |  |  | String locNo = wrkMast.getLocNo(); | 
|---|
|  |  |  | LocMast locMast = locMastService.queryByLoc(locNo); | 
|---|
|  |  |  | if (locMast == null) { | 
|---|
|  |  |  | log.info("[workNo={}]库位不存在", wrkMast.getWrkNo()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!locMast.getLocSts().equals("S")) { | 
|---|
|  |  |  | log.info("[workNo={}]库位状态不处于S", wrkMast.getWrkNo()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LocMast sourceLocMast= locMastService.queryByLoc(sourceLocNo); | 
|---|
|  |  |  | if (sourceLocMast == null) { | 
|---|
|  |  |  | log.info("[workNo={}]库位不存在", wrkMast.getWrkNo()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!sourceLocMast.getLocSts().equals("R")) { | 
|---|
|  |  |  | log.info("[workNo={}]库位状态不处于R", wrkMast.getWrkNo()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | locMast.setLocSts("F"); | 
|---|
|  |  |  | locMast.setModiTime(new Date()); | 
|---|
|  |  |  | boolean result = locMastService.updateById(locMast); | 
|---|
|  |  |  | if (!result) { | 
|---|
|  |  |  | log.info("[workNo={}]库位状态F更新失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sourceLocMast.setLocSts("O"); | 
|---|
|  |  |  | sourceLocMast.setModiTime(new Date()); | 
|---|
|  |  |  | boolean result2 = locMastService.updateById(sourceLocMast); | 
|---|
|  |  |  | if (!result2) { | 
|---|
|  |  |  | log.info("[workNo={}]库位状态O更新失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 保存工作主档历史档 | 
|---|
|  |  |  | if (!wrkMastLogService.save(wrkMast.getWrkNo())) { | 
|---|
|  |  |  | log.info("保存工作历史档[workNo={}]失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 删除工作主档 | 
|---|
|  |  |  | if (!wrkMastService.deleteById(wrkMast)) { | 
|---|
|  |  |  | log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron = "0/1 * * * * ? ") | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void executeMove(){ | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_MOVE.sts)); | 
|---|
|  |  |  | if (wrkMasts.isEmpty()) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron = "0/1 * * * * ? ") | 
|---|
|  |  |  | private void executeCharge(){ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void executeCharge(){ | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_CHARGE.sts)); | 
|---|
|  |  |  | if (wrkMasts.isEmpty()) { | 
|---|
|  |  |  | return; | 
|---|