| New file |
| | |
| | | package com.java110.api.bmo; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.factory.DataFlowFactory; |
| | | import com.java110.entity.center.AppService; |
| | | import com.java110.event.service.api.ServiceDataFlowEvent; |
| | | import com.java110.utils.constant.CommonConstant; |
| | | import com.java110.utils.constant.ServiceCodeConstant; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.*; |
| | | import org.springframework.web.client.HttpStatusCodeException; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.Map; |
| | | |
| | | public class ApiBaseBMO implements IApiBaseBMO{ |
| | | |
| | | protected static final int DEFAULT_ORDER = 1; |
| | | //默认序列 |
| | | protected static final int DEFAULT_SEQ = 1; |
| | | |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplateNoLoadBalanced; |
| | | |
| | | /** |
| | | * 调用下游服务 |
| | | * |
| | | * @param event |
| | | * @return |
| | | */ |
| | | protected ResponseEntity<String> callService(ServiceDataFlowEvent event) { |
| | | |
| | | DataFlowContext dataFlowContext = event.getDataFlowContext(); |
| | | AppService service = event.getAppService(); |
| | | return callService(dataFlowContext, service, dataFlowContext.getReqJson()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 调用下游服务 |
| | | * |
| | | * @param context |
| | | * @param serviceCode 下游服务 |
| | | * @return |
| | | */ |
| | | public ResponseEntity<String> callService(DataFlowContext context, String serviceCode,JSONArray businesses) { |
| | | JSONObject paramInObj = restToCenterProtocol(businesses, context.getRequestCurrentHeaders()); |
| | | //将 rest header 信息传递到下层服务中去 |
| | | HttpHeaders header = new HttpHeaders(); |
| | | freshHttpHeader(header, context.getRequestCurrentHeaders()); |
| | | |
| | | ResponseEntity responseEntity = null; |
| | | AppService appService = DataFlowFactory.getService(context.getAppId(), serviceCode); |
| | | if (appService == null) { |
| | | responseEntity = new ResponseEntity<String>("当前没有权限访问" + ServiceCodeConstant.SERVICE_CODE_QUERY_STORE_USERS, HttpStatus.UNAUTHORIZED); |
| | | context.setResponseEntity(responseEntity); |
| | | return responseEntity; |
| | | } |
| | | return callService(context, appService, paramInObj); |
| | | } |
| | | |
| | | /** |
| | | * 调用下游服务 |
| | | * |
| | | * @param context |
| | | * @param appService 下游服务 |
| | | * @return |
| | | */ |
| | | protected ResponseEntity<String> callService(DataFlowContext context, AppService appService, Map paramIn) { |
| | | |
| | | context.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD, "D"); |
| | | |
| | | ResponseEntity responseEntity = null; |
| | | if (paramIn == null || paramIn.isEmpty()) { |
| | | paramIn = context.getReqJson(); |
| | | } |
| | | |
| | | |
| | | RestTemplate tmpRestTemplate = appService.getServiceCode().startsWith("out.") ? restTemplateNoLoadBalanced : restTemplate; |
| | | |
| | | String serviceUrl = appService.getUrl(); |
| | | HttpEntity<String> httpEntity = null; |
| | | HttpHeaders header = new HttpHeaders(); |
| | | for (String key : context.getRequestCurrentHeaders().keySet()) { |
| | | if (CommonConstant.HTTP_SERVICE.toLowerCase().equals(key.toLowerCase())) { |
| | | continue; |
| | | } |
| | | header.add(key, context.getRequestCurrentHeaders().get(key)); |
| | | } |
| | | header.add(CommonConstant.HTTP_SERVICE.toLowerCase(), appService.getServiceCode()); |
| | | try { |
| | | if (CommonConstant.HTTP_METHOD_GET.equals(appService.getMethod())) { |
| | | serviceUrl += "?"; |
| | | for (Object key : paramIn.keySet()) { |
| | | serviceUrl += (key + "=" + paramIn.get(key) + "&"); |
| | | } |
| | | |
| | | if (serviceUrl.endsWith("&")) { |
| | | serviceUrl = serviceUrl.substring(0, serviceUrl.lastIndexOf("&")); |
| | | } |
| | | httpEntity = new HttpEntity<String>("", header); |
| | | responseEntity = tmpRestTemplate.exchange(serviceUrl, HttpMethod.GET, httpEntity, String.class); |
| | | } else if (CommonConstant.HTTP_METHOD_PUT.equals(appService.getMethod())) { |
| | | httpEntity = new HttpEntity<String>(JSONObject.toJSONString(paramIn), header); |
| | | responseEntity = tmpRestTemplate.exchange(serviceUrl, HttpMethod.PUT, httpEntity, String.class); |
| | | } else if (CommonConstant.HTTP_METHOD_DELETE.equals(appService.getMethod())) { |
| | | httpEntity = new HttpEntity<String>(JSONObject.toJSONString(paramIn), header); |
| | | responseEntity = tmpRestTemplate.exchange(serviceUrl, HttpMethod.DELETE, httpEntity, String.class); |
| | | } else { |
| | | httpEntity = new HttpEntity<String>(JSONObject.toJSONString(paramIn), header); |
| | | responseEntity = tmpRestTemplate.exchange(serviceUrl, HttpMethod.POST, httpEntity, String.class); |
| | | } |
| | | } catch (HttpStatusCodeException e) { //这里spring 框架 在4XX 或 5XX 时抛出 HttpServerErrorException 异常,需要重新封装一下 |
| | | responseEntity = new ResponseEntity<String>( e.getResponseBodyAsString(), e.getStatusCode()); |
| | | } |
| | | return responseEntity; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 将rest 协议转为 订单协议 |
| | | * |
| | | * @param businesses 多个业务 |
| | | * @param headers 订单头信息 |
| | | * @return |
| | | */ |
| | | protected JSONObject restToCenterProtocol(JSONArray businesses, Map<String, String> headers) { |
| | | |
| | | JSONObject centerProtocol = JSONObject.parseObject("{\"orders\":{},\"business\":[]}"); |
| | | freshOrderProtocol(centerProtocol.getJSONObject("orders"), headers); |
| | | centerProtocol.put("business", businesses); |
| | | return centerProtocol; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 将rest 协议转为 订单协议 |
| | | * |
| | | * @param business |
| | | * @return |
| | | */ |
| | | protected JSONObject restToCenterProtocol(JSONObject business, Map<String, String> headers) { |
| | | |
| | | JSONObject centerProtocol = JSONObject.parseObject("{\"orders\":{},\"business\":[]}"); |
| | | freshOrderProtocol(centerProtocol.getJSONObject("orders"), headers); |
| | | centerProtocol.getJSONArray("business").add(business); |
| | | return centerProtocol; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 刷入order信息 |
| | | * |
| | | * @param orders 订单信息 |
| | | * @param headers 头部信息 |
| | | */ |
| | | protected void freshOrderProtocol(JSONObject orders, Map<String, String> headers) { |
| | | for (String key : headers.keySet()) { |
| | | |
| | | if (CommonConstant.HTTP_APP_ID.equals(key)) { |
| | | orders.put("appId", headers.get(key)); |
| | | } |
| | | if (CommonConstant.HTTP_TRANSACTION_ID.equals(key)) { |
| | | orders.put("transactionId", headers.get(key)); |
| | | } |
| | | if (CommonConstant.HTTP_SIGN.equals(key)) { |
| | | orders.put("sign", headers.get(key)); |
| | | } |
| | | |
| | | if (CommonConstant.HTTP_REQ_TIME.equals(key)) { |
| | | orders.put("requestTime", headers.get(key)); |
| | | } |
| | | if (CommonConstant.HTTP_ORDER_TYPE_CD.equals(key)) { |
| | | orders.put("orderTypeCd", headers.get(key)); |
| | | } |
| | | if (CommonConstant.HTTP_USER_ID.equals(key)) { |
| | | orders.put("userId", headers.get(key)); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 刷入order信息 |
| | | * |
| | | * @param httpHeaders http 头信息 |
| | | * @param headers 头部信息 |
| | | */ |
| | | protected void freshHttpHeader(HttpHeaders httpHeaders, Map<String, String> headers) { |
| | | for (String key : headers.keySet()) { |
| | | |
| | | if (CommonConstant.HTTP_APP_ID.equals(key)) { |
| | | httpHeaders.add("app_id", headers.get(key)); |
| | | } |
| | | if (CommonConstant.HTTP_TRANSACTION_ID.equals(key)) { |
| | | httpHeaders.add("transaction_id", headers.get(key)); |
| | | } |
| | | |
| | | if (CommonConstant.HTTP_REQ_TIME.equals(key)) { |
| | | httpHeaders.add("req_time", headers.get(key)); |
| | | } |
| | | |
| | | if (CommonConstant.HTTP_USER_ID.equals(key)) { |
| | | httpHeaders.add("user_id", headers.get(key)); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.api.bmo; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import org.springframework.http.ResponseEntity; |
| | | |
| | | public interface IApiBaseBMO { |
| | | /** |
| | | * 调用下游服务 |
| | | * |
| | | * @param context |
| | | * @param serviceCode 下游服务 |
| | | * @return |
| | | */ |
| | | ResponseEntity<String> callService(DataFlowContext context, String serviceCode, JSONArray businesses); |
| | | } |
| New file |
| | |
| | | package com.java110.api.bmo.activities; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.bmo.IApiBaseBMO; |
| | | import com.java110.core.context.DataFlowContext; |
| | | |
| | | public interface IActivitiesBMO extends IApiBaseBMO { |
| | | |
| | | /** |
| | | * 添加物业费用 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | JSONObject addHeaderImg(JSONObject paramInJson, DataFlowContext dataFlowContext); |
| | | |
| | | |
| | | /** |
| | | * 添加活动 |
| | | * @param paramInJson |
| | | * @param dataFlowContext |
| | | * @return |
| | | */ |
| | | JSONObject addActivities(JSONObject paramInJson, DataFlowContext dataFlowContext); |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.api.bmo.activities.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.bmo.ApiBaseBMO; |
| | | import com.java110.api.bmo.activities.IActivitiesBMO; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.utils.constant.BusinessTypeConstant; |
| | | import com.java110.utils.constant.CommonConstant; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("activitiesBMOImpl") |
| | | public class ActivitiesBMOImpl extends ApiBaseBMO implements IActivitiesBMO { |
| | | |
| | | /** |
| | | * 添加物业费用 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | public JSONObject addHeaderImg(JSONObject paramInJson, DataFlowContext dataFlowContext) { |
| | | |
| | | |
| | | JSONObject business = JSONObject.parseObject("{\"datas\":{}}"); |
| | | business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FILE_REL); |
| | | business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ + 2); |
| | | business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S); |
| | | JSONObject businessUnit = new JSONObject(); |
| | | businessUnit.put("fileRelId", "-1"); |
| | | businessUnit.put("relTypeCd", "70000"); |
| | | businessUnit.put("saveWay", "table"); |
| | | businessUnit.put("objId", paramInJson.getString("activitiesId")); |
| | | businessUnit.put("fileRealName", paramInJson.getString("headerImg")); |
| | | businessUnit.put("fileSaveName", paramInJson.getString("fileSaveName")); |
| | | business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessFileRel", businessUnit); |
| | | |
| | | return business; |
| | | } |
| | | |
| | | /** |
| | | * 添加小区信息 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | public JSONObject addActivities(JSONObject paramInJson, DataFlowContext dataFlowContext) { |
| | | |
| | | |
| | | JSONObject business = JSONObject.parseObject("{\"datas\":{}}"); |
| | | business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_ACTIVITIES); |
| | | business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ); |
| | | business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S); |
| | | JSONObject businessActivities = new JSONObject(); |
| | | businessActivities.putAll(paramInJson); |
| | | businessActivities.put("readCount","0"); |
| | | businessActivities.put("likeCount","0"); |
| | | businessActivities.put("collectCount","0"); |
| | | businessActivities.put("state","11000"); // 先设置为不审核 |
| | | //businessActivities.put("activitiesId", "-1"); |
| | | //计算 应收金额 |
| | | business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessActivities", businessActivities); |
| | | return business; |
| | | } |
| | | |
| | | } |
| | |
| | | @Autowired |
| | | private RestTemplate restTemplateNoLoadBalanced; |
| | | |
| | | /** |
| | | * 调用下游服务 |
| | | * |
| | | * @param event |
| | | * @return |
| | | */ |
| | | protected ResponseEntity<String> callService(ServiceDataFlowEvent event) { |
| | | |
| | | DataFlowContext dataFlowContext = event.getDataFlowContext(); |
| | | AppService service = event.getAppService(); |
| | | return callService(dataFlowContext, service, dataFlowContext.getReqJson()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 调用下游服务 |
| | | * |
| | | * @param context |
| | | * @param serviceCode 下游服务 |
| | | * @return |
| | | */ |
| | | protected ResponseEntity<String> callService(DataFlowContext context, String serviceCode, Map paramIn) { |
| | | |
| | | ResponseEntity responseEntity = null; |
| | | AppService appService = DataFlowFactory.getService(context.getAppId(), serviceCode); |
| | | if (appService == null) { |
| | | responseEntity = new ResponseEntity<String>("当前没有权限访问" + ServiceCodeConstant.SERVICE_CODE_QUERY_STORE_USERS, HttpStatus.UNAUTHORIZED); |
| | | context.setResponseEntity(responseEntity); |
| | | return responseEntity; |
| | | } |
| | | return callService(context, appService, paramIn); |
| | | } |
| | | |
| | | /** |
| | | * 调用下游服务 |
| | | * |
| | | * @param context |
| | | * @param appService 下游服务 |
| | | * @return |
| | | */ |
| | | protected ResponseEntity<String> callService(DataFlowContext context, AppService appService, Map paramIn) { |
| | | |
| | | ResponseEntity responseEntity = null; |
| | | if (paramIn == null || paramIn.isEmpty()) { |
| | | paramIn = context.getReqJson(); |
| | | } |
| | | |
| | | RestTemplate tmpRestTemplate = appService.getServiceCode().startsWith("out.") ? restTemplateNoLoadBalanced : restTemplate; |
| | | |
| | | String serviceUrl = appService.getUrl(); |
| | | HttpEntity<String> httpEntity = null; |
| | | HttpHeaders header = new HttpHeaders(); |
| | | for (String key : context.getRequestCurrentHeaders().keySet()) { |
| | | if (CommonConstant.HTTP_SERVICE.toLowerCase().equals(key.toLowerCase())) { |
| | | continue; |
| | | } |
| | | header.add(key, context.getRequestCurrentHeaders().get(key)); |
| | | } |
| | | header.add(CommonConstant.HTTP_SERVICE.toLowerCase(), appService.getServiceCode()); |
| | | try { |
| | | if (CommonConstant.HTTP_METHOD_GET.equals(appService.getMethod())) { |
| | | serviceUrl += "?"; |
| | | for (Object key : paramIn.keySet()) { |
| | | serviceUrl += (key + "=" + paramIn.get(key) + "&"); |
| | | } |
| | | |
| | | if (serviceUrl.endsWith("&")) { |
| | | serviceUrl = serviceUrl.substring(0, serviceUrl.lastIndexOf("&")); |
| | | } |
| | | httpEntity = new HttpEntity<String>("", header); |
| | | responseEntity = tmpRestTemplate.exchange(serviceUrl, HttpMethod.GET, httpEntity, String.class); |
| | | } else if (CommonConstant.HTTP_METHOD_PUT.equals(appService.getMethod())) { |
| | | httpEntity = new HttpEntity<String>(JSONObject.toJSONString(paramIn), header); |
| | | responseEntity = tmpRestTemplate.exchange(serviceUrl, HttpMethod.PUT, httpEntity, String.class); |
| | | } else if (CommonConstant.HTTP_METHOD_DELETE.equals(appService.getMethod())) { |
| | | httpEntity = new HttpEntity<String>(JSONObject.toJSONString(paramIn), header); |
| | | responseEntity = tmpRestTemplate.exchange(serviceUrl, HttpMethod.DELETE, httpEntity, String.class); |
| | | } else { |
| | | httpEntity = new HttpEntity<String>(JSONObject.toJSONString(paramIn), header); |
| | | responseEntity = tmpRestTemplate.exchange(serviceUrl, HttpMethod.POST, httpEntity, String.class); |
| | | } |
| | | } catch (HttpStatusCodeException e) { //这里spring 框架 在4XX 或 5XX 时抛出 HttpServerErrorException 异常,需要重新封装一下 |
| | | responseEntity = new ResponseEntity<String>( e.getResponseBodyAsString(), e.getStatusCode()); |
| | | } |
| | | return responseEntity; |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | dataFlowContext.setResponseEntity(newResponseEntity); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 将rest 协议转为 订单协议 |
| | | * |
| | | * @param business |
| | | * @return |
| | | */ |
| | | protected JSONObject restToCenterProtocol(JSONObject business, Map<String, String> headers) { |
| | | |
| | | JSONObject centerProtocol = JSONObject.parseObject("{\"orders\":{},\"business\":[]}"); |
| | | freshOrderProtocol(centerProtocol.getJSONObject("orders"), headers); |
| | | centerProtocol.getJSONArray("business").add(business); |
| | | return centerProtocol; |
| | | } |
| | | |
| | | /** |
| | | * 将rest 协议转为 订单协议 |
| | | * |
| | | * @param businesses 多个业务 |
| | | * @param headers 订单头信息 |
| | | * @return |
| | | */ |
| | | protected JSONObject restToCenterProtocol(JSONArray businesses, Map<String, String> headers) { |
| | | |
| | | JSONObject centerProtocol = JSONObject.parseObject("{\"orders\":{},\"business\":[]}"); |
| | | freshOrderProtocol(centerProtocol.getJSONObject("orders"), headers); |
| | | centerProtocol.put("business", businesses); |
| | | return centerProtocol; |
| | | } |
| | | |
| | | /** |
| | | * 刷入order信息 |
| | | * |
| | | * @param orders 订单信息 |
| | | * @param headers 头部信息 |
| | | */ |
| | | protected void freshOrderProtocol(JSONObject orders, Map<String, String> headers) { |
| | | for (String key : headers.keySet()) { |
| | | |
| | | if (CommonConstant.HTTP_APP_ID.equals(key)) { |
| | | orders.put("appId", headers.get(key)); |
| | | } |
| | | if (CommonConstant.HTTP_TRANSACTION_ID.equals(key)) { |
| | | orders.put("transactionId", headers.get(key)); |
| | | } |
| | | if (CommonConstant.HTTP_SIGN.equals(key)) { |
| | | orders.put("sign", headers.get(key)); |
| | | } |
| | | |
| | | if (CommonConstant.HTTP_REQ_TIME.equals(key)) { |
| | | orders.put("requestTime", headers.get(key)); |
| | | } |
| | | if (CommonConstant.HTTP_ORDER_TYPE_CD.equals(key)) { |
| | | orders.put("orderTypeCd", headers.get(key)); |
| | | } |
| | | if (CommonConstant.HTTP_USER_ID.equals(key)) { |
| | | orders.put("userId", headers.get(key)); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 刷入order信息 |
| | | * |
| | | * @param httpHeaders http 头信息 |
| | | * @param headers 头部信息 |
| | | */ |
| | | protected void freshHttpHeader(HttpHeaders httpHeaders, Map<String, String> headers) { |
| | | for (String key : headers.keySet()) { |
| | | |
| | | if (CommonConstant.HTTP_APP_ID.equals(key)) { |
| | | httpHeaders.add("app_id", headers.get(key)); |
| | | } |
| | | if (CommonConstant.HTTP_TRANSACTION_ID.equals(key)) { |
| | | httpHeaders.add("transaction_id", headers.get(key)); |
| | | } |
| | | |
| | | if (CommonConstant.HTTP_REQ_TIME.equals(key)) { |
| | | httpHeaders.add("req_time", headers.get(key)); |
| | | } |
| | | |
| | | if (CommonConstant.HTTP_USER_ID.equals(key)) { |
| | | httpHeaders.add("user_id", headers.get(key)); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.bmo.activities.IActivitiesBMO; |
| | | import com.java110.api.listener.AbstractServiceApiListener; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.core.smo.file.IFileInnerServiceSMO; |
| | |
| | | |
| | | @Autowired |
| | | private IFileInnerServiceSMO fileInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IActivitiesBMO activitiesBMOImpl; |
| | | |
| | | @Override |
| | | protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) { |
| | | //Assert.hasKeyAndValue(reqJson, "xxx", "xxx"); |
| | | |
| | | Assert.hasKeyAndValue(reqJson, "title", "必填,请填写业活动标题"); |
| | | Assert.hasKeyAndValue(reqJson, "typeCd", "必填,请选择活动类型"); |
| | | Assert.hasKeyAndValue(reqJson, "headerImg", "必填,请选择头部照片"); |
| | |
| | | @Override |
| | | protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) { |
| | | |
| | | HttpHeaders header = new HttpHeaders(); |
| | | context.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD, "D"); |
| | | |
| | | JSONArray businesses = new JSONArray(); |
| | | |
| | | AppService service = event.getAppService(); |
| | | |
| | | reqJson.put("activitiesId",GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_activitiesId)); |
| | | |
| | | |
| | | |
| | | if (reqJson.containsKey("headerImg") && !StringUtils.isEmpty(reqJson.getString("headerImg"))) { |
| | | FileDto fileDto = new FileDto(); |
| | |
| | | reqJson.put("headerImg", fileDto.getFileId()); |
| | | reqJson.put("fileSaveName", fileName); |
| | | |
| | | businesses.add(addHeaderImg(reqJson, context)); |
| | | businesses.add(activitiesBMOImpl.addHeaderImg(reqJson, context)); |
| | | |
| | | } |
| | | |
| | | //添加单元信息 |
| | | businesses.add(addActivities(reqJson, context)); |
| | | businesses.add(activitiesBMOImpl.addActivities(reqJson, context)); |
| | | |
| | | JSONObject paramInObj = super.restToCenterProtocol(businesses, context.getRequestCurrentHeaders()); |
| | | |
| | | //将 rest header 信息传递到下层服务中去 |
| | | super.freshHttpHeader(header, context.getRequestCurrentHeaders()); |
| | | |
| | | ResponseEntity<String> responseEntity = this.callService(context, service.getServiceCode(), paramInObj); |
| | | ResponseEntity<String> responseEntity = activitiesBMOImpl.callService(context, service.getServiceCode(), businesses); |
| | | |
| | | context.setResponseEntity(responseEntity); |
| | | } |
| | | |
| | | /** |
| | | * 添加物业费用 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | private JSONObject addHeaderImg(JSONObject paramInJson, DataFlowContext dataFlowContext) { |
| | | |
| | | |
| | | JSONObject business = JSONObject.parseObject("{\"datas\":{}}"); |
| | | business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FILE_REL); |
| | | business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ + 2); |
| | | business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S); |
| | | JSONObject businessUnit = new JSONObject(); |
| | | businessUnit.put("fileRelId", "-1"); |
| | | businessUnit.put("relTypeCd", "70000"); |
| | | businessUnit.put("saveWay", "table"); |
| | | businessUnit.put("objId", paramInJson.getString("activitiesId")); |
| | | businessUnit.put("fileRealName", paramInJson.getString("headerImg")); |
| | | businessUnit.put("fileSaveName", paramInJson.getString("fileSaveName")); |
| | | business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessFileRel", businessUnit); |
| | | |
| | | return business; |
| | | } |
| | | |
| | | @Override |
| | | public String getServiceCode() { |
| | |
| | | public int getOrder() { |
| | | return DEFAULT_ORDER; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加小区信息 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | private JSONObject addActivities(JSONObject paramInJson, DataFlowContext dataFlowContext) { |
| | | |
| | | |
| | | JSONObject business = JSONObject.parseObject("{\"datas\":{}}"); |
| | | business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_ACTIVITIES); |
| | | business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ); |
| | | business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S); |
| | | JSONObject businessActivities = new JSONObject(); |
| | | businessActivities.putAll(paramInJson); |
| | | businessActivities.put("readCount","0"); |
| | | businessActivities.put("likeCount","0"); |
| | | businessActivities.put("collectCount","0"); |
| | | businessActivities.put("state","11000"); // 先设置为不审核 |
| | | //businessActivities.put("activitiesId", "-1"); |
| | | //计算 应收金额 |
| | | business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessActivities", businessActivities); |
| | | return business; |
| | | } |
| | | |
| | | } |