ganzi-api/inventory-dao/src/main/resources/mapper/ent/BaseInClassMapper.xml

489 lines
18 KiB
XML
Raw Normal View History

2022-09-16 15:07:17 +08:00
<?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.rzyc.mapper.ent.BaseInClassMapper">
<resultMap id="BaseResultMap" type="com.rzyc.model.ent.BaseInClass">
<id column="BaseInClassId" jdbcType="VARCHAR" property="baseinclassid" />
<result column="ClassCode" jdbcType="VARCHAR" property="classcode" />
<result column="IndustryClassName" jdbcType="VARCHAR" property="industryclassname" />
<result column="SuperInId" jdbcType="VARCHAR" property="superinid" />
<result column="SuperInCode" jdbcType="VARCHAR" property="superincode" />
<result column="SysLevel" jdbcType="INTEGER" property="syslevel" />
<result column="SortId" jdbcType="INTEGER" property="sortid" />
<result column="in_type" jdbcType="INTEGER" property="inType" />
<result column="CreatedOn" jdbcType="TIMESTAMP" property="createdon" />
<result column="CreatedBy" jdbcType="VARCHAR" property="createdby" />
<result column="ModifiedOn" jdbcType="TIMESTAMP" property="modifiedon" />
<result column="ModifiedBy" jdbcType="VARCHAR" property="modifiedby" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
BaseInClassId, ClassCode, IndustryClassName, SuperInId, SuperInCode, SysLevel, SortId,in_type,
CreatedOn, CreatedBy, ModifiedOn, ModifiedBy
</sql>
<select id="selectByExample" parameterType="com.rzyc.model.ent.BaseInClassExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from BaseInClass
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="limit != null">
<if test="offset != null">
limit ${offset}, ${limit}
</if>
<if test="offset == null">
limit ${limit}
</if>
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from BaseInClass
where BaseInClassId = #{baseinclassid,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from BaseInClass
where BaseInClassId = #{baseinclassid,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.rzyc.model.ent.BaseInClassExample">
delete from BaseInClass
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.rzyc.model.ent.BaseInClass">
insert into BaseInClass (BaseInClassId, ClassCode, IndustryClassName,work_type,
SuperInId, SuperInCode, SysLevel,
SortId, in_type,CreatedOn, CreatedBy,
ModifiedOn, ModifiedBy)
values (#{baseinclassid,jdbcType=VARCHAR}, #{classcode,jdbcType=VARCHAR},
#{industryclassname,jdbcType=VARCHAR},
#{workType,jdbcType=VARCHAR},
#{superinid,jdbcType=VARCHAR}, #{superincode,jdbcType=VARCHAR}, #{syslevel,jdbcType=INTEGER},
#{sortid,jdbcType=INTEGER},
#{inType,jdbcType=INTEGER},
#{createdon,jdbcType=TIMESTAMP}, #{createdby,jdbcType=VARCHAR},
#{modifiedon,jdbcType=TIMESTAMP}, #{modifiedby,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.rzyc.model.ent.BaseInClass">
insert into BaseInClass
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="baseinclassid != null">
BaseInClassId,
</if>
<if test="classcode != null">
ClassCode,
</if>
<if test="industryclassname != null">
IndustryClassName,
</if>
<if test="superinid != null">
SuperInId,
</if>
<if test="superincode != null">
SuperInCode,
</if>
<if test="syslevel != null">
SysLevel,
</if>
<if test="sortid != null">
SortId,
</if>
<if test="inType != null">
in_type,
</if>
<if test="createdon != null">
CreatedOn,
</if>
<if test="createdby != null">
CreatedBy,
</if>
<if test="modifiedon != null">
ModifiedOn,
</if>
<if test="modifiedby != null">
ModifiedBy,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="baseinclassid != null">
#{baseinclassid,jdbcType=VARCHAR},
</if>
<if test="classcode != null">
#{classcode,jdbcType=VARCHAR},
</if>
<if test="industryclassname != null">
#{industryclassname,jdbcType=VARCHAR},
</if>
<if test="superinid != null">
#{superinid,jdbcType=VARCHAR},
</if>
<if test="superincode != null">
#{superincode,jdbcType=VARCHAR},
</if>
<if test="syslevel != null">
#{syslevel,jdbcType=INTEGER},
</if>
<if test="sortid != null">
#{sortid,jdbcType=INTEGER},
</if>
<if test="inType != null">
#{inType,jdbcType=INTEGER},
</if>
<if test="createdon != null">
#{createdon,jdbcType=TIMESTAMP},
</if>
<if test="createdby != null">
#{createdby,jdbcType=VARCHAR},
</if>
<if test="modifiedon != null">
#{modifiedon,jdbcType=TIMESTAMP},
</if>
<if test="modifiedby != null">
#{modifiedby,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.rzyc.model.ent.BaseInClassExample" resultType="java.lang.Long">
select count(*) from BaseInClass
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update BaseInClass
<set>
<if test="record.baseinclassid != null">
BaseInClassId = #{record.baseinclassid,jdbcType=VARCHAR},
</if>
<if test="record.classcode != null">
ClassCode = #{record.classcode,jdbcType=VARCHAR},
</if>
<if test="record.industryclassname != null">
IndustryClassName = #{record.industryclassname,jdbcType=VARCHAR},
</if>
<if test="record.superinid != null">
SuperInId = #{record.superinid,jdbcType=VARCHAR},
</if>
<if test="record.superincode != null">
SuperInCode = #{record.superincode,jdbcType=VARCHAR},
</if>
<if test="record.syslevel != null">
SysLevel = #{record.syslevel,jdbcType=INTEGER},
</if>
<if test="record.sortid != null">
SortId = #{record.sortid,jdbcType=INTEGER},
</if>
<if test="record.inType != null">
in_type = #{record.inType,jdbcType=INTEGER},
</if>
<if test="record.createdon != null">
CreatedOn = #{record.createdon,jdbcType=TIMESTAMP},
</if>
<if test="record.createdby != null">
CreatedBy = #{record.createdby,jdbcType=VARCHAR},
</if>
<if test="record.modifiedon != null">
ModifiedOn = #{record.modifiedon,jdbcType=TIMESTAMP},
</if>
<if test="record.modifiedby != null">
ModifiedBy = #{record.modifiedby,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update BaseInClass
set BaseInClassId = #{record.baseinclassid,jdbcType=VARCHAR},
ClassCode = #{record.classcode,jdbcType=VARCHAR},
IndustryClassName = #{record.industryclassname,jdbcType=VARCHAR},
SuperInId = #{record.superinid,jdbcType=VARCHAR},
SuperInCode = #{record.superincode,jdbcType=VARCHAR},
SysLevel = #{record.syslevel,jdbcType=INTEGER},
SortId = #{record.sortid,jdbcType=INTEGER},
in_type = #{record.inType,jdbcType=INTEGER},
CreatedOn = #{record.createdon,jdbcType=TIMESTAMP},
CreatedBy = #{record.createdby,jdbcType=VARCHAR},
ModifiedOn = #{record.modifiedon,jdbcType=TIMESTAMP},
ModifiedBy = #{record.modifiedby,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.rzyc.model.ent.BaseInClass">
update BaseInClass
<set>
<if test="classcode != null">
ClassCode = #{classcode,jdbcType=VARCHAR},
</if>
<if test="industryclassname != null">
IndustryClassName = #{industryclassname,jdbcType=VARCHAR},
</if>
<if test="superinid != null">
SuperInId = #{superinid,jdbcType=VARCHAR},
</if>
<if test="superincode != null">
SuperInCode = #{superincode,jdbcType=VARCHAR},
</if>
<if test="syslevel != null">
SysLevel = #{syslevel,jdbcType=INTEGER},
</if>
<if test="sortid != null">
SortId = #{sortid,jdbcType=INTEGER},
</if>
<if test="inType != null">
in_type = #{inType,jdbcType=INTEGER},
</if>
<if test="createdon != null">
CreatedOn = #{createdon,jdbcType=TIMESTAMP},
</if>
<if test="createdby != null">
CreatedBy = #{createdby,jdbcType=VARCHAR},
</if>
<if test="modifiedon != null">
ModifiedOn = #{modifiedon,jdbcType=TIMESTAMP},
</if>
<if test="modifiedby != null">
ModifiedBy = #{modifiedby,jdbcType=VARCHAR},
</if>
</set>
where BaseInClassId = #{baseinclassid,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.rzyc.model.ent.BaseInClass">
update BaseInClass
set ClassCode = #{classcode,jdbcType=VARCHAR},
IndustryClassName = #{industryclassname,jdbcType=VARCHAR},
SuperInId = #{superinid,jdbcType=VARCHAR},
SuperInCode = #{superincode,jdbcType=VARCHAR},
SysLevel = #{syslevel,jdbcType=INTEGER},
SortId = #{sortid,jdbcType=INTEGER},
in_type = #{inType,jdbcType=INTEGER},
CreatedOn = #{createdon,jdbcType=TIMESTAMP},
CreatedBy = #{createdby,jdbcType=VARCHAR},
ModifiedOn = #{modifiedon,jdbcType=TIMESTAMP},
ModifiedBy = #{modifiedby,jdbcType=VARCHAR}
where BaseInClassId = #{baseinclassid,jdbcType=VARCHAR}
</update>
<!--企业行业类别-->
<select id="findByName" resultMap="BaseResultMap">
SELECT * FROM `BaseInClass` bc WHERE bc.IndustryClassName LIKE #{name}
ORDER BY bc.SysLevel ASC
</select>
<resultMap id="BaseResultMapTree" type="com.rzyc.bean.TreeModel">
<id column="BaseInClassId" jdbcType="VARCHAR" property="id" />
<result column="ClassCode" jdbcType="VARCHAR" property="code" />
<result column="IndustryClassName" jdbcType="VARCHAR" property="label" />
<collection property="children" ofType="com.rzyc.bean.TreeModel" column="id">
<id column="BaseInClassIdChild" jdbcType="VARCHAR" property="id" />
<result column="ClassCodeChild" jdbcType="VARCHAR" property="code" />
<result column="IndustryClassNameChild" jdbcType="VARCHAR" property="label" />
<result column="SuperInIdChild" jdbcType="VARCHAR" property="parentId" />
</collection>
</resultMap>
<select id="findAllTree" resultMap="BaseResultMapTree">
select t1.*,
t2.BaseInClassId BaseInClassIdChild,t2.ClassCode ClassCodeChild,
t2.IndustryClassName IndustryClassNameChild,t2.SuperInId as SuperInIdChild
2022-09-30 15:30:10 +08:00
from BaseInClass t1 LEFT join BaseInClass t2 on t1.BaseInClassId = t2.SuperInId
2022-09-16 15:07:17 +08:00
</select>
2023-02-16 15:39:00 +08:00
<!--行业树形结构-->
<resultMap id="InClassMap" type="com.rzyc.bean.TreeModel">
<id column="BaseInClassId" jdbcType="VARCHAR" property="id" />
<result column="ClassCode" jdbcType="VARCHAR" property="code" />
<result column="IndustryClassName" jdbcType="VARCHAR" property="label" />
<result column="SuperInId" jdbcType="VARCHAR" property="parentId" />
2023-03-31 11:45:34 +08:00
<result column="unit_trade_id" jdbcType="VARCHAR" property="unitTradeId" />
2023-02-16 15:39:00 +08:00
</resultMap>
<!--行业树形结构-->
<select id="findInClass" resultMap="InClassMap">
select t1.*
from BaseInClass t1
</select>
2023-03-31 11:45:34 +08:00
<!--单位行业监管信息-->
<select id="unitTradeList" resultMap="InClassMap">
SELECT ut.`unit_trade_id`, bc.*
FROM `baseinclass` bc
LEFT JOIN `sys_unit_trade` ut
ON bc.`BaseInClassId` = ut.`in_class_id`
AND ut.`unit_id` = #{unitId}
</select>
2022-09-16 15:07:17 +08:00
<select id="findAll" resultMap="BaseResultMap">
2023-02-16 15:39:00 +08:00
select * from BaseInClass bc
2022-09-16 15:07:17 +08:00
</select>
<select id="findByInType" resultMap="BaseResultMap">
select * from BaseInClass bc
where 1 = 1
<if test="null != inType">
and bc.in_type = #{inType}
</if>
</select>
<!--行业列表-->
<resultMap id="IndustryBaseResultMap" type="com.rzyc.model.ent.BaseInClass">
<id column="BaseInClassId" jdbcType="VARCHAR" property="baseinclassid" />
<result column="ClassCode" jdbcType="VARCHAR" property="classcode" />
<result column="IndustryClassName" jdbcType="VARCHAR" property="industryclassname" />
<result column="work_type" jdbcType="VARCHAR" property="workType" />
<result column="SuperInId" jdbcType="VARCHAR" property="superinid" />
<result column="superName" jdbcType="VARCHAR" property="superName" />
<result column="SuperInCode" jdbcType="VARCHAR" property="superincode" />
<result column="SysLevel" jdbcType="INTEGER" property="syslevel" />
<result column="SortId" jdbcType="INTEGER" property="sortid" />
<result column="in_type" jdbcType="INTEGER" property="inType" />
<result column="CreatedOn" jdbcType="TIMESTAMP" property="createdon" />
<result column="CreatedBy" jdbcType="VARCHAR" property="createdby" />
<result column="ModifiedOn" jdbcType="TIMESTAMP" property="modifiedon" />
<result column="ModifiedBy" jdbcType="VARCHAR" property="modifiedby" />
</resultMap>
<!--行业列表-->
<select id="industryPage" resultMap="IndustryBaseResultMap">
SELECT sp.`IndustryClassName` superName,bc.*
FROM `BaseInClass` bc
LEFT JOIN BaseInClass sp ON bc.`SuperInId` = sp.`BaseInClassId`
WHERE bc.`IndustryClassName` LIKE #{condition}
2023-02-16 10:43:42 +08:00
ORDER BY bc.SysLevel ASC,bc.SuperInId DESC, bc.`IndustryClassName` ASC
2022-09-16 15:07:17 +08:00
</select>
<!--通过父级id查询-->
<select id="findByParentId" resultMap="IndustryBaseResultMap">
SELECT * FROM `BaseInClass` bc
WHERE bc.in_type = #{inType}
<if test="null != baseinclassid and '' != baseinclassid">
AND bc.`SuperInId` = #{baseinclassid}
</if>
<if test="null == baseinclassid or '' == baseinclassid">
AND bc.`SuperInId` IS NULL
</if>
ORDER BY bc.`ClassCode` ASC;
</select>
<!--修改行业-->
<update id="changeInClass">
update BaseInClass
set ClassCode = #{record.classcode,jdbcType=VARCHAR},
IndustryClassName = #{record.industryclassname,jdbcType=VARCHAR},
work_type = #{record.workType,jdbcType=VARCHAR},
SuperInId = #{record.superinid,jdbcType=VARCHAR},
ModifiedOn = #{record.modifiedon,jdbcType=TIMESTAMP},
ModifiedBy = #{record.modifiedby,jdbcType=VARCHAR}
where BaseInClassId = #{record.baseinclassid,jdbcType=VARCHAR}
</update>
<!--最小工作单元行业-->
<select id="findByNameAndType" resultMap="BaseResultMap">
SELECT * FROM `BaseInClass` bc WHERE bc.`IndustryClassName` = #{industryClassName} AND bc.`in_type` = 2
</select>
<!--多个行业-->
<select id="findInId" resultMap="BaseResultMap">
SELECT * FROM baseinclass bc
WHERE bc.`BaseInClassId`
IN
<if test="ids.size() > 0">
<foreach collection="ids" item="id" separator="," close=")" open="(">
#{id}
</foreach>
</if>
</select>
<!--普通行业-->
<select id="selectByName" resultMap="BaseResultMap">
SELECT * FROM `BaseInClass` bc
WHERE bc.`IndustryClassName` = #{industryClassName}
AND bc.`in_type` = 1 limit 1
</select>
<!--普通行业-->
<select id="workIndustry" resultMap="BaseResultMap">
SELECT * FROM `BaseInClass` bc
WHERE bc.`in_type` = 2 AND bc.`SuperInId` IS NOT NULL AND bc.`SuperInId` != ''
</select>
<select id="selectBaseInClassByName" resultMap="BaseResultMap">
SELECT * FROM `BaseInClass` bc
WHERE bc.`IndustryClassName` = #{industryClassName}
limit 1
</select>
2022-09-16 15:07:17 +08:00
</mapper>