资源服务代码提交

master
yqy 3 years ago
parent 88d66726c4
commit e8d45b648f

@ -24,12 +24,61 @@
<artifactId>ad-platform-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.baiye</groupId>
<artifactId>ad-platform-pojo</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- easyExcel依赖-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.2.7</version>
</dependency>
<!-- hutool依赖包-->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.4.7</version>
</dependency>
<!-- druid数据源驱动 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<!-- Mysql依赖包-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- 注册中心客户端-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- feign 依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- mapstruct 依赖-->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

@ -1,18 +1,25 @@
package com.baiye;
import com.baiye.util.SpringContextHolder;
import com.spring4all.swagger.EnableSwagger2Doc;
import org.mapstruct.Mapper;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;
/**
* @author q
* @author YQY
*/
@EnableSwagger2Doc
@SpringBootApplication
@EnableAsync
@EnableJpaAuditing
@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@EnableSwagger2Doc
public class AdPlatformSourceApplication {
public static void main(String[] args) {
SpringApplication.run(AdPlatformSourceApplication.class, args);

@ -0,0 +1,53 @@
package com.baiye.config;
import cn.hutool.core.thread.NamedThreadFactory;
import org.apache.tomcat.util.threads.ThreadPoolExecutor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;
/**
* 线,线
*/
@Configuration
@EnableAsync
public class ThreadPoolConfig {
/**
* 线
*/
//常驻线程数量
@Value(value = "${save.task.thread_pool.corePoolSize}")
private int saveCorePoolSize = 4;
//最大线程数量
@Value(value = "${save.task.thread_pool.maxPoolSize}")
private int saveMaxPoolSize = 32;
//阻塞队列数量
@Value(value = "${save.task.thread_pool.queueCapacity}")
private int saveQueueCapacity = 100;
//线程名称前缀
@Value(value = "${save.task.thread_pool.ThreadNamePrefix}")
private String saveThreadNamePrefix = "SourceSaveFileTaskExecutor-";
@Bean(value = "SendBigDataTaskExecutor")
public Executor SendBigDataTaskExecutor(){
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
saveCorePoolSize,
saveMaxPoolSize,
3,
TimeUnit.SECONDS,
new LinkedBlockingDeque<>(saveQueueCapacity),
new NamedThreadFactory(saveThreadNamePrefix, false),
new ThreadPoolExecutor.DiscardOldestPolicy()
);
return threadPoolExecutor;
}
}

@ -1,19 +0,0 @@
package com.baiye.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author Enzo
* @date : 2021/12/16
*/
@RequestMapping("/test")
@RestController
public class TestController {
@GetMapping
public String helloWorld(){
return "Hello Source";
}
}

@ -0,0 +1,22 @@
package com.baiye.feign;
import com.baiye.feign.fallback.TaskClientFallback;
import com.baiye.module.entity.Task;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(value = "ad-platform-management",fallback = TaskClientFallback.class)
public interface TaskClient {
String PAY_PREFIX = "/api/task";
/**
*
* @param task
* @return
*/
@PostMapping(value = PAY_PREFIX + "/saveTask")
ResponseEntity<Object> saveTask(@RequestBody Task task);
}

@ -0,0 +1,14 @@
package com.baiye.feign.fallback;
import com.baiye.feign.TaskClient;
import com.baiye.module.entity.Task;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
@Component
public class TaskClientFallback implements TaskClient {
@Override
public ResponseEntity<Object> saveTask(Task task) {
return null;
}
}

@ -0,0 +1,74 @@
package com.baiye.module.constant;
/**
* @author
*
*/
public class FileConstant {
/**
* 0()
*/
public static final int ZERO_NUMBER = 0;
/**
* 1(UC)
*/
public static final int ONE_NUMBER = 1;
/**
* 2()
*/
public static final int TWO_NUMBER = 2;
/**
* 3()
*/
public static final int THREE_NUMBER = 3;
/**
* 4()
*/
public static final int FOUR_NUMBER = 4;
/**
* 5
*/
public static final int FIVE_NUMBER = 5;
/**
* 6
*/
public static final int SIX_NUMBER = 6;
/**
* 1000
*/
public static final int ONE_THOUSAND_NUMBER = 1000;
/**
* 1000000
*/
public static final int ONE_MILLION_NUMBER = 1000000;
/**
* uc
*/
public static final String UC = "uc";
/**
*
*/
public static final String KS = "ks";
/**
*
*/
public static final String DY = "dy";
/**
*
*/
public static final String QT = "qt";
}

@ -0,0 +1,78 @@
package com.baiye.module.controller;
import com.baiye.http.CommonResponse;
import com.baiye.http.ResponseCode;
import com.baiye.model.dto.ClueQueryCriteria;
import com.baiye.model.dto.DistributeResponseDTO;
import com.baiye.module.entity.Clue;
import com.baiye.module.service.ClueService;
import com.baiye.module.service.dto.ClueRecordCriteria;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@RequiredArgsConstructor
@RestController
@Api(tags = "资源管理")
@RequestMapping("/source/clue")
@Slf4j
public class ClueController {
private final ClueService clueService;
@ApiOperation("任务id查询资源列表")
@GetMapping("/queryList")
public ResponseEntity<List<Clue>> queryList(@RequestParam("taskId") Long taskId){
if (taskId != null){
return new ResponseEntity<>(clueService.queryList(taskId), HttpStatus.OK);
}
return new ResponseEntity<>(HttpStatus.OK);
}
@ApiOperation("查询资源记录列表")
@GetMapping("/queryRecordList")
public ResponseEntity<Object> queryRecordList(ClueRecordCriteria clueRecordCriteria, Pageable pageable){
return new ResponseEntity<>(clueService.queryRecordList(clueRecordCriteria,pageable), HttpStatus.OK);
}
@ApiOperation("批量更新组信息")
@PostMapping("/batchUpdateOrganize")
public ResponseEntity<Object> batchUpdateOrganize(@RequestBody DistributeResponseDTO distributeResponseDTO){
if (distributeResponseDTO != null){
clueService.batchUpdateOrganize(distributeResponseDTO);
}
return new ResponseEntity<>(CommonResponse.createBySuccess(ResponseCode.EMPTY_ARGUMENT), HttpStatus.OK);
}
@ApiOperation("小组id查询")
@GetMapping("/queryOrganizeIdList")
public ResponseEntity<List<Clue>> queryOrganizeIdList(@RequestParam("organizeId") Long organizeId){
if (organizeId != null){
return new ResponseEntity<>(clueService.queryOrganizeIdList(organizeId), HttpStatus.OK);
}
return new ResponseEntity<>(HttpStatus.OK);
}
@ApiOperation("批量更新组员信息")
@PostMapping("/batchUpdateUserId")
public ResponseEntity<Object> batchUpdateUserId(@RequestBody List<Map<Long, List<Long>>> mapList){
if ( mapList.size() > 0){
clueService.batchUpdateUserId(mapList);
}
return new ResponseEntity<>(CommonResponse.createBySuccess(ResponseCode.EMPTY_ARGUMENT), HttpStatus.OK);
}
@ApiOperation("分页查询资源信息")
@PostMapping("/queryAll")
public ResponseEntity<Map<String,Object>> queryAll(@RequestBody ClueQueryCriteria clueQueryCriteria){
return new ResponseEntity<>(clueService.queryAll(clueQueryCriteria),HttpStatus.OK);
}
}

@ -0,0 +1,51 @@
package com.baiye.module.controller;
import com.baiye.http.CommonResponse;
import com.baiye.http.ResponseCode;
import com.baiye.module.service.UploadFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@RequiredArgsConstructor
@RestController
@Api(tags = "文件上传管理")
@RequestMapping("/source/uploadFile")
@Slf4j
public class UploadFileController {
private final UploadFileService uploadFileService;
@Value("${storage.download-template}")
private String rootPath;
/**
*
*
*/
@ApiOperation("文件上传")
@PostMapping("/fileUpload")
public ResponseEntity<Object> singleFileUpload(@RequestParam("file") MultipartFile[] file,
@RequestParam(value = "uploadType") Integer uploadType,
@RequestParam(value = "userId") Long userId) {
if (file.length > 0 && uploadType != null && userId != null){
return uploadFileService.singleFileUpload(file,uploadType,userId);
}
return new ResponseEntity<>(CommonResponse.createBySuccess(ResponseCode.EMPTY_ARGUMENT.getDesc()), HttpStatus.OK);
}
@ApiOperation("模板下载")
@PostMapping("/downLoadTemplate")
public ResponseEntity<Object> downloadFileAction() {
return new ResponseEntity<>(rootPath, HttpStatus.OK);
}
}

@ -0,0 +1,19 @@
package com.baiye.module.dao;
import com.baiye.module.entity.ClueRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ClueRecordRepository extends JpaRepository<ClueRecord, Long>, JpaSpecificationExecutor<ClueRecord> {
/**
* id
* @param taskId
* @return
*/
List<ClueRecord> findByTaskId(Long taskId);
}

@ -0,0 +1,46 @@
package com.baiye.module.dao;
import com.baiye.module.entity.Clue;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ClueRepository extends JpaRepository<Clue, Long>, JpaSpecificationExecutor<Clue> {
/**
* recordId
* @param recordId
* @return
*/
List<Clue> findByRecordId(Long recordId);
/**
*
* @param id
* @param deptId
*/
@Modifying
@Query(value = " update tb_clue set organize_id = ?2 where id = ?1 ",nativeQuery = true)
void updateOrganizeIdById(Long id,Long deptId);
/**
* id
* @param organizeId
* @return
*/
List<Clue> findByOrganizeId(Long organizeId);
/**
*
* @param clueId
* @param userId
*/
@Modifying
@Query(value = " update tb_clue set member_id = ?3,member_status = ?2 where id = ?1 ",nativeQuery = true)
void updateUserId(Long clueId, Integer memberStatus,Long userId);
}

@ -0,0 +1,32 @@
package com.baiye.module.entity;
import com.baiye.model.entity.ClueBase;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.*;
import lombok.Data;
/**
* Clue
*
* @author yqy
* @date 2021-12-07 10:40:37
*/
@Data
@Entity
@Table(name = "tb_clue")
@ApiModel(value = "Clue")
public class Clue extends ClueBase {
/**
* 线id
* nullable : false
* default : null
*/
@Id
@ApiModelProperty(value = "线索表主键id自动递增")
@Column(name = "id", nullable = true)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
}

@ -0,0 +1,111 @@
package com.baiye.module.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.io.Serializable;
import java.util.Date;
/**
* ClueRecord
*
* @author yqy
* @date 2021-12-07 10:40:53
*/
@Setter
@Getter
@Entity
@Table(name = "tb_clue_record")
@ApiModel(value = "ClueRecord")
@EntityListeners(AuditingEntityListener.class)
public class ClueRecord implements Serializable {
private static final long serialVersionUID = 1271571231859316736L;
/**
* ID
* nullable : false
* default : null
*/
@Id
@Column(name = "id", nullable = false)
private Long id;
/**
* 0: 1: (0)
* nullable : true
* default : 0
*/
@ApiModelProperty(value = "上传状态 0:上传成功 1:上传失败 (默认0)")
@Column(name = "status", nullable = true, length = 1)
private Boolean status;
/**
* 0: 1:UC 2: 3: 4:
* nullable : true
* default : null
*/
@ApiModelProperty(value = "上传类型 0:自定义模板 1:UC 2:快手 3:抖音 4:百度")
@Column(name = "upload_type", nullable = true)
private Integer uploadType;
/**
* id
* nullable : false
* default : null
*/
@ApiModelProperty(value = "任务id")
@Column(name = "task_id", nullable = true)
private Long taskId;
/**
*
* nullable : true
* default : null
*/
@ApiModelProperty(value = "上传文件名")
@Column(name = "old_file", nullable = true, length = 255)
private String oldFile;
/**
*
* nullable : true
* default : null
*/
@ApiModelProperty(value = "存入路径")
@Column(name = "new_file_url", nullable = true, length = 255)
private String newFileUrl;
/**
*
* nullable : true
* default : null
*/
@ApiModelProperty(value = "创建人")
@Column(name = "create_by", nullable = true)
private Long createBy;
/**
*
* nullable : true
* default : null
*/
@ApiModelProperty(value = "创建时间")
@Column(name = "create_time", nullable = true)
@CreationTimestamp
private Date createTime;
/**
*
* nullable : true
* default : null
*/
@ApiModelProperty(value = "备注")
@Column(name = "remark", nullable = true, length = 500)
private String remark;
}

@ -0,0 +1,25 @@
package com.baiye.module.entity;
import com.baiye.model.entity.TaskBase;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.*;
@Data
@Entity
@Table(name = "tb_task")
@ApiModel(value = "Task")
public class Task extends TaskBase {
/**
* ID
* nullable : false
* default : null
*/
@Id
@ApiModelProperty(value = "任务表主键ID")
@Column(name = "id", nullable = true)
private Long id;
}

@ -0,0 +1,24 @@
package com.baiye.module.entity.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BaseExcelVo {
@ApiModelProperty(value = "记录表id")
private Long clueRecordId;
@ApiModelProperty(value = "用户id")
private Long userId;
@ApiModelProperty(value = "数据来源类型")
private Integer origin;
@ApiModelProperty(value = "任务id")
private Long taskId;
}

@ -0,0 +1,44 @@
package com.baiye.module.entity.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "快手表")
@ToString
public class KsVo {
@ExcelProperty(value = "姓名", index = 3)
@ApiModelProperty(value = "姓名")
private String name;
@ExcelProperty(value = "电话", index = 4)
@ApiModelProperty(value = "nid")
private String nid;
@ExcelProperty(value = "微信", index = 5)
@ApiModelProperty(value = "微信")
private String wx;
@ExcelProperty(value = "收集日期", index = 11)
@ApiModelProperty(value = "线索获取时间")
private Date collectTime;
@ExcelProperty(value = "线索归属地", index = 24)
@ApiModelProperty(value = "线索归属地")
private String address;
@ExcelProperty(value = "金额", index = 32)
@ApiModelProperty(value = "金额")
private String amount;
}

@ -0,0 +1,35 @@
package com.baiye.module.entity.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "UC表")
@ToString
public class UcVo{
@ExcelProperty(value = "时间", index = 2)
@ApiModelProperty(value = "线索获取时间")
private Date collectTime;
@ExcelProperty(value = "第一行", index = 3)
@ApiModelProperty(value = "姓名")
private String name;
@ExcelProperty(value = "第二行", index = 4)
@ApiModelProperty(value = "nid")
private String nid;
@ExcelProperty(value = "第三行", index = 5)
@ApiModelProperty(value = "金额")
private String amount;
}

@ -0,0 +1,44 @@
package com.baiye.module.entity.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "自定义表")
@ToString
public class ZdyVo {
@ExcelProperty(value = "姓名", index = 0)
@ApiModelProperty(value = "姓名")
private String name;
@ExcelProperty(value = "电话", index = 1)
@ApiModelProperty(value = "nid")
private String nid;
@ExcelProperty(value = "微信", index = 2)
@ApiModelProperty(value = "微信")
private String wx;
@ExcelProperty(value = "金额", index = 3)
@ApiModelProperty(value = "金额")
private String amount;
@ExcelProperty(value = "日期", index = 4)
@ApiModelProperty(value = "线索获取时间")
private Date collectTime;
@ExcelProperty(value = "线索归属地", index = 5)
@ApiModelProperty(value = "线索归属地")
private String address;
}

@ -0,0 +1,80 @@
package com.baiye.module.listener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.module.constant.FileConstant;
import com.baiye.module.entity.Clue;
import com.baiye.module.entity.vo.BaseExcelVo;
import com.baiye.module.entity.vo.KsVo;
import com.baiye.module.service.ClueService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import java.util.ArrayList;
import java.util.List;
@Slf4j
public class KsExcelListener extends AnalysisEventListener<KsVo> {
public final List<KsVo> rows = new ArrayList<>();
private BaseExcelVo baseExcelVo;
/**
* springservice
*/
private static ClueService clueService;
public KsExcelListener(ClueService clueService, BaseExcelVo baseExcelVo) {
this.clueService = clueService;
this.baseExcelVo = baseExcelVo;
}
/**
* 1000
* @param ksVo
* @param analysisContext
*/
@Override
public void invoke(KsVo ksVo, AnalysisContext analysisContext) {
rows.add(ksVo);
if (rows.size() >= FileConstant.ONE_THOUSAND_NUMBER){
saveData();
rows.clear();
}
}
/**
*
* @param analysisContext
*/
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
saveData();
rows.clear();
}
/**
*
*/
private void saveData(){
List<Clue> clues = new ArrayList<>();
for (KsVo row : rows) {
Clue clue = new Clue();
BeanUtils.copyProperties(row,clue);
// clue.setName(row.getName());
// clue.setNid(row.getNid());
// clue.setWx(row.getWx());
// clue.setAmount(row.getAmount());
// clue.setCollectTime(row.getCollectTime());
// clue.setAddress(row.getAddress());
clue.setOrigin(baseExcelVo.getOrigin());
clue.setRecordId(baseExcelVo.getClueRecordId());
clue.setCreateBy(baseExcelVo.getUserId());
clue.setMemberStatus(DefaultNumberConstants.ZERO_NUMBER);
clues.add(clue);
}
if (clues.size() > 0) {
clueService.saveClue(clues);
}
}
}

@ -0,0 +1,71 @@
package com.baiye.module.listener;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.text.csv.CsvData;
import cn.hutool.core.text.csv.CsvReader;
import cn.hutool.core.text.csv.CsvRow;
import cn.hutool.core.text.csv.CsvUtil;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.module.constant.FileConstant;
import com.baiye.module.entity.Clue;
import com.baiye.module.entity.vo.BaseExcelVo;
import com.baiye.module.service.ClueService;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
public class UcCsvListener {
private final List<Clue> clues = new ArrayList<>();
private BaseExcelVo baseExcelVo;
/**
* springservice
*/
private static ClueService clueService;
public UcCsvListener(ClueService clueService, BaseExcelVo baseExcelVo) {
this.clueService = clueService;
this.baseExcelVo = baseExcelVo;
}
/**
* UCcsv
* @param filePath
*/
public void readUcCsv(String filePath){
CsvReader reader = CsvUtil.getReader();
//从文件中读取CSV数据编码要gbk解决乱码
CsvData data = reader.read(FileUtil.file(filePath), Charset.forName("gbk"));
List<CsvRow> rows = data.getRows();
//遍历行
int index = 0;
for (CsvRow csvRow : rows) {
//判断去除表头
if (index != 0){
//getRawList返回一个List列表列表的每一项为CSV中的一个单元格既逗号分隔部分
Clue clue = new Clue();
clue.setName(csvRow.getRawList().get(3));
clue.setNid(csvRow.getRawList().get(4));
clue.setAmount(csvRow.getRawList().get(5));
clue.setCollectTime(DateUtil.parse(csvRow.getRawList().get(2)));
clue.setOrigin(baseExcelVo.getOrigin());
clue.setRecordId(baseExcelVo.getClueRecordId());
clue.setCreateBy(baseExcelVo.getUserId());
clue.setMemberStatus(DefaultNumberConstants.ZERO_NUMBER);
clues.add(clue);
}
//1000条插入一次
if (clues.size() > FileConstant.ONE_THOUSAND_NUMBER){
// if (clues.size() > 2){
clueService.saveClue(clues);
clues.clear();
}
index++;
}
//清除集合数据
if (clues.size() > 0) {
clueService.saveClue(clues);
}
}
}

@ -0,0 +1,75 @@
package com.baiye.module.listener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.module.constant.FileConstant;
import com.baiye.module.entity.Clue;
import com.baiye.module.entity.vo.BaseExcelVo;
import com.baiye.module.entity.vo.UcVo;
import com.baiye.module.service.ClueService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import java.util.ArrayList;
import java.util.List;
@Slf4j
public class UcExcelListener extends AnalysisEventListener<UcVo> {
private final List<UcVo> rows = new ArrayList<>();
private BaseExcelVo baseExcelVo;
/**
* springservice
*/
private static ClueService clueService;
public UcExcelListener(ClueService clueService, BaseExcelVo baseExcelVo) {
this.clueService = clueService;
this.baseExcelVo = baseExcelVo;
}
/**
* 1000
* @param ucVo
* @param analysisContext
*/
@Override
public void invoke(UcVo ucVo, AnalysisContext analysisContext) {
rows.add(ucVo);
if (rows.size() >= FileConstant.ONE_THOUSAND_NUMBER){
saveData();
rows.clear();
}
}
/**
*
* @param analysisContext
*/
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
saveData();
rows.clear();
}
private void saveData(){
List<Clue> clues = new ArrayList<>();
for (UcVo row : rows) {
Clue clue = new Clue();
// clue.setName(row.getName());
// clue.setNid(row.getNid());
// clue.setAmount(row.getAmount());
// clue.setCollectTime(row.getCollectTime());
BeanUtils.copyProperties(row,clue);
clue.setOrigin(baseExcelVo.getOrigin());
clue.setRecordId(baseExcelVo.getClueRecordId());
clue.setCreateBy(baseExcelVo.getUserId());
clue.setMemberStatus(DefaultNumberConstants.ZERO_NUMBER);
clues.add(clue);
}
if (clues.size() > 0) {
clueService.saveClue(clues);
}
}
}

@ -0,0 +1,79 @@
package com.baiye.module.listener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.module.constant.FileConstant;
import com.baiye.module.entity.Clue;
import com.baiye.module.entity.vo.BaseExcelVo;
import com.baiye.module.entity.vo.ZdyVo;
import com.baiye.module.service.ClueService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import java.util.ArrayList;
import java.util.List;
@Slf4j
public class ZdyExcelListener extends AnalysisEventListener<ZdyVo> {
public final List<ZdyVo> rows = new ArrayList<>();
private BaseExcelVo baseExcelVo;
/**
* springservice
*/
private static ClueService clueService;
public ZdyExcelListener(ClueService clueService, BaseExcelVo baseExcelVo) {
this.clueService = clueService;
this.baseExcelVo = baseExcelVo;
}
/**
* 1000
* @param zdyVo
* @param analysisContext
*/
@Override
public void invoke(ZdyVo zdyVo, AnalysisContext analysisContext) {
rows.add(zdyVo);
if (rows.size() >= FileConstant.ONE_THOUSAND_NUMBER){
saveData();
rows.clear();
}
}
/**
*
* @param analysisContext
*/
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
saveData();
rows.clear();
}
/**
*
*/
private void saveData(){
List<Clue> clues = new ArrayList<>();
for (ZdyVo row : rows) {
Clue clue = new Clue();
BeanUtils.copyProperties(row,clue);
// clue.setName(row.getName());
// clue.setNid(row.getNid());
// clue.setWx(row.getWx());
// clue.setAmount(row.getAmount());
// clue.setCollectTime(row.getCollectTime());
// clue.setAddress(row.getAddress());
clue.setOrigin(baseExcelVo.getOrigin());
clue.setRecordId(baseExcelVo.getClueRecordId());
clue.setCreateBy(baseExcelVo.getUserId());
clue.setMemberStatus(DefaultNumberConstants.ZERO_NUMBER);
clues.add(clue);
}
if (clues.size() > 0) {
clueService.saveClue(clues);
}
}
}

@ -0,0 +1,62 @@
package com.baiye.module.service;
import com.baiye.model.dto.ClueQueryCriteria;
import com.baiye.model.dto.DistributeResponseDTO;
import com.baiye.module.entity.Clue;
import com.baiye.module.entity.ClueRecord;
import com.baiye.module.service.dto.ClueRecordCriteria;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
public interface ClueService {
/**
*
* @param clueList
*/
void saveClue(List<Clue> clueList);
/**
* id
* @param taskId
* @return
*/
List<Clue> queryList(Long taskId);
/**
* id
* @return
*/
Page<ClueRecord> queryRecordList(ClueRecordCriteria clueRecordCriteria, Pageable pageable);
/**
*
* @param distributeResponseDTO
*/
void batchUpdateOrganize(DistributeResponseDTO distributeResponseDTO);
/**
* id
* @param organizeId
* @return
*/
List<Clue> queryOrganizeIdList(Long organizeId);
/**
*
* Map<Long, List<Long>> ,id->
* @param mapList
*/
void batchUpdateUserId(List<Map<Long, List<Long>>> mapList);
/**
*
* @param clueQueryCriteria
* @return
*/
Map<String,Object> queryAll(ClueQueryCriteria clueQueryCriteria);
}

@ -0,0 +1,16 @@
package com.baiye.module.service;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;
public interface UploadFileService {
/**
*
* @param file
* @param uploadType
* @param userId
* @return
*/
ResponseEntity<Object> singleFileUpload(MultipartFile[] file, Integer uploadType,Long userId);
}

@ -0,0 +1,23 @@
package com.baiye.module.service.dto;
import com.baiye.annotation.Query;
import lombok.Data;
import java.sql.Timestamp;
import java.util.List;
/**
*
*/
@Data
public class ClueRecordCriteria {
@Query
private Long createBy;
@Query
private String oldFile;
@Query(type = Query.Type.BETWEEN)
private List<Timestamp> createTime;
}

@ -0,0 +1,104 @@
package com.baiye.module.service.impl;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.model.dto.ClueDto;
import com.baiye.model.dto.ClueQueryCriteria;
import com.baiye.model.dto.DistributeResponseDTO;
import com.baiye.module.dao.ClueRecordRepository;
import com.baiye.module.dao.ClueRepository;
import com.baiye.module.entity.Clue;
import com.baiye.module.entity.ClueRecord;
import com.baiye.module.service.ClueService;
import com.baiye.module.service.dto.ClueRecordCriteria;
import com.baiye.module.service.mapstruct.ClueMapper;
import com.baiye.util.PageUtil;
import com.baiye.util.QueryHelp;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
@Slf4j
@RequiredArgsConstructor
public class ClueServiceImpl implements ClueService {
private final ClueRepository clueRepository;
private final ClueRecordRepository clueRecordRepository;
private final ClueMapper clueMapper;
@Override
public void saveClue(List<Clue> clueList) {
if (clueList.size() > 0){
clueRepository.saveAll(clueList);
}
}
@Override
public List<Clue> queryList(Long taskId) {
List<Clue> clueLists = new ArrayList<>();
List<ClueRecord> clueRecordList = clueRecordRepository.findByTaskId(taskId);
if (clueRecordList.size() > 0) {
for (ClueRecord clueRecord : clueRecordList) {
List<Clue> clueList = clueRepository.findByRecordId(clueRecord.getId());
clueLists.addAll(clueList);
}
return clueLists;
}
return null;
}
@Override
public Page<ClueRecord> queryRecordList(ClueRecordCriteria clueRecordCriteria, Pageable pageable) {
Page<ClueRecord> clueAll = clueRecordRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, clueRecordCriteria, criteriaBuilder), pageable);
return clueAll;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void batchUpdateOrganize(DistributeResponseDTO distributeResponseDTO) {
List<Long> responseList = distributeResponseDTO.getResponseList();
Long deptId = distributeResponseDTO.getDeptId();
for (Long id : responseList) {
clueRepository.updateOrganizeIdById(id,deptId);
}
}
@Override
public List<Clue> queryOrganizeIdList(Long organizeId) {
return clueRepository.findByOrganizeId(organizeId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void batchUpdateUserId(List<Map<Long, List<Long>>> mapList) {
for (Map<Long, List<Long>> map : mapList) {
for (Long userId : map.keySet()) {
List<Long> userIdList = map.get(userId);
for (Long clueId : userIdList) {
clueRepository.updateUserId(clueId, DefaultNumberConstants.ONE_NUMBER, userId);
}
}
}
}
/**
*
*/
@Override
public Map<String,Object> queryAll(ClueQueryCriteria clueQueryCriteria ) {
Sort sort = Sort.by(Sort.Direction.ASC, "createTime");
Pageable pageable = PageRequest.of(clueQueryCriteria.getPage(), clueQueryCriteria.getSize(),sort);
Page<Clue> cluePage = clueRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, clueQueryCriteria, criteriaBuilder), pageable);
return PageUtil.toPage(cluePage.map(clueMapper::toDto));
}
}

@ -0,0 +1,11 @@
package com.baiye.module.service.mapstruct;
import com.baiye.model.base.BaseMapper;
import com.baiye.model.dto.ClueDto;
import com.baiye.module.entity.Clue;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface ClueMapper extends BaseMapper<ClueDto, Clue> {
}

@ -0,0 +1,66 @@
package com.baiye.task;
import com.alibaba.excel.EasyExcelFactory;
import com.baiye.module.constant.FileConstant;
import com.baiye.module.entity.ClueRecord;
import com.baiye.module.entity.vo.BaseExcelVo;
import com.baiye.module.entity.vo.KsVo;
import com.baiye.module.entity.vo.ZdyVo;
import com.baiye.module.listener.KsExcelListener;
import com.baiye.module.listener.UcCsvListener;
import com.baiye.module.listener.ZdyExcelListener;
import com.baiye.module.service.ClueService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.FileInputStream;
import java.util.List;
@Component
@Slf4j
public class FileAnalysisTask {
@Resource
private ClueService clueService;
/**
*
* @param clueRecords
*/
@Async(value = "SendBigDataTaskExecutor")
@SneakyThrows //处理异常try
public void runFileAnalysisTask(List<ClueRecord> clueRecords) {
for (ClueRecord clueRecord : clueRecords) {
BaseExcelVo baseExcelVo = new BaseExcelVo();
baseExcelVo.setUserId(clueRecord.getCreateBy());
baseExcelVo.setClueRecordId(clueRecord.getId());
baseExcelVo.setOrigin(clueRecord.getUploadType());
FileInputStream file = new FileInputStream(clueRecord.getNewFileUrl());
switch (clueRecord.getUploadType()){
case FileConstant.ZERO_NUMBER:
log.info("==============开始导入自定义表单============{}",Thread.currentThread().getName());
EasyExcelFactory.read(file, ZdyVo.class, new ZdyExcelListener(clueService,baseExcelVo)).build().readAll();
break;
case FileConstant.ONE_NUMBER:
log.info("==============开始导入UC表单============",Thread.currentThread().getName());
//EasyExcelFactory.read(file, UcVo.class, new UcExcelListener(clueService,baseExcelVo)).build().readAll();
new UcCsvListener(clueService,baseExcelVo).readUcCsv(clueRecord.getNewFileUrl());
break;
case FileConstant.TWO_NUMBER:
log.info("==============开始导入快手表单============{}",Thread.currentThread().getName());
EasyExcelFactory.read(file, KsVo.class, new KsExcelListener(clueService,baseExcelVo)).build().readAll();
break;
default:
break;
}
}
}
}

@ -0,0 +1,178 @@
package com.baiye.util;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baiye.annotation.Query;
import com.baiye.constant.DefaultNumberConstants;
import lombok.extern.slf4j.Slf4j;
import javax.persistence.criteria.*;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@Slf4j
@SuppressWarnings({"unchecked", "all"})
public class QueryHelp {
public static <R, Q> Predicate getPredicate(Root<R> root, Q query, CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<>();
if (query == null) {
return cb.and(list.toArray(new Predicate[0]));
}
try {
List<Field> fields = getAllFields(query.getClass(), new ArrayList<>());
for (Field field : fields) {
boolean accessible = field.isAccessible();
field.setAccessible(true);
Query q = field.getAnnotation(Query.class);
if (q != null) {
String propName = q.propName();
String joinName = q.joinName();
String blurry = q.blurry();
String attributeName = isBlank(propName) ? field.getName() : propName;
Class<?> fieldType = field.getType();
Object val = field.get(query);
if (ObjectUtil.isNull(val) || StrUtil.EMPTY.equals(val) || StrUtil.NULL.equals(val) || "undefined".equals(val)) {
continue;
}
Join join = null;
// 模糊多字段
if (ObjectUtil.isNotEmpty(blurry)) {
String[] blurrys = blurry.split(StrUtil.COMMA);
List<Predicate> orPredicate = new ArrayList<>();
for (String s : blurrys) {
orPredicate.add(cb.like(root.get(s)
.as(String.class), DefaultNumberConstants.NAT_DELIM + val.toString() + DefaultNumberConstants.NAT_DELIM));
}
Predicate[] p = new Predicate[orPredicate.size()];
list.add(cb.or(orPredicate.toArray(p)));
continue;
}
if (ObjectUtil.isNotEmpty(joinName)) {
String[] joinNames = joinName.split(">");
for (String name : joinNames) {
switch (q.join()) {
case LEFT:
if (ObjectUtil.isNotNull(join)) {
join = join.join(name, JoinType.LEFT);
} else {
join = root.join(name, JoinType.LEFT);
}
break;
case RIGHT:
if (ObjectUtil.isNotNull(join)) {
join = join.join(name, JoinType.RIGHT);
} else {
join = root.join(name, JoinType.RIGHT);
}
break;
case INNER:
if (ObjectUtil.isNotNull(join)) {
join = join.join(name, JoinType.INNER);
} else {
join = root.join(name, JoinType.INNER);
}
break;
default:
break;
}
}
}
switch (q.type()) {
case EQUAL:
list.add(cb.equal(getExpression(attributeName, join, root)
.as((Class<? extends Comparable>) fieldType), val));
break;
case GREATER_THAN:
list.add(cb.greaterThanOrEqualTo(getExpression(attributeName, join, root)
.as((Class<? extends Comparable>) fieldType), (Comparable) val));
break;
case LESS_THAN:
list.add(cb.lessThanOrEqualTo(getExpression(attributeName, join, root)
.as((Class<? extends Comparable>) fieldType), (Comparable) val));
break;
case LESS_THAN_NQ:
list.add(cb.lessThan(getExpression(attributeName, join, root)
.as((Class<? extends Comparable>) fieldType), (Comparable) val));
break;
case INNER_LIKE:
list.add(cb.like(getExpression(attributeName, join, root)
.as(String.class), DefaultNumberConstants.NAT_DELIM + val.toString() + DefaultNumberConstants.NAT_DELIM));
break;
case LEFT_LIKE:
list.add(cb.like(getExpression(attributeName, join, root)
.as(String.class), DefaultNumberConstants.NAT_DELIM + val.toString()));
break;
case RIGHT_LIKE:
list.add(cb.like(getExpression(attributeName, join, root)
.as(String.class), val.toString() + DefaultNumberConstants.NAT_DELIM));
break;
case IN:
if (CollUtil.isNotEmpty((Collection<Long>) val)) {
list.add(getExpression(attributeName, join, root).in((Collection<Long>) val));
}
break;
case NOT_IN:
if (CollUtil.isNotEmpty((Collection<Long>) val)) {
list.add(cb.not(getExpression(attributeName, join, root).in((Collection<Long>) val)));
}
break;
case NOT_EQUAL:
list.add(cb.notEqual(getExpression(attributeName, join, root), val));
break;
case NOT_NULL:
list.add(cb.isNotNull(getExpression(attributeName, join, root)));
break;
case BETWEEN:
List<Object> between = new ArrayList<>((List<Object>) val);
list.add(cb.between(getExpression(attributeName, join, root).as((Class<? extends Comparable>) between.get(0).getClass()),
(Comparable) between.get(0), (Comparable) between.get(1)));
break;
default:
break;
}
}
field.setAccessible(accessible);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
int size = list.size();
return cb.and(list.toArray(new Predicate[size]));
}
@SuppressWarnings("unchecked")
private static <T, R> Expression<T> getExpression(String attributeName, Join join, Root<R> root) {
if (ObjectUtil.isNotEmpty(join)) {
return join.get(attributeName);
} else {
return root.get(attributeName);
}
}
private static boolean isBlank(final CharSequence cs) {
int strLen;
if (cs == null || (strLen = cs.length()) == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
if (!Character.isWhitespace(cs.charAt(i))) {
return false;
}
}
return true;
}
private static List<Field> getAllFields(Class clazz, List<Field> fields) {
if (clazz != null) {
fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
getAllFields(clazz.getSuperclass(), fields);
}
return fields;
}
}

@ -0,0 +1,80 @@
#配置数据源
spring:
cloud:
nacos:
discovery:
server-addr: ${NACOS_HOST:118.178.137.129}:${NACOS_PORT:8848}
datasource:
druid:
db-type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://118.178.137.129:3306/ad-platform?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull
username: root
password: root
# 初始连接数
initial-size: 5
# 最小连接数
min-idle: 15
# 最大连接数
max-active: 30
# 超时时间(以秒数为单位)
remove-abandoned-timeout: 180
# 获取连接超时时间
max-wait: 3000
# 连接有效性检测时间
time-between-eviction-runs-millis: 60000
# 连接在池中最小生存的时间
min-evictable-idle-time-millis: 300000
# 连接在池中最大生存的时间
max-evictable-idle-time-millis: 900000
# 指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败,则连接将被从池中去除
test-while-idle: true
# 指明是否在从池中取出连接前进行检验,如果检验失败, 则从池中去除连接并尝试取出另一个
test-on-borrow: true
# 是否在归还到池中前进行检验
test-on-return: false
# 检测连接是否有效
validation-query: select 1
# 配置监控统计
webStatFilter:
enabled: true
stat-view-servlet:
enabled: true
url-pattern: /druid/*
reset-enable: false
filter:
stat:
enabled: true
# 记录慢SQL
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
# 文件存储
storage:
# url: /usr/local/webapp/services/source/
# symbol:/
url: C:\Users\Admin\Desktop\
de_symbol: \\
se_symbol: \
download-template: /usr/local/webapp/ad-platform/ad-platform-source/custom.xlsx
# 线程池配置
save:
task:
thread_pool:
corePoolSize: 2
maxPoolSize: 16
queueCapacity: 3
ThreadNamePrefix: SaveFileTaskExecutor-
# IP 本地解析
ip:
local-parsing: true
#密码加密传输,前端公钥加密,后端私钥解密
rsa:
private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A==

@ -0,0 +1,76 @@
#配置数据源
spring:
cloud:
nacos:
discovery:
server-addr: ${NACOS_HOST:118.178.137.129}:${NACOS_PORT:8848}
datasource:
druid:
db-type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:eladmin}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
username: ${DB_USER:root}
password: ${DB_PWD:123456}
# 初始连接数
initial-size: 5
# 最小连接数
min-idle: 15
# 最大连接数
max-active: 30
# 超时时间(以秒数为单位)
remove-abandoned-timeout: 180
# 获取连接超时时间
max-wait: 3000
# 连接有效性检测时间
time-between-eviction-runs-millis: 60000
# 连接在池中最小生存的时间
min-evictable-idle-time-millis: 300000
# 连接在池中最大生存的时间
max-evictable-idle-time-millis: 900000
# 指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败,则连接将被从池中去除
test-while-idle: true
# 指明是否在从池中取出连接前进行检验,如果检验失败, 则从池中去除连接并尝试取出另一个
test-on-borrow: true
# 是否在归还到池中前进行检验
test-on-return: false
# 检测连接是否有效
validation-query: select 1
# 配置监控统计
webStatFilter:
enabled: true
stat-view-servlet:
enabled: true
url-pattern: /druid/*
reset-enable: false
filter:
stat:
enabled: true
# 记录慢SQL
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
# 文件存储
storage:
url: /usr/local/webapp/services/source/
de_symbol: /
# 线程池配置
save:
task:
thread_pool:
corePoolSize: 2
maxPoolSize: 16
queueCapacity: 3
ThreadNamePrefix: SaveFileTaskExecutor-
# IP 本地解析
ip:
local-parsing: true
#密码加密传输,前端公钥加密,后端私钥解密
rsa:
private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A==

@ -1,10 +1,37 @@
server:
port: 7788
port: 7325
spring:
cloud:
nacos:
discovery:
server-addr: ${NACOS_HOST:118.178.137.129}:${NACOS_PORT:8848}
main:
allow-bean-definition-overriding: true
freemarker:
check-template-location: false
profiles:
active: dev
application:
name: @artifactId@
jackson:
time-zone: GMT+8
data:
redis:
repositories:
enabled: false
# servlet:
# multipart:
# max-file-size: 200MB #单个文件上传大小
# max-request-size: 600MB #连续上传文件大小
#配置 Jpa
jpa:
hibernate:
ddl-auto: none
open-in-view: true
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
#hutool雪花算法
snowflake:
workerId: 9
datacenterId: 9

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds" debug="false">
<contextName>trade-account</contextName>
<!-- 定义日志格式基础信息 -->
<property name="LOG_DIR" value="./log/"/>
<property name="LOG_PATTERN"
value="%white(%contextName-) %d{yyyy-MM-dd HH:mm:ss:SS} %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{50}) - %cyan(%msg%n)"/>
<property name="LOG_CHARSET" value="utf-8"/>
<!--输出到控制台-->
<appender name="stdAppender" class="ch.qos.logback.core.ConsoleAppender">
<!--<withJansi>true</withJansi> &lt;!&ndash; 如果是UTF-8的环境这句要注释掉 &ndash;&gt;-->
<encoder>
<pattern>%highlight([%-5level]) %cyan(%d{yyyy-MM-dd#HH:mm:ss.SSS}) %yellow([Thread:%thread])
%magenta([Logger:%logger]) -> %msg%n
</pattern>
<charset>utf-8</charset>
</encoder>
</appender>
<!-- 输出到文件,并按天进行归档 -->
<appender name="fileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_DIR}/log.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天归档,如果按小时后面加-hh -->
<fileNamePattern>${LOG_DIR}/history/%d{yyyy-MM-dd}.gz</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<append>true</append>
<encoder>
<pattern>${LOG_PATTERN}</pattern>
<charset>utf-8</charset>
</encoder>
<!-- 不写TRACE DEBUG -->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
</appender>
<!--普通日志输出到控制台-->
<root level="info">
<appender-ref ref="stdAppender"/>
</root>
<!--监控sql日志输出 -->
<logger name="jdbc.sqlonly" level="INFO" additivity="false">
<appender-ref ref="stdAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
<logger name="jdbc.resultset" level="ERROR" additivity="false">
<appender-ref ref="stdAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
<!-- 如想看到表格数据将OFF改为INFO -->
<logger name="jdbc.resultsettable" level="OFF" additivity="false">
<appender-ref ref="stdAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
<logger name="jdbc.connection" level="OFF" additivity="false">
<appender-ref ref="stdAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
<logger name="jdbc.sqltiming" level="OFF" additivity="false">
<appender-ref ref="stdAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
<logger name="jdbc.audit" level="OFF" additivity="false">
<appender-ref ref="stdAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
<root level="INFO">
<!-- TODO prod 环境去掉std -->
<!--fileAppender生成文件===正式环境使用 -->
<!-- <appender-ref ref="fileAppender"/>-->
<!--stdAppender本地环境日志输出面板打印===本地测试环境使用 -->
<appender-ref ref="stdAppender"/>
</root>
</configuration>
Loading…
Cancel
Save