From 1c4f3bce3d88557b7ddb5f0a49b4be5e91b416f1 Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期四, 14 十月 2021 13:42:33 +0800
Subject: [PATCH] 专家测试--题库管理
---
zhengcaioa/Services/ProjectService.cs | 247 ++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 234 insertions(+), 13 deletions(-)
diff --git a/zhengcaioa/Services/ProjectService.cs b/zhengcaioa/Services/ProjectService.cs
index 9efb610..0c22304 100644
--- a/zhengcaioa/Services/ProjectService.cs
+++ b/zhengcaioa/Services/ProjectService.cs
@@ -27,6 +27,16 @@
ResultEntity resultEntity = new ResultEntity();
try
{
+ var checkUserSn = _context.Projects.Where(x => x.Name == projectDTO.Name && x.RecStatus == "A" && x.Id != projectDTO.Id).FirstOrDefault();
+ if (checkUserSn != null && (string.IsNullOrWhiteSpace(projectDTO.Id) || (!string.IsNullOrWhiteSpace(projectDTO.Id) && checkUserSn.Id != projectDTO.Id)))
+ {
+ resultEntity.Result = false;
+ resultEntity.Message = "椤圭洰閲嶅";
+ return resultEntity;
+ }
+
+
+
var project = _mapper.Map<Project>(projectDTO);
// var ZhuanjiaList = projectDTO.ZhuanjiaList;
//if(ZhuanjiaList!=null&& ZhuanjiaList.Length > 0)
@@ -54,6 +64,9 @@
updateproject.Name = project.Name;
updateproject.Drhx = project.Drhx;
updateproject.DrhxPrice = project.DrhxPrice;
+ updateproject.DrhxDefen = project.DrhxDefen;
+ updateproject.DshxDefen = project.DshxDefen;
+ updateproject.Dshx = project.Dshx;
updateproject.Dshx = project.Dshx;
updateproject.DshxPrice = project.DshxPrice;
updateproject.Zhuanjia = project.Zhuanjia;
@@ -79,6 +92,10 @@
updateproject.Dailiname = project.Dailiname;
updateproject.Dailicontact = project.Dailicontact;
updateproject.Dailiaddress = project.Dailiaddress;
+ updateproject.Fencha = project.Fencha;
+ updateproject.Shuliang = project.Shuliang;
+ updateproject.Caigouyusuan = project.Caigouyusuan;
+
}
//瀛愯〃
@@ -178,6 +195,7 @@
}
projectzhongbiao.Names = projectDTO.Names[i];
projectzhongbiao.Price = projectDTO.Price[i];
+ projectzhongbiao.Defen = projectDTO.Defen[i];
projectzhongbiao.ProjectId = project.Id;
_context.Projectzhongbiaos.Add(projectzhongbiao);
}
@@ -217,7 +235,10 @@
var projectDTO = _mapper.Map<ProjectDTO>(entity);
- if(projectreasons!=null && projectreasons.Count>0)
+ projectDTO.DrhxDefenName = projectDTO.DrhxDefen.HasValue ? projectDTO.DrhxDefen.Value.ToString("F2") : "";
+ projectDTO.DshxDefenName = projectDTO.DshxDefen.HasValue ? projectDTO.DshxDefen.Value.ToString("F2") : "";
+ projectDTO.CaigouyusuanName = projectDTO.Caigouyusuan.HasValue ? projectDTO.Caigouyusuan.Value.ToString() : "";
+ if (projectreasons!=null && projectreasons.Count>0)
{
projectDTO.projectreasons = projectreasons;
}
@@ -241,12 +262,26 @@
if (Projectzhongbiaos != null && Projectzhongbiaos.Count > 0)
{
- projectDTO.Projectzhongbiaos = Projectzhongbiaos;
+ List<ProjectzhongbiaoDTO> projectzhongbiaoDTOs = new List<ProjectzhongbiaoDTO>();
+ foreach(var projectzhongbiao in Projectzhongbiaos)
+ {
+ ProjectzhongbiaoDTO projectzhongbiaoDTO = new ProjectzhongbiaoDTO();
+ projectzhongbiaoDTO.DefenName = projectzhongbiao.Defen.HasValue ? projectzhongbiao.Defen.Value.ToString("F2") : "";
+
+ projectzhongbiaoDTO.ZhongbiaoId = projectzhongbiao.ZhongbiaoId;
+ projectzhongbiaoDTO.ProjectId = projectzhongbiao.ProjectId;
+ projectzhongbiaoDTO.Names = projectzhongbiao.Names;
+ projectzhongbiaoDTO.Price = projectzhongbiao.Price;
+ projectzhongbiaoDTO.Defen = projectzhongbiao.Defen;
+
+ projectzhongbiaoDTOs.Add(projectzhongbiaoDTO);
+ }
+ projectDTO.Projectzhongbiaos = projectzhongbiaoDTOs;
}
else
{
- var Projectzhongbiaoslist = new List<Projectzhongbiao>();
- Projectzhongbiaoslist.Add(new Projectzhongbiao());
+ var Projectzhongbiaoslist = new List<ProjectzhongbiaoDTO>();
+ Projectzhongbiaoslist.Add(new ProjectzhongbiaoDTO());
projectDTO.Projectzhongbiaos = Projectzhongbiaoslist;
}
@@ -262,7 +297,7 @@
List<ProjectDTO> list = new List<ProjectDTO>();
//绛涢��
StringBuilder sql = new StringBuilder();
- sql.Append("SELECT distinct a.[Id],a.[start_time] ,b.[name] +'-'+c.[name]+'-'+d.[name] Sheng ,a.city ,a.[area_id],a.cgfs, a.[name] ,a.[number],a.creater,a.createtime,a.modifier,a.modifytime ,a.[drhx],a.[drhx_price],a.[dshx],a.[dshx_price],a.[remark],a.[rec_status],a.[toubiaocishu] ,a.[question] ,a.[zhongbiaocishu],a.[feibiaocishu],a.[zhongbiaojine],a.[Fblx],a.[Fbyy] , a.[zhuanjia] , a.[caigourenname], a.[caigourenaddress], a.[caigourencontact], a.[dailiname], a.[dailiaddress], a.[dailicontact] "); //zhuanjia = stuff((select ','+name from [Zhuanjia] f where CHARINDEX(f.id,a.[zhuanjia]) >0 for xml path('')), 1,1, '')
+ sql.Append("SELECT distinct a.[Id],a.[start_time],a.[drhx_defen],a.[caigouyusuan],a.[dshx_defen] ,b.[name] +'-'+c.[name]+'-'+d.[name] Sheng ,a.city ,a.[area_id],a.cgfs, a.[name] ,a.[number],a.creater,a.createtime,a.modifier,a.modifytime ,a.[drhx],a.[drhx_price],a.[dshx],a.[dshx_price],a.[Fencha],a.[Shuliang],a.[remark],a.[rec_status] ,a.[question] ,a.[zhongbiaocishu],a.[feibiaocishu],a.[zhongbiaojine],a.[Fblx],a.[Fbyy] , a.[zhuanjia] , a.[caigourenname], a.[caigourenaddress], a.[caigourencontact], a.[dailiname], a.[dailiaddress], a.[dailicontact] ,toubiaocishu = stuff((select '銆�'+ f.[names] from [Projectzhongbiao] f where f.[ProjectId] = a.[Id] for xml path('')), 1,1, '') "); //zhuanjia = stuff((select ','+name from [Zhuanjia] f where CHARINDEX(f.id,a.[zhuanjia]) >0 for xml path('')), 1,1, '')
sql.Append("FROM [Project] a ");
sql.Append("left join [Area] b on a.[sheng] = b.[codeID] ");
sql.Append("left join [Area] c on a.[city] = c.[codeID] ");
@@ -276,16 +311,177 @@
}
- if (!string.IsNullOrWhiteSpace(searchEntity.StartTimestar))
+ if (!string.IsNullOrWhiteSpace(searchEntity.NamesToubiao))
{
- sql.Append(" and a.start_time >='"+ searchEntity.StartTimestar.Trim().Replace("'","''") + "'");
-
- }
- if (!string.IsNullOrWhiteSpace(searchEntity.StartTimeend))
- {
- sql.Append(" and a.start_time <='" + DateTime.Parse(searchEntity.StartTimeend.Trim().Replace("'", "''")).AddDays(1).ToString("yyyy-MM-dd") + "'"); ;
+ sql.Append(" and ( exists (select b.[ProjectId] from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] and b.[names] like '%" + searchEntity.NamesToubiao + "%') ");
+
+ sql.Append(" or exists (select c.[ProjectId] from [Projectreason] c where a.[Id]=c.[ProjectId] and c.[reasonname] like '%" + searchEntity.NamesToubiao + "%') ");
+
+ sql.Append(" or exists (select d.[ProjectId] from [Projectyouxiao] d where a.[Id]=d.[ProjectId] and d.[namesyouxiao] like '%" + searchEntity.NamesToubiao + "%') ");
+
+ sql.Append(" or a.[drhx] like '%" + searchEntity.NamesToubiao + "%' ");
+
+ sql.Append(" or a.[dshx] like '%" + searchEntity.NamesToubiao + "%' ");
+
+ sql.Append(" )");
}
+ if (!string.IsNullOrWhiteSpace(searchEntity.Fencha))
+ {
+ decimal aaaa = 0;
+ decimal.TryParse(searchEntity.Fencha, out aaaa);
+ if (aaaa > 0)
+ {
+ sql.Append(" and exists ( select b.[ProjectId] from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] and (b.[defen]-a.[drhx_defen]) <= " + aaaa + " ) ");
+ }
+ }
+ if (!string.IsNullOrWhiteSpace(searchEntity.Baojiachaxiaoyu))
+ {
+ decimal aaaa = 0;
+ decimal.TryParse(searchEntity.Baojiachaxiaoyu, out aaaa);
+ if (aaaa > 0)
+ {
+ sql.Append(" and exists ( select b.[ProjectId] from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] and (convert(numeric(10,2),b.[price] )-convert(numeric(10,2),a.[drhx_price] )) <= " + aaaa + " ) ");
+ }
+ }
+
+
+ if (!string.IsNullOrWhiteSpace(searchEntity.Fenchadayu))
+ {
+ decimal aaaa = 0;
+ decimal.TryParse(searchEntity.Fenchadayu, out aaaa);
+ if (aaaa > 0)
+ {
+ sql.Append(" and exists ( select b.[ProjectId] from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] and (b.[defen]-a.[drhx_defen]) >= " + aaaa + " ) ");
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(searchEntity.Shuliang))
+ {
+ decimal aaaa = 0;
+ decimal.TryParse(searchEntity.Shuliang, out aaaa);
+ if (aaaa > 0)
+ {
+ sql.Append(" and exists ( select * from( select ( isnull((select COUNT(*) ProjectIdshuliang from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] group by b.ProjectId) ,0)+ ");
+
+ sql.Append(" isnull( (select COUNT(*) ProjectIdshuliang from [Projectreason] b where a.[Id]=b.[ProjectId] group by b.ProjectId),0)+ ");
+ sql.Append(" isnull( (select COUNT(*) ProjectIdshuliang from [Projectyouxiao] b where a.[Id]=b.[ProjectId] group by b.ProjectId),0)+ ");
+ sql.Append(" isnull( ( select COUNT(*) ProjectIdshuliang from [Project] b where a.[Id]=b.[Id] and b.drhx is not null ),0)+ ");
+ sql.Append(" isnull( (select COUNT(*) ProjectIdshuliang from [Project] b where a.[Id]=b.[Id] and b.dshx is not null ),0) ");
+ sql.Append(" ) as sum_count ) a where a.sum_count <= " + aaaa + "");
+ sql.Append(" ) ");
+ }
+ }
+ if (!string.IsNullOrWhiteSpace(searchEntity.Chuanbiaofenxi))
+ {
+ if (searchEntity.Chuanbiaofenxi == "01")
+ {
+ sql.Append(" and exists ( select b.[ProjectId] from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] and (b.[defen]-a.[drhx_defen]) >= 10 ) ");
+ sql.Append(" and exists ( select * from( select ( isnull((select COUNT(*) ProjectIdshuliang from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] group by b.ProjectId) ,0)+ ");
+
+ sql.Append(" isnull( (select COUNT(*) ProjectIdshuliang from [Projectreason] b where a.[Id]=b.[ProjectId] group by b.ProjectId),0)+ ");
+ sql.Append(" isnull( (select COUNT(*) ProjectIdshuliang from [Projectyouxiao] b where a.[Id]=b.[ProjectId] group by b.ProjectId),0)+ ");
+ sql.Append(" isnull( ( select COUNT(*) ProjectIdshuliang from [Project] b where a.[Id]=b.[Id] and b.drhx is not null ),0)+ ");
+ sql.Append(" isnull( (select COUNT(*) ProjectIdshuliang from [Project] b where a.[Id]=b.[Id] and b.dshx is not null ),0) ");
+ sql.Append(" ) as sum_count ) a where a.sum_count <= 5 ");
+ sql.Append(" ) ");
+ }
+ else if (searchEntity.Chuanbiaofenxi == "02")
+ {
+ sql.Append(" and exists ( select b.[ProjectId] from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] and (b.[defen]-a.[drhx_defen]) >= 20 ) ");
+
+
+ }
+ else if (searchEntity.Chuanbiaofenxi == "03")
+ {
+ sql.Append(" and exists ( select b.[ProjectId] from [Projectzhongbiao] b where a.[Id]=b.[ProjectId] and (b.[defen]-a.[drhx_defen]) >= 10 ) ");
+ }
+
+ }
+
+
+ if (!string.IsNullOrWhiteSpace(searchEntity.Reasonname))
+ {
+ sql.Append(" and exists (select b.[ProjectId] from [Projectreason] b where a.[Id]=b.[ProjectId] and b.[reasonname] like '%" + searchEntity.Reasonname + "%') ");
+
+ }
+
+ if (!string.IsNullOrWhiteSpace(searchEntity.ShiFouyReasonname))
+ {
+ if (searchEntity.ShiFouyReasonname == "A")
+ {
+ sql.Append(" and exists (select b.[ProjectId] from [Projectreason] b where a.[Id]=b.[ProjectId] ) ");
+
+ }
+ else
+ {
+ sql.Append(" and not exists (select b.[ProjectId] from [Projectreason] b where a.[Id]=b.[ProjectId] ) ");
+ }
+
+
+ }
+
+
+ if (!string.IsNullOrWhiteSpace(searchEntity.fblx))
+ {
+ if (searchEntity.fblx == "A")
+ {
+ sql.Append(" and a.fblx is not null ");
+ }
+ else
+ {
+ sql.Append(" and a.fblx is null ");
+ }
+
+
+ }
+
+ DateTime StartTimestarstart = DateTime.Now;
+ DateTime StartTimestarend = DateTime.Now;
+ if (!string.IsNullOrWhiteSpace(searchEntity.StartTimestar))
+ {
+ string[] StartTimestars = searchEntity.StartTimestar.Split("|");
+ DateTime.TryParse(StartTimestars[0], out StartTimestarstart);
+ DateTime.TryParse(StartTimestars[1], out StartTimestarend);
+ //Createtimeend = Createtimeend.AddDays(1);
+ }
+
+
+ if (!string.IsNullOrWhiteSpace(searchEntity.StartTimestar))
+ {
+ sql.Append(" and a.start_time >='" + StartTimestarstart.ToString("yyyy-MM-dd") + "'");
+
+ }
+ if (!string.IsNullOrWhiteSpace(searchEntity.StartTimestar))
+ {
+ sql.Append(" and a.start_time <='" + StartTimestarend.AddDays(1).ToString("yyyy-MM-dd") + "'");
+
+ }
+
+ if (!string.IsNullOrWhiteSpace(searchEntity.KaibiaoTimeStar))
+ {
+ sql.Append(" and a.start_time >='" + searchEntity.KaibiaoTimeStar + "'");
+
+ }
+ if (!string.IsNullOrWhiteSpace(searchEntity.KaibiaoTimeEnd))
+ {
+ sql.Append(" and a.start_time <='" + searchEntity.KaibiaoTimeEnd + "'");
+
+ }
+
+ if (!string.IsNullOrWhiteSpace(searchEntity.Caigourenname))
+ {
+ sql.Append("and a.[caigourenname] like '%" + searchEntity.Caigourenname.Trim().Replace("'", "''") + "%'");
+
+ }
+
+ if (!string.IsNullOrWhiteSpace(searchEntity.Dailiname))
+ {
+ sql.Append("and a.[dailiname] like '%" + searchEntity.Dailiname.Trim().Replace("'", "''") + "%'");
+
+ }
+
+
if (!string.IsNullOrWhiteSpace(searchEntity.Sheng))
{
@@ -381,10 +577,24 @@
- 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<ProjectDTO>>(lianlist);
+
+ var cgfs = GetCgfs();
+ foreach(var projectDTO in list)
+ {
+ var cgf = cgfs.Where(x=>x.Id == projectDTO.Cgfs).FirstOrDefault();
+ if (cgf != null)
+ {
+ projectDTO.CgfsName = cgf.Name;
+ }
+
+ }
+
+
+
data.LoadData(searchEntity, list);
return data;
}
@@ -479,5 +689,16 @@
CacheHelperNetCore.CacheInsert("Projects", list);
return list;
}
+
+
+ public List<ProjectDTO> GetListsalary(string userid, DateTime datemin, DateTime datemax)
+ {
+
+
+ var listPosition = _context.Projects.Where(r => r.RecStatus == "A" && r.Creater == userid && r.Createtime >= datemin && r.Createtime < datemax).ToList();
+
+ var list = _mapper.Map<List<ProjectDTO>>(listPosition);
+ return list;
+ }
}
}
--
Gitblit v1.9.1