forked from luyan/epmet-cloud-lingshan
				
			
				 14 changed files with 367 additions and 3 deletions
			
			
		| @ -0,0 +1,29 @@ | |||
| package com.epmet.dto.indexcal; | |||
| 
 | |||
| import lombok.Data; | |||
| 
 | |||
| import java.io.Serializable; | |||
| 
 | |||
| /** | |||
|  *  指标计算通用入参DTO | |||
|  * | |||
|  * @author yinzuomei@elink-cn.com | |||
|  * @date 2020/8/26 10:49 | |||
|  */ | |||
| @Data | |||
| public class CalculateCommonFormDTO implements Serializable { | |||
|     /** | |||
|      * 月份id:  yyyyMM | |||
|      */ | |||
|     private String monthId; | |||
| 
 | |||
|     /** | |||
|      * 客户id | |||
|      */ | |||
|     private String customerId; | |||
| 
 | |||
|     public CalculateCommonFormDTO(String customerId, String monthId) { | |||
|         this.monthId=monthId; | |||
|         this.customerId=customerId; | |||
|     } | |||
| } | |||
| @ -0,0 +1,26 @@ | |||
| package com.epmet.dto.indexcal; | |||
| 
 | |||
| import lombok.Data; | |||
| 
 | |||
| import java.io.Serializable; | |||
| import java.math.BigDecimal; | |||
| 
 | |||
| /** | |||
|  * 最值通用DTO | |||
|  * | |||
|  * @author yinzuomei@elink-cn.com | |||
|  * @date 2020/8/26 10:39 | |||
|  */ | |||
| @Data | |||
| public class ExtremeValueCommonDTO implements Serializable { | |||
| 
 | |||
|     /** | |||
|      * 最小值 | |||
|      */ | |||
|     private BigDecimal minValue; | |||
| 
 | |||
|     /** | |||
|      * 最小值 | |||
|      */ | |||
|     private BigDecimal maxValue; | |||
| } | |||
| @ -0,0 +1,56 @@ | |||
| package com.epmet.eum; | |||
| 
 | |||
| /** | |||
|  * 需要计算指标code枚举类 | |||
|  * | |||
|  * @author jianjun liu | |||
|  * @date 2020-08-26 11:14 | |||
|  **/ | |||
| public enum IndexCodeEnum { | |||
|     DANG_YUAN_XIANG_GUAN("dangyuanxiangguan", "党员相关", 1), | |||
|     WANG_GE_XIANG_GUAN("wangggexiangguan", "网格相关", 1), | |||
|     SHE_QU_XIANG_GUAN("shequxiangguan", "社区相关", 1), | |||
|     JIE_DAO_XIANG_GUAN("jiedaoxiangguan", "街道相关", 1), | |||
|     QU_ZHI_BU_MEN("quzhibumen", "区直部门", 1), | |||
|     QUAN_QU_XIANG_GUAN("quanquxiangguan", "全区相关", 1), | |||
| 
 | |||
|     DANG_JIAN_NENG_LI("dangjiannengli", "党建能力", 2), | |||
|     ZHI_LI_NENG_LI("zhilinengli", "治理能力", 2), | |||
|     FU_WU_NENG_LI("fuwunengli", "服务能力", 2), | |||
| 
 | |||
|     CAN_YU_YI_SHI("canyuyishi", "参与议事", 4), | |||
|     DANG_WU_HUO_DONG("dangwuhuodong", "党务活动", 4), | |||
|     LIAN_XI_QUN_ZHONG("lianxiqunzhong", "联系群众", 4), | |||
| 
 | |||
|     ; | |||
| 
 | |||
|     private String code; | |||
|     private String name; | |||
|     private Integer level; | |||
| 
 | |||
| 
 | |||
|     IndexCodeEnum(String code, String name, Integer level) { | |||
|         this.code = code; | |||
|         this.name = name; | |||
|         this.level = level; | |||
|     } | |||
| 
 | |||
|     public static IndexCodeEnum getEnum(String code) { | |||
|         IndexCodeEnum[] values = IndexCodeEnum.values(); | |||
|         for (IndexCodeEnum value : values) { | |||
|             if (code != null && value.getCode().equals(code)) { | |||
|                 return value; | |||
|             } | |||
|         } | |||
|         return null; | |||
|     } | |||
| 
 | |||
| 
 | |||
|     public String getCode() { | |||
|         return code; | |||
|     } | |||
| 
 | |||
|     public String getName() { | |||
|         return name; | |||
|     } | |||
| } | |||
| @ -0,0 +1,21 @@ | |||
| package com.epmet.service.indexcal; | |||
| 
 | |||
| import com.epmet.dto.indexcal.CalculateCommonFormDTO; | |||
| 
 | |||
| /** | |||
|  * 网格相关指标计算 | |||
|  * | |||
|  * @author yinzuomei@elink-cn.com | |||
|  * @date 2020/8/26 10:34 | |||
|  */ | |||
| public interface GridCorreLationService { | |||
| 
 | |||
|     /** | |||
|      * @return java.lang.Boolean | |||
|      * @param formDTO | |||
|      * @author yinzuomei | |||
|      * @description 网格相关,分值计算 | |||
|      * @Date 2020/8/26 10:51 | |||
|      **/ | |||
|     Boolean calculateGridCorreLation(CalculateCommonFormDTO formDTO); | |||
| } | |||
| @ -0,0 +1,27 @@ | |||
| package com.epmet.service.indexcal.impl; | |||
| 
 | |||
| import com.epmet.dto.indexcal.CalculateCommonFormDTO; | |||
| import com.epmet.service.indexcal.GridCorreLationService; | |||
| import org.springframework.stereotype.Service; | |||
| 
 | |||
| /** | |||
|  * 网格相关service | |||
|  * | |||
|  * @author yinzuomei@elink-cn.com | |||
|  * @date 2020/8/26 10:35 | |||
|  */ | |||
| @Service | |||
| public class GridCorreLationServiceImpl implements GridCorreLationService { | |||
| 
 | |||
|     /** | |||
|      * @param formDTO | |||
|      * @return java.lang.Boolean | |||
|      * @author yinzuomei | |||
|      * @description 网格相关,分值计算 | |||
|      * @Date 2020/8/26 10:51 | |||
|      **/ | |||
|     @Override | |||
|     public Boolean calculateGridCorreLation(CalculateCommonFormDTO formDTO) { | |||
|         return null; | |||
|     } | |||
| } | |||
| @ -0,0 +1,170 @@ | |||
| package com.epmet.util; | |||
| 
 | |||
| 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.HanyuPinyinVCharType; | |||
| import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; | |||
| 
 | |||
| import java.util.HashMap; | |||
| import java.util.HashSet; | |||
| import java.util.Map; | |||
| import java.util.Set; | |||
| 
 | |||
| 
 | |||
| /** | |||
|  * @author liujianjun | |||
|  */ | |||
| public class Pinyin4jUtil { | |||
|     private static Map<Character,String[]> duoyinMap; | |||
|     static { | |||
|         duoyinMap = new HashMap<>(); | |||
|         duoyinMap.put('区',new String[]{"qu"}); | |||
|         duoyinMap.put('系',new String[]{"xi"}); | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * getFirstSpellPinYin:(多音字的时候获取第一个). <br/> | |||
|      * | |||
|      * @param src         传入的拼音字符串,以逗号隔开 | |||
|      * @param isFullSpell 是否全拼,true:全拼,false:第一个汉字全拼(其它汉字取首字母) | |||
|      * @return 第一个拼音 | |||
|      */ | |||
|     public static String getFirstSpellPinYin(String src, boolean isFullSpell) { | |||
|         String targetStr = Pinyin4jUtil.makeStringByStringSet(Pinyin4jUtil.getPinyin(src, isFullSpell)); | |||
|         System.out.println(targetStr); | |||
|         String[] split = targetStr.split(","); | |||
|         if (split.length > 1) { | |||
|             targetStr = split[0]; | |||
|         } | |||
|         return targetStr; | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * makeStringByStringSet:(拼音字符串集合转换字符串(逗号分隔)). <br/> | |||
|      * | |||
|      * @param stringSet 拼音集合 | |||
|      * @return 带逗号字符串 | |||
|      */ | |||
|     public static String makeStringByStringSet(Set<String> stringSet) { | |||
|         StringBuilder str = new StringBuilder(); | |||
|         int i = 0; | |||
|         if (stringSet.size() > 0) { | |||
|             for (String s : stringSet) { | |||
|                 if (i == stringSet.size() - 1) { | |||
|                     str.append(s); | |||
|                 } else { | |||
|                     str.append(s + ","); | |||
|                 } | |||
|                 i++; | |||
|             } | |||
|         } | |||
|         return str.toString().toLowerCase(); | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * getPinyin:(获取汉字拼音). <br/> | |||
|      * | |||
|      * @param src       汉字 | |||
|      * @param isFullSpell 是否全拼,如果为true:全拼,false:首字全拼 | |||
|      * @return | |||
|      */ | |||
|     public static Set<String> getPinyin(String src, boolean isFullSpell) { | |||
|         if (src != null && !src.trim().equalsIgnoreCase("")) { | |||
|             char[] srcChar; | |||
|             srcChar = src.toCharArray(); | |||
|             // 汉语拼音格式输出类
 | |||
|             HanyuPinyinOutputFormat hanYuPinOutputFormat = new HanyuPinyinOutputFormat(); | |||
| 
 | |||
|             // 输出设置,大小写,音标方式等
 | |||
|             hanYuPinOutputFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); | |||
|             hanYuPinOutputFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); | |||
|             hanYuPinOutputFormat.setVCharType(HanyuPinyinVCharType.WITH_V); | |||
| 
 | |||
|             String[][] temp = new String[src.length()][]; | |||
|             for (int i = 0; i < srcChar.length; i++) { | |||
|                 char c = srcChar[i]; | |||
|                 if (String.valueOf(c).matches("[\\u4E00-\\u9FA5]+")) {//中文
 | |||
|                     try { | |||
|                         String[] py = duoyinMap.get(c); | |||
|                         if (py != null){ | |||
|                             temp[i] = py; | |||
|                         }else{ | |||
|                             temp[i] = PinyinHelper.toHanyuPinyinStringArray(srcChar[i], hanYuPinOutputFormat); | |||
|                         } | |||
| 
 | |||
|                         if (!isFullSpell) { | |||
|                             if (i == 0) { | |||
|                                 temp[i] = temp[i]; | |||
|                             } else { | |||
|                                 String[] tTemps = new String[temp[i].length]; | |||
|                                 for (int j = 0; j < temp[i].length; j++) { | |||
|                                     char t = temp[i][j].charAt(0); | |||
|                                     tTemps[j] = Character.toString(t); | |||
|                                 } | |||
|                                 temp[i] = tTemps; | |||
|                             } | |||
|                         } | |||
|                     } catch (BadHanyuPinyinOutputFormatCombination e) { | |||
|                         e.printStackTrace(); | |||
|                     } | |||
|                 } else if (((int) c >= 65 && (int) c <= 90) | |||
|                         || ((int) c >= 97 && (int) c <= 122)) {//英文
 | |||
|                     temp[i] = new String[]{String.valueOf(srcChar[i])}; | |||
|                 } else { | |||
|                     temp[i] = new String[]{""}; | |||
|                 } | |||
|             } | |||
|             String[] pingyinArray = exchange(temp); | |||
|             Set<String> pinyinSet = new HashSet<String>(); | |||
|             for (int i = 0; i < pingyinArray.length; i++) { | |||
|                 pinyinSet.add(pingyinArray[i]); | |||
|             } | |||
|             return pinyinSet; | |||
|         } | |||
|         return null; | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * 递归 | |||
|      * | |||
|      * @param strJaggedArray | |||
|      * @return | |||
|      */ | |||
|     public static String[] exchange(String[][] strJaggedArray) { | |||
|         String[][] temp = doExchange(strJaggedArray); | |||
|         return temp[0]; | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * 递归 | |||
|      * | |||
|      * @param strJaggedArray | |||
|      * @return | |||
|      */ | |||
|     private static String[][] doExchange(String[][] strJaggedArray) { | |||
|         int len = strJaggedArray.length; | |||
|         if (len >= 2) { | |||
|             int len1 = strJaggedArray[0].length; | |||
|             int len2 = strJaggedArray[1].length; | |||
|             int newlen = len1 * len2; | |||
|             String[] temp = new String[newlen]; | |||
|             int Index = 0; | |||
|             for (int i = 0; i < len1; i++) { | |||
|                 for (int j = 0; j < len2; j++) { | |||
|                     temp[Index] = strJaggedArray[0][i] + strJaggedArray[1][j]; | |||
|                     Index++; | |||
|                 } | |||
|             } | |||
|             String[][] newArray = new String[len - 1][]; | |||
|             for (int i = 2; i < len; i++) { | |||
|                 newArray[i - 1] = strJaggedArray[i]; | |||
|             } | |||
|             newArray[0] = temp; | |||
|             return doExchange(newArray); | |||
|         } else { | |||
|             return strJaggedArray; | |||
|         } | |||
|     } | |||
| } | |||
					Loading…
					
					
				
		Reference in new issue