|
@@ -1,24 +1,17 @@
|
|
|
package org.jeecg;
|
|
|
|
|
|
import cn.com.ctop.common.utils.OSSUtils;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import org.apache.poi.hssf.usermodel.HSSFDataFormat;
|
|
|
-import org.apache.poi.ss.usermodel.Cell;
|
|
|
-import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
-import org.apache.poi.ss.usermodel.Row;
|
|
|
-import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
|
-import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
-import org.apache.shiro.crypto.hash.Hash;
|
|
|
import org.jeecg.common.util.ResultMapUtils;
|
|
|
import org.jeecg.common.util.StatusCode;
|
|
|
import org.jeecg.common.util.jsonschema.JsonschemaUtil;
|
|
|
import org.jeecg.modules.ctop.entity.BytedanceAreaInfo;
|
|
|
+import org.jeecg.modules.ctop.entity.BytedanceInterestCategory;
|
|
|
import org.jeecg.modules.ctop.mapper.BytedanceAreaInfoMapper;
|
|
|
-import org.jeecg.modules.ctop.mapper.PlatformCampaignStatisticInfoMapper;
|
|
|
+import org.jeecg.modules.ctop.mapper.BytedanceInterestCategoryMapper;
|
|
|
import org.jeecg.modules.ctop.service.ICreateInternalService;
|
|
|
import org.jeecg.modules.ctop.service.IReportService;
|
|
|
-import org.jeecg.modules.ctop.vo.StatisticCampaignVo;
|
|
|
import org.jeecg.modules.demo.mock.MockController;
|
|
|
import org.jeecg.modules.demo.test.mapper.JeecgDemoMapper;
|
|
|
import org.jeecg.modules.demo.test.service.IJeecgDemoService;
|
|
@@ -30,10 +23,9 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.*;
|
|
|
+import java.io.File;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@RunWith(SpringRunner.class)
|
|
@@ -77,58 +69,6 @@ public class SampleTest {
|
|
|
Map<String, Object> map = createInternalService.checkAccountPassword("dcd_ad@bytedance.com", "typdDCD@2018");
|
|
|
System.out.println(map.toString());
|
|
|
}
|
|
|
- @Test
|
|
|
- public void getExcelData() throws Exception {
|
|
|
- String statisticDate = "2019-08-23";
|
|
|
- Long accountId = 4L;
|
|
|
- Long secondId = 1L;
|
|
|
- List<StatisticCampaignVo> statisticCampaign4Vos = statisticInfoMapper.getVoByParams(accountId);
|
|
|
- List<StatisticCampaignVo> statisticCampaign1Vos = statisticInfoMapper.getVoByParams(secondId);
|
|
|
-
|
|
|
- File f = new File("D:\\upload\\excel\\template.xlsx");
|
|
|
- InputStream inputStream = new FileInputStream(f);
|
|
|
- XSSFWorkbook xssfWorkbook = new XSSFWorkbook(inputStream);
|
|
|
-// //获取第一个sheet
|
|
|
- XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
|
|
|
- CellStyle numbericCellStyle = xssfWorkbook.createCellStyle();
|
|
|
- numbericCellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("0.00"));
|
|
|
- int index;
|
|
|
- for (index = 1; index < statisticCampaign4Vos.size() + 1; index++) {
|
|
|
- StatisticCampaignVo vo = statisticCampaign4Vos.get(index - 1);
|
|
|
- System.out.println(vo.toString());
|
|
|
- String content = vo.getContent();
|
|
|
- String[] contents = content.split("-");
|
|
|
- Row row = xssfSheet.getRow(index);
|
|
|
- setExcelRow(numbericCellStyle, vo, contents, row, "single");
|
|
|
- }
|
|
|
- Row totalRow = xssfSheet.getRow(index);
|
|
|
- StatisticCampaignVo total = statisticInfoMapper.getTotalStatisticVoByparams(accountId);
|
|
|
- if (null != total) {
|
|
|
- setExcelRow(numbericCellStyle, total, new String[]{}, totalRow, "total4");
|
|
|
- }
|
|
|
- index++;
|
|
|
- for (int j = 0; j < statisticCampaign1Vos.size(); j++) {
|
|
|
- index++;
|
|
|
- StatisticCampaignVo vo = statisticCampaign1Vos.get(j);
|
|
|
- System.out.println(vo.toString());
|
|
|
- String content = vo.getContent();
|
|
|
- String[] contents = content.split("-");
|
|
|
- Row row = xssfSheet.getRow(index);
|
|
|
- setExcelRow(numbericCellStyle, vo, contents, row, "single");
|
|
|
- }
|
|
|
- index++;
|
|
|
- Row totalRow1 = xssfSheet.getRow(index);
|
|
|
- StatisticCampaignVo total1 = statisticInfoMapper.getTotalStatisticVoByparams(secondId);
|
|
|
- if (null != total1) {
|
|
|
- setExcelRow(numbericCellStyle, total1, new String[]{}, totalRow1, "total1");
|
|
|
- }
|
|
|
-
|
|
|
- FileOutputStream fileOutputStream = new FileOutputStream("D:\\upload\\excel\\get.xlsx");
|
|
|
- xssfWorkbook.write(fileOutputStream);
|
|
|
- fileOutputStream.close();
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
@Test
|
|
|
public void testFileType() {
|
|
@@ -136,272 +76,11 @@ public class SampleTest {
|
|
|
System.out.println(file);
|
|
|
}
|
|
|
|
|
|
- private void setExcelRow(CellStyle numbericCellStyle, StatisticCampaignVo vo, String[] contents, Row row, String type) {
|
|
|
- for (int j = 0; j < 38; j++) {
|
|
|
- Cell cell = row.createCell(j);
|
|
|
- if (j == 0) {
|
|
|
- //日期
|
|
|
- if (null != type && type.equals("single")) {
|
|
|
- cell.setCellValue(vo.getStatisticDate());
|
|
|
- } else if (null != type && type.equals("total1")) {
|
|
|
- cell.setCellValue("户一总计");
|
|
|
- } else {
|
|
|
- cell.setCellValue("户四总计");
|
|
|
- }
|
|
|
- } else if (j == 1) {
|
|
|
- //代理
|
|
|
- cell.setCellValue(vo.getProxy());
|
|
|
- } else if (j == 2) {
|
|
|
- //投放系统
|
|
|
- if (null != contents && contents.length > 3) {
|
|
|
- cell.setCellValue(contents[2]);
|
|
|
- } else {
|
|
|
- cell.setCellValue("");
|
|
|
- }
|
|
|
- } else if (j == 3) {
|
|
|
- //渠道号
|
|
|
- if (null != contents && contents.length > 2) {
|
|
|
- cell.setCellValue(contents[1]);
|
|
|
- } else {
|
|
|
- cell.setCellValue("");
|
|
|
- }
|
|
|
- } else if (j == 4) {
|
|
|
- //content
|
|
|
- if (null != contents && contents.length > 0) {
|
|
|
- cell.setCellValue(contents[0]);
|
|
|
- } else {
|
|
|
- cell.setCellValue("");
|
|
|
- }
|
|
|
-// cell.setCellValue(vo.getContent());
|
|
|
- } else if (j == 5) {
|
|
|
- if (null != contents && contents.length > 5) {
|
|
|
- cell.setCellValue(contents[4]);
|
|
|
- } else {
|
|
|
- cell.setCellValue("");
|
|
|
- }
|
|
|
- } else if (j == 6) {
|
|
|
- //出价方式
|
|
|
- if (null != contents && contents.length > 6) {
|
|
|
- cell.setCellValue(contents[5]);
|
|
|
- } else {
|
|
|
- cell.setCellValue("");
|
|
|
- }
|
|
|
- } else if (j == 7) {
|
|
|
- //定向条件
|
|
|
- if (null != contents && contents.length > 4) {
|
|
|
- cell.setCellValue(contents[3]);
|
|
|
- } else {
|
|
|
- cell.setCellValue("");
|
|
|
- }
|
|
|
- } else if (j == 8) {
|
|
|
- //定向条件
|
|
|
- if (null != contents && contents.length > 7) {
|
|
|
- cell.setCellValue(contents[6]);
|
|
|
- } else {
|
|
|
- cell.setCellValue("");
|
|
|
- }
|
|
|
- } else if (j == 9) {
|
|
|
- //花费
|
|
|
- if (null != vo.getCost() && !"".equals(vo.getCost())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getCost()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 10) {
|
|
|
- //封面曝光数
|
|
|
- if (null != vo.getCoverViews() && !"".equals(vo.getCoverViews())) {
|
|
|
- cell.setCellValue(Integer.parseInt(vo.getCoverViews()));
|
|
|
- }
|
|
|
- } else if (j == 11) {
|
|
|
- //封面点击数
|
|
|
- if (null != vo.getCoverClick() && !"".equals(vo.getCoverClick())) {
|
|
|
- cell.setCellValue(Integer.parseInt(vo.getCoverClick()));
|
|
|
- }
|
|
|
- } else if (j == 12) {
|
|
|
- //素材曝光数
|
|
|
- if (null != vo.getMaterialViews() && !"".equals(vo.getMaterialViews())) {
|
|
|
- cell.setCellValue(Integer.parseInt(vo.getMaterialViews()));
|
|
|
- }
|
|
|
- } else if (j == 13) {
|
|
|
- //行为数
|
|
|
- if (null != vo.getActions() && !"".equals(vo.getActions())) {
|
|
|
- cell.setCellValue(Integer.parseInt(vo.getActions()));
|
|
|
- }
|
|
|
- } else if (j == 14) {
|
|
|
- //点击率
|
|
|
- if (null != vo.getClickRate() && !"".equals(vo.getClickRate())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getClickRate()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 15) {
|
|
|
- //行为点击率
|
|
|
- if (null != vo.getActionClickRate() && !"".equals(vo.getActionClickRate())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getActionClickRate()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 16) {
|
|
|
- //ACTR*BCTR
|
|
|
- if (null != vo.getAbctr() && !"".equals(vo.getAbctr())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getAbctr()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 17) {
|
|
|
- //点击成本
|
|
|
- if (null != vo.getClickPrice() && !"".equals(vo.getClickPrice())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getClickPrice()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 18) {
|
|
|
- //行为成本
|
|
|
- if (null != vo.getActionPrice() && !"".equals(vo.getActionPrice())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getActionPrice()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 19) {
|
|
|
- //注册用户
|
|
|
- if (null != vo.getRegistUserNum() && !"".equals(vo.getRegistUserNum())) {
|
|
|
- cell.setCellValue(Integer.parseInt(vo.getRegistUserNum()));
|
|
|
- }
|
|
|
- } else if (j == 20) {
|
|
|
- //完件用户
|
|
|
- if (null != vo.getComplateUserNum() && !"".equals(vo.getComplateUserNum())) {
|
|
|
- cell.setCellValue(Integer.parseInt(vo.getComplateUserNum()));
|
|
|
- }
|
|
|
- } else if (j == 21) {
|
|
|
- //授信用户
|
|
|
- if (null != vo.getCreditUserNum() && !"".equals(vo.getCreditUserNum())) {
|
|
|
- cell.setCellValue(Integer.parseInt(vo.getCreditUserNum()));
|
|
|
- }
|
|
|
- } else if (j == 22) {
|
|
|
- //当日注册且完件数
|
|
|
- if (null != vo.getRegistCompleteNum() && !"".equals(vo.getRegistCompleteNum())) {
|
|
|
- cell.setCellValue(Integer.parseInt(vo.getRegistCompleteNum()));
|
|
|
- }
|
|
|
- } else if (j == 23) {
|
|
|
- //当日注册且授信数
|
|
|
- if (null != vo.getRegistCreditNum() && !"".equals(vo.getRegistCreditNum())) {
|
|
|
- cell.setCellValue(Integer.parseInt(vo.getRegistCreditNum()));
|
|
|
- }
|
|
|
- } else if (j == 25) {
|
|
|
- //注册成本
|
|
|
- if (null != vo.getRegistPrice() && !"".equals(vo.getRegistPrice())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getRegistPrice()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 26) {
|
|
|
- //完件成本
|
|
|
- if (null != vo.getCompletePrice() && !"".equals(vo.getCompletePrice())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getCompletePrice()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 27) {
|
|
|
- //授信成本
|
|
|
- if (null != vo.getCreditPrice() && !"".equals(vo.getCreditPrice())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getCreditPrice()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 28) {
|
|
|
- //当日注册且完件成本
|
|
|
- if (null != vo.getRegistCompletePrice() && !"".equals(vo.getRegistCompletePrice())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getRegistCompletePrice()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 29) {
|
|
|
- //当日注册且授信成本
|
|
|
- if (null != vo.getRegistCreditPrice() && !"".equals(vo.getRegistCreditPrice())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getRegistCreditPrice()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 30) {
|
|
|
- //点击注册率
|
|
|
- if (null != vo.getClickRegistRate() && !"".equals(vo.getClickRegistRate())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getClickRegistRate()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 31) {
|
|
|
- //行为注册率
|
|
|
- if (null != vo.getActionRegistRate() && !"".equals(vo.getActionRegistRate())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getActionRegistRate()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 32) {
|
|
|
- //完件率
|
|
|
- if (null != vo.getCompleteRate() && !"".equals(vo.getCompleteRate())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getCompleteRate()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 33) {
|
|
|
- //授信率
|
|
|
- if (null != vo.getCreditRate() && !"".equals(vo.getCreditRate())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getCreditRate()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 34) {
|
|
|
- //当日完件率
|
|
|
- if (null != vo.getRegistCompleteRate() && !"".equals(vo.getRegistCompleteRate())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getRegistCompleteRate()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 35) {
|
|
|
- //当日授信率
|
|
|
- if (null != vo.getRegistCreditRate() && !"".equals(vo.getRegistCreditRate())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getRegistCreditRate()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 36) {
|
|
|
- //当日完件/完件
|
|
|
- if (null != vo.getCompleteRateDay() && !"".equals(vo.getCompleteRateDay())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getCompleteRateDay()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 37) {
|
|
|
- //当日授信/授信
|
|
|
- if (null != vo.getCreditRateDay() && !"".equals(vo.getCreditRateDay())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getCreditRateDay()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- } else if (j == 38) {
|
|
|
- //当日授信/注册
|
|
|
- if (null != vo.getCreditRegistRateDay() && !"".equals(vo.getCreditRegistRateDay())) {
|
|
|
- cell.setCellValue(Float.parseFloat(vo.getCreditRegistRateDay()));
|
|
|
- cell.setCellStyle(numbericCellStyle);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void toPlateform() throws IOException {
|
|
|
- File f = new File("D:\\upload\\excel\\template.xlsx");
|
|
|
- InputStream inputStream = new FileInputStream(f);
|
|
|
- XSSFWorkbook xssfWorkbook = new XSSFWorkbook(inputStream);
|
|
|
-// //获取第一个sheet
|
|
|
- XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
|
|
|
- for (int i = 1; i < 6; i++) {
|
|
|
- System.out.println("i:" + i);
|
|
|
- Row row = xssfSheet.getRow(i);
|
|
|
- for (int j = 1; j < 4; j++) {
|
|
|
- Cell cell = row.createCell(j);
|
|
|
- if (j == 3) {
|
|
|
- cell.setCellType(XSSFCell.CELL_TYPE_FORMULA);
|
|
|
- cell.setCellFormula("B2*C2");
|
|
|
- } else {
|
|
|
- cell.setCellValue(i);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- FileOutputStream fileOutputStream = new FileOutputStream("D:\\upload\\excel\\get.xlsx");
|
|
|
- xssfWorkbook.write(fileOutputStream);
|
|
|
- fileOutputStream.close();
|
|
|
- }
|
|
|
-
|
|
|
@Test
|
|
|
public void testFileUpload() {
|
|
|
OSSUtils.uploadObject2Oss(new File("D:\\upload\\excel\\template.xlsx"));
|
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
- private PlatformCampaignStatisticInfoMapper statisticInfoMapper;
|
|
|
-
|
|
|
@Test
|
|
|
public void testNg() {
|
|
|
JSONObject json = new JSONObject();
|
|
@@ -411,8 +90,44 @@ public class SampleTest {
|
|
|
|
|
|
@Autowired
|
|
|
private BytedanceAreaInfoMapper areaInfoMapper;
|
|
|
+ @Autowired
|
|
|
+ private BytedanceInterestCategoryMapper interestCategoryMapper;
|
|
|
|
|
|
@Test
|
|
|
+ public void setCategoryData() {
|
|
|
+ String path = "D:\\工作文件\\头条批量\\data_20190222\\ad_tag.json";
|
|
|
+ String jsonString = JsonschemaUtil.readJsonFile(path);
|
|
|
+ JSONObject data = JSONObject.parseObject(jsonString);
|
|
|
+ JSONArray tagArray = data.getJSONArray("adtags");
|
|
|
+ tagArray.forEach(tag -> {
|
|
|
+ JSONObject getTag = (JSONObject) tag;
|
|
|
+ String pcode = getTag.getString("value");
|
|
|
+ String plabel = getTag.getString("label");
|
|
|
+ BytedanceInterestCategory category = new BytedanceInterestCategory();
|
|
|
+ category.setCode(pcode);
|
|
|
+ category.setName(plabel);
|
|
|
+ category.setParentCode("0");
|
|
|
+ category.setLevel(1);
|
|
|
+ category.setCreateTime(new Date());
|
|
|
+ category.setUpdateTime(new Date());
|
|
|
+ interestCategoryMapper.insert(category);
|
|
|
+ JSONArray children = getTag.getJSONArray("subTags");
|
|
|
+ children.forEach(child -> {
|
|
|
+ JSONObject getchild = (JSONObject) child;
|
|
|
+ String code = getchild.getString("value");
|
|
|
+ String label = getchild.getString("label");
|
|
|
+ BytedanceInterestCategory childCategory = new BytedanceInterestCategory();
|
|
|
+ childCategory.setCode(code);
|
|
|
+ childCategory.setName(label);
|
|
|
+ childCategory.setParentCode(pcode);
|
|
|
+ childCategory.setLevel(2);
|
|
|
+ childCategory.setCreateTime(new Date());
|
|
|
+ childCategory.setUpdateTime(new Date());
|
|
|
+ interestCategoryMapper.insert(childCategory);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ @Test
|
|
|
public void setJSONFile() {
|
|
|
String path = "C:\\Users\\宋英豪\\Downloads\\data_20190222\\city.json";
|
|
|
String jsonString = JsonschemaUtil.readJsonFile(path);
|
|
@@ -442,7 +157,6 @@ public class SampleTest {
|
|
|
areaInfo.setCreateTime(new Date());
|
|
|
areaInfo.setUpdateTime(new Date());
|
|
|
areaInfoMapper.insert(areaInfo);
|
|
|
-
|
|
|
});
|
|
|
}
|
|
|
}
|