ContractBonusDetailMapper.xml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.management.platform.mapper.ContractBonusDetailMapper">
  5. <insert id="batchInsert">
  6. insert into contract_bonus_detail(company_id, user_id, contract, project_id,project_working_time, bonus_type, bonus_value
  7. , total_bonus_value, ym, year, month, create_by, create_time)
  8. VALUES
  9. <foreach collection="toAddList" item="detail" separator=",">
  10. (#{detail.companyId},#{detail.userId},#{detail.contract},#{detail.projectId},#{detail.projectWorkingTime},#{detail.bonusType}
  11. ,#{detail.bonusValue},#{detail.totalBonusValue},#{detail.ym},#{detail.year},null,#{detail.createBy},now())
  12. </foreach>
  13. </insert>
  14. <!-- <resultMap id="contractProjectBonus" type="com.management.platform.entity.vo.ContractProjectBonusVO">-->
  15. <!-- <result property="contract" column="contract"></result>-->
  16. <!-- <collection property="projectBonusList" ofType="com.management.platform.entity.vo.ProjectBonusVO">-->
  17. <!-- <result property="projectId" column="projectId"></result>-->
  18. <!-- <result property="projectName" column="projectName"></result>-->
  19. <!-- <result property="bonus" column="bonus"></result>-->
  20. <!-- <result property="bonusType" column="bonusType"></result>-->
  21. <!-- </collection>-->
  22. <!-- </resultMap>-->
  23. <select id="getExportContractProjectBonus" resultType="com.management.platform.entity.excel.ProjectContractBonusExlceHead">
  24. select tmp1.*,p.project_name as projectName
  25. from
  26. (
  27. select contract,project_id projectId,bonus_type bonusType,
  28. max( case bonus_type when '第一季度奖' then bonus else 0 end) as firstSeasonBonus,
  29. max(case bonus_type when '第二季度奖' then bonus else 0 end )as secondSeasonBonus,
  30. max(case bonus_type when '第三季度奖' then bonus else 0 end) as thirdSeasonBonus,
  31. max(case bonus_type when '第四季度奖' then bonus else 0 end) as forthSeasonBonus,
  32. max(case bonus_type when '上半年奖' then bonus else 0 end) as soonerHalfYearBonus,
  33. max(case bonus_type when '下半年奖' then bonus else 0 end) as latterHalfYearBonus,
  34. max(case bonus_type when '全年奖' then bonus else 0 end) as yearBonus
  35. from (
  36. select contract,bonus_type,project_id,sum(bonus_value) as bonus
  37. from contract_bonus_detail
  38. where year = #{year} and company_id = #{companyId}
  39. group by contract,bonus_type,project_id
  40. )tmp2 group by contract, project_id
  41. )tmp1
  42. left join project p on tmp1.projectId = p.id
  43. order by tmp1.contract
  44. </select>
  45. </mapper>