166 lines
5.7 KiB
C#
166 lines
5.7 KiB
C#
using Dapper;
|
|
using NetCore.Common;
|
|
using NetCore.Model.enums;
|
|
using NetCore.Model.qw;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
|
|
namespace NetCore.BLL
|
|
{
|
|
public class hg_ordervoice_bll
|
|
{
|
|
private List<hg_ordervoice> _ordrvoic { get; set; }
|
|
private string comcode;
|
|
public hg_ordervoice_bll(string _comcode)
|
|
{
|
|
_ordrvoic = new List<hg_ordervoice>();
|
|
comcode = _comcode;
|
|
}
|
|
public void Clear()
|
|
{
|
|
_ordrvoic = new List<hg_ordervoice>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增数据
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public bool Add(hg_ordervoice model)
|
|
{
|
|
_ordrvoic.Add(model);
|
|
return true;
|
|
}
|
|
|
|
public void StartInsert()
|
|
{
|
|
|
|
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.qwContext, comcode))
|
|
{
|
|
foreach (var model in _ordrvoic)
|
|
{
|
|
try
|
|
{
|
|
hg_ordervoice getmodel = con.QueryFirstOrDefault<hg_ordervoice>("select corpid,seq,msgid from hg_ordervoice where msgid=@msgid", new { model.msgid });
|
|
|
|
if (getmodel == null || string.IsNullOrEmpty(getmodel.msgid))//无数据,需要插入数据
|
|
{
|
|
//无数据
|
|
con.Execute("insert into hg_ordervoice(corpid,tablename,seq,msgid,msgtype,md5sum,nfile,checkdate,ctime,msgctime,voiceUrl,fromer,tolist)" +
|
|
"values(@corpid,@tablename,@seq,@msgid,@msgtype,@md5sum,@nfile,@checkdate,now(),@msgctime,@voiceUrl,@fromer,@tolist)", model);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine("普通合规消息入库失败:" + JsonConvert.SerializeObject(model));
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取需要翻译的数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<hg_ordervoice> 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<date_add(now(), interval -10 minute)
|
|
order by seq asc limit {0}", clearcount);
|
|
|
|
return con.Query<hg_ordervoice>(sql, new { mintime = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd") }, buffered: false).ToList();
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取需要翻译的数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<hg_ordervoice> GetNeedHegList(int clearcount)
|
|
{
|
|
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.qwContext, comcode))
|
|
{
|
|
|
|
string sql = string.Format(@"select * from hg_ordervoice b
|
|
where transstatus=1
|
|
and ishg=0
|
|
order by seq asc limit {0}", clearcount);
|
|
|
|
return con.Query<hg_ordervoice>(sql, new { mintime = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd") }, buffered: false).ToList();
|
|
|
|
}
|
|
}
|
|
public void UpdateHgStatus(List<int> ids)
|
|
{
|
|
|
|
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.qwContext, comcode))
|
|
{
|
|
foreach (var item in ids)
|
|
{
|
|
con.Execute("update hg_ordervoice set ishg=1,hgtime=now() where id=@id ", new { id = item });
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 调用了翻译
|
|
/// </summary>
|
|
/// <param name="transcontent"></param>
|
|
/// <param name="id"></param>
|
|
/// <param name="transstatus"></param>
|
|
public bool ToTrans(int id, int transstatus)
|
|
{
|
|
bool result = true;
|
|
try
|
|
{
|
|
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.qwContext, comcode))
|
|
{
|
|
string sql = string.Format(@"update hg_ordervoice set transstatus=@transstatus,transtime=now() where id=@id");//过滤掉,只执行订单客服消息
|
|
con.Execute(sql, new { transstatus = transstatus, id = id });
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
LogHelper.Error(e.ToString());
|
|
result = false;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 翻译数据
|
|
/// </summary>
|
|
/// <param name="transcontent"></param>
|
|
/// <param name="id"></param>
|
|
/// <param name="transstatus"></param>
|
|
public bool TransBack(string transcontent, int id, int transstatus)
|
|
{
|
|
bool result = true;
|
|
try
|
|
{
|
|
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.qwContext, comcode))
|
|
{
|
|
string sql = string.Format(@"update hg_ordervoice set transstatus=@transstatus,transtime=now(),transcontent=@transcontent where id=@id");//过滤掉,只执行订单客服消息
|
|
con.Execute(sql, new { transstatus = transstatus, transcontent = transcontent, id = id });
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
LogHelper.Error(e.ToString());
|
|
result = false;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
}
|
|
}
|