| | |
| | | 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.*; |
| | |
| | | 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; |
| | |
| | | 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; |
| | | |
| | |
| | | @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 { |
| | |
| | | } |
| | | } |
| | | |
| | | // @Scheduled(cron = "0 1 * * * ? ") |
| | | // @Scheduled(cron = "0 1 * * * ? ") |
| | | @Async("orderThreadPool") |
| | | public void completeAndReportOrderIssuedOnceMore() { |
| | | List<Order> orderList = orderService.selectComplete99(); |
| | |
| | | } |
| | | } |
| | | |
| | | // @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()); |
| | | } |
| | | } |
| | | // } |
| | | } |
| | | |
| | |
| | | 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; |
| | |
| | | } |
| | | } |
| | | |
| | | 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); |
| | |
| | | } |
| | | } |
| | | |
| | | // @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() { |
| | | |