2021与蓝度共同重构项目,服务端
liuhaonan
2022-07-19 dca94edc9cd0681be081e36b0dba3bbe0f581ea0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.sandu.ximon.admin.controller;
 
import com.sandu.common.domain.ResponseVO;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.util.ResponseUtil;
import com.sandu.ximon.admin.service.C3mChargingChargeService;
import com.sandu.ximon.dao.domain.C3mChargingCharge;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * @Author liuhaonan
 * @Date 2022/3/18 15:58
 * @Version 1.0
 * 充电桩费率相关
 */
@RestController
@AllArgsConstructor
@RequestMapping("/v1/c3mChargingCharge")
public class C3mChargingChargeController {
 
    private final C3mChargingChargeService chargeService;
 
    /**
     * 编辑充电桩费率
     *
     * @param chargeEntities
     * @return
     */
    @PostMapping("/updateC3mCharging")
    public ResponseVO<Object> updateC3mCharging(@RequestBody List<C3mChargingCharge> chargeEntities) {
        if (chargeEntities.size() > 5) {
            throw new BusinessException("当前最高仅支持4组费率");
        }
        if (chargeEntities.size() == 0) {
            throw new BusinessException("最少需要一条费率");
        }
        return ResponseUtil.success(chargeService.updateCharge(chargeEntities));
    }
 
 
    @GetMapping("/getChargeByC3Id/{c3mId}")
    public ResponseVO<Object> getChargeByC3Id(@PathVariable Integer c3mId) {
        return ResponseUtil.success(chargeService.getChargeByC3Id(c3mId));
    }
 
    @GetMapping("/getChargeByPoleId/{PoleId}")
    public ResponseVO<Object> getChargeByPoleId(@PathVariable Long PoleId) {
        return ResponseUtil.success(chargeService.getChargeByPoleId(PoleId));
    }
 
    /**
     * 根据充电桩mac获取当前时间段的费率
     */
    @GetMapping("/getChargeByMac/{mac}")
    public ResponseVO<Object> getChargeByMac(@PathVariable Long mac, Integer power) {
        return ResponseUtil.success(chargeService.getCostByC3id(mac, power));
    }
 
 
}