DatabusAdaptImpl.java 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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;
  17. import com.alibaba.fastjson.JSONObject;
  18. import com.java110.core.client.RestTemplate;
  19. import com.java110.core.factory.WechatFactory;
  20. import com.java110.core.log.LoggerFactory;
  21. import com.java110.dto.data.DatabusDataDto;
  22. import com.java110.dto.machine.CarInoutDto;
  23. import com.java110.dto.machine.MachineDto;
  24. import com.java110.dto.wechat.SmallWeChatDto;
  25. import com.java110.dto.wechat.TemplateDataDto;
  26. import com.java110.dto.wechat.SmallWechatAttrDto;
  27. import com.java110.dto.fee.TempCarPayOrderDto;
  28. import com.java110.dto.system.Business;
  29. import com.java110.intf.store.ISmallWeChatInnerServiceSMO;
  30. import com.java110.intf.store.ISmallWechatAttrInnerServiceSMO;
  31. import com.java110.job.adapt.hcIot.GetToken;
  32. import com.java110.vo.ResultVo;
  33. import org.slf4j.Logger;
  34. import org.springframework.beans.factory.annotation.Autowired;
  35. import org.springframework.http.HttpHeaders;
  36. import java.util.List;
  37. /**
  38. * @desc add by 吴学文 15:21
  39. */
  40. public abstract class DatabusAdaptImpl implements IDatabusAdapt {
  41. private static Logger logger = LoggerFactory.getLogger(DatabusAdaptImpl.class);
  42. @Autowired
  43. private ISmallWeChatInnerServiceSMO smallWeChatInnerServiceSMOImpl;
  44. @Autowired
  45. private ISmallWechatAttrInnerServiceSMO smallWechatAttrInnerServiceSMOImpl;
  46. /**
  47. * 封装头信息
  48. *
  49. * @return
  50. */
  51. protected HttpHeaders getHeaders(RestTemplate outRestTemplate) {
  52. HttpHeaders httpHeaders = new HttpHeaders();
  53. httpHeaders.add("access_token", GetToken.get(outRestTemplate, false));
  54. //httpHeaders.add("Content-Type", "application/x-www-form-urlencoded");
  55. return httpHeaders;
  56. }
  57. /**
  58. * 开门
  59. *
  60. * @param paramIn 业务信息
  61. * @return
  62. */
  63. @Override
  64. public ResultVo openDoor(JSONObject paramIn) {
  65. return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
  66. }
  67. /**
  68. * 开门
  69. *
  70. * @param paramIn 业务信息
  71. * @return
  72. */
  73. @Override
  74. public ResultVo closeDoor(JSONObject paramIn) {
  75. return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
  76. }
  77. @Override
  78. public ResultVo getQRcode(JSONObject reqJson) {
  79. return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
  80. }
  81. @Override
  82. public ResultVo customCarInOut(JSONObject reqJson) {
  83. return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
  84. }
  85. @Override
  86. public ResultVo payVideo(MachineDto machineDto) {
  87. return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
  88. }
  89. @Override
  90. public ResultVo heartbeatVideo(JSONObject reqJson) {
  91. return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
  92. }
  93. /**
  94. * 重启设备
  95. *
  96. * @param paramIn
  97. * @return
  98. */
  99. @Override
  100. public ResultVo restartMachine(JSONObject paramIn) {
  101. return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
  102. }
  103. /**
  104. * 失败重新送IOT
  105. *
  106. * @param paramIn
  107. * @return
  108. */
  109. @Override
  110. public ResultVo reSendToIot(JSONObject paramIn) {
  111. return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
  112. }
  113. /**
  114. * 查询 临时车待支付订单
  115. *
  116. * @param tempCarPayOrderDto
  117. * @return
  118. */
  119. @Override
  120. public ResultVo getTempCarFeeOrder(TempCarPayOrderDto tempCarPayOrderDto) {
  121. return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
  122. }
  123. /**
  124. * 修改在场车辆车牌号
  125. *
  126. * @param carInoutDto
  127. * @return
  128. */
  129. @Override
  130. public ResultVo updateCarInoutCarNum(CarInoutDto carInoutDto) {
  131. return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
  132. }
  133. /**
  134. * 修改在场车辆车牌号
  135. *
  136. * @param reqJson
  137. * @return
  138. */
  139. @Override
  140. public ResultVo getManualOpenDoorLogs(JSONObject reqJson) {
  141. return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
  142. }
  143. /**
  144. * 修改在场车辆车牌号
  145. *
  146. * @param reqJson
  147. * @return
  148. */
  149. @Override
  150. public ResultVo tempCarAuth(JSONObject reqJson) {
  151. return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
  152. }
  153. /**
  154. * 查询待审核车辆
  155. *
  156. * @param reqJson
  157. * @return
  158. */
  159. @Override
  160. public ResultVo getTempCarAuths(JSONObject reqJson) {
  161. return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
  162. }
  163. /**
  164. * 查询 临时车待支付订单
  165. *
  166. * @param tempCarPayOrderDto
  167. * @return
  168. */
  169. @Override
  170. public ResultVo notifyTempCarFeeOrder(TempCarPayOrderDto tempCarPayOrderDto) {
  171. return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
  172. }
  173. /**
  174. * 业主处理执行
  175. *
  176. * @param business 当前处理业务
  177. * @param businesses 所有业务信息
  178. */
  179. @Override
  180. public void execute(Business business, List<Business> businesses) throws Exception {
  181. }
  182. /**
  183. * 查询模板信息
  184. * @param communityId
  185. * @param specCd
  186. * @return
  187. */
  188. protected TemplateDataDto getOwnerTemplateId(String communityId, String specCd){
  189. SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
  190. smallWeChatDto.setWeChatType("1100");
  191. smallWeChatDto.setObjType(SmallWeChatDto.OBJ_TYPE_COMMUNITY);
  192. smallWeChatDto.setObjId(communityId);
  193. List<SmallWeChatDto> smallWeChatDtos = smallWeChatInnerServiceSMOImpl.querySmallWeChats(smallWeChatDto);
  194. if (smallWeChatDto == null || smallWeChatDtos.size() <= 0) {
  195. logger.info("未配置微信公众号信息,定时任务执行结束");
  196. return null;
  197. }
  198. SmallWeChatDto weChatDto = smallWeChatDtos.get(0);
  199. SmallWechatAttrDto smallWechatAttrDto = new SmallWechatAttrDto();
  200. smallWechatAttrDto.setCommunityId(communityId);
  201. smallWechatAttrDto.setWechatId(weChatDto.getWeChatId());
  202. smallWechatAttrDto.setSpecCd(specCd);
  203. List<SmallWechatAttrDto> smallWechatAttrDtos = smallWechatAttrInnerServiceSMOImpl.querySmallWechatAttrs(smallWechatAttrDto);
  204. if (smallWechatAttrDtos == null || smallWechatAttrDtos.size() <= 0) {
  205. logger.info("未配置微信公众号消息模板");
  206. return null;
  207. }
  208. String templateId = smallWechatAttrDtos.get(0).getValue();
  209. String accessToken = WechatFactory.getAccessToken(weChatDto.getAppId(), weChatDto.getAppSecret());
  210. return new TemplateDataDto(templateId,accessToken,smallWeChatDtos.get(0).getAppId());
  211. }
  212. }