JAVA开发2021日常笔记

随便写写,记录遇到的难题,以及怎么解决的。。。

1、JAVA

1、字符串转list
List<String> value = Arrays.asList(e.get("value").toString().split(","));

2、PGSQL

1、分组排序
SELECT
			res.coords
		FROM
			(
				SELECT
					concat (
						s.address ->> 'longitude',
						',',
						s.address ->> 'latitude'
					) AS coords,
					s.address ->> 'provinceCode' AS provinceCode,
					ROW_NUMBER () OVER (
						PARTITION BY s.address ->> 'provinceCode'
					) RANK   //序列号
				FROM
					t_report_member s
				WHERE
					s.identity_code = '汽修厂'
				AND s.data_time = (
					SELECT
						MAX (data_time)
					FROM
						t_report_member
				)
			) res
		WHERE
			res. RANK = 1
2、replace into
<foreach item="item" collection="saveList">
            WITH upsert AS (
            UPDATE t_preferences_recommand
            SET preference =
            <choose>
                <when test="item.preference != null and item.preference != ''">#{item.preference}</when>
                <otherwise>''</otherwise>
            </choose>
            , val =
            <choose>
                <when test="item.val != null and item.val != ''">#{item.val}</when>
                <otherwise>''</otherwise>
            </choose>,update_time = now()
            WHERE
            user_id = #{item.userId} RETURNING *
            ) INSERT INTO t_preferences_recommand SELECT
            #{item.userId},
            <choose>
                <when test="item.preference != null and item.preference != ''">#{item.preference}</when>
                <otherwise>''</otherwise>
            </choose>
            ,
            <choose>
                <when test="item.val != null and item.val != ''">#{item.val}</when>
                <otherwise>''</otherwise>
            </choose>, now(), null
            WHERE NOT EXISTS ( SELECT 1 FROM upsert WHERE user_id = #{item.userId} );
        </foreach>

版权声明:本文为weixin_44521892原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。