Commit 8f7102f3 by huluobin

# 更新

parent cfa664a1
...@@ -162,4 +162,7 @@ public interface DcBaseQueueMapper { ...@@ -162,4 +162,7 @@ public interface DcBaseQueueMapper {
* @project https://github.com/itfsw/mybatis-generator-plugin * @project https://github.com/itfsw/mybatis-generator-plugin
*/ */
int upsertWithBLOBs(DcBaseQueue record); int upsertWithBLOBs(DcBaseQueue record);
List<DcBaseQueue> poll(int shardingItem);
} }
...@@ -6,20 +6,20 @@ ...@@ -6,20 +6,20 @@
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
--> -->
<id column="id" jdbcType="INTEGER" property="id" /> <id column="id" jdbcType="INTEGER" property="id"/>
<result column="type" jdbcType="VARCHAR" property="type" /> <result column="type" jdbcType="VARCHAR" property="type"/>
<result column="message" jdbcType="VARCHAR" property="message" /> <result column="message" jdbcType="VARCHAR" property="message"/>
<result column="submit_date" jdbcType="TIMESTAMP" property="submitDate" /> <result column="submit_date" jdbcType="TIMESTAMP" property="submitDate"/>
<result column="consume_date" jdbcType="TIMESTAMP" property="consumeDate" /> <result column="consume_date" jdbcType="TIMESTAMP" property="consumeDate"/>
<result column="error_message" jdbcType="VARCHAR" property="errorMessage" /> <result column="error_message" jdbcType="VARCHAR" property="errorMessage"/>
<result column="queue_type" jdbcType="INTEGER" property="queueType" /> <result column="queue_type" jdbcType="INTEGER" property="queueType"/>
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.bailuntec.domain.entity.DcBaseQueue"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.bailuntec.domain.entity.DcBaseQueue">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
--> -->
<result column="error_stack_trace" jdbcType="LONGVARCHAR" property="errorStackTrace" /> <result column="error_stack_trace" jdbcType="LONGVARCHAR" property="errorStackTrace"/>
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<!-- <!--
...@@ -110,12 +110,12 @@ ...@@ -110,12 +110,12 @@
<if test="distinct"> <if test="distinct">
distinct distinct
</if> </if>
<include refid="Base_Column_List" /> <include refid="Base_Column_List"/>
, ,
<include refid="Blob_Column_List" /> <include refid="Blob_Column_List"/>
from dc_base_queue from dc_base_queue
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause"/>
</if> </if>
<if test="orderByClause != null"> <if test="orderByClause != null">
order by ${orderByClause} order by ${orderByClause}
...@@ -138,10 +138,10 @@ ...@@ -138,10 +138,10 @@
<if test="distinct"> <if test="distinct">
distinct distinct
</if> </if>
<include refid="Base_Column_List" /> <include refid="Base_Column_List"/>
from dc_base_queue from dc_base_queue
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause"/>
</if> </if>
<if test="orderByClause != null"> <if test="orderByClause != null">
order by ${orderByClause} order by ${orderByClause}
...@@ -161,9 +161,9 @@ ...@@ -161,9 +161,9 @@
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
--> -->
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List"/>
, ,
<include refid="Blob_Column_List" /> <include refid="Blob_Column_List"/>
from dc_base_queue from dc_base_queue
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</select> </select>
...@@ -182,7 +182,7 @@ ...@@ -182,7 +182,7 @@
--> -->
delete from dc_base_queue delete from dc_base_queue
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause"/>
</if> </if>
</delete> </delete>
<insert id="insert" parameterType="com.bailuntec.domain.entity.DcBaseQueue"> <insert id="insert" parameterType="com.bailuntec.domain.entity.DcBaseQueue">
...@@ -263,7 +263,7 @@ ...@@ -263,7 +263,7 @@
--> -->
select count(*) from dc_base_queue select count(*) from dc_base_queue
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause"/>
</if> </if>
</select> </select>
<update id="updateByExampleSelective" parameterType="map"> <update id="updateByExampleSelective" parameterType="map">
...@@ -299,7 +299,7 @@ ...@@ -299,7 +299,7 @@
</if> </if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause"/>
</if> </if>
</update> </update>
<update id="updateByExampleWithBLOBs" parameterType="map"> <update id="updateByExampleWithBLOBs" parameterType="map">
...@@ -317,7 +317,7 @@ ...@@ -317,7 +317,7 @@
queue_type = #{record.queueType,jdbcType=INTEGER}, queue_type = #{record.queueType,jdbcType=INTEGER},
error_stack_trace = #{record.errorStackTrace,jdbcType=LONGVARCHAR} error_stack_trace = #{record.errorStackTrace,jdbcType=LONGVARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause"/>
</if> </if>
</update> </update>
<update id="updateByExample" parameterType="map"> <update id="updateByExample" parameterType="map">
...@@ -334,7 +334,7 @@ ...@@ -334,7 +334,7 @@
error_message = #{record.errorMessage,jdbcType=VARCHAR}, error_message = #{record.errorMessage,jdbcType=VARCHAR},
queue_type = #{record.queueType,jdbcType=INTEGER} queue_type = #{record.queueType,jdbcType=INTEGER}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause"/>
</if> </if>
</update> </update>
<update id="updateByPrimaryKeySelective" parameterType="com.bailuntec.domain.entity.DcBaseQueue"> <update id="updateByPrimaryKeySelective" parameterType="com.bailuntec.domain.entity.DcBaseQueue">
...@@ -536,10 +536,10 @@ ...@@ -536,10 +536,10 @@
@project https://github.com/itfsw/mybatis-generator-plugin @project https://github.com/itfsw/mybatis-generator-plugin
--> -->
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List"/>
from dc_base_queue from dc_base_queue
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause"/>
</if> </if>
<if test="orderByClause != null"> <if test="orderByClause != null">
order by ${orderByClause} order by ${orderByClause}
...@@ -553,16 +553,24 @@ ...@@ -553,16 +553,24 @@
@project https://github.com/itfsw/mybatis-generator-plugin @project https://github.com/itfsw/mybatis-generator-plugin
--> -->
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List"/>
, ,
<include refid="Blob_Column_List" /> <include refid="Blob_Column_List"/>
from dc_base_queue from dc_base_queue
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause"/>
</if> </if>
<if test="orderByClause != null"> <if test="orderByClause != null">
order by ${orderByClause} order by ${orderByClause}
</if> </if>
limit 1 limit 1
</select> </select>
<select id="poll" resultType="com.bailuntec.domain.entity.DcBaseQueue">
select *
from dc_base_queue
where consume_date is null
and id % 8 = #{shardingItem}
limit 100
</select>
</mapper> </mapper>
...@@ -5,7 +5,6 @@ import com.alibaba.fastjson.annotation.JSONField; ...@@ -5,7 +5,6 @@ import com.alibaba.fastjson.annotation.JSONField;
import com.bailuntec.domain.constant.CommonConstant; import com.bailuntec.domain.constant.CommonConstant;
import com.bailuntec.domain.entity.DcBaseQueue; import com.bailuntec.domain.entity.DcBaseQueue;
import com.bailuntec.domain.entity.DcBaseStock; import com.bailuntec.domain.entity.DcBaseStock;
import com.bailuntec.domain.example.DcBaseQueueExample;
import com.bailuntec.domain.example.DcBaseStockExample; import com.bailuntec.domain.example.DcBaseStockExample;
import com.bailuntec.mapper.DcBaseQueueMapper; import com.bailuntec.mapper.DcBaseQueueMapper;
import com.bailuntec.mapper.DcBaseStockMapper; import com.bailuntec.mapper.DcBaseStockMapper;
...@@ -45,15 +44,11 @@ public class QueueConsumerJob implements SimpleJob { ...@@ -45,15 +44,11 @@ public class QueueConsumerJob implements SimpleJob {
public void execute(ShardingContext shardingContext) { public void execute(ShardingContext shardingContext) {
try (SqlSession sqlSession = SessionUtil.getFactory().openSession(true)) { try (SqlSession sqlSession = SessionUtil.getFactory().openSession(true)) {
if (shardingContext.getShardingItem() == 0) {
AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob(); AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob();
DcBaseQueueMapper dcBaseQueueMapper = sqlSession.getMapper(DcBaseQueueMapper.class); DcBaseQueueMapper dcBaseQueueMapper = sqlSession.getMapper(DcBaseQueueMapper.class);
DcBaseStockMapper dcBaseStockMapper = sqlSession.getMapper(DcBaseStockMapper.class); DcBaseStockMapper dcBaseStockMapper = sqlSession.getMapper(DcBaseStockMapper.class);
List<DcBaseQueue> dcBaseQueueList = dcBaseQueueMapper.selectByExample(DcBaseQueueExample.newAndCreateCriteria() List<DcBaseQueue> dcBaseQueueList = dcBaseQueueMapper.poll(shardingContext.getShardingItem());
.andConsumeDateIsNull()
.example()
.limit(1000));
dcBaseQueueList.forEach(dcBaseQueue -> { dcBaseQueueList.forEach(dcBaseQueue -> {
BaseQueueMessage baseQueueMessage = JSON.parseObject(dcBaseQueue.getMessage(), BaseQueueMessage.class); BaseQueueMessage baseQueueMessage = JSON.parseObject(dcBaseQueue.getMessage(), BaseQueueMessage.class);
...@@ -81,5 +76,4 @@ public class QueueConsumerJob implements SimpleJob { ...@@ -81,5 +76,4 @@ public class QueueConsumerJob implements SimpleJob {
}); });
} }
} }
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment