Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
smart_gov_platform
Commits
312e4679
Commit
312e4679
authored
Feb 28, 2023
by
“yiyousong”
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.scsmile.cn/zxf/smart_gov_platform
parents
2893effc
c78eb922
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
572 additions
and
42 deletions
+572
-42
base-manager/pom.xml
base-manager/pom.xml
+1
-1
base-manager/src/main/java/com/mortals/xhx/base/system/message/MessageService.java
...a/com/mortals/xhx/base/system/message/MessageService.java
+14
-0
base-manager/src/main/java/com/mortals/xhx/base/system/message/impl/MessageServiceImpl.java
...tals/xhx/base/system/message/impl/MessageServiceImpl.java
+37
-0
base-manager/src/main/java/com/mortals/xhx/busiz/req/ApiThirdPartyReq.java
...main/java/com/mortals/xhx/busiz/req/ApiThirdPartyReq.java
+23
-0
base-manager/src/main/java/com/mortals/xhx/busiz/req/BussinessThirdPartyReq.java
...ava/com/mortals/xhx/busiz/req/BussinessThirdPartyReq.java
+50
-0
base-manager/src/main/java/com/mortals/xhx/common/code/MessageTypeEnum.java
...ain/java/com/mortals/xhx/common/code/MessageTypeEnum.java
+61
-0
base-manager/src/main/java/com/mortals/xhx/common/code/ThirdPartyStatusEnum.java
...ava/com/mortals/xhx/common/code/ThirdPartyStatusEnum.java
+66
-0
base-manager/src/main/java/com/mortals/xhx/common/code/ThirdPartyTypeEnum.java
.../java/com/mortals/xhx/common/code/ThirdPartyTypeEnum.java
+65
-0
base-manager/src/main/java/com/mortals/xhx/common/utils/SendTask.java
.../src/main/java/com/mortals/xhx/common/utils/SendTask.java
+42
-0
base-manager/src/main/java/com/mortals/xhx/common/utils/SendTaskThreadPool.java
...java/com/mortals/xhx/common/utils/SendTaskThreadPool.java
+68
-0
base-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/DemoStartService.java
...rtals/xhx/daemon/applicationservice/DemoStartService.java
+5
-1
base-manager/src/main/java/com/mortals/xhx/module/app/service/impl/AppServiceImpl.java
...m/mortals/xhx/module/app/service/impl/AppServiceImpl.java
+2
-2
base-manager/src/main/java/com/mortals/xhx/module/business/service/impl/BusinessServiceImpl.java
...xhx/module/business/service/impl/BusinessServiceImpl.java
+118
-18
base-manager/src/main/java/com/mortals/xhx/module/site/service/impl/SiteBusinessServiceImpl.java
...xhx/module/site/service/impl/SiteBusinessServiceImpl.java
+20
-20
No files found.
base-manager/pom.xml
View file @
312e4679
...
...
@@ -56,7 +56,7 @@
<profiles.nacos.group>
DEFAULT_GROUP
</profiles.nacos.group>
<profiles.nacos.namespace>
smart-gov
</profiles.nacos.namespace>
<profiles.log.path>
/home/mortals/app/logs
</profiles.log.path>
<profiles.log.level>
INFO
</profiles.log.level>
<profiles.log.level>
info
</profiles.log.level>
<package.environment>
test
</package.environment>
<skipUi>
false
</skipUi>
</properties>
...
...
base-manager/src/main/java/com/mortals/xhx/base/system/message/MessageService.java
0 → 100644
View file @
312e4679
package
com.mortals.xhx.base.system.message
;
public
interface
MessageService
{
/**
* 发送第三方平台四二班透传消息
*
* @param sendUrl
* @param content
* @return
*/
void
sendThirdParty
(
String
sendUrl
,
String
content
);
}
\ No newline at end of file
base-manager/src/main/java/com/mortals/xhx/base/system/message/impl/MessageServiceImpl.java
0 → 100644
View file @
312e4679
package
com.mortals.xhx.base.system.message.impl
;
import
cn.hutool.core.exceptions.ExceptionUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.xhx.base.system.message.MessageService
;
import
com.mortals.xhx.common.utils.SendTask
;
import
com.mortals.xhx.common.utils.SendTaskThreadPool
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
* DeviceService
* 设备 service实现
*
* @author zxfei
* @date 2022-03-09
*/
@Service
(
"messageService"
)
@Slf4j
public
class
MessageServiceImpl
implements
MessageService
{
@Autowired
private
SendTaskThreadPool
sendTaskThreadPool
;
@Override
public
void
sendThirdParty
(
String
sendUrl
,
String
content
)
{
SendTask
sendTask
=
new
SendTask
(
sendUrl
,
content
);
sendTaskThreadPool
.
execute
(
sendTask
);
}
public
static
void
main
(
String
[]
args
)
{
}
}
\ No newline at end of file
base-manager/src/main/java/com/mortals/xhx/busiz/req/ApiThirdPartyReq.java
0 → 100644
View file @
312e4679
package
com.mortals.xhx.busiz.req
;
import
lombok.Data
;
@Data
public
class
ApiThirdPartyReq
<
T
>
{
/**
* 结果编码
*/
private
int
code
;
/**
* 结果描述
*/
private
String
msg
;
private
Integer
type
;
private
Integer
status
;
private
T
data
;
}
base-manager/src/main/java/com/mortals/xhx/busiz/req/BussinessThirdPartyReq.java
0 → 100644
View file @
312e4679
package
com.mortals.xhx.busiz.req
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
lombok.Data
;
/**
* 业务类
*
* @author:
* @date: 2022/9/7 14:35
*/
@Data
public
class
BussinessThirdPartyReq
{
private
Long
id
;
/**
* 业务名称
*/
private
String
name
;
/**
* 备注
*/
private
String
remark
;
/**
* 是否允许预约(1.允许,0.不允许)
*/
private
Integer
canorder
;
/**
* 是否允许取号(1.允许,0.不允许)
*/
private
Integer
cantake
;
/**
* 大厅情况展示 (1.展示,0.不展示)
*/
private
Integer
datashow
;
/**
* 英语业务名
*/
private
String
englishname
;
/**
* 业务状态 (0.停用,1.正常)
*/
private
Integer
status
;
}
base-manager/src/main/java/com/mortals/xhx/common/code/MessageTypeEnum.java
0 → 100644
View file @
312e4679
package
com.mortals.xhx.common.code
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
public
enum
MessageTypeEnum
{
CRUD
(
0
,
"设备增删改查"
),
TRANSACTION
(
1
,
"设备消息类,数据域透传设备上行消息体"
);
private
Integer
value
;
private
String
desc
;
MessageTypeEnum
(
Integer
value
,
String
desc
)
{
this
.
value
=
value
;
this
.
desc
=
desc
;
}
public
Integer
getValue
()
{
return
this
.
value
;
}
public
String
getDesc
()
{
return
this
.
desc
;
}
public
static
MessageTypeEnum
getByValue
(
Integer
value
)
{
for
(
MessageTypeEnum
sendMsgTypeEnum
:
MessageTypeEnum
.
values
())
{
if
(
sendMsgTypeEnum
.
getValue
()
==
value
)
{
return
sendMsgTypeEnum
;
}
}
return
null
;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public
static
Map
<
String
,
String
>
getEnumMap
(
Integer
...
eItem
)
{
Map
<
String
,
String
>
resultMap
=
new
LinkedHashMap
<>();
for
(
MessageTypeEnum
item
:
MessageTypeEnum
.
values
())
{
try
{
boolean
hasE
=
false
;
for
(
Integer
e
:
eItem
)
{
if
(
item
.
getValue
()
==
e
)
{
hasE
=
true
;
break
;
}
}
if
(!
hasE
)
{
resultMap
.
put
(
item
.
getValue
()
+
""
,
item
.
getDesc
());
}
}
catch
(
Exception
ex
)
{
}
}
return
resultMap
;
}
}
\ No newline at end of file
base-manager/src/main/java/com/mortals/xhx/common/code/ThirdPartyStatusEnum.java
0 → 100644
View file @
312e4679
package
com.mortals.xhx.common.code
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* 启用状态 (0.停止,1.启用)枚举类
*
* @author zxfei
*/
public
enum
ThirdPartyStatusEnum
{
新增
(
1
,
"新增"
),
修改
(
2
,
"修改"
),
删除
(
3
,
"删除"
);
private
Integer
value
;
private
String
desc
;
ThirdPartyStatusEnum
(
Integer
value
,
String
desc
)
{
this
.
value
=
value
;
this
.
desc
=
desc
;
}
public
Integer
getValue
()
{
return
this
.
value
;
}
public
String
getDesc
()
{
return
this
.
desc
;
}
public
static
ThirdPartyStatusEnum
getByValue
(
Integer
value
)
{
for
(
ThirdPartyStatusEnum
statusEnum
:
ThirdPartyStatusEnum
.
values
())
{
if
(
statusEnum
.
getValue
()
==
value
)
{
return
statusEnum
;
}
}
return
null
;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public
static
Map
<
String
,
String
>
getEnumMap
(
Integer
...
eItem
)
{
Map
<
String
,
String
>
resultMap
=
new
LinkedHashMap
<>();
for
(
ThirdPartyStatusEnum
item
:
ThirdPartyStatusEnum
.
values
())
{
try
{
boolean
hasE
=
false
;
for
(
Integer
e
:
eItem
)
{
if
(
item
.
getValue
()
==
e
)
{
hasE
=
true
;
break
;
}
}
if
(!
hasE
)
{
resultMap
.
put
(
item
.
getValue
()
+
""
,
item
.
getDesc
());
}
}
catch
(
Exception
ex
)
{
}
}
return
resultMap
;
}
}
\ No newline at end of file
base-manager/src/main/java/com/mortals/xhx/common/code/ThirdPartyTypeEnum.java
0 → 100644
View file @
312e4679
package
com.mortals.xhx.common.code
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* 启用状态 (0.停止,1.启用)枚举类
*
* @author zxfei
*/
public
enum
ThirdPartyTypeEnum
{
业务
(
1
,
"业务信息变更"
),
启用
(
2
,
"启用"
);
private
Integer
value
;
private
String
desc
;
ThirdPartyTypeEnum
(
Integer
value
,
String
desc
)
{
this
.
value
=
value
;
this
.
desc
=
desc
;
}
public
Integer
getValue
()
{
return
this
.
value
;
}
public
String
getDesc
()
{
return
this
.
desc
;
}
public
static
ThirdPartyTypeEnum
getByValue
(
Integer
value
)
{
for
(
ThirdPartyTypeEnum
statusEnum
:
ThirdPartyTypeEnum
.
values
())
{
if
(
statusEnum
.
getValue
()
==
value
)
{
return
statusEnum
;
}
}
return
null
;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public
static
Map
<
String
,
String
>
getEnumMap
(
Integer
...
eItem
)
{
Map
<
String
,
String
>
resultMap
=
new
LinkedHashMap
<>();
for
(
ThirdPartyTypeEnum
item
:
ThirdPartyTypeEnum
.
values
())
{
try
{
boolean
hasE
=
false
;
for
(
Integer
e
:
eItem
)
{
if
(
item
.
getValue
()
==
e
)
{
hasE
=
true
;
break
;
}
}
if
(!
hasE
)
{
resultMap
.
put
(
item
.
getValue
()
+
""
,
item
.
getDesc
());
}
}
catch
(
Exception
ex
)
{
}
}
return
resultMap
;
}
}
\ No newline at end of file
base-manager/src/main/java/com/mortals/xhx/common/utils/SendTask.java
0 → 100644
View file @
312e4679
package
com.mortals.xhx.common.utils
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.util.HttpUtil
;
import
com.mortals.xhx.busiz.req.ApiThirdPartyReq
;
import
com.mortals.xhx.common.code.MessageTypeEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
com
.
mortals
.
framework
.
util
.
HttpUtil
.
HEADER_CONTENT_TYPE
;
/**
* 发通知第三方
*
* @author: zxfei
* @date: 2022/4/28 10:56
* @description:
**/
@Slf4j
@AllArgsConstructor
public
class
SendTask
implements
Runnable
{
private
String
sendUrl
;
private
String
content
;
@Override
public
void
run
()
{
String
resp
=
null
;
try
{
Map
<
String
,
String
>
header
=
new
HashMap
<>();
header
.
put
(
HEADER_CONTENT_TYPE
,
"application/json"
);
log
.
info
(
"sendUrl:{} \nsendMessageReq:{}"
,
sendUrl
,
content
);
resp
=
HttpUtil
.
doPost
(
sendUrl
,
header
,
content
);
log
.
debug
(
"sendMessageResp:{}"
,
resp
);
}
catch
(
Exception
e
)
{
log
.
error
(
"异常:"
,
e
);
}
}
}
base-manager/src/main/java/com/mortals/xhx/common/utils/SendTaskThreadPool.java
0 → 100644
View file @
312e4679
package
com.mortals.xhx.common.utils
;
import
org.springframework.stereotype.Component
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ThreadPoolExecutor
;
/**
* 发送任务线程池
*
* @author: zxfei
* @date: 2022/4/28 10:52
*/
@Component
public
class
SendTaskThreadPool
{
/**
* 线程池
*/
private
ThreadPoolExecutor
threadPool
;
private
int
poolSize
;
private
volatile
boolean
isInit
=
false
;
private
Object
lock
=
new
Object
();
public
void
init
(
Integer
threadNum
)
{
if
(
poolSize
<
0
)
{
throw
new
IllegalArgumentException
();
}
if
(
poolSize
<
Runtime
.
getRuntime
().
availableProcessors
())
{
poolSize
=
Runtime
.
getRuntime
().
availableProcessors
()
+
1
;
}
if
(!
isInit
)
{
synchronized
(
lock
)
{
if
(!
isInit
)
{
threadPool
=
(
ThreadPoolExecutor
)
Executors
.
newFixedThreadPool
(
threadNum
);
isInit
=
true
;
}
}
}
}
public
void
execute
(
Runnable
command
)
{
threadPool
.
execute
(
command
);
}
public
void
setPoolSize
(
int
poolSize
)
{
threadPool
.
setCorePoolSize
(
poolSize
);
threadPool
.
setMaximumPoolSize
(
poolSize
);
}
public
void
incrementPoolSize
(
int
delta
)
{
setPoolSize
(
threadPool
.
getCorePoolSize
()
+
delta
);
}
public
synchronized
void
close
()
{
if
(
threadPool
!=
null
)
{
threadPool
.
shutdown
();
threadPool
=
null
;
isInit
=
false
;
}
}
}
base-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/DemoStartService.java
View file @
312e4679
package
com.mortals.xhx.daemon.applicationservice
;
import
com.mortals.framework.util.ThreadPool
;
import
com.mortals.xhx.common.utils.SendTaskThreadPool
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -13,11 +14,14 @@ import com.mortals.framework.springcloud.service.IApplicationService;
public
class
DemoStartService
implements
IApplicationService
{
private
static
Log
logger
=
LogFactory
.
getLog
(
DemoStartService
.
class
);
@Autowired
private
SendTaskThreadPool
sendTaskThreadPool
;
@Override
public
void
start
()
{
ThreadPool
.
getInstance
().
init
(
10
);
sendTaskThreadPool
.
init
(
10
);
logger
.
info
(
"开始服务..[配置已加载完成,但部分框架还未初始化,比如:Kafka]"
);
}
...
...
base-manager/src/main/java/com/mortals/xhx/module/app/service/impl/AppServiceImpl.java
View file @
312e4679
...
...
@@ -66,7 +66,7 @@ public class AppServiceImpl extends AbstractCRUDServiceImpl<AppDao, AppEntity, L
@Override
protected
void
findAfter
(
AppEntity
params
,
PageInfo
pageInfo
,
Context
context
,
List
<
AppEntity
>
list
)
throws
AppException
{
//排序
if
(!
ObjectUtils
.
isEmpty
(
params
.
getIdList
()))
{
/*
if (!ObjectUtils.isEmpty(params.getIdList())) {
//根据idList进行排序
for (int i = 0; i < params.getIdList().size(); i++) {
Long id = params.getIdList().get(i);
...
...
@@ -80,7 +80,7 @@ public class AppServiceImpl extends AbstractCRUDServiceImpl<AppDao, AppEntity, L
}
}
}
}
}
*/
//统计站点
list
.
forEach
(
item
->
{
List
<
AppEntity
>
appEntityList
=
this
.
find
(
new
AppQuery
().
appCode
(
item
.
getAppCode
()),
context
);
...
...
base-manager/src/main/java/com/mortals/xhx/module/business/service/impl/BusinessServiceImpl.java
View file @
312e4679
package
com.mortals.xhx.module.business.service.impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.ap.GlobalSysInfo
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl
;
import
com.mortals.xhx.base.system.message.MessageService
;
import
com.mortals.xhx.busiz.req.ApiThirdPartyReq
;
import
com.mortals.xhx.busiz.req.BussinessThirdPartyReq
;
import
com.mortals.xhx.common.code.IsBusinessEnum
;
import
com.mortals.xhx.common.code.ThirdPartyStatusEnum
;
import
com.mortals.xhx.common.code.ThirdPartyTypeEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.module.business.model.*
;
import
com.mortals.xhx.module.business.service.BusinessMatterService
;
import
com.mortals.xhx.module.business.dao.BusinessDao
;
import
com.mortals.xhx.module.business.model.BusinessEntity
;
import
com.mortals.xhx.module.business.model.BusinessQuery
;
import
com.mortals.xhx.module.business.service.BusinessService
;
import
com.mortals.xhx.module.site.model.SiteBusinessEntity
;
import
com.mortals.xhx.module.site.model.SiteBusinessQuery
;
import
com.mortals.xhx.module.site.model.SiteEntity
;
import
com.mortals.xhx.module.site.service.SiteBusinessService
;
import
com.mortals.xhx.module.site.service.SiteService
;
import
com.mortals.xhx.module.window.model.WindowBusinessEntity
;
import
com.mortals.xhx.module.window.model.WindowBusinessQuery
;
import
com.mortals.xhx.module.window.service.WindowBusinessService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.xhx.common.code.SatusEnum
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.xhx.module.business.dao.BusinessDao
;
import
com.mortals.xhx.module.business.service.BusinessService
;
import
org.springframework.util.ObjectUtils
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
static
com
.
mortals
.
framework
.
ap
.
SysConstains
.
RESULT_KEY
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.
PARAM_SERVER_PHP_HTTP_URL
;
/**
* BusinessService
...
...
@@ -38,11 +46,17 @@ import static com.mortals.framework.ap.SysConstains.RESULT_KEY;
* @date 2022-01-13
*/
@Service
(
"businessService"
)
@Slf4j
public
class
BusinessServiceImpl
extends
AbstractCRUDCacheServiceImpl
<
BusinessDao
,
BusinessEntity
,
Long
>
implements
BusinessService
{
@Autowired
private
SiteBusinessService
siteBusinessService
;
@Autowired
private
WindowBusinessService
windowBusinessService
;
@Autowired
private
SiteService
siteService
;
@Autowired
private
MessageService
messageService
;
@Override
protected
void
findAfter
(
BusinessEntity
params
,
PageInfo
pageInfo
,
Context
context
,
List
<
BusinessEntity
>
list
)
throws
AppException
{
...
...
@@ -87,21 +101,97 @@ public class BusinessServiceImpl extends AbstractCRUDCacheServiceImpl<BusinessDa
.
filter
(
item
->
!
item
.
getBusinessName
().
equals
(
entity
.
getName
()))
.
peek
(
item
->
item
.
setBusinessName
(
entity
.
getName
()))
.
collect
(
Collectors
.
toList
());
if
(!
ObjectUtils
.
isEmpty
(
siteBusinessEntities
))
{
siteBusinessService
.
update
(
siteBusinessEntities
,
context
);
if
(!
ObjectUtils
.
isEmpty
(
siteBusinessEntities
))
{
siteBusinessService
.
update
(
siteBusinessEntities
,
context
);
}
//通知第三方平台
String
phpUrl
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_PHP_HTTP_URL
,
"http://172.15.28.116:8090"
);
phpUrl
+=
"/inter/device/baseDataSave"
;
BussinessThirdPartyReq
bussinessThirdPartyReq
=
new
BussinessThirdPartyReq
();
BeanUtils
.
copyProperties
(
entity
,
bussinessThirdPartyReq
,
BeanUtil
.
getNullPropertyNames
(
entity
));
ApiThirdPartyReq
<
BussinessThirdPartyReq
>
apiThirdPartyReq
=
new
ApiThirdPartyReq
<>();
apiThirdPartyReq
.
setCode
(
YesNoEnum
.
YES
.
getValue
());
apiThirdPartyReq
.
setType
(
ThirdPartyTypeEnum
.
业务
.
getValue
());
apiThirdPartyReq
.
setStatus
(
ThirdPartyStatusEnum
.
修改
.
getValue
());
apiThirdPartyReq
.
setData
(
bussinessThirdPartyReq
);
messageService
.
sendThirdParty
(
phpUrl
,
JSON
.
toJSONString
(
apiThirdPartyReq
));
super
.
updateAfter
(
entity
,
context
);
}
@Override
protected
void
removeBefore
(
Long
[]
ids
,
Context
context
)
throws
AppException
{
Set
<
Long
>
idSet
=
Arrays
.
asList
(
ids
).
stream
().
collect
(
Collectors
.
toSet
());
List
<
BusinessEntity
>
businessEntities
=
this
.
get
(
ids
,
context
);
//有子节点 禁止删除
List
<
BusinessEntity
>
collect
=
businessEntities
.
stream
().
filter
(
f
->
IsBusinessEnum
.
一级业务
.
getValue
()
==
f
.
getIsBusiness
()).
collect
(
Collectors
.
toList
());
if
(!
ObjectUtils
.
isEmpty
(
collect
))
{
//删除节点包含一级节点,查询删除的子节点 是否包含在所有
for
(
BusinessEntity
businessEntity
:
collect
)
{
List
<
BusinessEntity
>
childList
=
this
.
find
(
new
BusinessQuery
().
parentId
(
businessEntity
.
getId
()));
boolean
bool
=
false
;
for
(
BusinessEntity
child
:
childList
)
{
if
(!
idSet
.
contains
(
child
.
getId
()))
{
bool
=
true
;
break
;
}
if
(
bool
)
{
throw
new
AppException
(
"删除的父业务存在子业务,不能删除"
);
}
}
}
}
String
phpUrl
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_PHP_HTTP_URL
,
"http://172.15.28.116:8090"
);
phpUrl
+=
"/inter/device/baseDataSave"
;
for
(
BusinessEntity
entity
:
businessEntities
)
{
BussinessThirdPartyReq
bussinessThirdPartyReq
=
new
BussinessThirdPartyReq
();
BeanUtils
.
copyProperties
(
entity
,
bussinessThirdPartyReq
,
BeanUtil
.
getNullPropertyNames
(
entity
));
ApiThirdPartyReq
<
BussinessThirdPartyReq
>
apiThirdPartyReq
=
new
ApiThirdPartyReq
<>();
apiThirdPartyReq
.
setCode
(
YesNoEnum
.
YES
.
getValue
());
apiThirdPartyReq
.
setType
(
ThirdPartyTypeEnum
.
业务
.
getValue
());
apiThirdPartyReq
.
setStatus
(
ThirdPartyStatusEnum
.
删除
.
getValue
());
apiThirdPartyReq
.
setData
(
bussinessThirdPartyReq
);
messageService
.
sendThirdParty
(
phpUrl
,
JSON
.
toJSONString
(
apiThirdPartyReq
));
}
super
.
removeBefore
(
ids
,
context
);
}
/**
* @param ids
* @param context
* @param result
* @throws AppException
*/
@Override
protected
void
removeAfter
(
Long
[]
ids
,
Context
context
,
int
result
)
throws
AppException
{
super
.
removeAfter
(
ids
,
context
,
result
);
if
(!
ObjectUtils
.
isEmpty
(
ids
))
{
//级联删除窗口业务
WindowBusinessQuery
windowBusinessQuery
=
new
WindowBusinessQuery
();
windowBusinessQuery
.
setSiteBusinessIdList
(
Arrays
.
asList
(
ids
));
List
<
WindowBusinessEntity
>
windowBusinessEntities
=
windowBusinessService
.
find
(
windowBusinessQuery
);
log
.
info
(
"remove windowBusinessEntities size:{}"
,
windowBusinessEntities
.
size
());
if
(!
ObjectUtils
.
isEmpty
(
windowBusinessEntities
))
{
Long
[]
idList
=
windowBusinessEntities
.
stream
().
map
(
item
->
item
.
getId
()).
toArray
(
Long
[]::
new
);
windowBusinessService
.
remove
(
idList
,
context
);
}
/* SiteBusinessQuery siteBusinessQuery = new SiteBusinessQuery();
siteBusinessQuery.setBusinessIdList(Arrays.asList(ids));
List<SiteBusinessEntity> siteBusinessEntities = siteBusinessService.find(siteBusinessQuery);
log.info("remove siteBusinessEntities size:{}", siteBusinessEntities.size());
if (!ObjectUtils.isEmpty(siteBusinessEntities)) {
Long[] idList = siteBusinessEntities.stream().map(item -> item.getId()).toArray(Long[]::new);
siteBusinessService.remove(idList, context);
}*/
}
}
@Override
public
void
addBusinessToSite
(
String
businessIds
,
Long
siteId
,
Context
context
)
{
...
...
@@ -109,7 +199,6 @@ public class BusinessServiceImpl extends AbstractCRUDCacheServiceImpl<BusinessDa
throw
new
AppException
(
"请选择对应站点"
);
}
List
<
Long
>
businessIdList
=
Arrays
.
asList
(
businessIds
.
split
(
","
)).
stream
().
map
(
Long:
:
parseLong
).
collect
(
Collectors
.
toList
());
//先删除后再新增
SiteBusinessQuery
siteBusinessQuery
=
new
SiteBusinessQuery
();
siteBusinessQuery
.
setSiteId
(
siteId
);
...
...
@@ -119,6 +208,7 @@ public class BusinessServiceImpl extends AbstractCRUDCacheServiceImpl<BusinessDa
if
(!
ObjectUtils
.
isEmpty
(
ids
))
{
siteBusinessService
.
remove
(
ids
,
context
);
}
BusinessQuery
businessQuery
=
new
BusinessQuery
();
businessQuery
.
setIdList
(
businessIdList
);
this
.
find
(
businessQuery
).
stream
()
...
...
@@ -129,23 +219,34 @@ public class BusinessServiceImpl extends AbstractCRUDCacheServiceImpl<BusinessDa
}
@Override
public
Result
<
BusinessEntity
>
flatList
(
BusinessEntity
query
,
PageInfo
pageInfo
,
Context
context
)
{
public
Result
<
BusinessEntity
>
flatList
(
BusinessEntity
query
,
PageInfo
pageInfo
,
Context
context
)
{
Result
<
BusinessEntity
>
result
=
this
.
dao
.
getList
(
query
,
pageInfo
);
return
result
;
}
private
void
updateOrSave
(
BusinessEntity
item
,
Long
siteId
,
Context
context
)
{
SiteBusinessEntity
siteBusinessEntity
=
new
SiteBusinessEntity
();
BeanUtils
.
copyProperties
(
item
,
siteBusinessEntity
,
BeanUtil
.
getNullPropertyNames
(
item
));
// BeanUtils.copyProperties(item, siteBusinessEntity, BeanUtil.getNullPropertyNames(item));
SiteEntity
siteEntity
=
siteService
.
get
(
siteId
);
if
(
ObjectUtils
.
isEmpty
(
siteEntity
))
{
if
(
ObjectUtils
.
isEmpty
(
siteEntity
))
{
throw
new
AppException
(
"未找到相应站点!"
);
}
siteBusinessEntity
.
setSiteId
(
siteEntity
.
getId
());
siteBusinessEntity
.
setSiteName
(
siteEntity
.
getSiteName
());
siteBusinessEntity
.
setBusinessId
(
item
.
getId
());
siteBusinessEntity
.
setBusinessName
(
item
.
getName
());
siteBusinessEntity
.
setId
(
null
);
siteBusinessEntity
.
setAncestors
(
item
.
getAncestors
());
siteBusinessEntity
.
setIsBusiness
(
item
.
getIsBusiness
());
siteBusinessEntity
.
setParentId
(
item
.
getParentId
());
siteBusinessEntity
.
setStatus
(
item
.
getStatus
());
siteBusinessEntity
.
setRemark
(
item
.
getRemark
());
siteBusinessEntity
.
setCanorder
(
item
.
getCanorder
());
siteBusinessEntity
.
setCantake
(
item
.
getCantake
());
siteBusinessEntity
.
setDatashow
(
item
.
getDatashow
());
siteBusinessEntity
.
setEnglishname
(
item
.
getEnglishname
());
siteBusinessEntity
.
setFlownum
(
item
.
getFlownum
());
siteBusinessEntity
.
setBusinessType
(
item
.
getBusinessType
());
siteBusinessEntity
.
setCreateUserId
(
context
==
null
?
1L
:
context
.
getUser
()
==
null
?
1L
:
context
.
getUser
().
getId
());
siteBusinessEntity
.
setCreateTime
(
new
Date
());
...
...
@@ -182,6 +283,5 @@ public class BusinessServiceImpl extends AbstractCRUDCacheServiceImpl<BusinessDa
System
.
out
.
println
(
JSON
.
toJSONString
(
siteBusinessQuery
));
}
}
\ No newline at end of file
base-manager/src/main/java/com/mortals/xhx/module/site/service/impl/SiteBusinessServiceImpl.java
View file @
312e4679
...
...
@@ -6,7 +6,6 @@ import com.mortals.framework.model.Context;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl
;
import
com.mortals.xhx.common.code.BusinessTypeEnum
;
import
com.mortals.xhx.common.code.IsBusinessEnum
;
import
com.mortals.xhx.module.business.model.BusinessEntity
;
import
com.mortals.xhx.module.business.model.BusinessMatterEntity
;
...
...
@@ -88,8 +87,6 @@ public class SiteBusinessServiceImpl extends AbstractCRUDCacheServiceImpl<SiteBu
protected
void
findAfter
(
SiteBusinessEntity
params
,
PageInfo
pageInfo
,
Context
context
,
List
<
SiteBusinessEntity
>
list
)
throws
AppException
{
if
(!
ObjectUtils
.
isEmpty
(
params
.
getIdNotList
()))
{
//排除掉已经存在的ids
log
.
info
(
"idNotList:{}"
,
JSON
.
toJSONString
(
params
.
getIdNotList
()));
Iterator
<
SiteBusinessEntity
>
iterator
=
list
.
iterator
();
...
...
@@ -155,19 +152,8 @@ public class SiteBusinessServiceImpl extends AbstractCRUDCacheServiceImpl<SiteBu
}
}
@Override
protected
void
saveBefore
(
SiteBusinessEntity
entity
,
Context
context
)
throws
AppException
{
}
@Override
protected
void
updateBefore
(
SiteBusinessEntity
entity
,
Context
context
)
throws
AppException
{
super
.
updateBefore
(
entity
,
context
);
}
@Override
protected
void
updateAfter
(
SiteBusinessEntity
entity
,
Context
context
)
throws
AppException
{
//更新事项业务表中字段
List
<
BusinessMatterEntity
>
businessMatterEntities
=
businessMatterService
.
find
(
new
BusinessMatterQuery
().
siteBusinessId
(
entity
.
getId
()))
.
stream
()
...
...
@@ -177,20 +163,34 @@ public class SiteBusinessServiceImpl extends AbstractCRUDCacheServiceImpl<SiteBu
if
(!
ObjectUtils
.
isEmpty
(
businessMatterEntities
))
{
businessMatterService
.
update
(
businessMatterEntities
,
context
);
}
super
.
updateAfter
(
entity
,
context
);
}
@Override
protected
void
removeBefore
(
Long
[]
ids
,
Context
context
)
throws
AppException
{
L
ong
[]
childI
ds
=
Arrays
.
asList
(
ids
).
stream
()
L
ist
<
SiteBusinessEntity
>
chil
ds
=
Arrays
.
asList
(
ids
).
stream
()
.
flatMap
(
item
->
{
SiteBusinessEntity
siteBusinessEntity
=
this
.
get
(
item
);
return
this
.
find
(
new
SiteBusinessQuery
().
parentId
(
siteBusinessEntity
.
getBusinessId
())).
stream
();
}).
map
(
item
->
item
.
getId
()).
toArray
(
Long
[]::
new
);
return
this
.
find
(
new
SiteBusinessQuery
().
parentId
(
siteBusinessEntity
.
getId
())).
stream
();
}).
collect
(
Collectors
.
toList
());
log
.
info
(
"delete childs list:{}"
,
JSON
.
toJSONString
(
childs
));
Long
[]
childIds
=
childs
.
stream
().
map
(
item
->
item
.
getId
()).
toArray
(
Long
[]::
new
);
this
.
getDao
().
delete
(
childIds
);
Long
[]
bussinessIds
=
childs
.
stream
().
map
(
item
->
item
.
getBusinessId
()).
toArray
(
Long
[]::
new
);
log
.
info
(
"childBussinessIds:{}"
,
JSON
.
toJSONString
(
bussinessIds
));
if
(!
ObjectUtils
.
isEmpty
(
bussinessIds
)){
businessService
.
remove
(
bussinessIds
,
context
);
}
Long
[]
mainIds
=
this
.
get
(
ids
,
context
).
stream
().
map
(
item
->
item
.
getBusinessId
()).
toArray
(
Long
[]::
new
);
if
(!
ObjectUtils
.
isEmpty
(
mainIds
)){
//删除
businessService
.
remove
(
mainIds
,
context
);
}
}
...
...
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