From 15c46daf01460857514579cee0b25b22e5bcc5c8 Mon Sep 17 00:00:00 2001 From: Angel <1050374295@qq.com> Date: Wed, 6 Dec 2023 10:31:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=BA=E7=A7=9F=E6=88=BFTask?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mysqloracletest/domain/VSySyfwMysql.java | 2 + .../mysqloracletest/domain/VSySyfwOracle.java | 135 ++++----- .../task/RentalHousingTask.java | 258 ++++++++++-------- .../resources/mapper/VSySyfwMysqlMapper.xml | 6 +- 4 files changed, 224 insertions(+), 177 deletions(-) diff --git a/src/main/java/com/ssf/mysqloracletest/domain/VSySyfwMysql.java b/src/main/java/com/ssf/mysqloracletest/domain/VSySyfwMysql.java index 1444090..a9d9f2c 100644 --- a/src/main/java/com/ssf/mysqloracletest/domain/VSySyfwMysql.java +++ b/src/main/java/com/ssf/mysqloracletest/domain/VSySyfwMysql.java @@ -151,5 +151,7 @@ public class VSySyfwMysql { private String YSBZK_GXSJ; @TableField(value = "STATUS") private String STATUS; + + } diff --git a/src/main/java/com/ssf/mysqloracletest/domain/VSySyfwOracle.java b/src/main/java/com/ssf/mysqloracletest/domain/VSySyfwOracle.java index 6f175ae..dd32cee 100644 --- a/src/main/java/com/ssf/mysqloracletest/domain/VSySyfwOracle.java +++ b/src/main/java/com/ssf/mysqloracletest/domain/VSySyfwOracle.java @@ -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; } diff --git a/src/main/java/com/ssf/mysqloracletest/task/RentalHousingTask.java b/src/main/java/com/ssf/mysqloracletest/task/RentalHousingTask.java index 0bba88a..532928c 100644 --- a/src/main/java/com/ssf/mysqloracletest/task/RentalHousingTask.java +++ b/src/main/java/com/ssf/mysqloracletest/task/RentalHousingTask.java @@ -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); - - if (countRentalHouse > 0) { - rentalhouseTag = true; - - int count = countRentalHouse / oncesCounts; - CountDownLatch latch = new CountDownLatch(count); - ExecutorService RentalHousePool = Executors.newFixedThreadPool(5); - - 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 RentalHouses = syfwMysqlService.lambdaQuery().isNull(VSySyfwMysql::getSTATUS).list(); - // 创建分页参数 - Page page = new Page<>(1, 1000); - // 构建查询条件 - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.isNull("STATUS"); - // 进行分页查询 - syfwMysqlService.page(page, queryWrapper); - // 获取分页查询结果 - List rentalHouses = page.getRecords(); - if (rentalHouses == null) { - return; - } - for (VSySyfwMysql House : rentalHouses) { - MetaRentalHousingInfo metaRentalHousingInfo = new MetaRentalHousingInfo(); - //rental_housing_address出租房屋地址<-----FWDZ房屋地址 - metaRentalHousingInfo.setRentalHousingAddress(House.getFWDZ()); - //homeowner房主<-----XM - metaRentalHousingInfo.setHomeowner(House.getXM()); - //homeowner_id_card房主身份证<-----SFZH - metaRentalHousingInfo.setHomeownerIdCard(House.getSFZH()); - //homeowner_house_hold_register房主户籍地区县<-----HJDQX户籍辖区 - metaRentalHousingInfo.setHomeownerHouseHoldRegister(House.getHJDQX()); - //homeowner_house_hold_address户籍地址详情<-----HJDXZ户籍地详址 - metaRentalHousingInfo.setHomeownerHouseHoldAddress(House.getHJDXZ()); - //homeowner_habitation_register房主现居住地区县<-----XZDQX现住地辖区 - metaRentalHousingInfo.setHomeownerHabitationRegister(House.getXZDQX()); - //homeowner_habitation_address房主现居住地<-----XZDXZ现住地详址 - metaRentalHousingInfo.setHomeownerHabitationAddress(House.getXZDXZ()); - //homeowner_phone房主联系方式<-----LXDH联系电话 - metaRentalHousingInfo.setHomeownerPhone(House.getLXDH()); - //state_flag表示状态:0有效,1无效<-----BZ - metaRentalHousingInfo.setStateFlag(Integer.parseInt(House.getBZ())); - //rental_housing_end_date出租房到期时间<-----DQRQ - metaRentalHousingInfo.setRentalHousingEndDate(House.getDQRQ()); - //police_station_code派出所代码<-----PCSDM - metaRentalHousingInfo.setPoliceStationCode(House.getPCSDM()); - //police_district_code警务区编码<-----JWQID - metaRentalHousingInfo.setPoliceDistrictCode(House.getJWQID()); - //floating_population_standard_address_id流动人口标准地址id<-----LKBZDZID - metaRentalHousingInfo.setFloatingPopulationStandardAddressId(House.getLKBZDZID()); - //floating_population_standard_address流动人口标准地址<-----LKBZDZMC - metaRentalHousingInfo.setFloatingPopulationStandardAddress(House.getLKBZDZMC()); - //rental_housing_status出租房状态<-----FWZT - metaRentalHousingInfo.setRentalHousingStatus(Integer.parseInt(House.getFWZT())); - //is_rental_housing是否出租<-----SFCZ(Y,N) - metaRentalHousingInfo.setIsRentalHousing(Integer.parseInt(House.getSFCZ())); - //residential_type居住类型<-----JZLX - metaRentalHousingInfo.setResidentialType(Integer.parseInt(House.getJZLX())); - //rental_housing_grade房屋等级<-----FWDJ - metaRentalHousingInfo.setRentalHousingGrade(Integer.parseInt(House.getFWDJ())); - //imp_rental_housing重点房屋<-----ZDFW - metaRentalHousingInfo.setImpRentalHousing(Integer.parseInt(House.getZDFW())); - //imp_user_rental_housing重点人员<-----ZDRY - metaRentalHousingInfo.setImpUserRentalHousing(Integer.parseInt(House.getZDRY())); - //is_group_rental_housing是否群租房<-----SFQZ - metaRentalHousingInfo.setIsGroupRentalHousing(Integer.parseInt(House.getSFQZ())); - //rental_housing_type住房类型<-----ZFLX - metaRentalHousingInfo.setRentalHousingType(Integer.parseInt(House.getZFLX())); - //renting_house_user_name租房人姓名<----- CZRXM - metaRentalHousingInfo.setRentingHouseUserName(House.getCZRXM()); - //renting_house_user_phone租房人联系方式<-----CZRLXDH - metaRentalHousingInfo.setRentingHouseUserPhone(House.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")); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.isNull("STATUS"); + Page page = new Page<>(1, 1000); + List resultList = syfwMysqlService.page(page, queryWrapper).getRecords(); + + CountDownLatch latch = new CountDownLatch(resultList.size()); + ExecutorService SyfwPool = Executors.newFixedThreadPool(5); + + for (VSySyfwMysql bean: resultList) { + SyfwPool.submit(() -> { + cleanSyfw(bean); + logger.info("清洗完成"); + latch.countDown(); + }); + } + + try { + //Wait for all threads to complete + latch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + //关闭线程池 + SyfwPool.shutdown(); + } catch (Exception e) { + logger.info(StringKit.getTrace(e)); + } + } + + private void cleanSyfw(VSySyfwMysql bean) { + VSySyfwMysql syfwMysqlCp = new VSySyfwMysql(); + try { + BeanUtils.copyProperties(bean, syfwMysqlCp); + MetaRentalHousingInfo metaRentalHousingInfo = new MetaRentalHousingInfo(); + //rental_housing_address出租房屋地址<-----FWDZ房屋地址 + metaRentalHousingInfo.setRentalHousingAddress(syfwMysqlCp.getFWDZ()); + //homeowner房主<-----XM + metaRentalHousingInfo.setHomeowner(syfwMysqlCp.getXM()); + //homeowner_id_card房主身份证<-----SFZH + metaRentalHousingInfo.setHomeownerIdCard(syfwMysqlCp.getSFZH()); + //homeowner_house_hold_register房主户籍地区县<-----HJDQX户籍辖区 + metaRentalHousingInfo.setHomeownerHouseHoldRegister(syfwMysqlCp.getHJDQX()); + //homeowner_house_hold_address户籍地址详情<-----HJDXZ户籍地详址 + metaRentalHousingInfo.setHomeownerHouseHoldAddress(syfwMysqlCp.getHJDXZ()); + //homeowner_habitation_register房主现居住地区县<-----XZDQX现住地辖区 + metaRentalHousingInfo.setHomeownerHabitationRegister(syfwMysqlCp.getXZDQX()); + //homeowner_habitation_address房主现居住地<-----XZDXZ现住地详址 + metaRentalHousingInfo.setHomeownerHabitationAddress(syfwMysqlCp.getXZDXZ()); + //homeowner_phone房主联系方式<-----LXDH联系电话 + metaRentalHousingInfo.setHomeownerPhone(syfwMysqlCp.getLXDH()); + //state_flag表示状态:0有效,1无效<-----BZ + metaRentalHousingInfo.setStateFlag(Integer.parseInt(syfwMysqlCp.getBZ())); + //rental_housing_end_date出租房到期时间<-----DQRQ + metaRentalHousingInfo.setRentalHousingEndDate(syfwMysqlCp.getDQRQ()); + //police_station_code派出所代码<-----PCSDM + metaRentalHousingInfo.setPoliceStationCode(syfwMysqlCp.getPCSDM()); + //police_district_code警务区编码<-----JWQID + metaRentalHousingInfo.setPoliceDistrictCode(syfwMysqlCp.getJWQID()); + //floating_population_standard_address_id流动人口标准地址id<-----LKBZDZID + metaRentalHousingInfo.setFloatingPopulationStandardAddressId(syfwMysqlCp.getLKBZDZID()); + //floating_population_standard_address流动人口标准地址<-----LKBZDZMC + metaRentalHousingInfo.setFloatingPopulationStandardAddress(syfwMysqlCp.getLKBZDZMC()); + //rental_housing_status出租房状态<-----FWZT + metaRentalHousingInfo.setRentalHousingStatus(Integer.parseInt(syfwMysqlCp.getFWZT())); + //is_rental_housing是否出租<-----SFCZ(Y,N) + 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 + if (syfwMysqlCp.getJZLX() != null) { + metaRentalHousingInfo.setResidentialType(Integer.parseInt(syfwMysqlCp.getJZLX())); + } else { + metaRentalHousingInfo.setResidentialType(null); + } + //rental_housing_grade房屋等级<-----FWDJ + if (syfwMysqlCp.getFWDJ() != null) { + metaRentalHousingInfo.setRentalHousingGrade(Integer.parseInt(syfwMysqlCp.getFWDJ())); + } else { + metaRentalHousingInfo.setRentalHousingGrade(null); + } + + //imp_rental_housing重点房屋<-----ZDFW + 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 + 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); + } - try { - //Wait for all threads to complete - latch.await(); - } catch (InterruptedException e) { - e.printStackTrace(); + //is_group_rental_housing是否群租房<-----SFQZ + try { + if ("Y".equals(syfwMysqlCp.getSFQZ())) { + metaRentalHousingInfo.setIsGroupRentalHousing(1); + } else if ("N".equals(syfwMysqlCp.getSFQZ())) { + metaRentalHousingInfo.setIsGroupRentalHousing(0); + } else { + metaRentalHousingInfo.setIsGroupRentalHousing(null); } - //关闭线程池 - RentalHousePool.shutdown(); + } catch (NumberFormatException e) { + // 处理转换异常 + System.err.println("无法将字符串转换为整数:" + e.getMessage()); + } + + //rental_housing_type住房类型<-----ZFLX + if (syfwMysqlCp.getZFLX() != null) { + metaRentalHousingInfo.setRentalHousingType(Integer.parseInt(syfwMysqlCp.getZFLX())); + } else { + metaRentalHousingInfo.setRentalHousingType(null); + } + //renting_house_user_name租房人姓名<----- CZRXM + metaRentalHousingInfo.setRentingHouseUserName(syfwMysqlCp.getCZRXM()); + //renting_house_user_phone租房人联系方式<-----CZRLXDH + metaRentalHousingInfo.setRentingHouseUserPhone(syfwMysqlCp.getCZRLXDH()); + //renting_house_user_id_card租房人证件号码<-----CZRZJHM + metaRentalHousingInfo.setRentingHouseUserIdCard(syfwMysqlCp.getCZRZJHM()); + boolean b = rentalHousingInfoService.save(metaRentalHousingInfo); + + 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"); } } + } + + diff --git a/src/main/resources/mapper/VSySyfwMysqlMapper.xml b/src/main/resources/mapper/VSySyfwMysqlMapper.xml index 1616b99..2833a5e 100644 --- a/src/main/resources/mapper/VSySyfwMysqlMapper.xml +++ b/src/main/resources/mapper/VSySyfwMysqlMapper.xml @@ -223,7 +223,8 @@ #{CDC_JYM}, #{YSBZK_RKSJ}, #{YSBZK_GXSJ}, -c + #{STATUS}, + @@ -297,14 +298,13 @@ c YSBZK_RKSJ=#{YSBZK_RKSJ}, YSBZK_GXSJ=#{YSBZK_GXSJ}, STATUS=#{STATUS}, - where ZJLID = #{ZJLID} \ No newline at end of file