PublicReleaseMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.goafanti.common.dao.PublicReleaseMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.PublicRelease">
  5. <id column="id" jdbcType="INTEGER" property="id" />
  6. <result column="uid" jdbcType="VARCHAR" property="uid" />
  7. <result column="aid" jdbcType="VARCHAR" property="aid" />
  8. <result column="release_start" jdbcType="TIMESTAMP" property="releaseStart" />
  9. <result column="release_end" jdbcType="TIMESTAMP" property="releaseEnd" />
  10. <result column="remarks" jdbcType="VARCHAR" property="remarks" />
  11. <result column="annex_url" jdbcType="VARCHAR" property="annexUrl" />
  12. <result column="user_name" jdbcType="VARCHAR" property="userName" />
  13. <result column="longitude" jdbcType="VARCHAR" property="longitude" />
  14. <result column="latitude" jdbcType="VARCHAR" property="latitude" />
  15. <result column="status" jdbcType="INTEGER" property="status" />
  16. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  17. <result column="clock_in" jdbcType="INTEGER" property="clockIn" />
  18. <result column="clock_in_time" jdbcType="TIMESTAMP" property="clockInTime" />
  19. <result column="photo_url" jdbcType="VARCHAR" property="photoUrl" />
  20. <result column="pid" jdbcType="VARCHAR" property="pid" />
  21. <result column="pname" jdbcType="VARCHAR" property="pname" />
  22. <result column="ufid" jdbcType="VARCHAR" property="ufid" />
  23. <result column="duration" jdbcType="DOUBLE" property="duration" />
  24. <result column="valid_date" jdbcType="VARCHAR" property="validDate" />
  25. <result column="new_user" jdbcType="INTEGER" property="newUser" />
  26. <result column="sign_sum" jdbcType="INTEGER" property="signSum" />
  27. <result column="main_status" jdbcType="INTEGER" property="mainStatus" />
  28. <result column="supplement" jdbcType="VARCHAR" property="supplement" />
  29. <result column="audit_info" jdbcType="VARCHAR" property="auditInfo" />
  30. <result column="plan" jdbcType="VARCHAR" property="plan" />
  31. <result column="expected_effect" jdbcType="VARCHAR" property="expectedEffect" />
  32. <result column="next_plan" jdbcType="VARCHAR" property="nextPlan" />
  33. <result column="type" jdbcType="INTEGER" property="type" />
  34. <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
  35. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  36. <result column="update_status" jdbcType="INTEGER" property="updateStatus" />
  37. </resultMap>
  38. <sql id="Base_Column_List">
  39. id, `uid`, aid, release_start, release_end, remarks, annex_url, user_name, longitude,
  40. latitude, `status`, create_time, clock_in, clock_in_time, photo_url, pid, pname,
  41. ufid, duration, valid_date, new_user, sign_sum, main_status, supplement, audit_info,
  42. `plan`, expected_effect, next_plan, `type`, order_no, update_time, update_status
  43. </sql>
  44. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  45. select
  46. <include refid="Base_Column_List" />
  47. from public_release
  48. where id = #{id,jdbcType=INTEGER}
  49. </select>
  50. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  51. delete from public_release
  52. where id = #{id,jdbcType=INTEGER}
  53. </delete>
  54. <insert id="insert" parameterType="com.goafanti.common.model.PublicRelease">
  55. insert into public_release (id, `uid`, aid,
  56. release_start, release_end, remarks,
  57. annex_url, user_name, longitude,
  58. latitude, `status`, create_time,
  59. clock_in, clock_in_time, photo_url,
  60. pid, pname, ufid, duration,
  61. valid_date, new_user, sign_sum,
  62. main_status, supplement, audit_info,
  63. `plan`, expected_effect, next_plan,
  64. `type`, order_no, update_time,
  65. update_status)
  66. values (#{id,jdbcType=INTEGER}, #{uid,jdbcType=VARCHAR}, #{aid,jdbcType=VARCHAR},
  67. #{releaseStart,jdbcType=TIMESTAMP}, #{releaseEnd,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR},
  68. #{annexUrl,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR}, #{longitude,jdbcType=VARCHAR},
  69. #{latitude,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
  70. #{clockIn,jdbcType=INTEGER}, #{clockInTime,jdbcType=TIMESTAMP}, #{photoUrl,jdbcType=VARCHAR},
  71. #{pid,jdbcType=VARCHAR}, #{pname,jdbcType=VARCHAR}, #{ufid,jdbcType=VARCHAR}, #{duration,jdbcType=DOUBLE},
  72. #{validDate,jdbcType=VARCHAR}, #{newUser,jdbcType=INTEGER}, #{signSum,jdbcType=INTEGER},
  73. #{mainStatus,jdbcType=INTEGER}, #{supplement,jdbcType=VARCHAR}, #{auditInfo,jdbcType=VARCHAR},
  74. #{plan,jdbcType=VARCHAR}, #{expectedEffect,jdbcType=VARCHAR}, #{nextPlan,jdbcType=VARCHAR},
  75. #{type,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
  76. #{updateStatus,jdbcType=INTEGER})
  77. </insert>
  78. <insert id="insertSelective" parameterType="com.goafanti.common.model.PublicRelease">
  79. insert into public_release
  80. <trim prefix="(" suffix=")" suffixOverrides=",">
  81. <if test="id != null">
  82. id,
  83. </if>
  84. <if test="uid != null">
  85. `uid`,
  86. </if>
  87. <if test="aid != null">
  88. aid,
  89. </if>
  90. <if test="releaseStart != null">
  91. release_start,
  92. </if>
  93. <if test="releaseEnd != null">
  94. release_end,
  95. </if>
  96. <if test="remarks != null">
  97. remarks,
  98. </if>
  99. <if test="annexUrl != null">
  100. annex_url,
  101. </if>
  102. <if test="userName != null">
  103. user_name,
  104. </if>
  105. <if test="longitude != null">
  106. longitude,
  107. </if>
  108. <if test="latitude != null">
  109. latitude,
  110. </if>
  111. <if test="status != null">
  112. `status`,
  113. </if>
  114. <if test="createTime != null">
  115. create_time,
  116. </if>
  117. <if test="clockIn != null">
  118. clock_in,
  119. </if>
  120. <if test="clockInTime != null">
  121. clock_in_time,
  122. </if>
  123. <if test="photoUrl != null">
  124. photo_url,
  125. </if>
  126. <if test="pid != null">
  127. pid,
  128. </if>
  129. <if test="pname != null">
  130. pname,
  131. </if>
  132. <if test="ufid != null">
  133. ufid,
  134. </if>
  135. <if test="duration != null">
  136. duration,
  137. </if>
  138. <if test="validDate != null">
  139. valid_date,
  140. </if>
  141. <if test="newUser != null">
  142. new_user,
  143. </if>
  144. <if test="signSum != null">
  145. sign_sum,
  146. </if>
  147. <if test="mainStatus != null">
  148. main_status,
  149. </if>
  150. <if test="supplement != null">
  151. supplement,
  152. </if>
  153. <if test="auditInfo != null">
  154. audit_info,
  155. </if>
  156. <if test="plan != null">
  157. `plan`,
  158. </if>
  159. <if test="expectedEffect != null">
  160. expected_effect,
  161. </if>
  162. <if test="nextPlan != null">
  163. next_plan,
  164. </if>
  165. <if test="type != null">
  166. `type`,
  167. </if>
  168. <if test="orderNo != null">
  169. order_no,
  170. </if>
  171. <if test="updateTime != null">
  172. update_time,
  173. </if>
  174. <if test="updateStatus != null">
  175. update_status,
  176. </if>
  177. </trim>
  178. <trim prefix="values (" suffix=")" suffixOverrides=",">
  179. <if test="id != null">
  180. #{id,jdbcType=INTEGER},
  181. </if>
  182. <if test="uid != null">
  183. #{uid,jdbcType=VARCHAR},
  184. </if>
  185. <if test="aid != null">
  186. #{aid,jdbcType=VARCHAR},
  187. </if>
  188. <if test="releaseStart != null">
  189. #{releaseStart,jdbcType=TIMESTAMP},
  190. </if>
  191. <if test="releaseEnd != null">
  192. #{releaseEnd,jdbcType=TIMESTAMP},
  193. </if>
  194. <if test="remarks != null">
  195. #{remarks,jdbcType=VARCHAR},
  196. </if>
  197. <if test="annexUrl != null">
  198. #{annexUrl,jdbcType=VARCHAR},
  199. </if>
  200. <if test="userName != null">
  201. #{userName,jdbcType=VARCHAR},
  202. </if>
  203. <if test="longitude != null">
  204. #{longitude,jdbcType=VARCHAR},
  205. </if>
  206. <if test="latitude != null">
  207. #{latitude,jdbcType=VARCHAR},
  208. </if>
  209. <if test="status != null">
  210. #{status,jdbcType=INTEGER},
  211. </if>
  212. <if test="createTime != null">
  213. #{createTime,jdbcType=TIMESTAMP},
  214. </if>
  215. <if test="clockIn != null">
  216. #{clockIn,jdbcType=INTEGER},
  217. </if>
  218. <if test="clockInTime != null">
  219. #{clockInTime,jdbcType=TIMESTAMP},
  220. </if>
  221. <if test="photoUrl != null">
  222. #{photoUrl,jdbcType=VARCHAR},
  223. </if>
  224. <if test="pid != null">
  225. #{pid,jdbcType=VARCHAR},
  226. </if>
  227. <if test="pname != null">
  228. #{pname,jdbcType=VARCHAR},
  229. </if>
  230. <if test="ufid != null">
  231. #{ufid,jdbcType=VARCHAR},
  232. </if>
  233. <if test="duration != null">
  234. #{duration,jdbcType=DOUBLE},
  235. </if>
  236. <if test="validDate != null">
  237. #{validDate,jdbcType=VARCHAR},
  238. </if>
  239. <if test="newUser != null">
  240. #{newUser,jdbcType=INTEGER},
  241. </if>
  242. <if test="signSum != null">
  243. #{signSum,jdbcType=INTEGER},
  244. </if>
  245. <if test="mainStatus != null">
  246. #{mainStatus,jdbcType=INTEGER},
  247. </if>
  248. <if test="supplement != null">
  249. #{supplement,jdbcType=VARCHAR},
  250. </if>
  251. <if test="auditInfo != null">
  252. #{auditInfo,jdbcType=VARCHAR},
  253. </if>
  254. <if test="plan != null">
  255. #{plan,jdbcType=VARCHAR},
  256. </if>
  257. <if test="expectedEffect != null">
  258. #{expectedEffect,jdbcType=VARCHAR},
  259. </if>
  260. <if test="nextPlan != null">
  261. #{nextPlan,jdbcType=VARCHAR},
  262. </if>
  263. <if test="type != null">
  264. #{type,jdbcType=INTEGER},
  265. </if>
  266. <if test="orderNo != null">
  267. #{orderNo,jdbcType=VARCHAR},
  268. </if>
  269. <if test="updateTime != null">
  270. #{updateTime,jdbcType=TIMESTAMP},
  271. </if>
  272. <if test="updateStatus != null">
  273. #{updateStatus,jdbcType=INTEGER},
  274. </if>
  275. </trim>
  276. </insert>
  277. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.PublicRelease">
  278. update public_release
  279. <set>
  280. <if test="uid != null">
  281. `uid` = #{uid,jdbcType=VARCHAR},
  282. </if>
  283. <if test="aid != null">
  284. aid = #{aid,jdbcType=VARCHAR},
  285. </if>
  286. <if test="releaseStart != null">
  287. release_start = #{releaseStart,jdbcType=TIMESTAMP},
  288. </if>
  289. <if test="releaseEnd != null">
  290. release_end = #{releaseEnd,jdbcType=TIMESTAMP},
  291. </if>
  292. <if test="remarks != null">
  293. remarks = #{remarks,jdbcType=VARCHAR},
  294. </if>
  295. <if test="annexUrl != null">
  296. annex_url = #{annexUrl,jdbcType=VARCHAR},
  297. </if>
  298. <if test="userName != null">
  299. user_name = #{userName,jdbcType=VARCHAR},
  300. </if>
  301. <if test="longitude != null">
  302. longitude = #{longitude,jdbcType=VARCHAR},
  303. </if>
  304. <if test="latitude != null">
  305. latitude = #{latitude,jdbcType=VARCHAR},
  306. </if>
  307. <if test="status != null">
  308. `status` = #{status,jdbcType=INTEGER},
  309. </if>
  310. <if test="createTime != null">
  311. create_time = #{createTime,jdbcType=TIMESTAMP},
  312. </if>
  313. <if test="clockIn != null">
  314. clock_in = #{clockIn,jdbcType=INTEGER},
  315. </if>
  316. <if test="clockInTime != null">
  317. clock_in_time = #{clockInTime,jdbcType=TIMESTAMP},
  318. </if>
  319. <if test="photoUrl != null">
  320. photo_url = #{photoUrl,jdbcType=VARCHAR},
  321. </if>
  322. <if test="pid != null">
  323. pid = #{pid,jdbcType=VARCHAR},
  324. </if>
  325. <if test="pname != null">
  326. pname = #{pname,jdbcType=VARCHAR},
  327. </if>
  328. <if test="ufid != null">
  329. ufid = #{ufid,jdbcType=VARCHAR},
  330. </if>
  331. <if test="duration != null">
  332. duration = #{duration,jdbcType=DOUBLE},
  333. </if>
  334. <if test="validDate != null">
  335. valid_date = #{validDate,jdbcType=VARCHAR},
  336. </if>
  337. <if test="newUser != null">
  338. new_user = #{newUser,jdbcType=INTEGER},
  339. </if>
  340. <if test="signSum != null">
  341. sign_sum = #{signSum,jdbcType=INTEGER},
  342. </if>
  343. <if test="mainStatus != null">
  344. main_status = #{mainStatus,jdbcType=INTEGER},
  345. </if>
  346. <if test="supplement != null">
  347. supplement = #{supplement,jdbcType=VARCHAR},
  348. </if>
  349. <if test="auditInfo != null">
  350. audit_info = #{auditInfo,jdbcType=VARCHAR},
  351. </if>
  352. <if test="plan != null">
  353. `plan` = #{plan,jdbcType=VARCHAR},
  354. </if>
  355. <if test="expectedEffect != null">
  356. expected_effect = #{expectedEffect,jdbcType=VARCHAR},
  357. </if>
  358. <if test="nextPlan != null">
  359. next_plan = #{nextPlan,jdbcType=VARCHAR},
  360. </if>
  361. <if test="type != null">
  362. `type` = #{type,jdbcType=INTEGER},
  363. </if>
  364. <if test="orderNo != null">
  365. order_no = #{orderNo,jdbcType=VARCHAR},
  366. </if>
  367. <if test="updateTime != null">
  368. update_time = #{updateTime,jdbcType=TIMESTAMP},
  369. </if>
  370. <if test="updateStatus != null">
  371. update_status = #{updateStatus,jdbcType=INTEGER},
  372. </if>
  373. </set>
  374. where id = #{id,jdbcType=INTEGER}
  375. </update>
  376. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.PublicRelease">
  377. update public_release
  378. set `uid` = #{uid,jdbcType=VARCHAR},
  379. aid = #{aid,jdbcType=VARCHAR},
  380. release_start = #{releaseStart,jdbcType=TIMESTAMP},
  381. release_end = #{releaseEnd,jdbcType=TIMESTAMP},
  382. remarks = #{remarks,jdbcType=VARCHAR},
  383. annex_url = #{annexUrl,jdbcType=VARCHAR},
  384. user_name = #{userName,jdbcType=VARCHAR},
  385. longitude = #{longitude,jdbcType=VARCHAR},
  386. latitude = #{latitude,jdbcType=VARCHAR},
  387. `status` = #{status,jdbcType=INTEGER},
  388. create_time = #{createTime,jdbcType=TIMESTAMP},
  389. clock_in = #{clockIn,jdbcType=INTEGER},
  390. clock_in_time = #{clockInTime,jdbcType=TIMESTAMP},
  391. photo_url = #{photoUrl,jdbcType=VARCHAR},
  392. pid = #{pid,jdbcType=VARCHAR},
  393. pname = #{pname,jdbcType=VARCHAR},
  394. ufid = #{ufid,jdbcType=VARCHAR},
  395. duration = #{duration,jdbcType=DOUBLE},
  396. valid_date = #{validDate,jdbcType=VARCHAR},
  397. new_user = #{newUser,jdbcType=INTEGER},
  398. sign_sum = #{signSum,jdbcType=INTEGER},
  399. main_status = #{mainStatus,jdbcType=INTEGER},
  400. supplement = #{supplement,jdbcType=VARCHAR},
  401. audit_info = #{auditInfo,jdbcType=VARCHAR},
  402. `plan` = #{plan,jdbcType=VARCHAR},
  403. expected_effect = #{expectedEffect,jdbcType=VARCHAR},
  404. next_plan = #{nextPlan,jdbcType=VARCHAR},
  405. `type` = #{type,jdbcType=INTEGER},
  406. order_no = #{orderNo,jdbcType=VARCHAR},
  407. update_time = #{updateTime,jdbcType=TIMESTAMP},
  408. update_status = #{updateStatus,jdbcType=INTEGER}
  409. where id = #{id,jdbcType=INTEGER}
  410. </update>
  411. <update id="updateSignByAidAndUid">
  412. update public_release a ,(select max(create_time)create_time from public_release
  413. where aid= #{aid} and uid=#{uid} and main_status =1 group by aid,uid)b
  414. set a.sign_sum =a.sign_sum +1
  415. where a.aid =#{aid} and a.uid =#{uid} and a.main_status =1 and a.create_time =b.create_time
  416. </update>
  417. <select id="listPublicRelease" resultType="com.goafanti.weChat.bo.OutPublicReleaseList">
  418. select a.id,b.nickname ,c.name aname,date_format(a.release_start,'%Y-%m-%d %H:%i:%S') releaseStarts,a.user_name userName,
  419. date_format(a.release_end ,'%Y-%m-%d %H:%i:%S') releaseEnds,date_format(a.create_time ,'%Y-%m-%d %H:%i:%S') createTimes,a.status,
  420. a.latitude ,a.longitude ,a.clock_in clockIn
  421. from public_release a left join `user` b on a.uid =b.id left join admin c on a.aid =c.id
  422. <if test="type==2">
  423. left join department d on c.department_id =d.id
  424. </if>
  425. where 1=1
  426. <if test="type==0">
  427. and a.aid= #{aid}
  428. </if>
  429. <if test="type==1">
  430. and c.reviewer = #{aid}
  431. </if>
  432. <if test="type==2">
  433. and d.manager_id = #{aid}
  434. </if>
  435. <if test="clockTime !=null">
  436. and a.release_start &lt; #{clockTime} and a.release_end &gt; #{clockTime}
  437. </if>
  438. <if test="releaseStarts != null and publicEnd != null">
  439. and a.release_start BETWEEN #{releaseStarts} and #{publicEnd}
  440. </if>
  441. <if test="userName !=null">
  442. and b.nickname like CONCAT('%',#{userName},'%')
  443. </if>
  444. <if test="status !=null">
  445. and a.status = #{status}
  446. </if>
  447. <if test="clockIn !=null">
  448. and a.clock_in = #{clockIn}
  449. </if>
  450. ORDER BY (case when a.status=1 then 1 else 2 end),a.status ,a.create_time desc
  451. <if test="page_sql!=null">
  452. ${page_sql}
  453. </if>
  454. </select>
  455. <select id="countPublicRelease" resultType="java.lang.Integer">
  456. select count(*)
  457. from public_release a left join `user` b on a.uid =b.id left join admin c on a.aid =c.id
  458. <if test="type==2">
  459. left join department d on c.department_id =d.id
  460. </if>
  461. where 1=1
  462. <if test="type==0">
  463. and a.aid= #{aid}
  464. </if>
  465. <if test="type==1">
  466. and c.reviewer = #{aid}
  467. </if>
  468. <if test="type==2">
  469. and d.manager_id = #{aid}
  470. </if>
  471. <if test="clockTime !=null">
  472. and a.release_start &lt; #{clockTime} and a.release_end &gt; #{clockTime}
  473. </if>
  474. <if test="releaseStarts != null and publicEnd != null">
  475. and a.release_start BETWEEN #{releaseStarts} and #{publicEnd}
  476. </if>
  477. <if test="userName !=null">
  478. and b.nickname like CONCAT('%',#{userName},'%')
  479. </if>
  480. <if test="status !=null">
  481. and a.status = #{status}
  482. </if>
  483. <if test="clockIn !=null">
  484. and a.clock_in = #{clockIn}
  485. </if>
  486. </select>
  487. <select id="selectDtails" resultType="com.goafanti.weChat.bo.OutPublicRelease">
  488. select a.id,b.nickname ,c.name aname,date_format(a.release_start,'%Y-%m-%d %H:%i:%S') releaseStarts,a.user_name userName,
  489. date_format(a.release_end ,'%Y-%m-%d %H:%i:%S') releaseEnds,date_format(a.create_time ,'%Y-%m-%d %H:%i:%S') createTimes,a.status,
  490. a.annex_url annexUrl ,a.remarks,a.duration ,a.valid_date validDate ,a.latitude ,a.longitude ,a.aid ,c.superior_id suprId,a.uid,
  491. a.clock_in clockIn ,a.plan ,a.expected_effect expectedEffect,a.next_plan nextPlan,c.reviewer,a.type,a.order_no orderNo,d.contract_no contractNo,
  492. date_format(a.update_time ,'%Y-%m-%d %H:%i:%S') updateTimes,a.update_Status updateStatus
  493. from public_release a left join `user` b on a.uid =b.id left join admin c on a.aid =c.id
  494. left join t_order_new d on a.order_no=d.order_no
  495. where 1=1
  496. <if test="id !=null">
  497. and a.id= #{id}
  498. </if>
  499. <if test="ufid !=null">
  500. and a.ufid= #{ufid}
  501. </if>
  502. </select>
  503. <select id="listPublicStatistics" resultType="com.goafanti.weChat.bo.OutPublicStatistics">
  504. select y.aid,y.bh,y.dk,y.wsh,y.tg,y.duration,c.name from(select x.aid ,sum(x.bh)bh,sum(x.wsh)wsh,sum(x.tg)tg,sum(x.dk)dk,sum(x.duration)duration
  505. from (select if(a.status=0,1,0)bh ,if(a.status=1,1,0)wsh,if(a.status=2,1,0)tg,if(a.clock_in=1,1,0) dk,a.aid
  506. ,if(a.status=2,a.duration,0)duration from public_release a left join admin b on a.aid=b.id
  507. where 1=1
  508. <if test="aid != null">
  509. and a.aid= #{aid}
  510. </if>
  511. <if test="clockStart != null and clockEnd != null">
  512. and a.clock_in_time between #{clockStart} and #{clockEnd}
  513. </if>
  514. <if test="createStart != null and createEnd !=null">
  515. and a.create_time between #{createStart} and #{createEnd}
  516. </if>
  517. <if test="depId != null">
  518. and b.department_id = #{depId}
  519. </if>
  520. )x group by x.aid)y left join admin c on c.id=y.aid
  521. <if test="page_sql!=null">
  522. ${page_sql}
  523. </if>
  524. </select>
  525. <select id="countPublicStatistics" resultType="java.lang.Integer">
  526. select count(*) from (select aid from public_release a left join admin b on a.aid=b.id
  527. where 1=1
  528. <if test="aid != null">
  529. and a.aid= #{aid}
  530. </if>
  531. <if test="clockStart != null and clockEnd != null">
  532. and a.clock_in_time between #{clockStart} and #{clockEnd}
  533. </if>
  534. <if test="createStart != null and createEnd !=null">
  535. and a.create_time between #{createStart} and #{createEnd}
  536. </if>
  537. <if test="depId != null">
  538. and b.department_id = #{depId}
  539. </if>
  540. group by aid)x
  541. </select>
  542. <select id="listPublicDtails" resultType="com.goafanti.weChat.bo.OutPublicDtails">
  543. select a.id,b.nickname ,a.user_name userName,c.name aname,a.duration ,a.status,a.annex_url annexUrl,a.photo_url photoUrl,
  544. date_format(a.clock_in_time ,'%Y-%m-%d %H:%i:%S') clockInTimes,a.clock_in clockIn,a.remarks,a.supplement,a.type,
  545. date_format(a.create_time ,'%Y-%m-%d %H:%i:%S') createTimes,a.audit_info auditInfo,d.name sname,
  546. date_format(a.release_start,'%Y-%m-%d %H:%i:%S') releaseStarts,date_format(a.release_end ,'%Y-%m-%d %H:%i:%S') releaseEnds,
  547. a.plan ,a.next_plan nextPlan ,a.expected_effect expectedEffect,a.update_status updateStatus
  548. from public_release a left join `user` b on a.uid=b.id left join admin c on a.aid =c.id
  549. left join admin d on b.aid=d.id where 1=1
  550. <if test="publicType != null">
  551. and a.type= #{publicType}
  552. </if>
  553. <if test="aid != null">
  554. and a.aid= #{aid}
  555. </if>
  556. <if test="sid != null">
  557. and d.id= #{sid}
  558. </if>
  559. <if test="depId != null">
  560. and c.department_id = #{depId}
  561. </if>
  562. <if test="type==1 and deps !=null">
  563. and c.department_id in
  564. <foreach close=")" collection="deps" item="deps" open="(" separator=",">
  565. #{deps.id}
  566. </foreach>
  567. </if>
  568. <if test="uid != null">
  569. and a.uid = #{uid}
  570. </if>
  571. <if test="releaseStart != null and releaseEnd != null">
  572. and (a.release_start between #{releaseStart} and #{releaseEnd} or a.release_end between #{releaseStart} and #{releaseEnd})
  573. </if>
  574. <if test="status != null">
  575. and a.status = #{status}
  576. </if>
  577. <if test="clockIn !=null">
  578. and a.clock_in= #{clockIn}
  579. </if>
  580. order by a.status,a.create_time desc
  581. <if test="page_sql!=null">
  582. ${page_sql}
  583. </if>
  584. </select>
  585. <select id="countPublicDtails" resultType="java.lang.Integer">
  586. select count(*)
  587. from public_release a left join `user` b on a.uid=b.id left join admin c on a.aid =c.id
  588. left join admin d on b.aid=d.id
  589. where 1=1
  590. <if test="publicType != null">
  591. and a.type= #{publicType}
  592. </if>
  593. <if test="aid != null">
  594. and a.aid= #{aid}
  595. </if>
  596. <if test="sid != null">
  597. and d.id= #{sid}
  598. </if>
  599. <if test="depId != null">
  600. and c.department_id = #{depId}
  601. </if>
  602. <if test="type==1 and deps !=null">
  603. and c.department_id in
  604. <foreach close=")" collection="deps" item="deps" open="(" separator=",">
  605. #{deps.id}
  606. </foreach>
  607. </if>
  608. <if test="uid != null">
  609. and a.uid = #{uid}
  610. </if>
  611. <if test="releaseStart != null and releaseEnd != null">
  612. and (a.release_start between #{releaseStart} and #{releaseEnd} or a.release_end between #{releaseStart} and #{releaseEnd})
  613. </if>
  614. <if test="status != null">
  615. and a.status = #{status}
  616. </if>
  617. <if test="clockIn !=null">
  618. and a.clock_in= #{clockIn}
  619. </if>
  620. </select>
  621. <select id="checkTime" resultType="java.lang.Integer">
  622. select count(*) from public_release where aid=#{aid} and status in (0,1,2)
  623. and ( (release_start &gt;= #{start} and release_start &lt; #{end})
  624. or (release_start &lt; #{start} and release_end &gt; #{start})
  625. or (release_start &lt; #{end} and release_end &gt; #{end}))
  626. </select>
  627. <select id="getTimeUserFollow" resultType="com.goafanti.common.model.OutPublicReleaseCount">
  628. select e.id province,d.id depId,a.aid,a.uid,a.new_user newUser ,1 quantity from (select aid,uid,new_user from public_release
  629. where main_status =1 and create_time between #{date} and #{now}
  630. group by aid,uid,new_user)a left join admin c on a.aid=c.id
  631. left join department d on c.department_id =d.id left join district_glossory e on d.province =e.id
  632. </select>
  633. <select id="publicByOrder" resultType="com.goafanti.weChat.bo.OutPublicRelease">
  634. select a.id,a.uid,a.aid,b.nickname ,c.name aname,a.duration ,a.user_name userName,
  635. date_format(a.release_start,'%Y-%m-%d %H:%i:%S')releaseStarts,
  636. date_format(a.release_end ,'%Y-%m-%d %H:%i:%S')releaseEnds,
  637. date_format(a.clock_in_time ,'%Y-%m-%d %H:%i:%S')clockInTimes,
  638. a.remarks
  639. from public_release a left join user b on a.uid=b.id
  640. left join admin c on a.aid =c.id
  641. where a.order_no = #{orderNo}
  642. </select>
  643. </mapper>