Browse Source

小区单元代码生成成功

吴学文 7 years ago
parent
commit
7501b93d15
30 changed files with 2250 additions and 157 deletions
  1. 66 0
      CommunityService/src/main/java/com/java110/community/dao/IUnitServiceDao.java
  2. 116 0
      CommunityService/src/main/java/com/java110/community/dao/impl/UnitServiceDaoImpl.java
  3. 85 0
      CommunityService/src/main/java/com/java110/community/listener/unit/AbstractUnitBusinessServiceDataFlowListener.java
  4. 180 0
      CommunityService/src/main/java/com/java110/community/listener/unit/DeleteUnitInfoListener.java
  5. 157 0
      CommunityService/src/main/java/com/java110/community/listener/unit/SaveUnitInfoListener.java
  6. 190 0
      CommunityService/src/main/java/com/java110/community/listener/unit/UpdateUnitInfoListener.java
  7. 22 0
      WebService/src/main/resources/components/add-unit/addUnit.html
  8. 132 0
      WebService/src/main/resources/components/add-unit/addUnit.js
  9. 19 0
      WebService/src/main/resources/components/delete-unit/deleteUnit.html
  10. 59 0
      WebService/src/main/resources/components/delete-unit/deleteUnit.js
  11. 1 1
      WebService/src/main/resources/components/floor/listFloor.js
  12. 60 0
      WebService/src/main/resources/components/search-floor/searchFloor.html
  13. 58 0
      WebService/src/main/resources/components/search-floor/searchFloor.js
  14. 61 0
      WebService/src/main/resources/components/unit-select-floor/unitSelectFloor.html
  15. 39 0
      WebService/src/main/resources/components/unit-select-floor/unitSelectFloor.js
  16. 63 0
      WebService/src/main/resources/components/unit/unit.html
  17. 45 0
      WebService/src/main/resources/components/unit/unit.js
  18. 34 0
      WebService/src/main/resources/views/unitFlow.html
  19. 3 0
      docs/_sidebar.md
  20. 114 0
      docs/services/unit/DeleteUnitInfo.md
  21. 124 0
      docs/services/unit/SaveUnitInfo.md
  22. 124 0
      docs/services/unit/UpdateUnitInfo.md
  23. 68 0
      java110-code-generator/src/main/java/com/java110/FloorGeneratorApplication.java
  24. 69 0
      java110-code-generator/src/main/java/com/java110/UnitGeneratorApplication.java
  25. 21 25
      java110-code-generator/src/main/java/com/java110/code/GeneratorSaveInfoListener.java
  26. 137 130
      java110-code-generator/src/main/java/com/java110/code/GeneratorServiceDaoImplMapperListener.java
  27. 17 0
      java110-common/src/main/java/com/java110/common/constant/BusinessTypeConstant.java
  28. 38 1
      java110-config/db/CommunityService/create_room.sql
  29. 147 0
      java110-config/src/main/resources/mapper/unit/UnitServiceDaoImplMapper.xml
  30. 1 0
      java110-core/src/main/java/com/java110/core/factory/GenerateCodeFactory.java

+ 66 - 0
CommunityService/src/main/java/com/java110/community/dao/IUnitServiceDao.java

@@ -0,0 +1,66 @@
+package com.java110.community.dao;
+
+
+import com.java110.common.exception.DAOException;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 小区单元组件内部之间使用,没有给外围系统提供服务能力
+ * 小区单元服务接口类,要求全部以字符串传输,方便微服务化
+ * 新建客户,修改客户,删除客户,查询客户等功能
+ * <p>
+ * Created by wuxw on 2016/12/27.
+ */
+public interface IUnitServiceDao {
+
+    /**
+     * 保存 小区单元信息
+     *
+     * @param businessUnitInfo 小区单元信息 封装
+     * @throws DAOException 操作数据库异常
+     */
+     void saveBusinessUnitInfo(Map businessUnitInfo) throws DAOException;
+
+
+    /**
+     * 查询小区单元信息(business过程)
+     * 根据bId 查询小区单元信息
+     *
+     * @param info bId 信息
+     * @return 小区单元信息
+     * @throws DAOException
+     */
+     List<Map> getBusinessUnitInfo(Map info) throws DAOException;
+
+
+    /**
+     * 保存 小区单元信息 Business数据到 Instance中
+     *
+     * @param info
+     * @throws DAOException
+     */
+     void saveUnitInfoInstance(Map info) throws DAOException;
+
+
+    /**
+     * 查询小区单元信息(instance过程)
+     * 根据bId 查询小区单元信息
+     *
+     * @param info bId 信息
+     * @return 小区单元信息
+     * @throws DAOException
+     */
+     List<Map> getUnitInfo(Map info) throws DAOException;
+
+
+    /**
+     * 修改小区单元信息
+     *
+     * @param info 修改信息
+     * @throws DAOException
+     */
+     void updateUnitInfoInstance(Map info) throws DAOException;
+
+}

+ 116 - 0
CommunityService/src/main/java/com/java110/community/dao/impl/UnitServiceDaoImpl.java

@@ -0,0 +1,116 @@
+package com.java110.community.dao.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.exception.DAOException;
+import com.java110.common.util.DateUtil;
+import com.java110.community.dao.IUnitServiceDao;
+import com.java110.core.base.dao.BaseServiceDao;
+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("unitServiceDaoImpl")
+//@Transactional
+public class UnitServiceDaoImpl extends BaseServiceDao implements IUnitServiceDao {
+
+    private static Logger logger = LoggerFactory.getLogger(UnitServiceDaoImpl.class);
+
+    /**
+     * 小区单元信息封装
+     *
+     * @param businessUnitInfo 小区单元信息 封装
+     * @throws DAOException
+     */
+    @Override
+    public void saveBusinessUnitInfo(Map businessUnitInfo) throws DAOException {
+        businessUnitInfo.put("month", DateUtil.getCurrentMonth());
+        // 查询business_user 数据是否已经存在
+        logger.debug("保存小区单元信息 入参 businessUnitInfo : {}", businessUnitInfo);
+        int saveFlag = sqlSessionTemplate.insert("unitServiceDaoImpl.saveBusinessUnitInfo", businessUnitInfo);
+
+        if (saveFlag < 1) {
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存小区单元数据失败:" + JSONObject.toJSONString(businessUnitInfo));
+        }
+    }
+
+
+    /**
+     * 查询小区单元信息
+     *
+     * @param info bId 信息
+     * @return 小区单元信息
+     * @throws DAOException
+     */
+    @Override
+    public List<Map> getBusinessUnitInfo(Map info) throws DAOException {
+
+        logger.debug("查询小区单元信息 入参 info : {}", info);
+
+        List<Map> businessUnitInfos = sqlSessionTemplate.selectList("unitServiceDaoImpl.getBusinessUnitInfo", info);
+
+        return businessUnitInfos;
+    }
+
+
+    /**
+     * 保存小区单元信息 到 instance
+     *
+     * @param info bId 信息
+     * @throws DAOException
+     */
+    @Override
+    public void saveUnitInfoInstance(Map info) throws DAOException {
+        logger.debug("保存小区单元信息Instance 入参 info : {}", info);
+
+        int saveFlag = sqlSessionTemplate.insert("unitServiceDaoImpl.saveUnitInfoInstance", info);
+
+        if (saveFlag < 1) {
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存小区单元信息Instance数据失败:" + JSONObject.toJSONString(info));
+        }
+    }
+
+
+    /**
+     * 查询小区单元信息(instance)
+     *
+     * @param info bId 信息
+     * @return
+     * @throws DAOException
+     */
+    @Override
+    public List<Map> getUnitInfo(Map info) throws DAOException {
+        logger.debug("查询小区单元信息 入参 info : {}", info);
+
+        List<Map> businessUnitInfos = sqlSessionTemplate.selectList("unitServiceDaoImpl.getUnitInfo", info);
+
+        return businessUnitInfos;
+    }
+
+
+    /**
+     * 修改小区单元信息
+     *
+     * @param info 修改信息
+     * @throws DAOException
+     */
+    @Override
+    public void updateUnitInfoInstance(Map info) throws DAOException {
+        logger.debug("修改小区单元信息Instance 入参 info : {}", info);
+
+        int saveFlag = sqlSessionTemplate.update("unitServiceDaoImpl.updateUnitInfoInstance", info);
+
+        if (saveFlag < 1) {
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "修改小区单元信息Instance数据失败:" + JSONObject.toJSONString(info));
+        }
+    }
+
+
+}

+ 85 - 0
CommunityService/src/main/java/com/java110/community/listener/unit/AbstractUnitBusinessServiceDataFlowListener.java

@@ -0,0 +1,85 @@
+package com.java110.community.listener.unit;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.community.dao.IUnitServiceDao;
+import com.java110.entity.center.Business;
+import com.java110.event.service.AbstractBusinessServiceDataFlowListener;
+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 AbstractUnitBusinessServiceDataFlowListener extends AbstractBusinessServiceDataFlowListener {
+    private static Logger logger = LoggerFactory.getLogger(AbstractUnitBusinessServiceDataFlowListener.class);
+
+
+    /**
+     * 获取 DAO工具类
+     *
+     * @return
+     */
+    public abstract IUnitServiceDao getUnitServiceDaoImpl();
+
+    /**
+     * 刷新 businessUnitInfo 数据
+     * 主要将 数据库 中字段和 接口传递字段建立关系
+     *
+     * @param businessUnitInfo
+     */
+    protected void flushBusinessUnitInfo(Map businessUnitInfo, String statusCd) {
+        businessUnitInfo.put("newBId", businessUnitInfo.get("b_id"));
+        businessUnitInfo.put("operate", businessUnitInfo.get("operate"));
+        businessUnitInfo.put("layerCount", businessUnitInfo.get("layer_count"));
+        businessUnitInfo.put("unitId", businessUnitInfo.get("unit_id"));
+        businessUnitInfo.put("unitNum", businessUnitInfo.get("unit_num"));
+        businessUnitInfo.put("lift", businessUnitInfo.get("lift"));
+        businessUnitInfo.put("remark", businessUnitInfo.get("remark"));
+        businessUnitInfo.put("userId", businessUnitInfo.get("user_id"));
+
+        businessUnitInfo.put("statusCd", statusCd);
+    }
+
+
+    /**
+     * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
+     *
+     * @param businessUnit 小区单元信息
+     */
+    protected void autoSaveDelBusinessUnit(Business business, JSONObject businessUnit) {
+//自动插入DEL
+        Map info = new HashMap();
+        info.put("unitId", businessUnit.getString("unitId"));
+        info.put("statusCd", StatusConstant.STATUS_CD_VALID);
+        List<Map> currentUnitInfos = getUnitServiceDaoImpl().getUnitInfo(info);
+        if (currentUnitInfos == null || currentUnitInfos.size() != 1) {
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "未找到需要修改数据信息,入参错误或数据有问题,请检查" + info);
+        }
+
+        Map currentUnitInfo = currentUnitInfos.get(0);
+
+        currentUnitInfo.put("bId", business.getbId());
+
+        currentUnitInfo.put("operate", currentUnitInfo.get("operate"));
+        currentUnitInfo.put("layerCount", currentUnitInfo.get("layer_count"));
+        currentUnitInfo.put("unitId", currentUnitInfo.get("unit_id"));
+        currentUnitInfo.put("unitNum", currentUnitInfo.get("unit_num"));
+        currentUnitInfo.put("lift", currentUnitInfo.get("lift"));
+        currentUnitInfo.put("remark", currentUnitInfo.get("remark"));
+        currentUnitInfo.put("userId", currentUnitInfo.get("user_id"));
+
+
+        currentUnitInfo.put("operate", StatusConstant.OPERATE_DEL);
+        getUnitServiceDaoImpl().saveBusinessUnitInfo(currentUnitInfo);
+    }
+
+
+}

+ 180 - 0
CommunityService/src/main/java/com/java110/community/listener/unit/DeleteUnitInfoListener.java

@@ -0,0 +1,180 @@
+package com.java110.community.listener.unit;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.BusinessTypeConstant;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.common.util.Assert;
+import com.java110.community.dao.IUnitServiceDao;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+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、businessUnit:{} 小区单元基本信息节点
+ * 2、businessUnitAttr:[{}] 小区单元属性信息节点
+ * 3、businessUnitPhoto:[{}] 小区单元照片信息节点
+ * 4、businessUnitCerdentials:[{}] 小区单元证件信息节点
+ * 协议地址 :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("deleteUnitInfoListener")
+@Transactional
+public class DeleteUnitInfoListener extends AbstractUnitBusinessServiceDataFlowListener {
+
+    private static Logger logger = LoggerFactory.getLogger(DeleteUnitInfoListener.class);
+    @Autowired
+    IUnitServiceDao unitServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 3;
+    }
+
+    @Override
+    public String getBusinessTypeCd() {
+        return BusinessTypeConstant.BUSINESS_TYPE_DELETE_UNIT_INFO;
+    }
+
+    /**
+     * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去
+     *
+     * @param dataFlowContext 数据对象
+     * @param business        当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data, "没有datas 节点,或没有子节点需要处理");
+
+        //处理 businessUnit 节点
+        if (data.containsKey("businessUnit")) {
+            //处理 businessUnit 节点
+            if (data.containsKey("businessUnit")) {
+                Object _obj = data.get("businessUnit");
+                JSONArray businessUnits = null;
+                if (_obj instanceof JSONObject) {
+                    businessUnits = new JSONArray();
+                    businessUnits.add(_obj);
+                } else {
+                    businessUnits = (JSONArray) _obj;
+                }
+                //JSONObject businessUnit = data.getJSONObject("businessUnit");
+                for (int _unitIndex = 0; _unitIndex < businessUnits.size(); _unitIndex++) {
+                    JSONObject businessUnit = businessUnits.getJSONObject(_unitIndex);
+                    doBusinessUnit(business, businessUnit);
+                    if (_obj instanceof JSONObject) {
+                        dataFlowContext.addParamOut("unitId", businessUnit.getString("unitId"));
+                    }
+                }
+            }
+        }
+
+
+    }
+
+    /**
+     * 删除 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> businessUnitInfos = unitServiceDaoImpl.getBusinessUnitInfo(info);
+        if (businessUnitInfos != null && businessUnitInfos.size() > 0) {
+            for (int _unitIndex = 0; _unitIndex < businessUnitInfos.size(); _unitIndex++) {
+                Map businessUnitInfo = businessUnitInfos.get(_unitIndex);
+                flushBusinessUnitInfo(businessUnitInfo, StatusConstant.STATUS_CD_INVALID);
+                unitServiceDaoImpl.updateUnitInfoInstance(businessUnitInfo);
+                dataFlowContext.addParamOut("unitId", businessUnitInfo.get("unit_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> unitInfo = unitServiceDaoImpl.getUnitInfo(info);
+        if (unitInfo != null && unitInfo.size() > 0) {
+
+            //小区单元信息
+            List<Map> businessUnitInfos = unitServiceDaoImpl.getBusinessUnitInfo(delInfo);
+            //除非程序出错了,这里不会为空
+            if (businessUnitInfos == null || businessUnitInfos.size() == 0) {
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR, "撤单失败(unit),程序内部异常,请检查! " + delInfo);
+            }
+            for (int _unitIndex = 0; _unitIndex < businessUnitInfos.size(); _unitIndex++) {
+                Map businessUnitInfo = businessUnitInfos.get(_unitIndex);
+                flushBusinessUnitInfo(businessUnitInfo, StatusConstant.STATUS_CD_VALID);
+                unitServiceDaoImpl.updateUnitInfoInstance(businessUnitInfo);
+            }
+        }
+    }
+
+
+    /**
+     * 处理 businessUnit 节点
+     *
+     * @param business     总的数据节点
+     * @param businessUnit 小区单元节点
+     */
+    private void doBusinessUnit(Business business, JSONObject businessUnit) {
+
+        Assert.jsonObjectHaveKey(businessUnit, "unitId", "businessUnit 节点下没有包含 unitId 节点");
+
+        if (businessUnit.getString("unitId").startsWith("-")) {
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "unitId 错误,不能自动生成(必须已经存在的unitId)" + businessUnit);
+        }
+        //自动插入DEL
+        autoSaveDelBusinessUnit(business, businessUnit);
+    }
+
+    public IUnitServiceDao getUnitServiceDaoImpl() {
+        return unitServiceDaoImpl;
+    }
+
+    public void setUnitServiceDaoImpl(IUnitServiceDao unitServiceDaoImpl) {
+        this.unitServiceDaoImpl = unitServiceDaoImpl;
+    }
+}

+ 157 - 0
CommunityService/src/main/java/com/java110/community/listener/unit/SaveUnitInfoListener.java

@@ -0,0 +1,157 @@
+package com.java110.community.listener.unit;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.BusinessTypeConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.util.Assert;
+import com.java110.community.dao.IUnitServiceDao;
+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 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("saveUnitInfoListener")
+@Transactional
+public class SaveUnitInfoListener extends AbstractUnitBusinessServiceDataFlowListener {
+
+    private static Logger logger = LoggerFactory.getLogger(SaveUnitInfoListener.class);
+
+    @Autowired
+    IUnitServiceDao unitServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 0;
+    }
+
+    @Override
+    public String getBusinessTypeCd() {
+        return BusinessTypeConstant.BUSINESS_TYPE_SAVE_UNIT_INFO;
+    }
+
+    /**
+     * 保存小区单元信息 business 表中
+     *
+     * @param dataFlowContext 数据对象
+     * @param business        当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+        Assert.notEmpty(data, "没有datas 节点,或没有子节点需要处理");
+
+        //处理 businessUnit 节点
+        if (data.containsKey("businessUnit")) {
+            Object _obj = data.get("businessUnit");
+            JSONArray businessUnits = null;
+            if (_obj instanceof JSONObject) {
+                businessUnits = new JSONArray();
+                businessUnits.add(_obj);
+            } else {
+                businessUnits = (JSONArray) _obj;
+            }
+            //JSONObject businessUnit = data.getJSONObject("businessUnit");
+            for (int _unitIndex = 0; _unitIndex < businessUnits.size(); _unitIndex++) {
+                JSONObject businessUnit = businessUnits.getJSONObject(_unitIndex);
+                doBusinessUnit(business, businessUnit);
+                if (_obj instanceof JSONObject) {
+                    dataFlowContext.addParamOut("unitId", businessUnit.getString("unitId"));
+                }
+            }
+        }
+    }
+
+    /**
+     * 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> businessUnitInfo = unitServiceDaoImpl.getBusinessUnitInfo(info);
+        if (businessUnitInfo != null && businessUnitInfo.size() > 0) {
+            unitServiceDaoImpl.saveUnitInfoInstance(info);
+            if (businessUnitInfo.size() == 1) {
+                dataFlowContext.addParamOut("unitId", businessUnitInfo.get(0).get("unit_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> unitInfo = unitServiceDaoImpl.getUnitInfo(info);
+        if (unitInfo != null && unitInfo.size() > 0) {
+            unitServiceDaoImpl.updateUnitInfoInstance(paramIn);
+        }
+    }
+
+
+    /**
+     * 处理 businessUnit 节点
+     *
+     * @param business     总的数据节点
+     * @param businessUnit 小区单元节点
+     */
+    private void doBusinessUnit(Business business, JSONObject businessUnit) {
+
+        Assert.jsonObjectHaveKey(businessUnit, "unitId", "businessUnit 节点下没有包含 unitId 节点");
+
+        if (businessUnit.getString("unitId").startsWith("-")) {
+            //刷新缓存
+            //flushUnitId(business.getDatas());
+
+            businessUnit.put("unitId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_unitId));
+
+        }
+
+        businessUnit.put("bId", business.getbId());
+        businessUnit.put("operate", StatusConstant.OPERATE_ADD);
+        //保存小区单元信息
+        unitServiceDaoImpl.saveBusinessUnitInfo(businessUnit);
+
+    }
+
+    public IUnitServiceDao getUnitServiceDaoImpl() {
+        return unitServiceDaoImpl;
+    }
+
+    public void setUnitServiceDaoImpl(IUnitServiceDao unitServiceDaoImpl) {
+        this.unitServiceDaoImpl = unitServiceDaoImpl;
+    }
+}

+ 190 - 0
CommunityService/src/main/java/com/java110/community/listener/unit/UpdateUnitInfoListener.java

@@ -0,0 +1,190 @@
+package com.java110.community.listener.unit;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.BusinessTypeConstant;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.common.util.Assert;
+import com.java110.community.dao.IUnitServiceDao;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+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、businessUnit:{} 小区单元基本信息节点
+ * 2、businessUnitAttr:[{}] 小区单元属性信息节点
+ * 3、businessUnitPhoto:[{}] 小区单元照片信息节点
+ * 4、businessUnitCerdentials:[{}] 小区单元证件信息节点
+ * 协议地址 :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("updateUnitInfoListener")
+@Transactional
+public class UpdateUnitInfoListener extends AbstractUnitBusinessServiceDataFlowListener {
+
+    private static Logger logger = LoggerFactory.getLogger(UpdateUnitInfoListener.class);
+    @Autowired
+    IUnitServiceDao unitServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 2;
+    }
+
+    @Override
+    public String getBusinessTypeCd() {
+        return BusinessTypeConstant.BUSINESS_TYPE_UPDATE_UNIT_INFO;
+    }
+
+    /**
+     * business过程
+     *
+     * @param dataFlowContext
+     * @param business
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data, "没有datas 节点,或没有子节点需要处理");
+
+        //处理 businessUnit 节点
+        if (data.containsKey("businessUnit")) {
+            //处理 businessUnit 节点
+            if (data.containsKey("businessUnit")) {
+                Object _obj = data.get("businessUnit");
+                JSONArray businessUnits = null;
+                if (_obj instanceof JSONObject) {
+                    businessUnits = new JSONArray();
+                    businessUnits.add(_obj);
+                } else {
+                    businessUnits = (JSONArray) _obj;
+                }
+                //JSONObject businessUnit = data.getJSONObject("businessUnit");
+                for (int _unitIndex = 0; _unitIndex < businessUnits.size(); _unitIndex++) {
+                    JSONObject businessUnit = businessUnits.getJSONObject(_unitIndex);
+                    doBusinessUnit(business, businessUnit);
+                    if (_obj instanceof JSONObject) {
+                        dataFlowContext.addParamOut("unitId", businessUnit.getString("unitId"));
+                    }
+                }
+            }
+        }
+    }
+
+
+    /**
+     * 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> businessUnitInfos = unitServiceDaoImpl.getBusinessUnitInfo(info);
+        if (businessUnitInfos != null && businessUnitInfos.size() > 0) {
+            for (int _unitIndex = 0; _unitIndex < businessUnitInfos.size(); _unitIndex++) {
+                Map businessUnitInfo = businessUnitInfos.get(_unitIndex);
+                flushBusinessUnitInfo(businessUnitInfo, StatusConstant.STATUS_CD_VALID);
+                unitServiceDaoImpl.updateUnitInfoInstance(businessUnitInfo);
+                if (businessUnitInfo.size() == 1) {
+                    dataFlowContext.addParamOut("unitId", businessUnitInfo.get("unit_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> unitInfo = unitServiceDaoImpl.getUnitInfo(info);
+        if (unitInfo != null && unitInfo.size() > 0) {
+
+            //小区单元信息
+            List<Map> businessUnitInfos = unitServiceDaoImpl.getBusinessUnitInfo(delInfo);
+            //除非程序出错了,这里不会为空
+            if (businessUnitInfos == null || businessUnitInfos.size() == 0) {
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR, "撤单失败(unit),程序内部异常,请检查! " + delInfo);
+            }
+            for (int _unitIndex = 0; _unitIndex < businessUnitInfos.size(); _unitIndex++) {
+                Map businessUnitInfo = businessUnitInfos.get(_unitIndex);
+                flushBusinessUnitInfo(businessUnitInfo, StatusConstant.STATUS_CD_VALID);
+                unitServiceDaoImpl.updateUnitInfoInstance(businessUnitInfo);
+            }
+        }
+
+    }
+
+
+    /**
+     * 处理 businessUnit 节点
+     *
+     * @param business     总的数据节点
+     * @param businessUnit 小区单元节点
+     */
+    private void doBusinessUnit(Business business, JSONObject businessUnit) {
+
+        Assert.jsonObjectHaveKey(businessUnit, "unitId", "businessUnit 节点下没有包含 unitId 节点");
+
+        if (businessUnit.getString("unitId").startsWith("-")) {
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "unitId 错误,不能自动生成(必须已经存在的unitId)" + businessUnit);
+        }
+        //自动保存DEL
+        autoSaveDelBusinessUnit(business, businessUnit);
+
+        businessUnit.put("bId", business.getbId());
+        businessUnit.put("operate", StatusConstant.OPERATE_ADD);
+        //保存小区单元信息
+        unitServiceDaoImpl.saveBusinessUnitInfo(businessUnit);
+
+    }
+
+
+    public IUnitServiceDao getUnitServiceDaoImpl() {
+        return unitServiceDaoImpl;
+    }
+
+    public void setUnitServiceDaoImpl(IUnitServiceDao unitServiceDaoImpl) {
+        this.unitServiceDaoImpl = unitServiceDaoImpl;
+    }
+
+
+}

+ 22 - 0
WebService/src/main/resources/components/add-unit/addUnit.html

@@ -0,0 +1,22 @@
+<div id = "addUnitModel" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="addPrivilegeModalLabel" aria-hidden="true" >
+    <div class="modal-dialog modal-lg">
+        <div class="modal-content">
+            <div class="modal-body">
+                <div class=" row">
+                    <div class="col-lg-12">
+                        <div class="ibox ">
+                                <div class="table-responsive"
+                                     style="margin-top:15px">
+
+                                </div>
+
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
+            </div>
+        </div>
+    </div>
+</div>

+ 132 - 0
WebService/src/main/resources/components/add-unit/addUnit.js

@@ -0,0 +1,132 @@
+(function(vc,vm){
+
+    vc.extends({
+        data:{
+            addUnitInfo:{
+                _currentUserId:'',
+                name:'',
+                description:'',
+                errorInfo:'',
+                _noAddPrivilege:[],
+                _noAddPrivilegeGroup:[],
+                _currentTab:1
+            }
+        },
+         _initMethod:function(){
+
+         },
+         _initEvent:function(){
+             vc.on('addUnit','addUnitModel',function(_params){
+                $('#addUnitModel').modal('show');
+                vc.component._refreshData(_params);
+            });
+        },
+        methods:{
+            _refreshData:function(_params){
+                vc.component.addUnitInfo._currentUserId = _params.userId;
+                vc.component.addUnitInfo._currentTab = 1;
+                vc.component.listNoAddPrivilegeGroup();
+            },
+            changeTab:function(_tempTab){
+                vc.component.addUnitInfo._currentTab= _tempTab;
+                if(_tempTab == 2){
+                    vc.component.listNoAddPrivilege();
+                    return ;
+                }
+                vc.component.listNoAddPrivilegeGroup();
+            },
+            listNoAddPrivilegeGroup:function(){
+                vc.component.addUnitInfo._noAddPrivilegeGroup = [];
+                var param = {
+                    params:{
+                        userId:vc.component.addUnitInfo._currentUserId
+                    }
+                };
+                vc.http.get(
+                    'addUnit',
+                    'listNoAddPrivilegeGroup',
+                     param,
+                     function(json,res){
+                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
+                        if(res.status == 200){
+                            vc.component.addUnitInfo._noAddPrivilegeGroup = JSON.parse(json);
+                            return ;
+                        }
+                        vc.component.addUnitInfo.errorInfo = json;
+                     },
+                     function(errInfo,error){
+                        console.log('请求失败处理');
+
+                        vc.component.addUnitInfo.errorInfo = errInfo;
+                });
+
+            },
+            listNoAddPrivilege:function(){
+                vc.component.addUnitInfo._noAddPrivilege=[];
+                var param = {
+                    params:{
+                        userId:vc.component.addUnitInfo._currentUserId
+                    }
+                }
+                vc.http.get(
+                            'addUnit',
+                            'listNoAddPrivilege',
+                             param,
+                             function(json,res){
+                                //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
+                                if(res.status == 200){
+                                    vc.component.addUnitInfo._noAddPrivilege = JSON.parse(json);
+                                    return ;
+                                }
+                                vc.component.addUnitInfo.errorInfo = json;
+                             },
+                             function(errInfo,error){
+                                console.log('请求失败处理');
+
+                                vc.component.addUnitInfo.errorInfo = errInfo;
+                             });
+            },
+            addUnit:function(_pId,_privilegeFlag){
+                vc.component.addUnitInfo.errorInfo = "";
+                var param = {
+                    userId:vc.component.addUnitInfo._currentUserId,
+                    pId:_pId,
+                    pFlag:_privilegeFlag
+                };
+                vc.http.post(
+                    'addUnit',
+                    'addUnitOrPrivilegeGroup',
+                    JSON.stringify(param),
+                    {
+                        emulateJSON:true
+                     },
+                     function(json,res){
+                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
+                        if(res.status == 200){
+                            //关闭model
+                            $('#addUnitModel').modal('hide');
+                            vc.emit('staffPrivilege','_loadUnits',{
+                                staffId:vc.component.addUnitInfo._currentUserId
+                            });
+                            return ;
+                        }
+                        vc.component.addUnitInfo.errorInfo = json;
+                     },
+                     function(errInfo,error){
+                        console.log('请求失败处理');
+
+                        vc.component.addUnitInfo.errorInfo = errInfo;
+                     });
+            },
+            userAddPrivilegeGroup:function(_pgId){
+                console.log("需要添加权限:",_pgId);
+                vc.component.addUnit(_pgId,1)
+            },
+            userAddPrivilege:function(_pId){
+                console.log("需要添加权限:",_pId);
+                vc.component.addUnit(_pId,2)
+            }
+        }
+    });
+
+})(window.vc,window.vc.component);

+ 19 - 0
WebService/src/main/resources/components/delete-unit/deleteUnit.html

@@ -0,0 +1,19 @@
+<div class="modal fade" id="deleteUnitModel" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title" id="exampleModalLabel">请确认您的操作!</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <tr align="center"><th>确定删除小区单元</th></tr>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary" data-dismiss="modal" v-on:click="closeDeleteUnitModel()">点错了</button>
+                <button type="button" class="btn btn-primary" v-on:click="deleteUnit()">确认删除</button>
+            </div>
+        </div>
+    </div>
+</div>

+ 59 - 0
WebService/src/main/resources/components/delete-unit/deleteUnit.js

@@ -0,0 +1,59 @@
+(function(vc,vm){
+
+    vc.extends({
+        data:{
+            deleteUnitInfo:{
+                _currentFloorId:'',
+                _currentUnitId:''
+            }
+        },
+         _initMethod:function(){
+
+         },
+         _initEvent:function(){
+             vc.on('deleteUnit','openUnitModel',function(_params){
+
+                vc.component.deleteUnitInfo._currentFloorId = _params.floorId;
+                vc.component.deleteUnitInfo._currentUnitId = _params.unitId;
+                $('#deleteUnitModel').modal('show');
+
+            });
+        },
+        methods:{
+            deleteUnit:function(){
+                var param = {
+                    userId:vc.component.deleteUnitInfo._currentFloorId,
+                    pId:vc.component.deleteUnitInfo._currentUnitId
+                }
+                vc.http.post(
+                    'deleteUnit',
+                    'delete',
+                    JSON.stringify(param),
+                    {
+                        emulateJSON:true
+                     },
+                     function(json,res){
+                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
+                        if(res.status == 200){
+                            //关闭model
+                            $('#deleteUnitModel').modal('hide');
+                            vc.emit('unit','loadUnit',{
+                                unitId:vc.component.deleteUnitInfo._currentUnitId
+                            });
+                            return ;
+                        }
+                        vc.message(json);
+                     },
+                     function(errInfo,error){
+                        console.log('请求失败处理');
+                        vc.message(json);
+
+                     });
+            },
+            closeDeleteUnitModel:function(){
+                $('#deleteUnitModel').modal('hide');
+            }
+        }
+    });
+
+})(window.vc,window.vc.component);

+ 1 - 1
WebService/src/main/resources/components/floor/listFloor.js

@@ -1,6 +1,6 @@
 (function(vc){
     var DEFAULT_PAGE = 1;
-    var DEFAULT_ROWS = 15;
+    var DEFAULT_ROWS = 10;
     vc.extends({
         data:{
             listFloorInfo:{

+ 60 - 0
WebService/src/main/resources/components/search-floor/searchFloor.html

@@ -0,0 +1,60 @@
+<div id = "searchFloorModel" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="searchFloorModelLabel" aria-hidden="true" >
+    <div class="modal-dialog modal-lg">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h3 class="modal-title" id="searchFloorModelLabel">小区楼</h3>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <div class=" row">
+                    <div class="col-lg-12">
+                        <div class="ibox ">
+                            <div class="row">
+
+                                <div class="col-sm-7 m-b-xs">
+
+                                </div>
+                                <div class="col-sm-5">
+                                    <div class="input-group">
+                                        <input placeholder="输入小区楼编号" type="text" v-model="searchFloorInfo._currentFloorNum" class="form-control form-control-sm">
+                                        <span class="input-group-append">
+                                                <button type="button" class="btn btn-sm btn-primary" v-on:click="searchFloors()">查询</button>
+                                            </span>
+                                    </div>
+                                </div>
+                            </div>
+                            <div class="table-responsive" style="margin-top:15px">
+                                <table class="table table-striped">
+                                    <thead>
+                                    <tr>
+                                        <th>员工编码</th>
+                                        <th>员工名称</th>
+                                        <th>手机号</th>
+                                        <th>性别</th>
+                                        <th>创建时间</th>
+                                        <th>操作</th>
+                                    </tr>
+                                    </thead>
+                                    <tbody>
+                                    <tr v-for="floor in searchFloorInfo.floors">
+                                        <td>{{floor.userId}}</td>
+                                        <td>{{floor.name}}</td>
+                                        <td>{{floor.tel}}</td>
+                                        <td>{{floor.sex == 0 ? '男' : (staff.sex == 1 ?'女':'')}}</td>
+                                        <td>{{vc.dateFormat(floor.createTime)}}</td>
+                                        <td>
+                                            <button class="btn btn-primary btn-xs" v-on:click="chooseFloor(floor)">选择</button>
+                                        </td>
+                                    </tr>
+                                    </tbody>
+                                </table>
+                            </div>
+
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>

+ 58 - 0
WebService/src/main/resources/components/search-floor/searchFloor.js

@@ -0,0 +1,58 @@
+(function(vc){
+    vc.extends({
+        data:{
+            searchFloorInfo:{
+                floors:[],
+                _currentFloorNum:'',
+            }
+        },
+        _initMethod:function(){
+
+        },
+        _initEvent:function(){
+            vc.on('searchFloor','openSearchFloorModel',function(_param){
+                console.log("打开定位员工界面")
+                $('#searchFloorModel').modal('show');
+                vc.component._refreshSearchFloorData();
+                vc.component._loadAllFloorInfo(1,10);
+            });
+        },
+        methods:{
+            _loadAllFloorInfo:function(_page,_rows,_staffName){
+                var param = {
+                    params:{
+                        page:_page,
+                        rows:_rows,
+                        staffName:_staffName
+                    }
+                };
+
+                //发送get请求
+               vc.http.get('searchFloor',
+                            'listFloor',
+                             param,
+                             function(json){
+                                var _floorInfo = JSON.parse(json);
+                                vc.component.searchFloorInfo.floors = _floorInfo.datas;
+                             },function(){
+                                console.log('请求失败处理');
+                             }
+                           );
+            },
+            chooseStaff:function(_floor){
+                vc.emit('floorInfo','chooseFloor',_floor);
+                vc.emit('unit','_loadUnits',{
+                    floorId:_floor.floorId
+                });
+                $('#searchFloorModel').modal('hide');
+            },
+            searchFloors:function(){
+                vc.component._loadAllFloorInfo(1,10,vc.component.searchFloorInfo._currentFloorNum);
+            },
+            _refreshSearchFloorData:function(){
+                vc.component.searchFloorInfo._currentFloorName = "";
+            }
+        }
+
+    });
+})(window.vc);

+ 61 - 0
WebService/src/main/resources/components/unit-select-floor/unitSelectFloor.html

@@ -0,0 +1,61 @@
+<div class="row">
+    <div class="col-lg-12">
+        <div class="ibox ">
+            <div class="ibox-title">
+                <h5>小区楼信息</h5>
+                <div class="ibox-tools" style="top:10px;">
+                    <button type="button" class="btn btn-primary btn-sm" v-on:click="openSearchFloorModel()">
+                        <i class="glyphicon glyphicon-search"></i> 选择小区楼</button>
+                    <button type="button" class="btn btn-primary btn-sm"
+                            v-if="floorInfo.floorId != null && floorInfo.floorId != ''"
+                            style="margin-left:10px" v-on:click="openAddUnitModel()">
+                        <i class="glyphicon glyphicon-plus" ></i> 添加单元</button>
+                </div>
+            </div>
+            <div class="ibox-content">
+                <div class="row">
+                    <div class="col-sm-3">
+                        <div class="form-group">
+                            <label class="col-form-label" >员工ID:</label>
+                            <label class="">{{floorInfo.floorId}}</label>
+                        </div>
+                    </div>
+                    <div class="col-sm-3">
+                        <div class="form-group">
+                            <label class="col-form-label">员工名称:</label>
+                            <label class="">{{floorInfo.name}}</label>
+                        </div>
+                    </div>
+                    <div class="col-sm-3">
+                        <div class="form-group">
+                            <label class="col-form-label" >手机号:</label>
+                            <label class="">{{floorInfo.tel}}</label>
+                        </div>
+                    </div>
+                    <div class="col-sm-3">
+                        <div class="form-group">
+                            <label class="col-form-label" >邮箱:</label>
+                            <label class="">{{floorInfo.email}}</label>
+                        </div>
+                    </div>
+                </div>
+                <div class="row">
+                    <div class="col-sm-3">
+                        <div class="form-group">
+                            <label class="col-form-label" >性别:</label>
+                            <label class="">{{floorInfo.sex == 0 ? '男' : (floorInfo.sex == 1 ?'女':'')}}</label>
+                        </div>
+                    </div>
+                    <div class="col-sm-9">
+                        <div class="form-group">
+                            <label class="col-form-label">地址:</label>
+                            <label class="">{{floorInfo.address}}</label>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+    <vc:create name="searchFloor"></vc:create>
+    <vc:create name="addUnit"></vc:create>
+</div>

+ 39 - 0
WebService/src/main/resources/components/unit-select-floor/unitSelectFloor.js

@@ -0,0 +1,39 @@
+/**
+    权限组
+**/
+(function(vc){
+
+    vc.extends({
+        data:{
+            floorInfo:{
+                floorId:"",
+                name:"",
+                tel:"",
+                email:"",
+                sex:"",
+                address:"",
+            }
+        },
+        _initMethod:function(){
+
+        },
+        _initEvent:function(){
+            vc.on('unitSelectFloor','chooseFloor',function(_floor){
+                vc.component.floorInfo = _floor;
+            });
+
+        },
+        methods:{
+
+            openSearchFloorModel(){
+                vc.emit('searchFloor','openSearchFloorModel',{});
+            },
+            openAddUnitModel(){
+                vc.emit('addUnit','addUnitModel',{
+                    floorId:vc.component.floorInfo.floorId
+                });
+            }
+        }
+    });
+
+})(window.vc);

+ 63 - 0
WebService/src/main/resources/components/unit/unit.html

@@ -0,0 +1,63 @@
+<div id="component" class="wrapper wrapper-content animated fadeInRight ecommerce">
+    <vc:create name="unitSelectFloor"></vc:create>
+    <div class="row">
+        <div class="col-lg-12">
+            <div class="ibox">
+                <div class="ibox-content">
+
+                    <table class="footable table table-stripped toggle-arrow-tiny" data-page-size="15">
+                        <thead>
+                        <tr>
+                            <th>权限ID</th>
+                            <th data-hide="phone">权限名称</th>
+                            <th data-hide="phone">权限描述</th>
+                            <th data-hide="phone">隶属权限组ID</th>
+                            <th data-hide="phone,tablet" >隶属权限组名称</th>
+                            <th data-hide="phone">状态</th>
+                            <th class="text-right">操作</th>
+
+                        </tr>
+                        </thead>
+                        <tbody>
+                        <tr v-for="unit in unitInfo.units">
+                            <td>
+                                {{unit.pId}}
+                            </td>
+                            <td>
+                                {{unit.name}}
+                            </td>
+                            <td>
+                                {{unit.description}}
+                            </td>
+                            <td>
+                                {{unit.pgId}}
+                            </td>
+                            <td>
+                                {{unit.pgName}}
+                            </td>
+                            <td>
+                                <span class="label label-primary">在用</span>
+                            </td>
+                            <td      class="text-right">
+                                <div class="btn-group">
+                                    <button class="btn-white btn btn-xs" v-on:click="_openDeleteUnitModel(unit)">删除</button>
+                                </div>
+                            </td>
+                        </tr>
+                        </tbody>
+                        <tfoot>
+                        <tr>
+                            <td colspan="7">
+                                <ul class="pagination float-right"></ul>
+                            </td>
+                        </tr>
+                        </tfoot>
+                    </table>
+
+                </div>
+            </div>
+        </div>
+    </div>
+    <!-- 删除员工权限 -->
+    <vc:create name="deleteUnit"></vc:create>
+</div>

+ 45 - 0
WebService/src/main/resources/components/unit/unit.js

@@ -0,0 +1,45 @@
+(function(vc){
+    //员工权限
+    vc.extends({
+        data:{
+            unitInfo:{
+                units:[],
+                _currentFloorId:'',
+            }
+        },
+        _initMethod:function(){
+
+        },
+        _initEvent:function(){
+            vc.on('unit','loadUnit',function(_param){
+                vc.component._loadUnits(_param);
+            });
+        },
+        methods:{
+            _loadUnits:function(_param){
+                vc.component.staffPrivilegeInfo._currentFloorId=_param.floorId;
+                var param = {
+                    params:{
+                        floorId:_param.floorId
+                    }
+                };
+             //发送get请求
+            vc.http.get('unit',
+                         'loadUnit',
+                          param,
+                          function(json){
+                             var _unitInfo = JSON.parse(json);
+                             vc.component.unitInfo.units = _unitInfo.datas;
+
+                          },function(){
+                             console.log('请求失败处理');
+                          });
+            },
+            _openDeleteUnitModel:function(_unit){
+                _unit.floorId = vc.component.unitInfo._currentFloorId;
+                vc.emit('deleteUnit','openUnitModel',_unit);
+            }
+        }
+    });
+
+})(window.vc);

+ 34 - 0
WebService/src/main/resources/views/unitFlow.html

@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html lang="en"
+      xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:th="http://www.thymeleaf.org"
+      xmlns:vc="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8"/>
+    <title>员工权限|java110</title>
+    <vc:create name="commonTop"></vc:create>
+</head>
+<body>
+<vc:create name="bodyTop"></vc:create>
+<div id="wrapper">
+    <vc:create name="menu"></vc:create>
+
+
+    <div id="page-wrapper" class="gray-bg dashbard-1">
+        <div class="row border-bottom">
+            <vc:create name="nav"></vc:create>
+        </div>
+        <!-- id="component" -->
+        <div  class="wrapper wrapper-content animated fadeInRight">
+            <vc:create name="staffPrivilege"></vc:create>
+        </div>
+
+
+        <vc:create name="copyright"></vc:create>
+
+    </div>
+</div>
+
+<vc:create name="commonBottom"></vc:create>
+</body>
+</html>

+ 3 - 0
docs/_sidebar.md

@@ -43,6 +43,9 @@
   * [保存小区楼](services/floor/SaveFloorInfo.md)
   * [修改小区楼](services/floor/UpdateFloorInfo.md)
   * [删除小区楼](services/floor/DeleteFloorInfo.md)
+  * [保存小区单元](services/floor/SaveUnitInfo.md)
+  * [修改小区单元](services/floor/UpdateUnitInfo.md)
+  * [删除小区单元](services/floor/DeleteUnitInfo.md)
 
 * 工具类接口
 

+ 114 - 0
docs/services/unit/DeleteUnitInfo.md

@@ -0,0 +1,114 @@
+
+
+**1\. 删除小区单元**
+###### 接口功能
+> API服务做删除小区单元时调用该接口
+
+###### URL
+> [http://community-service/unitApi/service](http://community-service/unitApi/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|businessUnitInfo|1|Object|-|小区成员|小区成员|
+|businessUnitInfo|unitId|1|String|30|-|-|
+
+
+###### 返回协议
+
+当http返回状态不为200 时请求处理失败 body内容为失败的原因
+
+当http返回状态为200时请求处理成功,body内容为返回内容,
+
+
+
+
+
+###### 举例
+> 地址:[http://community-service/unitApi/service](http://community-service/unitApi/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": "520100050001",
+    "bId":"1234567892",
+    "remark": "备注",
+    "datas": {
+      "businessUnitInfo": {
+                "unitId":"填写存在的值"
+      }
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }
+}
+
+返回报文:
+ {
+	"orderTypeCd": "D",
+	"response": {
+		"code": "0000",
+		"message": "成功"
+	},
+	"responseTime": "20190418102004",
+	"bId": "202019041810750003",
+	"businessType": "B",
+	"transactionId": "3a5a411ec65a4c3f895935638aa1d2bc",
+	"dataFlowId": "44fde86d39ce46f4b4aab5f6b14f3947"
+}
+
+```

+ 124 - 0
docs/services/unit/SaveUnitInfo.md

@@ -0,0 +1,124 @@
+
+
+**1\. 保存小区单元**
+###### 接口功能
+> API服务做保存小区单元时调用该接口
+
+###### URL
+> [http://community-service/unitApi/service](http://community-service/unitApi/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|businessUnitInfo|1|Object|-|小区成员|小区成员|
+|businessUnitInfo|layerCount|1|String|30|-|-|
+|businessUnitInfo|unitId|1|String|30|-|-|
+|businessUnitInfo|unitNum|1|String|30|-|-|
+|businessUnitInfo|lift|1|String|30|-|-|
+|businessUnitInfo|remark|1|String|30|-|-|
+|businessUnitInfo|userId|1|String|30|-|-|
+
+
+###### 返回协议
+
+当http返回状态不为200 时请求处理失败 body内容为失败的原因
+
+当http返回状态为200时请求处理成功,body内容为返回内容,
+
+
+
+
+
+###### 举例
+> 地址:[http://community-service/unitApi/service](http://community-service/unitApi/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": "520100030001",
+    "bId":"1234567892",
+    "remark": "备注",
+    "datas": {
+      "businessUnitInfo": {
+                "layerCount":"填写具体值",
+        "unitId":"填写具体值",
+        "unitNum":"填写具体值",
+        "lift":"填写具体值",
+        "remark":"填写具体值",
+        "userId":"填写具体值"
+      }
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }
+}
+
+返回报文:
+ {
+	"orderTypeCd": "D",
+	"response": {
+		"code": "0000",
+		"message": "成功"
+	},
+	"responseTime": "20190418102004",
+	"bId": "202019041810750003",
+	"businessType": "B",
+	"transactionId": "3a5a411ec65a4c3f895935638aa1d2bc",
+	"dataFlowId": "44fde86d39ce46f4b4aab5f6b14f3947"
+}
+
+```

+ 124 - 0
docs/services/unit/UpdateUnitInfo.md

@@ -0,0 +1,124 @@
+
+
+**1\. 修改小区单元**
+###### 接口功能
+> API服务做修改小区单元时调用该接口
+
+###### URL
+> [http://community-service/unitApi/service](http://community-service/unitApi/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|businessUnitInfo|1|Object|-|小区成员|小区成员|
+|businessUnitInfo|layerCount|1|String|30|-|-|
+|businessUnitInfo|unitId|1|String|30|-|-|
+|businessUnitInfo|unitNum|1|String|30|-|-|
+|businessUnitInfo|lift|1|String|30|-|-|
+|businessUnitInfo|remark|1|String|30|-|-|
+|businessUnitInfo|userId|1|String|30|-|-|
+
+
+###### 返回协议
+
+当http返回状态不为200 时请求处理失败 body内容为失败的原因
+
+当http返回状态为200时请求处理成功,body内容为返回内容,
+
+
+
+
+
+###### 举例
+> 地址:[http://community-service/unitApi/service](http://community-service/unitApi/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": "520100040001",
+    "bId":"1234567892",
+    "remark": "备注",
+    "datas": {
+      "businessUnitInfo": {
+                "layerCount":"填写具体值",
+        "unitId":"填写具体值",
+        "unitNum":"填写具体值",
+        "lift":"填写具体值",
+        "remark":"填写具体值",
+        "userId":"填写具体值"
+      }
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }
+}
+
+返回报文:
+ {
+	"orderTypeCd": "D",
+	"response": {
+		"code": "0000",
+		"message": "成功"
+	},
+	"responseTime": "20190418102004",
+	"bId": "202019041810750003",
+	"businessType": "B",
+	"transactionId": "3a5a411ec65a4c3f895935638aa1d2bc",
+	"dataFlowId": "44fde86d39ce46f4b4aab5f6b14f3947"
+}
+
+```

+ 68 - 0
java110-code-generator/src/main/java/com/java110/FloorGeneratorApplication.java

@@ -0,0 +1,68 @@
+package com.java110;
+
+
+import com.java110.code.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Hello world!
+ *
+ */
+public class FloorGeneratorApplication {
+
+    protected FloorGeneratorApplication() {
+        // prevents calls from subclass
+        throw new UnsupportedOperationException();
+    }
+    /**
+     *  代码生成器 入口方法
+     * @param args 参数
+     */
+    public static void main(String[] args) {
+        Data data = new Data();
+        data.setId("floorId");
+        data.setName("floor");
+        data.setDesc("小区楼");
+        data.setNewBusinessTypeCd("BUSINESS_TYPE_SAVE_FLOOR_INFO");
+        data.setUpdateBusinessTypeCd("BUSINESS_TYPE_UPDATE_FLOOR_INFO");
+        data.setDeleteBusinessTypeCd("BUSINESS_TYPE_DELETE_FLOOR_INFO");
+        data.setNewBusinessTypeCdValue("510100030001");
+        data.setUpdateBusinessTypeCdValue("510100040001");
+        data.setDeleteBusinessTypeCdValue("510100050001");
+        data.setBusinessTableName("business_floor");
+        data.setTableName("f_floor");
+        Map<String, String> param = new HashMap<String, String>();
+        param.put("floorId", "floor_id");
+        param.put("bId", "b_id");
+        param.put("floorNum", "floor_num");
+        param.put("name", "name");
+        param.put("statusCd", "status_cd");
+        param.put("userId", "user_id");
+        param.put("remark", "remark");
+        param.put("operate", "operate");
+        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);
+    }
+}

+ 69 - 0
java110-code-generator/src/main/java/com/java110/UnitGeneratorApplication.java

@@ -0,0 +1,69 @@
+package com.java110;
+
+
+import com.java110.code.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Hello world!
+ *
+ */
+public class UnitGeneratorApplication {
+
+    protected UnitGeneratorApplication() {
+        // prevents calls from subclass
+        throw new UnsupportedOperationException();
+    }
+    /**
+     *  代码生成器 入口方法
+     * @param args 参数
+     */
+    public static void main(String[] args) {
+        Data data = new Data();
+        data.setId("unitId");
+        data.setName("unit");
+        data.setDesc("小区单元");
+        data.setNewBusinessTypeCd("BUSINESS_TYPE_SAVE_UNIT_INFO");
+        data.setUpdateBusinessTypeCd("BUSINESS_TYPE_UPDATE_UNIT_INFO");
+        data.setDeleteBusinessTypeCd("BUSINESS_TYPE_DELETE_UNIT_INFO");
+        data.setNewBusinessTypeCdValue("520100030001");
+        data.setUpdateBusinessTypeCdValue("520100040001");
+        data.setDeleteBusinessTypeCdValue("520100050001");
+        data.setBusinessTableName("business_building_unit");
+        data.setTableName("building_unit");
+        Map<String, String> param = new HashMap<String, String>();
+        param.put("unitId", "unit_id");
+        param.put("bId", "b_id");
+        param.put("unitNum", "unit_num");
+        param.put("layerCount", "layer_count");
+        param.put("lift", "lift");
+        param.put("statusCd", "status_cd");
+        param.put("userId", "user_id");
+        param.put("remark", "remark");
+        param.put("operate", "operate");
+        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);
+    }
+}

+ 21 - 25
java110-code-generator/src/main/java/com/java110/code/GeneratorSaveInfoListener.java

@@ -1,28 +1,24 @@
 package com.java110.code;
 
-import java.io.*;
-import java.util.Date;
 import java.util.Map;
 
 public class GeneratorSaveInfoListener extends BaseGenerator {
 
 
-
-
-
     /**
      * 生成代码
+     *
      * @param data
      */
-    public void generator(Data data){
+    public void generator(Data data) {
         StringBuffer sb = readFile(this.getClass().getResource("/template/SaveListener.txt").getFile());
         String fileContext = sb.toString();
-        fileContext = fileContext.replace("store",toLowerCaseFirstOne(data.getName()))
-                .replace("Store",toUpperCaseFirstOne(data.getName()))
-                .replace("商户",data.getDesc())
-                .replace("BUSINESS_TYPE_SAVE_STORE_INFO",data.getNewBusinessTypeCd());
+        fileContext = fileContext.replace("store", toLowerCaseFirstOne(data.getName()))
+                .replace("Store", toUpperCaseFirstOne(data.getName()))
+                .replace("商户", data.getDesc())
+                .replace("BUSINESS_TYPE_SAVE_STORE_INFO", data.getNewBusinessTypeCd());
         System.out.println(this.getClass().getResource("/listener").getPath());
-        String writePath = this.getClass().getResource("/listener").getPath()+"/Save"+toUpperCaseFirstOne(data.getName())+"InfoListener.java";
+        String writePath = this.getClass().getResource("/listener").getPath() + "/Save" + toUpperCaseFirstOne(data.getName()) + "InfoListener.java";
         writeFile(writePath,
                 fileContext);
 
@@ -33,26 +29,26 @@ public class GeneratorSaveInfoListener extends BaseGenerator {
          */
         StringBuffer sbDoc = readFile(this.getClass().getResource("/template/serviceDoc.txt").getFile());
         String fileContextDoc = sbDoc.toString();
-        fileContextDoc = fileContextDoc.replace("store",toLowerCaseFirstOne(data.getName()))
-                .replace("Store",toUpperCaseFirstOne(data.getName()))
-                .replace("商户",data.getDesc())
-                .replace("$businessTypeCd$",data.getNewBusinessTypeCdValue());
+        fileContextDoc = fileContextDoc.replace("store", toLowerCaseFirstOne(data.getName()))
+                .replace("Store", toUpperCaseFirstOne(data.getName()))
+                .replace("商户", data.getDesc())
+                .replace("$businessTypeCd$", data.getNewBusinessTypeCdValue());
 
-        Map<String,String> tmpParams = data.getParams();
+        Map<String, String> tmpParams = data.getParams();
         String tmpLine = "";
-        String _tmpLine ="";
-        for(String key : tmpParams.keySet()){
-            if("operate".equals(key) || "statusCd".equals(key) || "bId".equals(key)){
+        String _tmpLine = "";
+        for (String key : tmpParams.keySet()) {
+            if ("operate".equals(key) || "statusCd".equals(key) || "bId".equals(key)) {
                 continue;
             }
-            tmpLine += "|business"+toUpperCaseFirstOne(data.getName())+"Info|"+key+"|1|String|30|-|-|\n";
-            _tmpLine += "        \""+key+"\":\"填写具体值\",\n";
+            tmpLine += "|business" + toUpperCaseFirstOne(data.getName()) + "Info|" + key + "|1|String|30|-|-|\n";
+            _tmpLine += "        \"" + key + "\":\"填写具体值\",\n";
         }
-        _tmpLine = _tmpLine.substring(0,_tmpLine.lastIndexOf(","));
-        fileContextDoc = fileContextDoc.replace("$busienssInfo$",tmpLine);
-        fileContextDoc = fileContextDoc.replace("$businessInfoJson$",_tmpLine);
+        _tmpLine = _tmpLine.substring(0, _tmpLine.lastIndexOf(","));
+        fileContextDoc = fileContextDoc.replace("$busienssInfo$", tmpLine);
+        fileContextDoc = fileContextDoc.replace("$businessInfoJson$", _tmpLine);
         System.out.println(this.getClass().getResource("/listener").getPath());
-        String writePathDoc = this.getClass().getResource("/listener").getPath()+"/Save"+toUpperCaseFirstOne(data.getName())+"Info.md";
+        String writePathDoc = this.getClass().getResource("/listener").getPath() + "/Save" + toUpperCaseFirstOne(data.getName()) + "Info.md";
         writeFile(writePathDoc,
                 fileContextDoc);
     }

+ 137 - 130
java110-code-generator/src/main/java/com/java110/code/GeneratorServiceDaoImplMapperListener.java

@@ -6,34 +6,32 @@ public class GeneratorServiceDaoImplMapperListener extends BaseGenerator {
 
 
     /**
-     *
      * @param data
      * @param fileContext
      * @return
      */
     //insert into business_store(store_id,b_id,user_id,name,address,tel,store_type_cd,nearby_landmarks,map_x,map_y,month,operate)
     //        values(#{storeId},#{bId},#{userId},#{name},#{address},#{tel},#{storeTypeCd},#{nearbyLandmarks},#{mapX},#{mapY},#{month},#{operate})
-
-    private String dealSaveBusinessInfo(Data data,String fileContext){
-        String sql = "insert into "+ data.getBusinessTableName() + "(\n";
+    private String dealSaveBusinessInfo(Data data, String fileContext) {
+        String sql = "insert into " + data.getBusinessTableName() + "(\n";
         String sqlValue = "\n) values (\n";
 
-        Map<String,String> params = data.getParams();
+        Map<String, String> params = data.getParams();
 
-        for(String key:params.keySet()){
-            if("statusCd".equals(key)){
+        for (String key : params.keySet()) {
+            if ("statusCd".equals(key)) {
                 continue;
             }
-            sql += params.get(key)+",";
-            sqlValue += "#{"+key+"},";
+            sql += params.get(key) + ",";
+            sqlValue += "#{" + key + "},";
         }
 
-        sql = sql.endsWith(",")?sql.substring(0,sql.length()-1):sql;
-        sqlValue = sqlValue.endsWith(",")?sqlValue.substring(0,sqlValue.length()-1):sqlValue;
+        sql = sql.endsWith(",") ? sql.substring(0, sql.length() - 1) : sql;
+        sqlValue = sqlValue.endsWith(",") ? sqlValue.substring(0, sqlValue.length() - 1) : sqlValue;
 
-        sql += (sqlValue +"\n)");
+        sql += (sqlValue + "\n)");
 
-        fileContext = fileContext.replace("$saveBusinessInfo$",sql);
+        fileContext = fileContext.replace("$saveBusinessInfo$", sql);
 
         return fileContext;
 
@@ -41,42 +39,46 @@ public class GeneratorServiceDaoImplMapperListener extends BaseGenerator {
 
     /**
      * select s.store_id,s.b_id,s.user_id,s.name,s.address,s.tel,s.store_type_cd,s.nearby_landmarks,s.map_x,s.map_y,s.operate
-     *         from business_store 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="storeId != null and storeId != ''">
-     *             and s.store_id = #{storeId}
-     *         </if>
+     * from business_store 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="storeId != null and storeId != ''">
+     * and s.store_id = #{storeId}
+     * </if>
+     *
      * @param data
      * @param fileContext
      * @return
      */
-    private String dealGetBusinessInfo(Data data,String fileContext){
+    private String dealGetBusinessInfo(Data data, String fileContext) {
         String sql = "select  ";
-        String sqlValue = " \nfrom "+data.getBusinessTableName()+" t \nwhere 1 =1 \n";
+        String sqlValue = " \nfrom " + data.getBusinessTableName() + " t \nwhere 1 =1 \n";
 
-        Map<String,String> params = data.getParams();
+        Map<String, String> params = data.getParams();
 
-        for(String key:params.keySet()){
-            if("statusCd".equals(key)){
+        for (String key : params.keySet()) {
+            if ("statusCd".equals(key)) {
                 continue;
             }
-            sql += ("t."+params.get(key)+",");
-            sqlValue += "<if test=\""+key+" !=null and "+key+" != ''\">\n";
-            sqlValue += "   and t."+params.get(key)+"= #{"+key +"}\n";
+            sql += ("t." + params.get(key) + ",");
+            if (!key.equals(params.get(key))) {
+                sql += ("t." + params.get(key) + " " + key + ",");
+            }
+            sqlValue += "<if test=\"" + key + " !=null and " + key + " != ''\">\n";
+            sqlValue += "   and t." + params.get(key) + "= #{" + key + "}\n";
             sqlValue += "</if> \n";
 
         }
 
-        sql = sql.endsWith(",")?sql.substring(0,sql.length()-1):sql;
+        sql = sql.endsWith(",") ? sql.substring(0, sql.length() - 1) : sql;
 
         sql += sqlValue;
 
-        fileContext = fileContext.replace("$getBusinessInfo$",sql);
+        fileContext = fileContext.replace("$getBusinessInfo$", sql);
 
         return fileContext;
 
@@ -84,52 +86,52 @@ public class GeneratorServiceDaoImplMapperListener extends BaseGenerator {
 
     /**
      * insert into s_store(store_id,b_id,user_id,name,address,tel,store_type_cd,nearby_landmarks,map_x,map_y,status_cd)
-     *         select s.store_id,s.b_id,s.user_id,s.name,s.address,s.tel,s.store_type_cd,s.nearby_landmarks,s.map_x,s.map_y,'0'
-     *         from business_store s where
-     *         s.operate = 'ADD' and s.b_id=#{bId}
+     * select s.store_id,s.b_id,s.user_id,s.name,s.address,s.tel,s.store_type_cd,s.nearby_landmarks,s.map_x,s.map_y,'0'
+     * from business_store s where
+     * s.operate = 'ADD' and s.b_id=#{bId}
      */
-    private String dealSaveInfoInstance(Data data,String fileContext){
-        String sql = "insert into "+ data.getTableName() + "(\n";
+    private String dealSaveInfoInstance(Data data, String fileContext) {
+        String sql = "insert into " + data.getTableName() + "(\n";
         String sqlValue = "select ";
-        String sqlWhere = " from "+ data.getBusinessTableName() +" t where 1=1\n";
+        String sqlWhere = " from " + data.getBusinessTableName() + " t where 1=1\n";
 
-        Map<String,String> params = data.getParams();
+        Map<String, String> params = data.getParams();
 
-        for(String key:params.keySet()){
-            if("operate".equals(key)){
+        for (String key : params.keySet()) {
+            if ("operate".equals(key)) {
                 continue;
             }
-            sql += params.get(key)+",";
+            sql += params.get(key) + ",";
 
-            if("statusCd".equals(key)){
+            if ("statusCd".equals(key)) {
                 sqlValue += "'0',";
                 continue;
             }
-            sqlValue += "t."+params.get(key)+",";
+            sqlValue += "t." + params.get(key) + ",";
         }
 
-        for(String key:params.keySet()){
-            if("statusCd".equals(key)){
+        for (String key : params.keySet()) {
+            if ("statusCd".equals(key)) {
                 continue;
             }
 
-            if("operate".equals(key)){
-                sqlWhere += "   and t."+params.get(key)+"= 'ADD'\n";
-            }else{
-                sqlWhere += "<if test=\""+key+" !=null and "+key+" != ''\">\n";
-                sqlWhere += "   and t."+params.get(key)+"= #{"+key +"}\n";
+            if ("operate".equals(key)) {
+                sqlWhere += "   and t." + params.get(key) + "= 'ADD'\n";
+            } else {
+                sqlWhere += "<if test=\"" + key + " !=null and " + key + " != ''\">\n";
+                sqlWhere += "   and t." + params.get(key) + "= #{" + key + "}\n";
                 sqlWhere += "</if> \n";
 
             }
 
         }
 
-        sql = sql.endsWith(",")?sql.substring(0,sql.length()-1):sql;
-        sqlValue = sqlValue.endsWith(",")?sqlValue.substring(0,sqlValue.length()-1):sqlValue;
+        sql = sql.endsWith(",") ? sql.substring(0, sql.length() - 1) : sql;
+        sqlValue = sqlValue.endsWith(",") ? sqlValue.substring(0, sqlValue.length() - 1) : sqlValue;
 
-        sql += ("\n) "+ sqlValue + sqlWhere);
+        sql += ("\n) " + sqlValue + sqlWhere);
 
-        fileContext = fileContext.replace("$saveInfoInstance$",sql);
+        fileContext = fileContext.replace("$saveInfoInstance$", sql);
 
         return fileContext;
 
@@ -137,105 +139,109 @@ public class GeneratorServiceDaoImplMapperListener extends BaseGenerator {
 
     /**
      * select s.store_id,s.b_id,s.user_id,s.name,s.address,s.tel,s.store_type_cd,s.nearby_landmarks,s.map_x,s.map_y,s.status_cd
-     *         from s_store s
-     *         where 1=1
-     *         <if test="statusCd != null and statusCd != ''">
-     *             and s.status_cd = #{statusCd}
-     *         </if>
+     * from s_store 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="storeId != null and storeId !=''">
+     * and s.store_id = #{storeId}
+     * </if>
      *
-     *         <if test="bId != null and bId !=''">
-     *             and s.b_id = #{bId}
-     *         </if>
-     *         <if test="storeId != null and storeId !=''">
-     *             and s.store_id = #{storeId}
-     *         </if>
      * @param data
      * @param fileContext
      * @return
      */
-    private String dealGetInfo(Data data,String fileContext){
+    private String dealGetInfo(Data data, String fileContext) {
         String sql = "select  ";
-        String sqlValue = " \nfrom "+data.getTableName()+" t \nwhere 1 =1 \n";
+        String sqlValue = " \nfrom " + data.getTableName() + " t \nwhere 1 =1 \n";
 
-        Map<String,String> params = data.getParams();
+        Map<String, String> params = data.getParams();
 
-        for(String key:params.keySet()){
-            if("operate".equals(key)){
+        for (String key : params.keySet()) {
+            if ("operate".equals(key)) {
                 continue;
             }
-            sql += ("t."+params.get(key)+",");
-            sqlValue += "<if test=\""+key+" !=null and "+key+" != ''\">\n";
-            sqlValue += "   and t."+params.get(key)+"= #{"+key +"}\n";
+            sql += ("t." + params.get(key) + ",");
+            if (!key.equals(params.get(key))) {
+                sql += ("t." + params.get(key) + " " + key + ",");
+            }
+            sqlValue += "<if test=\"" + key + " !=null and " + key + " != ''\">\n";
+            sqlValue += "   and t." + params.get(key) + "= #{" + key + "}\n";
             sqlValue += "</if> \n";
 
         }
 
-        sql = sql.endsWith(",")?sql.substring(0,sql.length()-1):sql;
+        sql = sql.endsWith(",") ? sql.substring(0, sql.length() - 1) : sql;
 
         sql += sqlValue;
 
-        fileContext = fileContext.replace("$getInfo$",sql);
+        fileContext = fileContext.replace("$getInfo$", sql);
 
         return fileContext;
     }
 
     /**
      * update s_store s set s.status_cd = #{statusCd}
-     *         <if test="newBId != null and newBId != ''">
-     *             ,s.b_id = #{newBId}
-     *         </if>
-     *         <if test="userId != null and userId != ''">
-     *             ,s.user_id = #{userId}
-     *         </if>
-     *         <if test="name != null and name != ''">
-     *             ,s.name = #{name}
-     *         </if>
-     *         <if test="address != null and address != ''">
-     *             ,s.address = #{address}
-     *         </if>
-     *         <if test="tel != null and tel != ''">
-     *             ,s.tel = #{tel}
-     *         </if>
-     *         <if test="storeTypeCd != null and storeTypeCd != ''">
-     *             ,s.store_type_cd = #{storeTypeCd}
-     *         </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="storeId != null and storeId !=''">
-     *             and s.store_id = #{storeId}
-     *         </if>
+     * <if test="newBId != null and newBId != ''">
+     * ,s.b_id = #{newBId}
+     * </if>
+     * <if test="userId != null and userId != ''">
+     * ,s.user_id = #{userId}
+     * </if>
+     * <if test="name != null and name != ''">
+     * ,s.name = #{name}
+     * </if>
+     * <if test="address != null and address != ''">
+     * ,s.address = #{address}
+     * </if>
+     * <if test="tel != null and tel != ''">
+     * ,s.tel = #{tel}
+     * </if>
+     * <if test="storeTypeCd != null and storeTypeCd != ''">
+     * ,s.store_type_cd = #{storeTypeCd}
+     * </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="storeId != null and storeId !=''">
+     * and s.store_id = #{storeId}
+     * </if>
      */
-    private String dealUpdateInfoInstance(Data data,String fileContext){
-        String sql = "update  "+ data.getTableName() + " t set t.status_cd = #{statusCd}\n";
+    private String dealUpdateInfoInstance(Data data, String fileContext) {
+        String sql = "update  " + data.getTableName() + " t set t.status_cd = #{statusCd}\n";
         String sqlWhere = " where 1=1 ";
 
-        Map<String,String> params = data.getParams();
+        Map<String, String> params = data.getParams();
 
-        for(String key:params.keySet()){
-            if("operate".equals(key)){
+        for (String key : params.keySet()) {
+            if ("operate".equals(key)) {
                 continue;
             }
 
-            if("statusCd".equals(key)){
+            if ("statusCd".equals(key)) {
                 continue;
             }
-            if(!"bId".equals(key) && !data.getId().equals(key)) {
+            if (!"bId".equals(key) && !data.getId().equals(key)) {
                 sql += "<if test=\"" + key + " !=null and " + key + " != ''\">\n";
                 sql += ", t." + params.get(key) + "= #{" + key + "}\n";
                 sql += "</if> \n";
             }
-            if("bId".equals(key) || data.getId().equals(key)) {
+            if ("bId".equals(key) || data.getId().equals(key)) {
                 sqlWhere += "<if test=\"" + key + " !=null and " + key + " != ''\">\n";
                 sqlWhere += "and t." + params.get(key) + "= #{" + key + "}\n";
                 sqlWhere += "</if> \n";
@@ -244,7 +250,7 @@ public class GeneratorServiceDaoImplMapperListener extends BaseGenerator {
 
         sql += sqlWhere;
 
-        fileContext = fileContext.replace("$updateInfoInstance$",sql);
+        fileContext = fileContext.replace("$updateInfoInstance$", sql);
 
         return fileContext;
 
@@ -254,22 +260,23 @@ public class GeneratorServiceDaoImplMapperListener extends BaseGenerator {
 
     /**
      * 生成代码
+     *
      * @param data
      */
-    public void generator(Data data){
+    public void generator(Data data) {
         StringBuffer sb = readFile(this.getClass().getResource("/template/ServiceDaoImplMapper.txt").getFile());
         String fileContext = sb.toString();
-        fileContext = fileContext.replace("store",toLowerCaseFirstOne(data.getName()))
-                .replace("Store",toUpperCaseFirstOne(data.getName()))
-                .replace("商户",data.getDesc());
-        fileContext = dealSaveBusinessInfo(data,fileContext);
-        fileContext = dealGetBusinessInfo(data,fileContext);
-        fileContext = dealSaveInfoInstance(data,fileContext);
-        fileContext = dealGetInfo(data,fileContext);
-        fileContext = dealUpdateInfoInstance(data,fileContext);
+        fileContext = fileContext.replace("store", toLowerCaseFirstOne(data.getName()))
+                .replace("Store", toUpperCaseFirstOne(data.getName()))
+                .replace("商户", data.getDesc());
+        fileContext = dealSaveBusinessInfo(data, fileContext);
+        fileContext = dealGetBusinessInfo(data, fileContext);
+        fileContext = dealSaveInfoInstance(data, fileContext);
+        fileContext = dealGetInfo(data, fileContext);
+        fileContext = dealUpdateInfoInstance(data, fileContext);
 
         System.out.println(this.getClass().getResource("/listener").getPath());
-        String writePath = this.getClass().getResource("/listener").getPath()+"/"+toUpperCaseFirstOne(data.getName())+"ServiceDaoImplMapper.xml";
+        String writePath = this.getClass().getResource("/listener").getPath() + "/" + toUpperCaseFirstOne(data.getName()) + "ServiceDaoImplMapper.xml";
         writeFile(writePath,
                 fileContext);
     }

+ 17 - 0
java110-common/src/main/java/com/java110/common/constant/BusinessTypeConstant.java

@@ -190,6 +190,23 @@ public class BusinessTypeConstant {
      */
     public static final String BUSINESS_TYPE_DELETE_FLOOR_INFO = "510100050001";
 
+
+    /**
+     * 增加小区单元
+     */
+    public static final String BUSINESS_TYPE_SAVE_UNIT_INFO = "520100030001";
+
+    /**
+     * 修改小区单元
+     */
+    public static final String BUSINESS_TYPE_UPDATE_UNIT_INFO = "520100040001";
+
+
+    /**
+     * 删除小区单元
+     */
+    public static final String BUSINESS_TYPE_DELETE_UNIT_INFO = "520100050001";
+
     /**
      * 保存物业信息
      */

+ 38 - 1
java110-config/db/CommunityService/create_room.sql

@@ -27,4 +27,41 @@ CREATE TABLE f_floor(
   UNIQUE KEY (floor_id)
 );
 CREATE INDEX idx_floor_b_id ON f_floor(b_id);
-CREATE UNIQUE INDEX idx_floor_id ON f_floor(floor_id);
+CREATE UNIQUE INDEX idx_floor_id ON f_floor(floor_id);
+
+
+-- 单元信息 building 楼宇管理
+CREATE TABLE business_building_unit(
+  unit_id VARCHAR(30) NOT NULL COMMENT '单元ID',
+  b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
+  unit_num VARCHAR(12) NOT NULL COMMENT '单元编号',
+  floor_id VARCHAR(30) NOT NULL COMMENT '楼ID',
+  layer_count int NOT NULL COMMENT '总层数',
+  lift varchar(4) NOT NULL COMMENT '是否有电梯 1010有 2020 无',
+  user_id VARCHAR(30) NOT NULL COMMENT '用户ID',
+  remark VARCHAR(200) NOT NULL COMMENT '备注',
+  create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  operate VARCHAR(4) NOT NULL COMMENT '数据状态,添加ADD,修改MOD 删除DEL'
+);
+
+
+CREATE INDEX idx_business_unit_id ON business_building_unit(unit_id);
+CREATE INDEX idx_business_unit_b_id ON business_building_unit(b_id);
+
+
+CREATE TABLE building_unit(
+  unit_id VARCHAR(30) NOT NULL COMMENT '单元ID',
+  b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
+  unit_num VARCHAR(12) NOT NULL COMMENT '单元编号',
+  floor_id VARCHAR(30) NOT NULL COMMENT '楼ID',
+  layer_count int NOT NULL COMMENT '总层数',
+  lift varchar(4) NOT NULL COMMENT '是否有电梯 1010有 2020 无',
+  user_id VARCHAR(30) NOT NULL COMMENT '用户ID',
+  remark VARCHAR(200) NOT NULL COMMENT '备注',
+  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 (unit_id)
+);
+CREATE INDEX idx_unit_b_id ON building_unit(b_id);
+CREATE UNIQUE INDEX idx_unit_id ON building_unit(unit_id);
+

+ 147 - 0
java110-config/src/main/resources/mapper/unit/UnitServiceDaoImplMapper.xml

@@ -0,0 +1,147 @@
+<?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="unitServiceDaoImpl">
+
+    <!-- 保存小区单元信息 add by wuxw 2018-07-03 -->
+       <insert id="saveBusinessUnitInfo" parameterType="Map">
+           insert into business_building_unit(
+operate,layer_count,unit_id,unit_num,lift,remark,b_id,user_id
+) values (
+#{operate},#{layerCount},#{unitId},#{unitNum},#{lift},#{remark},#{bId},#{userId}
+)
+       </insert>
+
+
+       <!-- 查询小区单元信息(Business) add by wuxw 2018-07-03 -->
+       <select id="getBusinessUnitInfo" parameterType="Map" resultType="Map">
+           select  t.operate,t.layer_count,t.layer_count layerCount,t.unit_id,t.unit_id unitId,t.unit_num,t.unit_num unitNum,t.lift,t.remark,t.b_id,t.b_id bId,t.user_id,t.user_id userId 
+from business_building_unit t 
+where 1 =1 
+<if test="operate !=null and operate != ''">
+   and t.operate= #{operate}
+</if> 
+<if test="layerCount !=null and layerCount != ''">
+   and t.layer_count= #{layerCount}
+</if> 
+<if test="unitId !=null and unitId != ''">
+   and t.unit_id= #{unitId}
+</if> 
+<if test="unitNum !=null and unitNum != ''">
+   and t.unit_num= #{unitNum}
+</if> 
+<if test="lift !=null and lift != ''">
+   and t.lift= #{lift}
+</if> 
+<if test="remark !=null and remark != ''">
+   and t.remark= #{remark}
+</if> 
+<if test="bId !=null and bId != ''">
+   and t.b_id= #{bId}
+</if> 
+<if test="userId !=null and userId != ''">
+   and t.user_id= #{userId}
+</if> 
+
+       </select>
+
+
+
+
+
+    <!-- 保存小区单元信息至 instance表中 add by wuxw 2018-07-03 -->
+    <insert id="saveUnitInfoInstance" parameterType="Map">
+        insert into building_unit(
+layer_count,unit_id,unit_num,lift,status_cd,remark,b_id,user_id
+) select t.layer_count,t.unit_id,t.unit_num,t.lift,'0',t.remark,t.b_id,t.user_id from business_building_unit t where 1=1
+   and t.operate= 'ADD'
+<if test="layerCount !=null and layerCount != ''">
+   and t.layer_count= #{layerCount}
+</if> 
+<if test="unitId !=null and unitId != ''">
+   and t.unit_id= #{unitId}
+</if> 
+<if test="unitNum !=null and unitNum != ''">
+   and t.unit_num= #{unitNum}
+</if> 
+<if test="lift !=null and lift != ''">
+   and t.lift= #{lift}
+</if> 
+<if test="remark !=null and remark != ''">
+   and t.remark= #{remark}
+</if> 
+<if test="bId !=null and bId != ''">
+   and t.b_id= #{bId}
+</if> 
+<if test="userId !=null and userId != ''">
+   and t.user_id= #{userId}
+</if> 
+
+    </insert>
+
+
+
+    <!-- 查询小区单元信息 add by wuxw 2018-07-03 -->
+    <select id="getUnitInfo" parameterType="Map" resultType="Map">
+        select  t.layer_count,t.layer_count layerCount,t.unit_id,t.unit_id unitId,t.unit_num,t.unit_num unitNum,t.lift,t.status_cd,t.status_cd statusCd,t.remark,t.b_id,t.b_id bId,t.user_id,t.user_id userId 
+from building_unit t 
+where 1 =1 
+<if test="layerCount !=null and layerCount != ''">
+   and t.layer_count= #{layerCount}
+</if> 
+<if test="unitId !=null and unitId != ''">
+   and t.unit_id= #{unitId}
+</if> 
+<if test="unitNum !=null and unitNum != ''">
+   and t.unit_num= #{unitNum}
+</if> 
+<if test="lift !=null and lift != ''">
+   and t.lift= #{lift}
+</if> 
+<if test="statusCd !=null and statusCd != ''">
+   and t.status_cd= #{statusCd}
+</if> 
+<if test="remark !=null and remark != ''">
+   and t.remark= #{remark}
+</if> 
+<if test="bId !=null and bId != ''">
+   and t.b_id= #{bId}
+</if> 
+<if test="userId !=null and userId != ''">
+   and t.user_id= #{userId}
+</if> 
+
+    </select>
+
+
+
+
+    <!-- 修改小区单元信息 add by wuxw 2018-07-03 -->
+    <update id="updateUnitInfoInstance" parameterType="Map">
+        update  building_unit t set t.status_cd = #{statusCd}
+<if test="layerCount !=null and layerCount != ''">
+, t.layer_count= #{layerCount}
+</if> 
+<if test="unitNum !=null and unitNum != ''">
+, t.unit_num= #{unitNum}
+</if> 
+<if test="lift !=null and lift != ''">
+, t.lift= #{lift}
+</if> 
+<if test="remark !=null and remark != ''">
+, t.remark= #{remark}
+</if> 
+<if test="userId !=null and userId != ''">
+, t.user_id= #{userId}
+</if> 
+ where 1=1 <if test="unitId !=null and unitId != ''">
+and t.unit_id= #{unitId}
+</if> 
+<if test="bId !=null and bId != ''">
+and t.b_id= #{bId}
+</if> 
+
+    </update>
+
+</mapper>

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

@@ -75,6 +75,7 @@ public class GenerateCodeFactory {
     public static final String CODE_PREFIX_pgId = "600";
 
     public static final String CODE_PREFIX_floorId = "73";
+    public static final String CODE_PREFIX_unitId = "74";
 
     /**
      * 只有在不调用服务生成ID时有用