From fb22369e3d0078269dc1df2f3dbed51911b9e93a Mon Sep 17 00:00:00 2001 From: bynt <13586541001@163.com> Date: Thu, 23 May 2024 18:30:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=9D=E5=8D=95=E6=8E=A8?= =?UTF-8?q?=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/baiye/constant/ClueTypeConstants.java | 2 +- .../baiye/constant/ImportExcelConstants.java | 14 ++ .../java/com/baiye/constant/UrlConstants.java | 10 + .../com/baiye/listener/ExcelListener.java | 57 ++++++ .../baiye/util/TripartiteResponseUtil.java | 9 +- .../com/baiye/filter/ValidateCodeFilter.java | 2 +- .../config/properties/UrlsProperties.java | 19 ++ .../platform/domain/TrafficMaterial.java | 54 ++++++ .../repository/TrafficMaterialRepository.java | 15 ++ .../modules/platform/rest/TaskController.java | 3 + .../platform/rest/TaskImeiController.java | 8 +- .../rest/TelephoneTrafficController.java | 70 +++++++ .../service/DeliveryRecordService.java | 12 ++ .../platform/service/TaskImeiService.java | 6 +- .../service/TelephoneTrafficService.java | 46 +++++ .../platform/service/dto/ImportExcelDTO.java | 38 ++++ .../modules/platform/service/dto/TaskDto.java | 9 + .../platform/service/dto/TaskTagDto.java | 2 +- .../{TaskImeiDTO.java => TaskZDataDTO.java} | 8 +- .../platform/service/dto/ZDataDTO.java | 32 ++++ .../impl/DeliveryRecordServiceImpl.java | 19 ++ .../service/impl/TaskImeiServiceImpl.java | 39 ++-- .../service/impl/TaskServiceImpl.java | 3 + .../impl/TelephoneTrafficServiceImpl.java | 175 ++++++++++++++++++ .../mapstruct/TrafficMaterialMapper.java | 30 +++ .../entity/dto/CallImportDTO.java | 2 +- .../entity/dto/UpdateTrafficDTO.java | 28 +++ .../telemarkting/httpRequest/PreTestReq.java | 11 +- .../main/java/com/baiye/timed/FileTask.java | 112 +++++++++++ .../main/resources/config/application-dev.yml | 7 +- .../resources/config/application-prod.yml | 3 + .../src/main/resources/config/application.yml | 2 +- .../java/com/baiye/model/dto/PushClueDTO.java | 47 +++++ .../baiye/model/dto/TelephoneTrafficDTO.java | 51 +++++ .../java/com/baiye/model/entity/BaseTask.java | 16 ++ .../java/com/baiye/feign/PreTestClient.java | 15 ++ .../feign/fallback/PreTestClientFallback.java | 6 + .../controller/TrafficCallbackController.java | 35 ++++ .../com/baiye/module/dao/ClueQueryDSL.java | 49 ++--- .../com/baiye/module/service/ClueService.java | 16 +- .../service/TrafficCallbackService.java | 18 ++ .../module/service/impl/ClueServiceImpl.java | 18 ++ .../service/impl/DmpCallbackServiceImpl.java | 10 +- .../impl/TrafficCallbackServiceImpl.java | 97 ++++++++++ .../java/com/baiye/task/MailSourceTask.java | 6 +- .../src/main/resources/application-dev.yml | 6 +- .../src/main/resources/application-prod.yml | 2 + .../src/main/resources/application.yml | 1 + 48 files changed, 1157 insertions(+), 83 deletions(-) create mode 100644 ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/ImportExcelConstants.java create mode 100644 ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/listener/ExcelListener.java create mode 100644 ad-platform-manage/ad-platform-management/src/main/java/com/baiye/config/properties/UrlsProperties.java create mode 100644 ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/domain/TrafficMaterial.java create mode 100644 ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/TrafficMaterialRepository.java create mode 100644 ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/TelephoneTrafficController.java create mode 100644 ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/TelephoneTrafficService.java create mode 100644 ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/ImportExcelDTO.java rename ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/{TaskImeiDTO.java => TaskZDataDTO.java} (72%) create mode 100644 ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/ZDataDTO.java create mode 100644 ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/TelephoneTrafficServiceImpl.java create mode 100644 ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/mapstruct/TrafficMaterialMapper.java create mode 100644 ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/UpdateTrafficDTO.java create mode 100644 ad-platform-manage/ad-platform-management/src/main/java/com/baiye/timed/FileTask.java create mode 100644 ad-platform-pojo/src/main/java/com/baiye/model/dto/PushClueDTO.java create mode 100644 ad-platform-pojo/src/main/java/com/baiye/model/dto/TelephoneTrafficDTO.java create mode 100644 ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/controller/TrafficCallbackController.java create mode 100644 ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/TrafficCallbackService.java create mode 100644 ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/impl/TrafficCallbackServiceImpl.java diff --git a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/ClueTypeConstants.java b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/ClueTypeConstants.java index 7fa3f48b..e976f285 100644 --- a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/ClueTypeConstants.java +++ b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/ClueTypeConstants.java @@ -10,7 +10,7 @@ public class ClueTypeConstants { } public static final Integer[] SCREEN_TYPE = new Integer[]{0, 1, 2, 3, 6, 7}; - public static final Integer[] TOKER_TYPE = new Integer[]{4, 5}; + public static final Integer[] TOKER_TYPE = new Integer[]{4, 5, 9}; public static final Integer[] CLUE_POOL = new Integer[]{0, 8, 1, 3}; public static final Integer[] CRM_TOKER = new Integer[]{6, 7}; } diff --git a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/ImportExcelConstants.java b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/ImportExcelConstants.java new file mode 100644 index 00000000..9adda0c5 --- /dev/null +++ b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/ImportExcelConstants.java @@ -0,0 +1,14 @@ +package com.baiye.constant; + +/** + * @author Enzo + * @date : 2024/4/30 + */ +public class ImportExcelConstants { + + + public static final String NAME = "姓名"; + + + public static final String NID = "电话"; +} diff --git a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/UrlConstants.java b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/UrlConstants.java index 3d4698f1..fdeb1d44 100644 --- a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/UrlConstants.java +++ b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/UrlConstants.java @@ -15,4 +15,14 @@ public class UrlConstants { public static String CALL_BACK_CLUE_URL="https://ad.oceanengine.com/open_api/2/tools/clue/callback/"; + + public static final String SEND_URL = "https://ai.hzdaba.cn/external/activity/addClient"; + + public static final String GET_URL = "https://ai.hzdaba.cn/external/activity_statistics"; + + public static final String TOKEN_URL = "https://ai.hzdaba.cn/external/get/authKey"; + + public static final String UPDATE_STATUS = "https://ai.hzdaba.cn/external/activity/updateStatus"; + + } diff --git a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/listener/ExcelListener.java b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/listener/ExcelListener.java new file mode 100644 index 00000000..8b5a11ab --- /dev/null +++ b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/listener/ExcelListener.java @@ -0,0 +1,57 @@ +package com.baiye.listener; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author Enzo + * @date : 2024/4/29 + */ + +public class ExcelListener extends AnalysisEventListener> { + // Excel数据 + private List>> list; + // Excel列名 + private Map headTitleMap = new HashMap<>(); + + public ExcelListener() { + list = new ArrayList<>(); + } + + @Override + public void invoke(Map data, AnalysisContext context) { + Map> map = new HashMap<>(); + map.put(context.readRowHolder().getRowIndex(), data); + list.add(map); + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + } + + @Override + public void invokeHeadMap(Map headMap, AnalysisContext context) { + headTitleMap = headMap; + } + + public List>> getList() { + return list; + } + + public void setList(List>> list) { + this.list = list; + } + + public Map getHeadTitleMap() { + return headTitleMap; + } + + public void setHeadTitleMap(Map headTitleMap) { + this.headTitleMap = headTitleMap; + } +} diff --git a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/util/TripartiteResponseUtil.java b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/util/TripartiteResponseUtil.java index 8589ec9d..90509492 100644 --- a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/util/TripartiteResponseUtil.java +++ b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/util/TripartiteResponseUtil.java @@ -23,7 +23,7 @@ public class TripartiteResponseUtil { } - public static void transmissionParameter(String taskName, List tagList, List decryptList, String password) { + public static void transmissionParameter(Integer type, String taskName, List tagList, List decryptList, String password) { Map map = Maps.newHashMap(); List arrayList = Lists.newArrayList(); DmpResponse dmpResponse = new DmpResponse(); @@ -40,6 +40,11 @@ public class TripartiteResponseUtil { map.put("status", DefaultNumberConstants.TWO_HUNDRED); map.put("msg", ResponseCode.SUCCESS.getDesc()); map.put("data", dmpResponse); - HttpUtil.post("https://api.xiaolanben.com/blue-touch/api/v1/open/ad/dmp/exchange", JSONUtil.toJsonStr(map)); + if (type == DefaultNumberConstants.SIX_NUMBER) { + HttpUtil.post("", JSONUtil.toJsonStr(map)); + } + if (type == DefaultNumberConstants.THREE_NUMBER) { + HttpUtil.post("https://api.xiaolanben.com/blue-touch/api/v1/open/ad/dmp/exchange", JSONUtil.toJsonStr(map)); + } } } diff --git a/ad-platform-gateway/src/main/java/com/baiye/filter/ValidateCodeFilter.java b/ad-platform-gateway/src/main/java/com/baiye/filter/ValidateCodeFilter.java index 6ff9c9b1..a1a7c520 100644 --- a/ad-platform-gateway/src/main/java/com/baiye/filter/ValidateCodeFilter.java +++ b/ad-platform-gateway/src/main/java/com/baiye/filter/ValidateCodeFilter.java @@ -69,7 +69,7 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory { try { validateCodeService.checkCapcha(uuid,code); } catch (CaptchaException e) { - log.info("验证码有误"); + log.error("验证码有误"); ServerHttpResponse response = exchange.getResponse(); response.setStatusCode(HttpStatus.PRECONDITION_REQUIRED); response.getHeaders().setContentType(MediaType.APPLICATION_JSON); diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/config/properties/UrlsProperties.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/config/properties/UrlsProperties.java new file mode 100644 index 00000000..9a5aaee6 --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/config/properties/UrlsProperties.java @@ -0,0 +1,19 @@ +package com.baiye.config.properties; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Getter +@Setter +@Configuration +@ConfigurationProperties(prefix = "urls") +public class UrlsProperties { + + /** + * 大坝推送链接地址 + */ + private String dbPushUrl; + +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/domain/TrafficMaterial.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/domain/TrafficMaterial.java new file mode 100644 index 00000000..69f69da8 --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/domain/TrafficMaterial.java @@ -0,0 +1,54 @@ +package com.baiye.modules.platform.domain; + +import com.baiye.model.base.BaseEntity; +import com.baiye.util.JpaConverterAes; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * @author Enzo + * @date : 2024/4/27 + */ + +@Setter +@Getter +@Entity +@Table(name = "tb_traffic_material") +@ApiModel(value = "话务材料") +public class TrafficMaterial extends BaseEntity implements Serializable { + + + private static final long serialVersionUID = 8723232289324510063L; + + @Id + @ApiModelProperty(value = "id") + @Column(name = "id") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ApiModelProperty(value = "姓名") + @Column(name = "name") + private String name; + + @ApiModelProperty(value = "nid") + @Column(name = "nid") + @Convert(converter = JpaConverterAes.class) + private String nid; + + @ApiModelProperty(value = "线索分配人") + private Long userId; + + @ApiModelProperty(value = "线索分配人") + private Long taskId; + + @ApiModelProperty(value = "其他信息") + private String otherInfo; + + + +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/TrafficMaterialRepository.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/TrafficMaterialRepository.java new file mode 100644 index 00000000..5c61e0d6 --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/TrafficMaterialRepository.java @@ -0,0 +1,15 @@ +package com.baiye.modules.platform.repository; + +import com.baiye.modules.platform.domain.TrafficMaterial; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; + +/** + * @author Enzo + * @date 2024-4-27 + */ +@Repository +public interface TrafficMaterialRepository extends JpaRepository, JpaSpecificationExecutor { + +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/TaskController.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/TaskController.java index 0d6bd708..f0fa9f65 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/TaskController.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/TaskController.java @@ -171,10 +171,13 @@ public class TaskController { public TaskUserDTO findTaskId(@RequestParam(value = "userId") Long userId, @RequestParam("number") Integer number) { return taskService.queryTaskByUserId(userId, number); } + @Inner @ApiOperation("用户id获取任务id") @GetMapping("/findTaskIdByUserId") public Long findTaskIdByUserId(@RequestParam(value = "userId") Long userId, @RequestParam("isForm") Integer isForm) { return taskService.findTaskIdByUserId(userId, isForm); } + + } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/TaskImeiController.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/TaskImeiController.java index 60ad9b80..6e87ef3c 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/TaskImeiController.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/TaskImeiController.java @@ -4,7 +4,7 @@ import com.baiye.http.CommonResponse; import com.baiye.modules.platform.service.TaskImeiService; import com.baiye.modules.platform.service.TripartiteSourceService; import com.baiye.modules.platform.service.dto.PlatformTransmitDTO; -import com.baiye.modules.platform.service.dto.TaskImeiDTO; +import com.baiye.modules.platform.service.dto.TaskZDataDTO; import com.baiye.modules.platform.service.dto.TripartiteTransmitDTO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -21,7 +21,7 @@ import org.springframework.web.bind.annotation.*; @RestController @RequiredArgsConstructor @Api(tags = "系统:角色管理") -@RequestMapping("/api/taskImei") +@RequestMapping("/api/data") public class TaskImeiController { private final TaskImeiService taskImeiService; @@ -51,8 +51,8 @@ public class TaskImeiController { @ApiOperation("兑换条数") @PostMapping("/exchange") - public CommonResponse acceptAdBackSource(@Validated @RequestBody TaskImeiDTO taskImeiDTO) { - return taskImeiService.processingData(taskImeiDTO); + public CommonResponse acceptAdBackSource(@Validated @RequestBody TaskZDataDTO taskZDataDTO) { + return taskImeiService.processingData(taskZDataDTO); } } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/TelephoneTrafficController.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/TelephoneTrafficController.java new file mode 100644 index 00000000..1cc5f763 --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/TelephoneTrafficController.java @@ -0,0 +1,70 @@ +package com.baiye.modules.platform.rest; + +import com.baiye.annotation.Inner; +import com.baiye.annotation.Log; +import com.baiye.constant.DefaultNumberConstants; +import com.baiye.http.CommonResponse; +import com.baiye.http.ResponseCode; +import com.baiye.modules.platform.service.TelephoneTrafficService; +import com.baiye.util.SecurityUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +/** + * @author Enzo + * @date : 2024/4/27 + * ai话务 + */ +@Slf4j +@RestController +@RequiredArgsConstructor +@Api(tags = "话务资源推送") +@RequestMapping("/api/telephone/traffic") +public class TelephoneTrafficController { + + private final TelephoneTrafficService telephoneTrafficService; + + + @ApiOperation("资源文件上传") + @PostMapping("/upload") + @Log("资源文件上传") + public ResponseEntity clueFileUpload(@RequestParam("file") MultipartFile[] file, + @RequestParam(value = "taskId") Long taskId) { + if (file.length > DefaultNumberConstants.ZERO_NUMBER) { + return new ResponseEntity<>(telephoneTrafficService.uploadFile(file, taskId), HttpStatus.OK); + } + return new ResponseEntity<>(CommonResponse.createBySuccess(ResponseCode.EMPTY_ARGUMENT.getDesc()), HttpStatus.OK); + } + + + @ApiOperation("修改授权") + @GetMapping("/update") + public ResponseEntity update(Boolean flag, Long taskId) { + return new ResponseEntity<>(telephoneTrafficService.updateAuthorizationStatus(flag, taskId), HttpStatus.OK); + } + + + @ApiOperation("获取链接地址") + @GetMapping("/url") + public ResponseEntity queryUrl() { + return new ResponseEntity<>(telephoneTrafficService.queryUrlByUserId(SecurityUtils.getCurrentUserId()), HttpStatus.OK); + } + + + @Inner + @ApiOperation("获取链接地址") + @GetMapping("/detail") + public ResponseEntity detail(@RequestParam Long sourceId) { + return new ResponseEntity<>(telephoneTrafficService.queryById(sourceId), HttpStatus.OK); + } + + + + +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/DeliveryRecordService.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/DeliveryRecordService.java index 6270dc51..f7cb1abc 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/DeliveryRecordService.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/DeliveryRecordService.java @@ -3,6 +3,7 @@ package com.baiye.modules.platform.service; import cn.hutool.core.date.DateTime; import com.baiye.modules.platform.domain.DeliveryRecord; import com.baiye.modules.platform.service.dto.ImeiDTO; +import com.baiye.modules.platform.service.dto.ZDataDTO; import java.util.List; @@ -79,4 +80,15 @@ public interface DeliveryRecordService { * @return */ DeliveryRecord queryByDownId(Long downId); + + /** + * zdata兑换 + * @param filterList + * @param batchNo + * @param type + * @param publicKey + * @param privateKey + * @return + */ + Boolean exchangeZDataByInterFace(List filterList, String batchNo, Integer type, String publicKey, String privateKey); } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/TaskImeiService.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/TaskImeiService.java index 3dfaea29..b4cc8e51 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/TaskImeiService.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/TaskImeiService.java @@ -4,7 +4,7 @@ import cn.hutool.core.date.DateTime; import com.baiye.http.CommonResponse; import com.baiye.modules.platform.domain.TaskImei; import com.baiye.modules.platform.service.dto.PlatformTransmitDTO; -import com.baiye.modules.platform.service.dto.TaskImeiDTO; +import com.baiye.modules.platform.service.dto.TaskZDataDTO; import java.util.List; import java.util.Set; @@ -77,10 +77,10 @@ public interface TaskImeiService { /** * 上传并发送兑换邮件 - * @param taskImeiDTO + * @param taskZDataDTO * @return */ - CommonResponse processingData(TaskImeiDTO taskImeiDTO); + CommonResponse processingData(TaskZDataDTO taskZDataDTO); /** * 根据时间修改状态 diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/TelephoneTrafficService.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/TelephoneTrafficService.java new file mode 100644 index 00000000..b26a3b61 --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/TelephoneTrafficService.java @@ -0,0 +1,46 @@ +package com.baiye.modules.platform.service; + +import com.baiye.model.dto.TelephoneTrafficDTO; +import org.springframework.web.multipart.MultipartFile; + +/** + * @author Enzo + * @date : 2024/4/27 + */ +public interface TelephoneTrafficService { + + /** + * 上传文件 + * + * @param files + * @param taskId + * @return + */ + Boolean uploadFile(MultipartFile[] files, Long taskId); + + + /** + * 修改ai任务 + * + * @param flag + * @param id + * @return + */ + Boolean updateAuthorizationStatus(Boolean flag, Long id); + + + /** + * 获取请求链接 + * + * @param currentUserId + * @return + */ + String queryUrlByUserId(Long currentUserId); + + /** + * id查询详细信息 + * @param sourceId + * @return + */ + TelephoneTrafficDTO queryById(Long sourceId); +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/ImportExcelDTO.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/ImportExcelDTO.java new file mode 100644 index 00000000..12b16900 --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/ImportExcelDTO.java @@ -0,0 +1,38 @@ +package com.baiye.modules.platform.service.dto; + +import cn.hutool.core.annotation.Alias; +import lombok.Data; + +import java.util.Objects; + +/** + * @author Enzo + * @date : 2024/3/4 + */ +@Data +public class ImportExcelDTO { + + private Long id; + + @Alias("姓名") + private String name; + + @Alias("电话") + private String nid; + + @Alias("其他信息") + private String otherInfo; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ImportExcelDTO dto = (ImportExcelDTO) o; + return Objects.equals(name, dto.name) && Objects.equals(nid, dto.nid); + } + + @Override + public int hashCode() { + return Objects.hash(name, nid); + } +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/TaskDto.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/TaskDto.java index e8ca8c80..6955465b 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/TaskDto.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/TaskDto.java @@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; +import javax.persistence.Column; import java.io.Serializable; import java.util.Date; import java.util.List; @@ -53,4 +54,12 @@ public class TaskDto implements Serializable { * 未分配数 */ private Integer unassigned; + + private Boolean isAiDelivery; + + + private String actName; + + + private String actId; } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/TaskTagDto.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/TaskTagDto.java index 0e778fdc..71eb8d2e 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/TaskTagDto.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/TaskTagDto.java @@ -42,7 +42,7 @@ public class TaskTagDto { private Integer isForm = 0; - @ApiModelProperty(value = "是否dmp投放") + @ApiModelProperty(value = "是否投放") private Boolean isDmpDelivery; } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/TaskImeiDTO.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/TaskZDataDTO.java similarity index 72% rename from ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/TaskImeiDTO.java rename to ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/TaskZDataDTO.java index 0f6d6209..214989ff 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/TaskImeiDTO.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/TaskZDataDTO.java @@ -12,15 +12,19 @@ import java.util.List; * @date : 2023/1/13 */ @Data -public class TaskImeiDTO { +public class TaskZDataDTO { @NotBlank @ApiModelProperty(value = "批次号") private String batchNo; + @NotBlank + @ApiModelProperty(value = "兑换类型 0 imei 1 oaid") + private Integer type; + @NotEmpty @ApiModelProperty(value = "兑换数量") - private List imeiList; + private List dataList; } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/ZDataDTO.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/ZDataDTO.java new file mode 100644 index 00000000..6da782da --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/ZDataDTO.java @@ -0,0 +1,32 @@ +package com.baiye.modules.platform.service.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author Enzo + * @date : 2022/10/21 + */ +@Data +public class ZDataDTO implements Serializable { + + private static final long serialVersionUID = -3271582444610218303L; + + /** + * This field is used for IMEI exchange in the early stage, and OAID can also be exchanged later + * Enzo + */ + @ApiModelProperty(value = "zid") + private String zid; + + + @ApiModelProperty(value = "tag") + private String tag; + + + @ApiModelProperty(value = "time") + private String time; + +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/DeliveryRecordServiceImpl.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/DeliveryRecordServiceImpl.java index 55e3f1a9..5130f446 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/DeliveryRecordServiceImpl.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/DeliveryRecordServiceImpl.java @@ -15,6 +15,7 @@ import com.baiye.modules.platform.repository.DeliveryRecordRepository; import com.baiye.modules.platform.service.DeliveryRecordService; import com.baiye.modules.platform.service.dto.ExchangeStripsDTO; import com.baiye.modules.platform.service.dto.ImeiDTO; +import com.baiye.modules.platform.service.dto.ZDataDTO; import com.google.common.collect.Lists; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -110,4 +111,22 @@ public class DeliveryRecordServiceImpl implements DeliveryRecordService { } return new DeliveryRecord(); } + + @Override + public Boolean exchangeZDataByInterFace(List filterList, String batchNo, Integer type, String publicKey, String privateKey) { + List list = Lists.newArrayList(); + filterList.forEach(imeiDTO -> { + ExchangeStripsDTO.Data data = new ExchangeStripsDTO.Data(); + if (StringUtils.isNotBlank(imeiDTO.getZid()) && StringUtils.isNotBlank(imeiDTO.getTag())) { + data.setData(Base64.encode(imeiDTO.getZid().concat(StrPool.COMMA).concat(imeiDTO.getTag()))); + list.add(data); + } + }); + ExchangeStripsDTO build = ExchangeStripsDTO.builder().batchId(batchNo).reqId + (RandomUtil.randomString(DefaultNumberConstants.TEN_NUMBER)).orgCode + (exchangeProperties.getOrgCode()).datas(list).type(type).build(); + String post = HttpUtil.post(exchangeProperties.getSubmitUrl(), JSONUtil.toJsonStr(build)); + log.info("============ the submit result as {} =========", JSONUtil.toJsonStr(post)); + return Boolean.TRUE; + } } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/TaskImeiServiceImpl.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/TaskImeiServiceImpl.java index eeaa03a7..8588fb91 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/TaskImeiServiceImpl.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/TaskImeiServiceImpl.java @@ -3,12 +3,10 @@ package com.baiye.modules.platform.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; -import cn.hutool.core.text.StrPool; import cn.hutool.core.util.ObjectUtil; import com.baiye.config.properties.DeliveryProperties; import com.baiye.constant.DefaultNumberConstants; import com.baiye.http.CommonResponse; -import com.baiye.model.dto.wechat.SendMailDTO; import com.baiye.model.enums.ResponseCode; import com.baiye.modules.platform.domain.DeliveryRecord; @@ -114,9 +112,9 @@ public class TaskImeiServiceImpl implements TaskImeiService { } @Override - public CommonResponse processingData(TaskImeiDTO taskImeiDTO) { + public CommonResponse processingData(TaskZDataDTO dataDTO) { // imei去除重复重新组装 - List dtoList = Lists.newArrayList(Sets.newHashSet(taskImeiDTO.getImeiList())); + List dtoList = Lists.newArrayList(Sets.newHashSet(dataDTO.getDataList())); // 最大最小数量设置 if (dtoList.size() < DefaultNumberConstants.ONE_HUNDRED) { @@ -128,39 +126,26 @@ public class TaskImeiServiceImpl implements TaskImeiService { (DefaultNumberConstants.ZERO_NUMBER, ResponseCode.SEND_MAIL_MAX_NUM_FRIEND.getDesc()); } - if (redisUtils.get(CacheKey.UPLOAD_BATCH.concat(taskImeiDTO.getBatchNo())) != null) { - List recordList = deliveryRecordService.findByBatchNo(taskImeiDTO.getBatchNo()); + if (redisUtils.get(CacheKey.UPLOAD_BATCH.concat(dataDTO.getBatchNo())) != null) { + List recordList = deliveryRecordService.findByBatchNo(dataDTO.getBatchNo()); if (CollUtil.isNotEmpty(recordList)) { return CommonResponse.createByErrorCodeMessage (DefaultNumberConstants.ZERO_NUMBER, ResponseCode.BATCH_NUMBER_ALREADY_EXISTS.getDesc()); } } - dtoList.forEach(o -> o.setImei(AESUtils.decrypt(o.getImei(), deliveryProperties.getExchangePassword()))); + dtoList.forEach(o -> o.setZid(AESUtils.decrypt(o.getZid(), deliveryProperties.getExchangePassword()))); // 过滤未解密完成的 - List filterList = dtoList.stream().filter - (o -> ObjectUtil.isNotNull(o.getImei())).collect(Collectors.toList()); + List filterList = dtoList.stream().filter + (o -> ObjectUtil.isNotNull(o.getZid())).collect(Collectors.toList()); if (CollUtil.isNotEmpty(filterList)) { log.info("================ the exchange list size as {} =================", filterList.size()); - - // 传输方式 - Integer type = (Integer) redisUtils.get(CacheKey.DMP_REQUEST_UPLOAD_TYPE); - if (ObjectUtil.isNotNull(type) && type.equals(DefaultNumberConstants.TWO_NUMBER)) { - String file = deliveryProperties.getFileUrl().concat(StrPool.SLASH).concat(taskImeiDTO.getBatchNo()); - SendMailDTO sendMailDTO = FileAndMailUtil.zipFileAndSendDMPMail - (filterList, file, taskImeiDTO.getBatchNo(), deliveryProperties, DefaultNumberConstants.TWO_NUMBER); - Long recordId = deliveryRecordService.saveDeliveryRecord(sendMailDTO.getZipPath(), taskImeiDTO.getBatchNo(), null, dtoList.size(), - null, (long) DefaultNumberConstants.ONE_NUMBER, DefaultNumberConstants.THREE_NUMBER, DefaultNumberConstants.ZERO_NUMBER, null); - // 缓存一天 - redisUtils.set(CacheKey.UPLOAD_BATCH.concat(taskImeiDTO.getBatchNo()), recordId, DefaultNumberConstants.ONE_NUMBER, TimeUnit.DAYS); - return CommonResponse.createBySuccess(DefaultNumberConstants.TWO_HUNDRED); - } - Boolean result = deliveryRecordService.exchangeByInterFace - (filterList, taskImeiDTO.getBatchNo(), DefaultNumberConstants.ZERO_NUMBER, deliveryProperties.getPublicKey(), deliveryProperties.getPrivateKey()); + Boolean result = deliveryRecordService.exchangeZDataByInterFace + (filterList, dataDTO.getBatchNo(), dataDTO.getType(), deliveryProperties.getPublicKey(), deliveryProperties.getPrivateKey()); if (Boolean.TRUE.equals(result)) { - Long recordId = deliveryRecordService.saveDeliveryRecord(null, taskImeiDTO.getBatchNo(), null, dtoList.size(), - null, (long) DefaultNumberConstants.ONE_NUMBER, DefaultNumberConstants.THREE_NUMBER, DefaultNumberConstants.ZERO_NUMBER, null); + Long recordId = deliveryRecordService.saveDeliveryRecord(null, dataDTO.getBatchNo(), null, dtoList.size(), + null, (long) DefaultNumberConstants.ONE_NUMBER, DefaultNumberConstants.SIX_NUMBER, dataDTO.getType(), null); // 缓存一天 - redisUtils.set(CacheKey.UPLOAD_BATCH.concat(taskImeiDTO.getBatchNo()), recordId, DefaultNumberConstants.ONE_NUMBER, TimeUnit.DAYS); + redisUtils.set(CacheKey.UPLOAD_BATCH.concat(dataDTO.getBatchNo()), recordId, DefaultNumberConstants.ONE_NUMBER, TimeUnit.DAYS); log.info("============= interface sending send recordId {} =============", recordId); } } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/TaskServiceImpl.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/TaskServiceImpl.java index c61de767..637827d5 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/TaskServiceImpl.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/TaskServiceImpl.java @@ -403,6 +403,9 @@ public class TaskServiceImpl implements TaskService { if (task.getLabelOrganizeId() != null) { updateTask.setLabelOrganizeId(task.getLabelOrganizeId()); } + if (task.getIsAiDelivery() != null) { + updateTask.setIsAiDelivery(task.getIsAiDelivery()); + } taskRepository.save(updateTask); } } else { diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/TelephoneTrafficServiceImpl.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/TelephoneTrafficServiceImpl.java new file mode 100644 index 00000000..5fda5303 --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/TelephoneTrafficServiceImpl.java @@ -0,0 +1,175 @@ +package com.baiye.modules.platform.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.core.text.csv.CsvReader; +import cn.hutool.core.text.csv.CsvUtil; +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; +import cn.hutool.poi.excel.ExcelReader; +import cn.hutool.poi.excel.ExcelUtil; +import com.baiye.config.properties.UrlsProperties; +import com.baiye.constant.*; +import com.baiye.exception.BadRequestException; +import com.baiye.http.PreTestResponse; +import com.baiye.model.dto.TelephoneTrafficDTO; +import com.baiye.modules.agent.entity.ChannelCustom; +import com.baiye.modules.platform.domain.Task; +import com.baiye.modules.platform.domain.TrafficMaterial; +import com.baiye.modules.platform.repository.TrafficMaterialRepository; +import com.baiye.modules.platform.service.TaskService; +import com.baiye.modules.platform.service.TelephoneTrafficService; +import com.baiye.modules.platform.service.dto.ImportExcelDTO; +import com.baiye.modules.platform.service.mapstruct.TrafficMaterialMapper; +import com.baiye.modules.telemarkting.entity.PreTestAccount; +import com.baiye.modules.telemarkting.entity.dto.UpdateTrafficDTO; +import com.baiye.modules.telemarkting.service.PreTestService; +import com.baiye.timed.FileTask; +import com.baiye.util.AESUtils; +import com.baiye.util.FileUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author Enzo + * @description 话务上传 + * @date 2024-4-27 + **/ +@Slf4j +@Service +@RequiredArgsConstructor +public class TelephoneTrafficServiceImpl implements TelephoneTrafficService { + + + private final TrafficMaterialRepository trafficMaterialRepository; + + private final TrafficMaterialMapper trafficMaterialMapper; + + private final UrlsProperties urlsProperties; + + private final PreTestService preTestService; + + private final TaskService taskService; + + private final FileTask fileTask; + + @Value("${snowflake.workerId}") + private int workerId; + + @Value("${snowflake.datacenterId}") + private int datacenterId; + + + @Override + public Boolean uploadFile(MultipartFile[] files, Long taskId) { + Set dtoList = Sets.newHashSet(); + Task task = taskService.queryDetails(taskId); + if (ObjectUtil.isNotNull(task) && task.getIsAiDelivery().equals(Boolean.TRUE)) { + throw new BadRequestException("当前任务未关闭 请关闭后进行导入操作!"); + } + for (MultipartFile file : files) { + // 解析数据 + String originalFilename = file.getOriginalFilename(); + if (StringUtils.isNotBlank(originalFilename)) { + dtoList.addAll(parseFile(file, originalFilename)); + } + } + + PreTestAccount dbAccount = preTestService.accountQuery(); + if (ObjectUtil.isNull(dbAccount) || StringUtils.isBlank(dbAccount.getToken())) { + throw new BadRequestException("未配置预测试账号!"); + } + + // 保存数据 + fileTask.runFileAnalysisTask(dtoList, task, dbAccount.getToken()); + return Boolean.TRUE; + } + + + private Set parseFile(MultipartFile file, String originalFilename) { + List dtoList = Lists.newArrayList(); + List> maps = Lists.newArrayList(); + // 解析 文件 + File upload = FileUtil.multiToFile(file); + if (ObjectUtil.isNotNull(upload)) { + if (originalFilename.endsWith(FileConstant.XLS_FILE_SUB_NAME) + || originalFilename.endsWith(FileConstant.XLSX_FILE_SUB_NAME)) { + ExcelReader reader = ExcelUtil.getReader(upload); + maps = reader.readAll(); + } + if (originalFilename.endsWith(FileConstant.CSV_FILE_SUB_NAME)) { + // TODO + CsvReader reader = CsvUtil.getReader(); + Convert.toList(Map.class, reader.readMapList(FileUtil.getReader(upload, CharsetUtil.CHARSET_UTF_8))); + } + for (Map map : maps) { + long nextId = IdUtil.getSnowflake(workerId, datacenterId).nextId(); + ImportExcelDTO dto = new ImportExcelDTO(); + Map hashMap = Maps.newHashMap(map); + dto.setId(nextId); + Object name = hashMap.getOrDefault(ImportExcelConstants.NAME, CharSequenceUtil.EMPTY); + dto.setName(ObjectUtil.isNotNull(name) ? name.toString() : CharSequenceUtil.EMPTY); + hashMap.remove(ImportExcelConstants.NAME); + Object nid = hashMap.getOrDefault(ImportExcelConstants.NID, CharSequenceUtil.EMPTY); + dto.setNid(ObjectUtil.isNotNull(nid) ? nid.toString() : CharSequenceUtil.EMPTY); + hashMap.remove(ImportExcelConstants.NID); + dto.setOtherInfo(hashMap.entrySet().toString()); + dtoList.add(dto); + } + } + return Sets.newHashSet(dtoList); + } + + @Override + public Boolean updateAuthorizationStatus(Boolean flag, Long id) { + Task task = taskService.queryDetails(id); + if (ObjectUtil.isNotNull(task) && !task.getIsAiDelivery().equals(flag)) { + PreTestAccount dbAccount = preTestService.accountQuery(); + if (ObjectUtil.isNotNull(dbAccount) && StringUtils.isNotBlank(dbAccount.getToken())) { + UpdateTrafficDTO build = UpdateTrafficDTO.builder().actId(task.getActId()).status + (flag.equals(Boolean.TRUE) ? DefaultNumberConstants.ONE_NUMBER : DefaultNumberConstants.ZERO_NUMBER).authKey(dbAccount.getToken()).build(); + String body = HttpUtil.post(UrlConstants.UPDATE_STATUS, JSONUtil.toJsonStr(build)); + log.info("====================== the log response {} ======================", body); + if (JSONUtil.isJson(body)) { + PreTestResponse bean = JSONUtil.toBean(body, PreTestResponse.class); + if (ObjectUtil.isNotNull(bean) && bean.getResult().equals(Boolean.TRUE)) { + task.setIsAiDelivery(flag); + taskService.updateTask(task); + return Boolean.TRUE; + } + } + } + } + return Boolean.FALSE; + } + + + @Override + public String queryUrlByUserId(Long currentUserId) { + String baseUtl = urlsProperties.getDbPushUrl(); + String encrypt = AESUtils.encrypt(currentUserId.toString(), AdPlatFormConstants.AD_PLATFORM); + return baseUtl.concat(ObjectUtil.isNotNull(encrypt) ? encrypt : CharSequenceUtil.EMPTY).concat("?dataType=detail&encrypt=1"); + } + + @Override + public TelephoneTrafficDTO queryById(Long sourceId) { + return trafficMaterialMapper.toDto(trafficMaterialRepository.findById(sourceId).orElse(new TrafficMaterial())); + } + +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/mapstruct/TrafficMaterialMapper.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/mapstruct/TrafficMaterialMapper.java new file mode 100644 index 00000000..2a3e8423 --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/mapstruct/TrafficMaterialMapper.java @@ -0,0 +1,30 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.baiye.modules.platform.service.mapstruct; + +import com.baiye.model.base.BaseMapper; +import com.baiye.model.dto.TelephoneTrafficDTO; +import com.baiye.modules.platform.domain.TrafficMaterial; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** + * @author ENZO + * + */ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface TrafficMaterialMapper extends BaseMapper { +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/CallImportDTO.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/CallImportDTO.java index 1d918b3f..8881f3a4 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/CallImportDTO.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/CallImportDTO.java @@ -49,7 +49,7 @@ public class CallImportDTO { private String variable; - // private List variableList; + private List variableList; } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/UpdateTrafficDTO.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/UpdateTrafficDTO.java new file mode 100644 index 00000000..98ad3c9a --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/UpdateTrafficDTO.java @@ -0,0 +1,28 @@ +package com.baiye.modules.telemarkting.entity.dto; + +import lombok.Builder; +import lombok.Data; + +/** + * @author wjt + * @date 2023/11/13 + */ +@Data +@Builder +public class UpdateTrafficDTO { + + /** + * 身份认证 token + */ + private String authKey; + + /** + * 活动名称 + */ + private String actId; + + /** + * 状态 + */ + private Integer status; +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/PreTestReq.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/PreTestReq.java index 36927db0..45722622 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/PreTestReq.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/PreTestReq.java @@ -4,6 +4,7 @@ import cn.hutool.http.HttpRequest; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; +import com.baiye.constant.UrlConstants; import com.baiye.exception.BadRequestException; import com.baiye.http.PreTestResponse; import com.baiye.modules.telemarkting.entity.dto.CallImportDTO; @@ -18,15 +19,13 @@ import org.springframework.stereotype.Component; @Slf4j @Component public class PreTestReq { - String sendUrl = "https://ai.hzdaba.cn/external/activity/addClient"; - String getUrl = "https://ai.hzdaba.cn/external/activity_statistics"; - String tokenUrl = "https://ai.hzdaba.cn/external/get/authKey"; + /** * 导入数据 */ public Boolean sendDaBa(CallImportDTO callImportDTO) { - String body = sendCallReq(sendUrl, JSONUtil.toJsonStr(callImportDTO)); + String body = sendCallReq(UrlConstants.SEND_URL, JSONUtil.toJsonStr(callImportDTO)); PreTestResponse response = JSONUtil.toBean(body, PreTestResponse.class); if (!response.getResult()) { log.info("导入失败 参数{}, 返回结果{}", JSONUtil.toJsonStr(callImportDTO), JSONUtil.toJsonStr(response)); @@ -45,7 +44,7 @@ public class PreTestReq { json.putOpt("status", 0); json.putOpt("pageNum", 1); json.putOpt("pageSize", 10); - String body = sendCallReq(getUrl, JSONUtil.toJsonStr(json)); + String body = sendCallReq(UrlConstants.GET_URL, JSONUtil.toJsonStr(json)); PreTestResponse response = JSONUtil.toBean(body, PreTestResponse.class); if (response.getResult()) { return JSONUtil.parseArray(response.getData()); @@ -62,7 +61,7 @@ public class PreTestReq { JSONObject json = new JSONObject(8); json.putOpt("username", username); json.putOpt("password", password); - String body = sendCallReq(tokenUrl, JSONUtil.toJsonStr(json)); + String body = sendCallReq(UrlConstants.TOKEN_URL, JSONUtil.toJsonStr(json)); PreTestResponse response = JSONUtil.toBean(body, PreTestResponse.class); if (response.getResult()) { return String.valueOf(response.getData()); diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/timed/FileTask.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/timed/FileTask.java new file mode 100644 index 00000000..bf464c06 --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/timed/FileTask.java @@ -0,0 +1,112 @@ +package com.baiye.timed; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; +import com.baiye.constant.DefaultNumberConstants; +import com.baiye.constant.UrlConstants; +import com.baiye.modules.platform.domain.Task; +import com.baiye.modules.platform.domain.TrafficMaterial; +import com.baiye.modules.platform.repository.TrafficMaterialRepository; +import com.baiye.modules.platform.service.TaskService; +import com.baiye.modules.platform.service.dto.ImportExcelDTO; +import com.baiye.modules.telemarkting.entity.dto.CallImportDTO; +import com.google.common.collect.Lists; +import com.sun.org.apache.xalan.internal.XalanConstants; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * @author Enzo + * @date : 2024/4/27 + */ + +@Slf4j +@Component +@RequiredArgsConstructor +public class FileTask { + + + @Value(value = "${inter.sendClientAddress}") + private String sendClientAddress; + + private final TaskService taskService; + + private final TrafficMaterialRepository trafficMaterialRepository; + + @Async(value = "WorkExecutor") + @Transactional(rollbackFor = Exception.class) + public void runFileAnalysisTask(Set dtoSet, Task task, String token) { + log.info("================== run task begin time {} ==================", DateUtil.now()); + CallImportDTO dto = new CallImportDTO(); + Long taskId = task.getId(); + int count = DefaultNumberConstants.ZERO_NUMBER; + // 去除空字符串 + List dtoList = Lists.newArrayList(dtoSet).stream().filter(str -> StringUtils.isNotBlank(str.getNid())).collect(Collectors.toList()); + List> partition = Lists.partition(dtoList, DefaultNumberConstants.ONE_THOUSAND); + if (ObjectUtil.isNotNull(task) && ObjectUtil.isNotNull(task.getActId())) { + // 调用推送地址进行推送 + for (List list : partition) { + List sendClientList = Lists.newArrayList(); + try { + list.forEach(str -> { + if (StringUtils.isNotBlank(str.getNid())) { + CallImportDTO.Source client = new CallImportDTO.Source(); + client.setCellphone(str.getNid()); + List variableList = Lists.newArrayList(); + CallImportDTO.Variable taskVariable = + CallImportDTO.Variable.builder().field + ("taskId").value(taskId.toString()).build(); + CallImportDTO.Variable sourceVariable = + CallImportDTO.Variable.builder().field + ("sourceId").value(str.getId().toString()).build(); + variableList.add(taskVariable); + variableList.add(sourceVariable); + client.setCellphone(str.getNid()); + client.setVariableList(variableList); + sendClientList.add(client); + } + }); + dto.setAuthKey(token); + dto.setActId(task.getActId()); + dto.setActName(task.getActName()); + dto.setClientList(sendClientList); + log.info("============ the request as {} =========", JSONUtil.toJsonStr(dto)); + String post = HttpUtil.post(UrlConstants.SEND_URL, JSONUtil.toJsonStr(dto)); + if (post.contains(XalanConstants.FEATURE_TRUE)) { + count += list.size(); + } + log.info("============ the submit result as {} =========", JSONUtil.toJsonStr(post)); + if (count > DefaultNumberConstants.ZERO_NUMBER) { + // 保存数据 + List saveList = Lists.newArrayList(); + list.forEach(tf -> { + TrafficMaterial material = new TrafficMaterial(); + material.setTaskId(taskId); + material.setId(tf.getId()); + material.setNid(tf.getNid()); + material.setName(tf.getName()); + material.setUserId(task.getCreateBy()); + saveList.add(material); + }); + trafficMaterialRepository.saveAll(saveList); + } + } catch (Exception exception) { + // TODO throw new exception + log.error("============ the request exception {} ============", exception.getMessage()); + } + } + } + log.info("================== run task end time {} ==================", DateUtil.now()); + } +} diff --git a/ad-platform-manage/ad-platform-management/src/main/resources/config/application-dev.yml b/ad-platform-manage/ad-platform-management/src/main/resources/config/application-dev.yml index 9ee88de3..5fe8c8a0 100644 --- a/ad-platform-manage/ad-platform-management/src/main/resources/config/application-dev.yml +++ b/ad-platform-manage/ad-platform-management/src/main/resources/config/application-dev.yml @@ -68,6 +68,8 @@ spring: config: multi-statement-allow: true + jpa: + show-sql: false # 登录相关配置 login: @@ -217,7 +219,7 @@ ocean: engine: appId: 1744002574259247 appSecret: f1bef553cd635b7cd8057052654ebaaa30fa92a5 - redirectUrl: http:///39.100.77.21:8866/api/oceanEngine/callback + redirectUrl: http://39.100.77.21:8866/api/oceanEngine/callback welcomeUrl: https://baiyee.vip/ ad-back: @@ -242,3 +244,6 @@ exchange: org-code: org_by_test callback-url: http://proxy.hzdaba.cn:58888/pub/data/set submit-url: http://proxy.hzdaba.cn:58888/pub/data/submit + +urls: + dbPushUrl: http://39.100.77.21:8899/source/traffic/v1/exchange/callback/ diff --git a/ad-platform-manage/ad-platform-management/src/main/resources/config/application-prod.yml b/ad-platform-manage/ad-platform-management/src/main/resources/config/application-prod.yml index 8e72cbab..e56b65ef 100644 --- a/ad-platform-manage/ad-platform-management/src/main/resources/config/application-prod.yml +++ b/ad-platform-manage/ad-platform-management/src/main/resources/config/application-prod.yml @@ -235,3 +235,6 @@ channel: logstash: url: 127.0.0.1:5044 + +urls: + dbPushUrl: https://baiyee.vip/source/traffic/v1/exchange/callback/ diff --git a/ad-platform-manage/ad-platform-management/src/main/resources/config/application.yml b/ad-platform-manage/ad-platform-management/src/main/resources/config/application.yml index 205dd3df..998e6fbf 100644 --- a/ad-platform-manage/ad-platform-management/src/main/resources/config/application.yml +++ b/ad-platform-manage/ad-platform-management/src/main/resources/config/application.yml @@ -52,7 +52,7 @@ security: - /operlog - /logininfor - /oauth/check_token - - /api/taskImei/** + - /api/data/exchange - /pay/aliPay/pay-notify - /api/oceanEngine/callback - /api/back/cdrUrl diff --git a/ad-platform-pojo/src/main/java/com/baiye/model/dto/PushClueDTO.java b/ad-platform-pojo/src/main/java/com/baiye/model/dto/PushClueDTO.java new file mode 100644 index 00000000..15ff6a47 --- /dev/null +++ b/ad-platform-pojo/src/main/java/com/baiye/model/dto/PushClueDTO.java @@ -0,0 +1,47 @@ +package com.baiye.model.dto; + +import lombok.Data; + +import java.util.Map; + +/** + * @author Enzo + * @date 2023-12-6 + */ +@Data +public class PushClueDTO { + + + + private String remark; + + + /** + * 人工审核推送手机号, mobile就不是手机号字段了 + */ + private String called; + + /** + * 话单id + */ + private String recId; + + /** + * 太空猫传递的线索ID + */ + private Long variable; + + /** + * nid + */ + private String mobile; + + + private String empClientTypeName; + + + private Map clientVariables; + + + +} diff --git a/ad-platform-pojo/src/main/java/com/baiye/model/dto/TelephoneTrafficDTO.java b/ad-platform-pojo/src/main/java/com/baiye/model/dto/TelephoneTrafficDTO.java new file mode 100644 index 00000000..2b35a675 --- /dev/null +++ b/ad-platform-pojo/src/main/java/com/baiye/model/dto/TelephoneTrafficDTO.java @@ -0,0 +1,51 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.baiye.model.dto; + +import com.baiye.util.JpaConverterAes; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * @author Zheng Jie + * @date 2018-11-23 + */ +@Data +public class TelephoneTrafficDTO implements Serializable { + + @ApiModelProperty(value = "id") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ApiModelProperty(value = "姓名") + private String name; + + @ApiModelProperty(value = "nid") + @Convert(converter = JpaConverterAes.class) + private String nid; + + @ApiModelProperty(value = "线索分配人") + private Long userId; + + @ApiModelProperty(value = "线索分配人") + private Long taskId; + + @ApiModelProperty(value = "其他信息") + private String otherSource; +} diff --git a/ad-platform-pojo/src/main/java/com/baiye/model/entity/BaseTask.java b/ad-platform-pojo/src/main/java/com/baiye/model/entity/BaseTask.java index 79966b41..8da7d6a3 100644 --- a/ad-platform-pojo/src/main/java/com/baiye/model/entity/BaseTask.java +++ b/ad-platform-pojo/src/main/java/com/baiye/model/entity/BaseTask.java @@ -98,4 +98,20 @@ public class BaseTask implements Serializable { private Boolean isDmpDelivery = Boolean.TRUE; + @ApiModelProperty(value = "是否开启话务投送") + @Column(name = "is_ai_delivery") + private Boolean isAiDelivery = Boolean.FALSE; + + + @Column(name = "act_name") + @ApiModelProperty(value = "活动名称") + private String actName; + + + @ApiModelProperty(value = "活动id") + @Column(name = "act_id") + private String actId; + + + } diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/feign/PreTestClient.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/feign/PreTestClient.java index 74022dac..4eb8fd76 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/feign/PreTestClient.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/feign/PreTestClient.java @@ -4,11 +4,13 @@ import com.baiye.constant.SecurityConstants; import com.baiye.feign.fallback.PreTestClientFallback; import com.baiye.model.dto.AddSourceDTO; import com.baiye.model.dto.AddWeChatFriendRecordDTO; +import com.baiye.model.dto.TelephoneTrafficDTO; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; /** * @author Enzo @@ -29,4 +31,17 @@ public interface PreTestClient { @GetMapping( "/api/add/source") ResponseEntity addSource(@RequestBody AddSourceDTO source, @RequestHeader(SecurityConstants.FROM) String from); + + /** + * Id获取线索Id + * @param sourceId + * @param from + * @return + */ + @GetMapping("/api/telephone/traffic/detail") + ResponseEntity findByDetail(@RequestParam("sourceId") Long sourceId, @RequestHeader(SecurityConstants.FROM) String from); + + + + } diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/feign/fallback/PreTestClientFallback.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/feign/fallback/PreTestClientFallback.java index 0162c3db..76a0408d 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/feign/fallback/PreTestClientFallback.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/feign/fallback/PreTestClientFallback.java @@ -3,6 +3,7 @@ package com.baiye.feign.fallback; import com.baiye.feign.PreTestClient; import com.baiye.model.dto.AddSourceDTO; import com.baiye.model.dto.AddWeChatFriendRecordDTO; +import com.baiye.model.dto.TelephoneTrafficDTO; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; @@ -18,4 +19,9 @@ public class PreTestClientFallback implements PreTestClient { public ResponseEntity addSource(AddSourceDTO source, String from) { return null; } + + @Override + public ResponseEntity findByDetail(Long sourceId, String from) { + return null; + } } diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/controller/TrafficCallbackController.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/controller/TrafficCallbackController.java new file mode 100644 index 00000000..7b8f67a0 --- /dev/null +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/controller/TrafficCallbackController.java @@ -0,0 +1,35 @@ +package com.baiye.module.controller; + +import cn.hutool.json.JSONUtil; +import com.baiye.annotation.Log; +import com.baiye.model.dto.PushClueDTO; +import com.baiye.module.service.TrafficCallbackService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +/** + * @author Enzo + * @date : 2023/3/2 + */ +@Slf4j +@RestController +@RequestMapping("/traffic/v1/exchange") +@RequiredArgsConstructor +public class TrafficCallbackController { + + private final TrafficCallbackService trafficCallbackService; + + + @Log("推送资源") + @PostMapping("/callback") + public ResponseEntity pushClue(@RequestBody String body) { + log.info("=============== the push body {} ==============", JSONUtil.toJsonStr(body)); + PushClueDTO pushClueDTO = JSONUtil.toBean(body, PushClueDTO.class); + return new ResponseEntity<>(Boolean.TRUE.equals(trafficCallbackService.callbackByAppKeyAndNid(pushClueDTO)) ? HttpStatus.OK : HttpStatus.BAD_REQUEST); + + } + +} diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/ClueQueryDSL.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/ClueQueryDSL.java index 57655a8d..4cf22023 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/ClueQueryDSL.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/ClueQueryDSL.java @@ -30,7 +30,10 @@ import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.sql.Timestamp; -import java.util.*; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Objects; /** * @Author YQY @@ -56,10 +59,10 @@ public class ClueQueryDSL { public List getCRMClueList(ClueQueryCriteria clueQueryCriteria, Pageable pageable) { JPAQuery query = jpaQueryFactory.select( - Projections.bean( - ClueDto.class, - cluePojo(DefaultNumberConstants.ONE_NUMBER) - )).from(qClue) + Projections.bean( + ClueDto.class, + cluePojo(DefaultNumberConstants.ONE_NUMBER) + )).from(qClue) .innerJoin(qClueMiddle) .on(qClue.id.eq(qClueMiddle.clueId)) .where(this.builder(clueQueryCriteria, DefaultNumberConstants.ONE_NUMBER)) @@ -75,8 +78,8 @@ public class ClueQueryDSL { */ public Long getCRMCount(ClueQueryCriteria clueQueryCriteria) { return jpaQueryFactory.select( - QClue.clue.count() - ).from(QClue.clue) + QClue.clue.count() + ).from(QClue.clue) .innerJoin(QClueMiddle.clueMiddle) .on(QClue.clue.id.eq(QClueMiddle.clueMiddle.clueId)) .where(this.builder(clueQueryCriteria, DefaultNumberConstants.ONE_NUMBER)) @@ -89,10 +92,10 @@ public class ClueQueryDSL { public List getTalkClueList(ClueQueryCriteria clueQueryCriteria, Pageable pageable) { JPAQuery query = jpaQueryFactory.select( - Projections.bean( - ClueDto.class, - cluePojo(DefaultNumberConstants.TWO_NUMBER) - )).from(qClue) + Projections.bean( + ClueDto.class, + cluePojo(DefaultNumberConstants.TWO_NUMBER) + )).from(qClue) .innerJoin(qClueTalk) .on(qClue.id.eq(qClueTalk.clueId)) .where(this.builder(clueQueryCriteria, DefaultNumberConstants.TWO_NUMBER)) @@ -108,8 +111,8 @@ public class ClueQueryDSL { */ public Long getTalkCount(ClueQueryCriteria clueQueryCriteria) { return jpaQueryFactory.select( - QClue.clue.count() - ).from(QClue.clue) + QClue.clue.count() + ).from(QClue.clue) .innerJoin(QClueTalk.clueTalk) .on(QClue.clue.id.eq(QClueTalk.clueTalk.clueId)) .where(this.builder(clueQueryCriteria, DefaultNumberConstants.TWO_NUMBER)) @@ -290,16 +293,16 @@ public class ClueQueryDSL { */ public List findSourceLabel(List clueIds) { return jpaQueryFactory.select( - Projections.bean( - ResSourceLabel.class, - qClue.nid, - qClue.createTime, - qClue.name, - qClueMiddle.clueId, - qClueMiddle.remark, - qClueMiddle.sourceLabel, - qClueMiddle.clueStage - )).from(qClue) + Projections.bean( + ResSourceLabel.class, + qClue.nid, + qClue.createTime, + qClue.name, + qClueMiddle.clueId, + qClueMiddle.remark, + qClueMiddle.sourceLabel, + qClueMiddle.clueStage + )).from(qClue) .innerJoin(qClueMiddle) .on(qClue.id.eq(qClueMiddle.clueId)) .where(qClueMiddle.clueId.in(clueIds)) diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/ClueService.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/ClueService.java index a4fcd5f9..9d52d9fe 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/ClueService.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/ClueService.java @@ -10,7 +10,6 @@ import com.baiye.module.service.dto.ClueRecordCriteria; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; @@ -243,4 +242,19 @@ public interface ClueService { * @return */ Map saveClueTalk(List onLineNotblackList, List tagList, Long taskId, Long userId, Integer number, Long memberId, Integer status); + + /** + * 插入单条数据 + * + * @param phone + * @param taskId + * @param userId + * @param otherSource + * @param numer + * @param zeroNumber + * @param remark + * @param memberId + * @return + */ + Boolean saveSingleClueTalk(String phone, Long taskId, Long userId, String otherSource, Integer numer, Integer zeroNumber, String remark, Long memberId); } diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/TrafficCallbackService.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/TrafficCallbackService.java new file mode 100644 index 00000000..8ba0df6f --- /dev/null +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/TrafficCallbackService.java @@ -0,0 +1,18 @@ +package com.baiye.module.service; + +import com.baiye.model.dto.PushClueDTO; + +/** + * @author Enzo + * @date : 2023/3/2 + */ +public interface TrafficCallbackService { + + /** + * 接收数据 + * + * @param dto + * @return + */ + Boolean callbackByAppKeyAndNid(PushClueDTO dto); +} diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/impl/ClueServiceImpl.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/impl/ClueServiceImpl.java index e24263dc..3e0f06cf 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/impl/ClueServiceImpl.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/impl/ClueServiceImpl.java @@ -1139,6 +1139,24 @@ public class ClueServiceImpl implements ClueService { return map; } + @Override + public Boolean saveSingleClueTalk(String phone, Long taskId, Long userId, String otherSource, Integer numer, Integer zeroNumber, String remark, Long memberId) { + + Clue clue = new Clue(); + NidLocation byPhone = nidLocationService.findByPhone(phone.substring(DefaultNumberConstants.ZERO_NUMBER, DefaultNumberConstants.SEVEN_NUMBER)); + clue.setAddress(ObjectUtil.isNotNull(byPhone) && StringUtils.isNotBlank(byPhone.getProvince()) + && StringUtils.isNotBlank(byPhone.getCity()) ? byPhone.getProvince().concat(byPhone.getCity()) : CharSequenceUtil.EMPTY); + clue.setIsEncryption(DefaultNumberConstants.ONE_NUMBER); + clue.setCastInfo(otherSource); + clue.setCreateBy(userId); + clue.setRouteId(0L); + clue.setNid(phone); + Clue save = clueRepository.save(clue); + ClueTalk clueTalk = new ClueTalk(save.getId(), taskId, zeroNumber, 0, 0, 0, numer, new Date(), memberId); + clueTalk.setRemark(remark); + return clueTalkRepository.save(clueTalk).getClueId() != null; + } + /** * 分配 */ diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/impl/DmpCallbackServiceImpl.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/impl/DmpCallbackServiceImpl.java index da2dc55c..7ccac407 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/impl/DmpCallbackServiceImpl.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/impl/DmpCallbackServiceImpl.java @@ -132,9 +132,11 @@ public class DmpCallbackServiceImpl implements DmpCallbackService { } } // 兑换结果失败也将结果返回 - if (byTaskName.getType() == DefaultNumberConstants.THREE_NUMBER) { - sendRequest(bathNo, tagList, responseList); + if (byTaskName.getType() == DefaultNumberConstants.THREE_NUMBER + || byTaskName.getType() == DefaultNumberConstants.SIX_NUMBER ) { + sendRequest(byTaskName.getType(), bathNo, tagList, responseList); } + } finally { lock.unlock(); } @@ -179,8 +181,8 @@ public class DmpCallbackServiceImpl implements DmpCallbackService { } - private void sendRequest(String taskName, List tagList, List decryptList) { - TripartiteResponseUtil.transmissionParameter(taskName, tagList, decryptList, deliveryProperties.getExchangePassword()); + private void sendRequest(Integer type, String taskName, List tagList, List decryptList) { + TripartiteResponseUtil.transmissionParameter(type, taskName, tagList, decryptList, deliveryProperties.getExchangePassword()); deliveryRecordService.updateStatusByTaskName(DefaultNumberConstants.ONE_NUMBER, decryptList.size(), taskName); } diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/impl/TrafficCallbackServiceImpl.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/impl/TrafficCallbackServiceImpl.java new file mode 100644 index 00000000..461f9a39 --- /dev/null +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/impl/TrafficCallbackServiceImpl.java @@ -0,0 +1,97 @@ +package com.baiye.module.service.impl; + +import cn.hutool.core.codec.Base64; +import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baiye.constant.DefaultNumberConstants; +import com.baiye.constant.SecurityConstants; +import com.baiye.feign.PreTestClient; +import com.baiye.feign.TaskClient; +import com.baiye.model.dto.PushClueDTO; +import com.baiye.model.dto.TelephoneTrafficDTO; +import com.baiye.module.entity.Task; +import com.baiye.module.service.ClueService; +import com.baiye.module.service.TrafficCallbackService; +import com.baiye.util.DecryptPnoUtil; +import com.baiye.util.RedisUtils; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.Map; +import java.util.concurrent.TimeUnit; + +/** + * @author Enzo + * @date : 2022/11/24 + */ + +@Slf4j +@Service +@RequiredArgsConstructor +public class TrafficCallbackServiceImpl implements TrafficCallbackService { + + + private final TaskClient taskClient; + + private final RedisUtils redisUtils; + + private final ClueService clueService; + + private final PreTestClient preTestClient; + + @Override + public Boolean callbackByAppKeyAndNid(PushClueDTO dto) { + + String recId = dto.getRecId(); + String called = dto.getCalled(); + String remark = dto.getRemark(); + String phone = CharSequenceUtil.EMPTY; + String typeName = dto.getEmpClientTypeName(); + if (StringUtils.isNotBlank(dto.getMobile())) { + phone = Base64.decodeStr(dto.getMobile()); + } + // 格式校验 + if (StringUtils.isNotBlank(called) && StringUtils.isNotBlank(typeName) + && "A".equalsIgnoreCase(typeName)) { + phone = called.length() > DefaultNumberConstants.ELEVEN_NUMBER + ? DecryptPnoUtil.decryptPno(called) : called; + } + + if (StringUtils.isNotBlank(phone)) { + Map clientVariables = dto.getClientVariables(); + String taskId = clientVariables.getOrDefault("taskId", CharSequenceUtil.EMPTY); + String sourceId = clientVariables.getOrDefault("sourceId", CharSequenceUtil.EMPTY); + if (CharSequenceUtil.isNotBlank(taskId) && CharSequenceUtil.isNotBlank(sourceId)) { + // 已经存在的不进行操作 + if (StringUtils.isNotBlank(recId) && ObjectUtil.isNotNull(redisUtils.get(recId))) { + // TODO Do not modify for the time being + return Boolean.TRUE; + } + Long id = Long.parseLong(taskId); + Task task = findByTaskId(id); + if (ObjectUtil.isNotNull(task)) { + TelephoneTrafficDTO telephoneTrafficDTO = preTestClient.findByDetail(Long.parseLong(sourceId), SecurityConstants.FROM_IN).getBody(); + if (ObjectUtil.isNotNull(telephoneTrafficDTO)) { + clueService.saveSingleClueTalk + (phone, id, task.getCreateBy(), telephoneTrafficDTO.getOtherSource(), DefaultNumberConstants.NINE_NUMBER, DefaultNumberConstants.ZERO_NUMBER, remark, null); + } + } + if (StringUtils.isNotBlank(recId)) { + // 缓存三天 + redisUtils.set(recId, phone, DefaultNumberConstants.THREE_NUMBER, TimeUnit.DAYS); + } + } + } + return Boolean.TRUE; + } + + public Task findByTaskId(Long taskId) { + Task body = taskClient.queryDetails(taskId, SecurityConstants.FROM_IN).getBody(); + if (body != null) { + return body; + } + return null; + } +} diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/MailSourceTask.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/MailSourceTask.java index 4eb2c532..704b56fc 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/MailSourceTask.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/MailSourceTask.java @@ -129,7 +129,7 @@ public class MailSourceTask { downResource(taskName, byTaskName, decryptList, path, data.getRows(), parseFile); } if (byTaskName.getType() == DefaultNumberConstants.THREE_NUMBER) { - sendRequest(taskName, tagList, decryptList, path, unzipPath); + sendRequest(byTaskName.getType(), taskName, tagList, decryptList, path, unzipPath); } FileUtil.del(path); } @@ -178,8 +178,8 @@ public class MailSourceTask { deliveryRecordClient.updatePath(path, deliveryProperties.getDmpDownPath().concat(filePath), byTaskName.getDownId(), SecurityConstants.FROM_IN); } - private void sendRequest(String taskName, List tagList, List decryptList, String path, String unzipPath) { - TripartiteResponseUtil.transmissionParameter(taskName, tagList, decryptList, deliveryProperties.getExchangePassword()); + private void sendRequest(Integer type, String taskName, List tagList, List decryptList, String path, String unzipPath) { + TripartiteResponseUtil.transmissionParameter(type, taskName, tagList, decryptList, deliveryProperties.getExchangePassword()); deliveryRecordService.updateStatusByTaskName(DefaultNumberConstants.ONE_NUMBER, decryptList.size(), taskName); log.info("============== message parsing succeeded file path as {} unzip path as {} ===============", path, unzipPath); } diff --git a/ad-platform-services/ad-platform-source/src/main/resources/application-dev.yml b/ad-platform-services/ad-platform-source/src/main/resources/application-dev.yml index e7516b14..99f2f6bb 100644 --- a/ad-platform-services/ad-platform-source/src/main/resources/application-dev.yml +++ b/ad-platform-services/ad-platform-source/src/main/resources/application-dev.yml @@ -5,7 +5,8 @@ spring: discovery: # server-addr: ${NACOS_HOST:8.130.96.163}:${NACOS_PORT:8848} server-addr: ${NACOS_HOST:localhost}:${NACOS_PORT:8848} - + jpa: + show-sql: false redis: database: 2 host: 39.100.77.21 @@ -73,7 +74,7 @@ storage: download-template: /usr/local/webapp/ad-platform/ad-platform-source/custom.xlsx download-template-move: /usr/local/webapp/ad-platform/ad-platform-source/dynamictemplate.xlsx download-template-toker: /usr/local/webapp/ad-platform/ad-platform-source/toker.xlsx - download-auditing-file: http:///39.100.77.21:8001/source/auditingFiles/ + download-auditing-file: http://39.100.77.21:8001/source/auditingFiles/ private-key: C:\Users\Admin\Desktop\ # 线程池配置 @@ -89,3 +90,4 @@ logstash: url: 39.100.77.21:9601 + diff --git a/ad-platform-services/ad-platform-source/src/main/resources/application-prod.yml b/ad-platform-services/ad-platform-source/src/main/resources/application-prod.yml index 9ca4e8cf..f105576f 100644 --- a/ad-platform-services/ad-platform-source/src/main/resources/application-prod.yml +++ b/ad-platform-services/ad-platform-source/src/main/resources/application-prod.yml @@ -96,3 +96,5 @@ platform: logstash: url: 127.0.0.1:5044 + + diff --git a/ad-platform-services/ad-platform-source/src/main/resources/application.yml b/ad-platform-services/ad-platform-source/src/main/resources/application.yml index caa5de96..f91aacbd 100644 --- a/ad-platform-services/ad-platform-source/src/main/resources/application.yml +++ b/ad-platform-services/ad-platform-source/src/main/resources/application.yml @@ -54,6 +54,7 @@ security: - /open/v1/form/add - /dmp/v1/exchange/callback - /gender/exchange/v1/callback + - /traffic/v1/exchange/callback #hutool雪花算法 snowflake: