AgentService/src/main/java/com/java110/agent/listener/DeleteAgentAttrListener.java
@@ -42,7 +42,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_DELETE_AGENT_ATTR; } AgentService/src/main/java/com/java110/agent/listener/DeleteAgentCerdentialsListener.java
@@ -45,7 +45,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_DELETE_AGENT_CERDENTIALS; } AgentService/src/main/java/com/java110/agent/listener/DeleteAgentPhotoListener.java
@@ -41,7 +41,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_DELETE_AGENT_PHOTO; } AgentService/src/main/java/com/java110/agent/listener/DeleteAgentUserListener.java
@@ -41,7 +41,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_DELETE_AGENT_USER; } AgentService/src/main/java/com/java110/agent/listener/SaveAgentCerdentialsListener.java
@@ -44,7 +44,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_AGENT_CERDENTIALS; } AgentService/src/main/java/com/java110/agent/listener/SaveAgentInfoListener.java
@@ -38,7 +38,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_AGENT_INFO; } AgentService/src/main/java/com/java110/agent/listener/SaveAgentPhotoListener.java
@@ -40,7 +40,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_AGENT_PHOTO; } AgentService/src/main/java/com/java110/agent/listener/SaveAgentUserListener.java
@@ -44,7 +44,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_AGENT_USER; } AgentService/src/main/java/com/java110/agent/listener/UpdateAgentCerdentialsListener.java
@@ -41,7 +41,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_UPDATE_AGENT_CERDENTIALS; } AgentService/src/main/java/com/java110/agent/listener/UpdateAgentInfoListener.java
@@ -42,7 +42,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_UPDATE_AGENT_INFO; } AgentService/src/main/java/com/java110/agent/listener/UpdateAgentPhotoListener.java
@@ -41,7 +41,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_UPDATE_AGENT_PHOTO; } Api/docker/bin/start_api.sh
@@ -1,15 +1,15 @@ #!/bin/bash #### debug model prod #nohup java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n -jar -Dspring.profiles.active=dev target/Api.jar $1 > center.log 2>&1 & #nohup java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n -jar -Dspring.profiles.active=dev target/Api.jar $1 > order.log 2>&1 & #### normal prod model #nohup java -jar -Dspring.profiles.active=prod $1 target/Api.jar > center.log $1 2>&1 & #nohup java -jar -Dspring.profiles.active=prod $1 target/Api.jar > order.log $1 2>&1 & #### normal test model #nohup java -jar -Dspring.profiles.active=test $1 target/Api.jar > center.log $1 2>&1 & #nohup java -jar -Dspring.profiles.active=test $1 target/Api.jar > order.log $1 2>&1 & #### normal dev model #nohup java -jar -Dspring.profiles.active=dev $1 target/Api.jar > center.log $1 2>&1 & #nohup java -jar -Dspring.profiles.active=dev $1 target/Api.jar > order.log $1 2>&1 & nohup java -jar -Dspring.profiles.active=$1 $2 target/Api.jar > center.log $2 2>&1 & tail -100f center.log CenterService/doc/response_protocol.json
File was deleted CommentService/src/main/java/com/java110/comment/listener/DeleteCommentOrSubCommentListener.java
@@ -41,7 +41,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_DELETE_COMMENT_INFO; } CommentService/src/main/java/com/java110/comment/listener/FlushAboutCommentIdListener.java
@@ -28,7 +28,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_COMMENT_INFO; } CommentService/src/main/java/com/java110/comment/listener/SaveCommentAndSubCommentListener.java
@@ -36,7 +36,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_COMMENT_INFO; } CommentService/src/main/java/com/java110/comment/listener/SaveCommentScoreListener.java
@@ -38,7 +38,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_COMMENT_INFO; } CommentService/src/main/java/com/java110/comment/listener/SaveSubCommentAttrListener.java
@@ -38,7 +38,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_COMMENT_INFO; } CommentService/src/main/java/com/java110/comment/listener/SaveSubCommentPhotoListener.java
@@ -38,7 +38,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_COMMENT_INFO; } CommunityService/src/main/java/com/java110/community/listener/MemberJoinedCommunityListener.java
@@ -40,7 +40,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_MEMBER_JOINED_COMMUNITY; } CommunityService/src/main/java/com/java110/community/listener/MemberQuitCommunityListener.java
@@ -40,7 +40,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_MEMBER_QUIT_COMMUNITY; } CommunityService/src/main/java/com/java110/community/listener/SaveCommunityInfoListener.java
@@ -44,7 +44,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_COMMUNITY_INFO; } CommunityService/src/main/java/com/java110/community/listener/UpdateCommunityInfoListener.java
@@ -45,7 +45,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_UPDATE_COMMUNITY_INFO; } OrderService/doc/businessNotifyProtocol.json
File was renamed from CenterService/doc/businessNotifyProtocol.json @@ -12,7 +12,7 @@ "message": "éè¯¯æ¶æ¯" }, "bId":"12345678", "serviceCode": "querycustinfo" "businessTypeCd": "D" //å ¶ä»å段 } } OrderService/doc/businessRequestProtocol.json
OrderService/doc/businessResponseProtocol.json
OrderService/doc/business_interface/request_business.json
OrderService/doc/business_interface/request_delete_instance.json
OrderService/doc/business_interface/request_instance.json
OrderService/doc/business_interface/response_business.json
OrderService/doc/business_interface/response_instance.json
OrderService/doc/centerService.docxBinary files differ
OrderService/doc/centerService.pngOrderService/doc/centerServiceTestDocument.docxBinary files differ
OrderService/doc/encrypt_decrypt.txt
OrderService/doc/orderStatusNotifyProtocol.json
OrderService/doc/request_protocol.json
File was renamed from CenterService/doc/request_protocol.json @@ -1,12 +1,14 @@ header: "appId": "å¤ç³»ç»IDï¼åé å¾å°", "transactionId": "100000000020180409224736000001", "requestTime": "20180409224736", "userId": "ç¨æ·ID" body: { "orders": { "appId": "å¤ç³»ç»IDï¼åé å¾å°", "transactionId": "100000000020180409224736000001", "userId": "ç¨æ·ID", "orders": { "orderTypeCd": "订åç±»å,æ¥è¯¢,åç", "requestTime": "20180409224736", "remark":"夿³¨", "sign": "è¿ä¸ªæå¡æ¯å¦è¦æ±MD5ç¾å", "attrs": [{ "specCd": "é ç½®çåæ®µID", "value": "å ·ä½å¼" @@ -14,9 +16,10 @@ }, // å¦ææ¯æ¹éæ¹å¼ åæ "business":[{....}] "business": { "serviceCode": "queryCustInfo", "serviceName": "æ¥è¯¢å®¢æ·", "businessTypeCd": "B", "invokeModel":"S", "remark": "夿³¨", "seq":1, "datas": { "params": { //è¿ä¸ªåæ¥è¯¢æ¶çåæ° OrderService/doc/response_protocol.json
New file @@ -0,0 +1,8 @@ header: "transactionId": "100000000020180409224736000001", "requestTime": "20180409224736", { "msg":"æå" } OrderService/doc/ϵͳµ÷ÓÃÁ÷³Ìͼ.pngOrderService/docker/Dockerfile
OrderService/docker/bin/start_center.sh
File was renamed from CenterService/docker/bin/start_center.sh @@ -1,15 +1,15 @@ #!/bin/bash #### debug model prod #nohup java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n -jar -Dspring.profiles.active=dev target/CenterService.jar $1 > center.log 2>&1 & #nohup java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n -jar -Dspring.profiles.active=dev target/CenterService.jar $1 > order.log 2>&1 & #### normal prod model #nohup java -jar -Dspring.profiles.active=prod $1 target/CenterService.jar > center.log $1 2>&1 & #nohup java -jar -Dspring.profiles.active=prod $1 target/CenterService.jar > order.log $1 2>&1 & #### normal test model #nohup java -jar -Dspring.profiles.active=test $1 target/CenterService.jar > center.log $1 2>&1 & #nohup java -jar -Dspring.profiles.active=test $1 target/CenterService.jar > order.log $1 2>&1 & #### normal dev model #nohup java -jar -Dspring.profiles.active=dev $1 target/CenterService.jar > center.log $1 2>&1 & #nohup java -jar -Dspring.profiles.active=dev $1 target/CenterService.jar > order.log $1 2>&1 & nohup java -jar -Dspring.profiles.active=$1 $2 target/CenterService.jar > center.log 2>&1 & tail -100f center.log OrderService/docker/docker-compose.yml
OrderService/docker/onStart.sh
OrderService/pom.xml
File was renamed from CenterService/pom.xml @@ -9,7 +9,7 @@ </parent> <modelVersion>4.0.0</modelVersion> <artifactId>CenterService</artifactId> <artifactId>OrderService</artifactId> <name>CenterService</name> <!-- FIXME change it to the project's website --> @@ -52,7 +52,7 @@ </dependencies> <build> <finalName>CenterService</finalName> <finalName>OrderService</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -84,7 +84,7 @@ <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>com.java110.center.CenterServiceApplicationStart</mainClass> <mainClass>com.java110.order.OrderServiceApplicationStart</mainClass> </configuration> </plugin> <plugin> OrderService/src/main/java/com/java110/order/OrderServiceApplicationStart.java
File was renamed from CenterService/src/main/java/com/java110/center/CenterServiceApplicationStart.java @@ -1,11 +1,10 @@ package com.java110.center; package com.java110.order; import com.java110.center.smo.ICenterServiceCacheSMO; import com.java110.order.smo.ICenterServiceCacheSMO; import com.java110.common.factory.ApplicationContextFactory; import com.java110.core.annotation.Java110ListenerDiscovery; import com.java110.core.client.RestTemplate; import com.java110.event.center.DataFlowEventPublishing; import com.java110.event.center.init.EventConfigInit; import com.java110.service.init.ServiceStartInit; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -29,12 +28,12 @@ * @date 2016å¹´8æ6æ¥ * @tag */ @SpringBootApplication(scanBasePackages={"com.java110.service","com.java110.center","com.java110.core","com.java110.event.center","com.java110.cache"}) @SpringBootApplication(scanBasePackages={"com.java110.service","com.java110.order","com.java110.core","com.java110.event.order","com.java110.cache"}) @EnableDiscoveryClient //@EnableConfigurationProperties(EventProperties.class) @Java110ListenerDiscovery(listenerPublishClass = DataFlowEventPublishing.class, basePackages = {"com.java110.center.listener"}) public class CenterServiceApplicationStart { basePackages = {"com.java110.order.listener"}) public class OrderServiceApplicationStart { /** * å®ä¾åRestTemplateï¼éè¿@LoadBalanced注解å¼å¯åè¡¡è´è½½è½å. @@ -60,7 +59,7 @@ } public static void main(String[] args) throws Exception{ ApplicationContext context = SpringApplication.run(CenterServiceApplicationStart.class, args); ApplicationContext context = SpringApplication.run(OrderServiceApplicationStart.class, args); //æå¡å¯å¨å è½½ ServiceStartInit.initSystemConfig(context); OrderService/src/main/java/com/java110/order/api/CacheApi.java
File was renamed from CenterService/src/main/java/com/java110/center/api/CacheApi.java @@ -1,6 +1,6 @@ package com.java110.center.api; package com.java110.order.api; import com.java110.center.smo.ICenterServiceCacheSMO; import com.java110.order.smo.ICenterServiceCacheSMO; import com.java110.common.constant.ResponseConstant; import com.java110.core.base.controller.BaseController; import com.java110.core.factory.DataQueryFactory; OrderService/src/main/java/com/java110/order/api/CenterApi.java
File was renamed from CenterService/src/main/java/com/java110/center/api/CenterApi.java @@ -1,12 +1,11 @@ package com.java110.center.api; package com.java110.order.api; import com.alibaba.fastjson.JSONObject; import com.java110.center.smo.ICenterServiceSMO; import com.java110.order.smo.ICenterServiceSMO; import com.java110.common.constant.ResponseConstant; import com.java110.common.exception.BusinessException; import com.java110.common.util.Assert; import com.java110.core.base.controller.BaseController; import com.java110.core.factory.DataTransactionFactory; import com.java110.event.center.DataFlowEventPublishing; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -19,7 +18,6 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.HashMap; import java.util.Map; @@ -32,6 +30,7 @@ @RestController @Api(value = "ä¸å¿æå¡æ¥å£æå¡è§è") @RequestMapping(path = "/centerApi") @Deprecated public class CenterApi extends BaseController { protected final static Logger logger = LoggerFactory.getLogger(CenterApi.class); OrderService/src/main/java/com/java110/order/api/HttpApi.java
File was renamed from CenterService/src/main/java/com/java110/center/api/HttpApi.java @@ -1,7 +1,7 @@ package com.java110.center.api; package com.java110.order.api; import com.alibaba.fastjson.JSONObject; import com.java110.center.smo.ICenterServiceSMO; import com.java110.order.smo.ICenterServiceSMO; import com.java110.common.constant.ResponseConstant; import com.java110.common.exception.BusinessException; import com.java110.common.util.Assert; OrderService/src/main/java/com/java110/order/api/OrderApi.java
New file @@ -0,0 +1,119 @@ package com.java110.order.api; import com.alibaba.fastjson.JSONObject; import com.java110.common.constant.ResponseConstant; import com.java110.common.exception.BusinessException; import com.java110.common.util.Assert; import com.java110.core.base.controller.BaseController; import com.java110.event.center.DataFlowEventPublishing; import com.java110.order.smo.IOrderServiceSMO; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.Map; /** * @author wux * @create 2019-02-05 ä¸å10:29 * @desc è®¢åæ¥å£æå¡ç±» **/ @RestController @RequestMapping(path = "/orderApi") public class OrderApi extends BaseController { private final static Logger logger = LoggerFactory.getLogger(OrderApi.class); @Autowired private IOrderServiceSMO orderServiceSMOImpl; @RequestMapping(path = "/service",method= RequestMethod.POST) @ApiOperation(value="ä¸å¿æå¡è®¢ååç", notes="test: è¿å 200 表示æå¡åçæåï¼å ¶ä»è¡¨ç¤ºå¤±è´¥") @ApiImplicitParam(paramType="query", name = "orderInfo", value = "订ååçä¿¡æ¯", required = true, dataType = "String") public ResponseEntity<String> servicePost(@RequestBody String orderInfo, HttpServletRequest request) { ResponseEntity<String> responseEntity = null; try { Map<String, String> headers = new HashMap<String, String>(); getRequestInfo(request, headers); logger.debug("订åæå¡è¯·æ±æ¥æä¸º: {},请æ±å¤´ä¸º:{}",orderInfo,headers); //æ¥å请æ±äºä»¶ DataFlowEventPublishing.receiveRequest(orderInfo,headers); //颿 ¡éª preValiateOrderInfo(orderInfo); responseEntity = orderServiceSMOImpl.service(orderInfo, headers); }catch (Exception e){ logger.error("请æ±è®¢åå¼å¸¸",e); responseEntity = new ResponseEntity<String>("请æ±ä¸å¿æå¡åçå¼å¸¸ï¼"+e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); }finally { logger.debug("订åæå¡è¿åæ¥æä¸º: {}",responseEntity); return responseEntity; } } /** * è¿é颿 ¡éªï¼è¯·æ±æ¥æä¸ä¸è½æ dataFlowId * @param orderInfo */ private void preValiateOrderInfo(String orderInfo) { Assert.jsonObjectHaveKey(orderInfo,"orders","è¯·æ±æ¥æä¸æªå å«ordersèç¹ï¼"+orderInfo); Assert.jsonObjectHaveKey(orderInfo,"business","è¯·æ±æ¥æä¸æªå å«businessèç¹ï¼"+orderInfo); if(JSONObject.parseObject(orderInfo).getJSONObject("orders").containsKey("dataFlowId")){ throw new BusinessException(ResponseConstant.RESULT_CODE_ERROR,"æ¥æä¸ä¸è½åå¨dataFlowIdèç¹"); } } /** * è¿é颿 ¡éªï¼è¯·æ±æ¥æä¸ä¸è½æ dataFlowId * @param orderInfo */ private void preValiateOrderInfo(String orderInfo,Map<String, String> headers) { Assert.hasKey(headers,"serviceCode","没æå å«serviceCode"); Assert.hasLength(headers.get("serviceCode"),"serviceCode ä¸è½ä¸ºç©º"); Assert.hasKey(headers,"appId","没æå å«appId"); Assert.hasLength(headers.get("appId"),"appId ä¸è½ä¸ºç©º"); } /** * è·å请æ±ä¿¡æ¯ * @param request * @param headers * @throws RuntimeException */ private void getRequestInfo(HttpServletRequest request,Map headers) throws Exception{ try{ super.initHeadParam(request,headers); super.initUrlParam(request,headers); }catch (Exception e){ logger.error("å 载头信æ¯å¤±è´¥",e); throw e; } } public IOrderServiceSMO getOrderServiceSMOImpl() { return orderServiceSMOImpl; } public void setOrderServiceSMOImpl(IOrderServiceSMO orderServiceSMOImpl) { this.orderServiceSMOImpl = orderServiceSMOImpl; } } OrderService/src/main/java/com/java110/order/dao/ICenterServiceDAO.java
File was renamed from CenterService/src/main/java/com/java110/center/dao/ICenterServiceDAO.java @@ -1,4 +1,4 @@ package com.java110.center.dao; package com.java110.order.dao; import com.java110.common.exception.DAOException; import com.java110.entity.mapping.Mapping; @@ -76,6 +76,13 @@ public void completeOrderByBId(String bId) throws DAOException; /** * 彿æä¸å¡å¨ä½æ¯å¦é½æ¯Cï¼å°è®¢åä¿¡æ¯æ¹ä¸º C * @param oId * @return * @throws DAOException */ public void completeOrderByOId(String oId) throws DAOException; /** * 夿 business è¿ç¨æ¯å¦å®æ 1 è¡¨ç¤ºå®æ 0表示æªå®æ * @param oId * @return OrderService/src/main/java/com/java110/order/dao/impl/CenterServiceDAOImpl.java
File was renamed from CenterService/src/main/java/com/java110/center/dao/impl/CenterServiceDAOImpl.java @@ -1,7 +1,7 @@ package com.java110.center.dao.impl; package com.java110.order.dao.impl; import com.alibaba.fastjson.JSONObject; import com.java110.center.dao.ICenterServiceDAO; import com.java110.order.dao.ICenterServiceDAO; import com.java110.common.constant.ResponseConstant; import com.java110.common.exception.DAOException; import com.java110.core.base.dao.BaseServiceDao; @@ -169,6 +169,23 @@ } /** * 彿æä¸å¡å¨ä½æ¯å¦é½æ¯Cï¼å°è®¢åä¿¡æ¯æ¹ä¸º C * @param oId * @return * @throws DAOException */ public void completeOrderByOId(String oId) throws DAOException{ logger.debug("----ãCenterServiceDAOImpl.completeOrderByOIdãæ°æ®å ¥å : " + oId); int updateFlag = sqlSessionTemplate.update("centerServiceDAOImpl.completeOrderByOId",oId); if(updateFlag < 1){ //throw new DAOException(ResponseConstant.RESULT_CODE_INNER_ERROR,"å½åä¸å¡è¿æ²¡æå ¨å®æï¼Cï¼ï¼"+ bId); logger.debug("å½åä¸å¡è¿æ²¡æå ¨å®æï¼Cï¼:"+oId); } } /** * 夿 business è¿ç¨æ¯å¦å®æ 1 è¡¨ç¤ºå®æ 0表示æªå®æ * @param oId * @return OrderService/src/main/java/com/java110/order/kaka/CenserServiceKafkaListener.java
File was renamed from CenterService/src/main/java/com/java110/center/kaka/CenserServiceKafkaListener.java @@ -1,7 +1,8 @@ package com.java110.center.kaka; package com.java110.order.kaka; import com.java110.center.smo.ICenterServiceSMO; import com.java110.core.base.AppBase; import com.java110.order.smo.ICenterServiceSMO; import com.java110.order.smo.IOrderServiceSMO; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -18,21 +19,21 @@ @Autowired private ICenterServiceSMO centerServiceSMOImpl; private IOrderServiceSMO orderServiceSMOImpl; @KafkaListener(topics = {"NOTIFY_CENTER_SERVICE"}) public void listen(ConsumerRecord<?, ?> record) { logger.info("kafkaçkey: " + record.key()); logger.info("kafkaçvalue: " + record.value().toString()); centerServiceSMOImpl.receiveBusinessSystemNotifyMessage(record.value().toString()); orderServiceSMOImpl.receiveBusinessSystemNotifyMessage(record.value().toString()); } public ICenterServiceSMO getCenterServiceSMOImpl() { return centerServiceSMOImpl; public IOrderServiceSMO getOrderServiceSMOImpl() { return orderServiceSMOImpl; } public void setCenterServiceSMOImpl(ICenterServiceSMO centerServiceSMOImpl) { this.centerServiceSMOImpl = centerServiceSMOImpl; public void setOrderServiceSMOImpl(IOrderServiceSMO orderServiceSMOImpl) { this.orderServiceSMOImpl = orderServiceSMOImpl; } } OrderService/src/main/java/com/java110/order/kaka/CenterServiceBean.java
File was renamed from CenterService/src/main/java/com/java110/center/kaka/CenterServiceBean.java @@ -1,4 +1,4 @@ package com.java110.center.kaka; package com.java110.order.kaka; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; OrderService/src/main/java/com/java110/order/listener/DealUserIdListener.java
File was renamed from CenterService/src/main/java/com/java110/center/listener/DealUserIdListener.java @@ -1,9 +1,10 @@ package com.java110.center.listener; package com.java110.order.listener; import com.java110.common.constant.ResponseConstant; import com.java110.common.exception.ListenerExecuteException; import com.java110.core.annotation.Java110Listener; import com.java110.core.context.DataFlow; import com.java110.core.context.IOrderDataFlowContext; import com.java110.event.app.order.Ordered; import com.java110.event.center.event.InvokeBusinessSystemEvent; import com.java110.event.center.listener.DataFlowListener; @@ -22,8 +23,8 @@ @Override public void soService(InvokeBusinessSystemEvent event) { DataFlow dataFlow = event.getDataFlow(); if (dataFlow == null || dataFlow.getBusinesses() == null || dataFlow.getBusinesses().size() == 0){ IOrderDataFlowContext dataFlow = event.getDataFlow(); if (dataFlow == null || dataFlow.getBusinessList() == null || dataFlow.getBusinessList().size() == 0){ throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"ç¨æ·IDå¤ç侦嬿§è¡å¼å¸¸ï¼æ²¡æå¯å¤ççbusiness"); } OrderService/src/main/java/com/java110/order/listener/ReceiveRequestListener.java
File was renamed from CenterService/src/main/java/com/java110/center/listener/ReceiveRequestListener.java @@ -1,4 +1,4 @@ package com.java110.center.listener; package com.java110.order.listener; import com.java110.core.annotation.Java110Listener; import com.java110.event.app.order.Ordered; OrderService/src/main/java/com/java110/order/smo/ICenterServiceCacheSMO.java
File was renamed from CenterService/src/main/java/com/java110/center/smo/ICenterServiceCacheSMO.java @@ -1,4 +1,4 @@ package com.java110.center.smo; package com.java110.order.smo; import com.java110.entity.service.DataQuery; OrderService/src/main/java/com/java110/order/smo/ICenterServiceSMO.java
File was renamed from CenterService/src/main/java/com/java110/center/smo/ICenterServiceSMO.java @@ -1,9 +1,8 @@ package com.java110.center.smo; package com.java110.order.smo; import com.java110.common.exception.SMOException; import org.springframework.http.ResponseEntity; import javax.servlet.http.HttpServletRequest; import java.util.Map; /** OrderService/src/main/java/com/java110/order/smo/IOrderServiceSMO.java
New file @@ -0,0 +1,27 @@ package com.java110.order.smo; import com.java110.common.exception.SMOException; import org.springframework.http.ResponseEntity; import java.util.Map; /** * ä¸å¿æå¡ SMO ä¸å¡é»è¾æ¥å£ * Created by wuxw on 2018/4/13. */ public interface IOrderServiceSMO { /** * ä¸å¡ç»ä¸å¤çæå¡æ¹æ³ * @param reqJson è¯·æ±æ¥æjson * @return */ public ResponseEntity<String> service(String reqJson, Map<String, String> headers) throws SMOException; /** * æ¥åä¸å¡ç³»ç»éç¥æ¶æ¯ * @param receiveJson æ¥åæ¥æ * @throws SMOException */ public void receiveBusinessSystemNotifyMessage(String receiveJson) throws SMOException; } OrderService/src/main/java/com/java110/order/smo/impl/CenterServiceCacheSMOImpl.java
File was renamed from CenterService/src/main/java/com/java110/center/smo/impl/CenterServiceCacheSMOImpl.java @@ -1,8 +1,10 @@ package com.java110.center.smo.impl; package com.java110.order.smo.impl; import com.alibaba.fastjson.JSONObject; import com.java110.center.dao.ICenterServiceDAO; import com.java110.center.smo.ICenterServiceCacheSMO; import com.java110.common.cache.ServiceBusinessCache; import com.java110.entity.order.ServiceBusiness; import com.java110.order.dao.ICenterServiceDAO; import com.java110.order.smo.ICenterServiceCacheSMO; import com.java110.common.cache.AppRouteCache; import com.java110.common.cache.MappingCache; import com.java110.common.cache.ServiceSqlCache; @@ -55,6 +57,9 @@ //3.0 åè£ ServiceSql flushServiceSql(dataQuery); //4.0 å·æ°ä¸å¡ä¿¡æ¯ flushServiceBusiness(dataQuery); dataQuery.setResponseInfo(DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_SUCCESS,"å·æ°æå")); } @@ -70,6 +75,9 @@ //3.0 åè£ ServiceSql flushServiceSql(headers); //4.0 å·æ°ä¸å¡ä¿¡æ¯ flushServiceBusiness(headers); } /** @@ -85,6 +93,8 @@ //3.0 åè£ ServiceSql doFlushServiceSql(); doFlushServiceBusiness(); } private void checkCacheParam(DataQuery dataQuery) throws SMOException{ @@ -106,6 +116,16 @@ doFlushServiceSql(); } private void flushServiceBusiness(DataQuery dataQuery) { JSONObject params = dataQuery.getRequestParams(); if(!CommonConstant.CACHE_SERVICE_BUSINESS.equals(params.getString(CommonConstant.CACHE_PARAM_NAME))){ return ; } // å·æ° doFlushServiceBusiness(); } /** * 3.0 åè£ ServiceSql */ @@ -118,6 +138,20 @@ } // å·æ° doFlushServiceSql(); } /** * 3.0 åè£ ServiceSql */ private void flushServiceBusiness(Map<String,String> headers) { Assert.hasKey(headers,CommonConstant.CACHE_PARAM,"æªå å«cacheåæ°"+headers.toString()); if(!CommonConstant.CACHE_SERVICE_BUSINESS.equals(headers.get(CommonConstant.CACHE_PARAM)) && !CommonConstant.CACHE_ALL.equals(headers.get(CommonConstant.CACHE_PARAM))){ return ; } // å·æ° doFlushServiceBusiness(); } private void doFlushServiceSql() { @@ -137,6 +171,20 @@ } } private void doFlushServiceBusiness(){ logger.debug("å¼å§å·æ° ServiceBusinessæ°æ®å°redisæ°æ®åºä¸"); List<ServiceBusiness> serviceBusinesses = queryServiceDAOImpl.qureyServiceBusiness(); if(serviceBusinesses == null || serviceBusinesses.size() == 0){ return; } //å é¤åå§æ°æ® ServiceSqlCache.removeData(ServiceBusinessCache._KEY_SERVICE_BUSINESS); //设置ç¼å ServiceBusinessCache.setServiceBusiness(serviceBusinesses); } /** * å·æ° Mapping æ°æ® OrderService/src/main/java/com/java110/order/smo/impl/CenterServiceSMOImpl.java
File was renamed from CenterService/src/main/java/com/java110/center/smo/impl/CenterServiceSMOImpl.java @@ -1,9 +1,9 @@ package com.java110.center.smo.impl; package com.java110.order.smo.impl; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.java110.center.dao.ICenterServiceDAO; import com.java110.center.smo.ICenterServiceSMO; import com.java110.order.dao.ICenterServiceDAO; import com.java110.order.smo.ICenterServiceSMO; import com.java110.common.cache.AppRouteCache; import com.java110.common.cache.MappingCache; import com.java110.common.constant.*; @@ -71,23 +71,23 @@ DataFlowEventPublishing.preValidateData(reqJson,headers); //1.0 åå»ºæ°æ®æµ dataFlow = DataFlowFactory.newInstance(DataFlow.class).builder(reqJson, headers); DataFlowEventPublishing.initDataFlowComplete(dataFlow); //DataFlowEventPublishing.initDataFlowComplete(dataFlow); //2.0 å è½½é ç½®ä¿¡æ¯ initConfigData(dataFlow); DataFlowEventPublishing.loadConfigDataComplete(dataFlow); //DataFlowEventPublishing.loadConfigDataComplete(dataFlow); //3.0 æ ¡éª APPIDæ¯å¦ææéæä½serviceCode judgeAuthority(dataFlow); //4.0 è°ç¨è§åæ ¡éª ruleValidate(dataFlow); DataFlowEventPublishing.ruleValidateComplete(dataFlow); //DataFlowEventPublishing.ruleValidateComplete(dataFlow); //5.0 ä¿å订ååä¸å¡é¡¹ c_orders c_order_attrs c_business c_business_attrs saveOrdersAndBusiness(dataFlow); //6.0 è°ç¨ä¸æ¸¸ç³»ç» DataFlowEventPublishing.invokeBusinessSystem(dataFlow); //DataFlowEventPublishing.invokeBusinessSystem(dataFlow); invokeBusinessSystem(dataFlow); responseJson = DataTransactionFactory.createCommonResponseJson(dataFlow); @@ -149,7 +149,7 @@ AuthenticationFactory.putSign(dataFlow, responseJson); saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestHeaders(),dataFlow.getReqJson().toJSONString()), LogAgent.createLogMessage(dataFlow.getResponseHeaders(),dataFlow.getResJson().toJSONString()),endDate.getTime()-dataFlow.getStartDate().getTime()); DataFlowEventPublishing.dataResponse(dataFlow,reqJson,headers); // DataFlowEventPublishing.dataResponse(dataFlow,reqJson,headers); } resJson = encrypt(responseJson.toJSONString(),headers); //è¿éä¿åèæ¶ï¼ä»¥åæ¥å¿ @@ -175,23 +175,23 @@ DataFlowEventPublishing.preValidateData(reqJson,headers); //1.0 åå»ºæ°æ®æµ dataFlow = DataFlowFactory.newInstance(DataFlow.class).builder(reqJson, headers); DataFlowEventPublishing.initDataFlowComplete(dataFlow); //DataFlowEventPublishing.initDataFlowComplete(dataFlow); //2.0 å è½½é ç½®ä¿¡æ¯ initConfigData(dataFlow); DataFlowEventPublishing.loadConfigDataComplete(dataFlow); //DataFlowEventPublishing.loadConfigDataComplete(dataFlow); //3.0 æ ¡éª APPIDæ¯å¦ææéæä½serviceCode judgeAuthority(dataFlow); //4.0 è°ç¨è§åæ ¡éª ruleValidate(dataFlow); DataFlowEventPublishing.ruleValidateComplete(dataFlow); //DataFlowEventPublishing.ruleValidateComplete(dataFlow); //5.0 ä¿å订ååä¸å¡é¡¹ c_orders c_order_attrs c_business c_business_attrs saveOrdersAndBusiness(dataFlow); //6.0 è°ç¨ä¸æ¸¸ç³»ç» DataFlowEventPublishing.invokeBusinessSystem(dataFlow); //DataFlowEventPublishing.invokeBusinessSystem(dataFlow); invokeBusinessSystem(dataFlow); responseJson = DataTransactionFactory.createCommonResponseJson(dataFlow); @@ -245,7 +245,7 @@ //saveCostTimeLogMessage(dataFlow); saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestHeaders(),dataFlow.getReqJson().toJSONString()), LogAgent.createLogMessage(dataFlow.getResponseHeaders(),responseEntity.getBody()),endDate.getTime()-dataFlow.getStartDate().getTime()); DataFlowEventPublishing.dataResponse(dataFlow,reqJson,headers); //DataFlowEventPublishing.dataResponse(dataFlow,reqJson,headers); } //è¿éä¿åèæ¶ï¼ä»¥åæ¥å¿ OrderService/src/main/java/com/java110/order/smo/impl/OrderServiceSMOImpl.java
New file @@ -0,0 +1,1105 @@ package com.java110.order.smo.impl; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.java110.common.cache.AppRouteCache; import com.java110.common.cache.MappingCache; import com.java110.common.constant.*; import com.java110.common.exception.*; import com.java110.common.factory.ApplicationContextFactory; import com.java110.common.kafka.KafkaFactory; import com.java110.common.log.LoggerEngine; import com.java110.common.util.*; import com.java110.core.client.RestTemplate; import com.java110.core.context.*; import com.java110.core.factory.AuthenticationFactory; import com.java110.core.factory.OrderDataFlowContextFactory; import com.java110.core.factory.GenerateCodeFactory; import com.java110.entity.center.AppRoute; import com.java110.entity.center.AppService; import com.java110.entity.center.DataFlowLinksCost; import com.java110.entity.order.Business; import com.java110.entity.order.ServiceBusiness; import com.java110.event.center.DataFlowEventPublishing; import com.java110.log.agent.LogAgent; import com.java110.order.dao.ICenterServiceDAO; import com.java110.order.smo.IOrderServiceSMO; import com.java110.service.init.ServiceInfoListener; import com.java110.service.smo.IQueryServiceSMO; import org.apache.commons.lang3.math.NumberUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import java.util.*; /** * 订åæå¡å¤çç±» * Created by wuxw on 2018/4/13. */ @Service("orderServiceSMOImpl") //@Transactional public class OrderServiceSMOImpl implements IOrderServiceSMO { private final static Logger logger = LoggerFactory.getLogger(OrderServiceSMOImpl.class); @Autowired ICenterServiceDAO centerServiceDaoImpl; @Autowired private RestTemplate restTemplate; @Autowired private RestTemplate restTemplateNoLoadBalanced; @Autowired private IQueryServiceSMO queryServiceSMOImpl; /** * ä¸å¡ç»ä¸å¤çæå¡æ¹æ³ * @param reqJson è¯·æ±æ¥æjson * @return */ public ResponseEntity<String> service(String reqJson, Map<String,String> headers) throws SMOException{ IOrderDataFlowContext dataFlow = null; JSONObject responseJson = null; ResponseEntity<String> responseEntity = null; try { DataFlowEventPublishing.preValidateData(reqJson,headers); //1.0 åå»ºæ°æ®æµ dataFlow = OrderDataFlowContextFactory.newInstance(OrderDataFlow.class).builder(reqJson, headers); DataFlowEventPublishing.initDataFlowComplete(dataFlow); //2.0 è°ç¨è§åæ ¡éª ruleValidate(dataFlow); DataFlowEventPublishing.ruleValidateComplete(dataFlow); //3.0 ä¿å订ååä¸å¡é¡¹ c_orders c_order_attrs c_business c_business_attrs saveOrdersAndBusiness(dataFlow); //6.0 è°ç¨ä¸æ¸¸ç³»ç» DataFlowEventPublishing.invokeBusinessSystem(dataFlow); invokeBusinessSystem(dataFlow); //è½å¤æ§è¡å°è¿ä¸æ¥ 认为æ¯é½æåäº refreshOrderDataFlowResJson(dataFlow); }catch (BusinessException e) { responseEntity = new ResponseEntity<String>(e.getMessage() , OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()),HttpStatus.INTERNAL_SERVER_ERROR); } catch (OrdersException e) { responseEntity = new ResponseEntity<String>(e.getMessage() , OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()),HttpStatus.INTERNAL_SERVER_ERROR); } catch (RuleException e) { responseEntity = new ResponseEntity<String>(e.getMessage(),OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()), HttpStatus.NETWORK_AUTHENTICATION_REQUIRED); } catch (NoAuthorityException e) { responseEntity = new ResponseEntity<String>(e.getMessage(), OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()),HttpStatus.UNAUTHORIZED); } catch (InitConfigDataException e){ responseEntity = new ResponseEntity<String>(e.getMessage(), OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()),HttpStatus.INTERNAL_SERVER_ERROR); }catch (Exception e) { logger.error("å é¨å¼å¸¸äºï¼",e); responseEntity = new ResponseEntity<String>("å é¨å¼å¸¸äºï¼"+e.getMessage() + e.getLocalizedMessage(), OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()),HttpStatus.INTERNAL_SERVER_ERROR); } finally { if(responseEntity == null){ responseEntity = new ResponseEntity<String>(dataFlow.getResJson().getString("msg"),OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()),HttpStatus.OK); } if(dataFlow != null) { //æ·»å èæ¶ //OrderDataFlowContextFactory.addCostTime(dataFlow, "service", "ä¸å¡å¤çæ»èæ¶", dataFlow.getStartDate(), dataFlow.getEndDate()); //ä¿åèæ¶ //saveCostTimeLogMessage(dataFlow); // saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestHeaders(),dataFlow.getReqJson().toJSONString()), // LogAgent.createLogMessage(dataFlow.getResponseHeaders(),responseEntity.getBody()),endDate.getTime()-dataFlow.getStartDate().getTime()); // DataFlowEventPublishing.dataResponse(dataFlow,reqJson,headers); } //è¿éä¿åèæ¶ï¼ä»¥åæ¥å¿ return responseEntity ; } } /** * å·è¿åå¼ * @param dataFlow */ private void refreshOrderDataFlowResJson(IOrderDataFlowContext dataFlow){ if(dataFlow.getResJson() == null || dataFlow.getResJson().isEmpty()){ JSONObject resJson = new JSONObject(); resJson.put("msg","æå"); dataFlow.setResJson(resJson); } } /** * æåè¿åå¤´ä¿¡æ¯ * @param dataFlow */ private void putResponseHeader(DataFlow dataFlow,Map<String,String> headers) { headers.put("responseTime", DateUtil.getDefaultFormateTimeString(new Date())); headers.put("transactionId",dataFlow.getTransactionId()); } /** * è§£å¯ * @param reqJson * @return */ private String decrypt(String reqJson,Map<String,String> headers) throws DecryptException{ try { if (MappingConstant.VALUE_ON.equals(headers.get(CommonConstant.ENCRYPT))) { logger.debug("è§£å¯åå符ï¼" + reqJson); reqJson = new String(AuthenticationFactory.decrypt(reqJson.getBytes("UTF-8"), AuthenticationFactory.loadPrivateKey(MappingConstant.KEY_PRIVATE_STRING) , NumberUtils.isNumber(headers.get(CommonConstant.ENCRYPT_KEY_SIZE)) ? Integer.parseInt(headers.get(CommonConstant.ENCRYPT_KEY_SIZE)) : Integer.parseInt(MappingCache.getValue(MappingConstant.KEY_DEFAULT_DECRYPT_KEY_SIZE))),"UTF-8"); logger.debug("è§£å¯åå符ï¼" + reqJson); } }catch (Exception e){ throw new DecryptException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR,"è§£å¯å¤±è´¥"); } return reqJson; } /** * å å¯ * @param resJson * @param headers * @return */ private String encrypt(String resJson,Map<String,String> headers){ try { if (MappingConstant.VALUE_ON.equals(headers.get(CommonConstant.ENCRYPT))) { logger.debug("å å¯åå符ï¼" + resJson); resJson = new String(AuthenticationFactory.encrypt(resJson.getBytes("UTF-8"), AuthenticationFactory.loadPubKey(MappingConstant.KEY_PUBLIC_STRING) , NumberUtils.isNumber(headers.get(CommonConstant.ENCRYPT_KEY_SIZE)) ? Integer.parseInt(headers.get(CommonConstant.ENCRYPT_KEY_SIZE)) : Integer.parseInt(MappingCache.getValue(MappingConstant.KEY_DEFAULT_DECRYPT_KEY_SIZE))),"UTF-8"); logger.debug("å å¯åå符ï¼" + resJson); } }catch (Exception e){ logger.error("å å¯å¤±è´¥ï¼",e); } return resJson; } /** * 2.0åå§åé ç½®ä¿¡æ¯ * * @param dataFlow */ private void initConfigData(IOrderDataFlowContext dataFlow) { } /** * 4.0è§åæ ¡éª * * @param dataFlow * @throws RuleException */ private void ruleValidate(IOrderDataFlowContext dataFlow) throws RuleException { Date startDate = DateUtil.getCurrentDate(); try { if (MappingConstant.VALUE_OFF.equals(MappingCache.getValue(MappingConstant.KEY_RULE_ON_OFF)) || (MappingCache.getValue(MappingConstant.KEY_NO_NEED_RULE_VALDATE_ORDER) != null && MappingCache.getValue(MappingConstant.KEY_NO_NEED_RULE_VALDATE_ORDER).contains(dataFlow.getOrders().getOrderTypeCd()))) { //ä¸åæ ¡éª //æ·»å èæ¶ OrderDataFlowContextFactory.addCostTime(dataFlow, "ruleValidate", "è§åæ ¡éªèæ¶", startDate); return ; } //è°ç¨è§å } catch (Exception e) { //æ·»å èæ¶ OrderDataFlowContextFactory.addCostTime(dataFlow, "ruleValidate", "è§åæ ¡éªèæ¶", startDate); throw new RuleException(ResponseConstant.RESULT_CODE_RULE_ERROR, "è§åæ ¡éªå¼å¸¸å¤±è´¥ï¼" + e.getMessage()); } OrderDataFlowContextFactory.addCostTime(dataFlow, "ruleValidate", "è§åæ ¡éªèæ¶", startDate); } /** * 5.0 ä¿å订ååä¸å¡é¡¹ c_orders c_order_attrs c_business c_business_attrs * * @param dataFlow * @throws OrdersException */ private void saveOrdersAndBusiness(IOrderDataFlowContext dataFlow) throws OrdersException { Date startDate = DateUtil.getCurrentDate(); if(MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER) != null &&MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER).contains(dataFlow.getOrders().getOrderTypeCd())){ //ä¸ä¿å订åä¿¡æ¯ OrderDataFlowContextFactory.addCostTime(dataFlow, "saveOrdersAndBusiness", "ä¿å订ååä¸å¡é¡¹èæ¶", startDate); return ; } //1.0 ä¿å ordersä¿¡æ¯ centerServiceDaoImpl.saveOrder(OrderDataFlowContextFactory.getOrder(dataFlow.getOrders())); centerServiceDaoImpl.saveOrderAttrs(OrderDataFlowContextFactory.getOrderAttrs(dataFlow.getOrders())); //2.0 ä¿å businessä¿¡æ¯ centerServiceDaoImpl.saveBusiness(OrderDataFlowContextFactory.getBusiness(dataFlow)); centerServiceDaoImpl.saveBusinessAttrs(OrderDataFlowContextFactory.getBusinessAttrs(dataFlow)); OrderDataFlowContextFactory.addCostTime(dataFlow, "saveOrdersAndBusiness", "ä¿å订ååä¸å¡é¡¹èæ¶", startDate); } /** * 6.0 è°ç¨ä¸æ¸¸ç³»ç» * * @param dataFlow * @throws BusinessException */ private void invokeBusinessSystem(IOrderDataFlowContext dataFlow) throws BusinessException { Date startDate = DateUtil.getCurrentDate(); //6.1 å å¤ç忥æ¹å¼çæå¡ï¼æ¯ä¸åæ¥ååå¸äºä»¶å¹¿æ doSynchronousBusinesses(dataFlow); //6.2 å¤ç弿¥æå¡ doAsynchronousBusinesses(dataFlow); OrderDataFlowContextFactory.addCostTime(dataFlow, "invokeBusinessSystem", "è°ç¨ä¸æ¸¸ç³»ç»èæ¶", startDate); } /** * 7.0 ä½åºè®¢ååä¸å¡é¡¹ æå ¥æ¤åè®°å½ çå¾ æ¤å * * @param dataFlow */ private void invalidOrderAndBusiness(IOrderNotifyDataFlowContext dataFlow) { Date startDate = DateUtil.getCurrentDate(); if(MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER) != null &&MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER).contains(dataFlow.getOrderTypeCd())){ //ä¸ç¨ä½åºè®¢åä¿¡æ¯ // OrderDataFlowContextFactory.addCostTime(dataFlow, "invalidOrderAndBusiness", "ä½åºè®¢ååä¸å¡é¡¹èæ¶", startDate); return ; } //妿已ç»ä½åº ä¸åå¨ æå¤±è´¥ï¼åä¸åå¤ç Map order = centerServiceDaoImpl.getOrderInfoByBId(dataFlow.getbId()); if(order == null || !order.containsKey("status_cd") || StatusConstant.STATUS_CD_DELETE.equals(order.get("status_cd")) || StatusConstant.STATUS_CD_ERROR.equals(order.get("status_cd"))){ return ; } //ä½åº 订å centerServiceDaoImpl.updateOrder(OrderDataFlowContextFactory.getNeedInvalidOrder(dataFlow)); //ä½åºè®¢å项 centerServiceDaoImpl.updateBusiness(OrderDataFlowContextFactory.getNeedInvalidOrder(dataFlow)); //å°å½å订å项æ¹ä¸º æ¤åç¶æ centerServiceDaoImpl.updateBusinessByBId(OrderDataFlowContextFactory.getNeedDeleteBusiness(dataFlow)); //æå ¥æ¤åè®°å½ doAddDeleteOrderBusinessData(dataFlow); //OrderDataFlowContextFactory.addCostTime(dataFlow, "invalidOrderAndBusiness", "ä½åºè®¢ååä¸å¡é¡¹èæ¶", startDate); } /** * 8.0 广æä½åºå·²ç»å®æä¸å¡ç³»ç»è®¢åä¿¡æ¯ * * @param dataFlow */ private void invalidCompletedBusinessSystem(IOrderNotifyDataFlowContext dataFlow) throws Exception{ if(!StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) { return ; } //夿 订åinstance æ¯å¦é½åæäºæ¤åç¶æ if(centerServiceDaoImpl.judgeAllBusinessDeleteOrder(dataFlow.getoId(),StatusConstant.STATUS_CD_DELETE_ORDER) < 1){ return ; } // æ ¹æ® c_business 表ä¸çåæ®µbusiness_type_cd æ¾å°å¯¹åºçæ¶æ¯éååç§° Map paramIn = new HashMap(); paramIn.put("oId",dataFlow.getoId()); paramIn.put("statusCd",StatusConstant.STATUS_CD_DELETE_ORDER); List<Map> completedBusinesses = centerServiceDaoImpl.getBusinessByOId(paramIn); for(Map completedBusiness : completedBusinesses){ ServiceBusiness serviceBusiness = ServiceBusinessUtil.getServiceBusiness(completedBusiness.get("business_type_cd").toString()); long startTime = DateUtil.getCurrentDate().getTime(); //åèµ·æ¤å KafkaFactory.sendKafkaMessage(serviceBusiness.getMessageTopic(),"", OrderDataFlowContextFactory.getDeleteInstanceTableJson(dataFlow,completedBusiness).toJSONString()); //saveLogMessage(OrderDataFlowContextFactory.getDeleteInstanceTableJson(dataFlow,completedBusiness,appRoute.getAppService()),null); } } /** * 9.0 å°è®¢åç¶ææ¹ä¸ºå¤±è´¥ï¼äººå·¥å¤çã * * @param dataFlow */ private void updateOrderAndBusinessError(IOrderDataFlowContext dataFlow) { Date startDate = DateUtil.getCurrentDate(); //ä½åº 订å centerServiceDaoImpl.updateOrder(OrderDataFlowContextFactory.getNeedErrorOrder(dataFlow)); //ä½åºè®¢å项 centerServiceDaoImpl.updateBusiness(OrderDataFlowContextFactory.getNeedErrorOrder(dataFlow)); OrderDataFlowContextFactory.addCostTime(dataFlow, "updateOrderAndBusinessError", "订åç¶ææ¹ä¸ºå¤±è´¥èæ¶", startDate); } /** * 9.0 å°è®¢åç¶ææ¹ä¸ºå¤±è´¥ï¼äººå·¥å¤çã * * @param dataFlow */ private void updateOrderAndBusinessError(IOrderNotifyDataFlowContext dataFlow) { Date startDate = DateUtil.getCurrentDate(); //ä½åº 订å centerServiceDaoImpl.updateOrder(OrderDataFlowContextFactory.getNeedErrorOrder(dataFlow)); //ä½åºè®¢å项 centerServiceDaoImpl.updateBusiness(OrderDataFlowContextFactory.getNeedErrorOrder(dataFlow)); //OrderDataFlowContextFactory.addCostTime(dataFlow, "updateOrderAndBusinessError", "订åç¶ææ¹ä¸ºå¤±è´¥èæ¶", startDate); } /** * å°è®¢åç¶ææ¹ä¸ºä½åºç¶æã * * @param dataFlow */ private void updateOrderAndBusinessDelete(IOrderDataFlowContext dataFlow) { Date startDate = DateUtil.getCurrentDate(); //ä½åº 订å centerServiceDaoImpl.updateOrder(OrderDataFlowContextFactory.getNeedInvalidOrder(dataFlow)); //ä½åºè®¢å项 centerServiceDaoImpl.updateBusiness(OrderDataFlowContextFactory.getNeedDeleteBusiness(dataFlow)); //å å ¥æ¤åè®°å½ //doAddDeleteOrderBusinessData(dataFlow); OrderDataFlowContextFactory.addCostTime(dataFlow, "updateOrderAndBusinessError", "订åç¶ææ¹ä¸ºå¤±è´¥èæ¶", startDate); } /** * å å ¥æ¤åè®°å½ * @param dataFlow */ private void doAddDeleteOrderBusinessData(IOrderDataFlowContext dataFlow){ /* Map business = new HashMap(); business.put("bId",SequenceUtil.getBId()); business.put("oId",dataFlow.getoId()); business.put("businessTypeCd",StatusConstant.REQUEST_BUSINESS_TYPE_DELETE); business.put("remark","åèµ·æ¤å"); business.put("statusCd",StatusConstant.STATUS_CD_DELETE_ORDER);*/ centerServiceDaoImpl.saveBusiness(OrderDataFlowContextFactory.getDeleteOrderBusiness(dataFlow,"订å失败ï¼å å ¥æ¤å")); } /** * å å ¥æ¤åè®°å½ * @param dataFlow */ private void doAddDeleteOrderBusinessData(IOrderNotifyDataFlowContext dataFlow){ /* Map business = new HashMap(); business.put("bId",SequenceUtil.getBId()); business.put("oId",dataFlow.getoId()); business.put("businessTypeCd",StatusConstant.REQUEST_BUSINESS_TYPE_DELETE); business.put("remark","åèµ·æ¤å"); business.put("statusCd",StatusConstant.STATUS_CD_DELETE_ORDER);*/ centerServiceDaoImpl.saveBusiness(OrderDataFlowContextFactory.getDeleteOrderBusiness(dataFlow,"订å失败ï¼å å ¥æ¤å")); } /** * æ¥åä¸å¡ç³»ç»éç¥æ¶æ¯ * @param receiveJson æ¥åæ¥æ * @throws SMOException */ @Override public void receiveBusinessSystemNotifyMessage(String receiveJson) throws SMOException{ Date startDate = DateUtil.getCurrentDate(); IOrderNotifyDataFlowContext dataFlow = null; try { //1.0 åå»ºæ°æ®æµ dataFlow = OrderDataFlowContextFactory.newInstance(OrderNotifyDataFlow.class).builder(receiveJson,null); //å¦æè®¢å齿²¡æä¿åï¼ååä¸è¦å¤ç if(MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER) != null &&MappingCache.getValue(MappingConstant.KEY_NO_SAVE_ORDER).contains(dataFlow.getOrderTypeCd())){ //ä¸ä¿å订åä¿¡æ¯ return ; } //妿䏿¯ business åinstance è¿ç¨ åç´æ¥è·³åº judgeBusinessOrInstance(dataFlow); //2.0å è½½æ°æ®ï¼æ²¡ææ¾å°appId åé ç½®ä¿¡æ¯ åæåºInitConfigDataException reloadOrderInfo(dataFlow); //3.0 夿æ¯å¦æå,å¤±è´¥ä¼æåºBusinessStatusExceptionå¼å¸¸ judgeBusinessStatusAndCompleteBusiness(dataFlow); //4.0 ä¿®æ¹ä¸å¡ä¸ºæå,妿åç°ä¸å¡é¡¹å·²ç»æ¯ä½åºæå¤±è´¥ç¶æï¼DæEï¼åæåºBusinessExceptionå¼å¸¸ //completeBusiness(dataFlow); //5.0 夿 åèµ· Instance æ¡ä»¶æ¯å¦æ»¡è¶³ï¼å¦ææ»¡è¶³ åèµ· Instanceè¿ç¨ judgeSendToInstance(dataFlow); //7.0 夿æ¤åæ¡ä»¶æ¯å¦æ»¡è¶³ï¼å¦ææ»¡è¶³åèµ·æ¤å invalidCompletedBusinessSystem(dataFlow); }catch (BusinessStatusException e){ logger.error("订å失败:" ,e); //8.0 å°è®¢åç¶ææ¹ä¸ºå¤±è´¥ï¼äººå·¥å¤çã updateOrderAndBusinessError(dataFlow); }catch (BusinessException e) { //9.0说æè¿ä¸ªè®¢åå·²ç»å¤±è´¥äºï¼åä¸éè¦ //æ³æ³ï¼è¿é广æå½å失败ä¸å¡ logger.error("ä¿®æ¹ä¸å¡æ°æ®å¤±è´¥",e); }/*catch (InitConfigDataException e){ //è¿ç§ä¸è¬ä¸ä¼åºç°ï¼é¤é人工æ¹äºæ°æ® LoggerEngine.error("å è½½é ç½®æ°æ®åºé", e); try { //6.0 ä½åºè®¢ååææä¸å¡é¡¹ invalidOrderAndBusiness(dataFlow); //7.0 广æä½åºä¸å¡ç³»ç»è®¢åä¿¡æ¯,è¿éåªæ Instance 失败åæåèµ· æ¤å if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) { invalidCompletedBusinessSystem(dataFlow); } } catch (Exception e1) { LoggerEngine.error("ä½åºè®¢å失败", e1); //8.0 å°è®¢åç¶ææ¹ä¸ºå¤±è´¥ï¼äººå·¥å¤çã updateOrderAndBusinessError(dataFlow); } }*/catch (NoSupportException e){ LoggerEngine.error("å½åä¸å¡ä¸æ¯æ", e); }catch (Exception e){ LoggerEngine.error("ä½åºè®¢å失败", e); //10.0 æåçæ åµä¸éç¥ä¸æ¸¸ç³»ç»å¤±è´¥å°ç¶ææ¹ä¸ºNEï¼äººå·¥å¤çã updateBusinessNotifyError(dataFlow); }finally{ /*OrderDataFlowContextFactory.addCostTime(dataFlow, "receiveBusinessSystemNotifyMessage", "æ¥åä¸å¡ç³»ç»éç¥æ¶æ¯èæ¶", startDate); saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),dataFlow.getReqJson().toJSONString()), LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),ResponseConstant.RESULT_CODE_SUCCESS), DateUtil.getCurrentDate().getTime() - dataFlow.getStartDate().getTime());*/ } } /** * Instanceè¿ç¨ * @param dataFlow */ private void doSendInstance(IOrderNotifyDataFlowContext dataFlow) { if(dataFlow == null || !StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(dataFlow.getBusinessType())){ return ; } try { ServiceBusiness serviceBusiness = ServiceBusinessUtil.getServiceBusiness(dataFlow.getBusinessTypeCd()); KafkaFactory.sendKafkaMessage(serviceBusiness.getMessageTopic(), "", OrderDataFlowContextFactory.getBusinessTableDataInfoToInstanceTableJson(dataFlow).toJSONString()); }catch (Exception e){ } } /** * 夿æ¯å¦æ¯ business æè instanceè¿ç¨ * @param dataFlow * @throws NoSupportException */ private void judgeBusinessOrInstance(IOrderNotifyDataFlowContext dataFlow) throws NoSupportException{ if(dataFlow == null || StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(dataFlow.getBusinessType()) || StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())){ return ; } throw new NoSupportException(ResponseConstant.RESULT_PARAM_ERROR,"å½ååªæ¯æ Business å Instanceè¿ç¨"); } /** * 2.0éæ°å 载订åä¿¡æ¯å°dataFlow ä¸ * * @param dataFlow */ private void reloadOrderInfoAndConfigData(DataFlow dataFlow) { Map order = centerServiceDaoImpl.getOrderInfoByBId(dataFlow.getBusinesses().get(0).getbId()); dataFlow.setoId(order.get("o_id").toString()); dataFlow.setAppId(order.get("app_id").toString()); if("-1".equals(dataFlow.getDataFlowId()) || StringUtil.isNullOrNone(dataFlow.getDataFlowId())){ throw new InitConfigDataException(ResponseConstant.RESULT_CODE_ERROR,"è¯·æ±æ¥æä¸æ²¡æå å« dataFlowId èç¹"); } //éæ°å·ç«¯å£ä¿¡æ¯ ServiceInfoListener serviceInfoListener = ApplicationContextFactory.getBean("serviceInfoListener",ServiceInfoListener.class); if(serviceInfoListener != null){ dataFlow.setPort(serviceInfoListener.getServerPort()+""); } //éæ°å è½½é ç½® //initConfigData(dataFlow); } /** * 2.0éæ°å 载订åä¿¡æ¯å°dataFlow ä¸ * * @param dataFlow */ private void reloadOrderInfo(IOrderNotifyDataFlowContext dataFlow) { Map order = centerServiceDaoImpl.getOrderInfoByBId(dataFlow.getbId()); dataFlow.setoId(order.get("o_id").toString()); if("-1".equals(dataFlow.getDataFlowId()) || StringUtil.isNullOrNone(dataFlow.getDataFlowId())){ throw new InitConfigDataException(ResponseConstant.RESULT_CODE_ERROR,"è¯·æ±æ¥æä¸æ²¡æå å« dataFlowId èç¹"); } } /** * 9.0 æåçæ åµä¸éç¥ä¸æ¸¸ç³»ç»å¤±è´¥å°ç¶ææ¹ä¸ºNEï¼äººå·¥å¤çã * * @param dataFlow */ private void updateBusinessNotifyError(IOrderNotifyDataFlowContext dataFlow) { Date startDate = DateUtil.getCurrentDate(); //å®æè®¢å项 centerServiceDaoImpl.updateBusinessByBId(OrderDataFlowContextFactory.getNeedNotifyErrorBusiness(dataFlow)); // OrderDataFlowContextFactory.addCostTime(dataFlow, "updateBusinessNotifyError", "订åç¶ææ¹ä¸ºå¤±è´¥èæ¶", startDate); } /** * 夿æ¯å¦é½æåäº * @param dataFlow */ private void judgeBusinessStatusAndCompleteBusiness(IOrderNotifyDataFlowContext dataFlow) throws BusinessStatusException{ //List<Business> businesses = dataFlow.getBusinesses(); //1.0 夿æ¯å¦å卿¤åï¼å¦ææ¯æ¤ååå°å½å bId æ 记为æ¤åç¶æ if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) { Map businessMap = centerServiceDaoImpl.getDeleteOrderBusinessByOId(dataFlow.getoId()); if(businessMap != null && !businessMap.isEmpty()){ centerServiceDaoImpl.updateBusinessByBId(OrderDataFlowContextFactory.getNeedDeleteBusiness(dataFlow)); return ; } } //Business business = dataFlow.getCurrentBusiness(); if(!ResponseConstant.RESULT_CODE_SUCCESS.equals(((IOrderResponse)dataFlow).getCode())){ //throw new BusinessStatusException(business.getCode(),"ä¸å¡bId= "+business.getbId() + " å¤ç失败ï¼éè¦ä½åºè®¢å"); //ä½åºè®¢ååä¸å¡é¡¹ æå ¥æ¤åè®°å½ çå¾ æ¤å invalidOrderAndBusiness(dataFlow); }else{ completeBusiness(dataFlow); } } /** * 3.0 ä¿®æ¹ä¸å¡ä¸ºæå,妿åç°ä¸å¡é¡¹å·²ç»æ¯ä½åºæå¤±è´¥ç¶æï¼DæEï¼åæåºBusinessExceptionå¼å¸¸ * * @param dataFlow */ private void completeBusiness(IOrderNotifyDataFlowContext dataFlow) throws BusinessException{ try { if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(dataFlow.getBusinessType())) { //å®æè®¢å项 centerServiceDaoImpl.updateBusinessByBId(OrderDataFlowContextFactory.getNeedCompleteBusiness(dataFlow)); //妿ä¸å¡é½å®æï¼åå° è®¢åæ¹ä¸ºå®æç¶æ centerServiceDaoImpl.completeOrderByBId(dataFlow.getbId()); }else if(StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(dataFlow.getBusinessType())) { centerServiceDaoImpl.updateBusinessByBId(OrderDataFlowContextFactory.getNeedBusinessComplete(dataFlow)); }else{ //è¿éå°ä¸äºï¼åé¢åäºæ ¡éª throw new BusinessException(ResponseConstant.RESULT_PARAM_ERROR,"å½å䏿¯æ ä¸å¡ç±»å为 businessType" +dataFlow.getBusinessType()); } }catch (DAOException e){ throw new BusinessException(e.getResult(),e); } } /** * //4.0彿æä¸å¡å¨ä½æ¯å¦é½æ¯Cï¼å°è®¢åä¿¡æ¯æ¹ä¸º C å¹¶ä¸åå¸ç«£å·¥æ¶æ¯ï¼è¿éå¨å¹¿æä¹å确认 * @param dataFlow */ private void judgeSendToInstance(IOrderNotifyDataFlowContext dataFlow) throws Exception{ try { if(centerServiceDaoImpl.judgeAllBusinessCompleted(dataFlow.getoId(),StatusConstant.STATUS_CD_BUSINESS_COMPLETE) > 0) { //éç¥æåæ¶æ¯ doSendInstance(dataFlow); } }catch (DAOException e){ //è¿éä»ä¹é½ä¸åï¼è¯´æè®¢å没æå®æ } } /** * éç¥ è®¢åå·²ç»å®æï¼å端éè¦å®ææ°æ® * @param dataFlow */ private void notifyBusinessSystemSuccessMessage(IOrderNotifyDataFlowContext dataFlow) throws Exception{ long startTime = DateUtil.getCurrentDate().getTime(); ServiceBusiness serviceBusiness = ServiceBusinessUtil.getServiceBusiness(dataFlow.getBusinessTypeCd()); //æ¼è£ æ¥æéç¥ä¸å¡ç³»ç» KafkaFactory.sendKafkaMessage(serviceBusiness.getMessageTopic(),"", OrderDataFlowContextFactory.getNotifyBusinessSuccessJson(dataFlow).toJSONString()); /*saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),OrderDataFlowContextFactory.getNotifyBusinessSuccessJson(dataFlow).toJSONString()), LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),ResponseConstant.RESULT_CODE_SUCCESS), DateUtil.getCurrentDate().getTime() - startTime);*/ } /** * 8.0 广æä½åºä¸å¡ç³»ç»è®¢åä¿¡æ¯ * * @param dataFlow */ private void notifyBusinessSystemErrorMessage(IOrderNotifyDataFlowContext dataFlow) throws Exception{ long startTime = DateUtil.getCurrentDate().getTime(); ServiceBusiness serviceBusiness = ServiceBusinessUtil.getServiceBusiness(dataFlow.getBusinessTypeCd()); //æ¼è£ æ¥æéç¥ä¸å¡ç³»ç» KafkaFactory.sendKafkaMessage(serviceBusiness.getMessageTopic(),"", OrderDataFlowContextFactory.getNotifyBusinessErrorJson(dataFlow).toJSONString()); /*saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),OrderDataFlowContextFactory.getNotifyBusinessErrorJson(dataFlow).toJSONString()), LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),ResponseConstant.RESULT_CODE_ERROR), DateUtil.getCurrentDate().getTime() - startTime);*/ } /** * å¤ç忥ä¸å¡ * @param dataFlow */ private void doSynchronousBusinesses(IOrderDataFlowContext dataFlow) throws BusinessException{ Date startDate = DateUtil.getCurrentDate(); List<Business> synchronousBusinesses = OrderDataFlowContextFactory.getSynchronousBusinesses(dataFlow); List<Business> deleteBusinesses = new ArrayList<Business>(); if(synchronousBusinesses == null || synchronousBusinesses.size() == 0){ return ; } JSONArray responseBusinesses = new JSONArray(); //6.1å¤ç忥æå¡ åèµ·Business doSaveDataInfoToBusinessTable(dataFlow, synchronousBusinesses, responseBusinesses); try { //6.2åèµ·Instance doBusinessTableDataInfoToInstanceTable(dataFlow, synchronousBusinesses,deleteBusinesses); }catch (Exception e){ try { //è¿éåèµ·æ¤åé»è¾ doDeleteOrderAndInstanceData(dataFlow, deleteBusinesses); }catch (Exception e1){ logger.error("æ¤å失败",e1); //è¿éè®°å½æ¤å失败çä¿¡æ¯ } throw new BusinessException(ResponseConstant.RESULT_PARAM_ERROR,e.getMessage()); } //6.3 c_business æ°æ®ä¿®æ¹ä¸ºå®æ /*List<Business> asynchronousBusinesses = OrderDataFlowContextFactory.getAsynchronousBusinesses(dataFlow); if(asynchronousBusinesses == null || asynchronousBusinesses.size() == 0){ doComplateOrderAndBusiness(dataFlow,synchronousBusinesses); }*/ OrderDataFlowContextFactory.addCostTime(dataFlow, "doSynchronousBusinesses", "忥è°ç¨ä¸å¡ç³»ç»æ»èæ¶", startDate); } /** * åèµ·æ¤åä¸å¡ * @param dataFlow * @param deleteBusinesses */ private void doDeleteOrderAndInstanceData(IOrderDataFlowContext dataFlow, List<Business> deleteBusinesses) { if(deleteBusinesses == null || deleteBusinesses.size() == 0){ return ; } //1.0 å¨c_business 表ä¸å å ¥ æ¤åè®°å½ centerServiceDaoImpl.saveBusiness(OrderDataFlowContextFactory.getDeleteOrderBusiness(dataFlow,"ä¸å¡ç³»ç»å®ä¾å¤±è´¥ï¼åèµ·æ¤å")); //2.0 ä½åº c_orders å c_business æ°æ® updateOrderAndBusinessDelete(dataFlow); //3.0 åèµ· æ¤åä¸å¡ doDeleteBusinessSystemInstanceData(dataFlow,deleteBusinesses); } /** * å®æè®¢åç¶æ * @param synchronousBusinesses */ /*private void doComplateOrderAndBusiness(DataFlow dataFlow,List<Business> synchronousBusinesses) { //Complete Order and business Map order = new HashMap(); order.put("oId",dataFlow.getoId()); order.put("statusCd", StatusConstant.STATUS_CD_COMPLETE); order.put("finishTime",DateUtil.getCurrentDate()); centerServiceDaoImpl.updateOrder(order); centerServiceDaoImpl.updateBusiness(order); Date businessStartDate; AppService service; JSONObject requestBusinessJson; for(Business business : synchronousBusinesses){ businessStartDate = DateUtil.getCurrentDate(); service = OrderDataFlowContextFactory.getService(dataFlow,business.getServiceCode()); if(!CommonConstant.INSTANCE_Y.equals(service.getIsInstance())){ continue; } requestBusinessJson = OrderDataFlowContextFactory.getCompleteInstanceDataJson(dataFlow,business); JSONObject responseJson = doRequestBusinessSystem(dataFlow, service, requestBusinessJson); OrderDataFlowContextFactory.addCostTime(dataFlow, business.getServiceCode(), "è°ç¨"+business.getServiceName()+"-doCompleteèæ¶", businessStartDate); saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),requestBusinessJson.toJSONString()), LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),responseJson.toJSONString()), DateUtil.getCurrentDate().getTime() - businessStartDate.getTime()); } }*/ /** * å°BusinessTable ä¸çæ°æ®ä¿åå° InstanceTable * @param dataFlow * @param synchronousBusinesses */ private void doBusinessTableDataInfoToInstanceTable(IOrderDataFlowContext dataFlow, List<Business> synchronousBusinesses,List<Business> deleteBusinesses) { Date businessStartDate; ServiceBusiness serviceBusiness; JSONObject requestBusinessJson; for(Business business : synchronousBusinesses){ businessStartDate = DateUtil.getCurrentDate(); serviceBusiness = ServiceBusinessUtil.getServiceBusiness(business.getBusinessTypeCd()); //æ·»å éè¦æ¤åçä¸å¡ä¿¡æ¯ deleteBusinesses.add(business); requestBusinessJson = OrderDataFlowContextFactory.getBusinessTableDataInfoToInstanceTableJson(dataFlow,business); JSONObject responseJson = doRequestBusinessSystem(dataFlow, serviceBusiness, requestBusinessJson); //åå¸äºä»¶ DataFlowEventPublishing.invokeBusinessISuccess(dataFlow,business); updateBusinessStatusCdByBId(business.getbId(),StatusConstant.STATUS_CD_COMPLETE); OrderDataFlowContextFactory.addCostTime(dataFlow, business.getBusinessTypeCd(), "è°ç¨"+business.getBusinessTypeCd()+"èæ¶", businessStartDate); /* saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),requestBusinessJson.toJSONString()), LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),responseJson.toJSONString()), DateUtil.getCurrentDate().getTime() - businessStartDate.getTime());*/ } /* if(dataFlow.getCurrentBusiness() == null){ return ; }*/ //夿ä¸å¡å¨ä½æ¯å¦é½ç«£å·¥ï¼ä¸»è¦èè è¯·æ±æ¥æä¸ æå¼æ¥ä¹æåæ¥çæ åµ //妿ä¸å¡é½å®æï¼åå° è®¢åæ¹ä¸ºå®æç¶æ centerServiceDaoImpl.completeOrderByOId(dataFlow.getOrders().getoId()); } /** * ä¸å¡ç³»ç»æ¤å * @param dataFlow * @param deleteBusinesses */ private void doDeleteBusinessSystemInstanceData(IOrderDataFlowContext dataFlow, List<Business> deleteBusinesses) { Date businessStartDate; JSONObject requestBusinessJson; ServiceBusiness serviceBusiness; for(Business business : deleteBusinesses){ businessStartDate = DateUtil.getCurrentDate(); requestBusinessJson = OrderDataFlowContextFactory.getDeleteInstanceTableJson(dataFlow,business); serviceBusiness = ServiceBusinessUtil.getServiceBusiness(business.getBusinessTypeCd()); JSONObject responseJson = doRequestBusinessSystem(dataFlow, serviceBusiness, requestBusinessJson); OrderDataFlowContextFactory.addCostTime(dataFlow, business.getBusinessTypeCd(), "è°ç¨"+business.getBusinessTypeCd()+"-æ¤å èæ¶", businessStartDate); // saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),requestBusinessJson.toJSONString()), // LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),responseJson.toJSONString()), // DateUtil.getCurrentDate().getTime() - businessStartDate.getTime()); } } /** * è°ç¨ä¸æ¸¸ç³»ç» * @param dataFlow * @param serviceBusiness * @param requestBusinessJson è¯·æ±æ¥æ * @return */ private JSONObject doRequestBusinessSystem(IOrderDataFlowContext dataFlow, ServiceBusiness serviceBusiness, JSONObject requestBusinessJson) { String responseMessage; Assert.hasLength(serviceBusiness.getInvokeType(),"c_service_business表é ç½®åºéï¼invoke_type ä¸è½ä¸ºç©º"+ serviceBusiness.getBusinessTypeCd()); if(ServiceBusinessConstant.INVOKE_TYPE_WEBSERVICE.equals(serviceBusiness.getInvokeType())) {//webserviceæ¹å¼ String url = serviceBusiness.getUrl(); String[] urls = url.split("#"); if(urls.length != 2){ throw new ConfigDataException(ResponseConstant.RESULT_CODE_CONFIG_ERROR,"é ç½®é误ï¼c_service_businessé ç½®urlåæ®µé误"+serviceBusiness.getBusinessTypeCd()); } String webserviceUrl = CodeMapUtil.getDynamicConstantValue(urls[0]); String method = CodeMapUtil.getDynamicConstantValue(urls[1]); responseMessage = (String) WebServiceAxisClient.callWebService(webserviceUrl,method, new Object[]{requestBusinessJson.toJSONString()}, serviceBusiness.getTimeout()); }else if(ServiceBusinessConstant.INVOKE_TYPE_HTTP_POST.equals(serviceBusiness.getInvokeType())){ //http://user-service/test/sayHello String httpPostUrl = CodeMapUtil.getDynamicConstantValue(serviceBusiness.getUrl()); responseMessage = restTemplate.postForObject(httpPostUrl,requestBusinessJson.toJSONString(),String.class); }else if(ServiceBusinessConstant.INVOKE_TYPE_OUT_HTTP_POST.equals(serviceBusiness.getInvokeType())){ String httpPostUrl = CodeMapUtil.getDynamicConstantValue(serviceBusiness.getUrl()); responseMessage = restTemplateNoLoadBalanced.postForObject(httpPostUrl,requestBusinessJson.toJSONString(),String.class); } else {//postæ¹å¼ throw new ConfigDataException(ResponseConstant.RESULT_CODE_CONFIG_ERROR,"é ç½®é误ï¼c_service_businessé ç½®urlåæ®µé误,å½åæ æ³è¯å«"+serviceBusiness.getBusinessTypeCd()); } if(StringUtil.isNullOrNone(responseMessage) || !Assert.isJsonObject(responseMessage)){ throw new BusinessException(ResponseConstant.RESULT_CODE_INNER_ERROR,"䏿¸¸ç³»ç»è¿åæ ¼å¼ä¸æ£ç¡®ï¼è¯·æåè®®è§èå¤ç"); } JSONObject responseJson = JSONObject.parseObject(responseMessage); Assert.jsonObjectHaveKey(responseJson,"response","䏿¸¸è¿åæ¥ææ ¼å¼éè¯¯ï¼æ²¡æå å«responseJsonèç¹ã"+serviceBusiness.getBusinessTypeCd()+"ã"); JSONObject responseInfo = responseJson.getJSONObject("response"); Assert.jsonObjectHaveKey(responseInfo,"code","䏿¸¸è¿åæ¥ææ ¼å¼é误ï¼response èç¹ä¸æ²¡æå å«codeèç¹ã"+serviceBusiness.getBusinessTypeCd()+"ã"); if(!ResponseConstant.RESULT_CODE_SUCCESS.equals(responseInfo.getString("code"))){ throw new BusinessException(ResponseConstant.RESULT_PARAM_ERROR,"ä¸å¡ç³»ç»å¤ç失败ï¼"+responseInfo.getString("message")); } return responseJson; } private String doTransferRequestBusinessSystem(DataFlow dataFlow, AppService service, String reqData) { String responseMessage; if(service.getMethod() == null || "".equals(service.getMethod())) {//postæ¹å¼ //http://user-service/test/sayHello HttpHeaders header = new HttpHeaders(); for(String key : dataFlow.getRequestCurrentHeaders().keySet()){ header.add(key,dataFlow.getRequestCurrentHeaders().get(key)); } HttpEntity<String> httpEntity = new HttpEntity<String>(reqData, header); responseMessage = restTemplateNoLoadBalanced.postForObject(service.getUrl(),httpEntity,String.class); }else{//webserviceæ¹å¼ responseMessage = (String) WebServiceAxisClient.callWebService(service.getUrl(),service.getMethod(), new Object[]{dataFlow.getRequestBusinessJson().toJSONString()}, service.getTimeOut()); } return responseMessage; } /** * æ°æ®ä¿åå°BusinessTable ä¸ * @param dataFlow * @param synchronousBusinesses * @param responseBusinesses */ private void doSaveDataInfoToBusinessTable(IOrderDataFlowContext dataFlow, List<Business> synchronousBusinesses, JSONArray responseBusinesses) { Date businessStartDate; ServiceBusiness serviceBusiness; JSONObject requestBusinessJson; for(Business business : synchronousBusinesses) { businessStartDate = DateUtil.getCurrentDate(); //åèµ·Businessè¿ç¨ updateBusinessStatusCdByBId(business.getbId(),StatusConstant.STATUS_CD_BUSINESS); serviceBusiness = ServiceBusinessUtil.getServiceBusiness(business.getBusinessTypeCd()); requestBusinessJson = OrderDataFlowContextFactory.getRequestBusinessJson(dataFlow,business); JSONObject responseJson = doRequestBusinessSystem(dataFlow, serviceBusiness, requestBusinessJson); //åå¸äºä»¶ DataFlowEventPublishing.invokeBusinessBSuccess(dataFlow,business); responseBusinesses.add(responseJson); OrderDataFlowContextFactory.addCostTime(dataFlow, business.getBusinessTypeCd(), "è°ç¨"+business.getBusinessTypeCd()+"èæ¶", businessStartDate); /* saveLogMessage(null,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),requestBusinessJson.toJSONString()), LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),responseJson.toJSONString()), DateUtil.getCurrentDate().getTime()-businessStartDate.getTime());*/ } } /** * å¤ç弿¥ä¸å¡ * @param */ private void doAsynchronousBusinesses(IOrderDataFlowContext dataFlow) throws BusinessException{ Date startDate = DateUtil.getCurrentDate(); //6.3 å¤ç弿¥ï¼ææ¶æ¯ééå¤ç List<Business> asynchronousBusinesses = OrderDataFlowContextFactory.getAsynchronousBusinesses(dataFlow); if(asynchronousBusinesses == null || asynchronousBusinesses.size() == 0){ return ; } ServiceBusiness serviceBusiness; try { for (Business business : asynchronousBusinesses) { serviceBusiness = ServiceBusinessUtil.getServiceBusiness(business.getBusinessTypeCd()); KafkaFactory.sendKafkaMessage(serviceBusiness.getMessageTopic(), "", OrderDataFlowContextFactory.getRequestBusinessJson(dataFlow,business).toJSONString()); } }catch (Exception e){ throw new BusinessException(ResponseConstant.RESULT_CODE_INNER_ERROR,e.getMessage()); } OrderDataFlowContextFactory.addCostTime(dataFlow, "doSynchronousBusinesses", "弿¥è°ç¨ä¸å¡ç³»ç»æ»èæ¶", startDate); // saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),dataFlow.getRequestBusinessJson().toJSONString()), // LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),dataFlow.getResponseBusinessJson().toJSONString()), // DateUtil.getCurrentDate().getTime()-startDate.getTime()); } /** * ä¿åæ¥å¿ä¿¡æ¯ * @param dataFlow æ°æ®æµå¯¹è±¡ å°è£ ç¨æ·è¯·æ±çä¿¡æ¯ * * @param requestJson è¯·æ±æ¥æ æ ¼å¼ä¸º * {"headers":"", * "body":"" * } * @param responseJson è¯·æ±æ¥æ æ ¼å¼ä¸º * {"headers":"", * "body":"" * } */ private void saveLogMessage(DataFlow dataFlow,JSONObject requestJson,JSONObject responseJson,long costTime){ LogAgent.sendLog(dataFlow,requestJson,responseJson,costTime); } /** * ä¿åæ¥å¿ä¿¡æ¯ * @param requestJson */ private void saveLogMessage(String requestJson,String responseJson){ try{ if(MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_LOG_ON_OFF))){ JSONObject log = new JSONObject(); log.put("request",requestJson); log.put("response",responseJson); KafkaFactory.sendKafkaMessage(KafkaConstant.TOPIC_LOG_NAME,"",log.toJSONString()); } }catch (Exception e){ logger.error("æ¥éæ¥å¿åºéäºï¼",e); } } /** * ä¿åèæ¶ä¿¡æ¯ * @param dataFlow */ private void saveCostTimeLogMessage(DataFlow dataFlow){ try{ if(MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_COST_TIME_ON_OFF))){ List<DataFlowLinksCost> dataFlowLinksCosts = dataFlow.getLinksCostDates(); JSONObject costDate = new JSONObject(); JSONArray costDates = new JSONArray(); JSONObject newObj = null; for(DataFlowLinksCost dataFlowLinksCost : dataFlowLinksCosts){ newObj = JSONObject.parseObject(JSONObject.toJSONString(dataFlowLinksCost)); newObj.put("dataFlowId",dataFlow.getDataFlowId()); newObj.put("transactionId",dataFlow.getTransactionId()); costDates.add(newObj); } costDate.put("costDates",costDates); KafkaFactory.sendKafkaMessage(KafkaConstant.TOPIC_COST_TIME_LOG_NAME,"",costDate.toJSONString()); } }catch (Exception e){ logger.error("æ¥éæ¥å¿åºéäºï¼",e); } } /** * ä¿®æ¹c_businessç¶æ * @param bId * @param statusCd */ private void updateBusinessStatusCdByBId(String bId,String statusCd){ Map business = new HashMap(); business.put("bId",bId); business.put("statusCd",statusCd); business.put("finishTime",DateUtil.getCurrentDate()); centerServiceDaoImpl.updateBusinessByBId(business); } public ICenterServiceDAO getCenterServiceDaoImpl() { return centerServiceDaoImpl; } public void setCenterServiceDaoImpl(ICenterServiceDAO centerServiceDaoImpl) { this.centerServiceDaoImpl = centerServiceDaoImpl; } public RestTemplate getRestTemplate() { return restTemplate; } public void setRestTemplate(RestTemplate restTemplate) { this.restTemplate = restTemplate; } public IQueryServiceSMO getQueryServiceSMOImpl() { return queryServiceSMOImpl; } public void setQueryServiceSMOImpl(IQueryServiceSMO queryServiceSMOImpl) { this.queryServiceSMOImpl = queryServiceSMOImpl; } public RestTemplate getRestTemplateNoLoadBalanced() { return restTemplateNoLoadBalanced; } public void setRestTemplateNoLoadBalanced(RestTemplate restTemplateNoLoadBalanced) { this.restTemplateNoLoadBalanced = restTemplateNoLoadBalanced; } } OrderService/src/main/resources/application-dev.yml
File was renamed from CenterService/src/main/resources/application-dev.yml @@ -29,7 +29,7 @@ enabled: true force: true application: name: center-service name: order-service redis: database: 0 host: dev.redis.java110.com OrderService/src/main/resources/application-prod.yml
File was renamed from CenterService/src/main/resources/application-prod.yml @@ -29,7 +29,7 @@ enabled: true force: true application: name: center-service name: order-service redis: database: 0 host: hc.java110.com OrderService/src/main/resources/application-test.yml
File was renamed from CenterService/src/main/resources/application-test.yml @@ -29,7 +29,7 @@ enabled: true force: true application: name: center-service name: order-service redis: database: 0 host: hc.java110.com OrderService/src/main/resources/application.yml
OrderService/src/main/resources/banner.txt
OrderService/src/test/java/com/java110/AppTest.java
PropertyService/src/main/java/com/java110/property/listener/DeletePropertyAttrListener.java
@@ -42,7 +42,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_DELETE_PROPERTY_ATTR; } PropertyService/src/main/java/com/java110/property/listener/DeletePropertyCerdentialsListener.java
@@ -45,7 +45,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_DELETE_PROPERTY_CERDENTIALS; } PropertyService/src/main/java/com/java110/property/listener/DeletePropertyHouseListener.java
@@ -42,7 +42,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_DELETE_PROPERTY_HOUSE; } PropertyService/src/main/java/com/java110/property/listener/DeletePropertyPhotoListener.java
@@ -41,7 +41,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_DELETE_PROPERTY_PHOTO; } PropertyService/src/main/java/com/java110/property/listener/DeletePropertyUserListener.java
@@ -41,7 +41,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_DELETE_PROPERTY_USER; } PropertyService/src/main/java/com/java110/property/listener/SavePropertyCerdentialsListener.java
@@ -44,7 +44,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_PROPERTY_CERDENTIALS; } PropertyService/src/main/java/com/java110/property/listener/SavePropertyFeeListener.java
@@ -38,7 +38,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_PROPERTY_FEE; } PropertyService/src/main/java/com/java110/property/listener/SavePropertyHouseListener.java
@@ -44,7 +44,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_PROPERTY_HOUSE; } PropertyService/src/main/java/com/java110/property/listener/SavePropertyInfoListener.java
@@ -44,7 +44,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_PROPERTY_INFO; } PropertyService/src/main/java/com/java110/property/listener/SavePropertyPhotoListener.java
@@ -44,7 +44,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_PROPERTY_PHOTO; } PropertyService/src/main/java/com/java110/property/listener/SavePropertyUserListener.java
@@ -44,7 +44,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_PROPERTY_USER; } PropertyService/src/main/java/com/java110/property/listener/UpdatePropertyCerdentialsListener.java
@@ -41,7 +41,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_UPDATE_PROPERTY_CERDENTIALS; } PropertyService/src/main/java/com/java110/property/listener/UpdatePropertyFeeListener.java
@@ -41,7 +41,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_UPDATE_PROPERTY_FEE; } PropertyService/src/main/java/com/java110/property/listener/UpdatePropertyHouseListener.java
@@ -42,7 +42,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_UPDATE_PROPERTY_HOUSE; } PropertyService/src/main/java/com/java110/property/listener/UpdatePropertyInfoListener.java
@@ -42,7 +42,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_UPDATE_PROPERTY_INFO; } PropertyService/src/main/java/com/java110/property/listener/UpdatePropertyPhotoListener.java
@@ -41,7 +41,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_UPDATE_PROPERTY_PHOTO; } ShopService/src/main/java/com/java110/shop/listener/DeleteShopAttrAndAttrParamListener.java
@@ -42,7 +42,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_DELETE_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/DeleteShopCatalogListener.java
@@ -40,7 +40,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_DELETE_SHOP_CATALOG; } ShopService/src/main/java/com/java110/shop/listener/DeleteShopDescListener.java
@@ -40,7 +40,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_DELETE_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/DeleteShopInfoListener.java
@@ -42,7 +42,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_DELETE_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/DeleteShopPhotoListener.java
@@ -42,7 +42,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_DELETE_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/DeleteShopPreferentialListener.java
@@ -40,7 +40,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_DELETE_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/FlushAboutBuyIdListener.java
@@ -27,7 +27,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_BUY_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/FlushAboutShopIdListener.java
@@ -26,7 +26,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/FlushShopCatalogIdListener.java
@@ -26,7 +26,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_SHOP_CATALOG; } ShopService/src/main/java/com/java110/shop/listener/SaveBuyShopAttrListener.java
@@ -38,7 +38,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_BUY_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/SaveBuyShopListener.java
@@ -36,7 +36,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_BUY_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/SaveShopAttrAndAttrParamListener.java
@@ -39,7 +39,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/SaveShopCatalogListener.java
@@ -41,7 +41,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_SHOP_CATALOG; } ShopService/src/main/java/com/java110/shop/listener/SaveShopDescListener.java
@@ -41,7 +41,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/SaveShopInfoListener.java
@@ -45,7 +45,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/SaveShopPhotoListener.java
@@ -38,7 +38,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/SaveShopPreferentialListener.java
@@ -41,7 +41,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/UpdateShopAttrAndAttrParamListener.java
@@ -43,7 +43,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_UPDATE_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/UpdateShopCatalogListener.java
@@ -40,7 +40,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_UPDATE_SHOP_CATALOG; } ShopService/src/main/java/com/java110/shop/listener/UpdateShopDescListener.java
@@ -40,7 +40,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_UPDATE_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/UpdateShopInfoListener.java
@@ -42,7 +42,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_UPDATE_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/UpdateShopPhotoListener.java
@@ -42,7 +42,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_UPDATE_SHOP_INFO; } ShopService/src/main/java/com/java110/shop/listener/UpdateShopPreferentialListener.java
@@ -40,7 +40,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_UPDATE_SHOP_INFO; } StoreService/src/main/java/com/java110/store/listener/DeleteStoreInfoListener.java
@@ -45,7 +45,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_DELETE_STORE_INFO; } StoreService/src/main/java/com/java110/store/listener/SaveStoreInfoListener.java
@@ -44,7 +44,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_STORE_INFO; } StoreService/src/main/java/com/java110/store/listener/UpdateStoreInfoListener.java
@@ -45,7 +45,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_UPDATE_STORE_INFO; } StoreService/src/main/java/com/java110/store/listener/memberJoinedStoreListener.java
@@ -46,7 +46,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_MEMBER_JOINED_STORE; } StoreService/src/main/java/com/java110/store/listener/memberQuitStoreListener.java
@@ -42,7 +42,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_MEMBER_QUIT_STORE; } UserService/src/main/java/com/java110/user/listener/ModifyUserInfoListener.java
@@ -44,7 +44,7 @@ * @return */ @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_MODIFY_USER_INFO; } UserService/src/main/java/com/java110/user/listener/RecoverUserInfoListener.java
@@ -41,7 +41,7 @@ * @return */ @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_RECOVER_USER_INFO; } UserService/src/main/java/com/java110/user/listener/RemoveUserInfoListener.java
@@ -41,7 +41,7 @@ * @return */ @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_REMOVE_USER_INFO; } UserService/src/main/java/com/java110/user/listener/SaveUserAddressListener.java
@@ -46,7 +46,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_USER_ADDRESS; } UserService/src/main/java/com/java110/user/listener/SaveUserCredentialsListener.java
@@ -43,7 +43,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_USER_CREDENTIALS; } UserService/src/main/java/com/java110/user/listener/SaveUserInfoListener.java
@@ -44,7 +44,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_USER_INFO; } UserService/src/main/java/com/java110/user/listener/SaveUserTagListener.java
@@ -46,7 +46,7 @@ } @Override public String getServiceCode() { public String getBusinessTypeCd() { return ServiceCodeConstant.SERVICE_CODE_SAVE_USER_TAG; } java110-bean/src/main/java/com/java110/entity/center/Business.java
@@ -14,6 +14,8 @@ //ä¸å¡ç¼ç private String serviceCode; private String businessTypeCd; private String serviceName; private String remark; @@ -131,7 +133,7 @@ try{ this.setbId(businessObj.getString("bId")); this.setServiceCode(businessObj.getString("serviceCode")); this.setBusinessTypeCd(businessObj.getString("businessTypeCd")); if(businessObj.containsKey("serviceName")) { this.setServiceName(businessObj.getString("serviceName")); } @@ -172,4 +174,12 @@ } return 0; } public String getBusinessTypeCd() { return businessTypeCd; } public void setBusinessTypeCd(String businessTypeCd) { this.businessTypeCd = businessTypeCd; } } java110-bean/src/main/java/com/java110/entity/order/Attrs.java
New file @@ -0,0 +1,40 @@ package com.java110.entity.order; /** * @author wux * @create 2019-02-05 ä¸å11:20 * @desc 订å屿§ å¯¹åº è¡¨c_orders_attrs **/ public class Attrs { private String attrId; private String specCd; private String value; public String getAttrId() { return attrId; } public void setAttrId(String attrId) { this.attrId = attrId; } public String getSpecCd() { return specCd; } public void setSpecCd(String specCd) { this.specCd = specCd; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } } java110-bean/src/main/java/com/java110/entity/order/BaseOrder.java
New file @@ -0,0 +1,70 @@ package com.java110.entity.order; import java.util.Date; /** * @author wux * @create 2019-02-05 ä¸å11:35 * @desc 订åå ¬å ±é¨å **/ public class BaseOrder { /** * 订å宿æ¶é´ */ private Date finishTime; /** * 订å夿³¨ */ private String remark; /** * 订åç¶æ */ private String statusCd; /** * å建æ¶é´ */ private Date createTime; public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } public Date getFinishTime() { return finishTime; } public void setFinishTime(Date finishTime) { this.finishTime = finishTime; } public String getRemark() { return remark; } public void setRemark(String remark) { this.remark = remark; } public String getStatusCd() { return statusCd; } public void setStatusCd(String statusCd) { this.statusCd = statusCd; } } java110-bean/src/main/java/com/java110/entity/order/Business.java
New file @@ -0,0 +1,86 @@ package com.java110.entity.order; import com.alibaba.fastjson.JSONObject; import java.util.List; /** * @author wux * @create 2019-02-05 ä¸å11:27 * @desc 订å项 对åºè¡¨c_business **/ public class Business extends BusinessPlus implements Comparable{ /** * 订åID */ private String oId; /** * 订å项ID */ private String bId; /** * ä¸å¡ç±»å */ private String businessTypeCd; List<BusinessAttrs> businessAttrs; private JSONObject data; public String getoId() { return oId; } public void setoId(String oId) { this.oId = oId; } public String getbId() { return bId; } public void setbId(String bId) { this.bId = bId; } public String getBusinessTypeCd() { return businessTypeCd; } public void setBusinessTypeCd(String businessTypeCd) { this.businessTypeCd = businessTypeCd; } public List<BusinessAttrs> getBusinessAttrs() { return businessAttrs; } public void setBusinessAttrs(List<BusinessAttrs> businessAttrs) { this.businessAttrs = businessAttrs; } public JSONObject getData() { return data; } public void setData(JSONObject data) { this.data = data; } @Override public int compareTo(Object o) { Business otherBusiness = (Business)o; if(this.getSeq() > otherBusiness.getSeq()) { return -1; } return 0; } } java110-bean/src/main/java/com/java110/entity/order/BusinessAttrs.java
New file @@ -0,0 +1,10 @@ package com.java110.entity.order; /** * @author wux * @create 2019-02-05 ä¸å11:20 * @desc 订å屿§ å¯¹åº è¡¨c_orders_attrs **/ public class BusinessAttrs extends Attrs { } java110-bean/src/main/java/com/java110/entity/order/BusinessPlus.java
New file @@ -0,0 +1,29 @@ package com.java110.entity.order; /** * @author wux * @create 2019-02-05 ä¸å1:50 * @desc Businessæ©å±ç±» **/ public class BusinessPlus extends BaseOrder{ private String invokeModel; private long seq; public String getInvokeModel() { return invokeModel; } public void setInvokeModel(String invokeModel) { this.invokeModel = invokeModel; } public long getSeq() { return seq; } public void setSeq(long seq) { this.seq = seq; } } java110-bean/src/main/java/com/java110/entity/order/Orders.java
New file @@ -0,0 +1,105 @@ package com.java110.entity.order; import java.util.Date; import java.util.List; /** * @author wux * @create 2019-02-05 ä¸å11:10 * @desc 订åç±» 对åºè¡¨c_orders **/ public class Orders extends BaseOrder{ /** * 订åID */ private String oId; /** * ç»ä»¶ID */ private String appId; /** * å¤é¨äº¤ææµæ°´ */ private String extTransactionId; /** * ç¨æ·ID */ private String userId; /** * å¤é¨ç³»ç»è¯·æ±æ¶é´ */ private Date requestTime; /** * 订åç±»å */ private String orderTypeCd; private List<OrdersAttrs> ordersAttrs; public String getoId() { return oId; } public void setoId(String oId) { this.oId = oId; } public String getAppId() { return appId; } public void setAppId(String appId) { this.appId = appId; } public String getExtTransactionId() { return extTransactionId; } public void setExtTransactionId(String extTransactionId) { this.extTransactionId = extTransactionId; } public String getUserId() { return userId; } public void setUserId(String userId) { this.userId = userId; } public Date getRequestTime() { return requestTime; } public void setRequestTime(Date requestTime) { this.requestTime = requestTime; } public String getOrderTypeCd() { return orderTypeCd; } public void setOrderTypeCd(String orderTypeCd) { this.orderTypeCd = orderTypeCd; } public List<OrdersAttrs> getOrdersAttrs() { return ordersAttrs; } public void setOrdersAttrs(List<OrdersAttrs> ordersAttrs) { this.ordersAttrs = ordersAttrs; } } java110-bean/src/main/java/com/java110/entity/order/OrdersAttrs.java
New file @@ -0,0 +1,10 @@ package com.java110.entity.order; /** * @author wux * @create 2019-02-05 ä¸å11:20 * @desc 订å屿§ å¯¹åº è¡¨c_orders_attrs **/ public class OrdersAttrs extends Attrs{ } java110-bean/src/main/java/com/java110/entity/order/ServiceBusiness.java
New file @@ -0,0 +1,90 @@ package com.java110.entity.order; /** * @author wux * @create 2019-02-05 ä¸å10:22 * @desc æå¡ä¸å¡ç±» **/ public class ServiceBusiness { private long serviceBusinessId; /** * ä¸å¡ç±»å */ private String businessTypeCd; /** * è°ç¨ç±»å 1 http-post(å¾®æå¡å åºç¨) 2 webservice 3 kafka 4 http-post(å¾®æå¡ä¹å¤åºç¨) */ private String invokeType; /** * 忥æ¶çurlå°å å½invokeType 为 3 æ¶åkafka topic */ private String url; private String messageTopic; private int timeout; private int retryCount; public long getServiceBusinessId() { return serviceBusinessId; } public void setServiceBusinessId(long serviceBusinessId) { this.serviceBusinessId = serviceBusinessId; } public String getBusinessTypeCd() { return businessTypeCd; } public void setBusinessTypeCd(String businessTypeCd) { this.businessTypeCd = businessTypeCd; } public String getInvokeType() { return invokeType; } public void setInvokeType(String invokeType) { this.invokeType = invokeType; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public String getMessageTopic() { return messageTopic; } public void setMessageTopic(String messageTopic) { this.messageTopic = messageTopic; } public int getTimeout() { return timeout; } public void setTimeout(int timeout) { this.timeout = timeout; } public int getRetryCount() { return retryCount; } public void setRetryCount(int retryCount) { this.retryCount = retryCount; } } java110-common/src/main/java/com/java110/common/cache/ServiceBusinessCache.java
New file @@ -0,0 +1,58 @@ package com.java110.common.cache; import com.java110.common.util.SerializeUtil; import com.java110.entity.center.AppRoute; import com.java110.entity.order.ServiceBusiness; import redis.clients.jedis.Jedis; import java.util.List; /** * ä¸å¡ä¿¡æ¯ ç¼åç±» * Created by wuxw on 2018/4/14. */ public class ServiceBusinessCache extends BaseCache { //åç¼ ç¨æ¥å·ç¼åæ¶å é¤ ææä»¥è¿ä¸ªä¸ºåç¼çæ°æ® public final static String _KEY_SERVICE_BUSINESS = "_KEY_ALL_SERVICE_BUSINESS"; /** * è·å ä¸å¡ä¿¡æ¯ * @return */ public static List<ServiceBusiness> getServiceBusiness(){ List<ServiceBusiness> serviceBusinesses = null; Jedis redis = null; try { redis = getJedis(); serviceBusinesses = SerializeUtil.unserializeList(redis.get((_KEY_SERVICE_BUSINESS).getBytes()),ServiceBusiness.class); if(serviceBusinesses == null || serviceBusinesses.size() ==0) { return null; } }finally { if(redis != null){ redis.close(); } } return serviceBusinesses; } /** * ä¿åè·¯ç±ä¿¡æ¯ * @param serviceBusinesses */ public static void setServiceBusiness(List<ServiceBusiness> serviceBusinesses){ Jedis redis = null; try { redis = getJedis(); redis.set((_KEY_SERVICE_BUSINESS).getBytes(),SerializeUtil.serializeList(serviceBusinesses)); }finally { if(redis != null){ redis.close(); } } } } java110-common/src/main/java/com/java110/common/constant/CommonConstant.java
@@ -121,6 +121,12 @@ */ public final static String CACHE_SERVICE_SQL = "SERVICE_SQL"; /** * ä¸å¡ä¿¡æ¯å¸¸é */ public final static String CACHE_SERVICE_BUSINESS = "SERVICE_BUSINESS"; public final static String CACHE_ALL = "All"; @@ -136,6 +142,7 @@ public final static String HTTP_APP_ID = "app_id"; public final static String HTTP_TRANSACTION_ID = "transaction_id"; public final static String HTTP_REQ_TIME = "req_time"; public final static String HTTP_RES_TIME = "res_time"; public final static String HTTP_SIGN = "sign"; public final static String HTTP_PARAM = "params"; public final static String HTTP_ORDER_TYPE_CD = "order_type_cd"; java110-common/src/main/java/com/java110/common/constant/ServiceBusinessConstant.java
New file @@ -0,0 +1,24 @@ package com.java110.common.constant; /** * @author wux * @create 2019-02-05 ä¸å11:28 * @desc ä¸å¡ä¿¡æ¯å¸¸éç±» **/ public class ServiceBusinessConstant { /** * http post æ¹å¼ (å¾®æå¡å åºç¨) */ public final static String INVOKE_TYPE_HTTP_POST = "1"; /** * webservice æ¹å¼è°ç¨ */ public final static String INVOKE_TYPE_WEBSERVICE = "2"; /** * http-post(å¾®æå¡ä¹å¤åºç¨) */ public final static String INVOKE_TYPE_OUT_HTTP_POST = "3"; } java110-common/src/main/java/com/java110/common/exception/ConfigDataException.java
New file @@ -0,0 +1,189 @@ package com.java110.common.exception; import com.alibaba.fastjson.JSONObject; import java.io.PrintStream; import java.io.PrintWriter; /** * é ç½®æ°æ®å¼å¸¸ * Created by wuxw on 2018/4/14. */ public class ConfigDataException extends RuntimeException { private Result result; private Throwable cause = this; public ConfigDataException(){} /** * æé æ¹æ³ * @param result è¿åå¼ * @param cause å¼å¸¸å æ */ public ConfigDataException(Result result, Throwable cause) { super(result.getMsg(), cause); this.result = result; } /** * æé æ¹æ³ * @param code è¿åç * @param msg éè¯¯æ¶æ¯ */ public ConfigDataException(int code, String msg) { super(msg); this.result = new Result(code, msg); } public ConfigDataException(String code, String msg) { super(msg); this.result = new Result(code, msg); } /** * æé æ¹æ³ * @param result è¿åå¼ * @param detail å ·ä½çè¿åæ¶æ¯ */ public ConfigDataException(Result result, String detail) { super(result.getMsg() + "," + detail); this.result = new Result(result.getCode(), result.getMsg() + "," + detail); } /** * æé æ¹æ³ * @param result è¿åå¼ * @param detail å ·ä½çè¿åæ¶æ¯ * @param cause å¼å¸¸å æ */ public ConfigDataException(Result result, String detail, Throwable cause) { super(result.getMsg() + "," + detail, cause); this.result = new Result(result.getCode(), result.getMsg() + "," + detail); } /** * æé æ¹æ³ * @param code è¿åç * @param msg è¿åæ¶æ¯ * @param cause å¼å¸¸å æ */ public ConfigDataException(int code, String msg, Throwable cause) { super(msg, cause); if(cause != null) { if(cause.getCause() != null) { msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500); } msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500); } this.result = new Result(code, msg); } /** * æé æ¹æ³ * @param code è¿åç * @param cause å¼å¸¸å æ */ public ConfigDataException(int code, Throwable cause) { super(cause); String msg = ""; if(cause != null) { if(cause.getCause() != null) { msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500); } msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500); } this.result = new Result(code, msg); } /** * * TODO ç®åæè¿°è¯¥æ¹æ³çå®ç°åè½ï¼å¯éï¼. * @see Throwable#getCause() */ public synchronized Throwable getCause() { return (cause==this ? super.getCause() : cause); } /** * è¿åå¼å¸¸æ¶æ¯ * @return å¼å¸¸æ¶æ¯ */ @Override public String getMessage() { return ExceptionUtils.buildMessage(super.getMessage(), getCause()); } /** * å¼å¸¸ * @return */ public String toJsonString() { JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}"); JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception"); if (getResult() != null) exceptionJsonObj.putAll(JSONObject.parseObject(result.toString())); exceptionJsonObj.put("exceptionTrace",getMessage()); return exceptionJsonObj.toString(); } @Override public void printStackTrace(PrintStream ps) { ps.print("<exception>"); if (getResult() != null) { ps.print(result.toString()); } ps.append("<exceptionTrace>"); Throwable cause = getCause(); if (cause == null) { super.printStackTrace(ps); } else { ps.println(this); ps.print("Caused by: "); cause.printStackTrace(ps); } ps.append("</exceptionTrace>"); ps.println("</exception>"); } @Override public void printStackTrace(PrintWriter pw) { pw.print("<exception>"); if (getResult() != null) { pw.print(result.toString()); } pw.append("<exceptionTrace>"); Throwable cause = getCause(); if (cause == null) { super.printStackTrace(pw); } else { pw.println(this); pw.print("Caused by: "); cause.printStackTrace(pw); } pw.append("</exceptionTrace>"); pw.println("</exception>"); } /** * è¿åå¼å¸¸å¼ * @return å¼å¸¸å¼å¯¹è±¡ */ public Result getResult() { return result; } public void setResult(Result result) { this.result = result; } } java110-common/src/main/java/com/java110/common/util/Assert.java
@@ -180,4 +180,12 @@ throw new IllegalArgumentException(msg); } } public static void isDate(String text,String msg){ try{ DateUtil.getDefaultDateFromString(text); }catch (Exception e){ throw new IllegalArgumentException(msg); } } } java110-common/src/main/java/com/java110/common/util/ServiceBusinessUtil.java
New file @@ -0,0 +1,65 @@ /** * æä»¶åï¼CodeMapUtil.java * <p> * çæ¬ä¿¡æ¯ï¼ * æ¥æï¼2017-3-1 * Copyright äºä¿¡èå Corporation 2017 * çæææ */ package com.java110.common.util; import com.java110.common.cache.ServiceBusinessCache; import com.java110.common.log.LoggerEngine; import com.java110.common.namespace.NameSpaceHandler; import com.java110.entity.mapping.CodeMapping; import com.java110.entity.order.ServiceBusiness; import java.util.List; /** * ç±»åç§°ï¼ServiceBusinessUtil * ç±»æè¿°ï¼ * å建人ï¼å´å¦æ * å建æ¶é´ï¼2017-3-1 */ @SuppressWarnings("unchecked") public class ServiceBusinessUtil { /** * æ¥è¯¢æææ°æ® * * @return */ public static List<ServiceBusiness> getServiceBusinesses() { return ServiceBusinessCache.getServiceBusiness(); } /** * æ ¹æ®ä¸å¡ç±»åæ¥è¯¢ ä¸å¡ä¿¡æ¯ * * @param businessTypeCd ä¸å¡ç±»å * @return */ public static ServiceBusiness getServiceBusiness(String businessTypeCd) { if(StringUtil.isEmpty(businessTypeCd)){ return null; } List<ServiceBusiness> serviceBusinesses = getServiceBusinesses(); if(serviceBusinesses == null || serviceBusinesses.size() == 0){ return null; } for(ServiceBusiness serviceBusiness : serviceBusinesses){ if(businessTypeCd.equals(serviceBusiness.getBusinessTypeCd())){ return serviceBusiness; } } return null; } } java110-config/db/OrderService/create_table.sql
File was renamed from java110-config/db/CenterService/create_table.sql @@ -142,6 +142,19 @@ status_cd VARCHAR(2) NOT NULL default '0' COMMENT 'æ°æ®ç¶æï¼è¯¦ç»åèc_status表ï¼0å¨ç¨ï¼1失æ', UNIQUE KEY (service_id) ); -- æå¡ä¸å¡è¡¨ create table c_service_business( service_business_id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id', business_type_cd VARCHAR(4) NOT NULL COMMENT 'ä¸å¡é¡¹ç±»åï¼åèc_business_type表', invoke_type varchar(4) not null comment 'è°ç¨ç±»åï¼1 http-post(å¾®æå¡å åºç¨) 2 webservice 3 http-post(å¾®æå¡ä¹å¤åºç¨)', url VARCHAR(200) COMMENT 'ç®æ å°å', message_topic varchar(50) comment '弿¥æ¶çæ¶æ¯topicåç§°', timeout INT NOT NULL DEFAULT 60 COMMENT 'è¶ æ¶æ¶é´', retry_count INT NOT NULL DEFAULT 3 COMMENT 'éè¯æ¬¡æ°', create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'å建æ¶é´', status_cd VARCHAR(2) NOT NULL default '0' COMMENT 'æ°æ®ç¶æï¼è¯¦ç»åèc_status表ï¼0å¨ç¨ï¼1失æ', UNIQUE KEY (business_type_cd) ); java110-config/src/main/resources/logback.xml
@@ -62,7 +62,7 @@ <logger name="org.springframework" level="error"/> <logger name="com.java110.api" level="DEBUG"/> <logger name="com.java110.center" level="DEBUG"/> <logger name="com.java110.order" level="DEBUG"/> <logger name="com.java110" level="DEBUG"/> <!--myibatis log configure--> java110-config/src/main/resources/mapper/center/CenterServiceDAOImplMapper.xml
@@ -72,6 +72,18 @@ ]]> </update> <!-- 彿æä¸å¡å¨ä½æ¯å¦é½æ¯Cï¼å°è®¢åä¿¡æ¯æ¹ä¸º C--> <update id="completeOrderByOId" parameterType="String" > <![CDATA[ update c_orders co set co.status_cd = 'C' where co.status_cd='S' and co.o_id = #{oId} and not exists( select 1 from c_business cb where cb.status_cd <> 'C' and cb.o_id = co.o_id ) ]]> </update> <select id="getOrderInfoByBId" parameterType="String" resultType="Map"> <![CDATA[ select co.* from c_orders co where 1 = 1 and exists java110-config/src/main/resources/mapper/service/QueryServiceDAOImplMapper.xml
@@ -21,6 +21,16 @@ <parameter property="resMsg" javaType="java.lang.String" jdbcType="CLOB" mode="OUT" /> </parameterMap> <resultMap type="com.java110.entity.service.ServiceSql" id="serviceBusinessMap"> <result column="service_business_id" jdbcType="INT" property="serviceBusinessId"/> <result column="business_type_cd" jdbcType="VARCHAR" property="serviceTypeCd"/> <result column="invoke_type" jdbcType="VARCHAR" property="invokeType"/> <result column="url" jdbcType="VARCHAR" property="url"/> <result column="message_topic" jdbcType="VARCHAR" property="messageTopic"/> <result column="timeout" jdbcType="INT" property="timeout"/> <result column="retry_count" jdbcType="INT" property="retryCount"/> </resultMap> <!--æ§è¡æ¥è¯¢sql --> <select id="executeSql" parameterType="String" resultType="Map"> ${value} @@ -44,4 +54,19 @@ FROM c_service_sql css WHERE css.status_cd = '0' </select> <select id="queryServiceBusiness" resultMap="serviceBusinessMap"> SELECT a.service_business_id, a.business_type_cd, a.invoke_type, a.url, a.message_topic, a.timeout, a.retry_count FROM c_service_business a WHERE a.status_cd = '0' </select> </mapper> java110-core/src/main/java/com/java110/core/context/AbstractDataFlowContext.java
@@ -2,23 +2,18 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.java110.common.factory.ApplicationContextFactory; import com.java110.common.log.LoggerEngine; import com.java110.common.util.DateUtil; import com.java110.entity.center.Business; import com.java110.entity.center.DataFlowLinksCost; import com.java110.entity.center.DataFlowLog; import org.springframework.http.ResponseEntity; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.*; /** * æ°æ®æµä¸ä¸æ * Created by wuxw on 2018/5/18. */ public abstract class AbstractDataFlowContext extends AbstractTransactionLog implements DataFlowContext,Orders,TransactionLog{ public abstract class AbstractDataFlowContext extends AbstractTransactionLog implements DataFlowContext, IOrders,TransactionLog{ private String dataFlowId; @@ -357,7 +352,7 @@ } public abstract Orders getOrder(); public abstract IOrders getOrder(); protected AbstractDataFlowContext(Date startDate, String code){ this.setStartDate(startDate); java110-core/src/main/java/com/java110/core/context/AbstractDataFlowContextPlus.java
New file @@ -0,0 +1,87 @@ package com.java110.core.context; import com.alibaba.fastjson.JSONObject; import java.util.Map; /** * æ°æ®æµä¸ä¸æ * Created by wuxw on 2018/5/18. */ public abstract class AbstractDataFlowContextPlus implements IDataFlowContextPlus{ private String dataFlowId; /** * 请æ±å¤´ä¿¡æ¯ */ private Map<String,String> reqHeaders; /** * 请æ±ä½ä¿¡æ¯ï¼åªæ¯æjsonï¼ */ private JSONObject reqJson; /** * è¿åå¤´ä¿¡æ¯ */ private Map<String,String> resHeaders; /** * è¿åä½ä¿¡æ¯ ï¼åªæ¯æjsonï¼ */ private JSONObject resJson; @Override public String getDataFlowId() { return dataFlowId; } public void setDataFlowId(String dataFlowId) { this.dataFlowId = dataFlowId; } @Override public Map<String, String> getReqHeaders() { return reqHeaders; } public void setReqHeaders(Map<String, String> reqHeaders) { this.reqHeaders = reqHeaders; } @Override public JSONObject getReqJson() { return reqJson; } public void setReqJson(JSONObject reqJson) { this.reqJson = reqJson; } @Override public Map<String, String> getResHeaders() { return resHeaders; } @Override public void setResHeaders(Map<String, String> resHeaders) { this.resHeaders = resHeaders; } @Override public JSONObject getResJson() { return resJson; } @Override public void setResJson(JSONObject resJson) { this.resJson = resJson; } } java110-core/src/main/java/com/java110/core/context/AbstractOrderDataFlowContext.java
New file @@ -0,0 +1,60 @@ package com.java110.core.context; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.java110.entity.center.Business; import com.java110.entity.center.DataFlowLinksCost; import com.java110.entity.center.DataFlowLog; import org.springframework.http.ResponseEntity; import java.util.*; /** * æ°æ®æµä¸ä¸æ * Created by wuxw on 2018/5/18. */ public abstract class AbstractOrderDataFlowContext extends AbstractDataFlowContextPlus implements IOrderDataFlowContext{ protected AbstractOrderDataFlowContext(Date startDate, String code){} /** * æå»º å¯¹è±¡ä¿¡æ¯ * @param reqInfo * @param headerAll * @return * @throws Exception */ public <T> T builder(String reqInfo, Map<String,String> headerAll) throws Exception{ //é¢å¤ç preBuilder(reqInfo, headerAll); //è°ç¨builder T dataFlowContext = (T)doBuilder(reqInfo, headerAll); //åå¤ç afterBuilder((IOrderDataFlowContext) dataFlowContext); return dataFlowContext; } /** * é¢å¤ç * @param reqInfo * @param headerAll */ protected void preBuilder(String reqInfo, Map<String,String> headerAll) { } /** * æå»ºå¯¹è±¡ * @param reqInfo * @param headerAll * @return * @throws Exception */ public abstract IOrderDataFlowContext doBuilder(String reqInfo, Map<String,String> headerAll) throws Exception; protected void afterBuilder(IOrderDataFlowContext dataFlowContext){ } } java110-core/src/main/java/com/java110/core/context/AbstractOrderNotifyDataFlowContext.java
New file @@ -0,0 +1,94 @@ package com.java110.core.context; import java.util.Date; /** * @author wux * @create 2019-02-07 ä¸å7:01 * @desc 订åéç¥æ°æ®æµä¿¡æ¯ **/ public abstract class AbstractOrderNotifyDataFlowContext extends AbstractDataFlowContextPlus implements IOrderNotifyDataFlowContext,IOrderResponse { protected AbstractOrderNotifyDataFlowContext(Date startDate, String code) { } private String transactionId; private Date responseTime; private String orderTypeCd; private String businessType; private String code; private String message; private String bId; private String businessTypeCd; public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public String getTransactionId() { return transactionId; } public void setTransactionId(String transactionId) { this.transactionId = transactionId; } public Date getResponseTime() { return responseTime; } public void setResponseTime(Date responseTime) { this.responseTime = responseTime; } public String getOrderTypeCd() { return orderTypeCd; } public void setOrderTypeCd(String orderTypeCd) { this.orderTypeCd = orderTypeCd; } public String getBusinessType() { return businessType; } public void setBusinessType(String businessType) { this.businessType = businessType; } public String getbId() { return bId; } public void setbId(String bId) { this.bId = bId; } public String getBusinessTypeCd() { return businessTypeCd; } public void setBusinessTypeCd(String businessTypeCd) { this.businessTypeCd = businessTypeCd; } } java110-core/src/main/java/com/java110/core/context/AbstractOrderResponse.java
New file @@ -0,0 +1,30 @@ package com.java110.core.context; /** * @author wux * @create 2019-02-07 ä¸å7:10 * @desc 订åè¿åæ½è±¡ç±» **/ public class AbstractOrderResponse implements IOrderResponse { private String code; private String message; public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } } java110-core/src/main/java/com/java110/core/context/ApiDataFlow.java
@@ -1,13 +1,8 @@ package com.java110.core.context; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.java110.common.constant.CommonConstant; import com.java110.common.util.DateUtil; import com.java110.common.util.StringUtil; import com.java110.core.factory.GenerateCodeFactory; import com.java110.entity.center.AppRoute; import com.java110.entity.center.Business; import org.springframework.http.ResponseEntity; import java.util.ArrayList; @@ -87,7 +82,7 @@ } @Override public Orders getOrder() { public IOrders getOrder() { return this; } java110-core/src/main/java/com/java110/core/context/BusinessServiceDataFlow.java
@@ -1,6 +1,5 @@ package com.java110.core.context; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.java110.common.constant.ResponseConstant; import com.java110.common.exception.InitDataFlowContextException; @@ -23,7 +22,7 @@ private Map<String,Object> paramOut; @Override public Orders getOrder() { public IOrders getOrder() { return this; } java110-core/src/main/java/com/java110/core/context/CodeDataFlow.java
@@ -74,7 +74,7 @@ } @Override public Orders getOrder() { public IOrders getOrder() { return this; } } java110-core/src/main/java/com/java110/core/context/DataFlow.java
@@ -116,7 +116,7 @@ } @Override public Orders getOrder() { public IOrders getOrder() { return this; } java110-core/src/main/java/com/java110/core/context/DataFlowContext.java
@@ -72,7 +72,7 @@ public Map<String, String> getResponseCurrentHeaders(); public Orders getOrder(); public IOrders getOrder(); /** java110-core/src/main/java/com/java110/core/context/IDataFlowContextPlus.java
New file @@ -0,0 +1,59 @@ package com.java110.core.context; import com.alibaba.fastjson.JSONObject; import com.java110.entity.order.Orders; import java.util.Map; /** * æ»æ°æ®æµå°è£ æ¥å£ */ public interface IDataFlowContextPlus { /** * è·ådataflowId * @return */ public String getDataFlowId(); /** * è·å请æ±å¤´ * @return */ public Map<String, String> getReqHeaders(); /** * 请æ±jsonæ¥æ * @return */ public JSONObject getReqJson(); /** * 设置 è¿åå¤´ä¿¡æ¯ * @param resHeaders è¿åå¤´ä¿¡æ¯ */ public void setResHeaders(Map<String, String> resHeaders); /** * 设置è¿åjsonæ¥æ * @param resJson */ public void setResJson(JSONObject resJson); /** * æ¥è¯¢ è¿åå¤´ä¿¡æ¯ * @return */ public Map<String, String> getResHeaders(); /** * æ¥è¯¢è¿åJSONæ¥æ * @return */ public JSONObject getResJson(); } java110-core/src/main/java/com/java110/core/context/IOrderDataFlowContext.java
New file @@ -0,0 +1,25 @@ package com.java110.core.context; import com.java110.entity.order.Business; import com.java110.entity.order.Orders; import java.util.List; /** * 订åç±» æ°æ®å±å°è£ æ¥å£ */ public interface IOrderDataFlowContext extends IDataFlowContextPlus { /** * è·å订åä¿¡æ¯ * @return */ public Orders getOrders(); /** * è·å ä¸å¡ä¿¡æ¯ * @return */ public List<Business> getBusinessList(); } java110-core/src/main/java/com/java110/core/context/IOrderNotifyDataFlowContext.java
New file @@ -0,0 +1,53 @@ package com.java110.core.context; import java.util.Date; /** * 订åéç¥ä¸ä¸æ */ public interface IOrderNotifyDataFlowContext extends IDataFlowContextPlus{ /** * äº¤ææµæ°´å· * @return */ public String getTransactionId(); /** * è¿åæ¶é´ * @return */ public Date getResponseTime(); /** * 订åç±»å * @return */ public String getOrderTypeCd(); /** * 请æ±ç±»å B businessè¿ç¨ I instanceè¿ç¨ N notifyè¿ç¨ * @return */ public String getBusinessType(); /** * ä¸å¡ID * @return */ public String getbId(); /** * ä¸å¡ç±»å * @return */ public String getBusinessTypeCd(); public String getoId() ; public void setoId(String oId) ; } java110-core/src/main/java/com/java110/core/context/IOrderResponse.java
New file @@ -0,0 +1,21 @@ package com.java110.core.context; /** * 订åè¿åç»æä¿¡æ¯ */ public interface IOrderResponse { /** * è·åè¿åç¼ç * @return */ public String getCode() ; /** * è·åè¿åä¿¡æ¯ * @return */ public String getMessage() ; } java110-core/src/main/java/com/java110/core/context/IOrders.java
File was renamed from java110-core/src/main/java/com/java110/core/context/Orders.java @@ -6,7 +6,7 @@ * è·å订åä¿¡æ¯ * Created by wuxw on 2018/5/18. */ public interface Orders { public interface IOrders { public String getTransactionId(); java110-core/src/main/java/com/java110/core/context/OrderDataFlow.java
New file @@ -0,0 +1,229 @@ package com.java110.core.context; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.java110.common.constant.CommonConstant; import com.java110.common.util.Assert; import com.java110.common.util.DateUtil; import com.java110.entity.order.Business; import com.java110.entity.order.BusinessAttrs; import com.java110.entity.order.Orders; import com.java110.entity.order.OrdersAttrs; import java.util.*; /** * 主è¦ç¨äºç¦»æ£æå¯¹è±¡ httpApi service 请æ±è¿ç¨æ¶æ¯è®°å½åè¿åè®°å½ * Created by wuxw on 2018/4/13. */ public class OrderDataFlow extends AbstractOrderDataFlowContext { protected OrderDataFlow(Date startDate, String code) { super(startDate, code); } /** * 订å */ private Orders orders; /** * 订åé¡¹ä¿¡æ¯ */ private List<Business> businessList; /*private String dataFlowId; *//** * 请æ±å¤´ä¿¡æ¯ *//* private Map<String,String> reqHeaders; *//** * 请æ±ä½ä¿¡æ¯ï¼åªæ¯æjsonï¼ *//* private JSONObject reqJson; *//** * è¿åå¤´ä¿¡æ¯ *//* private Map<String,String> resHeaders; *//** * è¿åä½ä¿¡æ¯ ï¼åªæ¯æjsonï¼ *//* private JSONObject resJson;*/ /** * æå»º OrderDataFlow 对象 * @param reqInfo * @param headerAll * @return * @throws Exception */ public OrderDataFlow doBuilder(String reqInfo, Map<String,String> headerAll) throws Exception{ //æ ¡éªè¯·æ±æ¥ææ ¼å¼ Assert.isJsonObject(reqInfo,"å½åæ¥æä¸æ¯ææjson,è¯·æ£æ¥"+reqInfo); this.setDataFlowId(UUID.randomUUID().toString().replace("-","").toLowerCase()); //èµå¼è¯·æ±æ¥æ this.setResJson(JSONObject.parseObject(reqInfo)); //èµå¼ 请æ±å¤´ä¿¡æ¯ this.setReqHeaders(headerAll); //æå»ºè¿å头 builderResHeaders(); //æå»º 订åä¿¡æ¯ builderOrders(); //æå»ºè®¢åé¡¹ä¿¡æ¯ builderBusiness(); return this; } /** * æå»ºè¿åå¤´ä¿¡æ¯ */ private void builderResHeaders() { Map<String,String> tmpResHeaders = new HashMap<String,String>(); tmpResHeaders.put(CommonConstant.HTTP_TRANSACTION_ID,this.getReqHeaders().get(CommonConstant.HTTP_TRANSACTION_ID)); tmpResHeaders.put(CommonConstant.HTTP_RES_TIME,DateUtil.getyyyyMMddhhmmssDateString()); this.setResHeaders(tmpResHeaders); } /** * æå»ºè®¢å * */ private void builderOrders() throws Exception{ this.orders = new Orders(); Assert.hasKey(this.getReqHeaders(),CommonConstant.HTTP_APP_ID,"æå»ºOrderDataFlow对象失败ï¼è¯·æ±å¤´ä¸æªå å«"+CommonConstant.HTTP_APP_ID); this.orders.setAppId(this.getReqHeaders().get(CommonConstant.HTTP_APP_ID)); Assert.hasKey(this.getReqHeaders(),CommonConstant.HTTP_USER_ID,"æå»ºOrderDataFlow对象失败ï¼è¯·æ±å¤´ä¸æªå å«"+CommonConstant.HTTP_USER_ID); this.orders.setUserId(this.getReqHeaders().get(CommonConstant.HTTP_USER_ID)); Assert.hasKey(this.getReqHeaders(),CommonConstant.HTTP_TRANSACTION_ID,"æå»ºOrderDataFlow对象失败ï¼è¯·æ±å¤´ä¸æªå å«"+CommonConstant.HTTP_TRANSACTION_ID); this.orders.setExtTransactionId(this.getReqHeaders().get(CommonConstant.HTTP_TRANSACTION_ID)); Assert.hasKey(this.getReqHeaders(),CommonConstant.HTTP_REQ_TIME,"æå»ºOrderDataFlow对象失败ï¼è¯·æ±å¤´ä¸æªå å«"+CommonConstant.HTTP_REQ_TIME); Assert.isDate(this.getReqHeaders().get(CommonConstant.HTTP_REQ_TIME),"æå»ºOrderDataFlow对象失败ï¼è¯·æ±å¤´ä¸"+CommonConstant.HTTP_REQ_TIME+"æ ¼å¼é误"); this.orders.setRequestTime(DateUtil.getDefaultDateFromString(this.getReqHeaders().get(CommonConstant.HTTP_REQ_TIME))); this.orders.setoId("-1"); JSONObject tmpOrderJson = this.getReqJson().getJSONObject("orders"); Assert.jsonObjectHaveKey(tmpOrderJson,"orderTypeCd","è¯·æ±æ¥æéè¯¯ï¼æªæ¾å°orderTypeCdèç¹"); this.orders.setOrderTypeCd(tmpOrderJson.getString("orderTypeCd")); if(!tmpOrderJson.containsKey("attrs")){ return ; } JSONArray tmpOrderAttrs = tmpOrderJson.getJSONArray("attrs"); List<OrdersAttrs> ordersAttrsList = new ArrayList<OrdersAttrs>(); OrdersAttrs ordersAttrs = null; for(int tmpOrderAttrsIndex = 0;tmpOrderAttrsIndex < tmpOrderAttrs.size();tmpOrderAttrsIndex ++){ ordersAttrs= new OrdersAttrs(); ordersAttrs.setAttrId("-"+(tmpOrderAttrsIndex+1)); ordersAttrs.setSpecCd(tmpOrderAttrs.getJSONObject(tmpOrderAttrsIndex).getString("specId")); ordersAttrs.setValue(tmpOrderAttrs.getJSONObject(tmpOrderAttrsIndex).getString("value")); ordersAttrsList.add(ordersAttrs); } this.orders.setOrdersAttrs(ordersAttrsList); } /** * æå»º 订å项 */ private void builderBusiness() { this.businessList = new ArrayList<Business>(); JSONArray tmpBusiness = this.getResJson().getJSONArray("business"); Business business = null; for (int tmpBusinessIndex = 0;tmpBusinessIndex < tmpBusiness.size();tmpBusinessIndex++){ business = new Business(); business.setbId("-"+(tmpBusinessIndex+1)); Assert.jsonObjectHaveKey(tmpBusiness.getJSONObject(tmpBusinessIndex),"businessTypeCd","æå»ºOrderDataFlow对象失败ï¼business䏿ªå å«businessTypeCdèç¹"); business.setBusinessTypeCd(tmpBusiness.getJSONObject(tmpBusinessIndex).getString("businessTypeCd")); business.setoId("-1"); Assert.jsonObjectHaveKey(tmpBusiness.getJSONObject(tmpBusinessIndex),"datas","æå»ºOrderDataFlow对象失败ï¼business䏿ªå å«datasèç¹"); business.setData(tmpBusiness.getJSONObject(tmpBusinessIndex).getJSONObject("datas")); if(tmpBusiness.getJSONObject(tmpBusinessIndex).containsKey("invokeModel")){ business.setInvokeModel(tmpBusiness.getJSONObject(tmpBusinessIndex).getString("invokeModel")); } Assert.jsonObjectHaveKey(tmpBusiness.getJSONObject(tmpBusinessIndex),"seq","æå»ºOrderDataFlow对象失败ï¼business䏿ªå å«seqèç¹"); business.setSeq(tmpBusiness.getJSONObject(tmpBusinessIndex).getLongValue("seq")); if(tmpBusiness.getJSONObject(tmpBusinessIndex).containsKey("attrs")){ builderBusinessAttrs(tmpBusiness.getJSONObject(tmpBusinessIndex),business); } businessList.add(business); } } /** * æå»ºè®¢å项屿§ * @param tmpBusiness æ¯ä¸ªbusiness * @param business */ private void builderBusinessAttrs(JSONObject tmpBusiness, Business business) { JSONArray tmpBusinessAttrs = tmpBusiness.getJSONArray("attrs"); List<BusinessAttrs> businessAttrsList = new ArrayList<BusinessAttrs>(); BusinessAttrs businessAttrs = null; for(int tmpBusinessAttrsIndex = 0;tmpBusinessAttrsIndex < tmpBusinessAttrs.size();tmpBusinessAttrsIndex ++){ businessAttrs= new BusinessAttrs(); businessAttrs.setAttrId("-"+(tmpBusinessAttrsIndex+1)); businessAttrs.setSpecCd(tmpBusinessAttrs.getJSONObject(tmpBusinessAttrsIndex).getString("specId")); businessAttrs.setValue(tmpBusinessAttrs.getJSONObject(tmpBusinessAttrsIndex).getString("value")); businessAttrsList.add(businessAttrs); } } public Orders getOrders() { return orders; } public List<Business> getBusinessList() { return businessList; } } java110-core/src/main/java/com/java110/core/context/OrderNotifyDataFlow.java
New file @@ -0,0 +1,106 @@ package com.java110.core.context; import com.alibaba.fastjson.JSONObject; import com.java110.common.util.Assert; import com.java110.common.util.DateUtil; import java.util.Date; import java.util.Map; import java.util.UUID; /** * @author wux * @create 2019-02-07 ä¸å12:38 * @desc 订åéç¥æ°æ®å°è£ 对象 **/ public class OrderNotifyDataFlow extends AbstractOrderNotifyDataFlowContext { protected OrderNotifyDataFlow(Date startDate, String code) { super(startDate, code); } private String oId; /** * æå»º å¯¹è±¡ä¿¡æ¯ * @param reqInfo * @param headerAll * @return * @throws Exception */ public OrderNotifyDataFlow builder(String reqInfo, Map<String,String> headerAll) throws Exception{ //æ ¡éªè¯·æ±æ¥ææ ¼å¼ Assert.isJsonObject(reqInfo,"å½åæ¥æä¸æ¯ææjson,è¯·æ£æ¥"+reqInfo); this.setDataFlowId(UUID.randomUUID().toString().replace("-","").toLowerCase()); //èµå¼è¯·æ±æ¥æ this.setResJson(JSONObject.parseObject(reqInfo)); //èµå¼ 请æ±å¤´ä¿¡æ¯ this.setReqHeaders(headerAll); //æå»º 订åä¿¡æ¯ builderOrderResponse(); //æå»ºè®¢åé¡¹ä¿¡æ¯ builderOrderNotifyInfo(); return this; } /** * æå»ºè®¢åéç¥ä¿¡æ¯ */ private void builderOrderNotifyInfo() throws Exception{ JSONObject tmpReqJson = this.getReqJson(); Assert.jsonObjectHaveKey(tmpReqJson,"business","没æå å«businessèç¹ä¿¡æ¯,"+tmpReqJson.toJSONString()); JSONObject tmpBusiness = tmpReqJson.getJSONObject("business"); this.setbId(tmpBusiness.getString("bId")); this.setBusinessTypeCd(tmpBusiness.getString("businessTypeCd")); Assert.jsonObjectHaveKey(tmpReqJson,"orders","没æå å«ordersèç¹ä¿¡æ¯,"+tmpReqJson.toJSONString()); JSONObject tmpOrders = tmpReqJson.getJSONObject("orders"); this.setTransactionId(tmpOrders.getString("transactionId")); this.setResponseTime(DateUtil.getDefaultDateFromString(tmpOrders.getString("responseTime"))); this.setOrderTypeCd(tmpOrders.getString("orderTypeCd")); this.setDataFlowId(tmpOrders.getString("dataFlowId")); this.setBusinessType(tmpOrders.getString("businessType")); } /** * æå»ºè¿åç¶æç»æä¿¡æ¯ */ private void builderOrderResponse() { JSONObject tmpReqJson = this.getReqJson(); Assert.jsonObjectHaveKey(tmpReqJson,"business","没æå å«businessèç¹ä¿¡æ¯,"+tmpReqJson.toJSONString()); JSONObject tmpBusiness = tmpReqJson.getJSONObject("business"); Assert.jsonObjectHaveKey(tmpBusiness,"response","没æå å«responseèç¹ï¼"+tmpBusiness.toJSONString()); JSONObject tmpResponse = tmpBusiness.getJSONObject("response"); this.setCode(tmpResponse.getString("code")); this.setMessage(tmpResponse.getString("message")); } public String getoId() { return oId; } public void setoId(String oId) { this.oId = oId; } } java110-core/src/main/java/com/java110/core/factory/DataFlowFactory.java
@@ -10,14 +10,21 @@ import com.java110.common.constant.StatusConstant; import com.java110.common.util.Assert; import com.java110.common.util.DateUtil; import com.java110.common.util.StringUtil; import com.java110.core.context.AbstractDataFlowContext; import com.java110.core.context.ApiDataFlow; import com.java110.core.context.DataFlow; import com.java110.core.context.OrderDataFlow; import com.java110.entity.center.AppRoute; import com.java110.entity.center.AppService; import com.java110.entity.center.Business; import com.java110.entity.center.DataFlowLinksCost; import com.java110.entity.order.BusinessAttrs; import com.java110.entity.order.Orders; import com.java110.entity.order.OrdersAttrs; import org.springframework.beans.BeanInstantiationException; import org.springframework.http.HttpHeaders; import org.springframework.util.MultiValueMap; import java.util.*; @@ -202,6 +209,25 @@ return order ; } /** * è·åOrderä¿¡æ¯ * @param orders 订åä¿¡æ¯ * @return */ public static Map getOrder(Orders orders){ Map order = new HashMap(); orders.setoId(GenerateCodeFactory.getOId()); order.put("oId",orders.getoId()); order.put("appId",orders.getAppId()); order.put("extTransactionId",orders.getExtTransactionId()); order.put("userId",orders.getUserId()); order.put("requestTime",orders.getRequestTime()); order.put("orderTypeCd",orders.getOrderTypeCd()); order.put("remark",orders.getRemark()); order.put("statusCd",StatusConstant.STATUS_CD_SAVE); return order ; } /** * è·å订å屿§ @@ -229,6 +255,28 @@ } /** * è·å订å屿§ * @param orders * @return */ public static List<Map> getOrderAttrs(Orders orders){ List<Map> orderAttrs = new ArrayList<Map>(); List<OrdersAttrs> attrs = orders.getOrdersAttrs(); Map attrMap = null; for(OrdersAttrs ordersAttr:attrs) { ordersAttr.setAttrId(GenerateCodeFactory.getAttrId()); attrMap = new HashMap(); attrMap.put("oId",orders.getoId()); attrMap.put("attrId", ordersAttr.getAttrId()); attrMap.put("specCd",ordersAttr.getSpecCd()); attrMap.put("value",ordersAttr.getValue()); orderAttrs.add(attrMap); } return orderAttrs; } /** * è·å订å项 * @param dataFlow * @return @@ -253,6 +301,33 @@ return businesss; } /** * è·å订å项 * @param dataFlow * @return */ public static List<Map> getBusiness(OrderDataFlow dataFlow){ List<Map> businesss = new ArrayList<Map>(); Map busiMap = null; List<com.java110.entity.order.Business> businessList = dataFlow.getBusinessList(); for(com.java110.entity.order.Business business : businessList) { if(business == null){ continue; } business.setbId(GenerateCodeFactory.getBId()); busiMap = new HashMap(); busiMap.put("oId",dataFlow.getOrders().getoId()); busiMap.put("businessTypeCd",business.getBusinessTypeCd()); busiMap.put("remark",business.getRemark()); busiMap.put("statusCd",StatusConstant.STATUS_CD_SAVE); busiMap.put("bId",business.getbId()); businesss.add(busiMap); } return businesss; } /** * ç»è£ æ¤åæ°æ® * @param dataFlow @@ -263,6 +338,24 @@ List<Map> business = new ArrayList<Map>(); Map busiMap = new HashMap(); busiMap.put("oId",dataFlow.getoId()); busiMap.put("businessTypeCd",StatusConstant.REQUEST_BUSINESS_TYPE_DELETE); busiMap.put("remark",message); busiMap.put("statusCd",StatusConstant.STATUS_CD_DELETE_ORDER); busiMap.put("bId", GenerateCodeFactory.getBId()); business.add(busiMap); return business; } /** * ç»è£ æ¤åæ°æ® * @param dataFlow * @param message * @return */ public static List<Map> getDeleteOrderBusiness(OrderDataFlow dataFlow,String message){ List<Map> business = new ArrayList<Map>(); Map busiMap = new HashMap(); busiMap.put("oId",dataFlow.getOrders().getoId()); busiMap.put("businessTypeCd",StatusConstant.REQUEST_BUSINESS_TYPE_DELETE); busiMap.put("remark",message); busiMap.put("statusCd",StatusConstant.STATUS_CD_DELETE_ORDER); @@ -297,6 +390,34 @@ return businessAttrs; } /** * è·å订å屿§ * @param dataFlow * @return */ public static List<Map> getBusinessAttrs(OrderDataFlow dataFlow){ List<Map> businessAttrs = new ArrayList<Map>(); List<com.java110.entity.order.Business> businesses = dataFlow.getBusinessList(); for(com.java110.entity.order.Business business :businesses) { if (business.getBusinessAttrs() == null || business.getBusinessAttrs().size() ==0) { continue; } List<BusinessAttrs> attrs = business.getBusinessAttrs(); Map attrMap = null; for (BusinessAttrs businessAttrs1 : attrs) { attrMap = new HashMap(); businessAttrs1.setAttrId(GenerateCodeFactory.getAttrId()); attrMap.put("bId", business.getbId()); attrMap.put("attrId", businessAttrs1.getAttrId()); attrMap.put("specCd", businessAttrs1.getSpecCd()); attrMap.put("value", businessAttrs1.getValue()); businessAttrs.add(attrMap); } } return businessAttrs; } /** * è·åå°è¦ä½åºç订å * @param dataFlow @@ -306,6 +427,19 @@ Map order = new HashMap(); order.put("oId",dataFlow.getoId()); // order.put("finishTime",DateUtil.getCurrentDate()); order.put("statusCd",StatusConstant.STATUS_CD_DELETE); return order; } /** * è·åå°è¦ä½åºç订å * @param dataFlow * @return */ public static Map getNeedInvalidOrder(OrderDataFlow dataFlow){ Map order = new HashMap(); order.put("oId",dataFlow.getOrders().getoId()); // order.put("finishTime",DateUtil.getCurrentDate()); order.put("statusCd",StatusConstant.STATUS_CD_DELETE); return order; } @@ -361,6 +495,23 @@ Map business = new HashMap(); String bId = ""; for(Business busi:dataFlow.getBusinesses()){ bId += busi.getbId()+","; } business.put("bId",bId.substring(0,bId.length()-1)); business.put("finishTime",DateUtil.getCurrentDate()); business.put("statusCd",StatusConstant.STATUS_CD_DELETE_ORDER); return business; } /** * Business è¿ç¨å®æ * @param dataFlow * @return */ public static Map getNeedDeleteBusiness(OrderDataFlow dataFlow){ Map business = new HashMap(); String bId = ""; for(com.java110.entity.order.Business busi:dataFlow.getBusinessList()){ bId += busi.getbId()+","; } business.put("bId",bId.substring(0,bId.length()-1)); @@ -494,6 +645,21 @@ return requestMessage; } /** * è·åå¤±è´¥æ¶æ¯çæ¥æï¼è®¢å失败åéç¥ä¸å¡ç³»ç»ï¼ * @param business * @return */ public static JSONObject getBusinessTableDataInfoToInstanceTableJson(OrderDataFlow dataFlow,com.java110.entity.order.Business business){ JSONObject requestMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE); JSONObject busi = null; busi = new JSONObject(); busi.put("bId",business.getbId()); busi.put("businessTypeCd",business.getBusinessTypeCd()); requestMessage.put("business",busi); return requestMessage; } /** * åèµ·æ¤åè¯·æ±æ¥æ @@ -508,6 +674,23 @@ busi.put("bId",business.getbId()); busi.put("serviceCode",business.getServiceCode()); busi.put("serviceName",business.getServiceName()); //busi.put("datas",business.getDatas()); requestMessage.put("business",busi); return requestMessage; } /** * åèµ·æ¤åè¯·æ±æ¥æ * @param business * @return */ public static JSONObject getDeleteInstanceTableJson(OrderDataFlow dataFlow,com.java110.entity.order.Business business){ JSONObject requestMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.REQUEST_BUSINESS_TYPE_DELETE); JSONObject busi = null; busi = new JSONObject(); busi.put("bId",business.getbId()); busi.put("businessTypeCd",business.getBusinessTypeCd()); //busi.put("datas",business.getDatas()); requestMessage.put("business",busi); return requestMessage; @@ -564,6 +747,26 @@ return requestMessage; } /** * è·åå¤±è´¥æ¶æ¯çæ¥æï¼è®¢å失败åéç¥ä¸å¡ç³»ç»ï¼ * @param business * @return */ public static JSONObject getRequestBusinessJson(OrderDataFlow dataFlow,com.java110.entity.order.Business business){ JSONObject requestMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS); //JSONObject businesses = notifyMessage.getJSONObject("business"); JSONObject busi = null; busi = new JSONObject(); busi.put("bId",business.getbId()); busi.put("businessTypeCd",business.getBusinessTypeCd()); busi.put("remark",business.getRemark()); busi.put("datas",business.getData()); requestMessage.put("business",busi); return requestMessage; } /** * ä¸å¡ç³»ç»äº¤äº * @return @@ -574,6 +777,21 @@ orders.put("transactionId", UUID.randomUUID().toString().replace("-","")); orders.put("dataFlowId",dataFlow.getDataFlowId()); orders.put("orderTypeCd",dataFlow.getOrderTypeCd()); orders.put("requestTime",DateUtil.getyyyyMMddhhmmssDateString()); orders.put("businessType",businessType); return notifyMessage; } /** * ä¸å¡ç³»ç»äº¤äº * @return */ private static JSONObject getTransactionBusinessBaseJson(OrderDataFlow dataFlow,String businessType){ JSONObject notifyMessage = JSONObject.parseObject("{\"orders\":{},\"business\":{}}"); JSONObject orders = notifyMessage.getJSONObject("orders"); orders.put("transactionId", UUID.randomUUID().toString().replace("-","")); orders.put("dataFlowId",dataFlow.getDataFlowId()); orders.put("orderTypeCd",dataFlow.getOrders().getOrderTypeCd()); orders.put("requestTime",DateUtil.getyyyyMMddhhmmssDateString()); orders.put("businessType",businessType); return notifyMessage; @@ -605,6 +823,30 @@ /** * è·å忥å¤çä¸å¡ * @param dataFlow * @return */ public static List<com.java110.entity.order.Business> getSynchronousBusinesses(OrderDataFlow dataFlow){ AppService service = null; AppRoute route = null; List<com.java110.entity.order.Business> syschronousBusinesses = new ArrayList<com.java110.entity.order.Business>(); for(com.java110.entity.order.Business business :dataFlow.getBusinessList()){ if(CommonConstant.ORDER_INVOKE_METHOD_SYNCHRONOUS.equals(business.getInvokeModel()) || StringUtil.isEmpty(business.getInvokeModel())){ business.setSeq(service.getSeq()); syschronousBusinesses.add(business); } } if(syschronousBusinesses.size() > 0) { Collections.sort(syschronousBusinesses); } return syschronousBusinesses; } /** * è·å弿¥å¤çä¸å¡ * @param dataFlow * @return @@ -625,5 +867,38 @@ return syschronousBusinesses; } /** * è·å弿¥å¤çä¸å¡ * @param dataFlow * @return */ public static List<com.java110.entity.order.Business> getAsynchronousBusinesses(OrderDataFlow dataFlow){ List<com.java110.entity.order.Business> asynchronousBusinesses = new ArrayList<com.java110.entity.order.Business>(); for(com.java110.entity.order.Business business :dataFlow.getBusinessList()){ if(CommonConstant.ORDER_INVOKE_METHOD_ASYNCHRONOUS.equals(business.getInvokeModel())){ asynchronousBusinesses.add(business); } } return asynchronousBusinesses; } /** * hashmap 转MultiValueMap * @param httpHeaders * @return */ public static MultiValueMap<String, String> hashMap2MultiValueMap(Map<String,String> httpHeaders){ MultiValueMap<String, String> multiValueMap = new HttpHeaders(); for(String key:httpHeaders.keySet()) { multiValueMap.add(key,httpHeaders.get(key)); } return multiValueMap; } } java110-core/src/main/java/com/java110/core/factory/DataTransactionFactory.java
@@ -267,7 +267,7 @@ /** * åå»ºè¯·æ± center æ¥æ åè£ æJSON * åå»ºè¯·æ± order æ¥æ åè£ æJSON * @param appId * @return */ java110-core/src/main/java/com/java110/core/factory/OrderDataFlowContextFactory.java
New file @@ -0,0 +1,772 @@ package com.java110.core.factory; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.java110.common.cache.MappingCache; import com.java110.common.constant.CommonConstant; import com.java110.common.constant.MappingConstant; import com.java110.common.constant.ResponseConstant; import com.java110.common.constant.StatusConstant; import com.java110.common.util.Assert; import com.java110.common.util.DateUtil; import com.java110.common.util.StringUtil; import com.java110.core.context.DataFlow; import com.java110.core.context.IOrderDataFlowContext; import com.java110.core.context.IOrderNotifyDataFlowContext; import com.java110.entity.center.AppRoute; import com.java110.entity.center.AppService; import com.java110.entity.center.Business; import com.java110.entity.center.DataFlowLinksCost; import com.java110.entity.order.BusinessAttrs; import com.java110.entity.order.Orders; import com.java110.entity.order.OrdersAttrs; import com.java110.entity.order.ServiceBusiness; import org.springframework.beans.BeanInstantiationException; import org.springframework.http.HttpHeaders; import org.springframework.util.MultiValueMap; import java.util.*; /** * æ°æ®æµå·¥åç±» * Created by wuxw on 2018/4/13. */ public class OrderDataFlowContextFactory { /** * åå§å * @param clazz * @param <T> * @return */ public static <T> T newInstance(Class<T> clazz) throws BeanInstantiationException { Assert.notNull(clazz, "Class ä¸è½ä¸ºç©º"); if (clazz.isInterface()) { throw new BeanInstantiationException(clazz, "æå®ç±»æ¯ä¸ä¸ªæ¥å£"); } //DateUtil.getCurrentDate(), ResponseConstant.RESULT_CODE_SUCCESS try { return clazz.getConstructor(Date.class,String.class).newInstance(DateUtil.getCurrentDate(), ResponseConstant.RESULT_CODE_SUCCESS); } catch (InstantiationException ex) { throw new BeanInstantiationException(clazz, "æ¯ä¸ä¸ªæ½è±¡ç±»?", ex); }catch (Exception ex){ throw new BeanInstantiationException(clazz, "æé 彿°ä¸è½è®¿é®?", ex); } } /** * æ·»å èæ¶ * @param dataFlow æ°æ®æµ * @param linksCode ç¯èç¼ç * @param linksName ç¯èåç§° * @param startDate å¼å§æ¶é´ * @return */ public static void addCostTime(IOrderDataFlowContext dataFlow, String linksCode, String linksName, Date startDate){ if(MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_COST_TIME_ON_OFF))) { DataFlowLinksCost dataFlowLinksCost = new DataFlowLinksCost().builder(linksCode, linksName, startDate, DateUtil.getCurrentDate()); //dataFlow.addLinksCostDates(dataFlowLinksCost); } } /** * è·åå°è¦ä½åºç订å * @param dataFlow * @return */ public static Map getNeedErrorOrder(IOrderDataFlowContext dataFlow){ Map order = new HashMap(); order.put("oId",dataFlow.getOrders().getoId()); //order.put("finishTime",DateUtil.getCurrentDate()); order.put("statusCd",StatusConstant.STATUS_CD_ERROR); return order; } /** * è·åå°è¦ä½åºç订å * @param dataFlow * @return */ public static Map getNeedErrorOrder(IOrderNotifyDataFlowContext dataFlow){ Map order = new HashMap(); order.put("oId",dataFlow.getoId()); //order.put("finishTime",DateUtil.getCurrentDate()); order.put("statusCd",StatusConstant.STATUS_CD_ERROR); return order; } /** * æ·»å èæ¶ * @param dataFlow æ°æ®æµ * @param linksCode ç¯èç¼ç * @param linksName ç¯èåç§° * @param startDate å¼å§æ¶é´ * @param endDate ç»ææ¶é´ * @return */ public static void addCostTime(IOrderDataFlowContext dataFlow, String linksCode, String linksName, Date startDate, Date endDate){ if(MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_COST_TIME_ON_OFF))) { DataFlowLinksCost dataFlowLinksCost = new DataFlowLinksCost().builder(linksCode, linksName, startDate, endDate); //dataFlow.addLinksCostDates(dataFlowLinksCost); } } /** * è·åOrderä¿¡æ¯ * @param orders 订åä¿¡æ¯ * @return */ public static Map getOrder(Orders orders){ Map order = new HashMap(); orders.setoId(GenerateCodeFactory.getOId()); order.put("oId",orders.getoId()); order.put("appId",orders.getAppId()); order.put("extTransactionId",orders.getExtTransactionId()); order.put("userId",orders.getUserId()); order.put("requestTime",orders.getRequestTime()); order.put("orderTypeCd",orders.getOrderTypeCd()); order.put("remark",orders.getRemark()); order.put("statusCd",StatusConstant.STATUS_CD_SAVE); return order ; } /** * è·å订å项 * @param dataFlow * @return */ public static List<Map> getBusiness(IOrderDataFlowContext dataFlow){ List<Map> businesss = new ArrayList<Map>(); Map busiMap = null; List<com.java110.entity.order.Business> businessList = dataFlow.getBusinessList(); for(com.java110.entity.order.Business business : businessList) { if(business == null){ continue; } business.setbId(GenerateCodeFactory.getBId()); busiMap = new HashMap(); busiMap.put("oId",dataFlow.getOrders().getoId()); busiMap.put("businessTypeCd",business.getBusinessTypeCd()); busiMap.put("remark",business.getRemark()); busiMap.put("statusCd",StatusConstant.STATUS_CD_SAVE); busiMap.put("bId",business.getbId()); businesss.add(busiMap); } return businesss; } /** * ç»è£ æ¤åæ°æ® * @param dataFlow * @param message * @return */ public static List<Map> getDeleteOrderBusiness(IOrderDataFlowContext dataFlow,String message){ List<Map> business = new ArrayList<Map>(); Map busiMap = new HashMap(); busiMap.put("oId",dataFlow.getOrders().getoId()); busiMap.put("businessTypeCd",StatusConstant.REQUEST_BUSINESS_TYPE_DELETE); busiMap.put("remark",message); busiMap.put("statusCd",StatusConstant.STATUS_CD_DELETE_ORDER); busiMap.put("bId", GenerateCodeFactory.getBId()); business.add(busiMap); return business; } /** * ç»è£ æ¤åæ°æ® * @param dataFlow * @param message * @return */ public static List<Map> getDeleteOrderBusiness(IOrderNotifyDataFlowContext dataFlow,String message){ List<Map> business = new ArrayList<Map>(); Map busiMap = new HashMap(); busiMap.put("oId",dataFlow.getoId()); busiMap.put("businessTypeCd",StatusConstant.REQUEST_BUSINESS_TYPE_DELETE); busiMap.put("remark",message); busiMap.put("statusCd",StatusConstant.STATUS_CD_DELETE_ORDER); busiMap.put("bId", GenerateCodeFactory.getBId()); business.add(busiMap); return business; } /** * è·å订å屿§ * @param dataFlow * @return */ public static List<Map> getBusinessAttrs(IOrderDataFlowContext dataFlow){ List<Map> businessAttrs = new ArrayList<Map>(); List<com.java110.entity.order.Business> businesses = dataFlow.getBusinessList(); for(com.java110.entity.order.Business business :businesses) { if (business.getBusinessAttrs() == null || business.getBusinessAttrs().size() ==0) { continue; } List<BusinessAttrs> attrs = business.getBusinessAttrs(); Map attrMap = null; for (BusinessAttrs businessAttrs1 : attrs) { attrMap = new HashMap(); businessAttrs1.setAttrId(GenerateCodeFactory.getAttrId()); attrMap.put("bId", business.getbId()); attrMap.put("attrId", businessAttrs1.getAttrId()); attrMap.put("specCd", businessAttrs1.getSpecCd()); attrMap.put("value", businessAttrs1.getValue()); businessAttrs.add(attrMap); } } return businessAttrs; } /** * è·åå°è¦ä½åºç订å * @param dataFlow * @return */ public static Map getNeedInvalidOrder(IOrderDataFlowContext dataFlow){ Map order = new HashMap(); order.put("oId",dataFlow.getOrders().getoId()); // order.put("finishTime",DateUtil.getCurrentDate()); order.put("statusCd",StatusConstant.STATUS_CD_DELETE); return order; } /** * è·åå°è¦ä½åºç订å * @param dataFlow * @return */ public static Map getNeedInvalidOrder(IOrderNotifyDataFlowContext dataFlow){ Map order = new HashMap(); order.put("oId",dataFlow.getoId()); // order.put("finishTime",DateUtil.getCurrentDate()); order.put("statusCd",StatusConstant.STATUS_CD_DELETE); return order; } /** * Business è¿ç¨å®æ * @param dataFlow * @return */ public static Map getNeedDeleteBusiness(IOrderDataFlowContext dataFlow){ Map business = new HashMap(); String bId = ""; for(com.java110.entity.order.Business busi:dataFlow.getBusinessList()){ bId += busi.getbId()+","; } business.put("bId",bId.substring(0,bId.length()-1)); business.put("finishTime",DateUtil.getCurrentDate()); business.put("statusCd",StatusConstant.STATUS_CD_DELETE_ORDER); return business; } /** * Business è¿ç¨å®æ * @param dataFlow * @return */ public static Map getNeedDeleteBusiness(IOrderNotifyDataFlowContext dataFlow){ Map business = new HashMap(); String bId = ""; business.put("bId",dataFlow.getbId()); business.put("finishTime",DateUtil.getCurrentDate()); business.put("statusCd",StatusConstant.STATUS_CD_DELETE_ORDER); return business; } public static Map getNeedNotifyErrorBusiness(DataFlow dataFlow){ Map business = new HashMap(); String bId = getMoreBId(dataFlow); business.put("bId",bId.substring(0,bId.length()-1)); business.put("finishTime",DateUtil.getCurrentDate()); business.put("statusCd",StatusConstant.STATUS_CD_NOTIFY_ERROR); return business; } public static Map getNeedNotifyErrorBusiness(IOrderNotifyDataFlowContext dataFlow){ Map business = new HashMap(); business.put("bId",dataFlow.getbId()); business.put("finishTime",DateUtil.getCurrentDate()); business.put("statusCd",StatusConstant.STATUS_CD_NOTIFY_ERROR); return business; } /** * è·åDataFlow 对象ä¸çææbId * @param dataFlow * @return */ public static String getMoreBId(DataFlow dataFlow){ String bId = ""; for(Business busi:dataFlow.getBusinesses()){ bId += busi.getbId()+","; } return bId; } /** * è·åå°è¦å®æç订å * @param dataFlow * @return */ public static Map getNeedCompleteOrder(DataFlow dataFlow){ Map order = new HashMap(); order.put("oId",dataFlow.getoId()); order.put("finishTime",DateUtil.getCurrentDate()); order.put("statusCd",StatusConstant.STATUS_CD_COMPLETE); return order; } /** * è·åç«£å·¥æ¶æ¯çæ¥æï¼è®¢å宿åéç¥ä¸å¡ç³»ç»ï¼ * @param dataFlow * @return */ public static JSONObject getNotifyBusinessSuccessJson(DataFlow dataFlow){ JSONObject notifyMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.NOTIFY_BUSINESS_TYPE); JSONArray businesses = notifyMessage.getJSONArray("business"); JSONObject busi = null; JSONObject response = null; for(Business business :dataFlow.getBusinesses()){ busi = new JSONObject(); busi.put("bId",business.getbId()); busi.put("serviceCode",business.getServiceCode()); response = new JSONObject(); response.put("code",ResponseConstant.RESULT_CODE_SUCCESS); response.put("message","æå"); busi.put("response",response); businesses.add(busi); } return notifyMessage; } /** * è·åç«£å·¥æ¶æ¯çæ¥æï¼è®¢å宿åéç¥ä¸å¡ç³»ç»ï¼ * @param dataFlow * @return */ public static JSONObject getNotifyBusinessSuccessJson(IOrderNotifyDataFlowContext dataFlow){ JSONObject notifyMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.NOTIFY_BUSINESS_TYPE); JSONArray businesses = notifyMessage.getJSONArray("business"); JSONObject busi = null; JSONObject response = null; busi = new JSONObject(); busi.put("bId",dataFlow.getbId()); busi.put("businessTypeCd",dataFlow.getBusinessTypeCd()); response = new JSONObject(); response.put("code",ResponseConstant.RESULT_CODE_SUCCESS); response.put("message","æå"); busi.put("response",response); businesses.add(busi); return notifyMessage; } /** * è·å订å屿§ * @param orders * @return */ public static List<Map> getOrderAttrs(Orders orders){ List<Map> orderAttrs = new ArrayList<Map>(); List<OrdersAttrs> attrs = orders.getOrdersAttrs(); Map attrMap = null; for(OrdersAttrs ordersAttr:attrs) { ordersAttr.setAttrId(GenerateCodeFactory.getAttrId()); attrMap = new HashMap(); attrMap.put("oId",orders.getoId()); attrMap.put("attrId", ordersAttr.getAttrId()); attrMap.put("specCd",ordersAttr.getSpecCd()); attrMap.put("value",ordersAttr.getValue()); orderAttrs.add(attrMap); } return orderAttrs; } /** * è·åå¤±è´¥æ¶æ¯çæ¥æï¼è®¢å失败åéç¥ä¸å¡ç³»ç»ï¼ * @param dataFlow * @return */ public static JSONObject getNotifyBusinessErrorJson(DataFlow dataFlow){ JSONObject notifyMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.NOTIFY_BUSINESS_TYPE); JSONArray businesses = notifyMessage.getJSONArray("business"); JSONObject busi = null; JSONObject response = null; for(Business business :dataFlow.getBusinesses()){ busi = new JSONObject(); busi.put("bId",business.getbId()); busi.put("serviceCode",business.getServiceCode()); response = new JSONObject(); response.put("code",ResponseConstant.RESULT_CODE_INNER_ERROR); response.put("message","失败"); busi.put("response",response); businesses.add(busi); } return notifyMessage; } /** * è·åå¤±è´¥æ¶æ¯çæ¥æï¼è®¢å失败åéç¥ä¸å¡ç³»ç»ï¼ * @param dataFlow * @return */ public static JSONObject getNotifyBusinessErrorJson(IOrderNotifyDataFlowContext dataFlow){ JSONObject notifyMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.NOTIFY_BUSINESS_TYPE); JSONArray businesses = notifyMessage.getJSONArray("business"); JSONObject busi = null; JSONObject response = null; busi = new JSONObject(); busi.put("bId",dataFlow.getbId()); busi.put("businessTypeCd",dataFlow.getBusinessTypeCd()); response = new JSONObject(); response.put("code",ResponseConstant.RESULT_CODE_INNER_ERROR); response.put("message","失败"); busi.put("response",response); businesses.add(busi); return notifyMessage; } public static JSONObject getCompletedBusinessErrorJson(DataFlow dataFlow,Map business,AppService appService){ JSONObject notifyMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.NOTIFY_BUSINESS_TYPE); JSONArray businesses = notifyMessage.getJSONArray("business"); JSONObject busi = null; JSONObject response = null; busi = new JSONObject(); busi.put("bId",business.get("b_id")); busi.put("serviceCode",appService.getServiceCode()); response = new JSONObject(); response.put("code",ResponseConstant.RESULT_CODE_INNER_ERROR); response.put("message","失败"); busi.put("response",response); businesses.add(busi); return notifyMessage; } /** * è·åå¤±è´¥æ¶æ¯çæ¥æï¼è®¢å失败åéç¥ä¸å¡ç³»ç»ï¼ * @param business * @return */ public static JSONObject getBusinessTableDataInfoToInstanceTableJson(DataFlow dataFlow,Business business){ JSONObject requestMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE); JSONObject busi = null; busi = new JSONObject(); busi.put("bId",business.getbId()); busi.put("serviceCode",business.getServiceCode()); busi.put("serviceName",business.getServiceName()); //busi.put("isInstance",CommonConstant.INSTANCE_Y); //busi.put("datas",business.getDatas()); requestMessage.put("business",busi); return requestMessage; } /** * è·åå¤±è´¥æ¶æ¯çæ¥æï¼è®¢å失败åéç¥ä¸å¡ç³»ç»ï¼ * @param business * @return */ public static JSONObject getBusinessTableDataInfoToInstanceTableJson(IOrderDataFlowContext dataFlow,com.java110.entity.order.Business business){ JSONObject requestMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE); JSONObject busi = null; busi = new JSONObject(); busi.put("bId",business.getbId()); busi.put("businessTypeCd",business.getBusinessTypeCd()); requestMessage.put("business",busi); return requestMessage; } /** * è·åå¤±è´¥æ¶æ¯çæ¥æï¼è®¢å失败åéç¥ä¸å¡ç³»ç»ï¼ * @param dataFlow * @return */ public static JSONObject getBusinessTableDataInfoToInstanceTableJson(IOrderNotifyDataFlowContext dataFlow){ JSONObject requestMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE); JSONObject busi = null; busi = new JSONObject(); busi.put("bId",dataFlow.getbId()); busi.put("businessTypeCd",dataFlow.getBusinessTypeCd()); requestMessage.put("business",busi); return requestMessage; } /** * åèµ·æ¤åè¯·æ±æ¥æ * @param business * @return */ public static JSONObject getDeleteInstanceTableJson(DataFlow dataFlow,Business business){ JSONObject requestMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.REQUEST_BUSINESS_TYPE_DELETE); JSONObject busi = null; busi = new JSONObject(); busi.put("bId",business.getbId()); busi.put("serviceCode",business.getServiceCode()); busi.put("serviceName",business.getServiceName()); //busi.put("datas",business.getDatas()); requestMessage.put("business",busi); return requestMessage; } /** * åèµ·æ¤åè¯·æ±æ¥æ * @param business * @return */ public static JSONObject getDeleteInstanceTableJson(IOrderDataFlowContext dataFlow,com.java110.entity.order.Business business){ JSONObject requestMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.REQUEST_BUSINESS_TYPE_DELETE); JSONObject busi = null; busi = new JSONObject(); busi.put("bId",business.getbId()); busi.put("businessTypeCd",business.getBusinessTypeCd()); //busi.put("datas",business.getDatas()); requestMessage.put("business",busi); return requestMessage; } public static JSONObject getDeleteInstanceTableJson(DataFlow dataFlow,Map business,AppService appService){ JSONObject requestMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.REQUEST_BUSINESS_TYPE_DELETE); JSONObject busi = null; busi = new JSONObject(); busi.put("bId",business.get("b_id")); busi.put("serviceCode",appService.getServiceCode()); //busi.put("datas",business.getDatas()); requestMessage.put("business",busi); return requestMessage; } public static JSONObject getDeleteInstanceTableJson(IOrderNotifyDataFlowContext dataFlow, Map business ){ JSONObject requestMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.REQUEST_BUSINESS_TYPE_DELETE); JSONObject busi = null; busi = new JSONObject(); busi.put("bId",business.get("b_id")); busi.put("businessTypeCd",business.get("business_type_cd").toString()); //busi.put("datas",business.getDatas()); requestMessage.put("business",busi); return requestMessage; } /** * è·åå¤±è´¥æ¶æ¯çæ¥æï¼è®¢å失败åéç¥ä¸å¡ç³»ç»ï¼ * @param business * @return */ public static JSONObject getCompleteInstanceDataJson(DataFlow dataFlow,Business business){ JSONObject notifyMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.REQUEST_BUSINESS_TYPE); //JSONObject businesses = notifyMessage.getJSONObject("business"); JSONObject busi = null; busi = new JSONObject(); busi.put("bId",business.getbId()); busi.put("serviceCode",business.getServiceCode()); busi.put("serviceName",business.getServiceName()); busi.put("isInstance",CommonConstant.INSTANCE_Y); notifyMessage.put("business",busi); return notifyMessage; } /** * è·åå¤±è´¥æ¶æ¯çæ¥æï¼è®¢å失败åéç¥ä¸å¡ç³»ç»ï¼ * @param business * @return */ public static JSONObject getRequestBusinessJson(DataFlow dataFlow,Business business){ JSONObject requestMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS); //JSONObject businesses = notifyMessage.getJSONObject("business"); JSONObject busi = null; busi = new JSONObject(); busi.put("bId",business.getbId()); busi.put("serviceCode",business.getServiceCode()); busi.put("serviceName",business.getServiceName()); busi.put("remark",business.getRemark()); busi.put("datas",business.getDatas()); requestMessage.put("business",busi); return requestMessage; } /** * è·åå¤±è´¥æ¶æ¯çæ¥æï¼è®¢å失败åéç¥ä¸å¡ç³»ç»ï¼ * @param business * @return */ public static JSONObject getRequestBusinessJson(IOrderDataFlowContext dataFlow,com.java110.entity.order.Business business){ JSONObject requestMessage = getTransactionBusinessBaseJson(dataFlow,StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS); //JSONObject businesses = notifyMessage.getJSONObject("business"); JSONObject busi = null; busi = new JSONObject(); busi.put("bId",business.getbId()); busi.put("businessTypeCd",business.getBusinessTypeCd()); busi.put("remark",business.getRemark()); busi.put("datas",business.getData()); requestMessage.put("business",busi); return requestMessage; } /** * ä¸å¡ç³»ç»äº¤äº * @return */ private static JSONObject getTransactionBusinessBaseJson(DataFlow dataFlow,String businessType){ JSONObject notifyMessage = JSONObject.parseObject("{\"orders\":{},\"business\":{}}"); JSONObject orders = notifyMessage.getJSONObject("orders"); orders.put("transactionId", UUID.randomUUID().toString().replace("-","")); orders.put("dataFlowId",dataFlow.getDataFlowId()); orders.put("orderTypeCd",dataFlow.getOrderTypeCd()); orders.put("requestTime",DateUtil.getyyyyMMddhhmmssDateString()); orders.put("businessType",businessType); return notifyMessage; } /** * ä¸å¡ç³»ç»äº¤äº * @return */ private static JSONObject getTransactionBusinessBaseJson(IOrderDataFlowContext dataFlow,String businessType){ JSONObject notifyMessage = JSONObject.parseObject("{\"orders\":{},\"business\":{}}"); JSONObject orders = notifyMessage.getJSONObject("orders"); orders.put("transactionId", UUID.randomUUID().toString().replace("-","")); orders.put("dataFlowId",dataFlow.getDataFlowId()); orders.put("orderTypeCd",dataFlow.getOrders().getOrderTypeCd()); orders.put("requestTime",DateUtil.getyyyyMMddhhmmssDateString()); orders.put("businessType",businessType); return notifyMessage; } /** * ä¸å¡ç³»ç»äº¤äº * @return */ private static JSONObject getTransactionBusinessBaseJson(IOrderNotifyDataFlowContext dataFlow,String businessType){ JSONObject notifyMessage = JSONObject.parseObject("{\"orders\":{},\"business\":{}}"); JSONObject orders = notifyMessage.getJSONObject("orders"); orders.put("transactionId", UUID.randomUUID().toString().replace("-","")); orders.put("dataFlowId",dataFlow.getDataFlowId()); orders.put("orderTypeCd",dataFlow.getOrderTypeCd()); orders.put("requestTime",DateUtil.getyyyyMMddhhmmssDateString()); orders.put("businessType",businessType); return notifyMessage; } /** * è·å忥å¤çä¸å¡ * @param dataFlow * @return */ public static List<com.java110.entity.order.Business> getSynchronousBusinesses(IOrderDataFlowContext dataFlow){ AppService service = null; AppRoute route = null; List<com.java110.entity.order.Business> syschronousBusinesses = new ArrayList<com.java110.entity.order.Business>(); for(com.java110.entity.order.Business business :dataFlow.getBusinessList()){ if(CommonConstant.ORDER_INVOKE_METHOD_SYNCHRONOUS.equals(business.getInvokeModel()) || StringUtil.isEmpty(business.getInvokeModel())){ business.setSeq(service.getSeq()); syschronousBusinesses.add(business); } } if(syschronousBusinesses.size() > 0) { Collections.sort(syschronousBusinesses); } return syschronousBusinesses; } /** * è·å弿¥å¤çä¸å¡ * @param dataFlow * @return */ public static List<com.java110.entity.order.Business> getAsynchronousBusinesses(IOrderDataFlowContext dataFlow){ List<com.java110.entity.order.Business> asynchronousBusinesses = new ArrayList<com.java110.entity.order.Business>(); for(com.java110.entity.order.Business business :dataFlow.getBusinessList()){ if(CommonConstant.ORDER_INVOKE_METHOD_ASYNCHRONOUS.equals(business.getInvokeModel())){ asynchronousBusinesses.add(business); } } return asynchronousBusinesses; } /** * hashmap 转MultiValueMap * @param httpHeaders * @return */ public static MultiValueMap<String, String> hashMap2MultiValueMap(Map<String,String> httpHeaders){ MultiValueMap<String, String> multiValueMap = new HttpHeaders(); for(String key:httpHeaders.keySet()) { multiValueMap.add(key,httpHeaders.get(key)); } return multiValueMap; } public static Map getNeedCompleteBusiness(IOrderNotifyDataFlowContext dataFlow){ Map business = new HashMap(); business.put("bId",dataFlow.getbId()); business.put("finishTime",DateUtil.getCurrentDate()); business.put("statusCd",StatusConstant.STATUS_CD_COMPLETE); return business; } /** * Business è¿ç¨å®æ * @param dataFlow * @return */ public static Map getNeedBusinessComplete(IOrderNotifyDataFlowContext dataFlow){ Map business = new HashMap(); business.put("bId",dataFlow.getbId()); business.put("finishTime",DateUtil.getCurrentDate()); business.put("statusCd",StatusConstant.STATUS_CD_BUSINESS_COMPLETE); return business; } } java110-event/src/main/java/com/java110/event/center/DataFlowEventPublishing.java
@@ -5,7 +5,8 @@ import com.java110.common.factory.ApplicationContextFactory; import com.java110.common.log.LoggerEngine; import com.java110.common.util.Assert; import com.java110.core.context.DataFlow; import com.java110.core.context.IOrderDataFlowContext; import com.java110.entity.order.Business; import com.java110.event.center.event.*; import com.java110.event.center.listener.DataFlowListener; @@ -222,7 +223,7 @@ * åå§å DataFlow å¯¹è±¡å®æ * @param dataFlow æ°æ®æµå¯¹è±¡ */ public static void initDataFlowComplete(DataFlow dataFlow){ public static void initDataFlowComplete(IOrderDataFlowContext dataFlow){ multicastEvent(new DataFlowInitCompleteEvent("",dataFlow)); } @@ -230,7 +231,7 @@ * è§åæ ¡éªå®æäºä»¶ * @param dataFlow æ°æ®æµå¯¹è±¡ */ public static void ruleValidateComplete(DataFlow dataFlow){ public static void ruleValidateComplete(IOrderDataFlowContext dataFlow){ multicastEvent(new RuleValidateCompleteEvent("",dataFlow)); } @@ -238,7 +239,7 @@ * å è½½é ç½®æä»¶å®æ * @param dataFlow æ°æ®æµå¯¹è±¡ */ public static void loadConfigDataComplete(DataFlow dataFlow){ public static void loadConfigDataComplete(IOrderDataFlowContext dataFlow){ multicastEvent(new LoadConfigDataCompleteEvent("",dataFlow)); } @@ -247,15 +248,34 @@ * è°ç¨ä¸å¡ç³»ç»äºä»¶ * @param dataFlow æ°æ®æµ */ public static void invokeBusinessSystem(DataFlow dataFlow){ public static void invokeBusinessSystem(IOrderDataFlowContext dataFlow){ multicastEvent(new InvokeBusinessSystemEvent("",dataFlow)); } /** * è°ç¨ä¸å¡ç³»ç»æååäºä»¶ * @param dataFlow * @param business æåçäºä»¶ä¸å¡æ°æ®å°è£ 对象 */ public static void invokeBusinessBSuccess(IOrderDataFlowContext dataFlow, Business business){ multicastEvent(new InvokeBusinessBSuccessEvent("",dataFlow,business)); } /** * è°ç¨ä¸å¡ç³»ç»æååäºä»¶ * @param dataFlow * @param business æåçäºä»¶ä¸å¡æ°æ®å°è£ 对象 */ public static void invokeBusinessISuccess(IOrderDataFlowContext dataFlow, Business business){ multicastEvent(new InvokeBusinessISuccessEvent("",dataFlow,business)); } /** * æ°æ®è¿åäºä»¶ * @param dataFlow æ°æ®æµ */ public static void dataResponse(DataFlow dataFlow,String responseData,Map<String,String> headers){ public static void dataResponse(IOrderDataFlowContext dataFlow,String responseData,Map<String,String> headers){ multicastEvent(new DataResponseEvent("",dataFlow,responseData,headers)); } java110-event/src/main/java/com/java110/event/center/event/DataFlowEvent.java
@@ -1,6 +1,8 @@ package com.java110.event.center.event; import com.java110.core.context.DataFlow; import com.java110.core.context.IOrderDataFlowContext; import com.java110.core.context.OrderDataFlow; import java.util.EventObject; @@ -11,7 +13,7 @@ public class DataFlowEvent extends EventObject { private DataFlow dataFlow; private IOrderDataFlowContext dataFlow; /** * Constructs a prototypical Event. @@ -19,16 +21,16 @@ * @param source The object on which the Event initially occurred. * @throws IllegalArgumentException if source is null. */ public DataFlowEvent(Object source, DataFlow dataFlow) { public DataFlowEvent(Object source, IOrderDataFlowContext dataFlow) { super(source); this.dataFlow = dataFlow; } public DataFlow getDataFlow() { public IOrderDataFlowContext getDataFlow() { return dataFlow; } public void setDataFlow(DataFlow dataFlow) { public void setDataFlow(IOrderDataFlowContext dataFlow) { this.dataFlow = dataFlow; } } java110-event/src/main/java/com/java110/event/center/event/DataFlowInitCompleteEvent.java
@@ -1,6 +1,8 @@ package com.java110.event.center.event; import com.java110.core.context.DataFlow; import com.java110.core.context.IOrderDataFlowContext; import com.java110.core.context.OrderDataFlow; /** * dataFlow 对象åå§å宿 @@ -14,7 +16,7 @@ * @param dataFlow * @throws IllegalArgumentException if source is null. */ public DataFlowInitCompleteEvent(Object source, DataFlow dataFlow) { public DataFlowInitCompleteEvent(Object source, IOrderDataFlowContext dataFlow) { super(source, dataFlow); } } java110-event/src/main/java/com/java110/event/center/event/DataPreValidateEvent.java
@@ -1,6 +1,7 @@ package com.java110.event.center.event; import com.java110.core.context.DataFlow; import com.java110.core.context.IOrderDataFlowContext; import java.util.Map; @@ -19,7 +20,7 @@ * @param dataFlow * @throws IllegalArgumentException if source is null. */ public DataPreValidateEvent(Object source, DataFlow dataFlow, public DataPreValidateEvent(Object source, IOrderDataFlowContext dataFlow, String requestData, Map<String,String> headers) { super(source, dataFlow); this.requestData = requestData; java110-event/src/main/java/com/java110/event/center/event/DataResponseEvent.java
@@ -1,6 +1,7 @@ package com.java110.event.center.event; import com.java110.core.context.DataFlow; import com.java110.core.context.IOrderDataFlowContext; import java.util.Map; @@ -21,7 +22,7 @@ * @param dataFlow * @throws IllegalArgumentException if source is null. */ public DataResponseEvent(Object source, DataFlow dataFlow,String responseData, Map<String,String> headers) { public DataResponseEvent(Object source, IOrderDataFlowContext dataFlow, String responseData, Map<String,String> headers) { super(source, dataFlow); this.responseData = responseData; this.headers = headers; java110-event/src/main/java/com/java110/event/center/event/InvokeBusinessBSuccessEvent.java
New file @@ -0,0 +1,30 @@ package com.java110.event.center.event; import com.java110.core.context.IOrderDataFlowContext; import com.java110.core.context.OrderDataFlow; import com.java110.entity.order.Business; /** * è°ç¨ä¸å¡ç³»ç»äºä»¶ * Created by wuxw on 2018/7/2. */ public class InvokeBusinessBSuccessEvent extends DataFlowEvent { private Business business; /** * Constructs a prototypical Event. * * @param source The object on which the Event initially occurred. * @param dataFlow * @throws IllegalArgumentException if source is null. */ public InvokeBusinessBSuccessEvent(Object source, IOrderDataFlowContext dataFlow, Business business) { super(source, dataFlow); this.business = business; } public Business getBusiness() { return business; } } java110-event/src/main/java/com/java110/event/center/event/InvokeBusinessISuccessEvent.java
New file @@ -0,0 +1,30 @@ package com.java110.event.center.event; import com.java110.core.context.IOrderDataFlowContext; import com.java110.core.context.OrderDataFlow; import com.java110.entity.order.Business; /** * è°ç¨ä¸å¡ç³»ç»äºä»¶ * Created by wuxw on 2018/7/2. */ public class InvokeBusinessISuccessEvent extends DataFlowEvent { private Business business; /** * Constructs a prototypical Event. * * @param source The object on which the Event initially occurred. * @param dataFlow * @throws IllegalArgumentException if source is null. */ public InvokeBusinessISuccessEvent(Object source, IOrderDataFlowContext dataFlow, Business business) { super(source, dataFlow); this.business = business; } public Business getBusiness() { return business; } } java110-event/src/main/java/com/java110/event/center/event/InvokeBusinessSystemEvent.java
@@ -1,6 +1,8 @@ package com.java110.event.center.event; import com.java110.core.context.DataFlow; import com.java110.core.context.IOrderDataFlowContext; import com.java110.core.context.OrderDataFlow; /** * è°ç¨ä¸å¡ç³»ç»äºä»¶ @@ -15,7 +17,7 @@ * @param dataFlow * @throws IllegalArgumentException if source is null. */ public InvokeBusinessSystemEvent(Object source, DataFlow dataFlow) { public InvokeBusinessSystemEvent(Object source, IOrderDataFlowContext dataFlow) { super(source, dataFlow); } } java110-event/src/main/java/com/java110/event/center/event/LoadConfigDataCompleteEvent.java
@@ -1,6 +1,8 @@ package com.java110.event.center.event; import com.java110.core.context.DataFlow; import com.java110.core.context.IOrderDataFlowContext; import com.java110.core.context.OrderDataFlow; /** * å è½½é ç½®æä»¶å®æ @@ -14,7 +16,7 @@ * @param dataFlow * @throws IllegalArgumentException if source is null. */ public LoadConfigDataCompleteEvent(Object source, DataFlow dataFlow) { public LoadConfigDataCompleteEvent(Object source, IOrderDataFlowContext dataFlow) { super(source, dataFlow); } } java110-event/src/main/java/com/java110/event/center/event/ReceiveRequestEvent.java
@@ -1,6 +1,7 @@ package com.java110.event.center.event; import com.java110.core.context.DataFlow; import com.java110.core.context.IOrderDataFlowContext; import java.util.Map; @@ -19,7 +20,7 @@ * @param dataFlow * @throws IllegalArgumentException if source is null. */ public ReceiveRequestEvent(Object source, DataFlow dataFlow, public ReceiveRequestEvent(Object source, IOrderDataFlowContext dataFlow, String requestData, Map<String,String> headers) { super(source, dataFlow); this.requestData = requestData; java110-event/src/main/java/com/java110/event/center/event/RuleValidateCompleteEvent.java
@@ -1,6 +1,7 @@ package com.java110.event.center.event; import com.java110.core.context.DataFlow; import com.java110.core.context.IOrderDataFlowContext; import com.java110.core.context.OrderDataFlow; /** * è§åæ ¡éªå®æäºä»¶ @@ -14,7 +15,7 @@ * @param dataFlow * @throws IllegalArgumentException if source is null. */ public RuleValidateCompleteEvent(Object source, DataFlow dataFlow) { public RuleValidateCompleteEvent(Object source, IOrderDataFlowContext dataFlow) { super(source, dataFlow); } } java110-event/src/main/java/com/java110/event/service/BusinessServiceDataFlowEventPublishing.java
@@ -55,23 +55,23 @@ /** * æ ¹æ®æ¯å¦å®ç°äºæä¸ªæ¥å£ï¼è¿åä¾¦å¬ * @param serviceCode * @param businessTypeCd * @since 1.8 * @return */ public static List<BusinessServiceDataFlowListener> getListeners(String serviceCode){ public static List<BusinessServiceDataFlowListener> getListeners(String businessTypeCd){ Assert.hasLength(serviceCode,"è·åéè¦åå¸çäºä»¶å¤ç侦嬿¶ï¼ä¼ éäºä»¶ä¸ºç©ºï¼è¯·æ£æ¥"); Assert.hasLength(businessTypeCd,"è·åéè¦åå¸çäºä»¶å¤ç侦嬿¶ï¼ä¼ éäºä»¶ä¸ºç©ºï¼è¯·æ£æ¥"); //å ä»ç¼åä¸è·åï¼ä¸ºäºæåæç if(cacheListenersMap.containsKey(serviceCode)){ return cacheListenersMap.get(serviceCode); if(cacheListenersMap.containsKey(businessTypeCd)){ return cacheListenersMap.get(businessTypeCd); } List<BusinessServiceDataFlowListener> dataFlowListeners = new ArrayList<BusinessServiceDataFlowListener>(); for(String listenerBeanName : getListeners()){ BusinessServiceDataFlowListener listener = ApplicationContextFactory.getBean(listenerBeanName,BusinessServiceDataFlowListener.class); if(serviceCode.equals(listener.getServiceCode())){ if(businessTypeCd.equals(listener.getBusinessTypeCd())){ dataFlowListeners.add(listener); } } @@ -80,7 +80,7 @@ DataFlowListenerOrderComparator.sort(dataFlowListeners); //å°æ°æ®æ¾å ¥ç¼åä¸ cacheListenersMap.put(serviceCode,dataFlowListeners); cacheListenersMap.put(businessTypeCd,dataFlowListeners); return dataFlowListeners; } @@ -91,29 +91,29 @@ */ public static void multicastEvent(DataFlowContext dataFlowContext) throws BusinessException{ Assert.notNull(dataFlowContext.getCurrentBusiness(),"å½å没æå¯å¤ççä¸å¡ä¿¡æ¯ï¼"); multicastEvent(dataFlowContext.getCurrentBusiness().getServiceCode(),dataFlowContext,null); multicastEvent(dataFlowContext.getCurrentBusiness().getBusinessTypeCd(),dataFlowContext,null); } /** * åå¸äºä»¶ * @param serviceCode * @param businessTypeCd * @param dataFlowContext */ public static void multicastEvent(String serviceCode,DataFlowContext dataFlowContext) throws BusinessException{ multicastEvent(serviceCode,dataFlowContext,null); public static void multicastEvent(String businessTypeCd,DataFlowContext dataFlowContext) throws BusinessException{ multicastEvent(businessTypeCd,dataFlowContext,null); } /** * åå¸äºä»¶ * @param serviceCode * @param businessTypeCd * @param dataFlowContext è¿ä¸ªè®¢åä¿¡æ¯ï¼ä»¥ä¾¿äº 侦å¬é£è¾¹éè¦ç¨ */ public static void multicastEvent(String serviceCode,DataFlowContext dataFlowContext,String asyn) throws BusinessException{ public static void multicastEvent(String businessTypeCd,DataFlowContext dataFlowContext,String asyn) throws BusinessException{ try { BusinessServiceDataFlowEvent targetDataFlowEvent = new BusinessServiceDataFlowEvent(serviceCode,dataFlowContext); BusinessServiceDataFlowEvent targetDataFlowEvent = new BusinessServiceDataFlowEvent(businessTypeCd,dataFlowContext); multicastEvent(serviceCode,targetDataFlowEvent, asyn); multicastEvent(businessTypeCd,targetDataFlowEvent, asyn); }catch (Exception e){ throw new BusinessException(ResponseConstant.RESULT_CODE_INNER_ERROR,"åå¸ä¾¦å¬å¤±è´¥ï¼å¤±è´¥åå 为ï¼"+e); } @@ -126,8 +126,8 @@ * @param event * @param asyn A è¡¨ç¤ºå¼æ¥å¤ç */ public static void multicastEvent(String serviceCode,final BusinessServiceDataFlowEvent event, String asyn) { for (final BusinessServiceDataFlowListener listener : getListeners(serviceCode)) { public static void multicastEvent(String businessTypeCd,final BusinessServiceDataFlowEvent event, String asyn) { for (final BusinessServiceDataFlowListener listener : getListeners(businessTypeCd)) { if(CommonConstant.PROCESS_ORDER_ASYNCHRONOUS.equals(asyn)){ //弿¥å¤ç java110-event/src/main/java/com/java110/event/service/BusinessServiceDataFlowListener.java
@@ -14,7 +14,7 @@ * ä¸å¡ ç¼ç * @return */ public String getServiceCode(); public String getBusinessTypeCd(); public void soService(BusinessServiceDataFlowEvent event); } java110-service/src/main/java/com/java110/service/dao/IQueryServiceDAO.java
@@ -1,7 +1,9 @@ package com.java110.service.dao; import com.java110.entity.order.ServiceBusiness; import com.java110.entity.service.ServiceSql; import javax.validation.OverridesAttribute; import java.util.List; import java.util.Map; @@ -31,4 +33,10 @@ public String updateProc(Map<String,Object> paramsInfo); public List<ServiceSql> qureyServiceSqlAll(); /** * æ¥è¯¢æå¡ä¸å¡ä¿¡æ¯ * @return */ public List<ServiceBusiness> qureyServiceBusiness(); } java110-service/src/main/java/com/java110/service/dao/impl/QueryServiceDAOImpl.java
@@ -2,6 +2,7 @@ import com.java110.common.util.StringUtil; import com.java110.core.base.dao.BaseServiceDao; import com.java110.entity.order.ServiceBusiness; import com.java110.entity.service.ServiceSql; import com.java110.service.dao.IQueryServiceDAO; import org.slf4j.Logger; @@ -163,4 +164,13 @@ public List<ServiceSql> qureyServiceSqlAll() { return sqlSessionTemplate.selectList("queryServiceDAOImpl.qureyServiceSqlAll"); } /** * æ¥è¯¢æå¡ä¸å¡ä¿¡æ¯ * @return */ public List<ServiceBusiness> qureyServiceBusiness(){ return sqlSessionTemplate.selectList("queryServiceDAOImpl.queryServiceBusiness"); } } pom.xml
@@ -24,7 +24,7 @@ <module>RuleService</module> <module>SimpleListenerService</module> <module>java110-event</module> <module>CenterService</module> <module>OrderService</module> <module>java110-cacheAgent</module> <module>ConsoleService</module> <module>java110-logAgent</module>