using WcsMain.Common; using WcsMain.DataBase.TableEntity; using WcsMain.Constant.WcsAttribute.AutoFacAttribute; namespace WcsMain.DataBase.Dao; [Component] public class AppPLCDao { /// /// 查询PLC数据 /// /// public List? Query() { try { List appPLCs = CommonTool.DbServe.Queryable().OrderBy(o => o.PLCId).ToList(); return appPLCs; } catch (Exception ex) { _ = ex; } return default; } /// /// 根据条件查询 /// /// /// public List? Query(AppPLC plc) { try { var sqlFuc = CommonTool.DbServe.Queryable() .WhereIF(plc.PLCId != default, w=>w.PLCId == plc.PLCId) .WhereIF(plc.PLCIp != default, w => w.PLCIp == plc.PLCIp) .WhereIF(plc.PLCName != default, w => w.PLCName == plc.PLCName) .WhereIF(plc.PLCStatus != default, w => w.PLCStatus == plc.PLCStatus) .WhereIF(plc.PLCKind != default, w => w.PLCKind == plc.PLCKind) .WhereIF(plc.PLCRack != default, w => w.PLCRack == plc.PLCRack) .WhereIF(plc.PLCSlot != default, w => w.PLCSlot == plc.PLCSlot) .OrderBy(o => o.PLCId); var ss = sqlFuc.ToSql(); return sqlFuc.ToList(); } catch (Exception ex) { _ = ex; } return default; } /// /// 根据主键返回更新条数 /// /// /// public int Update(AppPLC plcInfo) { try { var sqlFuc = CommonTool.DbServe.Updateable(plcInfo).IgnoreColumns(ignoreAllNullColumns: true); return sqlFuc.ExecuteCommand(); } catch (Exception ex) { _ = ex; } return default; } /// /// 插入一条新记录 /// /// /// public int Insert(AppPLC plcInfo) { try { var sqlFuc = CommonTool.DbServe.Insertable(plcInfo); return sqlFuc.ExecuteCommand(); } catch (Exception ex) { _ = ex; } return default; } /// /// 删除一行数据,根据主键 /// /// /// public int Delete(AppPLC plcInfo) { try { var sqlFuc = CommonTool.DbServe.Deleteable(plcInfo); return sqlFuc.ExecuteCommand(); } catch (Exception ex) { _ = ex; } return default; } /// /// 根据状态查询PLC数据 /// /// /// public List? GetDataWithStatus(int status) { try { List appPLCs = CommonTool.DbServe.Queryable().Where(w => w.PLCStatus == status).ToList(); return appPLCs; } catch (Exception ex) { _ = ex; } return default; } }