增加进程锁

This commit is contained in:
haozq 2025-12-22 14:40:22 +08:00
parent a9a2acc608
commit 366b7346fa
11 changed files with 1053 additions and 441 deletions

View File

@ -4,12 +4,12 @@
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />

View File

@ -22,16 +22,17 @@
<select />
</component>
<component name="ChangeListManager">
<list default="true" id="a38a4155-0e8c-4ddb-9f60-993f173584d3" name="Default Changelist" comment="新增字段及接口">
<change beforePath="$PROJECT_DIR$/.idea/dataSources.local.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources.local.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/dataSources/f3c9cb31-a068-40bc-b157-fc2fddb017d4.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources/f3c9cb31-a068-40bc-b157-fc2fddb017d4.xml" afterDir="false" />
<list default="true" id="a38a4155-0e8c-4ddb-9f60-993f173584d3" name="Default Changelist" comment="新增安全单位接口">
<change afterPath="$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/mapper/DbDistLockUtilMapper.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/DbDistLockUtil.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/mapper/DbDistLockUtilMapper.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/jarRepositories.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/jarRepositories.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xxl-job-admin/src/main/java/com/xxl/job/admin/XxlJobAdminApplication.java" beforeDir="false" afterPath="$PROJECT_DIR$/xxl-job-admin/src/main/java/com/xxl/job/admin/XxlJobAdminApplication.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobRegistry.java" beforeDir="false" afterPath="$PROJECT_DIR$/xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobRegistry.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xxl-job-admin/src/main/resources/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/xxl-job-admin/src/main/resources/application.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xxl-job-admin/src/main/resources/xxl-job/XxlJobInfoMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/xxl-job-admin/src/main/resources/xxl-job/XxlJobInfoMapper.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/entity/JjDayPlan.java" beforeDir="false" afterPath="$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/entity/JjDayPlan.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/InterService.java" beforeDir="false" afterPath="$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/InterService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xxl-job-admin/src/main/resources/xxl-job/xxl-job2/XxlJobInfoMapper.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/DataCenterXxlJob.java" beforeDir="false" afterPath="$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/DataCenterXxlJob.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/JJBusinessXxlJob.java" beforeDir="false" afterPath="$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/JJBusinessXxlJob.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/application.properties" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -58,11 +59,20 @@
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="customMavenHome" value="$PROJECT_DIR$/../../maven/apache-maven-3.6.1" />
<option name="customMavenHome" value="D:\maven\apache-maven-3.6.1" />
<option name="localRepository" value="D:\maven\resp" />
<option name="mavenHomeTypeForPersistence" value="CUSTOM" />
<option name="userSettingsFile" value="D:\maven\apache-maven-3.6.1\conf\settings-jjsp.xml" />
<option name="userSettingsFile" value="D:\maven\apache-maven-3.6.1\conf\settings.xml" />
</MavenGeneralSettings>
</option>
<option name="importingSettings">
<MavenImportingSettings>
<option name="jdkForImporter" value="1.8" />
</MavenImportingSettings>
</option>
</component>
<component name="MavenRunner">
<option name="jreName" value="1.8" />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 0
@ -89,19 +99,21 @@
"RequestMappingsPanelWidth1": "75",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"SONARLINT_PRECOMMIT_ANALYSIS": "true",
"Spring Boot.XxlJobAdminApplication.executor": "Debug",
"Spring Boot.XxlJobExecutorApplication.executor": "Debug",
"WebServerToolWindowFactoryState": "false",
"git-widget-placeholder": "main",
"ignore.virus.scanning.warn.message": "true",
"kotlin-language-version-configured": "true",
"last_opened_file_path": "F:/workspace/idea/xxl-job",
"last_opened_file_path": "F:/workspace/idea/xxl-job/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/mapper",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"project.structure.last.edited": "Modules",
"project.structure.last.edited": "Libraries",
"project.structure.proportion": "0.15",
"project.structure.side.proportion": "0.2",
"settings.editor.selected.configurable": "MavenSettings",
@ -116,11 +128,11 @@
}]]></component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="F:\workspace\idea\xxl-job\xxl-job-executor-samples\xxl-job-executor-sample-springboot\src\main\resources\mapper" />
<recent name="F:\workspace\idea\xxl-job\xxl-job-executor-samples\xxl-job-executor-sample-springboot\src\main\java\com\xxl\job\executor\inter\entity" />
<recent name="D:\workspace\xxl-job\xxl-job-executor-samples\xxl-job-executor-sample-springboot\src\main\resources\mapper" />
<recent name="D:\workspace\xxl-job\xxl-job-executor-samples\xxl-job-executor-sample-springboot\src\main\java\com\xxl\job\executor\inter\entity" />
<recent name="D:\workspace\xxl-job\xxl-job-admin\src\main\resources\mybatis-mapper" />
<recent name="D:\workspace\xxl-job\xxl-job-admin\src\main\resources" />
<recent name="D:\workspace\xxl-job\xxl-job-executor-samples\xxl-job-executor-sample-springboot\src\main\resources\lib" />
</key>
<key name="CopyClassDialog.RECENTS_KEY">
<recent name="com.xxl.job.executor.inter.entity" />
@ -132,8 +144,8 @@
</component>
<component name="RunAnythingCache">
<option name="myCommands">
<command value="mvn install" />
<command value="mvn clean" />
<command value="mvn install" />
</option>
</component>
<component name="RunManager" selected="Spring Boot.XxlJobExecutorApplication">
@ -221,9 +233,9 @@
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.GenEntity" />
<item itemvalue="JUnit.FramelessApplicationTest.test" />
<item itemvalue="Application.DataUtils" />
<item itemvalue="Application.GenEntity" />
<item itemvalue="Application.DataCenterXxlJob" />
<item itemvalue="Application.PostUtils" />
</list>
@ -495,7 +507,18 @@
<workItem from="1755136940711" duration="605000" />
<workItem from="1755160595798" duration="618000" />
<workItem from="1755566535267" duration="6629000" />
<workItem from="1757658871943" duration="40000" />
<workItem from="1757658871943" duration="2135000" />
<workItem from="1758873748521" duration="169000" />
<workItem from="1759036926254" duration="254000" />
<workItem from="1759037616683" duration="25000" />
<workItem from="1760429201023" duration="192000" />
<workItem from="1760429650217" duration="201000" />
<workItem from="1762302965783" duration="7101000" />
<workItem from="1762334647681" duration="12864000" />
<workItem from="1762423073353" duration="3565000" />
<workItem from="1763027067254" duration="2637000" />
<workItem from="1764577090400" duration="1118000" />
<workItem from="1766380473286" duration="4235000" />
</task>
<task id="LOCAL-00001" summary="初始化提交">
<option name="closed" value="true" />
@ -633,7 +656,31 @@
<option name="project" value="LOCAL" />
<updated>1755134051551</updated>
</task>
<option name="localTasksCounter" value="18" />
<task id="LOCAL-00018" summary="新增字段及接口">
<option name="closed" value="true" />
<created>1757658946076</created>
<option name="number" value="00018" />
<option name="presentableId" value="LOCAL-00018" />
<option name="project" value="LOCAL" />
<updated>1757658946076</updated>
</task>
<task id="LOCAL-00019" summary="新增安全单位接口">
<option name="closed" value="true" />
<created>1762333452815</created>
<option name="number" value="00019" />
<option name="presentableId" value="LOCAL-00019" />
<option name="project" value="LOCAL" />
<updated>1762333452815</updated>
</task>
<task id="LOCAL-00020" summary="新增安全单位接口">
<option name="closed" value="true" />
<created>1762422871294</created>
<option name="number" value="00020" />
<option name="presentableId" value="LOCAL-00020" />
<option name="project" value="LOCAL" />
<updated>1762422871295</updated>
</task>
<option name="localTasksCounter" value="21" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -725,7 +772,8 @@
<MESSAGE value="修新增接口预警" />
<MESSAGE value="修改未执行日计划接口" />
<MESSAGE value="新增字段及接口" />
<option name="LAST_COMMIT_MESSAGE" value="新增字段及接口" />
<MESSAGE value="新增安全单位接口" />
<option name="LAST_COMMIT_MESSAGE" value="新增安全单位接口" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
@ -742,92 +790,97 @@
</line-breakpoint>
<line-breakpoint type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/JjBusinessService.java</url>
<line>254</line>
<line>260</line>
<option name="timeStamp" value="66" />
</line-breakpoint>
<line-breakpoint type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/InterService.java</url>
<line>880</line>
<line>913</line>
<option name="timeStamp" value="72" />
</line-breakpoint>
<line-breakpoint type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/InterService.java</url>
<line>910</line>
<line>943</line>
<option name="timeStamp" value="73" />
</line-breakpoint>
<line-breakpoint type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/JjBusinessService.java</url>
<line>120</line>
<line>126</line>
<option name="timeStamp" value="90" />
</line-breakpoint>
<line-breakpoint type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/JjBusinessService.java</url>
<line>159</line>
<line>165</line>
<option name="timeStamp" value="92" />
</line-breakpoint>
<line-breakpoint type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/JjBusinessService.java</url>
<line>198</line>
<line>204</line>
<option name="timeStamp" value="93" />
</line-breakpoint>
<line-breakpoint type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/JjBusinessService.java</url>
<line>446</line>
<line>452</line>
<option name="timeStamp" value="97" />
</line-breakpoint>
<line-breakpoint type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/JjBusinessService.java</url>
<line>467</line>
<line>473</line>
<option name="timeStamp" value="98" />
</line-breakpoint>
<line-breakpoint type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/JjBusinessService.java</url>
<line>502</line>
<line>508</line>
<option name="timeStamp" value="99" />
</line-breakpoint>
<line-breakpoint type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/JjBusinessService.java</url>
<line>637</line>
<line>643</line>
<option name="timeStamp" value="102" />
</line-breakpoint>
<line-breakpoint type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/JjBusinessService.java</url>
<line>674</line>
<line>680</line>
<option name="timeStamp" value="103" />
</line-breakpoint>
<line-breakpoint type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/JjBusinessService.java</url>
<line>856</line>
<line>862</line>
<option name="timeStamp" value="106" />
</line-breakpoint>
<line-breakpoint type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/JjBusinessService.java</url>
<line>547</line>
<line>553</line>
<option name="timeStamp" value="109" />
</line-breakpoint>
<line-breakpoint type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/JjBusinessService.java</url>
<line>42</line>
<line>48</line>
<option name="timeStamp" value="110" />
</line-breakpoint>
<line-breakpoint type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/JjBusinessService.java</url>
<line>841</line>
<line>847</line>
<option name="timeStamp" value="150" />
</line-breakpoint>
<line-breakpoint type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/JjBusinessService.java</url>
<line>830</line>
<line>836</line>
<option name="timeStamp" value="151" />
</line-breakpoint>
<line-breakpoint type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/service/JjBusinessService.java</url>
<line>784</line>
<line>790</line>
<option name="timeStamp" value="156" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/utils/PostUtils.java</url>
<line>55</line>
<option name="timeStamp" value="162" />
</line-breakpoint>
<line-breakpoint type="java-method">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/mapper/InterMapper.java</url>
<line>71</line>
<line>77</line>
<properties class="com.xxl.job.executor.inter.mapper.InterMapper" method="insertJjBall">
<option name="WATCH_EXIT" value="false" />
</properties>
@ -835,7 +888,7 @@
</line-breakpoint>
<line-breakpoint type="java-method">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/mapper/JjBusinessMapper.java</url>
<line>132</line>
<line>130</line>
<properties class="com.xxl.job.executor.inter.mapper.JjBusinessMapper" method="deleteWarnInfo">
<option name="EMULATED" value="true" />
<option name="WATCH_EXIT" value="false" />
@ -844,7 +897,7 @@
</line-breakpoint>
<line-breakpoint type="java-method">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/mapper/JjBusinessMapper.java</url>
<line>91</line>
<line>89</line>
<properties class="com.xxl.job.executor.inter.mapper.JjBusinessMapper" method="getTeamNum">
<option name="EMULATED" value="true" />
<option name="WATCH_EXIT" value="false" />
@ -853,7 +906,7 @@
</line-breakpoint>
<line-breakpoint type="java-method">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/mapper/JjBusinessMapper.java</url>
<line>305</line>
<line>303</line>
<properties class="com.xxl.job.executor.inter.mapper.JjBusinessMapper" method="getClassRisk">
<option name="EMULATED" value="true" />
<option name="WATCH_EXIT" value="false" />
@ -862,7 +915,7 @@
</line-breakpoint>
<line-breakpoint type="java-method">
<url>file://$PROJECT_DIR$/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/inter/mapper/JjBusinessMapper.java</url>
<line>303</line>
<line>301</line>
<properties class="com.xxl.job.executor.inter.mapper.JjBusinessMapper" method="getTodayWorkInfo">
<option name="EMULATED" value="true" />
<option name="WATCH_EXIT" value="false" />

View File

@ -30,6 +30,10 @@ spring.datasource.url=jdbc:mysql://127.0.0.1:3306/gwjjspaq?useUnicode=true&chara
spring.datasource.username=mroot
spring.datasource.password=bonus@admin123
#spring.datasource.url=jdbc:mysql://192.168.0.7:13306/gwjjspaq?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai
#spring.datasource.username=root
#spring.datasource.password=Bonus@admin123!
#spring.datasource.url=jdbc:mysql://192.168.0.14:4417/gwjjspaq?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai
#spring.datasource.username=root
#spring.datasource.password=Bonus@admin123!

View File

@ -59,7 +59,7 @@
<select id="pageList" parameterType="java.util.HashMap" resultMap="XxlJobInfo">
SELECT <include refid="Base_Column_List" />
FROM xxl_job_info2 AS t
FROM xxl_job_info AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="jobGroup gt 0">
AND t.job_group = #{jobGroup}
@ -83,7 +83,7 @@
<select id="pageListCount" parameterType="java.util.HashMap" resultType="int">
SELECT count(1)
FROM xxl_job_info2 AS t
FROM xxl_job_info AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="jobGroup gt 0">
AND t.job_group = #{jobGroup}
@ -104,7 +104,7 @@
</select>
<insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobInfo" useGeneratedKeys="true" keyProperty="id" >
INSERT INTO xxl_job_info2 (
INSERT INTO xxl_job_info (
job_group,
job_desc,
add_time,
@ -161,12 +161,12 @@
<select id="loadById" parameterType="java.util.HashMap" resultMap="XxlJobInfo">
SELECT <include refid="Base_Column_List" />
FROM xxl_job_info2 AS t
FROM xxl_job_info AS t
WHERE t.id = #{id}
</select>
<update id="update" parameterType="com.xxl.job.admin.core.model.XxlJobInfo" >
UPDATE xxl_job_info2
UPDATE xxl_job_info
SET
job_group = #{jobGroup},
job_desc = #{jobDesc},
@ -195,25 +195,25 @@
<delete id="delete" parameterType="java.util.HashMap">
DELETE
FROM xxl_job_info2
FROM xxl_job_info
WHERE id = #{id}
</delete>
<select id="getJobsByGroup" parameterType="java.util.HashMap" resultMap="XxlJobInfo">
SELECT <include refid="Base_Column_List" />
FROM xxl_job_info2 AS t
FROM xxl_job_info AS t
WHERE t.job_group = #{jobGroup}
</select>
<select id="findAllCount" resultType="int">
SELECT count(1)
FROM xxl_job_info2
FROM xxl_job_info
</select>
<select id="scheduleJobQuery" parameterType="java.util.HashMap" resultMap="XxlJobInfo">
SELECT <include refid="Base_Column_List" />
FROM xxl_job_info2 AS t
FROM xxl_job_info AS t
WHERE t.trigger_status = 1
and t.trigger_next_time <![CDATA[ <= ]]> #{maxNextTime}
ORDER BY id ASC
@ -221,7 +221,7 @@
</select>
<update id="scheduleUpdate" parameterType="com.xxl.job.admin.core.model.XxlJobInfo" >
UPDATE xxl_job_info2
UPDATE xxl_job_info
SET
trigger_last_time = #{triggerLastTime},
trigger_next_time = #{triggerNextTime},

View File

@ -1,232 +0,0 @@
<?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="com.xxl.job.admin.dao.XxlJobInfoDao">
<resultMap id="XxlJobInfo" type="com.xxl.job.admin.core.model.XxlJobInfo" >
<result column="id" property="id" />
<result column="job_group" property="jobGroup" />
<result column="job_desc" property="jobDesc" />
<result column="add_time" property="addTime" />
<result column="update_time" property="updateTime" />
<result column="author" property="author" />
<result column="alarm_email" property="alarmEmail" />
<result column="schedule_type" property="scheduleType" />
<result column="schedule_conf" property="scheduleConf" />
<result column="misfire_strategy" property="misfireStrategy" />
<result column="executor_route_strategy" property="executorRouteStrategy" />
<result column="executor_handler" property="executorHandler" />
<result column="executor_param" property="executorParam" />
<result column="executor_block_strategy" property="executorBlockStrategy" />
<result column="executor_timeout" property="executorTimeout" />
<result column="executor_fail_retry_count" property="executorFailRetryCount" />
<result column="glue_type" property="glueType" />
<result column="glue_source" property="glueSource" />
<result column="glue_remark" property="glueRemark" />
<result column="glue_updatetime" property="glueUpdatetime" />
<result column="child_jobid" property="childJobId" />
<result column="trigger_status" property="triggerStatus" />
<result column="trigger_last_time" property="triggerLastTime" />
<result column="trigger_next_time" property="triggerNextTime" />
</resultMap>
<sql id="Base_Column_List">
t.id,
t.job_group,
t.job_desc,
t.add_time,
t.update_time,
t.author,
t.alarm_email,
t.schedule_type,
t.schedule_conf,
t.misfire_strategy,
t.executor_route_strategy,
t.executor_handler,
t.executor_param,
t.executor_block_strategy,
t.executor_timeout,
t.executor_fail_retry_count,
t.glue_type,
t.glue_source,
t.glue_remark,
t.glue_updatetime,
t.child_jobid,
t.trigger_status,
t.trigger_last_time,
t.trigger_next_time
</sql>
<select id="pageList" parameterType="java.util.HashMap" resultMap="XxlJobInfo">
SELECT <include refid="Base_Column_List" />
FROM xxl_job_info2 AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="jobGroup gt 0">
AND t.job_group = #{jobGroup}
</if>
<if test="triggerStatus gte 0">
AND t.trigger_status = #{triggerStatus}
</if>
<if test="jobDesc != null and jobDesc != ''">
AND t.job_desc like CONCAT(CONCAT('%', #{jobDesc}), '%')
</if>
<if test="executorHandler != null and executorHandler != ''">
AND t.executor_handler like CONCAT(CONCAT('%', #{executorHandler}), '%')
</if>
<if test="author != null and author != ''">
AND t.author like CONCAT(CONCAT('%', #{author}), '%')
</if>
</trim>
ORDER BY id DESC
LIMIT #{offset}, #{pagesize}
</select>
<select id="pageListCount" parameterType="java.util.HashMap" resultType="int">
SELECT count(1)
FROM xxl_job_info2 AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="jobGroup gt 0">
AND t.job_group = #{jobGroup}
</if>
<if test="triggerStatus gte 0">
AND t.trigger_status = #{triggerStatus}
</if>
<if test="jobDesc != null and jobDesc != ''">
AND t.job_desc like CONCAT(CONCAT('%', #{jobDesc}), '%')
</if>
<if test="executorHandler != null and executorHandler != ''">
AND t.executor_handler like CONCAT(CONCAT('%', #{executorHandler}), '%')
</if>
<if test="author != null and author != ''">
AND t.author like CONCAT(CONCAT('%', #{author}), '%')
</if>
</trim>
</select>
<insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobInfo" useGeneratedKeys="true" keyProperty="id" >
INSERT INTO xxl_job_info2 (
job_group,
job_desc,
add_time,
update_time,
author,
alarm_email,
schedule_type,
schedule_conf,
misfire_strategy,
executor_route_strategy,
executor_handler,
executor_param,
executor_block_strategy,
executor_timeout,
executor_fail_retry_count,
glue_type,
glue_source,
glue_remark,
glue_updatetime,
child_jobid,
trigger_status,
trigger_last_time,
trigger_next_time
) VALUES (
#{jobGroup},
#{jobDesc},
#{addTime},
#{updateTime},
#{author},
#{alarmEmail},
#{scheduleType},
#{scheduleConf},
#{misfireStrategy},
#{executorRouteStrategy},
#{executorHandler},
#{executorParam},
#{executorBlockStrategy},
#{executorTimeout},
#{executorFailRetryCount},
#{glueType},
#{glueSource},
#{glueRemark},
#{glueUpdatetime},
#{childJobId},
#{triggerStatus},
#{triggerLastTime},
#{triggerNextTime}
);
<!--<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID()
/*SELECT @@IDENTITY AS id*/
</selectKey>-->
</insert>
<select id="loadById" parameterType="java.util.HashMap" resultMap="XxlJobInfo">
SELECT <include refid="Base_Column_List" />
FROM xxl_job_info2 AS t
WHERE t.id = #{id}
</select>
<update id="update" parameterType="com.xxl.job.admin.core.model.XxlJobInfo" >
UPDATE xxl_job_info2
SET
job_group = #{jobGroup},
job_desc = #{jobDesc},
update_time = #{updateTime},
author = #{author},
alarm_email = #{alarmEmail},
schedule_type = #{scheduleType},
schedule_conf = #{scheduleConf},
misfire_strategy = #{misfireStrategy},
executor_route_strategy = #{executorRouteStrategy},
executor_handler = #{executorHandler},
executor_param = #{executorParam},
executor_block_strategy = #{executorBlockStrategy},
executor_timeout = ${executorTimeout},
executor_fail_retry_count = ${executorFailRetryCount},
glue_type = #{glueType},
glue_source = #{glueSource},
glue_remark = #{glueRemark},
glue_updatetime = #{glueUpdatetime},
child_jobid = #{childJobId},
trigger_status = #{triggerStatus},
trigger_last_time = #{triggerLastTime},
trigger_next_time = #{triggerNextTime}
WHERE id = #{id}
</update>
<delete id="delete" parameterType="java.util.HashMap">
DELETE
FROM xxl_job_info2
WHERE id = #{id}
</delete>
<select id="getJobsByGroup" parameterType="java.util.HashMap" resultMap="XxlJobInfo">
SELECT <include refid="Base_Column_List" />
FROM xxl_job_info2 AS t
WHERE t.job_group = #{jobGroup}
</select>
<select id="findAllCount" resultType="int">
SELECT count(1)
FROM xxl_job_info2
</select>
<select id="scheduleJobQuery" parameterType="java.util.HashMap" resultMap="XxlJobInfo">
SELECT <include refid="Base_Column_List" />
FROM xxl_job_info2 AS t
WHERE t.trigger_status = 1
and t.trigger_next_time <![CDATA[ <= ]]> #{maxNextTime}
ORDER BY id ASC
LIMIT #{pagesize}
</select>
<update id="scheduleUpdate" parameterType="com.xxl.job.admin.core.model.XxlJobInfo" >
UPDATE xxl_job_info2
SET
trigger_last_time = #{triggerLastTime},
trigger_next_time = #{triggerNextTime},
trigger_status = #{triggerStatus}
WHERE id = #{id}
</update>
</mapper>

View File

@ -0,0 +1,20 @@
package com.xxl.job.executor.inter.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
@Mapper
public interface DbDistLockUtilMapper {
/**
* 更新锁
* @param lockKey
* @param now
*/
void update(@Param("lockKey") String lockKey, @Param("now")Date now);
int insert(@Param("jobId") Long jobId, @Param("lockKey") String lockKey,@Param("lockOwner") String lockOwner,@Param("now") Date now,@Param("expireTime") Date expireTime);
void delete(@Param("lockKey") String lockKey,@Param("lockOwner") String lockOwner);
}

View File

@ -0,0 +1,67 @@
package com.xxl.job.executor.inter.service;
import com.xxl.job.executor.inter.mapper.DbDistLockUtilMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Date;
@Service
@Slf4j
@Component
public class DbDistLockUtil {
@Value("${xxl.job.executor.port}")
private String port;
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private DbDistLockUtilMapper mapper;
// 获取锁返回true表示获取成功
public boolean tryLock(Long jobId, long expireSeconds) {
String lockKey = "xxl_job_lock_" + jobId;
// 执行器唯一标识IP+端口避免同机多实例冲突
String lockOwner = getLocalIp() + ":" + port;
Date now = new Date();
Date expireTime = new Date(now.getTime() + expireSeconds * 1000);
try {
// 1. 先清理过期锁防止死锁
mapper.update( lockKey, now);
// 2. 插入锁唯一键约束仅一个执行器能成功
int affected=mapper.insert( jobId, lockKey, lockOwner, now, expireTime);
return affected > 0;
} catch (Exception e) {
log.error(e.getMessage(), e);
// 唯一键冲突时说明已被其他执行器抢占
return false;
}
}
// 释放锁仅释放自己持有的锁
public void releaseLock(Long jobId) {
String lockKey = "xxl_job_lock_" + jobId;
String lockOwner = getLocalIp() + ":" + port;
mapper.delete(lockKey, lockOwner);
}
// 辅助获取本地IP
private String getLocalIp() {
try {
return InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
return "127.0.0.1";
}
}
}

View File

@ -1,6 +1,8 @@
package com.xxl.job.executor.service.jobhandler;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.executor.inter.service.DbDistLockUtil;
import com.xxl.job.executor.inter.service.JjBusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -16,14 +18,27 @@ public class JJBusinessXxlJob {
@Autowired
private JjBusinessService service ;
@Autowired
DbDistLockUtil lockUtil;
/**
* 预警管理-今日未施工
*/
@XxlJob("todayNoWork")
public void todayNoWork(){
service.todayNoWork();
Long jobId = XxlJobHelper.getJobId();
boolean locked = lockUtil.tryLock(jobId, 60);
if (!locked) {
XxlJobHelper.log("已有执行器执行该任务,本次放弃");
XxlJobHelper.handleFail("任务已在执行");
return;
}
try {
// 核心业务逻辑
service.todayNoWork();
} finally {
// 最终释放锁防止任务异常导致锁残留
lockUtil.releaseLock(jobId);
}
}
/**
@ -31,7 +46,20 @@ public class JJBusinessXxlJob {
*/
@XxlJob("todayNewTeam")
public void todayNewTeam(){
service.todayNewTeam();
Long jobId = XxlJobHelper.getJobId();
boolean locked = lockUtil.tryLock(jobId, 60);
if (!locked) {
XxlJobHelper.log("已有执行器执行该任务,本次放弃");
XxlJobHelper.handleFail("任务已在执行");
return;
}
try {
// 核心业务逻辑
service.todayNewTeam();
} finally {
// 最终释放锁防止任务异常导致锁残留
lockUtil.releaseLock(jobId);
}
}
/**
@ -39,14 +67,42 @@ public class JJBusinessXxlJob {
*/
@XxlJob("todaySevenNoWork")
public void todaySevenNoWork(){
service.todaySevenNoWork();
Long jobId = XxlJobHelper.getJobId();
boolean locked = lockUtil.tryLock(jobId, 60);
if (!locked) {
XxlJobHelper.log("已有执行器执行该任务,本次放弃");
XxlJobHelper.handleFail("任务已在执行");
return;
}
try {
// 核心业务逻辑
service.todaySevenNoWork();
} finally {
// 最终释放锁防止任务异常导致锁残留
lockUtil.releaseLock(jobId);
}
}
/**
* 预警管理-人数变化大
*/
@XxlJob("todayUseNumChange")
public void todayUseNumChange(){
service.todayUseNumChange();
Long jobId = XxlJobHelper.getJobId();
boolean locked = lockUtil.tryLock(jobId, 60);
if (!locked) {
XxlJobHelper.log("已有执行器执行该任务,本次放弃");
XxlJobHelper.handleFail("任务已在执行");
return;
}
try {
// 核心业务逻辑
service.todayUseNumChange();
} finally {
// 最终释放锁防止任务异常导致锁残留
lockUtil.releaseLock(jobId);
}
}
/**
@ -54,7 +110,21 @@ public class JJBusinessXxlJob {
*/
@XxlJob("todayGxChange")
public void todayGxChange(){
service.todayGxChange();
Long jobId = XxlJobHelper.getJobId();
boolean locked = lockUtil.tryLock(jobId, 60);
if (!locked) {
XxlJobHelper.log("已有执行器执行该任务,本次放弃");
XxlJobHelper.handleFail("任务已在执行");
return;
}
try {
// 核心业务逻辑
service.todayGxChange();
} finally {
// 最终释放锁防止任务异常导致锁残留
lockUtil.releaseLock(jobId);
}
}
/**
@ -62,7 +132,20 @@ public class JJBusinessXxlJob {
*/
@XxlJob("todayWorkChange")
public void todayWorkChange(){
service.todayWorkChange();
Long jobId = XxlJobHelper.getJobId();
boolean locked = lockUtil.tryLock(jobId, 60);
if (!locked) {
XxlJobHelper.log("已有执行器执行该任务,本次放弃");
XxlJobHelper.handleFail("任务已在执行");
return;
}
try {
// 核心业务逻辑
service.todayWorkChange();
} finally {
// 最终释放锁防止任务异常导致锁残留
lockUtil.releaseLock(jobId);
}
}
/**
@ -71,7 +154,21 @@ public class JJBusinessXxlJob {
@XxlJob("todayWarnFpByUserId")
@PostConstruct
public void todayWarnFpByUserId(){
Long jobId = XxlJobHelper.getJobId();
boolean locked = lockUtil.tryLock(jobId, 60);
if (!locked) {
XxlJobHelper.log("已有执行器执行该任务,本次放弃");
XxlJobHelper.handleFail("任务已在执行");
return;
}
try {
// 核心业务逻辑
service.todayWarnFpByUserId();
} finally {
// 最终释放锁防止任务异常导致锁残留
lockUtil.releaseLock(jobId);
}
}
/**
@ -80,7 +177,21 @@ public class JJBusinessXxlJob {
*/
@XxlJob("startEndWork")
public void startEndWork(){
service.startEndWork();
Long jobId = XxlJobHelper.getJobId();
boolean locked = lockUtil.tryLock(jobId, 60);
if (!locked) {
XxlJobHelper.log("已有执行器执行该任务,本次放弃");
XxlJobHelper.handleFail("任务已在执行");
return;
}
try {
// 核心业务逻辑
service.startEndWork();
} finally {
// 最终释放锁防止任务异常导致锁残留
lockUtil.releaseLock(jobId);
}
}
/**
@ -89,7 +200,21 @@ public class JJBusinessXxlJob {
@XxlJob("getBallFew")
public void getBallFew(){
service.getBallFew();
Long jobId = XxlJobHelper.getJobId();
boolean locked = lockUtil.tryLock(jobId, 60);
if (!locked) {
XxlJobHelper.log("已有执行器执行该任务,本次放弃");
XxlJobHelper.handleFail("任务已在执行");
return;
}
try {
// 核心业务逻辑
service.getBallFew();
} finally {
// 最终释放锁防止任务异常导致锁残留
lockUtil.releaseLock(jobId);
}
}
/**
@ -97,14 +222,42 @@ public class JJBusinessXxlJob {
*/
@XxlJob("getBallUpDown")
public void getBallUpDown(){
Long jobId = XxlJobHelper.getJobId();
boolean locked = lockUtil.tryLock(jobId, 60);
if (!locked) {
XxlJobHelper.log("已有执行器执行该任务,本次放弃");
XxlJobHelper.handleFail("任务已在执行");
return;
}
try {
// 核心业务逻辑
service.getBallUpDown();
} finally {
// 最终释放锁防止任务异常导致锁残留
lockUtil.releaseLock(jobId);
}
}
/**
* 对施工班组进行初始化添加
*/
@XxlJob("addNewTeam")
private void addNewTeam(){
service.addNewTeam();
Long jobId = XxlJobHelper.getJobId();
boolean locked = lockUtil.tryLock(jobId, 60);
if (!locked) {
XxlJobHelper.log("已有执行器执行该任务,本次放弃");
XxlJobHelper.handleFail("任务已在执行");
return;
}
try {
// 核心业务逻辑
service.addNewTeam();
} finally {
// 最终释放锁防止任务异常导致锁残留
lockUtil.releaseLock(jobId);
}
}
/**
@ -113,7 +266,20 @@ public class JJBusinessXxlJob {
@XxlJob("threeSpan")
@PostConstruct
private void threeSpan(){
service.threeSpan();
Long jobId = XxlJobHelper.getJobId();
boolean locked = lockUtil.tryLock(jobId, 60);
if (!locked) {
XxlJobHelper.log("已有执行器执行该任务,本次放弃");
XxlJobHelper.handleFail("任务已在执行");
return;
}
try {
// 核心业务逻辑
service.threeSpan();
} finally {
// 最终释放锁防止任务异常导致锁残留
lockUtil.releaseLock(jobId);
}
}
/**
@ -122,7 +288,20 @@ public class JJBusinessXxlJob {
@XxlJob("teamThreeSpan")
@PostConstruct
private void teamThreeSpan(){
service.teamThreeSpan();
Long jobId = XxlJobHelper.getJobId();
boolean locked = lockUtil.tryLock(jobId, 60);
if (!locked) {
XxlJobHelper.log("已有执行器执行该任务,本次放弃");
XxlJobHelper.handleFail("任务已在执行");
return;
}
try {
// 核心业务逻辑
service.teamThreeSpan();
} finally {
// 最终释放锁防止任务异常导致锁残留
lockUtil.releaseLock(jobId);
}
}
@ -133,12 +312,38 @@ public class JJBusinessXxlJob {
@XxlJob("getWorkGxNoWork")
@PostConstruct
public void getWorkGxNoWork(){
service.getWorkGxNoWork();
}
Long jobId = XxlJobHelper.getJobId();
boolean locked = lockUtil.tryLock(jobId, 60);
if (!locked) {
XxlJobHelper.log("已有执行器执行该任务,本次放弃");
XxlJobHelper.handleFail("任务已在执行");
return;
}
try {
// 核心业务逻辑
service.getWorkGxNoWork();
} finally {
// 最终释放锁防止任务异常导致锁残留
lockUtil.releaseLock(jobId);
}
}
@PostConstruct
private void addNewTeam2(){
service.addNewTeam2();
Long jobId = XxlJobHelper.getJobId();
boolean locked = lockUtil.tryLock(jobId, 60);
if (!locked) {
XxlJobHelper.log("已有执行器执行该任务,本次放弃");
XxlJobHelper.handleFail("任务已在执行");
return;
}
try {
// 核心业务逻辑
service.addNewTeam2();
} finally {
// 最终释放锁防止任务异常导致锁残留
lockUtil.releaseLock(jobId);
}
}
}

View File

@ -4,8 +4,9 @@ server.port=18084
#spring.main.web-environment=false
# log config
logging.config=classpath:logback.xml
#xxl.job.admin.addresses=http://20.51.8.9:18083/xxl-job-admin
#xxl.job.admin.addresses=http://20.51.8.10:18083/xxl-job-admin
xxl.job.admin.addresses=http://127.0.0.1:18083/xxl-job-admin
#xxl.job.admin.addresses=http://192.168.0.7:58883/xxl-job-admin
#xxl.job.admin.addresses=http://192.168.0.14:58883/xxl-job-admin
### xxl-job, access token
xxl.job.accessToken=default_token
@ -31,6 +32,9 @@ spring.datasource.url=jdbc:mysql://127.0.0.1:3306/gwjjspaq?useUnicode=true&chara
spring.datasource.username=mroot
spring.datasource.password=bonus@admin123
#spring.datasource.url=jdbc:mysql://192.168.0.7:13306/gwjjspaq?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai
#spring.datasource.username=root
#spring.datasource.password=Bonus@admin123!
#spring.datasource.url=jdbc:mysql://192.168.0.14:4417/gwjjspaq?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai
#spring.datasource.username=root
#spring.datasource.password=Bonus@admin123!

View File

@ -0,0 +1,16 @@
<?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="com.xxl.job.executor.inter.mapper.DbDistLockUtilMapper">
<insert id="insert">
INSERT INTO xxl_job_dist_lock (job_id, lock_key, lock_owner, lock_time, expire_time) VALUES
(#{jobId}, #{lockKey}, #{lockOwner}, #{now}, #{expireTime})
</insert>
<delete id="update">
DELETE FROM xxl_job_dist_lock WHERE lock_key = #{lockKey} AND expire_time &lt; #{now}
</delete>
<delete id="delete">
DELETE FROM xxl_job_dist_lock WHERE lock_key = #{lockKey} AND lock_owner = #{lockOwner}
</delete>
</mapper>