115 lines
4.3 KiB
C#
115 lines
4.3 KiB
C#
|
|
using Dapper;
|
|||
|
|
using dccdc.Models;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
|
|||
|
|
namespace dccdc.DAL
|
|||
|
|
{
|
|||
|
|
public class main_suggestionsDal
|
|||
|
|
{
|
|||
|
|
public List<main_suggestionsModel> GetAllList(string id, string jobsid, string harmfulid)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
string sql = "select * from main_suggestions where 1=1";
|
|||
|
|
if (!string.IsNullOrEmpty(id))
|
|||
|
|
{
|
|||
|
|
sql += " and id=@id";
|
|||
|
|
}
|
|||
|
|
if (!string.IsNullOrEmpty(jobsid))
|
|||
|
|
{
|
|||
|
|
sql += " and assessed_id=@jobsid";
|
|||
|
|
}
|
|||
|
|
if (!string.IsNullOrEmpty(harmfulid))
|
|||
|
|
{
|
|||
|
|
sql += " and harmful_id=@harmfulid";
|
|||
|
|
}
|
|||
|
|
return conn.Query<main_suggestionsModel>(sql, new { @id = id, @jobsid = jobsid, @harmfulid = harmfulid }).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public object save(main_suggestionsModel model)
|
|||
|
|
{
|
|||
|
|
string sql = "";
|
|||
|
|
if (model.id == 0)
|
|||
|
|
{
|
|||
|
|
sql = @"INSERT INTO [dbo].[main_suggestions]
|
|||
|
|
([suggestions]
|
|||
|
|
,[assessed_id]
|
|||
|
|
,[harmful_id])
|
|||
|
|
VALUES
|
|||
|
|
(@suggestions
|
|||
|
|
,@assessed_id
|
|||
|
|
,@harmful_id)";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
sql = @"UPDATE [dbo].[main_suggestions]
|
|||
|
|
SET [suggestions] = @suggestions
|
|||
|
|
,[assessed_id] = @assessed_id
|
|||
|
|
,[harmful_id] = @harmful_id
|
|||
|
|
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 object delete(string id)
|
|||
|
|
{
|
|||
|
|
string sql = "delete from main_suggestions where id=@id";
|
|||
|
|
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
int result = conn.Execute(sql, new { id = id });
|
|||
|
|
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<main_suggestionsModel> GetOutjianyiAll(string physical_num,string harmful_id ,string assessed_id)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
string sql = "SELECT ROW_NUMBER() OVER (ORDER BY getdate()) AS rn, id, main_advice as suggestions" +
|
|||
|
|
" FROM( SELECT id, main_advice FROM profession_main_advice_maintain WHERE status LIKE '是'"+
|
|||
|
|
" UNION SELECT id, suggestions FROM main_suggestions_group" +
|
|||
|
|
" WHERE groups_id IN(SELECT exam_group_maintain_id" +
|
|||
|
|
" FROM examination_process" +
|
|||
|
|
" WHERE physical_num = @physical_num)" +
|
|||
|
|
" UNION SELECT id, suggestions FROM main_suggestions WHERE " + //harmful_id = @harmful_id AND
|
|||
|
|
" assessed_id = @assessed_id ) a ORDER BY rn";
|
|||
|
|
|
|||
|
|
return conn.Query<main_suggestionsModel>(sql, new { @physical_num = physical_num, @harmful_id = harmful_id, @assessed_id = assessed_id }).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|