GetTempCarFeeOrderAdapt.java 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Copyright 2017-2020 吴学文 and java110 team.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.java110.job.adapt.hcIot;
  17. import com.alibaba.fastjson.JSONObject;
  18. import com.java110.core.client.RestTemplate;
  19. import com.java110.core.factory.GenerateCodeFactory;
  20. import com.java110.dto.machine.CarInoutDto;
  21. import com.java110.dto.tempCarFeeConfig.TempCarPayOrderDto;
  22. import com.java110.intf.common.IMachineInnerServiceSMO;
  23. import com.java110.intf.common.IMachineTranslateInnerServiceSMO;
  24. import com.java110.intf.user.IOwnerInnerServiceSMO;
  25. import com.java110.intf.user.IUserInnerServiceSMO;
  26. import com.java110.job.adapt.DatabusAdaptImpl;
  27. import com.java110.vo.ResultVo;
  28. import org.springframework.beans.factory.annotation.Autowired;
  29. import org.springframework.http.HttpEntity;
  30. import org.springframework.http.HttpMethod;
  31. import org.springframework.http.HttpStatus;
  32. import org.springframework.http.ResponseEntity;
  33. import org.springframework.stereotype.Component;
  34. import org.springframework.util.MultiValueMap;
  35. /**
  36. * 查询临时停车费订单
  37. * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
  38. *
  39. * @desc add by 吴学文 15:29
  40. */
  41. @Component(value = "getTempCarFeeOrderAdapt")
  42. public class GetTempCarFeeOrderAdapt extends DatabusAdaptImpl {
  43. @Autowired
  44. RestTemplate outRestTemplate;
  45. @Autowired
  46. private IMachineInnerServiceSMO machineInnerServiceSMOImpl;
  47. @Autowired
  48. private IUserInnerServiceSMO userInnerServiceSMOImpl;
  49. @Autowired
  50. private IMachineTranslateInnerServiceSMO machineTranslateInnerServiceSMOImpl;
  51. @Autowired
  52. private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
  53. /**
  54. * 获取历史停车费订单
  55. *
  56. * @param tempCarPayOrderDto 业务信息
  57. * @return
  58. */
  59. @Override
  60. public ResultVo getTempCarFeeOrder(TempCarPayOrderDto tempCarPayOrderDto) {
  61. JSONObject postParameters = new JSONObject();
  62. postParameters.put("taskId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_machineTranslateId));
  63. postParameters.put("carNum", tempCarPayOrderDto.getCarNum());
  64. postParameters.put("extPaId", tempCarPayOrderDto.getPaId());
  65. postParameters.put("extPccIds",tempCarPayOrderDto.getPccIds());
  66. HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters.toJSONString(), getHeaders(outRestTemplate));
  67. ResponseEntity<String> responseEntity = outRestTemplate.exchange(IotConstant.getUrl(IotConstant.GET_TEMP_CAR_FEE_ORDER), HttpMethod.POST, httpEntity, String.class);
  68. if (responseEntity.getStatusCode() != HttpStatus.OK) {
  69. return new ResultVo(ResultVo.CODE_ERROR, responseEntity.getBody());
  70. }
  71. JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
  72. return new ResultVo(paramOut.getInteger("code"), paramOut.getString("msg"), paramOut.getJSONObject("data"));
  73. }
  74. /**
  75. * 修改在场车辆车牌号
  76. *
  77. * @param carInoutDto
  78. * @return
  79. */
  80. @Override
  81. public ResultVo updateCarInoutCarNum(CarInoutDto carInoutDto) {
  82. JSONObject postParameters = new JSONObject();
  83. postParameters.put("taskId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_machineTranslateId));
  84. postParameters.put("carNum", carInoutDto.getCarNum());
  85. postParameters.put("oldCarNum", carInoutDto.getOldCarNum());
  86. postParameters.put("extPaId", carInoutDto.getPaId());
  87. HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters.toJSONString(), getHeaders(outRestTemplate));
  88. ResponseEntity<String> responseEntity = outRestTemplate.exchange(IotConstant.getUrl(IotConstant.UPDATE_CAR_INOUT_CAR_NUM), HttpMethod.POST, httpEntity, String.class);
  89. if (responseEntity.getStatusCode() != HttpStatus.OK) {
  90. return new ResultVo(ResultVo.CODE_ERROR, responseEntity.getBody());
  91. }
  92. JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
  93. return new ResultVo(paramOut.getInteger("code"), paramOut.getString("msg"), paramOut.getJSONObject("data"));
  94. }
  95. /**
  96. * 修改在场车辆车牌号
  97. *
  98. * @param reqJson
  99. * @return
  100. */
  101. @Override
  102. public ResultVo getManualOpenDoorLogs(JSONObject reqJson) {
  103. reqJson.put("taskId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_machineTranslateId));
  104. HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(reqJson.toJSONString(), getHeaders(outRestTemplate));
  105. ResponseEntity<String> responseEntity = outRestTemplate.exchange(IotConstant.getUrl(IotConstant.GET_MANUAL_OPEN_DOOR_LOGS), HttpMethod.POST, httpEntity, String.class);
  106. if (responseEntity.getStatusCode() != HttpStatus.OK) {
  107. return new ResultVo(ResultVo.CODE_ERROR, responseEntity.getBody());
  108. }
  109. JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
  110. return new ResultVo(paramOut.getInteger("code"), paramOut.getString("msg"), paramOut.getJSONArray("data"));
  111. }
  112. }