Merge remote-tracking branch 'origin/master'
20 files modified
2 files added
| New file |
| | |
| | | package org.springblade.binlog.client; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.binlog.constant.BinLogConstants; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | import java.sql.Connection; |
| | | import java.sql.DriverManager; |
| | | import java.sql.PreparedStatement; |
| | | import java.sql.SQLException; |
| | | |
| | | /** |
| | | * mysql 客户端连接 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class MysqlClient { |
| | | |
| | | //声明对象 |
| | | private static MysqlClient mysqlClient; |
| | | |
| | | |
| | | @Resource |
| | | private BinLogConstants binLogConstants; |
| | | |
| | | /** |
| | | * 初始化 |
| | | */ |
| | | @PostConstruct |
| | | public void init(){ |
| | | mysqlClient = this; |
| | | mysqlClient.binLogConstants = this.binLogConstants; |
| | | } |
| | | |
| | | /** |
| | | * sql 连接 |
| | | * @param sql |
| | | */ |
| | | public static void sqlConnect(String sql,Integer type){ |
| | | String driver = "com.mysql.cj.jdbc.Driver"; |
| | | String url = mysqlClient.binLogConstants.getFromUrl(); |
| | | String user = mysqlClient.binLogConstants.getFromUsername(); |
| | | String password = mysqlClient.binLogConstants.getFromPassword(); |
| | | Connection conn = null; |
| | | PreparedStatement ps = null; |
| | | try { |
| | | Class.forName ( driver ); |
| | | conn = (Connection) DriverManager.getConnection ( url, user, password ); |
| | | if (!conn.isClosed ()) { |
| | | log.info( "数据库连接成功!" ); |
| | | ps = conn.prepareStatement ( sql ); |
| | | //判断是否为修改,删除 |
| | | if (type==1){ |
| | | //修改删除 |
| | | ps.executeUpdate(); |
| | | log.info( "数据已发送成功!" ); |
| | | }else { |
| | | //新增 |
| | | ps.execute(); |
| | | log.info( "数据已发送成功!" ); |
| | | } |
| | | } |
| | | } catch (ClassNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace (); |
| | | }finally { |
| | | try { |
| | | ps.close(); |
| | | conn.close(); |
| | | } catch (SQLException throwables) { |
| | | throwables.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 连接mysql数据库 新增 |
| | | * @param sql |
| | | */ |
| | | public static void insert(String sql) { |
| | | sqlConnect(sql,2); |
| | | } |
| | | |
| | | /** |
| | | * 连接mysql数据库 修改 |
| | | * @param sql |
| | | */ |
| | | public static void update(String sql) { |
| | | sqlConnect(sql,1); |
| | | } |
| | | |
| | | /** |
| | | * 连接mysql数据库 删除 |
| | | * @param sql |
| | | */ |
| | | public static void delete(String sql) { |
| | | sqlConnect(sql,1); |
| | | } |
| | | } |
| | |
| | | @Value("${binlog.table}") |
| | | private String table; |
| | | |
| | | @Value("${binlog.from.datasource.url}") |
| | | private String fromUrl; |
| | | |
| | | @Value("${binlog.from.datasource.username}") |
| | | private String fromUsername; |
| | | |
| | | @Value("${binlog.from.datasource.password}") |
| | | private String fromPassword; |
| | | |
| | | public static final int consumerThreads = 5; |
| | | |
| | | public static final long queueSleep = 1000; |
| New file |
| | |
| | | package org.springblade.binlog.listener; |
| | | |
| | | import com.github.shyiko.mysql.binlog.BinaryLogClient; |
| | | import com.github.shyiko.mysql.binlog.event.Event; |
| | | import com.github.shyiko.mysql.binlog.event.EventData; |
| | | import com.github.shyiko.mysql.binlog.event.QueryEventData; |
| | | import com.github.shyiko.mysql.binlog.event.TableMapEventData; |
| | | import com.github.shyiko.mysql.binlog.event.WriteRowsEventData; |
| | | import com.github.shyiko.mysql.binlog.event.deserialization.EventDeserializer; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import java.io.IOException; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | public class BinlogListenerMixed { |
| | | |
| | | private static final Logger logger = LoggerFactory.getLogger(BinlogListenerMixed.class); |
| | | |
| | | private static final String MYSQL_HOST = "127.0.0.1"; |
| | | private static final int MYSQL_PORT = 3308; |
| | | private static final String MYSQL_USERNAME = "root"; |
| | | private static final String MYSQL_PASSWORD = "root"; |
| | | |
| | | public static void main(String[] args) { |
| | | try { |
| | | BinaryLogClient client = new BinaryLogClient(MYSQL_HOST, MYSQL_PORT, MYSQL_USERNAME, MYSQL_PASSWORD); |
| | | // client.setBinlogFilename(null); |
| | | // client.setBinlogPosition(-1); // 或者设置为其他适当的初始位置 |
| | | // client.setServerId(1); |
| | | // client.setBinlogFilename("mysql-bin.000005"); |
| | | // client.setBinlogPosition(154); |
| | | EventDeserializer eventDeserializer = new EventDeserializer(); |
| | | eventDeserializer.setCompatibilityMode( |
| | | EventDeserializer.CompatibilityMode.DATE_AND_TIME_AS_LONG |
| | | // EventDeserializer.CompatibilityMode.CHAR_AND_BINARY_AS_BYTE_ARRAY 该设置会将varchar 转为 byte[] |
| | | ); |
| | | logger.info("使用主机={}, 端口={}, 用户名={}, 密码={} 连接到 MySQL", MYSQL_HOST, MYSQL_PORT, MYSQL_USERNAME, MYSQL_PASSWORD); |
| | | client.setEventDeserializer(eventDeserializer); |
| | | client.registerEventListener(BinlogListenerMixed::handleEvent); |
| | | client.registerLifecycleListener(new BinaryLogClient.LifecycleListener() { |
| | | @Override |
| | | public void onConnect(BinaryLogClient client) { |
| | | logger.info("Connected to MySQL server"); |
| | | } |
| | | |
| | | @Override |
| | | public void onCommunicationFailure(BinaryLogClient client, Exception ex) { |
| | | logger.error("Communication failure with MySQL server", ex); |
| | | } |
| | | |
| | | @Override |
| | | public void onEventDeserializationFailure(BinaryLogClient client, Exception ex) { |
| | | logger.error("Event deserialization failure", ex); |
| | | } |
| | | |
| | | @Override |
| | | public void onDisconnect(BinaryLogClient client) { |
| | | logger.warn("Disconnected from MySQL server"); |
| | | // 在这里添加重新连接或其他处理逻辑 |
| | | } |
| | | }); |
| | | |
| | | client.connect(); |
| | | } catch (IOException e) { |
| | | logger.error("@@ 连接到 MySQL 时发生错误", e); |
| | | logger.error("@@ Error connecting to MySQL", e); |
| | | } |
| | | } |
| | | |
| | | private static void handleEvent(Event event) { |
| | | logger.info("@@ 打印 event: {}", event); |
| | | logger.info("@@ Received event type: {}", event.getHeader().getEventType()); |
| | | |
| | | switch (event.getHeader().getEventType()) { |
| | | case WRITE_ROWS: |
| | | case EXT_WRITE_ROWS: |
| | | handleWriteRowsEvent((WriteRowsEventData) event.getData()); |
| | | break; |
| | | case QUERY: |
| | | handleQueryEvent((QueryEventData) event.getData()); |
| | | break; |
| | | case TABLE_MAP: |
| | | handleTableMapEvent((TableMapEventData) event.getData()); |
| | | break; |
| | | // 其他事件处理... |
| | | } |
| | | } |
| | | |
| | | private static void handleWriteRowsEvent(WriteRowsEventData eventData) { |
| | | List<Serializable[]> rows = eventData.getRows(); |
| | | |
| | | // 获取表名 |
| | | String tableName = getTableName(eventData); |
| | | |
| | | // 处理每一行数据 |
| | | for (Serializable[] row : rows) { |
| | | // 根据需要调整以下代码以获取具体的列值 |
| | | String column1Value = row[0].toString(); |
| | | String column2Value = row[1].toString(); |
| | | String url = row[2].toString(); |
| | | logger.info(url); |
| | | |
| | | // 将数据备份到另一个数据库 |
| | | backupToAnotherDatabase(tableName, column1Value, column2Value); |
| | | } |
| | | } |
| | | |
| | | private static void handleQueryEvent(QueryEventData eventData) { |
| | | String sql = eventData.getSql(); |
| | | logger.info("@@ handleQueryEvent函数执行Query event SQL: {}", sql); |
| | | |
| | | // 解析SQL语句,根据需要处理 |
| | | // 例如,检查是否包含写入操作,然后执行相应的逻辑 |
| | | } |
| | | |
| | | private static void handleTableMapEvent(TableMapEventData eventData) { |
| | | // 获取表映射信息,根据需要处理 |
| | | logger.info("@@ handleTableMapEvent函数执行TableMap event: {}", eventData); |
| | | } |
| | | |
| | | private static String getTableName(EventData eventData) { |
| | | // 获取表名的逻辑,可以使用TableMapEventData等信息 |
| | | // 根据实际情况实现 |
| | | return "example_table"; |
| | | } |
| | | |
| | | private static void backupToAnotherDatabase(String tableName, String column1Value, String column2Value) { |
| | | // 将数据备份到另一个数据库的逻辑 |
| | | logger.info("Backup to another database: Table={}, Column1={}, Column2={}", tableName, column1Value, column2Value); |
| | | } |
| | | } |
| | |
| | | */ |
| | | public MysqlBinLogListener(DataSourceConfig conf) { |
| | | BinaryLogClient client = new BinaryLogClient(conf.getHost(), conf.getPort(), conf.getUsername(), conf.getPassword()); |
| | | // 序列化 EventDeserializer.CompatibilityMode.CHAR_AND_BINARY_AS_BYTE_ARRAY 该设置会将varchar 转为 byte[] |
| | | EventDeserializer eventDeserializer = new EventDeserializer(); |
| | | //eventDeserializer.setCompatibilityMode(//序列化 |
| | | // EventDeserializer.CompatibilityMode.DATE_AND_TIME_AS_LONG, |
| | | // EventDeserializer.CompatibilityMode.CHAR_AND_BINARY_AS_BYTE_ARRAY |
| | | //); |
| | | eventDeserializer.setCompatibilityMode(EventDeserializer.CompatibilityMode.DATE_AND_TIME_AS_LONG |
| | | ); |
| | | client.setEventDeserializer(eventDeserializer); |
| | | this.parseClient = client; |
| | | this.queue = new ArrayBlockingQueue<>(1024); |
| | |
| | | package org.springblade.binlog.listener; |
| | | |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.binlog.client.MysqlClient; |
| | | import org.springblade.binlog.config.DataSourceConfig; |
| | | import org.springblade.binlog.constant.BinLogConstants; |
| | | import org.springblade.binlog.util.BinLogUtils; |
| | | import org.springblade.binlog.vo.BinLogItem; |
| | | import org.springblade.binlog.vo.DataProperty; |
| | | import org.springframework.boot.CommandLineRunner; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 乐游监听器 |
| | |
| | | log.info("注册监听信息,注册DB:" + binLogConstants.getDb() + ",注册表:" + table); |
| | | try { |
| | | mysqlBinLogListener.regListener(binLogConstants.getDb(), table, item -> { |
| | | log.info("监听逻辑处理"); |
| | | if (item.getEventType().name().equals("EXT_WRITE_ROWS")){ |
| | | // 新增处理逻辑 |
| | | saveHandle(item); |
| | | } |
| | | if (item.getEventType().name().equals("EXT_UPDATE_ROWS")){ |
| | | // 更新处理逻辑 |
| | | updateHandle(item); |
| | | } |
| | | if (item.getEventType().name().equals("EXT_DELETE_ROWS")){ |
| | | // 删除处理逻辑 |
| | | deletedHandle(item); |
| | | } |
| | | }); |
| | | } catch (Exception e) { |
| | | log.error("BinLog监听异常:" + e); |
| | |
| | | // 多线程消费 |
| | | mysqlBinLogListener.parse(); |
| | | } |
| | | |
| | | /** |
| | | * 新增处理逻辑 |
| | | * @param item |
| | | */ |
| | | private void saveHandle(BinLogItem item) { |
| | | String tableName = item.getDbTable().split("-")[1]; |
| | | Map<String, Serializable> data = item.getAfter(); |
| | | Map<String, DataProperty> dataProperty = item.getDataProperty(); |
| | | // 创建更新对象 |
| | | List<String> keyList = new ArrayList<>(); |
| | | List<String> valueList = new ArrayList<>(); |
| | | // 遍历匹配数据 |
| | | dataProperty.forEach((key,value)->{ |
| | | // log.info("数据类型 " + value.dataType); |
| | | if(null!=data.get(key)) { |
| | | keyList.add(key); |
| | | if (value.dataType.equals("varchar") || |
| | | value.getDataType().equals("char")) { |
| | | valueList.add("'" + data.get(key).toString() + "'"); |
| | | }else if(value.dataType.equals("text") || |
| | | value.dataType.equals("mediumtext")) { |
| | | byte[] bytes = (byte[])data.get(key); |
| | | valueList.add("'" + new String(bytes) + "'"); |
| | | }else if(value.dataType.equals("date") || |
| | | value.getDataType().equals("datetime")) { |
| | | Long time = Long.parseLong(data.get(key).toString()); |
| | | valueList.add("'" + BinLogUtils.getDateFormatStr(new Date(time)) + "'"); |
| | | }else { |
| | | valueList.add(data.get(key).toString()); |
| | | } |
| | | } |
| | | }); |
| | | // 拼接sql |
| | | StringBuilder sqlBuilder = new StringBuilder(); |
| | | sqlBuilder.append("insert into ") |
| | | .append(tableName) |
| | | .append("(") |
| | | .append(String.join(",",keyList)) |
| | | .append(") ") |
| | | .append(" values (") |
| | | .append(String.join(",",valueList)) |
| | | .append(");"); |
| | | log.info("sql: " + sqlBuilder.toString()); |
| | | // 同步到其他数据库 |
| | | MysqlClient.insert(sqlBuilder.toString()); |
| | | } |
| | | |
| | | /** |
| | | * 修改处理逻辑 |
| | | * @param item |
| | | */ |
| | | private void updateHandle(BinLogItem item) { |
| | | String tableName = item.getDbTable().split("-")[1]; |
| | | Map<String, Serializable> data = item.getAfter(); |
| | | Map<String, DataProperty> dataProperty = item.getDataProperty(); |
| | | // 创建更新对象 |
| | | List<String> updateList = new ArrayList<>(); |
| | | // 遍历匹配数据 |
| | | dataProperty.forEach((key,value)->{ |
| | | // log.info("数据类型 " + value.dataType); |
| | | if(null!=data.get(key) && !key.equals("id")) { |
| | | if (value.dataType.equals("varchar") || |
| | | value.getDataType().equals("char")) { |
| | | updateList.add(key + " = '" + data.get(key).toString() + "'"); |
| | | }else if(value.dataType.equals("text") || |
| | | value.dataType.equals("mediumtext")) { |
| | | byte[] bytes = (byte[])data.get(key); |
| | | updateList.add(key + " = '" + new String(bytes) + "'"); |
| | | }else if(value.dataType.equals("date") || |
| | | value.getDataType().equals("datetime")) { |
| | | Long time = Long.parseLong(data.get(key).toString()); |
| | | updateList.add(key + " = '" + BinLogUtils.getDateFormatStr(new Date(time)) + "'"); |
| | | }else { |
| | | updateList.add(key + " = " + data.get(key).toString()); |
| | | } |
| | | } |
| | | }); |
| | | // 拼接sql |
| | | StringBuilder sqlBuilder = new StringBuilder(); |
| | | sqlBuilder.append("update ") |
| | | .append(tableName) |
| | | .append(" set ") |
| | | .append(String.join(",",updateList)) |
| | | .append(" where id = ") |
| | | .append(data.get("id")) |
| | | .append(";"); |
| | | log.info("sql: " + sqlBuilder.toString()); |
| | | // 同步到其他数据库 |
| | | MysqlClient.update(sqlBuilder.toString()); |
| | | } |
| | | |
| | | /** |
| | | * 删除处理逻辑 |
| | | * @param item 数据 |
| | | */ |
| | | private void deletedHandle(BinLogItem item) { |
| | | String tableName = item.getDbTable().split("-")[1]; |
| | | Map<String, Serializable> data = item.getBefore(); |
| | | // 拼接sql |
| | | StringBuilder sqlBuilder = new StringBuilder(); |
| | | sqlBuilder.append("delete from ") |
| | | .append(tableName) |
| | | .append(" where id = ") |
| | | .append(data.get("id")) |
| | | .append(";"); |
| | | log.info("sql: " + sqlBuilder.toString()); |
| | | // 同步到其他数据库 |
| | | MysqlClient.delete(sqlBuilder.toString()); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | import org.springblade.binlog.config.DataSourceConfig; |
| | | import org.springblade.binlog.vo.BinLogItem; |
| | | import org.springblade.binlog.vo.DataProperty; |
| | | import org.springblade.core.tool.utils.CollectionUtil; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springframework.stereotype.Component; |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.sql.*; |
| | | import java.util.Arrays; |
| | |
| | | public class BinLogUtils { |
| | | |
| | | private static BinLogUtils binLogUtils; |
| | | |
| | | // @Resource |
| | | // private SearchStoreLogoExtMapper searchStoreLogoExtMapper; |
| | | |
| | | // @PostConstruct |
| | | // public void init() { |
| | | // binLogUtils = this; |
| | | // binLogUtils.searchStoreLogoExtMapper = this.searchStoreLogoExtMapper; |
| | | // } |
| | | |
| | | /** |
| | | * 拼接dbTable |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | // /** |
| | | // * 根据table获取code |
| | | // * |
| | | // * @param table |
| | | // * @return java.lang.Integer |
| | | // */ |
| | | // public static Integer getCodeByTable(String table) { |
| | | // if (StringUtils.isEmpty(table)) { |
| | | // return null; |
| | | // } |
| | | // return CategoryEnum.getCodeByTab(table); |
| | | // } |
| | | |
| | | // public static String getMsgByTab(String table) { |
| | | // if (StringUtils.isEmpty(table)) { |
| | | // return null; |
| | | // } |
| | | // return CategoryEnum.getMsgByTab(table); |
| | | // } |
| | | |
| | | /** |
| | | * 根据DBTable获取table |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | // /** |
| | | // * 根据storeId获取imgUrl |
| | | // */ |
| | | // public static String getImgUrl(Long storeId) { |
| | | // |
| | | // if (storeId == null) { |
| | | // return ""; |
| | | // } |
| | | // //获取url |
| | | // SearchStoreLogo searchStoreLogo = new SearchStoreLogo(); |
| | | // searchStoreLogo.setStoreId(storeId); |
| | | // List<SearchStoreLogo> searchStoreLogos = binLogUtils.searchStoreLogoExtMapper.selectList(searchStoreLogo); |
| | | // if (CollectionUtil.isNotEmpty(searchStoreLogos)) { |
| | | // SearchStoreLogo storeLogo = searchStoreLogos.get(0); |
| | | // if (storeLogo != null) { |
| | | // return storeLogo.getStoreLogo(); |
| | | // } |
| | | // } |
| | | // return ""; |
| | | // } |
| | | |
| | | /** |
| | | * 格式化date |
| | | * |
| | |
| | | Date formatDate = DateUtil.parse(strDate, dateFormat); |
| | | return formatDate; |
| | | } |
| | | |
| | | /** |
| | | * 格式化date |
| | | * |
| | | * @param date |
| | | * @return java.util.Date |
| | | */ |
| | | public static String getDateFormatStr(Date date) { |
| | | if (date == null) { |
| | | return null; |
| | | } |
| | | String dateFormat = "yyyy-MM-dd HH:mm:ss"; |
| | | return DateUtil.format(date, dateFormat); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | String getDistrictId(String houseCode); |
| | | |
| | | List<ArticleVO> getArticleByDistrictId(ArticleVO article); |
| | | List<ArticleVO> getArticleByDistrictId(@Param("article") ArticleVO article); |
| | | } |
| | |
| | | |
| | | <if test="article.districtId != null and article.districtId != ''"> |
| | | and (ja.article_range like concat('%',#{article.districtId},'%') |
| | | or ja.article_range is null) |
| | | or ja.article_range is null or ja.article_range = '') |
| | | </if> |
| | | |
| | | <if test="article.userId != null"> |
| | | and (jpd.appoint_user like concat('%',#{article.userId},'%') |
| | | or jpd.appoint_user is null) |
| | | and (jpd.user_ids like concat('%',#{article.userId},'%') |
| | | OR jpd.user_ids IS NULL or jpd.user_ids = '') |
| | | </if> |
| | | |
| | | <if test="article.building != null and article.building != ''"> |
| | |
| | | jczz_article ja |
| | | LEFT JOIN jczz_district jd ON ja.district_id = jd.id |
| | | LEFT JOIN blade_region br on br.`code` = jd.community_code |
| | | LEFT JOIN jczz_public_discuss jpd on jpd.article_id=ja.id |
| | | where 1=1 |
| | | and ja.is_deleted = 0 |
| | | |
| | | <if test="article.eventType != null"> |
| | | and jpd.event_type = #{article.eventType} |
| | | and jpd.end_time is not null |
| | | </if> |
| | | |
| | | <if test="article.propertyFlag!=null "> |
| | | <if test="article.communityName!=null and article.communityName!=''"> |
| | | and br.`village_name` like concat('%',#{article.communityName},'%') |
| | |
| | | |
| | | @Override |
| | | public List<ArticleVO> getArticleByDistrictId(ArticleVO article) { |
| | | List<String> objects = new ArrayList<>(); |
| | | objects.add(article.getDistrictId()); |
| | | article.setDistrictIdList(objects); |
| | | return baseMapper.getArticleByDistrictId(article); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param place |
| | | * @param houseCodeList |
| | | * @param regionChildCodesList |
| | | * @param isAdministrator |
| | | * @return |
| | | */ |
| | | List<PlaceVO> selectPlacePage(IPage page, |
| | | @Param("place") PlaceVO place, |
| | | @Param("gridCodeList") List<String> gridCodeList, |
| | | @Param("regionChildCodesList") List<String> regionChildCodesList, |
| | | @Param("isAdministrator") Integer isAdministrator); |
| | | |
| | | /** |
| | | * 九小场所档案 |
| | | * |
| | | * @param page |
| | |
| | | @Param("isAdministrator") Integer isAdministrator, |
| | | @Param("nineTypeList") List<String> nineTypeList); |
| | | |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param place |
| | | * @param houseCodeList |
| | | * @param regionChildCodesList |
| | | * @param isAdministrator |
| | | * @return |
| | | */ |
| | | List<PlaceVO> selectPlacePage(IPage page, |
| | | @Param("place") PlaceVO place, |
| | | @Param("houseCodeList") List<String> houseCodeList, |
| | | @Param("regionChildCodesList") List<String> regionChildCodesList, |
| | | @Param("isAdministrator") Integer isAdministrator); |
| | | |
| | | /** |
| | | * 查询场所集合信息 |
| | |
| | | <if test="place.isPerfect==2"> |
| | | and jp.status = 2 |
| | | </if> |
| | | <if test="houseCodeList != null and houseCodeList.size()>0"> |
| | | and jp.house_code in |
| | | <foreach collection="houseCodeList" item="houseCode" separator ="," open="(" close=")"> |
| | | #{houseCode} |
| | | </foreach> |
| | | </if> |
| | | <if test="isAdministrator==2"> |
| | | <choose> |
| | | <when test="regionChildCodesList !=null and regionChildCodesList.size()>0"> |
| | | and jg.grid_code in |
| | | <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=","> |
| | | #{code} |
| | | </foreach> |
| | | <when test="place.roleName != null and place.roleName != ''"> |
| | | <if test="place.roleName=='wgy'"> |
| | | <choose> |
| | | <when test="gridCodeList !=null and gridCodeList.size()>0"> |
| | | and jp.grid_code in |
| | | <foreach collection="gridCodeList" item="code" open="(" close=")" separator=","> |
| | | #{code} |
| | | </foreach> |
| | | </when> |
| | | <otherwise> |
| | | and jp.grid_code in ('') |
| | | </otherwise> |
| | | </choose> |
| | | </if> |
| | | <if test="place.roleName=='mj'"> |
| | | <choose> |
| | | <when test="regionChildCodesList !=null and regionChildCodesList.size()>0"> |
| | | and jpag.community_code in |
| | | <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=","> |
| | | #{code} |
| | | </foreach> |
| | | </when> |
| | | <otherwise> |
| | | and jpag.community_code in ('') |
| | | </otherwise> |
| | | </choose> |
| | | </if> |
| | | </when> |
| | | <otherwise> |
| | | and jg.grid_code in ('') |
| | | <choose> |
| | | <when test="regionChildCodesList !=null and regionChildCodesList.size()>0"> |
| | | and |
| | | ( |
| | | jg.grid_code in |
| | | <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=","> |
| | | #{code} |
| | | </foreach> |
| | | or |
| | | jpag.community_code in |
| | | <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=","> |
| | | #{code} |
| | | </foreach> |
| | | ) |
| | | </when> |
| | | <otherwise> |
| | | and |
| | | ( |
| | | jg.grid_code in ('') or jpag.community_code in ('') |
| | | ) |
| | | </otherwise> |
| | | </choose> |
| | | </otherwise> |
| | | </choose> |
| | | </if> |
| | |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.common.cache.SysCache; |
| | | import org.springblade.common.node.TreeStringNode; |
| | | import org.springblade.common.param.CommonParamSet; |
| | | import org.springblade.common.utils.IdUtils; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.mp.support.Condition; |
| | |
| | | import org.springblade.modules.place.service.IPlaceExtService; |
| | | import org.springblade.modules.place.service.IPlacePoiLabelService; |
| | | import org.springblade.modules.place.service.IPlaceRelService; |
| | | import org.springblade.modules.place.vo.PlaceCheckVO; |
| | | import org.springblade.modules.place.vo.PlacePoiLabelVO; |
| | | import org.springblade.modules.place.vo.PlaceVO; |
| | | import org.springblade.modules.place.mapper.PlaceMapper; |
| | |
| | | */ |
| | | @Override |
| | | public IPage<PlaceVO> selectPlacePage(IPage<PlaceVO> page, PlaceVO place) { |
| | | List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId()); |
| | | Integer isAdministrator = AuthUtil.isAdministrator() == true ? 1 : 2; |
| | | List<String> list = new ArrayList<>(); |
| | | if (null != place.getRoleName() && !place.getRoleName().equals("")) { |
| | | if (place.getRoleName().equals("网格员")) { |
| | | // 查询对应的房屋地址code |
| | | list = gridService.getAddressCodeListByUserId(AuthUtil.getUserId()); |
| | | } |
| | | } |
| | | List<PlaceVO> placeVOS = baseMapper.selectPlacePage(page, place, list, regionChildCodesList, isAdministrator); |
| | | // 公共参数设置 |
| | | CommonParamSet commonParamSet = new CommonParamSet().invoke(PlaceVO.class,place); |
| | | List<PlaceVO> placeVOS = baseMapper.selectPlacePage(page, |
| | | place, |
| | | commonParamSet.getGridCodeList(), |
| | | commonParamSet.getRegionChildCodesList(), |
| | | commonParamSet.getIsAdministrator()); |
| | | // 返回 |
| | | return page.setRecords(placeVOS); |
| | | } |
| | |
| | | } |
| | | } else { |
| | | // 一对一,暂时不处理,后续考虑需加绑定关系表 |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | && !Strings.isBlank(placeVO.getLocation()) |
| | | && !Strings.isBlank(placeVO.getPlaceName()) |
| | | && !Strings.isBlank(placeVO.getImageUrls()) |
| | | && !Strings.isBlank(placeVO.getPrincipalIdCard()) |
| | | ) { |
| | | // 已完善 |
| | | placeVO.setStatus(2); |
| | |
| | | if (null != addressEntity) { |
| | | placeVO = new PlaceVO(); |
| | | placeVO.setDoorplateAddressEntity(addressEntity); |
| | | placeVO.setHouseCode(addressEntity.getAddressCode()); |
| | | placeVO.setLng(addressEntity.getX()); |
| | | placeVO.setLat(addressEntity.getY()); |
| | | placeVO.setLocation(addressEntity.getAddressName()); |
| | |
| | | |
| | | private String taskId; |
| | | |
| | | private Integer articleId; |
| | | |
| | | } |
| | |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="article_id" property="articleId"/> |
| | | </resultMap> |
| | | |
| | | <!--自定义分页查询--> |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.commons.beanutils.BeanUtils; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.task.dto.TaskBailReportingEventDTO; |
| | | import org.springblade.modules.task.entity.TaskBailReportingEventEntity; |
| | |
| | | @ApiOperation(value = "详情", notes = "传入taskBailReportingEvent") |
| | | public R<TaskBailReportingEventVO> detail(TaskBailReportingEventEntity taskBailReportingEvent) { |
| | | TaskBailReportingEventEntity detail = taskBailReportingEventService.getOne(Condition.getQueryWrapper(taskBailReportingEvent)); |
| | | return R.data(TaskBailReportingEventWrapper.build().entityVO(detail)); |
| | | TaskBailReportingEventVO copy = BeanUtil.copy(detail, TaskBailReportingEventVO.class); |
| | | return R.data(copy); |
| | | } |
| | | /** |
| | | * 取保候审任务 分页 |
| | |
| | | jt.source, |
| | | jt.is_deleted, |
| | | jt.house_code, |
| | | jt.report_type |
| | | jt.report_type, |
| | | jtbre.start_time startTimes, |
| | | jtbre.reach_time, |
| | | jtbre.return_time |
| | | FROM |
| | | jczz_task jt |
| | | LEFT JOIN jczz_house jh ON jt.house_code=jh.house_code and jh.is_deleted = 0 |
| | | LEFT JOIN blade_user bu on bu.id = jt.create_user and bu.is_deleted = 0 |
| | | LEFT JOIN jczz_grid jg on jg.grid_code = jh.grid_code and jg.is_deleted = 0 |
| | | LEFT JOIN blade_region br on br.code = jg.community_code |
| | | LEFT JOIN jczz_task_bail_reporting_event jtbre on jtbre.task_id = jt.id |
| | | <where> |
| | | <if test="task.roleName != null and task.roleName != ''"> |
| | | <if test="task.roleName=='wgy'"> |
| | |
| | | <select id="selectTaskPageBy" resultType="org.springblade.modules.task.vo.TaskVO"> |
| | | SELECT |
| | | jt.* , |
| | | jda.address_name |
| | | jda.address_name, |
| | | jtbre.start_time startTimes, |
| | | jtbre.reach_time, |
| | | jtbre.return_time |
| | | FROM |
| | | jczz_task jt |
| | | LEFT JOIN jczz_doorplate_address jda ON jt.house_code = jda.address_code |
| | | LEFT JOIN jczz_community jc ON jc.CODE = jda.nei_code |
| | | LEFT JOIN jczz_task_bail_reporting_event jtbre on jtbre.task_id = jt.id |
| | | <where> |
| | | <if test="task.reportType != null and task.reportType != '' and task.reportType == 1"> |
| | | AND jt.report_type = #{task.reportType} |
| | |
| | | jt.source, |
| | | jt.is_deleted, |
| | | jt.house_code, |
| | | jt.report_type |
| | | jt.report_type, |
| | | jtbre.start_time startTimes, |
| | | jtbre.reach_time, |
| | | jtbre.return_time |
| | | FROM |
| | | jczz_task jt |
| | | LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jt.house_code |
| | |
| | | */ |
| | | package org.springblade.modules.task.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.modules.task.entity.TaskEntity; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 任务表 视图实体类 |
| | |
| | | |
| | | private String frontType; |
| | | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date startTimes; |
| | | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date reachTime; |
| | | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date returnTime; |
| | | |
| | | } |
| | |
| | | </choose> |
| | | </if> |
| | | </where> |
| | | order by jpc.create_time desc |
| | | </select> |
| | | |
| | | <resultMap type="org.springblade.modules.taskPlaceSelfCheck.dto.TaskPlaceSelfCheckDTO" |
| | |
| | | |
| | | |
| | | <!--导出消防自查信息--> |
| | | <select id="exportTaskPlaceSelfCheck" resultType="org.springblade.modules.taskPlaceSelfCheck.excel.TaskPlaceSelfCheckExcel"> |
| | | <select id="exportTaskPlaceSelfCheck" |
| | | resultType="org.springblade.modules.taskPlaceSelfCheck.excel.TaskPlaceSelfCheckExcel"> |
| | | select |
| | | jpc.id, |
| | | case when jpc.status=1 then '待审核' |
| | |
| | | db: jczz # 监听数据库 |
| | | table: jczz_house,jczz_household,jczz_place |
| | | enabled: false |
| | | # 目标数据库 |
| | | from: |
| | | datasource: |
| | | url: jdbc:mysql://106.225.193.35:3306/srjw?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true |
| | | username: root |
| | | password: HCyj@2022 |
| | |
| | | # binlog listener |
| | | binlog: |
| | | datasource: # 订阅binlog数据库连接信息,ip,端口,用户密码(用户必须要有权限) |
| | | host: 127.0.0.1 |
| | | host: 172.16.50.240 |
| | | port: 3306 |
| | | username: root |
| | | password: 1qaz@WSX3edc |
| | | db: jczz # 监听数据库 |
| | | table: jczz_house,jczz_household,jczz_place |
| | | enabled: false |
| | | # table: jczz_house,jczz_household,jczz_place,jczz_place_check,jczz_place_ext,jczz_place_poi_label,jczz_place_practitioner,jczz_police_affairs_grid,jczz_task_label_reporting_event,jczz_patrol_record,blade_attach_data |
| | | table: blade_attach_data |
| | | enabled: true |
| | | # 目标数据库 |
| | | from: |
| | | datasource: |
| | | url: jdbc:mysql://czfw_wx_web.xzga.top:13005/srjw?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true |
| | | username: ewm_user |
| | | password: ft@135246 |
| | |
| | | |
| | | # binlog listener |
| | | binlog: |
| | | # 源数据库 |
| | | datasource: |
| | | host: 127.0.0.1 |
| | | port: 3308 |
| | | username: root |
| | | password: root |
| | | db: jczz_test |
| | | table: jczz_house,jczz_household,jczz_place |
| | | table: jczz_house,jczz_household,jczz_place,jczz_place_ext,blade_attach_data |
| | | enabled: false |
| | | # 目标数据库 |
| | | from: |
| | | datasource: |
| | | url: jdbc:mysql://106.225.193.35:3306/srjw?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true |
| | | username: root |
| | | password: HCyj@2022 |
| | |
| | | # - /blade-taskReportForRepairs/** |
| | | # - /blade-placeExt/** |
| | | # - /blade-grid/** |
| | | # - /blade-community/** |
| | | # - /blade-gridman/** |
| | | # - /blade-propertyCompany/** |
| | | # - /blade-eCallEvent/** |
| | | # - /blade-system/** |
| | | # - /blade-propertyCompanyComment/** |
| | | # - /blade-policeStation/** |
| | | # - /blade-policeAffairsGrid/** |
| | | #授权认证配置 |
| | | auth: |
| | | - method: ALL |