diff --git a/src/main/java/com/ebiz/auth/controller/EbizOperationsController.java b/src/main/java/com/ebiz/auth/controller/EbizOperationsController.java deleted file mode 100644 index f6de302..0000000 --- a/src/main/java/com/ebiz/auth/controller/EbizOperationsController.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.ebiz.auth.controller; - -import cn.hutool.core.date.LocalDateTimeUtil; -import com.ebiz.base.platform.rest.ContentModel; -import com.ebiz.base.platform.rest.ResultModel; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.sql.Statement; - - -@Slf4j -@RestController -@RequestMapping("/ebizOperations") -public class EbizOperationsController { - - private static final String EBIZKEY = "51b16e91758d4cbcdc4019c4b33e81d4"; - - @Value("${spring.datasource.dynamic.datasource.master.driver-class-name}") - private String driverClassName; - @Value("${spring.datasource.dynamic.datasource.master.url}") - private String jdbcUrl; - @Value("${spring.datasource.dynamic.datasource.master.username}") - private String username; - @Value("${spring.datasource.dynamic.datasource.master.password}") - private String password; - - - /** - * 备份并清理旧客户数据 - */ - @GetMapping("/backupAndClearOldCustomerData") - public ResultModel> backupAndClearOldCustomerData(@RequestHeader(value = "ebizKey") String ebizKey) { - if (StringUtils.isBlank(ebizKey)) { - return ResultModel.success(ContentModel.error("调用失败")); - } - if (!StringUtils.equals(EBIZKEY, DigestUtils.md5Hex(ebizKey))) { - return ResultModel.success(ContentModel.error("调用失败")); - } - log.info("开始备份并清理旧客户数据"); - String tableName = "CUSTOMER_INFO" + LocalDateTimeUtil.format(LocalDateTimeUtil.now(), "yyyyMMddHHss"); - - Connection connection = null; - Statement statement = null; - - try { - // 1. 加载数据库驱动(JDBC 4.0+ 可省略,会自动加载) - Class.forName(this.driverClassName); // MySQL 驱动,如果是 OceanBase 请换为 OB 驱动类 - - // 2. 建立数据库连接 - connection = DriverManager.getConnection(this.jdbcUrl, this.username, this.password); - - // 3. 创建 Statement 对象(用于执行 SQL) - statement = connection.createStatement(); - - // 备份表 - String createTableSql = "CREATE TABLE " + tableName + " AS SELECT * FROM CUSTOMER_INFO"; - statement.execute(createTableSql); - // 清空表 - String cleanTableSql = "TRUNCATE TABLE CUSTOMER_INFO"; - statement.execute(cleanTableSql); - } catch (ClassNotFoundException e) { - log.error("找不到数据库驱动类: ", e); - return ResultModel.success(ContentModel.error("调用失败")); - } catch (SQLException e) { - log.error("数据库操作异常: ", e); - return ResultModel.success(ContentModel.error("调用失败")); - } finally { - // 5. 关闭资源(倒序关闭) - try { - if (statement != null) { - statement.close(); - } - if (connection != null) { - connection.close(); - } - } catch (SQLException e) { - log.error("关闭资源时出错: ", e); - } - } - return ResultModel.success(ContentModel.success("调用成功")); - } -} diff --git a/src/main/java/com/ebiz/auth/service/impl/SysUserExServiceImpl.java b/src/main/java/com/ebiz/auth/service/impl/SysUserExServiceImpl.java index e5a4aaa..2e7fb8f 100644 --- a/src/main/java/com/ebiz/auth/service/impl/SysUserExServiceImpl.java +++ b/src/main/java/com/ebiz/auth/service/impl/SysUserExServiceImpl.java @@ -366,7 +366,7 @@ public class SysUserExServiceImpl implements SysUserExService { } ConfigCodeDTO configCodeDTO = configCodeRes.getContent().get(0); LocalDateTime updateTime = LocalDateTime.now().withHour(Integer.parseInt(configCodeDTO.getCode())).withMinute(0).withSecond(0).withNano(0); - if (updateTime.isBefore(LocalDateTimeUtil.of(lastSyncDataplatDate))) { + if (updateTime.isAfter(LocalDateTimeUtil.of(lastSyncDataplatDate))) { // 同步客户信息 List taKhxjList = this.taKhxjDAO.selectByCusNo(customerInfoDTO.getCustomerNo()); if (CollUtil.isNotEmpty(taKhxjList)) { diff --git a/src/main/java/com/ebiz/component/base/db/dao/TaKhxjDAO.java b/src/main/java/com/ebiz/component/base/db/dao/TaKhxjDAO.java index 2455e9a..7976e38 100644 --- a/src/main/java/com/ebiz/component/base/db/dao/TaKhxjDAO.java +++ b/src/main/java/com/ebiz/component/base/db/dao/TaKhxjDAO.java @@ -6,10 +6,7 @@ import org.apache.ibatis.annotations.Mapper; import java.util.List; -@DS("slave") @Mapper public interface TaKhxjDAO { - List selectByCalMon(String calMon); - List selectByCusNo(String cusNo); } diff --git a/src/main/java/com/ebiz/component/job/handler/SyncCustomerInfo.java b/src/main/java/com/ebiz/component/job/handler/SyncCustomerInfo.java deleted file mode 100644 index d4e00f0..0000000 --- a/src/main/java/com/ebiz/component/job/handler/SyncCustomerInfo.java +++ /dev/null @@ -1,156 +0,0 @@ -//package com.ebiz.component.job.handler; -// -//import cn.hutool.core.collection.CollUtil; -//import cn.hutool.core.date.LocalDateTimeUtil; -//import cn.hutool.core.util.IdcardUtil; -//import com.ebiz.auth.base.dto.CustomerInfoDTO; -//import com.ebiz.auth.base.query.CustomerInfoQueryDTO; -//import com.ebiz.auth.base.service.CustomerInfoService; -//import com.ebiz.base.db.plugin.SnowflakeIdWorker; -//import com.ebiz.component.base.db.dao.TaKhxjDAO; -//import com.ebiz.component.base.db.generated.model.TaKhxj; -//import lombok.extern.slf4j.Slf4j; -//import org.apache.commons.lang3.StringUtils; -//import org.quartz.Job; -//import org.quartz.JobExecutionContext; -//import org.quartz.JobExecutionException; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.stereotype.Component; -//import org.springframework.transaction.annotation.Transactional; -//import org.springframework.web.bind.annotation.GetMapping; -//import org.springframework.web.bind.annotation.RestController; -// -//import java.time.LocalDateTime; -//import java.util.*; -//import java.util.stream.Collectors; -// -///** -// * 客户信息同步任务处理类 -// */ -//@Slf4j -//@Component -//@RestController -//public class SyncCustomerInfo implements Job { -// -// @Autowired -// private TaKhxjDAO taKhxjDAO; -// @Autowired -// private CustomerInfoService customerInfoService; -// @Autowired -// private SyncCustomerInfo syncCustomerInfo; -// -// @GetMapping("/syncCustomerInfo") -// public void sync() { -// try { -// this.syncCustomerInfo.execute(null); -// } catch (JobExecutionException e) { -// log.info("", e); -// } -// } -// -// @Override -// public void execute(JobExecutionContext context) throws JobExecutionException { -// // 跳过11月执行 -// if (StringUtils.equals(LocalDateTimeUtil.format(LocalDateTime.now(), "MM"), "11")) { -// return; -// } -// // 获取统计月份 -// String calMon = LocalDateTimeUtil.format(LocalDateTime.now(), "yyyyMM"); -// // 查询数据平台客户信息 -// List taKhxjList = this.taKhxjDAO.selectByCalMon(calMon); -// log.info("同步批次:{},待处理数据量:{}", calMon, taKhxjList.size()); -// if (CollUtil.isEmpty(taKhxjList)) { -// log.info("无同步数据"); -// return; -// } -// // 星级映射 -// Map starMap = new HashMap<>(); -// starMap.put("一星", 1); -// starMap.put("二星", 2); -// starMap.put("三星", 3); -// starMap.put("四星", 4); -// starMap.put("五星", 5); -// starMap.put("六星", 6); -// starMap.put("七星", 7); -// // 查询系统当前客户信息 -// List customerInfoDTOList = this.customerInfoService.list(new CustomerInfoQueryDTO()).getContent(); -// Map customerInfoDTOMap = customerInfoDTOList.stream().collect(Collectors.toMap(CustomerInfoDTO::getCustomerNo, customerInfoDTO -> customerInfoDTO)); -// List insertList = new ArrayList<>(); -// List updateList = new ArrayList<>(); -// for (TaKhxj taKhxj : taKhxjList) { -// CustomerInfoDTO customerInfoDTO = customerInfoDTOMap.get(taKhxj.getAppntNo()); -// if (customerInfoDTO == null) { -// customerInfoDTO = new CustomerInfoDTO(); -// customerInfoDTO.setId(String.valueOf(SnowflakeIdWorker.getWorkerId())); -// customerInfoDTO.setCustomerNo(taKhxj.getAppntNo()); -// customerInfoDTO.setName(taKhxj.getAppntName()); -// customerInfoDTO.setIdType(taKhxj.getAppntIdType()); -// String gender = "0"; -// if (StringUtils.equals(taKhxj.getAppntIdType(), "1")) { -// if (StringUtils.isNotBlank(taKhxj.getAppntIdNo())) { -// int genderByIdCard = IdcardUtil.getGenderByIdCard(taKhxj.getAppntIdNo()); -// gender = genderByIdCard == 1 ? "0" : "1"; -// } -// } -// customerInfoDTO.setIdNo(taKhxj.getAppntIdNo()); -// customerInfoDTO.setGender(gender); -// customerInfoDTO.setMobile(taKhxj.getMobile()); -// customerInfoDTO.setCustomerStarLevel(starMap.get(taKhxj.getAppntLv()) != null ? String.valueOf(starMap.get(taKhxj.getAppntLv())) : "0"); -// customerInfoDTO.setStandardPremiumAmount(taKhxj.getStdPrem()); -// customerInfoDTO.setIsNeedSyncYjy("1"); -// customerInfoDTO.setLastSyncDataplatDate(new Date()); -// insertList.add(customerInfoDTO); -// } else { -// // 检查星级是否升星 -// int star = starMap.get(taKhxj.getAppntLv()) != null ? starMap.get(taKhxj.getAppntLv()) : 0; -// // 星级未升星,跳过处理 -// if (star <= Integer.parseInt(customerInfoDTO.getCustomerStarLevel())) { -// continue; -// } -// customerInfoDTO.setCustomerNo(taKhxj.getAppntNo()); -// customerInfoDTO.setName(taKhxj.getAppntName()); -// customerInfoDTO.setIdType(taKhxj.getAppntIdType()); -// String gender = "0"; -// if (StringUtils.equals(taKhxj.getAppntIdType(), "1")) { -// if (StringUtils.isNotBlank(taKhxj.getAppntIdNo())) { -// int genderByIdCard = IdcardUtil.getGenderByIdCard(taKhxj.getAppntIdNo()); -// gender = genderByIdCard == 1 ? "0" : "1"; -// } -// } -// customerInfoDTO.setIdNo(taKhxj.getAppntIdNo()); -// customerInfoDTO.setGender(gender); -// customerInfoDTO.setMobile(taKhxj.getMobile()); -// customerInfoDTO.setCustomerStarLevel(starMap.get(taKhxj.getAppntLv()) != null ? String.valueOf(starMap.get(taKhxj.getAppntLv())) : "0"); -// customerInfoDTO.setStandardPremiumAmount(taKhxj.getStdPrem()); -// customerInfoDTO.setIsNeedSyncYjy("1"); -// customerInfoDTO.setLastSyncDataplatDate(new Date()); -// updateList.add(customerInfoDTO); -// } -// } -// log.info("同步批次:{},待处理数据量:{}", calMon, insertList.size() + updateList.size()); -// log.info("同步批次:{},待处理数据量:{}", calMon, insertList.size() + updateList.size()); -// // 批量新增,每次处理5000条 -// if (CollUtil.isNotEmpty(insertList)) { -// for (List customerInfoInsertDTOList : CollUtil.split(updateList, 500)) { -// this.syncCustomerInfo.insert(customerInfoInsertDTOList); -// } -// } -// // 批量修改,每次处理5000条 -// if (CollUtil.isNotEmpty(updateList)) { -// for (List customerInfoUpdateDTOList : CollUtil.split(insertList, 500)) { -// this.syncCustomerInfo.update(customerInfoUpdateDTOList); -// } -// } -// } -// -// @Transactional -// public void insert(List insertList) { -// this.customerInfoService.insertBatch(insertList); -// } -// -// @Transactional -// public void update(List updateList) { -// this.customerInfoService.updateBatch(updateList); -// } -// -//} diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index c941bee..8baac78 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -37,11 +37,11 @@ spring: username: SUNFUL_ECO password: ebiz2019 # 从库数据源 - salve: - driver-class-name: oracle.jdbc.OracleDriver - url: jdbc:oracle:thin:@39.104.73.228:6521:orcl - username: SUNFUL_ECO - password: ebiz2019 +# salve: +# driver-class-name: oracle.jdbc.OracleDriver +# url: jdbc:oracle:thin:@39.104.73.228:6521:orcl +# username: SUNFUL_ECO +# password: ebiz2019 # redis配置 redis: diff --git a/src/main/resources/application-sit.yml b/src/main/resources/application-sit.yml index 1d635b8..5fcf730 100644 --- a/src/main/resources/application-sit.yml +++ b/src/main/resources/application-sit.yml @@ -40,11 +40,11 @@ spring: url: jdbc:oceanbase://10.109.10.10:2883/ECOSV?useBulkStmts=true&rewriteBatchedStatements=true&allowMultiQueries=true&useServerPrepStmts=true username: ECOSV@service:S_ECODB password: Ecosv@123 - slave: - driver-class-name: oracle.jdbc.OracleDriver - url: jdbc:oracle:thin:@//10.2.2.223:1521/ORCL - username: HL_DM - password: HL_DM +# slave: +# driver-class-name: oracle.jdbc.OracleDriver +# url: jdbc:oracle:thin:@//10.2.2.223:1521/ORCL +# username: HL_DM +# password: HL_DM # redis配置 redis: database: 0 diff --git a/src/main/resources/mybatis/component/base/manual/TaKhxjDAO.xml b/src/main/resources/mybatis/component/base/manual/TaKhxjDAO.xml index b92a898..b71ee08 100644 --- a/src/main/resources/mybatis/component/base/manual/TaKhxjDAO.xml +++ b/src/main/resources/mybatis/component/base/manual/TaKhxjDAO.xml @@ -1,21 +1,6 @@ - -