From e9e8395519238d99052eb0d77eac525cf24cf9e8 Mon Sep 17 00:00:00 2001 From: Renpc-kilig <308442850@qq.com> Date: Thu, 28 Oct 2021 20:33:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=9B=BE=E8=A1=A8=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96=20=E5=9B=BE?= =?UTF-8?q?=E8=A1=A8=E7=BB=9F=E8=AE=A1=E5=8A=9F=E8=83=BD=E6=96=B0=E5=A2=9E?= =?UTF-8?q?(=E5=AE=8C=E6=88=90)=20=E6=96=B0=E5=A2=9E=E7=9D=A3=E5=8A=9E?= =?UTF-8?q?=E9=A2=84=E8=AD=A6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 24 +- .../api/distribute/DistributeController.java | 2 +- .../ReceiverUserAppController.java | 1 + .../pojo/bos/receiveruser/ReceiverUserBO.java | 18 + .../dtos/receiveruser/ReceiverUserDTO.java | 31 ++ .../ReceiverUserPatrolDTO.java | 20 + .../pojo/pos/receiveruser/ReceiverUserPO.java | 18 + .../pojo/vos/receiveruser/ReceiverUserVO.java | 20 + .../distribute/IDistributeService.java | 2 +- .../impl/DistributeServiceImpl.java | 466 +++++++++++++++--- .../impl/ReceiverUserServiceImpl.java | 9 +- .../service/urge/impl/UrgeServiceImpl.java | 23 +- .../tenlion/systemtask/utils/DateUtils.java | 156 ++++-- .../receiveruser/receiver-user-mapper.xml | 48 +- .../receiver-user-patrol-mapper.xml | 2 + .../templates/distribute/charts.html | 301 ++++++----- .../templates/receiveruser/list.html | 83 +++- 17 files changed, 963 insertions(+), 261 deletions(-) diff --git a/pom.xml b/pom.xml index a1aa062..0fb97cb 100644 --- a/pom.xml +++ b/pom.xml @@ -63,17 +63,17 @@ - + - + org.quartz-scheduler @@ -82,7 +82,7 @@ - + + + + ink.wgink + basic-app + 1.0-SNAPSHOT + + + ink.wgink + login-app + 1.0-SNAPSHOT + + diff --git a/src/main/java/cn/com/tenlion/systemtask/controller/api/distribute/DistributeController.java b/src/main/java/cn/com/tenlion/systemtask/controller/api/distribute/DistributeController.java index 3300128..377c75b 100644 --- a/src/main/java/cn/com/tenlion/systemtask/controller/api/distribute/DistributeController.java +++ b/src/main/java/cn/com/tenlion/systemtask/controller/api/distribute/DistributeController.java @@ -213,7 +213,7 @@ public class DistributeController extends DefaultBaseController{ }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("bar-charts") - public SuccessResultData> barCharts() throws ParseException { + public SuccessResultData> barCharts() throws ParseException { Map params = requestParams(); return distributeService.barCharts(params); } diff --git a/src/main/java/cn/com/tenlion/systemtask/controller/app/api/receiveruser/ReceiverUserAppController.java b/src/main/java/cn/com/tenlion/systemtask/controller/app/api/receiveruser/ReceiverUserAppController.java index 8f67bb2..4409e01 100644 --- a/src/main/java/cn/com/tenlion/systemtask/controller/app/api/receiveruser/ReceiverUserAppController.java +++ b/src/main/java/cn/com/tenlion/systemtask/controller/app/api/receiveruser/ReceiverUserAppController.java @@ -106,6 +106,7 @@ public class ReceiverUserAppController extends DefaultBaseController { @GetMapping("listpagereceiveruser") public SuccessResultList> listPage(@RequestHeader("token") String token, ListPage page) { Map params = requestParams(); + params.put("token", token); page.setParams(params); return receiverUserService.listPage(page); } diff --git a/src/main/java/cn/com/tenlion/systemtask/pojo/bos/receiveruser/ReceiverUserBO.java b/src/main/java/cn/com/tenlion/systemtask/pojo/bos/receiveruser/ReceiverUserBO.java index f22842a..301c8cb 100644 --- a/src/main/java/cn/com/tenlion/systemtask/pojo/bos/receiveruser/ReceiverUserBO.java +++ b/src/main/java/cn/com/tenlion/systemtask/pojo/bos/receiveruser/ReceiverUserBO.java @@ -21,6 +21,8 @@ public class ReceiverUserBO { private String taskType; private String checkStatus; private String reason; + private String isWarning; + private String isSupervision; public String getReceiverUserId() { return receiverUserId == null ? "" : receiverUserId.trim(); @@ -109,4 +111,20 @@ public class ReceiverUserBO { public void setReason(String reason) { this.reason = reason; } + + public String getIsWarning() { + return isWarning; + } + + public void setIsWarning(String isWarning) { + this.isWarning = isWarning; + } + + public String getIsSupervision() { + return isSupervision; + } + + public void setIsSupervision(String isSupervision) { + this.isSupervision = isSupervision; + } } diff --git a/src/main/java/cn/com/tenlion/systemtask/pojo/dtos/receiveruser/ReceiverUserDTO.java b/src/main/java/cn/com/tenlion/systemtask/pojo/dtos/receiveruser/ReceiverUserDTO.java index a32e649..168acf6 100644 --- a/src/main/java/cn/com/tenlion/systemtask/pojo/dtos/receiveruser/ReceiverUserDTO.java +++ b/src/main/java/cn/com/tenlion/systemtask/pojo/dtos/receiveruser/ReceiverUserDTO.java @@ -38,6 +38,10 @@ public class ReceiverUserDTO { private String checkStatus; @ApiModelProperty(name = "reason", value = "审核原因") private String reason; + @ApiModelProperty(name = "isWarning", value = "是否预警") + private String isWarning; + @ApiModelProperty(name = "isSupervision", value = "是否督办") + private String isSupervision; @ApiModelProperty(name = "distributeTitle", value = "名称") @@ -153,6 +157,22 @@ public class ReceiverUserDTO { this.reason = reason; } + public String getIsWarning() { + return isWarning; + } + + public void setIsWarning(String isWarning) { + this.isWarning = isWarning; + } + + public String getIsSupervision() { + return isSupervision; + } + + public void setIsSupervision(String isSupervision) { + this.isSupervision = isSupervision; + } + public String getDistributeTitle() { return distributeTitle; } @@ -216,4 +236,15 @@ public class ReceiverUserDTO { public void setFrequency(String frequency) { this.frequency = frequency; } + + @Override + public String toString() { + return "ReceiverUserDTO{" + + "receiverUserId='" + receiverUserId + '\'' + + ", receiveType='" + receiveType + '\'' + + ", executeStatus='" + executeStatus + '\'' + + ", taskType='" + taskType + '\'' + + ", checkStatus='" + checkStatus + '\'' + + '}'; + } } diff --git a/src/main/java/cn/com/tenlion/systemtask/pojo/dtos/receiveruserpatrol/ReceiverUserPatrolDTO.java b/src/main/java/cn/com/tenlion/systemtask/pojo/dtos/receiveruserpatrol/ReceiverUserPatrolDTO.java index 72656d2..c5b8e3c 100644 --- a/src/main/java/cn/com/tenlion/systemtask/pojo/dtos/receiveruserpatrol/ReceiverUserPatrolDTO.java +++ b/src/main/java/cn/com/tenlion/systemtask/pojo/dtos/receiveruserpatrol/ReceiverUserPatrolDTO.java @@ -14,6 +14,10 @@ import io.swagger.annotations.ApiModelProperty; @ApiModel public class ReceiverUserPatrolDTO { + @ApiModelProperty(name = "receiverUserPatrolId", value = "上报记录ID") + private String receiverUserPatrolId; + @ApiModelProperty(name = "receiverUserId", value = "任务接收人表ID") + private String receiverUserId; @ApiModelProperty(name = "patrolTime", value = "巡查时间") private String patrolTime; @ApiModelProperty(name = "patrolContent", value = "巡查内容") @@ -37,6 +41,22 @@ public class ReceiverUserPatrolDTO { @ApiModelProperty(name = "isDelete", value = "") private Integer isDelete; + public String getReceiverUserPatrolId() { + return receiverUserPatrolId; + } + + public void setReceiverUserPatrolId(String receiverUserPatrolId) { + this.receiverUserPatrolId = receiverUserPatrolId; + } + + public String getReceiverUserId() { + return receiverUserId; + } + + public void setReceiverUserId(String receiverUserId) { + this.receiverUserId = receiverUserId; + } + public String getPatrolTime() { return patrolTime == null ? "" : patrolTime.trim(); } diff --git a/src/main/java/cn/com/tenlion/systemtask/pojo/pos/receiveruser/ReceiverUserPO.java b/src/main/java/cn/com/tenlion/systemtask/pojo/pos/receiveruser/ReceiverUserPO.java index 89336fe..f9e6621 100644 --- a/src/main/java/cn/com/tenlion/systemtask/pojo/pos/receiveruser/ReceiverUserPO.java +++ b/src/main/java/cn/com/tenlion/systemtask/pojo/pos/receiveruser/ReceiverUserPO.java @@ -21,6 +21,8 @@ public class ReceiverUserPO { private String taskType; private String checkStatus; private String reason; + private String isWarning; + private String isSupervision; public String getReceiverUserId() { return receiverUserId == null ? "" : receiverUserId.trim(); @@ -109,4 +111,20 @@ public class ReceiverUserPO { public void setReason(String reason) { this.reason = reason; } + + public String getIsWarning() { + return isWarning; + } + + public void setIsWarning(String isWarning) { + this.isWarning = isWarning; + } + + public String getIsSupervision() { + return isSupervision; + } + + public void setIsSupervision(String isSupervision) { + this.isSupervision = isSupervision; + } } diff --git a/src/main/java/cn/com/tenlion/systemtask/pojo/vos/receiveruser/ReceiverUserVO.java b/src/main/java/cn/com/tenlion/systemtask/pojo/vos/receiveruser/ReceiverUserVO.java index b966d25..19f8066 100644 --- a/src/main/java/cn/com/tenlion/systemtask/pojo/vos/receiveruser/ReceiverUserVO.java +++ b/src/main/java/cn/com/tenlion/systemtask/pojo/vos/receiveruser/ReceiverUserVO.java @@ -40,6 +40,10 @@ public class ReceiverUserVO { private String checkStatus; @ApiModelProperty(name = "reason", value = "审核原因") private String reason; + @ApiModelProperty(name = "isWarning", value = "是否预警") + private String isWarning; + @ApiModelProperty(name = "isSupervision", value = "是否督办") + private String isSupervision; public String getDistributeId() { return distributeId == null ? "" : distributeId.trim(); @@ -128,4 +132,20 @@ public class ReceiverUserVO { public void setReason(String reason) { this.reason = reason; } + + public String getIsWarning() { + return isWarning; + } + + public void setIsWarning(String isWarning) { + this.isWarning = isWarning; + } + + public String getIsSupervision() { + return isSupervision; + } + + public void setIsSupervision(String isSupervision) { + this.isSupervision = isSupervision; + } } diff --git a/src/main/java/cn/com/tenlion/systemtask/service/distribute/IDistributeService.java b/src/main/java/cn/com/tenlion/systemtask/service/distribute/IDistributeService.java index df3ed8e..26745c3 100644 --- a/src/main/java/cn/com/tenlion/systemtask/service/distribute/IDistributeService.java +++ b/src/main/java/cn/com/tenlion/systemtask/service/distribute/IDistributeService.java @@ -290,5 +290,5 @@ public interface IDistributeService { * @param params * @return */ - SuccessResultData> barCharts(Map params) throws ParseException; + SuccessResultData> barCharts(Map params) throws ParseException; } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/systemtask/service/distribute/impl/DistributeServiceImpl.java b/src/main/java/cn/com/tenlion/systemtask/service/distribute/impl/DistributeServiceImpl.java index 459fffe..a6571fd 100644 --- a/src/main/java/cn/com/tenlion/systemtask/service/distribute/impl/DistributeServiceImpl.java +++ b/src/main/java/cn/com/tenlion/systemtask/service/distribute/impl/DistributeServiceImpl.java @@ -612,81 +612,414 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri } @Override - public SuccessResultData> barCharts(Map params) throws ParseException { + public SuccessResultData> barCharts(Map params) throws ParseException { + Map backMap = new HashMap<>(); // 设置返回数据的输出格式为保留两位有效数字的百分比 NumberFormat fmt = NumberFormat.getPercentInstance(); fmt.setMinimumFractionDigits(2); - // 最后的结果返回集合 - List chartsDTOList = new ArrayList<>(); + // 用于填充数据的集合 + List taskOverList = new ArrayList<>(); + List taskSoonOverdueList = new ArrayList<>(); + List taskOverdueList = new ArrayList<>(); + List taskBackList = new ArrayList<>(); + List taskIncompleteList = new ArrayList<>(); + // 用于饼图数据 + List pieList = new ArrayList<>(); List receiverUserDTOList = receiverUserService.list(params); + // 设置纵坐标值集合 + String xAxisValue = ""; if(null != receiverUserDTOList && receiverUserDTOList.size() > 0) { // 当前月份 int dateNum = screenData(receiverUserDTOList, params); - if(dateNum > 0) { - // 任务下派数量 - int taskSendCount = receiverUserDTOList.size(); - for(int i=1;i<=dateNum;i++) { - // 任务完成数量 - int taskOverCount = 0; - // 任务完成率 - String taskOverRate; - // 任务即将超期数量 - int taskSoonOverdueCount = 0; - // 任务即将超期率 - String taskSoonOverdueRate; - // 任务超期数量 - int taskOverdueCount = 0; - // 任务超期率 - String taskOverdueRate; - // 任务退回数量 - int taskBackCount = 0; - // 任务退回率 - String taskBackRate; - DateRange dateRange = DateUtils.getAppointMonth(i - dateNum); - Date startDate = dateRange.getStart(); - Date endDate = dateRange.getEnd(); - for(ReceiverUserDTO receiverUserDTO: receiverUserDTOList) { - Date nowDate = df.parse(receiverUserDTO.getDistributeDeadline()); - boolean isOver = isEffectiveDate(nowDate, startDate, endDate); - if(isOver) { - if("正常".equals(receiverUserDTO.getTaskType()) && "完成".equals(receiverUserDTO.getExecuteStatus()) && "已通过".equals(receiverUserDTO.getCheckStatus())) { - taskOverCount++; - } - if("即将超期".equals(receiverUserDTO.getTaskType())) { - taskSoonOverdueCount++; - } - if("已超期".equals(receiverUserDTO.getTaskType())) { - taskOverdueCount++; - } - if("已回退".equals(receiverUserDTO.getTaskType())) { - taskBackCount++; - } - } - } - ChartsDTO chartsDTO = new ChartsDTO(); - chartsDTO.setName(i + "月"); - - - /*System.out.println("----------------"); - System.out.println(i + "月"); - System.out.println(taskSendCount); - System.out.println(taskOverCount); - System.out.println(taskSoonOverdueCount); - System.out.println(taskOverdueCount); - System.out.println(taskBackCount); - System.out.println("----------------");*/ - // 计算率 - taskOverRate = fmt.format((float) taskOverCount / taskSendCount); - taskSoonOverdueRate = fmt.format((float) taskSoonOverdueCount / taskSendCount); - taskOverdueRate = fmt.format((float) taskOverdueCount / taskSendCount); - taskBackRate = fmt.format((float) taskBackCount / taskSendCount); - chartsDTO.setDataValue(taskOverRate + "," + taskSoonOverdueRate + "," + taskOverdueRate + "," + taskBackRate); - chartsDTOList.add(chartsDTO); + if (!StringHandler.isNull(params.get("startTime")) && StringHandler.isNull(params.get("endTime"))) { + Date date = df.parse(params.get("startTime").toString()); + if(dateNum/12 < 1) { + xAxisValue = monthData(date, xAxisValue, dateNum, receiverUserDTOList, taskOverList, taskSoonOverdueList, taskOverdueList, taskBackList, taskIncompleteList, pieList); + }else { + int yearDifference = DateUtils.compareDate(params.get("startTime").toString(), null, 2); + xAxisValue = yearData(date, yearDifference, xAxisValue, receiverUserDTOList, taskOverList, taskSoonOverdueList, taskOverdueList, taskBackList, taskIncompleteList, pieList); + } + xAxisValue = xAxisValue.substring(0, xAxisValue.length()-1); + backMap.put("xAxisValue", xAxisValue); + } else if (!StringHandler.isNull(params.get("endTime")) && StringHandler.isNull(params.get("startTime"))) { + if(dateNum/12 < 1) { + xAxisValue = monthData(new Date(), xAxisValue, dateNum, receiverUserDTOList, taskOverList, taskSoonOverdueList, taskOverdueList, taskBackList, taskIncompleteList, pieList); + }else { + int yearDifference = DateUtils.compareDate(df.format(new Date()), params.get("endTime").toString(), 2); + xAxisValue = yearData(new Date(), yearDifference, xAxisValue, receiverUserDTOList, taskOverList, taskSoonOverdueList, taskOverdueList, taskBackList, taskIncompleteList, pieList); + } + xAxisValue = xAxisValue.substring(0, xAxisValue.length()-1); + backMap.put("xAxisValue", xAxisValue); + } else if (!StringHandler.isNull(params.get("startTime")) && !StringHandler.isNull(params.get("endTime"))) { + Date startDate = df.parse(params.get("startTime").toString()); + if(dateNum/12 < 1) { + xAxisValue = monthData(startDate, xAxisValue, dateNum, receiverUserDTOList, taskOverList, taskSoonOverdueList, taskOverdueList, taskBackList, taskIncompleteList, pieList); + }else { + int yearDifference = DateUtils.compareDate(params.get("startTime").toString(), params.get("endTime").toString(), 2); + xAxisValue = yearData(startDate, yearDifference, xAxisValue, receiverUserDTOList, taskOverList, taskSoonOverdueList, taskOverdueList, taskBackList, taskIncompleteList, pieList); + } + xAxisValue = xAxisValue.substring(0, xAxisValue.length()-1); + backMap.put("xAxisValue", xAxisValue); + } else { + if(dateNum/12 < 1) { + xAxisValue = monthData(new Date(), xAxisValue, dateNum, receiverUserDTOList, taskOverList, taskSoonOverdueList, taskOverdueList, taskBackList, taskIncompleteList, pieList); + xAxisValue = xAxisValue.substring(0, xAxisValue.length()-1); + backMap.put("xAxisValue", xAxisValue); } } } - return new SuccessResultData<>(chartsDTOList); + setBackData(taskOverList, backMap); + setBackData(taskSoonOverdueList, backMap); + setBackData(taskOverdueList, backMap); + setBackData(taskBackList, backMap); + setBackData(taskIncompleteList, backMap); + ChartsDTO chartsDTO = new ChartsDTO(); + chartsDTO.setName("任务数"); + chartsDTO.setDataValue(String.valueOf(receiverUserDTOList.size())); + pieList.add(chartsDTO); + backMap.put("pieData", pieList); + return new SuccessResultData<>(backMap); + } + + /** + * 按月份计算数据 + * @param date + * @param xAxisValue + * @param dateNum + * @param receiverUserDTOList + * @param taskOverList + * @param taskSoonOverdueList + * @param taskOverdueList + * @param taskBackList + * @param taskIncompleteList + * @param pieList + * @return + * @throws ParseException + */ + private String monthData(Date date, String xAxisValue, int dateNum, + List receiverUserDTOList, List taskOverList, + List taskSoonOverdueList, List taskOverdueList, + List taskBackList, List taskIncompleteList, + List pieList) throws ParseException { + + // 任务完成数量 + int taskOverCountPie = 0; + // 任务即将超期数量 + int taskSoonOverdueCountPie = 0; + // 任务超期数量 + int taskOverdueCountPie = 0; + // 任务退回数量 + int taskBackCountPie = 0; + // 任务未完成数量 + int taskIncompleteCountPie = 0; + + cal.setTime(date); + Date nowDate = new Date(); + boolean dateEqual = DateUtils.DateEqual(nowDate, date); + // 横坐标起始日期 + int yearTime = cal.get(Calendar.YEAR); + int monthTime = cal.get(Calendar.MONTH) + 1; + if(dateNum/12 < 1) { + for (int i = 1; i <= dateNum; i++) { + DateRange dateRange; + if(!dateEqual) { + if (monthTime > 12) { + yearTime += 1; + monthTime = 1; + } + xAxisValue += yearTime + "年-" + monthTime + "月" + ","; + String dateTime = ""; + if(monthTime < 10) { + dateTime = yearTime + "-0" + monthTime + "-01" + " 00:00:00"; + }else { + dateTime = yearTime + "-" + monthTime + "-01" + " 00:00:00"; + } + dateRange = DateUtils.getMonthRange(df.parse(dateTime)); + monthTime++; + }else { + xAxisValue += yearTime + "年-" + i + "月" + ","; + dateRange = DateUtils.getAppointMonth(i - dateNum); + } + + Date startDate = dateRange.getStart(); + Date endDate = dateRange.getEnd(); + backData(startDate, endDate, + receiverUserDTOList, taskOverList, + taskSoonOverdueList, taskOverdueList, + taskBackList, taskIncompleteList, pieList, + taskOverCountPie, taskSoonOverdueCountPie, + taskOverdueCountPie, taskBackCountPie, taskIncompleteCountPie); + } + backPieData(pieList); + } + return xAxisValue; + } + + /** + * 按年份计算数据 + * @param date + * @param yearDifference + * @param xAxisValue + * @param receiverUserDTOList + * @param taskOverList + * @param taskSoonOverdueList + * @param taskOverdueList + * @param taskBackList + * @param pieList + * @throws ParseException + */ + private String yearData(Date date, int yearDifference, String xAxisValue, + List receiverUserDTOList, List taskOverList, + List taskSoonOverdueList, List taskOverdueList, + List taskBackList, List taskIncompleteList, List pieList) throws ParseException { + // 任务完成数量 + int taskOverCountPie = 0; + // 任务即将超期数量 + int taskSoonOverdueCountPie = 0; + // 任务超期数量 + int taskOverdueCountPie = 0; + // 任务退回数量 + int taskBackCountPie = 0; + // 任务未完成数量 + int taskIncompleteCountPie = 0; + + cal.setTime(date); + // 横坐标起始日期 + int yearTime = cal.get(Calendar.YEAR); + if(yearDifference > 0) { + for(int i=0;i<=yearDifference;i++) { + xAxisValue += (yearTime + i) + "年" + ","; + + Date startDate = df.parse((yearTime + i) + "-01-01 00:00:00"); + Date endDate = df.parse((yearTime + i) + "-12-31 23:59:59"); + backData(startDate, endDate, + receiverUserDTOList, taskOverList, + taskSoonOverdueList, taskOverdueList, + taskBackList, taskIncompleteList, pieList, + taskOverCountPie, taskSoonOverdueCountPie, + taskOverdueCountPie, taskBackCountPie, + taskIncompleteCountPie); + } + + backPieData(pieList); + } + return xAxisValue; + } + + /** + * 处理饼图集合数据,用作最后返回 + * @param pieList + */ + private void backPieData(List pieList) { + if(null != pieList && pieList.size() > 0) { + // 任务完成数量 + int taskOverCountPie = 0; + // 任务即将超期数量 + int taskSoonOverdueCountPie = 0; + // 任务超期数量 + int taskOverdueCountPie = 0; + // 任务退回数量 + int taskBackCountPie = 0; + // 任务未完成数量 + int taskIncompleteCountPie = 0; + for(ChartsDTO chartsDTO: pieList) { + if("完成数".equals(chartsDTO.getName())) { + taskOverCountPie += Integer.valueOf(chartsDTO.getDataValue()); + } + if("即将超期数".equals(chartsDTO.getName())) { + taskSoonOverdueCountPie += Integer.valueOf(chartsDTO.getDataValue()); + } + if("超期数".equals(chartsDTO.getName())) { + taskOverdueCountPie += Integer.valueOf(chartsDTO.getDataValue()); + } + if("退回数".equals(chartsDTO.getName())) { + taskBackCountPie += Integer.valueOf(chartsDTO.getDataValue()); + } + if("未完成数".equals(chartsDTO.getName())) { + taskIncompleteCountPie += Integer.valueOf(chartsDTO.getDataValue()); + } + } + pieList.clear(); + setPieData(pieList, taskOverCountPie, taskSoonOverdueCountPie, taskOverdueCountPie, taskBackCountPie, taskIncompleteCountPie); + } + } + + /** + * 填充饼图数据 + * @param pieList + * @param taskOverCountPie + * @param taskSoonOverdueCountPie + * @param taskOverdueCountPie + * @param taskBackCountPie + * @param taskIncompleteCountPie + */ + private void setPieData(List pieList, int taskOverCountPie, int taskSoonOverdueCountPie, + int taskOverdueCountPie, int taskBackCountPie, int taskIncompleteCountPie) { + ChartsDTO chartsDTO = new ChartsDTO(); + chartsDTO.setName("完成数"); + chartsDTO.setDataValue(String.valueOf(taskOverCountPie)); + pieList.add(chartsDTO); + + chartsDTO = new ChartsDTO(); + chartsDTO.setName("即将超期数"); + chartsDTO.setDataValue(String.valueOf(taskSoonOverdueCountPie)); + pieList.add(chartsDTO); + + chartsDTO = new ChartsDTO(); + chartsDTO.setName("超期数"); + chartsDTO.setDataValue(String.valueOf(taskOverdueCountPie)); + + pieList.add(chartsDTO); + chartsDTO = new ChartsDTO(); + chartsDTO.setName("退回数"); + chartsDTO.setDataValue(String.valueOf(taskBackCountPie)); + pieList.add(chartsDTO); + + chartsDTO = new ChartsDTO(); + chartsDTO.setName("未完成数"); + chartsDTO.setDataValue(String.valueOf(taskIncompleteCountPie)); + pieList.add(chartsDTO); + } + + /** + * 数据填充 + * @param startDate + * @param endDate + * @param receiverUserDTOList + * @param taskOverList + * @param taskSoonOverdueList + * @param taskOverdueList + * @param taskBackList + * @param taskIncompleteList + * @param pieList + * @param taskOverCountPie + * @param taskSoonOverdueCountPie + * @param taskOverdueCountPie + * @param taskBackCountPie + * @param taskIncompleteCountPie + * @throws ParseException + */ + private void backData(Date startDate, Date endDate, List receiverUserDTOList, + List taskOverList, List taskSoonOverdueList, + List taskOverdueList, List taskBackList, + List taskIncompleteList, List pieList, + int taskOverCountPie, int taskSoonOverdueCountPie, + int taskOverdueCountPie, int taskBackCountPie, + int taskIncompleteCountPie) throws ParseException { + + int taskSendCount = receiverUserDTOList.size(); + // 任务完成数量 + int taskOverCount = 0; + // 任务完成率 + String taskOverRate; + // 任务即将超期数量 + int taskSoonOverdueCount = 0; + // 任务即将超期率 + String taskSoonOverdueRate; + // 任务超期数量 + int taskOverdueCount = 0; + // 任务超期率 + String taskOverdueRate; + // 任务退回数量 + int taskBackCount = 0; + // 任务退回率 + String taskBackRate; + // 任务未完成数量 + int taskIncompleteCount = 0; + // 任务未完成率 + String taskIncompleteRate; + + if(null != receiverUserDTOList && receiverUserDTOList.size() > 0) { + for (ReceiverUserDTO receiverUserDTO : receiverUserDTOList) { + Date nowDate = df.parse(receiverUserDTO.getDistributeDeadline()); + boolean isOver = isEffectiveDate(nowDate, startDate, endDate); + if (isOver) { + if ("正常".equals(receiverUserDTO.getTaskType()) && "完成".equals(receiverUserDTO.getExecuteStatus()) && "已通过".equals(receiverUserDTO.getCheckStatus())) { + taskOverCount++; + taskOverCountPie++; + } + if ("即将超期".equals(receiverUserDTO.getTaskType())) { + taskSoonOverdueCount++; + taskSoonOverdueCountPie++; + } + if ("已超期".equals(receiverUserDTO.getTaskType()) && !"已回退".equals(receiverUserDTO.getCheckStatus())) { + taskOverdueCount++; + taskOverdueCountPie++; + } + if ("已回退".equals(receiverUserDTO.getCheckStatus())) { + System.out.println("-------------------"); + System.out.println(receiverUserDTO.toString()); + System.out.println("-------------------"); + taskBackCount++; + taskBackCountPie++; + } + if ("正常".equals(receiverUserDTO.getTaskType()) && "未完成".equals(receiverUserDTO.getExecuteStatus())) { + taskIncompleteCount++; + taskIncompleteCountPie++; + } + } + } + } + + /*System.out.println("---------------"); + System.out.println(taskOverCountPie); + System.out.println(taskSoonOverdueCountPie); + System.out.println(taskOverdueCountPie); + System.out.println(taskBackCountPie); + System.out.println("---------------");*/ + + setPieData(pieList, taskOverCountPie, taskSoonOverdueCountPie, taskOverdueCountPie, taskBackCountPie, taskIncompleteCountPie); + + // 计算率 + taskOverRate = String.format("%.2f", ((float) taskOverCount / taskSendCount * 100)); + taskSoonOverdueRate = String.format("%.2f", ((float) taskSoonOverdueCount / taskSendCount * 100)); + taskOverdueRate = String.format("%.2f", ((float) taskOverdueCount / taskSendCount * 100)); + taskBackRate = String.format("%.2f", ((float) taskBackCount / taskSendCount * 100)); + taskIncompleteRate = String.format("%.2f", ((float) taskIncompleteCount / taskSendCount * 100)); + + // 数据填充 + ChartsDTO taskOverDTO = new ChartsDTO(); + taskOverDTO.setName("完成率"); + taskOverDTO.setDataValue(taskOverRate); + taskOverList.add(taskOverDTO); + + ChartsDTO taskSoonOverdueDTO = new ChartsDTO(); + taskSoonOverdueDTO.setName("即将超期率"); + taskSoonOverdueDTO.setDataValue(taskSoonOverdueRate); + taskSoonOverdueList.add(taskSoonOverdueDTO); + + ChartsDTO taskOverdueDTO = new ChartsDTO(); + taskOverdueDTO.setName("超期率"); + taskOverdueDTO.setDataValue(taskOverdueRate); + taskOverdueList.add(taskOverdueDTO); + + ChartsDTO taskBackDTO = new ChartsDTO(); + taskBackDTO.setName("退回率"); + taskBackDTO.setDataValue(taskBackRate); + taskBackList.add(taskBackDTO); + + ChartsDTO taskIncompleteDTO = new ChartsDTO(); + taskIncompleteDTO.setName("未完成率"); + taskIncompleteDTO.setDataValue(taskIncompleteRate); + taskIncompleteList.add(taskIncompleteDTO); + } + + /** + * 遍历数据集合,并拼接成字符串 + * 主要用于图表功能 + * @param chartsDTOList + * @return + */ + private void setBackData(List chartsDTOList, Map params) { + if(null != chartsDTOList && chartsDTOList.size() > 0) { + String dataValue = ""; + for(ChartsDTO chartsDTO: chartsDTOList) { + dataValue += chartsDTO.getDataValue() + ","; + } + dataValue = dataValue.substring(0, dataValue.length()-1); + params.put(chartsDTOList.get(0).getName(), dataValue); + } } /** @@ -726,6 +1059,7 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri iterator.remove(); continue; } + dateNum = DateUtils.compareDate(params.get("startTime").toString(), null, 1); } else if (!StringHandler.isNull(params.get("endTime")) && StringHandler.isNull(params.get("startTime"))) { Date nowTime = df.parse(receiverUserDTO.getDistributeDeadline()); Date startTime = new Date(); @@ -736,7 +1070,8 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri iterator.remove(); continue; } - } else if (!StringHandler.isNull(params.get("endTime")) && !StringHandler.isNull(params.get("endTime"))) { + dateNum = DateUtils.compareDate(df.format(startTime), params.get("endTime").toString(), 1); + } else if (!StringHandler.isNull(params.get("startTime")) && !StringHandler.isNull(params.get("endTime"))) { Date nowTime = df.parse(receiverUserDTO.getDistributeDeadline()); Date startTime = df.parse(params.get("startTime").toString()); Date endTime = df.parse(params.get("endTime").toString()); @@ -746,6 +1081,7 @@ public class DistributeServiceImpl extends DefaultBaseService implements IDistri iterator.remove(); continue; } + dateNum = DateUtils.compareDate(params.get("startTime").toString(), params.get("endTime").toString(), 1); } else { Date nowDate = df.parse(receiverUserDTO.getDistributeDeadline()); boolean isOver = isEffectiveDate(nowDate, startDate, endDate); diff --git a/src/main/java/cn/com/tenlion/systemtask/service/receiveruser/impl/ReceiverUserServiceImpl.java b/src/main/java/cn/com/tenlion/systemtask/service/receiveruser/impl/ReceiverUserServiceImpl.java index 34b2d8e..b072c1d 100644 --- a/src/main/java/cn/com/tenlion/systemtask/service/receiveruser/impl/ReceiverUserServiceImpl.java +++ b/src/main/java/cn/com/tenlion/systemtask/service/receiveruser/impl/ReceiverUserServiceImpl.java @@ -14,8 +14,10 @@ import cn.com.tenlion.systemtask.service.distribute.IDistributeService; import cn.com.tenlion.systemtask.service.distributesub.IDistributeSubService; import cn.com.tenlion.systemtask.service.receiveruser.IReceiverUserService; import cn.com.tenlion.systemtask.service.urge.IUrgeService; +import cn.com.tenlion.systemtask.utils.StringHandler; import ink.wgink.common.base.DefaultBaseService; import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.app.AppTokenUser; import ink.wgink.pojo.result.SuccessResultList; import ink.wgink.properties.ApiPathProperties; import ink.wgink.util.date.DateUtil; @@ -169,10 +171,15 @@ public class ReceiverUserServiceImpl extends DefaultBaseService implements IRece @Override public List list(Map params) { try{ - if(!StringUtils.isEmpty(params.get("userId").toString())) { + if(!StringHandler.isNull(params.get("userId"))) { String[] userId = params.get("userId").toString().split(","); params.put("userIds", Arrays.asList(userId)); } + if(!StringHandler.isNull(params.get("token"))) { + String token = params.get("token").toString(); + AppTokenUser appTokenUser = getAppTokenUser(token); + params.put("userId", appTokenUser.getId()); + } }catch (Exception e) { } diff --git a/src/main/java/cn/com/tenlion/systemtask/service/urge/impl/UrgeServiceImpl.java b/src/main/java/cn/com/tenlion/systemtask/service/urge/impl/UrgeServiceImpl.java index 26ef251..007c396 100644 --- a/src/main/java/cn/com/tenlion/systemtask/service/urge/impl/UrgeServiceImpl.java +++ b/src/main/java/cn/com/tenlion/systemtask/service/urge/impl/UrgeServiceImpl.java @@ -8,7 +8,9 @@ import cn.com.tenlion.systemtask.pojo.vos.urge.UrgeVO; import cn.com.tenlion.systemtask.service.urge.IUrgeService; import ink.wgink.common.base.DefaultBaseService; import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.bos.UserInfoBO; import ink.wgink.pojo.result.SuccessResultList; +import ink.wgink.util.date.DateUtil; import ink.wgink.util.map.HashMapUtil; import ink.wgink.util.UUIDUtil; import com.github.pagehelper.PageHelper; @@ -52,10 +54,23 @@ public class UrgeServiceImpl extends DefaultBaseService implements IUrgeService String urgeId = UUIDUtil.getUUID(); Map params = HashMapUtil.beanToMap(urgeVO); params.put("urgeId", urgeId); - if (StringUtils.isBlank(token)) { - setSaveInfo(params); - } else { - setAppSaveInfo(token, params); + try { + if (null == securityComponent) { + if (StringUtils.isBlank(token)) { + setSaveInfo(params); + } else { + setAppSaveInfo(token, params); + } + } else { + String currentDate = DateUtil.getTime(); + params.put("creator", 1); + params.put("gmtCreate", currentDate); + params.put("modifier", 1); + params.put("gmtModified", currentDate); + params.put("isDelete", 0); + } + }catch (Exception e) { + } urgeDao.save(params); return urgeId; diff --git a/src/main/java/cn/com/tenlion/systemtask/utils/DateUtils.java b/src/main/java/cn/com/tenlion/systemtask/utils/DateUtils.java index e34ed9c..f4e28a4 100644 --- a/src/main/java/cn/com/tenlion/systemtask/utils/DateUtils.java +++ b/src/main/java/cn/com/tenlion/systemtask/utils/DateUtils.java @@ -2,8 +2,11 @@ package cn.com.tenlion.systemtask.utils; /** * Calendar操作Date + * * @author renpc */ + +import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; @@ -13,6 +16,7 @@ public class DateUtils { /**设置初始值*/ private static Calendar cal; + private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); /** * 根据当前系统时区定义Calendar @@ -21,6 +25,22 @@ public class DateUtils { cal = Calendar.getInstance(); } + /** + * 比较两个日期是否相等 + * @param startDate + * @param endDate + * @return + */ + public static boolean DateEqual(Date startDate, Date endDate) { + String startTime = sdf.format(startDate); + String endTime = sdf.format(endDate); + if(startTime.equals(endTime)) { + return true; + }else { + return false; + } + } + /** * 获取date的月份的时间范围 * @param date @@ -44,7 +64,7 @@ public class DateUtils { * 根据指定日期获取当前属于第几个季度 * @param date */ - public static int getNowQuarter(Date date){ + public static int getNowQuarter(Date date) { cal.setTime(date); int month = cal.get(Calendar.MONTH) + 1; int quarter = 0; @@ -68,19 +88,19 @@ public class DateUtils { public static DateRange returnQuarterCurrent(int year, int quarter) { Calendar startCalendar = Calendar.getInstance(); Calendar endCalendar = Calendar.getInstance(); - if(quarter == 1) { - startCalendar.set(year, 1-1, 1, 00, 00, 00); - endCalendar.set(year, 3-1,31, 23,59,59); - }else if(quarter == 2) { - startCalendar.set(year, 4-1, 1, 00, 00, 00); - endCalendar.set(year, 6-1,30, 23,59,59); - }else if(quarter == 3) { - startCalendar.set(year, 7-1, 1, 00, 00, 00); - endCalendar.set(year, 9-1,30, 23,59,59); - }else { - startCalendar.set(year, 10-1, 1, 00, 00, 00); - endCalendar.set(year, 12-1,31, 23,59,59); - } + if (quarter == 1) { + startCalendar.set(year, 1 - 1, 1, 00, 00, 00); + endCalendar.set(year, 3 - 1, 31, 23, 59, 59); + } else if (quarter == 2) { + startCalendar.set(year, 4 - 1, 1, 00, 00, 00); + endCalendar.set(year, 6 - 1, 30, 23, 59, 59); + } else if (quarter == 3) { + startCalendar.set(year, 7 - 1, 1, 00, 00, 00); + endCalendar.set(year, 9 - 1, 30, 23, 59, 59); + } else { + startCalendar.set(year, 10 - 1, 1, 00, 00, 00); + endCalendar.set(year, 12 - 1, 31, 23, 59, 59); + } return new DateRange(startCalendar.getTime(), endCalendar.getTime()); } @@ -122,7 +142,7 @@ public class DateUtils { * 获取当前月份的时间范围 * @return */ - public static DateRange getThisMonth(){ + public static DateRange getThisMonth() { Calendar startCalendar = Calendar.getInstance(); startCalendar.set(Calendar.DAY_OF_MONTH, 1); setMinTime(startCalendar); @@ -138,7 +158,7 @@ public class DateUtils { * 获取上个月的时间范围 * @return */ - public static DateRange getLastMonth(){ + public static DateRange getLastMonth() { Calendar startCalendar = Calendar.getInstance(); startCalendar.add(Calendar.MONTH, -1); startCalendar.set(Calendar.DAY_OF_MONTH, 1); @@ -153,11 +173,11 @@ public class DateUtils { } /** - * 获取指定月的时间范围 + * 获取指定当前年份月的时间范围 * month:-1是前一个月,-2是前二个月。+1是推后一个月。以此类推 * @return */ - public static DateRange getAppointMonth(int month){ + public static DateRange getAppointMonth(int month) { Calendar startCalendar = Calendar.getInstance(); startCalendar.add(Calendar.MONTH, month); startCalendar.set(Calendar.DAY_OF_MONTH, 1); @@ -189,14 +209,70 @@ public class DateUtils { return new DateRange(startCalendar.getTime(), endCalendar.getTime()); } - private static void setMinTime(Calendar calendar){ + /** + * @param date1 需要比较的时间 不能为空(null),需要正确的日期格式 + * @param date2 被比较的时间 为空(null)则为当前时间 + * @param stype 返回值类型 0为多少天,1为多少个月,2为多少年 + * @return + */ + public static int compareDate(String date1, String date2, int stype) { + int n = 0; + + String[] u = {"天", "月", "年"}; + String formatStyle = stype == 1 ? "yyyy-MM" : "yyyy-MM-dd"; + + date2 = date2 == null ? DateUtils.getCurrentDate() : date2; + + DateFormat df = new SimpleDateFormat(formatStyle); + Calendar c1 = Calendar.getInstance(); + Calendar c2 = Calendar.getInstance(); + try { + c1.setTime(df.parse(date1)); + c2.setTime(df.parse(date2)); + } catch (Exception e3) { + System.out.println("wrong occured"); + } + // 循环对比,直到相等,n 就是所要的结果 + while (!c1.after(c2)) { + n++; + if (stype == 1) { + // 比较月份,月份+1 + c1.add(Calendar.MONTH, 1); + } else { + // 比较天数,日期+1 + c1.add(Calendar.DATE, 1); + } + } + + n = n - 1; + + if (stype == 2) { + n = (int) n / 365; + } + + System.out.println(date1 + " -- " + date2 + " 相差多少" + u[stype] + ":" + n); + return n; + } + + /** + * 得到当前日期 + * @return + */ + public static String getCurrentDate() { + Calendar c = Calendar.getInstance(); + Date date = c.getTime(); + SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd"); + return simple.format(date); + } + + private static void setMinTime(Calendar calendar) { calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); } - private static void setMaxTime(Calendar calendar){ + private static void setMaxTime(Calendar calendar) { calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMaximum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMaximum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMaximum(Calendar.SECOND)); @@ -205,34 +281,26 @@ public class DateUtils { public final static String DEFAULT_PATTERN = "MM/dd/yyyy HH:mm:ss"; - public static String format(Date date){ + + public static String format(Date date) { SimpleDateFormat sdf = new SimpleDateFormat(DEFAULT_PATTERN); return sdf.format(date); } public static void main(String[] args) { - - //DateRange currentQuarter = getThisQuarter(); - //System.out.println("当前季度的时间范围: "+DateUtilsTemp.format(currentQuarter.getStart())+" - "+DateUtilsTemp.format(currentQuarter.getEnd())); - - - DateRange yesterdayRange = getYesterdayRange(); - //System.out.println("昨天的时间范围: "+DateUtilsTemp.format(yesterdayRange.getStart())+" - "+DateUtilsTemp.format(yesterdayRange.getEnd())); - - DateRange thisMonth = getThisMonth(); - //System.out.println("当前月份的时间范围: "+DateUtilsTemp.format(thisMonth.getStart())+" - "+DateUtilsTemp.format(thisMonth.getEnd())); - - DateRange lastMonth = getLastMonth(); - //System.out.println("上个月的时间范围: "+DateUtilsTemp.format(lastMonth.getStart())+" - "+DateUtilsTemp.format(lastMonth.getEnd())); - - DateRange lastQuarter = getLastQuarter(); - //System.out.println("上个季度的时间范围: "+DateUtilsTemp.format(lastQuarter.getStart())+" - "+DateUtilsTemp.format(lastQuarter.getEnd())); - - DateRange dateRange = returnQuarterCurrent(2020, 5); - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - System.out.println(df.format(dateRange.getStart())); - System.out.println(df.format(dateRange.getEnd())); - - + int dateNum = 10; + int monthTime = 10; + int yearTime = 2020; + String xAxisValue = ""; + int j = 0; + for(int i=1;i<=dateNum;i++) { + if (monthTime > 12) { + yearTime += 1; + monthTime = 1; + } + xAxisValue += yearTime + "年-" + monthTime + "月" + ","; + monthTime++; + } + System.out.println(xAxisValue); } } \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/receiveruser/receiver-user-mapper.xml b/src/main/resources/mybatis/mapper/receiveruser/receiver-user-mapper.xml index 23fcd89..b30567f 100644 --- a/src/main/resources/mybatis/mapper/receiveruser/receiver-user-mapper.xml +++ b/src/main/resources/mybatis/mapper/receiveruser/receiver-user-mapper.xml @@ -22,6 +22,8 @@ + + @@ -37,6 +39,8 @@ + + @@ -52,6 +56,8 @@ + + @@ -69,6 +75,8 @@ task_type, check_status, reason, + is_warning, + is_supervision, creator, gmt_create, modifier, @@ -87,6 +95,8 @@ #{taskType}, #{checkStatus}, #{reason}, + #{is_warning}, + #{is_supervision}, #{creator}, #{gmtCreate}, #{modifier}, @@ -147,6 +157,12 @@ ,reason = #{reason} + + ,is_warning = #{isWarning} + + + ,is_supervision = #{isSupervision} + WHERE 1 = 1 @@ -212,6 +228,12 @@ reason = #{reason}, + + + is_warning = #{isWarning}, + + + is_supervision = #{isSupervision}, gmt_modified = #{gmtModified}, modifier = #{modifier}, @@ -234,6 +256,8 @@ t1.task_type, t1.check_status, t1.reason, + t1.is_warning, + t1.is_supervision, t1.receiver_user_id FROM task_receiver_user t1 @@ -259,6 +283,8 @@ t1.task_score, t1.task_type, t1.check_status, + t1.is_warning, + t1.is_supervision, t1.reason FROM task_receiver_user t1 @@ -284,6 +310,8 @@ t1.task_score, t1.task_type, t1.check_status, + t1.is_warning, + t1.is_supervision, t1.reason FROM task_receiver_user t1 @@ -317,6 +345,8 @@ t2.distribute_deadline, t2.days, t2.hours, + t1.is_warning, + t1.is_supervision, 1 FROM task_receiver_user t1 LEFT JOIN task_distribute t2 ON t1.distribute_id = t2.distribute_id AND t2.is_delete = 0 @@ -331,9 +361,21 @@ OR t2.task_area4_name LIKE CONCAT('%', #{keywords}, '%') OR t2.task_area5_name LIKE CONCAT('%', #{keywords}, '%') OR t2.mission_location LIKE CONCAT('%', #{keywords}, '%') - OR t1.distribute_title LIKE CONCAT('%', #{keywords}, '%') + OR t2.distribute_title LIKE CONCAT('%', #{keywords}, '%') ) + + AND + t1.user_id = #{userId} + + + AND + t1.is_warning = #{isWarning} + + + AND + t1.is_supervision = #{isSupervision} + AND t1.distribute_id = #{distributeId} @@ -425,6 +467,8 @@ t1.task_score, t1.task_type, t1.check_status, + t1.is_warning, + t1.is_supervision, t1.reason FROM task_receiver_user t1 @@ -458,6 +502,8 @@ t1.task_score, t1.task_type, t1.check_status, + t1.is_warning, + t1.is_supervision, t1.reason FROM task_receiver_user t1 diff --git a/src/main/resources/mybatis/mapper/receiveruserpatrol/receiver-user-patrol-mapper.xml b/src/main/resources/mybatis/mapper/receiveruserpatrol/receiver-user-patrol-mapper.xml index 46a575a..72f54d2 100644 --- a/src/main/resources/mybatis/mapper/receiveruserpatrol/receiver-user-patrol-mapper.xml +++ b/src/main/resources/mybatis/mapper/receiveruserpatrol/receiver-user-patrol-mapper.xml @@ -3,6 +3,8 @@ + + diff --git a/src/main/resources/templates/distribute/charts.html b/src/main/resources/templates/distribute/charts.html index 9d369f1..17db91a 100644 --- a/src/main/resources/templates/distribute/charts.html +++ b/src/main/resources/templates/distribute/charts.html @@ -21,7 +21,10 @@
- + +
+
+
@@ -41,15 +44,16 @@
+
- - -
+
+
@@ -75,26 +79,23 @@ var selectedAreaArray = []; var app = {}; - function charts() { - var chartDom = document.getElementById('main'); - var myChart = echarts.init(chartDom); - var option; - + // 柱状图 + function barCharts(data) { const posList = [ - 'left', - 'right', - 'top', - 'bottom', - 'inside', - 'insideTop', - 'insideLeft', - 'insideRight', - 'insideBottom', - 'insideTopLeft', - 'insideTopRight', - 'insideBottomLeft', - 'insideBottomRight' - ]; + 'left', + 'right', + 'top', + 'bottom', + 'inside', + 'insideTop', + 'insideLeft', + 'insideRight', + 'insideBottom', + 'insideTopLeft', + 'insideTopRight', + 'insideBottomLeft', + 'insideBottomRight' + ]; app.configParameters = { rotate: { min: -90, @@ -164,96 +165,148 @@ align: app.config.align, verticalAlign: app.config.verticalAlign, rotate: app.config.rotate, - formatter: '{c} {name|{a}}', + formatter: '{b}:{c}%', fontSize: 16, rich: { name: {} } }; - option = { - tooltip: { - trigger: 'axis', - axisPointer: { - type: 'shadow' + + var xAxisValue; + var series = []; + if(!$.isEmptyObject(data)) { + if(null != data.xAxisValue && '' != data.xAxisValue && typeof(data.xAxisValue) != 'undefined') { + xAxisValue = data.xAxisValue.split(','); + delete data.xAxisValue; + } + for(let key in data) { + if('pieData' != key) { + series.push({ + name: key, + type: 'bar', + // 不同系列的柱间距离,为百分比(如 '30%',表示柱子宽度的 30%)。 + // 如果想要两个系列的柱子重叠,可以设置 barGap 为 '-100%'。这在用柱子做背景的时候有用。 + // 在同一坐标系上,此属性会被多个 'bar' 系列共享。此属性应设置于此坐标系中最后一个 'bar' 系列上才会生效,并且是对此坐标系中所有 'bar' 系列生效。 + barGap: 0, + label: labelOption, + emphasis: { + focus: 'series' + }, + data: data[key].split(',') + }) } + } + + var chartDom = document.getElementById('barDiv'); + var myChart = echarts.init(chartDom); + var option; + + option = { + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow' + } + }, + legend: { + data: ['退回率', '未完成率', '超期率', '即将超期率', '完成率'] + }, + toolbox: { + show: true, + orient: 'vertical', + left: 'right', + top: 'center', + feature: { + mark: { show: true }, + dataView: { show: true, readOnly: false }, + magicType: { show: true, type: ['bar', 'stack'] }, + restore: { show: true }, + saveAsImage: { show: true } + } + }, + xAxis: [ + { + type: 'category', + axisTick: { show: false }, + data: xAxisValue + } + ], + yAxis: [ + { + type: 'value' + } + ], + series: series + }; + + option && myChart.setOption(option); + }else { + top.dialog.msg('该条件下暂无数据'); + } + myChart.on('click', function (param) { + console.log(param) + }); + } + + // 饼图 + function pieCharts(data) { + var chartDom = document.getElementById('main'); + var myChart = echarts.init(chartDom); + var option; + + var pieData = []; + + if(!$.isEmptyObject(data)) { + var pieDataArr = data.pieData; + if(null != pieDataArr && pieDataArr.length > 0) { + for(let key in pieDataArr) { + pieData.push({ + name: pieDataArr[key]['name'], + value: pieDataArr[key]['dataValue'] + }) + } + } + } + console.log(pieData) + + option = { + title: { + text: '任务完成情况', + left: 'center' + }, + tooltip: { + trigger: 'item' }, legend: { - data: ['Forest', 'Steppe', 'Desert', 'Wetland'] - }, - toolbox: { - show: true, orient: 'vertical', - left: 'right', - top: 'center', - feature: { - mark: { show: true }, - dataView: { show: true, readOnly: false }, - magicType: { show: true, type: ['bar', 'stack'] }, - restore: { show: true }, - saveAsImage: { show: true } - } + left: 'left' }, - xAxis: [ - { - type: 'category', - axisTick: { show: false }, - data: ['2012', '2013', '2014', '2015', '2016'] - } - ], - yAxis: [ - { - type: 'value' - } - ], series: [ { - name: 'Forest', - type: 'bar', - barGap: 0, - label: labelOption, + name: '任务数据', + type: 'pie', + radius: '50%', + data: pieData, emphasis: { - focus: 'series' - }, - data: [320, 332, 301, 334, 390] - }, - { - name: 'Steppe', - type: 'bar', - label: labelOption, - emphasis: { - focus: 'series' - }, - data: [220, 182, 191, 234, 290] - }, - { - name: 'Desert', - type: 'bar', - label: labelOption, - emphasis: { - focus: 'series' - }, - data: [150, 232, 201, 154, 190] - }, - { - name: 'Wetland', - type: 'bar', - label: labelOption, - emphasis: { - focus: 'series' - }, - data: [98, 77, 101, 99, 40] + itemStyle: { + shadowBlur: 10, + shadowOffsetX: 0, + shadowColor: 'rgba(0, 0, 0, 0.5)' + } + } } ] }; option && myChart.setOption(option); } - charts(); function initData() { + var layIndex; top.restAjax.get(top.restAjax.path(tableUrl, ['已下派']), {}, null, function (code, data) { - console.log(data) - // reloadTable(); + console.log(data.data) + barCharts(data.data); + pieCharts(data.data); }, function (code, data) { top.dialog.msg(data.msg); }, function () { @@ -325,24 +378,31 @@ // 重载表格 function reloadTable(currentPage) { - table.reload('dataTable', { - url: top.restAjax.path(tableUrl, ['未下派']), - where: { - keywords: $('#keywords').val(), - distributeDeadline: $('#distributeDeadline').val(), - taskArea1Id: $('#areaId_1').val(), - taskArea2Id: $('#areaId_2').val(), - taskArea3Id: $('#areaId_3').val(), - taskArea4Id: $('#areaId_4').val(), - taskArea5Id: $('#areaId_5').val(), - userId: $('#userId').val(), - urgentLevel: $('#urgentLevel').val(), - reportCount: $('#reportCount').val(), - }, - page: { - curr: currentPage - }, - height: $win.height() - 90, + var layIndex; + top.restAjax.get(top.restAjax.path(tableUrl, ['已下派']), { + keywords: $('#keywords').val(), + // distributeDeadline: $('#distributeDeadline').val(), + startTime: $('#startTime').val(), + endTime: $('#endTime').val(), + taskArea1Id: $('#areaId_1').val(), + taskArea1Id: $('#areaId_1').val(), + taskArea2Id: $('#areaId_2').val(), + taskArea3Id: $('#areaId_3').val(), + taskArea4Id: $('#areaId_4').val(), + taskArea5Id: $('#areaId_5').val(), + userId: $('#userId').val(), + urgentLevel: $('#urgentLevel').val(), + reportCount: $('#reportCount').val(), + }, null, function (code, data) { + console.log(data.data) + barCharts(data.data); + pieCharts(data.data); + }, function (code, data) { + top.dialog.msg(data.msg); + }, function () { + layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3}); + }, function () { + top.dialog.close(layIndex); }); } @@ -351,11 +411,11 @@ // 日期选择 laydate.render({ elem: '#startTime', - format: 'yyyy-MM-dd' + format: 'yyyy-MM-dd HH:mm:ss' }); laydate.render({ elem: '#endTime', - format: 'yyyy-MM-dd' + format: 'yyyy-MM-dd HH:mm:ss' }); } @@ -374,6 +434,23 @@ reloadTable(1); }); + // 事件 - 清空搜索条件 + $(document).on('click', '#reset', function() { + $('#keywords').val(''); + $('#startTime').val(''); + $('#endTime').val(''); + $('#area').val(''); + $('#areaId_1').val(''); + $('#areaId_2').val(''); + $('#areaId_3').val(''); + $('#areaId_4').val(''); + $('#areaId_5').val(''); + $('#receiverUser').val(''); + $('#userId').val(''); + $('#urgentLevel').val(''); + $('#reportCount').val(''); + }); + }); diff --git a/src/main/resources/templates/receiveruser/list.html b/src/main/resources/templates/receiveruser/list.html index 86c59aa..5c477f2 100644 --- a/src/main/resources/templates/receiveruser/list.html +++ b/src/main/resources/templates/receiveruser/list.html @@ -454,33 +454,16 @@ return rowData; } }, - {field: 'reassignment', fixed: 'right', width: 90, title: '转派', align:'center', + {field: '', fixed: 'right', width: 300, title: '操作', align:'center', templet: function(row) { - var rowData = '转派'; - return rowData; - } - }, - {field: 'check', fixed: 'right', width: 90, title: '审核', align:'center', - templet: function(row) { - var rowData = '审核'; - return rowData; - } - }, - {field: 'taskStatus', fixed: 'right', width: 90, title: '执行状态', align:'center', - templet: function(row) { - var rowData = '执行状态'; - return rowData; - } - }, - {field: 'taskPatrol', fixed: 'right', width: 90, title: '任务记录', align:'center', - templet: function(row) { - var rowData = '任务记录'; - return rowData; - } - }, - {field: 'addScore', fixed: 'right', width: 90, title: '评分', align:'center', - templet: function(row) { - var rowData = '评分'; + var rowData = '
\n' + + ' 转派\n' + + ' 审核\n' + + ' 执行状态\n' + + ' 任务记录\n' + + ' 预警\n' + + ' 督办\n' + + '
'; return rowData; } } @@ -729,6 +712,10 @@ addScore(data['receiverUserId']); }else if('taskPatrol' == obj.event) { taskPatrol(data['receiverUserId']); + }else if('isWarning' == obj.event) { + isWarning(data['receiverUserId']); + }else if('isSupervision' == obj.event) { + isSupervision(data['receiverUserId']); } }); @@ -769,6 +756,50 @@ }); } + // 预警 + function isWarning(receiverUserId) { + top.dialog.msg('确定预警?', { + time: 0, + btn: [top.dataMessage.button.yes, top.dataMessage.button.no], + shade: 0.3, + yes: function (index) { + var layIndex; + top.restAjax.delete(top.restAjax.path('api/receiveruser/back/{receiverUserId}?isWarning={isWarning}', [receiverUserId, 1]), {}, null, function (code, data) { + top.dialog.msg('预警成功', {time: 1000}); + reloadTable(); + }, function (code, data) { + top.dialog.msg(data.msg); + }, function () { + layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3}); + }, function () { + top.dialog.close(layIndex); + }); + } + }); + } + + // 督办 + function isSupervision(receiverUserId) { + top.dialog.msg('确定督办?', { + time: 0, + btn: [top.dataMessage.button.yes, top.dataMessage.button.no], + shade: 0.3, + yes: function (index) { + var layIndex; + top.restAjax.delete(top.restAjax.path('api/receiveruser/back/{receiverUserId}?isSupervision={isSupervision}', [receiverUserId, 1]), {}, null, function (code, data) { + top.dialog.msg('督办成功', {time: 1000}); + reloadTable(); + }, function (code, data) { + top.dialog.msg(data.msg); + }, function () { + layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3}); + }, function () { + top.dialog.close(layIndex); + }); + } + }); + } + // 退回 function check(receiverUserIds) { layer.confirm('审核状态', {