| | |
| | | package com.vci.ubcs.code.algorithm; |
| | | |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | 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.code.dto.CodeCustomSerialDTO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeBasicSecVO; |
| | | import com.vci.ubcs.starter.exception.VciBaseException; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | |
| | | import java.util.List; |
| | | |
| | | /**** |
| | | * 自定义罗马流水算法自定义类 |
| | | */ |
| | | @MdmSerialAlgorithm(text = "自定义罗马流水",description = "自定义罗马流水算法") |
| | | @MdmSerialAlgorithm(text = "自定义罗马流水",serialType="custom_serial_roman",description = "自定义罗马流水算法") |
| | | public class CustomRomanSerialAlgorithmExample { |
| | | /** |
| | | * 生成罗马流水号的方法 |
| | | * @return 流水号的信息 |
| | | */ |
| | | @MdmSerialAlgorithmMethod |
| | | public String serialGenerate(BaseModel data, CodeRuleVO codeRuleVO, List<CodeOrderSecDTO> secDTOList){ |
| | | public String serialGenerate(CodeCustomSerialDTO codeCustomSerialDTO){ |
| | | // |
| | | codeCustomSerialDTO.getSerialUnitString(); |
| | | CodeBasicSecVO secVO= codeCustomSerialDTO.getSerialCodeCodeBasicSec(); |
| | | String currentFlowValue=codeCustomSerialDTO.getCurrentFlowValue(); |
| | | |
| | | |
| | | |
| | | |
| | | //将数字流水转为罗马流水 |
| | | String romanValue=VciBaseUtil.convertArabicToRoman(5); |
| | | Double newThisSerialValue = 0d; |
| | | if(StringUtils.isBlank(currentFlowValue)){ |
| | | //第一个编码 |
| | | newThisSerialValue = VciBaseUtil.getDouble(secVO.getSerialStart()); |
| | | }else { |
| | | //流水号肯定是数字 |
| | | //将罗马流水转为数字流水 |
| | | int arabicValue=VciBaseUtil.convertRomanToArabic(romanValue); |
| | | return ""; |
| | | int arabicValue=VciBaseUtil.convertRomanToArabic(currentFlowValue); |
| | | newThisSerialValue = (double)(arabicValue + secVO.getSerialStep()) ; |
| | | } |
| | | //要看是否超过最大的流水值 |
| | | if (newThisSerialValue >= secVO.getCodeFillLimit()) { |
| | | throw new VciBaseException("流水号已经超过允许的最大流水值{0}", new String[]{secVO.getCodeFillLimit().toString()}); |
| | | } |
| | | //将数字流水转为罗马流水 |
| | | String romanValue=VciBaseUtil.convertArabicToRoman(newThisSerialValue.intValue()); |
| | | return romanValue; |
| | | } |
| | | |
| | | } |