SendUserAsync.java 2.59 KB
package com.sincere.haikangface.async;


import com.sincere.haikangface.CMSServer;
import com.sincere.haikangface.dao.DeviceDao;
import com.sincere.haikangface.dao.UserDao;
import com.sincere.haikangface.utils.*;
import com.sincere.haikangface.xiananDao.SendRecordDao;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.imageio.stream.FileImageInputStream;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*;

@Component
public class SendUserAsync {


    @Autowired
    CMSServer cmsServer;

    @Autowired
    DeviceDao deviceDao;

    @Autowired
    SendRecordDao sendRecordDao;

    @Autowired
    UserDao userDao;

    SendRecoderUtils sendRecoderUtils;

    //    @Async("taskExecutor")
    public void sendStuToHaiKang(String srcFile, String picUrl, String card, String startTime, String endTime, int validTimeEnabled, String name, String deviceId, String userType, int isPiliang) {
        System.out.println("下发时间设置:"+validTimeEnabled);
        if (null == sendRecoderUtils) sendRecoderUtils = new SendRecoderUtils();
        //1、检测图片是否合格
        boolean check = true;
        if (check) {//合格
            try {
                CompressPic.CompressPic(srcFile, picUrl);
            } catch (Exception e) {
                e.printStackTrace();
            }
            //根据设备是5603 还是新设备
            String employeeNo = "";
            if (deviceId.contains("ymzx")||deviceId.contains("5607")||deviceId.contains("5671")){
                employeeNo = System.currentTimeMillis()+"";
                cmsServer.SetCardWeekPlan(deviceId, HKXmlUtils.getInstance().SetCardTemplate(), "设置卡权限计划模板");
                cmsServer.SetCardWeekPlan(deviceId, HKXmlUtils.getInstance().SetCardWeekPlan(), "卡权限周计划");
                for (int i = 0; i < 7; i++) {
                    cmsServer. SetCardWeekPlan(deviceId, HKXmlUtils.getInstance().SetCardWeekPlanTime("00:00:00", "23:00:00",""+i), "设置卡权限周计划时间");
                }
                cmsServer.SetCardWeekPlan(deviceId, HKXmlUtils.getInstance().SetCardRightCfg(card), "设置卡权限");
            }

            boolean result = cmsServer.createImgPath(srcFile, picUrl, card, startTime, endTime, validTimeEnabled, name, deviceId, userType,employeeNo);
        } else {//不合格
            sendRecoderUtils.sendFail(sendRecordDao, card, srcFile, deviceId, userDao, "人脸照片不合格", userType);
        }

    }

}