diff --git a/com.actionsoft.apps.kms/src/com/actionsoft/apps/kms/service/SearchService.java b/com.actionsoft.apps.kms/src/com/actionsoft/apps/kms/service/SearchService.java index dd3335f7..3513eebf 100644 --- a/com.actionsoft.apps.kms/src/com/actionsoft/apps/kms/service/SearchService.java +++ b/com.actionsoft.apps.kms/src/com/actionsoft/apps/kms/service/SearchService.java @@ -4,13 +4,19 @@ import java.sql.Timestamp; import java.text.Collator; import java.util.*; +import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel; +import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryAPIManager; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryPropertyCache; import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory; import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.cache.DesignerShapeRelationCache; import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel; import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryPropertyModel; import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.org.model.RoleModel; import com.actionsoft.bpms.util.DBSql; -import com.awspaas.user.apps.yili.reportform.util.RepositoryAttribute; import org.apache.commons.lang.StringUtils; import com.actionsoft.apps.kms.KMSConstant; @@ -114,7 +120,7 @@ public class SearchService { } // 同步发布部门到APP_ACT_COE_PAL_REPOSITORY try { - Map queryRepositoryAttributeById = new RepositoryAttribute().queryRepositoryAttributeById(id); + Map queryRepositoryAttributeById = queryRepositoryAttributeById(id); if (null != queryRepositoryAttributeById && !queryRepositoryAttributeById.isEmpty()) { // 发布部门 JSONObject Issuing_department = queryRepositoryAttributeById.get("Issuing_department"); @@ -1179,4 +1185,169 @@ public class SearchService { return false; } } + + /** + * 根据模型ID查询所有文件扩展属性 + * + * @param uuid + * @return + */ + public Map queryRepositoryAttributeById(String uuid) { + Map result = new HashMap<>(); + PALRepositoryModel plModel = PALRepositoryCache.getCache().get(uuid); + // 获取所有文件属性 + List methodAttrModels = PALRepositoryAPIManager.getInstance().getValidAndUseAttributeModels(plModel.getWsId(), plModel.getMethodId()); + if (methodAttrModels != null && methodAttrModels.size() > 0) { + Map attributeModelMap = new HashMap<>(); + Map sortAttrMap = new HashMap<>(); + if (methodAttrModels != null) { + int sort = 0; + for (PALMethodAttributeModel attr : methodAttrModels) { + attributeModelMap.put(attr.getKey(), attr); + sortAttrMap.put(attr.getKey(), ++sort); + } + } + List propertys = PALRepositoryPropertyCache.getPropertyByPlId(plModel.getId()); + // 排序 + // propertys.sort((p1, p2) -> (sortAttrMap.containsKey(p1.getPropertyId()) ? sortAttrMap.get(p1.getPropertyId()) : 0) - (sortAttrMap.containsKey(p2.getPropertyId()) ? sortAttrMap.get(p2.getPropertyId()) : 0)); + + for (PALRepositoryPropertyModel property : propertys) { + String id = property.getPropertyId(); + if (!attributeModelMap.containsKey(id) || !attributeModelMap.get(id).getUse()) { + continue; + } + PALMethodAttributeModel attributeModel = attributeModelMap.get(id); + // 记录结果集 + JSONObject attrObj = new JSONObject(); + attrObj.put("ref", attributeModel.getRef());// ref + attrObj.put("type", attributeModel.getType());// 类型 relation string ... + attrObj.put("attrId", attributeModel.getKey());// 属性key + attrObj.put("attrTitle", attributeModel.getNewTitle());// 属性标题 + attrObj.put("text", "");// 属性内容单行文本 + attrObj.put("value", new JSONArray());// 属性内容集,relation或awsorg类型时存储对应的json数据 + String inputValue = property.getPropertyValue(); + if ("relation".equals(attributeModel.getType())) { + List inputValueList = new ArrayList<>(); + List list = DesignerShapeRelationCache.getListByAttrId(plModel.getId(), "", attributeModel.getKey()); + if (list != null && list.size() > 0) { + // 判断是否有重复数据,进行重复过滤 + Set tempStrs = new HashSet<>(); + List 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; + 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 list2 = PALRepositoryCache.getByVersionId(plModel.getWsId(), model.getRelationFileId()); + for (PALRepositoryModel model2 : list2) { + if (model2.isUse()) { + inputValueList.add(model2.getName()); + JSONObject tmp = new JSONObject(); + tmp.put("fileId", model2.getId()); + tmp.put("name", model2.getName()); + tmp.put("isFile", true); + attrObj.getJSONArray("value").add(tmp); + break; + } + } + } else { + inputValueList.add(model.getRelationShapeText()); + JSONObject tmp = new JSONObject(); + tmp.put("fileId", model.getRelationFileId()); + tmp.put("shapeId", model.getRelationShapeId()); + tmp.put("name", model.getRelationShapeText()); + tmp.put("isFile", false); + attrObj.getJSONArray("value").add(tmp); + } + } + } + inputValue = org.apache.tools.ant.util.StringUtils.join(inputValueList, ","); + } + // 关联bpm组织架构 + if ("awsorg".equals(attributeModel.getType())) { + List list = DesignerShapeRelationCache.getListByAttrId(plModel.getId(), "", attributeModel.getKey()); + List deptValList = new ArrayList<>(); + List positionValList = new ArrayList<>(); + List roleValList = new ArrayList<>(); + List userValList = new ArrayList<>(); + if (list != null && list.size() > 0) { + Set filter = new HashSet();// 去重记录 + list.sort((m1, m2) -> { + return m1.getId().compareTo(m2.getId()); + }); + 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()); + boolean flag = false; + // 查询最新名称 + if ("department".equals(object.getString("type"))) { + DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); + if (dept != null && !filter.contains(dept.getId())) { + deptValList.add(dept.getName()); + filter.add(dept.getId()); + flag = true; + } + } + if ("position".equals(object.getString("type"))) {// 岗位,先用角色代替 + RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id")); + if (role != null && !filter.contains(role.getId())) { + positionValList.add(role.getName()); + filter.add(role.getId()); + flag = true; + } + } + if ("user".equals(object.getString("type"))) { + UserModel user = SDK.getORGAPI().getUser(object.getString("id")); + if (user != null && !filter.contains(user.getUID())) { + userValList.add(user.getUserName()); + filter.add(user.getUID()); + flag = true; + } + } + if ("role".equals(object.getString("type"))) { + RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id")); + if (role != null && !filter.contains(role.getId())) { + roleValList.add(role.getName()); + filter.add(role.getId()); + flag = true; + } + } + if (flag) { + attrObj.getJSONArray("value").add(object); + } + } + } + } + // 数据组合 + deptValList.addAll(positionValList); + deptValList.addAll(roleValList); + deptValList.addAll(userValList); + inputValue = org.apache.tools.ant.util.StringUtils.join(deptValList, ","); + + } + if (UtilString.isNotEmpty(inputValue)){ + inputValue = inputValue.replaceAll("'", "'"); + inputValue = inputValue.replaceAll("\"", """); + attrObj.put("text", inputValue); + result.put(attributeModel.getKey(), attrObj); + }else { + attrObj.put("text", inputValue); + result.put(attributeModel.getKey(), attrObj); + } + } + } + return result; + } } diff --git a/com.actionsoft.apps.kms/src/com/actionsoft/apps/kms/web/KnwlSearchWeb.java b/com.actionsoft.apps.kms/src/com/actionsoft/apps/kms/web/KnwlSearchWeb.java index 95a1577d..cbbba11c 100644 --- a/com.actionsoft.apps.kms/src/com/actionsoft/apps/kms/web/KnwlSearchWeb.java +++ b/com.actionsoft.apps.kms/src/com/actionsoft/apps/kms/web/KnwlSearchWeb.java @@ -8,20 +8,20 @@ import java.nio.charset.StandardCharsets; import java.sql.Date; import java.sql.Timestamp; import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - +import java.util.*; +import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel; import com.actionsoft.apps.coe.pal.pal.output.OutputAPIManager; import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask; import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager; import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile; import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel; +import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryAPIManager; import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryPropertyCache; +import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.cache.DesignerShapeRelationCache; +import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel; import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryPropertyModel; import com.actionsoft.apps.kms.KMSConstant; import com.actionsoft.apps.kms.KMSUtil; import com.actionsoft.apps.kms.ac.XpageMgrACCM; @@ -48,6 +48,7 @@ import com.actionsoft.bpms.commons.security.ac.cache.AccessControlCache; import com.actionsoft.bpms.commons.security.ac.model.AccessControlModel; import com.actionsoft.bpms.org.cache.UserCache; import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.org.model.RoleModel; import com.actionsoft.bpms.org.model.UserModel; import com.actionsoft.bpms.server.UserContext; import com.actionsoft.bpms.server.fs.DCContext; @@ -59,7 +60,7 @@ import com.actionsoft.sdk.local.SDK; import com.actionsoft.sdk.local.api.AppAPI; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.awspaas.user.apps.yili.reportform.util.RepositoryAttribute; +import org.apache.tools.ant.util.StringUtils; /** * 检索(全文检索、属性检索) @@ -364,7 +365,7 @@ public class KnwlSearchWeb extends ActionWeb { String departName = ""; try { System.out.println("查询到的uuid是什么>>>>>>>>>>>>>"+id); - Map queryRepositoryAttributeById = new RepositoryAttribute().queryRepositoryAttributeById(id); + Map queryRepositoryAttributeById = queryRepositoryAttributeById(id); if (null != queryRepositoryAttributeById && !queryRepositoryAttributeById.isEmpty()) { // 发布部门 JSONObject Issuing_department = queryRepositoryAttributeById.get("Issuing_department"); @@ -1439,4 +1440,171 @@ public class KnwlSearchWeb extends ActionWeb { ro.put("data", data); return ro.toString(); } + + + /** + * 根据模型ID查询所有文件扩展属性 + * + * @param uuid + * @return + */ + public Map queryRepositoryAttributeById(String uuid) { + Map result = new HashMap<>(); + PALRepositoryModel plModel = PALRepositoryCache.getCache().get(uuid); + // 获取所有文件属性 + List methodAttrModels = PALRepositoryAPIManager.getInstance().getValidAndUseAttributeModels(plModel.getWsId(), plModel.getMethodId()); + if (methodAttrModels != null && methodAttrModels.size() > 0) { + Map attributeModelMap = new HashMap<>(); + Map sortAttrMap = new HashMap<>(); + if (methodAttrModels != null) { + int sort = 0; + for (PALMethodAttributeModel attr : methodAttrModels) { + attributeModelMap.put(attr.getKey(), attr); + sortAttrMap.put(attr.getKey(), ++sort); + } + } + List propertys = PALRepositoryPropertyCache.getPropertyByPlId(plModel.getId()); + // 排序 + // propertys.sort((p1, p2) -> (sortAttrMap.containsKey(p1.getPropertyId()) ? sortAttrMap.get(p1.getPropertyId()) : 0) - (sortAttrMap.containsKey(p2.getPropertyId()) ? sortAttrMap.get(p2.getPropertyId()) : 0)); + + for (PALRepositoryPropertyModel property : propertys) { + String id = property.getPropertyId(); + if (!attributeModelMap.containsKey(id) || !attributeModelMap.get(id).getUse()) { + continue; + } + PALMethodAttributeModel attributeModel = attributeModelMap.get(id); + // 记录结果集 + JSONObject attrObj = new JSONObject(); + attrObj.put("ref", attributeModel.getRef());// ref + attrObj.put("type", attributeModel.getType());// 类型 relation string ... + attrObj.put("attrId", attributeModel.getKey());// 属性key + attrObj.put("attrTitle", attributeModel.getNewTitle());// 属性标题 + attrObj.put("text", "");// 属性内容单行文本 + attrObj.put("value", new JSONArray());// 属性内容集,relation或awsorg类型时存储对应的json数据 + String inputValue = property.getPropertyValue(); + if ("relation".equals(attributeModel.getType())) { + List inputValueList = new ArrayList<>(); + List list = DesignerShapeRelationCache.getListByAttrId(plModel.getId(), "", attributeModel.getKey()); + if (list != null && list.size() > 0) { + // 判断是否有重复数据,进行重复过滤 + Set tempStrs = new HashSet<>(); + List 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; + 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 list2 = PALRepositoryCache.getByVersionId(plModel.getWsId(), model.getRelationFileId()); + for (PALRepositoryModel model2 : list2) { + if (model2.isUse()) { + inputValueList.add(model2.getName()); + JSONObject tmp = new JSONObject(); + tmp.put("fileId", model2.getId()); + tmp.put("name", model2.getName()); + tmp.put("isFile", true); + attrObj.getJSONArray("value").add(tmp); + break; + } + } + } else { + inputValueList.add(model.getRelationShapeText()); + JSONObject tmp = new JSONObject(); + tmp.put("fileId", model.getRelationFileId()); + tmp.put("shapeId", model.getRelationShapeId()); + tmp.put("name", model.getRelationShapeText()); + tmp.put("isFile", false); + attrObj.getJSONArray("value").add(tmp); + } + } + } + inputValue = StringUtils.join(inputValueList, ","); + } + // 关联bpm组织架构 + if ("awsorg".equals(attributeModel.getType())) { + List list = DesignerShapeRelationCache.getListByAttrId(plModel.getId(), "", attributeModel.getKey()); + List deptValList = new ArrayList<>(); + List positionValList = new ArrayList<>(); + List roleValList = new ArrayList<>(); + List userValList = new ArrayList<>(); + if (list != null && list.size() > 0) { + Set filter = new HashSet();// 去重记录 + list.sort((m1, m2) -> { + return m1.getId().compareTo(m2.getId()); + }); + 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()); + boolean flag = false; + // 查询最新名称 + if ("department".equals(object.getString("type"))) { + DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); + if (dept != null && !filter.contains(dept.getId())) { + deptValList.add(dept.getName()); + filter.add(dept.getId()); + flag = true; + } + } + if ("position".equals(object.getString("type"))) {// 岗位,先用角色代替 + RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id")); + if (role != null && !filter.contains(role.getId())) { + positionValList.add(role.getName()); + filter.add(role.getId()); + flag = true; + } + } + if ("user".equals(object.getString("type"))) { + UserModel user = SDK.getORGAPI().getUser(object.getString("id")); + if (user != null && !filter.contains(user.getUID())) { + userValList.add(user.getUserName()); + filter.add(user.getUID()); + flag = true; + } + } + if ("role".equals(object.getString("type"))) { + RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id")); + if (role != null && !filter.contains(role.getId())) { + roleValList.add(role.getName()); + filter.add(role.getId()); + flag = true; + } + } + if (flag) { + attrObj.getJSONArray("value").add(object); + } + } + } + } + // 数据组合 + deptValList.addAll(positionValList); + deptValList.addAll(roleValList); + deptValList.addAll(userValList); + inputValue = StringUtils.join(deptValList, ","); + + } + if (UtilString.isNotEmpty(inputValue)){ + inputValue = inputValue.replaceAll("'", "'"); + inputValue = inputValue.replaceAll("\"", """); + attrObj.put("text", inputValue); + result.put(attributeModel.getKey(), attrObj); + }else { + attrObj.put("text", inputValue); + result.put(attributeModel.getKey(), attrObj); + } + } + } + return result; + } + }