|
|
@@ -3,22 +3,20 @@ package com.java110.api.listener.floor;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.java110.api.listener.AbstractServiceApiDataFlowListener;
|
|
|
-import com.java110.api.listener.community.CommunityMemberJoinedListener;
|
|
|
import com.java110.common.constant.BusinessTypeConstant;
|
|
|
import com.java110.common.constant.CommonConstant;
|
|
|
+import com.java110.common.constant.CommunityMemberTypeConstant;
|
|
|
import com.java110.common.constant.ServiceCodeConstant;
|
|
|
import com.java110.common.util.Assert;
|
|
|
import com.java110.core.annotation.Java110Listener;
|
|
|
import com.java110.core.context.DataFlowContext;
|
|
|
-import com.java110.core.smo.user.IUserInnerServiceSMO;
|
|
|
+import com.java110.core.factory.GenerateCodeFactory;
|
|
|
import com.java110.entity.center.AppService;
|
|
|
import com.java110.event.service.api.ServiceDataFlowEvent;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.http.HttpEntity;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.HttpMethod;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
|
|
/**
|
|
|
@@ -36,6 +34,7 @@ public class SaveFloorListener extends AbstractServiceApiDataFlowListener {
|
|
|
|
|
|
//默认序列
|
|
|
private static final int DEFAULT_SEQ = 1;
|
|
|
+ private static final int DEFAULT_SEQ_COMMUNITY_MEMBER = 2;
|
|
|
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(SaveFloorListener.class);
|
|
|
@@ -68,9 +67,16 @@ public class SaveFloorListener extends AbstractServiceApiDataFlowListener {
|
|
|
dataFlowContext.getRequestCurrentHeaders().put(CommonConstant.HTTP_USER_ID, "-1");
|
|
|
dataFlowContext.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD, "D");
|
|
|
JSONArray businesses = new JSONArray();
|
|
|
- //添加商户
|
|
|
+
|
|
|
+ //生成floorId
|
|
|
+ generateFloorId(paramObj);
|
|
|
+
|
|
|
+ //添加小区楼
|
|
|
businesses.add(addFloor(paramObj));
|
|
|
|
|
|
+ //小区楼添加到小区中
|
|
|
+ businesses.add(addCommunityMember(paramObj));
|
|
|
+
|
|
|
JSONObject paramInObj = super.restToCenterProtocol(businesses, dataFlowContext.getRequestCurrentHeaders());
|
|
|
|
|
|
//将 rest header 信息传递到下层服务中去
|
|
|
@@ -82,6 +88,16 @@ public class SaveFloorListener extends AbstractServiceApiDataFlowListener {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 生成小区楼ID
|
|
|
+ *
|
|
|
+ * @param paramObj 请求入参数据
|
|
|
+ */
|
|
|
+ private void generateFloorId(JSONObject paramObj) {
|
|
|
+ String floorId = GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_floorId);
|
|
|
+ paramObj.put("floorId", floorId);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 添加小区楼信息
|
|
|
@@ -91,12 +107,13 @@ public class SaveFloorListener extends AbstractServiceApiDataFlowListener {
|
|
|
*/
|
|
|
private JSONObject addFloor(JSONObject paramInJson) {
|
|
|
|
|
|
+
|
|
|
JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
|
|
|
business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FLOOR_INFO);
|
|
|
business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
|
|
|
business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
|
|
|
JSONObject businessFloor = new JSONObject();
|
|
|
- businessFloor.put("floorId", "-1");
|
|
|
+ businessFloor.put("floorId", paramInJson.getString("floorId"));
|
|
|
businessFloor.put("name", paramInJson.getString("name"));
|
|
|
businessFloor.put("remark", paramInJson.getString("remark"));
|
|
|
businessFloor.put("userId", paramInJson.getString("userId"));
|
|
|
@@ -106,6 +123,30 @@ public class SaveFloorListener extends AbstractServiceApiDataFlowListener {
|
|
|
return business;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加小区成员
|
|
|
+ *
|
|
|
+ * @param paramInJson 组装 楼小区关系
|
|
|
+ * @return 小区成员信息
|
|
|
+ */
|
|
|
+ private JSONObject addCommunityMember(JSONObject paramInJson) {
|
|
|
+
|
|
|
+
|
|
|
+ JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
|
|
|
+ business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_MEMBER_JOINED_COMMUNITY);
|
|
|
+ business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ_COMMUNITY_MEMBER);
|
|
|
+ business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
|
|
|
+ JSONObject businessCommunityMember = new JSONObject();
|
|
|
+ businessCommunityMember.put("communityMemberId", "-1");
|
|
|
+ businessCommunityMember.put("communityId", paramInJson.getString("communityId"));
|
|
|
+ businessCommunityMember.put("memberId", paramInJson.getString("floorId"));
|
|
|
+ businessCommunityMember.put("memberTypeCd", CommunityMemberTypeConstant.FLOOR);
|
|
|
+ business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessCommunityMember", businessCommunityMember);
|
|
|
+
|
|
|
+ return business;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 数据校验
|
|
|
*
|
|
|
@@ -117,6 +158,7 @@ public class SaveFloorListener extends AbstractServiceApiDataFlowListener {
|
|
|
Assert.jsonObjectHaveKey(paramIn, "name", "请求报文中未包含name");
|
|
|
Assert.jsonObjectHaveKey(paramIn, "userId", "请求报文中未包含userId");
|
|
|
Assert.jsonObjectHaveKey(paramIn, "floorNum", "请求报文中未包含floorNum");
|
|
|
+ Assert.jsonObjectHaveKey(paramIn, "communityId", "请求报文中未包含communityId");
|
|
|
}
|
|
|
|
|
|
|