博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
多线程分页处理大批量数据实例
阅读量:5369 次
发布时间:2019-06-15

本文共 41387 字,大约阅读时间需要 137 分钟。

核心处理方法

@Override    public void syncData(String category) {            //判断当前es索引是否存在            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");            StringBuffer indexName = null;            if(category.equals(StatContant.CATEGORY_TYPE_HOUSE)) {
//房源 indexName = new StringBuffer("bi_kanyu_dm_housebase_").append(dateFormat.format(new Date())).append("_1"); }else if(category.equals(StatContant.CATEGORY_TYPE_CUSTORMER)) {
//客源 indexName = new StringBuffer("bi_kanyu_dm_customer_").append(dateFormat.format(new Date())).append("_1"); }else if(category.equals(StatContant.CATEGORY_TYPE_PERFORMANCE)) {
//业绩 indexName = new StringBuffer("bi_kanyu_dm_performance_").append(dateFormat.format(new Date())).append("_1"); } String indexName1 = indexName.toString(); String clusterNames = AppPropUtil.getPropValue(AppPropUtil.Keys.BI_CLUSTER_NAME); boolean indexExists = searchService.isIndexExists(clusterNames, indexName.toString()); if (indexExists) {
//如果这个索引存在,先干掉 searchService.deleteIndex(clusterNames, indexName.toString()); } //创建当前对应的索引 boolean createIndex = searchService.createIndex(clusterNames, indexName.toString()); if (createIndex) {
//创建安索引成功 logger.error("创建索引" + indexName + "成功"); //创建对应的mapping boolean createMapping = false; if(category.equals(StatContant.CATEGORY_TYPE_HOUSE)) {
//房源 createMapping = searchService.createMapping(clusterNames, indexName.toString(), ESContant.DM_HOUSEBASE_TYPE, FileUtils.getContentByLine("mappings/dm_housebase.txt")); }else if(category.equals(StatContant.CATEGORY_TYPE_CUSTORMER)) {
//客源 createMapping = searchService.createMapping(clusterNames, indexName.toString(), ESContant.DM_CUSTOMER_TYPE, FileUtils.getContentByLine("mappings/dm_customer.txt")); }else if(category.equals(StatContant.CATEGORY_TYPE_PERFORMANCE)) {
//业绩 createMapping = searchService.createMapping(clusterNames, indexName.toString(), ESContant.DM_PERFORMANCE_TYPE, FileUtils.getContentByLine("mappings/dm_performance.txt")); } if (createMapping) { logger.error("创建mapping--"+StatContant.CATEGORY_TYPE_MAP.get(category)+"成功"); long begin = System.currentTimeMillis(); logger.error("------------------开始同步BI两个月"+StatContant.CATEGORY_TYPE_MAP.get(category)+"中间表数据:开始时间" + DateUtil.getDefaultDate() + "-----------------------"); int pageSize = 10000; while (true) { int total = biJdbcTemplate.queryForInt("select count(1) from "+StatContant.CATEGORY_TYPE_MAP.get(category)+"_batch dt where dt.processed=1 and dt.status=0 and to_char(dt.batchtime,'yyyyMMdd') = to_char(sysdate,'yyyyMMdd')"); if (total == 0) { break; } logger.error("查出BI两个月"+StatContant.CATEGORY_TYPE_MAP.get(category)+"中间表数据为:" + total + "条"); double querySize = total; double totalPage = Math.ceil(querySize / pageSize); logger.error("共分" + totalPage + "页"); final String sql = "select * from (select t.*,rownum as rn from "+StatContant.CATEGORY_TYPE_MAP.get(category)+"_batch t where t.processed=1 and t.status=0 and to_char(t.batchtime,'yyyyMMdd') = to_char(sysdate,'yyyyMMdd') and rownum<=? order by t.batchtime asc) where rn>=?"; ExecutorService es = Executors.newFixedThreadPool(10); for (int i = 0; i < totalPage; i++) { int start = i * pageSize + 1; int end = (i + 1) * pageSize; if (end > total) { end = total; } final Object[] params = new Object[]{end, start}; es.submit(new Runnable() { @Override public void run() { List
> objs = new ArrayList
>(); List
dmperformances = new ArrayList
(); List
dmCustomers =new ArrayList
(); List
dmHouseBases = new ArrayList
(); if(category.equals(StatContant.CATEGORY_TYPE_CUSTORMER)) { //客源 dmCustomers = biJdbcTemplate.query(sql, params, new RowMapper
() { @Override public DmCustomer mapRow(ResultSet rs, int arg1) throws SQLException { DmCustomer dmCustomer = new DmCustomer(); String id = JugHelper.generalUUID(); dmCustomer.setId(id); dmCustomer.setMid(rs.getObject("MID") != null ? rs.getObject("MID").toString() : ""); dmCustomer.setDimorgid(rs.getObject("DIMORGID") != null ? rs.getObject("DIMORGID").toString() : ""); dmCustomer.setOldorgid(rs.getObject("OLDORGID") != null ? rs.getObject("OLDORGID").toString() : ""); dmCustomer.setDimdateid(rs.getObject("DIMDATEID") != null ? rs.getObject("DIMDATEID").toString() : ""); dmCustomer.setStartdate(rs.getObject("STARTDATE") != null ? rs.getObject("STARTDATE").toString() : ""); dmCustomer.setEnddate(rs.getObject("ENDDATE") != null ? rs.getObject("ENDDATE").toString() : ""); dmCustomer.setIdfullpath(rs.getObject("IDFULLPATH") != null ? rs.getObject("IDFULLPATH").toString() : ""); dmCustomer.setType(rs.getObject("TYPE") != null ? rs.getObject("TYPE").toString() : ""); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String batchTime = ""; if (rs.getObject("BATCHTIME") != null) { batchTime = format.format(rs.getDate("BATCHTIME")); } dmCustomer.setBatchtime(batchTime); dmCustomer.setBatchuser(rs.getObject("BATCHUSER") != null ? rs.getObject("BATCHUSER").toString() : ""); dmCustomer.setEfCusts(rs.getObject("EF_CUSTS") != null ? rs.getObject("EF_CUSTS").toString() : ""); dmCustomer.setBuyCusts(rs.getObject("BUY_CUSTS") != null ? rs.getObject("BUY_CUSTS").toString() : ""); dmCustomer.setSecLookCusts(rs.getObject("SEC_LOOK_CUSTS") != null ? rs.getObject("SEC_LOOK_CUSTS").toString() : ""); dmCustomer.setCrossRegionLookGroups(rs.getObject("CROSS_REGION_LOOK_GROUPS") != null ? rs.getObject("CROSS_REGION_LOOK_GROUPS").toString() : ""); dmCustomer.setLookGroups(rs.getObject("LOOK_GROUPS") != null ? rs.getObject("LOOK_GROUPS").toString() : ""); dmCustomer.setCrossZoneOfAreaLookGroups(rs.getObject("CROSS_ZONE_OF_AREA_LOOK_GROUPS") != null ? rs.getObject("CROSS_ZONE_OF_AREA_LOOK_GROUPS").toString() : ""); dmCustomer.setCrossAreaLookGroups(rs.getObject("CROSS_AREA_LOOK_GROUPS") != null ? rs.getObject("CROSS_AREA_LOOK_GROUPS").toString() : ""); dmCustomer.setCrossAreaOneWithMoreLooks(rs.getObject("CROSS_AREA_ONE_WITH_MORE_LOOKS") != null ? rs.getObject("CROSS_AREA_ONE_WITH_MORE_LOOKS").toString() : ""); dmCustomer.setAddCusts(rs.getObject("ADD_CUSTS") != null ? rs.getObject("ADD_CUSTS").toString() : ""); dmCustomer.setAddCusts7daysLook(rs.getObject("ADD_CUSTS_7DAYS_LOOK") != null ? rs.getObject("ADD_CUSTS_7DAYS_LOOK").toString() : ""); dmCustomer.setAddCustsDeals(rs.getObject("ADD_CUSTS_DEALS") != null ? rs.getObject("ADD_CUSTS_DEALS").toString() : ""); dmCustomer.setNewSalesPurchasesGroup(rs.getObject("NEW_SALES_PURCHASES_GROUP") != null ? rs.getObject("NEW_SALES_PURCHASES_GROUP").toString() : ""); dmCustomer.setSalesWithViews(rs.getObject("SALES_WITH_VIEWS") != null ? rs.getObject("SALES_WITH_VIEWS").toString() : ""); dmCustomer.setNewCustomersSeeMore(rs.getObject("NEW_CUSTOMERS_SEE_MORE") != null ? rs.getObject("NEW_CUSTOMERS_SEE_MORE").toString() : ""); dmCustomer.setNewRentCustomerGroup(rs.getObject("NEW_RENT_CUSTOMER_GROUP") != null ? rs.getObject("NEW_RENT_CUSTOMER_GROUP").toString() : ""); dmCustomer.setNewRentCustomersWithViews(rs.getObject("NEW_RENT_CUSTOMERS_WITH_VIEWS") != null ? rs.getObject("NEW_RENT_CUSTOMERS_WITH_VIEWS").toString() : ""); dmCustomer.setnTransaCustHisVAvgViews(rs.getObject("N_TRANSA_CUST_HIS_V_AVG_VIEWS") != null ? rs.getObject("N_TRANSA_CUST_HIS_V_AVG_VIEWS").toString() : ""); dmCustomer.setnTransaCustHisHAvgViews(rs.getObject("N_TRANSA_CUST_HIS_H_AVG_VIEWS") != null ? rs.getObject("N_TRANSA_CUST_HIS_H_AVG_VIEWS").toString() : ""); dmCustomer.setnTransaCustAvgPeriod(rs.getObject("N_TRANSA_CUST_AVG_PERIOD") != null ? rs.getObject("N_TRANSA_CUST_AVG_PERIOD").toString() : ""); dmCustomer.setDimorgcnt(rs.getObject("DIMORGCNT") != null ? rs.getObject("DIMORGCNT").toString() : ""); dmCustomer.setDimorgallcnt(rs.getObject("DIMORGALLCNT") != null ? rs.getObject("DIMORGALLCNT").toString() : ""); dmCustomer.setPerbusicnt(rs.getObject("PERBUSICNT") != null ? rs.getObject("PERBUSICNT").toString() : ""); dmCustomer.setPernobusicnt(rs.getObject("PERNOBUSICNT") != null ? rs.getObject("PERNOBUSICNT").toString() : ""); dmCustomer.setPidfullpath(rs.getObject("PIDFULLPATH") != null ? rs.getObject("PIDFULLPATH").toString() : ""); dmCustomer.setCrossAreaLookGroupsCnt(rs.getObject("CROSS_AREA_LOOK_GROUPS_CNT") != null ? rs.getObject("CROSS_AREA_LOOK_GROUPS_CNT").toString() : ""); dmCustomer.setShopcnt(rs.getObject("SHOPCNT") != null ? rs.getObject("SHOPCNT").toString() : ""); dmCustomer.setCrossAreaOneWithMoreGroup(rs.getObject("CROSS_AREA_ONE_WITH_MORE_GROUP") != null ? rs.getObject("CROSS_AREA_ONE_WITH_MORE_GROUP").toString() : ""); dmCustomer.setSecLookRate(rs.getObject("SEC_LOOK_RATE") != null ? rs.getObject("SEC_LOOK_RATE").toString() : ""); dmCustomer.setCrossAreaOneWithMoreRate(rs.getObject("CROSS_AREA_ONE_WITH_MORE_RATE") != null ? rs.getObject("CROSS_AREA_ONE_WITH_MORE_RATE").toString() : ""); dmCustomer.setCrossZoneOfAreaLookRate(rs.getObject("CROSS_ZONE_OF_AREA_LOOK_RATE") != null ? rs.getObject("CROSS_ZONE_OF_AREA_LOOK_RATE").toString() : ""); dmCustomer.setCrossAreaLookRate(rs.getObject("CROSS_AREA_LOOK_RATE") != null ? rs.getObject("CROSS_AREA_LOOK_RATE").toString() : ""); dmCustomer.setCrossAreaOneWithMore(rs.getObject("CROSS_AREA_ONE_WITH_MORE") != null ? rs.getObject("CROSS_AREA_ONE_WITH_MORE").toString() : ""); dmCustomer.setAddCustsDealsRate(rs.getObject("ADD_CUSTS_DEALS_RATE") != null ? rs.getObject("ADD_CUSTS_DEALS_RATE").toString() : ""); dmCustomer.setDimorgName(rs.getObject("DIMORG_NAME") != null ? rs.getObject("DIMORG_NAME").toString() : ""); dmCustomer.setPerBusi(rs.getObject("PER_BUSI") != null ? rs.getObject("PER_BUSI").toString() : ""); dmCustomer.setShopcnt1(rs.getObject("SHOPCNT1") != null ? rs.getObject("SHOPCNT1").toString() : ""); dmCustomer.setAreacnt1(rs.getObject("AREACNT1") != null ? rs.getObject("AREACNT1").toString() : ""); dmCustomer.setDictcnt1(rs.getObject("DICTCNT1") != null ? rs.getObject("DICTCNT1").toString() : ""); dmCustomer.setShopcnt2(rs.getObject("SHOPCNT2") != null ? rs.getObject("SHOPCNT2").toString() : ""); dmCustomer.setAreacnt2(rs.getObject("AREACNT2") != null ? rs.getObject("AREACNT2").toString() : ""); dmCustomer.setDictcnt2(rs.getObject("DICTCNT2") != null ? rs.getObject("DICTCNT2").toString() : ""); dmCustomer.setActperbusi2(rs.getObject("ACTPERBUSI2") != null ? rs.getObject("ACTPERBUSI2").toString() : ""); dmCustomer.setnTransaCustPeriod(rs.getObject("N_TRANSA_CUST_PERIOD") != null ? rs.getObject("N_TRANSA_CUST_PERIOD").toString() : ""); dmCustomer.setnTransaCustHisHViews(rs.getObject("N_TRANSA_CUST_HIS_H_VIEWS") != null ? rs.getObject("N_TRANSA_CUST_HIS_H_VIEWS").toString() : ""); dmCustomer.setNidfullpath(rs.getObject("NIDFULLPATH") != null ? rs.getObject("NIDFULLPATH").toString() : ""); dmCustomer.setNpidfullpath(rs.getObject("NPIDFULLPATH") != null ? rs.getObject("NPIDFULLPATH").toString() : ""); dmCustomer.setProcessed(rs.getObject("PROCESSED") != null ? rs.getObject("PROCESSED").toString() : ""); dmCustomer.setCrossZoneOfAreaLooks(rs.getObject("CROSS_ZONE_OF_AREA_LOOKS") != null ? rs.getObject("CROSS_ZONE_OF_AREA_LOOKS").toString() : ""); dmCustomer.setAreaSLookCnt(rs.getObject("AREA_S_LOOK_CNT") != null ? rs.getObject("AREA_S_LOOK_CNT").toString() : ""); dmCustomer.setAreaSLookGroups(rs.getObject("AREA_S_LOOK_GROUPS") != null ? rs.getObject("AREA_S_LOOK_GROUPS").toString() : ""); dmCustomer.setRepeatLookGroups(rs.getObject("REPEAT_LOOK_GROUPS") != null ? rs.getObject("REPEAT_LOOK_GROUPS").toString() : ""); dmCustomer.setRepeatLookRate(rs.getObject("REPEAT_LOOK_RATE") != null ? rs.getObject("REPEAT_LOOK_RATE").toString() : ""); dmCustomer.setStatus("1"); return dmCustomer; } }); for (DmCustomer dmCustomer : dmCustomers) { try { objs.add(StatUtils.objectToMap(dmCustomer)); } catch (Exception e) { e.printStackTrace(); } } }else if(category.equals(StatContant.CATEGORY_TYPE_HOUSE)) { dmHouseBases = biJdbcTemplate.query(sql, params, new RowMapper
() { @Override public DmHouseBase mapRow(ResultSet rs, int arg1) throws SQLException { DmHouseBase dmHouseBase = new DmHouseBase(); dmHouseBase.setId(rs.getObject("MID") != null ? rs.getObject("MID").toString() : ""); dmHouseBase.setMid(rs.getObject("MID") != null ? rs.getObject("MID").toString() : ""); dmHouseBase.setDimorgid(rs.getObject("DIMORGID") != null ? rs.getObject("DIMORGID").toString() : ""); dmHouseBase.setOldorgid(rs.getObject("OLDORGID") != null ? rs.getObject("OLDORGID").toString() : ""); dmHouseBase.setDimdateid(rs.getObject("DIMDATEID") != null ? rs.getObject("DIMDATEID").toString() : ""); dmHouseBase.setStartdate(rs.getObject("STARTDATE") != null ? rs.getObject("STARTDATE").toString() : ""); dmHouseBase.setEnddate(rs.getObject("ENDDATE") != null ? rs.getObject("ENDDATE").toString() : ""); dmHouseBase.setIdfullpath(rs.getObject("IDFULLPATH") != null ? rs.getObject("IDFULLPATH").toString() : ""); dmHouseBase.setType(rs.getObject("TYPE") != null ? rs.getObject("TYPE").toString() : ""); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String batchTime = ""; if (rs.getObject("BATCHTIME") != null) { batchTime = format.format(rs.getDate("BATCHTIME")); } dmHouseBase.setBatchtime(batchTime); dmHouseBase.setBatchuser(rs.getObject("BATCHUSER") != null ? rs.getObject("BATCHUSER").toString() : ""); dmHouseBase.setForsalecnt(rs.getObject("FORSALECNT") != null ? rs.getObject("FORSALECNT").toString() : ""); dmHouseBase.setHaskeycnt(rs.getObject("HASKEYCNT") != null ? rs.getObject("HASKEYCNT").toString() : ""); dmHouseBase.setAuthorcnt(rs.getObject("AUTHORCNT") != null ? rs.getObject("AUTHORCNT").toString() : ""); dmHouseBase.setGoodpiccnt(rs.getObject("GOODPICCNT") != null ? rs.getObject("GOODPICCNT").toString() : ""); dmHouseBase.setGoodhoucnt(rs.getObject("GOODHOUCNT") != null ? rs.getObject("GOODHOUCNT").toString() : ""); dmHouseBase.setSecLookCusts(rs.getObject("SEC_LOOK_CUSTS") != null ? rs.getObject("SEC_LOOK_CUSTS").toString() : ""); dmHouseBase.setCrossRegionLookGroups(rs.getObject("CROSS_REGION_LOOK_GROUPS") != null ? rs.getObject("CROSS_REGION_LOOK_GROUPS").toString() : ""); dmHouseBase.setLookGroups(rs.getObject("LOOK_GROUPS") != null ? rs.getObject("LOOK_GROUPS").toString() : ""); dmHouseBase.setCrossZoneOfAreaLookGroups(rs.getObject("CROSS_ZONE_OF_AREA_LOOK_GROUPS") != null ? rs.getObject("CROSS_ZONE_OF_AREA_LOOK_GROUPS").toString() : ""); dmHouseBase.setCrossAreaLookGroups(rs.getObject("CROSS_AREA_LOOK_GROUPS") != null ? rs.getObject("CROSS_AREA_LOOK_GROUPS").toString() : ""); dmHouseBase.setCrossAreaOneWithMoreLooks(rs.getObject("CROSS_AREA_ONE_WITH_MORE_LOOKS") != null ? rs.getObject("CROSS_AREA_ONE_WITH_MORE_LOOKS").toString() : ""); dmHouseBase.setDimorgcnt(rs.getObject("DIMORGCNT") != null ? rs.getObject("DIMORGCNT").toString() : ""); dmHouseBase.setDimorgallcnt(rs.getObject("DIMORGALLCNT") != null ? rs.getObject("DIMORGALLCNT").toString() : ""); dmHouseBase.setAddHouse(rs.getObject("ADD_HOUSE") != null ? rs.getObject("ADD_HOUSE").toString() : ""); dmHouseBase.setAddSalekey(rs.getObject("ADD_SALEKEY") != null ? rs.getObject("ADD_SALEKEY").toString() : ""); dmHouseBase.setAddSaleauthor(rs.getObject("ADD_SALEAUTHOR") != null ? rs.getObject("ADD_SALEAUTHOR").toString() : ""); dmHouseBase.setAddRentauthor(rs.getObject("ADD_RENTAUTHOR") != null ? rs.getObject("ADD_RENTAUTHOR").toString() : ""); dmHouseBase.setAddRentkey(rs.getObject("ADD_RENTKEY") != null ? rs.getObject("ADD_RENTKEY").toString() : ""); dmHouseBase.setAddGoogpicture(rs.getObject("ADD_GOOGPICTURE") != null ? rs.getObject("ADD_GOOGPICTURE").toString() : ""); dmHouseBase.setPerbusicnt(rs.getObject("PERBUSICNT") != null ? rs.getObject("PERBUSICNT").toString() : ""); dmHouseBase.setPernobusicnt(rs.getObject("PERNOBUSICNT") != null ? rs.getObject("PERNOBUSICNT").toString() : ""); dmHouseBase.setAddSevenActioncnt(rs.getObject("ADD_SEVEN_ACTIONCNT") != null ? rs.getObject("ADD_SEVEN_ACTIONCNT").toString() : ""); dmHouseBase.setPidfullpath(rs.getObject("PIDFULLPATH") != null ? rs.getObject("PIDFULLPATH").toString() : ""); dmHouseBase.setAddRent(rs.getObject("ADD_RENT") != null ? rs.getObject("ADD_RENT").toString() : ""); dmHouseBase.setShopcnt(rs.getObject("SHOPCNT") != null ? rs.getObject("SHOPCNT").toString() : ""); dmHouseBase.setForsaleDutyCnt(rs.getObject("FORSALE_DUTY_CNT") != null ? rs.getObject("FORSALE_DUTY_CNT").toString() : ""); dmHouseBase.setLookCnt(rs.getObject("LOOK_CNT") != null ? rs.getObject("LOOK_CNT").toString() : ""); dmHouseBase.setCrossAreaLookCnt(rs.getObject("CROSS_AREA_LOOK_CNT") != null ? rs.getObject("CROSS_AREA_LOOK_CNT").toString() : ""); dmHouseBase.setCrossRegionHouseLooks(rs.getObject("CROSS_REGION_HOUSE_LOOKS") != null ? rs.getObject("CROSS_REGION_HOUSE_LOOKS").toString() : ""); dmHouseBase.setLatelySevenActioncnt(rs.getObject("LATELY_SEVEN_ACTIONCNT") != null ? rs.getObject("LATELY_SEVEN_ACTIONCNT").toString() : ""); dmHouseBase.setForsaleDutyOwerCnt(rs.getObject("FORSALE_DUTY_OWER_CNT") != null ? rs.getObject("FORSALE_DUTY_OWER_CNT").toString() : ""); dmHouseBase.setHaskeyRate(rs.getObject("HASKEY_RATE") != null ? rs.getObject("HASKEY_RATE").toString() : ""); dmHouseBase.setAuthorRate(rs.getObject("AUTHOR_RATE") != null ? rs.getObject("AUTHOR_RATE").toString() : ""); dmHouseBase.setGoodpicRate(rs.getObject("GOODPIC_RATE") != null ? rs.getObject("GOODPIC_RATE").toString() : ""); dmHouseBase.setForsaleDutyRate(rs.getObject("FORSALE_DUTY_RATE") != null ? rs.getObject("FORSALE_DUTY_RATE").toString() : ""); dmHouseBase.setForsalePerAvg(rs.getObject("FORSALE_PER_AVG") != null ? rs.getObject("FORSALE_PER_AVG").toString() : ""); dmHouseBase.setForsaleShopAvg(rs.getObject("FORSALE_SHOP_AVG") != null ? rs.getObject("FORSALE_SHOP_AVG").toString() : ""); dmHouseBase.setCrossAreaLookRate(rs.getObject("CROSS_AREA_LOOK_RATE") != null ? rs.getObject("CROSS_AREA_LOOK_RATE").toString() : ""); dmHouseBase.setCrossAreaOneWithMoreRate(rs.getObject("CROSS_AREA_ONE_WITH_MORE_RATE") != null ? rs.getObject("CROSS_AREA_ONE_WITH_MORE_RATE").toString() : ""); dmHouseBase.setAddSevenActionRate(rs.getObject("ADD_SEVEN_ACTION_RATE") != null ? rs.getObject("ADD_SEVEN_ACTION_RATE").toString() : ""); dmHouseBase.setLatelySevenActionRate(rs.getObject("LATELY_SEVEN_ACTION_RATE") != null ? rs.getObject("LATELY_SEVEN_ACTION_RATE").toString() : ""); dmHouseBase.setLastTwentyPercentAvg(rs.getObject("LAST_TWENTY_PERCENT_AVG") != null ? rs.getObject("LAST_TWENTY_PERCENT_AVG").toString() : ""); dmHouseBase.setDimorgName(rs.getObject("DIMORG_NAME") != null ? rs.getObject("DIMORG_NAME").toString() : ""); dmHouseBase.setPerBusi(rs.getObject("PER_BUSI") != null ? rs.getObject("PER_BUSI").toString() : ""); dmHouseBase.setShopcnt1(rs.getObject("SHOPCNT1") != null ? rs.getObject("SHOPCNT1").toString() : ""); dmHouseBase.setAreacnt1(rs.getObject("AREACNT1") != null ? rs.getObject("AREACNT1").toString() : ""); dmHouseBase.setDictcnt1(rs.getObject("DICTCNT1") != null ? rs.getObject("DICTCNT1").toString() : ""); dmHouseBase.setShopcnt2(rs.getObject("SHOPCNT2") != null ? rs.getObject("SHOPCNT2").toString() : ""); dmHouseBase.setAreacnt2(rs.getObject("AREACNT2") != null ? rs.getObject("AREACNT2").toString() : ""); dmHouseBase.setDictcnt2(rs.getObject("DICTCNT2") != null ? rs.getObject("DICTCNT2").toString() : ""); dmHouseBase.setActperbusi2(rs.getObject("ACTPERBUSI2") != null ? rs.getObject("ACTPERBUSI2").toString() : ""); dmHouseBase.setNidfullpath(rs.getObject("NIDFULLPATH") != null ? rs.getObject("NIDFULLPATH").toString() : ""); dmHouseBase.setNpidfullpath(rs.getObject("NPIDFULLPATH") != null ? rs.getObject("NPIDFULLPATH").toString() : ""); dmHouseBase.setProcessed(rs.getObject("PROCESSED") != null ? rs.getObject("PROCESSED").toString() : ""); dmHouseBase.setCrossAreaLookCnt(rs.getObject("CROSS_AREA_S_LOOK_CNT") != null ? rs.getObject("CROSS_AREA_S_LOOK_CNT").toString() : ""); dmHouseBase.setAreaSLookCnt(rs.getObject("AREA_S_LOOK_CNT") != null ? rs.getObject("AREA_S_LOOK_CNT").toString() : ""); dmHouseBase.setAreaSLookGroups(rs.getObject("AREA_S_LOOK_GROUPS") != null ? rs.getObject("AREA_S_LOOK_GROUPS").toString() : ""); dmHouseBase.setStatus("1"); return dmHouseBase; } }); for (DmHouseBase dmHouseBase : dmHouseBases) { try { objs.add(StatUtils.objectToMap(dmHouseBase)); } catch (Exception e) { e.printStackTrace(); } } }else if(category.equals(StatContant.CATEGORY_TYPE_PERFORMANCE)) { dmperformances = biJdbcTemplate.query(sql, params, new RowMapper
() { @Override public DmPerformance mapRow(ResultSet rs, int arg1) throws SQLException { DmPerformance dmperformance = new DmPerformance(); String id = JugHelper.generalUUID(); dmperformance.setId(id); dmperformance.setMid(rs.getObject("MID") != null ? rs.getObject("MID").toString() : ""); dmperformance.setDimorgid(rs.getObject("DIMORGID") != null ? rs.getObject("DIMORGID").toString() : ""); dmperformance.setOldorgid(rs.getObject("OLDORGID") != null ? rs.getObject("OLDORGID").toString() : ""); dmperformance.setDimdateid(rs.getObject("DIMDATEID") != null ? rs.getObject("DIMDATEID").toString() : ""); dmperformance.setStartdate(rs.getObject("STARTDATE") != null ? rs.getObject("STARTDATE").toString() : ""); dmperformance.setEnddate(rs.getObject("ENDDATE") != null ? rs.getObject("ENDDATE").toString() : ""); dmperformance.setIdfullpath(rs.getObject("IDFULLPATH") != null ? rs.getObject("IDFULLPATH").toString() : ""); dmperformance.setType(rs.getObject("TYPE") != null ? rs.getObject("TYPE").toString() : ""); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String batchTime = ""; if (rs.getObject("BATCHTIME") != null) { batchTime = format.format(rs.getDate("BATCHTIME")); } dmperformance.setBatchtime(batchTime); dmperformance.setBatchuser(rs.getObject("BATCHUSER") != null ? rs.getObject("BATCHUSER").toString() : ""); dmperformance.setPerformanceMoney(rs.getObject("PERFORMANCE_MONEY") != null ? rs.getObject("PERFORMANCE_MONEY").toString() : ""); dmperformance.setPerformanceCnt(rs.getObject("PERFORMANCE_CNT") != null ? rs.getObject("PERFORMANCE_CNT").toString() : ""); dmperformance.setPerformanceMoneySArea(rs.getObject("PERFORMANCE_MONEY_S_AREA") != null ? rs.getObject("PERFORMANCE_MONEY_S_AREA").toString() : ""); dmperformance.setPerformanceMoneyCArea(rs.getObject("PERFORMANCE_MONEY_C_AREA") != null ? rs.getObject("PERFORMANCE_MONEY_C_AREA").toString() : ""); dmperformance.setPerformanceMoneyCDictarea(rs.getObject("PERFORMANCE_MONEY_C_DICTAREA") != null ? rs.getObject("PERFORMANCE_MONEY_C_DICTAREA").toString() : ""); dmperformance.setPerformanceHCnt(rs.getObject("PERFORMANCE_H_CNT") != null ? rs.getObject("PERFORMANCE_H_CNT").toString() : ""); dmperformance.setPerformanceCCnt(rs.getObject("PERFORMANCE_C_CNT") != null ? rs.getObject("PERFORMANCE_C_CNT").toString() : ""); dmperformance.setPerformanceHMoney(rs.getObject("PERFORMANCE_H_MONEY") != null ? rs.getObject("PERFORMANCE_H_MONEY").toString() : ""); dmperformance.setPerformanceCMoney(rs.getObject("PERFORMANCE_C_MONEY") != null ? rs.getObject("PERFORMANCE_C_MONEY").toString() : ""); dmperformance.setPerformanceMoneyGroups(rs.getObject("PERFORMANCE_MONEY_GROUPS") != null ? rs.getObject("PERFORMANCE_MONEY_GROUPS").toString() : ""); dmperformance.setPerformanceMoneyOrders(rs.getObject("PERFORMANCE_MONEY_ORDERS") != null ? rs.getObject("PERFORMANCE_MONEY_ORDERS").toString() : ""); dmperformance.setPerformanceMoneyPers(rs.getObject("PERFORMANCE_MONEY_PERS") != null ? rs.getObject("PERFORMANCE_MONEY_PERS").toString() : ""); dmperformance.setSellamount(rs.getObject("SELLAMOUNT") != null ? rs.getObject("SELLAMOUNT").toString() : ""); dmperformance.setPerformanceMoneySer(rs.getObject("PERFORMANCE_MONEY_SER") != null ? rs.getObject("PERFORMANCE_MONEY_SER").toString() : ""); dmperformance.setRentMoney(rs.getObject("RENT_MONEY") != null ? rs.getObject("RENT_MONEY").toString() : ""); dmperformance.setRentHCnt(rs.getObject("RENT_H_CNT") != null ? rs.getObject("RENT_H_CNT").toString() : ""); dmperformance.setRentCCnt(rs.getObject("RENT_C_CNT") != null ? rs.getObject("RENT_C_CNT").toString() : ""); dmperformance.setRentACnt(rs.getObject("RENT_A_CNT") != null ? rs.getObject("RENT_A_CNT").toString() : ""); dmperformance.setRentHMoney(rs.getObject("RENT_H_MONEY") != null ? rs.getObject("RENT_H_MONEY").toString() : ""); dmperformance.setRentCMoney(rs.getObject("RENT_C_MONEY") != null ? rs.getObject("RENT_C_MONEY").toString() : ""); dmperformance.setGuarFee(rs.getObject("GUAR_FEE") != null ? rs.getObject("GUAR_FEE").toString() : ""); dmperformance.setGuarCnt(rs.getObject("GUAR_CNT") != null ? rs.getObject("GUAR_CNT").toString() : ""); dmperformance.setDutycnt(rs.getObject("DUTYCNT") != null ? rs.getObject("DUTYCNT").toString() : ""); dmperformance.setNewhouseMoney(rs.getObject("NEWHOUSE_MONEY") != null ? rs.getObject("NEWHOUSE_MONEY").toString() : ""); dmperformance.setNewhouseCnt(rs.getObject("NEWHOUSE_CNT") != null ? rs.getObject("NEWHOUSE_CNT").toString() : ""); dmperformance.setNewhouseFee(rs.getObject("NEWHOUSE_FEE") != null ? rs.getObject("NEWHOUSE_FEE").toString() : ""); dmperformance.setDimorgcnt(rs.getObject("DIMORGCNT") != null ? rs.getObject("DIMORGCNT").toString() : ""); dmperformance.setDimorgallcnt(rs.getObject("DIMORGALLCNT") != null ? rs.getObject("DIMORGALLCNT").toString() : ""); dmperformance.setPerbusicnt(rs.getObject("PERBUSICNT") != null ? rs.getObject("PERBUSICNT").toString() : ""); dmperformance.setPernobusicnt(rs.getObject("PERNOBUSICNT") != null ? rs.getObject("PERNOBUSICNT").toString() : ""); dmperformance.setPerformancePercnt(rs.getObject("PERFORMANCE_PERCNT") != null ? rs.getObject("PERFORMANCE_PERCNT").toString() : ""); dmperformance.setAllmoney(rs.getObject("ALLMONEY") != null ? rs.getObject("ALLMONEY").toString() : ""); dmperformance.setPidfullpath(rs.getObject("PIDFULLPATH") != null ? rs.getObject("PIDFULLPATH").toString() : ""); dmperformance.setShopcnt(rs.getObject("SHOPCNT") != null ? rs.getObject("SHOPCNT").toString() : ""); dmperformance.setShopAllmoneyAvg(rs.getObject("SHOP_ALLMONEY_AVG") != null ? rs.getObject("SHOP_ALLMONEY_AVG").toString() : ""); dmperformance.setPerAllmoneyAvg(rs.getObject("PER_ALLMONEY_AVG") != null ? rs.getObject("PER_ALLMONEY_AVG").toString() : ""); dmperformance.setShopPerformanceAvg(rs.getObject("SHOP_PERFORMANCE_AVG") != null ? rs.getObject("SHOP_PERFORMANCE_AVG").toString() : ""); dmperformance.setCntPerformanceAvg(rs.getObject("CNT_PERFORMANCE_AVG") != null ? rs.getObject("CNT_PERFORMANCE_AVG").toString() : ""); dmperformance.setPerPerformanceAvg(rs.getObject("PER_PERFORMANCE_AVG") != null ? rs.getObject("PER_PERFORMANCE_AVG").toString() : ""); dmperformance.setPerformanceCommissionRate(rs.getObject("PERFORMANCE_COMMISSION_RATE") != null ? rs.getObject("PERFORMANCE_COMMISSION_RATE").toString() : ""); dmperformance.setDimorgName(rs.getObject("DIMORG_NAME") != null ? rs.getObject("DIMORG_NAME").toString() : ""); dmperformance.setPerformanceDictareaCnt(rs.getObject("PERFORMANCE_DICTAREA_CNT") != null ? rs.getObject("PERFORMANCE_DICTAREA_CNT").toString() : ""); dmperformance.setPerformanceDictareaRate(rs.getObject("PERFORMANCE_DICTAREA_RATE") != null ? rs.getObject("PERFORMANCE_DICTAREA_RATE").toString() : ""); dmperformance.setPerformanceAreaCnt(rs.getObject("PERFORMANCE_AREA_CNT") != null ? rs.getObject("PERFORMANCE_AREA_CNT").toString() : ""); dmperformance.setPerformanceAreaRate(rs.getObject("PERFORMANCE_AREA_RATE") != null ? rs.getObject("PERFORMANCE_AREA_RATE").toString() : ""); dmperformance.setDiscountCommissionRate(rs.getObject("DISCOUNT_COMMISSION_RATE") != null ? rs.getObject("DISCOUNT_COMMISSION_RATE").toString() : ""); dmperformance.setNoDealCnt(rs.getObject("NO_DEAL_CNT") != null ? rs.getObject("NO_DEAL_CNT").toString() : ""); dmperformance.setNoDealRate(rs.getObject("NO_DEAL_RATE") != null ? rs.getObject("NO_DEAL_RATE").toString() : ""); dmperformance.setDealCnt(rs.getObject("DEAL_CNT") != null ? rs.getObject("DEAL_CNT").toString() : ""); dmperformance.setDealRate(rs.getObject("DEAL_RATE") != null ? rs.getObject("DEAL_RATE").toString() : ""); dmperformance.setCntRentAvg(rs.getObject("CNT_RENT_AVG") != null ? rs.getObject("CNT_RENT_AVG").toString() : ""); dmperformance.setRentAvgRate(rs.getObject("RENT_AVG_RATE") != null ? rs.getObject("RENT_AVG_RATE").toString() : ""); dmperformance.setCommissionMoney(rs.getObject("COMMISSION_MONEY") != null ? rs.getObject("COMMISSION_MONEY").toString() : ""); dmperformance.setDiscountCommissionMoney(rs.getObject("DISCOUNT_COMMISSION_MONEY") != null ? rs.getObject("DISCOUNT_COMMISSION_MONEY").toString() : ""); dmperformance.setPerBusi(rs.getObject("PER_BUSI") != null ? rs.getObject("PER_BUSI").toString() : ""); dmperformance.setShopcnt1(rs.getObject("SHOPCNT1") != null ? rs.getObject("SHOPCNT1").toString() : ""); dmperformance.setAreacnt1(rs.getObject("AREACNT1") != null ? rs.getObject("AREACNT1").toString() : ""); dmperformance.setDictcnt1(rs.getObject("DICTCNT1") != null ? rs.getObject("DICTCNT1").toString() : ""); dmperformance.setShopcnt2(rs.getObject("SHOPCNT2") != null ? rs.getObject("SHOPCNT2").toString() : ""); dmperformance.setAreacnt2(rs.getObject("AREACNT2") != null ? rs.getObject("AREACNT2").toString() : ""); dmperformance.setDictcnt2(rs.getObject("DICTCNT2") != null ? rs.getObject("DICTCNT2").toString() : ""); dmperformance.setActperbusi2(rs.getObject("ACTPERBUSI2") != null ? rs.getObject("ACTPERBUSI2").toString() : ""); dmperformance.setCommissionCMoney(rs.getObject("COMMISSION_C_MONEY") != null ? rs.getObject("COMMISSION_C_MONEY").toString() : ""); dmperformance.setSellCAmount(rs.getObject("SELL_C_AMOUNT") != null ? rs.getObject("SELL_C_AMOUNT").toString() : ""); dmperformance.setRate27Cnt(rs.getObject("RATE_27_CNT") != null ? rs.getObject("RATE_27_CNT").toString() : ""); dmperformance.setRate25Cnt(rs.getObject("RATE_25_CNT") != null ? rs.getObject("RATE_25_CNT").toString() : ""); dmperformance.setRate20Cnt(rs.getObject("RATE_20_CNT") != null ? rs.getObject("RATE_20_CNT").toString() : ""); dmperformance.setRate15Cnt(rs.getObject("RATE_15_CNT") != null ? rs.getObject("RATE_15_CNT").toString() : ""); dmperformance.setRateOtherCnt(rs.getObject("RATE_OTHER_CNT") != null ? rs.getObject("RATE_OTHER_CNT").toString() : ""); dmperformance.setAllReachPerMoney(rs.getObject("ALL_REACH_PER_MONEY") != null ? rs.getObject("ALL_REACH_PER_MONEY").toString() : ""); dmperformance.setAllNoReachPerMoney(rs.getObject("ALL_NO_REACH_PER_MONEY") != null ? rs.getObject("ALL_NO_REACH_PER_MONEY").toString() : ""); dmperformance.setAllReachPerCnt(rs.getObject("ALL_REACH_PER_CNT") != null ? rs.getObject("ALL_REACH_PER_CNT").toString() : ""); dmperformance.setAllNoReachPerCnt(rs.getObject("ALL_NO_REACH_PER_CNT") != null ? rs.getObject("ALL_NO_REACH_PER_CNT").toString() : ""); dmperformance.setAllReachShopMoney(rs.getObject("ALL_REACH_SHOP_MONEY") != null ? rs.getObject("ALL_REACH_SHOP_MONEY").toString() : ""); dmperformance.setAllNoReachShopMoney(rs.getObject("ALL_NO_REACH_SHOP_MONEY") != null ? rs.getObject("ALL_NO_REACH_SHOP_MONEY").toString() : ""); dmperformance.setAllReachShopCnt(rs.getObject("ALL_REACH_SHOP_CNT") != null ? rs.getObject("ALL_REACH_SHOP_CNT").toString() : ""); dmperformance.setAllNoReachShopCnt(rs.getObject("ALL_NO_REACH_SHOP_CNT") != null ? rs.getObject("ALL_NO_REACH_SHOP_CNT").toString() : ""); dmperformance.setPerformanceReachPerMoney(rs.getObject("PERFORMANCE_REACH_PER_MONEY") != null ? rs.getObject("PERFORMANCE_REACH_PER_MONEY").toString() : ""); dmperformance.setPerformanceNoReachPerMoney(rs.getObject("PERFORMANCE_NO_REACH_PER_MONEY") != null ? rs.getObject("PERFORMANCE_NO_REACH_PER_MONEY").toString() : ""); dmperformance.setPerformanceReachPerCnt(rs.getObject("PERFORMANCE_REACH_PER_CNT") != null ? rs.getObject("PERFORMANCE_REACH_PER_CNT").toString() : ""); dmperformance.setPerformanceNoReachPerCnt(rs.getObject("PERFORMANCE_NO_REACH_PER_CNT") != null ? rs.getObject("PERFORMANCE_NO_REACH_PER_CNT").toString() : ""); dmperformance.setPerformanceReachShopMoney(rs.getObject("PERFORMANCE_REACH_SHOP_MONEY") != null ? rs.getObject("PERFORMANCE_REACH_SHOP_MONEY").toString() : ""); dmperformance.setPerformanceNoReaShopMoney(rs.getObject("PERFORMANCE_NO_REA_SHOP_MONEY") != null ? rs.getObject("PERFORMANCE_NO_REA_SHOP_MONEY").toString() : ""); dmperformance.setPerformanceReachShopCnt(rs.getObject("PERFORMANCE_REACH_SHOP_CNT") != null ? rs.getObject("PERFORMANCE_REACH_SHOP_CNT").toString() : ""); dmperformance.setPerformanceNoReachShopCnt(rs.getObject("PERFORMANCE_NO_REACH_SHOP_CNT") != null ? rs.getObject("PERFORMANCE_NO_REACH_SHOP_CNT").toString() : ""); dmperformance.setInsideDiscount(rs.getObject("INSIDE_DISCOUNT") != null ? rs.getObject("INSIDE_DISCOUNT").toString() : ""); dmperformance.setInsideDiscountRate(rs.getObject("INSIDE_DISCOUNT_RATE") != null ? rs.getObject("INSIDE_DISCOUNT_RATE").toString() : ""); dmperformance.setOutsideDiscount(rs.getObject("OUTSIDE_DISCOUNT") != null ? rs.getObject("OUTSIDE_DISCOUNT").toString() : ""); dmperformance.setOutsideDiscountRate(rs.getObject("OUTSIDE_DISCOUNT_RATE") != null ? rs.getObject("OUTSIDE_DISCOUNT_RATE").toString() : ""); dmperformance.setLitigationCompensation(rs.getObject("LITIGATION_COMPENSATION") != null ? rs.getObject("LITIGATION_COMPENSATION").toString() : ""); dmperformance.setLitigationCompensationRate(rs.getObject("LITIGATION_COMPENSATION_RATE") != null ? rs.getObject("LITIGATION_COMPENSATION_RATE").toString() : ""); dmperformance.setNoLitigationCompensation(rs.getObject("NO_LITIGATION_COMPENSATION") != null ? rs.getObject("NO_LITIGATION_COMPENSATION").toString() : ""); dmperformance.setNoLitigationCompensaRate(rs.getObject("NO_LITIGATION_COMPENSA_RATE") != null ? rs.getObject("NO_LITIGATION_COMPENSA_RATE").toString() : ""); dmperformance.setCancellationListMoney(rs.getObject("CANCELLATION_LIST_MONEY") != null ? rs.getObject("CANCELLATION_LIST_MONEY").toString() : ""); dmperformance.setCancellationListRate(rs.getObject("CANCELLATION_LIST_RATE") != null ? rs.getObject("CANCELLATION_LIST_RATE").toString() : ""); dmperformance.setNormalListMoney(rs.getObject("NORMAL_LIST_MONEY") != null ? rs.getObject("NORMAL_LIST_MONEY").toString() : ""); dmperformance.setNormalListRate(rs.getObject("NORMAL_LIST_RATE") != null ? rs.getObject("NORMAL_LIST_RATE").toString() : ""); dmperformance.setCancellationMoney(rs.getObject("CANCELLATION_MONEY") != null ? rs.getObject("CANCELLATION_MONEY").toString() : ""); dmperformance.setCancellationRate(rs.getObject("CANCELLATION_RATE") != null ? rs.getObject("CANCELLATION_RATE").toString() : ""); dmperformance.setTravelMoney(rs.getObject("TRAVEL_MONEY") != null ? rs.getObject("TRAVEL_MONEY").toString() : ""); dmperformance.setTravelRate(rs.getObject("TRAVEL_RATE") != null ? rs.getObject("TRAVEL_RATE").toString() : ""); dmperformance.setMaidMoney(rs.getObject("MAID_MONEY") != null ? rs.getObject("MAID_MONEY").toString() : ""); dmperformance.setMaidRate(rs.getObject("MAID_RATE") != null ? rs.getObject("MAID_RATE").toString() : ""); dmperformance.setPerformanceRate(rs.getObject("PERFORMANCE_RATE") != null ? rs.getObject("PERFORMANCE_RATE").toString() : ""); dmperformance.setRentRate(rs.getObject("RENT_RATE") != null ? rs.getObject("RENT_RATE").toString() : ""); dmperformance.setGuarRate(rs.getObject("GUAR_RATE") != null ? rs.getObject("GUAR_RATE").toString() : ""); dmperformance.setNewhouseRate(rs.getObject("NEWHOUSE_RATE") != null ? rs.getObject("NEWHOUSE_RATE").toString() : ""); dmperformance.setPerformanceDictMoneyRate(rs.getObject("PERFORMANCE_DICT_MONEY_RATE") != null ? rs.getObject("PERFORMANCE_DICT_MONEY_RATE").toString() : ""); dmperformance.setPerformanceAreaMoneyRate(rs.getObject("PERFORMANCE_AREA_MONEY_RATE") != null ? rs.getObject("PERFORMANCE_AREA_MONEY_RATE").toString() : ""); dmperformance.setPerformanceSAreaMoneyRate(rs.getObject("PERFORMANCE_S_AREA_MONEY_RATE") != null ? rs.getObject("PERFORMANCE_S_AREA_MONEY_RATE").toString() : ""); dmperformance.setRentHRate(rs.getObject("RENT_H_RATE") != null ? rs.getObject("RENT_H_RATE").toString() : ""); dmperformance.setRentCRate(rs.getObject("RENT_C_RATE") != null ? rs.getObject("RENT_C_RATE").toString() : ""); dmperformance.setNidfullpath(rs.getObject("NIDFULLPATH") != null ? rs.getObject("NIDFULLPATH").toString() : ""); dmperformance.setNpidfullpath(rs.getObject("NPIDFULLPATH") != null ? rs.getObject("NPIDFULLPATH").toString() : ""); dmperformance.setProcessed(rs.getObject("PROCESSED") != null ? rs.getObject("PROCESSED").toString() : ""); dmperformance.setStatus("1"); return dmperformance; } }); for (DmPerformance dmperformance : dmperformances) { try { objs.add(StatUtils.objectToMap(dmperformance)); } catch (Exception e) { e.printStackTrace(); } } } try { String clusterNames = AppPropUtil.getPropValue(AppPropUtil.Keys.BI_CLUSTER_NAME); if (!CollectionUtils.isEmpty(objs)) { //保证结果集不为空 boolean batchInsert = searchService.batchInsert(clusterNames,indexName1,StatContant.CATEGORY_TYPE_MAP.get(category), objs); if (batchInsert) { //如果成功返回200更新中间表状态为已处理 logger.error("------------------开始更新"+StatContant.CATEGORY_TYPE_MAP.get(category)+"中间表数据状态------------------------"); StringBuffer sql = new StringBuffer("update "+StatContant.CATEGORY_TYPE_MAP.get(category)+"_batch t set t.status = 1 where "); ArrayList
midLists = new ArrayList
(); if(category.equals(StatContant.CATEGORY_TYPE_HOUSE)) { //房源 for (DmHouseBase dmHouseBase : dmHouseBases) { midLists.add(dmHouseBase.getMid()); } }else if(category.equals(StatContant.CATEGORY_TYPE_CUSTORMER)) { //客源 for (DmCustomer customer : dmCustomers) { midLists.add(customer.getMid()); } }else if(category.equals(StatContant.CATEGORY_TYPE_PERFORMANCE)) { //业绩 for (DmPerformance dmperformance : dmperformances) { midLists.add(dmperformance.getMid()); } } String sqlbuffer = StatUtils.chgListStrToInStr("t.mid", midLists); sql.append(sqlbuffer); int[] batchUpdate = biJdbcTemplate.batchUpdate(new String[]{sql.toString()}); logger.error("------------------结束更新"+StatContant.CATEGORY_TYPE_MAP.get(category)+"中间表数据状态共:" + batchUpdate[0] + "条-----------------------"); } else { //es插入失败,强制回滚事物,干掉这一批插入的全部数据 logger.error("------------------batch插入es报错,强制回滚事物,批量删除开始------------------------"); StringBuffer buffer = new StringBuffer(); if(category.equals(StatContant.CATEGORY_TYPE_HOUSE)) { //房源 for (DmHouseBase dmHouseBase : dmHouseBases) { buffer.append(dmHouseBase.getMid()).append(" "); } }else if(category.equals(StatContant.CATEGORY_TYPE_CUSTORMER)) { //客源 for (DmCustomer customer : dmCustomers) { buffer.append(customer.getMid()).append(" "); } }else if(category.equals(StatContant.CATEGORY_TYPE_PERFORMANCE)) { //业绩 for (DmPerformance dmperformance : dmperformances) { buffer.append(dmperformance.getMid()).append(" "); } } String midsString = buffer.substring(0, buffer.length() - 1); Map
conditions = new HashMap
(); conditions.put("mid", midsString); boolean deleteRecordsByConditions = searchService.deleteRecordsByConditions(clusterNames, indexName1,StatContant.CATEGORY_TYPE_MAP.get(category), conditions); if (deleteRecordsByConditions) { logger.error("------------------batch插入es报错,强制回滚事物,批量删除结束------------------------"); } } } } catch (Exception e) { e.printStackTrace(); } } }); } es.shutdown(); try { boolean loop = true; do { //等待所有任务完成 loop = !es.awaitTermination(2, TimeUnit.SECONDS); //阻塞,直到线程池里所有任务结束 } while (loop); } catch (Exception e) { e.printStackTrace(); } } logger.error("------------------同步BI两个月"+StatContant.CATEGORY_TYPE_MAP.get(category)+"中间表数据结束:结束时间" + DateUtil.getDefaultDate() + "-----------------------"); long end = System.currentTimeMillis(); logger.error("同步BI两个月"+StatContant.CATEGORY_TYPE_MAP.get(category)+"中间表数据共耗时" + (end - begin) + "ms"); //写入跑批日志记录表 String deletesql = "delete from sys_stat_jobs_exe_detail sd where sd.dm_time = ? and sd.dm_type = ?"; Object args[] = new Object[]{1, StatContant.CATEGORY_TYPE_MAP.get(category)}; jdbcTemplate.update(deletesql, args); String insertsql = "insert into sys_stat_jobs_exe_detail values(?,?,?,?,?)"; int exectime = (int) (end - begin); Object args1[] = new Object[]{StatContant.CATEGORY_TYPE_MAP.get(category), "1", new Date(begin), new Date(end), exectime}; int count = jdbcTemplate.update(insertsql, args1); if (count > 0) { logger.error("插入跑批日志成功,插入类型" + StatContant.CATEGORY_TYPE_MAP.get(category) + "---" + "1"); } } } }

 

转载于:https://www.cnblogs.com/pypua/articles/9909456.html

你可能感兴趣的文章
MyEclipse部署Jboss出现java.lang.OutOfMemoryError: PermGen space
查看>>
ZOJ 1133
查看>>
alibaba / zeus 安装 图解
查看>>
Planned Delivery Time as Work Days (SCN discussion)
查看>>
Ubuntu:让桌面显示回收站
查看>>
Android上传头像代码,相机,相册,裁剪
查看>>
git 安装体验
查看>>
Oracle 给已创建的表增加自增长列
查看>>
《DSP using MATLAB》Problem 2.17
查看>>
if 循环
查看>>
uva 111 History Grading(lcs)
查看>>
Python学习week2-python介绍与pyenv安装
查看>>
php判断网页是否gzip压缩
查看>>
一个有意思的js实例,你会吗??[原创]
查看>>
sql server中bit字段实现取反操作
查看>>
Part3_lesson2---ARM指令分类学习
查看>>
jQuery拖拽原理实例
查看>>
JavaScript 技巧与高级特性
查看>>
Uva 11729 Commando War
查看>>
增强学习(一) ----- 基本概念
查看>>