Просмотр исходного кода

保存小区 修改小区测试完成

wuxw лет назад: 7
Родитель
Сommit
93345c8751
21 измененных файлов с 925 добавлено и 251 удалено
  1. 32 0
      CommunityService/doc/memberJoinCommunity.json
  2. 29 0
      CommunityService/doc/memberQuitCommunity.json
  3. 47 0
      CommunityService/doc/saveCommunityInfo.json
  4. 47 0
      CommunityService/doc/updateStoreInfo.json
  5. 10 0
      CommunityService/docker/Dockerfile
  6. 14 0
      CommunityService/docker/bin/start_community.sh
  7. 12 0
      CommunityService/docker/docker-compose.yml
  8. 11 0
      CommunityService/docker/onStart.sh
  9. 9 25
      CommunityService/src/main/java/com/java110/community/dao/ICommunityServiceDao.java
  10. 18 55
      CommunityService/src/main/java/com/java110/community/dao/impl/CommunityServiceDaoImpl.java
  11. 24 64
      CommunityService/src/main/java/com/java110/community/listener/AbstractCommunityBusinessServiceDataFlowListener.java
  12. 155 0
      CommunityService/src/main/java/com/java110/community/listener/MemberJoinedCommunityListener.java
  13. 153 0
      CommunityService/src/main/java/com/java110/community/listener/MemberQuitCommunityListener.java
  14. 5 55
      CommunityService/src/main/java/com/java110/community/listener/SaveCommunityInfoListener.java
  15. 4 48
      CommunityService/src/main/java/com/java110/community/listener/UpdateCommunityInfoListener.java
  16. 1 1
      CommunityService/src/main/resources/application.yml
  17. 28 0
      java110-common/src/main/java/com/java110/common/constant/ServiceCodeConstant.java
  18. 0 0
      java110-config/db/CenterService/create_table.sql
  19. 13 3
      java110-config/db/CommunityService/create_table.sql
  20. 300 0
      java110-config/src/main/resources/mapper/community/CommunityServiceDaoImplMapper.xml
  21. 13 0
      java110-core/src/main/java/com/java110/core/factory/GenerateCodeFactory.java

+ 32 - 0
CommunityService/doc/memberJoinCommunity.json

@@ -0,0 +1,32 @@
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": [{
+    "serviceCode": "member.join.community",
+    "serviceName": "小区成员加入",
+    "remark": "备注",
+    "datas": {
+      "businessCommunityMember": {
+        "communityMemberId": "-1",
+        "communityId": "123456",
+        "memberId": "345678",
+        "memberTypeCd": "390001200001"
+      }
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }]
+}

+ 29 - 0
CommunityService/doc/memberQuitCommunity.json

@@ -0,0 +1,29 @@
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": [{
+    "serviceCode": "member.quit.community",
+    "serviceName": "小区成员退出",
+    "remark": "备注",
+    "datas": {
+      "businessCommunityMember": {
+        "memberCommunityId": "387367363736"
+      }
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }]
+}

+ 47 - 0
CommunityService/doc/saveCommunityInfo.json

@@ -0,0 +1,47 @@
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": [{
+    "serviceCode": "save.community.info",
+    "serviceName": "保存小区信息",
+    "remark": "备注",
+    "datas": {
+      "businessCommunity": {
+        "communityId": "-1",
+        "name": "方博家园",
+        "address": "青海省西宁市城中区129号",
+        "cityCode": "100010",
+        "nearbyLandmarks": "王府井旁30米",
+        "mapX": "101.801909",
+        "mapY": "36.597263"
+      },
+      "businessCommunityAttr": [{
+        "communityId": "-1",
+        "attrId":"-1",
+        "specCd":"1001",
+        "value":"01"
+      }],
+      "businessCommunityPhoto":[{
+        "communityPhotoId":"-1",
+        "communityId":"-1",
+        "communityPhotoTypeCd":"T",
+        "photo":"12345678.jpg"
+      }]
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }]
+}

+ 47 - 0
CommunityService/doc/updateStoreInfo.json

@@ -0,0 +1,47 @@
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": [{
+    "serviceCode": "update.community.info",
+    "serviceName": "修改商户信息",
+    "remark": "备注",
+    "datas": {
+      "businessCommunity": {
+        "communityId": "123456",
+        "name": "万博家博园(城西区)",
+        "address": "青海省西宁市城中区129号",
+        "cityCode": "100010",
+        "nearbyLandmarks": "王府井旁30米",
+        "mapX": "101.801909",
+        "mapY": "36.597263"
+      },
+      "businessCommunityAttr": [{
+        "communityId": "123456",
+        "attrId":"1234546",
+        "specCd":"1001",
+        "value":"01"
+      }],
+      "businessCommunityPhoto":[{
+        "communityPhotoId":"12321",
+        "communityId": "123456",
+        "communityPhotoTypeCd":"T",
+        "photo":"12345678.jpg"
+      }]
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }]
+}

+ 10 - 0
CommunityService/docker/Dockerfile

@@ -0,0 +1,10 @@
+FROM registry.cn-beijing.aliyuncs.com/sxd/ubuntu-java8:1.0
+MAINTAINER wuxw <928255095@qq.com>
+
+
+ADD bin/start_community.sh /root/
+
+
+RUN chmod u+x /root/start_community.sh
+
+CMD ["/root/start_community.sh","dev"]

+ 14 - 0
CommunityService/docker/bin/start_community.sh

@@ -0,0 +1,14 @@
+#!/bin/bash
+#### debug model prod
+#nohup java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n -jar -Dspring.profiles.active=dev target/CommunityService.jar > community.log 2>&1 &
+
+#### normal prod model
+#nohup java -jar -Dspring.profiles.active=prod target/CommunityService.jar > community.log 2>&1 &
+
+#### normal test model
+#nohup java -jar -Dspring.profiles.active=test target/CommunityService.jar > community.log 2>&1 &
+
+#### normal dev model
+nohup java -jar -Dspring.profiles.active=$1 target/CommunityService.jar > community.log 2>&1 &
+
+tail -100f community.log

+ 12 - 0
CommunityService/docker/docker-compose.yml

@@ -0,0 +1,12 @@
+version: '2'
+services:
+   communityserivce:
+       container_name: communityserivce-1
+       build:
+          context: .
+          dockerfile: Dockerfile
+       restart: always
+       ports:
+       - "8009:8009"
+       volumes:
+       - ../target/CommunityService.jar:/root/target/CommunityService.jar

+ 11 - 0
CommunityService/docker/onStart.sh

@@ -0,0 +1,11 @@
+#!/bin/bash
+
+cp -r ../bin .
+
+cp  -r ../target .
+
+docker build -t java110/community .
+
+docker run -ti --name community_test -p8006:8006 -idt java110/community:latest
+
+docker logs -f community_test

+ 9 - 25
CommunityService/src/main/java/com/java110/community/dao/ICommunityServiceDao.java

@@ -103,12 +103,7 @@ public interface ICommunityServiceDao {
     public void saveCommunityPhotoInstance(Map info) throws DAOException;
 
 
-    /**
-     * 保存 小区证件信息 Business数据到 Instance中
-     * @param info
-     * @throws DAOException
-     */
-    public void saveCommunityCerdentialsInstance(Map info) throws DAOException;
+
 
 
 
@@ -139,13 +134,7 @@ public interface ICommunityServiceDao {
      */
     public List<Map> getCommunityPhoto(Map info) throws DAOException;
 
-    /**
-     * 查询小区证件信息(instance 过程)
-     * @param info bId 信息
-     * @return 小区照片
-     * @throws DAOException
-     */
-    public List<Map> getCommunityCerdentials(Map info) throws DAOException;
+
 
     /**
      * 修改小区信息
@@ -170,27 +159,22 @@ public interface ICommunityServiceDao {
      */
     public void updateCommunityPhotoInstance(Map info) throws DAOException;
 
-    /**
-     * 修改小区证件信息
-     * @param info 修改信息
-     * @throws DAOException
-     */
-    public void updateCommunityCerdentailsInstance(Map info) throws DAOException;
+    
 
 
     /**
      * 小区成员加入信息
-     * @param businessMemberCommunity 小区成员信息 封装
+     * @param businessCommunityMember 小区成员信息 封装
      * @throws DAOException 操作数据库异常
      */
-    public void saveBusinessMemberCommunity(Map businessMemberCommunity) throws DAOException;
+    public void saveBusinessCommunityMember(Map businessCommunityMember) throws DAOException;
 
     /**
      * 成员加入 保存信息至instance
      * @param info
      * @throws DAOException
      */
-    public void saveMemberCommunityInstance(Map info) throws DAOException;
+    public void saveCommunityMemberInstance(Map info) throws DAOException;
 
     /**
      * 查询小区成员加入信息(business过程)
@@ -199,7 +183,7 @@ public interface ICommunityServiceDao {
      * @return 小区信息
      * @throws DAOException
      */
-    public Map getBusinessMemberCommunity(Map info) throws DAOException;
+    public Map getBusinessCommunityMember(Map info) throws DAOException;
 
     /**
      * 查询小区成员加入信息(instance过程)
@@ -208,13 +192,13 @@ public interface ICommunityServiceDao {
      * @return 小区信息
      * @throws DAOException
      */
-    public Map getMemberCommunity(Map info) throws DAOException;
+    public Map getCommunityMember(Map info) throws DAOException;
 
     /**
      * 修改小区成员加入信息
      * @param info 修改信息
      * @throws DAOException
      */
-    public void updateMemberCommunityInstance(Map info) throws DAOException;
+    public void updateCommunityMemberInstance(Map info) throws DAOException;
 
 }

+ 18 - 55
CommunityService/src/main/java/com/java110/community/dao/impl/CommunityServiceDaoImpl.java

@@ -197,16 +197,7 @@ public class CommunityServiceDaoImpl extends BaseServiceDao implements ICommunit
         }
     }
 
-    @Override
-    public void saveCommunityCerdentialsInstance(Map info) throws DAOException {
-        logger.debug("保存小区证件信息Instance 入参 info : {}",info);
-
-        int saveFlag = sqlSessionTemplate.insert("communityServiceDaoImpl.saveCommunityCerdentialsInstance",info);
 
-        if(saveFlag < 1){
-            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存小区证件信息Instance数据失败:"+ JSONObject.toJSONString(info));
-        }
-    }
 
     /**
      * 查询小区信息(instance)
@@ -259,20 +250,7 @@ public class CommunityServiceDaoImpl extends BaseServiceDao implements ICommunit
         return communityPhotos;
     }
 
-    /**
-     * 小区证件查询(instance)
-     * @param info bId 信息
-     * @return
-     * @throws DAOException
-     */
-    @Override
-    public List<Map> getCommunityCerdentials(Map info) throws DAOException {
-        logger.debug("查询小区证件信息 入参 info : {}",info);
-
-        List<Map> communityCerdentialses = sqlSessionTemplate.selectList("communityServiceDaoImpl.getCommunityCerdentials",info);
 
-        return communityCerdentialses;
-    }
 
     /**
      * 修改小区信息
@@ -322,34 +300,19 @@ public class CommunityServiceDaoImpl extends BaseServiceDao implements ICommunit
         }
     }
 
-    /**
-     * 修改小区证件信息
-     * @param info 修改信息
-     * @throws DAOException
-     */
-    @Override
-    public void updateCommunityCerdentailsInstance(Map info) throws DAOException {
-        logger.debug("修改小区证件信息Instance 入参 info : {}",info);
-
-        int saveFlag = sqlSessionTemplate.update("communityServiceDaoImpl.updateCommunityCerdentailsInstance",info);
-
-        if(saveFlag < 1){
-            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改小区证件信息Instance数据失败:"+ JSONObject.toJSONString(info));
-        }
-    }
 
     /**
      * 小区成员加入信息
-     * @param businessMemberCommunity 小区成员信息 封装
+     * @param businessCommunityMember 小区成员信息 封装
      * @throws DAOException 操作数据库异常
      */
-    public void saveBusinessMemberCommunity(Map businessMemberCommunity) throws DAOException{
-        logger.debug("小区成员加入 入参 businessMemberCommunity : {}",businessMemberCommunity);
+    public void saveBusinessCommunityMember(Map businessCommunityMember) throws DAOException{
+        logger.debug("小区成员加入 入参 businessCommunityMember : {}",businessCommunityMember);
 
-        int saveFlag = sqlSessionTemplate.insert("communityServiceDaoImpl.saveBusinessMemberCommunity",businessMemberCommunity);
+        int saveFlag = sqlSessionTemplate.insert("communityServiceDaoImpl.saveBusinessCommunityMember",businessCommunityMember);
 
         if(saveFlag < 1){
-            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"小区成员加入失败:"+ JSONObject.toJSONString(businessMemberCommunity));
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"小区成员加入失败:"+ JSONObject.toJSONString(businessCommunityMember));
         }
     }
 
@@ -359,10 +322,10 @@ public class CommunityServiceDaoImpl extends BaseServiceDao implements ICommunit
      * @throws DAOException
      */
     @Override
-    public void saveMemberCommunityInstance(Map info) throws DAOException {
+    public void saveCommunityMemberInstance(Map info) throws DAOException {
         logger.debug("小区成员加入Instance 入参 info : {}",info);
 
-        int saveFlag = sqlSessionTemplate.insert("communityServiceDaoImpl.saveMemberCommunityInstance",info);
+        int saveFlag = sqlSessionTemplate.insert("communityServiceDaoImpl.saveCommunityMemberInstance",info);
 
         if(saveFlag < 1){
             throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存小区照片信息Instance数据失败:"+ JSONObject.toJSONString(info));
@@ -376,18 +339,18 @@ public class CommunityServiceDaoImpl extends BaseServiceDao implements ICommunit
      * @return 小区信息
      * @throws DAOException
      */
-    public Map getBusinessMemberCommunity(Map info) throws DAOException{
+    public Map getBusinessCommunityMember(Map info) throws DAOException{
         logger.debug("查询小区成员加入信息 入参 info : {}",info);
 
-        List<Map> businessMemberCommunitys = sqlSessionTemplate.selectList("communityServiceDaoImpl.getBusinessMemberCommunity",info);
-        if(businessMemberCommunitys == null || businessMemberCommunitys.size() == 0){
+        List<Map> businessCommunityMembers = sqlSessionTemplate.selectList("communityServiceDaoImpl.getBusinessCommunityMember",info);
+        if(businessCommunityMembers == null || businessCommunityMembers.size() == 0){
             return null;
         }
-        if(businessMemberCommunitys.size() >1){
-            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:businessMemberCommunity,"+ JSONObject.toJSONString(info));
+        if(businessCommunityMembers.size() >1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:businessCommunityMember,"+ JSONObject.toJSONString(info));
         }
 
-        return businessMemberCommunitys.get(0);
+        return businessCommunityMembers.get(0);
     }
 
     /**
@@ -397,15 +360,15 @@ public class CommunityServiceDaoImpl extends BaseServiceDao implements ICommunit
      * @return 小区信息
      * @throws DAOException
      */
-    public Map getMemberCommunity(Map info) throws DAOException{
+    public Map getCommunityMember(Map info) throws DAOException{
         logger.debug("查询小区成员加入信息 入参 info : {}",info);
 
-        List<Map> memberCommunitys = sqlSessionTemplate.selectList("communityServiceDaoImpl.getMemberCommunity",info);
+        List<Map> memberCommunitys = sqlSessionTemplate.selectList("communityServiceDaoImpl.getCommunityMember",info);
         if(memberCommunitys == null || memberCommunitys.size() == 0){
             return null;
         }
         if(memberCommunitys.size() >1){
-            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:getMemberCommunity,"+ JSONObject.toJSONString(info));
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:getCommunityMember,"+ JSONObject.toJSONString(info));
         }
 
         return memberCommunitys.get(0);
@@ -415,10 +378,10 @@ public class CommunityServiceDaoImpl extends BaseServiceDao implements ICommunit
      * @param info 修改信息
      * @throws DAOException
      */
-    public void updateMemberCommunityInstance(Map info) throws DAOException{
+    public void updateCommunityMemberInstance(Map info) throws DAOException{
         logger.debug("修改小区成员加入信息Instance 入参 info : {}",info);
 
-        int saveFlag = sqlSessionTemplate.update("communityServiceDaoImpl.updateMemberCommunityInstance",info);
+        int saveFlag = sqlSessionTemplate.update("communityServiceDaoImpl.updateCommunityMemberInstance",info);
 
         if(saveFlag < 1){
             throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改小区成员加入信息Instance数据失败:"+ JSONObject.toJSONString(info));

+ 24 - 64
CommunityService/src/main/java/com/java110/community/listener/AbstractCommunityBusinessServiceDataFlowListener.java

@@ -34,8 +34,7 @@ public abstract class AbstractCommunityBusinessServiceDataFlowListener extends A
     protected void flushBusinessCommunityInfo(Map businessCommunityInfo,String statusCd){
         businessCommunityInfo.put("newBId",businessCommunityInfo.get("b_id"));
         businessCommunityInfo.put("communityId",businessCommunityInfo.get("community_id"));
-        businessCommunityInfo.put("userId",businessCommunityInfo.get("user_id"));
-        businessCommunityInfo.put("communityTypeCd",businessCommunityInfo.get("community_type_cd"));
+        businessCommunityInfo.put("cityCode",businessCommunityInfo.get("city_code"));
         businessCommunityInfo.put("nearbyLandmarks",businessCommunityInfo.get("nearby_landmarks"));
         businessCommunityInfo.put("mapX",businessCommunityInfo.get("map_x"));
         businessCommunityInfo.put("mapY",businessCommunityInfo.get("map_y"));
@@ -69,33 +68,20 @@ public abstract class AbstractCommunityBusinessServiceDataFlowListener extends A
         businessCommunityPhoto.put("statusCd",statusCd);
     }
 
-    /**
-     * 刷新 businessCommunityCerdentials 数据
-     * @param businessCommunityCerdentials
-     * @param statusCd
-     */
-    protected void flushBusinessCommunityCredentials(Map businessCommunityCerdentials ,String statusCd){
-        businessCommunityCerdentials.put("communityId",businessCommunityCerdentials.get("community_id"));
-        businessCommunityCerdentials.put("communityCerdentialsId",businessCommunityCerdentials.get("community_cerdentials_id"));
-        businessCommunityCerdentials.put("credentialsCd",businessCommunityCerdentials.get("credentials_cd"));
-        businessCommunityCerdentials.put("validityPeriod",businessCommunityCerdentials.get("validity_period"));
-        businessCommunityCerdentials.put("positivePhoto",businessCommunityCerdentials.get("positive_photo"));
-        businessCommunityCerdentials.put("negativePhoto",businessCommunityCerdentials.get("negative_photo"));
-        businessCommunityCerdentials.put("newBId",businessCommunityCerdentials.get("b_id"));
-        businessCommunityCerdentials.put("statusCd",statusCd);
-    }
+
 
     /**
-     * 刷新 businessMemberCommunity 数据
+     * 刷新 businessCommunityMember 数据
      * 主要将 数据库 中字段和 接口传递字段建立关系
-     * @param businessMemberCommunity
+     * @param businessCommunityMember
      */
-    protected void flushBusinessMemberCommunity(Map businessMemberCommunity,String statusCd){
-        businessMemberCommunity.put("newBId",businessMemberCommunity.get("b_id"));
-        businessMemberCommunity.put("communityId",businessMemberCommunity.get("community_id"));
-        businessMemberCommunity.put("memberCommunityId",businessMemberCommunity.get("member_community_id"));
-        businessMemberCommunity.put("memberId",businessMemberCommunity.get("member_id"));
-        businessMemberCommunity.put("statusCd", statusCd);
+    protected void flushBusinessCommunityMember(Map businessCommunityMember,String statusCd){
+        businessCommunityMember.put("newBId",businessCommunityMember.get("b_id"));
+        businessCommunityMember.put("communityId",businessCommunityMember.get("community_id"));
+        businessCommunityMember.put("communityMemberId",businessCommunityMember.get("community_member_id"));
+        businessCommunityMember.put("memberId",businessCommunityMember.get("member_id"));
+        businessCommunityMember.put("memberTypeCd",businessCommunityMember.get("member_type_cd"));
+        businessCommunityMember.put("statusCd", statusCd);
     }
 
     /**
@@ -113,8 +99,7 @@ public abstract class AbstractCommunityBusinessServiceDataFlowListener extends A
         }
         currentCommunityInfo.put("bId",business.getbId());
         currentCommunityInfo.put("communityId",currentCommunityInfo.get("community_id"));
-        currentCommunityInfo.put("userId",currentCommunityInfo.get("user_id"));
-        currentCommunityInfo.put("communityTypeCd",currentCommunityInfo.get("community_type_cd"));
+        currentCommunityInfo.put("cityCode",currentCommunityInfo.get("city_code"));
         currentCommunityInfo.put("nearbyLandmarks",currentCommunityInfo.get("nearby_landmarks"));
         currentCommunityInfo.put("mapX",currentCommunityInfo.get("map_x"));
         currentCommunityInfo.put("mapY",currentCommunityInfo.get("map_y"));
@@ -168,52 +153,27 @@ public abstract class AbstractCommunityBusinessServiceDataFlowListener extends A
         getCommunityServiceDaoImpl().saveBusinessCommunityPhoto(currentCommunityPhoto);
     }
 
-    /**
-     * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
-     * @param business
-     * @param businessCommunityCerdentials 小区证件
-     */
-    protected void autoSaveDelBusinessCommunityCerdentials(Business business,JSONObject businessCommunityCerdentials){
-        Map info = new HashMap();
-        info.put("communityCerdentialsId",businessCommunityCerdentials.getString("communityCerdentialsId"));
-        info.put("communityId",businessCommunityCerdentials.getString("communityId"));
-        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
-        List<Map> currentCommunityCerdentailses = getCommunityServiceDaoImpl().getCommunityCerdentials(info);
-        if(currentCommunityCerdentailses == null || currentCommunityCerdentailses.size() != 1){
-            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info);
-        }
-        Map currentCommunityCerdentials = currentCommunityCerdentailses.get(0);
-
-        currentCommunityCerdentials.put("bId",business.getbId());
-        currentCommunityCerdentials.put("communityCerdentialsId",currentCommunityCerdentials.get("community_cerdentials_id"));
-        currentCommunityCerdentials.put("communityId",currentCommunityCerdentials.get("community_id"));
-        currentCommunityCerdentials.put("credentialsCd",currentCommunityCerdentials.get("credentials_cd"));
-        currentCommunityCerdentials.put("validityPeriod",currentCommunityCerdentials.get("validity_period"));
-        currentCommunityCerdentials.put("positivePhoto",currentCommunityCerdentials.get("positive_photo"));
-        currentCommunityCerdentials.put("negativePhoto",currentCommunityCerdentials.get("negative_photo"));
-        currentCommunityCerdentials.put("operate",StatusConstant.OPERATE_DEL);
-        getCommunityServiceDaoImpl().saveBusinessCommunityCerdentials(currentCommunityCerdentials);
-    }
 
 
     /**
      * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
-     * @param businessMemberCommunity 小区信息
+     * @param businessCommunityMember 小区信息
      */
-    protected void autoSaveDelBusinessMemberCommunity(Business business, JSONObject businessMemberCommunity){
+    protected void autoSaveDelBusinessCommunityMember(Business business, JSONObject businessCommunityMember){
 //自动插入DEL
         Map info = new HashMap();
-        info.put("memberCommunityId",businessMemberCommunity.getString("memberCommunityId"));
+        info.put("communityMemberId",businessCommunityMember.getString("communityMemberId"));
         info.put("statusCd",StatusConstant.STATUS_CD_VALID);
-        Map currentMemberCommunity = getCommunityServiceDaoImpl().getMemberCommunity(info);
-        if(currentMemberCommunity == null || currentMemberCommunity.isEmpty()){
+        Map currentCommunityMember = getCommunityServiceDaoImpl().getCommunityMember(info);
+        if(currentCommunityMember == null || currentCommunityMember.isEmpty()){
             throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info);
         }
-        currentMemberCommunity.put("bId",business.getbId());
-        currentMemberCommunity.put("communityId",currentMemberCommunity.get("community_id"));
-        currentMemberCommunity.put("memberCommunityId",currentMemberCommunity.get("member_community_id"));
-        currentMemberCommunity.put("memberId",currentMemberCommunity.get("member_id"));
-        currentMemberCommunity.put("operate",StatusConstant.OPERATE_DEL);
-        getCommunityServiceDaoImpl().saveBusinessCommunityInfo(currentMemberCommunity);
+        currentCommunityMember.put("bId",business.getbId());
+        currentCommunityMember.put("communityId",currentCommunityMember.get("community_id"));
+        currentCommunityMember.put("communityMemberId",currentCommunityMember.get("community_member_id"));
+        currentCommunityMember.put("memberId",currentCommunityMember.get("member_id"));
+        currentCommunityMember.put("memberTypeCd",currentCommunityMember.get("member_type_cd"));
+        currentCommunityMember.put("operate",StatusConstant.OPERATE_DEL);
+        getCommunityServiceDaoImpl().saveBusinessCommunityInfo(currentCommunityMember);
     }
 }

+ 155 - 0
CommunityService/src/main/java/com/java110/community/listener/MemberJoinedCommunityListener.java

@@ -0,0 +1,155 @@
+package com.java110.community.listener;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.ServiceCodeConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.common.util.Assert;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.entity.center.Business;
+import com.java110.community.dao.ICommunityServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 小区成员加入 侦听
+ *
+ * businessCommunityMember
+ * Created by wuxw on 2018/5/18.
+ */
+@Java110Listener("memberJoinedCommunityListener")
+@Transactional
+public class MemberJoinedCommunityListener extends AbstractCommunityBusinessServiceDataFlowListener{
+
+    private final static Logger logger = LoggerFactory.getLogger(MemberJoinedCommunityListener.class);
+
+    @Autowired
+    ICommunityServiceDao communityServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 5;
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeConstant.SERVICE_CODE_MEMBER_JOINED_COMMUNITY;
+    }
+
+    /**
+     * 保存小区信息 business 表中
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+        if(data.containsKey("businessCommunityMember")){
+            JSONObject businessCommunityMember = data.getJSONObject("businessCommunityMember");
+            doBusinessCommunityMember(business,businessCommunityMember);
+        }
+    }
+
+    /**
+     * business 数据转移到 instance
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+
+        Map info = new HashMap();
+        info.put("bId",business.getbId());
+        info.put("operate",StatusConstant.OPERATE_ADD);
+
+        //小区信息
+        Map businessCommunityMember = communityServiceDaoImpl.getBusinessCommunityMember(info);
+        if( businessCommunityMember != null && !businessCommunityMember.isEmpty()) {
+            communityServiceDaoImpl.saveCommunityMemberInstance(info);
+            dataFlowContext.addParamOut("communityId",businessCommunityMember.get("community_id"));
+            dataFlowContext.addParamOut("memberId",businessCommunityMember.get("member_id"));
+        }
+    }
+
+    /**
+     * 撤单
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
+        Map paramIn = new HashMap();
+        paramIn.put("bId",bId);
+        paramIn.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+        //小区信息
+        Map communityMember = communityServiceDaoImpl.getCommunityMember(info);
+        if(communityMember != null && !communityMember.isEmpty()){
+            paramIn.put("communityMemberId",communityMember.get("member_community_id").toString());
+            communityServiceDaoImpl.updateCommunityMemberInstance(paramIn);
+            dataFlowContext.addParamOut("communityMemberId",communityMember.get("member_community_id"));
+        }
+    }
+
+    /**
+     * 处理 businessCommunityMember 节点
+     * @param business 总的数据节点
+     * @param businessCommunityMember 小区成员节点
+     */
+    private void doBusinessCommunityMember(Business business,JSONObject businessCommunityMember){
+
+        Assert.jsonObjectHaveKey(businessCommunityMember,"communityId","businessCommunityMember 节点下没有包含 communityId 节点");
+        Assert.jsonObjectHaveKey(businessCommunityMember,"memberId","businessCommunityMember 节点下没有包含 memberId 节点");
+        Assert.jsonObjectHaveKey(businessCommunityMember,"memberTypeCd","businessCommunityMember 节点下没有包含 memberTypeCd 节点");
+
+        if(businessCommunityMember.getString("communityId").startsWith("-") || businessCommunityMember.getString("memberId").startsWith("-")){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"传入参数 communityId 或 communityId 必须是已有小区ID,"+businessCommunityMember);
+        }
+
+        if(businessCommunityMember.getString("communityMemberId").startsWith("-")){
+            //刷新缓存
+            flushCommunityMemberId(business.getDatas());
+        }
+
+        businessCommunityMember.put("bId",business.getbId());
+        businessCommunityMember.put("operate", StatusConstant.OPERATE_ADD);
+        //保存小区信息
+        communityServiceDaoImpl.saveBusinessCommunityMember(businessCommunityMember);
+
+    }
+
+
+    /**
+     * 刷新 小区ID
+     * @param data
+     */
+    private void flushCommunityMemberId(JSONObject data) {
+
+        String communityMemberId = GenerateCodeFactory.getCommunityMemberId();
+        JSONObject businessCommunityMember = data.getJSONObject("businessCommunityMember");
+        businessCommunityMember.put("communityMemberId",communityMemberId);
+
+    }
+    public ICommunityServiceDao getCommunityServiceDaoImpl() {
+        return communityServiceDaoImpl;
+    }
+
+    public void setCommunityServiceDaoImpl(ICommunityServiceDao communityServiceDaoImpl) {
+        this.communityServiceDaoImpl = communityServiceDaoImpl;
+    }
+}

+ 153 - 0
CommunityService/src/main/java/com/java110/community/listener/MemberQuitCommunityListener.java

@@ -0,0 +1,153 @@
+package com.java110.community.listener;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.ServiceCodeConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.common.util.Assert;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+import com.java110.community.dao.ICommunityServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 小区成员退出 侦听
+ *
+ * 处理节点
+ * 1、businessCommunityMember:{} 小区基本信息节点
+ * 协议地址 :https://github.com/java110/MicroCommunity/wiki/%E5%88%A0%E9%99%A4%E5%95%86%E6%88%B7%E4%BF%A1%E6%81%AF-%E5%8D%8F%E8%AE%AE
+ * Created by wuxw on 2018/5/18.
+ */
+@Java110Listener("memberQuitCommunityListener")
+@Transactional
+public class MemberQuitCommunityListener extends AbstractCommunityBusinessServiceDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(MemberQuitCommunityListener.class);
+    @Autowired
+    ICommunityServiceDao communityServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 6;
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeConstant.SERVICE_CODE_MEMBER_QUIT_COMMUNITY;
+    }
+
+    /**
+     * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+        //处理 businessCommunity 节点 按理这里不应该处理,程序上支持,以防真有这种业务
+        if(data.containsKey("businessCommunityMember")){
+            JSONObject memberCommunity = data.getJSONObject("businessCommunityMember");
+            doBusinessCommunityMember(business,memberCommunity);
+            dataFlowContext.addParamOut("memberCommunityId",memberCommunity.getString("memberCommunityId"));
+        }
+
+    }
+
+    /**
+     * 删除 instance数据
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+
+        //小区信息
+        Map info = new HashMap();
+        info.put("bId",business.getbId());
+        info.put("operate",StatusConstant.OPERATE_DEL);
+
+        //小区信息
+        Map businessCommunityMember = communityServiceDaoImpl.getBusinessCommunityMember(info);
+        if( businessCommunityMember != null && !businessCommunityMember.isEmpty()) {
+            flushBusinessCommunityMember(businessCommunityMember,StatusConstant.STATUS_CD_INVALID);
+            communityServiceDaoImpl.updateCommunityMemberInstance(businessCommunityMember);
+            dataFlowContext.addParamOut("memberCommunityId",businessCommunityMember.get("member_community_id"));
+        }
+    }
+
+    /**
+     * 撤单
+     * 从business表中查询到DEL的数据 将instance中的数据更新回来
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+
+        Map delInfo = new HashMap();
+        delInfo.put("bId",business.getbId());
+        delInfo.put("operate",StatusConstant.OPERATE_DEL);
+        //小区信息
+        Map memberCommunity = communityServiceDaoImpl.getCommunityMember(info);
+        if(memberCommunity != null && !memberCommunity.isEmpty()){
+
+            //小区信息
+            Map businessCommunityMember = communityServiceDaoImpl.getBusinessCommunityMember(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessCommunityMember == null || businessCommunityMember.isEmpty()){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(member community),程序内部异常,请检查! "+delInfo);
+            }
+
+            flushBusinessCommunityMember(businessCommunityMember,StatusConstant.STATUS_CD_VALID);
+            communityServiceDaoImpl.updateCommunityMemberInstance(businessCommunityMember);
+            dataFlowContext.addParamOut("memberCommunityId",memberCommunity.get("member_community_id"));
+        }
+    }
+
+
+
+    /**
+     * 处理 businessCommunity 节点
+     * @param business 总的数据节点
+     * @param businessCommunity 小区节点
+     */
+    private void doBusinessCommunityMember(Business business,JSONObject businessCommunity){
+
+        Assert.jsonObjectHaveKey(businessCommunity,"memberCommunityId","doBusinessCommunityMember 节点下没有包含 memberCommunityId 节点");
+
+        if(businessCommunity.getString("memberCommunityId").startsWith("-")){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"memberCommunityId 错误,不能自动生成(必须已经存在的memberCommunityId)"+businessCommunity);
+        }
+        //自动插入DEL
+        autoSaveDelBusinessCommunityMember(business,businessCommunity);
+    }
+
+
+
+
+    public ICommunityServiceDao getCommunityServiceDaoImpl() {
+        return communityServiceDaoImpl;
+    }
+
+    public void setCommunityServiceDaoImpl(ICommunityServiceDao communityServiceDaoImpl) {
+        this.communityServiceDaoImpl = communityServiceDaoImpl;
+    }
+}

+ 5 - 55
CommunityService/src/main/java/com/java110/community/listener/SaveCommunityInfoListener.java

@@ -45,7 +45,7 @@ public class SaveCommunityInfoListener extends AbstractCommunityBusinessServiceD
 
     @Override
     public String getServiceCode() {
-        return ServiceCodeConstant.SERVICE_CODE_SAVE_STORE_INFO;
+        return ServiceCodeConstant.SERVICE_CODE_SAVE_COMMUNITY_INFO;
     }
 
     /**
@@ -75,10 +75,7 @@ public class SaveCommunityInfoListener extends AbstractCommunityBusinessServiceD
             doBusinessCommunityPhoto(business,businessCommunityPhotos);
         }
 
-        if(data.containsKey("businessCommunityCerdentials")){
-            JSONArray businessCommunityCerdentialses = data.getJSONArray("businessCommunityCerdentials");
-            doBusinessCommunityCerdentials(business,businessCommunityCerdentialses);
-        }
+
     }
 
     /**
@@ -110,11 +107,7 @@ public class SaveCommunityInfoListener extends AbstractCommunityBusinessServiceD
         if(businessCommunityPhotos != null && businessCommunityPhotos.size() >0){
             communityServiceDaoImpl.saveCommunityPhotoInstance(info);
         }
-        //小区证件
-        List<Map> businessCommunityCerdentialses = communityServiceDaoImpl.getBusinessCommunityCerdentials(info);
-        if(businessCommunityCerdentialses != null && businessCommunityCerdentialses.size()>0){
-            communityServiceDaoImpl.saveCommunityCerdentialsInstance(info);
-        }
+
     }
 
     /**
@@ -152,11 +145,7 @@ public class SaveCommunityInfoListener extends AbstractCommunityBusinessServiceD
             communityServiceDaoImpl.updateCommunityPhotoInstance(paramIn);
         }
 
-        //小区属性
-        List<Map> communityCerdentialses = communityServiceDaoImpl.getCommunityCerdentials(info);
-        if(communityCerdentialses != null && communityCerdentialses.size()>0){
-            communityServiceDaoImpl.updateCommunityCerdentailsInstance(paramIn);
-        }
+
     }
 
     /**
@@ -230,38 +219,6 @@ public class SaveCommunityInfoListener extends AbstractCommunityBusinessServiceD
     }
 
 
-    /**
-     * 保存 小区证件 信息
-     * @param business 当前业务
-     * @param businessCommunityCerdentialses 小区证件
-     */
-    private void doBusinessCommunityCerdentials(Business business, JSONArray businessCommunityCerdentialses) {
-        for(int businessCommunityCerdentialsIndex = 0 ; businessCommunityCerdentialsIndex < businessCommunityCerdentialses.size() ; businessCommunityCerdentialsIndex ++) {
-            JSONObject businessCommunityCerdentials = businessCommunityCerdentialses.getJSONObject(businessCommunityCerdentialsIndex);
-            Assert.jsonObjectHaveKey(businessCommunityCerdentials, "communityId", "businessCommunityPhoto 节点下没有包含 communityId 节点");
-
-            if (businessCommunityCerdentials.getString("communityCerdentialsId").startsWith("-")) {
-                String communityPhotoId = "";//GenerateCodeFactory.getCommunityCerdentialsId();
-                businessCommunityCerdentials.put("communityCerdentialsId", communityPhotoId);
-            }
-            Date validityPeriod = null;
-            try {
-                if(StringUtil.isNullOrNone(businessCommunityCerdentials.getString("validityPeriod"))){
-                    validityPeriod = DateUtil.getLastDate();
-                }else {
-                    validityPeriod = DateUtil.getDateFromString(businessCommunityCerdentials.getString("validityPeriod"), DateUtil.DATE_FORMATE_STRING_B);
-                }
-            } catch (ParseException e) {
-                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"传入参数 validityPeriod 格式不正确,请填写 "+DateUtil.DATE_FORMATE_STRING_B +" 格式,"+businessCommunityCerdentials);
-            }
-            businessCommunityCerdentials.put("validityPeriod",validityPeriod);
-            businessCommunityCerdentials.put("bId", business.getbId());
-            businessCommunityCerdentials.put("operate", StatusConstant.OPERATE_ADD);
-            //保存小区信息
-            communityServiceDaoImpl.saveBusinessCommunityCerdentials(businessCommunityCerdentials);
-        }
-    }
-
 
 
     /**
@@ -289,14 +246,7 @@ public class SaveCommunityInfoListener extends AbstractCommunityBusinessServiceD
                 businessCommunityPhoto.put("communityId", communityId);
             }
         }
-        //刷 小区证件 的communityId
-        if(data.containsKey("businessCommunityCerdentials")) {
-            JSONArray businessCommunityCerdentialses = data.getJSONArray("businessCommunityCerdentials");
-            for(int businessCommunityCerdentialsIndex = 0;businessCommunityCerdentialsIndex < businessCommunityCerdentialses.size();businessCommunityCerdentialsIndex++) {
-                JSONObject businessCommunityCerdentials = businessCommunityCerdentialses.getJSONObject(businessCommunityCerdentialsIndex);
-                businessCommunityCerdentials.put("communityId", communityId);
-            }
-        }
+
     }
 
 

+ 4 - 48
CommunityService/src/main/java/com/java110/community/listener/UpdateCommunityInfoListener.java

@@ -46,7 +46,7 @@ public class UpdateCommunityInfoListener extends AbstractCommunityBusinessServic
 
     @Override
     public String getServiceCode() {
-        return ServiceCodeConstant.SERVICE_CODE_UPDATE_STORE_INFO;
+        return ServiceCodeConstant.SERVICE_CODE_UPDATE_COMMUNITY_INFO;
     }
 
     /**
@@ -78,10 +78,7 @@ public class UpdateCommunityInfoListener extends AbstractCommunityBusinessServic
             doBusinessCommunityPhoto(business,businessCommunityPhotos);
         }
 
-        if(data.containsKey("businessCommunityCerdentials")){
-            JSONArray businessCommunityCerdentialses = data.getJSONArray("businessCommunityCerdentials");
-            doBusinessCommunityCerdentials(business,businessCommunityCerdentialses);
-        }
+
     }
 
 
@@ -122,14 +119,7 @@ public class UpdateCommunityInfoListener extends AbstractCommunityBusinessServic
                 communityServiceDaoImpl.updateCommunityPhotoInstance(businessCommunityPhoto);
             }
         }
-        //小区证件
-        List<Map> businessCommunityCerdentialses = communityServiceDaoImpl.getBusinessCommunityCerdentials(info);
-        if(businessCommunityCerdentialses != null && businessCommunityCerdentialses.size()>0){
-            for(Map businessCommunityCerdentials : businessCommunityCerdentialses) {
-                flushBusinessCommunityCredentials(businessCommunityCerdentials,StatusConstant.STATUS_CD_VALID);
-                communityServiceDaoImpl.updateCommunityCerdentailsInstance(businessCommunityCerdentials);
-            }
-        }
+
     }
 
     /**
@@ -193,19 +183,7 @@ public class UpdateCommunityInfoListener extends AbstractCommunityBusinessServic
             }
         }
 
-        //小区属性
-        List<Map> communityCerdentialses = communityServiceDaoImpl.getCommunityCerdentials(info);
-        if(communityCerdentialses != null && communityCerdentialses.size()>0){
-            List<Map> businessCommunityCerdentialses = communityServiceDaoImpl.getBusinessCommunityCerdentials(delInfo);
-            //除非程序出错了,这里不会为空
-            if(businessCommunityCerdentialses == null || businessCommunityCerdentialses.size() ==0 ){
-                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(community_cerdentials),程序内部异常,请检查! "+delInfo);
-            }
-            for(Map businessCommunityCerdentials : businessCommunityCerdentialses) {
-                flushBusinessCommunityCredentials(businessCommunityCerdentials,StatusConstant.STATUS_CD_VALID);
-                communityServiceDaoImpl.updateCommunityCerdentailsInstance(businessCommunityCerdentials);
-            }
-        }
+
     }
 
     /**
@@ -285,29 +263,7 @@ public class UpdateCommunityInfoListener extends AbstractCommunityBusinessServic
     }
 
 
-    /**
-     * 保存 小区证件 信息
-     * @param business 当前业务
-     * @param businessCommunityCerdentialses 小区证件
-     */
-    private void doBusinessCommunityCerdentials(Business business, JSONArray businessCommunityCerdentialses) {
-
-        for(int businessCommunityCerdentialsIndex = 0 ; businessCommunityCerdentialsIndex < businessCommunityCerdentialses.size() ; businessCommunityCerdentialsIndex ++) {
-            JSONObject businessCommunityCerdentials = businessCommunityCerdentialses.getJSONObject(businessCommunityCerdentialsIndex);
-            Assert.jsonObjectHaveKey(businessCommunityCerdentials, "communityId", "businessCommunityPhoto 节点下没有包含 communityId 节点");
-
-            if (businessCommunityCerdentials.getString("communityCerdentialsId").startsWith("-")) {
-                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"communityPhotoId 错误,不能自动生成(必须已经存在的communityPhotoId)"+businessCommunityCerdentials);
-            }
-
-            autoSaveDelBusinessCommunityCerdentials(business,businessCommunityCerdentials);
 
-            businessCommunityCerdentials.put("bId", business.getbId());
-            businessCommunityCerdentials.put("operate", StatusConstant.OPERATE_ADD);
-            //保存小区信息
-            communityServiceDaoImpl.saveBusinessCommunityCerdentials(businessCommunityCerdentials);
-        }
-    }
 
     public ICommunityServiceDao getCommunityServiceDaoImpl() {
         return communityServiceDaoImpl;

+ 1 - 1
CommunityService/src/main/resources/application.yml

@@ -1,3 +1,3 @@
 spring:
   profiles:
-    active: test
+    active: dev

+ 28 - 0
java110-common/src/main/java/com/java110/common/constant/ServiceCodeConstant.java

@@ -224,6 +224,34 @@ public class ServiceCodeConstant {
 
 
 
+    /**
+     * 保存商户信息
+     */
+    public static final String SERVICE_CODE_SAVE_COMMUNITY_INFO = "save.community.info";
+
+    /**
+     * 修改商户信息
+     */
+    public static final String SERVICE_CODE_UPDATE_COMMUNITY_INFO = "update.community.info";
+
+    /**
+     * 删除商户信息
+     */
+    public static final String SERVICE_CODE_DELETE_COMMUNITY_INFO = "delete.community.info";
+
+
+    /**
+     * 商户成员加入信息
+     */
+    public static final String SERVICE_CODE_MEMBER_JOINED_COMMUNITY = "member.join.community";
+
+    /**
+     * 商户成员退出信息
+     */
+    public static final String SERVICE_CODE_MEMBER_QUIT_COMMUNITY = "member.quit.community";
+
+
+
 
 
 }

java110-config/db/CenterService/create_table.db → java110-config/db/CenterService/create_table.sql


+ 13 - 3
java110-config/db/CommunityService/create_table.sql

@@ -90,7 +90,8 @@ create table business_community_member(
     community_member_id varchar(30) not null comment 'ID',
     b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
     community_id VARCHAR(30) NOT NULL COMMENT '小区ID',
-    member_id varchar(50) not null  comment '商户成员ID',
+    member_id varchar(50) not null  comment '成员ID',
+    member_type_cd varchar(12) not null comment '成员类型见 community_member_type表',
     `month` INT NOT NULL comment '月份',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     operate VARCHAR(3) NOT NULL COMMENT '数据状态,添加ADD,修改MOD 删除DEL'
@@ -164,10 +165,19 @@ create table s_community_member(
     community_member_id varchar(30) not null comment 'ID',
     b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
     community_id VARCHAR(30) NOT NULL COMMENT '小区ID',
-    member_id varchar(50) not null  comment '商户成员ID',
+    member_id varchar(50) not null  comment '成员ID',
+    member_type_cd varchar(12) not null comment '成员类型见 community_member_type表',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     status_cd VARCHAR(2) NOT NULL default '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效',
     unique KEY (community_member_id)
-)
+);
 CREATE INDEX idx_s_community_member_id ON s_community_member(community_id);
 CREATE INDEX idx_s_community_member_b_id ON s_community_member(b_id);
+
+create table  community_member_type(
+    id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id',
+    member_type_cd VARCHAR(12) NOT NULL UNIQUE COMMENT '编码',
+    `name` VARCHAR(50) NOT NULL COMMENT '名称',
+    description VARCHAR(200) COMMENT '描述',
+    create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
+);

+ 300 - 0
java110-config/src/main/resources/mapper/community/CommunityServiceDaoImplMapper.xml

@@ -0,0 +1,300 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="communityServiceDaoImpl">
+    
+    <!-- 保存小区信息 add by wuxw 2018-07-03 -->
+    <insert id="saveBusinessCommunityInfo" parameterType="Map">
+        insert into business_community(community_id,b_id,name,address,city_code,nearby_landmarks,map_x,map_y,month,operate)
+        values(#{communityId},#{bId},#{name},#{address},#{cityCode},#{nearbyLandmarks},#{mapX},#{mapY},#{month},#{operate})
+    </insert>
+    <!-- 保存小区属性信息  add by wuxw 2018-07-03 -->
+    <insert id="saveBusinessCommunityAttr" parameterType="Map">
+        insert into business_community_attr(b_id,attr_id,community_id,spec_cd,value,month,operate)
+        values(#{bId},#{attrId},#{communityId},#{specCd},#{value},#{month},#{operate})
+    </insert>
+    <!-- 保存小区照片信息 add by wuxw 2018-07-03 -->
+    <insert id="saveBusinessCommunityPhoto" parameterType="Map">
+        insert into business_community_photo(community_photo_id,b_id,community_id,community_photo_type_cd,photo,month,operate)
+        values(#{communityPhotoId},#{bId},#{communityId},#{communityPhotoTypeCd},#{photo},#{month},#{operate})
+    </insert>
+
+
+    <!-- 查询小区信息(Business) add by wuxw 2018-07-03 -->
+    <select id="getBusinessCommunityInfo" parameterType="Map" resultType="Map">
+        select s.community_id,s.b_id,s.name,s.address,s.city_code,s.nearby_landmarks,s.map_x,s.map_y,s.operate
+        from business_community s where 1 = 1
+        <if test="operate != null and operate != ''">
+            and s.operate = #{operate}
+        </if>
+        <if test="bId != null and bId !=''">
+            and s.b_id = #{bId}
+        </if>
+        <if test="communityId != null and communityId != ''">
+            and s.community_id = #{communityId}
+        </if>
+    </select>
+
+
+    <!-- 查询小区属性信息(Business) add by wuxw 2018-07-03 -->
+    <select id="getBusinessCommunityAttrs" parameterType="Map" resultType="Map">
+        select sa.b_id,sa.attr_id,sa.community_id,sa.spec_cd,sa.value,sa.operate
+        from business_community_attr sa where 1=1
+        <if test="operate != null and operate != ''">
+            and sa.operate = #{operate}
+        </if>
+        <if test="bId != null and bId !=''">
+            and sa.b_id = #{bId}
+        </if>
+        <if test="communityId != null and communityId != ''">
+            and sa.community_id = #{communityId}
+        </if>
+        <if test="attrId != null and attrId != ''">
+            and sa.attr_id = #{attrId}
+        </if>
+    </select>
+
+    <!-- 查询小区照片信息 add by wuxw 2018-07-03 -->
+    <select id="getBusinessCommunityPhoto" parameterType="Map" resultType="Map">
+        select sp.community_photo_id,sp.b_id,sp.community_id,sp.community_photo_type_cd,sp.photo,sp.operate
+        from business_community_photo sp where 1=1
+        <if test="bId != null and bId !=''">
+            and sp.b_id = #{bId}
+        </if>
+        <if test="operate != null and operate != ''">
+            and sp.operate = #{operate}
+        </if>
+        <if test="communityId != null and communityId != ''">
+            and sp.community_id = #{communityId}
+        </if>
+    </select>
+
+
+    <!-- 保存小区信息至 instance表中 add by wuxw 2018-07-03 -->
+    <insert id="saveCommunityInfoInstance" parameterType="Map">
+        insert into s_community(community_id,b_id,name,address,city_code,nearby_landmarks,map_x,map_y,status_cd)
+        select s.community_id,s.b_id,s.name,s.address,s.city_code,s.nearby_landmarks,s.map_x,s.map_y,'0'
+        from business_community s where 
+        s.operate = 'ADD' and s.b_id=#{bId}
+    </insert>
+
+    <!-- 保存小区属性信息到 instance add by wuxw 2018-07-03 -->
+    <insert id="saveCommunityAttrsInstance" parameterType="Map">
+        insert into s_community_attr(b_id,attr_id,community_id,spec_cd,value,status_cd)
+        select sa.b_id,sa.attr_id,sa.community_id,sa.spec_cd,sa.value,'0'
+        from business_community_attr sa
+        where sa.operate = 'ADD' and sa.b_id=#{bId}
+    </insert>
+    
+    <!-- 保存 小区照片信息 instance add by wuxw 2018-07-03 -->
+    <insert id="saveCommunityPhotoInstance" parameterType="Map">
+        insert into s_community_photo(community_photo_id,b_id,community_id,community_photo_type_cd,photo,status_cd)
+        select sp.community_photo_id,sp.b_id,sp.community_id,sp.community_photo_type_cd,sp.photo,'0'
+        from business_community_photo sp
+        where  sp.operate = 'ADD' and sp.b_id=#{bId}
+    </insert>
+
+
+    <!-- 查询小区信息 add by wuxw 2018-07-03 -->
+    <select id="getCommunityInfo" parameterType="Map" resultType="Map">
+        select s.community_id,s.b_id,s.name,s.address,s.city_code,s.nearby_landmarks,s.map_x,s.map_y,s.status_cd
+        from s_community s
+        where 1=1
+        <if test="statusCd != null and statusCd != ''">
+            and s.status_cd = #{statusCd}
+        </if>
+
+        <if test="bId != null and bId !=''">
+            and s.b_id = #{bId}
+        </if>
+        <if test="communityId != null and communityId !=''">
+            and s.community_id = #{communityId}
+        </if>
+    </select>
+
+    <!-- 查询小区属性信息 add by wuxw 2018-07-03 -->
+    <select id="getCommunityAttrs" parameterType="Map" resultType="Map">
+        select sa.b_id,sa.attr_id,sa.community_id,sa.spec_cd,sa.value,sa.status_cd
+        from s_community_attr sa
+        where
+        1=1
+        <if test="statusCd != null and statusCd != ''">
+            and sa.status_cd = #{statusCd}
+        </if>
+        <if test="bId != null and bId !=''">
+            and sa.b_id = #{bId}
+        </if>
+        <if test="communityId != null and communityId !=''">
+            and sa.community_id = #{communityId}
+        </if>
+        <if test="attrId != null and attrId != ''">
+            and sa.attr_id = #{attrId}
+        </if>
+    </select>
+
+    <!-- 查询小区照片信息 add by wuxw 2018-07-03 -->
+    <select id="getCommunityPhoto" parameterType="Map" resultType="Map">
+        select sp.community_photo_id,sp.b_id,sp.community_id,sp.community_photo_type_cd,sp.photo,sp.status_cd
+        from s_community_photo sp
+        where 1=1
+        <if test="statusCd != null and statusCd != ''">
+            and sp.status_cd = #{statusCd}
+        </if>
+        <if test="bId != null and bId !=''">
+            and sp.b_id = #{bId}
+        </if>
+        <if test="communityId != null and communityId !=''">
+            and sp.community_id = #{communityId}
+        </if>
+    </select>
+
+
+
+    <!-- 修改小区信息 add by wuxw 2018-07-03 -->
+    <update id="updateCommunityInfoInstance" parameterType="Map">
+        update s_community s set s.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,s.b_id = #{newBId}
+        </if>
+
+        <if test="name != null and name != ''">
+            ,s.name = #{name}
+        </if>
+        <if test="address != null and address != ''">
+            ,s.address = #{address}
+        </if>
+        <if test="cityCode != null and cityCode != ''">
+            ,s.city_code = #{cityCode}
+        </if>
+        <if test="nearbyLandmarks != null and nearbyLandmarks != ''">
+            ,s.nearby_landmarks = #{nearbyLandmarks}
+        </if>
+        <if test="mapX != null and mapX != ''">
+            ,s.map_x = #{mapX}
+        </if>
+        <if test="mapY != null and mapY != ''">
+            ,s.map_y = #{mapY}
+        </if>
+        where 1=1
+        <if test="bId != null and bId !=''">
+            and s.b_id = #{bId}
+        </if>
+        <if test="communityId != null and communityId !=''">
+            and s.community_id = #{communityId}
+        </if>
+    </update>
+
+    <!-- 修改小区属性信息 add by wuxw 2018-07-03 -->
+    <update id="updateCommunityAttrInstance" parameterType="Map">
+        update s_community_attr sa set sa.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,sa.b_id = #{newBId}
+        </if>
+        <if test="value != null and value != ''">
+            ,sa.value = #{value}
+        </if>
+        where 1=1
+        <if test="bId != null and bId !=''">
+            and sa.b_id = #{bId}
+        </if>
+        <if test="communityId != null and communityId !=''">
+            and sa.community_id = #{communityId}
+        </if>
+        <if test="specCd != null and specCd !=''">
+            and sa.spec_cd = #{specCd}
+        </if>
+        <if test="attrId != null and attrId !=''">
+            and sa.attr_id = #{attrId}
+        </if>
+    </update>
+
+    <!-- 修改小区照片信息 add by wuxw 2018-07-03 -->
+    <update id="updateCommunityPhotoInstance" parameterType="Map">
+        update s_community_photo sp set sp.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,sp.b_id = #{newBId}
+        </if>
+        <if test="communityPhotoTypeCd != null and communityPhotoTypeCd != ''">
+            ,sp.community_photo_type_cd = #{communityPhotoTypeCd}
+        </if>
+        <if test="photo != null and photo != ''">
+            ,sp.photo = #{photo}
+        </if>
+        where 1=1
+        <if test="bId != null and bId !=''">
+            and sp.b_id = #{bId}
+        </if>
+        <if test="communityId != null and communityId !=''">
+            and sp.community_id = #{communityId}
+        </if>
+        <if test="communityPhotoId != null and communityPhotoId !=''">
+            and sp.community_photo_id = #{communityPhotoId}
+        </if>
+    </update>
+
+    
+
+    <!--小区成员加入 add by wuxw 2018-10-27 saveBusinessCommunityMember-->
+    <insert id="saveBusinessCommunityMember" parameterType="Map">
+        insert into business_community_member(community_member_id,b_id,community_id,member_id,member_type_cd,month,operate)
+        values(#{communityMemberId},#{bId},#{communityId},#{memberId},#{memberTypeCd},#{month},#{operate})
+    </insert>
+
+    <!-- 小区成员加入 instance表中 add by wuxw 2018-10-27 -->
+    <insert id="saveCommunityMemberInstance" parameterType="Map">
+        insert into s_community_member(community_member_id,b_id,community_id,member_id,member_type_cd,status_cd)
+        select ms.community_member_id,ms.b_id,ms.community_id,ms.member_id,ms.memberTypeCd,'0'
+        from business_community_member ms where
+        ms.operate = 'ADD' and ms.b_id=#{bId}
+    </insert>
+
+    <!-- 查询小区成员 add by wuxw 2018-10-27 getBusinessCommunityMember-->
+    <select id="getBusinessCommunityMember" parameterType="Map" resultType="Map">
+        select ms.community_member_id,ms.b_id,ms.community_id,ms.member_id,ms.member_type_cd,ms.operate
+        from business_community_member ms where 1 = 1
+        <if test="operate != null and operate != ''">,
+            and ms.operate = #{operate}
+        </if>
+        <if test="bId != null and bId !=''">
+            and ms.b_id = #{bId}
+        </if>
+        <if test="communityId != null and communityId != ''">
+            and ms.community_id = #{communityId}
+        </if>
+    </select>
+
+
+    <!-- 查询小区成员  add by wuxw 2018-07-03 -->
+    <select id="getCommunityMember" parameterType="Map" resultType="Map">
+        select ms.community_member_id,ms.b_id,ms.community_id,ms.member_id,ms.member_type_cd,ms.status_cd
+        from business_community_member ms
+        where 1=1
+        <if test="statusCd != null and statusCd != ''">
+            and ms.status_cd = #{statusCd}
+        </if>,
+
+        <if test="bId != null and bId !=''">
+            and ms.b_id = #{bId}
+        </if>
+        <if test="communityId != null and communityId !=''">
+            and ms.community_member_id = #{communityMemberId}
+        </if>
+    </select>
+
+    <!-- 修改小区成员 add by wuxw 2018-07-03 -->
+    <update id="updateCommunityMemberInstance" parameterType="Map">
+        update s_community_member ms set ms.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,ms.b_id = #{newBId}
+        </if>
+        where 1=1
+        <if test="bId != null and bId !=''">
+            and ms.b_id = #{bId}
+        </if>
+        <if test="communityMemberId != null and communityMemberId !=''">
+            and ms.community_member_id = #{communityMemberId}
+        </if>
+    </update>
+
+</mapper>

+ 13 - 0
java110-core/src/main/java/com/java110/core/factory/GenerateCodeFactory.java

@@ -71,6 +71,7 @@ public class GenerateCodeFactory {
         prefixMap.put("commentScoreId","64");
         prefixMap.put("communityId","70");
         prefixMap.put("communityPhotoId","71");
+        prefixMap.put("communityMemberId","72");
         prefixMap.put("agentId","80");
         prefixMap.put("agentIdPhotoId","81");
         prefixMap.put("agentCerdentialsId","82");
@@ -276,6 +277,18 @@ public class GenerateCodeFactory {
         return getCode(prefixMap.get("communityPhotoId"));
     }
 
+    /**
+     * 生成小区成员ID
+     * @return
+     * @throws GenerateCodeException
+     */
+    public static String getCommunityMemberId() throws GenerateCodeException{
+        if(!MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_NEED_INVOKE_GENERATE_ID))){
+            return prefixMap.get("communityMemberId") +DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H)+ nextId("%06d");
+        }
+        //调用服务
+        return getCode(prefixMap.get("communityMemberId"));
+    }
     /**
      * 获取小区ID
      * @return