username@email.com
2021-10-14 1c4f3bce3d88557b7ddb5f0a49b4be5e91b416f1
zhengcaioa/Services/ExpertTestTopicService.cs
@@ -65,7 +65,7 @@
                    updateproject.RecStatus = entity.RecStatus;
                    updateproject.Modifier = entity.Modifier;
                    updateproject.Modifytime = entity.Modifytime;
                    updateproject.Jiexi = entity.Jiexi;
                }
@@ -103,6 +103,44 @@
                        }
                    }
                }
                //解析
                var expertTestTopicjiexis = _context.ExpertTestTopicjiexis.Where(x => x.Topic == dto.Id).ToList();
                if (expertTestTopicjiexis != null && expertTestTopicjiexis.Count > 0)
                {
                    foreach (var expertTestTopicjiexi in expertTestTopicjiexis)
                    {
                        _context.ExpertTestTopicjiexis.Remove(expertTestTopicjiexi);
                    }
                }
                var Falv = dto.Falv;
                if (Falv != null && Falv.Length > 0)
                {
                    for (int i = 0; i < Falv.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(dto.Falv[i]))
                        {
                            ExpertTestTopicjiexi expertTestTopicjiexi = new ExpertTestTopicjiexi();
                            expertTestTopicjiexi.Id = Guid.NewGuid().ToString();
                            expertTestTopicjiexi.Topic = dto.Id;
                            expertTestTopicjiexi.Falv = dto.Falv[i];
                            expertTestTopicjiexi.Fatiao = dto.Fatiao[i];
                            expertTestTopicjiexi.Flag = dto.Flag[i];
                            expertTestTopicjiexi.Creater = dto.Modifier;
                            expertTestTopicjiexi.Createtime = DateTime.Now;
                            expertTestTopicjiexi.Modifier = dto.Modifier;
                            expertTestTopicjiexi.Modifytime = DateTime.Now;
                            _context.ExpertTestTopicjiexis.Add(expertTestTopicjiexi);
                        }
                    }
                }
                _context.SaveChanges();
@@ -233,6 +271,7 @@
                             && (string.IsNullOrWhiteSpace(searchEntity.JiexiStatus) || a.JiexiStatus == searchEntity.JiexiStatus.Trim())
                            && (string.IsNullOrWhiteSpace(searchEntity.ShenpiStatus) || a.ShenpiStatus == searchEntity.ShenpiStatus.Trim())
                             && (string.IsNullOrWhiteSpace(searchEntity.Topic) || a.Topic.Contains(searchEntity.Topic.Trim()))
                              && (string.IsNullOrWhiteSpace(searchEntity.Area) || a.Area == searchEntity.Area.Trim())
                            
@@ -251,6 +290,7 @@
                             ZhongdianName = ggg.Comments,
                             JiexiStatus = a.JiexiStatus,
                             JiexiStatusName  = hhh.Comments,
                             Jiexi = a.Jiexi,
                             ShenpiStatus = a.ShenpiStatus,
                             ShenpiStatusName = iii.Comments,
                             Area = a.Area,
@@ -666,5 +706,226 @@
            return result;
        }
        /// <summary>
        /// 获取所有有效角色
        /// </summary>
        /// <returns></returns>
        public List<ExpertTestResultDTO> GetListResult()
        {
            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
                            }
                             );
            var listRole = (from a in _context.ExpertTestResults
                            join e in listCode.Where(x => x.CodeTable == "expert_test_result" && x.CodeField == "resulttype")
                     on a.Resulttype equals e.CodeSn
                     into esssss
                            from eee in esssss.DefaultIfEmpty()
                            where a.RecStatus == "A"
                              //&& (string.IsNullOrWhiteSpace(topicId) || a.Topic == topicId.Trim())
                            select new ExpertTestResultDTO
                            {
                                Id = a.Id,
                                Resulttype = a.Resulttype,
                                ResulttypeName = eee.Comments,
                                Result = a.Result,
                                Creater = a.Creater,
                                Createtime = a.Createtime,
                                RecStatus = a.RecStatus,
                                Modifier = a.Modifier,
                                Modifytime = a.Modifytime,
                            }
                ).OrderBy(x => x).ToList();
            return listRole;
        }
        /// <summary>
        /// 获取所有有效角色
        /// </summary>
        /// <returns></returns>
        public List<ExpertTestTopicpeizhiDTO> GetListpeizhi()
        {
            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
                            }
                             );
            var listRole = (from a in _context.ExpertTestTopicpeizhis
                            join e in listCode.Where(x => x.CodeTable == "expert_test_topic" && x.CodeField == "topictype")
                     on a.Topictype equals e.CodeSn
                     into esssss
                            from eee in esssss.DefaultIfEmpty()
                            join f in listCode.Where(x => x.CodeTable == "expert_test_topic" && x.CodeField == "zhishitype")
                       on a.Zhishitype equals f.CodeSn
                       into fsssss
                            from fff in fsssss.DefaultIfEmpty()
                            where a.RecStatus == "A"
                              //&& (string.IsNullOrWhiteSpace(topicId) || a.Topic == topicId.Trim())
                            select new ExpertTestTopicpeizhiDTO
                            {
                                Id = a.Id,
                                ShijianId = a.ShijianId,
                                Topictype = a.Topictype,
                                TopictypeName = eee.Comments,
                                Zhishitype = a.Zhishitype,
                                ZhishitypeName = fff.Comments,
                                Fenshu = a.Fenshu,
                                Fenzhi = a.Fenzhi,
                                Creater = a.Creater,
                                Createtime = a.Createtime,
                                RecStatus = a.RecStatus,
                                Modifier = a.Modifier,
                                Modifytime = a.Modifytime,
                            }
                ).OrderBy(x => x.Topictype).ThenBy(x => x.Zhishitype).ToList();
            return listRole;
        }
        public ResultEntity saveResult(ExpertTestResultDTO dto)
        {
            ResultEntity resultEntity = new ResultEntity();
            try
            {
                var entity = _mapper.Map<ExpertTestResult>(dto);
                if (String.IsNullOrEmpty(entity.Id))
                {
                    entity.Id = Guid.NewGuid().ToString();
                    dto.Id = entity.Id;
                    _context.ExpertTestResults.Add(entity);
                }
                else
                {
                    var updateproject = _context.ExpertTestResults.Find(entity.Id);
                    updateproject.Resulttype = entity.Resulttype;
                    updateproject.Result = entity.Result;
                    updateproject.RecStatus = entity.RecStatus;
                    updateproject.Modifier = entity.Modifier;
                    updateproject.Modifytime = entity.Modifytime;
                }
                _context.SaveChanges();
                resultEntity.ReturnID = entity.Id;
                resultEntity.Result = true;
            }
            catch (Exception ex)
            {
                resultEntity.Result = false;
                resultEntity.Message = "保存失败,请联系管理员";
            }
            return resultEntity;
        }
        public ResultEntity savepeizhi(ExpertTestTopicpeizhiDTO dto)
        {
            ResultEntity resultEntity = new ResultEntity();
            try
            {
                var entity = _mapper.Map<ExpertTestTopicpeizhi>(dto);
                if (String.IsNullOrEmpty(entity.Id))
                {
                    entity.Id = Guid.NewGuid().ToString();
                    dto.Id = entity.Id;
                    _context.ExpertTestTopicpeizhis.Add(entity);
                }
                else
                {
                    var updateproject = _context.ExpertTestTopicpeizhis.Find(entity.Id);
                    updateproject.ShijianId = entity.ShijianId;
                    updateproject.Topictype = entity.Topictype;
                    updateproject.Zhishitype = entity.Zhishitype;
                    updateproject.Fenshu = entity.Fenshu;
                    updateproject.Fenzhi = entity.Fenzhi;
                    updateproject.RecStatus = entity.RecStatus;
                    updateproject.Modifier = entity.Modifier;
                    updateproject.Modifytime = entity.Modifytime;
                }
                _context.SaveChanges();
                resultEntity.ReturnID = entity.Id;
                resultEntity.Result = true;
            }
            catch (Exception ex)
            {
                resultEntity.Result = false;
                resultEntity.Message = "保存失败,请联系管理员";
            }
            return resultEntity;
        }
    }
}