package com.vci.ubcs.code.service.impl;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.vci.ubcs.code.annotation.MdmSerialAlgorithm;
|
import com.vci.ubcs.code.service.ICodeSerialAlgorithmService;
|
import com.vci.ubcs.code.vo.pagemodel.CodeSerialAlgorithmVO;
|
import com.vci.ubcs.starter.web.util.ApplicationContextProvider;
|
import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
|
import org.springblade.core.mp.support.Condition;
|
import org.springblade.core.mp.support.Query;
|
import org.springframework.aop.framework.Advised;
|
import org.springframework.stereotype.Service;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* 流水算法的服务
|
* @author weidy
|
* @date 2022-2-17
|
*/
|
@Service
|
public class CodeSerialAlgorithmServiceImpl implements ICodeSerialAlgorithmService {
|
/**
|
* 获取流水算法的列表
|
*
|
* @return 流水算法的信息
|
*/
|
@Override
|
public IPage<CodeSerialAlgorithmVO> gridSerialAlgorithm() {
|
//使用主键去扫描
|
String[] beanNames = ApplicationContextProvider.getApplicationContext().getBeanNamesForAnnotation(MdmSerialAlgorithm.class);
|
List<CodeSerialAlgorithmVO> voList = new ArrayList<>();
|
if(beanNames!=null && beanNames.length>0){
|
for(String beanName : beanNames){
|
Object bean = ApplicationContextProvider.getApplicationContext().getBean(beanName);
|
if(bean!=null){
|
CodeSerialAlgorithmVO algorithmVO = new CodeSerialAlgorithmVO();
|
Advised advised = (Advised)bean;
|
Class<?> targetClass = advised.getTargetSource().getTargetClass();
|
algorithmVO.setClassFullName(targetClass.getName());
|
MdmSerialAlgorithm serialAlgorithm = targetClass.getDeclaredAnnotation(MdmSerialAlgorithm.class);
|
if(serialAlgorithm==null){
|
serialAlgorithm = targetClass.getAnnotation(MdmSerialAlgorithm.class);
|
}
|
if(serialAlgorithm !=null) {
|
algorithmVO.setName(serialAlgorithm.text());
|
algorithmVO.setDescription(serialAlgorithm.description());
|
algorithmVO.setId(serialAlgorithm.value());
|
if(StringUtils.isBlank(algorithmVO.getId())){
|
algorithmVO.setId(beanName);
|
}
|
voList.add(algorithmVO);
|
}
|
}
|
}
|
}
|
Query query=new Query();
|
IPage<CodeSerialAlgorithmVO> queryIPage =Condition.getPage(query);
|
return queryIPage;
|
}
|
}
|