| | |
| | | |
| | | 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.entity.*; |
| | | 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.Date; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | |
| | | @Autowired |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private DocTypeService docTypeService; |
| | | @Autowired |
| | | private AutoReplenishmentHandler autoReplenishmentHandler; |
| | |
| | | @Autowired |
| | | private AgvLocDetlService agvLocDetlService; |
| | | @Autowired |
| | | private AgvLocMastService agvLocMastService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | |
| | | /* |
| | | 定时便利库存,生成自动补货单据 |
| | | 定时遍历库存,生成自动补货单据 |
| | | */ |
| | | @Scheduled(cron = "0 */1 * * * ? ") |
| | | public void createOrder(){ |
| | | System.out.println(new Date()); |
| | | |
| | | 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().eq("settle",1)); |
| | | if(count > 0){ |
| | | if(count > 2){ |
| | | return; |
| | | } |
| | | |
| | | //判断CTU库是否有足够的空库位,空库位数需要大于100 |
| | | int i = agvLocMastService.selectCount(new EntityWrapper<AgvLocMast>().eq("loc_sts", "O")); |
| | | if(i < 100){ |
| | | return; |
| | | } |
| | | |
| | |
| | | List<Mat> matList = matService.selectList(new EntityWrapper<Mat>().gt( "store_min", 0)); |
| | | if(!Cools.isEmpty(matList)){ |
| | | for (Mat mat : matList){ |
| | | //检测是否有未完成的补货单据 |
| | | DocType docType1 = docTypeService.selectOne(new EntityWrapper<DocType>().eq("doc_name", "自动补货单")); |
| | | int count1 = orderService.selectCount(new EntityWrapper<Order>() |
| | | .eq("doc_type", docType1.getDocId()) |
| | | .andNew().eq("settle",2) |
| | | .or().eq("settle",1)); |
| | | if(count1 > 2){ |
| | | break; |
| | | } |
| | | |
| | | //判断CTU库是否有足够的空库位,空库位数需要大于100 |
| | | int j = agvLocMastService.selectCount(new EntityWrapper<AgvLocMast>().eq("loc_sts", "O")); |
| | | if(j < 100){ |
| | | return; |
| | | } |
| | | |
| | | //收集当前物料自动补货单明细数量 |
| | | Double orderDetlCount = 0.0; |
| | | List<Order> orders = orderService.selectList(new EntityWrapper<Order>() |
| | | .eq("doc_type", docType1.getDocId()) |
| | | .andNew().eq("settle", 2) |
| | | .or().eq("settle", 1)); |
| | | if(!Cools.isEmpty(orders)){ |
| | | for (Order order : orders){ |
| | | List<OrderDetl> orderDetls = orderDetlService.selectList(new EntityWrapper<OrderDetl>() |
| | | .eq("matnr", mat.getMatnr()) |
| | | .eq("order_no", order.getOrderNo())); |
| | | if(Cools.isEmpty(orderDetls)){ |
| | | continue; |
| | | } |
| | | for (OrderDetl orderDetl : orderDetls){ |
| | | orderDetlCount=orderDetlCount+orderDetl.getQty(); |
| | | } |
| | | } |
| | | } |
| | | //查询当前物料是否在agv库小于库存上限 |
| | | Double anfmeSum = agvLocDetlService.selectSumAnfmeByMatnr(mat.getMatnr()); |
| | | if(Cools.isEmpty(anfmeSum)){ |
| | | anfmeSum = 0.0; |
| | | } |
| | | //当前物料不需要补货 |
| | | if(anfmeSum > mat.getStoreMin()){ |
| | | if(anfmeSum+orderDetlCount > mat.getStoreMin()){ |
| | | continue; |
| | | } |
| | | //查询当前物料四项库是否存在,并且托盘不含有非料箱物料 |