伊利项目-设计器页面版本差异查看
This commit is contained in:
parent
2261f14fe9
commit
ba084184b5
Binary file not shown.
@ -3297,4 +3297,16 @@ public class CoEPALController {
|
||||
return web.checkFilePermissionBatch(uuids,isSub).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设计器页面右侧版本差异窗口接口
|
||||
* @param me
|
||||
* @param id 当前资产库文件ID
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal_repository_model_version_diff_query")
|
||||
public String getRepositoryModelVersionDiff(UserContext me,String id){
|
||||
CoeProcessLevelWeb web = new CoeProcessLevelWeb(me);
|
||||
return web.getRepositoryModelVersionDiff(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,6 +6,8 @@ import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.cooperation.cache.CooperationCache;
|
||||
import com.actionsoft.apps.coe.pal.log.CoEOpLogAPI;
|
||||
import com.actionsoft.apps.coe.pal.log.CoEOpLogConst;
|
||||
import com.actionsoft.apps.coe.pal.output.pr.util.ReportRepositoryCompare;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.util.OutputWordUtil;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.util.DiagramsUtil;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.util.ShapeUtils;
|
||||
import com.actionsoft.apps.coe.pal.pal.ws.constant.CoeWsConstant;
|
||||
@ -104,6 +106,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.*;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
@ -9944,4 +9947,661 @@ public class CoeProcessLevelWeb extends ActionWeb {
|
||||
}
|
||||
return ResponseObject.newOkResponse();
|
||||
}
|
||||
|
||||
public String getRepositoryModelVersionDiff(String repositoryId){
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
JSONArray result = new JSONArray();
|
||||
if (UtilString.isEmpty(repositoryId)) {
|
||||
ro = ResponseObject.newErrResponse("参数异常");
|
||||
return ro.toString();
|
||||
}
|
||||
List<PALRepositoryModel> versions = PALRepositoryQueryAPIManager.getInstance().queryPalRepositoryModelsByPalId(repositoryId);
|
||||
if (versions == null) {
|
||||
ro = ResponseObject.newErrResponse("查询文件失败[ruuid=" + repositoryId + "]");
|
||||
return ro.toString();
|
||||
}
|
||||
// 版本排序
|
||||
Collections.sort(versions, new Comparator<PALRepositoryModel>() {
|
||||
@Override
|
||||
public int compare(PALRepositoryModel o1, PALRepositoryModel o2) {
|
||||
return VersionUtil.compareVersionNo(o1.getVersion(),o2.getVersion(),true);
|
||||
}
|
||||
});
|
||||
if (versions.size() == 1) {
|
||||
JSONObject object = new JSONObject();
|
||||
Timestamp date = versions.get(0).getModifyDate();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(UtilDate.yearFormat(date)).append("年").append(UtilDate.monthFormat(date)).append("月").append(UtilDate.dayFormat(date)).append("日").append(" ").append(UtilDate.timeFormat(date));
|
||||
object.put("versionName", VersionUtil.getVersionStrV(versions.get(0).getVersion()));
|
||||
object.put("updateUser", SDK.getORGAPI().getUser(versions.get(0).getModifyUser()) == null ? "" : SDK.getORGAPI().getUser(versions.get(0).getModifyUser()).getUserName());
|
||||
object.put("updateTime", sb.toString());
|
||||
JSONArray updateContent = new JSONArray();
|
||||
JSONObject content = new JSONObject();
|
||||
content.put("title","");
|
||||
content.put("detail",new JSONArray());
|
||||
content.getJSONArray("detail").add("起始版本");
|
||||
updateContent.add(content);
|
||||
object.put("updateContent",updateContent);
|
||||
result.add(object);
|
||||
ro.setData(result);
|
||||
return ro.toString();
|
||||
}
|
||||
for (int i = 0; i < versions.size() - 1; i++) {
|
||||
JSONObject object = new JSONObject();
|
||||
PALRepositoryModel currModel = versions.get(i);
|
||||
PALRepositoryModel prevModel = versions.get(i+1);
|
||||
// 主信息
|
||||
Timestamp date = currModel.getModifyDate();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(UtilDate.yearFormat(date)).append("年").append(UtilDate.monthFormat(date)).append("月").append(UtilDate.dayFormat(date)).append("日").append(" ").append(UtilDate.timeFormat(date));
|
||||
object.put("versionName", VersionUtil.getVersionStrV(currModel.getVersion()));
|
||||
object.put("updateUser", SDK.getORGAPI().getUser(currModel.getModifyUser()) == null ? "" : SDK.getORGAPI().getUser(currModel.getModifyUser()).getUserName());
|
||||
object.put("updateTime", sb.toString());
|
||||
JSONArray updateContent = new JSONArray();
|
||||
// 对比文件属性(扩展+附件)
|
||||
List<String> repositorylList = compareRepositoryProperty(currModel, prevModel);
|
||||
if (repositorylList.size() > 0) {
|
||||
JSONObject property = new JSONObject();
|
||||
property.put("title","文件修改");
|
||||
property.put("detail",repositorylList);
|
||||
updateContent.add(property);
|
||||
}
|
||||
// 对比节点(节点增删修改属性附件等)
|
||||
List<String> shapeList = compareRepositoryShape(currModel, prevModel);
|
||||
if (shapeList.size() > 0) {
|
||||
JSONObject shape = new JSONObject();
|
||||
shape.put("title","节点修改");
|
||||
shape.put("detail",shapeList);
|
||||
updateContent.add(shape);
|
||||
}
|
||||
object.put("updateContent",updateContent);
|
||||
result.add(object);
|
||||
}
|
||||
// 起始版本
|
||||
JSONObject object = new JSONObject();
|
||||
PALRepositoryModel model = versions.get(versions.size() - 1);
|
||||
Timestamp date = model.getModifyDate();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(UtilDate.yearFormat(date)).append("年").append(UtilDate.monthFormat(date)).append("月").append(UtilDate.dayFormat(date)).append("日").append(" ").append(UtilDate.timeFormat(date));
|
||||
object.put("versionName", VersionUtil.getVersionStrV(model.getVersion()));
|
||||
object.put("updateUser", SDK.getORGAPI().getUser(model.getModifyUser()) == null ? "" : SDK.getORGAPI().getUser(model.getModifyUser()).getUserName());
|
||||
object.put("updateTime", sb.toString());
|
||||
JSONArray updateContent = new JSONArray();
|
||||
JSONObject content = new JSONObject();
|
||||
content.put("title","");
|
||||
content.put("detail",new JSONArray());
|
||||
content.getJSONArray("detail").add("起始版本");
|
||||
updateContent.add(content);
|
||||
object.put("updateContent",updateContent);
|
||||
result.add(object);
|
||||
ro.setData(result);
|
||||
return ro.toString();
|
||||
}
|
||||
/**
|
||||
* 对比节点数据
|
||||
* @param currModel
|
||||
* @param prevModel
|
||||
*/
|
||||
private List<String> compareRepositoryShape(PALRepositoryModel currModel, PALRepositoryModel prevModel) {
|
||||
// 获取文件
|
||||
String prevDefinition = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(null, prevModel.getId());
|
||||
|
||||
List<JSONObject> prevList = ShapeUtil.getShapeJsonToJsonObject(prevDefinition);
|
||||
String currDefinition = currDefinition = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(null, currModel.getId());
|
||||
List<JSONObject> currList = ShapeUtil.getShapeJsonToJsonObject(currDefinition);
|
||||
|
||||
Map<String, JSONObject> prevMap = new HashMap<>();
|
||||
Map<String, JSONObject> currMap = new HashMap<>();
|
||||
for (JSONObject obj : prevList) {
|
||||
String id = obj.getString("id");
|
||||
prevMap.put(id, obj);
|
||||
}
|
||||
for (JSONObject obj : currList) {
|
||||
String id = obj.getString("id");
|
||||
currMap.put(id, obj);
|
||||
}
|
||||
Set<String> sameSet = new HashSet<>();// 记录前一版本与当前版本都存在的节点
|
||||
// 查找较上一版本新增节点
|
||||
Set<String> addSet = new HashSet<>();// 记录新增节点
|
||||
Set<String> currSet = currMap.keySet();
|
||||
for (String str : currSet) {
|
||||
if (!prevMap.containsKey(str)) {
|
||||
addSet.add(str);
|
||||
} else {
|
||||
sameSet.add(str);
|
||||
}
|
||||
}
|
||||
// 查找较上一版本删除节点
|
||||
Set<String> deleteSet = new HashSet<>();// 记录删除节点
|
||||
Set<String> prevSet = prevMap.keySet();
|
||||
for (String str : prevSet) {
|
||||
if (!currMap.containsKey(str)) {
|
||||
deleteSet.add(str);
|
||||
}
|
||||
}
|
||||
List<String> result = new LinkedList<>();
|
||||
List<String> addList = new ArrayList<String>();
|
||||
for (String shapeId : addSet) {
|
||||
JSONObject object = currMap.get(shapeId);
|
||||
String text = assembleShapeName(object.getString("text"));
|
||||
addList.add(text);
|
||||
}
|
||||
if (addList.size() > 0) {
|
||||
Collections.sort(addList);
|
||||
result.add("增加节点 " + StringUtils.join(addList, ","));
|
||||
}
|
||||
List<String> deleteList = new ArrayList<>();
|
||||
for (String shapeId : deleteSet) {
|
||||
JSONObject object = prevMap.get(shapeId);
|
||||
String text = assembleShapeName(object.getString("text"));
|
||||
deleteList.add(text);
|
||||
}
|
||||
if (deleteList.size() > 0) {
|
||||
Collections.sort(deleteList);
|
||||
result.add("删除节点 " + StringUtils.join(deleteList, ","));
|
||||
}
|
||||
|
||||
for (String id : sameSet) {
|
||||
JSONObject currShape = currMap.get(id);
|
||||
JSONObject prevShape = prevMap.get(id);
|
||||
// 对比名称
|
||||
String currText = currShape.getString("text");
|
||||
String prevText = prevShape.getString("text");
|
||||
String curr = currText == null ? "" : currText.replace("\n", "").replace(" ", "");
|
||||
String prev = prevText == null ? "" : prevText.replace("\n", "").replace(" ", "");
|
||||
if (!curr.equals(prev)) {
|
||||
result.add(assembleShapeName(prev) + "名称修改为" + assembleShapeName(curr));
|
||||
}
|
||||
// 对比类型
|
||||
String currName = currShape.getString("name");
|
||||
String prevName = prevShape.getString("name");
|
||||
String currTitle = currShape.getString("title");
|
||||
String prevTitle = prevShape.getString("title");
|
||||
String nameCompareResult = compareIdContent(currName, prevName);
|
||||
// 节点类型有变化,不再比对具体属性值内容
|
||||
boolean compareAttrContent = true;
|
||||
if (nameCompareResult != null) {
|
||||
|
||||
result.add(assembleShapeName(curr) + "节点类型" + transferCommonStr(nameCompareResult, currTitle, prevTitle, null));
|
||||
compareAttrContent = false;
|
||||
}
|
||||
// 对比节点描述
|
||||
JSONObject currAttributes = currShape.containsKey("dataAttributes") ? currShape.getJSONObject("dataAttributes") : new JSONObject();
|
||||
JSONObject prevAttributes = prevShape.containsKey("dataAttributes") ? prevShape.getJSONObject("dataAttributes") : new JSONObject();
|
||||
|
||||
if (compareAttrContent) {// 两个版本相同的节点类型相同时对比
|
||||
// 节点属性对比
|
||||
String shapeName = currShape.getString("name");
|
||||
List<PALRepositoryShapeAttributeModel> shapeAttributeModels = PALRepositoryShapeAttributeCache.getAttributeListByShapeName(currModel.getWsId(), currModel.getMethodId(), shapeName);
|
||||
JSONArray currAttributesJsonArray = currAttributes.containsKey("attributesJsonArray") ? currAttributes.getJSONArray("attributesJsonArray") : new JSONArray();
|
||||
JSONArray prevAttributesJsonArray = prevAttributes.containsKey("attributesJsonArray") ? prevAttributes.getJSONArray("attributesJsonArray") : new JSONArray();
|
||||
for (PALRepositoryShapeAttributeModel shapeAttrModel : shapeAttributeModels) {
|
||||
if (!UtilString.isEmpty(shapeAttrModel.getType())) {
|
||||
String compareResult = compareShapeAttribute(shapeAttrModel, currModel, prevModel, id, currAttributesJsonArray, prevAttributesJsonArray);
|
||||
if (compareResult != null) {
|
||||
result.add(assembleShapeName(curr) + assemblePropertyName(shapeAttrModel.getAttrName()) + compareResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 对比节点附件
|
||||
String compareResult = compareRepositoryUpfileFile(currModel, prevModel, id);
|
||||
if (compareResult != null) {
|
||||
result.add(assembleShapeName(curr) + assemblePropertyName("附件") + compareResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 节点属性对比
|
||||
* @param model
|
||||
* @param currModel
|
||||
* @param prevModel
|
||||
* @param shapeId
|
||||
* @param currAttributesJsonArray
|
||||
* @param prevAttributesJsonArray
|
||||
* @return
|
||||
*/
|
||||
private String compareShapeAttribute(PALRepositoryShapeAttributeModel model, PALRepositoryModel currModel, PALRepositoryModel prevModel, String shapeId, JSONArray currAttributesJsonArray, JSONArray prevAttributesJsonArray) {
|
||||
// 获取两个value
|
||||
String attrId = model.getAttrId();
|
||||
if (model.getType().equalsIgnoreCase("relation")) {// 对比PAL关联属性
|
||||
List<DesignerShapeRelationModel> currRelationModels = DesignerShapeRelationCache.getListByAttrId(currModel.getId(), shapeId, attrId);
|
||||
List<DesignerShapeRelationModel> prevRelationModels = DesignerShapeRelationCache.getListByAttrId(prevModel.getId(), shapeId, attrId);
|
||||
return compareRelationShapeContent(currRelationModels, prevRelationModels);
|
||||
} else if (model.getType().equalsIgnoreCase("awsorg")) {// 对比关联平台的关联属性
|
||||
List<DesignerShapeRelationModel> currRelationModels = DesignerShapeRelationCache.getListByAttrId(currModel.getId(), shapeId, attrId);
|
||||
List<DesignerShapeRelationModel> prevRelationModels = DesignerShapeRelationCache.getListByAttrId(prevModel.getId(), shapeId, attrId);
|
||||
return compareRelationOrgShapeContent(currRelationModels, prevRelationModels);
|
||||
} else {// string/textarea/boolean/select/select_m等
|
||||
String currValue = "";
|
||||
String prevValue = "";
|
||||
for (Object object : currAttributesJsonArray) {
|
||||
JSONObject obj = (JSONObject)object;
|
||||
if (obj != null && obj.containsKey("key") && attrId.equals(obj.getString("key"))) {
|
||||
currValue = obj.containsKey("value") ? obj.getString("value") : "";
|
||||
}
|
||||
}
|
||||
for (Object object : prevAttributesJsonArray) {
|
||||
JSONObject obj = (JSONObject)object;
|
||||
if (obj != null && obj.containsKey("key") && attrId.equals(obj.getString("key"))) {
|
||||
prevValue = obj.containsKey("value") ? obj.getString("value") : "";
|
||||
}
|
||||
}
|
||||
if (model.getType().equals("select_m")) {// select_m多选
|
||||
if (currValue.equals(prevValue)) {
|
||||
return null;
|
||||
} else if ("".equals(currValue) && !"".equals(prevValue)) {
|
||||
// delete
|
||||
List<String> prevList = new ArrayList<>();
|
||||
CollectionUtils.addAll(prevList, prevValue.split(","));
|
||||
Collections.sort(prevList);
|
||||
return transferCommonStr("delete", null, StringUtils.join(prevList, ","));
|
||||
} else if (!"".equals(currValue) && "".equals(prevValue)) {
|
||||
// add
|
||||
List<String> currList = new ArrayList<>();
|
||||
CollectionUtils.addAll(currList, currValue.split(","));
|
||||
return transferCommonStr("add", StringUtils.join(currList, ","), null);
|
||||
} else {
|
||||
List<String> currList = new ArrayList<>();
|
||||
CollectionUtils.addAll(currList, currValue.split(","));
|
||||
List<String> prevList = new ArrayList<>();
|
||||
CollectionUtils.addAll(prevList, prevValue.split(","));
|
||||
if (currList.size() == prevList.size()) {
|
||||
boolean isSame = true;
|
||||
for (String prev : prevList) {
|
||||
if (!currList.contains(prev)) {
|
||||
isSame = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isSame) {
|
||||
// update
|
||||
return transferCommonStr("update", StringUtils.join(currList, ","), StringUtils.join(prevList, ","));
|
||||
}
|
||||
} else {
|
||||
// update
|
||||
return transferCommonStr("update", StringUtils.join(currList, ","), StringUtils.join(prevList, ","));
|
||||
}
|
||||
}
|
||||
} else {// other
|
||||
return compareTextContent(currValue, prevValue);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 对比文件属性
|
||||
* @param currModel
|
||||
* @param prevModel
|
||||
*/
|
||||
private List<String> compareRepositoryProperty(PALRepositoryModel currModel, PALRepositoryModel prevModel) {
|
||||
List<String> result = new LinkedList<>();
|
||||
// 对比文件扩展属性
|
||||
List<PALRepositoryAttributeModel> extendList = PALRepositoryAttributeCache.getAttributeByMethodId(currModel.getWsId(), currModel.getMethodId());
|
||||
/*
|
||||
* 对比文本/多行文本,下拉框/多选下拉框,关联属性
|
||||
*/
|
||||
if (extendList != null && extendList.size() > 0) {
|
||||
for (PALRepositoryAttributeModel model : extendList) {
|
||||
if ("0".equals(model.getIsDelete())) {
|
||||
if (model.getType().equalsIgnoreCase("string") || model.getType().equalsIgnoreCase("textarea")) {// 对比文本/多行文本,下拉框/多选下拉框
|
||||
// 获取属性内容
|
||||
PALRepositoryPropertyModel currPropertyModel = PALRepositoryPropertyCache.getPropertyByPropertyId(currModel.getId(), model.getAttrId());
|
||||
PALRepositoryPropertyModel prevPropertyModel = PALRepositoryPropertyCache.getPropertyByPropertyId(prevModel.getId(), model.getAttrId());
|
||||
String compareResult = compareTextContent(currPropertyModel.getPropertyValue(), prevPropertyModel.getPropertyValue());
|
||||
if (compareResult != null) {
|
||||
result.add(assemblePropertyName(model.getAttrName()) + compareResult);
|
||||
}
|
||||
} else if (model.getType().equalsIgnoreCase("relation")) {// 对比PAL关联属性
|
||||
List<DesignerShapeRelationModel> currRelationModels = DesignerShapeRelationCache.getListByAttrId(currModel.getId(), "", model.getAttrId());
|
||||
List<DesignerShapeRelationModel> prevRelationModels = DesignerShapeRelationCache.getListByAttrId(prevModel.getId(), "", model.getAttrId());
|
||||
String compareResult = compareRelationShapeContent(currRelationModels, prevRelationModels);
|
||||
if (compareResult != null) {
|
||||
result.add(assemblePropertyName(model.getAttrName()) + compareResult);
|
||||
}
|
||||
} else if (model.getType().equalsIgnoreCase("awsorg")) {// 对比关联平台的关联属性
|
||||
List<DesignerShapeRelationModel> currRelationModels = DesignerShapeRelationCache.getListByAttrId(currModel.getId(), "", model.getAttrId());
|
||||
List<DesignerShapeRelationModel> prevRelationModels = DesignerShapeRelationCache.getListByAttrId(prevModel.getId(), "", model.getAttrId());
|
||||
String compareResult = compareRelationOrgShapeContent(currRelationModels, prevRelationModels);
|
||||
if (compareResult != null) {
|
||||
result.add(assemblePropertyName(model.getAttrName()) + compareResult);
|
||||
}
|
||||
} else {// 其余类型按照string类型进行对比
|
||||
// 获取属性内容
|
||||
PALRepositoryPropertyModel currPropertyModel = PALRepositoryPropertyCache.getPropertyByPropertyId(currModel.getId(), model.getAttrId());
|
||||
PALRepositoryPropertyModel prevPropertyModel = PALRepositoryPropertyCache.getPropertyByPropertyId(prevModel.getId(), model.getAttrId());
|
||||
String compareResult = compareTextContent(currPropertyModel.getPropertyValue(), prevPropertyModel.getPropertyValue());
|
||||
if (compareResult != null) {
|
||||
result.add(assemblePropertyName(model.getAttrName()) + compareResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 对比文件附件
|
||||
String compareResult = compareRepositoryUpfileFile(currModel, prevModel);
|
||||
if (compareResult != null) {
|
||||
result.add(assemblePropertyName("附件") + compareResult);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// 对比节点附件
|
||||
private String compareRepositoryUpfileFile(PALRepositoryModel currModel, PALRepositoryModel prevModel, String currShapeId) {
|
||||
// 获取文件属性
|
||||
String currSql = " AND " + UpfileModel.FIELD_PL_UUID + "='" + currModel.getId() + "' AND " + UpfileModel.FIELD_SHAPE_UUID + "='" + currShapeId + "' AND " + UpfileModel.FIELD_TYPE + "='s'";
|
||||
String prevSql = " AND " + UpfileModel.FIELD_PL_UUID + "='" + prevModel.getId() + "' AND " + UpfileModel.FIELD_SHAPE_UUID + "='" + currShapeId + "' AND " + UpfileModel.FIELD_TYPE + "='s'";
|
||||
UpFileDao dao = new UpFileDao();
|
||||
List<UpfileModel> currList = dao.search(currSql);
|
||||
List<UpfileModel> prevList = dao.search(prevSql);
|
||||
return compareUpfileModels(currList, prevList);
|
||||
}
|
||||
// 对比文件附件
|
||||
private String compareRepositoryUpfileFile(PALRepositoryModel currModel, PALRepositoryModel prevModel) {
|
||||
// 获取文件属性
|
||||
String currSql = " AND " + UpfileModel.FIELD_PL_UUID + "='" + currModel.getId() + "' AND " + UpfileModel.FIELD_TYPE + "='f'";
|
||||
String prevSql = " AND " + UpfileModel.FIELD_PL_UUID + "='" + prevModel.getId() + "' AND " + UpfileModel.FIELD_TYPE + "='f'";
|
||||
UpFileDao dao = new UpFileDao();
|
||||
List<UpfileModel> currList = dao.search(currSql);
|
||||
List<UpfileModel> prevList = dao.search(prevSql);
|
||||
return compareUpfileModels(currList, prevList);
|
||||
}
|
||||
private String compareUpfileModels(List<UpfileModel> currList, List<UpfileModel> prevList) {
|
||||
if ((currList == null || currList.size() == 0) && (prevList == null || prevList.size() == 0)) {
|
||||
return null;
|
||||
} else if ((currList == null || currList.size() == 0) && prevList.size() > 0) {// 删除了
|
||||
return transferCommonStr("delete", null, getUpfileModelsText(prevList), null);
|
||||
} else if ((prevList == null || prevList.size() == 0) && currList.size() > 0) {// 增加了
|
||||
return transferCommonStr("add", getUpfileModelsText(currList), null, null);
|
||||
} else {
|
||||
List<String> currNames = new ArrayList<>();
|
||||
List<String> prevNames = new ArrayList<>();
|
||||
for (UpfileModel model : currList) {
|
||||
currNames.add(model.getFileName());
|
||||
}
|
||||
for (UpfileModel model : prevList) {
|
||||
prevNames.add(model.getFileName());
|
||||
}
|
||||
if (currNames.size() == prevNames.size()) {
|
||||
for (String prev : prevNames) {
|
||||
if (!currNames.contains(prev)) {
|
||||
return transferCommonStr("update", getUpfileModelsText(currList), getUpfileModelsText(prevList), null);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return transferCommonStr("update", getUpfileModelsText(currList), getUpfileModelsText(prevList), null);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
private String getUpfileModelsText(List<UpfileModel> list) {
|
||||
if (list == null || list.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
List<String> result = new ArrayList<>();
|
||||
for (UpfileModel model : list) {
|
||||
result.add(model.getFileName());
|
||||
}
|
||||
Collections.sort(result);
|
||||
return StringUtils.join(result, ",");
|
||||
}
|
||||
/**
|
||||
* 对比关联属性(关联到AWS平台的角色岗位部门员工)
|
||||
* @param currRelationModels
|
||||
* @param prevRelationModels
|
||||
* @return
|
||||
*/
|
||||
private String compareRelationOrgShapeContent(List<DesignerShapeRelationModel> currRelationModels, List<DesignerShapeRelationModel> prevRelationModels) {
|
||||
String commonStr = "00000000-0000-0000-0000-000000000000";
|
||||
if ((currRelationModels == null || currRelationModels.size() == 0) && (prevRelationModels == null || prevRelationModels.size() == 0)) {
|
||||
return null;
|
||||
} else if ((currRelationModels == null || currRelationModels.size() == 0) && prevRelationModels.size() > 0) {// 删除了
|
||||
return transferCommonStr("delete", null, getRelationOrgModelsText(prevRelationModels, commonStr));
|
||||
} else if ((prevRelationModels == null || prevRelationModels.size() == 0) && currRelationModels.size() > 0) {// 增加了
|
||||
return transferCommonStr("add", getRelationOrgModelsText(currRelationModels, commonStr), null);
|
||||
} else {
|
||||
Set<String> currSets = new HashSet<>();
|
||||
Set<String> prevSets = new HashSet<>();
|
||||
for (DesignerShapeRelationModel model : currRelationModels) {
|
||||
if (commonStr.equals(model.getRelationFileId()) && commonStr.equals(model.getRelationShapeId())) {
|
||||
JSONObject object = JSONObject.parseObject(model.getRelationShapeText());
|
||||
currSets.add(object.getString("id"));
|
||||
}
|
||||
}
|
||||
for (DesignerShapeRelationModel model : prevRelationModels) {
|
||||
if (commonStr.equals(model.getRelationFileId()) && commonStr.equals(model.getRelationShapeId())) {
|
||||
JSONObject object = JSONObject.parseObject(model.getRelationShapeText());
|
||||
prevSets.add(object.getString("id"));
|
||||
}
|
||||
}
|
||||
if (currSets.size() == prevSets.size()) {
|
||||
for (String prev : prevSets) {
|
||||
if (!currSets.contains(prev)) {
|
||||
return transferCommonStr("update", getRelationOrgModelsText(currRelationModels, commonStr), getRelationOrgModelsText(prevRelationModels, commonStr));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return transferCommonStr("update", getRelationOrgModelsText(currRelationModels, commonStr), getRelationOrgModelsText(prevRelationModels, commonStr));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关联到AWS平台的角色部门员工
|
||||
* @param list
|
||||
* @param commonStr
|
||||
* @return
|
||||
*/
|
||||
private String getRelationOrgModelsText(List<DesignerShapeRelationModel> list, String commonStr) {
|
||||
if (list == null || list.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
List<JSONObject> resultList = new ArrayList<>();
|
||||
Set<String> filter = new HashSet<String>();
|
||||
for (DesignerShapeRelationModel model : list) {
|
||||
if (commonStr.equals(model.getRelationFileId()) && commonStr.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())) {
|
||||
flag = true;
|
||||
object.put("name", dept.getName());
|
||||
filter.add(dept.getId());
|
||||
}
|
||||
}
|
||||
if ("user".equals(object.getString("type"))) {
|
||||
UserModel user = SDK.getORGAPI().getUser(object.getString("id"));
|
||||
if (user != null && !filter.contains(user.getUID())) {
|
||||
flag = true;
|
||||
object.put("name", user.getUserName());
|
||||
filter.add(user.getUID());
|
||||
}
|
||||
}
|
||||
if ("role".equals(object.getString("type"))) {
|
||||
RoleModel roleModel = SDK.getORGAPI().getRoleById(object.getString("id"));
|
||||
if (roleModel != null && !filter.contains(roleModel.getId())) {
|
||||
flag = true;
|
||||
object.put("name", roleModel.getName());
|
||||
filter.add(roleModel.getId());
|
||||
}
|
||||
}
|
||||
if ("position".equals(object.getString("type"))) {// 岗位
|
||||
RoleModel roleModel = SDK.getORGAPI().getRoleById(object.getString("id"));
|
||||
if (roleModel != null && !filter.contains(roleModel.getId())) {
|
||||
flag = true;
|
||||
object.put("name", roleModel.getName());
|
||||
filter.add(roleModel.getId());
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
resultList.add(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<String> result = new ArrayList<>();
|
||||
if (resultList.size() > 0) {
|
||||
// 排序
|
||||
Collections.sort(resultList, new Comparator<JSONObject>() {
|
||||
@Override
|
||||
public int compare(JSONObject o1, JSONObject o2) {
|
||||
if (o1.getString("type").equals(o2.getString("type"))) {
|
||||
return (o1.containsKey("name") ? o1.getString("name") : "").compareTo(o2.containsKey("name") ? o2.getString("name") : "");
|
||||
} else {
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("department", 1);
|
||||
object.put("user", 2);
|
||||
object.put("role", 3);
|
||||
object.put("position", 4);
|
||||
return object.getIntValue(o1.getString("type")) - object.getIntValue(o2.getString("type"));
|
||||
}
|
||||
}
|
||||
});
|
||||
for (JSONObject object : resultList) {
|
||||
result.add(object.getString("name"));
|
||||
}
|
||||
}
|
||||
return StringUtils.join(result, ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* 对比关联属性
|
||||
* @param currRelationModels
|
||||
* @param prevRelationModels
|
||||
*/
|
||||
private String compareRelationShapeContent(List<DesignerShapeRelationModel> currRelationModels, List<DesignerShapeRelationModel> prevRelationModels) {
|
||||
if ((currRelationModels == null || currRelationModels.size() == 0) && (prevRelationModels == null || prevRelationModels.size() == 0)) {
|
||||
return null;
|
||||
} else if ((currRelationModels == null || currRelationModels.size() == 0) && prevRelationModels.size() > 0) {// 删除了
|
||||
return transferCommonStr("delete", null, getRelationModelsText(prevRelationModels));
|
||||
} else if ((prevRelationModels == null || prevRelationModels.size() == 0) && currRelationModels.size() > 0) {// 增加了
|
||||
return transferCommonStr("add", getRelationModelsText(currRelationModels), null);
|
||||
} else {
|
||||
Set<String> currSets = new HashSet<>();
|
||||
Set<String> prevSets = new HashSet<>();
|
||||
for (DesignerShapeRelationModel model : currRelationModels) {
|
||||
currSets.add(model.getRelationFileId() + "_" + model.getRelationShapeId());
|
||||
}
|
||||
for (DesignerShapeRelationModel model : prevRelationModels) {
|
||||
prevSets.add(model.getRelationFileId() + "_" + model.getRelationShapeId());
|
||||
}
|
||||
if (currSets.size() == prevSets.size()) {
|
||||
for (String prev : prevSets) {
|
||||
if (!currSets.contains(prev)) {
|
||||
return transferCommonStr("update", getRelationModelsText(currRelationModels), getRelationModelsText(prevRelationModels));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return transferCommonStr("update", getRelationModelsText(currRelationModels), getRelationModelsText(prevRelationModels));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getRelationModelsText(List<DesignerShapeRelationModel> list) {
|
||||
if (list == null || list.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
Set<String> set = new HashSet<>();
|
||||
List<String> result = new ArrayList<>();
|
||||
for (DesignerShapeRelationModel model : list) {
|
||||
if (set.contains(model.getRelationFileId() + "_" + model.getRelationShapeId())) {
|
||||
continue;
|
||||
}
|
||||
set.add(model.getRelationFileId() + "_" + model.getRelationShapeId());
|
||||
if (UtilString.isEmpty(model.getRelationShapeId())) {
|
||||
String versionId = model.getRelationFileId();
|
||||
List<PALRepositoryModel> list2 = PALRepositoryCache.getByVersionId(versionId);
|
||||
for (PALRepositoryModel pModel : list2) {
|
||||
if (pModel.isUse()) {
|
||||
result.add(pModel.getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result.add(model.getRelationShapeText());
|
||||
}
|
||||
}
|
||||
Collections.sort(result);
|
||||
return StringUtils.join(result, ",");
|
||||
}
|
||||
|
||||
private String compareTextContent(String currStr, String prevStr) {
|
||||
String curr = currStr == null ? "" : currStr.replace("\n", "").replace(" ", "");
|
||||
String prev = prevStr == null ? "" : prevStr.replace("\n", "").replace(" ", "");
|
||||
if (curr.equals(prev)) {
|
||||
return null;
|
||||
}
|
||||
if ("".equals(prev) && !"".equals(curr)) {// 由空变为非空
|
||||
// 增加了内容xxx
|
||||
return transferCommonStr("add", curr, prev);
|
||||
} else if ("".equals(curr) && !"".equals(prev)) {// 由非空变为空
|
||||
// 删除了内容
|
||||
return transferCommonStr("delete", curr, prev);
|
||||
} else {// 由prev变为curr
|
||||
return transferCommonStr("update", curr, prev);
|
||||
}
|
||||
}
|
||||
|
||||
private String compareIdContent(String currStr, String prevStr) {
|
||||
String curr = currStr == null ? "" : currStr.replace("\n", "").replace(" ", "");
|
||||
String prev = prevStr == null ? "" : prevStr.replace("\n", "").replace(" ", "");
|
||||
if (curr.equals(prev)) {
|
||||
return null;
|
||||
}
|
||||
if ("".equals(prev) && !"".equals(curr)) {// 由空变为非空
|
||||
// 增加了内容xxx
|
||||
return "add";
|
||||
} else if ("".equals(curr) && !"".equals(prev)) {// 由非空变为空
|
||||
// 删除了内容
|
||||
return "delete";
|
||||
} else {// 由prev变为curr
|
||||
return "update";
|
||||
}
|
||||
}
|
||||
|
||||
private String transferCommonStr(String type, String curr, String prev) {
|
||||
return transferCommonStr(type, curr, prev, "内容");
|
||||
}
|
||||
|
||||
private String transferCommonStr(String type, String curr, String prev, String keyword) {
|
||||
String prefix = " ", suffix = " ";
|
||||
keyword = keyword == null ? "" : keyword;
|
||||
if ("add".equals(type)) {
|
||||
return "增加了" + keyword + prefix + specialCharTransfer(curr);
|
||||
} else if ("delete".equals(type)) {
|
||||
return "删除了" + keyword + prefix + specialCharTransfer(prev);
|
||||
} else if ("update".equals(type)) {
|
||||
return keyword + "由" + prefix + specialCharTransfer(prev) + suffix + "修改为" + prefix + specialCharTransfer(curr);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String specialCharTransfer(String str) {
|
||||
return OutputWordUtil.specialCharTransfer(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼接属性名称
|
||||
* @param propertyName
|
||||
* @return
|
||||
*/
|
||||
private String assemblePropertyName(String propertyName) {
|
||||
return "[" + propertyName + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼接节点名称
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
private String assembleShapeName(String text) {
|
||||
return "【" + text + "】";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1727,4 +1727,7 @@
|
||||
<param name="desc"/>
|
||||
<param name="methodId"/>
|
||||
</cmd-bean>
|
||||
<cmd-bean name="com.actionsoft.apps.coe.pal_repository_model_version_diff_query">
|
||||
<param name="id"/>
|
||||
</cmd-bean>
|
||||
</aws-actions>
|
||||
@ -3045,78 +3045,51 @@ var Dock = {
|
||||
else if(this.currentView == 'diff') {
|
||||
// var html = "<div style=\"font-size: 16px; color: #aaa; text-align: center; vertical-align: middle; line-height: 200px;\">暂无版本差异</div>";
|
||||
var html = ''
|
||||
var diffContent = [
|
||||
{
|
||||
versionName: 'Ver 2.0',
|
||||
updateTime: '5月19日 16:00',
|
||||
updateContent: [
|
||||
{
|
||||
title: '文件修改:',
|
||||
detail: ['[内容]增加了111111111111111111','[责任部门]增加了11111111111111111']
|
||||
},
|
||||
{
|
||||
title: '节点修改:',
|
||||
detail: ['删除[开始事件]节点','删除[开始]节点','删除[人工]节点']
|
||||
},
|
||||
{
|
||||
title: '[文件]删除11111111111',
|
||||
detail: []
|
||||
$.ajax({
|
||||
url: "./jd?sid=" + $("#sid").val()
|
||||
+ "&cmd=com.actionsoft.apps.coe.pal_repository_model_version_diff_query&wsId=" + $("#wsId").val()
|
||||
+ "&id=" + ruuid,
|
||||
success: function (ro) {
|
||||
// console.log("历史差异结果: " + JSON.stringify(ro))
|
||||
if (ro.result == "ok") {
|
||||
var diffContent = ro.data;
|
||||
for (var i = 0; i < diffContent.length; i++) {
|
||||
var diffCount = 0
|
||||
var content = diffContent[i].updateContent
|
||||
var diffListHtml = ''
|
||||
for (var j = 0; j < content.length; j++) {
|
||||
var diffDetailHtml = ''
|
||||
var listDetail = content[j].detail
|
||||
if (listDetail.length == 0) {
|
||||
diffCount += 1
|
||||
}
|
||||
for (var k = 0; k < listDetail.length; k++) {
|
||||
diffCount += 1
|
||||
diffDetailHtml += '<div style="margin-left: 10px">' + '·' + listDetail[k] + '</div>'
|
||||
}
|
||||
diffListHtml += '<div>' + content[j].title + '</div>'
|
||||
+ '<div>' + diffDetailHtml + '</div>'
|
||||
|
||||
}
|
||||
html += '<tr>'
|
||||
+ '<td style="width:50px;">' + diffContent[i].versionName + '</td>'
|
||||
+ '<td style="width:250px">' + diffContent[i].updateTime + '<span style="padding-left: 10px">' + '(' + diffCount + '处修改)' + '</span>' + '</td>'
|
||||
+ '</tr>'
|
||||
+ '<tr>'
|
||||
+ '<td style="width:50px"></td>'
|
||||
+ '<td style="width:250px">' + diffListHtml + '</td>'
|
||||
+ '</tr>'
|
||||
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
versionName: 'Ver 1.0',
|
||||
updateTime: '5月14日 15:00',
|
||||
updateContent: [
|
||||
{
|
||||
title: '文件修改',
|
||||
detail: ['[内容]增加了111111111111 ',]
|
||||
},
|
||||
{
|
||||
title: '节点修改',
|
||||
detail: ['删除[开始事件]节点','删除[开始]节点','删除[人工]节点','删除[结束]节点']
|
||||
},
|
||||
{
|
||||
title: '[制度]增加了11111111111111',
|
||||
detail: []
|
||||
},
|
||||
{
|
||||
title: '[文件]删除了11111111111',
|
||||
detail: []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
for (var i = 0; i < diffContent.length; i++) {
|
||||
var diffCount = 0
|
||||
var content = diffContent[i].updateContent
|
||||
var diffListHtml = ''
|
||||
for (var j = 0; j < content.length; j++) {
|
||||
var diffDetailHtml = ''
|
||||
var listDetail = content[j].detail
|
||||
if (listDetail.length == 0) {
|
||||
diffCount +=1
|
||||
$("#diffTable").empty().html(html)
|
||||
} else {
|
||||
html = '<tr>'
|
||||
+ ro.msg
|
||||
+ '</tr>'
|
||||
$("#diffTable").empty().html(html)
|
||||
}
|
||||
for (var k = 0; k < listDetail.length; k++) {
|
||||
diffCount +=1
|
||||
diffDetailHtml += '<div style="margin-left: 10px">' + '·' +listDetail[k]+'</div>'
|
||||
}
|
||||
diffListHtml += '<div>' + content[j].title +'</div>'
|
||||
+ '<div>'+diffDetailHtml+'</div>'
|
||||
|
||||
}
|
||||
html += '<tr>'
|
||||
+ '<td style="width:50px;">' + diffContent[i].versionName + '</td>'
|
||||
+ '<td style="width:250px">' + diffContent[i].updateTime + '<span style="padding-left: 10px">' + '(' + diffCount + '处修改)' + '</span>' + '</td>'
|
||||
+ '</tr>'
|
||||
+ '<tr>'
|
||||
+ '<td style="width:50px"></td>'
|
||||
+ '<td style="width:250px">' + diffListHtml + '</td>'
|
||||
+ '</tr>'
|
||||
|
||||
}
|
||||
$("#diffTable").empty().html(html)
|
||||
|
||||
});
|
||||
}
|
||||
if (this.currentView == "history") {
|
||||
if (drawNav && Dock.historyVersions == null) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user