You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.6 KiB
XML

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?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="cn.iocoder.yudao.module.camera.dal.mysql.stock.StockMapper">
<!-- 动态更新最后一条taskId匹配的记录 -->
<update id="updateLastByTaskId">
UPDATE logistics_stock
SET extend_info = JSON_SET(
extend_info,
CONCAT('$.', #{column}),
#{value}
)
WHERE id = #{id};
</update>
<!-- 根据字段列表更新status -->
<!-- 规则:有字段为空或null → status=0,全部和wms字段相等 → status=2,否则 → status=1 -->
<!-- fields格式如:code, tray_code,对应的wms字段为:wms_code, wms_tray_code(下划线格式) -->
<update id="updateStatusByFields">
UPDATE logistics_stock
SET status = CASE
WHEN
<foreach collection="fields" item="field" separator=" OR ">
JSON_EXTRACT(extend_info, CONCAT('$.', #{field})) IS NULL
OR JSON_EXTRACT(extend_info, CONCAT('$.', #{field})) = ''
</foreach>
THEN 0
WHEN
<foreach collection="fields" item="field" separator=" AND ">
JSON_EXTRACT(extend_info, CONCAT('$.', #{field})) = JSON_EXTRACT(wms_extend_info, CONCAT('$.', #{field}))
</foreach>
THEN 2
ELSE 1
END
WHERE id = #{id}
</update>
<!-- 清空整个表 -->
<update id="truncate">
TRUNCATE TABLE logistics_stock
</update>
</mapper>