自动化立体仓库 - WMS系统
#
zyx
2024-05-08 4d99b3dd7a4e3aba703740152bd1c2d72a36874e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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;
    }
 
}