| | |
| | | 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 org.springblade.core.tool.api.R; |
| | |
| | | * @throws VciBaseException |
| | | */ |
| | | @Override |
| | | public R saveOrUpdate(CodeRuleCharacterVO codeRuleCharacterVO) throws VciBaseException { |
| | | public R saveOrUpdate(CodeRuleCharacterVO codeRuleCharacterVO,int operation) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(codeRuleCharacterVO.getCodeRuleId(),"编码规则id",codeRuleCharacterVO.getChartType(),"字符集类型"); |
| | | CodeRuleCharacter codeRuleCharacter=codeRuleCharacterMapper.selectOne(Wrappers.<CodeRuleCharacter>query().lambda().eq(CodeRuleCharacter::getCodeRuleId,codeRuleCharacterVO.getCodeRuleId()).eq(CodeRuleCharacter::getChartType,codeRuleCharacterVO.getChartType())); |
| | | if(codeRuleCharacter!=null&& StringUtils.isNotBlank(codeRuleCharacter.getOid())) { |
| | | List<Character> oldCharacterList = StringUtils.isBlank(codeRuleCharacter.getChartValue())?new ArrayList<>():codeRuleCharacter.getChartValue().chars().mapToObj(c -> (char) c).collect(Collectors.toList()); |
| | | List<Character> newCharacterList = StringUtils.isBlank(codeRuleCharacterVO.getChartValue())?new ArrayList<>():codeRuleCharacterVO.getChartValue().chars().mapToObj(c -> (char) c).collect(Collectors.toList()); |
| | | List<Character> intersectList = intersect(oldCharacterList, newCharacterList); |
| | | if (intersectList.size() > 0) { |
| | | String ss = Joiner.on(",").join(intersectList); |
| | | throw new VciBaseException("系统中存在相应的字符:【" + ss + "】"); |
| | | if(operation==1) {//新增时候 |
| | | List<Character> intersectList = intersect(oldCharacterList, newCharacterList); |
| | | if (intersectList.size() > 0) { |
| | | String ss = Joiner.on(",").join(intersectList); |
| | | throw new VciBaseException("系统中存在相应的字符:【" + ss + "】"); |
| | | } |
| | | List<Character> allCharacterList = union(oldCharacterList, newCharacterList); |
| | | String str = allCharacterList.stream().map(integer -> Func.isNotEmpty(integer) ? integer.toString() : "").collect(Collectors.joining()); |
| | | codeRuleCharacter.setChartValue(str); |
| | | }else if(operation==2){//修改 |
| | | String oldChartValue= codeRuleCharacterVO.getOldChartValue(); |
| | | String chartValue= codeRuleCharacterVO.getChartValue(); |
| | | Map<String,String> oldChartNewChartMap=new HashMap<>(); |
| | | List<Character> chartValueList = StringUtils.isBlank(chartValue)?new ArrayList<>():chartValue.chars().mapToObj(c -> (char) c).collect(Collectors.toList()); |
| | | List<Character> oldChartValueList = StringUtils.isBlank(oldChartValue)?new ArrayList<>():oldChartValue.chars().mapToObj(c -> (char) c).collect(Collectors.toList()); |
| | | |
| | | if(chartValueList.size()!=oldChartValueList.size()){ |
| | | throw new VciBaseException("替换的值个数与选中值的个数不相等"); |
| | | } |
| | | /*** |
| | | * id |
| | | */ |
| | | for (int i=0;i<oldChartValueList.size();i++){ |
| | | Character oldValue=oldChartValueList.get(i); |
| | | if(oldCharacterList.contains(oldValue)){ |
| | | int index =oldCharacterList.indexOf(oldValue); |
| | | oldCharacterList.set(index,chartValueList.get(i)); |
| | | } |
| | | } |
| | | String str = oldCharacterList.stream().map(integer -> Func.isNotEmpty(integer) ? integer.toString() : "").collect(Collectors.joining()); |
| | | codeRuleCharacter.setChartValue(str); |
| | | }else{//删除 |
| | | oldCharacterList.removeAll(newCharacterList); |
| | | String str = oldCharacterList.stream().map(integer -> Func.isNotEmpty(integer) ? integer.toString() : "").collect(Collectors.joining()); |
| | | codeRuleCharacter.setChartValue(str); |
| | | } |
| | | List<Character> allCharacterList = union(oldCharacterList, newCharacterList); |
| | | String str = allCharacterList.stream().map(integer -> Func.isNotEmpty(integer)?integer.toString():"").collect(Collectors.joining()); |
| | | codeRuleCharacter.setChartValue(str); |
| | | codeRuleCharacterMapper.updateById(codeRuleCharacter); |
| | | }else{ |
| | | codeRuleCharacter=new CodeRuleCharacter(); |