<?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.thhy.secure.modules.biz.encourage.mapper.TEncourageMapper">
|
<resultMap id="BaseResultMap" type="com.thhy.secure.modules.biz.encourage.entity.TEncourage">
|
<!--
|
WARNING - @mbg.generated
|
This element is automatically generated by MyBatis Generator, do not modify.
|
This element was generated on Mon Jun 05 14:42:58 CST 2023.
|
-->
|
<id column="encourage_id" jdbcType="VARCHAR" property="encourageId" />
|
<result column="encourage_name" jdbcType="VARCHAR" property="encourageName" />
|
<result column="matter" jdbcType="VARCHAR" property="matter" />
|
<result column="matter_type" jdbcType="INTEGER" property="matterType" />
|
<result column="integral" jdbcType="INTEGER" property="integral" />
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
|
<result column="is_use" jdbcType="INTEGER" property="isUse" />
|
<result column="company_id" jdbcType="VARCHAR" property="companyId" />
|
</resultMap>
|
|
<insert id="encourageInsert">
|
insert into t_encourage
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="encourageId != null">
|
encourage_id,
|
</if>
|
<if test="encourageName != null">
|
encourage_name,
|
</if>
|
<if test="matter != null">
|
matter,
|
</if>
|
<if test="matterType != null">
|
matter_type,
|
</if>
|
<if test="integral != null">
|
integral,
|
</if>
|
<if test="createTime != null">
|
create_time,
|
</if>
|
<if test="createUser != null">
|
create_user,
|
</if>
|
<if test="isUse != null">
|
is_use,
|
</if>
|
<if test="companyId != null">
|
company_id,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="encourageId != null">
|
#{encourageId,jdbcType=VARCHAR},
|
</if>
|
<if test="encourageName != null">
|
#{encourageName,jdbcType=VARCHAR},
|
</if>
|
<if test="matter != null">
|
#{matter,jdbcType=VARCHAR},
|
</if>
|
<if test="matterType != null">
|
#{matterType,jdbcType=INTEGER},
|
</if>
|
<if test="integral != null">
|
#{integral,jdbcType=INTEGER},
|
</if>
|
<if test="createTime != null">
|
#{createTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="createUser != null">
|
#{createUser,jdbcType=VARCHAR},
|
</if>
|
<if test="isUse != null">
|
#{isUse,jdbcType=INTEGER},
|
</if>
|
<if test="companyId != null">
|
#{companyId,jdbcType=VARCHAR},
|
</if>
|
</trim>
|
</insert>
|
|
<select id="encourageList" resultType="com.thhy.secure.modules.biz.encourage.entity.TEncourage">
|
select
|
encourage_id as encourageId,
|
encourage_name as encourageName,
|
matter,
|
matter_type as matterType,
|
integral
|
from t_encourage
|
where is_use=1
|
<if test="companyId!=null and companyId!='' ">
|
and company_id=#{companyId}
|
</if>
|
<if test="encourageName!=null and encourageName!='' ">
|
and encourage_name like concat('%',#{encourageName},'%')
|
</if>
|
order by create_time desc
|
</select>
|
<select id="encourageInfo" resultType="com.thhy.secure.modules.biz.encourage.entity.TEncourage">
|
select
|
encourage_id as encourageId,
|
encourage_name as encourageName,
|
matter,
|
matter_type as matterType,
|
integral
|
from t_encourage
|
where is_use=1 and encourage_id=#{encourageId}
|
</select>
|
|
|
<update id="encourageUpdate" >
|
update t_encourage
|
<set>
|
<if test="encourageName != null">
|
encourage_name = #{encourageName,jdbcType=VARCHAR},
|
</if>
|
<if test="matter != null">
|
matter = #{matter,jdbcType=VARCHAR},
|
</if>
|
<if test="matterType != null">
|
matter_type = #{matterType,jdbcType=INTEGER},
|
</if>
|
<if test="integral != null">
|
integral = #{integral,jdbcType=INTEGER},
|
</if>
|
<if test="createTime != null">
|
create_time = #{createTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="createUser != null">
|
create_user = #{createUser,jdbcType=VARCHAR},
|
</if>
|
<if test="isUse != null">
|
is_use = #{isUse,jdbcType=INTEGER},
|
</if>
|
<if test="companyId != null">
|
company_id = #{companyId,jdbcType=VARCHAR},
|
</if>
|
</set>
|
where encourage_id = #{encourageId,jdbcType=VARCHAR}
|
</update>
|
<update id="encourageDel" >
|
update t_encourage set
|
is_use=2
|
where encourage_id = #{encourageId,jdbcType=VARCHAR}
|
</update>
|
|
<insert id="encourageRecordInsert">
|
insert into t_encourage_record
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="encourageRecordId != null">
|
encourage_record_id,
|
</if>
|
<if test="userId != null">
|
user_id,
|
</if>
|
<if test="createTime != null">
|
create_time,
|
</if>
|
<if test="createUser != null">
|
create_user,
|
</if>
|
<if test="isUse != null">
|
is_use,
|
</if>
|
<if test="encourageId != null">
|
encourage_id,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="encourageRecordId != null">
|
#{encourageRecordId,jdbcType=VARCHAR},
|
</if>
|
<if test="userId != null">
|
#{userId,jdbcType=VARCHAR},
|
</if>
|
<if test="createTime != null">
|
#{createTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="createUser != null">
|
#{createUser,jdbcType=VARCHAR},
|
</if>
|
<if test="isUse != null">
|
#{isUse,jdbcType=INTEGER},
|
</if>
|
<if test="encourageId != null">
|
#{encourageId,jdbcType=VARCHAR},
|
</if>
|
</trim>
|
</insert>
|
<select id="encourageRecordList" resultType="com.thhy.secure.modules.biz.encourage.entity.TEncourageRecord">
|
SELECT
|
ter.encourage_record_id as encourageRecordId,
|
te.encourage_name as encourageName,
|
te.integral,
|
te.matter_type as matterType,
|
ter.create_time as createTime,
|
spu.real_name as realName
|
FROM
|
t_encourage_record ter
|
LEFT JOIN t_encourage te ON ter.encourage_id = te.encourage_id
|
LEFT JOIN sys_plat_user spu ON ter.user_id = spu.user_id
|
where 1=1
|
<if test="companyId!=null and companyId!='' ">
|
and te.company_id=#{companyId}
|
</if>
|
<if test="realName!=null and realName!='' ">
|
and spu.real_name like concat('%',#{realName},'%')
|
</if>
|
<if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
|
and ter.create_time between #{strTime} and #{endTime}
|
</if>
|
order by ter.create_time desc
|
</select>
|
<select id="encourageRecordWebList" resultType="com.thhy.secure.modules.biz.encourage.entity.TEncourageRecord">
|
SELECT
|
ter.encourage_record_id as encourageRecordId,
|
te.encourage_name as encourageName,
|
te.integral,
|
te.matter_type as matterType,
|
ter.create_time as createTime,
|
spu.real_name as realName,
|
su.real_name as realNames,
|
te.matter as matter
|
FROM
|
t_encourage_record ter
|
LEFT JOIN t_encourage te ON ter.encourage_id = te.encourage_id
|
LEFT JOIN sys_plat_user spu ON ter.user_id = spu.user_id
|
LEFT JOIN sys_users su ON ter.create_user = su.user_id
|
where 1=1
|
<if test="companyId!=null and companyId!='' ">
|
and te.company_id=#{companyId}
|
</if>
|
<if test="realName!=null and realName!='' ">
|
and spu.real_name like concat('%',#{realName},'%')
|
</if>
|
<if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
|
and ter.create_time between #{strTime} and #{endTime}
|
</if>
|
order by ter.create_time desc
|
</select>
|
|
<select id="encourageRecordLists" resultType="com.thhy.secure.modules.biz.encourage.entity.dto.EncourageRecordDto">
|
SELECT
|
ter.encourage_record_id as encourageRecordId,
|
te.encourage_name as encourageName,
|
te.integral,
|
te.matter_type as matterType,
|
ter.create_time as createTime
|
FROM
|
t_encourage_record ter
|
LEFT JOIN t_encourage te ON ter.encourage_id = te.encourage_id
|
where 1=1
|
<if test="userId!=null and userId!='' ">
|
and ter.user_id=#{userId}
|
</if>
|
<if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
|
and ter.create_time between #{strTime} and #{endTime}
|
</if>
|
order by ter.create_time desc
|
</select>
|
<select id="encourage" resultType="java.lang.Integer">
|
SELECT
|
sum(te.integral) as integral
|
FROM
|
t_encourage_record ter
|
LEFT JOIN t_encourage te ON ter.encourage_id = te.encourage_id
|
where te.matter_type=1
|
<if test="userId!=null and userId!='' ">
|
and ter.user_id=#{userId}
|
</if>
|
<if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
|
and ter.create_time between #{strTime} and #{endTime}
|
</if>
|
</select>
|
<select id="encourages" resultType="java.lang.Integer">
|
SELECT
|
sum(te.integral) as integral
|
FROM
|
t_encourage_record ter
|
LEFT JOIN t_encourage te ON ter.encourage_id = te.encourage_id
|
where te.matter_type=1
|
<if test="userId!=null and userId!='' ">
|
and ter.user_id=#{userId}
|
</if>
|
</select>
|
<select id="punish" resultType="java.lang.Integer">
|
SELECT
|
sum(te.integral) as integral
|
FROM
|
t_encourage_record ter
|
LEFT JOIN t_encourage te ON ter.encourage_id = te.encourage_id
|
where te.matter_type=2
|
<if test="userId!=null and userId!='' ">
|
and ter.user_id=#{userId}
|
</if>
|
<if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
|
and ter.create_time between #{strTime} and #{endTime}
|
</if>
|
</select>
|
<select id="punishs" resultType="java.lang.Integer">
|
SELECT
|
sum(te.integral) as integral
|
FROM
|
t_encourage_record ter
|
LEFT JOIN t_encourage te ON ter.encourage_id = te.encourage_id
|
where te.matter_type=2
|
<if test="userId!=null and userId!='' ">
|
and ter.user_id=#{userId}
|
</if>
|
</select>
|
<select id="userPlatId" parameterType="java.lang.String" resultType="java.lang.String">
|
select plat_id from sys_users
|
where user_id=#{userId}
|
</select>
|
|
<select id="platUserInfo" parameterType="java.lang.String" resultType="com.thhy.secure.modules.biz.encourage.entity.PlatUserDto">
|
SELECT
|
spu.job_num AS jobNum,
|
spu.sex,
|
spu.photo,
|
spu.phone,
|
spu.id_no AS idNo,
|
spu.has_cert AS hasCert,
|
spu.employed_time AS employedTime,
|
spu.come_factory_time AS comeFactoryTime,
|
spu.leave_factory_time AS leaveFactoryTime,
|
sc.shortname AS jg,
|
spu.`status`,
|
spu.real_name AS realName,
|
sp.pos_name AS posName,
|
sd.depart_name AS departName,
|
sdi.dict_name AS zzmm,
|
group_concat( sg.group_name ) AS groupName
|
FROM
|
sys_plat_user spu
|
LEFT JOIN sys_plat_position_user ppu ON spu.user_id = ppu.user_id
|
LEFT JOIN sys_position sp ON ppu.position_id = sp.pos_id
|
LEFT JOIN sys_depart_user du ON spu.user_id = du.user_id
|
LEFT JOIN sys_depart sd ON du.depart_id = sd.depart_id
|
LEFT JOIN sys_dict sdi ON spu.zzmm = sdi.dict_id
|
LEFT JOIN sys_group_user sgu ON spu.user_id = sgu.user_id
|
LEFT JOIN sys_group sg ON sgu.group_id = sg.group_id
|
LEFT JOIN sys_city sc ON spu.jg = sc.id
|
where spu.user_id=#{platId}
|
GROUP BY
|
spu.user_id,sp.pos_name,sd.depart_name
|
</select>
|
|
<select id="encourageSecurityCode" resultType="com.thhy.secure.modules.biz.encourage.entity.dto.SecurityCodeDto">
|
SELECT
|
spu.user_id as userId,
|
spu.real_name as realName,
|
sp.pos_name as posName,
|
sp.company_id as companyId,
|
100 as an
|
FROM
|
sys_plat_user spu
|
LEFT JOIN sys_plat_position_user ppu ON spu.user_id = ppu.user_id
|
LEFT JOIN sys_position sp ON sp.pos_id = ppu.position_id
|
where sp.company_id=#{companyId} and
|
spu.user_type=2
|
<if test="realName!=null and realName!='' ">
|
and spu.real_name like concat('%',#{realName},'%')
|
</if>
|
</select>
|
<select id="encourageSecurityCodeJia" resultType="java.lang.Double">
|
SELECT
|
IF(SUM(te.integral)!='',SUM(te.integral),'0.0') as jia
|
FROM
|
sys_plat_user spu
|
LEFT JOIN sys_plat_position_user ppu ON spu.user_id = ppu.user_id
|
LEFT JOIN sys_position sp ON sp.pos_id = ppu.position_id
|
left join t_encourage_record er on ppu.user_id=er.user_id
|
left join t_encourage te on te.encourage_id=er.encourage_id
|
where sp.company_id=#{companyId} and spu.user_id=#{userId} and
|
te.matter_type=1 GROUP BY spu.user_id
|
</select>
|
<select id="encourageSecurityCodeJian" resultType="java.lang.Double">
|
SELECT
|
IF(SUM(te.integral)!='',SUM(te.integral),'0.0') as jian
|
FROM
|
sys_plat_user spu
|
LEFT JOIN sys_plat_position_user ppu ON spu.user_id = ppu.user_id
|
LEFT JOIN sys_position sp ON sp.pos_id = ppu.position_id
|
left join t_encourage_record er on ppu.user_id=er.user_id
|
left join t_encourage te on te.encourage_id=er.encourage_id
|
where sp.company_id=#{companyId} and spu.user_id=#{userId} and
|
te.matter_type=2 GROUP BY spu.user_id
|
</select>
|
|
|
</mapper>
|