自动化立体仓库 - WCS系统
#
lsh
2024-03-21 b909f4e136ca3182befba9510fd0ccc13f6a784f
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
package com.zy.asrs.service.impl;
 
import com.alibaba.fastjson.JSON;
import com.zy.asrs.entity.CommandInfoLog;
import com.zy.asrs.mapper.CommandInfoMapper;
import com.zy.asrs.entity.CommandInfo;
import com.zy.asrs.service.CommandInfoLogService;
import com.zy.asrs.service.CommandInfoService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Service("commandInfoService")
public class CommandInfoServiceImpl extends ServiceImpl<CommandInfoMapper, CommandInfo> implements CommandInfoService {
 
    @Autowired
    private CommandInfoLogService commandInfoLogService;
 
    @Override
    public List<CommandInfo> selectByTaskNoAndWrkNo(String taskNo, Integer wrkNo) {
        return this.baseMapper.selectByTaskNoAndWrkNo(taskNo, wrkNo);
    }
 
    @Override
    public List<CommandInfo> selectByWrkNo(Integer wrkNo) {
        return this.baseMapper.selectByWrkNo(wrkNo);
    }
 
    @Override
    public List<CommandInfo> selectByTaskNo(String taskNo) {
        return this.baseMapper.selectByTaskNo(taskNo);
    }
 
    @Override
    public int saveToHistory(String taskNo) {
        int count = 0;
        if (this.selectByTaskNo(taskNo).isEmpty()) {
            return count;
        }
        for (CommandInfo commandInfo : this.baseMapper.selectByTaskNo(taskNo)) {
            String jsonString = JSON.toJSONString(commandInfo);
            CommandInfoLog commandInfoLog = JSON.parseObject(jsonString, CommandInfoLog.class);
            commandInfoLog.setId(null);
            if (commandInfoLogService.insert(commandInfoLog)) {
                count++;
            }
        }
        return count;
    }
 
    @Override
    public boolean saveToHistory(Integer id) {
        CommandInfo commandInfo = this.baseMapper.selectById(id);
        String jsonString = JSON.toJSONString(commandInfo);
        CommandInfoLog commandInfoLog = JSON.parseObject(jsonString, CommandInfoLog.class);
        commandInfoLog.setId(null);
        boolean result1 = commandInfoLogService.insert(commandInfoLog);
        Integer result2 = this.baseMapper.deleteById(id);
        return result1 && result2 > 0;
    }
 
    @Override
    public List<CommandInfo> selectCompleteManualCommand() {
        return this.baseMapper.selectCompleteManualCommand();
    }
}