guide.sql.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <das-client>
  3. <Sqls>
  4. <Sql name="queryGuideEssaySbyGEIDs">
  5. SELECT * FROM Weixin_GuideEssay WHERE Status=0 @condition
  6. </Sql>
  7. <!--插入 指南-->
  8. <Sql name="insertGuide">
  9. <![CDATA[
  10. INSERT INTO
  11. Weixin_Guide(Gtid,Title,Subtitle,Status,Guid,HospitalID,DepartID,DoctorID)
  12. VALUES(?,?,?,?,?,?,?,?)
  13. ]]>
  14. </Sql>
  15. <Sql name="queryGuide">
  16. <![CDATA[
  17. Select t3.* from(
  18. Select t2.*,rownum as row_num from(
  19. Select * from Weixin_Guide a where 1=1 and a.Status=0
  20. and exists (select 1 from weixin_guanxibiao f,weixin_guideessay d
  21. where f.objtypebigid = a.gtid and d.geid = f.objtypesmallid @a) @condition
  22. )t2 where rownum <=?
  23. ) t3
  24. where t3.row_num > ? order by t3.gtid desc
  25. ]]>
  26. </Sql>
  27. <Sql name="queryGuideaStatic">
  28. <![CDATA[
  29. SELECT * from (SELECT ROW_NUMBER() OVER( order by GtID desc) rank,* FROM GuideShaoMiaoView where 1=1 @condition ) a where 1=1 @startTime @page
  30. ]]>
  31. </Sql>
  32. <Sql name="queryGuideTotal">
  33. <![CDATA[
  34. SELECT count(*) from (SELECT ROW_NUMBER() OVER( order by GtID desc) rank,b.* FROM Weixin_Guide b where 1=1 and b.Status=0
  35. and exists (select 1 from weixin_guanxibiao f,weixin_guideessay d where f.objtypebigid = b.gtid and d.geid = f.objtypesmallid @a ) @condition ) a where 1=1 and a.Status=0
  36. <!-- SELECT count(*) from (SELECT ROW_NUMBER() OVER( order by GtID desc) rowId,* FROM Weixin_Guide where 1=1 and Status=0 @condition ) as a where 1=1 and Status=0 and Title like '%"+?+"%'-->
  37. ]]>
  38. </Sql>
  39. <Sql name="queryGuideStaticTotal">
  40. <![CDATA[
  41. SELECT count(*) from (SELECT ROW_NUMBER() OVER( order by GtID desc) rank,* FROM GuideShaoMiaoView where 1=1 @condition @startTime) a where 1=1
  42. <!-- SELECT count(*) from (SELECT ROW_NUMBER() OVER( order by GtID desc) rowId,* FROM Weixin_Guide where 1=1 and Status=0 @condition ) as a where 1=1 and Status=0 and Title like '%"+?+"%'-->
  43. ]]>
  44. </Sql>
  45. <!--查询文章-->
  46. <Sql name="queryEssayByCondition">
  47. <![CDATA[
  48. Select t3.* from(
  49. Select t2.*,rownum as row_num from(
  50. Select * from Weixin_GuideEssay a where 1=1 and a.Status=0 @condition
  51. )t2 where rownum <=?
  52. ) t3
  53. where t3.row_num > ? order by t3.geid desc
  54. ]]>
  55. </Sql>
  56. <Sql name="queryEssayTotal">
  57. SELECT count(*) from (SELECT ROW_NUMBER() OVER( order by GEID desc) rank,b.* FROM Weixin_GuideEssay b where 1=1 @condition ) a where 1=1 and a.Status=0
  58. </Sql>
  59. <Sql name="queryGuideEssayTotal">
  60. <![CDATA[
  61. SELECT count(*) from (SELECT ROW_NUMBER() OVER( order by OrderID desc) rank,b.* FROM GuideEssayView b where 1=1 @condition ) a where 1=1 and Status=0 and gxStatus=0 and geStatus=0
  62. ]]>
  63. </Sql>
  64. <Sql name="queryEssayById">
  65. <![CDATA[
  66. SELECT * FROM Weixin_GuideEssay where @condition and Status=0
  67. ]]>
  68. </Sql>
  69. <Sql name="querySceneRecordVoCondition">
  70. SELECT * FROM Weixin_GuideSceneRecord where 1=1 @condition and Status=0
  71. </Sql>
  72. <Sql name="queryGuideEssayById">
  73. <!-- SELECT * FROM GuideEssayView where @condition-->
  74. <![CDATA[
  75. Select t3.* from(
  76. Select t2.*,rownum as row_num from(
  77. Select * from GuideEssayView a where 1=1 @condition and a.Status=0 and a.gxStatus=0 and a.geStatus=0
  78. order by a.OrderID asc
  79. )t2 where rownum <=?
  80. ) t3
  81. where t3.row_num > ?
  82. ]]>
  83. </Sql>
  84. <!--插入 文章-->
  85. <Sql name="insertEssay">
  86. <![CDATA[
  87. INSERT INTO
  88. Weixin_GuideEssay(GEID,Title,TypeID,Status,ImgUrl,BigImgUrl,LinkUrl,GeContent,ResId,ResUid,OwnerHospital,TypeClass)
  89. VALUES(?,?,?,?,?,?,?,?,?,?,?,?)
  90. ]]>
  91. </Sql>
  92. <!--修改文章-->
  93. <Sql name="updateEssayById">
  94. UPDATE Weixin_GuideEssay SET @condition,Title=?,ImgUrl=?,LinkUrl=?,BigImgUrl=?,GeContent=?,Lastmodify=?,TypeClass=? WHERE GEID = ?
  95. </Sql>
  96. <!-- 删除 文章-->
  97. <Sql name="deleteEssayById">
  98. UPDATE Weixin_GuideEssay SET @condition WHERE GEID = ?
  99. </Sql>
  100. <!--修改指南-->
  101. <Sql name="updateGuideById">
  102. UPDATE Weixin_Guide SET Title=?,Subtitle=?,HospitalID=?,DepartID=?,DoctorID=?,Status=?,Guid=? WHERE GtID = ?
  103. </Sql>
  104. <!-- 删除 指南-->
  105. <Sql name="deleteGuideById">
  106. UPDATE Weixin_Guide SET @condition WHERE GtID = ?
  107. </Sql>
  108. <!--场景值记录-->
  109. <Sql name="insertSceneRecordVo">
  110. INSERT Weixin_GuideSceneRecord( ServiceType ,GuideID ,SceneID,MaterialID ,Status )VALUES ( ? , ? ,? , ?,?)
  111. </Sql>
  112. <!--修改场景值状态-->
  113. <Sql name="updateSceneRecordStatus">
  114. UPDATE Weixin_GuideSceneRecord SET Status=? WHERE SceneID=?
  115. </Sql>
  116. <!--修改关系 -->
  117. <Sql name="updateGuanXi">
  118. UPDATE Weixin_GuanXiBiao SET OrderID=? WHERE ObjTypeSmallID = ? and ObjTypeBigID=?
  119. </Sql>
  120. <!-- 删除 关系-->
  121. <Sql name="deleteGuanXiById">
  122. UPDATE Weixin_GuanXiBiao SET @condition WHERE ObjTypeBigID = ? and ObjTypeSmallID=?
  123. </Sql>
  124. <!-- 删除 关系-->
  125. <Sql name="deleteGuanXiByBId">
  126. UPDATE Weixin_GuanXiBiao SET @condition WHERE ObjTypeBigID = ?
  127. </Sql>
  128. <Sql name="deleteGuanXiByGuid">
  129. UPDATE Weixin_GuanXiBiao SET Status=1 WHERE ObjTypeBigID = ?
  130. </Sql>
  131. <!--新增 关系-->
  132. <Sql name="insertGuanXi">
  133. INSERT INTO
  134. Weixin_GuanXiBiao(GXBID,ObjType,ObjTypeBigID,ObjTypeSmallID,OrderID,Status)
  135. VALUES(?,?,?,?,?,?)
  136. </Sql>
  137. <Sql name="queryGuanXiBiao">
  138. SELECT * FROM Weixin_GuanXiBiao where @condition and Status=0
  139. </Sql>
  140. <Sql name="queryGuideById">
  141. SELECT * FROM Weixin_Guide where @condition and Status=0
  142. </Sql>
  143. <!--插入扫苗-->
  144. <Sql name="insertShaoMiao">
  145. INSERT INTO
  146. Weixin_ShaoMiao(LoginID,LoginType,IsFirst,SceneID,WlName,Wlid,ServiceType,GID,HospitalID,DepartID,DoctorID,Nickname)
  147. VALUES(?,?,?,?,?,?,?,?,?,?,?,?)
  148. </Sql>
  149. <Sql name="queryMaterial">
  150. SELECT * FROM Weixin_Material where 1=1 and Status=0
  151. </Sql>
  152. <Sql name="queryMaterialById">
  153. SELECT * FROM Weixin_Material where @condition and Status=0
  154. </Sql>
  155. <Sql name="queryShaoMiao">
  156. select * from
  157. (
  158. select top 10000 a.[HospitalID],b.[HosName],[ProvinceName],[ProvinceID],[CityName],[CityID],count(1) as col FROM [Guide].[dbo].[Weixin_ShaoMiao]
  159. a left join [10.0.200.7].[BaseInfo].[dbo].[B_Hospital] b on a.[HospitalID]= cast(b.[HospitalID] as varchar(20)) where 1=1 @Wlid
  160. @startTime and [IsFirst]=0
  161. group by a.[HospitalID],[ProvinceName],[ProvinceID],b.[HosName],[CityName],[CityID]
  162. ) xx where 1=1 @condition order by col desc
  163. </Sql>
  164. <Sql name="queryProvice">
  165. SELECT c.ProvinceID,c.ProvinceName
  166. ,count(1) as col
  167. FROM [Guide].[dbo].[Weixin_GuideSceneRecord] a ,[Guide].[dbo].[Weixin_Guide] b ,[10.0.200.7].[BaseInfo].[dbo].[B_Hospital] c
  168. where a.GuideID=b.GtID and a.Status=0 and b.Status=0 and b.HospitalID=cast (c.[HospitalID] as varchar(20))
  169. group by c.ProvinceID,c.ProvinceName
  170. </Sql>
  171. <Sql name="queryCity">
  172. SELECT c.ProvinceID,c.ProvinceName,c.CityID,c.CityName
  173. ,count(1) as col
  174. FROM [Guide].[dbo].[Weixin_GuideSceneRecord] a ,[Guide].[dbo].[Weixin_Guide] b ,[10.0.200.7].[BaseInfo].[dbo].[B_Hospital] c
  175. where a.GuideID=b.GtID and a.Status=0 and b.Status=0 and b.HospitalID=cast (c.[HospitalID] as varchar(20)) and c.ProvinceID=?
  176. group by c.ProvinceID,c.ProvinceName,c.CityID,c.CityName
  177. </Sql>
  178. <Sql name="queryHospital">
  179. SELECT c.ProvinceID,c.ProvinceName,c.CityID,c.CityName,c.HosName,b.HospitalID
  180. ,count(1) as col
  181. FROM [Guide].[dbo].[Weixin_GuideSceneRecord] a ,[Guide].[dbo].[Weixin_Guide] b ,[10.0.200.7].[BaseInfo].[dbo].[B_Hospital] c
  182. where a.GuideID=b.GtID and a.Status=0 and b.Status=0 and b.HospitalID=cast (c.[HospitalID] as varchar(20)) and 1=1 @condition
  183. group by c.ProvinceID,c.ProvinceName,c.CityID,c.CityName,c.HosName,b.HospitalID
  184. </Sql>
  185. <Sql name="SceneByConditon">
  186. SELECT * from (SELECT ROW_NUMBER() OVER( order by ProvinceID desc) rowId,* FROM SceneProviceCityVoView where 1=1 and Status=0 @condition ) as a where 1=1 and Status=0 @page
  187. </Sql>
  188. <Sql name="getSceneByConditonToal">
  189. SELECT count(*) FROM SceneProviceCityVoView where 1=1 @condition and Status=0
  190. </Sql>
  191. <Sql name="queryGuideStaticTotal2">
  192. SELECT count(*) FROM [Weixin_ShaoMiao] where 1=1 @condition @startTime @endTime
  193. <!-- SELECT count(*) from (SELECT ROW_NUMBER() OVER( order by GtID desc) rowId,* FROM Weixin_Guide where 1=1 and Status=0 @condition ) as a where 1=1 and Status=0 and Title like '%"+?+"%'-->
  194. </Sql>
  195. <Sql name="queryGuideStaticTotalList">
  196. SELECT GID,COUNT(GID) as col FROM [Weixin_ShaoMiao] where 1=1 @condition @startTime @endTime GROUP BY GID;
  197. </Sql>
  198. <Sql name="queryGuideTj">
  199. SELECT * FROM ( SELECT ROW_NUMBER() OVER( order by col desc) rank, c.GtID,c.Title,c.Subtitle,c.HospitalID,c.DepartID,c.DoctorID,d.col,d.col1 FROM dbo.Weixin_Guide c JOIN
  200. (SELECT sum(case when isfirst=0 then 1 else 0 end) col,
  201. count(0) col1,
  202. a.GtID
  203. FROM dbo.Weixin_Guide a JOIN dbo.Weixin_ShaoMiao b ON a.GtID=b.GID
  204. WHERE a.Status=0 @condition GROUP BY a.GtID) d ON c.GtID=d.GtID) e WHERE 1=1 @page
  205. </Sql>
  206. <Sql name="queryGuideStaticTotal3">
  207. SELECT count(*) FROM [Weixin_ShaoMiao] where IsFirst=0 and 1=1 @condition @startTime @endTime
  208. <!-- SELECT count(*) from (SELECT ROW_NUMBER() OVER( order by GtID desc) rowId,* FROM Weixin_Guide where 1=1 and Status=0 @condition ) as a where 1=1 and Status=0 and Title like '%"+?+"%'-->
  209. </Sql>
  210. <Sql name="importGuide">
  211. <![CDATA[
  212. SELECT * FROM [Guide].[dbo].[Weixin_Guide] where Status=0
  213. ]]>
  214. </Sql>
  215. <Sql name="pushShaoMiao">
  216. SELECT LoginID,HospitalID from (SELECT ROW_NUMBER() OVER( order by [HospitalID] desc) rank,LoginID,HospitalID FROM Weixin_ShaoMiao where 1=1 @condition @startTime group by [LoginID] ,[HospitalID] ) as a where 1=1 @page
  217. </Sql>
  218. <Sql name="insertGuideStaic">
  219. INSERT INTO
  220. GuideStatic( ProvinceID ,CityID,HospitalID,ProvinceName,HosName ,CityName,ScanNumber,WatchNumber,Time,Status)
  221. VALUES(?,?,?,?,?,?,?,?,?,?)
  222. </Sql>
  223. <Sql name="queryShaoMiao1">
  224. select
  225. a.[HospitalID],b.[HosName],[ProvinceName],[ProvinceID],[CityName],[CityID], count(a.smid) as col ,
  226. (select count(v.smid) from [Guide].[dbo].[Weixin_ShaoMiao] v where v.hospitalid = a.[HospitalID] and 1=1 @condition @startTime ) AllCol
  227. FROM [Guide].[dbo].[Weixin_ShaoMiao] a
  228. left join
  229. [10.0.200.7].[BaseInfo].[dbo].[B_Hospital] b
  230. on a.[HospitalID]=cast (b.[HospitalID] as varchar(20))
  231. where 1=1 @condition @startTime and [IsFirst]=0
  232. group by a.[HospitalID],[ProvinceName],[ProvinceID],
  233. b.[HosName],[CityName],[CityID] order by col desc
  234. </Sql>
  235. <Sql name="queryNewShaoMiao">
  236. SELECT * from GuideStatic where 1=1 @condition @startTime order by Time desc
  237. </Sql>
  238. <Sql name="queryNewGuide">
  239. select * from [Guide].[dbo].[GuideRep] a
  240. inner join [Guide].dbo.Weixin_Guide b on a.gid= b.gtid @condition
  241. @startTime
  242. </Sql>
  243. <Sql name="pushDoctorShaoMiao">
  244. <!-- SELECT [LoginID],[doctorUid],[hosId],[hosName],[doctorName] from (SELECT ROW_NUMBER() OVER( order by [hosId] desc) rowId,[LoginID],[hosId] ,[doctorUid] ,[hosName],[doctorName] FROM [WeiXin_Doctor_SaoMiao] where 1=1 @condition @startTime group by [LoginID] ,[doctorUid],[hosId],[hosName],[doctorName] ) as a where 1=1 @page -->
  245. SELECT [LoginID],[doctorUid],[hosId],[hosName],[doctorName] from
  246. (
  247. select ROW_NUMBER() OVER( order by [hosId] desc) rowId,[LoginID],[hosId]
  248. ,[doctorUid] ,[hosName],[doctorName]
  249. from (
  250. SELECT [LoginID],[hosId] ,[doctorUid] ,[hosName],[doctorName]
  251. FROM [WeiXin_Doctor_SaoMiao] where 1=1 @condition @startTime group by
  252. [LoginID] ,[doctorUid],[hosId],[hosName],[doctorName]
  253. union
  254. SELECT [LoginID],[hosId] ,[doctorUid] ,[hosName],[doctorName]
  255. FROM [WeiXin_Doctor_ShouCang] where 1=1 @condition @startTime group by
  256. [LoginID] ,[doctorUid],[hosId],[hosName],[doctorName])
  257. as b
  258. )
  259. as a where 1=1 @page
  260. </Sql>
  261. <Sql name="queryShaoMiaoDay">
  262. select hospitalid ,count(hospitalid) as total from [Guide].[dbo].Weixin_ShaoMiao
  263. where isfirst=0 group by hospitalid having count(hospitalid)>30
  264. </Sql>
  265. <Sql name="queryGuideReport">
  266. select xx.*,yy.col2 from
  267. (
  268. select top 10000 a.[Wlid],a.[HospitalID],b.[HosName],[ProvinceName],[ProvinceID],[CityName],[CityID],count(1) as col FROM [Guide].[dbo].[Weixin_ShaoMiao]
  269. a left join [10.0.200.7].[BaseInfo].[dbo].[B_Hospital] b on a.[HospitalID]= cast(b.[HospitalID] as varchar(20)) where 1=1
  270. and [IsFirst]=0 @startTime
  271. group by a.[HospitalID],[ProvinceName],[ProvinceID],b.[HosName],[CityName],[CityID] , a.[Wlid]
  272. ) xx left join (
  273. SELECT provinceName ,provinceId,cityId,cityName,hosName,hosId,2 as [Wlid],count(1) as col2
  274. FROM [Guide].[dbo].[WeiXin_Doctor_SaoMiao] where isfirst=0 @doctorTime
  275. group by provinceName ,provinceId,cityId,cityName,hosName ,hosId
  276. ) yy
  277. on xx.[HospitalID]=yy.hosId
  278. where xx.wlid=2
  279. union
  280. select top 10000 a.[Wlid],a.[HospitalID],b.[HosName],[ProvinceName],[ProvinceID],[CityName],[CityID],count(1) as col
  281. , NULL as col2 FROM [Guide].[dbo].[Weixin_ShaoMiao]
  282. a left join [10.0.200.7].[BaseInfo].[dbo].[B_Hospital] b on a.[HospitalID]= cast(b.[HospitalID] as varchar(20)) where 1=1
  283. and [IsFirst]=0 and a.wlid!=2 @startTime
  284. group by a.[HospitalID],[ProvinceName],[ProvinceID],b.[HosName],[CityName],[CityID] , a.[Wlid]
  285. </Sql>
  286. <Sql name="insertGuideReport">
  287. INSERT INTO [Guide].[dbo].[GuideReport]
  288. ([Wlid],[HospitalID]
  289. ,[HosName]
  290. ,[ProvinceName]
  291. ,[ProvinceID]
  292. ,[CityName]
  293. ,[CityID]
  294. ,[col]
  295. ,[col2]
  296. ,[CreateTime])
  297. VALUES (?,?,?,?,?,?,?,?,?,?)
  298. </Sql>
  299. <Sql name="queryDoctorGuideReport">
  300. SELECT provinceName ,provinceId,cityId,cityName,hosName,hosId,count(1) as col2
  301. FROM [Guide].[dbo].[WeiXin_Doctor_SaoMiao]
  302. where hosid not in (select HospitalID from [Guide].[dbo].[Weixin_ShaoMiao] where isfirst=0
  303. @startTime
  304. group by HospitalID)
  305. and isfirst=0 @doctorTime
  306. group by provinceName ,provinceId,cityId,cityName,hosName ,hosId
  307. </Sql>
  308. <Sql name="updateShaoMiao">
  309. UPDATE [Guide].[dbo].[Weixin_ShaoMiao] SET
  310. isfirst=?
  311. WHERE 1=1 and LoginID =?
  312. </Sql>
  313. <Sql name="queryGuideReport1">
  314. SELECT
  315. [HospitalID]
  316. ,[HosName]
  317. ,[ProvinceName]
  318. ,[ProvinceID]
  319. ,[CityName]
  320. ,[CityID]
  321. ,sum(col) as col
  322. ,sum(col2) as col2
  323. FROM [Guide].[dbo].[GuideReport] where 1=1 @condition @startTime group by [HospitalID],[HosName],[ProvinceName] ,[ProvinceID],[CityName],[CityID] order by col desc
  324. </Sql>
  325. <Sql name="queryGuideReport2ForPage1">
  326. select * from(SELECT ROW_NUMBER() OVER( order by @orderCol desc) rowId, * FROM( SELECT
  327. [HospitalID]
  328. ,[HosName]
  329. ,[ProvinceName]
  330. ,[ProvinceID]
  331. ,[CityName]
  332. ,[CityID]
  333. ,sum(col) as col
  334. ,sum(col2) as col2
  335. FROM [Guide].[dbo].[GuideReport] where 1=1 @condition @startTime group by [HospitalID],[HosName],[ProvinceName] ,[ProvinceID],[CityName],[CityID] ) AS a where 1=1) as b where 1=1 @page
  336. </Sql>
  337. <Sql name="queryGuideReport2">
  338. SELECT [Wlid]
  339. ,[HospitalID]
  340. ,[HosName]
  341. ,[ProvinceName]
  342. ,[ProvinceID]
  343. ,[CityName]
  344. ,[CityID]
  345. ,sum(col) as col
  346. ,sum(col2) as col2
  347. FROM [Guide].[dbo].[GuideReport] where 1=1 @condition @startTime group by [Wlid] ,[HospitalID],[HosName],[ProvinceName] ,[ProvinceID],[CityName],[CityID] order by col desc
  348. </Sql>
  349. <Sql name="queryGuideReport2ForPage2">
  350. select * from(SELECT ROW_NUMBER() OVER( order by @orderCol desc) rowId, * FROM( SELECT [Wlid]
  351. ,[HospitalID]
  352. ,[HosName]
  353. ,[ProvinceName]
  354. ,[ProvinceID]
  355. ,[CityName]
  356. ,[CityID]
  357. ,sum(col) as col
  358. ,sum(col2) as col2
  359. FROM [Guide].[dbo].[GuideReport] where 1=1 @condition @startTime group by [Wlid] ,[HospitalID],[HosName],[ProvinceName] ,[ProvinceID],[CityName],[CityID] ) AS a where 1=1) as b where 1=1 @page
  360. </Sql>
  361. <!-- <Sql name="queryHosDetail">-->
  362. <!-- select xx.gid as gtid,xx.hospitalid,xx.title,sum(xx.col) as col from (-->
  363. <!---->
  364. <!--SELECT [GID] ,a.[HospitalID],b.[Title] ,count(*) as col-->
  365. <!-- FROM [Guide].[dbo].[Weixin_ShaoMiao_Log] a left join [Guide].[dbo].[Weixin_Guide] b-->
  366. <!-- on a.gid= b.GtID where isfirst=0 @condition @startTime group by [GID],a.[HospitalID] ,b.[Title]-->
  367. <!---->
  368. <!-- union all-->
  369. <!-- -->
  370. <!-- SELECT [GID] ,a.[HospitalID],b.[Title] ,count(*) as col-->
  371. <!-- FROM [Guide].[dbo].[Weixin_ShaoMiao] a left join [Guide].[dbo].[Weixin_Guide] b-->
  372. <!-- on a.gid= b.GtID where isfirst=0 @condition @startTime and datediff(day,a.createon,getdate())=0 -->
  373. <!-- group by [GID],a.[HospitalID] ,b.[Title]) as xx group by xx.gid,xx.hospitalid,xx.title-->
  374. <!-- -->
  375. <!-- -->
  376. <!-- </Sql>-->
  377. <Sql name="queryHosDetail">
  378. SELECT a.[GID] as GtID ,a.[HospitalID],b.[Title] ,count(0)-sum(isfirst) as col,
  379. sum(case when isfirst=0 then 1 else 0 end) as col1
  380. FROM [Guide].[dbo].[Weixin_ShaoMiao] a left join [Guide].[dbo].[Weixin_Guide] b
  381. on a.gid= b.GtID where 1=1 @condition @startTime
  382. group by [GID],a.[HospitalID] ,b.[Title] order by col desc
  383. </Sql>
  384. <Sql name="queryHosDetailForPage">
  385. select * from ( SELECT ROW_NUMBER() OVER( order by col desc) rowId ,* from ( SELECT a.[GID] as GtID ,a.[HospitalID],b.[Title] ,count(0)-sum(isfirst) as col,
  386. sum(case when isfirst=0 then 1 else 0 end) as col1
  387. FROM [Guide].[dbo].[Weixin_ShaoMiao] a left join [Guide].[dbo].[Weixin_Guide] b
  388. on a.gid= b.GtID where 1=1 @condition @startTime
  389. group by [GID],a.[HospitalID] ,b.[Title] ) as a where 1=1) as c where 1=1 @page
  390. </Sql>
  391. <Sql name="queryHoswater">
  392. select * FROM [Guide].[dbo].[Weixin_ShaoMiao] where 1=1 @condition @startTime order by createon desc
  393. </Sql>
  394. <Sql name="queryHoswaterForPage">
  395. SELECT * FROM (SELECT ROW_NUMBER() OVER( order by createon desc) rowId, * FROM (select * FROM [Guide].[dbo].[Weixin_ShaoMiao] where 1=1 @condition @startTime ) as a where 1=1) as b where 1=1 @page
  396. </Sql>
  397. <Sql name="queryDocwater">
  398. select * FROM [Guide].[dbo].[WeiXin_Doctor_SaoMiao] where 1=1 @condition @startTime order by createtime desc
  399. </Sql>
  400. <Sql name="queryDocwaterForPage">
  401. SELECT * FROM (SELECT ROW_NUMBER() OVER( order by createtime desc) rowId, * FROM ( select * FROM [Guide].[dbo].[WeiXin_Doctor_SaoMiao] where 1=1 @condition @startTime ) as a where 1=1 ) as b where 1=1 @page
  402. </Sql>
  403. <!-- <Sql name="querySaoMiaoHis">-->
  404. <!-- -->
  405. <!-- select * from (-->
  406. <!-- select top 50 d.[hosname],d.[doctorName] as title ,d.createtime,d.loginId ,d.isfirst -->
  407. <!-- from [Guide].[dbo].[WeiXin_Doctor_SaoMiao] d where 1=1 @condition-->
  408. <!-- union all-->
  409. <!-- select top 50 x.hosname,n.title ,m.createon as createtime,loginId,m.isfirst from -->
  410. <!-- [Guide].[dbo].[Weixin_ShaoMiao] m-->
  411. <!-- ,[Guide].[dbo].[Weixin_Guide] n,-->
  412. <!-- [10.0.200.7].BaseInfo.[dbo].[B_Hospital] x-->
  413. <!-- where m.[HospitalID]=x.[HospitalID] and m.[GID]=n.gtid-->
  414. <!-- @condition-->
  415. <!-- ) h-->
  416. <!-- -->
  417. <!-- </Sql>-->
  418. <Sql name="querySaoMiaoHis">
  419. if exists (select 1 from WeiXin_Doctor_SaoMiao where loginid=@condition)
  420. begin
  421. select top 1 '该用户在' + convert(char(23), createTime, 121) + ' 关注过【'+hosName+'】'+doctorName +'医生的信息点' as title
  422. from WeiXin_Doctor_SaoMiao where loginid=@condition order by createTime
  423. end else
  424. begin
  425. select top 1 '该用户在' + convert(char(23), CreateON, 121) + '关注过【'+b.hosName+'】的信息点' as title
  426. from Weixin_ShaoMiao as a, [10.0.200.7].[BaseInfo].[dbo].[B_Hospital] as b
  427. where a.loginid=@condition and a.hospitalId=b.hospitalId
  428. order by CreateON
  429. end
  430. </Sql>
  431. <!-- 判断是否首次扫描-->
  432. <Sql name="queryShaoMiaoIsFirst">
  433. select loginId as col from WeiXin_Doctor_SaoMiao where 1=1 and @condition
  434. union all
  435. select loginId as col from [Guide].[dbo].[WeiXin_ShaoMiao]
  436. where 1=1 and @condition
  437. </Sql>
  438. <!-- 判断医生 是否扫描-->
  439. <Sql name="queryDoctorSaoMiaoIsFirst">
  440. select loginId as col from WeiXin_Doctor_SaoMiao where 1=1 and @condition
  441. </Sql>
  442. <Sql name="queryGuideEassylist">
  443. select @pageSize * from (
  444. select [GEID] ,[Title] ,[TypeID] ,[LinkUrl] ,[ResId],[ResUid] ,[CreateON]
  445. from [dbo].[Weixin_GuideEssay] n where n.status=0 @condition
  446. union all
  447. select [GEID] ,[Title] ,[TypeID] ,[LinkUrl] ,[ResId],[ResUid] ,[Lastmodify] as[CreateON]
  448. from [dbo].[Weixin_GuideEssay] m where m.status=0 @condition1) h
  449. group by h.geid,h.title,h.typeid,h.linkurl,h.resid,h.resuid,h.createon
  450. order by h.createon desc
  451. </Sql>
  452. <Sql name="queryWuLiaoByLoginId">
  453. select top 1 * from [Weixin_ShaoMiao] m where 1=1 @condition order by createon desc
  454. </Sql>
  455. <!--查询省份统计 -->
  456. <Sql name="queryProvinceCount">
  457. select m.provinceid,n.provincename,(sum(col)+ sum(col2)) as col,
  458. (select count(*) from (
  459. select h.hospitalid ,h.provinceid FROM [Guide].[dbo].[GuideReport] h
  460. where 1=1 @startTime
  461. group by h.hospitalid ,h.provinceid
  462. ) dd where dd.provinceid=m.provinceid ) as col2
  463. from [Guide].[dbo].[GuideReport] m,
  464. [10.0.200.7].baseinfo.dbo.BASE_PROVINCE n
  465. where m.provinceid=n.provinceid @condition @startTime
  466. group by m.provinceid ,n.provincename order by m.provinceid
  467. </Sql>
  468. <Sql name="queryWuLiaoByLoginIdFirst">
  469. select * from (
  470. select top 1 loginid ,createon FROM [Guide].[dbo].[Weixin_ShaoMiao]
  471. where 1=1 @condition order by createon desc ) aa
  472. where aa.createon>(
  473. select top 1 createtime FROM [Guide].[dbo].[WeiXin_Doctor_SaoMiao] where
  474. 1=1 @condition order by createtime desc)
  475. </Sql>
  476. <Sql name="getSequence">
  477. select @p as num from dual
  478. </Sql>
  479. <Sql name="updateSequence">
  480. update SEQUENCE set current_val = (current_val+increment_val) where seq_name = ?
  481. </Sql>
  482. <Sql name="getMySqlSequence">
  483. select current_val from SEQUENCE where seq_name = ?
  484. </Sql>
  485. <Sql name="queryArticleListByClass">
  486. <![CDATA[
  487. Select t3.* from(
  488. Select t2.*,rownum as row_num from(
  489. Select a.* from Weixin_GuideEssay a @condition
  490. )t2 where rownum <=?
  491. ) t3
  492. where t3.row_num > ?
  493. ]]>
  494. </Sql>
  495. <Sql name="queryArticleListByClassTotal">
  496. Select count(1) from Weixin_GuideEssay a @condition
  497. </Sql>
  498. <Sql name="getSequence">
  499. select @p as num from dual
  500. </Sql>
  501. <Sql name="updateListEssay">
  502. UPDATE Weixin_GuideEssay SET @condition
  503. </Sql>
  504. <Sql name="getNewsIdByGuidId">
  505. select b.objtypesmallid id from weixin_guide a,weixin_guanxibiao b where b.objtypebigid = a.gtid and @a
  506. </Sql>
  507. <Sql name="updateStatus">
  508. update WEIXIN_GUIDEESSAY t set t.isadd = 0 where @a
  509. </Sql>
  510. </Sqls>
  511. </das-client>