MajorProductionMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  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. ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id IS NULL AND business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 ) as mDeclareResult,
  194. ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id IS NULL AND business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 ) as eDeclareResult
  195. FROM
  196. major m
  197. left join user u on u.id = m.principal_id
  198. left join user u1 on u1.id = m.client_manager_id
  199. left join customer_company cc on cc.id = m.clientele_id
  200. left join customer_company cc1 on cc1.id = m.clientele_sub_id
  201. left join customer_linkman cl on cl.id = m.clientele_contact_id
  202. left join (select * from order_fund where business_type ='MAJOR_BUSINESS' and deleted = 0) orf on orf.business_id = m.id
  203. </sql>
  204. <select id="myOrder" parameterType="com.dayou.vo.MajorOrderVO" resultType="com.dayou.vo.MajorOrderVO">
  205. <include refid="myMajorOrder" />
  206. where m.deleted = 0
  207. and m.client_manager_id = #{vo.clientManagerId}
  208. <if test="keyword!=null and keyword!='' ">
  209. and (
  210. m.name like concat ('%',#{keyword},'%')
  211. or m.order_id like concat('%',#{keyword},'%')
  212. or u.name like concat('%',#{keyword},'%')
  213. or u1.name like concat('%',#{keyword},'%')
  214. or cc.name like concat('%',#{keyword},'%')
  215. or cc1.name like concat('%',#{keyword},'%')
  216. or cl.name like concat('%',#{keyword},'%')
  217. or m.bailor like concat('%',#{keyword},'%')
  218. or m.owner like concat('%',#{keyword},'%')
  219. or orf.should_amount like concat('%',#{keyword},'%')
  220. or orf.real_amount like concat('%',#{keyword},'%')
  221. or orf.remark like concat('%',#{keyword},'%')
  222. )
  223. </if>
  224. <if test="vo!=null and vo.startDate!=null and vo.startDate!=''">
  225. and m.created &gt;= #{vo.startDate}
  226. </if>
  227. <if test="vo!=null and vo.endDate!=null and vo.endDate!=''">
  228. and m.created &lt;= #{vo.endDate}
  229. </if>
  230. <if test="vo!=null and vo.endDate!=null and vo.endDate!=''">
  231. and m.created &lt;= #{vo.endDate}
  232. </if>
  233. <if test="vo!=null and vo.endDate!=null and vo.endDate!=''">
  234. and m.created &lt;= #{vo.endDate}
  235. </if>
  236. order by m.created DESC
  237. </select>
  238. <select id="waitingClaim" parameterType="com.dayou.vo.MajorOrderVO" resultType="com.dayou.vo.MajorOrderVO">
  239. <include refid="myMajorOrder" />
  240. where m.deleted = 0
  241. and m.client_manager_id = #{vo.clientManagerId} and orf.id is not null
  242. <if test="vo!=null and vo.name!=null and vo.name !=''">
  243. and m.name like concat ('%',#{vo.name},'%')
  244. </if>
  245. <if test="vo!=null and vo.orderId!=null and vo.orderId !=''">
  246. and m.order_id like concat ('%',#{vo.orderId},'%')
  247. </if>
  248. <if test="vo!=null and vo.mDeclareResult!=null and vo.mDeclareResult =='审核通过'">
  249. and ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id IS NULL AND business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 ) = '审核通过'
  250. </if>
  251. <if test="vo!=null and vo.mDeclareResult!=null and vo.mDeclareResult =='审核拒绝'">
  252. and ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id IS NULL AND business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 ) = '审核拒绝'
  253. </if>
  254. <if test="vo!=null and vo.mDeclareResult!=null and vo.mDeclareResult =='审核中'">
  255. and ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id IS NULL AND business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 ) = '审核中'
  256. </if>
  257. <if test="vo!=null and vo.mDeclareResult!=null and vo.mDeclareResult =='未申报'">
  258. and ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id IS NULL AND business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 ) is null
  259. </if>
  260. <if test="vo!=null and vo.eDeclareResult!=null and vo.eDeclareResult =='审核通过'">
  261. and ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id IS NULL AND business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 ) = '审核通过'
  262. </if>
  263. <if test="vo!=null and vo.eDeclareResult!=null and vo.eDeclareResult =='审核拒绝'">
  264. and ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id IS NULL AND business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 ) = '审核拒绝'
  265. </if>
  266. <if test="vo!=null and vo.eDeclareResult!=null and vo.eDeclareResult =='审核中'">
  267. and ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id IS NULL AND business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 ) = '审核中'
  268. </if>
  269. <if test="vo!=null and vo.eDeclareResult!=null and vo.eDeclareResult =='未申报'">
  270. and ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id IS NULL AND business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 ) is null
  271. </if>
  272. order by m.created DESC
  273. </select>
  274. <select id="getMajorProductionAboutFundId" parameterType="java.lang.Long" resultType="com.dayou.entity.MajorProduction">
  275. SELECT
  276. mp.id,
  277. pf.id AS productionFundId,
  278. sum(pf.real_amount) as realAmount,
  279. mp.production,
  280. mp.NAME,
  281. mp.client_name,
  282. mp.OWNER,
  283. mp.evaluate_acreage,
  284. mp.evaluate_amount,
  285. mp.evaluate_price,
  286. mp.report_no,
  287. mp.repertory_state,
  288. mp.repertory_in_time,
  289. mp.repertory_out_time,
  290. mp.if_save_file,
  291. mp.save_file_date,
  292. mp.delivery
  293. FROM
  294. major_production mp
  295. 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 ( mp.major_id = pf.business_id AND mp.report_no = pf.production_no AND mp.production = pf.production_type )
  296. WHERE
  297. mp.major_id = #{majorId} and mp.deleted = 0
  298. AND mp.NAME IS NOT NULL
  299. GROUP BY mp.id
  300. ORDER BY mp.id DESC
  301. </select>
  302. <select id="todoSaveFilePage" parameterType="com.dayou.vo.TaskTodoVO" resultType="com.dayou.vo.TaskTodoVO">
  303. SELECT
  304. wfni.id,
  305. mp.id AS productionId,
  306. mp.NAME,
  307. mp.repertory_state,
  308. wtr.id AS taskId,
  309. wfni.id AS currentNodeId,
  310. wfni.business_min_id ,
  311. wfni.business_id,
  312. m.NAME AS orderName,
  313. m.order_id,
  314. u1.NAME AS clientManager,
  315. u2.NAME AS principal,
  316. d.NAME AS departmentName,
  317. wfni.NAME AS nodeName,
  318. wfni.CODE AS nodeCode,
  319. u.NAME AS HANDLER,
  320. pf.real_amount AS realAmount,
  321. wtr.handler_id,
  322. wtr.finished AS taskFinished,
  323. DATE_FORMAT( m.created, '%Y-%m-%d' ) AS created,
  324. wtr.created AS taskCreated,
  325. mp.production
  326. FROM
  327. work_task_record wtr
  328. LEFT JOIN work_node_task wnt ON wnt.id = wtr.task_id
  329. INNER JOIN (
  330. SELECT
  331. wn.NAME,
  332. wn.CODE,
  333. wfni.id,
  334. wfni.business_id,
  335. wfni.business_sub_id,
  336. wfni.business_min_id,
  337. wfni.state
  338. FROM
  339. work_flow_node_instance wfni
  340. LEFT JOIN work_node wn ON wn.id = wfni.node_id
  341. WHERE
  342. wfni.business_type = 'MAJOR_BUSINESS'
  343. AND wfni.state = 'PENDING'
  344. AND wfni.deleted = 0
  345. AND wn.deleted = 0
  346. AND wn.CODE = 'BUSINESS_ARCHIVING'
  347. ) wfni ON wtr.instance_id = wfni.id
  348. LEFT JOIN major m ON m.id = wfni.business_id
  349. LEFT JOIN user u ON u.id = wtr.handler_id
  350. LEFT JOIN user u1 ON u1.id = m.client_manager_id
  351. LEFT JOIN user u2 ON u2.id = m.principal_id
  352. LEFT JOIN department d ON d.id = m.department_id
  353. 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 )
  354. LEFT JOIN ( SELECT business_id, production_no, real_amount FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON (
  355. pf.business_id = m.id
  356. AND pf.production_no = wfni.business_min_id)
  357. WHERE u.deleted = 0
  358. and wtr.handler_id =#{todoVO.handlerId}
  359. AND wnt.deleted = 0
  360. AND wtr.deleted = 0
  361. <if test="keyword!=null and keyword!='' ">
  362. and (
  363. mp.name like concat('%',#{keyword},'%')
  364. or m.order_id like concat('%',#{keyword},'%')
  365. or m.name like concat('%',#{keyword},'%')
  366. or wfni.business_min_id like concat('%',#{keyword},'%')
  367. or u1.NAME like concat('%',#{keyword},'%')
  368. or u2.NAME like concat('%',#{keyword},'%')
  369. )
  370. </if>
  371. <if test="todoVO!=null and todoVO.production!=null and todoVO.production!=''">
  372. and mp.production =#{todoVO.production}
  373. </if>
  374. ORDER BY
  375. wtr.created DESC
  376. </select>
  377. <update id="updateSaveFileInfo" parameterType="java.util.List">
  378. update major_production set if_save_file = 1 ,save_file_date= now() where id in (
  379. <foreach collection="productionIds" index="index" item="item" separator=",">
  380. #{item}
  381. </foreach>
  382. )
  383. </update>
  384. <select id="performanceAllotPage" parameterType="com.dayou.vo.MajorProductionPerformanceVO" resultType="com.dayou.vo.MajorProductionPerformanceVO">
  385. SELECT
  386. mp.id,
  387. m.order_id,
  388. m.id as majorId,
  389. mp.NAME,
  390. mp.report_no,
  391. (case mp.production when 'REPORT' then '报告' when 'STATEMENT' THEN '价值意见书' else '复评函' end ) as production,
  392. ( SELECT count(id) FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND business_id = m.id AND production_no = mp.report_no AND deleted = 0 ) AS claimTimes,
  393. ( SELECT major_production_id FROM major_production_allot WHERE deleted = 0 GROUP BY major_production_id HAVING major_production_id = mp.id ) AS isAllot
  394. FROM
  395. major_production mp
  396. LEFT JOIN major m ON m.id = mp.major_id
  397. WHERE
  398. m.deleted = 0
  399. AND mp.deleted = 0
  400. AND mp.NAME IS NOT NULL
  401. and m.department_id in (select distinct department_id from post where name='评估部经理' and id in (select post_id from user_post where user_id = #{currentUserId}))
  402. order by isAllot ASC;
  403. </select>
  404. <select id="validateProd" parameterType="java.lang.Long" resultType="com.dayou.vo.ProdValidateVO">
  405. SELECT
  406. mp.evaluate_acreage as acreage,
  407. ROUND(mp.evaluate_amount/10000,2) as amount,
  408. mp.name AS productionName,
  409. mp.report_no AS productionNo ,
  410. mp.client_name as bailor
  411. FROM
  412. major_production mp
  413. WHERE
  414. mp.id = #{id}
  415. AND mp.deleted = 0
  416. </select>
  417. <select id="waitingClaimProd" parameterType="com.dayou.vo.MajorProductionVO" resultType="com.dayou.vo.MajorProductionVO">
  418. SELECT
  419. m.id as majorId,
  420. m.order_id,
  421. m.financial,
  422. mp.id,
  423. mp.name,
  424. mp.report_no,
  425. mp.standard_amount,
  426. (case mp.production when 'STATEMENT' THEN '意见书' when 'REPORT' THEN '报告' when 'LETTER' THEN '复评函' else '' end) production,
  427. u.NAME AS principal,
  428. u1.NAME AS clientManager,
  429. cc.NAME AS clienteleName,
  430. orf.id AS orderFundId,
  431. orf.should_amount,
  432. off.id as productionFundId,
  433. off.real_amount,
  434. off.standard_amount,
  435. ifnull(( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id = mp.id AND business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 ),
  436. ( SELECT declare_result FROM commission_declare WHERE business_id = m.id and production_id is null AND business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 )) as mDeclareResult,
  437. ifnull(( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id = mp.id AND business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 ),
  438. ( SELECT declare_result FROM commission_declare WHERE business_id = m.id and production_id is null AND business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 )) as eDeclareResult
  439. FROM
  440. major_production mp
  441. left join major m on m.id = mp.major_id
  442. INNER JOIN ( SELECT id,business_id,should_amount FROM order_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) orf ON orf.business_id = m.id
  443. LEFT JOIN ( SELECT id,business_id,production_no,real_amount,standard_amount,production_should_amount FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0) off ON (off.business_id = m.id and off.production_no = mp.report_no)
  444. LEFT JOIN USER u ON u.id = m.principal_id
  445. LEFT JOIN USER u1 ON u1.id = m.client_manager_id
  446. LEFT JOIN customer_company cc ON cc.id = m.clientele_id
  447. WHERE
  448. m.deleted = 0
  449. AND mp.deleted = 0
  450. AND m.client_manager_id = #{vo.clientManagerId}
  451. <if test="vo!=null and vo.name!=null and vo.name !=''">
  452. and mp.name like concat ('%',#{vo.name},'%')
  453. </if>
  454. <if test="vo!=null and vo.orderId!=null and vo.orderId !=''">
  455. and m.order_id like concat ('%',#{vo.orderId},'%')
  456. </if>
  457. <if test="vo!=null and vo.reportNo!=null and vo.reportNo !=''">
  458. and mp.report_no like concat ('%',#{vo.reportNo},'%')
  459. </if>
  460. <if test="vo!=null and vo.mDeclareResult!=null and vo.mDeclareResult =='审核通过'">
  461. and ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id = mp.id AND business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 ) = '审核通过'
  462. </if>
  463. <if test="vo!=null and vo.mDeclareResult!=null and vo.mDeclareResult =='审核拒绝'">
  464. and ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id = mp.id AND business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 ) = '审核拒绝'
  465. </if>
  466. <if test="vo!=null and vo.mDeclareResult!=null and vo.mDeclareResult =='审核中'">
  467. and ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id = mp.id AND business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 ) = '审核中'
  468. </if>
  469. <if test="vo!=null and vo.mDeclareResult!=null and vo.mDeclareResult =='未申报'">
  470. and ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id = mp.id AND business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 ) is null
  471. </if>
  472. <if test="vo!=null and vo.eDeclareResult!=null and vo.eDeclareResult =='审核通过'">
  473. and ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id = mp.id AND business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 ) = '审核通过'
  474. </if>
  475. <if test="vo!=null and vo.eDeclareResult!=null and vo.eDeclareResult =='审核拒绝'">
  476. and ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id = mp.id AND business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 ) = '审核拒绝'
  477. </if>
  478. <if test="vo!=null and vo.eDeclareResult!=null and vo.eDeclareResult =='审核中'">
  479. and ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id = mp.id AND business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 ) = '审核中'
  480. </if>
  481. <if test="vo!=null and vo.eDeclareResult!=null and vo.eDeclareResult =='未申报'">
  482. and ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id = mp.id AND business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 ) is null
  483. </if>
  484. ORDER BY
  485. mp.created DESC
  486. </select>
  487. </mapper>