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

420 lines
15 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.MinWorkUnitMapper">
<resultMap id="BaseResultMap" type="com.rzyc.model.ent.MinWorkUnit">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="title" jdbcType="VARCHAR" property="title" />
<result column="dangerinfo" jdbcType="VARCHAR" property="dangerinfo" />
<result column="EntName" jdbcType="VARCHAR" property="entName" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="charge_person" jdbcType="VARCHAR" property="chargePerson" />
<result column="contact_phone" jdbcType="VARCHAR" property="contactPhone" />
<result column="files" jdbcType="VARCHAR" property="files" />
<result column="del_state" jdbcType="INTEGER" property="delState" />
<result column="parent_id" jdbcType="VARCHAR" property="parentId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="qr_code" jdbcType="VARCHAR" property="qrCode" />
<result column="min_category" jdbcType="VARCHAR" property="minCategory" />
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
<result column="modify_by" jdbcType="VARCHAR" property="modifyBy" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="minCategoryName" jdbcType="VARCHAR" property="minCategoryName"/>
</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">
id, title, remark, charge_person, contact_phone, files, del_state, parent_id, create_time,
qr_code, min_category, modify_time, modify_by, create_by
</sql>
<select id="selectByExample" parameterType="com.rzyc.model.ent.MinWorkUnitExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from min_work_unit
<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 min_work_unit
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from min_work_unit
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.rzyc.model.ent.MinWorkUnitExample">
delete from min_work_unit
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.rzyc.model.ent.MinWorkUnit">
insert into min_work_unit (id, title, remark,
charge_person, contact_phone, files,
del_state, parent_id, create_time,
qr_code, min_category, modify_time,
modify_by, create_by)
values (#{id,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
#{chargePerson,jdbcType=VARCHAR}, #{contactPhone,jdbcType=VARCHAR}, #{files,jdbcType=VARCHAR},
#{delState,jdbcType=INTEGER}, #{parentId,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{qrCode,jdbcType=VARCHAR}, #{minCategory,jdbcType=VARCHAR}, #{modifyTime,jdbcType=TIMESTAMP},
#{modifyBy,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.rzyc.model.ent.MinWorkUnit">
insert into min_work_unit
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="title != null">
title,
</if>
<if test="remark != null">
remark,
</if>
<if test="chargePerson != null">
charge_person,
</if>
<if test="contactPhone != null">
contact_phone,
</if>
<if test="files != null">
files,
</if>
<if test="delState != null">
del_state,
</if>
<if test="parentId != null">
parent_id,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="qrCode != null">
qr_code,
</if>
<if test="minCategory != null">
min_category,
</if>
<if test="modifyTime != null">
modify_time,
</if>
<if test="modifyBy != null">
modify_by,
</if>
<if test="createBy != null">
create_by,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="title != null">
#{title,jdbcType=VARCHAR},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="chargePerson != null">
#{chargePerson,jdbcType=VARCHAR},
</if>
<if test="contactPhone != null">
#{contactPhone,jdbcType=VARCHAR},
</if>
<if test="files != null">
#{files,jdbcType=VARCHAR},
</if>
<if test="delState != null">
#{delState,jdbcType=INTEGER},
</if>
<if test="parentId != null">
#{parentId,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="qrCode != null">
#{qrCode,jdbcType=VARCHAR},
</if>
<if test="minCategory != null">
#{minCategory,jdbcType=VARCHAR},
</if>
<if test="modifyTime != null">
#{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyBy != null">
#{modifyBy,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.rzyc.model.ent.MinWorkUnitExample" resultType="java.lang.Long">
select count(*) from min_work_unit
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update min_work_unit
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.title != null">
title = #{record.title,jdbcType=VARCHAR},
</if>
<if test="record.remark != null">
remark = #{record.remark,jdbcType=VARCHAR},
</if>
<if test="record.chargePerson != null">
charge_person = #{record.chargePerson,jdbcType=VARCHAR},
</if>
<if test="record.contactPhone != null">
contact_phone = #{record.contactPhone,jdbcType=VARCHAR},
</if>
<if test="record.files != null">
files = #{record.files,jdbcType=VARCHAR},
</if>
<if test="record.delState != null">
del_state = #{record.delState,jdbcType=INTEGER},
</if>
<if test="record.parentId != null">
parent_id = #{record.parentId,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.qrCode != null">
qr_code = #{record.qrCode,jdbcType=VARCHAR},
</if>
<if test="record.minCategory != null">
min_category = #{record.minCategory,jdbcType=VARCHAR},
</if>
<if test="record.modifyTime != null">
modify_time = #{record.modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="record.modifyBy != null">
modify_by = #{record.modifyBy,jdbcType=VARCHAR},
</if>
<if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update min_work_unit
set id = #{record.id,jdbcType=VARCHAR},
title = #{record.title,jdbcType=VARCHAR},
remark = #{record.remark,jdbcType=VARCHAR},
charge_person = #{record.chargePerson,jdbcType=VARCHAR},
contact_phone = #{record.contactPhone,jdbcType=VARCHAR},
files = #{record.files,jdbcType=VARCHAR},
del_state = #{record.delState,jdbcType=INTEGER},
parent_id = #{record.parentId,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
qr_code = #{record.qrCode,jdbcType=VARCHAR},
min_category = #{record.minCategory,jdbcType=VARCHAR},
modify_time = #{record.modifyTime,jdbcType=TIMESTAMP},
modify_by = #{record.modifyBy,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.rzyc.model.ent.MinWorkUnit">
update min_work_unit
<set>
<if test="title != null">
title = #{title,jdbcType=VARCHAR},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="chargePerson != null">
charge_person = #{chargePerson,jdbcType=VARCHAR},
</if>
<if test="contactPhone != null">
contact_phone = #{contactPhone,jdbcType=VARCHAR},
</if>
<if test="files != null">
files = #{files,jdbcType=VARCHAR},
</if>
<if test="delState != null">
del_state = #{delState,jdbcType=INTEGER},
</if>
<if test="parentId != null">
parent_id = #{parentId,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="qrCode != null">
qr_code = #{qrCode,jdbcType=VARCHAR},
</if>
<if test="minCategory != null">
min_category = #{minCategory,jdbcType=VARCHAR},
</if>
<if test="modifyTime != null">
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyBy != null">
modify_by = #{modifyBy,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.rzyc.model.ent.MinWorkUnit">
update min_work_unit
set title = #{title,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR},
charge_person = #{chargePerson,jdbcType=VARCHAR},
contact_phone = #{contactPhone,jdbcType=VARCHAR},
files = #{files,jdbcType=VARCHAR},
del_state = #{delState,jdbcType=INTEGER},
parent_id = #{parentId,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
qr_code = #{qrCode,jdbcType=VARCHAR},
min_category = #{minCategory,jdbcType=VARCHAR},
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
modify_by = #{modifyBy,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="selectByCompanyId" resultMap="BaseResultMap">
select * from min_work_unit where parent_id = #{companyId} and del_state = 1
</select>
<!--最小工作单元条件查询-->
<select id="selectQueryMinWorkUnit" parameterType="java.lang.String" resultMap="BaseResultMap">
select un.id,un.title,un.remark,un.charge_person,un.contact_phone,un.parent_id,ca.title as minCategoryName,
un.min_category,un.create_time,un.qr_code,un.files,se.EntName
from min_work_unit un
left join SysEnterprise se on se.SysEnterpriseId = un.parent_id
LEFT JOIN min_work_unit_category ca on ca.id = un.min_category
where del_state = 1
<if test="parentId != null and parentId != ''">
and un.parent_id = #{parentId}
</if>
<if test="condition != null and condition != ''">
and (
un.title like concat(concat("%",#{condition}),"%")
or un.charge_person like concat(concat("%",#{condition}),"%")
or un.contact_phone like concat(concat("%",#{condition}),"%")
or ca.title like concat(concat("%",#{condition}),"%")
)
</if>
ORDER BY un.modify_time DESC
</select>
<!--删除最小工作单元-->
<update id="deleteMinWorkUnit" parameterType="java.lang.String">
UPDATE min_work_unit SET del_state = 2 WHERE id = #{id}
</update>
<!--根据企业id返回最小工作单元-->
<select id="getByparentIdList" parameterType="java.lang.String" resultMap="BaseResultMap">
select un.title,un.qr_code,un.id,min_category from min_work_unit un
where un.del_state = 1
<if test="parentId != null and parentId != ''">
and un.parent_id = #{parentId}
</if>
ORDER BY un.modify_time DESC
</select>
<!--工作单元风险信息-->
<select id="findDanger" resultMap="BaseResultMap">
SELECT mu.`dangerinfo`,mw.*
FROM min_work_unit mw
LEFT JOIN min_work_unit_category mu ON mw.`min_category` = mu.`id`
WHERE mw.`parent_id` = #{entId} and mw.del_state = 1
</select>
<!--删除最小工作单元-->
<update id="delWorkUnit">
UPDATE min_work_unit SET del_state = 2 where parent_id = #{companyId}
</update>
</mapper>