2021与蓝度共同重构项目,服务端
zhanzhiqin
2022-04-25 35b68d05c92ae1eab2e409529a070a217ba492ae
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
64
65
66
67
68
69
70
71
72
73
package com.sandu.ximon.admin.controller;
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sandu.common.domain.ResponseVO;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.util.ResponseUtil;
import com.sandu.ximon.admin.param.C3mChargingChargeParam;
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 charge
     * @return
     */
    // @PostMapping("/addC3mCharging")
    public ResponseVO<Object> addC3mCharging(@RequestBody C3mChargingChargeParam charge) {
//        chargeService.save(charge);
//        chargeService.initCharge(charge);
        return ResponseUtil.success(chargeService.initCharge(charge));
    }
 
    @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));
    }
 
    // @PostMapping("/deleteC3mCharging")
    public ResponseVO<Object> deleteC3mCharging(@RequestBody C3mChargingChargeParam charge) {
        boolean remove = chargeService.remove(Wrappers.lambdaQuery(C3mChargingCharge.class).eq(C3mChargingCharge::getC3Id, charge.getC3Id())
                .eq(C3mChargingCharge::getHour, charge.getCharge()).eq(C3mChargingCharge::getHour, charge.getHour())
                .eq(C3mChargingCharge::getCharge, charge.getCharge()).eq(C3mChargingCharge::getCharge, charge.getTimestamp()));
        return ResponseUtil.success(remove);
    }
 
 
    @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));
    }
 
 
}