From 611d19bf1a8b8673be814fc70a2e432d5ab22e10 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期六, 10 一月 2026 14:02:58 +0800
Subject: [PATCH] 浪潮对接单点登录:租户数据隔离功能4
---
src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java | 147 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 147 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
new file mode 100644
index 0000000..3faf934
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
@@ -0,0 +1,147 @@
+package com.ruoyi.production.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.production.dto.DaiDto;
+import com.ruoyi.production.mapper.ProductionOrderMapper;
+import com.ruoyi.production.mapper.SalesLedgerSchedulingMapper;
+import com.ruoyi.production.mapper.SalesLedgerWorkMapper;
+import com.ruoyi.production.pojo.ProductionOrder;
+import com.ruoyi.production.pojo.SalesLedgerScheduling;
+import com.ruoyi.production.pojo.SalesLedgerWork;
+import com.ruoyi.production.service.ProductionOrderService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * @author :yys
+ * @date : 2025/11/26 14:20
+ */
+@Service
+@Slf4j
+public class ProductionOrderServiceImpl extends ServiceImpl<ProductionOrderMapper, ProductionOrder> implements ProductionOrderService {
+
+ @Autowired
+ private ProductionOrderMapper productionOrderMapper;
+
+ @Autowired
+ private SalesLedgerWorkMapper salesLedgerWorkMapper;
+
+ @Autowired
+ private SalesLedgerSchedulingMapper salesLedgerSchedulingMapper;
+
+ @Override
+ public AjaxResult listPage(Page page, ProductionOrder productionOrder) {
+ LambdaQueryWrapper<ProductionOrder> productionOrderLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ if(productionOrder != null){
+ if(StringUtils.isNotEmpty(productionOrder.getOrderNo())){
+ productionOrderLambdaQueryWrapper.like(ProductionOrder::getOrderNo, productionOrder.getOrderNo());
+ }
+ if(StringUtils.isNotEmpty(productionOrder.getProductCategory())){
+ productionOrderLambdaQueryWrapper.like(ProductionOrder::getProductCategory, productionOrder.getProductCategory());
+ }
+ if(StringUtils.isNotEmpty(productionOrder.getEntryDateStart()) && StringUtils.isNotEmpty(productionOrder.getEntryDateEnd())){
+ productionOrderLambdaQueryWrapper.ge(ProductionOrder::getRegisterDate, productionOrder.getEntryDateStart())
+ .le(ProductionOrder::getRegisterDate, productionOrder.getEntryDateEnd());
+ }
+
+ }
+ IPage<ProductionOrder> list = productionOrderMapper.selectPage(page,productionOrderLambdaQueryWrapper);
+ if(CollectionUtils.isEmpty(list.getRecords())){
+ return AjaxResult.success(list);
+ }
+ Set<Long> collect = list.getRecords().stream().map(ProductionOrder::getId).collect(Collectors.toSet());
+ // 鑾峰彇鎺掍骇鏁伴噺
+ LambdaQueryWrapper<SalesLedgerScheduling> salesLedgerSchedulingLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ salesLedgerSchedulingLambdaQueryWrapper.in(SalesLedgerScheduling::getSalesLedgerProductId, collect);
+ List<SalesLedgerScheduling> salesLedgerSchedulings = salesLedgerSchedulingMapper.selectList(salesLedgerSchedulingLambdaQueryWrapper);
+ // 璁$畻瀹屽伐鏁伴噺
+ LambdaQueryWrapper<SalesLedgerWork> salesLedgerWorkLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ salesLedgerWorkLambdaQueryWrapper.in(SalesLedgerWork::getSalesLedgerProductId, collect)
+ .ne(SalesLedgerWork::getStatus, 1);
+ List<SalesLedgerWork> salesLedgerWorks = salesLedgerWorkMapper.selectList(salesLedgerWorkLambdaQueryWrapper);
+ list.getRecords().forEach(i -> {
+ // 鑾峰彇鎺掍骇鏁伴噺
+ i.setSchedulingNum(salesLedgerSchedulings
+ .stream()
+ .filter(j -> j.getSalesLedgerProductId().equals(i.getId()))
+ .map(SalesLedgerScheduling::getSchedulingNum)
+ .reduce(BigDecimal.ZERO, BigDecimal::add));
+ // 鑾峰彇瀹屾垚鏁伴噺
+ i.setSuccessNum(salesLedgerWorks
+ .stream()
+ .filter(j -> j.getSalesLedgerProductId().equals(i.getId()))
+ .map(SalesLedgerWork::getFinishedNum)
+ .reduce(BigDecimal.ZERO, BigDecimal::add));
+ // 鐘舵�� = 鏁伴噺鍜屽畬宸ユ暟閲忔瘮杈�
+ if(i.getSchedulingNum().compareTo(i.getSuccessNum()) == 0){
+ i.setStatus("宸插畬鎴�");
+ }else{
+ i.setStatus("鏈畬鎴�");
+ }
+ });
+ return AjaxResult.success(list);
+ }
+
+ @Override
+ public void export(HttpServletResponse response) {
+ List<ProductionOrder> list = this.list();
+ if(CollectionUtils.isEmpty(list)){
+ throw new RuntimeException("鏃犲鍑烘暟鎹�");
+ }
+ Set<Long> collect = list.stream().map(ProductionOrder::getId).collect(Collectors.toSet());
+ LambdaQueryWrapper<SalesLedgerWork> salesLedgerWorkLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ salesLedgerWorkLambdaQueryWrapper.in(SalesLedgerWork::getSalesLedgerProductId, collect)
+ .ne(SalesLedgerWork::getStatus, 1);
+ List<SalesLedgerWork> salesLedgerWorks = salesLedgerWorkMapper.selectList(salesLedgerWorkLambdaQueryWrapper);
+ list.forEach(i -> {
+ // 鑾峰彇瀹屾垚鏁伴噺
+ i.setSuccessNum(salesLedgerWorks
+ .stream()
+ .filter(j -> j.getSalesLedgerProductId().equals(i.getId()))
+ .map(SalesLedgerWork::getFinishedNum)
+ .reduce(BigDecimal.ZERO, BigDecimal::add));
+ // 鐘舵�� = 鏁伴噺鍜屽畬宸ユ暟閲忔瘮杈�
+ if(i.getQuantity().compareTo(i.getSuccessNum()) == 0){
+ i.setStatus("宸插畬鎴�");
+ }else{
+ i.setStatus("鏈畬鎴�");
+ }
+ });
+ ExcelUtil<ProductionOrder> util = new ExcelUtil<>(ProductionOrder.class);
+ util.exportExcel(response, list, "鐢熶骇璁㈠崟");
+ }
+
+ @Override
+ public void exportOne(HttpServletResponse response) {
+ List<ProductionOrder> list = this.list();
+ if(CollectionUtils.isEmpty(list)){
+ throw new RuntimeException("鏃犲鍑烘暟鎹�");
+ }
+ List<DaiDto> dais = new ArrayList<>();
+ list.forEach(i -> {
+ DaiDto daiDto = new DaiDto();
+ BeanUtils.copyProperties(i, daiDto);
+ // 鑾峰彇寰呮帓浜ф暟閲�
+ daiDto.setDaiNum(daiDto.getQuantity().subtract(i.getSuccessNum()));
+ dais.add(daiDto);
+ });
+ ExcelUtil<DaiDto> util = new ExcelUtil<>(DaiDto.class);
+ util.exportExcel(response, dais, "鐢熶骇娲惧伐");
+ }
+}
--
Gitblit v1.9.3