修改分部名称生成登录名逻辑

main
youHong.ai 2023-03-23 16:15:32 +08:00
parent 228ed443a1
commit e22366fdc5
4 changed files with 100 additions and 5 deletions

5
.gitignore vendored
View File

@ -36,6 +36,7 @@ DirectoryV2.xml
/lib/classbeanLib/ecology-dev-lib.jar /lib/classbeanLib/ecology-dev-lib.jar
/lib/classbeanLib/web-inf-class-lib.jar /lib/classbeanLib/web-inf-class-lib.jar
/lib/weaverLib/ /lib/weaverLib/
/lib/jitulib/
*.groovy *.groovy
*.log *.log
*.iml *.iml
@ -46,5 +47,5 @@ src/test/resources/font
src/main/resources/WEB-INF/vm/outFile src/main/resources/WEB-INF/vm/outFile
target/ target/
*.back *.back
src/main/old_src/ src/main/aiyh_old_src/
src/main/jitu_src/

View File

@ -15,6 +15,7 @@ import weaver.soa.workflow.request.RequestInfo;
import weaver.youhong.ai.pcn.actioin.generateloginid.mapper.GenerateLoginIdMapper; import weaver.youhong.ai.pcn.actioin.generateloginid.mapper.GenerateLoginIdMapper;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -57,9 +58,11 @@ public class GenerateLoginIdAction extends SafeCusBaseAction {
Map<String, String> mainTableValue = super.getMainTableValue(requestInfo); Map<String, String> mainTableValue = super.getMainTableValue(requestInfo);
String subCompanyName = mainTableValue.get(subCompanyTextField); String subCompanyName = mainTableValue.get(subCompanyTextField);
String subCompanyId = mapper.selectSubCompanyIdBySubCompanyName(subCompanyName); String subCompanyId = mapper.selectSubCompanyIdBySubCompanyName(subCompanyName);
Map<String, String> lastLoginIdInfo = mapper.selectLastLoginId(subCompanyName, subCompanyId, subCompanyName + "%"); // Map<String, String> lastLoginIdInfo = mapper.selectLastLoginId(subCompanyName, subCompanyId, subCompanyName + "%");
String loginIdNo = lastLoginIdInfo.get("loginIdNo"); // String loginIdNo = lastLoginIdInfo.get("loginIdNo");
String loginId = prefixFill(loginIdNo, subCompanyName); // String loginId = prefixFill(loginIdNo, subCompanyName);
List<String> loginIdList = mapper.selectLoginIdList(subCompanyId);
String loginId = subCompanyName + formatList(loginIdList, Integer.parseInt(numberFillQuantity));
if (mapper.updateLoginId(billTable, requestId, loginId, loginIdField)) { if (mapper.updateLoginId(billTable, requestId, loginId, loginIdField)) {
try { try {
Thread.sleep(500); Thread.sleep(500);
@ -74,6 +77,48 @@ public class GenerateLoginIdAction extends SafeCusBaseAction {
} }
} }
/**
* <h2></h2>
*
* @param list
* @param length
* @return
*/
public String formatList(List<String> list, int length) {
NumberFormat format = NumberFormat.getInstance();
format.setMinimumIntegerDigits(length);
format.setGroupingUsed(false);
if (list == null || list.isEmpty()) {
return format.format(0);
}
int maxNum = 0;
for (String s : list) {
if (s != null && !s.isEmpty()) {
int num = 0;
boolean foundNum = false;
// 从末尾向前读取
for (int i = s.length() - 1; i >= 0; i--) {
char c = s.charAt(i);
if (Character.isDigit(c)) {
foundNum = true;
int digit = c - '0';
// 根据数字位数计算数字大小
num += digit * Math.pow(10, s.length() - i - 1);
} else if (foundNum) {
// 遇到非数字字符,停止读取
break;
}
}
if (num > maxNum) {
maxNum = num;
}
}
}
return format.format(maxNum + 1);
}
/** /**
* <h2></h2> * <h2></h2>
* *

View File

@ -5,6 +5,7 @@ import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper; import aiyh.utils.annotation.recordset.SqlMapper;
import aiyh.utils.annotation.recordset.Update; import aiyh.utils.annotation.recordset.Update;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -47,6 +48,16 @@ public interface GenerateLoginIdMapper {
); );
/**
* <h2></h2>
*
* @param subCompanyId id
* @return
*/
@Select("select LOGINID from hrmresource where SUBCOMPANYID1 = #{subCompanyId}")
List<String> selectLoginIdList(@ParamMapper("subCompanyId") String subCompanyId);
/** /**
* <h2>loginId</h2> * <h2>loginId</h2>
* *

View File

@ -27,6 +27,7 @@ import youhong.ai.pcn.pojo.Student;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.text.NumberFormat;
import java.util.*; import java.util.*;
import static com.alibaba.fastjson.JSON.parseObject; import static com.alibaba.fastjson.JSON.parseObject;
@ -257,5 +258,42 @@ public class UtilTest extends BaseTest {
@Test @Test
public void testOaNum() { public void testOaNum() {
out.println(formatList(Arrays.asList("PCN2P000001", "PCNS0000002", "PDJA000003", "PDC0000405"), 10));
} }
public static String formatList(List<String> list, int length) {
NumberFormat format = NumberFormat.getInstance();
format.setMinimumIntegerDigits(length);
format.setGroupingUsed(false);
if (list == null || list.isEmpty()) {
return format.format(0);
}
int maxNum = 0;
for (String s : list) {
if (s != null && !s.isEmpty()) {
int num = 0;
boolean foundNum = false;
// 从末尾向前读取
for (int i = s.length() - 1; i >= 0; i--) {
char c = s.charAt(i);
if (Character.isDigit(c)) {
foundNum = true;
int digit = c - '0';
// 根据数字位数计算数字大小
num += digit * Math.pow(10, s.length() - i - 1);
} else if (foundNum) {
// 遇到非数字字符,停止读取
break;
}
}
if (num > maxNum) {
maxNum = num;
}
}
}
return format.format(maxNum + 1);
}
} }