Commit e87c86ca by manxiaoqiang

app排序

parent d28522b6
package common.controller;
import com.google.common.collect.ImmutableList;
import common.model.*;
import common.service.ContractService;
import common.service.MenuService;
import dic.OperateObjectTypeEnum;
import exception.TipException;
import org.apache.commons.io.IOUtils;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import security.annotation.CurrentAccount;
import util.NewUserLogThread;
import util.ResultModel;
import util.UserLogThread;
import util.ValidateUtil;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.List;
/**
......@@ -34,6 +51,33 @@ public class ContractController {
return ResultModel.OK(service.findAll(startDate, endDate, platform));
}
@RequestMapping(value = "export", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<byte[]> export(@PathVariable String platform, @RequestParam String startDate
, @RequestParam String endDate, HttpServletRequest request, HttpServletResponse response) {
List<Contract> contractList = service.findAll(startDate, endDate, platform);
InputStream in = null;
byte[] content = new byte[0];
StringBuilder sb = new StringBuilder();
sb.append("时间,合同编号,客户账号,签约方,销售,开始日期,结束日期,套餐类型,合同金额,折扣,收款金额,合同状态");
if(ValidateUtil.isValid(contractList)){
for (Contract c : contractList){
sb.append(c.getDs()).append(c.getContractCode()).append(c.getEmail()).append(c.getCustomerBody()).append(c.getSaleName())
.append(c.getStartDate()).append(c.getEndDate()).append(c.getPriceLevelName()).append(c.getMoney()).append(c.getPayMoney())
.append(c.getStatus());
}
}
content = sb.toString().getBytes();
HttpHeaders headers = new HttpHeaders();
response.setHeader("filename", "contraact.xls");
response.setHeader("content-disposition", "attachment; filename=contraact.xls");
response.setHeader("Content-Type", "application/vnd.ms-excel");
//返回文件字符串
return new ResponseEntity<byte[]>(content, headers, HttpStatus.CREATED);
}
@RequestMapping(value = "findone", method = RequestMethod.GET)
@ResponseBody
public ResultModel findOne(@CurrentAccount User loginAccount, @RequestParam String code) {
......
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