2021与蓝度共同重构项目,服务端
liuhaonan
2022-07-22 d9a9d8a2dad1d1e57b184bf8f972a03d654d883a
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
@@ -38,11 +38,13 @@
import com.sandu.ximon.admin.vo.PoleBindVO;
import com.sandu.ximon.dao.bo.*;
import com.sandu.ximon.dao.domain.*;
import com.sandu.ximon.dao.enums.OrderByEnums;
import com.sandu.ximon.dao.mapper.PoleMapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -139,7 +141,7 @@
        StringBuilder sb = new StringBuilder();
        String date = new SimpleDateFormat("yyMMdd").format(new Date());
        sb.append(date);
        String key = LightKey.POLE_SN.key(null);
        String key = LightKey.POLE_SN.key(date);
        Long increment = redisService.incr(key, 1);
        String incrementStr = increment.toString();
        if (incrementStr.length() <= 4) {
@@ -173,7 +175,7 @@
        result.put("poleTotalCount", list.size());
        //诺瓦
        List<LedPlayerEntity> ledPlayerEntities = SpringContextHolder.getBean(LedPlayerEntityService.class).ledPlayerEntityList(null, null);
        List<LedPlayerEntity> ledPlayerEntities = SpringContextHolder.getBean(LedPlayerEntityService.class).ledPlayerEntityList(null, null, null, null);
        int number = 0;
        for (LedPlayerEntity bean : ledPlayerEntities) {
            if (bean.getOnlineStatus() == 1) {
@@ -188,9 +190,9 @@
        BroadcastTerminalV2Param broadcastTerminalV2Param = new BroadcastTerminalV2Param();
        broadcastTerminalV2Param.setBindingState(2);
        broadcastTerminalV2Param.setWorkState(2);
        List<BroadcastTerminalV2EntityBo> broadcastTerminalList = SpringContextHolder.getBean(IpVolumeService.class).getBroadcastTerminalList(null, broadcastTerminalV2Param);
        List<BroadcastTerminalV2EntityBo> broadcastTerminalList = SpringContextHolder.getBean(IpVolumeService.class).getBroadcastTerminalList(null, null, null, broadcastTerminalV2Param);
        for (BroadcastTerminalV2EntityBo bean : broadcastTerminalList) {
            if (bean.getStatus() == 1 || bean.getStatus() == 0) {
            if (bean.getStatus() != 0) {
                number++;
            }
        }
@@ -202,9 +204,9 @@
        MonitorParam monitorParam = new MonitorParam();
        monitorParam.setEquipmentState(2);
        monitorParam.setBindingState(2);
        List<MonitorBo> monitorBos = SpringContextHolder.getBean(MonitorService.class).listMonitorByKeyword(null, monitorParam).getList();
        List<MonitorBo> monitorBos = SpringContextHolder.getBean(MonitorService.class).listMonitorByKeyword(null, null, null, monitorParam).getList();
        monitorParam.setEquipmentState(1);
        List<MonitorBo> online = SpringContextHolder.getBean(MonitorService.class).listMonitorByKeyword(null, monitorParam).getList();
        List<MonitorBo> online = SpringContextHolder.getBean(MonitorService.class).listMonitorByKeyword(null, null, null, monitorParam).getList();
        result.put("monitorOnlineCount", online.size());
        result.put("monitorTotalCount", monitorBos.size());
@@ -276,8 +278,8 @@
        result.put("LightPoleHeelingTotalCount", lightPoleHeelings.size());
        //熙讯
        List<PoleLightemitEntity> poleLightemitEntities = SpringContextHolder.getBean(PoleLightemitService.class).listLed(null, false);
        List<PoleLightemitEntity> poleLightemitEntityOnlineList = SpringContextHolder.getBean(PoleLightemitService.class).listLed(null, true);
        List<PoleLightemitEntity> poleLightemitEntities = SpringContextHolder.getBean(PoleLightemitService.class).listLed(null, null, null, false);
        List<PoleLightemitEntity> poleLightemitEntityOnlineList = SpringContextHolder.getBean(PoleLightemitService.class).listLed(null, null, null, true);
        result.put("XiXunOnlineCount", poleLightemitEntityOnlineList.size());
        result.put("XiXunTotalCount", poleLightemitEntities.size());
@@ -285,16 +287,51 @@
        return result;
    }
    public CommonPage queryAllStatesAndList(Integer pageNo, Integer pageSize, PoleStatesParam param) {
    public CommonPage queryAllStatesAndList(Integer pageNo, Integer pageSize, PoleStatesParam param, Integer order, Integer seq) {
        if (param == null) {
            param = new PoleStatesParam();
        }
        System.out.println(param);
        //排序字段
        String orderByResult = OrderByEnums.POLE_ID.getCode();
        //正序、倒叙
        String orderBySeq = OrderByEnums.ASC.getCode();
        if (order != null) {
            switch (order) {
                case 1:
                    orderByResult = OrderByEnums.POLE_NAME.getCode();
                    break;
                case 2:
                    orderByResult = OrderByEnums.POLE_ID.getCode();
                    break;
                case 3:
                    orderByResult = OrderByEnums.POLE_CREATE_TIME.getCode();
                    break;
                default:
            }
        }
        if (seq != null) {
            switch (seq) {
                case 1:
                    orderBySeq = OrderByEnums.ASC.getCode();
                    break;
                case 2:
                    orderBySeq = OrderByEnums.DESC.getCode();
                    break;
                default:
                    break;
            }
        }
        //排序方式
        String orderBy = "t1." + orderByResult + " " + orderBySeq;
        List<Pole> poleList;
        if (SecurityUtils.getClientId() == null) {
            poleList = poleMapper.queryPoleOnLineStatesList(null, param.getIsTrue(), param.getBingStates(), param.getGroupid(), param.getKeyword());
            poleList = poleMapper.queryPoleOnLineStatesList(null, param.getIsTrue(),
                    param.getBingStates(), param.getGroupid(), param.getKeyword(), orderBy);
        } else {
            poleList = poleMapper.queryPoleOnLineStatesList(SecurityUtils.getUserId(), param.getIsTrue(), param.getBingStates(), param.getGroupid(), param.getKeyword());
            poleList = poleMapper.queryPoleOnLineStatesList(SecurityUtils.getUserId(),
                    param.getIsTrue(), param.getBingStates(), param.getGroupid(), param.getKeyword(), orderBy);
        }
        List<Pole> PoleResult = isOnLine(poleList, param);
@@ -569,9 +606,9 @@
    /**
     * 给灯杆注册三元码
     */
    public boolean setMac(String baseMac) {
        boolean setMac = false;
        //String baseMac = "baseDevice";
    @Transactional(rollbackFor = Exception.class)
    public Map setMac(String baseMac) {
        A1Frame a1Frame = new A1Frame(A1OrderEnum.REQUEST_READ_DEVICE_UNIQUE_MAC.getCode(), new EmptyRequestInnerFrame());
        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(baseMac, a1Frame);
        //存储振记录
@@ -641,10 +678,6 @@
        StoreOperationRecordsUtils.storeInnerFrameData(baseMac, "重启设备", build4, rebootFrame);
        if ("00".equals(rebootFrame.getPayload())) {
            //  pole.setDeviceCode(uniqueMac);
            // setMac = updateById(pole);
            System.out.println("重启成功");
        }
@@ -653,11 +686,8 @@
        if (pole == null) {
            pole = new Pole();
        }
      /*  String type = uniqueMac.substring(uniqueMac.length() - 2, uniqueMac.length());
        String Code = uniqueMac.substring(0, uniqueMac.length() - 2);*/
        pole.setDeviceCode(uniqueMac);
        pole.setPoleName(uniqueMac);
        /*  int i = Integer.parseInt(strm);*/
        if ("00".equals(a1DeviceMacRespInnerFrame.getType())) {
            pole.setDeviceType(0);
        } else if ("01".equals(a1DeviceMacRespInnerFrame.getType())) {
@@ -665,20 +695,32 @@
        }
        pole.setPoleCode(generatePoleCode());
//        setMac = save(pole);
        boolean result = saveOrUpdate(pole);
        if (result) {
            Light light = new Light();
            light.setDeviceCode(uniqueMac);
            light.setLightCount(2);
            SpringContextHolder.getBean(LightService.class).save(light);
        }
        /**
         * 实体灯杆注册日志记录开始
         */
        String content = "{灯杆ID:" + pole.getId() + ",灯杆编号:" + pole.getPoleCode() + ",灯杆名称:" + pole.getPoleName() + ",灯杆类型:" + pole.getDeviceType() + ",灯杆MAC:" + pole.getDeviceCode() + " }";
        StoreOperationRecordsUtils.storeOperationData(null, null, "实体灯杆注册", content);
//        String content = "{灯杆ID:" + pole.getId() + ",灯杆编号:" + pole.getPoleCode() + ",灯杆名称:" + pole.getPoleName() + ",灯杆类型:" + pole.getDeviceType() + ",灯杆MAC:" + pole.getDeviceCode() + " }";
//        StoreOperationRecordsUtils.storeOperationData(null, null, "实体灯杆注册", content);
        /**
         * 实体灯杆注册日志记录结束
         */
        Map map = new HashMap();
        if (true) {
            map.put("mac", uniqueMac);
        } else {
            map.put("mac", -1);
        }
        return result;
        return map;
    }
    public List<String> listDeviceCodeByIds(List<Long> poleIdList) {