自动化立体仓库 - WMS系统
#
zhou zhou
2025-12-26 221fc4d27eee086473de9d5b6d7150843e1c6e6d
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
84
85
86
87
88
package com.zy.asrs.task;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.zy.asrs.entity.InOut;
import com.zy.asrs.entity.LocDetl;
import com.zy.asrs.entity.Mat;
import com.zy.asrs.entity.MatBarcode;
import com.zy.asrs.service.InOutService;
import com.zy.asrs.service.LocDetlService;
import com.zy.asrs.service.MatBarcodeService;
import com.zy.asrs.service.MatService;
import lombok.extern.slf4j.Slf4j;
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 java.util.List;
 
@Component
@Slf4j
@Transactional
public class InOutSyncScheduler {
    @Autowired
    private LocDetlService locDetlService;
    @Autowired
    private InOutService inOutService;
    @Autowired
    private MatService matService;
    @Autowired
    private MatBarcodeService matBarcodeService;
 
//    @Scheduled(cron = "0/30 * * * * ? ")
    private void syncInOut(){
//        List<LocDetl> locDetlList = locDetlService.selectList(new EntityWrapper<LocDetl>().ne("length",1).last("top 100"));
        List<LocDetl> locDetlList = locDetlService.select100();
        if (locDetlList.size() == 0){
            log.info("商品信息更新完毕");
            return;
        }
        for (LocDetl locDetl : locDetlList) {
            InOut inOut = inOutService.selectByMatnr(locDetl.getMatnr());
            Mat mat = matService.selectByMatnr(locDetl.getMatnr());
 
            inOut.setBrand(locDetl.getZpallet());//托盘条码
            inOut.setTemp3(locDetl.getLocNo());//库位号
            inOut.setTemp1("在库");//是否在库
            inOut.setTemp2(mat.getName());//套号
 
            locDetl.setLength(1.0);//标记
 
 
            if (!inOutService.update(inOut, new EntityWrapper<InOut>().eq("matnr",inOut.getMatnr()))){
                log.error("更新商品信息失败");
            }
            if (!locDetlService.update(locDetl,new EntityWrapper<LocDetl>().eq("matnr",locDetl.getMatnr()))){
                log.error("更新库存标记失败");
            }
 
        }
        log.info("更新" + locDetlList.size() + "条商品信息成功");
    }
 
 
//    @Scheduled(cron = "0/30 * * * * ? ")
    private void syncBarcodeMat(){
        List<MatBarcode> matBarcodeList = matBarcodeService.select100();
        if (matBarcodeList.size() == 0){
            log.info("托盘物料绑定关系更新完毕");
            return;
        }
        for (MatBarcode matBarcode : matBarcodeList) {
            String matnr = matBarcode.getMatnr();
            String[] split = matnr.split("__");
            if (split.length > 1){
                matBarcode.setModel(split[1]); // 套号
                matBarcode.setColor("1"); // 标记
                if (!matBarcodeService.update(matBarcode,new EntityWrapper<MatBarcode>().eq("matnr",matBarcode.getMatnr()))){
                    log.error("更新托盘物料绑定关系失败");
                }
            }else {
                continue;
            }
        }
        log.info("更新" + matBarcodeList.size() + "条托盘物料绑定关系成功");
    }
}