Commit a2d19547 by peterchu

fix:

1. 完成销售明细报表功能业务
2. 完善销售汇总业务
parent 20d4885b
......@@ -90,5 +90,7 @@
<orderEntry type="library" name="Maven: cglib:cglib:3.1" level="project" />
<orderEntry type="library" name="Maven: org.ow2.asm:asm:4.2" level="project" />
<orderEntry type="library" name="Maven: org.ehcache:ehcache:3.2.2" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.2.0" level="project" />
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:3.2" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -134,6 +134,11 @@
<artifactId>yutu_common</artifactId>
<version>1.0.37</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.2.0</version>
</dependency>
</dependencies>
<build>
......
......@@ -3,13 +3,13 @@ package com.yutu.base.controller;
import com.yutu.base.entity.Response;
import com.yutu.base.service.SaleDetailService;
import com.yutu.base.service.SalesSummaryService;
import com.yutu.comm.entity.exception.NoteResult;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
/**
* 报表管理:
......@@ -24,13 +24,15 @@ public class StatementController {
private Logger logger = Logger.getLogger("download");
@Autowired
private SaleDetailService saleDetailService;
@Autowired
private SalesSummaryService salesSummaryService;
/**
* 销售明细报表页面 获取销售明细数据
* @param requestBody
* @return
*/
@RequestMapping(value = "salesDetail/getSalesDetailList",method = RequestMethod.POST)
@RequestMapping(value = "salesDetail/getSalesDetailList", method = RequestMethod.POST)
public NoteResult getSalesDetailList(@RequestBody String requestBody){
return saleDetailService.getSalesDetailList(requestBody);
}
......@@ -41,12 +43,20 @@ public class StatementController {
* @param requestBody
* @return
*/
@RequestMapping(value = "salesDetail/downloadSalesDetailReport",method = RequestMethod.POST)
public NoteResult saleDetailReportFromAutoSource(@RequestBody String requestBody){
return saleDetailService.downloadSalesDetailReportExcel(requestBody);
@RequestMapping(value = "salesDetail/downloadSalesDetailReport", method = RequestMethod.POST)
public NoteResult saleDetailReportFromAutoSource(@RequestBody String requestBody, HttpServletResponse response){
return saleDetailService.downloadSalesDetailReportExcel(requestBody, response);
}
/**
* 查询销售汇总数据 salesSummary
* @param requestBody
* @return
*/
@RequestMapping(value = "salesSummary/getSalesSummaryList", method = RequestMethod.POST)
public NoteResult getSalesSummaryList(@RequestBody String requestBody){
return salesSummaryService.getSalesSummaryList(requestBody);
}
......
......@@ -2,6 +2,7 @@ package com.yutu.base.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yutu.base.entity.SaleDetail;
import com.yutu.base.entity.Store;
import com.yutu.base.entity.User;
import com.yutu.base.utils.httpClient.HttpUtil;
......@@ -9,6 +10,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
......@@ -67,4 +69,6 @@ public class BaseService {
}
return storeList;
}
}
......@@ -20,6 +20,7 @@ import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
......@@ -89,7 +90,7 @@ public class ParseToSaleDetail extends BaseService{
String passengerIds = purchObj.getString("passengerIds");//乘客id
int flightSize = flightInfoIds.replace(",","").length()/36;//行程段数
int passengerSize = passengerIds.replace(",","").length()/36;//乘客人量
// String route = purchObj.getString("routeType");
String route = purchObj.getString("routeType");
// String route = orderArr.get(0).getString("routeType");
String orderTripType = "";//订单行程类型
String routeType = convertTripTypeNum(route);//采购行程类型
......@@ -672,12 +673,18 @@ public class ParseToSaleDetail extends BaseService{
* @param filePath
* @return
*/
public String createSaleDetailReport(List<SaleDetail> saleDetails,String filePath){
public String createSaleDetailReport(List<SaleDetail> saleDetails, String filePath){
logger.info("开始生成报表");
// 写到本地指定文件夹目录中
File files = new File(filePath);
if (!files.exists()) { files.mkdir(); }
if (!files.exists()) {
files.mkdirs(); // 父目录不存在时创建多级目录
}
String file = filePath + new SimpleDateFormat("yyMMddHHmmss").format(new Date())+".xls";
WritableWorkbook workbook = null;
String file = filePath + new SimpleDateFormat("yyMMddHHmmss").format(new Date())+".xlsx";
try{
workbook = Workbook.createWorkbook(new File(file));
......@@ -1021,4 +1028,367 @@ public class ParseToSaleDetail extends BaseService{
}
return file;
}
/**
* 通过 response 对象向浏览器输出二进制流生成报表
* @param saleDetails
* @param response
* @return
*/
public String createSaleDetailReport(List<SaleDetail> saleDetails, HttpServletResponse response){
logger.info("开始生成报表");
WritableWorkbook workbook = null;
// 通过响应对象写出
String file = new SimpleDateFormat("yyMMddHHmmss").format(new Date())+".xls";
try{
// workbook = Workbook.createWorkbook(new File(file));
// 设置response参数,可以打开下载页面
response.reset();
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename=" + new String(file.getBytes(), "iso-8859-1"));
workbook = Workbook.createWorkbook(response.getOutputStream());
DecimalFormat df = new DecimalFormat("######0.00");
WritableFont wf = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
WritableFont wf_auto = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
WritableCellFormat wcf_integer = new WritableCellFormat(wf_auto,NumberFormats.INTEGER); // 整数
WritableCellFormat wcf_float = new WritableCellFormat(wf_auto,NumberFormats.FLOAT); // 小数
wcf_integer.setAlignment(Alignment.CENTRE); // 设置对齐方式
wcf_float.setAlignment(Alignment.CENTRE); // 设置对齐方式
WritableCellFormat wcf = new WritableCellFormat(wf); // 单元格定义
wcf.setAlignment(Alignment.CENTRE); // 设置对齐方式
WritableCellFormat wcf1 = new WritableCellFormat(wf); // 单元格定义
wcf1.setAlignment(Alignment.CENTRE); // 设置对齐方式
WritableCellFormat wcf2 = new WritableCellFormat();
wcf2.setAlignment(Alignment.CENTRE); // 设置对齐方式
wcf2.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
wcf2.setWrap(true);
WritableSheet sheet = workbook.createSheet("First Sheet", 0);//创建新的一页
CellView cellView = new CellView();
cellView.setAutosize(true); //设置自动大小
cellView.setFormat(wcf1);
CellView cellView_float = new CellView();
cellView.setAutosize(true); //设置自动大小
cellView.setFormat(wcf_float);
sheet.setColumnView(0,cellView);
sheet.setColumnView(1,cellView);
sheet.setColumnView(2,cellView);
sheet.setColumnView(3,cellView);
sheet.setColumnView(4,cellView);
sheet.setColumnView(5,cellView);
sheet.setColumnView(6,cellView);
sheet.setColumnView(7,cellView);
sheet.setColumnView(8,cellView);
sheet.setColumnView(9,cellView);
sheet.setColumnView(10,cellView);
sheet.setColumnView(11,cellView);
sheet.setColumnView(12,cellView);
sheet.setColumnView(13,cellView);
sheet.setColumnView(14,cellView);
sheet.setColumnView(15,cellView);
sheet.setColumnView(16,cellView);
sheet.setColumnView(17,cellView);
sheet.setColumnView(18,cellView);
sheet.setColumnView(19,cellView);
sheet.setColumnView(20,cellView);
sheet.setColumnView(21,cellView);
sheet.setColumnView(22,cellView);
sheet.setColumnView(23,cellView);
sheet.setColumnView(24,cellView);
sheet.setColumnView(25,cellView);
sheet.setColumnView(26,cellView);
sheet.setColumnView(27,cellView);
sheet.setColumnView(28,cellView);
sheet.setColumnView(29,cellView);
sheet.setColumnView(30,cellView);
sheet.setColumnView(31,cellView);
sheet.setColumnView(32,cellView);
sheet.setColumnView(33,cellView);
sheet.setColumnView(34,cellView);
sheet.setColumnView(35,cellView);
sheet.setColumnView(36,cellView);
sheet.setColumnView(37,cellView);
sheet.setColumnView(38,cellView);
sheet.setColumnView(39,cellView);
sheet.setColumnView(40,cellView);
sheet.setColumnView(41,cellView);
sheet.getSettings().setDefaultColumnWidth(22);//设置默认宽度22px
sheet.addCell(new Label(0,0,"生单时间",wcf2));
sheet.addCell(new Label(1,0,"出票时间",wcf2));
sheet.addCell(new Label(2,0,"订单号",wcf2));
sheet.addCell(new Label(3,0,"销售渠道",wcf2));
sheet.addCell(new Label(4,0,"销售店铺",wcf2));
sheet.addCell(new Label(5,0,"航线",wcf2));
sheet.addCell(new Label(6,0,"起飞时间",wcf2));
sheet.addCell(new Label(7,0,"航班号",wcf2));
sheet.addCell(new Label(8,0,"行程类型",wcf2));
sheet.addCell(new Label(9,0,"票号类型",wcf2));
sheet.addCell(new Label(10,0,"编码",wcf2));
sheet.addCell(new Label(11,0,"人数",wcf2));
sheet.addCell(new Label(12,0,"成人数量",wcf2));
sheet.addCell(new Label(13,0,"儿童数量",wcf2));
sheet.addCell(new Label(14,0,"销售—金额",wcf2));
sheet.addCell(new Label(15,0,"行李总金额",wcf2));
sheet.addCell(new Label(16,0,"采购积分",wcf2));
sheet.addCell(new Label(17,0,"采购币种",wcf2));
sheet.addCell(new Label(18,0,"采购金额(外)",wcf2));
sheet.addCell(new Label(19,0,"采购金额(本)",wcf2));
sheet.addCell(new Label(20,0,"支付明细(外)",wcf2));
sheet.addCell(new Label(21,0,"支付明细(本)",wcf2));
sheet.addCell(new Label(22,0,"支付方式",wcf2));
sheet.addCell(new Label(23,0,"卡号",wcf2));
sheet.addCell(new Label(24,0,"利润",wcf2));
sheet.addCell(new Label(25,0,"交易流水号",wcf2));
sheet.addCell(new Label(26,0,"辅营订单号",wcf2));
sheet.addCell(new Label(27,0,"采购渠道",wcf2));
sheet.addCell(new Label(28,0,"采购账户",wcf2));
sheet.addCell(new Label(29,0,"采购订单号",wcf2));
sheet.addCell(new Label(30,0,"政策类型",wcf2));
sheet.addCell(new Label(31,0,"政策编码",wcf2));
sheet.addCell(new Label(32,0,"订单状态",wcf2));
sheet.addCell(new Label(33,0,"出票人",wcf2));
sheet.addCell(new Label(34,0,"采购时间",wcf2));
sheet.addCell(new Label(35,0,"附加产品",wcf2));
sheet.addCell(new Label(36,0,"附加产品规格",wcf2));
sheet.addCell(new Label(37,0,"备注",wcf2));
sheet.addCell(new Label(38,0,"财务-回款状态",wcf2));
sheet.addCell(new Label(39,0,"财务-实际支出金额",wcf2));
sheet.addCell(new Label(40,0,"财务-补差",wcf2));
sheet.addCell(new Label(41,0,"财务-外币调整日期",wcf2));
sheet.addCell(new Label(42,0,"航司",wcf2));
sheet.addCell(new Label(43,0,"旅客姓名",wcf2));
//遍历采购信息
if(saleDetails == null || saleDetails.size() == 0){
logger.info("获取销售明细表数据为空,saleDetails.size()=0");
}else{
for (int i = 0; i < saleDetails.size(); i++) {
SaleDetail saleDetail = saleDetails.get(i);
Integer count = 0;
if(i-1 > 0){//如果本票号与上一行票号一致,合并
String pnr = saleDetail.getPnr();
for (int j = i-1; j >= 0; j--) {
if(saleDetails.size() > i+1){
if(pnr.equals(saleDetails.get(i+1).getPnr()) && saleDetails.get(i+1).getPurchaseTime() == null){
break;
}
}
if(pnr.equals(saleDetails.get(j).getPnr()) && saleDetail.getPurchaseTime() == null){
count ++;
}else{
break;
}
}
}
if(saleDetail.getCreateOrderTime()!=null){
// sheet.addCell(new Label(0,i+1,date_alt(String.valueOf(saleDetail.getCreateOrderTime().getTime())),wcf2));
sheet.addCell(new Label(0,i+1,date_alt(saleDetail.getCreateOrderTime()),wcf2));
}else{
if(saleDetails.get(i-1) != null){
if(saleDetail.getOuterOrderNo().equals(saleDetails.get(i-1).getOuterOrderNo())){
if(saleDetails.get(i-1).getCreateOrderTime() != null){
saleDetail.setCreateOrderTime(saleDetails.get(i-1).getCreateOrderTime());
}
// sheet.addCell(new Label(0,i+1,date_alt(String.valueOf(saleDetails.get(i-1).getCreateOrderTime().getTime())),wcf2));
sheet.addCell(new Label(0,i+1,date_alt(String.valueOf(saleDetails.get(i-1).getCreateOrderTime())),wcf2));
}
}
}
if(saleDetail.getTicketTime()!=null){
// sheet.addCell(new Label(1,i+1,date_alt(String.valueOf(saleDetail.getTicketTime().getTime())),wcf2));
sheet.addCell(new Label(1,i+1,date_alt(saleDetail.getTicketTime()),wcf2));
}
if(saleDetail.getOuterOrderNo()!=null){
sheet.addCell(new Label(2,i+1,saleDetail.getOuterOrderNo(),wcf2));
}
if(StringUtils.isNotBlank(saleDetail.getChannel())){
sheet.addCell(new Label(3,i+1,saleDetail.getChannel(),wcf2));
}else{
if(saleDetails.get(i-1) != null){
if(saleDetail.getOuterOrderNo().equals(saleDetails.get(i-1).getOuterOrderNo())){
sheet.addCell(new Label(3,i+1,saleDetails.get(i-1).getChannel(),wcf2));
}
}
}
if(StringUtils.isNotBlank(saleDetail.getStore())){
sheet.addCell(new Label(4,i+1,saleDetail.getStore(),wcf2));
}else{
if(saleDetails.get(i-1) != null){
if(saleDetail.getOuterOrderNo().equals(saleDetails.get(i-1).getOuterOrderNo())){
sheet.addCell(new Label(4,i+1,saleDetails.get(i-1).getStore(),wcf2));
}
}
}
if(saleDetail.getTairLine()!=null){
sheet.addCell(new Label(5,i+1,saleDetail.getTairLine(),wcf2));
}
if(saleDetail.getFlightTime()!=null){
String flightTime = saleDetail.getFlightTime();
if(saleDetail.getFlightTime().length() == 13){
flightTime = date_alt(saleDetail.getFlightTime());
sheet.addCell(new Label(6,i+1,flightTime,wcf2));
}else if(saleDetail.getFlightTime().length() == 26){
String flight_from = flightTime.substring(0,13);
String flight_ret = flightTime.substring(13);
sheet.addCell(new Label(6,i+1,date_alt(flight_from)+"\n"
+date_alt(flight_ret),wcf2));
}
}
if(saleDetail.getFlightNumber()!=null){
sheet.addCell(new Label(7,i+1,saleDetail.getFlightNumber(),wcf2));
}
if(saleDetail.getTripType()!=null){
sheet.addCell(new Label(8,i+1,saleDetail.getTripType(),wcf2));
}
if(saleDetail.getPnrType()!=null){
sheet.addCell(new Label(9,i+1,saleDetail.getPnrType(),wcf2));
}
if(saleDetail.getPnr()!=null){
sheet.addCell(new Label(10,i+1,saleDetail.getPnr(),wcf2));
}
if(saleDetail.getPassengerCount()!=null){
sheet.addCell(new Number(11,i+1,saleDetail.getPassengerCount(),wcf2));
}
if(saleDetail.getAdultCount()!=null){
sheet.addCell(new Number(12,i+1,saleDetail.getAdultCount(),wcf2));
}
if(saleDetail.getChildCount()!=null){
sheet.addCell(new Number(13,i+1,saleDetail.getChildCount(),wcf2));
}
if(saleDetail.getSalePrice()!=null){
sheet.addCell(new Number(14,i+1,saleDetail.getSalePrice(),wcf2));
}
if(saleDetail.getLuggagePrice()!=null){
sheet.addCell(new Number(15,i+1,saleDetail.getLuggagePrice(),wcf2));
}
if(saleDetail.getPoints()!=null){
sheet.addCell(new Number(16,i+1,saleDetail.getPoints(),wcf2));
}
if(saleDetail.getPurchaseCurrency()!=null){
sheet.addCell(new Label(17,i+1,saleDetail.getPurchaseCurrency(),wcf2));
}
if(saleDetail.getPurchasePrice_local()!=null){
sheet.addCell(new Number(18,i+1,saleDetail.getPurchasePrice_local(),wcf2));
}
if(saleDetail.getPurchasePrice_rmb()!=null){
sheet.addCell(new Number(19,i+1,saleDetail.getPurchasePrice_rmb(),wcf2));
}
if(saleDetail.getTransactionDetail_local()!=null){
sheet.addCell(new Number(20,i+1,saleDetail.getTransactionDetail_local(),wcf2));
}
if(saleDetail.getTransactionDetail_rmb()!=null){
sheet.addCell(new Number(21,i+1,saleDetail.getTransactionDetail_rmb(),wcf2));
}
if(saleDetail.getPayMethod()!=null){
sheet.addCell(new Label(22,i+1,saleDetail.getPayMethod(),wcf2));
}
if(saleDetail.getCardNumber()!=null){
sheet.addCell(new Label(23,i+1,saleDetail.getCardNumber(),wcf2));
}
if(saleDetail.getProfit()!=null){
sheet.addCell(new Number(24,i+1,saleDetail.getProfit(),wcf2));
}
if(saleDetail.getTransactionNumber()!=null){
sheet.addCell(new Label(25,i+1,saleDetail.getTransactionNumber(),wcf2));
}
if(saleDetail.getOrderValueAddedNo()!=null){
sheet.addCell(new Label(26,i+1,saleDetail.getOrderValueAddedNo(),wcf2));
}
if(saleDetail.getPurchaseChannel()!=null){
sheet.addCell(new Label(27,i+1,saleDetail.getPurchaseChannel(),wcf2));
}
if(saleDetail.getPurchaseAccount()!=null){
sheet.addCell(new Label(28,i+1,saleDetail.getPurchaseAccount(),wcf2));
}
if(saleDetail.getPurchaseOrderNo()!=null){
sheet.addCell(new Label(29,i+1,saleDetail.getPurchaseOrderNo(),wcf2));
}
if(saleDetail.getPolicyType()!=null){
sheet.addCell(new Label(30,i+1,saleDetail.getPolicyType(),wcf2));
}
if(saleDetail.getPolicyCode()!=null){
sheet.addCell(new Label(31,i+1,saleDetail.getPolicyCode(),wcf2));
}
if(saleDetail.getOrderStatus()!=null){
sheet.addCell(new Label(32,i+1,saleDetail.getOrderStatus(),wcf2));
}
if(saleDetail.getOperator()!=null){
sheet.addCell(new Label(33,i+1,saleDetail.getOperator(),wcf2));
}
if(saleDetail.getPurchaseTime()!=null){
// sheet.addCell(new Label(34,i+1,date_alt(String.valueOf(saleDetail.getPurchaseTime().getTime())),wcf2));
sheet.addCell(new Label(34,i+1,date_alt(String.valueOf(saleDetail.getPurchaseTime())),wcf2));
}
if(saleDetail.getOrderValueAdded()!=null){
sheet.addCell(new Label(35,i+1,saleDetail.getOrderValueAdded(),wcf2));
}
if(saleDetail.getOrderValueAddedSpecific()!=null){
sheet.addCell(new Label(36,i+1,saleDetail.getOrderValueAddedSpecific(),wcf2));
}
if(saleDetail.getRemark()!=null){
sheet.addCell(new Label(37,i+1,saleDetail.getRemark(),wcf2));
}
if(saleDetail.getOfficalReceivedPaymentStatus()!=null){
sheet.addCell(new Label(38,i+1,saleDetail.getOfficalReceivedPaymentStatus(),wcf2));
}
sheet.addCell(new Label(39,i+1,"",wcf2));
sheet.addCell(new Label(40,i+1,"",wcf2));
sheet.addCell(new Label(41,i+1,"",wcf2));
String carrier = "";//航司
if(StringUtils.isNotBlank(saleDetail.getFlightNumber())){
carrier = saleDetail.getFlightNumber().substring(0,2);
}
sheet.addCell(new Label(42,i+1,carrier,wcf2));
if(StringUtils.isNotBlank(saleDetail.getPassengerNames())){
sheet.addCell(new Label(43,i+1,saleDetail.getPassengerNames(),wcf2));
}
if(count > 0){//本采购信息对应票号
sheet.mergeCells(10,i+1-count,10,i+1);
sheet.mergeCells(11,i+1-count,11,i+1);
sheet.mergeCells(16,i+1-count,14,i+1);
sheet.mergeCells(17,i+1-count,15,i+1);
sheet.mergeCells(18,i+1-count,16,i+1);
sheet.mergeCells(19,i+1-count,17,i+1);
sheet.mergeCells(24,i+1-count,22,i+1);
sheet.mergeCells(26,i+1-count,24,i+1);
sheet.mergeCells(27,i+1-count,25,i+1);
sheet.mergeCells(28,i+1-count,26,i+1);
sheet.mergeCells(29,i+1-count,27,i+1);
sheet.mergeCells(33,i+1-count,31,i+1);
sheet.mergeCells(34,i+1-count,32,i+1);
sheet.mergeCells(43,i+1-count,41,i+1);
}
}
}
logger.info("生成销售明细报表成功!");
}catch (Exception e) {
e.printStackTrace();
logger.error("导出Execl异常",e);
}finally{
try{
workbook.write();
workbook.close();
}catch (Exception e){
e.printStackTrace();
logger.error("写出Execl异常",e);
}
}
return file;
}
}
......@@ -3,6 +3,7 @@ package com.yutu.base.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.yutu.base.entity.Response;
import com.yutu.base.entity.SaleDetail;
import com.yutu.base.utils.HttpsSendData;
......@@ -14,6 +15,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
......@@ -27,6 +29,8 @@ import java.util.concurrent.LinkedBlockingDeque;
/**
* 销售明细报表相关操作
* @author pc
* @date 20210324104930
*/
@Service
public class SaleDetailService implements CommandLineRunner {
......@@ -37,6 +41,8 @@ public class SaleDetailService implements CommandLineRunner {
@Value("${spring.urlConfig.statementApiUrl}")
private String statementApiUrl;
@Value("${spring.pathConfig.saleDetailReportExcelPath}")
private String saleDetailReportExcelPath;
@Value("${spring.urlConfig.productServiceUrl}")
......@@ -51,11 +57,9 @@ public class SaleDetailService implements CommandLineRunner {
/**
* 获取销售明细报表数据
* 参数:
* startTime endTime 采购时间
* creatStartTime creatEndTime 生单时间
* ticketStartTime ticketEndTime 出票时间
*
*
* startPurchaseTime endPurchaseTime 采购时间
* startCreateOrderTime endCreateOrderTime 生单时间
* startTicketTime endTicketTime 出票时间
*
* @param requestBody
* @return
......@@ -69,15 +73,10 @@ public class SaleDetailService implements CommandLineRunner {
}
logger.info("开始获取数据,参数:" + requestBody);
long beginTime = System.currentTimeMillis();
// String result = HttpsSendData.getPost(overseasAirTicketUrl+"orderInfo/getReportExcelData.do",requestBody); autoSaleDetai/findByKeyList
// String result = HttpsSendData.getPost(statementApiUrl + "saledetail/getSaleDetailList", requestBody);
String result = "{\"status\":0,\"msg\":\"查询成功\",\"data\":[{\"id\":\"00027727-2e16-485a-b1b3-f13d5079645a\",\"key\":\"df0286f1-eaac-11e7-adf4-a4badb3682ff_2018-10-25_2018-10-26\",\"createTime\":\"2018-12-21 09:41:41\",\"updateTime\":\"2018-12-21 09:41:41\",\"createOrderTime\":\"2018-10-24 16:24:26\",\"ticketTime\":\"2018-10-25 00:55:41\",\"outerOrderNo\":\"1380889117689\",\"channel\":\"Taobao\",\"store\":\"tbml\",\"tairLine\":\"HKT-DMK\",\"flightTime\":\"1544358000000\",\"flightNumber\":\"FD3028\",\"tripType\":\"单程\",\"pnrType\":\"去程\",\"pnr\":\"BWSTUZ\",\"passengerCount\":1,\"salePrice\":128,\"luggagePrice\":0,\"points\":0,\"purchaseCurrency\":\"CNY\",\"purchasePrice_local\":92,\"purchasePrice_rmb\":92,\"transactionDetail_local\":92,\"transactionDetail_rmb\":92,\"payMethod\":\"支付宝huochepiao3\",\"cardNumber\":\"支付宝huochepiao3\",\"profit\":36,\"transactionNumber\":\" \",\"orderValueAddedNo\":\" \",\"purchaseChannel\":\"艺龙\",\"purchaseAccount\":\"18513092060----huidarui\",\"purchaseOrderNo\":\"IT7JP5181024MO515179\",\"policyType\":\"普通促销\",\"policyCode\":\"TGJ泰国-中国\",\"orderStatus\":\"已出票\",\"operator\":\"曹坤祥\",\"purchaseTime\":\"2018-10-24 19:01:39\",\"orderValueAdded\":\" \",\"orderValueAddedSpecific\":\" \",\"remark\":\" \",\"officalReceivedPaymentStatus\":\" \",\"officalActualExpendAmount\":0,\"officalBalance\":0,\"officalRateAdjustDate\":null,\"passengerNames\":null,\"adultCount\":1,\"childCount\":0,\"sortIndex\":438}],\"info\":null}";
// String result = HttpsSendData.getPost(overseasAirTicketUrl+"orderInfo/getReportExcelData.do",requestBody); autoSaleDetai/findByKeyList
String result = HttpsSendData.getPost(statementApiUrl + "saledetail/getSaleDetailList", requestBody);
// String result = "{\"status\":0,\"msg\":\"查询成功\",\"data\":[{\"id\":\"00027727-2e16-485a-b1b3-f13d5079645a\",\"key\":\"df0286f1-eaac-11e7-adf4-a4badb3682ff_2018-10-25_2018-10-26\",\"createTime\":\"2018-12-21 09:41:41\",\"updateTime\":\"2018-12-21 09:41:41\",\"createOrderTime\":\"2018-10-24 16:24:26\",\"ticketTime\":\"2018-10-25 00:55:41\",\"outerOrderNo\":\"1380889117689\",\"channel\":\"Taobao\",\"store\":\"tbml\",\"tairLine\":\"HKT-DMK\",\"flightTime\":\"1544358000000\",\"flightNumber\":\"FD3028\",\"tripType\":\"单程\",\"pnrType\":\"去程\",\"pnr\":\"BWSTUZ\",\"passengerCount\":1,\"salePrice\":128,\"luggagePrice\":0,\"points\":0,\"purchaseCurrency\":\"CNY\",\"purchasePrice_local\":92,\"purchasePrice_rmb\":92,\"transactionDetail_local\":92,\"transactionDetail_rmb\":92,\"payMethod\":\"支付宝huochepiao3\",\"cardNumber\":\"支付宝huochepiao3\",\"profit\":36,\"transactionNumber\":\" \",\"orderValueAddedNo\":\" \",\"purchaseChannel\":\"艺龙\",\"purchaseAccount\":\"18513092060----huidarui\",\"purchaseOrderNo\":\"IT7JP5181024MO515179\",\"policyType\":\"普通促销\",\"policyCode\":\"TGJ泰国-中国\",\"orderStatus\":\"已出票\",\"operator\":\"曹坤祥\",\"purchaseTime\":\"2018-10-24 19:01:39\",\"orderValueAdded\":\" \",\"orderValueAddedSpecific\":\" \",\"remark\":\" \",\"officalReceivedPaymentStatus\":\" \",\"officalActualExpendAmount\":0,\"officalBalance\":0,\"officalRateAdjustDate\":null,\"passengerNames\":null,\"adultCount\":1,\"childCount\":0,\"sortIndex\":438}],\"info\":null}";
if (StringUtils.isBlank(result)) {
// return Response.error("获取数据失败");
......@@ -87,43 +86,57 @@ public class SaleDetailService implements CommandLineRunner {
return noteResult;
}
JSONObject resultObj = JSONObject.parseObject(result);
if (resultObj.getInteger("status") != 0) {
if (resultObj.getInteger("status") != 200) {
// return Response.error("获取数据失败");
noteResult.setMsg("获取数据失败");
return noteResult;
}
logger.info("获取数据成功,共用时:" + (System.currentTimeMillis() - beginTime));
// Map<String, String> resultMap = resultObj.getObject("data", Map.class);
noteResult.setStatus(200);
// noteResult.setStatus(200);
// com.alibaba.fastjson.JSONException: can not cast to : java.util.Map
// noteResult.setData(resultMap);
noteResult.setData(resultObj.getObject("data", Object.class));
//// noteResult.setData(resultMap);
// noteResult.setData(resultObj.getObject("data", NoteResult.class)); // "data":{}, 前端报错
// noteResult.setMsg("获取成功");
noteResult.setMsg("获取成功");
return noteResult;
return JSONObject.toJavaObject(resultObj, NoteResult.class);
}
/**
* 获取销售明细报表数据,并将其处理为 Excel
* @param requestBody
* @param response
* @return
*/
public NoteResult downloadSalesDetailReportExcel(String requestBody){
NoteResult noteResult ;
public NoteResult downloadSalesDetailReportExcel(String requestBody, HttpServletResponse response){
NoteResult noteResult = new NoteResult();
System.out.println(requestBody);
if (StringUtils.isBlank(requestBody)) {
noteResult.setStatus(300);
noteResult.setMsg("参数不能为空 [requestBody]");
return noteResult;
}
String keyList = JSONObject.parseObject(requestBody).getString("keyList");
logger.info("[AutoSource] 从saleDetail表数据中直接下载报表,keyList="+keyList);
long beginTime = System.currentTimeMillis();
Map<String,String> params = new HashMap<>();
params.put("keyList", keyList);
// String result = HttpsSendData.send(statementApiUrl + "saledetail/getSaleDetailList",params);
String result = "{\"status\":200,\"msg\":\"查询成功\",\"data\":[{\"id\":\"00027727-2e16-485a-b1b3-f13d5079645a\",\"key\":\"df0286f1-eaac-11e7-adf4-a4badb3682ff_2018-10-25_2018-10-26\",\"createTime\":\"2018-12-21 09:41:41\",\"updateTime\":\"2018-12-21 09:41:41\",\"createOrderTime\":\"2018-10-24 16:24:26\",\"ticketTime\":\"2018-10-25 00:55:41\",\"outerOrderNo\":\"1380889117689\",\"channel\":\"Taobao\",\"store\":\"tbml\",\"tairLine\":\"HKT-DMK\",\"flightTime\":\"1544358000000\",\"flightNumber\":\"FD3028\",\"tripType\":\"单程\",\"pnrType\":\"去程\",\"pnr\":\"BWSTUZ\",\"passengerCount\":1,\"salePrice\":128,\"luggagePrice\":0,\"points\":0,\"purchaseCurrency\":\"CNY\",\"purchasePrice_local\":92,\"purchasePrice_rmb\":92,\"transactionDetail_local\":92,\"transactionDetail_rmb\":92,\"payMethod\":\"支付宝huochepiao3\",\"cardNumber\":\"支付宝huochepiao3\",\"profit\":36,\"transactionNumber\":\" \",\"orderValueAddedNo\":\" \",\"purchaseChannel\":\"艺龙\",\"purchaseAccount\":\"18513092060----huidarui\",\"purchaseOrderNo\":\"IT7JP5181024MO515179\",\"policyType\":\"普通促销\",\"policyCode\":\"TGJ泰国-中国\",\"orderStatus\":\"已出票\",\"operator\":\"曹坤祥\",\"purchaseTime\":\"2018-10-24 19:01:39\",\"orderValueAdded\":\" \",\"orderValueAddedSpecific\":\" \",\"remark\":\" \",\"officalReceivedPaymentStatus\":\" \",\"officalActualExpendAmount\":0,\"officalBalance\":0,\"officalRateAdjustDate\":null,\"passengerNames\":null,\"adultCount\":1,\"childCount\":0,\"sortIndex\":438}],\"info\":null}";
String result = HttpsSendData.send(statementApiUrl + "saledetail/findByKeyList", params);
// String result = HttpsSendData.getPost(statementApiUrl + "saledetail/getSaleDetailList", requestBody);
// String result = "{\"status\":200,\"msg\":\"查询成功\",\"data\":[{\"id\":\"00027727-2e16-485a-b1b3-f13d5079645a\",\"key\":\"df0286f1-eaac-11e7-adf4-a4badb3682ff_2018-10-25_2018-10-26\",\"createTime\":\"2018-12-21 09:41:41\",\"updateTime\":\"2018-12-21 09:41:41\",\"createOrderTime\":\"2018-10-24 16:24:26\",\"ticketTime\":\"2018-10-25 00:55:41\",\"outerOrderNo\":\"1380889117689\",\"channel\":\"Taobao\",\"store\":\"tbml\",\"tairLine\":\"HKT-DMK\",\"flightTime\":\"1544358000000\",\"flightNumber\":\"FD3028\",\"tripType\":\"单程\",\"pnrType\":\"去程\",\"pnr\":\"BWSTUZ\",\"passengerCount\":1,\"salePrice\":128,\"luggagePrice\":0,\"points\":0,\"purchaseCurrency\":\"CNY\",\"purchasePrice_local\":92,\"purchasePrice_rmb\":92,\"transactionDetail_local\":92,\"transactionDetail_rmb\":92,\"payMethod\":\"支付宝huochepiao3\",\"cardNumber\":\"支付宝huochepiao3\",\"profit\":36,\"transactionNumber\":\" \",\"orderValueAddedNo\":\" \",\"purchaseChannel\":\"艺龙\",\"purchaseAccount\":\"18513092060----huidarui\",\"purchaseOrderNo\":\"IT7JP5181024MO515179\",\"policyType\":\"普通促销\",\"policyCode\":\"TGJ泰国-中国\",\"orderStatus\":\"已出票\",\"operator\":\"曹坤祥\",\"purchaseTime\":\"2018-10-24 19:01:39\",\"orderValueAdded\":\" \",\"orderValueAddedSpecific\":\" \",\"remark\":\" \",\"officalReceivedPaymentStatus\":\" \",\"officalActualExpendAmount\":0,\"officalBalance\":0,\"officalRateAdjustDate\":null,\"passengerNames\":null,\"adultCount\":1,\"childCount\":0,\"sortIndex\":438}],\"info\":null}";
if (StringUtils.isBlank(result)) {
// return Response.error("获取数据失败");
noteResult.setStatus(300);
noteResult.setMsg("获取数据失败!");
noteResult.setData(new HashMap<String, String>());
return noteResult;
}
noteResult = JSONObject.parseObject(result, NoteResult.class);
if(noteResult.getStatus() != 200){
logger.error("[AutoSource] 从saleDetail表中查询报表数据失败,keyList="+keyList);
......@@ -131,14 +144,17 @@ public class SaleDetailService implements CommandLineRunner {
noteResult.setStatus(300); // 获取失败状态值
return noteResult;
}
List<SaleDetail> saleDetails = JSONArray.parseArray(JSONArray.toJSONString(noteResult.getData()), SaleDetail.class);
Response response = new Response();
// 从分页对象中取出 data ,再从 data.list 中取出 销售明细数据的数组
List<SaleDetail> saleDetails = JSONArray.parseArray(JSONArray.toJSONString((noteResult.getData())), SaleDetail.class);
// List<SaleDetail> saleDetails = JSONArray.parseArray(JSONArray.toJSONString(((PageInfo)noteResult.getData()).getList()), SaleDetail.class);
logger.info("[AutoSource] 获取数据库表数据,总用时:"+(System.currentTimeMillis()-beginTime)+"ms");
try{
// String customerId = keyList.substring(0,keyList.indexOf("_"));
String customerId = JSONObject.parseObject(requestBody).getString("customerId");
final String filePath = saleDetailReportExcelPath + customerId + "/SalesDetailReport/";//指定文件保存路径
String path = parseToSaleDetail.createSaleDetailReport(saleDetails,filePath);
// String customerId = JSONObject.parseObject(requestBody).getString("customerId");
// final String filePath = saleDetailReportExcelPath + customerId + "/SalesDetailReport/";//指定文件保存路径
// 使用浏览器的下载机制,而不是指定本地保存下载路径
String path = parseToSaleDetail.createSaleDetailReport(saleDetails, response);
noteResult.setStatus(Response.Status.SUCCEED.getStatus());
noteResult.setData(path);
noteResult.setMsg("[AutoSource] 生成报表成功,总用时:"+(System.currentTimeMillis()-beginTime)+"ms");
......
package com.yutu.base.service;
import com.alibaba.fastjson.JSONObject;
import com.yutu.base.utils.HttpsSendData;
import com.yutu.comm.entity.exception.NoteResult;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
/**
* 销售汇总
* @author pc
* @date 2021年03月24日 18:41
*/
@Service
public class SalesSummaryService {
@Value("${spring.urlConfig.statementApiUrl}")
private String statementApiUrl;
private static Logger logger = Logger.getLogger("saleDetail");
/**
* 获取销售汇总报表数据
* 参数:
* startCreateOrderTime endCreateOrderTime 生单时间
* startTicketTime endTicketTime 出票时间
*
* @param requestBody
* @return
*/
public NoteResult getSalesSummaryList(String requestBody) {
NoteResult noteResult = new NoteResult();
if (StringUtils.isBlank(requestBody)) {
noteResult.setStatus(300);
noteResult.setMsg("参数不能为空 [requestBody] ");
return noteResult;
}
logger.info("开始获取数据,参数: " + requestBody);
long beginTime = System.currentTimeMillis();
String result = HttpsSendData.getPost(statementApiUrl + "salesSummary/getSalesSummaryList", requestBody);
// String result = "{\"status\":0,\"msg\":\"查询成功\",\"data\":[{\"id\":\"00027727-2e16-485a-b1b3-f13d5079645a\",\"key\":\"df0286f1-eaac-11e7-adf4-a4badb3682ff_2018-10-25_2018-10-26\",\"createTime\":\"2018-12-21 09:41:41\",\"updateTime\":\"2018-12-21 09:41:41\",\"createOrderTime\":\"2018-10-24 16:24:26\",\"ticketTime\":\"2018-10-25 00:55:41\",\"outerOrderNo\":\"1380889117689\",\"channel\":\"Taobao\",\"store\":\"tbml\",\"tairLine\":\"HKT-DMK\",\"flightTime\":\"1544358000000\",\"flightNumber\":\"FD3028\",\"tripType\":\"单程\",\"pnrType\":\"去程\",\"pnr\":\"BWSTUZ\",\"passengerCount\":1,\"salePrice\":128,\"luggagePrice\":0,\"points\":0,\"purchaseCurrency\":\"CNY\",\"purchasePrice_local\":92,\"purchasePrice_rmb\":92,\"transactionDetail_local\":92,\"transactionDetail_rmb\":92,\"payMethod\":\"支付宝huochepiao3\",\"cardNumber\":\"支付宝huochepiao3\",\"profit\":36,\"transactionNumber\":\" \",\"orderValueAddedNo\":\" \",\"purchaseChannel\":\"艺龙\",\"purchaseAccount\":\"18513092060----huidarui\",\"purchaseOrderNo\":\"IT7JP5181024MO515179\",\"policyType\":\"普通促销\",\"policyCode\":\"TGJ泰国-中国\",\"orderStatus\":\"已出票\",\"operator\":\"曹坤祥\",\"purchaseTime\":\"2018-10-24 19:01:39\",\"orderValueAdded\":\" \",\"orderValueAddedSpecific\":\" \",\"remark\":\" \",\"officalReceivedPaymentStatus\":\" \",\"officalActualExpendAmount\":0,\"officalBalance\":0,\"officalRateAdjustDate\":null,\"passengerNames\":null,\"adultCount\":1,\"childCount\":0,\"sortIndex\":438}],\"info\":null}";
if (StringUtils.isBlank(result)) {
noteResult.setStatus(300);
noteResult.setMsg("获取数据失败!");
noteResult.setData(new HashMap<String, String>());
return noteResult;
}
JSONObject resultObj = JSONObject.parseObject(result);
if (resultObj.getInteger("status") != 200) {
noteResult.setMsg("获取数据失败!");
return noteResult;
}
logger.info("获取数据成功,共用时:" + (System.currentTimeMillis() - beginTime));
return JSONObject.toJavaObject(resultObj, NoteResult.class);
}
}
package com.yutu.base.utils;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections4.Get;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
......@@ -18,50 +19,50 @@ import java.util.Map;
import java.util.Scanner;
public class HttpsSendData {
public class HttpsSendData {
/**
* @param url 请求地址
* @param paramsMap 将参数的名作为键
* @return
*/
public static Logger logger= Logger.getLogger(HttpsSendData.class.getName());
public static String send(String url, Map<String, String> paramsMap) {
String result = null;
String result = null;
PostMethod postMethod = null;
HttpClient httpClient = new HttpClient();
httpClient.getParams().setParameter(
httpClient.getParams().setParameter(
HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8");
postMethod = new PostMethod(url);
if (paramsMap != null && paramsMap.size() > 0) {
if (paramsMap != null && paramsMap.size() > 0) {
NameValuePair[] datas = new NameValuePair[paramsMap.size()];
int index = 0;
for (String key : paramsMap.keySet()) {
int index = 0;
for (String key : paramsMap.keySet()) {
datas[index++] = new NameValuePair(key,paramsMap.get(key));
}
postMethod.setRequestBody(datas);
}
}
postMethod.setRequestBody(datas);
}
HttpClientParams httparams = new HttpClientParams();
httparams.setSoTimeout(300000);
postMethod.setParams(httparams);
try {
int statusCode = httpClient.executeMethod(postMethod);
try {
int statusCode = httpClient.executeMethod(postMethod);
if (statusCode == HttpStatus.SC_OK) {
//result = postMethod.getResponseBodyAsString();//原来的方式
InputStream is = postMethod.getResponseBodyAsStream();
Scanner scanner = new Scanner(is, "UTF-8");
result=scanner.useDelimiter("\\A").next();
} else {
} else {
System.out.println("请求状态:"+statusCode);
}
}
} catch (Exception e) {
e.printStackTrace();
}finally {
}finally {
if (postMethod != null) {
//释放链接
postMethod.releaseConnection();
postMethod.releaseConnection();
}
if(url.contains("insert.do") || url.contains("update.do") || url.contains("delete")){
logger.info("url:"+url);
......@@ -79,15 +80,15 @@ public class HttpsSendData {
logger.info("result:"+ JSONObject.toJSONString(result));
}
}
return result;
return result;
}
public static String getPost(String url, String body) {
//System.out.println("准备开始发送请求:"+System.currentTimeMillis());
String result = null;
String result = null;
PostMethod postMethod = new PostMethod(url);
if(body!=null && !"".equals(body)){
StringRequestEntity requestEntity;
......@@ -99,44 +100,44 @@ public class HttpsSendData {
e.printStackTrace();
}
}
HttpClientParams httparams = new HttpClientParams();
httparams.setSoTimeout(180000);
postMethod.setParams(httparams);
postMethod.setParams(httparams);
postMethod.setRequestHeader("Content-Type","application/json;charset=UTF-8");
HttpClient httpClient = new HttpClient();
httpClient.getParams().setParameter(
httpClient.getParams().setParameter(
HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8");
try {
int statusCode = httpClient.executeMethod(postMethod);
try {
int statusCode = httpClient.executeMethod(postMethod);
if (statusCode == HttpStatus.SC_OK) {
//result = postMethod.getResponseBodyAsString();//原来的方式
InputStream is = postMethod.getResponseBodyAsStream();
Scanner scanner = new Scanner(is, "UTF-8");
result=scanner.useDelimiter("\\A").next();
} else {
} else {
System.out.println("请求状态:"+statusCode);
}
}
} catch (Exception e) {
e.printStackTrace();
}finally {
}finally {
if (postMethod != null) {
//释放链接
postMethod.releaseConnection();
}
postMethod.releaseConnection();
}
}
//System.out.println("收到响应:"+System.currentTimeMillis());
return result;
return result;
}
public static String httpPost(String url, String body) {
//System.out.println("准备开始发送请求:"+System.currentTimeMillis());
String result = null;
String result = null;
PostMethod postMethod = new PostMethod(url);
if(body!=null && !"".equals(body)){
StringRequestEntity requestEntity;
......@@ -148,39 +149,91 @@ public class HttpsSendData {
e.printStackTrace();
}
}
HttpClientParams httparams = new HttpClientParams();
httparams.setSoTimeout(180000);
postMethod.setParams(httparams);
postMethod.setParams(httparams);
postMethod.setRequestHeader("Content-Type","application/json;charset=UTF-8");
HttpClient httpClient = new HttpClient();
httpClient.getParams().setParameter(
httpClient.getParams().setParameter(
HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8");
try {
int statusCode = httpClient.executeMethod(postMethod);
try {
int statusCode = httpClient.executeMethod(postMethod);
if (statusCode == HttpStatus.SC_OK) {
//result = postMethod.getResponseBodyAsString();//原来的方式
InputStream is = postMethod.getResponseBodyAsStream();
Scanner scanner = new Scanner(is, "UTF-8");
result=scanner.useDelimiter("\\A").next();
} else {
} else {
System.out.println("请求状态:"+statusCode);
}
}
} catch (Exception e) {
e.printStackTrace();
}finally {
}finally {
if (postMethod != null) {
//释放链接
postMethod.releaseConnection();
}
postMethod.releaseConnection();
}
}
//System.out.println("收到响应:"+System.currentTimeMillis());
return result;
}
/**
* get 请求
* @param url
* @param body
* @return
*/
public static String httpGet(String url, String body) {
//System.out.println("准备开始发送请求:"+System.currentTimeMillis());
String result = null;
GetMethod getMethod = new GetMethod(url);
PostMethod postMethod = new PostMethod(url);
if(body!=null && !"".equals(body)){
StringRequestEntity requestEntity;
try {
requestEntity = new StringRequestEntity(body,"application/json","UTF-8");
postMethod.setRequestEntity(requestEntity);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
HttpClientParams httparams = new HttpClientParams();
httparams.setSoTimeout(180000);
postMethod.setParams(httparams);
postMethod.setRequestHeader("Content-Type","application/json;charset=UTF-8");
HttpClient httpClient = new HttpClient();
httpClient.getParams().setParameter(
HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8");
try {
int statusCode = httpClient.executeMethod(postMethod);
if (statusCode == HttpStatus.SC_OK) {
//result = postMethod.getResponseBodyAsString();//原来的方式
InputStream is = postMethod.getResponseBodyAsStream();
Scanner scanner = new Scanner(is, "UTF-8");
result=scanner.useDelimiter("\\A").next();
} else {
System.out.println("请求状态:"+statusCode);
}
} catch (Exception e) {
e.printStackTrace();
}finally {
if (postMethod != null) {
//释放链接
postMethod.releaseConnection();
}
}
//System.out.println("收到响应:"+System.currentTimeMillis());
return result;
}
}
}
spring:
urlConfig:
overseasCheetahUrl: 'http://127.0.0.1:18092/polestar/'
overseasAirTicketUrl: 'http://127.0.0.1:18071/OverseasAirTicket/'
# overseasAirTicketUrl: 'http://127.0.0.1:18071/OverseasAirTicket/'
overseasAirTicketUrl: 'http://192.168.11.158:8080/ordercenterApi/'
productServiceUrl: 'http://127.0.0.1:28071/20160907_InterfaceConnected/'
polestarLogsServicesUrl: 'http://127.0.0.1:8089/'
dataApiUrl: 'http://127.0.0.1:38071/iffs-data-api/'
dataApiUrl: 'http://14.18.207.91:38071/iffs-data-api/'
# 订单服务 ordercenter
statementApiUrl: 'http://http://121.36.16.56:32482/ordercenterApi/'
pathConfig:
saleDetailReportExcelPath: 'D:\\polestar_ExcelFile/'
saleReportExcelPath: 'D:/polestar_ExcelFile/'
saleDetailReportExcelPath: 'D:\\polestar_ExcelFile/' # 销售明细报表导出保存的本地路径
saleReportExcelPath: 'D:/polestar_ExcelFile/' #
server:
port: 8066
compression:
......
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