Newer
Older
newfiber-termite / newfiber-termites / newfiber-termites-package / src / test / java / ServiceTest.java
@xiongkai xiongkai 29 days ago 3 KB 数据接收程序
import cn.hutool.core.thread.ThreadUtil;
import com.newfiber.common.core.utils.file.FileUtils;
import com.newfiber.termite.NewfiberTermiteApplication;
import com.newfiber.termite.domain.DeviceMonitoringData;
import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.enums.EExistsAnt;
import com.newfiber.termite.mapper.TermiteMapper;
import com.newfiber.termite.schedule.HeatMapSchedule;
import com.newfiber.termite.service.ISmsRecordService;
import com.newfiber.termite.service.impl.DataPublishService;
import com.newfiber.termite.service.impl.TermiteServiceImpl;
import java.io.File;
import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.multipart.MultipartFile;

@SpringBootTest(classes = NewfiberTermiteApplication.class)
@RunWith(SpringRunner.class)
public class ServiceTest {

    @Resource
    private TermiteMapper termiteMapper;

    @Resource
    private TermiteServiceImpl termiteService;

    @Resource
    private ISmsRecordService smsRecordService;

    @Resource
    HeatMapSchedule heatMapSchedule;

    @Resource
    private DataPublishService dataPublishService;

    @Test
    public void termiteDataupTest() throws Exception{
        TermiteDataUpRequest termiteDataUpRequest = new TermiteDataUpRequest();
        termiteDataUpRequest.setSn("ANT231031003");
        MultipartFile multipartFile = FileUtils.getMultipartFile(new File("C:\\Users\\Administrator\\Downloads\\复位.png"));
        DataUpResponse dataUpResponse = termiteService.termiteDataup(termiteDataUpRequest, multipartFile);
        System.out.println(dataUpResponse.toString());
    }

    @Test
    public void photoIdentifyTest() throws Exception{
        PhotoIdentifyDto photoIdentifyDto = new PhotoIdentifyDto();
        photoIdentifyDto.setId("1795644012890468354");
        photoIdentifyDto.setYesnoant(EExistsAnt.True.getCode());
        MultipartFile multipartFile = FileUtils.getMultipartFile(new File("C:\\Users\\Administrator\\Downloads\\复位.png"));
        String url = termiteService.photoIdentify(photoIdentifyDto, multipartFile);
        System.out.println(url);
    }

    @Test
    public void smsTest(){
        smsRecordService.send("wulinshuiku", "10-1");
    }

    @Test
    public void geometryTest(){
        heatMapSchedule.generator();
    }

    @Test
    public void dataPublishServiceTest(){
        DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData();
        deviceMonitoringData.setSn("12345");
        deviceMonitoringData.setDate("2024-11-01 10:00:01");
        deviceMonitoringData.setYesnoant("1");
//        dataPublishService.publish("241028", "123", deviceMonitoringData);
//        dataPublishService.publish("24102801", "123", deviceMonitoringData);
//        dataPublishService.publish("20241029", "123", deviceMonitoringData);
//        dataPublishService.publish("abc", "123", deviceMonitoringData);

        ThreadUtil.sleep(10, TimeUnit.SECONDS);
    }
}