| | |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.entity.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.BasCrnp; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.entity.Order; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.task.handler.AutoLocMoveHandler; |
| | | import com.zy.common.model.enums.WorkNoType; |
| | | import com.zy.common.properties.SlaveWmsParameterProperties; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | |
| | | @Slf4j |
| | | @Component |
| | |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private AutoMoveService autoMoveService; |
| | | |
| | | @Resource |
| | | private CommonService commonService; |
| | | |
| | | @Resource |
| | | private LocMastService locMastService; |
| | | |
| | | // 立体库跑库程序,生产勿用 ,一个巷道放一个托盘 |
| | | // @Scheduled(cron = "0/5 * * * * ? ") |
| | | public synchronized void autoMoveLoc() { |
| | | for(int i = 1; i <= 2; i++ ){ |
| | | // 源库位 |
| | | LocMast sourceLocMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_sts", "D").eq("crn_no", i)); |
| | | if(sourceLocMast != null) { |
| | | // 获取一个移动的目标库位 |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("crn_no", i).eq("loc_type3", "0") |
| | | .eq("loc_sts","O").orderBy("lev1").orderBy("bay1").orderBy("row1")); |
| | | |
| | | if (locMast != null) { |
| | | if (!locMast.getLocSts().equals("O") || (!sourceLocMast.getLocSts().equals("F") && !sourceLocMast.getLocSts().equals("D"))){ |
| | | log.error("{}库位状态已改变",sourceLocMast.getLocNo()); |
| | | continue; |
| | | } |
| | | String sourceLoc = sourceLocMast.getLocNo(); // 源库位 |
| | | String locNo = locMast.getLocNo(); // 目标库位 |
| | | |
| | | // 创建移库任务 |
| | | Date now = new Date(); |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.PICK.type); |
| | | // 保存工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(11); // 入出库状态: 11.库格移载 |
| | | wrkMast.setIoPri(10D); |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setSourceLocNo(sourceLoc); // 源库位 |
| | | wrkMast.setLocNo(locNo); // 目标库位 |
| | | wrkMast.setFullPlt("N"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("Y"); // 空板 |
| | | wrkMast.setBarcode(locMast.getBarcode()); // 托盘码 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiTime(now); |
| | | wrkMastService.insert(wrkMast); |
| | | |
| | | // 修改源库位状态 |
| | | if (sourceLocMast.getLocSts().equals("D") || sourceLocMast.getLocSts().equals("F")) { |
| | | sourceLocMast.setLocSts("R"); // R.出库预约 |
| | | sourceLocMast.setModiTime(now); |
| | | sourceLocMast.setLocType3((short)1); |
| | | if (!locMastService.updateById(sourceLocMast)){ |
| | | throw new CoolException("更新源库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("源库位出库失败,状态:"+sourceLocMast.getLocSts$()); |
| | | } |
| | | // 修改目标库位状态 |
| | | if (locMast.getLocSts().equals("O")) { |
| | | locMast.setLocSts("S"); // S.入库预约 |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败,目标库位状态:"+locMast.getLocSts$()); |
| | | } |
| | | log.info("移库任务下发成功,源库位:{},目标库位:{}",sourceLoc,locNo); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //定时出库 经典双伸 |
| | | @Scheduled(cron = "0/3 * * * * ? ") |
| | | // @Scheduled(cron = "0/3 * * * * ? ") |
| | | public void locToLocAutoLocMove(){ |
| | | if (slaveWmsParameterProperties.isAutoLocMoveBoolean()){ |
| | | Config config = configService.selectConfigByCode("AutoLocMove"); |
| | |
| | | } |
| | | |
| | | //定时出库 |
| | | @Scheduled(cron = "0/3 * * * * ? ") |
| | | // @Scheduled(cron = "0/3 * * * * ? ") |
| | | public void locToLoc11(){ |
| | | if (slaveWmsParameterProperties.isAutoLocMoveUnilateralBoolean()){ |
| | | Config config = configService.selectConfigByCode("AutoLocMoveUnilateral"); |
| | |
| | | } |
| | | |
| | | //定时入库 |
| | | @Scheduled(cron = "0/3 * * * * ? ") |
| | | // @Scheduled(cron = "0/3 * * * * ? ") |
| | | public void locToLoc111() { |
| | | if (slaveWmsParameterProperties.isAutoLocMoveUnilateralBoolean()){ |
| | | Config config = configService.selectConfigByCode("AutoLocMoveUnilateral"); |