任务下发校验大区域

This commit is contained in:
cbs 2025-01-14 16:25:03 +08:00
parent 8ace49177c
commit 0b517511ea
36 changed files with 681 additions and 102 deletions

View File

@ -0,0 +1,35 @@
package cn.iocoder.yudao.framework.mybatis.core.type;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;
import com.fasterxml.jackson.core.type.TypeReference;
import java.util.Set;
/**
* 参考 {@link com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler} 实现
* 在我们将字符串反序列化为 Set 并且泛型为 Long 如果每个元素的数值太小会被处理成 Integer 类型导致可能存在隐性的 BUG
*
* 例如说哦SysUserDO postIds 属性
*
*/
public class JsonLongSetTypeHandler extends AbstractJsonTypeHandler<Object> {
private static final TypeReference<Set<Long>> TYPE_REFERENCE = new TypeReference<Set<Long>>(){};
public JsonLongSetTypeHandler(Class<?> type) {
super(type);
}
@Override
public Object parse(String json) {
return JsonUtils.parseObject(json, TYPE_REFERENCE);
}
@Override
public String toJson(Object obj) {
return JsonUtils.toJsonString(obj);
}
}

View File

@ -2,9 +2,11 @@ package cn.iocoder.yudao.module.mqtt.api.task.dto;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class Pose2ds {
private String x;
private String y;
private String yaw;
private Double x;
private Double y;
private Double yaw;
}

View File

@ -10,6 +10,7 @@ public class RobotAcceptTaskData {
private String command_id;
private String command_type;
private List<Pose2ds> pose2ds;
private Pose2ds pose2d;
private String target_height;
private String parm;
}

View File

@ -36,7 +36,7 @@ public class MqttCallBack implements MqttCallback {
@Override
public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception {
String msg = new String(mqttMessage.getPayload());
log.info("[MQTT]接收当前消息为 :{}", msg);
// log.info("[MQTT]接收当前消息为 :{}", msg);
MqttService mqttService = MqttFactory.getMqttFactory(topic);
mqttService.analysisMessage(msg);

View File

@ -10,6 +10,6 @@ public class RobotGenericsStatusServiceImpl implements MqttService{
@Override
public void analysisMessage(String message) {
log.info("处理RobotGenericsStatusServiceImpl的消息 :{}",message);
// log.info("处理RobotGenericsStatusServiceImpl的消息 :{}",message);
}
}

View File

@ -18,6 +18,6 @@ public class RobotStatusServiceImpl implements MqttService{
*/
@Override
public void analysisMessage(String message) {
log.info("处理RobotStatusServiceImpl的消息 :{}",message);
// log.info("处理RobotStatusServiceImpl的消息 :{}",message);
}
}

View File

@ -31,7 +31,7 @@ management:
# MQTT
mqtt:
host: tcp://127.0.0.1:1883
host: tcp://192.168.0.116:1883
username: adminuser
password: adminuser
qos: 1

View File

@ -182,6 +182,8 @@ public interface ErrorCodeConstants {
// ========== 车辆信息 1-002-034-000 ==========
ErrorCode ROBOT_INFORMATION_NOT_EXISTS = new ErrorCode(1-002-034-001, "车辆信息不存在");
ErrorCode ROBOT_MAC_ADDRESS_EXISTS = new ErrorCode(1-002-034-002, "MAC地址重复");
ErrorCode ROBOT_ROBOT_NO_EXISTS = new ErrorCode(1-002-034-003, "机器人编号重复");
// ========== 机器人任务主表 1-002-035-000 ==========
ErrorCode TASK_NOT_EXISTS = new ErrorCode(1-002-035-001, "机器人任务主表不存在");

View File

@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.util.List;
@Slf4j
@ -37,8 +38,13 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
public CommonResult<Boolean> robotDoneTask(RobotCompleteTaskDTO robotCompleteTaskDTO) {
log.info("机器人完成任务上报 :{}", JSON.toJSONString(robotCompleteTaskDTO));
TenantContextHolder.setTenantId(1L);
robotTaskDetailMapper.updateRobotDetailStatus(robotCompleteTaskDTO.getOrder_id(),
robotCompleteTaskDTO.getExecution_state());
RobotTaskDetailDO detailDO = new RobotTaskDetailDO();
detailDO.setId(robotCompleteTaskDTO.getOrder_id());
detailDO.setEndTime(LocalDateTime.now());
detailDO.setTaskStatus(robotCompleteTaskDTO.getExecution_state());
robotTaskDetailMapper.updateRobotDetailById(detailDO);
RobotTaskDetailDO robotTaskDetailDO = robotTaskDetailMapper.selectById(robotCompleteTaskDTO.getOrder_id());
List<RobotTaskDetailDO> taskDetails = robotTaskDetailMapper.queryByTaskId(robotTaskDetailDO.getRobotTaskId());
boolean b =

View File

@ -0,0 +1,6 @@
package cn.iocoder.yudao.module.system.constant.robot;
public class RobotTaskChcheConstant {
//机器人电量
public static String ROBOT_ELECTRICITY = "robot:information:electricity";
}

View File

@ -99,4 +99,7 @@ public class WareHouseLocationPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "ware_position_map的id", example = "1")
private Long mapId;
}

View File

@ -125,4 +125,7 @@ public class WareHouseLocationRespVO {
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "ware_position_map的id", example = "1")
@ExcelProperty("ware_position_map的id")
private Long mapId;
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.system.controller.admin.houselocation.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@ -91,4 +92,6 @@ public class WareHouseLocationSaveReqVO {
@Schema(description = "最后一次执行任务robot_task的id", example = "23816")
private Long taskId;
@Schema(description = "ware_position_map的id", example = "1")
private Long mapId;
}

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.controller.admin.robot;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationRespVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationStatisticsVO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
import cn.iocoder.yudao.module.system.service.robot.RobotInformationService;
import org.springframework.web.bind.annotation.*;
@ -68,7 +69,7 @@ public class RobotInformationController {
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('robot:information:query')")
public CommonResult<RobotInformationRespVO> getInformation(@RequestParam("id") Long id) {
RobotInformationDO information = informationService.getInformation(id);
RobotInformationRespVO information = informationService.getInformation(id);
return success(BeanUtils.toBean(information, RobotInformationRespVO.class));
}
@ -76,7 +77,7 @@ public class RobotInformationController {
@Operation(summary = "获得车辆信息分页")
@PreAuthorize("@ss.hasPermission('robot:information:query')")
public CommonResult<PageResult<RobotInformationRespVO>> getInformationPage(@Valid RobotInformationPageReqVO pageReqVO) {
PageResult<RobotInformationDO> pageResult = informationService.getInformationPage(pageReqVO);
PageResult<RobotInformationRespVO> pageResult = informationService.getInformationPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, RobotInformationRespVO.class));
}
@ -87,10 +88,17 @@ public class RobotInformationController {
public void exportInformationExcel(@Valid RobotInformationPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<RobotInformationDO> list = informationService.getInformationPage(pageReqVO).getList();
List<RobotInformationRespVO> list = informationService.getInformationPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "车辆信息.xls", "数据", RobotInformationRespVO.class,
BeanUtils.toBean(list, RobotInformationRespVO.class));
}
@PostMapping("/statistics")
@Operation(summary = "统计车辆待命/任务中/离线")
@PreAuthorize("@ss.hasPermission('robot:information:statistics')")
public CommonResult<RobotInformationStatisticsVO> statisticsInformation() {
return success(informationService.statisticsInformation());
}
}

View File

@ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.Set;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ -36,7 +37,7 @@ public class RobotInformationPageReqVO extends PageParam {
private Integer robotStatus;
@Schema(description = "楼层/区域(json)")
private String floorAreaJson;
private Set<Long> floorAreaJson;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)

View File

@ -1,9 +1,13 @@
package cn.iocoder.yudao.module.system.controller.admin.robot.vo;
import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
import java.util.List;
import java.util.Set;
@Schema(description = "管理后台 - 车辆信息 Response VO")
@Data
@ -42,12 +46,21 @@ public class RobotInformationRespVO {
@ExcelProperty("AGV状态0暂停且无任务、1暂停(有处理中的任务)、2任务中、3待命")
private Integer robotStatus;
@Schema(description = "楼层/区域(json)")
@TableField(typeHandler = LongListTypeHandler.class)
@ExcelProperty("楼层/区域(json)")
private String floorAreaJson;
private Set<Long> floorAreaJson;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "楼层/区域(json)")
@ExcelProperty("楼层/区域(json)")
public List<RobotPositionMapVO> positionMapList;
@Schema(description = "电量")
@ExcelProperty("电量")
private String electricity;
}

View File

@ -4,6 +4,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.validation.constraints.NotEmpty;
import java.util.Set;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 车辆信息新增/修改 Request VO")
@Data
@ -13,7 +15,7 @@ public class RobotInformationSaveReqVO {
private Long id;
@Schema(description = "车辆类型表id", example = "28234")
@NotEmpty(message = "车辆类型不能为空")
@NotNull(message = "车辆类型不能为空")
private Long robotModelId;
@Schema(description = "车辆类型")
@ -25,7 +27,6 @@ public class RobotInformationSaveReqVO {
private String robotNo;
@Schema(description = "任务模式0拒收任务、1正常", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "任务模式不能为空")
private Integer robotTaskModel;
@Schema(description = "mac地址")
@ -40,6 +41,6 @@ public class RobotInformationSaveReqVO {
@Schema(description = "楼层/区域(json)")
@NotEmpty(message = "楼层/区域不能为空")
private String floorAreaJson;
private Set<Long> floorAreaJson;
}

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.system.controller.admin.robot.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class RobotInformationStatisticsVO {
@Schema(description = "待命")
private Integer standby;
@Schema(description = "任务中")
private Integer inTask;
@Schema(description = "充电中")
private Integer charge;
@Schema(description = "离线")
private Integer offline;
}

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.system.controller.admin.robot.vo;
import lombok.Data;
/**
* 机器人楼层区域信息
*/
@Data
public class RobotPositionMapVO {
/**
* 楼层
*/
private String floor;
/**
* 区域
*/
private String area;
}

View File

@ -1,15 +1,7 @@
package cn.iocoder.yudao.module.system.dal.dataobject.houselocation;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
@ -137,5 +129,8 @@ public class WareHouseLocationDO extends BaseDO {
* 最后一次执行任务robot_task的id
*/
private Long taskId;
/**
* ware_position_map的id
*/
private Long mapId;
}

View File

@ -1,15 +1,18 @@
package cn.iocoder.yudao.module.system.dal.dataobject.robot;
import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler;
import lombok.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import java.util.Set;
/**
* 车辆信息 DO
*
* @author 陈宾顺
*/
@TableName("robot_information")
@TableName(value = "robot_information" , autoResultMap = true)
@KeySequence("robot_information_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ -55,6 +58,7 @@ public class RobotInformationDO extends BaseDO {
/**
* 楼层/区域(json)
*/
private String floorAreaJson;
@TableField(typeHandler = JsonLongSetTypeHandler.class)
private Set<Long> floorAreaJson;
}

View File

@ -10,6 +10,7 @@ import org.apache.ibatis.annotations.Param;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Set;
/**
* 库位 Mapper
@ -60,7 +61,8 @@ public interface WareHouseLocationMapper extends BaseMapperX<WareHouseLocationDO
WareHouseLocationDO selectByTypeAndId(@Param("locationUseStatus") Integer locationUseStatus,
@Param("type") Integer type,
@Param("id") Long id,
@Param("locationIds") List<Long> locationIds);
@Param("locationIds") List<Long> locationIds,
@Param("mapIds") Set<Long> mapIds);
/**
* 普通查询(未删除)
@ -85,7 +87,8 @@ public interface WareHouseLocationMapper extends BaseMapperX<WareHouseLocationDO
* @return
*/
List<WareHouseLocationDO> selectLocations(@Param("query") WareHouseLocationDO query,
@Param("locationIds") List<Long> locationIds);
@Param("locationIds") List<Long> locationIds,
@Param("mapIds") Set<Long> mapIds);
void updateLocationLockList( @Param("locationIds") List<Long> locationIds,
@Param("taskId") Long taskId);

View File

@ -4,8 +4,13 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.positionmap.vo.PositionMapPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotPositionMapVO;
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
/**
* 仓库点位地图 Mapper
@ -26,4 +31,10 @@ public interface PositionMapMapper extends BaseMapperX<PositionMapDO> {
.orderByDesc(PositionMapDO::getId));
}
/**
* 根据id查询
* @param ids
* @return
*/
List<PositionMapDO> selectByIds(@Param("ids") Set<Long> ids);
}

View File

@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationStatisticsVO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -43,4 +44,24 @@ public interface RobotInformationMapper extends BaseMapperX<RobotInformationDO>
* @param robotStatus
*/
void updateRobotStatus(@Param("robotNo") String robotNo, @Param("robotStatus") Integer robotStatus);
/**
* 查询
* @param query
* @return
*/
List<RobotInformationDO> queryAllByLimit(RobotInformationDO query);
/**
* 统计车辆任务
* @return
*/
RobotInformationStatisticsVO statisticsInformation();
/**
* 根据机器人编号查询
* @param robotNos
* @return
*/
List<RobotInformationDO> selectByRobotNos(@Param("robotNos") Set<String> robotNos);
}

View File

@ -60,12 +60,12 @@ public interface RobotTaskDetailMapper extends BaseMapperX<RobotTaskDetailDO> {
*/
List<RobotTaskDetailDO> getUnDoTask();
/**
* 更新任务状态
* @param id
* @param taskStatus
*/
void updateRobotDetailStatus(@Param("id") Long id, @Param("taskStatus") Integer taskStatus);
List<RobotTaskDetailDO> queryByTaskId(@Param("robotTaskId") Long robotTaskId);
/**
* 更新
* @param detailDO
*/
void updateRobotDetailById(RobotTaskDetailDO detailDO);
}

View File

@ -3,9 +3,12 @@ package cn.iocoder.yudao.module.system.enums.redis;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* redis锁的key
*/
@Getter
@AllArgsConstructor
public enum RobotCacheTypeEnum {
public enum RobotCacheLockEnum {
TASK_NO("task:robot:no", "任务号"),
ROBOT_TASK_ADD_LOCK("robot:task:add:lock", "所有创建机器人任务的锁"),

View File

@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.system.enums.robot;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum RobotTaskModelEnum {
REJECTION(0),//拒收任务
NORMAL(1); //正常
/**
* 类型
*/
private final Integer type;
}

View File

@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.system.job.robot;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import cn.iocoder.yudao.module.system.enums.redis.RobotCacheTypeEnum;
import cn.iocoder.yudao.module.system.enums.redis.RobotCacheLockEnum;
import cn.iocoder.yudao.module.system.service.robot.job.DistributeTasksService;
import cn.iocoder.yudao.module.system.util.redis.RedissonUtils;
import com.xxl.job.core.handler.annotation.XxlJob;
@ -11,7 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;
@Component
@ -29,7 +28,7 @@ public class RobotJob {
@TenantJob
public void distributeTasksJob() throws InterruptedException {
log.info("----下发任务给车机----");
RLock lock = redissonUtils.getLock(RobotCacheTypeEnum.ROBOT_TASK_DISTRIBUTE_LOCK.getKey());
RLock lock = redissonUtils.getLock(RobotCacheLockEnum.ROBOT_TASK_DISTRIBUTE_LOCK.getKey());
if (lock.tryLock()){
try {
distributeTasksService.distributeTasks();

View File

@ -5,7 +5,9 @@ import javax.validation.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationRespVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationStatisticsVO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
/**
@ -43,7 +45,7 @@ public interface RobotInformationService {
* @param id 编号
* @return 车辆信息
*/
RobotInformationDO getInformation(Long id);
RobotInformationRespVO getInformation(Long id);
/**
* 获得车辆信息分页
@ -51,6 +53,11 @@ public interface RobotInformationService {
* @param pageReqVO 分页查询
* @return 车辆信息分页
*/
PageResult<RobotInformationDO> getInformationPage(RobotInformationPageReqVO pageReqVO);
PageResult<RobotInformationRespVO> getInformationPage(RobotInformationPageReqVO pageReqVO);
/**
* 统计车辆待命/任务中/离线
* @return
*/
RobotInformationStatisticsVO statisticsInformation();
}

View File

@ -1,9 +1,14 @@
package cn.iocoder.yudao.module.system.service.robot;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationSaveReqVO;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
import cn.iocoder.yudao.module.system.dal.mysql.positionmap.PositionMapMapper;
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotInformationMapper;
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
@ -14,7 +19,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.ROBOT_INFORMATION_NOT_EXISTS;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
/**
* 车辆信息 Service 实现类
@ -28,8 +33,28 @@ public class RobotInformationServiceImpl implements RobotInformationService {
@Resource
private RobotInformationMapper informationMapper;
@Resource
private PositionMapMapper positionMapMapper;
@Resource
private RedisUtil redisUtil;
@Override
public Long createInformation(RobotInformationSaveReqVO createReqVO) {
//判断mac地址是否重复
RobotInformationDO query = new RobotInformationDO();
query.setMacAddress(createReqVO.getMacAddress());
List<RobotInformationDO> existRobotMac = informationMapper.queryAllByLimit(query);
if (ObjectUtil.isNotEmpty(existRobotMac)) {
throw exception(ROBOT_MAC_ADDRESS_EXISTS);
}
//判断机器人编号
query.setMacAddress(null);
query.setRobotNo(createReqVO.getRobotNo());
List<RobotInformationDO> existRobotNo = informationMapper.queryAllByLimit(query);
if (ObjectUtil.isNotEmpty(existRobotNo)) {
throw exception(ROBOT_ROBOT_NO_EXISTS);
}
// 插入
RobotInformationDO information = BeanUtils.toBean(createReqVO, RobotInformationDO.class);
informationMapper.insert(information);
@ -41,6 +66,24 @@ public class RobotInformationServiceImpl implements RobotInformationService {
public void updateInformation(RobotInformationSaveReqVO updateReqVO) {
// 校验存在
validateInformationExists(updateReqVO.getId());
//校验MAC地址
RobotInformationDO query = new RobotInformationDO();
query.setMacAddress(updateReqVO.getMacAddress());
List<RobotInformationDO> existRobot = informationMapper.queryAllByLimit(query);
boolean exist = existRobot.stream().anyMatch(v -> (v.getMacAddress().equals(updateReqVO.getMacAddress())
&& !v.getId().equals(updateReqVO.getId())));
if (exist) {
throw exception(ROBOT_MAC_ADDRESS_EXISTS);
}
//校验机器人编号
query.setMacAddress(null);
query.setRobotNo(updateReqVO.getRobotNo());
List<RobotInformationDO> existRobotNo = informationMapper.queryAllByLimit(query);
boolean robotNoExist = existRobotNo.stream().anyMatch(v -> (v.getRobotNo().equals(updateReqVO.getRobotNo())
&& !v.getId().equals(updateReqVO.getId())));
if (robotNoExist) {
throw exception(ROBOT_ROBOT_NO_EXISTS);
}
// 更新
RobotInformationDO updateObj = BeanUtils.toBean(updateReqVO, RobotInformationDO.class);
informationMapper.updateById(updateObj);
@ -61,13 +104,61 @@ public class RobotInformationServiceImpl implements RobotInformationService {
}
@Override
public RobotInformationDO getInformation(Long id) {
return informationMapper.selectById(id);
public RobotInformationRespVO getInformation(Long id) {
RobotInformationDO robotInformationDO = informationMapper.selectById(id);
RobotInformationRespVO bean = BeanUtils.toBean(robotInformationDO, RobotInformationRespVO.class);
setPositionMapList(bean);
return bean;
}
public void setPositionMapList(RobotInformationRespVO bean) {
Set<Long> ids = bean.getFloorAreaJson();
if (ObjectUtil.isNotEmpty(ids)) {
List<PositionMapDO> list = positionMapMapper.selectByIds(ids);
List<RobotPositionMapVO> targetList = BeanUtil.copyToList(list, RobotPositionMapVO.class);
bean.setPositionMapList(targetList);
}
}
@Override
public PageResult<RobotInformationDO> getInformationPage(RobotInformationPageReqVO pageReqVO) {
return informationMapper.selectPage(pageReqVO);
public PageResult<RobotInformationRespVO> getInformationPage(RobotInformationPageReqVO pageReqVO) {
PageResult<RobotInformationDO> pageResult = informationMapper.selectPage(pageReqVO);
PageResult<RobotInformationRespVO> dataPage = new PageResult<>();
dataPage.setTotal(pageResult.getTotal());
List<RobotInformationDO> list = pageResult.getList();
List<RobotInformationRespVO> targetList = BeanUtil.copyToList(list, RobotInformationRespVO.class);
targetList.stream().forEach(v -> {
setPositionMapList(v);
String electricity = (String)redisUtil.get(RobotTaskChcheConstant.ROBOT_ELECTRICITY + v.getRobotNo());
v.setElectricity(electricity);
});
dataPage.setList(targetList);
return dataPage;
}
/**
* 统计车辆待命/任务中/离线
* @return
*/
@Override
public RobotInformationStatisticsVO statisticsInformation() {
RobotInformationStatisticsVO info = informationMapper.statisticsInformation();
RobotInformationDO query = new RobotInformationDO();
List<RobotInformationDO> existRobot = informationMapper.queryAllByLimit(query);
int i = 0;
if (ObjectUtil.isNotEmpty(existRobot)) {
for (RobotInformationDO v : existRobot) {
String electricity = (String)redisUtil.get(RobotTaskChcheConstant.ROBOT_ELECTRICITY + v.getRobotNo());
if (ObjectUtil.isEmpty(electricity)) {
i++;
}
}
}
info.setOffline(i);
return info;
}
}

View File

@ -2,16 +2,19 @@ package cn.iocoder.yudao.module.system.service.robot;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotTaskDetailAddVo;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotTaskPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotTaskSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDetailDO;
import cn.iocoder.yudao.module.system.dal.mysql.houselocation.WareHouseLocationMapper;
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotInformationMapper;
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskDetailMapper;
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskMapper;
import cn.iocoder.yudao.module.system.enums.redis.RobotCacheTypeEnum;
import cn.iocoder.yudao.module.system.enums.redis.RobotCacheLockEnum;
import cn.iocoder.yudao.module.system.enums.robot.*;
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
import cn.iocoder.yudao.module.system.util.redis.RedissonUtils;
@ -28,7 +31,6 @@ import org.springframework.validation.annotation.Validated;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
@ -37,6 +39,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
import static org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weighers.map;
/**
* 机器人任务主表 Service 实现类
@ -68,6 +71,9 @@ public class RobotTaskServiceImpl implements RobotTaskService {
@Resource
private RobotTaskDetailService robotTaskDetailService;
@Resource
private RobotInformationMapper informationMapper;
@Value("${zn.task-no:ZN}")
private String taskNo;
@Value("${zn.do_cycle:true}")
@ -81,11 +87,11 @@ public class RobotTaskServiceImpl implements RobotTaskService {
//设置任务号
if (ObjectUtil.isEmpty(createReqVO.getTaskNo())) {
String incrementByKey = redisUtil.getIncrementByKey(RobotCacheTypeEnum.TASK_NO.getKey());
String incrementByKey = redisUtil.getIncrementByKey(RobotCacheLockEnum.TASK_NO.getKey());
createReqVO.setTaskNo(taskNo+ DateUtils.getYearMonthDay()+incrementByKey);
}
//获取库位id
RLock lock = redissonUtils.getLock(RobotCacheTypeEnum.ROBOT_TASK_ADD_LOCK.getKey());
RLock lock = redissonUtils.getLock(RobotCacheLockEnum.ROBOT_TASK_ADD_LOCK.getKey());
String addResult = "";
if (lock.tryLock(30l,TimeUnit.MINUTES)){
@ -134,6 +140,22 @@ public class RobotTaskServiceImpl implements RobotTaskService {
throw exception(TASK_ONLY_CHOOSE_LOCATION);
}
}
//校验机器人是否禁用
Set<String> robotNos = createReqVO.getTaskDetailList()
.stream()
.map(RobotTaskDetailAddVo::getRobotNo)
.collect(Collectors.toSet());
if (ObjectUtil.isNotEmpty(robotNos)) {
List<RobotInformationDO> robots = informationMapper.selectByRobotNos(robotNos);
String robotNo = robots.stream()
.filter(v -> RobotTaskModelEnum.REJECTION.getType().equals(v.getRobotTaskModel()))
.map(RobotInformationDO::getRobotNo)
.collect(Collectors.joining(" "));
if (ObjectUtil.isNotEmpty(robotNo)) {
throw exception0(TASK_CHECK_EXCEPTION.getCode(), "以下机器人已被禁用 ",robotNo);
}
}
}
/**
@ -175,6 +197,16 @@ public class RobotTaskServiceImpl implements RobotTaskService {
List<Long> toLocationIds = new ArrayList<>(); //被此次任务锁定的空库位id
List<Long> fromLocationIds = new ArrayList<>(); //被此次任务锁定的有货库位id
for (RobotTaskDetailAddVo robotTaskVo : taskDetailList) {
Set<Long> mapIds = new HashSet<>();
if (ObjectUtil.isNotEmpty(robotTaskVo.getRobotNo())) {
RobotInformationPageReqVO pageReqVO = new RobotInformationPageReqVO();
pageReqVO.setRobotNo(robotTaskVo.getRobotNo());
mapIds = informationMapper.selectPage(pageReqVO).getList()
.stream()
.findFirst()
.map(RobotInformationDO::getFloorAreaJson)
.orElse(new HashSet<>());
}
//查找有货且非锁定的库位
WareHouseLocationDO query = null;
if (ReleaseTakeEnum.TO_LANE.getType().equals(robotTaskVo.getTakeType())) {
@ -193,9 +225,10 @@ public class RobotTaskServiceImpl implements RobotTaskService {
.build();
}
List<WareHouseLocationDO> stockList = locationMapper.selectLocations(query,toLocationIds);
List<WareHouseLocationDO> stockList = locationMapper.selectLocations(query,toLocationIds,mapIds);
if (ObjectUtil.isEmpty(stockList)) {
throw new RuntimeException("取货线库/区域为空或者已锁定");
log.error("取货线库/区域为空或者已锁定或者机器人取放货区域受限制 :{}",robotTaskVo.toString());
throw new RuntimeException("取货线库/区域为空或者已锁定或者机器人取放货区域受限制");
}
//判断取货库位是否存在未完成的任务
Set<Long> stockLocationIds = stockList.stream().map(WareHouseLocationDO::getId).collect(Collectors.toSet());
@ -221,9 +254,10 @@ public class RobotTaskServiceImpl implements RobotTaskService {
.build();
}
List<WareHouseLocationDO> releaseStockList = locationMapper.selectLocations(releaseQuery,toLocationIds);
List<WareHouseLocationDO> releaseStockList = locationMapper.selectLocations(releaseQuery,toLocationIds,mapIds);
if (ObjectUtil.isEmpty(releaseStockList) || releaseStockList.size() < stockList.size()) {
throw new RuntimeException("放货线库/区域库位数量不足");
log.error("放货线库/区域库位数量不足或者机器人取放货区域受限制 :{}",robotTaskVo.toString());
throw new RuntimeException("放货线库/区域库位数量不足或者机器人取放货区域受限制");
}
//赋值数据
List<RobotTaskDetailAddVo> addTaskDetailList = getTaskDatail(stockList,releaseStockList,toLocationIds,
@ -292,6 +326,17 @@ public class RobotTaskServiceImpl implements RobotTaskService {
public void setSingleLocationIdNo(List<RobotTaskDetailAddVo> taskDetailList, Long taskId){
List<Long> locationIds = new ArrayList<>();
for (RobotTaskDetailAddVo robotTaskVo : taskDetailList) {
Set<Long> mapIds = new HashSet<>();
if (ObjectUtil.isNotEmpty(robotTaskVo.getRobotNo())) {
RobotInformationPageReqVO pageReqVO = new RobotInformationPageReqVO();
pageReqVO.setRobotNo(robotTaskVo.getRobotNo());
mapIds = informationMapper.selectPage(pageReqVO).getList()
.stream()
.findFirst()
.map(RobotInformationDO::getFloorAreaJson)
.orElse(new HashSet<>());
}
//校验放货库位
if (ReleaseTakeEnum.TO_LOCATION.getType().equals(robotTaskVo.getReleaseType())) {
WareHouseLocationDO query = WareHouseLocationDO.builder().id(robotTaskVo.getReleaseId()).build();
@ -299,12 +344,17 @@ public class RobotTaskServiceImpl implements RobotTaskService {
robotTaskVo.setToLocationNo(locationDO.getLocationNo());
robotTaskVo.setToLocationId(robotTaskVo.getReleaseId());
robotTaskVo.setToLocationStorey(locationDO.getLocationStorey());
if (ObjectUtil.isNotEmpty(mapIds) && !mapIds.contains(locationDO.getMapId())) {
log.error("机器人不能在此放货库位放货 :{}, 机器人编号 :{}", locationDO.getLocationNo(),robotTaskVo.getRobotNo());
throw new RuntimeException("机器人不能在此放货库位放货 "+ robotTaskVo.getReleaseId());
}
} else {
WareHouseLocationDO wareHouseLocationDO =
locationMapper.selectByTypeAndId(LocationUseStatusEnum.NO.getType(), robotTaskVo.getReleaseType()
,robotTaskVo.getReleaseId(),locationIds);
,robotTaskVo.getReleaseId(),locationIds,mapIds);
if (ObjectUtil.isEmpty(wareHouseLocationDO)) {
throw new RuntimeException("放货库位为空或者已锁定 "+ robotTaskVo.getReleaseId());
log.error("放货库位为空或者已锁定或者机器人取放货区域受限制 :{}", robotTaskVo.getReleaseId());
throw new RuntimeException("放货库位为空或者已锁定或者机器人取放货区域受限制 "+ robotTaskVo.getReleaseId());
}
robotTaskVo.setToLocationNo(wareHouseLocationDO.getLocationNo());
robotTaskVo.setToLocationId(wareHouseLocationDO.getId());
@ -319,12 +369,17 @@ public class RobotTaskServiceImpl implements RobotTaskService {
robotTaskVo.setFromLocationNo(locationDO.getLocationNo());
robotTaskVo.setFromLocationId(robotTaskVo.getTakeId());
robotTaskVo.setFromLocationStorey(locationDO.getLocationStorey());
if (ObjectUtil.isNotEmpty(mapIds) && !mapIds.contains(locationDO.getMapId())) {
log.error("机器人不能在此取货库位取货 :{}, 机器人编号 :{}", locationDO.getLocationNo(),robotTaskVo.getRobotNo());
throw new RuntimeException("机器人不能在此取货库位取货 "+ robotTaskVo.getTakeId());
}
} else {
WareHouseLocationDO wareHouseLocationDO =
locationMapper.selectByTypeAndId(LocationUseStatusEnum.YES.getType(),robotTaskVo.getTakeType(),
robotTaskVo.getTakeId(),locationIds);
robotTaskVo.getTakeId(),locationIds,mapIds);
if (ObjectUtil.isEmpty(wareHouseLocationDO)) {
throw new RuntimeException("取货库位为空或者已锁定 "+ robotTaskVo.getTakeId());
log.error("取货库位为空或者已锁定或者机器人取放货区域受限制 :{}", robotTaskVo.getTakeId());
throw new RuntimeException("取货库位为空或者已锁定或者机器人取放货区域受限制 "+ robotTaskVo.getTakeId());
}
robotTaskVo.setFromLocationNo(wareHouseLocationDO.getLocationNo());
robotTaskVo.setFromLocationId(wareHouseLocationDO.getId());
@ -333,9 +388,10 @@ public class RobotTaskServiceImpl implements RobotTaskService {
locationIds.add(robotTaskVo.getFromLocationId());
//验证取货库位是否存在未完成的任务
Set<Long> set = new HashSet<>();
set.add(robotTaskVo.getToLocationId());
set.add(robotTaskVo.getFromLocationId());
List<RobotTaskDetailDO> doingTasks = taskDetailMapper.queryDoingTaskByIds(set);
if (ObjectUtil.isNotEmpty(doingTasks)) {
log.error("取货库位,存在未完成的任务 :{}", robotTaskVo.getTakeId());
throw new RuntimeException("取货库位,存在未完成的任务");
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.system.service.robot.job;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.mqtt.api.task.RobotTaskApi;
import cn.iocoder.yudao.module.mqtt.api.task.dto.Pose2ds;
import cn.iocoder.yudao.module.mqtt.api.task.dto.RobotAcceptTaskDTO;
@ -16,7 +17,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
@ -41,6 +44,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
@Override
@Transactional(rollbackFor = Exception.class)
public void distributeTasks() {
TenantContextHolder.setTenantId(1L);
List<RobotInformationDO> robots = robotInformationMapper.selectFreeRobot();
if (robots.isEmpty()) {
log.info("暂无空闲的机器人");
@ -69,7 +73,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
List<RobotAcceptTaskDTO> robotTaskDOS = new ArrayList<>();
int i = 0;
for (RobotTaskDetailDO taskDetailDO : taskDetailDOS) {
if (robots.size() < i) {
if (robots.size() <= i) {
break;
}
@ -86,13 +90,13 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
List<Pose2ds> pose2ds = new ArrayList<>();
Pose2ds pose2d = new Pose2ds();
pose2d.setX("21.02");
pose2d.setY("11.02");
pose2d.setYaw("2.0");
pose2ds.add(pose2d);
taskOne.setPose2ds(pose2ds);
pose2d.setX(-0.700);
pose2d.setY(-0.678);
pose2d.setYaw(-0.193);
// pose2ds.add(pose2d);
taskOne.setPose2d(pose2d);
RobotAcceptTaskData taskTwo = new RobotAcceptTaskData();
/* RobotAcceptTaskData taskTwo = new RobotAcceptTaskData();
taskTwo.setSerial("1");
taskTwo.setCommand_id(taskDetailDO.getId().toString());
taskTwo.setCommand_type(CommandTypeEnum.FORK.getType());
@ -110,9 +114,9 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
taskFour.setCommand_type(CommandTypeEnum.MOVE_POSE.getType());
List<Pose2ds> pose2ds4 = new ArrayList<>();
Pose2ds pose2d4 = new Pose2ds();
pose2d4.setX("33.02");
pose2d4.setY("33.02");
pose2d4.setYaw("3.0");
pose2d4.setX(33.02);
pose2d4.setY(33.02);
pose2d4.setYaw(3.0);
pose2ds4.add(pose2d4);
taskFour.setPose2ds(pose2ds4);
@ -128,9 +132,9 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
taskSix.setCommand_type(CommandTypeEnum.FORK.getType());
List<Pose2ds> pose2ds5 = new ArrayList<>();
Pose2ds pose2d5 = new Pose2ds();
pose2d5.setX("55.02");
pose2d5.setY("55.02");
pose2d5.setYaw("5.0");
pose2d5.setX(55.02);
pose2d5.setY(55.02);
pose2d5.setYaw(5.0);
pose2ds5.add(pose2d5);
taskSix.setPose2ds(pose2ds5);
@ -138,15 +142,15 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
taskSeven.setSerial("4");
taskSeven.setCommand_id(taskDetailDO.getId().toString());
taskSeven.setCommand_type(CommandTypeEnum.FORK.getType());
taskSeven.setTarget_height("0.0");
taskSeven.setTarget_height("0.0");*/
data.add(taskOne);
data.add(taskTwo);
/*data.add(taskTwo);
data.add(taskThree);
data.add(taskFour);
data.add(taskFive);
data.add(taskSix);
data.add(taskSeven);
data.add(taskSeven);*/
robotTaskDO.setData(data);
robotTaskDOS.add(robotTaskDO);
@ -161,7 +165,11 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
@Transactional(rollbackFor = Exception.class)
public void updateTaskStatus(RobotInformationDO robotInformationDO, RobotTaskDetailDO taskDetailDO) {
robotInformationMapper.updateRobotStatus(robotInformationDO.getRobotNo(), RobotStatusEnum.DOING.getType());
robotTaskDetailMapper.updateRobotDetailStatus(taskDetailDO.getId(), RobotTaskDetailStatusEnum.DOING.getType());
RobotTaskDetailDO detailDO = new RobotTaskDetailDO();
detailDO.setId(taskDetailDO.getId());
detailDO.setStartTime(LocalDateTime.now());
detailDO.setTaskStatus(RobotTaskDetailStatusEnum.DOING.getType());
robotTaskDetailMapper.updateRobotDetailById(detailDO);
robotTaskMapper.updateRobotStatus(taskDetailDO.getRobotTaskId(), RobotTaskStatusEnum.DOING.getType());
}

View File

@ -533,6 +533,13 @@
#{id}
</foreach>
</when>
<when test= " mapIds != null and mapIds != ''">
AND map_id in
<foreach collection="mapIds" item="mapId" index="index" open="(" close=")"
separator=",">
#{mapId}
</foreach>
</when>
<when test= "1==1">
AND location_enable = '1'
AND location_lock = '1'
@ -639,6 +646,13 @@
#{item}
</foreach>
</if>
<if test="mapIds != null and mapIds.size() > 0">
and map_id in
<foreach collection="mapIds" item="mapId" index="index" open="(" close=")"
separator=",">
#{mapId}
</foreach>
</if>
</where>
</select>

View File

@ -9,4 +9,225 @@
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<resultMap id="BaseResultMap" type="cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapDO">
<!--@Table ware_position_map-->
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="floor" column="floor" jdbcType="INTEGER"/>
<result property="area" column="area" jdbcType="VARCHAR"/>
<result property="yamlJson" column="yaml_json" jdbcType="VARCHAR"/>
<result property="pngUrl" column="png_url" jdbcType="VARCHAR"/>
<result property="yamlUrl" column="yaml_url" jdbcType="VARCHAR"/>
<result property="creator" column="creator" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updater" column="updater" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="deleted" column="deleted" jdbcType="INTEGER"/>
</resultMap>
<!--查询单个-->
<sql id="base_sql" >
id,
floor,
area,
yaml_json,
png_url,
yaml_url,
creator,
create_time,
updater,
update_time,
deleted,
tenant_id
</sql>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="BaseResultMap">
select
id, floor, area, yml_json, png_url,yaml_url, creator, create_time, updater, update_time, deleted, tenant_id
from ware_position_map
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="floor != null">
and floor = #{floor}
</if>
<if test="area != null and area != ''">
and area = #{area}
</if>
<if test="ymlJson != null and ymlJson != ''">
and yml_json = #{ymlJson}
</if>
<if test="pngUrl != null and pngUrl != ''">
and png_url = #{pngUrl}
</if>
<if test="yamlUrl != null and yamlUrl != ''">
and yaml_url = #{yamlUrl}
</if>
<if test="creator != null and creator != ''">
and creator = #{creator}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="updater != null and updater != ''">
and updater = #{updater}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="deleted != null">
and deleted = #{deleted}
</if>
<if test="tenantId != null">
and tenant_id = #{tenantId}
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
</select>
<!--通过实体作为筛选条件查询-->
<select id="queryAll" resultMap="BaseResultMap">
select
id, floor, area, yml_json, url, creator, create_time, updater, update_time, deleted, tenant_id
from ware_position_map
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from ware_position_map
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="floor != null">
and floor = #{floor}
</if>
<if test="area != null and area != ''">
and area = #{area}
</if>
<if test="ymlJson != null and ymlJson != ''">
and yml_json = #{ymlJson}
</if>
<if test="pngUrl != null and pngUrl != ''">
and png_url = #{pngUrl}
</if>
<if test="yamlUrl != null and yamlUrl != ''">
and yaml_url = #{yamlUrl}
</if>
<if test="creator != null and creator != ''">
and creator = #{creator}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="updater != null and updater != ''">
and updater = #{updater}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="deleted != null">
and deleted = #{deleted}
</if>
<if test="tenantId != null">
and tenant_id = #{tenantId}
</if>
</where>
</select>
<select id="selectByIds" resultMap="BaseResultMap">
select
<include refid="base_sql"></include>
from
ware_position_map
where deleted = '0'
and id in
<foreach collection="ids" item="id" index="index" open="(" close=")"
separator=",">
#{id}
</foreach>
</select>
<!--新增所有列-->
<insert id="insertEntity" keyProperty="id" useGeneratedKeys="true">
insert into ware_position_map(floor, area, yml_json, png_url, yaml_url,creator, create_time, updater, update_time, deleted,
tenant_id)
values (#{floor}, #{area}, #{ymlJson}, #{pngUrl},#{yamlUrl}, #{creator}, #{createTime}, #{updater}, #{updateTime}, #{deleted},
#{tenantId})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into ware_position_map(floor, area, yml_json, png_url,yaml_url, creator, create_time, updater, update_time, deleted,
tenant_id)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.floor}, #{entity.area}, #{entity.ymlJson}, #{entity.pngUrl},#{entity.yamlUrl}, #{entity.creator}, #{entity.createTime},
#{entity.updater}, #{entity.updateTime}, #{entity.deleted}, #{entity.tenantId})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into ware_position_map(floor, area, yml_json, png_url,yaml_url, creator, create_time, updater, update_time, deleted,
tenant_id)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.floor}, #{entity.area}, #{entity.ymlJson}, #{entity.pngUrl}, #{entity.yamlUrl},#{entity.creator}, #{entity.createTime},
#{entity.updater}, #{entity.updateTime}, #{entity.deleted}, #{entity.tenantId})
</foreach>
on duplicate key update
floor = values(floor),
area = values(area),
yml_json = values(yml_json),
png_url = values(png_url),
yaml_url = values(yaml_url),
creator = values(creator),
create_time = values(create_time),
updater = values(updater),
update_time = values(update_time),
deleted = values(deleted),
tenant_id = values(tenant_id)
</insert>
<!--通过主键修改数据-->
<update id="updateBySelect">
update ware_position_map
<set>
<if test="floor != null">
floor = #{floor},
</if>
<if test="area != null and area != ''">
area = #{area},
</if>
<if test="ymlJson != null and ymlJson != ''">
yml_json = #{ymlJson},
</if>
<if test="pngUrl != null and pngUrl != ''">
and png_url = #{pngUrl}
</if>
<if test="yamlUrl != null and yamlUrl != ''">
and yaml_url = #{yamlUrl}
</if>
<if test="creator != null and creator != ''">
creator = #{creator},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updater != null and updater != ''">
updater = #{updater},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="deleted != null">
deleted = #{deleted},
</if>
<if test="tenantId != null">
tenant_id = #{tenantId},
</if>
</set>
where id = #{id}
</update>
</mapper>

View File

@ -19,6 +19,7 @@
<result property="macAddress" column="mac_address" jdbcType="VARCHAR"/>
<result property="url" column="url" jdbcType="VARCHAR"/>
<result property="robotStatus" column="robot_status" jdbcType="INTEGER"/>
<!-- <result property="floorAreaJson" column="floor_area_json" jdbcType="VARCHAR"/>-->
<result property="creator" column="creator" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updater" column="updater" jdbcType="VARCHAR"/>
@ -37,6 +38,7 @@
url,
robot_status,
creator,
floor_area_json,
create_time,
updater,
update_time,
@ -47,8 +49,7 @@
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="BaseResultMap">
select
id, robot_model_id, robot_model_number, robot_no, robot_task_model, mac_address, url, robot_status, creator,
create_time, updater, update_time, deleted, tenant_id
<include refid="base_sql"></include>
from robot_information
<where>
<if test="id != null">
@ -87,14 +88,10 @@
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="deleted != null">
and deleted = #{deleted}
</if>
<if test="tenantId != null">
and tenant_id = #{tenantId}
<if test="1==1">
and deleted = '0'
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
</select>
<!--通过实体作为筛选条件查询-->
@ -199,7 +196,7 @@
</insert>
<!--通过主键修改数据-->
<update id="updateById">
<update id="doUpdateById">
update robot_information
<set>
<if test="robotModelId != null">
@ -268,7 +265,33 @@
robot_information
where
robot_task_model = '1'
and deleted = '0'
and robot_status = '3'
order by update_time asc
</select>
<select id="statisticsInformation"
resultType="cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationStatisticsVO">
SELECT
(SELECT count(*) from robot_information where robot_status in ('0','3') and deleted = '0' ) AS 'standby',
(SELECT count(*) from robot_task_detail t2 where t2.task_type != 3 and t2.task_status = 1 and deleted = '0') as 'inTask',
(SELECT count(*) from robot_task_detail t2 where t2.task_type = 3 and t2.task_status = 1 and deleted = '0') as 'charge'
from
robot_information
limit 1
</select>
<select id="selectByRobotNos" resultMap="BaseResultMap">
select
<include refid="base_sql"></include>
from
robot_information
where
deleted = '0'
and robot_no in
<foreach collection="robotNos" item="robotNo" index="index" open="(" close=")"
separator=",">
#{robotNo}
</foreach>
</select>
</mapper>

View File

@ -292,7 +292,7 @@
</insert>
<!--通过主键修改数据-->
<update id="update">
<update id="updateRobotDetailById">
update robot_task_detail
<set>
<if test="robotTaskId != null">
@ -358,22 +358,10 @@
<if test="deleted != null">
deleted = #{deleted},
</if>
<if test="tenantId != null">
tenant_id = #{tenantId},
</if>
</set>
where id = #{id}
</update>
<update id="updateRobotDetailStatus">
update
robot_task_detail
set
task_status = #{taskStatus}
where
id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete