Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-standard-interfaces
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit fd5d6634
authored
Apr 12, 2022
by
王欣伟
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
标准接口创建帐号开发
1 parent
a2207629
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
680 additions
and
0 deletions
src/main/java/cn/com/glsx/Application.java
src/main/java/cn/com/glsx/stdinterface/modules/api/ZhongliCreateAccountApiController.java
src/main/java/cn/com/glsx/stdinterface/modules/component/CreateNewAccountComponent.java
src/main/java/cn/com/glsx/stdinterface/modules/entity/ZhongliDepartment.java
src/main/java/cn/com/glsx/stdinterface/modules/entity/sync/DepartmentItem.java
src/main/java/cn/com/glsx/stdinterface/modules/mapper/VehicleMapper.java
src/main/java/cn/com/glsx/stdinterface/modules/mapper/ZhongliDepartmentMapper.java
src/main/java/cn/com/glsx/stdinterface/modules/model/CommonSyncApiRequest.java
src/main/java/cn/com/glsx/stdinterface/modules/service/RedisService.java
src/main/java/cn/com/glsx/stdinterface/modules/service/VehicleService.java
src/main/java/cn/com/glsx/stdinterface/modules/service/WorkOrderService.java
src/main/java/cn/com/glsx/stdinterface/modules/util/Pinyin.java
src/main/java/cn/com/glsx/stdinterface/modules/util/PinyinUtil.java
src/main/resources/mapper/VehicleMapper.xml
src/main/resources/mapper/ZhongliDepartmentMapper.xml
src/test/java/cn/com/glsx/stdinterface/modules/component/ZhongliAccountComponentTest.java
src/test/java/cn/com/glsx/stdinterface/modules/service/WorkOrderServiceTest.java
src/main/java/cn/com/glsx/Application.java
View file @
fd5d663
...
...
@@ -7,6 +7,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.context.annotation.EnableMBeanExport
;
import
org.springframework.jmx.support.RegistrationPolicy
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
javax.annotation.PostConstruct
;
...
...
@@ -18,6 +19,7 @@ import static java.util.TimeZone.getTimeZone;
/**
* @author payu
*/
@EnableAsync
@EnableRestAdmin
@EnableDiscoveryClient
@EnableFeignClients
(
basePackages
=
{
"cn.com.glsx.*.api"
})
...
...
src/main/java/cn/com/glsx/stdinterface/modules/api/ZhongliCreateAccountApiController.java
0 → 100644
View file @
fd5d663
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
api
;
import
cn.com.glsx.stdinterface.modules.component.CreateNewAccountComponent
;
import
cn.com.glsx.stdinterface.modules.model.CommonApiRequest
;
import
cn.com.glsx.stdinterface.modules.model.CommonSyncApiRequest
;
import
cn.com.glsx.stdinterface.modules.service.RedisService
;
import
com.alibaba.fastjson.JSONObject
;
import
com.glsx.plat.core.web.R
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
@Slf4j
@RestController
@RequestMapping
(
value
=
"/api/accountmanager"
)
public
class
ZhongliCreateAccountApiController
{
@Autowired
private
CreateNewAccountComponent
createNewAccountComponent
;
@Autowired
private
RedisService
redisService
;
@PostMapping
(
value
=
"/createNewAccount"
)
@ResponseBody
public
R
<
String
>
createNewAccount
(
@RequestBody
CommonSyncApiRequest
request
)
{
log
.
info
(
"create account:{}"
,
JSONObject
.
toJSONString
(
request
));
if
(
request
.
getTenantId
()==
null
||
request
.
getRoleId
()==
null
)
{
return
R
.
error
(
"租户ID不能为空,角色ID不能为空"
);
}
createNewAccountComponent
.
createNewAccountByOrgRelation
(
request
);
return
R
.
ok
();
}
}
src/main/java/cn/com/glsx/stdinterface/modules/component/CreateNewAccountComponent.java
0 → 100644
View file @
fd5d663
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
component
;
import
cn.com.glsx.stdinterface.modules.entity.ZhongliDepartment
;
import
cn.com.glsx.stdinterface.modules.entity.sync.DepartmentItem
;
import
cn.com.glsx.stdinterface.modules.mapper.ZhongliDepartmentMapper
;
import
cn.com.glsx.stdinterface.modules.model.CommonSyncApiRequest
;
import
cn.com.glsx.stdinterface.modules.service.RedisService
;
import
cn.com.glsx.stdinterface.modules.util.Pinyin
;
import
cn.com.glsx.usercenter.api.dto.request.SimpleAddUser
;
import
cn.com.glsx.usercenter.api.dto.response.User
;
import
cn.com.glsx.usercenter.api.feign.ApiUserService
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.glsx.plat.core.web.R
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
@Slf4j
@Component
public
class
CreateNewAccountComponent
{
@Autowired
private
ZhongliDepartmentMapper
zhongliDepartmentMapper
;
@Autowired
private
RedisService
redisService
;
@Autowired
private
ApiUserService
apiUserService
;
/**
* 异步创建帐号
* @param request
*/
// @Async("threadPoolTaskExecutor")
public
void
createNewAccountByOrgRelation
(
CommonSyncApiRequest
request
)
{
log
.
info
(
"async start:{}"
,
JSONObject
.
toJSONString
(
request
));
String
lockKey
=
"createNewAccountByOrgRelation_lock"
;
boolean
nxLock
=
getNxLock
(
lockKey
);
log
.
info
(
"createNewAccountByOrgRelation_lock result:{}"
,
nxLock
);
if
(!
nxLock
)
{
log
.
info
(
"createNewAccountByOrgRelation business not executor end.{}"
,
JSONObject
.
toJSONString
(
request
));
return
;
}
String
tenantName
=
zhongliDepartmentMapper
.
getTenantName
(
request
.
getTenantId
());
if
(!
tenantName
.
equals
(
request
.
getOrganization
()))
{
log
.
info
(
"tenant id and name not equals:{}"
,
tenantName
);
return
;
}
List
<
ZhongliDepartment
>
baseAccountList
=
zhongliDepartmentMapper
.
selectBaseAccount
();
Map
<
String
,
DepartmentItem
>
departmentItemMap
=
getDepartmentMapper
(
request
.
getTenantId
());
Map
<
String
,
Integer
>
accountNumMap
=
new
HashMap
<>();
for
(
ZhongliDepartment
zhongliDepartment
:
baseAccountList
)
{
String
userName
=
zhongliDepartment
.
getThreeLevel
()
+
zhongliDepartment
.
getFourLevel
();
String
account
=
Pinyin
.
getPinYinHeadChar
(
userName
);
// 处理重复帐号,自动加1
Integer
uCount
=
accountNumMap
.
get
(
account
);
if
(
uCount
!=
null
)
{
uCount
=
uCount
+
1
;
account
=
account
+
uCount
;
}
else
{
uCount
=
0
;
accountNumMap
.
put
(
account
,
uCount
);
}
log
.
info
(
"userName:{}, userAccount:{}"
,
userName
,
account
);
DepartmentItem
departmentItem
=
departmentItemMap
.
get
(
userName
);
if
(
departmentItem
==
null
)
{
log
.
info
(
"departmentInfo is empty:{}"
,
userName
);
}
// 创建帐号
SimpleAddUser
simpleAddUser
=
new
SimpleAddUser
();
simpleAddUser
.
setAccount
(
account
);
simpleAddUser
.
setTenantId
(
Long
.
parseLong
(
String
.
valueOf
(
request
.
getTenantId
())));
simpleAddUser
.
setPassword
(
"ABC123"
);
simpleAddUser
.
setUserName
(
userName
);
simpleAddUser
.
setPhoneNum
(
"13500001001"
);
simpleAddUser
.
setRoleId
(
Long
.
parseLong
(
String
.
valueOf
(
request
.
getRoleId
())));
simpleAddUser
.
setDepartmentId
(
Long
.
parseLong
(
String
.
valueOf
(
departmentItem
.
getDepartmentId
())));
log
.
info
(
"create user account request:{}"
,
JSONObject
.
toJSONString
(
simpleAddUser
));
R
<
User
>
userR
=
apiUserService
.
addSimpleUser
(
simpleAddUser
);
log
.
info
(
"craete user account result:{}"
,
JSONObject
.
toJSONString
(
userR
));
if
(
userR
.
isSuccess
())
{
User
user
=
userR
.
getData
(
User
.
class
);
zhongliDepartmentMapper
.
updateAccountInfoByOrg
(
zhongliDepartment
,
user
);
log
.
info
(
"zhongli department account info update{}"
,
userName
);
}
}
// unlock
boolean
unLockResutl
=
unLock
(
lockKey
);
log
.
info
(
"createNewAccountByOrgRelation_unlock result:{}"
,
unLockResutl
);
}
private
Map
<
String
,
DepartmentItem
>
getDepartmentMapper
(
Integer
tenantId
)
{
Map
<
String
,
DepartmentItem
>
resultMapper
=
new
HashMap
<>();
List
<
DepartmentItem
>
departmentItemList
=
zhongliDepartmentMapper
.
getDepartmentListByTenant
(
tenantId
);
if
(
CollectionUtil
.
isEmpty
(
departmentItemList
))
{
return
resultMapper
;
}
resultMapper
=
departmentItemList
.
stream
().
collect
(
Collectors
.
toMap
(
DepartmentItem:
:
getDepartmentName
,
Function
.
identity
(),
(
v1
,
v2
)->
v1
));
return
resultMapper
;
}
private
boolean
getNxLock
(
String
lockKey
)
{
return
redisService
.
getSimpleNxLock
(
lockKey
);
}
private
boolean
unLock
(
String
lockKey
)
{
return
redisService
.
unSimpleNxLock
(
lockKey
);
}
}
src/main/java/cn/com/glsx/stdinterface/modules/entity/ZhongliDepartment.java
0 → 100644
View file @
fd5d663
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
entity
;
import
com.glsx.plat.mybatis.base.BaseEntity
;
import
lombok.Data
;
import
javax.persistence.Column
;
import
javax.persistence.Table
;
@Data
@Table
(
name
=
"t_zhongli_department"
)
public
class
ZhongliDepartment
extends
BaseEntity
{
/**
* 分组id
*/
@Column
(
name
=
"group_id"
)
private
String
groupId
;
/**
* 分组
*/
@Column
(
name
=
"class_id"
)
private
String
classId
;
/**
* 用户名称
*/
@Column
(
name
=
"class_name"
)
private
String
className
;
/**
* 1级
*/
@Column
(
name
=
"one_level"
)
private
String
oneLevel
;
/**
* 2级
*/
@Column
(
name
=
"two_level"
)
private
String
twoLevel
;
/**
* 3级
*/
@Column
(
name
=
"three_level"
)
private
String
threeLevel
;
/**
* 4级
*/
@Column
(
name
=
"four_level"
)
private
String
fourLevel
;
/**
* 类型
*/
@Column
(
name
=
"type"
)
private
Integer
type
;
/**
* 用户名
*/
@Column
(
name
=
"user_account"
)
private
String
userAccount
;
/**
* 用户ID
*/
@Column
(
name
=
"user_id"
)
private
String
userId
;
/**
* 组织ID
*/
@Column
(
name
=
"department_id"
)
private
String
departmentId
;
}
\ No newline at end of file
src/main/java/cn/com/glsx/stdinterface/modules/entity/sync/DepartmentItem.java
0 → 100644
View file @
fd5d663
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
entity
.
sync
;
import
lombok.Data
;
@Data
public
class
DepartmentItem
{
private
String
departmentName
;
private
Integer
departmentId
;
}
src/main/java/cn/com/glsx/stdinterface/modules/mapper/VehicleMapper.java
View file @
fd5d663
...
...
@@ -25,4 +25,6 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
int
updateCreateByByRefVehicleIds
(
@Param
(
"userId"
)
Long
userId
,
@Param
(
"refVehicleIds"
)
Collection
<
Long
>
refVehicleIds
);
Vehicle
getVehicleBySn
(
@Param
(
"sn"
)
String
sn
);
Vehicle
selectByWorkOrderIdAndVin
(
@Param
(
"workOrderId"
)
Long
workOrderId
,
@Param
(
"vin"
)
String
vin
);
}
\ No newline at end of file
src/main/java/cn/com/glsx/stdinterface/modules/mapper/ZhongliDepartmentMapper.java
0 → 100644
View file @
fd5d663
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
mapper
;
import
cn.com.glsx.stdinterface.modules.entity.ZhongliAccount
;
import
cn.com.glsx.stdinterface.modules.entity.ZhongliDepartment
;
import
cn.com.glsx.stdinterface.modules.entity.sync.DepartmentItem
;
import
cn.com.glsx.stdinterface.modules.model.ZhongliAccountModel
;
import
cn.com.glsx.usercenter.api.dto.response.User
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
@Mapper
public
interface
ZhongliDepartmentMapper
extends
CommonBaseMapper
<
ZhongliDepartment
>
{
List
<
ZhongliDepartment
>
selectBaseAccount
();
String
getTenantName
(
@Param
(
"tenantId"
)
Integer
tenantId
);
List
<
DepartmentItem
>
getDepartmentListByTenant
(
@Param
(
"tenantId"
)
Integer
tenantId
);
int
updateAccountInfoByOrg
(
@Param
(
"zhliDepart"
)
ZhongliDepartment
zhongliDepartment
,
@Param
(
"user"
)
User
user
);
}
\ No newline at end of file
src/main/java/cn/com/glsx/stdinterface/modules/model/CommonSyncApiRequest.java
0 → 100644
View file @
fd5d663
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
model
;
import
lombok.Data
;
@Data
public
class
CommonSyncApiRequest
{
/**
* 租户ID
*/
private
Integer
tenantId
;
/**
* 请求发起时间戳,毫秒级别
*/
private
Long
timestamp
;
/**
* 接口调用方的组织识别码
*/
private
String
organization
;
/**
* 经加密处理的Json数据体
*/
private
String
data
;
/**
* 角色ID
*/
private
Integer
roleId
;
}
src/main/java/cn/com/glsx/stdinterface/modules/service/RedisService.java
View file @
fd5d663
...
...
@@ -72,4 +72,14 @@ public class RedisService {
return
Long
.
valueOf
(
orderId
);
}
public
boolean
getSimpleNxLock
(
String
lockKey
)
{
int
defaultValue
=
1
;
int
defaultTimeout
=
86400
;
return
redisUtils
.
setnx
(
lockKey
,
defaultValue
,
defaultTimeout
);
}
public
boolean
unSimpleNxLock
(
String
lockKey
)
{
int
defaultValue
=
1
;
return
redisUtils
.
unlock
(
lockKey
,
defaultValue
);
}
}
\ No newline at end of file
src/main/java/cn/com/glsx/stdinterface/modules/service/VehicleService.java
View file @
fd5d663
...
...
@@ -4,6 +4,7 @@ import cn.com.glsx.stdinterface.modules.entity.Vehicle;
import
cn.com.glsx.stdinterface.modules.entity.WorkOrder
;
import
cn.com.glsx.stdinterface.modules.mapper.VehicleMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -23,4 +24,11 @@ public class VehicleService {
Vehicle
vehicle
=
vehicleMapper
.
getVehicleBySn
(
sn
);
return
vehicle
;
}
public
Vehicle
getVehicleInfoByWorkOrderIdAndVin
(
Long
workOrderId
,
String
vin
)
{
if
(
workOrderId
==
null
||
StringUtils
.
isBlank
(
vin
))
{
return
null
;
}
return
vehicleMapper
.
selectByWorkOrderIdAndVin
(
workOrderId
,
vin
);
}
}
src/main/java/cn/com/glsx/stdinterface/modules/service/WorkOrderService.java
View file @
fd5d663
...
...
@@ -117,6 +117,9 @@ public class WorkOrderService {
@Autowired
private
WorkOrderDocsService
workOrderDocsService
;
@Resource
private
VehicleService
vehicleService
;
/**
* 新增工单
*
...
...
@@ -1027,6 +1030,9 @@ public class WorkOrderService {
workOrder
=
workOrderMapper
.
selectById
(
orderReq
.
getWorkOrderId
());
}
// 修改工单的车架号和车牌号
updateWorkOrderVin
(
workOrder
,
orderReq
);
//设备类型补全、转换,包活干过来的设备类型要校验
transBhgWireType
(
isApiCall
,
orderReq
.
getDevices
());
...
...
@@ -1076,6 +1082,50 @@ public class WorkOrderService {
}
/**
* 激活和审核工单时 更新车架号和工单号
* @param workOrder
* @param orderReq
* @return
*/
public
Boolean
updateWorkOrderVin
(
WorkOrder
workOrder
,
WorkOrderActivateBO
orderReq
)
{
boolean
updateFlag
=
false
;
WorkOrderVehicle
workOrderVehicle
=
workOrderVehicleMapper
.
selectOneByOrderId
(
workOrder
.
getId
());
if
(
workOrderVehicle
==
null
)
{
return
updateFlag
;
}
WorkOrderVehicle
updateCondition
=
new
WorkOrderVehicle
();
updateCondition
.
setId
(
workOrderVehicle
.
getId
());
if
(
StringUtils
.
isNotBlank
(
orderReq
.
getVin
()))
{
// 不存在车辆档案才可以更新
Boolean
updateVehicle
=
validUpdateVehicle
(
workOrder
.
getId
(),
orderReq
.
getVin
());
if
(
updateVehicle
)
{
updateCondition
.
setVin
(
orderReq
.
getVin
());
updateFlag
=
true
;
}
}
if
(
StringUtils
.
isNotBlank
(
orderReq
.
getPlateNo
()))
{
updateCondition
.
setPlateNo
(
orderReq
.
getPlateNo
());
updateFlag
=
true
;
}
if
(
updateFlag
)
{
workOrderVehicleMapper
.
updateByPrimaryKeySelective
(
updateCondition
);
}
return
updateFlag
;
}
private
Boolean
validUpdateVehicle
(
Long
id
,
String
vin
)
{
Boolean
updateRes
=
false
;
if
(
id
==
null
||
StringUtils
.
isBlank
(
vin
))
{
return
updateRes
;
}
Vehicle
vehicle
=
vehicleService
.
getVehicleInfoByWorkOrderIdAndVin
(
id
,
vin
);
updateRes
=
(
vehicle
==
null
)?
true
:
false
;
return
updateRes
;
}
/**
* 审核工单
*
* @param auditBO
...
...
src/main/java/cn/com/glsx/stdinterface/modules/util/Pinyin.java
0 → 100644
View file @
fd5d663
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
util
;
import
net.sourceforge.pinyin4j.PinyinHelper
;
import
net.sourceforge.pinyin4j.format.HanyuPinyinCaseType
;
import
net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat
;
import
net.sourceforge.pinyin4j.format.HanyuPinyinToneType
;
import
net.sourceforge.pinyin4j.format.HanyuPinyinVCharType
;
import
net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination
;
public
class
Pinyin
{
/**
* 得到 全拼
*
* @param src
* @return
*/
public
static
String
getPingYin
(
String
src
)
{
char
[]
t1
=
null
;
t1
=
src
.
toCharArray
();
String
[]
t2
=
new
String
[
t1
.
length
];
HanyuPinyinOutputFormat
t3
=
new
HanyuPinyinOutputFormat
();
t3
.
setCaseType
(
HanyuPinyinCaseType
.
LOWERCASE
);
t3
.
setToneType
(
HanyuPinyinToneType
.
WITHOUT_TONE
);
t3
.
setVCharType
(
HanyuPinyinVCharType
.
WITH_V
);
String
t4
=
""
;
int
t0
=
t1
.
length
;
try
{
for
(
int
i
=
0
;
i
<
t0
;
i
++)
{
// 判断是否为汉字字符
if
(
java
.
lang
.
Character
.
toString
(
t1
[
i
]).
matches
(
"[\\u4E00-\\u9FA5]+"
))
{
t2
=
PinyinHelper
.
toHanyuPinyinStringArray
(
t1
[
i
],
t3
);
t4
+=
t2
[
0
];
}
else
{
t4
+=
java
.
lang
.
Character
.
toString
(
t1
[
i
]);
}
}
return
t4
;
}
catch
(
BadHanyuPinyinOutputFormatCombination
e1
)
{
e1
.
printStackTrace
();
}
return
t4
;
}
/**
* 得到中文首字母
*
* @param str
* @return
*/
public
static
String
getPinYinHeadChar
(
String
str
)
{
String
convert
=
""
;
for
(
int
j
=
0
;
j
<
str
.
length
();
j
++)
{
char
word
=
str
.
charAt
(
j
);
String
[]
pinyinArray
=
PinyinHelper
.
toHanyuPinyinStringArray
(
word
);
if
(
pinyinArray
!=
null
)
{
convert
+=
pinyinArray
[
0
].
charAt
(
0
);
}
else
{
convert
+=
word
;
}
}
return
convert
;
}
/**
* 将字符串转移为ASCII码
*
* @param cnStr
* @return
*/
public
static
String
getCnASCII
(
String
cnStr
)
{
StringBuffer
strBuf
=
new
StringBuffer
();
byte
[]
bGBK
=
cnStr
.
getBytes
();
for
(
int
i
=
0
;
i
<
bGBK
.
length
;
i
++)
{
// System.out.println(Integer.toHexString(bGBK[i]&0xff));
strBuf
.
append
(
Integer
.
toHexString
(
bGBK
[
i
]
&
0xff
));
}
return
strBuf
.
toString
();
}
public
static
void
main
(
String
[]
args
)
{
String
cnStr
=
"深圳营建广东"
;
System
.
out
.
println
(
Pinyin
.
getPingYin
(
cnStr
));
System
.
out
.
println
(
Pinyin
.
getPinYinHeadChar
(
cnStr
));
}
}
\ No newline at end of file
src/main/java/cn/com/glsx/stdinterface/modules/util/PinyinUtil.java
0 → 100644
View file @
fd5d663
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
util
;
import
java.io.UnsupportedEncodingException
;
public
class
PinyinUtil
{
private
final
static
int
[]
li_SecPosValue
=
{
1601
,
1637
,
1833
,
2078
,
2274
,
2302
,
2433
,
2594
,
2787
,
3106
,
3212
,
3472
,
3635
,
3722
,
3730
,
3858
,
4027
,
4086
,
4390
,
4558
,
4684
,
4925
,
5249
,
5590
};
private
final
static
String
[]
lc_FirstLetter
=
{
"a"
,
"b"
,
"c"
,
"d"
,
"e"
,
"f"
,
"g"
,
"h"
,
"j"
,
"k"
,
"l"
,
"m"
,
"n"
,
"o"
,
"p"
,
"q"
,
"r"
,
"s"
,
"t"
,
"w"
,
"x"
,
"y"
,
"z"
};
/**
* 取得给定汉字串的首字母串,即声母串
*
* @param str
* 给定汉字串
* @return 声母串
*/
public
static
String
getAllFirstLetter
(
String
str
,
boolean
isUpper
)
{
if
(
str
==
null
||
str
.
trim
().
length
()
==
0
)
{
return
""
;
}
String
_str
=
""
;
for
(
int
i
=
0
;
i
<
str
.
length
();
i
++)
{
_str
=
_str
+
getFirstLetter
(
str
.
substring
(
i
,
i
+
1
),
isUpper
);
}
return
_str
;
}
/**
* 取得给定汉字的首字母,即声母
*
* @param chinese
* 给定的汉字
* @return 给定汉字的声母
*/
private
static
String
getFirstLetter
(
String
chinese
,
boolean
isUpper
)
{
if
(
chinese
==
null
||
chinese
.
trim
().
length
()
==
0
)
{
return
""
;
}
chinese
=
conversionStr
(
chinese
,
"GB2312"
,
"ISO8859-1"
);
if
(
chinese
.
length
()
>
1
)
// 判断是不是汉字
{
int
li_SectorCode
=
(
int
)
chinese
.
charAt
(
0
);
// 汉字区码
int
li_PositionCode
=
(
int
)
chinese
.
charAt
(
1
);
// 汉字位码
li_SectorCode
=
li_SectorCode
-
160
;
li_PositionCode
=
li_PositionCode
-
160
;
int
li_SecPosCode
=
li_SectorCode
*
100
+
li_PositionCode
;
// 汉字区位码
if
(
li_SecPosCode
>
1600
&&
li_SecPosCode
<
5590
)
{
for
(
int
i
=
0
;
i
<
23
;
i
++)
{
if
(
li_SecPosCode
>=
li_SecPosValue
[
i
]
&&
li_SecPosCode
<
li_SecPosValue
[
i
+
1
])
{
chinese
=
isUpper
?
lc_FirstLetter
[
i
].
toUpperCase
():
lc_FirstLetter
[
i
];
break
;
}
}
}
else
// 非汉字字符,如图形符号或ASCII码
{
chinese
=
conversionStr
(
chinese
,
"ISO8859-1"
,
"GB2312"
);
chinese
=
chinese
.
substring
(
0
,
1
);
}
}
return
chinese
;
}
/**
* 字符串编码转换
*
* @param str
* 要转换编码的字符串
* @param charsetName
* 原来的编码
* @param toCharsetName
* 转换后的编码
* @return 经过编码转换后的字符串
*/
private
static
String
conversionStr
(
String
str
,
String
charsetName
,
String
toCharsetName
)
{
try
{
str
=
new
String
(
str
.
getBytes
(
charsetName
),
toCharsetName
);
}
catch
(
UnsupportedEncodingException
ex
)
{
System
.
out
.
println
(
ex
.
getMessage
());
}
return
str
;
}
public
static
void
main
(
String
[]
args
)
{
String
aa
=
PinyinUtil
.
getAllFirstLetter
(
"深圳营建广东"
,
false
);
System
.
out
.
println
(
aa
);
}
}
src/main/resources/mapper/VehicleMapper.xml
View file @
fd5d663
...
...
@@ -130,4 +130,14 @@
and tvd.del_flag = 0 and tv.del_flag = 0
and tvd.bind_status = 1;
</select>
<select
id=
"selectByWorkOrderIdAndVin"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_vehicle
where del_flag = 0
and workorder_id = #{workOrderId}
and vin=#{vin}
</select>
</mapper>
\ No newline at end of file
src/main/resources/mapper/ZhongliDepartmentMapper.xml
0 → 100644
View file @
fd5d663
<?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=
"cn.com.glsx.stdinterface.modules.mapper.ZhongliDepartmentMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.stdinterface.modules.entity.ZhongliDepartment"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"group_id"
jdbcType=
"VARCHAR"
property=
"groupId"
/>
<result
column=
"group_name"
jdbcType=
"VARCHAR"
property=
"groupName"
/>
<result
column=
"class_id"
jdbcType=
"VARCHAR"
property=
"classId"
/>
<result
column=
"class_name"
jdbcType=
"VARCHAR"
property=
"className"
/>
<result
column=
"one_level"
jdbcType=
"VARCHAR"
property=
"oneLevel"
/>
<result
column=
"two_level"
jdbcType=
"VARCHAR"
property=
"twoLevel"
/>
<result
column=
"three_level"
jdbcType=
"VARCHAR"
property=
"threeLevel"
/>
<result
column=
"four_level"
jdbcType=
"VARCHAR"
property=
"fourLevel"
/>
<result
column=
"type"
jdbcType=
"TINYINT"
property=
"type"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"created_date"
jdbcType=
"TIMESTAMP"
property=
"createdDate"
/>
<result
column=
"created_by"
jdbcType=
"INTEGER"
property=
"createdBy"
/>
<result
column=
"updated_date"
jdbcType=
"TIMESTAMP"
property=
"updatedDate"
/>
<result
column=
"updated_by"
jdbcType=
"INTEGER"
property=
"updatedBy"
/>
<result
column=
"user_account"
jdbcType=
"INTEGER"
property=
"userAccount"
/>
<result
column=
"user_id"
jdbcType=
"TIMESTAMP"
property=
"userId"
/>
<result
column=
"department_id"
jdbcType=
"INTEGER"
property=
"departmentId"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--
WARNING - @mbg.generated
-->
id, group_id, group_name, class_id, class_name, one_level, two_level, three_level, four_level,
`type`, del_flag, created_date, created_by, updated_date, updated_by, user_account, user_id, department_id
</sql>
<select
id=
"selectBaseAccount"
resultMap=
"BaseResultMap"
>
SELECT `one_level`,`two_level`,`three_level`,`four_level` FROM `t_zhongli_department`
GROUP BY `one_level`,`two_level`,`three_level`,`four_level`
</select>
<select
id=
"getTenantName"
resultType=
"java.lang.String"
>
SELECT tenant_name FROM `t_tenant` WHERE id=#{tenantId}
</select>
<select
id=
"getDepartmentListByTenant"
resultType=
"cn.com.glsx.stdinterface.modules.entity.sync.DepartmentItem"
>
SELECT CONCAT(b.`department_name`,c.`department_name`) AS departmentName,c.`id` AS departmentId
FROM `t_organization` a
LEFT JOIN `t_department` b ON b.`id`=a.`superior_id`
LEFT JOIN `t_department` c ON c.`id`=a.`sub_id`
WHERE a.`depth`=1 AND a.`tenant_id`=#{tenantId}
</select>
<update
id=
"updateAccountInfoByOrg"
>
UPDATE `t_zhongli_department`
SET `user_account`=#{user.account},`user_id`=#{user.id},`department_id`=#{user.orgId}
WHERE `three_level`=#{zhliDepart.threeLevel} AND `four_level`=#{zhliDepart.fourLevel}
</update>
</mapper>
\ No newline at end of file
src/test/java/cn/com/glsx/stdinterface/modules/component/ZhongliAccountComponentTest.java
0 → 100644
View file @
fd5d663
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
component
;
import
cn.com.glsx.Application
;
import
cn.com.glsx.stdinterface.dto.VehicleDto
;
import
cn.com.glsx.stdinterface.modules.entity.Vehicle
;
import
cn.com.glsx.stdinterface.modules.model.CommonApiRequest
;
import
cn.com.glsx.stdinterface.modules.model.CommonSyncApiRequest
;
import
cn.com.glsx.stdinterface.modules.service.VehicleService
;
import
cn.hutool.core.date.DateUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
@Slf4j
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
Application
.
class
,
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
public
class
ZhongliAccountComponentTest
{
@Autowired
private
CreateNewAccountComponent
createNewAccountComponent
;
@Test
public
void
testddd
()
{
CommonSyncApiRequest
request
=
new
CommonSyncApiRequest
();
request
.
setOrganization
(
"仲利国际"
);
request
.
setTenantId
(
86
);
request
.
setRoleId
(
81
);
createNewAccountComponent
.
createNewAccountByOrgRelation
(
request
);
}
}
src/test/java/cn/com/glsx/stdinterface/modules/service/WorkOrderServiceTest.java
View file @
fd5d663
...
...
@@ -2,11 +2,13 @@ package cn.com.glsx.stdinterface.modules.service;
import
cn.com.glsx.Application
;
import
cn.com.glsx.notify.dto.MailTemplateMessageDTO
;
import
cn.com.glsx.stdinterface.dto.WorkOrderActivateBO
;
import
cn.com.glsx.stdinterface.dto.WorkOrderAddrVerifyBO
;
import
cn.com.glsx.stdinterface.dto.WorkOrderAddrVerifyDTO
;
import
cn.com.glsx.stdinterface.modules.entity.Vehicle
;
import
cn.com.glsx.stdinterface.modules.entity.WorkOrder
;
import
cn.com.glsx.stdinterface.modules.entity.WorkOrderDocs
;
import
cn.com.glsx.stdinterface.modules.entity.WorkOrderVehicle
;
import
cn.com.glsx.stdinterface.modules.mapper.WorkOrderDocsMapper
;
import
cn.com.glsx.stdinterface.modules.model.CommonApiRequest
;
import
cn.com.glsx.stdinterface.modules.model.WorkOrderInfoBO
;
...
...
@@ -153,4 +155,14 @@ public class WorkOrderServiceTest {
System
.
out
.
println
(
"collect = "
+
collect
);
}
@Test
public
void
updateVehicleVin
()
{
WorkOrder
workOrderVehicle
=
new
WorkOrder
();
workOrderVehicle
.
setId
(
9281L
);
WorkOrderActivateBO
orderReq
=
new
WorkOrderActivateBO
();
orderReq
.
setVin
(
"G3GF2F224F2222L12"
);
orderReq
.
setPlateNo
(
"粤CF32223"
);
workOrderService
.
updateWorkOrderVin
(
workOrderVehicle
,
orderReq
);
}
}
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