|
@@ -49,7 +49,7 @@ import cn.com.qmth.examcloud.web.jpa.PageUtils;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class OrgIpServiceImpl implements OrgIpService {
|
|
public class OrgIpServiceImpl implements OrgIpService {
|
|
- private static final Logger log = LoggerFactory.getLogger(OrgIpService.class);
|
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(OrgIpService.class);
|
|
private static final String[] EXCEL_HEADER = new String[] { "IP/IP段", "学习中心代码", "学习中心名称", "备注" };
|
|
private static final String[] EXCEL_HEADER = new String[] { "IP/IP段", "学习中心代码", "学习中心名称", "备注" };
|
|
@Autowired
|
|
@Autowired
|
|
private OrgIpRepo orgIpRepo;
|
|
private OrgIpRepo orgIpRepo;
|
|
@@ -175,21 +175,23 @@ public class OrgIpServiceImpl implements OrgIpService {
|
|
if (ss1.length != 4) {
|
|
if (ss1.length != 4) {
|
|
throw new StatusException("ip格式错误");
|
|
throw new StatusException("ip格式错误");
|
|
}
|
|
}
|
|
- for (String s : ss1) {
|
|
|
|
- if (s.indexOf("-") != -1) {
|
|
|
|
- String[] ss2 = ip.split("-");
|
|
|
|
- if (ss2.length != 2) {
|
|
|
|
- throw new StatusException("ip段格式错误");
|
|
|
|
- }
|
|
|
|
- for (String s2 : ss2) {
|
|
|
|
- checkIpNumber(s2);
|
|
|
|
- }
|
|
|
|
- if (Integer.valueOf(ss2[0]) >= Integer.valueOf(ss2[1])) {
|
|
|
|
- throw new StatusException("ip段格式错误,起始数值必须小于截止数值");
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- checkIpNumber(s);
|
|
|
|
|
|
+ for (int i = 0; i <= 2; i++) {
|
|
|
|
+ checkIpNumber(ss1[i]);
|
|
|
|
+ }
|
|
|
|
+ String s = ss1[3];
|
|
|
|
+ if (s.indexOf("-") != -1) {
|
|
|
|
+ String[] ss2 = ip.split("-");
|
|
|
|
+ if (ss2.length != 2) {
|
|
|
|
+ throw new StatusException("ip段格式错误");
|
|
|
|
+ }
|
|
|
|
+ for (String s2 : ss2) {
|
|
|
|
+ checkIpNumber(s2);
|
|
}
|
|
}
|
|
|
|
+ if (Integer.valueOf(ss2[0]) >= Integer.valueOf(ss2[1])) {
|
|
|
|
+ throw new StatusException("ip段格式错误,起始数值必须小于截止数值");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ checkIpNumber(s);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -210,9 +212,9 @@ public class OrgIpServiceImpl implements OrgIpService {
|
|
orgIpRepo.delete(ids, rootOrgId);
|
|
orgIpRepo.delete(ids, rootOrgId);
|
|
}
|
|
}
|
|
|
|
|
|
- private String newError(int lineNum, String msg) {
|
|
|
|
- return "第"+lineNum+"行 "+msg;
|
|
|
|
- }
|
|
|
|
|
|
+ private String newError(int lineNum, String msg) {
|
|
|
|
+ return "第" + lineNum + "行 " + msg;
|
|
|
|
+ }
|
|
|
|
|
|
private String trimAndNullIfBlank(String s) {
|
|
private String trimAndNullIfBlank(String s) {
|
|
if (StringUtils.isBlank(s)) {
|
|
if (StringUtils.isBlank(s)) {
|
|
@@ -328,13 +330,13 @@ public class OrgIpServiceImpl implements OrgIpService {
|
|
} catch (StatusException e) {
|
|
} catch (StatusException e) {
|
|
failRecords.add(newError(i + 1, e.getDesc()));
|
|
failRecords.add(newError(i + 1, e.getDesc()));
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- failRecords.add(newError(i + 1, "系统异常"));
|
|
|
|
- log.error("IP导入系统异常", e);
|
|
|
|
- }
|
|
|
|
|
|
+ failRecords.add(newError(i + 1, "系统异常"));
|
|
|
|
+ log.error("IP导入系统异常", e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (CollectionUtils.isNotEmpty(failRecords)) {
|
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
}
|
|
}
|
|
- if (CollectionUtils.isNotEmpty(failRecords)) {
|
|
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
|
- }
|
|
|
|
return failRecords;
|
|
return failRecords;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -424,11 +426,11 @@ public class OrgIpServiceImpl implements OrgIpService {
|
|
@Override
|
|
@Override
|
|
public void examAdd(Long rootOrgId, Long examId) {
|
|
public void examAdd(Long rootOrgId, Long examId) {
|
|
ExamEntity exam = GlobalHelper.getPresentEntity(examRepo, examId, ExamEntity.class);
|
|
ExamEntity exam = GlobalHelper.getPresentEntity(examRepo, examId, ExamEntity.class);
|
|
- if(!exam.getRootOrgId().equals(rootOrgId)) {
|
|
|
|
|
|
+ if (!exam.getRootOrgId().equals(rootOrgId)) {
|
|
throw new StatusException("参数错误,考试id非法");
|
|
throw new StatusException("参数错误,考试id非法");
|
|
}
|
|
}
|
|
- List<OrgIpEntity> list=orgIpRepo.findByRootOrgId(rootOrgId);
|
|
|
|
- if(CollectionUtils.isEmpty(list)) {
|
|
|
|
|
|
+ List<OrgIpEntity> list = orgIpRepo.findByRootOrgId(rootOrgId);
|
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
List<OrgIpInfo> ret = new ArrayList<>();
|
|
List<OrgIpInfo> ret = new ArrayList<>();
|