98 lines
3.4 KiB
C#
98 lines
3.4 KiB
C#
using Infrastructure.Attribute;
|
|
using Mapster.Utils;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Model.DBModel;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using ZR.Model.mes.md;
|
|
using ZR.Model.mes.pro;
|
|
using ZR.Service.mes.pro.IService;
|
|
using ZR.Service.MES.md.IService;
|
|
|
|
namespace ZR.Service.mes.pro
|
|
{
|
|
|
|
[AppService(ServiceType = typeof(IProWorkplanServiceV2), ServiceLifetime = LifeTime.Transient)]
|
|
public class ProWorkplanServiceV2 : BaseService<ProWorklplan_v2>, IProWorkplanServiceV2
|
|
{
|
|
|
|
public (List<ProWorklplan_v2>, int) GetAllData(int pageNum, int pageSize, int year, int week, string partNumber, string color)
|
|
{
|
|
var predicate = Expressionable.Create<ProWorklplan_v2>()
|
|
.AndIF(year > 0, it => it.Year == year)
|
|
.AndIF(week > 0, it => it.Week == week)
|
|
.AndIF(!string.IsNullOrEmpty(partNumber), it => it.Partnumber.Contains(partNumber))
|
|
.AndIF(!string.IsNullOrEmpty(color), it => it.ColorCode.Contains(color))
|
|
.ToExpression();
|
|
int totalCount = 0;
|
|
List<ProWorklplan_v2> proWorkplanList = Context.Queryable<ProWorklplan_v2>().Where(predicate).ToPageList(pageNum, pageSize, ref totalCount);
|
|
return (proWorkplanList, totalCount);
|
|
}
|
|
|
|
|
|
public List<ProWorkplan> GetProWorkplanById(string id)
|
|
{
|
|
return Context.Queryable<ProWorkplan>().Where(it => it.Id == id).ToList();
|
|
}
|
|
|
|
public int AddWorkPlan(ProWorklplan_v2 proWorkplan)
|
|
{
|
|
ProWorklplan_v2 max_workplan = Context.Queryable<ProWorklplan_v2>().OrderBy(it => it.Id, OrderByType.Desc).First();
|
|
if (max_workplan != null && !string.IsNullOrEmpty(max_workplan.Id) && max_workplan.Id.Substring(2, 8) == DateTime.Now.ToString("yyyyMMdd"))
|
|
{
|
|
int num = Convert.ToInt32(max_workplan.Id.Substring(10)) + 1;
|
|
proWorkplan.Id = "MP" + DateTime.Now.ToString("yyyyMMdd") + num.ToString("000");
|
|
}
|
|
else
|
|
{
|
|
proWorkplan.Id = "MP" + DateTime.Now.ToString("yyyyMMdd") + "001";
|
|
}
|
|
|
|
return Context.Insertable(proWorkplan).ExecuteCommand();
|
|
}
|
|
|
|
public int UpdateWorkPlan(ProWorklplan_v2 proWorkplan)
|
|
{
|
|
return Context.Updateable(proWorkplan).ExecuteCommand();
|
|
}
|
|
|
|
public int DeleteWorkPlan(string id)
|
|
{
|
|
return Context.Deleteable<ProWorklplan_v2>().In(id).ExecuteCommand();
|
|
}
|
|
|
|
public List<ProWorkorder> GetWorkorderListByPlanId(string id)
|
|
{
|
|
return Context.Queryable<ProWorkorder>().Where(it => it.FkProPlanId == id).OrderBy("priority desc ").ToList();
|
|
}
|
|
|
|
public List<ProWorkorder> GetWorkorderListById(string id)
|
|
{
|
|
return Context.Queryable<ProWorkorder>().Where(it => it.Id == id).ToList();
|
|
}
|
|
|
|
public int AddWorkorder(ProWorkorder proWorkorder)
|
|
{
|
|
|
|
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();
|
|
}
|
|
|
|
|
|
}
|
|
}
|