出租房Task

develop
Angel 10 months ago
parent b3301ac65a
commit 15c46daf01

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

@ -1,138 +1,143 @@
package com.ssf.mysqloracletest.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName(value = "v_sy_syfw")
public class VSySyfwOracle {
private String ZJLID;
@TableField(value = "ZJLID")
private String ZJLID;
@TableField(value = "YSXTJRZJ")
private String YSXTJRZJ;
@TableField(value = "XXSC_PDBZ")
private String XXSC_PDBZ;
@TableField(value = "DAH")
private String DAH;
@TableField(value = "JCWH")
private String JCWH;
@TableField(value = "FWID")
private String FWID;
@TableField(value = "FWLX")
private String FWLX;
@TableField(value = "FWDZ")
private String FWDZ;
@TableField(value = "FWXZ")
private String FWXZ;
@TableField(value = "FWLB")
private String FWLB;
@TableField(value = "FWJG")
private String FWJG;
@TableField(value = "FJS")
private String FJS;
@TableField(value = "MJ")
private String MJ;
@TableField(value = "CZYT")
private String CZYT;
@TableField(value = "DJRQ")
private String DJRQ;
//姓名
@TableField(value = "XM")
private String XM;
@TableField(value = "SFZH")
private String SFZH;
@TableField(value = "XB")
private String XB;
@TableField(value = "HJDQX")
private String HJDQX;
@TableField(value = "HJDXZ")
private String HJDXZ;
@TableField(value = "XZDQX")
private String XZDQX;
@TableField(value = "XZDXZ")
private String XZDXZ;
@TableField(value = "DWMC")
private String DWMC;
@TableField(value = "DWXZ")
private String DWXZ;
@TableField(value = "LXDH")
private String LXDH;
@TableField(value = "LRRID")
private String LRRID;
@TableField(value = "LRR")
private String LRR;
@TableField(value = "LRSJ")
private String LRSJ;
@TableField(value = "XGRID")
private String XGRID;
@TableField(value = "XGRXM")
private String XGRXM;
@TableField(value = "XGSJ")
private String XGSJ;
@TableField(value = "TBBS")
private String TBBS;
@TableField(value = "TBSJ")
private String TBSJ;
@TableField(value = "MEMO")
private String MEMO;
@TableField(value = "BZ")
private String BZ;
@TableField(value = "DQRQ")
private String DQRQ;
@TableField(value = "SJFWID")
private String SJFWID;
@TableField(value = "DYHCODE")
private String DYHCODE;
@TableField(value = "PCSDM")
private String PCSDM;
@TableField(value = "JWQID")
private String JWQID;
@TableField(value = "SSYS")
private String SSYS;
@TableField(value = "SNO")
private String SNO;
@TableField(value = "ZXRQ")
private String ZXRQ;
@TableField(value = "ZXYY")
private String ZXYY;
@TableField(value = "LKBZDZID")
private String LKBZDZID;
@TableField(value = "LKBZDZMC")
private String LKBZDZMC;
@TableField(value = "FWZT")
private String FWZT;
@TableField(value = "CZFWBM")
private String CZFWBM;
@TableField(value = "CZFWQM")
private String CZFWQM;
@TableField(value = "TBMEMO")
private String TBMEMO;
@TableField(value = "SFCZ")
private String SFCZ;
@TableField(value = "JZLX")
private String JZLX;
@TableField(value = "FWDJ")
private String FWDJ;
@TableField(value = "ZDFW")
private String ZDFW;
@TableField(value = "ZDRY")
private String ZDRY;
@TableField(value = "SFQZ")
private String SFQZ;
@TableField(value = "ZJLX")
private String ZJLX;
@TableField(value = "ZFLX")
private String ZFLX;
@TableField(value = "CWS")
private String CWS;
@TableField(value = "CZRZJLX")
private String CZRZJLX;
@TableField(value = "CZRZJHM")
private String CZRZJHM;
@TableField(value = "CZRXM")
private String CZRXM;
@TableField(value = "CZRLXDH")
private String CZRLXDH;
@TableField(value = "CDC_JYM")
private String CDC_JYM;
@TableField(value = "YSBZK_RKSJ")
private String YSBZK_RKSJ;
@TableField(value = "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.VSySyfwMysqlService;
import com.ssf.mysqloracletest.utils.ConfigParam;
import com.ssf.mysqloracletest.utils.NumKit;
import com.ssf.mysqloracletest.utils.StringKit;
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 javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -25,133 +23,175 @@ import java.util.concurrent.Executors;
@Component
public class RentalHousingTask {
private static final Logger logger = LoggerFactory.getLogger(RentalHousingTask.class);
@Resource
private VSySyfwMysqlService syfwMysqlService;
@Resource
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)
public void transRentalHouse() {
if (rentalhouseTag) {
return;
}
if (!"true".equals(ConfigParam.RentalHouseSwitch)) {
return;
}
try {
int countRentalHouse = syfwMysqlService.countSyfw();
logger.info("countRentalHouse:" + countRentalHouse);
QueryWrapper<VSySyfwMysql> queryWrapper = new QueryWrapper<>();
queryWrapper.isNull("STATUS");
Page<VSySyfwMysql> page = new Page<>(1, 1000);
List<VSySyfwMysql> resultList = syfwMysqlService.page(page, queryWrapper).getRecords();
if (countRentalHouse > 0) {
rentalhouseTag = true;
CountDownLatch latch = new CountDownLatch(resultList.size());
ExecutorService SyfwPool = Executors.newFixedThreadPool(5);
int count = countRentalHouse / oncesCounts;
CountDownLatch latch = new CountDownLatch(count);
ExecutorService RentalHousePool = Executors.newFixedThreadPool(5);
for (VSySyfwMysql bean: resultList) {
SyfwPool.submit(() -> {
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 {
//List<VSySyfwMysql> RentalHouses = syfwMysqlService.lambdaQuery().isNull(VSySyfwMysql::getSTATUS).list();
// 创建分页参数
Page<VSySyfwMysql> page = new Page<>(1, 1000);
// 构建查询条件
QueryWrapper<VSySyfwMysql> queryWrapper = new QueryWrapper<>();
queryWrapper.isNull("STATUS");
// 进行分页查询
syfwMysqlService.page(page, queryWrapper);
// 获取分页查询结果
List<VSySyfwMysql> rentalHouses = page.getRecords();
if (rentalHouses == null) {
return;
//Wait for all threads to complete
latch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
//关闭线程池
SyfwPool.shutdown();
} catch (Exception e) {
logger.info(StringKit.getTrace(e));
}
for (VSySyfwMysql House : rentalHouses) {
}
private void cleanSyfw(VSySyfwMysql bean) {
VSySyfwMysql syfwMysqlCp = new VSySyfwMysql();
try {
BeanUtils.copyProperties(bean, syfwMysqlCp);
MetaRentalHousingInfo metaRentalHousingInfo = new MetaRentalHousingInfo();
//rental_housing_address出租房屋地址<-----FWDZ房屋地址
metaRentalHousingInfo.setRentalHousingAddress(House.getFWDZ());
metaRentalHousingInfo.setRentalHousingAddress(syfwMysqlCp.getFWDZ());
//homeowner房主<-----XM
metaRentalHousingInfo.setHomeowner(House.getXM());
metaRentalHousingInfo.setHomeowner(syfwMysqlCp.getXM());
//homeowner_id_card房主身份证<-----SFZH
metaRentalHousingInfo.setHomeownerIdCard(House.getSFZH());
metaRentalHousingInfo.setHomeownerIdCard(syfwMysqlCp.getSFZH());
//homeowner_house_hold_register房主户籍地区县<-----HJDQX户籍辖区
metaRentalHousingInfo.setHomeownerHouseHoldRegister(House.getHJDQX());
metaRentalHousingInfo.setHomeownerHouseHoldRegister(syfwMysqlCp.getHJDQX());
//homeowner_house_hold_address户籍地址详情<-----HJDXZ户籍地详址
metaRentalHousingInfo.setHomeownerHouseHoldAddress(House.getHJDXZ());
metaRentalHousingInfo.setHomeownerHouseHoldAddress(syfwMysqlCp.getHJDXZ());
//homeowner_habitation_register房主现居住地区县<-----XZDQX现住地辖区
metaRentalHousingInfo.setHomeownerHabitationRegister(House.getXZDQX());
metaRentalHousingInfo.setHomeownerHabitationRegister(syfwMysqlCp.getXZDQX());
//homeowner_habitation_address房主现居住地<-----XZDXZ现住地详址
metaRentalHousingInfo.setHomeownerHabitationAddress(House.getXZDXZ());
metaRentalHousingInfo.setHomeownerHabitationAddress(syfwMysqlCp.getXZDXZ());
//homeowner_phone房主联系方式<-----LXDH联系电话
metaRentalHousingInfo.setHomeownerPhone(House.getLXDH());
metaRentalHousingInfo.setHomeownerPhone(syfwMysqlCp.getLXDH());
//state_flag表示状态:0有效1无效<-----BZ
metaRentalHousingInfo.setStateFlag(Integer.parseInt(House.getBZ()));
metaRentalHousingInfo.setStateFlag(Integer.parseInt(syfwMysqlCp.getBZ()));
//rental_housing_end_date出租房到期时间<-----DQRQ
metaRentalHousingInfo.setRentalHousingEndDate(House.getDQRQ());
metaRentalHousingInfo.setRentalHousingEndDate(syfwMysqlCp.getDQRQ());
//police_station_code派出所代码<-----PCSDM
metaRentalHousingInfo.setPoliceStationCode(House.getPCSDM());
metaRentalHousingInfo.setPoliceStationCode(syfwMysqlCp.getPCSDM());
//police_district_code警务区编码<-----JWQID
metaRentalHousingInfo.setPoliceDistrictCode(House.getJWQID());
metaRentalHousingInfo.setPoliceDistrictCode(syfwMysqlCp.getJWQID());
//floating_population_standard_address_id流动人口标准地址id<-----LKBZDZID
metaRentalHousingInfo.setFloatingPopulationStandardAddressId(House.getLKBZDZID());
metaRentalHousingInfo.setFloatingPopulationStandardAddressId(syfwMysqlCp.getLKBZDZID());
//floating_population_standard_address流动人口标准地址<-----LKBZDZMC
metaRentalHousingInfo.setFloatingPopulationStandardAddress(House.getLKBZDZMC());
metaRentalHousingInfo.setFloatingPopulationStandardAddress(syfwMysqlCp.getLKBZDZMC());
//rental_housing_status出租房状态<-----FWZT
metaRentalHousingInfo.setRentalHousingStatus(Integer.parseInt(House.getFWZT()));
metaRentalHousingInfo.setRentalHousingStatus(Integer.parseInt(syfwMysqlCp.getFWZT()));
//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
metaRentalHousingInfo.setResidentialType(Integer.parseInt(House.getJZLX()));
if (syfwMysqlCp.getJZLX() != null) {
metaRentalHousingInfo.setResidentialType(Integer.parseInt(syfwMysqlCp.getJZLX()));
} else {
metaRentalHousingInfo.setResidentialType(null);
}
//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
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
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
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
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
metaRentalHousingInfo.setRentingHouseUserName(House.getCZRXM());
metaRentalHousingInfo.setRentingHouseUserName(syfwMysqlCp.getCZRXM());
//renting_house_user_phone租房人联系方式<-----CZRLXDH
metaRentalHousingInfo.setRentingHouseUserPhone(House.getCZRLXDH());
metaRentalHousingInfo.setRentingHouseUserPhone(syfwMysqlCp.getCZRLXDH());
//renting_house_user_id_card租房人证件号码<-----CZRZJHM
metaRentalHousingInfo.setRentingHouseUserIdCard(House.getCZRZJHM());
//将STATUS设成1
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"));
}
metaRentalHousingInfo.setRentingHouseUserIdCard(syfwMysqlCp.getCZRZJHM());
boolean b = rentalHousingInfoService.save(metaRentalHousingInfo);
try {
//Wait for all threads to complete
latch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
//关闭线程池
RentalHousePool.shutdown();
if (b) {
syfwMysqlCp.setSTATUS("1");
syfwMysqlService.updateVSySyfwById(syfwMysqlCp);
logger.info("状态修改为1");
}
} catch (Exception 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="YSBZK_RKSJ != null and YSBZK_RKSJ != '' ">#{YSBZK_RKSJ},</if>
<if test="YSBZK_GXSJ != null and YSBZK_GXSJ != '' ">#{YSBZK_GXSJ},</if>
c </trim>
<if test="STATUS != null and STATUS != '' ">#{STATUS},</if>
</trim>
</insert>
<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_GXSJ != null and YSBZK_GXSJ != '' ">YSBZK_GXSJ=#{YSBZK_GXSJ},</if>
<if test="STATUS != null and STATUS != '' ">STATUS=#{STATUS},</if>
</trim>
where ZJLID = #{ZJLID}
</update>
<select id="countSyfw" resultType="int">
select count(*)
from V_SY_SYFW
from V_SY_SYFW limit 1
</select>
</mapper>
Loading…
Cancel
Save