模型转换应用阶段性提交

This commit is contained in:
qinoy 2022-09-30 10:57:19 +08:00
parent 42ed863012
commit afabcb990d
17 changed files with 553 additions and 33 deletions

View File

@ -0,0 +1,17 @@
CREATE TABLE APP_ACT_COE_PAL_MC_HISTORY_RECORD (
ID CHAR(36) NOT NULL,
WSID CHAR(36) NOT NULL,
SOURCEMETHOD VARCHAR(36) NOT NULL,
TARGETMETHOD VARCHAR(36) NOT NULL,
OPERATOR VARCHAR(36) NOT NULL,
OPERATORTIME DATETIME NOT NULL,
CONSTRAINT APP_ACT_COE_PAL_MODEL_CONVERT_HISTORY_RECORD_PK PRIMARY KEY (ID));
CREATE TABLE APP_ACT_COE_PAL_MC_HISTORY_RECORD_DETAIL (
ID CHAR(36) NOT NULL,
HISTORYRECORDID CHAR(36) NOT NULL,
REPOSITORYID CHAR(36) NOT NULL,
REPOSITORYNAME VARCHAR(255) NOT NULL,
CONSTRAINT APP_ACT_COE_PAL_MC_HISTORY_RECORD_DETAIL_PK PRIMARY KEY (ID),
CONSTRAINT APP_ACT_COE_PAL_MC_HISTORY_RECORD_DETAIL_FK FOREIGN KEY (HISTORYRECORDID) REFERENCES APP_ACT_COE_PAL_MC_HISTORY_RECORD(ID)
);

View File

@ -1,13 +1,24 @@
package com.actionsoft.apps.coe.pal.modelconvert;
import com.actionsoft.apps.coe.pal.modelconvert.web.ModelConvertWeb;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.server.bind.annotation.Controller;
import com.actionsoft.bpms.server.bind.annotation.Mapping;
@Controller
public class ModelConvertController {
@Mapping("com.actionsoft.apps.coe.pal.test_handle")
public String test(){
return "";
// 获取模型转换历史信息
@Mapping("com.actionsoft.apps.coe.pal.model_convert_history_record_list")
public String getHistoryRecordInfo(UserContext uc,String wsId, String teamId){
ModelConvertWeb modelConvertWeb = new ModelConvertWeb(uc);
return modelConvertWeb.getHistoryRecordInfo(wsId, teamId);
}
// 获取模型转换历史详细信息
@Mapping("com.actionsoft.apps.coe.pal.model_convert_history_record_detail_list")
public String getHistoryRecordDetailInfo(UserContext uc,String historyId){
ModelConvertWeb modelConvertWeb = new ModelConvertWeb(uc);
return modelConvertWeb.getHistoryRecordDetailInfo(historyId);
}
}

View File

@ -112,4 +112,15 @@ public class HistoryRecordDao extends DaoObject<HistoryRecord> {
DBSql.close(conn);
}
}
/**
* 根据流程资产的id查询数据
*
* @param wsId
* @return
*/
public List<HistoryRecord> getHistoryRecordListByWsId(String wsId) {
String sql = "select * from " + entityName() + " where " + HistoryRecord.FIELD_WSID + "=?";
return DBSql.query(sql, rowMapper(), wsId);
}
}

View File

@ -0,0 +1,108 @@
package com.actionsoft.apps.coe.pal.modelconvert.dao;
import com.actionsoft.apps.coe.pal.modelconvert.model.HistoryRecordDetail;
import com.actionsoft.bpms.commons.database.BatchPreparedStatementSetter;
import com.actionsoft.bpms.commons.database.RowMapper;
import com.actionsoft.bpms.commons.mvc.dao.DaoObject;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.bpms.util.UUIDGener;
import com.actionsoft.bpms.util.UtilString;
import com.actionsoft.exception.AWSDataAccessException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class HistoryRecordDetailDao extends DaoObject<HistoryRecordDetail> {
@Override
public int insert(HistoryRecordDetail historyRecordDetail) throws AWSDataAccessException {
Map<String, Object> paraMap = new HashMap<String, Object>();
if (UtilString.isEmpty(historyRecordDetail.getId())) {
historyRecordDetail.setId(UUIDGener.getUUID());
}
paraMap.put(HistoryRecordDetail.FIELD_UUID,historyRecordDetail.getId());
paraMap.put(HistoryRecordDetail.FIELD_HISTORY_RECORD_ID,historyRecordDetail.getHistoryRecordId());
paraMap.put(HistoryRecordDetail.FIELD_REPOSITORY_ID,historyRecordDetail.getRepositoryId());
paraMap.put(HistoryRecordDetail.FIELD_REPOSITORY_NAME,historyRecordDetail.getRepositoryName());
int result = DBSql.update(DBSql.getInsertStatement(entityName(), paraMap), paraMap);
return result;
}
@Override
public int update(HistoryRecordDetail historyRecordDetail) throws AWSDataAccessException {
return 0;
}
@Override
public String entityName() {
return HistoryRecordDetail.DATABASE_ENTITY;
}
@Override
public RowMapper<HistoryRecordDetail> rowMapper() {
return new RowMapper<HistoryRecordDetail>() {
@Override
public HistoryRecordDetail mapRow(ResultSet resultSet, int i) throws SQLException {
HistoryRecordDetail historyRecordDetail = new HistoryRecordDetail();
historyRecordDetail.setId(resultSet.getString(HistoryRecordDetail.FIELD_UUID));
historyRecordDetail.setHistoryRecordId(resultSet.getString(HistoryRecordDetail.FIELD_HISTORY_RECORD_ID));
historyRecordDetail.setRepositoryId(resultSet.getString(HistoryRecordDetail.FIELD_REPOSITORY_ID));
historyRecordDetail.setRepositoryName(resultSet.getString(HistoryRecordDetail.FIELD_REPOSITORY_NAME));
return historyRecordDetail;
}
};
}
/**
* 批量入库
* @param historyRecordDetailList
* @throws SQLException
*/
public void batchInsert(List<HistoryRecordDetail> historyRecordDetailList) throws SQLException {
Connection conn = DBSql.open();
conn.setAutoCommit(false);
String sql = "INSERT INTO " + entityName() + "(" + HistoryRecordDetail.FIELD_UUID + "," + HistoryRecordDetail.FIELD_HISTORY_RECORD_ID
+ "," + HistoryRecordDetail.FIELD_REPOSITORY_ID + "," + HistoryRecordDetail.FIELD_REPOSITORY_NAME + ") VALUES (?, ?, ?, ?)";
try {
int[] result = DBSql.batch(conn, sql, new BatchPreparedStatementSetter() {
@Override
public int getBatchSize() {
return historyRecordDetailList.size();
}
@Override
public void setValues(PreparedStatement preparedStatement, int i) throws SQLException {
HistoryRecordDetail historyRecordDetail = historyRecordDetailList.get(i);
preparedStatement.setString(1, historyRecordDetail.getId());
preparedStatement.setString(2, historyRecordDetail.getHistoryRecordId());
preparedStatement.setString(3, historyRecordDetail.getRepositoryId());
preparedStatement.setString(4, historyRecordDetail.getRepositoryName());
}
});
conn.commit();
} catch (AWSDataAccessException e) {
conn.rollback();
e.printStackTrace();
} catch (SQLException throwables) {
conn.rollback();
throwables.printStackTrace();
} finally {
DBSql.close(conn);
}
}
/**
* 根据流程资产的id查询数据
*
* @param wsId
* @return
*/
public List<HistoryRecordDetail> getHistoryRecordDetailListByWsId(String historyId) {
String sql = "select * from " + entityName() + " where " + HistoryRecordDetail.FIELD_HISTORY_RECORD_ID + "=?";
return DBSql.query(sql, rowMapper(), historyId);
}
}

View File

@ -6,7 +6,7 @@ import java.sql.Timestamp;
public class HistoryRecord extends ModelBean {
public static final String DATABASE_ENTITY = "APP_ACT_COE_PAL_MODEL_CONVERT_HISTORY_RECORD";
public static final String DATABASE_ENTITY = "APP_ACT_COE_PAL_MC_HISTORY_RECORD";
public static final String FIELD_UUID = "ID";
public static final String FIELD_WSID = "WSID";
public static final String FIELD_SOURCE_METHOD = "SOURCEMETHOD";

View File

@ -4,9 +4,16 @@ import com.actionsoft.bpms.commons.mvc.model.ModelBean;
public class HistoryRecordDetail extends ModelBean {
public static final String DATABASE_ENTITY = "APP_ACT_COE_PAL_MC_HISTORY_RECORD_DETAIL";
public static final String FIELD_UUID = "ID";
public static final String FIELD_HISTORY_RECORD_ID = "HISTORYRECORDID";
public static final String FIELD_REPOSITORY_ID = "REPOSITORYID";
public static final String FIELD_REPOSITORY_NAME = "REPOSITORYNAME";
private String id;
private String historyId;
private String historyRecordId;
private String repositoryId;
private String repositoryName;
public String getId() {
return id;
@ -16,12 +23,12 @@ public class HistoryRecordDetail extends ModelBean {
this.id = id;
}
public String getHistoryId() {
return historyId;
public String getHistoryRecordId() {
return historyRecordId;
}
public void setHistoryId(String historyId) {
this.historyId = historyId;
public void setHistoryRecordId(String historyRecordId) {
this.historyRecordId = historyRecordId;
}
public String getRepositoryId() {
@ -31,4 +38,12 @@ public class HistoryRecordDetail extends ModelBean {
public void setRepositoryId(String repositoryId) {
this.repositoryId = repositoryId;
}
public String getRepositoryName() {
return repositoryName;
}
public void setRepositoryName(String repositoryName) {
this.repositoryName = repositoryName;
}
}

View File

@ -0,0 +1,88 @@
package com.actionsoft.apps.coe.pal.modelconvert.model.vo;
import com.actionsoft.bpms.commons.mvc.model.ModelBean;
public class HistoryRecordVo extends ModelBean {
private String historyId;
private String wsId;
private String serialNumber;
private String convertType;
private String operator;
private String operatorName;
private String operationTime;
private String convertCount;
private String repositoryNames;
public String getHistoryId() {
return historyId;
}
public void setHistoryId(String historyId) {
this.historyId = historyId;
}
public String getWsId() {
return wsId;
}
public void setWsId(String wsId) {
this.wsId = wsId;
}
public String getSerialNumber() {
return serialNumber;
}
public void setSerialNumber(String serialNumber) {
this.serialNumber = serialNumber;
}
public String getConvertType() {
return convertType;
}
public void setConvertType(String convertType) {
this.convertType = convertType;
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public String getOperatorName() {
return operatorName;
}
public void setOperatorName(String operatorName) {
this.operatorName = operatorName;
}
public String getOperationTime() {
return operationTime;
}
public void setOperationTime(String operationTime) {
this.operationTime = operationTime;
}
public String getConvertCount() {
return convertCount;
}
public void setConvertCount(String convertCount) {
this.convertCount = convertCount;
}
public String getRepositoryNames() {
return repositoryNames;
}
public void setRepositoryNames(String repositoryNames) {
this.repositoryNames = repositoryNames;
}
}

View File

@ -1,10 +1,13 @@
package com.actionsoft.apps.coe.pal.modelconvert.strategy.impl;
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
import com.actionsoft.apps.coe.pal.modelconvert.cache.ConvertShapeIdMapping;
import com.actionsoft.apps.coe.pal.modelconvert.cache.ConvertShapeNameMapping;
import com.actionsoft.apps.coe.pal.modelconvert.cache.RepositoryModelCache;
import com.actionsoft.apps.coe.pal.modelconvert.constant.LinkerDefConstant;
import com.actionsoft.apps.coe.pal.modelconvert.constant.ShapeConstant;
import com.actionsoft.apps.coe.pal.modelconvert.dao.HistoryRecordDao;
import com.actionsoft.apps.coe.pal.modelconvert.dao.HistoryRecordDetailDao;
import com.actionsoft.apps.coe.pal.modelconvert.model.*;
import com.actionsoft.apps.coe.pal.modelconvert.strategy.ModelConvertStrategy;
import com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute.DataAttributeContext;
@ -18,14 +21,23 @@ import com.actionsoft.apps.coe.pal.pal.repository.designer.util.ShapeUtil;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryAttributeModel;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryShapeAttributeModel;
import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelImpl;
import com.actionsoft.apps.coe.pal.pal.repository.upfile.constant.CoeFileConstant;
import com.actionsoft.apps.coe.pal.pal.repository.upfile.dao.UpFileDao;
import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil;
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.server.fs.DCContext;
import com.actionsoft.bpms.server.fs.dc.DCProfileManager;
import com.actionsoft.bpms.util.UUIDGener;
import com.actionsoft.bpms.util.UtilDate;
import com.actionsoft.bpms.util.UtilFile;
import com.actionsoft.bpms.util.UtilString;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -48,8 +60,6 @@ public class EpcToFlowChart implements ModelConvertStrategy {
PALRepositoryModelImpl epcRepositoryModel = (PALRepositoryModelImpl)repository.getInstance(repositoryId);
// 1.放入缓存
String historyId = UUIDGener.getUUID();
RepositoryModelCache.load(historyId,epcRepositoryModel);
// 2.新模型文件入库
String newRepositoryId = UUIDGener.getUUID();
String plRid = UUIDGener.getUUID();
@ -59,22 +69,45 @@ public class EpcToFlowChart implements ModelConvertStrategy {
int orderIndex = repository.getChildrenMaxOrderIndexByPidAndWsId(parentId, wsId) + 1;
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
String repositoryName = epcRepositoryModel.getName();
if (duplicateName) {
repositoryName += "副本";
}
PALRepositoryModelImpl repositoryModel = CoeProcessLevelUtil.createPALRepositoryModel(newRepositoryId, plRid, wsId, repositoryName, "", orderIndex, parentId,
methodCategory, true, 1, newRepositoryId, false, targetMethod, "0", epcRepositoryModel.getLevel(), null, null,
uc.getUID(), uc.getUID(), nowTime, null, null, null, null, null, null, null, null, null,epcRepositoryModel.getSecurityLevel());
if (duplicateName) {
int count = epcRepositoryModel.getConvertCount();
String suffix = "副本_" + count;
repositoryName += suffix;
repositoryModel.setName(repositoryName);
}
repository.updateConvertCount(epcRepositoryModel.getId());
repository.insert(repositoryModel);
// 3.调用模型转换的方法
this.handleEPCToFlowChart(uc,repositoryId,newRepositoryId,targetMethod);
// 4.放入缓存同时放入历史记录表中
// 6处理转换后的flowchart模型的文件属性 节点属性 形状显示规则
// 4处理转换后的flowchart模型的文件属性 节点属性 形状显示规则
this.handleDataAttribute(repositoryId,newRepositoryId,wsId,sourceMethod,targetMethod);
// 7. 处理附件
// 8. 小组权限问题
// 5. 处理附件
this.handleRepositoryModelAttachment(uc,repositoryId,newRepositoryId);
// 6.1 历史记录表
String historyId = UUIDGener.getUUID();
HistoryRecord historyRecord = new HistoryRecord();
historyRecord.setId(historyId);
historyRecord.setWsId(wsId);
historyRecord.setSourceMethod(sourceMethod);
historyRecord.setTargetMethod(targetMethod);
historyRecord.setOperator(uc.getUID());
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Timestamp nowTimeStamp = UtilDate.parseTsFromDateTime(dateFormat.format(new Date()));
historyRecord.setOperationTime(nowTimeStamp);
HistoryRecordDao historyRecordDao = new HistoryRecordDao();
historyRecordDao.insert(historyRecord);
// 6.2 历史记录详细
HistoryRecordDetail recordDetail = new HistoryRecordDetail();
recordDetail.setId(UUIDGener.getUUID());
recordDetail.setHistoryRecordId(historyId);
recordDetail.setRepositoryId(epcRepositoryModel.getId());
recordDetail.setRepositoryName(epcRepositoryModel.getName());
HistoryRecordDetailDao detailDao = new HistoryRecordDetailDao();
detailDao.insert(recordDetail);
// 7. 小组权限问题
return null;
}
@ -87,14 +120,62 @@ public class EpcToFlowChart implements ModelConvertStrategy {
@Override
public String modelConvertBatch(UserContext uc,Map<String, Object> param) {
// 1.批量放入缓存队列中
// 2.批量新模型文件入库
// 3.调用转换的方法
// 4.存入历史记录表中
List<String> repositoryIdList = (List<String>) param.get("repositoryIdList");
String sourceMethod = (String)param.get("sourceMethod");
String targetMethod = (String)param.get("targetMethod");
boolean duplicateName = Boolean.parseBoolean((String) param.get("duplicateName"));
PALRepository repositoryDao = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
repositoryIdList.stream().forEach(repositoryId -> {
PALRepositoryModelImpl sourceRepositoryModel = (PALRepositoryModelImpl)repositoryDao.getInstance(repositoryId);
// 1. 入库
String newRepositoryId = UUIDGener.getUUID();
String plRid = UUIDGener.getUUID();
String parentId = sourceRepositoryModel.getParentId();
String wsId = sourceRepositoryModel.getWsId();
String methodCategory = targetMethod.substring(0,targetMethod.indexOf("."));
int orderIndex = repositoryDao.getChildrenMaxOrderIndexByPidAndWsId(parentId, wsId) + 1;
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
String repositoryName = sourceRepositoryModel.getName();
PALRepositoryModelImpl repositoryModel = CoeProcessLevelUtil.createPALRepositoryModel(newRepositoryId, plRid, wsId, repositoryName, "", orderIndex, parentId,
methodCategory, true, 1, newRepositoryId, false, targetMethod, "0", sourceRepositoryModel.getLevel(), null, null,
uc.getUID(), uc.getUID(), nowTime, null, null, null, null, null, null, null, null, null,sourceRepositoryModel.getSecurityLevel());
if (duplicateName) {
int count = sourceRepositoryModel.getConvertCount();
String suffix = "副本_" + count;
repositoryName += suffix;
repositoryModel.setName(repositoryName);
}
repositoryDao.updateConvertCount(sourceRepositoryModel.getId());
repositoryDao.insert(repositoryModel);
// 2.调用模型转换的方法
this.handleEPCToFlowChart(uc,repositoryId,newRepositoryId,targetMethod);
// 3.处理转换后的flowchart模型的文件属性 节点属性 形状显示规则
this.handleDataAttribute(repositoryId,newRepositoryId,wsId,sourceMethod,targetMethod);
// 4. 处理附件
this.handleRepositoryModelAttachment(uc,repositoryId,newRepositoryId);
// 5.1 历史记录表
String historyId = UUIDGener.getUUID();
HistoryRecord historyRecord = new HistoryRecord();
historyRecord.setId(historyId);
historyRecord.setWsId(wsId);
historyRecord.setSourceMethod(sourceMethod);
historyRecord.setTargetMethod(targetMethod);
historyRecord.setOperator(uc.getUID());
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Timestamp nowTimeStamp = UtilDate.parseTsFromDateTime(dateFormat.format(new Date()));
historyRecord.setOperationTime(nowTimeStamp);
HistoryRecordDao historyRecordDao = new HistoryRecordDao();
historyRecordDao.insert(historyRecord);
// 5.2 历史记录详细
HistoryRecordDetail recordDetail = new HistoryRecordDetail();
recordDetail.setId(UUIDGener.getUUID());
recordDetail.setHistoryRecordId(historyId);
recordDetail.setRepositoryId(sourceRepositoryModel.getId());
recordDetail.setRepositoryName(sourceRepositoryModel.getName());
HistoryRecordDetailDao detailDao = new HistoryRecordDetailDao();
detailDao.insert(recordDetail);
// 6. 小组权限问题
});
return null;
}
@ -483,4 +564,90 @@ public class EpcToFlowChart implements ModelConvertStrategy {
}
/**
* 处理模型附件以及模型中图形的附件
* @param uc
* @param sourceRepositoryId
* @param targetRepositoryId
*/
private void handleRepositoryModelAttachment(UserContext uc,String sourceRepositoryId, String targetRepositoryId){
DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE);
UpFileDao upFileDao = new UpFileDao();
// 查询模型附件
List<UpfileModel> sourceModelFileList = upFileDao.searchByRepositoryId(sourceRepositoryId,"f");
List<UpfileModel> targetFileList = new ArrayList<>();
sourceModelFileList.stream().forEach(model -> {
// 封装附件实体
UpfileModel upfileModel = new UpfileModel();
upfileModel.setUuid(UUIDGener.getUUID());
upfileModel.setPl_uuid(targetRepositoryId);
upfileModel.setShape_uuid("");
upfileModel.setType(model.getType());
upfileModel.setFileName(model.getFileName());
upfileModel.setDownload(1);
upfileModel.setCreateUser(uc.getUID());
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateStr = dateFormat.format(new Date());
upfileModel.setCreateTime(UtilDate.parseTsFromDateTime(dateStr));
upfileModel.setSecurityLevel(-1);
targetFileList.add(upfileModel);
// 处理DocCenter
DCContext fileDcContext = new DCContext(uc, dcProfile, CoEConstant.APP_ID, "file", model.getPl_uuid(), model.getFileName());
String filePath = fileDcContext.getFilePath();
UtilFile sourceFile = new UtilFile(filePath);
DCContext targetFileDcContext = new DCContext(uc, dcProfile, CoEConstant.APP_ID, "file", upfileModel.getPl_uuid(), upfileModel.getFileName());
UtilFile targetFile = new UtilFile(targetFileDcContext.getFilePath());
// 目标文件的父级目录
UtilFile targetFileDir = new UtilFile(targetFileDcContext.getPath());
try {
if (!targetFileDir.exists()){
targetFileDir.mkdirs();
}
if (!targetFile.exists()){
targetFile.createNewFile();
}
UtilFile.copyFile(sourceFile,targetFile);
} catch (Exception e) {
e.printStackTrace();
}
});
// 模型中的图形附件
List<UpfileModel> sourceShapeFileList = upFileDao.searchByRepositoryId(sourceRepositoryId,"s");
sourceShapeFileList.stream().forEach(model -> {
UpfileModel upfileModel = new UpfileModel();
upfileModel.setUuid(UUIDGener.getUUID());
upfileModel.setPl_uuid(targetRepositoryId);
upfileModel.setShape_uuid(model.getShape_uuid());
upfileModel.setType(model.getType());
upfileModel.setFileName(model.getFileName());
upfileModel.setDownload(1);
upfileModel.setCreateUser(uc.getUID());
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateStr = dateFormat.format(new Date());
upfileModel.setCreateTime(UtilDate.parseTsFromDateTime(dateStr));
upfileModel.setSecurityLevel(-1);
targetFileList.add(upfileModel);
// 处理DocCenter
DCContext fileDcContext = new DCContext(uc, dcProfile, CoEConstant.APP_ID, model.getPl_uuid(), model.getShape_uuid(), model.getFileName());
String filePath = fileDcContext.getFilePath();
UtilFile sourceFile = new UtilFile(filePath);
DCContext targetFileDcContext = new DCContext(uc, dcProfile, CoEConstant.APP_ID, upfileModel.getPl_uuid(), upfileModel.getShape_uuid(), upfileModel.getFileName());
UtilFile targetFile = new UtilFile(targetFileDcContext.getFilePath());
// 目标文件的父级目录
UtilFile targetFileDir = new UtilFile(targetFileDcContext.getPath());
try {
if (!targetFileDir.exists()){
targetFileDir.mkdirs();
}
if (!targetFile.exists()){
targetFile.createNewFile();
}
UtilFile.copyFile(sourceFile,targetFile);
} catch (Exception e) {
e.printStackTrace();
}
});
upFileDao.batchInsert(targetFileList);
}
}

View File

@ -1,13 +1,27 @@
package com.actionsoft.apps.coe.pal.modelconvert.web;
import com.actionsoft.apps.coe.pal.modelconvert.constant.ConvertType;
import com.actionsoft.apps.coe.pal.modelconvert.dao.HistoryRecordDao;
import com.actionsoft.apps.coe.pal.modelconvert.dao.HistoryRecordDetailDao;
import com.actionsoft.apps.coe.pal.modelconvert.model.HistoryRecord;
import com.actionsoft.apps.coe.pal.modelconvert.model.HistoryRecordDetail;
import com.actionsoft.apps.coe.pal.modelconvert.model.vo.HistoryRecordVo;
import com.actionsoft.apps.coe.pal.modelconvert.util.ConvertUtil;
import com.actionsoft.apps.coe.pal.pal.modelconvert.constant.ModelConvertConst;
import com.actionsoft.bpms.commons.htmlframework.HtmlPageTemplate;
import com.actionsoft.bpms.commons.mvc.view.ActionWeb;
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.util.UtilDate;
import com.actionsoft.sdk.local.SDK;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.HashMap;
import java.util.Map;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
public class ModelConvertWeb extends ActionWeb {
@ -37,5 +51,52 @@ public class ModelConvertWeb extends ActionWeb {
return HtmlPageTemplate.merge(ModelConvertConst.APP_ID,"main.htm",macroLibraries);
}
// 查询历史信息 小组ID的待定
public String getHistoryRecordInfo(String wsId,String teamId){
ResponseObject ro = ResponseObject.newOkResponse();
HistoryRecordDao recordDao = new HistoryRecordDao();
HistoryRecordDetailDao detailDao = new HistoryRecordDetailDao();
List<HistoryRecord> recordList = recordDao.getHistoryRecordListByWsId(wsId);
// 根据时间排序
recordList = recordList.stream().sorted((d1,d2) -> {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date date1 = format.parse(UtilDate.datetimeFormat(d1.getOperationTime()));
Date date2 = format.parse(UtilDate.datetimeFormat(d2.getOperationTime()));
return Long.compare(date2.getTime(), date1.getTime());
} catch (ParseException e) {
e.printStackTrace();
}
return 0;
}).collect(Collectors.toList());
JSONArray result = new JSONArray();
long i = 0;
for (HistoryRecord historyRecord : recordList) {
HistoryRecordVo recordVo = new HistoryRecordVo();
recordVo.setHistoryId(historyRecord.getId());
recordVo.setWsId(historyRecord.getWsId());
recordVo.setSerialNumber(String.valueOf(++i));
recordVo.setConvertType(ConvertUtil.matchConvertType(historyRecord.getSourceMethod(),historyRecord.getTargetMethod()).getDesc());
recordVo.setOperationTime(UtilDate.datetimeFormat(historyRecord.getOperationTime()));
recordVo.setOperator(historyRecord.getOperator());
recordVo.setOperatorName(SDK.getORGAPI().getUser(historyRecord.getOperator()).getUserName());
List<HistoryRecordDetail> detailList = detailDao.getHistoryRecordDetailListByWsId(historyRecord.getId());
List<String> nameList = detailList.stream().map(detail -> detail.getRepositoryName()).collect(Collectors.toList());
String nameStr = String.join("", nameList);
recordVo.setRepositoryNames(nameStr);
recordVo.setConvertCount(String.valueOf(detailList.size()));
result.add(recordVo.toJSONObject());
}
ro.put("recordList",result);
return ro.toString();
}
// 查询历史详细信息
public String getHistoryRecordDetailInfo(String historyId){
ResponseObject ro = ResponseObject.newOkResponse();
HistoryRecordDetailDao detailDao = new HistoryRecordDetailDao();
List<HistoryRecordDetail> detailList = detailDao.getHistoryRecordDetailListByWsId(historyId);
ro.put("detailList",detailList);
return ro.toString();
}
}

View File

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<aws-actions>
<cmd-bean name="com.actionsoft.apps.coe.pal.test_handle">
<cmd-bean name="com.actionsoft.apps.coe.pal.model_convert_history_record_list">
<param name="wsId"/>
<param name="teamId"/>
</cmd-bean>
<cmd-bean name="com.actionsoft.apps.coe.pal.model_convert_history_record_detail_list">
<param name="historyId"/>
</cmd-bean>
</aws-actions>

View File

@ -7,4 +7,7 @@ ALTER TABLE APP_ACT_COE_PAL_REPO_R modify PLLEVEL DECIMAL(6,3);
ALTER TABLE APP_ACT_COE_PAL_COOP_ROLE_PERM ADD ACTIONPERM varchar(36);
ALTER TABLE APP_ACT_COE_PAL_COOP_ROLE ADD ISUSER SMALLINT;
UPDATE APP_ACT_COE_PAL_COOP_ROLE SET ISUSER = 0;
UPDATE APP_ACT_COE_PAL_COOP_ROLE SET ISUSER = 0;
ALTER TABLE APP_ACT_COE_PAL_REPOSITORY ADD CONVERTCOUNT INT DEFAULT 0 NULL;

View File

@ -44,7 +44,7 @@ public class ModelConvertWeb extends ActionWeb {
List<String> repositoryIdList = array.stream().map(id -> (String) id).collect(Collectors.toList());
Map<String,Object> params = new HashMap<String, Object>();
params.put("sid",uc.getSessionId());
params.put("repositoryId",repositoryIdList);
params.put("repositoryIdList",repositoryIdList);
params.put("sourceMethod",sourceMethod);
params.put("targetMethod",targetMethod);
params.put("duplicateName",duplicateName);

View File

@ -475,6 +475,7 @@ public class PALRepository extends DaoObject<PALRepositoryModel> {
model.setExt4(rs.getString(PALRepositoryModelImpl.FIELD_PL_EXT4));
//三员管理-密级
model.setSecurityLevel(rs.getInt(PALRepositoryModelImpl.FIELD_SECURITY_LEVEL));
model.setConvertCount(rs.getInt(PALRepositoryModelImpl.FIELD_CONVERT_COUNT));
return model;
}
@ -3337,6 +3338,25 @@ public class PALRepository extends DaoObject<PALRepositoryModel> {
return r;
}
/**
* 修改模型转换次数
*
* @param palRepositoryId
* @author zhangming
*/
public int updateConvertCount(String palRepositoryId) {
PALRepositoryModelImpl model = (PALRepositoryModelImpl) PALRepositoryCache.getCache().get(palRepositoryId);
int convertCount = model.getConvertCount();
++convertCount;
model.setConvertCount(convertCount);
String sql = "UPDATE " + PALRepositoryModelImpl.DATABASE_ENTITY + " SET "+PALRepositoryModelImpl.FIELD_CONVERT_COUNT+" =? WHERE ID = ?";
int r = DBSql.update(sql, new Object[] { convertCount, palRepositoryId });
if (r > 0) {
PALRepositoryCache.getCache().put(model.getId(), model);
}
return r;
}
/**
* 搜索已发布流程用于流程发布客户端
*

View File

@ -344,4 +344,6 @@ public interface PALRepositoryModel extends IModelBean {
*/
public Integer getSecurityLevel();
public int getConvertCount();
}

View File

@ -64,6 +64,8 @@ public class PALRepositoryModelImpl extends PlatformMetaModelBean implements PAL
public static final String FIELD_PL_EXT4 = "EXT4";// add by sunlh
//文件密级 add by anhc
public static final String FIELD_SECURITY_LEVEL = "SECURITYLEVEL";
// 模型转换次数
public static final String FIELD_CONVERT_COUNT = "CONVERTCOUNT";
private String id = "";
private String wsId = "";
@ -140,6 +142,8 @@ public class PALRepositoryModelImpl extends PlatformMetaModelBean implements PAL
*/
private String plRid = "";
private int convertCount = 0;
public boolean isPublish() {
return isPublish;
}
@ -585,4 +589,12 @@ public class PALRepositoryModelImpl extends PlatformMetaModelBean implements PAL
public void setSecurityLevel(Integer securityLevel) {
this.securityLevel = securityLevel;
}
public int getConvertCount() {
return convertCount;
}
public void setConvertCount(int convertCount) {
this.convertCount = convertCount;
}
}