Browse Source

加入设备属性功能

wuxw 6 years ago
parent
commit
7fc3275620
14 changed files with 1649 additions and 0 deletions
  1. 81 0
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/dao/IMachineAttrServiceDao.java
  2. 134 0
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/dao/impl/MachineAttrServiceDaoImpl.java
  3. 83 0
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/listener/machineAttr/AbstractMachineAttrBusinessServiceDataFlowListener.java
  4. 180 0
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/listener/machineAttr/DeleteMachineAttrInfoListener.java
  5. 175 0
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/listener/machineAttr/SaveMachineAttrInfoListener.java
  6. 190 0
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/listener/machineAttr/UpdateMachineAttrInfoListener.java
  7. 70 0
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/smo/impl/MachineAttrInnerServiceSMOImpl.java
  8. 114 0
      docs/document/services/machine/DeleteMachineAttrInfo.md
  9. 122 0
      docs/document/services/machine/SaveMachineAttrInfo.md
  10. 122 0
      docs/document/services/machine/UpdateMachineAttrInfo.md
  11. 86 0
      java110-bean/src/main/java/com/java110/dto/hardwareAdapation/MachineAttrDto.java
  12. 80 0
      java110-code-generator/src/main/java/com/java110/MachineAttrGeneratorApplication.java
  13. 41 0
      java110-core/src/main/java/com/java110/core/smo/hardwareAdapation/IMachineAttrInnerServiceSMO.java
  14. 171 0
      java110-db/src/main/resources/mapper/hardwareAdapation/MachineAttrServiceDaoImplMapper.xml

+ 81 - 0
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/dao/IMachineAttrServiceDao.java

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

+ 134 - 0
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/dao/impl/MachineAttrServiceDaoImpl.java

@@ -0,0 +1,134 @@
+package com.java110.hardwareAdapation.dao.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.base.dao.BaseServiceDao;
+import com.java110.hardwareAdapation.dao.IMachineAttrServiceDao;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.exception.DAOException;
+import com.java110.utils.util.DateUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 设备属性服务 与数据库交互
+ * Created by wuxw on 2017/4/5.
+ */
+@Service("machineAttrServiceDaoImpl")
+//@Transactional
+public class MachineAttrServiceDaoImpl extends BaseServiceDao implements IMachineAttrServiceDao {
+
+    private static Logger logger = LoggerFactory.getLogger(MachineAttrServiceDaoImpl.class);
+
+    /**
+     * 设备属性信息封装
+     *
+     * @param businessMachineAttrInfo 设备属性信息 封装
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public void saveBusinessMachineAttrInfo(Map businessMachineAttrInfo) throws DAOException {
+        businessMachineAttrInfo.put("month", DateUtil.getCurrentMonth());
+        // 查询business_user 数据是否已经存在
+        logger.debug("保存设备属性信息 入参 businessMachineAttrInfo : {}", businessMachineAttrInfo);
+        int saveFlag = sqlSessionTemplate.insert("machineAttrServiceDaoImpl.saveBusinessMachineAttrInfo", businessMachineAttrInfo);
+
+        if (saveFlag < 1) {
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存设备属性数据失败:" + JSONObject.toJSONString(businessMachineAttrInfo));
+        }
+    }
+
+
+    /**
+     * 查询设备属性信息
+     *
+     * @param info bId 信息
+     * @return 设备属性信息
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public List<Map> getBusinessMachineAttrInfo(Map info) throws DAOException {
+
+        logger.debug("查询设备属性信息 入参 info : {}", info);
+
+        List<Map> businessMachineAttrInfos = sqlSessionTemplate.selectList("machineAttrServiceDaoImpl.getBusinessMachineAttrInfo", info);
+
+        return businessMachineAttrInfos;
+    }
+
+
+    /**
+     * 保存设备属性信息 到 instance
+     *
+     * @param info bId 信息
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public void saveMachineAttrInfoInstance(Map info) throws DAOException {
+        logger.debug("保存设备属性信息Instance 入参 info : {}", info);
+
+        int saveFlag = sqlSessionTemplate.insert("machineAttrServiceDaoImpl.saveMachineAttrInfoInstance", info);
+
+        if (saveFlag < 1) {
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存设备属性信息Instance数据失败:" + JSONObject.toJSONString(info));
+        }
+    }
+
+
+    /**
+     * 查询设备属性信息(instance)
+     *
+     * @param info bId 信息
+     * @return List<Map>
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public List<Map> getMachineAttrInfo(Map info) throws DAOException {
+        logger.debug("查询设备属性信息 入参 info : {}", info);
+
+        List<Map> businessMachineAttrInfos = sqlSessionTemplate.selectList("machineAttrServiceDaoImpl.getMachineAttrInfo", info);
+
+        return businessMachineAttrInfos;
+    }
+
+
+    /**
+     * 修改设备属性信息
+     *
+     * @param info 修改信息
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public void updateMachineAttrInfoInstance(Map info) throws DAOException {
+        logger.debug("修改设备属性信息Instance 入参 info : {}", info);
+
+        int saveFlag = sqlSessionTemplate.update("machineAttrServiceDaoImpl.updateMachineAttrInfoInstance", info);
+
+        if (saveFlag < 1) {
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "修改设备属性信息Instance数据失败:" + JSONObject.toJSONString(info));
+        }
+    }
+
+    /**
+     * 查询设备属性数量
+     *
+     * @param info 设备属性信息
+     * @return 设备属性数量
+     */
+    @Override
+    public int queryMachineAttrsCount(Map info) {
+        logger.debug("查询设备属性数据 入参 info : {}", info);
+
+        List<Map> businessMachineAttrInfos = sqlSessionTemplate.selectList("machineAttrServiceDaoImpl.queryMachineAttrsCount", info);
+        if (businessMachineAttrInfos.size() < 1) {
+            return 0;
+        }
+
+        return Integer.parseInt(businessMachineAttrInfos.get(0).get("count").toString());
+    }
+
+
+}

+ 83 - 0
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/listener/machineAttr/AbstractMachineAttrBusinessServiceDataFlowListener.java

@@ -0,0 +1,83 @@
+package com.java110.hardwareAdapation.listener.machineAttr;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.entity.center.Business;
+import com.java110.event.service.AbstractBusinessServiceDataFlowListener;
+import com.java110.hardwareAdapation.dao.IMachineAttrServiceDao;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.exception.ListenerExecuteException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 设备属性 服务侦听 父类
+ * Created by wuxw on 2018/7/4.
+ */
+public abstract class AbstractMachineAttrBusinessServiceDataFlowListener extends AbstractBusinessServiceDataFlowListener {
+    private static Logger logger = LoggerFactory.getLogger(AbstractMachineAttrBusinessServiceDataFlowListener.class);
+
+
+    /**
+     * 获取 DAO工具类
+     *
+     * @return
+     */
+    public abstract IMachineAttrServiceDao getMachineAttrServiceDaoImpl();
+
+    /**
+     * 刷新 businessMachineAttrInfo 数据
+     * 主要将 数据库 中字段和 接口传递字段建立关系
+     *
+     * @param businessMachineAttrInfo
+     */
+    protected void flushBusinessMachineAttrInfo(Map businessMachineAttrInfo, String statusCd) {
+        businessMachineAttrInfo.put("newBId", businessMachineAttrInfo.get("b_id"));
+        businessMachineAttrInfo.put("machineId", businessMachineAttrInfo.get("machine_id"));
+        businessMachineAttrInfo.put("attrId", businessMachineAttrInfo.get("attr_id"));
+        businessMachineAttrInfo.put("operate", businessMachineAttrInfo.get("operate"));
+        businessMachineAttrInfo.put("specCd", businessMachineAttrInfo.get("spec_cd"));
+        businessMachineAttrInfo.put("communityId", businessMachineAttrInfo.get("community_id"));
+        businessMachineAttrInfo.put("value", businessMachineAttrInfo.get("value"));
+        businessMachineAttrInfo.remove("bId");
+        businessMachineAttrInfo.put("statusCd", statusCd);
+    }
+
+
+    /**
+     * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
+     *
+     * @param businessMachineAttr 设备属性信息
+     */
+    protected void autoSaveDelBusinessMachineAttr(Business business, JSONObject businessMachineAttr) {
+//自动插入DEL
+        Map info = new HashMap();
+        info.put("attrId", businessMachineAttr.getString("attrId"));
+        info.put("statusCd", StatusConstant.STATUS_CD_VALID);
+        List<Map> currentMachineAttrInfos = getMachineAttrServiceDaoImpl().getMachineAttrInfo(info);
+        if (currentMachineAttrInfos == null || currentMachineAttrInfos.size() != 1) {
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "未找到需要修改数据信息,入参错误或数据有问题,请检查" + info);
+        }
+
+        Map currentMachineAttrInfo = currentMachineAttrInfos.get(0);
+
+        currentMachineAttrInfo.put("bId", business.getbId());
+
+        currentMachineAttrInfo.put("machineId", currentMachineAttrInfo.get("machine_id"));
+        currentMachineAttrInfo.put("attrId", currentMachineAttrInfo.get("attr_id"));
+        currentMachineAttrInfo.put("operate", currentMachineAttrInfo.get("operate"));
+        currentMachineAttrInfo.put("specCd", currentMachineAttrInfo.get("spec_cd"));
+        currentMachineAttrInfo.put("communityId", currentMachineAttrInfo.get("community_id"));
+        currentMachineAttrInfo.put("value", currentMachineAttrInfo.get("value"));
+
+
+        currentMachineAttrInfo.put("operate", StatusConstant.OPERATE_DEL);
+        getMachineAttrServiceDaoImpl().saveBusinessMachineAttrInfo(currentMachineAttrInfo);
+    }
+
+
+}

+ 180 - 0
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/listener/machineAttr/DeleteMachineAttrInfoListener.java

@@ -0,0 +1,180 @@
+package com.java110.hardwareAdapation.listener.machineAttr;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+import com.java110.hardwareAdapation.dao.IMachineAttrServiceDao;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.exception.ListenerExecuteException;
+import com.java110.utils.util.Assert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 删除设备属性信息 侦听
+ * <p>
+ * 处理节点
+ * 1、businessMachineAttr:{} 设备属性基本信息节点
+ * 2、businessMachineAttrAttr:[{}] 设备属性属性信息节点
+ * 3、businessMachineAttrPhoto:[{}] 设备属性照片信息节点
+ * 4、businessMachineAttrCerdentials:[{}] 设备属性证件信息节点
+ * 协议地址 :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("deleteMachineAttrInfoListener")
+@Transactional
+public class DeleteMachineAttrInfoListener extends AbstractMachineAttrBusinessServiceDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(DeleteMachineAttrInfoListener.class);
+    @Autowired
+    IMachineAttrServiceDao machineAttrServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 3;
+    }
+
+    @Override
+    public String getBusinessTypeCd() {
+        return BusinessTypeConstant.BUSINESS_TYPE_DELETE_MACHINE;
+    }
+
+    /**
+     * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去
+     *
+     * @param dataFlowContext 数据对象
+     * @param business        当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data, "没有datas 节点,或没有子节点需要处理");
+
+        //处理 businessMachineAttr 节点
+        if (data.containsKey("businessMachineAttr")) {
+            //处理 businessMachineAttr 节点
+            if (data.containsKey("businessMachineAttr")) {
+                Object _obj = data.get("businessMachineAttr");
+                JSONArray businessMachineAttrs = null;
+                if (_obj instanceof JSONObject) {
+                    businessMachineAttrs = new JSONArray();
+                    businessMachineAttrs.add(_obj);
+                } else {
+                    businessMachineAttrs = (JSONArray) _obj;
+                }
+                //JSONObject businessMachineAttr = data.getJSONObject("businessMachineAttr");
+                for (int _machineAttrIndex = 0; _machineAttrIndex < businessMachineAttrs.size(); _machineAttrIndex++) {
+                    JSONObject businessMachineAttr = businessMachineAttrs.getJSONObject(_machineAttrIndex);
+                    doBusinessMachineAttr(business, businessMachineAttr);
+                    if (_obj instanceof JSONObject) {
+                        dataFlowContext.addParamOut("attrId", businessMachineAttr.getString("attrId"));
+                    }
+                }
+            }
+        }
+
+
+    }
+
+    /**
+     * 删除 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> businessMachineAttrInfos = machineAttrServiceDaoImpl.getBusinessMachineAttrInfo(info);
+        if (businessMachineAttrInfos != null && businessMachineAttrInfos.size() > 0) {
+            for (int _machineAttrIndex = 0; _machineAttrIndex < businessMachineAttrInfos.size(); _machineAttrIndex++) {
+                Map businessMachineAttrInfo = businessMachineAttrInfos.get(_machineAttrIndex);
+                flushBusinessMachineAttrInfo(businessMachineAttrInfo, StatusConstant.STATUS_CD_INVALID);
+                machineAttrServiceDaoImpl.updateMachineAttrInfoInstance(businessMachineAttrInfo);
+                dataFlowContext.addParamOut("attrId", businessMachineAttrInfo.get("attr_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> machineAttrInfo = machineAttrServiceDaoImpl.getMachineAttrInfo(info);
+        if (machineAttrInfo != null && machineAttrInfo.size() > 0) {
+
+            //设备属性信息
+            List<Map> businessMachineAttrInfos = machineAttrServiceDaoImpl.getBusinessMachineAttrInfo(delInfo);
+            //除非程序出错了,这里不会为空
+            if (businessMachineAttrInfos == null || businessMachineAttrInfos.size() == 0) {
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR, "撤单失败(machineAttr),程序内部异常,请检查! " + delInfo);
+            }
+            for (int _machineAttrIndex = 0; _machineAttrIndex < businessMachineAttrInfos.size(); _machineAttrIndex++) {
+                Map businessMachineAttrInfo = businessMachineAttrInfos.get(_machineAttrIndex);
+                flushBusinessMachineAttrInfo(businessMachineAttrInfo, StatusConstant.STATUS_CD_VALID);
+                machineAttrServiceDaoImpl.updateMachineAttrInfoInstance(businessMachineAttrInfo);
+            }
+        }
+    }
+
+
+    /**
+     * 处理 businessMachineAttr 节点
+     *
+     * @param business            总的数据节点
+     * @param businessMachineAttr 设备属性节点
+     */
+    private void doBusinessMachineAttr(Business business, JSONObject businessMachineAttr) {
+
+        Assert.jsonObjectHaveKey(businessMachineAttr, "attrId", "businessMachineAttr 节点下没有包含 attrId 节点");
+
+        if (businessMachineAttr.getString("attrId").startsWith("-")) {
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "attrId 错误,不能自动生成(必须已经存在的attrId)" + businessMachineAttr);
+        }
+        //自动插入DEL
+        autoSaveDelBusinessMachineAttr(business, businessMachineAttr);
+    }
+
+    public IMachineAttrServiceDao getMachineAttrServiceDaoImpl() {
+        return machineAttrServiceDaoImpl;
+    }
+
+    public void setMachineAttrServiceDaoImpl(IMachineAttrServiceDao machineAttrServiceDaoImpl) {
+        this.machineAttrServiceDaoImpl = machineAttrServiceDaoImpl;
+    }
+}

+ 175 - 0
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/listener/machineAttr/SaveMachineAttrInfoListener.java

@@ -0,0 +1,175 @@
+package com.java110.hardwareAdapation.listener.machineAttr;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.entity.center.Business;
+import com.java110.hardwareAdapation.dao.IMachineAttrServiceDao;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.util.Assert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 保存 设备属性信息 侦听
+ * Created by wuxw on 2018/5/18.
+ */
+@Java110Listener("saveMachineAttrInfoListener")
+@Transactional
+public class SaveMachineAttrInfoListener extends AbstractMachineAttrBusinessServiceDataFlowListener{
+
+    private static Logger logger = LoggerFactory.getLogger(SaveMachineAttrInfoListener.class);
+
+    @Autowired
+    private IMachineAttrServiceDao machineAttrServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 0;
+    }
+
+    @Override
+    public String getBusinessTypeCd() {
+        return BusinessTypeConstant.BUSINESS_TYPE_SAVE_MACHINE;
+    }
+
+    /**
+     * 保存设备属性信息 business 表中
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+        //处理 businessMachineAttr 节点
+        if(data.containsKey("businessMachineAttr")){
+            Object bObj = data.get("businessMachineAttr");
+            JSONArray businessMachineAttrs = null;
+            if(bObj instanceof JSONObject){
+                businessMachineAttrs = new JSONArray();
+                businessMachineAttrs.add(bObj);
+            }else {
+                businessMachineAttrs = (JSONArray)bObj;
+            }
+            //JSONObject businessMachineAttr = data.getJSONObject("businessMachineAttr");
+            for (int bMachineAttrIndex = 0; bMachineAttrIndex < businessMachineAttrs.size();bMachineAttrIndex++) {
+                JSONObject businessMachineAttr = businessMachineAttrs.getJSONObject(bMachineAttrIndex);
+                doBusinessMachineAttr(business, businessMachineAttr);
+                if(bObj instanceof JSONObject) {
+                    dataFlowContext.addParamOut("attrId", businessMachineAttr.getString("attrId"));
+                }
+            }
+        }
+    }
+
+    /**
+     * 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> businessMachineAttrInfo = machineAttrServiceDaoImpl.getBusinessMachineAttrInfo(info);
+        if( businessMachineAttrInfo != null && businessMachineAttrInfo.size() >0) {
+            reFreshShareColumn(info, businessMachineAttrInfo.get(0));
+            machineAttrServiceDaoImpl.saveMachineAttrInfoInstance(info);
+            if(businessMachineAttrInfo.size() == 1) {
+                dataFlowContext.addParamOut("attrId", businessMachineAttrInfo.get(0).get("attr_id"));
+            }
+        }
+    }
+
+
+    /**
+     * 刷 分片字段
+     *
+     * @param info         查询对象
+     * @param businessInfo 小区ID
+     */
+    private void reFreshShareColumn(Map info, Map businessInfo) {
+
+        if (info.containsKey("communityId")) {
+            return;
+        }
+
+        if (!businessInfo.containsKey("community_id")) {
+            return;
+        }
+
+        info.put("communityId", businessInfo.get("community_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> machineAttrInfo = machineAttrServiceDaoImpl.getMachineAttrInfo(info);
+        if(machineAttrInfo != null && machineAttrInfo.size() > 0){
+            reFreshShareColumn(paramIn, machineAttrInfo.get(0));
+            machineAttrServiceDaoImpl.updateMachineAttrInfoInstance(paramIn);
+        }
+    }
+
+
+
+    /**
+     * 处理 businessMachineAttr 节点
+     * @param business 总的数据节点
+     * @param businessMachineAttr 设备属性节点
+     */
+    private void doBusinessMachineAttr(Business business,JSONObject businessMachineAttr){
+
+        Assert.jsonObjectHaveKey(businessMachineAttr,"attrId","businessMachineAttr 节点下没有包含 attrId 节点");
+
+        if(businessMachineAttr.getString("attrId").startsWith("-")){
+            //刷新缓存
+            //flushMachineAttrId(business.getDatas());
+
+            businessMachineAttr.put("attrId",GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_attrId));
+
+        }
+
+        businessMachineAttr.put("bId",business.getbId());
+        businessMachineAttr.put("operate", StatusConstant.OPERATE_ADD);
+        //保存设备属性信息
+        machineAttrServiceDaoImpl.saveBusinessMachineAttrInfo(businessMachineAttr);
+
+    }
+
+    public IMachineAttrServiceDao getMachineAttrServiceDaoImpl() {
+        return machineAttrServiceDaoImpl;
+    }
+
+    public void setMachineAttrServiceDaoImpl(IMachineAttrServiceDao machineAttrServiceDaoImpl) {
+        this.machineAttrServiceDaoImpl = machineAttrServiceDaoImpl;
+    }
+}

+ 190 - 0
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/listener/machineAttr/UpdateMachineAttrInfoListener.java

@@ -0,0 +1,190 @@
+package com.java110.hardwareAdapation.listener.machineAttr;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+import com.java110.hardwareAdapation.dao.IMachineAttrServiceDao;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.exception.ListenerExecuteException;
+import com.java110.utils.util.Assert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 修改设备属性信息 侦听
+ * <p>
+ * 处理节点
+ * 1、businessMachineAttr:{} 设备属性基本信息节点
+ * 2、businessMachineAttrAttr:[{}] 设备属性属性信息节点
+ * 3、businessMachineAttrPhoto:[{}] 设备属性照片信息节点
+ * 4、businessMachineAttrCerdentials:[{}] 设备属性证件信息节点
+ * 协议地址 :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("updateMachineAttrInfoListener")
+@Transactional
+public class UpdateMachineAttrInfoListener extends AbstractMachineAttrBusinessServiceDataFlowListener {
+
+    private static Logger logger = LoggerFactory.getLogger(UpdateMachineAttrInfoListener.class);
+    @Autowired
+    private IMachineAttrServiceDao machineAttrServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 2;
+    }
+
+    @Override
+    public String getBusinessTypeCd() {
+        return BusinessTypeConstant.BUSINESS_TYPE_UPDATE_MACHINE;
+    }
+
+    /**
+     * business过程
+     *
+     * @param dataFlowContext 上下文对象
+     * @param business        业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data, "没有datas 节点,或没有子节点需要处理");
+
+        //处理 businessMachineAttr 节点
+        if (data.containsKey("businessMachineAttr")) {
+            //处理 businessMachineAttr 节点
+            if (data.containsKey("businessMachineAttr")) {
+                Object _obj = data.get("businessMachineAttr");
+                JSONArray businessMachineAttrs = null;
+                if (_obj instanceof JSONObject) {
+                    businessMachineAttrs = new JSONArray();
+                    businessMachineAttrs.add(_obj);
+                } else {
+                    businessMachineAttrs = (JSONArray) _obj;
+                }
+                //JSONObject businessMachineAttr = data.getJSONObject("businessMachineAttr");
+                for (int _machineAttrIndex = 0; _machineAttrIndex < businessMachineAttrs.size(); _machineAttrIndex++) {
+                    JSONObject businessMachineAttr = businessMachineAttrs.getJSONObject(_machineAttrIndex);
+                    doBusinessMachineAttr(business, businessMachineAttr);
+                    if (_obj instanceof JSONObject) {
+                        dataFlowContext.addParamOut("attrId", businessMachineAttr.getString("attrId"));
+                    }
+                }
+            }
+        }
+    }
+
+
+    /**
+     * 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> businessMachineAttrInfos = machineAttrServiceDaoImpl.getBusinessMachineAttrInfo(info);
+        if (businessMachineAttrInfos != null && businessMachineAttrInfos.size() > 0) {
+            for (int _machineAttrIndex = 0; _machineAttrIndex < businessMachineAttrInfos.size(); _machineAttrIndex++) {
+                Map businessMachineAttrInfo = businessMachineAttrInfos.get(_machineAttrIndex);
+                flushBusinessMachineAttrInfo(businessMachineAttrInfo, StatusConstant.STATUS_CD_VALID);
+                machineAttrServiceDaoImpl.updateMachineAttrInfoInstance(businessMachineAttrInfo);
+                if (businessMachineAttrInfo.size() == 1) {
+                    dataFlowContext.addParamOut("attrId", businessMachineAttrInfo.get("attr_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> machineAttrInfo = machineAttrServiceDaoImpl.getMachineAttrInfo(info);
+        if (machineAttrInfo != null && machineAttrInfo.size() > 0) {
+
+            //设备属性信息
+            List<Map> businessMachineAttrInfos = machineAttrServiceDaoImpl.getBusinessMachineAttrInfo(delInfo);
+            //除非程序出错了,这里不会为空
+            if (businessMachineAttrInfos == null || businessMachineAttrInfos.size() == 0) {
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR, "撤单失败(machineAttr),程序内部异常,请检查! " + delInfo);
+            }
+            for (int _machineAttrIndex = 0; _machineAttrIndex < businessMachineAttrInfos.size(); _machineAttrIndex++) {
+                Map businessMachineAttrInfo = businessMachineAttrInfos.get(_machineAttrIndex);
+                flushBusinessMachineAttrInfo(businessMachineAttrInfo, StatusConstant.STATUS_CD_VALID);
+                machineAttrServiceDaoImpl.updateMachineAttrInfoInstance(businessMachineAttrInfo);
+            }
+        }
+
+    }
+
+
+    /**
+     * 处理 businessMachineAttr 节点
+     *
+     * @param business            总的数据节点
+     * @param businessMachineAttr 设备属性节点
+     */
+    private void doBusinessMachineAttr(Business business, JSONObject businessMachineAttr) {
+
+        Assert.jsonObjectHaveKey(businessMachineAttr, "attrId", "businessMachineAttr 节点下没有包含 attrId 节点");
+
+        if (businessMachineAttr.getString("attrId").startsWith("-")) {
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "attrId 错误,不能自动生成(必须已经存在的attrId)" + businessMachineAttr);
+        }
+        //自动保存DEL
+        autoSaveDelBusinessMachineAttr(business, businessMachineAttr);
+
+        businessMachineAttr.put("bId", business.getbId());
+        businessMachineAttr.put("operate", StatusConstant.OPERATE_ADD);
+        //保存设备属性信息
+        machineAttrServiceDaoImpl.saveBusinessMachineAttrInfo(businessMachineAttr);
+
+    }
+
+
+    public IMachineAttrServiceDao getMachineAttrServiceDaoImpl() {
+        return machineAttrServiceDaoImpl;
+    }
+
+    public void setMachineAttrServiceDaoImpl(IMachineAttrServiceDao machineAttrServiceDaoImpl) {
+        this.machineAttrServiceDaoImpl = machineAttrServiceDaoImpl;
+    }
+
+
+}

+ 70 - 0
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/smo/impl/MachineAttrInnerServiceSMOImpl.java

@@ -0,0 +1,70 @@
+package com.java110.hardwareAdapation.smo.impl;
+
+
+import com.java110.core.base.smo.BaseServiceSMO;
+import com.java110.core.smo.hardwareAdapation.IMachineAttrInnerServiceSMO;
+import com.java110.core.smo.user.IUserInnerServiceSMO;
+import com.java110.dto.PageDto;
+import com.java110.dto.hardwareAdapation.MachineAttrDto;
+import com.java110.hardwareAdapation.dao.IMachineAttrServiceDao;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @ClassName FloorInnerServiceSMOImpl
+ * @Description 设备属性内部服务实现类
+ * @Author wuxw
+ * @Date 2019/4/24 9:20
+ * @Version 1.0
+ * add by wuxw 2019/4/24
+ **/
+@RestController
+public class MachineAttrInnerServiceSMOImpl extends BaseServiceSMO implements IMachineAttrInnerServiceSMO {
+
+    @Autowired
+    private IMachineAttrServiceDao machineAttrServiceDaoImpl;
+
+    @Autowired
+    private IUserInnerServiceSMO userInnerServiceSMOImpl;
+
+    @Override
+    public List<MachineAttrDto> queryMachineAttrs(@RequestBody MachineAttrDto machineAttrDto) {
+
+        //校验是否传了 分页信息
+
+        int page = machineAttrDto.getPage();
+
+        if (page != PageDto.DEFAULT_PAGE) {
+            machineAttrDto.setPage((page - 1) * machineAttrDto.getRow());
+        }
+
+        List<MachineAttrDto> machineAttrs = BeanConvertUtil.covertBeanList(machineAttrServiceDaoImpl.getMachineAttrInfo(BeanConvertUtil.beanCovertMap(machineAttrDto)), MachineAttrDto.class);
+
+        return machineAttrs;
+    }
+
+    @Override
+    public int queryMachineAttrsCount(@RequestBody MachineAttrDto machineAttrDto) {
+        return machineAttrServiceDaoImpl.queryMachineAttrsCount(BeanConvertUtil.beanCovertMap(machineAttrDto));
+    }
+
+    public IMachineAttrServiceDao getMachineAttrServiceDaoImpl() {
+        return machineAttrServiceDaoImpl;
+    }
+
+    public void setMachineAttrServiceDaoImpl(IMachineAttrServiceDao machineAttrServiceDaoImpl) {
+        this.machineAttrServiceDaoImpl = machineAttrServiceDaoImpl;
+    }
+
+    public IUserInnerServiceSMO getUserInnerServiceSMOImpl() {
+        return userInnerServiceSMOImpl;
+    }
+
+    public void setUserInnerServiceSMOImpl(IUserInnerServiceSMO userInnerServiceSMOImpl) {
+        this.userInnerServiceSMOImpl = userInnerServiceSMOImpl;
+    }
+}

+ 114 - 0
docs/document/services/machine/DeleteMachineAttrInfo.md

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

+ 122 - 0
docs/document/services/machine/SaveMachineAttrInfo.md

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

+ 122 - 0
docs/document/services/machine/UpdateMachineAttrInfo.md

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

+ 86 - 0
java110-bean/src/main/java/com/java110/dto/hardwareAdapation/MachineAttrDto.java

@@ -0,0 +1,86 @@
+package com.java110.dto.hardwareAdapation;
+
+import com.java110.dto.PageDto;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @ClassName FloorDto
+ * @Description 设备属性数据层封装
+ * @Author wuxw
+ * @Date 2019/4/24 8:52
+ * @Version 1.0
+ * add by wuxw 2019/4/24
+ **/
+public class MachineAttrDto extends PageDto implements Serializable {
+
+    private String machineId;
+    private String attrId;
+    private String specCd;
+    private String communityId;
+    private String value;
+
+
+    private Date createTime;
+
+    private String statusCd = "0";
+
+
+    public String getMachineId() {
+        return machineId;
+    }
+
+    public void setMachineId(String machineId) {
+        this.machineId = machineId;
+    }
+
+    public String getAttrId() {
+        return attrId;
+    }
+
+    public void setAttrId(String attrId) {
+        this.attrId = attrId;
+    }
+
+    public String getSpecCd() {
+        return specCd;
+    }
+
+    public void setSpecCd(String specCd) {
+        this.specCd = specCd;
+    }
+
+    public String getCommunityId() {
+        return communityId;
+    }
+
+    public void setCommunityId(String communityId) {
+        this.communityId = communityId;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getStatusCd() {
+        return statusCd;
+    }
+
+    public void setStatusCd(String statusCd) {
+        this.statusCd = statusCd;
+    }
+}

+ 80 - 0
java110-code-generator/src/main/java/com/java110/MachineAttrGeneratorApplication.java

@@ -0,0 +1,80 @@
+package com.java110;
+
+
+import com.java110.code.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Hello world!
+ */
+public class MachineAttrGeneratorApplication {
+
+    protected MachineAttrGeneratorApplication() {
+        // prevents calls from subclass
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * 代码生成器 入口方法
+     *
+     * @param args 参数
+     */
+    public static void main(String[] args) {
+        Data data = new Data();
+        data.setId("attrId");
+        data.setName("machineAttr");
+        data.setDesc("设备属性");
+        data.setShareParam("communityId");
+        data.setShareColumn("community_id");
+        data.setNewBusinessTypeCd("BUSINESS_TYPE_SAVE_MACHINE");
+        data.setUpdateBusinessTypeCd("BUSINESS_TYPE_UPDATE_MACHINE");
+        data.setDeleteBusinessTypeCd("BUSINESS_TYPE_DELETE_MACHINE");
+        data.setNewBusinessTypeCdValue("200200030001");
+        data.setUpdateBusinessTypeCdValue("200200040001");
+        data.setDeleteBusinessTypeCdValue("200200050001");
+        data.setBusinessTableName("business_machine_attrs");
+        data.setTableName("machine_attrs");
+        Map<String, String> param = new HashMap<String, String>();
+        param.put("machineId", "machine_id");
+        param.put("communityId", "community_id");
+        param.put("bId", "b_id");
+        param.put("attrId", "attr_id");
+        param.put("specCd", "spec_cd");
+        param.put("value", "value");
+        param.put("statusCd", "status_cd");
+        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);
+
+        GeneratorInnerServiceSMOImpl generatorInnerServiceSMOImpl = new GeneratorInnerServiceSMOImpl();
+        generatorInnerServiceSMOImpl.generator(data);
+
+        GeneratorDtoBean generatorDtoBean = new GeneratorDtoBean();
+        generatorDtoBean.generator(data);
+
+        GeneratorIInnerServiceSMO generatorIInnerServiceSMO = new GeneratorIInnerServiceSMO();
+        generatorIInnerServiceSMO.generator(data);
+    }
+}

+ 41 - 0
java110-core/src/main/java/com/java110/core/smo/hardwareAdapation/IMachineAttrInnerServiceSMO.java

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

+ 171 - 0
java110-db/src/main/resources/mapper/hardwareAdapation/MachineAttrServiceDaoImplMapper.xml

@@ -0,0 +1,171 @@
+<?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="machineAttrServiceDaoImpl">
+
+    <!-- 保存设备属性信息 add by wuxw 2018-07-03 -->
+       <insert id="saveBusinessMachineAttrInfo" parameterType="Map">
+           insert into business_machine_attrs(
+machine_id,attr_id,operate,spec_cd,community_id,b_id,value
+) values (
+#{machineId},#{attrId},#{operate},#{specCd},#{communityId},#{bId},#{value}
+)
+       </insert>
+
+
+       <!-- 查询设备属性信息(Business) add by wuxw 2018-07-03 -->
+       <select id="getBusinessMachineAttrInfo" parameterType="Map" resultType="Map">
+           select  t.machine_id,t.machine_id machineId,t.attr_id,t.attr_id attrId,t.operate,t.spec_cd,t.spec_cd specCd,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.value 
+from business_machine_attrs t 
+where 1 =1 
+<if test="machineId !=null and machineId != ''">
+   and t.machine_id= #{machineId}
+</if> 
+<if test="attrId !=null and attrId != ''">
+   and t.attr_id= #{attrId}
+</if> 
+<if test="operate !=null and operate != ''">
+   and t.operate= #{operate}
+</if> 
+<if test="specCd !=null and specCd != ''">
+   and t.spec_cd= #{specCd}
+</if> 
+<if test="communityId !=null and communityId != ''">
+   and t.community_id= #{communityId}
+</if> 
+<if test="bId !=null and bId != ''">
+   and t.b_id= #{bId}
+</if> 
+<if test="value !=null and value != ''">
+   and t.value= #{value}
+</if> 
+
+       </select>
+
+
+
+
+
+    <!-- 保存设备属性信息至 instance表中 add by wuxw 2018-07-03 -->
+    <insert id="saveMachineAttrInfoInstance" parameterType="Map">
+        insert into machine_attrs(
+machine_id,attr_id,spec_cd,status_cd,community_id,b_id,value
+) select t.machine_id,t.attr_id,t.spec_cd,'0',t.community_id,t.b_id,t.value from business_machine_attrs t where 1=1
+<if test="machineId !=null and machineId != ''">
+   and t.machine_id= #{machineId}
+</if> 
+<if test="attrId !=null and attrId != ''">
+   and t.attr_id= #{attrId}
+</if> 
+   and t.operate= 'ADD'
+<if test="specCd !=null and specCd != ''">
+   and t.spec_cd= #{specCd}
+</if> 
+<if test="communityId !=null and communityId != ''">
+   and t.community_id= #{communityId}
+</if> 
+<if test="bId !=null and bId != ''">
+   and t.b_id= #{bId}
+</if> 
+<if test="value !=null and value != ''">
+   and t.value= #{value}
+</if> 
+
+    </insert>
+
+
+
+    <!-- 查询设备属性信息 add by wuxw 2018-07-03 -->
+    <select id="getMachineAttrInfo" parameterType="Map" resultType="Map">
+        select  t.machine_id,t.machine_id machineId,t.attr_id,t.attr_id attrId,t.spec_cd,t.spec_cd specCd,t.status_cd,t.status_cd statusCd,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.value 
+from machine_attrs t 
+where 1 =1 
+<if test="machineId !=null and machineId != ''">
+   and t.machine_id= #{machineId}
+</if> 
+<if test="attrId !=null and attrId != ''">
+   and t.attr_id= #{attrId}
+</if> 
+<if test="specCd !=null and specCd != ''">
+   and t.spec_cd= #{specCd}
+</if> 
+<if test="statusCd !=null and statusCd != ''">
+   and t.status_cd= #{statusCd}
+</if> 
+<if test="communityId !=null and communityId != ''">
+   and t.community_id= #{communityId}
+</if> 
+<if test="bId !=null and bId != ''">
+   and t.b_id= #{bId}
+</if> 
+<if test="value !=null and value != ''">
+   and t.value= #{value}
+</if> 
+<if test="page != -1 and page != null ">
+   limit #{page}, #{row}
+</if> 
+
+    </select>
+
+
+
+
+    <!-- 修改设备属性信息 add by wuxw 2018-07-03 -->
+    <update id="updateMachineAttrInfoInstance" parameterType="Map">
+        update  machine_attrs t set t.status_cd = #{statusCd}
+<if test="newBId != null and newBId != ''">
+,t.b_id = #{newBId}
+</if> 
+<if test="machineId !=null and machineId != ''">
+, t.machine_id= #{machineId}
+</if> 
+<if test="specCd !=null and specCd != ''">
+, t.spec_cd= #{specCd}
+</if> 
+<if test="communityId !=null and communityId != ''">
+, t.community_id= #{communityId}
+</if> 
+<if test="value !=null and value != ''">
+, t.value= #{value}
+</if> 
+ where 1=1 <if test="attrId !=null and attrId != ''">
+and t.attr_id= #{attrId}
+</if> 
+<if test="bId !=null and bId != ''">
+and t.b_id= #{bId}
+</if> 
+
+    </update>
+
+    <!-- 查询设备属性数量 add by wuxw 2018-07-03 -->
+     <select id="queryMachineAttrsCount" parameterType="Map" resultType="Map">
+        select  count(1) count 
+from machine_attrs t 
+where 1 =1 
+<if test="machineId !=null and machineId != ''">
+   and t.machine_id= #{machineId}
+</if> 
+<if test="attrId !=null and attrId != ''">
+   and t.attr_id= #{attrId}
+</if> 
+<if test="specCd !=null and specCd != ''">
+   and t.spec_cd= #{specCd}
+</if> 
+<if test="statusCd !=null and statusCd != ''">
+   and t.status_cd= #{statusCd}
+</if> 
+<if test="communityId !=null and communityId != ''">
+   and t.community_id= #{communityId}
+</if> 
+<if test="bId !=null and bId != ''">
+   and t.b_id= #{bId}
+</if> 
+<if test="value !=null and value != ''">
+   and t.value= #{value}
+</if> 
+
+
+     </select>
+
+</mapper>