zhang
2025-05-20 1313906bb1eb983d3beece810035e7fc28d6a92f
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package com.zy.acs.manager.manager.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zy.acs.manager.manager.entity.Loc;
import com.zy.acs.manager.manager.entity.Sta;
import com.zy.acs.manager.manager.entity.Task;
import com.zy.acs.manager.manager.enums.LocStsType;
import com.zy.acs.manager.manager.enums.StaStsType;
import com.zy.acs.manager.manager.enums.TaskStsType;
import com.zy.acs.manager.manager.enums.TaskTypeType;
import com.zy.acs.manager.manager.mapper.LocMapper;
import com.zy.acs.manager.manager.service.LocService;
import com.zy.acs.manager.manager.service.StaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
 
@Slf4j
@Service("locService")
public class LocServiceImpl extends ServiceImpl<LocMapper, Loc> implements LocService {
 
    @Autowired
    private StaService staService;
 
    @Override
    public Loc selecatByLocNo(String locNo) {
        return this.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, locNo));
    }
 
    @Override
    public List<Map<String, Object>> selectCountGroupByLocSts() {
        return this.baseMapper.selectCountGroupByLocSts();
    }
 
    @Override
    public List<Map<String, Object>> selectDigitalLocWhichNeedShow() {
        return this.baseMapper.selectDigitalLocWhichNeedShow();
    }
 
    @Override
    public void taskCallBack(Task task) {
        if (null == task) {
            return;
        }
        if (!task.getTaskSts().equals(TaskStsType.PROGRESS.val())) {
            return;
        }
        Date now = new Date();
        // loc status
        Loc oriLoc = null;
        Loc destLoc = null;
        Sta oriSta = null;
        Sta destSta = null;
        switch (Objects.requireNonNull(TaskTypeType.get(task.getTaskTypeEl()))) {
            case LOC_TO_LOC:
                oriLoc = this.getById(task.getOriLoc());
                if (oriLoc.getLocSts().equals(LocStsType.PAKOUT.val())) {
                    oriLoc.setLocSts(LocStsType.IDLE.val());
                    oriLoc.setUpdateTime(now);
                    if (!this.updateById(oriLoc)) {
                        log.error("Loc [{}] 库位修改状态失败", task.getOriLoc$());
                    }
                }
 
                destLoc = this.getById(task.getDestLoc());
                if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) {
                    destLoc.setLocSts(LocStsType.STOCK.val());
                    destLoc.setUpdateTime(now);
                    if (!this.updateById(destLoc)) {
                        log.error("Loc [{}] 库位修改状态失败", task.getDestLoc$());
                    }
                }
                break;
            case LOC_TO_STA:
                oriLoc = this.getById(task.getOriLoc());
                if (oriLoc.getLocSts().equals(LocStsType.PAKOUT.val())) {
                    oriLoc.setLocSts(LocStsType.IDLE.val());
                    oriLoc.setUpdateTime(now);
                    if (!this.updateById(oriLoc)) {
                        log.error("Loc [{}] 库位修改状态失败", task.getOriLoc$());
                    }
                }
 
                destSta = staService.getById(task.getDestSta());
                if (destSta.getStaSts().equals(StaStsType.READY_RELEASE.val())) {
                    destSta.setStaSts(StaStsType.STOCK.val());
                    destSta.setUpdateTime(now);
                    if (!staService.updateById(destSta)) {
                        log.error("Sta [{}] 站点修改状态失败", task.getDestSta$());
                    }
                }
                break;
            case STA_TO_LOC:
                oriSta = staService.getById(task.getOriSta());
                if (oriSta.getStaSts().equals(StaStsType.READY_TAKE.val())) {
                    oriSta.setStaSts(StaStsType.IDLE.val());
                    oriSta.setUpdateTime(now);
                    if (!staService.updateById(oriSta)) {
                        log.error("Sta [{}] 站点修改状态失败", task.getOriSta$());
                    }
                }
 
                destLoc = this.getById(task.getDestLoc());
                if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) {
                    destLoc.setLocSts(LocStsType.STOCK.val());
                    destLoc.setUpdateTime(now);
                    if (!this.updateById(destLoc)) {
                        log.error("Loc [{}] 库位修改状态失败", task.getDestLoc$());
                    }
                }
                break;
            case STA_TO_STA:
                oriSta = staService.getById(task.getOriSta());
                if (oriSta.getStaSts().equals(StaStsType.READY_TAKE.val())) {
                    oriSta.setStaSts(StaStsType.IDLE.val());
                    oriSta.setUpdateTime(now);
                    if (!staService.updateById(oriSta)) {
                        log.error("Sta [{}] 站点修改状态失败", task.getOriSta$());
                    }
                }
 
                destSta = staService.getById(task.getDestSta());
                if (destSta.getStaSts().equals(StaStsType.READY_RELEASE.val())) {
                    destSta.setStaSts(StaStsType.STOCK.val());
                    destSta.setUpdateTime(now);
                    if (!staService.updateById(destSta)) {
                        log.error("Sta [{}] 站点修改状态失败", task.getDestSta$());
                    }
                }
                break;
            case TO_CHARGE:
            case TO_STANDBY:
            case MOVE:
                break;
            default:
                break;
        }
 
    }
 
}