MajorMapper.xml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819
  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. m.evaluate_unit,
  343. u.NAME AS clientManager ,
  344. cc1.name as cClienteleName,
  345. cc2.name as cClienteleSubName,
  346. cl1.name as cClienteleContactName,
  347. cl1.mobile as cMobile,
  348. cl1.department as cDepartment,
  349. cl1.duty as cDuty,
  350. cc3.name as tTerminalClienteleName,
  351. cc3.phone as tCompanyMobile,
  352. cl2.name as tTerminalClienteleContactName,
  353. cl2.mobile as tMobile
  354. FROM
  355. major m
  356. LEFT JOIN user u ON u.id = m.client_manager_id
  357. left join customer_company cc1 on cc1.id = m.clientele_id
  358. left join customer_company cc2 on cc2.id = m.clientele_sub_id
  359. left join customer_linkman cl1 on cl1.id = m.clientele_contact_id
  360. left join customer_company cc3 on cc3.id = m.terminal_clientele_id
  361. left join customer_linkman cl2 on cl2.id = m.terminal_clientele_contact_id where m.id =#{id}
  362. </select>
  363. <select id="staticsInformation" resultType="com.dayou.dto.MajorStaticsDTO">
  364. SELECT
  365. (SELECT count(wfni.id) FROM
  366. work_task_record wtr
  367. LEFT JOIN work_node_task wnt ON wnt.id = wtr.task_id
  368. INNER JOIN (
  369. SELECT wfni.id FROM
  370. work_flow_node_instance wfni
  371. LEFT JOIN work_node wn ON wn.id = wfni.node_id
  372. WHERE
  373. wfni.business_type = 'MAJOR_BUSINESS'
  374. AND wfni.state = 'PENDING'
  375. AND wfni.deleted = 0
  376. AND wn.deleted = 0
  377. ) wfni ON wtr.instance_id = wfni.id WHERE
  378. wtr.handler_id =#{userId}
  379. AND wnt.deleted = 0
  380. AND wtr.deleted = 0 ) as majorToDo,
  381. (SELECT count(*) FROM work_flow_log WHERE handler_id = #{userId} and business_type='MAJOR_BUSINESS') as majorDone,
  382. ( SELECT count(*) FROM major_production WHERE deleted = 0 AND if_save_file = 1 ) AS saveFileCount,
  383. ( SELECT count(*) FROM work_flow_node_instance WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 AND state = 'PENDING' ) AS pending,
  384. ( SELECT count(*) FROM major_production WHERE deleted = 0 AND production = 'STATEMENT' and repertory_state is not null ) AS statementCount,
  385. ( SELECT count(*) FROM major_production WHERE deleted = 0 AND production = 'REPORT' and repertory_state is not null ) AS reportCount,
  386. ( SELECT count(*) FROM major_production WHERE deleted = 0 AND production = 'LETTER' and repertory_state is not null ) AS letterCount,
  387. ( SELECT count(*) FROM major_production WHERE deleted = 0 AND repertory_state = 0 ) AS inWarehouseCount
  388. </select>
  389. <sql id="majorPageSql">
  390. SELECT
  391. wfni.currentNodeId AS id,
  392. wfni.nodeName,
  393. wfni.productionName,
  394. wfni.business_sub_id AS statementNo,
  395. wfni.business_min_id AS reportNo,
  396. m.id AS majorId,
  397. m.created,
  398. m.NAME,
  399. m.order_id,
  400. m.financial,
  401. m.allot_type,
  402. m.client_manager_id,
  403. u.NAME AS clientManager,
  404. m.principal_id,
  405. u1.NAME AS principal,
  406. m.department_id,
  407. d.NAME AS department,
  408. m.business_object_type,
  409. m.clientele_id,
  410. m.clientele_contact_id,
  411. m.clientele_id AS clientele,
  412. m.clientele_contact_id AS clienteleContact,
  413. cc1.NAME AS cClienteleName,
  414. cc2.NAME AS cClienteleSubName,
  415. cl1.NAME AS cClienteleContactName,
  416. cl1.mobile AS cMobile,
  417. wfni.client_name,
  418. wfni.client_tel,
  419. wfni.evaluate_amount,
  420. wfni.OWNER,
  421. wfni.HANDLER,
  422. wfni.nodeCode,
  423. wfni.currentNodeId
  424. FROM
  425. major m
  426. LEFT JOIN user u ON u.id = m.client_manager_id
  427. LEFT JOIN user u1 ON u1.id = m.principal_id
  428. LEFT JOIN department d ON d.id = m.department_id
  429. INNER JOIN (
  430. SELECT
  431. wf.id AS currentNodeId,
  432. wf.node_id,
  433. wf.business_id,
  434. wf.business_sub_id,
  435. wf.business_min_id,
  436. wf.state,
  437. wn.NAME AS nodeName,
  438. mp.NAME AS productionName,
  439. mp.client_name,
  440. mp.client_tel,
  441. mp.evaluate_amount,
  442. mp.OWNER,
  443. u.NAME AS HANDLER,
  444. wn.CODE AS nodeCode,
  445. mp.client_address
  446. FROM
  447. work_flow_node_instance wf
  448. LEFT JOIN work_node wn ON wn.id = wf.node_id
  449. 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 ) )
  450. LEFT JOIN work_task_record wtr ON wtr.instance_id = wf.id
  451. LEFT JOIN user u ON u.id = wtr.handler_id
  452. WHERE
  453. wf.business_type = 'MAJOR_BUSINESS'
  454. AND wf.deleted = 0
  455. AND wf.state = 'PENDING'
  456. ) wfni ON wfni.business_id = m.id
  457. LEFT JOIN customer_company cc1 ON cc1.id = m.clientele_id
  458. LEFT JOIN customer_company cc2 ON cc2.id = m.clientele_sub_id
  459. LEFT JOIN customer_linkman cl1 ON cl1.id = m.clientele_contact_id
  460. WHERE
  461. m.deleted = 0
  462. </sql>
  463. <select id="xPage" parameterType="com.dayou.vo.MajorVO" resultType="com.dayou.vo.MajorVO">
  464. <include refid="majorPageSql" />
  465. <if test="keyword!=null and keyword!='' ">
  466. and (
  467. m.name like concat ('%',#{keyword},'%')
  468. or m.order_id like concat('%',#{keyword},'%')
  469. or u.name like concat('%',#{keyword},'%')
  470. or u1.name like concat('%',#{keyword},'%')
  471. or cc2.name like concat('%',#{keyword},'%')
  472. or cc1.name like concat('%',#{keyword},'%')
  473. or cl1.name like concat('%',#{keyword},'%')
  474. or cl1.mobile like concat('%',#{keyword},'%')
  475. or m.business_object_type like concat('%',#{keyword},'%')
  476. or d.name like concat('%',#{keyword},'%')
  477. or m.allot_type like concat('%',#{keyword},'%')
  478. or wfni.client_name like concat('%',#{keyword},'%')
  479. or wfni.productionName like concat('%',#{keyword},'%')
  480. or wfni.business_sub_id like concat('%',#{keyword},'%')
  481. or wfni.owner like concat('%',#{keyword},'%')
  482. or wfni.business_min_id like concat('%',#{keyword},'%')
  483. or wfni.client_address like concat('%',#{keyword},'%')
  484. or wfni.productionName like concat('%',#{keyword},'%')
  485. )
  486. </if>
  487. <if test="major!=null and major.financial!=null">
  488. and m.financial = #{major.financial}
  489. </if>
  490. <if test="major!=null and major.startDate!=null and major.startDate!=''">
  491. and m.created &gt;= #{major.startDate}
  492. </if>
  493. <if test="major!=null and major.endDate!=null and major.endDate!=''">
  494. and m.created &lt;= #{major.endDate}
  495. </if>
  496. <if test="major!=null and major.nodeId!=null">
  497. and wfni.node_id = #{major.nodeId}
  498. </if>
  499. <if test="major!=null and major.clienteleName!=null and major.clienteleName!=''">
  500. and cc1.name like concat('%',#{major.clienteleName},'%')
  501. </if>
  502. <if test="major!=null and major.clienteleSubName!=null and major.clienteleSubName!=''">
  503. and cc2.name like concat('%',#{major.clienteleSubName},'%')
  504. </if>
  505. <if test="major!=null and major.clientManagerId!=null ">
  506. and m.client_manager_id = #{major.clientManagerId}
  507. </if>
  508. <if test="major!=null and major.principalId!=null ">
  509. and m.principal_id = #{major.principalId}
  510. </if>
  511. <if test="major!=null and major.departmentId!=null ">
  512. and m.department_id = #{major.departmentId}
  513. </if>
  514. <if test="major!=null and major.businessObjectType!=null and major.businessObjectType!=''">
  515. and m.business_object_type = #{major.businessObjectType}
  516. </if>
  517. <if test="major!=null and major.userIds!=null and major.userIds.size!=0">
  518. and (
  519. m.principal_id in
  520. <foreach collection="major.userIds" open="(" close=")" separator="," item="userId">#{userId}
  521. </foreach>
  522. or
  523. m.client_manager_id in
  524. <foreach collection="
  525. major.userIds" open="(" close=")" separator="," item="userId">#{userId}
  526. </foreach>
  527. or JSON_CONTAINS(
  528. JSON_EXTRACT(m.members, '$[*]'),CAST(#{currentUserId} AS CHAR))
  529. )
  530. </if>
  531. order by wfni.currentNodeId DESC
  532. </select>
  533. <select id="pgLeaderPage" parameterType="com.dayou.vo.MajorVO" resultType="com.dayou.vo.MajorVO">
  534. <include refid="majorPageSql" />
  535. <if test="keyword!=null and keyword!='' ">
  536. and (
  537. m.name like concat ('%',#{keyword},'%')
  538. or m.order_id like concat('%',#{keyword},'%')
  539. or u.name like concat('%',#{keyword},'%')
  540. or u1.name like concat('%',#{keyword},'%')
  541. or cc2.name like concat('%',#{keyword},'%')
  542. or cc1.name like concat('%',#{keyword},'%')
  543. or cl1.name like concat('%',#{keyword},'%')
  544. or cl1.mobile like concat('%',#{keyword},'%')
  545. or m.business_object_type like concat('%',#{keyword},'%')
  546. or d.name like concat('%',#{keyword},'%')
  547. or m.allot_type like concat('%',#{keyword},'%')
  548. or wfni.client_name like concat('%',#{keyword},'%')
  549. or wfni.productionName like concat('%',#{keyword},'%')
  550. or wfni.business_sub_id like concat('%',#{keyword},'%')
  551. or wfni.owner like concat('%',#{keyword},'%')
  552. or wfni.business_min_id like concat('%',#{keyword},'%')
  553. or wfni.client_address like concat('%',#{keyword},'%')
  554. or wfni.productionName like concat('%',#{keyword},'%')
  555. )
  556. </if>
  557. <if test="major!=null and major.financial!=null">
  558. and m.financial = #{major.financial}
  559. </if>
  560. <if test="major!=null and major.startDate!=null and major.startDate!=''">
  561. and m.created &gt;= #{major.startDate}
  562. </if>
  563. <if test="major!=null and major.endDate!=null and major.endDate!=''">
  564. and m.created &lt;= #{major.endDate}
  565. </if>
  566. <if test="major!=null and major.nodeId!=null">
  567. and wfni.node_id = #{major.nodeId}
  568. </if>
  569. <if test="major!=null and major.clienteleName!=null and major.clienteleName!=''">
  570. and cc1.name like concat('%',#{major.clienteleName},'%')
  571. </if>
  572. <if test="major!=null and major.clienteleSubName!=null and major.clienteleSubName!=''">
  573. and cc2.name like concat('%',#{major.clienteleSubName},'%')
  574. </if>
  575. <if test="major!=null and major.principalId!=null ">
  576. and m.principal_id = #{major.principalId}
  577. </if>
  578. <if test="major!=null and major.clientManagerId!=null ">
  579. and m.client_manager_id = #{major.clientManagerId}
  580. </if>
  581. <if test="major!=null and major.departmentId!=null ">
  582. and m.department_id = #{major.departmentId}
  583. </if>
  584. <if test="major!=null and major.businessObjectType!=null and major.businessObjectType!=''">
  585. and m.business_object_type = #{major.businessObjectType}
  586. </if>
  587. order by wfni.currentNodeId DESC
  588. </select>
  589. <select id="scNonFinancePage" parameterType="com.dayou.vo.MajorVO" resultType="com.dayou.vo.MajorVO">
  590. <include refid="majorPageSql" />
  591. and m.financial = 0
  592. <if test="keyword!=null and keyword!='' ">
  593. and (
  594. m.name like concat ('%',#{keyword},'%')
  595. or m.order_id like concat('%',#{keyword},'%')
  596. or u.name like concat('%',#{keyword},'%')
  597. or u1.name like concat('%',#{keyword},'%')
  598. or cc2.name like concat('%',#{keyword},'%')
  599. or cc1.name like concat('%',#{keyword},'%')
  600. or cl1.name like concat('%',#{keyword},'%')
  601. or cl1.mobile like concat('%',#{keyword},'%')
  602. or m.business_object_type like concat('%',#{keyword},'%')
  603. or d.name like concat('%',#{keyword},'%')
  604. or m.allot_type like concat('%',#{keyword},'%')
  605. or wfni.client_name like concat('%',#{keyword},'%')
  606. or wfni.productionName like concat('%',#{keyword},'%')
  607. or wfni.business_sub_id like concat('%',#{keyword},'%')
  608. or wfni.owner like concat('%',#{keyword},'%')
  609. or wfni.business_min_id like concat('%',#{keyword},'%')
  610. or wfni.client_address like concat('%',#{keyword},'%')
  611. or wfni.productionName like concat('%',#{keyword},'%')
  612. )
  613. </if>
  614. <if test="major!=null and major.startDate!=null and major.startDate!=''">
  615. and m.created &gt;= #{major.startDate}
  616. </if>
  617. <if test="major!=null and major.endDate!=null and major.endDate!=''">
  618. and m.created &lt;= #{major.endDate}
  619. </if>
  620. <if test="major!=null and major.nodeId!=null">
  621. and wfni.node_id = #{major.nodeId}
  622. </if>
  623. <if test="major!=null and major.clienteleName!=null and major.clienteleName!=''">
  624. and cc1.name like concat('%',#{major.clienteleName},'%')
  625. </if>
  626. <if test="major!=null and major.clienteleSubName!=null and major.clienteleSubName!=''">
  627. and cc2.name like concat('%',#{major.clienteleSubName},'%')
  628. </if>
  629. <if test="major!=null and major.principalId!=null ">
  630. and m.principal_id = #{major.principalId}
  631. </if>
  632. <if test="major!=null and major.businessObjectType!=null and major.businessObjectType!=''">
  633. and m.business_object_type = #{major.businessObjectType}
  634. </if>
  635. <if test="major!=null and major.userIds!=null and major.userIds.size!=0">
  636. or
  637. m.client_manager_id in
  638. <foreach collection="
  639. major.userIds" open="(" close=")" separator="," item="userId">#{userId}
  640. </foreach>
  641. </if>
  642. order by wfni.currentNodeId DESC
  643. </select>
  644. <select id="scFinancePage" parameterType="com.dayou.vo.MajorVO" resultType="com.dayou.vo.MajorVO">
  645. <include refid="majorPageSql" />
  646. and m.financial = 1
  647. <if test="keyword!=null and keyword!='' ">
  648. and (
  649. m.name like concat ('%',#{keyword},'%')
  650. or m.order_id like concat('%',#{keyword},'%')
  651. or u.name like concat('%',#{keyword},'%')
  652. or u1.name like concat('%',#{keyword},'%')
  653. or cc2.name like concat('%',#{keyword},'%')
  654. or cc1.name like concat('%',#{keyword},'%')
  655. or cl1.name like concat('%',#{keyword},'%')
  656. or cl1.mobile like concat('%',#{keyword},'%')
  657. or m.business_object_type like concat('%',#{keyword},'%')
  658. or d.name like concat('%',#{keyword},'%')
  659. or m.allot_type like concat('%',#{keyword},'%')
  660. or wfni.client_name like concat('%',#{keyword},'%')
  661. or wfni.productionName like concat('%',#{keyword},'%')
  662. or wfni.business_sub_id like concat('%',#{keyword},'%')
  663. or wfni.owner like concat('%',#{keyword},'%')
  664. or wfni.business_min_id like concat('%',#{keyword},'%')
  665. or wfni.client_address like concat('%',#{keyword},'%')
  666. or wfni.productionName like concat('%',#{keyword},'%')
  667. )
  668. </if>
  669. <if test="major!=null and major.startDate!=null and major.startDate!=''">
  670. and m.created &gt;= #{major.startDate}
  671. </if>
  672. <if test="major!=null and major.endDate!=null and major.endDate!=''">
  673. and m.created &lt;= #{major.endDate}
  674. </if>
  675. <if test="major!=null and major.nodeId!=null">
  676. and wfni.node_id = #{major.nodeId}
  677. </if>
  678. <if test="major!=null and major.clienteleName!=null and major.clienteleName!=''">
  679. and cc1.name like concat('%',#{major.clienteleName},'%')
  680. </if>
  681. <if test="major!=null and major.clienteleSubName!=null and major.clienteleSubName!=''">
  682. and cc2.name like concat('%',#{major.clienteleSubName},'%')
  683. </if>
  684. <if test="major!=null and major.principalId!=null ">
  685. and m.principal_id = #{major.principalId}
  686. </if>
  687. <if test="major!=null and major.businessObjectType!=null and major.businessObjectType!=''">
  688. and m.business_object_type = #{major.businessObjectType}
  689. </if>
  690. <if test="major!=null and major.userIds!=null and major.userIds.size!=0">
  691. and
  692. m.client_manager_id in
  693. <foreach collection="
  694. major.userIds" open="(" close=")" separator="," item="userId">#{userId}
  695. </foreach>
  696. </if>
  697. order by wfni.currentNodeId DESC
  698. </select>
  699. <select id="findMajorSubClient" resultType="com.dayou.dto.MajorSubClientDTO">
  700. SELECT
  701. m.id,
  702. m.clientele_sub_id,
  703. (select id from customer_company where deleted = 0 and parent_id = m.clientele_id and name = cc.NAME limit 1) as realSubId
  704. FROM
  705. major m
  706. LEFT JOIN customer_company cc ON (m.clientele_sub_id = cc.id )
  707. WHERE
  708. m.deleted = 0 and cc.level = 1
  709. </select>
  710. <select id="productionDetail" resultType="com.dayou.vo.MajorVO">
  711. SELECT
  712. m.id,
  713. mp.report_no as productionNo,
  714. mp.evaluate_acreage,
  715. mp.evaluate_amount/10000 as evaluateAmount,
  716. m.created,
  717. m.NAME,
  718. m.order_id,
  719. m.financial,
  720. m.allot_type,
  721. m.client_manager_id,
  722. m.principal_id,
  723. m.department_id,
  724. m.business_object_type,
  725. m.special_type,
  726. m.business_gener,
  727. m.evaluate_aim,
  728. m.entrust_again,
  729. m.multiple_removal,
  730. m.informal_evaluate,
  731. m.clientele_type,
  732. m.clientele_id,
  733. m.clientele_sub_id,
  734. m.clientele_contact_id,
  735. m.dispense_benefit,
  736. m.nonnative,
  737. m.refinance,
  738. m.loan_limit,
  739. m.loan_period,
  740. m.loan_nature,
  741. m.loan_aim,
  742. m.loan_expire,
  743. m.bailor,
  744. m.bailor_address,
  745. m.bailor_contact_name,
  746. m.bailor_contact_tel,
  747. m.OWNER,
  748. m.owner_tel,
  749. m.urgent,
  750. m.terminal_clientele_id,
  751. m.terminal_clientele_type,
  752. m.terminal_clientele_contact_id,
  753. m.remark,
  754. m.members,
  755. m.feedback_info,
  756. u.NAME AS clientManager ,
  757. cc1.name as cClienteleName,
  758. cc2.name as cClienteleSubName,
  759. cl1.name as cClienteleContactName,
  760. cl1.mobile as cMobile,
  761. cl1.department as cDepartment,
  762. cl1.duty as cDuty,
  763. cc3.name as tTerminalClienteleName,
  764. cc3.phone as tCompanyMobile,
  765. cl2.name as tTerminalClienteleContactName,
  766. cl2.mobile as tMobile
  767. FROM
  768. major m
  769. LEFT JOIN user u ON u.id = m.client_manager_id
  770. 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
  771. left join customer_company cc1 on cc1.id = m.clientele_id
  772. left join customer_company cc2 on cc2.id = m.clientele_sub_id
  773. left join customer_linkman cl1 on cl1.id = m.clientele_contact_id
  774. left join customer_company cc3 on cc3.id = m.terminal_clientele_id
  775. left join customer_linkman cl2 on cl2.id = m.terminal_clientele_contact_id where m.id =#{id}
  776. </select>
  777. <select id="getDepartmentOrderOverStock" parameterType="java.lang.Long" resultType="java.lang.Integer">
  778. SELECT
  779. count(*)
  780. FROM
  781. major
  782. WHERE
  783. id IN (
  784. SELECT
  785. business_id
  786. FROM
  787. work_flow_node_instance
  788. WHERE
  789. flow_id = 6
  790. AND business_type = 'MAJOR_BUSINESS'
  791. AND deleted = 0
  792. AND state = 'PENDING'
  793. AND node_id IN ( 55, 56, 57, 58, 59 ))
  794. AND deleted = 0
  795. AND allot_type = '轮单'
  796. and financial = 1
  797. and created &lt;=DATE_SUB(NOW(), INTERVAL 7 DAY)
  798. AND department_id = #{departmentId}
  799. </select>
  800. </mapper>