Explorar o código

加入 组织管理功能

wuxw %!s(int64=6) %!d(string=hai) anos
pai
achega
d54bf02de4

+ 81 - 0
UserService/src/main/java/com/java110/user/dao/IOrgServiceDao.java

@@ -0,0 +1,81 @@
+package com.java110.user.dao;
+
+
+import com.java110.utils.exception.DAOException;
+import com.java110.entity.merchant.BoMerchant;
+import com.java110.entity.merchant.BoMerchantAttr;
+import com.java110.entity.merchant.Merchant;
+import com.java110.entity.merchant.MerchantAttr;
+
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 组织组件内部之间使用,没有给外围系统提供服务能力
+ * 组织服务接口类,要求全部以字符串传输,方便微服务化
+ * 新建客户,修改客户,删除客户,查询客户等功能
+ *
+ * Created by wuxw on 2016/12/27.
+ */
+public interface IOrgServiceDao {
+
+    /**
+     * 保存 组织信息
+     * @param businessOrgInfo 组织信息 封装
+     * @throws DAOException 操作数据库异常
+     */
+    void saveBusinessOrgInfo(Map businessOrgInfo) throws DAOException;
+
+
+
+    /**
+     * 查询组织信息(business过程)
+     * 根据bId 查询组织信息
+     * @param info bId 信息
+     * @return 组织信息
+     * @throws DAOException DAO异常
+     */
+    List<Map> getBusinessOrgInfo(Map info) throws DAOException;
+
+
+
+
+    /**
+     * 保存 组织信息 Business数据到 Instance中
+     * @param info
+     * @throws DAOException DAO异常
+     */
+    void saveOrgInfoInstance(Map info) throws DAOException;
+
+
+
+
+    /**
+     * 查询组织信息(instance过程)
+     * 根据bId 查询组织信息
+     * @param info bId 信息
+     * @return 组织信息
+     * @throws DAOException DAO异常
+     */
+    List<Map> getOrgInfo(Map info) throws DAOException;
+
+
+
+    /**
+     * 修改组织信息
+     * @param info 修改信息
+     * @throws DAOException DAO异常
+     */
+    void updateOrgInfoInstance(Map info) throws DAOException;
+
+
+    /**
+     * 查询组织总数
+     *
+     * @param info 组织信息
+     * @return 组织数量
+     */
+    int queryOrgsCount(Map info);
+
+}

+ 129 - 0
UserService/src/main/java/com/java110/user/dao/impl/OrgServiceDaoImpl.java

@@ -0,0 +1,129 @@
+package com.java110.user.dao.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.base.dao.BaseServiceDao;
+import com.java110.user.dao.IOrgServiceDao;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.exception.DAOException;
+import com.java110.utils.util.DateUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 组织服务 与数据库交互
+ * Created by wuxw on 2017/4/5.
+ */
+@Service("orgServiceDaoImpl")
+//@Transactional
+public class OrgServiceDaoImpl extends BaseServiceDao implements IOrgServiceDao {
+
+    private static Logger logger = LoggerFactory.getLogger(OrgServiceDaoImpl.class);
+
+    /**
+     * 组织信息封装
+     * @param businessOrgInfo 组织信息 封装
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public void saveBusinessOrgInfo(Map businessOrgInfo) throws DAOException {
+        businessOrgInfo.put("month", DateUtil.getCurrentMonth());
+        // 查询business_user 数据是否已经存在
+        logger.debug("保存组织信息 入参 businessOrgInfo : {}",businessOrgInfo);
+        int saveFlag = sqlSessionTemplate.insert("orgServiceDaoImpl.saveBusinessOrgInfo",businessOrgInfo);
+
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存组织数据失败:"+ JSONObject.toJSONString(businessOrgInfo));
+        }
+    }
+
+
+    /**
+     * 查询组织信息
+     * @param info bId 信息
+     * @return 组织信息
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public List<Map> getBusinessOrgInfo(Map info) throws DAOException {
+
+        logger.debug("查询组织信息 入参 info : {}",info);
+
+        List<Map> businessOrgInfos = sqlSessionTemplate.selectList("orgServiceDaoImpl.getBusinessOrgInfo",info);
+
+        return businessOrgInfos;
+    }
+
+
+
+    /**
+     * 保存组织信息 到 instance
+     * @param info   bId 信息
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public void saveOrgInfoInstance(Map info) throws DAOException {
+        logger.debug("保存组织信息Instance 入参 info : {}",info);
+
+        int saveFlag = sqlSessionTemplate.insert("orgServiceDaoImpl.saveOrgInfoInstance",info);
+
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存组织信息Instance数据失败:"+ JSONObject.toJSONString(info));
+        }
+    }
+
+
+    /**
+     * 查询组织信息(instance)
+     * @param info bId 信息
+     * @return List<Map>
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public List<Map> getOrgInfo(Map info) throws DAOException {
+        logger.debug("查询组织信息 入参 info : {}",info);
+
+        List<Map> businessOrgInfos = sqlSessionTemplate.selectList("orgServiceDaoImpl.getOrgInfo",info);
+
+        return businessOrgInfos;
+    }
+
+
+    /**
+     * 修改组织信息
+     * @param info 修改信息
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public void updateOrgInfoInstance(Map info) throws DAOException {
+        logger.debug("修改组织信息Instance 入参 info : {}",info);
+
+        int saveFlag = sqlSessionTemplate.update("orgServiceDaoImpl.updateOrgInfoInstance",info);
+
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改组织信息Instance数据失败:"+ JSONObject.toJSONString(info));
+        }
+    }
+
+     /**
+     * 查询组织数量
+     * @param info 组织信息
+     * @return 组织数量
+     */
+    @Override
+    public int queryOrgsCount(Map info) {
+        logger.debug("查询组织数据 入参 info : {}",info);
+
+        List<Map> businessOrgInfos = sqlSessionTemplate.selectList("orgServiceDaoImpl.queryOrgsCount", info);
+        if (businessOrgInfos.size() < 1) {
+            return 0;
+        }
+
+        return Integer.parseInt(businessOrgInfos.get(0).get("count").toString());
+    }
+
+
+}

+ 85 - 0
UserService/src/main/java/com/java110/user/listener/org/AbstractOrgBusinessServiceDataFlowListener.java

@@ -0,0 +1,85 @@
+package com.java110.user.listener.org;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.entity.center.Business;
+import com.java110.event.service.AbstractBusinessServiceDataFlowListener;
+import com.java110.user.dao.IOrgServiceDao;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.exception.ListenerExecuteException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 组织 服务侦听 父类
+ * Created by wuxw on 2018/7/4.
+ */
+public abstract class AbstractOrgBusinessServiceDataFlowListener extends AbstractBusinessServiceDataFlowListener {
+    private static Logger logger = LoggerFactory.getLogger(AbstractOrgBusinessServiceDataFlowListener.class);
+
+
+    /**
+     * 获取 DAO工具类
+     *
+     * @return
+     */
+    public abstract IOrgServiceDao getOrgServiceDaoImpl();
+
+    /**
+     * 刷新 businessOrgInfo 数据
+     * 主要将 数据库 中字段和 接口传递字段建立关系
+     *
+     * @param businessOrgInfo
+     */
+    protected void flushBusinessOrgInfo(Map businessOrgInfo, String statusCd) {
+        businessOrgInfo.put("newBId", businessOrgInfo.get("b_id"));
+        businessOrgInfo.put("orgName", businessOrgInfo.get("org_name"));
+        businessOrgInfo.put("operate", businessOrgInfo.get("operate"));
+        businessOrgInfo.put("parentOrgId", businessOrgInfo.get("parent_org_id"));
+        businessOrgInfo.put("description", businessOrgInfo.get("description"));
+        businessOrgInfo.put("orgLevel", businessOrgInfo.get("org_level"));
+        businessOrgInfo.put("storeId", businessOrgInfo.get("store_id"));
+        businessOrgInfo.put("orgId", businessOrgInfo.get("org_id"));
+        businessOrgInfo.remove("bId");
+        businessOrgInfo.put("statusCd", statusCd);
+    }
+
+
+    /**
+     * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
+     *
+     * @param businessOrg 组织信息
+     */
+    protected void autoSaveDelBusinessOrg(Business business, JSONObject businessOrg) {
+//自动插入DEL
+        Map info = new HashMap();
+        info.put("orgId", businessOrg.getString("orgId"));
+        info.put("statusCd", StatusConstant.STATUS_CD_VALID);
+        List<Map> currentOrgInfos = getOrgServiceDaoImpl().getOrgInfo(info);
+        if (currentOrgInfos == null || currentOrgInfos.size() != 1) {
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "未找到需要修改数据信息,入参错误或数据有问题,请检查" + info);
+        }
+
+        Map currentOrgInfo = currentOrgInfos.get(0);
+
+        currentOrgInfo.put("bId", business.getbId());
+
+        currentOrgInfo.put("orgName", currentOrgInfo.get("org_name"));
+        currentOrgInfo.put("operate", currentOrgInfo.get("operate"));
+        currentOrgInfo.put("parentOrgId", currentOrgInfo.get("parent_org_id"));
+        currentOrgInfo.put("description", currentOrgInfo.get("description"));
+        currentOrgInfo.put("orgLevel", currentOrgInfo.get("org_level"));
+        currentOrgInfo.put("storeId", currentOrgInfo.get("store_id"));
+        currentOrgInfo.put("orgId", currentOrgInfo.get("org_id"));
+
+
+        currentOrgInfo.put("operate", StatusConstant.OPERATE_DEL);
+        getOrgServiceDaoImpl().saveBusinessOrgInfo(currentOrgInfo);
+    }
+
+
+}

+ 180 - 0
UserService/src/main/java/com/java110/user/listener/org/DeleteOrgInfoListener.java

@@ -0,0 +1,180 @@
+package com.java110.user.listener.org;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+import com.java110.user.dao.IOrgServiceDao;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.exception.ListenerExecuteException;
+import com.java110.utils.util.Assert;
+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.List;
+import java.util.Map;
+
+/**
+ * 删除组织信息 侦听
+ * <p>
+ * 处理节点
+ * 1、businessOrg:{} 组织基本信息节点
+ * 2、businessOrgAttr:[{}] 组织属性信息节点
+ * 3、businessOrgPhoto:[{}] 组织照片信息节点
+ * 4、businessOrgCerdentials:[{}] 组织证件信息节点
+ * 协议地址 :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("deleteOrgInfoListener")
+@Transactional
+public class DeleteOrgInfoListener extends AbstractOrgBusinessServiceDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(DeleteOrgInfoListener.class);
+    @Autowired
+    IOrgServiceDao orgServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 3;
+    }
+
+    @Override
+    public String getBusinessTypeCd() {
+        return BusinessTypeConstant.BUSINESS_TYPE_DELETE_ORG;
+    }
+
+    /**
+     * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去
+     *
+     * @param dataFlowContext 数据对象
+     * @param business        当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data, "没有datas 节点,或没有子节点需要处理");
+
+        //处理 businessOrg 节点
+        if (data.containsKey("businessOrg")) {
+            //处理 businessOrg 节点
+            if (data.containsKey("businessOrg")) {
+                Object _obj = data.get("businessOrg");
+                JSONArray businessOrgs = null;
+                if (_obj instanceof JSONObject) {
+                    businessOrgs = new JSONArray();
+                    businessOrgs.add(_obj);
+                } else {
+                    businessOrgs = (JSONArray) _obj;
+                }
+                //JSONObject businessOrg = data.getJSONObject("businessOrg");
+                for (int _orgIndex = 0; _orgIndex < businessOrgs.size(); _orgIndex++) {
+                    JSONObject businessOrg = businessOrgs.getJSONObject(_orgIndex);
+                    doBusinessOrg(business, businessOrg);
+                    if (_obj instanceof JSONObject) {
+                        dataFlowContext.addParamOut("orgId", businessOrg.getString("orgId"));
+                    }
+                }
+            }
+        }
+
+
+    }
+
+    /**
+     * 删除 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);
+
+        //组织信息
+        List<Map> businessOrgInfos = orgServiceDaoImpl.getBusinessOrgInfo(info);
+        if (businessOrgInfos != null && businessOrgInfos.size() > 0) {
+            for (int _orgIndex = 0; _orgIndex < businessOrgInfos.size(); _orgIndex++) {
+                Map businessOrgInfo = businessOrgInfos.get(_orgIndex);
+                flushBusinessOrgInfo(businessOrgInfo, StatusConstant.STATUS_CD_INVALID);
+                orgServiceDaoImpl.updateOrgInfoInstance(businessOrgInfo);
+                dataFlowContext.addParamOut("orgId", businessOrgInfo.get("org_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);
+        //组织信息
+        List<Map> orgInfo = orgServiceDaoImpl.getOrgInfo(info);
+        if (orgInfo != null && orgInfo.size() > 0) {
+
+            //组织信息
+            List<Map> businessOrgInfos = orgServiceDaoImpl.getBusinessOrgInfo(delInfo);
+            //除非程序出错了,这里不会为空
+            if (businessOrgInfos == null || businessOrgInfos.size() == 0) {
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR, "撤单失败(org),程序内部异常,请检查! " + delInfo);
+            }
+            for (int _orgIndex = 0; _orgIndex < businessOrgInfos.size(); _orgIndex++) {
+                Map businessOrgInfo = businessOrgInfos.get(_orgIndex);
+                flushBusinessOrgInfo(businessOrgInfo, StatusConstant.STATUS_CD_VALID);
+                orgServiceDaoImpl.updateOrgInfoInstance(businessOrgInfo);
+            }
+        }
+    }
+
+
+    /**
+     * 处理 businessOrg 节点
+     *
+     * @param business    总的数据节点
+     * @param businessOrg 组织节点
+     */
+    private void doBusinessOrg(Business business, JSONObject businessOrg) {
+
+        Assert.jsonObjectHaveKey(businessOrg, "orgId", "businessOrg 节点下没有包含 orgId 节点");
+
+        if (businessOrg.getString("orgId").startsWith("-")) {
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "orgId 错误,不能自动生成(必须已经存在的orgId)" + businessOrg);
+        }
+        //自动插入DEL
+        autoSaveDelBusinessOrg(business, businessOrg);
+    }
+
+    public IOrgServiceDao getOrgServiceDaoImpl() {
+        return orgServiceDaoImpl;
+    }
+
+    public void setOrgServiceDaoImpl(IOrgServiceDao orgServiceDaoImpl) {
+        this.orgServiceDaoImpl = orgServiceDaoImpl;
+    }
+}

+ 179 - 0
UserService/src/main/java/com/java110/user/listener/org/SaveOrgInfoListener.java

@@ -0,0 +1,179 @@
+package com.java110.user.listener.org;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+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.user.dao.IOrgServiceDao;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.util.Assert;
+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.List;
+import java.util.Map;
+
+/**
+ * 保存 组织信息 侦听
+ * Created by wuxw on 2018/5/18.
+ */
+@Java110Listener("saveOrgInfoListener")
+@Transactional
+public class SaveOrgInfoListener extends AbstractOrgBusinessServiceDataFlowListener {
+
+    private static Logger logger = LoggerFactory.getLogger(SaveOrgInfoListener.class);
+
+    @Autowired
+    private IOrgServiceDao orgServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 0;
+    }
+
+    @Override
+    public String getBusinessTypeCd() {
+        return BusinessTypeConstant.BUSINESS_TYPE_SAVE_ORG;
+    }
+
+    /**
+     * 保存组织信息 business 表中
+     *
+     * @param dataFlowContext 数据对象
+     * @param business        当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+        Assert.notEmpty(data, "没有datas 节点,或没有子节点需要处理");
+
+        //处理 businessOrg 节点
+        if (data.containsKey("businessOrg")) {
+            Object bObj = data.get("businessOrg");
+            JSONArray businessOrgs = null;
+            if (bObj instanceof JSONObject) {
+                businessOrgs = new JSONArray();
+                businessOrgs.add(bObj);
+            } else {
+                businessOrgs = (JSONArray) bObj;
+            }
+            //JSONObject businessOrg = data.getJSONObject("businessOrg");
+            for (int bOrgIndex = 0; bOrgIndex < businessOrgs.size(); bOrgIndex++) {
+                JSONObject businessOrg = businessOrgs.getJSONObject(bOrgIndex);
+                doBusinessOrg(business, businessOrg);
+                if (bObj instanceof JSONObject) {
+                    dataFlowContext.addParamOut("orgId", businessOrg.getString("orgId"));
+                }
+            }
+        }
+    }
+
+    /**
+     * 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);
+
+        //组织信息
+        List<Map> businessOrgInfo = orgServiceDaoImpl.getBusinessOrgInfo(info);
+        if (businessOrgInfo != null && businessOrgInfo.size() > 0) {
+            reFreshShareColumn(info, businessOrgInfo.get(0));
+            orgServiceDaoImpl.saveOrgInfoInstance(info);
+            if (businessOrgInfo.size() == 1) {
+                dataFlowContext.addParamOut("orgId", businessOrgInfo.get(0).get("org_id"));
+            }
+        }
+    }
+
+
+    /**
+     * 刷 分片字段
+     *
+     * @param info         查询对象
+     * @param businessInfo 小区ID
+     */
+    private void reFreshShareColumn(Map info, Map businessInfo) {
+
+        if (info.containsKey("storeId")) {
+            return;
+        }
+
+        if (!businessInfo.containsKey("store_id")) {
+            return;
+        }
+
+        info.put("storeId", businessInfo.get("store_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);
+        //组织信息
+        List<Map> orgInfo = orgServiceDaoImpl.getOrgInfo(info);
+        if (orgInfo != null && orgInfo.size() > 0) {
+            reFreshShareColumn(paramIn, orgInfo.get(0));
+            orgServiceDaoImpl.updateOrgInfoInstance(paramIn);
+        }
+    }
+
+
+    /**
+     * 处理 businessOrg 节点
+     *
+     * @param business    总的数据节点
+     * @param businessOrg 组织节点
+     */
+    private void doBusinessOrg(Business business, JSONObject businessOrg) {
+
+        Assert.jsonObjectHaveKey(businessOrg, "orgId", "businessOrg 节点下没有包含 orgId 节点");
+
+        if (businessOrg.getString("orgId").startsWith("-")) {
+            //刷新缓存
+            //flushOrgId(business.getDatas());
+
+            businessOrg.put("orgId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_orgId));
+
+        }
+
+        businessOrg.put("bId", business.getbId());
+        businessOrg.put("operate", StatusConstant.OPERATE_ADD);
+        //保存组织信息
+        orgServiceDaoImpl.saveBusinessOrgInfo(businessOrg);
+
+    }
+
+    public IOrgServiceDao getOrgServiceDaoImpl() {
+        return orgServiceDaoImpl;
+    }
+
+    public void setOrgServiceDaoImpl(IOrgServiceDao orgServiceDaoImpl) {
+        this.orgServiceDaoImpl = orgServiceDaoImpl;
+    }
+}

+ 190 - 0
UserService/src/main/java/com/java110/user/listener/org/UpdateOrgInfoListener.java

@@ -0,0 +1,190 @@
+package com.java110.user.listener.org;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+import com.java110.user.dao.IOrgServiceDao;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.exception.ListenerExecuteException;
+import com.java110.utils.util.Assert;
+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.List;
+import java.util.Map;
+
+/**
+ * 修改组织信息 侦听
+ * <p>
+ * 处理节点
+ * 1、businessOrg:{} 组织基本信息节点
+ * 2、businessOrgAttr:[{}] 组织属性信息节点
+ * 3、businessOrgPhoto:[{}] 组织照片信息节点
+ * 4、businessOrgCerdentials:[{}] 组织证件信息节点
+ * 协议地址 :https://github.com/java110/MicroCommunity/wiki/%E4%BF%AE%E6%94%B9%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("updateOrgInfoListener")
+@Transactional
+public class UpdateOrgInfoListener extends AbstractOrgBusinessServiceDataFlowListener {
+
+    private static Logger logger = LoggerFactory.getLogger(UpdateOrgInfoListener.class);
+    @Autowired
+    private IOrgServiceDao orgServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 2;
+    }
+
+    @Override
+    public String getBusinessTypeCd() {
+        return BusinessTypeConstant.BUSINESS_TYPE_UPDATE_ORG;
+    }
+
+    /**
+     * business过程
+     *
+     * @param dataFlowContext 上下文对象
+     * @param business        业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data, "没有datas 节点,或没有子节点需要处理");
+
+        //处理 businessOrg 节点
+        if (data.containsKey("businessOrg")) {
+            //处理 businessOrg 节点
+            if (data.containsKey("businessOrg")) {
+                Object _obj = data.get("businessOrg");
+                JSONArray businessOrgs = null;
+                if (_obj instanceof JSONObject) {
+                    businessOrgs = new JSONArray();
+                    businessOrgs.add(_obj);
+                } else {
+                    businessOrgs = (JSONArray) _obj;
+                }
+                //JSONObject businessOrg = data.getJSONObject("businessOrg");
+                for (int _orgIndex = 0; _orgIndex < businessOrgs.size(); _orgIndex++) {
+                    JSONObject businessOrg = businessOrgs.getJSONObject(_orgIndex);
+                    doBusinessOrg(business, businessOrg);
+                    if (_obj instanceof JSONObject) {
+                        dataFlowContext.addParamOut("orgId", businessOrg.getString("orgId"));
+                    }
+                }
+            }
+        }
+    }
+
+
+    /**
+     * business to 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);
+
+        //组织信息
+        List<Map> businessOrgInfos = orgServiceDaoImpl.getBusinessOrgInfo(info);
+        if (businessOrgInfos != null && businessOrgInfos.size() > 0) {
+            for (int _orgIndex = 0; _orgIndex < businessOrgInfos.size(); _orgIndex++) {
+                Map businessOrgInfo = businessOrgInfos.get(_orgIndex);
+                flushBusinessOrgInfo(businessOrgInfo, StatusConstant.STATUS_CD_VALID);
+                orgServiceDaoImpl.updateOrgInfoInstance(businessOrgInfo);
+                if (businessOrgInfo.size() == 1) {
+                    dataFlowContext.addParamOut("orgId", businessOrgInfo.get("org_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 delInfo = new HashMap();
+        delInfo.put("bId", business.getbId());
+        delInfo.put("operate", StatusConstant.OPERATE_DEL);
+        //组织信息
+        List<Map> orgInfo = orgServiceDaoImpl.getOrgInfo(info);
+        if (orgInfo != null && orgInfo.size() > 0) {
+
+            //组织信息
+            List<Map> businessOrgInfos = orgServiceDaoImpl.getBusinessOrgInfo(delInfo);
+            //除非程序出错了,这里不会为空
+            if (businessOrgInfos == null || businessOrgInfos.size() == 0) {
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR, "撤单失败(org),程序内部异常,请检查! " + delInfo);
+            }
+            for (int _orgIndex = 0; _orgIndex < businessOrgInfos.size(); _orgIndex++) {
+                Map businessOrgInfo = businessOrgInfos.get(_orgIndex);
+                flushBusinessOrgInfo(businessOrgInfo, StatusConstant.STATUS_CD_VALID);
+                orgServiceDaoImpl.updateOrgInfoInstance(businessOrgInfo);
+            }
+        }
+
+    }
+
+
+    /**
+     * 处理 businessOrg 节点
+     *
+     * @param business    总的数据节点
+     * @param businessOrg 组织节点
+     */
+    private void doBusinessOrg(Business business, JSONObject businessOrg) {
+
+        Assert.jsonObjectHaveKey(businessOrg, "orgId", "businessOrg 节点下没有包含 orgId 节点");
+
+        if (businessOrg.getString("orgId").startsWith("-")) {
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "orgId 错误,不能自动生成(必须已经存在的orgId)" + businessOrg);
+        }
+        //自动保存DEL
+        autoSaveDelBusinessOrg(business, businessOrg);
+
+        businessOrg.put("bId", business.getbId());
+        businessOrg.put("operate", StatusConstant.OPERATE_ADD);
+        //保存组织信息
+        orgServiceDaoImpl.saveBusinessOrgInfo(businessOrg);
+
+    }
+
+
+    public IOrgServiceDao getOrgServiceDaoImpl() {
+        return orgServiceDaoImpl;
+    }
+
+    public void setOrgServiceDaoImpl(IOrgServiceDao orgServiceDaoImpl) {
+        this.orgServiceDaoImpl = orgServiceDaoImpl;
+    }
+
+
+}

+ 74 - 0
UserService/src/main/java/com/java110/user/smo/impl/OrgInnerServiceSMOImpl.java

@@ -0,0 +1,74 @@
+package com.java110.user.smo.impl;
+
+
+import com.java110.core.base.smo.BaseServiceSMO;
+import com.java110.core.smo.org.IOrgInnerServiceSMO;
+import com.java110.core.smo.user.IUserInnerServiceSMO;
+import com.java110.dto.PageDto;
+import com.java110.dto.UserDto;
+import com.java110.dto.org.OrgDto;
+import com.java110.user.dao.IOrgServiceDao;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @ClassName FloorInnerServiceSMOImpl
+ * @Description 组织内部服务实现类
+ * @Author wuxw
+ * @Date 2019/4/24 9:20
+ * @Version 1.0
+ * add by wuxw 2019/4/24
+ **/
+@RestController
+public class OrgInnerServiceSMOImpl extends BaseServiceSMO implements IOrgInnerServiceSMO {
+
+    @Autowired
+    private IOrgServiceDao orgServiceDaoImpl;
+
+    @Autowired
+    private IUserInnerServiceSMO userInnerServiceSMOImpl;
+
+    @Override
+    public List<OrgDto> queryOrgs(@RequestBody OrgDto orgDto) {
+
+        //校验是否传了 分页信息
+
+        int page = orgDto.getPage();
+
+        if (page != PageDto.DEFAULT_PAGE) {
+            orgDto.setPage((page - 1) * orgDto.getRow());
+        }
+
+        List<OrgDto> orgs = BeanConvertUtil.covertBeanList(orgServiceDaoImpl.getOrgInfo(BeanConvertUtil.beanCovertMap(orgDto)), OrgDto.class);
+
+
+        return orgs;
+    }
+
+
+    @Override
+    public int queryOrgsCount(@RequestBody OrgDto orgDto) {
+        return orgServiceDaoImpl.queryOrgsCount(BeanConvertUtil.beanCovertMap(orgDto));
+    }
+
+    public IOrgServiceDao getOrgServiceDaoImpl() {
+        return orgServiceDaoImpl;
+    }
+
+    public void setOrgServiceDaoImpl(IOrgServiceDao orgServiceDaoImpl) {
+        this.orgServiceDaoImpl = orgServiceDaoImpl;
+    }
+
+    public IUserInnerServiceSMO getUserInnerServiceSMOImpl() {
+        return userInnerServiceSMOImpl;
+    }
+
+    public void setUserInnerServiceSMOImpl(IUserInnerServiceSMO userInnerServiceSMOImpl) {
+        this.userInnerServiceSMOImpl = userInnerServiceSMOImpl;
+    }
+}

+ 114 - 0
docs/document/services/org/DeleteOrgInfo.md

@@ -0,0 +1,114 @@
+
+
+**1\. 删除组织**
+###### 接口功能
+> API服务做删除组织时调用该接口
+
+###### URL
+> [http://org-service/orgApi/service](http://org-service/orgApi/service)
+
+###### 支持格式
+> JSON
+
+###### HTTP请求方式
+> POST
+
+###### 协议接口
+|父元素名称|参数名称|约束|类型|长度|描述|取值说明|
+| :-: | :-: | :-: | :-: | :-: | :-: | :-:|
+|-|orders|1|Object|-|订单节点|-|
+|-|business|1|Array|-|业务节点|-|
+
+###### orders
+|父元素名称|参数名称|约束|类型|长度|描述|取值说明|
+| :-: | :-: | :-: | :-: | :-: | :-: | :-: |
+|-|orders|1|Object|-|订单节点|-|
+|orders|appId|1|String|10|系统ID|由中心服务提供|
+|orders|transactionId|1|String|30|交互流水|appId+'00'+YYYYMMDD+10位序列|
+|orders|userId|1|String|30|用户ID|已有用户ID|
+|orders|orderTypeCd|1|String|4|订单类型|查看订单类型说明|
+|orders|requestTime|1|String|14|请求时间|YYYYMMDDhhmmss|
+|orders|remark|1|String|200|备注|备注|
+|orders|sign|?|String|64|签名|查看加密说明|
+|orders|attrs|?|Array|-|订单属性|-|
+|attrs|specCd|1|String|12|规格编码|由中心服务提供|
+|attrs|value|1|String|50|属性值|-|
+|orders|response|1|Object|-|返回结果节点|-|
+|response|code|1|String|4|返回状态|查看状态说明|
+|response|message|1|String|200|返回状态描述|-|
+
+###### business
+|父元素名称|参数名称|约束|类型|长度|描述|取值说明|
+| :-: | :-: | :-: | :-: | :-: | :-: | :-: |
+|-|business|?|Array|-|业务节点|-|
+|business|businessTypeCd|1|String|12|业务类型编码|500100030002|
+|business|datas|1|Object|-|数据节点|不同的服务下的节点不一样|
+|datas|businessOrgInfo|1|Object|-|小区成员|小区成员|
+|businessOrgInfo|orgId|1|String|30|-|-|
+
+
+###### 返回协议
+
+当http返回状态不为200 时请求处理失败 body内容为失败的原因
+
+当http返回状态为200时请求处理成功,body内容为返回内容,
+
+
+
+
+
+###### 举例
+> 地址:[http://org-service/orgApi/service](http://org-service/orgApi/service)
+
+``` javascript
+请求头信息:
+Content-Type:application/json
+
+请求报文:
+
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "businessType":"I",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": {
+    "businessTypeCd": "140100050001",
+    "bId":"1234567892",
+    "remark": "备注",
+    "datas": {
+      "businessOrgInfo": {
+                "orgId":"填写存在的值"
+      }
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }
+}
+
+返回报文:
+ {
+	"orderTypeCd": "D",
+	"response": {
+		"code": "0000",
+		"message": "成功"
+	},
+	"responseTime": "20190418102004",
+	"bId": "202019041810750003",
+	"businessType": "B",
+	"transactionId": "3a5a411ec65a4c3f895935638aa1d2bc",
+	"dataFlowId": "44fde86d39ce46f4b4aab5f6b14f3947"
+}
+
+```

+ 124 - 0
docs/document/services/org/SaveOrgInfo.md

@@ -0,0 +1,124 @@
+
+
+**1\. 保存组织**
+###### 接口功能
+> API服务做保存组织时调用该接口
+
+###### URL
+> [http://org-service/orgApi/service](http://org-service/orgApi/service)
+
+###### 支持格式
+> JSON
+
+###### HTTP请求方式
+> POST
+
+###### 协议接口
+|父元素名称|参数名称|约束|类型|长度|描述|取值说明|
+| :-: | :-: | :-: | :-: | :-: | :-: | :-:|
+|-|orders|1|Object|-|订单节点|-|
+|-|business|1|Array|-|业务节点|-|
+
+###### orders
+|父元素名称|参数名称|约束|类型|长度|描述|取值说明|
+| :-: | :-: | :-: | :-: | :-: | :-: | :-: |
+|-|orders|1|Object|-|订单节点|-|
+|orders|appId|1|String|10|系统ID|由中心服务提供|
+|orders|transactionId|1|String|30|交互流水|appId+'00'+YYYYMMDD+10位序列|
+|orders|userId|1|String|30|用户ID|已有用户ID|
+|orders|orderTypeCd|1|String|4|订单类型|查看订单类型说明|
+|orders|requestTime|1|String|14|请求时间|YYYYMMDDhhmmss|
+|orders|remark|1|String|200|备注|备注|
+|orders|sign|?|String|64|签名|查看加密说明|
+|orders|attrs|?|Array|-|订单属性|-|
+|attrs|specCd|1|String|12|规格编码|由中心服务提供|
+|attrs|value|1|String|50|属性值|-|
+|orders|response|1|Object|-|返回结果节点|-|
+|response|code|1|String|4|返回状态|查看状态说明|
+|response|message|1|String|200|返回状态描述|-|
+
+###### business
+|父元素名称|参数名称|约束|类型|长度|描述|取值说明|
+| :-: | :-: | :-: | :-: | :-: | :-: | :-: |
+|-|business|?|Array|-|业务节点|-|
+|business|businessTypeCd|1|String|12|业务类型编码|500100030002|
+|business|datas|1|Object|-|数据节点|不同的服务下的节点不一样|
+|datas|businessOrgInfo|1|Object|-|小区成员|小区成员|
+|businessOrgInfo|orgName|1|String|30|-|-|
+|businessOrgInfo|parentOrgId|1|String|30|-|-|
+|businessOrgInfo|description|1|String|30|-|-|
+|businessOrgInfo|orgLevel|1|String|30|-|-|
+|businessOrgInfo|storeId|1|String|30|-|-|
+|businessOrgInfo|orgId|1|String|30|-|-|
+
+
+###### 返回协议
+
+当http返回状态不为200 时请求处理失败 body内容为失败的原因
+
+当http返回状态为200时请求处理成功,body内容为返回内容,
+
+
+
+
+
+###### 举例
+> 地址:[http://org-service/orgApi/service](http://org-service/orgApi/service)
+
+``` javascript
+请求头信息:
+Content-Type:application/json
+
+请求报文:
+
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "businessType":"I",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": {
+    "businessTypeCd": "140100030001",
+    "bId":"1234567892",
+    "remark": "备注",
+    "datas": {
+      "businessOrgInfo": {
+                "orgName":"填写具体值",
+        "parentOrgId":"填写具体值",
+        "description":"填写具体值",
+        "orgLevel":"填写具体值",
+        "storeId":"填写具体值",
+        "orgId":"填写具体值"
+      }
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }
+}
+
+返回报文:
+ {
+	"orderTypeCd": "D",
+	"response": {
+		"code": "0000",
+		"message": "成功"
+	},
+	"responseTime": "20190418102004",
+	"bId": "202019041810750003",
+	"businessType": "B",
+	"transactionId": "3a5a411ec65a4c3f895935638aa1d2bc",
+	"dataFlowId": "44fde86d39ce46f4b4aab5f6b14f3947"
+}
+
+```

+ 124 - 0
docs/document/services/org/UpdateOrgInfo.md

@@ -0,0 +1,124 @@
+
+
+**1\. 修改组织**
+###### 接口功能
+> API服务做修改组织时调用该接口
+
+###### URL
+> [http://org-service/orgApi/service](http://org-service/orgApi/service)
+
+###### 支持格式
+> JSON
+
+###### HTTP请求方式
+> POST
+
+###### 协议接口
+|父元素名称|参数名称|约束|类型|长度|描述|取值说明|
+| :-: | :-: | :-: | :-: | :-: | :-: | :-:|
+|-|orders|1|Object|-|订单节点|-|
+|-|business|1|Array|-|业务节点|-|
+
+###### orders
+|父元素名称|参数名称|约束|类型|长度|描述|取值说明|
+| :-: | :-: | :-: | :-: | :-: | :-: | :-: |
+|-|orders|1|Object|-|订单节点|-|
+|orders|appId|1|String|10|系统ID|由中心服务提供|
+|orders|transactionId|1|String|30|交互流水|appId+'00'+YYYYMMDD+10位序列|
+|orders|userId|1|String|30|用户ID|已有用户ID|
+|orders|orderTypeCd|1|String|4|订单类型|查看订单类型说明|
+|orders|requestTime|1|String|14|请求时间|YYYYMMDDhhmmss|
+|orders|remark|1|String|200|备注|备注|
+|orders|sign|?|String|64|签名|查看加密说明|
+|orders|attrs|?|Array|-|订单属性|-|
+|attrs|specCd|1|String|12|规格编码|由中心服务提供|
+|attrs|value|1|String|50|属性值|-|
+|orders|response|1|Object|-|返回结果节点|-|
+|response|code|1|String|4|返回状态|查看状态说明|
+|response|message|1|String|200|返回状态描述|-|
+
+###### business
+|父元素名称|参数名称|约束|类型|长度|描述|取值说明|
+| :-: | :-: | :-: | :-: | :-: | :-: | :-: |
+|-|business|?|Array|-|业务节点|-|
+|business|businessTypeCd|1|String|12|业务类型编码|500100030002|
+|business|datas|1|Object|-|数据节点|不同的服务下的节点不一样|
+|datas|businessOrgInfo|1|Object|-|小区成员|小区成员|
+|businessOrgInfo|orgName|1|String|30|-|-|
+|businessOrgInfo|parentOrgId|1|String|30|-|-|
+|businessOrgInfo|description|1|String|30|-|-|
+|businessOrgInfo|orgLevel|1|String|30|-|-|
+|businessOrgInfo|storeId|1|String|30|-|-|
+|businessOrgInfo|orgId|1|String|30|-|-|
+
+
+###### 返回协议
+
+当http返回状态不为200 时请求处理失败 body内容为失败的原因
+
+当http返回状态为200时请求处理成功,body内容为返回内容,
+
+
+
+
+
+###### 举例
+> 地址:[http://org-service/orgApi/service](http://org-service/orgApi/service)
+
+``` javascript
+请求头信息:
+Content-Type:application/json
+
+请求报文:
+
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "businessType":"I",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": {
+    "businessTypeCd": "140100040001",
+    "bId":"1234567892",
+    "remark": "备注",
+    "datas": {
+      "businessOrgInfo": {
+                "orgName":"填写具体值",
+        "parentOrgId":"填写具体值",
+        "description":"填写具体值",
+        "orgLevel":"填写具体值",
+        "storeId":"填写具体值",
+        "orgId":"填写具体值"
+      }
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }
+}
+
+返回报文:
+ {
+	"orderTypeCd": "D",
+	"response": {
+		"code": "0000",
+		"message": "成功"
+	},
+	"responseTime": "20190418102004",
+	"bId": "202019041810750003",
+	"businessType": "B",
+	"transactionId": "3a5a411ec65a4c3f895935638aa1d2bc",
+	"dataFlowId": "44fde86d39ce46f4b4aab5f6b14f3947"
+}
+
+```

+ 95 - 0
java110-bean/src/main/java/com/java110/dto/org/OrgDto.java

@@ -0,0 +1,95 @@
+package com.java110.dto.org;
+
+import com.java110.dto.PageDto;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @ClassName FloorDto
+ * @Description 组织数据层封装
+ * @Author wuxw
+ * @Date 2019/4/24 8:52
+ * @Version 1.0
+ * add by wuxw 2019/4/24
+ **/
+public class OrgDto extends PageDto implements Serializable {
+
+    private String orgName;
+    private String parentOrgId;
+    private String description;
+    private String orgLevel;
+    private String storeId;
+    private String orgId;
+
+
+    private Date createTime;
+
+    private String statusCd = "0";
+
+
+    public String getOrgName() {
+        return orgName;
+    }
+
+    public void setOrgName(String orgName) {
+        this.orgName = orgName;
+    }
+
+    public String getParentOrgId() {
+        return parentOrgId;
+    }
+
+    public void setParentOrgId(String parentOrgId) {
+        this.parentOrgId = parentOrgId;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getOrgLevel() {
+        return orgLevel;
+    }
+
+    public void setOrgLevel(String orgLevel) {
+        this.orgLevel = orgLevel;
+    }
+
+    public String getStoreId() {
+        return storeId;
+    }
+
+    public void setStoreId(String storeId) {
+        this.storeId = storeId;
+    }
+
+    public String getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(String orgId) {
+        this.orgId = orgId;
+    }
+
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getStatusCd() {
+        return statusCd;
+    }
+
+    public void setStatusCd(String statusCd) {
+        this.statusCd = statusCd;
+    }
+}

+ 82 - 0
java110-code-generator/src/main/java/com/java110/OrgGeneratorApplication.java

@@ -0,0 +1,82 @@
+package com.java110;
+
+
+import com.java110.code.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Hello world!
+ */
+public class OrgGeneratorApplication {
+
+    protected OrgGeneratorApplication() {
+        // prevents calls from subclass
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * 代码生成器 入口方法
+     *  此处生成的mapper文件包含过程表和实例表的sql,所以要求两张表的特殊字段也要写上
+     *   BusinessTypeCd
+     * @param args 参数
+     */
+    public static void main(String[] args) {
+        Data data = new Data();
+        data.setId("orgId");
+        data.setName("org");
+        data.setDesc("组织");
+        data.setShareParam("storeId");
+        data.setShareColumn("store_id");
+        data.setNewBusinessTypeCd("BUSINESS_TYPE_SAVE_ORG");
+        data.setUpdateBusinessTypeCd("BUSINESS_TYPE_UPDATE_ORG");
+        data.setDeleteBusinessTypeCd("BUSINESS_TYPE_DELETE_ORG");
+        data.setNewBusinessTypeCdValue("140100030001");
+        data.setUpdateBusinessTypeCdValue("140100040001");
+        data.setDeleteBusinessTypeCdValue("140100050001");
+        data.setBusinessTableName("business_org");
+        data.setTableName("u_org");
+        Map<String, String> param = new HashMap<String, String>();
+        param.put("orgId", "org_id");       //map的key为你自定义的字段名就是驼峰命名法的那个,value为数据库表的字段名
+        param.put("storeId", "store_id");
+        param.put("orgName", "org_name");
+        param.put("orgLevel", "org_level");
+        param.put("parentOrgId", "parent_org_id");
+        param.put("description", "description");
+        param.put("statusCd", "status_cd");
+        param.put("operate", "operate");
+        param.put("bId", "b_id");
+        data.setParams(param);
+        GeneratorSaveInfoListener generatorSaveInfoListener = new GeneratorSaveInfoListener();
+        generatorSaveInfoListener.generator(data);
+
+        GeneratorAbstractBussiness generatorAbstractBussiness = new GeneratorAbstractBussiness();
+        generatorAbstractBussiness.generator(data);
+
+        GeneratorIServiceDaoListener generatorIServiceDaoListener = new GeneratorIServiceDaoListener();
+        generatorIServiceDaoListener.generator(data);
+
+        GeneratorServiceDaoImplListener generatorServiceDaoImplListener = new GeneratorServiceDaoImplListener();
+        generatorServiceDaoImplListener.generator(data);
+
+        GeneratorServiceDaoImplMapperListener generatorServiceDaoImplMapperListener = null;
+        generatorServiceDaoImplMapperListener = new GeneratorServiceDaoImplMapperListener();
+        generatorServiceDaoImplMapperListener.generator(data);
+
+        GeneratorUpdateInfoListener generatorUpdateInfoListener = new GeneratorUpdateInfoListener();
+        generatorUpdateInfoListener.generator(data);
+
+        GeneratorDeleteInfoListener generatorDeleteInfoListener = new GeneratorDeleteInfoListener();
+        generatorDeleteInfoListener.generator(data);
+
+        GeneratorInnerServiceSMOImpl generatorInnerServiceSMOImpl = new GeneratorInnerServiceSMOImpl();
+        generatorInnerServiceSMOImpl.generator(data);
+
+        GeneratorDtoBean generatorDtoBean = new GeneratorDtoBean();
+        generatorDtoBean.generator(data);
+
+        GeneratorIInnerServiceSMO generatorIInnerServiceSMO = new GeneratorIInnerServiceSMO();
+        generatorIInnerServiceSMO.generator(data);
+    }
+}

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

@@ -94,6 +94,7 @@ public class GenerateCodeFactory {
     public static final String CODE_PREFIX_file_id = "81";
     public static final String CODE_PREFIX_file_id = "81";
     public static final String CODE_PREFIX_repairId = "82";
     public static final String CODE_PREFIX_repairId = "82";
     public static final String CODE_PREFIX_ruId = "83";
     public static final String CODE_PREFIX_ruId = "83";
+    public static final String CODE_PREFIX_orgId = "84";
 
 
 
 
 
 

+ 42 - 0
java110-core/src/main/java/com/java110/core/smo/org/IOrgInnerServiceSMO.java

@@ -0,0 +1,42 @@
+package com.java110.core.smo.org;
+
+import com.java110.core.feign.FeignConfiguration;
+import com.java110.dto.org.OrgDto;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import java.util.List;
+
+/**
+ * @ClassName IOrgInnerServiceSMO
+ * @Description 组织接口类
+ * @Author wuxw
+ * @Date 2019/4/24 9:04
+ * @Version 1.0
+ * add by wuxw 2019/4/24
+ **/
+@FeignClient(name = "user-service", configuration = {FeignConfiguration.class})
+@RequestMapping("/orgApi")
+public interface IOrgInnerServiceSMO {
+
+    /**
+     * <p>查询小区楼信息</p>
+     *
+     *
+     * @param orgDto 数据对象分享
+     * @return OrgDto 对象数据
+     */
+    @RequestMapping(value = "/queryOrgs", method = RequestMethod.POST)
+    List<OrgDto> queryOrgs(@RequestBody OrgDto orgDto);
+
+    /**
+     * 查询<p>小区楼</p>总记录数
+     *
+     * @param orgDto 数据对象分享
+     * @return 小区下的小区楼记录数
+     */
+    @RequestMapping(value = "/queryOrgsCount", method = RequestMethod.POST)
+    int queryOrgsCount(@RequestBody OrgDto orgDto);
+}

+ 186 - 0
java110-db/src/main/resources/mapper/org/OrgServiceDaoImplMapper.xml

@@ -0,0 +1,186 @@
+<?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="orgServiceDaoImpl">
+
+    <!-- 保存组织信息 add by wuxw 2018-07-03 -->
+       <insert id="saveBusinessOrgInfo" parameterType="Map">
+           insert into business_org(
+org_name,operate,parent_org_id,description,org_level,store_id,b_id,org_id
+) values (
+#{orgName},#{operate},#{parentOrgId},#{description},#{orgLevel},#{storeId},#{bId},#{orgId}
+)
+       </insert>
+
+
+       <!-- 查询组织信息(Business) add by wuxw 2018-07-03 -->
+       <select id="getBusinessOrgInfo" parameterType="Map" resultType="Map">
+           select  t.org_name,t.org_name orgName,t.operate,t.parent_org_id,t.parent_org_id parentOrgId,t.description,t.org_level,t.org_level orgLevel,t.store_id,t.store_id storeId,t.b_id,t.b_id bId,t.org_id,t.org_id orgId 
+from business_org t 
+where 1 =1 
+<if test="orgName !=null and orgName != ''">
+   and t.org_name= #{orgName}
+</if> 
+<if test="operate !=null and operate != ''">
+   and t.operate= #{operate}
+</if> 
+<if test="parentOrgId !=null and parentOrgId != ''">
+   and t.parent_org_id= #{parentOrgId}
+</if> 
+<if test="description !=null and description != ''">
+   and t.description= #{description}
+</if> 
+<if test="orgLevel !=null and orgLevel != ''">
+   and t.org_level= #{orgLevel}
+</if> 
+<if test="storeId !=null and storeId != ''">
+   and t.store_id= #{storeId}
+</if> 
+<if test="bId !=null and bId != ''">
+   and t.b_id= #{bId}
+</if> 
+<if test="orgId !=null and orgId != ''">
+   and t.org_id= #{orgId}
+</if> 
+
+       </select>
+
+
+
+
+
+    <!-- 保存组织信息至 instance表中 add by wuxw 2018-07-03 -->
+    <insert id="saveOrgInfoInstance" parameterType="Map">
+        insert into u_org(
+org_name,parent_org_id,description,org_level,status_cd,store_id,b_id,org_id
+) select t.org_name,t.parent_org_id,t.description,t.org_level,'0',t.store_id,t.b_id,t.org_id from business_org t where 1=1
+<if test="orgName !=null and orgName != ''">
+   and t.org_name= #{orgName}
+</if> 
+   and t.operate= 'ADD'
+<if test="parentOrgId !=null and parentOrgId != ''">
+   and t.parent_org_id= #{parentOrgId}
+</if> 
+<if test="description !=null and description != ''">
+   and t.description= #{description}
+</if> 
+<if test="orgLevel !=null and orgLevel != ''">
+   and t.org_level= #{orgLevel}
+</if> 
+<if test="storeId !=null and storeId != ''">
+   and t.store_id= #{storeId}
+</if> 
+<if test="bId !=null and bId != ''">
+   and t.b_id= #{bId}
+</if> 
+<if test="orgId !=null and orgId != ''">
+   and t.org_id= #{orgId}
+</if> 
+
+    </insert>
+
+
+
+    <!-- 查询组织信息 add by wuxw 2018-07-03 -->
+    <select id="getOrgInfo" parameterType="Map" resultType="Map">
+        select  t.org_name,t.org_name orgName,t.parent_org_id,t.parent_org_id parentOrgId,t.description,t.org_level,t.org_level orgLevel,t.status_cd,t.status_cd statusCd,t.store_id,t.store_id storeId,t.b_id,t.b_id bId,t.org_id,t.org_id orgId 
+from u_org t 
+where 1 =1 
+<if test="orgName !=null and orgName != ''">
+   and t.org_name= #{orgName}
+</if> 
+<if test="parentOrgId !=null and parentOrgId != ''">
+   and t.parent_org_id= #{parentOrgId}
+</if> 
+<if test="description !=null and description != ''">
+   and t.description= #{description}
+</if> 
+<if test="orgLevel !=null and orgLevel != ''">
+   and t.org_level= #{orgLevel}
+</if> 
+<if test="statusCd !=null and statusCd != ''">
+   and t.status_cd= #{statusCd}
+</if> 
+<if test="storeId !=null and storeId != ''">
+   and t.store_id= #{storeId}
+</if> 
+<if test="bId !=null and bId != ''">
+   and t.b_id= #{bId}
+</if> 
+<if test="orgId !=null and orgId != ''">
+   and t.org_id= #{orgId}
+</if> 
+<if test="page != -1 and page != null ">
+   limit #{page}, #{row}
+</if> 
+
+    </select>
+
+
+
+
+    <!-- 修改组织信息 add by wuxw 2018-07-03 -->
+    <update id="updateOrgInfoInstance" parameterType="Map">
+        update  u_org t set t.status_cd = #{statusCd}
+<if test="newBId != null and newBId != ''">
+,t.b_id = #{newBId}
+</if> 
+<if test="orgName !=null and orgName != ''">
+, t.org_name= #{orgName}
+</if> 
+<if test="parentOrgId !=null and parentOrgId != ''">
+, t.parent_org_id= #{parentOrgId}
+</if> 
+<if test="description !=null and description != ''">
+, t.description= #{description}
+</if> 
+<if test="orgLevel !=null and orgLevel != ''">
+, t.org_level= #{orgLevel}
+</if> 
+<if test="storeId !=null and storeId != ''">
+, t.store_id= #{storeId}
+</if> 
+ where 1=1 <if test="bId !=null and bId != ''">
+and t.b_id= #{bId}
+</if> 
+<if test="orgId !=null and orgId != ''">
+and t.org_id= #{orgId}
+</if> 
+
+    </update>
+
+    <!-- 查询组织数量 add by wuxw 2018-07-03 -->
+     <select id="queryOrgsCount" parameterType="Map" resultType="Map">
+        select  count(1) count 
+from u_org t 
+where 1 =1 
+<if test="orgName !=null and orgName != ''">
+   and t.org_name= #{orgName}
+</if> 
+<if test="parentOrgId !=null and parentOrgId != ''">
+   and t.parent_org_id= #{parentOrgId}
+</if> 
+<if test="description !=null and description != ''">
+   and t.description= #{description}
+</if> 
+<if test="orgLevel !=null and orgLevel != ''">
+   and t.org_level= #{orgLevel}
+</if> 
+<if test="statusCd !=null and statusCd != ''">
+   and t.status_cd= #{statusCd}
+</if> 
+<if test="storeId !=null and storeId != ''">
+   and t.store_id= #{storeId}
+</if> 
+<if test="bId !=null and bId != ''">
+   and t.b_id= #{bId}
+</if> 
+<if test="orgId !=null and orgId != ''">
+   and t.org_id= #{orgId}
+</if> 
+
+
+     </select>
+
+</mapper>

+ 15 - 0
java110-utils/src/main/java/com/java110/utils/constant/BusinessTypeConstant.java

@@ -481,4 +481,19 @@ public class BusinessTypeConstant {
      */
      */
     public static final String BUSINESS_TYPE_DELETE_REPAIR_USER ="130200050001";
     public static final String BUSINESS_TYPE_DELETE_REPAIR_USER ="130200050001";
 
 
+
+    /**
+     *  保存组织
+     * 11开头  3保存
+     */
+    public static final String BUSINESS_TYPE_SAVE_ORG="140100030001";
+    /**
+     *  修改组织
+     */
+    public static final String BUSINESS_TYPE_UPDATE_ORG="140100040001";
+    /**
+     *  删除组织
+     */
+    public static final String BUSINESS_TYPE_DELETE_ORG ="140100050001";
+
 }
 }