| | |
| | | import com.vci.corba.omd.vrm.VersionRule; |
| | | import com.vci.dto.OsRevisionRuleDTO; |
| | | import com.vci.starter.web.annotation.log.VciUnLog; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.starter.web.util.VciDateUtil; |
| | | import com.vci.pagemodel.OsRevisionRuleVO; |
| | | import com.vci.starter.web.util.WebThreadLocalUtil; |
| | | import com.vci.web.service.OsRevisionRuleServiceI; |
| | | import com.vci.web.util.Func; |
| | | import com.vci.web.util.PlatformClientUtil; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.swing.*; |
| | | import java.awt.*; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public boolean addVersionRule(OsRevisionRuleDTO osRevisionRuleDTO) throws PLException { |
| | | //判空 |
| | | VciBaseUtil.alertNotNull(osRevisionRuleDTO,"版本规则对象",osRevisionRuleDTO.getId(),"版本规则名称"); |
| | | //版本规则合规检验 |
| | | this.checkVersionRule(osRevisionRuleDTO); |
| | | //查重 |
| | | VersionRule vr = platformClientUtil.getVersionService().getVersionRule(osRevisionRuleDTO.getName()); |
| | | //name不为空 |
| | | if(Func.isNotEmpty(vr) && !"".equals(vr.name)){ |
| | | throw new PLException("500",new String[]{"名称重复请更换名称!"}); |
| | | } |
| | | |
| | | platformClientUtil.getVersionService().addVersionRule(this.dto2VersionRule(osRevisionRuleDTO)); |
| | | return false; |
| | | return platformClientUtil.getVersionService().addVersionRule(this.dto2VersionRule(osRevisionRuleDTO)); |
| | | } |
| | | |
| | | /** |
| | | * 修改版本规则 |
| | | * @param osRevisionRuleDTO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean updateVersionRule(OsRevisionRuleDTO osRevisionRuleDTO) { |
| | | public boolean updateVersionRule(OsRevisionRuleDTO osRevisionRuleDTO) throws PLException { |
| | | //判空 |
| | | VciBaseUtil.alertNotNull(osRevisionRuleDTO,"版本规则对象",osRevisionRuleDTO.getId(),"版本规则名称"); |
| | | //判断是否在系统中存在 |
| | | VersionRule vr = platformClientUtil.getVersionService().getVersionRule(osRevisionRuleDTO.getName()); |
| | | //版本规则合规检验 |
| | | this.checkVersionRule(osRevisionRuleDTO); |
| | | //name不为空 |
| | | if(Func.isEmpty(vr) && !"".equals(vr.name)){ |
| | | throw new PLException("500",new String[]{"修改的版本规则在系统中不存在!"}); |
| | | } |
| | | return platformClientUtil.getVersionService().modifyVersionRule(this.dto2VersionRule(osRevisionRuleDTO)); |
| | | } |
| | | |
| | | return false; |
| | | /** |
| | | * 检查版本规则设置的是否合理 |
| | | * @param dto |
| | | */ |
| | | private void checkVersionRule(OsRevisionRuleDTO dto) throws PLException { |
| | | //版本规则名称只能为英文字母 |
| | | String regex = "[a-z A-Z]*"; |
| | | if (!dto.getId().matches(regex)) { |
| | | throw new PLException("500",new String[]{"名称只能为英文!"}); |
| | | } |
| | | //跳跃字符只能为数字或者字母 |
| | | if(Func.isNotBlank(dto.getJumpCharacter()) && (!(dto.getJumpCharacter().matches(regex)))){ |
| | | throw new PLException("500",new String[]{"跳跃字符只能为数字或者字母!"}); |
| | | } |
| | | //初始值不能为空且只能为数字或者字母或英文状态下的符号 |
| | | String regex1 = "[A-Za-z0-9!@#$%^&*()-_=+{}':|;,.?/]+$"; |
| | | if(Func.isBlank(dto.getInitialValue()) || !dto.getInitialValue().matches(regex1)){ |
| | | throw new PLException("500",new String[]{"初始值不能为空且只能为数字或者字母或英文状态下的符号!"}); |
| | | } |
| | | if(dto.getInitialValue().length() + dto.getInitialValue().length() > 32) { |
| | | throw new PLException("500",new String[]{"初始值不能超过32个字符!"}); |
| | | } |
| | | //步长不能为空且必须为1-9的正整数 |
| | | String regex2 = "[1-9]"; |
| | | if(Func.isBlank(dto.getStepLength()) || (!dto.getStepLength().matches(regex2))){ |
| | | throw new PLException("500",new String[]{"步长不能为空且必须为1-9的正整数"}); |
| | | } |
| | | //前缀相关判断 |
| | | String regex3 = "^\\s+.*"; |
| | | if(Func.isNotBlank(dto.getPrefixion()) && (dto.getPrefixion().matches(regex3))){ |
| | | throw new PLException("500",new String[]{"前缀不能以空格开头"}); |
| | | } |
| | | if (dto.getPrefixion().length() + dto.getPrefixion().length() > 32) { |
| | | throw new PLException("500",new String[]{"前缀不能超过32个字符"}); |
| | | } |
| | | //后缀相关判断 |
| | | String regex4 = "^*.\\s+$"; |
| | | if(Func.isNotBlank(dto.getSuffix()) && (dto.getSuffix().matches(regex4))){ |
| | | throw new PLException("500",new String[]{"后缀不能以空格结尾"}); |
| | | } |
| | | if (dto.getSuffix().length() + dto.getSuffix().length() > 32) { |
| | | throw new PLException("500",new String[]{"后缀不能超过32个字符"}); |
| | | } |
| | | if (dto.getId().length() > 255) { |
| | | throw new PLException("500",new String[]{"名称不能超过255个字符"}); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | VersionRule newVR = new VersionRule(); |
| | | newVR.name = osRevisionRuleDTO.getId(); |
| | | newVR.tag = osRevisionRuleDTO.getName(); |
| | | newVR.jumpCharacter = osRevisionRuleDTO.getPrefixCode(); |
| | | /*newVR.initialValue = jtf3.getText(); |
| | | newVR.stepLength = jtf4.getText(); |
| | | newVR.prefixion = jtf5.getText(); |
| | | newVR.suffix = jtf6.getText(); |
| | | newVR.description = jta.getText();*/ |
| | | String userName = ClientSessionUtility.getCurUserName(); |
| | | newVR.creator = userName; |
| | | newVR.description = osRevisionRuleDTO.getDescription(); |
| | | newVR.jumpCharacter = osRevisionRuleDTO.getJumpCharacter(); |
| | | newVR.initialValue = osRevisionRuleDTO.getInitialValue(); |
| | | newVR.stepLength = osRevisionRuleDTO.getStepLength(); |
| | | newVR.prefixion = osRevisionRuleDTO.getPrefixion(); |
| | | newVR.suffix = osRevisionRuleDTO.getSuffix(); |
| | | String userName = "developer";//WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); |
| | | long timeMillis = System.currentTimeMillis(); |
| | | newVR.creator = Func.isBlank(osRevisionRuleDTO.getCreator()) ? userName:osRevisionRuleDTO.getCreator(); |
| | | newVR.createTime = Func.isEmpty(osRevisionRuleDTO.getCreateTime()) ? timeMillis:osRevisionRuleDTO.getCreateTime().getTime(); |
| | | newVR.modifier = userName; |
| | | newVR.modifyTime = timeMillis; |
| | | return newVR; |
| | | } |
| | | |
| | |
| | | ruleVO.setDescription(versionRule.description); |
| | | ruleVO.setId(versionRule.name); |
| | | ruleVO.setName(versionRule.tag); |
| | | ruleVO.setSerialStep(WebUtil.getInt(versionRule.stepLength)); |
| | | ruleVO.setSkipCode(versionRule.jumpCharacter); |
| | | ruleVO.setPrefixCode(versionRule.prefixion); |
| | | ruleVO.setSuffixCode(versionRule.suffix); |
| | | ruleVO.setStartCode(versionRule.initialValue); |
| | | ruleVO.setStepLength(WebUtil.getInt(versionRule.stepLength)); |
| | | ruleVO.setJumpCharacter(versionRule.jumpCharacter); |
| | | ruleVO.setPrefixion(versionRule.prefixion); |
| | | ruleVO.setSuffix(versionRule.suffix); |
| | | ruleVO.setInitialValue(versionRule.initialValue); |
| | | //associated暂时没有使用 |
| | | } |
| | | return ruleVO; |