From 004ee58feda41620f621db1fb8773f1b56eaf71e Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期二, 30 十二月 2025 14:28:41 +0800
Subject: [PATCH] 外购成品功能迁移v1
---
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/RawMaterialOrderServiceImpl.java | 100 ++++++++++++++++++++++++++++++++++++++------------
1 files changed, 76 insertions(+), 24 deletions(-)
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/RawMaterialOrderServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/RawMaterialOrderServiceImpl.java
index 50a5633..b388357 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/RawMaterialOrderServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/RawMaterialOrderServiceImpl.java
@@ -20,21 +20,25 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.basic.dto.*;
+import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper;
+import com.ruoyi.basic.mapper.StandardTreeMapper;
import com.ruoyi.basic.pojo.IfsInventoryQuantity;
+import com.ruoyi.basic.vo.IfsInventoryQuantityVO;
+import com.ruoyi.common.config.WechatProperty;
import com.ruoyi.common.constant.InsOrderTypeConstants;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.common.core.domain.entity.User;
-import com.ruoyi.common.config.WechatProperty;
+import com.ruoyi.common.enums.OrderType;
+import com.ruoyi.common.numgen.NumberGenerator;
import com.ruoyi.common.utils.LimsDateUtil;
import com.ruoyi.common.utils.QueryWrappers;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.WxCpUtils;
import com.ruoyi.common.utils.api.IfsApiUtils;
+import com.ruoyi.framework.exception.ErrorException;
import com.ruoyi.inspect.dto.CopperInsOrderDto;
import com.ruoyi.inspect.dto.OrderSplitDTO;
import com.ruoyi.inspect.dto.RawMaterialStandardTreeDto;
-import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper;
-import com.ruoyi.basic.mapper.StandardTreeMapper;
import com.ruoyi.inspect.dto.SampleProductDto;
import com.ruoyi.inspect.excel.OrderSplitExcelData;
import com.ruoyi.inspect.excel.OrderSplitExcelListener;
@@ -48,8 +52,6 @@
import com.ruoyi.inspect.service.InsOrderService;
import com.ruoyi.inspect.service.InsReportService;
import com.ruoyi.inspect.service.RawMaterialOrderService;
-import com.ruoyi.common.numgen.NumberGenerator;
-import com.ruoyi.framework.exception.ErrorException;
import com.ruoyi.performance.mapper.AuxiliaryOutputWorkingHoursMapper;
import com.ruoyi.performance.pojo.AuxiliaryOutputWorkingHours;
import com.ruoyi.system.mapper.UserMapper;
@@ -99,7 +101,7 @@
private IfsSplitOrderRecordService ifsSplitOrderRecordService;
-
+ private final NumberGenerator<IfsSplitOrderRecord> splitOrderRecordNumberGenerator;
@Override
public Result selectStandardTreeListByPartNo(String partNo) {
@@ -111,7 +113,7 @@
for (FactoryDto factoryDto : factoryDtos) {
for (LaboratoryDto laboratoryDto : factoryDto.getChildren()) {
for (SampleTypeDto sampleTypeDto : laboratoryDto.getChildren()) {
- if (sampleTypeDto.getChildren().size() == 0) {
+ if (sampleTypeDto.getChildren().isEmpty()) {
sampleTypeDto.setChildren(standardTreeMapper.getStandardTree3(sampleTypeDto.getValue()));
}
// 鍒ゆ柇缁戝畾鐨勬槸鍚︽槸褰撳墠闆朵欢鍙�
@@ -146,12 +148,23 @@
}
@Override
- public IPage<IfsInventoryQuantity> getWarehouseSubmit(IPage<IfsInventoryQuantity> page, IfsInventoryQuantity ifsInventoryQuantity) {
- return standardTreeMapper.selectIfsPage(page, QueryWrappers.queryWrappers(ifsInventoryQuantity));
+ public IPage<IfsInventoryQuantityVO> getWarehouseSubmit(IPage<IfsInventoryQuantity> page, IfsInventoryQuantity ifsInventoryQuantity) {
+ if(ifsInventoryQuantity.getIsInspect().equals(1)){
+ ifsInventoryQuantity.setOrderType(OrderType.RAW.getValue());
+ }
+ IPage<IfsInventoryQuantityVO> ifsInventoryQuantityIPage = standardTreeMapper.selectIfsPage(page, QueryWrappers.queryWrappers(ifsInventoryQuantity));
+ ifsInventoryQuantityIPage.getRecords().forEach(f->{
+ Long count = ifsInventoryQuantityMapper.selectCount(Wrappers.<IfsInventoryQuantity>lambdaQuery()
+ .ne(IfsInventoryQuantity::getId,f.getId())
+ .eq(IfsInventoryQuantity::getUpdateBatchNo, f.getUpdateBatchNo()));
+ f.setLotBatchNoHasRepeat(count>0);
+ });
+ return ifsInventoryQuantityIPage;
}
@Override
public IPage<IfsInventoryQuantityDto> getIfsByStateOne(IPage<IfsInventoryQuantityDto> page, IfsInventoryQuantityDto ifsInventoryQuantityDto) {
+ ifsInventoryQuantityDto.setOrderType(OrderType.RAW.getValue());
return standardTreeMapper.getIfsByStateOne(page, QueryWrappers.queryWrappers(ifsInventoryQuantityDto));
}
@@ -162,13 +175,14 @@
* @return
*/
@Override
- public int inspectionReport(List<Long> ids) {
+ public int inspectionReport(List<Long> ids,String orderType) {
Integer userId = SecurityUtils.getUserId().intValue();
ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate()
.in(IfsInventoryQuantity::getId, ids)
.set(IfsInventoryQuantity::getDeclareUser, userMapper.selectById(userId).getName())
.set(IfsInventoryQuantity::getDeclareUserId, userId)
.set(IfsInventoryQuantity::getIsInspect, 1)
+ .set(IfsInventoryQuantity::getOrderType,orderType)
.set(IfsInventoryQuantity::getDeclareDate, LocalDateTime.now())
);
threadPoolTaskExecutor.execute(() -> {
@@ -222,6 +236,13 @@
return ifsInventoryQuantityMapper.printLabel(ids);
}
+
+ @Override
+ @Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
+ public Long getOrderCountByIfsId(Long ifsId) {
+ return insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getIfsInventoryId,ifsId).ne(InsOrder::getState,-1));
+ }
+
/**
* 鎶ユ
* @param ifsInventoryQuantity
@@ -230,6 +251,12 @@
@Override
public int inspectionReportOne(IfsInventoryQuantity ifsInventoryQuantity) {
Integer userId = SecurityUtils.getUserId().intValue();
+ boolean validateValue = OrderType.validateValue(ifsInventoryQuantity.getOrderType());
+ if(!validateValue){
+ throw new ErrorException("鎶ユ澶辫触锛岄潪娉曠殑閿�鍞鍗曞垎绫绘灇涓�");
+ }
+ //鎵规鍙峰瓧姣嶈浆澶у啓
+ ifsInventoryQuantity.setUpdateBatchNo(ifsInventoryQuantity.getUpdateBatchNo().toUpperCase(Locale.ROOT));
ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate()
.eq(IfsInventoryQuantity::getId, ifsInventoryQuantity.getId())
.set(IfsInventoryQuantity::getDeclareUser, userMapper.selectById(userId).getName())
@@ -237,17 +264,37 @@
.set(IfsInventoryQuantity::getIsInspect, 1)
.set(IfsInventoryQuantity::getDeclareDate, LocalDateTime.now())
.set(IfsInventoryQuantity::getUpdateBatchNo, ifsInventoryQuantity.getUpdateBatchNo())
+ .set(IfsInventoryQuantity::getOrderType,ifsInventoryQuantity.getOrderType())
);
threadPoolTaskExecutor.execute(() -> {
IfsInventoryQuantity inventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsInventoryQuantity.getId());
- // 浼佷笟寰俊閫氱煡
- String message = "";
- message += "鏂板鎶ユ閫氱煡";
- message += "\n鎵规鍙�: " + inventoryQuantity.getUpdateBatchNo();
- message += "\n闆朵欢鎻忚堪: " + inventoryQuantity.getPartDesc();
- message += "\n鎶佃揪鏁伴噺: " + inventoryQuantity.getQtyArrived().stripTrailingZeros().toPlainString() + inventoryQuantity.getBuyUnitMeas();
- WxCpUtils.informWebHook(wechatProperty.getExaminingUrl(), message);
+ //鏌ヨ鐩稿悓鎵瑰彿鐨勫巻鍙瞚fs璁㈠崟
+ List<IfsInventoryQuantity> historyRecords = ifsInventoryQuantityMapper.selectList(Wrappers.<IfsInventoryQuantity>lambdaQuery()
+ .ne(IfsInventoryQuantity::getId, ifsInventoryQuantity.getId())
+ .eq(IfsInventoryQuantity::getIsInspect, 1)
+ .eq(IfsInventoryQuantity::getUpdateBatchNo, ifsInventoryQuantity.getUpdateBatchNo())
+ );
+ if(CollUtil.isEmpty(historyRecords)){
+ // 浼佷笟寰俊閫氱煡
+ String message = "";
+ message += "鏂板鎶ユ閫氱煡";
+ message += "\n鎵规鍙�: " + inventoryQuantity.getUpdateBatchNo();
+ message += "\n闆朵欢鎻忚堪: " + inventoryQuantity.getPartDesc();
+ message += "\n鎶佃揪鏁伴噺: " + inventoryQuantity.getQtyArrived().stripTrailingZeros().toPlainString() + inventoryQuantity.getBuyUnitMeas();
+ WxCpUtils.informWebHook(wechatProperty.getExaminingUrl(), message);
+ }else{
+ //鑾峰彇鍘嗗彶鎶佃揪鏁伴噺
+ double sum = historyRecords.stream().map(IfsInventoryQuantity::getQtyArrived).mapToDouble(BigDecimal::doubleValue).sum();
+ String historyQuantity = sum + inventoryQuantity.getBuyUnitMeas();
+ String messageMarkdown = "";
+ messageMarkdown += "鏂板鎶ユ閫氱煡";
+ messageMarkdown += "\n鎵规鍙�: <font color='warning'>" + inventoryQuantity.getUpdateBatchNo() + "</font>";
+ messageMarkdown += "\n闆朵欢鎻忚堪: "+ inventoryQuantity.getPartDesc();
+ messageMarkdown += "\n鎶佃揪鏁伴噺: " + inventoryQuantity.getQtyArrived().stripTrailingZeros().toPlainString() + inventoryQuantity.getBuyUnitMeas();
+ messageMarkdown += "\n鍘嗗彶鎶佃揪鏁伴噺: " + historyQuantity;
+ WxCpUtils.informWebHook(wechatProperty.getExaminingUrl(), messageMarkdown,"markdown");
+ }
});
return 1;
}
@@ -388,8 +435,9 @@
String endDeclareDate = ifsInventoryQuantityDto.getEndDeclareDate();
ifsInventoryQuantityDto.setBeginDeclareDate(null);
ifsInventoryQuantityDto.setEndDeclareDate(null);
-
+ ifsInventoryQuantityDto.setOrderType(OrderType.RAW.getValue());
IPage<IfsInventoryQuantitySupplierDto> ifsByOver = standardTreeMapper.getIfsByOver(page, QueryWrappers.queryWrappers(ifsInventoryQuantityDto), beginDeclareDate, endDeclareDate);
+ ifsByOver.getRecords().forEach(r->r.setOrderTypeName(OrderType.getLabelByValue(r.getOrderType())));
return ifsByOver;
}
@@ -506,6 +554,9 @@
ifsInventoryQuantity.setIsSource(0);
ifsInventoryQuantity.setState(0);
ifsInventoryQuantity.setIsFinish(0);
+ if(!OrderType.validateValue(ifsInventoryQuantity.getOrderType())){
+ throw new ErrorException("鏂板鎶ユ淇℃伅澶辫触锛岄潪娉曠殑閿�鍞鍗曞垎绫绘灇涓�");
+ }
ifsInventoryQuantityMapper.insert(ifsInventoryQuantity);
}
@@ -769,7 +820,7 @@
String endDeclareDate = ifsInventoryQuantityDto.getEndDeclareDate();
ifsInventoryQuantityDto.setBeginDeclareDate(null);
ifsInventoryQuantityDto.setEndDeclareDate(null);
-
+ ifsInventoryQuantityDto.setOrderType(OrderType.RAW.getValue());
return standardTreeMapper.getIfsByQuarter(page, QueryWrappers.queryWrappers(ifsInventoryQuantityDto), beginDeclareDate, endDeclareDate);
}
@@ -921,20 +972,21 @@
if(Objects.nonNull(splitOrderList) && !splitOrderList.isEmpty()){
List<Long> ids = splitOrderList.stream().map(IfsInventoryQuantity::getId).collect(Collectors.toList());
ids.add(ifsInventoryQuantity.getId());
- this.inspectionReport(ids);
+ this.inspectionReport(ids,OrderType.RAW.getValue());
}
//鍕鹃�夊悓姝ュ埌MES锛屼繚瀛樿鍗曟媶鍒嗚褰�
if(orderSplitDTO.getPushToMes()){
- List<IfsSplitOrderRecord> collect = orderSplitDTO.getSplitDetailList().stream().map(m -> {
+ orderSplitDTO.getSplitDetailList().forEach(m -> {
IfsSplitOrderRecord record = new IfsSplitOrderRecord();
BeanUtil.copyProperties(m, record);
+ record.setSystemNo(splitOrderRecordNumberGenerator.generateNumberWithPrefix(IfsSplitOrderRecord.DIGIT, IfsSplitOrderRecord.PREFIX, IfsSplitOrderRecord::getSystemNo));
record.setOrderNo(ifsInventoryQuantity.getOrderNo());
record.setLineNo(ifsInventoryQuantity.getLineNo());
record.setReleaseNo(ifsInventoryQuantity.getReleaseNo());
record.setReceiptNo(ifsInventoryQuantity.getReceiptNo());
- return record;
- }).collect(Collectors.toList());
- return ifsSplitOrderRecordService.saveBatch(collect);
+ ifsSplitOrderRecordService.save(record);
+ });
+ return true;
}
return false;
}
--
Gitblit v1.9.3