MajorProductionMapper.xml 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  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. mp.checked_file_path,
  76. mp.validate_code
  77. FROM
  78. major_production mp
  79. LEFT JOIN major m ON m.id = mp.major_id
  80. WHERE
  81. mp.major_id = #{production.majorId}
  82. <if test="production!=null and production.afterProduction==null
  83. and production.statementNo==null and production.reportNo!=null and production.reportNo!='' ">
  84. and mp.report_no = #{production.reportNo}
  85. </if>
  86. <if test="production!=null and production.afterProduction==null
  87. and production.statementNo!=null and production.statementNo!='' and production.reportNo==null ">
  88. and mp.report_no = #{production.statementNo}
  89. </if>
  90. <if test="production!=null and production.afterProduction!=null and production.afterProduction=='REPORT' and production.reportNo!=null and production.reportNo!='' ">
  91. and mp.report_no in (select report_no from major_target where major_id = #{production.majorId} and statement_no =#{production.reportNo} and deleted = 0)
  92. </if>
  93. <if test="production!=null and production.afterProduction!=null and production.afterProduction=='LETTER' and production.reportNo!=null and production.reportNo!='' ">
  94. and mp.report_no in (select letter_no from major_target where major_id = #{production.majorId} and statement_no =#{production.reportNo} and deleted = 0)
  95. </if>
  96. <if test="production!=null and production.production!=null and production.production!='' ">
  97. and mp.production = #{production.production}
  98. </if>
  99. <if test="production!=null and production.afterProduction==null and production.statementNo!=null
  100. and production.statementNo!='' and production.reportNo!=null and production.reportNo!=''">
  101. and mp.report_no in (#{production.statementNo},#{production.reportNo})
  102. </if>
  103. and mp.deleted = 0 and m.deleted = 0
  104. order by mp.created ASC ) t where nextInstanceNodeId is null
  105. </select>
  106. <select id="getPendingList" parameterType="com.dayou.entity.MajorProduction" resultType="com.dayou.entity.MajorProduction">
  107. SELECT
  108. mp.id,
  109. mp.major_id,
  110. mp.report_no,
  111. mp.production,
  112. mp.signatory,
  113. mp.`name`,
  114. mp.client_name,
  115. mp.client_tel,
  116. mp.client_address,
  117. mp.`owner`,
  118. mp.value_timing,
  119. mp.evaluate_acreage,
  120. mp.evaluate_amount,
  121. mp.evaluate_price,
  122. mp.`comment`,
  123. mp.qr_code,
  124. mp.repertory_state,
  125. mp.first_check,
  126. mp.second_check,
  127. mp.third_check,
  128. mp.save_file_check,
  129. mp.save_file_second_check,
  130. mp.if_save_file,
  131. mp.file_path,
  132. m.`name` AS majorName,
  133. mp.checked_file_path,
  134. mp.validate_code
  135. FROM
  136. major_production mp
  137. LEFT JOIN major m ON m.id = mp.major_id
  138. WHERE
  139. mp.major_id = #{production.majorId}
  140. <if test="production!=null and production.afterProduction==null
  141. and production.statementNo==null and production.reportNo!=null and production.reportNo!='' ">
  142. and mp.report_no = #{production.reportNo}
  143. </if>
  144. <if test="production!=null and production.afterProduction==null
  145. and production.statementNo!=null and production.statementNo!='' and production.reportNo==null ">
  146. and mp.report_no = #{production.statementNo}
  147. </if>
  148. <if test="production!=null and production.afterProduction==null and production.statementNo!=null
  149. and production.statementNo!='' and production.reportNo!=null and production.reportNo!=''">
  150. and mp.report_no in (#{production.statementNo},#{production.reportNo})
  151. </if>
  152. and mp.deleted = 0 and m.deleted = 0
  153. order by mp.created ASC
  154. </select>
  155. <select id="saveDonePage" parameterType="com.dayou.vo.MajorProductionSaveDoneVO" resultType="com.dayou.vo.MajorProductionSaveDoneVO">
  156. SELECT
  157. mp.id,
  158. mp.name,
  159. mp.major_id,
  160. mp.report_no,
  161. m.order_id,
  162. m.name as orderName,
  163. u1.name as clientManager,
  164. u2.name as principal,
  165. m.business_object_type,
  166. mp.production,
  167. mp.repertory_state,
  168. mp.save_file_date,
  169. pf.real_amount
  170. FROM
  171. major_production mp
  172. LEFT JOIN major m ON m.id = mp.major_id
  173. LEFT JOIN user u1 ON u1.id = m.client_manager_id
  174. LEFT JOIN user u2 ON u2.id = m.principal_id
  175. left join (select business_id,production_no,real_amount, production_type from production_fund where business_type='MAJOR_BUSINESS' and deleted = 0) pf
  176. on (pf.business_id = mp.major_id and pf.production_no =mp.report_no and mp.production = pf.production_type)
  177. where mp.deleted = 0 and m.deleted = 0 and mp.if_save_file= 1
  178. <if test="keyword!=null and keyword!='' ">
  179. and (
  180. mp.name like concat('%',#{keyword},'%')
  181. or m.order_id like concat('%',#{keyword},'%')
  182. or m.name like concat('%',#{keyword},'%')
  183. or u1.NAME like concat('%',#{keyword},'%')
  184. or u2.NAME like concat('%',#{keyword},'%')
  185. or mp.report_no like concat('%',#{keyword},'%')
  186. )
  187. </if>
  188. <if test="done!=null and done.production!=null and done.production!=''">
  189. and mp.production =#{done.production}
  190. </if>
  191. <if test="done!=null and done.startDate!=null and done.startDate!=''">
  192. and mp.save_file_date &gt;= #{done.startDate}
  193. </if>
  194. <if test="done!=null and done.endDate!=null and done.endDate!=''">
  195. and mp.save_file_date &lt;= #{done.endDate}
  196. </if>
  197. order by mp.save_file_date desc
  198. </select>
  199. <select id="getHouse" parameterType="com.dayou.vo.MajorProductionVO" resultType="com.dayou.vo.MajorProductionVO">
  200. select
  201. (@i := @i + 1) AS id,
  202. temp.* from (SELECT
  203. '大中型' AS businessType,
  204. mp.report_no AS reportNo,
  205. ( CASE mp.production WHEN 'STATEMENT' THEN '价值意见书' WHEN 'REPORT' THEN '报告' ELSE '复评函' END ) production,
  206. mp.repertory_state,
  207. mp.repertory_in_time,
  208. u.name as clientManager
  209. FROM
  210. major_production mp left join major m on m.id = mp.major_id
  211. left join user u on u.id = m.client_manager_id
  212. WHERE
  213. mp.deleted = 0
  214. AND mp.repertory_state = 0 UNION ALL
  215. SELECT
  216. '资产' AS business_type,
  217. ap.production_no AS reportNo,
  218. ( CASE ap.production_type WHEN 'STATEMENT' THEN '价值意见书' WHEN 'REPORT' THEN '报告' WHEN 'CONSULT' THEN '咨询报告' WHEN 'TECHNIC' THEN '技术报告' WHEN 'FINAL' THEN '结果报告' ELSE '复评函' END ) production,
  219. ap.repertory_state,
  220. ap.repertory_in_time,
  221. u.name as clientManager
  222. FROM
  223. assets_production ap left join assets a on a.id = ap.business_id
  224. left join user u on u.id = a.client_manager_id
  225. WHERE
  226. ap.deleted = 0
  227. AND ap.repertory_state = 0 UNION ALL
  228. SELECT
  229. '个贷' AS business_type,
  230. p.order_id AS reportNo,
  231. ( CASE pp.production WHEN 'STATEMENT' THEN '价值意见书' WHEN 'REPORT' THEN '报告' WHEN 'CONSULT' THEN '咨询报告' WHEN 'TECHNIC' THEN '技术报告' WHEN 'FINAL' THEN '结果报告' ELSE '复评函' END ) production,
  232. pp.repertory_state,
  233. pp.repertory_in_time,
  234. u.name as clientManager
  235. FROM
  236. personal_production pp
  237. LEFT JOIN personal_target pt ON pt.id = pp.target_id
  238. LEFT JOIN personal p ON p.id = pt.personal_id
  239. left join user u on u.id = p.client_manager_id
  240. WHERE
  241. p.deleted = 0
  242. AND pp.repertory_state = 0
  243. AND pt.deleted = 0
  244. AND pp.deleted = 0) temp
  245. <where>
  246. <if test="vo!=null and vo.reportNo!=null and vo.reportNo!=''">
  247. and temp.reportNo =#{vo.reportNo}
  248. </if>
  249. <if test="vo!=null and vo.production!=null and vo.production!=''">
  250. and temp.production =#{vo.production}
  251. </if>
  252. <if test="vo!=null and vo.startDate!=null and vo.startDate!=''">
  253. and temp.repertory_in_time &gt;= #{vo.startDate}
  254. </if>
  255. <if test="vo!=null and vo.endDate!=null and vo.endDate!=''">
  256. and temp.repertory_in_time &lt;= #{vo.endDate}
  257. </if>
  258. </where>
  259. order by temp.repertory_in_time desc
  260. </select>
  261. <resultMap id="myOrderMap" type="com.dayou.vo.MajorOrderVO">
  262. <result column="id" property="id" />
  263. <result column="businessId" property="businessId" />
  264. <result column="order_id" property="orderId" />
  265. <result column="orderName" property="orderName" />
  266. <result column="productionNo" property="productionNo" />
  267. <result column="if_save_file" property="ifSaveFile" />
  268. <result column="principal" property="principal" />
  269. <result column="clientManager" property="clientManager" />
  270. <result column="clienteleName" property="clienteleName" />
  271. <result column="clienteleSubName" property="clienteleSubName" />
  272. <result column="bailor" property="bailor" />
  273. <result column="clienteleContactName" property="clienteleContactName" />
  274. <result column="owner" property="owner" />
  275. <result column="orderFundId" property="orderFundId" />
  276. <result column="should_amount" property="shouldAmount" />
  277. <result column="real_amount" property="realAmount" />
  278. <result column="created" property="created" />
  279. <result column="remark" property="remark" />
  280. <result column="mDeclareResult" property="mDeclareResult" />
  281. <result column="eDeclareResult" property="eDeclareResult" />
  282. <association property="currentNodeName" javaType="java.lang.String"
  283. select="queryCurrentNodeName" column="{businessId=businessId,productionNo=productionNo}"/>
  284. </resultMap>
  285. <select id="queryCurrentNodeName" resultType="java.lang.String">
  286. select name from work_node where id = (
  287. select node_id from work_flow_node_instance where
  288. business_type='MAJOR_BUSINESS'
  289. and state= 'PENDING'
  290. AND deleted = 0
  291. and business_id = #{businessId}
  292. <if test="productionNo!=null and productionNo!=''">
  293. and (business_min_id = #{productionNo} or business_sub_id = #{productionNo}) order by id desc limit 1
  294. </if>
  295. <if test="productionNo==null">
  296. and business_sub_id is null and business_min_id is null
  297. </if>
  298. )
  299. </select>
  300. <sql id="myMajorOrder">
  301. SELECT
  302. mp.id AS id,
  303. m.id as businessId,
  304. m.order_id,
  305. m.name as orderName,
  306. mp.report_no as productionNo,
  307. mp.if_save_file,
  308. u.name as principal,
  309. u1.name as clientManager,
  310. cc.name as clienteleName,
  311. cc1.name as clienteleSubName,
  312. cl.name as clienteleContactName,
  313. m.bailor,
  314. m.owner,
  315. m.created,
  316. orf.id as orderFundId,
  317. orf.should_amount,
  318. orf.real_amount,
  319. orf.remark,
  320. ( 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,
  321. ( 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
  322. FROM
  323. major m
  324. left join major_production mp on mp.major_id = m.id
  325. left join user u on u.id = m.principal_id
  326. left join user u1 on u1.id = m.client_manager_id
  327. left join customer_company cc on cc.id = m.clientele_id
  328. left join customer_company cc1 on cc1.id = m.clientele_sub_id
  329. left join customer_linkman cl on cl.id = m.clientele_contact_id
  330. left join (select * from order_fund where business_type ='MAJOR_BUSINESS' and deleted = 0) orf on orf.business_id = m.id
  331. </sql>
  332. <select id="myOrder" parameterType="com.dayou.vo.MajorOrderVO" resultMap="myOrderMap">
  333. <include refid="myMajorOrder" />
  334. where m.deleted = 0
  335. and m.client_manager_id = #{vo.clientManagerId}
  336. <if test="keyword!=null and keyword!='' ">
  337. and (
  338. m.name like concat ('%',#{keyword},'%')
  339. or m.order_id like concat('%',#{keyword},'%')
  340. or u.name like concat('%',#{keyword},'%')
  341. or u1.name like concat('%',#{keyword},'%')
  342. or cc.name like concat('%',#{keyword},'%')
  343. or cc1.name like concat('%',#{keyword},'%')
  344. or cl.name like concat('%',#{keyword},'%')
  345. or m.bailor like concat('%',#{keyword},'%')
  346. or m.owner like concat('%',#{keyword},'%')
  347. or orf.should_amount like concat('%',#{keyword},'%')
  348. or orf.real_amount like concat('%',#{keyword},'%')
  349. or orf.remark like concat('%',#{keyword},'%')
  350. )
  351. </if>
  352. <if test="vo!=null and vo.principalId!=null and vo.principalId!=''">
  353. AND m.principal_id like concat('%',#{vo.principalId},'%')
  354. </if>
  355. <if test="vo!=null and vo.orderId!=null and vo.orderId!=''">
  356. AND m.order_id like concat('%',#{vo.orderId},'%')
  357. </if>
  358. <if test="vo!=null and vo.productionNo!=null and vo.productionNo!=''">
  359. AND mp.report_no like concat('%',#{vo.productionNo},'%')
  360. </if>
  361. <if test="vo!=null and vo.clienteleName!=null and vo.clienteleName!=''">
  362. AND cc.name like concat('%',#{vo.clienteleName},'%')
  363. </if>
  364. <if test="vo!=null and vo.clienteleSubName!=null and vo.clienteleSubName!=''">
  365. AND cc1.name like concat('%',#{vo.clienteleSubName},'%')
  366. </if>
  367. <if test="vo!=null and vo.startDate!=null and vo.startDate!=''">
  368. and m.created &gt;= #{vo.startDate}
  369. </if>
  370. <if test="vo!=null and vo.endDate!=null and vo.endDate!=''">
  371. and m.created &lt;= #{vo.endDate}
  372. </if>
  373. order by m.created DESC
  374. </select>
  375. <select id="waitingClaim" parameterType="com.dayou.vo.MajorOrderVO" resultType="com.dayou.vo.MajorOrderVO">
  376. <include refid="myMajorOrder" />
  377. where m.deleted = 0
  378. and m.client_manager_id = #{vo.clientManagerId} and orf.id is not null
  379. <if test="vo!=null and vo.name!=null and vo.name !=''">
  380. and m.name like concat ('%',#{vo.name},'%')
  381. </if>
  382. <if test="vo!=null and vo.orderId!=null and vo.orderId !=''">
  383. and m.order_id like concat ('%',#{vo.orderId},'%')
  384. </if>
  385. <if test="vo!=null and vo.mDeclareResult!=null and vo.mDeclareResult =='审核通过'">
  386. 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 ) = '审核通过'
  387. </if>
  388. <if test="vo!=null and vo.mDeclareResult!=null and vo.mDeclareResult =='审核拒绝'">
  389. 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 ) = '审核拒绝'
  390. </if>
  391. <if test="vo!=null and vo.mDeclareResult!=null and vo.mDeclareResult =='审核中'">
  392. 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 ) = '审核中'
  393. </if>
  394. <if test="vo!=null and vo.mDeclareResult!=null and vo.mDeclareResult =='未申报'">
  395. 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
  396. </if>
  397. <if test="vo!=null and vo.eDeclareResult!=null and vo.eDeclareResult =='审核通过'">
  398. 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 ) = '审核通过'
  399. </if>
  400. <if test="vo!=null and vo.eDeclareResult!=null and vo.eDeclareResult =='审核拒绝'">
  401. 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 ) = '审核拒绝'
  402. </if>
  403. <if test="vo!=null and vo.eDeclareResult!=null and vo.eDeclareResult =='审核中'">
  404. 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 ) = '审核中'
  405. </if>
  406. <if test="vo!=null and vo.eDeclareResult!=null and vo.eDeclareResult =='未申报'">
  407. 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
  408. </if>
  409. order by m.created DESC
  410. </select>
  411. <select id="getMajorProductionAboutFundId" parameterType="java.lang.Long" resultType="com.dayou.entity.MajorProduction">
  412. SELECT
  413. mp.id,
  414. pf.id AS productionFundId,
  415. sum(pf.real_amount) as realAmount,
  416. mp.production,
  417. mp.NAME,
  418. mp.client_name,
  419. mp.OWNER,
  420. mp.evaluate_acreage,
  421. mp.evaluate_amount,
  422. mp.evaluate_price,
  423. mp.report_no,
  424. mp.repertory_state,
  425. mp.repertory_in_time,
  426. mp.repertory_out_time,
  427. mp.if_save_file,
  428. mp.save_file_date,
  429. mp.delivery,
  430. `of`.should_amount AS orderShouldAmount
  431. FROM
  432. major_production mp
  433. 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 )
  434. LEFT JOIN (SELECT business_id,should_amount FROM order_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0) AS `of` ON mp.major_id = `of`.business_id
  435. WHERE
  436. mp.major_id = #{majorId} and mp.deleted = 0
  437. AND mp.NAME IS NOT NULL
  438. GROUP BY mp.id
  439. ORDER BY mp.id DESC
  440. </select>
  441. <select id="todoSaveFilePage" parameterType="com.dayou.vo.TaskTodoVO" resultType="com.dayou.vo.TaskTodoVO">
  442. SELECT
  443. wfni.id,
  444. mp.id AS productionId,
  445. mp.NAME,
  446. mp.repertory_state,
  447. wtr.id AS taskId,
  448. wfni.id AS currentNodeId,
  449. wfni.business_min_id,
  450. wfni.business_sub_id,
  451. mp.report_no,
  452. wfni.business_id,
  453. m.NAME AS orderName,
  454. m.order_id,
  455. u1.NAME AS clientManager,
  456. u2.NAME AS principal,
  457. d.NAME AS departmentName,
  458. wfni.NAME AS nodeName,
  459. wfni.CODE AS nodeCode,
  460. u.NAME AS HANDLER,
  461. pf.real_amount AS realAmount,
  462. wtr.handler_id,
  463. wtr.finished AS taskFinished,
  464. DATE_FORMAT( m.created, '%Y-%m-%d' ) AS created,
  465. wtr.created AS taskCreated,
  466. mp.production
  467. FROM
  468. work_task_record wtr
  469. LEFT JOIN work_node_task wnt ON wnt.id = wtr.task_id
  470. INNER JOIN (
  471. SELECT
  472. wn.NAME,
  473. wn.CODE,
  474. wfni.id,
  475. wfni.business_id,
  476. wfni.business_sub_id,
  477. wfni.business_min_id,
  478. wfni.state
  479. FROM
  480. work_flow_node_instance wfni
  481. LEFT JOIN work_node wn ON wn.id = wfni.node_id
  482. WHERE
  483. wfni.business_type = 'MAJOR_BUSINESS'
  484. AND wfni.state = 'PENDING'
  485. AND wfni.deleted = 0
  486. AND wn.deleted = 0
  487. AND wn.CODE = 'BUSINESS_ARCHIVING'
  488. ) wfni ON wtr.instance_id = wfni.id
  489. LEFT JOIN major m ON m.id = wfni.business_id
  490. LEFT JOIN user u ON u.id = wtr.handler_id
  491. LEFT JOIN user u1 ON u1.id = m.client_manager_id
  492. LEFT JOIN user u2 ON u2.id = m.principal_id
  493. LEFT JOIN department d ON d.id = m.department_id
  494. LEFT JOIN ( SELECT id, major_id, report_no, NAME, repertory_state, production FROM major_production WHERE deleted = 0 ) mp
  495. ON ( mp.major_id = m.id AND (mp.report_no = wfni.business_sub_id or mp.report_no = wfni.business_min_id))
  496. LEFT JOIN ( SELECT business_id, production_no, real_amount FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf
  497. ON ( pf.business_id = m.id AND pf.production_no = mp.report_no )
  498. WHERE u.deleted = 0
  499. and wtr.handler_id =#{todoVO.handlerId}
  500. AND wnt.deleted = 0
  501. AND wtr.deleted = 0
  502. # and pf.real_amount is not null
  503. <if test="keyword!=null and keyword!='' ">
  504. and (
  505. mp.name like concat('%',#{keyword},'%')
  506. or m.order_id like concat('%',#{keyword},'%')
  507. or m.name like concat('%',#{keyword},'%')
  508. or wfni.business_min_id like concat('%',#{keyword},'%')
  509. or u1.NAME like concat('%',#{keyword},'%')
  510. or u2.NAME like concat('%',#{keyword},'%')
  511. )
  512. </if>
  513. <if test="todoVO!=null and todoVO.production!=null and todoVO.production!=''">
  514. and mp.production =#{todoVO.production}
  515. </if>
  516. ORDER BY
  517. wtr.created DESC
  518. </select>
  519. <update id="updateSaveFileInfo" parameterType="java.util.List">
  520. update major_production set if_save_file = 1 ,save_file_date= now() where id in (
  521. <foreach collection="productionIds" index="index" item="item" separator=",">
  522. #{item}
  523. </foreach>
  524. )
  525. </update>
  526. <select id="performanceAllotPage" parameterType="com.dayou.vo.MajorProductionPerformanceVO" resultType="com.dayou.vo.MajorProductionPerformanceVO">
  527. SELECT
  528. mp.id,
  529. m.order_id,
  530. m.id as majorId,
  531. mp.NAME,
  532. mp.report_no,
  533. (case mp.production when 'REPORT' then '报告' when 'STATEMENT' THEN '价值意见书' else '复评函' end ) as production,
  534. ( 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,
  535. ( SELECT major_production_id FROM major_production_allot WHERE deleted = 0 and user_type = 'EVALUATE' GROUP BY major_production_id HAVING major_production_id = mp.id ) AS isAllot
  536. FROM
  537. major_production mp
  538. LEFT JOIN major m ON m.id = mp.major_id
  539. WHERE
  540. m.deleted = 0
  541. AND mp.deleted = 0
  542. AND mp.NAME IS NOT NULL
  543. 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}))
  544. order by isAllot ASC;
  545. </select>
  546. <select id="validateProd" parameterType="java.lang.Long" resultType="com.dayou.vo.ProdValidateVO">
  547. SELECT
  548. mp.evaluate_acreage as acreage,
  549. ROUND(mp.evaluate_amount/10000,2) as amount,
  550. mp.name AS productionName,
  551. mp.report_no AS productionNo ,
  552. mp.client_name as bailor
  553. FROM
  554. major_production mp
  555. WHERE
  556. mp.id = #{id}
  557. AND mp.deleted = 0
  558. </select>
  559. <select id="waitingClaimProd" parameterType="com.dayou.vo.MajorProductionVO" resultType="com.dayou.vo.MajorProductionVO">
  560. SELECT
  561. m.id as majorId,
  562. m.order_id,
  563. m.financial,
  564. mp.id,
  565. mp.name,
  566. mp.report_no,
  567. mp.standard_amount,
  568. (case mp.production when 'STATEMENT' THEN '意见书' when 'REPORT' THEN '报告' when 'LETTER' THEN '复评函' else '' end) production,
  569. u.NAME AS principal,
  570. u1.NAME AS clientManager,
  571. cc.NAME AS clienteleName,
  572. orf.id AS orderFundId,
  573. orf.should_amount,
  574. off.id as productionFundId,
  575. off.real_amount,
  576. off.standard_amount,
  577. 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 ),
  578. ( 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,
  579. 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 ),
  580. ( 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
  581. FROM
  582. major_production mp
  583. left join major m on m.id = mp.major_id
  584. 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
  585. 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)
  586. LEFT JOIN user u ON u.id = m.principal_id
  587. LEFT JOIN user u1 ON u1.id = m.client_manager_id
  588. LEFT JOIN customer_company cc ON cc.id = m.clientele_id
  589. WHERE
  590. m.deleted = 0
  591. AND mp.deleted = 0
  592. AND m.client_manager_id = #{vo.clientManagerId}
  593. <if test="vo!=null and vo.name!=null and vo.name !=''">
  594. and mp.name like concat ('%',#{vo.name},'%')
  595. </if>
  596. <if test="vo!=null and vo.orderId!=null and vo.orderId !=''">
  597. and m.order_id like concat ('%',#{vo.orderId},'%')
  598. </if>
  599. <if test="vo!=null and vo.reportNo!=null and vo.reportNo !=''">
  600. and mp.report_no like concat ('%',#{vo.reportNo},'%')
  601. </if>
  602. <if test="vo!=null and vo.mDeclareResult!=null and vo.mDeclareResult =='审核通过'">
  603. 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 ) = '审核通过'
  604. </if>
  605. <if test="vo!=null and vo.mDeclareResult!=null and vo.mDeclareResult =='审核拒绝'">
  606. 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 ) = '审核拒绝'
  607. </if>
  608. <if test="vo!=null and vo.mDeclareResult!=null and vo.mDeclareResult =='审核中'">
  609. 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 ) = '审核中'
  610. </if>
  611. <if test="vo!=null and vo.mDeclareResult!=null and vo.mDeclareResult =='未申报'">
  612. 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
  613. </if>
  614. <if test="vo!=null and vo.eDeclareResult!=null and vo.eDeclareResult =='审核通过'">
  615. 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 ) = '审核通过'
  616. </if>
  617. <if test="vo!=null and vo.eDeclareResult!=null and vo.eDeclareResult =='审核拒绝'">
  618. 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 ) = '审核拒绝'
  619. </if>
  620. <if test="vo!=null and vo.eDeclareResult!=null and vo.eDeclareResult =='审核中'">
  621. 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 ) = '审核中'
  622. </if>
  623. <if test="vo!=null and vo.eDeclareResult!=null and vo.eDeclareResult =='未申报'">
  624. 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
  625. </if>
  626. ORDER BY
  627. mp.created DESC
  628. </select>
  629. <update id="cancelDelivery">
  630. update major_production set delivery = 0 ,delivery_date = null where major_id = #{businessId} and report_no = #{businessSubId} and production = #{productionType}
  631. </update>
  632. <select id="getMajorProductionById" parameterType="java.lang.Long" resultType="com.dayou.vo.MajorProductionVO">
  633. SELECT
  634. mp.id,
  635. mp.major_id,
  636. m.order_id,
  637. mp.report_no,
  638. mp.production,
  639. m.client_manager_id,
  640. m.department_id,
  641. d.leader_id as departmentLeaderId
  642. FROM
  643. major_production mp
  644. LEFT JOIN major m ON m.id = mp.major_id
  645. left join department d on d.id = m.department_id
  646. WHERE
  647. mp.id = #{productionId} and mp.deleted = 0 and m.deleted = 0
  648. </select>
  649. <select id="getProductionNosByMajorId" parameterType="java.lang.Long" resultType="java.lang.String">
  650. select report_no from major_production where major_id = #{majorId} and deleted = 0
  651. </select>
  652. </mapper>