537 lines
24 KiB
C#
537 lines
24 KiB
C#
using dccdc.DAL;
|
||
using dccdc.Models;
|
||
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Web.Mvc;
|
||
using ZWL.Common;
|
||
using dccdc.BLL;
|
||
using System.IO;
|
||
using System.Data;
|
||
using MiniExcelLibs;
|
||
using ExcelDataReader;
|
||
using NPOI.SS.UserModel;
|
||
using NPOI.XSSF.UserModel;
|
||
using Excel;
|
||
using NPOI.HSSF.UserModel;
|
||
using static dccdc.Models.DictionariesViewModel;
|
||
using Aspose.Pdf.Operators;
|
||
using static ZXing.QrCode.Internal.Mode;
|
||
|
||
namespace dccdc.Controllers
|
||
{
|
||
public class DoctorInquiryController : Controller
|
||
{
|
||
// GET: DoctorInquiry
|
||
public ActionResult Index()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
#region 职业问诊
|
||
public ActionResult DoctorInquiry()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
public ActionResult OccupationDiseaseInput()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
public ActionResult OccupationHistoryInput()
|
||
{
|
||
ViewBag.tjzt = "0";
|
||
var tzzylb = new List<string> { "电工作业", "金属焊接,切割作业", "起重机械", "企业内机动车驾驶", "锅炉作业", "锅炉作业", "登高架设作业", "制冷作业", "电梯", "天车", "航吊", "其他" };
|
||
ViewData["tzzylb"] = new SelectList(tzzylb);
|
||
ViewData["tjlx"] = new SelectList(new checktypemaintainBll().GetListBybelong("职业"), "id", "check_type");
|
||
ViewData["zgzt"] = new SelectList(new JobsStateMaintainBll().GetAllList("", "是"), "id", "jobs_state");
|
||
ViewData["tytjfn"] = new SelectList(new OccupationExamSchemeMaintainBll().GetListByType("通用"), "id", "scheme_name");
|
||
return View();
|
||
}
|
||
|
||
public string uploadOccupationDataImport(string enterprise,string enterprise_id,string scheme_name, string work_state,string physical_way,string hazard_names,string hazard_alias,string hazard_ids,
|
||
string hazards_type,string hazards_type_codes,string check_item_ids,string exam_type,string exam_type_maintain_id,string charge,string util_scheme_id,string common_scheme_id)
|
||
{
|
||
if (Request.Files.Count == 0)
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "没有要处理的文件" });
|
||
}
|
||
else
|
||
{
|
||
try
|
||
{
|
||
string path = Server.MapPath("~/exec/");
|
||
if (!Directory.Exists(path))
|
||
{
|
||
Directory.CreateDirectory(path);
|
||
}
|
||
string Excel_Name = Guid.NewGuid().ToString("N") + Request.Files[0].FileName.Substring(Request.Files[0].FileName.LastIndexOf("."));
|
||
|
||
string st10 = DateTime.Now.ToFileTime().ToString() + ".xls";
|
||
|
||
Request.Files[0].SaveAs(path + st10);
|
||
|
||
//DataTable dtx = MiniExcel.QueryAsDataTable(path, useHeaderRow: true);
|
||
|
||
System.Data.DataTable dtx = ZWL.Common.DataToExcel.Reader_Excel(path, st10);
|
||
|
||
System.Data.DataTable[] dts = { dtx };
|
||
|
||
var bll = new BLL.OccupationDataImportObjectBll();
|
||
for (int i = 0; i < dts[0].Rows.Count; i++)
|
||
{
|
||
OccupationDataImportObjectModel och = new OccupationDataImportObjectModel();
|
||
och.enterprise = enterprise;
|
||
och.enterprise_id = Convert.ToInt32(enterprise_id);
|
||
och.process = "已完成导入";//"已导入完成";
|
||
och.import_date = DateTime.Now.ToString("yyyy-MM-dd");
|
||
och.scheme_name = scheme_name;
|
||
och.work_state = work_state;
|
||
och.physical_way = physical_way;
|
||
//2023-10-31 xulu 因团检报告需求修改,暂时注释
|
||
//根据dts[0].Rows[i][8].ToString()中的有害因素查询表中是否存在其有害因素,
|
||
//若存在,记录其id,若不存在,新增并记录其id,最终返回所有有害因素ids
|
||
//string strIds = new DAL.HarmfulFactorsMaintainDal().GetIdsByNames(dts[0].Rows[i][8].ToString());
|
||
//och.hazard_names = dts[0].Rows[i][8].ToString();//
|
||
och.hazard_names = hazard_names;
|
||
och.hazard_alias = hazard_names;
|
||
//och.hazard_ids = strIds;//
|
||
och.hazard_ids = hazard_ids;
|
||
och.hazards_type = hazards_type;
|
||
och.hazards_type_codes = hazards_type_codes;
|
||
och.check_item_ids = check_item_ids;
|
||
och.exam_type = exam_type;
|
||
och.exam_type_maintain_id = exam_type_maintain_id;
|
||
och.charge = charge;
|
||
och.comment = dts[0].Rows[i][12].ToString();
|
||
//2023-10-25 xulu 检查姓名及身份证号是否为空,若为空返回提示信息
|
||
if(dts[0].Rows[i][0].ToString() =="")
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "存在姓名为空的行,请检查并重新上传!" });
|
||
}
|
||
och.name = dts[0].Rows[i][0].ToString();
|
||
och.sex = dts[0].Rows[i][1].ToString();
|
||
if(dts[0].Rows[i][2].ToString() == "")
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "存在身份证号为空的行,请检查并重新上传!" });
|
||
}
|
||
och.identity_card = dts[0].Rows[i][2].ToString();
|
||
//2023-10-24 xulu 导入模板添加民族,并根据婚否状态填写数据
|
||
string strMarry = "";
|
||
if(dts[0].Rows[i][3].ToString()=="已婚")
|
||
{
|
||
strMarry = "是";
|
||
}
|
||
else if(dts[0].Rows[i][3].ToString() == "未婚")
|
||
{
|
||
strMarry = "否";
|
||
}
|
||
else if (dts[0].Rows[i][3].ToString() == "离异")
|
||
{
|
||
strMarry = "离异";
|
||
}
|
||
och.is_merry= strMarry;
|
||
och.nation = dts[0].Rows[i][4].ToString();
|
||
och.telephone = dts[0].Rows[i][5].ToString();
|
||
och.dept = dts[0].Rows[i][6].ToString();
|
||
och.work_type = dts[0].Rows[i][7].ToString();
|
||
och.factor = dts[0].Rows[i][8].ToString();
|
||
och.work_age_year = dts[0].Rows[i][9].ToString();
|
||
och.work_age_month = dts[0].Rows[i][10].ToString();
|
||
och.factor_age_year = dts[0].Rows[i][11].ToString();
|
||
och.factor_age_month = dts[0].Rows[i][12].ToString();
|
||
och.check_type = dts[0].Rows[i][14].ToString();
|
||
|
||
if(!util_scheme_id.Equals("-1"))
|
||
och.util_scheme_id = util_scheme_id;
|
||
if (!common_scheme_id.Equals("-1"))
|
||
och.common_scheme_id = common_scheme_id;
|
||
bll.add(och);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "处理文件失败!" + ex.Message });
|
||
}
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 1, Message = "处理上传成功!" });
|
||
}
|
||
}
|
||
|
||
/*/// <summary>
|
||
/// 2023-06-28 李星,重写读取Excel
|
||
/// </summary>
|
||
/// <param name="path1"></param>
|
||
/// <param name="Excel_Name"></param>
|
||
/// <returns></returns>
|
||
private System.Data.DataTable Reader_Excel(string path1,string Excel_Name)
|
||
{
|
||
try
|
||
{
|
||
//实例化DataTable来存放数据
|
||
System.Data.DataTable dt = new System.Data.DataTable();
|
||
string fileName = path1 + Excel_Name;
|
||
string sheetName = Excel_Name;//Excel的工作表名称
|
||
bool isColumnName = true;//判断第一行是否为标题列
|
||
IWorkbook workbook;//创建一个工作薄接口
|
||
string fileExt = Path.GetExtension(fileName).ToLower();//获取文件的拓展名
|
||
//创建一个文件流
|
||
using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
|
||
{
|
||
if (fileExt == ".xls" || fileExt == ".xlsx")//xlsx
|
||
{
|
||
//.xls ,xlsx
|
||
//XSSFWorkbook workbook = new XSSFWorkbook(file);
|
||
//HSSFWorkbook workbook = new HSSFWorkbook(file);
|
||
workbook = new HSSFWorkbook(fs);
|
||
}
|
||
else
|
||
{
|
||
workbook = null;
|
||
}
|
||
|
||
//实例化sheet
|
||
ISheet sheet = null;
|
||
if (sheetName != null && sheetName != "")//判断是否存在sheet
|
||
{
|
||
sheet = workbook.GetSheet(sheetName);
|
||
if (sheet == null)
|
||
{
|
||
sheet = workbook.GetSheetAt(0);//从第一个开始读取,0位索引
|
||
}
|
||
else
|
||
{
|
||
sheet = workbook.GetSheetAt(0);
|
||
}
|
||
}
|
||
|
||
//获取表头
|
||
IRow header = sheet.GetRow(sheet.FirstRowNum);
|
||
int startRow = 0;//数据的第一行索引
|
||
if (isColumnName)//表示第一行是列名
|
||
{
|
||
startRow = sheet.FirstRowNum + 1;//数据从第二行开始读
|
||
|
||
//遍历表的第一行,即所有的列名
|
||
for (int i = header.FirstCellNum; i < header.LastCellNum; i++)
|
||
{
|
||
ICell cell = header.GetCell(i);
|
||
if (cell != null)
|
||
{
|
||
//获取列名的值
|
||
string cellValue = cell.ToString();
|
||
if (cellValue != null)
|
||
{
|
||
DataColumn col = new DataColumn(cellValue);
|
||
dt.Columns.Add(col);
|
||
}
|
||
else
|
||
{
|
||
DataColumn col = new DataColumn();
|
||
dt.Columns.Add(col);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//读取数据
|
||
for (int i = startRow; i <= sheet.LastRowNum; i++)
|
||
{
|
||
IRow row = sheet.GetRow(i);
|
||
if (row == null)
|
||
{
|
||
continue;
|
||
}
|
||
DataRow dr = dt.NewRow();
|
||
for (int j = row.FirstCellNum; j < row.LastCellNum; j++)
|
||
{
|
||
if (row.GetCell(j) != null)
|
||
{
|
||
dr[j] = row.GetCell(j).ToString();
|
||
}
|
||
}
|
||
dt.Rows.Add(dr);
|
||
}
|
||
return dt;
|
||
}
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
throw e;
|
||
}
|
||
}*/
|
||
|
||
public JsonResult uploadOccupationHistory(string key,String name)
|
||
{
|
||
if (Request.Files.Count == 0)
|
||
{
|
||
return Json(new { State = 0, Message = "没有要处理的文件" });
|
||
}
|
||
else
|
||
{
|
||
/*
|
||
byte[] buffer = new byte[1024];
|
||
MemoryStream ms = new MemoryStream();
|
||
while (true)
|
||
{
|
||
int sz = Request.Files[0].InputStream.Read(buffer, 0, 1024);
|
||
if (sz == 0) break;
|
||
ms.Write(buffer, 0, sz);
|
||
}
|
||
ms.Position = 0;*/
|
||
|
||
try
|
||
{
|
||
string path = Server.MapPath("~/exec/");
|
||
if (!Directory.Exists(path))
|
||
{
|
||
Directory.CreateDirectory(path);
|
||
}
|
||
path = path + Guid.NewGuid().ToString("N") + Request.Files[0].FileName.Substring(Request.Files[0].FileName.LastIndexOf("."));
|
||
Request.Files[0].SaveAs(path);
|
||
|
||
System.Data.DataTable dtx = MiniExcel.QueryAsDataTable(path, useHeaderRow: true);
|
||
System.Data.DataTable[] dts = { dtx };
|
||
|
||
//DataTable[] dts = xiaoy.Excel.ExcelFile.GetData(path, xiaoy.Excel.ExcelVersion.Excel12, xiaoy.Excel.HDRType.Yes, false);
|
||
|
||
var bll = new BLL.OccupationDiseaseDataImportBll();
|
||
for (int i = 0; i < dts[0].Rows.Count; i++)
|
||
{
|
||
OccupationDiseaseDataImportModel oh = new OccupationDiseaseDataImportModel();
|
||
oh.enterprise_id = key;
|
||
oh.enterprise = name;
|
||
oh.name= dts[0].Rows[i][0].ToString();
|
||
oh.identity_card = dts[0].Rows[i][1].ToString();
|
||
oh.start_date = dts[0].Rows[i][2].ToString();
|
||
oh.end_date = dts[0].Rows[i][3].ToString();
|
||
oh.util = dts[0].Rows[i][4].ToString();
|
||
oh.workshop = dts[0].Rows[i][5].ToString();
|
||
oh.work_type = dts[0].Rows[i][6].ToString();
|
||
oh.factory = dts[0].Rows[i][7].ToString();
|
||
oh.protect_method = dts[0].Rows[i][8].ToString();
|
||
oh.status = "导入阶段";
|
||
bll.save(oh);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return Json(new { State = 0, Message = "处理结果文件失败!" + ex.Message });
|
||
}
|
||
|
||
return Json(new { State = 1, Message = "处理上报结果成功!" });
|
||
}
|
||
}
|
||
|
||
public ActionResult DoctorInquiryInfo()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
public JsonResult saveExam(String key,string pNum, String type)
|
||
{
|
||
var bll = new BLL.DoctorInquiryBll();
|
||
var user = Session["loginUser"] as Models.ERPUser;
|
||
return Json(bll.saveExam(key, pNum, type, user));
|
||
}
|
||
|
||
public JsonResult getSymptomsList()
|
||
{
|
||
var bll = new BLL.SymptomsMaintainBll();
|
||
List<Models.SymptomsMaintainModel> ctList = bll.GetAllListN("","是");
|
||
return Json(new { SymptomsList = ctList });
|
||
}
|
||
|
||
public JsonResult initPage()
|
||
{
|
||
var areaBll = new BLL.AreaInfoMaintainBll();
|
||
List<Models.AreaInfoMaintainModel> areas = areaBll.GetAllList();
|
||
var personType = new BLL.PersonTypeMaintainBll();
|
||
List<Models.PersonTypeMaintainModel > types = personType.GetAllList("","");
|
||
return Json(new {Area = areas,Type = types });
|
||
}
|
||
|
||
public JsonResult getDoctorInquiryList(int page, int pagesize, string key)
|
||
{
|
||
var bll = new BLL.DoctorInquiryBll();
|
||
int count = bll.getCount(key);
|
||
List<Models.DoctorInquiryModel> ctList = bll.getList(page, pagesize, key);
|
||
return Json(new { Total = count, Rows = ctList });
|
||
}
|
||
|
||
public JsonResult getDoctorInquiry(FormCollection param)
|
||
{
|
||
var bll = new BLL.DoctorInquiryBll();
|
||
int count = bll.getCount(param["physical_num"]);
|
||
List<Models.DoctorInquiryModel> ctList = bll.getList(1, 1, param["physical_num"]);
|
||
|
||
return Json(new {
|
||
doctorInquiry = ctList.FirstOrDefault(),
|
||
factorSymtom =new BLL.summaryreport_factor_symptomBll().GetAllList(param["job_status_id"], param["hazard_type_ids"].TrimEnd(',').TrimStart(',')),
|
||
//notice = new BLL.notice_factor_maintainBll().GetAllList(param["job_status_id"], param["hazard_type_ids"].TrimEnd(',').TrimStart(','), param["exam_type_id"]),
|
||
//查询条件exam_type_id与查询语句中的exam_group_maintain_id不对应,暂时赋null
|
||
notice = new BLL.notice_factor_maintainBll().GetAllList(param["job_status_id"], param["hazard_type_ids"].TrimEnd(',').TrimStart(','),null),
|
||
factorImport = new BLL.summaryreport_factor_importantBll().GetAllList(param["job_status_id"], param["hazard_type_ids"].TrimEnd(',').TrimStart(','))
|
||
});
|
||
}
|
||
|
||
public JsonResult getDoctorInquiryByNum(String key)
|
||
{
|
||
var bll = new BLL.DoctorInquiryBll();
|
||
ProfessionalExamRegisterModel model = new ProfessionalExamRegisterBll().getOneByNum(key);
|
||
int count = bll.getCount(model.physical_num);
|
||
List<Models.DoctorInquiryModel> ctList = bll.getList(1, 1, model.physical_num);
|
||
string strHarmfulids = model.hazard_type_ids == null ? null : model.hazard_type_ids.TrimEnd(',').TrimStart(',');
|
||
return Json(new
|
||
{
|
||
doctorInquiry = ctList.FirstOrDefault(),
|
||
factorSymtom = new BLL.summaryreport_factor_symptomBll().GetAllList(model.job_status_id.ToString(), strHarmfulids),
|
||
notice = new BLL.notice_factor_maintainBll().GetAllList(model.job_status_id.ToString(), strHarmfulids, model.exam_type_id.ToString()),
|
||
factorImport = new BLL.summaryreport_factor_importantBll().GetAllList(model.job_status_id.ToString(), strHarmfulids),
|
||
sex=model.sex
|
||
});
|
||
}
|
||
|
||
public JsonResult getProfessionalExamRegisterList(FormCollection param)
|
||
{
|
||
var bll = new BLL.ProfessionalExamRegisterBll();
|
||
List<Models.ProfessionalExamRegisterModel> ctList = bll.getUseList(param["tjbh"], param["djrq"], param["jsrq"], param["qy"],param["xm"], param["tjrq"], param["tjjsrq"], param["rylb"], param["qiye"],param["ywz"]);
|
||
return Json(new { Rows = ctList });
|
||
}
|
||
|
||
public JsonResult saveDoctorInquiry(DoctorInquiryModel ct)
|
||
{
|
||
var user = Session["loginUser"] as Models.ERPUser;
|
||
return Json(new BLL.DoctorInquiryBll().save(ct, user));
|
||
}
|
||
|
||
public JsonResult getFactorSymtom(string jobsid, string harmfulid)
|
||
{
|
||
return Json(new BLL.summaryreport_factor_symptomBll().GetAllList("", jobsid, harmfulid));
|
||
}
|
||
|
||
public JsonResult getNotice(string jobsid, string harmfulid,String examId)
|
||
{
|
||
return Json(new BLL.notice_factor_maintainBll().GetAllList("", jobsid, harmfulid, examId));
|
||
}
|
||
|
||
public JsonResult getFactorimportant(string jobsid, string harmfulid)
|
||
{
|
||
return Json(new BLL.summaryreport_factor_importantBll().GetAllList("", jobsid, harmfulid));
|
||
}
|
||
|
||
public JsonResult getOccupationHistoryList(string key)
|
||
{
|
||
if(key == "")
|
||
{
|
||
return Json(null);
|
||
}
|
||
var bll = new BLL.OccupationHistoryBll();
|
||
int count = bll.getCount(key);
|
||
List<Models.OccupationHistoryModel> ctList = bll.getList(key);
|
||
return Json(new { Total = count, Rows = ctList });
|
||
}
|
||
|
||
public JsonResult getOccupationHistoryImportList(int page, int pagesize, string key)
|
||
{
|
||
if (key == "")
|
||
{
|
||
return Json(null);
|
||
}
|
||
var bll = new BLL.OccupationDiseaseDataImportBll();
|
||
int count = bll.getCount(key);
|
||
List<Models.OccupationDiseaseDataImportModel> ctList = bll.getList(page,pagesize,key);
|
||
return Json(new { Total = count, Rows = ctList });
|
||
}
|
||
|
||
public JsonResult getPastHistoryList(string key)
|
||
{
|
||
if (key == "")
|
||
{
|
||
return Json(null);
|
||
}
|
||
var bll = new BLL.PastHistoryBll();
|
||
int count = bll.getCount(key);
|
||
List<Models.PastHistoryModel> ctList = bll.getList(key);
|
||
return Json(new { Total = count, Rows = ctList });
|
||
}
|
||
|
||
public JsonResult savePastHistory(PastHistoryModel oc)
|
||
{
|
||
var bll = new BLL.PastHistoryBll();
|
||
return Json(bll.save(oc, null));
|
||
}
|
||
|
||
public JsonResult saveOccupationHistory(OccupationHistoryModel oc)
|
||
{
|
||
var bll = new BLL.OccupationHistoryBll();
|
||
return Json(bll.save(oc, null));
|
||
}
|
||
#endregion
|
||
|
||
public JsonResult deleteOccupationHistory(string id)
|
||
{
|
||
if (string.IsNullOrEmpty(id))
|
||
return Json(null);
|
||
return Json(new BLL.OccupationHistoryBll().delete(id));
|
||
}
|
||
public JsonResult deletePastHistory(string id)
|
||
{
|
||
if (string.IsNullOrEmpty(id))
|
||
return Json(null);
|
||
return Json(new BLL.PastHistoryBll().delete(id));
|
||
}
|
||
|
||
public string GetTjfnModel(string tjfnId)
|
||
{
|
||
if (tjfnId == "")
|
||
{
|
||
return "{}";
|
||
}
|
||
OccupationExamSchemeMaintainBll bll = new OccupationExamSchemeMaintainBll();
|
||
return JsonConvert.SerializeObject(bll.GetModel(tjfnId));
|
||
}
|
||
|
||
public string GetTjfnBySiteId(string siteid)
|
||
{
|
||
|
||
OccupationExamSchemeMaintainBll bll = new OccupationExamSchemeMaintainBll();
|
||
return JsonConvert.SerializeObject(bll.GetSiteList(siteid));
|
||
}
|
||
|
||
public string GetsfxmBytjfnid(string tjfnid)
|
||
{
|
||
MedicalSchemeChargeMaintainBll bll = new MedicalSchemeChargeMaintainBll();
|
||
List<MedicalSchemeChargeMaintainModel> al = bll.GetListBymedicalschememaintainid(tjfnid);
|
||
string modelslistjson = JsonConvert.SerializeObject(al); ;
|
||
return "{\"Rows\":" + modelslistjson + "}";
|
||
}
|
||
|
||
public string GetSfxmBytjfn(string tjfnid)
|
||
{
|
||
if (tjfnid == "")
|
||
{
|
||
return "";
|
||
}
|
||
OccupationExamSchemeMaintainBll bll = new OccupationExamSchemeMaintainBll();
|
||
string tjxmids = bll.GetModel(tjfnid).check_item_ids;
|
||
ChargeProjectMaintainBll bll1 = new ChargeProjectMaintainBll();
|
||
string modelslistjson = JsonConvert.SerializeObject(bll1.GetAllListBytjxm(tjxmids));
|
||
return "{\"Rows\":" + modelslistjson + "}";
|
||
}
|
||
|
||
public string GetTjxmBytjfn(string tjfnid)
|
||
{
|
||
if (tjfnid == "")
|
||
{
|
||
return "";
|
||
}
|
||
OccupationExamSchemeMaintainBll bll = new OccupationExamSchemeMaintainBll();
|
||
string tjxmids = bll.GetModel(tjfnid).check_item_ids;
|
||
ExamProjectMaintainBll tjxmbll = new ExamProjectMaintainBll();
|
||
string modelslistjson = JsonConvert.SerializeObject(tjxmbll.GetTjfnmxByIDs(tjxmids.TrimStart(',').TrimEnd(',')));
|
||
return "{\"Rows\":" + modelslistjson + "}";
|
||
}
|
||
}
|
||
} |