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; private ProjectService projectService;
@ResponseBody @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") @PostMapping("/api/test/test-tube-rack-list")
public ApiResponse testTubeRackList() { public ApiResponse testTubeRackList() {
List<Map<String,Object>> list = new ArrayList<>(); 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 @Override
public void execute( Executor executor ) { public void execute( Executor executor ) {
this.setStatus(Task.STATUS_EXECUTING); this.setStatus(Task.STATUS_EXECUTING);
this.testService.regularTaskStart(this.mdbTask);
this.device = executor.getDevice(); this.device = executor.getDevice();
this.testTubeFeedMotor = (ActMotor)this.device.getActuator(ActuatorModule.TEST_TUBE_RACK_FEED_MOTOR); 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(); TaskBatchTubeExit exitTask = new TaskBatchTubeExit();
executor.appendTask(exitTask); executor.appendTask(exitTask);
this.testService.regularTaskStart(this.mdbTask);
this.setStatus(Task.STATUS_FINISHED); 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 { public class MdbTest {
// id // id
public Integer id; public Integer id;
// batch id
public Long batchId;
// serial code // serial code
public String serialCode; public String serialCode;
// task type // task type

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

@ -8,9 +8,9 @@ import java.util.List;
@Mapper @Mapper
public interface TestMapper { public interface TestMapper {
@Insert("INSERT INTO bdt_tests (" + @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 (" + ") 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") @Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
int insert(MdbTest test); int insert(MdbTest test);
@ -41,4 +41,7 @@ public interface TestMapper {
"WHERE id = #{id}" "WHERE id = #{id}"
) )
void update( MdbTest test ); 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.AppError;
import com.dreamworks.boditech.utils.AppRuntimeException; import com.dreamworks.boditech.utils.AppRuntimeException;
import com.dreamworks.boditech.utils.MyCommon; import com.dreamworks.boditech.utils.MyCommon;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -42,6 +43,13 @@ public class TestService {
@Resource @Resource
@Lazy @Lazy
private DeviceService deviceService; private DeviceService deviceService;
// batch id
private Long batchId = null;
@PostConstruct
public void init() {
this.batchId = System.currentTimeMillis();
}
// fetch task from database // fetch task from database
public List<Task> fetchTask() { public List<Task> fetchTask() {
@ -346,7 +354,10 @@ public class TestService {
return this.testMapper.count(param); 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(); Long startTime = calendar.getTimeInMillis();
int count = this.testMapper.countByTimeRange(startTime, System.currentTimeMillis()); int count = this.testMapper.countByTimeRange(startTime, System.currentTimeMillis());
test.serialCode = String.format("%s_%03d", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMdd")), count + 1); 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(); test.startedAt = System.currentTimeMillis();
this.testMapper.insert(test); this.testMapper.insert(test);
} }

Loading…
Cancel
Save