人民医院API

WorkOrderBaseController.cs 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. using RMYY_CallCenter_Api.Models.Enum;
  2. using RMYY_CallCenter_Api.Utility;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Web;
  9. using System.Web.Mvc;
  10. using System.Reflection;
  11. using RMYY_CallCenter_Api.Models.Dto;
  12. using RMYY_CallCenter_Api.DB;
  13. namespace RMYY_CallCenter_Api.Controllers
  14. {
  15. public class WorkOrderBaseController : BaseController
  16. {
  17. private Bll.T_Sys_Department deptbll = new Bll.T_Sys_Department();
  18. private Bll.T_Sys_UserAccount userbll = new Bll.T_Sys_UserAccount();
  19. private Bll.T_Wowo_repairyqbll yqbll = new Bll.T_Wowo_repairyqbll();
  20. private Bll.T_Sys_GongDan gdbll = new Bll.T_Sys_GongDan();
  21. // GET: WorkOrderBase
  22. /// <summary>
  23. /// 获取院区
  24. /// </summary>
  25. /// <returns></returns>
  26. public ActionResult GetHosArea()
  27. {
  28. List<HosArea> mlist = new List<HosArea>();
  29. var modelist = yqbll.GetListall();
  30. return Content(modelist.ToJson());
  31. }
  32. /// <summary>
  33. /// 获取科室部门列表
  34. /// </summary>
  35. /// <returns></returns>
  36. public ActionResult GetDept(int HosId)
  37. {
  38. //int userId = User.F_UserId;
  39. //if (userId != 0)
  40. //{
  41. if (HosId == 0)
  42. return Error("请选择院区!");
  43. List<Model.T_Sys_Department> dmodel = deptbll.GetModelList("T_Woid="+ HosId + " and F_State=1");
  44. if (dmodel.Count > 0)
  45. {
  46. var obj = new
  47. {
  48. rows = dmodel.Select(p => new
  49. {
  50. deptid = p.F_DeptId,
  51. deptName = p.F_DeptName
  52. })
  53. };
  54. return Content(obj.ToJson());
  55. }
  56. else
  57. return Success("暂无信息!");
  58. //}
  59. //return
  60. // Error("无操作权限!");
  61. }
  62. /// <summary>
  63. /// 获取所有部门列表
  64. /// </summary>
  65. /// <returns></returns>
  66. public ActionResult GetDeptall()
  67. {
  68. //int userId = User.F_UserId;
  69. //if (userId != 0)
  70. //{
  71. List<Model.T_Sys_Department> dmodel = deptbll.GetModelList("F_State=1");
  72. if (dmodel.Count > 0)
  73. {
  74. var obj = new
  75. {
  76. rows = dmodel.Select(p => new
  77. {
  78. deptid = p.F_DeptId,
  79. deptName = p.F_DeptName
  80. })
  81. };
  82. return Content(obj.ToJson());
  83. }
  84. else
  85. return Success("暂无信息!");
  86. //}
  87. //return
  88. // Error("无操作权限!");
  89. }
  90. public ActionResult GetPerson(int deptid = 0)
  91. {
  92. string sql = "";
  93. if (deptid != 0)
  94. {
  95. var dmodel = deptbll.GetModel(deptid);
  96. if (dmodel != null)
  97. {
  98. sql = "F_DeptId=" + deptid;
  99. sql += "and F_EnableFlag=1";
  100. }
  101. }
  102. var ua = userbll.GetModelList(sql);
  103. var obj = new
  104. {
  105. state = "success",
  106. message = "成功",
  107. rows = ua.Select(p => new
  108. {
  109. usercode = p.F_UserCode,
  110. username = p.F_UserName,
  111. usertelphone = p.F_Telephone,
  112. userworkphone = p.F_WorkPhone
  113. })
  114. };
  115. return Content(obj.ToJson());
  116. }
  117. /// <summary>
  118. /// 获取科室人员信息
  119. /// </summary>
  120. /// <param name="deptid"></param>
  121. /// <returns></returns>
  122. public ActionResult GetPersonByDeptId(int deptid = 0)
  123. {
  124. string sql = "";
  125. if (deptid != 0)
  126. {
  127. var dmodel = deptbll.GetModel(deptid);
  128. if (dmodel != null)
  129. {
  130. sql = "F_DeptId=" + deptid;
  131. sql += "and F_EnableFlag=1";
  132. }
  133. }
  134. if (deptid > 0)
  135. {
  136. Bll.T_Sys_GroupClass gcbll = new Bll.T_Sys_GroupClass();
  137. List<Model.T_Sys_GroupClass> grouplist = gcbll.GetModelList(" F_IsDelete=0 and F_Date = CONVERT(varchar, GETDATE(), 120) and F_ClassCode in ( select F_Id from t_sys_class where F_IsDelete = 0 and CONVERT(varchar, GETDATE(),108) between F_InTime and F_OutTime and F_DeptId ='" + deptid + "' )");
  138. if (grouplist.Count > 0)
  139. {
  140. var obj = new
  141. {
  142. state = "success",
  143. message = "成功",
  144. rows = grouplist.Select(p => new
  145. {
  146. usercode = p.F_UserCode,
  147. username = GetUserModel( p.F_UserCode)
  148. })
  149. };
  150. return Content(obj.ToJson());
  151. }
  152. else
  153. {
  154. var ua = userbll.GetModelList(sql);
  155. var obj = new
  156. {
  157. state = "success",
  158. message = "成功",
  159. rows = ua.Select(p => new
  160. {
  161. usercode = p.F_UserCode,
  162. username = p.F_UserName
  163. })
  164. };
  165. return Content(obj.ToJson());
  166. }
  167. }
  168. return Error("deptid要大于0");
  169. }
  170. public string GetUserModel(string usercode = "")
  171. {
  172. string sql = " 1=1 ";
  173. if (!string.IsNullOrWhiteSpace(usercode))
  174. {
  175. sql += " and F_UserCode='" + usercode + "'";
  176. }
  177. if (string.IsNullOrEmpty(usercode))
  178. return "";
  179. Model.T_Sys_UserAccount ua = new Bll.T_Sys_UserAccount().GetModelList(sql).FirstOrDefault();
  180. if (ua != null)
  181. {
  182. return ua.F_UserName;
  183. }
  184. return "";
  185. }
  186. /// <summary>
  187. /// 获取转运人
  188. /// </summary>
  189. /// <param name="deptid"></param>
  190. /// <param name="rolecode"></param>
  191. /// <returns></returns>
  192. public ActionResult GetTransPson(int deptid = 0, string rolecode = "")
  193. {
  194. string sql = "1=1";
  195. if (deptid != 0)
  196. {
  197. sql+= $" and F_DeptId="+deptid;
  198. }
  199. if (!string.IsNullOrEmpty(rolecode))
  200. {
  201. int roldid = new Bll.T_Sys_Role().GetModel(rolecode).F_RoleId;
  202. if (roldid != 0)
  203. {
  204. sql += $" and F_RoleId=" + roldid;
  205. }
  206. }
  207. var modellist = userbll.GetModelList(sql);
  208. var obj = new
  209. {
  210. state = "success",
  211. message = "成功",
  212. rows = modellist.Select(p => new
  213. {
  214. usercode = p.F_UserCode,
  215. username = p.F_UserName,
  216. userphon = p.F_Telephone
  217. })
  218. };
  219. return Content(obj.ToJson());
  220. }
  221. /// <summary>
  222. /// 获取工单类型
  223. /// </summary>
  224. /// <param name="pid"></param>
  225. /// <param name="typeid"></param>
  226. /// <returns></returns>
  227. public ActionResult GetGongDanType(int pid = 0, int typeid = 1)
  228. {
  229. var modelist = gdbll.GetModelList("");
  230. //if (pid != 0)
  231. //{
  232. var obj = new
  233. {
  234. rows = modelist.Where(t => t.F_ParentID == pid && t.F_TypeId == typeid).Select(p => new
  235. {
  236. fid = p.F_GDId,
  237. fname = p.F_Name,
  238. pid = p.F_ParentID,
  239. typeid=p.F_TypeId
  240. })
  241. };
  242. return Content(obj.ToJson());
  243. //}
  244. //else
  245. //{
  246. // var obj = new
  247. // {
  248. // rows = modelist.Where(t => t.F_TypeId == typeid).Select(p => new
  249. // {
  250. // fid = p.F_GDId,
  251. // fname = p.F_Name,
  252. // pid = p.F_ParentID,
  253. // typeid = p.F_TypeId
  254. // })
  255. // };
  256. // return Content(obj.ToJson());
  257. //}
  258. }
  259. /// <summary>
  260. /// 上传附件
  261. /// </summary>
  262. /// <returns></returns>
  263. //[Authority]
  264. public ActionResult UploadFile()
  265. {
  266. #region 多个上传
  267. HttpFileCollectionBase files = Request.Files;
  268. if (files.Count > 0)
  269. {
  270. List<Model.T_Sys_Accessories> acs = new List<Model.T_Sys_Accessories>();
  271. string path = "/Upload/Files/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
  272. for (int i = 0; i < files.Count; i++)
  273. {
  274. HttpPostedFileBase file = files[i];
  275. string name = FileHelper.Upload(file, path);
  276. Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
  277. model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
  278. model_T_Sys_Accessories.F_FileName = name;//附件名称
  279. model_T_Sys_Accessories.F_FileType = Path.GetExtension(file.FileName);//附件类型
  280. model_T_Sys_Accessories.F_FileUrl = path + name;//附件地址
  281. model_T_Sys_Accessories.F_Size = file.ContentLength;
  282. model_T_Sys_Accessories.F_UserCode = User.F_UserCode;//上传人
  283. int id = new Bll.T_Sys_Accessories().Add(model_T_Sys_Accessories);
  284. model_T_Sys_Accessories.F_FileId = id;
  285. acs.Add(model_T_Sys_Accessories);
  286. }
  287. return Success("成功", acs);
  288. }
  289. else
  290. {
  291. return Error("请选择要上传的文件");
  292. }
  293. #endregion
  294. }
  295. /// <summary>
  296. /// 上传图片
  297. /// </summary>
  298. /// <returns></returns>
  299. public ActionResult UploadImage()
  300. {
  301. string path = string.Empty;
  302. HttpPostedFileBase _upfile = Request.Files["upFile"];
  303. if (_upfile != null)
  304. {
  305. path = "/Upload/Pic/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
  306. ImageHelper iu = new ImageHelper();
  307. iu.SavePath = path;
  308. iu.PostFile = _upfile;
  309. iu.Upload();
  310. path = path + iu.OutFileName;
  311. return Success("成功", path);
  312. }
  313. else
  314. return Error("请选择要上传的文件");
  315. }
  316. /// <summary>
  317. /// 上传图片表单
  318. /// </summary>
  319. /// <returns></returns>
  320. public ActionResult UploadImage64()
  321. {
  322. string path = string.Empty;
  323. //HttpPostedFile _upfile = RequestString.GetFile("upFile");
  324. string dataurl = HttpUtility.UrlDecode(Request["dataurl"]);
  325. string filename = Request["filename"];
  326. if (!string.IsNullOrEmpty(dataurl))
  327. {
  328. path = "/Upload/Pic/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
  329. ImageHelper iu = new ImageHelper();
  330. iu.SavePath = path;
  331. iu.DataUrl = dataurl;
  332. if (!string.IsNullOrEmpty(filename))
  333. {
  334. iu.SaveType = 1;
  335. iu.InFileName = filename;
  336. }
  337. iu.Upload64();
  338. //var configfj = new Bll.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  339. int n = iu.Error;
  340. if (n == 0)
  341. {
  342. path = path + iu.OutFileName;
  343. Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
  344. model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
  345. model_T_Sys_Accessories.F_FileName = iu.OutFileName;//附件名称
  346. model_T_Sys_Accessories.F_FileType = ".jpg";//附件类型
  347. model_T_Sys_Accessories.F_FileUrl = path;//附件地址
  348. model_T_Sys_Accessories.F_Size = iu.FileSize;
  349. //model_T_Sys_Accessories.F_UserCode = User.F_UserCode;//上传人
  350. int id = new Bll.T_Sys_Accessories().Add(model_T_Sys_Accessories);
  351. model_T_Sys_Accessories.F_FileId = id;
  352. return Success("成功", model_T_Sys_Accessories);
  353. }
  354. else
  355. {
  356. string msg = string.Empty;
  357. switch (n)
  358. {
  359. case 1: msg = "请选择要上传的文件"; break;
  360. case 2: msg = "上传的文件类型不支持"; break;
  361. case 3: msg = "上传的文件过大"; break;
  362. case 4: msg = "未知错误"; break;
  363. }
  364. return Error(msg);
  365. }
  366. }
  367. else
  368. {
  369. return Error("请选择要上传的文件");
  370. }
  371. }
  372. public class HosArea
  373. {
  374. /// <summary>
  375. /// 院区id
  376. /// </summary>
  377. public int hosid { get; set; }
  378. /// <summary>
  379. /// 院区名称
  380. /// </summary>
  381. public string hosname { get; set; }
  382. }
  383. public object CreateInstance()
  384. {
  385. //用传递参数来得到一个类的实例
  386. string itemType = "T_Sys_GongDan";
  387. string assembleyName = this.GetType().Assembly.GetName().Name;//Net.BLL
  388. string nameSpace = this.GetType().Namespace;
  389. Type type = Type.GetType($"RMYY_CallCenter_Api.Bll.{itemType},RMYY_CallCenter_Api.Bll");
  390. //用Activator .CreateInstance创建函数实例,默认的不带参数的构造函数
  391. object obj = (object)Activator.CreateInstance(type, null);
  392. return obj;
  393. }
  394. }
  395. }