Browse Source

案件专班报表

jz.kai 2 years ago
parent
commit
97b9e7c667

+ 1 - 1
common/src/main/java/com/jpsoft/excellent/modules/base/dao/IncidentDAO.java

@@ -20,5 +20,5 @@ public interface IncidentDAO {
 	List<Incident> search(Map<String,Object> searchParams,List<Sort> sortList);
 	List<IncidentStepOrgDTO> searchStepOrg(Map<String,Object> searchParams, List<Sort> sortList);
 	List<Incident> findTodayListByWarnTime(String startTime, String endTime);
-	int getCount(String areaId, String isFinished, Boolean isTimeout, String dateStart, String dateEnd);
+	int getCount(String areaId, String specialClassId, String isFinished, Boolean isTimeout, String dateStart, String dateEnd);
 }

+ 1 - 1
common/src/main/java/com/jpsoft/excellent/modules/base/service/IncidentService.java

@@ -18,5 +18,5 @@ public interface IncidentService {
 	Page<Incident> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
 	Page<IncidentStepOrgDTO> pageSearchStepOrg(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
 	List<Incident> findTodayListByWarnTime(String startTime, String endTime);
-	int getCount(String areaId, String isFinished, Boolean isTimeout, String dateStart, String dateEnd);
+	int getCount(String areaId, String specialClassId, String isFinished, Boolean isTimeout, String dateStart, String dateEnd);
 }

+ 2 - 2
common/src/main/java/com/jpsoft/excellent/modules/base/service/impl/IncidentServiceImpl.java

@@ -86,7 +86,7 @@ public class IncidentServiceImpl implements IncidentService {
 	}
 
 	@Override
-	public int getCount(String areaId, String isFinished, Boolean isTimeout, String dateStart, String dateEnd) {
-		return incidentDAO.getCount(areaId, isFinished, isTimeout, dateStart, dateEnd);
+	public int getCount(String areaId, String specialClassId, String isFinished, Boolean isTimeout, String dateStart, String dateEnd) {
+		return incidentDAO.getCount(areaId, specialClassId, isFinished, isTimeout, dateStart, dateEnd);
 	}
 }

+ 4 - 1
common/src/main/resources/mapper/base/Incident.xml

@@ -289,7 +289,10 @@
 		SELECT COUNT(id_) FROM base_incident
 		WHERE del_flag = 0
 		<if test="areaId != null">
-			AND area_id = #{areaId}
+			AND area_id LIKE #{areaId}
+		</if>
+		<if test="specialClassId != null">
+			AND special_class_id LIKE #{specialClassId}
 		</if>
 		<if test="isFinished != null">
 			AND is_finished = #{isFinished}

+ 145 - 4
web/src/main/java/com/jpsoft/excellent/modules/base/controller/ReportsController.java

@@ -164,10 +164,151 @@ public class ReportsController {
 
         List<DataDictionary> dataDictionaryList = dataDictionaryService.findByCatalogName("区域");
         for(DataDictionary dataDictionary : dataDictionaryList){
-            Integer total = incidentService.getCount(dataDictionary.getValue(),null,null,sdf.format(reportDate[0]),sdf.format(calendar.getTime()));
-            Integer noTimeout = incidentService.getCount(dataDictionary.getValue(),"0",false,sdf.format(reportDate[0]),sdf.format(calendar.getTime()));
-            Integer timeout = incidentService.getCount(dataDictionary.getValue(),"0",true,sdf.format(reportDate[0]),sdf.format(calendar.getTime()));
-            Integer unfinished = incidentService.getCount(dataDictionary.getValue(),"1",null,sdf.format(reportDate[0]),sdf.format(calendar.getTime()));
+            Integer total = incidentService.getCount("%"+dataDictionary.getValue()+"%",null,null,null,sdf.format(reportDate[0]),sdf.format(calendar.getTime()));
+            Integer noTimeout = incidentService.getCount("%"+dataDictionary.getValue()+"%",null,"0",false,sdf.format(reportDate[0]),sdf.format(calendar.getTime()));
+            Integer timeout = incidentService.getCount("%"+dataDictionary.getValue()+"%",null,"0",true,sdf.format(reportDate[0]),sdf.format(calendar.getTime()));
+            Integer unfinished = incidentService.getCount("%"+dataDictionary.getValue()+"%",null,"1",null,sdf.format(reportDate[0]),sdf.format(calendar.getTime()));
+
+            Map<String,Object> map = new HashMap<>();
+            map.put("areaName",dataDictionary.getName());
+            map.put("total",total);
+            map.put("noTimeout",noTimeout);
+            map.put("timeout",timeout);
+            map.put("unfinished",unfinished);
+
+            mapList.add(map);
+        }
+
+        return mapList;
+    }
+
+    @ApiOperation(value="案件专班报表")
+    @RequestMapping(value = "reportClass",method = RequestMethod.POST)
+    public MessageResult reportClass(Date[] reportDate){
+        MessageResult msgResult = new MessageResult<>();
+        List<Map> mapList = new ArrayList<>();
+
+        try{
+            mapList = reportClassData(reportDate);
+
+            msgResult.setResult(true);
+            msgResult.setData(mapList);
+        }
+        catch(Exception ex){
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="导出案件专班报表")
+    @RequestMapping(value = "reportClassXls",method = RequestMethod.POST)
+    public String reportClassXls(Date[] reportDate){
+        String downloadUrl = "";
+
+        //新建文档
+        Workbook workbook = new HSSFWorkbook();
+        Sheet sheet = workbook.createSheet();
+
+        //单元格样式
+        sheet.setDefaultColumnWidth(15);
+        sheet.setDefaultRowHeight((short) 400);
+
+        Font fontTitle = workbook.createFont();
+        fontTitle.setFontName("宋体");
+        fontTitle.setFontHeightInPoints((short) 11);
+        fontTitle.setBold(true);
+
+        CellStyle cellStyleTitle = workbook.createCellStyle();
+        cellStyleTitle.setBorderTop(BorderStyle.THIN);
+        cellStyleTitle.setBorderBottom(BorderStyle.THIN);
+        cellStyleTitle.setBorderLeft(BorderStyle.THIN);
+        cellStyleTitle.setBorderRight(BorderStyle.THIN);
+        cellStyleTitle.setVerticalAlignment(VerticalAlignment.CENTER);
+        cellStyleTitle.setAlignment(HorizontalAlignment.CENTER);
+        cellStyleTitle.setFont(fontTitle);
+
+        Font fontContent = workbook.createFont();
+        fontContent.setFontName("宋体");
+        fontContent.setFontHeightInPoints((short) 11);
+
+        CellStyle cellStyleContent = workbook.createCellStyle();
+        cellStyleContent.setBorderTop(BorderStyle.THIN);
+        cellStyleContent.setBorderBottom(BorderStyle.THIN);
+        cellStyleContent.setBorderLeft(BorderStyle.THIN);
+        cellStyleContent.setBorderRight(BorderStyle.THIN);
+        cellStyleContent.setVerticalAlignment(VerticalAlignment.CENTER);
+        cellStyleContent.setAlignment(HorizontalAlignment.CENTER);
+        cellStyleContent.setFont(fontContent);
+
+        //表头
+        Row rowTitle = sheet.createRow(0);
+        String[] titles = new String[]{"所属专班","总案件数","按时办结数","超期办结数","未办结数"};
+        for (int i=0;i<titles.length;i++) {
+            Cell cell = rowTitle.createCell(i);
+            cell.setCellValue(titles[i]);
+            cell.setCellStyle(cellStyleTitle);
+        }
+
+        //写入数据
+        List<Map> mapList = reportClassData(reportDate);
+        for(int i=0; i<mapList.size(); i++){
+            Map<String,Object> map = mapList.get(i);
+
+            Row row = sheet.createRow(i+1);
+            row.createCell(0);
+            row.createCell(1);
+            row.createCell(2);
+            row.createCell(3);
+            row.createCell(4);
+
+            row.getCell(0).setCellValue(map.get("areaName").toString());
+            row.getCell(1).setCellValue(map.get("total").toString());
+            row.getCell(2).setCellValue(map.get("noTimeout").toString());
+            row.getCell(3).setCellValue(map.get("timeout").toString());
+            row.getCell(4).setCellValue(map.get("unfinished").toString());
+
+            row.getCell(0).setCellStyle(cellStyleContent);
+            row.getCell(1).setCellStyle(cellStyleContent);
+            row.getCell(2).setCellStyle(cellStyleContent);
+            row.getCell(3).setCellStyle(cellStyleContent);
+            row.getCell(4).setCellStyle(cellStyleContent);
+        }
+
+        ByteArrayOutputStream output = new ByteArrayOutputStream();
+        try {
+            workbook.write(output);
+
+            byte[] buffer = output.toByteArray();
+            ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+
+            SimpleDateFormat sdf2 = new SimpleDateFormat("yyyyMMddHHmm");
+            String now = sdf2.format(new Date());
+            String fileName = "案件专班报表.xls";
+            downloadUrl = OSSUtil.upload(ossConfig,"InsuranceReport",fileName,input);
+        }
+        catch (Exception ex){
+            logger.error(ex.getMessage(),ex);
+        }
+
+        return downloadUrl;
+    }
+
+    private List<Map> reportClassData(Date[] reportDate){
+        List<Map> mapList = new ArrayList<>();
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar calendar = new GregorianCalendar();
+        calendar.setTime(reportDate[1]);
+        calendar.add(calendar.DATE,1);
+
+        List<DataDictionary> dataDictionaryList = dataDictionaryService.findByCatalogName("工作专班");
+        for(DataDictionary dataDictionary : dataDictionaryList){
+            Integer total = incidentService.getCount(null,"%"+dataDictionary.getValue()+"%",null,null,sdf.format(reportDate[0]),sdf.format(calendar.getTime()));
+            Integer noTimeout = incidentService.getCount(null,"%"+dataDictionary.getValue()+"%","0",false,sdf.format(reportDate[0]),sdf.format(calendar.getTime()));
+            Integer timeout = incidentService.getCount(null,"%"+dataDictionary.getValue()+"%","0",true,sdf.format(reportDate[0]),sdf.format(calendar.getTime()));
+            Integer unfinished = incidentService.getCount(null,"%"+dataDictionary.getValue()+"%","1",null,sdf.format(reportDate[0]),sdf.format(calendar.getTime()));
 
             Map<String,Object> map = new HashMap<>();
             map.put("areaName",dataDictionary.getName());