diff --git a/renren-admin/src/main/java/io/renren/modules/monitor/task/GetAndUpdateUserFromJhTask.java b/renren-admin/src/main/java/io/renren/modules/monitor/task/GetAndUpdateUserFromJhTask.java new file mode 100644 index 00000000..b7493da5 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/monitor/task/GetAndUpdateUserFromJhTask.java @@ -0,0 +1,28 @@ +package io.renren.modules.monitor.task; + +import io.renren.modules.job.task.ITask; +import io.renren.modules.monitor.service.MonitorService; +import io.renren.modules.sys.service.SysUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 定期从金宏网获取并增量修改用户信息,已存在的用户只修改 guid mobile ywMobile + * @author ytl + * @Date 2022/8/30 18:06 + **/ +@Component("getAndUpdateUserFromJhTask") +public class GetAndUpdateUserFromJhTask implements ITask { + @Autowired + private SysUserService userService; + + + @Override + public void run(String params) { + //先备份数据库表 sys_user + int i = userService.backSysUser(); + if(i == 0){ + userService.getUserInfoFromJH(); + } + } +} diff --git a/renren-admin/src/main/java/io/renren/modules/sys/controller/SysUserController.java b/renren-admin/src/main/java/io/renren/modules/sys/controller/SysUserController.java index 89d3ebc6..9f05ec46 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/controller/SysUserController.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/controller/SysUserController.java @@ -176,4 +176,12 @@ public class SysUserController { public Result getUserInfoFromJH() { return sysUserService.getUserInfoFromJH(); } + + @GetMapping("backSysUser") + public void backSysUser(){ + int i = sysUserService.backSysUser(); + if(i ==0){ + sysUserService.getUserInfoFromJH(); + } + } } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/sys/service/SysUserService.java b/renren-admin/src/main/java/io/renren/modules/sys/service/SysUserService.java index d1343513..a47214e8 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/service/SysUserService.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/service/SysUserService.java @@ -61,4 +61,6 @@ public interface SysUserService extends BaseService { Result getUserInfoFromJH(); + int backSysUser(); + } diff --git a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysUserServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysUserServiceImpl.java index 11c8afe0..d8560bf8 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysUserServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysUserServiceImpl.java @@ -62,6 +62,15 @@ public class SysUserServiceImpl extends BaseServiceImpl page(Map params) { //转换成like @@ -471,4 +480,38 @@ public class SysUserServiceImpl extends BaseServiceImpl /data/services/sys_user.sql"); + + //String newCmdLinux = " mysqldump -uroot -pw@CmM1mBVQkPhdrc -h15.72.183.91 -P3306 share_platform sys_user > /data/services/sys_user.sql"; + String newCmdLinux = strBuil.toString(); + String newCmdWin = " cmd /c mysqldump -uroot -proot -h127.0.0.1 -P3306 share_platform sys_user > D:\\sys_user.sql"; + try{ + if (property.indexOf("Linux") != -1) { + // linux + process = Runtime.getRuntime().exec(new String[]{"bash", "-c", newCmdLinux}); + } else { + // 本地win + process = Runtime.getRuntime().exec(newCmdWin); + } + //0 表示线程正常终止。 + //if (process.waitFor() == 0) {} + result = process.waitFor(); + }catch (Exception e){ + e.printStackTrace(); + }finally { + return result; + } + } }