出租房Task

develop
Angel 11 months ago
parent b3301ac65a
commit 15c46daf01

@ -151,5 +151,7 @@ public class VSySyfwMysql {
private String YSBZK_GXSJ; private String YSBZK_GXSJ;
@TableField(value = "STATUS") @TableField(value = "STATUS")
private String STATUS; private String STATUS;
} }

@ -1,138 +1,143 @@
package com.ssf.mysqloracletest.domain; package com.ssf.mysqloracletest.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
@Data @Data
@TableName(value = "v_sy_syfw")
public class VSySyfwOracle { public class VSySyfwOracle {
private String ZJLID;
@TableField(value = "ZJLID")
private String ZJLID;
@TableField(value = "YSXTJRZJ")
private String YSXTJRZJ; private String YSXTJRZJ;
@TableField(value = "XXSC_PDBZ")
private String XXSC_PDBZ; private String XXSC_PDBZ;
@TableField(value = "DAH")
private String DAH; private String DAH;
@TableField(value = "JCWH")
private String JCWH; private String JCWH;
@TableField(value = "FWID")
private String FWID; private String FWID;
@TableField(value = "FWLX")
private String FWLX; private String FWLX;
@TableField(value = "FWDZ")
private String FWDZ; private String FWDZ;
@TableField(value = "FWXZ")
private String FWXZ; private String FWXZ;
@TableField(value = "FWLB")
private String FWLB; private String FWLB;
@TableField(value = "FWJG")
private String FWJG; private String FWJG;
@TableField(value = "FJS")
private String FJS; private String FJS;
@TableField(value = "MJ")
private String MJ; private String MJ;
@TableField(value = "CZYT")
private String CZYT; private String CZYT;
@TableField(value = "DJRQ")
private String DJRQ; private String DJRQ;
//姓名 @TableField(value = "XM")
private String XM; private String XM;
@TableField(value = "SFZH")
private String SFZH; private String SFZH;
@TableField(value = "XB")
private String XB; private String XB;
@TableField(value = "HJDQX")
private String HJDQX; private String HJDQX;
@TableField(value = "HJDXZ")
private String HJDXZ; private String HJDXZ;
@TableField(value = "XZDQX")
private String XZDQX; private String XZDQX;
@TableField(value = "XZDXZ")
private String XZDXZ; private String XZDXZ;
@TableField(value = "DWMC")
private String DWMC; private String DWMC;
@TableField(value = "DWXZ")
private String DWXZ; private String DWXZ;
@TableField(value = "LXDH")
private String LXDH; private String LXDH;
@TableField(value = "LRRID")
private String LRRID; private String LRRID;
@TableField(value = "LRR")
private String LRR; private String LRR;
@TableField(value = "LRSJ")
private String LRSJ; private String LRSJ;
@TableField(value = "XGRID")
private String XGRID; private String XGRID;
@TableField(value = "XGRXM")
private String XGRXM; private String XGRXM;
@TableField(value = "XGSJ")
private String XGSJ; private String XGSJ;
@TableField(value = "TBBS")
private String TBBS; private String TBBS;
@TableField(value = "TBSJ")
private String TBSJ; private String TBSJ;
@TableField(value = "MEMO")
private String MEMO; private String MEMO;
@TableField(value = "BZ")
private String BZ; private String BZ;
@TableField(value = "DQRQ")
private String DQRQ; private String DQRQ;
@TableField(value = "SJFWID")
private String SJFWID; private String SJFWID;
@TableField(value = "DYHCODE")
private String DYHCODE; private String DYHCODE;
@TableField(value = "PCSDM")
private String PCSDM; private String PCSDM;
@TableField(value = "JWQID")
private String JWQID; private String JWQID;
@TableField(value = "SSYS")
private String SSYS; private String SSYS;
@TableField(value = "SNO")
private String SNO; private String SNO;
@TableField(value = "ZXRQ")
private String ZXRQ; private String ZXRQ;
@TableField(value = "ZXYY")
private String ZXYY; private String ZXYY;
@TableField(value = "LKBZDZID")
private String LKBZDZID; private String LKBZDZID;
@TableField(value = "LKBZDZMC")
private String LKBZDZMC; private String LKBZDZMC;
@TableField(value = "FWZT")
private String FWZT; private String FWZT;
@TableField(value = "CZFWBM")
private String CZFWBM; private String CZFWBM;
@TableField(value = "CZFWQM")
private String CZFWQM; private String CZFWQM;
@TableField(value = "TBMEMO")
private String TBMEMO; private String TBMEMO;
@TableField(value = "SFCZ")
private String SFCZ; private String SFCZ;
@TableField(value = "JZLX")
private String JZLX; private String JZLX;
@TableField(value = "FWDJ")
private String FWDJ; private String FWDJ;
@TableField(value = "ZDFW")
private String ZDFW; private String ZDFW;
@TableField(value = "ZDRY")
private String ZDRY; private String ZDRY;
@TableField(value = "SFQZ")
private String SFQZ; private String SFQZ;
@TableField(value = "ZJLX")
private String ZJLX; private String ZJLX;
@TableField(value = "ZFLX")
private String ZFLX; private String ZFLX;
@TableField(value = "CWS")
private String CWS; private String CWS;
@TableField(value = "CZRZJLX")
private String CZRZJLX; private String CZRZJLX;
@TableField(value = "CZRZJHM")
private String CZRZJHM; private String CZRZJHM;
@TableField(value = "CZRXM")
private String CZRXM; private String CZRXM;
@TableField(value = "CZRLXDH")
private String CZRLXDH; private String CZRLXDH;
@TableField(value = "CDC_JYM")
private String CDC_JYM; private String CDC_JYM;
@TableField(value = "YSBZK_RKSJ")
private String YSBZK_RKSJ; private String YSBZK_RKSJ;
@TableField(value = "YSBZK_GXSJ")
private String YSBZK_GXSJ; private String YSBZK_GXSJ;
} }

@ -7,17 +7,15 @@ import com.ssf.mysqloracletest.domain.VSySyfwMysql;
import com.ssf.mysqloracletest.service.MetaRentalHousingInfoService; import com.ssf.mysqloracletest.service.MetaRentalHousingInfoService;
import com.ssf.mysqloracletest.service.VSySyfwMysqlService; import com.ssf.mysqloracletest.service.VSySyfwMysqlService;
import com.ssf.mysqloracletest.utils.ConfigParam; import com.ssf.mysqloracletest.utils.ConfigParam;
import com.ssf.mysqloracletest.utils.NumKit;
import com.ssf.mysqloracletest.utils.StringKit; import com.ssf.mysqloracletest.utils.StringKit;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -25,133 +23,175 @@ import java.util.concurrent.Executors;
@Component @Component
public class RentalHousingTask { public class RentalHousingTask {
private static final Logger logger = LoggerFactory.getLogger(RentalHousingTask.class); private static final Logger logger = LoggerFactory.getLogger(RentalHousingTask.class);
@Resource @Resource
private VSySyfwMysqlService syfwMysqlService; private VSySyfwMysqlService syfwMysqlService;
@Resource @Resource
private MetaRentalHousingInfoService rentalHousingInfoService; private MetaRentalHousingInfoService rentalHousingInfoService;
final int oncesCounts = NumKit.checkInt(ConfigParam.oncesCounts) == 0 ? 10000 : NumKit.checkInt(ConfigParam.oncesCounts);
private boolean rentalhouseTag = false;
@Scheduled(initialDelay = 100, fixedDelay = 3000) @Scheduled(initialDelay = 100, fixedDelay = 3000)
public void transRentalHouse() { public void transRentalHouse() {
if (rentalhouseTag) {
return;
}
if (!"true".equals(ConfigParam.RentalHouseSwitch)) { if (!"true".equals(ConfigParam.RentalHouseSwitch)) {
return; return;
} }
try { try {
int countRentalHouse = syfwMysqlService.countSyfw(); QueryWrapper<VSySyfwMysql> queryWrapper = new QueryWrapper<>();
logger.info("countRentalHouse:" + countRentalHouse); queryWrapper.isNull("STATUS");
Page<VSySyfwMysql> page = new Page<>(1, 1000);
List<VSySyfwMysql> resultList = syfwMysqlService.page(page, queryWrapper).getRecords();
if (countRentalHouse > 0) { CountDownLatch latch = new CountDownLatch(resultList.size());
rentalhouseTag = true; ExecutorService SyfwPool = Executors.newFixedThreadPool(5);
int count = countRentalHouse / oncesCounts; for (VSySyfwMysql bean: resultList) {
CountDownLatch latch = new CountDownLatch(count); SyfwPool.submit(() -> {
ExecutorService RentalHousePool = Executors.newFixedThreadPool(5); cleanSyfw(bean);
logger.info("清洗完成");
latch.countDown();
});
}
for (int i = 0; i <= count; i++) {
Map HouseMap = new HashMap();
HouseMap.put("rowStart", i * oncesCounts);
HouseMap.put("rowEnd", (i + 1) * oncesCounts);
RentalHousePool.submit(() -> {
try { try {
//List<VSySyfwMysql> RentalHouses = syfwMysqlService.lambdaQuery().isNull(VSySyfwMysql::getSTATUS).list(); //Wait for all threads to complete
// 创建分页参数 latch.await();
Page<VSySyfwMysql> page = new Page<>(1, 1000); } catch (InterruptedException e) {
// 构建查询条件 e.printStackTrace();
QueryWrapper<VSySyfwMysql> queryWrapper = new QueryWrapper<>(); }
queryWrapper.isNull("STATUS"); //关闭线程池
// 进行分页查询 SyfwPool.shutdown();
syfwMysqlService.page(page, queryWrapper); } catch (Exception e) {
// 获取分页查询结果 logger.info(StringKit.getTrace(e));
List<VSySyfwMysql> rentalHouses = page.getRecords();
if (rentalHouses == null) {
return;
} }
for (VSySyfwMysql House : rentalHouses) { }
private void cleanSyfw(VSySyfwMysql bean) {
VSySyfwMysql syfwMysqlCp = new VSySyfwMysql();
try {
BeanUtils.copyProperties(bean, syfwMysqlCp);
MetaRentalHousingInfo metaRentalHousingInfo = new MetaRentalHousingInfo(); MetaRentalHousingInfo metaRentalHousingInfo = new MetaRentalHousingInfo();
//rental_housing_address出租房屋地址<-----FWDZ房屋地址 //rental_housing_address出租房屋地址<-----FWDZ房屋地址
metaRentalHousingInfo.setRentalHousingAddress(House.getFWDZ()); metaRentalHousingInfo.setRentalHousingAddress(syfwMysqlCp.getFWDZ());
//homeowner房主<-----XM //homeowner房主<-----XM
metaRentalHousingInfo.setHomeowner(House.getXM()); metaRentalHousingInfo.setHomeowner(syfwMysqlCp.getXM());
//homeowner_id_card房主身份证<-----SFZH //homeowner_id_card房主身份证<-----SFZH
metaRentalHousingInfo.setHomeownerIdCard(House.getSFZH()); metaRentalHousingInfo.setHomeownerIdCard(syfwMysqlCp.getSFZH());
//homeowner_house_hold_register房主户籍地区县<-----HJDQX户籍辖区 //homeowner_house_hold_register房主户籍地区县<-----HJDQX户籍辖区
metaRentalHousingInfo.setHomeownerHouseHoldRegister(House.getHJDQX()); metaRentalHousingInfo.setHomeownerHouseHoldRegister(syfwMysqlCp.getHJDQX());
//homeowner_house_hold_address户籍地址详情<-----HJDXZ户籍地详址 //homeowner_house_hold_address户籍地址详情<-----HJDXZ户籍地详址
metaRentalHousingInfo.setHomeownerHouseHoldAddress(House.getHJDXZ()); metaRentalHousingInfo.setHomeownerHouseHoldAddress(syfwMysqlCp.getHJDXZ());
//homeowner_habitation_register房主现居住地区县<-----XZDQX现住地辖区 //homeowner_habitation_register房主现居住地区县<-----XZDQX现住地辖区
metaRentalHousingInfo.setHomeownerHabitationRegister(House.getXZDQX()); metaRentalHousingInfo.setHomeownerHabitationRegister(syfwMysqlCp.getXZDQX());
//homeowner_habitation_address房主现居住地<-----XZDXZ现住地详址 //homeowner_habitation_address房主现居住地<-----XZDXZ现住地详址
metaRentalHousingInfo.setHomeownerHabitationAddress(House.getXZDXZ()); metaRentalHousingInfo.setHomeownerHabitationAddress(syfwMysqlCp.getXZDXZ());
//homeowner_phone房主联系方式<-----LXDH联系电话 //homeowner_phone房主联系方式<-----LXDH联系电话
metaRentalHousingInfo.setHomeownerPhone(House.getLXDH()); metaRentalHousingInfo.setHomeownerPhone(syfwMysqlCp.getLXDH());
//state_flag表示状态:0有效1无效<-----BZ //state_flag表示状态:0有效1无效<-----BZ
metaRentalHousingInfo.setStateFlag(Integer.parseInt(House.getBZ())); metaRentalHousingInfo.setStateFlag(Integer.parseInt(syfwMysqlCp.getBZ()));
//rental_housing_end_date出租房到期时间<-----DQRQ //rental_housing_end_date出租房到期时间<-----DQRQ
metaRentalHousingInfo.setRentalHousingEndDate(House.getDQRQ()); metaRentalHousingInfo.setRentalHousingEndDate(syfwMysqlCp.getDQRQ());
//police_station_code派出所代码<-----PCSDM //police_station_code派出所代码<-----PCSDM
metaRentalHousingInfo.setPoliceStationCode(House.getPCSDM()); metaRentalHousingInfo.setPoliceStationCode(syfwMysqlCp.getPCSDM());
//police_district_code警务区编码<-----JWQID //police_district_code警务区编码<-----JWQID
metaRentalHousingInfo.setPoliceDistrictCode(House.getJWQID()); metaRentalHousingInfo.setPoliceDistrictCode(syfwMysqlCp.getJWQID());
//floating_population_standard_address_id流动人口标准地址id<-----LKBZDZID //floating_population_standard_address_id流动人口标准地址id<-----LKBZDZID
metaRentalHousingInfo.setFloatingPopulationStandardAddressId(House.getLKBZDZID()); metaRentalHousingInfo.setFloatingPopulationStandardAddressId(syfwMysqlCp.getLKBZDZID());
//floating_population_standard_address流动人口标准地址<-----LKBZDZMC //floating_population_standard_address流动人口标准地址<-----LKBZDZMC
metaRentalHousingInfo.setFloatingPopulationStandardAddress(House.getLKBZDZMC()); metaRentalHousingInfo.setFloatingPopulationStandardAddress(syfwMysqlCp.getLKBZDZMC());
//rental_housing_status出租房状态<-----FWZT //rental_housing_status出租房状态<-----FWZT
metaRentalHousingInfo.setRentalHousingStatus(Integer.parseInt(House.getFWZT())); metaRentalHousingInfo.setRentalHousingStatus(Integer.parseInt(syfwMysqlCp.getFWZT()));
//is_rental_housing是否出租<-----SFCZY,N //is_rental_housing是否出租<-----SFCZY,N
metaRentalHousingInfo.setIsRentalHousing(Integer.parseInt(House.getSFCZ())); try {
if ("Y".equals(syfwMysqlCp.getSFCZ())) {
metaRentalHousingInfo.setIsRentalHousing(1);
} else if ("N".equals(syfwMysqlCp.getSFCZ())) {
metaRentalHousingInfo.setIsRentalHousing(0);
} else {
// 处理其他情况,如果有的话
metaRentalHousingInfo.setIsRentalHousing(null);
}
} catch (NumberFormatException e) {
// 处理转换异常
System.err.println("无法将字符串转换为整数:" + e.getMessage());
}
//residential_type居住类型<-----JZLX //residential_type居住类型<-----JZLX
metaRentalHousingInfo.setResidentialType(Integer.parseInt(House.getJZLX())); if (syfwMysqlCp.getJZLX() != null) {
metaRentalHousingInfo.setResidentialType(Integer.parseInt(syfwMysqlCp.getJZLX()));
} else {
metaRentalHousingInfo.setResidentialType(null);
}
//rental_housing_grade房屋等级<-----FWDJ //rental_housing_grade房屋等级<-----FWDJ
metaRentalHousingInfo.setRentalHousingGrade(Integer.parseInt(House.getFWDJ())); if (syfwMysqlCp.getFWDJ() != null) {
metaRentalHousingInfo.setRentalHousingGrade(Integer.parseInt(syfwMysqlCp.getFWDJ()));
} else {
metaRentalHousingInfo.setRentalHousingGrade(null);
}
//imp_rental_housing重点房屋<-----ZDFW //imp_rental_housing重点房屋<-----ZDFW
metaRentalHousingInfo.setImpRentalHousing(Integer.parseInt(House.getZDFW())); if (syfwMysqlCp.getZDFW() != null) {
if (syfwMysqlCp.getZDFW().equals("21")) {
metaRentalHousingInfo.setImpRentalHousing(21);
} else if (syfwMysqlCp.getZDFW().equals("22")) {
metaRentalHousingInfo.setImpRentalHousing(22);
}
} else {
metaRentalHousingInfo.setImpRentalHousing(null);
}
//imp_user_rental_housing重点人员<-----ZDRY //imp_user_rental_housing重点人员<-----ZDRY
metaRentalHousingInfo.setImpUserRentalHousing(Integer.parseInt(House.getZDRY())); if (syfwMysqlCp.getZDRY() != null) {
if (syfwMysqlCp.getZDRY().equals("27")) {
metaRentalHousingInfo.setImpUserRentalHousing(27);
} else if (syfwMysqlCp.getZDRY().equals("35")) {
metaRentalHousingInfo.setImpUserRentalHousing(35);
}
} else {
metaRentalHousingInfo.setImpUserRentalHousing(null);
}
//is_group_rental_housing是否群租房<-----SFQZ //is_group_rental_housing是否群租房<-----SFQZ
metaRentalHousingInfo.setIsGroupRentalHousing(Integer.parseInt(House.getSFQZ())); try {
if ("Y".equals(syfwMysqlCp.getSFQZ())) {
metaRentalHousingInfo.setIsGroupRentalHousing(1);
} else if ("N".equals(syfwMysqlCp.getSFQZ())) {
metaRentalHousingInfo.setIsGroupRentalHousing(0);
} else {
metaRentalHousingInfo.setIsGroupRentalHousing(null);
}
} catch (NumberFormatException e) {
// 处理转换异常
System.err.println("无法将字符串转换为整数:" + e.getMessage());
}
//rental_housing_type住房类型<-----ZFLX //rental_housing_type住房类型<-----ZFLX
metaRentalHousingInfo.setRentalHousingType(Integer.parseInt(House.getZFLX())); if (syfwMysqlCp.getZFLX() != null) {
metaRentalHousingInfo.setRentalHousingType(Integer.parseInt(syfwMysqlCp.getZFLX()));
} else {
metaRentalHousingInfo.setRentalHousingType(null);
}
//renting_house_user_name租房人姓名<----- CZRXM //renting_house_user_name租房人姓名<----- CZRXM
metaRentalHousingInfo.setRentingHouseUserName(House.getCZRXM()); metaRentalHousingInfo.setRentingHouseUserName(syfwMysqlCp.getCZRXM());
//renting_house_user_phone租房人联系方式<-----CZRLXDH //renting_house_user_phone租房人联系方式<-----CZRLXDH
metaRentalHousingInfo.setRentingHouseUserPhone(House.getCZRLXDH()); metaRentalHousingInfo.setRentingHouseUserPhone(syfwMysqlCp.getCZRLXDH());
//renting_house_user_id_card租房人证件号码<-----CZRZJHM //renting_house_user_id_card租房人证件号码<-----CZRZJHM
metaRentalHousingInfo.setRentingHouseUserIdCard(House.getCZRZJHM()); metaRentalHousingInfo.setRentingHouseUserIdCard(syfwMysqlCp.getCZRZJHM());
//将STATUS设成1 boolean b = rentalHousingInfoService.save(metaRentalHousingInfo);
House.setSTATUS("1");
logger.info("插入成功");
}
} catch (Exception e) {
logger.info("rentalHouses"+ StringKit.getTrace(e));
}
latch.countDown();
});
logger.info("rentalhouseTag数据总理:" + countRentalHouse + "," + "当前处理下标:" + HouseMap.get("rowStart") + "/" + HouseMap.get("rowEnd"));
}
try { if (b) {
//Wait for all threads to complete syfwMysqlCp.setSTATUS("1");
latch.await(); syfwMysqlService.updateVSySyfwById(syfwMysqlCp);
} catch (InterruptedException e) { logger.info("状态修改为1");
e.printStackTrace();
}
//关闭线程池
RentalHousePool.shutdown();
} }
} catch (Exception e) { } catch (Exception e) {
logger.info(StringKit.getTrace(e)); logger.info(StringKit.getTrace(e));
syfwMysqlCp.setSTATUS("2");
syfwMysqlService.updateVSySyfwById(syfwMysqlCp);
logger.info("状态修改为2");
} }
} }
} }

@ -223,7 +223,8 @@
<if test="CDC_JYM != null and CDC_JYM != '' ">#{CDC_JYM},</if> <if test="CDC_JYM != null and CDC_JYM != '' ">#{CDC_JYM},</if>
<if test="YSBZK_RKSJ != null and YSBZK_RKSJ != '' ">#{YSBZK_RKSJ},</if> <if test="YSBZK_RKSJ != null and YSBZK_RKSJ != '' ">#{YSBZK_RKSJ},</if>
<if test="YSBZK_GXSJ != null and YSBZK_GXSJ != '' ">#{YSBZK_GXSJ},</if> <if test="YSBZK_GXSJ != null and YSBZK_GXSJ != '' ">#{YSBZK_GXSJ},</if>
c </trim> <if test="STATUS != null and STATUS != '' ">#{STATUS},</if>
</trim>
</insert> </insert>
<update id="updateVSySyfwById" parameterType="com.ssf.mysqloracletest.domain.VSySyfwMysql"> <update id="updateVSySyfwById" parameterType="com.ssf.mysqloracletest.domain.VSySyfwMysql">
@ -297,14 +298,13 @@ c </trim>
<if test="YSBZK_RKSJ != null and YSBZK_RKSJ != '' ">YSBZK_RKSJ=#{YSBZK_RKSJ},</if> <if test="YSBZK_RKSJ != null and YSBZK_RKSJ != '' ">YSBZK_RKSJ=#{YSBZK_RKSJ},</if>
<if test="YSBZK_GXSJ != null and YSBZK_GXSJ != '' ">YSBZK_GXSJ=#{YSBZK_GXSJ},</if> <if test="YSBZK_GXSJ != null and YSBZK_GXSJ != '' ">YSBZK_GXSJ=#{YSBZK_GXSJ},</if>
<if test="STATUS != null and STATUS != '' ">STATUS=#{STATUS},</if> <if test="STATUS != null and STATUS != '' ">STATUS=#{STATUS},</if>
</trim> </trim>
where ZJLID = #{ZJLID} where ZJLID = #{ZJLID}
</update> </update>
<select id="countSyfw" resultType="int"> <select id="countSyfw" resultType="int">
select count(*) select count(*)
from V_SY_SYFW from V_SY_SYFW limit 1
</select> </select>
</mapper> </mapper>
Loading…
Cancel
Save