768 lines
31 KiB
C#
768 lines
31 KiB
C#
using Dapper;
|
|
using dccdc.Models;
|
|
using dccdc.Models.DTO;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace dccdc.DAL
|
|
{
|
|
public class InfectionTestDal
|
|
{
|
|
public List<InfectionTestModel> GetAllDataList()
|
|
{
|
|
string sql = "Select * From infection_test Order By create_time";
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.Query<InfectionTestModel>(sql).ToList();
|
|
}
|
|
}
|
|
|
|
public List<InfectionTestModel> GetDataByIdent(string ident)
|
|
{
|
|
string sql = string.Format("Select * From infection_test Where ident = '{0}'", ident);
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.Query<InfectionTestModel>(sql).ToList();
|
|
}
|
|
}
|
|
|
|
public List<InfectionTestModel> GetNoticsList()
|
|
{
|
|
string sql = "Select * From infection_test where DATEDIFF(day,order_date,GETDATE())=-1";
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.Query<InfectionTestModel>(sql).ToList();
|
|
}
|
|
}
|
|
|
|
public string SaveData(InfectionTestModel model,int user_id)
|
|
{
|
|
int isQuestion = 0;
|
|
int state = 0;
|
|
int info_id = 0;
|
|
string open_id = "";
|
|
string returnValue = string.Empty;
|
|
int crowd_id;
|
|
string trade_name = "";
|
|
string ATime = model.order_date.Substring(0,10).Replace("-", "");
|
|
TradeTypeMaintainModel Ttm = new TradeTypeMaintainModel();
|
|
string sql1 = string.Format("Select isQuestion From infection_open_crowd Where id = (Select crowd_id From infection_open_user_info Where user_id = {0} ) ",user_id);
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
List<InfectionOpenCrowdModel> crowdModels = conn.Query<InfectionOpenCrowdModel>(sql1).ToList();
|
|
isQuestion = crowdModels[0].isQuestion;
|
|
}
|
|
|
|
string sql3 = string.Format("Select * From infection_open_user Where id = {0} ", user_id);
|
|
using (IDbConnection conn3 = CommHelper.GetSqlConnection())
|
|
{
|
|
InfectionOpenUserModel crowdModels3 = conn3.QueryFirst<InfectionOpenUserModel>(sql3);
|
|
state = crowdModels3.state;
|
|
open_id = crowdModels3.openid;
|
|
}
|
|
|
|
string sql4 = string.Format("Select * From infection_open_user_info Where user_id = {0} ", user_id);
|
|
using (IDbConnection conn4 = CommHelper.GetSqlConnection())
|
|
{
|
|
InfectionOpenUserInfoModel crowdModels4 = conn4.QueryFirst<InfectionOpenUserInfoModel>(sql4);
|
|
info_id = crowdModels4.id;
|
|
}
|
|
|
|
if (isQuestion == 0)
|
|
{
|
|
if (state == 0)
|
|
{
|
|
return "请完成信息录入!";
|
|
}
|
|
else if (state == 1)
|
|
{
|
|
return "请等待信息审核通过!";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (state == 0)
|
|
{
|
|
return "请完成信息录入!";
|
|
}
|
|
else if (state == 1)
|
|
{
|
|
return "请等待信息审核通过!";
|
|
}
|
|
else if (state == 2)
|
|
{
|
|
return "请填写调查问卷!";
|
|
}
|
|
}
|
|
model.info_id = info_id;
|
|
model.open_id = open_id;
|
|
string sqla = "select crowd_id from infection_open_user_info where id = " + model.info_id;
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
crowd_id = conn.Query<int>(sqla).FirstOrDefault();
|
|
}
|
|
string sqlb = "select name from infection_open_crowd where id = " + crowd_id;
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
trade_name = conn.Query<string>(sqlb).FirstOrDefault();
|
|
}
|
|
string sqlc = "select * from trade_type_maintain where trade_name = '" + trade_name + "'";
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
Ttm = conn.Query<TradeTypeMaintainModel>(sqlc).First();
|
|
}
|
|
string sqld = "select top 1 YYCode from MedicalAppointment where YYCode like '" + ATime + "%' order by YYCode desc";
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
var LastYYCode = conn.Query<string>(sqld).FirstOrDefault();
|
|
if (string.IsNullOrEmpty(LastYYCode))
|
|
{
|
|
model.YYCode = ATime + "001";
|
|
}
|
|
else
|
|
{
|
|
int c = int.Parse(LastYYCode.Substring(8));
|
|
c++;
|
|
model.YYCode = ATime + c.ToString("000");
|
|
}
|
|
}
|
|
|
|
model.CYFA = Ttm.id;
|
|
model.CYFAName = Ttm.trade_name;
|
|
string sql = @"Insert Into infection_test(info_id,test_type,test_org,name,ident,birth,unit,test_date,phone,order_date,order_place,state,
|
|
cancel_reason,create_time,ma_id) Values (@info_id,@test_type,@test_org,(Select name From infection_open_user_info Where
|
|
id = @info_id),(Select ident From infection_open_user_info Where
|
|
id = @info_id),(Select birth From infection_open_user_info Where
|
|
id = @info_id),(Select unit From infection_open_user_info Where
|
|
id = @info_id),@test_date,@phone,@order_date,@order_place,@state,@cancel_reason,@create_time,@ma_id)";
|
|
string saveAsSQL = @"Insert Into MedicalAppointment(openid,xingMing,IDCard,ADate,Mobile,YYType,jgid,CYFA,CYFAName,YYCode,ATime,MType) Values (@open_id,(Select name From infection_open_user_info Where
|
|
id = @info_id),(Select ident From infection_open_user_info Where
|
|
id = @info_id),@order_date,@phone,1,@test_org,@CYFA,@CYFAName,@YYCode,getdate(),1)Select @@Identity";
|
|
try
|
|
{
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
int ma_id = conn.ExecuteScalar<int>(saveAsSQL,model);
|
|
model.ma_id = ma_id;
|
|
int c = conn.Execute(sql, model);
|
|
//int d = conn.Execute(saveAsSQL, model);
|
|
if (c > 0)
|
|
{
|
|
returnValue = "预约成功!";
|
|
}
|
|
else
|
|
{
|
|
returnValue = "操作失败!";
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
returnValue = "操作失败!";
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
public string ModifyDataByID(InfectionTestModel model)
|
|
{
|
|
model.state = 0;
|
|
string returnValue = string.Empty;
|
|
string sql = @"Update dccdc.dbo.infection_test Set test_type=@test_type,test_org=@test_org,test_date=@test_date,phone=@phone,
|
|
order_date=@order_date,order_place=@order_place,state=@state,cancel_reason=@cancel_reason Where id=@id";
|
|
string saveAsSQL = @"Update dccdc.dbo.MedicalAppointment Set ADate=@order_date,Mobile=@phone,MType=1,jgid=@test_org Where id=@ma_id ";
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
int c = conn.Execute(sql, model);
|
|
int d = conn.Execute(saveAsSQL, model);
|
|
if (c > 0&& d > 0)
|
|
{
|
|
returnValue = "修改成功!";
|
|
}
|
|
else
|
|
{
|
|
returnValue = "修改失败!";
|
|
}
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
//取消预约
|
|
public string AbolishOrder(InfectionTestModel model)
|
|
{
|
|
string returnValue = string.Empty;
|
|
string sql = @"UPDATE dccdc.dbo.infection_test
|
|
SET cancel_reason = @cancel_reason
|
|
,state = 2
|
|
WHERE id=@id";
|
|
string sql2 = @"delete from dccdc.dbo.MedicalAppointment
|
|
WHERE id=@ma_id";
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
try
|
|
{
|
|
int result = conn.Execute(sql, model);
|
|
int result2 = conn.Execute(sql2, model);
|
|
if (result > 0 && result2 > 0)
|
|
returnValue = "取消成功!";
|
|
else
|
|
returnValue = "取消失败!";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return ex.Message;
|
|
}
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
public List<InfectionTestModel> GetDataByInfoID(int info_id)
|
|
{
|
|
string sql = string.Format("Select * From infection_test Where info_id = {0}", info_id);
|
|
List<InfectionTestModel> models = new List<InfectionTestModel>();
|
|
try
|
|
{
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
models = conn.Query<InfectionTestModel>(sql).ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string s = ex.Message;
|
|
}
|
|
return models;
|
|
}
|
|
|
|
public List<InfectionTestModel> GetDataByNamePhoneIdent(string name, string phone, int info_id)
|
|
{
|
|
string sql = string.Format("Select * From infection_test Where name = '{0}' And phone = '{1}' And info_id = {2} And state = 1", name, phone, info_id);
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.Query<InfectionTestModel>(sql).ToList();
|
|
}
|
|
}
|
|
|
|
public List<InfectionTestModel> GetDataByID(int ID)
|
|
{
|
|
string sql = string.Format("Select * From infection_test Where id = {0}",ID);
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.Query<InfectionTestModel>(sql).ToList();
|
|
}
|
|
}
|
|
|
|
|
|
public List<InfectionTestModel> getAllList(string pageSize,string page, string start, string end)
|
|
{
|
|
try
|
|
{
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
string sql = "select * ,row_number() over(order by id) as rownum from infection_test where 1=1 ";
|
|
if (start != null && start != "")
|
|
{
|
|
sql += "and order_date >= @start and order_date <= @end";
|
|
}
|
|
|
|
sql = "SELECT * FROM ("+sql+") t where t.rownum > (" + page + " - 1) * " + pageSize + " and rownum<= " + page + " * " + pageSize ;
|
|
return conn.Query<InfectionTestModel>(sql, new { start = start, end = end }).ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string s = ex.Message;
|
|
return null;
|
|
}
|
|
}
|
|
public int getCount(string start, string end)
|
|
{
|
|
try
|
|
{
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
string sql = "select count(1) from infection_test where 1=1 ";
|
|
if (!string.IsNullOrEmpty(start) && !string.IsNullOrEmpty(end))
|
|
{
|
|
sql += "and order_date >= @start and order_date <= @end";
|
|
}
|
|
return conn.ExecuteScalar<int>(sql, new { start = start, end = end });
|
|
}
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
string s = ex.Message;
|
|
return 0;
|
|
}
|
|
}
|
|
public int getCountids(string ids)
|
|
{
|
|
try
|
|
{
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
string sql = "select distinct info_id from infection_test where info_id in (" + ids + ") and state = 1";
|
|
return conn.ExecuteScalar<int>(sql);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
public InfectionTestModel getOne(string id)
|
|
{
|
|
string sql = "SELECT * FROM infection_test WHERE id = @id";
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.Query<InfectionTestModel>(sql, new { id = id }).First();
|
|
}
|
|
}
|
|
|
|
public List<InfectionTestModel> getAllList2()
|
|
{
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.Query<InfectionTestModel>("select * from infection_test where 1=1 ").ToList();
|
|
}
|
|
}
|
|
|
|
public object save(InfectionTestModel model)
|
|
{
|
|
string sql = "";
|
|
string saveAsSQL = "";
|
|
int crowd_id;
|
|
string trade_name = "";
|
|
string ATime = model.order_date.Replace("-","");
|
|
TradeTypeMaintainModel Ttm = new TradeTypeMaintainModel();
|
|
string sql1 = "select crowd_id from infection_open_user_info where id = "+ model.info_id;
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
crowd_id = conn.Query<int>(sql1).FirstOrDefault();
|
|
}
|
|
string sql2 = "select name from infection_open_crowd where id = " + crowd_id;
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
trade_name = conn.Query<string>(sql2).FirstOrDefault();
|
|
}
|
|
string sql3 = "select * from trade_type_maintain where trade_name = '"+trade_name+"'";
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
Ttm = conn.Query<TradeTypeMaintainModel>(sql3).First();
|
|
}
|
|
string sql4 = "select top 1 YYCode from MedicalAppointment where YYCode like '" + ATime + "%' order by YYCode desc";
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
var LastYYCode = conn.Query<string>(sql4).FirstOrDefault();
|
|
if (string.IsNullOrEmpty(LastYYCode))
|
|
{
|
|
model.YYCode = ATime + "001";
|
|
}
|
|
else
|
|
{
|
|
int c = int.Parse(LastYYCode.Substring(8));
|
|
c++;
|
|
model.YYCode = ATime + c.ToString("000");
|
|
}
|
|
}
|
|
|
|
model.CYFA = Ttm.id;
|
|
model.CYFAName = Ttm.trade_name;
|
|
if (model.id == 0)
|
|
{
|
|
sql = @"INSERT INTO [dbo].[infection_test](
|
|
[info_id],
|
|
[test_type],
|
|
[test_org],
|
|
[name],
|
|
[birth],
|
|
[unit],
|
|
[ident],
|
|
[phone],
|
|
[order_date],
|
|
[order_place],
|
|
[test_date],
|
|
[cancel_reason],
|
|
[state],
|
|
[create_time],
|
|
[ma_id]
|
|
)
|
|
VALUES
|
|
(@info_id,
|
|
@test_type,
|
|
@test_org,
|
|
@name,
|
|
@birth,
|
|
@unit,
|
|
@ident,
|
|
@phone,
|
|
@order_date,
|
|
@order_place,
|
|
@test_date,
|
|
@cancel_reason,
|
|
@state,
|
|
@create_time,
|
|
@ma_id
|
|
)";
|
|
saveAsSQL = @"Insert Into MedicalAppointment(openid,xingMing,IDCard,ADate,Mobile,YYType,jgid,CYFA,CYFAName,YYCode,MType) Values (@open_id,@name,@ident,@order_date,@phone,5,@test_org,@CYFA,@CYFAName,@YYCode,1)Select @@Identity";
|
|
}
|
|
else
|
|
{
|
|
sql = @"UPDATE [dbo].[infection_test]
|
|
SET [info_id] = @info_id
|
|
,[test_type] = @test_type
|
|
,[test_org] = @test_org
|
|
,[name] = @name
|
|
,[ident] = @ident
|
|
,[phone] = @phone
|
|
,[order_date] = @order_date
|
|
,[test_date] = @test_date
|
|
,[cancel_reason] = @cancel_reason
|
|
,[state] = @state
|
|
,[birth] = @birth
|
|
WHERE id=@id";
|
|
}
|
|
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
try
|
|
{
|
|
int ma_id = conn.ExecuteScalar<int>(saveAsSQL, model);
|
|
model.ma_id = ma_id;
|
|
int result = conn.Execute(sql, model);
|
|
if (result > 0)
|
|
return new { State = 1, Message = "保存成功!" };
|
|
else
|
|
return new { State = 0, Message = "保存失败!" };
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new { State = 0, Message = ex.Message };
|
|
}
|
|
}
|
|
}
|
|
|
|
//取消预约
|
|
public object abolishOrder(InfectionTestModel model)
|
|
{
|
|
string sql = @"UPDATE dccdc.dbo.infection_test
|
|
SET cancel_reason = @cancel_reason
|
|
,state = 2
|
|
WHERE id=@id";
|
|
string sql2 = @"delete from dccdc.dbo.MedicalAppointment
|
|
WHERE id=@ma_id";
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
try
|
|
{
|
|
int result = conn.Execute(sql, model);
|
|
int result2 = conn.Execute(sql2, model);
|
|
if (result > 0&& result2>0)
|
|
return new { State = 1, Message = "取消成功!" };
|
|
else
|
|
return new { State = 0, Message = "取消失败!" };
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new { State = 0, Message = ex.Message };
|
|
}
|
|
}
|
|
}
|
|
|
|
//导出
|
|
public List<InfectionTestModel> export(string start, string end)
|
|
{
|
|
string sql = "select t.*,m.status from infection_test t left join MedicalAppointment m on t.ma_id=m.id where 1=1 ";
|
|
|
|
if (!string.IsNullOrEmpty(start))
|
|
{
|
|
sql += " and t.order_date >= '" + start + "' ";
|
|
}
|
|
if (!string.IsNullOrEmpty(end))
|
|
{
|
|
sql += "' and t.order_date <= '" + end + "' ";
|
|
}
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
try
|
|
{
|
|
|
|
return conn.Query<InfectionTestModel>(sql).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
string err = e.Message;
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public object update2(InfectionTestModel model)
|
|
{
|
|
// model.passTime = DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
|
string sql = @"UPDATE [dbo].[professionalExam_register]
|
|
SET [person_name] = @person_name
|
|
,[sex] = @sex
|
|
,[nation] =@nation
|
|
,[marry_status]=@marry_status
|
|
,[person_age] = @person_age
|
|
,[birth] = @birth
|
|
,[phone] = @phone
|
|
,[native_info_maintain_id] = @native_info_maintain_id
|
|
,[home_address] = @home_address
|
|
,[work_category] = @work_category
|
|
WHERE id=@id";
|
|
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
try
|
|
{
|
|
int result = conn.Execute(sql, model);
|
|
if (result > 0)
|
|
return new { State = 1, Message = "保存成功!" };
|
|
else
|
|
return new { State = 0, Message = "保存失败!" };
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new { State = 0, Message = ex.Message };
|
|
}
|
|
}
|
|
}
|
|
|
|
public List<InfectionTestModel> getAllList(Criteria model)
|
|
{
|
|
string sql = "";
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
switch (model.result_status)
|
|
{
|
|
case "1":
|
|
sql = @"select id,health_certificate_number,enterprise_info_maintain_id,physical_num,person_name,person_age,card_number,phone,category,work_category,util_name,area,register_type,hazard_ids,job_status_id
|
|
from professionalExam_register
|
|
where id not in(select distinct person_id from professionalExam_project_result where qualified like '不合格' or deficiency like '缺项')
|
|
and procedure_status like '已录入检查结果' and register_type not like '复检登记'
|
|
and freezing_and_thawing is null and register_date >= @startDate and register_date <= @endDate and physical_type like '%职业%'";
|
|
break;
|
|
case "2":
|
|
sql = @"select id,health_certificate_number,enterprise_info_maintain_id,physical_num,person_name,person_age,card_number,phone,category,work_category,util_name,area,register_type ,hazard_ids,job_status_id
|
|
from professionalExam_register
|
|
where id in(select distinct person_id from professionalExam_project_result where qualified like '不合格')
|
|
and procedure_status like '已录入检查结果' and register_type not like '复检登记'
|
|
and freezing_and_thawing is null and register_date >= @startDate and register_date <= @endDate and physical_type like '%职业%'";
|
|
break;
|
|
case "3":
|
|
sql = @"select id,health_certificate_number,enterprise_info_maintain_id,physical_num,person_name,person_age,card_number,phone,category,work_category,util_name,area,register_type ,hazard_ids,job_status_id
|
|
from professionalExam_register
|
|
where register_type like '复检登记' and procedure_status like '已录入检查结果'
|
|
and freezing_and_thawing is null and register_date >= @startDate and register_date <= @endDate and physical_type like '%职业%'";
|
|
break;
|
|
case "4":
|
|
sql = @"select id,health_certificate_number,enterprise_info_maintain_id,physical_num,person_name,person_age,card_number,phone,category,work_category,util_name,area,register_type ,hazard_ids,job_status_id
|
|
from professionalExam_register
|
|
where procedure_status in('主检医生已审核','已打印健康证')
|
|
and freezing_and_thawing is null and register_date >= @startDate and register_date <= @endDate and physical_type like '%职业%'";
|
|
break;
|
|
}
|
|
|
|
if (model.person_name != "")
|
|
{
|
|
sql += " and person_name like @person_name ";
|
|
}
|
|
|
|
if (model.physical_num != "")
|
|
{
|
|
sql += " and physical_num like @physical_num ";
|
|
}
|
|
if (model.check_type != "")
|
|
{
|
|
sql += " and exam_type = @check_type ";
|
|
}
|
|
|
|
if (model.checkstartDate != null && model.checkstartDate != "")
|
|
{
|
|
sql += "and check_date >= @checkstartDate ";
|
|
}
|
|
if (model.checkendDate != null && model.checkendDate != "")
|
|
{
|
|
sql += "and check_date <= @checkendDate ";
|
|
}
|
|
|
|
sql += " order by register_date";
|
|
return conn.Query<InfectionTestModel>(sql, new { @checkstartDate = model.checkstartDate, @checkendDate = model.checkendDate, @check_type = model.check_type, @person_name = "%" + model.person_name + "%", @physical_num = "%" + model.physical_num + "%", @startDate = model.startDate, @endDate = model.endDate }).ToList();
|
|
}
|
|
}
|
|
|
|
public List<InfectionTestModel> GetDataByUserID(int user_id)
|
|
{
|
|
int info_id = 0;
|
|
string sql2 = string.Format("Select * From infection_open_user_info Where user_id = {0}", user_id);
|
|
List<InfectionOpenUserInfoModel> models2 = new List<InfectionOpenUserInfoModel>();
|
|
try
|
|
{
|
|
using (IDbConnection conn2 = CommHelper.GetSqlConnection())
|
|
{
|
|
models2 = conn2.Query<InfectionOpenUserInfoModel>(sql2).ToList();
|
|
info_id = models2[0].id;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string s = ex.Message;
|
|
}
|
|
string sql = string.Format("Select it.*,eb.bumenname as jgmc From dccdc.dbo.infection_test it left join oa.dbo.erpbumen eb on it.test_org=eb.id Where it.info_id = {0}", info_id);
|
|
List<InfectionTestModel> models = new List<InfectionTestModel>();
|
|
try
|
|
{
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
models = conn.Query<InfectionTestModel>(sql).ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string s = ex.Message;
|
|
}
|
|
return models;
|
|
}
|
|
|
|
public bool checkUserState(int info_id)
|
|
{
|
|
string sql = @"select count(*) from dccdc.dbo.infection_test where state <> 2 and info_id=" + info_id;
|
|
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
try
|
|
{
|
|
int result = conn.QueryFirst<int>(sql);
|
|
if (result > 0)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
public InfectionTestModel getLastTestData(int info_id)
|
|
{
|
|
string sql = @"select * from dccdc.dbo.infection_test where state = 0 and info_id=" + info_id + "order by id desc";
|
|
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
try
|
|
{
|
|
InfectionTestModel result = conn.QueryFirst<InfectionTestModel>(sql);
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public InfectionTestModel getDataByMaId(int ma_id)
|
|
{
|
|
string sql = @"select * from dccdc.dbo.infection_test where ma_id=" + ma_id ;
|
|
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
try
|
|
{
|
|
InfectionTestModel result = conn.QueryFirst<InfectionTestModel>(sql);
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void UpdateSendMsgFlg(int id)
|
|
{
|
|
string sql = "UPDATE infection_test SET send_msg_flg = '1' where id = " + id;
|
|
|
|
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
try
|
|
{
|
|
conn.Execute(sql);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void UpdateTestState(int ma_id)
|
|
{
|
|
string sql = "UPDATE infection_test SET state = 1 where ma_id = " + ma_id;
|
|
|
|
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
try
|
|
{
|
|
conn.Execute(sql);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
//当月已预约
|
|
public int getMonthOne()
|
|
{
|
|
string sql = "select count(*) from infection_test where state=0 and DATEDIFF(m,create_time,GETDATE())=0";
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.ExecuteScalar<int>(sql);
|
|
}
|
|
}
|
|
//当月已体检
|
|
public int getMonthTwo()
|
|
{
|
|
string sql = "select count(*) from infection_test where state=1 and DATEDIFF(m,create_time,GETDATE())=0";
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.ExecuteScalar<int>(sql);
|
|
}
|
|
}
|
|
//已预约
|
|
public int getAllOne()
|
|
{
|
|
string sql = "select count(*) from infection_test where state=0 ";
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.ExecuteScalar<int>(sql);
|
|
}
|
|
}
|
|
//已体检
|
|
public int getAllTwo()
|
|
{
|
|
string sql = "select count(*) from infection_test where state=1 ";
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.ExecuteScalar<int>(sql);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|