|
@@ -27,6 +27,8 @@ import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
@@ -1828,7 +1830,7 @@ public class AWImplClient implements AWClint {
|
|
if (cj - 1 != getSize(fno)) {
|
|
if (cj - 1 != getSize(fno)) {
|
|
errmsg = errmsg + "父需求编号层级错误;";
|
|
errmsg = errmsg + "父需求编号层级错误;";
|
|
}
|
|
}
|
|
- if (StringUtils.isNotBlank(fno) && !noList.containsKey(fno)) {
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(fno) && !noList.containsKey(category+fno)) {
|
|
// 导入数据前父需求编号不存在
|
|
// 导入数据前父需求编号不存在
|
|
if(!charterMap.containsKey(getCode(UtilMap.getString(item,"textField_m0afm8pd")))){
|
|
if(!charterMap.containsKey(getCode(UtilMap.getString(item,"textField_m0afm8pd")))){
|
|
errmsg = errmsg + "父需求编号数据不存在;";
|
|
errmsg = errmsg + "父需求编号数据不存在;";
|
|
@@ -1839,7 +1841,7 @@ public class AWImplClient implements AWClint {
|
|
errmsg = errmsg + "需求编号于父需求编号不能相同;";
|
|
errmsg = errmsg + "需求编号于父需求编号不能相同;";
|
|
}
|
|
}
|
|
dataList.get(i).put("selectField_lr4y2xcj",cj + "级");
|
|
dataList.get(i).put("selectField_lr4y2xcj",cj + "级");
|
|
- dataList.get(i).put("multiSelectField_lw678e43_str",String.join(",",UtilMap.getList(item,"multiSelectField_lw678e43")));
|
|
|
|
|
|
+ dataList.get(i).put("multiSelectField_lw678e43_str",JSONObject.toJSONString(item.get("multiSelectField_lw678e43")));
|
|
}
|
|
}
|
|
if(errmsg!=""){
|
|
if(errmsg!=""){
|
|
dataList.get(i).put("result",errmsg);
|
|
dataList.get(i).put("result",errmsg);
|
|
@@ -1853,14 +1855,13 @@ public class AWImplClient implements AWClint {
|
|
String codeNo=getCode(no);
|
|
String codeNo=getCode(no);
|
|
if(charterMap.containsKey(codeNo)){
|
|
if(charterMap.containsKey(codeNo)){
|
|
dataList.get(i).put("associationFormField_lvy7yjq8",getAss(no,UtilMap.getString(charterMap,"instanceId")));
|
|
dataList.get(i).put("associationFormField_lvy7yjq8",getAss(no,UtilMap.getString(charterMap,"instanceId")));
|
|
|
|
+ dataList.get(i).put("textField_lyqprdyf",codeNo); // 序号
|
|
}else{
|
|
}else{
|
|
// 新增
|
|
// 新增
|
|
String category=UtilMap.getString(item,"selectField_lronu2g3");
|
|
String category=UtilMap.getString(item,"selectField_lronu2g3");
|
|
String categoryNew = category.split("(")[1].replace(")", "");
|
|
String categoryNew = category.split("(")[1].replace(")", "");
|
|
no = noCP(UtilMap.getString(item,"textField_lt2d2x79"), categoryNew);
|
|
no = noCP(UtilMap.getString(item,"textField_lt2d2x79"), categoryNew);
|
|
- String fno = noCP(UtilMap.getString(item,"textField_m0afm8pd"), categoryNew);
|
|
|
|
- dataList.get(i).put("textField_lt2d2x79",no);
|
|
|
|
- dataList.get(i).put("textField_m0afm8pd",fno);
|
|
|
|
|
|
+ String fno = "";
|
|
int level = getSize(no);
|
|
int level = getSize(no);
|
|
dataList.get(i).put("selectField_lr4y2xcj",level + "级");
|
|
dataList.get(i).put("selectField_lr4y2xcj",level + "级");
|
|
// 根据层级查询序号
|
|
// 根据层级查询序号
|
|
@@ -1868,23 +1869,75 @@ public class AWImplClient implements AWClint {
|
|
Map reMap=getMaxValue(list,level + "级",category);
|
|
Map reMap=getMaxValue(list,level + "级",category);
|
|
// 处理结果
|
|
// 处理结果
|
|
if(level>1){
|
|
if(level>1){
|
|
-
|
|
|
|
|
|
+ fno=getCodeNo(categoryNew,noCP(UtilMap.getString(item,"textField_m0afm8pd"), categoryNew));
|
|
}
|
|
}
|
|
if(reMap!=null){
|
|
if(reMap!=null){
|
|
String id=UtilMap.getString(reMap,"id");
|
|
String id=UtilMap.getString(reMap,"id");
|
|
- System.out.println(id);
|
|
|
|
|
|
+ noNew=incrementLastPart(id);
|
|
}else{
|
|
}else{
|
|
- noNew=categoryNew+ (level==1?"001":".1");
|
|
|
|
|
|
+ noNew=level==1?categoryNew+"001":fno+".1";
|
|
}
|
|
}
|
|
- // 拼装数据并新增需求
|
|
|
|
codeNo=noNew;
|
|
codeNo=noNew;
|
|
|
|
+ String nowTime= LocalDateTime.now().format(DateTimeFormatter.ofPattern("MMddHHmmssS"));
|
|
|
|
+ dataList.get(i).put("textField_lt2d2x79",noNew+"_"+nowTime);
|
|
|
|
+ dataList.get(i).put("textField_m0afm8pd",fno);
|
|
|
|
+ dataList.get(i).put("textField_lyqprdyf",codeNo); // 序号
|
|
|
|
+ // 拼装数据并新增需求
|
|
|
|
+ Map mapNew=dataList.get(i);
|
|
|
|
+ mapNew.put("textField_lth2h04b",charter);
|
|
|
|
+ mapNew.put("radioField_lroozhse","是");
|
|
|
|
+ mapNew.put("textField_m0m3dyk4",fno);
|
|
|
|
+ mapNew.put("textField_lyqpt99s",codeNo);
|
|
|
|
+ String id=(String) ydClient.operateData(YDParam.builder().appType("APP_YQY0OH7953OKBTM57PLL")
|
|
|
|
+ .systemToken("PGC66MB1H2RLXMFQ7XKW4BC3BDFJ2UDM909XL18")
|
|
|
|
+ .formUuid("FORM-7A52930D0E834522AD65A4CFE2C0818F1KQO")
|
|
|
|
+ .formDataJson(JSONObject.toJSONString(mapNew))
|
|
|
|
+ .build(), YDConf.FORM_OPERATION.create);
|
|
|
|
+ dataList.get(i).put("associationFormField_lvy7yjq8",getAss(noNew+"_"+nowTime,id));
|
|
|
|
+ mapNew.put("instanceId",id);
|
|
|
|
+ mapNew.put("id",codeNo);
|
|
|
|
+ list.add(mapNew);
|
|
}
|
|
}
|
|
- dataList.get(i).put("textField_lyqprdyf",codeNo); // 序号
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return UtilMap.map("data, flag", dataList,flag);
|
|
return UtilMap.map("data, flag", dataList,flag);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static String incrementLastPart(String input) {
|
|
|
|
+ // 查找最后一个点号的位置
|
|
|
|
+ int lastDotIndex = input.lastIndexOf('.');
|
|
|
|
+ // 如果没有点号,则整个字符串都需要加1
|
|
|
|
+ if (lastDotIndex == -1) {
|
|
|
|
+ String q=input.substring(0,input.length()-3);
|
|
|
|
+ String h=input.substring(input.length()-3);
|
|
|
|
+ return q+String.format("%03d",Integer.parseInt(h)+1);
|
|
|
|
+ }
|
|
|
|
+ // 分割字符串
|
|
|
|
+ String prefix = input.substring(0, lastDotIndex + 1);
|
|
|
|
+ String lastPart = input.substring(lastDotIndex + 1);
|
|
|
|
+ // 对最后一部分加1
|
|
|
|
+ String incrementedLastPart = incrementPart(lastPart);
|
|
|
|
+ // 返回拼接后的结果
|
|
|
|
+ return prefix + incrementedLastPart;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static String incrementPart(String part) {
|
|
|
|
+ // 将字符串转换为整数并加1
|
|
|
|
+ int number = Integer.parseInt(part);
|
|
|
|
+ number++;
|
|
|
|
+ // 将整数转换回字符串
|
|
|
|
+ return String.valueOf(number);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static String getCodeNo(String category,String no){
|
|
|
|
+ int dotIndex = no.indexOf('.');
|
|
|
|
+ String beforeDot = dotIndex == -1 ? no : no.substring(0, dotIndex);
|
|
|
|
+ String afterDot = dotIndex == -1 ? "" : no.substring(dotIndex);
|
|
|
|
+ // 对第一部分进行补零
|
|
|
|
+ String paddedBeforeDot = String.format("%03d", Integer.parseInt(beforeDot));
|
|
|
|
+ return category+paddedBeforeDot + afterDot;
|
|
|
|
+ }
|
|
|
|
+
|
|
private Map getMaxValue(List<Map> list, String level, String category){
|
|
private Map getMaxValue(List<Map> list, String level, String category){
|
|
// 查找符合条件的最大 id
|
|
// 查找符合条件的最大 id
|
|
List<Map> list1=list.stream()
|
|
List<Map> list1=list.stream()
|