OrgActivityCostMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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.OrgActivityCostMapper" >
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.OrgActivityCost" >
  5. <id column="id" property="id" jdbcType="VARCHAR" />
  6. <result column="aid" property="aid" jdbcType="VARCHAR" />
  7. <result column="uid" property="uid" jdbcType="VARCHAR" />
  8. <result column="year" property="year" jdbcType="INTEGER" />
  9. <result column="activity_number" property="activityNumber" jdbcType="VARCHAR" />
  10. <result column="internal_labor_cost" property="internalLaborCost" jdbcType="DECIMAL" />
  11. <result column="internal_direct_cost" property="internalDirectCost" jdbcType="DECIMAL" />
  12. <result column="internal_depreciation_cost" property="internalDepreciationCost" jdbcType="DECIMAL" />
  13. <result column="internal_amortization_cost" property="internalAmortizationCost" jdbcType="DECIMAL" />
  14. <result column="internal_design_cost" property="internalDesignCost" jdbcType="DECIMAL" />
  15. <result column="internal_equipment_cost" property="internalEquipmentCost" jdbcType="DECIMAL" />
  16. <result column="internal_other_cost" property="internalOtherCost" jdbcType="DECIMAL" />
  17. <result column="external_total_cost" property="externalTotalCost" jdbcType="DECIMAL" />
  18. <result column="external_abroad_cost" property="externalAbroadCost" jdbcType="DECIMAL" />
  19. <result column="enterprise_filler" property="enterpriseFiller" jdbcType="VARCHAR" />
  20. <result column="sign_date" property="signDate" jdbcType="TIMESTAMP" />
  21. <result column="sort_number" property="sortNumber" jdbcType="VARCHAR" />
  22. <result column="start_date" property="startDate" jdbcType="TIMESTAMP" />
  23. <result column="end_date" property="endDate" jdbcType="TIMESTAMP" />
  24. <result column="account_url" property="accountUrl" jdbcType="VARCHAR" />
  25. <result column="deleted_sign" property="deletedSign" jdbcType="INTEGER" />
  26. </resultMap>
  27. <sql id="Base_Column_List" >
  28. id, aid, uid, year, activity_number, internal_labor_cost, internal_direct_cost, internal_depreciation_cost,
  29. internal_amortization_cost, internal_design_cost, internal_equipment_cost, internal_other_cost,
  30. external_total_cost, external_abroad_cost, enterprise_filler, sign_date, sort_number,
  31. start_date, end_date, account_url, deleted_sign
  32. </sql>
  33. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
  34. select
  35. <include refid="Base_Column_List" />
  36. from org_activity_cost
  37. where id = #{id,jdbcType=VARCHAR}
  38. </select>
  39. <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
  40. delete from org_activity_cost
  41. where id = #{id,jdbcType=VARCHAR}
  42. </delete>
  43. <insert id="insert" parameterType="com.goafanti.common.model.OrgActivityCost" >
  44. insert into org_activity_cost (id, aid, uid, year,
  45. activity_number, internal_labor_cost, internal_direct_cost,
  46. internal_depreciation_cost, internal_amortization_cost,
  47. internal_design_cost, internal_equipment_cost,
  48. internal_other_cost, external_total_cost, external_abroad_cost,
  49. enterprise_filler, sign_date, sort_number,
  50. start_date, end_date, account_url, deleted_sign
  51. )
  52. values (#{id,jdbcType=VARCHAR}, #{aid,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR}, #{year,jdbcType=INTEGER},
  53. #{activityNumber,jdbcType=VARCHAR}, #{internalLaborCost,jdbcType=DECIMAL}, #{internalDirectCost,jdbcType=DECIMAL},
  54. #{internalDepreciationCost,jdbcType=DECIMAL}, #{internalAmortizationCost,jdbcType=DECIMAL},
  55. #{internalDesignCost,jdbcType=DECIMAL}, #{internalEquipmentCost,jdbcType=DECIMAL},
  56. #{internalOtherCost,jdbcType=DECIMAL}, #{externalTotalCost,jdbcType=DECIMAL}, #{externalAbroadCost,jdbcType=DECIMAL},
  57. #{enterpriseFiller,jdbcType=VARCHAR}, #{signDate,jdbcType=TIMESTAMP}, #{sortNumber,jdbcType=VARCHAR},
  58. #{startDate,jdbcType=TIMESTAMP}, #{endDate,jdbcType=TIMESTAMP}, #{accountUrl,jdbcType=VARCHAR}, #{deletedSign,jdbcType=INTEGER}
  59. )
  60. </insert>
  61. <insert id="insertSelective" parameterType="com.goafanti.common.model.OrgActivityCost" >
  62. insert into org_activity_cost
  63. <trim prefix="(" suffix=")" suffixOverrides="," >
  64. <if test="id != null" >
  65. id,
  66. </if>
  67. <if test="aid != null" >
  68. aid,
  69. </if>
  70. <if test="uid != null" >
  71. uid,
  72. </if>
  73. <if test="year != null" >
  74. year,
  75. </if>
  76. <if test="activityNumber != null" >
  77. activity_number,
  78. </if>
  79. <if test="internalLaborCost != null" >
  80. internal_labor_cost,
  81. </if>
  82. <if test="internalDirectCost != null" >
  83. internal_direct_cost,
  84. </if>
  85. <if test="internalDepreciationCost != null" >
  86. internal_depreciation_cost,
  87. </if>
  88. <if test="internalAmortizationCost != null" >
  89. internal_amortization_cost,
  90. </if>
  91. <if test="internalDesignCost != null" >
  92. internal_design_cost,
  93. </if>
  94. <if test="internalEquipmentCost != null" >
  95. internal_equipment_cost,
  96. </if>
  97. <if test="internalOtherCost != null" >
  98. internal_other_cost,
  99. </if>
  100. <if test="externalTotalCost != null" >
  101. external_total_cost,
  102. </if>
  103. <if test="externalAbroadCost != null" >
  104. external_abroad_cost,
  105. </if>
  106. <if test="enterpriseFiller != null" >
  107. enterprise_filler,
  108. </if>
  109. <if test="signDate != null" >
  110. sign_date,
  111. </if>
  112. <if test="sortNumber != null" >
  113. sort_number,
  114. </if>
  115. <if test="startDate != null" >
  116. start_date,
  117. </if>
  118. <if test="endDate != null" >
  119. end_date,
  120. </if>
  121. <if test="accountUrl != null" >
  122. account_url,
  123. </if>
  124. <if test="deletedSign != null" >
  125. deleted_sign,
  126. </if>
  127. </trim>
  128. <trim prefix="values (" suffix=")" suffixOverrides="," >
  129. <if test="id != null" >
  130. #{id,jdbcType=VARCHAR},
  131. </if>
  132. <if test="aid != null" >
  133. #{aid,jdbcType=VARCHAR},
  134. </if>
  135. <if test="uid != null" >
  136. #{uid,jdbcType=VARCHAR},
  137. </if>
  138. <if test="year != null" >
  139. #{year,jdbcType=INTEGER},
  140. </if>
  141. <if test="activityNumber != null" >
  142. #{activityNumber,jdbcType=VARCHAR},
  143. </if>
  144. <if test="internalLaborCost != null" >
  145. #{internalLaborCost,jdbcType=DECIMAL},
  146. </if>
  147. <if test="internalDirectCost != null" >
  148. #{internalDirectCost,jdbcType=DECIMAL},
  149. </if>
  150. <if test="internalDepreciationCost != null" >
  151. #{internalDepreciationCost,jdbcType=DECIMAL},
  152. </if>
  153. <if test="internalAmortizationCost != null" >
  154. #{internalAmortizationCost,jdbcType=DECIMAL},
  155. </if>
  156. <if test="internalDesignCost != null" >
  157. #{internalDesignCost,jdbcType=DECIMAL},
  158. </if>
  159. <if test="internalEquipmentCost != null" >
  160. #{internalEquipmentCost,jdbcType=DECIMAL},
  161. </if>
  162. <if test="internalOtherCost != null" >
  163. #{internalOtherCost,jdbcType=DECIMAL},
  164. </if>
  165. <if test="externalTotalCost != null" >
  166. #{externalTotalCost,jdbcType=DECIMAL},
  167. </if>
  168. <if test="externalAbroadCost != null" >
  169. #{externalAbroadCost,jdbcType=DECIMAL},
  170. </if>
  171. <if test="enterpriseFiller != null" >
  172. #{enterpriseFiller,jdbcType=VARCHAR},
  173. </if>
  174. <if test="signDate != null" >
  175. #{signDate,jdbcType=TIMESTAMP},
  176. </if>
  177. <if test="sortNumber != null" >
  178. #{sortNumber,jdbcType=VARCHAR},
  179. </if>
  180. <if test="startDate != null" >
  181. #{startDate,jdbcType=TIMESTAMP},
  182. </if>
  183. <if test="endDate != null" >
  184. #{endDate,jdbcType=TIMESTAMP},
  185. </if>
  186. <if test="accountUrl != null" >
  187. #{accountUrl,jdbcType=VARCHAR},
  188. </if>
  189. <if test="deletedSign != null" >
  190. #{deletedSign,jdbcType=INTEGER},
  191. </if>
  192. </trim>
  193. </insert>
  194. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.OrgActivityCost" >
  195. update org_activity_cost
  196. <set >
  197. <if test="aid != null" >
  198. aid = #{aid,jdbcType=VARCHAR},
  199. </if>
  200. <if test="uid != null" >
  201. uid = #{uid,jdbcType=VARCHAR},
  202. </if>
  203. <if test="year != null" >
  204. year = #{year,jdbcType=INTEGER},
  205. </if>
  206. <if test="activityNumber != null" >
  207. activity_number = #{activityNumber,jdbcType=VARCHAR},
  208. </if>
  209. <if test="internalLaborCost != null" >
  210. internal_labor_cost = #{internalLaborCost,jdbcType=DECIMAL},
  211. </if>
  212. <if test="internalDirectCost != null" >
  213. internal_direct_cost = #{internalDirectCost,jdbcType=DECIMAL},
  214. </if>
  215. <if test="internalDepreciationCost != null" >
  216. internal_depreciation_cost = #{internalDepreciationCost,jdbcType=DECIMAL},
  217. </if>
  218. <if test="internalAmortizationCost != null" >
  219. internal_amortization_cost = #{internalAmortizationCost,jdbcType=DECIMAL},
  220. </if>
  221. <if test="internalDesignCost != null" >
  222. internal_design_cost = #{internalDesignCost,jdbcType=DECIMAL},
  223. </if>
  224. <if test="internalEquipmentCost != null" >
  225. internal_equipment_cost = #{internalEquipmentCost,jdbcType=DECIMAL},
  226. </if>
  227. <if test="internalOtherCost != null" >
  228. internal_other_cost = #{internalOtherCost,jdbcType=DECIMAL},
  229. </if>
  230. <if test="externalTotalCost != null" >
  231. external_total_cost = #{externalTotalCost,jdbcType=DECIMAL},
  232. </if>
  233. <if test="externalAbroadCost != null" >
  234. external_abroad_cost = #{externalAbroadCost,jdbcType=DECIMAL},
  235. </if>
  236. <if test="enterpriseFiller != null" >
  237. enterprise_filler = #{enterpriseFiller,jdbcType=VARCHAR},
  238. </if>
  239. <if test="signDate != null" >
  240. sign_date = #{signDate,jdbcType=TIMESTAMP},
  241. </if>
  242. <if test="sortNumber != null" >
  243. sort_number = #{sortNumber,jdbcType=VARCHAR},
  244. </if>
  245. <if test="startDate != null" >
  246. start_date = #{startDate,jdbcType=TIMESTAMP},
  247. </if>
  248. <if test="endDate != null" >
  249. end_date = #{endDate,jdbcType=TIMESTAMP},
  250. </if>
  251. <if test="accountUrl != null" >
  252. account_url = #{accountUrl,jdbcType=VARCHAR},
  253. </if>
  254. <if test="deletedSign != null" >
  255. deleted_sign = #{deletedSign,jdbcType=INTEGER},
  256. </if>
  257. </set>
  258. where id = #{id,jdbcType=VARCHAR}
  259. </update>
  260. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.OrgActivityCost" >
  261. update org_activity_cost
  262. set aid = #{aid,jdbcType=VARCHAR},
  263. uid = #{uid,jdbcType=VARCHAR},
  264. year = #{year,jdbcType=INTEGER},
  265. activity_number = #{activityNumber,jdbcType=VARCHAR},
  266. internal_labor_cost = #{internalLaborCost,jdbcType=DECIMAL},
  267. internal_direct_cost = #{internalDirectCost,jdbcType=DECIMAL},
  268. internal_depreciation_cost = #{internalDepreciationCost,jdbcType=DECIMAL},
  269. internal_amortization_cost = #{internalAmortizationCost,jdbcType=DECIMAL},
  270. internal_design_cost = #{internalDesignCost,jdbcType=DECIMAL},
  271. internal_equipment_cost = #{internalEquipmentCost,jdbcType=DECIMAL},
  272. internal_other_cost = #{internalOtherCost,jdbcType=DECIMAL},
  273. external_total_cost = #{externalTotalCost,jdbcType=DECIMAL},
  274. external_abroad_cost = #{externalAbroadCost,jdbcType=DECIMAL},
  275. enterprise_filler = #{enterpriseFiller,jdbcType=VARCHAR},
  276. sign_date = #{signDate,jdbcType=TIMESTAMP},
  277. sort_number = #{sortNumber,jdbcType=VARCHAR},
  278. start_date = #{startDate,jdbcType=TIMESTAMP},
  279. end_date = #{endDate,jdbcType=TIMESTAMP},
  280. account_url = #{accountUrl,jdbcType=VARCHAR},
  281. deleted_sign = #{deletedSign,jdbcType=INTEGER}
  282. where id = #{id,jdbcType=VARCHAR}
  283. </update>
  284. <select id="findOrgActivityCostListByPage" parameterType="java.lang.String" resultMap="BaseResultMap">
  285. select
  286. <include refid="Base_Column_List" />
  287. from org_activity_cost
  288. where deleted_sign = 0
  289. <if test="uid != null">
  290. and uid = #{uid,jdbcType=VARCHAR}
  291. </if>
  292. <if test="year != null">
  293. and year = #{year,jdbcType=INTEGER}
  294. </if>
  295. <if test="activityNumber != null">
  296. and activity_number = #{activityNumber,jdbcType=VARCHAR}
  297. </if>
  298. <if test="activityName != null">
  299. and activity_name= #{activityName,jdbcType=VARCHAR}
  300. </if>
  301. <if test="startDate != null">
  302. and start_date <![CDATA[ > ]]> #{startDate,jdbcType=TIMESTAMP}
  303. </if>
  304. <if test="endDate != null">
  305. and end_date <![CDATA[ < ]]> #{endDate,jdbcType=TIMESTAMP}
  306. </if>
  307. order by start_date
  308. <if test="page_sql != null">
  309. ${page_sql}
  310. </if>
  311. </select>
  312. <select id="findOrgActivityCostCount" resultType="java.lang.Integer" parameterType="String">
  313. select count(1)
  314. from org_activity_cost
  315. where deleted_sign = 0
  316. <if test="uid != null">
  317. and uid = #{uid,jdbcType=VARCHAR}
  318. </if>
  319. <if test="year != null">
  320. and year = #{year,jdbcType=INTEGER}
  321. </if>
  322. <if test="activityNumber != null">
  323. and activity_number = #{activityNumber,jdbcType=VARCHAR}
  324. </if>
  325. <if test="activityName != null">
  326. and activity_name= #{activityName,jdbcType=VARCHAR}
  327. </if>
  328. <if test="startDate != null">
  329. and start_date <![CDATA[ > ]]> #{startDate,jdbcType=TIMESTAMP}
  330. </if>
  331. <if test="endDate != null">
  332. and end_date <![CDATA[ < ]]> #{endDate,jdbcType=TIMESTAMP}
  333. </if>
  334. </select>
  335. <update id="batchDeleteByPrimaryKey" parameterType="java.util.List">
  336. update org_activity_cost set deleted_sign = 1
  337. where id in
  338. <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
  339. #{item}
  340. </foreach>
  341. </update>
  342. <select id="selectOrgActivityCostByAid" parameterType="java.lang.String" resultMap="BaseResultMap">
  343. select
  344. <include refid="Base_Column_List" />
  345. from org_activity_cost
  346. where aid = #{aid,jdbcType=VARCHAR}
  347. </select>
  348. <update id="batchDeleteByAid" parameterType="java.util.List">
  349. update org_activity_cost set deleted_sign = 1
  350. where aid in
  351. <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
  352. #{item}
  353. </foreach>
  354. </update>
  355. <select id="selectOrgActivityCostByUidAndAid" resultMap="BaseResultMap" >
  356. select
  357. <include refid="Base_Column_List" />
  358. from org_activity_cost
  359. where aid = #{0} and uid = #{1} and deleted_sign = 0
  360. </select>
  361. <select id="selectOrgActivityCostByAidAndYear" resultMap="BaseResultMap" >
  362. select
  363. <include refid="Base_Column_List" />
  364. from org_activity_cost
  365. where aid = #{0} and year = #{1} and deleted_sign = 0
  366. </select>
  367. <select id="selectDetailCostByIdAndYear" resultType="com.goafanti.cognizance.bo.OrgActivityDetailCostBo">
  368. select oa.id,
  369. (oac1.internal_labor_cost + oac1.internal_direct_cost + oac1.internal_depreciation_cost + oac1.internal_amortization_cost
  370. + oac1.internal_design_cost + oac1.internal_equipment_cost + oac1.internal_other_cost + oac1.external_total_cost) as firstYearCost,
  371. (oac2.internal_labor_cost + oac2.internal_direct_cost + oac2.internal_depreciation_cost + oac2.internal_amortization_cost
  372. + oac2.internal_design_cost + oac2.internal_equipment_cost + oac2.internal_other_cost + oac2.external_total_cost) as secondYearCost,
  373. (oac3.internal_labor_cost + oac3.internal_direct_cost + oac3.internal_depreciation_cost + oac3.internal_amortization_cost
  374. + oac3.internal_design_cost + oac3.internal_equipment_cost + oac3.internal_other_cost + oac3.external_total_cost) as thirdYearCost
  375. from org_activity oa
  376. LEFT JOIN org_activity_cost oac1 on oa.id = oac1.aid and oac1.year = #{1} and oa.deleted_sign = 0 and oac1.deleted_sign = 0
  377. LEFT JOIN org_activity_cost oac2 on oa.id = oac2.aid and oac2.year = #{1}-1 and oa.deleted_sign = 0 and oac2.deleted_sign = 0
  378. LEFT JOIN org_activity_cost oac3 on oa.id = oac3.aid and oac3.year = #{1}-2 and oa.deleted_sign = 0 and oac3.deleted_sign = 0
  379. where oa.id = #{0}
  380. </select>
  381. </mapper>