Commit 611f44b9 authored by yajun.zhang's avatar yajun.zhang

导出Excel

parent 20998ac2
......@@ -335,6 +335,13 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/easyexcel -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.3.3</version>
</dependency>
</dependencies>
</project>
......@@ -20,7 +20,7 @@ public class MailConfig {
@Value("${customer.transaction.mail.host}")
private String host;
@Value("${customer.transaction.mail.port}")
private int port = 587;
private int port = 465;
@Value("${customer.transaction.mail.password}")
private String password;
......
......@@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -27,6 +28,10 @@ public class ThirdWorkOrderRest {
public JsonResult list(@RequestBody WorkOrderParam param) {
return thirdWorkOrderService.queryWorkOrder(param);
}
@PostMapping("/export")
public JsonResult export(@RequestBody WorkOrderParam param,@RequestHeader("account") String account) {
return thirdWorkOrderService.export(param,account);
}
}
......@@ -19,5 +19,9 @@ public class WorkOrderParam {
private String acceptUser;
private String priority;
private List<String> statusList;
private String startTime;
private String endTime;
}
package cn.quantgroup.customer.rest.vo.thirdworkorder;
import com.alibaba.excel.annotation.ExcelProperty;
import java.io.Serializable;
import java.math.BigDecimal;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ThirdWorkOrderExportVo implements Serializable {
/**
* 工单信息
*/
//创建时间
@ExcelProperty(value = "创建时间", index = 0)
private String createTime;
//小结id
@ExcelProperty(value = "小结id", index = 1)
private String id;
//工单id
@ExcelProperty(value = "工单id", index = 2)
private String processInstanceId;
//反馈渠道
@ExcelProperty(value = "反馈渠道", index = 3)
private String feedbackChannel;
//问题细分二级
@ExcelProperty(value = "问题细分", index = 4)
private String questionLevel;
//订单id
@ExcelProperty(value = "订单id", index = 6)
private String orderNo;
//问题描述
@ExcelProperty(value = "问题描述", index = 13)
private String problemDesc;
//工单创建人
@ExcelProperty(value = "一级客服", index = 14)
private String createUser;
//工单受理人
@ExcelProperty(value = "二级客服", index = 15)
private String acceptUser;
//工单状态
@ExcelProperty(value = "工单状态", index = 16)
private String status;
//关单时间
@ExcelProperty(value = "关闭工单时间", index = 18)
private String closeTime;
/**
* 订单信息
*/
/**
* 订单no
*/
// private String orderNo;
/**
* sku分类名称
*/
@ExcelProperty(value = "商品分类", index = 5)
private String categroyName;
/**
* 下单时间
*/
@ExcelProperty(value = "下单时间", index = 7)
private String orderTime;
/**
* 发货时间
*/
@ExcelProperty(value = "发货时间", index = 8)
private String deliveryAt;
/**
* 供应商名称
*/
@ExcelProperty(value = "供应商名称", index = 9)
private String supplierName;
/**
* 商品名称
*/
@ExcelProperty(value = "商品名称", index = 10)
private String skuName;
/**
* 支付金额
*/
@ExcelProperty(value = "支付金额", index = 11)
private BigDecimal payAmount;
/**
* 订单状态
*/
@ExcelProperty(value = "订单状态", index = 12)
private Integer orderStatus;
/**
* 物流单号
*/
@ExcelProperty(value = "物流单号", index = 17)
private String deliveryNo;
}
......@@ -2,7 +2,6 @@ package cn.quantgroup.customer.rest.vo.thirdworkorder;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ThirdWorkOrderVo {
......@@ -29,4 +28,6 @@ public class ThirdWorkOrderVo {
private String status;
//问题描述
private String problemDesc;
//问题描述
private String createTime;
}
package cn.quantgroup.customer.service;
import cn.quantgroup.customer.model.kaordermapping.ApplyRequestHistory;
import cn.quantgroup.customer.model.kaordermapping.ChannelConfigurationResult;
import cn.quantgroup.customer.model.kaordermapping.LoanOrderMapping;
import cn.quantgroup.customer.model.order.CallbackRecordList;
import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam;
import cn.quantgroup.customer.rest.vo.JsonResult;
import cn.quantgroup.customer.rest.vo.thirdworkorder.ThirdWorkOrderExportVo;
import java.util.List;
import java.util.Map;
/**
* @author Wang Xiangwei
* @version 2020/3/9
*/
public interface IKdspService {
JsonResult<List<ThirdWorkOrderExportVo>> getOrderDetailForWorkOder(List<String> orderNos);
}
......@@ -16,4 +16,6 @@ public interface IThirdWorkOrderService {
JsonResult<Map<String,Object>> queryWorkOrder(WorkOrderParam param);
JsonResult export(WorkOrderParam param,String account);
}
......@@ -72,6 +72,8 @@ public interface IHttpService {
*/
String post(String uri, Object parameters);
String postJson(String uri, Object parameters);
String post(String uri, Map<String, ?> parameters);
<T> T post(String uri, Map<String, String> headers, Object parameters, Class<T> clazz);
......
package cn.quantgroup.customer.service.http;
import com.alibaba.fastjson.JSON;
import java.net.URL;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -134,6 +136,20 @@ public class RestTemplateServiceImpl implements IHttpService {
throw new HttpClientErrorException(entity.getStatusCode());
}
@Override
public String postJson(String uri, Object parameters) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
// 将JSON数据和请求头封装成HttpEntity
HttpEntity<String> entity = new HttpEntity<>(JSON.toJSONString(parameters), headers);
// 发送POST请求
ResponseEntity<String> response = restTemplate.postForEntity(uri, entity, String.class);
// 输出响应内容
return response.getBody();
}
@Override
public String post(String uri, Map<String, ?> parameters) {
log.info("method post uri:{},parameters:{}", uri, parameters);
......
package cn.quantgroup.customer.service.impl;
import static cn.quantgroup.customer.constant.Constant.GSON;
import cn.quantgroup.customer.enums.ErrorCodeEnum;
import cn.quantgroup.customer.rest.vo.JsonResult;
import cn.quantgroup.customer.rest.vo.thirdworkorder.ThirdWorkOrderExportVo;
import cn.quantgroup.customer.service.IKdspService;
import cn.quantgroup.customer.service.http.IHttpService;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
/**
* @author Wang Xiangwei
* @version 2020/3/9
*/
@Slf4j
@Service
public class KdspServiceImpl implements IKdspService {
// @Value("${kdsp.operation.http}")
private String kdspOperationUrl;
@Autowired
private IHttpService httpService;
@Override
public JsonResult<List<ThirdWorkOrderExportVo>> getOrderDetailForWorkOder(
List<String> orderNos) {
String url = "http://kdsp-operation-yxm.liangkebang.net/api/kdsp/op/order/getOrderDetailForWorkOder";
JsonResult<List<ThirdWorkOrderExportVo>> jsonResult = null;
try {
String result = httpService.postJson(url, orderNos);
jsonResult = GSON.fromJson(result, JsonResult.class);
log.info("工单查询订单详情返回值:{}", result);
} catch (Exception ex) {
log.error("工单查询订单详情异常",ex);
return JsonResult.buildErrorStateResult(ErrorCodeEnum.NET_ERROR.getMessage(), null);
}
return jsonResult;
}
}
package cn.quantgroup.customer.util;
import cn.quantgroup.customer.rest.vo.thirdworkorder.ThirdWorkOrderExportVo;
import com.alibaba.excel.EasyExcel;
import java.util.List;
/**
* @author :dongjianhua
* @date :Created in 2019/10/28 10:20
* @description:excel处理工具类
* @modified By:
* @version: 1.0
*/
public class EasyExcelUtil {
public static void write(String filePath,Class clas,List exportVos) {
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,名字为模板 然后文件流会自动关闭
EasyExcel.write(filePath, clas).sheet("数据").doWrite(exportVos);
}
}
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