TWarehouseAgreementMapper.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.warehouseBusiness.mapper.TWarehouseAgreementMapper">
  6. <resultMap type="TWarehouseAgreement" id="TWarehouseAgreementResult">
  7. <result property="rankNo" column="rank_no"/>
  8. <result property="fId" column="f_id"/>
  9. <result property="fBillno" column="f_billno"/>
  10. <result property="fContractno" column="f_contractno"/>
  11. <result property="fDeptid" column="f_deptid"/>
  12. <result property="fDeptName" column="f_deptname"/>
  13. <result property="fCorpid" column="f_corpid"/>
  14. <result property="fCorpName" column="f_corpname"/>
  15. <result property="fGoodsid" column="f_goodsid"/>
  16. <result property="fStltypeName" column="f_stltypename"/>
  17. <result property="fStltypeid" column="f_stltypeid"/>
  18. <result property="fFeetypeid" column="f_feetypeid"/>
  19. <result property="fFeetypeName" column="f_feetypename"/>
  20. <result property="tPackages" column="t_packages"/>
  21. <result property="fTrademodeid" column="f_trademodeid"/>
  22. <result property="fTrademodeName" column="f_trademodename"/>
  23. <result property="fFreedays" column="f_freedays"/>
  24. <result property="fBegindate" column="f_begindate"/>
  25. <result property="fEnddate" column="f_enddate"/>
  26. <result property="fBillstatus" column="f_billstatus"/>
  27. <result property="fStatus" column="f_status"/>
  28. <result property="delFlag" column="del_flag"/>
  29. <result property="createBy" column="create_by"/>
  30. <result property="createTime" column="create_time"/>
  31. <result property="updateBy" column="update_by"/>
  32. <result property="updateTime" column="update_time"/>
  33. <result property="remark" column="remark"/>
  34. <result property="fTaskTypeName" column="f_task_type_name"/>
  35. <result property="fTaskType" column="f_task_type"/>
  36. <result property="fDc" column="f_dc"/>
  37. <result property="fBilltype" column="f_billtype"/>
  38. <result property="fBilltypeName" column="f_billtype_name"/>
  39. <result property="fWarehouseid" column="f_warehouseid"/>
  40. </resultMap>
  41. <sql id="selectTWarehouseAgreementVo">
  42. select f_id,
  43. f_billno,
  44. f_contractno,
  45. f_deptid,
  46. f_corpid,
  47. f_goodsid,
  48. f_stltypeid,
  49. f_feetypeid,
  50. t_packages,
  51. f_trademodeid,
  52. f_freedays,
  53. f_begindate,
  54. f_enddate,
  55. f_billstatus,
  56. f_status,
  57. del_flag,
  58. create_by,
  59. create_time,
  60. update_by,
  61. update_time,
  62. remark,
  63. f_task_type,
  64. f_dc,
  65. f_billtype,
  66. f_billtype_name,
  67. f_warehouseid
  68. from t_warehouse_agreement
  69. </sql>
  70. <select id="selectTWarehouseAgreementList" parameterType="TWarehouseAgreement"
  71. resultMap="TWarehouseAgreementResult">
  72. select
  73. @rank:=@rank + 1 as rank_no,
  74. a.*
  75. from
  76. (
  77. select
  78. twg.f_id,
  79. twg.f_billno,
  80. twg.f_contractno,
  81. twg.f_deptid,
  82. dept.dept_name as f_deptname,
  83. corp.f_name as f_corpname,
  84. twg.f_goodsid,
  85. dict.dict_label as f_stltypename,
  86. twg.f_stltypeid,
  87. twg.f_feetypeid,
  88. CASE
  89. WHEN twg.f_feetypeid='D' THEN '收'
  90. WHEN twg.f_feetypeid='C' THEN '付'
  91. END as f_feetypename,
  92. twg.t_packages,
  93. twg.f_trademodeid,
  94. dttradmode.dict_label as f_trademodename,
  95. twg.f_freedays,
  96. twg.f_begindate,
  97. twg.f_enddate,
  98. CASE
  99. WHEN twg.f_billstatus=1 THEN '保存'
  100. WHEN twg.f_billstatus=2 THEN '暂存'
  101. WHEN twg.f_billstatus=3 THEN '审批驳回'
  102. WHEN twg.f_billstatus=4 THEN '提交审核'
  103. WHEN twg.f_billstatus=5 THEN '审核中'
  104. WHEN twg.f_billstatus=6 THEN '审核完成'
  105. END as f_billstatus,
  106. twg.f_status,
  107. twg.del_flag,
  108. twg.create_by,
  109. twg.create_time,
  110. twg.update_by,
  111. twg.update_time,
  112. twg.remark,
  113. CASE
  114. WHEN twg.f_task_type=1 THEN '车队作业费'
  115. WHEN twg.f_task_type=2 THEN '劳务作业费'
  116. END as f_task_type_name,
  117. twg.f_task_type,
  118. twg.f_dc,
  119. twg.f_billtype,
  120. twg.f_billtype_name,
  121. twg.f_warehouseid
  122. from t_warehouse_agreement twg
  123. LEFT JOIN t_corps corp ON corp.f_id = twg.f_corpid
  124. LEFT JOIN sys_dept dept ON dept.dept_id = twg.f_deptid
  125. LEFT JOIN (
  126. SELECT
  127. *
  128. FROM
  129. sys_dict_data dictIn
  130. WHERE
  131. dictIn.dict_label =
  132. IF(
  133. (
  134. (dictIn.dict_type = 'data_stltype_type' AND dictIn.`status`='0' AND dictIn.dict_value=1) OR
  135. (dictIn.dict_type = 'data_stltype_type' AND dictIn.`status`='0' AND dictIn.dict_value=0)
  136. ),
  137. dictIn.dict_label,NULL
  138. )
  139. ) dict ON dict.dict_value = twg.f_billtype
  140. LEFT JOIN (
  141. SELECT
  142. *
  143. FROM
  144. sys_dict_data dictIn
  145. WHERE
  146. dictIn.dict_label =
  147. IF(
  148. (dictIn.dict_type = 'data_trademodes' AND dictIn.`status`='0'),
  149. dictIn.dict_label,NULL
  150. )
  151. ) dttradmode ON dttradmode.dict_value = twg.f_billtype
  152. <where>
  153. <if test="fBillno != null and fBillno != ''">and twg.f_billno = #{fBillno}</if>
  154. <if test="fContractno != null and fContractno != ''">and twg.f_contractno = #{fContractno}</if>
  155. <if test="fDeptid != null ">and twg.f_deptid = #{fDeptid}</if>
  156. <if test="fCorpid != null ">and twg.f_corpid = #{fCorpid}</if>
  157. <if test="fGoodsid != null ">and twg.f_goodsid = #{fGoodsid}</if>
  158. <if test="fStltypeid != null ">and twg.f_stltypeid = #{fStltypeid}</if>
  159. <if test="fFeetypeid != null ">and twg.f_feetypeid = #{fFeetypeid}</if>
  160. <if test="tPackages != null and tPackages != ''">and twg.t_packages = #{tPackages}</if>
  161. <if test="fTrademodeid != null ">and twg.f_trademodeid = #{fTrademodeid}</if>
  162. <if test="fFreedays != null ">and twg.f_freedays = #{fFreedays}</if>
  163. <if test="fBegindate != null ">and twg.f_begindate = #{fBegindate}</if>
  164. <if test="fEnddate != null ">and twg.f_enddate = #{fEnddate}</if>
  165. <if test="fTaskType != null ">and twg.f_task_type = #{fTaskType}</if>
  166. <if test="fBillstatus != null and fBillstatus != ''">and twg.f_billstatus = #{fBillstatus}</if>
  167. <if test="fStatus != null and fStatus != ''">and twg.f_status = #{fStatus}</if>
  168. <if test="fBilltype != null and fBilltype != ''">and twg.f_billtype like concat('%', #{fBilltype}, '%')
  169. </if>
  170. <if test="fBilltypeName != null and fBilltypeName != ''">and twg.f_billtype_name like concat('%',
  171. #{fBilltypeName}, '%')
  172. </if>
  173. </where>
  174. ) a,
  175. (select @rank:=0) b
  176. </select>
  177. <select id="selectTWarehouseAgreementList1" parameterType="TWarehouseAgreement"
  178. resultType="Map">
  179. SELECT DISTINCT
  180. agre.f_id AS fId,
  181. agre.f_billno AS fBillno,
  182. corp.f_name AS fCorpid,
  183. agre.f_contractno AS fContractno,
  184. goods.f_id AS fGoodsid,
  185. goods.f_name AS fGoodsids,
  186. agre.t_packages AS tPackages,
  187. agre.f_begindate AS fBegindate,
  188. agre.f_enddate AS fEnddate,
  189. agre.f_feetypeid AS fFeetypeid,
  190. agre.f_billstatus AS fBillstatus,
  191. agre.f_status AS fStatus,
  192. agre.f_task_type AS fTaskType,
  193. agre.f_dc AS fDc,
  194. agre.f_billtype_name AS fBilltypeName
  195. FROM
  196. t_warehouse_agreement agre
  197. LEFT JOIN t_corps corp ON corp.f_id = agre.f_corpid
  198. LEFT JOIN t_goods goods ON goods.f_id = agre.f_goodsid
  199. <where>
  200. <if test="fBillno != null and fBillno != ''">and agre.f_billno = #{fBillno}</if>
  201. <if test="fContractno != null and fContractno != ''">and agre.f_contractno = #{fContractno}</if>
  202. <if test="fDeptid != null ">and agre.f_deptid = #{fDeptid}</if>
  203. <if test="fCorpid != null ">and agre.f_corpid = #{fCorpid}</if>
  204. <if test="fGoodsid != null">and JSON_CONTAINS( agre.f_goodsid -> '$[*]', #{fGoodsid}, '$')</if>
  205. <if test="fStltypeid != null ">and agre.f_stltypeid = #{fStltypeid}</if>
  206. <if test="fFeetypeid != null ">and agre.f_feetypeid = #{fFeetypeid}</if>
  207. <if test="tPackages != null and tPackages != ''">and agre.t_packages = #{tPackages}</if>
  208. <if test="fTrademodeid != null ">and agre.f_trademodeid = #{fTrademodeid}</if>
  209. <if test="fFreedays != null ">and agre.f_freedays = #{fFreedays}</if>
  210. <if test="fBegindate != null ">and agre.f_begindate = #{fBegindate}</if>
  211. <if test="fTaskType != null ">and agre.f_task_type = #{fTaskType}</if>
  212. <if test="fDc != null ">and agre.f_dc = #{fDc}</if>
  213. <if test="fEnddate != null ">and agre.f_enddate = #{fEnddate}</if>
  214. <if test="fBillstatus != null and fBillstatus != ''">and agre.f_billstatus = #{fBillstatus}</if>
  215. <if test="fStatus != null and fStatus != ''">and agre.f_status = #{fStatus}</if>
  216. <if test="fBilltype != null and fBilltype != ''">and agre.f_billtype like concat('%', #{fBilltype}, '%')
  217. </if>
  218. <if test="fBilltypeName != null and fBilltypeName != ''">and agre.f_billtype_name like concat('%',
  219. #{fBilltypeName}, '%')
  220. </if>
  221. </where>
  222. </select>
  223. <select id="selectTWarehouseAgreementById" parameterType="Long" resultMap="TWarehouseAgreementResult">
  224. <include refid="selectTWarehouseAgreementVo"/>
  225. where f_id = #{fId}
  226. </select>
  227. <select id="selectTWarehouseAgreementByCorpsId" parameterType="TWarehouseAgreement" resultType="map">
  228. SELECT DISTINCT
  229. agre.f_id AS fId,
  230. agre.f_billno AS fBillno,
  231. corp.f_name AS fName,
  232. agre.f_contractno AS fContractno,
  233. agre.t_packages AS tPackages,
  234. agre.f_begindate AS fBegindate,
  235. agre.f_enddate AS fEnddate,
  236. agre.f_feetypeid AS fFeetypeid,
  237. agre.f_billstatus AS fBillstatus,
  238. agre.f_status AS fStatus,
  239. agre.f_task_type AS fTaskType,
  240. agre.f_dc AS fDc,
  241. agre.f_billtype_name AS fBilltypeName
  242. FROM
  243. t_warehouse_agreement agre
  244. LEFT JOIN t_corps corp ON corp.f_id = agre.f_corpid
  245. <where>
  246. agre.f_task_type = 1
  247. <if test="fCorpId != null and fCorpId != ''">and corp.f_id = #{fCorpId}</if>
  248. </where>
  249. </select>
  250. <insert id="insertTWarehouseAgreement" parameterType="TWarehouseAgreement" useGeneratedKeys="true"
  251. keyProperty="fId">
  252. insert into t_warehouse_agreement
  253. <trim prefix="(" suffix=")" suffixOverrides=",">
  254. <if test="fBillno != null and fBillno != ''">f_billno,</if>
  255. <if test="fContractno != null and fContractno != ''">f_contractno,</if>
  256. <if test="fDeptid != null">f_deptid,</if>
  257. <if test="fCorpid != null">f_corpid,</if>
  258. <if test="fGoodsid != null">f_goodsid,</if>
  259. <if test="fStltypeid != null">f_stltypeid,</if>
  260. <if test="fFeetypeid != null">f_feetypeid,</if>
  261. <if test="tPackages != null">t_packages,</if>
  262. <if test="fWarehouseid != null">f_warehouseid,</if>
  263. <if test="fTrademodeid != null">f_trademodeid,</if>
  264. <if test="fFreedays != null">f_freedays,</if>
  265. <if test="fBegindate != null">f_begindate,</if>
  266. <if test="fEnddate != null">f_enddate,</if>
  267. <if test="fBillstatus != null">f_billstatus,</if>
  268. <if test="fStatus != null">f_status,</if>
  269. <if test="delFlag != null">del_flag,</if>
  270. <if test="createBy != null">create_by,</if>
  271. <if test="createTime != null">create_time,</if>
  272. <if test="updateBy != null">update_by,</if>
  273. <if test="updateTime != null">update_time,</if>
  274. <if test="remark != null">remark,</if>
  275. <if test="fTaskType != null">f_task_type,</if>
  276. <if test="fDc != null">f_dc,</if>
  277. <if test="fBilltype != null">f_billtype,</if>
  278. <if test="fBilltypeName != null">f_billtype_name,</if>
  279. </trim>
  280. <trim prefix="values (" suffix=")" suffixOverrides=",">
  281. <if test="fBillno != null and fBillno != ''">#{fBillno},</if>
  282. <if test="fContractno != null and fContractno != ''">#{fContractno},</if>
  283. <if test="fDeptid != null">#{fDeptid},</if>
  284. <if test="fCorpid != null">#{fCorpid},</if>
  285. <if test="fGoodsid != null">#{fGoodsid},</if>
  286. <if test="fStltypeid != null">#{fStltypeid},</if>
  287. <if test="fFeetypeid != null">#{fFeetypeid},</if>
  288. <if test="tPackages != null">#{tPackages},</if>
  289. <if test="fWarehouseid != null">#{fWarehouseid},</if>
  290. <if test="fTrademodeid != null">#{fTrademodeid},</if>
  291. <if test="fFreedays != null">#{fFreedays},</if>
  292. <if test="fBegindate != null">#{fBegindate},</if>
  293. <if test="fEnddate != null">#{fEnddate},</if>
  294. <if test="fBillstatus != null">#{fBillstatus},</if>
  295. <if test="fStatus != null">#{fStatus},</if>
  296. <if test="delFlag != null">#{delFlag},</if>
  297. <if test="createBy != null">#{createBy},</if>
  298. <if test="createTime != null">#{createTime},</if>
  299. <if test="updateBy != null">#{updateBy},</if>
  300. <if test="updateTime != null">#{updateTime},</if>
  301. <if test="remark != null">#{remark},</if>
  302. <if test="fTaskType != null">#{fTaskType},</if>
  303. <if test="fDc != null">#{fDc},</if>
  304. <if test="fBilltype != null">#{fBilltype},</if>
  305. <if test="fBilltypeName != null">#{fBilltypeName},</if>
  306. </trim>
  307. </insert>
  308. <update id="updateTWarehouseAgreement" parameterType="TWarehouseAgreement">
  309. update t_warehouse_agreement
  310. <trim prefix="SET" suffixOverrides=",">
  311. <if test="fBillno != null and fBillno != ''">f_billno = #{fBillno},</if>
  312. <if test="fContractno != null and fContractno != ''">f_contractno = #{fContractno},</if>
  313. <if test="fDeptid != null">f_deptid = #{fDeptid},</if>
  314. <if test="fCorpid != null">f_corpid = #{fCorpid},</if>
  315. <if test="fGoodsid != null">f_goodsid = #{fGoodsid},</if>
  316. <if test="fStltypeid != null">f_stltypeid = #{fStltypeid},</if>
  317. <if test="fFeetypeid != null">f_feetypeid = #{fFeetypeid},</if>
  318. <if test="tPackages != null">t_packages = #{tPackages},</if>
  319. <if test="fWarehouseid != null">f_warehouseid = #{fWarehouseid},</if>
  320. <if test="fTrademodeid != null">f_trademodeid = #{fTrademodeid},</if>
  321. <if test="fFreedays != null">f_freedays = #{fFreedays},</if>
  322. <if test="fBegindate != null">f_begindate = #{fBegindate},</if>
  323. <if test="fEnddate != null">f_enddate = #{fEnddate},</if>
  324. <if test="fBillstatus != null">f_billstatus = #{fBillstatus},</if>
  325. <if test="fStatus != null">f_status = #{fStatus},</if>
  326. <if test="delFlag != null">del_flag = #{delFlag},</if>
  327. <if test="createBy != null">create_by = #{createBy},</if>
  328. <if test="createTime != null">create_time = #{createTime},</if>
  329. <if test="updateBy != null">update_by = #{updateBy},</if>
  330. <if test="updateTime != null">update_time = #{updateTime},</if>
  331. <if test="remark != null">remark = #{remark},</if>
  332. <if test="fTaskType != null">f_task_type = #{fTaskType},</if>
  333. <if test="fDc != null">f_dc = #{fDc},</if>
  334. <if test="fBilltype != null">f_billtype = #{fBilltype},</if>
  335. <if test="fBilltypeName != null">f_billtype_name = #{fBilltypeName},</if>
  336. </trim>
  337. where f_id = #{fId}
  338. </update>
  339. <delete id="deleteTWarehouseAgreementById" parameterType="Long">
  340. delete
  341. from t_warehouse_agreement
  342. where f_id = #{fId}
  343. </delete>
  344. <delete id="deleteTWarehouseAgreementByIds" parameterType="String">
  345. delete
  346. w.*,
  347. wa.*
  348. from
  349. t_warehouse_agreement w
  350. LEFT JOIN t_warehouse_agreementitems wa ON wa.f_pid = w.f_id
  351. where w.f_id in
  352. <foreach item="fId" collection="array" open="(" separator="," close=")">
  353. #{fId}
  354. </foreach>
  355. </delete>
  356. <select id="agreementRemind" parameterType="TWarehouseAgreement" resultType="Map">
  357. select distinct
  358. agre.f_id AS fId,
  359. agre.f_feetypeid AS fFeetypeid,
  360. corp.f_name AS fCorpid,
  361. agre.f_contractno AS fContractno,
  362. agre.f_begindate AS fBegindate,
  363. agre.f_enddate AS fEnddate,
  364. agre.create_by AS createBy,
  365. agre.create_time AS createTime,
  366. agre.remark AS remark
  367. from t_warehouse_agreement agre
  368. left join t_corps corp on corp.f_id = agre.f_corpid
  369. where
  370. agre.f_status = '0'
  371. and datediff(date_format(agre.f_enddate, '%Y-%m-%d'), date_format(now(), '%Y-%m-%d')) &lt;= #{remindDays}
  372. <if test="fCorpid != null ">and agre.f_corpid = #{fCorpid}</if>
  373. <if test="fContractno != null and fContractno != ''">and agre.f_contractno = #{fContractno}</if>
  374. <if test="fBegindate != null ">and agre.f_begindate = #{fBegindate}</if>
  375. <if test="fEnddate != null ">and agre.f_enddate = #{fEnddate}</if>
  376. </select>
  377. <select id="biContractCount" resultType="map">
  378. select count(f_id) as contractCount
  379. from t_warehouse_agreement
  380. where f_feetypeid = 0
  381. <if test="beginDate != null and beginDate != ''">and f_enddate &gt;= #{beginDate}</if>
  382. <if test="endDate != null and endDate != ''">and f_enddate &lt; #{endDate}</if>
  383. <if test="external != null and external != ''">
  384. and f_corpid = (select f_pid from t_customer_contact where f_tel = #{external})
  385. </if>
  386. <if test="customerId != null">and f_corpid = #{customerId}</if>
  387. </select>
  388. <select id="biContractList" resultType="map">
  389. select
  390. ifnull(tc.f_cname, tc.f_name) as customerName,
  391. ta.f_begindate as beginDate,
  392. ta.f_enddate as endDate
  393. from t_warehouse_agreement ta left join t_corps tc on tc.f_id = ta.f_corpid
  394. where ta.f_feetypeid = 0
  395. <if test="external != null and external != ''">
  396. and ta.f_corpid = (select f_pid from t_customer_contact where f_tel = #{external})
  397. </if>
  398. <if test="customerId != null">and ta.f_corpid = #{customerId}</if>
  399. order by ta.create_time desc
  400. </select>
  401. <select id="selectTGoodsTypeByTypeId" resultType="com.ruoyi.basicData.domain.TGoods">
  402. select
  403. f_typeid as typeId,
  404. f_name as fName
  405. from
  406. t_goods
  407. WHERE
  408. f_typeid in
  409. <foreach collection="typeIds" item="typeId" open="(" separator="," close=")">
  410. #{typeId}
  411. </foreach>
  412. </select>
  413. <select id="selectTWarehouseByIds" resultType="com.ruoyi.common.core.domain.entity.TWarehouse">
  414. select
  415. f_id as fId,
  416. f_name as fName
  417. from
  418. t_warehouse
  419. WHERE
  420. f_id in
  421. <foreach collection="fIds" item="fId" open="(" separator="," close=")">
  422. #{fId}
  423. </foreach>
  424. </select>
  425. </mapper>