Commit 00e630ff810bbd6f75b6b31666bb0e73b705a394
1 parent
c2082068
feat:一次性通过率
Showing
4 changed files
with
60 additions
and
0 deletions
src/main/java/com/order/erp/common/constant/Constant.java
@@ -166,6 +166,7 @@ public class Constant { | @@ -166,6 +166,7 @@ public class Constant { | ||
166 | public static final int TWENTY_FIRST = 21; | 166 | public static final int TWENTY_FIRST = 21; |
167 | 167 | ||
168 | 168 | ||
169 | + public static final int HUNDRED=100; | ||
169 | public static final int THOUSAND = 1000; | 170 | public static final int THOUSAND = 1000; |
170 | 171 | ||
171 | public static final String DATE_TIME = "yyyy-MM-dd HH:mm:ss"; | 172 | public static final String DATE_TIME = "yyyy-MM-dd HH:mm:ss"; |
src/main/java/com/order/erp/controller/OrderController.java
@@ -156,5 +156,19 @@ public class OrderController { | @@ -156,5 +156,19 @@ public class OrderController { | ||
156 | public ServerResult check(@RequestBody OrderBaseInfoQueryVO orderBaseInfoQueryVO) { | 156 | public ServerResult check(@RequestBody OrderBaseInfoQueryVO orderBaseInfoQueryVO) { |
157 | return orderBaseInfoService.check(orderBaseInfoQueryVO); | 157 | return orderBaseInfoService.check(orderBaseInfoQueryVO); |
158 | } | 158 | } |
159 | + | ||
160 | + | ||
161 | + /** | ||
162 | + * 一次性通过率 | ||
163 | + * | ||
164 | + * @param orderOpinionLogVO 查询条件 | ||
165 | + * @return 查询结果 | ||
166 | + */ | ||
167 | + @PostMapping("/passRate") | ||
168 | + @AnonymousAccess | ||
169 | + public ServerResult oneTimePassRate(@RequestBody OrderOpinionLogVO orderOpinionLogVO) { | ||
170 | + return orderBaseInfoService.passRate(orderOpinionLogVO); | ||
171 | + } | ||
172 | + | ||
159 | } | 173 | } |
160 | 174 |
src/main/java/com/order/erp/service/order/OrderBaseInfoService.java
@@ -101,6 +101,14 @@ public interface OrderBaseInfoService extends IService<OrderBaseInfoDO> { | @@ -101,6 +101,14 @@ public interface OrderBaseInfoService extends IService<OrderBaseInfoDO> { | ||
101 | */ | 101 | */ |
102 | ServerResult deleteById(OrderBaseInfoQueryVO orderBaseInfoQueryVO); | 102 | ServerResult deleteById(OrderBaseInfoQueryVO orderBaseInfoQueryVO); |
103 | 103 | ||
104 | + /** | ||
105 | + * 通过orderId计算订单的一次性通过率 | ||
106 | + * | ||
107 | + * @param orderOpinionLogVO 筛选条件 | ||
108 | + * @return 是否成功 | ||
109 | + */ | ||
110 | + ServerResult passRate(OrderOpinionLogVO orderOpinionLogVO); | ||
111 | + | ||
104 | long countByOrderStatus(Integer orderFinish); | 112 | long countByOrderStatus(Integer orderFinish); |
105 | 113 | ||
106 | long countRecentMonthByOrderStatus(Integer orderFinish); | 114 | long countRecentMonthByOrderStatus(Integer orderFinish); |
@@ -115,4 +123,5 @@ public interface OrderBaseInfoService extends IService<OrderBaseInfoDO> { | @@ -115,4 +123,5 @@ public interface OrderBaseInfoService extends IService<OrderBaseInfoDO> { | ||
115 | ServerResult checkChargeOrderCount(List<Long> orderIds); | 123 | ServerResult checkChargeOrderCount(List<Long> orderIds); |
116 | 124 | ||
117 | List<OrderBaseInfoDO> getEventList(); | 125 | List<OrderBaseInfoDO> getEventList(); |
126 | + | ||
118 | } | 127 | } |
src/main/java/com/order/erp/service/order/impl/OrderBaseInfoServiceImpl.java
@@ -47,6 +47,7 @@ import java.io.InputStream; | @@ -47,6 +47,7 @@ import java.io.InputStream; | ||
47 | import java.math.BigDecimal; | 47 | import java.math.BigDecimal; |
48 | import java.math.RoundingMode; | 48 | import java.math.RoundingMode; |
49 | import java.net.URL; | 49 | import java.net.URL; |
50 | +import java.text.DecimalFormat; | ||
50 | import java.time.LocalDateTime; | 51 | import java.time.LocalDateTime; |
51 | import java.util.*; | 52 | import java.util.*; |
52 | import java.util.function.Function; | 53 | import java.util.function.Function; |
@@ -1985,6 +1986,41 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O | @@ -1985,6 +1986,41 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O | ||
1985 | } | 1986 | } |
1986 | 1987 | ||
1987 | /** | 1988 | /** |
1989 | + * 根据订单orderId计算订单的通过率。 | ||
1990 | + * | ||
1991 | + * @param orderOpinionLogVO | ||
1992 | + * @return | ||
1993 | + */ | ||
1994 | + @Override | ||
1995 | + public ServerResult passRate(OrderOpinionLogVO orderOpinionLogVO) { | ||
1996 | + if(Objects.isNull(orderOpinionLogVO.getOrderId())){ | ||
1997 | + return ServerResult.fail("OrderId 参数不能为空"); | ||
1998 | + } | ||
1999 | + List<OrderOpinionLogDO> orderOpinionLogDOList = orderOpinionLogService.list(new LambdaQueryWrapper<OrderOpinionLogDO>() | ||
2000 | + .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | ||
2001 | + .eq(OrderOpinionLogDO::getOrderId, orderOpinionLogVO.getOrderId()) | ||
2002 | + .eq(OrderOpinionLogDO::getOpinionType, orderOpinionLogVO.getOpinionType())); | ||
2003 | + List<Integer> okCountList= new ArrayList(); | ||
2004 | + List<Integer> FailCountList= new ArrayList(); | ||
2005 | + orderOpinionLogDOList.stream().forEach(x->{ | ||
2006 | + if (x.getField().contains("ok")){ | ||
2007 | + okCountList.add(Constant.ONE); | ||
2008 | + }else{ | ||
2009 | + FailCountList.add(Constant.ZERO); | ||
2010 | + } | ||
2011 | + }); | ||
2012 | + int sum=okCountList.size()+FailCountList.size(); | ||
2013 | + double rate = ((double) okCountList.size() / sum)*Constant.HUNDRED; | ||
2014 | + DecimalFormat decimalFormat = new DecimalFormat("0"); | ||
2015 | + String resultrate = decimalFormat.format(rate); | ||
2016 | + return ServerResult.success(resultrate+"%"); | ||
2017 | + } | ||
2018 | + | ||
2019 | + | ||
2020 | + | ||
2021 | + | ||
2022 | + | ||
2023 | + /** | ||
1988 | * 根据订单状态统计订单数量 | 2024 | * 根据订单状态统计订单数量 |
1989 | * | 2025 | * |
1990 | * @param orderStatus | 2026 | * @param orderStatus |