New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using AutoMapper; |
| | | using DTO; |
| | | using IServices; |
| | | using Microsoft.AspNetCore.Mvc.Rendering; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using zhengcaioa.Models; |
| | | |
| | | |
| | | |
| | | namespace Services |
| | | { |
| | | public class OrderBanciService: IOrderBanciService |
| | | { |
| | | private readonly zhengcaioaContext _context; |
| | | private readonly IMapper _mapper; |
| | | public OrderBanciService(zhengcaioaContext context, IMapper mapper) |
| | | { |
| | | _context = context; |
| | | _mapper = mapper; |
| | | } |
| | | public ResultEntity save(OrderBanciDTO dto) |
| | | { |
| | | ResultEntity resultEntity = new ResultEntity(); |
| | | try |
| | | { |
| | | |
| | | |
| | | var entity = _mapper.Map<OrderBanci>(dto); |
| | | |
| | | |
| | | if (String.IsNullOrEmpty(entity.Id)) |
| | | { |
| | | entity.Id = Guid.NewGuid().ToString(); |
| | | dto.Id = entity.Id; |
| | | _context.OrderBancis.Add(entity); |
| | | } |
| | | else |
| | | { |
| | | var updateproject = _context.OrderBancis.Find(entity.Id); |
| | | |
| | | updateproject.Banci = entity.Banci; |
| | | updateproject.Shijian = entity.Shijian; |
| | | |
| | | updateproject.Shijianend = entity.Shijianend; |
| | | updateproject.Didian = entity.Didian; |
| | | |
| | | updateproject.RecStatus = entity.RecStatus; |
| | | updateproject.Modifier = entity.Modifier; |
| | | updateproject.Modifytime = entity.Modifytime; |
| | | updateproject.Mingcheng = entity.Mingcheng; |
| | | updateproject.Renshu = entity.Renshu; |
| | | } |
| | | |
| | | _context.SaveChanges(); |
| | | resultEntity.ReturnID = entity.Id; |
| | | resultEntity.Result = true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | resultEntity.Result = false; |
| | | resultEntity.Message = "保存失败,请联系管理员"; |
| | | |
| | | } |
| | | return resultEntity; |
| | | } |
| | | |
| | | public OrderBanciDTO Get(string id) |
| | | { |
| | | |
| | | var entity = _context.OrderBancis.Find(id); |
| | | |
| | | if (entity.RecStatus != "A") |
| | | { |
| | | entity = new OrderBanci(); |
| | | } |
| | | |
| | | var result = _mapper.Map<OrderBanciDTO>(entity); |
| | | |
| | | |
| | | return result; |
| | | } |
| | | |
| | | public ResultDataEntity<OrderBanciDTO> SearchByPaging(OrderBanciDTOSearch searchEntity) |
| | | { |
| | | |
| | | |
| | | |
| | | ResultDataEntity<OrderBanciDTO> data = new ResultDataEntity<OrderBanciDTO>(); |
| | | List<OrderBanciDTO> list = new List<OrderBanciDTO>(); |
| | | |
| | | |
| | | |
| | | //var listCode = (from a in _context.SysCodeDtls |
| | | // join b in _context.SysCodes |
| | | // on a.CodeId equals b.Id |
| | | // where a.RecStatus == "A" |
| | | // && b.RecStatus == "A" |
| | | // select new CodeDataEntity() |
| | | // { |
| | | // CodeId = b.Id, |
| | | // CodeTable = b.CodeTable, |
| | | // CodeField = b.CodeField, |
| | | // CodeSn = a.CodeSn, |
| | | // Comments = a.Comments, |
| | | // Contents = a.Contents, |
| | | // RecStatus = a.RecStatus, |
| | | // Sort = a.Sort |
| | | // } |
| | | //); |
| | | |
| | | ///OrderBancis |
| | | /// |
| | | DateTime Shijianstart = DateTime.Now; |
| | | DateTime Shijianend = DateTime.Now; |
| | | if (!string.IsNullOrWhiteSpace(searchEntity.Shijian)) |
| | | { |
| | | string[] Shijians = searchEntity.Shijian.Split("|"); |
| | | DateTime.TryParse(Shijians[0], out Shijianstart); |
| | | DateTime.TryParse(Shijians[1], out Shijianend); |
| | | //Shijianend = Shijianend.AddDays(1); |
| | | } |
| | | |
| | | var query = (from a in _context.OrderBancis |
| | | |
| | | |
| | | |
| | | |
| | | where a.RecStatus == "A" |
| | | |
| | | && (string.IsNullOrWhiteSpace(searchEntity.Banci) || a.Banci.Contains(searchEntity.Banci.Trim())) |
| | | && (string.IsNullOrWhiteSpace(searchEntity.Shijian) || (a.Shijian >= Shijianstart && a.Shijian <= Shijianend)) |
| | | && (string.IsNullOrWhiteSpace(searchEntity.Didian) || a.Didian.Contains(searchEntity.Didian.Trim())) |
| | | |
| | | && (string.IsNullOrWhiteSpace(searchEntity.Createtime) || a.Shijian >= DateTime.Parse(searchEntity.Createtime) ) |
| | | |
| | | |
| | | |
| | | |
| | | select new OrderBanciDTO |
| | | { |
| | | Id = a.Id, |
| | | Banci = a.Banci, |
| | | Shijian = a.Shijian, |
| | | ShijianName = a.Shijian.HasValue? a.Shijian.Value.ToString("yyyy-MM-dd HH:mm"):"", |
| | | Didian = a.Didian, |
| | | Shijianend = a.Shijianend, |
| | | ShijianendName = a.Shijianend.HasValue ? a.Shijianend.Value.ToString("yyyy-MM-dd HH:mm") : "", |
| | | |
| | | Mingcheng = a.Mingcheng, |
| | | |
| | | Renshu = a.Renshu??0, |
| | | |
| | | |
| | | Creater = a.Creater, |
| | | Createtime = a.Createtime, |
| | | |
| | | RecStatus = a.RecStatus, |
| | | Modifier = a.Modifier, |
| | | Modifytime = a.Modifytime, |
| | | |
| | | } |
| | | ).OrderByDescending(x => x.Modifytime).ToList(); |
| | | |
| | | |
| | | |
| | | //if (searchEntity.totalrows == 0) |
| | | searchEntity.totalrows = query.Count(); |
| | | var lianlist = query.Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList(); |
| | | data.LoadData(searchEntity, lianlist); |
| | | return data; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 修改主表状态 |
| | | /// </summary> |
| | | /// <param name="id">主id</param> |
| | | /// <param name="userid">用户</param> |
| | | /// <returns></returns> |
| | | public ResultEntity ModifyStatus(string id, string userid) |
| | | { |
| | | ResultEntity result = new ResultEntity(); |
| | | result.Result = true; |
| | | |
| | | var model = _context.OrderBancis.Find(id); |
| | | if (model != null) |
| | | { |
| | | model.RecStatus = "D"; |
| | | model.Modifier = userid; |
| | | model.Modifytime = DateTime.Now; |
| | | _context.SaveChanges(); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取所有有效角色 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<OrderBanciDTO> GetList() |
| | | { |
| | | |
| | | |
| | | var listRole = _context.OrderBancis.Where(r => r.RecStatus == "A").ToList(); |
| | | |
| | | |
| | | var list = _mapper.Map<List<OrderBanciDTO>>(listRole); |
| | | return list; |
| | | } |
| | | } |
| | | } |