Merge branch 'refs/heads/dev'

# Conflicts:
#	src/main/resources/application-prod.yml
This commit is contained in:
郭诚奇
2025-11-06 18:24:49 +08:00
7 changed files with 11 additions and 277 deletions

View File

@@ -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<ContentModel<String>> 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("调用成功"));
}
}

View File

@@ -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<TaKhxj> taKhxjList = this.taKhxjDAO.selectByCusNo(customerInfoDTO.getCustomerNo());
if (CollUtil.isNotEmpty(taKhxjList)) {

View File

@@ -6,10 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@DS("slave")
@Mapper
public interface TaKhxjDAO {
List<TaKhxj> selectByCalMon(String calMon);
List<TaKhxj> selectByCusNo(String cusNo);
}

View File

@@ -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<TaKhxj> taKhxjList = this.taKhxjDAO.selectByCalMon(calMon);
// log.info("同步批次:{},待处理数据量:{}", calMon, taKhxjList.size());
// if (CollUtil.isEmpty(taKhxjList)) {
// log.info("无同步数据");
// return;
// }
// // 星级映射
// Map<String, Integer> 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<CustomerInfoDTO> customerInfoDTOList = this.customerInfoService.list(new CustomerInfoQueryDTO()).getContent();
// Map<String, CustomerInfoDTO> customerInfoDTOMap = customerInfoDTOList.stream().collect(Collectors.toMap(CustomerInfoDTO::getCustomerNo, customerInfoDTO -> customerInfoDTO));
// List<CustomerInfoDTO> insertList = new ArrayList<>();
// List<CustomerInfoDTO> 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<CustomerInfoDTO> customerInfoInsertDTOList : CollUtil.split(updateList, 500)) {
// this.syncCustomerInfo.insert(customerInfoInsertDTOList);
// }
// }
// // 批量修改每次处理5000条
// if (CollUtil.isNotEmpty(updateList)) {
// for (List<CustomerInfoDTO> customerInfoUpdateDTOList : CollUtil.split(insertList, 500)) {
// this.syncCustomerInfo.update(customerInfoUpdateDTOList);
// }
// }
// }
//
// @Transactional
// public void insert(List<CustomerInfoDTO> insertList) {
// this.customerInfoService.insertBatch(insertList);
// }
//
// @Transactional
// public void update(List<CustomerInfoDTO> updateList) {
// this.customerInfoService.updateBatch(updateList);
// }
//
//}

View File

@@ -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:

View File

@@ -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

View File

@@ -1,21 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ebiz.component.base.db.dao.TaKhxjDAO">
<select id="selectByCalMon" resultType="com.ebiz.component.base.db.generated.model.TaKhxj">
select
CAL_MON as calMon,
APPNTNO as appntNo,
APPNTNAME as appntName,
APPNTIDTYPE as appntIdType,
APPNTIDNO as appntIdNo,
APPNTLV as appntLv,
STD_PREM as stdPrem,
MOBILE as mobile,
MODIFYDATE as modifyDate
from TA_KHXJ
where CAL_MON = #{calMon}
</select>
<select id="selectByCusNo" resultType="com.ebiz.component.base.db.generated.model.TaKhxj">
select
CAL_MON as calMon,