From c8972c40bdc522c12654f8fbade6911deb194bfe Mon Sep 17 00:00:00 2001 From: ly19960718 <1622779752@qq.com> Date: Fri, 15 Jan 2021 10:58:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5excel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/properties/ScoreProperties.java | 20 +++++ .../apis/deptassess/DeptAssessController.java | 34 ++++----- .../DeptAssessChangeScoreController.java | 14 +++- .../pojo/dtos/deptassess/DeptAssessDTO.java | 1 + .../deptassess/IDeptAssessService.java | 10 +++ .../impl/DeptAssessServiceImpl.java | 74 ++++++++++++++++++- .../DeptAssessChangeScoreServiceImpl.java | 2 +- src/main/resources/application.yml | 8 +- .../route/deptassess/list-deptassess.html | 6 +- .../list-deptassesschangescore.html | 41 +++++----- ...t-score-details-deptassesschangescore.html | 2 +- 11 files changed, 163 insertions(+), 49 deletions(-) diff --git a/src/main/java/com/cm/bigdata/config/properties/ScoreProperties.java b/src/main/java/com/cm/bigdata/config/properties/ScoreProperties.java index 71ecee2..c420c1d 100644 --- a/src/main/java/com/cm/bigdata/config/properties/ScoreProperties.java +++ b/src/main/java/com/cm/bigdata/config/properties/ScoreProperties.java @@ -32,6 +32,10 @@ public class ScoreProperties { private Double deptSettlescore4; private Double deptSettlescore5; + private Double deptEventscoreUp; + private Double deptEventscoreDown; + + public Integer getBossGrossscore() { return bossGrossscore; } @@ -143,4 +147,20 @@ public class ScoreProperties { public void setLowscore(Double lowscore) { this.lowscore = lowscore; } + + public Double getDeptEventscoreUp() { + return deptEventscoreUp; + } + + public void setDeptEventscoreUp(Double deptEventscoreUp) { + this.deptEventscoreUp = deptEventscoreUp; + } + + public Double getDeptEventscoreDown() { + return deptEventscoreDown; + } + + public void setDeptEventscoreDown(Double deptEventscoreDown) { + this.deptEventscoreDown = deptEventscoreDown; + } } diff --git a/src/main/java/com/cm/bigdata/controller/apis/deptassess/DeptAssessController.java b/src/main/java/com/cm/bigdata/controller/apis/deptassess/DeptAssessController.java index 092c76a..a43e765 100644 --- a/src/main/java/com/cm/bigdata/controller/apis/deptassess/DeptAssessController.java +++ b/src/main/java/com/cm/bigdata/controller/apis/deptassess/DeptAssessController.java @@ -20,6 +20,8 @@ import java.util.Map; import com.cm.common.exception.SearchException; import org.springframework.web.client.RestTemplate; +import javax.servlet.http.HttpServletResponse; + /** * @ClassName: DeptAssessController * @Description: 职能部门考核 @@ -38,24 +40,6 @@ public class DeptAssessController extends AbstractController { -/* @ApiOperation(value = "职能部门考核分页列表", notes = "职能部门考核分页列表接口") - @ApiImplicitParams({ - @ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"), - @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"), - @ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String") - }) - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("listpagedeptassess") - public SuccessResultList> listPageDeptAssess(ListPage page) throws SearchException{ - Map params = requestParams(); - page.setParams(params); - String url = partyBuildingProperties.getDeptassesstUrl()+DEPT_ASSESS_LIST_URL; - RestTemplate restTemplate = new RestTemplate(); - restTemplate.getForObject(url,String.class,params); - return ; - }*/ @ApiOperation(value = "手动统计数据", notes = "手动统计数据接口") @@ -68,6 +52,17 @@ public class DeptAssessController extends AbstractController { + @ApiOperation(value = "导出excel统计数据", notes = "导出excel统计数据") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("excelManualDeptData/{year}/{quarter}") + @CheckRequestBodyAnnotation + public void excelManualDeptData(@PathVariable("year") String year, @PathVariable("quarter") String quarter, HttpServletResponse response) throws Exception { + deptAssessService.excelManualDeptData(year,quarter,response); + } + + + + @ApiOperation(value = "职能部门考核列表", notes = "职能部门考核列表接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @@ -80,6 +75,9 @@ public class DeptAssessController extends AbstractController { + + + /* @Autowired private IDeptAssessService deptAssessService; @Autowired diff --git a/src/main/java/com/cm/bigdata/controller/apis/deptassesschangescore/DeptAssessChangeScoreController.java b/src/main/java/com/cm/bigdata/controller/apis/deptassesschangescore/DeptAssessChangeScoreController.java index 8267c08..09211de 100644 --- a/src/main/java/com/cm/bigdata/controller/apis/deptassesschangescore/DeptAssessChangeScoreController.java +++ b/src/main/java/com/cm/bigdata/controller/apis/deptassesschangescore/DeptAssessChangeScoreController.java @@ -1,5 +1,6 @@ package com.cm.bigdata.controller.apis.deptassesschangescore; +import com.cm.bigdata.config.properties.ScoreProperties; import com.cm.bigdata.pojo.dtos.deptassess.DeptAssessAllQuarterDTO; import com.cm.bigdata.pojo.dtos.deptassess.DeptAssessDTO; import com.cm.bigdata.pojo.dtos.deptassesschangescore.DeptAssessScoreDetailsDTO; @@ -44,6 +45,13 @@ public class DeptAssessChangeScoreController extends AbstractController { private IDeptAssessChangeScoreService deptAssessChangeScoreService; @Autowired private SecurityComponent securityComponent; + @Autowired + private ScoreProperties scoreProperties; + + + + + @ApiOperation(value = "职能部门加减分列表", notes = "职能部门加减分列表接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @@ -80,16 +88,18 @@ public class DeptAssessChangeScoreController extends AbstractController { if(deptAssessChangeScoreVO.getChangeScore() == 0.0){ throw new ParamsException("请输入正确的改变分数"); } + Double up = scoreProperties.getDeptEventscoreUp(); + Double down = scoreProperties.getDeptEventscoreDown(); if("1".equals(deptAssessChangeScoreVO.getChangeScoreType())){ Double num = deptAssessChangeScoreVO.getDeptCaseTotalScore() + deptAssessChangeScoreVO.getChangeScore(); - if(num > 100){ + if(num > up){ throw new ParamsException("【输入分数+总分】超出总分上限"); } } if("2".equals(deptAssessChangeScoreVO.getChangeScoreType())){ Double num = deptAssessChangeScoreVO.getDeptCaseTotalScore() - deptAssessChangeScoreVO.getChangeScore(); - if(num < 0.0){ + if(num < down){ throw new ParamsException("【总分-输入分数】超出总分下限"); } } diff --git a/src/main/java/com/cm/bigdata/pojo/dtos/deptassess/DeptAssessDTO.java b/src/main/java/com/cm/bigdata/pojo/dtos/deptassess/DeptAssessDTO.java index 7cee60e..644981d 100644 --- a/src/main/java/com/cm/bigdata/pojo/dtos/deptassess/DeptAssessDTO.java +++ b/src/main/java/com/cm/bigdata/pojo/dtos/deptassess/DeptAssessDTO.java @@ -1,5 +1,6 @@ package com.cm.bigdata.pojo.dtos.deptassess; +import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/src/main/java/com/cm/bigdata/service/deptassess/IDeptAssessService.java b/src/main/java/com/cm/bigdata/service/deptassess/IDeptAssessService.java index bb404e9..52a8ffe 100644 --- a/src/main/java/com/cm/bigdata/service/deptassess/IDeptAssessService.java +++ b/src/main/java/com/cm/bigdata/service/deptassess/IDeptAssessService.java @@ -12,6 +12,7 @@ import com.cm.common.result.SuccessResultList; import com.cm.bigdata.pojo.dtos.deptassess.DeptAssessDTO; import com.cm.bigdata.pojo.vos.deptassess.DeptAssessVO; +import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; @@ -25,6 +26,15 @@ import java.util.Map; public interface IDeptAssessService { + /** + * 导出案件统计数据 + * @param deptTotalYear + * @param deptTotalQuarter + * @return + * @throws Exception + */ + void excelManualDeptData(String deptTotalYear, String deptTotalQuarter, HttpServletResponse response) throws Exception; + /** * 查询所有部门指定年的季度总分 * @param year diff --git a/src/main/java/com/cm/bigdata/service/deptassess/impl/DeptAssessServiceImpl.java b/src/main/java/com/cm/bigdata/service/deptassess/impl/DeptAssessServiceImpl.java index 8cc230d..f59f3d1 100644 --- a/src/main/java/com/cm/bigdata/service/deptassess/impl/DeptAssessServiceImpl.java +++ b/src/main/java/com/cm/bigdata/service/deptassess/impl/DeptAssessServiceImpl.java @@ -1,5 +1,6 @@ package com.cm.bigdata.service.deptassess.impl; +import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cm.bigdata.config.properties.PartyBuildingProperties; @@ -24,6 +25,7 @@ import com.cm.bigdata.pojo.vos.deptassess.DeptAssessVO; import com.cm.bigdata.service.deptassess.IDeptAssessService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import org.apache.http.HttpResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; @@ -32,6 +34,8 @@ import org.springframework.util.StringUtils; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; +import javax.servlet.http.HttpServletResponse; +import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.*; @@ -57,13 +61,72 @@ public class DeptAssessServiceImpl extends AbstractService implements IDeptAsses private IDeptAssessChangeScoreService deptAssessChangeScoreService; + //部门考核列表数据接口 private final static String DEPT_ASSESS_LIST_URL_1 = "/resource/caseexamine/listdeptcasetimeout"; private final static String DEPT_ASSESS_LIST_URL_2 = "/resource/caseexamine/getreportcasescore"; + + + + + + /** + * 导出案件统计数据 + * @param deptTotalYear + * @param deptTotalQuarter + * @return + * @throws Exception + */ + public void excelManualDeptData(String deptTotalYear, String deptTotalQuarter, HttpServletResponse response) throws Exception{ + String excelName = "y年q季度职能部门考核分数统计表"; + String fileName = URLEncoder.encode("党费管理Excel模板", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + String [] headers = {"部门名称","统计年份","统计季度","部门已处理案件数量","案件处理情况分数","部门超时案件数量","案件处置时效分数","案件处理结果分数", + "案件督查分数","总分","自定义共加分","最终得分","数据统计时间" + }; + List> listHeader = new ArrayList<>(); + for (String item : headers){ + List title = new ArrayList<>(); + title.add(item); + listHeader.add(title); + } + + Map params = new HashMap<>(); + params.put("deptTotalQuarter",deptTotalQuarter); + params.put("deptTotalYear",deptTotalYear); + List deptAssessDTOs = deptAssessDao.listDeptAssess(params); + List> listData = new ArrayList<>(); + for (DeptAssessDTO d : deptAssessDTOs) { + List data = new ArrayList(); + data.add(d.getDeptName()); + data.add(d.getDeptTotalYear()); + data.add(d.getDeptTotalQuarter()); + data.add(d.getDeptCaseNum().toString()); + data.add("加"+d.getDeptCaseSettleScore().toString()+"分"); + data.add(d.getDeptCaseTimeoutNum().toString()); + data.add("加"+d.getDeptCaseTimeoutScore().toString()+"分"); + data.add(d.getDeptCaseGrossScore().toString()); + Integer num = deptInspectorService.countDeptInspectorNum(d.getDeptTotalYear(),d.getDeptTotalQuarter(),d.getDeptId()); + data.add("扣"+num.toString()+"分"); + data.add(d.getDeptCaseTotalScore().toString()+"分"); + double zdy = deptAssessChangeScoreService.getDeptChangeScore(d.getDeptAssessId()); + data.add(zdy+"分"); + Double eventScore = totalEvenSocre(d.getDeptCaseTotalScore(),zdy); + data.add(eventScore.toString()+"分"); + data.add(d.getDeptTotalTime()); + listData.add(data); + } + + EasyExcel.write(response.getOutputStream()).sheet("职能部门考核分数表").head(listHeader).doWrite(listData); + } + + + +/** * 初始化手动案件统计数据 * @param deptTotalYear * @param deptTotalQuarter @@ -453,13 +516,16 @@ public class DeptAssessServiceImpl extends AbstractService implements IDeptAsses public Double totalEvenSocre(Double num1,Double num2){ + Double up = scoreProperties.getDeptEventscoreUp(); + Double down = scoreProperties.getDeptEventscoreDown(); + Double socere = 0.0; socere = num1 + num2; - if(socere < 0.0){ - socere = 0.0; + if(socere < down){ + socere = down; } - if(socere > 100){ - socere = 100.0; + if(socere > up){ + socere = up; } return socere; } diff --git a/src/main/java/com/cm/bigdata/service/deptassesschangescore/impl/DeptAssessChangeScoreServiceImpl.java b/src/main/java/com/cm/bigdata/service/deptassesschangescore/impl/DeptAssessChangeScoreServiceImpl.java index e77a6ba..7517569 100644 --- a/src/main/java/com/cm/bigdata/service/deptassesschangescore/impl/DeptAssessChangeScoreServiceImpl.java +++ b/src/main/java/com/cm/bigdata/service/deptassesschangescore/impl/DeptAssessChangeScoreServiceImpl.java @@ -140,7 +140,7 @@ public class DeptAssessChangeScoreServiceImpl extends AbstractService implements dto.setScoreCause(scoreCause); dto.setScoreWay("系统判定"); dto.setChangeScoreTime(time); - dto.setChangeScoreUser(""); + dto.setChangeScoreUser("系统"); return dto; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 82091da..beabbf3 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,6 +1,6 @@ server: - port: 8087 - url: http://192.168.0.111:8087/bigdata + port: 8080 + url: http://192.168.0.120:8080/bigdata title: bigdata servlet: context-path: /bigdata @@ -150,4 +150,6 @@ score: dept-settlescore-2: 0.5 #案件处理情况扣分值 dept-settlescore-3: 20 #处理结果总分值 dept-settlescore-4: 1 #案件督查扣分值 - dept-settlescore-5: 40 #案件处置时效默认分值 \ No newline at end of file + dept-settlescore-5: 40 #案件处置时效默认分值 + dept-eventscore-up: 100 #最终得分上限 + dept-eventscore-down: 0 #最终得分下限 \ No newline at end of file diff --git a/src/main/resources/static/route/deptassess/list-deptassess.html b/src/main/resources/static/route/deptassess/list-deptassess.html index 40652a2..17fb383 100644 --- a/src/main/resources/static/route/deptassess/list-deptassess.html +++ b/src/main/resources/static/route/deptassess/list-deptassess.html @@ -146,7 +146,7 @@ return ''+rowData+'分'; } }, - {field: 'deptTotalYear', width: 150, title: '统计年份', align:'center', + {field: 'deptTotalYear', width: 120, title: '统计年份', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { @@ -155,7 +155,7 @@ return rowData; } }, - {field: 'deptTotalQuarter', width: 150, title: '统计季度', align:'center', + {field: 'deptTotalQuarter', width: 120, title: '统计季度', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { @@ -164,7 +164,7 @@ return rowData; } }, - {field: 'deptTotalTime', width: 150, title: '数据统计时间', align:'center', + {field: 'deptTotalTime', width: 180, title: '数据统计时间', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { diff --git a/src/main/resources/static/route/deptassesschangescore/list-deptassesschangescore.html b/src/main/resources/static/route/deptassesschangescore/list-deptassesschangescore.html index 0686b62..29dd9cb 100644 --- a/src/main/resources/static/route/deptassesschangescore/list-deptassesschangescore.html +++ b/src/main/resources/static/route/deptassesschangescore/list-deptassesschangescore.html @@ -36,6 +36,9 @@ +
@@ -144,7 +147,7 @@ return ''+rowData+'分'; } }, - {field: 'deptTotalYear', width: 150, title: '统计年份', align:'center', + {field: 'deptTotalYear', width: 120, title: '统计年份', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { @@ -153,7 +156,7 @@ return rowData; } }, - {field: 'deptTotalQuarter', width: 150, title: '统计季度', align:'center', + {field: 'deptTotalQuarter', width: 120, title: '统计季度', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { @@ -162,7 +165,7 @@ return rowData; } }, - {field: 'deptTotalTime', width: 150, title: '数据统计时间', align:'center', + {field: 'deptTotalTime', width: 180, title: '数据统计时间', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { @@ -243,21 +246,19 @@ $(document).on('click', '#search', function() { reloadTable(1); }); - //手动统计 - $(document).on('click', '#total', function() { + $(document).on('click', '#excel', function() { var v1 = $('#deptTotalYear').val(); var v2 = $('#deptTotalQuarter').val(); - total(v1,v2); + excel(v1,v2); }); - - function total(v1,v2){ + function excel(v1,v2){ if(v1 === ''){ - layer.msg('请选择统计年份') + layer.msg('请选择导出数据年份') } if(v2 === ''){ - layer.msg('请选择统计季度') + layer.msg('请选择导出数据季度') } var v2Str = ""; if(v2 === '1'){ @@ -272,29 +273,35 @@ if(v2 === '4'){ v2Str = '第四季度' } - top.dialog.msg('确定要统计'+v1+'年'+v2Str+'的数据吗?', { + + + top.dialog.msg('确定要导出'+v1+'年'+v2Str+'的数据吗?', { time: 0, btn: [top.dataMessage.button.yes, top.dataMessage.button.no], shade: 0.3, yes: function (index) { top.dialog.close(index); var layIndex; - top.restAjax.get(top.restAjax.path('api/deptassess/initManualDeptData/{year}/{quarter}', [v1,v2]), {}, null, function (code, data) { - top.dialog.msg('统计完成', {time: 1000}); + window.open(top.restAjax.path('api/deptassess/excelManualDeptData/{year}/{quarter}', [v1,v2])); + /* top.restAjax.get(top.restAjax.path('api/deptassess/excelManualDeptData/{year}/{quarter}', [v1,v2]), {}, null, function (code, data) { + top.dialog.msg('导出完成', {time: 1000}); reloadTable(); }, function (code, data) { top.dialog.msg(data.msg); }, function () { - layIndex = top.dialog.msg('统计中...', {icon: 16, time: 0, shade: 0.3}); + layIndex = top.dialog.msg('导出中...', {icon: 16, time: 0, shade: 0.3}); }, function () { top.dialog.close(layIndex); - }); + });*/ } }); - - } + + + + + //按钮事件 table.on('tool(dataTable)',function(obj){ var layEvent = obj.event; diff --git a/src/main/resources/static/route/deptassesschangescore/list-score-details-deptassesschangescore.html b/src/main/resources/static/route/deptassesschangescore/list-score-details-deptassesschangescore.html index f3efe55..1e0a1c7 100644 --- a/src/main/resources/static/route/deptassesschangescore/list-score-details-deptassesschangescore.html +++ b/src/main/resources/static/route/deptassesschangescore/list-score-details-deptassesschangescore.html @@ -96,7 +96,7 @@ return rowData; } }, - {field: 'changeScoreTime', width: 150, title: '操作时间', align:'center', + {field: 'changeScoreTime', width: 180, title: '操作时间', align:'center', templet: function(row) { var rowData = row[this.field]; return rowData;