
17 changed files with 699 additions and 73 deletions
@ -1,11 +1,38 @@ |
|||||
<?xml version="1.0" encoding="UTF-8" ?> |
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.yxt.anrui.as.biz.asserviceattachitem.AsServiceAttachItemMapper"> |
<mapper namespace="com.yxt.anrui.as.biz.asserviceattachitem.AsServiceAttachItemMapper"> |
||||
|
<update id="updateBySidIsDelete"> |
||||
|
UPDATE as_service_attachitem |
||||
|
SET isDelete=1 |
||||
|
where sid in |
||||
|
<foreach collection="list" item="item" index="index" open="(" separator="," close=")"> |
||||
|
#{item} |
||||
|
</foreach> |
||||
|
</update> |
||||
<!-- <where> ${ew.sqlSegment} </where>--> |
<!-- <where> ${ew.sqlSegment} </where>--> |
||||
<!-- ${ew.customSqlSegment} --> |
<!-- ${ew.customSqlSegment} --> |
||||
|
|
||||
|
|
||||
<select id="selectPageVo" resultType="com.yxt.anrui.as.api.asserviceattachitem.AsServiceAttachItemVo"> |
<select id="selectPageVo" resultType="com.yxt.anrui.as.api.asserviceattachitem.AsServiceAttachItemVo"> |
||||
SELECT * FROM as_service_attachitem <where> ${ew.sqlSegment} </where> |
SELECT * FROM as_service_attachitem as a |
||||
|
LEFT JOIN anrui_portal.sys_organization as s ON a.useOrgSid = s.sid |
||||
|
<where> |
||||
|
${ew.sqlSegment} |
||||
|
</where> |
||||
|
</select> |
||||
|
<select id="checkForInsert" resultType="com.yxt.anrui.as.api.asserviceitem.AsServiceItem"> |
||||
|
select * |
||||
|
from as_service_attachitem |
||||
|
where aitemName = #{aitemName} |
||||
|
and useOrgSid = #{useOrgSid} |
||||
|
and isDelete = 0 |
||||
|
</select> |
||||
|
<select id="checkForUpdate" resultType="com.yxt.anrui.as.api.asserviceitem.AsServiceItem"> |
||||
|
select * |
||||
|
from as_service_attachitem |
||||
|
where aitemName = #{aitemName} |
||||
|
and useOrgSid = #{useOrgSid} |
||||
|
and isDelete = 0 |
||||
|
and sid !=#{sid} |
||||
</select> |
</select> |
||||
</mapper> |
</mapper> |
@ -1,19 +1,45 @@ |
|||||
<?xml version="1.0" encoding="UTF-8" ?> |
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.yxt.anrui.as.biz.asserviceitem.AsServiceItemMapper"> |
<mapper namespace="com.yxt.anrui.as.biz.asserviceitem.AsServiceItemMapper"> |
||||
|
<update id="updateBySidIsDelete"> |
||||
|
UPDATE as_service_item |
||||
|
SET isDelete=1 |
||||
|
where sid in |
||||
|
<foreach collection="list" item="item" index="index" open="(" separator="," close=")"> |
||||
|
#{item} |
||||
|
</foreach> |
||||
|
</update> |
||||
<!-- <where> ${ew.sqlSegment} </where>--> |
<!-- <where> ${ew.sqlSegment} </where>--> |
||||
<!-- ${ew.customSqlSegment} --> |
<!-- ${ew.customSqlSegment} --> |
||||
|
|
||||
|
|
||||
<select id="selectPageVo" resultType="com.yxt.anrui.as.api.asserviceitem.AsServiceItemVo"> |
<select id="selectPageVo" resultType="com.yxt.anrui.as.api.asserviceitem.AsServiceItemVo"> |
||||
SELECT * FROM as_service_item <where> ${ew.sqlSegment} </where> |
SELECT * FROM as_service_item as a |
||||
|
LEFT JOIN anrui_portal.sys_organization as s ON a.useOrgSid = s.sid |
||||
|
<where> |
||||
|
${ew.sqlSegment} |
||||
|
</where> |
||||
</select> |
</select> |
||||
<select id="getServiceType" resultType="com.yxt.anrui.as.api.asserviceitem.ServiceTypeVo"> |
<select id="getServiceType" resultType="com.yxt.anrui.as.api.asserviceitem.ServiceTypeVo"> |
||||
SELECT |
SELECT sid AS serviceTypeSid, |
||||
sid AS serviceTypeSid, |
|
||||
serviceTypeName AS serviceType |
serviceTypeName AS serviceType |
||||
FROM |
FROM as_service_type |
||||
as_service_type |
|
||||
WHERE useOrgSid = #{useOrgSid} |
WHERE useOrgSid = #{useOrgSid} |
||||
|
and isDelete = 0 |
||||
|
</select> |
||||
|
<select id="checkForInsert" resultType="com.yxt.anrui.as.api.asserviceitem.AsServiceItem"> |
||||
|
select * |
||||
|
from as_service_item |
||||
|
where sitemName = #{sitemName} |
||||
|
and useOrgSid = #{useOrgSid} |
||||
|
and isDelete = 0 |
||||
|
</select> |
||||
|
<select id="checkForUpdate" resultType="com.yxt.anrui.as.api.asserviceitem.AsServiceItem"> |
||||
|
select * |
||||
|
from as_service_item |
||||
|
where sitemName = #{sitemName} |
||||
|
and useOrgSid = #{useOrgSid} |
||||
|
and isDelete = 0 |
||||
|
and sid !=#{sid} |
||||
</select> |
</select> |
||||
</mapper> |
</mapper> |
@ -0,0 +1,292 @@ |
|||||
|
package com.yxt.anrui.as.utils; |
||||
|
|
||||
|
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 org.apache.commons.lang3.StringUtils; |
||||
|
|
||||
|
import java.util.*; |
||||
|
import java.util.stream.Collectors; |
||||
|
import java.util.stream.Stream; |
||||
|
|
||||
|
/** |
||||
|
* @Description |
||||
|
* @Author liuguohui |
||||
|
* @Date 2021/9/16 |
||||
|
*/ |
||||
|
public class PinYinUtils { |
||||
|
|
||||
|
private static HanyuPinyinOutputFormat format = null; |
||||
|
|
||||
|
static { |
||||
|
format = new HanyuPinyinOutputFormat(); |
||||
|
//拼音小写
|
||||
|
format.setCaseType(HanyuPinyinCaseType.LOWERCASE); |
||||
|
//无音标方式;WITH_TONE_NUMBER:1-4数字表示英标;WITH_TONE_MARK:直接用音标符(必须WITH_U_UNICODE否则异常
|
||||
|
format.setToneType(HanyuPinyinToneType.WITHOUT_TONE); |
||||
|
//用v表示ü
|
||||
|
format.setVCharType(HanyuPinyinVCharType.WITH_V); |
||||
|
} |
||||
|
|
||||
|
// 多音字
|
||||
|
private static final Map<String, Object> DYZMAP = setDYZMap(); |
||||
|
|
||||
|
private static Map<String, Object> setDYZMap(){ |
||||
|
Map<String, Object> map = new HashMap<>(); |
||||
|
map.put("仇","QIU"); |
||||
|
map.put("柏", "BO"); |
||||
|
map.put("牟", "MU"); |
||||
|
map.put("颉", "XIE"); |
||||
|
map.put("解", "XIE"); |
||||
|
map.put("尉", "YU"); |
||||
|
map.put("奇", "JI"); |
||||
|
map.put("单", "SHAN"); |
||||
|
map.put("谌", "SHEN"); |
||||
|
map.put("乐", "YUE"); |
||||
|
map.put("召", "SHAO"); |
||||
|
map.put("朴", "PIAO"); |
||||
|
map.put("区", "OU"); |
||||
|
map.put("查", "ZHA"); |
||||
|
map.put("曾", "ZENG"); |
||||
|
map.put("缪", "MIAO"); |
||||
|
map.put("晟", "CHENG"); |
||||
|
map.put("员", "YUN"); |
||||
|
map.put("贠", "YUN"); |
||||
|
map.put("黑", "HE"); |
||||
|
map.put("重", "CHONG"); |
||||
|
map.put("秘", "BI"); |
||||
|
map.put("冼", "XIAN"); |
||||
|
map.put("折", "SHE"); |
||||
|
map.put("翟", "ZHAI"); |
||||
|
map.put("盖", "GE"); |
||||
|
map.put("万俟", "MOQI"); |
||||
|
map.put("尉迟", "YUCHI"); |
||||
|
return map; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 返回字符串的拼音 |
||||
|
* @param str |
||||
|
* @return |
||||
|
*/ |
||||
|
public static String[] getCharPinYinString(String str) { |
||||
|
if (str == null || str.length() < 1) { |
||||
|
return null; |
||||
|
} |
||||
|
List<String> result = new ArrayList<String>(); |
||||
|
//对字符串中的记录逐个分析
|
||||
|
for (int i = 0; i < str.length(); i++) { |
||||
|
result = getCharPinYinString(str.charAt(i), result); |
||||
|
} |
||||
|
return result.toArray(new String[result.size()]); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将字符c的拼音拼接到list中的记录中 |
||||
|
* @param c |
||||
|
* @param list |
||||
|
* @return |
||||
|
*/ |
||||
|
private static List<String> getCharPinYinString(char c, List<String> list) { |
||||
|
String[] strs = getCharPinYinString(c); |
||||
|
List<String> result = new ArrayList<String>(); |
||||
|
// strs去重(多音字)
|
||||
|
strs = disdinctStr(strs); |
||||
|
|
||||
|
//如果解析出的拼音为空,判断字符C是否为英文字母,如果是英文字母则添加值拼音结果中
|
||||
|
if (strs == null) { |
||||
|
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) { |
||||
|
c = c <= 91 ? (char)(c + 32) : c; |
||||
|
if (list == null || list.size() == 0) { |
||||
|
result.add(c + ""); |
||||
|
} else { |
||||
|
for (String s : list) { |
||||
|
result.add(s + c); |
||||
|
} |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
return list; |
||||
|
} |
||||
|
//将字符C的拼音首和已存在的拼音首组合成新的记录
|
||||
|
for (String str : strs) { |
||||
|
if (list == null || list.size() == 0) { |
||||
|
result.add(str); |
||||
|
} else { |
||||
|
for (String s : list) { |
||||
|
result.add(s + str); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 返回汉字的拼音 |
||||
|
* @param c |
||||
|
* @return |
||||
|
*/ |
||||
|
public static String[] getCharPinYinString(char c) { |
||||
|
try { |
||||
|
//返回字符C的拼音
|
||||
|
return PinyinHelper.toHanyuPinyinStringArray(c, format); |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
/** |
||||
|
* 缩写 |
||||
|
* @param args |
||||
|
*/ |
||||
|
public static String sx(String hz) { |
||||
|
char [] nameArray = hz.toCharArray(); |
||||
|
String b=""; |
||||
|
for (int i = 0; i < nameArray.length; i++) { |
||||
|
if (Character.toString(nameArray[i]).matches("^[\u4e00-\u9fa5]+$")) { |
||||
|
b=b+PinYinUtils.getCharDuoPinYinChar(String.valueOf(nameArray[i])); |
||||
|
}else{ |
||||
|
b=b+String.valueOf(nameArray[i]); |
||||
|
} |
||||
|
} |
||||
|
return b; |
||||
|
} |
||||
|
/** |
||||
|
* 返回字符串的拼音的首字母 |
||||
|
* @param str |
||||
|
* @return |
||||
|
*/ |
||||
|
public static String[] getCharPinYinChar(String str) { |
||||
|
if (str == null || str.length() < 1) { |
||||
|
return null; |
||||
|
} |
||||
|
List<String> result = new ArrayList<String>(); |
||||
|
//对字符串中的记录逐个分析
|
||||
|
for (int i = 0; i < str.length(); i++) { |
||||
|
result = getCharPinYinChar(str.charAt(i), result); |
||||
|
} |
||||
|
return result.toArray(new String[result.size()]); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将字符c的拼音首字母拼接到list中的记录中 |
||||
|
* @param c |
||||
|
* @param list |
||||
|
* @return |
||||
|
*/ |
||||
|
private static List<String> getCharPinYinChar(char c, List<String> list) { |
||||
|
char[] chars = getCharPinYinChar(c); |
||||
|
List<String> result = new ArrayList<String>(); |
||||
|
//如果解析出的拼音为空,判断字符C是否为英文字母,如果是英文字母则添加值拼音结果中
|
||||
|
if (chars == null) { |
||||
|
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) { |
||||
|
c = c < 91 ? (char)(c + 32) : c; |
||||
|
if (list == null || list.size() == 0) { |
||||
|
result.add(c + ""); |
||||
|
} else { |
||||
|
for (String s : list) { |
||||
|
result.add(s + c); |
||||
|
} |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
return list; |
||||
|
} |
||||
|
//将字符C的拼音首字母和已存在的拼音首字母组合成新的记录
|
||||
|
for (char ch : chars) { |
||||
|
if (list == null || list.size() == 0) { |
||||
|
result.add(ch + ""); |
||||
|
} else { |
||||
|
for (String s : list) { |
||||
|
result.add(s + ch); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 返回汉字拼音首字母 |
||||
|
* @param c |
||||
|
* @return |
||||
|
*/ |
||||
|
public static char[] getCharPinYinChar(char c) { |
||||
|
//字符C的拼音
|
||||
|
String[] strs = getCharPinYinString(c); |
||||
|
if (strs != null) { |
||||
|
//截取拼音的首字母
|
||||
|
char[] chars = new char[strs.length]; |
||||
|
for(int i = 0; i <chars.length; i++) { |
||||
|
chars[i] = strs[i].charAt(0); |
||||
|
} |
||||
|
return chars; |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 去重 |
||||
|
* @param str |
||||
|
* @return |
||||
|
*/ |
||||
|
private static String [] disdinctStr(String str[]){ |
||||
|
Stream<String> arrStream = Arrays.stream(str); |
||||
|
List<String> arrList = arrStream.distinct().collect(Collectors.toList()); |
||||
|
str = new String[arrList.size()]; |
||||
|
arrList.toArray(str); |
||||
|
return str; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 判断传入的字符串是否为中文,将中文的转换为拼音 |
||||
|
* @param name |
||||
|
* @return |
||||
|
*/ |
||||
|
public static String getPinYinName(String name){ |
||||
|
char[] nameArray = name.toCharArray(); |
||||
|
String newName = ""; |
||||
|
for (int i = 0; i < nameArray.length; i++) { |
||||
|
if (Character.toString(nameArray[i]).matches("^[\u4e00-\u9fa5]+$")) { // 如果字符是中文,则将中文转为汉语拼音
|
||||
|
String[] pinYinString = PinYinUtils.getCharPinYinString(nameArray[i]); |
||||
|
// strs去重(多音字)
|
||||
|
pinYinString = disdinctStr(pinYinString); |
||||
|
String pinYinStr = StringUtils.join(pinYinString); |
||||
|
newName = newName + pinYinStr; |
||||
|
}else { |
||||
|
newName = newName + Character.toString(nameArray[i]); |
||||
|
} |
||||
|
} |
||||
|
return newName; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 返回字符串的拼音的首字母(包括多音字) |
||||
|
* @param str |
||||
|
* @return |
||||
|
*/ |
||||
|
public static String getCharDuoPinYinChar(String str) { |
||||
|
if (str == null || str.length() < 1) { |
||||
|
return null; |
||||
|
} |
||||
|
char firstChar = str.toCharArray()[0]; |
||||
|
if(Character.toString(firstChar).matches("^[\u4e00-\u9fa5]+$")){ // 为中文
|
||||
|
char[] charPinYinChar = getCharPinYinChar(firstChar); |
||||
|
String result = ""; |
||||
|
if (DYZMAP.containsKey(Character.toString(firstChar))) { |
||||
|
result = DYZMAP.get(Character.toString(firstChar)).toString().substring(0, 1); |
||||
|
}else { |
||||
|
result = StringUtils.join(charPinYinChar[0]); |
||||
|
} |
||||
|
return result.toUpperCase(); |
||||
|
}else if(Character.toString(firstChar).matches("^[a-zA-Z]")){ // 为英文字母
|
||||
|
return Character.toString(firstChar).toUpperCase(); |
||||
|
}else { // 特殊符号
|
||||
|
return "#"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
Loading…
Reference in new issue