|
@@ -1,7 +1,6 @@
|
|
package org.jeecg.modules.ctop.service.impl;
|
|
package org.jeecg.modules.ctop.service.impl;
|
|
|
|
|
|
import cn.com.ctop.common.utils.CsvUtils;
|
|
import cn.com.ctop.common.utils.CsvUtils;
|
|
-import cn.com.ctop.common.utils.OSSUtils;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import org.apache.http.client.ClientProtocolException;
|
|
import org.apache.http.client.ClientProtocolException;
|
|
@@ -19,12 +18,12 @@ import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.jeecg.common.util.ResultMapUtils;
|
|
import org.jeecg.common.util.ResultMapUtils;
|
|
import org.jeecg.common.util.StatusCode;
|
|
import org.jeecg.common.util.StatusCode;
|
|
-import org.jeecg.modules.ctop.entity.CTopOauthToken;
|
|
|
|
|
|
+import org.jeecg.modules.ctop.entity.CtopOauthToken;
|
|
import org.jeecg.modules.ctop.entity.CustomerPlanStatisticInfo;
|
|
import org.jeecg.modules.ctop.entity.CustomerPlanStatisticInfo;
|
|
import org.jeecg.modules.ctop.entity.PlatformCampaignStatisticInfo;
|
|
import org.jeecg.modules.ctop.entity.PlatformCampaignStatisticInfo;
|
|
import org.jeecg.modules.ctop.mapper.CustomerPlanStatisticInfoMapper;
|
|
import org.jeecg.modules.ctop.mapper.CustomerPlanStatisticInfoMapper;
|
|
import org.jeecg.modules.ctop.mapper.PlatformCampaignStatisticInfoMapper;
|
|
import org.jeecg.modules.ctop.mapper.PlatformCampaignStatisticInfoMapper;
|
|
-import org.jeecg.modules.ctop.service.ICTopOauthTokenService;
|
|
|
|
|
|
+import org.jeecg.modules.ctop.service.ICtopOauthTokenService;
|
|
import org.jeecg.modules.ctop.service.ICustomerPlanStatisticInfoService;
|
|
import org.jeecg.modules.ctop.service.ICustomerPlanStatisticInfoService;
|
|
import org.jeecg.modules.ctop.service.IPlatformCampaignStatisticInfoService;
|
|
import org.jeecg.modules.ctop.service.IPlatformCampaignStatisticInfoService;
|
|
import org.jeecg.modules.ctop.service.IReportService;
|
|
import org.jeecg.modules.ctop.service.IReportService;
|
|
@@ -34,6 +33,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.*;
|
|
import java.io.*;
|
|
|
|
+import java.math.BigDecimal;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.URI;
|
|
import java.net.URI;
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
@@ -45,6 +45,21 @@ import java.util.Map;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class ReportServiceImpl implements IReportService {
|
|
public class ReportServiceImpl implements IReportService {
|
|
|
|
+ @Value("${jeecg.path.csv-upload}")
|
|
|
|
+ private String csvUploadPath;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IPlatformCampaignStatisticInfoService platformCampaignStatisticInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICustomerPlanStatisticInfoService customerPlanStatisticInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private PlatformCampaignStatisticInfoMapper statisticInfoMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private CustomerPlanStatisticInfoMapper customerPlanStatisticInfoMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private PlatformCampaignStatisticInfoMapper platformCampaignStatisticInfoMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICtopOauthTokenService tokenService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> getAdvertiserReport(JSONObject conditions) {
|
|
public Map<String, Object> getAdvertiserReport(JSONObject conditions) {
|
|
conditions = new JSONObject();
|
|
conditions = new JSONObject();
|
|
@@ -55,7 +70,7 @@ public class ReportServiceImpl implements IReportService {
|
|
conditions.put("page", 1);
|
|
conditions.put("page", 1);
|
|
Long accountId = conditions.getLong("advertiser_id");
|
|
Long accountId = conditions.getLong("advertiser_id");
|
|
// Long accountId = 74099510334L;
|
|
// Long accountId = 74099510334L;
|
|
- CTopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");
|
|
|
|
|
|
+ CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");
|
|
JSONObject getObject = getAdvertiserStat(token, conditions);
|
|
JSONObject getObject = getAdvertiserStat(token, conditions);
|
|
return getObject;
|
|
return getObject;
|
|
}
|
|
}
|
|
@@ -63,23 +78,20 @@ public class ReportServiceImpl implements IReportService {
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> getCampaignReport(JSONObject conditions) {
|
|
public Map<String, Object> getCampaignReport(JSONObject conditions) {
|
|
Long accountId = conditions.getLong("accountId");
|
|
Long accountId = conditions.getLong("accountId");
|
|
- CTopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");
|
|
|
|
|
|
+ CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");
|
|
JSONObject getObject = getAdStat(token, conditions);
|
|
JSONObject getObject = getAdStat(token, conditions);
|
|
return new HashMap<>();
|
|
return new HashMap<>();
|
|
}
|
|
}
|
|
|
|
|
|
- private JSONObject getAdStat(CTopOauthToken token, JSONObject conditions) {
|
|
|
|
|
|
+ private JSONObject getAdStat(CtopOauthToken token, JSONObject conditions) {
|
|
final Long advertiserId = token.getAccountId();
|
|
final Long advertiserId = token.getAccountId();
|
|
-
|
|
|
|
// 请求地址
|
|
// 请求地址
|
|
String url = "https://ad.toutiao.com/open_api/2/report/ad/get/";
|
|
String url = "https://ad.toutiao.com/open_api/2/report/ad/get/";
|
|
-
|
|
|
|
final Map filtering = new HashMap() {
|
|
final Map filtering = new HashMap() {
|
|
{
|
|
{
|
|
put("campaign_id", 1L);
|
|
put("campaign_id", 1L);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-
|
|
|
|
// 请求参数
|
|
// 请求参数
|
|
final Map data = new HashMap() {
|
|
final Map data = new HashMap() {
|
|
{
|
|
{
|
|
@@ -100,12 +112,9 @@ public class ReportServiceImpl implements IReportService {
|
|
return "GET";
|
|
return "GET";
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-
|
|
|
|
httpEntity.setHeader("Access-Token", token.getAccessToken());
|
|
httpEntity.setHeader("Access-Token", token.getAccessToken());
|
|
-
|
|
|
|
CloseableHttpResponse response = null;
|
|
CloseableHttpResponse response = null;
|
|
CloseableHttpClient client = null;
|
|
CloseableHttpClient client = null;
|
|
-
|
|
|
|
try {
|
|
try {
|
|
client = HttpClientBuilder.create().build();
|
|
client = HttpClientBuilder.create().build();
|
|
httpEntity.setURI(URI.create(url));
|
|
httpEntity.setURI(URI.create(url));
|
|
@@ -143,7 +152,7 @@ public class ReportServiceImpl implements IReportService {
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> getAdReport(JSONObject conditions) {
|
|
public Map<String, Object> getAdReport(JSONObject conditions) {
|
|
Long accountId = conditions.getLong("accountId");
|
|
Long accountId = conditions.getLong("accountId");
|
|
- CTopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");
|
|
|
|
|
|
+ CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");
|
|
JSONObject getObject = getAdStat(token, conditions);
|
|
JSONObject getObject = getAdStat(token, conditions);
|
|
return getObject;
|
|
return getObject;
|
|
}
|
|
}
|
|
@@ -151,7 +160,7 @@ public class ReportServiceImpl implements IReportService {
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> getCreativeReport(JSONObject conditions) {
|
|
public Map<String, Object> getCreativeReport(JSONObject conditions) {
|
|
Long accountId = conditions.getLong("accountId");
|
|
Long accountId = conditions.getLong("accountId");
|
|
- CTopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");
|
|
|
|
|
|
+ CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");
|
|
JSONObject getObject = getCreativeStat(token, conditions);
|
|
JSONObject getObject = getCreativeStat(token, conditions);
|
|
return getObject;
|
|
return getObject;
|
|
}
|
|
}
|
|
@@ -159,7 +168,7 @@ public class ReportServiceImpl implements IReportService {
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> getAgentReport(JSONObject conditions) {
|
|
public Map<String, Object> getAgentReport(JSONObject conditions) {
|
|
Long accountId = conditions.getLong("accountId");
|
|
Long accountId = conditions.getLong("accountId");
|
|
- CTopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");
|
|
|
|
|
|
+ CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");
|
|
JSONObject getObject = getCreativeStat(token, conditions);
|
|
JSONObject getObject = getCreativeStat(token, conditions);
|
|
return getObject;
|
|
return getObject;
|
|
}
|
|
}
|
|
@@ -167,7 +176,7 @@ public class ReportServiceImpl implements IReportService {
|
|
@Override
|
|
@Override
|
|
public void insertCustomerInfo(String csvPath, String charset) {
|
|
public void insertCustomerInfo(String csvPath, String charset) {
|
|
try {
|
|
try {
|
|
- List<String[]> data = CsvUtils.ReadCSV(csvPath, charset);
|
|
|
|
|
|
+ List<String[]> data = CsvUtils.readCSV(csvPath, charset);
|
|
if (null != data && data.size() > 1) {
|
|
if (null != data && data.size() > 1) {
|
|
for (int i = 1; i < data.size(); i++) {
|
|
for (int i = 1; i < data.size(); i++) {
|
|
String[] record = data.get(i);
|
|
String[] record = data.get(i);
|
|
@@ -183,7 +192,7 @@ public class ReportServiceImpl implements IReportService {
|
|
@Override
|
|
@Override
|
|
public void insertPlatformInfo(String csvPath, String charset, Long accountId) {
|
|
public void insertPlatformInfo(String csvPath, String charset, Long accountId) {
|
|
try {
|
|
try {
|
|
- List<String[]> data = CsvUtils.ReadCSV(csvPath, charset);
|
|
|
|
|
|
+ List<String[]> data = CsvUtils.readCSV(csvPath, charset);
|
|
if (null != data && data.size() > 1) {
|
|
if (null != data && data.size() > 1) {
|
|
for (int i = 1; i < data.size(); i++) {
|
|
for (int i = 1; i < data.size(); i++) {
|
|
String[] record = data.get(i);
|
|
String[] record = data.get(i);
|
|
@@ -196,9 +205,6 @@ public class ReportServiceImpl implements IReportService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @Value("${jeecg.path.csv-upload}")
|
|
|
|
- private String csvUploadPath;
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> debitAuto(JSONObject data) {
|
|
public Map<String, Object> debitAuto(JSONObject data) {
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
@@ -206,21 +212,31 @@ public class ReportServiceImpl implements IReportService {
|
|
String accountFourKsDataUrl = data.getString("accountFourKsDataUrl");
|
|
String accountFourKsDataUrl = data.getString("accountFourKsDataUrl");
|
|
String debitDataUrl = data.getString("debitDataUrl");
|
|
String debitDataUrl = data.getString("debitDataUrl");
|
|
//1:文件下载入库
|
|
//1:文件下载入库
|
|
- String accountOneKsDataPath = downLoadByURL(accountOneKsDataUrl);
|
|
|
|
- String accountFourKsDataPath = downLoadByURL(accountFourKsDataUrl);
|
|
|
|
- String debitDataPath = downLoadByURL(debitDataUrl);
|
|
|
|
|
|
+ String accountOneKsDataPath = downLoadByUrl(accountOneKsDataUrl);
|
|
|
|
+ String accountFourKsDataPath = downLoadByUrl(accountFourKsDataUrl);
|
|
|
|
+ String debitDataPath = downLoadByUrl(debitDataUrl);
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/M/dd");
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/M/dd");
|
|
//2:文件入库
|
|
//2:文件入库
|
|
//2.1 清除数据库原始数据
|
|
//2.1 清除数据库原始数据
|
|
QueryWrapper<CustomerPlanStatisticInfo> planWrapper = new QueryWrapper<>();
|
|
QueryWrapper<CustomerPlanStatisticInfo> planWrapper = new QueryWrapper<>();
|
|
- planWrapper.eq("statistic_date", simpleDateFormat.format(new Date()));
|
|
|
|
|
|
+ planWrapper.isNotNull("id");
|
|
customerPlanStatisticInfoService.remove(planWrapper);
|
|
customerPlanStatisticInfoService.remove(planWrapper);
|
|
|
|
|
|
QueryWrapper<PlatformCampaignStatisticInfo> campaignWrapper = new QueryWrapper<>();
|
|
QueryWrapper<PlatformCampaignStatisticInfo> campaignWrapper = new QueryWrapper<>();
|
|
- campaignWrapper.eq("statistic_date", simpleDateFormat.format(new Date()));
|
|
|
|
|
|
+ campaignWrapper.isNotNull("id");
|
|
platformCampaignStatisticInfoService.remove(campaignWrapper);
|
|
platformCampaignStatisticInfoService.remove(campaignWrapper);
|
|
|
|
|
|
this.insertPlatformInfo(accountOneKsDataPath, "gb2312", 1L);
|
|
this.insertPlatformInfo(accountOneKsDataPath, "gb2312", 1L);
|
|
|
|
+ QueryWrapper<PlatformCampaignStatisticInfo> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("campaign_code", "biaodan").orderByDesc("id").last("limit 1");
|
|
|
|
+ PlatformCampaignStatisticInfo statisticInfo = platformCampaignStatisticInfoMapper.selectOne(queryWrapper);
|
|
|
|
+ if (null != statisticInfo) {
|
|
|
|
+ PlatformCampaignStatisticInfo updateInfo = new PlatformCampaignStatisticInfo();
|
|
|
|
+ updateInfo.setCampaignCode("biaodan2");
|
|
|
|
+ QueryWrapper<PlatformCampaignStatisticInfo> updateWrapper = new QueryWrapper<>();
|
|
|
|
+ updateWrapper.ne("campaign_info", statisticInfo.getCampaignInfo()).eq("campaign_code", statisticInfo.getCampaignCode());
|
|
|
|
+ platformCampaignStatisticInfoMapper.update(updateInfo, updateWrapper);
|
|
|
|
+ }
|
|
this.insertPlatformInfo(accountFourKsDataPath, "gb2312", 4L);
|
|
this.insertPlatformInfo(accountFourKsDataPath, "gb2312", 4L);
|
|
this.insertCustomerInfo(debitDataPath, "utf8");
|
|
this.insertCustomerInfo(debitDataPath, "utf8");
|
|
//3:根据模板生成相应的excel模板文件
|
|
//3:根据模板生成相应的excel模板文件
|
|
@@ -239,16 +255,9 @@ public class ReportServiceImpl implements IReportService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private IPlatformCampaignStatisticInfoService platformCampaignStatisticInfoService;
|
|
|
|
- @Autowired
|
|
|
|
- private ICustomerPlanStatisticInfoService customerPlanStatisticInfoService;
|
|
|
|
-
|
|
|
|
public String getExcelDataPath(String date, Long accountId1, Long accountId4) throws Exception {
|
|
public String getExcelDataPath(String date, Long accountId1, Long accountId4) throws Exception {
|
|
-
|
|
|
|
- List<StatisticCampaignVo> statisticCampaign4Vos = statisticInfoMapper.getVoByParams(date, accountId4);
|
|
|
|
- List<StatisticCampaignVo> statisticCampaign1Vos = statisticInfoMapper.getVoByParams(date, accountId1);
|
|
|
|
-
|
|
|
|
|
|
+ List<StatisticCampaignVo> statisticCampaign1Vos = statisticInfoMapper.getVoByParams(accountId1);
|
|
|
|
+ List<StatisticCampaignVo> statisticCampaign4Vos = statisticInfoMapper.getVoByParams(accountId4);
|
|
File f = new File(csvUploadPath + "template.xlsx");
|
|
File f = new File(csvUploadPath + "template.xlsx");
|
|
InputStream inputStream = new FileInputStream(f);
|
|
InputStream inputStream = new FileInputStream(f);
|
|
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(inputStream);
|
|
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(inputStream);
|
|
@@ -259,14 +268,35 @@ public class ReportServiceImpl implements IReportService {
|
|
int index;
|
|
int index;
|
|
for (index = 1; index < statisticCampaign1Vos.size() + 1; index++) {
|
|
for (index = 1; index < statisticCampaign1Vos.size() + 1; index++) {
|
|
StatisticCampaignVo vo = statisticCampaign1Vos.get(index - 1);
|
|
StatisticCampaignVo vo = statisticCampaign1Vos.get(index - 1);
|
|
- System.out.println(vo.toString());
|
|
|
|
String content = vo.getContent();
|
|
String content = vo.getContent();
|
|
String[] contents = content.split("-");
|
|
String[] contents = content.split("-");
|
|
Row row = xssfSheet.getRow(index);
|
|
Row row = xssfSheet.getRow(index);
|
|
setExcelRow(numbericCellStyle, vo, contents, row, "single");
|
|
setExcelRow(numbericCellStyle, vo, contents, row, "single");
|
|
}
|
|
}
|
|
|
|
+ List<StatisticCampaignVo> zero1Vos = statisticInfoMapper.sumZeroVoByParams(accountId1);
|
|
|
|
+ List<StatisticCampaignVo> zaodianVos = statisticInfoMapper.sumZaodianVoByParams(accountId1);
|
|
|
|
+ if (null != zero1Vos && zero1Vos.size() > 0) {
|
|
|
|
+ for (int z = 0; z < zero1Vos.size(); z++) {
|
|
|
|
+ StatisticCampaignVo vo = zero1Vos.get(z);
|
|
|
|
+ Row row = xssfSheet.getRow(index);
|
|
|
|
+ String content = vo.getContent();
|
|
|
|
+ String[] contents = content.split("-");
|
|
|
|
+ setExcelRow(numbericCellStyle, vo, contents, row, "single");
|
|
|
|
+ index++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (null != zaodianVos && zaodianVos.size() > 0) {
|
|
|
|
+ for (int z = 0; z < zaodianVos.size(); z++) {
|
|
|
|
+ StatisticCampaignVo vo = zaodianVos.get(z);
|
|
|
|
+ Row row = xssfSheet.getRow(index);
|
|
|
|
+ String content = vo.getContent();
|
|
|
|
+ String[] contents = content.split("-");
|
|
|
|
+ setExcelRow(numbericCellStyle, vo, contents, row, "single");
|
|
|
|
+ index++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
Row totalRow1 = xssfSheet.getRow(index);
|
|
Row totalRow1 = xssfSheet.getRow(index);
|
|
- StatisticCampaignVo total = statisticInfoMapper.getTotalStatisticVoByparams(date, accountId1);
|
|
|
|
|
|
+ StatisticCampaignVo total = statisticInfoMapper.getTotalStatisticVoByparams(accountId1);
|
|
if (null != total) {
|
|
if (null != total) {
|
|
setExcelRow(numbericCellStyle, total, new String[]{}, totalRow1, "total1");
|
|
setExcelRow(numbericCellStyle, total, new String[]{}, totalRow1, "total1");
|
|
}
|
|
}
|
|
@@ -274,19 +304,28 @@ public class ReportServiceImpl implements IReportService {
|
|
for (int j = 0; j < statisticCampaign4Vos.size(); j++) {
|
|
for (int j = 0; j < statisticCampaign4Vos.size(); j++) {
|
|
index++;
|
|
index++;
|
|
StatisticCampaignVo vo = statisticCampaign4Vos.get(j);
|
|
StatisticCampaignVo vo = statisticCampaign4Vos.get(j);
|
|
- System.out.println(vo.toString());
|
|
|
|
String content = vo.getContent();
|
|
String content = vo.getContent();
|
|
String[] contents = content.split("-");
|
|
String[] contents = content.split("-");
|
|
Row row = xssfSheet.getRow(index);
|
|
Row row = xssfSheet.getRow(index);
|
|
setExcelRow(numbericCellStyle, vo, contents, row, "single");
|
|
setExcelRow(numbericCellStyle, vo, contents, row, "single");
|
|
}
|
|
}
|
|
|
|
+ List<StatisticCampaignVo> zero4Vos = statisticInfoMapper.sumZeroVoByParams(accountId4);
|
|
|
|
+ if (null != zero4Vos && zero4Vos.size() > 0) {
|
|
|
|
+ for (int z = 0; z < zero4Vos.size(); z++) {
|
|
|
|
+ index++;
|
|
|
|
+ StatisticCampaignVo vo = zero4Vos.get(z);
|
|
|
|
+ Row row = xssfSheet.getRow(index);
|
|
|
|
+ String content = vo.getContent();
|
|
|
|
+ String[] contents = content.split("-");
|
|
|
|
+ setExcelRow(numbericCellStyle, vo, contents, row, "single");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
index++;
|
|
index++;
|
|
Row totalRow4 = xssfSheet.getRow(index);
|
|
Row totalRow4 = xssfSheet.getRow(index);
|
|
- StatisticCampaignVo total1 = statisticInfoMapper.getTotalStatisticVoByparams(date, accountId4);
|
|
|
|
|
|
+ StatisticCampaignVo total1 = statisticInfoMapper.getTotalStatisticVoByparams(accountId4);
|
|
if (null != total1) {
|
|
if (null != total1) {
|
|
setExcelRow(numbericCellStyle, total1, new String[]{}, totalRow4, "total4");
|
|
setExcelRow(numbericCellStyle, total1, new String[]{}, totalRow4, "total4");
|
|
}
|
|
}
|
|
-
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-m-dd");
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-m-dd");
|
|
String path = csvUploadPath + "report_" + dateFormat.format(new Date()) + ".xlsx";
|
|
String path = csvUploadPath + "report_" + dateFormat.format(new Date()) + ".xlsx";
|
|
FileOutputStream fileOutputStream = new FileOutputStream(path);
|
|
FileOutputStream fileOutputStream = new FileOutputStream(path);
|
|
@@ -296,17 +335,14 @@ public class ReportServiceImpl implements IReportService {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private PlatformCampaignStatisticInfoMapper statisticInfoMapper;
|
|
|
|
-
|
|
|
|
private void setExcelRow(CellStyle numbericCellStyle, StatisticCampaignVo vo, String[] contents, Row row, String type) {
|
|
private void setExcelRow(CellStyle numbericCellStyle, StatisticCampaignVo vo, String[] contents, Row row, String type) {
|
|
for (int j = 0; j < 38; j++) {
|
|
for (int j = 0; j < 38; j++) {
|
|
Cell cell = row.createCell(j);
|
|
Cell cell = row.createCell(j);
|
|
if (j == 0) {
|
|
if (j == 0) {
|
|
//日期
|
|
//日期
|
|
- if (null != type && type.equals("single")) {
|
|
|
|
|
|
+ if (null != type && "single".equals(type)) {
|
|
cell.setCellValue(vo.getStatisticDate());
|
|
cell.setCellValue(vo.getStatisticDate());
|
|
- } else if (null != type && type.equals("total1")) {
|
|
|
|
|
|
+ } else if (null != type && "total1".equals(type)) {
|
|
cell.setCellValue("户一总计");
|
|
cell.setCellValue("户一总计");
|
|
} else {
|
|
} else {
|
|
cell.setCellValue("户四总计");
|
|
cell.setCellValue("户四总计");
|
|
@@ -422,107 +458,112 @@ public class ReportServiceImpl implements IReportService {
|
|
} else if (j == 19) {
|
|
} else if (j == 19) {
|
|
//注册用户
|
|
//注册用户
|
|
if (null != vo.getRegistUserNum() && !"".equals(vo.getRegistUserNum())) {
|
|
if (null != vo.getRegistUserNum() && !"".equals(vo.getRegistUserNum())) {
|
|
- cell.setCellValue(Integer.parseInt(vo.getRegistUserNum()));
|
|
|
|
|
|
+ BigDecimal decimal = new BigDecimal(vo.getRegistUserNum());
|
|
|
|
+ cell.setCellValue(decimal.intValue());
|
|
}
|
|
}
|
|
} else if (j == 20) {
|
|
} else if (j == 20) {
|
|
//完件用户
|
|
//完件用户
|
|
if (null != vo.getComplateUserNum() && !"".equals(vo.getComplateUserNum())) {
|
|
if (null != vo.getComplateUserNum() && !"".equals(vo.getComplateUserNum())) {
|
|
- cell.setCellValue(Integer.parseInt(vo.getComplateUserNum()));
|
|
|
|
|
|
+ BigDecimal decimal = new BigDecimal(vo.getComplateUserNum());
|
|
|
|
+ cell.setCellValue(decimal.intValue());
|
|
}
|
|
}
|
|
} else if (j == 21) {
|
|
} else if (j == 21) {
|
|
//授信用户
|
|
//授信用户
|
|
if (null != vo.getCreditUserNum() && !"".equals(vo.getCreditUserNum())) {
|
|
if (null != vo.getCreditUserNum() && !"".equals(vo.getCreditUserNum())) {
|
|
- cell.setCellValue(Integer.parseInt(vo.getCreditUserNum()));
|
|
|
|
|
|
+ BigDecimal decimal = new BigDecimal(vo.getCreditUserNum());
|
|
|
|
+ cell.setCellValue(decimal.intValue());
|
|
}
|
|
}
|
|
} else if (j == 22) {
|
|
} else if (j == 22) {
|
|
//当日注册且完件数
|
|
//当日注册且完件数
|
|
if (null != vo.getRegistCompleteNum() && !"".equals(vo.getRegistCompleteNum())) {
|
|
if (null != vo.getRegistCompleteNum() && !"".equals(vo.getRegistCompleteNum())) {
|
|
- cell.setCellValue(Integer.parseInt(vo.getRegistCompleteNum()));
|
|
|
|
|
|
+ BigDecimal decimal = new BigDecimal(vo.getRegistCompleteNum());
|
|
|
|
+ cell.setCellValue(decimal.intValue());
|
|
}
|
|
}
|
|
} else if (j == 23) {
|
|
} else if (j == 23) {
|
|
//当日注册且授信数
|
|
//当日注册且授信数
|
|
if (null != vo.getRegistCreditNum() && !"".equals(vo.getRegistCreditNum())) {
|
|
if (null != vo.getRegistCreditNum() && !"".equals(vo.getRegistCreditNum())) {
|
|
- cell.setCellValue(Integer.parseInt(vo.getRegistCreditNum()));
|
|
|
|
|
|
+ BigDecimal decimal = new BigDecimal(vo.getRegistCreditNum());
|
|
|
|
+ cell.setCellValue(decimal.intValue());
|
|
}
|
|
}
|
|
- } else if (j == 25) {
|
|
|
|
|
|
+ } else if (j == 24) {
|
|
//注册成本
|
|
//注册成本
|
|
if (null != vo.getRegistPrice() && !"".equals(vo.getRegistPrice())) {
|
|
if (null != vo.getRegistPrice() && !"".equals(vo.getRegistPrice())) {
|
|
cell.setCellValue(Float.parseFloat(vo.getRegistPrice()));
|
|
cell.setCellValue(Float.parseFloat(vo.getRegistPrice()));
|
|
cell.setCellStyle(numbericCellStyle);
|
|
cell.setCellStyle(numbericCellStyle);
|
|
}
|
|
}
|
|
- } else if (j == 26) {
|
|
|
|
|
|
+ } else if (j == 25) {
|
|
//完件成本
|
|
//完件成本
|
|
if (null != vo.getCompletePrice() && !"".equals(vo.getCompletePrice())) {
|
|
if (null != vo.getCompletePrice() && !"".equals(vo.getCompletePrice())) {
|
|
cell.setCellValue(Float.parseFloat(vo.getCompletePrice()));
|
|
cell.setCellValue(Float.parseFloat(vo.getCompletePrice()));
|
|
cell.setCellStyle(numbericCellStyle);
|
|
cell.setCellStyle(numbericCellStyle);
|
|
}
|
|
}
|
|
- } else if (j == 27) {
|
|
|
|
|
|
+ } else if (j == 26) {
|
|
//授信成本
|
|
//授信成本
|
|
if (null != vo.getCreditPrice() && !"".equals(vo.getCreditPrice())) {
|
|
if (null != vo.getCreditPrice() && !"".equals(vo.getCreditPrice())) {
|
|
cell.setCellValue(Float.parseFloat(vo.getCreditPrice()));
|
|
cell.setCellValue(Float.parseFloat(vo.getCreditPrice()));
|
|
cell.setCellStyle(numbericCellStyle);
|
|
cell.setCellStyle(numbericCellStyle);
|
|
}
|
|
}
|
|
- } else if (j == 28) {
|
|
|
|
|
|
+ } else if (j == 27) {
|
|
//当日注册且完件成本
|
|
//当日注册且完件成本
|
|
if (null != vo.getRegistCompletePrice() && !"".equals(vo.getRegistCompletePrice())) {
|
|
if (null != vo.getRegistCompletePrice() && !"".equals(vo.getRegistCompletePrice())) {
|
|
cell.setCellValue(Float.parseFloat(vo.getRegistCompletePrice()));
|
|
cell.setCellValue(Float.parseFloat(vo.getRegistCompletePrice()));
|
|
cell.setCellStyle(numbericCellStyle);
|
|
cell.setCellStyle(numbericCellStyle);
|
|
}
|
|
}
|
|
- } else if (j == 29) {
|
|
|
|
|
|
+ } else if (j == 28) {
|
|
//当日注册且授信成本
|
|
//当日注册且授信成本
|
|
if (null != vo.getRegistCreditPrice() && !"".equals(vo.getRegistCreditPrice())) {
|
|
if (null != vo.getRegistCreditPrice() && !"".equals(vo.getRegistCreditPrice())) {
|
|
cell.setCellValue(Float.parseFloat(vo.getRegistCreditPrice()));
|
|
cell.setCellValue(Float.parseFloat(vo.getRegistCreditPrice()));
|
|
cell.setCellStyle(numbericCellStyle);
|
|
cell.setCellStyle(numbericCellStyle);
|
|
}
|
|
}
|
|
- } else if (j == 30) {
|
|
|
|
|
|
+ } else if (j == 29) {
|
|
//点击注册率
|
|
//点击注册率
|
|
if (null != vo.getClickRegistRate() && !"".equals(vo.getClickRegistRate())) {
|
|
if (null != vo.getClickRegistRate() && !"".equals(vo.getClickRegistRate())) {
|
|
cell.setCellValue(Float.parseFloat(vo.getClickRegistRate()));
|
|
cell.setCellValue(Float.parseFloat(vo.getClickRegistRate()));
|
|
cell.setCellStyle(numbericCellStyle);
|
|
cell.setCellStyle(numbericCellStyle);
|
|
}
|
|
}
|
|
- } else if (j == 31) {
|
|
|
|
|
|
+ } else if (j == 30) {
|
|
//行为注册率
|
|
//行为注册率
|
|
if (null != vo.getActionRegistRate() && !"".equals(vo.getActionRegistRate())) {
|
|
if (null != vo.getActionRegistRate() && !"".equals(vo.getActionRegistRate())) {
|
|
cell.setCellValue(Float.parseFloat(vo.getActionRegistRate()));
|
|
cell.setCellValue(Float.parseFloat(vo.getActionRegistRate()));
|
|
cell.setCellStyle(numbericCellStyle);
|
|
cell.setCellStyle(numbericCellStyle);
|
|
}
|
|
}
|
|
- } else if (j == 32) {
|
|
|
|
|
|
+ } else if (j == 31) {
|
|
//完件率
|
|
//完件率
|
|
if (null != vo.getCompleteRate() && !"".equals(vo.getCompleteRate())) {
|
|
if (null != vo.getCompleteRate() && !"".equals(vo.getCompleteRate())) {
|
|
cell.setCellValue(Float.parseFloat(vo.getCompleteRate()));
|
|
cell.setCellValue(Float.parseFloat(vo.getCompleteRate()));
|
|
cell.setCellStyle(numbericCellStyle);
|
|
cell.setCellStyle(numbericCellStyle);
|
|
}
|
|
}
|
|
- } else if (j == 33) {
|
|
|
|
|
|
+ } else if (j == 32) {
|
|
//授信率
|
|
//授信率
|
|
if (null != vo.getCreditRate() && !"".equals(vo.getCreditRate())) {
|
|
if (null != vo.getCreditRate() && !"".equals(vo.getCreditRate())) {
|
|
cell.setCellValue(Float.parseFloat(vo.getCreditRate()));
|
|
cell.setCellValue(Float.parseFloat(vo.getCreditRate()));
|
|
cell.setCellStyle(numbericCellStyle);
|
|
cell.setCellStyle(numbericCellStyle);
|
|
}
|
|
}
|
|
- } else if (j == 34) {
|
|
|
|
|
|
+ } else if (j == 33) {
|
|
//当日完件率
|
|
//当日完件率
|
|
if (null != vo.getRegistCompleteRate() && !"".equals(vo.getRegistCompleteRate())) {
|
|
if (null != vo.getRegistCompleteRate() && !"".equals(vo.getRegistCompleteRate())) {
|
|
cell.setCellValue(Float.parseFloat(vo.getRegistCompleteRate()));
|
|
cell.setCellValue(Float.parseFloat(vo.getRegistCompleteRate()));
|
|
cell.setCellStyle(numbericCellStyle);
|
|
cell.setCellStyle(numbericCellStyle);
|
|
}
|
|
}
|
|
- } else if (j == 35) {
|
|
|
|
|
|
+ } else if (j == 34) {
|
|
//当日授信率
|
|
//当日授信率
|
|
if (null != vo.getRegistCreditRate() && !"".equals(vo.getRegistCreditRate())) {
|
|
if (null != vo.getRegistCreditRate() && !"".equals(vo.getRegistCreditRate())) {
|
|
cell.setCellValue(Float.parseFloat(vo.getRegistCreditRate()));
|
|
cell.setCellValue(Float.parseFloat(vo.getRegistCreditRate()));
|
|
cell.setCellStyle(numbericCellStyle);
|
|
cell.setCellStyle(numbericCellStyle);
|
|
}
|
|
}
|
|
- } else if (j == 36) {
|
|
|
|
|
|
+ } else if (j == 35) {
|
|
//当日完件/完件
|
|
//当日完件/完件
|
|
if (null != vo.getCompleteRateDay() && !"".equals(vo.getCompleteRateDay())) {
|
|
if (null != vo.getCompleteRateDay() && !"".equals(vo.getCompleteRateDay())) {
|
|
cell.setCellValue(Float.parseFloat(vo.getCompleteRateDay()));
|
|
cell.setCellValue(Float.parseFloat(vo.getCompleteRateDay()));
|
|
cell.setCellStyle(numbericCellStyle);
|
|
cell.setCellStyle(numbericCellStyle);
|
|
}
|
|
}
|
|
- } else if (j == 37) {
|
|
|
|
|
|
+ } else if (j == 36) {
|
|
//当日授信/授信
|
|
//当日授信/授信
|
|
if (null != vo.getCreditRateDay() && !"".equals(vo.getCreditRateDay())) {
|
|
if (null != vo.getCreditRateDay() && !"".equals(vo.getCreditRateDay())) {
|
|
cell.setCellValue(Float.parseFloat(vo.getCreditRateDay()));
|
|
cell.setCellValue(Float.parseFloat(vo.getCreditRateDay()));
|
|
cell.setCellStyle(numbericCellStyle);
|
|
cell.setCellStyle(numbericCellStyle);
|
|
}
|
|
}
|
|
- } else if (j == 38) {
|
|
|
|
|
|
+ } else if (j == 37) {
|
|
//当日授信/注册
|
|
//当日授信/注册
|
|
if (null != vo.getCreditRegistRateDay() && !"".equals(vo.getCreditRegistRateDay())) {
|
|
if (null != vo.getCreditRegistRateDay() && !"".equals(vo.getCreditRegistRateDay())) {
|
|
cell.setCellValue(Float.parseFloat(vo.getCreditRegistRateDay()));
|
|
cell.setCellValue(Float.parseFloat(vo.getCreditRegistRateDay()));
|
|
@@ -532,7 +573,7 @@ public class ReportServiceImpl implements IReportService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public String downLoadByURL(String fileUrl) {
|
|
|
|
|
|
+ public String downLoadByUrl(String fileUrl) {
|
|
//获取文件名,文件名实际上在URL中可以找到
|
|
//获取文件名,文件名实际上在URL中可以找到
|
|
String fileName = fileUrl.substring(fileUrl.lastIndexOf("/") + 1);
|
|
String fileName = fileUrl.substring(fileUrl.lastIndexOf("/") + 1);
|
|
//这里服务器上要将此图保存的路径
|
|
//这里服务器上要将此图保存的路径
|
|
@@ -563,12 +604,7 @@ public class ReportServiceImpl implements IReportService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private CustomerPlanStatisticInfoMapper customerPlanStatisticInfoMapper;
|
|
|
|
- @Autowired
|
|
|
|
- private PlatformCampaignStatisticInfoMapper platformCampaignStatisticInfoMapper;
|
|
|
|
-
|
|
|
|
- public JSONObject getAgentStat(CTopOauthToken token, JSONObject conditions) {
|
|
|
|
|
|
+ public JSONObject getAgentStat(CtopOauthToken token, JSONObject conditions) {
|
|
// 请求地址
|
|
// 请求地址
|
|
String url = "https://ad.toutiao.com/open_api/2/report/agent/get/";
|
|
String url = "https://ad.toutiao.com/open_api/2/report/agent/get/";
|
|
// 请求参数
|
|
// 请求参数
|
|
@@ -588,15 +624,12 @@ public class ReportServiceImpl implements IReportService {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
httpEntity.setHeader("Access-Token", token.getAccessToken());
|
|
httpEntity.setHeader("Access-Token", token.getAccessToken());
|
|
-
|
|
|
|
CloseableHttpResponse response = null;
|
|
CloseableHttpResponse response = null;
|
|
CloseableHttpClient client = null;
|
|
CloseableHttpClient client = null;
|
|
-
|
|
|
|
try {
|
|
try {
|
|
client = HttpClientBuilder.create().build();
|
|
client = HttpClientBuilder.create().build();
|
|
httpEntity.setURI(URI.create(url));
|
|
httpEntity.setURI(URI.create(url));
|
|
httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
|
|
httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
|
|
-
|
|
|
|
response = client.execute(httpEntity);
|
|
response = client.execute(httpEntity);
|
|
if (response != null && response.getStatusLine().getStatusCode() == 200) {
|
|
if (response != null && response.getStatusLine().getStatusCode() == 200) {
|
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
@@ -625,17 +658,14 @@ public class ReportServiceImpl implements IReportService {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
- public JSONObject getCreativeStat(CTopOauthToken token, JSONObject conditions) {
|
|
|
|
-
|
|
|
|
|
|
+ public JSONObject getCreativeStat(CtopOauthToken token, JSONObject conditions) {
|
|
// 请求地址
|
|
// 请求地址
|
|
String url = "https://ad.toutiao.com/open_api/2/report/creative/get/";
|
|
String url = "https://ad.toutiao.com/open_api/2/report/creative/get/";
|
|
-
|
|
|
|
final Map filtering = new HashMap() {
|
|
final Map filtering = new HashMap() {
|
|
{
|
|
{
|
|
put("campaign_id", 1L);
|
|
put("campaign_id", 1L);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-
|
|
|
|
// 请求参数
|
|
// 请求参数
|
|
final Map data = new HashMap() {
|
|
final Map data = new HashMap() {
|
|
{
|
|
{
|
|
@@ -645,7 +675,6 @@ public class ReportServiceImpl implements IReportService {
|
|
put("time_granularity", "STAT_TIME_GRANULARITY_DAILY");
|
|
put("time_granularity", "STAT_TIME_GRANULARITY_DAILY");
|
|
put("group_by", new String[]{"STAT_GROUP_BY_FIELD_ID"});
|
|
put("group_by", new String[]{"STAT_GROUP_BY_FIELD_ID"});
|
|
put("filtering", filtering);
|
|
put("filtering", filtering);
|
|
-
|
|
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
@@ -656,17 +685,13 @@ public class ReportServiceImpl implements IReportService {
|
|
return "GET";
|
|
return "GET";
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-
|
|
|
|
httpEntity.setHeader("Access-Token", token.getAccessToken());
|
|
httpEntity.setHeader("Access-Token", token.getAccessToken());
|
|
-
|
|
|
|
CloseableHttpResponse response = null;
|
|
CloseableHttpResponse response = null;
|
|
CloseableHttpClient client = null;
|
|
CloseableHttpClient client = null;
|
|
-
|
|
|
|
try {
|
|
try {
|
|
client = HttpClientBuilder.create().build();
|
|
client = HttpClientBuilder.create().build();
|
|
httpEntity.setURI(URI.create(url));
|
|
httpEntity.setURI(URI.create(url));
|
|
httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
|
|
httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
|
|
-
|
|
|
|
response = client.execute(httpEntity);
|
|
response = client.execute(httpEntity);
|
|
if (response != null && response.getStatusLine().getStatusCode() == 200) {
|
|
if (response != null && response.getStatusLine().getStatusCode() == 200) {
|
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
@@ -678,7 +703,6 @@ public class ReportServiceImpl implements IReportService {
|
|
bufferedReader.close();
|
|
bufferedReader.close();
|
|
return JSONObject.parseObject(result.toString());
|
|
return JSONObject.parseObject(result.toString());
|
|
}
|
|
}
|
|
-
|
|
|
|
} catch (ClientProtocolException e) {
|
|
} catch (ClientProtocolException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
@@ -696,16 +720,14 @@ public class ReportServiceImpl implements IReportService {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
- public static JSONObject getCampaignStat(CTopOauthToken token, JSONObject conditions) {
|
|
|
|
|
|
+ public static JSONObject getCampaignStat(CtopOauthToken token, JSONObject conditions) {
|
|
// 请求地址
|
|
// 请求地址
|
|
String url = "https://ad.toutiao.com/open_api/2/report/campaign/get/";
|
|
String url = "https://ad.toutiao.com/open_api/2/report/campaign/get/";
|
|
-
|
|
|
|
final Map filtering = new HashMap() {
|
|
final Map filtering = new HashMap() {
|
|
{
|
|
{
|
|
put("campaign_ids", new Long[]{1L, 2L});
|
|
put("campaign_ids", new Long[]{1L, 2L});
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-
|
|
|
|
// 请求参数
|
|
// 请求参数
|
|
final Map data = new HashMap() {
|
|
final Map data = new HashMap() {
|
|
{
|
|
{
|
|
@@ -717,10 +739,8 @@ public class ReportServiceImpl implements IReportService {
|
|
put("time_granularity", conditions.getString("timeGranularity"));
|
|
put("time_granularity", conditions.getString("timeGranularity"));
|
|
put("group_by", conditions.getJSONArray("groupBy"));
|
|
put("group_by", conditions.getJSONArray("groupBy"));
|
|
put("filtering", filtering);
|
|
put("filtering", filtering);
|
|
-
|
|
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-
|
|
|
|
// 构造请求
|
|
// 构造请求
|
|
HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
|
|
HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
|
|
@Override
|
|
@Override
|
|
@@ -728,17 +748,13 @@ public class ReportServiceImpl implements IReportService {
|
|
return "GET";
|
|
return "GET";
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-
|
|
|
|
httpEntity.setHeader("Access-Token", token.getAccessToken());
|
|
httpEntity.setHeader("Access-Token", token.getAccessToken());
|
|
-
|
|
|
|
CloseableHttpResponse response = null;
|
|
CloseableHttpResponse response = null;
|
|
CloseableHttpClient client = null;
|
|
CloseableHttpClient client = null;
|
|
-
|
|
|
|
try {
|
|
try {
|
|
client = HttpClientBuilder.create().build();
|
|
client = HttpClientBuilder.create().build();
|
|
httpEntity.setURI(URI.create(url));
|
|
httpEntity.setURI(URI.create(url));
|
|
httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
|
|
httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
|
|
-
|
|
|
|
response = client.execute(httpEntity);
|
|
response = client.execute(httpEntity);
|
|
if (response != null && response.getStatusLine().getStatusCode() == 200) {
|
|
if (response != null && response.getStatusLine().getStatusCode() == 200) {
|
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
@@ -750,7 +766,6 @@ public class ReportServiceImpl implements IReportService {
|
|
bufferedReader.close();
|
|
bufferedReader.close();
|
|
return JSONObject.parseObject(result.toString());
|
|
return JSONObject.parseObject(result.toString());
|
|
}
|
|
}
|
|
-
|
|
|
|
} catch (ClientProtocolException e) {
|
|
} catch (ClientProtocolException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
@@ -768,15 +783,10 @@ public class ReportServiceImpl implements IReportService {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private ICTopOauthTokenService tokenService;
|
|
|
|
-
|
|
|
|
- public JSONObject getAdvertiserStat(CTopOauthToken token, JSONObject conditions) {
|
|
|
|
|
|
+ public JSONObject getAdvertiserStat(CtopOauthToken token, JSONObject conditions) {
|
|
final Long advertiserId = token.getAccountId();
|
|
final Long advertiserId = token.getAccountId();
|
|
-
|
|
|
|
// 请求地址
|
|
// 请求地址
|
|
String url = "https://ad.toutiao.com/open_api/2/report/advertiser/get/";
|
|
String url = "https://ad.toutiao.com/open_api/2/report/advertiser/get/";
|
|
-
|
|
|
|
// 请求参数
|
|
// 请求参数
|
|
Map data = new HashMap() {
|
|
Map data = new HashMap() {
|
|
{
|
|
{
|
|
@@ -788,7 +798,6 @@ public class ReportServiceImpl implements IReportService {
|
|
put("page_size", conditions.getString("page_size"));
|
|
put("page_size", conditions.getString("page_size"));
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-
|
|
|
|
// 构造请求
|
|
// 构造请求
|
|
HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
|
|
HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
|
|
@Override
|
|
@Override
|
|
@@ -796,17 +805,13 @@ public class ReportServiceImpl implements IReportService {
|
|
return "GET";
|
|
return "GET";
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-
|
|
|
|
httpEntity.setHeader("Access-Token", token.getAccessToken());
|
|
httpEntity.setHeader("Access-Token", token.getAccessToken());
|
|
-
|
|
|
|
CloseableHttpResponse response = null;
|
|
CloseableHttpResponse response = null;
|
|
CloseableHttpClient client = null;
|
|
CloseableHttpClient client = null;
|
|
-
|
|
|
|
try {
|
|
try {
|
|
client = HttpClientBuilder.create().build();
|
|
client = HttpClientBuilder.create().build();
|
|
httpEntity.setURI(URI.create(url));
|
|
httpEntity.setURI(URI.create(url));
|
|
httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
|
|
httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
|
|
-
|
|
|
|
response = client.execute(httpEntity);
|
|
response = client.execute(httpEntity);
|
|
if (response != null && response.getStatusLine().getStatusCode() == 200) {
|
|
if (response != null && response.getStatusLine().getStatusCode() == 200) {
|
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
@@ -818,7 +823,6 @@ public class ReportServiceImpl implements IReportService {
|
|
bufferedReader.close();
|
|
bufferedReader.close();
|
|
return JSONObject.parseObject(result.toString());
|
|
return JSONObject.parseObject(result.toString());
|
|
}
|
|
}
|
|
-
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
} finally {
|
|
} finally {
|