diff --git a/pigx-common/pigx-common-excel/src/main/java/com/pig4cloud/pigx/common/excel/converters/LocalDateTimeStringConverter.java b/pigx-common/pigx-common-excel/src/main/java/com/pig4cloud/pigx/common/excel/converters/LocalDateTimeStringConverter.java index a326ea03a..9ecc2188c 100644 --- a/pigx-common/pigx-common-excel/src/main/java/com/pig4cloud/pigx/common/excel/converters/LocalDateTimeStringConverter.java +++ b/pigx-common/pigx-common-excel/src/main/java/com/pig4cloud/pigx/common/excel/converters/LocalDateTimeStringConverter.java @@ -72,21 +72,21 @@ public enum LocalDateTimeStringConverter implements Converter { private static String switchDateFormat(String dateString) { int length = dateString.length(); switch (length) { - case 19: - if (dateString.contains(MINUS)) { - return DateUtils.DATE_FORMAT_19; - } - else { - return DateUtils.DATE_FORMAT_19_FORWARD_SLASH; - } - case 17: - return DateUtils.DATE_FORMAT_17; - case 14: - return DateUtils.DATE_FORMAT_14; - case 10: - return DateUtils.DATE_FORMAT_10; - default: - throw new IllegalArgumentException("can not find date format for:" + dateString); + case 19: + if (dateString.contains(MINUS)) { + return DateUtils.DATE_FORMAT_19; + } + else { + return DateUtils.DATE_FORMAT_19_FORWARD_SLASH; + } + case 17: + return DateUtils.DATE_FORMAT_17; + case 14: + return DateUtils.DATE_FORMAT_14; + case 10: + return DateUtils.DATE_FORMAT_10; + default: + throw new IllegalArgumentException("can not find date format for:" + dateString); } } diff --git a/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/service/impl/AccessUserServiceImpl.java b/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/service/impl/AccessUserServiceImpl.java index ebe584478..0874f03a1 100644 --- a/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/service/impl/AccessUserServiceImpl.java +++ b/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/service/impl/AccessUserServiceImpl.java @@ -246,17 +246,17 @@ public class AccessUserServiceImpl implements AccessUserService { public void processBeforeOperation(AccessUser entity, BaseOperationEnum operationEnum) throws BusinessException { // 过滤密码 switch (operationEnum) { - case INSERT: - // gaea是为了和前端加密保持一致 - entity.setPassword(MD5Util.encrypt(MD5Util.encrypt(defaultPassword.concat("gaea")))); - break; - case UPDATE: - // 更新用户不允许修改密码 - entity.setPassword(null); - break; - default: + case INSERT: + // gaea是为了和前端加密保持一致 + entity.setPassword(MD5Util.encrypt(MD5Util.encrypt(defaultPassword.concat("gaea")))); + break; + case UPDATE: + // 更新用户不允许修改密码 + entity.setPassword(null); + break; + default: - break; + break; } } diff --git a/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/datasource/service/impl/DataSourceServiceImpl.java b/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/datasource/service/impl/DataSourceServiceImpl.java index 6e8ec81b2..0cb2d8e3b 100644 --- a/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/datasource/service/impl/DataSourceServiceImpl.java +++ b/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/datasource/service/impl/DataSourceServiceImpl.java @@ -93,22 +93,22 @@ public class DataSourceServiceImpl implements DataSourceService { DataSourceDto dto = new DataSourceDto(); dto.setSourceConfig(sourceConfig); switch (sourceType) { - case JdbcConstants.ELASTIC_SEARCH_SQL: - testElasticsearchSqlConnection(dto); - break; - case JdbcConstants.MYSQL: - case JdbcConstants.KUDU_IMAPLA: - case JdbcConstants.ORACLE: - case JdbcConstants.SQL_SERVER: - case JdbcConstants.JDBC: - case JdbcConstants.POSTGRESQL: - testRelationalDb(dto); - break; - case JdbcConstants.HTTP: - testHttp(dto); - break; - default: - throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_TYPE_DOES_NOT_MATCH_TEMPORARILY); + case JdbcConstants.ELASTIC_SEARCH_SQL: + testElasticsearchSqlConnection(dto); + break; + case JdbcConstants.MYSQL: + case JdbcConstants.KUDU_IMAPLA: + case JdbcConstants.ORACLE: + case JdbcConstants.SQL_SERVER: + case JdbcConstants.JDBC: + case JdbcConstants.POSTGRESQL: + testRelationalDb(dto); + break; + case JdbcConstants.HTTP: + testHttp(dto); + break; + default: + throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_TYPE_DOES_NOT_MATCH_TEMPORARILY); } log.info("测试连接成功:{}", JSONObject.toJSONString(connectionParam)); return true; @@ -119,19 +119,19 @@ public class DataSourceServiceImpl implements DataSourceService { public List execute(DataSourceDto dto) { String sourceType = dto.getSourceType(); switch (sourceType) { - case JdbcConstants.ELASTIC_SEARCH_SQL: - return executeElasticsearchSql(dto); - case JdbcConstants.MYSQL: - case JdbcConstants.KUDU_IMAPLA: - case JdbcConstants.ORACLE: - case JdbcConstants.SQL_SERVER: - case JdbcConstants.JDBC: - case JdbcConstants.POSTGRESQL: - return executeRelationalDb(dto); - case JdbcConstants.HTTP: - return executeHttp(dto); - default: - throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_TYPE_DOES_NOT_MATCH_TEMPORARILY); + case JdbcConstants.ELASTIC_SEARCH_SQL: + return executeElasticsearchSql(dto); + case JdbcConstants.MYSQL: + case JdbcConstants.KUDU_IMAPLA: + case JdbcConstants.ORACLE: + case JdbcConstants.SQL_SERVER: + case JdbcConstants.JDBC: + case JdbcConstants.POSTGRESQL: + return executeRelationalDb(dto); + case JdbcConstants.HTTP: + return executeHttp(dto); + default: + throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_TYPE_DOES_NOT_MATCH_TEMPORARILY); } } @@ -145,12 +145,12 @@ public class DataSourceServiceImpl implements DataSourceService { // 区分数据类型 String sourceType = sourceDto.getSourceType(); switch (sourceType) { - case JdbcConstants.ELASTIC_SEARCH_SQL: - return 0; - case JdbcConstants.MYSQL: - return mysqlTotal(sourceDto, dto); - default: - throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_TYPE_DOES_NOT_MATCH_TEMPORARILY); + case JdbcConstants.ELASTIC_SEARCH_SQL: + return 0; + case JdbcConstants.MYSQL: + return mysqlTotal(sourceDto, dto); + default: + throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_TYPE_DOES_NOT_MATCH_TEMPORARILY); } } diff --git a/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/dict/service/impl/GaeaDictItemServiceImpl.java b/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/dict/service/impl/GaeaDictItemServiceImpl.java index 5d4823cd2..0560bb5ef 100644 --- a/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/dict/service/impl/GaeaDictItemServiceImpl.java +++ b/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/dict/service/impl/GaeaDictItemServiceImpl.java @@ -49,13 +49,13 @@ public class GaeaDictItemServiceImpl implements GaeaDictItemService { String key = GaeaKeyConstant.DICT_PREFIX + locale + GaeaConstant.REDIS_SPLIT + dictCode; switch (operationEnum) { - case INSERT: - case UPDATE: - cacheHelper.hashSet(key, entity.getItemValue(), entity.getItemName()); - break; - case DELETE: - cacheHelper.hashDel(key, entity.getItemValue()); - default: + case INSERT: + case UPDATE: + cacheHelper.hashSet(key, entity.getItemValue(), entity.getItemName()); + break; + case DELETE: + cacheHelper.hashDel(key, entity.getItemValue()); + default: } } @@ -71,15 +71,15 @@ public class GaeaDictItemServiceImpl implements GaeaDictItemService { Collectors.toMap(GaeaDictItem::getItemValue, GaeaDictItem::getItemName, (v1, v2) -> v2))); switch (operationEnum) { - case DELETE_BATCH: - // 遍历并保持到Redis中 - dictItemMap.entrySet().stream().forEach(entry -> { - String key = GaeaKeyConstant.DICT_PREFIX + entry.getKey(); - Set hashKeys = entry.getValue().keySet(); - cacheHelper.hashBatchDel(key, hashKeys); - }); - break; - default: + case DELETE_BATCH: + // 遍历并保持到Redis中 + dictItemMap.entrySet().stream().forEach(entry -> { + String key = GaeaKeyConstant.DICT_PREFIX + entry.getKey(); + Set hashKeys = entry.getValue().keySet(); + cacheHelper.hashBatchDel(key, hashKeys); + }); + break; + default: } } diff --git a/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/service/impl/ReportExcelServiceImpl.java b/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/service/impl/ReportExcelServiceImpl.java index c109ecd1f..6b3e49c28 100644 --- a/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/service/impl/ReportExcelServiceImpl.java +++ b/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/service/impl/ReportExcelServiceImpl.java @@ -287,21 +287,21 @@ public class ReportExcelServiceImpl implements ReportExcelService { // 获取单元格类型 CellType cellType = getCellType(cellObject); switch (cellType) { - case BLACK: - // 空数据单元格不处理 - break; - case DYNAMIC_MERGE: - case DYNAMIC: - // 处理动态单元格 - String v = cellObject.getJSONObject("v").getString("v"); - DataSetDto dataSet = getDataSet(v, setParam); - handleDynamicCellObject(dataSet, v, cellStr, cnt, cellR, cellC, merge, dbObject, colAddCntMap); - break; - default: - // 处理静态单元格 - handleStaticCellObject(cellStr, dbObject, cnt, cellR, cellC, cellDataMap, setParam, merge, colAddCntMap, - cellType); - break; + case BLACK: + // 空数据单元格不处理 + break; + case DYNAMIC_MERGE: + case DYNAMIC: + // 处理动态单元格 + String v = cellObject.getJSONObject("v").getString("v"); + DataSetDto dataSet = getDataSet(v, setParam); + handleDynamicCellObject(dataSet, v, cellStr, cnt, cellR, cellC, merge, dbObject, colAddCntMap); + break; + default: + // 处理静态单元格 + handleStaticCellObject(cellStr, dbObject, cnt, cellR, cellC, cellDataMap, setParam, merge, colAddCntMap, + cellType); + break; } } @@ -382,44 +382,44 @@ public class ReportExcelServiceImpl implements ReportExcelService { JSONObject addCellData = JSONObject.parseObject(cellStr); int rows = 0; switch (cellType) { - case STATIC: - case STATIC_MERGE: - // 静态不扩展单元格只需要初始化位置就可以 - initCellPosition(addCellData, cnt, merge); - break; - case STATIC_AUTO: - // 获取静态单元格右侧动态单元格的总行数 - rows = getRightDynamicCellRows(addCellData, cellDataMap, setParam, rows, cellType); - initCellPosition(addCellData, cnt, merge); - if (rows > 1) { - // 需要把这个静态扩展单元格 改变为 静态合并扩展单元格,就是增加合并属性 mc 以及merge配置 - JSONObject mc = new JSONObject(); - mc.put("rs", rows); - mc.put("cs", 1); - mc.put("r", addCellData.getIntValue("r")); - mc.put("c", addCellData.getIntValue("c")); - addCellData.getJSONObject("v").put("mc", mc); - // 合并单元格需要处理config.merge - merge.put((mc.getInteger("r")) + "_" + mc.getString("c"), mc); - // 处理单元格扩展之后此列扩展的总行数 - colAddCntMap.put(c, cnt + rows - 1); - } - break; - case STATIC_MERGE_AUTO: - // 获取静态单元格右侧动态单元格的总行数 - rows = getRightDynamicCellRows(addCellData, cellDataMap, setParam, rows, cellType); - initCellPosition(addCellData, cnt, merge); - if (rows > 0) { - // 需要修改单元格mc中的rs - JSONObject cellMc = addCellData.getJSONObject("v").getJSONObject("mc"); - int addCnt = cellMc.getInteger("rs"); - cellMc.put("rs", rows); - // 合并单元格需要处理config.merge - merge.put((cellMc.getInteger("r")) + "_" + cellMc.getString("c"), cellMc); - // 处理单元格扩展之后此列扩展的总行数 - colAddCntMap.put(c, cnt + rows - addCnt); - } - break; + case STATIC: + case STATIC_MERGE: + // 静态不扩展单元格只需要初始化位置就可以 + initCellPosition(addCellData, cnt, merge); + break; + case STATIC_AUTO: + // 获取静态单元格右侧动态单元格的总行数 + rows = getRightDynamicCellRows(addCellData, cellDataMap, setParam, rows, cellType); + initCellPosition(addCellData, cnt, merge); + if (rows > 1) { + // 需要把这个静态扩展单元格 改变为 静态合并扩展单元格,就是增加合并属性 mc 以及merge配置 + JSONObject mc = new JSONObject(); + mc.put("rs", rows); + mc.put("cs", 1); + mc.put("r", addCellData.getIntValue("r")); + mc.put("c", addCellData.getIntValue("c")); + addCellData.getJSONObject("v").put("mc", mc); + // 合并单元格需要处理config.merge + merge.put((mc.getInteger("r")) + "_" + mc.getString("c"), mc); + // 处理单元格扩展之后此列扩展的总行数 + colAddCntMap.put(c, cnt + rows - 1); + } + break; + case STATIC_MERGE_AUTO: + // 获取静态单元格右侧动态单元格的总行数 + rows = getRightDynamicCellRows(addCellData, cellDataMap, setParam, rows, cellType); + initCellPosition(addCellData, cnt, merge); + if (rows > 0) { + // 需要修改单元格mc中的rs + JSONObject cellMc = addCellData.getJSONObject("v").getJSONObject("mc"); + int addCnt = cellMc.getInteger("rs"); + cellMc.put("rs", rows); + // 合并单元格需要处理config.merge + merge.put((cellMc.getInteger("r")) + "_" + cellMc.getString("c"), cellMc); + // 处理单元格扩展之后此列扩展的总行数 + colAddCntMap.put(c, cnt + rows - addCnt); + } + break; } dbObject.getJSONArray("celldata").add(addCellData); } @@ -467,29 +467,29 @@ public class ReportExcelServiceImpl implements ReportExcelService { // 首先判断这个单元格是否也是【静态扩展单元格】 CellType rightCellType = getCellType(rightCell); switch (rightCellType) { - case STATIC_AUTO: - case STATIC_MERGE_AUTO: - // 递归查找 - sumRows = getRightDynamicCellRows(rightCell, cellDataMap, setParam, sumRows, rightCellType); - break; - case BLACK: - case STATIC: - sumRows++; - break; - case STATIC_MERGE: - sumRows += rightCell.getJSONObject("v").getJSONObject("mc").getInteger("rs"); - break; - default: - List cellDynamicData = getDynamicDataList(rightCell.getJSONObject("v").getString("v"), - setParam); - if (cellDynamicData != null && cellDynamicData.size() > 1) { - int size = cellDynamicData.size(); - sumRows += size; - } - else { + case STATIC_AUTO: + case STATIC_MERGE_AUTO: + // 递归查找 + sumRows = getRightDynamicCellRows(rightCell, cellDataMap, setParam, sumRows, rightCellType); + break; + case BLACK: + case STATIC: sumRows++; - } - break; + break; + case STATIC_MERGE: + sumRows += rightCell.getJSONObject("v").getJSONObject("mc").getInteger("rs"); + break; + default: + List cellDynamicData = getDynamicDataList(rightCell.getJSONObject("v").getString("v"), + setParam); + if (cellDynamicData != null && cellDynamicData.size() > 1) { + int size = cellDynamicData.size(); + sumRows += size; + } + else { + sumRows++; + } + break; } } return sumRows; @@ -513,14 +513,14 @@ public class ReportExcelServiceImpl implements ReportExcelService { Integer cellRs = 0; Integer cellCs = 0; switch (cellType) { - case STATIC_AUTO: - cellRs = 1; - cellCs = 1; - break; - case STATIC_MERGE_AUTO: - cellRs = addCellData.getJSONObject("v").getJSONObject("mc").getInteger("rs"); - cellCs = addCellData.getJSONObject("v").getJSONObject("mc").getInteger("cs"); - break; + case STATIC_AUTO: + cellRs = 1; + cellCs = 1; + break; + case STATIC_MERGE_AUTO: + cellRs = addCellData.getJSONObject("v").getJSONObject("mc").getInteger("rs"); + cellCs = addCellData.getJSONObject("v").getJSONObject("mc").getInteger("cs"); + break; } List rightCells = new ArrayList<>(); for (int nums = 0; nums < cellRs; nums++) { diff --git a/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/util/ConstantUtil.java b/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/util/ConstantUtil.java index 4922fad43..18bd83af2 100644 --- a/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/util/ConstantUtil.java +++ b/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/util/ConstantUtil.java @@ -209,24 +209,24 @@ public class ConstantUtil { public static short getRotation(int i) { short t = 0; switch (i) { - case 1: - t = 45; - break; - case 2: - t = -45; - break; - case 3: - t = 255; - break; - case 4: - t = 90; - break; - case 5: - t = -90; - break; + case 1: + t = 45; + break; + case 2: + t = -45; + break; + case 3: + t = 255; + break; + case 4: + t = 90; + break; + case 5: + t = -90; + break; - default: - t = 0; + default: + t = 0; } return t; } diff --git a/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/util/XlsSheetUtil.java b/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/util/XlsSheetUtil.java index fbcfd0f38..f99def22a 100644 --- a/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/util/XlsSheetUtil.java +++ b/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/util/XlsSheetUtil.java @@ -639,106 +639,106 @@ public class XlsSheetUtil { Integer _i = ConstantUtil.getNumberFormatMap(fa); switch (t) { - case "s": { - // 字符串 - if (_i >= 0) { - style.setDataFormat(_i.shortValue()); - } - else { - style.setDataFormat((short) 0); - } - cell.setCellType(org.apache.poi.ss.usermodel.CellType.STRING); - break; - } - case "d": { - // 日期 - Date _d = null; - String v = getByDBObject(dbObject, "m"); - if (v.length() == 0) { - v = getByDBObject(dbObject, "v"); - } - if (v.length() > 0) { - if (v.indexOf("-") > -1) { - if (v.indexOf(":") > -1) { - _d = ConstantUtil.stringToDateTime(v); - } - else { - _d = ConstantUtil.stringToDate(v); - } - } - else { - _d = ConstantUtil.toDate(v); - } - } - if (_d != null) { - // 能转换为日期 - cell.setCellValue(_d); - DataFormat format = wb.createDataFormat(); - style.setDataFormat(format.getFormat(fa)); - - } - else { - // 不能转换为日期 + case "s": { + // 字符串 if (_i >= 0) { style.setDataFormat(_i.shortValue()); } else { style.setDataFormat((short) 0); } + cell.setCellType(org.apache.poi.ss.usermodel.CellType.STRING); + break; } - break; - } - case "b": { - // 逻辑 - cell.setCellType(org.apache.poi.ss.usermodel.CellType.BOOLEAN); - if (_i >= 0) { - style.setDataFormat(_i.shortValue()); + case "d": { + // 日期 + Date _d = null; + String v = getByDBObject(dbObject, "m"); + if (v.length() == 0) { + v = getByDBObject(dbObject, "v"); + } + if (v.length() > 0) { + if (v.indexOf("-") > -1) { + if (v.indexOf(":") > -1) { + _d = ConstantUtil.stringToDateTime(v); + } + else { + _d = ConstantUtil.stringToDate(v); + } + } + else { + _d = ConstantUtil.toDate(v); + } + } + if (_d != null) { + // 能转换为日期 + cell.setCellValue(_d); + DataFormat format = wb.createDataFormat(); + style.setDataFormat(format.getFormat(fa)); + + } + else { + // 不能转换为日期 + if (_i >= 0) { + style.setDataFormat(_i.shortValue()); + } + else { + style.setDataFormat((short) 0); + } + } + break; } - else { - DataFormat format = wb.createDataFormat(); - style.setDataFormat(format.getFormat(fa)); + case "b": { + // 逻辑 + cell.setCellType(org.apache.poi.ss.usermodel.CellType.BOOLEAN); + if (_i >= 0) { + style.setDataFormat(_i.shortValue()); + } + else { + DataFormat format = wb.createDataFormat(); + style.setDataFormat(format.getFormat(fa)); + } + break; } - break; - } - case "n": { - // 数值 - // cell.setCellType(CellType.NUMERIC); - // 数字转字符串 - cell.setCellType(org.apache.poi.ss.usermodel.CellType.STRING); - if (_i >= 0) { - style.setDataFormat(_i.shortValue()); + case "n": { + // 数值 + // cell.setCellType(CellType.NUMERIC); + // 数字转字符串 + cell.setCellType(org.apache.poi.ss.usermodel.CellType.STRING); + if (_i >= 0) { + style.setDataFormat(_i.shortValue()); + } + else { + DataFormat format = wb.createDataFormat(); + style.setDataFormat(format.getFormat(fa)); + } + break; } - else { - DataFormat format = wb.createDataFormat(); - style.setDataFormat(format.getFormat(fa)); + case "u": + case "g": { + // general 自动类型 + // cell.setCellType(CellType._NONE); + if (_i >= 0) { + style.setDataFormat(_i.shortValue()); + } + else { + DataFormat format = wb.createDataFormat(); + style.setDataFormat(format.getFormat(fa)); + } + break; } - break; - } - case "u": - case "g": { - // general 自动类型 - // cell.setCellType(CellType._NONE); - if (_i >= 0) { - style.setDataFormat(_i.shortValue()); + case "e": { + // 错误 + cell.setCellType(org.apache.poi.ss.usermodel.CellType.ERROR); + if (_i >= 0) { + style.setDataFormat(_i.shortValue()); + } + else { + DataFormat format = wb.createDataFormat(); + style.setDataFormat(format.getFormat(fa)); + } + break; } - else { - DataFormat format = wb.createDataFormat(); - style.setDataFormat(format.getFormat(fa)); - } - break; - } - case "e": { - // 错误 - cell.setCellType(org.apache.poi.ss.usermodel.CellType.ERROR); - if (_i >= 0) { - style.setDataFormat(_i.shortValue()); - } - else { - DataFormat format = wb.createDataFormat(); - style.setDataFormat(format.getFormat(fa)); - } - break; - } } diff --git a/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/util/XlsUtil.java b/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/util/XlsUtil.java index e6eeb14e3..3ff4962b7 100644 --- a/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/util/XlsUtil.java +++ b/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/util/XlsUtil.java @@ -164,29 +164,29 @@ public class XlsUtil { dataModel.put("r", row.getRowNum()); // 获取单元格内容 switch (cell.getCellType()) { - case STRING: - dataModel.getJSONObject("v").put("m", cell.getStringCellValue()); - dataModel.getJSONObject("v").put("v", cell.getStringCellValue()); - break; - case NUMERIC: - dataModel.getJSONObject("v").put("m", cell.getNumericCellValue()); - dataModel.getJSONObject("v").put("v", cell.getNumericCellValue()); - break; - case BLANK: - dataModel.getJSONObject("v").put("m", ""); - dataModel.getJSONObject("v").put("v", ""); - break; - case BOOLEAN: - dataModel.getJSONObject("v").put("m", cell.getBooleanCellValue()); - dataModel.getJSONObject("v").put("v", cell.getBooleanCellValue()); - break; - case ERROR: - dataModel.getJSONObject("v").put("m", cell.getErrorCellValue()); - dataModel.getJSONObject("v").put("v", cell.getErrorCellValue()); - break; - default: - dataModel.getJSONObject("v").put("m", ""); - dataModel.getJSONObject("v").put("v", ""); + case STRING: + dataModel.getJSONObject("v").put("m", cell.getStringCellValue()); + dataModel.getJSONObject("v").put("v", cell.getStringCellValue()); + break; + case NUMERIC: + dataModel.getJSONObject("v").put("m", cell.getNumericCellValue()); + dataModel.getJSONObject("v").put("v", cell.getNumericCellValue()); + break; + case BLANK: + dataModel.getJSONObject("v").put("m", ""); + dataModel.getJSONObject("v").put("v", ""); + break; + case BOOLEAN: + dataModel.getJSONObject("v").put("m", cell.getBooleanCellValue()); + dataModel.getJSONObject("v").put("v", cell.getBooleanCellValue()); + break; + case ERROR: + dataModel.getJSONObject("v").put("m", cell.getErrorCellValue()); + dataModel.getJSONObject("v").put("v", cell.getErrorCellValue()); + break; + default: + dataModel.getJSONObject("v").put("m", ""); + dataModel.getJSONObject("v").put("v", ""); } // 设置单元格合并标记 dealWithCellMarge(rangeMap, row, cell, dataModel); diff --git a/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/service/impl/ReportShareServiceImpl.java b/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/service/impl/ReportShareServiceImpl.java index 09b3f7ef9..9c9db0d45 100644 --- a/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/service/impl/ReportShareServiceImpl.java +++ b/pigx-visual/pigx-report-platform/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/service/impl/ReportShareServiceImpl.java @@ -89,12 +89,12 @@ public class ReportShareServiceImpl implements ReportShareService { @Override public void processBeforeOperation(ReportShare entity, BaseOperationEnum operationEnum) throws BusinessException { switch (operationEnum) { - case INSERT: - init(entity); - break; - default: + case INSERT: + init(entity); + break; + default: - break; + break; } } diff --git a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/coordinator/DefaultCore.java b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/coordinator/DefaultCore.java index 94130b3df..45492891e 100644 --- a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/coordinator/DefaultCore.java +++ b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/coordinator/DefaultCore.java @@ -212,39 +212,39 @@ public class DefaultCore implements Core { branchSession); switch (branchStatus) { - case PhaseTwo_Committed: - globalSession.removeBranch(branchSession); - return CONTINUE; - case PhaseTwo_CommitFailed_Unretryable: - if (globalSession.canBeCommittedAsync()) { - LOGGER.error( - "Committing branch transaction[{}], status: PhaseTwo_CommitFailed_Unretryable, please check the business log.", - branchSession.getBranchId()); + case PhaseTwo_Committed: + globalSession.removeBranch(branchSession); return CONTINUE; - } - else { - SessionHelper.endCommitFailed(globalSession); - LOGGER.error( - "Committing global transaction[{}] finally failed, caused by branch transaction[{}] commit failed.", - globalSession.getXid(), branchSession.getBranchId()); - return false; - } - default: - if (!retrying) { - globalSession.queueToRetryCommit(); - return false; - } - if (globalSession.canBeCommittedAsync()) { - LOGGER.error("Committing branch transaction[{}], status:{} and will retry later", - branchSession.getBranchId(), branchStatus); - return CONTINUE; - } - else { - LOGGER.error( - "Committing global transaction[{}] failed, caused by branch transaction[{}] commit failed, will retry later.", - globalSession.getXid(), branchSession.getBranchId()); - return false; - } + case PhaseTwo_CommitFailed_Unretryable: + if (globalSession.canBeCommittedAsync()) { + LOGGER.error( + "Committing branch transaction[{}], status: PhaseTwo_CommitFailed_Unretryable, please check the business log.", + branchSession.getBranchId()); + return CONTINUE; + } + else { + SessionHelper.endCommitFailed(globalSession); + LOGGER.error( + "Committing global transaction[{}] finally failed, caused by branch transaction[{}] commit failed.", + globalSession.getXid(), branchSession.getBranchId()); + return false; + } + default: + if (!retrying) { + globalSession.queueToRetryCommit(); + return false; + } + if (globalSession.canBeCommittedAsync()) { + LOGGER.error("Committing branch transaction[{}], status:{} and will retry later", + branchSession.getBranchId(), branchStatus); + return CONTINUE; + } + else { + LOGGER.error( + "Committing global transaction[{}] failed, caused by branch transaction[{}] commit failed, will retry later.", + globalSession.getXid(), branchSession.getBranchId()); + return false; + } } } catch (Exception ex) { @@ -331,23 +331,23 @@ public class DefaultCore implements Core { try { BranchStatus branchStatus = branchRollback(globalSession, branchSession); switch (branchStatus) { - case PhaseTwo_Rollbacked: - globalSession.removeBranch(branchSession); - LOGGER.info("Rollback branch transaction successfully, xid = {} branchId = {}", - globalSession.getXid(), branchSession.getBranchId()); - return CONTINUE; - case PhaseTwo_RollbackFailed_Unretryable: - SessionHelper.endRollbackFailed(globalSession); - LOGGER.info("Rollback branch transaction fail and stop retry, xid = {} branchId = {}", - globalSession.getXid(), branchSession.getBranchId()); - return false; - default: - LOGGER.info("Rollback branch transaction fail and will retry, xid = {} branchId = {}", - globalSession.getXid(), branchSession.getBranchId()); - if (!retrying) { - globalSession.queueToRetryRollback(); - } - return false; + case PhaseTwo_Rollbacked: + globalSession.removeBranch(branchSession); + LOGGER.info("Rollback branch transaction successfully, xid = {} branchId = {}", + globalSession.getXid(), branchSession.getBranchId()); + return CONTINUE; + case PhaseTwo_RollbackFailed_Unretryable: + SessionHelper.endRollbackFailed(globalSession); + LOGGER.info("Rollback branch transaction fail and stop retry, xid = {} branchId = {}", + globalSession.getXid(), branchSession.getBranchId()); + return false; + default: + LOGGER.info("Rollback branch transaction fail and will retry, xid = {} branchId = {}", + globalSession.getXid(), branchSession.getBranchId()); + if (!retrying) { + globalSession.queueToRetryRollback(); + } + return false; } } catch (Exception ex) { diff --git a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/session/SessionHolder.java b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/session/SessionHolder.java index bf03ed979..6393eeda6 100644 --- a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/session/SessionHolder.java +++ b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/session/SessionHolder.java @@ -159,45 +159,45 @@ public class SessionHolder { GlobalSession globalSession = iterator.next(); GlobalStatus globalStatus = globalSession.getStatus(); switch (globalStatus) { - case UnKnown: - case Committed: - case CommitFailed: - case Rollbacked: - case RollbackFailed: - case TimeoutRollbacked: - case TimeoutRollbackFailed: - case Finished: - removeGlobalSessions.add(globalSession); - break; - case AsyncCommitting: - if (storeMode == StoreMode.FILE) { - queueToAsyncCommitting(globalSession); - } - break; - default: { - if (storeMode == StoreMode.FILE) { - lockBranchSessions(globalSession.getSortedBranches()); - - switch (globalStatus) { - case Committing: - case CommitRetrying: - queueToRetryCommit(globalSession); - break; - case Rollbacking: - case RollbackRetrying: - case TimeoutRollbacking: - case TimeoutRollbackRetrying: - queueToRetryRollback(globalSession); - break; - case Begin: - globalSession.setActive(true); - break; - default: - throw new ShouldNeverHappenException("NOT properly handled " + globalStatus); + case UnKnown: + case Committed: + case CommitFailed: + case Rollbacked: + case RollbackFailed: + case TimeoutRollbacked: + case TimeoutRollbackFailed: + case Finished: + removeGlobalSessions.add(globalSession); + break; + case AsyncCommitting: + if (storeMode == StoreMode.FILE) { + queueToAsyncCommitting(globalSession); } + break; + default: { + if (storeMode == StoreMode.FILE) { + lockBranchSessions(globalSession.getSortedBranches()); + + switch (globalStatus) { + case Committing: + case CommitRetrying: + queueToRetryCommit(globalSession); + break; + case Rollbacking: + case RollbackRetrying: + case TimeoutRollbacking: + case TimeoutRollbackRetrying: + queueToRetryRollback(globalSession); + break; + case Begin: + globalSession.setActive(true); + break; + default: + throw new ShouldNeverHappenException("NOT properly handled " + globalStatus); + } + } + break; } - break; - } } } for (GlobalSession globalSession : removeGlobalSessions) { diff --git a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/storage/file/TransactionWriteStore.java b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/storage/file/TransactionWriteStore.java index 881abdc9c..315d21dac 100644 --- a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/storage/file/TransactionWriteStore.java +++ b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/storage/file/TransactionWriteStore.java @@ -109,18 +109,18 @@ public class TransactionWriteStore implements SessionStorable { private SessionStorable getSessionInstanceByOperation(LogOperation logOperation) { SessionStorable sessionStorable = null; switch (logOperation) { - case GLOBAL_ADD: - case GLOBAL_UPDATE: - case GLOBAL_REMOVE: - sessionStorable = new GlobalSession(); - break; - case BRANCH_ADD: - case BRANCH_UPDATE: - case BRANCH_REMOVE: - sessionStorable = new BranchSession(); - break; - default: - throw new ShouldNeverHappenException("incorrect logOperation"); + case GLOBAL_ADD: + case GLOBAL_UPDATE: + case GLOBAL_REMOVE: + sessionStorable = new GlobalSession(); + break; + case BRANCH_ADD: + case BRANCH_UPDATE: + case BRANCH_REMOVE: + sessionStorable = new BranchSession(); + break; + default: + throw new ShouldNeverHappenException("incorrect logOperation"); } return sessionStorable; } diff --git a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/storage/file/session/FileSessionManager.java b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/storage/file/session/FileSessionManager.java index f0016fd86..e19dd488a 100644 --- a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/storage/file/session/FileSessionManager.java +++ b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/storage/file/session/FileSessionManager.java @@ -180,17 +180,17 @@ public class FileSessionManager extends AbstractSessionManager implements Reload private boolean checkSessionStatus(GlobalSession globalSession) { GlobalStatus globalStatus = globalSession.getStatus(); switch (globalStatus) { - case UnKnown: - case Committed: - case CommitFailed: - case Rollbacked: - case RollbackFailed: - case TimeoutRollbacked: - case TimeoutRollbackFailed: - case Finished: - return false; - default: - return true; + case UnKnown: + case Committed: + case CommitFailed: + case Rollbacked: + case RollbackFailed: + case TimeoutRollbacked: + case TimeoutRollbackFailed: + case Finished: + return false; + default: + return true; } } @@ -212,119 +212,119 @@ public class FileSessionManager extends AbstractSessionManager implements Reload TransactionStoreManager.LogOperation logOperation = store.getOperate(); SessionStorable sessionStorable = store.getSessionRequest(); switch (logOperation) { - case GLOBAL_ADD: - case GLOBAL_UPDATE: { - GlobalSession globalSession = (GlobalSession) sessionStorable; - if (globalSession.getTransactionId() == 0) { - LOGGER.error("Restore globalSession from file failed, the transactionId is zero , xid:" - + globalSession.getXid()); - break; - } - if (removedGlobalBuffer.contains(globalSession.getXid())) { - break; - } - GlobalSession foundGlobalSession = sessionMap.get(globalSession.getXid()); - if (foundGlobalSession == null) { - if (this.checkSessionStatus(globalSession)) { - sessionMap.put(globalSession.getXid(), globalSession); + case GLOBAL_ADD: + case GLOBAL_UPDATE: { + GlobalSession globalSession = (GlobalSession) sessionStorable; + if (globalSession.getTransactionId() == 0) { + LOGGER.error("Restore globalSession from file failed, the transactionId is zero , xid:" + + globalSession.getXid()); + break; } - else { - removedGlobalBuffer.add(globalSession.getXid()); - unhandledBranchBuffer.remove(globalSession.getXid()); + if (removedGlobalBuffer.contains(globalSession.getXid())) { + break; } - } - else { - if (this.checkSessionStatus(globalSession)) { - foundGlobalSession.setStatus(globalSession.getStatus()); - } - else { - sessionMap.remove(globalSession.getXid()); - removedGlobalBuffer.add(globalSession.getXid()); - unhandledBranchBuffer.remove(globalSession.getXid()); - } - } - break; - } - case GLOBAL_REMOVE: { - GlobalSession globalSession = (GlobalSession) sessionStorable; - if (globalSession.getTransactionId() == 0) { - LOGGER.error("Restore globalSession from file failed, the transactionId is zero , xid:" - + globalSession.getXid()); - break; - } - if (removedGlobalBuffer.contains(globalSession.getXid())) { - break; - } - if (sessionMap.remove(globalSession.getXid()) == null) { - if (LOGGER.isInfoEnabled()) { - LOGGER.info("GlobalSession To Be Removed Does Not Exists [" + globalSession.getXid() + "]"); - } - } - removedGlobalBuffer.add(globalSession.getXid()); - unhandledBranchBuffer.remove(globalSession.getXid()); - break; - } - case BRANCH_ADD: - case BRANCH_UPDATE: { - BranchSession branchSession = (BranchSession) sessionStorable; - if (branchSession.getTransactionId() == 0) { - LOGGER.error("Restore branchSession from file failed, the transactionId is zero , xid:" - + branchSession.getXid()); - break; - } - if (removedGlobalBuffer.contains(branchSession.getXid())) { - break; - } - GlobalSession foundGlobalSession = sessionMap.get(branchSession.getXid()); - if (foundGlobalSession == null) { - unhandledBranchBuffer.computeIfAbsent(branchSession.getXid(), key -> new HashMap<>()) - .put(branchSession.getBranchId(), branchSession); - } - else { - BranchSession existingBranch = foundGlobalSession.getBranch(branchSession.getBranchId()); - if (existingBranch == null) { - foundGlobalSession.add(branchSession); - } - else { - existingBranch.setStatus(branchSession.getStatus()); - } - } - break; - } - case BRANCH_REMOVE: { - BranchSession branchSession = (BranchSession) sessionStorable; - String xid = branchSession.getXid(); - if (removedGlobalBuffer.contains(xid)) { - break; - } - long bid = branchSession.getBranchId(); - if (branchSession.getTransactionId() == 0) { - LOGGER.error("Restore branchSession from file failed, the transactionId is zero , xid:" - + branchSession.getXid()); - break; - } - GlobalSession found = sessionMap.get(xid); - if (found == null) { - if (LOGGER.isInfoEnabled()) { - LOGGER.info("GlobalSession To Be Updated (Remove Branch) Does Not Exists [" + bid + "/" + xid - + "]"); - } - } - else { - BranchSession theBranch = found.getBranch(bid); - if (theBranch == null) { - if (LOGGER.isInfoEnabled()) { - LOGGER.info("BranchSession To Be Updated Does Not Exists [" + bid + "/" + xid + "]"); + GlobalSession foundGlobalSession = sessionMap.get(globalSession.getXid()); + if (foundGlobalSession == null) { + if (this.checkSessionStatus(globalSession)) { + sessionMap.put(globalSession.getXid(), globalSession); + } + else { + removedGlobalBuffer.add(globalSession.getXid()); + unhandledBranchBuffer.remove(globalSession.getXid()); } } else { - found.remove(theBranch); + if (this.checkSessionStatus(globalSession)) { + foundGlobalSession.setStatus(globalSession.getStatus()); + } + else { + sessionMap.remove(globalSession.getXid()); + removedGlobalBuffer.add(globalSession.getXid()); + unhandledBranchBuffer.remove(globalSession.getXid()); + } } + break; } - break; - } - default: - throw new ShouldNeverHappenException("Unknown Operation: " + logOperation); + case GLOBAL_REMOVE: { + GlobalSession globalSession = (GlobalSession) sessionStorable; + if (globalSession.getTransactionId() == 0) { + LOGGER.error("Restore globalSession from file failed, the transactionId is zero , xid:" + + globalSession.getXid()); + break; + } + if (removedGlobalBuffer.contains(globalSession.getXid())) { + break; + } + if (sessionMap.remove(globalSession.getXid()) == null) { + if (LOGGER.isInfoEnabled()) { + LOGGER.info("GlobalSession To Be Removed Does Not Exists [" + globalSession.getXid() + "]"); + } + } + removedGlobalBuffer.add(globalSession.getXid()); + unhandledBranchBuffer.remove(globalSession.getXid()); + break; + } + case BRANCH_ADD: + case BRANCH_UPDATE: { + BranchSession branchSession = (BranchSession) sessionStorable; + if (branchSession.getTransactionId() == 0) { + LOGGER.error("Restore branchSession from file failed, the transactionId is zero , xid:" + + branchSession.getXid()); + break; + } + if (removedGlobalBuffer.contains(branchSession.getXid())) { + break; + } + GlobalSession foundGlobalSession = sessionMap.get(branchSession.getXid()); + if (foundGlobalSession == null) { + unhandledBranchBuffer.computeIfAbsent(branchSession.getXid(), key -> new HashMap<>()) + .put(branchSession.getBranchId(), branchSession); + } + else { + BranchSession existingBranch = foundGlobalSession.getBranch(branchSession.getBranchId()); + if (existingBranch == null) { + foundGlobalSession.add(branchSession); + } + else { + existingBranch.setStatus(branchSession.getStatus()); + } + } + break; + } + case BRANCH_REMOVE: { + BranchSession branchSession = (BranchSession) sessionStorable; + String xid = branchSession.getXid(); + if (removedGlobalBuffer.contains(xid)) { + break; + } + long bid = branchSession.getBranchId(); + if (branchSession.getTransactionId() == 0) { + LOGGER.error("Restore branchSession from file failed, the transactionId is zero , xid:" + + branchSession.getXid()); + break; + } + GlobalSession found = sessionMap.get(xid); + if (found == null) { + if (LOGGER.isInfoEnabled()) { + LOGGER.info("GlobalSession To Be Updated (Remove Branch) Does Not Exists [" + bid + "/" + + xid + "]"); + } + } + else { + BranchSession theBranch = found.getBranch(bid); + if (theBranch == null) { + if (LOGGER.isInfoEnabled()) { + LOGGER.info("BranchSession To Be Updated Does Not Exists [" + bid + "/" + xid + "]"); + } + } + else { + found.remove(theBranch); + } + } + break; + } + default: + throw new ShouldNeverHappenException("Unknown Operation: " + logOperation); } } diff --git a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/transaction/saga/SagaCore.java b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/transaction/saga/SagaCore.java index 51a668708..6fa31b097 100644 --- a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/transaction/saga/SagaCore.java +++ b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/transaction/saga/SagaCore.java @@ -106,46 +106,47 @@ public class SagaCore extends AbstractCore { globalSession.getXid(), -1, getSagaResourceId(globalSession), globalSession.getStatus().name())); switch (branchStatus) { - case PhaseTwo_Committed: - removeAllBranches(globalSession); - LOGGER.info("Successfully committed SAGA global[" + globalSession.getXid() + "]"); - break; - case PhaseTwo_Rollbacked: - LOGGER.info("Successfully rollbacked SAGA global[" + globalSession.getXid() + "]"); - removeAllBranches(globalSession); - SessionHelper.endRollbacked(globalSession); - return false; - case PhaseTwo_RollbackFailed_Retryable: - LOGGER.error("By [{}], failed to rollback SAGA global [{}], will retry later.", branchStatus, - globalSession.getXid()); - SessionHolder.getRetryCommittingSessionManager().removeGlobalSession(globalSession); - globalSession.queueToRetryRollback(); - return false; - case PhaseOne_Failed: - LOGGER.error("By [{}], finish SAGA global [{}]", branchStatus, globalSession.getXid()); - removeAllBranches(globalSession); - globalSession.changeStatus(GlobalStatus.Finished); - globalSession.end(); - return false; - case PhaseTwo_CommitFailed_Unretryable: - if (globalSession.canBeCommittedAsync()) { - LOGGER.error("By [{}], failed to commit SAGA global [{}]", branchStatus, globalSession.getXid()); + case PhaseTwo_Committed: + removeAllBranches(globalSession); + LOGGER.info("Successfully committed SAGA global[" + globalSession.getXid() + "]"); break; - } - else { - SessionHelper.endCommitFailed(globalSession); - LOGGER.error("Finally, failed to commit SAGA global[{}]", globalSession.getXid()); + case PhaseTwo_Rollbacked: + LOGGER.info("Successfully rollbacked SAGA global[" + globalSession.getXid() + "]"); + removeAllBranches(globalSession); + SessionHelper.endRollbacked(globalSession); return false; - } - default: - if (!retrying) { - globalSession.queueToRetryCommit(); + case PhaseTwo_RollbackFailed_Retryable: + LOGGER.error("By [{}], failed to rollback SAGA global [{}], will retry later.", branchStatus, + globalSession.getXid()); + SessionHolder.getRetryCommittingSessionManager().removeGlobalSession(globalSession); + globalSession.queueToRetryRollback(); return false; - } - else { - LOGGER.error("Failed to commit SAGA global[{}], will retry later.", globalSession.getXid()); + case PhaseOne_Failed: + LOGGER.error("By [{}], finish SAGA global [{}]", branchStatus, globalSession.getXid()); + removeAllBranches(globalSession); + globalSession.changeStatus(GlobalStatus.Finished); + globalSession.end(); return false; - } + case PhaseTwo_CommitFailed_Unretryable: + if (globalSession.canBeCommittedAsync()) { + LOGGER.error("By [{}], failed to commit SAGA global [{}]", branchStatus, + globalSession.getXid()); + break; + } + else { + SessionHelper.endCommitFailed(globalSession); + LOGGER.error("Finally, failed to commit SAGA global[{}]", globalSession.getXid()); + return false; + } + default: + if (!retrying) { + globalSession.queueToRetryCommit(); + return false; + } + else { + LOGGER.error("Failed to commit SAGA global[{}], will retry later.", globalSession.getXid()); + return false; + } } } catch (Exception ex) { @@ -166,26 +167,26 @@ public class SagaCore extends AbstractCore { globalSession.getXid(), -1, getSagaResourceId(globalSession), globalSession.getStatus().name())); switch (branchStatus) { - case PhaseTwo_Rollbacked: - removeAllBranches(globalSession); - LOGGER.info("Successfully rollbacked SAGA global[{}]", globalSession.getXid()); - break; - case PhaseTwo_RollbackFailed_Unretryable: - SessionHelper.endRollbackFailed(globalSession); - LOGGER.error("Failed to rollback SAGA global[{}]", globalSession.getXid()); - return false; - case PhaseTwo_CommitFailed_Retryable: - SessionHolder.getRetryRollbackingSessionManager().removeGlobalSession(globalSession); - globalSession.queueToRetryCommit(); - LOGGER.warn("Retry by custom recover strategy [Forward] on timeout, SAGA global[{}]", - globalSession.getXid()); - return false; - default: - LOGGER.error("Failed to rollback SAGA global[{}]", globalSession.getXid()); - if (!retrying) { - globalSession.queueToRetryRollback(); - } - return false; + case PhaseTwo_Rollbacked: + removeAllBranches(globalSession); + LOGGER.info("Successfully rollbacked SAGA global[{}]", globalSession.getXid()); + break; + case PhaseTwo_RollbackFailed_Unretryable: + SessionHelper.endRollbackFailed(globalSession); + LOGGER.error("Failed to rollback SAGA global[{}]", globalSession.getXid()); + return false; + case PhaseTwo_CommitFailed_Retryable: + SessionHolder.getRetryRollbackingSessionManager().removeGlobalSession(globalSession); + globalSession.queueToRetryCommit(); + LOGGER.warn("Retry by custom recover strategy [Forward] on timeout, SAGA global[{}]", + globalSession.getXid()); + return false; + default: + LOGGER.error("Failed to rollback SAGA global[{}]", globalSession.getXid()); + if (!retrying) { + globalSession.queueToRetryRollback(); + } + return false; } } catch (Exception ex) { diff --git a/pigx-visual/pigx-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterConfigController.java b/pigx-visual/pigx-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterConfigController.java index f55dae83b..e967900b8 100644 --- a/pigx-visual/pigx-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterConfigController.java +++ b/pigx-visual/pigx-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterConfigController.java @@ -70,25 +70,25 @@ public class ClusterConfigController { if (body.containsKey(KEY_MODE)) { int mode = body.getInteger(KEY_MODE); switch (mode) { - case ClusterStateManager.CLUSTER_CLIENT: - ClusterClientModifyRequest data = JSON.parseObject(payload, ClusterClientModifyRequest.class); - Result res = checkValidRequest(data); - if (res != null) { - return res; - } - clusterConfigService.modifyClusterClientConfig(data).get(); - return Result.ofSuccess(true); - case ClusterStateManager.CLUSTER_SERVER: - ClusterServerModifyRequest d = JSON.parseObject(payload, ClusterServerModifyRequest.class); - Result r = checkValidRequest(d); - if (r != null) { - return r; - } - // TODO: bad design here, should refactor! - clusterConfigService.modifyClusterServerConfig(d).get(); - return Result.ofSuccess(true); - default: - return Result.ofFail(-1, "invalid mode"); + case ClusterStateManager.CLUSTER_CLIENT: + ClusterClientModifyRequest data = JSON.parseObject(payload, ClusterClientModifyRequest.class); + Result res = checkValidRequest(data); + if (res != null) { + return res; + } + clusterConfigService.modifyClusterClientConfig(data).get(); + return Result.ofSuccess(true); + case ClusterStateManager.CLUSTER_SERVER: + ClusterServerModifyRequest d = JSON.parseObject(payload, ClusterServerModifyRequest.class); + Result r = checkValidRequest(d); + if (r != null) { + return r; + } + // TODO: bad design here, should refactor! + clusterConfigService.modifyClusterServerConfig(d).get(); + return Result.ofSuccess(true); + default: + return Result.ofFail(-1, "invalid mode"); } } return Result.ofFail(-1, "invalid parameter"); diff --git a/pigx-visual/pigx-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/gateway/GatewayFlowRuleEntity.java b/pigx-visual/pigx-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/gateway/GatewayFlowRuleEntity.java index a66a4fa66..eed4463fc 100644 --- a/pigx-visual/pigx-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/gateway/GatewayFlowRuleEntity.java +++ b/pigx-visual/pigx-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/gateway/GatewayFlowRuleEntity.java @@ -78,16 +78,16 @@ public class GatewayFlowRuleEntity implements RuleEntity { public static Long calIntervalSec(Long interval, Integer intervalUnit) { switch (intervalUnit) { - case INTERVAL_UNIT_SECOND: - return interval; - case INTERVAL_UNIT_MINUTE: - return interval * 60; - case INTERVAL_UNIT_HOUR: - return interval * 60 * 60; - case INTERVAL_UNIT_DAY: - return interval * 60 * 60 * 24; - default: - break; + case INTERVAL_UNIT_SECOND: + return interval; + case INTERVAL_UNIT_MINUTE: + return interval * 60; + case INTERVAL_UNIT_HOUR: + return interval * 60 * 60; + case INTERVAL_UNIT_DAY: + return interval * 60 * 60 * 24; + default: + break; } throw new IllegalArgumentException("Invalid intervalUnit: " + intervalUnit); diff --git a/pigx-visual/pigx-xxl-job-admin/src/main/java/com/xxl/job/admin/core/cron/CronExpression.java b/pigx-visual/pigx-xxl-job-admin/src/main/java/com/xxl/job/admin/core/cron/CronExpression.java index f52677fa6..2f8669bda 100755 --- a/pigx-visual/pigx-xxl-job-admin/src/main/java/com/xxl/job/admin/core/cron/CronExpression.java +++ b/pigx-visual/pigx-xxl-job-admin/src/main/java/com/xxl/job/admin/core/cron/CronExpression.java @@ -1073,28 +1073,28 @@ public final class CronExpression implements Serializable, Cloneable { int max = -1; if (stopAt < startAt) { switch (type) { - case SECOND: - max = 60; - break; - case MINUTE: - max = 60; - break; - case HOUR: - max = 24; - break; - case MONTH: - max = 12; - break; - case DAY_OF_WEEK: - max = 7; - break; - case DAY_OF_MONTH: - max = 31; - break; - case YEAR: - throw new IllegalArgumentException("Start year must be less than stop year"); - default: - throw new IllegalArgumentException("Unexpected type encountered"); + case SECOND: + max = 60; + break; + case MINUTE: + max = 60; + break; + case HOUR: + max = 24; + break; + case MONTH: + max = 12; + break; + case DAY_OF_WEEK: + max = 7; + break; + case DAY_OF_MONTH: + max = 31; + break; + case YEAR: + throw new IllegalArgumentException("Start year must be less than stop year"); + default: + throw new IllegalArgumentException("Unexpected type encountered"); } stopAt += max; } @@ -1120,22 +1120,22 @@ public final class CronExpression implements Serializable, Cloneable { TreeSet getSet(int type) { switch (type) { - case SECOND: - return seconds; - case MINUTE: - return minutes; - case HOUR: - return hours; - case DAY_OF_MONTH: - return daysOfMonth; - case MONTH: - return months; - case DAY_OF_WEEK: - return daysOfWeek; - case YEAR: - return years; - default: - return null; + case SECOND: + return seconds; + case MINUTE: + return minutes; + case HOUR: + return hours; + case DAY_OF_MONTH: + return daysOfMonth; + case MONTH: + return months; + case DAY_OF_WEEK: + return daysOfWeek; + case YEAR: + return years; + default: + return null; } } @@ -1651,32 +1651,32 @@ public final class CronExpression implements Serializable, Cloneable { protected int getLastDayOfMonth(int monthNum, int year) { switch (monthNum) { - case 1: - return 31; - case 2: - return (isLeapYear(year)) ? 29 : 28; - case 3: - return 31; - case 4: - return 30; - case 5: - return 31; - case 6: - return 30; - case 7: - return 31; - case 8: - return 31; - case 9: - return 30; - case 10: - return 31; - case 11: - return 30; - case 12: - return 31; - default: - throw new IllegalArgumentException("Illegal month number: " + monthNum); + case 1: + return 31; + case 2: + return (isLeapYear(year)) ? 29 : 28; + case 3: + return 31; + case 4: + return 30; + case 5: + return 31; + case 6: + return 30; + case 7: + return 31; + case 8: + return 31; + case 9: + return 30; + case 10: + return 31; + case 11: + return 30; + case 12: + return 31; + default: + throw new IllegalArgumentException("Illegal month number: " + monthNum); } }