|
|
@ -3,12 +3,32 @@ import com.dreamworks.boditech.driver.Device; |
|
|
|
import com.dreamworks.boditech.driver.actuator.*; |
|
|
|
import com.dreamworks.boditech.driver.entity.LisTestInfo; |
|
|
|
import com.dreamworks.boditech.driver.entity.TaskBatchTubeTestInfo; |
|
|
|
import com.dreamworks.boditech.entity.MdbTestTubeRackTestTask; |
|
|
|
import com.dreamworks.boditech.entity.MdbTestTubeRackTestTaskTube; |
|
|
|
import com.dreamworks.boditech.service.TestService; |
|
|
|
import com.dreamworks.boditech.utils.MyCommon; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
|
public class TaskBatchTubePrepare extends TaskBase { |
|
|
|
// tests |
|
|
|
public List<TaskBatchTubeTestInfo> tests; |
|
|
|
public class TaskTestTubeRackPrepare extends TaskBase { |
|
|
|
// test service |
|
|
|
private TestService testService; |
|
|
|
// test tube rack test task |
|
|
|
private MdbTestTubeRackTestTask mdbTask; |
|
|
|
|
|
|
|
// test tube rack test task tubes |
|
|
|
public void setTestService(TestService testService) { |
|
|
|
this.testService = testService; |
|
|
|
} |
|
|
|
|
|
|
|
// set mdb test tube rack test task |
|
|
|
public void setMdbTestTubeRackTestTask(MdbTestTubeRackTestTask mdbTestTubeRackTestTask) { |
|
|
|
this.mdbTask = mdbTestTubeRackTestTask; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// device |
|
|
|
private Device device; |
|
|
|
// testTubeMovement |
|
|
@ -20,6 +40,8 @@ public class TaskBatchTubePrepare extends TaskBase { |
|
|
|
// testTubeBarcodes |
|
|
|
private String[] testTubeBarcodes; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void execute( Executor executor ) { |
|
|
|
this.setStatus(Task.STATUS_EXECUTING); |
|
|
@ -58,6 +80,11 @@ public class TaskBatchTubePrepare extends TaskBase { |
|
|
|
this.testTubeBarcodes[i] = code; |
|
|
|
} |
|
|
|
|
|
|
|
if ( this.mdbTask.tubeType.isEmpty() ) { |
|
|
|
// @TODO : 试管为空需要扫描试管架了 |
|
|
|
this.mdbTask.tubeType = "BloodTube5ml"; |
|
|
|
} |
|
|
|
|
|
|
|
// 04. 扫描完成后推送到预备区域 |
|
|
|
testTubeMoveMotor.moveTo("testTubeRackStandby"); |
|
|
|
|
|
|
@ -70,39 +97,38 @@ public class TaskBatchTubePrepare extends TaskBase { |
|
|
|
|
|
|
|
// 追加测试到执行器 |
|
|
|
private void appendTestTasksToExecutor(Executor executor) { |
|
|
|
for ( TaskBatchTubeTestInfo test : this.tests ) { |
|
|
|
if ( !this.testTubeExistsStatus[test.tubeIndex] ) { |
|
|
|
List<MdbTestTubeRackTestTaskTube> tubes = this.testService.testTubeRackTaskTubeListByRackId(this.mdbTask.id); |
|
|
|
for (MdbTestTubeRackTestTaskTube tube : tubes) { |
|
|
|
if ( !this.testTubeExistsStatus[tube.index] ) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
String barCode = test.barcode; |
|
|
|
if ( barCode.isEmpty() ) { |
|
|
|
barCode = this.testTubeBarcodes[test.tubeIndex]; |
|
|
|
if ( tube.barCode.isEmpty() ) { |
|
|
|
tube.barCode = this.testTubeBarcodes[tube.index]; |
|
|
|
} |
|
|
|
|
|
|
|
// @TODO : 这里的SampleType为空的时候需要从LIS获取数据了 ~~~ |
|
|
|
// 获取LIS测试信息 |
|
|
|
LisTestInfo lisTestInfo = device.lis.requestTestInfo(barCode); |
|
|
|
if ( null == lisTestInfo ) { |
|
|
|
lisTestInfo = new LisTestInfo(); |
|
|
|
lisTestInfo.sampleType = ""; |
|
|
|
lisTestInfo.projectNames = new ArrayList<>(); |
|
|
|
} |
|
|
|
lisTestInfo.sampleType = test.blood.isEmpty() ? lisTestInfo.sampleType : test.blood; |
|
|
|
lisTestInfo.projectNames = test.projectNames.isEmpty() ? lisTestInfo.projectNames : test.projectNames; |
|
|
|
|
|
|
|
// 追加测试任务 |
|
|
|
for ( String projectName : lisTestInfo.projectNames ) { |
|
|
|
// LisTestInfo lisTestInfo = device.lis.requestTestInfo(barCode); |
|
|
|
// if ( null == lisTestInfo ) { |
|
|
|
// lisTestInfo = new LisTestInfo(); |
|
|
|
// lisTestInfo.sampleType = ""; |
|
|
|
// lisTestInfo.projectNames = new ArrayList<>(); |
|
|
|
// } |
|
|
|
// lisTestInfo.sampleType = test.blood.isEmpty() ? lisTestInfo.sampleType : test.blood; |
|
|
|
// lisTestInfo.projectNames = test.projectNames.isEmpty() ? lisTestInfo.projectNames : test.projectNames; |
|
|
|
|
|
|
|
List<Integer> projectIds = (List<Integer>) MyCommon.jsonToObject(tube.projectIds, List.class); |
|
|
|
for (Integer projectId : projectIds) { |
|
|
|
TaskTestRegular task = new TaskTestRegular(); |
|
|
|
task.tubeIndex = test.tubeIndex; |
|
|
|
task.patientCode = test.patientCode; |
|
|
|
task.tubeType = test.testTube; |
|
|
|
task.barcode = barCode; |
|
|
|
// task.projectName = projectName; |
|
|
|
task.bloodType = lisTestInfo.sampleType; |
|
|
|
task.setMdbTestTubeRackTestTask(this.mdbTask); |
|
|
|
task.setMdbTestTubeRackTestTaskTube(tube); |
|
|
|
task.setProjectId(projectId); |
|
|
|
executor.appendTask(task); |
|
|
|
|
|
|
|
// Device.LOG.info("append test task: {}", task.projectName); |
|
|
|
} |
|
|
|
|
|
|
|
tube.status = MdbTestTubeRackTestTaskTube.STATUS_WAITING; |
|
|
|
this.testService.testTubeRackTaskTubeStatusUpdate(tube); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|