设备管理
This commit is contained in:
136
ZR.Service/mes/Device/DeviceRouteInspectionPlanService.cs
Normal file
136
ZR.Service/mes/Device/DeviceRouteInspectionPlanService.cs
Normal file
@@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using ZR.Model;
|
||||
using ZR.Repository;
|
||||
|
||||
using System.Linq;
|
||||
using ZR.Model.MES.dev;
|
||||
using ZR.Model.MES.dev.Dto;
|
||||
using ZR.Service.MES.dev.IService;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace ZR.Service.MES.dev
|
||||
{
|
||||
/// <summary>
|
||||
/// 巡检计划Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IDeviceRouteInspectionPlanService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class DeviceRouteInspectionPlanService : BaseService<DeviceRouteInspectionPlan>, IDeviceRouteInspectionPlanService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询巡检计划列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<DeviceRouteInspectionPlanDto> GetList(DeviceRouteInspectionPlanQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<DeviceRouteInspectionPlan>();
|
||||
|
||||
predicate.AndIF(!string.IsNullOrEmpty(parm.Name), it => it.Name.Contains(parm.Name))
|
||||
.AndIF(parm.LifeCycleStart != null, it => it.LifeCycleStart >= parm.LifeCycleStart)
|
||||
.AndIF(parm.LifeCycleEnd != null, it => it.LifeCycleEnd <= parm.LifeCycleEnd)
|
||||
.AndIF(parm.ExcuteCycleType > 0, it => it.ExcuteCycleType == parm.ExcuteCycleType)
|
||||
.AndIF(parm.InnerType>-1, it => it.InnerType == parm.InnerType);
|
||||
|
||||
var response = Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.ToPage<DeviceRouteInspectionPlan, DeviceRouteInspectionPlanDto>(parm);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
public DeviceRouteInspectionPlan GetInfo(string Id)
|
||||
{
|
||||
var response = Queryable()
|
||||
.Where(x => x.Id == Id)
|
||||
.First();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加巡检计划
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public DeviceRouteInspectionPlan AddDeviceRouteInspectionPlan(DeviceRouteInspectionPlan model)
|
||||
{
|
||||
model.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
||||
|
||||
switch (model.ExcuteCycleType)
|
||||
{
|
||||
case 1:
|
||||
model.WeekList = "";
|
||||
model.MonthDayList = "";
|
||||
break;
|
||||
case 2:
|
||||
model.DayNum = null;
|
||||
model.MonthDayList = "";
|
||||
break;
|
||||
case 3:
|
||||
model.DayNum = null;
|
||||
model.WeekList = "";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Context.Insertable(model).ExecuteReturnEntity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改巡检计划
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateDeviceRouteInspectionPlan(DeviceRouteInspectionPlan model)
|
||||
{
|
||||
switch (model.ExcuteCycleType)
|
||||
{
|
||||
// 每日
|
||||
case 1:
|
||||
model.WeekList = "";
|
||||
model.MonthDayList = "";
|
||||
break;
|
||||
//每周
|
||||
case 2:
|
||||
model.DayNum = null;
|
||||
model.MonthDayList = "";
|
||||
break;
|
||||
//每月
|
||||
case 3:
|
||||
model.WeekList = "";
|
||||
model.DayNum = null;
|
||||
break;
|
||||
}
|
||||
var response = Update(w => w.Id == model.Id, it => new DeviceRouteInspectionPlan()
|
||||
{
|
||||
Name = model.Name,
|
||||
Status = model.Status,
|
||||
InnerType = model.InnerType,
|
||||
LifeCycleStart = model.LifeCycleStart,
|
||||
LifeCycleEnd = model.LifeCycleEnd,
|
||||
ExcuteCycleType = model.ExcuteCycleType,
|
||||
DayNum = model.DayNum,
|
||||
WeekList = model.WeekList,
|
||||
MonthDayList = model.MonthDayList,
|
||||
Remark = model.Remark,
|
||||
|
||||
UpdatedBy = model.UpdatedBy,
|
||||
UpdatedTime = model.UpdatedTime,
|
||||
});
|
||||
return response;
|
||||
// return Update(model, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user