2021与蓝度共同重构项目,服务端
fix
zhanzhiqin
2022-04-20 25e3153ff1256c321d4985070b5f07db930026ec
ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3ChargingService.java
@@ -19,6 +19,7 @@
import com.sandu.ximon.admin.param.C3ChargingAddParam;
import com.sandu.ximon.admin.param.C3ChargingParam;
import com.sandu.ximon.admin.param.PoleBindingParam;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.LogUtils;
import com.sandu.ximon.admin.utils.RedisUtils;
import com.sandu.ximon.dao.bo.C3ChargingBo;
@@ -56,7 +57,7 @@
     * @return 是否成功
     */
    public boolean updateReportState(String deviceName, String c3Mac, String statusBit, String deviceTemperature) {
        C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getPoleDevicesCode, deviceName));
        C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, c3Mac));
        if (one != null) {
//            one.setStatusBit(Integer.valueOf(statusBit));
            one.setDeviceTemperature(deviceTemperature);
@@ -107,23 +108,23 @@
                c3mChargingChargeService.initCharge((c3mCharging1.getC3Id()).intValue());
            }
        }
        /**
         * 添加绑定关系开始
         */
        Pole pole = poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getDeviceCode, deviceName));
        if (pole == null) {
            Pole pole1 = new Pole();
            pole1.setDeviceCode(deviceName);
            pole1.setPoleName(deviceName);
            pole1.setPoleCode(poleService.generatePoleCode());
            poleService.save(pole1);
        }
        Long poleId = poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getDeviceCode, deviceName)).getId();
        PoleBindingParam poleBindingParam = new PoleBindingParam();
        poleBindingParam.setDeviceType(2);
        poleBindingParam.setDeviceCode(mcuUdid);
        bindingService.bindPole(poleId, poleBindingParam);
//        /**
//         * 添加绑定关系开始
//         */
//        Pole pole = poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getDeviceCode, deviceName));
//        if (pole == null) {
//            Pole pole1 = new Pole();
//            pole1.setDeviceCode(deviceName);
//            pole1.setPoleName(deviceName);
//            pole1.setPoleCode(poleService.generatePoleCode());
//            poleService.save(pole1);
//        }
//
//        Long poleId = poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getDeviceCode, deviceName)).getId();
//        PoleBindingParam poleBindingParam = new PoleBindingParam();
//        poleBindingParam.setDeviceType(2);
//        poleBindingParam.setDeviceCode(mcuUdid);
//        bindingService.bindPole(poleId, poleBindingParam);
        /**
         * 添加绑定关系结束
@@ -183,7 +184,9 @@
     * @return
     */
    public List<C3ChargingBo> getC3ChargingListByKeyword(BaseConditionVO baseConditionVO, C3ChargingParam c3ChargingParam) {
        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
        if (baseConditionVO != null) {
            PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
        }
        if (c3ChargingParam == null) {
            c3ChargingParam = new C3ChargingParam();
        }
@@ -193,11 +196,21 @@
            c3ChargingParam.setKeyword(c3ChargingParam.getKeyword().trim());
        }
        List<C3ChargingBo> c3ChargingBoList = c3mChargingMapper.listC3mChargingDto(c3ChargingParam.getKeyword());
        List<C3ChargingBo> c3ChargingBoList;
        if (SecurityUtils.getClientId() == null) {
            c3ChargingBoList = c3mChargingMapper.listC3mChargingDto(c3ChargingParam.getKeyword(), null);
        } else {
            c3ChargingBoList = c3mChargingMapper.listC3mChargingDto(c3ChargingParam.getKeyword(), SecurityUtils.getUserId());
        }
        for (C3ChargingBo one : c3ChargingBoList) {
            String s = RedisUtils.getBean().get(C3mRedisConstant.C3_STATUS.getCode() + one.getC3Mac());
            if (s != null) {
                one.setStatusBit(1);
                try {
                    A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage beatDataPackage = JSON.parseObject(s, A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage.class);
                    one.setStatusBit((Integer.valueOf(beatDataPackage.getStatusBit())));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                one.setStatusBit(0);
            }
@@ -211,11 +224,16 @@
     *
     * @return
     */
    public C3mCharging getByC3Mac(String c3Mac) {
        C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac));
    public C3mCharging getByC3Mac(String udid) {
        C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, udid));
        String s = RedisUtils.getBean().get(C3mRedisConstant.C3_STATUS.getCode() + one.getC3Mac());
        if (s != null) {
            one.setStatusBit(1);
            try {
                A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage beatDataPackage = JSON.parseObject(s, A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage.class);
                one.setStatusBit((Integer.valueOf(beatDataPackage.getStatusBit())));
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            one.setStatusBit(0);
        }
@@ -789,7 +807,7 @@
        if (one == null) {
            throw new BusinessException("未找到绑定关系");
        }
        return getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, one.getDeviceCode()));
        return getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, one.getDeviceCode()));
    }