Commit 2fdd9995 authored by 耿迪迪's avatar 耿迪迪

供需平衡导出

parent 5a719e2e
......@@ -5,11 +5,11 @@ import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.SecurityUtils;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.Statistics;
import com.zehong.system.domain.TSupBalGasSup;
import com.zehong.system.service.ITSupBalGasSupService;
import com.zehong.system.service.ITTroubleStandingBookService;
import com.zehong.web.controller.tool.TimeConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -39,6 +39,9 @@ public class TSupBalGasSupController extends BaseController
public TableDataInfo list(TSupBalGasSup tSupBalGasSup)
{
startPage();
if("-2".equals(SecurityUtils.getLoginUser().getUser().getDeptId())){
tSupBalGasSup.setfRepStatus("1");
}
List<TSupBalGasSup> list = tSupBalGasSupService.selectTSupBalGasSupList(tSupBalGasSup);
return getDataTable(list);
}
......@@ -82,10 +85,23 @@ public class TSupBalGasSupController extends BaseController
*/
@Log(title = "供需平衡-气量监管", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TSupBalGasSup tSupBalGasSup)
{
public AjaxResult export(TSupBalGasSup tSupBalGasSup){
if("-2".equals(SecurityUtils.getLoginUser().getUser().getDeptId())){
tSupBalGasSup.setfRepStatus("1");
}
List<TSupBalGasSup> list = tSupBalGasSupService.selectTSupBalGasSupList(tSupBalGasSup);
ExcelUtil<TSupBalGasSup> util = new ExcelUtil<TSupBalGasSup>(TSupBalGasSup.class);
ExcelUtil<TSupBalGasSup> util = new ExcelUtil<>(TSupBalGasSup.class);
if("-2".equals(SecurityUtils.getLoginUser().getUser().getDeptId())){
List<String> columns = new ArrayList<>();
columns.add("fRepStatus");
columns.add("fRepDate");
util.hideColumns(util.clazz,columns);
}else{
List<String> columns = new ArrayList<>();
columns.add("fGovUploadStatus");
columns.add("fGovUploadTime");
util.hideColumns(util.clazz,columns);
}
return util.exportExcel(list, "供需平衡-气量监管数据");
}
......
package com.zehong.web.controller.supplybalance;
import java.util.ArrayList;
import java.util.List;
import com.zehong.common.utils.SecurityUtils;
......@@ -58,8 +59,24 @@ public class TSupBalStopSupController extends BaseController
@GetMapping("/export")
public AjaxResult export(TSupBalStopSup tSupBalStopSup)
{
if(!"-2".equals(SecurityUtils.getLoginUser().getUser().getDeptId())){
tSupBalStopSup.setfCompanyInfoId(SecurityUtils.getLoginUser().getUser().getDeptId());
}else{
tSupBalStopSup.setfRepStatus("1");
}
List<TSupBalStopSup> list = tSupBalStopSupService.selectTSupBalStopSupList(tSupBalStopSup);
ExcelUtil<TSupBalStopSup> util = new ExcelUtil<TSupBalStopSup>(TSupBalStopSup.class);
if("-2".equals(SecurityUtils.getLoginUser().getUser().getDeptId())){
List<String> columns = new ArrayList<>();
columns.add("fRepStatus");
columns.add("entRepTime");
util.hideColumns(util.clazz,columns);
}else{
List<String> columns = new ArrayList<>();
columns.add("fGovUploadStatus");
columns.add("fGovUploadTime");
util.hideColumns(util.clazz,columns);
}
return util.exportExcel(list, "供需平衡-停气监管数据");
}
......
package com.zehong.web.controller.supplybalance;
import java.util.ArrayList;
import java.util.List;
import com.zehong.common.utils.SecurityUtils;
import com.zehong.system.domain.TSupBalGasSup;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -32,9 +34,11 @@ public class TSupBalUsgDayController extends BaseController
* 查询供需平衡-企业每日填报列表
*/
@GetMapping("/list")
public TableDataInfo list(TSupBalUsgDay tSupBalUsgDay)
{
public TableDataInfo list(TSupBalUsgDay tSupBalUsgDay){
startPage();
if("-2".equals(SecurityUtils.getLoginUser().getUser().getDeptId())){
tSupBalUsgDay.setfReportStatus("1");
}
List<TSupBalUsgDay> list = tSupBalUsgDayService.selectTSupBalUsgDayList(tSupBalUsgDay);
return getDataTable(list);
}
......@@ -44,10 +48,23 @@ public class TSupBalUsgDayController extends BaseController
*/
@Log(title = "供需平衡-企业每日填报", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TSupBalUsgDay tSupBalUsgDay)
{
public AjaxResult export(TSupBalUsgDay tSupBalUsgDay){
if("-2".equals(SecurityUtils.getLoginUser().getUser().getDeptId())){
tSupBalUsgDay.setfReportStatus("1");
}
List<TSupBalUsgDay> list = tSupBalUsgDayService.selectTSupBalUsgDayList(tSupBalUsgDay);
ExcelUtil<TSupBalUsgDay> util = new ExcelUtil<TSupBalUsgDay>(TSupBalUsgDay.class);
if("-2".equals(SecurityUtils.getLoginUser().getUser().getDeptId())){
List<String> columns = new ArrayList<>();
columns.add("fReportStatus");
columns.add("fReportTime");
util.hideColumns(util.clazz,columns);
}else{
List<String> columns = new ArrayList<>();
columns.add("fGovUploadStatus");
columns.add("fGovUploadTime");
util.hideColumns(util.clazz,columns);
}
return util.exportExcel(list, "供需平衡-企业每日填报数据");
}
......
......@@ -105,6 +105,9 @@ public @interface Excel
*/
public boolean isStatistics() default false;
/**隐藏某属性*/
public boolean hide() default false;
/**
* 导出字段对齐方式(0:默认;1:靠左;2:居中;3:靠右)
*/
......
package com.zehong.common.utils.poi;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.commons.collections4.bag.SynchronizedSortedBag;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.zehong.common.annotation.Excel;
import com.zehong.common.annotation.Excel.ColumnType;
import com.zehong.common.annotation.Excel.Type;
......@@ -41,6 +14,22 @@ import com.zehong.common.utils.StringUtils;
import com.zehong.common.utils.file.FileTypeUtils;
import com.zehong.common.utils.file.ImageUtils;
import com.zehong.common.utils.reflect.ReflectUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* Excel相关处理
......@@ -360,7 +349,9 @@ public class ExcelUtil<T>
for (Object[] os : fields)
{
Excel excel = (Excel) os[1];
this.createCell(excel, row, column++);
if(!excel.hide()){
this.createCell(excel, row, column++);
}
// 设置列默认格式
this.createDefaultColumnStyle(wb, tempColumn++);
......@@ -435,7 +426,9 @@ public class ExcelUtil<T>
Excel excel = (Excel) os[1];
// 设置实体类私有属性可访问
field.setAccessible(true);
this.addCell(excel, row, vo, field, column++);
if(!excel.hide()){
this.addCell(excel, row, vo, field, column++);
}
}
}
}
......@@ -1160,4 +1153,22 @@ public class ExcelUtil<T>
}
return value;
}
public void hideColumns (Class<?> clazz,List<String> columNames) {
try {
for(String column : columNames){
Field classProp = clazz.getDeclaredField(column);
Excel excel = classProp.getAnnotation(Excel.class);
InvocationHandler h = Proxy.getInvocationHandler(excel);
Field hFiled = h.getClass().getDeclaredField("memberValues");
hFiled.setAccessible(true);
Map map = (Map)hFiled.get(h);
map.put("hide",true);
}
} catch (Exception e) {
log.error("列隐藏失败", e);
}
}
}
\ No newline at end of file
......@@ -48,7 +48,7 @@ public class TSupBalGasSup extends BaseEntity
private Date fSupDate;
/** 上报状态 0-未上报,1-已上报 */
@Excel(name = "上报状态",readConverterExp = "0=未上报,1=已上报")
@Excel(name = "上报状态",readConverterExp = "0=未上报,1=已上报",isExport = false)
private String fRepStatus;
/** 上报日期 */
......@@ -62,7 +62,6 @@ public class TSupBalGasSup extends BaseEntity
private Date calendarDate;
/** 是否删除(0正常,1删除) */
@Excel(name = "是否删除(0正常,1删除)")
private String isDel;
/** 备注 */
......@@ -82,11 +81,12 @@ public class TSupBalGasSup extends BaseEntity
private Date endCurrentMonthDate;
/** 政府端上报状态 */
@Excel(name = "政府端上报状态",readConverterExp = "0=未上报,1=已上报")
@Excel(name = "上报状态",readConverterExp = "0=未上报,1=已上报")
private String fGovUploadStatus;
/** 政府端上报时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "上报日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date fGovUploadTime;
public void setfGasSupId(Long fGasSupId)
......
......@@ -69,6 +69,7 @@ public class TSupBalStopSup extends BaseEntity
* 企业端上传时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "上报时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private String entRepTime;
/** 停气区域 */
......@@ -82,10 +83,12 @@ public class TSupBalStopSup extends BaseEntity
@Excel(name = "备注")
private String remarks;
@Excel(name = "上报状态",readConverterExp = "0=未上报,1=已上报")
private String fGovUploadStatus;
/** 政府端上报时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "上报时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date fGovUploadTime;
public void setfGasStopId(Long fGasStopId)
......
......@@ -102,13 +102,13 @@ public class TSupBalUsgDay extends BaseEntity
/** 记录时间,日,格式:2023-09-01 */
private String fReportRecord;
@Excel(name = "上报状态",readConverterExp = "0=未上报,1=已上报")
private String fReportStatus;
/** 上报时间,日,格式:2023-09-01 */
@Excel(name = "上报时间")
private String fReportTime;
@Excel(name = "上报状态",readConverterExp = "0=未上报,1=已上报")
private String fReportStatus;
/** 创建时间 yyyy-MM-dd hh:mm:ss */
@Excel(name = "创建时间")
private String fCreateTime;
......@@ -127,10 +127,12 @@ public class TSupBalUsgDay extends BaseEntity
private Date fCalendarDate;
/** 政府端上报状态0-未上报,1-已上报,默认0 */
@Excel(name = "上报状态",readConverterExp = " 0=未上报,1=已上报")
private String fGovUploadStatus;
/** 政府端上报时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "上报时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date fGovUploadTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment