自动化立体仓库 - WMS系统
ZY
2024-07-19 7125be069f3f926afe3e15366e9211646de1c637
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
59
60
61
62
63
package com.zy.third.erp.task;
 
import com.zy.common.service.erp.ErpSqlServer;
import com.zy.third.erp.entity.InCancelTB;
import com.zy.third.erp.entity.OutCancelTB;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.HashMap;
import java.util.List;
 
@Slf4j
@Component
public class ERPOutCancelScheduler {
 
    @Value("${erp.enabled}")
    private Boolean erpEnabled;
 
    @Autowired
    private ERPInOrOutCancelService inMS;
 
    @Autowired
    private ErpSqlServer erpSqlServer;
 
 
    @Transactional(rollbackFor = Throwable.class)
    @Scheduled(cron = "${erp.refreshtime}")
    public void InCancelScheduler() {
        log.info("InCancelScheduler开始了");
        if (!erpEnabled) return;
        String sqlInCancelTB = "select * from erp_OutCancelTB where LKName='中扬二期'";
        List<OutCancelTB> ins = erpSqlServer.select(sqlInCancelTB, OutCancelTB.class);
        for (OutCancelTB in : ins) {
            System.out.println(in);
            com.zy.third.lk.entity.InCancelTB lkCancel = inMS.tryCancel(in.getBillNo());
            if (lkCancel != null) {
                HashMap<String, String> condition = new HashMap<>();
                condition.put("BillNo", "'" + in.getBillNo() + "'");
                int delete = erpSqlServer.delete(InCancelTB.class, condition);
                if (delete > 0) {
                    log.info("将入库取消通知单删除成功,{}", lkCancel.getBillNo());
                } else {
                    log.error("将入库取消通知单删除失败,{}", lkCancel.getBillNo());
                }
                HashMap<String, Object> content = new HashMap<>();
                content.put("BillNo", "'" + lkCancel.getBillNo() + "'");
                content.put("opFlag", lkCancel.getOpFlag());
                int insert = erpSqlServer.insert(com.zy.third.lk.entity.InCancelTB.class, content);
                if (insert > 0) {
                    log.info("将入库取消通知单写入成功,{}", lkCancel.getBillNo());
                } else {
                    log.error("将入库取消通知单写入失败,{}", lkCancel.getBillNo());
                }
            } else {
                log.error("将入库取消通知单写入失败");
            }
        }
    }
}