| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.entity.DocType; |
| | | import com.zy.asrs.entity.LocDetl; |
| | | import com.zy.asrs.entity.Mat; |
| | | import com.zy.asrs.entity.Order; |
| | | import com.zy.asrs.service.AgvLocDetlService; |
| | | import com.zy.asrs.service.DocTypeService; |
| | | import com.zy.asrs.service.MatService; |
| | | import com.zy.asrs.service.OrderService; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.task.handler.AutoReplenishmentHandler; |
| | | import com.zy.common.entity.Parameter; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | @Slf4j |
| | | @Component |
| | |
| | | private MatService matService; |
| | | @Autowired |
| | | private AgvLocDetlService agvLocDetlService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | |
| | | /* |
| | | 定时便利库存,生成自动补货单据 |
| | | 定时遍历库存,生成自动补货单据 |
| | | */ |
| | | //@Scheduled(cron = "0/5 * * * * ? ") |
| | | // @Scheduled(cron = "0 */1 * * * ? ") |
| | | public void createOrder(){ |
| | | |
| | | if(!"Y".equals(Parameter.get().getAutoReplenishment())){ |
| | | return; |
| | | } |
| | | |
| | | //检测是否有未完成的补货单据 |
| | | DocType docType = docTypeService.selectOne(new EntityWrapper<DocType>().eq("doc_name", "自动补货单")); |
| | | int count = orderService.selectCount(new EntityWrapper<Order>() |
| | | .eq("doc_type", docType.getDocId()) |
| | | .andNew().eq("settle",2) |
| | | .or("settle",1)); |
| | | .or().eq("settle",1)); |
| | | if(count > 0){ |
| | | return; |
| | | } |
| | | |
| | | //查询所有需要补货的物料 |
| | | List<Mat> matList = matService.selectList(new EntityWrapper<Mat>().eq(false, "store_min", 0)); |
| | | List<Mat> matList = matService.selectList(new EntityWrapper<Mat>().gt( "store_min", 0)); |
| | | if(!Cools.isEmpty(matList)){ |
| | | for (Mat mat : matList){ |
| | | //查询当前物料是否在agv库小于库存上限 |
| | | Double anfmeSum = agvLocDetlService.selectSumAnfmeByMatnr(mat.getMatnr()); |
| | | if(anfmeSum < mat.getStoreMin()){ |
| | | if(Cools.isEmpty(anfmeSum)){ |
| | | anfmeSum = 0.0; |
| | | } |
| | | //当前物料不需要补货 |
| | | if(anfmeSum > mat.getStoreMin()){ |
| | | continue; |
| | | } |
| | | //查询当前物料四项库是否存在,并且货架不含有非货架物料 |
| | | if(Cools.isEmpty(locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("matnr", mat.getMatnr())))){ |
| | | continue; |
| | | } |
| | | |
| | | Set<String> locNosSearch = locDetlService.selectLocNos(mat.getMatnr()); |
| | | //是否含有可补货出库的库位 |
| | | boolean flag = false; |
| | | for (String locNo : locNosSearch){ |
| | | //log.info("需要拣料的货位:" + locNo +",需要补货的物料:" + mat.getMatnr()); |
| | | if(Cools.isEmpty(locDetlService.selectByLocWithoutContainer(locNo))){ |
| | | flag = true; |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if(flag){ |
| | | autoReplenishmentHandler.create(mat,mat.getStoreMax() - anfmeSum); |
| | | break; |
| | | } |
| | |
| | | /* |
| | | 定时处理自动补货单据 |
| | | */ |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | //@Scheduled(cron = "0/10 * * * * ? ") |
| | | public void excuteOrder(){ |
| | | DocType docType = docTypeService.selectOne(new EntityWrapper<DocType>().eq("doc_name", "自动补货单")); |
| | | List<Order> orderList = orderService.selectList(new EntityWrapper<Order>() |