| | |
| | | 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.param.C3mChargingChargeParam; |
| | | import com.sandu.ximon.admin.security.PermissionConfig; |
| | | import com.sandu.ximon.admin.service.C3mChargingChargeService; |
| | | import com.sandu.ximon.dao.domain.C3mChargingCharge; |
| | | import com.sandu.ximon.dao.enums.MenuEnum; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | public class C3mChargingChargeController { |
| | | |
| | | private final C3mChargingChargeService chargeService; |
| | | private final PermissionConfig permissionConfig; |
| | | |
| | | @PostMapping("/addC3mCharging") |
| | | public ResponseVO<Object> addC3mCharging(@RequestBody C3mChargingChargeParam charge) { |
| | | // chargeService.save(charge); |
| | | // chargeService.initCharge(charge); |
| | | return ResponseUtil.success(chargeService.initCharge(charge)); |
| | | } |
| | | |
| | | /** |
| | | * 编辑充电桩费率 |
| | | * |
| | | * @param chargeEntities |
| | | * @return |
| | | */ |
| | | @PostMapping("/updateC3mCharging") |
| | | public ResponseVO<Object> updateC3mCharging(@RequestBody List<C3mChargingCharge> chargeEntities) { |
| | | if (!permissionConfig.check(MenuEnum.CHARGE_UPDATE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | if (chargeEntities.size() > 5) { |
| | | throw new BusinessException("当前最高仅支持4组费率"); |
| | | } |
| | | if (chargeEntities.size() == 0) { |
| | | throw new BusinessException("最少需要一条费率"); |
| | | } |
| | | return ResponseUtil.success(chargeService.updateCharge(chargeEntities)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据c3id获取充电桩费率 |
| | | * |
| | | * @param c3mId |
| | | * @return |
| | | */ |
| | | @GetMapping("/getChargeByC3Id/{c3mId}") |
| | | public ResponseVO<Object> getChargeByC3Id(@PathVariable Integer c3mId) { |
| | | if (!permissionConfig.check(MenuEnum.CHARGE_LIST.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(chargeService.getChargeByC3Id(c3mId)); |
| | | } |
| | | |
| | | /** |
| | | * 根据灯杆id获取费率 |
| | | * |
| | | * @param PoleId |
| | | * @return |
| | | */ |
| | | @GetMapping("/getChargeByPoleId/{PoleId}") |
| | | public ResponseVO<Object> getChargeByPoleId(@PathVariable Long PoleId) { |
| | | if (!permissionConfig.check(MenuEnum.CHARGE_LIST.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(chargeService.getChargeByPoleId(PoleId)); |
| | | } |
| | | |
| | | /** |
| | | * 根据充电桩mac获取当前时间段的费率 |
| | | */ |
| | | @GetMapping("/getChargeByMac/{mac}") |
| | | public ResponseVO<Object> getChargeByMac(@PathVariable Long mac, Integer power) { |
| | | if (!permissionConfig.check(MenuEnum.CHARGE_LIST.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(chargeService.getCostByC3id(mac, power)); |
| | | } |
| | | |
| | | |
| | | } |