using Model.ModelDto.SysDto; using Model.ModelVm.SysVm; using System; using System.Collections.Generic; using System.Text; using WMS.DAL; using WMS.IBLL.ISysServer; using WMS.Entity.SysEntity; using SqlSugar; using WMS.Entity.Context; using AutoMapper; using System.Threading.Tasks; namespace WMS.BLL.SysServer { public class PrintTemplateServer : DbHelper, IPrintTemplateServer { private static readonly SqlSugarScope Db = DataContext.Db; public PrintTemplateServer() : base(Db) { } /// /// 添加模板 /// /// /// /// public async Task AddPrintTemplate(SysPrintTemplate model, int userid) { if (model.Status == "1") { await Db.Updateable().SetColumns(s => s.Status == "0").Where(s => s.Type == model.Type && model.Status == "1").ExecuteCommandAsync(); } model.CreateTime = DateTime.Now; model.CreateUser = userid; await Db.Insertable(model).ExecuteCommandAsync(); } /// /// 删除模板 /// /// /// /// public async Task DelPrintTemplate(SysPrintTemplate model, int userid) { await Db.Updateable().SetColumns(s => s.IsDel == "1").Where(s => s.Id == model.Id).ExecuteCommandAsync(); } /// /// 修改模板 /// /// /// /// public async Task EditPrintTemplate(SysPrintTemplate model, int userid) { if (model.Status == "1") { await Db.Updateable().SetColumns(s => s.Status == "0").Where(s => s.Type == model.Type && model.Status == "1").ExecuteCommandAsync(); } model.UpdateTime = DateTime.Now; model.UpdateUser = userid; await Db.Updateable(model).UpdateColumns(it => new { it.Name, it.Type, it.Status, it.PositionJson, it.UpdateTime, it.UpdateUser }).ExecuteCommandAsync(); } /// /// 获取模板分页 /// /// /// /// /// public async Task> GetPrintTemplateList(PrintTemplateVm model, RefAsync count) { var list = await Db.Queryable() .LeftJoin((a, b) => a.CreateUser == b.Id) .WhereIF(!string.IsNullOrWhiteSpace(model.Name), (a, b) => a.Name.Contains(model.Name)) .Where((a, b) => a.IsDel == "0") .Select((a, b) => new PrintTemplateDto() { Id = a.Id, Name = a.Name, Type = a.Type, Status = a.Status, PositionJson = a.PositionJson, CreateTime = a.CreateTime, CreateUserName = b.RealName, UpdateTime = b.CreateTime, }) .ToPageListAsync(model.Page, model.Limit, count); return list; } /// /// 获取默认打印模板 /// public async Task GetDefaultPrintTemplate(string Type) { return await Db.Queryable().FirstAsync(s => s.Type == Type && s.Status == "1"); } } }