切换导航条
此项目
正在载入...
登录
zhangFan
/
analysis_imf
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
朱兆平
2 years ago
提交
ef4d2bee36064d5c34291e7603e6292a4a8c058c
1 个父辈
8a1495f3
优化关锁在动态验放中的逻辑以及流转申请核销的逻辑
显示空白字符变更
内嵌
并排对比
正在显示
12 个修改的文件
包含
456 行增加
和
32 行删除
src/main/java/com/sy/bean/DEVDEBUG.java
src/main/java/com/sy/controller/CustomsLockController.java
src/main/java/com/sy/controller/EnginChanelController.java
src/main/java/com/sy/groovy/LockNoticeCheck.groovy
src/main/java/com/sy/groovy/WeightCheckImportDlv.groovy
src/main/java/com/sy/groovy/X21FormReleaseCheck.groovy
src/main/java/com/sy/service/EnginCheckService.java
src/main/java/com/sy/service/WeightCheckHandleService.java
src/main/java/com/sy/service/impl/EnginCheckServiceImpl.java
src/main/java/com/sy/service/impl/WeightCheckHandleServiceImpl.java
src/main/resources/mapping/RuleChannelConfigDao.xml
src/test/java/com/sy/engin/EnginTest.java
src/main/java/com/sy/bean/DEVDEBUG.java
0 → 100644
查看文件 @
ef4d2be
package
com
.
sy
.
bean
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
DEVDEBUG
{
@Value
(
"${devdebug}"
)
private
Boolean
debug
;
@Bean
(
"devdebug"
)
public
Boolean
getDebug
(){
System
.
out
.
println
(
"devdebug:"
+
debug
);
return
debug
;
}
}
...
...
src/main/java/com/sy/controller/CustomsLockController.java
查看文件 @
ef4d2be
...
...
@@ -9,6 +9,7 @@ import com.sy.model.NoticeLock;
import
com.sy.response.ResultJson
;
import
com.sy.service.CommandLogService
;
import
com.sy.service.CustomsLockService
;
import
com.sy.service.EnginCheckService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -30,6 +31,9 @@ public class CustomsLockController {
@Autowired
CommandLogService
commandLogService
;
@Autowired
EnginCheckService
enginCheckService
;
@PostMapping
(
"response"
)
public
ResultJson
lockResponse
(
@RequestBody
LockFeedBack
feedBack
){
try
{
...
...
@@ -73,7 +77,8 @@ public class CustomsLockController {
sb
.
append
(
"成功"
);
if
(
gatherInfo
!=
null
){
commandLogService
.
commandlog
(
gatherInfo
,
true
,
sb
.
toString
(),
null
,
null
,
0.0
,
0.0
,
0.0
,
0.0
);
customsLockService
.
localGatherInfoHandle
(
gatherInfo
);
// customsLockService.localGatherInfoHandle(gatherInfo);
enginCheckService
.
lockNoticeContinueCheck
(
gatherInfo
);
}
else
{
sb
.
append
(
"关锁缓存信息读取失败"
);
gatherInfo
=
new
GatherInfo
();
...
...
src/main/java/com/sy/controller/EnginChanelController.java
0 → 100644
查看文件 @
ef4d2be
package
com
.
sy
.
controller
;
import
com.sy.model.GatherInfo
;
import
com.sy.service.EnginCheckService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.basis.enhance.groovy.entity.EngineExecutorResult
;
import
org.basis.enhance.groovy.entity.ExecuteParams
;
import
org.basis.enhance.groovy.entity.ScriptQuery
;
import
org.basis.enhance.groovy.executor.EngineExecutor
;
import
org.basis.enhance.groovy.helper.RefreshScriptHelper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.math.BigDecimal
;
@RestController
@Slf4j
@RequestMapping
(
"/chanel"
)
public
class
EnginChanelController
{
@Autowired
EnginCheckService
enginCheckService
;
@PostMapping
(
"/check"
)
public
String
x21Check
(
@RequestBody
GatherInfo
gatherInfo
)
{
ExecuteParams
executeParams
=
enginCheckService
.
makeParaByGagherInfo
(
gatherInfo
);
Boolean
check
=
enginCheckService
.
enginCheckByGatherInfo
(
gatherInfo
,
executeParams
);
if
(
check
){
log
.
info
(
"脚本验放测试通过"
);
//放行
enginCheckService
.
pass
(
gatherInfo
,
executeParams
);
enginCheckService
.
formRelease
(
gatherInfo
,
executeParams
);
}
else
{
log
.
error
(
"脚本验放测试失败或等待关锁施解封"
);
}
return
"ok"
;
}
}
...
...
src/main/java/com/sy/groovy/LockNoticeCheck.groovy
查看文件 @
ef4d2be
...
...
@@ -8,6 +8,8 @@ import com.sy.model.LockFeignResponse
import
com.sy.model.NoticeLock
import
com.sy.service.CommandLogService
import
com.sy.service.CustomsLockService
import
com.sy.service.LandBusListService
import
com.sy.service.RedisService
import
com.sy.service.feigin.LockFeignService
import
com.sy.socket.CommandClient
import
org.apache.commons.lang.StringUtils
...
...
@@ -22,6 +24,18 @@ import org.springframework.context.ApplicationContext
*/
class
LockNoticeCheck
extends
Script
implements
ChannelCheckScript
{
private
final
Logger
log
=
LoggerFactory
.
getLogger
(
getClass
());
/**
* 需要通知
*/
private
final
String
NEED_NOTICE
=
"Y"
;
/**
* 不需要通知
*/
private
final
String
DOT_NOTICE
=
"N"
;
/**
* 验证失败
*/
private
final
String
FAIL_NOTICE
=
"F"
;
@Override
Object
run
()
{
return
null
...
...
@@ -46,8 +60,9 @@ class LockNoticeCheck extends Script implements ChannelCheckScript {
LandListDao
landListDao
=
context
.
getBean
(
LandListDao
.
class
);
LockFeignService
lockFeignService
=
context
.
getBean
(
LockFeignService
.
class
);
//需要关锁业务通知
if
(
customsLockService
.
lockNoticeCheck
(
info
)){
//判定是否需要关锁业务通知
String
checkResult
=
lockNoticeCheck
(
info
,
executeParams
);
if
(
NEED_NOTICE
.
equals
(
checkResult
)){
/**
* 关锁号申请检查
* 根据二维码查申请是否有关锁信息,没有查到实体返回null
...
...
@@ -72,7 +87,13 @@ class LockNoticeCheck extends Script implements ChannelCheckScript {
LockFeignResponse
lockFeignResponse
=
lockFeignService
.
noticeLock
(
noticeLock
);
log
.
info
(
"[LOCK-API-RSP]-关锁通知接口返回,code:{},message:{},success:{}"
,
lockFeignResponse
.
code
,
lockFeignResponse
.
message
,
lockFeignResponse
.
success
);
record
(
info
,
false
,
"关锁施封通知中,等待下一步指令"
,
null
);
return
true
;
/**
* 因为关锁业务为异步,实际上这里的返回是进行关锁通知成功
* 但是要返回false,抬杆指令判定才能中断
* 后续等待关锁服务从接口进行通知并抬杆验放
*/
return
false
;
}
else
{
if
(
IN_TYPE
.
equals
(
info
.
getIetype
())
&&
customsLockService
.
unLockCheck
(
info
))
{
customsLockService
.
cacheWrite
(
info
);
...
...
@@ -83,16 +104,31 @@ class LockNoticeCheck extends Script implements ChannelCheckScript {
LockFeignResponse
lockFeignResponse
=
lockFeignService
.
noticeLock
(
noticeLock
);
log
.
info
(
"[LOCK-API-RSP]-关锁通知接口返回,code:{},message:{},success:{}"
,
lockFeignResponse
.
code
,
lockFeignResponse
.
message
,
lockFeignResponse
.
success
);
record
(
info
,
false
,
"关锁解封通知中,等待下一步指令"
,
null
);
return
tru
e
;
return
fals
e
;
}
}
/**
* 无需上锁,无需解锁,则返回true
* 继续抬杆指令判定.
*/
return
true
;
}
else
{
CommandClient
.
Client
(
info
,
"流转业务-未申请关锁号"
);
record
(
info
,
false
,
"业务异常:流转业务-未申请关锁号"
,
null
);
//这里需要返回true,是关锁业务,但是中断,不抬杆不放行,给予关锁业务异常通知
return
true
;
return
false
;
}
}
if
(
DOT_NOTICE
.
equals
(
checkResult
)){
/**
* 不进行关锁通知,
* 所以可以继续走验放流程,进行自动抬杆
*/
return
true
;
}
//关锁通知验放失败
return
false
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
...
...
@@ -113,4 +149,72 @@ class LockNoticeCheck extends Script implements ChannelCheckScript {
CommandLogService
commandLogService
=
context
.
getBean
(
CommandLogService
.
class
);
commandLogService
.
commandlog
(
info
,
result
,
reason
,
landBusinessTypeList
,
null
,
0.0
,
0.0
,
0.0
,
0.0
);
}
String
lockNoticeCheck
(
GatherInfo
info
,
ExecuteParams
executeParams
)
{
if
(
info
!=
null
&&
StringUtils
.
isNotEmpty
(
info
.
getBarcode
()))
{
//todo:这里后期判定可以复用场站白名单验证
// FileTool.readProperties("station").contains(info.getAreaid());
/**
* 申请业务类型检查
* 调拨业务及分拨业务装载货物为单证的,必须有关锁号
* 就算申请信息里面没关锁号也要通知
*/
LandBusinessTypeList
landBusinessTypeList
=
(
LandBusinessTypeList
)
executeParams
.
get
(
"ChanelFormInfo"
);
if
(
landBusinessTypeList
!=
null
){
if
(
"调拨业务"
.
equals
(
landBusinessTypeList
.
getBusinesstype
())
||
"分拨业务"
.
equals
(
landBusinessTypeList
.
getBusinesstype
()))
{
String
sfAreaid
=
"4600541001"
;
String
zbqAreaid
=
"4600329012"
;
String
zbqN3Areaid
=
"4612199001"
;
ApplicationContext
context
=
getContext
();
// 获取容器中的bean
RedisService
redisService
=
context
.
getBean
(
RedisService
.
class
);
String
carEndstationList
=
redisService
.
get
(
info
.
getVename
()
+
"_endstationList"
);
if
(
StringUtils
.
isNotEmpty
(
info
.
getVename
())
&&
StringUtils
.
isNotEmpty
(
carEndstationList
)){
//涉及综保区场站的申请不核验关锁业务.
if
(
carEndstationList
.
contains
(
zbqAreaid
))
{
log
.
info
(
"[LOCK-CHECK]-申报场站列表包含综保区,不处理关锁业务,当前场站:{}"
,
landBusinessTypeList
.
getEndstation
());
return
DOT_NOTICE
;
}
//综保区场站及内三不通知,顺丰场站不通知
if
(
zbqAreaid
.
equals
(
landBusinessTypeList
.
getEndstation
())
||
zbqN3Areaid
.
equals
(
landBusinessTypeList
.
getEndstation
())
||
sfAreaid
.
equals
(
landBusinessTypeList
.
getEndstation
())
)
{
log
.
info
(
"[LOCK-CHECK]-综保区及内三场站,顺丰场站,不处理关锁业务,当前场站:{}"
,
landBusinessTypeList
.
getEndstation
());
return
DOT_NOTICE
;
}
else
{
return
NEED_NOTICE
;
/**
* 单证验证-取消
*/
// List<LAND_BUSINEESTYPE_LIST_INFO> land_busineestype_list_infos = landBusinessTypeList.getLandBusineestypeListInfoList();
// if (!land_busineestype_list_infos.isEmpty()){
// LAND_BUSINEESTYPE_LIST_INFO list_info = land_busineestype_list_infos.stream().parallel()
// .filter(item -> "B".equals(item.getExt4()))
// .findAny().orElse(null);
//
// //包含单证
// if (list_info!=null){
// log.info("[LOCK-CHECK]-包含单证,开始关锁通知");
// return true;
// }
// }
}
}
else
{
return
FAIL_NOTICE
;
}
}
}
else
{
log
.
info
(
"[LOCK-CHECK]-无对应进出场申请"
);
return
FAIL_NOTICE
;
}
}
return
FAIL_NOTICE
;
}
}
...
...
src/main/java/com/sy/groovy/WeightCheckImportDlv.groovy
查看文件 @
ef4d2be
...
...
@@ -10,6 +10,8 @@ import org.slf4j.Logger
import
org.slf4j.LoggerFactory
import
org.springframework.context.ApplicationContext
import
java.text.DecimalFormat
/**
* 重量验放
* 提货验放
...
...
@@ -43,7 +45,7 @@ class WeightCheckImportDlv extends Script implements ChannelCheckScript {
WeightCheckHandleService
weightCheckHandleService
=
context
.
getBean
(
WeightCheckHandleService
.
class
);
logger
.
info
(
"[进出场申请]-业务类型为:{}-{}"
,
landBusinessTypeList
.
getCocode
(),
landBusinessTypeList
.
getBusinesstype
());
if
(
weightCheckHandleService
.
checkImportDlv
(
gatherInfo
.
getGrosswt
(),
selfWt
,
goodsWt
,
inAisleWT
)){
if
(
checkImportDlv
(
gatherInfo
.
getGrosswt
(),
selfWt
,
goodsWt
,
inAisleWT
)){
return
true
;
}
else
{
logger
.
error
(
"[进口提货]-出场重量未通过校验:"
+
GROWSSEXCETION
);
...
...
@@ -52,7 +54,7 @@ class WeightCheckImportDlv extends Script implements ChannelCheckScript {
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
logger
.
error
(
"[
VE
-CHECK-ERROR]:"
,
e
);
logger
.
error
(
"[
DLV_WEIGHT
-CHECK-ERROR]:"
,
e
);
return
false
;
}
}
...
...
@@ -68,4 +70,59 @@ class WeightCheckImportDlv extends Script implements ChannelCheckScript {
ApplicationContext
context
=
applicationContext
;
return
context
;
}
boolean
checkImportDlv
(
double
grossWt
,
double
wt
,
double
goodsWt
,
double
inWt
){
// 调用方法
ApplicationContext
context
=
getContext
();
//重量校验算法
WeightCheckHandleService
weightCheckHandleService
=
context
.
getBean
(
WeightCheckHandleService
.
class
);
DecimalFormat
df
=
new
DecimalFormat
(
"0.00"
);
boolean
flag
=
false
;
double
result
=
0.00
;
double
result1
=
0.00
;
double
result2
=
0.00
;
double
emptyOut
=
0.00
;
double
goodCheckResult
=
0.00
;
if
(
Double
.
doubleToLongBits
(
grossWt
)>
Double
.
doubleToLongBits
(
0
)){
//进场过磅重量+带货重量 = 出场过磅重量
// result = Double.parseDouble(df.format(Math.abs((inWt + goodsWt - grossWt)) / grossWt));
result
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
grossWt
-
wt
-
goodsWt
))
/ goodsWt));
//带货提货,不提货判定,非空车离场
result2 = Double.parseDouble(df.format(Math.abs((inWt - grossWt)) /
grossWt
));
//个别原因不提货了,空车离场
emptyOut
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
wt
-
grossWt
))
/ grossWt));
//车辆备案重量+货物重量 = 出场过磅重量,测试用,生产关闭
result1 = Double.parseDouble(df.format(Math.abs((wt + goodsWt - grossWt)) /
grossWt
));
//带货提货,货重误差
goodCheckResult
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
grossWt
-
inWt
-
goodsWt
))
/ goodsWt));
double range = weightCheckHandleService.valueDob();
logger.info("[WEIGHT-CHECK]-实际离场拉货重量:{},申请离场拉货重量:{},货重差值:{},货重误差:{}",grossWt-inWt,goodsWt,grossWt-inWt-goodsWt,goodCheckResult);
logger.info("[WEIGHT-CHECK]-进出场比对差值:{},提货离场差值:{},进出场比对重量差:{}",result,result1,Math.abs(inWt - grossWt));
if (goodCheckResult<=range
// || result <= range
) {
flag = true;
}
// //车辆备案重量+货物重量 = 出场过磅重量,测试用,生产关闭
// if (result1 <= range || result2 <= range || emptyOut <= range) {
//
// return true;
/
/
}
}
return
flag
;
}
}
...
...
src/main/java/com/sy/groovy/X21FormReleaseCheck.groovy
查看文件 @
ef4d2be
package
com.sy.groovy
import
com.sy.crossDomain.BuildBarCode
import
com.sy.mapper.LandListDao
import
com.sy.model.GatherInfo
import
com.sy.model.LandBusinessTypeList
import
com.sy.service.CommandLogService
import
com.sy.service.LandBusListService
import
com.sy.service.RedisService
import
com.sy.service.impl.GatherInfoHandle
import
org.basis.enhance.groovy.entity.ExecuteParams
import
org.slf4j.Logger
...
...
@@ -73,7 +78,7 @@ class X21FormReleaseCheck extends Script {
//todo:流转申请状态核销
logger
.
info
(
"[进出场申请]-流转申请开始核销:"
+
gatherInfo
.
getVename
());
//二维码核销
// gatherInfoHandle.releaseBarCode(
);
releaseBarCode
(
gatherInfo
,
executeParams
);
logger
.
info
(
"[进出场申请]-流转申请已核销:"
+
gatherInfo
.
getVename
());
}
}
catch
(
Exception
e
){
...
...
@@ -94,4 +99,61 @@ class X21FormReleaseCheck extends Script {
return
context
;
}
void
releaseBarCode
(
GatherInfo
info
,
ExecuteParams
executeParams
){
ApplicationContext
context
=
getContext
();
// 获取容器中的bean
LandBusListService
listService
=
context
.
getBean
(
LandBusListService
.
class
);
LandListDao
landListDao
=
context
.
getBean
(
LandListDao
.
class
);
Boolean
devdebug
=
(
Boolean
)
context
.
getBean
(
"devdebug"
);
//是否有未驶离的流转记录二维码判定
int
count
=
listService
.
selectlaststation
(
info
.
getVename
(),
info
.
getBarcode
());
//二维码失效通知,已进入场站的与缓存比较.
if
(
count
==
0
){
//todo:测试注释掉,二维码释放
if
(!
devdebug
){
BuildBarCode
.
cancleBarCode
(
info
.
getVename
());
logger
.
info
(
"[流转申请]-二维码已释放:"
+
info
.
getVename
());
}
int
rc
=
landListDao
.
releaseBarcode
(
info
.
getBarcode
());
if
(
rc
>
0
)
{
logger
.
info
(
"[进出场核销]-{}流转已核销:{}"
,
info
.
getVename
(),
info
.
getBarcode
());
}
else
{
logger
.
error
(
"[进出场核销-ERROR]-{}流转未核销成功:{}"
,
info
.
getVename
(),
info
.
getBarcode
());
}
//车辆流转申请缓存删除
releaseCache
(
info
,
executeParams
);
}
else
{
logger
.
error
(
"[进出场核销-ERROR]-{}二维码应该核销,但是不符合核销条件:{}"
,
info
.
getVename
(),
info
.
getBarcode
());
}
}
void
releaseCache
(
GatherInfo
info
,
ExecuteParams
executeParams
){
ApplicationContext
context
=
getContext
();
// 获取容器中的bean
RedisService
redisService
=
context
.
getBean
(
RedisService
.
class
);
//车辆流转申请缓存删除
redisService
.
del
(
info
.
getVename
());
//流转申请时生成的临时核碰场站代码列表
redisService
.
del
(
info
.
getVename
()+
"_endstationList"
);
//车辆过卡信息缓存删除-X22金二判定时候生成的这个缓存
redisService
.
del
(
info
.
getSeqno
());
logger
.
info
(
"[流转缓存]-{}缓存已核销"
,
info
.
getVename
());
//核销记录
releaseRecord
(
info
,
executeParams
);
}
/**
* 核销记录
*/
void
releaseRecord
(
GatherInfo
info
,
ExecuteParams
executeParams
){
LandBusinessTypeList
chanelFormInfo
=
(
LandBusinessTypeList
)
executeParams
.
get
(
"ChanelFormInfo"
);
ApplicationContext
context
=
getContext
();
CommandLogService
commandLogService
=
context
.
getBean
(
CommandLogService
.
class
);
commandLogService
.
commandlog
(
info
,
true
,
"流转核销"
,
chanelFormInfo
,
null
,
0.0
,
0.0
,
0.0
,
0.0
);
}
}
...
...
src/main/java/com/sy/service/EnginCheckService.java
查看文件 @
ef4d2be
...
...
@@ -56,6 +56,10 @@ public interface EnginCheckService {
*/
void
commandlog
(
GatherInfo
info
,
boolean
check
,
String
reason
,
ExecuteParams
executeParams
);
void
formRelease
(
GatherInfo
info
,
ExecuteParams
executeParams
);
void
lockNoticeContinueCheck
(
GatherInfo
info
);
}
...
...
src/main/java/com/sy/service/WeightCheckHandleService.java
查看文件 @
ef4d2be
...
...
@@ -68,4 +68,11 @@ public interface WeightCheckHandleService {
* @return 返回校验结果 true 通过,false 不通过
*/
boolean
checkEmpty
(
double
grossWt
,
double
wt
);
/**
* 误差配置获取
* @return
*/
double
valueDob
();
}
...
...
src/main/java/com/sy/service/impl/EnginCheckServiceImpl.java
查看文件 @
ef4d2be
...
...
@@ -77,7 +77,14 @@ public class EnginCheckServiceImpl implements EnginCheckService {
ruleChannelConfig
.
setChannelNum
(
gatherInfo
.
getChnlno
());
List
<
RuleChannelConfig
>
ruleChannelConfigs
=
ruleChannelConfigDao
.
selectByChannelAndBusiTypeAndGoodsType
(
ruleChannelConfig
);
if
(
ruleChannelConfigs
!=
null
&&
!
ruleChannelConfigs
.
isEmpty
()){
for
(
int
i
=
0
;
i
<
ruleChannelConfigs
.
size
();
i
++)
{
/**
* 核销判定需要另外执行.这里需要跳过.
*/
if
(
ruleChannelConfigs
.
get
(
i
).
ruleConfig
!=
null
&&
"核销判定"
.
equals
(
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getRuleType
())){
return
true
;
}
// 执行脚本中指定的方法 changeProduct
EngineExecutorResult
executorResult
=
engineExecutor
.
execute
(
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getScriptMethodName
(),
new
ScriptQuery
(
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getScriptKey
()),
executeParams
);
...
...
@@ -93,18 +100,19 @@ public class EnginCheckServiceImpl implements EnginCheckService {
return
false
;
}
}
//核销判定
if
(
executorResult
.
getContext
()==
null
&&
"void"
.
equals
(
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getScriptMethodReturn
())){
log
.
info
(
"核销判定"
);
}
}
else
{
log
.
error
(
"验证脚本名称:{},验证KEY-NAME:{}-[验放失败]"
,
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getRuleName
(),
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getScriptKey
());
return
false
;
}
}
return
true
;
}
else
{
log
.
error
(
"[{}]-通道未配置规则,不支持此业务"
,
gatherInfo
.
getChnlno
());
sendBw
(
gatherInfo
,
false
,
"通道未配置规则,不支持此业务"
,
executeParams
);
return
false
;
}
}
sendBw
(
gatherInfo
,
false
,
"未找到流转申请信息"
,
executeParams
);
log
.
error
(
"未找到流转申请信息"
);
return
false
;
}
...
...
@@ -192,6 +200,7 @@ public class EnginCheckServiceImpl implements EnginCheckService {
redisService
.
incr
(
"kako-total"
,
1
);
}
commandlog
(
info
,
check
,
reason
,
executeParams
);
return
;
}
log
.
info
(
String
.
format
(
"开始发送指令:车牌%s,场站%s,通道%s,重量%s"
,
info
.
getVename
(),
info
.
getAreaid
(),
info
.
getChnlno
(),
info
.
getGrosswt
()));
...
...
@@ -302,4 +311,107 @@ public class EnginCheckServiceImpl implements EnginCheckService {
}
commandLogService
.
insert
(
command
);
}
@Override
public
void
formRelease
(
GatherInfo
gatherInfo
,
ExecuteParams
executeParams
)
{
//获取申请信息
LandBusinessTypeList
chanelFormInfo
=
(
LandBusinessTypeList
)
executeParams
.
get
(
"ChanelFormInfo"
);
if
(
chanelFormInfo
!=
null
)
{
//查询验放配置参数生成
RuleChannelConfig
ruleChannelConfig
=
new
RuleChannelConfig
();
ruleChannelConfig
.
setBusinessType
(
chanelFormInfo
.
getBusinesstype
());
ruleChannelConfig
.
setGoodsType
(
chanelFormInfo
.
getCocode
());
ruleChannelConfig
.
setChannelNum
(
gatherInfo
.
getChnlno
());
List
<
RuleChannelConfig
>
ruleChannelConfigs
=
ruleChannelConfigDao
.
selectByChannelAndBusiTypeAndGoodsType
(
ruleChannelConfig
);
if
(
ruleChannelConfigs
!=
null
&&
!
ruleChannelConfigs
.
isEmpty
()){
for
(
int
i
=
0
;
i
<
ruleChannelConfigs
.
size
();
i
++)
{
//核销判定
if
(
ruleChannelConfigs
.
get
(
i
).
ruleConfig
!=
null
&&
"核销判定"
.
equals
(
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getRuleType
())){
// 执行脚本中指定的方法 changeProduct
EngineExecutorResult
executorResult
=
engineExecutor
.
execute
(
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getScriptMethodName
(),
new
ScriptQuery
(
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getScriptKey
()),
executeParams
);
log
.
info
(
"核销判定验证脚本名称:{},验证KEY-NAME:{}"
,
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getRuleName
(),
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getScriptKey
());
log
.
info
(
"核销判定判定放行结果=========>>>>>>>>>>>{}"
,
executorResult
);
}
}
}
}
else
{
log
.
error
(
"核销判定通道申请信息无效"
);
}
}
@Override
public
void
lockNoticeContinueCheck
(
GatherInfo
gatherInfo
)
{
ExecuteParams
executeParams
=
makeParaByGagherInfo
(
gatherInfo
);
Boolean
check
=
enginCheckByLockNotice
(
gatherInfo
,
executeParams
);
if
(
check
){
log
.
info
(
"脚本验放测试通过"
);
//放行
pass
(
gatherInfo
,
executeParams
);
formRelease
(
gatherInfo
,
executeParams
);
}
else
{
log
.
error
(
"脚本验放测试失败"
);
}
}
private
Boolean
enginCheckByLockNotice
(
GatherInfo
gatherInfo
,
ExecuteParams
executeParams
)
{
//获取申请信息
LandBusinessTypeList
chanelFormInfo
=
(
LandBusinessTypeList
)
executeParams
.
get
(
"ChanelFormInfo"
);
if
(
chanelFormInfo
!=
null
){
//查询验放配置参数生成
RuleChannelConfig
ruleChannelConfig
=
new
RuleChannelConfig
();
ruleChannelConfig
.
setBusinessType
(
chanelFormInfo
.
getBusinesstype
());
ruleChannelConfig
.
setGoodsType
(
chanelFormInfo
.
getCocode
());
ruleChannelConfig
.
setChannelNum
(
gatherInfo
.
getChnlno
());
List
<
RuleChannelConfig
>
ruleChannelConfigs
=
ruleChannelConfigDao
.
selectByChannelAndBusiTypeAndGoodsType
(
ruleChannelConfig
);
if
(
ruleChannelConfigs
!=
null
&&
!
ruleChannelConfigs
.
isEmpty
()){
for
(
int
i
=
0
;
i
<
ruleChannelConfigs
.
size
();
i
++)
{
/**
* 核销判定需要另外执行.这里需要跳过.
*/
if
(
ruleChannelConfigs
.
get
(
i
).
ruleConfig
!=
null
&&
"核销判定"
.
equals
(
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getRuleType
())){
continue
;
}
if
(
ruleChannelConfigs
.
get
(
i
).
ruleConfig
!=
null
&&
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getRuleType
().
contains
(
"关锁"
)){
continue
;
}
// 执行脚本中指定的方法 changeProduct
EngineExecutorResult
executorResult
=
engineExecutor
.
execute
(
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getScriptMethodName
(),
new
ScriptQuery
(
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getScriptKey
()),
executeParams
);
log
.
info
(
"验证脚本名称:{},验证KEY-NAME:{}"
,
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getRuleName
(),
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getScriptKey
());
log
.
info
(
"使用groovy脚本来验证过卡判定放行结果=========>>>>>>>>>>>执行结果:{}"
,
executorResult
);
if
(
executorResult
.
getExecutionStatus
().
equals
(
ExecutionStatus
.
SUCCESS
)){
if
(
executorResult
.
getContext
()
instanceof
Boolean
){
Boolean
execResult
=
(
Boolean
)
executorResult
.
getContext
();
if
(
execResult
)
{
log
.
info
(
"验证脚本名称:{},验证KEY-NAME:{}-[验放成功]"
,
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getRuleName
(),
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getScriptKey
());
}
else
{
log
.
info
(
"验放失败"
);
return
false
;
}
}
}
else
{
log
.
error
(
"验证脚本名称:{},验证KEY-NAME:{}-[验放失败]"
,
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getRuleName
(),
ruleChannelConfigs
.
get
(
i
).
ruleConfig
.
getScriptKey
());
return
false
;
}
}
return
true
;
}
else
{
log
.
error
(
"[{}]-通道未配置规则,不支持此业务"
,
gatherInfo
.
getChnlno
());
sendBw
(
gatherInfo
,
false
,
"通道未配置规则,不支持此业务"
,
executeParams
);
return
false
;
}
}
sendBw
(
gatherInfo
,
false
,
"未找到流转申请信息"
,
executeParams
);
log
.
error
(
"未找到流转申请信息"
);
return
false
;
}
}
...
...
src/main/java/com/sy/service/impl/WeightCheckHandleServiceImpl.java
查看文件 @
ef4d2be
...
...
@@ -58,7 +58,8 @@ public class WeightCheckHandleServiceImpl implements WeightCheckHandleService {
* @param wt 车辆自重
* @param goodsWt 货物总重
* @param inWt 进场过磅重量
* 误差计算方式 (应该出场重量 - 出场重量) / 出场重量 与 误差比对,超过误差则不放行
* 误差计算方式 (应该出场重量 - 出场重量) / 出场重量 与 误差比对,超过误差则不放行(规则取消)
* 误差计算方式 (应该出场重量 - 出场重量) / 货物重量 与 误差比对,超过误差则不放行(新规)
* @return 返回校验结果 true 通过,false 不通过
*/
@Override
...
...
@@ -83,7 +84,7 @@ public class WeightCheckHandleServiceImpl implements WeightCheckHandleService {
if
(
Double
.
doubleToLongBits
(
grossWt
)>
Double
.
doubleToLongBits
(
0
)){
result
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
inWt
-
goodsWt
-
grossWt
))
/
grossWt
));
result2
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
grossWt
-
wt
))
/
grossW
t
));
result2
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
grossWt
-
wt
))
/
w
t
));
log
.
info
(
"[WEIGHT-CHECK]-进出场比对差值:{},空车出场差值:{},进出场比对重量差:{},空车比对重量差:{}"
,
result
,
result2
,
Math
.
abs
(
inWt
-
goodsWt
-
grossWt
),
Math
.
abs
(
grossWt
-
wt
));
}
...
...
@@ -107,7 +108,7 @@ public class WeightCheckHandleServiceImpl implements WeightCheckHandleService {
DecimalFormat
df
=
new
DecimalFormat
(
"0.00"
);
if
(
Double
.
doubleToLongBits
(
grossWt
)>
Double
.
doubleToLongBits
(
0
)){
//空车入场判定,入场重量-车辆备案重量
emptyIN
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
wt
-
grossWt
))
/
grossW
t
));
emptyIN
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
wt
-
grossWt
))
/
w
t
));
double
range
=
valueDob
();
...
...
@@ -141,7 +142,8 @@ public class WeightCheckHandleServiceImpl implements WeightCheckHandleService {
double
goodCheckResult
=
0.00
;
if
(
Double
.
doubleToLongBits
(
grossWt
)>
Double
.
doubleToLongBits
(
0
)){
//进场过磅重量+带货重量 = 出场过磅重量
result
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
inWt
+
goodsWt
-
grossWt
))
/
grossWt
));
// result = Double.parseDouble(df.format(Math.abs((inWt + goodsWt - grossWt)) / grossWt));
result
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
grossWt
-
wt
-
goodsWt
))
/
goodsWt
));
//带货提货,不提货判定,非空车离场
result2
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
inWt
-
grossWt
))
/
grossWt
));
...
...
@@ -159,8 +161,8 @@ public class WeightCheckHandleServiceImpl implements WeightCheckHandleService {
log
.
info
(
"[WEIGHT-CHECK]-实际离场拉货重量:{},申请离场拉货重量:{},货重差值:{},货重误差:{}"
,
grossWt
-
inWt
,
goodsWt
,
grossWt
-
inWt
-
goodsWt
,
goodCheckResult
);
log
.
info
(
"[WEIGHT-CHECK]-进出场比对差值:{},提货离场差值:{},进出场比对重量差:{}"
,
result
,
result1
,
Math
.
abs
(
inWt
-
grossWt
));
if
(
result
<=
range
// || goodCheckResult<=range
if
(
goodCheckResult
<=
range
// || result <= range
)
{
flag
=
true
;
...
...
@@ -205,20 +207,26 @@ public class WeightCheckHandleServiceImpl implements WeightCheckHandleService {
if
(
Double
.
doubleToLongBits
(
grossWt
)>
Double
.
doubleToLongBits
(
0
)){
//带货出,入场重量+带货重量 = 离场重量
result
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
inWt
+
goodsWt
-
grossWt
))
/
gros
sWt
));
result
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
grossWt
-
inWt
-
goodsWt
))
/
good
sWt
));
//带货出,用车辆备案重量对碰,车辆备案重量+带货重量 = 离场重量
result4
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
wt
+
goodsWt
-
grossWt
))
/
grossWt
));
// result4 = Double.parseDouble(df.format(Math.abs((wt + goodsWt - grossWt)) / grossWt));
result4
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
grossWt
-
wt
-
goodsWt
))
/
goodsWt
));
//空车出,过磅重量 = 车辆备案重量
result2
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
grossWt
-
wt
))
/
grossW
t
));
result2
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
grossWt
-
wt
))
/
w
t
));
//卸货出,入场重量-卸货重量 = 离场重量
result3
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
inWt
-
goodsWt
-
grossWt
))
/
grossWt
));
result3
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
inWt
-
goodsWt
-
grossWt
))
/
goodsWt
));
System
.
out
.
println
(
"进场提货离场差值:"
+
result
);
System
.
out
.
println
(
"空车离场差值:"
+
result2
);
System
.
out
.
println
(
"进场卸货离场差值:"
+
result3
);
System
.
out
.
println
(
"备案重量进场装载货物离场差值:"
+
result4
);
}
double
range
=
valueDob
();
if
(
result
<=
range
||
result2
<=
range
||
result3
<=
range
||
result4
<=
range
)
{
if
(
result2
<=
range
||
result
<=
range
||
result3
<=
range
||
result4
<=
range
)
{
flag
=
true
;
}
return
flag
;
...
...
@@ -234,7 +242,7 @@ public class WeightCheckHandleServiceImpl implements WeightCheckHandleService {
public
boolean
checkEmpty
(
double
grossWt
,
double
wt
)
{
DecimalFormat
df
=
new
DecimalFormat
(
"0.00"
);
boolean
flag
=
false
;
double
reult
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
grossWt
-
wt
))
/
grossW
t
));
double
reult
=
Double
.
parseDouble
(
df
.
format
(
Math
.
abs
((
grossWt
-
wt
))
/
w
t
));
if
(
reult
<=
valueDob
())
{
flag
=
true
;
}
...
...
@@ -259,7 +267,8 @@ public class WeightCheckHandleServiceImpl implements WeightCheckHandleService {
}
//将获取的checkWt进行小数转化
private
double
valueDob
()
{
@Override
public
double
valueDob
()
{
NumberFormat
nf
=
NumberFormat
.
getPercentInstance
();
Number
m
=
null
;
try
{
...
...
src/main/resources/mapping/RuleChannelConfigDao.xml
查看文件 @
ef4d2be
...
...
@@ -17,6 +17,7 @@
<result
column=
"script_method_name"
jdbcType=
"VARCHAR"
property=
"scriptMethodName"
/>
<result
column=
"script_method_return"
jdbcType=
"VARCHAR"
property=
"scriptMethodReturn"
/>
<result
column=
"rule_name"
jdbcType=
"VARCHAR"
property=
"ruleName"
/>
<result
column=
"rule_type"
jdbcType=
"VARCHAR"
property=
"ruleType"
/>
</association>
</resultMap>
<sql
id=
"Base_Column_List"
>
...
...
@@ -39,7 +40,8 @@
rule.script_key,
rule.script_method_name,
rule.script_method_return,
rule.rule_name
rule.rule_name,
rule.rule_type
FROM
(
SELECT
...
...
@@ -54,12 +56,12 @@
channel_num = #{channelNum,jdbcType=VARCHAR}
AND business_type = #{businessType,jdbcType=VARCHAR}
AND goods_type = #{goodsType,jdbcType=VARCHAR}
ORDER BY config_order
) conf
LEFT JOIN
rule_config rule
ON
conf.rule_id = rule.rule_id
ORDER BY config_order
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Integer"
>
delete from rule_channel_config
...
...
src/test/java/com/sy/engin/EnginTest.java
查看文件 @
ef4d2be
...
...
@@ -30,6 +30,7 @@ public class EnginTest {
private
static
String
IEPORSE
=
"无相对应进出场申请"
;
private
static
String
CHANEL_ERR
=
"无对应通道流转申请,走错通道"
;
private
final
static
String
PERMITTHOUGH
=
"直接放行"
;
@Autowired
...
...
@@ -202,9 +203,9 @@ public class EnginTest {
public
void
enginTest
(){
GatherInfo
gatherInfo
=
new
GatherInfo
();
gatherInfo
.
setAreaid
(
"4604600000"
);
gatherInfo
.
setChnlno
(
"4604600010"
);
gatherInfo
.
setBarcode
(
"681-43e2-925c-7b1e1054fbef"
);
gatherInfo
.
setGrosswt
(
new
BigDecimal
(
"6000"
));
gatherInfo
.
setChnlno
(
"4604601010"
);
gatherInfo
.
setBarcode
(
"bd4-4ee7-8cae-dbc2d6bc75b2"
);
gatherInfo
.
setGrosswt
(
new
BigDecimal
(
"2000"
));
gatherInfo
.
setSeqno
(
"20220630184441000028"
);
gatherInfo
.
setIetype
(
"I"
);
gatherInfo
.
setVename
(
"豫A61CR7"
);
...
...
@@ -213,6 +214,7 @@ public class EnginTest {
Boolean
check
=
enginCheckService
.
enginCheckByGatherInfo
(
gatherInfo
,
executeParams
);
if
(
check
){
log
.
info
(
"脚本验放测试通过"
);
//放行
enginCheckService
.
pass
(
gatherInfo
,
executeParams
);
}
else
{
log
.
error
(
"脚本验放测试失败"
);
...
...
请
注册
或
登录
后发表评论