From bf2026a38d4d36371060673d4651b6e05ca90632 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期二, 01 九月 2026 17:07:30 +0800
Subject: [PATCH] feat(device): 1.更新设备导入验证逻辑和检验任务功能 2.报告编制
---
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java | 167 ++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 114 insertions(+), 53 deletions(-)
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
index ebbf0c2..cb1f287 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
@@ -16,6 +16,7 @@
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.basic.dto.InventoryDetailDTO;
import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper;
import com.ruoyi.basic.mapper.StandardProductListMapper;
import com.ruoyi.basic.mapper.StructureItemParameterMapper;
@@ -26,6 +27,7 @@
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.enums.OrderType;
import com.ruoyi.common.numgen.NumberGenerator;
import com.ruoyi.common.utils.LimsDateUtil;
import com.ruoyi.common.utils.QueryWrappers;
@@ -39,6 +41,7 @@
import com.ruoyi.inspect.service.InsOrderStateService;
import com.ruoyi.inspect.service.InsProductService;
import com.ruoyi.inspect.service.InsSampleService;
+import com.ruoyi.inspect.vo.IfsOrderVO;
import com.ruoyi.inspect.vo.InsOrderPrintingVo;
import com.ruoyi.system.mapper.UserMapper;
import lombok.AllArgsConstructor;
@@ -312,9 +315,9 @@
}
}
});
- //鏄惁涓哄師鏉愭枡涓嬪崟
- if (insOrder.getTypeSource() != null && insOrder.getTypeSource().equals(1)) {
- // 鍘熸潗鏂欎笅鍗�: 濮旀墭浜哄氨鏄姤妫�浜�, 鐢熶骇鍗曚綅灏辨槸渚涘簲鍟嗗崟浣�
+ //鍘熸潗鏂欎笅鍗曟垨澶栬喘鎴愬搧涓嬪崟
+ if (Objects.nonNull(insOrder.getTypeSource())&&Objects.nonNull(insOrder.getIfsInventoryId())) {
+ // 濮旀墭浜哄氨鏄姤妫�浜�, 鐢熶骇鍗曚綅灏辨槸渚涘簲鍟嗗崟浣�
IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(insOrder.getIfsInventoryId());
Integer declareUserId = ifsInventoryQuantity.getDeclareUserId();
User user = userMapper.selectById(declareUserId);
@@ -352,47 +355,51 @@
upInsOrderOfState(insOrder);
// 鍒嗛厤妫�楠屼汉
- upInsOrder(insOrder.getId(), null, appointed != null ? appointed.toString() : null, SecurityUtils.getUserId().intValue(), "鍘熸潗鏂�");
+ String sonLaboratory = insOrder.getTypeSource().equals(1)?"鍘熸潗鏂�":"鎴愬搧瀹為獙瀹�";
+ upInsOrder(insOrder.getId(), null, appointed != null ? appointed.toString() : null, SecurityUtils.getUserId().intValue(), sonLaboratory);
- // 鏍规嵁闆朵欢鍙峰垽鏂槸鍚︽槸杈呮潗
- boolean isRaw = false;
- StructureTestObject productObject = insOrderMapper.selectProductByPartNo(ifsInventoryQuantity.getPartNo());
- // 鏌ヨ浜у搧
- if (productObject != null && StrUtil.isNotBlank(productObject.getObjectType()) && productObject.getObjectType().equals("1")) {
- isRaw = true;
- } else {
- // 鏌ヨ瀵硅薄
- StructureTestObject testObject = insOrderMapper.selectByPartNo(ifsInventoryQuantity.getPartNo());
- if (testObject != null && StrUtil.isNotBlank(testObject.getObjectType()) && testObject.getObjectType().equals("1")) {
+ //鏄惁涓哄師鏉愭枡涓嬪崟
+ if(insOrder.getTypeSource().equals(1)){
+ // 鏍规嵁闆朵欢鍙峰垽鏂槸鍚︽槸杈呮潗
+ boolean isRaw = false;
+ StructureTestObject productObject = insOrderMapper.selectProductByPartNo(ifsInventoryQuantity.getPartNo());
+ // 鏌ヨ浜у搧
+ if (productObject != null && StrUtil.isNotBlank(productObject.getObjectType()) && productObject.getObjectType().equals("1")) {
isRaw = true;
+ } else {
+ // 鏌ヨ瀵硅薄
+ StructureTestObject testObject = insOrderMapper.selectByPartNo(ifsInventoryQuantity.getPartNo());
+ if (testObject != null && StrUtil.isNotBlank(testObject.getObjectType()) && testObject.getObjectType().equals("1")) {
+ isRaw = true;
+ }
}
- }
- if (isRaw) {
- // 鑾峰彇褰撳墠瀛e害鐨勫紑濮嬫椂闂村拰缁撴潫鏃堕棿
- LocalDateTime now = LocalDateTime.now();
- // 鑾峰彇褰撳墠鏈堜唤
- int month = now.getMonthValue();
- // 纭畾褰撳墠瀛e害鐨勫紑濮嬫湀浠�
- int startMonth = (month - 1) / 3 * 3 + 1;
- // 鏋勯�犲搴︾殑寮�濮嬫椂闂�
- LocalDateTime startOfQuarter = LocalDateTime.of(now.getYear(), Month.of(startMonth), 1, 0, 0);
- // 璁$畻涓嬩竴涓搴︾殑寮�濮嬫椂闂�
- LocalDateTime startOfNextQuarter = startOfQuarter.plusMonths(3);
- // 璁$畻褰撳墠瀛e害鐨勭粨鏉熸椂闂�
- LocalDateTime endOfQuarter = startOfNextQuarter.minusSeconds(1);
+ if (isRaw) {
+ // 鑾峰彇褰撳墠瀛e害鐨勫紑濮嬫椂闂村拰缁撴潫鏃堕棿
+ LocalDateTime now = LocalDateTime.now();
+ // 鑾峰彇褰撳墠鏈堜唤
+ int month = now.getMonthValue();
+ // 纭畾褰撳墠瀛e害鐨勫紑濮嬫湀浠�
+ int startMonth = (month - 1) / 3 * 3 + 1;
+ // 鏋勯�犲搴︾殑寮�濮嬫椂闂�
+ LocalDateTime startOfQuarter = LocalDateTime.of(now.getYear(), Month.of(startMonth), 1, 0, 0);
+ // 璁$畻涓嬩竴涓搴︾殑寮�濮嬫椂闂�
+ LocalDateTime startOfNextQuarter = startOfQuarter.plusMonths(3);
+ // 璁$畻褰撳墠瀛e害鐨勭粨鏉熸椂闂�
+ LocalDateTime endOfQuarter = startOfNextQuarter.minusSeconds(1);
- // 鏍规嵁涓嬪崟鐨勮鏍煎瀷鍙峰垽鏂槸鍚︿负瀛e害棣栨鍑虹幇
- Integer count = ifsInventoryQuantityMapper.selectIsFirst(insOrder.getPartDetail(),
- ifsInventoryQuantity.getSupplierName(),
- startOfNextQuarter,
- endOfQuarter);
+ // 鏍规嵁涓嬪崟鐨勮鏍煎瀷鍙峰垽鏂槸鍚︿负瀛e害棣栨鍑虹幇
+ Integer count = ifsInventoryQuantityMapper.selectIsFirst(insOrder.getPartDetail(),
+ ifsInventoryQuantity.getSupplierName(),
+ startOfNextQuarter,
+ endOfQuarter);
- if(count == 0) {
- ifsInventoryQuantity.setIsFirst(1);
- ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate()
- .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId())
- .set(IfsInventoryQuantity::getIsFirst, 1));
+ if (count == 0) {
+ ifsInventoryQuantity.setIsFirst(1);
+ ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate()
+ .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId())
+ .set(IfsInventoryQuantity::getIsFirst, 1));
+ }
}
}
}
@@ -516,9 +523,10 @@
@Override
public Map<String, Object> getInsOrderAndSample(Integer id, String laboratory) {
Map<String, Object> map = new HashMap<>();
- InsOrder insOrder = insOrderMapper.selectById(id);
+// InsOrder insOrder = insOrderMapper.selectById(id);
+ IfsOrderVO ifsOrderVO = insOrderMapper.selectOrderInfoById(id);
List<SampleProductDto> list = insSampleMapper.getInsOrderAndSample(id, laboratory);
- map.put("insOrder", insOrder);
+ map.put("insOrder", ifsOrderVO);
map.put("sampleProduct", list);
//鏌ヨ鎵�鏈夎褰曟ā鐗堝幓閲�
List<Map<Integer, Object>> list2 = insOrderMapper.selectReportModelByOrderId(id, laboratory);
@@ -640,13 +648,6 @@
if(isSplitOrder){
ifsInventoryQuantity.setIsSplitOrder(1);
}
- //todo:涓嶆竻妤氱敤閫旓紝鏆傛椂灞忚斀鎺�
- // 鏌ヨ浜т笟閾炬娴嬫暟鎹�
-// String industryChainAttrFields = IndustryChainUtils.getIndustryChainAttrFields(ifsInventoryQuantity.getOrderNo(),
-// ifsInventoryQuantity.getLineNo(),
-// ifsInventoryQuantity.getReleaseNo());
-// ifsInventoryQuantity.setIndustryChain(industryChainAttrFields);
-
ifsInventoryQuantityMapper.insert(ifsInventoryQuantity);
}
}
@@ -794,6 +795,9 @@
ifsInventoryQuantity.setIsCopper(1);
ifsInventoryQuantity.setIsQuarter(0);
ifsInventoryQuantity.setInspectStatus(0);
+ //閾滄潗鏂欎笅鍗曢粯璁ゅ��
+ ifsInventoryQuantity.setOrderType(OrderType.RAW.getValue());
+ ifsInventoryQuantity.setMaterialProp("01Cu");
ifsInventoryQuantity.setQtyArrived(insOrder.getQtyArrived());
ifsInventoryQuantity.setBuyUnitMeas(insOrder.getBuyUnitMeas());
@@ -803,10 +807,8 @@
ifsInventoryQuantityMapper.insert(ifsInventoryQuantity);
-
insOrder.setIfsInventoryId(ifsInventoryQuantity.getId());
insOrder.setState(1);
-
upInsOrderOfState(insOrder);
upInsOrder(insOrder.getId(), null, appointed != null ? appointed.toString() : null, SecurityUtils.getUserId().intValue(), "鍘熸潗鏂�");
@@ -872,6 +874,19 @@
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean updateInsOrder(InsOrderUpdateDto insOrderUpdateDto) {
+ InsOrder currentOrder = insOrderMapper.selectById(insOrderUpdateDto.getInsOrder().getId());
+ if (currentOrder == null || !Objects.equals(currentOrder.getState(), 2)) {
+ throw new ErrorException("鍙湁閫�鍥炵殑妫�楠屽崟鍙互淇敼");
+ }
+ boolean hasSelectedProduct = CollectionUtils.isNotEmpty(insOrderUpdateDto.getSampleProduct())
+ && insOrderUpdateDto.getSampleProduct().stream()
+ .filter(sample -> CollectionUtils.isNotEmpty(sample.getInsProduct()))
+ .flatMap(sample -> sample.getInsProduct().stream())
+ .anyMatch(product -> Objects.equals(product.getState(), 1));
+ if (!hasSelectedProduct) {
+ throw new ErrorException("璇疯嚦灏戦�夋嫨涓�涓楠岄」");
+ }
+
// 淇敼璁㈠崟
insOrderUpdateDto.getInsOrder().setState(0);
insOrderUpdateDto.getInsOrder().setTell("");
@@ -879,11 +894,50 @@
// 淇敼妫�楠岄」
for (SampleProductDto sampleProductDto : insOrderUpdateDto.getSampleProduct()) {
+ Long sampleCount = insSampleMapper.selectCount(Wrappers.<InsSample>lambdaQuery()
+ .eq(InsSample::getId, sampleProductDto.getId())
+ .eq(InsSample::getInsOrderId, insOrderUpdateDto.getInsOrder().getId()));
+ if (sampleCount == 0) {
+ throw new ErrorException("妫�楠屾牱鍝佹暟鎹紓甯�");
+ }
+
insSampleService.update(Wrappers.<InsSample>lambdaUpdate()
.eq(InsSample::getId, sampleProductDto.getId())
.set(InsSample::getSpecialStandardMethod, sampleProductDto.getSpecialStandardMethod()));
- insProductService.updateBatchById(sampleProductDto.getInsProduct());
+ List<InsProduct> products = sampleProductDto.getInsProduct();
+ if (CollectionUtils.isEmpty(products)) {
+ continue;
+ }
+
+ Set<Integer> productIds = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
+ .eq(InsProduct::getInsSampleId, sampleProductDto.getId()))
+ .stream()
+ .map(InsProduct::getId)
+ .collect(Collectors.toSet());
+ if (products.stream().anyMatch(product -> product.getId() != null && !productIds.contains(product.getId()))) {
+ throw new ErrorException("妫�楠岄」鏁版嵁寮傚父");
+ }
+
+ List<Integer> removedIds = products.stream()
+ .filter(product -> product.getId() != null && !Objects.equals(product.getState(), 1))
+ .map(InsProduct::getId)
+ .collect(Collectors.toList());
+ if (CollectionUtils.isNotEmpty(removedIds)) {
+ insProductService.removeByIds(removedIds);
+ }
+
+ List<InsProduct> existingProducts = products.stream()
+ .filter(product -> product.getId() != null && Objects.equals(product.getState(), 1))
+ .collect(Collectors.toList());
+ if (CollectionUtils.isNotEmpty(existingProducts)) {
+ insProductService.updateBatchById(existingProducts);
+ }
+
+ List<InsProduct> newProducts = products.stream()
+ .filter(product -> product.getId() == null && Objects.equals(product.getState(), 1))
+ .collect(Collectors.toList());
+ addInsProductMethod(sampleProductDto.getId(), newProducts);
}
return true;
@@ -897,6 +951,11 @@
@Override
public List<InsOrderPrintingVo> labelOrderPrinting(List<Integer> ids) {
return insOrderMapper.labelOrderPrinting(ids);
+ }
+
+ @Override
+ public List<InventoryDetailDTO> labelOutsideOrderPrinting(List<Integer> ids) {
+ return insOrderMapper.labelOutsideOrderPrinting(ids);
}
/**
@@ -1207,9 +1266,11 @@
* TODO 鍚庣画闇�瑕佽皟鐢↖FS鐨勬帴鍙� 绉诲叆鐨勫簱浣嶅彿 toLocation
*/
// 妫�楠屽悗绉诲簱
- if(one.getIsSplitOrder().equals(1)){
- //濡傛灉璁㈠崟涓哄師鏉愭枡鐨勬媶鍒嗚鍗曪紝鍒欑Щ鍒板璐簱浣�
- toLocation = "W03";
+ //1301:鍘熸潗鏂欏悎鏍煎簱锛孋P-02-001:鎴愬搧搴�
+ if(StringUtils.equals(inventoryQuantity.getOrderType(), OrderType.RAW.getValue())){
+ toLocation = "1301";
+ }else if(StringUtils.equals(inventoryQuantity.getOrderType(), OrderType.WG.getValue())){
+ toLocation = "CP-02-001";
}else{
toLocation = "1301";
}
--
Gitblit v1.9.3