shgx_tz_mom/ZR.Service/mes/pro/ProWorkplanService.cs

79 lines
2.6 KiB
C#
Raw Permalink Normal View History

2023-11-14 14:30:14 +08:00
using Infrastructure.Attribute;
using SqlSugar;
using System;
using ZR.Model.mes.pro;
using ZR.Service.mes.pro.IService;
namespace ZR.Service.mes.pro
{
[AppService(ServiceType = typeof(IProWorkplanService), ServiceLifetime = LifeTime.Transient)]
public class ProWorkplanService : BaseService<ProWorkplan>, IProWorkplanService
{
2024-06-07 11:04:26 +08:00
2023-11-14 14:30:14 +08:00
public (List<ProWorkplan>, int) GetAllData(int pageNum, int pageSize, int year, int week, string partNumber, string color)
{
var predicate = Expressionable.Create<ProWorkplan>()
.AndIF(year > 0, it => it.Year == year)
.AndIF(week > 0, it => it.Week == week)
2024-06-07 11:04:26 +08:00
.AndIF(!string.IsNullOrEmpty(partNumber), it => it.Partnumber.Contains(partNumber))
2023-11-14 14:30:14 +08:00
.AndIF(!string.IsNullOrEmpty(color), it => it.Color.Contains(color))
.ToExpression();
int totalCount = 0;
List<ProWorkplan> proWorkplanList = Context.Queryable<ProWorkplan>().Where(predicate).ToPageList(pageNum, pageSize, ref totalCount);
return (proWorkplanList, totalCount);
}
2023-11-14 18:46:59 +08:00
2024-06-07 11:04:26 +08:00
2023-11-15 15:36:18 +08:00
public List<ProWorkplan> GetProWorkplanById(string id)
{
return Context.Queryable<ProWorkplan>().Where(it => it.Id == id).ToList();
}
2023-11-14 18:46:59 +08:00
public int AddWorkPlan(ProWorkplan proWorkplan)
{
proWorkplan.Id = DateTime.Now.ToString("yyyyMMddHHmmss");
return Context.Insertable(proWorkplan).ExecuteCommand();
}
public int UpdateWorkPlan(ProWorkplan proWorkplan)
{
return Context.Updateable(proWorkplan).ExecuteCommand();
}
public int DeleteWorkPlan(string id)
{
return Context.Deleteable<ProWorkplan>().In(id).ExecuteCommand();
}
2023-11-15 14:38:10 +08:00
public List<ProWorkorder> GetWorkorderListByPlanId(string id)
2023-11-15 14:38:10 +08:00
{
return Context.Queryable<ProWorkorder>().Where(it => it.FkProPlanId == id).OrderBy("priority desc ").ToList();
2023-11-15 14:38:10 +08:00
}
2023-11-15 14:53:20 +08:00
2023-11-16 09:35:16 +08:00
public List<ProWorkorder> GetWorkorderListById(string id)
{
return Context.Queryable<ProWorkorder>().Where(it => it.Id == id).ToList();
}
2023-11-15 14:53:20 +08:00
public int AddWorkorder(ProWorkorder proWorkorder)
{
2024-06-07 11:04:26 +08:00
2023-11-15 14:53:20 +08:00
return Context.Insertable(proWorkorder).ExecuteCommand();
}
public int UpdateWorkorder(ProWorkorder proWorkorder)
{
return Context.Updateable(proWorkorder).ExecuteCommand();
}
public int DeleteWorkorder(string id)
{
return Context.Deleteable<ProWorkorder>().In(id).ExecuteCommand();
}
2023-11-15 15:36:18 +08:00
2024-06-07 11:04:26 +08:00
2023-11-14 14:30:14 +08:00
}
}