Compare commits

...

2 Commits

Author SHA1 Message Date
fengchunyu 2b346567ed 实有房屋 清洗到业务表
11 months ago
fengchunyu d8072f5021 log日志输出地址改变
11 months ago

@ -1,3 +1,4 @@
# mysql-oracle-dynamic-datasource # mysql-oracle-dynamic-datasource
SpringBoot集成MyBatis-Plus动态数据源测试同时集成Mysql和Oracle SpringBoot集成MyBatis-Plus动态数据源测试同时集成Mysql和Oracle
射阳源数据表接入 射阳源数据表接入
射阳科信相关业务

@ -21,7 +21,8 @@ metaActualUnitUserInfoSwitch=false
metaActualUserInfoSwitch=false metaActualUserInfoSwitch=false
actualTimecjxxSwitch=false actualTimecjxxSwitch=false
actualTimejjxxSwitch=false actualTimejjxxSwitch=false
RentalHouseSwitch=true RentalHouseSwitch=false
metaRealEstateInfoSwitch=true

@ -0,0 +1,56 @@
package com.ssf.mysqloracletest.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* (MetaRealEstateInfo)Domain
*
* @author makejava
* @since 2023-12-05 09:24:09
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName(value = "meta_real_estate_info")
public class MetaRealEstateInfo {
/**
*
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* ID
*/
private String homeId;
/**
*
*/
private String policeStationCode;
/**
*
*/
private String policeDistrictCode;
/**
*
*/
private String realEstateAddress;
/**
*
*/
private Double longitude;
/**
*
*/
private Double latitude;
}

@ -0,0 +1,30 @@
package com.ssf.mysqloracletest.domain;
import lombok.Data;
/**
* v_jwt_syfw
*
* @author ruoyi
* @date 2023-12-04
*/
@Data
public class VJwtSyfw {
private Long id;
private String pcsdm;
private String jwqdm;
private String mc;
private String x;
private String y;
private String oldid;
private String status;
}

@ -0,0 +1,16 @@
package com.ssf.mysqloracletest.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ssf.mysqloracletest.domain.MetaRealEstateInfo;
import org.apache.ibatis.annotations.Mapper;
/**
* (MetaRealEstateInfo)Mapper
*
* @author makejava
* @since 2023-12-05 09:24:09
*/
@Mapper
public interface MetaRealEstateInfoMapper extends BaseMapper<MetaRealEstateInfo> {
}

@ -0,0 +1,64 @@
package com.ssf.mysqloracletest.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ssf.mysqloracletest.domain.VJwtSyfw;
import java.util.List;
/**
* Mapper
*
* @author ruoyi
* @date 2023-12-04
*/
public interface VJwtSyfwMapper extends BaseMapper<VJwtSyfw> {
/**
*
*
* @param id
* @return
*/
public VJwtSyfw selectVJwtSyfwById(Long id);
/**
*
*
* @param vJwtSyfw
* @return
*/
public List<VJwtSyfw> selectVJwtSyfwList(VJwtSyfw vJwtSyfw);
/**
*
*
* @param vJwtSyfw
* @return
*/
public int insertVJwtSyfw(VJwtSyfw vJwtSyfw);
/**
*
*
* @param vJwtSyfw
* @return
*/
public int updateVJwtSyfw(VJwtSyfw vJwtSyfw);
public int updateVJwtSyfwByMc(VJwtSyfw vJwtSyfw);
/**
*
*
* @param id
* @return
*/
public int deleteVJwtSyfwById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteVJwtSyfwByIds(Long[] ids);
}

@ -0,0 +1,69 @@
package com.ssf.mysqloracletest.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ssf.mysqloracletest.domain.VJwtSyfw;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2023-12-04
*/
@Service
public interface JwtSyfwService extends IService<VJwtSyfw> {
/**
*
*
* @param id
* @return
*/
public VJwtSyfw selectVJwtSyfwById(Long id);
/**
*
*
* @param vJwtSyfw
* @return
*/
public List<VJwtSyfw> selectVJwtSyfwList(VJwtSyfw vJwtSyfw);
/**
*
*
* @param vJwtSyfw
* @return
*/
public int insertVJwtSyfw(VJwtSyfw vJwtSyfw);
/**
*
*
* @param vJwtSyfw
* @return
*/
public int updateVJwtSyfw(VJwtSyfw vJwtSyfw);
public int updateVJwtSyfwByMc(VJwtSyfw vJwtSyfw);
/**
*
*
* @param ids
* @return
*/
public int deleteVJwtSyfwByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteVJwtSyfwById(Long id);
public boolean saveOrUpdate(VJwtSyfw bean);
}

@ -0,0 +1,23 @@
package com.ssf.mysqloracletest.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ssf.mysqloracletest.domain.MetaRealEstateInfo;
/**
* (MetaRealEstateInfo)Service
*
* @author makejava
* @since 2023-12-05 09:24:09
*/
public interface MetaRealEstateInfoService extends IService<MetaRealEstateInfo> {
/**
*
*
* @param metaRealEstateInfo
* @return
*/
boolean insertOrUpdate(MetaRealEstateInfo metaRealEstateInfo);
}

@ -0,0 +1,24 @@
package com.ssf.mysqloracletest.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ssf.mysqloracletest.domain.MetaRealEstateInfo;
import com.ssf.mysqloracletest.mapper.MetaRealEstateInfoMapper;
import com.ssf.mysqloracletest.service.MetaRealEstateInfoService;
import org.springframework.stereotype.Service;
/**
* (MetaRealEstateInfo)ServiceImpl
*
* @author makejava
* @since 2023-12-05 09:24:09
*/
@Service
public class MetaRealEstateInfoServiceImpl extends ServiceImpl<MetaRealEstateInfoMapper, MetaRealEstateInfo> implements MetaRealEstateInfoService {
@Override
public boolean insertOrUpdate(MetaRealEstateInfo metaRealEstateInfo) {
return false;
}
}

@ -0,0 +1,117 @@
package com.ssf.mysqloracletest.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ssf.mysqloracletest.domain.VJwtSyfw;
import com.ssf.mysqloracletest.mapper.VJwtSyfwMapper;
import com.ssf.mysqloracletest.service.JwtSyfwService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2023-12-04
*/
@Service
@RequiredArgsConstructor
public class VJwtSyfwServiceImpl extends ServiceImpl<VJwtSyfwMapper, VJwtSyfw>
implements JwtSyfwService {
private final VJwtSyfwMapper vJwtSyfwMapper;
/**
*
*
* @param id
* @return
*/
@Override
public VJwtSyfw selectVJwtSyfwById(Long id) {
return vJwtSyfwMapper.selectVJwtSyfwById(id);
}
/**
*
*
* @param vJwtSyfw
* @return
*/
@Override
public List<VJwtSyfw> selectVJwtSyfwList(VJwtSyfw vJwtSyfw) {
return vJwtSyfwMapper.selectVJwtSyfwList(vJwtSyfw);
}
/**
*
*
* @param vJwtSyfw
* @return
*/
@Override
public int insertVJwtSyfw(VJwtSyfw vJwtSyfw) {
return vJwtSyfwMapper.insertVJwtSyfw(vJwtSyfw);
}
/**
*
*
* @param vJwtSyfw
* @return
*/
@Override
public int updateVJwtSyfw(VJwtSyfw vJwtSyfw) {
return vJwtSyfwMapper.updateVJwtSyfw(vJwtSyfw);
}
@Override
public int updateVJwtSyfwByMc(VJwtSyfw vJwtSyfw) {
return vJwtSyfwMapper.updateVJwtSyfwByMc(vJwtSyfw);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteVJwtSyfwByIds(Long[] ids) {
return vJwtSyfwMapper.deleteVJwtSyfwByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteVJwtSyfwById(Long id) {
return vJwtSyfwMapper.deleteVJwtSyfwById(id);
}
@Override
public boolean saveOrUpdate(VJwtSyfw bean) {
VJwtSyfw syfwPara = new VJwtSyfw();
syfwPara.setMc(bean.getMc());
List<VJwtSyfw> syfws = selectVJwtSyfwList(syfwPara);
if (syfws != null && syfws.size() > 0) {
//根据地址更新数据
updateVJwtSyfwByMc(bean);
} else {
//插入数据
insertVJwtSyfw(bean);
}
return false;
}
}

@ -0,0 +1,107 @@
package com.ssf.mysqloracletest.task;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ssf.mysqloracletest.domain.MetaRealEstateInfo;
import com.ssf.mysqloracletest.domain.VJwtSyfw;
import com.ssf.mysqloracletest.service.JwtSyfwService;
import com.ssf.mysqloracletest.service.MetaRealEstateInfoService;
import com.ssf.mysqloracletest.utils.ConfigParam;
import com.ssf.mysqloracletest.utils.NumKit;
import com.ssf.mysqloracletest.utils.StringKit;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
*
*/
@Component
@RequiredArgsConstructor
public class MetaRealEstateInfoTask {
private static final Logger logger = LoggerFactory.getLogger(MetaRealEstateInfoTask.class);
private final MetaRealEstateInfoService estateInfoService;
private final JwtSyfwService jwySyfwService;
/**
*
*/
@Scheduled(initialDelay = 100, fixedDelay = 3000)
public void transMetaRealEstateInfo() {
if (!"true".equals(ConfigParam.metaRealEstateInfoSwitch)) {
return;
}
try {
QueryWrapper<VJwtSyfw> queryWrapper = new QueryWrapper<>();
queryWrapper.isNull("status");
Page<VJwtSyfw> page = new Page<>(1, 1000);
List<VJwtSyfw> resultList = jwySyfwService.page(page, queryWrapper).getRecords();
CountDownLatch latch = new CountDownLatch(resultList.size());
ExecutorService jwtSyfwPool = Executors.newFixedThreadPool(50);
for (VJwtSyfw bean : resultList) {
jwtSyfwPool.submit(() -> {
cleanJwtSyfw(bean);
latch.countDown();
});
}
try {
// Wait for all threads to complete
latch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
// 关闭线程池
jwtSyfwPool.shutdown();
} catch (Exception e) {
logger.info(StringKit.getTrace(e));
}
}
private void cleanJwtSyfw(VJwtSyfw bean) {
VJwtSyfw jwtSyfwCp = new VJwtSyfw();
try {
BeanUtils.copyProperties(bean, jwtSyfwCp);
MetaRealEstateInfo realEstateInfo = new MetaRealEstateInfo();
// realEstateInfo.setId();
// realEstateInfo.setHomeId();
realEstateInfo.setPoliceStationCode(StringKit.toString(jwtSyfwCp.getPcsdm()));
realEstateInfo.setPoliceDistrictCode(StringKit.toString(jwtSyfwCp.getJwqdm()));
realEstateInfo.setRealEstateAddress(StringKit.toString(jwtSyfwCp.getMc()));
realEstateInfo.setLongitude(NumKit.checkDouble(jwtSyfwCp.getY()));
realEstateInfo.setLatitude(NumKit.checkDouble(jwtSyfwCp.getX()));
boolean b = estateInfoService.save(realEstateInfo);
if (b) {
jwtSyfwCp.setStatus("1");
jwySyfwService.updateVJwtSyfw(jwtSyfwCp);
}
} catch (Exception e) {
logger.info(StringKit.getTrace(e));
jwtSyfwCp.setStatus("2");
jwySyfwService.updateVJwtSyfw(jwtSyfwCp);
}
}
}

@ -1,11 +1,7 @@
package com.ssf.mysqloracletest.task; package com.ssf.mysqloracletest.task;
import com.ssf.mysqloracletest.domain.VSySydzMysql;
import com.ssf.mysqloracletest.domain.VSySydzOracle;
import com.ssf.mysqloracletest.domain.VSySyfwMysql; import com.ssf.mysqloracletest.domain.VSySyfwMysql;
import com.ssf.mysqloracletest.domain.VSySyfwOracle; import com.ssf.mysqloracletest.domain.VSySyfwOracle;
import com.ssf.mysqloracletest.service.VSySydzMysqlService;
import com.ssf.mysqloracletest.service.VSySydzOracleService;
import com.ssf.mysqloracletest.service.VSySyfwMysqlService; import com.ssf.mysqloracletest.service.VSySyfwMysqlService;
import com.ssf.mysqloracletest.service.VSySyfwOracleService; import com.ssf.mysqloracletest.service.VSySyfwOracleService;
import com.ssf.mysqloracletest.utils.ConfigParam; import com.ssf.mysqloracletest.utils.ConfigParam;
@ -26,7 +22,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
/** /**
* *
*/ */
@Component @Component
public class VSySyfwTask { public class VSySyfwTask {

@ -39,5 +39,6 @@ public class ConfigParam {
//rentalHouse数据清洗开关 //rentalHouse数据清洗开关
public static String RentalHouseSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("RentalHouseSwitch")); public static String RentalHouseSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("RentalHouseSwitch"));
public static String metaRealEstateInfoSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("metaRealEstateInfoSwitch"));
} }

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<configuration> <configuration>
<!-- 日志存放路径 --> <!-- 日志存放路径 -->
<property name="log.path" value="/home/Dutem/HRC/log" /> <property name="log.path" value="/home/project/dataCompareSyHRC/log" />
<!-- 日志输出格式 --> <!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" /> <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ssf.mysqloracletest.mapper.VJwtSyfwMapper">
<resultMap type="com.ssf.mysqloracletest.domain.VJwtSyfw" id="VJwtSyfwResult">
<result property="id" column="id" />
<result property="pcsdm" column="pcsdm" />
<result property="jwqdm" column="jwqdm" />
<result property="mc" column="mc" />
<result property="x" column="x" />
<result property="y" column="y" />
<result property="oldid" column="oldid" />
<result property="status" column="status" />
</resultMap>
<sql id="selectVJwtSyfwVo">
select id, pcsdm, jwqdm, mc, x, y, oldid,status from v_jwt_syfw
</sql>
<select id="selectVJwtSyfwList" parameterType="com.ssf.mysqloracletest.domain.VJwtSyfw" resultMap="VJwtSyfwResult">
<include refid="selectVJwtSyfwVo"/>
<where>
<if test="pcsdm != null and pcsdm != ''"> and pcsdm = #{pcsdm}</if>
<if test="jwqdm != null and jwqdm != ''"> and jwqdm = #{jwqdm}</if>
<if test="mc != null and mc != ''"> and mc = #{mc}</if>
<if test="x != null and x != ''"> and x = #{x}</if>
<if test="y != null and y != ''"> and y = #{y}</if>
<if test="oldid != null and oldid != ''"> and oldid = #{oldid}</if>
</where>
</select>
<select id="selectVJwtSyfwById" parameterType="Long" resultMap="VJwtSyfwResult">
<include refid="selectVJwtSyfwVo"/>
where id = #{id}
</select>
<insert id="insertVJwtSyfw" parameterType="com.ssf.mysqloracletest.domain.VJwtSyfw" useGeneratedKeys="true" keyProperty="id">
insert into v_jwt_syfw
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="pcsdm != null">pcsdm,</if>
<if test="jwqdm != null">jwqdm,</if>
<if test="mc != null">mc,</if>
<if test="x != null">x,</if>
<if test="y != null">y,</if>
<if test="oldid != null">oldid,</if>
<if test="status != null">status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="pcsdm != null">#{pcsdm},</if>
<if test="jwqdm != null">#{jwqdm},</if>
<if test="mc != null">#{mc},</if>
<if test="x != null">#{x},</if>
<if test="y != null">#{y},</if>
<if test="oldid != null">#{oldid},</if>
<if test="status != null">#{status},</if>
</trim>
</insert>
<update id="updateVJwtSyfw" parameterType="com.ssf.mysqloracletest.domain.VJwtSyfw">
update v_jwt_syfw
<trim prefix="SET" suffixOverrides=",">
<if test="pcsdm != null">pcsdm = #{pcsdm},</if>
<if test="jwqdm != null">jwqdm = #{jwqdm},</if>
<if test="mc != null">mc = #{mc},</if>
<if test="x != null">x = #{x},</if>
<if test="y != null">y = #{y},</if>
<if test="oldid != null">oldid = #{oldid},</if>
<if test="status != null">status = #{status},</if>
</trim>
where id = #{id}
</update>
<update id="updateVJwtSyfwByMc" parameterType="com.ssf.mysqloracletest.domain.VJwtSyfw">
update v_jwt_syfw
<trim prefix="SET" suffixOverrides=",">
<if test="pcsdm != null">pcsdm = #{pcsdm},</if>
<if test="jwqdm != null">jwqdm = #{jwqdm},</if>
<if test="x != null">x = #{x},</if>
<if test="y != null">y = #{y},</if>
<if test="oldid != null">oldid = #{oldid},</if>
</trim>
where mc = #{mc}
</update>
<delete id="deleteVJwtSyfwById" parameterType="Long">
delete from v_jwt_syfw where id = #{id}
</delete>
<delete id="deleteVJwtSyfwByIds" parameterType="String">
delete from v_jwt_syfw where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
Loading…
Cancel
Save