From d0744f7ef31041274dacb13b21edeffb746c0fc4 Mon Sep 17 00:00:00 2001 From: chen <1251790704@qq.com> Date: Tue, 5 Jan 2021 14:25:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DgEfficiencyController.java | 66 ++++++++++------- .../PersonalEfficiencyListRequest.java | 2 +- .../guarantee/model/response/NumResponse.java | 22 ++++++ .../PersonalEfficiencyListResponse.java | 14 +--- .../daqing/financial/guarantee/util/R.java | 71 +++++++++++++++++++ .../financial/guarantee/util/ResultCode.java | 13 ++++ .../utils/excel/TaskNodeConverter.java | 2 +- 7 files changed, 149 insertions(+), 41 deletions(-) create mode 100644 dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/response/NumResponse.java create mode 100644 dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/util/R.java create mode 100644 dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/util/ResultCode.java diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/DgEfficiencyController.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/DgEfficiencyController.java index ebb70ad4..67136272 100644 --- a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/DgEfficiencyController.java +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/DgEfficiencyController.java @@ -4,9 +4,11 @@ import com.alibaba.fastjson.JSONObject; import com.daqing.financial.guarantee.feign.HrmsFeignService; import com.daqing.financial.guarantee.model.request.DgEfficiencyTeamRequest; import com.daqing.financial.guarantee.model.request.PersonalEfficiencyListRequest; +import com.daqing.financial.guarantee.model.response.NumResponse; import com.daqing.financial.guarantee.model.response.PersonalEfficiencyListResponse; import com.daqing.financial.guarantee.service.IDgEfficiencyService; import com.daqing.financial.guarantee.util.DateUtils; +import com.daqing.financial.guarantee.util.R; import com.daqing.financial.guarantee.util.TaskNodeUtil; import com.daqing.framework.model.StatusCode; import com.daqing.framework.model.response.ResponseResult; @@ -62,7 +64,7 @@ public class DgEfficiencyController { @ApiOperation(value = "个人效率记录列表") @PostMapping("/personalEfficiencyList") - public ResponseResult personalEfficiencyList( + public R personalEfficiencyList( @ApiParam(name = "personalEfficiencyListRequest", value = "个人效率列表查询对象") @RequestBody PersonalEfficiencyListRequest personalEfficiencyListRequest){ List responseList = dgEfficiencyService.queryPersonalEfficiencyList(); @@ -87,23 +89,54 @@ public class DgEfficiencyController { } } } + + NumResponse numResponse = new NumResponse(); + //转换任务节点,并统计操作状态个数 + responseList.forEach(personalEfficiencyListResponse -> { + String taskNode = personalEfficiencyListResponse.getTaskNode(); + if (taskNode!=null){ + String converter = TaskNodeUtil.converter(taskNode); + personalEfficiencyListResponse.setTaskNode(converter); + } + if (personalEfficiencyListResponse.getOperatingStatus()!=null){ + switch (personalEfficiencyListResponse.getOperatingStatus()){ + case 0: + numResponse.setInitiateNum(numResponse.getInitiateNum()+1); + break; + case 1: + numResponse.setPendingNum(numResponse.getPendingNum()+1); + break; + case 2: + numResponse.setProcessedNum(numResponse.getProcessedNum()+1); + break; + default: + numResponse.setInitiateNum(0); + numResponse.setPendingNum(0); + numResponse.setProcessedNum(0); + break; + } + } + }); //根据条件筛选数据 + //迭代器进行筛选 if (personalEfficiencyListRequest.getOperatingStatus()!=null){ // 已发起 if (personalEfficiencyListRequest.getOperatingStatus().equals(StatusCode.CZ_LAUNCH)){ - responseList = responseList.stream().filter(p -> p.getOperatingStatus().equals(StatusCode.CZ_LAUNCH)).collect(Collectors.toList()); + responseList.removeIf(next -> !next.getOperatingStatus().equals(StatusCode.CZ_LAUNCH)); + // responseList = responseList.stream().filter(p -> !p.getOperatingStatus().equals(StatusCode.CZ_LAUNCH)).collect(Collectors.toList()); // 待处理 }else if (personalEfficiencyListRequest.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)){ - responseList = responseList.stream().filter(p -> p.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)).collect(Collectors.toList()); + responseList.removeIf(next -> !next.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)); + // responseList = responseList.stream().filter(p -> !p.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)).collect(Collectors.toList()); // 已处理 }else if (personalEfficiencyListRequest.getOperatingStatus().equals(StatusCode.CZ_PROCESSED)){ - responseList = responseList.stream().filter(p -> p.getOperatingStatus().equals(StatusCode.CZ_PROCESSED)).collect(Collectors.toList()); + responseList.removeIf(next -> !next.getOperatingStatus().equals(StatusCode.CZ_PROCESSED)); + // responseList = responseList.stream().filter(p -> !p.getOperatingStatus().equals(StatusCode.CZ_PROCESSED)).collect(Collectors.toList()); } } - // 时间筛选(固定时间) if (personalEfficiencyListRequest.getCreateFixedTime() != null && personalEfficiencyListRequest.getStartTime() == null && personalEfficiencyListRequest.getEndTime() == null) { - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); switch (personalEfficiencyListRequest.getCreateFixedTime()) { case 0: personalEfficiencyListRequest.setStartTime(dateFormat.format(DateUtils.getDayBegin())); @@ -144,26 +177,7 @@ public class DgEfficiencyController { } } } - //转换任务节点,并统计操作状态个数 - responseList.forEach(personalEfficiencyListResponse -> { - String taskNode = personalEfficiencyListResponse.getTaskNode(); - if (taskNode!=null){ - String converter = TaskNodeUtil.converter(taskNode); - personalEfficiencyListResponse.setTaskNode(converter); - } - if (personalEfficiencyListResponse.getOperatingStatus()!=null){ - switch (personalEfficiencyListResponse.getOperatingStatus()){ - case 0: - personalEfficiencyListResponse.setInitiateNum(personalEfficiencyListResponse.getInitiateNum()+1); - case 1: - personalEfficiencyListResponse.setPendingNum(personalEfficiencyListResponse.getPendingNum()+1); - case 2: - personalEfficiencyListResponse.setProcessedNum(personalEfficiencyListResponse.getProcessedNum()+1); - } - } - }); - - return ResponseResult.SUCCESS(responseList); + return R.ok().data("responseList",responseList).data("statistics",numResponse); } public static long getLongDate(String stringDate){ diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/request/PersonalEfficiencyListRequest.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/request/PersonalEfficiencyListRequest.java index 91571f33..c37fff38 100644 --- a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/request/PersonalEfficiencyListRequest.java +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/request/PersonalEfficiencyListRequest.java @@ -25,6 +25,6 @@ public class PersonalEfficiencyListRequest { @ApiModelProperty("结束时间") private String endTime; - @ApiModelProperty("操作状态") + @ApiModelProperty("操作状态,") private Integer operatingStatus; } diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/response/NumResponse.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/response/NumResponse.java new file mode 100644 index 00000000..69dfd3d3 --- /dev/null +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/response/NumResponse.java @@ -0,0 +1,22 @@ +package com.daqing.financial.guarantee.model.response; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author chen + * @DATE 2021/1/5 11:32 + * @Version 1.0 + */ +@Data +public class NumResponse { + + @ApiModelProperty("发起数") + private Integer initiateNum = 0; + + @ApiModelProperty("待处理数") + private Integer pendingNum = 0; + + @ApiModelProperty("已处理数") + private Integer processedNum = 0; +} diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/response/PersonalEfficiencyListResponse.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/response/PersonalEfficiencyListResponse.java index 50d80a57..0b03da74 100644 --- a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/response/PersonalEfficiencyListResponse.java +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/response/PersonalEfficiencyListResponse.java @@ -21,18 +21,6 @@ public class PersonalEfficiencyListResponse { @ApiModelProperty(value = "业务id") private Integer businessId; - @ExcelIgnore - @ApiModelProperty("发起数") - private Integer initiateNum = 0; - - @ExcelIgnore - @ApiModelProperty("待处理数") - private Integer pendingNum = 0; - - @ExcelIgnore - @ApiModelProperty("已处理数") - private Integer processedNum = 0; - @ExcelIgnore @ApiModelProperty(value = "提单人") private Integer applicantId; @@ -62,7 +50,7 @@ public class PersonalEfficiencyListResponse { private String taskNode; @ApiModelProperty("审批状态") - @ExcelProperty(value = "审核状态",index = 7,converter = ApprovalStatusConverter.class) + @ExcelProperty(value = "审批状态",index = 7,converter = ApprovalStatusConverter.class) private Integer approveStatus; @ApiModelProperty("业务状态") diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/util/R.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/util/R.java new file mode 100644 index 00000000..9e8017b3 --- /dev/null +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/util/R.java @@ -0,0 +1,71 @@ +package com.daqing.financial.guarantee.util; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Author chen + * @DATE 2021/1/5 11:43 + * @Version 1.0 + */ +@Data +public class R { + + @ApiModelProperty(value = "是否成功") + private Boolean success; + + @ApiModelProperty(value = "返回码") + private Integer code; + + @ApiModelProperty(value = "返回消息") + private String message; + + @ApiModelProperty(value = "返回数据") + private Map data = new HashMap(); + + private R(){} + + public static R ok(){ + R r = new R(); + r.setSuccess(true); + r.setCode(ResultCode.SUCCESS); + r.setMessage(ResultCode.SUCCESS_MESSAGE); + return r; + } + + public static R error(){ + R r = new R(); + r.setSuccess(false); + r.setCode(ResultCode.FAILURE); + r.setMessage(ResultCode.FAILURE_MESSAGE); + return r; + } + + public R success(Boolean success){ + this.setSuccess(success); + return this; + } + + public R message(String message){ + this.setMessage(message); + return this; + } + + public R code(Integer code){ + this.setCode(code); + return this; + } + + public R data(String key, Object value){ + this.data.put(key, value); + return this; + } + + public R data(Map map){ + this.setData(map); + return this; + } +} diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/util/ResultCode.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/util/ResultCode.java new file mode 100644 index 00000000..a1c18c85 --- /dev/null +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/util/ResultCode.java @@ -0,0 +1,13 @@ +package com.daqing.financial.guarantee.util; + +/** + * @Author chen + * @DATE 2021/1/5 11:43 + * @Version 1.0 + */ +public interface ResultCode { + Integer SUCCESS = 10000;//成功 + Integer FAILURE = 20000;//失败 + String SUCCESS_MESSAGE = "成功"; + String FAILURE_MESSAGE = "失败"; +} diff --git a/dq-framework-utils/src/main/java/com/daqing/framework/utils/excel/TaskNodeConverter.java b/dq-framework-utils/src/main/java/com/daqing/framework/utils/excel/TaskNodeConverter.java index 234c334e..8df4881c 100644 --- a/dq-framework-utils/src/main/java/com/daqing/framework/utils/excel/TaskNodeConverter.java +++ b/dq-framework-utils/src/main/java/com/daqing/framework/utils/excel/TaskNodeConverter.java @@ -45,7 +45,7 @@ public class TaskNodeConverter implements Converter { * 这里是写的时候会调用 * * @param value - * NotNull + * NotNull * @param contentProperty * Nullable * @param globalConfiguration