You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
182 lines
7.1 KiB
182 lines
7.1 KiB
package com.dreamworks.boditech.controller;
|
|
import com.dreamworks.boditech.controller.entity.ApiResponse;
|
|
import com.dreamworks.boditech.entity.MdbTestTubeRackTestTask;
|
|
import com.dreamworks.boditech.entity.MdbTestTubeRackTestTaskTube;
|
|
import com.dreamworks.boditech.entity.Project;
|
|
import com.dreamworks.boditech.entity.parameter.ParamEmergencyTaskSave;
|
|
import com.dreamworks.boditech.entity.parameter.ParamTestTubeRackTaskSave;
|
|
import com.dreamworks.boditech.service.ProjectService;
|
|
import com.dreamworks.boditech.service.TestService;
|
|
import com.dreamworks.boditech.utils.MyCommon;
|
|
import jakarta.annotation.Resource;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
@Controller
|
|
public class TestController extends BaseController {
|
|
@Resource
|
|
private TestService testService;
|
|
@Resource
|
|
private ProjectService projectService;
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/test/test-tube-rack-save")
|
|
public ApiResponse testTubeRackTaskSave(@RequestBody ParamTestTubeRackTaskSave param ) {
|
|
MdbTestTubeRackTestTask task = this.testService.testTubeRackTaskSave(param);
|
|
return this.success(task);
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/test/test-tube-rack-list")
|
|
public ApiResponse testTubeRackList() {
|
|
List<Map<String,Object>> list = new ArrayList<>();
|
|
List<MdbTestTubeRackTestTask> racks = this.testService.testTubeRackTaskList();
|
|
for ( MdbTestTubeRackTestTask rack : racks ) {
|
|
Map<String,Object> item = MyCommon.objectToMap(rack);
|
|
|
|
// attach tubes to rack
|
|
List<MdbTestTubeRackTestTaskTube> tubes = this.testService.testTubeRackTaskTubeListByRackId(rack.id);
|
|
List<Map<String,Object>> tubeList = new ArrayList<>();
|
|
for ( MdbTestTubeRackTestTaskTube tube : tubes ) {
|
|
Map<String,Object> tubeItem = MyCommon.objectToMap(tube);
|
|
|
|
// attach projects to tube
|
|
String[] ids = tube.projectIds.isEmpty() ? new String[0] : tube.projectIds.split(",");
|
|
List<Integer> projectIds = new ArrayList<>();
|
|
List<Map<String,Object>> projectList = new ArrayList<>();
|
|
for ( String id : ids ) {
|
|
Project project = this.projectService.activeProjectGetById(Integer.parseInt(id));
|
|
Map<String,Object> projectItem = MyCommon.objectToMap(project);
|
|
projectItem.remove("steps");
|
|
projectList.add(projectItem);
|
|
projectIds.add(Integer.parseInt(id));
|
|
}
|
|
tubeItem.put("projects", projectList);
|
|
tubeItem.put("projectIds", projectIds);
|
|
tubeList.add(tubeItem);
|
|
}
|
|
item.put("tubes", tubeList);
|
|
list.add(item);
|
|
}
|
|
return this.success(list);
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/test/test-tube-rack-delete")
|
|
public ApiResponse testTubeRackBatchDelete( @RequestBody Map<String,Object> params ) {
|
|
Integer id = Integer.parseInt(params.get("id").toString());
|
|
this.testService.testTubeRackTaskDeleteById(id);
|
|
return this.success();
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/test/test-tube-rack-lock")
|
|
public ApiResponse testTubeRackLock(@RequestBody Map<String,Object> params) {
|
|
Integer id = Integer.parseInt(params.get("id").toString());
|
|
this.testService.testTubeRackTestLock(id);
|
|
return this.success();
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/test/test-tube-rack-unlock")
|
|
public ApiResponse testTubeRackUnlock(@RequestBody Map<String,Object> params) {
|
|
Integer id = Integer.parseInt(params.get("id").toString());
|
|
this.testService.testTubeRackTestUnlock(id);
|
|
return this.success();
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/test/emergency-task-append")
|
|
public ApiResponse testEmergencyAppend( @RequestBody List<ParamEmergencyTaskSave> param) {
|
|
for ( ParamEmergencyTaskSave item : param ) {
|
|
this.testService.emergencyTaskSave(item);
|
|
}
|
|
return this.success();
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/test/emergency-slot-status-get")
|
|
public ApiResponse emergencySlotStatusGet() {
|
|
String slot0Status = this.testService.emergencyTaskStatusGet(0);
|
|
if ( null == slot0Status ) {
|
|
slot0Status = "EMPTY";
|
|
}
|
|
String slot1Status = this.testService.emergencyTaskStatusGet(1);
|
|
if ( null == slot1Status ) {
|
|
slot1Status = "EMPTY";
|
|
}
|
|
return this.success(List.of(
|
|
Map.of("index","0","status",slot0Status),
|
|
Map.of("index","1","status",slot1Status)
|
|
));
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/test/list")
|
|
public ApiResponse list(@RequestBody Map<String,Object> params) {
|
|
List<Map<String,Object>> list = new ArrayList<>();
|
|
for (int i = 0; i < 20; i++) {
|
|
Map<String,Object> item = new HashMap<>();
|
|
item.put("recordUUID", "202110-01");
|
|
item.put("samplePID", "ABCD1234");
|
|
item.put("sampleUID", "016");
|
|
item.put("projectName", "hsCRP");
|
|
item.put("lotCode", "1234567890");
|
|
item.put("tubeIndex", "05");
|
|
item.put("tubeType", "WB");
|
|
item.put("sampleType", "FB");
|
|
item.put("incubateStartedAt", "2012-12-15 00:00:44");
|
|
item.put("incubateTime", "3600");
|
|
item.put("status", "INUSE");
|
|
item.put("slotIndex", Integer.toString(i));
|
|
list.add(item);
|
|
}
|
|
return this.success(list);
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/test/search")
|
|
public ApiResponse search( @RequestBody Map<String,Object> params ) {
|
|
List<Map<String,Object>> list = new ArrayList<>();
|
|
for (int i = 0; i < 20; i++) {
|
|
List<Map<String, String>> results = new ArrayList<>();
|
|
for (int j = 0; j < 2; j++) {
|
|
Map<String, String> result = new HashMap<>();
|
|
result.put("name", "sth01");
|
|
result.put("value", "123.45mg/L");
|
|
results.add(result);
|
|
}
|
|
|
|
Map<String,Object> item = new HashMap<>();
|
|
item.put("recordUUID", "202110-01");
|
|
item.put("samplePID", "ABCD1234");
|
|
item.put("sampleUID", "016");
|
|
item.put("projectName", "hsCRP");
|
|
item.put("lotCode", "1234567890");
|
|
item.put("tubeIndex", "05");
|
|
item.put("tubeType", "WB");
|
|
item.put("sampleType", "FB");
|
|
item.put("incubateStartedAt", "2012-12-15 00:00:44");
|
|
item.put("incubateTime", "3600");
|
|
item.put("status", "INUSE");
|
|
item.put("slotIndex", Integer.toString(i));
|
|
item.put("results", results);
|
|
list.add(item);
|
|
}
|
|
|
|
return this.success(Map.of(
|
|
"totalCount", "100",
|
|
"list", list
|
|
));
|
|
}
|
|
}
|