|
@ -1,5 +1,6 @@ |
|
|
package com.qyft.gd.device.service.impl; |
|
|
package com.qyft.gd.device.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
import com.qyft.gd.device.mapper.CtrlFuncMapper; |
|
|
import com.qyft.gd.device.mapper.CtrlFuncMapper; |
|
@ -27,22 +28,22 @@ public class CtrlFuncServiceImpl extends ServiceImpl<CtrlFuncMapper, CtrlFunc> i |
|
|
private static final List<DeviceCtrlFuncCMD> ctrlFuncDeviceCMDList = new ArrayList<>(); |
|
|
private static final List<DeviceCtrlFuncCMD> ctrlFuncDeviceCMDList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
static { |
|
|
static { |
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("开门", "openDoor")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("关门", "closeDoor")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("导轨机械臂运动到指定点位", "moveRailArmToPoint")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("导轨机械臂相对运动", "moveRailArmRelative")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("导轨机械臂移至指定加热区上方", "moveToHeatArea")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("导轨机械臂移至加液区上方", "moveToActionArea")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("打开导轨机械臂夹爪", "openClaw")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("收合导轨机械臂夹爪", "closeClaw")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("指定加热区开始加热", "startHeating")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("指定加热区停止加热", "stopHeating")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("指定加热区抬起托盘", "raiseTray")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("指定加热区放下托盘", "lowerTray")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("依次添加溶液", "addLiquid")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("开始摇匀", "startShaking")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("停止摇匀", "stopShaking")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("拍照", "takePhoto")); |
|
|
|
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("开门", "openDoor", "{}")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("关门", "closeDoor", "{}")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("导轨机械臂运动到指定点位", "moveRailArmToPoint", "{\"x\":0,\"y\":0,\"z\":0}")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("导轨机械臂相对运动", "moveRailArmRelative", "{\"x\":0,\"y\":0,\"z\":0}")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("导轨机械臂移至指定加热区上方", "moveToHeatArea", "{\"heatId\":2}")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("导轨机械臂移至加液区上方", "moveToActionArea", "{}")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("打开导轨机械臂夹爪", "openClaw", "{}")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("收合导轨机械臂夹爪", "closeClaw", "{}")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("指定加热区开始加热", "startHeating", "{\"heatId\":2}")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("指定加热区停止加热", "stopHeating", "{\"heatId\":2}")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("指定加热区抬起托盘", "raiseTray", "{\"heatId\":2}")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("指定加热区放下托盘", "lowerTray", "{\"heatId\":2}")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("依次添加溶液", "addLiquid", "{\"tubeSolList\":[{\"tubeNum\":1,\"solId\":15,\"volume\":20}]}")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("开始摇匀", "startShaking", "{}")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("停止摇匀", "stopShaking", "{}")); |
|
|
|
|
|
ctrlFuncDeviceCMDList.add(new DeviceCtrlFuncCMD("拍照", "takePhoto", "{}")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -56,7 +57,7 @@ public class CtrlFuncServiceImpl extends ServiceImpl<CtrlFuncMapper, CtrlFunc> i |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public DeviceCtrlFuncVO findById(Long id) { |
|
|
|
|
|
|
|
|
public DeviceCtrlFuncVO findVOById(Long id) { |
|
|
CtrlFunc ctrlFunc = this.getById(id); |
|
|
CtrlFunc ctrlFunc = this.getById(id); |
|
|
List<CtrlFuncStep> ctrlFuncStepList = ctrlFuncStepService.selectListByFuncCmd(ctrlFunc.getFuncCmd()); |
|
|
List<CtrlFuncStep> ctrlFuncStepList = ctrlFuncStepService.selectListByFuncCmd(ctrlFunc.getFuncCmd()); |
|
|
DeviceCtrlFuncVO ctrlFuncVO = new DeviceCtrlFuncVO(); |
|
|
DeviceCtrlFuncVO ctrlFuncVO = new DeviceCtrlFuncVO(); |
|
@ -78,7 +79,7 @@ public class CtrlFuncServiceImpl extends ServiceImpl<CtrlFuncMapper, CtrlFunc> i |
|
|
ctrlFunc.setFuncCmd(ctrlFuncForm.getFuncCmd()); |
|
|
ctrlFunc.setFuncCmd(ctrlFuncForm.getFuncCmd()); |
|
|
ctrlFunc.setName(ctrlFuncForm.getName()); |
|
|
ctrlFunc.setName(ctrlFuncForm.getName()); |
|
|
if (this.save(ctrlFunc)) { |
|
|
if (this.save(ctrlFunc)) { |
|
|
return saveCtrlFunc(ctrlFuncForm, ctrlFunc); |
|
|
|
|
|
|
|
|
return reSaveCtrlFunc(ctrlFuncForm, ctrlFunc); |
|
|
} |
|
|
} |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -90,7 +91,7 @@ public class CtrlFuncServiceImpl extends ServiceImpl<CtrlFuncMapper, CtrlFunc> i |
|
|
ctrlFunc.setFuncCmd(ctrlFuncForm.getFuncCmd()); |
|
|
ctrlFunc.setFuncCmd(ctrlFuncForm.getFuncCmd()); |
|
|
ctrlFunc.setName(ctrlFuncForm.getName()); |
|
|
ctrlFunc.setName(ctrlFuncForm.getName()); |
|
|
if (this.updateById(ctrlFunc)) { |
|
|
if (this.updateById(ctrlFunc)) { |
|
|
return saveCtrlFunc(ctrlFuncForm, ctrlFunc); |
|
|
|
|
|
|
|
|
return reSaveCtrlFunc(ctrlFuncForm, ctrlFunc); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return false; |
|
|
return false; |
|
@ -102,19 +103,21 @@ public class CtrlFuncServiceImpl extends ServiceImpl<CtrlFuncMapper, CtrlFunc> i |
|
|
.map(Long::parseLong) |
|
|
.map(Long::parseLong) |
|
|
.collect(Collectors.toList()); |
|
|
.collect(Collectors.toList()); |
|
|
for (Long id : ids) { |
|
|
for (Long id : ids) { |
|
|
ctrlFuncStepService.remove(new LambdaQueryWrapper<CtrlFuncStep>().eq(CtrlFuncStep::getFuncCmd, id)); |
|
|
|
|
|
|
|
|
String funcCmd = this.getById(id).getFuncCmd(); |
|
|
|
|
|
ctrlFuncStepService.remove(new LambdaQueryWrapper<CtrlFuncStep>().eq(CtrlFuncStep::getFuncCmd, funcCmd)); |
|
|
} |
|
|
} |
|
|
return this.removeByIds(ids); |
|
|
return this.removeByIds(ids); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private boolean saveCtrlFunc(CtrlFuncForm ctrlFuncForm, CtrlFunc ctrlFunc) { |
|
|
|
|
|
|
|
|
private boolean reSaveCtrlFunc(CtrlFuncForm ctrlFuncForm, CtrlFunc ctrlFunc) { |
|
|
|
|
|
ctrlFuncStepService.remove(new LambdaQueryWrapper<CtrlFuncStep>().eq(CtrlFuncStep::getFuncCmd, ctrlFunc.getFuncCmd())); |
|
|
List<CtrlFuncForm.CtrlFuncStepForm> ctrlFuncStepFormList = ctrlFuncForm.getCtrlFuncStepList(); |
|
|
List<CtrlFuncForm.CtrlFuncStepForm> ctrlFuncStepFormList = ctrlFuncForm.getCtrlFuncStepList(); |
|
|
List<CtrlFuncStep> ctrlFuncStepList = ctrlFuncStepFormList.stream() |
|
|
List<CtrlFuncStep> ctrlFuncStepList = ctrlFuncStepFormList.stream() |
|
|
.map(ctrlFuncStepForm -> { |
|
|
.map(ctrlFuncStepForm -> { |
|
|
CtrlFuncStep ctrlFuncStep = new CtrlFuncStep(); |
|
|
CtrlFuncStep ctrlFuncStep = new CtrlFuncStep(); |
|
|
ctrlFuncStep.setFuncCmd(ctrlFunc.getFuncCmd()); |
|
|
ctrlFuncStep.setFuncCmd(ctrlFunc.getFuncCmd()); |
|
|
ctrlFuncStep.setDeviceCmd(ctrlFuncStepForm.getDeviceCmd()); |
|
|
ctrlFuncStep.setDeviceCmd(ctrlFuncStepForm.getDeviceCmd()); |
|
|
ctrlFuncStep.setParams(ctrlFuncStepForm.getParams()); |
|
|
|
|
|
|
|
|
ctrlFuncStep.setParams(JSONUtil.toJsonStr(ctrlFuncStepForm.getParams())); |
|
|
return ctrlFuncStep; |
|
|
return ctrlFuncStep; |
|
|
}).toList(); |
|
|
}).toList(); |
|
|
return ctrlFuncStepService.saveBatch(ctrlFuncStepList); |
|
|
return ctrlFuncStepService.saveBatch(ctrlFuncStepList); |
|
|