|
|
@ -2,12 +2,18 @@ package com.hnac.hzinfo.inspect.plan.controller; |
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.exception.HzServiceException; |
|
|
|
import com.hnac.hzinfo.inspect.Constants; |
|
|
|
import com.hnac.hzinfo.inspect.Constants; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.inspect.ai.entity.RobotEntity; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.inspect.ai.service.IRobotService; |
|
|
|
import com.hnac.hzinfo.inspect.obj.utils.CodeUtils; |
|
|
|
import com.hnac.hzinfo.inspect.obj.utils.CodeUtils; |
|
|
|
import com.hnac.hzinfo.inspect.plan.entity.PlanEntity; |
|
|
|
import com.hnac.hzinfo.inspect.plan.entity.PlanEntity; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.inspect.plan.entity.RouteEntity; |
|
|
|
import com.hnac.hzinfo.inspect.plan.service.IPlanObjectTemplateService; |
|
|
|
import com.hnac.hzinfo.inspect.plan.service.IPlanObjectTemplateService; |
|
|
|
import com.hnac.hzinfo.inspect.plan.service.IPlanService; |
|
|
|
import com.hnac.hzinfo.inspect.plan.service.IPlanService; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.inspect.plan.service.IRouteService; |
|
|
|
import com.hnac.hzinfo.inspect.plan.vo.PlanListQueryVO; |
|
|
|
import com.hnac.hzinfo.inspect.plan.vo.PlanListQueryVO; |
|
|
|
import com.hnac.hzinfo.inspect.plan.vo.PlanVO; |
|
|
|
import com.hnac.hzinfo.inspect.plan.vo.PlanVO; |
|
|
|
import com.hnac.hzinfo.inspect.utils.Condition; |
|
|
|
import com.hnac.hzinfo.inspect.utils.Condition; |
|
|
@ -23,13 +29,17 @@ import org.springblade.core.mp.support.Query; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.constant.BladeConstant; |
|
|
|
import org.springblade.core.tool.constant.BladeConstant; |
|
|
|
|
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
|
|
|
import org.springblade.system.user.cache.UserCache; |
|
|
|
|
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
|
|
import javax.validation.Valid; |
|
|
|
import javax.validation.Valid; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -47,6 +57,8 @@ public class PlanController extends BladeController { |
|
|
|
|
|
|
|
|
|
|
|
private final IPlanService planService; |
|
|
|
private final IPlanService planService; |
|
|
|
private final IPlanObjectTemplateService planObjectTemplateService; |
|
|
|
private final IPlanObjectTemplateService planObjectTemplateService; |
|
|
|
|
|
|
|
private final IRobotService robotService; |
|
|
|
|
|
|
|
private final IRouteService routeService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 详情 |
|
|
|
* 详情 |
|
|
@ -189,4 +201,40 @@ public class PlanController extends BladeController { |
|
|
|
} |
|
|
|
} |
|
|
|
return R.status(planService.submitForHld(plan)); |
|
|
|
return R.status(planService.submitForHld(plan)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/initiateRobotPlan") |
|
|
|
|
|
|
|
@ApiOperationSupport(order = 10) |
|
|
|
|
|
|
|
@ApiOperation(value = "机器人计划", notes = "传入userId,routeId,routeName") |
|
|
|
|
|
|
|
public R<Boolean> initiateRobotPlan(@RequestBody Map<String,String> request) { |
|
|
|
|
|
|
|
String itemName = request.get("itemName"); |
|
|
|
|
|
|
|
// 拆解语义 剔除掉空格前内容以及以开始巡检结尾的字符串
|
|
|
|
|
|
|
|
String robotName = this.processString(itemName).trim(); |
|
|
|
|
|
|
|
List<RobotEntity> robotEntityList = robotService.list(Wrappers.<RobotEntity>lambdaQuery().eq(RobotEntity::getName, robotName)); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(robotEntityList)) { |
|
|
|
|
|
|
|
throw new HzServiceException("未获取到机器人配置!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
RobotEntity robotEntity = robotEntityList.get(0); |
|
|
|
|
|
|
|
if(Func.isEmpty(robotEntity.getUserId())) { |
|
|
|
|
|
|
|
throw new HzServiceException("未获取到机器人配置!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 获取机器人巡检路线
|
|
|
|
|
|
|
|
List<RouteEntity> routeEntityList = routeService.list(Wrappers.<RouteEntity>lambdaQuery().eq(RouteEntity::getCreateDept, UserCache.getUser(robotEntity.getUserId()).getDeptId())); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(routeEntityList)) { |
|
|
|
|
|
|
|
throw new HzServiceException("获取机器人巡检路线失败!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
RouteEntity routeEntity = routeEntityList.get(0); |
|
|
|
|
|
|
|
return R.status(planService.initiateRobotPlan(robotEntity.getUserId(), robotEntity.getUserId(), routeEntity.getId(), routeEntity.getRouteName())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String processString(String input) { |
|
|
|
|
|
|
|
String result = input; |
|
|
|
|
|
|
|
int spaceIndex = input.indexOf(" "); |
|
|
|
|
|
|
|
if(spaceIndex != -1) { |
|
|
|
|
|
|
|
result = input.substring(spaceIndex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (result.endsWith("开始巡检")) { |
|
|
|
|
|
|
|
result = result.substring(0, result.length() - "开始巡检".length()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|