|
|
|
@ -28,6 +28,7 @@ package org.springblade.desk.dashboard.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
import jakarta.annotation.Resource; |
|
|
|
import jakarta.annotation.Resource; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
@ -54,6 +55,8 @@ import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import java.util.regex.Matcher; |
|
|
|
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -372,9 +375,111 @@ public class DsProModelServiceImpl extends BaseServiceImpl<DsProModelMapper, DsP |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// public List<DsProModelVO> getModelList() {
|
|
|
|
|
|
|
|
// List<DsProModelVO> dsProModelVOList = proModelMapper.selectDsProModelAll();
|
|
|
|
|
|
|
|
// if(CollectionUtils.isEmpty(dsProModelVOList)){
|
|
|
|
|
|
|
|
// return List.of();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// for (DsProModelVO dsProModelVO : dsProModelVOList) {
|
|
|
|
|
|
|
|
// if (dsProModelVO.getPlatingType() != null) {
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
|
|
// BasicClazz basicClazz = basicClazzService.getById(dsProModelVO.getPlatingType());
|
|
|
|
|
|
|
|
// if (basicClazz != null) {
|
|
|
|
|
|
|
|
// dsProModelVO.setPlatingTypeStr(basicClazz.getName());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
|
|
|
// log.error("查询电镀类型失败, platingType: {}", dsProModelVO.getPlatingType(), e);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// //然后想根据镀种分类做成二级结构platingType
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// return null;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<DsProModelVO> getModelList() { |
|
|
|
public List<DsProModelVO> getModelList() { |
|
|
|
return proModelMapper.selectDsProModelAll(); |
|
|
|
List<DsProModelVO> dsProModelVOList = proModelMapper.selectDsProModelAll(); |
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(dsProModelVOList)) { |
|
|
|
|
|
|
|
return List.of(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1. 按照镀种分类构建二级结构
|
|
|
|
|
|
|
|
Map<Integer, List<DsProModelVO>> groupByPlatingType = dsProModelVOList.stream() |
|
|
|
|
|
|
|
.filter(vo -> vo.getPlatingType() != null) |
|
|
|
|
|
|
|
.collect(Collectors.groupingBy(DsProModelVO::getPlatingType)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 构建二级结构的返回列表
|
|
|
|
|
|
|
|
List<DsProModelVO> result = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Map.Entry<Integer, List<DsProModelVO>> entry : groupByPlatingType.entrySet()) { |
|
|
|
|
|
|
|
Integer platingTypeId = entry.getKey(); |
|
|
|
|
|
|
|
List<DsProModelVO> children = entry.getValue(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(children)) { |
|
|
|
|
|
|
|
// 获取镀种名称(从第一个子节点获取)
|
|
|
|
|
|
|
|
String platingTypeName = children.get(0).getPlatingTypeStr(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建父节点(镀种分类)
|
|
|
|
|
|
|
|
DsProModelVO parent = new DsProModelVO(); |
|
|
|
|
|
|
|
parent.setPlatingType(platingTypeId); |
|
|
|
|
|
|
|
parent.setPlatingTypeStr(platingTypeName); |
|
|
|
|
|
|
|
parent.setChildren(children); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.add(parent); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3.设置名称
|
|
|
|
|
|
|
|
for (DsProModelVO dsProModelVO : result) { |
|
|
|
|
|
|
|
if (dsProModelVO.getPlatingType() != null) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
BasicClazz basicClazz = basicClazzService.getById(dsProModelVO.getPlatingType()); |
|
|
|
|
|
|
|
if (basicClazz != null) { |
|
|
|
|
|
|
|
dsProModelVO.setPlatingTypeStr(basicClazz.getName()); |
|
|
|
|
|
|
|
dsProModelVO.setBasicClazzCode(basicClazz.getCode()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("查询电镀类型失败, platingType: {}", dsProModelVO.getPlatingType(), e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 4. 按英文部分排序
|
|
|
|
|
|
|
|
result.sort((o1, o2) -> { |
|
|
|
|
|
|
|
String str1 = o1.getPlatingTypeStr(); |
|
|
|
|
|
|
|
String str2 = o2.getPlatingTypeStr(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ("未分类".equals(str1)) return 1; |
|
|
|
|
|
|
|
if ("未分类".equals(str2)) return -1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String english1 = extractEnglishPrefix(str1); |
|
|
|
|
|
|
|
String english2 = extractEnglishPrefix(str2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (english1 == null && english2 == null) return 0; |
|
|
|
|
|
|
|
if (english1 == null) return 1; |
|
|
|
|
|
|
|
if (english2 == null) return -1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return english1.compareTo(english2); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 辅助方法
|
|
|
|
|
|
|
|
private String extractEnglishPrefix(String str) { |
|
|
|
|
|
|
|
if (str == null) return null; |
|
|
|
|
|
|
|
Matcher matcher = Pattern.compile("^([A-Za-z]+)").matcher(str); |
|
|
|
|
|
|
|
if (matcher.find()) { |
|
|
|
|
|
|
|
return matcher.group(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return str; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|