| New file |
| | |
| | | package com.java110.common.listener.machineAuth; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | 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 com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.common.dao.IMachineAuthServiceDao; |
| | | 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; |
| | | |
| | | /** |
| | | * 删除设备权限信息 侦听 |
| | | * |
| | | * 处理节点 |
| | | * 1、businessMachineAuth:{} 设备权限基本信息节点 |
| | | * 2、businessMachineAuthAttr:[{}] 设备权限属性信息节点 |
| | | * 3、businessMachineAuthPhoto:[{}] 设备权限照片信息节点 |
| | | * 4、businessMachineAuthCerdentials:[{}] 设备权限证件信息节点 |
| | | * 协议地址 :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("deleteMachineAuthInfoListener") |
| | | @Transactional |
| | | public class DeleteMachineAuthInfoListener extends AbstractMachineAuthBusinessServiceDataFlowListener { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(DeleteMachineAuthInfoListener.class); |
| | | @Autowired |
| | | IMachineAuthServiceDao machineAuthServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 3; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_DELETE_MACHINE_AUTH; |
| | | } |
| | | |
| | | /** |
| | | * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessMachineAuth 节点 |
| | | if(data.containsKey(MachineAuthPo.class.getSimpleName())){ |
| | | Object _obj = data.get(MachineAuthPo.class.getSimpleName()); |
| | | JSONArray businessMachineAuths = null; |
| | | if(_obj instanceof JSONObject){ |
| | | businessMachineAuths = new JSONArray(); |
| | | businessMachineAuths.add(_obj); |
| | | }else { |
| | | businessMachineAuths = (JSONArray)_obj; |
| | | } |
| | | //JSONObject businessMachineAuth = data.getJSONObject(MachineAuthPo.class.getSimpleName()); |
| | | for (int _machineAuthIndex = 0; _machineAuthIndex < businessMachineAuths.size();_machineAuthIndex++) { |
| | | JSONObject businessMachineAuth = businessMachineAuths.getJSONObject(_machineAuthIndex); |
| | | doBusinessMachineAuth(business, businessMachineAuth); |
| | | if(_obj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("authId", businessMachineAuth.getString("authId")); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 删除 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> businessMachineAuthInfos = machineAuthServiceDaoImpl.getBusinessMachineAuthInfo(info); |
| | | if( businessMachineAuthInfos != null && businessMachineAuthInfos.size() >0) { |
| | | for (int _machineAuthIndex = 0; _machineAuthIndex < businessMachineAuthInfos.size();_machineAuthIndex++) { |
| | | Map businessMachineAuthInfo = businessMachineAuthInfos.get(_machineAuthIndex); |
| | | flushBusinessMachineAuthInfo(businessMachineAuthInfo,StatusConstant.STATUS_CD_INVALID); |
| | | machineAuthServiceDaoImpl.updateMachineAuthInfoInstance(businessMachineAuthInfo); |
| | | dataFlowContext.addParamOut("authId",businessMachineAuthInfo.get("auth_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> machineAuthInfo = machineAuthServiceDaoImpl.getMachineAuthInfo(info); |
| | | if(machineAuthInfo != null && machineAuthInfo.size() > 0){ |
| | | |
| | | //设备权限信息 |
| | | List<Map> businessMachineAuthInfos = machineAuthServiceDaoImpl.getBusinessMachineAuthInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessMachineAuthInfos == null || businessMachineAuthInfos.size() == 0){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(machineAuth),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | for (int _machineAuthIndex = 0; _machineAuthIndex < businessMachineAuthInfos.size();_machineAuthIndex++) { |
| | | Map businessMachineAuthInfo = businessMachineAuthInfos.get(_machineAuthIndex); |
| | | flushBusinessMachineAuthInfo(businessMachineAuthInfo,StatusConstant.STATUS_CD_VALID); |
| | | machineAuthServiceDaoImpl.updateMachineAuthInfoInstance(businessMachineAuthInfo); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessMachineAuth 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessMachineAuth 设备权限节点 |
| | | */ |
| | | private void doBusinessMachineAuth(Business business,JSONObject businessMachineAuth){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessMachineAuth,"authId","businessMachineAuth 节点下没有包含 authId 节点"); |
| | | |
| | | if(businessMachineAuth.getString("authId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"authId 错误,不能自动生成(必须已经存在的authId)"+businessMachineAuth); |
| | | } |
| | | //自动插入DEL |
| | | autoSaveDelBusinessMachineAuth(business,businessMachineAuth); |
| | | } |
| | | @Override |
| | | public IMachineAuthServiceDao getMachineAuthServiceDaoImpl() { |
| | | return machineAuthServiceDaoImpl; |
| | | } |
| | | |
| | | public void setMachineAuthServiceDaoImpl(IMachineAuthServiceDao machineAuthServiceDaoImpl) { |
| | | this.machineAuthServiceDaoImpl = machineAuthServiceDaoImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.common.listener.machineAuth; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.utils.constant.BusinessTypeConstant; |
| | | import com.java110.utils.constant.StatusConstant; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.common.dao.IMachineAuthServiceDao; |
| | | 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("saveMachineAuthInfoListener") |
| | | @Transactional |
| | | public class SaveMachineAuthInfoListener extends AbstractMachineAuthBusinessServiceDataFlowListener{ |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(SaveMachineAuthInfoListener.class); |
| | | |
| | | @Autowired |
| | | private IMachineAuthServiceDao machineAuthServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_SAVE_MACHINE_AUTH; |
| | | } |
| | | |
| | | /** |
| | | * 保存设备权限信息 business 表中 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessMachineAuth 节点 |
| | | if(data.containsKey(MachineAuthPo.class.getSimpleName())){ |
| | | Object bObj = data.get(MachineAuthPo.class.getSimpleName()); |
| | | JSONArray businessMachineAuths = null; |
| | | if(bObj instanceof JSONObject){ |
| | | businessMachineAuths = new JSONArray(); |
| | | businessMachineAuths.add(bObj); |
| | | }else { |
| | | businessMachineAuths = (JSONArray)bObj; |
| | | } |
| | | //JSONObject businessMachineAuth = data.getJSONObject(MachineAuthPo.class.getSimpleName()); |
| | | for (int bMachineAuthIndex = 0; bMachineAuthIndex < businessMachineAuths.size();bMachineAuthIndex++) { |
| | | JSONObject businessMachineAuth = businessMachineAuths.getJSONObject(bMachineAuthIndex); |
| | | doBusinessMachineAuth(business, businessMachineAuth); |
| | | if(bObj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("authId", businessMachineAuth.getString("authId")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 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> businessMachineAuthInfo = machineAuthServiceDaoImpl.getBusinessMachineAuthInfo(info); |
| | | if( businessMachineAuthInfo != null && businessMachineAuthInfo.size() >0) { |
| | | reFreshShareColumn(info, businessMachineAuthInfo.get(0)); |
| | | machineAuthServiceDaoImpl.saveMachineAuthInfoInstance(info); |
| | | if(businessMachineAuthInfo.size() == 1) { |
| | | dataFlowContext.addParamOut("authId", businessMachineAuthInfo.get(0).get("auth_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> machineAuthInfo = machineAuthServiceDaoImpl.getMachineAuthInfo(info); |
| | | if(machineAuthInfo != null && machineAuthInfo.size() > 0){ |
| | | reFreshShareColumn(paramIn, machineAuthInfo.get(0)); |
| | | machineAuthServiceDaoImpl.updateMachineAuthInfoInstance(paramIn); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessMachineAuth 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessMachineAuth 设备权限节点 |
| | | */ |
| | | private void doBusinessMachineAuth(Business business,JSONObject businessMachineAuth){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessMachineAuth,"authId","businessMachineAuth 节点下没有包含 authId 节点"); |
| | | |
| | | if(businessMachineAuth.getString("authId").startsWith("-")){ |
| | | //刷新缓存 |
| | | //flushMachineAuthId(business.getDatas()); |
| | | |
| | | businessMachineAuth.put("authId",GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_authId)); |
| | | |
| | | } |
| | | |
| | | businessMachineAuth.put("bId",business.getbId()); |
| | | businessMachineAuth.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存设备权限信息 |
| | | machineAuthServiceDaoImpl.saveBusinessMachineAuthInfo(businessMachineAuth); |
| | | |
| | | } |
| | | @Override |
| | | public IMachineAuthServiceDao getMachineAuthServiceDaoImpl() { |
| | | return machineAuthServiceDaoImpl; |
| | | } |
| | | |
| | | public void setMachineAuthServiceDaoImpl(IMachineAuthServiceDao machineAuthServiceDaoImpl) { |
| | | this.machineAuthServiceDaoImpl = machineAuthServiceDaoImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.common.listener.machineAuth; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | 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 com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.common.dao.IMachineAuthServiceDao; |
| | | 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; |
| | | |
| | | /** |
| | | * 修改设备权限信息 侦听 |
| | | * |
| | | * 处理节点 |
| | | * 1、businessMachineAuth:{} 设备权限基本信息节点 |
| | | * 2、businessMachineAuthAttr:[{}] 设备权限属性信息节点 |
| | | * 3、businessMachineAuthPhoto:[{}] 设备权限照片信息节点 |
| | | * 4、businessMachineAuthCerdentials:[{}] 设备权限证件信息节点 |
| | | * 协议地址 :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("updateMachineAuthInfoListener") |
| | | @Transactional |
| | | public class UpdateMachineAuthInfoListener extends AbstractMachineAuthBusinessServiceDataFlowListener { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(UpdateMachineAuthInfoListener.class); |
| | | @Autowired |
| | | private IMachineAuthServiceDao machineAuthServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 2; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_UPDATE_MACHINE_AUTH; |
| | | } |
| | | |
| | | /** |
| | | * business过程 |
| | | * @param dataFlowContext 上下文对象 |
| | | * @param business 业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | |
| | | //处理 businessMachineAuth 节点 |
| | | if(data.containsKey(MachineAuthPo.class.getSimpleName())){ |
| | | Object _obj = data.get(MachineAuthPo.class.getSimpleName()); |
| | | JSONArray businessMachineAuths = null; |
| | | if(_obj instanceof JSONObject){ |
| | | businessMachineAuths = new JSONArray(); |
| | | businessMachineAuths.add(_obj); |
| | | }else { |
| | | businessMachineAuths = (JSONArray)_obj; |
| | | } |
| | | //JSONObject businessMachineAuth = data.getJSONObject(MachineAuthPo.class.getSimpleName()); |
| | | for (int _machineAuthIndex = 0; _machineAuthIndex < businessMachineAuths.size();_machineAuthIndex++) { |
| | | JSONObject businessMachineAuth = businessMachineAuths.getJSONObject(_machineAuthIndex); |
| | | doBusinessMachineAuth(business, businessMachineAuth); |
| | | if(_obj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("authId", businessMachineAuth.getString("authId")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 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> businessMachineAuthInfos = machineAuthServiceDaoImpl.getBusinessMachineAuthInfo(info); |
| | | if( businessMachineAuthInfos != null && businessMachineAuthInfos.size() >0) { |
| | | for (int _machineAuthIndex = 0; _machineAuthIndex < businessMachineAuthInfos.size();_machineAuthIndex++) { |
| | | Map businessMachineAuthInfo = businessMachineAuthInfos.get(_machineAuthIndex); |
| | | flushBusinessMachineAuthInfo(businessMachineAuthInfo,StatusConstant.STATUS_CD_VALID); |
| | | machineAuthServiceDaoImpl.updateMachineAuthInfoInstance(businessMachineAuthInfo); |
| | | if(businessMachineAuthInfo.size() == 1) { |
| | | dataFlowContext.addParamOut("authId", businessMachineAuthInfo.get("auth_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> machineAuthInfo = machineAuthServiceDaoImpl.getMachineAuthInfo(info); |
| | | if(machineAuthInfo != null && machineAuthInfo.size() > 0){ |
| | | |
| | | //设备权限信息 |
| | | List<Map> businessMachineAuthInfos = machineAuthServiceDaoImpl.getBusinessMachineAuthInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessMachineAuthInfos == null || businessMachineAuthInfos.size() == 0){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(machineAuth),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | for (int _machineAuthIndex = 0; _machineAuthIndex < businessMachineAuthInfos.size();_machineAuthIndex++) { |
| | | Map businessMachineAuthInfo = businessMachineAuthInfos.get(_machineAuthIndex); |
| | | flushBusinessMachineAuthInfo(businessMachineAuthInfo,StatusConstant.STATUS_CD_VALID); |
| | | machineAuthServiceDaoImpl.updateMachineAuthInfoInstance(businessMachineAuthInfo); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessMachineAuth 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessMachineAuth 设备权限节点 |
| | | */ |
| | | private void doBusinessMachineAuth(Business business,JSONObject businessMachineAuth){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessMachineAuth,"authId","businessMachineAuth 节点下没有包含 authId 节点"); |
| | | |
| | | if(businessMachineAuth.getString("authId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"authId 错误,不能自动生成(必须已经存在的authId)"+businessMachineAuth); |
| | | } |
| | | //自动保存DEL |
| | | autoSaveDelBusinessMachineAuth(business,businessMachineAuth); |
| | | |
| | | businessMachineAuth.put("bId",business.getbId()); |
| | | businessMachineAuth.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存设备权限信息 |
| | | machineAuthServiceDaoImpl.saveBusinessMachineAuthInfo(businessMachineAuth); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public IMachineAuthServiceDao getMachineAuthServiceDaoImpl() { |
| | | return machineAuthServiceDaoImpl; |
| | | } |
| | | |
| | | public void setMachineAuthServiceDaoImpl(IMachineAuthServiceDao machineAuthServiceDaoImpl) { |
| | | this.machineAuthServiceDaoImpl = machineAuthServiceDaoImpl; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.dto.machineAuth; |
| | | |
| | | 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 MachineAuthDto extends PageDto implements Serializable { |
| | | |
| | | private String personName; |
| | | private String machineId; |
| | | private String personId; |
| | | private String startTime; |
| | | private String state; |
| | | private String endTime; |
| | | private String communityId; |
| | | private String personType; |
| | | private String authId; |
| | | |
| | | |
| | | private Date createTime; |
| | | |
| | | private String statusCd = "0"; |
| | | |
| | | |
| | | public String getPersonName() { |
| | | return personName; |
| | | } |
| | | public void setPersonName(String personName) { |
| | | this.personName = personName; |
| | | } |
| | | public String getMachineId() { |
| | | return machineId; |
| | | } |
| | | public void setMachineId(String machineId) { |
| | | this.machineId = machineId; |
| | | } |
| | | public String getPersonId() { |
| | | return personId; |
| | | } |
| | | public void setPersonId(String personId) { |
| | | this.personId = personId; |
| | | } |
| | | public String getStartTime() { |
| | | return startTime; |
| | | } |
| | | public void setStartTime(String startTime) { |
| | | this.startTime = startTime; |
| | | } |
| | | public String getState() { |
| | | return state; |
| | | } |
| | | public void setState(String state) { |
| | | this.state = state; |
| | | } |
| | | public String getEndTime() { |
| | | return endTime; |
| | | } |
| | | public void setEndTime(String endTime) { |
| | | this.endTime = endTime; |
| | | } |
| | | public String getCommunityId() { |
| | | return communityId; |
| | | } |
| | | public void setCommunityId(String communityId) { |
| | | this.communityId = communityId; |
| | | } |
| | | public String getPersonType() { |
| | | return personType; |
| | | } |
| | | public void setPersonType(String personType) { |
| | | this.personType = personType; |
| | | } |
| | | public String getAuthId() { |
| | | return authId; |
| | | } |
| | | public void setAuthId(String authId) { |
| | | this.authId = authId; |
| | | } |
| | | |
| | | |
| | | 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; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.po.machineAuth; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | public class MachineAuthPo implements Serializable { |
| | | |
| | | private String personName; |
| | | private String machineId; |
| | | private String personId; |
| | | private String startTime; |
| | | private String state; |
| | | private String endTime; |
| | | private String communityId; |
| | | private String personType; |
| | | private String authId; |
| | | public String getPersonName() { |
| | | return personName; |
| | | } |
| | | public void setPersonName(String personName) { |
| | | this.personName = personName; |
| | | } |
| | | public String getMachineId() { |
| | | return machineId; |
| | | } |
| | | public void setMachineId(String machineId) { |
| | | this.machineId = machineId; |
| | | } |
| | | public String getPersonId() { |
| | | return personId; |
| | | } |
| | | public void setPersonId(String personId) { |
| | | this.personId = personId; |
| | | } |
| | | public String getStartTime() { |
| | | return startTime; |
| | | } |
| | | public void setStartTime(String startTime) { |
| | | this.startTime = startTime; |
| | | } |
| | | public String getState() { |
| | | return state; |
| | | } |
| | | public void setState(String state) { |
| | | this.state = state; |
| | | } |
| | | public String getEndTime() { |
| | | return endTime; |
| | | } |
| | | public void setEndTime(String endTime) { |
| | | this.endTime = endTime; |
| | | } |
| | | public String getCommunityId() { |
| | | return communityId; |
| | | } |
| | | public void setCommunityId(String communityId) { |
| | | this.communityId = communityId; |
| | | } |
| | | public String getPersonType() { |
| | | return personType; |
| | | } |
| | | public void setPersonType(String personType) { |
| | | this.personType = personType; |
| | | } |
| | | public String getAuthId() { |
| | | return authId; |
| | | } |
| | | public void setAuthId(String authId) { |
| | | this.authId = authId; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | public static final String CODE_PREFIX_userTitleId = "21"; |
| | | public static final String CODE_PREFIX_beId = "22"; |
| | | public static final String CODE_PREFIX_collectionId = "23"; |
| | | public static final String CODE_PREFIX_authId = "23"; |
| | | |
| | | |
| | | |
| New file |
| | |
| | | <?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="machineAuthServiceDaoImpl"> |
| | | |
| | | <!-- 保存设备权限信息 add by wuxw 2018-07-03 --> |
| | | <insert id="saveBusinessMachineAuthInfo" parameterType="Map"> |
| | | insert into business_machine_auth( |
| | | person_name,machine_id,operate,person_id,start_time,state,end_time,community_id,b_id,person_type,auth_id |
| | | ) values ( |
| | | #{personName},#{machineId},#{operate},#{personId},#{startTime},#{state},#{endTime},#{communityId},#{bId},#{personType},#{authId} |
| | | ) |
| | | </insert> |
| | | |
| | | |
| | | <!-- 查询设备权限信息(Business) add by wuxw 2018-07-03 --> |
| | | <select id="getBusinessMachineAuthInfo" parameterType="Map" resultType="Map"> |
| | | select t.person_name,t.person_name personName,t.machine_id,t.machine_id machineId,t.operate,t.person_id,t.person_id personId,t.start_time,t.start_time startTime,t.state,t.end_time,t.end_time endTime,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.person_type,t.person_type personType,t.auth_id,t.auth_id authId |
| | | from business_machine_auth t |
| | | where 1 =1 |
| | | <if test="personName !=null and personName != ''"> |
| | | and t.person_name= #{personName} |
| | | </if> |
| | | <if test="machineId !=null and machineId != ''"> |
| | | and t.machine_id= #{machineId} |
| | | </if> |
| | | <if test="operate !=null and operate != ''"> |
| | | and t.operate= #{operate} |
| | | </if> |
| | | <if test="personId !=null and personId != ''"> |
| | | and t.person_id= #{personId} |
| | | </if> |
| | | <if test="startTime !=null and startTime != ''"> |
| | | and t.start_time= #{startTime} |
| | | </if> |
| | | <if test="state !=null and state != ''"> |
| | | and t.state= #{state} |
| | | </if> |
| | | <if test="endTime !=null and endTime != ''"> |
| | | and t.end_time= #{endTime} |
| | | </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="personType !=null and personType != ''"> |
| | | and t.person_type= #{personType} |
| | | </if> |
| | | <if test="authId !=null and authId != ''"> |
| | | and t.auth_id= #{authId} |
| | | </if> |
| | | |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <!-- 保存设备权限信息至 instance表中 add by wuxw 2018-07-03 --> |
| | | <insert id="saveMachineAuthInfoInstance" parameterType="Map"> |
| | | insert into machine_auth( |
| | | person_name,machine_id,person_id,start_time,status_cd,state,end_time,community_id,b_id,person_type,auth_id |
| | | ) select t.person_name,t.machine_id,t.person_id,t.start_time,'0',t.state,t.end_time,t.community_id,t.b_id,t.person_type,t.auth_id from business_machine_auth t where 1=1 |
| | | <if test="personName !=null and personName != ''"> |
| | | and t.person_name= #{personName} |
| | | </if> |
| | | <if test="machineId !=null and machineId != ''"> |
| | | and t.machine_id= #{machineId} |
| | | </if> |
| | | and t.operate= 'ADD' |
| | | <if test="personId !=null and personId != ''"> |
| | | and t.person_id= #{personId} |
| | | </if> |
| | | <if test="startTime !=null and startTime != ''"> |
| | | and t.start_time= #{startTime} |
| | | </if> |
| | | <if test="state !=null and state != ''"> |
| | | and t.state= #{state} |
| | | </if> |
| | | <if test="endTime !=null and endTime != ''"> |
| | | and t.end_time= #{endTime} |
| | | </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="personType !=null and personType != ''"> |
| | | and t.person_type= #{personType} |
| | | </if> |
| | | <if test="authId !=null and authId != ''"> |
| | | and t.auth_id= #{authId} |
| | | </if> |
| | | |
| | | </insert> |
| | | |
| | | |
| | | |
| | | <!-- 查询设备权限信息 add by wuxw 2018-07-03 --> |
| | | <select id="getMachineAuthInfo" parameterType="Map" resultType="Map"> |
| | | select t.person_name,t.person_name personName,t.machine_id,t.machine_id machineId,t.person_id,t.person_id personId,t.start_time,t.start_time startTime,t.status_cd,t.status_cd statusCd,t.state,t.end_time,t.end_time endTime,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.person_type,t.person_type personType,t.auth_id,t.auth_id authId |
| | | from machine_auth t |
| | | where 1 =1 |
| | | <if test="personName !=null and personName != ''"> |
| | | and t.person_name= #{personName} |
| | | </if> |
| | | <if test="machineId !=null and machineId != ''"> |
| | | and t.machine_id= #{machineId} |
| | | </if> |
| | | <if test="personId !=null and personId != ''"> |
| | | and t.person_id= #{personId} |
| | | </if> |
| | | <if test="startTime !=null and startTime != ''"> |
| | | and t.start_time= #{startTime} |
| | | </if> |
| | | <if test="statusCd !=null and statusCd != ''"> |
| | | and t.status_cd= #{statusCd} |
| | | </if> |
| | | <if test="state !=null and state != ''"> |
| | | and t.state= #{state} |
| | | </if> |
| | | <if test="endTime !=null and endTime != ''"> |
| | | and t.end_time= #{endTime} |
| | | </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="personType !=null and personType != ''"> |
| | | and t.person_type= #{personType} |
| | | </if> |
| | | <if test="authId !=null and authId != ''"> |
| | | and t.auth_id= #{authId} |
| | | </if> |
| | | order by t.create_time desc |
| | | <if test="page != -1 and page != null "> |
| | | limit #{page}, #{row} |
| | | </if> |
| | | |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <!-- 修改设备权限信息 add by wuxw 2018-07-03 --> |
| | | <update id="updateMachineAuthInfoInstance" parameterType="Map"> |
| | | update machine_auth t set t.status_cd = #{statusCd} |
| | | <if test="newBId != null and newBId != ''"> |
| | | ,t.b_id = #{newBId} |
| | | </if> |
| | | <if test="personName !=null and personName != ''"> |
| | | , t.person_name= #{personName} |
| | | </if> |
| | | <if test="machineId !=null and machineId != ''"> |
| | | , t.machine_id= #{machineId} |
| | | </if> |
| | | <if test="personId !=null and personId != ''"> |
| | | , t.person_id= #{personId} |
| | | </if> |
| | | <if test="startTime !=null and startTime != ''"> |
| | | , t.start_time= #{startTime} |
| | | </if> |
| | | <if test="state !=null and state != ''"> |
| | | , t.state= #{state} |
| | | </if> |
| | | <if test="endTime !=null and endTime != ''"> |
| | | , t.end_time= #{endTime} |
| | | </if> |
| | | <if test="communityId !=null and communityId != ''"> |
| | | , t.community_id= #{communityId} |
| | | </if> |
| | | <if test="personType !=null and personType != ''"> |
| | | , t.person_type= #{personType} |
| | | </if> |
| | | where 1=1 <if test="bId !=null and bId != ''"> |
| | | and t.b_id= #{bId} |
| | | </if> |
| | | <if test="authId !=null and authId != ''"> |
| | | and t.auth_id= #{authId} |
| | | </if> |
| | | |
| | | </update> |
| | | |
| | | <!-- 查询设备权限数量 add by wuxw 2018-07-03 --> |
| | | <select id="queryMachineAuthsCount" parameterType="Map" resultType="Map"> |
| | | select count(1) count |
| | | from machine_auth t |
| | | where 1 =1 |
| | | <if test="personName !=null and personName != ''"> |
| | | and t.person_name= #{personName} |
| | | </if> |
| | | <if test="machineId !=null and machineId != ''"> |
| | | and t.machine_id= #{machineId} |
| | | </if> |
| | | <if test="personId !=null and personId != ''"> |
| | | and t.person_id= #{personId} |
| | | </if> |
| | | <if test="startTime !=null and startTime != ''"> |
| | | and t.start_time= #{startTime} |
| | | </if> |
| | | <if test="statusCd !=null and statusCd != ''"> |
| | | and t.status_cd= #{statusCd} |
| | | </if> |
| | | <if test="state !=null and state != ''"> |
| | | and t.state= #{state} |
| | | </if> |
| | | <if test="endTime !=null and endTime != ''"> |
| | | and t.end_time= #{endTime} |
| | | </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="personType !=null and personType != ''"> |
| | | and t.person_type= #{personType} |
| | | </if> |
| | | <if test="authId !=null and authId != ''"> |
| | | and t.auth_id= #{authId} |
| | | </if> |
| | | |
| | | |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | { |
| | | "autoMove": true, |
| | | "id": "attrId", |
| | | "name": "parkingAreaAttr", |
| | | "desc": "单元属性", |
| | | "id": "authId", |
| | | "name": "machineAuth", |
| | | "desc": "设备权限", |
| | | "shareParam": "communityId", |
| | | "shareColumn": "community_id", |
| | | "shareName": "community", |
| | | "newBusinessTypeCd": "BUSINESS_TYPE_SAVE_PARKING_AREA_ATTR", |
| | | "updateBusinessTypeCd": "BUSINESS_TYPE_UPDATE_PARKING_AREA_ATTR", |
| | | "deleteBusinessTypeCd": "BUSINESS_TYPE_DELETE_PARKING_AREA_ATTR", |
| | | "newBusinessTypeCdValue": "541100030002", |
| | | "updateBusinessTypeCdValue": "541100040002", |
| | | "deleteBusinessTypeCdValue": "541100050002", |
| | | "businessTableName": "business_parking_area_attr", |
| | | "tableName": "parking_area_attr", |
| | | "shareName": "common", |
| | | "newBusinessTypeCd": "BUSINESS_TYPE_SAVE_MACHINE_AUTH", |
| | | "updateBusinessTypeCd": "BUSINESS_TYPE_UPDATE_MACHINE_AUTH", |
| | | "deleteBusinessTypeCd": "BUSINESS_TYPE_DELETE_MACHINE_AUTH", |
| | | "newBusinessTypeCdValue": "661100030004", |
| | | "updateBusinessTypeCdValue": "661100040004", |
| | | "deleteBusinessTypeCdValue": "661100050004", |
| | | "businessTableName": "business_machine_auth", |
| | | "tableName": "machine_auth", |
| | | "param": { |
| | | "paId": "pa_id", |
| | | "authId": "auth_id", |
| | | "communityId": "community_id", |
| | | "bId": "b_id", |
| | | "attrId": "attr_id", |
| | | "specCd": "spec_cd", |
| | | "value": "value", |
| | | "machineId": "machine_id", |
| | | "personId": "person_id", |
| | | "personName": "person_name", |
| | | "personType": "person_type", |
| | | "state": "state", |
| | | "startTime": "start_time", |
| | | "endTime": "end_time", |
| | | "statusCd": "status_cd", |
| | | "operate": "operate" |
| | | }, |
| | | "required": [ |
| | | { |
| | | "code": "specCd", |
| | | "msg": "属性不能为空" |
| | | "code": "machineId", |
| | | "msg": "设备不能为空" |
| | | }, |
| | | { |
| | | "code": "personId", |
| | | "msg": "人员不能为空" |
| | | }, |
| | | { |
| | | "code": "personName", |
| | | "msg": "人员名称不能为空" |
| | | }, |
| | | { |
| | | "code": "startTime", |
| | | "msg": "开始时间不能为空" |
| | | }, |
| | | { |
| | | "code": "endTime", |
| | | "msg": "结束时间不能为空" |
| | | } |
| | | ] |
| | | } |
| New file |
| | |
| | | package com.java110.intf.common; |
| | | |
| | | import com.java110.config.feign.FeignConfiguration; |
| | | import com.java110.dto.machineAuth.MachineAuthDto; |
| | | 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 IMachineAuthInnerServiceSMO |
| | | * @Description 设备权限接口类 |
| | | * @Author wuxw |
| | | * @Date 2019/4/24 9:04 |
| | | * @Version 1.0 |
| | | * add by wuxw 2019/4/24 |
| | | **/ |
| | | @FeignClient(name = "common-service", configuration = {FeignConfiguration.class}) |
| | | @RequestMapping("/machineAuthApi") |
| | | public interface IMachineAuthInnerServiceSMO { |
| | | |
| | | /** |
| | | * <p>查询小区楼信息</p> |
| | | * |
| | | * |
| | | * @param machineAuthDto 数据对象分享 |
| | | * @return MachineAuthDto 对象数据 |
| | | */ |
| | | @RequestMapping(value = "/queryMachineAuths", method = RequestMethod.POST) |
| | | List<MachineAuthDto> queryMachineAuths(@RequestBody MachineAuthDto machineAuthDto); |
| | | |
| | | /** |
| | | * 查询<p>小区楼</p>总记录数 |
| | | * |
| | | * @param machineAuthDto 数据对象分享 |
| | | * @return 小区下的小区楼记录数 |
| | | */ |
| | | @RequestMapping(value = "/queryMachineAuthsCount", method = RequestMethod.POST) |
| | | int queryMachineAuthsCount(@RequestBody MachineAuthDto machineAuthDto); |
| | | } |
| | |
| | | public static final String BUSINESS_TYPE_DELETE_ATTENDANCE_CLASSES_ATTR="651100050004"; |
| | | |
| | | |
| | | /** |
| | | * 保存工作流节点 处理员工 ORDER_COMMON_SERVICE_URL |
| | | * 3保存 commonServiceTopic |
| | | */ |
| | | public static final String BUSINESS_TYPE_SAVE_MACHINE_AUTH="661100030004"; |
| | | |
| | | |
| | | /** |
| | | * 修改工作流节点 处理员工 |
| | | * 3保存 |
| | | */ |
| | | public static final String BUSINESS_TYPE_UPDATE_MACHINE_AUTH="661100040004"; |
| | | |
| | | /** |
| | | * 删除工作流节点 处理员工 |
| | | */ |
| | | public static final String BUSINESS_TYPE_DELETE_MACHINE_AUTH="661100050004"; |
| | | |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.utils.constant; |
| | | |
| | | /** |
| | | * 设备权限常量类 |
| | | * Created by wuxw on 2017/5/20. |
| | | */ |
| | | public class ServiceCodeMachineAuthConstant { |
| | | |
| | | /** |
| | | * 添加 设备权限 |
| | | */ |
| | | public static final String ADD_MACHINEAUTH = "machineAuth.saveMachineAuth"; |
| | | |
| | | |
| | | /** |
| | | * 修改 设备权限 |
| | | */ |
| | | public static final String UPDATE_MACHINEAUTH = "machineAuth.updateMachineAuth"; |
| | | /** |
| | | * 删除 设备权限 |
| | | */ |
| | | public static final String DELETE_MACHINEAUTH = "machineAuth.deleteMachineAuth"; |
| | | |
| | | |
| | | /** |
| | | * 查询 设备权限 |
| | | */ |
| | | public static final String LIST_MACHINEAUTHS = "machineAuth.listMachineAuths"; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.api.bmo.machineAuth; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.bmo.IApiBaseBMO; |
| | | import com.java110.core.context.DataFlowContext; |
| | | |
| | | public interface IMachineAuthBMO extends IApiBaseBMO { |
| | | |
| | | |
| | | /** |
| | | * 添加设备权限 |
| | | * @param paramInJson |
| | | * @param dataFlowContext |
| | | * @return |
| | | */ |
| | | void addMachineAuth(JSONObject paramInJson, DataFlowContext dataFlowContext); |
| | | |
| | | /** |
| | | * 添加设备权限信息 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | void updateMachineAuth(JSONObject paramInJson, DataFlowContext dataFlowContext); |
| | | |
| | | /** |
| | | * 删除设备权限 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | void deleteMachineAuth(JSONObject paramInJson, DataFlowContext dataFlowContext); |
| | | |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.api.bmo.machineAuth.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.bmo.ApiBaseBMO; |
| | | import com.java110.api.bmo.machineAuth.IMachineAuthBMO; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.intf.common.IMachineAuthInnerServiceSMO; |
| | | import com.java110.po.machineAuth.MachineAuthPo; |
| | | import com.java110.utils.constant.BusinessTypeConstant; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("machineAuthBMOImpl") |
| | | public class MachineAuthBMOImpl extends ApiBaseBMO implements IMachineAuthBMO { |
| | | |
| | | @Autowired |
| | | private IMachineAuthInnerServiceSMO machineAuthInnerServiceSMOImpl; |
| | | |
| | | /** |
| | | * 添加小区信息 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | public void addMachineAuth(JSONObject paramInJson, DataFlowContext dataFlowContext) { |
| | | |
| | | paramInJson.put("authId", "-1"); |
| | | MachineAuthPo machineAuthPo = BeanConvertUtil.covertBean(paramInJson, MachineAuthPo.class); |
| | | super.insert(dataFlowContext, machineAuthPo, BusinessTypeConstant.BUSINESS_TYPE_SAVE_MACHINE_AUTH); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加活动信息 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | public void updateMachineAuth(JSONObject paramInJson, DataFlowContext dataFlowContext) { |
| | | MachineAuthPo machineAuthPo = BeanConvertUtil.covertBean(paramInJson, MachineAuthPo.class); |
| | | super.update(dataFlowContext, machineAuthPo, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_MACHINE_AUTH); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加小区信息 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param dataFlowContext 数据上下文 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | public void deleteMachineAuth(JSONObject paramInJson, DataFlowContext dataFlowContext) { |
| | | |
| | | MachineAuthPo machineAuthPo = BeanConvertUtil.covertBean(paramInJson, MachineAuthPo.class); |
| | | super.update(dataFlowContext, machineAuthPo, BusinessTypeConstant.BUSINESS_TYPE_DELETE_MACHINE_AUTH); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.api.listener.machine; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.bmo.machineAuth.IMachineAuthBMO; |
| | | import com.java110.api.listener.AbstractServiceApiPlusListener; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.event.service.api.ServiceDataFlowEvent; |
| | | import com.java110.utils.constant.ServiceCodeMachineAuthConstant; |
| | | import com.java110.utils.util.Assert; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpMethod; |
| | | |
| | | |
| | | /** |
| | | * 保存小区侦听 |
| | | * add by wuxw 2019-06-30 |
| | | */ |
| | | @Java110Listener("deleteMachineAuthListener") |
| | | public class DeleteMachineAuthListener extends AbstractServiceApiPlusListener { |
| | | |
| | | @Autowired |
| | | private IMachineAuthBMO machineAuthBMOImpl; |
| | | |
| | | @Override |
| | | protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) { |
| | | //Assert.hasKeyAndValue(reqJson, "xxx", "xxx"); |
| | | |
| | | Assert.hasKeyAndValue(reqJson, "authId", "authId不能为空"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) { |
| | | |
| | | machineAuthBMOImpl.deleteMachineAuth(reqJson, context); |
| | | } |
| | | |
| | | @Override |
| | | public String getServiceCode() { |
| | | return ServiceCodeMachineAuthConstant.DELETE_MACHINEAUTH; |
| | | } |
| | | |
| | | @Override |
| | | public HttpMethod getHttpMethod() { |
| | | return HttpMethod.POST; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.api.listener.machine; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.listener.AbstractServiceApiListener; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.event.service.api.ServiceDataFlowEvent; |
| | | import com.java110.intf.common.IMachineAuthInnerServiceSMO; |
| | | import com.java110.dto.machineAuth.MachineAuthDto; |
| | | import com.java110.utils.constant.ServiceCodeMachineAuthConstant; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 查询小区侦听类 |
| | | */ |
| | | @Java110Listener("listMachineAuthsListener") |
| | | public class ListMachineAuthsListener extends AbstractServiceApiListener { |
| | | |
| | | @Autowired |
| | | private IMachineAuthInnerServiceSMO machineAuthInnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public String getServiceCode() { |
| | | return ServiceCodeMachineAuthConstant.LIST_MACHINEAUTHS; |
| | | } |
| | | |
| | | @Override |
| | | public HttpMethod getHttpMethod() { |
| | | return HttpMethod.GET; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return DEFAULT_ORDER; |
| | | } |
| | | |
| | | |
| | | public IMachineAuthInnerServiceSMO getMachineAuthInnerServiceSMOImpl() { |
| | | return machineAuthInnerServiceSMOImpl; |
| | | } |
| | | |
| | | public void setMachineAuthInnerServiceSMOImpl(IMachineAuthInnerServiceSMO machineAuthInnerServiceSMOImpl) { |
| | | this.machineAuthInnerServiceSMOImpl = machineAuthInnerServiceSMOImpl; |
| | | } |
| | | |
| | | @Override |
| | | protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) { |
| | | super.validatePageInfo(reqJson); |
| | | } |
| | | |
| | | @Override |
| | | protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) { |
| | | |
| | | MachineAuthDto machineAuthDto = BeanConvertUtil.covertBean(reqJson, MachineAuthDto.class); |
| | | |
| | | int count = machineAuthInnerServiceSMOImpl.queryMachineAuthsCount(machineAuthDto); |
| | | |
| | | List<MachineAuthDto> machineAuthDtos = null; |
| | | |
| | | if (count > 0) { |
| | | machineAuthDtos = machineAuthInnerServiceSMOImpl.queryMachineAuths(machineAuthDto); |
| | | } else { |
| | | machineAuthDtos = new ArrayList<>(); |
| | | } |
| | | |
| | | ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, machineAuthDtos); |
| | | |
| | | ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK); |
| | | |
| | | context.setResponseEntity(responseEntity); |
| | | |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.api.listener.machine; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.bmo.machineAuth.IMachineAuthBMO; |
| | | import com.java110.api.listener.AbstractServiceApiPlusListener; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.event.service.api.ServiceDataFlowEvent; |
| | | import com.java110.utils.constant.ServiceCodeMachineAuthConstant; |
| | | import com.java110.utils.util.Assert; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpMethod; |
| | | |
| | | /** |
| | | * 保存商户侦听 |
| | | * add by wuxw 2019-06-30 |
| | | */ |
| | | @Java110Listener("saveMachineAuthListener") |
| | | public class SaveMachineAuthListener extends AbstractServiceApiPlusListener { |
| | | |
| | | @Autowired |
| | | private IMachineAuthBMO machineAuthBMOImpl; |
| | | |
| | | @Override |
| | | protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) { |
| | | //Assert.hasKeyAndValue(reqJson, "xxx", "xxx"); |
| | | |
| | | Assert.hasKeyAndValue(reqJson, "machineId", "请求报文中未包含machineId"); |
| | | Assert.hasKeyAndValue(reqJson, "personId", "请求报文中未包含personId"); |
| | | Assert.hasKeyAndValue(reqJson, "personName", "请求报文中未包含personName"); |
| | | Assert.hasKeyAndValue(reqJson, "startTime", "请求报文中未包含startTime"); |
| | | Assert.hasKeyAndValue(reqJson, "endTime", "请求报文中未包含endTime"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) { |
| | | machineAuthBMOImpl.addMachineAuth(reqJson, context); |
| | | } |
| | | |
| | | @Override |
| | | public String getServiceCode() { |
| | | return ServiceCodeMachineAuthConstant.ADD_MACHINEAUTH; |
| | | } |
| | | |
| | | @Override |
| | | public HttpMethod getHttpMethod() { |
| | | return HttpMethod.POST; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.api.listener.machine; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.bmo.machineAuth.IMachineAuthBMO; |
| | | import com.java110.api.listener.AbstractServiceApiPlusListener; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.event.service.api.ServiceDataFlowEvent; |
| | | import com.java110.utils.constant.ServiceCodeMachineAuthConstant; |
| | | import com.java110.utils.util.Assert; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpMethod; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 保存设备权限侦听 |
| | | * add by wuxw 2019-06-30 |
| | | */ |
| | | @Java110Listener("updateMachineAuthListener") |
| | | public class UpdateMachineAuthListener extends AbstractServiceApiPlusListener { |
| | | |
| | | @Autowired |
| | | private IMachineAuthBMO machineAuthBMOImpl; |
| | | |
| | | @Override |
| | | protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) { |
| | | |
| | | Assert.hasKeyAndValue(reqJson, "authId", "authId不能为空"); |
| | | Assert.hasKeyAndValue(reqJson, "machineId", "请求报文中未包含machineId"); |
| | | Assert.hasKeyAndValue(reqJson, "personId", "请求报文中未包含personId"); |
| | | Assert.hasKeyAndValue(reqJson, "personName", "请求报文中未包含personName"); |
| | | Assert.hasKeyAndValue(reqJson, "startTime", "请求报文中未包含startTime"); |
| | | Assert.hasKeyAndValue(reqJson, "endTime", "请求报文中未包含endTime"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) { |
| | | |
| | | machineAuthBMOImpl.updateMachineAuth(reqJson, context); |
| | | } |
| | | |
| | | @Override |
| | | public String getServiceCode() { |
| | | return ServiceCodeMachineAuthConstant.UPDATE_MACHINEAUTH; |
| | | } |
| | | |
| | | @Override |
| | | public HttpMethod getHttpMethod() { |
| | | return HttpMethod.POST; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.common.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 IMachineAuthServiceDao { |
| | | |
| | | /** |
| | | * 保存 设备权限信息 |
| | | * @param businessMachineAuthInfo 设备权限信息 封装 |
| | | * @throws DAOException 操作数据库异常 |
| | | */ |
| | | void saveBusinessMachineAuthInfo(Map businessMachineAuthInfo) throws DAOException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询设备权限信息(business过程) |
| | | * 根据bId 查询设备权限信息 |
| | | * @param info bId 信息 |
| | | * @return 设备权限信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | List<Map> getBusinessMachineAuthInfo(Map info) throws DAOException; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 保存 设备权限信息 Business数据到 Instance中 |
| | | * @param info |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | void saveMachineAuthInfoInstance(Map info) throws DAOException; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询设备权限信息(instance过程) |
| | | * 根据bId 查询设备权限信息 |
| | | * @param info bId 信息 |
| | | * @return 设备权限信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | List<Map> getMachineAuthInfo(Map info) throws DAOException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 修改设备权限信息 |
| | | * @param info 修改信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | void updateMachineAuthInfoInstance(Map info) throws DAOException; |
| | | |
| | | |
| | | /** |
| | | * 查询设备权限总数 |
| | | * |
| | | * @param info 设备权限信息 |
| | | * @return 设备权限数量 |
| | | */ |
| | | int queryMachineAuthsCount(Map info); |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.common.dao.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.utils.constant.ResponseConstant; |
| | | import com.java110.utils.exception.DAOException; |
| | | import com.java110.utils.util.DateUtil; |
| | | import com.java110.core.base.dao.BaseServiceDao; |
| | | import com.java110.common.dao.IMachineAuthServiceDao; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 设备权限服务 与数据库交互 |
| | | * Created by wuxw on 2017/4/5. |
| | | */ |
| | | @Service("machineAuthServiceDaoImpl") |
| | | //@Transactional |
| | | public class MachineAuthServiceDaoImpl extends BaseServiceDao implements IMachineAuthServiceDao { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(MachineAuthServiceDaoImpl.class); |
| | | |
| | | /** |
| | | * 设备权限信息封装 |
| | | * @param businessMachineAuthInfo 设备权限信息 封装 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | @Override |
| | | public void saveBusinessMachineAuthInfo(Map businessMachineAuthInfo) throws DAOException { |
| | | businessMachineAuthInfo.put("month", DateUtil.getCurrentMonth()); |
| | | // 查询business_user 数据是否已经存在 |
| | | logger.debug("保存设备权限信息 入参 businessMachineAuthInfo : {}",businessMachineAuthInfo); |
| | | int saveFlag = sqlSessionTemplate.insert("machineAuthServiceDaoImpl.saveBusinessMachineAuthInfo",businessMachineAuthInfo); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存设备权限数据失败:"+ JSONObject.toJSONString(businessMachineAuthInfo)); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询设备权限信息 |
| | | * @param info bId 信息 |
| | | * @return 设备权限信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | @Override |
| | | public List<Map> getBusinessMachineAuthInfo(Map info) throws DAOException { |
| | | |
| | | logger.debug("查询设备权限信息 入参 info : {}",info); |
| | | |
| | | List<Map> businessMachineAuthInfos = sqlSessionTemplate.selectList("machineAuthServiceDaoImpl.getBusinessMachineAuthInfo",info); |
| | | |
| | | return businessMachineAuthInfos; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 保存设备权限信息 到 instance |
| | | * @param info bId 信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | @Override |
| | | public void saveMachineAuthInfoInstance(Map info) throws DAOException { |
| | | logger.debug("保存设备权限信息Instance 入参 info : {}",info); |
| | | |
| | | int saveFlag = sqlSessionTemplate.insert("machineAuthServiceDaoImpl.saveMachineAuthInfoInstance",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> getMachineAuthInfo(Map info) throws DAOException { |
| | | logger.debug("查询设备权限信息 入参 info : {}",info); |
| | | |
| | | List<Map> businessMachineAuthInfos = sqlSessionTemplate.selectList("machineAuthServiceDaoImpl.getMachineAuthInfo",info); |
| | | |
| | | return businessMachineAuthInfos; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改设备权限信息 |
| | | * @param info 修改信息 |
| | | * @throws DAOException DAO异常 |
| | | */ |
| | | @Override |
| | | public void updateMachineAuthInfoInstance(Map info) throws DAOException { |
| | | logger.debug("修改设备权限信息Instance 入参 info : {}",info); |
| | | |
| | | int saveFlag = sqlSessionTemplate.update("machineAuthServiceDaoImpl.updateMachineAuthInfoInstance",info); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改设备权限信息Instance数据失败:"+ JSONObject.toJSONString(info)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询设备权限数量 |
| | | * @param info 设备权限信息 |
| | | * @return 设备权限数量 |
| | | */ |
| | | @Override |
| | | public int queryMachineAuthsCount(Map info) { |
| | | logger.debug("查询设备权限数据 入参 info : {}",info); |
| | | |
| | | List<Map> businessMachineAuthInfos = sqlSessionTemplate.selectList("machineAuthServiceDaoImpl.queryMachineAuthsCount", info); |
| | | if (businessMachineAuthInfos.size() < 1) { |
| | | return 0; |
| | | } |
| | | |
| | | return Integer.parseInt(businessMachineAuthInfos.get(0).get("count").toString()); |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.common.listener.machineAuth; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.dao.IMachineAuthServiceDao; |
| | | import com.java110.core.event.service.AbstractBusinessServiceDataFlowListener; |
| | | import com.java110.entity.center.Business; |
| | | 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 AbstractMachineAuthBusinessServiceDataFlowListener extends AbstractBusinessServiceDataFlowListener { |
| | | private static Logger logger = LoggerFactory.getLogger(AbstractMachineAuthBusinessServiceDataFlowListener.class); |
| | | |
| | | |
| | | /** |
| | | * 获取 DAO工具类 |
| | | * |
| | | * @return |
| | | */ |
| | | public abstract IMachineAuthServiceDao getMachineAuthServiceDaoImpl(); |
| | | |
| | | /** |
| | | * 刷新 businessMachineAuthInfo 数据 |
| | | * 主要将 数据库 中字段和 接口传递字段建立关系 |
| | | * |
| | | * @param businessMachineAuthInfo |
| | | */ |
| | | protected void flushBusinessMachineAuthInfo(Map businessMachineAuthInfo, String statusCd) { |
| | | businessMachineAuthInfo.put("newBId", businessMachineAuthInfo.get("b_id")); |
| | | businessMachineAuthInfo.put("personName", businessMachineAuthInfo.get("person_name")); |
| | | businessMachineAuthInfo.put("machineId", businessMachineAuthInfo.get("machine_id")); |
| | | businessMachineAuthInfo.put("operate", businessMachineAuthInfo.get("operate")); |
| | | businessMachineAuthInfo.put("personId", businessMachineAuthInfo.get("person_id")); |
| | | businessMachineAuthInfo.put("startTime", businessMachineAuthInfo.get("start_time")); |
| | | businessMachineAuthInfo.put("state", businessMachineAuthInfo.get("state")); |
| | | businessMachineAuthInfo.put("endTime", businessMachineAuthInfo.get("end_time")); |
| | | businessMachineAuthInfo.put("communityId", businessMachineAuthInfo.get("community_id")); |
| | | businessMachineAuthInfo.put("personType", businessMachineAuthInfo.get("person_type")); |
| | | businessMachineAuthInfo.put("authId", businessMachineAuthInfo.get("auth_id")); |
| | | businessMachineAuthInfo.remove("bId"); |
| | | businessMachineAuthInfo.put("statusCd", statusCd); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中 |
| | | * |
| | | * @param businessMachineAuth 设备权限信息 |
| | | */ |
| | | protected void autoSaveDelBusinessMachineAuth(Business business, JSONObject businessMachineAuth) { |
| | | //自动插入DEL |
| | | Map info = new HashMap(); |
| | | info.put("authId", businessMachineAuth.getString("authId")); |
| | | info.put("statusCd", StatusConstant.STATUS_CD_VALID); |
| | | List<Map> currentMachineAuthInfos = getMachineAuthServiceDaoImpl().getMachineAuthInfo(info); |
| | | if (currentMachineAuthInfos == null || currentMachineAuthInfos.size() != 1) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "未找到需要修改数据信息,入参错误或数据有问题,请检查" + info); |
| | | } |
| | | |
| | | Map currentMachineAuthInfo = currentMachineAuthInfos.get(0); |
| | | |
| | | currentMachineAuthInfo.put("bId", business.getbId()); |
| | | |
| | | currentMachineAuthInfo.put("personName", currentMachineAuthInfo.get("person_name")); |
| | | currentMachineAuthInfo.put("machineId", currentMachineAuthInfo.get("machine_id")); |
| | | currentMachineAuthInfo.put("operate", currentMachineAuthInfo.get("operate")); |
| | | currentMachineAuthInfo.put("personId", currentMachineAuthInfo.get("person_id")); |
| | | currentMachineAuthInfo.put("startTime", currentMachineAuthInfo.get("start_time")); |
| | | currentMachineAuthInfo.put("state", currentMachineAuthInfo.get("state")); |
| | | currentMachineAuthInfo.put("endTime", currentMachineAuthInfo.get("end_time")); |
| | | currentMachineAuthInfo.put("communityId", currentMachineAuthInfo.get("community_id")); |
| | | currentMachineAuthInfo.put("personType", currentMachineAuthInfo.get("person_type")); |
| | | currentMachineAuthInfo.put("authId", currentMachineAuthInfo.get("auth_id")); |
| | | |
| | | |
| | | currentMachineAuthInfo.put("operate", StatusConstant.OPERATE_DEL); |
| | | getMachineAuthServiceDaoImpl().saveBusinessMachineAuthInfo(currentMachineAuthInfo); |
| | | for (Object key : currentMachineAuthInfo.keySet()) { |
| | | if (businessMachineAuth.get(key) == null) { |
| | | businessMachineAuth.put(key.toString(), currentMachineAuthInfo.get(key)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.common.listener.machineAuth; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.po.machineAuth.MachineAuthPo; |
| | | 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 com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.common.dao.IMachineAuthServiceDao; |
| | | 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; |
| | | |
| | | /** |
| | | * 删除设备权限信息 侦听 |
| | | * |
| | | * 处理节点 |
| | | * 1、businessMachineAuth:{} 设备权限基本信息节点 |
| | | * 2、businessMachineAuthAttr:[{}] 设备权限属性信息节点 |
| | | * 3、businessMachineAuthPhoto:[{}] 设备权限照片信息节点 |
| | | * 4、businessMachineAuthCerdentials:[{}] 设备权限证件信息节点 |
| | | * 协议地址 :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("deleteMachineAuthInfoListener") |
| | | @Transactional |
| | | public class DeleteMachineAuthInfoListener extends AbstractMachineAuthBusinessServiceDataFlowListener { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(DeleteMachineAuthInfoListener.class); |
| | | @Autowired |
| | | IMachineAuthServiceDao machineAuthServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 3; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_DELETE_MACHINE_AUTH; |
| | | } |
| | | |
| | | /** |
| | | * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessMachineAuth 节点 |
| | | if(data.containsKey(MachineAuthPo.class.getSimpleName())){ |
| | | Object _obj = data.get(MachineAuthPo.class.getSimpleName()); |
| | | JSONArray businessMachineAuths = null; |
| | | if(_obj instanceof JSONObject){ |
| | | businessMachineAuths = new JSONArray(); |
| | | businessMachineAuths.add(_obj); |
| | | }else { |
| | | businessMachineAuths = (JSONArray)_obj; |
| | | } |
| | | //JSONObject businessMachineAuth = data.getJSONObject(MachineAuthPo.class.getSimpleName()); |
| | | for (int _machineAuthIndex = 0; _machineAuthIndex < businessMachineAuths.size();_machineAuthIndex++) { |
| | | JSONObject businessMachineAuth = businessMachineAuths.getJSONObject(_machineAuthIndex); |
| | | doBusinessMachineAuth(business, businessMachineAuth); |
| | | if(_obj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("authId", businessMachineAuth.getString("authId")); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 删除 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> businessMachineAuthInfos = machineAuthServiceDaoImpl.getBusinessMachineAuthInfo(info); |
| | | if( businessMachineAuthInfos != null && businessMachineAuthInfos.size() >0) { |
| | | for (int _machineAuthIndex = 0; _machineAuthIndex < businessMachineAuthInfos.size();_machineAuthIndex++) { |
| | | Map businessMachineAuthInfo = businessMachineAuthInfos.get(_machineAuthIndex); |
| | | flushBusinessMachineAuthInfo(businessMachineAuthInfo,StatusConstant.STATUS_CD_INVALID); |
| | | machineAuthServiceDaoImpl.updateMachineAuthInfoInstance(businessMachineAuthInfo); |
| | | dataFlowContext.addParamOut("authId",businessMachineAuthInfo.get("auth_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> machineAuthInfo = machineAuthServiceDaoImpl.getMachineAuthInfo(info); |
| | | if(machineAuthInfo != null && machineAuthInfo.size() > 0){ |
| | | |
| | | //设备权限信息 |
| | | List<Map> businessMachineAuthInfos = machineAuthServiceDaoImpl.getBusinessMachineAuthInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessMachineAuthInfos == null || businessMachineAuthInfos.size() == 0){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(machineAuth),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | for (int _machineAuthIndex = 0; _machineAuthIndex < businessMachineAuthInfos.size();_machineAuthIndex++) { |
| | | Map businessMachineAuthInfo = businessMachineAuthInfos.get(_machineAuthIndex); |
| | | flushBusinessMachineAuthInfo(businessMachineAuthInfo,StatusConstant.STATUS_CD_VALID); |
| | | machineAuthServiceDaoImpl.updateMachineAuthInfoInstance(businessMachineAuthInfo); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessMachineAuth 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessMachineAuth 设备权限节点 |
| | | */ |
| | | private void doBusinessMachineAuth(Business business,JSONObject businessMachineAuth){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessMachineAuth,"authId","businessMachineAuth 节点下没有包含 authId 节点"); |
| | | |
| | | if(businessMachineAuth.getString("authId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"authId 错误,不能自动生成(必须已经存在的authId)"+businessMachineAuth); |
| | | } |
| | | //自动插入DEL |
| | | autoSaveDelBusinessMachineAuth(business,businessMachineAuth); |
| | | } |
| | | @Override |
| | | public IMachineAuthServiceDao getMachineAuthServiceDaoImpl() { |
| | | return machineAuthServiceDaoImpl; |
| | | } |
| | | |
| | | public void setMachineAuthServiceDaoImpl(IMachineAuthServiceDao machineAuthServiceDaoImpl) { |
| | | this.machineAuthServiceDaoImpl = machineAuthServiceDaoImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.common.listener.machineAuth; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.po.machineAuth.MachineAuthPo; |
| | | import com.java110.utils.constant.BusinessTypeConstant; |
| | | import com.java110.utils.constant.StatusConstant; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.common.dao.IMachineAuthServiceDao; |
| | | 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("saveMachineAuthInfoListener") |
| | | @Transactional |
| | | public class SaveMachineAuthInfoListener extends AbstractMachineAuthBusinessServiceDataFlowListener{ |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(SaveMachineAuthInfoListener.class); |
| | | |
| | | @Autowired |
| | | private IMachineAuthServiceDao machineAuthServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_SAVE_MACHINE_AUTH; |
| | | } |
| | | |
| | | /** |
| | | * 保存设备权限信息 business 表中 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessMachineAuth 节点 |
| | | if(data.containsKey(MachineAuthPo.class.getSimpleName())){ |
| | | Object bObj = data.get(MachineAuthPo.class.getSimpleName()); |
| | | JSONArray businessMachineAuths = null; |
| | | if(bObj instanceof JSONObject){ |
| | | businessMachineAuths = new JSONArray(); |
| | | businessMachineAuths.add(bObj); |
| | | }else { |
| | | businessMachineAuths = (JSONArray)bObj; |
| | | } |
| | | //JSONObject businessMachineAuth = data.getJSONObject(MachineAuthPo.class.getSimpleName()); |
| | | for (int bMachineAuthIndex = 0; bMachineAuthIndex < businessMachineAuths.size();bMachineAuthIndex++) { |
| | | JSONObject businessMachineAuth = businessMachineAuths.getJSONObject(bMachineAuthIndex); |
| | | doBusinessMachineAuth(business, businessMachineAuth); |
| | | if(bObj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("authId", businessMachineAuth.getString("authId")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 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> businessMachineAuthInfo = machineAuthServiceDaoImpl.getBusinessMachineAuthInfo(info); |
| | | if( businessMachineAuthInfo != null && businessMachineAuthInfo.size() >0) { |
| | | reFreshShareColumn(info, businessMachineAuthInfo.get(0)); |
| | | machineAuthServiceDaoImpl.saveMachineAuthInfoInstance(info); |
| | | if(businessMachineAuthInfo.size() == 1) { |
| | | dataFlowContext.addParamOut("authId", businessMachineAuthInfo.get(0).get("auth_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> machineAuthInfo = machineAuthServiceDaoImpl.getMachineAuthInfo(info); |
| | | if(machineAuthInfo != null && machineAuthInfo.size() > 0){ |
| | | reFreshShareColumn(paramIn, machineAuthInfo.get(0)); |
| | | machineAuthServiceDaoImpl.updateMachineAuthInfoInstance(paramIn); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessMachineAuth 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessMachineAuth 设备权限节点 |
| | | */ |
| | | private void doBusinessMachineAuth(Business business,JSONObject businessMachineAuth){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessMachineAuth,"authId","businessMachineAuth 节点下没有包含 authId 节点"); |
| | | |
| | | if(businessMachineAuth.getString("authId").startsWith("-")){ |
| | | //刷新缓存 |
| | | //flushMachineAuthId(business.getDatas()); |
| | | |
| | | businessMachineAuth.put("authId",GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_authId)); |
| | | |
| | | } |
| | | |
| | | businessMachineAuth.put("bId",business.getbId()); |
| | | businessMachineAuth.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存设备权限信息 |
| | | machineAuthServiceDaoImpl.saveBusinessMachineAuthInfo(businessMachineAuth); |
| | | |
| | | } |
| | | @Override |
| | | public IMachineAuthServiceDao getMachineAuthServiceDaoImpl() { |
| | | return machineAuthServiceDaoImpl; |
| | | } |
| | | |
| | | public void setMachineAuthServiceDaoImpl(IMachineAuthServiceDao machineAuthServiceDaoImpl) { |
| | | this.machineAuthServiceDaoImpl = machineAuthServiceDaoImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.common.listener.machineAuth; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.po.machineAuth.MachineAuthPo; |
| | | 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 com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.common.dao.IMachineAuthServiceDao; |
| | | 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; |
| | | |
| | | /** |
| | | * 修改设备权限信息 侦听 |
| | | * |
| | | * 处理节点 |
| | | * 1、businessMachineAuth:{} 设备权限基本信息节点 |
| | | * 2、businessMachineAuthAttr:[{}] 设备权限属性信息节点 |
| | | * 3、businessMachineAuthPhoto:[{}] 设备权限照片信息节点 |
| | | * 4、businessMachineAuthCerdentials:[{}] 设备权限证件信息节点 |
| | | * 协议地址 :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("updateMachineAuthInfoListener") |
| | | @Transactional |
| | | public class UpdateMachineAuthInfoListener extends AbstractMachineAuthBusinessServiceDataFlowListener { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(UpdateMachineAuthInfoListener.class); |
| | | @Autowired |
| | | private IMachineAuthServiceDao machineAuthServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 2; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_UPDATE_MACHINE_AUTH; |
| | | } |
| | | |
| | | /** |
| | | * business过程 |
| | | * @param dataFlowContext 上下文对象 |
| | | * @param business 业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | |
| | | //处理 businessMachineAuth 节点 |
| | | if(data.containsKey(MachineAuthPo.class.getSimpleName())){ |
| | | Object _obj = data.get(MachineAuthPo.class.getSimpleName()); |
| | | JSONArray businessMachineAuths = null; |
| | | if(_obj instanceof JSONObject){ |
| | | businessMachineAuths = new JSONArray(); |
| | | businessMachineAuths.add(_obj); |
| | | }else { |
| | | businessMachineAuths = (JSONArray)_obj; |
| | | } |
| | | //JSONObject businessMachineAuth = data.getJSONObject(MachineAuthPo.class.getSimpleName()); |
| | | for (int _machineAuthIndex = 0; _machineAuthIndex < businessMachineAuths.size();_machineAuthIndex++) { |
| | | JSONObject businessMachineAuth = businessMachineAuths.getJSONObject(_machineAuthIndex); |
| | | doBusinessMachineAuth(business, businessMachineAuth); |
| | | if(_obj instanceof JSONObject) { |
| | | dataFlowContext.addParamOut("authId", businessMachineAuth.getString("authId")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 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> businessMachineAuthInfos = machineAuthServiceDaoImpl.getBusinessMachineAuthInfo(info); |
| | | if( businessMachineAuthInfos != null && businessMachineAuthInfos.size() >0) { |
| | | for (int _machineAuthIndex = 0; _machineAuthIndex < businessMachineAuthInfos.size();_machineAuthIndex++) { |
| | | Map businessMachineAuthInfo = businessMachineAuthInfos.get(_machineAuthIndex); |
| | | flushBusinessMachineAuthInfo(businessMachineAuthInfo,StatusConstant.STATUS_CD_VALID); |
| | | machineAuthServiceDaoImpl.updateMachineAuthInfoInstance(businessMachineAuthInfo); |
| | | if(businessMachineAuthInfo.size() == 1) { |
| | | dataFlowContext.addParamOut("authId", businessMachineAuthInfo.get("auth_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> machineAuthInfo = machineAuthServiceDaoImpl.getMachineAuthInfo(info); |
| | | if(machineAuthInfo != null && machineAuthInfo.size() > 0){ |
| | | |
| | | //设备权限信息 |
| | | List<Map> businessMachineAuthInfos = machineAuthServiceDaoImpl.getBusinessMachineAuthInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessMachineAuthInfos == null || businessMachineAuthInfos.size() == 0){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(machineAuth),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | for (int _machineAuthIndex = 0; _machineAuthIndex < businessMachineAuthInfos.size();_machineAuthIndex++) { |
| | | Map businessMachineAuthInfo = businessMachineAuthInfos.get(_machineAuthIndex); |
| | | flushBusinessMachineAuthInfo(businessMachineAuthInfo,StatusConstant.STATUS_CD_VALID); |
| | | machineAuthServiceDaoImpl.updateMachineAuthInfoInstance(businessMachineAuthInfo); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessMachineAuth 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessMachineAuth 设备权限节点 |
| | | */ |
| | | private void doBusinessMachineAuth(Business business,JSONObject businessMachineAuth){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessMachineAuth,"authId","businessMachineAuth 节点下没有包含 authId 节点"); |
| | | |
| | | if(businessMachineAuth.getString("authId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"authId 错误,不能自动生成(必须已经存在的authId)"+businessMachineAuth); |
| | | } |
| | | //自动保存DEL |
| | | autoSaveDelBusinessMachineAuth(business,businessMachineAuth); |
| | | |
| | | businessMachineAuth.put("bId",business.getbId()); |
| | | businessMachineAuth.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存设备权限信息 |
| | | machineAuthServiceDaoImpl.saveBusinessMachineAuthInfo(businessMachineAuth); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public IMachineAuthServiceDao getMachineAuthServiceDaoImpl() { |
| | | return machineAuthServiceDaoImpl; |
| | | } |
| | | |
| | | public void setMachineAuthServiceDaoImpl(IMachineAuthServiceDao machineAuthServiceDaoImpl) { |
| | | this.machineAuthServiceDaoImpl = machineAuthServiceDaoImpl; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.common.smo.impl; |
| | | |
| | | |
| | | import com.java110.common.dao.IMachineAuthServiceDao; |
| | | import com.java110.dto.machineAuth.MachineAuthDto; |
| | | import com.java110.intf.common.IMachineAuthInnerServiceSMO; |
| | | import com.java110.intf.user.IUserInnerServiceSMO; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.core.base.smo.BaseServiceSMO; |
| | | import com.java110.dto.user.UserDto; |
| | | import com.java110.dto.PageDto; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @ClassName FloorInnerServiceSMOImpl |
| | | * @Description 设备权限内部服务实现类 |
| | | * @Author wuxw |
| | | * @Date 2019/4/24 9:20 |
| | | * @Version 1.0 |
| | | * add by wuxw 2019/4/24 |
| | | **/ |
| | | @RestController |
| | | public class MachineAuthInnerServiceSMOImpl extends BaseServiceSMO implements IMachineAuthInnerServiceSMO { |
| | | |
| | | @Autowired |
| | | private IMachineAuthServiceDao machineAuthServiceDaoImpl; |
| | | |
| | | @Autowired |
| | | private IUserInnerServiceSMO userInnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public List<MachineAuthDto> queryMachineAuths(@RequestBody MachineAuthDto machineAuthDto) { |
| | | |
| | | //校验是否传了 分页信息 |
| | | |
| | | int page = machineAuthDto.getPage(); |
| | | |
| | | if (page != PageDto.DEFAULT_PAGE) { |
| | | machineAuthDto.setPage((page - 1) * machineAuthDto.getRow()); |
| | | } |
| | | |
| | | List<MachineAuthDto> machineAuths = BeanConvertUtil.covertBeanList(machineAuthServiceDaoImpl.getMachineAuthInfo(BeanConvertUtil.beanCovertMap(machineAuthDto)), MachineAuthDto.class); |
| | | |
| | | if (machineAuths == null || machineAuths.size() == 0) { |
| | | return machineAuths; |
| | | } |
| | | |
| | | String[] userIds = getUserIds(machineAuths); |
| | | //根据 userId 查询用户信息 |
| | | List<UserDto> users = userInnerServiceSMOImpl.getUserInfo(userIds); |
| | | |
| | | for (MachineAuthDto machineAuth : machineAuths) { |
| | | refreshMachineAuth(machineAuth, users); |
| | | } |
| | | return machineAuths; |
| | | } |
| | | |
| | | /** |
| | | * 从用户列表中查询用户,将用户中的信息 刷新到 floor对象中 |
| | | * |
| | | * @param machineAuth 小区设备权限信息 |
| | | * @param users 用户列表 |
| | | */ |
| | | private void refreshMachineAuth(MachineAuthDto machineAuth, List<UserDto> users) { |
| | | for (UserDto user : users) { |
| | | if (machineAuth.getAuthId().equals(user.getUserId())) { |
| | | BeanConvertUtil.covertBean(user, machineAuth); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取批量userId |
| | | * |
| | | * @param machineAuths 小区楼信息 |
| | | * @return 批量userIds 信息 |
| | | */ |
| | | private String[] getUserIds(List<MachineAuthDto> machineAuths) { |
| | | List<String> userIds = new ArrayList<String>(); |
| | | for (MachineAuthDto machineAuth : machineAuths) { |
| | | userIds.add(machineAuth.getAuthId()); |
| | | } |
| | | |
| | | return userIds.toArray(new String[userIds.size()]); |
| | | } |
| | | |
| | | @Override |
| | | public int queryMachineAuthsCount(@RequestBody MachineAuthDto machineAuthDto) { |
| | | return machineAuthServiceDaoImpl.queryMachineAuthsCount(BeanConvertUtil.beanCovertMap(machineAuthDto)); } |
| | | |
| | | public IMachineAuthServiceDao getMachineAuthServiceDaoImpl() { |
| | | return machineAuthServiceDaoImpl; |
| | | } |
| | | |
| | | public void setMachineAuthServiceDaoImpl(IMachineAuthServiceDao machineAuthServiceDaoImpl) { |
| | | this.machineAuthServiceDaoImpl = machineAuthServiceDaoImpl; |
| | | } |
| | | |
| | | public IUserInnerServiceSMO getUserInnerServiceSMOImpl() { |
| | | return userInnerServiceSMOImpl; |
| | | } |
| | | |
| | | public void setUserInnerServiceSMOImpl(IUserInnerServiceSMO userInnerServiceSMOImpl) { |
| | | this.userInnerServiceSMOImpl = userInnerServiceSMOImpl; |
| | | } |
| | | } |