You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
351 lines
16 KiB
351 lines
16 KiB
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Configuration.UserSecrets;
|
|
using Newtonsoft.Json;
|
|
using Shentun.PeisReport.Api.Dto;
|
|
using SqlSugar;
|
|
using System.Data;
|
|
using static Dm.net.buffer.ByteArrayBuffer;
|
|
|
|
namespace Shentun.PeisReport.Api.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 上传
|
|
/// </summary>
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
public class ReportController : ControllerBase
|
|
{
|
|
private readonly SqlSugarClient _peisDb;
|
|
private readonly SqlSugarClient _reportDb;
|
|
private readonly IConfiguration _configuration;
|
|
private readonly ILogger<ReportController> _logger;
|
|
|
|
|
|
public ReportController(
|
|
IConfiguration configuration,
|
|
ILogger<ReportController> logger)
|
|
{
|
|
_configuration = configuration;
|
|
_logger = logger;
|
|
_reportDb = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
ConnectionString = _configuration.GetSection("ConnectionStrings:Report").Value,
|
|
DbType = SqlSugar.DbType.Oracle,
|
|
IsAutoCloseConnection = true
|
|
});
|
|
|
|
//_reportDb.Aop.OnLogExecuting = (sql, pars) =>
|
|
//{
|
|
// _logger.LogError(sql);
|
|
// _logger.LogError("参数:" + string.Join(",", pars.Select(p => $"{p.ParameterName}={p.Value}")));
|
|
//};
|
|
|
|
_peisDb = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
ConnectionString = _configuration.GetSection("ConnectionStrings:Default").Value,
|
|
DbType = SqlSugar.DbType.SqlServer,
|
|
IsAutoCloseConnection = true
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 上传体检数据
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<UploadReportDto> UploadReportAsync(UploadReportInputDto input)
|
|
{
|
|
|
|
var result = new UploadReportDto
|
|
{
|
|
Code = 100,
|
|
Message = "请求失败"
|
|
};
|
|
|
|
try
|
|
{
|
|
|
|
var peisQuery = await _peisDb.Ado.GetDataTableAsync($"select name as patient_name from patient_register where patient_register_id='{input.PatientRegisterId}' and create_pdf_flag='1'");
|
|
if (peisQuery.Rows.Count > 0)
|
|
{
|
|
|
|
string patientName = peisQuery.Rows[0]["patient_name"].ToString();
|
|
string directoryDate = input.PatientRegisterId.Substring(0, 6);
|
|
string zWHostAddress = _configuration.GetSection("ZWHostAddress").Value;
|
|
string reportVirtual = _configuration.GetSection("ReportVirtualPath:RequestPath").Value;
|
|
string reportUrl = $"{zWHostAddress + reportVirtual}/{directoryDate}/{input.PatientRegisterId}({patientName}).pdf";
|
|
|
|
input.bgdz = reportUrl;
|
|
}
|
|
|
|
|
|
var query = await _reportDb.Ado.GetDataTableAsync($"select * from TJDJ_00.tj_jbxxb where examRequestCode='{input.examRequestCode}' " +
|
|
$" and yljgdm='{input.yljgdm}' and yljgmc='{input.yljgmc}' ");
|
|
if (query.Rows.Count > 0)
|
|
{
|
|
////修改
|
|
//var exeCount = await _reportDb.Ado.ExecuteCommandAsync("update TJDJ_00.tj_jbxxb set name=@name,iDCard=@iDCard,identityType=@identityType,birthDate=@birthDate,xb=@xb,age=@age," +
|
|
// "telephone=@telephone,mz=@mz,kh=@kh,klx=@klx,gzdw=@gzdw,xjzdz=@xjzdz,regCode=@regCode,scheduleDate=@scheduleDate,iTypeName=@iTypeName," +
|
|
// "groupName=@groupName,tjzje=@tjzje,bgdz=@bgdz,scheduleStatus=@scheduleStatus,xgbz=@xgbz,scsj=@scsj,yljgdm=@yljgdm,yljgmc=@yljgmc where examRequestCode=@examRequestCode",
|
|
// new List<SugarParameter>() {
|
|
// new SugarParameter("name",input.name),
|
|
// new SugarParameter("iDCard",input.iDCard),
|
|
// new SugarParameter("identityType",input.identityType),
|
|
// new SugarParameter("birthDate",input.birthDate),
|
|
// new SugarParameter("xb",input.xb),
|
|
// new SugarParameter("age",input.age),
|
|
// new SugarParameter("telephone",input.telephone),
|
|
// new SugarParameter("mz",input.mz),
|
|
// new SugarParameter("kh",input.kh),
|
|
// new SugarParameter("klx",input.klx),
|
|
// new SugarParameter("gzdw",input.gzdw),
|
|
// new SugarParameter("xjzdz",input.xjzdz),
|
|
// new SugarParameter("examRequestCode",input.examRequestCode),
|
|
// new SugarParameter("scheduleDate",input.scheduleDate),
|
|
// new SugarParameter("iTypeName",input.iTypeName),
|
|
// new SugarParameter("groupName",input.groupName),
|
|
// new SugarParameter("regCode",input.regCode),
|
|
// new SugarParameter("tjzje",input.tjzje),
|
|
// new SugarParameter("bgdz",input.bgdz),
|
|
// new SugarParameter("scheduleStatus",input.scheduleStatus),
|
|
// new SugarParameter("xgbz","2"),
|
|
// new SugarParameter("scsj",input.scsj),
|
|
// new SugarParameter("yljgdm",input.yljgdm),
|
|
// new SugarParameter("yljgmc",input.yljgmc)
|
|
// });
|
|
|
|
//修改
|
|
var exeCount = await _reportDb.Ado.ExecuteCommandAsync($"update TJDJ_00.tj_jbxxb set name='{input.name}',iDCard='{input.iDCard}',identityType='{input.identityType}'," +
|
|
$"birthDate='{input.birthDate}',xb='{input.xb}',age='{input.age}',telephone='{input.telephone}',mz='{input.mz}',kh='{input.kh}',klx='{input.klx}',gzdw='{input.gzdw}'," +
|
|
$"xjzdz='{input.xjzdz}',regCode='{input.regCode}',scheduleDate='{input.scheduleDate}',iTypeName='{input.iTypeName}',groupName='{input.groupName}',tjzje='{input.tjzje}'," +
|
|
$"bgdz='{input.bgdz}',scheduleStatus='{input.scheduleStatus}',xgbz='{input.xgbz}',scsj='{input.scsj}' " +
|
|
$" where examRequestCode='{input.examRequestCode}' and yljgdm='{input.yljgdm}' and yljgmc='{input.yljgmc}' ");
|
|
|
|
|
|
if (exeCount == 0)
|
|
{
|
|
_logger.LogError($"接口UploadReportAsync异常,更新失败:{JsonConvert.SerializeObject(input)}");
|
|
result = new UploadReportDto
|
|
{
|
|
Code = 100,
|
|
Message = "更新失败"
|
|
};
|
|
}
|
|
else
|
|
{
|
|
result = new UploadReportDto
|
|
{
|
|
Code = 200,
|
|
Message = "更新成功"
|
|
};
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
////新增
|
|
//var exeCount = await _reportDb.Ado.ExecuteCommandAsync("INSERT INTO TJDJ_00.tj_jbxxb(name,iDCard,identityType,birthDate,xb,age,telephone,mz,kh,klx,gzdw,xjzdz,examRequestCode,scheduleDate,iTypeName," +
|
|
// "groupName,regCode,tjzje,bgdz,scheduleStatus,xgbz,scsj,yljgdm,yljgmc) VALUES (@name,@iDCard,@identityType,@birthDate,@xb,@age,@telephone,@mz,@kh,@klx,@gzdw,@xjzdz,@examRequestCode," +
|
|
// "@scheduleDate,@iTypeName,@groupName,@regCode,@tjzje,@bgdz,@scheduleStatus,@xgbz,@scsj,@yljgdm,@yljgmc);",
|
|
// new List<SugarParameter>() {
|
|
// new SugarParameter("name",input.name),
|
|
// new SugarParameter("iDCard",input.iDCard),
|
|
// new SugarParameter("identityType",input.identityType),
|
|
// new SugarParameter("birthDate",input.birthDate),
|
|
// new SugarParameter("xb",input.xb),
|
|
// new SugarParameter("age",input.age),
|
|
// new SugarParameter("telephone",input.telephone),
|
|
// new SugarParameter("mz",input.mz),
|
|
// new SugarParameter("kh",input.kh),
|
|
// new SugarParameter("klx",input.klx),
|
|
// new SugarParameter("gzdw",input.gzdw),
|
|
// new SugarParameter("xjzdz",input.xjzdz),
|
|
// new SugarParameter("examRequestCode",input.examRequestCode),
|
|
// new SugarParameter("scheduleDate",input.scheduleDate),
|
|
// new SugarParameter("iTypeName",input.iTypeName),
|
|
// new SugarParameter("groupName",input.groupName),
|
|
// new SugarParameter("regCode",input.regCode),
|
|
// new SugarParameter("tjzje",input.tjzje),
|
|
// new SugarParameter("bgdz",input.bgdz),
|
|
// new SugarParameter("scheduleStatus",input.scheduleStatus),
|
|
// new SugarParameter("xgbz","1"),
|
|
// new SugarParameter("scsj",input.scsj),
|
|
// new SugarParameter("yljgdm",input.yljgdm),
|
|
// new SugarParameter("yljgmc",input.yljgmc)
|
|
// });
|
|
|
|
|
|
//新增
|
|
var exeCount = await _reportDb.Ado.ExecuteCommandAsync($"INSERT INTO TJDJ_00.tj_jbxxb(name,iDCard,identityType,birthDate,xb,age,telephone,mz,kh,klx,gzdw,xjzdz,examRequestCode,scheduleDate,iTypeName," +
|
|
$"groupName,regCode,tjzje,bgdz,scheduleStatus,xgbz,scsj,yljgdm,yljgmc) VALUES ('{input.name}','{input.iDCard}','{input.identityType}','{input.birthDate}','{input.xb}','{input.age}'," +
|
|
$"'{input.telephone}','{input.mz}','{input.kh}','{input.klx}','{input.gzdw}','{input.xjzdz}','{input.examRequestCode}'," +
|
|
$"'{input.scheduleDate}','{input.iTypeName}','{input.groupName}','{input.regCode}','{input.tjzje}','{input.bgdz}','{input.scheduleStatus}','1','{input.scsj}','{input.yljgdm}','{input.yljgmc}');");
|
|
|
|
|
|
|
|
if (exeCount == 0)
|
|
{
|
|
_logger.LogError($"接口UploadReportAsync异常,上传失败:{JsonConvert.SerializeObject(input)}");
|
|
result = new UploadReportDto
|
|
{
|
|
Code = 100,
|
|
Message = "上传失败"
|
|
};
|
|
}
|
|
else
|
|
{
|
|
result = new UploadReportDto
|
|
{
|
|
Code = 200,
|
|
Message = "上传成功"
|
|
};
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.Message = ex.Message;
|
|
_logger.LogError($"接口UploadReportAsync异常,上传失败:{JsonConvert.SerializeObject(input)},异常信息:{ex.ToString()}");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 撤销上传的数据
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<UploadReportDto> DeleteReportAsync(DeleteReportInputDto input)
|
|
{
|
|
|
|
var result = new UploadReportDto
|
|
{
|
|
Code = 100,
|
|
Message = "请求失败"
|
|
};
|
|
|
|
try
|
|
{
|
|
|
|
|
|
var query = await _reportDb.Ado.GetDataTableAsync($"select * from TJDJ_00.tj_jbxxb where examRequestCode='{input.examRequestCode}' and yljgdm='{input.yljgdm}' and yljgmc='{input.yljgmc}' ");
|
|
if (query.Rows.Count > 0)
|
|
{
|
|
//修改
|
|
var exeCount = await _reportDb.Ado.ExecuteCommandAsync($"update TJDJ_00.tj_jbxxb set xgbz='3' where examRequestCode='{input.examRequestCode}' " +
|
|
" and yljgdm='{input.yljgdm}' and yljgmc='{input.yljgmc}' ");
|
|
|
|
if (exeCount == 0)
|
|
{
|
|
_logger.LogError($"接口DeleteReportAsync异常,更新失败:{JsonConvert.SerializeObject(input)}");
|
|
result = new UploadReportDto
|
|
{
|
|
Code = 100,
|
|
Message = "更新失败"
|
|
};
|
|
}
|
|
else
|
|
{
|
|
result = new UploadReportDto
|
|
{
|
|
Code = 200,
|
|
Message = "更新成功"
|
|
};
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
result = new UploadReportDto
|
|
{
|
|
Code = 100,
|
|
Message = "数据不存在"
|
|
};
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.Message = ex.Message;
|
|
_logger.LogError($"接口DeleteReportAsync异常,上传失败:{JsonConvert.SerializeObject(input)},异常信息:{ex.ToString()}");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 查询测试
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<PublicResultDto> TestSqlAsync()
|
|
{
|
|
|
|
var result = new PublicResultDto
|
|
{
|
|
Code = 100,
|
|
Message = "请求失败"
|
|
};
|
|
|
|
try
|
|
{
|
|
var query = _reportDb.Ado.GetScalar("select count(*) from TJDJ_00.tj_jbxxb");
|
|
result = new PublicResultDto
|
|
{
|
|
Code = 200,
|
|
Message = query.ToString()
|
|
};
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.Message = ex.Message;
|
|
_logger.LogError($"接口TestSqlAsync异常,上传失败:{ex.Message}");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
///// <summary>
|
|
///// 删除测试
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//[HttpPost]
|
|
//public async Task<PublicResultDto> TestDeleteSqlAsync(string examRequestCode)
|
|
//{
|
|
|
|
// var result = new PublicResultDto
|
|
// {
|
|
// Code = 100,
|
|
// Message = "请求失败"
|
|
// };
|
|
|
|
// try
|
|
// {
|
|
// var query = _reportDb.Ado.ExecuteCommand("delete from TJDJ_00.tj_jbxxb where examRequestCode='{examRequestCode}' ");
|
|
// result = new PublicResultDto
|
|
// {
|
|
// Code = 200,
|
|
// Message = query.ToString()
|
|
// };
|
|
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// result.Message = ex.Message;
|
|
// _logger.LogError($"接口TestDeleteSqlAsync异常,失败:{ex.Message}");
|
|
// }
|
|
// return result;
|
|
//}
|
|
|
|
|
|
}
|
|
}
|