一张表到另一张表

(1)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //闸机导入台账方法
    @Override
    public void setAFCInfoToRec(AFCQueryParamsDTO afcQueryParamsDTO) {
        setAFCInfos(afcQueryParamsDTO);
    }

    public Result setAFCInfos(AFCQueryParamsDTO afcQueryParamsDTO) {
        List<Device> resultList = new ArrayList<>();
        List<AFCGateEquipment> list = afcInfoDao.findAfcInfo();
        StationInfTree stationInfTree = new StationInfTree();
        for (AFCGateEquipment afcGateEquipment : list) {
            //in_name
            stationInfTree.setRelaTreeId(afcGateEquipment.getRelaTreeId());
            String parentId = stationInfTreeDao.findInfName2(stationInfTree.getRelaTreeId());    //二级 31
            String parentId2 = stationInfTreeDao.findInfName1(parentId);    //一级 26
            String infName = stationInfTreeDao.findInfName(parentId2);      //一级对应的 infName
            Device device = new Device();
            device.setAddress(infName);
            //innercode(s_station_id)
            String innerCode = afcGateEquipment.getInnerCode();
            String stationId = stationDao.getStationId(innerCode);
            device.setStationId(stationId);
            //check_type
            String checkType = afcGateEquipment.getCheckType();
            if (checkType.equals("1") || checkType.equals("2") || checkType.equals("3")) {  // || checkType.equals("4") || checkType.equals("5")
                device.setDeviceLargeCategoryId("8a83cb4e6e7dd26c016e86800888000c");  //门式大类123
                device.setDeviceCategory("8a83cb4e6f51574d016f5a015aad355a");   //门式小类123
            } else if (checkType.equals("4") || checkType.equals("5")) {
                device.setDeviceLargeCategoryId("8a83cb4e6e7dd26c016e86800888000c");  //柱式大类45
                device.setDeviceCategory("8a83cb4e726f3abf01727421fdbf017f");   //柱式小类45
            }
            //gate_ipaddr
            device.setIp(afcGateEquipment.getGateIpaddr());
            //gate_name
            device.setName(afcGateEquipment.getGateName());
            //gate_no
            device.setNo(afcGateEquipment.getGateNo());
            resultList.add(device);
        }

        List<Device> insertList = new ArrayList<>();
        for (Device device1 : resultList) {
            Device dev = deviceDao.selectRecDevice(device1.getNo(),device1.getIp());
            if (dev != null) {
                device1.setId(dev.getId());
                device1.setCreateTime(dev.getCreateTime());
                device1.setUpdateTime(new Date());
                deviceDao.save(device1);
//                deviceDao.updateRecDevice(device1);
            } else {
                insertList.add(device1);
            }
        }
        if (insertList.size() > 0) {
            for (Device device2 : insertList) {
//                deviceDao.insertRecDevice(device2);
                device2.setCreateTime(new Date());
                deviceDao.save(device2);
            }
        }
        return Result.ok();
    }


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////










(2)
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //导向屏信息导入台账方法
    public void setPisInfoToRec(DFQueryParamsDTO dfQueryParamsDTO) {
        setPisInfos(dfQueryParamsDTO);
    }

    public Result setPisInfos(DFQueryParamsDTO dfQueryParamsDTO) {
        List<Device> resultList = new ArrayList<>();
        List<PisInfo> list = pisInfoDao.findPisInfo();
        StationInfTree stationInfTree = new StationInfTree();
        for (PisInfo pisInfo : list) {
            //rela_tree_id(s_address)
            stationInfTree.setRelaTreeId(String.valueOf(pisInfo.getRelaTreeId()));
            String parentId = stationInfTreeDao.findInfName2(stationInfTree.getRelaTreeId());    //二级
            String parentId2 = stationInfTreeDao.findInfName1(parentId);     //一级
            String infName = stationInfTreeDao.findInfName(parentId2);       //一级对应的 infName
            Device device = new Device();
            device.setAddress(infName);
            //pis_arsnum(s_no)
            device.setNo(String.valueOf(pisInfo.getPisArsnum()));
            //led_name(s_name)
            device.setName(pisInfo.getLedname());
            //led_type
            int ledType = pisInfo.getLedType();
            if (ledType == 1 || ledType ==3) {
                device.setDeviceLargeCategoryId("8a83092878f2b5460178f3084590017b");  //异步屏大类13
                device.setDeviceCategory("8a83092878f2b5460178f3087a57017c");   //异步屏小类13
            } else if (ledType == 2 || ledType ==4) {
                device.setDeviceLargeCategoryId("8a83092878f2b5460178f3084590017b");  //同步屏大类24
                device.setDeviceCategory("8a8309287908abb401790c145a270224");   //同步屏小类24
            }
            //ip(s_ip)
            device.setIp(pisInfo.getIp());
            //station_name(s_station_id)
            String stationName = pisInfo.getStationName();
            String stationId = stationDao.getStationIdByName(stationName);
            device.setStationId(stationId);
            resultList.add(device);
        }

        List<Device> insertList = new ArrayList<>();
        for (Device device1 : resultList) {
            Device dev = deviceDao.selectRecDevice(device1.getNo(),device1.getIp());
            if (dev != null) {
                device1.setId(dev.getId());
                device1.setCreateTime(dev.getCreateTime());
                device1.setUpdateTime(new Date());
                deviceDao.save(device1);
            } else {
                insertList.add(device1);
            }
        }
        if (insertList.size() > 0) {
            for (Device device2 : insertList) {
                device2.setCreateTime(new Date());
                deviceDao.save(device2);
            }
        }
        return Result.ok();
    }


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

















posted @   sensen~||^_^|||&  阅读(34)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示
点击右上角即可分享
微信分享提示