Files
shgx_tz_mes_backend_sync/ZR.Service/mes/ql/PLBatchService.cs

137 lines
5.3 KiB
C#

using Infrastructure.Attribute;
using SqlSugar;
using System;
using ZR.Model.MES.ql;
using ZR.Service.mes.ql.IService;
namespace ZR.Service.mes.ql
{
/// <summary>
/// 查询报表
/// </summary>
[AppService(ServiceType = typeof(IPLBatchService), ServiceLifetime = LifeTime.Transient)]
public class PLBatchService : BaseService<PLBatch>, IPLBatchService
{
/// <summary>
/// 增加批处理数据
/// </summary>
/// <param name="num"></param>
/// <param name="size"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public int AddPLBatchRecords(int num, int size)
{
PLBatch t1 = GetDefaultPLBatch();
PLBatch t2 = GetDefaultPLBatch();
PLBatch t3 = GetDefaultPLBatch();
PLBatch t4 = GetDefaultPLBatch();
PLBatch t5 = GetDefaultPLBatch();
PLBatch t6 = GetDefaultPLBatch();
t1.Value01 = "15°"; t1.Value07 = "0"; t1.Value09 = "R1"; t1.Value14 = "底漆"; t1.Value19 = "2";
t2.Value01 = "25°"; t2.Value07 = "0"; t2.Value09 = "R2"; t2.Value14 = "色漆"; t2.Value19 = "2";
t3.Value01 = "45°"; t3.Value07 = "0"; t3.Value09 = "R3"; t3.Value14 = "云母"; t3.Value19 = "2";
t4.Value01 = "75°"; t4.Value07 = "0"; t4.Value09 = "R4"; t4.Value14 = "清漆"; t4.Value19 = "2";
t5.Value01 = "110°"; t5.Value07 = "0"; t5.Value09 = "R5"; t5.Value14 = "总膜厚"; t5.Value19 = "2";
t6.Value01 = ""; t6.Value07 = "0"; t6.Value09 = "R6"; t6.Value14 = ""; t6.Value19 = "2";
t2.IdGroup = t1.IdGroup;
t3.IdGroup = t1.IdGroup;
t4.IdGroup = t1.IdGroup;
t5.IdGroup = t1.IdGroup;
t6.IdGroup = t1.IdGroup;
List<PLBatch> lst = new List<PLBatch>();
lst.Add(t1); lst.Add(t2); lst.Add(t3); lst.Add(t4); lst.Add(t5); lst.Add(t6);
int ret = Context.Insertable<PLBatch>(lst).ExecuteReturnIdentity();
return ret;
}
/// <summary>
/// 删除批处理数据
/// </summary>
/// <param name="idGroup"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public int DelPLBatchRecords(string idGroup)
{
return Context.Deleteable<PLBatch>().Where(it => it.IdGroup.Equals(idGroup)).ExecuteCommand();
}
/// <summary>
/// 获取批处理数据
/// </summary>
/// <param name="starttime"></param>
/// <param name="endTime"></param>
/// <param name="pageNum"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public (List<PLBatch>, int) GetPLBatchTable(DateTime starttime, DateTime endTime, string code,string description, int pageNum, int pageSize)
{
starttime = starttime.ToLocalTime();
endTime = endTime.ToLocalTime();
int totalNum = 0;
var predicate = Expressionable.Create<PLBatch>()
.AndIF(starttime > new DateTime(2023, 1, 1, 0, 0, 0), it => it.CreatedTime >= starttime.ToLocalTime())
.AndIF(endTime > new DateTime(2023, 1, 1, 0, 0, 0), it => it.CreatedTime <= endTime.ToLocalTime())
.AndIF(!string.IsNullOrEmpty(code), it => it.Code.Contains(code))
.AndIF(!string.IsNullOrEmpty(description), it => it.Description.Contains(description))
.ToExpression();
//int totalNum = 0;
List<PLBatch> data = Context.Queryable<PLBatch>()
.Where(predicate)
.OrderByDescending(it => it.IdGroup)
.OrderBy(it => it.Id)
.ToPageList(pageNum, pageSize, ref totalNum);
return (data, totalNum);
}
/// <summary>
/// 更新批处理数据
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public int UpdatePLBatchRecords(List<PLBatch> list)
{
return Context.Updateable<PLBatch>(list).ExecuteCommand();
}
private PLBatch GetDefaultPLBatch()
{
return new PLBatch()
{
Id = 0,
IdGroup = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
Description = "",
Dt = "",
Code = "",
Value01 = "",
Value02 = "",
Value03 = "",
Value04 = "",
Value05 = "",
Value06 = "",
Value07 = "",
Value08 = "",
Value09 = "",
Value10 = "",
Value11 = "",
Value12 = "",
Value13 = "",
Value14 = "",
Value15 = "",
Value16 = "",
Value17 = "",
Value18 = "",
Value19 = "",
CreatedBy = "user",
CreatedTime = DateTime.Now,
UpdatedBy = "user",
UpdatedTime = DateTime.Now,
};
}
}
}