|
|
@@ -706,7 +706,6 @@ public class MESDataServiceImpl implements MESDataService {
|
|
|
List<String> duplicates = detailList.stream()
|
|
|
.map(SNBindMaterialRequest.DetailDTO::getSm_fprodcode)
|
|
|
.filter(s -> !set.add(s))
|
|
|
- .distinct()
|
|
|
.collect(Collectors.toList());
|
|
|
if (!duplicates.isEmpty()) {
|
|
|
return ApiResponse.failRsp(ErrorMessage.BUSINESS_ILLEGAL.getCode(), requestId,
|
|
|
@@ -717,7 +716,6 @@ public class MESDataServiceImpl implements MESDataService {
|
|
|
duplicates = detailList.stream()
|
|
|
.map(SNBindMaterialRequest.DetailDTO::getSm_barcode)
|
|
|
.filter(s -> !set1.add(s))
|
|
|
- .distinct()
|
|
|
.collect(Collectors.toList());
|
|
|
if (!duplicates.isEmpty()) {
|
|
|
return ApiResponse.failRsp(ErrorMessage.BUSINESS_ILLEGAL.getCode(), requestId,
|
|
|
@@ -783,7 +781,6 @@ public class MESDataServiceImpl implements MESDataService {
|
|
|
//校验是否重复barcode 不重复则插入
|
|
|
List<String> barList = detailList.stream()
|
|
|
.map(SNBindMaterialRequest.DetailDTO::getSm_barcode)
|
|
|
- .distinct()
|
|
|
.collect(Collectors.toList());
|
|
|
String checksql = "select wm_concat(sm_barcode) from SNBINDMATERIAL where sm_barcode IN (%s) and rownum<20";
|
|
|
String inClause = String.join(",", Collections.nCopies(barList.size(), "?"));
|
|
|
@@ -802,10 +799,44 @@ public class MESDataServiceImpl implements MESDataService {
|
|
|
@Transactional
|
|
|
public ApiResult<Map<Object, Object>> executeSNBindInfo(String accessKey, String requestId, SNBindInfoRequest reqData) {
|
|
|
List<SNBindInfoRequest.DetailDTO> detailList = reqData.getData().getDetail();
|
|
|
- // 1. sncode(去重,避免重复处理)
|
|
|
+
|
|
|
+ Set<String> set = new HashSet<>();
|
|
|
+ List<String> duplicates = detailList.stream()
|
|
|
+ .map(SNBindInfoRequest.DetailDTO::getSi_sncode)
|
|
|
+ .filter(s -> !set.add(s))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!duplicates.isEmpty()) {
|
|
|
+ return ApiResponse.failRsp(ErrorMessage.BUSINESS_ILLEGAL.getCode(), requestId,
|
|
|
+ "本次传参存在重复的si_sncode: " + String.join(", ", duplicates));
|
|
|
+ }
|
|
|
+
|
|
|
+ //绑定值si_bt等必须唯一不能重复 ,也不能与历史数据重复
|
|
|
+ Set<String> set1 = new HashSet<>();
|
|
|
+ duplicates = detailList.stream()
|
|
|
+ .map(SNBindInfoRequest.DetailDTO::getSi_bt)
|
|
|
+ .filter(s -> s != null && !s.isEmpty() && !"N/A".equals(s)) // 排除 null、空字符串、"N/A"
|
|
|
+ .filter(s -> !set1.add(s))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!duplicates.isEmpty()) {
|
|
|
+ return ApiResponse.failRsp(ErrorMessage.BUSINESS_ILLEGAL.getCode(), requestId,
|
|
|
+ "本次传参存在重复的si_bt: " + String.join(", ", duplicates));
|
|
|
+ }
|
|
|
+
|
|
|
+ //绑定值si_wifi等必须唯一不能重复 ,也不能与历史数据重复
|
|
|
+ Set<String> set2 = new HashSet<>();
|
|
|
+ duplicates = detailList.stream()
|
|
|
+ .map(SNBindInfoRequest.DetailDTO::getSi_wifi)
|
|
|
+ .filter(s -> s != null && !s.isEmpty() && !"N/A".equals(s)) // 排除 null、空字符串、"N/A"
|
|
|
+ .filter(s -> !set2.add(s))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!duplicates.isEmpty()) {
|
|
|
+ return ApiResponse.failRsp(ErrorMessage.BUSINESS_ILLEGAL.getCode(), requestId,
|
|
|
+ "本次传参存在重复的si_wifi: " + String.join(", ", duplicates));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1. sncode
|
|
|
List<String> sncodeList = detailList.stream()
|
|
|
.map(SNBindInfoRequest.DetailDTO::getSi_sncode)
|
|
|
- .distinct()
|
|
|
.collect(Collectors.toList());
|
|
|
// 2. 批量查询已存在的记录(返回 sncode 和 si_id)
|
|
|
String selectSql = "SELECT si_id,si_sncode FROM SNBIND_INFO WHERE si_sncode IN (%s)";
|
|
|
@@ -830,6 +861,36 @@ public class MESDataServiceImpl implements MESDataService {
|
|
|
String fullDeleteSql = String.format(deleteSql, inClause);
|
|
|
baseDao.execute(fullDeleteSql, existSncodes.toArray());
|
|
|
}
|
|
|
+
|
|
|
+ List<String> wifiList = detailList.stream()
|
|
|
+ .map(SNBindInfoRequest.DetailDTO::getSi_wifi)
|
|
|
+ .filter(s -> s != null && !s.isEmpty() && !"N/A".equals(s)) // 排除 null、空字符串、"N/A"
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if(!wifiList.isEmpty()) {
|
|
|
+ String checksql = "select wm_concat(SI_WIFI) from SNBIND_INFO where SI_WIFI IN (%s) and rownum<20";
|
|
|
+ String inClause = String.join(",", Collections.nCopies(wifiList.size(), "?"));
|
|
|
+ checksql = String.format(checksql, inClause);
|
|
|
+ String barr = baseDao.getJdbcTemplate().queryForObject(checksql, String.class, wifiList.toArray());
|
|
|
+ if (null != barr) {
|
|
|
+ return ApiResponse.failRsp(ErrorMessage.BUSINESS_ILLEGAL.getCode(), requestId,
|
|
|
+ "si_wifi与历史已有数据表重复: " + barr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<String> btList = detailList.stream()
|
|
|
+ .map(SNBindInfoRequest.DetailDTO::getSi_bt)
|
|
|
+ .filter(s -> s != null && !s.isEmpty() && !"N/A".equals(s)) // 排除 null、空字符串、"N/A"
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if(!btList.isEmpty()) {
|
|
|
+ String checksql = "select wm_concat(SI_BT) from SNBIND_INFO where SI_BT IN (%s) and rownum<20";
|
|
|
+ String inClause = String.join(",", Collections.nCopies(btList.size(), "?"));
|
|
|
+ checksql = String.format(checksql, inClause);
|
|
|
+ String barr = baseDao.getJdbcTemplate().queryForObject(checksql, String.class, btList.toArray());
|
|
|
+ if (null != barr) {
|
|
|
+ return ApiResponse.failRsp(ErrorMessage.BUSINESS_ILLEGAL.getCode(), requestId,
|
|
|
+ "si_wifi与历史已有数据表重复: " + barr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 5. 批量插入新数据
|
|
|
String insertSql = "INSERT INTO SNBIND_INFO (SI_ID,SI_SNCODE,SI_PRODCODE,SI_MACODE,SI_CPU,SI_WIFI,SI_BT," +
|
|
|
" SI_UUID,SI_BIOS,SI_OS,SI_EC,SI_DP,SI_INDATE) " +
|