From 4d00b5a1923103b25ae4beaf26ba0a04b8d3ca4a Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期一, 26 五月 2025 11:25:30 +0800
Subject: [PATCH] 中空代码优化:提供字符串多级排序 提供客户名称
---
hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/entity/dto/OrderDetailsDTO.java | 21 ++++++++++
hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/entity/vo/HollowAllFlowCardVO.java | 8 +++-
hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/mapper/HollowGlassRelationInfoMapper.java | 3 +
hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java | 46 +++++++++++++++++++----
hangzhoumesParent/moduleService/hollowGlassModule/src/main/resources/mapper/HollowGlassRelationInfoMapper.xml | 9 ++--
5 files changed, 72 insertions(+), 15 deletions(-)
diff --git a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/entity/dto/OrderDetailsDTO.java b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/entity/dto/OrderDetailsDTO.java
new file mode 100644
index 0000000..85d7637
--- /dev/null
+++ b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/entity/dto/OrderDetailsDTO.java
@@ -0,0 +1,21 @@
+package com.mes.hollow.entity.dto;
+
+import lombok.Data;
+
+/**
+ * @Author : zhoush
+ * @Date: 2025/5/23 15:18
+ * @Description:瀹㈡埛鐩稿叧淇℃伅
+ */
+@Data
+public class OrderDetailsDTO {
+ /**
+ * 瀹㈡埛鍚嶇О
+ */
+ private String customerName;
+ /**
+ * 浜у搧鍚嶇О
+ */
+ private String productName;
+}
+
diff --git a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/entity/vo/HollowAllFlowCardVO.java b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/entity/vo/HollowAllFlowCardVO.java
index 54001ec..917eaff 100644
--- a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/entity/vo/HollowAllFlowCardVO.java
+++ b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/entity/vo/HollowAllFlowCardVO.java
@@ -15,11 +15,15 @@
/**
* 娴佺▼鍗″彿
*/
- private String FlowCardId;
+ private String flowCardId;
+ /**
+ * 瀹㈡埛鍚嶇О
+ */
+ private String customerName;
/**
* 浜у搧鍚嶇О
*/
- private String ProductName;
+ private String productName;
/**
* 鏄惁鐩撮��
*/
diff --git a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/mapper/HollowGlassRelationInfoMapper.java b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/mapper/HollowGlassRelationInfoMapper.java
index 0367c10..44f7fc8 100644
--- a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/mapper/HollowGlassRelationInfoMapper.java
+++ b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/mapper/HollowGlassRelationInfoMapper.java
@@ -4,6 +4,7 @@
import com.mes.hollow.entity.HollowGlassRelationInfo;
import com.mes.hollow.entity.dto.HollowGlassDetailsDTO;
import com.mes.hollow.entity.dto.LackDetailsDTO;
+import com.mes.hollow.entity.dto.OrderDetailsDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -34,6 +35,6 @@
* @param flowCardId
* @return
*/
- String queryProductNameByFlowCardId(@Param("flowCardId") String flowCardId);
+ OrderDetailsDTO queryProductNameByFlowCardId(@Param("flowCardId") String flowCardId);
}
diff --git a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java
index 5b12e1a..dbc4e08 100644
--- a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java
+++ b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java
@@ -13,10 +13,7 @@
import com.mes.hollow.entity.HollowBigStorageCageDetails;
import com.mes.hollow.entity.HollowGlassOutRelationInfo;
import com.mes.hollow.entity.HollowGlassRelationInfo;
-import com.mes.hollow.entity.dto.FlowCardGlassInfoDTO;
-import com.mes.hollow.entity.dto.HollowBigStorageDTO;
-import com.mes.hollow.entity.dto.HollowGlassDetailsDTO;
-import com.mes.hollow.entity.dto.LackDetailsDTO;
+import com.mes.hollow.entity.dto.*;
import com.mes.hollow.entity.vo.HollowAllFlowCardVO;
import com.mes.hollow.entity.vo.HollowBigStorageDetailsQueryVO;
import com.mes.hollow.mapper.HollowGlassRelationInfoMapper;
@@ -30,10 +27,13 @@
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
+import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
@@ -315,21 +315,23 @@
listMap.forEach((e, v) -> {
HollowAllFlowCardVO hollowAllFlowCardVO = new HollowAllFlowCardVO();
HollowBigStorageCageDetails cageDetails = v.get(0);
+ //鎸夌収娴佺▼鍗¤幏鍙栧搴旂殑浜у搧鍚嶇О
+ OrderDetailsDTO orderDetails = baseMapper.queryProductNameByFlowCardId(cageDetails.getFlowCardId());
+ if (null != orderDetails) {
+ BeanUtils.copyProperties(orderDetails, hollowAllFlowCardVO);
+ }
hollowAllFlowCardVO.setFlowCardId(e);
if (cageDetails.getHollowSequence() == 0) {
hollowAllFlowCardVO.setIsThroughSlot(Boolean.TRUE);
} else {
hollowAllFlowCardVO.setIsThroughSlot(Boolean.FALSE);
}
- //鎸夌収娴佺▼鍗¤幏鍙栧搴旂殑浜у搧鍚嶇О
- String productName = baseMapper.queryProductNameByFlowCardId(cageDetails.getFlowCardId());
- hollowAllFlowCardVO.setProductName(productName);
List<FlowCardGlassInfoDTO> flowCardInfoList = hollowBigStorageCageDetailsService.hollowIsAll(e, cageDetails.getTotalLayer(), Boolean.FALSE);
hollowAllFlowCardVO.setFlowCardGlassInfoDTOList(flowCardInfoList);
resultList.add(hollowAllFlowCardVO);
});
+ sortFlowCardIdList(resultList);
return resultList;
-// return dtos.stream().collect(Collectors.groupingBy(e -> e.getFlowCardId() + ":" + e.getProductName()));
}
@Override
@@ -396,5 +398,33 @@
// return lackDetailsList;
// }
+ private void sortFlowCardIdList(List<HollowAllFlowCardVO> list) {
+ Pattern pattern = Pattern.compile("^NG(\\d+)([A-Za-z]+)(\\d+)$");
+
+ list.sort((v1, v2) -> {
+ Matcher m1 = pattern.matcher(v1.getFlowCardId());
+ Matcher m2 = pattern.matcher(v2.getFlowCardId());
+
+ if (!m1.find() || !m2.find()) {
+ throw new IllegalArgumentException("鑾峰彇鍒扮殑娴佺▼鍗′笉绗﹀悎鏍¢獙瑙勫垯");
+ }
+
+ // 鎻愬彇閮ㄥ垎
+ BigInteger order1 = new BigInteger(m1.group(1));
+ BigInteger order2 = new BigInteger(m2.group(1));
+ String layer1 = m1.group(2);
+ String layer2 = m2.group(2);
+ BigInteger seq1 = new BigInteger(m1.group(3));
+ BigInteger seq2 = new BigInteger(m2.group(3));
+
+ // 浼樺厛绾ф帓搴�
+ int cmp = order1.compareTo(order2);
+ if (cmp != 0) return cmp;
+ cmp = layer1.compareTo(layer2);
+ if (cmp != 0) return cmp;
+ return seq1.compareTo(seq2);
+ });
+ }
+
}
diff --git a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/resources/mapper/HollowGlassRelationInfoMapper.xml b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/resources/mapper/HollowGlassRelationInfoMapper.xml
index 981209f..df09271 100644
--- a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/resources/mapper/HollowGlassRelationInfoMapper.xml
+++ b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/resources/mapper/HollowGlassRelationInfoMapper.xml
@@ -129,10 +129,11 @@
from hollow_glass_relation_info
where flow_card_id = #{flowCardId}
</select>
- <select id="queryProductNameByFlowCardId" resultType="java.lang.String">
- select product_name
- from sd.order_detail
- where (order_id, order_number) = (
+ <select id="queryProductNameByFlowCardId" resultType="com.mes.hollow.entity.dto.OrderDetailsDTO">
+ select t.product_name, t1.customer_name
+ from sd.order_detail t
+ inner join sd.order t1 on t.order_id = t1.order_id
+ where (t.order_id, t.order_number) = (
select min(order_id) as order_id, min(order_number) as order_number
from pp.flow_card
where process_id = #{flowCardId}
--
Gitblit v1.8.0