|
|
@ -1,5 +1,7 @@ |
|
|
package com.mdp.form.service; |
|
|
package com.mdp.form.service; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|
|
@ -79,28 +81,23 @@ public class FormDataService extends BaseService<FormDataMapper,FormData> { |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
public String createBizKey(FormDefVo formDefVo,FormData formData){ |
|
|
public String createBizKey(FormDefVo formDefVo,FormData formData){ |
|
|
User user= LoginUtils.getCurrentUserInfo(); |
|
|
|
|
|
FormDef formDef=formDefVo.getFormDef(); |
|
|
FormDef formDef=formDefVo.getFormDef(); |
|
|
if(ObjectTools.isEmpty(formDef.getPks())){ |
|
|
if(ObjectTools.isEmpty(formDef.getPks())){ |
|
|
return ""; |
|
|
return ""; |
|
|
} |
|
|
} |
|
|
String[] pkIds1=formDef.getPks().split(":"); |
|
|
|
|
|
String ctimeFormat=""; |
|
|
|
|
|
if(pkIds1.length>1){ |
|
|
|
|
|
ctimeFormat=pkIds1[1]; |
|
|
|
|
|
} |
|
|
|
|
|
String[] pkIds=pkIds1[0].split(","); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String[] pkIds=formDef.getPks().split(","); |
|
|
List<String> extInfosPkIds= Arrays.stream(pkIds).filter(k->k.indexOf(".")>=0).collect(Collectors.toList()); |
|
|
List<String> extInfosPkIds= Arrays.stream(pkIds).filter(k->k.indexOf(".")>=0).collect(Collectors.toList()); |
|
|
Map<String,Object> extInfos=new HashMap<>(); |
|
|
|
|
|
|
|
|
JSONArray extInfos=new JSONArray(); |
|
|
if(extInfosPkIds.size()>0){ |
|
|
if(extInfosPkIds.size()>0){ |
|
|
extInfos= JSONObject.parseObject(formData.getExtInfos()); |
|
|
|
|
|
|
|
|
extInfos= JSON.parseArray(formData.getExtInfos()); |
|
|
} |
|
|
} |
|
|
List<String> bizKeys=new ArrayList<>(); |
|
|
List<String> bizKeys=new ArrayList<>(); |
|
|
Map<String,Object> formDataMap=null; |
|
|
Map<String,Object> formDataMap=null; |
|
|
for (String pkId : pkIds) { |
|
|
for (String pkId : pkIds) { |
|
|
if(pkId.indexOf(".")<0){ |
|
|
if(pkId.indexOf(".")<0){ |
|
|
if(pkId.equals("ctime")){ |
|
|
|
|
|
String formate=transNum2String(ctimeFormat); |
|
|
|
|
|
|
|
|
if(pkId.startsWith("ctime:")){ |
|
|
|
|
|
String formate=transNum2String(pkId.split(":")[1]); |
|
|
String ctime=DateUtils.format(formData.getCtime(),formate); |
|
|
String ctime=DateUtils.format(formData.getCtime(),formate); |
|
|
bizKeys.add(ctime); |
|
|
bizKeys.add(ctime); |
|
|
}else if("cuserid".equals(pkId)){ |
|
|
}else if("cuserid".equals(pkId)){ |
|
|
@ -120,11 +117,11 @@ public class FormDataService extends BaseService<FormDataMapper,FormData> { |
|
|
}else{ |
|
|
}else{ |
|
|
String pkIdTrim=pkId.replaceAll("\\w*[.]",""); |
|
|
String pkIdTrim=pkId.replaceAll("\\w*[.]",""); |
|
|
|
|
|
|
|
|
String v= (String) extInfos.get(pkIdTrim); |
|
|
|
|
|
if(ObjectTools.isEmpty(v)){ |
|
|
|
|
|
|
|
|
Optional<Object> options=extInfos.stream().filter(e->((JSONObject)e).getString("id").equals(pkIdTrim)).findAny(); |
|
|
|
|
|
if(!options.isPresent()){ |
|
|
throw new BizException(LangTips.errMsg("pk-field-required","%s不能为空",pkId)); |
|
|
throw new BizException(LangTips.errMsg("pk-field-required","%s不能为空",pkId)); |
|
|
} |
|
|
} |
|
|
bizKeys.add(v); |
|
|
|
|
|
|
|
|
bizKeys.add(((JSONObject)(options.get())).getString("value")); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return bizKeys.stream().collect(Collectors.joining(",")); |
|
|
return bizKeys.stream().collect(Collectors.joining(",")); |
|
|
|