|
@@ -0,0 +1,136 @@
|
|
|
+package org.jeecg.ctop.finance.policy.service.impl;
|
|
|
+
|
|
|
+import cn.com.ctop.common.module.mapper.SysUserMapper;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.apache.poi.hssf.usermodel.*;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
+import org.jeecg.common.system.entity.SysUser;
|
|
|
+import org.jeecg.ctop.finance.policy.entity.CwjsPolicyInfo;
|
|
|
+import org.jeecg.ctop.finance.policy.mapper.CwjsPolicyInfoMapper;
|
|
|
+import org.jeecg.ctop.finance.policy.service.ICreateSheetService;
|
|
|
+import org.jeecg.ctop.finance.policy.service.ICwjsPolicyInfoService;
|
|
|
+import org.jeecg.ctop.finance.policy.utils.Check;
|
|
|
+import org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportBytedanceVo;
|
|
|
+import org.jeecg.ctop.finance.settlement.mapper.ReportSettlementMapper;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @author jeecg-boot
|
|
|
+ * 2021-07-27
|
|
|
+ * @version V1.0
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class CreateSheetServiceImpl implements ICreateSheetService {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ReportSettlementMapper reportSettlementMapper;
|
|
|
+
|
|
|
+
|
|
|
+ public void createBytedance(HSSFWorkbook wb, HSSFCellStyle style, List<String> accountIdList,String uploadYears){
|
|
|
+
|
|
|
+ DecimalFormat sf = new DecimalFormat("#.####");//保留四位小数
|
|
|
+ //2:创建sheet 设置sheet名称
|
|
|
+ HSSFSheet sheet = wb.createSheet("汇总页");
|
|
|
+
|
|
|
+ //3:添加 第一行单元格
|
|
|
+ HSSFRow row0 = sheet.createRow(0);
|
|
|
+ HSSFCell cell0 = row0.createCell(0);
|
|
|
+ //设置 第一行 表头
|
|
|
+ cell0.setCellValue(uploadYears+"-头条结算单汇总");
|
|
|
+ CellRangeAddress region = new CellRangeAddress(0, 0, 0, 10);
|
|
|
+ sheet.addMergedRegion(region);//合并行
|
|
|
+ cell0.setCellStyle(style);
|
|
|
+
|
|
|
+ //4:添加表头2行
|
|
|
+ HSSFRow row = sheet.createRow(1);
|
|
|
+
|
|
|
+ //5:创建第2行的单元格
|
|
|
+ HSSFCell cell = row.createCell(0); //第一个单元格
|
|
|
+ cell.setCellValue("日期"); //设定值
|
|
|
+ cell.setCellStyle(style); //内容居中
|
|
|
+
|
|
|
+ cell = row.createCell(1);
|
|
|
+ cell.setCellValue("账户名称");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+
|
|
|
+ cell = row.createCell(2);
|
|
|
+ cell.setCellValue("账户ID");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+
|
|
|
+ cell = row.createCell(3);
|
|
|
+ cell.setCellValue("所属代理商名称");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+
|
|
|
+ cell = row.createCell(4);
|
|
|
+ cell.setCellValue("所属代理商ID");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+
|
|
|
+ cell = row.createCell(5);
|
|
|
+ cell.setCellValue("账户总支出(¥)");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+
|
|
|
+ cell = row.createCell(6);
|
|
|
+ cell.setCellValue("账户现金支出(¥)");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+
|
|
|
+ cell = row.createCell(7);
|
|
|
+ cell.setCellValue("账户赠款支出(¥)");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+
|
|
|
+ cell = row.createCell(8);
|
|
|
+ cell.setCellValue("账户总存入(¥)");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+
|
|
|
+ cell = row.createCell(9);
|
|
|
+ cell.setCellValue("账户总转入(¥)");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+
|
|
|
+ cell = row.createCell(10);
|
|
|
+ cell.setCellValue("账户总转出(¥)");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+
|
|
|
+ cell = row.createCell(11);
|
|
|
+ cell.setCellValue("账户日终结余(¥)");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+
|
|
|
+ cell = row.createCell(12);
|
|
|
+ cell.setCellValue("冻结(¥)");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ sheet.autoSizeColumn(0, true);
|
|
|
+ List<Map<String,Object>> list = reportSettlementMapper.getAccountTransactionDayBytedanceSheet(accountIdList,uploadYears);
|
|
|
+
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ Map<String,Object> vo = list.get(i);
|
|
|
+ //创建行 (表头占0-1行 所以 从 2开始)
|
|
|
+ row = sheet.createRow(i + 2);
|
|
|
+ sheet.autoSizeColumn(0, true);
|
|
|
+ sheet.autoSizeColumn(i + 1, true);
|
|
|
+ //创建单元格并且添加数据
|
|
|
+ row.createCell(0).setCellValue(uploadYears);
|
|
|
+ row.createCell(1).setCellValue(vo.get("accountName")+"");
|
|
|
+ row.createCell(2).setCellValue(vo.get("advertiser_id")+"");
|
|
|
+ row.createCell(3).setCellValue(vo.get("agentName")+"");
|
|
|
+ row.createCell(4).setCellValue(vo.get("agentId")+"");
|
|
|
+ row.createCell(5).setCellValue(sf.format(vo.get("cost")));
|
|
|
+ row.createCell(6).setCellValue(sf.format(vo.get("cash_cost")));
|
|
|
+ row.createCell(7).setCellValue(sf.format(vo.get("reward_cost")));
|
|
|
+ row.createCell(8).setCellValue(sf.format(vo.get("income")));
|
|
|
+ row.createCell(9).setCellValue(sf.format(vo.get("transfer_in")));
|
|
|
+ row.createCell(10).setCellValue(sf.format(vo.get("transfer_out")));
|
|
|
+ row.createCell(11).setCellValue(sf.format(vo.get("balance")));
|
|
|
+ row.createCell(12).setCellValue(sf.format(vo.get("frozen")));
|
|
|
+ // row.setRowStyle(style);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|