【admin&front】 新增&优化 # 1、新增excel按模版导出 2、检修单新增完工照片字段 3、小程序维修单添加约束部件编码不能和模块号一样
parent
7b3ea8773c
commit
06dcecb077
|
@ -1,14 +1,10 @@
|
|||
package com.hcy.admin.controller.order;
|
||||
|
||||
import com.hcy.admin.config.aop.Log;
|
||||
import com.hcy.admin.service.order.DistributionOrderExcel;
|
||||
import com.hcy.admin.service.order.IRepairOrderService;
|
||||
import com.hcy.admin.service.order.RepairOrderExcel;
|
||||
import com.hcy.admin.validate.order.MaintenanceOrderParam;
|
||||
import com.hcy.admin.validate.order.OrderDistributionParam;
|
||||
import com.hcy.admin.validate.order.RepairOrderParam;
|
||||
import com.hcy.admin.validate.common.PageParam;
|
||||
import com.hcy.admin.validate.order.RoutingInspectionOrderParam;
|
||||
import com.hcy.admin.vo.order.RepairOrderListVo;
|
||||
import com.hcy.admin.vo.order.RepairOrderDetailVo;
|
||||
import com.hcy.common.core.AjaxResult;
|
||||
|
@ -23,7 +19,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 维修订单管理
|
||||
|
@ -158,4 +153,10 @@ public class RepairOrderController {
|
|||
log.error("报表导出异常:", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "模块管理 - 导出模块维修报表 - 按模版导出")
|
||||
@PostMapping(value="/exportModuleMaintenanceExcelTemplate")
|
||||
public void exportModuleMaintenanceExcelTemplate(@Validated @RequestBody RepairOrderParam params, HttpServletResponse response) {
|
||||
iRepairOrderService.getExportModuleMaintenanceExcelTemplate(params,response);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.hcy.admin.service.order;
|
|||
|
||||
import com.hcy.admin.validate.common.PageParam;
|
||||
import com.hcy.admin.validate.order.RepairOrderParam;
|
||||
import com.hcy.admin.vo.excel.ModuleMaintenanceExcel;
|
||||
import com.hcy.admin.vo.order.RepairOrderListVo;
|
||||
import com.hcy.admin.vo.order.RepairOrderDetailVo;
|
||||
import com.hcy.common.core.PageResult;
|
||||
|
@ -80,4 +81,11 @@ public interface IRepairOrderService {
|
|||
* @return
|
||||
*/
|
||||
List<RepairOrderExcel> getExportModuleMaintenanceExcel(RepairOrderParam params);
|
||||
|
||||
/**
|
||||
* 导出模块维修报表 - 按模版导出
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
void getExportModuleMaintenanceExcelTemplate(RepairOrderParam params,HttpServletResponse response);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,21 @@
|
|||
package com.hcy.admin.service.order;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.hcy.admin.vo.sparePartStockAudit.SparePartStockAuditDetailVo;
|
||||
import com.hcy.common.entity.order.OrderPartCode;
|
||||
import com.alibaba.excel.annotation.write.style.*;
|
||||
|
||||
import com.alibaba.excel.enums.poi.BorderStyleEnum;
|
||||
import com.alibaba.excel.enums.poi.FillPatternTypeEnum;
|
||||
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
|
||||
import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
|
||||
import com.hcy.common.utils.excel.ImageUrlConverter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -14,6 +23,18 @@ import java.util.List;
|
|||
* RepairOrderExcel
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@AllArgsConstructor
|
||||
// 头背景设置
|
||||
//@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, horizontalAlignment = HorizontalAlignmentEnum.CENTER, borderLeft = BorderStyleEnum.THIN, borderTop = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN)
|
||||
//标题高度
|
||||
@HeadRowHeight(20)
|
||||
//内容高度
|
||||
@ContentRowHeight(120)
|
||||
//内容居中,左、上、右、下的边框显示
|
||||
@ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER, verticalAlignment = VerticalAlignmentEnum.CENTER, borderLeft = BorderStyleEnum.THIN, borderTop = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN)
|
||||
public class RepairOrderExcel implements Serializable {
|
||||
|
||||
|
||||
|
@ -21,27 +42,38 @@ public class RepairOrderExcel implements Serializable {
|
|||
private String orderNo; // 订单编号*/
|
||||
|
||||
@ColumnWidth(20) // 定义列宽
|
||||
@ExcelProperty(value = {"模块号"}, index = 0)
|
||||
private String moduleNumber; // 模块号
|
||||
@ExcelProperty(value = {"客户名称"}, index = 0)
|
||||
private String clientName; // 客户名称
|
||||
|
||||
@ColumnWidth(20) // 定义列宽
|
||||
@ExcelProperty(value = {"模块代码"}, index = 1)
|
||||
@ExcelProperty(value = {"模块号"}, index = 1)
|
||||
private String moduleCode; // 模块代码
|
||||
|
||||
@ColumnWidth(20) // 定义列宽
|
||||
@ExcelProperty(value = {"发现时间"}, index = 2)
|
||||
@ExcelProperty(value = {"模块型号"}, index = 2)
|
||||
private String moduleNumber; // 模块型号
|
||||
|
||||
@ColumnWidth(20) // 定义列宽
|
||||
@ExcelProperty(value = {"发现时间"}, index = 3)
|
||||
private Date createTime; // 创建时间
|
||||
|
||||
@ColumnWidth(20) // 定义列宽
|
||||
@ExcelProperty(value = {"维修前(现场图片)"}, index = 3)
|
||||
private String preMaintenanceImg; // 维修前照片
|
||||
@ExcelProperty(value = {"维修前(现场图片)"}, index = 4, converter = ImageUrlConverter.class)
|
||||
private List<URL> preMaintenanceImg; // 维修前照片
|
||||
|
||||
@ColumnWidth(20) // 定义列宽
|
||||
@ExcelProperty(value = {"维修中"}, index = 4)
|
||||
private String inMaintenanceImg; // 维修中照片
|
||||
@ExcelProperty(value = {"维修中"}, index = 5, converter = ImageUrlConverter.class)
|
||||
private List<URL> inMaintenanceImg; // 维修中照片
|
||||
|
||||
@ColumnWidth(20) // 定义列宽
|
||||
@ExcelProperty(value = {"维修后"}, index = 5)
|
||||
private String afterRepairImg; // 维修后照片
|
||||
@ExcelProperty(value = {"维修后"}, index = 6, converter = ImageUrlConverter.class)
|
||||
private List<URL> afterRepairImg; // 维修后照片
|
||||
|
||||
@ColumnWidth(20) // 定义列宽
|
||||
@ExcelProperty(value = {"故障原因"}, index = 6)
|
||||
@ExcelProperty(value = {"故障原因"}, index = 7)
|
||||
private String faultName; //故障名称
|
||||
@ExcelProperty(value = {"是否报废"}, index = 7)
|
||||
|
||||
@ExcelProperty(value = {"是否报废"}, index = 8)
|
||||
private String scrapOrNot; // 是否报废(0=是,1=否)
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.hcy.admin.service.order.impl;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
import com.alibaba.excel.write.metadata.fill.FillConfig;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
@ -15,6 +19,7 @@ import com.hcy.admin.validate.order.RepairOrderParam;
|
|||
import com.hcy.admin.validate.order.RoutingInspectionOrderParam;
|
||||
import com.hcy.admin.vo.address.UserAddressListVo;
|
||||
import com.hcy.admin.vo.client.EquipmentListVo;
|
||||
import com.hcy.admin.vo.excel.ModuleMaintenanceExcel;
|
||||
import com.hcy.admin.vo.order.OrderSparePartListVo;
|
||||
import com.hcy.admin.vo.order.RepairOrderListVo;
|
||||
import com.hcy.admin.vo.order.RepairOrderDetailVo;
|
||||
|
@ -48,16 +53,26 @@ import com.hcy.common.mapper.system.SystemAuthAdminMapper;
|
|||
import com.hcy.common.mapper.user.UserMapper;
|
||||
import com.hcy.common.mapper.warehouse.WarehouseMapper;
|
||||
import com.hcy.common.utils.ArrayUtil;
|
||||
import com.hcy.common.utils.StringUtil;
|
||||
import com.hcy.common.utils.TimeUtil;
|
||||
import com.hcy.common.utils.UrlUtil;
|
||||
import com.hcy.common.config.GlobalConfig;
|
||||
import com.hcy.common.utils.excel.CustomImageModifyStrategy;
|
||||
import com.hcy.common.utils.excel.EasyExcelUtil;
|
||||
import com.hcy.common.utils.excel.LocalImageModifyStrategy;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URL;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
|
@ -669,6 +684,7 @@ public class RepairOrderServiceImpl implements IRepairOrderService {
|
|||
BeanUtils.copyProperties(params,repairOrderDto);
|
||||
|
||||
List<RepairOrderDto> resultDtoList = repairOrderMapper.getExportModuleMaintenanceExcel(repairOrderDto);
|
||||
|
||||
List<RepairOrderExcel> list = new LinkedList<>();
|
||||
|
||||
for (RepairOrderDto item : resultDtoList) {
|
||||
|
@ -681,21 +697,55 @@ public class RepairOrderServiceImpl implements IRepairOrderService {
|
|||
.eq(RepairOrderStepData::getRepairOrderId, item.getId())
|
||||
.eq(RepairOrderStepData::getRepairStep, RepairOrderStopEnum.PRE_MAINTENANCE_IMG.getStatus()));
|
||||
if(preMaintenanceImg != null){
|
||||
repairOrderExcel.setPreMaintenanceImg(preMaintenanceImg.getImg());
|
||||
try{
|
||||
List<URL> imgList1 = new ArrayList<>();
|
||||
String[] arr = preMaintenanceImg.getImg().split(",");
|
||||
for (String s : arr) {
|
||||
System.out.println(s);
|
||||
imgList1.add(new URL(s));
|
||||
}
|
||||
|
||||
repairOrderExcel.setPreMaintenanceImg(imgList1);
|
||||
}catch (Exception e) {
|
||||
System.out.println("导出异常");
|
||||
}
|
||||
|
||||
}
|
||||
//返回维修中照片
|
||||
RepairOrderStepData inMaintenanceImg = repairOrderStepDataMapper.selectOne(new LambdaQueryWrapper<RepairOrderStepData>()
|
||||
.eq(RepairOrderStepData::getRepairOrderId, item.getId())
|
||||
.eq(RepairOrderStepData::getRepairStep, RepairOrderStopEnum.IN_MAINTENANCE_IMG.getStatus()));
|
||||
if(inMaintenanceImg != null){
|
||||
repairOrderExcel.setInMaintenanceImg(inMaintenanceImg.getImg());
|
||||
try{
|
||||
List<URL> imgList1 = new ArrayList<>();
|
||||
String[] arr = inMaintenanceImg.getImg().split(",");
|
||||
for (String s : arr) {
|
||||
System.out.println(s);
|
||||
imgList1.add(new URL(s));
|
||||
}
|
||||
|
||||
repairOrderExcel.setInMaintenanceImg(imgList1);
|
||||
}catch (Exception e) {
|
||||
System.out.println("导出异常");
|
||||
}
|
||||
}
|
||||
//返回维修后照片
|
||||
RepairOrderStepData afterRepairImg = repairOrderStepDataMapper.selectOne(new LambdaQueryWrapper<RepairOrderStepData>()
|
||||
.eq(RepairOrderStepData::getRepairOrderId, item.getId())
|
||||
.eq(RepairOrderStepData::getRepairStep, RepairOrderStopEnum.AFTER_REPAIR_IMG.getStatus()));
|
||||
if(afterRepairImg != null){
|
||||
repairOrderExcel.setAfterRepairImg(afterRepairImg.getImg());
|
||||
try{
|
||||
List<URL> imgList1 = new ArrayList<>();
|
||||
String[] arr = afterRepairImg.getImg().split(",");
|
||||
for (String s : arr) {
|
||||
System.out.println(s);
|
||||
imgList1.add(new URL(s));
|
||||
}
|
||||
|
||||
repairOrderExcel.setAfterRepairImg(imgList1);
|
||||
}catch (Exception e) {
|
||||
System.out.println("导出异常");
|
||||
}
|
||||
}
|
||||
|
||||
//故障类型名称
|
||||
|
@ -722,5 +772,138 @@ public class RepairOrderServiceImpl implements IRepairOrderService {
|
|||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出模块维修报表 - 按模版导出
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void getExportModuleMaintenanceExcelTemplate(RepairOrderParam params, HttpServletResponse response) {
|
||||
RepairOrderDto repairOrderDto = new RepairOrderDto();
|
||||
BeanUtils.copyProperties(params,repairOrderDto);
|
||||
|
||||
List<RepairOrderDto> resultDtoList = repairOrderMapper.getExportModuleMaintenanceExcel(repairOrderDto);
|
||||
|
||||
List<ModuleMaintenanceExcel> list = new LinkedList<>();
|
||||
|
||||
for (RepairOrderDto item : resultDtoList) {
|
||||
ModuleMaintenanceExcel repairOrderExcel = new ModuleMaintenanceExcel();
|
||||
BeanUtils.copyProperties(item, repairOrderExcel);
|
||||
|
||||
//返回前中后照片
|
||||
//返回维修前照片
|
||||
RepairOrderStepData preMaintenanceImg = repairOrderStepDataMapper.selectOne(new LambdaQueryWrapper<RepairOrderStepData>()
|
||||
.eq(RepairOrderStepData::getRepairOrderId, item.getId())
|
||||
.eq(RepairOrderStepData::getRepairStep, RepairOrderStopEnum.PRE_MAINTENANCE_IMG.getStatus()));
|
||||
if(preMaintenanceImg != null){
|
||||
try{
|
||||
List<URL> imgList1 = new ArrayList<>();
|
||||
String[] arr = preMaintenanceImg.getImg().split(",");
|
||||
for (String s : arr) {
|
||||
System.out.println(s);
|
||||
imgList1.add(new URL(s));
|
||||
}
|
||||
|
||||
repairOrderExcel.setPreMaintenanceImg(imgList1);
|
||||
}catch (Exception e) {
|
||||
System.out.println("导出异常");
|
||||
}
|
||||
|
||||
}
|
||||
//返回维修中照片
|
||||
RepairOrderStepData inMaintenanceImg = repairOrderStepDataMapper.selectOne(new LambdaQueryWrapper<RepairOrderStepData>()
|
||||
.eq(RepairOrderStepData::getRepairOrderId, item.getId())
|
||||
.eq(RepairOrderStepData::getRepairStep, RepairOrderStopEnum.IN_MAINTENANCE_IMG.getStatus()));
|
||||
if(inMaintenanceImg != null){
|
||||
try{
|
||||
List<URL> imgList1 = new ArrayList<>();
|
||||
String[] arr = inMaintenanceImg.getImg().split(",");
|
||||
for (String s : arr) {
|
||||
System.out.println(s);
|
||||
imgList1.add(new URL(s));
|
||||
}
|
||||
|
||||
repairOrderExcel.setInMaintenanceImg(imgList1);
|
||||
}catch (Exception e) {
|
||||
System.out.println("导出异常");
|
||||
}
|
||||
}
|
||||
//返回维修后照片
|
||||
RepairOrderStepData afterRepairImg = repairOrderStepDataMapper.selectOne(new LambdaQueryWrapper<RepairOrderStepData>()
|
||||
.eq(RepairOrderStepData::getRepairOrderId, item.getId())
|
||||
.eq(RepairOrderStepData::getRepairStep, RepairOrderStopEnum.AFTER_REPAIR_IMG.getStatus()));
|
||||
if(afterRepairImg != null){
|
||||
try{
|
||||
List<URL> imgList1 = new ArrayList<>();
|
||||
String[] arr = afterRepairImg.getImg().split(",");
|
||||
for (String s : arr) {
|
||||
System.out.println(s);
|
||||
imgList1.add(new URL(s));
|
||||
}
|
||||
|
||||
repairOrderExcel.setAfterRepairImg(imgList1);
|
||||
}catch (Exception e) {
|
||||
System.out.println("导出异常");
|
||||
}
|
||||
}
|
||||
|
||||
//故障类型名称
|
||||
Fault faultName = faultMapper.selectOne(
|
||||
new LambdaQueryWrapper<Fault>()
|
||||
.eq(Fault::getId, item.getFaultId()));
|
||||
if(faultName != null){
|
||||
repairOrderExcel.setFaultName(faultName.getName());
|
||||
}
|
||||
|
||||
// scrapOrNot 是否报废(0=是,1=否)
|
||||
if(item.getScrapOrNot() != null){
|
||||
if(item.getScrapOrNot() == 0){
|
||||
repairOrderExcel.setScrapOrNot("是");
|
||||
} else if (item.getScrapOrNot() == 1) {
|
||||
repairOrderExcel.setScrapOrNot("否");
|
||||
}
|
||||
}
|
||||
|
||||
//制单人、制单时间
|
||||
repairOrderExcel.setDocumentationName(String.valueOf(AdminThreadLocal.get("username")));
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
repairOrderExcel.setDocumentationTime(sdf.format(new Date()));
|
||||
list.add(repairOrderExcel);
|
||||
}
|
||||
|
||||
try {
|
||||
ServletOutputStream out = response.getOutputStream();
|
||||
|
||||
EasyExcelUtil.initResponse(response, "模块维修报表");
|
||||
|
||||
// 文件模板输入流,将 excel 模板放到 resources 目录下
|
||||
InputStream templateFile = new ClassPathResource("templates/excel/ModuleMaintenance-template.xlsx").getInputStream();
|
||||
|
||||
ExcelWriter writer = EasyExcel
|
||||
.write(out)
|
||||
.withTemplate(templateFile)
|
||||
// 使用图片处理策略
|
||||
.registerWriteHandler(
|
||||
// 设置每张图片的宽度为 200px,转换因子为 32
|
||||
new LocalImageModifyStrategy(100, 32))
|
||||
.build();
|
||||
|
||||
WriteSheet sheet = EasyExcel.writerSheet().build();
|
||||
|
||||
// 填充配置,开启组合填充换行
|
||||
FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build();
|
||||
|
||||
// 填充列表占位符
|
||||
writer.fill(list, fillConfig, sheet);
|
||||
|
||||
//填充完成
|
||||
writer.finish();
|
||||
} catch (Exception e) {
|
||||
System.out.println("导出异常:" + e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -105,6 +105,7 @@ public class MaintenanceOrderParam implements Serializable {
|
|||
|
||||
private String createTimeStart; //报修开始时间
|
||||
private String createTimeEnd; //报修结束时间
|
||||
private String completeImg; // 完工照片
|
||||
private String createImg; // 创建照片
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import javax.validation.constraints.*;
|
|||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 维修订单参数
|
||||
|
@ -107,4 +108,7 @@ public class RepairOrderParam implements Serializable {
|
|||
private Integer repairStep; // 当前步骤(0=拆机,1=清洗,2=故障排查,3=确认签名,4=重领配件,5=上传维修前图片,6=上传维修中图片,7=上传维修后图片,8=补强三防漆,9=补强点胶,10=DC&PFC组装,11=补强三防漆和点胶,12=模块装配,13=功能测试,14=老化测试,15=包装出货,16=填写回单)
|
||||
private Integer repairNextStep; // 下个步骤(0=拆机,1=清洗,2=故障排查,3=确认签名,4=重领配件,5=上传维修前图片,6=上传维修中图片,7=上传维修后图片,8=补强三防漆,9=补强点胶,10=DC&PFC组装,11=补强三防漆和点胶,12=模块装配,13=功能测试,14=老化测试,15=包装出货,16=填写回单)
|
||||
private Integer timeoutOrNot; // 是否超时(0=是,1=否)
|
||||
|
||||
private List<Integer> ids; //批量操作
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package com.hcy.admin.vo.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.hcy.common.utils.excel.DownloadUrlConverter;
|
||||
import com.hcy.common.utils.excel.ImageUrlConverter;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ModuleMaintenanceExcel {
|
||||
|
||||
@ApiModelProperty(value = "客户名称")
|
||||
private String clientName; // 客户名称
|
||||
|
||||
@ApiModelProperty(value = "模块代码")
|
||||
private String moduleCode; // 模块代码
|
||||
|
||||
@ApiModelProperty(value = "模块型号")
|
||||
private String moduleNumber; // 模块型号
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime; // 创建时间
|
||||
|
||||
@ApiModelProperty(value = "维修前照片")
|
||||
@ExcelProperty(value = {"维修前(现场图片)"}, converter = DownloadUrlConverter.class)
|
||||
private List<URL> preMaintenanceImg; // 维修前照片
|
||||
|
||||
@ApiModelProperty(value = "维修中照片")
|
||||
@ExcelProperty(value = {"维修中照片"}, converter = DownloadUrlConverter.class)
|
||||
private List<URL> inMaintenanceImg; // 维修中照片
|
||||
|
||||
@ApiModelProperty(value = "维修后照片")
|
||||
@ExcelProperty(value = {"维修后照片"}, converter = DownloadUrlConverter.class)
|
||||
private List<URL> afterRepairImg; // 维修后照片
|
||||
|
||||
@ApiModelProperty(value = "故障名称")
|
||||
private String faultName; //故障名称
|
||||
|
||||
@ApiModelProperty(value = "是否报废")
|
||||
private String scrapOrNot; // 是否报废(0=是,1=否)
|
||||
|
||||
private String documentationTime; // 制单日期
|
||||
private String documentationName; // 制单人
|
||||
}
|
|
@ -71,6 +71,7 @@ public class MaintenanceOrderDetailVo implements Serializable {
|
|||
|
||||
private Date quotationTime; //报价时间
|
||||
private Integer receiveStatus; // 配件领用状态(0=未审核,1=审核未通过,2=待领取,3=待确认,4=已完成)
|
||||
private String completeImg; // 完工照片
|
||||
private String createImg; // 创建照片
|
||||
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ public class MaintenanceOrderListVo implements Serializable {
|
|||
private String shortName; //客户简称
|
||||
private EquipmentModelDetailVo equipmentModel; //设备模块信息
|
||||
private Integer receiveStatus; // 配件领用状态(0=未审核,1=审核未通过,2=待领取,3=待确认,4=已完成)
|
||||
private String completeImg; // 完工照片
|
||||
private String createImg; // 创建照片
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,11 @@ spring:
|
|||
driver-class-name: com.mysql.jdbc.Driver # MySql的驱动
|
||||
username: root # 数据库账号
|
||||
password: hcy123456
|
||||
# url: jdbc:mysql://120.77.216.5:3306/charging-pile?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
|
||||
# type: com.zaxxer.hikari.HikariDataSource # 数据源类型
|
||||
# driver-class-name: com.mysql.jdbc.Driver # MySql的驱动
|
||||
# username: charging-pile # 数据库账号
|
||||
# password: FZcP7eFwN4T5jkXz
|
||||
# Redis配置
|
||||
redis:
|
||||
host: localhost # Redis服务地址
|
||||
|
|
|
@ -29,6 +29,11 @@ spring:
|
|||
driver-class-name: com.mysql.jdbc.Driver # MySql的驱动
|
||||
username: root # 数据库账号
|
||||
password: hcy123456
|
||||
# url: jdbc:mysql://120.77.216.5:3306/charging-pile?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
|
||||
# type: com.zaxxer.hikari.HikariDataSource # 数据源类型
|
||||
# driver-class-name: com.mysql.jdbc.Driver # MySql的驱动
|
||||
# username: charging-pile # 数据库账号
|
||||
# password: FZcP7eFwN4T5jkXz
|
||||
hikari:
|
||||
connection-timeout: 30000 # 等待连接分配连接的最大时长(毫秒),超出时长还没可用连接则发送SQLException,默认30秒
|
||||
minimum-idle: 5 # 最小连接数
|
||||
|
|
Binary file not shown.
|
@ -268,6 +268,12 @@
|
|||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel-core</artifactId>
|
||||
<version>3.3.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -88,4 +88,7 @@ public class RepairOrderDto implements Serializable {
|
|||
private Integer repairStep; // 当前步骤(0=拆机,1=清洗,2=故障排查,3=确认签名,4=重领配件,5=上传维修前图片,6=上传维修中图片,7=上传维修后图片,8=补强三防漆,9=补强点胶,10=DC&PFC组装,11=补强三防漆和点胶,12=模块装配,13=功能测试,14=老化测试,15=包装出货,16=填写回单)
|
||||
private Integer repairNextStep; // 下个步骤(0=拆机,1=清洗,2=故障排查,3=确认签名,4=重领配件,5=上传维修前图片,6=上传维修中图片,7=上传维修后图片,8=补强三防漆,9=补强点胶,10=DC&PFC组装,11=补强三防漆和点胶,12=模块装配,13=功能测试,14=老化测试,15=包装出货,16=填写回单)
|
||||
private Integer timeoutOrNot; // 是否超时(0=是,1=否)
|
||||
|
||||
private List<Integer> ids; //批量操作
|
||||
|
||||
}
|
||||
|
|
|
@ -38,9 +38,13 @@ public class RoutingInspectionOrder implements Serializable {
|
|||
private BigDecimal orderDistance; // 订单距离
|
||||
private BigDecimal totalAmount; // 总金额
|
||||
private BigDecimal actualAmount; // 实际金额
|
||||
|
||||
@TableField(value = "receiver_id",updateStrategy = FieldStrategy.IGNORED)
|
||||
private Long receiverId; // 接单人id
|
||||
private Long repairId; // 返修id
|
||||
@TableField(value = "receiver_time",updateStrategy = FieldStrategy.IGNORED)
|
||||
private Date receiverTime; // 接单时间
|
||||
|
||||
private Date cancelOrderTime; // 取消订单时间
|
||||
private String cancelCause; // 取消原因
|
||||
private String refuseMaintenanceCause; // 拒绝维修原因
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
package com.hcy.common.utils;
|
||||
|
||||
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
|
||||
import com.alibaba.excel.write.metadata.style.WriteFont;
|
||||
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
|
||||
import com.hcy.common.utils.excel.CustomImageModifyStrategy;
|
||||
import com.hcy.common.utils.excel.MonthSheetWriteHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.support.ExcelTypeEnum;
|
||||
import org.apache.poi.ss.usermodel.BorderStyle;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
|
@ -49,7 +57,21 @@ public class ExcelUtils {
|
|||
// 这里URLEncoder.encode可以防止中文乱码
|
||||
excelName = URLEncoder.encode(excelName, "UTF-8");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + excelName + ExcelTypeEnum.XLSX.getValue());
|
||||
EasyExcel.write(response.getOutputStream(), clazz).sheet(sheetName).doWrite(data);
|
||||
|
||||
EasyExcel.write(response.getOutputStream(), clazz)
|
||||
.autoCloseStream(true)
|
||||
//设置输出excel版本,不设置默认为xlsx
|
||||
.excelType(ExcelTypeEnum.XLSX).head(clazz)
|
||||
//设置拦截器或自定义样式
|
||||
.registerWriteHandler(new MonthSheetWriteHandler())
|
||||
// 使用图片处理策略
|
||||
.registerWriteHandler(
|
||||
// 设置每张图片的宽度为 200px,转换因子为 32
|
||||
new CustomImageModifyStrategy(200, 32))
|
||||
.sheet(sheetName)
|
||||
//设置默认样式及写入头信息开始的行数
|
||||
.useDefaultStyle(true).relativeHeadRowIndex(6)
|
||||
.doWrite(data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,190 @@
|
|||
package com.hcy.common.utils.excel;
|
||||
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.Head;
|
||||
import com.alibaba.excel.metadata.data.ImageData;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.write.handler.CellWriteHandler;
|
||||
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
|
||||
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.util.Units;
|
||||
import org.apache.poi.xssf.usermodel.XSSFDrawing;
|
||||
import org.apache.poi.xssf.usermodel.XSSFPicture;
|
||||
import org.apache.poi.xssf.usermodel.XSSFShape;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* Excel导出单元格中有图片,图片会进行压缩,缩略,插入单元格
|
||||
* 注意:
|
||||
* - 该策略是复制原表格中的图片进行缩放,原图片并没有删除掉,而是将尺寸设置为 0 看不到而已,但是依旧占用空间
|
||||
* - 且在多 sheet 的环境下,除第一个 sheet,其余的 sheet 图片会被置 0
|
||||
* 目前上述问题并没有得到解决,如果在导出数据较多或者存在多个 sheet 的情况下不建议使用
|
||||
*/
|
||||
public class CustomImageModifyStrategy implements CellWriteHandler {
|
||||
|
||||
/**
|
||||
* 已经处理的Cell
|
||||
*/
|
||||
private final CopyOnWriteArrayList<String> REPEATS = new CopyOnWriteArrayList<>();
|
||||
|
||||
/**
|
||||
* 单元格的图片最大张数(每列的单元格图片张数不确定,单元格宽度需按照张数最多的长度来设置)
|
||||
*/
|
||||
private final AtomicReference<Integer> MAX_IMAGE_SIZE = new AtomicReference<>(0);
|
||||
|
||||
/**
|
||||
* 标记手动添加的图片,用于排除EasyExcel自动添加的图片
|
||||
*/
|
||||
private final CopyOnWriteArrayList<Integer> CREATE_PIC_INDEX = new CopyOnWriteArrayList<>();
|
||||
|
||||
/**
|
||||
* 默认图片宽度(单位像素):60
|
||||
*/
|
||||
private final static int DEFAULT_IMAGE_WIDTH = 60;
|
||||
|
||||
/**
|
||||
* 默认像素转换因子:32
|
||||
*/
|
||||
private final static int DEFAULT_PIXEL_CONVERSION_FACTOR = 32;
|
||||
|
||||
/**
|
||||
* 图片宽度,单位像素
|
||||
*/
|
||||
private final int imageWidth;
|
||||
|
||||
/**
|
||||
* 像素转换因子
|
||||
*/
|
||||
private final int pixelConversionFactor;
|
||||
|
||||
public CustomImageModifyStrategy() {
|
||||
this.imageWidth = DEFAULT_IMAGE_WIDTH;
|
||||
this.pixelConversionFactor = DEFAULT_PIXEL_CONVERSION_FACTOR;
|
||||
}
|
||||
|
||||
public CustomImageModifyStrategy(int imageWidth, int pixelConversionFactor) {
|
||||
this.imageWidth = imageWidth;
|
||||
this.pixelConversionFactor = pixelConversionFactor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Head head, Integer columnIndex, Integer relativeRowIndex, Boolean isHead) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCellDataConverted(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, WriteCellData<?> cellData, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
|
||||
// 在数据转换成功后 不是头就把类型设置成空
|
||||
if (isHead) {
|
||||
return;
|
||||
}
|
||||
//将要插入图片的单元格的type设置为空,下面再填充图片
|
||||
if (!CollectionUtils.isEmpty(cellData.getImageDataList())) {
|
||||
cellData.setType(CellDataTypeEnum.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
|
||||
// 在 单元格写入完毕后 ,自己填充图片
|
||||
if (isHead || CollectionUtils.isEmpty(cellDataList)) {
|
||||
return;
|
||||
}
|
||||
boolean listFlag = false;
|
||||
Sheet sheet = cell.getSheet();
|
||||
List<ImageData> imageDataList = cellDataList.get(0).getImageDataList();
|
||||
if (!CollectionUtils.isEmpty(imageDataList)) {
|
||||
listFlag = true;
|
||||
}
|
||||
if (!listFlag && imageDataList == null) {
|
||||
return;
|
||||
}
|
||||
String key = cell.getRowIndex() + "_" + cell.getColumnIndex();
|
||||
if (REPEATS.contains(key)) {
|
||||
return;
|
||||
}
|
||||
REPEATS.add(key);
|
||||
if (imageDataList.size() > MAX_IMAGE_SIZE.get()) {
|
||||
MAX_IMAGE_SIZE.set(imageDataList.size());
|
||||
}
|
||||
|
||||
int widthValue = imageWidth * pixelConversionFactor;
|
||||
sheet.setColumnWidth(cell.getColumnIndex(), listFlag ? widthValue * MAX_IMAGE_SIZE.get() + pixelConversionFactor : widthValue);
|
||||
|
||||
if (listFlag) {
|
||||
for (int i = 0; i < imageDataList.size(); i++) {
|
||||
ImageData imageData = imageDataList.get(i);
|
||||
if (imageData == null) {
|
||||
continue;
|
||||
}
|
||||
byte[] image = imageData.getImage();
|
||||
int index = this.insertImage(sheet, cell, image, i);
|
||||
CREATE_PIC_INDEX.add(index);
|
||||
}
|
||||
} else {
|
||||
this.insertImage(sheet, cell, imageDataList.get(0).getImage(), 0);
|
||||
}
|
||||
|
||||
// 清除EasyExcel自动添加的没有格式的图片
|
||||
XSSFDrawing drawingPatriarch = (XSSFDrawing) sheet.getDrawingPatriarch();
|
||||
List<XSSFShape> shapes = drawingPatriarch.getShapes();
|
||||
for (int i = 0; i < shapes.size(); i++) {
|
||||
XSSFShape shape = shapes.get(i);
|
||||
if (shape instanceof XSSFPicture && !CREATE_PIC_INDEX.contains(i)) {
|
||||
CREATE_PIC_INDEX.add(i);
|
||||
XSSFPicture picture = (XSSFPicture) shape;
|
||||
// 这里只是将图片的大小设置为 0,所以表格依旧会存放该图片
|
||||
picture.resize(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新插入一个图片
|
||||
*
|
||||
* @param sheet Excel页面
|
||||
* @param cell 表格元素
|
||||
* @param pictureData 图片数据
|
||||
* @param i 图片顺序
|
||||
*/
|
||||
public int insertImage(Sheet sheet, Cell cell, byte[] pictureData, int i) {
|
||||
int picWidth = Units.pixelToEMU(imageWidth);
|
||||
int index = sheet.getWorkbook().addPicture(pictureData, HSSFWorkbook.PICTURE_TYPE_PNG);
|
||||
Drawing<?> drawing = sheet.getDrawingPatriarch();
|
||||
if (drawing == null) {
|
||||
drawing = sheet.createDrawingPatriarch();
|
||||
}
|
||||
CreationHelper helper = sheet.getWorkbook().getCreationHelper();
|
||||
ClientAnchor anchor = helper.createClientAnchor();
|
||||
/*
|
||||
* 设置图片坐标
|
||||
* 为了不让图片遮挡单元格的上边框和右边框,故 x1、x2、y1 这几个坐标点均向后移动了一个像素点
|
||||
*/
|
||||
anchor.setDx1(Units.pixelToEMU(1) + picWidth * i);
|
||||
anchor.setDx2(Units.pixelToEMU(1) + picWidth + picWidth * i);
|
||||
anchor.setDy1(Units.pixelToEMU(1));
|
||||
anchor.setDy2(0);
|
||||
//设置图片位置
|
||||
int columnIndex = cell.getColumnIndex();
|
||||
anchor.setCol1(columnIndex);
|
||||
anchor.setCol2(columnIndex);
|
||||
int rowIndex = cell.getRowIndex();
|
||||
anchor.setRow1(rowIndex);
|
||||
anchor.setRow2(rowIndex + 1);
|
||||
anchor.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE);
|
||||
drawing.createPicture(anchor, index);
|
||||
return index;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
package com.hcy.common.utils.excel;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||
import com.alibaba.excel.util.ListUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 该类主要是将 URL 资源下载到本地磁盘,需要配合 LocalImageModifyStrategy 使用
|
||||
*/
|
||||
@Slf4j
|
||||
public class DownloadUrlConverter implements Converter<List<URL>> {
|
||||
|
||||
|
||||
@Override
|
||||
public Class<?> supportJavaTypeKey() {
|
||||
return List.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellDataTypeEnum supportExcelTypeKey() {
|
||||
return CellDataTypeEnum.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<URL> convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WriteCellData<?> convertToExcelData(List<URL> value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
|
||||
// 这里进行对数据实体类URL集合处理
|
||||
List<String> filePaths = ListUtils.newArrayList();
|
||||
// 下载文件存放地址
|
||||
String folder = System.getProperty("java.io.tmpdir") + File.separator + "excel-temp" + File.separator;
|
||||
// for 循环一次读取
|
||||
for (URL url : value) {
|
||||
String path = url.getPath();
|
||||
String suffix = path.substring(path.indexOf("."));
|
||||
long millis = System.currentTimeMillis();
|
||||
String fileName = millis + suffix;
|
||||
String filePath = folder + fileName;
|
||||
// 下载文件到本地
|
||||
try {
|
||||
this.downloadURL(url, filePath);
|
||||
filePaths.add(filePath);
|
||||
log.info("The temporary file storage path: " + filePath);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
WriteCellData<?> cellData = new WriteCellData<>();
|
||||
if (!CollectionUtils.isEmpty(filePaths)) {
|
||||
// 图片返回图片列表
|
||||
cellData.setStringValue("Files:" + String.join(",", filePaths));
|
||||
cellData.setType(CellDataTypeEnum.EMPTY);
|
||||
} else {
|
||||
cellData.setType(CellDataTypeEnum.STRING);
|
||||
}
|
||||
return cellData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 URL 中下载文件到指定路径
|
||||
* @param url 统一资源定位符
|
||||
* @param savePath 存放路径
|
||||
*/
|
||||
private void downloadURL(URL url, String savePath) throws IOException {
|
||||
|
||||
URLConnection connection = url.openConnection();
|
||||
connection.connect();
|
||||
InputStream inputStream = new BufferedInputStream(connection.getInputStream());
|
||||
|
||||
File file = new File(savePath);
|
||||
if (!file.getParentFile().exists()) {
|
||||
if (file.getParentFile().mkdirs()) {
|
||||
log.info("parent file had created.");
|
||||
}
|
||||
}
|
||||
|
||||
OutputStream outputStream = new FileOutputStream(savePath);
|
||||
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
|
||||
inputStream.close();
|
||||
outputStream.close();
|
||||
|
||||
log.info("Image downloaded successfully!");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.hcy.common.utils.excel;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
public class EasyExcelUtil {
|
||||
|
||||
/**
|
||||
* 初始化响应体
|
||||
* @param response 请求头
|
||||
* @param fileName 导出名称
|
||||
*/
|
||||
public static void initResponse(HttpServletResponse response, String fileName) {
|
||||
// 设置content—type 响应类型
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
try {
|
||||
// 这里URLEncoder.encode可以防止中文乱码
|
||||
fileName = URLEncoder.encode(fileName, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.hcy.common.utils.excel;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||
import com.alibaba.excel.metadata.data.ImageData;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||
import com.alibaba.excel.util.IoUtils;
|
||||
import com.alibaba.excel.util.ListUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class ImageUrlConverter implements Converter<List<URL>> {
|
||||
|
||||
@Override
|
||||
public Class<?> supportJavaTypeKey() {
|
||||
return List.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellDataTypeEnum supportExcelTypeKey() {
|
||||
return CellDataTypeEnum.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<URL> convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WriteCellData<?> convertToExcelData(List<URL> value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
|
||||
// 这里进行对数据实体类URL集合处理
|
||||
List<ImageData> data = ListUtils.newArrayList();
|
||||
ImageData imageData;
|
||||
// for 循环一次读取
|
||||
for (URL url : value) {
|
||||
try (InputStream inputStream = url.openStream();) {
|
||||
byte[] bytes = IoUtils.toByteArray(inputStream);
|
||||
imageData = new ImageData();
|
||||
imageData.setImage(bytes);
|
||||
data.add(imageData);
|
||||
} catch (Exception e) {
|
||||
log.error("导出临时记录图片异常:", e);
|
||||
}
|
||||
}
|
||||
WriteCellData<?> cellData = new WriteCellData<>();
|
||||
if (!CollectionUtils.isEmpty(data)) {
|
||||
// 图片返回图片列表
|
||||
cellData.setImageDataList(data);
|
||||
cellData.setType(CellDataTypeEnum.EMPTY);
|
||||
} else {
|
||||
// 没有图片使用汉字表示
|
||||
cellData.setStringValue("无图");
|
||||
cellData.setType(CellDataTypeEnum.STRING);
|
||||
}
|
||||
return cellData;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
package com.hcy.common.utils.excel;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.Head;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.write.handler.CellWriteHandler;
|
||||
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
|
||||
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.util.Units;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* Excel导出单元格中有图片,图片会进行压缩,缩略,插入单元格(通过读取本地文件的方式)
|
||||
* 需要搭配 DownloadUrlConverter 使用
|
||||
*/
|
||||
public class LocalImageModifyStrategy implements CellWriteHandler {
|
||||
|
||||
/**
|
||||
* 单元格的图片最大张数(每列的单元格图片张数不确定,单元格宽度需按照张数最多的长度来设置)
|
||||
*/
|
||||
private final AtomicReference<Integer> MAX_IMAGE_SIZE = new AtomicReference<>(0);
|
||||
|
||||
/**
|
||||
* 默认图片宽度(单位像素):60
|
||||
*/
|
||||
private final static int DEFAULT_IMAGE_WIDTH = 60;
|
||||
|
||||
/**
|
||||
* 默认像素转换因子:32
|
||||
*/
|
||||
private final static int DEFAULT_PIXEL_CONVERSION_FACTOR = 32;
|
||||
|
||||
/**
|
||||
* 图片宽度,单位像素
|
||||
*/
|
||||
private final int imageWidth;
|
||||
|
||||
/**
|
||||
* 像素转换因子
|
||||
*/
|
||||
private final int pixelConversionFactor;
|
||||
|
||||
public LocalImageModifyStrategy() {
|
||||
this.imageWidth = DEFAULT_IMAGE_WIDTH;
|
||||
this.pixelConversionFactor = DEFAULT_PIXEL_CONVERSION_FACTOR;
|
||||
}
|
||||
|
||||
public LocalImageModifyStrategy(int imageWidth, int pixelConversionFactor) {
|
||||
this.imageWidth = imageWidth;
|
||||
this.pixelConversionFactor = pixelConversionFactor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCellDataConverted(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, WriteCellData<?> cellData, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
|
||||
// 在数据转换成功后 不是头就把类型设置成空
|
||||
if (isHead) {
|
||||
return;
|
||||
}
|
||||
//将要插入图片的单元格的type设置为空,下面再填充图片
|
||||
if (!CollectionUtils.isEmpty(cellData.getImageDataList())) {
|
||||
cellData.setType(CellDataTypeEnum.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
|
||||
// 在单元格写入完毕后 ,自己填充图片
|
||||
if (isHead || CollectionUtils.isEmpty(cellDataList)) {
|
||||
return;
|
||||
}
|
||||
boolean imgFlag = false;
|
||||
Sheet sheet = cell.getSheet();
|
||||
WriteCellData<?> writeCellData = cellDataList.get(0);
|
||||
CellDataTypeEnum type = writeCellData.getType();
|
||||
if (type != CellDataTypeEnum.EMPTY) {
|
||||
return;
|
||||
}
|
||||
String stringValue = writeCellData.getStringValue();
|
||||
if (stringValue == null) {
|
||||
return;
|
||||
}
|
||||
// 判断是否属于文件
|
||||
if (stringValue.startsWith("Files:")) {
|
||||
imgFlag = true;
|
||||
stringValue = stringValue.replace("Files:", "");
|
||||
}
|
||||
if (!imgFlag) {
|
||||
return;
|
||||
}
|
||||
List<String> filePaths = Arrays.asList(stringValue.split(","));
|
||||
|
||||
if (filePaths.size() > MAX_IMAGE_SIZE.get()) {
|
||||
MAX_IMAGE_SIZE.set(filePaths.size());
|
||||
}
|
||||
|
||||
int widthValue = imageWidth * pixelConversionFactor;
|
||||
sheet.setColumnWidth(cell.getColumnIndex(), widthValue * MAX_IMAGE_SIZE.get() + pixelConversionFactor);
|
||||
|
||||
for (int i = 0; i < filePaths.size(); i++) {
|
||||
String filePath = filePaths.get(i);
|
||||
// todo 这里可以对图片作一些处理,比如说压缩
|
||||
// ...
|
||||
// 读取文件
|
||||
byte[] image = FileUtil.readBytes(filePath);
|
||||
this.insertImage(sheet, cell, image, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 重新插入一个图片
|
||||
*
|
||||
* @param sheet Excel页面
|
||||
* @param cell 表格元素
|
||||
* @param pictureData 图片数据
|
||||
* @param i 图片顺序
|
||||
*/
|
||||
public int insertImage(Sheet sheet, Cell cell, byte[] pictureData, int i) {
|
||||
int picWidth = Units.pixelToEMU(imageWidth);
|
||||
int index = sheet.getWorkbook().addPicture(pictureData, HSSFWorkbook.PICTURE_TYPE_PNG);
|
||||
Drawing<?> drawing = sheet.getDrawingPatriarch();
|
||||
if (drawing == null) {
|
||||
drawing = sheet.createDrawingPatriarch();
|
||||
}
|
||||
CreationHelper helper = sheet.getWorkbook().getCreationHelper();
|
||||
ClientAnchor anchor = helper.createClientAnchor();
|
||||
/*
|
||||
* 设置图片坐标
|
||||
* 为了不让图片遮挡单元格的上边框和右边框,故 x1、x2、y1 这几个坐标点均向后移动了一个像素点
|
||||
*/
|
||||
anchor.setDx1(Units.pixelToEMU(1) + picWidth * i);
|
||||
anchor.setDx2(Units.pixelToEMU(1) + picWidth + picWidth * i);
|
||||
anchor.setDy1(Units.pixelToEMU(1));
|
||||
anchor.setDy2(0);
|
||||
//设置图片位置
|
||||
int columnIndex = cell.getColumnIndex();
|
||||
anchor.setCol1(columnIndex);
|
||||
anchor.setCol2(columnIndex);
|
||||
int rowIndex = cell.getRowIndex();
|
||||
anchor.setRow1(rowIndex);
|
||||
anchor.setRow2(rowIndex + 1);
|
||||
anchor.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE);
|
||||
drawing.createPicture(anchor, index);
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
package com.hcy.common.utils.excel;
|
||||
|
||||
import com.alibaba.excel.write.handler.SheetWriteHandler;
|
||||
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
|
||||
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
|
||||
public class MonthSheetWriteHandler implements SheetWriteHandler {
|
||||
@Override
|
||||
public void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
|
||||
Workbook workbook = writeWorkbookHolder.getWorkbook();
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
|
||||
Row row = sheet.createRow(0);
|
||||
Cell cell = row.createCell(0);
|
||||
//标题1,设置单元格内容
|
||||
cell.setCellValue("深圳创先捷智能科技有限公司");
|
||||
CellStyle cellStyleTitle = workbook.createCellStyle();
|
||||
cellStyleTitle.setVerticalAlignment(VerticalAlignment.CENTER); // 设置居中
|
||||
cellStyleTitle.setAlignment(HorizontalAlignment.CENTER); // 设置居中
|
||||
Font fontTitle = workbook.createFont();
|
||||
fontTitle.setFontName("宋体"); // 设置字体
|
||||
fontTitle.setBold(true); // 设置字体加粗
|
||||
fontTitle.setFontHeightInPoints((short)18);// 设置字体大小
|
||||
// fontTitle.setFontHeight((short) 360);
|
||||
cellStyleTitle.setFont(fontTitle);
|
||||
cell.setCellStyle(cellStyleTitle);
|
||||
//合并单元格,起始行,结束行,起始列,结束列
|
||||
sheet.addMergedRegionUnsafe(new CellRangeAddress(0, 0, 0, 8));
|
||||
|
||||
//设置标题
|
||||
Row row1 = sheet.createRow(1);
|
||||
Cell cell1 = row1.createCell(0);
|
||||
cell1.setCellValue("地址:深圳市宝安区石岩街道塘头第三工业区二栋");
|
||||
CellStyle cellStyle = workbook.createCellStyle();
|
||||
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
Font font = workbook.createFont();
|
||||
font.setFontName("宋体"); // 设置字体
|
||||
font.setBold(true);
|
||||
font.setFontHeightInPoints((short)11);// 设置字体大小
|
||||
// font.setFontHeight((short) 220);
|
||||
cellStyle.setFont(font);
|
||||
cell1.setCellStyle(cellStyle);
|
||||
//合并单元格,起始行,结束行,起始列,结束列
|
||||
sheet.addMergedRegionUnsafe(new CellRangeAddress(1, 1, 0, 8));
|
||||
|
||||
//设置标题
|
||||
Row row2 = sheet.createRow(2);
|
||||
Cell cell2 = row2.createCell(0);
|
||||
cell2.setCellValue("电话:0755-26009122 26009366 传真:26009133");
|
||||
CellStyle cellStyle2 = workbook.createCellStyle();
|
||||
cellStyle2.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
cellStyle2.setAlignment(HorizontalAlignment.CENTER);
|
||||
Font font2 = workbook.createFont();
|
||||
font2.setFontName("宋体"); // 设置字体
|
||||
font2.setBold(true);
|
||||
font2.setFontHeightInPoints((short)11);// 设置字体大小
|
||||
// font2.setFontHeight((short) 220);
|
||||
cellStyle2.setFont(font2);
|
||||
cell2.setCellStyle(cellStyle2);
|
||||
//合并单元格,起始行,结束行,起始列,结束列
|
||||
sheet.addMergedRegionUnsafe(new CellRangeAddress(2, 2, 0, 8));
|
||||
|
||||
//设置标题
|
||||
Row row3 = sheet.createRow(3);
|
||||
Cell cell3 = row3.createCell(0);
|
||||
cell3.setCellValue("模块维修报表");
|
||||
CellStyle cellStyle3 = workbook.createCellStyle();
|
||||
cellStyle3.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
cellStyle3.setAlignment(HorizontalAlignment.CENTER);
|
||||
Font font3 = workbook.createFont();
|
||||
font3.setFontName("宋体"); // 设置字体
|
||||
font3.setFontHeightInPoints((short)20);// 设置字体大小
|
||||
// font3.setFontHeight((short) 400);
|
||||
cellStyle3.setFont(font3);
|
||||
cell3.setCellStyle(cellStyle3);
|
||||
//合并单元格,起始行,结束行,起始列,结束列
|
||||
sheet.addMergedRegionUnsafe(new CellRangeAddress(3, 3, 0, 8));
|
||||
|
||||
//设置客户名称、单据编号、制单日期
|
||||
Row row4 = sheet.createRow(4);
|
||||
Cell cell4 = row4.createCell(7);
|
||||
cell4.setCellValue("单据编号:");
|
||||
CellStyle cellStyle4 = workbook.createCellStyle();
|
||||
Font font4 = workbook.createFont();
|
||||
font4.setFontName("宋体"); // 设置字体
|
||||
font4.setFontHeightInPoints((short) 11); // 设置字体大小
|
||||
cellStyle4.setFont(font4);
|
||||
cell4.setCellStyle(cellStyle4);
|
||||
//合并单元格,起始行,结束行,起始列,结束列
|
||||
sheet.addMergedRegionUnsafe(new CellRangeAddress(4, 4, 7, 8));
|
||||
|
||||
Row row5 = sheet.createRow(5);
|
||||
Cell cell5 = row5.createCell(0);
|
||||
cell5.setCellValue("客户名称:");
|
||||
CellStyle cellStyle5 = workbook.createCellStyle();
|
||||
Font font5 = workbook.createFont();
|
||||
font5.setFontName("宋体"); // 设置字体
|
||||
font5.setFontHeightInPoints((short) 11);
|
||||
cellStyle5.setFont(font5);
|
||||
cell5.setCellStyle(cellStyle5);
|
||||
sheet.addMergedRegionUnsafe(new CellRangeAddress(5, 5, 0, 2));
|
||||
|
||||
Cell cell51 = row5.createCell(7);
|
||||
cell51.setCellValue(" 制单日期:");
|
||||
CellStyle cellStyle51 = workbook.createCellStyle();
|
||||
Font font51 = workbook.createFont();
|
||||
font51.setFontName("宋体"); // 设置字体
|
||||
font51.setFontHeightInPoints((short) 11);
|
||||
cellStyle51.setFont(font51);
|
||||
cell51.setCellStyle(cellStyle51);
|
||||
//合并单元格,起始行,结束行,起始列,结束列
|
||||
sheet.addMergedRegionUnsafe(new CellRangeAddress(5, 5, 7, 8));
|
||||
|
||||
}
|
||||
}
|
|
@ -131,6 +131,12 @@
|
|||
<if test="form.id != null">
|
||||
and ro.id = #{form.id}
|
||||
</if>
|
||||
<if test="form.ids != null and form.ids.size > 0">
|
||||
and ro.id in
|
||||
<foreach item="id" collection="form.ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="form.orderNo != null and form.orderNo != ''">
|
||||
and ro.order_no like concat('%', #{form.orderNo}, '%')
|
||||
</if>
|
||||
|
|
|
@ -950,6 +950,10 @@ public class RepairOrderServiceImpl implements IRepairOrderService {
|
|||
//批量添加配件编码
|
||||
List<OrderPartCode> orderPartCodeList = repairOrderParam.getOrderPartCodeList();
|
||||
for (OrderPartCode orderPartCode : orderPartCodeList) {
|
||||
//部件编码不能和模块号一样
|
||||
if(Objects.equals(orderPartCode.getPartCode(), repairOrder.getModuleNumber())){
|
||||
throw new OperateException("部件编码不能和模块号一样!");
|
||||
}
|
||||
orderPartCode.setRepairOrderId(repairOrder.getId()); // 维修单号
|
||||
orderPartCodeMapper.insert(orderPartCode);
|
||||
}
|
||||
|
|
|
@ -457,6 +457,8 @@ public class RoutingInspectionOrderServiceImpl implements IRoutingInspectionOrde
|
|||
if(model.getOrderStatus() == OrderStateEnum.PENDING_ORDER.getStatus() ||
|
||||
model.getOrderStatus() == OrderStateEnum.TO_BE_INSPECTED.getStatus()){
|
||||
|
||||
model.setReceiverId(null); // 清空接单人
|
||||
model.setReceiverTime(null); // 清空接单时间
|
||||
model.setCancelOrderTime(new Date()); //退单时间
|
||||
model.setCancelCause(routingInspectionOrderParam.getCancelCause()); //取消原因
|
||||
//如果工单去向是工单池的话,退单后工单状态为待抢单,如果是检修员,工单状态是 5=已退单
|
||||
|
|
|
@ -11,6 +11,11 @@ spring:
|
|||
driver-class-name: com.mysql.jdbc.Driver # MySql的驱动
|
||||
username: root # 数据库账号
|
||||
password: hcy123456
|
||||
# url: jdbc:mysql://120.77.216.5:3306/charging-pile?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
|
||||
# type: com.zaxxer.hikari.HikariDataSource # 数据源类型
|
||||
# driver-class-name: com.mysql.jdbc.Driver # MySql的驱动
|
||||
# username: charging-pile # 数据库账号
|
||||
# password: FZcP7eFwN4T5jkXz
|
||||
# Redis配置
|
||||
redis:
|
||||
host: localhost # Redis服务地址
|
||||
|
|
|
@ -25,6 +25,11 @@ spring:
|
|||
driver-class-name: com.mysql.jdbc.Driver # MySql的驱动
|
||||
username: root # 数据库账号
|
||||
password: hcy123456
|
||||
# url: jdbc:mysql://120.77.216.5:3306/charging-pile?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
|
||||
# type: com.zaxxer.hikari.HikariDataSource # 数据源类型
|
||||
# driver-class-name: com.mysql.jdbc.Driver # MySql的驱动
|
||||
# username: charging-pile # 数据库账号
|
||||
# password: FZcP7eFwN4T5jkXz
|
||||
hikari:
|
||||
connection-timeout: 30000 # 等待连接分配连接的最大时长(毫秒),超出时长还没可用连接则发送SQLException,默认30秒
|
||||
minimum-idle: 5 # 最小连接数
|
||||
|
@ -94,4 +99,4 @@ netty:
|
|||
|
||||
#adnin服务地址
|
||||
adminService:
|
||||
sendLargeScreenUrl : http://localhost:8082/api/system/notification/sendLargeScreen
|
||||
sendLargeScreenUrl : http://120.77.216.5:8082/api/system/notification/sendLargeScreen
|
7
pom.xml
7
pom.xml
|
@ -168,6 +168,13 @@
|
|||
<artifactId>like-common</artifactId>
|
||||
<version>${like.version}</version>
|
||||
</dependency>-->
|
||||
<!-- easyExcel 表格依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<version>3.3.4</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
|
Loading…
Reference in New Issue