| | |
| | | package com.highdatas.mdm.util; |
| | | |
| | | import com.highdatas.mdm.process.canvas.ProcessDiagramGenerator; |
| | | import net.sourceforge.pinyin4j.PinyinHelper; |
| | | import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; |
| | | import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; |
| | | import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; |
| | | import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; |
| | | import org.activiti.bpmn.model.BpmnModel; |
| | | import org.activiti.engine.ProcessEngineConfiguration; |
| | | import org.activiti.engine.RepositoryService; |
| | | import org.activiti.engine.repository.ProcessDefinition; |
| | | import com.highdatas.mdm.process.canvas.ProcessDiagramGenerator; |
| | | import org.apache.commons.io.FileUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | |
| | | public class WorkflowUtils { |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(toFirstChar("汉字转换为拼音").toUpperCase()); //转为首字母大写 |
| | | //System.out.println(toPinyin("汉字转换为拼音")); |
| | | } |
| | | private static Logger logger = LoggerFactory.getLogger(WorkflowUtils.class); |
| | | |
| | | /** |
| | |
| | | return diagramPath; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取字符串拼音的第一个字母 |
| | | * @param chinese |
| | | * @return |
| | | */ |
| | | public static String toFirstChar(String chinese){ |
| | | String pinyinStr = ""; |
| | | char[] newChar = chinese.toCharArray(); //转为单个字符 |
| | | HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat(); |
| | | defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); |
| | | defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); |
| | | for (int i = 0; i < newChar.length; i++) { |
| | | if (newChar[i] > 128) { |
| | | try { |
| | | pinyinStr += PinyinHelper.toHanyuPinyinStringArray(newChar[i], defaultFormat)[0].charAt(0); |
| | | } catch (BadHanyuPinyinOutputFormatCombination e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }else{ |
| | | pinyinStr += newChar[i]; |
| | | } |
| | | } |
| | | return pinyinStr; |
| | | } |
| | | |
| | | /** |
| | | * 汉字转为拼音 |
| | | * @param chinese |
| | | * @return |
| | | */ |
| | | public static String toPinyin(String chinese){ |
| | | String pinyinStr = ""; |
| | | char[] newChar = chinese.toCharArray(); |
| | | HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat(); |
| | | defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); |
| | | defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); |
| | | for (int i = 0; i < newChar.length; i++) { |
| | | if (newChar[i] > 128) { |
| | | try { |
| | | pinyinStr += PinyinHelper.toHanyuPinyinStringArray(newChar[i], defaultFormat)[0]; |
| | | } catch (BadHanyuPinyinOutputFormatCombination e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }else{ |
| | | pinyinStr += newChar[i]; |
| | | } |
| | | } |
| | | return pinyinStr; |
| | | } |
| | | } |