emis-service/emis-biz/src/main/resources/mapper/EmisBaseMapper.xml
2024-07-03 23:15:35 +08:00

143 lines
6.8 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.xdadan.erp.emis.mapper.EmisBaseMapper">
<resultMap type="BaseEntity" id="EmisBaseResult">
<result property="remark" column="remark" />
<result property="tenantId" column="tenant_id" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="createSite" column="create_site" />
<result property="updateSite" column="update_site" />
<association property="createByName" column="create_by" select="selectEmpNameByUserId" fetchType="lazy"/>
<association property="updateByName" column="update_by" select="selectEmpNameByUserId" fetchType="lazy"/>
<association property="createSiteName" column="create_site" select="selectSiteNameByCode" fetchType="lazy"/>
<association property="updateSiteName" column="update_site" select="selectSiteNameByCode" fetchType="lazy"/>
</resultMap>
<!-- 查询区域名称 -->
<select id="selectAreaNameById" parameterType="Long" resultType="string">
select a.name from emis_country_area a where a.id = #{id} limit 1
</select>
<!-- 查询国家名称 -->
<select id="selectCountryNameByCode" parameterType="String" resultType="string">
select a.name from emis_country a where a.code = #{code} limit 1
</select>
<!-- 查询国家名称(多个) -->
<select id="selectGroupCountryNameByCode" parameterType="String" resultType="string">
select GROUP_CONCAT(name) from emis_country where FIND_IN_SET(`code`,#{code})
</select>
<!-- 查询区域名称 -->
<select id="selectRegionNameByCode" parameterType="String" resultType="string">
select a.region_name from emis_region a where a.region_code = #{code} limit 1
</select>
<!-- 查询站点名称 -->
<select id="selectSiteNameByCode" parameterType="String" resultType="string">
select a.site_name from emis_site a where a.site_code = #{code} limit 1
</select>
<!-- 查询多个站点名称 -->
<select id="selectGroupSiteNameByCode" parameterType="String" resultType="string">
select group_concat(a.site_name) as site_name from emis_site a where a.del_flag='0' and FIND_IN_SET(a.site_code, #{code}) limit 1
</select>
<!-- 查询国家区域名称 -->
<select id="selectCountryAreaNameById" parameterType="long" resultType="string">
select a.name from emis_country_area a where a.id = #{id} limit 1
</select>
<!-- 查询线路名称 -->
<select id="selectLineNameByCode" parameterType="String" resultType="string">
select a.line_name from emis_trans_line a where a.line_code = #{code} limit 1
</select>
<!-- 查询多个产品名称 -->
<select id="selectProdNameByCode" parameterType="String" resultType="string">
select group_concat(a.prod_name) from emis_trans_product a where FIND_IN_SET(a.prod_code, #{code}) limit 1
</select>
<!-- 根据产品查线路名称 -->
<select id="selectLineNameByProdCode" parameterType="String" resultType="string">
select a.line_name from emis_trans_line a,emis_trans_product b where a.line_code=b.trans_line_code and b.prod_code = #{code} limit 1
</select>
<!-- 根据产品查线路编号 -->
<select id="selectLineProdByProdCode" parameterType="string" resultType="string">
select trans_line_code from emis_trans_product a where del_flag='0' and prod_code=#{code} limit 1
</select>
<!-- 根据线路获取出发国家名称-->
<select id="selectFromCountryNameByLineCode" parameterType="String" resultType="string">
select a.name from emis_country a,emis_trans_line b where a.del_flag='0' and b.del_flag='0' and a.code=b.from_country and b.line_code = #{code} limit 1
</select>
<!-- 根据线路获取目的国家名称 -->
<select id="selectDestCountryNameByLineCode" parameterType="String" resultType="string">
select a.name from emis_country a,emis_trans_line b where a.del_flag='0' and b.del_flag='0' and a.code=b.country and b.line_code = #{code} limit 1
</select>
<!--目的地名称-->
<select id="selectDestNameByCode" parameterType="String" resultType="string">
select a.dest_name from emis_destination a where a.dest_code = #{code} and a.del_flag='0' limit 1
</select>
<!-- 查询客户名称(code) -->
<select id="selectCustomerNameByCode" parameterType="String" resultType="string">
select a.customer_name from emis_customer_user a where a.customer_code = #{code} limit 1
</select>
<!-- 查询月结客户名称(月结编码) -->
<select id="selectCustNameByCustNo" parameterType="String" resultType="string">
select a.customer_name from emis_customer_user a where a.monthly_pay_code = #{code} limit 1
</select>
<!-- 查询员工(emp_code) -->
<select id="selectEmpNameByCode" parameterType="String" resultType="string">
select a.emp_name from sys_user a where a.emp_code = #{code} limit 1
</select>
<!-- 查询员工部门(dept_name) -->
<select id="selectDeptNameByEmpCode" parameterType="String" resultType="string">
select b.dept_name from sys_user a,sys_dept b where a.dept_id=b.dept_id and a.emp_code = #{code} limit 1
</select>
<!-- 查询员工(user_id) -->
<select id="selectEmpNameByUserId" parameterType="String" resultType="string">
select a.emp_name from sys_user a where a.user_id = #{id} limit 1
</select>
<!-- 查询品牌名称-->
<select id="selectBrandNameByCode" parameterType="String" resultType="string">
select a.name from emis_brand a where a.code = #{code} limit 1
</select>
<!-- 查询问题件类型原型 -->
<select id="selectProblemTypeNameById" parameterType="int" resultType="string">
select a.type_name from emis_problem_type a where a.id = #{id} limit 1
</select>
<!-- 查询费用结算类型 -->
<select id="selectSettleTypeNameByCode" parameterType="string" resultType="string">
select a.settle_name from emis_settle_type a where a.settle_type = #{settleType} limit 1
</select>
<!-- 查询运单调整类型 -->
<select id="selectAjustTypeNameByCode" parameterType="string" resultType="string">
select group_concat(a.type_name) as type_name from emis_waybill_ajust_type a where a.del_flag='0' and FIND_IN_SET(a.type_code, #{typeCode}) limit 1
</select>
</mapper>