#
luxiaotao1123
2021-09-06 046476cb412140e8fc589845d5079cd784a64ba0
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package zy.cloud.wms.common.service.task;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import zy.cloud.wms.manager.entity.DocLog;
import zy.cloud.wms.manager.service.DocLogService;
import zy.cloud.wms.manager.service.MatService;
 
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
/**
 * Created by vincent on 2021/9/3
 */
@Slf4j
@Component
public class DetectionScheduler {
 
    @Autowired
    private MatService matService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private DocLogService docLogService;
 
    /**
     * 订单转历史档处理器
     */
    @Scheduled(cron = "0/10 * * * * ? ")
    public void orderBeLogExecute(){
        List<String> matnrList = jdbcTemplate.queryForList("select distinct matnr from man_mat", String.class);
        for (String matnr : matnrList) {
            // 查找立库库存
            double asrsAnfme = jdbcTemplate.queryForObject("select isnull(sum(anfme), 0) from asr_loc_detl where matnr ='" + matnr + "'", Double.class);
            // 查找平仓库存
            double wmsAnfme = jdbcTemplate.queryForObject("select isnull(sum(anfme), 0) from man_loc_detl where matnr ='" + matnr + "'", Double.class);
            double total = asrsAnfme + wmsAnfme;
            // 单据库存
            List<DocLog> docLogs = docLogService.selectList(new EntityWrapper<DocLog>().eq("matnr", matnr));
 
            double stock = 0.0D;
            Set<String> set = new HashSet<>();
            for (DocLog docLog : docLogs) {
                // 防止重复单据
                if (set.contains(docLog.getDocNum())) {
                    break;
                }
                set.add(docLog.getDocNum());
                int docId = Math.toIntExact(docLog.getDocId());
                // 计算库存
                switch (docId) {
                    case 6:
 
                        break;
                    case 9:
                        break;
                    case 11:
                        break;
                    case 14:
                        break;
                    case 34:
                        break;
                    default:
                        break;
                }
            }
            // 比较差异值
            if (stock != total) {
                // todo
            }
 
 
        }
 
    }
 
}