| | |
| | | package com.zy.asrs.task; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zy.asrs.entity.BasArmRules; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.entity.param.OrderToLine; |
| | | import com.zy.asrs.service.BasArmRulesService; |
| | | import com.zy.asrs.service.OrderDetlService; |
| | | import com.zy.asrs.service.OrderService; |
| | | import com.zy.asrs.service.impl.OrderDetlServiceImpl; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.task.handler.OrderToLineHandler; |
| | | 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.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | //订单下发至分拣线 |
| | | public class OrderToSortLineScheduler { |
| | | @Autowired |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private BasArmRulesService basArmRulesService; |
| | | @Autowired |
| | | private OrderToLineHandler orderToLineHandler; |
| | | |
| | | // @Scheduled(cron = "0/3 * * * * ? ") |
| | | |
| | | // @Scheduled(cron = "0/3 * * * * ? ") |
| | | private void orderToSortLine() { |
| | | //获取未下发单据 |
| | | List<String> orderNos = orderService.AllStatusSatisfyOrder(0); |
| | | for (String orderNo : orderNos) { |
| | | List<OrderDetl> orderDetls = orderDetlService.selectByOrderNo(orderNo); |
| | | OrderToLine orderToLine = new OrderToLine(); |
| | | orderToLine.setOrderNo(orderNo); |
| | | orderToLine.setCreateTime(System.currentTimeMillis()); |
| | | |
| | | Long bindingTag = System.currentTimeMillis();//混搭标记 |
| | | |
| | | List<OrderToLine.MatList> matLists = new ArrayList<>(); |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | Integer number = basArmRulesService.getNumber(orderDetl.getWeight(),orderDetl.getVolume(),orderDetl.getManLength(),orderDetl.getWidth(),orderDetl.getHeight()); |
| | | Double anfme = orderDetl.getAnfme(); |
| | | Double remainder = anfme % number; //取余 余数混搭 |
| | | if(remainder != 0){ |
| | | // 组装物料信息 |
| | | OrderToLine.MatList matMix = new OrderToLine.MatList( |
| | | orderDetl.getMatnr(), // matnr -> sku |
| | | orderDetl.getSupp(), // supp -> po |
| | | remainder, //余料 |
| | | orderDetl.getBarcode(), //barcode -> upc |
| | | 1, |
| | | orderDetl.getOrigin(), //origin -> supplier 货源 |
| | | bindingTag //余料标记相同 |
| | | ); |
| | | matLists.add(matMix); |
| | | } |
| | | Double ctns = anfme - remainder; |
| | | // 组装物料信息 |
| | | OrderToLine.MatList mat = new OrderToLine.MatList( |
| | | orderDetl.getMatnr(), // matnr -> sku |
| | | orderDetl.getSupp(), // supp -> po |
| | | ctns, //整料 |
| | | orderDetl.getBarcode(), //barcode -> upc |
| | | 1, |
| | | orderDetl.getOrigin(), //origin -> supplier 货源 |
| | | System.currentTimeMillis() |
| | | ); |
| | | matLists.add(mat); |
| | | } |
| | | orderToLine.setMatList(matLists); |
| | | try{ |
| | | ReturnT<String> returnT = orderToLineHandler.start(orderToLine); |
| | | if (!returnT.isSuccess()) { |
| | | log.error("下发单据失败===>"+ JSON.toJSON(orderToLine)); |
| | | } |
| | | } catch (Exception e){ |
| | | log.error("下发单据异常===>"+e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |