自动化立体仓库 - WMS系统
dubin
16 小时以前 23ba6b079e80ae6e5fbd909df6544c1d992df561
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
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.service.InOutService;
import com.zy.asrs.service.LocDetlService;
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;
 
    @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() + "条商品信息成功");
    }
}