OrgCognizanceMapper.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  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.goafanti.common.dao.OrgCognizanceMapper" >
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.OrgCognizance" >
  5. <id column="id" property="id" jdbcType="VARCHAR" />
  6. <result column="uid" property="uid" jdbcType="VARCHAR" />
  7. <result column="serial_number" property="serialNumber" jdbcType="INTEGER" />
  8. <result column="contacts" property="contacts" jdbcType="INTEGER" />
  9. <result column="comment" property="comment" jdbcType="VARCHAR" />
  10. <result column="consultant" property="consultant" jdbcType="VARCHAR" />
  11. <result column="technical_field1" property="technicalField1" jdbcType="INTEGER" />
  12. <result column="technical_field2" property="technicalField2" jdbcType="INTEGER" />
  13. <result column="technical_field3" property="technicalField3" jdbcType="INTEGER" />
  14. <result column="basic_research_cost" property="basicResearchCost" jdbcType="DECIMAL" />
  15. <result column="accident" property="accident" jdbcType="INTEGER" />
  16. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  17. <result column="accept_date" property="acceptDate" jdbcType="TIMESTAMP" />
  18. <result column="issuing_date" property="issuingDate" jdbcType="TIMESTAMP" />
  19. <result column="certificate_number" property="certificateNumber" jdbcType="VARCHAR" />
  20. <result column="certificate_url" property="certificateUrl" jdbcType="VARCHAR" />
  21. <result column="state" property="state" jdbcType="INTEGER" />
  22. <result column="year" property="year" jdbcType="INTEGER" />
  23. <result column="record_time" property="recordTime" jdbcType="TIMESTAMP" />
  24. <result column="large_order" property="largeOrder" jdbcType="INTEGER" />
  25. <result column="deleted_sign" property="deletedSign" jdbcType="INTEGER" />
  26. <result column="founder" property="founder" jdbcType="VARCHAR" />
  27. <result column="tech_principal" property="techPrincipal" jdbcType="VARCHAR" />
  28. <result column="contract_id" property="contractId" jdbcType="VARCHAR" />
  29. </resultMap>
  30. <sql id="Base_Column_List" >
  31. id, uid, serial_number, contacts, comment, consultant, technical_field1, technical_field2,
  32. technical_field3, basic_research_cost, accident, create_time, accept_date, issuing_date,
  33. certificate_number, certificate_url, state, year, record_time, large_order, deleted_sign,
  34. founder, tech_principal, contract_id
  35. </sql>
  36. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
  37. select
  38. <include refid="Base_Column_List" />
  39. from org_cognizance
  40. where id = #{id,jdbcType=VARCHAR}
  41. </select>
  42. <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
  43. delete from org_cognizance
  44. where id = #{id,jdbcType=VARCHAR}
  45. </delete>
  46. <insert id="insert" parameterType="com.goafanti.common.model.OrgCognizance" >
  47. insert into org_cognizance (id, uid, serial_number,
  48. contacts, comment, consultant,
  49. technical_field1, technical_field2, technical_field3,
  50. basic_research_cost, accident, create_time,
  51. accept_date, issuing_date, certificate_number,
  52. certificate_url, state, year, record_time, large_order, deleted_sign, founder,
  53. tech_principal, contract_id
  54. )
  55. values (#{id,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR}, #{serialNumber,jdbcType=INTEGER},
  56. #{contacts,jdbcType=INTEGER}, #{comment,jdbcType=VARCHAR}, #{consultant,jdbcType=VARCHAR},
  57. #{technicalField1,jdbcType=INTEGER}, #{technicalField2,jdbcType=INTEGER}, #{technicalField3,jdbcType=INTEGER},
  58. #{basicResearchCost,jdbcType=DECIMAL}, #{accident,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
  59. #{acceptDate,jdbcType=TIMESTAMP}, #{issuingDate,jdbcType=TIMESTAMP}, #{certificateNumber,jdbcType=VARCHAR},
  60. #{certificateUrl,jdbcType=VARCHAR}, #{state,jdbcType=INTEGER}, #{year,jdbcType=INTEGER}, #{recordTime,jdbcType=TIMESTAMP},
  61. #{largeOrder,jdbcType=INTEGER}, #{deletedSign,jdbcType=INTEGER}, #{founder,jdbcType=VARCHAR},
  62. #{techPrincipal,jdbcType=VARCHAR}, #{contractId,jdbcType=VARCHAR}
  63. )
  64. </insert>
  65. <insert id="insertSelective" parameterType="com.goafanti.common.model.OrgCognizance" >
  66. insert into org_cognizance
  67. <trim prefix="(" suffix=")" suffixOverrides="," >
  68. <if test="id != null" >
  69. id,
  70. </if>
  71. <if test="uid != null" >
  72. uid,
  73. </if>
  74. <if test="serialNumber != null" >
  75. serial_number,
  76. </if>
  77. <if test="contacts != null" >
  78. contacts,
  79. </if>
  80. <if test="comment != null" >
  81. comment,
  82. </if>
  83. <if test="consultant != null" >
  84. consultant,
  85. </if>
  86. <if test="technicalField1 != null" >
  87. technical_field1,
  88. </if>
  89. <if test="technicalField2 != null" >
  90. technical_field2,
  91. </if>
  92. <if test="technicalField3 != null" >
  93. technical_field3,
  94. </if>
  95. <if test="basicResearchCost != null" >
  96. basic_research_cost,
  97. </if>
  98. <if test="accident != null" >
  99. accident,
  100. </if>
  101. <if test="createTime != null" >
  102. create_time,
  103. </if>
  104. <if test="acceptDate != null" >
  105. accept_date,
  106. </if>
  107. <if test="issuingDate != null" >
  108. issuing_date,
  109. </if>
  110. <if test="certificateNumber != null" >
  111. certificate_number,
  112. </if>
  113. <if test="certificateUrl != null" >
  114. certificate_url,
  115. </if>
  116. <if test="state != null" >
  117. state,
  118. </if>
  119. <if test="year != null" >
  120. year,
  121. </if>
  122. <if test="recordTime != null" >
  123. record_time,
  124. </if>
  125. <if test="largeOrder != null" >
  126. large_order,
  127. </if>
  128. <if test="deletedSign != null" >
  129. deleted_sign,
  130. </if>
  131. <if test="founder != null" >
  132. founder,
  133. </if>
  134. <if test="techPrincipal != null" >
  135. tech_principal,
  136. </if>
  137. <if test="contractId != null" >
  138. contract_id,
  139. </if>
  140. </trim>
  141. <trim prefix="values (" suffix=")" suffixOverrides="," >
  142. <if test="id != null" >
  143. #{id,jdbcType=VARCHAR},
  144. </if>
  145. <if test="uid != null" >
  146. #{uid,jdbcType=VARCHAR},
  147. </if>
  148. <if test="serialNumber != null" >
  149. #{serialNumber,jdbcType=INTEGER},
  150. </if>
  151. <if test="contacts != null" >
  152. #{contacts,jdbcType=INTEGER},
  153. </if>
  154. <if test="comment != null" >
  155. #{comment,jdbcType=VARCHAR},
  156. </if>
  157. <if test="consultant != null" >
  158. #{consultant,jdbcType=VARCHAR},
  159. </if>
  160. <if test="technicalField1 != null" >
  161. #{technicalField1,jdbcType=INTEGER},
  162. </if>
  163. <if test="technicalField2 != null" >
  164. #{technicalField2,jdbcType=INTEGER},
  165. </if>
  166. <if test="technicalField3 != null" >
  167. #{technicalField3,jdbcType=INTEGER},
  168. </if>
  169. <if test="basicResearchCost != null" >
  170. #{basicResearchCost,jdbcType=DECIMAL},
  171. </if>
  172. <if test="accident != null" >
  173. #{accident,jdbcType=INTEGER},
  174. </if>
  175. <if test="createTime != null" >
  176. #{createTime,jdbcType=TIMESTAMP},
  177. </if>
  178. <if test="acceptDate != null" >
  179. #{acceptDate,jdbcType=TIMESTAMP},
  180. </if>
  181. <if test="issuingDate != null" >
  182. #{issuingDate,jdbcType=TIMESTAMP},
  183. </if>
  184. <if test="certificateNumber != null" >
  185. #{certificateNumber,jdbcType=VARCHAR},
  186. </if>
  187. <if test="certificateUrl != null" >
  188. #{certificateUrl,jdbcType=VARCHAR},
  189. </if>
  190. <if test="state != null" >
  191. #{state,jdbcType=INTEGER},
  192. </if>
  193. <if test="year != null" >
  194. #{year,jdbcType=INTEGER},
  195. </if>
  196. <if test="recordTime != null" >
  197. #{recordTime,jdbcType=TIMESTAMP},
  198. </if>
  199. <if test="largeOrder != null" >
  200. #{largeOrder,jdbcType=INTEGER},
  201. </if>
  202. <if test="deletedSign != null" >
  203. #{deletedSign,jdbcType=INTEGER},
  204. </if>
  205. <if test="founder != null" >
  206. #{founder,jdbcType=VARCHAR},
  207. </if>
  208. <if test="techPrincipal != null" >
  209. #{techPrincipal,jdbcType=VARCHAR},
  210. </if>
  211. <if test="contractId != null" >
  212. #{contractId,jdbcType=VARCHAR},
  213. </if>
  214. </trim>
  215. </insert>
  216. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.OrgCognizance" >
  217. update org_cognizance
  218. <set >
  219. <if test="uid != null" >
  220. uid = #{uid,jdbcType=VARCHAR},
  221. </if>
  222. <if test="serialNumber != null" >
  223. serial_number = #{serialNumber,jdbcType=INTEGER},
  224. </if>
  225. <if test="contacts != null" >
  226. contacts = #{contacts,jdbcType=INTEGER},
  227. </if>
  228. <if test="comment != null" >
  229. comment = #{comment,jdbcType=VARCHAR},
  230. </if>
  231. <if test="consultant != null" >
  232. consultant = #{consultant,jdbcType=VARCHAR},
  233. </if>
  234. <if test="technicalField1 != null" >
  235. technical_field1 = #{technicalField1,jdbcType=INTEGER},
  236. </if>
  237. <if test="technicalField2 != null" >
  238. technical_field2 = #{technicalField2,jdbcType=INTEGER},
  239. </if>
  240. <if test="technicalField3 != null" >
  241. technical_field3 = #{technicalField3,jdbcType=INTEGER},
  242. </if>
  243. <if test="basicResearchCost != null" >
  244. basic_research_cost = #{basicResearchCost,jdbcType=DECIMAL},
  245. </if>
  246. <if test="accident != null" >
  247. accident = #{accident,jdbcType=INTEGER},
  248. </if>
  249. <if test="createTime != null" >
  250. create_time = #{createTime,jdbcType=TIMESTAMP},
  251. </if>
  252. <if test="acceptDate != null" >
  253. accept_date = #{acceptDate,jdbcType=TIMESTAMP},
  254. </if>
  255. <if test="issuingDate != null" >
  256. issuing_date = #{issuingDate,jdbcType=TIMESTAMP},
  257. </if>
  258. <if test="certificateNumber != null" >
  259. certificate_number = #{certificateNumber,jdbcType=VARCHAR},
  260. </if>
  261. <if test="certificateUrl != null" >
  262. certificate_url = #{certificateUrl,jdbcType=VARCHAR},
  263. </if>
  264. <if test="state != null" >
  265. state = #{state,jdbcType=INTEGER},
  266. </if>
  267. <if test="year != null" >
  268. year = #{year,jdbcType=INTEGER},
  269. </if>
  270. <if test="recordTime != null" >
  271. record_time = #{recordTime,jdbcType=TIMESTAMP},
  272. </if>
  273. <if test="largeOrder != null" >
  274. large_order = #{largeOrder,jdbcType=INTEGER},
  275. </if>
  276. <if test="deletedSign != null" >
  277. deleted_sign = #{deletedSign,jdbcType=INTEGER},
  278. </if>
  279. <if test="founder != null" >
  280. founder = #{founder,jdbcType=VARCHAR},
  281. </if>
  282. <if test="techPrincipal != null" >
  283. tech_principal = #{techPrincipal,jdbcType=VARCHAR},
  284. </if>
  285. <if test="contractId != null" >
  286. contract_id = #{contractId,jdbcType=VARCHAR},
  287. </if>
  288. </set>
  289. where id = #{id,jdbcType=VARCHAR}
  290. </update>
  291. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.OrgCognizance" >
  292. update org_cognizance
  293. set uid = #{uid,jdbcType=VARCHAR},
  294. serial_number = #{serialNumber,jdbcType=INTEGER},
  295. contacts = #{contacts,jdbcType=INTEGER},
  296. comment = #{comment,jdbcType=VARCHAR},
  297. consultant = #{consultant,jdbcType=VARCHAR},
  298. technical_field1 = #{technicalField1,jdbcType=INTEGER},
  299. technical_field2 = #{technicalField2,jdbcType=INTEGER},
  300. technical_field3 = #{technicalField3,jdbcType=INTEGER},
  301. basic_research_cost = #{basicResearchCost,jdbcType=DECIMAL},
  302. accident = #{accident,jdbcType=INTEGER},
  303. create_time = #{createTime,jdbcType=TIMESTAMP},
  304. accept_date = #{acceptDate,jdbcType=TIMESTAMP},
  305. issuing_date = #{issuingDate,jdbcType=TIMESTAMP},
  306. certificate_number = #{certificateNumber,jdbcType=VARCHAR},
  307. certificate_url = #{certificateUrl,jdbcType=VARCHAR},
  308. state = #{state,jdbcType=INTEGER},
  309. year = #{year,jdbcType=INTEGER},
  310. record_time = #{recordTime,jdbcType=TIMESTAMP},
  311. large_order = #{largeOrder,jdbcType=INTEGER},
  312. deleted_sign = #{deletedSign,jdbcType=INTEGER},
  313. founder = #{founder,jdbcType=VARCHAR},
  314. tech_principal = #{techPrincipal,jdbcType=VARCHAR},
  315. contract_id = #{contractId,jdbcType=VARCHAR}
  316. where id = #{id,jdbcType=VARCHAR}
  317. </update>
  318. <select id="findCognizanceBoByPage" parameterType="String" resultType="com.goafanti.cognizance.bo.CognizanceBo">
  319. select c.id as cid, c.uid as uid, c.serial_number as serialNumber, i.licence_province as locationProvince,
  320. i.unit_name as unitName, c.contacts, c.create_time as createTime, c.contract_id as contractId,
  321. c.comment, c.state, c.certificate_number as certificateNumber, c.large_order as largeOrder,
  322. c.issuing_date as issuingDate, c.year, a.name as consultant,
  323. CONCAT(i.first_contacts,' ', i.first_mobile) as firstContacts,
  324. CONCAT(i.second_contacts,' ', i.second_mobile) as secondContacts,
  325. CONCAT(i.third_contacts,' ', i.third_mobile) as thirdContacts,
  326. ad.name as founder, ct.serial_number as contractNumber
  327. from org_cognizance c
  328. LEFT JOIN organization_identity i on c.uid = i.uid
  329. LEFT JOIN admin a on c.consultant = a.id
  330. LEFT JOIN admin ad on c.founder = ad.id
  331. left join contract ct on ct.id = c.contract_id
  332. <if test="principal != null">
  333. left join contract_log l on c.contract_id=l.cid
  334. </if>
  335. where c.deleted_sign = 0
  336. <if test="principal != null">
  337. and l.principal = #{principal,jdbcType=VARCHAR}
  338. </if>
  339. <if test="unitName != null">
  340. and i.unit_name like CONCAT('%', #{unitName,jdbcType=VARCHAR}, '%')
  341. </if>
  342. <if test="uid != null">
  343. and c.uid = #{uid,jdbcType=VARCHAR}
  344. </if>
  345. <if test="contractId != null">
  346. and c.contract_id = #{contractId,jdbcType=VARCHAR}
  347. </if>
  348. <if test="locationProvince != null">
  349. and i.licence_province = #{locationProvince, jdbcType=INTEGER}
  350. </if>
  351. <if test="principal != null">
  352. group by c.id
  353. </if>
  354. order by c.serial_number desc
  355. <if test="page_sql!=null">
  356. ${page_sql}
  357. </if>
  358. </select>
  359. <select id="findCognizanceBoCount" resultType="java.lang.Integer" parameterType="String">
  360. select count(1)
  361. from org_cognizance c
  362. LEFT JOIN organization_identity i on c.uid = i.uid
  363. <if test="principal != null">
  364. left join contract_log l on c.contract_id=l.cid
  365. </if>
  366. where c.deleted_sign = 0
  367. <if test="principal != null">
  368. and l.principal = #{principal,jdbcType=VARCHAR}
  369. </if>
  370. <if test="contractId != null">
  371. and c.contract_id = #{contractId,jdbcType=VARCHAR}
  372. </if>
  373. <if test="uid != null">
  374. and c.uid = #{uid,jdbcType=VARCHAR}
  375. </if>
  376. <if test="unitName != null">
  377. and i.unit_name like CONCAT('%', #{unitName,jdbcType=VARCHAR}, '%')
  378. </if>
  379. <if test="locationProvince != null">
  380. and i.licence_province = #{locationProvince, jdbcType=INTEGER}
  381. </if>
  382. <if test="principal != null">
  383. group by c.id
  384. </if>
  385. </select>
  386. <select id="selectCognizanceOrgInfoBoByUidAndCid" resultType="com.goafanti.cognizance.bo.CognizanceOrgInfoBo">
  387. select u.id as uid, c.id as cid, o.unit_name as unitName, o.org_code as orgCode, o.postal_address as postalAddress,
  388. c.contacts, c.technical_field1 as technicalField1, c.technical_field2 as technicalField2, c.technical_field3 as technicalField3,
  389. c.basic_research_cost as basicResearchCost, c.accident, c.large_order as largeOrder, c.year, c.certificate_number as certificateNumber
  390. from (select id from user where id = #{0}) u
  391. LEFT JOIN organization_identity o on u.id = o.uid
  392. INNER JOIN org_cognizance c on c.uid = u.id and c.deleted_sign = 0 and c.id = #{1}
  393. </select>
  394. <select id="selectCognizanceResearchCostBoByUidAndYear" resultType="com.goafanti.cognizance.bo.CognizanceResearchCostBo">
  395. select m.uid, sum(m.cost1) as researchCost, sum(m.territory) as territory from(
  396. select uid, (internal_labor_cost + internal_direct_cost + internal_depreciation_cost + internal_amortization_cost
  397. + internal_design_cost + internal_equipment_cost + internal_other_cost +external_total_cost) as cost1,
  398. external_abroad_cost as territory
  399. from org_activity_cost
  400. where (start_date >= (select str_to_date(CONCAT(#{0}-3,'-01-01'), '%Y-%m-%d %H'))
  401. and start_date <![CDATA[ < ]]> (select str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H')))
  402. or (end_date <![CDATA[ < ]]> (select str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H')) and
  403. end_date >= (select str_to_date(CONCAT(#{0}-3,'-01-01'), '%Y-%m-%d %H')))
  404. and deleted_sign = 0
  405. ) m where m.uid = #{1} GROUP BY m.uid
  406. </select>
  407. <select id="selectCognizanceManageCostBoByUidAndYear" resultType="com.goafanti.cognizance.bo.CognizanceManageCostBo">
  408. select u.id as uid, a.netAsset1, a.salesRevenue1, a.grossProfit1, b.netAsset2, b.salesRevenue2, b.grossProfit2,
  409. c.netAsset3, c.salesRevenue3, c.grossProfit3 from
  410. (select id from user where id = #{1}) u
  411. LEFT JOIN
  412. (
  413. select uid, net_asset as netAsset1, gross_profit as grossProfit1, sales_revenue as salesRevenue1 from org_finance where uid = #{1} and year =
  414. #{0}-1 and deleted_sign = 0
  415. ) a ON a.uid = u.id
  416. LEFT JOIN
  417. (
  418. select uid, net_asset as netAsset2, gross_profit as grossProfit2, sales_revenue as salesRevenue2 from org_finance where uid = #{1} and year =
  419. #{0}-2 and deleted_sign = 0
  420. ) b on b.uid = u. id
  421. LEFT JOIN
  422. (
  423. select uid, net_asset as netAsset3, gross_profit as grossProfit3, sales_revenue as salesRevenue3 from org_finance where uid = #{1} and year =
  424. #{0}-3 and deleted_sign = 0
  425. ) c on c.uid = u.id
  426. </select>
  427. <select id="selectCognizanceCatagoryBoByUidAndYear" resultType="com.goafanti.cognizance.bo.CognizanceCatagoryBo">
  428. select
  429. u.id as uid,
  430. a.firstCatagory, b.secondCatagory,
  431. c.firmTotal,
  432. c.techTotal,
  433. d.totalRevenue FROM
  434. (
  435. select id from user where id = #{1}
  436. ) u
  437. LEFT JOIN
  438. (
  439. select
  440. uid,
  441. count(1) as firstCatagory
  442. from org_intellectual_property
  443. where uid = #{1}
  444. and evaluation_category= 0
  445. and deleted_sign = 0
  446. and authorization_date >=
  447. (
  448. select
  449. str_to_date(CONCAT(#{0}-2,'-01-01'), '%Y-%m-%d %H')
  450. )
  451. and authorization_date <![CDATA[ < ]]>
  452. (
  453. select
  454. str_to_date(CONCAT(#{0}+1,'-01-01'), '%Y-%m-%d %H')
  455. )
  456. and deleted_sign = 0
  457. GROUP BY uid
  458. ) a on a.uid = u.id
  459. LEFT JOIN
  460. (
  461. select
  462. uid,
  463. count(1) as secondCatagory
  464. from org_intellectual_property
  465. where uid = #{1}
  466. and evaluation_category = 1
  467. and deleted_sign = 0
  468. and authorization_date >=
  469. (
  470. select
  471. str_to_date(CONCAT(#{0}-2,'-01-01'), '%Y-%m-%d %H')
  472. )
  473. and authorization_date <![CDATA[ < ]]>
  474. (
  475. select
  476. str_to_date(CONCAT(#{0}+1,'-01-01'), '%Y-%m-%d %H')
  477. )
  478. GROUP BY uid
  479. ) b on b.uid = u.id
  480. LEFT JOIN
  481. (
  482. select
  483. uid,
  484. firm_total as firmTotal,
  485. tech_total as techTotal
  486. from org_human_resource
  487. where
  488. uid = #{1}
  489. and year = #{0}-1
  490. and deleted_sign = 0
  491. ) c on c.uid = u.id
  492. LEFT JOIN
  493. (
  494. SELECT
  495. uid,
  496. (operating_income + non_operating_income - non_taxable_income) as totalRevenue
  497. from org_ratepay
  498. where
  499. uid = #{1}
  500. and year = #{0}-1
  501. and deleted_sign = 0
  502. ) d on d.uid = u.id
  503. </select>
  504. <select id="selectLastYearRevenueByUidAndYear" resultType="java.math.BigDecimal">
  505. SELECT
  506. sum(last_year_revenue) as lastYearRevenue
  507. from org_tech_product
  508. where
  509. uid = #{1}
  510. and year = #{0}
  511. and deleted_sign = 0
  512. </select>
  513. <select id="selectCognizanceByUidAndYear" resultMap="BaseResultMap" >
  514. select
  515. <include refid="Base_Column_List" />
  516. from org_cognizance
  517. where year = #{0} and uid = #{1} and deleted_sign = 0
  518. </select>
  519. <update id="batchDeleteByPrimaryKey" parameterType="java.util.List">
  520. update org_cognizance set deleted_sign = 1
  521. where id in
  522. <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
  523. #{item}
  524. </foreach>
  525. </update>
  526. <select id="findCultivationListByPage" parameterType="java.lang.String" resultType="com.goafanti.cognizance.bo.CultivationListBo">
  527. select
  528. u.id as uid,
  529. i.licence_province as province,
  530. i.unit_name as unitName,
  531. i.cog_contacts as cogContacts,
  532. i.certificate_number as certificateNumber,
  533. i.issuing_date as issuingDate,
  534. a.name as consultant,
  535. i.tech_principal,
  536. CONCAT(i.first_contacts,' ', i.first_mobile) as firstContacts,
  537. CONCAT(i.second_contacts,' ', i.second_mobile) as secondContacts,
  538. CONCAT(i.third_contacts,' ', i.third_mobile) as thirdContacts
  539. from user u
  540. LEFT JOIN organization_identity i on u.id = i.uid
  541. LEFT JOIN admin a on a.id = u.aid
  542. where u.type = 1 and u.lvl = 1
  543. <if test="unitName != null">
  544. and i.unit_name like CONCAT('%', #{unitName,jdbcType=VARCHAR}, '%')
  545. </if>
  546. <if test="uid != null">
  547. and u.id = #{uid,jdbcType=VARCHAR}
  548. </if>
  549. <if test="province != null">
  550. and i.licence_province = #{province,jdbcType=INTEGER}
  551. </if>
  552. <if test="page_sql!=null">
  553. ${page_sql}
  554. </if>
  555. </select>
  556. <select id="findCultivationCount" resultType="java.lang.Integer" parameterType="java.lang.String">
  557. select count(1)
  558. from user u
  559. LEFT JOIN organization_identity i on u.id = i.uid
  560. LEFT JOIN admin a on a.id = u.aid
  561. where u.type = 1 and u.lvl = 1
  562. <if test="unitName != null">
  563. and i.unit_name = #{unitName,jdbcType=VARCHAR}
  564. </if>
  565. <if test="uid != null">
  566. and u.id = #{uid,jdbcType=VARCHAR}
  567. </if>
  568. <if test="province != null">
  569. and i.licence_province = #{province,jdbcType=INTEGER}
  570. </if>
  571. </select>
  572. <select id="selectLatelyRecordYear" resultType="Integer" parameterType="java.lang.String" >
  573. select
  574. Max(year)
  575. from org_cognizance
  576. where state not in (8, 11, 13)
  577. and deleted_sign = 0
  578. and uid= #{uid,jdbcType=VARCHAR}
  579. </select>
  580. <select id="selectContractCognizanceByContractId" resultType="com.goafanti.cognizance.bo.CognizanceContractBo" parameterType="java.lang.String" >
  581. select
  582. oc.id, oc.uid, oc.contract_id as contractId,
  583. oc.year, oc.serial_number as serialNumber, oc.state,
  584. oc.certificate_Number as certificate_number, a.name as techPrincipal
  585. from org_cognizance oc
  586. left join admin a on a.id = oc.tech_principal
  587. where oc.contract_id = #{contractId,jdbcType=VARCHAR}
  588. </select>
  589. <update id="batchDeleteByContractId" parameterType="java.util.List">
  590. update org_cognizance set deleted_sign = 1
  591. where contract_id in
  592. <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
  593. #{item}
  594. </foreach>
  595. </update>
  596. </mapper>