chenrj-PC\chenrj %!s(int64=8) %!d(string=hai) anos
pai
achega
a617085ec5

+ 16 - 0
VisualInspection/view/other_check/data_platform_check.html

@@ -28,6 +28,8 @@
 
             <div style="float:right;margin-right:30px;">
                 <button class="btn btn-primary" type="button" id="add_btn"><i class="icon icon-plus-sign"></i> 增加稽查记录</button>
+
+                <button class="btn btn-info3" type="button" style="margin-left:30px;" onclick="exportThird()" > 导出Excel</button>
             </div>
         </div>
     </div>
@@ -137,4 +139,18 @@
             check_type = 4;
             init();
         });
+
+        function exportThird(){
+             var param = '';
+             var month_date = $("#month_date").val();
+             var first =  $("#first").val(); 
+             var second = $("#second").val();
+            if( month_date != '' ){
+                param = "&check_time_name="+month_date ;
+            }
+            if( second != '' ){
+                param += "&dept_id="+ second ;
+            }
+            window.open(getserveraddr() + "/file/other/check/excel?check_type=4" + param);
+        }
     </script>

+ 15 - 0
VisualInspection/view/other_check/onsite_check.html

@@ -28,6 +28,8 @@
 
             <div style="float:right;margin-right:30px;">
                 <button class="btn btn-primary" type="button" id="add_btn"><i class="icon icon-plus-sign"></i> 增加稽查记录</button>
+
+                <button class="btn btn-info3" type="button" style="margin-left:30px;" onclick="exportThird()" > 导出Excel</button>
             </div>
         </div>
     </div>
@@ -137,4 +139,17 @@
             check_type = 3;
             init();
         });
+        function exportThird(){
+             var param = '';
+             var month_date = $("#month_date").val();
+             var first =  $("#first").val(); 
+             var second = $("#second").val();
+            if( month_date != '' ){
+                param = "&check_time_name="+month_date ;
+            }
+            if( second != '' ){
+                param += "&dept_id="+ second ;
+            }
+            window.open(getserveraddr() + "/file/other/check/excel?check_type=3" + param);
+        }
     </script>

+ 20 - 0
VisualInspection/view/other_check/special_check.html

@@ -32,6 +32,8 @@
 
             <div style="float:right;margin-right:30px;">
                 <button class="btn btn-primary" type="button" id="add_btn"><i class="icon icon-plus-sign"></i> 增加稽查记录</button>
+
+                <button class="btn btn-info3" type="button" style="margin-left:30px;" onclick="exportThird()" > 导出Excel</button>
             </div>
         </div>
     </div>
@@ -149,4 +151,22 @@
             check_type = 2;
             init();
         });
+
+        function exportThird(){
+             var param = '';
+             var month_date = $("#month_date").val();
+             var first =  $("#first").val(); 
+             var second = $("#second").val();
+             var special_check_type_name = $("#speacial_type_select").val() ;
+            if( month_date != '' ){
+                param = "&check_time_name="+month_date ;
+            }
+            if( second != '' ){
+                param += "&dept_id="+ second ;
+            }
+            if( special_check_type_name !=''){
+                param += "&special_check_type=" + special_check_type_name ;
+            }
+            window.open(getserveraddr() + "/file/other/check/excel?check_type=2" + param);
+        }
     </script>

+ 18 - 1
VisualInspection/view/other_check/third_unannounced_check.html

@@ -28,7 +28,10 @@
 
             <div style="float:right;margin-right:30px;">
                 <button class="btn btn-primary" type="button" id="add_btn"><i class="icon icon-plus-sign"></i> 增加稽查记录</button>
-            </div>
+
+                <button class="btn btn-info3" type="button" style="margin-left:30px;" onclick="exportThird()" > 导出Excel</button>
+            </div>      
+
         </div>
     </div>
     <hr>
@@ -137,4 +140,18 @@
             check_type = 1;
             init();
         });
+
+        function exportThird(){
+             var param = '';
+             var month_date = $("#month_date").val();
+             var first =  $("#first").val(); 
+             var second = $("#second").val();
+            if( month_date != '' ){
+                param = "&check_time_name="+month_date ;
+            }
+            if( second != '' ){
+                param += "&dept_id="+ second ;
+            }
+            window.open(getserveraddr() + "/file/other/check/excel?check_type=1" + param);
+        }
     </script>

+ 16 - 0
VisualInspection/view/other_check/toubleshoot_check.html

@@ -28,6 +28,8 @@
 
             <div style="float:right;margin-right:30px;">
                 <button class="btn btn-primary" type="button" id="add_btn"><i class="icon icon-plus-sign"></i> 增加稽查记录</button>
+
+                <button class="btn btn-info3" type="button" style="margin-left:30px;" onclick="exportThird()" > 导出Excel</button>
             </div>
         </div>
     </div>
@@ -145,4 +147,18 @@
             check_type = 5;
             init();
         });
+
+        function exportThird(){
+             var param = '';
+             var month_date = $("#month_date").val();
+             var first =  $("#first").val(); 
+             var second = $("#second").val();
+            if( month_date != '' ){
+                param = "&check_time_name="+month_date ;
+            }
+            if( second != '' ){
+                param += "&dept_id="+ second ;
+            }
+            window.open(getserveraddr() + "/file/other/check/excel?check_type=5" + param);
+        }
     </script>

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

@@ -17,8 +17,10 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.xintong.visualinspection.bean.CheckAppealStatistic;
+import com.xintong.visualinspection.bean.CheckOther;
 import com.xintong.visualinspection.bean.StatisticsBean;
 import com.xintong.visualinspection.bean.StatisticsBeanBO;
+import com.xintong.visualinspection.service.CheckOtherService;
 import com.xintong.visualinspection.service.StatisticsService;
 import com.xintong.visualinspection.util.DateUtil;
 
@@ -33,6 +35,8 @@ public class FileExcelController extends BaseController {
 	@Autowired
 	private StatisticsService statisticsService;
 	
+	@Autowired
+	private CheckOtherService checkOtherService  ;
 	/**
      * 收费生产人员业务提升考核情况反馈表(所有员工排名)
      * @return
@@ -205,4 +209,12 @@ public class FileExcelController extends BaseController {
     	statisticsService.getOperationInfo(obj, req, resp);
     	return super.returnSuccessResult(null);
     }
+    
+    @RequestMapping(value = "/other/check/excel",method=RequestMethod.GET)
+    public String getOtherCheck(HttpServletRequest req,HttpServletResponse resp,
+    		 CheckOther checkOther){
+    	checkOtherService.getOtherCheckExcel(checkOther, req, resp);
+    	return super.returnSuccessResult(null);
+    }
+    
 }

+ 27 - 15
VisualInspection_server/src/main/java/com/xintong/visualinspection/mapper/master/StatisticsMapper.xml

@@ -86,22 +86,34 @@
 			AND t.ORGANID =#{dept_id}			
 		</if>
 		  ) y LEFT JOIN
-		
 		(
-		
-		SELECT  u.checked_person AS user_id , u.checked_dept AS dept_id,count(1) AS checked_num,sum(u.score) AS score  FROM (
-			SELECT IFNULL(t.checked_person,ct.checked_person) AS checked_person , IFNULL(t.checked_dept,ct.checked_dept) AS checked_dept  ,
-			IFNULL(t.check_item_score,0) AS score  FROM check_task ct 
-			LEFT JOIN check_score t ON  ct.id = t.task_id
-			WHERE 1=1 and ct.check_status!=22 and ct.id not in <include refid="taskexclouddeleteUser"/>
-			<if test="start_date!=null and end_date != null">
-		        AND	 ct.start_time &gt;= #{start_date} AND ct.end_time &lt; #{end_date}
-			</if>
-			<if test="dept_id!=null">
-				AND ct.checked_dept =#{dept_id}			
-			</if>
-		 ) 
-		u  GROUP  BY checked_person) x
+			SELECT m.* , t.checked_num FROM  
+			(
+				SELECT COUNT(1) AS checked_num , t.checked_person AS user_id FROM check_task t 
+			    	WHERE 1=1 and t.check_status!=22  and t.id not in <include refid="taskexclouddeleteUser"/>
+						<if test="start_date!=null and end_date != null">
+					        AND	 t.start_time &gt;= #{start_date} AND t.end_time &lt; #{end_date} 
+						</if>
+						<if test="dept_id!=null">
+							AND t.checked_dept =#{dept_id}			
+						</if>
+			    	GROUP BY t.checked_person
+			) t LEFT JOIN (
+				SELECT  u.checked_person AS user_id , u.checked_dept AS dept_id , sum(u.score) AS score  FROM (
+					SELECT IFNULL(t.checked_person, ct.checked_person ) AS checked_person , IFNULL(t.checked_dept,ct.checked_dept) AS checked_dept  ,
+					IFNULL(t.check_item_score,0) AS score  FROM check_task ct 
+					LEFT JOIN check_score t ON  ct.id = t.task_id
+					WHERE 1=1 and ct.check_status!=22 and ct.id not in <include refid="taskexclouddeleteUser"/>
+					<if test="start_date!=null and end_date != null">
+				        AND	 ct.start_time &gt;= #{start_date} AND ct.end_time &lt; #{end_date}
+					</if>
+					<if test="dept_id!=null">
+						AND ct.checked_dept =#{dept_id}			
+					</if>
+				 ) 
+				u  GROUP  BY checked_person
+			 ) m ON t.user_id = m.user_id
+		) x
 		ON y.user_id = x.user_id AND y.dept_id =  x.dept_id
 		
 		LEFT JOIN (SELECT user_id,dept_id,COUNT(1) check_a_num,SUM(check_score) check_a_score FROM other_check WHERE check_type = 1 

+ 11 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/service/CheckOtherService.java

@@ -2,7 +2,11 @@ package com.xintong.visualinspection.service;
 
 import java.util.List;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import com.xintong.visualinspection.bean.CheckOther;
+import com.xintong.visualinspection.bean.StatisticsBean;
 
 public interface CheckOtherService {
 
@@ -20,6 +24,13 @@ public interface CheckOtherService {
 	 * @return
 	 */
 	List<CheckOther> getCheckByDeptId(CheckOther checkOther);
+	
+	/**
+	 * 下载信息Excel
+	 */
+	void getOtherCheckExcel(CheckOther checkOther,HttpServletRequest req,HttpServletResponse resp);
+	
+	
 	/**根据id获取稽查记录
 	 * @param id
 	 */

+ 97 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/service/impl/CheckOtherServiceImpl.java

@@ -1,15 +1,33 @@
 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.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
+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;
 
+import com.alibaba.druid.util.Utils;
 import com.xintong.visualinspection.bean.CheckOther;
 import com.xintong.visualinspection.dao.master.CheckOtherDao;
 import com.xintong.visualinspection.service.BaseService;
 import com.xintong.visualinspection.service.CheckOtherService;
+import com.xintong.visualinspection.util.CodeUtil;
+import com.xintong.visualinspection.util.DateUtil;
 
 /**
  * 文件名:CheckOtherServiceImpl
@@ -31,6 +49,84 @@ public class CheckOtherServiceImpl  extends BaseService implements CheckOtherSer
 		List<CheckOther> checkOtherList = checkOtherDao.getCheckByDeptId(checkOther);
 		return checkOtherList;
 	}
+	
+	@Override
+	public void getOtherCheckExcel(CheckOther checkOther, HttpServletRequest req, HttpServletResponse resp) {
+		List<CheckOther> checkOtherList = getCheckByDeptId(checkOther);
+		Long id = 1L ;
+    	for(CheckOther co : checkOtherList){
+    		co.setId(id++);
+    		if(co.getWrecker_check_type()!=null){
+    			co.setWrecker_check_type_name(CodeUtil.getCodeNameByFlagAndValue("wrecker_group_check_type", co.getWrecker_check_type()+""));
+    		}
+    		if(co.getSpecial_check_type()!=null){
+    			co.setSpecial_check_type_name(CodeUtil.getCodeNameByFlagAndValue("special_check_type", co.getSpecial_check_type()+""));
+    		}
+    		co.setCheck_time_name(DateUtil.DateFormatStr(co.getCheck_time()));
+    		if( co.getUsername() == null || "".equals(co.getUsername()) ){
+    			co.setUsername("站部");
+    		}
+    	}
+    	Map<String, Object> map = new HashMap<String, Object>();
+		map.put("list", checkOtherList);
+		if(checkOther.getCheck_type() == 1){
+			exportExcel("第三方暗访稽查" , "third_check", map, resp);
+		}else if(checkOther.getCheck_type() == 2){
+			exportExcel("特情稽查" , "special_check", map, resp);
+		}else if(checkOther.getCheck_type() == 3){
+			exportExcel("现场稽查" , "duty_check", map, resp);
+		}else if(checkOther.getCheck_type() == 4){
+			exportExcel("数据平台应用稽查" , "data_platform", map, resp);
+		}else if(checkOther.getCheck_type() == 5){
+			exportExcel("清排障稽查" , "solve_traffic", map, resp);
+		}
+	}
+	
+	private void exportExcel(String fileName, String excelTemplateName, Map<String, Object> map,
+			HttpServletResponse resp) {
+		String path = "./" + fileName + ".xls";
+		try (InputStream is = this.getClass().getResourceAsStream("/" + excelTemplateName + ".xls")) {
+			try (OutputStream os = new FileOutputStream(path)) {
+				Context context = new Context();
+				// context.putVar("list", map.get("list"));
+				// context.putVar("totalMan", map.get("totalMan"));
+				for (String key : map.keySet()) {
+					context.putVar(key, map.get(key));
+				}
+				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();
+			// 删除生成的临时文件
+			if (file.exists()) {
+				file.delete();
+			}
+
+		} catch (Exception e) {
+			logger.error(e.toString());
+		}
+	}
+	
+	
 	@Override
 	public void delete(Long id) {
 		checkOtherDao.delete(id);
@@ -44,4 +140,5 @@ public class CheckOtherServiceImpl  extends BaseService implements CheckOtherSer
 	public void update(CheckOther checkOther) {
 		checkOtherDao.update(checkOther);
 	}
+	
 }

+ 20 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/util/DateUtil.java

@@ -30,4 +30,24 @@ public class DateUtil {
 		}
 		return null;
 	}
+	
+	public static String DateFormatStr(Date date , String format){
+		SimpleDateFormat sdf = new SimpleDateFormat(format);
+		try{
+			return sdf.format(date);
+		}catch(Exception e){
+			e.printStackTrace();
+		}
+		return "" ;
+	}
+	
+	public static String DateFormatStr(Date date){
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		try{
+			return sdf.format(date);
+		}catch(Exception e){
+			e.printStackTrace();
+		}
+		return "" ;
+	}
 }

BIN=BIN
VisualInspection_server/src/main/resources/data_platform.xls


BIN=BIN
VisualInspection_server/src/main/resources/duty_check.xls


BIN=BIN
VisualInspection_server/src/main/resources/solve_traffic.xls


BIN=BIN
VisualInspection_server/src/main/resources/special_check.xls


BIN=BIN
VisualInspection_server/src/main/resources/third_check.xls