Commit ea62f287b3a734958ff5325343f78e3fdbe60fa8

Authored by zhongnanhuang
1 parent 7fe47dff

利润分析接口和首页数据展示接口

src/main/java/com/order/erp/common/utils/ProfitUtils.java
@@ -28,6 +28,6 @@ public class ProfitUtils { @@ -28,6 +28,6 @@ public class ProfitUtils {
28 28
29 BigDecimal customerTotalPrice = new BigDecimal(calculateVO.getCustomerTotalPrice()); 29 BigDecimal customerTotalPrice = new BigDecimal(calculateVO.getCustomerTotalPrice());
30 30
31 - return new BigDecimal(1).subtract((productionDepartmentTotalPrice.divide(exchangeRate).add(packetTotalPrice)).divide(customerTotalPrice)).doubleValue(); 31 + return new BigDecimal(1).subtract((productionDepartmentTotalPrice.divide(exchangeRate,4,BigDecimal.ROUND_HALF_UP).add(packetTotalPrice)).divide(customerTotalPrice,4,BigDecimal.ROUND_HALF_UP)).doubleValue();
32 } 32 }
33 } 33 }
src/main/java/com/order/erp/controller/IndexController.java 0 → 100644
  1 +package com.order.erp.controller;
  2 +
  3 +import com.order.erp.common.constant.ServerResult;
  4 +import com.order.erp.domain.OrderStatusEnum;
  5 +import com.order.erp.domain.vo.IndexDataVO;
  6 +import com.order.erp.service.order.OrderBaseInfoService;
  7 +import com.order.erp.service.order.OrderCompletionReportService;
  8 +import com.order.erp.service.order.OrderInspectionStageService;
  9 +import com.order.erp.service.order.OrderProfitAnalysisService;
  10 +import org.springframework.web.bind.annotation.GetMapping;
  11 +import org.springframework.web.bind.annotation.RequestMapping;
  12 +import org.springframework.web.bind.annotation.RestController;
  13 +
  14 +import javax.annotation.Resource;
  15 +
  16 +/**
  17 + * @author zhongnanhuang
  18 + * @version 1.0
  19 + * @project order-erp
  20 + * @description 首页
  21 + * @date 2023/10/23 16:44:55
  22 + */
  23 +@RestController
  24 +@RequestMapping("/order/erp/index")
  25 +public class IndexController {
  26 +
  27 + @Resource
  28 + OrderBaseInfoService orderBaseInfoService;
  29 +
  30 + @Resource
  31 + OrderInspectionStageService orderInspectionStageService;
  32 +
  33 + @Resource
  34 + OrderProfitAnalysisService orderProfitAnalysisService;
  35 +
  36 + @Resource
  37 + OrderCompletionReportService orderCompletionReportService;
  38 +
  39 + @GetMapping("/data")
  40 + public ServerResult getData(){
  41 + //订单总完成数
  42 + long orderTotalFinished = orderBaseInfoService.countByOrderStatus(OrderStatusEnum.ORDER_FINISH.getStatus());
  43 + //订单当月完成数
  44 + long orderRecentMonthFinished = orderBaseInfoService.countRecentMonthByOrderStatus(OrderStatusEnum.ORDER_FINISH.getStatus());
  45 +
  46 +
  47 + //跟单和质检中
  48 + long inspecting = orderInspectionStageService.countByOrderStatus(OrderStatusEnum.INSPECT_ING.getStatus());
  49 + long recentMonthInspecting = orderInspectionStageService.countRecentMonthByOrderStatus(OrderStatusEnum.INSPECT_ING.getStatus());
  50 +
  51 + //利润分析表待审核
  52 + long orderProfitWaitAudit = orderProfitAnalysisService.countByOrderStatus(OrderStatusEnum.PROFIT_WAIT_AUDIT.getStatus());
  53 + long orderRecentWeekProfitWaitAudit = orderProfitAnalysisService.countRecentWeekByOrderStatus(OrderStatusEnum.PROFIT_WAIT_AUDIT.getStatus());
  54 +
  55 + //项目报告书待审核
  56 + long orderReport = orderCompletionReportService.countByOrderStatus(OrderStatusEnum.REPORT_WAIT_AUDIT.getStatus());
  57 + long orderYearReport = orderCompletionReportService.countYearByOrderStatus(OrderStatusEnum.REPORT_WAIT_AUDIT.getStatus());
  58 +
  59 + //当天订单数据
  60 + IndexDataVO.ChartData chartData = orderBaseInfoService.countHoursFromDay();
  61 +
  62 + IndexDataVO indexDataVo = new IndexDataVO();
  63 + indexDataVo.setOrderFinishedCount(orderTotalFinished);
  64 + indexDataVo.setOrderRecentMonthFinishedCount(orderRecentMonthFinished);
  65 + indexDataVo.setOrderInspectingCount(inspecting);
  66 + indexDataVo.setOrderRecentMonthInspectingCount(recentMonthInspecting);
  67 + indexDataVo.setOrderProfitWaitAuditCount(orderProfitWaitAudit);
  68 + indexDataVo.setOrderRecentWeekProfitWaitAuditCount(orderRecentWeekProfitWaitAudit);
  69 + indexDataVo.setOrderReportWaitAuditCount(orderReport);
  70 + indexDataVo.setOrderReportRecentYearWaitAuditCount(orderYearReport);
  71 + indexDataVo.setChartData(chartData);
  72 +
  73 + return ServerResult.success(indexDataVo);
  74 + }
  75 +}
src/main/java/com/order/erp/controller/OrderProfitController.java 0 → 100644
  1 +package com.order.erp.controller;
  2 +
  3 +import com.order.erp.common.constant.ServerResult;
  4 +import com.order.erp.domain.dto.order.OrderProfitAnalysisDO;
  5 +import com.order.erp.service.order.OrderProfitAnalysisService;
  6 +import org.springframework.web.bind.annotation.PostMapping;
  7 +import org.springframework.web.bind.annotation.RequestBody;
  8 +import org.springframework.web.bind.annotation.RequestMapping;
  9 +import org.springframework.web.bind.annotation.RestController;
  10 +
  11 +import javax.annotation.Resource;
  12 +import java.util.List;
  13 +
  14 +/**
  15 + * @author zhongnanhuang
  16 + * @version 1.0
  17 + * @project order-erp
  18 + * @description 订单利润表控制层
  19 + * @date 2023/10/23 11:48:36
  20 + */
  21 +@RestController
  22 +@RequestMapping("/order/erp/profit")
  23 +public class OrderProfitController {
  24 +
  25 + @Resource
  26 + OrderProfitAnalysisService orderProfitAnalysisService;
  27 +
  28 + @PostMapping("/analysis")
  29 + public ServerResult analysis(@RequestBody List<Long> orderIds){
  30 + if (orderIds==null||orderIds.size()<=0){
  31 + return ServerResult.fail("订单不能为空");
  32 + }
  33 +
  34 + OrderProfitAnalysisDO orderProfitAnalysisDO = orderProfitAnalysisService.analysisByOrderIds(orderIds);
  35 +
  36 + if (orderProfitAnalysisDO==null){
  37 + return ServerResult.fail("找不到订单信息");
  38 + }
  39 +
  40 + return ServerResult.success(orderProfitAnalysisDO);
  41 + }
  42 +}
src/main/java/com/order/erp/domain/vo/IndexDataVO.java 0 → 100644
  1 +package com.order.erp.domain.vo;
  2 +
  3 +import lombok.AllArgsConstructor;
  4 +import lombok.Data;
  5 +import lombok.NoArgsConstructor;
  6 +import lombok.ToString;
  7 +
  8 +/**
  9 + * @author zhongnanhuang
  10 + * @version 1.0
  11 + * @project order-erp
  12 + * @description 首页数据展示
  13 + * @date 2023/10/24 09:03:20
  14 + */
  15 +@Data
  16 +@AllArgsConstructor
  17 +@ToString
  18 +@NoArgsConstructor
  19 +public class IndexDataVO {
  20 + private Long orderFinishedCount;
  21 +
  22 + private Long orderRecentMonthFinishedCount;
  23 +
  24 + private Long orderInspectingCount;
  25 +
  26 + private Long orderRecentMonthInspectingCount;
  27 +
  28 + private Long orderProfitWaitAuditCount;
  29 +
  30 + private Long orderRecentWeekProfitWaitAuditCount;
  31 +
  32 + private Long orderReportWaitAuditCount;
  33 +
  34 + private Long orderReportRecentYearWaitAuditCount;
  35 +
  36 + private ChartData chartData;
  37 +
  38 + @Data
  39 + @AllArgsConstructor
  40 + @NoArgsConstructor
  41 + public static class ChartData{
  42 + private String[] x;//小时
  43 + private int[] y;//订单量
  44 + }
  45 +}
src/main/java/com/order/erp/domain/vo/OrderCountVO.java 0 → 100644
  1 +package com.order.erp.domain.vo;
  2 +
  3 +import lombok.AllArgsConstructor;
  4 +import lombok.Data;
  5 +import lombok.NoArgsConstructor;
  6 +import lombok.ToString;
  7 +
  8 +/**
  9 + * @author zhongnanhuang
  10 + * @version 1.0
  11 + * @project order-erp
  12 + * @description 订单每日数据
  13 + * @date 2023/10/24 10:28:59
  14 + */
  15 +@Data
  16 +@AllArgsConstructor
  17 +@NoArgsConstructor
  18 +@ToString
  19 +public class OrderCountVO {
  20 + private String hour;
  21 + private Integer count;
  22 +}
src/main/java/com/order/erp/mapper/order/OrderBaseInfoMapper.java
1 package com.order.erp.mapper.order; 1 package com.order.erp.mapper.order;
2 2
3 import com.baomidou.mybatisplus.core.mapper.BaseMapper; 3 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  4 +import com.order.erp.domain.OrderStatusEnum;
4 import com.order.erp.domain.dto.order.OrderBaseInfoDO; 5 import com.order.erp.domain.dto.order.OrderBaseInfoDO;
  6 +import com.order.erp.domain.vo.OrderCountVO;
  7 +import org.apache.ibatis.annotations.Select;
  8 +
  9 +import java.util.List;
5 10
6 /** 11 /**
7 * 订单基础信息表(OrderBaseInfo)表数据库访问层 12 * 订单基础信息表(OrderBaseInfo)表数据库访问层
@@ -12,5 +17,10 @@ import com.order.erp.domain.dto.order.OrderBaseInfoDO; @@ -12,5 +17,10 @@ import com.order.erp.domain.dto.order.OrderBaseInfoDO;
12 public interface OrderBaseInfoMapper extends BaseMapper<OrderBaseInfoDO> { 17 public interface OrderBaseInfoMapper extends BaseMapper<OrderBaseInfoDO> {
13 18
14 19
  20 + @Select("SELECT count(*) FROM order_base_info WHERE order_status=#{orderStatus} and DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= date(create_time);")
  21 + long countRecentMonthByOrderStatus(Integer orderStatus);
  22 +
  23 + @Select("SELECT HOUR(create_time) AS hour, COUNT(*) AS count FROM order_base_info WHERE create_time >= DATE_SUB(NOW(), INTERVAL 1 DAY) GROUP BY HOUR(create_time);")
  24 + List<OrderCountVO> countHoursFromDay();
15 } 25 }
16 26
src/main/java/com/order/erp/mapper/order/OrderCompletionReportMapper.java
@@ -2,6 +2,7 @@ package com.order.erp.mapper.order; @@ -2,6 +2,7 @@ package com.order.erp.mapper.order;
2 2
3 import com.baomidou.mybatisplus.core.mapper.BaseMapper; 3 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 import com.order.erp.domain.dto.order.OrderCompletionReportDO; 4 import com.order.erp.domain.dto.order.OrderCompletionReportDO;
  5 +import org.apache.ibatis.annotations.Select;
5 6
6 /** 7 /**
7 * 订单-项目完成报告书(OrderCompletionReport)表数据库访问层 8 * 订单-项目完成报告书(OrderCompletionReport)表数据库访问层
@@ -12,5 +13,7 @@ import com.order.erp.domain.dto.order.OrderCompletionReportDO; @@ -12,5 +13,7 @@ import com.order.erp.domain.dto.order.OrderCompletionReportDO;
12 public interface OrderCompletionReportMapper extends BaseMapper<OrderCompletionReportDO> { 13 public interface OrderCompletionReportMapper extends BaseMapper<OrderCompletionReportDO> {
13 14
14 15
  16 + @Select("SELECT count(*) FROM order_completion_report WHERE order_status=20 and create_time >= DATE_SUB(NOW(), INTERVAL 1 YEAR);SELECT * FROM order_completion_report WHERE order_status=#{status} and create_time >= DATE_SUB(NOW(), INTERVAL 1 YEAR);")
  17 + long countYearByOrderStatus(Integer status);
15 } 18 }
16 19
src/main/java/com/order/erp/mapper/order/OrderInspectionStageMapper.java
@@ -2,6 +2,7 @@ package com.order.erp.mapper.order; @@ -2,6 +2,7 @@ package com.order.erp.mapper.order;
2 2
3 import com.baomidou.mybatisplus.core.mapper.BaseMapper; 3 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 import com.order.erp.domain.dto.order.OrderInspectionStageDO; 4 import com.order.erp.domain.dto.order.OrderInspectionStageDO;
  5 +import org.apache.ibatis.annotations.Select;
5 6
6 /** 7 /**
7 * 订单-质检环节(OrderInspectionStage)表数据库访问层 8 * 订单-质检环节(OrderInspectionStage)表数据库访问层
@@ -12,5 +13,7 @@ import com.order.erp.domain.dto.order.OrderInspectionStageDO; @@ -12,5 +13,7 @@ import com.order.erp.domain.dto.order.OrderInspectionStageDO;
12 public interface OrderInspectionStageMapper extends BaseMapper<OrderInspectionStageDO> { 13 public interface OrderInspectionStageMapper extends BaseMapper<OrderInspectionStageDO> {
13 14
14 15
  16 + @Select("SELECT count(*) FROM order_inspection_stage WHERE order_status=#{status} and DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= date(create_time);")
  17 + long countRecentMonthByOrderStatus(Integer status);
15 } 18 }
16 19
src/main/java/com/order/erp/mapper/order/OrderProfitAnalysisMapper.java
@@ -2,6 +2,7 @@ package com.order.erp.mapper.order; @@ -2,6 +2,7 @@ package com.order.erp.mapper.order;
2 2
3 import com.baomidou.mybatisplus.core.mapper.BaseMapper; 3 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 import com.order.erp.domain.dto.order.OrderProfitAnalysisDO; 4 import com.order.erp.domain.dto.order.OrderProfitAnalysisDO;
  5 +import org.apache.ibatis.annotations.Select;
5 6
6 /** 7 /**
7 * 订单利润分析表(OrderProfitAnalysis)表数据库访问层 8 * 订单利润分析表(OrderProfitAnalysis)表数据库访问层
@@ -12,5 +13,7 @@ import com.order.erp.domain.dto.order.OrderProfitAnalysisDO; @@ -12,5 +13,7 @@ import com.order.erp.domain.dto.order.OrderProfitAnalysisDO;
12 public interface OrderProfitAnalysisMapper extends BaseMapper<OrderProfitAnalysisDO> { 13 public interface OrderProfitAnalysisMapper extends BaseMapper<OrderProfitAnalysisDO> {
13 14
14 15
  16 + @Select("SELECT count(*) FROM order_profit_analysis WHERE order_status=#{status} and create_time >= DATE_SUB(NOW(), INTERVAL 1 WEEK);")
  17 + long countRecentWeekByOrderStatus(Integer status);
15 } 18 }
16 19
src/main/java/com/order/erp/service/order/OrderBaseInfoService.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
4 import com.order.erp.common.constant.ServerResult; 4 import com.order.erp.common.constant.ServerResult;
5 import com.order.erp.common.excel4j.exceptions.Excel4JException; 5 import com.order.erp.common.excel4j.exceptions.Excel4JException;
6 import com.order.erp.domain.dto.order.OrderBaseInfoDO; 6 import com.order.erp.domain.dto.order.OrderBaseInfoDO;
  7 +import com.order.erp.domain.vo.IndexDataVO;
7 import com.order.erp.domain.vo.order.*; 8 import com.order.erp.domain.vo.order.*;
8 9
9 import javax.servlet.http.HttpServletResponse; 10 import javax.servlet.http.HttpServletResponse;
@@ -80,4 +81,9 @@ public interface OrderBaseInfoService extends IService&lt;OrderBaseInfoDO&gt; { @@ -80,4 +81,9 @@ public interface OrderBaseInfoService extends IService&lt;OrderBaseInfoDO&gt; {
80 */ 81 */
81 ServerResult deleteById(OrderBaseInfoQueryVO orderBaseInfoQueryVO); 82 ServerResult deleteById(OrderBaseInfoQueryVO orderBaseInfoQueryVO);
82 83
  84 + long countByOrderStatus(Integer orderFinish);
  85 +
  86 + long countRecentMonthByOrderStatus(Integer orderFinish);
  87 +
  88 + IndexDataVO.ChartData countHoursFromDay();
83 } 89 }
src/main/java/com/order/erp/service/order/OrderCompletionReportService.java
@@ -59,4 +59,8 @@ public interface OrderCompletionReportService extends IService&lt;OrderCompletionRe @@ -59,4 +59,8 @@ public interface OrderCompletionReportService extends IService&lt;OrderCompletionRe
59 boolean deleteByOrderId(Long orderId); 59 boolean deleteByOrderId(Long orderId);
60 60
61 boolean deleteByOrderIds(List<Long> orderIds); 61 boolean deleteByOrderIds(List<Long> orderIds);
  62 +
  63 + long countByOrderStatus(Integer status);
  64 +
  65 + long countYearByOrderStatus(Integer status);
62 } 66 }
src/main/java/com/order/erp/service/order/OrderInspectionStageService.java
@@ -2,6 +2,7 @@ package com.order.erp.service.order; @@ -2,6 +2,7 @@ package com.order.erp.service.order;
2 2
3 import com.baomidou.mybatisplus.extension.service.IService; 3 import com.baomidou.mybatisplus.extension.service.IService;
4 import com.order.erp.common.constant.ServerResult; 4 import com.order.erp.common.constant.ServerResult;
  5 +import com.order.erp.domain.OrderStatusEnum;
5 import com.order.erp.domain.dto.order.OrderInspectionStageDO; 6 import com.order.erp.domain.dto.order.OrderInspectionStageDO;
6 import com.order.erp.domain.vo.order.OrderInspectionStageQueryVO; 7 import com.order.erp.domain.vo.order.OrderInspectionStageQueryVO;
7 import com.order.erp.domain.vo.order.OrderInspectionStageVO; 8 import com.order.erp.domain.vo.order.OrderInspectionStageVO;
@@ -59,4 +60,8 @@ public interface OrderInspectionStageService extends IService&lt;OrderInspectionSta @@ -59,4 +60,8 @@ public interface OrderInspectionStageService extends IService&lt;OrderInspectionSta
59 boolean deleteByOrderId(Long orderId); 60 boolean deleteByOrderId(Long orderId);
60 61
61 boolean deleteByOrderIds(List<Long> orderIds); 62 boolean deleteByOrderIds(List<Long> orderIds);
  63 +
  64 + long countByOrderStatus(Integer orderStatus);
  65 +
  66 + long countRecentMonthByOrderStatus(Integer status);
62 } 67 }
src/main/java/com/order/erp/service/order/OrderProfitAnalysisService.java
@@ -59,4 +59,10 @@ public interface OrderProfitAnalysisService extends IService&lt;OrderProfitAnalysis @@ -59,4 +59,10 @@ public interface OrderProfitAnalysisService extends IService&lt;OrderProfitAnalysis
59 boolean deleteByOrderId(Long orderId); 59 boolean deleteByOrderId(Long orderId);
60 60
61 boolean deleteByOrderIds(List<Long> orderIds); 61 boolean deleteByOrderIds(List<Long> orderIds);
  62 +
  63 + OrderProfitAnalysisDO analysisByOrderIds(List<Long> orderIds);
  64 +
  65 + long countByOrderStatus(Integer status);
  66 +
  67 + long countRecentWeekByOrderStatus(Integer status);
62 } 68 }
src/main/java/com/order/erp/service/order/impl/OrderBaseInfoServiceImpl.java
@@ -26,20 +26,20 @@ import com.order.erp.domain.OrderStatusEnum; @@ -26,20 +26,20 @@ import com.order.erp.domain.OrderStatusEnum;
26 import com.order.erp.domain.dto.BaseDO; 26 import com.order.erp.domain.dto.BaseDO;
27 import com.order.erp.domain.dto.order.*; 27 import com.order.erp.domain.dto.order.*;
28 import com.order.erp.domain.excel.OrderExcelVO; 28 import com.order.erp.domain.excel.OrderExcelVO;
  29 +import com.order.erp.domain.vo.IndexDataVO;
  30 +import com.order.erp.domain.vo.OrderCountVO;
29 import com.order.erp.domain.vo.order.*; 31 import com.order.erp.domain.vo.order.*;
30 import com.order.erp.mapper.order.OrderBaseInfoMapper; 32 import com.order.erp.mapper.order.OrderBaseInfoMapper;
31 import com.order.erp.service.order.*; 33 import com.order.erp.service.order.*;
32 import lombok.extern.slf4j.Slf4j; 34 import lombok.extern.slf4j.Slf4j;
33 import org.springframework.beans.BeanUtils; 35 import org.springframework.beans.BeanUtils;
34 import org.springframework.stereotype.Service; 36 import org.springframework.stereotype.Service;
  37 +import org.springframework.transaction.annotation.Transactional;
35 38
36 import javax.annotation.Resource; 39 import javax.annotation.Resource;
37 import javax.servlet.http.HttpServletResponse; 40 import javax.servlet.http.HttpServletResponse;
38 import java.io.IOException; 41 import java.io.IOException;
39 -import java.util.List;  
40 -import java.util.Map;  
41 -import java.util.Objects;  
42 -import java.util.Set; 42 +import java.util.*;
43 import java.util.function.Function; 43 import java.util.function.Function;
44 import java.util.stream.Collectors; 44 import java.util.stream.Collectors;
45 45
@@ -553,6 +553,7 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl&lt;OrderBaseInfoMapper, O @@ -553,6 +553,7 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl&lt;OrderBaseInfoMapper, O
553 * @return 是否成功 553 * @return 是否成功
554 */ 554 */
555 @Override 555 @Override
  556 + @Transactional
556 public ServerResult deleteById(OrderBaseInfoQueryVO orderBaseInfoQueryVO) { 557 public ServerResult deleteById(OrderBaseInfoQueryVO orderBaseInfoQueryVO) {
557 List<Long> ids = orderBaseInfoQueryVO.getIds(); 558 List<Long> ids = orderBaseInfoQueryVO.getIds();
558 if (CollUtil.isEmpty(ids)) { 559 if (CollUtil.isEmpty(ids)) {
@@ -571,39 +572,65 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl&lt;OrderBaseInfoMapper, O @@ -571,39 +572,65 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl&lt;OrderBaseInfoMapper, O
571 572
572 573
573 //删除订单关联信息 574 //删除订单关联信息
574 - this.deleteRelationInfoByOrderId(ids);  
575 -  
576 -  
577 - return ServerResult.success();  
578 - }  
579 -  
580 - /**  
581 - * 删除订单关联信息  
582 - * @param orderId  
583 - */  
584 - private void deleteRelationInfoByOrderId(List<Long> orderIds) {  
585 //订单审批日志 575 //订单审批日志
586 - orderAuditLogService.deleteByOrderIds(orderIds); 576 + orderAuditLogService.deleteByOrderIds(ids);
587 577
588 //订单-项目完成报告书 578 //订单-项目完成报告书
589 - orderCompletionReportService.deleteByOrderIds(orderIds); 579 + orderCompletionReportService.deleteByOrderIds(ids);
590 580
591 //用户订单-字段锁定申请表 581 //用户订单-字段锁定申请表
592 - orderFieldLockApplyService.deleteByOrderIds(orderIds); 582 + orderFieldLockApplyService.deleteByOrderIds(ids);
593 583
594 //用户订单-字段锁定记录表 584 //用户订单-字段锁定记录表
595 - orderFieldLockRecordService.deleteByOrderIds(orderIds); 585 + orderFieldLockRecordService.deleteByOrderIds(ids);
596 586
597 //订单-质检环节 587 //订单-质检环节
598 - orderInspectionStageService.deleteByOrderIds(orderIds); 588 + orderInspectionStageService.deleteByOrderIds(ids);
599 589
600 //用户订单操作日志表 590 //用户订单操作日志表
601 - orderOptLogService.deleteByOrderIds(orderIds); 591 + orderOptLogService.deleteByOrderIds(ids);
602 592
603 //订单利润分析表 593 //订单利润分析表
604 - profitAnalysisService.deleteByOrderIds(orderIds); 594 + profitAnalysisService.deleteByOrderIds(ids);
605 595
606 //订单-跟单环节 596 //订单-跟单环节
607 - trackStageService.deleteByOrderIds(orderIds); 597 + trackStageService.deleteByOrderIds(ids);
  598 +
  599 +
  600 + return ServerResult.success();
  601 + }
  602 +
  603 + /**
  604 + * 根据订单状态统计订单数量
  605 + * @param orderStatus
  606 + * @return
  607 + */
  608 + @Override
  609 + public long countByOrderStatus(Integer orderStatus) {
  610 + return this.count(new LambdaQueryWrapper<OrderBaseInfoDO>().eq(OrderBaseInfoDO::getOrderStatus,orderStatus));
608 } 611 }
  612 +
  613 + @Override
  614 + public long countRecentMonthByOrderStatus(Integer orderStatus) {
  615 + return this.baseMapper.countRecentMonthByOrderStatus(orderStatus);
  616 + }
  617 +
  618 + @Override
  619 + public IndexDataVO.ChartData countHoursFromDay() {
  620 + List<OrderCountVO> orderCountVOS = this.baseMapper.countHoursFromDay();
  621 + Map<String,Integer> countValueMap = new HashMap<>();
  622 + if (orderCountVOS!=null&& orderCountVOS.size()>0){
  623 + for (OrderCountVO orderCountVO : orderCountVOS) {
  624 + countValueMap.put(orderCountVO.getHour(),orderCountVO.getCount());
  625 + }
  626 + }
  627 + String[] x = new String[24];
  628 + int[] y = new int[24];
  629 + for (int i = 0; i < 24; i++) {
  630 + x[i] = i+":00";
  631 + y[i] = countValueMap.get(i+"")==null?0:countValueMap.get(i+"");
  632 + }
  633 + return new IndexDataVO.ChartData(x,y);
  634 + }
  635 +
609 } 636 }
src/main/java/com/order/erp/service/order/impl/OrderCompletionReportServiceImpl.java
@@ -2,6 +2,7 @@ package com.order.erp.service.order.impl; @@ -2,6 +2,7 @@ package com.order.erp.service.order.impl;
2 2
3 import cn.hutool.core.bean.BeanUtil; 3 import cn.hutool.core.bean.BeanUtil;
4 import cn.hutool.core.collection.CollUtil; 4 import cn.hutool.core.collection.CollUtil;
  5 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
5 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 6 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
6 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 import com.order.erp.common.constant.Constant; 8 import com.order.erp.common.constant.Constant;
@@ -143,4 +144,15 @@ public class OrderCompletionReportServiceImpl extends ServiceImpl&lt;OrderCompletio @@ -143,4 +144,15 @@ public class OrderCompletionReportServiceImpl extends ServiceImpl&lt;OrderCompletio
143 144
144 return update(updateWrapper); 145 return update(updateWrapper);
145 } 146 }
  147 +
  148 + @Override
  149 + public long countByOrderStatus(Integer status) {
  150 + return baseMapper.selectCount(new LambdaQueryWrapper<OrderCompletionReportDO>()
  151 + .eq(OrderCompletionReportDO::getOrderStatus, status));
  152 + }
  153 +
  154 + @Override
  155 + public long countYearByOrderStatus(Integer status) {
  156 + return baseMapper.countYearByOrderStatus(status);
  157 + }
146 } 158 }
src/main/java/com/order/erp/service/order/impl/OrderInspectionStageServiceImpl.java
@@ -2,10 +2,12 @@ package com.order.erp.service.order.impl; @@ -2,10 +2,12 @@ package com.order.erp.service.order.impl;
2 2
3 import cn.hutool.core.bean.BeanUtil; 3 import cn.hutool.core.bean.BeanUtil;
4 import cn.hutool.core.collection.CollUtil; 4 import cn.hutool.core.collection.CollUtil;
  5 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
5 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 6 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
6 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 import com.order.erp.common.constant.Constant; 8 import com.order.erp.common.constant.Constant;
8 import com.order.erp.common.constant.ServerResult; 9 import com.order.erp.common.constant.ServerResult;
  10 +import com.order.erp.domain.OrderStatusEnum;
9 import com.order.erp.domain.dto.order.OrderInspectionStageDO; 11 import com.order.erp.domain.dto.order.OrderInspectionStageDO;
10 import com.order.erp.domain.vo.order.OrderInspectionStageQueryVO; 12 import com.order.erp.domain.vo.order.OrderInspectionStageQueryVO;
11 import com.order.erp.domain.vo.order.OrderInspectionStageVO; 13 import com.order.erp.domain.vo.order.OrderInspectionStageVO;
@@ -136,4 +138,14 @@ public class OrderInspectionStageServiceImpl extends ServiceImpl&lt;OrderInspection @@ -136,4 +138,14 @@ public class OrderInspectionStageServiceImpl extends ServiceImpl&lt;OrderInspection
136 .set(OrderInspectionStageDO::getEnableFlag, Constant.UNABLE_TWENTY); 138 .set(OrderInspectionStageDO::getEnableFlag, Constant.UNABLE_TWENTY);
137 return update(updateWrapper); 139 return update(updateWrapper);
138 } 140 }
  141 +
  142 + @Override
  143 + public long countByOrderStatus(Integer orderStatus) {
  144 + return this.count(new LambdaQueryWrapper<OrderInspectionStageDO>().eq(OrderInspectionStageDO::getOrderStatus,orderStatus));
  145 + }
  146 +
  147 + @Override
  148 + public long countRecentMonthByOrderStatus(Integer status) {
  149 + return this.baseMapper.countRecentMonthByOrderStatus(status);
  150 + }
139 } 151 }
src/main/java/com/order/erp/service/order/impl/OrderProfitAnalysisServiceImpl.java
@@ -2,18 +2,26 @@ package com.order.erp.service.order.impl; @@ -2,18 +2,26 @@ package com.order.erp.service.order.impl;
2 2
3 import cn.hutool.core.bean.BeanUtil; 3 import cn.hutool.core.bean.BeanUtil;
4 import cn.hutool.core.collection.CollUtil; 4 import cn.hutool.core.collection.CollUtil;
  5 +import com.baomidou.mybatisplus.core.conditions.Wrapper;
  6 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  7 +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 8 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
6 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 9 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 import com.order.erp.common.constant.Constant; 10 import com.order.erp.common.constant.Constant;
8 import com.order.erp.common.constant.ServerResult; 11 import com.order.erp.common.constant.ServerResult;
  12 +import com.order.erp.common.utils.ProfitUtils;
9 import com.order.erp.domain.dto.order.OrderProfitAnalysisDO; 13 import com.order.erp.domain.dto.order.OrderProfitAnalysisDO;
10 import com.order.erp.domain.vo.order.OrderProfitAnalysisQueryVO; 14 import com.order.erp.domain.vo.order.OrderProfitAnalysisQueryVO;
11 import com.order.erp.domain.vo.order.OrderProfitAnalysisVO; 15 import com.order.erp.domain.vo.order.OrderProfitAnalysisVO;
  16 +import com.order.erp.domain.vo.order.ProfitCalculateVO;
12 import com.order.erp.mapper.order.OrderProfitAnalysisMapper; 17 import com.order.erp.mapper.order.OrderProfitAnalysisMapper;
13 import com.order.erp.service.order.OrderProfitAnalysisService; 18 import com.order.erp.service.order.OrderProfitAnalysisService;
14 import lombok.extern.slf4j.Slf4j; 19 import lombok.extern.slf4j.Slf4j;
  20 +import org.springframework.beans.BeanUtils;
15 import org.springframework.stereotype.Service; 21 import org.springframework.stereotype.Service;
16 22
  23 +import java.math.BigDecimal;
  24 +import java.util.Arrays;
17 import java.util.List; 25 import java.util.List;
18 import java.util.Objects; 26 import java.util.Objects;
19 27
@@ -141,4 +149,52 @@ public class OrderProfitAnalysisServiceImpl extends ServiceImpl&lt;OrderProfitAnaly @@ -141,4 +149,52 @@ public class OrderProfitAnalysisServiceImpl extends ServiceImpl&lt;OrderProfitAnaly
141 .set(OrderProfitAnalysisDO::getEnableFlag, Constant.UNABLE_TWENTY); 149 .set(OrderProfitAnalysisDO::getEnableFlag, Constant.UNABLE_TWENTY);
142 return update(updateWrapper); 150 return update(updateWrapper);
143 } 151 }
  152 +
  153 + @Override
  154 + public OrderProfitAnalysisDO analysisByOrderIds(List<Long> orderIds) {
  155 + //查询订单id的利润分析数据
  156 + QueryWrapper queryWrapper = new QueryWrapper<OrderProfitAnalysisVO>().in("order_id", orderIds);
  157 + List<OrderProfitAnalysisDO> orderProfits = list(queryWrapper);
  158 +
  159 +
  160 + if (orderProfits==null||orderProfits.isEmpty()){
  161 + return null;
  162 + }
  163 +
  164 + BigDecimal packetTotalPrice = new BigDecimal("0");
  165 + BigDecimal customerTotalPrice = new BigDecimal("0");
  166 + BigDecimal productionDepartmentTotalPrice = new BigDecimal("0");
  167 + double profits = 0;
  168 + //分别计算每个orderProfit的利润率,通过ProfitUtils的calculateProfitRate方法计算
  169 + for (OrderProfitAnalysisDO orderProfit : orderProfits) {
  170 + ProfitCalculateVO profitCalculateVO = new ProfitCalculateVO();
  171 + BeanUtils.copyProperties(orderProfit,profitCalculateVO);
  172 + double profit = ProfitUtils.calculateProfitRate(profitCalculateVO);
  173 +
  174 + packetTotalPrice = packetTotalPrice.add(new BigDecimal(orderProfit.getPacketTotalPrice()));
  175 + customerTotalPrice = customerTotalPrice.add(new BigDecimal(orderProfit.getCustomerTotalPrice()));
  176 + productionDepartmentTotalPrice = productionDepartmentTotalPrice.add(new BigDecimal(orderProfit.getProductionDepartmentTotalPrice()));
  177 + profits+=profit;
  178 + }
  179 +
  180 + profits = (profits / orderProfits.size());
  181 +
  182 + OrderProfitAnalysisDO orderProfitAnalysisDO = new OrderProfitAnalysisDO();
  183 + orderProfitAnalysisDO.setPacketTotalPrice(packetTotalPrice.doubleValue());
  184 + orderProfitAnalysisDO.setCustomerTotalPrice(customerTotalPrice.doubleValue());
  185 + orderProfitAnalysisDO.setProductionDepartmentTotalPrice(productionDepartmentTotalPrice.doubleValue());
  186 + orderProfitAnalysisDO.setProfitRate(profits);
  187 +
  188 + return orderProfitAnalysisDO;
  189 + }
  190 +
  191 + @Override
  192 + public long countByOrderStatus(Integer status) {
  193 + return this.count(new LambdaQueryWrapper<OrderProfitAnalysisDO>().eq(OrderProfitAnalysisDO::getOrderStatus,status));
  194 + }
  195 +
  196 + @Override
  197 + public long countRecentWeekByOrderStatus(Integer status) {
  198 + return this.baseMapper.countRecentWeekByOrderStatus(status);
  199 + }
144 } 200 }