上传文件至 'CA和CR的Tab上加入文档预览按钮'
parent
a3ee879ba2
commit
2967d07a88
@ -0,0 +1,92 @@
|
||||
import com.matrixone.apps.domain.DomainObject;
|
||||
import com.matrixone.apps.domain.util.MqlUtil;
|
||||
import matrix.db.Context;
|
||||
import matrix.db.File;
|
||||
import matrix.db.FileItr;
|
||||
import matrix.db.FileList;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class AegApiTool_mxJPO {
|
||||
|
||||
private static final String basePath = "/kkFileView2/kkFileView-4.4.0";
|
||||
private static final String targetDir = basePath + "/file/demo/";
|
||||
private static final Logger LOGGER = Logger.getLogger(AegCADemote_mxJPO.class.getName());
|
||||
private static final String tempFilePath = "/kkFileView2/kkFileView-4.4.0/file/demo/";
|
||||
|
||||
public Map<String, String> downloadFile(Context context1, String[] args) throws Exception {
|
||||
String physicalId = args[0];
|
||||
String documentName = args[1];
|
||||
LOGGER.info("physicalId ==> " + physicalId);
|
||||
LOGGER.info("documentName ==> " + documentName);
|
||||
LOGGER.info("context.name ==> " + context1.getUser());
|
||||
|
||||
Context context=new Context("");
|
||||
context.setUser("admin_platform");
|
||||
context.setPassword("Aeg12345678");
|
||||
context.connect();
|
||||
|
||||
String getItemIdInfo = "temp query bus * * * where 'physicalId == " + physicalId + "' select id dump |";
|
||||
String itemIdInfo = MqlUtil.mqlCommand(context, getItemIdInfo);
|
||||
|
||||
String itemId = itemIdInfo.split("\\|")[3];
|
||||
DomainObject domainObject = DomainObject.newInstance(context, itemId);
|
||||
|
||||
String getFileFormat = "print bus " + itemId + " select format[].file.format dump |" ;
|
||||
String fileFormat = MqlUtil.mqlCommand(context, getFileFormat);
|
||||
String[] formatArray=fileFormat.split("\\|");
|
||||
|
||||
boolean isFlag = false;
|
||||
String displayName = "";
|
||||
|
||||
for(String format : formatArray)
|
||||
{
|
||||
FileList fileList = domainObject.getFiles(context, format);
|
||||
FileItr fileItr = new FileItr(fileList);
|
||||
|
||||
while (fileItr.next())
|
||||
{
|
||||
File file = fileItr.obj();
|
||||
String fileName = file.getName();
|
||||
|
||||
LOGGER.info("fileName ==> " + fileName);
|
||||
LOGGER.info("documentName ==> " + documentName);
|
||||
|
||||
// if(documentName.equals(fileName.substring(0, fileName.lastIndexOf('.')))) {
|
||||
// domainObject.checkoutFile(context, false, format, fileName, tempFilePath);
|
||||
// displayName = fileName;
|
||||
// isFlag = true;
|
||||
// }
|
||||
|
||||
Path path = Paths.get(targetDir);
|
||||
|
||||
if(!Files.exists(path)){
|
||||
Files.createDirectories(path);
|
||||
System.out.println("目录创建成功:" + targetDir);
|
||||
} else {
|
||||
System.out.println("目录已存在,跳过创建:" + targetDir);
|
||||
}
|
||||
|
||||
domainObject.checkoutFile(context, false, format, fileName, tempFilePath);
|
||||
displayName = fileName;
|
||||
isFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("displayName", displayName);
|
||||
|
||||
if(isFlag) {
|
||||
map.put("isFlag","true");
|
||||
return map;
|
||||
} else {
|
||||
map.put("isFlag","false");
|
||||
return map;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@ -0,0 +1,272 @@
|
||||
|
||||
import com.dassault_systemes.enovia.changeorder.factory.ChangeOrderFactory;
|
||||
import com.dassault_systemes.enovia.changeorder.interfaces.IChangeOrderServices;
|
||||
import com.dassault_systemes.enovia.changerequest.factory.ChangeRequestFactory;
|
||||
import com.dassault_systemes.enovia.changerequest.interfaces.IAffectedItem;
|
||||
import com.dassault_systemes.enovia.changerequest.interfaces.IChangeRequest;
|
||||
import com.dassault_systemes.enovia.changerequest.interfaces.IChangeRequestServices;
|
||||
import com.dassault_systemes.enovia.enterprisechangemgt.common.ChangeAction;
|
||||
import com.dassault_systemes.enovia.enterprisechangemgtapp.common.ChangeRequest;
|
||||
import com.dassault_systemes.platform.ven.jackson.databind.ObjectMapper;
|
||||
import com.matrixone.apps.cpd.json.JSONObject;
|
||||
import com.matrixone.apps.domain.DomainObject;
|
||||
import com.matrixone.apps.domain.util.FrameworkException;
|
||||
import com.matrixone.apps.domain.util.MapList;
|
||||
import com.matrixone.apps.domain.util.MqlUtil;
|
||||
import matrix.db.Context;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class CommonTools_mxJPO {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(CommonTools_mxJPO.class.getName());
|
||||
|
||||
public String getInfoByObjId(Context context, String[] args) {
|
||||
|
||||
String objId = args[0];
|
||||
String selectVal = args[1];
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
if(selectVal.contains("|")){
|
||||
String[] selectValInfo = selectVal.split("\\|");
|
||||
for (String value : selectValInfo){
|
||||
list.add(value);
|
||||
stringBuilder.append(value);
|
||||
stringBuilder.append(" ");
|
||||
}
|
||||
} else {
|
||||
list.add(selectVal);
|
||||
stringBuilder.append(selectVal);
|
||||
}
|
||||
|
||||
String queryInfo = "print bus " + objId + " select " + stringBuilder + " dump |";
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
||||
try {
|
||||
String selInfo = MqlUtil.mqlCommand(context, queryInfo);
|
||||
|
||||
if(selInfo.isEmpty()){
|
||||
return "fail";
|
||||
}
|
||||
|
||||
if(selInfo.contains("|")){
|
||||
String[] queryInfoSplit = selInfo.split("\\|");
|
||||
for (int i = 0; i < queryInfoSplit.length; i++) {
|
||||
jsonObject.put(list.get(i),queryInfoSplit[i]);
|
||||
}
|
||||
} else{
|
||||
jsonObject.put(list.get(0),selInfo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
public String getInfoByPhyId(Context context, String[] args){
|
||||
|
||||
String physicalId = args[0];
|
||||
String selectVal = args[1];
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
if(selectVal.contains("|")){
|
||||
String[] selectValInfo = selectVal.split("\\|");
|
||||
for (String value : selectValInfo){
|
||||
list.add(value);
|
||||
stringBuilder.append(value);
|
||||
stringBuilder.append(" ");
|
||||
}
|
||||
} else {
|
||||
list.add(selectVal);
|
||||
stringBuilder.append(selectVal);
|
||||
}
|
||||
|
||||
String queryInfo = "temp query bus * * * where 'physicalid==" + physicalId + "' select " + stringBuilder + " dump |";
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
||||
try {
|
||||
String selInfo = MqlUtil.mqlCommand(context, queryInfo);
|
||||
|
||||
if(selInfo.isEmpty()){
|
||||
return "fail";
|
||||
}
|
||||
|
||||
if(selInfo.contains("|")){
|
||||
String[] queryInfoSplit = selInfo.split("\\|");
|
||||
for (int i = 3; i < queryInfoSplit.length; i++) {
|
||||
jsonObject.put(list.get(i-3),queryInfoSplit[i]);
|
||||
}
|
||||
} else{
|
||||
jsonObject.put(list.get(0),selInfo);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
public String getInfoByObjIdAndVersion(Context context, String[] args){
|
||||
String name = args[0];
|
||||
String version = args[1];
|
||||
String selectList = args[2];
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
if(selectList.contains("|")){
|
||||
String[] selectValInfo = selectList.split("\\|");
|
||||
for (String value : selectValInfo){
|
||||
list.add(value);
|
||||
stringBuilder.append(value);
|
||||
stringBuilder.append(" ");
|
||||
}
|
||||
} else {
|
||||
list.add(selectList);
|
||||
stringBuilder.append(selectList);
|
||||
}
|
||||
|
||||
String queryInfo = "temp query bus * " + name + " " + version + " select " + stringBuilder + " dump |";
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
||||
try {
|
||||
String selInfo = MqlUtil.mqlCommand(context, queryInfo);
|
||||
|
||||
if(selInfo.isEmpty()){
|
||||
return "fail";
|
||||
}
|
||||
|
||||
if(selInfo.contains("|")){
|
||||
String[] queryInfoSplit = selInfo.split("\\|");
|
||||
for (int i = 3; i < queryInfoSplit.length; i++) {
|
||||
jsonObject.put(list.get(i-3),queryInfoSplit[i]);
|
||||
}
|
||||
} else{
|
||||
jsonObject.put(list.get(0),selInfo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
public String getProposedChangeInfoByName(Context context, String[] args) throws Exception {
|
||||
String Name = args[0];
|
||||
LOGGER.info("Name ==> " + Name);
|
||||
|
||||
String getObjId = "temp query bus * " + Name + " * select id dump |";
|
||||
LOGGER.info("getObjId ==> " + getObjId);
|
||||
String objId = MqlUtil.mqlCommand(context, getObjId);
|
||||
System.out.println(objId);
|
||||
|
||||
if(!objId.isEmpty()){
|
||||
ChangeAction changeAction = new ChangeAction(objId.split("\\|")[3]);
|
||||
MapList mapList = changeAction.getAffectedItems(context);
|
||||
MapList realizedChangesList = changeAction.getRealizedChanges(context);
|
||||
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
|
||||
response.put("proposedChanges", processItems(context, mapList));
|
||||
response.put("realizedChanges", processItems(context, realizedChangesList));
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
return mapper.writeValueAsString(response);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public List<Map> processItems(Context context, MapList items) throws FrameworkException {
|
||||
if(items.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Map> list = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
Map itemMap = (Map) items.get(i);
|
||||
|
||||
if(!"Document".equals((String) itemMap.get("type"))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String type = (String) itemMap.get("type");
|
||||
String name = (String) itemMap.get("name");
|
||||
String id = (String) itemMap.get("id");
|
||||
String current = (String) itemMap.get("current");
|
||||
|
||||
String getObjInfo = "print bus " + id + " select attribute[Title] physicalid dump |";
|
||||
String objInfo = MqlUtil.mqlCommand(context, getObjInfo);
|
||||
|
||||
String physicalId = objInfo.split("\\|")[1];
|
||||
String title = objInfo.split("\\|")[0];
|
||||
|
||||
map.put("title", title);
|
||||
map.put("physicalid", physicalId);
|
||||
map.put("name", name);
|
||||
map.put("current", current);
|
||||
map.put("type",type);
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public String getCRAffectInfo(Context context, String[] args) throws Exception {
|
||||
String itemName = args[0];
|
||||
System.out.println(123);
|
||||
System.out.println(itemName);
|
||||
|
||||
String getItemIdInfo = "temp query bus * " + itemName + " * select id dump |";
|
||||
String itemIdInfo = MqlUtil.mqlCommand(context, getItemIdInfo);
|
||||
|
||||
MapList mapList = new MapList();
|
||||
|
||||
if(!itemIdInfo.isEmpty()){
|
||||
DomainObject domChange = DomainObject.newInstance(context, itemIdInfo.split("\\|")[3]);
|
||||
IChangeRequestServices changeRequestFactory = ChangeRequestFactory.createChangeRequestFactory();
|
||||
IChangeRequest iChangeRequest = changeRequestFactory.retrieveChangeRequestFromDatabase(context, domChange);
|
||||
List<IAffectedItem> affectedItems = iChangeRequest.getAffectedItems(context);
|
||||
|
||||
for (int i = 0; i < affectedItems.size(); i++) {
|
||||
System.out.println(affectedItems.get(i).getPhysicalId());
|
||||
Map<String, String> itemMap = getCRAffectItemInfo(context, affectedItems.get(i).getPhysicalId());
|
||||
|
||||
if(itemMap.size() == 0){
|
||||
continue;
|
||||
}
|
||||
mapList.add(itemMap);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(mapList);
|
||||
return mapList.toString();
|
||||
}
|
||||
|
||||
public Map<String, String> getCRAffectItemInfo(Context context, String physicalId) throws FrameworkException {
|
||||
String getItemInfo = "temp query bus * * * where ' physicalid == " + physicalId + "' select attribute[Title] type name current dump |";
|
||||
System.out.println(getItemInfo);
|
||||
String itemInfo = MqlUtil.mqlCommand(context, getItemInfo);
|
||||
System.out.println(itemInfo);
|
||||
|
||||
Map<String, String> map = new HashMap();
|
||||
|
||||
System.out.println(itemInfo.split("\\|")[1]);
|
||||
|
||||
if(!itemInfo.isEmpty() && "Document".equals(itemInfo.split("\\|")[0])){
|
||||
String[] itemSplit = itemInfo.split("\\|");
|
||||
map.put("title", itemSplit[3]);
|
||||
map.put("physicalid", physicalId);
|
||||
map.put("type", itemSplit[0]);
|
||||
map.put("name", itemSplit[1]);
|
||||
map.put("current",itemSplit[6]);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue