TyJytjbbMapper.xml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  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.unis.transaction.server.dao.TyJytjbbDao">
  4. <sql id="traderuleColumns">
  5. bd.bdbm as bdbm,
  6. bd.bdh as bdh,
  7. bd.apbm as apbm
  8. </sql>
  9. <sql id="siteColumns">
  10. cc.apcc as apcc,
  11. MAX(to_char(cc.jyrq, 'yyyy年MM月dd日')) as cjrq,
  12. MAX(wt.jyfs) as jyfs,
  13. MAX(wt.jyfx) as jyfx,
  14. MAX(wt.jyfxmc) as jyfxmc,
  15. MAX(wt.jyfsmc) as jyfsmc,
  16. MAX(wt.wtfmc) as wtfmc,
  17. MAX(cc.wtfbm) as wtfbm,
  18. MAX(ht.pzmc) as pzmc,
  19. MAX(ht.pzbm) as pzbm,
  20. MAX(wt.lsxzbm) as lsxzbm,
  21. MAX(CASE ht.jylx
  22. WHEN '0' THEN ht.cmmc
  23. WHEN '1' THEN ht.sgmc
  24. ELSE NULL
  25. END) as sgmc,
  26. MAX(cc.ccbm) as ccbm
  27. </sql>
  28. <insert id="insertDcjybzxx">
  29. insert into ty_dcjybzxx (id, bdh, htbh, tsbz, yy, bjr, bjrq)
  30. values (#{id}, #{bdh}, #{htbh}, #{tsbz}, #{yy}, #{bjr}, #{bjrq})
  31. </insert>
  32. <update id="updateDcjybzxx">
  33. update ty_dcjybzxx set bdh = #{bdh}, htbh = #{htbh}, tsbz = #{tsbz}, yy = #{yy}, bjr = #{bjr}, bjrq = #{bjrq}
  34. where id = #{id}
  35. </update>
  36. <select id="selectPageList" resultType="com.unis.transaction.server.entity.tradeplan.TyJytjbb" parameterType="com.unis.transaction.server.entity.tradeplan.TyJytjbb">
  37. SELECT
  38. <include refid="siteColumns"/>
  39. FROM
  40. <if test="sgmc != null and sgmc != ''">
  41. (select * from ty_jycc c where c.apcc IN
  42. ( SELECT ht.apcc FROM ty_jyht ht
  43. where
  44. (instr(decode(ht.jylx, 0, ht.cmmc, 1, ht.sgmc), #{sgmc}) > 0)
  45. GROUP BY ht.apcc
  46. )) cc
  47. </if>
  48. <if test="sgmc == null or sgmc == ''">
  49. ty_jycc cc
  50. </if>
  51. left join ty_jycrkwt wt on cc.wtbm = wt.wtbm
  52. left join ty_jyht ht on ht.apcc = cc.apcc
  53. <trim prefix="where" prefixOverrides="and|or">
  54. and ht.htbm!='' and ht.htbm is not null
  55. <if test="apcc != null and apcc != ''">
  56. and instr(cc.apcc, #{apcc}) > 0
  57. </if>
  58. <if test="cczt != null and cczt != ''">
  59. and cc.cczt = #{cczt}
  60. </if>
  61. <if test="cjrq != null">
  62. and cc.jyrq = to_date(#{cjrq}, 'yyyy-mm-dd')
  63. </if>
  64. <if test="jyfx != null and jyfx != ''">
  65. and cc.jyfx = #{jyfx}
  66. </if>
  67. <if test="jyfs != null and jyfs != ''">
  68. and cc.jyfs = #{jyfs}
  69. </if>
  70. <if test="wtfmc != null and wtfmc != ''">
  71. and instr(cc.wtfmc, #{wtfmc}) > 0
  72. </if>
  73. <if test="pzbm != null and pzbm != ''">
  74. and instr(wt.pzbm, #{pzbm}) > 0
  75. </if>
  76. <!-- <if test="jylx != null and jylx != ''">-->
  77. <!-- and wt.jylx = #{jylx}-->
  78. <!-- </if>-->
  79. <!-- <if test="apzt != null and apzt != ''">-->
  80. <!-- and wt.apzt = #{apzt}-->
  81. <!-- </if>-->
  82. <if test="lsxzbm != null and lsxzbm != ''">
  83. and wt.lsxzbm = #{lsxzbm}
  84. </if>
  85. </trim>
  86. GROUP BY cc.apcc
  87. ORDER BY MAX(cc.ccbm) DESC
  88. </select>
  89. <select id="sjcbcj" resultType="com.unis.transaction.server.entity.tradeplan.TyJytjbbScbcj">
  90. select cc.apcc,
  91. ht.htbh as htbh,
  92. ht.cckmc as cckmc,
  93. ht.nch as nch,
  94. ht.pzmc as pzmc,
  95. ht.pzbm as pzbm,
  96. ht.nnf as nnf,
  97. ht.lssl as cjsl,
  98. ht.qpdj as qpdj,
  99. ht.cjdj as cjdj,
  100. CASE ht.jylx
  101. WHEN '0' THEN ht.cmmc
  102. WHEN '1' THEN ht.sgmc
  103. ELSE NULL
  104. END as cjdw,
  105. ht.je as je,
  106. to_char(wt.wcsj, 'yyyy年MM月dd日') as cjrq
  107. from ty_jyht ht
  108. left join ty_jycc cc on cc.apcc = ht.apcc
  109. left join ty_jycrkwt wt on wt.wtbm = cc.wtbm
  110. where cc.apcc = #{apcc}
  111. order by ht.htbh asc
  112. </select>
  113. <select id="sxfTj" resultType="com.unis.transaction.server.entity.tradeplan.TyJytjbbSxftj">
  114. select cc.apcc,
  115. ht.htbh as htbh,
  116. CASE ht.jylx
  117. WHEN '0' THEN ht.cmmc
  118. WHEN '1' THEN ht.sgmc
  119. ELSE NULL
  120. END as cjdw,
  121. ht.cjdj as cjdj,
  122. ht.lssl as cjsl,
  123. ht.je as je,
  124. cc.sxfl as sxfl,
  125. cc.jybzj as jybzj,
  126. cc.lybzj as lybzj,
  127. cc.sxf_Type as sxfType,
  128. ht.sjjke as sjjke,
  129. wt.jyfx as jyfx,
  130. wt.jyfs as jyfs,
  131. ht.jylx as jylx,
  132. wt.wtfmc as wtfmc,
  133. wt.lsxzbm as lsxzbm,
  134. to_char(wt.wcsj, 'yyyy年MM月dd日') as cjrq
  135. from ty_jyht ht
  136. left join ty_jycc cc on cc.apcc = ht.apcc
  137. left join ty_jycrkwt wt on wt.wtbm = cc.wtbm
  138. where cc.apcc = #{apcc}
  139. order by ht.htbh asc
  140. </select>
  141. <select id="jyjghz" resultType="com.unis.transaction.server.entity.tradeplan.TyJytjbbJyjghz">
  142. SELECT to_char(tcc.jyrq, 'yyyy年MM月dd日') as cjrq,
  143. tcc.apcc as apcc,
  144. case tap.aplx
  145. when 0 then '采购'
  146. when 1 then '销售'
  147. else ''
  148. end as jyfx,
  149. case tap.aplx
  150. when 0 then '采购'
  151. when 1 then '销售'
  152. else ''
  153. end as jyfxmc,
  154. -- tap.pzmc
  155. tap.scnd as ccnx,
  156. max(tap.pzmc) as pzmc,
  157. tap.jydj as dj,
  158. max(wt.lscd) as cd,
  159. wm_concat(tap.bdbm) as bdbm
  160. FROM ty_jycrkap tap
  161. JOIN
  162. ty_jycc tcc ON tap.wtbm = tcc.wtbm
  163. JOIN
  164. ty_jyht tht ON tcc.apcc = tht.apcc AND tcc.ccbm = tht.ccbm
  165. join
  166. ty_jycrkwt wt on wt.wtbm = tap.wtbm
  167. <where>
  168. tht.htbm is not null and tht.htbm != ''
  169. <if test="cjrqks != null and cjrqks != ''">
  170. and tcc.jyrq &gt;= to_date(#{cjrqks}, 'yyyy-mm-dd')
  171. </if>
  172. <if test="cjrqjs != null and cjrqjs != ''">
  173. and tcc.jyrq &lt;= to_date(#{cjrqjs}, 'yyyy-mm-dd')
  174. </if>
  175. </where>
  176. GROUP BY tap.aplx,
  177. tcc.jyrq,
  178. tcc.apcc,
  179. tap.scnd,
  180. tap.jydj
  181. order by tcc.jyrq desc,tcc.jyrq desc
  182. </select>
  183. <select id="jyjghzlist" resultType="com.unis.transaction.server.entity.tradeplan.TyJytjbbJyjghz">
  184. SELECT to_char(tcc.jyrq, 'yyyy年MM月dd日') as cjrq,
  185. tcc.apcc as apcc,
  186. case tap.aplx
  187. when 0 then '采购'
  188. when 1 then '销售'
  189. else ''
  190. end as jyfx,
  191. case tap.aplx
  192. when 0 then '采购'
  193. when 1 then '销售'
  194. else ''
  195. end as jyfxmc,
  196. -- tap.pzmc
  197. tap.scnd as ccnx,
  198. max(tap.pzmc) as pzmc,
  199. tap.jydj as dj,
  200. max(wt.lscd) as cd,
  201. wm_concat(tap.bdbm) as bdbm
  202. FROM ty_jycrkap tap
  203. JOIN
  204. ty_jycc tcc ON tap.wtbm = tcc.wtbm
  205. JOIN
  206. ty_jyht tht ON tcc.apcc = tht.apcc AND tcc.ccbm = tht.ccbm
  207. join
  208. ty_jycrkwt wt on wt.wtbm = tap.wtbm
  209. <where>
  210. tht.htbm is not null and tht.htbm != ''
  211. <if test="cjrqks != null and cjrqks != ''">
  212. and tcc.jyrq &gt;= to_date(#{cjrqks}, 'yyyy-mm-dd')
  213. </if>
  214. <if test="cjrqjs != null and cjrqjs != ''">
  215. and tcc.jyrq &lt;= to_date(#{cjrqjs}, 'yyyy-mm-dd')
  216. </if>
  217. </where>
  218. GROUP BY tap.aplx,
  219. tcc.jyrq,
  220. tcc.apcc,
  221. tap.scnd,
  222. tap.jydj
  223. order by tcc.jyrq desc,tcc.apcc desc
  224. </select>
  225. <select id="selectDcjlPage" resultType="com.unis.transaction.server.entity.tradeplan.TyDcsjjl">
  226. select cc.apcc as cc,
  227. cc.ccbh as ccbh,
  228. to_char(cc.jyrq,'yyyy-MM-dd') as jyrq,
  229. cc.wtfmc as wtf,
  230. wt.lsxzbm as jyjb,
  231. CASE ap.aplx
  232. WHEN '0' THEN '采购'
  233. WHEN '1' THEN '销售'
  234. ELSE NULL
  235. END as jylxmc,
  236. ap.aplx as jylx,
  237. wt.jyfs as jyfs,
  238. wt.jyfsmc as jyfsmc,
  239. ap.pzmc as pzmc,
  240. ap.pzbm as pzbm,
  241. ap.bdh as bdh,
  242. ht.htbh as hth,
  243. ap.lssl as bdsl,
  244. ht.lssl as htsl,
  245. ht.qpdj as qpj,
  246. ht.cjdj as cjj,
  247. (select lysl from ty_refund_notice rn where rn.htbm = ht.htbm and rn.zt = '92000400') as lysl,
  248. (select wysl from ty_refund_notice rn where rn.htbm = ht.htbm and rn.zt = '92000400') as wysl,
  249. CASE ht.jylx
  250. WHEN '0' THEN ht.cmmc
  251. WHEN '1' THEN ht.sgmc
  252. ELSE NULL
  253. END as cjkh,
  254. (select wm_concat(kh.khmc) from ty_jycc_khxx kh where kh.wtbh=cc.wtbm) as bmkh,
  255. ap.dwmc as ccdw,
  256. ap.ccdd as ch,
  257. ht.je as htje,
  258. cc.sxfl as khsxfl,
  259. cc.lybzj as lybzj,
  260. cc.jybzj as jybzj
  261. from ty_jycrkap ap
  262. left join ty_jycc cc on cc.wtbm = ap.wtbm
  263. left join ty_jyht ht on ap.bdbm = ht.bdbm
  264. left join ty_jycrkwt wt on wt.wtbm = ap.wtbm
  265. <where>
  266. <if test="jyrqStart != null and jyrqStart != ''">
  267. and cc.jyrq &gt;= to_date(#{jyrqStart}, 'yyyy-mm-dd')
  268. </if>
  269. <if test="jyrqEnd != null and jyrqEnd != ''">
  270. and cc.jyrq &lt;= to_date(#{jyrqEnd}, 'yyyy-mm-dd')
  271. </if>
  272. <!-- 流拍 -->
  273. <if test="jyjg == '1'.toString()">
  274. and to_date(to_date(cc.jyrq,'yyyy-MM-dd')+2,'yyyy-MM-dd') &lt; to_date(sysdate,'yyyy-MM-dd') and ht.htbh is null
  275. </if>
  276. <!-- 成交 -->
  277. <if test="jyjg == '2'.toString()">
  278. and ht.htbh is not null
  279. </if>
  280. <!-- 待维护 -->
  281. <if test="jyjg == '3'.toString()">
  282. and to_date(to_date(cc.jyrq,'yyyy-MM-dd')+2,'yyyy-MM-dd') &gt;= to_date(sysdate,'yyyy-MM-dd') and ht.htbh is null
  283. </if>
  284. <if test="jylx != null and jylx != ''">
  285. and ap.aplx = #{jylx}
  286. </if>
  287. <if test="jyjb != null and jyjb != ''">
  288. and wt.lsxzbm = #{jyjb}
  289. </if>
  290. <if test="jyfs != null and jyfs != ''">
  291. and wt.jyfs = #{jyfs}
  292. </if>
  293. <if test="hth != null and hth != ''">
  294. and ht.htbh like '%'||#{hth}||'%'
  295. </if>
  296. <if test="pzbm != null and pzbm != ''">
  297. and ap.pzbm = #{pzbm}
  298. </if>
  299. <if test="cc != null and cc != ''">
  300. and cc.apcc like '%'||#{cc}||'%'
  301. </if>
  302. <if test="wtf != null and wtf != ''">
  303. and cc.wtfmc like '%'||#{wtf}||'%'
  304. </if>
  305. </where>
  306. order by cc.jyrq desc,cc.apcc desc
  307. </select>
  308. <select id="dcjlExport" resultType="com.unis.transaction.server.entity.tradeplan.TyDcsjjl">
  309. select cc.apcc as cc,
  310. cc.ccbh as ccbh,
  311. to_char(cc.jyrq,'yyyy-MM-dd') as jyrq,
  312. cc.wtfmc as wtf,
  313. wt.lsxzbm as jyjb,
  314. CASE ap.aplx
  315. WHEN '0' THEN '采购'
  316. WHEN '1' THEN '销售'
  317. ELSE NULL
  318. END as jylxmc,
  319. ap.aplx as jylx,
  320. wt.jyfs as jyfs,
  321. wt.jyfsmc as jyfsmc,
  322. ap.pzmc as pzmc,
  323. ap.pzbm as pzbm,
  324. ap.bdh as bdh,
  325. ht.htbh as hth,
  326. ap.lssl as bdsl,
  327. ht.lssl as htsl,
  328. ht.qpdj as qpj,
  329. ht.cjdj as cjj,
  330. (select lysl from ty_refund_notice rn where rn.htbm = ht.htbm and rn.zt = '92000400') as lysl,
  331. (select wysl from ty_refund_notice rn where rn.htbm = ht.htbm and rn.zt = '92000400') as wysl,
  332. CASE ht.jylx
  333. WHEN '0' THEN ht.cmmc
  334. WHEN '1' THEN ht.sgmc
  335. ELSE NULL
  336. END as cjkh,
  337. (select wm_concat(kh.khmc) from ty_jycc_khxx kh where kh.wtbh=cc.wtbm) as bmkh,
  338. ap.dwmc as ccdw,
  339. ap.ccdd as ch,
  340. ht.je as htje,
  341. cc.sxfl as khsxfl,
  342. cc.lybzj as lybzj,
  343. cc.jybzj as jybzj
  344. from ty_jycrkap ap
  345. left join ty_jycc cc on cc.wtbm = ap.wtbm
  346. left join ty_jyht ht on ap.bdbm = ht.bdbm
  347. left join ty_jycrkwt wt on wt.wtbm = ap.wtbm
  348. <where>
  349. <if test="jyrqStart != null and jyrqStart != ''">
  350. and cc.jyrq &gt;= to_date(#{jyrqStart}, 'yyyy-mm-dd')
  351. </if>
  352. <if test="jyrqEnd != null and jyrqEnd != ''">
  353. and cc.jyrq &lt;= to_date(#{jyrqEnd}, 'yyyy-mm-dd')
  354. </if>
  355. <!-- 流拍 -->
  356. <if test="jyjg == '1'.toString()">
  357. and to_date(to_date(cc.jyrq,'yyyy-MM-dd')+2,'yyyy-MM-dd') &lt; to_date(sysdate,'yyyy-MM-dd') and ht.htbh is null
  358. </if>
  359. <!-- 成交 -->
  360. <if test="jyjg == '2'.toString()">
  361. and ht.htbh is not null
  362. </if>
  363. <!-- 待维护 -->
  364. <if test="jyjg == '3'.toString()">
  365. and to_date(to_date(cc.jyrq,'yyyy-MM-dd')+2,'yyyy-MM-dd') &gt;= to_date(sysdate,'yyyy-MM-dd') and ht.htbh is null
  366. </if>
  367. <if test="jylx != null and jylx != ''">
  368. and ap.aplx = #{jylx}
  369. </if>
  370. <if test="jyjb != null and jyjb != ''">
  371. and wt.lsxzbm = #{jyjb}
  372. </if>
  373. <if test="jyfs != null and jyfs != ''">
  374. and wt.jyfs = #{jyfs}
  375. </if>
  376. <if test="hth != null and hth != ''">
  377. and ht.htbh like '%'||#{hth}||'%'
  378. </if>
  379. <if test="pzbm != null and pzbm != ''">
  380. and ap.pzbm = #{pzbm}
  381. </if>
  382. <if test="cc != null and cc != ''">
  383. and cc.apcc like '%'||#{cc}||'%'
  384. </if>
  385. <if test="wtf != null and wtf != ''">
  386. and cc.wtfmc like '%'||#{wtf}||'%'
  387. </if>
  388. </where>
  389. order by cc.jyrq desc,cc.apcc desc
  390. </select>
  391. <select id="selectDcjyhzPage" resultType="com.unis.transaction.server.entity.tradeplan.DcJyHzzb">
  392. SELECT main.cc,
  393. main.ccbh,
  394. to_char(main.jyrq,'yyyy-MM-dd') as jyrq,
  395. main.wtf,
  396. main.jyjb,
  397. main.jylx,
  398. main.jylxmc,
  399. main.jyfs,
  400. main.jyfsmc,
  401. main.pzmc,
  402. main.pzbm,
  403. SUM(CAST(main.bdsl AS decimal)) as bdsl,
  404. SUM(CAST(main.htsl AS decimal)) as htsl,
  405. SUM(rn.lysl) as lysl,
  406. SUM(rn.wysl) as wysl,
  407. SUM(CAST(main.htje AS decimal)) as htje,
  408. SUM(rn.lysl * main.cjdj) as lyje,
  409. SUM((main.sxfl / 100) * main.htje) as sxfje
  410. FROM (SELECT cc.apcc as cc,
  411. cc.ccbh as ccbh,
  412. cc.jyrq as jyrq,
  413. cc.wtfmc as wtf,
  414. wt.lsxzbm as jyjb,
  415. CASE ap.aplx
  416. WHEN '0' THEN '采购'
  417. WHEN '1' THEN '销售'
  418. ELSE NULL
  419. END as jylxmc,
  420. ap.aplx as jylx,
  421. wt.jyfs as jyfs,
  422. wt.jyfsmc as jyfsmc,
  423. ap.pzmc as pzmc,
  424. ap.pzbm as pzbm,
  425. ap.lssl as bdsl,
  426. ht.lssl as htsl,
  427. ht.je as htje,
  428. ht.htbm as htbm,
  429. ht.cjdj as cjdj,
  430. cc.sxfl as sxfl
  431. FROM ty_jycc cc
  432. LEFT JOIN
  433. ty_jycrkap ap ON cc.wtbm = ap.wtbm
  434. LEFT JOIN
  435. ty_jyht ht ON ap.bdbm = ht.bdbm
  436. LEFT JOIN
  437. ty_jycrkwt wt ON wt.wtbm = ap.wtbm
  438. <!--where ht.htbm is not null and ht.htbm != ''-->
  439. ) as main
  440. LEFT JOIN
  441. ty_refund_notice rn ON rn.htbm = main.htbm AND rn.zt = '92000400'
  442. <where>
  443. <if test="jyrqStart != null and jyrqStart != ''">
  444. and main.jyrq &gt;= to_date(#{jyrqStart}, 'yyyy-mm-dd')
  445. </if>
  446. <if test="jyrqEnd != null and jyrqEnd != ''">
  447. and main.jyrq &lt;= to_date(#{jyrqEnd}, 'yyyy-mm-dd')
  448. </if>
  449. <if test="jylx != null and jylx != ''">
  450. and main.jylx = #{jylx}
  451. </if>
  452. <if test="jyjb != null and jyjb != ''">
  453. and main.jyjb = #{jyjb}
  454. </if>
  455. <if test="jyfs != null and jyfs != ''">
  456. and main.jyfs = #{jyfs}
  457. </if>
  458. <if test="pzbm != null and pzbm != ''">
  459. and main.pzbm = #{pzbm}
  460. </if>
  461. <if test="cc != null and cc != ''">
  462. and main.cc like '%'||#{cc}||'%'
  463. </if>
  464. <if test="wtf != null and wtf != ''">
  465. and main.wtf like '%'||#{wtf}||'%'
  466. </if>
  467. </where>
  468. GROUP BY main.cc, main.ccbh,main.jylxmc,main.jylx, main.jyrq, main.wtf, main.jyjb, main.jylxmc, main.jyfs, main.jyfsmc,
  469. main.pzmc, main.pzbm order by main.jyrq desc,main.cc desc
  470. </select>
  471. <select id="dcjyhzExport" resultType="com.unis.transaction.server.entity.tradeplan.DcJyHzzb">
  472. SELECT main.cc,
  473. main.ccbh,
  474. to_char(main.jyrq,'yyyy-MM-dd') as jyrq,
  475. main.wtf,
  476. main.jyjb,
  477. main.jylx,
  478. main.jylxmc,
  479. main.jyfs,
  480. main.jyfsmc,
  481. main.pzmc,
  482. main.pzbm,
  483. SUM(CAST(main.bdsl AS decimal)) as bdsl,
  484. SUM(CAST(main.htsl AS decimal)) as htsl,
  485. SUM(rn.lysl) as lysl,
  486. SUM(rn.wysl) as wysl,
  487. SUM(CAST(main.htje AS decimal)) as htje,
  488. SUM(rn.lysl * main.cjdj) as lyje,
  489. SUM((main.sxfl / 100) * main.htje) as sxfje
  490. FROM (SELECT cc.apcc as cc,
  491. cc.ccbh as ccbh,
  492. cc.jyrq as jyrq,
  493. cc.wtfmc as wtf,
  494. wt.lsxzbm as jyjb,
  495. CASE ap.aplx
  496. WHEN '0' THEN '采购'
  497. WHEN '1' THEN '销售'
  498. ELSE NULL
  499. END as jylxmc,
  500. ap.aplx as jylx,
  501. wt.jyfs as jyfs,
  502. wt.jyfsmc as jyfsmc,
  503. ap.pzmc as pzmc,
  504. ap.pzbm as pzbm,
  505. ap.lssl as bdsl,
  506. ht.lssl as htsl,
  507. ht.je as htje,
  508. ht.htbm as htbm,
  509. ht.cjdj as cjdj,
  510. cc.sxfl as sxfl
  511. FROM ty_jycc cc
  512. LEFT JOIN
  513. ty_jycrkap ap ON cc.wtbm = ap.wtbm
  514. LEFT JOIN
  515. ty_jyht ht ON ap.bdbm = ht.bdbm
  516. LEFT JOIN
  517. ty_jycrkwt wt ON wt.wtbm = ap.wtbm
  518. <!--where ht.htbm is not null and ht.htbm != ''-->
  519. ) as main
  520. LEFT JOIN
  521. ty_refund_notice rn ON rn.htbm = main.htbm AND rn.zt = '92000400'
  522. <where>
  523. <if test="jyrqStart != null and jyrqStart != ''">
  524. and main.jyrq &gt;= to_date(#{jyrqStart}, 'yyyy-mm-dd')
  525. </if>
  526. <if test="jyrqEnd != null and jyrqEnd != ''">
  527. and main.jyrq &lt;= to_date(#{jyrqEnd}, 'yyyy-mm-dd')
  528. </if>
  529. <if test="jylx != null and jylx != ''">
  530. and main.jylx = #{jylx}
  531. </if>
  532. <if test="jyjb != null and jyjb != ''">
  533. and main.jyjb = #{jyjb}
  534. </if>
  535. <if test="jyfs != null and jyfs != ''">
  536. and main.jyfs = #{jyfs}
  537. </if>
  538. <if test="pzbm != null and pzbm != ''">
  539. and main.pzbm = #{pzbm}
  540. </if>
  541. <if test="cc != null and cc != ''">
  542. and main.cc like '%'||#{cc}||'%'
  543. </if>
  544. <if test="wtf != null and wtf != ''">
  545. and main.wtf like '%'||#{wtf}||'%'
  546. </if>
  547. </where>
  548. GROUP BY main.cc, main.ccbh,main.jylxmc,main.jylx, main.jyrq, main.wtf, main.jyjb, main.jylxmc, main.jyfs, main.jyfsmc,
  549. main.pzmc, main.pzbm order by main.jyrq desc,main.cc desc
  550. </select>
  551. <select id="selectDcjybzxx" resultType="com.unis.transaction.server.entity.tradeplan.Dcjybzxx">
  552. select * from ty_dcjybzxx;
  553. </select>
  554. </mapper>