|  | @@ -1,18 +1,28 @@
 | 
	
		
			
				|  |  |  package com.ym.mec.web.controller;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import com.ym.mec.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.Employee;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.OperatingReport;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.service.InspectionItemPlanConclusionService;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.controller.BaseController;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.entity.HttpResponseResult;
 | 
	
		
			
				|  |  | +import com.ym.mec.common.page.PageInfo;
 | 
	
		
			
				|  |  | +import com.ym.mec.util.date.DateUtil;
 | 
	
		
			
				|  |  | +import com.ym.mec.util.excel.POIUtil;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.Api;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiImplicitParam;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiImplicitParams;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiOperation;
 | 
	
		
			
				|  |  | +import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | +import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.security.access.prepost.PreAuthorize;
 | 
	
		
			
				|  |  |  import org.springframework.web.bind.annotation.*;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import java.util.List;
 | 
	
		
			
				|  |  | -import java.util.Map;
 | 
	
		
			
				|  |  | +import javax.servlet.http.HttpServletResponse;
 | 
	
		
			
				|  |  | +import java.io.IOException;
 | 
	
		
			
				|  |  | +import java.io.OutputStream;
 | 
	
		
			
				|  |  | +import java.util.*;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @Api(tags = "巡查结果")
 | 
	
		
			
				|  |  |  @RequestMapping("inspectionItemPlanConclusion")
 | 
	
	
		
			
				|  | @@ -33,7 +43,42 @@ public class InspectionItemPlanConclusionController extends BaseController {
 | 
	
		
			
				|  |  |      @GetMapping("/exportPlanConclusion")
 | 
	
		
			
				|  |  |      @PreAuthorize("@pcs.hasPermissions('inspectionItemPlanConclusion/exportPlanConclusion')")
 | 
	
		
			
				|  |  |      @ApiImplicitParams({@ApiImplicitParam(name = "planId", value = "日程id", required = true, dataType = "int")})
 | 
	
		
			
				|  |  | -    public HttpResponseResult<List<Map<String, String>>> exportPlanConclusion(Long planId) {
 | 
	
		
			
				|  |  | -        return succeed(InspectionItemPlanConclusionService.getPlanConclusion(planId));
 | 
	
		
			
				|  |  | +    public void exportPlanConclusion(Long planId, HttpServletResponse response) throws Exception {
 | 
	
		
			
				|  |  | +        List<Map<String, String>> conclusions = InspectionItemPlanConclusionService.getPlanConclusion(planId);
 | 
	
		
			
				|  |  | +        if (conclusions.size() <= 0) {
 | 
	
		
			
				|  |  | +            response.setStatus(200);
 | 
	
		
			
				|  |  | +            response.setContentType("Content-Type: application/json;charset=UTF-8");
 | 
	
		
			
				|  |  | +            response.getOutputStream().write("{\"data\": null, \"code\": 500, \"status\": false, \"msg\": \"没有可导出的记录\"}".getBytes());
 | 
	
		
			
				|  |  | +            response.flushBuffer();
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        OutputStream outputStream = response.getOutputStream();
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            List<String> bodyList = new ArrayList<>();
 | 
	
		
			
				|  |  | +            conclusions.get(0).forEach((key,vak)->{
 | 
	
		
			
				|  |  | +                bodyList.add(key);
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +            String[] body = bodyList.toArray(new String[bodyList.size()]);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            String[] header = {"老师","老师是否提前准备板书(本课内容、作业)","老师是否佩戴工牌","老师是否仪容仪表整洁","老师是否携带乐器","老师是否携带教学资料、设备","老师是否合理安排学员座位","乐器箱包、书包是否摆放整齐","课堂纪律是否保持良好","老师是否全程站立教学","老师是否全程使用节拍器或教学音频","是否发现学员需要更换新乐器","老师是否将上课照片/视频发送到声部群","老师是否保持教室环境卫生","老师是否关好所有电源、门窗","老师是否有序组织学员放学"};
 | 
	
		
			
				|  |  | +            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, conclusions);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            response.setContentType("application/octet-stream");
 | 
	
		
			
				|  |  | +            response.setHeader("Content-Disposition", "attachment;filename=cooperationOrgan-" + DateUtil.getDate(new Date()) + ".xls");
 | 
	
		
			
				|  |  | +            response.flushBuffer();
 | 
	
		
			
				|  |  | +            outputStream = response.getOutputStream();
 | 
	
		
			
				|  |  | +            workbook.write(outputStream);
 | 
	
		
			
				|  |  | +            outputStream.flush();
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            e.printStackTrace();
 | 
	
		
			
				|  |  | +        } finally {
 | 
	
		
			
				|  |  | +            if (outputStream != null) {
 | 
	
		
			
				|  |  | +                try {
 | 
	
		
			
				|  |  | +                    outputStream.close();
 | 
	
		
			
				|  |  | +                } catch (IOException e) {
 | 
	
		
			
				|  |  | +                    e.printStackTrace();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |