parent
477b9bcaf0
commit
163b7b81ea
|
@ -13,4 +13,8 @@ public interface SensorTaskMapper {
|
||||||
int addNewSensorTaskData(@Param("sensor") SensorTask sensorTask);
|
int addNewSensorTaskData(@Param("sensor") SensorTask sensorTask);
|
||||||
|
|
||||||
int addNewSensorTaskDatas(@Param("taskLists") List<SensorTask> taskLists);
|
int addNewSensorTaskDatas(@Param("taskLists") List<SensorTask> taskLists);
|
||||||
|
|
||||||
|
int countTaskResponseSensor(@Param("taskId") Integer taskId);
|
||||||
|
|
||||||
|
int countTaskResponseSuccessedSensor(@Param("taskId") Integer taskId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,4 +4,8 @@ import com.zjyr.beidouservice.pojo.vo.binary.SensorTaskAck;
|
||||||
|
|
||||||
public interface SensorTaskService {
|
public interface SensorTaskService {
|
||||||
void addSensorTaskResponse(Long controlId, SensorTaskAck sensorTaskAck);
|
void addSensorTaskResponse(Long controlId, SensorTaskAck sensorTaskAck);
|
||||||
|
|
||||||
|
int getRespSensors(int taskId);
|
||||||
|
|
||||||
|
int getRespSuccessedSensors(int taskId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,26 @@ public class SensorTaskServiceImpl implements SensorTaskService {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
for (var v : sensorTaskAck.getSensorStatus()) {
|
for (var v : sensorTaskAck.getSensorStatus()) {
|
||||||
sensorTasks.add(SensorTask.builder().taskId(sensorTaskAck.getTaskId())
|
sensorTasks.add(SensorTask.builder()
|
||||||
|
.taskId(sensorTaskAck.getTaskId())
|
||||||
.deviceId(controlId)
|
.deviceId(controlId)
|
||||||
.sensorId((long) v.getSensorId()).deviceId(0L).taskResult(
|
.sensorId((long) v.getSensorId())
|
||||||
v.getTaskResult()).reportTime(sdf.format(timeStamp)).build());
|
.deviceId(0L)
|
||||||
|
.taskResult(v.getTaskResult())
|
||||||
|
.reportTime(sdf.format(timeStamp))
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
sensorTaskMapper.addNewSensorTaskDatas(sensorTasks);
|
sensorTaskMapper.addNewSensorTaskDatas(sensorTasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRespSensors(int taskId) {
|
||||||
|
return sensorTaskMapper.countTaskResponseSensor(taskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRespSuccessedSensors(int taskId) {
|
||||||
|
return sensorTaskMapper.countTaskResponseSuccessedSensor(taskId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,4 +50,17 @@
|
||||||
TIMESTAMP(#{itme.reportTime}))
|
TIMESTAMP(#{itme.reportTime}))
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<select id="countTaskResponseSensor" resultType="int">
|
||||||
|
SELECT COUNT(DISTINCT sensorId) as cnt
|
||||||
|
FROM sensor_task
|
||||||
|
WHERE taskId = #{taskId};
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="countTaskResponseSuccessedSensor" resultType="int">
|
||||||
|
SELECT COUNT(DISTINCT sensorId) as cnt
|
||||||
|
FROM sensor_task
|
||||||
|
WHERE taskResult = ${@com.zjyr.beidouservice.common.impl.TaskResultName@TASK_RESULT_SUCCESSED.getValue()}
|
||||||
|
AND taskId = #{taskId};
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -8,14 +8,16 @@ import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
|
import org.springframework.test.annotation.Rollback;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
|
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
|
||||||
//@Transactional
|
@Transactional
|
||||||
//@Rollback
|
@Rollback
|
||||||
public class ControlDeviceMapperTest {
|
public class ControlDeviceMapperTest {
|
||||||
@Resource
|
@Resource
|
||||||
private ControlDeviceMapper controlDeviceMapper;
|
private ControlDeviceMapper controlDeviceMapper;
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.zjyr.beidouservice.mapper;
|
||||||
|
|
||||||
|
import com.zjyr.beidouservice.pojo.entry.ControlDevice;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
|
import org.springframework.test.annotation.Rollback;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
|
@Slf4j
|
||||||
|
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
|
||||||
|
@Transactional
|
||||||
|
@Rollback
|
||||||
|
public class SensorTaskMapperTest {
|
||||||
|
@Resource
|
||||||
|
SensorTaskMapper sensorTaskMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void a1_countTaskResponseSensor() {
|
||||||
|
int nResponse = sensorTaskMapper.countTaskResponseSensor(0);
|
||||||
|
Assertions.assertNotEquals(nResponse, 0);
|
||||||
|
log.info("Total Response Sensor: {}", nResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void a2_countTaskResponseSuccessedSensor() {
|
||||||
|
int nResponseOK = sensorTaskMapper.countTaskResponseSuccessedSensor(0);
|
||||||
|
Assertions.assertNotEquals(nResponseOK, 0);
|
||||||
|
log.info("Total Response OK Sensor: {}", nResponseOK);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue