weaver-hrm-salary/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper...

240 lines
7.5 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO">
<result column="id" property="id"/>
<result column="primary_id" property="primaryId"/>
<result column="insurance_id" property="insuranceId"/>
<result column="effective_time" property="effectiveTime"/>
<result column="expiration_time" property="expirationTime"/>
<result column="is_payment" property="isPayment"/>
<result column="payment_scope" property="paymentScope"/>
<result column="upper_limit" property="upperLimit"/>
<result column="lower_limit" property="lowerLimit"/>
<result column="payment_proportion" property="paymentProportion"/>
<result column="fixed_cost" property="fixedCost"/>
<result column="valid_num" property="validNum"/>
<result column="rentention_rule" property="rententionRule"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="tenant_key" property="tenantKey"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t.id
, t.primary_id
, t.insurance_id
, t.effective_time
, t.expiration_time
, t.is_payment
, t.payment_scope
, t.upper_limit
, t.lower_limit
, t.payment_proportion
, t.fixed_cost
, t.valid_num
, t.rentention_rule
, t.create_time
, t.update_time
, t.creator
, t.delete_type
, t.tenant_key
</sql>
<sql id="formColumns">
t.id
, t.primary_id
, t.insurance_id
, t.is_payment
, t.payment_scope
, t.payment_proportion
, t.fixed_cost
, t.valid_num
, t.rentention_rule
, t.create_time
, t.update_time
, t.creator
, t.delete_type
, t.tenant_key
</sql>
<select id="queryListBySchemeId" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_scheme_detail t
WHERE t.primary_id = #{schemeId} AND delete_type = 0
</select>
<!-- 根据主键获取单条记录 -->
<select id="listByPrimaryId" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_scheme_detail t
WHERE t.primary_id = #{primaryId} AND delete_type = 0
</select>
<sql id="paramSql">
<if test="primaryId != null and primaryId != ''">
AND primary_id = #{primaryId}
</if>
</sql>
<select id="getByPPI" resultMap="BaseResultMap" >
SELECT
<include refid="baseColumns"/>
FROM hrsa_scheme_detail t
WHERE t.insurance_id = #{insuranceId}
AND t.payment_scope = #{paymentScope}
AND t.primary_id = #{primaryId}
AND delete_type = 0
</select>
<!-- 插入全部字段 -->
<insert id="insert" parameterType="com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO"
keyProperty="id" keyColumn="id" useGeneratedKeys="true"
>
INSERT INTO hrsa_scheme_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
primary_id,
insurance_id,
effective_time,
expiration_time,
is_payment,
payment_scope,
upper_limit,
lower_limit,
payment_proportion,
fixed_cost,
valid_num,
rentention_rule,
create_time,
update_time,
creator,
delete_type,
tenant_key,
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
#{primaryId},
#{insuranceId},
#{effectiveTime},
#{expirationTime},
#{isPayment},
#{paymentScope},
#{upperLimit},
#{lowerLimit},
#{paymentProportion},
#{fixedCost},
#{validNum},
#{rententionRule},
#{createTime},
#{updateTime},
#{creator},
#{deleteType},
#{tenantKey},
</trim>
</insert>
<insert id="insert" parameterType="com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO" databaseId="oracle"
>
<selectKey keyProperty="id" resultType="long" order="AFTER">
select hrsa_scheme_detail_id.currval from dual
</selectKey>
INSERT INTO hrsa_scheme_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
primary_id,
insurance_id,
effective_time,
expiration_time,
is_payment,
payment_scope,
upper_limit,
lower_limit,
payment_proportion,
fixed_cost,
valid_num,
rentention_rule,
create_time,
update_time,
creator,
delete_type,
tenant_key,
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
#{primaryId},
#{insuranceId},
#{effectiveTime},
#{expirationTime},
#{isPayment},
#{paymentScope},
#{upperLimit},
#{lowerLimit},
#{paymentProportion},
#{fixedCost},
#{validNum},
#{rententionRule},
#{createTime},
#{updateTime},
#{creator},
#{deleteType},
#{tenantKey},
</trim>
</insert>
<delete id="batchDeleteByPrimaryIds">
UPDATE hrsa_scheme_detail
SET delete_type = 1
WHERE delete_type = 0
AND primary_id IN
<foreach collection="primaryIds" open="(" item="primaryIds" separator="," close=")">
#{primaryIds}
</foreach>
</delete>
<!-- 根据险种id和是否缴费查询社保方案明细表 -->
<select id="queryListByInsuranceIdIsPayment" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_scheme_detail t
WHERE t.insurance_id = #{insuranceId} AND t.is_payment = #{isPayment} AND delete_type = 0
</select>
<select id="queryListByPrimaryIdIsPayment" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_scheme_detail t,hrsa_insurance_category b
WHERE t.insurance_id = b.id
AND t.primary_id = #{primaryId}
AND t.is_payment = #{isPayment}
AND b.welfare_type = #{welfareType}
AND t.delete_type = 0
</select>
<select id="queryInsuranceSchemeDetailList" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_scheme_detail t
WHERE t.primary_id = #{primaryId}
AND t.is_payment = #{isPayment}
AND delete_type = 0
</select>
<update id="deleteByIds">
UPDATE
hrsa_scheme_detail
SET delete_type = 1
WHERE primary_id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>