#
zjj
6 天以前 ab0193f955b64f5ab8636c46b5d1f0f86fde8806
src/main/java/com/zy/asrs/service/impl/CommandInfoServiceImpl.java
@@ -1,12 +1,15 @@
package com.zy.asrs.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.asrs.entity.CommandInfoLog;
import com.zy.asrs.entity.TaskWrk;
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 com.zy.asrs.service.TaskWrkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -17,6 +20,10 @@
    @Autowired
    private CommandInfoLogService commandInfoLogService;
    @Autowired
    private TaskWrkService taskWrkService;
    @Autowired
    private CommandInfoService commandInfoService;
    @Override
    public List<CommandInfo> selectByTaskNoAndWrkNo(String taskNo, Integer wrkNo) {
@@ -49,4 +56,32 @@
        }
        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();
    }
    @Override
    public void clearCommandInfo() {
        int count = taskWrkService.selectCount(new EntityWrapper<TaskWrk>());
        if (count != 0){
            return;
        }
        int count1 = commandInfoService.selectCount(new EntityWrapper<CommandInfo>());
        if (count1 != 0){
            commandInfoService.delete(new EntityWrapper<>());
        }
    }
}