提交 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;
/**
......
......@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论