MajorProductionMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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.dayou.mapper.MajorProductionMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.dayou.entity.MajorProduction">
  6. <result column="id" property="id" />
  7. <result column="major_id" property="majorId" />
  8. <result column="deleted" property="deleted" />
  9. <result column="created" property="created" />
  10. <result column="modified" property="modified" />
  11. <result column="report_no" property="reportNo" />
  12. <result column="production" property="production" />
  13. <result column="signatory" property="signatory" />
  14. <result column="name" property="name" />
  15. <result column="client_name" property="clientName" />
  16. <result column="client_tel" property="clientTel" />
  17. <result column="client_address" property="clientAddress" />
  18. <result column="owner" property="owner" />
  19. <result column="value_timing" property="valueTiming" />
  20. <result column="evaluate_acreage" property="evaluateAcreage" />
  21. <result column="evaluate_amount" property="evaluateAmount" />
  22. <result column="evaluate_price" property="evaluatePrice" />
  23. <result column="comment" property="comment" />
  24. <result column="qr_code" property="qrCode" />
  25. <result column="repertory_state" property="repertoryState" />
  26. <result column="first_check" property="firstCheck" />
  27. <result column="second_check" property="secondCheck" />
  28. <result column="third_check" property="thirdCheck" />
  29. <result column="save_file_check" property="saveFileCheck" />
  30. <result column="save_file_second_check" property="saveFileSecondCheck" />
  31. <result column="if_save_file" property="ifSaveFile" />
  32. </resultMap>
  33. <!-- 通用查询结果列 -->
  34. <sql id="Base_Column_List">
  35. id,
  36. major_id,
  37. deleted,
  38. created,
  39. modified,
  40. report_no, production,signatory, name, client_name, client_tel, client_address, owner, value_timing, evaluate_acreage, evaluate_amount, evaluate_price
  41. , comment,qr_code,repertory_state,first_check,second_check,third_check,save_file_check,save_file_second_check,if_save_file
  42. </sql>
  43. <select id="getList" parameterType="com.dayou.entity.MajorProduction" resultType="com.dayou.entity.MajorProduction">
  44. select * from (
  45. SELECT
  46. mp.id,
  47. mp.major_id,
  48. (SELECT id FROM work_flow_node_instance
  49. WHERE business_id = #{production.majorId}
  50. AND (business_sub_id = mp.report_no or business_min_id = mp.report_no ) and deleted = 0
  51. and sequence = ( #{production.sequence} + 1) ) AS nextInstanceNodeId ,
  52. mp.report_no,
  53. mp.production,
  54. mp.signatory,
  55. mp.`name`,
  56. mp.client_name,
  57. mp.client_tel,
  58. mp.client_address,
  59. mp.`owner`,
  60. mp.value_timing,
  61. mp.evaluate_acreage,
  62. mp.evaluate_amount,
  63. mp.evaluate_price,
  64. mp.`comment`,
  65. mp.qr_code,
  66. mp.repertory_state,
  67. mp.first_check,
  68. mp.second_check,
  69. mp.third_check,
  70. mp.save_file_check,
  71. mp.save_file_second_check,
  72. mp.if_save_file,
  73. mp.file_path,
  74. m.`name` AS majorName
  75. FROM
  76. major_production mp
  77. LEFT JOIN major m ON m.id = mp.major_id
  78. WHERE
  79. mp.major_id = #{production.majorId}
  80. <if test="production!=null and production.afterProduction==null and production.reportNo!=null and production.reportNo!='' ">
  81. and mp.report_no = #{production.reportNo}
  82. </if>
  83. <if test="production!=null and production.afterProduction!=null and production.afterProduction=='REPORT' and production.reportNo!=null and production.reportNo!='' ">
  84. and mp.report_no in (select report_no from major_target where major_id = #{production.majorId} and statement_no =#{production.reportNo} and deleted = 0)
  85. </if>
  86. <if test="production!=null and production.afterProduction!=null and production.afterProduction=='LETTER' and production.reportNo!=null and production.reportNo!='' ">
  87. and mp.report_no in (select letter_no from major_target where major_id = #{production.majorId} and statement_no =#{production.reportNo} and deleted = 0)
  88. </if>
  89. <if test="production!=null and production.production!=null and production.production!='' ">
  90. and mp.production = #{production.production}
  91. </if>
  92. and mp.deleted = 0 and m.deleted = 0
  93. order by mp.created ASC ) t where nextInstanceNodeId is null
  94. </select>
  95. <select id="saveDonePage" parameterType="com.dayou.vo.MajorProductionSaveDoneVO" resultType="com.dayou.vo.MajorProductionSaveDoneVO">
  96. SELECT
  97. mp.id,
  98. mp.name,
  99. mp.major_id,
  100. mp.report_no,
  101. m.order_id,
  102. m.name as orderName,
  103. u1.name as clientManager,
  104. u2.name as principal,
  105. m.business_object_type,
  106. mp.production,
  107. mp.repertory_state,
  108. mp.save_file_date,
  109. pf.real_amount
  110. FROM
  111. major_production mp
  112. LEFT JOIN major m ON m.id = mp.major_id
  113. LEFT JOIN user u1 ON u1.id = m.client_manager_id
  114. LEFT JOIN user u2 ON u2.id = m.principal_id
  115. left join (select business_id,production_no,real_amount, production_type from production_fund where business_type='MAJOR_BUSINESS' and deleted = 0) pf
  116. on (pf.business_id = mp.major_id and pf.production_no =mp.report_no and mp.production = pf.production_type)
  117. where mp.deleted = 0 and m.deleted = 0 and mp.if_save_file= 1
  118. <if test="keyword!=null and keyword!='' ">
  119. and (
  120. mp.name like concat('%',#{keyword},'%')
  121. or m.order_id like concat('%',#{keyword},'%')
  122. or m.name like concat('%',#{keyword},'%')
  123. or u1.NAME like concat('%',#{keyword},'%')
  124. or u2.NAME like concat('%',#{keyword},'%')
  125. or mp.report_no like concat('%',#{keyword},'%')
  126. )
  127. </if>
  128. <if test="done!=null and done.production!=null and done.production!=''">
  129. and mp.production =#{done.production}
  130. </if>
  131. <if test="done!=null and done.startDate!=null and done.startDate!=''">
  132. and mp.save_file_date &gt;= #{done.startDate}
  133. </if>
  134. <if test="done!=null and done.endDate!=null and done.endDate!=''">
  135. and mp.save_file_date &lt;= #{done.endDate}
  136. </if>
  137. order by mp.save_file_date desc
  138. </select>
  139. <select id="getHouse" parameterType="com.dayou.vo.MajorProductionVO" resultType="com.dayou.vo.MajorProductionVO">
  140. SELECT
  141. mp.id,
  142. mp.major_id,
  143. mp.report_no,
  144. mp.production,
  145. mp.NAME,
  146. mp.client_name,
  147. mp.evaluate_amount,
  148. mp.repertory_state,
  149. mp.repertory_in_time,
  150. u.NAME AS principal
  151. FROM
  152. major_production mp
  153. LEFT JOIN major m ON m.id = mp.major_id
  154. LEFT JOIN user u ON u.id = m.principal_id
  155. where mp.deleted = 0 and m.deleted = 0 and mp.repertory_state=0
  156. <if test="keyword!=null and keyword!='' ">
  157. and (
  158. mp.report_no like concat ('%',#{keyword},'%')
  159. or mp.NAME like concat('%',#{keyword},'%')
  160. or mp.client_name like concat('%',#{keyword},'%')
  161. or mp.evaluate_amount like concat('%',#{keyword},'%')
  162. or u.NAME like concat('%',#{keyword},'%')
  163. )
  164. </if>
  165. <if test="vo!=null and vo.production!=null and vo.production!=''">
  166. and mp.production =#{vo.production}
  167. </if>
  168. <if test="vo!=null and vo.startDate!=null and vo.startDate!=''">
  169. and mp.repertory_in_time &gt;= #{vo.startDate}
  170. </if>
  171. <if test="vo!=null and vo.endDate!=null and vo.endDate!=''">
  172. and mp.repertory_in_time &lt;= #{vo.endDate}
  173. </if>
  174. order by mp.repertory_in_time DESC
  175. </select>
  176. <sql id="myMajorOrder">
  177. SELECT
  178. m.id,
  179. m.order_id,
  180. m.name as orderName,
  181. u.name as principal,
  182. u1.name as clientManager,
  183. cc.name as clienteleName,
  184. cc1.name as clienteleSubName,
  185. cl.name as clienteleContactName,
  186. m.bailor,
  187. m.owner,
  188. m.created,
  189. orf.id as orderFundId,
  190. orf.should_amount,
  191. orf.real_amount,
  192. orf.remark
  193. FROM
  194. major m
  195. left join user u on u.id = m.principal_id
  196. left join user u1 on u1.id = m.client_manager_id
  197. left join customer_company cc on cc.id = m.clientele_id
  198. left join customer_company cc1 on cc1.id = m.clientele_sub_id
  199. left join customer_linkman cl on cl.id = m.clientele_contact_id
  200. left join (select * from order_fund where business_type ='MAJOR_BUSINESS' and deleted = 0) orf on orf.business_id = m.id
  201. </sql>
  202. <select id="myOrder" parameterType="com.dayou.vo.MajorOrderVO" resultType="com.dayou.vo.MajorOrderVO">
  203. <include refid="myMajorOrder" />
  204. where m.deleted = 0
  205. and m.client_manager_id = #{vo.clientManagerId}
  206. <if test="keyword!=null and keyword!='' ">
  207. and (
  208. m.name like concat ('%',#{keyword},'%')
  209. or m.order_id like concat('%',#{keyword},'%')
  210. or u.name like concat('%',#{keyword},'%')
  211. or u1.name like concat('%',#{keyword},'%')
  212. or cc.name like concat('%',#{keyword},'%')
  213. or cc1.name like concat('%',#{keyword},'%')
  214. or cl.name like concat('%',#{keyword},'%')
  215. or m.bailor like concat('%',#{keyword},'%')
  216. or m.owner like concat('%',#{keyword},'%')
  217. or orf.should_amount like concat('%',#{keyword},'%')
  218. or orf.real_amount like concat('%',#{keyword},'%')
  219. or orf.remark like concat('%',#{keyword},'%')
  220. )
  221. </if>
  222. <if test="vo!=null and vo.startDate!=null and vo.startDate!=''">
  223. and m.created &gt;= #{vo.startDate}
  224. </if>
  225. <if test="vo!=null and vo.endDate!=null and vo.endDate!=''">
  226. and m.created &lt;= #{vo.endDate}
  227. </if>
  228. order by m.created DESC
  229. </select>
  230. <select id="waitingClaim" parameterType="com.dayou.vo.MajorOrderVO" resultType="com.dayou.vo.MajorOrderVO">
  231. <include refid="myMajorOrder" />
  232. where m.deleted = 0
  233. and m.client_manager_id = #{vo.clientManagerId} and orf.id is not null
  234. order by m.created DESC
  235. </select>
  236. <select id="getMajorProductionAboutFundId" parameterType="java.lang.Long" resultType="com.dayou.entity.MajorProduction">
  237. SELECT
  238. mp.id,
  239. pf.id as productionFundId,
  240. pf.real_amount,
  241. mp.production,
  242. mp.NAME,
  243. mp.client_name,
  244. mp.OWNER,
  245. mp.evaluate_acreage,
  246. mp.evaluate_amount,
  247. mp.evaluate_price,
  248. mp.report_no,
  249. mp.repertory_state,
  250. mp.repertory_in_time,
  251. mp.repertory_out_time,
  252. mp.if_save_file,
  253. mp.save_file_date,
  254. mp.delivery
  255. FROM
  256. major_production mp
  257. LEFT JOIN ( SELECT id, business_id, production_no,real_amount,production_type FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON (
  258. mp.major_id = pf.business_id
  259. AND mp.report_no = pf.production_no and mp.production = pf.production_type) where mp.major_id = #{majorId} and mp.deleted = 0
  260. and mp.name is not null
  261. <if test="reportNo!=null and reportNo!=''">
  262. and mp.report_no = #{reportNo}
  263. </if>
  264. order by mp.id DESC
  265. </select>
  266. <select id="todoSaveFilePage" parameterType="com.dayou.vo.TaskTodoVO" resultType="com.dayou.vo.TaskTodoVO">
  267. SELECT
  268. wfni.id,
  269. mp.id AS productionId,
  270. mp.NAME,
  271. mp.repertory_state,
  272. wtr.id AS taskId,
  273. wfni.id AS currentNodeId,
  274. wfni.business_min_id ,
  275. wfni.business_id,
  276. m.NAME AS orderName,
  277. m.order_id,
  278. u1.NAME AS clientManager,
  279. u2.NAME AS principal,
  280. d.NAME AS departmentName,
  281. wfni.NAME AS nodeName,
  282. wfni.CODE AS nodeCode,
  283. u.NAME AS HANDLER,
  284. pf.real_amount AS realAmount,
  285. wtr.handler_id,
  286. wtr.finished AS taskFinished,
  287. DATE_FORMAT( m.created, '%Y-%m-%d' ) AS created,
  288. wtr.created AS taskCreated,
  289. mp.production
  290. FROM
  291. work_task_record wtr
  292. LEFT JOIN work_node_task wnt ON wnt.id = wtr.task_id
  293. INNER JOIN (
  294. SELECT
  295. wn.NAME,
  296. wn.CODE,
  297. wfni.id,
  298. wfni.business_id,
  299. wfni.business_sub_id,
  300. wfni.business_min_id,
  301. wfni.state
  302. FROM
  303. work_flow_node_instance wfni
  304. LEFT JOIN work_node wn ON wn.id = wfni.node_id
  305. WHERE
  306. wfni.business_type = 'MAJOR_BUSINESS'
  307. AND wfni.state = 'PENDING'
  308. AND wfni.deleted = 0
  309. AND wn.deleted = 0
  310. AND wn.CODE = 'BUSINESS_ARCHIVING'
  311. ) wfni ON wtr.instance_id = wfni.id
  312. LEFT JOIN major m ON m.id = wfni.business_id
  313. LEFT JOIN USER u ON u.id = wtr.handler_id
  314. LEFT JOIN USER u1 ON u1.id = m.client_manager_id
  315. LEFT JOIN USER u2 ON u2.id = m.principal_id
  316. LEFT JOIN department d ON d.id = m.department_id
  317. LEFT JOIN ( SELECT id, major_id, report_no, NAME, repertory_state, production FROM major_production WHERE production != 'STATEMENT' AND deleted = 0 ) mp ON ( mp.major_id = m.id AND mp.report_no = wfni.business_min_id )
  318. LEFT JOIN ( SELECT business_id, production_no, real_amount FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON (
  319. pf.business_id = m.id
  320. AND pf.production_no = wfni.business_min_id)
  321. WHERE u.deleted = 0
  322. and wtr.handler_id =#{todoVO.handlerId}
  323. AND wnt.deleted = 0
  324. AND wtr.deleted = 0
  325. <if test="keyword!=null and keyword!='' ">
  326. and (
  327. mp.name like concat('%',#{keyword},'%')
  328. or m.order_id like concat('%',#{keyword},'%')
  329. or m.name like concat('%',#{keyword},'%')
  330. or wfni.business_min_id like concat('%',#{keyword},'%')
  331. or u1.NAME like concat('%',#{keyword},'%')
  332. or u2.NAME like concat('%',#{keyword},'%')
  333. )
  334. </if>
  335. <if test="todoVO!=null and todoVO.production!=null and todoVO.production!=''">
  336. and mp.production =#{todoVO.production}
  337. </if>
  338. ORDER BY
  339. wtr.created DESC
  340. </select>
  341. <update id="updateSaveFileInfo" parameterType="java.util.List">
  342. update major_production set if_save_file = 1 ,save_file_date= now() where id in (
  343. <foreach collection="productionIds" index="index" item="item" separator=",">
  344. #{item}
  345. </foreach>
  346. )
  347. </update>
  348. </mapper>