private void InsertData(List<special_alarm_detour> list)
{
try
{
using (var db = new DapperHelper(BasicInformation.connection))
{
try
{
List<List<special_alarm_detour>> listGroup = new List<List<special_alarm_detour>>();
int j = 1000;
for (int i = 0; i < list.Count; i += 1000)//以1000为一组分组
{
List<special_alarm_detour> cList = new List<special_alarm_detour>();
cList = list.Take(j).Skip(i).ToList();
j += 1000;
listGroup.Add(cList);
}
for (int i = 0; i < listGroup.Count; i++)
{
List<special_alarm_detour> fzlist = new List<special_alarm_detour>();
fzlist = listGroup[i];
using (var ctx = db.TranStart())
{
try
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Restart();
db.Insert<special_alarm_detour>(fzlist);
ctx.Commit();
stopwatch.Stop();
Log.Blue($"【车辆绕行】插入数据:{fzlist.Count}条,耗时:{stopwatch.ElapsedMilliseconds}毫秒");
}
catch (Exception ex)
{
ctx.Rollback();
Log.Error($"【车辆绕行】插入数据报错:{ex.Message.ToString()}");
}
}

}
}
catch (Exception ex)
{
Log.Error($"【车辆绕行】插入数据报错:{ex.Message.ToString()}");
}

}
}
catch (Exception ex)
{
Log.Error($"【车辆绕行】插入数据报错:{ex.Message.ToString()}");
}
}