提交 1414dcc2 authored 作者: ljj's avatar ljj

fix:fixbug

上级 82aa679b
......@@ -27,6 +27,7 @@ public class SwaggerConfig {
boolean flag = environment.acceptsProfiles(profiles);
return new Docket(DocumentationType.SWAGGER_2)
.enable(false)
.apiInfo(apiInfo())
.enable(flag)
.select()
......
package com.tykj.transfer.controller;
import com.tykj.transfer.slave_service.*;
import com.tykj.transfer.task.PushTask;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -32,6 +34,9 @@ public class transferController {
@Resource
private Biz088DcVolunteerStatisticsService biz088DcVolunteerStatisticsService;
@Autowired
private PushTask pushTask;
@GetMapping("/tranBranch")
@ApiOperation("网点数据转移")
public void tranBranch() {
......@@ -62,4 +67,9 @@ public class transferController {
public void transferVolunteer(){
biz088DcVolunteerStatisticsService.transferVolunteer();
}
@GetMapping("/pushNow")
public void pushNow() {
pushTask.task();
}
}
......@@ -23,5 +23,5 @@ public interface BranchesDao extends JpaRepository<Branches, Long> {
List<Branches> findAllByUpdatedAtAfter(Date date);
Branches findAllByName(String name);
List<Branches> findAllByName(String name);
}
package com.tykj.transfer.dao;
package com.tykj.transfer.local_dao;
import com.tykj.transfer.entity.RegionModelDo;
import com.tykj.transfer.local_entity.RegionModelDo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
import java.util.Optional;
/**
* @author Ozoz.L cnljj1995@gmail.com
......
package com.tykj.transfer.entity;
package com.tykj.transfer.local_entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;
import javax.persistence.Entity;
import javax.persistence.Id;
......
......@@ -21,8 +21,8 @@ public class YlBranchTrainStatistics {
* 主键
*/
@Id
@GenericGenerator(name = "idGenerator", strategy = "uuid")
@GeneratedValue(generator = "idGenerator")
// @GenericGenerator(name = "idGenerator", strategy = "uuid")
// @GeneratedValue(generator = "idGenerator")
@Column(name = "id",length = 64)
private String id;
/**
......
......@@ -20,8 +20,8 @@ public class YlTrainStatistics {
* 主键
*/
@Id
@GenericGenerator(name = "idGenerator", strategy = "uuid")
@GeneratedValue(generator = "idGenerator")
// @GenericGenerator(name = "idGenerator", strategy = "uuid")
// @GeneratedValue(generator = "idGenerator")
@Column(name = "id",length = 64)
private String id;
/**
......
......@@ -20,8 +20,8 @@ public class YlVolunteerStatistics {
* 主键
*/
@Id
@GenericGenerator(name = "idGenerator", strategy = "uuid")
@GeneratedValue(generator = "idGenerator")
// @GenericGenerator(name = "idGenerator", strategy = "uuid")
// @GeneratedValue(generator = "idGenerator")
@Column(name = "id",length = 64)
private String id;
/**
......
......@@ -25,8 +25,8 @@ public class Biz088DcBranchTrainStatistics {
* 主键
*/
@Id
@GenericGenerator(name = "idGenerator", strategy = "uuid")
@GeneratedValue(generator = "idGenerator")
// @GenericGenerator(name = "idGenerator", strategy = "uuid")
// @GeneratedValue(generator = "idGenerator")
@Column(name = "id",length = 64)
private String id;
/**
......
......@@ -25,8 +25,8 @@ public class Biz088DcTrainStatistics {
* 主键
*/
@Id
@GenericGenerator(name = "idGenerator", strategy = "uuid")
@GeneratedValue(generator = "idGenerator")
// @GenericGenerator(name = "idGenerator", strategy = "uuid")
// @GeneratedValue(generator = "idGenerator")
@Column(name = "id",length = 64)
private String id;
/**
......
......@@ -25,8 +25,8 @@ public class Biz088DcVolunteerStatistics {
* 主键
*/
@Id
@GenericGenerator(name = "idGenerator", strategy = "uuid")
@GeneratedValue(generator = "idGenerator")
// @GenericGenerator(name = "idGenerator", strategy = "uuid")
// @GeneratedValue(generator = "idGenerator")
@Column(name = "id",length = 64)
private String id;
/**
......
......@@ -39,12 +39,17 @@ public class Biz088DcActivityStatisticsServiceImpl implements Biz088DcActivitySt
@Resource
private YlActivityStatisticsDao ylActivityStatisticsDao;
@Override
@Transactional
// @Transactional
public void transferActivity() {
Date from = Date.from(LocalDateTime.now().minusWeeks(1L).toInstant(ZoneOffset.of("+8")));
List<Activity> all = activitiesDao.findAllByCreatedAtAfter(from);
// Date from = Date.from(LocalDateTime.now().minusWeeks(1L).toInstant(ZoneOffset.of("+8")));
// List<Activity> all = activitiesDao.findAllByCreatedAtAfter(from);
List<Activity> all = activitiesDao.findAll();
int total = all.size();
int i = 0;
Timestamp date = new Timestamp(new Date().getTime());
List<Biz088DcActivityStatistics> rs = new ArrayList<>();
for (Activity activity : all) {
......@@ -57,21 +62,41 @@ public class Biz088DcActivityStatisticsServiceImpl implements Biz088DcActivitySt
}
newObj.setTongTime(date);
newObj.setTongId(0L);
newObj.setIntroduction(filterEmojis(newObj.getIntroduction()));
try {
newObj.setIntroduction(filterEmojis(newObj.getIntroduction()));
} catch (Exception e) {
e.printStackTrace();
log.error("{}", e);
}
try {
// 过滤手机号
newObj.setLatitude(latLon(newObj.getLatitude()));
newObj.setLongitude(latLon(newObj.getLongitude()));
newObj.setContactPerson(replacePhone(newObj.getContactPerson()));
// newObj.setIntroduction(replacePhone(newObj.getIntroduction()));
newObj.setAdscriptionOrg(replacePhone(newObj.getAdscriptionOrg()));
biz088DcActivityStatisticsDao.save(newObj);
YlActivityStatistics ylActivityStatistics=new YlActivityStatistics();
BeanUtils.copyProperties(newObj,ylActivityStatistics);
YlActivityStatistics ylActivityStatistics = new YlActivityStatistics();
BeanUtils.copyProperties(newObj, ylActivityStatistics);
ylActivityStatisticsDao.save(ylActivityStatistics);
} catch (Exception e) {
log.error("{}", e.toString());
e.printStackTrace();
}
rs.add(newObj);
}
// biz088DcActivityStatisticsDao.saveAll(rs);
// 计数
i++;
if (i % 100 == 0) {
log.info("{}/{}", i, total);
}
log.info("活动转移完成:{}", rs.size());
}
log.info("活动转移完成");
}
public static String filterEmojis(String text) {
......@@ -89,4 +114,74 @@ public class Biz088DcActivityStatisticsServiceImpl implements Biz088DcActivitySt
}
public static boolean isNumericZidai(String str) {
for (int i = 0; i < str.length(); i++) {
System.out.println(str.charAt(i));
if (!Character.isDigit(str.charAt(i))) {
return false;
}
}
return true;
}
public static String findContinuousDigits(String input, int length) {
// 构建正则表达式,匹配连续的指定长度的数字
String regex = "\\d{" + length + "}";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);
if (matcher.find()) {
return matcher.group();
} else {
return null;
}
}
public static String replacePhone(String s) {
if (s == null) {
return "";
}
String continuousDigits = findContinuousDigits(s, 11);
if ( continuousDigits!= null) {
String replace = s.replace(continuousDigits, "");
log.info("替换情况:{} -> {}", s, replace);
return replace;
} else {
return s;
}
}
public static String latLon(String s) {
if (s ==null || !s.contains(".")) {
return "";
}
String[] split = s.split("\\.");
int length2 = split[1].length();
if (length2>6) {
String s1 = split[1];
String substring = s1.substring(0, 6);
String rs = split[0] + "." + substring;
log.info("经纬度替换:{}->{}", s, rs);
return rs;
}
return s;
}
public static void main(String[] args) {
System.out.println(findContinuousDigits(" \n" +
"<script>\n" +
" window.ENV = window.ggconfig = {\"waterFall\":\"YySoEF\",\"detailRecommend\":\"qsdVZV\",\"indexRecommend\":\"SV1siw\",\"detail_aside_gg_2\":\"2KQszu\",\"comment_bottom_gg\":\"dusOBv_1999227\",\"detail_aside_gg_3\":\"xW7yoY_2013341\",\"detail_aside_gg_4\":\"h0W0wW\",\"detail_aside_gg_1\":\"jDAIfk_2013324\",\"detail_comment_top_gg1\":\"DJGw7y\",\"detail_comment_top_gg\":\"J7pfVk\",\"home_aside_gg_3\":\"JucSwF\",\"home_aside_gg_2\":\"LcUX7A\",\"news24\":\"v24xz1\",\"detail_aside_gg_5\":\"V8VJcw\",\"comment_gg\":\"gHLkOR_2343083\",\"detail_content_top_gg\":\"GuKwSv_2064424\",\"detail_pic_gg\":\"\",\"btc\":\"SDYzsK\",\"new_home_waterFall\":\"JFE0mB\",\"new_home_news24\":\"Z28n1t\",\"new_home_indexRecommend\":\"8yLvE8\",\"new_home_aside_gg_2\":\"gsCJHA\",\"show_pic_gg\":false,\"waterfall_gg_n\":{\"detail\":{\"START\":0,\"STEP\":3},\"home\":{\"START\":2,\"STEP\":3},\"ndetail\":{\"START\":0,\"STEP\":[1,2]}},\"new_home\":true,\"webp\":false,\"new_detail_waterFall\":\"hHI0ZV\",\"new_detail_news24\":{\"id\":\"WPU6sr\",\"row\":8,\"col\":3,\"pos\":[2,4,6,8,10,12,14,16,18,20,22,24],\"style\":\"col3\"},\"relate_gg\":{\"id\":\"nnfNe7\",\"pos\":[1,3,5,7,9,11,13,15,17,19,21,23]},\"popup_gg\":\"oDRR2M\",\"content_title_gg\":\"Uzm2KI\",\"comment_bottom_js_gg\":\"\",\"detail_bottom_left_gg\":\"l4BNih_2343091\",\"detail_bottom_right_gg\":\"0bauCf_2343090\",\"ndetail\":true,\"content_bottom_one_js\":true,\"comment\":false,\"hide_relate_news\":false,\"news24_recommend_exchange_position\":true,\"detail_pic_gg_2\":\"\",\"btn_refresh_pos\":\"middle\",\"all_people_see_gg\":\"\",\"author_bottom_all_people_see\":false,\"bucket\":12,\"_eds_id_\":3649,\"popug_gg_bounceIn_style\":true,\"event_bg_wall_gg\":[{\"linkUrl\":\"https:\\/\\/s.click.taobao.com\\/t?e=m%3D2%26s%3DUDS9L5P90bgcQipKwQzePCperVdZeJviK7Vc7tFgwiFRAdhuF14FMaoY22eTiCR5J1gyddu7kN8D6MZ%2Bql29yIW%2FXPHWPSQpN2yQOQl2meVsJ4%2BKPUYCzJ3PLI70IiRVfkwHTg4TQaeOJ2XZVrYPybh9YVht%2FlWEjPobR%2B9Wl%2BoGUUcdOTOM78t2Q9%2B4hwiDxquIk%2Fg7%2BcMvIAIHRmVEk3aH9JtUKSe2bauJldkSeEBxKmPmpIKZsA%3D%3D\",\"grayImgUrl\":\"http:\\/\\/p0.qhimg.com\\/t01908aa4a3a716a40c.png\",\"colorImgUrl\":\"http:\\/\\/p0.qhimg.com\\/t017fa09b4836e2e5b7.png\",\"showTime\":{\"start\":{\"year\":2019,\"month\":5,\"date\":30},\"end\":{\"year\":2019,\"month\":6,\"date\":18}}}],\"resupdate_ssl_support\":true,\"tuji\":true,\"pure_tuji\":true,\"tuji_popup_carousel_gg\":\"\",\"exp_tuji_desc_bottom_rec_gg\":\"Rm7O8i_2353065\",\"tuji_barrage_gg\":\"aFHDvx\",\"exp_tuji_rec_gg\":\"ptHhA5\",\"tuji_wenzi_gg\":\"FB9fRZ\",\"exp_tuji_last_rec_gg\":\"P6J2Lq\",\"bg_wall_gg\":\"gtos8Q\",\"ndetail_tuji_switch\":false,\"popup\":\"\",\"tuji_popup_gg\":\"lsOkP2\",\"waterfall_insert_text_ad\":true,\"subscribe\":true,\"comic_bottom_left_gg\":\"HuEL5r_2360748\",\"comic_detail_waterFall\":{\"id\":\"rDthE4\",\"START\":1,\"STEP\":3},\"comic_bottom_right_gg\":\"CyqDDv_2360749\",\"author_card_ad\":false,\"hide_author_card\":true,\"article_info\":true,\"crypto\":true,\"cube_force_purphv\":\"QnCaKiS68Hn\\nQnCGdNvD3jd\",\"p2pvideo\":true,\"economic_channel_ad\":{\"start\":\"1603123200000\",\"end\":\"1603987200000\",\"img_src\":\"https:\\/\\/p0.ssl.img.360kuai.com\\/t0117de56eda8c11d66.jpg\",\"url\":\"https:\\/\\/c.ssp.360.cn\\/t?type=19&pub=1153552_899282_2380668&cus=0_0_0_20414_0&url=http%3A%2F%2Fwww.xafy.edu.cn%2F\"},\"videodetail_append_data\":true,\"detail_top_banner\":{\"start\":1603209600000,\"end\":1605110400000,\"img\":\"https:\\/\\/p4.ssl.img.360kuai.com\\/t013308206a2c408ae5.jpg\",\"url\":\"https:\\/\\/s.click.taobao.com\\/coIoJvu\"},\"detail_middle_bar_ad\":{\"start\":1603209600000,\"end\":1605110400000,\"bigimg\":\"https:\\/\\/p3.ssl.img.360kuai.com\\/t015a7be191b2a4fcd6.png\",\"bigimghover\":\"https:\\/\\/p1.ssl.img.360kuai.com\\/t0122fca7efa28ae2d3.png\",\"smallimg\":\"https:\\/\\/p3.ssl.img.360kuai.com\\/t0116ec621ae732e104.png\",\"smallimghover\":\"https:\\/\\/p2.ssl.img.360kuai.com\\/t019fb8ee4185653819.png\",\"bubble\":\"https:\\/\\/p5.ssl.img.360kuai.com\\/t01330defe20c248273.png\",\"url\":\"https:\\/\\/s.click.taobao.com\\/tbilHvu\"},\"tuji_black_sign\":\"360dh\\n360_0de6261f\\n360_8910f42c\\n360_2b4058b3\\n360_fc624efc\\n360_fcf5961b\\n360_3aa2b959\\n360_e39369d1\\n360_7bc3b157\\n360_57c3bbd1\\n360_6aa05217\\n360_df5d7b7e\\nbaike\\n360_1208a660\\n360_6d00629c\\n360_d838ecb6\\n360_79aabe15\\nlook \\n360_aa58bd32\\n360_a9931de8\\n360_46b9a0ef\\n360_684394a8\\n360%5F684394a8\\n360_cf71a426\\n360_edf2f6aa\\n360_205bc453\\n360_5469fded\\n360_802c86e3\\n360_e26c9522\\n360_a0ab86ec\\n360_08a937e6\\n360_fe17ca07\\npctab\\n360_2f7f67d4\\n360_d058a970\\n360_06f984f8\\n360_79cf27fd\\n360_0ed9f8f8\\n360_09801ce2\\n360_101b1016\\n360_21192782\\n360_de5bc722\\n360_b7497603\\n360_7513f821\\n360_e8841d4a\\n360_3fbc9d35\\n360_c58990f0\\n\\n\\n\",\"no_comment_qid\":[\"2779554476\"],\"pendant_interactive_gg\":\"\",\"detail_festival_skin\":{\"start\":\"1612368000000\",\"end\":\"1614355200000\",\"icon\":\"https:\\/\\/p2.ssl.img.360kuai.com\\/t0131e4ca6c78cfb2dd.png\",\"img\":\"https:\\/\\/p1.ssl.img.360kuai.com\\/t01c1dbbdef15181826.gif\"},\"nexttuji_leftflow_gg\":{\"id\":\"7nsMQI\",\"pos\":{\"START\":1,\"STEP\":3}},\"nexttuji_contentcard_lastpage_bgg\":\"YV1We2\",\"nexttuji_rightcontent_bottomgg\":{\"id\":\"fvbrHU\",\"pos\":{\"START\":1,\"STEP\":2}},\"wonderful_gallery\":false,\"preview_pic_mode\":true,\"detail_flow_related\":true,\"detail_video_relate_next\":true,\"detail_car_inquiry_modal\":true,\"attention_card\":4,\"detail_zmtlist_card\":true,\"event_fullscreen_modal_gg\":\"J6tceR\",\"footer_ad\":{\"frequency\":2,\"id\":\"vZQmw5\"},\"home_festival_page_body_bg_small\":\"https:\\/\\/p5.ssl.img.360kuai.com\\/t012c12e161c6f7a3e1.png\",\"home_festival_page_body_bg_small_new_version\":\"https:\\/\\/p3.ssl.img.360kuai.com\\/t010bbcb9418dbc760d.png\",\"home_festival_page_body_bg_color\":\"#b81b0c\",\"home_festival_page_body_bg_normal_new_version\":\"https:\\/\\/p1.ssl.img.360kuai.com\\/t01ff43bb12b76a42fa.png\",\"home_festival_page_body_bg_normal\":\"https:\\/\\/p0.ssl.img.360kuai.com\\/t01fafbd86ebaab1ea1.png\",\"home_festival_page_header_bg\":\"https:\\/\\/p1.ssl.img.360kuai.com\\/t018a647e7043b06a0e.png\",\"home_festival_end_time\":1625587200000,\"home_festival_start_time\":1624377600000,\"detail_tuji_attention_tooltip\":true,\"game_top_ad\":true,\"left_flow_refresh_topbar\":300,\"zmtkch_gg_step\":3,\"zmtkch_gg_start\":2,\"zmtkch_gg_showid\":\"kY3CU4\",\"article_bottom_gg\":\"\",\"flowIdleTime\":1,\"videodetail_relate_gg\":{\"id\":\"QdAYZ6\",\"pos\":{\"START\":2,\"STEP\":1}},\"new_detail_waterFall_searchad\":\"s3bfc48c999\",\"new_detail_waterfall_modal_gg\":\"61JoAM\",\"video_player_after_gg_countdown\":1060010,\"ndetail_right_aside_top_gg\":\"JIBGJ0_2350023\",\"video_player_after_gg_min_time\":180,\"article_text_gg\":{\"id\":\"P4Y89g\",\"pos\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]},\"video_player_pause_gg\":\"YHKAry\",\"detail_version\":3,\"videodetail_feed_gg\":{\"id\":\"ESN6ch\",\"pos\":{\"START\":\"0\",\"STEP\":\"3\"}},\"content_bottom_showcase_gg\":\"c2kbYM\",\"ndetail_article_right_aside\":true,\"ndetail_right_aside_content_gg\":\"uHYxUo\",\"article_share_bottom_showcase_gg\":\"N8rV9n\",\"video_player_after_gg\":\"u6bTCG\",\"hide_content_font_feature\":true,\"detail_follow_zmtlist\":true,\"sign\":\"360_57c3bbd1\"};\n" +
" if(window.ggconfig.hide_relate_news) {\n" +
" // 相关新闻不显示的话底部广告不显示\n" +
" window.ggconfig.detail_bottom_left_gg = '';\n" +
" window.ggconfig.detail_bottom_right_gg = '';\n" +
" }\n" +
"</script>", 11));
}
}
......@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
import com.tykj.transfer.dao.ActivitiesDao;
import com.tykj.transfer.dao.ActivityApplyDao;
import com.tykj.transfer.dao.BranchesDao;
import com.tykj.transfer.dao.RegionModelRepository;
import com.tykj.transfer.entity.Activity;
import com.tykj.transfer.entity.Branches;
import com.tykj.transfer.entity.vo.BranchesVo;
......@@ -16,17 +15,15 @@ import com.tykj.transfer.slave_dao.Biz088DcBranchTrainStatisticsDao;
import com.tykj.transfer.slave_service.Biz088DcBranchTrainStatisticsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import javax.xml.crypto.Data;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
@Slf4j
public class Biz088DcBranchTrainStatisticsImpl implements Biz088DcBranchTrainStatisticsService {
......@@ -48,25 +45,27 @@ public class Biz088DcBranchTrainStatisticsImpl implements Biz088DcBranchTrainSta
@Resource
private YlBranchTrainStatisticsDao ylBranchTrainStatisticsDao;
@Override
@Transactional
// @Transactional
public void transferBranchApply() {
String s = stringRedisTemplate.opsForValue().get("330000YlTotal");
PageVo pageVo = JSON.parseObject(String.valueOf(s), PageVo.class);
List<BranchesVo> branchesList = pageVo.getBranchesList();
List<Biz088DcBranchTrainStatistics> rs=new ArrayList<>();
List<YlBranchTrainStatistics> listVo=new ArrayList<>();
List<Biz088DcBranchTrainStatistics> rs = new ArrayList<>();
List<YlBranchTrainStatistics> listVo = new ArrayList<>();
Date date = new Date();
for (BranchesVo branchesVo : branchesList) {
Biz088DcBranchTrainStatistics VO = new Biz088DcBranchTrainStatistics();
YlBranchTrainStatistics ylBranchTrainStatistics=new YlBranchTrainStatistics();
YlBranchTrainStatistics ylBranchTrainStatistics = new YlBranchTrainStatistics();
VO.setBranchName(branchesVo.getName());
Branches allByName = branchesDao.findAllByName(branchesVo.getName());
Branches allByName = branchesDao.findAllByName(branchesVo.getName()).get(0);
VO.setId(allByName.getId() + "");
VO.setRegionCode(allByName.getArea());
List<Activity> allByBranchId = activitiesDao.findAllByBranchId(allByName.getId());
Long activityApplyCount=0L;
Long activityApplyCount = 0L;
for (Activity activity : allByBranchId) {
activityApplyCount+= activityApplyDao.getActivityApplyCount(activity.getId());
activityApplyCount += activityApplyDao.getActivityApplyCount(activity.getId());
}
VO.setTrainNum(String.valueOf(activityApplyCount));
VO.setUpdateTime(date);
......@@ -74,7 +73,7 @@ public class Biz088DcBranchTrainStatisticsImpl implements Biz088DcBranchTrainSta
VO.setLoadTime(date);
VO.setTongTime(date);
VO.setTongId(0L);
BeanUtils.copyProperties(VO,ylBranchTrainStatistics);
BeanUtils.copyProperties(VO, ylBranchTrainStatistics);
listVo.add(ylBranchTrainStatistics);
rs.add(VO);
}
......
......@@ -18,6 +18,8 @@ import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.tykj.transfer.slave_service.impl.Biz088DcActivityStatisticsServiceImpl.filterEmojis;
......@@ -33,32 +35,95 @@ public class Biz088DcNetworkStatisticsImpl implements Biz088DcNetworkStatisticsS
@Resource
private YlNetworkStatisticsDao ylNetworkStatisticsDao;
@Override
@Transactional
// @Transactional
public void transferBranch() {
List<Branches> all = branchesDao.findAll();
int total = all.size();
int i = 0;
Date date = new Date();
List<Biz088DcNetworkStatistics> rs = new ArrayList<>();
for (Branches branches : all) {
Biz088DcNetworkStatistics newObj = JSON.parseObject( JSON.toJSONString(branches), Biz088DcNetworkStatistics.class);
Biz088DcNetworkStatistics newObj = JSON.parseObject(JSON.toJSONString(branches), Biz088DcNetworkStatistics.class);
newObj.setBizTime(date);
newObj.setLoadTime(date);
if (!StringUtils.equals(branches.getDataActiveStatus(), "1")) {
newObj.setOp("delete");
}
newObj.setTongTime(date);
newObj.setAddress(filterEmojis(newObj.getAddress()));
try {
newObj.setAddress(filterEmojis(newObj.getAddress()));
} catch (Exception e) {
log.error("{}", e);
e.printStackTrace();
}
newObj.setTongId(0L);
try {
YlNetworkStatistics ylNetworkStatistics=new YlNetworkStatistics();
BeanUtils.copyProperties(newObj,ylNetworkStatistics);
YlNetworkStatistics ylNetworkStatistics = new YlNetworkStatistics();
BeanUtils.copyProperties(newObj, ylNetworkStatistics);
newObj.setName(replacePhone(newObj.getName()));
newObj.setContactPerson(replacePhone(newObj.getContactPerson()));
newObj.setLeaderName(replacePhone(newObj.getLeaderName()));
biz088DcNetworkStatisticsDao.save(newObj);
ylNetworkStatisticsDao.save(ylNetworkStatistics);
}catch (Exception e) {
} catch (Exception e) {
log.error("{}", e.toString());
log.error("jpa不成功+1");
}
rs.add(newObj);
//计数
i++;
if (i % 100 == 0) {
log.info("{}/{}", i / total);
}
}
log.info("网点转移完成,成功转移了{}条", rs.size());
log.info("网点转移完成");
}
public static boolean isNumericZidai(String str) {
for (int i = 0; i < str.length(); i++) {
System.out.println(str.charAt(i));
if (!Character.isDigit(str.charAt(i))) {
return false;
}
}
return true;
}
public static String replacePhone(String s) {
if (s == null) {
return "";
}
String continuousDigits = findContinuousDigits(s, 11);
if ( continuousDigits!= null) {
String replace = s.replace(continuousDigits, "");
log.info("替换情况:{} -> {}", s, replace);
return replace;
} else {
return s;
}
}
public static String findContinuousDigits(String input, int length) {
// 构建正则表达式,匹配连续的指定长度的数字
String regex = "\\d{" + length + "}";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);
if (matcher.find()) {
return matcher.group();
} else {
return null;
}
}
public static void main(String[] args) {
String str = "花园里15068682696";
System.out.println(findContinuousDigits(str, 11));
System.out.println(str.replaceAll(findContinuousDigits(str, 11), ""));
}
}
package com.tykj.transfer.slave_service.impl;
import com.alibaba.fastjson.JSON;
import com.tykj.transfer.dao.RegionModelRepository;
import com.tykj.transfer.entity.RegionModelDo;
import com.tykj.transfer.local_dao.RegionModelRepository;
import com.tykj.transfer.local_entity.RegionModelDo;
import com.tykj.transfer.entity.vo.PageVo;
import com.tykj.transfer.local_dao.YlTrainStatisticsDao;
import com.tykj.transfer.local_entity.YlBranchTrainStatistics;
import com.tykj.transfer.local_entity.YlTrainStatistics;
import com.tykj.transfer.pojo.Biz088DcTrainStatistics;
import com.tykj.transfer.slave_dao.Biz088DcBranchTrainStatisticsDao;
import com.tykj.transfer.slave_dao.Biz088DcTrainStatisticsDao;
import com.tykj.transfer.slave_service.Biz088DcTrainStatisticsService;
import lombok.extern.slf4j.Slf4j;
......@@ -39,7 +39,7 @@ public class Biz088DcTrainStatisticsImpl implements Biz088DcTrainStatisticsServi
private YlTrainStatisticsDao ylTrainStatisticsDao;
@Override
@Transactional
// @Transactional
public void transferTrain() {
// 先存储省级的培训人数信息
List<Biz088DcTrainStatistics> rs = new ArrayList<>();
......@@ -124,6 +124,12 @@ public class Biz088DcTrainStatisticsImpl implements Biz088DcTrainStatisticsServi
}
rs.add(provinceVo);
localList.add(localProvince);
for (Biz088DcTrainStatistics r : rs) {
r.setId(r.getRegionCode());
}
for (YlTrainStatistics ylTrainStatistics : localList) {
ylTrainStatistics.setId(ylTrainStatistics.getRegionCode());
}
biz088DcTrainStatisticsDao.saveAll(rs);
ylTrainStatisticsDao.saveAll(localList);
log.info("网点转移完成,成功转移了{}条", rs.size());
......
package com.tykj.transfer.slave_service.impl;
import com.alibaba.fastjson.JSON;
import com.tykj.transfer.dao.RegionModelRepository;
import com.tykj.transfer.entity.RegionModelDo;
import com.tykj.transfer.local_dao.RegionModelRepository;
import com.tykj.transfer.local_entity.RegionModelDo;
import com.tykj.transfer.entity.vo.PageVo;
import com.tykj.transfer.local_dao.YlVolunteerStatisticsDao;
import com.tykj.transfer.local_entity.YlTrainStatistics;
import com.tykj.transfer.local_entity.YlVolunteerStatistics;
import com.tykj.transfer.pojo.Biz088DcTrainStatistics;
import com.tykj.transfer.pojo.Biz088DcVolunteerStatistics;
import com.tykj.transfer.slave_dao.Biz088DcVolunteerStatisticsDao;
import com.tykj.transfer.slave_service.Biz088DcVolunteerStatisticsService;
......@@ -40,7 +39,7 @@ public class Biz088DcVolunteerStatisticsImpl implements Biz088DcVolunteerStatist
private YlVolunteerStatisticsDao ylVolunteerStatisticsDao;
@Override
@Transactional
// @Transactional
public void transferVolunteer() {
String s = stringRedisTemplate.opsForValue().get("330000YlTotal");
List<Biz088DcVolunteerStatistics> rs=new ArrayList<>();
......@@ -57,7 +56,6 @@ public class Biz088DcVolunteerStatisticsImpl implements Biz088DcVolunteerStatist
provinceVo.setWorkTypeNums(JSON.toJSONString(eduCount).replaceAll("\\{|}", ""));
provinceVo.setEducationTypeNums(JSON.toJSONString(workTypeCount).replaceAll("\\{|}", ""));
provinceVo.setUpdateTime(date);
provinceVo.setUpdateTime(date);
provinceVo.setBizTime(date);
provinceVo.setLoadTime(date);
provinceVo.setTongTime(date);
......@@ -112,6 +110,12 @@ public class Biz088DcVolunteerStatisticsImpl implements Biz088DcVolunteerStatist
rs.add(streetVo);
}
}
for (Biz088DcVolunteerStatistics r : rs) {
r.setId(r.getRegionCode());
}
for (YlVolunteerStatistics ylVolunteerStatistics : localList) {
ylVolunteerStatistics.setId(ylVolunteerStatistics.getRegionCode());
}
biz088DcVolunteerStatisticsDao.saveAll(rs);
ylVolunteerStatisticsDao.saveAll(localList);
log.info("志愿者人数转移完成,成功转移了{}条", rs.size());
......
package com.tykj.transfer.task;
import com.sun.media.jfxmedia.logging.Logger;
import com.tykj.transfer.slave_service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......
server.port=8866
spring.datasource.local.username=root
spring.datasource.local.password=root
spring.datasource.local.url=jdbc:mysql://127.0.0.1:3306/test?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.local.password=tykj@2022
spring.datasource.local.url=jdbc:mysql://192.168.100.232:3306/skx_hj?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.local.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.remote1.url = jdbc:mysql://192.168.100.232:3307/hp_kjgzzqz?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
spring.datasource.remote1.url = jdbc:mysql://192.168.100.232:3306/ylhd_share_0715?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
spring.datasource.remote1.username = root
#spring.datasource.remote1.password = root
spring.datasource.remote1.password = tykj@2022
......@@ -12,8 +12,8 @@ spring.datasource.remote1.driverClassName = com.mysql.cj.jdbc.Driver
spring.datasource.remote2.username=root
spring.datasource.remote2.password=root
spring.datasource.remote2.url=jdbc:mysql://127.0.0.1:3306/asd?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.remote2.password=tykj@2022
spring.datasource.remote2.url=jdbc:mysql://192.168.100.232:3306/bus_internal_activity?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.remote2.driver-class-name=com.mysql.cj.jdbc.Driver
spring.aop.proxy-target-class= true
......@@ -24,7 +24,7 @@ spring.jpa.show-sql=false
#172.30.30.89
spring.redis.host=192.168.100.233
spring.redis.host=192.168.100.232
spring.redis.password=
spring.redis.database=7
spring.redis.port=6379
......
server.port=8866
spring.datasource.local.username=root
spring.datasource.local.password=ljj123456
spring.datasource.local.url=jdbc:mysql://127.0.0.1:3306/test?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.local.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.remote1.url = jdbc:mysql://127.0.0.1:3306/ylhd_share?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
spring.datasource.remote1.username = root
#spring.datasource.remote1.password = root
spring.datasource.remote1.password = ljj123456
spring.datasource.remote1.driverClassName = com.mysql.cj.jdbc.Driver
spring.datasource.remote2.username=root
spring.datasource.remote2.password=ljj123456
spring.datasource.remote2.url=jdbc:mysql://127.0.0.1:3306/yl_pre?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.remote2.driver-class-name=com.mysql.cj.jdbc.Driver
spring.aop.proxy-target-class= true
spring.jpa.properties.hibernate.format_sql=true
spring.main.allow-bean-definition-overriding=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=false
#172.30.30.89
spring.redis.host=192.168.100.233
spring.redis.password=
spring.redis.database=7
spring.redis.port=6379
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.jedis.pool.max-active=8
## 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.jedis.pool.max-wait=-1
## 连接池中的最大空闲连接
spring.redis.jedis.pool.max-idle=20
## 连接池中的最小空闲连接
spring.redis.jedis.pool.min-idle=0
## 连接超时时间(毫秒)
spring.redis.timeout=5000
\ No newline at end of file
......@@ -3,25 +3,21 @@ server.port=8015
spring.datasource.local.username=skx_hj
spring.datasource.local.password=tB2vSEuQyKOq5grUm9Jj
spring.datasource.local.url=jdbc:mysql://59.202.45.192:3306/skx_hj?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=false
spring.datasource.local.driver-class-name=com.mysql.cj.jdbc.Driver.
spring.datasource.local.driver-class-name=com.mysql.cj.jdbc.Driver
# yl system db
spring.datasource.remote1.url=jdbc:mysql://10.145.221.243:3306/ylhd_share?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=false
spring.datasource.remote1.username=root
spring.datasource.remote1.password=root
spring.datasource.remote1.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.remote2.url=jdbc:mysql://172.30.30.86:3306/yl_pre?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=false
spring.datasource.remote2.url=jdbc:mysql://172.30.30.86:3306/bus_internal_activity?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=false
spring.datasource.remote2.username=mcjsuper
spring.datasource.remote2.password=mcj123
spring.datasource.remote2.driverClassName=com.mysql.cj.jdbc.Driver
spring.aop.proxy-target-class=true
spring.jpa.properties.hibernate.format_sql=true
spring.main.allow-bean-definition-overriding=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=false
#172.30.30.89
spring.redis.host=172.30.30.89
spring.redis.password=MlD8LPkb
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论