Merge branch 'master' of http://git.homecommunity.cn/supervip/MicroCommunity
| | |
| | | exclusions.append("/app/chargeMachine.listChargeMachine,");//查询注册信息 |
| | | exclusions.append("/app/chargeMachine.listChargeMachinePort,");//查询充电桩 |
| | | exclusions.append("/app/smartMeter/notify/*,");// 智能水电表通知放开 |
| | | exclusions.append("/equipments/*,");// 叮叮充电桩通知放开 |
| | | exclusions.append("/app/equipments/*,");// 叮叮充电桩通知放开 |
| | | exclusions.append("/app/charge/*,");// 通用充电桩通知放开 |
| | | exclusions.append("/app/reportInfoAnswer/queryReportInfoAnswerByOpenId"); |
| | | |
| | |
| | | import java.util.Base64; |
| | | |
| | | @RestController |
| | | @RequestMapping(path = "/equipments") |
| | | @RequestMapping(path = "/app/equipments") |
| | | public class NotifyDingDingChargeController extends BaseController { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(NotifyDingDingChargeController.class); |
| | |
| | | @PathVariable String port, |
| | | @RequestBody String postInfo, |
| | | HttpServletRequest request) { |
| | | if (!validateSign(request)) { |
| | | if (!validateSign(request, "/equipments/" + id + "/" + port + "/finish", postInfo)) { |
| | | return new ResponseEntity<>("{\n" + |
| | | "\"code\" : -1,\n" + |
| | | "\"msg\" : \"鉴权失败\"\n" + |
| | |
| | | notifyChargeOrderDto.setMachineCode(id); |
| | | notifyChargeOrderDto.setPortCode(port); |
| | | notifyChargeOrderDto.setBodyParam(postInfo); |
| | | notifyChargeOrderDto.setReason(param.getString("typeName")); |
| | | |
| | | ResultVo resultVo = notifyChargeV1InnerServiceSMOImpl.finishCharge(notifyChargeOrderDto); |
| | | ResultVo resultVo = null; |
| | | resultVo = notifyChargeV1InnerServiceSMOImpl.finishCharge(notifyChargeOrderDto); |
| | | |
| | | if (resultVo.getCode() == ResultVo.CODE_OK) { |
| | | resultVo.setCode(200); |
| | |
| | | @PathVariable String id, |
| | | @RequestBody String postInfo, |
| | | HttpServletRequest request) { |
| | | if (!validateSign(request)) { |
| | | if (!validateSign(request, "/equipments/" + id + "/event", postInfo)) { |
| | | return new ResponseEntity<>("{\n" + |
| | | "\"code\" : -1,\n" + |
| | | "\"msg\" : \"鉴权失败\"\n" + |
| | |
| | | |
| | | } |
| | | |
| | | private boolean validateSign(HttpServletRequest request) { |
| | | String appId = request.getParameter("appid"); |
| | | String timestamp = request.getParameter("timestamp"); |
| | | String sign = request.getParameter("sign"); |
| | | private boolean validateSign(HttpServletRequest request, String url, String postInfo) { |
| | | String appId = request.getHeader("appid"); |
| | | String timestamp = request.getHeader("timestamp"); |
| | | String sign = request.getHeader("sign"); |
| | | String secret = MappingCache.getValue(DING_DING_DOMAIN, DING_DING_APP_SECURE); |
| | | String data = "appid=" + appId + "×tamp=" + timestamp; |
| | | String data = "appid=" + appId + "&content=" + postInfo + "×tamp=" + timestamp + "&uri=" + url; |
| | | SecretKey secretKey = new SecretKeySpec(secret.getBytes(), "HmacMD5"); |
| | | Mac mac = null; |
| | | try { |
| | |
| | | chargeMachineDto.setMachineCode(notifyChargeOrderDto.getMachineCode()); |
| | | List<ChargeMachineDto> chargeMachineDtos = chargeMachineV1InnerServiceSMOImpl.queryChargeMachines(chargeMachineDto); |
| | | |
| | | Assert.listOnlyOne(chargeMachineDtos, "充电桩 不存在"); |
| | | //Assert.listOnlyOne(chargeMachineDtos, "充电桩 不存在"); |
| | | |
| | | if(chargeMachineDtos == null || chargeMachineDtos.size() < 1){ |
| | | return new ResultVo(ResultVo.CODE_OK, "成功"); |
| | | } |
| | | |
| | | // todo 插槽是否空闲 |
| | | |
| | |
| | | chargeMachinePortDto.setPortCode(notifyChargeOrderDto.getPortCode()); |
| | | chargeMachinePortDto.setState(ChargeMachinePortDto.STATE_WORKING); |
| | | List<ChargeMachinePortDto> chargeMachinePortDtos = chargeMachinePortV1InnerServiceSMOImpl.queryChargeMachinePorts(chargeMachinePortDto); |
| | | Assert.listOnlyOne(chargeMachinePortDtos, "插槽空闲"); |
| | | //Assert.listOnlyOne(chargeMachinePortDtos, "插槽空闲"); |
| | | if(chargeMachinePortDtos == null || chargeMachinePortDtos.size() < 1){ |
| | | return new ResultVo(ResultVo.CODE_OK, "成功"); |
| | | } |
| | | |
| | | ChargeMachinePortPo chargeMachinePortPo = new ChargeMachinePortPo(); |
| | | chargeMachinePortPo.setPortId(chargeMachinePortDtos.get(0).getPortId()); |
| | |
| | | |
| | | private static final String QUERY_PORT_URL = DingdingChargeUtils.URL + "/equipments/ID/PORT"; |
| | | |
| | | private static final String QUERY_CHARGE_STATE_URL = DingdingChargeUtils.URL + "/equipments/code/ID"; |
| | | private static final String QUERY_CHARGE_STATE_URL = DingdingChargeUtils.URL + "/equipments/ID"; |
| | | |
| | | |
| | | //开始充电 |
| | |
| | | httpHeaders.add("Authorization", "Bearer " |
| | | + getAccessToken(MappingCache.getValue(DING_DING_DOMAIN, DING_DING_APP_ID), |
| | | MappingCache.getValue(DING_DING_DOMAIN, DING_DING_APP_SECURE))); |
| | | httpHeaders.add("Content-Type","application/json"); |
| | | HttpEntity httpEntity = new HttpEntity(body, httpHeaders); |
| | | ResponseEntity<String> response = null; |
| | | try { |
| | | response = outRestTemplate.exchange(url, httpMethod, httpEntity, String.class); |
| | | } catch (HttpStatusCodeException e) { |
| | | logger.error("请求异常", e.getResponseBodyAsString()); |
| | | throw new IllegalArgumentException(e.getResponseBodyAsString()); |
| | | return e.getResponseBodyAsString(); |
| | | } |
| | | |
| | | return response.getBody(); |
| | |
| | | Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区信息"); |
| | | Assert.hasKeyAndValue(reqJson, "machineId", "未包含充电桩"); |
| | | Assert.hasKeyAndValue(reqJson, "portId", "未包含插槽"); |
| | | Assert.hasKeyAndValue(reqJson, "orderId", "未包含订单号"); |
| | | |
| | | String userId = context.getReqHeaders().get("user-id"); |
| | | Assert.hasLength(userId, "用户不存在"); |
| | |
| | | chargeMachinePortDto.setPortId(reqJson.getString("portId")); |
| | | List<ChargeMachinePortDto> chargeMachinePortDtos = chargeMachinePortV1InnerServiceSMOImpl.queryChargeMachinePorts(chargeMachinePortDto); |
| | | |
| | | String orderId = reqJson.getString("orderId"); |
| | | //调用充电桩充电 |
| | | ResultVo resultVo = chargeCoreImpl.stopCharge(chargeMachineDtos.get(0), chargeMachinePortDtos.get(0)); |
| | | |
| | |
| | | exclusions.append("/app/chargeMachine.listChargeMachinePort,");//查询充电桩 |
| | | |
| | | exclusions.append("/app/smartMeter/notify/*,");// 智能水电表通知放开 |
| | | exclusions.append("/equipments/*,");// 叮叮充电桩通知放开 |
| | | exclusions.append("/app/equipments/*,");// 叮叮充电桩通知放开 |
| | | exclusions.append("/app/charge/*,");// 通用充电桩通知放开 |
| | | |
| | | |
| | |
| | | import java.util.Base64; |
| | | |
| | | /** |
| | | * http://demo.homecommunity.cn/app/equipments/{id}/{port}/finish |
| | | * <p> |
| | | * 需要给叮叮厂家提供 |
| | | * http://demo.homecommunity.cn/app |
| | | * 注意demo.homecommunity.cn 改成自己的域名 |
| | | * 叮叮充电桩 结束充电回调处理类 |
| | | */ |
| | | @RestController |
| | | @RequestMapping(path = "/equipments") |
| | | @RequestMapping(path = "/app/equipments") |
| | | public class NotifyDingDingChargeController extends BaseController { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(NotifyDingDingChargeController.class); |
| | |
| | | @PathVariable String port, |
| | | @RequestBody String postInfo, |
| | | HttpServletRequest request) { |
| | | if (!validateSign(request)) { |
| | | if (!validateSign(request, "/equipments/" + id + "/" + port + "/finish", postInfo)) { |
| | | return new ResponseEntity<>("{\n" + |
| | | "\"code\" : -1,\n" + |
| | | "\"msg\" : \"鉴权失败\"\n" + |
| | |
| | | notifyChargeOrderDto.setBodyParam(postInfo); |
| | | notifyChargeOrderDto.setReason(param.getString("typeName")); |
| | | |
| | | |
| | | ResultVo resultVo = notifyChargeV1InnerServiceSMOImpl.finishCharge(notifyChargeOrderDto); |
| | | ResultVo resultVo = null; |
| | | resultVo = notifyChargeV1InnerServiceSMOImpl.finishCharge(notifyChargeOrderDto); |
| | | |
| | | if (resultVo.getCode() == ResultVo.CODE_OK) { |
| | | resultVo.setCode(200); |
| | |
| | | @PathVariable String id, |
| | | @RequestBody String postInfo, |
| | | HttpServletRequest request) { |
| | | if (!validateSign(request)) { |
| | | if (!validateSign(request, "/equipments/" + id + "/event", postInfo)) { |
| | | return new ResponseEntity<>("{\n" + |
| | | "\"code\" : -1,\n" + |
| | | "\"msg\" : \"鉴权失败\"\n" + |
| | |
| | | |
| | | } |
| | | |
| | | private boolean validateSign(HttpServletRequest request) { |
| | | String appId = request.getParameter("appid"); |
| | | String timestamp = request.getParameter("timestamp"); |
| | | String sign = request.getParameter("sign"); |
| | | private boolean validateSign(HttpServletRequest request, String url, String postInfo) { |
| | | String appId = request.getHeader("appid"); |
| | | String timestamp = request.getHeader("timestamp"); |
| | | String sign = request.getHeader("sign"); |
| | | String secret = MappingCache.getValue(DING_DING_DOMAIN, DING_DING_APP_SECURE); |
| | | String data = "appid=" + appId + "×tamp=" + timestamp; |
| | | String data = "appid=" + appId + "&content=" + postInfo + "×tamp=" + timestamp + "&uri=" + url; |
| | | SecretKey secretKey = new SecretKeySpec(secret.getBytes(), "HmacMD5"); |
| | | Mac mac = null; |
| | | try { |