| | |
| | | package com.java110.community.dao; |
| | | |
| | | |
| | | import com.java110.common.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 IFloorServiceDao { |
| | | |
| | | /** |
| | | * 保存 小区楼信息 |
| | | * @param businessFloorInfo 小区楼信息 封装 |
| | | * @throws DAOException 操作数据库异常 |
| | | */ |
| | | public void saveBusinessFloorInfo(Map businessFloorInfo) throws DAOException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询小区楼信息(business过程) |
| | | * 根据bId 查询小区楼信息 |
| | | * @param info bId 信息 |
| | | * @return 小区楼信息 |
| | | * @throws DAOException |
| | | */ |
| | | public Map getBusinessFloorInfo(Map info) throws DAOException; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 保存 小区楼信息 Business数据到 Instance中 |
| | | * @param info |
| | | * @throws DAOException |
| | | */ |
| | | public void saveFloorInfoInstance(Map info) throws DAOException; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询小区楼信息(instance过程) |
| | | * 根据bId 查询小区楼信息 |
| | | * @param info bId 信息 |
| | | * @return 小区楼信息 |
| | | * @throws DAOException |
| | | */ |
| | | public Map getFloorInfo(Map info) throws DAOException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 修改小区楼信息 |
| | | * @param info 修改信息 |
| | | * @throws DAOException |
| | | */ |
| | | public void updateFloorInfoInstance(Map info) throws DAOException; |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.community.dao.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.exception.DAOException; |
| | | import com.java110.common.util.DateUtil; |
| | | import com.java110.community.dao.IFloorServiceDao; |
| | | import com.java110.core.base.dao.BaseServiceDao; |
| | | 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("floorServiceDaoImpl") |
| | | //@Transactional |
| | | public class FloorServiceDaoImpl extends BaseServiceDao implements IFloorServiceDao { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(FloorServiceDaoImpl.class); |
| | | |
| | | /** |
| | | * 小区楼信息封装 |
| | | * @param businessFloorInfo 小区楼信息 封装 |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public void saveBusinessFloorInfo(Map businessFloorInfo) throws DAOException { |
| | | businessFloorInfo.put("month", DateUtil.getCurrentMonth()); |
| | | // 查询business_user 数据是否已经存在 |
| | | logger.debug("保存小区楼信息 入参 businessFloorInfo : {}",businessFloorInfo); |
| | | int saveFlag = sqlSessionTemplate.insert("floorServiceDaoImpl.saveBusinessFloorInfo",businessFloorInfo); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存小区楼数据失败:"+ JSONObject.toJSONString(businessFloorInfo)); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询小区楼信息 |
| | | * @param info bId 信息 |
| | | * @return 小区楼信息 |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public Map getBusinessFloorInfo(Map info) throws DAOException { |
| | | |
| | | logger.debug("查询小区楼信息 入参 info : {}",info); |
| | | |
| | | List<Map> businessFloorInfos = sqlSessionTemplate.selectList("floorServiceDaoImpl.getBusinessFloorInfo",info); |
| | | if(businessFloorInfos == null){ |
| | | return null; |
| | | } |
| | | if(businessFloorInfos.size() >1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:businessFloorInfos,"+ JSONObject.toJSONString(info)); |
| | | } |
| | | |
| | | return businessFloorInfos.get(0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 保存小区楼信息 到 instance |
| | | * @param info bId 信息 |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public void saveFloorInfoInstance(Map info) throws DAOException { |
| | | logger.debug("保存小区楼信息Instance 入参 info : {}",info); |
| | | |
| | | int saveFlag = sqlSessionTemplate.insert("floorServiceDaoImpl.saveFloorInfoInstance",info); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存小区楼信息Instance数据失败:"+ JSONObject.toJSONString(info)); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询小区楼信息(instance) |
| | | * @param info bId 信息 |
| | | * @return |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public Map getFloorInfo(Map info) throws DAOException { |
| | | logger.debug("查询小区楼信息 入参 info : {}",info); |
| | | |
| | | List<Map> businessFloorInfos = sqlSessionTemplate.selectList("floorServiceDaoImpl.getFloorInfo",info); |
| | | if(businessFloorInfos == null || businessFloorInfos.size() == 0){ |
| | | return null; |
| | | } |
| | | if(businessFloorInfos.size() >1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:getFloorInfo,"+ JSONObject.toJSONString(info)); |
| | | } |
| | | |
| | | return businessFloorInfos.get(0); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改小区楼信息 |
| | | * @param info 修改信息 |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public void updateFloorInfoInstance(Map info) throws DAOException { |
| | | logger.debug("修改小区楼信息Instance 入参 info : {}",info); |
| | | |
| | | int saveFlag = sqlSessionTemplate.update("floorServiceDaoImpl.updateFloorInfoInstance",info); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改小区楼信息Instance数据失败:"+ JSONObject.toJSONString(info)); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.community.listener.floor; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.constant.StatusConstant; |
| | | import com.java110.common.exception.ListenerExecuteException; |
| | | import com.java110.community.dao.IFloorServiceDao; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.event.service.AbstractBusinessServiceDataFlowListener; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * |
| | | * 小区楼 服务侦听 父类 |
| | | * Created by wuxw on 2018/7/4. |
| | | */ |
| | | public abstract class AbstractFloorBusinessServiceDataFlowListener extends AbstractBusinessServiceDataFlowListener{ |
| | | private final static Logger logger = LoggerFactory.getLogger(AbstractFloorBusinessServiceDataFlowListener.class); |
| | | |
| | | |
| | | /** |
| | | * 获取 DAO工具类 |
| | | * @return |
| | | */ |
| | | public abstract IFloorServiceDao getFloorServiceDaoImpl(); |
| | | |
| | | /** |
| | | * 刷新 businessFloorInfo 数据 |
| | | * 主要将 数据库 中字段和 接口传递字段建立关系 |
| | | * @param businessFloorInfo |
| | | */ |
| | | protected void flushBusinessFloorInfo(Map businessFloorInfo,String statusCd){ |
| | | businessFloorInfo.put("newBId",businessFloorInfo.get("b_id")); |
| | | businessFloorInfo.put("floorId",businessFloorInfo.get("floor_id")); |
| | | businessFloorInfo.put("operate",businessFloorInfo.get("operate")); |
| | | businessFloorInfo.put("remark",businessFloorInfo.get("remark")); |
| | | businessFloorInfo.put("userId",businessFloorInfo.get("user_id")); |
| | | businessFloorInfo.put("floorNum",businessFloorInfo.get("floor_num")); |
| | | |
| | | businessFloorInfo.put("statusCd", statusCd); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中 |
| | | * @param businessFloor 小区楼信息 |
| | | */ |
| | | protected void autoSaveDelBusinessFloor(Business business, JSONObject businessFloor){ |
| | | //自动插入DEL |
| | | Map info = new HashMap(); |
| | | info.put("floorId",businessFloor.getString("floorId")); |
| | | info.put("statusCd",StatusConstant.STATUS_CD_VALID); |
| | | Map currentFloorInfo = getFloorServiceDaoImpl().getFloorInfo(info); |
| | | if(currentFloorInfo == null || currentFloorInfo.isEmpty()){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info); |
| | | } |
| | | currentFloorInfo.put("bId",business.getbId()); |
| | | |
| | | currentFloorInfo.put("floorId",currentFloorInfo.get("floor_id")); |
| | | currentFloorInfo.put("operate",currentFloorInfo.get("operate")); |
| | | currentFloorInfo.put("remark",currentFloorInfo.get("remark")); |
| | | currentFloorInfo.put("userId",currentFloorInfo.get("user_id")); |
| | | currentFloorInfo.put("floorNum",currentFloorInfo.get("floor_num")); |
| | | |
| | | |
| | | currentFloorInfo.put("operate",StatusConstant.OPERATE_DEL); |
| | | getFloorServiceDaoImpl().saveBusinessFloorInfo(currentFloorInfo); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.community.listener.floor; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.constant.BusinessTypeConstant; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.constant.StatusConstant; |
| | | import com.java110.common.exception.ListenerExecuteException; |
| | | import com.java110.common.util.Assert; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.community.dao.IFloorServiceDao; |
| | | 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、businessFloor:{} 小区楼基本信息节点 |
| | | * 2、businessFloorAttr:[{}] 小区楼属性信息节点 |
| | | * 3、businessFloorPhoto:[{}] 小区楼照片信息节点 |
| | | * 4、businessFloorCerdentials:[{}] 小区楼证件信息节点 |
| | | * 协议地址 :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("deleteFloorInfoListener") |
| | | @Transactional |
| | | public class DeleteFloorInfoListener extends AbstractFloorBusinessServiceDataFlowListener { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(DeleteFloorInfoListener.class); |
| | | @Autowired |
| | | IFloorServiceDao floorServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 3; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_DELETE_FLOOR_INFO; |
| | | } |
| | | |
| | | /** |
| | | * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessFloor 节点 按理这里不应该处理,程序上支持,以防真有这种业务 |
| | | if(data.containsKey("businessFloor")){ |
| | | JSONObject businessFloor = data.getJSONObject("businessFloor"); |
| | | doBusinessFloor(business,businessFloor); |
| | | dataFlowContext.addParamOut("floorId",businessFloor.getString("floorId")); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 删除 instance数据 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) { |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | |
| | | //小区楼信息 |
| | | Map info = new HashMap(); |
| | | info.put("bId",business.getbId()); |
| | | info.put("operate",StatusConstant.OPERATE_DEL); |
| | | |
| | | //小区楼信息 |
| | | Map businessFloorInfo = floorServiceDaoImpl.getBusinessFloorInfo(info); |
| | | if( businessFloorInfo != null && !businessFloorInfo.isEmpty()) { |
| | | flushBusinessFloorInfo(businessFloorInfo,StatusConstant.STATUS_CD_INVALID); |
| | | floorServiceDaoImpl.updateFloorInfoInstance(businessFloorInfo); |
| | | dataFlowContext.addParamOut("floorId",businessFloorInfo.get("floor_id")); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 撤单 |
| | | * 从business表中查询到DEL的数据 将instance中的数据更新回来 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doRecover(DataFlowContext dataFlowContext, Business business) { |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | Map info = new HashMap(); |
| | | info.put("bId",bId); |
| | | info.put("statusCd",StatusConstant.STATUS_CD_INVALID); |
| | | |
| | | Map delInfo = new HashMap(); |
| | | delInfo.put("bId",business.getbId()); |
| | | delInfo.put("operate",StatusConstant.OPERATE_DEL); |
| | | //小区楼信息 |
| | | Map floorInfo = floorServiceDaoImpl.getFloorInfo(info); |
| | | if(floorInfo != null && !floorInfo.isEmpty()){ |
| | | |
| | | //小区楼信息 |
| | | Map businessFloorInfo = floorServiceDaoImpl.getBusinessFloorInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessFloorInfo == null || businessFloorInfo.isEmpty()){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(floor),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | |
| | | flushBusinessFloorInfo(businessFloorInfo,StatusConstant.STATUS_CD_VALID); |
| | | floorServiceDaoImpl.updateFloorInfoInstance(businessFloorInfo); |
| | | dataFlowContext.addParamOut("floorId",floorInfo.get("floor_id")); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessFloor 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessFloor 小区楼节点 |
| | | */ |
| | | private void doBusinessFloor(Business business,JSONObject businessFloor){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessFloor,"floorId","businessFloor 节点下没有包含 floorId 节点"); |
| | | |
| | | if(businessFloor.getString("floorId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"floorId 错误,不能自动生成(必须已经存在的floorId)"+businessFloor); |
| | | } |
| | | //自动插入DEL |
| | | autoSaveDelBusinessFloor(business,businessFloor); |
| | | } |
| | | |
| | | public IFloorServiceDao getFloorServiceDaoImpl() { |
| | | return floorServiceDaoImpl; |
| | | } |
| | | |
| | | public void setFloorServiceDaoImpl(IFloorServiceDao floorServiceDaoImpl) { |
| | | this.floorServiceDaoImpl = floorServiceDaoImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.community.listener.floor; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.constant.BusinessTypeConstant; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.constant.ServiceCodeConstant; |
| | | import com.java110.common.constant.StatusConstant; |
| | | import com.java110.common.exception.ListenerExecuteException; |
| | | import com.java110.common.util.Assert; |
| | | import com.java110.common.util.DateUtil; |
| | | import com.java110.common.util.StringUtil; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.community.dao.IFloorServiceDao; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.text.ParseException; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 保存 小区楼信息 侦听 |
| | | * Created by wuxw on 2018/5/18. |
| | | */ |
| | | @Java110Listener("saveFloorInfoListener") |
| | | @Transactional |
| | | public class SaveFloorInfoListener extends AbstractFloorBusinessServiceDataFlowListener{ |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(SaveFloorInfoListener.class); |
| | | |
| | | @Autowired |
| | | IFloorServiceDao floorServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_SAVE_FLOOR_INFO; |
| | | } |
| | | |
| | | /** |
| | | * 保存小区楼信息 business 表中 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessFloor 节点 |
| | | if(data.containsKey("businessFloor")){ |
| | | JSONObject businessFloor = data.getJSONObject("businessFloor"); |
| | | doBusinessFloor(business,businessFloor); |
| | | dataFlowContext.addParamOut("floorId",businessFloor.getString("floorId")); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * business 数据转移到 instance |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Map info = new HashMap(); |
| | | info.put("bId",business.getbId()); |
| | | info.put("operate",StatusConstant.OPERATE_ADD); |
| | | |
| | | //小区楼信息 |
| | | Map businessFloorInfo = floorServiceDaoImpl.getBusinessFloorInfo(info); |
| | | if( businessFloorInfo != null && !businessFloorInfo.isEmpty()) { |
| | | floorServiceDaoImpl.saveFloorInfoInstance(info); |
| | | dataFlowContext.addParamOut("floorId",businessFloorInfo.get("floor_id")); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 撤单 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doRecover(DataFlowContext dataFlowContext, Business business) { |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | Map info = new HashMap(); |
| | | info.put("bId",bId); |
| | | info.put("statusCd",StatusConstant.STATUS_CD_VALID); |
| | | Map paramIn = new HashMap(); |
| | | paramIn.put("bId",bId); |
| | | paramIn.put("statusCd",StatusConstant.STATUS_CD_INVALID); |
| | | //小区楼信息 |
| | | Map floorInfo = floorServiceDaoImpl.getFloorInfo(info); |
| | | if(floorInfo != null && !floorInfo.isEmpty()){ |
| | | paramIn.put("floorId",floorInfo.get("floor_id").toString()); |
| | | floorServiceDaoImpl.updateFloorInfoInstance(paramIn); |
| | | dataFlowContext.addParamOut("floorId",floorInfo.get("floor_id")); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessFloor 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessFloor 小区楼节点 |
| | | */ |
| | | private void doBusinessFloor(Business business,JSONObject businessFloor){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessFloor,"floorId","businessFloor 节点下没有包含 floorId 节点"); |
| | | |
| | | if(businessFloor.getString("floorId").startsWith("-")){ |
| | | //刷新缓存 |
| | | //flushFloorId(business.getDatas()); |
| | | |
| | | businessFloor.put("floorId",GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_floorId)); |
| | | |
| | | } |
| | | |
| | | businessFloor.put("bId",business.getbId()); |
| | | businessFloor.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存小区楼信息 |
| | | floorServiceDaoImpl.saveBusinessFloorInfo(businessFloor); |
| | | |
| | | } |
| | | |
| | | public IFloorServiceDao getFloorServiceDaoImpl() { |
| | | return floorServiceDaoImpl; |
| | | } |
| | | |
| | | public void setFloorServiceDaoImpl(IFloorServiceDao floorServiceDaoImpl) { |
| | | this.floorServiceDaoImpl = floorServiceDaoImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.community.listener.floor; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.constant.BusinessTypeConstant; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.constant.StatusConstant; |
| | | import com.java110.common.exception.ListenerExecuteException; |
| | | import com.java110.common.util.Assert; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.community.dao.IFloorServiceDao; |
| | | 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、businessFloor:{} 小区楼基本信息节点 |
| | | * 2、businessFloorAttr:[{}] 小区楼属性信息节点 |
| | | * 3、businessFloorPhoto:[{}] 小区楼照片信息节点 |
| | | * 4、businessFloorCerdentials:[{}] 小区楼证件信息节点 |
| | | * 协议地址 :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("updateFloorInfoListener") |
| | | @Transactional |
| | | public class UpdateFloorInfoListener extends AbstractFloorBusinessServiceDataFlowListener { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(UpdateFloorInfoListener.class); |
| | | @Autowired |
| | | IFloorServiceDao floorServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 2; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_UPDATE_FLOOR_INFO; |
| | | } |
| | | |
| | | /** |
| | | * business过程 |
| | | * @param dataFlowContext |
| | | * @param business |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessFloor 节点 |
| | | if(data.containsKey("businessFloor")){ |
| | | JSONObject businessFloor = data.getJSONObject("businessFloor"); |
| | | doBusinessFloor(business,businessFloor); |
| | | dataFlowContext.addParamOut("floorId",businessFloor.getString("floorId")); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 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); |
| | | |
| | | //小区楼信息 |
| | | Map businessFloorInfo = floorServiceDaoImpl.getBusinessFloorInfo(info); |
| | | if( businessFloorInfo != null && !businessFloorInfo.isEmpty()) { |
| | | flushBusinessFloorInfo(businessFloorInfo,StatusConstant.STATUS_CD_VALID); |
| | | floorServiceDaoImpl.updateFloorInfoInstance(businessFloorInfo); |
| | | dataFlowContext.addParamOut("floorId",businessFloorInfo.get("floor_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); |
| | | //小区楼信息 |
| | | Map floorInfo = floorServiceDaoImpl.getFloorInfo(info); |
| | | if(floorInfo != null && !floorInfo.isEmpty()){ |
| | | |
| | | //小区楼信息 |
| | | Map businessFloorInfo = floorServiceDaoImpl.getBusinessFloorInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessFloorInfo == null || businessFloorInfo.isEmpty()){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(floor),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | |
| | | flushBusinessFloorInfo(businessFloorInfo,StatusConstant.STATUS_CD_VALID); |
| | | floorServiceDaoImpl.updateFloorInfoInstance(businessFloorInfo); |
| | | dataFlowContext.addParamOut("floorId",floorInfo.get("floor_id")); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessFloor 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessFloor 小区楼节点 |
| | | */ |
| | | private void doBusinessFloor(Business business,JSONObject businessFloor){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessFloor,"floorId","businessFloor 节点下没有包含 floorId 节点"); |
| | | |
| | | if(businessFloor.getString("floorId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"floorId 错误,不能自动生成(必须已经存在的floorId)"+businessFloor); |
| | | } |
| | | //自动保存DEL |
| | | autoSaveDelBusinessFloor(business,businessFloor); |
| | | |
| | | businessFloor.put("bId",business.getbId()); |
| | | businessFloor.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存小区楼信息 |
| | | floorServiceDaoImpl.saveBusinessFloorInfo(businessFloor); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public IFloorServiceDao getFloorServiceDaoImpl() { |
| | | return floorServiceDaoImpl; |
| | | } |
| | | |
| | | public void setFloorServiceDaoImpl(IFloorServiceDao floorServiceDaoImpl) { |
| | | this.floorServiceDaoImpl = floorServiceDaoImpl; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | * 入驻小区组件处理类 |
| | | * |
| | | * add by wuxw 2019-04-15 |
| | | * |
| | | * |
| | | * |
| | | */ |
| | | @Component("enterCommunity") |
| | | public class EnterCommunityComponent { |
| | |
| | | public static void main( String[] args ) |
| | | { |
| | | Data data = new Data(); |
| | | data.setId("floorId"); |
| | | data.setName("floor"); |
| | | data.setDesc("小区楼"); |
| | | data.setBusinessTypeCd("sdddfff"); |
| | | data.setNewBusinessTypeCd("BUSINESS_TYPE_SAVE_FLOOR_INFO"); |
| | | data.setUpdateBusinessTypeCd("BUSINESS_TYPE_UPDATE_FLOOR_INFO"); |
| | | data.setDeleteBusinessTypeCd("BUSINESS_TYPE_DELETE_FLOOR_INFO"); |
| | | data.setBusinessTableName("business_floor"); |
| | | data.setTableName("f_floor"); |
| | | Map<String,String> param = new HashMap<String,String>(); |
| | |
| | | |
| | | GeneratorServiceDaoImplMapperListener generatorServiceDaoImplMapperListener = new GeneratorServiceDaoImplMapperListener(); |
| | | generatorServiceDaoImplMapperListener.generator(data); |
| | | |
| | | GeneratorUpdateInfoListener generatorUpdateInfoListener = new GeneratorUpdateInfoListener(); |
| | | generatorUpdateInfoListener.generator(data); |
| | | |
| | | GeneratorDeleteInfoListener generatorDeleteInfoListener = new GeneratorDeleteInfoListener(); |
| | | generatorDeleteInfoListener.generator(data); |
| | | } |
| | | } |
| | |
| | | |
| | | private String desc; |
| | | |
| | | private String businessTypeCd; |
| | | private String newBusinessTypeCd; |
| | | |
| | | private String updateBusinessTypeCd; |
| | | |
| | | private String deleteBusinessTypeCd; |
| | | |
| | | private String businessTableName; |
| | | |
| | |
| | | this.desc = desc; |
| | | } |
| | | |
| | | public String getBusinessTypeCd() { |
| | | return businessTypeCd; |
| | | } |
| | | |
| | | public void setBusinessTypeCd(String businessTypeCd) { |
| | | this.businessTypeCd = businessTypeCd; |
| | | } |
| | | |
| | | public String getBusinessTableName() { |
| | | return businessTableName; |
| | |
| | | public void setTableName(String tableName) { |
| | | this.tableName = tableName; |
| | | } |
| | | |
| | | public String getNewBusinessTypeCd() { |
| | | return newBusinessTypeCd; |
| | | } |
| | | |
| | | public void setNewBusinessTypeCd(String newBusinessTypeCd) { |
| | | this.newBusinessTypeCd = newBusinessTypeCd; |
| | | } |
| | | |
| | | public String getUpdateBusinessTypeCd() { |
| | | return updateBusinessTypeCd; |
| | | } |
| | | |
| | | public void setUpdateBusinessTypeCd(String updateBusinessTypeCd) { |
| | | this.updateBusinessTypeCd = updateBusinessTypeCd; |
| | | } |
| | | |
| | | public String getDeleteBusinessTypeCd() { |
| | | return deleteBusinessTypeCd; |
| | | } |
| | | |
| | | public void setDeleteBusinessTypeCd(String deleteBusinessTypeCd) { |
| | | this.deleteBusinessTypeCd = deleteBusinessTypeCd; |
| | | } |
| | | } |
| | |
| | | ; |
| | | Map<String,String> param = data.getParams(); |
| | | String mappingContext=""; |
| | | String autoMappingContext =""; |
| | | for(String key : param.keySet()){ |
| | | if("statusCd".equals(key)){ |
| | | if("statusCd".equals(key) || "bId".equals(key)){ |
| | | continue; |
| | | } |
| | | mappingContext += "business"+toUpperCaseFirstOne(data.getName())+"Info.put(\""+key+"\",business"+toUpperCaseFirstOne(data.getName())+"Info.get(\""+param.get(key)+"\"));\n"; |
| | | autoMappingContext += "current"+toUpperCaseFirstOne(data.getName())+"Info.put(\""+key+"\",current"+toUpperCaseFirstOne(data.getName())+"Info.get(\""+param.get(key)+"\"));\n"; |
| | | |
| | | } |
| | | |
| | | fileContext = fileContext.replace("$flushBusinessInfo$",mappingContext); |
| | | fileContext = fileContext.replace("$autoSaveDelBusiness$",autoMappingContext); |
| | | System.out.println(this.getClass().getResource("/listener").getPath()); |
| | | String writePath = this.getClass().getResource("/listener").getPath()+"/Abstract"+toUpperCaseFirstOne(data.getName())+"BusinessServiceDataFlowListener.java"; |
| | | writeFile(writePath, |
| New file |
| | |
| | | package com.java110.code; |
| | | |
| | | public class GeneratorDeleteInfoListener extends BaseGenerator { |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 生成代码 |
| | | * @param data |
| | | */ |
| | | public void generator(Data data){ |
| | | StringBuffer sb = readFile(this.getClass().getResource("/template/DeleteInfoListener.txt").getFile()); |
| | | String fileContext = sb.toString(); |
| | | fileContext = fileContext.replace("store",toLowerCaseFirstOne(data.getName())) |
| | | .replace("Store",toUpperCaseFirstOne(data.getName())) |
| | | .replace("商户",data.getDesc()) |
| | | .replace("BUSINESS_TYPE_DELETE_STORE_INFO",data.getDeleteBusinessTypeCd()); |
| | | System.out.println(this.getClass().getResource("/listener").getPath()); |
| | | String writePath = this.getClass().getResource("/listener").getPath()+"/Delete"+toUpperCaseFirstOne(data.getName())+"InfoListener.java"; |
| | | writeFile(writePath, |
| | | fileContext); |
| | | } |
| | | } |
| | |
| | | fileContext = fileContext.replace("store",toLowerCaseFirstOne(data.getName())) |
| | | .replace("Store",toUpperCaseFirstOne(data.getName())) |
| | | .replace("商户",data.getDesc()) |
| | | .replace("BUSINESS_TYPE_SAVE_STORE_INFO",data.getBusinessTypeCd()); |
| | | .replace("BUSINESS_TYPE_SAVE_STORE_INFO",data.getNewBusinessTypeCd()); |
| | | System.out.println(this.getClass().getResource("/listener").getPath()); |
| | | String writePath = this.getClass().getResource("/listener").getPath()+"/Save"+toUpperCaseFirstOne(data.getName())+"Listener.java"; |
| | | String writePath = this.getClass().getResource("/listener").getPath()+"/Save"+toUpperCaseFirstOne(data.getName())+"InfoListener.java"; |
| | | writeFile(writePath, |
| | | fileContext); |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * insert into s_store(store_id,b_id,user_id,name,address,tel,store_type_cd,nearby_landmarks,map_x,map_y,status_cd) |
| | | * select s.store_id,s.b_id,s.user_id,s.name,s.address,s.tel,s.store_type_cd,s.nearby_landmarks,s.map_x,s.map_y,'0' |
| | | * from business_store s where |
| | | * s.operate = 'ADD' and s.b_id=#{bId} |
| | | */ |
| | | private String dealSaveInfoInstance(Data data,String fileContext){ |
| | | String sql = "insert info "+ data.getTableName() + "(\n"; |
| | | String sqlValue = "select "; |
| | | String sqlWhere = " from "+ data.getBusinessTableName() +" t where 1=1\n"; |
| | | |
| | | Map<String,String> params = data.getParams(); |
| | | |
| | | for(String key:params.keySet()){ |
| | | if("operate".equals(key)){ |
| | | continue; |
| | | } |
| | | sql += params.get(key)+","; |
| | | |
| | | if("statusCd".equals(key)){ |
| | | sqlValue += "'0',"; |
| | | continue; |
| | | } |
| | | sqlValue += "t."+params.get(key)+","; |
| | | } |
| | | |
| | | for(String key:params.keySet()){ |
| | | if("statusCd".equals(key)){ |
| | | continue; |
| | | } |
| | | |
| | | if("operate".equals(key)){ |
| | | sqlWhere += " and t."+params.get(key)+"= 'ADD'\n"; |
| | | }else{ |
| | | sqlWhere += "<if test=\""+key+" !=null and "+key+" != ''\">\n"; |
| | | sqlWhere += " and t."+params.get(key)+"= #{"+key +"}\n"; |
| | | sqlWhere += "</if> \n"; |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | sql = sql.endsWith(",")?sql.substring(0,sql.length()-1):sql; |
| | | sqlValue = sqlValue.endsWith(",")?sqlValue.substring(0,sqlValue.length()-1):sqlValue; |
| | | |
| | | sql += (sqlValue +"\n)" + sqlWhere); |
| | | |
| | | fileContext = fileContext.replace("$saveInfoInstance$",sql); |
| | | |
| | | return fileContext; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * select s.store_id,s.b_id,s.user_id,s.name,s.address,s.tel,s.store_type_cd,s.nearby_landmarks,s.map_x,s.map_y,s.status_cd |
| | | * from s_store s |
| | | * where 1=1 |
| | | * <if test="statusCd != null and statusCd != ''"> |
| | | * and s.status_cd = #{statusCd} |
| | | * </if> |
| | | * |
| | | * <if test="bId != null and bId !=''"> |
| | | * and s.b_id = #{bId} |
| | | * </if> |
| | | * <if test="storeId != null and storeId !=''"> |
| | | * and s.store_id = #{storeId} |
| | | * </if> |
| | | * @param data |
| | | * @param fileContext |
| | | * @return |
| | | */ |
| | | private String dealGetInfo(Data data,String fileContext){ |
| | | String sql = "select "; |
| | | String sqlValue = " \nfrom "+data.getTableName()+" t \nwhere 1 =1 \n"; |
| | | |
| | | Map<String,String> params = data.getParams(); |
| | | |
| | | for(String key:params.keySet()){ |
| | | if("operate".equals(key)){ |
| | | continue; |
| | | } |
| | | sql += ("t."+params.get(key)+","); |
| | | sqlValue += "<if test=\""+key+" !=null and "+key+" != ''\">\n"; |
| | | sqlValue += " and t."+params.get(key)+"= #{"+key +"}\n"; |
| | | sqlValue += "</if> \n"; |
| | | |
| | | } |
| | | |
| | | sql = sql.endsWith(",")?sql.substring(0,sql.length()-1):sql; |
| | | |
| | | sql += sqlValue; |
| | | |
| | | fileContext = fileContext.replace("$getInfo$",sql); |
| | | |
| | | return fileContext; |
| | | } |
| | | |
| | | /** |
| | | * update s_store s set s.status_cd = #{statusCd} |
| | | * <if test="newBId != null and newBId != ''"> |
| | | * ,s.b_id = #{newBId} |
| | | * </if> |
| | | * <if test="userId != null and userId != ''"> |
| | | * ,s.user_id = #{userId} |
| | | * </if> |
| | | * <if test="name != null and name != ''"> |
| | | * ,s.name = #{name} |
| | | * </if> |
| | | * <if test="address != null and address != ''"> |
| | | * ,s.address = #{address} |
| | | * </if> |
| | | * <if test="tel != null and tel != ''"> |
| | | * ,s.tel = #{tel} |
| | | * </if> |
| | | * <if test="storeTypeCd != null and storeTypeCd != ''"> |
| | | * ,s.store_type_cd = #{storeTypeCd} |
| | | * </if> |
| | | * <if test="nearbyLandmarks != null and nearbyLandmarks != ''"> |
| | | * ,s.nearby_landmarks = #{nearbyLandmarks} |
| | | * </if> |
| | | * <if test="mapX != null and mapX != ''"> |
| | | * ,s.map_x = #{mapX} |
| | | * </if> |
| | | * <if test="mapY != null and mapY != ''"> |
| | | * ,s.map_y = #{mapY} |
| | | * </if> |
| | | * where 1=1 |
| | | * <if test="bId != null and bId !=''"> |
| | | * and s.b_id = #{bId} |
| | | * </if> |
| | | * <if test="storeId != null and storeId !=''"> |
| | | * and s.store_id = #{storeId} |
| | | * </if> |
| | | */ |
| | | private String dealUpdateInfoInstance(Data data,String fileContext){ |
| | | String sql = "update "+ data.getTableName() + " t set t.status_cd = #{statusCd}\n"; |
| | | String sqlWhere = " where 1=1 "; |
| | | |
| | | Map<String,String> params = data.getParams(); |
| | | |
| | | for(String key:params.keySet()){ |
| | | if("operate".equals(key)){ |
| | | continue; |
| | | } |
| | | |
| | | if("statusCd".equals(key)){ |
| | | continue; |
| | | } |
| | | if(!"bId".equals(key) && !data.getId().equals(key)) { |
| | | sql += "<if test=\"" + key + " !=null and " + key + " != ''\">\n"; |
| | | sql += ", t." + params.get(key) + "= #{" + key + "}\n"; |
| | | sql += "</if> \n"; |
| | | } |
| | | if("bId".equals(key) || data.getId().equals(key)) { |
| | | sqlWhere += "<if test=\"" + key + " !=null and " + key + " != ''\">\n"; |
| | | sqlWhere += "and t." + params.get(key) + "= #{" + key + "}\n"; |
| | | sqlWhere += "</if> \n"; |
| | | } |
| | | } |
| | | |
| | | sql += sqlWhere; |
| | | |
| | | fileContext = fileContext.replace("$updateInfoInstance$",sql); |
| | | |
| | | return fileContext; |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | .replace("商户",data.getDesc()); |
| | | fileContext = dealSaveBusinessInfo(data,fileContext); |
| | | fileContext = dealGetBusinessInfo(data,fileContext); |
| | | fileContext = dealSaveInfoInstance(data,fileContext); |
| | | fileContext = dealGetInfo(data,fileContext); |
| | | fileContext = dealUpdateInfoInstance(data,fileContext); |
| | | |
| | | System.out.println(this.getClass().getResource("/listener").getPath()); |
| | | String writePath = this.getClass().getResource("/listener").getPath()+"/"+toUpperCaseFirstOne(data.getName())+"ServiceDaoImplMapper.xml"; |
| New file |
| | |
| | | package com.java110.code; |
| | | |
| | | public class GeneratorUpdateInfoListener extends BaseGenerator { |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 生成代码 |
| | | * @param data |
| | | */ |
| | | public void generator(Data data){ |
| | | StringBuffer sb = readFile(this.getClass().getResource("/template/UpdateInfoListener.txt").getFile()); |
| | | String fileContext = sb.toString(); |
| | | fileContext = fileContext.replace("store",toLowerCaseFirstOne(data.getName())) |
| | | .replace("Store",toUpperCaseFirstOne(data.getName())) |
| | | .replace("商户",data.getDesc()) |
| | | .replace("BUSINESS_TYPE_UPDATE_STORE_INFO",data.getUpdateBusinessTypeCd()); |
| | | System.out.println(this.getClass().getResource("/listener").getPath()); |
| | | String writePath = this.getClass().getResource("/listener").getPath()+"/Update"+toUpperCaseFirstOne(data.getName())+"InfoListener.java"; |
| | | writeFile(writePath, |
| | | fileContext); |
| | | } |
| | | } |
| | |
| | | } |
| | | currentStoreInfo.put("bId",business.getbId()); |
| | | |
| | | $flushBusinessInfo$ |
| | | $autoSaveDelBusiness$ |
| | | |
| | | currentStoreInfo.put("operate",StatusConstant.OPERATE_DEL); |
| | | getStoreServiceDaoImpl().saveBusinessStoreInfo(currentStoreInfo); |
| New file |
| | |
| | | package com.java110.store.listener; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.constant.BusinessTypeConstant; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.constant.StatusConstant; |
| | | import com.java110.common.exception.ListenerExecuteException; |
| | | import com.java110.common.util.Assert; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.store.dao.IStoreServiceDao; |
| | | 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、businessStore:{} 商户基本信息节点 |
| | | * 2、businessStoreAttr:[{}] 商户属性信息节点 |
| | | * 3、businessStorePhoto:[{}] 商户照片信息节点 |
| | | * 4、businessStoreCerdentials:[{}] 商户证件信息节点 |
| | | * 协议地址 :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("deleteStoreInfoListener") |
| | | @Transactional |
| | | public class DeleteStoreInfoListener extends AbstractStoreBusinessServiceDataFlowListener { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(DeleteStoreInfoListener.class); |
| | | @Autowired |
| | | IStoreServiceDao storeServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 3; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_DELETE_STORE_INFO; |
| | | } |
| | | |
| | | /** |
| | | * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessStore 节点 按理这里不应该处理,程序上支持,以防真有这种业务 |
| | | if(data.containsKey("businessStore")){ |
| | | JSONObject businessStore = data.getJSONObject("businessStore"); |
| | | doBusinessStore(business,businessStore); |
| | | dataFlowContext.addParamOut("storeId",businessStore.getString("storeId")); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 删除 instance数据 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) { |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | |
| | | //商户信息 |
| | | Map info = new HashMap(); |
| | | info.put("bId",business.getbId()); |
| | | info.put("operate",StatusConstant.OPERATE_DEL); |
| | | |
| | | //商户信息 |
| | | Map businessStoreInfo = storeServiceDaoImpl.getBusinessStoreInfo(info); |
| | | if( businessStoreInfo != null && !businessStoreInfo.isEmpty()) { |
| | | flushBusinessStoreInfo(businessStoreInfo,StatusConstant.STATUS_CD_INVALID); |
| | | storeServiceDaoImpl.updateStoreInfoInstance(businessStoreInfo); |
| | | dataFlowContext.addParamOut("storeId",businessStoreInfo.get("store_id")); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 撤单 |
| | | * 从business表中查询到DEL的数据 将instance中的数据更新回来 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doRecover(DataFlowContext dataFlowContext, Business business) { |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | Map info = new HashMap(); |
| | | info.put("bId",bId); |
| | | info.put("statusCd",StatusConstant.STATUS_CD_INVALID); |
| | | |
| | | Map delInfo = new HashMap(); |
| | | delInfo.put("bId",business.getbId()); |
| | | delInfo.put("operate",StatusConstant.OPERATE_DEL); |
| | | //商户信息 |
| | | Map storeInfo = storeServiceDaoImpl.getStoreInfo(info); |
| | | if(storeInfo != null && !storeInfo.isEmpty()){ |
| | | |
| | | //商户信息 |
| | | Map businessStoreInfo = storeServiceDaoImpl.getBusinessStoreInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessStoreInfo == null || businessStoreInfo.isEmpty()){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | |
| | | flushBusinessStoreInfo(businessStoreInfo,StatusConstant.STATUS_CD_VALID); |
| | | storeServiceDaoImpl.updateStoreInfoInstance(businessStoreInfo); |
| | | dataFlowContext.addParamOut("storeId",storeInfo.get("store_id")); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessStore 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessStore 商户节点 |
| | | */ |
| | | private void doBusinessStore(Business business,JSONObject businessStore){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessStore,"storeId","businessStore 节点下没有包含 storeId 节点"); |
| | | |
| | | if(businessStore.getString("storeId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storeId 错误,不能自动生成(必须已经存在的storeId)"+businessStore); |
| | | } |
| | | //自动插入DEL |
| | | autoSaveDelBusinessStore(business,businessStore); |
| | | } |
| | | |
| | | public IStoreServiceDao getStoreServiceDaoImpl() { |
| | | return storeServiceDaoImpl; |
| | | } |
| | | |
| | | public void setStoreServiceDaoImpl(IStoreServiceDao storeServiceDaoImpl) { |
| | | this.storeServiceDaoImpl = storeServiceDaoImpl; |
| | | } |
| | | } |
| | |
| | | |
| | | if(businessStore.getString("storeId").startsWith("-")){ |
| | | //刷新缓存 |
| | | flushStoreId(business.getDatas()); |
| | | //flushStoreId(business.getDatas()); |
| | | |
| | | businessStore.put("storeId",GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_storeId)); |
| | | |
| | | } |
| | | |
| | | businessStore.put("bId",business.getbId()); |
| | |
| | | |
| | | <!-- 保存商户信息至 instance表中 add by wuxw 2018-07-03 --> |
| | | <insert id="saveStoreInfoInstance" parameterType="Map"> |
| | | insert into s_store(store_id,b_id,user_id,name,address,tel,store_type_cd,nearby_landmarks,map_x,map_y,status_cd) |
| | | select s.store_id,s.b_id,s.user_id,s.name,s.address,s.tel,s.store_type_cd,s.nearby_landmarks,s.map_x,s.map_y,'0' |
| | | from business_store s where |
| | | s.operate = 'ADD' and s.b_id=#{bId} |
| | | $saveInfoInstance$ |
| | | </insert> |
| | | |
| | | |
| | | |
| | | <!-- 查询商户信息 add by wuxw 2018-07-03 --> |
| | | <select id="getStoreInfo" parameterType="Map" resultType="Map"> |
| | | select s.store_id,s.b_id,s.user_id,s.name,s.address,s.tel,s.store_type_cd,s.nearby_landmarks,s.map_x,s.map_y,s.status_cd |
| | | from s_store s |
| | | where 1=1 |
| | | <if test="statusCd != null and statusCd != ''"> |
| | | and s.status_cd = #{statusCd} |
| | | </if> |
| | | |
| | | <if test="bId != null and bId !=''"> |
| | | and s.b_id = #{bId} |
| | | </if> |
| | | <if test="storeId != null and storeId !=''"> |
| | | and s.store_id = #{storeId} |
| | | </if> |
| | | $getInfo$ |
| | | </select> |
| | | |
| | | |
| | |
| | | |
| | | <!-- 修改商户信息 add by wuxw 2018-07-03 --> |
| | | <update id="updateStoreInfoInstance" parameterType="Map"> |
| | | update s_store s set s.status_cd = #{statusCd} |
| | | <if test="newBId != null and newBId != ''"> |
| | | ,s.b_id = #{newBId} |
| | | </if> |
| | | <if test="userId != null and userId != ''"> |
| | | ,s.user_id = #{userId} |
| | | </if> |
| | | <if test="name != null and name != ''"> |
| | | ,s.name = #{name} |
| | | </if> |
| | | <if test="address != null and address != ''"> |
| | | ,s.address = #{address} |
| | | </if> |
| | | <if test="tel != null and tel != ''"> |
| | | ,s.tel = #{tel} |
| | | </if> |
| | | <if test="storeTypeCd != null and storeTypeCd != ''"> |
| | | ,s.store_type_cd = #{storeTypeCd} |
| | | </if> |
| | | <if test="nearbyLandmarks != null and nearbyLandmarks != ''"> |
| | | ,s.nearby_landmarks = #{nearbyLandmarks} |
| | | </if> |
| | | <if test="mapX != null and mapX != ''"> |
| | | ,s.map_x = #{mapX} |
| | | </if> |
| | | <if test="mapY != null and mapY != ''"> |
| | | ,s.map_y = #{mapY} |
| | | </if> |
| | | where 1=1 |
| | | <if test="bId != null and bId !=''"> |
| | | and s.b_id = #{bId} |
| | | </if> |
| | | <if test="storeId != null and storeId !=''"> |
| | | and s.store_id = #{storeId} |
| | | </if> |
| | | $updateInfoInstance$ |
| | | </update> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | package com.java110.store.listener; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.constant.BusinessTypeConstant; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.constant.StatusConstant; |
| | | import com.java110.common.exception.ListenerExecuteException; |
| | | import com.java110.common.util.Assert; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.store.dao.IStoreServiceDao; |
| | | 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、businessStore:{} 商户基本信息节点 |
| | | * 2、businessStoreAttr:[{}] 商户属性信息节点 |
| | | * 3、businessStorePhoto:[{}] 商户照片信息节点 |
| | | * 4、businessStoreCerdentials:[{}] 商户证件信息节点 |
| | | * 协议地址 :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("updateStoreInfoListener") |
| | | @Transactional |
| | | public class UpdateStoreInfoListener extends AbstractStoreBusinessServiceDataFlowListener { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(UpdateStoreInfoListener.class); |
| | | @Autowired |
| | | IStoreServiceDao storeServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 2; |
| | | } |
| | | |
| | | @Override |
| | | public String getBusinessTypeCd() { |
| | | return BusinessTypeConstant.BUSINESS_TYPE_UPDATE_STORE_INFO; |
| | | } |
| | | |
| | | /** |
| | | * business过程 |
| | | * @param dataFlowContext |
| | | * @param business |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessStore 节点 |
| | | if(data.containsKey("businessStore")){ |
| | | JSONObject businessStore = data.getJSONObject("businessStore"); |
| | | doBusinessStore(business,businessStore); |
| | | dataFlowContext.addParamOut("storeId",businessStore.getString("storeId")); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 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); |
| | | |
| | | //商户信息 |
| | | Map businessStoreInfo = storeServiceDaoImpl.getBusinessStoreInfo(info); |
| | | if( businessStoreInfo != null && !businessStoreInfo.isEmpty()) { |
| | | flushBusinessStoreInfo(businessStoreInfo,StatusConstant.STATUS_CD_VALID); |
| | | storeServiceDaoImpl.updateStoreInfoInstance(businessStoreInfo); |
| | | dataFlowContext.addParamOut("storeId",businessStoreInfo.get("store_id")); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 撤单 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doRecover(DataFlowContext dataFlowContext, Business business) { |
| | | |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | Map info = new HashMap(); |
| | | info.put("bId",bId); |
| | | info.put("statusCd",StatusConstant.STATUS_CD_VALID); |
| | | Map delInfo = new HashMap(); |
| | | delInfo.put("bId",business.getbId()); |
| | | delInfo.put("operate",StatusConstant.OPERATE_DEL); |
| | | //商户信息 |
| | | Map storeInfo = storeServiceDaoImpl.getStoreInfo(info); |
| | | if(storeInfo != null && !storeInfo.isEmpty()){ |
| | | |
| | | //商户信息 |
| | | Map businessStoreInfo = storeServiceDaoImpl.getBusinessStoreInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessStoreInfo == null || businessStoreInfo.isEmpty()){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | |
| | | flushBusinessStoreInfo(businessStoreInfo,StatusConstant.STATUS_CD_VALID); |
| | | storeServiceDaoImpl.updateStoreInfoInstance(businessStoreInfo); |
| | | dataFlowContext.addParamOut("storeId",storeInfo.get("store_id")); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理 businessStore 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessStore 商户节点 |
| | | */ |
| | | private void doBusinessStore(Business business,JSONObject businessStore){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessStore,"storeId","businessStore 节点下没有包含 storeId 节点"); |
| | | |
| | | if(businessStore.getString("storeId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storeId 错误,不能自动生成(必须已经存在的storeId)"+businessStore); |
| | | } |
| | | //自动保存DEL |
| | | autoSaveDelBusinessStore(business,businessStore); |
| | | |
| | | businessStore.put("bId",business.getbId()); |
| | | businessStore.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存商户信息 |
| | | storeServiceDaoImpl.saveBusinessStoreInfo(businessStore); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public IStoreServiceDao getStoreServiceDaoImpl() { |
| | | return storeServiceDaoImpl; |
| | | } |
| | | |
| | | public void setStoreServiceDaoImpl(IStoreServiceDao storeServiceDaoImpl) { |
| | | this.storeServiceDaoImpl = storeServiceDaoImpl; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | public static final String BUSINESS_TYPE_DELETE_COMMUNITY_INFO = "500100050001"; |
| | | |
| | | /** |
| | | * 增加小区楼 |
| | | */ |
| | | public static final String BUSINESS_TYPE_SAVE_FLOOR_INFO = "510100030001"; |
| | | |
| | | /** |
| | | * 修改小区楼 |
| | | */ |
| | | public static final String BUSINESS_TYPE_UPDATE_FLOOR_INFO = "510100040001"; |
| | | |
| | | |
| | | /** |
| | | * 删除小区楼 |
| | | */ |
| | | public static final String BUSINESS_TYPE_DELETE_FLOOR_INFO = "510100050001"; |
| | | |
| | | /** |
| | | * 保存物业信息 |
| | |
| | | private static short lastCount = 1; |
| | | private static int count = 0; |
| | | private static final String first = "10"; |
| | | //10+yyyymmdd+八位序列 |
| | | public static final String CODE_PREFIX_oId = "10"; |
| | | public static final String CODE_PREFIX_bId = "20"; |
| | | public static final String CODE_PREFIX_attrId = "11"; |
| | | public static final String CODE_PREFIX_transactionId = "1000001"; |
| | | public static final String CODE_PREFIX_pageTransactionId = "1000002"; |
| | | public static final String CODE_PREFIX_dataFlowId = "2000"; |
| | | public static final String CODE_PREFIX_userId = "30"; |
| | | public static final String CODE_PREFIX_storeId = "40"; |
| | | public static final String CODE_PREFIX_storePhotoId = "41"; |
| | | public static final String CODE_PREFIX_storeCerdentialsId = "42"; |
| | | public static final String CODE_PREFIX_memberStoreId = "43"; |
| | | public static final String CODE_PREFIX_propertyStoreId = "44"; |
| | | public static final String CODE_PREFIX_storeUserId = "45"; |
| | | public static final String CODE_PREFIX_shopId = "50"; |
| | | public static final String CODE_PREFIX_shopAttrId = "51"; |
| | | public static final String CODE_PREFIX_shopPhotoId = "52"; |
| | | public static final String CODE_PREFIX_shopAttrParamId = "53"; |
| | | public static final String CODE_PREFIX_shopPreferentialId = "54"; |
| | | public static final String CODE_PREFIX_shopDescId = "55"; |
| | | public static final String CODE_PREFIX_shopCatalogId = "56"; |
| | | public static final String CODE_PREFIX_buyId = "57"; |
| | | public static final String CODE_PREFIX_buyAttrId = "58"; |
| | | public static final String CODE_PREFIX_commentId = "60"; |
| | | public static final String CODE_PREFIX_subCommentId = "61"; |
| | | public static final String CODE_PREFIX_subCommentAttrId = "62"; |
| | | public static final String CODE_PREFIX_commentPhotoId = "63"; |
| | | public static final String CODE_PREFIX_commentScoreId = "64"; |
| | | public static final String CODE_PREFIX_communityId = "70"; |
| | | public static final String CODE_PREFIX_communityPhotoId = "71"; |
| | | public static final String CODE_PREFIX_communityMemberId = "72"; |
| | | public static final String CODE_PREFIX_agentId = "80"; |
| | | public static final String CODE_PREFIX_agentPhotoId = "81"; |
| | | public static final String CODE_PREFIX_agentCerdentialsId = "82"; |
| | | public static final String CODE_PREFIX_agentUserId = "83"; |
| | | public static final String CODE_PREFIX_propertyId = "90"; |
| | | public static final String CODE_PREFIX_propertyPhotoId = "91"; |
| | | public static final String CODE_PREFIX_propertyCerdentialsId = "92"; |
| | | public static final String CODE_PREFIX_propertyUserId = "93"; |
| | | public static final String CODE_PREFIX_propertyFeeId = "94"; |
| | | public static final String CODE_PREFIX_houseId = "95"; |
| | | public static final String CODE_PREFIX_pgId = "600"; |
| | | |
| | | public static final String CODE_PREFIX_floorId = "73"; |
| | | |
| | | /** |
| | | * |
| | |
| | | return prefixMap.get("pageTransactionId") + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H) + nextId(); |
| | | } |
| | | |
| | | /** |
| | | * pgId生成 |
| | | * @return |
| | | * @throws GenerateCodeException |
| | | */ |
| | | public static String getGeneratorId(String prefix) throws GenerateCodeException{ |
| | | if(!MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_NEED_INVOKE_GENERATE_ID))){ |
| | | return prefix +DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H)+ nextId("%04d"); |
| | | } |
| | | //调用服务 |
| | | return getCode(prefix); |
| | | } |
| | | |
| | | public static String getOId() throws GenerateCodeException{ |
| | | if(!MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_NEED_INVOKE_GENERATE_ID))){ |
| | | return prefixMap.get("oId") + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H) + nextId("%04d"); |
| | |
| | | |
| | | /** |
| | | * 查询服务 |
| | | * Created by wuxw on 2018/4/20. |
| | | * add by wuxw on 2018/4/20. |
| | | * modify by wuxw on 2019/4/20. |
| | | * @version 1.1 |
| | | */ |
| | | @RestController |
| | | @Api(value = "查询业务统一提供服务") |