|
@@ -141,7 +141,7 @@ namespace MWS.Data.Manager
|
|
|
{
|
|
|
|
|
|
string insertSql = "INSERT INTO record (time,grossweight,tareweight,netweight,device,entrance,team)" +
|
|
|
- "VALUES(@CreationTime,@GrossWeight,@TareWeight,@NetWeight,@device,@entrance,@team)";
|
|
|
+ "VALUES(@CreationTime,@GrossWeight,@TareWeight,@NetWeight,@device,@entrance,@team); select @@IDENTITY";
|
|
|
|
|
|
return Execute<Record>(insertSql, new { CreationTime= t_record.CreationTime,GrossWeight = t_record.GrossWeight, TareWeight = t_record.TareWeight, NetWeight = t_record.NetWeight, device = t_record.Device, entrance = t_record.Entrance, team = t_record.Team });
|
|
|
}
|
|
@@ -430,6 +430,35 @@ namespace MWS.Data.Manager
|
|
|
return weightRecordDtos;
|
|
|
}
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 获取当前数据前一条或后一条
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id">当前id</param>
|
|
|
+ /// <param name="deviceId">设备id</param>
|
|
|
+ /// <param name="isNext">1代表下一条,0或其他上一条</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public Record GetNextOne(int id, int deviceId, int isNext)
|
|
|
+ {
|
|
|
+ string selectSql = "SELECT * from record where 1=1 ";
|
|
|
+ if (deviceId > 0)
|
|
|
+ {
|
|
|
+ selectSql += " and device = " + deviceId;
|
|
|
+ }
|
|
|
+ if (isNext==1)
|
|
|
+ {
|
|
|
+ selectSql += " and id>"+id;
|
|
|
+ selectSql += " order by id limit 1";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ selectSql += " and id<" + id;
|
|
|
+ selectSql += " order by id desc limit 1";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ var weightRecord = Query<Record>(selectSql).FindFirst();
|
|
|
+ return weightRecord;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|