Commit 1464aebd4c108ba28ee6cb5cfb89c19a3c507556
1 parent
1446ab89
feat: 问题修复项
1、内部编号处理 '-' 通过接口刷数据处理 2、计算利润率支持全选(根据页面查询条件) 3、计算设计师权重分母对内部编码去重
Showing
9 changed files
with
150 additions
and
8 deletions
src/main/java/com/order/erp/controller/DataController.java
0 → 100644
1 | +package com.order.erp.controller; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
4 | +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | |
5 | +import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |
6 | +import com.order.erp.common.constant.Constant; | |
7 | +import com.order.erp.common.constant.ServerResult; | |
8 | +import com.order.erp.domain.dto.BaseDO; | |
9 | +import com.order.erp.domain.dto.order.OrderBaseInfoDO; | |
10 | +import com.order.erp.domain.vo.order.OrderBaseInfoQueryVO; | |
11 | +import com.order.erp.service.order.OrderBaseInfoService; | |
12 | +import org.springframework.validation.annotation.Validated; | |
13 | +import org.springframework.web.bind.annotation.PostMapping; | |
14 | +import org.springframework.web.bind.annotation.RequestBody; | |
15 | +import org.springframework.web.bind.annotation.RequestMapping; | |
16 | +import org.springframework.web.bind.annotation.RestController; | |
17 | + | |
18 | +import javax.annotation.Resource; | |
19 | +import java.util.List; | |
20 | + | |
21 | +/** | |
22 | + * @author zhongnanhuang | |
23 | + * @version 1.0 | |
24 | + * @project order-erp | |
25 | + * @description 订单利润表控制层 | |
26 | + * @date 2023/10/23 11:48:36 | |
27 | + */ | |
28 | +@RestController | |
29 | +@RequestMapping("/order/erp/data") | |
30 | +public class DataController { | |
31 | + | |
32 | + @Resource | |
33 | + private OrderBaseInfoService orderBaseInfoService; | |
34 | + | |
35 | + @PostMapping("/do_inner_no") | |
36 | + public ServerResult doInnerNo(@RequestBody @Validated OrderBaseInfoQueryVO queryVO) { | |
37 | + List<OrderBaseInfoDO> orderBaseInfoDOList = orderBaseInfoService.list(new LambdaQueryWrapper<OrderBaseInfoDO>() | |
38 | + .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN)); | |
39 | + if (CollectionUtils.isEmpty(orderBaseInfoDOList)) { | |
40 | + return ServerResult.success(); | |
41 | + } | |
42 | + orderBaseInfoDOList.forEach(x -> { | |
43 | + if (StringUtils.isNotBlank(x.getInnerNo())) { | |
44 | + x.setInnerNo(x.getInnerNo().split("-")[Constant.ZERO]); | |
45 | + } | |
46 | + }); | |
47 | + orderBaseInfoService.updateBatchById(orderBaseInfoDOList); | |
48 | + return ServerResult.success(); | |
49 | + } | |
50 | + | |
51 | +} | ... | ... |
src/main/java/com/order/erp/controller/OrderProfitController.java
... | ... | @@ -29,7 +29,7 @@ public class OrderProfitController { |
29 | 29 | |
30 | 30 | @PostMapping("/analysis") |
31 | 31 | public ServerResult<OrderProfitAnalysisVO> analysis(@RequestBody @Validated OrderProfitAnalysisVo orderProfitAnalysisVo) { |
32 | - return orderProfitAnalysisService.analysisByOrderIds(orderProfitAnalysisVo); | |
32 | + return orderProfitAnalysisService.analysis(orderProfitAnalysisVo); | |
33 | 33 | } |
34 | 34 | |
35 | 35 | @PostMapping("/calculate") | ... | ... |
src/main/java/com/order/erp/domain/vo/OrderProfitAnalysisVo.java
1 | 1 | package com.order.erp.domain.vo; |
2 | 2 | |
3 | +import com.order.erp.domain.vo.order.OrderBaseInfoQueryVO; | |
3 | 4 | import lombok.AllArgsConstructor; |
4 | 5 | import lombok.Data; |
5 | 6 | import lombok.NoArgsConstructor; |
... | ... | @@ -35,4 +36,9 @@ public class OrderProfitAnalysisVo implements Serializable { |
35 | 36 | */ |
36 | 37 | @NotNull(message = "请选择当天汇率进行计算") |
37 | 38 | private String exchangeRate; |
39 | + | |
40 | + /** | |
41 | + * 页面查询条件 | |
42 | + */ | |
43 | + private OrderBaseInfoQueryVO queryVO; | |
38 | 44 | } | ... | ... |
src/main/java/com/order/erp/service/order/OrderProfitAnalysisService.java
... | ... | @@ -64,6 +64,10 @@ public interface OrderProfitAnalysisService extends IService<OrderProfitAnalysis |
64 | 64 | |
65 | 65 | ServerResult<OrderProfitAnalysisVO> analysisByOrderIds(OrderProfitAnalysisVo orderProfitAnalysisVo); |
66 | 66 | |
67 | + ServerResult<OrderProfitAnalysisVO> analysis(OrderProfitAnalysisVo orderProfitAnalysisVo); | |
68 | + | |
69 | + ServerResult<OrderProfitAnalysisVO> analysisByQueryVO(OrderProfitAnalysisVo orderProfitAnalysisVo); | |
70 | + | |
67 | 71 | ServerResult calculate(ProfitCalculateVO calculateVO); |
68 | 72 | |
69 | 73 | long countByOrderStatus(Integer status); | ... | ... |
src/main/java/com/order/erp/service/order/impl/OrderBaseInfoServiceImpl.java
... | ... | @@ -1350,12 +1350,12 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
1350 | 1350 | // } |
1351 | 1351 | // } |
1352 | 1352 | |
1353 | - if (queryVO.getFieldVO() != null && queryVO.getFieldVO().getOrderIds() != null) { | |
1354 | - Set<Long> collect = new HashSet<>(queryVO.getFieldVO().getOrderIds()); | |
1355 | - if (collect.size() > 0) { | |
1356 | - queryVO.setOrderIds(collect); | |
1357 | - } | |
1358 | - } | |
1353 | +// if (queryVO.getFieldVO() != null && queryVO.getFieldVO().getOrderIds() != null) { | |
1354 | +// Set<Long> collect = new HashSet<>(queryVO.getFieldVO().getOrderIds()); | |
1355 | +// if (collect.size() > 0) { | |
1356 | +// queryVO.setOrderIds(collect); | |
1357 | +// } | |
1358 | +// } | |
1359 | 1359 | |
1360 | 1360 | return new LambdaQueryWrapper<OrderBaseInfoDO>() |
1361 | 1361 | .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | ... | ... |
src/main/java/com/order/erp/service/order/impl/OrderCompletionReportServiceImpl.java
... | ... | @@ -89,7 +89,8 @@ public class OrderCompletionReportServiceImpl extends ServiceImpl<OrderCompletio |
89 | 89 | sum = sum.add(new BigDecimal(ideaSourceRate)).add(new BigDecimal(manualPreform1Rate)).add(new BigDecimal(manualPreform2Rate)); |
90 | 90 | } |
91 | 91 | } |
92 | - resultVo.setRate(sum.divide(new BigDecimal(orderBaseInfoDOList.size())).doubleValue()); | |
92 | + Set<String> innerNoSet = orderBaseInfoDOList.stream().map(OrderBaseInfoDO::getInnerNo).collect(Collectors.toSet()); | |
93 | + resultVo.setRate(sum.divide(new BigDecimal(innerNoSet.size())).doubleValue()); | |
93 | 94 | } |
94 | 95 | return ServerResult.success(resultVo); |
95 | 96 | } | ... | ... |
src/main/java/com/order/erp/service/order/impl/OrderProfitAnalysisServiceImpl.java
... | ... | @@ -12,20 +12,24 @@ import com.order.erp.common.exception.BusinessException; |
12 | 12 | import com.order.erp.common.utils.ProfitUtils; |
13 | 13 | import com.order.erp.common.utils.StringUtils; |
14 | 14 | import com.order.erp.domain.dto.BaseDO; |
15 | +import com.order.erp.domain.dto.order.OrderBaseInfoDO; | |
15 | 16 | import com.order.erp.domain.dto.order.OrderProfitAnalysisDO; |
16 | 17 | import com.order.erp.domain.vo.OrderProfitAnalysisVo; |
17 | 18 | import com.order.erp.domain.vo.order.OrderProfitAnalysisQueryVO; |
18 | 19 | import com.order.erp.domain.vo.order.OrderProfitAnalysisVO; |
19 | 20 | import com.order.erp.domain.vo.order.ProfitCalculateVO; |
20 | 21 | import com.order.erp.mapper.order.OrderProfitAnalysisMapper; |
22 | +import com.order.erp.service.order.OrderBaseInfoService; | |
21 | 23 | import com.order.erp.service.order.OrderProfitAnalysisService; |
22 | 24 | import lombok.extern.slf4j.Slf4j; |
23 | 25 | import org.springframework.beans.BeanUtils; |
24 | 26 | import org.springframework.stereotype.Service; |
25 | 27 | |
28 | +import javax.annotation.Resource; | |
26 | 29 | import java.math.BigDecimal; |
27 | 30 | import java.util.List; |
28 | 31 | import java.util.Objects; |
32 | +import java.util.stream.Collectors; | |
29 | 33 | |
30 | 34 | /** |
31 | 35 | * 订单利润分析表(OrderProfitAnalysis)表服务实现类 |
... | ... | @@ -37,6 +41,9 @@ import java.util.Objects; |
37 | 41 | @Service |
38 | 42 | public class OrderProfitAnalysisServiceImpl extends ServiceImpl<OrderProfitAnalysisMapper, OrderProfitAnalysisDO> implements OrderProfitAnalysisService { |
39 | 43 | |
44 | + @Resource | |
45 | + private OrderBaseInfoService orderBaseInfoService; | |
46 | + | |
40 | 47 | /** |
41 | 48 | * 通过ID查询单条数据 |
42 | 49 | * <p> |
... | ... | @@ -158,6 +165,32 @@ public class OrderProfitAnalysisServiceImpl extends ServiceImpl<OrderProfitAnaly |
158 | 165 | } |
159 | 166 | |
160 | 167 | @Override |
168 | + public ServerResult<OrderProfitAnalysisVO> analysisByQueryVO(OrderProfitAnalysisVo profitAnalysisVo) { | |
169 | + LambdaQueryWrapper<OrderBaseInfoDO> queryWrapper = orderBaseInfoService.buildQueryByParam(profitAnalysisVo.getQueryVO()); | |
170 | + List<OrderBaseInfoDO> orderBaseInfoDOList = orderBaseInfoService.list(queryWrapper); | |
171 | + if (CollectionUtils.isEmpty(orderBaseInfoDOList)) { | |
172 | + throw new BusinessException("页面未查询到数据,请重置刷新页面后操作"); | |
173 | + } | |
174 | + //查询订单id的利润分析数据 | |
175 | + List<OrderProfitAnalysisDO> orderProfits = list(new LambdaQueryWrapper<OrderProfitAnalysisDO>() | |
176 | + .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | |
177 | + .in(OrderProfitAnalysisDO::getOrderId, orderBaseInfoDOList.stream().map(OrderBaseInfoDO::getId).collect(Collectors.toSet()))); | |
178 | + | |
179 | + if (CollectionUtils.isEmpty(orderProfits)) { | |
180 | + throw new BusinessException("选中的订单信息不存在"); | |
181 | + } | |
182 | + return wrapperProfitResult(profitAnalysisVo, orderProfits); | |
183 | + } | |
184 | + | |
185 | + @Override | |
186 | + public ServerResult<OrderProfitAnalysisVO> analysis(OrderProfitAnalysisVo orderProfitAnalysisVo) { | |
187 | + if (CollectionUtils.isNotEmpty(orderProfitAnalysisVo.getOrderIds())) { | |
188 | + return analysisByOrderIds(orderProfitAnalysisVo); | |
189 | + } | |
190 | + return analysisByQueryVO(orderProfitAnalysisVo); | |
191 | + } | |
192 | + | |
193 | + @Override | |
161 | 194 | public ServerResult<OrderProfitAnalysisVO> analysisByOrderIds(OrderProfitAnalysisVo profitAnalysisVo) { |
162 | 195 | //查询订单id的利润分析数据 |
163 | 196 | List<OrderProfitAnalysisDO> orderProfits = list(new LambdaQueryWrapper<OrderProfitAnalysisDO>() |
... | ... | @@ -168,6 +201,15 @@ public class OrderProfitAnalysisServiceImpl extends ServiceImpl<OrderProfitAnaly |
168 | 201 | throw new BusinessException("选中的订单信息不存在"); |
169 | 202 | } |
170 | 203 | |
204 | + return wrapperProfitResult(profitAnalysisVo, orderProfits); | |
205 | + } | |
206 | + | |
207 | + /** | |
208 | + * @param profitAnalysisVo | |
209 | + * @param orderProfits | |
210 | + * @return | |
211 | + */ | |
212 | + private ServerResult<OrderProfitAnalysisVO> wrapperProfitResult(OrderProfitAnalysisVo profitAnalysisVo, List<OrderProfitAnalysisDO> orderProfits) { | |
171 | 213 | BigDecimal packetTotalPrice = new BigDecimal(Constant.ZERO_STRING); |
172 | 214 | BigDecimal customerTotalPrice = new BigDecimal(Constant.ZERO_STRING); |
173 | 215 | BigDecimal productionDepartmentTotalPrice = new BigDecimal(Constant.ZERO_STRING); | ... | ... |
src/test/java/BaseTest.java
0 → 100644
1 | +import com.order.erp.AdminApplication; | |
2 | +import org.junit.runner.RunWith; | |
3 | +import org.springframework.boot.test.context.SpringBootTest; | |
4 | +import org.springframework.test.context.junit4.SpringRunner; | |
5 | +import org.springframework.transaction.annotation.Transactional; | |
6 | + | |
7 | +/** | |
8 | + * | |
9 | + */ | |
10 | +@RunWith(SpringRunner.class) | |
11 | +@SpringBootTest(classes = AdminApplication.class) | |
12 | +//主动回滚测试产生的数据 | |
13 | +@Transactional | |
14 | +public class BaseTest { | |
15 | + | |
16 | + | |
17 | +} | ... | ... |
src/test/java/DateTimeUtilTest.java
0 → 100644
1 | +import com.order.erp.common.constant.Constant; | |
2 | +import org.joda.time.format.DateTimeFormat; | |
3 | +import org.joda.time.format.DateTimeFormatter; | |
4 | +import org.junit.Test; | |
5 | + | |
6 | +/** | |
7 | + * @author: xms | |
8 | + * @description: TODO | |
9 | + * @date: 2023/2/10 14:09 | |
10 | + * @version: 1.0 | |
11 | + */ | |
12 | +public class DateTimeUtilTest { | |
13 | + | |
14 | + @Test | |
15 | + public void test() { | |
16 | + String customerCode = "A05/C23063-1"; | |
17 | + String customerCode1 = "A05/C23064"; | |
18 | + System.out.println(customerCode.split("-")[Constant.ZERO]); | |
19 | + System.out.println(customerCode1.split("-")[Constant.ZERO]); | |
20 | + } | |
21 | +} | ... | ... |