package com.pqs9900.serviceImpl.terminal;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.njcn.enums.TerminalLogsEnum;
import com.njcn.mapper.configuration.DevFunctionMapper;
import com.njcn.mapper.configuration.DeviceMapper;
import com.njcn.mapper.configuration.LineMapper;
import com.njcn.mapper.configuration.TerminalLogsMapper;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.device.DeviceDetail;
import com.njcn.pojo.commons.device.LineInfo;
import com.njcn.pojo.configuration.DevFunction;
import com.njcn.pojo.configuration.Device;
import com.njcn.pojo.configuration.Line;
import com.njcn.pojo.configuration.TerminalLogs;
import com.njcn.pojo.terminal.ContUpdateDevValueVO;
import com.njcn.pojo.terminal.ContUpdateValueVO;
import com.njcn.pojo.terminal.ContValueVO;
import com.njcn.pojo.terminal.UpDevVO;
import com.njcn.shiro.token.TokenManager;
import com.njcn.sso.pojo.user.User;
import com.njcn.utils.*;
import com.pqs9900.mapper.DataInfo.VersionMapper;
import com.pqs9900.pojo.DataInfo.TerminalPojo;
import com.pqs9900.pojo.terminal.*;
import com.pqs9900.service.terminal.VersionService;
import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

import static java.util.Objects.isNull;

/**
 * @Description 终端程序版本管理
 * @Author cdf
 * @Date 2020/8/6 13:35
 **/
@Service
public class VersionServiceImpl implements VersionService {
    @Autowired
    private VersionMapper versionMapper;

    @Autowired
    private SocketClient socketClient;
    @Autowired
    private AppConfig appConfig;

    @Autowired
    private LineMapper lineMapper;

    @Autowired
    private DeviceMapper deviceMapper;
    @Autowired
    private DevFunctionMapper devFunctionMapper;
    @Resource
    private TerminalLogsMapper terminalLogsMapper;

    @Override
    public List<TerminalPojo> getDeviceList(Integer status, String devType, String devSeries, Integer upIsNo) {
        List<TerminalPojo> list = versionMapper.getDeviceList(status, devType, devSeries, null);
        if (!CollectionUtil.isEmpty(list)) {
            if (upIsNo == null) {
                return list;
            } else {
                if (upIsNo == 0) {
                    return list.stream().filter(s -> s.getEdName().equals("/")).collect(Collectors.toList());
                } else if (upIsNo == 1) {
                    return list.stream().filter(s -> !s.getEdName().equals("/")).collect(Collectors.toList());
                } else {
                    return list;
                }
            }
        }
        return list;
    }

    @Override
    public List<TerminalPojo> getTerminalListForUp(List<String> devarr) {
        return versionMapper.getDeviceList(null, null, null, devarr);
    }

    @Override
    public String addVersion(String edName, String edDescribe, String edProtocol, String edDate, String devType, String type, MultipartFile file) {
        List<EdData> list = versionMapper.getVersionList(null, edName, edProtocol, edDate, devType, null, null);
        if (list.size() != 0) {
            return "已存在相同类型的版本";
        }
        byte[] b = null;
        try {
            b = file.getBytes();
        } catch (IOException e) {
            e.printStackTrace();
        }
        String index = UUID.randomUUID().toString();
        EdData edData = new EdData();
        edData.setEdName(edName);
        edData.setEdDescribe(edDescribe);
        edData.setEdIndex(index);
        edData.setUpdateUser(TokenManager.getUserId());
        edData.setEdProtocol(edProtocol);
        edData.setEdDate(edDate);
        edData.setDevType(devType);
        edData.setEdFile(b);
        edData.setUpdateTime(new Date());
        edData.setType(type);
        Integer res3 = versionMapper.addVersion(edData);
        if (res3 == 1) {
            return "新增成功";
        } else {
            return "新增失败";
        }
    }

    @Override
    public String updateVersion(String edIndex, String edName, String edDescribe, String edProtocol, String edDate, String devType, String type, MultipartFile file) {
        List<EdData> list = versionMapper.getVersionList(edIndex, edName, edProtocol, edDate, devType, null, null);
        if (list.size() != 0) {
            return "已存在相同类型的版本";
        }
        EdData edData = new EdData();
        edData.setEdName(edName);
        edData.setEdDescribe(edDescribe);
        edData.setEdIndex(edIndex);
        edData.setEdProtocol(edProtocol);
        edData.setEdDate(edDate);
        edData.setUpdateUser(TokenManager.getUserId());
        edData.setUpdateTime(new Date());
        edData.setDevType(devType);
        edData.setType(type);
        if (file != null) {
            if (!file.isEmpty()) {
                byte[] b = {};
                try {
                    b = file.getBytes();
                    edData.setEdFile(b);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

        Integer res3 = versionMapper.updateVersion(edData);
        if (res3 == 1) {
            return "修改成功";
        } else {
            return "修改失败";
        }
    }

    @Override
    public Integer delVersion(String edIndex) {
        //检查版本是否已经绑定装置
        int is = versionMapper.isBindDev(edIndex);
        if(is>0){
            return -1;
        }
        Integer res = versionMapper.delVersion(edIndex);
        return res;
    }

    @Override
    public Integer enableDisable(String edIndex, Integer status) {
        Integer res = versionMapper.enableDisable(edIndex, status);
        return res;
    }

    @Override
    public EdData getVersion(String edIndex) {
        EdData edData = versionMapper.getVersion(edIndex);
        return edData;
    }

    @Override
    public EdData getVersionTwo(String edIndex) {
        EdData edData = versionMapper.getVersionTwo(edIndex);
        return edData;
    }

    @Override
    public List<EdData> getVersionList(String blob, String devType) {
        return versionMapper.getVersionList(null, null, null, null, devType, null, blob);
    }

    @Override
    public List<EdData> getVersionListFilterEdIndex(String devType, String blob, List<String> edList) {
        return versionMapper.getVersionListFilterEdIndex(devType, blob, edList);
    }

    /**
     * @Author chendaofei
     * @Description 点击升级
     * @Date 14:06 2020/8/11
     **/
    @Override
    public String getTemplet(List<String> list, String edIndex) {
        List<DeviceIpRVO> resTemlist = new ArrayList<>();
        List<DeviceIpRVO> relist = versionMapper.getDeviceIp(list);
        //判断设备版本号
        Integer isExit = versionMapper.isExitVersionForDev(edIndex, list);
        if (isExit > 0) {
            return "请勿选择相同版本号升级";
        }
        if (!CollectionUtil.isEmpty(relist)) {
            EdData edData = versionMapper.getVersionTwo(edIndex);
            String series = edData.getDevTypeId();
            //判断设备是否存在相同型号

            for (DeviceIpRVO deviceIpRVO : relist) {
                if (!series.equals(deviceIpRVO.getDevSeries())) {
                    return "当前装置版本系列与目标版本系列不相同";
                }
            }


            //判断是否断开
            if (relist.stream().filter(w -> w.getStatus() == 0).findAny().isPresent()) {
                return "存在通讯中断设备";
            }


            Set<String> set = new HashSet<>();
            for (DeviceIpRVO d : relist) {
                set.add(d.getNodeIp());
            }
            Iterator<String> iterator = set.iterator();
            while (iterator.hasNext()) {

                List<UpDevVO> devIndex = new ArrayList<>();
                DeviceIpRVO deviceIpRVO = new DeviceIpRVO();
                String ip = iterator.next();
                for (DeviceIpRVO d : relist) {
                    UpDevVO upDevVO = new UpDevVO();
                    upDevVO.setDevIndex(d.getDevIndex());
                    upDevVO.setDevName(d.getDevName());
                    if (ip.equals(d.getNodeIp())) {
                        devIndex.add(upDevVO);
                    }
                }
                deviceIpRVO.setNodeIp(ip);
                deviceIpRVO.setDevlist(devIndex);
                resTemlist.add(deviceIpRVO);
            }
        } else {
            return "存在未知错误";
        }
        Integer port = Integer.valueOf(appConfig.getSocketPort());
        User user = TokenManager.getToken();
        String name = user.getLoginName();
        String userIndex = user.getUserIndex();
        for (DeviceIpRVO deviceIpRVO : resTemlist) {
            String ip = deviceIpRVO.getNodeIp();
            List<UpDevVO> devlist = deviceIpRVO.getDevlist();
            UpDataVO upDataVO = new UpDataVO();
            UpParamVO upParamVO = new UpParamVO();
            upDataVO.setTerminal(devlist);
            upDataVO.setType("180");
            upDataVO.setEdIndex(edIndex);
            upDataVO.setUserIndex(userIndex);
            JSONObject jsonstr = new JSONObject(upDataVO);
            Integer len = jsonstr.toString().length();
            upParamVO.setData(upDataVO);
            upParamVO.setLen(len.toString());
            JSONObject jsonObject = new JSONObject(upParamVO);
            String str = jsonObject.toString();
            socketClient.sentTerminal(str, ip, port, name, edIndex, devlist);
        }
        return "运行成功";
    }

    @Override
    public String sentDev(String ip, String type, String index, Long hander) {
        String msg = "";
        try {
            Device device = new Device();
            device.setDevIndex(Long.valueOf(index));
            device = deviceMapper.selectOne(device);
            UpDevVO upDevVO = new UpDevVO();
            upDevVO.setDevIndex(index);
            upDevVO.setDevName(device.getName());
            String host = lineMapper.getNodeIpbyDevIndex(Long.valueOf(index));
            Integer port = Integer.valueOf(appConfig.getSocketPort());
            ContValueRVO upParamVO = new ContValueRVO();
            ContValueVO valueVO = new ContValueVO();
            valueVO.setType(type);
            valueVO.setIndex(index);
            valueVO.setHander(String.valueOf(hander));
            JSONObject jsonstr = new JSONObject(valueVO);
            Integer len = jsonstr.toString().length();
            upParamVO.setLen(len.toString());
            upParamVO.setData(valueVO);
            JSONObject jsonObject = new JSONObject(upParamVO);
            String str = jsonObject.toString();
            User user = TokenManager.getToken();
            String name = user.getLoginName();
            List<UpDevVO> devlist = new ArrayList<>();
            devlist.add(upDevVO);
            socketClient.sentDZDev(ip, str, host, port, name, devlist, index);
            return "获取定值成功";
        } catch (Exception e) {
            return "获取定值失败";
        }
    }

    @Override
    public String sentLine(String ip, String type, String index, Long hander) {
        String msg = "";
        try {
            Line line = new Line();
            line.setLineIndex(Long.valueOf(index));
            line = lineMapper.selectOne(line);
            Device device = new Device();
            device.setDevIndex(Long.valueOf(line.getDevIndex()));
            device = deviceMapper.selectOne(device);
            UpDevVO upDevVO = new UpDevVO();
            upDevVO.setDevIndex(index);
            upDevVO.setDevName(device.getName());
            String host = lineMapper.getNodeIpbylineIndex(Long.valueOf(index));
            Integer port = Integer.valueOf(appConfig.getSocketPort());
            ContValueRVO upParamVO = new ContValueRVO();
            ContValueVO valueVO = new ContValueVO();
            valueVO.setType(type);
            valueVO.setLineid(index);
            valueVO.setHander(String.valueOf(hander));
            JSONObject jsonstr = new JSONObject(valueVO);
            Integer len = jsonstr.toString().length();
            upParamVO.setLen(len.toString());
            upParamVO.setData(valueVO);
            JSONObject jsonObject = new JSONObject(upParamVO);
            String str = jsonObject.toString();
            User user = TokenManager.getToken();
            String name = user.getLoginName();
            List<UpDevVO> devlist = new ArrayList<>();
            devlist.add(upDevVO);
            socketClient.sentLine(ip, str, host, port, name, devlist, index);
            return "获取定值成功";
        } catch (Exception e) {
            return "获取定值失败";
        }
    }


    @Override
    public String socketoReset(String ip, String type, String index) {
        String msg = "";
        try {
            String host = lineMapper.getNodeIpbyDevIndex(Long.valueOf(index));
            Integer port = Integer.valueOf(appConfig.getSocketPort());
            ContValueRVO upParamVO = new ContValueRVO();
            ContValueVO valueVO = new ContValueVO();
            valueVO.setType(type);
            valueVO.setIndex(index);
            valueVO.setHander(String.valueOf(4));
            JSONObject jsonstr = new JSONObject(valueVO);
            Integer len = jsonstr.toString().length();
            upParamVO.setLen(len.toString());
            upParamVO.setData(valueVO);
            JSONObject jsonObject = new JSONObject(upParamVO);
            String str = jsonObject.toString();
            User user = TokenManager.getToken();
            String name = user.getLoginName();
            msg = socketClient.sentResetDev(ip, str, host, port, name);
        } catch (Exception e) {
            return "重启装置失败";
        }
        return msg;
    }

    @Override
    public String sentUpdateDev(String ip, String type, String index, Long hander, String interValue) {
        try {
            Device device = new Device();
            device.setDevIndex(Long.valueOf(index));
            device = deviceMapper.selectOne(device);
            UpDevVO upDevVO = new UpDevVO();
            upDevVO.setDevIndex(index);
            upDevVO.setDevName(device.getName());
            String host = lineMapper.getNodeIpbyDevIndex(Long.valueOf(index));
            Integer port = Integer.valueOf(appConfig.getSocketPort());
            ContUpdateDevValueRVO upParamVO = new ContUpdateDevValueRVO();
            ContUpdateDevValueVO valueVO = new ContUpdateDevValueVO();
            valueVO.setType(type);
            valueVO.setIndex(index);
            valueVO.setHander(String.valueOf(hander));
            int[] intArr = new int[0];
            if (isNull(interValue)) {
                intArr = new int[0];
            } else {
                String[] valueArr = interValue.split(",");
                intArr = new int[valueArr.length];
                for (int i = 0; i < valueArr.length; i++) {
                    intArr[i] = Integer.parseInt(valueArr[i]);
                }
            }
            valueVO.setInterValue(intArr);
            JSONObject jsonstr = new JSONObject(valueVO);
            Integer len = jsonstr.toString().length();
            upParamVO.setLen(len.toString());
            upParamVO.setData(valueVO);
            JSONObject jsonObject = new JSONObject(upParamVO);
            String str = jsonObject.toString();
            User user = TokenManager.getToken();
            String name = user.getLoginName();
            List<UpDevVO> devlist = new ArrayList<>();
            devlist.add(upDevVO);
            socketClient.sentDZDev(ip, str, host, port, name, devlist, index);
            String deviceDescribe = deviceMapper.deviceDescribe(Integer.valueOf(index));
            TerminalLogs terminalLogs = new TerminalLogs();
            terminalLogs.setLogsIndex(UUID.randomUUID().toString());
            terminalLogs.setObjIndex(index);
            terminalLogs.setTerminalType(TerminalLogsEnum.constantValueInLog.getTerminalIndex());
            terminalLogs.setTerminalDescribe(TokenManager.getNickname()+deviceDescribe+"修改了内部定值");
            terminalLogs.setUpdateTime(new Date());
            terminalLogs.setUserIndex(TokenManager.getUserId());
            terminalLogsMapper.insert(terminalLogs);
        } catch (Exception e) {
            return "运行失败";
        }
        return "运行成功";
    }

    @Override
    public String sentUpdateLine(String ip, String type, String index, Long hander, String value) {
        try {
            Line line = new Line();
            line.setLineIndex(Long.valueOf(index));
            line = lineMapper.selectOne(line);
            Device device = new Device();
            device.setDevIndex(Long.valueOf(line.getDevIndex()));
            device = deviceMapper.selectOne(device);
            UpDevVO upDevVO = new UpDevVO();
            upDevVO.setDevIndex(index);
            upDevVO.setDevName(device.getName());
            String host = lineMapper.getNodeIpbylineIndex(Long.valueOf(index));
            Integer port = Integer.valueOf(appConfig.getSocketPort());
            ContUpdateValueRVO upParamVO = new ContUpdateValueRVO();
            ContUpdateValueVO valueVO = new ContUpdateValueVO();
            valueVO.setType(type);
            valueVO.setLineid(index);
            valueVO.setHander(String.valueOf(hander));
            float[] intArr = new float[0];
            if (isNull(value)) {
                intArr = new float[0];
            } else {
                String[] valueArr = value.split(",");
                intArr = new float[valueArr.length];
                for (int i = 0; i < valueArr.length; i++) {
                    intArr[i] = Float.parseFloat(valueArr[i]);
                }
            }
            valueVO.setValue(intArr);
            JSONObject jsonstr = new JSONObject(valueVO);
            Integer len = jsonstr.toString().length();
            upParamVO.setLen(len.toString());
            upParamVO.setData(valueVO);
            JSONObject jsonObject = new JSONObject(upParamVO);
            String str = jsonObject.toString();
            User user = TokenManager.getToken();
            String name = user.getLoginName();
            List<UpDevVO> devlist = new ArrayList<>();
            devlist.add(upDevVO);
            socketClient.sentLine(ip, str, host, port, name, devlist, index);
            LineInfo lineInfo = lineMapper.getLineObject(Integer.valueOf(index));
            TerminalLogs terminalLogs = new TerminalLogs();
            terminalLogs.setLogsIndex(UUID.randomUUID().toString());
            terminalLogs.setObjIndex(index);
            terminalLogs.setTerminalDescribe(TokenManager.getNickname()+"修改了"+lineInfo.getGdName()+" - "+lineInfo.getSubName()+" - "+lineInfo.getDevName()+" - "+lineInfo.getName()+"的外部定值");
            terminalLogs.setTerminalType(TerminalLogsEnum.constantValueOutLog.getTerminalIndex());
            terminalLogs.setUpdateTime(new Date());
            terminalLogs.setUserIndex(TokenManager.getUserId());
            terminalLogsMapper.insert(terminalLogs);
        } catch (Exception e) {
            return "运行失败";
        }
        return "运行成功";
    }

    @Override
    public List<DevFunction> getDevfunction(String devIndex) {
        return devFunctionMapper.queryByDevIndex(Long.parseLong(devIndex));
    }

    /**
     * @Author 陈道飞
     * @Description 获取升级日志
     * @Date 14:45 2020/9/18
     */
    @Override
    public List<TerminalPojo> getUpdetail(String devIndex) {
        return versionMapper.getUpdetail(devIndex);
    }

    /**
     * 重启装置命令
     * @author cdf
     * @date 2021/4/12
     */
    @Override
    public String restartDev(List<String> devList){
        List<DeviceIpRVO> relist = versionMapper.getDeviceIp(devList);
        if(CollectionUtil.isEmpty(relist)){
            return "前置机为空";
        }else {
            List<String> nodeIp = relist.stream().map(DeviceIpRVO::getNodeIp).distinct().collect(Collectors.toList());
            for(String ip: nodeIp){
               List<DeviceIpRVO> devLl = relist.stream().filter(item->item.getNodeIp().equals(ip)).collect(Collectors.toList());
               if(CollectionUtil.isEmpty(devLl)){
                   return "出错啦";
               }

               List<JSONObject> list = new ArrayList<>();
               List<String> devIn = new ArrayList<>();
               for(DeviceIpRVO devRVO:devLl){
                   devIn.add(devRVO.getDevIndex());
                   JSONObject dev = new JSONObject();
                   dev.put("devIndex",devRVO.getDevIndex());
                   dev.put("devName",devRVO.getDevName());
                   list.add(dev);
               }


                JSONObject jsonObject = new JSONObject();
                jsonObject.put("terminal",list);
                jsonObject.put("type",181);
                jsonObject.put("userIndex",TokenManager.getUserId());
                JSONObject jsonObject1 = new JSONObject();
                jsonObject1.put("len",0);
                jsonObject1.put("data",jsonObject);



                socketClient.restartDev(jsonObject1.toString(),ip,60000,devIn);
            }
        }
        return "命令发送成功";
    }

    @Override
    public String restartDevConValue(Integer devList) {
        List<DeviceIpRVO> relist = versionMapper.getDeviceIps(devList);
        if(CollectionUtil.isEmpty(relist)){
            return "前置机为空";
        }else {
            List<String> nodeIp = relist.stream().map(DeviceIpRVO::getNodeIp).distinct().collect(Collectors.toList());
            for(String ip: nodeIp){
                List<DeviceIpRVO> devLl = relist.stream().filter(item->item.getNodeIp().equals(ip)).collect(Collectors.toList());
                if(CollectionUtil.isEmpty(devLl)){
                    return "出错啦";
                }

                List<JSONObject> list = new ArrayList<>();
                for(DeviceIpRVO devRVO:devLl){
                    JSONObject dev = new JSONObject();
                    dev.put("devIndex",devRVO.getDevIndex());
                    dev.put("devName",devRVO.getDevName());
                    list.add(dev);
                }


                JSONObject jsonObject = new JSONObject();
                jsonObject.put("terminal",list);
                jsonObject.put("type",181);
                jsonObject.put("userIndex",TokenManager.getUserId());
                JSONObject jsonObject1 = new JSONObject();
                jsonObject1.put("len",0);
                jsonObject1.put("data",jsonObject);



                socketClient.restartDevConValue(jsonObject1.toString(),ip,60000);
            }
        }
        return "命令发送成功";
    }

    /**
     * 取消升级
     * @author cdf
     * @date 2021/8/2
     */
    @Override
    public String cancelUp(List<String> devList){
        List<DeviceIpRVO> relist = versionMapper.getDeviceIp(devList);
        if(CollectionUtil.isEmpty(relist)){
            return "前置机为空";
        }else {
            List<String> nodeIp = relist.stream().map(DeviceIpRVO::getNodeIp).distinct().collect(Collectors.toList());
            for(String ip: nodeIp){
                List<DeviceIpRVO> devLl= relist.stream().filter(item->item.getNodeIp().equals(ip)).collect(Collectors.toList());
                if(CollectionUtil.isEmpty(devLl)){
                    return "出错啦";
                }

                List<JSONObject> list = new ArrayList<>();
                for(DeviceIpRVO devRVO:devLl){
                    JSONObject dev = new JSONObject();
                    dev.put("devIndex",devRVO.getDevIndex());
                    dev.put("devName",devRVO.getDevName());
                    list.add(dev);
                }


                JSONObject jsonObject = new JSONObject();
                jsonObject.put("terminal",list);
                jsonObject.put("type",182);
                JSONObject jsonObject1 = new JSONObject();
                jsonObject1.put("len",0);
                jsonObject1.put("data",jsonObject);



                socketClient.cancelUp(jsonObject1.toString(),ip,60000,devLl.size());
            }
        }
        return "取消命令发送成功";
    }



    @Override
    public List<TerminalPojo> upFlag(List<Integer> devIndex){
        return  versionMapper.upFlag(devIndex);
    }


    @Override
    public void logsPush(List<Map<String, String>> map) throws Exception{
        //记录日志
        List<TerminalLogs> logsList = new ArrayList<>();
        for (Map m : map) {
            String hisMsg = "";
            String nowMsg = "";
            String result = "";
            String devIndex = m.get("dev").toString();
            String hisEd = m.get("hisEd").toString();
            String now = m.get("nowEd").toString();
            String state = m.get("state").toString();
            if(state.equals("2")){
                result = "成功";
            }else {
                result = "失败";
            }
            EdData his = versionMapper.getVersion(hisEd);
            if(Objects.nonNull(his)){
                hisMsg=his.getEdName()+"_"+his.getEdProtocol()+"_"+his.getEdDate();
            }
            EdData no = versionMapper.getVersion(now);
            if(Objects.nonNull(no)){
                nowMsg=no.getEdName()+"_"+no.getEdProtocol()+"_"+no.getEdDate();
            }
            DeviceDetail deviceDetail = deviceMapper.getDevAndParent(devIndex);
            if(Objects.nonNull(deviceDetail)) {
                TerminalLogs terminalLogs = new TerminalLogs();
                terminalLogs.setLogsIndex(UUID.randomUUID().toString());
                terminalLogs.setObjIndex(devIndex);
                terminalLogs.setTerminalType(TerminalLogsEnum.versonDevLog.getTerminalIndex());
                String deviceDescribe = TokenManager.getNickname() +
                        "将 " + deviceDetail.getGdNa()+" 下的 "+deviceDetail.getSubName()+" 下的 "
                        +deviceDetail.getName()+"的装置版本从历史版本: "+hisMsg+" 升级为目标版本"+nowMsg+"升级结果为 "+result;
                terminalLogs.setTerminalDescribe(deviceDescribe);
                terminalLogs.setUpdateTime(new Date());
                terminalLogs.setUserIndex(TokenManager.getUserId());
                logsList.add(terminalLogs);
            }
        }
        terminalLogsMapper.batchAddTerminalLogs(logsList);
    }


}
