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

View File

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

View File

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

View File

@ -5,41 +5,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.bonus.system.logs.dao.SysLogininforMapper">
<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})
</insert>
<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>
<if test="ipaddr != null and ipaddr != ''">
AND ipaddr like concat('%', #{ipaddr}, '%')
AND "ipaddr" like '%' || #{ipaddr} || '%'
</if>
<if test="status != null and status != ''">
AND status = #{status}
AND "status" = #{status}
</if>
<if test="userName != null and userName != ''">
AND user_name like concat('%', #{userName}, '%')
AND "user_name" like '%' || #{userName} || '%'
</if>
<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 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>
</where>
order by info_id desc
order by "info_id" desc
</select>
<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=")">
#{infoId}
</foreach>
</delete>
<update id="cleanLogininfor">
truncate table sys_logininfor
truncate table "ynrealname"."sys_logininfor"
</update>
</mapper>