mybatis的接口映射语法

<?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="cn.eeka.productwms.dao.biz.ProductInBoundDao" >
<resultMap id="BaseResultMap" type="cn.eeka.productwms.entity.biz.ProductInBound" >
<id column="productInBoundId" property="productInBoundId" jdbcType="VARCHAR" />
<result column="productInBoundCode" property="productInBoundCode" jdbcType="VARCHAR" />
<result column="factoryCode" property="factoryCode" jdbcType="VARCHAR" />
<result column="factoryName" property="factoryName" jdbcType="VARCHAR" />
<result column="customerCode" property="customerCode" jdbcType="VARCHAR" />
<result column="customerName" property="customerName" jdbcType="VARCHAR" />
<result column="storageAreaId" property="storageAreaId" jdbcType="VARCHAR" />
<result column="documentDate" property="documentDate" jdbcType="TIMESTAMP" />
<result column="originDocCode" property="originDocCode" jdbcType="VARCHAR" />
<result column="referenceCode" property="referenceCode" jdbcType="VARCHAR" />
<result column="orderTotal" property="orderTotal" jdbcType="DECIMAL" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="createUserId" property="createUserId" jdbcType="VARCHAR" />
<result column="createUserId" property="createUserId" jdbcType="VARCHAR" />
<result column="createDate" property="createDate" jdbcType="TIMESTAMP" />
<result column="updateDate" property="updateDate" jdbcType="TIMESTAMP" />
<result column="postDate" property="postDate" jdbcType="TIMESTAMP" />
<result column="version" property="version" jdbcType="INTEGER" />
</resultMap>

<sql id="Base_Column_List" >
productInBoundId, productInBoundCode, factoryCode, factoryName, customerCode, customerName,
storageAreaId, documentDate, originDocCode, referenceCode, orderTotal,
status, createUserId, updateUserId, createDate, updateDate, version
</sql>

<insert id="insert" parameterType="cn.eeka.productwms.entity.biz.ProductInBound" >
insert into PM_ProductInBound (productInBoundId, productInBoundCode,
factoryCode, factoryName, customerCode,
customerName, storageAreaId, documentDate,
originDocCode, referenceCode, orderTotal, status,
createUserId, updateUserId, createDate,
updateDate, postDate, version)
values (#{productInBoundId,jdbcType=VARCHAR}, #{productInBoundCode,jdbcType=VARCHAR},
#{factoryCode,jdbcType=VARCHAR}, #{factoryName,jdbcType=VARCHAR}, #{customerCode,jdbcType=VARCHAR},
#{customerName,jdbcType=VARCHAR}, #{storageAreaId}, #{documentDate,jdbcType=TIMESTAMP}, #{originDocCode,jdbcType=VARCHAR},
#{referenceCode,jdbcType=VARCHAR}, #{orderTotal,jdbcType=DECIMAL}, #{status,jdbcType=INTEGER},
#{createUserId,jdbcType=VARCHAR}, #{updateUserId,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP},
#{updateDate,jdbcType=TIMESTAMP}, #{postDate}, #{version,jdbcType=INTEGER})
</insert>

<update id="updateByPrimaryKey" parameterType="cn.eeka.productwms.entity.biz.ProductInBound" >
update PM_ProductInBound
<set >
<if test="productInBoundCode != null" >
productInBoundCode = #{productInBoundCode,jdbcType=VARCHAR},
</if>
<if test="factoryCode != null" >
factoryCode = #{factoryCode,jdbcType=VARCHAR},
</if>
<if test="factoryName != null" >
factoryName = #{factoryName,jdbcType=VARCHAR},
</if>
</set>
where productInBoundId = #{productInBoundId,jdbcType=VARCHAR}
</update>

<update id="updateById" parameterType="java.util.HashMap">
update PM_ProductInBound
<set >
<if test="status != null" >
status = #{status},
</if>
<if test="updateUserId != null" >
updateUserId = #{updateUserId},
</if>
<if test="updateDate != null" >
updateDate = #{updateDate},
</if>
<if test="version != null" >
version = #{version} + 1
</if>
</set>
where productInBoundId = #{productInBoundId}
and version = #{version}
</update>

<select id="listByPagePC" parameterType="java.util.HashMap" resultMap="BaseResultMap" >
SELECT pro.* FROM PM_ProductInBound pro
<where>
<include refid="condition_where_clause" />
</where>

<!--这里是后台动态排序(排序的字段不固定)-->
<if test="orderByCondition != null and orderByCondition != ''">
        ORDER BY ${orderByCondition} DESC
</if>

<if test="offset != null">
  limit #{offset},#{limit}
</if>

</select>

<select id="getCountByCondition" parameterType="java.util.HashMap" resultType="java.lang.Integer">
SELECT count(1) FROM PM_ProductInBound pro
<where>
<include refid="condition_where_clause" />
</where>
</select>

<sql id="condition_where_clause">
<if test="productInBoundCode != null and productInBoundCode != ''">
<bind name="productInBoundCodeCon" value="'%' + productInBoundCode + '%'" />
and pro.productInBoundCode LIKE #{productInBoundCodeCon}
</if>

<if test="referenceCode != null and referenceCode != ''">
  <bind name="referenceCodeCon" value="'%' + referenceCode + '%'" />
  and pro.referenceCode  LIKE #{referenceCodeCon}
</if>

<if test="storageAreaIds != null and storageAreaIds.size > 0">
  AND pro.storageAreaId IN
  <foreach collection="storageAreaIds" item="storageAreaId" index="index" open="("  separator="," close=")">
    #{storageAreaId}
  </foreach>
</if>

<if test="startDate != null and startDate != ''">
  <![CDATA[AND pro.documentDate >= #{startDate}]]>
</if>
<if test="endDate != null and endDate != ''">
  <![CDATA[AND pro.documentDate <= #{endDate}]]>
</if>

</sql>

</mapper>

转载于:https://blog.51cto.com/9381188/2068469

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
帮我优化一下这段代码(select uuid() as id , a.customerCode as customerCode , a.customerName as customerName , a.unifiedSocialCreditCode as unifiedSocialCreditCode , a.firstInsuranceCode as firstInsuranceCode , a.firstInsuranceName as firstInsuranceName , a.firstRiskCode as firstRiskCode , a.firstRiskName as firstRiskName , a.secondRiskCode as secondRiskCode, a.secondRiskName as secondRiskName, cast(a.secondRiskBasicScore as DECIMAL(6,2)) as secondRiskBasicScore , cast(a.secondRiskBasicScore as DECIMAL(6,2)) as secondRiskScore , to_date(date_add(now(),-1)) as createDate from ( select a.customerCode, a.customerName, a.unifiedSocialCreditCode,'ALL' AS firstInsuranceCode,'全险种' AS firstInsuranceName,c.firstRiskCode,c.firstRiskName,c.secondRiskCode,c.secondRiskName, sum((case when (a.POLICYSTATUS = 'A') then a.sumAssured when (a.POLICYSTATUS = 'B') then (a.PAYOUT+a.OUTSTANDING) else a.sumAssured end) / b.AllcustomersumAssured * c.secondRiskScore) as secondRiskBasicScore from ccic_fkyjrisk.FocusCustomerPolicyData a join ccic_fkyjrisk_orig.InsuranceProductGroup d on d.scoreCardType='0' and a.insuranceCode = d.insuranceCode join ccic_fkyjrisk.PolicyRiskSecondScore c on a.customerCode = c.customerCode and a.policycode=c.policycode and firstRiskCode = '002' join ccic_fkyjrisk.TargetcustomerRanking b on b.firstInsuranceCode ='ALL' and a.customerCode = b.customerCode where (case when (a.POLICYSTATUS = 'A') then a.sumAssured when (a.POLICYSTATUS = 'B') then (a.PAYOUT+a.OUTSTANDING) else a.sumAssured end)>0 and length(nvl(cast((case when (a.POLICYSTATUS = 'A') then a.sumAssured when (a.POLICYSTATUS = 'B') then (a.PAYOUT+a.OUTSTANDING) else a.sumAssured end) as string),''))>0 and (a.firstInsuranceName!='健康险' and a.insuranceCode not in('5IE','5VA','5XA','5XC','5XE','EFD','EFM','EFW','EGB','EGM', 'EGZ','EIA','EIB','EIE','EIF','EIH','EIZ','ERQ','ERW','ERY','ERZ','ESZ','ETB','ETC', 'ETR','ETX','ETZ','EVA','EVB','EXA','EXB','EXE','EYM','4DJ','EGD','5GD','ZCJ','ZCF') and a.secondInsuranceName not in('家庭财产保险','农业保险') and a.insuranceCode not like 'YEE%' and a.insuranceCode not like 'YAC%') group by a.customerCode, a.customerName, a.unifiedSocialCreditCode,c.firstRiskCode,c.firstRiskName,c.secondRiskCode,c.secondRiskName) a;)
06-08

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值