| | |
| | | package com.zy.asrs.wms.asrs.timer; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.plugins.IgnoreStrategy; |
| | | import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wms.asrs.entity.*; |
| | | import com.zy.asrs.wms.asrs.entity.enums.OrderSettleType; |
| | | import com.zy.asrs.wms.asrs.service.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OrderTimer { |
| | | |
| | | @Autowired |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private OrderDetlFieldService orderDetlFieldService; |
| | | @Autowired |
| | | private OrderLogService orderLogService; |
| | | @Autowired |
| | | private OrderDetlLogService orderDetlLogService; |
| | | @Autowired |
| | | private OrderDetlFieldLogService orderDetlFieldLogService; |
| | | |
| | | @Scheduled(cron = "0/3 * * * * ? ") |
| | | @Transactional |
| | | public void orderToHistory() { |
| | | InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().tenantLine(true).build()); |
| | | try { |
| | | List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getOrderSettle, OrderSettleType.COMPLETE.val())); |
| | | if (list.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | for (Order order : list) { |
| | | //转历史档 |
| | | OrderLog orderLog = new OrderLog(); |
| | | orderLog.sync(order); |
| | | if (!orderLogService.save(orderLog)) { |
| | | throw new CoolException("订单转历史档失败"); |
| | | } |
| | | |
| | | //订单明细转历史档 |
| | | List<OrderDetl> orderDetls = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>().eq(OrderDetl::getOrderId, order.getId())); |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | OrderDetlLog orderDetlLog = new OrderDetlLog(); |
| | | orderDetlLog.sync(orderDetl); |
| | | if(!orderDetlLogService.save(orderDetlLog)) { |
| | | throw new CoolException("订单明细转历史档失败"); |
| | | } |
| | | |
| | | //明细扩展字段转历史档 |
| | | List<OrderDetlField> orderDetlFields = orderDetlFieldService.list(new LambdaQueryWrapper<OrderDetlField>().eq(OrderDetlField::getDetlId, orderDetl.getId())); |
| | | for (OrderDetlField orderDetlField : orderDetlFields) { |
| | | OrderDetlFieldLog orderDetlFieldLog = new OrderDetlFieldLog(); |
| | | orderDetlFieldLog.sync(orderDetlField); |
| | | if(!orderDetlFieldLogService.save(orderDetlFieldLog)) { |
| | | throw new CoolException("明细扩展字段转历史档失败"); |
| | | } |
| | | |
| | | //删除明细扩展字段 |
| | | if (!orderDetlFieldService.removeById(orderDetlField.getId())) { |
| | | throw new CoolException("删除明细扩展字段失败"); |
| | | } |
| | | } |
| | | |
| | | //删除订单明细 |
| | | if (!orderDetlService.removeById(orderDetl.getId())) { |
| | | throw new CoolException("删除订单明细失败"); |
| | | } |
| | | } |
| | | |
| | | //删除订单 |
| | | if (!orderService.removeById(order.getId())) { |
| | | throw new CoolException("删除订单失败"); |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | }finally { |
| | | InterceptorIgnoreHelper.clearIgnoreStrategy(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | package com.zy.asrs.wms.asrs.timer;
|
| | |
|
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
| | | import com.baomidou.mybatisplus.core.plugins.IgnoreStrategy;
|
| | | import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
|
| | | import com.zy.asrs.framework.exception.CoolException;
|
| | | import com.zy.asrs.wms.asrs.entity.*;
|
| | | import com.zy.asrs.wms.asrs.entity.enums.OrderSettleType;
|
| | | import com.zy.asrs.wms.asrs.service.*;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.scheduling.annotation.Scheduled;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | @Component
|
| | | public class OrderTimer {
|
| | |
|
| | | @Autowired
|
| | | private OrderService orderService;
|
| | | @Autowired
|
| | | private OrderDetlService orderDetlService;
|
| | | @Autowired
|
| | | private OrderDetlFieldService orderDetlFieldService;
|
| | | @Autowired
|
| | | private OrderLogService orderLogService;
|
| | | @Autowired
|
| | | private OrderDetlLogService orderDetlLogService;
|
| | | @Autowired
|
| | | private OrderDetlFieldLogService orderDetlFieldLogService;
|
| | |
|
| | | // @Scheduled(cron = "0/3 * * * * ? ")
|
| | | @Transactional
|
| | | public void orderToHistory() {
|
| | | InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().tenantLine(true).build());
|
| | | try {
|
| | | List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getOrderSettle, OrderSettleType.COMPLETE.val()));
|
| | | if (list.isEmpty()) {
|
| | | return;
|
| | | }
|
| | |
|
| | | for (Order order : list) {
|
| | | //转历史档
|
| | | OrderLog orderLog = new OrderLog();
|
| | | orderLog.sync(order);
|
| | | if (!orderLogService.save(orderLog)) {
|
| | | throw new CoolException("订单转历史档失败");
|
| | | }
|
| | |
|
| | | //订单明细转历史档
|
| | | List<OrderDetl> orderDetls = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>().eq(OrderDetl::getOrderId, order.getId()));
|
| | | for (OrderDetl orderDetl : orderDetls) {
|
| | | OrderDetlLog orderDetlLog = new OrderDetlLog();
|
| | | orderDetlLog.sync(orderDetl);
|
| | | if(!orderDetlLogService.save(orderDetlLog)) {
|
| | | throw new CoolException("订单明细转历史档失败");
|
| | | }
|
| | |
|
| | | //明细扩展字段转历史档
|
| | | List<OrderDetlField> orderDetlFields = orderDetlFieldService.list(new LambdaQueryWrapper<OrderDetlField>().eq(OrderDetlField::getDetlId, orderDetl.getId()));
|
| | | for (OrderDetlField orderDetlField : orderDetlFields) {
|
| | | OrderDetlFieldLog orderDetlFieldLog = new OrderDetlFieldLog();
|
| | | orderDetlFieldLog.sync(orderDetlField);
|
| | | if(!orderDetlFieldLogService.save(orderDetlFieldLog)) {
|
| | | throw new CoolException("明细扩展字段转历史档失败");
|
| | | }
|
| | |
|
| | | //删除明细扩展字段
|
| | | if (!orderDetlFieldService.removeById(orderDetlField.getId())) {
|
| | | throw new CoolException("删除明细扩展字段失败");
|
| | | }
|
| | | }
|
| | |
|
| | | //删除订单明细
|
| | | if (!orderDetlService.removeById(orderDetl.getId())) {
|
| | | throw new CoolException("删除订单明细失败");
|
| | | }
|
| | | }
|
| | |
|
| | | //删除订单
|
| | | if (!orderService.removeById(order.getId())) {
|
| | | throw new CoolException("删除订单失败");
|
| | | }
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
| | | }finally {
|
| | | InterceptorIgnoreHelper.clearIgnoreStrategy();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|