using Dapper;
using NetCore.Common;
using NetCore.Model.enums;
using NetCore.Model.qw;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
namespace NetCore.BLL.qw
{
public class hg_record_bll
{
private string comcode;
public hg_record_bll(string _comcode)
{
comcode = _comcode;
}
///
/// 获取需要翻译的数据
///
///
public List GetNeedTransList(int clearcount)
{
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.qwContext, comcode))
{
string sql = string.Format(@"select * from hg_ordervoice b
where transstatus=0
and ctime>@mintime
and msgctime(sql, new { mintime = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd") }, buffered: false).ToList();
}
}
public bool ExeRecordToVoice(DateTime time)
{
try
{
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.qwContext, comcode))
{
string sql = string.Format(@"insert into hg_ordervoice(corpid,tablename,seq,msgid,msgctime,msgtype,nfile,checkdate,ctime,fromer,tolist)
select t.corpid,'ww_record',0,t.voiceid,t.starttime,'phone',t.filename, date_format(t.endtime,'%Y-%m-%d'),t.ctime,t.fromer,t.tolist from wework.ww_record t
where EXISTS (select 1 from hg_orderuser a where a.external_userid=t.tolist)
and EXISTS (select 1 from hg_jobuser a where a.userid=t.fromer and a.corpid=t.corpid)
and t.endtime >@stime
and t.endtime<@etime
and not exists(select 1 from hg_ordervoice a where a.msgid=t.voiceid)");
con.Execute(sql, new { stime = time, etime = time.AddDays(1) });
return true;
}
}
catch (Exception e)
{
LogHelper.Error(e.ToString());
return false;
}
}
}
}