|
@@ -1,6 +1,7 @@
|
|
|
package com.iamberry.rst.controllers.cm;
|
|
|
|
|
|
import com.iamberry.rst.core.cm.CompanyInfo;
|
|
|
+import com.iamberry.rst.core.cm.SalesOrder;
|
|
|
import com.iamberry.rst.core.fm.*;
|
|
|
import com.iamberry.rst.core.order.Product;
|
|
|
import com.iamberry.rst.core.order.ProductColor;
|
|
@@ -23,6 +24,7 @@ import com.iamberry.rst.utils.AdminUtils;
|
|
|
import com.iamberry.rst.utils.GenerateKeyUtil;
|
|
|
import com.iamberry.rst.utils.StitchAttrUtil;
|
|
|
import com.iamberry.wechat.tools.ResponseJson;
|
|
|
+import org.apache.poi.hssf.usermodel.*;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
@@ -31,7 +33,10 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.*;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
@@ -610,5 +615,196 @@ public class AdminDetectController {
|
|
|
}
|
|
|
return msg;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询维修信息条数
|
|
|
+ * @param request
|
|
|
+ * @param res
|
|
|
+ * @param detectInfo
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @ResponseBody
|
|
|
+ @RequiresPermissions("detect:select:detect")
|
|
|
+ @RequestMapping("/detect_excel_num")
|
|
|
+ public ResponseJson salesOrderExcelNum(HttpServletRequest request,HttpServletResponse res
|
|
|
+ , ComplaintDetectInfo detectInfo) throws Exception{
|
|
|
+ ResponseJson msg = new ResponseJson();
|
|
|
+ //根据条件查询维修数据
|
|
|
+ List<ComplaintDetectInfo> detectList = complaintDetectInfoService.listComplaintDetect(detectInfo);
|
|
|
+ if (detectList == null || detectList.size() == 0) {
|
|
|
+ msg.setResultCode(500);
|
|
|
+ msg.setReturnCode(500);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ msg.setResultCode(200);
|
|
|
+ msg.setReturnCode(200);
|
|
|
+ return msg;
|
|
|
+
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 导出维修信息
|
|
|
+ * @param request
|
|
|
+ * @param res
|
|
|
+ * @param detectInfo
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @RequiresPermissions("detect:select:detect")
|
|
|
+ @RequestMapping("/detect_excel")
|
|
|
+ public void salesOrderExcel(HttpServletRequest request,HttpServletResponse res
|
|
|
+ , ComplaintDetectInfo detectInfo) throws Exception{
|
|
|
+ //根据id查询订单数据
|
|
|
+ List<ComplaintDetectInfo> detectList = complaintDetectInfoService.listComplaintDetect(detectInfo);
|
|
|
+ if (detectList == null || detectList.size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String[] cells = {
|
|
|
+ "维修编号","产品名称","颜色","生产月份","机身条码",
|
|
|
+ "退货地区","返厂日期","购买日期","客诉日期","客诉类型",
|
|
|
+ "客诉问题","售后原因","售后处理类型","工厂检测现象","是否翻新机",
|
|
|
+ "故障原因","判断结果","故障指向","原因分析",
|
|
|
+ "维修内容","厚膜类型","浮子类型","版本号"
|
|
|
+ };
|
|
|
+ exportExcel(request,res,cells,detectList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出订单Excel并下载
|
|
|
+ * @param request
|
|
|
+ * @param res
|
|
|
+ * @param cells
|
|
|
+ * @param detectList
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public void exportExcel(HttpServletRequest request,HttpServletResponse res,
|
|
|
+ String[] cells,List<ComplaintDetectInfo> detectList) throws Exception {
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ //创建一个workbook,对应一个Excel文件
|
|
|
+ HSSFWorkbook wb = new HSSFWorkbook();
|
|
|
+ //在workbook中添加一个sheet,对应Excel中的一个sheet
|
|
|
+ HSSFSheet sheet = wb.createSheet("导出维修");
|
|
|
+ //在sheet中添加表头第0行,老版本poi对excel行数列数有限制short
|
|
|
+ HSSFRow row = sheet.createRow((int) 0);
|
|
|
+ //创建单元格,设置值表头,设置表头居中
|
|
|
+ HSSFCellStyle style = wb.createCellStyle();
|
|
|
+ //居中格式
|
|
|
+ style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
+ //设置表头
|
|
|
+
|
|
|
+ if (cells == null || cells.length == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //循环设置表头
|
|
|
+ HSSFCell cell = null;
|
|
|
+ for (int i = 0;i < cells.length;i++) {
|
|
|
+ String name = cells[i];
|
|
|
+ cell = row.createCell(i);
|
|
|
+ cell.setCellValue(name);
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ }
|
|
|
+ for (int i = 0; i < detectList.size(); i++) {
|
|
|
+ row = sheet.createRow((int) i + 1);
|
|
|
+ ComplaintDetectInfo detect = detectList.get(i);
|
|
|
+ String detectFilmType = "";
|
|
|
+ if(detect.getDetectFilmType() != null){
|
|
|
+ switch (detect.getDetectFilmType()) {
|
|
|
+ case 1:detectFilmType = "圆";break;
|
|
|
+ case 2:detectFilmType = "扁";break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String detectIsRefurbishing = "";
|
|
|
+ if(detect.getDetectIsRefurbishing() != null){
|
|
|
+ switch (detect.getDetectIsRefurbishing()) {
|
|
|
+ case 1:detectIsRefurbishing = "是";break;
|
|
|
+ case 2:detectIsRefurbishing = "否";break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String detectFloatType = "";
|
|
|
+ if(detect.getDetectFloatType() != null){
|
|
|
+ switch (detect.getDetectFloatType()) {
|
|
|
+ case 1:detectFloatType = "长";break;
|
|
|
+ case 2:detectFloatType = "短";break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 创建单元格,设置值
|
|
|
+ row.createCell(0).setCellValue(detect.getDetectNumber()==null?"":detect.getDetectNumber());
|
|
|
+ row.createCell(1).setCellValue(detect.getProductName()==null?"":detect.getProductName());
|
|
|
+ row.createCell(2).setCellValue(detect.getColorName()==null?"":detect.getColorName());
|
|
|
+ row.createCell(3).setCellValue(detect.getDetectProduction()==null?"":detect.getDetectProduction());
|
|
|
+ row.createCell(4).setCellValue(detect.getDetectFuselageBarcode()==null?"":detect.getDetectFuselageBarcode());
|
|
|
+ row.createCell(5).setCellValue(detect.getSignclosedAddrProvincesName()+"-"+detect.getSignclosedAddrCityName()+"-"+detect.getSignclosedAddrAreaName());
|
|
|
+ if(detect.getSignclosedDate()==null){
|
|
|
+ row.createCell(6).setCellValue( "");
|
|
|
+ }else{
|
|
|
+ row.createCell(6).setCellValue(detect.getSignclosedDate());
|
|
|
+ }
|
|
|
+ if(detect.getSalesTime()==null){
|
|
|
+ row.createCell(7).setCellValue( "");
|
|
|
+ }else{
|
|
|
+ row.createCell(7).setCellValue(detect.getSalesTime());
|
|
|
+ }
|
|
|
+ if(detect.getCustomerCreateTime()==null){
|
|
|
+ row.createCell(8).setCellValue("");
|
|
|
+ }else{
|
|
|
+ row.createCell(8).setCellValue(detect.getCustomerCreateTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ row.createCell(9).setCellValue(detect.getProcTypeName()==null?"":detect.getProcTypeName());
|
|
|
+ row.createCell(10).setCellValue(detect.getQuestionTitle()==null?"":detect.getQuestionTitle());
|
|
|
+ row.createCell(12).setCellValue(detect.getProcMethodName()==null?"":detect.getProcMethodName());
|
|
|
+ row.createCell(13).setCellValue(detect.getDetectPhenomenon()==null?"":detect.getDetectPhenomenon());
|
|
|
+ row.createCell(14).setCellValue(detectIsRefurbishing);
|
|
|
+ row.createCell(15).setCellValue(detect.getDetectFailureCause()==null?"":detect.getDetectFailureCause());
|
|
|
+ row.createCell(16).setCellValue(detect.getDetectResults()==null?"":detect.getDetectResults());
|
|
|
+ row.createCell(17).setCellValue(detect.getDetectPoint()==null?"":detect.getDetectPoint());
|
|
|
+ row.createCell(18).setCellValue(detect.getDetectNalysis()==null?"":detect.getDetectNalysis());
|
|
|
+ row.createCell(19).setCellValue(detect.getDetectContent()==null?"":detect.getDetectContent());
|
|
|
+ row.createCell(20).setCellValue(detectFilmType);
|
|
|
+ row.createCell(21).setCellValue(detectFloatType);
|
|
|
+ row.createCell(22).setCellValue(detect.getDetectVersionNumber()==null?"":detect.getDetectVersionNumber());
|
|
|
+ }
|
|
|
+ //下载导出订单Excel
|
|
|
+ downloadOrderExcel(res,wb);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下载导出订单Excel
|
|
|
+ * @param res
|
|
|
+ * @param wb
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public void downloadOrderExcel(HttpServletResponse res, HSSFWorkbook wb) throws Exception{
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String fileName = format.format(new Date()) + "维修报表";
|
|
|
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
+ wb.write(os);
|
|
|
+ byte[] content = os.toByteArray();
|
|
|
+ InputStream is = new ByteArrayInputStream(content);
|
|
|
+ // 设置response参数,可以打开下载页面
|
|
|
+ res.reset();
|
|
|
+ res.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
|
+ res.setHeader("Content-Disposition", "attachment;filename="
|
|
|
+ + new String((fileName + ".xls").getBytes(), "iso-8859-1"));
|
|
|
+ ServletOutputStream out = res.getOutputStream();
|
|
|
+ BufferedInputStream bis = null;
|
|
|
+ BufferedOutputStream bos = null;
|
|
|
+ try {
|
|
|
+ bis = new BufferedInputStream(is);
|
|
|
+ bos = new BufferedOutputStream(out);
|
|
|
+ byte[] buff = new byte[2048];
|
|
|
+ int bytesRead;
|
|
|
+ // Simple read/write loop.
|
|
|
+ while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
|
|
|
+ bos.write(buff, 0, bytesRead);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO: handle exception
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (bis != null)
|
|
|
+ bis.close();
|
|
|
+ if (bos != null)
|
|
|
+ bos.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|