Browse Source

Export excel

chenrj-PC\chenrj 9 năm trước cách đây
mục cha
commit
841743c716

+ 11 - 6
VisualInspection/js/statistics/assess_ranking.js

@@ -104,27 +104,32 @@ function getItemScore(obj, check_item_name){
     return 0 ;
 }
 
+/**
+ * 过滤除数为0和保留二位小数时出现的0.00
+ * @param {*} value 
+ * @param {*} default_display_value 
+ */
 function filterByZeroHandle(value , default_display_value){
-        if(isNaN(value)|| value=='0.00'){
+        if(isNaN(value)){
             return default_display_value ;
         }else{
+            if((value+'').endsWith('.00')){
+                return value.substring(0,value.length-3);
+            }
             return value ;
         }
-       
 }
 
 function exportExcel(){
     var start_date = $("#start-time").val();
     var end_date = $("#end-time").val();
     var dept_id = $("#fsList").val();
-    if(start_date==null||start_date==''||start_date==undefined||end_date==null||end_date==''||end_date==undefined){
+    if( start_date=='' || end_date==''){
         tip("请选择起止日期");
         return ;
     }else{
         start_date += " 00:00:00";
         end_date += " 00:00:00";
     }
-    window.open("http://localhost:8089/file/employee/order?dept_id="+dept_id+"&start_date="+start_date+"&end_date="+end_date);
-    //window.location.href="http://localhost:8089/file/employee/order?id="+dept_id+"&start="+start_date+"&end="+end_date;
+    window.open( getserveraddr() + "/file/employee/order?dept_id="+dept_id+"&start_date="+start_date+"&end_date="+end_date);
 }
-

+ 32 - 6
VisualInspection/js/statistics/assess_situation.js

@@ -85,8 +85,8 @@ function gethtml(data,i){
                         +"</td><td>"+(data.people_num-(data.score_fifteen+data.score_fifty+data.score_over_fifty))
                         +"</td><td>"+data.score_fifteen+"</td><td>"+data.score_fifty+"</td><td>"
                         +data.score_over_fifty+"</td><td>"+data.all_check_score+"</td><td>"
-                        +filterByZeroHandle((data.all_check_score/data.checked_num).toFixed(2),'0')+"</td><td>"
-                        +filterByZeroHandle((1000-((data.all_check_score/data.checked_num).toFixed(2))),'1000')+"</td>";
+                        +filterByZeroHandle(filterJudge(data.all_check_score,data.checked_num),'0')+"</td><td>"
+                        +filterByZeroHandle((1000-filterJudge(data.all_check_score,data.checked_num)),'1000')+"</td>";
                 strTbody += "</tr>";
        }else{
                 num ++;
@@ -97,8 +97,8 @@ function gethtml(data,i){
                         +"</td><td>"+(data.people_num-(data.score_fifteen+data.score_fifty+data.score_over_fifty))
                         +"</td><td>"+data.score_fifteen+"</td><td>"+data.score_fifty+"</td><td>"
                         +data.score_over_fifty+"</td><td>"+data.all_check_score+"</td><td>"
-                        +filterByZeroHandle((data.all_check_score/data.checked_num).toFixed(2),'0')+"</td><td>"
-                        +filterByZeroHandle((1000-((data.all_check_score/data.checked_num).toFixed(2))),'1000')+"</td>";
+                        +filterByZeroHandle(filterJudge(data.all_check_score,data.checked_num),'0')+"</td><td>"
+                        +filterByZeroHandle((1000-filterJudge(data.all_check_score,data.checked_num)),'1000')+"</td>";
                 strTbody+="</tr>";
             
       }
@@ -115,16 +115,42 @@ function filter(value , default_display_value){
         }
 }
 
+/**
+ * 过滤除数为0和保留二位小数时出现的0.00
+ * @param {*} value 
+ * @param {*} default_display_value 
+ */
 function filterByZeroHandle(value , default_display_value){
-        if(isNaN(value)|| value=='0.00'){
+        if(isNaN(value)){
             return default_display_value ;
         }else{
+            if((value+'').endsWith('.00')){
+                return value.substring(0,value.length-3);
+            }
             return value ;
         }
-       
 }
 
+function filterJudge(num1,num2){
+        if(num2==0){
+            return 0;
+        }else{
+            return (num1/num2).toFixed(2);
+        }
+}
 
+function exportExcel(){
+    var start_date = $("#start-time").val();
+    var end_date = $("#end-time").val();
+    if( start_date=='' || end_date==''){
+        tip("请选择起止日期");
+        return ;
+    }else{
+        start_date += " 00:00:00";
+        end_date += " 00:00:00";
+    }
+    window.open( getserveraddr() + "/file/score/info?start_date="+start_date+"&end_date="+end_date);
+}
 
 
 

+ 18 - 4
VisualInspection/js/statistics/assess_type.js

@@ -96,7 +96,7 @@ function gethtml(data,i,avg){
                    +"</td> <td>"+getItemScore(data, '仪容仪表')+"</td><td>"+getItemScore(data, '表情')
                    +"</td><td>"+getItemScore(data, '收费动作')+"</td><td>"+getItemScore(data, '文明用语')
                    +"</td><td>"+getItemScore(data, '工作纪律')+"</td><td>"+data.all_check_score+"</td><td>"
-                   +filterByZeroHandle((data.all_check_score/data.checked_num).toFixed(2),'0')
+                   +filterByZeroHandle(filterJudge(data.all_check_score,data.checked_num),'0')
                    +"</td><td rowspan="+rowspan+">"+avg+"</td>";
         strTbody += "</tr>";
     }else{
@@ -109,7 +109,7 @@ function gethtml(data,i,avg){
                   +"</td><td>"+getItemScore(data, '表情')+"</td><td>"+getItemScore(data, '收费动作')
                   +"</td><td>"+getItemScore(data, '文明用语')+"</td><td>"+getItemScore(data, '工作纪律')
                   +"</td><td>"+data.all_check_score+"</td><td>"
-                  +filterByZeroHandle((data.all_check_score/data.checked_num).toFixed(2),'0')+"</td>";
+                  +filterByZeroHandle(filterJudge(data.all_check_score,data.checked_num),'0')+"</td>";
         strTbody += "</tr>";
           
     }
@@ -198,9 +198,12 @@ function getItemScore(obj, check_item_name){
  * @param {*} default_display_value 
  */
 function filterByZeroHandle(value , default_display_value){
-        if(isNaN(value) || value=='0.00'){
+        if(isNaN(value)){
             return default_display_value ;
         }else{
+            if((value+'').endsWith('.00')){
+                return value.substring(0,value.length-3);
+            }
             return value ;
         }
 }
@@ -213,7 +216,18 @@ function filterJudge(num1,num2){
         }
 }
 
-
+function exportExcel(){
+    var start_date = $("#start-time").val();
+    var end_date = $("#end-time").val();
+    if( start_date=='' || end_date==''){
+        tip("请选择起止日期");
+        return ;
+    }else{
+        start_date += " 00:00:00";
+        end_date += " 00:00:00";
+    }
+    window.open( getserveraddr() + "/file/score/item/info?start_date="+start_date+"&end_date="+end_date);
+}
 
 
 

+ 1 - 1
VisualInspection/view/statistics/assess_situation.html

@@ -15,7 +15,7 @@
                     <button class="btn btn-primary " type="button" onclick="querySituationClick()">查询</button>
                 </div>
                 <div class="col-sm-6">
-                    <button class="btn btn-primary " type="button" >导出Excel</button>
+                    <button class="btn btn-primary " type="button"  onclick="exportExcel()" >导出Excel</button>
                 </div>
             </div>
         </form>

+ 1 - 1
VisualInspection/view/statistics/assess_type.html

@@ -15,7 +15,7 @@
                     <button class="btn btn-primary " type="button" onclick="queryTypeClick()">查询</button>
                 </div>
                 <div class="col-sm-6">
-                    <button class="btn btn-primary " type="button" >导出Excel</button>
+                    <button class="btn btn-primary " type="button" onclick="exportExcel()" >导出Excel</button>
                 </div>
             </div>
         </form>

+ 14 - 3
VisualInspection_server/src/main/java/com/xintong/visualinspection/bean/StatisticsBean.java

@@ -39,11 +39,11 @@ public class StatisticsBean {
     
     private Integer item_id ;
 
-    private Integer checked_num;
+    private int checked_num;
     
-    private Integer checked_people_num ;
+    private int checked_people_num ;
     
-    private Integer people_num;
+    private int people_num;
     
     private int score_fifteen;
     
@@ -53,7 +53,18 @@ public class StatisticsBean {
     
     private int all_check_score ;
     
+    // 满分
+    private int check_no_score ;
+    
+    // 平均得分
+    private String score_avg ;
+    
+    // 平均人均扣分
+    private float check_score_avg;
+    
     private List<String> checked_socre_name = new ArrayList<>() ;
     
     private List<Integer> checked_score = new ArrayList<>() ;
+    
+    private List<Integer> seq_checked_score = new ArrayList<>() ;
 }

+ 3 - 3
VisualInspection_server/src/main/java/com/xintong/visualinspection/bean/StatisticsBo.java

@@ -15,7 +15,7 @@ public class StatisticsBo {
     //编号
     private Integer id;
  
-    private Integer checked_num ;
+    private int checked_num = 0 ;
     
     private int check_all_score =0 ; 
     
@@ -25,8 +25,8 @@ public class StatisticsBo {
     
     private User user;
     
-    //private Integer[] emp_assess;
+    private List<Integer> emp_item_score = new ArrayList<>();
     
-    private int check_score_avg;
+    private String check_score_avg;
     
 }

+ 30 - 7
VisualInspection_server/src/main/java/com/xintong/visualinspection/controller/FileExcelController.java

@@ -37,7 +37,8 @@ public class FileExcelController extends BaseController {
      * @since  1.0.0
      */
     @RequestMapping(value = "/employee/order",method=RequestMethod.GET)
-    public String getEmployeeOrder(HttpServletRequest req,HttpServletResponse resp,@RequestParam Long dept_id,@RequestParam String start_date,@RequestParam String end_date){
+    public String getEmployeeOrder(HttpServletRequest req,HttpServletResponse resp,@RequestParam Long dept_id,
+    		@RequestParam String start_date,@RequestParam String end_date){
     	StatisticsBean obj = new StatisticsBean();
     	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" );
     	try {
@@ -59,17 +60,39 @@ public class FileExcelController extends BaseController {
      * @return
      */
     @RequestMapping(value = "/score/info",method=RequestMethod.GET)
-    public String getScoreInfo(@RequestBody StatisticsBean obj){
-    	List<StatisticsBean> lists=  statisticsService.getFeeStationCheckedScore(obj);
-    	return super.returnSuccessResult(lists);
+    public String getScoreInfo(HttpServletRequest req,HttpServletResponse resp,
+    		@RequestParam String start_date,@RequestParam String end_date){
+    	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" );
+    	StatisticsBean obj = new StatisticsBean();
+    	try {
+			Date start = sdf.parse(start_date);
+			Date end = sdf.parse(end_date);
+			obj.setStart_date(start);
+			obj.setEnd_date(end);
+		} catch (ParseException e) {
+			e.printStackTrace();
+		}
+    	statisticsService.getFeeStationCheckedScore(obj, req, resp);
+    	return super.returnSuccessResult(null);
     }
     
     /**
      * 温馨服务检查情况统计表
      */
     @RequestMapping(value = "/score/item/info",method=RequestMethod.GET)
-    public String getScoreItemInfo(@RequestBody StatisticsBean obj){
-    	List<StatisticsBean> lists=  statisticsService.getFeeStationCheckItemScore(obj);
-    	return super.returnSuccessResult(lists);
+    public String getScoreItemInfo(HttpServletRequest req,HttpServletResponse resp,
+    		@RequestParam String start_date,@RequestParam String end_date){
+    	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" );
+    	StatisticsBean obj = new StatisticsBean();
+    	try {
+			Date start = sdf.parse(start_date);
+			Date end = sdf.parse(end_date);
+			obj.setStart_date(start);
+			obj.setEnd_date(end);
+		} catch (ParseException e) {
+			e.printStackTrace();
+		}
+    	statisticsService.getFeeStationCheckItemScore(obj, req, resp);
+    	return super.returnSuccessResult(null);
     }
 }

+ 83 - 43
VisualInspection_server/src/main/java/com/xintong/visualinspection/service/impl/StatisticsServiceImpl.java

@@ -66,6 +66,7 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
 			user.setOrganid(obj.getDept_id().intValue());
 		List<User> listUserts = userInfoDao.getUsers(user);
 		for (User u : listUserts) {
+			u.setPassword(null);
 			if (u.getFee_station_name() != null) {
 				StatisticsBo tmp = new StatisticsBo();
 				tmp.setUser(u);
@@ -73,16 +74,6 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
 			}
 		}
 
-		// for(User user:CacheUtil.userMap.values()){
-		// if(user.getPositionid() ==1){
-		// if(organId ==null || user.getOrganid()+0L == organId+0L ){
-		// StatisticsBo tmp = new StatisticsBo();
-		// tmp.setUser(user);
-		// statisticBoMap.put(user.getId()+0L,tmp);
-		// }
-		// }
-		// }
-
 		for (StatisticsBean statisticsBean : list) {
 			if (statisticBoMap.containsKey(statisticsBean.getUser_id())) {
 				StatisticsBo tmp = statisticBoMap.get(statisticsBean.getUser_id());
@@ -106,10 +97,12 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
 		lists.sort(new Comparator<StatisticsBo>() {
 			@Override
 			public int compare(StatisticsBo o1, StatisticsBo o2) {
-				if (o1.getCheck_all_score() >= o2.getCheck_all_score()) {
+				if (o1.getCheck_all_score() > o2.getCheck_all_score()) {
 					return 1;
-				} else {
-					return -1;
+				} else if(o1.getCheck_all_score()< o2.getCheck_all_score()){
+					return -1 ;
+				}else {
+					return 0;
 				}
 			}
 		});
@@ -186,32 +179,87 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
 
 	}
 
+	private Integer getItemScore(StatisticsBo obj ,String name){
+		List<String> names = obj.getChecked_socre_name();
+		List<Integer> scores = obj.getChecked_score();
+		for(int i=0;i<names.size();i++ ){
+			if( names.get(i).indexOf(name)>-1){
+				return scores.get(i);
+			}
+		}
+		return 0 ;
+	}
+	
+	private Integer getItemScore2(StatisticsBean obj ,String name){
+		List<String> names = obj.getChecked_socre_name();
+		List<Integer> scores = obj.getChecked_score();
+		for(int i=0;i<names.size();i++ ){
+			if( names.get(i).indexOf(name)>-1){
+				return scores.get(i);
+			}
+		}
+		return 0 ;
+	}
+	
 	@Override
 	public void getEmployeeCheckedInfo(StatisticsBean obj, HttpServletRequest req, HttpServletResponse resp) {
 		// 检索数据
 		List<StatisticsBo> listStatistic = getEmployeeCheckedInfo(obj);
 		// 处理数据
-		//Integer[] emp_assess = new Integer[listStatistic.size()];
-		for (int i = 0; i < listStatistic.size(); i++) {
-			StatisticsBo st = new StatisticsBo();
-			st = listStatistic.get(i);
-			try {
-				st.setCheck_score_avg(listStatistic.get(i).getCheck_all_score() 
-						/ listStatistic.get(i).getChecked_num());
-			} catch (Exception e) {
-				e.printStackTrace();
-			}
-			/*List<Integer> checked_score_list = st.getChecked_score();
-			for (int j = 0; j < checked_score_list.size(); i++) {
-				emp_assess[j] = checked_score_list.get(i);
-			}*/
+		for(int i=0;i<listStatistic.size();i++){
+			StatisticsBo st = listStatistic.get(i) ;
+			// id值设置
+			st.setId(i+1);  
+			//平均值
+			st.setCheck_score_avg((st.getChecked_num()!=0)?String.format("%.2f", st.getCheck_all_score()/(st.getChecked_num()+0.0)):"0.00");
+			st.getEmp_item_score().add(getItemScore(st,"环境卫生"));
+			st.getEmp_item_score().add(getItemScore(st,"仪容仪表"));
+			st.getEmp_item_score().add(getItemScore(st,"表情"));
+			st.getEmp_item_score().add(getItemScore(st,"动作"));
+			st.getEmp_item_score().add(getItemScore(st,"文明用语"));
+			st.getEmp_item_score().add(getItemScore(st,"工作纪律"));
+		}
+		exportExcel("温馨服务考核情况反馈表","employee_order",listStatistic,resp);
+	}
+
+	@Override
+	public void getFeeStationCheckedScore(StatisticsBean obj, HttpServletRequest req, HttpServletResponse resp) {
+		List<StatisticsBean> list = getFeeStationCheckedScore(obj);
+		for(StatisticsBean st :list){
+			st.setCheck_no_score(st.getPeople_num() - st.getScore_fifteen() -st.getScore_fifteen()-st.getScore_over_fifty() );
+			st.setCheck_score_avg((st.getChecked_num()!=0)?st.getAll_check_score()/(st.getChecked_num()+0.0f):0.00f );
+			st.setScore_avg(String.format("%.2f", 1000.0 - st.getCheck_score_avg()));
+		}
+		// 处理数据
+		exportExcel("温馨服务检查千分考核扣分情况汇总表","checked_info",list,resp);
+	}
+
+	@Override
+	public void getFeeStationCheckItemScore(StatisticsBean obj, HttpServletRequest req, HttpServletResponse resp) {
+		List<StatisticsBean> list = getFeeStationCheckItemScore(obj);
+		// 处理数据
+		for(int i=0;i<list.size();i++){
+			StatisticsBean st = list.get(i) ;
+			// id值设置   seq_checked_score
+			//平均值
+			st.setCheck_score_avg((st.getChecked_num()!=0)? st.getAll_check_score()/(st.getChecked_num()+0.0f):0.00f);
+			st.getSeq_checked_score().add(getItemScore2(st,"环境卫生"));
+			st.getSeq_checked_score().add(getItemScore2(st,"仪容仪表"));
+			st.getSeq_checked_score().add(getItemScore2(st,"表情"));
+			st.getSeq_checked_score().add(getItemScore2(st,"动作"));
+			st.getSeq_checked_score().add(getItemScore2(st,"文明用语"));
+			st.getSeq_checked_score().add(getItemScore2(st,"工作纪律"));
 		}
+		exportExcel("温馨服务检查情况统计表","checked_item_info",list,resp);
+	}
 
-		String path = "D:/file20170606.xls";
-		try (InputStream is = this.getClass().getResourceAsStream("/employee_order.xls")) {
+	
+	private void exportExcel(String fileName , String excelTemplateName,List<?> list,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", listStatistic);
+				context.putVar("list", list);
 				JxlsHelper.getInstance().processTemplate(is, os, context);
 			}
 			Thread.sleep(1000);
@@ -235,21 +283,13 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
 			toClient.write(buffer);
 			toClient.flush();
 			toClient.close();
+			// 删除生成的临时文件
+			if(file.exists()){
+				file.delete();
+			}
+			
 		} 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/checked_info.xls


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


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