Ejemplo n.º 1
0
//增加插入考勤流水表记录功能
//added by hhd at 2006-06-27
static int InsertKQSerial(T_t_door_txdtl* tTxdtl)
{
	int ret = 0;
	int confid = 0;
	T_t_pif_card tCard;
	memset(&tCard,0,sizeof(tCard));
	/*
	ret = DB_t_pif_card_read_by_card_id(tTxdtl->card_no,&tCard);
	if(ret)
	{
		writelog(LOG_DEBUG,"DB_t_pif_card_read_by_card_id error,errcode=[%d]",ret);
		return ret;
	}
	*/
	ret = SaveKQSerial(tTxdtl);
	if(ret)
	{
		writelog(LOG_DEBUG,"SaveKQSerial error,errcode=[%d]",ret);
		return ret;
	}
	return 0;
}
Ejemplo n.º 2
0
int F930203(TRUSERID *handle, int iRequest, ST_PACK *in_pack, int *pRetCode, char *szMsg)
{
	T_t_door_txdtl txdtl;
	T_t_pif_card tCard;
	T_t_pif_device device;
	T_t_door_events event;
	int ret;
	char weigand_no[12+1] = "";
	memset(&device, 0, sizeof device);
	// 查询设备ID号
	if (in_pack->lvol5 > 0)
	{
		ret = DB_t_pif_device_read_by_device_id(in_pack->lvol5, &device);
	}
	else
	{
		// 先判断是不是有父设备ID
		if (in_pack->lvol2 > 0)
			ret = get_door_dev_by_parent_and_termid(&device, in_pack->lvol2
			                                        , in_pack->lvol1); // 通过机号查询
		else
		{
			// 判断父设备机号
			if (in_pack->lvol3 > 0)
				ret = find_device_by_parent_termid(&device, in_pack->lvol3, in_pack->lvol1
				                                   , in_pack->lserial0); // 通过父设备机号与设备机号查询
			else
			{
				// 通过子系统号与设备机号查询
				ret = find_device_by_devinfo(&device, in_pack->lcert_code, in_pack->lvol1
				                             , in_pack->sbank_code, 1001);//in_pack->lserial0);
			}
		}
	}
	if (ret)
	{
		writelog(LOG_ERR, "get_door_dev_by_parent_and_termid err,device[=%d]parent_id=[%d],dev_no=[%d],ret=[%d]",
		         in_pack->lvol5, in_pack->lvol2, in_pack->lvol1, ret);
		if (ret == E_DB_DEVICE_N)
		{
			writelog(LOG_ERR, "上传记录找不到对应的设备termid[%d]type[%s]parent[%d][%d],sys[%d],phytype[%d]"
			         , in_pack->lvol1, in_pack->sbank_code, in_pack->lvol2, in_pack->lvol3, in_pack->lcert_code, in_pack->lserial0);
			return 0;
		}
		else
		{
			*pRetCode = ret;
			goto L_RETU;
		}
	}
	// 没有物理卡号
	if (strlen(in_pack->sdate1) == 0)
	{
		//事件
		memset(&event, 0, sizeof event);
		event.device_id = device.device_id;
		event.event_code = atoi(in_pack->semp_no);
		des2src(event.event_msg, in_pack->vsmess);
		event.sysid = in_pack->lcert_code;
		des2src(event.tx_date, in_pack->sdate0);
		des2src(event.tx_time, in_pack->stime0);
		getsysdate(event.col_date);
		getsystime(event.col_time);
		ret = DB_t_door_events_add(&event);
		if (ret)
		{
			if (DB_REPEAT == ret)	return 0;
			*pRetCode = E_DB_DOOR_TXDTL_I;
			goto L_RETU;
		}
		return 0;

	}
	else
	{
		memset(&tCard, 0, sizeof tCard);
		ret = get_card_by_phyno(&tCard, in_pack->sdate1);
		if (ret)
		{
			if (ret == E_DB_CARD_N)
			{
				ConverPhyNo(in_pack->sdate1, weigand_no);
				ret = get_card_by_weigand_no(&tCard, weigand_no);
				if (ret)
				{
					writelog(LOG_ERR, "Get_card_by_weigand_no err,weigand_no=[%s],ret=[%d]", weigand_no, ret);
					// 没有这张卡,仍然保留流水
					if (ret != E_DB_CARD_N)
					{
						*pRetCode = ret;
						goto L_RETU;
					};
				}
			}
			else
			{
				*pRetCode = ret;
				goto L_RETU;
			}
		}
		memset(&txdtl, 0, sizeof txdtl);
		txdtl.device_id = device.device_id;
		txdtl.card_no = tCard.card_id;
		txdtl.sys_id = in_pack->lcert_code;
		txdtl.cust_id = tCard.cosumer_id;
		if (!ret)	des2src(txdtl.phycard_no, tCard.physical_no);
		else des2src(txdtl.phycard_no, in_pack->sdate1);
		//writelog(LOG_DEBUG,"door serial date[%s] time[%s]",in_pack->sdate0,in_pack->stime0);
		des2src(txdtl.tx_date, in_pack->sdate0);
		des2src(txdtl.tx_time, in_pack->stime0);
		getsysdate(txdtl.col_date);
		getsystime(txdtl.col_time);
		txdtl.tx_mark = atoi(in_pack->semp_no);
		// 保存门禁流水
		ret = DB_t_door_txdtl_add(&txdtl);
		if (ret)
		{
			// 重复流水忽略
			if (DB_REPEAT == ret)
			{
				writelog(LOG_DEBUG, "流水重复card[%s],date[%s],time[%s]", in_pack->sdate1
				         , in_pack->sdate0, in_pack->stime0);
				return 0;
			}
			writelog(LOG_ERR, "保存流水失败card[%s],date[%s],time[%s]", in_pack->sdate1
			         , in_pack->sdate0, in_pack->stime0);
			*pRetCode = E_DB_DOOR_TXDTL_I;
			goto L_RETU;
		}
		switch (device.dev_usage)
		{
		case DU_JSB_CONFRENCE:
			/*
			ret = SaveDoorJSBSerial(&txdtl);
			if(ret)
			{
				writelog(LOG_ERR,"保存计时宝流水失败,errcode[%d]",ret);
				break;
			}
			ret = UpdateConferSerial(&txdtl);
			*/
			break;
		case DU_JSB_ATTENDANCE:
			ret = SaveKQSerial(&txdtl);
			if (ret)
			{
				writelog(LOG_ERR, "插入考勤流水表失败,errcode[%d]", ret);
				break;
			}
		default:
			//ret = SaveDoorJSBSerial(&txdtl);
			break;
		}
		if (ret)
		{
			*pRetCode = ret;
			goto L_RETU;
		}
	}
	return 0;

L_RETU:
	return -1;

}
Ejemplo n.º 3
0
int F930203(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg)
{
    T_t_door_txdtl txdtl;
    T_t_pif_card tCard;
    T_t_pif_device device;
    T_t_door_events event;
    int ret;
    memset(&device,0,sizeof device);
    if(in_pack->lvol2 > 0)
        ret = get_door_dev_by_parent_and_termid(&device,in_pack->lvol2,in_pack->lvol1);
    else
    {
        if(in_pack->lvol3>0)
            ret = find_device_by_parent_termid(&device,in_pack->lvol3,in_pack->lvol1,in_pack->lserial0);
        else
        {
            writelog(LOG_ERR,"上传流水无设备信息");
            return 0;
        }
    }
    if(ret)
    {
        if(ret == E_DB_DEVICE_N)
        {
            writelog(LOG_ERR,"上传记录找不到对应的设备");
            return 0;
        }
        *pRetCode = ret;
        return -1;
    }
    if(strlen(in_pack->sdate1) == 0)
    {
        //事件
        memset(&event,0,sizeof event);
        event.device_id = device.device_id;
        event.event_code = atoi(in_pack->semp_no);
        des2src(event.event_msg,in_pack->vsmess);
        event.sysid = in_pack->lcert_code;
        des2src(event.tx_date,in_pack->sdate0);
        des2src(event.tx_time,in_pack->stime0);
        getsysdate(event.col_date);
        getsystime(event.col_time);
        ret = DB_t_door_events_add(&event);
        if(ret)
        {
            if(DB_REPEAT == ret)
                return 0;
            *pRetCode = E_DB_DOOR_TXDTL_I;
            return -1;
        }
        return 0;

    }
    else if(strlen(in_pack->sdate1) !=8)
    {
        // 流水卡号错误
        writelog(LOG_DEBUG,"数据有误");
        return 0;
    }
    else
    {
        memset(&tCard,0,sizeof tCard);
        ret = get_card_by_phyno(&tCard,in_pack->sdate1);
        if(ret)
        {
            // 没有这张卡
            if(ret != E_DB_CARD_N)
            {
                *pRetCode = ret;
                return -1;
            }
        }
        memset(&txdtl,0,sizeof txdtl);
        txdtl.device_id = device.device_id;
        txdtl.card_no = tCard.card_id;
        txdtl.sys_id = in_pack->lcert_code;
        txdtl.cust_id = tCard.cosumer_id;
        des2src(txdtl.phycard_no,in_pack->sdate1);
        //writelog(LOG_DEBUG,"door serial date[%s] time[%s]",in_pack->sdate0,in_pack->stime0);
        des2src(txdtl.tx_date,in_pack->sdate0);
        des2src(txdtl.tx_time,in_pack->stime0);
        getsysdate(txdtl.col_date);
        getsystime(txdtl.col_time);
        txdtl.tx_mark = atoi(in_pack->semp_no);

        ret = DB_t_door_txdtl_add(&txdtl);
        if(ret)
        {
            // 重复流水忽略
            if(DB_REPEAT == ret)
            {
                writelog(LOG_DEBUG,"流水重复card[%s],date[%s],time[%s]",in_pack->sdate1
                         ,in_pack->sdate0,in_pack->stime0);
                return 0;
            }
            writelog(LOG_ERR,"保存流水失败card[%s],date[%s],time[%s]",in_pack->sdate1
                     ,in_pack->sdate0,in_pack->stime0);
            *pRetCode = E_DB_DOOR_TXDTL_I;
            return -1;
        }
        switch(device.dev_usage)
        {
        case DU_JSB_CONFRENCE:
            /*
            ret = SaveDoorJSBSerial(&txdtl);
            if(ret)
            {
            	writelog(LOG_ERR,"保存计时宝流水失败,errcode[%d]",ret);
            	break;
            }
            ret = UpdateConferSerial(&txdtl);
            */
            break;
        case DU_JSB_ATTENDANCE:
            ret = SaveKQSerial(&txdtl);
            if(ret)
            {
                writelog(LOG_ERR,"插入考勤流水表失败,errcode[%d]",ret);
                break;
            }
        default:
            //ret = SaveDoorJSBSerial(&txdtl);
            break;
        }
        if(ret)
        {
            *pRetCode = ret;
            return -1;
        }
        return 0;
    }

}
Ejemplo n.º 4
0
int F930101(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg)
{

	int ret= 0;
	int dev_usage = 0;
	//T_t_attend_txdtl tTxdtl;
	T_t_door_txdtl tTxdtl;
	T_t_pif_device tDevice;
	T_t_pif_card tCard;
	if(strlen(rPack->sdate0) != 8)
	{
		*pRetCode = E_DEVPHYID_NULL;
		goto L_RETU;
	}

	/*
	ret=chk_dyn_key(rPack->lcert_code,rPack->scust_limit2);
	if(ret)
	{
		writelog(LOG_ERR,"subsys_id[%d]dyn_key[%s]",rPack->lcert_code,rPack->scust_limit2);
		*pRetCode =  ret;
		goto L_RETU;
	}
	*/
	memset(&tTxdtl,0,sizeof(tTxdtl));
	memset(&tDevice,0,sizeof tDevice);

	/*

	tTxdtl.serial_no= rPack->lvol3;						//上传端流水号
	tTxdtl.sys_id  = rPack->lcert_code;					//上传工作站标识(前置机注册号)
//		tTxdtl.mode_code=rPack->lvol6;					//模式代码
	tTxdtl.card_no= rPack->lvol7;						//交易卡号
//		tTxdtl.use_type= rPack->lvol8;						//考勤类型
//		tTxdtl.inductor_no= rPack->lvol9;					//感应头标记
//		tTxdtl.work_mark=rPack->lvol10;					//上下班标志
	tTxdtl.tx_mark=rPack->lvol11;						//999交易标志
	des2src(tTxdtl.device_id, rPack->sdate0);			//物理设备ID
	des2src(tTxdtl.tx_date,rPack->sdate1);				//发生日期(格式化输入的日期)
	des2src(tTxdtl.crc,rPack->sbank_code2);				//CRC校验
	des2src(tTxdtl.tx_time,rPack->spost_code2);			//发生时间(格式化输入的时间)
	getsysdate(tTxdtl.col_date);
	getsystime(tTxdtl.col_time);
//		ret=check(&tTxdtl);
//		if(ret)
//		{
//			tTxdtl.status[0]='5';							//无效交易
//			//tTxdtl.err_code=ret;
//			writelog(LOG_DEBUG,"无效流水device_id[%d]serial_no[%d]",tTxdtl.device_id,tTxdtl.serial_no);
//			return ret;
//		}
//		else
//			tTxdtl.status[0]='1';
	ret = SaveDoorJSBSerial(&tTxdtl);
	*/
	tTxdtl.serial_no= rPack->lvol3;						//上传端流水号
	tTxdtl.sys_id  = rPack->lcert_code;					//上传工作站标识(前置机注册号)
//		tTxdtl.mode_code=rPack->lvol6;					//模式代码
	tTxdtl.card_no= rPack->lvol7;						//交易卡号
	memset(&tCard,0,sizeof tCard);
	ret = DB_t_pif_card_read_by_card_id(tTxdtl.card_no,&tCard);
	if(ret)
	{
		if(DB_NOTFOUND == ret)
		{
			// 卡号不存在
			writelog(LOG_ERR,"上传的交易卡号deviceid[%s],cardno[%d],不存在",
				rPack->sdate0,tTxdtl.card_no);
			return 0;
		}
		else
		{
			writelog(LOG_ERR,"上传的交易卡号读取表失败cardno[%d]",tTxdtl.card_no);
			*pRetCode = E_DB_CARD_R;
			goto L_RETU;
		}
	}
//		tTxdtl.use_type= rPack->lvol8;						//考勤类型
//		tTxdtl.inductor_no= rPack->lvol9;					//感应头标记
//		tTxdtl.work_mark=rPack->lvol10;					//上下班标志
	des2src(tTxdtl.phycard_no,tCard.physical_no);
	tTxdtl.cust_id = tCard.cosumer_id; //客户号
	tTxdtl.tx_mark=rPack->lvol11;						//999交易标志
	//des2src(tTxdtl.device_id, rPack->sdate0);			//物理设备ID
	ret = get_devinfo_by_phyid(rPack->sdate0,&tDevice);
	if(ret)
	{
		if(DB_NOTFOUND == ret)
		{
			// 设备不存在
			writelog(LOG_ERR,"采集计时宝流水,设备不存在或已注销[%s]"
			,rPack->sdate0);
			return 0;
		}
		else
		{
			*pRetCode = ret;
			goto L_RETU;
		}
	}
	tTxdtl.device_id = tDevice.device_id;
	//if(strlen(rPack->sdate1)==0)
	//	getsysdate(tTxdtl.tx_date);
	//else 	
	if(strlen(rPack->sdate1)==6)
	{
		sprintf(tTxdtl.tx_date,"20%s",rPack->sdate1);
	}
	else
		des2src(tTxdtl.tx_date,rPack->sdate1);				//发生日期(格式化输入的日期)

	des2src(tTxdtl.crc,rPack->sbank_code2);				//CRC校验
	des2src(tTxdtl.tx_time,rPack->spost_code2);			//发生时间(格式化输入的时间)
	getsysdate(tTxdtl.col_date);
	getsystime(tTxdtl.col_time);
	check(&tTxdtl);
	g_dbchkerr=0;
	ret = DB_t_door_txdtl_add(&tTxdtl);
	g_dbchkerr=1;
	if(ret)
	{
		if(DB_REPEAT == ret)
			return 0;
		writelog(LOG_ERR,"插入门禁流水表失败,errcode[%d]",ret);
		writelog(LOG_ERR,"serial_no[%d]phycardid[%s]card_no[%d]device_id[%s]tx_date[%s]tx_time[%s]",
			tTxdtl.serial_no,tTxdtl.phycard_no,tTxdtl.card_no,tTxdtl.device_id,tTxdtl.tx_date,tTxdtl.tx_time);
		*pRetCode = ret;
		goto L_RETU;
	}
	ret = SaveKQSerial(&tTxdtl);
	if(ret)
	{
		writelog(LOG_ERR,"插入考勤流水表失败,errcode[%d]",ret);
		*pRetCode = ret;
		goto L_RETU;
	}
	return 0;
L_RETU:
	return -1;
}