Merge branch 'apps_dev_ydq_process_list' into apps_4_test

This commit is contained in:
袁东强 2025-07-30 17:06:36 +08:00
commit 84b63b5bdf

View File

@ -3,6 +3,7 @@ package com.actionsoft.apps.coe.pal.processlist.web;
import java.io.File;
import java.io.FileOutputStream;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -48,6 +49,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alipay.remoting.util.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
@ -80,6 +82,8 @@ import com.actionsoft.sdk.local.SDK;
* 流程清单-web
*/
public class PALRepositoryListWeb extends ActionWeb {
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
UserContext _uc;
public PALRepositoryListWeb() {
}
@ -117,6 +121,35 @@ public class PALRepositoryListWeb extends ActionWeb {
macroLibraries.put("defaultSelectVal", defaultSelectVal);
macroLibraries.put("teamId", teamId);
macroLibraries.put("settingParam", JSON.toJSON(macroLibraries));
JSONArray processStatusFilters = getProcessStatusFilters();
for(int i=0;i<processStatusFilters.size();i++){
JSONObject jsonObject = processStatusFilters.getJSONObject(i);
jsonObject.put("label", jsonObject.get("text"));
}
macroLibraries.put("statusSelect", processStatusFilters);
JSONArray useStatusSelect = new JSONArray();
JSONObject syz = new JSONObject();
syz.put("value", 1);
syz.put("label", "使用中");
useStatusSelect.add(syz);
JSONObject fsyz = new JSONObject();
fsyz.put("value", 2);
fsyz.put("label", "非使用中");
useStatusSelect.add(fsyz);
macroLibraries.put("useStatusSelect", useStatusSelect);
List<String> palMethodCategoryList = PALMethodCache.getPALMethodList(true);
JSONArray categorySelect = new JSONArray();
for (int i=0;i<palMethodCategoryList.size();i++){
String s = palMethodCategoryList.get(i);
List<PALMethodModel> list = PALMethodCache.getPALMethodModelListByMethod(s);
for (PALMethodModel model : list) {
JSONObject category = new JSONObject();
category.put("value", model.getId());
category.put("label", I18nRes.findValue(CoEConstant.APP_ID, model.getId()));
categorySelect.add(category);
}
}
macroLibraries.put("categorySelect", categorySelect);
// 操作行为日志记录
if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) {
CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_APPCENTER, CoEOpLogConst.OP_ACCESS, CoEOpLogConst.INFO_APPCENTER_ACCESS_PREFIX + SDK.getAppAPI().getAppContext(ProcessListConstant.PROCESSLIST).getName() + CoEOpLogConst.INFO_APPCENTER_ACCESS_SUFFIX);
@ -664,10 +697,98 @@ public class PALRepositoryListWeb extends ActionWeb {
permVerIds = CoeProcessLevelUtil.getPermRepositoryVersionIds(wsId, teamId, _uc.getUID(), null, null);
}
//文件状态
JSONArray statusFilter = customFilterObj.getJSONArray("statusFilter");//流程架构L1
Set<String> statusSet = new HashSet<>();
for (int i = 0; i < statusFilter.size(); i++) {
statusSet.add(statusFilter.getString(i));
}
//使用状态
JSONArray useFilter = customFilterObj.getJSONArray("useStatusFilter");
Set<String> useSet = new HashSet<>();
for (int i = 0; i < useFilter.size(); i++) {
useSet.add(useFilter.getString(i));
}
//生效日期
JSONArray effectiveDate = customFilterObj.getJSONArray("effectiveDate");
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
long startTime = 0;
if (effectiveDate.size() > 0){
String startTimeString = effectiveDate.getString(0);
try {
Date date = formatter.parse(startTimeString);
startTime = date.getTime();
} catch (ParseException e) {
System.out.println("流程清单数据过滤时,生效日期的开始时间转化失败");
e.printStackTrace();
}
}
long endTime = 0;
if (effectiveDate.size() > 1){
String endTimeString = effectiveDate.getString(1);
try {
Date date = formatter.parse(endTimeString);
endTime = date.getTime();
} catch (ParseException e) {
System.out.println("流程清单数据过滤时,生效日期的结束时间转化失败");
e.printStackTrace();
}
}
//流程分类
JSONArray categoryFilter = customFilterObj.getJSONArray("categoryFilter");
Set<String> categorySet = new HashSet<>();
for (int i = 0; i < categoryFilter.size(); i++) {
categorySet.add(categoryFilter.getString(i));
}
for (PALRepositoryModel model: palList) {
// if (!model.isUse()) {// 非设计中状态过滤
// continue;
// }
//文件状态
if (statusSet.size()>0){
String type = model.isPublish()?"publish":model.isStop()?"stop":"designer";
if (!statusSet.contains( type)){
continue;
}
}
//使用状态
if (useSet.size()>0){
String isUse= model.isUse()?"1":"2";
if (!useSet.contains(isUse)){
continue;
}
}
//流程分类
if (categorySet.size()>0){
if (!categorySet.contains(model.getMethodId())){
continue;
}
}
//生效日期
if (startTime > 0 || endTime > 0) {
try {
PALRepositoryPropertyModel propModel = PALRepositoryPropertyCache.getPropertyByPropertyId(model.getId(), "fileExpiryDate");
if (propModel == null) {
continue;
}
String expiryDate = propModel.getPropertyValue();
if (UtilString.isEmpty(expiryDate)) {
continue;
}
Date date = formatter.parse(expiryDate);
if (startTime > 0 && date.getTime() <= startTime) {
continue;
}
if (endTime > 0 && date.getTime() >= endTime) {
continue;
}
} catch (Exception e) {
System.out.println("流程清单数据过滤时,文件有效期转化失败");
e.printStackTrace();
}
}
if (!UtilString.isEmpty(searchInput)) {// 流程名称条件不为空时过滤名称
if (!model.getName().toUpperCase().contains(searchInput.toUpperCase())) {
continue;
@ -771,6 +892,15 @@ public class PALRepositoryListWeb extends ActionWeb {
JSONObject statusObj = getJsonObject("status", "status", "状态", "状态", "150", "150", false, columnType, "selectStatus");
statusObj.put("filters", getProcessStatusFilters());
map.put("status", statusObj);
//使用状态
map.put("is_use", getJsonObject("is_use", "is_use", "使用状态", "使用状态", "150", "150", false, columnType, "default"));
//最后修改时间
map.put("modify_date", getJsonObject("modify_date", "modify_date", "修改时间", "修改时间", "150", "150", false, columnType, "default"));
//文件ID
map.put("file_id", getJsonObject("file_id", "file_id", "文件ID", "文件ID", "150", "150", false, columnType, "default"));
//文件组ID
map.put("group_id", getJsonObject("group_id", "group_id", "文件组ID", "文件组ID", "150", "150", false, columnType, "default"));
// map.put("parent_name",getJsonObject("parent_name","parent_name","上级名称","上级名称","250","250",false,columnType,"name"));
}
return map;
@ -998,6 +1128,20 @@ public class PALRepositoryListWeb extends ActionWeb {
return model.getInput();
case "output":
return model.getOutput();
case "is_use":
return model.isUse()?"使用中":"非使用中";
case "modify_date":
String modifyDate = "";
try {
modifyDate = sdf.format(model.getModifyDate());
} catch (Exception e) {
e.getMessage();
}
return modifyDate;
case "file_id":
return model.getId();
case "group_id":
return model.getVersionId();
default:
return "";
}
@ -1211,7 +1355,21 @@ public class PALRepositoryListWeb extends ActionWeb {
// 获取符合条件数据的maxLevel
int maxLevel = getMaxLevelByList(palList);
// 获取Excel表头信息
List<String> excelTableHeadList = getExcelTableHeadData(wsId, palList, maxLevel, tempArr);
boolean treeVisible = true;
boolean idVisible = true;
try{
JSONObject jsonObject = JSONObject.parseObject(customFilter);
if (jsonObject != null&& jsonObject.containsKey("treeVisible")&&"false".equals(jsonObject.getString("treeVisible"))){
treeVisible = false;
}
if (jsonObject != null&& jsonObject.containsKey("idVisible")&&"false".equals(jsonObject.getString("idVisible"))){
idVisible = false;
}
}catch (Exception e){
e.getMessage() ;
}
List<String> excelTableHeadList = getExcelTableHeadData(wsId, palList, maxLevel, tempArr, treeVisible, idVisible);
ConsolePrinter.info("流程清单表头信息 " + excelTableHeadList.toString().replaceAll("\n",""));
short column = columnIndex;
// 设置默认的两行 通栏
@ -1298,24 +1456,25 @@ public class PALRepositoryListWeb extends ActionWeb {
String cellValue = getDefaultFixedValueById("type", model.getId());
cell.setCellValue(I18nRes.findValue(ProcessListConstant.PROCESSLIST, cellValue.trim()));
// 名称
int level = model.getLevel();
HSSFCell levelCell = row.createCell(level);
String levelCellValue = "";
if (level <= 1) {
levelCellValue = model.getName();
} else {
levelCellValue = getDefaultFixedValueById("no", model.getId()) + " " + model.getName();
if (treeVisible) {
int level = model.getLevel();
HSSFCell levelCell = row.createCell(level);
String levelCellValue = "";
if (level <= 1) {
levelCellValue = model.getName();
} else {
levelCellValue = getDefaultFixedValueById("no", model.getId()) + " " + model.getName();
}
levelCell.setCellValue(levelCellValue);
// 记录合并列
Map<Integer, Integer> map = new HashMap<>();
map.put(0, rowIndex);
map.put(1, levelCell.getColumnIndex());
map.put(2, maxLevel + 1);
columMap.put(count, map);
count++;
cellIndex = cellIndex + maxLevel + 1;// 第一列+level所占列数+空闲一列
}
levelCell.setCellValue(levelCellValue);
// 记录合并列
Map<Integer, Integer> map = new HashMap<>();
map.put(0, rowIndex);
map.put(1, levelCell.getColumnIndex());
map.put(2, maxLevel + 1);
columMap.put(count, map);
count++;
cellIndex = cellIndex + maxLevel + 1;// 第一列+level所占列数+空闲一列
// 模型名称
HSSFCell modelNameCell = row.createCell(++cellIndex);
modelNameCell.setCellValue(model.getName());
@ -1371,10 +1530,15 @@ public class PALRepositoryListWeb extends ActionWeb {
int parentNameCellIndex = 0;
for (int j = 0; j < tempArr.size(); j++) {
HSSFCell attrCell = row.createCell(++cellIndex);
String attrCellValue = "";
JSONObject config = tempArr.getJSONObject(j);
String propId = config.getString("id");
// 当idVisible为false时跳过group_id和file_id列
if (!idVisible && (StringUtils.isNotBlank(propId) && ("group_id".equals(propId) || "file_id".equals(propId)))) {
continue;
}
HSSFCell attrCell = row.createCell(++cellIndex);
String attrCellValue = "";
// 伊利定制化需求23-01-05
if ("status".equals(propId)){
@ -1462,22 +1626,29 @@ public class PALRepositoryListWeb extends ActionWeb {
* @param tableHeadConfigArr
* @return
*/
private List<String> getExcelTableHeadData(String wsId, List<PALRepositoryModel> palList, int maxLevel, JSONArray tableHeadConfigArr) {
private List<String> getExcelTableHeadData(String wsId, List<PALRepositoryModel> palList, int maxLevel, JSONArray tableHeadConfigArr,boolean treeVisible,boolean idVisible) {
List<String> result = new ArrayList<>();
for (int i = 0; i <= maxLevel; i++) {
if (i == 0) {
result.add(getExcelTitleName(I18nRes.findValue(CoEConstant.APP_ID, "流程分类")));
} else {
} else if (treeVisible){
result.add("\n" + I18nRes.findValue(CoEConstant.APP_ID, com.actionsoft.apps.coe.pal.pal.repository.util.Number2ChineseNumUtil.convertChineseStr(String.valueOf(i))) + getExcelTitleName(I18nRes.findValue(CoEConstant.APP_ID, "级流程")));
}
}
result.add("");// 空一列
if(treeVisible){
result.add("");// 空一列
}
// 伊利定制化需求23-11-21 空白列与扩展列之间增加 模型名称与版本号两列
result.add("模型名称");
result.add("版本号");
// excel表格扩展字段
for (int i = 0; i < tableHeadConfigArr.size(); i++) {
if (!idVisible){
String id = tableHeadConfigArr.getJSONObject(i).getString("id");
if (StringUtils.isNotBlank( id)&&("group_id".equals( id)||"file_id".equals( id))){
continue;
}
}
result.add(tableHeadConfigArr.getJSONObject(i).getString("name"));
if ("status".equals(tableHeadConfigArr.getJSONObject(i).getString("id"))){
result.add("上级名称");