自动化立体仓库 - WMS系统
zwl
6 天以前 b6681bc12173c1179d0185805ba461211472ac18
src/main/java/com/zy/asrs/task/OrderSyncScheduler.java
@@ -4,6 +4,8 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.common.R;
import com.zy.asrs.controller.OutController;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.mes.*;
import com.zy.asrs.service.*;
@@ -12,6 +14,7 @@
import com.zy.asrs.task.handler.OrderSyncHandler;
import com.zy.asrs.utils.OrderInAndOutUtil;
import com.zy.common.entity.Parameter;
import com.zy.common.model.LocDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -20,8 +23,7 @@
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -56,6 +58,18 @@
    @Value("${erp.switch.ErpReportOld}")
    private boolean ErpReportOld;
    @Autowired
    private LocDetlService locDetlService;
    @Autowired
    private LocMastService locMastService;
    @Autowired
    private StaDescService staDescService;
    @Autowired
    private OutController  outController;
    @Scheduled(cron = "0 0 1 * * ? ")
    public void clearApiLog() {
        try {
@@ -65,7 +79,7 @@
        }
    }
//    @Scheduled(cron = "0 1 * * * ? ")
    //    @Scheduled(cron = "0 1 * * * ? ")
    @Async("orderThreadPool")
    public void completeAndReportOrderIssuedOnceMore() {
        List<Order> orderList = orderService.selectComplete99();
@@ -82,44 +96,44 @@
        }
    }
//    @Scheduled(cron = "0/30 * * * * ? ")
    //    @Scheduled(cron = "0/30 * * * * ? ")
    @Async("orderThreadPool")
    public void completeAndReportOrderIssued() {
//        String erpReport = Parameter.get().getErpReport();
//        if (!Cools.isEmpty(erpReport) && erpReport.equals("true")) {
            List<Order> orderList = orderService.selectComplete1();
        List<Order> orderList = orderService.selectComplete1();
//            List<Order> orderList = orderService.selectList(new EntityWrapper<Order>().eq("settle", 1L).eq("status", 1).orderBy("create_time", true));
            for (Order order : orderList) {
                try {
                    ReturnT<String> result = orderSyncHandler.startOrderIssued(order);
                    if (!result.isSuccess()) {
                        log.error("单据[orderNo={}]转执行表失败", order.getOrderNo());
                    }
                } catch (Exception e){
                    log.error(e.getMessage());
        for (Order order : orderList) {
            try {
                ReturnT<String> result = orderSyncHandler.startOrderIssued(order);
                if (!result.isSuccess()) {
                    log.error("单据[orderNo={}]转执行表失败", order.getOrderNo());
                }
            } catch (Exception e){
                log.error(e.getMessage());
                log.error("单据[orderNo={}]转执行表失败", order.getOrderNo());
            }
        }
//        }
    }
//    @Scheduled(cron = "0/5 * * * * ? ")
    //    @Scheduled(cron = "0/5 * * * * ? ")
    @Async("orderThreadPool")
    public void completeAndReportOrderInAndOutUtil() {
//        String erpReport = Parameter.get().getErpReport();
//        if (!Cools.isEmpty(erpReport) && erpReport.equals("true")) {
            List<Order> orders = OrderInAndOutUtil.selectComplete(null);
            for (Order order : orders) {
                try {
                    ReturnT<String> result = orderSyncHandler.startOrderInAndOutUtil(order);
                    if (!result.isSuccess()) {
                        log.error("单据[orderNo={}]转上报表失败", order.getOrderNo());
                    }
                } catch (Exception e){
                    log.error(e.getMessage());
        List<Order> orders = OrderInAndOutUtil.selectComplete(null);
        for (Order order : orders) {
            try {
                ReturnT<String> result = orderSyncHandler.startOrderInAndOutUtil(order);
                if (!result.isSuccess()) {
                    log.error("单据[orderNo={}]转上报表失败", order.getOrderNo());
                }
            } catch (Exception e){
                log.error(e.getMessage());
                log.error("单据[orderNo={}]转上报表失败", order.getOrderNo());
            }
        }
//        }
    }
@@ -179,7 +193,7 @@
    void otherInOrderCompleteReport() {
        String erpReport = Parameter.get().getErpReport();
        if (!Cools.isEmpty(erpReport) && erpReport.equals("true")) {
            OrderPakin orderPakin = orderPakinService.selectOne(new EntityWrapper<OrderPakin>().eq("settle", 4)
            OrderPakin orderPakin = orderPakinService.selectOne(new EntityWrapper<OrderPakin>().ne("doc_type",1).eq("settle", 4)
                    .ne("doc_type", 1).orderBy("update_time"));
            if (orderPakin == null) {
                return;
@@ -228,7 +242,7 @@
                    }
                }
                String url = MES_URL + "loadComplete";
                String url = MES_URL + "issueCompleteFit";
                String response = RcsServiceImpl.sendPost(url, JSONObject.toJSONString(result));
                if (!StringUtils.isEmpty(response) && response.contains("Success")) {
                    MesReturn mesReturn = JSONObject.parseObject(response, MesReturn.class);
@@ -242,7 +256,76 @@
        }
    }
//    @Scheduled(cron = "0/30 * * * * ? ")
    // 出库单上报
    @Scheduled(cron = "0/30 * * * * ? ")
    @Async("orderThreadPool")
    void AutoOutOrderPinOut() throws InterruptedException {
        String erpReport = Parameter.get().getErpReport();
        if (!Cools.isEmpty(erpReport) && erpReport.equals("true")) {
            List<OrderPakout> orderPakouts = orderPakoutService.selectList(new EntityWrapper<OrderPakout>()
                    .eq("settle", 1)
                    .eq("doc_type", 12)
                    .orderBy("update_time"));
            if (orderPakouts.isEmpty()) {
                return;
            }
            for (OrderPakout orderPakout : orderPakouts) {
                List<LocDto> locDtos = new ArrayList<>();
                Boolean boo = false;
                Set<String> exist = new HashSet<>();
                List<OrderDetlPakout> orderDetlPakouts = orderDetlPakoutService.selectList(new EntityWrapper<OrderDetlPakout>().eq("order_no", orderPakout.getOrderNo()));
                for (OrderDetlPakout orderDetl : orderDetlPakouts) {
                    double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getWorkQty()).orElse(0.0D);
                    if (issued <= 0.0D) {
                        continue;
                    }
                    List<LocDetl> locDetls = locDetlService.queryStockAll(null, exist, orderDetl.getMatnr(), orderDetl.getBatch(),
                            orderDetl.getBrand(), orderPakout.getDocType() == 11 ? null : orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3());
                    for (LocDetl locDetl : locDetls) {
                        if (issued > 0) {
                            LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(),
                                    issued >= locDetl.getAnfme() ? locDetl.getAnfme() : issued);
                            LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo()));
                            locDto.setFrozen(locDetl.getFrozen());
                            locDto.setFrozenLoc(locMast.getFrozen());
                            List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), issued >= locDetl.getAnfme() ? 101 : 103);
                            locDto.setStaNos(staNos);
                            locDto.setBrand(orderDetl.getBrand());
                            locDto.setStandby1(orderDetl.getStandby1());
                            locDto.setStandby2(orderDetl.getStandby2());
                            locDto.setStandby3(orderDetl.getStandby3());
                            locDto.setBoxType1(orderDetl.getBoxType1());
                            locDto.setBoxType2(orderDetl.getBoxType2());
                            locDto.setBoxType3(orderDetl.getBoxType3());
                            locDtos.add(locDto);
                            exist.add(locDetl.getLocNo());
                            // 剩余待出数量递减
                            issued = issued - locDetl.getAnfme();
                        } else {
                            break;
                        }
                    }
                    if (issued > 0) {
                        boo = true;
                        continue;
                    }
                }
                if (boo){
                    continue;
                }
                R pakout = outController.pakout(locDtos);
                break;
            }
        }
    }
    //    @Scheduled(cron = "0/30 * * * * ? ")
    @Async("orderThreadPool")
    public void completeAndReportOrderReport() {