SQL 修改

This commit is contained in:
cwchen 2025-08-27 16:04:03 +08:00
parent 8dc4512abb
commit a55fe26ec1
4 changed files with 32 additions and 32 deletions

View File

@ -4,7 +4,7 @@
<mapper namespace="com.bonus.bmw.basic.dao.CompanyDao"> <mapper namespace="com.bonus.bmw.basic.dao.CompanyDao">
<sql id="where"> <sql id="where">
where pc.IS_ACTIVE = '1' where pc."is_active" = '1'
<if test="params.companyId != null and params.companyId !='' "> <if test="params.companyId != null and params.companyId !='' ">
and pc."id" = #{params.companyId} and pc."id" = #{params.companyId}
</if> </if>
@ -16,7 +16,7 @@
</if> </if>
<if test="params.keyWord != null and params.keyWord != ''"> <if test="params.keyWord != null and params.keyWord != ''">
and ( and (
pc.NAME like concat('%', #{params.keyWord}, '%') or pc."name" like concat('%', #{params.keyWord}, '%') or
pc."legal_person" like concat('%', #{params.keyWord}, '%') pc."legal_person" like concat('%', #{params.keyWord}, '%')
) )
</if> </if>
@ -24,27 +24,27 @@
</sql> </sql>
<insert id="saveCompanyWithOrg"> <insert id="saveCompanyWithOrg">
INSERT INTO "ynrealname"."pm_organization"(NAME, ABBREVIATION, PARENT_ID, INSERT INTO "ynrealname"."pm_organization"("name", "abbreviation", "parent_id",
"company_id","foreign_id", DESCRIPTION, TYPE, IS_ACTIVE) "company_id","foreign_id", "description", "type", "is_active")
VALUES (#{companyName}, #{companyName}, 0, #{id},#{id},NULL, 1, '1'); VALUES (#{companyName}, #{companyName}, 0, #{id},#{id},NULL, 1, '1');
</insert> </insert>
<update id="updateCompany"> <update id="updateCompany">
update "ynrealname"."pm_company" set update "ynrealname"."pm_company" set
NAME = #{companyName},"type_id" = #{unitType},"legal_person" = #{represent}, "name" = #{companyName},"type_id" = #{unitType},"legal_person" = #{represent},
"legal_phone" = #{representPhone}, "legal_idnumber" = #{representIdNumber}, "legal_phone" = #{representPhone}, "legal_idnumber" = #{representIdNumber},
"register_date" = #{registerDate}, "address"= #{address} where "id" = #{id} "register_date" = #{registerDate}, "address"= #{address} where "id" = #{id}
</update> </update>
<update id="updateCompanyWithOrg"> <update id="updateCompanyWithOrg">
UPDATE "ynrealname"."pm_organization" SET UPDATE "ynrealname"."pm_organization" SET
NAME = #{companyName},ABBREVIATION = #{companyName} "name" = #{companyName},"abbreviation" = #{companyName}
WHERE "foreign_id" = #{id} and TYPE = '1' WHERE "foreign_id" = #{id} and "type" = '1'
</update> </update>
<delete id="deleteCompanyWithOrg"> <delete id="deleteCompanyWithOrg">
UPDATE "ynrealname"."pm_organization" SET UPDATE "ynrealname"."pm_organization" SET
"is_active" = '0' "is_active" = '0'
WHERE "foreign_id" = #{id} and TYPE = '1' WHERE "foreign_id" = #{id} and "type" = '1'
</delete> </delete>
<select id="count" resultType="int"> <select id="count" resultType="int">
@ -57,7 +57,7 @@
<select id="list" resultType="com.bonus.bmw.basic.entity.CompanyBean"> <select id="list" resultType="com.bonus.bmw.basic.entity.CompanyBean">
SELECT SELECT
pc."id", pc."id",
NAME AS companyName, pc."name" AS companyName,
pc."type_id" AS unitTypeId, pc."type_id" AS unitTypeId,
td."value" AS unitType, td."value" AS unitType,
pc."address", pc."address",

View File

@ -4,13 +4,13 @@
<mapper namespace="com.bonus.bmw.basic.dao.SubCompanyDao"> <mapper namespace="com.bonus.bmw.basic.dao.SubCompanyDao">
<sql id="where"> <sql id="where">
where pd.IS_ACTIVE = '1' where pd."is_active" = '1'
<if test="params.companyId != null and params.companyId != ''"> <if test="params.companyId != null and params.companyId != ''">
and pc."id" = #{params.companyId} and pc."id" = #{params.companyId}
</if> </if>
<if test="params.keyWord != null and params.keyWord != ''"> <if test="params.keyWord != null and params.keyWord != ''">
and ( and (
pd.NAME like concat('%', #{params.keyWord}, '%') or pd."name" like concat('%', #{params.keyWord}, '%') or
pc."name" like concat('%', #{params.keyWord}, '%') or pc."name" like concat('%', #{params.keyWord}, '%') or
pd."abbreviation" like concat('%', #{params.keyWord}, '%') pd."abbreviation" like concat('%', #{params.keyWord}, '%')
) )
@ -18,8 +18,8 @@
</sql> </sql>
<insert id="saveSubCompanyWithOrg"> <insert id="saveSubCompanyWithOrg">
INSERT INTO "ynrealname"."pm_organization"(NAME, ABBREVIATION, PARENT_ID, INSERT INTO "ynrealname"."pm_organization"("name", "abbreviation", "parent_id",
"company_id","foreign_id", DESCRIPTION, TYPE, IS_ACTIVE) "company_id","foreign_id", "description", "type", "is_active")
VALUES (#{subCompanyName}, #{abbreviation}, #{parentId}, #{companyId},#{id}, NULL, 2, '1'); VALUES (#{subCompanyName}, #{abbreviation}, #{parentId}, #{companyId},#{id}, NULL, 2, '1');
</insert> </insert>
@ -30,33 +30,33 @@
</update> </update>
<update id="updateSubCompanyWithOrg"> <update id="updateSubCompanyWithOrg">
UPDATE "ynrealname"."pm_organization" SET UPDATE "ynrealname"."pm_organization" SET
NAME = #{subCompanyName},ABBREVIATION = #{abbreviation},"parent_id" = #{parentId},"company_id" = #{companyId} "name" = #{subCompanyName},"abbreviation" = #{abbreviation},"parent_id" = #{parentId},"company_id" = #{companyId}
WHERE "foreign_id" = #{id} and "type" = '2' WHERE "foreign_id" = #{id} and "type" = '2'
</update> </update>
<update id="delSubCompanyWithOrg"> <update id="delSubCompanyWithOrg">
UPDATE "ynrealname"."pm_organization" SET UPDATE "ynrealname"."pm_organization" SET
IS_ACTIVE = '0' "is_active" = '0'
WHERE "foreign_id" = #{id} and "type" = '2' WHERE "foreign_id" = #{id} and "type" = '2'
</update> </update>
<select id="count" resultType="int"> <select id="count" resultType="int">
select count(1) FROM select count(1) FROM
"ynrealname"."pm_dept" pd "ynrealname"."pm_dept" pd
LEFT JOIN "ynrealname"."pm_company" pc ON pd."company_id" = pc."id" and pc.IS_ACTIVE = '1' LEFT JOIN "ynrealname"."pm_company" pc ON pd."company_id" = pc."id" and pc."is_active" = '1'
<include refid="where" /> <include refid="where" />
</select> </select>
<select id="list" resultType="com.bonus.bmw.basic.entity.SubCompanyBean"> <select id="list" resultType="com.bonus.bmw.basic.entity.SubCompanyBean">
SELECT SELECT
pc.ID AS companyId, pc."id" AS companyId,
pc.NAME AS companyName, pc."name" AS companyName,
pd."id", pd."id",
pd.NAME AS subCompanyName, pd."name" AS subCompanyName,
pd."abbreviation", pd."abbreviation",
pd."status" pd."status"
FROM FROM
"ynrealname"."pm_dept" pd "ynrealname"."pm_dept" pd
LEFT JOIN "ynrealname"."pm_company" pc ON pd."company_id" = pc."id" and pc.IS_ACTIVE = '1' LEFT JOIN "ynrealname"."pm_company" pc ON pd."company_id" = pc."id" and pc."is_active" = '1'
<include refid="where" /> <include refid="where" />
<if test="offset != null and offset >= 0 and limit != null and limit >= 0"> <if test="offset != null and offset >= 0 and limit != null and limit >= 0">
OFFSET #{offset} ROWS FETCH NEXT #{limit} ROWS ONLY OFFSET #{offset} ROWS FETCH NEXT #{limit} ROWS ONLY

View File

@ -344,8 +344,8 @@ select * from (
bp."name" as proName, bp."name" as proName,
pd."name" as companyName, pd."name" as companyName,
CASE CASE
WHEN MONTHS_BETWEEN(bwc."stop_date", TRUNC(SYSDATE)) > 5 THEN '有效' WHEN MONTHS_BETWEEN(bwc."stop_date", TRUNC(SYSDATE)) &gt; 5 THEN '有效'
WHEN (bwc."stop_date" - TRUNC(SYSDATE)) < 0 THEN '' WHEN (bwc."stop_date" - TRUNC(SYSDATE)) &lt; 0 THEN '过期'
ELSE '预警' ELSE '预警'
END as remind END as remind
FROM FROM

View File

@ -5,41 +5,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.bonus.system.logs.dao.SysLogininforMapper"> <mapper namespace="com.bonus.system.logs.dao.SysLogininforMapper">
<insert id="insertLogininfor" parameterType="com.bonus.system.api.domain.SysLogininfor"> <insert id="insertLogininfor" parameterType="com.bonus.system.api.domain.SysLogininfor">
insert into sys_logininfor (user_id, status, ipaddr, msg) insert into "ynrealname"."sys_logininfor" ("user_id", "status", "ipaddr", "msg")
values (#{userName}, #{status}, #{ipaddr}, #{msg}) values (#{userName}, #{status}, #{ipaddr}, #{msg})
</insert> </insert>
<select id="selectLogininforList" resultType="com.bonus.system.api.domain.SysLogininfor"> <select id="selectLogininforList" resultType="com.bonus.system.api.domain.SysLogininfor">
select info_id, user_name, ipaddr, status, msg, access_time from sys_logininfor select "info_id", "user_name", "ipaddr", "status", "msg", "access_time" from "ynrealname"."sys_logininfor"
<where> <where>
<if test="ipaddr != null and ipaddr != ''"> <if test="ipaddr != null and ipaddr != ''">
AND ipaddr like concat('%', #{ipaddr}, '%') AND "ipaddr" like '%' || #{ipaddr} || '%'
</if> </if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
AND status = #{status} AND "status" = #{status}
</if> </if>
<if test="userName != null and userName != ''"> <if test="userName != null and userName != ''">
AND user_name like concat('%', #{userName}, '%') AND "user_name" like '%' || #{userName} || '%'
</if> </if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(access_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d') and to_char("access_time",'YYYYMMDD') &gt;= to_char(#{params.beginTime},'YYYYMMDD')
</if> </if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 --> <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(access_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d') and to_char("access_time",'YYYYMMDD') &lt;= to_char(#{params.endTime},'YYYYMMDD')
</if> </if>
</where> </where>
order by info_id desc order by "info_id" desc
</select> </select>
<delete id="deleteLogininforByIds" parameterType="Long"> <delete id="deleteLogininforByIds" parameterType="Long">
delete from sys_logininfor where info_id in delete from "ynrealname"."sys_logininfor" where "info_id" in
<foreach collection="array" item="infoId" open="(" separator="," close=")"> <foreach collection="array" item="infoId" open="(" separator="," close=")">
#{infoId} #{infoId}
</foreach> </foreach>
</delete> </delete>
<update id="cleanLogininfor"> <update id="cleanLogininfor">
truncate table sys_logininfor truncate table "ynrealname"."sys_logininfor"
</update> </update>
</mapper> </mapper>