Commit 7dc713b3 authored by wei's avatar wei 🎱

供方预警数据导出

parent 2a5fba8f
...@@ -3,12 +3,12 @@ package com.yonde.dcs.plan.common.utils; ...@@ -3,12 +3,12 @@ package com.yonde.dcs.plan.common.utils;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.write.metadata.style.WriteCellStyle; import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont; import com.alibaba.excel.write.metadata.style.WriteFont;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.alibaba.excel.write.style.column.AbstractColumnWidthStyleStrategy;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.yonde.dcs.plan.common.vo.SupplierEarlyWarningVO;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.ss.usermodel.IndexedColors;
...@@ -93,6 +93,40 @@ public class EasyExcelUtils { ...@@ -93,6 +93,40 @@ public class EasyExcelUtils {
exportPublic(fileName, response, data, clazz, excludeColumnFieldNames); exportPublic(fileName, response, data, clazz, excludeColumnFieldNames);
} }
/**
* EasyExce导出到浏览器
* @param fileName 文件名
* @param response 响应对象
* @param list 数据集
* @param clazz 实体类模板
* @param <T> 泛型
* @throws IOException
*/
public static <T> void exportData(String fileName, HttpServletResponse response, List<T> list, Class<T> clazz) throws IOException {
setExcelResponseProp(response, fileName);
EasyExcel.write(response.getOutputStream())
.head(clazz)
.excelType(ExcelTypeEnum.XLSX)
.sheet(fileName)
.doWrite(list);
}
/**
* 设置响应结果
*
* @param response 响应结果对象
* @param rawFileName 文件名
* @throws UnsupportedEncodingException 不支持编码异常
*/
private static void setExcelResponseProp(HttpServletResponse response, String rawFileName) throws UnsupportedEncodingException {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode(rawFileName, "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
}
/** /**
* export公共 * export公共
* *
...@@ -115,7 +149,6 @@ public class EasyExcelUtils { ...@@ -115,7 +149,6 @@ public class EasyExcelUtils {
// .registerWriteHandler(new CustomCellWriteHeightConfig()) // .registerWriteHandler(new CustomCellWriteHeightConfig())
.sheet() .sheet()
.doWrite(data); .doWrite(data);
} }
/** /**
......
package com.yonde.dcs.plan.common.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author weihongda
* @Date 2024/9/21 11:26
* @Description: 供应商预警
*/
@Data
public class SupplierEarlyWarningVO implements Serializable {
/**
* 供方编号
*/
@ExcelProperty("供方编号")
private String number;
/**
* 供方名称
*/
@ExcelProperty("供方名称")
private String name;
/**
* 经营类别
*/
//@ExcelProperty("经营类别")
private String operateType;
/**
* 统一社会信用引用代码
*/
@ExcelProperty("统一社会信用引用代码")
private String unifiedSocietyCode;
/**
* 供方类别
*/
@ExcelProperty("供方类别")
private String supplierType;
/**
* 供方地址
*/
@ExcelProperty("供方地址")
private String supplierAddress;
/**
* 注册时间
*/
@ExcelProperty("注册时间")
private LocalDateTime registrationTime;
/**
* 注册资金
*/
@ExcelProperty("注册资金")
private String registrationFund;
/**
* 名录有效期
*/
@ExcelProperty("名录有效期")
private String directoryValidity;
/**
* 资质内容
*/
@ExcelProperty("资质内容")
private String qualificationsContent;
/**
* 证书编号
*/
@ExcelProperty("证书编号")
private String certificateNumber;
/**
* 证书有效期
*/
@ExcelProperty("证书有效期")
private LocalDateTime certificateTime;
}
package com.yonde.dcs.plan.core.controller; package com.yonde.dcs.plan.core.controller;
import com.yonde.dcs.plan.common.utils.EasyExcelUtils;
import com.yonde.dcs.plan.common.vo.ExtSupplierManageVO; import com.yonde.dcs.plan.common.vo.ExtSupplierManageVO;
import com.yonde.dcs.plan.common.vo.SupplierEarlyWarningVO;
import com.yonde.dcs.plan.core.controller.shadow.ExtSupplierManageControllerShadow; import com.yonde.dcs.plan.core.controller.shadow.ExtSupplierManageControllerShadow;
import com.yonde.dcs.plan.core.service.ExtSupplierManageService; import com.yonde.dcs.plan.core.service.ExtSupplierManageService;
import com.yonde.dcs.plan.entity.po.ExtSupplierManage;
import com.yonde.dex.basedata.entity.api.ApiResult; import com.yonde.dex.basedata.entity.api.ApiResult;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -14,6 +15,10 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -14,6 +15,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/** /**
* @description: ExtSupplierManage-Controller * @description: ExtSupplierManage-Controller
* @author: dexadmin * @author: dexadmin
...@@ -31,15 +36,28 @@ public class ExtSupplierManageController<V extends ExtSupplierManageVO, S extend ...@@ -31,15 +36,28 @@ public class ExtSupplierManageController<V extends ExtSupplierManageVO, S extend
@ApiOperation("发起审批流程") @ApiOperation("发起审批流程")
@PostMapping({"startWorkflow"}) @PostMapping({"startWorkflow"})
public ApiResult startWorkflow(@RequestParam("id") Long id){ public ApiResult startWorkflow(@RequestParam("id") Long id) {
return ApiResult.ok(extSupplierManageService.startWorkflow(id),"操作完成"); return ApiResult.ok(extSupplierManageService.startWorkflow(id), "操作完成");
} }
@ApiOperation("供方预警列表") @ApiOperation("供方预警列表")
@PostMapping({"earlyWarning"}) @PostMapping({"earlyWarning"})
public ApiResult earlyWarning(@RequestParam("warningDay") Integer warningDay){ public ApiResult earlyWarning(@RequestParam("warningDay") Integer warningDay) {
return ApiResult.ok(extSupplierManageService.earlyWarning(warningDay),"查询成功"); return ApiResult.ok(extSupplierManageService.earlyWarning(warningDay), "查询成功");
}
@ApiOperation("导出供方预警列表")
@PostMapping(value = "/exportEarlyWarningData")
public void exportEarlyWarningData(@RequestParam("fileName") String fileName, @RequestParam("ids") List<Long> ids,
HttpServletResponse response) {
try {
List<SupplierEarlyWarningVO> list = extSupplierManageService.exportEarlyWarningData(ids);
EasyExcelUtils.exportData(fileName, response, list, SupplierEarlyWarningVO.class);
} catch (IOException e) {
throw new RuntimeException(e);
} }
}
} }
...@@ -17,4 +17,6 @@ public interface ExtSupplierManageService<V extends ExtSupplierManageVO> extends ...@@ -17,4 +17,6 @@ public interface ExtSupplierManageService<V extends ExtSupplierManageVO> extends
ExtSupplierManageVO startWorkflow(Long id); ExtSupplierManageVO startWorkflow(Long id);
List<SupplierEarlyWarningVO> earlyWarning(Integer warningDay); List<SupplierEarlyWarningVO> earlyWarning(Integer warningDay);
List<SupplierEarlyWarningVO> exportEarlyWarningData(List<Long> ids);
} }
...@@ -15,6 +15,7 @@ import com.yonde.dex.basedata.data.search.SearchQueryCondition; ...@@ -15,6 +15,7 @@ import com.yonde.dex.basedata.data.search.SearchQueryCondition;
import com.yonde.dex.basedata.exception.DxBusinessException; import com.yonde.dex.basedata.exception.DxBusinessException;
import com.yonde.dex.wfc.feign.api.WfcProcessFeign; import com.yonde.dex.wfc.feign.api.WfcProcessFeign;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -75,6 +76,11 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme ...@@ -75,6 +76,11 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme
return list; return list;
} }
@Override
public List<SupplierEarlyWarningVO> exportEarlyWarningData(List<Long> ids) {
return this.earlyWarning(30);
}
private SupplierEarlyWarningVO buildSupplierEarlyWarningVO(ExtSupplierManageVO source, ExtQualificationsVO target) { private SupplierEarlyWarningVO buildSupplierEarlyWarningVO(ExtSupplierManageVO source, ExtQualificationsVO target) {
SupplierEarlyWarningVO supplierEarlyWarningVO = new SupplierEarlyWarningVO(); SupplierEarlyWarningVO supplierEarlyWarningVO = new SupplierEarlyWarningVO();
BeanUtils.copyProperties(source, supplierEarlyWarningVO); BeanUtils.copyProperties(source, supplierEarlyWarningVO);
......
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