| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.security.annotation.AnonymousAccess; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.param.C3ChargingAddParam; |
| | | import com.sandu.ximon.admin.param.C3ChargingParam; |
| | | import com.sandu.ximon.admin.security.PermissionConfig; |
| | | import com.sandu.ximon.admin.service.C3ChargingService; |
| | | import com.sandu.ximon.dao.enums.MenuEnum; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * @author ZZQ |
| | |
| | | @RequestMapping("/v1/admin/C3Charging") |
| | | public class C3ChargingController { |
| | | private C3ChargingService c3ChargingService; |
| | | private PermissionConfig permissionConfig; |
| | | |
| | | /** |
| | | * 充电开启 |
| | | */ |
| | | @PostMapping("/startCharging") |
| | | public ResponseVO<Object> startCharging(@RequestBody C3ChargingParam c3ChargingParam) { |
| | | c3ChargingService.startCharging(c3ChargingParam.getC3Mac(), c3ChargingParam.getChargingCapacity(), c3ChargingParam.getChargeAmount()); |
| | | |
| | | return ResponseUtil.success(null); |
| | | @PostMapping("/C3ChargingList") |
| | | public ResponseVO<Object> C3ChargingList(BaseConditionVO baseConditionVO, @RequestBody(required = false) C3ChargingParam c3ChargingParam |
| | | , @RequestParam(value = "order", required = false) Integer order |
| | | , @RequestParam(value = "seq", required = false) Integer seq) { |
| | | if (!permissionConfig.check(MenuEnum.C3_CHARGING_LIST.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(c3ChargingService.getC3ChargingListByKeyword(baseConditionVO, c3ChargingParam, order, seq)); |
| | | } |
| | | |
| | | @AnonymousAccess |
| | | @GetMapping("/chargingInfo") |
| | | public ResponseVO<Object> getChargingInfo(@RequestParam(required = false, value = "poleId") String poleId) { |
| | | return ResponseUtil.success(c3ChargingService.getChargingInfo(poleId)); |
| | | } |
| | | |
| | | // /** |
| | | // * 充电开启 |
| | | // */ |
| | | // @AnonymousAccess |
| | | // @PostMapping("/startCharging") |
| | | // public ResponseVO<Object> startCharging(@RequestBody C3ChargingParam c3ChargingParam) { |
| | | // String result = c3ChargingService.startCharging(c3ChargingParam.getC3Mac(), c3ChargingParam.getChargingCapacity(), c3ChargingParam.getChargeAmount()); |
| | | // if ("操作成功".equals(result)) { |
| | | // return ResponseUtil.success(result); |
| | | // } else { |
| | | // return ResponseUtil.fail(result); |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | /** |
| | | * 充电结束 |
| | | * 充电结束——小程序用户结束,不需要token,需要openId |
| | | */ |
| | | @AnonymousAccess |
| | | @PostMapping("/finishCharging") |
| | | public ResponseVO<Object> finishCharging(@RequestBody C3ChargingParam c3ChargingParam) { |
| | | c3ChargingService.finishCharging(c3ChargingParam.getC3Mac()); |
| | | if (c3ChargingParam.getC3Id() == null || c3ChargingParam.getOpenId() == null) { |
| | | throw new BusinessException("参数错误!"); |
| | | } |
| | | String result = c3ChargingService.finishCharging(c3ChargingParam.getC3Id(), c3ChargingParam.getOpenId()); |
| | | |
| | | return ResponseUtil.success(null); |
| | | if ("操作成功".equals(result)) { |
| | | return ResponseUtil.success(result); |
| | | } else { |
| | | return ResponseUtil.fail(result); |
| | | } |
| | | } |
| | | |
| | | // /** |
| | | // * 同步结束 |
| | | // */ |
| | | // @PostMapping("/EndOfTheSynchronization") |
| | | // public ResponseVO<Object> EndOfTheSynchronization(@RequestBody C3ChargingParam c3ChargingParam) { |
| | | // String result = c3ChargingService.EndOfTheSynchronization(c3ChargingParam.getC3Mac(), false); |
| | | // |
| | | // if ("操作成功".equals(result)) { |
| | | // return ResponseUtil.success(result); |
| | | // } else { |
| | | // return ResponseUtil.fail(result); |
| | | // } |
| | | // } |
| | | |
| | | // /** |
| | | // * 二维码 |
| | | // */ |
| | | // @PostMapping("/QrCode") |
| | | // public ResponseVO<Object> QrCode(@RequestBody C3ChargingParam c3ChargingParam) { |
| | | // //String testUrl = "http://www.ximonsmart.com/charge/#/charge/" +streetlightId+"/"+System.currentTimeMillis(); |
| | | // String result = c3ChargingService.QrCode(c3ChargingParam.getC3Mac(), c3ChargingParam.getQrCodeData()); |
| | | // |
| | | // if ("操作成功".equals(result)) { |
| | | // return ResponseUtil.success(result); |
| | | // } else { |
| | | // return ResponseUtil.fail(result); |
| | | // } |
| | | // } |
| | | |
| | | /** |
| | | * 查询版本 |
| | | */ |
| | | @PostMapping("/QueryVersion") |
| | | public ResponseVO<Object> QueryVersion(@RequestBody C3ChargingParam c3ChargingParam) { |
| | | if (!permissionConfig.check(MenuEnum.C3_CHARGING_QUERYVERSION.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | |
| | | String result = c3ChargingService.QueryVersion(c3ChargingParam.getC3Id()); |
| | | |
| | | return ResponseUtil.success(result); |
| | | } |
| | | |
| | | /** |
| | | * 查询心跳包间隔时间 |
| | | */ |
| | | @PostMapping("/QueryIntervalTime") |
| | | public ResponseVO<Object> QueryIntervalTime(@RequestBody C3ChargingParam c3ChargingParam) { |
| | | if (!permissionConfig.check(MenuEnum.C3_CHARGING_HEARTBEATPACKETTIME.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | String result = c3ChargingService.QueryIntervalTime(c3ChargingParam.getC3Id()); |
| | | |
| | | return ResponseUtil.success(result); |
| | | } |
| | | |
| | | /** |
| | | * 查询电压/电流常数 |
| | | */ |
| | | @PostMapping("/QueryConstant") |
| | | public ResponseVO<Object> QueryConstant(@RequestBody C3ChargingParam c3ChargingParam) { |
| | | if (!permissionConfig.check(MenuEnum.C3_CHARGING_QUERYCONSTANT.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | String result = c3ChargingService.QueryConstant(c3ChargingParam.getC3Id()); |
| | | |
| | | return ResponseUtil.success(result); |
| | | } |
| | | |
| | | /** |
| | | * 查询地址 |
| | | */ |
| | | @PostMapping("/QueryAddress") |
| | | public ResponseVO<Object> QueryAddress(@RequestBody C3ChargingParam c3ChargingParam) { |
| | | if (!permissionConfig.check(MenuEnum.C3_CHARGING_QUERYADDRESS.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | String result = c3ChargingService.QueryAddress(c3ChargingParam.getC3Id()); |
| | | return ResponseUtil.success(result); |
| | | } |
| | | |
| | | /** |
| | | * 查询故障码 |
| | | */ |
| | | @PostMapping("/QueryFaultCode") |
| | | public ResponseVO<Object> QueryFaultCode(@RequestBody C3ChargingParam c3ChargingParam) { |
| | | if (!permissionConfig.check(MenuEnum.C3_CHARGING_QUERYFAULTCODE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | String result = c3ChargingService.QueryFaultCode(c3ChargingParam.getC3Id()); |
| | | return ResponseUtil.success(result); |
| | | } |
| | | |
| | | /** |
| | | * 读心跳包 |
| | | */ |
| | | @PostMapping("/ReadTheHeartbeatPackage") |
| | | public ResponseVO<Object> ReadTheHeartbeatPackage(@RequestBody C3ChargingParam c3ChargingParam) { |
| | | if (!permissionConfig.check(MenuEnum.C3_CHARGING_READTHEHEARTBEATPACKAGE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(c3ChargingService.ReadTheHeartbeatPackage(c3ChargingParam.getC3Id(), false)); |
| | | } |
| | | |
| | | /** |
| | | * 设置心跳包间隔时间(秒)-充电状态时 |
| | | */ |
| | | @PostMapping("/SetHeartbeatPacketTimeCharging") |
| | | public ResponseVO<Object> SetHeartbeatPacketTimeCharging(@RequestBody @Validated C3ChargingParam c3ChargingParam) { |
| | | if (!permissionConfig.check(MenuEnum.C3_CHARGING_HEARTBEATPACKETTIME.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(c3ChargingService.SetHeartbeatPacketTimeCharging(c3ChargingParam.getC3Id(), c3ChargingParam.getTime(), true, false)); |
| | | } |
| | | |
| | | /** |
| | | * 设置心跳包间隔时间(秒)-非充电状态时 |
| | | */ |
| | | @PostMapping("/SetHeartbeatPacketTimeNotCharging") |
| | | public ResponseVO<Object> SetHeartbeatPacketTimeNotCharging(@RequestBody @Validated C3ChargingParam c3ChargingParam) { |
| | | if (!permissionConfig.check(MenuEnum.C3_CHARGING_HEARTBEATPACKETTIME.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(c3ChargingService.SetHeartbeatPacketTimeCharging(c3ChargingParam.getC3Id(), c3ChargingParam.getTime(), false, false)); |
| | | } |
| | | |
| | | /** |
| | | * 设置电压/电流常数(各一字节)(默认值0xBC64) |
| | | */ |
| | | @PostMapping("/SetConstant") |
| | | public ResponseVO<Object> SetConstant(@RequestBody @Validated C3ChargingParam c3ChargingParam) { |
| | | if (!permissionConfig.check(MenuEnum.C3_CHARGING_SETCONSTANT.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(c3ChargingService.SetConstant(c3ChargingParam.getC3Id(), c3ChargingParam.getConstant())); |
| | | } |
| | | |
| | | /** |
| | | * 设置地址 |
| | | */ |
| | | @PostMapping("/SetAddress") |
| | | public ResponseVO<Object> SetAddress(@RequestBody @Validated C3ChargingParam c3ChargingParam) { |
| | | if (!permissionConfig.check(MenuEnum.C3_CHARGING_SETADDRESS.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(c3ChargingService.SetAddress(c3ChargingParam.getC3Id(), c3ChargingParam.getAddress(), false)); |
| | | } |
| | | |
| | | /** |
| | | * 设置日历(同心跳包中的6字节日期时间) |
| | | */ |
| | | @PostMapping("/SetCalendar") |
| | | public ResponseVO<Object> SetCalendar(@RequestBody @Validated C3ChargingParam c3ChargingParam) { |
| | | if (!permissionConfig.check(MenuEnum.C3_CHARGING_SETCALENDAR.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | |
| | | return ResponseUtil.success(c3ChargingService.SetCalendar(c3ChargingParam.getC3Id() |
| | | , c3ChargingParam.getYear(), c3ChargingParam.getMonth(), c3ChargingParam.getDay() |
| | | , c3ChargingParam.getHour(), c3ChargingParam.getMin(), c3ChargingParam.getSec(), false)); |
| | | } |
| | | |
| | | /** |
| | | * 故障码上报清除 |
| | | */ |
| | | @PostMapping("/ClearedFaultCode") |
| | | public ResponseVO<Object> ClearedFaultCode(@RequestBody @Validated C3ChargingParam c3ChargingParam) { |
| | | if (!permissionConfig.check(MenuEnum.C3_CHARGING_CLEAREDFAULTCODE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(c3ChargingService.ClearedFaultCode(c3ChargingParam.getC3Id())); |
| | | } |
| | | |
| | | /** |
| | | * 恢复出厂值 |
| | | */ |
| | | @PostMapping("/RestoreFactoryValue") |
| | | public ResponseVO<Object> RestoreFactoryValue(@RequestBody @Validated C3ChargingParam c3ChargingParam) { |
| | | if (!permissionConfig.check(MenuEnum.C3_CHARGING_RESTOREFACTORYVALUE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(c3ChargingService.RestoreFactoryValue(c3ChargingParam.getC3Id())); |
| | | } |
| | | |
| | | /** |
| | | * 软重启 |
| | | */ |
| | | @PostMapping("/restartCharging") |
| | | public ResponseVO<Object> restartCharging(@RequestBody C3ChargingParam c3ChargingParam) { |
| | | c3ChargingService.restartCharging(c3ChargingParam.getC3Mac()); |
| | | if (!permissionConfig.check(MenuEnum.C3_CHARGING_RESTARTCHARGING.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | String result = c3ChargingService.restartCharging(c3ChargingParam.getC3Id()); |
| | | |
| | | return ResponseUtil.success(null); |
| | | if ("操作成功".equals(result)) { |
| | | return ResponseUtil.success(result); |
| | | } else { |
| | | return ResponseUtil.fail(result); |
| | | } |
| | | } |
| | | |
| | | // /** |
| | | // * 添加充电桩硬件设备 |
| | | // * |
| | | // * @param c3ChargingAddParam |
| | | // * @return |
| | | // */ |
| | | // @PostMapping("/addC3Charging") |
| | | // public ResponseVO<Object> addC3Charging(@RequestBody C3ChargingAddParam c3ChargingAddParam) { |
| | | // boolean flag = c3ChargingService.addC3Charging(c3ChargingAddParam); |
| | | // if (flag) { |
| | | // return ResponseUtil.success("添加充电桩硬件设备成功!"); |
| | | // } else { |
| | | // return ResponseUtil.fail("添加充电桩硬件设备失败!"); |
| | | // } |
| | | // } |
| | | |
| | | /** |
| | | * 修改充电桩硬件设备名称 |
| | | * |
| | | * @param c3ChargingAddParam |
| | | * @return |
| | | */ |
| | | @PostMapping("/updateC3ChargingName") |
| | | public ResponseVO<Object> updateC3ChargingName(@RequestBody C3ChargingAddParam c3ChargingAddParam) { |
| | | if (!permissionConfig.check(MenuEnum.C3_CHARGING_UPDATEC3CHARGINGNAME.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | boolean flag = c3ChargingService.updateC3ChargingName(c3ChargingAddParam); |
| | | if (flag) { |
| | | return ResponseUtil.success("修改充电桩硬件设备名称成功!"); |
| | | } else { |
| | | return ResponseUtil.fail("修改充电桩硬件设备名称失败!"); |
| | | } |
| | | } |
| | | } |