压缩tf文件

master
wjt 1 year ago
parent 28b9d70c6c
commit 3bda0c02ca

@ -72,7 +72,11 @@
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>22.0</version> <version>22.0</version>
</dependency> </dependency>
<dependency>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

@ -4,7 +4,6 @@ import cn.hutool.core.util.StrUtil;
import com.baiyee.adcallback.api.common.CommonResponse; import com.baiyee.adcallback.api.common.CommonResponse;
import com.baiyee.adcallback.api.vo.*; import com.baiyee.adcallback.api.vo.*;
import com.baiyee.adcallback.service.AdOriginalityManageService; import com.baiyee.adcallback.service.AdOriginalityManageService;
import com.baiyee.adcallback.service.AdTFPackageService;
import com.baiyee.adcallback.tools.CheckPlatPointParamsUtil; import com.baiyee.adcallback.tools.CheckPlatPointParamsUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -13,9 +12,9 @@ import org.springframework.web.bind.annotation.RestController;
/** /**
* 2023-5-18 * 2023-5-18
* * <p>
* *
* * <p>
* : * :
* 广, 广, , * 广, 广, ,
* *
@ -30,17 +29,14 @@ public class MobileMonitorCallbackNewAPI {
private final AdOriginalityManageService originalityManageService; private final AdOriginalityManageService originalityManageService;
private final AdTFPackageService adTFPackageService; public MobileMonitorCallbackNewAPI(AdOriginalityManageService originalityManageService) {
public MobileMonitorCallbackNewAPI(AdOriginalityManageService originalityManageService, AdTFPackageService adTFPackageService) {
this.originalityManageService = originalityManageService; this.originalityManageService = originalityManageService;
this.adTFPackageService = adTFPackageService;
} }
/** /**
* V2-广 * V2-广
* * <p>
* *
* promotion_id=__PROMOTION_ID__&project_id=__PROJECT_ID__&promotion_name=__PROMOTION_NAME__&project_name=__PROJECT_NAME__&mid1=__MID1__&mid2=__MID2__&mid3=__MID3__&mid4=__MID4__&mid5=__MID5__&mid6=__MID6__&csite=__CSITE__&convert_id=__CONVERT_ID__&request_id=__REQUEST_ID__&track_id=__TRACK_ID__&os=__OS__&ua=__UA__&geo=__GEO__&ts=__TS__&model=__MODEL__&imei=__IMEI__&idfa=__IDFA__&idfa_md5=__IDFA_MD5__&oaid=__OAID__&oaid_md5=__OAID_MD5__&mac=__MAC__&callback_param=__CALLBACK_PARAM__&callback_url=__CALLBACK_URL__&advertiser_id=__ADVERTISER_ID__&tag=&vpoint= * promotion_id=__PROMOTION_ID__&project_id=__PROJECT_ID__&promotion_name=__PROMOTION_NAME__&project_name=__PROJECT_NAME__&mid1=__MID1__&mid2=__MID2__&mid3=__MID3__&mid4=__MID4__&mid5=__MID5__&mid6=__MID6__&csite=__CSITE__&convert_id=__CONVERT_ID__&request_id=__REQUEST_ID__&track_id=__TRACK_ID__&os=__OS__&ua=__UA__&geo=__GEO__&ts=__TS__&model=__MODEL__&imei=__IMEI__&idfa=__IDFA__&idfa_md5=__IDFA_MD5__&oaid=__OAID__&oaid_md5=__OAID_MD5__&mac=__MAC__&callback_param=__CALLBACK_PARAM__&callback_url=__CALLBACK_URL__&advertiser_id=__ADVERTISER_ID__&tag=&vpoint=
*/ */
@ -97,18 +93,13 @@ public class MobileMonitorCallbackNewAPI {
originalityManageService.handleNewJLV2MonitorUrlCallbackDataThenSave(vo); originalityManageService.handleNewJLV2MonitorUrlCallbackDataThenSave(vo);
} }
// 校验以下参数是否存在 - 入投放包库 - 部分字段
if (CheckPlatPointParamsUtil.checkMainParamForPut(vo.getOaid(), vo.getOaidMD5(), vo.getImei(), null,vo.getIdfa(), vo.getIdfaMD5(), vo.getMac())){
adTFPackageService.loadJLTFV2PackageData(vo);
}
return CommonResponse.createBySuccess(); return CommonResponse.createBySuccess();
} }
/** /**
* V1-广1.0 * V1-广1.0
* * <p>
* *
* aid=__AID__&aid_name=__AID_NAME__&cid=__CID__&cid_name=__CID_NAME__&campaign_id=__CAMPAIGN_ID__&campaign_name=__CAMPAIGN_NAME__&ctype=__CTYPE__&csite=__CSITE__&convert_id=__CONVERT_ID__&request_id=__REQUEST_ID__&track_id=__TRACK_ID__&os=__OS__&ua=__UA__&geo=__GEO__&ts=__TS__&model=__MODEL__&imei=__IMEI__&idfa=__IDFA__&idfa_md5=__IDFA_MD5__&oaid=__OAID__&oaid_md5=__OAID_MD5__&mac=__MAC__&callback_param=__CALLBACK_PARAM__&callback_url=__CALLBACK_URL__&advertiser_id=__ADVERTISER_ID__&tag=&vpoint= * aid=__AID__&aid_name=__AID_NAME__&cid=__CID__&cid_name=__CID_NAME__&campaign_id=__CAMPAIGN_ID__&campaign_name=__CAMPAIGN_NAME__&ctype=__CTYPE__&csite=__CSITE__&convert_id=__CONVERT_ID__&request_id=__REQUEST_ID__&track_id=__TRACK_ID__&os=__OS__&ua=__UA__&geo=__GEO__&ts=__TS__&model=__MODEL__&imei=__IMEI__&idfa=__IDFA__&idfa_md5=__IDFA_MD5__&oaid=__OAID__&oaid_md5=__OAID_MD5__&mac=__MAC__&callback_param=__CALLBACK_PARAM__&callback_url=__CALLBACK_URL__&advertiser_id=__ADVERTISER_ID__&tag=&vpoint=
*/ */
@ -161,17 +152,12 @@ public class MobileMonitorCallbackNewAPI {
originalityManageService.handleNewJLV1MonitorUrlCallbackDataThenSave(vo); originalityManageService.handleNewJLV1MonitorUrlCallbackDataThenSave(vo);
} }
// 校验以下参数是否存在 - 入投放包库 - 部分字段
if (CheckPlatPointParamsUtil.checkMainParamForPut(vo.getOaid(), vo.getOaidMD5(), vo.getImei(), null,vo.getIdfa(), vo.getIdfaMD5(), vo.getMac())){
adTFPackageService.loadJLTFV1PackageData(vo);
}
return CommonResponse.createBySuccess(); return CommonResponse.createBySuccess();
} }
/** /**
* *
* * <p>
* https://developers.e.kuaishou.com/docs?docType=DSP&documentId=1938 * https://developers.e.kuaishou.com/docs?docType=DSP&documentId=1938
*/ */
@RequestMapping(value = "/ks/new/monitor") @RequestMapping(value = "/ks/new/monitor")
@ -218,17 +204,12 @@ public class MobileMonitorCallbackNewAPI {
originalityManageService.handleNewKSMonitorUrlCallbackDataThenSave(vo); originalityManageService.handleNewKSMonitorUrlCallbackDataThenSave(vo);
} }
// 校验以下参数是否存在 - 入投放包库 - 部分字段
if (CheckPlatPointParamsUtil.checkMainParamForPut(vo.getOaid(), null, vo.getImei(), null,vo.getIdfa(), null, vo.getMac())){
adTFPackageService.loadKSTFPackageData(vo);
}
return CommonResponse.createBySuccess(); return CommonResponse.createBySuccess();
} }
/** /**
* *
* * <p>
* http://www.test.com/notice?tag=test123&imei_md5={{IMEI_MD5}}&os={{OS}}&ip={{IP}}&ua={{UA}}&ts={{TS}}&userid={{USER_ID}}&pid={{PLAN_ID}}&uid={{UNIT_ID}}&aid={{IDEA_ID}}&click_id={{CLICK_ID}}&callback_url={{CALLBACK_URL}} * http://www.test.com/notice?tag=test123&imei_md5={{IMEI_MD5}}&os={{OS}}&ip={{IP}}&ua={{UA}}&ts={{TS}}&userid={{USER_ID}}&pid={{PLAN_ID}}&uid={{UNIT_ID}}&aid={{IDEA_ID}}&click_id={{CLICK_ID}}&callback_url={{CALLBACK_URL}}
*/ */
@RequestMapping(value = "/bd/new/monitor") @RequestMapping(value = "/bd/new/monitor")
@ -273,18 +254,13 @@ public class MobileMonitorCallbackNewAPI {
originalityManageService.handleNewBDTMonitorUrlCallbackDataThenSave(vo); originalityManageService.handleNewBDTMonitorUrlCallbackDataThenSave(vo);
} }
// 校验以下参数是否存在 - 入投放包库 - 部分字段
if (CheckPlatPointParamsUtil.checkMainParamForPut(vo.getOaid(), vo.getOaidMD5(), null, vo.getImei(),vo.getIdfa(), null, vo.getMac())){
adTFPackageService.loadBDPackageData(vo);
}
return CommonResponse.createBySuccess(); return CommonResponse.createBySuccess();
} }
/** /**
* 广 * 广
* * <p>
* API : https://developers.e.qq.com/docs/guide/conversion/new_version/dianjijiance * API : https://developers.e.qq.com/docs/guide/conversion/new_version/dianjijiance
*/ */
@RequestMapping(value = "/gdt/new/monitor") @RequestMapping(value = "/gdt/new/monitor")
@ -345,11 +321,6 @@ public class MobileMonitorCallbackNewAPI {
originalityManageService.handleNewGDTMonitorUrlCallbackDataThenSave(vo); originalityManageService.handleNewGDTMonitorUrlCallbackDataThenSave(vo);
} }
// 校验以下参数是否存在 - 入投放包库 - 部分字段
if (CheckPlatPointParamsUtil.checkMainParamForPut(vo.getOaid(), null, vo.getMuid(), null,vo.getMuid(), null, vo.getMac())){
adTFPackageService.loadGDTPackageData(vo);
}
return CommonResponse.createBySuccess(); return CommonResponse.createBySuccess();
} }

@ -0,0 +1,46 @@
package com.baiyee.adcallback.api.dto;
import lombok.Data;
/**
* @author wjt
* @date 2023/5/31
*/
@Data
public class TfSourceDTO {
/**
*
*/
private String clickTime;
/**
* '广'
*/
private String adName;
/**
* 'id'
*/
private String imei;
/**
* 'id'
*/
private String idfa;
/**
* mac
*/
private String mac;
/**
* ''
*/
private String oaid;
/**
* ''
*/
private String tag;
/**
* '广'
*/
private Integer vpoint;
}

@ -36,8 +36,18 @@ public enum TableEnum {
/** /**
* 广 * 广
*/ */
GD("tb_gdt_backdata"); GD("tb_gdt_backdata"),
JL1("tb_jl_v1_backdata"),
JL2("tb_jl_v2_backdata"),
GDT_NEW("tb_gdt_new_backdata"),
KS_NEW("tb_ks_new_backdata"),
BD_NEW("tb_bd_new_backdata"),
;
/** /**
* *
*/ */

@ -2,7 +2,6 @@ package com.baiyee.adcallback.repository;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import com.baiyee.adcallback.api.dto.PlateFormDTO; import com.baiyee.adcallback.api.dto.PlateFormDTO;
import com.baiyee.adcallback.repository.entity.TbBdBackdataEntity;
import com.baiyee.adcallback.repository.entity.TbBdNewBackdataEntity; import com.baiyee.adcallback.repository.entity.TbBdNewBackdataEntity;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
@ -29,4 +28,7 @@ public interface TbBDNewBackdataEntityRepository extends JpaRepository<TbBdNewBa
" TbBdBackdataEntity where imei != :imeiStrFirst and imei != :imeiSecond " + " TbBdBackdataEntity where imei != :imeiStrFirst and imei != :imeiSecond " +
"and gmtCreate >= :startDate and gmtCreate < :endDate and tag in :tag group by imei,tag") "and gmtCreate >= :startDate and gmtCreate < :endDate and tag in :tag group by imei,tag")
List<PlateFormDTO> queryPlateFormDTO(@Param("imeiStrFirst") String imeiStrFirst, @Param("imeiSecond") String imeiSecond, @Param("startDate") DateTime startDate, @Param("endDate") DateTime endDate, @Param("tag") List<String> tag); List<PlateFormDTO> queryPlateFormDTO(@Param("imeiStrFirst") String imeiStrFirst, @Param("imeiSecond") String imeiSecond, @Param("startDate") DateTime startDate, @Param("endDate") DateTime endDate, @Param("tag") List<String> tag);
@Query(value = "SELECT * FROM tb_bd_new_backdata WHERE imei != '' AND imei != '__imei__' AND gmt_create > ?1 AND gmt_create < ?2", nativeQuery = true)
List<TbBdNewBackdataEntity> queryByDate(String startDate, String endDate);
} }

@ -2,7 +2,6 @@ package com.baiyee.adcallback.repository;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import com.baiyee.adcallback.api.dto.PlateFormDTO; import com.baiyee.adcallback.api.dto.PlateFormDTO;
import com.baiyee.adcallback.repository.entity.TbGdtBackdataEntity;
import com.baiyee.adcallback.repository.entity.TbGdtNewBackdataEntity; import com.baiyee.adcallback.repository.entity.TbGdtNewBackdataEntity;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
@ -17,6 +16,7 @@ public interface TbGdtNewBackdataEntityRepository extends JpaRepository<TbGdtNew
/** /**
* *
*
* @param imeiStrFirst * @param imeiStrFirst
* @param imeiSecond * @param imeiSecond
* @param startDate * @param startDate
@ -29,4 +29,7 @@ public interface TbGdtNewBackdataEntityRepository extends JpaRepository<TbGdtNew
" TbGdtBackdataEntity where muid != :imeiStrFirst and muid != :imeiSecond " + " TbGdtBackdataEntity where muid != :imeiStrFirst and muid != :imeiSecond " +
"and gmtCreate >= :startDate and gmtCreate < :endDate and tag in :tag and deviceOsType = :models group by muid,tag") "and gmtCreate >= :startDate and gmtCreate < :endDate and tag in :tag and deviceOsType = :models group by muid,tag")
List<PlateFormDTO> queryPlateFormDTO(@Param("imeiStrFirst") String imeiStrFirst, @Param("imeiSecond") String imeiSecond, @Param("startDate") DateTime startDate, @Param("endDate") DateTime endDate, @Param("tag") List<String> tag, @Param("models") String models); List<PlateFormDTO> queryPlateFormDTO(@Param("imeiStrFirst") String imeiStrFirst, @Param("imeiSecond") String imeiSecond, @Param("startDate") DateTime startDate, @Param("endDate") DateTime endDate, @Param("tag") List<String> tag, @Param("models") String models);
@Query(value = "SELECT * FROM tb_gdt_new_backdata WHERE imei != '' AND imei != '__imei__' AND gmt_create > ?1 AND gmt_create < ?2", nativeQuery = true)
List<TbGdtNewBackdataEntity> queryByDate(String startDate, String endDate);
} }

@ -36,4 +36,6 @@ public interface TbJLV1BackdataEntityRepository extends JpaRepository<TbJLBackDa
"and gmtCreate >= :startDate and gmtCreate < :endDate and tag in :tag group by imei,tag") "and gmtCreate >= :startDate and gmtCreate < :endDate and tag in :tag group by imei,tag")
List<PlateFormDTO> queryPlateFormDTO(@Param("imeiStrFirst") String imeiStrFirst, @Param("imeiSecond") String imeiSecond, @Param("startDate") DateTime startDate, @Param("endDate") DateTime endDate, @Param("tag") List<String> tag); List<PlateFormDTO> queryPlateFormDTO(@Param("imeiStrFirst") String imeiStrFirst, @Param("imeiSecond") String imeiSecond, @Param("startDate") DateTime startDate, @Param("endDate") DateTime endDate, @Param("tag") List<String> tag);
@Query(value = "SELECT * FROM tb_jl_v1_backdata WHERE imei != '' AND imei != '__IMEI__' AND gmt_create > ?1 AND gmt_create < ?2", nativeQuery = true)
List<TbJLBackDataV1Entity> queryByDate(String startDate, String endDate);
} }

@ -21,6 +21,8 @@ public interface TbJLV2BackdataEntityRepository extends JpaRepository<TbJLBackDa
@Query(value = "SELECT imei FROM tb_jl_v2_backdata WHERE imei != '' AND imei != '__IMEI__' AND gmt_create > :startDate AND gmt_create < :endDate", nativeQuery = true) @Query(value = "SELECT imei FROM tb_jl_v2_backdata WHERE imei != '' AND imei != '__IMEI__' AND gmt_create > :startDate AND gmt_create < :endDate", nativeQuery = true)
List<String> queryAllImeiByDate(Date startDate, Date endDate); List<String> queryAllImeiByDate(Date startDate, Date endDate);
@Query(value = "SELECT * FROM tb_jl_v2_backdata WHERE imei != '' AND imei != '__IMEI__' AND gmt_create > ?1 AND gmt_create < ?2", nativeQuery = true)
List<TbJLBackDataV2Entity> queryByDate(String startDate, String endDate);
/** /**
* *

@ -3,7 +3,6 @@ package com.baiyee.adcallback.repository;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import com.baiyee.adcallback.api.dto.PlateFormDTO; import com.baiyee.adcallback.api.dto.PlateFormDTO;
import com.baiyee.adcallback.repository.entity.TbKSNewBackdataEntity; import com.baiyee.adcallback.repository.entity.TbKSNewBackdataEntity;
import com.baiyee.adcallback.repository.entity.TbKsBackdataEntity;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
@ -17,6 +16,7 @@ public interface TbKSNewBackdataEntityRepository extends JpaRepository<TbKSNewBa
/** /**
* *
*
* @param imeiStrFirst * @param imeiStrFirst
* @param imeiSecond * @param imeiSecond
* @param startDate * @param startDate
@ -28,4 +28,7 @@ public interface TbKSNewBackdataEntityRepository extends JpaRepository<TbKSNewBa
" TbKsBackdataEntity where imei != :imeiStrFirst and imei != :imeiSecond " + " TbKsBackdataEntity where imei != :imeiStrFirst and imei != :imeiSecond " +
"and gmtCreate >= :startDate and gmtCreate < :endDate and tag in :tag group by imei,tag") "and gmtCreate >= :startDate and gmtCreate < :endDate and tag in :tag group by imei,tag")
List<PlateFormDTO> queryPlateFormDTO(@Param("imeiStrFirst") String imeiStrFirst, @Param("imeiSecond") String imeiSecond, @Param("startDate") DateTime startDate, @Param("endDate") DateTime endDate, @Param("tag") List<String> tag); List<PlateFormDTO> queryPlateFormDTO(@Param("imeiStrFirst") String imeiStrFirst, @Param("imeiSecond") String imeiSecond, @Param("startDate") DateTime startDate, @Param("endDate") DateTime endDate, @Param("tag") List<String> tag);
@Query(value = "SELECT * FROM tb_ks_new_backdata WHERE imei != '' AND imei != '__imei__' AND gmt_create > ?1 AND gmt_create < ?2", nativeQuery = true)
List<TbKSNewBackdataEntity> queryByDate(String startDate, String endDate);
} }

@ -0,0 +1,11 @@
package com.baiyee.adcallback.repository;
import com.baiyee.adcallback.repository.entity.TbTfSourceEntity;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @author wjt
* @date 2023/5/31
*/
public interface TbTfSourceEntityRepository extends JpaRepository<TbTfSourceEntity, Long> {
}

@ -0,0 +1,89 @@
package com.baiyee.adcallback.repository.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* @author wjt
* @date 2023/5/31
*/
@Data
@Entity
@Table(name = "tb_tf_source", schema = "db_ad")
@EntityListeners(AuditingEntityListener.class)
public class TbTfSourceEntity implements Serializable {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "gmt_create")
@CreatedDate
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date gmtCreate;
@Column(name = "gmt_modified")
@LastModifiedDate
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date gmtModified;
@LastModifiedBy
@Column(name = "operator")
private String operator;
@Column(name = "produce_time")
private String produceTime;
@Column(name = "ad_name")
private String adName;
@Column(name = "category")
private String category;
@Column(name = "file_name")
private String fileName;
@Column(name = "file_path")
private String filePath;
@Column(name = "file_pwd")
private String filePwd;
/**
* , 1- 2- 3- 4-
*/
@Column(name = "file_status")
private Integer fileStatus;
@Column(name = "last_operator_time")
@LastModifiedDate
private Date lastOperatorTime;
@Column(name = "weight")
private Integer weight;
public TbTfSourceEntity addTbTfSourceEntity(String produceTime, String adName, String category, String fileName, String filePath, String filePwd) {
this.setProduceTime(produceTime);
this.setAdName(adName);
this.setCategory(category);
this.setFileName(fileName);
this.setFilePath(filePath);
this.setFilePwd(filePwd);
this.setFileStatus(2);
this.setWeight(0);
return this;
}
}

@ -1,17 +0,0 @@
package com.baiyee.adcallback.service;
import com.baiyee.adcallback.api.vo.*;
public interface AdTFPackageService {
void loadBDPackageData(BDMobileMonitorCallbackRequestNewVO vo);
void loadGDTPackageData(GdtMobileMonitorCallbackRequestNewVO vo);
void loadJLTFV1PackageData(JuliangMobileMonitorCallbackRequestNewV1VO vo);
void loadJLTFV2PackageData(JuliangMobileMonitorCallbackRequestNewV2VO vo);
void loadKSTFPackageData(KSNewMobileMonitorCallbackRequestVO vo);
}

@ -1,54 +0,0 @@
package com.baiyee.adcallback.service.impl;
import com.baiyee.adcallback.api.constants.VpointEnum;
import com.baiyee.adcallback.api.vo.*;
import com.baiyee.adcallback.service.AdTFPackageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class AdJLTFPackageServiceImpl implements AdTFPackageService {
@Override
public void loadBDPackageData(BDMobileMonitorCallbackRequestNewVO vo) {
// log - 埋点
log.info("================================= [finish check, do data loading, AdJLTFPackageServiceImpl|loadBDPackageData, tag is {} , vpoint is {}] =================================",
vo.getTag(), VpointEnum.vPointCodeConvertStatus(vo.getVpoint()));
// TODO: 2023/5/26 0026
}
@Override
public void loadKSTFPackageData(KSNewMobileMonitorCallbackRequestVO vo) {
// log - 埋点
log.info("================================= [finish check, do data loading, AdJLTFPackageServiceImpl|loadKSTFPackageData, tag is {} , vpoint is {}] =================================",
vo.getTag(), VpointEnum.vPointCodeConvertStatus(vo.getVpoint()));
// TODO: 2023/5/26 0026
}
@Override
public void loadGDTPackageData(GdtMobileMonitorCallbackRequestNewVO vo) {
// log - 埋点
log.info("================================= [finish check, do data loading, AdJLTFPackageServiceImpl|loadGDTPackageData, tag is {} , vpoint is {}] =================================",
vo.getTag(), VpointEnum.vPointCodeConvertStatus(vo.getVpoint()));
// TODO: 2023/5/26 0026
}
@Override
public void loadJLTFV1PackageData(JuliangMobileMonitorCallbackRequestNewV1VO vo) {
// log - 埋点
log.info("================================= [finish check, do data loading, AdJLTFPackageServiceImpl|loadJLTFV1PackageData, tag is {} , vpoint is {}] =================================",
vo.getTag(), VpointEnum.vPointCodeConvertStatus(vo.getVpoint()));
// TODO: 2023/5/18 0018
}
@Override
public void loadJLTFV2PackageData(JuliangMobileMonitorCallbackRequestNewV2VO vo) {
// log - 埋点
log.info("================================= [finish check, do data loading, AdJLTFPackageServiceImpl|loadJLTFV2PackageData, tag is {} , vpoint is {}] =================================",
vo.getTag(), VpointEnum.vPointCodeConvertStatus(vo.getVpoint()));
// TODO: 2023/5/18 0018
}
}

@ -0,0 +1,181 @@
package com.baiyee.adcallback.task;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.csv.CsvWriter;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.baiyee.adcallback.api.dto.TfSourceDTO;
import com.baiyee.adcallback.common.util.FileUtil;
import com.baiyee.adcallback.repository.*;
import com.baiyee.adcallback.repository.entity.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import net.lingala.zip4j.model.ZipParameters;
import net.lingala.zip4j.util.Zip4jConstants;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author wjt
* @date 2023/5/31
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class TfSourceTask {
private final TbJLV2BackdataEntityRepository tbJLV2BackdataEntityRepository;
private final TbJLV1BackdataEntityRepository tbJLV1BackdataEntityRepository;
private final TbGdtNewBackdataEntityRepository tbGdtNewBackdataEntityRepository;
private final TbKSNewBackdataEntityRepository tbKSNewBackdataEntityRepository;
private final TbBDNewBackdataEntityRepository tbBDNewBackdataEntityRepository;
private final TbTfSourceEntityRepository tbTfSourceEntityRepository;
@Value("${tf.source.path}")
private String path;
/**
* 23 30
* <p>
*
*/
@Scheduled(cron = "0 30 23 * * ? ")
@Transactional(rollbackFor = Exception.class)
public void tfSource() {
log.info("++++++++++++++++++++++TfSource Sync start time {} ++++++++++++++++", DateUtil.now());
String startTime = DateUtil.format(DateUtil.date(), "yyyy-MM-dd 00:00:00");
String endTime = DateUtil.format(DateUtil.date(), "yyyy-MM-dd 23:59:59");
List<TfSourceDTO> list = new ArrayList<>();
//jlv2
obtainDateByJlV2(startTime, endTime, list);
//jlv1
obtainDateByJlv1(startTime, endTime, list);
//gdt
obtainDateByGdt(startTime, endTime, list);
//ks
obtainDateByKs(startTime, endTime, list);
//bd
obtainDateByBd(startTime, endTime, list);
if (CollUtil.isEmpty(list)) {
return;
}
//tag分组
HashMap<String, List<TfSourceDTO>> mapByTag = new HashMap<>(list.stream().collect(Collectors.groupingBy(TfSourceDTO::getTag, Collectors.toList())));
String format = DateUtil.format(DateUtil.date(), "yyyy-MM-dd");
List<TbTfSourceEntity> saveList = new ArrayList<>();
for (String tag : mapByTag.keySet()) {
String password = RandomUtil.randomString(6);
//压缩文件
String filePath = generateFile(tag, format, password, mapByTag.get(tag));
if (StrUtil.isNotBlank(filePath)) {
//保存文件记录
TbTfSourceEntity tbTfSourceEntity = new TbTfSourceEntity().addTbTfSourceEntity(format, null, null, tag, filePath, password);
saveList.add(tbTfSourceEntity);
}
}
tbTfSourceEntityRepository.saveAll(saveList);
log.info("++++++++++++++++++++++TfSource Sync end time {} ++++++++++++++++", DateUtil.now());
}
/**
*
*
* @param tag
* @param list
*/
private String generateFile(String tag, String format, String password, List<TfSourceDTO> list) {
String filePath = path + format;
File file = new File(filePath + File.separator + tag + ".csv");
CsvWriter writer = new CsvWriter(file, StandardCharsets.UTF_8);
writer.writeBeans(list);
writer.flush();
writer.close();
return zipFile(file, filePath + File.separator + tag + ".zip", password);
}
/**
*
*
* @param srcFile
* @param newPath
* @param password
*/
private String zipFile(File srcFile, String newPath, String password) {
ZipParameters zipParameters = new ZipParameters();
zipParameters.setEncryptionMethod(Zip4jConstants.COMP_DEFLATE);
zipParameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
if (StrUtil.isNotBlank(password)) {
zipParameters.setEncryptFiles(true);
zipParameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_STANDARD);
zipParameters.setPassword(password.toCharArray());
}
try {
ZipFile zipFile = new ZipFile(newPath);
if (srcFile.isDirectory()) {
zipFile.addFolder(srcFile, zipParameters);
} else {
zipFile.addFile(srcFile, zipParameters);
}
FileUtil.del(srcFile);
return newPath;
} catch (ZipException e) {
e.printStackTrace();
}
return null;
}
private void obtainDateByJlV2(String startTime, String endTime, List<TfSourceDTO> list) {
List<TbJLBackDataV2Entity> jlV2Data = tbJLV2BackdataEntityRepository.queryByDate(startTime, endTime);
if (CollUtil.isNotEmpty(jlV2Data)) {
List<TfSourceDTO> tfSourceDTOS = Convert.toList(TfSourceDTO.class, jlV2Data);
list.addAll(tfSourceDTOS);
}
}
private void obtainDateByJlv1(String startTime, String endTime, List<TfSourceDTO> list) {
List<TbJLBackDataV1Entity> jlV1Data = tbJLV1BackdataEntityRepository.queryByDate(startTime, endTime);
if (CollUtil.isNotEmpty(jlV1Data)) {
List<TfSourceDTO> tfSourceDTOS = Convert.toList(TfSourceDTO.class, jlV1Data);
list.addAll(tfSourceDTOS);
}
}
private void obtainDateByGdt(String startTime, String endTime, List<TfSourceDTO> list) {
List<TbGdtNewBackdataEntity> jlV2Data = tbGdtNewBackdataEntityRepository.queryByDate(startTime, endTime);
if (CollUtil.isNotEmpty(jlV2Data)) {
List<TfSourceDTO> tfSourceDTOS = Convert.toList(TfSourceDTO.class, jlV2Data);
list.addAll(tfSourceDTOS);
}
}
private void obtainDateByKs(String startTime, String endTime, List<TfSourceDTO> list) {
List<TbKSNewBackdataEntity> jlV2Data = tbKSNewBackdataEntityRepository.queryByDate(startTime, endTime);
if (CollUtil.isNotEmpty(jlV2Data)) {
List<TfSourceDTO> tfSourceDTOS = Convert.toList(TfSourceDTO.class, jlV2Data);
list.addAll(tfSourceDTOS);
}
}
private void obtainDateByBd(String startTime, String endTime, List<TfSourceDTO> list) {
List<TbBdNewBackdataEntity> jlV2Data = tbBDNewBackdataEntityRepository.queryByDate(startTime, endTime);
if (CollUtil.isNotEmpty(jlV2Data)) {
List<TfSourceDTO> tfSourceDTOS = Convert.toList(TfSourceDTO.class, jlV2Data);
list.addAll(tfSourceDTOS);
}
}
}

@ -43,3 +43,6 @@ spring:
wall: wall:
config: config:
multi-statement-allow: true multi-statement-allow: true
tf:
source:
path: /home/www/ad-bak/source/

@ -47,3 +47,7 @@ spring:
platform: platform:
authToken: nqJpVSf3UcrEcVIH authToken: nqJpVSf3UcrEcVIH
url: https://baiyee.vip/api/taskImei/callback/add url: https://baiyee.vip/api/taskImei/callback/add
tf:
source:
path: /home/www/ad-bak/source/
Loading…
Cancel
Save