|
@@ -287,11 +287,13 @@ public class AppFunInfoService extends BaseService<AppFunInfo, String> implement
|
|
@Override
|
|
@Override
|
|
public ResponseStatus impExcel(String fileId) {
|
|
public ResponseStatus impExcel(String fileId) {
|
|
try {
|
|
try {
|
|
- fileId = JsonUtils.parseObject(fileId).getString("fileId");
|
|
|
|
DocContentDTO fileContent = uploadhandler.getFileContent(fileId);
|
|
DocContentDTO fileContent = uploadhandler.getFileContent(fileId);
|
|
byte[] fileData = fileContent.getFileData();
|
|
byte[] fileData = fileContent.getFileData();
|
|
InputStream inputStream = new ByteArrayInputStream(fileData);
|
|
InputStream inputStream = new ByteArrayInputStream(fileData);
|
|
List<AppFunInfo> list = loadInfo(inputStream);
|
|
List<AppFunInfo> list = loadInfo(inputStream);
|
|
|
|
+ for (AppFunInfo funInfo: list){
|
|
|
|
+ save(funInfo);
|
|
|
|
+ }
|
|
}catch (IOException e) {
|
|
}catch (IOException e) {
|
|
return ResponseStatus.fail("300","导入文件类型错误");
|
|
return ResponseStatus.fail("300","导入文件类型错误");
|
|
} catch (NumberFormatException e) {
|
|
} catch (NumberFormatException e) {
|
|
@@ -314,6 +316,7 @@ public class AppFunInfoService extends BaseService<AppFunInfo, String> implement
|
|
Workbook wb0 = new HSSFWorkbook(inputStream);
|
|
Workbook wb0 = new HSSFWorkbook(inputStream);
|
|
//获取Excel文档中的第一个表单
|
|
//获取Excel文档中的第一个表单
|
|
Sheet sht0 = wb0.getSheetAt(0);
|
|
Sheet sht0 = wb0.getSheetAt(0);
|
|
|
|
+ List<String> codeList = new ArrayList<>();
|
|
for (Row r : sht0) {
|
|
for (Row r : sht0) {
|
|
if (r.getRowNum() == 0) {
|
|
if (r.getRowNum() == 0) {
|
|
checkRowTitle(r);
|
|
checkRowTitle(r);
|
|
@@ -323,8 +326,11 @@ public class AppFunInfoService extends BaseService<AppFunInfo, String> implement
|
|
AppFunInfo entity = new AppFunInfo();
|
|
AppFunInfo entity = new AppFunInfo();
|
|
for (int i = 0; i < 8; i++) {
|
|
for (int i = 0; i < 8; i++) {
|
|
Cell cell = r.getCell(i);
|
|
Cell cell = r.getCell(i);
|
|
|
|
+ if (cell != null){
|
|
|
|
+ r.getCell(i).setCellType(Cell.CELL_TYPE_STRING);
|
|
|
|
+ }
|
|
checkCellData(cell, i, r.getRowNum());
|
|
checkCellData(cell, i, r.getRowNum());
|
|
- checkCellDataValid(cell, i, r.getRowNum(), entity);
|
|
|
|
|
|
+ checkCellDataValid(cell, i, r.getRowNum(), entity,codeList);
|
|
}
|
|
}
|
|
entity.setCreateTime(new Date());
|
|
entity.setCreateTime(new Date());
|
|
entity.setModifiedTime(new Date());
|
|
entity.setModifiedTime(new Date());
|
|
@@ -343,7 +349,7 @@ public class AppFunInfoService extends BaseService<AppFunInfo, String> implement
|
|
* @param row
|
|
* @param row
|
|
* @param resource
|
|
* @param resource
|
|
*/
|
|
*/
|
|
- private void checkCellDataValid(Cell cell, int num, int row, AppFunInfo resource) {
|
|
|
|
|
|
+ private void checkCellDataValid(Cell cell, int num, int row, AppFunInfo resource, List<String> codeList) {
|
|
if (cell == null)
|
|
if (cell == null)
|
|
return;
|
|
return;
|
|
String value = cell.getStringCellValue();
|
|
String value = cell.getStringCellValue();
|
|
@@ -351,42 +357,55 @@ public class AppFunInfoService extends BaseService<AppFunInfo, String> implement
|
|
case 0:
|
|
case 0:
|
|
ApplyInfo applyInfo = applyInfoFacade.getAppByCode(value);
|
|
ApplyInfo applyInfo = applyInfoFacade.getAppByCode(value);
|
|
if (applyInfo == null){
|
|
if (applyInfo == null){
|
|
- throw new NumberFormatException("第" + (row + 1) + "行''所属应用系统编号''不存在!");
|
|
|
|
|
|
+ throw new NumberFormatException("第" + (row + 1) + "行'所属应用系统编号'不存在!");
|
|
}
|
|
}
|
|
|
|
+
|
|
resource.setAppId(applyInfo.getId());
|
|
resource.setAppId(applyInfo.getId());
|
|
break;
|
|
break;
|
|
case 1:
|
|
case 1:
|
|
if (value.length() > 40) {
|
|
if (value.length() > 40) {
|
|
- throw new NumberFormatException("第" + (row + 1) + "行''功能编号''长度大于40!");
|
|
|
|
|
|
+ throw new NumberFormatException("第" + (row + 1) + "行'功能编号'长度大于40!");
|
|
|
|
+ }
|
|
|
|
+ AppFunInfo appFunInfo = getByAppAndFuncCode(resource.getAppId(), value);
|
|
|
|
+ if (appFunInfo != null){
|
|
|
|
+ throw new NumberFormatException("第" + (row + 1) + "行'功能编号'已存在!");
|
|
|
|
+ }
|
|
|
|
+ if (codeList.contains(resource.getAppId() + value)){
|
|
|
|
+ throw new NumberFormatException("第" + (row + 1) + "行'功能编号'重复!");
|
|
}
|
|
}
|
|
|
|
+ codeList.add(resource.getAppId() + value);
|
|
resource.setCode(value);
|
|
resource.setCode(value);
|
|
break;
|
|
break;
|
|
case 2:
|
|
case 2:
|
|
if (value.length() > 80) {
|
|
if (value.length() > 80) {
|
|
- throw new NumberFormatException("第" + (row + 1) + "行''功能名称''长度大于80!");
|
|
|
|
|
|
+ throw new NumberFormatException("第" + (row + 1) + "行'功能名称'长度大于80!");
|
|
}
|
|
}
|
|
resource.setName(value);
|
|
resource.setName(value);
|
|
break;
|
|
break;
|
|
case 3:
|
|
case 3:
|
|
- AppFunInfo funInfo = appFunInfoBPO.findByCode(value);
|
|
|
|
- if (funInfo == null){
|
|
|
|
- throw new NumberFormatException("第" + (row + 1) + "行''上级功能编号''不存在!");
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(value)){
|
|
|
|
+ AppFunInfo funInfo = appFunInfoBPO.findByCode(value);
|
|
|
|
+ if (funInfo == null){
|
|
|
|
+ throw new NumberFormatException("第" + (row + 1) + "行'上级功能编号'不存在!");
|
|
|
|
+ }
|
|
|
|
+ resource.setParentId(funInfo.getId());
|
|
}
|
|
}
|
|
- resource.setParentId(funInfo.getId());
|
|
|
|
break;
|
|
break;
|
|
case 4:
|
|
case 4:
|
|
- String activeCode = null;
|
|
|
|
- if (value.equals("停用")){
|
|
|
|
- activeCode = "0";
|
|
|
|
- }
|
|
|
|
- if (value.equals("启用")){
|
|
|
|
- activeCode = "1";
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(value)){
|
|
|
|
+ String activeCode = null;
|
|
|
|
+ if (value.equals("停用")){
|
|
|
|
+ activeCode = "0";
|
|
|
|
+ }
|
|
|
|
+ if (value.equals("启用")){
|
|
|
|
+ activeCode = "1";
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(activeCode)){
|
|
|
|
+ throw new NumberFormatException("第" + (row + 1) + "行'在用状态'不存在!");
|
|
|
|
+ }
|
|
|
|
+ resource.setIsActive(activeCode);
|
|
}
|
|
}
|
|
- if (StringUtils.isBlank(activeCode)){
|
|
|
|
- throw new NumberFormatException("第" + (row + 1) + "行''在用状态''不存在!");
|
|
|
|
- }
|
|
|
|
- resource.setIsActive(activeCode);
|
|
|
|
break;
|
|
break;
|
|
case 5:
|
|
case 5:
|
|
String code = "";
|
|
String code = "";
|
|
@@ -396,21 +415,21 @@ public class AppFunInfoService extends BaseService<AppFunInfo, String> implement
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (StringUtils.isBlank(code)){
|
|
if (StringUtils.isBlank(code)){
|
|
- throw new NumberFormatException("第" + (row + 1) + "行''功能使用场景代码''不存在!");
|
|
|
|
|
|
+ throw new NumberFormatException("第" + (row + 1) + "行'功能使用场景代码'不存在!");
|
|
}
|
|
}
|
|
resource.setFunctionUsageScenarios(code);
|
|
resource.setFunctionUsageScenarios(code);
|
|
break;
|
|
break;
|
|
case 6:
|
|
case 6:
|
|
- if (StringUtils.isNotBlank(value)){
|
|
|
|
- String secureTypeEnumCode = "";
|
|
|
|
- for (DesignSecureTypeEnum secureTypeEnum: DesignSecureTypeEnum.values()){
|
|
|
|
- if (value.equals(secureTypeEnum.getLabel())){
|
|
|
|
- secureTypeEnumCode = secureTypeEnum.getValue();
|
|
|
|
- }
|
|
|
|
|
|
+ String secureTypeEnumCode = "";
|
|
|
|
+ for (DesignSecureTypeEnum secureTypeEnum: DesignSecureTypeEnum.values()){
|
|
|
|
+ if (value.equals(secureTypeEnum.getLabel())){
|
|
|
|
+ secureTypeEnumCode = secureTypeEnum.getValue();
|
|
}
|
|
}
|
|
- resource.setDesignSecureType(secureTypeEnumCode);
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ if (StringUtils.isBlank(secureTypeEnumCode)){
|
|
|
|
+ throw new NumberFormatException("第" + (row + 1) + "行'设计安全隐私类别'不存在!");
|
|
|
|
+ }
|
|
|
|
+ resource.setDesignSecureType(secureTypeEnumCode);
|
|
break;
|
|
break;
|
|
case 7:
|
|
case 7:
|
|
resource.setRemark(value);
|
|
resource.setRemark(value);
|
|
@@ -432,21 +451,17 @@ public class AppFunInfoService extends BaseService<AppFunInfo, String> implement
|
|
if (!(cell == null || StringUtils.isBlank(cell.getStringCellValue()))) {
|
|
if (!(cell == null || StringUtils.isBlank(cell.getStringCellValue()))) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- switch (row) {
|
|
|
|
|
|
+ switch (i) {
|
|
case 0:
|
|
case 0:
|
|
- throw new NumberFormatException("第" + (row + 1) + "行''所属应用系统编号''为空!");
|
|
|
|
|
|
+ throw new NumberFormatException("第" + (row + 1) + "行'所属应用系统编号'为空!");
|
|
case 1:
|
|
case 1:
|
|
- throw new NumberFormatException("第" + (row + 1) + "行''功能编号''为空!");
|
|
|
|
|
|
+ throw new NumberFormatException("第" + (row + 1) + "行'功能编号'为空!");
|
|
case 2:
|
|
case 2:
|
|
- throw new NumberFormatException("第" + (row + 1) + "行''功能名称''为空!");
|
|
|
|
- case 3:
|
|
|
|
- throw new NumberFormatException("第" + (row + 1) + "行''上级功能编号''为空!");
|
|
|
|
- case 4:
|
|
|
|
- throw new NumberFormatException("第" + (row + 1) + "行''在用状态''为空!");
|
|
|
|
|
|
+ throw new NumberFormatException("第" + (row + 1) + "行'功能名称'为空!");
|
|
case 5:
|
|
case 5:
|
|
- throw new NumberFormatException("第" + (row + 1) + "行''功能使用场景代码''为空!");
|
|
|
|
- case 7:
|
|
|
|
- throw new NumberFormatException("第" + (row + 1) + "行''功能说明''为空!");
|
|
|
|
|
|
+ throw new NumberFormatException("第" + (row + 1) + "行'功能使用场景代码'为空!");
|
|
|
|
+ case 6:
|
|
|
|
+ throw new NumberFormatException("第" + (row + 1) + "行'设计安全隐私类别'为空!");
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -459,28 +474,28 @@ public class AppFunInfoService extends BaseService<AppFunInfo, String> implement
|
|
*/
|
|
*/
|
|
private static void checkRowTitle(Row r) {
|
|
private static void checkRowTitle(Row r) {
|
|
if (!r.getCell(0).getStringCellValue().equals("所属应用系统编号")) {
|
|
if (!r.getCell(0).getStringCellValue().equals("所属应用系统编号")) {
|
|
- throw new NumberFormatException("缺少''所属应用系统编号''列!");
|
|
|
|
|
|
+ throw new NumberFormatException("缺少'所属应用系统编号'列!");
|
|
}
|
|
}
|
|
if (!r.getCell(1).getStringCellValue().equals("功能编号")) {
|
|
if (!r.getCell(1).getStringCellValue().equals("功能编号")) {
|
|
- throw new NumberFormatException("缺少''功能编号''列!");
|
|
|
|
|
|
+ throw new NumberFormatException("缺少'功能编号'列!");
|
|
}
|
|
}
|
|
if (!r.getCell(2).getStringCellValue().equals("功能名称")) {
|
|
if (!r.getCell(2).getStringCellValue().equals("功能名称")) {
|
|
- throw new NumberFormatException("缺少''功能名称''列!");
|
|
|
|
|
|
+ throw new NumberFormatException("缺少'功能名称'列!");
|
|
}
|
|
}
|
|
if (!r.getCell(3).getStringCellValue().equals("上级功能编号")) {
|
|
if (!r.getCell(3).getStringCellValue().equals("上级功能编号")) {
|
|
- throw new NumberFormatException("缺少''上级功能编号''列!");
|
|
|
|
|
|
+ throw new NumberFormatException("缺少'上级功能编号'列!");
|
|
}
|
|
}
|
|
if (!r.getCell(4).getStringCellValue().equals("在用状态")) {
|
|
if (!r.getCell(4).getStringCellValue().equals("在用状态")) {
|
|
- throw new NumberFormatException("缺少''在用状态''列!");
|
|
|
|
|
|
+ throw new NumberFormatException("缺少'在用状态'列!");
|
|
}
|
|
}
|
|
if (!r.getCell(5).getStringCellValue().equals("功能使用场景代码")) {
|
|
if (!r.getCell(5).getStringCellValue().equals("功能使用场景代码")) {
|
|
- throw new NumberFormatException("缺少''功能使用场景代码''列!");
|
|
|
|
|
|
+ throw new NumberFormatException("缺少'功能使用场景代码'列!");
|
|
}
|
|
}
|
|
if (!r.getCell(6).getStringCellValue().equals("设计安全隐私类别")) {
|
|
if (!r.getCell(6).getStringCellValue().equals("设计安全隐私类别")) {
|
|
- throw new NumberFormatException("缺少''设计安全隐私类别''列!");
|
|
|
|
|
|
+ throw new NumberFormatException("缺少'设计安全隐私类别'列!");
|
|
}
|
|
}
|
|
if (!r.getCell(7).getStringCellValue().equals("功能说明")) {
|
|
if (!r.getCell(7).getStringCellValue().equals("功能说明")) {
|
|
- throw new NumberFormatException("缺少''功能说明''列!");
|
|
|
|
|
|
+ throw new NumberFormatException("缺少'功能说明'列!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|