| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | import com.alibaba.nacos.common.utils.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.vci.ubcs.code.service.ICodeRuleCharacterService; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeRuleCharacterVO; |
| | | import com.vci.ubcs.starter.exception.VciBaseException; |
| | | import com.vci.ubcs.starter.poi.bo.SheetRowData; |
| | | import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.rmi.ServerException; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | * @date 2023-11-30 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class CodeRuleCharacterServiceImpl extends ServiceImpl<CodeRuleCharacterMapper, CodeRuleCharacter> implements ICodeRuleCharacterService { |
| | | |
| | | @Autowired |
| | | private CodeRuleCharacterMapper codeRuleCharacterMapper; |
| | | private final CodeRuleCharacterMapper codeRuleCharacterMapper; |
| | | |
| | | /*** |
| | | * 使用编码规则oid获取数据 |
| | | * @param codeRuleId |
| | |
| | | charValueList.add(chartMap); |
| | | } |
| | | } |
| | | |
| | | return charValueList; |
| | | } |
| | | |
| | | /*** |
| | | * 使用编码规则oid获取数据 |
| | | * @param codeRuleId |
| | | * @param chartType |
| | | * @return |
| | | * @throws VciBaseException |
| | | */ |
| | | @Override |
| | | public List<Map<String, String>> getSelectListByRuleId(String codeRuleId,String chartType) throws ServerException { |
| | | List<Map<String, String>> charValueMap = new ArrayList<>(); |
| | | CodeRuleCharacter codeRuleCharacter=codeRuleCharacterMapper.selectOne(Wrappers.<CodeRuleCharacter>query().lambda().eq(CodeRuleCharacter::getCodeRuleId,codeRuleId).eq(CodeRuleCharacter::getChartType,chartType)); |
| | | if(codeRuleCharacter!=null&&StringUtils.isNotBlank(codeRuleCharacter.getOid())){ |
| | | List<Character> characterList=codeRuleCharacter.getChartValue().chars().mapToObj(c -> (char) c).collect(Collectors.toList()); |
| | | characterList.stream().forEach(item->{ |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("lable",item.toString()); |
| | | map.put("value",item.toString()); |
| | | charValueMap.add(map); |
| | | }); |
| | | } |
| | | return charValueMap; |
| | | } |
| | | |
| | | @Override |
| | | public String getRegexStrByCodeRuleId(String codeRuleId, String chartType) throws ServerException { |
| | | StringBuilder regexStr = new StringBuilder(); |
| | | CodeRuleCharacter codeRuleCharacter=codeRuleCharacterMapper.selectOne(Wrappers.<CodeRuleCharacter>query().lambda().eq(CodeRuleCharacter::getCodeRuleId,codeRuleId).eq(CodeRuleCharacter::getChartType,chartType)); |
| | | if(codeRuleCharacter!=null&&StringUtils.isNotBlank(codeRuleCharacter.getOid())){ |
| | | regexStr.append("^["); |
| | | regexStr.append(codeRuleCharacter.getChartValue()); |
| | | regexStr.append("]+$"); |
| | | } |
| | | return regexStr.toString(); |
| | | } |
| | | |
| | | /*** |
| | | * 字符集数据保存 |
| | | * @param codeRuleCharacterVO |
| | |
| | | codeRuleCharacterMapper.updateById(codeRuleCharacter); |
| | | }else{ |
| | | codeRuleCharacter=new CodeRuleCharacter(); |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeRuleCharacter,"character",null); |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeRuleCharacter,"character"); |
| | | codeRuleCharacter.setCodeRuleId(codeRuleCharacterVO.getCodeRuleId()); |
| | | codeRuleCharacter.setChartType(codeRuleCharacterVO.getChartType()); |
| | | codeRuleCharacter.setChartValue(codeRuleCharacterVO.getChartValue()); |