Commit 884f9489 by 李小惠

导入导出依赖

parent 8af7f90b
...@@ -51,7 +51,10 @@ ...@@ -51,7 +51,10 @@
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
</dependency>
</dependencies> </dependencies>
......
package com.junmp.jyzb.api.bean.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.*;
import com.alibaba.excel.enums.BooleanEnum;
import com.alibaba.excel.enums.poi.BorderStyleEnum;
import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
import lombok.Builder;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import static com.alibaba.excel.enums.poi.HorizontalAlignmentEnum.CENTER;
@Data
@Builder
@HeadRowHeight(value = 15)
@HeadStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER)
@HeadFontStyle(fontName = "宋体",fontHeightInPoints = 12,bold = BooleanEnum.TRUE)
public class InventoryVo {
/**
* 装备包ID
*/
@ColumnWidth(10)
@ExcelProperty(value = "分类编码")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN,
borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN,
borderRight = BorderStyleEnum.THIN)
private String packageId;
/**
* 装备类型ID
*/
@ColumnWidth(10)
@ExcelProperty(value = "分类编码")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN,
borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN,
borderRight = BorderStyleEnum.THIN)
private String typeId;
/**
* 装备类型名称
*/
@ColumnWidth(10)
@ExcelProperty(value = "分类编码")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN,
borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN,
borderRight = BorderStyleEnum.THIN)
private String typeName;
/**
* 装备型号ID
*/
@ColumnWidth(10)
@ExcelProperty(value = "分类编码")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN,
borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN,
borderRight = BorderStyleEnum.THIN)
private String sizeId;
/**
* 装备型号名称
*/
@ColumnWidth(10)
@ExcelProperty(value = "分类编码")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN,
borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN,
borderRight = BorderStyleEnum.THIN)
private String sizeName;
/**
* 供应商ID
*/
@ColumnWidth(10)
@ExcelProperty(value = "分类编码")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN,
borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN,
borderRight = BorderStyleEnum.THIN)
private String supplierId;
/**
* 部门ID
*/
@ColumnWidth(10)
@ExcelProperty(value = "分类编码")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN,
borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN,
borderRight = BorderStyleEnum.THIN)
private long departmentId;
/**
* 货架位置
*/
@ColumnWidth(10)
@ExcelProperty(value = "分类编码")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN,
borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN,
borderRight = BorderStyleEnum.THIN)
private String shelfLocation;
/**
* 货架id
*/
@ColumnWidth(10)
@ExcelProperty(value = "分类编码")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN,
borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN,
borderRight = BorderStyleEnum.THIN)
private String shelfId;
/**
* 区域id
*/
@ColumnWidth(10)
@ExcelProperty(value = "分类编码")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN,
borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN,
borderRight = BorderStyleEnum.THIN)
private String areaId;
/**
* epc
*/
@ColumnWidth(10)
@ExcelProperty(value = "分类编码")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN,
borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN,
borderRight = BorderStyleEnum.THIN)
private String epc;
/**
* 组织机构ID
*/
@ColumnWidth(10)
@ExcelProperty(value = "分类编码")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN,
borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN,
borderRight = BorderStyleEnum.THIN)
private Long orgId;
/**
* 规格尺寸
*/
@ColumnWidth(10)
@ExcelProperty(value = "分类编码")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN,
borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN,
borderRight = BorderStyleEnum.THIN)
private String state;
/**
* 业务状�
*/
@ColumnWidth(10)
@ExcelProperty(value = "分类编码")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN,
borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN,
borderRight = BorderStyleEnum.THIN)
private String bussinessState;
/**
* 位置状�
*/
@ColumnWidth(10)
@ExcelProperty(value = "分类编码")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN,
borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN,
borderRight = BorderStyleEnum.THIN)
private String locationState;
/**
* 生产日期
*/
@ColumnWidth(10)
@ExcelProperty(value = "生产日期")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN)
private Date productionDate;
/**
* 质保期
*/
@ColumnWidth(10)
@ExcelProperty(value = "质保期")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN)
private long warrantyPeriod;
/**
* 维保期
*/
@ColumnWidth(10)
@ExcelProperty(value = "维保期")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN)
private Integer maintenancePeriod;
/**
* 维修次数
*/
@ColumnWidth(10)
@ExcelProperty(value = "维修次数")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN)
private Integer fixCount;
/**
* 维修次数
*/
@ColumnWidth(10)
@ExcelProperty(value = "超期状态")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN)
private int TermState;
/**
* 位置类型
*/
@ColumnWidth(10)
@ExcelProperty(value = "位置类型")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN)
private Integer locationType;
/**
* 位置ID
*/
@ColumnWidth(20)
@ExcelProperty(value = "位置ID")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN)
private String locationId ;
/**
* 是否遗失
*/
@ColumnWidth(10)
@ExcelProperty(value = "是否遗失")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN)
private Integer lostFlag ;
/**
* 标签id
*/
@ColumnWidth(10)
@ExcelProperty(value = "标签id")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN)
private String tid ;
/**
* 价格
*/
@ColumnWidth(10)
@ExcelProperty(value = "价格")
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
@ContentStyle(horizontalAlignment = CENTER ,verticalAlignment = VerticalAlignmentEnum.CENTER,
borderLeft = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN,
borderTop = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN)
private BigDecimal price ;
}
...@@ -47,6 +47,10 @@ ...@@ -47,6 +47,10 @@
<groupId>com.junmp.v2</groupId> <groupId>com.junmp.v2</groupId>
<artifactId>v2-db-api</artifactId> <artifactId>v2-db-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.junmp.v2</groupId>
<artifactId>office-sdk-excel</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.junmp.jyzb</groupId> <groupId>com.junmp.jyzb</groupId>
......
...@@ -142,8 +142,8 @@ public class InventoryController { ...@@ -142,8 +142,8 @@ public class InventoryController {
//导出,通过传递组织机构id,将该组织机构下的所有装备信息进行导出 //导出,通过传递组织机构id,将该组织机构下的所有装备信息进行导出
@PostMapping("/ExportInventoryExcel") @PostMapping("/ExportInventoryExcel")
@ApiOperation("组织机构装备导出") @ApiOperation("组织机构装备导出")
public void ExportInventoryExcel(@RequestBody @Validated(ValidationApi.export.class) InventoryReq req, HttpServletResponse response) throws IOException { public void ExportInventoryExcel(@RequestBody @Validated(ValidationApi.export.class) InventoryReq req) {
inventoryService.ExportInventoryExcel(req,response); inventoryService.ExportInventoryExcel(req);
} }
//装备出入库记录(通过装备id) //装备出入库记录(通过装备id)
......
...@@ -54,7 +54,7 @@ public interface InventoryService extends IService<Inventory> { ...@@ -54,7 +54,7 @@ public interface InventoryService extends IService<Inventory> {
List<InventorySummary> EqsByCabinetBoxId(CabinetBoxReq req); List<InventorySummary> EqsByCabinetBoxId(CabinetBoxReq req);
//通过组织机构id对该组织机构下的装备进行导出 //通过组织机构id对该组织机构下的装备进行导出
void ExportInventoryExcel(InventoryReq req, HttpServletResponse response) throws IOException; void ExportInventoryExcel(InventoryReq req);
//获取装备的出入库记录 //获取装备的出入库记录
List<InOutRecordsDto> getInOutRecords(InventoryReq req); List<InOutRecordsDto> getInOutRecords(InventoryReq req);
......
...@@ -16,6 +16,9 @@ import com.junmp.jyzb.entity.*; ...@@ -16,6 +16,9 @@ import com.junmp.jyzb.entity.*;
import com.junmp.jyzb.service.*; import com.junmp.jyzb.service.*;
import com.junmp.v2.common.exception.base.ServiceException; import com.junmp.v2.common.exception.base.ServiceException;
import com.junmp.v2.common.util.BeanPlusUtil; import com.junmp.v2.common.util.BeanPlusUtil;
import com.junmp.v2.common.util.HttpServletUtil;
import com.junmp.v2.office.api.OfficeExcelApi;
import com.junmp.v2.office.api.bean.ExcelExportParam;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -24,7 +27,6 @@ import javax.servlet.http.HttpServletResponse; ...@@ -24,7 +27,6 @@ import javax.servlet.http.HttpServletResponse;
import com.junmp.jyzb.mapper.InventoryMapper; import com.junmp.jyzb.mapper.InventoryMapper;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.util.*; import java.util.*;
...@@ -63,6 +65,9 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory ...@@ -63,6 +65,9 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
@Resource @Resource
private LogDetailService logDetailService; private LogDetailService logDetailService;
@Resource
private OfficeExcelApi officeExcelApi;
@Override @Override
public InventoryDto getInventoryDetail(InventoryReq req) { public InventoryDto getInventoryDetail(InventoryReq req) {
Inventory inventory = InventoryExist(req.getId()); Inventory inventory = InventoryExist(req.getId());
...@@ -276,13 +281,18 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory ...@@ -276,13 +281,18 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
//通过组织机构id将该组织下的装备进行导出 //通过组织机构id将该组织下的装备进行导出
@Override @Override
public void ExportInventoryExcel(InventoryReq req, HttpServletResponse response) throws IOException { public void ExportInventoryExcel(InventoryReq req){
//判断组织机构是否存在 //判断组织机构是否存在
pubOrgService.PubOrgExist(req.getOrgId()); pubOrgService.PubOrgExist(req.getOrgId());
//查询该组织机构下的所有装备信息 //查询该组织机构下的所有装备信息
List<Inventory> list = list(new LambdaQueryWrapper<Inventory>() List<Inventory> list = list(new LambdaQueryWrapper<Inventory>()
.eq(Inventory::getOrgId, req.getOrgId())); .eq(Inventory::getOrgId, req.getOrgId()));
String filename="装备列表"; HttpServletResponse response = HttpServletUtil.getResponse();
ExcelExportParam param = new ExcelExportParam();
param.setDataList(list);
param.setClazz(Inventory.class);
param.setResponse(response);
param.setFileName("装备列表.xls");
//对数据进行导出 //对数据进行导出
// ExcelUtils.exportExcel(list,filename,"装备导出",Inventory.class,filename,response); // ExcelUtils.exportExcel(list,filename,"装备导出",Inventory.class,filename,response);
} }
......
...@@ -266,7 +266,24 @@ ...@@ -266,7 +266,24 @@
<version>5.0.5.RELEASE</version> <version>5.0.5.RELEASE</version>
</dependency> </dependency>
<!--导入导出依赖-->
<dependency>
<groupId>com.junmp.v2</groupId>
<artifactId>office-api</artifactId>
<version>${junmp.v2.version}</version>
</dependency>
<dependency>
<groupId>com.junmp.v2</groupId>
<artifactId>office-sdk-excel</artifactId>
<version>${junmp.v2.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.1.3</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论