| | |
| | | package com.vci.ubcs.code.vo.pagemodel; |
| | | |
| | | import com.vci.ubcs.starter.revision.model.BaseModel; |
| | | |
| | | /** |
| | | * æµæ°´ç®æ³ç±»çæ¾ç¤ºä¿¡æ¯ |
| | | * @author weidy |
| | | * @date 2022-2-17 |
| | | */ |
| | | public class CodeSerialAlgorithmVO implements java.io.Serializable{ |
| | | public class CodeSerialAlgorithmVO extends BaseModel { |
| | | |
| | | /** |
| | | * ç®æ³ç¼å· |
| | |
| | | |
| | | return sb.toString(); |
| | | } |
| | | public static String intToRomans(int num) { |
| | | public static String convertArabicToRoman(int num) { |
| | | int[] values={1000,900,500,400,100,90,50,40,10,9,5,4,1}; |
| | | String[] romans={"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"}; |
| | | StringBuilder sb=new StringBuilder(); |
| | | for(int i=0;i<values.length;i++){ |
| | | while(num>=values[i]){ |
| | | num=num-values[i]; |
| | | sb.append(romans[i]); |
| | | } |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | /** |
| | | * æç½é©¬æ°å转æ¢ä¸ºé¿æä¼¯æ°å |
| | | * @param m |
| | | * @return |
| | | */ |
| | | public static int convertRomanToArabic(String m) { |
| | | int graph[] = new int[400]; |
| | | graph['I'] = 1; |
| | | graph['V'] = 5; |
| | | graph['X'] = 10; |
| | | graph['L'] = 50; |
| | | graph['C'] = 100; |
| | | graph['D'] = 500; |
| | | graph['M'] = 1000; |
| | | char[] num = m.toCharArray(); |
| | | int sum = graph[num[0]]; |
| | | for (int i = 0; i < num.length - 1; i++) { |
| | | if (graph[num[i]] >= graph[num[i + 1]]) { |
| | | sum += graph[num[i + 1]]; |
| | | } else { |
| | | sum = sum + graph[num[i + 1]] - 2 * graph[num[i]]; |
| | | } |
| | | } |
| | | return sum; |
| | | } |
| | | |
| | | public static String intToRomanTwo(int num) { |
| | | String M[] = {"", "M", "MM", "MMM"}; |
| | | String C[] = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"}; |
| | | String X[] = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"}; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.code.algorithm; |
| | | |
| | | import com.vci.ubcs.code.annotation.MdmSerialAlgorithm; |
| | | import com.vci.ubcs.code.annotation.MdmSerialAlgorithmMethod; |
| | | import com.vci.ubcs.code.dto.CodeOrderSecDTO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO; |
| | | import com.vci.ubcs.starter.revision.model.BaseModel; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | |
| | | import java.util.List; |
| | | |
| | | /**** |
| | | * èªå®ä¹ç½é©¬æµæ°´ç®æ³èªå®ä¹ç±» |
| | | */ |
| | | @MdmSerialAlgorithm(text = "èªå®ä¹ç½é©¬æµæ°´",description = "èªå®ä¹ç½é©¬æµæ°´ç®æ³") |
| | | public class CustomRomanSerialAlgorithmExample { |
| | | /** |
| | | * çæç½é©¬æµæ°´å·çæ¹æ³ |
| | | * @return æµæ°´å·çä¿¡æ¯ |
| | | */ |
| | | @MdmSerialAlgorithmMethod |
| | | public String serialGenerate(BaseModel data, CodeRuleVO codeRuleVO, List<CodeOrderSecDTO> secDTOList){ |
| | | |
| | | |
| | | |
| | | |
| | | //å°æ°åæµæ°´è½¬ä¸ºç½é©¬æµæ°´ |
| | | String romanValue=VciBaseUtil.convertArabicToRoman(5); |
| | | //å°ç½é©¬æµæ°´è½¬ä¸ºæ°åæµæ°´ |
| | | int arabicValue=VciBaseUtil.convertRomanToArabic(romanValue); |
| | | return ""; |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.code.algorithm; |
| | | |
| | | import com.vci.ubcs.code.annotation.MdmSerialAlgorithm; |
| | | import com.vci.ubcs.code.annotation.MdmSerialAlgorithmMethod; |
| | | import com.vci.ubcs.code.dto.CodeOrderSecDTO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO; |
| | | import com.vci.ubcs.starter.revision.model.BaseModel; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * æµæ°´ç®æ³çç¤ºä¾ |
| | | */ |
| | | @MdmSerialAlgorithm(text = "æµæ°´ç®æ³ç示ä¾",description = "请ä¸è¦ä½¿ç¨è¿ä¸ªç±»ï¼è¿ä¸ªç±»åªæ¯ç¤ºä¾ï¼ç¨äºæ¥çå¦ä½ç¼åæµæ°´ç®æ³") |
| | | public class CustomSerialAlgorithmExample { |
| | | |
| | | /** |
| | | * çææµæ°´å·çæ¹æ³ |
| | | * @return æµæ°´å·çä¿¡æ¯ |
| | | */ |
| | | @MdmSerialAlgorithmMethod |
| | | public String serialGenerate(BaseModel data, CodeRuleVO codeRuleVO, List<CodeOrderSecDTO> secDTOList){ |
| | | return ""; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.code.annotation; |
| | | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * èªå®ä¹æµæ°´ç®æ³ç注解 |
| | | * @author xiejun |
| | | * @date 2023-11-09 |
| | | */ |
| | | @Target({ElementType.TYPE}) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Component |
| | | public @interface MdmSerialAlgorithm { |
| | | |
| | | /** |
| | | * å¼ï¼å®é
å°±æ¯è¿ä¸ªæ³¨è§£æå¨çç±»çå
¨è·¯å¾ |
| | | * @return å¼ |
| | | */ |
| | | String value() default ""; |
| | | |
| | | /** |
| | | * äºä»¶çåç§° |
| | | * @return äºä»¶åç§° |
| | | */ |
| | | String text(); |
| | | |
| | | /** |
| | | * æè¿° |
| | | * @return æè¿° |
| | | */ |
| | | String description() default ""; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.code.annotation; |
| | | |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * èªå®ä¹æµæ°´ç®æ³å¤çæ¹æ³ç注解 |
| | | * @author xiejun |
| | | * @date 2023-11-09 |
| | | */ |
| | | @Target({ElementType.METHOD}) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface MdmSerialAlgorithmMethod { |
| | | |
| | | /** |
| | | * å¼ |
| | | * @return å¼ |
| | | */ |
| | | String value() default ""; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.code.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeAllCodeVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeSerialAlgorithmVO; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.vci.ubcs.code.service.ICodeSerialAlgorithmService; |
| | | |
| | | /** |
| | | * å
¨é¨ç å¼ æ§å¶å¨ |
| | | * |
| | | * @author ludc |
| | | * @since 2023-04-03 |
| | | */ |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/codeSerialAlgorithmController") |
| | | @Api(value = "èªå®ä¹æµæ°´", tags = "èªå®ä¹æµæ°´ç®æ³") |
| | | public class CodeSerialAlgorithmController extends BladeController { |
| | | /** |
| | | * ç®æ³æå¡ |
| | | */ |
| | | @Autowired |
| | | private ICodeSerialAlgorithmService algorithmService; |
| | | |
| | | /** |
| | | * ç®æ³çå表 |
| | | * @return ç®æ³çä¿¡æ¯ |
| | | */ |
| | | @GetMapping("/gridCodeSerialAlgorithm") |
| | | public R<IPage<CodeSerialAlgorithmVO>> gridCodeSerialAlgorithm(){ |
| | | IPage<CodeSerialAlgorithmVO> pages= algorithmService.gridSerialAlgorithm(); |
| | | return R.data(pages); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.code.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeSerialAlgorithmVO; |
| | | import org.springblade.core.tool.api.R; |
| | | |
| | | /** |
| | | * æµæ°´ç®æ³ç±» |
| | | * @author weidy |
| | | * @date 2022-2-17 |
| | | */ |
| | | public interface ICodeSerialAlgorithmService { |
| | | |
| | | /** |
| | | * è·åæµæ°´ç®æ³çå表 |
| | | * @return æµæ°´ç®æ³çä¿¡æ¯ |
| | | */ |
| | | IPage<CodeSerialAlgorithmVO> gridSerialAlgorithm(); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | | } |