Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 9d156871
authored
Nov 06, 2023
by
huangjinxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:bean组织机构数据同步,工单一家多单分组优化
1 parent
c3266f4a
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
129 additions
and
31 deletions
project-order/src/main/java/com/dituhui/pea/order/dao/OrgTeamEngineerDao.java
project-order/src/main/java/com/dituhui/pea/order/enums/AppointmentMethodEnum.java
project-order/src/main/java/com/dituhui/pea/order/enums/BeanServiceFlowEnum.java
project-order/src/main/java/com/dituhui/pea/order/feign/bean/enums/BeanRegionIdEnum.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/BeanRemoteServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/DispatchServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderCreateServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderInfoServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/dao/OrgTeamEngineerDao.java
View file @
9d15687
...
...
@@ -17,7 +17,7 @@ public interface OrgTeamEngineerDao extends JpaRepository<OrgTeamEngineerEntity,
@Query
(
"select t from OrgTeamEngineerEntity t where t.teamId = :teamId and t.status=1"
)
List
<
OrgTeamEngineerEntity
>
findAllByTeamId
(
String
teamId
);
@Query
(
"select t from OrgTeamEngineerEntity t where t.teamId = :teamId and t.engineerCode=:engineerCode"
)
OrgTeamEngineerEntity
findByTeamIdAndEngineerCode
(
String
teamId
,
String
engineerCode
);
...
...
@@ -35,5 +35,5 @@ public interface OrgTeamEngineerDao extends JpaRepository<OrgTeamEngineerEntity,
@Query
(
"UPDATE OrgTeamEngineerEntity tt SET tt.status = :status WHERE tt.teamId = :teamId AND tt.engineerCode IN :engineerCodes"
)
void
updateStatusByEngineerCodes
(
String
teamId
,
List
<
String
>
engineerCodes
,
int
status
);
OrgTeamEngineerEntity
findByEngineerCode
(
String
engineerCode
);
List
<
OrgTeamEngineerEntity
>
findByEngineerCode
(
String
engineerCode
);
}
project-order/src/main/java/com/dituhui/pea/order/enums/AppointmentMethodEnum.java
View file @
9d15687
...
...
@@ -2,5 +2,5 @@ package com.dituhui.pea.order.enums;
public
enum
AppointmentMethodEnum
{
// 指派方式(MANUAL人工/AUTO_NOW 自动立即/AUTO_BATCH/PROTECTION 自保点)
MANUAL
,
AUTO_NOW
,
AUTO_BATCH
,
PROTECTION
MANUAL
,
AUTO_NOW
,
AUTO_BATCH
,
PROTECTION
,
CANCELED
,
}
project-order/src/main/java/com/dituhui/pea/order/enums/BeanServiceFlowEnum.java
View file @
9d15687
...
...
@@ -11,6 +11,7 @@ public enum BeanServiceFlowEnum {
PENDING
(
"已联系"
,
"PENDING"
),
CONTACTED
(
"准备服务"
,
"CONTACTED"
),
STARTED
(
"开始服务"
,
"STARTED"
),
CANCELED
(
"已取消"
,
"CANCELED"
),
FINISHED
(
"结束服务"
,
"FINISHED"
);
private
String
name
;
...
...
project-order/src/main/java/com/dituhui/pea/order/feign/bean/enums/BeanRegionIdEnum.java
0 → 100644
View file @
9d15687
package
com
.
dituhui
.
pea
.
order
.
feign
.
bean
.
enums
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.List
;
public
enum
BeanRegionIdEnum
{
// 上海大区,部门ID:1575934909016727553,华东大区:1575934912659275778
SHANGHAIDAQU
(
"1575934909016727553"
),
HUADONGDAQU
(
"1575934912659275778"
),
;
private
String
id
;
BeanRegionIdEnum
(
String
id
)
{
this
.
id
=
id
;
}
public
static
Boolean
getEnumByRegionId
(
String
regionId
)
{
if
(
StringUtils
.
isBlank
(
regionId
))
{
return
false
;
}
BeanRegionIdEnum
[]
beanRegionIdEnums
=
BeanRegionIdEnum
.
values
();
for
(
BeanRegionIdEnum
regionIdEnum
:
beanRegionIdEnums
)
{
if
(
regionId
.
equals
(
regionIdEnum
.
id
))
{
return
true
;
}
}
return
false
;
}
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/BeanRemoteServiceImpl.java
View file @
9d15687
...
...
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.alibaba.nacos.common.utils.CollectionUtils
;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.enums.StatusCodeEnum
;
import
com.dituhui.pea.order.common.RedisService
;
import
com.dituhui.pea.order.common.jackson.JsonUtil
;
import
com.dituhui.pea.order.dao.OrgBranchDao
;
...
...
@@ -16,6 +17,7 @@ import com.dituhui.pea.order.entity.OrgGroupEntity;
import
com.dituhui.pea.order.feign.IBeanRemoteService
;
import
com.dituhui.pea.order.feign.bean.*
;
import
com.dituhui.pea.order.feign.bean.enums.BeanOrgLevelEnum
;
import
com.dituhui.pea.order.feign.bean.enums.BeanRegionIdEnum
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.codec.digest.DigestUtils
;
...
...
@@ -24,10 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.*
;
/**
* 调用BEAN远程接口实现
...
...
@@ -42,6 +41,13 @@ public class BeanRemoteServiceImpl {
private
final
RedisService
redisService
;
//组织机构map,防止重复查询数据库
private
static
Map
<
String
,
OrgBranchEntity
>
branchMap
=
new
HashMap
<>();
// 上海大区,部门ID:1575934909016727553,华东大区:1575934912659275778
private
static
List
<
String
>
regionIds
=
new
ArrayList
<>()
{
{
add
(
"1575934909016727553"
);
add
(
"1575934912659275778"
);
}
};
@Value
(
"${bean.app-key}"
)
private
String
appKey
;
...
...
@@ -154,21 +160,68 @@ public class BeanRemoteServiceImpl {
return
Result
.
failed
(
beanR
.
getMessage
());
}
for
(
Department
department
:
beanR
.
getData
())
{
if
(
StringUtils
.
isBlank
(
department
.
getBsDeptId
()))
{
continue
;
}
log
.
info
(
"处理部门详情---->{}"
,
department
.
getBsDeptId
());
Result
result
=
this
.
departmentDetail
(
accessToken
,
department
.
getBsDeptId
());
log
.
info
(
"处理部门详情,id:{},结果---->{}"
,
department
.
getBsDeptId
(),
result
.
getCode
());
Boolean
isDisposeData
=
true
;
if
(!
BeanRegionIdEnum
.
getEnumByRegionId
(
department
.
getBsDeptId
()))
{
log
.
info
(
"处理部门详情ID不在所需同步大区---->{}"
,
department
.
getBsDeptId
());
isDisposeData
=
false
;
}
if
(
isDisposeData
)
{
System
.
out
.
println
(
222
);
Result
result
=
this
.
departmentDetail
(
accessToken
,
department
.
getBsDeptId
(),
null
);
log
.
info
(
"处理部门详情,id:{},结果---->{}"
,
department
.
getBsDeptId
(),
result
.
getCode
());
if
(
result
.
getCode
().
equals
(
StatusCodeEnum
.
SUCCESS
.
getCode
())
&&
ObjUtil
.
isNotNull
(
department
.
getChildren
()))
{
continue
;
}
}
disposeChildren
(
department
,
accessToken
,
isDisposeData
,
null
);
System
.
out
.
println
(
111
);
}
return
Result
.
success
();
}
/**
* 处理子部门
*
* @param departments
* @param accessToken
*/
private
void
disposeChildren
(
Department
departments
,
String
accessToken
,
Boolean
isDisposeData
,
String
parentId
)
{
for
(
Department
department
:
departments
.
getChildren
())
{
if
(
StringUtils
.
isBlank
(
department
.
getBsDeptId
()))
{
return
;
}
log
.
info
(
"处理部门详情---->{}"
,
department
.
getBsDeptId
());
if
(!
BeanRegionIdEnum
.
getEnumByRegionId
(
department
.
getBsDeptId
()))
{
log
.
info
(
"处理部门详情ID不在所需同步大区---->{}"
,
department
.
getBsDeptId
());
}
else
{
isDisposeData
=
true
;
}
if
(
isDisposeData
)
{
System
.
out
.
println
(
222
);
Result
result
=
this
.
departmentDetail
(
accessToken
,
department
.
getBsDeptId
(),
departments
.
getBsDeptId
());
log
.
info
(
"处理部门详情,id:{},结果---->{}"
,
department
.
getBsDeptId
(),
result
.
getCode
());
if
(
result
.
getCode
().
equals
(
StatusCodeEnum
.
SUCCESS
.
getCode
())
&&
ObjUtil
.
isNotNull
(
department
.
getChildren
()))
{
continue
;
}
}
disposeChildren
(
department
,
accessToken
,
isDisposeData
,
departments
.
getBsDeptId
());
}
}
/**
* 处理单极机构,包含大区,分部,分站
*
* @param token
* @param orgId
* @return
*/
public
Result
departmentDetail
(
String
token
,
String
orgId
)
{
public
Result
departmentDetail
(
String
token
,
String
orgId
,
String
parentId
)
{
//获取token
BeanR
<
Department
>
departmentBeanR
=
beanRemoteService
.
departmentDetail
(
token
,
orgId
);
if
(!
departmentBeanR
.
getSuccess
()
||
ObjUtil
.
isNull
(
departmentBeanR
.
getData
()))
{
...
...
@@ -182,10 +235,11 @@ public class BeanRemoteServiceImpl {
if
(
ObjUtil
.
isNull
(
clusterEntity
))
{
clusterEntity
=
new
OrgClusterEntity
();
}
clusterEntity
.
setName
(
data
.
getTagName
());
clusterEntity
.
setName
(
StringUtils
.
isNotBlank
(
data
.
getDesc
())
?
data
.
getDesc
()
:
data
.
getTagName
());
clusterEntity
.
setClusterId
(
data
.
getBsDeptId
());
clusterEntity
.
setAbbreviation
(
data
.
getAbbreviation
());
clusterEntity
.
setStatus
(
data
.
getEnable
());
clusterEntity
.
setCitycodeList
(
CollectionUtils
.
isEmpty
(
data
.
getManageCityList
())
?
""
:
JSONObject
.
toJSONString
(
data
.
getManageCityList
()));
clusterEntity
.
setCitycodeList
(
CollectionUtils
.
isEmpty
(
data
.
getManageCityList
())
?
"
{}
"
:
JSONObject
.
toJSONString
(
data
.
getManageCityList
()));
clusterEntity
.
setMemo
(
data
.
getDesc
());
clusterEntity
.
setCode
(
data
.
getCode
());
clusterEntity
.
setPhone
(
data
.
getPhone
());
...
...
@@ -197,16 +251,18 @@ public class BeanRemoteServiceImpl {
if
(
ObjUtil
.
isNull
(
branchEntity
))
{
branchEntity
=
new
OrgBranchEntity
();
}
branchEntity
.
setBranchName
(
data
.
getTagName
());
// branchEntity.setBranchName(data.getTagName());
branchEntity
.
setBranchName
(
StringUtils
.
isNotBlank
(
data
.
getDesc
())
?
data
.
getDesc
()
:
data
.
getTagName
());
branchEntity
.
setBranchId
(
data
.
getBsDeptId
());
branchEntity
.
setAbbreviation
(
data
.
getAbbreviation
());
branchEntity
.
setStatus
(
data
.
getEnable
());
branchEntity
.
setCitycodeList
(
CollectionUtils
.
isEmpty
(
data
.
getManageCityList
())
?
""
:
JSONObject
.
toJSONString
(
data
.
getManageCityList
()));
branchEntity
.
setCitycodeList
(
CollectionUtils
.
isEmpty
(
data
.
getManageCityList
())
?
"
{}
"
:
JSONObject
.
toJSONString
(
data
.
getManageCityList
()));
branchEntity
.
setMemo
(
data
.
getDesc
());
branchEntity
.
setCode
(
data
.
getCode
());
branchEntity
.
setPhone
(
data
.
getPhone
());
branchEntity
.
setWarehouseEnabled
(
data
.
getPeripheralWarehouseEnabled
());
branchEntity
.
setReserveTimeMax
(
data
.
getPartReserveTimeMax
());
branchEntity
.
setClusterId
(
data
.
getParentId
()
);
branchEntity
.
setClusterId
(
parentId
);
orgBranchDao
.
save
(
branchEntity
);
branchMap
.
put
(
data
.
getBsDeptId
(),
branchEntity
);
}
...
...
@@ -218,25 +274,27 @@ public class BeanRemoteServiceImpl {
if
(
ObjUtil
.
isNull
(
groupEntity
))
{
groupEntity
=
new
OrgGroupEntity
();
}
groupEntity
.
setGroupName
(
data
.
getTagName
());
// groupEntity.setGroupName(data.getTagName());
groupEntity
.
setGroupName
(
StringUtils
.
isNotBlank
(
data
.
getDesc
())
?
data
.
getDesc
()
:
data
.
getTagName
());
groupEntity
.
setGroupId
(
data
.
getBsDeptId
());
groupEntity
.
setAbbreviation
(
data
.
getAbbreviation
());
groupEntity
.
setStatus
(
data
.
getEnable
());
groupEntity
.
setCitycodeList
(
CollectionUtils
.
isEmpty
(
data
.
getManageCityList
())
?
""
:
JSONObject
.
toJSONString
(
data
.
getManageCityList
()));
groupEntity
.
setCitycodeList
(
CollectionUtils
.
isEmpty
(
data
.
getManageCityList
())
?
"
{}
"
:
JSONObject
.
toJSONString
(
data
.
getManageCityList
()));
groupEntity
.
setMemo
(
data
.
getDesc
());
groupEntity
.
setCode
(
data
.
getCode
());
groupEntity
.
setPhone
(
data
.
getPhone
());
groupEntity
.
setWarehouseEnabled
(
data
.
getPeripheralWarehouseEnabled
());
groupEntity
.
setReserveTimeMax
(
data
.
getPartReserveTimeMax
());
//处理clusterId和branchId
OrgBranchEntity
branchEntity
=
branchMap
.
get
(
data
.
getParentId
()
);
OrgBranchEntity
branchEntity
=
branchMap
.
get
(
parentId
);
if
(
ObjUtil
.
isNull
(
branchEntity
))
{
branchEntity
=
orgBranchDao
.
getByBranchId
(
data
.
getParentId
()
);
branchEntity
=
orgBranchDao
.
getByBranchId
(
parentId
);
if
(
ObjUtil
.
isNull
(
branchEntity
))
{
return
Result
.
failed
();
}
branchMap
.
put
(
data
.
getParentId
()
,
branchEntity
);
branchMap
.
put
(
parentId
,
branchEntity
);
}
groupEntity
.
setBranchId
(
data
.
getParentId
()
);
groupEntity
.
setBranchId
(
parentId
);
groupEntity
.
setClusterId
(
branchEntity
.
getClusterId
());
//处理分站外围
if
(
data
.
getDeptType
().
equals
(
BeanOrgLevelEnum
.
PERIPHERY
.
getCode
()))
{
...
...
@@ -268,8 +326,8 @@ public class BeanRemoteServiceImpl {
}
for
(
ServiceOrg
serviceOrg
:
listBeanR
.
getData
())
{
log
.
info
(
"处理网点部门详情---->{}"
,
serviceOrg
.
getServiceOrgId
());
Result
result
=
this
.
serviceOrgDetail
(
accessToken
,
serviceOrg
);
log
.
info
(
"处理网点部门详情,id:{},结果---->{}"
,
serviceOrg
.
getServiceOrgId
(),
result
.
getCode
());
//
Result result = this.serviceOrgDetail(accessToken, serviceOrg);
//
log.info("处理网点部门详情,id:{},结果---->{}", serviceOrg.getServiceOrgId(), result.getCode());
}
return
Result
.
success
();
}
...
...
@@ -285,6 +343,7 @@ public class BeanRemoteServiceImpl {
if
(
ObjUtil
.
isNull
(
groupEntity
))
{
groupEntity
=
new
OrgGroupEntity
();
}
groupEntity
.
setGroupId
(
data
.
getServiceOrgId
());
groupEntity
.
setGroupName
(
data
.
getName
());
groupEntity
.
setStatus
(
data
.
getStatus
());
groupEntity
.
setCitycodeList
(
CollectionUtils
.
isEmpty
(
data
.
getServiceRange
())
?
""
:
JSONObject
.
toJSONString
(
data
.
getServiceRange
()));
...
...
@@ -341,5 +400,4 @@ public class BeanRemoteServiceImpl {
return
accessTokenR
.
getData
();
}
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/DispatchServiceImpl.java
View file @
9d15687
...
...
@@ -399,7 +399,10 @@ public class DispatchServiceImpl implements DispatchService {
}
item
.
setMultipleOrderList
(
multipleItems
);
}
Object
groupkey
=
null
;
Object
groupkey
=
"其他"
;
if
(
groupTagId
.
equals
(
OrderGroupEnum
.
five
.
getCode
()))
{
groupkey
=
"一家一台"
;
}
// 0:工单优先级,1:耗时,2:意向时间,3:分站/网点,4:技能,5:一家多单
if
(
groupTagId
.
equals
(
OrderGroupEnum
.
zero
.
getCode
())
&&
StringUtils
.
isNotEmpty
(
item
.
getBeanPriority
()))
{
// 分组字段:紧急、正常 数据库:1:紧急、0:正常
...
...
@@ -432,9 +435,9 @@ public class DispatchServiceImpl implements DispatchService {
}
else
if
(
groupTagId
.
equals
(
OrderGroupEnum
.
four
.
getCode
())
&&
StringUtils
.
isNotEmpty
(
item
.
getSkill
()))
{
makeOrderMap
(
groupByMap
,
item
,
item
.
getSkill
());
}
else
if
(
groupTagId
.
equals
(
OrderGroupEnum
.
five
.
getCode
())
&&
StringUtils
.
isNotEmpty
(
item
.
getMultipleOrders
()))
{
makeOrderMap
(
groupByMap
,
item
,
"一家多台ID:"
+
item
.
getMultipleOrders
());
makeOrderMap
(
groupByMap
,
item
,
"一家多台ID:"
+
o
.
getAddressId
());
}
else
{
makeOrderMap
(
groupByMap
,
item
,
"其他"
);
makeOrderMap
(
groupByMap
,
item
,
groupkey
);
}
return
item
;
}
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderCreateServiceImpl.java
View file @
9d15687
...
...
@@ -167,8 +167,11 @@ public class OrderCreateServiceImpl implements OrderCreateService {
entity
.
setAppointEngineerCodes
(
appointEngineerCodes
);
if
(
req
.
getIsAppointEngineer
()
==
1
)
{
EngineerInfoEntity
engineerInfo
=
engineerInfoDao
.
getByEngineerCode
(
req
.
getAppointEngineerCodes
().
get
(
0
));
OrgTeamEngineerEntity
orgTeamEngineer
=
orgTeamEngineerDao
.
findByEngineerCode
(
req
.
getAppointEngineerCodes
().
get
(
0
));
OrgTeamEntity
byTeamId
=
orgTeamDao
.
getByTeamId
(
orgTeamEngineer
.
getTeamId
());
List
<
OrgTeamEngineerEntity
>
orgTeamEngineers
=
orgTeamEngineerDao
.
findByEngineerCode
(
req
.
getAppointEngineerCodes
().
get
(
0
));
if
(
CollectionUtils
.
isEmpty
(
orgTeamEngineers
))
{
return
Result
.
failed
(
StatusCodeEnum
.
FENDAN_TEAM_UNMATCHED
);
}
OrgTeamEntity
byTeamId
=
orgTeamDao
.
getByTeamId
(
orgTeamEngineers
.
get
(
0
).
getTeamId
());
entity
.
setEngineerCode
(
engineerInfo
.
getEngineerCode
());
entity
.
setEngineerName
(
engineerInfo
.
getName
());
entity
.
setEngineerPhone
(
engineerInfo
.
getPhone
());
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderInfoServiceImpl.java
View file @
9d15687
...
...
@@ -18,6 +18,7 @@ import com.dituhui.pea.order.entity.OrderInfoEntity;
import
com.dituhui.pea.order.entity.OrgBranchEntity
;
import
com.dituhui.pea.order.entity.OrgGroupEntity
;
import
com.dituhui.pea.order.entity.SkillInfoEntity
;
import
com.dituhui.pea.order.enums.AppointmentMethodEnum
;
import
com.dituhui.pea.order.enums.BeanServiceFlowEnum
;
import
com.dituhui.pea.order.enums.OrderStatusEnum
;
import
com.dituhui.pea.order.enums.ServiceStatusEnum
;
...
...
@@ -154,9 +155,9 @@ public class OrderInfoServiceImpl implements OrderInfoService {
//记录流程
commonService
.
addOrderEvent
(
request
.
getOrderId
(),
""
,
"BEAN"
,
"BEAN"
,
OrderStatusEnum
.
NORMAL
.
getDescription
(),
request
.
getStage
(),
""
,
LocalDateTimeUtil
.
of
(
request
.
getHappen
()));
}
else
if
(
request
.
getOrderStatus
().
equalsIgnoreCase
(
OrderStatusEnum
.
CANCELED
.
getCode
()))
{
orderInfo
.
setServiceStatus
(
""
);
orderInfo
.
setServiceStatus
(
BeanServiceFlowEnum
.
CANCELED
.
getStatus
()
);
orderInfo
.
setOrderStatus
(
OrderStatusEnum
.
CANCELED
.
getCode
());
orderInfo
.
setAppointmentStatus
(
""
);
orderInfo
.
setAppointmentStatus
(
AppointmentMethodEnum
.
CANCELED
.
name
()
);
if
(
StringUtils
.
isBlank
(
request
.
getDescription
()))
{
orderInfo
.
setDescription
(
request
.
getDescription
());
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment