Browse Source

任务的校验

tags/v1.1.0
qiujinyang 2 years ago
parent
commit
92e679d51f
2 changed files with 28 additions and 14 deletions
  1. +15
    -5
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/MissionController.java
  2. +13
    -9
      tuoheng-common/src/main/java/com/tuoheng/common/utils/IpUtils.java

+ 15
- 5
tuoheng-admin/src/main/java/com/tuoheng/admin/controller/MissionController.java View File

@@ -49,12 +49,22 @@ public class MissionController {

private void checkAddInfo(MissionRequest request) throws ServiceException {
//判断任务名称不能重复
LambdaQueryWrapper<ThMission> lambdaQueryWrapper= new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ThMission::getName, request.getName());
lambdaQueryWrapper.eq(ThMission::getTenantId, ShiroUtils.getTenantId());
List<ThMission> missionList = missionService.getList(lambdaQueryWrapper);
LambdaQueryWrapper<ThMission> lambdaQueryCheckRepartWrapper= new LambdaQueryWrapper<>();
lambdaQueryCheckRepartWrapper.eq(ThMission::getName, request.getName());
lambdaQueryCheckRepartWrapper.eq(ThMission::getTenantId, ShiroUtils.getTenantId());
List<ThMission> missionList = missionService.getList(lambdaQueryCheckRepartWrapper);
if(!ObjectUtils.isEmpty(missionList) || missionList.size() >0 ){
throw new ServiceException(HttpStatus.SC_BAD_REQUEST,"任务名称不能重复");
throw new ServiceException(HttpStatus.SC_BAD_REQUEST,"任务名称不能重复!");
}


LambdaQueryWrapper<ThMission> lambdaQueryTimeWrapper= new LambdaQueryWrapper<>();
lambdaQueryTimeWrapper.eq(ThMission::getInspectionLine, request.getInspectionLine());
lambdaQueryTimeWrapper.eq(ThMission::getExecutionStartTime, request.getExecutionStartTime());
lambdaQueryTimeWrapper.eq(ThMission::getTenantId, ShiroUtils.getTenantId());
List<ThMission> missionListTime = missionService.getList(lambdaQueryTimeWrapper);
if(!ObjectUtils.isEmpty(missionListTime) || missionListTime.size() >0 ){
throw new ServiceException(HttpStatus.SC_BAD_REQUEST,"同一个航线已存在相同的巡检时间!");
}

if(request.getName().length()>100){

+ 13
- 9
tuoheng-common/src/main/java/com/tuoheng/common/utils/IpUtils.java View File

@@ -278,16 +278,20 @@ public class IpUtils {
if (IpUtils.internalIp(ip)) {
return "内网IP";
}
String rspStr = HttpUtils.doSend("http://ip.taobao.com/service/getIpInfo.php?ip="+ip, new JSONObject(),null,"GET");
if (StringUtils.isEmpty(rspStr)) {
log.error("获取地理位置异常 {}", ip);
return address;
try {
String rspStr = HttpUtils.doSend("http://ip.taobao.com/service/getIpInfo.php?ip=" + ip, new JSONObject(), null, "GET");
if (StringUtils.isEmpty(rspStr)) {
log.error("获取地理位置异常 {}", ip);
return address;
}
JSONObject obj = JSONObject.parseObject(rspStr);
JSONObject data = obj.getObject("data", JSONObject.class);
String region = data.getString("region");
String city = data.getString("city");
address = region + " " + city;
}catch (Exception e){
log.info("获取ip地址信息失败。{}",ip);
}
JSONObject obj = JSONObject.parseObject(rspStr);
JSONObject data = obj.getObject("data", JSONObject.class);
String region = data.getString("region");
String city = data.getString("city");
address = region + " " + city;
return address;
}


Loading…
Cancel
Save