Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
Z
zlmy-cloud
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zlmy
zlmy-cloud
Commits
ae8660ef
Commit
ae8660ef
authored
Oct 24, 2025
by
鲁鸿波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
有限空间等各类作业类型时间未做限制均可起票,如高度作业8小时
parent
6578a2f3
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
202 additions
and
0 deletions
+202
-0
DangerousOperationValidator.java
...a/com/testor/common/util/DangerousOperationValidator.java
+135
-0
THazardWorkPlanController.java
...r/module/hazard/controller/THazardWorkPlanController.java
+10
-0
THazardWorkPlanService.java
.../testor/module/hazard/service/THazardWorkPlanService.java
+11
-0
THazardWorkPlanServiceImpl.java
...odule/hazard/service/impl/THazardWorkPlanServiceImpl.java
+34
-0
NewSysDictDataService.java
.../com/testor/module/sys/service/NewSysDictDataService.java
+7
-0
NewSysDictDataServiceImpl.java
...or/module/sys/service/impl/NewSysDictDataServiceImpl.java
+5
-0
No files found.
zlmy-modules/zlmy-boot/src/main/java/com/testor/common/util/DangerousOperationValidator.java
0 → 100644
View file @
ae8660ef
package
com
.
testor
.
common
.
util
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
DangerousOperationValidator
{
public
enum
OperationType
{
HOT_WORK
(
"动火作业"
),
HEIGHT_WORK
(
"高处作业"
),
CONFINED_SPACE
(
"有限空间"
),
TEMP_ELECTRICITY
(
"临时用电"
),
FUMIGATION
(
"熏蒸作业"
),
IN_OUT_WAREHOUSE
(
"进出仓"
);
private
final
String
name
;
OperationType
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getName
()
{
return
name
;
}
public
static
OperationType
fromDictValue
(
String
dictValue
)
{
for
(
OperationType
type
:
values
())
{
if
(
type
.
getName
().
equals
(
dictValue
))
{
return
type
;
}
}
return
null
;
}
}
public
enum
DangerLevel
{
HIGH
(
"高度危险"
),
MEDIUM
(
"较大危险"
),
LOW
(
"一般危险"
);
private
final
String
level
;
DangerLevel
(
String
level
)
{
this
.
level
=
level
;
}
public
String
getLevel
()
{
return
level
;
}
public
static
DangerLevel
fromDictValue
(
String
dictValue
)
{
for
(
DangerLevel
level
:
values
())
{
if
(
level
.
getLevel
().
equals
(
dictValue
))
{
return
level
;
}
}
return
null
;
}
}
private
static
final
Map
<
OperationType
,
Map
<
DangerLevel
,
Integer
>>
TIME_LIMITS
=
new
HashMap
<>();
static
{
// 动火作业
Map
<
DangerLevel
,
Integer
>
hotWorkMap
=
new
HashMap
<>();
hotWorkMap
.
put
(
DangerLevel
.
HIGH
,
8
);
hotWorkMap
.
put
(
DangerLevel
.
MEDIUM
,
12
);
hotWorkMap
.
put
(
DangerLevel
.
LOW
,
72
);
TIME_LIMITS
.
put
(
OperationType
.
HOT_WORK
,
hotWorkMap
);
// 高处作业
Map
<
DangerLevel
,
Integer
>
heightWorkMap
=
new
HashMap
<>();
heightWorkMap
.
put
(
DangerLevel
.
HIGH
,
12
);
heightWorkMap
.
put
(
DangerLevel
.
MEDIUM
,
24
);
heightWorkMap
.
put
(
DangerLevel
.
LOW
,
7
*
24
);
TIME_LIMITS
.
put
(
OperationType
.
HEIGHT_WORK
,
heightWorkMap
);
// 有限空间
Map
<
DangerLevel
,
Integer
>
confinedSpaceMap
=
new
HashMap
<>();
confinedSpaceMap
.
put
(
DangerLevel
.
HIGH
,
8
);
confinedSpaceMap
.
put
(
DangerLevel
.
MEDIUM
,
8
);
confinedSpaceMap
.
put
(
DangerLevel
.
LOW
,
8
);
TIME_LIMITS
.
put
(
OperationType
.
CONFINED_SPACE
,
confinedSpaceMap
);
// 临时用电
Map
<
DangerLevel
,
Integer
>
tempElectricityMap
=
new
HashMap
<>();
tempElectricityMap
.
put
(
DangerLevel
.
HIGH
,
8
);
tempElectricityMap
.
put
(
DangerLevel
.
MEDIUM
,
8
);
tempElectricityMap
.
put
(
DangerLevel
.
LOW
,
8
);
TIME_LIMITS
.
put
(
OperationType
.
TEMP_ELECTRICITY
,
tempElectricityMap
);
// 熏蒸作业
Map
<
DangerLevel
,
Integer
>
fumigationMap
=
new
HashMap
<>();
fumigationMap
.
put
(
DangerLevel
.
HIGH
,
7
*
24
);
// 其他等级不设置限制
TIME_LIMITS
.
put
(
OperationType
.
FUMIGATION
,
fumigationMap
);
// 进出仓
Map
<
DangerLevel
,
Integer
>
inOutWarehouseMap
=
new
HashMap
<>();
inOutWarehouseMap
.
put
(
DangerLevel
.
HIGH
,
12
);
inOutWarehouseMap
.
put
(
DangerLevel
.
MEDIUM
,
24
);
inOutWarehouseMap
.
put
(
DangerLevel
.
LOW
,
72
);
TIME_LIMITS
.
put
(
OperationType
.
IN_OUT_WAREHOUSE
,
inOutWarehouseMap
);
}
public
static
String
validateOperation
(
String
workTypeDictValue
,
String
workLevelDictValue
,
double
actualHours
)
{
// 转换为枚举类型
OperationType
type
=
OperationType
.
fromDictValue
(
workTypeDictValue
);
DangerLevel
level
=
DangerLevel
.
fromDictValue
(
workLevelDictValue
);
// 如果类型或等级不在规则范围内,直接返回安全
if
(
type
==
null
||
level
==
null
)
{
return
"在安全时间内"
;
}
// 获取该类型的时间限制映射
Map
<
DangerLevel
,
Integer
>
levelMap
=
TIME_LIMITS
.
get
(
type
);
if
(
levelMap
==
null
)
{
return
"在安全时间内"
;
}
// 获取具体等级的时间限制
Integer
timeLimit
=
levelMap
.
get
(
level
);
// 如果没有找到该等级的限制,返回安全
if
(
timeLimit
==
null
)
{
return
"在安全时间内"
;
}
// 检查实际时长是否超过限制
int
actualHoursInt
=
(
int
)
Math
.
ceil
(
actualHours
);
if
(
actualHoursInt
>
timeLimit
)
{
return
String
.
format
(
"%s-%s作业超过规定时间%d小时,规定最大时长为%d小时。"
,
type
.
getName
(),
level
.
getLevel
(),
actualHoursInt
-
timeLimit
,
timeLimit
);
}
return
"在安全时间内"
;
}
}
\ No newline at end of file
zlmy-modules/zlmy-boot/src/main/java/com/testor/module/hazard/controller/THazardWorkPlanController.java
View file @
ae8660ef
...
@@ -306,5 +306,15 @@ public class THazardWorkPlanController extends SuperController
...
@@ -306,5 +306,15 @@ public class THazardWorkPlanController extends SuperController
}
}
}
}
@ApiOperation
(
value
=
"危险作业计划时间是否合规"
,
notes
=
"危险作业计划时间是否合规"
)
@GetMapping
(
value
=
"/validateOperation"
)
public
BaseResponse
validateOperation
(
String
workType
,
String
workLevel
,
String
scheduledStartTime
,
String
scheduledEndTime
)
throws
BusinessException
{
BaseResponse
<
BizGeneralResponse
>
baseResponse
=
new
BaseResponse
<>();
String
result
=
tHazardWorkPlanService
.
validateOperation
(
workType
,
workLevel
,
scheduledStartTime
,
scheduledEndTime
);
baseResponse
.
setMsg
(
result
);
return
baseResponse
;
}
}
}
zlmy-modules/zlmy-boot/src/main/java/com/testor/module/hazard/service/THazardWorkPlanService.java
View file @
ae8660ef
...
@@ -91,4 +91,15 @@ public interface THazardWorkPlanService extends SuperService<THazardWorkPlan> {
...
@@ -91,4 +91,15 @@ public interface THazardWorkPlanService extends SuperService<THazardWorkPlan> {
List
<
TaskInfoDTO
>
getAllTaskApprovers
(
String
processInstanceId
,
String
planId
);
List
<
TaskInfoDTO
>
getAllTaskApprovers
(
String
processInstanceId
,
String
planId
);
public
String
getOrgNamesByOrgIds
(
String
orgId
);
public
String
getOrgNamesByOrgIds
(
String
orgId
);
/**
* 危险作业计划时间是否合规
* @param workType 危险作业类型
* @param workLevel 危险等级
* @param scheduledStartTime 计划开始时间
* @param scheduledEndTime 计划结束时间
* @return
*/
String
validateOperation
(
String
workType
,
String
workLevel
,
String
scheduledStartTime
,
String
scheduledEndTime
);
}
}
zlmy-modules/zlmy-boot/src/main/java/com/testor/module/hazard/service/impl/THazardWorkPlanServiceImpl.java
View file @
ae8660ef
...
@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...
@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.testor.biz.file.model.domain.SysFile
;
import
com.testor.biz.file.model.domain.SysFile
;
import
com.testor.biz.file.service.SysFileService
;
import
com.testor.biz.file.service.SysFileService
;
import
com.testor.biz.sys.dict.data.model.domain.SysDictData
;
import
com.testor.biz.sys.dict.data.model.domain.SysDictData
;
import
com.testor.biz.sys.dict.data.service.SysDictDataService
;
import
com.testor.biz.sys.user.model.domain.SysUser
;
import
com.testor.biz.sys.user.model.domain.SysUser
;
import
com.testor.biz.sys.user.service.SysUserService
;
import
com.testor.biz.sys.user.service.SysUserService
;
import
com.testor.common.constant.RemindConstants
;
import
com.testor.common.constant.RemindConstants
;
...
@@ -19,6 +20,7 @@ import com.testor.common.core.constant.Constants;
...
@@ -19,6 +20,7 @@ import com.testor.common.core.constant.Constants;
import
com.testor.common.core.utils.StringUtils
;
import
com.testor.common.core.utils.StringUtils
;
import
com.testor.common.core.utils.poi.ExcelUtil
;
import
com.testor.common.core.utils.poi.ExcelUtil
;
import
com.testor.common.util.BeanConverUtil
;
import
com.testor.common.util.BeanConverUtil
;
import
com.testor.common.util.DangerousOperationValidator
;
import
com.testor.common.util.DateUtil
;
import
com.testor.common.util.DateUtil
;
import
com.testor.common.util.FileUtil
;
import
com.testor.common.util.FileUtil
;
import
com.testor.module.contractor.ledger.model.domain.TContractorInfo
;
import
com.testor.module.contractor.ledger.model.domain.TContractorInfo
;
...
@@ -91,6 +93,10 @@ import java.io.IOException;
...
@@ -91,6 +93,10 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.time.Duration
;
import
java.time.ZoneId
;
import
java.time.ZonedDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -821,6 +827,34 @@ public class THazardWorkPlanServiceImpl extends SuperServiceImpl<THazardWorkPlan
...
@@ -821,6 +827,34 @@ public class THazardWorkPlanServiceImpl extends SuperServiceImpl<THazardWorkPlan
return
null
;
return
null
;
}
}
@Override
public
String
validateOperation
(
String
workType
,
String
workLevel
,
String
scheduledStartTime
,
String
scheduledEndTime
)
{
SysDictData
workTypeDictData
=
sysDictDataService
.
getDictDataById
(
workType
);
SysDictData
workLevelDictData
=
sysDictDataService
.
getDictDataById
(
workLevel
);
String
result
=
"在安全时间内"
;
if
(
null
!=
workTypeDictData
&&
null
!=
workLevelDictData
){
double
hoursDifference
=
calculateHoursDifferenceWithZone
(
scheduledStartTime
,
scheduledEndTime
);
result
=
DangerousOperationValidator
.
validateOperation
(
workTypeDictData
.
getDictValue
(),
workLevelDictData
.
getDictValue
(),
hoursDifference
);
}
return
result
;
}
// 添加时区支持
public
static
double
calculateHoursDifferenceWithZone
(
String
startTime
,
String
endTime
)
{
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
)
.
withZone
(
ZoneId
.
of
(
"Asia/Shanghai"
));
ZonedDateTime
start
=
ZonedDateTime
.
parse
(
startTime
,
formatter
);
ZonedDateTime
end
=
ZonedDateTime
.
parse
(
endTime
,
formatter
);
Duration
duration
=
Duration
.
between
(
start
,
end
);
return
duration
.
toMinutes
()
/
60.0
;
}
/**
/**
* 提取 0-id,1-id ,格式中的id字段 返回如 id1,id2
* 提取 0-id,1-id ,格式中的id字段 返回如 id1,id2
*
*
...
...
zlmy-modules/zlmy-boot/src/main/java/com/testor/module/sys/service/NewSysDictDataService.java
View file @
ae8660ef
...
@@ -84,4 +84,11 @@ public interface NewSysDictDataService {
...
@@ -84,4 +84,11 @@ public interface NewSysDictDataService {
* @return
* @return
*/
*/
List
<
String
>
getDictIdsByParentKeyAndType
(
String
parentKey
,
String
type
);
List
<
String
>
getDictIdsByParentKeyAndType
(
String
parentKey
,
String
type
);
/**
* 根据字典id获取字典数据
* @param dictDataId 字典id
* @return
*/
SysDictData
getDictDataById
(
String
dictDataId
);
}
}
zlmy-modules/zlmy-boot/src/main/java/com/testor/module/sys/service/impl/NewSysDictDataServiceImpl.java
View file @
ae8660ef
...
@@ -156,4 +156,9 @@ public class NewSysDictDataServiceImpl implements NewSysDictDataService {
...
@@ -156,4 +156,9 @@ public class NewSysDictDataServiceImpl implements NewSysDictDataService {
}
}
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
}
@Override
public
SysDictData
getDictDataById
(
String
dictDataId
)
{
return
sysDictDataService
.
getById
(
dictDataId
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment