| | |
| | | package com.zy.asrs.task.handler; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.asrs.entity.Order; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.service.OrderDetlLogService; |
| | | import com.zy.asrs.service.OrderDetlService; |
| | | import com.zy.asrs.service.OrderLogService; |
| | | import com.zy.asrs.service.OrderService; |
| | | import com.zy.asrs.task.AbstractHandler; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class OrderLogHandler extends AbstractHandler<String> { |
| | | // @Autowired |
| | | // private OrderService orderService; |
| | | // @Autowired |
| | | // private OrderDetlService orderDetlService; |
| | | // @Autowired |
| | | // private OrderLogService orderLogService; |
| | | // @Autowired |
| | | // private OrderDetlLogService orderDetlLogService; |
| | | // |
| | | // @Transactional |
| | | // public ReturnT<String> start(Order order) { |
| | | // try { |
| | | // // 保存单据主档历史档 |
| | | // if (!orderLogService.save(order.getOrderNo())) { |
| | | // exceptionHandle("保存单据历史档[orderNo={0}]失败", order.getOrderNo()); |
| | | // } |
| | | // // 删除单据主档 |
| | | // if (!orderService.deleteById(order)) { |
| | | // exceptionHandle("删除单据主档[orderNo={0}]失败", order.getOrderNo()); |
| | | // } |
| | | // // 保存单据明细档历史档 |
| | | // if (!orderDetlLogService.save(order.getOrderNo())) { |
| | | // exceptionHandle("保存单据明细历史档[orderNo={0}]失败", order.getOrderNo()); |
| | | // } |
| | | // // 删除工作明细档 |
| | | // if (!orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_no", order.getOrderNo()))) { |
| | | // exceptionHandle("删除单据明细档[orderNo={0}]失败", order.getOrderNo()); |
| | | // } |
| | | // |
| | | // } catch (Exception e) { |
| | | // log.error("fail", e); |
| | | // e.printStackTrace(); |
| | | // TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | // return FAIL.setMsg(e.getMessage()); |
| | | // } |
| | | // return SUCCESS; |
| | | // } |
| | | @Autowired |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private OrderLogService orderLogService; |
| | | @Autowired |
| | | private OrderDetlLogService orderDetlLogService; |
| | | |
| | | @Transactional |
| | | public ReturnT<String> start(Order order) { |
| | | try { |
| | | // 保存单据主档历史档 |
| | | if (!orderLogService.save(order.getOrderNo())) { |
| | | exceptionHandle("保存单据历史档[orderNo={0}]失败", order.getOrderNo()); |
| | | } |
| | | // 删除单据主档 |
| | | if (!orderService.deleteById(order)) { |
| | | exceptionHandle("删除单据主档[orderNo={0}]失败", order.getOrderNo()); |
| | | } |
| | | // 保存单据明细档历史档 |
| | | if (!orderDetlLogService.save(order.getOrderNo())) { |
| | | exceptionHandle("保存单据明细历史档[orderNo={0}]失败", order.getOrderNo()); |
| | | } |
| | | // 删除工作明细档 |
| | | if (!orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_no", order.getOrderNo()))) { |
| | | exceptionHandle("删除单据明细档[orderNo={0}]失败", order.getOrderNo()); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | log.error("fail", e); |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return FAIL.setMsg(e.getMessage()); |
| | | } |
| | | return SUCCESS; |
| | | } |
| | | |
| | | } |
| | | |