SearchMapperTest.java 8.78 KB
package com.example.dahua.mapper;

import com.alibaba.fastjson.JSON;
import com.example.dahua.MyTask;
import com.example.dahua.Tester;
import com.example.dahua.async.MyScheduledTask;
import com.example.dahua.async.SendFaceBatchTask2;
import com.example.dahua.bean.*;
import com.example.dahua.dao.PermissionFaceDao;
import com.example.dahua.dao.UserDao;
import com.example.dahua.enums.EnumSzBusinessType;
import com.example.dahua.mqtt.MqttManager;
import com.example.dahua.service.DeleteBatchTest;
import com.example.dahua.service.PermissFaceService;
import com.example.dahua.service.UserService;
import com.example.dahua.utils.BaiduUtils;
import com.example.dahua.utils.DateUtils;
import com.example.dahua.utils.HttpUtil;
import com.example.dahua.utils.JsonUtils;
import com.example.dahua.xiananDao.SearchMapper;
import com.example.dahua.xiananDao.SendRecordDao;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.concurrent.*;

/**
 * TODO
 *
 * @author xuquan
 * @date 2020/11/11 12:13
 */

public class SearchMapperTest extends Tester {

    @Autowired
    private SearchMapper searchMapper;

    @Autowired
    private UserDao userDao;

    @Autowired
    private UserService userService;

    @Autowired
    private PermissionFaceDao permissionFaceDao;

    @Autowired
    private PermissFaceService permissFaceService;

    @Autowired
    private DeleteBatchTest deleteBatchTest;

    @Test
    public void test(){
        AttendanceBean attendanceBean =userDao.getTypeByClint_id("ytj01hzszdddddddd");
        String outOrIn = attendanceBean.getOutOrIn();
        //有效刷卡调考勤存储过程
        CheckIn checkIn = new CheckIn();
        checkIn.setDeviceId("ytj01hzszdddddddd");
        checkIn.setCardNo("611621AC");
        checkIn.setFunNo(8);
        checkIn.setFlag(Integer.parseInt(outOrIn) == EnumSzBusinessType.EnumDeviceInAndOut.INT.code ? 0:1);
        checkIn.setCheckTime("2020-11-20 12:19:12");
        searchMapper.checkIn(checkIn);
        System.out.println(JSON.toJSON(checkIn));
    }

    @Test
    public void test2(){
        userDao.checkLeave("234232");
        System.out.println(JSON.toJSON(userDao.checkLeave("234232")));
        userDao.selectByParentMobile("234232");
        System.out.println(JSON.toJSON(userDao.selectByParentMobile("234232")));
//        userDao.checkLeave("234232");
//        System.out.println(JSON.toJSON(userDao.checkLeave("234232")));
    }

    @Test
    public void test3(){
        ShortMsg shortMsg = new ShortMsg();
        String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
        shortMsg.setTableName("smsNew" + tableSuffix);
        shortMsg.setSchoolId(23);
        shortMsg.setMobile("124124242");
//        userDao.insertMessage();
//        System.out.println(JSON.toJSON(userDao.checkLeave("234232")));

    }

    @Test
    public void test4(){
        PermissionFaceBean faceBean = permissionFaceDao.getPerFaceWithId(45);
        System.out.println(JsonUtils.nonDefaultMapper().toJson(faceBean));
        faceBean.setType(1);

        String json = "{\"studentType\":\"1\",\"deviceIds\":[\"ytj01hzszdddddddd\"],\"weekDays\":[{\"weekTimes\":[{\"startTime\":\"10:00\",\"endTime\":\"12:05\"}],\"sex\":\"1\",\"weekDay\":\"3,4,5\"}]}";
        PermissionBean permissionBean =  JsonUtils.nonDefaultMapper().fromJson(json,PermissionBean.class);
        faceBean.setPermissionBean(permissionBean);
        faceBean.setPerrmissName("顺治测试学校");
        faceBean.setChannel("");
        faceBean.setCustomName("");
        permissFaceService.addPermissionFace(faceBean);

    }


    private MqttManager mqttManager;

//    @Autowired
//    private MyTask myTask;

//    @Test
//    public void test5(){
//        if(null == mqttManager){
//            mqttManager = new MqttManager();
//            mqttManager.init();
//        }
//
//        String eventTime = DateUtils.date2String(new Date(), DateUtils.format2);
//        String deviceId ="";
//        String cardNo ="";
//        String content = "考勤成功!,设备:" + deviceId + "卡号:" + cardNo + "方向:进门" + "______" + eventTime;
//
//        myTask.sendMQMess(deviceId,cardNo,1);
//        System.out.println("发送成功");
//    }

    @Test
    public void test6() {
//        String path = "D://dahua-logs/sxzx2020889.png";
        String path = "D://dahua-logs/sxzx2020002.png";
        userService.test(path);
    }

    @Test
    public void test7() {
        String schoolId = "1037";
        deleteBatchTest.test(schoolId);
    }

    @Test
    public void test8() {
//        String schoolId = "1037";
//        deleteBatchTest.test2(schoolId);
        String schoolId = "1485";
        deleteBatchTest.test3(schoolId);

    }

    @Test
    public void test9() {
        String cardNum="8733277A";
        String intime= "2021-01-28 20:47:14";
        String systime="2021-01-28 20:47:23";
        String clientId ="253169469";
        deleteBatchTest.test5(cardNum,intime,systime,clientId);
    }

    @Test
    public void test10() {
        //男
        Integer roomId =11748;
//        String roomId ="12226";
        Integer type = 12;
        Integer outof = 0;
        String intime = "2021-01-24 20:26:14";
        String clintId="253169240";
        String startTime= "2021-01-24 00:00:00";
        String endTime ="2021-01-24 23:59:59";
        deleteBatchTest.test6(27,roomId,type,outof,intime,clintId,startTime,endTime);
    }

    @Test
    public void test11() {
        //男11748
        Integer roomId =11748;
//        String roomId ="12226";
        Integer type = 7;
        Integer outof = 1;
        String intime = "2021-01-08 06:03:39";
        String clintId="253169240";
        String startTime= "2021-01-08 00:00:00";
        String endTime ="2021-01-08 23:59:59";
        deleteBatchTest.test6(27,roomId,type,outof,intime,clintId,startTime,endTime);
    }

    @Test
    public void test12() {
        //男
        Integer roomId =11748;
//        String roomId ="12226";
//        Integer type = 7;
//        Integer outof = 1;
        Integer type = 12;
        Integer outof = 0;
        String startTime= "2021-01-24 00:00:00";
        String endTime ="2021-01-09 23:59:59";
        deleteBatchTest.test8(27,roomId,type,outof,startTime,endTime,47);
    }

    @Test
    public void test13() {
        //男11748
        Integer roomId =12226;
//        String roomId ="12226";
        Integer type =1;
        Integer outof = 0;
        String intime = "2021-01-21 06:03:39";
        String clintId="253185199";
        String startTime= "2021-01-21 00:00:00";
        String endTime ="2021-01-21 23:59:59";
        deleteBatchTest.test7(27,roomId,type,outof,intime,clintId,startTime,endTime);
    }

    @Test
    public void test14() {
        //男11748
        Integer roomId =12226;
//        String roomId ="12226";
        Integer type =4;
        Integer outof = 1;
        String intime = "2021-01-20 17:14:39";
        String clintId="253185199";
        String startTime= "2021-01-20 00:00:00";
        String endTime ="2021-01-20 23:59:59";
        deleteBatchTest.test7(27,roomId,type,outof,intime,clintId,startTime,endTime);
    }

    @Autowired
    private SendRecordDao sendRecordDao;

    @Test
    public void test15() {
        //男
        Integer schoolId=27;
        Integer roomId =12226;
        Integer type = 4;
        Integer outof = 0;
        String clintId="253169212";
        String timeIds = "2021-01-08,2021-01-11,2021-01-12,2021-01-13,2021-01-14,2021-01-15,2021-01-18,2021-01-19,2021-01-20,2021-01-21,2021-01-22";
        String[] deviceArr = timeIds.split(",");
        List<String> deviceList= new ArrayList<>(Arrays.asList(deviceArr));
        //启用多线程执行
        CountDownLatch begin = new CountDownLatch(1);
        CountDownLatch end = new CountDownLatch(deviceList.size());
        ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("thread-sendFace-runner-%d").build();
        ExecutorService exe = new ThreadPoolExecutor(8,16,0L, TimeUnit.MILLISECONDS,new LinkedBlockingQueue<Runnable>(),namedThreadFactory);
        for(String s : deviceList){
            String intime = s + " 06:03:39";
            String startTime= s + " 00:00:00";
            String endTime = s+" 23:59:59";
            exe.execute(new SendFaceBatchTask2(userDao,sendRecordDao,searchMapper,schoolId,roomId,type,outof,intime,clintId,startTime,endTime,begin,end));
        }
        begin.countDown();
        try {
            end.await();
        }catch (Exception e){
            e.printStackTrace();
        }
        exe.shutdown();
        System.out.println("统计100服务器总共有"+deviceList.size()+"个设备,处理完毕");
    }
}