人民医院API

WorkCommonController.cs 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. using RMYY_CallCenter_Api.Controllers.CarManage;
  2. using RMYY_CallCenter_Api.DB;
  3. using RMYY_CallCenter_Api.Model;
  4. using RMYY_CallCenter_Api.Models.Dto;
  5. using RMYY_CallCenter_Api.Models.Enum;
  6. using RMYY_CallCenter_Api.Utility;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Linq;
  11. using System.Web.Mvc;
  12. namespace RMYY_CallCenter_Api.Controllers.WorkOrder
  13. {
  14. public class WorkCommonController : BaseController
  15. {
  16. private BLL.T_Wo_CommonBase basebll = new BLL.T_Wo_CommonBase();
  17. private Bll.T_Sys_GongDan gdbll = new Bll.T_Sys_GongDan();
  18. private Bll.AddLogBll logbll = new Bll.AddLogBll();
  19. private static InternalMessagesController msg = new InternalMessagesController();
  20. /// <summary>
  21. /// 我的提交
  22. /// </summary>
  23. /// <param name="keyword"></param>
  24. /// <param name="starttime"></param>
  25. /// <param name="endtime"></param>
  26. /// <param name="pageindex"></param>
  27. /// <param name="pagesize"></param>
  28. /// <param name="state"></param>
  29. /// <returns></returns>
  30. public ActionResult GetSubmitList(string starttime = "", string endtime = "", string keyword = "", int pageindex = 1, int pagesize = 10, int state = -1, int type = 0, int loweltype = 0, string wocode = "")
  31. {
  32. if (User != null)
  33. {
  34. int recordCount = 0;
  35. string sql = $" and (F_ProposerDept='{User.F_DeptId}' or F_DealDept='{User.F_DeptId}' ) and F_IsDelete = 0";
  36. if (!string.IsNullOrEmpty(wocode))
  37. {
  38. sql += $" and F_WoCode like'%{wocode}%'";
  39. }
  40. if (type > 0)
  41. {
  42. sql += $" and F_Type={type}";
  43. }
  44. if (loweltype > 0)
  45. {
  46. sql += $" and F_SonType={loweltype}";
  47. }
  48. if (state >= 0)
  49. {
  50. sql += $" and F_IsDone={state}";
  51. }
  52. if (!string.IsNullOrEmpty(starttime))
  53. {
  54. sql += $" and F_CreateTime>='{starttime}'";
  55. }
  56. if (!string.IsNullOrEmpty(endtime))
  57. {
  58. sql += $" and F_CreateTime<'{endtime}'";
  59. }
  60. if (!string.IsNullOrEmpty(keyword))
  61. {
  62. sql += $" and F_Content like '%{keyword}%'";
  63. }
  64. DataTable datatable = Bll.PagerBll.GetListPager
  65. ("T_Wo_CommonBase ",
  66. "F_WoCode",
  67. "*,[dbo].[GetUserName](F_Proposer) F_ProposerName,[dbo].[GetUserName](F_DealUser) F_DealUserName",
  68. sql,
  69. "order by F_CreateTime desc",
  70. pagesize,
  71. pageindex,
  72. true,
  73. out recordCount
  74. );
  75. datatable = WorkOrderBase.SetOtherField(datatable, MENUENUM.我的提交,User.F_UserCode, User.F_RoleId);
  76. var obj = new
  77. {
  78. state = "success",
  79. message = "成功",
  80. rows = datatable,
  81. total = recordCount
  82. };
  83. return Content(obj.ToJson());
  84. }
  85. return Error("无操作权限!");
  86. }
  87. /// <summary>
  88. /// 综合查询
  89. /// </summary>
  90. /// <param name="keyword"></param>
  91. /// <param name="starttime"></param>
  92. /// <param name="endtime"></param>
  93. /// <param name="pageindex"></param>
  94. /// <param name="pagesize"></param>
  95. /// <param name="state"></param>
  96. /// <returns></returns>
  97. public ActionResult GetComList(int? myd, string starttime = "",string phone="", string endtime = "", string keyword = "", int pageindex = 1, int pagesize = 10, int state = -1, int type = 0, int loweltype = 0, string wocode = "", int isdc = 0)
  98. {
  99. if (User != null)
  100. {
  101. int recordCount = 0;
  102. string sql = $" and F_IsDelete = 0 and F_Status>=0 ";
  103. if (!string.IsNullOrEmpty(wocode))
  104. {
  105. sql += $" and F_WoCode like'%{wocode}%'";
  106. }
  107. if (type > 0)
  108. {
  109. sql += $" and F_Type={type}";
  110. }
  111. if (myd != null)
  112. {
  113. sql += $" and MYD={myd}";
  114. }
  115. sql += "and F_Type !=4000";
  116. if (loweltype > 0)
  117. {
  118. sql += $" and F_SonType={loweltype}";
  119. }
  120. if (state >= 0)
  121. {
  122. sql += $" and F_IsDone={state}";
  123. }
  124. if (!string.IsNullOrEmpty(starttime))
  125. {
  126. sql += $" and F_CreateTime>='{starttime}'";
  127. }
  128. if (!string.IsNullOrEmpty(endtime))
  129. {
  130. sql += $" and F_CreateTime<'{endtime}'";
  131. }
  132. if (!string.IsNullOrEmpty(keyword))
  133. {
  134. sql += $" and F_Content like '%{keyword}%'";
  135. }
  136. if (!string.IsNullOrEmpty(phone))
  137. {
  138. sql += $" and F_Phone = '{phone}'";
  139. }
  140. if (isdc > 0)
  141. {
  142. var dtdc = DbHelperSQL.Query(" select F_WoCode 工单编号,[dbo].[GetUserName](F_Proposer) 姓名, dbo.GetGongDanNameByID(F_SonType) 工单类别, F_Content 工单内容, F_Status 工单状态, (case when MYD =0 then '满意' when MYD =1 then '基本满意' when MYD =2 then '不满意' else '' end ) MYD, F_CreateTime 创建时间 from T_Wo_CommonBase "
  143. + " WITH(NOLOCK) where 1=1 " + sql + "ORDER BY F_CreateTime desc").Tables[0];
  144. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  145. if (msg == "")
  146. {
  147. return Success("导出成功");
  148. }
  149. else
  150. {
  151. return Error("导出失败");
  152. }
  153. }
  154. DataTable datatable = Bll.PagerBll.GetListPager
  155. ("T_Wo_CommonBase ",
  156. "F_WoCode",
  157. "*,[dbo].[GetUserName](F_Proposer) F_ProposerName,[dbo].[GetUserName](F_DealUser) F_DealUserName, (case when MYD =0 then '满意' when MYD =1 then '基本满意' when MYD =2 then '不满意' else '' end ) MYD ",
  158. sql,
  159. "order by F_CreateTime desc",
  160. pagesize,
  161. pageindex,
  162. true,
  163. out recordCount
  164. );
  165. datatable = WorkOrderBase.SetOtherField(datatable, MENUENUM.工单列表,User.F_UserCode, User.F_RoleId);
  166. var obj = new
  167. {
  168. state = "success",
  169. message = "成功",
  170. rows = datatable,
  171. total = recordCount
  172. };
  173. return Content(obj.ToJson());
  174. }
  175. return Error("无操作权限!");
  176. }
  177. //催单按钮 urge 类型 1是调度员催单 2 是申请人催单
  178. // 申请人:提交完工单只要工单未完成都可催单
  179. //调度人:已派单,没有完成状态能催单; 催单按钮在添加的时候 汉字写 催单
  180. public ActionResult UrgeWorkOrder(string workordercode,string reason, int urgetype = 0)
  181. {
  182. if (urgetype ==0)
  183. {
  184. return Error("需要传urgetype参数");
  185. }
  186. Model.T_Wo_CommonBase ordermodel= basebll.GetModel(workordercode);
  187. //工单类型上增加可催办次数字段,=0不允许催办,=-1不限制催办次数,
  188. //其他的 =几就是可以催办几次
  189. Model.T_Sys_GongDan gdmodel = gdbll.GetModel(ordermodel.F_SonType);
  190. if (gdmodel.F_CanUrgeCount == 0)
  191. {
  192. return Error("该工单类型不允许催办");
  193. }
  194. int nowcount = ordermodel.F_UrgeCount + 1;
  195. if (gdmodel.F_CanUrgeCount != -1 && nowcount > gdmodel.F_CanUrgeCount)
  196. {
  197. return Error("催办次数已经用光了");
  198. }
  199. ordermodel.F_UrgeCount = nowcount;
  200. ordermodel.F_UpdateTime = DateTime.Now;
  201. basebll.Update(ordermodel);
  202. string content = "催办了工单,催单原因"+reason;
  203. // string touser = "";
  204. EnumSmsType smytype = new EnumSmsType();
  205. List<string> touserlist = new List<string>();
  206. //获取调度中心值班人员
  207. // 添加日志
  208. switch (ordermodel.F_Type)
  209. {
  210. case 1000:
  211. Bll.T_Con_WorkOrder conbll = new Bll.T_Con_WorkOrder();
  212. Model.T_Con_WorkOrder conmodel= conbll.GetModelByCode(workordercode);
  213. logbll.AddLog(conmodel.F_ID, conmodel.F_State.Value, (int)conmodel.F_type1, content, (int)EnumItemType.urge, 0, User.F_UserCode, 0, User.F_UserCode);
  214. smytype = EnumSmsType.consulting;
  215. break;
  216. case 2000:
  217. SchedulingController sc = new SchedulingController();
  218. sc.AddOperatorLogNew(content, (int)EnumOperatorType.urge, workordercode,User.F_UserCode);
  219. smytype = EnumSmsType.comprehensive ;
  220. break;
  221. case 3000:
  222. FaultRepairController cc = new FaultRepairController();
  223. cc.AddOperatorLogNew(content, (int)EnumOperatorType.urge, workordercode,User.F_UserCode);
  224. smytype = EnumSmsType.repair;
  225. break;
  226. case 4000:
  227. T_Car_WorkOrderController car = new T_Car_WorkOrderController();
  228. car.AddOperation(content, User.F_UserCode, ordermodel.F_Status, workordercode, 0);
  229. smytype = EnumSmsType.car;
  230. break;
  231. }
  232. //发送消息
  233. // 点击催单给对应人发消息,如果单子在调度中心,调度中心当日值班人员都可收到消息
  234. if (urgetype == 1)
  235. {
  236. touserlist.Add(ordermodel.F_DealUser.Value.ToString());
  237. }
  238. else if (urgetype == 2)
  239. {
  240. if (ordermodel.F_Status == 0)
  241. {
  242. //调度中心当天的值班人员
  243. var GroupClass = new Bll.T_Sys_GroupClass().GetModelList("F_IsDelete=0 and datediff(day , F_Date , getdate())= 0 " +
  244. "and F_DeptId= ( select F_DeptId from T_Sys_Department where F_deptcode='ZHDDZX') order by F_Id asc");
  245. touserlist = GroupClass.Select(x => x.F_UserCode).ToList();
  246. }
  247. else
  248. {
  249. touserlist.Add(ordermodel.F_DealUser.Value.ToString());
  250. }
  251. }
  252. if (touserlist != null && touserlist.Count > 0)
  253. {
  254. foreach (var item in touserlist)
  255. {
  256. msg.AddInternalMessagesInfo("催单", "催单" + "工单编号:" + workordercode + "," + content, item, User.F_UserCode, smytype, 0, workordercode);
  257. }
  258. }
  259. return Success("成功催办");
  260. }
  261. }
  262. }