chenrj-PC\chenrj 9 лет назад
Родитель
Сommit
294ace78e3

+ 18 - 0
VisualInspection_server/pom.xml

@@ -156,8 +156,26 @@
 		    <artifactId>aspectjweaver</artifactId>
 		    <version>1.8.10</version>
 		 </dependency>
+		
+		<dependency>
+			<groupId>org.apache.poi</groupId>
+			<artifactId>poi</artifactId>
+			<version>3.12</version>
+		</dependency>
 
 		<dependency>
+			<groupId>org.jxls</groupId>
+			<artifactId>jxls</artifactId>
+			<version>2.3.0</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.jxls</groupId>
+			<artifactId>jxls-poi</artifactId>
+			<version>1.0.9</version>
+		</dependency>
+		
+		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-test</artifactId>
 			<scope>test</scope>

+ 61 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/controller/FileExcelController.java

@@ -0,0 +1,61 @@
+package com.xintong.visualinspection.controller;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+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 com.xintong.visualinspection.bean.StatisticsBean;
+import com.xintong.visualinspection.bean.StatisticsBo;
+import com.xintong.visualinspection.service.StatisticsService;
+
+/**
+ * 文件名:StatisticsController
+ * 版本信息:日期:2017/3/30 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
+ */
+@RestController
+@RequestMapping("/file")
+public class FileExcelController extends BaseController {
+
+	@Autowired
+	private StatisticsService statisticsService;
+    
+    /**
+     * 温馨服务考核情况反馈表(所有员工排名)
+     * @return
+     * String
+     * @exception
+     * @since  1.0.0
+     */
+    @RequestMapping(value = "/employee/order",method=RequestMethod.GET)
+    public String getEmployeeOrder(HttpServletRequest req,HttpServletResponse resp){
+    	 statisticsService.getEmployeeCheckedInfo(new StatisticsBean(), req, resp);
+    	return super.returnSuccessResult(null);
+    }
+    
+    /**
+     * 温馨服务检查千分考核扣分情况汇总表
+     * @param obj
+     * @return
+     */
+    @RequestMapping(value = "/score/info",method=RequestMethod.GET)
+    public String getScoreInfo(@RequestBody StatisticsBean obj){
+    	List<StatisticsBean> lists=  statisticsService.getFeeStationCheckedScore(obj);
+    	return super.returnSuccessResult(lists);
+    }
+    
+    /**
+     * 温馨服务检查情况统计表
+     */
+    @RequestMapping(value = "/score/item/info",method=RequestMethod.GET)
+    public String getScoreItemInfo(@RequestBody StatisticsBean obj){
+    	List<StatisticsBean> lists=  statisticsService.getFeeStationCheckItemScore(obj);
+    	return super.returnSuccessResult(lists);
+    }
+}

+ 9 - 2
VisualInspection_server/src/main/java/com/xintong/visualinspection/service/StatisticsService.java

@@ -2,8 +2,9 @@ package com.xintong.visualinspection.service;
 
 import java.util.List;
 
-import com.xintong.visualinspection.bean.CheckRule;
-import com.xintong.visualinspection.bean.Constant;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import com.xintong.visualinspection.bean.StatisticsBean;
 import com.xintong.visualinspection.bean.StatisticsBo;
 
@@ -27,4 +28,10 @@ public interface StatisticsService {
 	
 	public List<StatisticsBean> getFeeStationCheckItemScore(StatisticsBean obj);
 	
+	public void getEmployeeCheckedInfo(StatisticsBean obj,HttpServletRequest req,HttpServletResponse resp);
+	
+	public void getFeeStationCheckedScore(StatisticsBean obj,HttpServletRequest req,HttpServletResponse resp);
+	
+	public void getFeeStationCheckItemScore(StatisticsBean obj,HttpServletRequest req,HttpServletResponse resp);
+	
 }

+ 65 - 4
VisualInspection_server/src/main/java/com/xintong/visualinspection/service/impl/StatisticsServiceImpl.java

@@ -1,13 +1,23 @@
 package com.xintong.visualinspection.service.impl;
 
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jxls.common.Context;
+import org.jxls.util.JxlsHelper;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -18,10 +28,8 @@ import com.xintong.visualinspection.bean.User;
 import com.xintong.visualinspection.dao.cluster.DepartmentDao;
 import com.xintong.visualinspection.dao.cluster.UserInfoDao;
 import com.xintong.visualinspection.dao.master.StatisticsDao;
-import com.xintong.visualinspection.dao.master.UserDao;
 import com.xintong.visualinspection.service.BaseService;
 import com.xintong.visualinspection.service.StatisticsService;
-import com.xintong.visualinspection.util.CacheUtil;
 
 /**
  * 文件名:StatisticsServiceImpl
@@ -177,5 +185,58 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
 		return new ArrayList<>(mapStationInfos.values());
 	
 	}
+
+	@Override
+	public void getEmployeeCheckedInfo(StatisticsBean obj, HttpServletRequest req, HttpServletResponse resp) {
+		// 检索数据
+		List<StatisticsBo> listStatistic = getEmployeeCheckedInfo(obj);
+		// 处理数据
+		// todo ...   
+		
+		
+		String path = "D:/file20170606.xls";
+		try (InputStream is = this.getClass().getResourceAsStream("/employee_order.xls")) {
+			try (OutputStream os = new FileOutputStream(path)) {
+				Context context = new Context();
+				context.putVar("list", listStatistic);
+				JxlsHelper.getInstance().processTemplate(is, os, context);
+			}
+			Thread.sleep(1000);
+			// path是指欲下载的文件的路径。
+			File file = new File(path);
+			// 取得文件名。
+			String filename = file.getName();
+			// 以流的形式下载文件。
+			InputStream bis = new BufferedInputStream(new FileInputStream(file));
+			byte[] buffer = new byte[bis.available()];
+			bis.read(buffer);
+			bis.close();
+			// 清空response
+			resp.reset();
+			// 设置response的Header
+			resp.addHeader("Content-Disposition",
+					"attachment;filename=" + new String(filename.getBytes("gb2312"), "ISO8859-1"));
+			resp.addHeader("Content-Length", "" + file.length());
+			OutputStream toClient = new BufferedOutputStream(resp.getOutputStream());
+			resp.setContentType("application/vnd.ms-excel;charset=gb2312");
+			toClient.write(buffer);
+			toClient.flush();
+			toClient.close();
+		}catch(Exception e){
+			logger.error(e.toString());
+		}
+	}
+
+	@Override
+	public void getFeeStationCheckedScore(StatisticsBean obj, HttpServletRequest req, HttpServletResponse resp) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	public void getFeeStationCheckItemScore(StatisticsBean obj, HttpServletRequest req, HttpServletResponse resp) {
+		// TODO Auto-generated method stub
+		
+	}
     
 }

BIN
VisualInspection_server/src/main/resources/employee_order.xls