BusinessAgentBgmxzMapper.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  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.chinaitop.depot.agent.bgz.mapper.BusinessAgentBgmxzMapper">
  4. <resultMap id="BaseResultMap" type="com.chinaitop.depot.agent.bgz.model.BusinessAgentBgmxz">
  5. <id column="id" jdbcType="INTEGER" property="id" />
  6. <result column="org_id" jdbcType="INTEGER" property="orgId" />
  7. <result column="agent_id" jdbcType="INTEGER" property="agentId" />
  8. <result column="szlk_org_id" jdbcType="INTEGER" property="szlkOrgId" />
  9. <result column="house_id" jdbcType="VARCHAR" property="houseId" />
  10. <result column="ware_id" jdbcType="VARCHAR" property="wareId" />
  11. <result column="lspz" jdbcType="INTEGER" property="lspz" />
  12. <result column="lsxz" jdbcType="INTEGER" property="lsxz" />
  13. <result column="lsdj" jdbcType="INTEGER" property="lsdj" />
  14. <result column="fssj" jdbcType="TIMESTAMP" property="fssj" />
  15. <result column="srsl" jdbcType="DECIMAL" property="srsl" />
  16. <result column="zcsl" jdbcType="DECIMAL" property="zcsl" />
  17. <result column="kcsl" jdbcType="DECIMAL" property="kcsl" />
  18. <result column="lqgs_org_id" jdbcType="INTEGER" property="lqgsOrgId" />
  19. <result column="is_jz" jdbcType="INTEGER" property="isJz" />
  20. <result column="sjly" jdbcType="INTEGER" property="sjly" />
  21. <result column="create_person" jdbcType="VARCHAR" property="createPerson" />
  22. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  23. <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
  24. </resultMap>
  25. <sql id="Example_Where_Clause">
  26. <where>
  27. <foreach collection="oredCriteria" item="criteria" separator="or">
  28. <if test="criteria.valid">
  29. <trim prefix="(" prefixOverrides="and" suffix=")">
  30. <foreach collection="criteria.criteria" item="criterion">
  31. <choose>
  32. <when test="criterion.noValue">
  33. and ${criterion.condition}
  34. </when>
  35. <when test="criterion.singleValue">
  36. and ${criterion.condition} #{criterion.value}
  37. </when>
  38. <when test="criterion.betweenValue">
  39. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  40. </when>
  41. <when test="criterion.listValue">
  42. and ${criterion.condition}
  43. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  44. #{listItem}
  45. </foreach>
  46. </when>
  47. </choose>
  48. </foreach>
  49. </trim>
  50. </if>
  51. </foreach>
  52. </where>
  53. </sql>
  54. <sql id="Update_By_Example_Where_Clause">
  55. <where>
  56. <foreach collection="example.oredCriteria" item="criteria" separator="or">
  57. <if test="criteria.valid">
  58. <trim prefix="(" prefixOverrides="and" suffix=")">
  59. <foreach collection="criteria.criteria" item="criterion">
  60. <choose>
  61. <when test="criterion.noValue">
  62. and ${criterion.condition}
  63. </when>
  64. <when test="criterion.singleValue">
  65. and ${criterion.condition} #{criterion.value}
  66. </when>
  67. <when test="criterion.betweenValue">
  68. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  69. </when>
  70. <when test="criterion.listValue">
  71. and ${criterion.condition}
  72. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  73. #{listItem}
  74. </foreach>
  75. </when>
  76. </choose>
  77. </foreach>
  78. </trim>
  79. </if>
  80. </foreach>
  81. </where>
  82. </sql>
  83. <sql id="Base_Column_List">
  84. id, org_id, agent_id, szlk_org_id, house_id, ware_id, lspz, lsxz, lsdj, fssj, srsl,
  85. zcsl, kcsl, lqgs_org_id, is_jz, sjly, create_person, create_date, updatetime
  86. </sql>
  87. <select id="selectByExample" parameterType="com.chinaitop.depot.agent.bgz.model.BusinessAgentBgmxzExample" resultMap="BaseResultMap">
  88. select
  89. <if test="distinct">
  90. distinct
  91. </if>
  92. <include refid="Base_Column_List" />
  93. from business_agent_bgmxz
  94. <if test="_parameter != null">
  95. <include refid="Example_Where_Clause" />
  96. </if>
  97. <if test="orderByClause != null">
  98. order by ${orderByClause}
  99. </if>
  100. </select>
  101. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  102. select
  103. <include refid="Base_Column_List" />
  104. from business_agent_bgmxz
  105. where id = #{id,jdbcType=INTEGER}
  106. </select>
  107. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  108. delete from business_agent_bgmxz
  109. where id = #{id,jdbcType=INTEGER}
  110. </delete>
  111. <delete id="deleteByExample" parameterType="com.chinaitop.depot.agent.bgz.model.BusinessAgentBgmxzExample">
  112. delete from business_agent_bgmxz
  113. <if test="_parameter != null">
  114. <include refid="Example_Where_Clause" />
  115. </if>
  116. </delete>
  117. <insert id="insert" parameterType="com.chinaitop.depot.agent.bgz.model.BusinessAgentBgmxz">
  118. insert into business_agent_bgmxz (id, org_id, agent_id,
  119. szlk_org_id, house_id, ware_id,
  120. lspz, lsxz, lsdj, fssj,
  121. srsl, zcsl, kcsl, lqgs_org_id,
  122. is_jz, sjly, create_person,
  123. create_date, updatetime)
  124. values (#{id,jdbcType=INTEGER}, #{orgId,jdbcType=INTEGER}, #{agentId,jdbcType=INTEGER},
  125. #{szlkOrgId,jdbcType=INTEGER}, #{houseId,jdbcType=VARCHAR}, #{wareId,jdbcType=VARCHAR},
  126. #{lspz,jdbcType=INTEGER}, #{lsxz,jdbcType=INTEGER}, #{lsdj,jdbcType=INTEGER}, #{fssj,jdbcType=TIMESTAMP},
  127. #{srsl,jdbcType=DECIMAL}, #{zcsl,jdbcType=DECIMAL}, #{kcsl,jdbcType=DECIMAL}, #{lqgsOrgId,jdbcType=INTEGER},
  128. #{isJz,jdbcType=INTEGER}, #{sjly,jdbcType=INTEGER}, #{createPerson,jdbcType=VARCHAR},
  129. #{createDate,jdbcType=TIMESTAMP}, #{updatetime,jdbcType=TIMESTAMP})
  130. </insert>
  131. <insert id="insertSelective" parameterType="com.chinaitop.depot.agent.bgz.model.BusinessAgentBgmxz">
  132. insert into business_agent_bgmxz
  133. <trim prefix="(" suffix=")" suffixOverrides=",">
  134. <if test="id != null">
  135. id,
  136. </if>
  137. <if test="orgId != null">
  138. org_id,
  139. </if>
  140. <if test="agentId != null">
  141. agent_id,
  142. </if>
  143. <if test="szlkOrgId != null">
  144. szlk_org_id,
  145. </if>
  146. <if test="houseId != null">
  147. house_id,
  148. </if>
  149. <if test="wareId != null">
  150. ware_id,
  151. </if>
  152. <if test="lspz != null">
  153. lspz,
  154. </if>
  155. <if test="lsxz != null">
  156. lsxz,
  157. </if>
  158. <if test="lsdj != null">
  159. lsdj,
  160. </if>
  161. <if test="fssj != null">
  162. fssj,
  163. </if>
  164. <if test="srsl != null">
  165. srsl,
  166. </if>
  167. <if test="zcsl != null">
  168. zcsl,
  169. </if>
  170. <if test="kcsl != null">
  171. kcsl,
  172. </if>
  173. <if test="lqgsOrgId != null">
  174. lqgs_org_id,
  175. </if>
  176. <if test="isJz != null">
  177. is_jz,
  178. </if>
  179. <if test="sjly != null">
  180. sjly,
  181. </if>
  182. <if test="createPerson != null">
  183. create_person,
  184. </if>
  185. <if test="createDate != null">
  186. create_date,
  187. </if>
  188. <if test="updatetime != null">
  189. updatetime,
  190. </if>
  191. </trim>
  192. <trim prefix="values (" suffix=")" suffixOverrides=",">
  193. <if test="id != null">
  194. #{id,jdbcType=INTEGER},
  195. </if>
  196. <if test="orgId != null">
  197. #{orgId,jdbcType=INTEGER},
  198. </if>
  199. <if test="agentId != null">
  200. #{agentId,jdbcType=INTEGER},
  201. </if>
  202. <if test="szlkOrgId != null">
  203. #{szlkOrgId,jdbcType=INTEGER},
  204. </if>
  205. <if test="houseId != null">
  206. #{houseId,jdbcType=VARCHAR},
  207. </if>
  208. <if test="wareId != null">
  209. #{wareId,jdbcType=VARCHAR},
  210. </if>
  211. <if test="lspz != null">
  212. #{lspz,jdbcType=INTEGER},
  213. </if>
  214. <if test="lsxz != null">
  215. #{lsxz,jdbcType=INTEGER},
  216. </if>
  217. <if test="lsdj != null">
  218. #{lsdj,jdbcType=INTEGER},
  219. </if>
  220. <if test="fssj != null">
  221. #{fssj,jdbcType=TIMESTAMP},
  222. </if>
  223. <if test="srsl != null">
  224. #{srsl,jdbcType=DECIMAL},
  225. </if>
  226. <if test="zcsl != null">
  227. #{zcsl,jdbcType=DECIMAL},
  228. </if>
  229. <if test="kcsl != null">
  230. #{kcsl,jdbcType=DECIMAL},
  231. </if>
  232. <if test="lqgsOrgId != null">
  233. #{lqgsOrgId,jdbcType=INTEGER},
  234. </if>
  235. <if test="isJz != null">
  236. #{isJz,jdbcType=INTEGER},
  237. </if>
  238. <if test="sjly != null">
  239. #{sjly,jdbcType=INTEGER},
  240. </if>
  241. <if test="createPerson != null">
  242. #{createPerson,jdbcType=VARCHAR},
  243. </if>
  244. <if test="createDate != null">
  245. #{createDate,jdbcType=TIMESTAMP},
  246. </if>
  247. <if test="updatetime != null">
  248. #{updatetime,jdbcType=TIMESTAMP},
  249. </if>
  250. </trim>
  251. </insert>
  252. <select id="countByExample" parameterType="com.chinaitop.depot.agent.bgz.model.BusinessAgentBgmxzExample" resultType="java.lang.Integer">
  253. select count(*) from business_agent_bgmxz
  254. <if test="_parameter != null">
  255. <include refid="Example_Where_Clause" />
  256. </if>
  257. </select>
  258. <update id="updateByExampleSelective" parameterType="map">
  259. update business_agent_bgmxz
  260. <set>
  261. <if test="record.id != null">
  262. id = #{record.id,jdbcType=INTEGER},
  263. </if>
  264. <if test="record.orgId != null">
  265. org_id = #{record.orgId,jdbcType=INTEGER},
  266. </if>
  267. <if test="record.agentId != null">
  268. agent_id = #{record.agentId,jdbcType=INTEGER},
  269. </if>
  270. <if test="record.szlkOrgId != null">
  271. szlk_org_id = #{record.szlkOrgId,jdbcType=INTEGER},
  272. </if>
  273. <if test="record.houseId != null">
  274. house_id = #{record.houseId,jdbcType=VARCHAR},
  275. </if>
  276. <if test="record.wareId != null">
  277. ware_id = #{record.wareId,jdbcType=VARCHAR},
  278. </if>
  279. <if test="record.lspz != null">
  280. lspz = #{record.lspz,jdbcType=INTEGER},
  281. </if>
  282. <if test="record.lsxz != null">
  283. lsxz = #{record.lsxz,jdbcType=INTEGER},
  284. </if>
  285. <if test="record.lsdj != null">
  286. lsdj = #{record.lsdj,jdbcType=INTEGER},
  287. </if>
  288. <if test="record.fssj != null">
  289. fssj = #{record.fssj,jdbcType=TIMESTAMP},
  290. </if>
  291. <if test="record.srsl != null">
  292. srsl = #{record.srsl,jdbcType=DECIMAL},
  293. </if>
  294. <if test="record.zcsl != null">
  295. zcsl = #{record.zcsl,jdbcType=DECIMAL},
  296. </if>
  297. <if test="record.kcsl != null">
  298. kcsl = #{record.kcsl,jdbcType=DECIMAL},
  299. </if>
  300. <if test="record.lqgsOrgId != null">
  301. lqgs_org_id = #{record.lqgsOrgId,jdbcType=INTEGER},
  302. </if>
  303. <if test="record.isJz != null">
  304. is_jz = #{record.isJz,jdbcType=INTEGER},
  305. </if>
  306. <if test="record.sjly != null">
  307. sjly = #{record.sjly,jdbcType=INTEGER},
  308. </if>
  309. <if test="record.createPerson != null">
  310. create_person = #{record.createPerson,jdbcType=VARCHAR},
  311. </if>
  312. <if test="record.createDate != null">
  313. create_date = #{record.createDate,jdbcType=TIMESTAMP},
  314. </if>
  315. <if test="record.updatetime != null">
  316. updatetime = #{record.updatetime,jdbcType=TIMESTAMP},
  317. </if>
  318. </set>
  319. <if test="_parameter != null">
  320. <include refid="Update_By_Example_Where_Clause" />
  321. </if>
  322. </update>
  323. <update id="updateByExample" parameterType="map">
  324. update business_agent_bgmxz
  325. set id = #{record.id,jdbcType=INTEGER},
  326. org_id = #{record.orgId,jdbcType=INTEGER},
  327. agent_id = #{record.agentId,jdbcType=INTEGER},
  328. szlk_org_id = #{record.szlkOrgId,jdbcType=INTEGER},
  329. house_id = #{record.houseId,jdbcType=VARCHAR},
  330. ware_id = #{record.wareId,jdbcType=VARCHAR},
  331. lspz = #{record.lspz,jdbcType=INTEGER},
  332. lsxz = #{record.lsxz,jdbcType=INTEGER},
  333. lsdj = #{record.lsdj,jdbcType=INTEGER},
  334. fssj = #{record.fssj,jdbcType=TIMESTAMP},
  335. srsl = #{record.srsl,jdbcType=DECIMAL},
  336. zcsl = #{record.zcsl,jdbcType=DECIMAL},
  337. kcsl = #{record.kcsl,jdbcType=DECIMAL},
  338. lqgs_org_id = #{record.lqgsOrgId,jdbcType=INTEGER},
  339. is_jz = #{record.isJz,jdbcType=INTEGER},
  340. sjly = #{record.sjly,jdbcType=INTEGER},
  341. create_person = #{record.createPerson,jdbcType=VARCHAR},
  342. create_date = #{record.createDate,jdbcType=TIMESTAMP},
  343. updatetime = #{record.updatetime,jdbcType=TIMESTAMP}
  344. <if test="_parameter != null">
  345. <include refid="Update_By_Example_Where_Clause" />
  346. </if>
  347. </update>
  348. <update id="updateByPrimaryKeySelective" parameterType="com.chinaitop.depot.agent.bgz.model.BusinessAgentBgmxz">
  349. update business_agent_bgmxz
  350. <set>
  351. <if test="orgId != null">
  352. org_id = #{orgId,jdbcType=INTEGER},
  353. </if>
  354. <if test="agentId != null">
  355. agent_id = #{agentId,jdbcType=INTEGER},
  356. </if>
  357. <if test="szlkOrgId != null">
  358. szlk_org_id = #{szlkOrgId,jdbcType=INTEGER},
  359. </if>
  360. <if test="houseId != null">
  361. house_id = #{houseId,jdbcType=VARCHAR},
  362. </if>
  363. <if test="wareId != null">
  364. ware_id = #{wareId,jdbcType=VARCHAR},
  365. </if>
  366. <if test="lspz != null">
  367. lspz = #{lspz,jdbcType=INTEGER},
  368. </if>
  369. <if test="lsxz != null">
  370. lsxz = #{lsxz,jdbcType=INTEGER},
  371. </if>
  372. <if test="lsdj != null">
  373. lsdj = #{lsdj,jdbcType=INTEGER},
  374. </if>
  375. <if test="fssj != null">
  376. fssj = #{fssj,jdbcType=TIMESTAMP},
  377. </if>
  378. <if test="srsl != null">
  379. srsl = #{srsl,jdbcType=DECIMAL},
  380. </if>
  381. <if test="zcsl != null">
  382. zcsl = #{zcsl,jdbcType=DECIMAL},
  383. </if>
  384. <if test="kcsl != null">
  385. kcsl = #{kcsl,jdbcType=DECIMAL},
  386. </if>
  387. <if test="lqgsOrgId != null">
  388. lqgs_org_id = #{lqgsOrgId,jdbcType=INTEGER},
  389. </if>
  390. <if test="isJz != null">
  391. is_jz = #{isJz,jdbcType=INTEGER},
  392. </if>
  393. <if test="sjly != null">
  394. sjly = #{sjly,jdbcType=INTEGER},
  395. </if>
  396. <if test="createPerson != null">
  397. create_person = #{createPerson,jdbcType=VARCHAR},
  398. </if>
  399. <if test="createDate != null">
  400. create_date = #{createDate,jdbcType=TIMESTAMP},
  401. </if>
  402. <if test="updatetime != null">
  403. updatetime = #{updatetime,jdbcType=TIMESTAMP},
  404. </if>
  405. </set>
  406. where id = #{id,jdbcType=INTEGER}
  407. </update>
  408. <update id="updateByPrimaryKey" parameterType="com.chinaitop.depot.agent.bgz.model.BusinessAgentBgmxz">
  409. update business_agent_bgmxz
  410. set org_id = #{orgId,jdbcType=INTEGER},
  411. agent_id = #{agentId,jdbcType=INTEGER},
  412. szlk_org_id = #{szlkOrgId,jdbcType=INTEGER},
  413. house_id = #{houseId,jdbcType=VARCHAR},
  414. ware_id = #{wareId,jdbcType=VARCHAR},
  415. lspz = #{lspz,jdbcType=INTEGER},
  416. lsxz = #{lsxz,jdbcType=INTEGER},
  417. lsdj = #{lsdj,jdbcType=INTEGER},
  418. fssj = #{fssj,jdbcType=TIMESTAMP},
  419. srsl = #{srsl,jdbcType=DECIMAL},
  420. zcsl = #{zcsl,jdbcType=DECIMAL},
  421. kcsl = #{kcsl,jdbcType=DECIMAL},
  422. lqgs_org_id = #{lqgsOrgId,jdbcType=INTEGER},
  423. is_jz = #{isJz,jdbcType=INTEGER},
  424. sjly = #{sjly,jdbcType=INTEGER},
  425. create_person = #{createPerson,jdbcType=VARCHAR},
  426. create_date = #{createDate,jdbcType=TIMESTAMP},
  427. updatetime = #{updatetime,jdbcType=TIMESTAMP}
  428. where id = #{id,jdbcType=INTEGER}
  429. </update>
  430. <!-- 查询分仓保管账列表 -->
  431. <select id="selectFcbgzList" parameterType="java.util.Map" resultType="java.util.Map">
  432. SELECT datas.* FROM (
  433. select
  434. a.org_id orgId,
  435. DATE_FORMAT(a.fssj,'%Y-%m-%d') as fssj,
  436. a.agent_id agentId,
  437. b.agent_name agentName,
  438. a.szlk_org_id dckId,
  439. c.agent_depot_name agentDepotName,
  440. a.house_id houseId,
  441. d.storehouse_name houseName,
  442. a.ware_id wareId,
  443. e.warehouse_name wareName,
  444. a.lsxz,
  445. a.lspz,
  446. a.lsdj,
  447. sum(a.srsl) as srsl,
  448. sum(a.zcsl) as zcsl,
  449. a.kcsl,
  450. c.depot_id isJz
  451. from (SELECT * from business_agent_bgmxz WHERE 1=1 AND SUBSTR(house_id,1,2)!='YG' ORDER BY fssj DESC) a
  452. LEFT JOIN business_agent b ON b.id=a.agent_id
  453. LEFT JOIN business_agent_depot c ON c.id=a.szlk_org_id
  454. LEFT JOIN basic_storehouse d ON d.storehouse_id=a.house_id
  455. LEFT JOIN basic_warehouse e ON e.warehouse_id=a.ware_id
  456. where 1=1
  457. group by a.agent_id, a.szlk_org_id, a.house_id, a.ware_id, a.lsxz, a.lspz, DATE_FORMAT(a.fssj,'%Y-%m-%d')
  458. UNION
  459. select
  460. a.org_id orgId,
  461. DATE_FORMAT(a.fssj,'%Y-%m-%d') as fssj,
  462. a.agent_id agentId,
  463. b.agent_name agentName,
  464. a.szlk_org_id dckId,
  465. c.agent_depot_name agentDepotName,
  466. a.house_id houseId,
  467. d.storageTank_name houseName,
  468. a.house_id wareId,
  469. '' wareName,
  470. a.lsxz,
  471. a.lspz,
  472. a.lsdj,
  473. sum(a.srsl) as srsl,
  474. sum(a.zcsl) as zcsl,
  475. a.kcsl,
  476. c.depot_id isJz
  477. from (SELECT * from business_agent_bgmxz WHERE 1=1 AND SUBSTR(house_id,1,2)='YG' AND sjly=1 ORDER BY fssj DESC) a
  478. LEFT JOIN business_agent b ON b.id=a.agent_id
  479. LEFT JOIN business_agent_depot c ON c.id=a.szlk_org_id
  480. LEFT JOIN basic_tank d ON d.id=a.house_id
  481. where 1=1
  482. group by a.agent_id, a.szlk_org_id, a.house_id, a.ware_id, a.lsxz, a.lspz, DATE_FORMAT(a.fssj,'%Y-%m-%d')
  483. UNION
  484. select
  485. a.org_id orgId,
  486. DATE_FORMAT(a.fssj,'%Y-%m-%d') as fssj,
  487. a.agent_id agentId,
  488. b.agent_name agentName,
  489. a.szlk_org_id dckId,
  490. c.agent_depot_name agentDepotName,
  491. a.house_id houseId,
  492. d.tank_name houseName,
  493. a.house_id wareId,
  494. '' wareName,
  495. a.lsxz,
  496. a.lspz,
  497. a.lsdj,
  498. sum(a.srsl) as srsl,
  499. sum(a.zcsl) as zcsl,
  500. a.kcsl,
  501. c.depot_id isJz
  502. from (SELECT * from business_agent_bgmxz WHERE 1=1 AND SUBSTR(house_id,1,2)='YG' AND sjly=0 ORDER BY fssj DESC) a
  503. LEFT JOIN business_agent b ON b.id=a.agent_id
  504. LEFT JOIN business_agent_depot c ON c.id=a.szlk_org_id
  505. LEFT JOIN business_agent_tank d ON d.id=a.house_id
  506. where 1=1
  507. group by a.agent_id, a.szlk_org_id, a.house_id, a.ware_id, a.lsxz, a.lspz, DATE_FORMAT(a.fssj,'%Y-%m-%d')
  508. ) datas WHERE 1=1
  509. <if test="orgId != null">
  510. AND datas.orgId = #{orgId,jdbcType=INTEGER}
  511. </if>
  512. <if test="agentId != null">
  513. AND datas.agentId = #{agentId,jdbcType=INTEGER}
  514. </if>
  515. <if test="szlkOrgId != null">
  516. AND datas.dckId = #{szlkOrgId,jdbcType=INTEGER}
  517. </if>
  518. <if test="houseId != null">
  519. AND datas.houseId = #{houseId,jdbcType=VARCHAR}
  520. </if>
  521. <if test="wareId != null">
  522. AND datas.wareId = #{wareId,jdbcType=VARCHAR}
  523. </if>
  524. <if test="lspz != null">
  525. AND datas.lspz = #{lspz,jdbcType=INTEGER}
  526. </if>
  527. <if test="lsxz != null">
  528. AND datas.lsxz = #{lsxz,jdbcType=INTEGER}
  529. </if>
  530. <if test="fssj != null">
  531. AND datas.fssj = #{fssj}
  532. </if>
  533. ORDER BY datas.fssj DESC
  534. </select>
  535. <select id="selectByExampleNew" parameterType="java.util.Map" resultMap="BaseResultMap">
  536. select datas.* from (
  537. select
  538. <if test="distinct">
  539. distinct
  540. </if>
  541. a.*,b.agent_name agentName,c.agent_depot_name agentDepotName,d.storehouse_name houseName,e.warehouse_name wareName
  542. from business_agent_bgmxz a
  543. LEFT JOIN business_agent b ON b.id=a.agent_id
  544. LEFT JOIN business_agent_depot c ON c.id=a.szlk_org_id
  545. LEFT JOIN basic_storehouse d ON d.storehouse_id=a.house_id
  546. LEFT JOIN basic_warehouse e ON e.warehouse_id=a.ware_id
  547. WHERE 1=1
  548. AND SUBSTR(a.house_id, 1, 2) != 'YG'
  549. AND a.ware_id != ''
  550. AND a.ware_id is not null
  551. <if test="agentId != null">
  552. and a.agent_id = ${agentId}
  553. </if>
  554. <if test="szlkOrgId != null">
  555. and a.szlk_org_id = ${szlkOrgId}
  556. </if>
  557. <if test="houseId != null">
  558. and a.house_id = #{houseId,jdbcType=VARCHAR}
  559. </if>
  560. <if test="wareId != null">
  561. and a.ware_id = #{wareId,jdbcType=VARCHAR}
  562. </if>
  563. <if test="orgId != null">
  564. and a.org_id = ${orgId}
  565. </if>
  566. <if test="startTime != null">
  567. and a.fssj >= DATE_FORMAT(#{startTime},'%Y-%m-%d %H:%i:%s')
  568. </if>
  569. <if test="endTime != null">
  570. and a.fssj &lt;= DATE_FORMAT(#{endTime},'%Y-%m-%d %H:%i:%s')
  571. </if>
  572. UNION
  573. select
  574. <if test="distinct">
  575. distinct
  576. </if>
  577. a.*,b.agent_name agentName,c.agent_depot_name agentDepotName,d.storageTank_name houseName,'' wareName
  578. from business_agent_bgmxz a
  579. LEFT JOIN business_agent b ON b.id=a.agent_id
  580. LEFT JOIN business_agent_depot c ON c.id=a.szlk_org_id
  581. LEFT JOIN basic_tank d ON d.id=a.house_id
  582. WHERE 1=1
  583. AND a.sjly=1
  584. AND SUBSTR(a.house_id,1,2) = 'YG'
  585. <if test="agentId != null">
  586. and a.agent_id = ${agentId}
  587. </if>
  588. <if test="szlkOrgId != null">
  589. and a.szlk_org_id = ${szlkOrgId}
  590. </if>
  591. <if test="houseId != null">
  592. and a.house_id = #{houseId,jdbcType=VARCHAR}
  593. </if>
  594. <if test="wareId != null">
  595. and a.ware_id = #{wareId,jdbcType=VARCHAR}
  596. </if>
  597. <if test="orgId != null">
  598. and a.org_id = ${orgId}
  599. </if>
  600. <if test="startTime != null">
  601. and a.fssj >= DATE_FORMAT(#{startTime},'%Y-%m-%d %H:%i:%s')
  602. </if>
  603. <if test="endTime != null">
  604. and a.fssj &lt;= DATE_FORMAT(#{endTime},'%Y-%m-%d %H:%i:%s')
  605. </if>
  606. UNION
  607. select
  608. <if test="distinct">
  609. distinct
  610. </if>
  611. a.*,b.agent_name agentName,c.agent_depot_name agentDepotName,d.tank_name houseName,'' wareName
  612. from business_agent_bgmxz a
  613. LEFT JOIN business_agent b ON b.id=a.agent_id
  614. LEFT JOIN business_agent_depot c ON c.id=a.szlk_org_id
  615. LEFT JOIN business_agent_tank d ON d.id=a.house_id
  616. WHERE 1=1
  617. AND a.sjly=0
  618. AND (a.ware_id='' OR a.ware_id is NULL)
  619. <if test="agentId != null">
  620. and a.agent_id = ${agentId}
  621. </if>
  622. <if test="szlkOrgId != null">
  623. and a.szlk_org_id = ${szlkOrgId}
  624. </if>
  625. <if test="houseId != null">
  626. and a.house_id = #{houseId,jdbcType=VARCHAR}
  627. </if>
  628. <if test="wareId != null">
  629. and a.ware_id = #{wareId,jdbcType=VARCHAR}
  630. </if>
  631. <if test="orgId != null">
  632. and a.org_id = ${orgId}
  633. </if>
  634. <if test="startTime != null">
  635. and a.fssj >= DATE_FORMAT(#{startTime},'%Y-%m-%d %H:%i:%s')
  636. </if>
  637. <if test="endTime != null">
  638. and a.fssj &lt;= DATE_FORMAT(#{endTime},'%Y-%m-%d %H:%i:%s')
  639. </if>
  640. ) datas where 1=1
  641. <if test="orderByClause != null">
  642. order by ${orderByClause}
  643. </if>
  644. </select>
  645. <!-- 查询代储库仓房货位和油罐信息 -->
  646. <select id="selectAgentHouseWareList" parameterType="java.util.Map" resultType="java.util.Map">
  647. SELECT
  648. a.depot_id unitid,
  649. c.warehouse_id hwh,
  650. c.bgmxz_tbsj modifydate
  651. FROM business_agent_depot a
  652. LEFT JOIN business_agent_storehouse b ON b.agent_depot_id=a.id
  653. LEFT JOIN business_agent_warehouse c ON c.agent_storehouse_id=b.id AND c.del_flag=1
  654. WHERE a.depot_id != 0 AND b.storehouse_id IS NOT NULL AND c.warehouse_id IS NOT NULL
  655. <if test="orgId != null">
  656. and c.org_id=#{orgId,jdbcType=INTEGER}
  657. </if>
  658. UNION
  659. SELECT
  660. a.depot_id unitid,
  661. b.tank_id hwh,
  662. b.bgmxz_tbsj modifydate
  663. FROM business_agent_depot a
  664. INNER JOIN business_agent_tank_exist b ON b.agent_depot_id = a.id
  665. <if test="orgId != null">
  666. AND b.org_id = #{orgId,jdbcType=INTEGER}
  667. </if>
  668. </select>
  669. </mapper>