对接dmp

master
wujingtao 2 years ago
parent 272ac2f67f
commit e346b5b326

@ -76,7 +76,7 @@ public class BaseTask implements Serializable {
@Column(name = "remark")
private String remark;
@ApiModelProperty(value = "特殊任务 1-动态表单任务 2-员工个人上传任务")
@ApiModelProperty(value = "特殊任务 1-动态表单任务 2-员工个人上传任务 3-抖音任务 4- ad-back")
@Column(name = "is_form")
private Integer isForm=0;
}

@ -0,0 +1,44 @@
package com.baiye.modules.system.domain;
import com.baiye.util.JpaConverterListJson;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
/**
* @author jt
* tag
*/
@Entity
@Data
@Table(name = "tb_task_tag")
@EntityListeners(AuditingEntityListener.class)
public class TaskTag implements Serializable {
@Id
@Column(name = "id")
@ApiModelProperty(value = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "task_id")
@ApiModelProperty(value = "动态任务id")
@JsonSerialize(using = ToStringSerializer.class)
private Long taskId;
@Column(name = "user_id")
@ApiModelProperty(value = "业务管理员id")
@JsonSerialize(using = ToStringSerializer.class)
private Long userId;
@Column(name = "tag")
@ApiModelProperty(value = "tag")
@Convert(converter = JpaConverterListJson.class)
private List<String> tag;
}

@ -0,0 +1,107 @@
package com.baiye.modules.system.httpRequest;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author jt
* <p>
* ad_back tag
*/
@Slf4j
public class AdBackRequestApi {
@Value("${ad-back.url}")
private String url;
@Value("${ad-back.token}")
private String token;
public void sendTag(Long taskId, Long userId, List<String> tagStr) {
Map<String, Object> map = new HashMap<>(2);
map.put("taskId", taskId);
map.put("userId", userId);
map.put("token", token);
map.put("tagStr", tagStr);
String post = HttpUtil.post(url, JSONUtil.toJsonStr(map));
log.info("推送结果={}", post);
}
}

@ -6,6 +6,7 @@ import com.baiye.http.CommonResponse;
import com.baiye.model.dto.TaskQueryCriteria;
import com.baiye.modules.system.domain.Task;
import com.baiye.modules.system.service.TaskService;
import com.baiye.modules.system.service.dto.TaskTagDto;
import com.baiye.socket.WebSocketServer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -13,6 +14,7 @@ import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
@ -99,4 +101,11 @@ public class TaskController {
taskService.updateTaskEncryption(taskId);
return CommonResponse.createBySuccessMessage("操作成功");
}
@ApiOperation("新建ad-back任务")
@PostMapping("/saveAdBackTask")
public ResponseEntity<Object> saveAdBackTask(@RequestBody @Validated TaskTagDto taskTagDto) {
taskService.saveAdBackTask(taskTagDto);
return new ResponseEntity<>(HttpStatus.CREATED);
}
}

@ -3,6 +3,7 @@ package com.baiye.modules.system.service;
import com.baiye.model.dto.TaskQueryCriteria;
import com.baiye.modules.system.domain.Task;
import com.baiye.modules.system.service.dto.TaskDto;
import com.baiye.modules.system.service.dto.TaskTagDto;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
@ -15,13 +16,15 @@ public interface TaskService {
/**
*
*
* @param task
* @return
*/
ResponseEntity<Object> saveTask(Task task);
/**
*()
* ()
*
* @param taskQueryCriteria
* @param pageable
* @return
@ -30,6 +33,7 @@ public interface TaskService {
/**
* ()
*
* @param taskQueryCriteria
* @return
*/
@ -37,6 +41,7 @@ public interface TaskService {
/**
*
*
* @param taskId
* @return
*/
@ -44,27 +49,37 @@ public interface TaskService {
/**
*
*
* @param task
*/
void updateTask(Task task);
/**
* (使)
*
* @param userIds
*/
void delCompanyAll(List<Long> userIds);
/**
*
*
* @param taskId
*/
void delTask(Long taskId);
/**
*
*
* @param taskId
*/
void delDynamicTask(Long taskId);
void updateTaskEncryption(Long taskId);
void updateTaskEncryption(Long taskId);
/**
* ad-back
* @param taskTagDto
*/
void saveAdBackTask(TaskTagDto taskTagDto);
}

@ -0,0 +1,29 @@
package com.baiye.modules.system.service.dto;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @author jt
*/
@Getter
@Setter
@NoArgsConstructor
public class TaskTagDto {
/**
*
*/
@NotNull
private String taskName;
/**
*
*/
@NotNull
private Long userId;
@NotNull
private List<String> tagStr;
}

@ -13,6 +13,7 @@ import com.baiye.modules.system.domain.Label;
import com.baiye.modules.system.domain.OrganizeUser;
import com.baiye.modules.system.domain.Task;
import com.baiye.modules.system.domain.TaskOrganize;
import com.baiye.modules.system.httpRequest.AdBackRequestApi;
import com.baiye.modules.system.repository.OrganizeUserRepository;
import com.baiye.modules.system.repository.TaskOrganizeRepository;
import com.baiye.modules.system.repository.TaskRepository;
@ -21,6 +22,7 @@ import com.baiye.modules.system.service.LabelService;
import com.baiye.modules.system.service.TaskService;
import com.baiye.modules.system.service.UserService;
import com.baiye.modules.system.service.dto.TaskDto;
import com.baiye.modules.system.service.dto.TaskTagDto;
import com.baiye.modules.system.service.mapstruct.TaskMapper;
import com.baiye.util.PageUtil;
import com.baiye.util.QueryHelp;
@ -41,6 +43,9 @@ import javax.transaction.Transactional;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author jt
*/
@Service
@RequiredArgsConstructor
@Slf4j
@ -54,6 +59,7 @@ public class TaskServiceImpl implements TaskService {
private final SourceClueClient sourceClueClient;
private final LabelOrganizeService labelOrganizeService;
private final LabelService labelService;
private final AdBackRequestApi adBackRequestApi;
@Value("${snowflake.workerId}")
private int workerId;
@Value("${snowflake.datacenterId}")
@ -88,12 +94,45 @@ public class TaskServiceImpl implements TaskService {
return new ResponseEntity<>(CommonResponse.createBySuccess(ResponseCode.SUCCESS), HttpStatus.OK);
}
/**
* ad-back
*
* @param taskTagDto
*/
@Override
public void saveAdBackTask(TaskTagDto taskTagDto) {
Long taskId = createTask(taskTagDto.getUserId(), taskTagDto.getTaskName(), DefaultNumberConstants.FOUR_NUMBER);
//推送到ad-bask
adBackRequestApi.sendTag(taskId, taskTagDto.getUserId(), taskTagDto.getTagStr());
}
/**
*
*
* @param username
*/
private Long createTask(Long id, String username, Integer isForm) {
Long taskId = IdUtil.getSnowflake(9, 9).nextId();
Task task = new Task();
task.setId(taskId);
task.setTaskName(username);
task.setIsEncryption(DefaultNumberConstants.ONE_NUMBER);
//设置默认值
task.setIsDistribution(DefaultNumberConstants.ZERO_NUMBER);
task.setTaskType(DefaultNumberConstants.ONE_NUMBER);
task.setIsForm(isForm);
task.setCreateBy(id);
task.setLabelOrganizeId(null);
Task save = taskRepository.save(task);
return save.getId();
}
/**
* ()()
*/
@Override
public Object queryAll(TaskQueryCriteria taskQueryCriteria, Pageable pageable) {
PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by(Sort.Direction.DESC, "isForm","updateTime"));
PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by(Sort.Direction.DESC, "isForm", "updateTime"));
taskQueryCriteria.setCreateBy(SecurityUtils.getCurrentUserId());
Page<Task> taskRepositoryAll = taskRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, taskQueryCriteria, criteriaBuilder), pageRequest);
Page<TaskDto> taskDtoMap = taskRepositoryAll.map(taskMapper::toDto);
@ -194,6 +233,7 @@ public class TaskServiceImpl implements TaskService {
}
}
/**
* id
*/

@ -4,6 +4,7 @@ spring:
nacos:
discovery:
server-addr: ${NACOS_HOST:8.130.96.163}:${NACOS_PORT:8848}
# server-addr: localhost:8848
redis:
database: 2
host: 8.130.96.163
@ -178,3 +179,7 @@ ocean:
appSecret: f1bef553cd635b7cd8057052654ebaaa30fa92a5
redirectUrl: http://8.130.96.163:8866/api/oceanEngine/callback
welcomeUrl: https://baiyee.vip/
ad-back:
url: cb.tuoz.net
token: 4f41de7d-97a3-4a40-b682-b9fc73b92459

@ -1,5 +1,6 @@
package com.baiye.module.controller;
import com.baiye.http.CommonResponse;
import com.baiye.module.service.FormSourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -30,4 +31,12 @@ public class FromTaskApi {
log.info("json======{}", json);
return formSourceService.acceptFormSource(json);
}
@ApiOperation("接受ad-back任务资源")
@PostMapping("/ad_back/add")
public CommonResponse<Object> acceptAdBackSource(@RequestBody String json) {
log.info("json======{}", json);
formSourceService.acceptAdBackSource(json);
return CommonResponse.createBySuccess();
}
}

@ -0,0 +1,36 @@
package com.baiye.module.entity;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
/**
* @author jt
* imel
*/
@Entity
@Data
@Table(name = "tb_task_imel")
@EntityListeners(AuditingEntityListener.class)
public class TaskImel implements Serializable {
@Id
@Column(name = "id")
@ApiModelProperty(value = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "task_id")
@ApiModelProperty(value = "动态任务id")
@JsonSerialize(using = ToStringSerializer.class)
private Long taskId;
@Column(name = "imel")
@ApiModelProperty(value = "imel")
private String imel;
}

@ -7,4 +7,6 @@ import java.util.Map;
*/
public interface FormSourceService {
Map<String, Object> acceptFormSource(String json);
void acceptAdBackSource(String json);
}

@ -113,6 +113,11 @@ public class FormSourceServiceImpl implements FormSourceService {
return map;
}
@Override
public void acceptAdBackSource(String json) {
}
private String decry(String data) {
FileReader fileReader = new FileReader(privatePath);
// FileReader fileReader = new FileReader("E:\\file\\source\\privatekey.txt");

Loading…
Cancel
Save