| New file |
| | |
| | | package com.zy.asrs.task.handler; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.entity.StaDesc; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.entity.param.EmptyPlateOutParam; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.asrs.service.StaDescService; |
| | | import com.zy.asrs.service.WorkService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.task.AbstractHandler; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | 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.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class AutoEmptyOutHandler extends AbstractHandler<String> { |
| | | @Autowired |
| | | private ConfigService configService; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | | private WorkService workService; |
| | | @Autowired |
| | | private BasDevpService basDevpService; |
| | | @Autowired |
| | | private StaDescService staDescService; |
| | | @Transactional |
| | | public ReturnT<String> start() { |
| | | try { |
| | | Config config = configService.selectConfigByCode("EmptyMax"); |
| | | Integer max; |
| | | if (Cools.isEmpty(config)) { |
| | | max = 10; |
| | | }else{ |
| | | max = Integer.valueOf(config.getValue()); |
| | | } |
| | | for(Integer crnNo = 1; crnNo < 5; crnNo++){ |
| | | List<WrkMast> wrkMastList = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .eq("crn_no", crnNo) |
| | | .eq("io_type", 110) |
| | | ); |
| | | if(!wrkMastList.isEmpty()){continue;} |
| | | Integer emptyLocCount = locMastService.selectCount(new EntityWrapper<LocMast>() |
| | | .eq("crn_no", crnNo) |
| | | .eq("loc_sts", "O") |
| | | .eq("frozen", 0) |
| | | .eq("deleted", 0) |
| | | .eq("whs_type", 1)); |
| | | if (emptyLocCount == null || emptyLocCount >= max) { |
| | | continue; |
| | | } |
| | | |
| | | List<LocMast> locMastDList = locMastService.selectPage( |
| | | new Page<>(1, 3), //选三个空轴库位 |
| | | new EntityWrapper<LocMast>() |
| | | .eq("crn_no", crnNo) |
| | | .eq("loc_sts", "D") |
| | | .eq("frozen", 0) |
| | | .eq("deleted", 0) |
| | | .eq("whs_type", 1) |
| | | .orderBy("lev1,bay1") |
| | | ).getRecords(); |
| | | if (Cools.isEmpty(locMastDList)) { |
| | | continue; |
| | | } |
| | | |
| | | List<String> locNos = new ArrayList<>(); |
| | | for (LocMast locMast : locMastDList) { |
| | | locNos.add(locMast.getLocNo()); |
| | | } |
| | | EmptyPlateOutParam emptyPlateOutParam = new EmptyPlateOutParam(); |
| | | emptyPlateOutParam.setOutSite(1076); |
| | | emptyPlateOutParam.setLocNos(locNos); |
| | | workService.emptyPlateOut(emptyPlateOutParam, 1L); |
| | | |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | log.error("fail", e); |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return FAIL.setMsg(e.getMessage()); |
| | | } |
| | | return SUCCESS; |
| | | } |
| | | |
| | | |
| | | } |