OrgCognizanceMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  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
  388. u.id as uid,
  389. c.id as cid,
  390. o.unit_name as unitName,
  391. o.org_code as orgCode,
  392. o.postal_address as postalAddress,
  393. c.contacts,
  394. c.technical_field1 as technicalField1,
  395. c.technical_field2 as technicalField2,
  396. c.technical_field3 as technicalField3,
  397. c.basic_research_cost as basicResearchCost,
  398. c.accident,
  399. c.large_order as largeOrder,
  400. c.year,
  401. c.certificate_number as certificateNumber
  402. from (select id from user where id = #{0}) u
  403. LEFT JOIN organization_identity o on u.id = o.uid
  404. INNER JOIN org_cognizance c on c.uid = u.id and c.deleted_sign = 0 and c.id = #{1}
  405. </select>
  406. <select id="selectCognizanceResearchCostBoByUidAndYear" resultType="com.goafanti.cognizance.bo.CognizanceResearchCostBo">
  407. select m.uid, sum(m.cost1) as researchCost, sum(m.territory) as territory from(
  408. select uid, (internal_labor_cost + internal_direct_cost + internal_depreciation_cost + internal_amortization_cost
  409. + internal_design_cost + internal_equipment_cost + internal_other_cost +external_total_cost) as cost1,
  410. external_abroad_cost as territory
  411. from org_activity_cost
  412. where (start_date >= (select str_to_date(CONCAT(#{0}-3,'-01-01'), '%Y-%m-%d %H'))
  413. and start_date <![CDATA[ < ]]> (select str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H')))
  414. or (end_date <![CDATA[ < ]]> (select str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H')) and
  415. end_date >= (select str_to_date(CONCAT(#{0}-3,'-01-01'), '%Y-%m-%d %H')))
  416. and deleted_sign = 0
  417. ) m where m.uid = #{1} GROUP BY m.uid
  418. </select>
  419. <select id="selectCognizanceManageCostBoByUidAndYear" resultType="com.goafanti.cognizance.bo.CognizanceManageCostBo">
  420. select u.id as uid, a.netAsset1, a.salesRevenue1, a.grossProfit1, b.netAsset2, b.salesRevenue2, b.grossProfit2,
  421. c.netAsset3, c.salesRevenue3, c.grossProfit3 from
  422. (select id from user where id = #{1}) u
  423. LEFT JOIN
  424. (
  425. select uid, net_asset as netAsset1, gross_profit as grossProfit1, sales_revenue as salesRevenue1 from org_finance where uid = #{1} and year =
  426. #{0}-1 and deleted_sign = 0
  427. ) a ON a.uid = u.id
  428. LEFT JOIN
  429. (
  430. select uid, net_asset as netAsset2, gross_profit as grossProfit2, sales_revenue as salesRevenue2 from org_finance where uid = #{1} and year =
  431. #{0}-2 and deleted_sign = 0
  432. ) b on b.uid = u. id
  433. LEFT JOIN
  434. (
  435. select uid, net_asset as netAsset3, gross_profit as grossProfit3, sales_revenue as salesRevenue3 from org_finance where uid = #{1} and year =
  436. #{0}-3 and deleted_sign = 0
  437. ) c on c.uid = u.id
  438. </select>
  439. <select id="selectCognizanceCatagoryBoByUidAndYear" resultType="com.goafanti.cognizance.bo.CognizanceCatagoryBo">
  440. select
  441. u.id as uid,
  442. a.firstCatagory, b.secondCatagory,
  443. c.firmTotal,
  444. c.techTotal,
  445. d.totalRevenue FROM
  446. (
  447. select id from user where id = #{1}
  448. ) u
  449. LEFT JOIN
  450. (
  451. select
  452. uid,
  453. count(1) as firstCatagory
  454. from org_intellectual_property
  455. where uid = #{1}
  456. and evaluation_category= 0
  457. and deleted_sign = 0
  458. and authorization_date >=
  459. (
  460. select
  461. str_to_date(CONCAT(#{0}-3,'-01-01'), '%Y-%m-%d %H')
  462. )
  463. and authorization_date <![CDATA[ < ]]>
  464. (
  465. select
  466. str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H')
  467. )
  468. and deleted_sign = 0
  469. GROUP BY uid
  470. ) a on a.uid = u.id
  471. LEFT JOIN
  472. (
  473. select
  474. uid,
  475. count(1) as secondCatagory
  476. from org_intellectual_property
  477. where uid = #{1}
  478. and evaluation_category = 1
  479. and deleted_sign = 0
  480. and authorization_date >=
  481. (
  482. select
  483. str_to_date(CONCAT(#{0}-3,'-01-01'), '%Y-%m-%d %H')
  484. )
  485. and authorization_date <![CDATA[ < ]]>
  486. (
  487. select
  488. str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H')
  489. )
  490. GROUP BY uid
  491. ) b on b.uid = u.id
  492. LEFT JOIN
  493. (
  494. select
  495. uid,
  496. firm_total as firmTotal,
  497. tech_total as techTotal
  498. from org_human_resource
  499. where
  500. uid = #{1}
  501. and year = #{0}-1
  502. and deleted_sign = 0
  503. ) c on c.uid = u.id
  504. LEFT JOIN
  505. (
  506. SELECT
  507. uid,
  508. (operating_income + non_operating_income - non_taxable_income) as totalRevenue
  509. from org_ratepay
  510. where
  511. uid = #{1}
  512. and year = #{0}-1
  513. and deleted_sign = 0
  514. ) d on d.uid = u.id
  515. </select>
  516. <select id="selectLastYearRevenueByUidAndYear" resultType="java.math.BigDecimal">
  517. SELECT
  518. sum(last_year_revenue) as lastYearRevenue
  519. from org_tech_product
  520. where
  521. uid = #{1}
  522. and year = #{0}-1
  523. and deleted_sign = 0
  524. </select>
  525. <select id="selectCognizanceByUidAndYear" resultMap="BaseResultMap" >
  526. select
  527. <include refid="Base_Column_List" />
  528. from org_cognizance
  529. where year = #{0} and uid = #{1} and deleted_sign = 0
  530. </select>
  531. <update id="batchDeleteByPrimaryKey" parameterType="java.util.List">
  532. update org_cognizance set deleted_sign = 1
  533. where id in
  534. <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
  535. #{item}
  536. </foreach>
  537. </update>
  538. <select id="findCultivationListByPage" parameterType="java.lang.String" resultType="com.goafanti.cognizance.bo.CultivationListBo">
  539. select
  540. u.id as uid,
  541. i.licence_province as province,
  542. i.unit_name as unitName,
  543. i.cog_contacts as cogContacts,
  544. i.certificate_number as certificateNumber,
  545. i.issuing_date as issuingDate,
  546. a.name as consultant,
  547. i.tech_principal,
  548. CONCAT(i.first_contacts,' ', i.first_mobile) as firstContacts,
  549. CONCAT(i.second_contacts,' ', i.second_mobile) as secondContacts,
  550. CONCAT(i.third_contacts,' ', i.third_mobile) as thirdContacts
  551. from user u
  552. LEFT JOIN organization_identity i on u.id = i.uid
  553. LEFT JOIN admin a on a.id = u.aid
  554. where u.type = 1 and u.lvl = 1
  555. <if test="unitName != null">
  556. and i.unit_name like CONCAT('%', #{unitName,jdbcType=VARCHAR}, '%')
  557. </if>
  558. <if test="uid != null">
  559. and u.id = #{uid,jdbcType=VARCHAR}
  560. </if>
  561. <if test="province != null">
  562. and i.licence_province = #{province,jdbcType=INTEGER}
  563. </if>
  564. <if test="page_sql!=null">
  565. ${page_sql}
  566. </if>
  567. </select>
  568. <select id="findCultivationCount" resultType="java.lang.Integer" parameterType="java.lang.String">
  569. select count(1)
  570. from user u
  571. LEFT JOIN organization_identity i on u.id = i.uid
  572. LEFT JOIN admin a on a.id = u.aid
  573. where u.type = 1 and u.lvl = 1
  574. <if test="unitName != null">
  575. and i.unit_name = #{unitName,jdbcType=VARCHAR}
  576. </if>
  577. <if test="uid != null">
  578. and u.id = #{uid,jdbcType=VARCHAR}
  579. </if>
  580. <if test="province != null">
  581. and i.licence_province = #{province,jdbcType=INTEGER}
  582. </if>
  583. </select>
  584. <select id="selectLatelyRecordYear" resultType="Integer" parameterType="java.lang.String" >
  585. select
  586. Max(year)
  587. from org_cognizance
  588. where state not in (8, 11, 13)
  589. and deleted_sign = 0
  590. and uid= #{uid,jdbcType=VARCHAR}
  591. </select>
  592. <select id="selectContractCognizanceByContractId" resultType="com.goafanti.cognizance.bo.CognizanceContractBo" parameterType="java.lang.String" >
  593. select
  594. oc.id,
  595. oc.uid,
  596. oc.contract_id as contractId,
  597. oc.year,
  598. oc.serial_number as serialNumber,
  599. oc.state,
  600. oc.certificate_Number as certificateNumber,
  601. a.name as techPrincipal
  602. from org_cognizance oc
  603. left join admin a on a.id = oc.tech_principal
  604. where oc.contract_id = #{contractId,jdbcType=VARCHAR}
  605. </select>
  606. <update id="batchDeleteByContractId" parameterType="java.util.List">
  607. update org_cognizance set deleted_sign = 1
  608. where contract_id in
  609. <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
  610. #{item}
  611. </foreach>
  612. </update>
  613. <select id="findFirstCatagory" resultType="java.lang.Integer">
  614. select
  615. count(1) as firstCatagory
  616. from org_intellectual_property
  617. where uid = #{uid,jdbcType=VARCHAR}
  618. and evaluation_category= 0
  619. and deleted_sign = 0
  620. and authorization_date >=
  621. (
  622. select
  623. str_to_date(CONCAT(#{year,jdbcType=INTEGER}-3,'-01-01'), '%Y-%m-%d %H')
  624. )
  625. and authorization_date <![CDATA[ < ]]>
  626. (
  627. select
  628. str_to_date(CONCAT(#{year,jdbcType=INTEGER},'-01-01'), '%Y-%m-%d %H')
  629. )
  630. and deleted_sign = 0
  631. GROUP BY uid
  632. </select>
  633. <select id="findSecondCatagory" resultType="java.lang.Integer">
  634. select
  635. count(1) as secondCatagory
  636. from org_intellectual_property
  637. where uid = #{uid,jdbcType=VARCHAR}
  638. and evaluation_category = 1
  639. and deleted_sign = 0
  640. and authorization_date >=
  641. (
  642. select
  643. str_to_date(CONCAT(#{year,jdbcType=INTEGER}-3,'-01-01'), '%Y-%m-%d %H')
  644. )
  645. and authorization_date <![CDATA[ < ]]>
  646. (
  647. select
  648. str_to_date(CONCAT(#{year,jdbcType=INTEGER},'-01-01'), '%Y-%m-%d %H')
  649. )
  650. GROUP BY uid
  651. </select>
  652. <select id="findFirmAndTechTotal" resultType="com.goafanti.common.model.OrgHumanResource">
  653. select
  654. uid,
  655. firm_total as firmTotal,
  656. tech_total as techTotal
  657. from org_human_resource
  658. where
  659. uid = #{uid,jdbcType=VARCHAR}
  660. and year = #{year,jdbcType=INTEGER}-1
  661. and deleted_sign = 0
  662. </select>
  663. <select id="findTotalRevenue" resultType="java.math.BigDecimal">
  664. SELECT
  665. (operating_income + non_operating_income - non_taxable_income) as totalRevenue
  666. from org_ratepay
  667. where
  668. uid = #{uid,jdbcType=VARCHAR}
  669. and year = #{year,jdbcType=INTEGER}-1
  670. and deleted_sign = 0
  671. </select>
  672. </mapper>