MajorMapper.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  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.MajorMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.dayou.entity.Major">
  6. <result column="id" property="id" />
  7. <result column="deleted" property="deleted" />
  8. <result column="created" property="created" />
  9. <result column="modified" property="modified" />
  10. <result column="name" property="name" />
  11. <result column="order_id" property="orderId" />
  12. <result column="financial" property="financial" />
  13. <result column="allot_type" property="allotType" />
  14. <result column="client_manager_id" property="clientManagerId" />
  15. <result column="principal_id" property="principalId" />
  16. <result column="department_id" property="departmentId" />
  17. <result column="business_object_type" property="businessObjectType" />
  18. <result column="special_type" property="specialType" />
  19. <result column="business_gener" property="businessGener" />
  20. <result column="evaluate_aim" property="evaluateAim" />
  21. <result column="entrust_again" property="entrustAgain" />
  22. <result column="multiple_removal" property="multipleRemoval" />
  23. <result column="informal_evaluate" property="informalEvaluate" />
  24. <result column="clientele_type" property="clienteleType" />
  25. <result column="clientele_id" property="clienteleId" />
  26. <result column="clientele_contact_id" property="clienteleContactId" />
  27. <result column="dispense_benefit" property="dispenseBenefit" />
  28. <result column="nonnative" property="nonnative" />
  29. <result column="refinance" property="refinance" />
  30. <result column="loan_limit" property="loanLimit" />
  31. <result column="loan_period" property="loanPeriod" />
  32. <result column="loan_nature" property="loanNature" />
  33. <result column="loan_aim" property="loanAim" />
  34. <result column="loan_expire" property="loanExpire" />
  35. <result column="bailor" property="bailor" />
  36. <result column="bailor_address" property="bailorAddress" />
  37. <result column="bailor_contact_name" property="bailorContactName" />
  38. <result column="bailor_contact_tel" property="bailorContactTel" />
  39. <result column="owner" property="owner" />
  40. <result column="owner_tel" property="ownerTel" />
  41. <result column="urgent" property="urgent" />
  42. <result column="terminal_clientele_id" property="terminalClienteleId" />
  43. <result column="terminal_clientele_type" property="terminalClienteleType" />
  44. <result column="terminal_clientele_contact_id" property="terminalClienteleContactId" />
  45. <result column="remark" property="remark" />
  46. <result column="members" property="members" />
  47. </resultMap>
  48. <!-- 通用查询结果列 -->
  49. <sql id="Base_Column_List">
  50. id,
  51. deleted,
  52. created,
  53. modified,
  54. name, order_id, financial, allot_type, client_manager_id, principal_id, department_id, business_object_type, special_type, business_gener,
  55. evaluate_aim, entrust_again, multiple_removal, informal_evaluate, clientele_type, clientele_id, clientele_contact_id, dispense_benefit,
  56. nonnative, refinance, loan_limit, loan_period, loan_nature, loan_aim, loan_expire, bailor, bailor_address, bailor_contact_name,
  57. bailor_contact_tel, owner, owner_tel, urgent, terminal_clientele_id, terminal_clientele_type, terminal_clientele_contact_id, remark,members,
  58. production_info,printing,printing_remark
  59. </sql>
  60. <resultMap id="majorVoMap" type="com.dayou.vo.MajorListVO">
  61. <result column="id" property="id" />
  62. <result column="created" property="created" />
  63. <result column="name" property="name" />
  64. <result column="order_id" property="orderId" />
  65. <result column="financial" property="financial" />
  66. <result column="allot_type" property="allotType" />
  67. <result column="client_manager_id" property="clientManagerId" />
  68. <result column="clientManager" property="clientManager" />
  69. <result column="principal_id" property="principalId" />
  70. <result column="principal" property="principal" />
  71. <result column="department_id" property="departmentId" />
  72. <result column="departmentName" property="departmentName" />
  73. <result column="business_object_type" property="businessObjectType" />
  74. <result column="clientele_id" property="clienteleId" />
  75. <result column="clientele" property="clientele" />
  76. <result column="clientele_contact_id" property="clienteleContactId" />
  77. <result column="clienteleContact" property="clienteleContact" />
  78. <result column="clienteleContactTel" property="clienteleContactTel" />
  79. <result column="currentNodeId" property="currentNodeId" />
  80. <result column="currentNodeName" property="currentNodeName" />
  81. <result column="cClienteleName" property="cClienteleName" />
  82. <result column="cClienteleSubName" property="cClienteleSubName" />
  83. <result column="cClienteleContactName" property="cClienteleContactName" />
  84. <result column="cMobile" property="cMobile" />
  85. <collection property="productions" ofType="com.dayou.vo.MajorProductionVO" select="selectProduction" column="id"/>
  86. </resultMap>
  87. <select id="getPage" parameterType="com.dayou.vo.MajorVO" resultMap="majorVoMap">
  88. SELECT
  89. DISTINCT
  90. m.id,
  91. m.created,
  92. m.name,
  93. m.order_id,
  94. m.financial,
  95. m.allot_type,
  96. m.client_manager_id,
  97. u.name as clientManager,
  98. m.principal_id,
  99. u1.name as principal,
  100. m.department_id,
  101. d.name as departmentName,
  102. m.business_object_type,
  103. m.clientele_id,
  104. m.clientele_contact_id,
  105. m.clientele_id as clientele,
  106. m.clientele_contact_id as clienteleContact,
  107. cc1.name as cClienteleName,
  108. cc2.name as cClienteleSubName,
  109. cl1.name as cClienteleContactName,
  110. cl1.mobile as cMobile
  111. FROM
  112. major m
  113. left join user u on u.id = m.client_manager_id
  114. left join user u1 on u1.id = m.principal_id
  115. left join department d on d.id = m.department_id
  116. inner join ( SELECT id, node_id, business_id, business_sub_id, state FROM work_flow_node_instance WHERE business_type = 'MAJOR_BUSINESS' and deleted = 0 and state='PENDING') wfni
  117. ON wfni.business_id = m.id
  118. left join customer_company cc1 on cc1.id = m.clientele_id
  119. left join customer_company cc2 on cc2.id = m.clientele_sub_id
  120. left join customer_linkman cl1 on cl1.id = m.clientele_contact_id
  121. where m.deleted = 0
  122. <if test="keyword!=null and keyword!='' ">
  123. and (
  124. m.name like concat ('%',#{keyword},'%')
  125. or m.order_id like concat('%',#{keyword},'%')
  126. or u.name like concat('%',#{keyword},'%')
  127. or u1.name like concat('%',#{keyword},'%')
  128. or cc2.name like concat('%',#{keyword},'%')
  129. or cc1.name like concat('%',#{keyword},'%')
  130. or cl1.name like concat('%',#{keyword},'%')
  131. or cl1.mobile like concat('%',#{keyword},'%')
  132. or m.business_object_type like concat('%',#{keyword},'%')
  133. or d.name like concat('%',#{keyword},'%')
  134. or m.allot_type like concat('%',#{keyword},'%')
  135. )
  136. </if>
  137. <if test="major!=null and major.financial!=null">
  138. and m.financial = #{major.financial}
  139. </if>
  140. <if test="major!=null and major.startDate!=null and major.startDate!=''">
  141. and m.created &gt;= #{major.startDate}
  142. </if>
  143. <if test="major!=null and major.endDate!=null and major.endDate!=''">
  144. and m.created &lt;= #{major.endDate}
  145. </if>
  146. ORDER BY
  147. created DESC
  148. </select>
  149. <select id="getTerminatedPage" resultType="com.dayou.vo.MajorVO">
  150. SELECT
  151. wfni.currentNodeId AS id,
  152. wfni.nodeName,
  153. wfni.productionName,
  154. wfni.business_sub_id AS statementNo,
  155. wfni.business_min_id AS reportNo,
  156. m.id AS majorId,
  157. m.created,
  158. m.NAME,
  159. m.order_id,
  160. m.financial,
  161. m.allot_type,
  162. m.client_manager_id,
  163. u.NAME AS clientManager,
  164. m.principal_id,
  165. u1.NAME AS principal,
  166. m.department_id,
  167. d.NAME AS department,
  168. m.business_object_type,
  169. m.clientele_id,
  170. m.clientele_contact_id,
  171. m.clientele_id AS clientele,
  172. m.clientele_contact_id AS clienteleContact,
  173. cc1.NAME AS cClienteleName,
  174. cc2.NAME AS cClienteleSubName,
  175. cl1.NAME AS cClienteleContactName,
  176. cl1.mobile AS cMobile,
  177. wfni.client_name,
  178. wfni.client_tel,
  179. wfni.evaluate_amount,
  180. wfni.OWNER,
  181. wfni.HANDLER,
  182. wfni.nodeCode,
  183. wfni.currentNodeId,
  184. wfni.`comment`
  185. FROM
  186. major m
  187. LEFT JOIN user u ON u.id = m.client_manager_id
  188. LEFT JOIN user u1 ON u1.id = m.principal_id
  189. LEFT JOIN department d ON d.id = m.department_id
  190. INNER JOIN (
  191. SELECT
  192. wf.id AS currentNodeId,
  193. wf.node_id,
  194. wf.business_id,
  195. wf.business_sub_id,
  196. wf.business_min_id,
  197. wf.state,
  198. wn.NAME AS nodeName,
  199. mp.NAME AS productionName,
  200. mp.client_name,
  201. mp.client_tel,
  202. mp.evaluate_amount,
  203. mp.OWNER,
  204. u.NAME AS HANDLER,
  205. wn.CODE AS nodeCode,
  206. mp.client_address,
  207. wf.modified,
  208. wf.`comment`
  209. FROM
  210. work_flow_node_instance wf
  211. LEFT JOIN work_node wn ON wn.id = wf.node_id
  212. LEFT JOIN ( SELECT report_no, major_id, NAME, client_name,client_address, client_tel, evaluate_amount, OWNER FROM major_production WHERE deleted = 0 ) mp ON ( mp.major_id = wf.business_id AND mp.report_no = ifnull( wf.business_min_id, wf.business_sub_id ) )
  213. LEFT JOIN work_task_record wtr ON wtr.instance_id = wf.id
  214. LEFT JOIN user u ON u.id = wtr.handler_id
  215. WHERE
  216. wf.business_type = 'MAJOR_BUSINESS'
  217. AND wf.deleted = 0
  218. AND wf.state = 'CLOSED'
  219. ) wfni ON wfni.business_id = m.id
  220. LEFT JOIN customer_company cc1 ON cc1.id = m.clientele_id
  221. LEFT JOIN customer_company cc2 ON cc2.id = m.clientele_sub_id
  222. LEFT JOIN customer_linkman cl1 ON cl1.id = m.clientele_contact_id
  223. WHERE m.deleted = 0
  224. <if test="keyword!=null and keyword!='' ">
  225. and (
  226. m.name like concat ('%',#{keyword},'%')
  227. or m.order_id like concat('%',#{keyword},'%')
  228. or u.name like concat('%',#{keyword},'%')
  229. or u1.name like concat('%',#{keyword},'%')
  230. or cc2.name like concat('%',#{keyword},'%')
  231. or cc1.name like concat('%',#{keyword},'%')
  232. or cl1.name like concat('%',#{keyword},'%')
  233. or cl1.mobile like concat('%',#{keyword},'%')
  234. or m.business_object_type like concat('%',#{keyword},'%')
  235. or d.name like concat('%',#{keyword},'%')
  236. or m.allot_type like concat('%',#{keyword},'%')
  237. or wfni.client_name like concat('%',#{keyword},'%')
  238. or wfni.productionName like concat('%',#{keyword},'%')
  239. or wfni.business_sub_id like concat('%',#{keyword},'%')
  240. or wfni.owner like concat('%',#{keyword},'%')
  241. or wfni.business_min_id like concat('%',#{keyword},'%')
  242. or wfni.client_address like concat('%',#{keyword},'%')
  243. or wfni.productionName like concat('%',#{keyword},'%')
  244. )
  245. </if>
  246. <if test="major!=null and major.financial!=null">
  247. and m.financial = #{major.financial}
  248. </if>
  249. <if test="major!=null and major.startDate!=null and major.startDate!=''">
  250. and m.created &gt;= #{major.startDate}
  251. </if>
  252. <if test="major!=null and major.endDate!=null and major.endDate!=''">
  253. and m.created &lt;= #{major.endDate}
  254. </if>
  255. <if test="major!=null and major.nodeCode!=null and major.nodeCode!=''">
  256. and wfni.nodeCode = #{major.nodeCode}
  257. </if>
  258. <if test="major!=null and major.clientName!=null and major.clientName!=''">
  259. and wfni.client_name like concat('%',#{major.clientName},'%')
  260. </if>
  261. <if test="major!=null and major.clientManagerId!=null ">
  262. and m.client_manager_id = #{major.clientManagerId}
  263. </if>
  264. <if test="major!=null and major.principalId!=null ">
  265. and m.principal_id = #{major.principalId}
  266. </if>
  267. <if test="major!=null and major.businessObjectType!=null and major.businessObjectType!=''">
  268. and m.business_object_type = #{major.businessObjectType}
  269. </if>
  270. <if test="major!=null and major.departmentId!=null ">
  271. and m.department_id = #{major.departmentId}
  272. </if>
  273. order by wfni.modified DESC
  274. </select>
  275. <select id="selectProduction" parameterType="java.lang.Long" resultType="com.dayou.vo.MajorProductionVO">
  276. select *,sum(amount) as realAmount from (SELECT
  277. mp.id,
  278. mp.report_no,
  279. mp.name,
  280. mp.client_name,
  281. mp.client_tel,
  282. mp.evaluate_acreage,
  283. mp.evaluate_amount,
  284. mp.repertory_state,
  285. mp.if_save_file,
  286. wfni.id AS currentNodeId,
  287. wn.name AS currentNodeName,
  288. wfni.state,
  289. mp.major_id,
  290. pf.real_amount as amount
  291. FROM
  292. (select * from major_production where major_id = #{id} and deleted = 0) mp left join
  293. ( SELECT id, node_id, business_id, business_sub_id, state FROM work_flow_node_instance WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 AND business_id = #{id} and state='PENDING' ) wfni
  294. ON ( wfni.business_id = mp.major_id AND mp.report_no = wfni.business_sub_id )
  295. LEFT JOIN (select id,name from work_node where deleted =0) wn ON wn.id = wfni.node_id
  296. left join (select business_id,business_sub_id,real_amount,production_type from production_fund where deleted = 0) pf on (pf.business_id = mp.major_id and pf.business_sub_id = mp.report_no and pf.production_type = mp.production)) t GROUP BY report_no
  297. order by id DESC
  298. </select>
  299. <select id="getDetail" parameterType="java.lang.Long" resultType="com.dayou.vo.MajorVO">
  300. SELECT
  301. m.id,
  302. m.created,
  303. m.NAME,
  304. m.order_id,
  305. m.financial,
  306. m.allot_type,
  307. m.client_manager_id,
  308. m.principal_id,
  309. m.department_id,
  310. m.business_object_type,
  311. m.special_type,
  312. m.business_gener,
  313. m.evaluate_aim,
  314. m.entrust_again,
  315. m.multiple_removal,
  316. m.informal_evaluate,
  317. m.clientele_type,
  318. m.clientele_id,
  319. m.clientele_sub_id,
  320. m.clientele_contact_id,
  321. m.dispense_benefit,
  322. m.nonnative,
  323. m.refinance,
  324. m.loan_limit,
  325. m.loan_period,
  326. m.loan_nature,
  327. m.loan_aim,
  328. m.loan_expire,
  329. m.bailor,
  330. m.bailor_address,
  331. m.bailor_contact_name,
  332. m.bailor_contact_tel,
  333. m.OWNER,
  334. m.owner_tel,
  335. m.urgent,
  336. m.terminal_clientele_id,
  337. m.terminal_clientele_type,
  338. m.terminal_clientele_contact_id,
  339. m.remark,
  340. m.members,
  341. m.feedback_info,
  342. u.NAME AS clientManager ,
  343. cc1.name as cClienteleName,
  344. cc2.name as cClienteleSubName,
  345. cl1.name as cClienteleContactName,
  346. cl1.mobile as cMobile,
  347. cl1.department as cDepartment,
  348. cl1.duty as cDuty,
  349. cc3.name as tTerminalClienteleName,
  350. cc3.phone as tCompanyMobile,
  351. cl2.name as tTerminalClienteleContactName,
  352. cl2.mobile as tMobile
  353. FROM
  354. major m
  355. LEFT JOIN user u ON u.id = m.client_manager_id
  356. left join customer_company cc1 on cc1.id = m.clientele_id
  357. left join customer_company cc2 on cc2.id = m.clientele_sub_id
  358. left join customer_linkman cl1 on cl1.id = m.clientele_contact_id
  359. left join customer_company cc3 on cc3.id = m.terminal_clientele_id
  360. left join customer_linkman cl2 on cl2.id = m.terminal_clientele_contact_id where m.id =#{id}
  361. </select>
  362. <select id="staticsInformation" resultType="com.dayou.dto.MajorStaticsDTO">
  363. SELECT
  364. (SELECT count(wfni.id) FROM
  365. work_task_record wtr
  366. LEFT JOIN work_node_task wnt ON wnt.id = wtr.task_id
  367. INNER JOIN (
  368. SELECT wfni.id FROM
  369. work_flow_node_instance wfni
  370. LEFT JOIN work_node wn ON wn.id = wfni.node_id
  371. WHERE
  372. wfni.business_type = 'MAJOR_BUSINESS'
  373. AND wfni.state = 'PENDING'
  374. AND wfni.deleted = 0
  375. AND wn.deleted = 0
  376. ) wfni ON wtr.instance_id = wfni.id WHERE
  377. wtr.handler_id =#{userId}
  378. AND wnt.deleted = 0
  379. AND wtr.deleted = 0 ) as majorToDo,
  380. (SELECT count(*) FROM work_flow_log WHERE handler_id = #{userId} and business_type='MAJOR_BUSINESS') as majorDone,
  381. ( SELECT count(*) FROM major_production WHERE deleted = 0 AND if_save_file = 1 ) AS saveFileCount,
  382. ( SELECT count(*) FROM work_flow_node_instance WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 AND state = 'PENDING' ) AS pending,
  383. ( SELECT count(*) FROM major_production WHERE deleted = 0 AND production = 'STATEMENT' and repertory_state is not null ) AS statementCount,
  384. ( SELECT count(*) FROM major_production WHERE deleted = 0 AND production = 'REPORT' and repertory_state is not null ) AS reportCount,
  385. ( SELECT count(*) FROM major_production WHERE deleted = 0 AND production = 'LETTER' and repertory_state is not null ) AS letterCount,
  386. ( SELECT count(*) FROM major_production WHERE deleted = 0 AND repertory_state = 0 ) AS inWarehouseCount
  387. </select>
  388. <select id="xPage" parameterType="com.dayou.vo.MajorVO" resultType="com.dayou.vo.MajorVO">
  389. SELECT
  390. wfni.currentNodeId AS id,
  391. wfni.nodeName,
  392. wfni.productionName,
  393. wfni.business_sub_id AS statementNo,
  394. wfni.business_min_id AS reportNo,
  395. m.id AS majorId,
  396. m.created,
  397. m.NAME,
  398. m.order_id,
  399. m.financial,
  400. m.allot_type,
  401. m.client_manager_id,
  402. u.NAME AS clientManager,
  403. m.principal_id,
  404. u1.NAME AS principal,
  405. m.department_id,
  406. d.NAME AS department,
  407. m.business_object_type,
  408. m.clientele_id,
  409. m.clientele_contact_id,
  410. m.clientele_id AS clientele,
  411. m.clientele_contact_id AS clienteleContact,
  412. cc1.NAME AS cClienteleName,
  413. cc2.NAME AS cClienteleSubName,
  414. cl1.NAME AS cClienteleContactName,
  415. cl1.mobile AS cMobile,
  416. wfni.client_name,
  417. wfni.client_tel,
  418. wfni.evaluate_amount,
  419. wfni.OWNER,
  420. wfni.HANDLER,
  421. wfni.nodeCode,
  422. wfni.currentNodeId
  423. FROM
  424. major m
  425. LEFT JOIN user u ON u.id = m.client_manager_id
  426. LEFT JOIN user u1 ON u1.id = m.principal_id
  427. LEFT JOIN department d ON d.id = m.department_id
  428. INNER JOIN (
  429. SELECT
  430. wf.id AS currentNodeId,
  431. wf.node_id,
  432. wf.business_id,
  433. wf.business_sub_id,
  434. wf.business_min_id,
  435. wf.state,
  436. wn.NAME AS nodeName,
  437. mp.NAME AS productionName,
  438. mp.client_name,
  439. mp.client_tel,
  440. mp.evaluate_amount,
  441. mp.OWNER,
  442. u.NAME AS HANDLER,
  443. wn.CODE AS nodeCode,
  444. mp.client_address
  445. FROM
  446. work_flow_node_instance wf
  447. LEFT JOIN work_node wn ON wn.id = wf.node_id
  448. LEFT JOIN ( SELECT report_no, major_id, NAME, client_name,client_address, client_tel, evaluate_amount, OWNER FROM major_production WHERE deleted = 0 ) mp ON ( mp.major_id = wf.business_id AND mp.report_no = ifnull( wf.business_min_id, wf.business_sub_id ) )
  449. LEFT JOIN work_task_record wtr ON wtr.instance_id = wf.id
  450. LEFT JOIN user u ON u.id = wtr.handler_id
  451. WHERE
  452. wf.business_type = 'MAJOR_BUSINESS'
  453. AND wf.deleted = 0
  454. AND wf.state = 'PENDING'
  455. ) wfni ON wfni.business_id = m.id
  456. LEFT JOIN customer_company cc1 ON cc1.id = m.clientele_id
  457. LEFT JOIN customer_company cc2 ON cc2.id = m.clientele_sub_id
  458. LEFT JOIN customer_linkman cl1 ON cl1.id = m.clientele_contact_id
  459. WHERE
  460. m.deleted = 0
  461. <if test="keyword!=null and keyword!='' ">
  462. and (
  463. m.name like concat ('%',#{keyword},'%')
  464. or m.order_id like concat('%',#{keyword},'%')
  465. or u.name like concat('%',#{keyword},'%')
  466. or u1.name like concat('%',#{keyword},'%')
  467. or cc2.name like concat('%',#{keyword},'%')
  468. or cc1.name like concat('%',#{keyword},'%')
  469. or cl1.name like concat('%',#{keyword},'%')
  470. or cl1.mobile like concat('%',#{keyword},'%')
  471. or m.business_object_type like concat('%',#{keyword},'%')
  472. or d.name like concat('%',#{keyword},'%')
  473. or m.allot_type like concat('%',#{keyword},'%')
  474. or wfni.client_name like concat('%',#{keyword},'%')
  475. or wfni.productionName like concat('%',#{keyword},'%')
  476. or wfni.business_sub_id like concat('%',#{keyword},'%')
  477. or wfni.owner like concat('%',#{keyword},'%')
  478. or wfni.business_min_id like concat('%',#{keyword},'%')
  479. or wfni.client_address like concat('%',#{keyword},'%')
  480. or wfni.productionName like concat('%',#{keyword},'%')
  481. )
  482. </if>
  483. <if test="major!=null and major.financial!=null">
  484. and m.financial = #{major.financial}
  485. </if>
  486. <if test="major!=null and major.startDate!=null and major.startDate!=''">
  487. and m.created &gt;= #{major.startDate}
  488. </if>
  489. <if test="major!=null and major.endDate!=null and major.endDate!=''">
  490. and m.created &lt;= #{major.endDate}
  491. </if>
  492. <if test="major!=null and major.nodeId!=null">
  493. and wfni.node_id = #{major.nodeId}
  494. </if>
  495. <if test="major!=null and major.clientName!=null and major.clientName!=''">
  496. and wfni.client_name like concat('%',#{major.clientName},'%')
  497. </if>
  498. <if test="major!=null and major.clientManagerId!=null ">
  499. and m.client_manager_id = #{major.clientManagerId}
  500. </if>
  501. <if test="major!=null and major.principalId!=null ">
  502. and m.principal_id = #{major.principalId}
  503. </if>
  504. <if test="major!=null and major.businessObjectType!=null and major.businessObjectType!=''">
  505. and m.business_object_type = #{major.businessObjectType}
  506. </if>
  507. <if test="major!=null and major.departmentId!=null ">
  508. and m.department_id = #{major.departmentId}
  509. </if>
  510. <if test="major!=null and major.userIds!=null and major.userIds.size!=0">
  511. and (
  512. m.principal_id in
  513. <foreach collection="major.userIds" open="(" close=")" separator="," item="userId">
  514. #{userId}
  515. </foreach>
  516. or
  517. m.client_manager_id in
  518. <foreach collection="major.userIds" open="(" close=")" separator="," item="userId">
  519. #{userId}
  520. </foreach>
  521. or JSON_CONTAINS(JSON_EXTRACT(m.members, '$[*]'),CAST(#{currentUserId} AS CHAR))
  522. )
  523. </if>
  524. order by wfni.currentNodeId DESC
  525. </select>
  526. <select id="findMajorSubClient" resultType="com.dayou.dto.MajorSubClientDTO">
  527. SELECT
  528. m.id,
  529. m.clientele_sub_id,
  530. (select id from customer_company where deleted = 0 and parent_id = m.clientele_id and name = cc.NAME limit 1) as realSubId
  531. FROM
  532. major m
  533. LEFT JOIN customer_company cc ON (m.clientele_sub_id = cc.id )
  534. WHERE
  535. m.deleted = 0 and cc.level = 1
  536. </select>
  537. <select id="productionDetail" resultType="com.dayou.vo.MajorVO">
  538. SELECT
  539. m.id,
  540. mp.report_no as productionNo,
  541. mp.evaluate_acreage,
  542. mp.evaluate_amount/10000 as evaluateAmount,
  543. m.created,
  544. m.NAME,
  545. m.order_id,
  546. m.financial,
  547. m.allot_type,
  548. m.client_manager_id,
  549. m.principal_id,
  550. m.department_id,
  551. m.business_object_type,
  552. m.special_type,
  553. m.business_gener,
  554. m.evaluate_aim,
  555. m.entrust_again,
  556. m.multiple_removal,
  557. m.informal_evaluate,
  558. m.clientele_type,
  559. m.clientele_id,
  560. m.clientele_sub_id,
  561. m.clientele_contact_id,
  562. m.dispense_benefit,
  563. m.nonnative,
  564. m.refinance,
  565. m.loan_limit,
  566. m.loan_period,
  567. m.loan_nature,
  568. m.loan_aim,
  569. m.loan_expire,
  570. m.bailor,
  571. m.bailor_address,
  572. m.bailor_contact_name,
  573. m.bailor_contact_tel,
  574. m.OWNER,
  575. m.owner_tel,
  576. m.urgent,
  577. m.terminal_clientele_id,
  578. m.terminal_clientele_type,
  579. m.terminal_clientele_contact_id,
  580. m.remark,
  581. m.members,
  582. m.feedback_info,
  583. u.NAME AS clientManager ,
  584. cc1.name as cClienteleName,
  585. cc2.name as cClienteleSubName,
  586. cl1.name as cClienteleContactName,
  587. cl1.mobile as cMobile,
  588. cl1.department as cDepartment,
  589. cl1.duty as cDuty,
  590. cc3.name as tTerminalClienteleName,
  591. cc3.phone as tCompanyMobile,
  592. cl2.name as tTerminalClienteleContactName,
  593. cl2.mobile as tMobile
  594. FROM
  595. major m
  596. LEFT JOIN user u ON u.id = m.client_manager_id
  597. left join (select major_id,report_no, evaluate_acreage,evaluate_amount from major_production where major_id = #{id} and report_no = #{productionNo} and deleted=0 and production = #{production}) mp on mp.major_id = m.id
  598. left join customer_company cc1 on cc1.id = m.clientele_id
  599. left join customer_company cc2 on cc2.id = m.clientele_sub_id
  600. left join customer_linkman cl1 on cl1.id = m.clientele_contact_id
  601. left join customer_company cc3 on cc3.id = m.terminal_clientele_id
  602. left join customer_linkman cl2 on cl2.id = m.terminal_clientele_contact_id where m.id =#{id}
  603. </select>
  604. </mapper>