From d4a6d65f5e449c3e5464aa18ae97bf8953987217 Mon Sep 17 00:00:00 2001 From: LR-20210131IOQH\Administrator <jackcold@163.com> Date: 星期二, 10 八月 2021 15:44:14 +0800 Subject: [PATCH] Merge branch 'master' of http://47.108.235.38:8080/r/zhengcaioa --- zhengcaioa/Services/LiaotianService.cs | 292 +++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 216 insertions(+), 76 deletions(-) diff --git a/zhengcaioa/Services/LiaotianService.cs b/zhengcaioa/Services/LiaotianService.cs index 5630f89..6ddb2bb 100644 --- a/zhengcaioa/Services/LiaotianService.cs +++ b/zhengcaioa/Services/LiaotianService.cs @@ -9,7 +9,7 @@ namespace Services { - public class LiaotianService: ILiaotianService + public class LiaotianService : ILiaotianService { private readonly zhengcaioaContext _context; private readonly IMapper _mapper; @@ -19,7 +19,7 @@ _mapper = mapper; } - public ResultEntity saveLiaotian(LiaotianDTO liaotiandto) + public ResultEntity saveLiaotian(LiaotianDTO liaotiandto) { ResultEntity resultEntity = new ResultEntity(); try @@ -42,18 +42,21 @@ } else { - var updateliaotian = _context.Liaotians.Find(liaotian.Id); + var updateliaotian = _context.Liaotians.Find(liaotian.Id); updateliaotian.Question = liaotian.Question; updateliaotian.Anwser = liaotian.Anwser; updateliaotian.RecStatus = liaotian.RecStatus; updateliaotian.Clientid = liaotian.Clientid; - // updateliaotian.Creater = liaotian.Creater; + // updateliaotian.Creater = liaotian.Creater; //updateliaotian.Createtime = liaotian.Createtime; updateliaotian.Modifier = liaotian.Modifier; updateliaotian.Modifytime = liaotian.Modifytime; updateliaotian.Questiontype = liaotian.Questiontype; updateliaotian.Problemtype = liaotian.Problemtype; updateliaotian.Shiyongfatiao = liaotian.Shiyongfatiao; + updateliaotian.ChushuStatus = liaotian.ChushuStatus; + updateliaotian.Shenheer = liaotian.Shenheer; + updateliaotian.Shenhetime = liaotian.Shenhetime; } _context.SaveChanges(); @@ -64,7 +67,7 @@ { resultEntity.Result = false; resultEntity.Message = "淇濆瓨澶辫触锛岃鑱旂郴绠$悊鍛�"; - + } return resultEntity; } @@ -83,21 +86,21 @@ return liaotiandto; } - public List<SysCodeDtl> GetSYScode(string code_table,string code_field) + public List<SysCodeDtl> GetSYScode(string code_table, string code_field) { List<SysCodeDtl> sysCodeDtls = (from e in _context.SysCodes join c in _context.SysCodeDtls - on e.Id equals c.CodeId - where e.RecStatus == "A" + on e.Id equals c.CodeId + where e.RecStatus == "A" && c.RecStatus == "A" - && e.CodeTable == code_table + && e.CodeTable == code_table && e.CodeField == code_field - select c).OrderBy(x=>x.Sort).ToList(); - - - + select c).OrderBy(x => x.Sort).ToList(); + + + @@ -108,29 +111,8 @@ public ResultDataEntity<LiaotianDTO> SearchByPaging(LiaotianDTOSearch searchEntity) { ResultDataEntity<LiaotianDTO> data = new ResultDataEntity<LiaotianDTO>(); - List<LiaotianDTO> list = new List<LiaotianDTO>(); - //绛涢�� - var query = _context.Liaotians - .Where(b => b.RecStatus=="A") - .ToList(); + //List<LiaotianDTO> list = new List<LiaotianDTO>(); - if (!string.IsNullOrEmpty(searchEntity.Question)) - { - query = query.Where(m => m.Question.Contains(searchEntity.Question)).ToList(); - } - if (!string.IsNullOrEmpty(searchEntity.Questiontype)) - { - query = query.Where(m => m.Questiontype == searchEntity.Questiontype).ToList(); - } - if (!string.IsNullOrEmpty(searchEntity.Problemtype)) - { - query = query.Where(m => m.Problemtype.Contains(searchEntity.Problemtype)).ToList(); - } - if (!string.IsNullOrEmpty(searchEntity.Shifoushenhe)) - { - query = query.Where(m => m.Clientid == searchEntity.Shifoushenhe ).ToList(); - } - DateTime Createtimestart = DateTime.Now; DateTime Createtimeend = DateTime.Now; if (!string.IsNullOrWhiteSpace(searchEntity.Createtime)) @@ -140,50 +122,72 @@ DateTime.TryParse(Createtimes[1], out Createtimeend); Createtimeend = Createtimeend.AddDays(1); } - if (!string.IsNullOrEmpty(searchEntity.Createtime)) - { - query = query.Where(m => m.Createtime >= Createtimestart).ToList(); - } - if (!string.IsNullOrEmpty(searchEntity.Createtime)) - { - query = query.Where(m => m.Createtime <= Createtimeend).ToList(); - } - if (!string.IsNullOrEmpty(searchEntity.Creater)) - { - query = query.Where(m => m.Creater == searchEntity.Creater).ToList(); - } - - if (!string.IsNullOrEmpty(searchEntity.Info)) - { - var check = searchEntity.Info.Split(' '); - List<Liaotian> liaotians = new List<Liaotian>(); - if(check!=null&& check.Length > 0) - { - for(int i = 0;i< check.Length; i++) - { - if (!string.IsNullOrWhiteSpace(check[i])){ - liaotians = liaotians.Union(query.Where(m => m.Question.Contains(check[i])).ToList()).Distinct().ToList(); - } - - } - - } - - query = liaotians; - } - else - { - query = query.OrderByDescending(x => x.Modifytime).ToList(); - } + + //var query1 = _context.Liaotians.Where(a => a.RecStatus == "A"); + + + + + + //绛涢�� + var query = (from a in _context.Liaotians + + + // join h in _context.LiaotianShoucangs.Where(x => x.RecStatus == "A" && x.Creater == searchEntity.ShouCangCreater) + // on a.Id equals h.LiaotianId + //into hsss + // from hhh in hsss.DefaultIfEmpty() + + + where a.RecStatus == "A" + && (string.IsNullOrWhiteSpace(searchEntity.Createtime) || (a.Createtime >= Createtimestart && a.Createtime <= Createtimeend)) + + && (string.IsNullOrWhiteSpace(searchEntity.Question) || (a.Question.Contains(searchEntity.Question.Trim()))) + && (string.IsNullOrWhiteSpace(searchEntity.Questiontype) || (a.Questiontype == searchEntity.Questiontype.Trim())) + && (string.IsNullOrWhiteSpace(searchEntity.Problemtype) || (a.Problemtype.Contains(searchEntity.Problemtype.Trim()))) + && (string.IsNullOrWhiteSpace(searchEntity.Shifoushenhe) || (a.Clientid == searchEntity.Shifoushenhe.Trim())) + && (string.IsNullOrWhiteSpace(searchEntity.ChushuStatus) || (a.ChushuStatus == searchEntity.ChushuStatus.Trim())) + && (string.IsNullOrWhiteSpace(searchEntity.Creater) || (a.Creater == searchEntity.Creater.Trim())) + //&& (string.IsNullOrWhiteSpace(searchEntity.ShouCangStatus) || (searchEntity.ShouCangStatus == "A" && hhh.Id !=null) || (searchEntity.ShouCangStatus != "A" && hhh.Id == null)) + select new LiaotianDTO + { + Id = a.Id, + Question = a.Question, + Anwser = a.Anwser, + RecStatus = a.RecStatus, + Creater = a.Creater, + Createtime = a.Createtime, + Modifier = a.Modifier, + Modifytime = a.Modifytime, + Clientid = a.Clientid, + Questiontype = a.Questiontype, + Problemtype = a.Problemtype, + Shiyongfatiao = a.Shiyongfatiao, + ChushuStatus= a.ChushuStatus, + Shenheer = a.Shenheer, + Shenhetime = a.Shenhetime, + } + ) + .Distinct() .OrderByDescending(x => x.Modifytime).ToList(); - if (searchEntity.totalrows == 0) + + + + + + + + + + + //if (searchEntity.totalrows == 0) searchEntity.totalrows = query.Count(); var lianlist = query.Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList(); - list = _mapper.Map<List<LiaotianDTO>>(lianlist); - data.LoadData(searchEntity, list); + //list = _mapper.Map<List<LiaotianDTO>>(lianlist); + data.LoadData(searchEntity, lianlist); return data; } @@ -219,7 +223,7 @@ /// <returns></returns> public List<LiaotianDTO> SearchForPrint(LiaotianDTOSearch searchEntity) { - + List<LiaotianDTO> list = new List<LiaotianDTO>(); //绛涢�� var query = _context.Liaotians @@ -262,9 +266,145 @@ query = query.OrderByDescending(x => x.Modifytime).ToList(); - + list = _mapper.Map<List<LiaotianDTO>>(query); - + + return list; + } + + + + public ResultEntity saveLiaotianShoucang(LiaotianShoucangDTO dto) + { + ResultEntity resultEntity = new ResultEntity(); + try + { + + + var liaotian = _mapper.Map<LiaotianShoucang>(dto); + if (String.IsNullOrEmpty(liaotian.Id)) + { + liaotian.Id = Guid.NewGuid().ToString(); + dto.Id = liaotian.Id; + _context.LiaotianShoucangs.Add(liaotian); + } + else + { + var updateliaotian = _context.LiaotianShoucangs.Find(liaotian.Id); + updateliaotian.LiaotianId = liaotian.LiaotianId; + + updateliaotian.RecStatus = liaotian.RecStatus; + + // updateliaotian.Creater = liaotian.Creater; + //updateliaotian.Createtime = liaotian.Createtime; + updateliaotian.Modifier = liaotian.Modifier; + updateliaotian.Modifytime = liaotian.Modifytime; + + } + + _context.SaveChanges(); + resultEntity.ReturnID = liaotian.Id; + resultEntity.Result = true; + } + catch (Exception ex) + { + resultEntity.Result = false; + resultEntity.Message = "淇濆瓨澶辫触锛岃鑱旂郴绠$悊鍛�"; + + } + return resultEntity; + } + + public ResultEntity ModifyStatusLiaotianShoucang(string id, string userid) + { + ResultEntity result = new ResultEntity(); + result.Result = true; + + var model = _context.LiaotianShoucangs.Find(id); + if (model != null) + { + model.RecStatus = "D"; + model.Modifier = userid; + model.Modifytime = DateTime.Now; + _context.SaveChanges(); + } + + return result; + } + + public List<LiaotianShoucangDTO> getListLiaotianShoucang(string userId, string LiaotianId) + { + List<LiaotianShoucangDTO> result = new List<LiaotianShoucangDTO>(); + + + var listFiServices = _context.LiaotianShoucangs.Where(r => r.RecStatus == "A" && (string.IsNullOrEmpty(userId) || r.Creater == userId) && (string.IsNullOrEmpty(LiaotianId) || r.LiaotianId == LiaotianId)).OrderBy(x => x.Createtime).ToList(); + + result = _mapper.Map<List<LiaotianShoucangDTO>>(listFiServices); + + return result; + } + + + + public ResultEntity saveSysUpdatetime(SysUpdatetime sysUpdatetime) + { + ResultEntity resultEntity = new ResultEntity(); + try + { + + + if (String.IsNullOrEmpty(sysUpdatetime.Id)) + { + sysUpdatetime.Id = Guid.NewGuid().ToString(); + _context.SysUpdatetimes.Add(sysUpdatetime); + } + else + { + var updateliaotian = _context.SysUpdatetimes.Find(sysUpdatetime.Id); + updateliaotian.Updatename = sysUpdatetime.Updatename; + updateliaotian.Updatetime = sysUpdatetime.Updatetime; + + } + + _context.SaveChanges(); + resultEntity.ReturnID = sysUpdatetime.Id; + resultEntity.Result = true; + } + catch (Exception ex) + { + resultEntity.Result = false; + resultEntity.Message = "淇濆瓨澶辫触锛岃鑱旂郴绠$悊鍛�"; + + } + return resultEntity; + } + + public SysUpdatetime GetSysUpdatetime(string updatename) + { + + var entity = _context.SysUpdatetimes.Where(x=>x.Updatename == updatename).FirstOrDefault(); + + return entity; + } + + + public List<LiaotianDTO> GetListsalary(string userid, DateTime datemin, DateTime datemax) + { + + + var listPosition = _context.Liaotians.Where(r => r.RecStatus == "A" && r.Creater == userid && r.Createtime >= datemin && r.Createtime < datemax).ToList(); + + var list = _mapper.Map<List<LiaotianDTO>>(listPosition); + return list; + } + + public List<LiaotianDTO> GetListsalaryshenhe(string userid, DateTime datemin, DateTime datemax) + { + + + var listPosition = _context.Liaotians.Where(r => r.RecStatus == "A" && r.Shenheer == userid && r.Shenhetime >= datemin && r.Shenhetime < datemax).ToList(); + + var list = _mapper.Map<List<LiaotianDTO>>(listPosition); return list; } } -- Gitblit v1.9.1