OrgAnnualReportMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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.OrgAnnualReportMapper" >
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.OrgAnnualReport" >
  5. <id column="id" property="id" jdbcType="VARCHAR" />
  6. <result column="uid" property="uid" jdbcType="VARCHAR" />
  7. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  8. <result column="last_update_time" property="lastUpdateTime" jdbcType="TIMESTAMP" />
  9. <result column="total_tax" property="totalTax" jdbcType="DECIMAL" />
  10. <result column="income_tax_relief" property="incomeTaxRelief" jdbcType="DECIMAL" />
  11. <result column="total_export_volume" property="totalExportVolume" jdbcType="DECIMAL" />
  12. <result column="basic_research_cost" property="basicResearchCost" jdbcType="DECIMAL" />
  13. <result column="year" property="year" jdbcType="INTEGER" />
  14. <result column="state" property="state" jdbcType="INTEGER" />
  15. <result column="deleted_sign" property="deletedSign" jdbcType="INTEGER" />
  16. </resultMap>
  17. <sql id="Base_Column_List" >
  18. id, uid, create_time, last_update_time, total_tax, income_tax_relief, total_export_volume, basic_research_cost,
  19. year, state, deleted_sign
  20. </sql>
  21. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
  22. select
  23. <include refid="Base_Column_List" />
  24. from org_annual_report
  25. where id = #{id,jdbcType=VARCHAR}
  26. </select>
  27. <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
  28. delete from org_annual_report
  29. where id = #{id,jdbcType=VARCHAR}
  30. </delete>
  31. <insert id="insert" parameterType="com.goafanti.common.model.OrgAnnualReport" >
  32. insert into org_annual_report (id, uid, create_time,
  33. last_update_time, total_tax, income_tax_relief,
  34. total_export_volume, basic_research_cost, year, state,
  35. deleted_sign)
  36. values (#{id,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
  37. #{lastUpdateTime,jdbcType=TIMESTAMP}, #{totalTax,jdbcType=DECIMAL}, #{incomeTaxRelief,jdbcType=DECIMAL},
  38. #{totalExportVolume,jdbcType=DECIMAL}, #{basicResearchCost,jdbcType=DECIMAL},
  39. #{year,jdbcType=INTEGER}, #{state,jdbcType=INTEGER},
  40. #{deletedSign,jdbcType=INTEGER})
  41. </insert>
  42. <insert id="insertSelective" parameterType="com.goafanti.common.model.OrgAnnualReport" >
  43. insert into org_annual_report
  44. <trim prefix="(" suffix=")" suffixOverrides="," >
  45. <if test="id != null" >
  46. id,
  47. </if>
  48. <if test="uid != null" >
  49. uid,
  50. </if>
  51. <if test="createTime != null" >
  52. create_time,
  53. </if>
  54. <if test="lastUpdateTime != null" >
  55. last_update_time,
  56. </if>
  57. <if test="totalTax != null" >
  58. total_tax,
  59. </if>
  60. <if test="incomeTaxRelief != null" >
  61. income_tax_relief,
  62. </if>
  63. <if test="totalExportVolume != null" >
  64. total_export_volume,
  65. </if>
  66. <if test="basicResearchCost != null">
  67. basic_research_cost
  68. </if>
  69. <if test="year != null" >
  70. year,
  71. </if>
  72. <if test="state != null" >
  73. state,
  74. </if>
  75. <if test="deletedSign != null" >
  76. deleted_sign,
  77. </if>
  78. </trim>
  79. <trim prefix="values (" suffix=")" suffixOverrides="," >
  80. <if test="id != null" >
  81. #{id,jdbcType=VARCHAR},
  82. </if>
  83. <if test="uid != null" >
  84. #{uid,jdbcType=VARCHAR},
  85. </if>
  86. <if test="createTime != null" >
  87. #{createTime,jdbcType=TIMESTAMP},
  88. </if>
  89. <if test="lastUpdateTime != null" >
  90. #{lastUpdateTime,jdbcType=TIMESTAMP},
  91. </if>
  92. <if test="totalTax != null" >
  93. #{totalTax,jdbcType=DECIMAL},
  94. </if>
  95. <if test="incomeTaxRelief != null" >
  96. #{incomeTaxRelief,jdbcType=DECIMAL},
  97. </if>
  98. <if test="totalExportVolume != null" >
  99. #{totalExportVolume,jdbcType=DECIMAL},
  100. </if>
  101. <if test="basicResearchCost != null">
  102. #{basicResearchCost,jdbcType=DECIMAL},
  103. </if>
  104. <if test="year != null" >
  105. #{year,jdbcType=INTEGER},
  106. </if>
  107. <if test="state != null" >
  108. #{state,jdbcType=INTEGER},
  109. </if>
  110. <if test="deletedSign != null" >
  111. #{deletedSign,jdbcType=INTEGER},
  112. </if>
  113. </trim>
  114. </insert>
  115. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.OrgAnnualReport" >
  116. update org_annual_report
  117. <set >
  118. <if test="uid != null" >
  119. uid = #{uid,jdbcType=VARCHAR},
  120. </if>
  121. <if test="createTime != null" >
  122. create_time = #{createTime,jdbcType=TIMESTAMP},
  123. </if>
  124. <if test="lastUpdateTime != null" >
  125. last_update_time = #{lastUpdateTime,jdbcType=TIMESTAMP},
  126. </if>
  127. <if test="totalTax != null" >
  128. total_tax = #{totalTax,jdbcType=DECIMAL},
  129. </if>
  130. <if test="incomeTaxRelief != null" >
  131. income_tax_relief = #{incomeTaxRelief,jdbcType=DECIMAL},
  132. </if>
  133. <if test="totalExportVolume != null" >
  134. total_export_volume = #{totalExportVolume,jdbcType=DECIMAL},
  135. </if>
  136. <if test="basicResearchCost != null" >
  137. basic_research_cost = #{basicResearchCost,jdbcType=DECIMAL},
  138. </if>
  139. <if test="year != null" >
  140. year = #{year,jdbcType=INTEGER},
  141. </if>
  142. <if test="state != null" >
  143. state = #{state,jdbcType=INTEGER},
  144. </if>
  145. <if test="deletedSign != null" >
  146. deleted_sign = #{deletedSign,jdbcType=INTEGER},
  147. </if>
  148. </set>
  149. where id = #{id,jdbcType=VARCHAR}
  150. </update>
  151. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.OrgAnnualReport" >
  152. update org_annual_report
  153. set uid = #{uid,jdbcType=VARCHAR},
  154. create_time = #{createTime,jdbcType=TIMESTAMP},
  155. last_update_time = #{lastUpdateTime,jdbcType=TIMESTAMP},
  156. total_tax = #{totalTax,jdbcType=DECIMAL},
  157. income_tax_relief = #{incomeTaxRelief,jdbcType=DECIMAL},
  158. total_export_volume = #{totalExportVolume,jdbcType=DECIMAL},
  159. basic_research_cost = #{basicResearchCost,jdbcType=DECIMAL},
  160. year = #{year,jdbcType=INTEGER},
  161. state = #{state,jdbcType=INTEGER},
  162. deleted_sign = #{deletedSign,jdbcType=INTEGER}
  163. where id = #{id,jdbcType=VARCHAR}
  164. </update>
  165. <select id="findOrgAnnualReportListByPage" parameterType="java.lang.String" resultMap="BaseResultMap">
  166. select
  167. <include refid="Base_Column_List" />
  168. from org_annual_report
  169. where deleted_sign = 0
  170. <if test="year != null">
  171. and year = #{year,jdbcType=INTEGER}
  172. </if>
  173. <if test="state != null">
  174. and state = #{state,jdbcType=INTEGER}
  175. </if>
  176. <if test="uid != null">
  177. and uid = #{uid,jdbcType=VARCHAR}
  178. </if>
  179. order by year desc
  180. <if test="page_sql != null">
  181. ${page_sql}
  182. </if>
  183. </select>
  184. <select id="findOrgAnnualReportCount" resultType="java.lang.Integer" parameterType="String">
  185. select count(1)
  186. from org_annual_report
  187. where deleted_sign = 0
  188. <if test="year != null">
  189. and year = #{year,jdbcType=INTEGER}
  190. </if>
  191. <if test="state != null">
  192. and state = #{state,jdbcType=INTEGER}
  193. </if>
  194. <if test="uid != null">
  195. and uid = #{uid,jdbcType=VARCHAR}
  196. </if>
  197. </select>
  198. <update id="batchDeleteByPrimaryKey" parameterType="java.util.List">
  199. update org_annual_report set deleted_sign = 1
  200. where id in
  201. <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
  202. #{item}
  203. </foreach>
  204. </update>
  205. <select id="selectAnnualReportPropertyRightBoByYearAndUid" resultType="com.goafanti.cognizance.bo.AnnualReportPropertyRightBo">
  206. select u.id as uid, a.utilityPatent, b.exteriorPatent, c.softwareWorks, d.defensePatent, e.newPlantCariety, f.nationalCrop,
  207. g.nationalDrug, h.chineseMedicine, i.circuitDesign, j.inventionPatent from
  208. (
  209. select id from user where id = #{1}
  210. ) u LEFT JOIN
  211. (
  212. select uid, count(1) as utilityPatent
  213. from org_intellectual_property
  214. where uid = #{1} and catagory = 2 and authorization_date
  215. >= (select str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H') )
  216. and authorization_date <![CDATA[ < ]]> (select str_to_date(CONCAT(#{0}+1,'-01-01'), '%Y-%m-%d %H'))
  217. and deleted_sign = 0
  218. ) a on a.uid = u.id
  219. LEFT JOIN
  220. (
  221. select uid, count(1) as exteriorPatent
  222. from org_intellectual_property
  223. where uid = #{1} and catagory = 3 and authorization_date
  224. >= (select str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H') )
  225. and authorization_date <![CDATA[ < ]]> (select str_to_date(CONCAT(#{0}+1,'-01-01'), '%Y-%m-%d %H'))
  226. and deleted_sign = 0
  227. ) b on u.id = b.uid
  228. LEFT JOIN
  229. (
  230. select uid, count(1) as softwareWorks
  231. from org_intellectual_property
  232. where uid = #{1} and catagory = 4 and authorization_date
  233. >= (select str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H') )
  234. and authorization_date <![CDATA[ < ]]> (select str_to_date(CONCAT(#{0}+1,'-01-01'), '%Y-%m-%d %H'))
  235. and deleted_sign = 0
  236. ) c on u.id = c.uid
  237. LEFT JOIN
  238. (
  239. select uid, count(1) as defensePatent
  240. from org_intellectual_property
  241. where uid = #{1} and catagory = 5 and authorization_date
  242. >= (select str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H') )
  243. and authorization_date <![CDATA[ < ]]> (select str_to_date(CONCAT(#{0}+1,'-01-01'), '%Y-%m-%d %H'))
  244. and deleted_sign = 0
  245. ) d on u.id = d.uid
  246. LEFT JOIN
  247. (
  248. select uid, count(1) as newPlantCariety
  249. from org_intellectual_property
  250. where uid = #{1} and catagory = 6 and authorization_date
  251. >= (select str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H') )
  252. and authorization_date <![CDATA[ < ]]> (select str_to_date(CONCAT(#{0}+1,'-01-01'), '%Y-%m-%d %H'))
  253. and deleted_sign = 0
  254. ) e on u.id = e.uid
  255. LEFT JOIN
  256. (
  257. select uid, count(1) as nationalCrop
  258. from org_intellectual_property
  259. where uid = #{1} and catagory = 7 and authorization_date
  260. >= (select str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H') )
  261. and authorization_date <![CDATA[ < ]]> (select str_to_date(CONCAT(#{0}+1,'-01-01'), '%Y-%m-%d %H'))
  262. and deleted_sign = 0
  263. ) f on u.id = f.uid
  264. LEFT JOIN
  265. (
  266. select uid, count(1) as nationalDrug
  267. from org_intellectual_property
  268. where uid = #{1} and catagory = 8 and authorization_date
  269. >= (select str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H') )
  270. and authorization_date <![CDATA[ < ]]> (select str_to_date(CONCAT(#{0}+1,'-01-01'), '%Y-%m-%d %H'))
  271. and deleted_sign = 0
  272. ) g on u.id = g.uid
  273. LEFT JOIN
  274. (
  275. select uid, count(1) as chineseMedicine
  276. from org_intellectual_property
  277. where uid = #{1} and catagory = 9 and authorization_date
  278. >= (select str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H') )
  279. and authorization_date <![CDATA[ < ]]> (select str_to_date(CONCAT(#{0}+1,'-01-01'), '%Y-%m-%d %H'))
  280. and deleted_sign = 0
  281. ) h on u.id = h.uid
  282. LEFT JOIN
  283. (
  284. select uid, count(1) as circuitDesign
  285. from org_intellectual_property
  286. where uid = #{1} and catagory = 10 and authorization_date
  287. >= (select str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H') )
  288. and authorization_date <![CDATA[ < ]]> (select str_to_date(CONCAT(#{0}+1,'-01-01'), '%Y-%m-%d %H'))
  289. and deleted_sign = 0
  290. ) i on u.id = i.uid
  291. LEFT JOIN
  292. (
  293. select uid, count(1) as inventionPatent
  294. from org_intellectual_property
  295. where uid = #{1} and catagory = 11 and authorization_date
  296. >= (select str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H') )
  297. and authorization_date <![CDATA[ < ]]> (select str_to_date(CONCAT(#{0}+1,'-01-01'), '%Y-%m-%d %H'))
  298. and deleted_sign = 0
  299. ) j on u.id = j.uid
  300. </select>
  301. <select id="selectAnnualReportTerritoryByYearAndUid" resultType="java.math.BigDecimal">
  302. select sum(m.territory) as territory from(
  303. select uid,
  304. external_abroad_cost as territory
  305. from org_activity_cost
  306. where uid = #{1} and
  307. (start_date >= (select str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H') )
  308. and start_date <![CDATA[ < ]]> (select str_to_date(CONCAT(#{0}+1,'-01-01'), '%Y-%m-%d %H') )
  309. or (end_date >= (select str_to_date(CONCAT(#{0},'-01-01'), '%Y-%m-%d %H') )
  310. and end_date <![CDATA[ < ]]> (select str_to_date(CONCAT(#{0}+1,'-01-01'), '%Y-%m-%d %H') ) ))
  311. and deleted_sign = 0
  312. ) m
  313. </select>
  314. <select id="selectAnnualReportMainBoByYearAndUid" resultType="com.goafanti.cognizance.bo.AnnualReportMainBo">
  315. select u.id as uid, o.unit_name as unitName, o.org_code as orgCode, o.location_province as locationProvince,
  316. o.location_city as locationCity, o.location_area as locationArea, o.listed, o.listed_date as listedDate,
  317. o.listed_type as listedType, o.stock_code as stockCode, h.firm_total as firmTotal, h.tech_total as techTotal,
  318. h.new_employment as newEmployment, h.graduate_number as graduateNumber,
  319. f.sales_revenue as salesRevenue, f.gross_profit as grossProfit, f.net_asset as netAsset,
  320. c.certificate_number as certificateNumber, c.issuing_date as issuingDate, c.contacts, r.research_cost as researchCost,
  321. x.totalRevenue, y.lastYearRevenue from
  322. (select id from user where id = #{1}) u
  323. LEFT JOIN organization_identity o
  324. on u.id = o.uid AND o.audit_status = 5
  325. LEFT JOIN org_human_resource h on h.uid = u.id AND h.year = #{0} AND h.deleted_sign = 0
  326. LEFT JOIN org_finance f on f.uid = u.id AND f.year = #{0} AND f.deleted_sign = 0
  327. LEFT JOIN org_cognizance c on c.uid = u.id AND c.year = #{0} AND c.deleted_sign = 0
  328. LEFT JOIN org_ratepay r on r.uid = u.id AND r.year = #{0} AND r.deleted_sign = 0
  329. LEFT JOIN
  330. (SELECT uid,(operating_income + non_operating_income - non_taxable_income) as totalRevenue
  331. from org_ratepay where uid = #{1}
  332. and year = #{0} and deleted_sign = 0)
  333. x on x.uid = u.id
  334. LEFT JOIN
  335. (
  336. SELECT uid, sum(last_year_revenue) as lastYearRevenue
  337. from org_tech_product where uid = #{1}
  338. and year = #{0} and deleted_sign = 0
  339. ) y on y.uid = u.id
  340. </select>
  341. <select id="selectAnnualReportByYearAndUid" resultMap="BaseResultMap">
  342. select
  343. <include refid="Base_Column_List" />
  344. from org_annual_report
  345. where year = #{0} and uid = #{1} and deleted_sign = 0
  346. </select>
  347. </mapper>