tijian_jichuang/Code/SOH.BLL.Host/t_grgzbBll.cs
2025-02-20 11:54:48 +08:00

635 lines
26 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EAS.Services;
using SOH.Entities;
using SOH.Data;
using EAS.Data;
using EAS.Data.Linq;
using EAS.Data.ORM;
using EAS.Data.Access;
using System.Data;
namespace SOH.BLL
{
[ServiceObject("个人信息")]
[ServiceBind(typeof(It_grgzb))]
public class t_grgzbBll : It_grgzb
{
/// <summary>
/// 根据体检日期获取当日的化验项目明细
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public DataTable GetHyxmMx(DateTime dt, DateTime dt1)
{
DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd") + " 00:00:00");
DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 23:59:59");
using (var db = new DbEntities())
{
string sql1 = @"select a.zhbm,b.zhmc,COUNT(1) as sl from t_tempdjxm a left join t_zhxm b on a.zhbm=b.zhbm where
a.djrq between '"+ dtStr + "' and '"+ dtEnd + "' and a.ztz!=0 and a.ztz!=2 and b.jclb=1 group by a.zhbm,b.zhmc order by sl desc";
DataTable dtb = db.DataAccessor.QueryDataTable(sql1);
return dtb;
}
}
/// <summary>
/// 根据体检日期获取当日的其他项目明细
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public DataTable GetQtxmMx(DateTime dt, DateTime dt1)
{
DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd") + " 00:00:00");
DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 23:59:59");
using (var db = new DbEntities())
{
string sql1 = @"select a.zhbm,b.zhmc,COUNT(1) as sl from t_tempdjxm a left join t_zhxm b on a.zhbm=b.zhbm where
a.djrq between '" + dtStr + "' and '" + dtEnd + "' and a.ztz!=0 and a.ztz!=2 and b.jclb=0 group by a.zhbm,b.zhmc order by sl desc";
DataTable dtb = db.DataAccessor.QueryDataTable(sql1);
return dtb;
}
}
/// <summary>
/// 当日的其他项目明细-根据组合编码获取男性数量
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public DataTable GetQtMan(DateTime dt, DateTime dt1,string zhbm)
{
DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd") + " 00:00:00");
DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 23:59:59");
using (var db = new DbEntities())
{
string sql1 = " select COUNT(xb) as sl from ("+
"select xb from t_ttgzb where tm in ("+
"select tm from t_tempdjxm a left join t_zhxm b on a.zhbm=b.zhbm where a.zhbm="+ zhbm + " " +
"and a.djrq between '"+ dtStr + "' and '"+ dtEnd + "' "+
"and a.ztz!=0 and a.ztz!=2 and b.jclb=0) and xb=0 "+
"union all "+
"select xb from t_grgzb where tm in ("+
"select tm from t_tempdjxm a left join t_zhxm b on a.zhbm=b.zhbm where a.zhbm="+ zhbm + " " +
"and a.djrq between '"+ dtStr+"' and '"+ dtEnd+"'"+
"and a.ztz!=0 and a.ztz!=2 and b.jclb=0) and xb=0 ) as t";
DataTable dtb = db.DataAccessor.QueryDataTable(sql1);
return dtb;
}
}
/// <summary>
/// 当日的医生工作量项目明细-根据组合编码获取男性数量
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public DataTable GetYsgzlMan(DateTime dt, DateTime dt1, string zhbm,string czy)
{
DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd") + " 00:00:00");
DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 23:59:59");
using (var db = new DbEntities())
{
string sql1 = "select COUNT(xb) as sl from ("+
"select xb from t_ttgzb where tm in (" +
"select tm from t_tempdjxm a left join t_zhxm b on a.zhbm = b.zhbm " +
"left join t_czygl c on a.czy = c.czym " +
"left join t_ygzd d on c.ygbm = d.bm " +
"where a.zhbm = "+ zhbm + "" +
" and a.djrq between '"+ dtStr + "' and '"+ dtEnd + "'" +
" and a.ztz != 0 and a.ztz != 2 and d.xm = '"+ czy + "') and xb = 0 " +
"union all " +
"select xb from t_grgzb where tm in (" +
"select tm from t_tempdjxm a left join t_zhxm b on a.zhbm = b.zhbm " +
"left join t_czygl c on a.czy = c.czym " +
"left join t_ygzd d on c.ygbm = d.bm " +
" where a.zhbm = "+ zhbm + "" +
" and a.djrq between '"+ dtStr + "' and '"+ dtEnd + "'" +
" and a.ztz != 0 and a.ztz != 2 and d.xm = '"+ czy + "') and xb = 0 ) as t";
DataTable dtb = db.DataAccessor.QueryDataTable(sql1);
return dtb;
}
}
/// <summary>
/// 根据体检日期获取当日的化验项目人数
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public DataTable GetHyxm(DateTime dt, DateTime dt1)
{
//DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd") + " 00:00:00");
//DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 23:59:59");
//DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd HH:mm:ss"));
//DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd HH:mm:ss"));
using (var db = new DbEntities())
{
string sql1 = @"select a.zhbm from t_tempdjxm a left join t_zhxm b on a.zhbm=b.zhbm where
a.djrq between '"+ dt + "' and '"+ dt1 + "' and a.ztz!=0 and a.ztz!=2 and b.jclb=1";
DataTable dtb = db.DataAccessor.QueryDataTable(sql1);
return dtb;
}
}
/// <summary>
/// 根据体检日期获取当日的项目数量
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public DataTable GetXmzs(DateTime dt, DateTime dt1)
{
//DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd") + " 00:00:00");
//DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 23:59:59");
//DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd HH:mm:ss"));
//DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd HH:mm:ss"));
using (var db = new DbEntities())
{
string sql1 = @"select zhbm from t_tempdjxm where djrq > '"+ dt + "' and djrq< '"+ dt1 + "' and czy is not null ";
DataTable dtb = db.DataAccessor.QueryDataTable(sql1);
return dtb;
}
}
/// <summary>
/// 根据体检日期获取当日的其他项目人数
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public DataTable GetQtxm(DateTime dt, DateTime dt1)
{
//DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd") + " 00:00:00");
//DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 23:59:59");
//DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd HH:mm:ss"));
//DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd HH:mm:ss"));
using (var db = new DbEntities())
{
string sql1 = @"select a.zhbm from t_tempdjxm a left join t_zhxm b on a.zhbm=b.zhbm where
a.djrq between '" + dt + "' and '" + dt1 + "' and a.ztz!=0 and a.ztz!=2 and b.jclb=0";
DataTable dtb = db.DataAccessor.QueryDataTable(sql1);
return dtb;
}
}
/// <summary>
/// 根据体检日期获取当日的个检体检人数
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public DataTable GetLsjxMx(DateTime dt, DateTime dt1)
{
DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd") + " 00:00:00");
DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 23:59:59");
using (var db = new DbEntities())
{
string sql1 = @"select a.zhbm,b.zhmc,COUNT(1) as sl from t_jjxb a left join t_zhxm b on a.zhbm=b.zhbm
where a.tm in (select tm from T_drxpjl where rq between
'"+ dtStr + "' and '"+ dtEnd + "' and sfjx =1 ) group by a.zhbm,b.zhmc order by sl desc";
DataTable dtb = db.DataAccessor.QueryDataTable(sql1);
return dtb;
}
}
/// <summary>
/// 根据体检日期获取当日的统计项目明细
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public DataTable GetYzbmMx(DateTime dt, DateTime dt1,string yzbm)
{
DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd") + " 00:00:00");
DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 23:59:59");
using (var db = new DbEntities())
{
string sql1 = @"select a.zhbm,b.zhmc,COUNT(1) as sl from t_tempdjxm a left join t_zhxm b on a.zhbm=b.zhbm
where a.djrq > '"+ dt + "' and a.djrq<'"+ dt1 + "' and b.yzbm='"+ yzbm + "' group by a.zhbm,b.zhmc order by sl desc";
DataTable dtb = db.DataAccessor.QueryDataTable(sql1);
return dtb;
}
}
/// <summary>
/// 根据体检日期获取当日的统计医生工作量明细
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public DataTable GetYsgzlMx(DateTime dt, DateTime dt1)
{
using (var db = new DbEntities())
{
string sql1 = @"select a.zhbm,d.xm,b.zhmc,COUNT(1) as sl from t_tempdjxm a left join t_zhxm b on a.zhbm=b.zhbm left join t_czygl c
on a.czy=c.czym left join t_ygzd d on c.ygbm=d.bm where a.djrq > '"+ dt + "' and a.djrq<'"+ dt1 + "' and a.czy is not null " +
"and a.czy !='' and a.ztz!=0 and a.ztz!=2 group by d.xm,a.zhbm,b.zhmc order by d.xm,a.zhbm";
DataTable dtb = db.DataAccessor.QueryDataTable(sql1);
return dtb;
}
}
/// <summary>
/// 根据体检日期获取当日的个检体检人数
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public DataTable GetLsjx(DateTime dt, DateTime dt1)
{
//DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd") + " 00:00:00");
//DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 23:59:59");
//DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd HH:mm:ss"));
//DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd HH:mm:ss"));
using (var db = new DbEntities())
{
string sql1 = @" select * from t_jjxb where tm in (select tm from T_drxpjl where rq between
'" + dt + "' and '" + dt1 + "' and sfjx =1 )";
DataTable dtb = db.DataAccessor.QueryDataTable(sql1);
return dtb;
}
}
/// <summary>
/// 根据体检日期获取统计项目人数信息
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public DataTable GetYzbm(DateTime dt, DateTime dt1)
{
//DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd") + " 00:00:00");
//DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 23:59:59");
//DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd HH:mm:ss"));
//DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd HH:mm:ss"));
using (var db = new DbEntities())
{
string sql1 = @"select COUNT(1) as rs,t_zhxm.yzbm from t_tempdjxm left join t_zhxm on
t_tempdjxm.zhbm=t_zhxm.zhbm where t_tempdjxm.djrq > '"+ dt + "' and " +
"t_tempdjxm.djrq < '"+ dt1 + "' and t_zhxm.yzbm !='' group by t_zhxm.yzbm";
DataTable dtb = db.DataAccessor.QueryDataTable(sql1);
return dtb;
}
}
/// <summary>
/// 根据体检日期获取当日的个检体检人数
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public List<t_grgzb> GetGrgzb(short fddm, DateTime dt, DateTime dt1)
{
if (dt == null)
{
return null;
}
//DateTime dtstr = DateTime.Parse(dt.ToUniversalTime().ToString());
//DateTime dt2end = DateTime.Parse(dt1.ToUniversalTime().ToString());
//DateTime dtstr = DateTime.Parse(dt.ToString("yyyy-MM-dd HH:mm:ss"));
//DateTime dt2end = DateTime.Parse(dt1.ToString("yyyy-MM-dd HH:mm:ss"));
using (DbEntities db = new DbEntities())
{
var data = from a in db.t_grgzbs where a.fddm == fddm && a.tmztz !=0 && a.tjrq > dt && a.tjrq < dt1 select a;
//var data = from a in db.t_grgzbs where a.fddm == fddm && a.tmztz != 0 && a.tjrq select a;
if (data.Any())
{
return data.ToList();
}
else
{
return null;
}
}
}
/// <summary>
/// 根据体检日期获取当日的团检体检人数
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public List<t_ttgzb> GetTtgzb(short fddm, DateTime dt, DateTime dt1)
{
if (dt == null||dt1==null)
{
return null;
}
//DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd") + " 00:00:00");
//DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 23:59:59");
//DateTime dtStr = DateTime.Parse(dt.ToString("yyyy-MM-dd HH:mm:ss"));
//DateTime dtEnd = DateTime.Parse(dt1.ToString("yyyy-MM-dd HH:mm:ss"));
using (DbEntities db = new DbEntities())
{
var data = from a in db.t_ttgzbs where a.fddm == fddm && a.tmztz != 0 && a.tjrq > dt && a.tjrq < dt1 select a;
if (data.Any())
{
return data.ToList();
}
else
{
return null;
}
}
}
/// <summary>
/// 根据条码获取个人信息
/// </summary>
/// <param name="tm"></param>
/// <returns></returns>
public t_grgzb GetGrgzbByTm(int tm)
{
t_grgzb tg = new t_grgzb();
using (DbEntities db = new DbEntities())
{
var data = from t in db.t_grgzbs where t.tm == tm select t;
if (data.Any())
{
tg = data.First();
}
else
{
tg = null;
}
}
return tg;
}
public string GetGrgzbListByTm(int tm)
{
using (DbEntities db = new DbEntities())
{
var data = from g in db.t_grgzbs
where g.tm == tm
select new
{
tm = g.tm,
hyh = g.hyh,
xm = g.xm,
xb = g.xb,
nl = g.nl,
ssbm = "",
tjrq = g.tjrq,
ygh = "",
htbm = "",
fddm = g.fddm,
dh = g.dh,
sfzh = g.sfzh,
tcbm = g.tcbm,
hfbz = g.hfbz
};
return Newtonsoft.Json.JsonConvert.SerializeObject(data.ToList());
}
}
public string GetTcByTm(int tmh)
{
using (DbEntities db = new DbEntities())
{
var data = db.t_grgzbs.Where(t => t.tm == tmh).Join(db.t_tcs, t => t.tcbm, p => p.tcbm, (t, p) => p);
return Newtonsoft.Json.JsonConvert.SerializeObject(data.ToList()); ;
}
}
public OperationResult Updategrgzb(t_grgzb b)
{
OperationResult or = new OperationResult();
using (DbEntities db = new DbEntities())
{
try
{
db.t_grgzbs.OrmAccessor.Update(b);
}
catch (Exception ex)
{
or.State = 0;
or.Message = ex.Message;
}
}
or.State = 1;
or.Message = "修改成功";
return or;
}
public OperationResult GrgzbCzrzDel(string czy,int tmztz,int tm)
{
OperationResult or = new OperationResult();
using (DbEntities db = new DbEntities())
{
using (DbTransaction tan = db.DataAccessor.CreateTransaction())
{
try
{
db.DataAccessor.Execute("insert into t_czrz(czy,czrq,czfs,tmztz,tm) values ('" + czy+"','"+DateTime.Now+"','删除',"+ tmztz + ",'"+tm+"')");
tan.Commit();
or.State = 1;
or.Message = "删除成功!";
}
catch (Exception e)
{
tan.Rollback();
or.State = 2;
or.Message = "删除失败!请联系网络管理员。";
}
}
}
return or;
}
public OperationResult CzrzFpks(string czy, int tmztz,string czfs, int tm)
{
OperationResult or = new OperationResult();
using (DbEntities db = new DbEntities())
{
using (DbTransaction tan = db.DataAccessor.CreateTransaction())
{
try
{
db.DataAccessor.Execute("insert into t_czrz(czy,czrq,czfs,tmztz,tm) values ('" + czy + "','" + DateTime.Now + "','"+ czfs + "'," + tmztz + ",'" + tm + "')");
tan.Commit();
or.State = 1;
or.Message = "分配成功";
}
catch (Exception e)
{
tan.Rollback();
or.State = 2;
or.Message = "分配成功!请联系网络管理员。";
}
}
}
return or;
}
public OperationResult GrgzbCzrzUpdate(string czy, int tmztz, int tm)
{
OperationResult or = new OperationResult();
using (DbEntities db = new DbEntities())
{
using (DbTransaction tan = db.DataAccessor.CreateTransaction())
{
try
{
db.DataAccessor.Execute("insert into t_czrz(czy,czrq,czfs,tmztz,tm) values ('" + czy + "','" + DateTime.Now + "','修改'," + tmztz + ",'" + tm + "')");
tan.Commit();
or.State = 1;
or.Message = "删除成功!";
}
catch (Exception e)
{
tan.Rollback();
or.State = 2;
or.Message = "删除失败!请联系网络管理员。";
}
}
}
return or;
}
public OperationResult GrgzbCzrzHF(string czy, int tmztz, int tm)
{
OperationResult or = new OperationResult();
using (DbEntities db = new DbEntities())
{
using (DbTransaction tan = db.DataAccessor.CreateTransaction())
{
try
{
db.DataAccessor.Execute("insert into t_czrz(czy,czrq,czfs,tmztz,tm) values ('" + czy + "','" + DateTime.Now + "','恢复'," + tmztz + ",'" + tm + "')");
tan.Commit();
or.State = 1;
or.Message = "删除成功!";
}
catch (Exception e)
{
tan.Rollback();
or.State = 2;
or.Message = "删除失败!请联系网络管理员。";
}
}
}
return or;
}
public OperationResult Del(int tm)
{
OperationResult or = new OperationResult();
using (DbEntities db = new DbEntities())
{
using (DbTransaction tan = db.DataAccessor.CreateTransaction())
{
try
{
db.DataAccessor.Execute("insert t_delgrgzb select * from t_grgzb where tm='" + tm + "'");
db.t_grgzbs.Delete(t => t.tm == tm);
db.DataAccessor.Execute("insert t_deljjxb select * from t_jjxb where tm='" + tm + "'");
db.t_jjxbs.Delete(t => t.tm == tm);
db.DataAccessor.Execute("insert t_delsfmxb select * from t_sfmxb where tm='" + tm + "'");
db.t_sfmxbs.Delete(t => t.tm == tm);
db.DataAccessor.Execute("insert t_deltfb select * from t_tfb where tm='" + tm + "'");
db.t_tfbs.Delete(t => t.tm == tm);
db.DataAccessor.Execute("insert t_deltjjg select * from t_tjjg where tm='" + tm + "'");
db.t_tjjgs.Delete(t => t.tm == tm);
db.DataAccessor.Execute("insert t_deltjjd select * from t_tjjd where tm='" + tm + "'");
db.t_tjjds.Delete(t => t.tm == tm);
db.DataAccessor.Execute("insert T_deldrxpjl select * from T_drxpjl where tm='" + tm + "'");
db.DataAccessor.Execute("delete from T_drxpjl where tm='" + tm + "'");
tan.Commit();
or.State = 1;
or.Message = "删除成功!";
}
catch (Exception e)
{
tan.Rollback();
or.State = 2;
or.Message = "删除失败!请联系网络管理员。";
}
}
}
return or;
}
public OperationResult Hf(int tm)
{
OperationResult or = new OperationResult();
using (DbEntities db = new DbEntities())
{
using (DbTransaction tan = db.DataAccessor.CreateTransaction())
{
try
{
db.DataAccessor.Execute("insert t_grgzb select * from t_delgrgzb where tm='" + tm + "'");
db.DataAccessor.Execute("delete from t_delgrgzb where tm='" + tm + "'");
db.DataAccessor.Execute("insert t_jjxb select * from t_deljjxb where tm='" + tm + "'");
db.DataAccessor.Execute("delete from t_deljjxb where tm='" + tm + "'");
db.DataAccessor.Execute("insert t_sfmxb select * from t_delsfmxb where tm='" + tm + "'");
db.DataAccessor.Execute("delete from t_delsfmxb where tm='" + tm + "'");
db.DataAccessor.Execute("insert t_tfb select * from t_deltfb where tm='" + tm + "'");
db.DataAccessor.Execute("delete from t_deltfb where tm='" + tm + "'");
db.DataAccessor.Execute("insert t_tjjg select * from t_deltjjg where tm='" + tm + "'");
db.DataAccessor.Execute("delete from t_deltjjg where tm='" + tm + "'");
db.DataAccessor.Execute("insert t_tjjd select * from t_deltjjd where tm='" + tm + "'");
db.DataAccessor.Execute("delete from t_deltjjd where tm='" + tm + "'");
db.DataAccessor.Execute("insert T_drxpjl select * from T_deldrxpjl where tm='" + tm + "'");
db.DataAccessor.Execute("delete from T_deldrxpjl where tm='" + tm + "'");
tan.Commit();
or.State = 1;
or.Message = "恢复成功!";
}
catch (Exception e)
{
tan.Rollback();
or.State = 2;
or.Message = "恢复失败!请联系网络管理员。";
}
}
}
return or;
}
}
}