WorkContractInfoDao.xml 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242
  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.jeeplus.modules.workcontractinfo.dao.WorkContractInfoDao">
  4. <sql id="workContractInfoColumns">
  5. a.id AS "id",
  6. a.create_by AS "createBy.id",
  7. (select name from sys_user user where user.id=a.create_by) AS "createBy.name",
  8. a.create_date AS "createDate",
  9. a.update_by AS "updateBy.id",
  10. a.update_date AS "updateDate",
  11. a.project_id AS "project.id",
  12. a.project_name AS "projectName",
  13. a.ext AS "ext",
  14. p.project_name AS "project.projectName",
  15. p.project_number AS "project.projectNumber",
  16. a.del_flag AS "delFlag",
  17. a.remarks AS "remarks",
  18. a.client_id AS "client.id",
  19. a.contract_date AS "contractDate",
  20. a.effective_date AS "effectiveDate",
  21. a.closing_date AS "closingDate",
  22. a.name AS "name",
  23. a.contract_num_path AS "contractNumPath",
  24. a.contract_category AS "contractCategory",
  25. a.contract_num AS "contractNum",
  26. a.contract_price AS "contractPrice",
  27. a.contract_opposite AS "contractOpposite",
  28. a.contract_type AS "contractType",
  29. a.contract_fee AS "contractFee",
  30. a.contract_special AS "contractSpecial",
  31. a.contract_state AS "contractState",
  32. a.create_name AS "createName",
  33. a.office_id AS "chargeCompany",
  34. a.charge_company_name AS "chargeCompanyName",
  35. a.contract_file_id AS "contractFileId",
  36. a.contract_role AS "contractRole",
  37. a.apply_view AS "applyView",
  38. a.company_id AS "companyId",
  39. a.contractFeeDoc AS "contractFeeDoc",
  40. a.contractTypeDoc AS "contractTypeDoc",
  41. a.process_instance_id AS "processInstanceId",
  42. client.name AS "client.name",
  43. a.is_total AS "isTotal",
  44. a.total_contract_id AS "totalContractId",
  45. a.common_flag AS "commonFlag",
  46. a.status AS "status",
  47. a.investment_scale AS "investmentScale",
  48. a.summary_payment AS "summaryPayment",
  49. a.investment_amount AS "investmentAmount",
  50. a.create_bys AS "createBys",
  51. a.construction_project_type AS "constructionProjectType",
  52. a.invalidate_process_instance_id AS "invalidateProcessInstanceId",
  53. a.alter_process_instance_id AS "alterProcessInstanceId",
  54. a.invalidate_status AS "invalidateStatus",
  55. a.invalidate_user AS "invalidateUserId",
  56. a.alter_state AS "alterState",
  57. a.alterbefore_id AS "alterBeforeId",
  58. a.alter_sign AS "alterSign",
  59. a.record_state AS "recordState",
  60. a.completion_status AS "completionStatus",
  61. a.signature_status as "signatureStatus",
  62. a.office_id AS "officeId",
  63. (select count(1) from work_contract_info c where c.total_contract_id = a.id) cnt
  64. </sql>
  65. <sql id="workContractInfoJoins">
  66. LEFT JOIN work_client_info client ON client.id = a.client_id
  67. LEFT JOIN sys_user u on u.id = a.create_by
  68. LEFT JOIN sys_office o ON o.id = a.office_id
  69. LEFT JOIN work_bid_project p ON p.id = a.project_id
  70. LEFT JOIN sys_office s ON s.id = a.company_id
  71. </sql>
  72. <select id="get" resultType="WorkContractInfo" >
  73. SELECT
  74. a.id AS "id",
  75. a.project_id AS "project.id",
  76. a.project_name AS "project.name",
  77. a.ext AS "ext",
  78. u.name AS "createBy.name",
  79. a.create_by AS "createBy.id",
  80. a.create_date AS "createDate",
  81. a.update_by AS "updateBy.id",
  82. a.update_date AS "updateDate",
  83. a.del_flag AS "delFlag",
  84. a.remarks AS "remarks",
  85. a.client_id AS "client.id",
  86. a.contract_date AS "contractDate",
  87. a.effective_date AS "effectiveDate",
  88. a.closing_date AS "closingDate",
  89. a.name AS "name",
  90. a.contract_num_path AS "contractNumPath",
  91. a.create_name AS "createName",
  92. a.contract_category AS "contractCategory",
  93. a.contract_num AS "contractNum",
  94. a.contract_price AS "contractPrice",
  95. a.contract_opposite AS "contractOpposite",
  96. a.contract_type AS "contractType",
  97. a.contract_fee AS "contractFee",
  98. a.contract_special AS "contractSpecial",
  99. a.contract_state AS "contractState",
  100. a.office_id AS "chargeCompany",
  101. a.charge_company_name AS "chargeCompanyName",
  102. a.contract_file_id AS "contractFileId",
  103. a.contract_role AS "contractRole",
  104. a.apply_view AS "applyView",
  105. a.process_instance_id AS "processInstanceId",
  106. a.company_id as companyId,
  107. a.contractFeeDoc AS "contractFeeDoc",
  108. a.contractTypeDoc AS "contractTypeDoc",
  109. a.another_contract_num AS "anotherContractNum",
  110. client.name AS "client.name",
  111. a.is_total AS "isTotal",
  112. a.total_contract_id AS "totalContractId",
  113. a.status AS "status",
  114. a.investment_scale AS "investmentScale",
  115. a.summary_payment AS "summaryPayment",
  116. a.investment_amount AS "investmentAmount",
  117. a.create_bys AS "createBys",
  118. a.construction_project_type AS "constructionProjectType",
  119. a.invalidate_process_instance_id AS "invalidateProcessInstanceId",
  120. a.alter_process_instance_id AS "alterProcessInstanceId",
  121. a.invalidate_status AS "invalidateStatus",
  122. a.invalidate_user AS "invalidateUserId",
  123. a.alter_state AS "alterState",
  124. a.alter_sign AS "alterSign",
  125. a.record_state AS "recordState",
  126. a.alterbefore_id AS "alterBeforeId",
  127. a.completion_status AS "completionStatus",
  128. a.common_flag AS "commonFlag",
  129. a.office_id AS "officeId",
  130. a.signature_status as "signatureStatus"
  131. FROM work_contract_info a
  132. <include refid="workContractInfoJoins"/>
  133. WHERE a.id = #{id}
  134. </select>
  135. <select id="findByReport" resultType="java.lang.Integer" >
  136. SELECT
  137. count(*)
  138. FROM work_contract_info a
  139. LEFT JOIN project_records r ON r.contract_id = a.id
  140. LEFT JOIN project_report_data d ON d.project_id = r.id
  141. WHERE a.id = #{id} AND (d.status != '5' or d.file_status != '3')
  142. </select>
  143. <select id="getByBeforeId" resultType="WorkContractInfo" >
  144. SELECT
  145. a.*,
  146. a.project_id AS "project.id",
  147. p.project_name AS "project.projectName",
  148. p.project_number AS "project.projectNumber",
  149. a.create_by AS "createBy.id",
  150. a.invalidate_process_instance_id AS "invalidateProcessInstanceId",
  151. a.alter_process_instance_id AS "alterProcessInstanceId",
  152. a.invalidate_status AS "invalidateStatus",
  153. a.invalidate_user AS "invalidateUserId",
  154. client.id AS "client.id",
  155. a.alter_state AS "alterState",
  156. a.alterbefore_id AS "alterBeforeId",
  157. a.alter_sign AS "alterSign",
  158. a.record_state AS "recordState",
  159. client.name AS "client.name"
  160. FROM work_contract_info a
  161. <include refid="workContractInfoJoins"/>
  162. WHERE a.alterbefore_id = #{alterBeforeId} and a.del_flag = 0 and contract_state is null
  163. </select>
  164. <select id="getClientInfoByClientId" parameterType="java.lang.String" resultType="WorkClientInfo" >
  165. SELECT
  166. id As "id",
  167. name As "name",
  168. name_for_short AS "nameForShort",
  169. or_unicode AS "orUnicode",
  170. company_type AS "companyType",
  171. company_industry AS "companyIndustry",
  172. client_type AS "clientType",
  173. credit_rank AS "creditRank",
  174. area_id AS "area",
  175. zip_code AS "zipCode",
  176. fax AS "fax",
  177. tax_id AS "taxId",
  178. email AS "email",
  179. address AS address,
  180. register_address AS registerAddress,
  181. company_url AS companyUrl
  182. FROM
  183. work_client_info
  184. WHERE id=#{id} and del_flag = 0
  185. </select>
  186. <select id="findList" resultType="WorkContractInfo" >
  187. SELECT
  188. a.id AS "id",
  189. u.name AS "createBy.name",
  190. a.create_by AS "createBy.id",
  191. a.create_date AS "createDate",
  192. a.update_by AS "updateBy.id",
  193. a.update_date AS "updateDate",
  194. a.del_flag AS "delFlag",
  195. a.remarks AS "remarks",
  196. a.client_id AS "client.id",
  197. a.contract_date AS "contractDate",
  198. a.effective_date AS "effectiveDate",
  199. a.closing_date AS "closingDate",
  200. a.name AS "name",
  201. a.contract_num_path AS "contractNumPath",
  202. a.create_name AS "createName",
  203. a.contract_category AS "contractCategory",
  204. a.contract_num AS "contractNum",
  205. a.contract_price AS "contractPrice",
  206. a.contract_opposite AS "contractOpposite",
  207. a.contract_type AS "contractType",
  208. a.contract_fee AS "contractFee",
  209. a.contract_special AS "contractSpecial",
  210. a.contract_state AS "contractState",
  211. a.office_id AS "chargeCompany",
  212. a.charge_company_name AS "chargeCompanyName",
  213. a.contract_file_id AS "contractFileId",
  214. a.contract_role AS "contractRole",
  215. a.apply_view AS "applyView",
  216. a.process_instance_id AS "processInstanceId",
  217. a.company_id as companyId,
  218. a.contractFeeDoc AS "contractFeeDoc",
  219. a.contractTypeDoc AS "contractTypeDoc",
  220. a.another_contract_num AS "anotherContractNum",
  221. client.name AS "client.name",
  222. a.is_total AS "isTotal",
  223. a.total_contract_id AS "totalContractId",
  224. a.status AS "status",
  225. a.investment_scale AS "investmentScale",
  226. a.summary_payment AS "summaryPayment",
  227. a.investment_amount AS "investmentAmount",
  228. a.create_bys AS "createBys",
  229. a.construction_project_type AS "constructionProjectType",
  230. a.invalidate_process_instance_id AS "invalidateProcessInstanceId",
  231. a.alter_process_instance_id AS "alterProcessInstanceId",
  232. a.invalidate_status AS "invalidateStatus",
  233. a.invalidate_user AS "invalidateUserId",
  234. a.alter_state AS "alterState",
  235. a.alter_sign AS "alterSign",
  236. a.record_state AS "recordState",
  237. a.alterbefore_id AS "alterBeforeId",
  238. a.completion_status AS "completionStatus",
  239. a.common_flag AS "commonFlag",
  240. a.signature_status as "signatureStatus"
  241. FROM work_contract_info a
  242. <include refid="workContractInfoJoins"/>
  243. <where>
  244. a.del_flag = #{DEL_FLAG_NORMAL} and (a.alter_state is null or a.alter_state ="")
  245. <if test="id != null and id != ''">
  246. AND a.id = #{id}
  247. </if>
  248. <if test="client != null and client.id != null and client.id != ''">
  249. AND a.client_id = #{client.id}
  250. </if>
  251. <if test="client != null and client.name != null and client.name != ''">
  252. AND client.name LIKE concat('%',#{client.name},'%')
  253. </if>
  254. <if test="beginContractDate != null and endContractDate != null and beginContractDate != '' and endContractDate != ''">
  255. AND a.contract_date BETWEEN #{beginContractDate} AND #{endContractDate}
  256. </if>
  257. <if test="name != null and name != ''">
  258. AND a.name LIKE
  259. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  260. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  261. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  262. </if>
  263. <if test="totalContractIds != null and totalContractIds != ''">
  264. AND a.total_contract_ids LIKE
  265. <if test="dbName == 'oracle'">'%'||#{totalContractIds}||'%'</if>
  266. <if test="dbName == 'mssql'">'%'+#{totalContractIds}+'%'</if>
  267. <if test="dbName == 'mysql'">concat('%',#{totalContractIds},'%')</if>
  268. </if>
  269. <!--<if test="totalContractId != null and totalContractId != ''">
  270. AND a.total_contract_id =#{totalContractId}
  271. </if>-->
  272. <if test="beginInvestmentAmount != null and endInvestmentAmount != null and beginInvestmentAmount != '' and endInvestmentAmount != ''">
  273. AND a.investment_amount &gt;= #{beginInvestmentAmount} AND a.investment_amount &lt;= #{endInvestmentAmount}
  274. </if>
  275. <if test="contractPrice != '' and contractPrice != null">
  276. AND a.contract_price like concat('%',#{contractPrice},'%')
  277. </if>
  278. <if test="contractState != null and contractState != ''">
  279. AND a.contract_state = #{contractState}
  280. </if>
  281. <if test="contractNum != null and contractNum!= ''">
  282. AND a.contract_num like concat('%',#{contractNum},'%')
  283. </if>
  284. <if test="isTotal != null and isTotal != ''">
  285. AND a.is_total = #{isTotal}
  286. </if>
  287. ${sqlMap.dsf}
  288. </where>
  289. <choose>
  290. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  291. ORDER BY ${page.orderBy}
  292. </when>
  293. <otherwise>
  294. ORDER BY a.contract_date DESC
  295. </otherwise>
  296. </choose>
  297. </select>
  298. <select id="queryCount" resultType="int" >
  299. SELECT count(1)
  300. FROM work_contract_info a
  301. <if test="client != null and client.name != null and client.name != ''">
  302. LEFT JOIN work_client_info client ON client.id = a.client_id
  303. </if>
  304. <where>
  305. a.del_flag = #{DEL_FLAG_NORMAL} and (a.alter_state is null or a.alter_state ="")
  306. <if test="id != null and id != ''">
  307. AND a.id = #{id}
  308. </if>
  309. <if test="client != null and client.id != null and client.id != ''">
  310. AND a.client_id = #{client.id}
  311. </if>
  312. <if test="client != null and client.name != null and client.name != ''">
  313. AND client.name LIKE concat('%',#{client.name},'%')
  314. </if>
  315. <if test="beginContractDate != null and endContractDate != null and beginContractDate != '' and endContractDate != ''">
  316. AND a.contract_date BETWEEN #{beginContractDate} AND #{endContractDate}
  317. </if>
  318. <if test="name != null and name != ''">
  319. AND a.name LIKE
  320. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  321. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  322. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  323. </if>
  324. <if test="totalContractIds != null and totalContractIds != ''">
  325. AND a.total_contract_ids LIKE
  326. <if test="dbName == 'oracle'">'%'||#{totalContractIds}||'%'</if>
  327. <if test="dbName == 'mssql'">'%'+#{totalContractIds}+'%'</if>
  328. <if test="dbName == 'mysql'">concat('%',#{totalContractIds},'%')</if>
  329. </if>
  330. <!--<if test="totalContractId != null and totalContractId != ''">
  331. AND a.total_contract_id =#{totalContractId}
  332. </if>-->
  333. <if test="beginInvestmentAmount != null and endInvestmentAmount != null and beginInvestmentAmount != '' and endInvestmentAmount != ''">
  334. AND a.investment_amount &gt;= #{beginInvestmentAmount} AND a.investment_amount &lt;= #{endInvestmentAmount}
  335. </if>
  336. <if test="contractPrice != '' and contractPrice != null">
  337. AND a.contract_price = #{contractPrice}
  338. </if>
  339. <if test="contractState != null and contractState != ''">
  340. AND a.contract_state = #{contractState}
  341. </if>
  342. <if test="contractNum != null and contractNum!= ''">
  343. AND a.contract_num = #{contractNum}
  344. </if>
  345. <if test="isTotal != null and isTotal != ''">
  346. AND a.is_total = #{isTotal}
  347. </if>
  348. ${sqlMap.dsf}
  349. </where>
  350. <choose>
  351. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  352. ORDER BY ${page.orderBy}
  353. </when>
  354. <otherwise>
  355. ORDER BY a.contract_date DESC
  356. </otherwise>
  357. </choose>
  358. </select>
  359. <select id="findListReceipts" resultType="WorkContractInfo" >
  360. SELECT
  361. a.id AS "id",
  362. (select name from sys_user user where user.id=a.create_by) AS "createBy.name",
  363. a.create_by AS "createBy.id",
  364. a.create_date AS "createDate",
  365. a.update_by AS "updateBy.id",
  366. a.update_date AS "updateDate",
  367. a.del_flag AS "delFlag",
  368. a.remarks AS "remarks",
  369. a.client_id AS "client.id",
  370. a.contract_date AS "contractDate",
  371. a.effective_date AS "effectiveDate",
  372. a.closing_date AS "closingDate",
  373. a.name AS "name",
  374. a.contract_num_path AS "contractNumPath",
  375. a.create_name AS "createName",
  376. a.contract_category AS "contractCategory",
  377. a.contract_num AS "contractNum",
  378. a.contract_price AS "contractPrice",
  379. a.contract_opposite AS "contractOpposite",
  380. a.contract_type AS "contractType",
  381. a.contract_fee AS "contractFee",
  382. a.contract_special AS "contractSpecial",
  383. a.contract_state AS "contractState",
  384. a.office_id AS "chargeCompany",
  385. a.charge_company_name AS "chargeCompanyName",
  386. a.contract_file_id AS "contractFileId",
  387. a.contract_role AS "contractRole",
  388. a.apply_view AS "applyView",
  389. a.process_instance_id AS "processInstanceId",
  390. a.company_id as companyId,
  391. a.contractFeeDoc AS "contractFeeDoc",
  392. a.contractTypeDoc AS "contractTypeDoc",
  393. a.another_contract_num AS "anotherContractNum",
  394. client.name AS "client.name",
  395. a.is_total AS "isTotal",
  396. a.total_contract_id AS "totalContractId",
  397. a.status AS "status",
  398. a.investment_scale AS "investmentScale",
  399. a.summary_payment AS "summaryPayment",
  400. a.investment_amount AS "investmentAmount",
  401. a.create_bys AS "createBys",
  402. a.construction_project_type AS "constructionProjectType",
  403. a.invalidate_process_instance_id AS "invalidateProcessInstanceId",
  404. a.alter_process_instance_id AS "alterProcessInstanceId",
  405. a.invalidate_status AS "invalidateStatus",
  406. a.invalidate_user AS "invalidateUserId",
  407. a.alter_state AS "alterState",
  408. a.alter_sign AS "alterSign",
  409. a.record_state AS "recordState",
  410. a.completion_status AS "completionStatus",
  411. a.alterbefore_id AS "alterBeforeId",
  412. (select name from work_contract_info where id = a.total_contract_id) AS "totalContractName",
  413. a.common_flag AS "commonFlag",
  414. (select count(1) from work_contract_info c where c.total_contract_id = a.id) cnt
  415. FROM work_contract_info a
  416. <include refid="workContractInfoJoins"/>
  417. <where>
  418. a.del_flag = #{DEL_FLAG_NORMAL} and (a.alter_state is null or a.alter_state ="")
  419. <if test="id != null and id != ''">
  420. AND a.id = #{id}
  421. </if>
  422. <if test="contractState != null and contractState != ''">
  423. AND a.contract_state = #{contractState}
  424. </if>
  425. <if test="createBy != null and createBy.id != null and createBy.id != '' and
  426. chargeCompany != null and chargeCompany != ''
  427. ">
  428. AND (a.create_by = #{createBy.id} or a.office_id= #{chargeCompany})
  429. </if>
  430. </where>
  431. <choose>
  432. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  433. ORDER BY ${page.orderBy}
  434. </when>
  435. <otherwise>
  436. ORDER BY a.contract_date DESC
  437. </otherwise>
  438. </choose>
  439. </select>
  440. <select id="ifindList" resultType="WorkContractInfo" >
  441. SELECT
  442. a.id AS "id",
  443. (select name from sys_user user where user.id=a.create_by) AS "createBy.name",
  444. a.create_by AS "createBy.id",
  445. a.create_date AS "createDate",
  446. a.update_by AS "updateBy.id",
  447. a.update_date AS "updateDate",
  448. a.del_flag AS "delFlag",
  449. a.remarks AS "remarks",
  450. a.client_id AS "client.id",
  451. a.contract_date AS "contractDate",
  452. a.effective_date AS "effectiveDate",
  453. a.closing_date AS "closingDate",
  454. a.name AS "name",
  455. a.create_name AS "createName",
  456. a.contract_category AS "contractCategory",
  457. a.contract_num AS "contractNum",
  458. a.contract_price AS "contractPrice",
  459. a.contract_opposite AS "contractOpposite",
  460. a.contract_type AS "contractType",
  461. a.contract_fee AS "contractFee",
  462. a.contract_special AS "contractSpecial",
  463. a.contract_state AS "contractState",
  464. a.office_id AS "chargeCompany",
  465. a.charge_company_name AS "chargeCompanyName",
  466. a.contract_file_id AS "contractFileId",
  467. a.contract_role AS "contractRole",
  468. a.apply_view AS "applyView",
  469. a.process_instance_id AS "processInstanceId",
  470. a.company_id as companyId,
  471. a.contractFeeDoc AS "contractFeeDoc",
  472. a.contractTypeDoc AS "contractTypeDoc",
  473. a.another_contract_num AS "anotherContractNum",
  474. client.name AS "client.name",
  475. a.is_total AS "isTotal",
  476. a.total_contract_id AS "totalContractId",
  477. a.status AS "status",
  478. a.investment_scale AS "investmentScale",
  479. a.summary_payment AS "summaryPayment",
  480. a.investment_amount AS "investmentAmount",
  481. a.create_bys AS "createBys",
  482. a.construction_project_type AS "constructionProjectType",
  483. a.invalidate_process_instance_id AS "invalidateProcessInstanceId",
  484. a.alter_process_instance_id AS "alterProcessInstanceId",
  485. a.invalidate_status AS "invalidateStatus",
  486. a.invalidate_user AS "invalidateUserId",
  487. a.alter_state AS "alterState",
  488. a.alter_sign AS "alterSign",
  489. a.record_state AS "recordState",
  490. a.completion_status AS "completionStatus",
  491. a.alterbefore_id AS "alterBeforeId",
  492. (select name from work_contract_info where id = a.total_contract_id) AS "totalContractName",
  493. a.common_flag AS "commonFlag",
  494. (select count(1) from work_contract_info c where c.total_contract_id = a.id) cnt
  495. FROM work_contract_info a
  496. <include refid="workContractInfoJoins"/>
  497. <where>
  498. a.del_flag = #{DEL_FLAG_NORMAL} and (a.contract_state = 6 or a.contract_state = 7)
  499. <if test="id != null and id != ''">
  500. AND a.id = #{id}
  501. </if>
  502. <if test="client != null and client.id != null and client.id != ''">
  503. AND a.client_id = #{client.id}
  504. </if>
  505. <if test="client != null and client.name != null and client.name != ''">
  506. AND client.name LIKE concat('%',#{client.name},'%')
  507. </if>
  508. <if test="beginContractDate != null and endContractDate != null and beginContractDate != '' and endContractDate != ''">
  509. AND a.contract_date BETWEEN #{beginContractDate} AND #{endContractDate}
  510. </if>
  511. <if test="name != null and name != ''">
  512. AND a.name LIKE
  513. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  514. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  515. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  516. </if>
  517. <if test="totalContractIds != null and totalContractIds != ''">
  518. AND a.total_contract_ids LIKE
  519. <if test="dbName == 'oracle'">'%'||#{totalContractIds}||'%'</if>
  520. <if test="dbName == 'mssql'">'%'+#{totalContractIds}+'%'</if>
  521. <if test="dbName == 'mysql'">concat('%',#{totalContractIds},'%')</if>
  522. </if>
  523. <!--<if test="totalContractId != null and totalContractId != ''">
  524. AND a.total_contract_id =#{totalContractId}
  525. </if>-->
  526. <if test="contractPrice != '' and contractPrice != null">
  527. AND a.contract_price like concat('%',#{contractPrice},'%')
  528. </if>
  529. <if test="contractState != null and contractState != ''">
  530. AND a.contract_state = #{contractState}
  531. </if>
  532. <if test="contractNum != null and contractNum!= ''">
  533. AND a.contract_num like concat('%',#{contractNum},'%')
  534. </if>
  535. <!--<if test="isTotal != null and isTotal != ''">
  536. AND a.is_total = #{isTotal}
  537. </if>-->
  538. <choose>
  539. <when test="queryCon != null and queryCon != ''">
  540. AND (
  541. find_in_set(#{queryCon},a.create_bys)
  542. ${sqlMap.dsf}
  543. )
  544. </when>
  545. <otherwise>
  546. ${sqlMap.dsf}
  547. </otherwise>
  548. </choose>
  549. </where>
  550. <choose>
  551. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  552. ORDER BY ${page.orderBy}
  553. </when>
  554. <otherwise>
  555. ORDER BY a.contract_date DESC
  556. </otherwise>
  557. </choose>
  558. </select>
  559. <select id="afindList" resultType="WorkContractInfo" >
  560. SELECT
  561. a.id AS "id",
  562. (select name from sys_user user where user.id=a.create_by) AS "createBy.name",
  563. a.create_by AS "createBy.id",
  564. a.create_date AS "createDate",
  565. a.update_by AS "updateBy.id",
  566. a.update_date AS "updateDate",
  567. a.del_flag AS "delFlag",
  568. a.remarks AS "remarks",
  569. a.client_id AS "client.id",
  570. a.contract_date AS "contractDate",
  571. a.effective_date AS "effectiveDate",
  572. a.closing_date AS "closingDate",
  573. a.name AS "name",
  574. a.contract_num_path AS "contractNumPath",
  575. a.create_name AS "createName",
  576. a.contract_category AS "contractCategory",
  577. a.contract_num AS "contractNum",
  578. a.contract_price AS "contractPrice",
  579. a.contract_opposite AS "contractOpposite",
  580. a.contract_type AS "contractType",
  581. a.contract_fee AS "contractFee",
  582. a.contract_special AS "contractSpecial",
  583. a.contract_state AS "contractState",
  584. a.office_id AS "chargeCompany",
  585. a.charge_company_name AS "chargeCompanyName",
  586. a.contract_file_id AS "contractFileId",
  587. a.contract_role AS "contractRole",
  588. a.apply_view AS "applyView",
  589. a.process_instance_id AS "processInstanceId",
  590. a.company_id as companyId,
  591. a.contractFeeDoc AS "contractFeeDoc",
  592. a.contractTypeDoc AS "contractTypeDoc",
  593. a.another_contract_num AS "anotherContractNum",
  594. client.name AS "client.name",
  595. a.is_total AS "isTotal",
  596. a.total_contract_id AS "totalContractId",
  597. a.status AS "status",
  598. a.investment_scale AS "investmentScale",
  599. a.summary_payment AS "summaryPayment",
  600. a.investment_amount AS "investmentAmount",
  601. a.create_bys AS "createBys",
  602. a.construction_project_type AS "constructionProjectType",
  603. a.invalidate_process_instance_id AS "invalidateProcessInstanceId",
  604. a.alter_process_instance_id AS "alterProcessInstanceId",
  605. a.invalidate_status AS "invalidateStatus",
  606. a.invalidate_user AS "invalidateUserId",
  607. a.alter_state AS "alterState",
  608. a.alter_sign AS "alterSign",
  609. a.record_state AS "recordState",
  610. a.alterbefore_id AS "alterBeforeId",
  611. a.completion_status AS "completionStatus",
  612. (select name from work_contract_info where id = a.total_contract_id) AS "totalContractName",
  613. a.common_flag AS "commonFlag",
  614. (select count(1) from work_contract_info c where c.total_contract_id = a.id) cnt
  615. FROM work_contract_info a
  616. <include refid="workContractInfoJoins"/>
  617. <where>
  618. a.del_flag = #{DEL_FLAG_NORMAL} and a.alterbefore_id is not null
  619. <if test="id != null and id != ''">
  620. AND a.id = #{id}
  621. </if>
  622. <if test="client != null and client.id != null and client.id != ''">
  623. AND a.client_id = #{client.id}
  624. </if>
  625. <if test="client != null and client.name != null and client.name != ''">
  626. AND client.name LIKE concat('%',#{client.name},'%')
  627. </if>
  628. <if test="beginContractDate != null and endContractDate != null and beginContractDate != '' and endContractDate != ''">
  629. AND a.contract_date BETWEEN #{beginContractDate} AND #{endContractDate}
  630. </if>
  631. <if test="name != null and name != ''">
  632. AND a.name LIKE
  633. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  634. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  635. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  636. </if>
  637. <if test="totalContractIds != null and totalContractIds != ''">
  638. AND a.total_contract_ids LIKE
  639. <if test="dbName == 'oracle'">'%'||#{totalContractIds}||'%'</if>
  640. <if test="dbName == 'mssql'">'%'+#{totalContractIds}+'%'</if>
  641. <if test="dbName == 'mysql'">concat('%',#{totalContractIds},'%')</if>
  642. </if>
  643. <!--<if test="totalContractId != null and totalContractId != ''">
  644. AND a.total_contract_id =#{totalContractId}
  645. </if>-->
  646. <if test="contractPrice != '' and contractPrice != null">
  647. AND a.contract_price like concat('%',#{contractPrice},'%')
  648. </if>
  649. <if test="contractState != null and contractState != ''">
  650. AND a.contract_state = #{contractState}
  651. </if>
  652. <if test="contractNum != null and contractNum!= ''">
  653. AND a.contract_num like concat('%',#{contractNum},'%')
  654. </if>
  655. <!--<if test="isTotal != null and isTotal != ''">
  656. AND a.is_total = #{isTotal}
  657. </if>-->
  658. <choose>
  659. <when test="queryCon != null and queryCon != ''">
  660. AND (
  661. find_in_set(#{queryCon},a.create_bys)
  662. ${sqlMap.dsf}
  663. )
  664. </when>
  665. <otherwise>
  666. ${sqlMap.dsf}
  667. </otherwise>
  668. </choose>
  669. </where>
  670. <choose>
  671. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  672. ORDER BY ${page.orderBy}
  673. </when>
  674. <otherwise>
  675. ORDER BY a.update_date DESC
  676. </otherwise>
  677. </choose>
  678. </select>
  679. <select id="findLists" resultType="WorkContractInfo" >
  680. SELECT
  681. a.id AS "id",
  682. (select name from sys_user user where user.id=a.create_by) AS "createBy.name",
  683. a.create_by AS "createBy.id",
  684. a.create_date AS "createDate",
  685. a.update_by AS "updateBy.id",
  686. a.update_date AS "updateDate",
  687. a.del_flag AS "delFlag",
  688. a.remarks AS "remarks",
  689. a.client_id AS "client.id",
  690. a.contract_date AS "contractDate",
  691. a.effective_date AS "effectiveDate",
  692. a.closing_date AS "closingDate",
  693. a.name AS "name",
  694. a.contract_num_path AS "contractNumPath",
  695. a.create_name AS "createName",
  696. a.contract_category AS "contractCategory",
  697. a.contract_num AS "contractNum",
  698. a.contract_price AS "contractPrice",
  699. a.contract_opposite AS "contractOpposite",
  700. a.contract_type AS "contractType",
  701. a.contract_fee AS "contractFee",
  702. a.contract_special AS "contractSpecial",
  703. a.contract_state AS "contractState",
  704. a.office_id AS "chargeCompany",
  705. a.charge_company_name AS "chargeCompanyName",
  706. a.contract_file_id AS "contractFileId",
  707. a.contract_role AS "contractRole",
  708. a.apply_view AS "applyView",
  709. a.process_instance_id AS "processInstanceId",
  710. a.company_id as companyId,
  711. a.contractFeeDoc AS "contractFeeDoc",
  712. a.contractTypeDoc AS "contractTypeDoc",
  713. a.another_contract_num AS "anotherContractNum",
  714. client.name AS "client.name",
  715. a.is_total AS "isTotal",
  716. a.total_contract_id AS "totalContractId",
  717. a.status AS "status",
  718. a.investment_scale AS "investmentScale",
  719. a.summary_payment AS "summaryPayment",
  720. a.investment_amount AS "investmentAmount",
  721. a.create_bys AS "createBys",
  722. a.alter_state AS "alterState",
  723. a.alter_sign AS "alterSign",
  724. a.record_state AS "recordState",
  725. a.alterbefore_id AS "alterBeforeId",
  726. a.completion_status AS "completionStatus",
  727. a.construction_project_type AS "constructionProjectType",
  728. (select name from work_contract_info where id = a.total_contract_id) AS "totalContractName",
  729. a.common_flag AS "commonFlag",
  730. (select count(1) from work_contract_info c where c.total_contract_id = a.id) cnt
  731. FROM work_contract_info a
  732. <include refid="workContractInfoJoins"/>
  733. <where>
  734. a.del_flag = #{DEL_FLAG_NORMAL}
  735. <if test="id != null and id != ''">
  736. AND a.id = #{id}
  737. </if>
  738. <if test="client != null and client.id != null and client.id != ''">
  739. AND a.client_id = #{client.id}
  740. </if>
  741. <if test="beginContractDate != null and endContractDate != null and beginContractDate != '' and endContractDate != ''">
  742. AND a.contract_date BETWEEN #{beginContractDate} AND #{endContractDate}
  743. </if>
  744. <if test="name != null and name != ''">
  745. AND a.name LIKE
  746. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  747. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  748. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  749. </if>
  750. <if test="totalContractIds != null and totalContractIds != ''">
  751. AND a.total_contract_ids LIKE
  752. <if test="dbName == 'oracle'">'%'||#{totalContractIds}||'%'</if>
  753. <if test="dbName == 'mssql'">'%'+#{totalContractIds}+'%'</if>
  754. <if test="dbName == 'mysql'">concat('%',#{totalContractIds},'%')</if>
  755. </if>
  756. <!--<if test="totalContractId != null and totalContractId != ''">
  757. AND a.total_contract_id =#{totalContractId}
  758. </if>-->
  759. <if test="contractPrice != '' and contractPrice != null">
  760. AND a.contract_price like concat('%',#{contractPrice},'%')
  761. </if>
  762. <if test="contractState != null and contractState != ''">
  763. AND a.contract_state = #{contractState}
  764. </if>
  765. <if test="contractNum != null and contractNum!= ''">
  766. AND a.contract_num = #{contractNum}
  767. </if>
  768. ${sqlMap.dsf}
  769. </where>
  770. <choose>
  771. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  772. ORDER BY ${page.orderBy}
  773. </when>
  774. <otherwise>
  775. ORDER BY a.contract_date DESC
  776. </otherwise>
  777. </choose>
  778. </select>
  779. <select id="findAllList" resultType="WorkContractInfo" >
  780. SELECT
  781. <include refid="workContractInfoColumns"/>
  782. FROM work_contract_info a
  783. <include refid="workContractInfoJoins"/>
  784. <where>
  785. a.del_flag = #{DEL_FLAG_NORMAL}
  786. </where>
  787. <choose>
  788. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  789. ORDER BY ${page.orderBy}
  790. </when>
  791. <otherwise>
  792. ORDER BY a.update_date DESC
  793. </otherwise>
  794. </choose>
  795. </select>
  796. <insert id="insert">
  797. INSERT INTO work_contract_info(
  798. id,
  799. project_id,
  800. project_name,
  801. ext,
  802. create_by,
  803. create_date,
  804. update_by,
  805. update_date,
  806. del_flag,
  807. remarks,
  808. client_id,
  809. contract_date,
  810. effective_date,
  811. closing_date,
  812. name,
  813. contract_category,
  814. contract_num,
  815. contract_price,
  816. contract_opposite,
  817. contract_type,
  818. contract_fee,
  819. contract_special,
  820. contract_state,
  821. office_id,
  822. contract_file_id,
  823. contract_role,
  824. apply_view,
  825. process_instance_id,
  826. create_name,
  827. create_company,
  828. company_id,
  829. contractFeeDoc,
  830. contractTypeDoc,
  831. charge_company_name,
  832. another_contract_num,
  833. is_total,
  834. total_contract_id,
  835. is_total_name,
  836. total_contract_ids,
  837. common_flag,
  838. status,
  839. investment_scale,
  840. summary_payment,
  841. investment_amount,
  842. construction_project_type,
  843. create_bys,
  844. alter_state,
  845. alter_sign,
  846. record_state,
  847. alterbefore_id,
  848. completion_status,
  849. sort,
  850. signature_status,
  851. contract_num_path
  852. ) VALUES (
  853. #{id},
  854. #{project.id},
  855. #{projectName},
  856. #{ext},
  857. #{createBy.id},
  858. #{createDate},
  859. #{updateBy.id},
  860. #{updateDate},
  861. #{delFlag},
  862. #{remarks},
  863. #{client.id},
  864. #{contractDate},
  865. #{effectiveDate},
  866. #{closingDate},
  867. #{name},
  868. #{contractCategory},
  869. #{contractNum},
  870. #{contractPrice},
  871. #{contractOpposite},
  872. #{contractType},
  873. #{contractFee},
  874. #{contractSpecial},
  875. #{contractState},
  876. #{chargeCompany},
  877. #{contractFileId},
  878. #{contractRole},
  879. #{applyView},
  880. #{processInstanceId},
  881. #{createName},
  882. #{createCompany},
  883. #{companyId},
  884. #{contractFeeDoc},
  885. #{contractTypeDoc},
  886. #{chargeCompanyName},
  887. #{anotherContractNum},
  888. #{isTotal},
  889. #{totalContractId},
  890. #{isTotalName},
  891. #{totalContractIds},
  892. #{commonFlag},
  893. #{status},
  894. #{investmentScale},
  895. #{summaryPayment},
  896. #{investmentAmount},
  897. #{constructionProjectType},
  898. #{createBys},
  899. #{alterState},
  900. #{alterSign},
  901. #{recordState},
  902. #{alterBeforeId},
  903. #{completionStatus},
  904. #{sort},
  905. #{signatureStatus},
  906. #{contractNumPath}
  907. )
  908. </insert>
  909. <update id="update">
  910. UPDATE work_contract_info SET
  911. update_by = #{updateBy.id},
  912. project_id = #{project.id},
  913. project_name = #{projectName},
  914. ext = #{ext},
  915. update_date = #{updateDate},
  916. remarks = #{remarks},
  917. client_id = #{client.id},
  918. contract_date = #{contractDate},
  919. effective_date = #{effectiveDate},
  920. closing_date = #{closingDate},
  921. name = #{name},
  922. contract_category = #{contractCategory},
  923. contract_num = #{contractNum},
  924. contract_price = #{contractPrice},
  925. contract_opposite = #{contractOpposite},
  926. contract_type = #{contractType},
  927. contract_fee = #{contractFee},
  928. contract_special = #{contractSpecial},
  929. contract_state = #{contractState},
  930. office_id = #{chargeCompany},
  931. contract_file_id = #{contractFileId},
  932. contract_role = #{contractRole},
  933. apply_view = #{applyView},
  934. process_instance_id = #{processInstanceId},
  935. company_id = #{companyId},
  936. contractFeeDoc = #{contractFeeDoc},
  937. contractTypeDoc = #{contractTypeDoc},
  938. charge_company_name = #{chargeCompanyName},
  939. another_contract_num = #{anotherContractNum},
  940. is_total = #{isTotal},
  941. total_contract_id = #{totalContractId},
  942. status = #{status},
  943. investment_scale = #{investmentScale},
  944. summary_payment = #{summaryPayment},
  945. investment_amount = #{investmentAmount},
  946. construction_project_type = #{constructionProjectType},
  947. create_bys = #{createBys},
  948. invalidate_process_instance_id = #{invalidateProcessInstanceId},
  949. alter_process_instance_id = #{alterProcessInstanceId},
  950. invalidate_status = #{invalidateStatus},
  951. invalidate_user = #{invalidateUserId},
  952. alter_state = #{alterState},
  953. alter_sign = #{alterSign},
  954. record_state = #{recordState},
  955. alterbefore_id = #{alterBeforeId},
  956. completion_status = #{completionStatus},
  957. sort = #{sort},
  958. signature_status=#{signatureStatus},
  959. contract_num_path=#{contractNumPath}
  960. WHERE id = #{id}
  961. </update>
  962. <update id="updateId">
  963. UPDATE work_contract_info SET
  964. id = #{beforeId}
  965. WHERE id = #{id}
  966. </update>
  967. <update id="updateBeforeId">
  968. UPDATE work_contract_info SET
  969. alterbefore_id = #{beforeId}
  970. WHERE id = #{id}
  971. </update>
  972. <!--物理删除-->
  973. <update id="delete">
  974. DELETE FROM work_contract_info
  975. WHERE id = #{id}
  976. </update>
  977. <!--逻辑删除-->
  978. <update id="deleteByLogic">
  979. UPDATE work_contract_info SET
  980. del_flag = #{DEL_FLAG_DELETE}
  981. WHERE id = #{id}
  982. </update>
  983. <insert id="inertContractManger">
  984. INSERT INTO work_contract_annex(
  985. id,
  986. create_by,
  987. create_date,
  988. update_by,
  989. remarks,
  990. contract_id,
  991. name,
  992. url
  993. )
  994. VALUES
  995. <foreach collection="list" item="item" index="index" separator="," >
  996. (#{item.id},#{item.createBy.id},#{item.createDate},#{item.updateBy.id},#{item.remarks},
  997. #{item.contractNoId},#{item.name},#{item.url})
  998. </foreach>
  999. </insert>
  1000. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  1001. <select id="findUniqueByProperty" resultType="WorkContractInfo" statementType="STATEMENT">
  1002. select * FROM work_contract_info where ${propertyName} = '${value}'
  1003. </select>
  1004. <select id="findListByclient" resultType="WorkClientInfo">
  1005. SELECT
  1006. a.*
  1007. FROM work_client_info a
  1008. LEFT JOIN work_client_linkman b on a.id = b.client_id
  1009. <where>
  1010. a.del_flag = #{DEL_FLAG_NORMAL}
  1011. <if test="companyId != null and companyId != ''">
  1012. AND a.company_id = #{companyId}
  1013. </if>
  1014. <if test="workLinkName != null and workLinkName != ''">
  1015. AND b.name like concat('%',#{workLinkName},'%')
  1016. </if>
  1017. <if test="name != null and name != ''">
  1018. AND a.name like concat('%',#{name},'%')
  1019. </if>
  1020. GROUP BY a.id
  1021. </where>
  1022. <choose>
  1023. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  1024. ORDER BY ${page.orderBy}
  1025. </when>
  1026. <otherwise>
  1027. ORDER BY a.update_date DESC
  1028. </otherwise>
  1029. </choose>
  1030. </select>
  1031. <update id="updateInvalidateStatusAndUser">
  1032. <!-- 不要判空,因为有需要置空 -->
  1033. UPDATE work_contract_info SET
  1034. invalidate_status = #{invalidateStatus},
  1035. invalidate_user = #{invalidateUserId}
  1036. WHERE id = #{id}
  1037. </update>
  1038. <!-- 更新作废流程id -->
  1039. <update id="updateInvalidateProcessInstanceId">
  1040. UPDATE work_contract_info SET
  1041. invalidate_process_instance_id = #{invalidateProcessInstanceId}
  1042. WHERE id = #{id}
  1043. </update>
  1044. <!-- 更新作废流程id -->
  1045. <update id="saveContractPrice">
  1046. UPDATE work_contract_info SET
  1047. contract_price = #{contractPrice}
  1048. WHERE id = #{id}
  1049. </update>
  1050. <update id="updatealterProcessInstanceId">
  1051. UPDATE work_contract_info SET
  1052. alter_process_instance_id = #{alterProcessInstanceId}
  1053. WHERE id = #{id}
  1054. </update>
  1055. <!-- 根据合同作废流程ID获取合同信息 -->
  1056. <select id="getByInvalidateProcessInstanceId" resultType="WorkContractInfo">
  1057. SELECT
  1058. <include refid="workContractInfoColumns"/>
  1059. FROM work_contract_info a
  1060. <include refid="workContractInfoJoins"/>
  1061. WHERE a.invalidate_process_instance_id = #{invalidateProcessInstanceId}
  1062. </select>
  1063. <!-- 根据合同作废流程ID获取合同信息 -->
  1064. <select id="getByalterProcessInstanceId" resultType="WorkContractInfo">
  1065. SELECT
  1066. <include refid="workContractInfoColumns"/>
  1067. FROM work_contract_info a
  1068. <include refid="workContractInfoJoins"/>
  1069. WHERE a.alter_process_instance_id = #{alterProcessInstanceId}
  1070. </select>
  1071. <!--更新审批流程id-->
  1072. <update id="updateProcessInstanceId">
  1073. UPDATE work_contract_info SET
  1074. process_instance_id = #{processInstanceId}
  1075. WHERE id = #{id}
  1076. </update>
  1077. <!-- 获取流程ID -->
  1078. <select id="getByProcessInstanceId" resultType="WorkContractInfo">
  1079. SELECT
  1080. <include refid="workContractInfoColumns"/>
  1081. FROM work_contract_info a
  1082. <include refid="workContractInfoJoins"/>
  1083. WHERE a.process_instance_id = #{processInstanceId}
  1084. </select>
  1085. <select id="findWaitAndFinishList" parameterType="map" resultType="WorkContractInfo">
  1086. SELECT
  1087. a.id AS "id",
  1088. (select name from sys_user user where user.id=a.create_by) AS "createBy.id",
  1089. a.create_date AS "createDate",
  1090. a.update_by AS "updateBy.id",
  1091. a.update_date AS "updateDate",
  1092. a.del_flag AS "delFlag",
  1093. a.remarks AS "remarks",
  1094. a.client_id AS "client.id",
  1095. a.contract_date AS "contractDate",
  1096. a.effective_date AS "effectiveDate",
  1097. a.closing_date AS "closingDate",
  1098. a.name AS "name",
  1099. a.contract_num_path as "contractNumPath",
  1100. a.contract_category AS "contractCategory",
  1101. a.contract_num AS "contractNum",
  1102. a.contract_price AS "contractPrice",
  1103. a.contract_opposite AS "contractOpposite",
  1104. a.contract_type AS "contractType",
  1105. a.contract_fee AS "contractFee",
  1106. a.contract_special AS "contractSpecial",
  1107. a.contract_state AS "contractState",
  1108. a.office_id AS "chargeCompany",
  1109. a.contract_file_id AS "contractFileId",
  1110. a.contract_role AS "contractRole",
  1111. a.apply_view AS "applyView",
  1112. a.process_instance_id AS "processInstanceId",
  1113. a.company_id as companyId,
  1114. client.name AS "client.name",
  1115. a.contractTypeDoc,
  1116. a.contractFeeDoc,
  1117. a.charge_company_name AS "chargeCompanyName",
  1118. a.another_contract_num AS "anotherContractNum",
  1119. client.name AS "client.name",
  1120. a.is_total AS "isTotal",
  1121. a.total_contract_id AS "totalContractId"
  1122. FROM work_contract_info a
  1123. <include refid="workContractInfoJoins"/>
  1124. WHERE
  1125. process_instance_id in (${procInsIds})
  1126. </select>
  1127. <delete id="deleteFile">
  1128. DELETE FROM work_contract_annex
  1129. WHERE contract_id = #{id}
  1130. </delete>
  1131. <select id="findByList" resultType="WorkContractInfo">
  1132. SELECT
  1133. a.id,a.sort
  1134. FROM work_contract_info a
  1135. <where>
  1136. a.del_flag = #{DEL_FLAG_NORMAL}
  1137. AND (
  1138. a.total_contract_id = #{totalContractId} OR a.id= #{totalContractId})
  1139. </where>
  1140. ORDER BY a.sort DESC
  1141. </select>
  1142. <!--月计划管理选择已签未完成的合同-->
  1143. <select id="findWorkContractInfoPage" resultType="WorkContractInfo">
  1144. SELECT
  1145. a.id AS "id",
  1146. a.contract_date AS "contractDate",
  1147. a.name AS "name",
  1148. a.contract_num AS "contractNum",
  1149. a.contract_price AS "contractPrice",
  1150. a.contract_type AS "contractType",
  1151. c.name AS "client.name",
  1152. a.construction_project_type AS "constructionProjectType"
  1153. FROM work_contract_info a
  1154. left join work_client_info c on c.id=a.client_id
  1155. <where>
  1156. a.del_flag = #{DEL_FLAG_NORMAL}
  1157. <if test="client != null and client.name != null and client.name != ''">
  1158. AND c.name LIKE concat('%',#{client.name},'%')
  1159. </if>
  1160. <if test="beginContractDate != null and endContractDate != null and beginContractDate != '' and endContractDate != ''">
  1161. AND a.contract_date BETWEEN #{beginContractDate} AND #{endContractDate}
  1162. </if>
  1163. <if test="name != null and name != ''">
  1164. AND a.name LIKE
  1165. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  1166. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  1167. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  1168. </if>
  1169. <if test="contractPrice != '' and contractPrice != null">
  1170. AND a.contract_price like concat('%',#{contractPrice},'%')
  1171. </if>
  1172. <if test="contractNum != null and contractNum!= ''">
  1173. AND a.contract_num like concat('%',#{contractNum},'%')
  1174. </if>
  1175. AND a.contract_state = '5'
  1176. and a.office_id=#{officeId}
  1177. </where>
  1178. <choose>
  1179. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  1180. ORDER BY ${page.orderBy}
  1181. </when>
  1182. <otherwise>
  1183. ORDER BY a.contract_date DESC
  1184. </otherwise>
  1185. </choose>
  1186. </select>
  1187. <select id="countByOffice" resultType="int">
  1188. SELECT count(1) FROM work_contract_info a WHERE a.office_id = #{officeId} AND a.del_flag='0'
  1189. </select>
  1190. <update id="updateStatus">
  1191. UPDATE work_contract_info SET
  1192. contract_state = #{contractState}
  1193. WHERE id = #{id}
  1194. </update>
  1195. </mapper>