WTJLService.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. using QWPlatform.IService;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using PMS.EntityModels.Product;
  9. using System.Text.RegularExpressions;
  10. namespace PMS.DBService.Product
  11. {
  12. public class WTJLService : DataServiceBase
  13. {
  14. /// <summary>
  15. /// 获取紧急程度信息
  16. /// </summary>
  17. /// <returns></returns>
  18. public DataTable GETJJCDinfo()
  19. {
  20. string sql = "select 代码 id,显示名 紧急程度 from 基础编码 where 分类ID = 'A10D6027-DEDD-4B6D-9549-33830DE52AEA'";
  21. var dt = this.SqlBuilder.SqlText(sql).Select();
  22. return dt;
  23. }
  24. /// <summary>
  25. /// 获取渠道信息
  26. /// </summary>
  27. /// <param name="channel"></param>
  28. /// <returns></returns>
  29. public DataTable GETQDinfo(string channel)
  30. {
  31. var dt = this.ProcedureBuilder.Procedure("B_产品问题记录.P_授权渠道信息Select")
  32. .Paramter("渠道列表_in", channel)
  33. .ParamterOut("Resultlist", true);
  34. dt.Execute();
  35. return dt.ParameterValue<DataTable>("Resultlist");
  36. }
  37. /// <summary>
  38. /// 获取渠道信息(1-中联;2-中联渠道;3-客户;4-医院管理员;5-卫计委管理员)
  39. /// </summary>
  40. /// <param name="personProp">人员性质</param>
  41. /// <returns></returns>
  42. public DataTable GetChanels(int personProp, string companyid)
  43. {
  44. var sqlbuilder = this.SqlBuilder;
  45. var sql = @"Select c.Id, c.名称 From 渠道信息 c Where c.状态 = 1";
  46. if (personProp != 1)
  47. {//非中联渠道,需要根据渠道加载自己所在渠道
  48. sql += " And ID=:渠道ID";
  49. sqlbuilder.Parameters("渠道ID", companyid);
  50. }
  51. sql += " Order by c.名称 asc";
  52. return sqlbuilder.SqlText(sql)
  53. .Select();
  54. }
  55. /// <summary>
  56. /// 获取性质信息
  57. /// </summary>
  58. /// <returns></returns>
  59. public DataTable GETXZinfo()
  60. {
  61. string sql = "select 代码 id, 显示名 问题性质 from 基础编码 where 分类ID = 'AFBA7E41-A62E-4AB0-B861-40BAB5DA6F73'";
  62. var dt = this.SqlBuilder.SqlText(sql).Select();
  63. return dt;
  64. }
  65. /// <summary>
  66. /// 获取流程环节信息
  67. /// </summary>
  68. /// <returns></returns>
  69. public DataTable LCHJ()
  70. {
  71. string sql = "select ID,名称 流程环节 from 问题流程环节";
  72. var dt = this.SqlBuilder.SqlText(sql).Select();
  73. return dt;
  74. }
  75. /// <summary>
  76. /// 自定义查询方案查询
  77. /// </summary>
  78. /// <param name="model"></param>
  79. /// <param name="startNumbers"></param>
  80. /// <param name="endnumbers"></param>
  81. /// <returns></returns>
  82. public DataTable ProjectZdyCxInfoSqlBulder(WTJLModel model, int page, int rows, out int total)
  83. {
  84. string sql = @"select z.编号,
  85. z.问题标题,
  86. z.id,
  87. z.问题描述,
  88. (select 显示名
  89. from 基础编码
  90. where 分类ID =
  91. 'AFBA7E41-A62E-4AB0-B861-40BAB5DA6F73'
  92. and 代码 = z.问题性质) 性质,
  93. (select 名称
  94. from 产品系统配置
  95. where ID = z.产品ID) 产品,
  96. (CASE z.是否终止
  97.   WHEN 0 THEN
  98. (case z.是否解决 when 0 then ((select (trunc(sysdate-登记日期)*24) from 问题记录 where 是否解决=0 and id=z.id))
  99. when 1 then ((select (trunc((select max(z.记录时间) from 问题记录过程 z) -(select min(z.记录时间) from 问题记录过程 z))*24) from 问题记录 t where t.id=z.id))
  100. end)
  101.   WHEN 1 THEN ((select (trunc((select max(z.记录时间) from 问题记录过程 z)-(select min(z.记录时间) from 问题记录过程 z))*24) from 问题记录 t where t.id=z.id))
  102. end)总时间,
  103. z.版本号 版本,
  104. (select 显示名
  105. from 基础编码
  106. where 分类ID =
  107. 'A10D6027-DEDD-4B6D-9549-33830DE52AEA'
  108. and 代码 = z.紧急代码) 优先级,
  109. (select 名称 from 项目信息 where ID = z.项目ID) 项目,
  110. (select 名称 from 站点信息 where ID = z.机构ID) 机构,
  111. z.登记人 反馈人,
  112. (select 名称
  113. from 问题工作流程
  114. where ID = z.流程id) 问题环节,
  115. decode(z.是否终止,0,'正常',1,'终止')||','||decode(z.是否解决,0,'未解决',1,'已解决')是否解决
  116. from 问题记录 z where z.问题类型=1 &wheresql";
  117. // and 是否终止 = 1 and 是否解决 = 1
  118. string replacestr = string.Empty;
  119. if (!String.IsNullOrEmpty(model.XMID))
  120. {
  121. replacestr += " and 项目id= '" + model.XMID + "' ";
  122. }
  123. if (!String.IsNullOrEmpty(model.QDID))
  124. {
  125. replacestr += " and 渠道id= '" + model.QDID + "' ";
  126. }
  127. if (!String.IsNullOrEmpty(model.CPID))
  128. {
  129. replacestr += " and 产品id= '" + model.CPID + "' ";
  130. }
  131. if (!String.IsNullOrEmpty(model.JGID))
  132. {
  133. replacestr += " and 机构id= '" + model.JGID + "' ";
  134. }
  135. if (!String.IsNullOrEmpty(model.DJRID))
  136. {
  137. replacestr += " and 登记人id= '" + model.DJRID + "' ";
  138. }
  139. if (!String.IsNullOrEmpty(model.WTXZ.ToString()))
  140. {
  141. replacestr += " and 问题性质= '" + model.WTXZ + "' ";
  142. }
  143. if (!String.IsNullOrEmpty(model.JJDM))
  144. {
  145. replacestr += " and 紧急代码= '" + model.JJDM + "' ";
  146. }
  147. if (!String.IsNullOrEmpty(model.HJID.ToString()))
  148. {
  149. replacestr += " and 环节ID= '" + model.HJID + "' ";
  150. }
  151. if (!String.IsNullOrEmpty(model.GJZ))
  152. {
  153. replacestr += " and 关键字= '" + model.GJZ + "' ";
  154. }
  155. replacestr += " order by 编号 asc";
  156. if (String.IsNullOrEmpty(replacestr))
  157. {
  158. sql = sql.Replace("&wheresql", "");
  159. }
  160. else
  161. {
  162. sql = sql.Replace("&wheresql", replacestr);
  163. }
  164. return this.SqlBuilder.SqlText(sql)
  165. .Paging(page, rows)
  166. .Select(out total);
  167. }
  168. /// <summary>
  169. /// 快速查询
  170. /// </summary>
  171. /// <param name="ksCx"></param>
  172. /// <param name="StartNumbers"></param>
  173. /// <param name="Endnumbers"></param>
  174. /// <param name="total"></param>
  175. /// <returns></returns>
  176. public DataTable KsSelect(string ksCx, int StartNumbers, int Endnumbers, out int total)
  177. {
  178. string sql = @"select z.编号,
  179. z.问题标题,
  180. z.id,
  181. z.问题描述,
  182. (select 显示名
  183. from 基础编码
  184. where 分类ID =
  185. 'AFBA7E41-A62E-4AB0-B861-40BAB5DA6F73'
  186. and 代码 = z.问题性质) 性质,
  187. (select 名称
  188. from 产品系统配置
  189. where ID = z.产品ID) 产品,
  190. (CASE z.是否终止
  191.   WHEN 0 THEN
  192. (case z.是否解决 when 0 then ((select (trunc(sysdate-登记日期)*24) from 问题记录 where 是否解决=0 and id=z.id))
  193. when 1 then ((select (trunc((select max(z.记录时间) from 问题记录过程 z) -(select min(z.记录时间) from 问题记录过程 z))*24) from 问题记录 t where t.id=z.id))
  194. end)
  195.   WHEN 1 THEN ((select (trunc((select max(z.记录时间) from 问题记录过程 z)-(select min(z.记录时间) from 问题记录过程 z))*24) from 问题记录 t where t.id=z.id))
  196. end)总时间,
  197. z.版本号 版本,
  198. (select 显示名
  199. from 基础编码
  200. where 分类ID =
  201. 'A10D6027-DEDD-4B6D-9549-33830DE52AEA'
  202. and 代码 = z.紧急代码) 优先级,
  203. (select 名称 from 项目信息 where ID = z.项目ID) 项目,
  204. (select 名称 from 站点信息 where ID = z.机构ID) 机构,
  205. z.登记人 反馈人,
  206. (select 名称
  207. from 问题工作流程
  208. where ID = z.流程id) 问题环节,
  209. decode(z.是否终止,0,'正常',1,'终止')||','||decode(z.是否解决,0,'未解决',1,'已解决')是否解决
  210. from 问题记录 z where z.问题类型=1 &wheresql";
  211. string replacestr = string.Empty;
  212. bool flag = Regex.IsMatch(ksCx, @"\b\d\w*");
  213. if (flag == true)
  214. {
  215. replacestr += " and 编号= '" + ksCx + "' ";
  216. }
  217. else
  218. {
  219. replacestr += " and 标题= '" + ksCx + "' ";
  220. }
  221. if (String.IsNullOrEmpty(replacestr))
  222. {
  223. sql = sql.Replace("&wheresql", "");
  224. }
  225. else
  226. {
  227. sql = sql.Replace("&wheresql", replacestr);
  228. }
  229. return this.SqlBuilder.SqlText(sql)
  230. .Paging(StartNumbers, Endnumbers)
  231. .Select(out total);
  232. }
  233. /// <summary>
  234. /// 问题处理状态
  235. /// </summary>
  236. /// <param name="wTid"></param>
  237. /// <returns></returns>
  238. public string DealProblem(string wTid, string Xz)
  239. {
  240. var dt = this.ProcedureBuilder.Procedure("B_问题处理.P_问题处理状态_select")
  241. .Paramter("问题ID_in", wTid)
  242. .Paramter("人员性质_in", Xz)
  243. .ParamterOut("Result_out", DbType.String, 4000);
  244. dt.Execute();
  245. return dt.ParameterValue<String>("Result_out");
  246. }
  247. /// <summary>
  248. /// 获取渠道项目
  249. /// </summary>
  250. /// <param name="qdID"></param>
  251. /// <returns></returns>
  252. public DataTable QdXm(string qdID)
  253. {
  254. string sql = "select ID,名称 项目名称 from 项目信息 where 渠道ID=:渠道ID and 启用=1";
  255. return this.SqlBuilder.SqlText(sql).Parameters("渠道ID", qdID)
  256. .Select();
  257. }
  258. /// <summary>
  259. /// 客户问题查询
  260. /// </summary>
  261. /// <param name="DJRID"></param>
  262. /// <param name="page"></param>
  263. /// <param name="rows"></param>
  264. /// <param name="total"></param>
  265. /// <returns></returns>
  266. public DataTable ProjectZdyCxInfoKh(string DJRID, int page, int rows, out int total)
  267. {
  268. string sql = @"select z.编号,
  269. z.问题标题,
  270. z.id,
  271. z.问题描述,
  272. (select 显示名
  273. from 基础编码
  274. where 分类ID =
  275. 'AFBA7E41-A62E-4AB0-B861-40BAB5DA6F73'
  276. and 代码 = z.问题性质) 性质,
  277. (select 名称
  278. from 产品系统配置
  279. where ID = z.产品ID) 产品,
  280. (CASE z.是否终止
  281.   WHEN 0 THEN
  282. (case z.是否解决 when 0 then ((select (trunc(sysdate-登记日期)*24) from 问题记录 where 是否解决=0 and id=z.id))
  283. when 1 then ((select (trunc((select max(z.记录时间) from 问题记录过程 z) -(select min(z.记录时间) from 问题记录过程 z))*24) from 问题记录 t where t.id=z.id))
  284. end)
  285.   WHEN 1 THEN ((select (trunc((select max(z.记录时间) from 问题记录过程 z)-(select min(z.记录时间) from 问题记录过程 z))*24) from 问题记录 t where t.id=z.id))
  286. end)总时间,
  287. z.版本号 版本,
  288. (select 显示名
  289. from 基础编码
  290. where 分类ID =
  291. 'A10D6027-DEDD-4B6D-9549-33830DE52AEA'
  292. and 代码 = z.紧急代码) 优先级,
  293. (select 名称 from 项目信息 where ID = z.项目ID) 项目,
  294. (select 名称 from 站点信息 where ID = z.机构ID) 机构,
  295. z.登记人 反馈人,
  296. (select 名称
  297. from 问题工作流程
  298. where ID = z.流程id) 问题环节,
  299. decode(z.是否终止,0,'正常',1,'终止')||','||decode(z.是否解决,0,'未解决',1,'已解决')是否解决
  300. from 问题记录 z where z.问题类型=1 &wheresql";
  301. // and 是否终止=1 and 是否解决=1
  302. string replacestr = string.Empty;
  303. if (!String.IsNullOrEmpty(DJRID))
  304. {
  305. replacestr += " and 登记人ID='" + DJRID + "'";
  306. }
  307. replacestr += " order by 编号 asc";
  308. if (String.IsNullOrEmpty(replacestr))
  309. {
  310. sql = sql.Replace("&wheresql", "");
  311. }
  312. else
  313. {
  314. sql = sql.Replace("&wheresql", replacestr);
  315. }
  316. return this.SqlBuilder.SqlText(sql)
  317. .Paging(page, rows)
  318. .Select(out total);
  319. }
  320. /// <summary>
  321. /// 卫计委,本部,渠道人员根据渠道id查询数据权限
  322. /// </summary>
  323. /// <param name="model"></param>
  324. /// <param name="channel"></param>
  325. /// <param name="page"></param>
  326. /// <param name="rows"></param>
  327. public DataTable ProjectZdyCxInfoQKW(string channel, int page, int rows, out int total)
  328. {
  329. string sql = @"select z.编号,
  330. z.问题标题,
  331. z.id,
  332. z.问题描述,
  333. (select 显示名
  334. from 基础编码
  335. where 分类ID =
  336. 'AFBA7E41-A62E-4AB0-B861-40BAB5DA6F73'
  337. and 代码 = z.问题性质) 性质,
  338. (select 名称
  339. from 产品系统配置
  340. where ID = z.产品ID) 产品,
  341. (CASE z.是否终止
  342.   WHEN 0 THEN
  343. (case z.是否解决 when 0 then ((select (trunc(sysdate-登记日期)*24) from 问题记录 where 是否解决=0 and id=z.id))
  344. when 1 then ((select (trunc((select max(z.记录时间) from 问题记录过程 z) -(select min(z.记录时间) from 问题记录过程 z))*24) from 问题记录 t where t.id=z.id))
  345. end)
  346.   WHEN 1 THEN ((select (trunc((select max(z.记录时间) from 问题记录过程 z)-(select min(z.记录时间) from 问题记录过程 z))*24) from 问题记录 t where t.id=z.id))
  347. end)总时间,
  348. z.版本号 版本,
  349. (select 显示名
  350. from 基础编码
  351. where 分类ID =
  352. 'A10D6027-DEDD-4B6D-9549-33830DE52AEA'
  353. and 代码 = z.紧急代码) 优先级,
  354. (select 名称 from 项目信息 where ID = z.项目ID) 项目,
  355. (select 名称 from 站点信息 where ID = z.机构ID) 机构,
  356. z.登记人 反馈人,
  357. (select 名称
  358. from 问题工作流程
  359. where ID = z.流程id) 问题环节,
  360. decode(z.是否终止,0,'正常',1,'终止')||','||decode(z.是否解决,0,'未解决',1,'已解决')是否解决
  361. from 问题记录 z where z.问题类型=1 &wheresql";
  362. string replacestr = string.Empty;
  363. // and 是否终止=1 and 是否解决=1
  364. if (!String.IsNullOrEmpty(channel))
  365. {
  366. replacestr += " and 渠道ID in (select * from table(f_split_string('" + channel + "',','))) ";
  367. // and 渠道ID in (select * from table(f_split_string('4A9B2065-65AB-4411-B528-968D26737EAE',',')))
  368. }
  369. if (String.IsNullOrEmpty(replacestr))
  370. {
  371. sql = sql.Replace("&wheresql", "");
  372. }
  373. else
  374. {
  375. sql = sql.Replace("&wheresql", replacestr);
  376. }
  377. return this.SqlBuilder.SqlText(sql)
  378. .Paging(page, rows)
  379. .Select(out total);
  380. }
  381. /// <summary>
  382. /// 获取项目产品
  383. /// </summary>
  384. /// <param name="xmID"></param>
  385. /// <returns></returns>
  386. public object XmCp(string xmID)
  387. {
  388. string sql = "select ID, 名称 产品名称 from 产品系统配置 where ID in (select 产品ID from 项目产品模块 where 项目ID =:项目ID)";
  389. return this.SqlBuilder.SqlText(sql).Parameters("项目ID", xmID).Select();
  390. }
  391. /// <summary>
  392. /// 获取项目机构信息
  393. /// </summary>
  394. /// <param name="jgID"></param>
  395. /// <returns></returns>
  396. public DataTable XmJgs(string jgID)
  397. {
  398. string sql = "select ID,名称 机构名称 from 站点信息 where 项目ID=:项目ID";
  399. return this.SqlBuilder.SqlText(sql).Parameters("项目ID", jgID).Select();
  400. }
  401. /// <summary>
  402. /// 4医院管理员 自己机构(站点信息)的数据
  403. /// </summary>
  404. /// <param name="model"></param>
  405. /// <param name="page"></param>
  406. /// <param name="rows"></param>
  407. public DataTable ProjectZdyCxZd(string DJRID, int page, int rows, out int total)
  408. {
  409. string sql = @"select z.编号,
  410. z.问题标题,
  411. z.id,
  412. z.问题描述,
  413. (select 显示名
  414. from 基础编码
  415. where 分类ID =
  416. 'AFBA7E41-A62E-4AB0-B861-40BAB5DA6F73'
  417. and 代码 = z.问题性质) 性质,
  418. (select 名称
  419. from 产品系统配置
  420. where ID = z.产品ID) 产品,
  421. (CASE z.是否终止
  422.   WHEN 0 THEN
  423. (case z.是否解决 when 0 then ((select (trunc(sysdate-登记日期)*24) from 问题记录 where 是否解决=0 and id=z.id))
  424. when 1 then ((select (trunc((select max(z.记录时间) from 问题记录过程 z) -(select min(z.记录时间) from 问题记录过程 z))*24) from 问题记录 t where t.id=z.id))
  425. end)
  426.   WHEN 1 THEN ((select (trunc((select max(z.记录时间) from 问题记录过程 z)-(select min(z.记录时间) from 问题记录过程 z))*24) from 问题记录 t where t.id=z.id))
  427. end)总时间,
  428. z.版本号 版本,
  429. (select 显示名
  430. from 基础编码
  431. where 分类ID =
  432. 'A10D6027-DEDD-4B6D-9549-33830DE52AEA'
  433. and 代码 = z.紧急代码) 优先级,
  434. (select 名称 from 项目信息 where ID = z.项目ID) 项目,
  435. (select 名称 from 站点信息 where ID = z.机构ID) 机构,
  436. z.登记人 反馈人,
  437. (select 名称
  438. from 问题工作流程
  439. where ID = z.流程id) 问题环节,
  440. decode(z.是否终止,0,'正常',1,'终止')||','||decode(z.是否解决,0,'未解决',1,'已解决')是否解决
  441. from 问题记录 z where z.问题类型=1 &wheresql";
  442. // and 是否终止=1 and 是否解决=1
  443. string replacestr = string.Empty;
  444. if (!String.IsNullOrEmpty(DJRID))
  445. {
  446. replacestr += " and 机构ID=( select ID from 站点信息 where ID=(select 站点ID from 人员信息 t where ID='" + DJRID + "'))";
  447. }
  448. if (String.IsNullOrEmpty(replacestr))
  449. {
  450. sql = sql.Replace("&wheresql", "");
  451. }
  452. else
  453. {
  454. sql = sql.Replace("&wheresql", replacestr);
  455. }
  456. return this.SqlBuilder.SqlText(sql)
  457. .Paging(page, rows)
  458. .Select(out total);
  459. }
  460. }
  461. }