class AgentsServiceImpl extends SonicServiceImpl<AgentsMapper, Agents> implements AgentsService {

    @Autowired
    private DevicesService devicesService;
    @Autowired
    private AlertRobotsServiceImpl alertRobotsService;
    @Autowired
    private AgentsMapper agentsMapper;

    @Override
    public List<Agents> findAgents() {
        return list();
    }

    @Override
    public void update(int id, String name, int highTemp, int highTempTime, int robotType, String robotToken, String robotSecret, int[] alertRobotIds) {<FILL_FUNCTION_BODY>}

    public void resetDevice(int id) {
        List<Devices> devicesList = devicesService.listByAgentId(id);
        for (Devices devices : devicesList) {
            if ((!devices.getStatus().equals(DeviceStatus.OFFLINE))
                    && (!devices.getStatus().equals(DeviceStatus.DISCONNECTED))) {
                devices.setStatus(DeviceStatus.OFFLINE);
                devicesService.save(devices);
            }
        }
    }

    @Override
    public void saveAgents(JSONObject jsonObject) {
        if (jsonObject.getInteger("agentId") != null && jsonObject.getInteger("agentId") != 0) {
            if (existsById(jsonObject.getInteger("agentId"))) {
                Agents oldAgent = findById(jsonObject.getInteger("agentId"));
                oldAgent.setStatus(AgentStatus.ONLINE);
                oldAgent.setHost(jsonObject.getString("host"));
                oldAgent.setPort(jsonObject.getInteger("port"));
                oldAgent.setVersion(jsonObject.getString("version"));
                oldAgent.setSystemType(jsonObject.getString("systemType"));
                if (jsonObject.getInteger("hasHub") != null) {
                    oldAgent.setHasHub(jsonObject.getInteger("hasHub"));
                }
                save(oldAgent);
            }
        }
    }

    @Override
    public void saveAgents(Agents agents) {
        save(agents);
    }

    @Override
    @Transactional
    public boolean updateAgentsByLockVersion(Agents agents) {
        return lambdaUpdate()
                .eq(Agents::getId, agents.getId())
                .eq(Agents::getLockVersion, agents.getLockVersion())
                .update(agents.setLockVersion(agents.getLockVersion() + 1));
    }

    @Deprecated
    @Override
    public boolean offLine(int id) {
        if (existsById(id)) {
            Agents agentOffLine = findById(id);
            agentOffLine
                    .setStatus(AgentStatus.OFFLINE);
            updateAgentsByLockVersion(agentOffLine);
            resetDevice(agentOffLine.getId());
            return true;
        } else {
            return false;
        }
    }

    @Override
    public Agents auth(String key) {
        Agents agents = findBySecretKey(key);
        if (agents != null) {
            resetDevice(agents.getId());
        }
        return agents;
    }

    @Override
    public Agents findById(int id) {
        return baseMapper.selectById(id);
    }

    @Override
    public Agents findBySecretKey(String secretKey) {
        return lambdaQuery().eq(Agents::getSecretKey, secretKey).one();
    }

    @Override
    public void errCall(int id, String udId, int tem, int type) {
        alertRobotsService.sendErrorDevice(id, type, tem, udId);
    }
}

        if (id == 0) {
            Agents agents = new Agents();
            agents.setName(name);
            agents.setHost("unknown");
            agents.setStatus(AgentStatus.OFFLINE);
            agents.setVersion("unknown");
            agents.setPort(0);
            agents.setSystemType("unknown");
            agents.setHighTemp(highTemp);
            agents.setHighTempTime(highTempTime);
            agents.setRobotType(robotType);
            agents.setRobotToken(robotToken);
            agents.setRobotSecret(robotSecret);
            agents.setSecretKey(UUID.randomUUID().toString());
            agents.setHasHub(0);
            agents.setAlertRobotIds(alertRobotIds);
            save(agents);
        } else {
            Agents ag = findById(id);
            if (ObjectUtils.isNotEmpty(ag)) {
                ag.setName(name);
                ag.setHighTemp(highTemp);
                ag.setHighTempTime(highTempTime);
                ag.setRobotType(robotType);
                ag.setRobotToken(robotToken);
                ag.setRobotSecret(robotSecret);
                ag.setAlertRobotIds(alertRobotIds);
                save(ag);
                JSONObject result = new JSONObject();
                result.put("msg", "settings");
                result.put("highTemp", highTemp);
                result.put("highTempTime", highTempTime);
                TransportWorker.send(id, result);
            }
        }
    
<methods>public non-sealed void <init>() ,public boolean save(org.cloud.sonic.controller.models.domain.Agents) <variables>