From 4b9dc71d162f3fcd79bc88b170154b7516fc4962 Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期四, 18 十二月 2025 13:37:14 +0800
Subject: [PATCH] 新增设备维修保养过程描述,上传对应附件
---
src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java | 120 ++++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 77 insertions(+), 43 deletions(-)
diff --git a/src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java
index 96be320..7c96246 100644
--- a/src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java
@@ -25,6 +25,7 @@
import lombok.RequiredArgsConstructor;
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;
@@ -32,6 +33,7 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
+import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -56,6 +58,11 @@
@Override
public IPage<SalesLedgerSchedulingDto> listPage(Page page, SalesLedgerSchedulingDto salesLedgerSchedulingDto) {
+ LoginUser loginUser = SecurityUtils.getLoginUser();
+ if(!"admin".equals(loginUser.getUsername())){
+ salesLedgerSchedulingDto.setProductionUserId(SecurityUtils.getLoginUser().getUser().getUserId());
+ salesLedgerSchedulingDto.setProductionUserName(SecurityUtils.getLoginUser().getUser().getNickName());
+ }
IPage<SalesLedgerSchedulingDto> list = salesLedgerSchedulingMapper.listPage(page, salesLedgerSchedulingDto);
if(list.getTotal() == 0){
return list;
@@ -82,7 +89,7 @@
}
// 璁$畻鐢熶骇鎬婚噺 = 瑙勬牸 * 鏁伴噺 / 1000
String[] split = i.getSpecificationModel().split("\\*");
- if(split.length == 2){
+ if(split.length == 2 && isNumeric(split[0]) && isNumeric(split[1])){
BigDecimal multiply = new BigDecimal(split[0])
.multiply(new BigDecimal(split[1])
.multiply(i.getQuantity()).divide(new BigDecimal(1000),2, RoundingMode.CEILING));
@@ -91,6 +98,19 @@
});
return list;
+ }
+
+ public static boolean isNumeric(String str) {
+ if (str == null || str.isEmpty()) {
+ return false;
+ }
+ // 閬嶅巻瀛楃涓茬殑姣忎釜瀛楃锛屾鏌ユ槸鍚︿负鏁板瓧
+ for (int i = 0; i < str.length(); i++) {
+ if (!Character.isDigit(str.charAt(i))) {
+ return false;
+ }
+ }
+ return true;
}
@Override
@@ -131,52 +151,60 @@
i++;
continue;
}
- // 鑾峰彇绌轰綑鐐掓満
- String[] split = productionDispatchAddDto.getSpeculativeTradingName().split(",");
- if(split != null && split.length == 0){
+ SysUser sysUser1 = sysUserMapper.selectUserById(productionDispatchAddDto.getProductionUserId() == null ? loginUser.getUser().getUserId() : productionDispatchAddDto.getSchedulingUserId());
+ if(sysUser1 == null){
i++;
continue;
}
- List<SpeculativeTradingInfo> speculativeTradingInfos = speculativeTradingInfoMapper.selectList(new LambdaQueryWrapper<SpeculativeTradingInfo>()
- .in(SpeculativeTradingInfo::getName, Arrays.asList(split))
- .orderByAsc(SpeculativeTradingInfo::getSort));
- if(CollectionUtils.isEmpty(speculativeTradingInfos)){
- i++;
- continue;
- }
- AtomicReference<String> name = new AtomicReference<>(""); //闇�瑕佺粦瀹氱殑鐐掓満
- //閫氳繃瑙勬牸鍨嬪彿鍜屾帓浜ф暟閲忚绠楁湰娆$敓浜т骇閲�
- String[] split1 = productionDispatchAddDto.getSpecificationModel().split("\\*");
- if(split1.length != 2){
- i++;
- continue;
- }
- // 鏈鐢熶骇浜ч噺
- BigDecimal productionNum = new BigDecimal(split1[0])
- .multiply(new BigDecimal(split1[1]).multiply(productionDispatchAddDto.getSchedulingNum()));
- // 澶氫釜鐐掓満鎯呭喌
- if(speculativeTradingInfos.size() > 1){
- for (SpeculativeTradingInfo speculativeTradingInfo : speculativeTradingInfos) {
- // 鑾峰彇璇ョ倰鏈烘鍦ㄦ帓浜ч噺
- BigDecimal schedulingNumBySpeculativeTradingName = getSchedulingNumBySpeculativeTradingName(speculativeTradingInfo.getName());
- // 濡傛灉璇ョ倰鏈烘�婚噺(鍗曚綅kg闇�瑕佷箻1000) - 姝e湪鎺掍骇閲� >=鏈鐢熶骇浜ч噺灏卞垎閰嶆鐐掓満
- if(speculativeTradingInfo.getWorkLoad().multiply(new BigDecimal(1000)).subtract(schedulingNumBySpeculativeTradingName).compareTo(productionNum) >= 0){
- name.set(speculativeTradingInfo.getName());
- break;
- }
- }
- }else{
- // 鍗曚釜鐐掓満鎯呭喌
- name.set(speculativeTradingInfos.get(0).getName());
- }
- if(name.get().isEmpty()){
- i++;
- continue;
- }
+// // 鑾峰彇绌轰綑鐐掓満
+// String[] split = productionDispatchAddDto.getSpeculativeTradingName().split(",");
+// if(split != null && split.length == 0){
+// i++;
+// continue;
+// }
+// List<SpeculativeTradingInfo> speculativeTradingInfos = speculativeTradingInfoMapper.selectList(new LambdaQueryWrapper<SpeculativeTradingInfo>()
+// .in(SpeculativeTradingInfo::getName, Arrays.asList(split))
+// .orderByAsc(SpeculativeTradingInfo::getSort));
+// if(CollectionUtils.isEmpty(speculativeTradingInfos)){
+// i++;
+// continue;
+// }
+// AtomicReference<String> name = new AtomicReference<>(""); //闇�瑕佺粦瀹氱殑鐐掓満
+// //閫氳繃瑙勬牸鍨嬪彿鍜屾帓浜ф暟閲忚绠楁湰娆$敓浜т骇閲�
+// String[] split1 = productionDispatchAddDto.getSpecificationModel().split("\\*");
+// if(split1.length != 2){
+// i++;
+// continue;
+// }
+// // 鏈鐢熶骇浜ч噺
+// BigDecimal productionNum = new BigDecimal(split1[0])
+// .multiply(new BigDecimal(split1[1]).multiply(productionDispatchAddDto.getSchedulingNum()));
+// // 澶氫釜鐐掓満鎯呭喌
+// if(speculativeTradingInfos.size() > 1){
+// for (SpeculativeTradingInfo speculativeTradingInfo : speculativeTradingInfos) {
+// // 鑾峰彇璇ョ倰鏈烘鍦ㄦ帓浜ч噺
+// BigDecimal schedulingNumBySpeculativeTradingName = getSchedulingNumBySpeculativeTradingName(speculativeTradingInfo.getName());
+// // 濡傛灉璇ョ倰鏈烘�婚噺(鍗曚綅kg闇�瑕佷箻1000) - 姝e湪鎺掍骇閲� >=鏈鐢熶骇浜ч噺灏卞垎閰嶆鐐掓満
+// if(speculativeTradingInfo.getWorkLoad().multiply(new BigDecimal(1000)).subtract(schedulingNumBySpeculativeTradingName).compareTo(productionNum) >= 0){
+// name.set(speculativeTradingInfo.getName());
+// break;
+// }
+// }
+// }else{
+// // 鍗曚釜鐐掓満鎯呭喌
+// name.set(speculativeTradingInfos.get(0).getName());
+// }
+// if(name.get().isEmpty()){
+// i++;
+// continue;
+// }
SalesLedgerScheduling salesLedgerScheduling = SalesLedgerScheduling.builder()
.salesLedgerId(productionDispatchAddDto.getSalesLedgerId())
.salesLedgerProductId(productionDispatchAddDto.getSalesLedgerProductId())
- .speculativeTradingName(name.get())
+// .speculativeTradingName(name.get())
+ .productionUserId(sysUser1.getUserId())
+ .productionUserName(sysUser1.getNickName())
+ .productionLineId(productionDispatchAddDto.getLineId())
.schedulingUserId(sysUser.getUserId())
.schedulingUserName(sysUser.getNickName())
.schedulingNum(productionDispatchAddDto.getSchedulingNum())
@@ -229,7 +257,7 @@
return new BigDecimal(totalNum.get()).multiply(new BigDecimal(100)).divide(lossNum, 2,RoundingMode.HALF_UP);
}
- private LossMapper lossMapper;
+ private final LossMapper lossMapper;
/**
@@ -267,6 +295,10 @@
@Override
public IPage<SalesLedgerSchedulingProcessDto> listPageProcess(Page page, SalesLedgerSchedulingProcessDto salesLedgerSchedulingDto) {
+ LoginUser loginUser = SecurityUtils.getLoginUser();
+ if(!"admin".equals(loginUser.getUsername())){
+ salesLedgerSchedulingDto.setProductionUserId(loginUser.getUserId());
+ }
IPage<SalesLedgerSchedulingProcessDto> list = salesLedgerSchedulingMapper.listPageProcess(page, salesLedgerSchedulingDto);
// Set<Long> collect = list.getRecords().stream().map(SalesLedgerSchedulingProcessDto::getId).collect(Collectors.toSet());
// if(CollectionUtils.isEmpty(collect)) return list;
@@ -277,7 +309,7 @@
list.getRecords().forEach(i -> {
// 璁$畻鐢熶骇鎬婚噺 = 瑙勬牸 * 鏁伴噺 / 1000
String[] split = i.getSpecificationModel().split("\\*");
- if(split.length == 2){
+ if(split.length == 2 && isNumeric(split[0]) && isNumeric(split[1])){
BigDecimal multiply = new BigDecimal(split[0])
.multiply(new BigDecimal(split[1])
.multiply(i.getSuccessNum()).divide(new BigDecimal(1000),2, RoundingMode.CEILING));
@@ -324,6 +356,8 @@
SalesLedgerWork.SalesLedgerWorkBuilder salesLedgerWorkBuilder = SalesLedgerWork.builder()
.salesLedgerSchedulingId(salesLedgerScheduling.getId())
.salesLedgerId(salesLedgerScheduling.getSalesLedgerId())
+ .productionUserId(salesLedgerScheduling.getProductionUserId())
+ .productionUserName(salesLedgerScheduling.getProductionUserName())
.remark(processSchedulingDto.getRemark())
.type(processSchedulingDto.getType())
.loss(processSchedulingDto.getLoss())
--
Gitblit v1.9.3