2021与蓝度共同重构项目,服务端
liuhaonan
2022-05-27 b34d941094d11e21e21a2ceead8a9fdeee640e2d
ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3mChargingChargeService.java
@@ -1,10 +1,16 @@
package com.sandu.ximon.admin.service;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.ximon.admin.param.C3mChargingChargeParam;
import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
import com.sandu.ximon.dao.domain.C3mChargingCharge;
import com.sandu.ximon.dao.domain.PoleBinding;
import com.sandu.ximon.dao.mapper.C3mChargingChargeMapper;
import com.sandu.ximon.dao.mapper.C3mChargingMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
@@ -23,6 +29,8 @@
@AllArgsConstructor
public class C3mChargingChargeService extends BaseServiceImpl<C3mChargingChargeMapper, C3mChargingCharge> {
    private final C3mChargingChargeMapper c3mChargingChargeMapper;
    private final PoleBindingService bindingService;
    private final C3mChargingMapper chargingMapper;
    /**
     * 修改费率
@@ -40,13 +48,21 @@
            c3m.setTimestamp(timestamp);
            save(c3m);
        }
//        LogService.getBean().log(userId,username,"修改C3m费率",null,
//                "{ "+ JSON.toJSONString(chargeEntities)+" }");
        /**
         * c3充电桩费率更改 日志记录开始
         */
        String content = "c3充电桩费率更改:" + JSON.toJSONString(chargeEntities);
        StoreOperationRecordsUtils.storeOperationData(null, null, "c3充电桩费率更改", content);
        /**
         * c3充电桩费率更改 日志记录结束
         */
        return true;
    }
    /**
     * 插入费率
     *
     * @param c3
     * @return
     */
@@ -55,11 +71,14 @@
        BeanUtil.copyProperties(c3, charge);
        charge.setTimestamp(new Date().getTime());
//        c3mChargingChargeMapper.insertCharge(charge);
        return save(charge);
    }
    /**
     * 自动插入默认费率
     *
     * @param c3Id
     */
    public void initCharge(Integer c3Id) {
@@ -130,4 +149,22 @@
    }
    /**
     * 根据灯杆id查找费率
     *
     * @param poleId
     * @return
     */
    public List<C3mChargingCharge> getChargeByPoleId(Long poleId) {
        PoleBinding one = bindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceType, 2).eq(PoleBinding::getPoleId, poleId));
        if (one == null) {
            throw new BusinessException("未找到绑定关系");
        }
        Long c3Id = chargingMapper.getAllByC3Mac(one.getDeviceCode()).getC3Id();
        return getChargeByC3Id(c3Id.intValue());
    }
    public boolean deleteC3mCharging(Integer c3mId) {
        return c3mChargingChargeMapper.deleteCharge(c3mId);
    }
}