Browse Source

当前测试列表更新

master
sige 2 years ago
parent
commit
b390faa262
  1. 21
      src/main/java/com/dreamworks/boditech/controller/TestController.java
  2. 2
      src/main/java/com/dreamworks/boditech/driver/task/TaskTestTubeRackPrepare.java
  3. 2
      src/main/java/com/dreamworks/boditech/entity/MdbTest.java
  4. 7
      src/main/java/com/dreamworks/boditech/mapper/TestMapper.java
  5. 18
      src/main/java/com/dreamworks/boditech/service/TestService.java

21
src/main/java/com/dreamworks/boditech/controller/TestController.java

@ -24,6 +24,27 @@ public class TestController extends BaseController {
private ProjectService projectService;
@ResponseBody
@PostMapping("/api/test/active-batch-list")
public ApiResponse activeBatchList() {
List<Map<String,Object>> list = new ArrayList<>();
List<MdbTest> tests = this.testService.testActiveBatchList();
for ( MdbTest test : tests ) {
Map<String,Object> item = MyCommon.objectToMap(test);
long letfTime = test.incubateStartedAt + test.incubateTime - System.currentTimeMillis();
if ( letfTime < 0 ) {
letfTime = 0L;
}
letfTime /= 1000;
Integer sec = (int)(letfTime % 60);
Integer min = (int)(letfTime / 60);
item.put("incubateLeftTime", String.format("%02d:%02d", min, sec));
item.put("results", MyCommon.jsonToObject(test.result, List.class));
list.add(item);
}
return this.success(list);
}
@ResponseBody
@PostMapping("/api/test/test-tube-rack-list")
public ApiResponse testTubeRackList() {
List<Map<String,Object>> list = new ArrayList<>();

2
src/main/java/com/dreamworks/boditech/driver/task/TaskTestTubeRackPrepare.java

@ -44,6 +44,7 @@ public class TaskTestTubeRackPrepare extends TaskBase {
@Override
public void execute( Executor executor ) {
this.setStatus(Task.STATUS_EXECUTING);
this.testService.regularTaskStart(this.mdbTask);
this.device = executor.getDevice();
this.testTubeFeedMotor = (ActMotor)this.device.getActuator(ActuatorModule.TEST_TUBE_RACK_FEED_MOTOR);
@ -93,7 +94,6 @@ public class TaskTestTubeRackPrepare extends TaskBase {
TaskBatchTubeExit exitTask = new TaskBatchTubeExit();
executor.appendTask(exitTask);
this.testService.regularTaskStart(this.mdbTask);
this.setStatus(Task.STATUS_FINISHED);
}

2
src/main/java/com/dreamworks/boditech/entity/MdbTest.java

@ -2,6 +2,8 @@ package com.dreamworks.boditech.entity;
public class MdbTest {
// id
public Integer id;
// batch id
public Long batchId;
// serial code
public String serialCode;
// task type

7
src/main/java/com/dreamworks/boditech/mapper/TestMapper.java

@ -8,9 +8,9 @@ import java.util.List;
@Mapper
public interface TestMapper {
@Insert("INSERT INTO bdt_tests (" +
"serialCode, barCode, lotCode, taskType, taskId, sampleUid, projectId, projectName, sampleType, tubeType, startedAt, startedBy" +
"batchId, serialCode, barCode, lotCode, taskType, taskId, sampleUid, projectId, projectName, sampleType, tubeType, startedAt, startedBy" +
") VALUES (" +
"#{serialCode}, #{barCode}, #{lotCode}, #{taskType}, #{taskId}, #{sampleUid}, #{projectId}, #{projectName}, #{sampleType}, #{tubeType}, #{startedAt}, #{startedBy}" +
"#{batchId}, #{serialCode}, #{barCode}, #{lotCode}, #{taskType}, #{taskId}, #{sampleUid}, #{projectId}, #{projectName}, #{sampleType}, #{tubeType}, #{startedAt}, #{startedBy}" +
")")
@Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
int insert(MdbTest test);
@ -41,4 +41,7 @@ public interface TestMapper {
"WHERE id = #{id}"
)
void update( MdbTest test );
@Select("SELECT * FROM bdt_tests WHERE batchId=#{batchId} ORDER BY id DESC LIMIT 20")
List<MdbTest> activeBatchList( Long batchId );
}

18
src/main/java/com/dreamworks/boditech/service/TestService.java

@ -12,6 +12,7 @@ import com.dreamworks.boditech.mapper.*;
import com.dreamworks.boditech.utils.AppError;
import com.dreamworks.boditech.utils.AppRuntimeException;
import com.dreamworks.boditech.utils.MyCommon;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -42,6 +43,13 @@ public class TestService {
@Resource
@Lazy
private DeviceService deviceService;
// batch id
private Long batchId = null;
@PostConstruct
public void init() {
this.batchId = System.currentTimeMillis();
}
// fetch task from database
public List<Task> fetchTask() {
@ -346,7 +354,10 @@ public class TestService {
return this.testMapper.count(param);
}
// test list
public List<MdbTest> testActiveBatchList() {
return this.testMapper.activeBatchList(this.batchId);
}
@ -364,9 +375,8 @@ public class TestService {
Long startTime = calendar.getTimeInMillis();
int count = this.testMapper.countByTimeRange(startTime, System.currentTimeMillis());
test.serialCode = String.format("%s_%03d", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMdd")), count + 1);
// @TODO : startedBy should be set to the current user
test.startedBy = 0;
test.batchId = this.batchId;
test.startedBy = this.accountService.getCurrentAccountId();
test.startedAt = System.currentTimeMillis();
this.testMapper.insert(test);
}

Loading…
Cancel
Save