From 28c0d364e7ff349a77037c3770acaa9f656fb93b Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期三, 12 十一月 2025 18:01:27 +0800
Subject: [PATCH] yys 1.仓储物流增加分类管理 2.仓储物流分类管理导出接口 4.新疆生产管控定制化
---
src/main/java/com/ruoyi/production/service/SalesLedgerSchedulingService.java | 2
src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java | 116 ++++++++++++++++++++++++--------------
src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java | 2
src/main/java/com/ruoyi/production/controller/SalesLedgerSchedulingController.java | 19 +++++
src/main/resources/mapper/production/SalesLedgerSchedulingMapper.xml | 1
src/main/java/com/ruoyi/production/dto/SalesLedgerSchedulingProcessDto.java | 6 ++
6 files changed, 98 insertions(+), 48 deletions(-)
diff --git a/src/main/java/com/ruoyi/production/controller/SalesLedgerSchedulingController.java b/src/main/java/com/ruoyi/production/controller/SalesLedgerSchedulingController.java
index fd4b2b2..169b83f 100644
--- a/src/main/java/com/ruoyi/production/controller/SalesLedgerSchedulingController.java
+++ b/src/main/java/com/ruoyi/production/controller/SalesLedgerSchedulingController.java
@@ -23,6 +23,9 @@
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -47,7 +50,8 @@
public AjaxResult list() {
List<SpeculativeTradingInfo> result = speculativeTradingInfoMapper.selectList(null);
result.forEach(item -> {
- item.setCurrentWorkLoad(salesLedgerSchedulingService.getSchedulingNumBySpeculativeTradingName(item.getName()));
+
+ item.setCurrentWorkLoad(salesLedgerSchedulingService.getSchedulingNumBySpeculativeTradingName(item.getName()).divide(new BigDecimal(1000),2, RoundingMode.CEILING));
item.setVacant(item.getWorkLoad().subtract(item.getCurrentWorkLoad()));
});
return AjaxResult.success(result);
@@ -110,7 +114,18 @@
@ApiOperation("鐢熶骇绠$悊-鐢熶骇璁㈠崟-鐢熶骇娲惧伐")
@Transactional(rollbackFor = Exception.class)
public AjaxResult productionDispatch(@RequestBody ProductionDispatchAddDto productionDispatchAddDto) {
- int result = salesLedgerSchedulingService.productionDispatch(productionDispatchAddDto);
+ List<ProductionDispatchAddDto> productionDispatchAddDtoList = new ArrayList<>();
+ productionDispatchAddDtoList.add(productionDispatchAddDto);
+ String result = salesLedgerSchedulingService.productionDispatch(productionDispatchAddDtoList);
+ return AjaxResult.success(result);
+ }
+
+ @PostMapping("/productionDispatchList")
+ @Log(title = "鐢熶骇绠$悊-鐢熶骇璁㈠崟-鑷姩娲惧伐", businessType = BusinessType.INSERT)
+ @ApiOperation("鐢熶骇绠$悊-鐢熶骇璁㈠崟-鑷姩娲惧伐")
+ @Transactional(rollbackFor = Exception.class)
+ public AjaxResult productionDispatchList(@RequestBody List<ProductionDispatchAddDto> productionDispatchAddDto) {
+ String result = salesLedgerSchedulingService.productionDispatch(productionDispatchAddDto);
return AjaxResult.success(result);
}
diff --git a/src/main/java/com/ruoyi/production/dto/SalesLedgerSchedulingProcessDto.java b/src/main/java/com/ruoyi/production/dto/SalesLedgerSchedulingProcessDto.java
index 8952455..f60b055 100644
--- a/src/main/java/com/ruoyi/production/dto/SalesLedgerSchedulingProcessDto.java
+++ b/src/main/java/com/ruoyi/production/dto/SalesLedgerSchedulingProcessDto.java
@@ -26,6 +26,12 @@
@ApiModelProperty(value = "閿�鍞彴璐D")
private Long salesLedgerId;
+ /**
+ * 鐢熶骇鐐掓満
+ */
+ @Excel(name = "鐢熶骇鐐掓満")
+ private String speculativeTradingName;
+
@ApiModelProperty(value = "寮�濮嬫椂闂�")
private String entryDateStart;
diff --git a/src/main/java/com/ruoyi/production/service/SalesLedgerSchedulingService.java b/src/main/java/com/ruoyi/production/service/SalesLedgerSchedulingService.java
index 2387e87..813553a 100644
--- a/src/main/java/com/ruoyi/production/service/SalesLedgerSchedulingService.java
+++ b/src/main/java/com/ruoyi/production/service/SalesLedgerSchedulingService.java
@@ -22,7 +22,7 @@
void export(HttpServletResponse response);
- int productionDispatch(ProductionDispatchAddDto productionDispatchAddDto);
+ String productionDispatch(List<ProductionDispatchAddDto> productionDispatchAddDto);
IPage<SalesLedgerSchedulingProcessDto> listPageProcess(Page page, SalesLedgerSchedulingProcessDto salesLedgerSchedulingDto);
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 0bfe363..f9d6105 100644
--- a/src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java
@@ -4,7 +4,10 @@
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.DateUtils;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.framework.security.LoginUser;
import com.ruoyi.production.dto.*;
import com.ruoyi.production.mapper.SalesLedgerSchedulingMapper;
import com.ruoyi.production.mapper.SalesLedgerWorkMapper;
@@ -67,10 +70,12 @@
.map(SalesLedgerWork::getFinishedNum)
.reduce(BigDecimal.ZERO, BigDecimal::add));
// 鐘舵�� = 鏁伴噺鍜屽畬宸ユ暟閲忔瘮杈�
- if(i.getSchedulingNum().compareTo(i.getSuccessNum()) == 0){
+ if(i.getSchedulingNum().compareTo(new BigDecimal(0)) == 0){
+ i.setStatus("鏈畬鎴�");
+ } else if(i.getSchedulingNum().compareTo(i.getSuccessNum()) == 0){
i.setStatus("宸插畬鎴�");
}else{
- i.setStatus("鏈畬鎴�");
+ i.setStatus("鐢熶骇涓�");
}
});
return list;
@@ -104,50 +109,73 @@
private final SpeculativeTradingInfoMapper speculativeTradingInfoMapper;
@Override
- public int productionDispatch(ProductionDispatchAddDto productionDispatchAddDto) {
- SysUser sysUser = sysUserMapper.selectUserById(productionDispatchAddDto.getSchedulingUserId());
- if(sysUser == null) throw new RuntimeException("鎺掍骇浜轰笉瀛樺湪");
- // 鑾峰彇绌轰綑鐐掓満
- String[] split = productionDispatchAddDto.getSpeculativeTradingName().split(",");
- if(split != null && split.length == 0){
- throw new RuntimeException("鐢熶骇鐐掓満涓嶈兘涓虹┖");
- }
- List<SpeculativeTradingInfo> speculativeTradingInfos = speculativeTradingInfoMapper.selectList(new LambdaQueryWrapper<SpeculativeTradingInfo>()
- .in(SpeculativeTradingInfo::getName, Arrays.asList(split))
- .orderByAsc(SpeculativeTradingInfo::getSort));
- if(CollectionUtils.isEmpty(speculativeTradingInfos)){
- throw new RuntimeException("鏃犵┖浣欑倰鏈�,璇锋鏌ョ倰鏈鸿〃");
- }
- AtomicReference<String> name = new AtomicReference<>(""); //闇�瑕佺粦瀹氱殑鐐掓満
- //閫氳繃瑙勬牸鍨嬪彿鍜屾帓浜ф暟閲忚绠楁湰娆$敓浜т骇閲�
- String[] split1 = productionDispatchAddDto.getSpecificationModel().split("\\*");
- if(split1.length != 2) throw new RuntimeException("瑙勬牸鍨嬪彿鏍煎紡閿欒");
- // 鏈鐢熶骇浜ч噺
- BigDecimal productionNum = new BigDecimal(split1[0])
- .multiply(new BigDecimal(split1[1]).multiply(productionDispatchAddDto.getSchedulingNum()));
- // 澶氫釜鐐掓満鎯呭喌
- if(speculativeTradingInfos.size() > 1){
- speculativeTradingInfos.forEach(item ->{
- // 鑾峰彇璇ョ倰鏈烘鍦ㄦ帓浜ч噺
- BigDecimal schedulingNumBySpeculativeTradingName = getSchedulingNumBySpeculativeTradingName(item.getName());
- // 濡傛灉璇ョ倰鏈烘�婚噺 - 姝e湪鎺掍骇閲� >=鏈鐢熶骇浜ч噺灏卞垎閰嶆鐐掓満
- if(item.getWorkLoad().subtract(schedulingNumBySpeculativeTradingName).compareTo(productionNum) >= 0){
- name.set(item.getName());
+ public String productionDispatch(List<ProductionDispatchAddDto> productionDispatchAddDtoList) {
+ int i = 0;
+ int successNum = 0;
+ LoginUser loginUser = SecurityUtils.getLoginUser();
+ for (ProductionDispatchAddDto productionDispatchAddDto : productionDispatchAddDtoList) {
+ SysUser sysUser = sysUserMapper.selectUserById(productionDispatchAddDto.getSchedulingUserId() == null ? loginUser.getUser().getUserId() : productionDispatchAddDto.getSchedulingUserId());
+ if(sysUser == null){
+ 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())
+ .schedulingUserId(sysUser.getUserId())
+ .schedulingUserName(sysUser.getNickName())
+ .schedulingNum(productionDispatchAddDto.getSchedulingNum())
+ .schedulingDate(productionDispatchAddDto.getSchedulingDate() == null ? LocalDate.now() : LocalDate.parse(productionDispatchAddDto.getSchedulingDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")))
+ .status(1)
+ .build();
+ salesLedgerSchedulingMapper.insert(salesLedgerScheduling);
+ successNum++;
}
- if(name.get().isEmpty()) throw new RuntimeException("鏃犵┖浣欑倰鏈�,璇锋鏌ョ倰鏈鸿〃");
- SalesLedgerScheduling salesLedgerScheduling = SalesLedgerScheduling.builder()
- .salesLedgerId(productionDispatchAddDto.getSalesLedgerId())
- .salesLedgerProductId(productionDispatchAddDto.getSalesLedgerProductId())
- .speculativeTradingName(name.get())
- .schedulingUserId(productionDispatchAddDto.getSchedulingUserId())
- .schedulingUserName(sysUser.getNickName())
- .schedulingNum(productionDispatchAddDto.getSchedulingNum())
- .schedulingDate(LocalDate.parse(productionDispatchAddDto.getSchedulingDate(), DateTimeFormatter.ISO_LOCAL_DATE))
- .status(1)
- .build();
- return salesLedgerSchedulingMapper.insert(salesLedgerScheduling);
+
+ return "娲惧伐鎴愬姛鏁伴噺" + successNum + "锛屽け璐ユ暟閲�" + i;
}
private final SalesLedgerProductMapper salesLedgerProductMapper;
diff --git a/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java b/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
index c384520..d06132c 100644
--- a/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
+++ b/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
@@ -264,7 +264,7 @@
iPage.getRecords().removeIf(salesLedger -> Objects.equals(salesLedger.getNoInvoiceAmountTotal(), new BigDecimal("0.00")));
}
}
- iPage.setTotal(iPage.getRecords().size());
+ iPage.setTotal(iPage.getTotal());
return iPage;
}
}
diff --git a/src/main/resources/mapper/production/SalesLedgerSchedulingMapper.xml b/src/main/resources/mapper/production/SalesLedgerSchedulingMapper.xml
index aacfbba..6009d15 100644
--- a/src/main/resources/mapper/production/SalesLedgerSchedulingMapper.xml
+++ b/src/main/resources/mapper/production/SalesLedgerSchedulingMapper.xml
@@ -72,6 +72,7 @@
T2.status,
T2.scheduling_user_id,
T2.scheduling_user_name,
+ T2.speculative_trading_name,
T2.scheduling_date,
ifNull(T2.scheduling_num,0) AS schedulingNum,
ifNull(T2.finished_num,0) AS successNum,
--
Gitblit v1.9.3