TTaskMidMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  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.TTaskMidMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.TTaskMid">
  5. <id column="id" jdbcType="INTEGER" property="id" />
  6. <result column="tid" jdbcType="INTEGER" property="tid" />
  7. <result column="cost_amount" jdbcType="DECIMAL" property="costAmount" />
  8. <result column="party_amount" jdbcType="DECIMAL" property="partyAmount" />
  9. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  10. <result column="certificates_count" jdbcType="INTEGER" property="certificatesCount" />
  11. <result column="urgent_day" jdbcType="INTEGER" property="urgentDay" />
  12. <result column="if_material" jdbcType="INTEGER" property="ifMaterial" />
  13. <result column="reject_count" jdbcType="INTEGER" property="rejectCount" />
  14. <result column="accept_count" jdbcType="INTEGER" property="acceptCount" />
  15. <result column="end_count" jdbcType="INTEGER" property="endCount" />
  16. <result column="authorize_count" jdbcType="INTEGER" property="authorizeCount" />
  17. <result column="apply_count" jdbcType="INTEGER" property="applyCount" />
  18. <result column="high_new_retrial" jdbcType="INTEGER" property="highNewRetrial" />
  19. <result column="dispatch_count" jdbcType="INTEGER" property="dispatchCount" />
  20. <result column="stock_count" jdbcType="INTEGER" property="stockCount" />
  21. <result column="complete_count" jdbcType="INTEGER" property="completeCount" />
  22. <result column="promulgate_count" jdbcType="INTEGER" property="promulgateCount" />
  23. <result column="dispatch_province" jdbcType="INTEGER" property="dispatchProvince" />
  24. <result column="duty_dep" jdbcType="VARCHAR" property="dutyDep" />
  25. <result column="set_up_count" jdbcType="INTEGER" property="setUpCount" />
  26. <result column="spot_check_count" jdbcType="INTEGER" property="spotCheckCount" />
  27. <result column="fail_count" jdbcType="INTEGER" property="failCount" />
  28. <result column="last_year" jdbcType="VARCHAR" property="lastYear" />
  29. <result column="last_year_capital" jdbcType="VARCHAR" property="lastYearCapital" />
  30. <result column="last_year_income" jdbcType="VARCHAR" property="lastYearIncome" />
  31. </resultMap>
  32. <sql id="Base_Column_List">
  33. id, tid, cost_amount, party_amount, create_time, certificates_count, urgent_day,
  34. if_material, reject_count, accept_count, end_count, authorize_count, apply_count,
  35. high_new_retrial, dispatch_count, stock_count, complete_count, promulgate_count,
  36. dispatch_province, duty_dep, set_up_count, spot_check_count, fail_count, last_year,
  37. last_year_capital, last_year_income
  38. </sql>
  39. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  40. select
  41. <include refid="Base_Column_List" />
  42. from t_task_mid
  43. where id = #{id,jdbcType=INTEGER}
  44. </select>
  45. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  46. delete from t_task_mid
  47. where id = #{id,jdbcType=INTEGER}
  48. </delete>
  49. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TTaskMid" useGeneratedKeys="true">
  50. insert into t_task_mid (tid, cost_amount, party_amount,
  51. create_time, certificates_count, urgent_day,
  52. if_material, reject_count, accept_count,
  53. end_count, authorize_count, apply_count,
  54. high_new_retrial, dispatch_count, stock_count,
  55. complete_count, promulgate_count, dispatch_province,
  56. duty_dep, set_up_count, spot_check_count,
  57. fail_count, last_year, last_year_capital,
  58. last_year_income)
  59. values (#{tid,jdbcType=INTEGER}, #{costAmount,jdbcType=DECIMAL}, #{partyAmount,jdbcType=DECIMAL},
  60. #{createTime,jdbcType=TIMESTAMP}, #{certificatesCount,jdbcType=INTEGER}, #{urgentDay,jdbcType=INTEGER},
  61. #{ifMaterial,jdbcType=INTEGER}, #{rejectCount,jdbcType=INTEGER}, #{acceptCount,jdbcType=INTEGER},
  62. #{endCount,jdbcType=INTEGER}, #{authorizeCount,jdbcType=INTEGER}, #{applyCount,jdbcType=INTEGER},
  63. #{highNewRetrial,jdbcType=INTEGER}, #{dispatchCount,jdbcType=INTEGER}, #{stockCount,jdbcType=INTEGER},
  64. #{completeCount,jdbcType=INTEGER}, #{promulgateCount,jdbcType=INTEGER}, #{dispatchProvince,jdbcType=INTEGER},
  65. #{dutyDep,jdbcType=VARCHAR}, #{setUpCount,jdbcType=INTEGER}, #{spotCheckCount,jdbcType=INTEGER},
  66. #{failCount,jdbcType=INTEGER}, #{lastYear,jdbcType=VARCHAR}, #{lastYearCapital,jdbcType=VARCHAR},
  67. #{lastYearIncome,jdbcType=VARCHAR})
  68. </insert>
  69. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TTaskMid" useGeneratedKeys="true">
  70. insert into t_task_mid
  71. <trim prefix="(" suffix=")" suffixOverrides=",">
  72. <if test="tid != null">
  73. tid,
  74. </if>
  75. <if test="costAmount != null">
  76. cost_amount,
  77. </if>
  78. <if test="partyAmount != null">
  79. party_amount,
  80. </if>
  81. <if test="createTime != null">
  82. create_time,
  83. </if>
  84. <if test="certificatesCount != null">
  85. certificates_count,
  86. </if>
  87. <if test="urgentDay != null">
  88. urgent_day,
  89. </if>
  90. <if test="ifMaterial != null">
  91. if_material,
  92. </if>
  93. <if test="rejectCount != null">
  94. reject_count,
  95. </if>
  96. <if test="acceptCount != null">
  97. accept_count,
  98. </if>
  99. <if test="endCount != null">
  100. end_count,
  101. </if>
  102. <if test="authorizeCount != null">
  103. authorize_count,
  104. </if>
  105. <if test="applyCount != null">
  106. apply_count,
  107. </if>
  108. <if test="highNewRetrial != null">
  109. high_new_retrial,
  110. </if>
  111. <if test="dispatchCount != null">
  112. dispatch_count,
  113. </if>
  114. <if test="stockCount != null">
  115. stock_count,
  116. </if>
  117. <if test="completeCount != null">
  118. complete_count,
  119. </if>
  120. <if test="promulgateCount != null">
  121. promulgate_count,
  122. </if>
  123. <if test="dispatchProvince != null">
  124. dispatch_province,
  125. </if>
  126. <if test="dutyDep != null">
  127. duty_dep,
  128. </if>
  129. <if test="setUpCount != null">
  130. set_up_count,
  131. </if>
  132. <if test="spotCheckCount != null">
  133. spot_check_count,
  134. </if>
  135. <if test="failCount != null">
  136. fail_count,
  137. </if>
  138. <if test="lastYear != null">
  139. last_year,
  140. </if>
  141. <if test="lastYearCapital != null">
  142. last_year_capital,
  143. </if>
  144. <if test="lastYearIncome != null">
  145. last_year_income,
  146. </if>
  147. </trim>
  148. <trim prefix="values (" suffix=")" suffixOverrides=",">
  149. <if test="tid != null">
  150. #{tid,jdbcType=INTEGER},
  151. </if>
  152. <if test="costAmount != null">
  153. #{costAmount,jdbcType=DECIMAL},
  154. </if>
  155. <if test="partyAmount != null">
  156. #{partyAmount,jdbcType=DECIMAL},
  157. </if>
  158. <if test="createTime != null">
  159. #{createTime,jdbcType=TIMESTAMP},
  160. </if>
  161. <if test="certificatesCount != null">
  162. #{certificatesCount,jdbcType=INTEGER},
  163. </if>
  164. <if test="urgentDay != null">
  165. #{urgentDay,jdbcType=INTEGER},
  166. </if>
  167. <if test="ifMaterial != null">
  168. #{ifMaterial,jdbcType=INTEGER},
  169. </if>
  170. <if test="rejectCount != null">
  171. #{rejectCount,jdbcType=INTEGER},
  172. </if>
  173. <if test="acceptCount != null">
  174. #{acceptCount,jdbcType=INTEGER},
  175. </if>
  176. <if test="endCount != null">
  177. #{endCount,jdbcType=INTEGER},
  178. </if>
  179. <if test="authorizeCount != null">
  180. #{authorizeCount,jdbcType=INTEGER},
  181. </if>
  182. <if test="applyCount != null">
  183. #{applyCount,jdbcType=INTEGER},
  184. </if>
  185. <if test="highNewRetrial != null">
  186. #{highNewRetrial,jdbcType=INTEGER},
  187. </if>
  188. <if test="dispatchCount != null">
  189. #{dispatchCount,jdbcType=INTEGER},
  190. </if>
  191. <if test="stockCount != null">
  192. #{stockCount,jdbcType=INTEGER},
  193. </if>
  194. <if test="completeCount != null">
  195. #{completeCount,jdbcType=INTEGER},
  196. </if>
  197. <if test="promulgateCount != null">
  198. #{promulgateCount,jdbcType=INTEGER},
  199. </if>
  200. <if test="dispatchProvince != null">
  201. #{dispatchProvince,jdbcType=INTEGER},
  202. </if>
  203. <if test="dutyDep != null">
  204. #{dutyDep,jdbcType=VARCHAR},
  205. </if>
  206. <if test="setUpCount != null">
  207. #{setUpCount,jdbcType=INTEGER},
  208. </if>
  209. <if test="spotCheckCount != null">
  210. #{spotCheckCount,jdbcType=INTEGER},
  211. </if>
  212. <if test="failCount != null">
  213. #{failCount,jdbcType=INTEGER},
  214. </if>
  215. <if test="lastYear != null">
  216. #{lastYear,jdbcType=VARCHAR},
  217. </if>
  218. <if test="lastYearCapital != null">
  219. #{lastYearCapital,jdbcType=VARCHAR},
  220. </if>
  221. <if test="lastYearIncome != null">
  222. #{lastYearIncome,jdbcType=VARCHAR},
  223. </if>
  224. </trim>
  225. </insert>
  226. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TTaskMid">
  227. update t_task_mid
  228. <set>
  229. <if test="tid != null">
  230. tid = #{tid,jdbcType=INTEGER},
  231. </if>
  232. <if test="costAmount != null">
  233. cost_amount = #{costAmount,jdbcType=DECIMAL},
  234. </if>
  235. <if test="partyAmount != null">
  236. party_amount = #{partyAmount,jdbcType=DECIMAL},
  237. </if>
  238. <if test="createTime != null">
  239. create_time = #{createTime,jdbcType=TIMESTAMP},
  240. </if>
  241. <if test="certificatesCount != null">
  242. certificates_count = #{certificatesCount,jdbcType=INTEGER},
  243. </if>
  244. <if test="urgentDay != null">
  245. urgent_day = #{urgentDay,jdbcType=INTEGER},
  246. </if>
  247. <if test="ifMaterial != null">
  248. if_material = #{ifMaterial,jdbcType=INTEGER},
  249. </if>
  250. <if test="rejectCount != null">
  251. reject_count = #{rejectCount,jdbcType=INTEGER},
  252. </if>
  253. <if test="acceptCount != null">
  254. accept_count = #{acceptCount,jdbcType=INTEGER},
  255. </if>
  256. <if test="endCount != null">
  257. end_count = #{endCount,jdbcType=INTEGER},
  258. </if>
  259. <if test="authorizeCount != null">
  260. authorize_count = #{authorizeCount,jdbcType=INTEGER},
  261. </if>
  262. <if test="applyCount != null">
  263. apply_count = #{applyCount,jdbcType=INTEGER},
  264. </if>
  265. <if test="highNewRetrial != null">
  266. high_new_retrial = #{highNewRetrial,jdbcType=INTEGER},
  267. </if>
  268. <if test="dispatchCount != null">
  269. dispatch_count = #{dispatchCount,jdbcType=INTEGER},
  270. </if>
  271. <if test="stockCount != null">
  272. stock_count = #{stockCount,jdbcType=INTEGER},
  273. </if>
  274. <if test="completeCount != null">
  275. complete_count = #{completeCount,jdbcType=INTEGER},
  276. </if>
  277. <if test="promulgateCount != null">
  278. promulgate_count = #{promulgateCount,jdbcType=INTEGER},
  279. </if>
  280. <if test="dispatchProvince != null">
  281. dispatch_province = #{dispatchProvince,jdbcType=INTEGER},
  282. </if>
  283. <if test="dutyDep != null">
  284. duty_dep = #{dutyDep,jdbcType=VARCHAR},
  285. </if>
  286. <if test="setUpCount != null">
  287. set_up_count = #{setUpCount,jdbcType=INTEGER},
  288. </if>
  289. <if test="spotCheckCount != null">
  290. spot_check_count = #{spotCheckCount,jdbcType=INTEGER},
  291. </if>
  292. <if test="failCount != null">
  293. fail_count = #{failCount,jdbcType=INTEGER},
  294. </if>
  295. <if test="lastYear != null">
  296. last_year = #{lastYear,jdbcType=VARCHAR},
  297. </if>
  298. <if test="lastYearCapital != null">
  299. last_year_capital = #{lastYearCapital,jdbcType=VARCHAR},
  300. </if>
  301. <if test="lastYearIncome != null">
  302. last_year_income = #{lastYearIncome,jdbcType=VARCHAR},
  303. </if>
  304. </set>
  305. where id = #{id,jdbcType=INTEGER}
  306. </update>
  307. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TTaskMid">
  308. update t_task_mid
  309. set tid = #{tid,jdbcType=INTEGER},
  310. cost_amount = #{costAmount,jdbcType=DECIMAL},
  311. party_amount = #{partyAmount,jdbcType=DECIMAL},
  312. create_time = #{createTime,jdbcType=TIMESTAMP},
  313. certificates_count = #{certificatesCount,jdbcType=INTEGER},
  314. urgent_day = #{urgentDay,jdbcType=INTEGER},
  315. if_material = #{ifMaterial,jdbcType=INTEGER},
  316. reject_count = #{rejectCount,jdbcType=INTEGER},
  317. accept_count = #{acceptCount,jdbcType=INTEGER},
  318. end_count = #{endCount,jdbcType=INTEGER},
  319. authorize_count = #{authorizeCount,jdbcType=INTEGER},
  320. apply_count = #{applyCount,jdbcType=INTEGER},
  321. high_new_retrial = #{highNewRetrial,jdbcType=INTEGER},
  322. dispatch_count = #{dispatchCount,jdbcType=INTEGER},
  323. stock_count = #{stockCount,jdbcType=INTEGER},
  324. complete_count = #{completeCount,jdbcType=INTEGER},
  325. promulgate_count = #{promulgateCount,jdbcType=INTEGER},
  326. dispatch_province = #{dispatchProvince,jdbcType=INTEGER},
  327. duty_dep = #{dutyDep,jdbcType=VARCHAR},
  328. set_up_count = #{setUpCount,jdbcType=INTEGER},
  329. spot_check_count = #{spotCheckCount,jdbcType=INTEGER},
  330. fail_count = #{failCount,jdbcType=INTEGER},
  331. last_year = #{lastYear,jdbcType=VARCHAR},
  332. last_year_capital = #{lastYearCapital,jdbcType=VARCHAR},
  333. last_year_income = #{lastYearIncome,jdbcType=VARCHAR}
  334. where id = #{id,jdbcType=INTEGER}
  335. </update>
  336. <update id="updatePaymentAmount">
  337. update t_task_mid
  338. <if test="type == 0">
  339. set party_amount = party_amount + #{paymentAmount,jdbcType=DECIMAL}
  340. </if>
  341. <if test="type == 1">
  342. set party_amount = party_amount - #{paymentAmount,jdbcType=DECIMAL}
  343. </if>
  344. where tid = #{tid,jdbcType=INTEGER}
  345. </update>
  346. <select id="selectListByTid" resultType="com.goafanti.common.model.TTaskMid">
  347. select c.id,c.tid,c.cost_amount costAmount,c.party_amount partyAmount from t_order_task a left join t_order_task b on a.order_no=b.order_no
  348. left join t_task_mid c on b.id=c.tid
  349. where a.id= #{tid}
  350. </select>
  351. <update id="updateCostAmount">
  352. update t_order_task a ,t_task_mid c
  353. set c.cost_amount=#{count}
  354. where a.id=c.tid and a.id= #{tid}
  355. </update>
  356. <update id="updateCertificatesCountByTid">
  357. update t_task_mid
  358. set certificates_count= #{count}
  359. where tid= #{tid}
  360. </update>
  361. <update id="updateByTid" parameterType="com.goafanti.common.model.TTaskMid">
  362. update t_task_mid
  363. <set>
  364. <if test="tid != null">
  365. tid = #{tid,jdbcType=INTEGER},
  366. </if>
  367. <if test="costAmount != null">
  368. cost_amount = #{costAmount,jdbcType=DECIMAL},
  369. </if>
  370. <if test="partyAmount != null">
  371. party_amount = #{partyAmount,jdbcType=DECIMAL},
  372. </if>
  373. <if test="createTime != null">
  374. create_time = #{createTime,jdbcType=TIMESTAMP},
  375. </if>
  376. <if test="certificatesCount != null">
  377. certificates_count = #{certificatesCount,jdbcType=INTEGER},
  378. </if>
  379. <if test="urgentDay != null">
  380. urgent_day = #{urgentDay,jdbcType=INTEGER},
  381. </if>
  382. <if test="ifMaterial != null">
  383. if_material = #{ifMaterial,jdbcType=INTEGER},
  384. </if>
  385. <if test="rejectCount != null">
  386. reject_count = #{rejectCount,jdbcType=INTEGER},
  387. </if>
  388. <if test="acceptCount != null">
  389. accept_count = #{acceptCount,jdbcType=INTEGER},
  390. </if>
  391. <if test="endCount != null">
  392. end_count = #{endCount,jdbcType=INTEGER},
  393. </if>
  394. <if test="authorizeCount != null">
  395. authorize_count = #{authorizeCount,jdbcType=INTEGER},
  396. </if>
  397. <if test="applyCount != null">
  398. apply_count = #{applyCount,jdbcType=INTEGER},
  399. </if>
  400. <if test="highNewRetrial != null">
  401. high_new_retrial = #{highNewRetrial,jdbcType=INTEGER},
  402. </if>
  403. <if test="dispatchCount != null">
  404. dispatch_count = #{dispatchCount,jdbcType=INTEGER},
  405. </if>
  406. <if test="stockCount != null">
  407. stock_count = #{stockCount,jdbcType=INTEGER},
  408. </if>
  409. <if test="completeCount != null">
  410. complete_count = #{completeCount,jdbcType=INTEGER},
  411. </if>
  412. <if test="promulgateCount != null">
  413. promulgate_count = #{promulgateCount,jdbcType=INTEGER},
  414. </if>
  415. <if test="dispatchProvince != null">
  416. dispatch_province = #{dispatchProvince,jdbcType=INTEGER},
  417. </if>
  418. <if test="dutyDep != null">
  419. duty_dep = #{dutyDep,jdbcType=VARCHAR},
  420. </if>
  421. <if test="setUpCount != null">
  422. set_up_count = #{setUpCount,jdbcType=INTEGER},
  423. </if>
  424. <if test="spotCheckCount != null">
  425. spot_check_count = #{spotCheckCount,jdbcType=INTEGER},
  426. </if>
  427. <if test="failCount != null">
  428. fail_count = #{failCount,jdbcType=INTEGER},
  429. </if>
  430. </set>
  431. where tid = #{tid,jdbcType=INTEGER}
  432. </update>
  433. <select id="selectCountBytid" resultType="com.goafanti.common.model.TTaskMid">
  434. select a.id,
  435. <if test="type ==0">
  436. ifnull(b.lic,0) certificatesCount
  437. </if>
  438. <if test="type ==1">
  439. ifnull(b.acc ,0)acceptCount, ifnull(b.lic ,0)authorizeCount,ifnull(b.lic ,0)certificatesCount,
  440. ifnull(b.tgc ,0)endCount,ifnull(b.bhc ,0)rejectCount
  441. </if>
  442. <if test="type ==2">
  443. ifnull(b.acc ,0)acceptCount,ifnull(b.lic ,0)certificatesCount,ifnull(b.sqc,0) applyCount,
  444. ifnull(b.bhc,0) rejectCount
  445. </if>
  446. from t_task_mid a left join (select task_id tid,
  447. <if test="type ==0">
  448. sum(if(licence_time is null,0,1))lic from task_progress where task_id= #{tid} GROUP by task_id)b
  449. </if>
  450. <if test="type ==1">
  451. <!-- 下证数与授权数一样,下证统计大于则用下证,小于或者等于用授权统计 -->
  452. sum(if(if(licence_time is null,0,1) &gt; if(authorize_time is null,0,1),
  453. if(licence_time is null,0,1),if(authorize_time is null,0,1)))lic ,ifnull(count(accept_time),0)acc,
  454. sum(if(status=1,1,0))tgc,sum(if(status=2 ,1,0))bhc from task_progress where task_id= #{tid} GROUP by task_id )b
  455. </if>
  456. <if test="type ==2">
  457. count(*)sqc, sum(if(licence_time is null,0,1))lic , sum(if(accept_time is null,0,1))acc,
  458. sum(if(status=2 ,1,0))bhc from task_progress where task_id= #{tid} GROUP by task_id )b
  459. </if>
  460. on a.tid =b.tid
  461. where a.tid= #{tid}
  462. </select>
  463. <select id="getDtails" resultType="com.goafanti.common.model.TTaskMid">
  464. select a.id tid,dg.id dispatchProvince,tr.department_id dutyDep
  465. from t_order_task a left join t_order_new b on a.order_no =b.order_no
  466. left join department c on b.order_dep =c.id left join admin tr on a.task_receiver =tr.id
  467. left join district_glossory dg on c.province =dg.id
  468. where a.id= #{id};
  469. </select>
  470. </mapper>