优化质量校验代码
This commit is contained in:
parent
cb34360976
commit
798b56d6bf
@ -8363,8 +8363,8 @@ public class CoeProcessLevelWeb extends ActionWeb {
|
||||
*/
|
||||
public String defineQualityCheck(String sid,String uuid,String obj){
|
||||
|
||||
|
||||
/************************************文件属性校验************************************/
|
||||
PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid);
|
||||
/************************************文件属性校验************************************/
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
PALRepositoryModel m = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid);
|
||||
// 获取所有文件属性
|
||||
@ -8383,7 +8383,7 @@ public class CoeProcessLevelWeb extends ActionWeb {
|
||||
List<PALRepositoryPropertyModel> propertys = dao.getPropertysByPlid(uuid, null);
|
||||
|
||||
|
||||
Boolean flag1=false;
|
||||
Boolean flag1=true;
|
||||
Boolean flag2=false;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuffer sb1=new StringBuffer();
|
||||
@ -8394,167 +8394,84 @@ public class CoeProcessLevelWeb extends ActionWeb {
|
||||
continue;
|
||||
}
|
||||
PALMethodAttributeModel attributeModel = attributeModelMap.get(id);
|
||||
|
||||
if (!attributeModel.getIsRequired()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean flag = true;// 通过
|
||||
String inputValue = property.getPropertyValue();
|
||||
if ("relation".equals(attributeModel.getType())) {
|
||||
if ("relation".equals(attributeModel.getType()) || "awsorg".equals(attributeModel.getType())) {
|
||||
List<DesignerShapeRelationModel> list = DesignerShapeRelationCache.getListByAttrId(uuid, "", attributeModel.getKey());
|
||||
if (list != null && list.size() > 0) {
|
||||
// 判断是否有重复数据,进行重复过滤
|
||||
Set<String> tempStrs = new HashSet<>();
|
||||
List<DesignerShapeRelationModel> tempList = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
DesignerShapeRelationModel model = list.get(i);
|
||||
String str = model.getFileId() + model.getShapeId() + model.getAttrId() + model.getRelationFileId() + model.getRelationShapeId();
|
||||
if (!tempStrs.contains(str)) {
|
||||
tempList.add(model);
|
||||
tempStrs.add(str);
|
||||
}
|
||||
}
|
||||
list = tempList;
|
||||
List<String> inputValueList = new ArrayList<>();
|
||||
List<String> fileIdList = new ArrayList<>();
|
||||
List<String> shapeIdList = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
DesignerShapeRelationModel model = list.get(i);
|
||||
JSONObject refObj = JSONObject.parseObject(attributeModel.getRef());
|
||||
String relationTyp = refObj.containsKey("type") ? refObj.getString("type") : "shape";
|
||||
if ("file".equals(relationTyp)) {// 关联的模型文件
|
||||
if (model.getRelationFileId().length() < 36) {
|
||||
continue;
|
||||
}
|
||||
List<PALRepositoryModel> list2 = PALRepositoryCache.getByVersionId(m.getWsId(), model.getRelationFileId());
|
||||
for (PALRepositoryModel model2 : list2) {
|
||||
if (model2.isUse()) {
|
||||
inputValueList.add(model2.getName());
|
||||
fileIdList.add(model2.getId());// 再次存储时会转换为versionId
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
inputValueList.add(model.getRelationShapeText());
|
||||
fileIdList.add(model.getRelationFileId());
|
||||
shapeIdList.add(model.getRelationShapeId());
|
||||
}
|
||||
}
|
||||
inputValue = StringUtils.join(inputValueList, ",");
|
||||
|
||||
} else {//db中无关联数据
|
||||
inputValue = "";
|
||||
if (list == null || list.isEmpty()) {
|
||||
flag = false;
|
||||
}
|
||||
} else {
|
||||
flag = UtilString.isNotEmpty(property.getPropertyValue()) ? true : false;
|
||||
}
|
||||
// 关联bpm组织架构
|
||||
JSONArray dataArr = new JSONArray();
|
||||
if ("awsorg".equals(attributeModel.getType())) {
|
||||
List<DesignerShapeRelationModel> list = DesignerShapeRelationCache.getListByAttrId(uuid, "", attributeModel.getKey());
|
||||
if (list != null && list.size() > 0) {
|
||||
Set<String> filter = new HashSet<String>();// 去重记录
|
||||
for (DesignerShapeRelationModel model : list) {
|
||||
if ("00000000-0000-0000-0000-000000000000".equals(model.getRelationFileId()) && "00000000-0000-0000-0000-000000000000".equals(model.getRelationShapeId())) {
|
||||
JSONObject object = JSONObject.parseObject(model.getRelationShapeText());
|
||||
// 查询最新名称
|
||||
if ("department".equals(object.getString("type"))) {
|
||||
DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id"));
|
||||
if (dept != null && !filter.contains(dept.getId())) {
|
||||
object.put("name", dept.getName());
|
||||
filter.add(dept.getId());
|
||||
dataArr.add(object);
|
||||
}
|
||||
}
|
||||
if ("position".equals(object.getString("type"))) {// 岗位,先用角色代替
|
||||
RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id"));
|
||||
if (role != null && !filter.contains(role.getId())) {
|
||||
object.put("name", role.getName());
|
||||
filter.add(role.getId());
|
||||
dataArr.add(object);
|
||||
}
|
||||
}
|
||||
if ("user".equals(object.getString("type"))) {
|
||||
UserModel user = SDK.getORGAPI().getUser(object.getString("id"));
|
||||
if (user != null && !filter.contains(user.getUID())) {
|
||||
object.put("name", user.getUserName());
|
||||
filter.add(user.getUID());
|
||||
dataArr.add(object);
|
||||
}
|
||||
}
|
||||
if ("role".equals(object.getString("type"))) {
|
||||
RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id"));
|
||||
if (role != null && !filter.contains(role.getId())) {
|
||||
object.put("name", role.getName());
|
||||
filter.add(role.getId());
|
||||
dataArr.add(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 数据组合
|
||||
List<String> valueList = new ArrayList<>();
|
||||
for (int i = 0; i < dataArr.size(); i++) {
|
||||
valueList.add(dataArr.getJSONObject(i).getString("name"));
|
||||
}
|
||||
inputValue = StringUtils.join(valueList, ",");
|
||||
if (!flag) {// 校验不通过
|
||||
sb.append("''"+attributeModel.getTitle()+"''").append(",");
|
||||
flag1 = false;
|
||||
}
|
||||
|
||||
inputValue = inputValue.replaceAll("'", "'");
|
||||
inputValue = inputValue.replaceAll("\"", """);
|
||||
boolean isRequired = attributeModel.getIsRequired();
|
||||
|
||||
if (isRequired) {
|
||||
if(UtilString.isEmpty(inputValue)){
|
||||
sb.append("''"+attributeModel.getTitle()+"''").append(",");
|
||||
flag1=true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
StringBuffer sb2=new StringBuffer();
|
||||
/***************************************************数据属性校验*************************************************/
|
||||
JSONObject elementJsonobject=JSONObject.parseObject(obj).getJSONObject("elements");
|
||||
|
||||
Iterator<String> sIterator = elementJsonobject.keySet().iterator();
|
||||
//循环并得到key列表
|
||||
while (sIterator.hasNext()) {
|
||||
// 获得key
|
||||
String key = sIterator.next();
|
||||
//获得key值对应的value
|
||||
String value = elementJsonobject.getString(key);
|
||||
JSONObject jsonvalue = JSON.parseObject(value);
|
||||
String id = jsonvalue.getString("id");
|
||||
|
||||
JSONArray jo=JSONObject.parseObject(obj).getJSONObject("elements").getJSONObject(id).getJSONArray("dataAttributes");
|
||||
|
||||
for(int j=0;j<jo.size();j++){
|
||||
JSONArray attributesJsonArray=jo.getJSONObject(j).getJSONArray("attributesJsonArray");
|
||||
if(attributesJsonArray!=null){
|
||||
for(int k=0;k<attributesJsonArray.size();k++){
|
||||
String isRequired=attributesJsonArray.getJSONObject(k).getString("isRequired");
|
||||
if(UtilString.isNotEmpty(isRequired)){
|
||||
if(Boolean.parseBoolean(isRequired)==true){
|
||||
String inputvalue = attributesJsonArray.getJSONObject(k).getString("value");
|
||||
if(UtilString.isEmpty(inputvalue)){
|
||||
sb.append("''"+attributesJsonArray.getJSONObject(k).getString("name")+"''").append(",");
|
||||
flag2=true;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, PALMethodAttributeModel> methodAttributeModelMap = new HashMap<>();
|
||||
// 校验形状
|
||||
List<JSONObject> elements = ShapeUtil.getShapeJsonToJsonObject(obj);
|
||||
List<JSONObject> resultList = new ArrayList<>();
|
||||
for (JSONObject o : elements) {
|
||||
String shapeId = o.getString("id");
|
||||
String shapeName = o.getString("name");
|
||||
String text = UtilString.isEmpty(o.getString("text")) ? o.getString("title") : o.getString("text");
|
||||
String shapeCategory = o.getString("category");
|
||||
JSONObject dataAttributes = o.getJSONObject("dataAttributes");
|
||||
JSONArray attributesJsonArray = dataAttributes.getJSONArray("attributesJsonArray");
|
||||
for (int i = 0; i < attributesJsonArray.size(); i++) {
|
||||
JSONObject attr = attributesJsonArray.getJSONObject(i);
|
||||
String attrId = attr.getString("id");
|
||||
String value = attr.getString("value");
|
||||
if (!methodAttributeModelMap.containsKey(shapeName + "-" + attrId)) {
|
||||
List<PALMethodAttributeModel> methodAttributeModels = CoeDesignerShapeAPIManager.getInstance().getValidAndUseAttributeModels(model.getWsId(), shapeCategory.replace("_", "."), shapeName, model.getMethodId());
|
||||
for (PALMethodAttributeModel attributeModel : methodAttributeModels) {
|
||||
if (!methodAttributeModelMap.containsKey(shapeName + "-" + attributeModel.getKey())) {
|
||||
methodAttributeModelMap.put(shapeName + "-" + attributeModel.getKey(), attributeModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!methodAttributeModelMap.containsKey(shapeName + "-" + attrId)) {
|
||||
continue;// 没有配置到形状的属性,不处理
|
||||
}
|
||||
PALMethodAttributeModel attrModel = methodAttributeModelMap.get(shapeName + "-" + attrId);
|
||||
if (attrModel.getIsRequired()) {// 筛选必填
|
||||
String attrType = attrModel.getType();
|
||||
boolean flag = true;
|
||||
if ("relation".equals(attrType) || "awsorg".equals(attrType)) {
|
||||
List<DesignerShapeRelationModel> list = DesignerShapeRelationCache.getListByAttrId(model.getId(), shapeId, attrId);
|
||||
if (list == null || list.isEmpty()) {
|
||||
flag = false;
|
||||
}
|
||||
} else {
|
||||
flag = UtilString.isNotEmpty(value);
|
||||
}
|
||||
if (!flag) {
|
||||
sb.append("''"+shapeName+"''").append(",");
|
||||
flag2=false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if(flag1==true || flag2==true){
|
||||
|
||||
if(flag1==false || flag2==false){
|
||||
sb1.append(sb.substring(0, sb.length()-1));
|
||||
sb1.append("未填写,请检查!");
|
||||
}
|
||||
|
||||
int index=sb1.indexOf("未填写");
|
||||
if(index==-1 ){
|
||||
ro.put("result","ok");
|
||||
ro.put("result","ok");
|
||||
}else{
|
||||
ro.put("result","error");
|
||||
}
|
||||
@ -8562,7 +8479,7 @@ public class CoeProcessLevelWeb extends ActionWeb {
|
||||
ro.put("sb",sb1);
|
||||
return ro.toString();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -78,7 +78,6 @@ $(function() {
|
||||
});
|
||||
}
|
||||
function initSaveFun() {
|
||||
debugger;
|
||||
Dock.showView('');
|
||||
var obj = Model.define;
|
||||
var tempMessageArr = {};
|
||||
@ -100,7 +99,6 @@ $(function() {
|
||||
define: awsui.encode(obj),
|
||||
},
|
||||
success: function (msg, textStatus, jqXHR) {
|
||||
debugger;
|
||||
if(msg.result == "ok") {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user