Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ajb-backend-car
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AutogeneralShanghai
ajb-backend-car
Commits
744bf4ee
Commit
744bf4ee
authored
Aug 08, 2018
by
Simon Cheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构芝麻访问连接,统一记录访问调用msg
parent
d35e0281
Show whitespace changes
Inline
Side-by-side
Showing
58 changed files
with
2899 additions
and
388 deletions
+2899
-388
ajb-car-api/pom.xml
+3
-15
ajb-car-api/src/main/java/com/ajb/car/DataController.java
+0
-23
ajb-car-api/src/main/java/com/ajb/car/apimessage/originmessage.java
+0
-5
ajb-car-api/src/main/java/com/ajb/car/quotation/QuotationController.java
+0
-30
ajb-car-api/src/main/java/com/ajb/car/schedule/ScheduledTaskService.java
+0
-286
ajb-car-api/src/main/java/com/ajb/global/authorize/AuthorizeController.java
+39
-0
ajb-car-api/src/main/java/com/ajb/global/authorize/service/AuthorizeService.java
+11
-0
ajb-car-api/src/main/java/com/ajb/global/authorize/service/impl/AuthorizeServiceImpl.java
+79
-0
ajb-car-api/src/main/java/com/ajb/global/authorize/util/AudienceSetting.java
+25
-0
ajb-car-api/src/main/java/com/ajb/global/authorize/util/JwtTokenUtil.java
+255
-0
ajb-car-api/src/main/java/com/ajb/global/authorize/vo/CheckTokenRequestVO.java
+22
-0
ajb-car-api/src/main/java/com/ajb/global/authorize/vo/CheckTokenResponseVO.java
+15
-0
ajb-car-api/src/main/java/com/ajb/global/authorize/vo/ObtainTokenRequestVO.java
+26
-0
ajb-car-api/src/main/java/com/ajb/global/authorize/vo/ObtainTokenResponseVO.java
+24
-0
ajb-car-api/src/main/java/com/ajb/global/config/DruidConfiguration.java
+34
-0
ajb-car-api/src/main/java/com/ajb/global/config/HttpZuihuibiAuthorizeConfig.java
+19
-0
ajb-car-api/src/main/java/com/ajb/global/config/ServletInitializer.java
+13
-0
ajb-car-api/src/main/java/com/ajb/global/config/SpringContextUtil.java
+36
-0
ajb-car-api/src/main/java/com/ajb/global/config/SpringMvcConfig.java
+35
-0
ajb-car-api/src/main/java/com/ajb/global/config/ZhimaConnection.java
+145
-0
ajb-car-api/src/main/java/com/ajb/global/enums/ParamVerifyEnum.java
+70
-0
ajb-car-api/src/main/java/com/ajb/global/enums/ResultEnum.java
+41
-0
ajb-car-api/src/main/java/com/ajb/global/exception/GlobalExceptionHandler.java
+41
-0
ajb-car-api/src/main/java/com/ajb/global/filter/HttpZuihuibiAuthorizeFilter.java
+126
-0
ajb-car-api/src/main/java/com/ajb/web/DataController.java
+28
-7
ajb-car-api/src/main/java/com/ajb/web/MetaDataController.java
+63
-0
ajb-car-api/src/main/java/com/ajb/web/OrderController.java
+69
-0
ajb-car-api/src/main/java/com/ajb/web/QuotationController.java
+145
-0
ajb-car-api/src/main/java/com/ajb/web/UserDataController.java
+3
-4
ajb-car-api/src/main/java/com/ajb/web/metadata/MetaDataService.java
+11
-0
ajb-car-api/src/main/java/com/ajb/web/metadata/impl/UserdataWebServiceImpl.java
+2
-4
ajb-car-api/src/main/java/com/ajb/web/quotation/AgPoQuotationWebService.java
+1
-1
ajb-car-api/src/main/java/com/ajb/web/quotation/impl/AgPoQuotationConverter.java
+1
-1
ajb-car-api/src/main/java/com/ajb/web/quotation/impl/AgPoQuotationWebServiceImpl.java
+4
-9
ajb-car-api/src/main/java/com/ajb/web/user/UserdataWebService.java
+1
-1
ajb-car-api/src/main/java/com/ajb/web/zhima/ZhimaDataSyncService.java
+9
-0
ajb-car-api/src/main/java/com/ajb/web/zhima/impl/ZhimaDataSyncServiceImpl.java
+201
-0
ajb-car-api/src/main/resources/application-local.properties
+1
-1
ajb-car-utils/src/main/java/com/ajb/common/utils/cache/SystemCacheManager.java
+0
-0
ajb-car-utils/src/main/java/com/ajb/common/utils/encryption/DESUtils.java
+0
-0
ajb-car-utils/src/main/java/com/ajb/common/utils/encryption/EncryptUtil.java
+0
-0
ajb-car-utils/src/main/java/com/ajb/common/utils/encryption/JPACryptoConverter.java
+0
-0
ajb-car-utils/src/main/java/com/ajb/common/utils/encryption/JPASensitiveSetting.java
+0
-0
ajb-car-utils/src/main/java/com/ajb/common/utils/encryption/MD5Util.java
+0
-0
ajb-car-utils/src/main/java/com/ajb/common/utils/encryption/MaskUtils.java
+0
-0
ajb-car-utils/src/main/java/com/ajb/common/utils/http/HttpHelpZhiMa.java
+1
-1
ajb-car-utils/src/main/java/com/ajb/common/utils/http/HttpUtil.java
+0
-0
ajb-car-utils/src/main/java/com/ajb/common/utils/office/ExcelUtils.java
+0
-0
ajb-car-utils/src/main/java/com/ajb/common/utils/string/CommonUtil.java
+978
-0
ajb-car-utils/src/main/java/com/ajb/common/utils/string/Data.java
+111
-0
ajb-car-utils/src/main/java/com/ajb/common/utils/string/IDcardValidator.java
+0
-0
ajb-car-utils/src/main/java/com/ajb/common/utils/string/IpToAddress.java
+20
-0
ajb-car-utils/src/main/java/com/ajb/common/utils/string/JsonUtil.java
+0
-0
ajb-car-utils/src/main/java/com/ajb/common/utils/string/StringUtil.java
+0
-0
ajb-car-utils/src/main/java/com/ajb/common/utils/string/XmlUtil.java
+0
-0
ajb-car-vo/src/main/java/com/ajb/car/vo/quotation/QuotationRequestVO.java
+80
-0
ajb-car-vo/src/main/java/com/ajb/car/vo/zhima/meta/VehicleModels.java
+92
-0
ajb-car-vo/src/main/java/com/ajb/car/vo/zhima/quotation/QuotationResponse.java
+19
-0
No files found.
ajb-car-api/pom.xml
View file @
744bf4ee
...
...
@@ -113,23 +113,11 @@
<groupId>
org.springframework.mobile
</groupId>
<artifactId>
spring-mobile-device
</artifactId>
</dependency>
<!--
<dependency>
<groupId>org.jeecg</groupId>
<artifactId>easypoi-base</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.jeecg</groupId>
<artifactId>easypoi-web</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>
org.jeecg</groupId>
<artifactId>
easypoi-annotation</artifactId>
<version>
2.3.1</version>
<groupId>
io.jsonwebtoken
</groupId>
<artifactId>
jjwt
</artifactId>
<version>
0.6.0
</version>
</dependency>
-->
</dependencies>
<!-- 打包spring boot应用 -->
<build>
...
...
ajb-car-api/src/main/java/com/ajb/car/DataController.java
deleted
100644 → 0
View file @
d35e0281
package
com
.
ajb
.
car
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ajb.car.vo.zhima.user.UserdataRequestVO
;
@RestController
public
class
DataController
{
/**
* 批处理表中的一列,多列
* @param userdataRequestVO
* @return
* @throws Exception
*/
@RequestMapping
(
"/batch"
)
public
Object
query
(
@RequestBody
UserdataRequestVO
userdataRequestVO
)
throws
Exception
{
return
null
;
}
}
ajb-car-api/src/main/java/com/ajb/car/apimessage/originmessage.java
deleted
100644 → 0
View file @
d35e0281
package
com
.
ajb
.
car
.
apimessage
;
public
class
originmessage
{
}
ajb-car-api/src/main/java/com/ajb/car/quotation/QuotationController.java
deleted
100644 → 0
View file @
d35e0281
package
com
.
ajb
.
car
.
quotation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ajb.car.vo.quotation.AgPoQuotationRequestVO
;
import
com.ajb.common.utils.encryption.MaskUtils
;
@RestController
public
class
QuotationController
{
@Autowired
private
AgPoQuotationWebService
agPoQuotationWebService
;
@RequestMapping
(
value
=
"/quotations/{quotationId}"
,
method
=
RequestMethod
.
GET
)
public
AgPoQuotationRequestVO
queryAgPoQuotation
(
@PathVariable
String
quotationId
,
Model
model
)
throws
Exception
{
AgPoQuotationRequestVO
quotationResponse
=
agPoQuotationWebService
.
queryAgPoQuotation
(
Long
.
valueOf
(
quotationId
));
quotationResponse
.
setCustomerMobileMask
(
MaskUtils
.
maskCellphone
(
quotationResponse
.
getCustomerMobile
()));
model
.
addAttribute
(
"quotation"
,
quotationResponse
);
return
quotationResponse
;
}
}
\ No newline at end of file
ajb-car-api/src/main/java/com/ajb/car/schedule/ScheduledTaskService.java
deleted
100644 → 0
View file @
d35e0281
package
com
.
ajb
.
car
.
schedule
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ajb.car.entity.apimessage.AgTransVehicleMsgOrigin
;
import
com.ajb.car.entity.quotation.AgPoQuotation
;
import
com.ajb.car.metadata.service.SystemConfigService
;
import
com.ajb.car.quotation.AgPoQuotationWebService
;
import
com.ajb.car.quotation.service.AgPoQuotationService
;
import
com.ajb.car.quotation.service.AgTransVehicleMsgOriginService
;
import
com.ajb.car.vo.zhima.TokenZhiMa
;
import
com.ajb.car.vo.zhima.policy.PolicyInfo
;
import
com.ajb.car.vo.zhima.policy.PolicyResponse
;
import
com.ajb.car.vo.zhima.quotation.QuotationDetail
;
import
com.ajb.car.vo.zhima.quotation.QuotationResponse
;
import
com.ajb.common.utils.http.HttpHelpZhiMa
;
import
com.alibaba.fastjson.JSON
;
/**
* 定时任务
* @service和@Component有一个即可,否则自动任务不会被启动
* @EnableScheduling 是必须
*/
@Service
(
"ScheduledTaskService"
)
//@EnableScheduling
public
class
ScheduledTaskService
{
@Autowired
private
SystemConfigService
systemConfigService
;
@Autowired
AgPoQuotationWebService
agPoQuotationWebService
;
@Autowired
AgPoQuotationService
agPoQuotationService
;
//Map<String , String> map = new HashMap<String , String>();
private
static
String
hostURL
=
""
;
// "https://baoxian.linkersoft.com/tbjap/";
//获取token
//private static String auth2ParamTest = "{\r\n\t\"unitid\": \"LKTEST\",\r\n\t\"pwd\": \"password\",\r\n\t\"secretid\": \"1aaca8b5fb364267a9d3b56474157cf6\"\r\n}\r\n";
private
static
String
auth2ParamProduction1
=
""
;
// "{\r\n\t\"unitid\": \"SHYD\",\r\n\t\"pwd\": \"shyd1234\",\r\n\t\"secretid\": \"ad9a64fb913f4affa8064f2ae51e3b91\"\r\n}\r\n";
private
static
String
tokenMethod
=
""
;
//"api/login";
//private static String tokenXPath = "$.datas.session.token";
//按品牌查型号
//private static String queryUrlModelParam = "{\"keyword\":\"%s\"}";
//private static String queryUrlModelMethod = "api/searchmodel1";
//private static String queryUrlModelXPath = "$.datas.modelNumbers";
//按型号查详细信息
//private static String queryUrlModel2Param = "{\"modelNumber\":\"%s\"}";
//private static String queryUrlModel2Method = "api/searchmodel2";
//private static String queryUrlModel2XPath = "$.datas.vehiclemodels[*]";
//报价查询
//private static String queryUrlCarPriceParam = "{\"carNumber\": \"%s\", \"carOwner\": \"%s\", \"plateType\": \"02\",\"bizAttribute\": \"101\"}";
//private static String queryUrlCarPriceMethod = "api/carpricebynumber";
//private static String queryUrlCarPriceXPath = "$.datas.priceinfo";
//private static String queryUrlGiftParam = "{\"policycode\":\"%s\"}";
//private static String queryURLGift = "api/loadgift";
//报价单加载
//private static String queryUrlConfirmInfoParam = "{\"policycode\":\"%s\"}";
//private static String queryUrlConfirmInfoMethod = "api/loadconfirminfo";
//private static String queryUrlConfirmInfoXPath = "$.datas.confirminfo";
//报价确认
//private static String queryUrlConfirmInfoPostMethod = "api/confirmprice";
//报价列表查询
//private static String queryQuotationURLParam = "{\"status\":\"%s\"}";
private
static
String
queryQuotationURLScopeParam
=
""
;
//"{\"begindate\":\"%s\",\"enddate\":\"%s\"}";
private
static
String
queryQuotationMethod
=
""
;
// "api/policylist?start=%s&count=%s";
//private static String queryQuotationXPath = "$.datas.pages.rows[*]";
//获取报价单详情
private
static
String
queryQuotationDetailMethod
=
""
;
//"api/getconfirmpolicydetail?policycode=%s";
@Autowired
private
AgTransVehicleMsgOriginService
carZhiMaService
;
//@Scheduled(cron = "0/2 * * * * *")
public
QuotationResponse
synchQuotaion
(
Date
begin
,
Date
end
)
throws
InterruptedException
{
auth2ParamProduction1
=
systemConfigService
.
getSingleConfigValue
(
"LinkerSoftAPITokenAuth2Param"
);
hostURL
=
systemConfigService
.
getSingleConfigValue
(
"LinkerSoftAPIHostURL"
);
tokenMethod
=
systemConfigService
.
getSingleConfigValue
(
"LinkerSoftAPITokenMethod"
);
queryQuotationMethod
=
systemConfigService
.
getSingleConfigValue
(
"LinkerSoftAPIQueryQuotationMethod"
);
queryQuotationURLScopeParam
=
systemConfigService
.
getSingleConfigValue
(
"LinkerSoftAPIQueryQuotationURLScopeParam"
);
queryQuotationDetailMethod
=
systemConfigService
.
getSingleConfigValue
(
"LinkerSoftAPIQueryQuotationDetailMethod"
);
TokenZhiMa
tokenEntity
=
getToken
(
hostURL
+
tokenMethod
,
auth2ParamProduction1
);
//写原始消息入表
AgTransVehicleMsgOrigin
agtransvehiclemsgorigin
=
new
AgTransVehicleMsgOrigin
();
agtransvehiclemsgorigin
=
initOriginMessage
(
hostURL
,
tokenMethod
,
auth2ParamProduction1
,
"Post"
,
JSON
.
toJSONString
(
tokenEntity
));
carZhiMaService
.
save
(
agtransvehiclemsgorigin
);
String
token
=
tokenEntity
.
getDatas
().
getTokenInfo
().
getToken
();
System
.
out
.
println
(
"token:"
+
token
);
String
startTime
=
dateToString
(
begin
);
String
endTime
=
dateToString
(
end
);
return
testPolicyList
(
startTime
,
endTime
,
token
);
}
public
static
String
dateToString
(
Date
time
){
SimpleDateFormat
formatter
;
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
ctime
=
formatter
.
format
(
time
);
return
ctime
;
}
private
QuotationResponse
testPolicyList
(
String
startTime
,
String
endTime
,
String
token
)
{
QuotationResponse
quotationResponse
;
quotationResponse
=
new
QuotationResponse
();
QuotationResponse
quotationResponsePage
=
new
QuotationResponse
();
Integer
start
=
0
;
Integer
total
=
0
;
Integer
size
=
15
;
//询价单列表,按状态,1,2,3
PolicyResponse
policyList
=
null
;
policyList
=
queryList
(
startTime
,
endTime
,
start
,
token
);
total
=
Integer
.
parseInt
(
policyList
.
getDatas
().
getPolicyPage
().
getTotal
());
System
.
out
.
println
(
"Total:"
+
total
);
quotationResponse
.
setTotal
(
total
);
while
(
start
<
total
)
{
quotationResponsePage
=
new
QuotationResponse
();
//分页,开始行,页行数queryQuotationURLParam
System
.
out
.
println
(
"start:"
+
start
);
policyList
=
queryList
(
startTime
,
endTime
,
start
,
token
);
quotationResponsePage
=
displayList
(
policyList
.
getDatas
().
getPolicyPage
().
getRows
(),
token
);
quotationResponse
.
setTotalPremium
(
quotationResponse
.
getTotalPremium
().
add
(
quotationResponsePage
.
getTotalPremium
()));
quotationResponse
.
setBzPremium
(
quotationResponse
.
getBzPremium
().
add
(
quotationResponsePage
.
getBzPremium
()));
quotationResponse
.
setTcPremium
(
quotationResponse
.
getTcPremium
().
add
(
quotationResponsePage
.
getTcPremium
()));
quotationResponse
.
setTsltax
(
quotationResponse
.
getTsltax
().
add
(
quotationResponsePage
.
getTsltax
()));
quotationResponse
.
setAllCharge
(
quotationResponse
.
getAllCharge
().
add
(
quotationResponsePage
.
getAllCharge
()));
if
(
start
>
0
&&
(
start
+
size
>
total
))
{
break
;
}
else
{
start
=
start
+
size
;
}
}
return
quotationResponse
;
}
private
PolicyResponse
queryList
(
String
startTime
,
String
endTime
,
Integer
start
,
String
token
)
{
String
queryQuotationMethodStep
=
String
.
format
(
queryQuotationMethod
,
start
.
toString
(),
"15"
);
queryQuotationURLScopeParam
=
String
.
format
(
queryQuotationURLScopeParam
,
startTime
,
endTime
);
PolicyResponse
policyList
=
postQuotationList
(
hostURL
+
queryQuotationMethodStep
,
queryQuotationURLScopeParam
,
token
);
//写原始消息入表
AgTransVehicleMsgOrigin
agtransvehiclemsgorigin
=
new
AgTransVehicleMsgOrigin
();
agtransvehiclemsgorigin
=
initOriginMessage
(
hostURL
,
queryQuotationMethodStep
,
queryQuotationURLScopeParam
,
"Post"
,
JSON
.
toJSONString
(
policyList
));
carZhiMaService
.
save
(
agtransvehiclemsgorigin
);
return
policyList
;
}
private
QuotationResponse
displayList
(
List
<
PolicyInfo
>
list
,
String
token
)
{
QuotationResponse
quotationResponse
=
new
QuotationResponse
();
String
policyCode
=
null
;
Date
quotationDate
=
null
;
BigDecimal
totalPremium
=
new
BigDecimal
(
0
);
BigDecimal
bzPremium
=
new
BigDecimal
(
0
);
BigDecimal
tcPremium
=
new
BigDecimal
(
0
);
BigDecimal
vsltax
=
new
BigDecimal
(
0
);
BigDecimal
allCharge
=
new
BigDecimal
(
0
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
policyCode
=
list
.
get
(
i
).
getPolicycode
();
quotationDate
=
list
.
get
(
i
).
getCreateDate
();
System
.
out
.
print
(
""
+
list
.
get
(
i
).
getCarNumber
());
totalPremium
=
totalPremium
.
add
(
BigDecimal
.
valueOf
(
list
.
get
(
i
).
getTotalPremium
()));
bzPremium
=
bzPremium
.
add
(
BigDecimal
.
valueOf
(
list
.
get
(
i
).
getBzPremium
()));
tcPremium
=
tcPremium
.
add
(
BigDecimal
.
valueOf
(
list
.
get
(
i
).
getTcPremium
()));
vsltax
=
vsltax
.
add
(
BigDecimal
.
valueOf
(
list
.
get
(
i
).
getVsltax
()));
allCharge
=
allCharge
.
add
(
BigDecimal
.
valueOf
(
list
.
get
(
i
).
getAllCharge
()));
System
.
out
.
print
(
"getTotalPremium,"
+
list
.
get
(
i
).
getTotalPremium
());
System
.
out
.
print
(
"getBzPremium,"
+
list
.
get
(
i
).
getBzPremium
());
System
.
out
.
print
(
"getTcPremium,"
+
list
.
get
(
i
).
getTcPremium
());
System
.
out
.
print
(
"getVsltax,"
+
list
.
get
(
i
).
getVsltax
());
System
.
out
.
println
(
"getAllCharge,"
+
list
.
get
(
i
).
getAllCharge
());
//检查是否已经存在
AgPoQuotation
one
=
agPoQuotationService
.
findByQuoteNo
(
policyCode
);
if
(
one
==
null
)
{
String
queryQuotationDetailMethodNew
=
String
.
format
(
queryQuotationDetailMethod
,
policyCode
);
QuotationDetail
postConfirm
=
getComfirmationDetail
(
hostURL
+
queryQuotationDetailMethodNew
,
null
,
token
);
//写车辆信息,报价信息,coverages入表
//agPoQuotationWebService.saveAgPoQuotation(postConfirm.getDatas().getPriceinfo());
agPoQuotationWebService
.
saveAgPoQuotationAndConfirm
(
quotationDate
,
postConfirm
.
getDatas
().
getPriceinfo
(),
postConfirm
.
getDatas
().
getConfirmInfo
());
//写确认信息入表confirmInfo
//agPoQuotationWebService.saveAgPoQuotationConfirm(postConfirm.getDatas().getConfirmInfo());
//写原始消息入表
AgTransVehicleMsgOrigin
agtransvehiclemsgorigin
=
new
AgTransVehicleMsgOrigin
();
agtransvehiclemsgorigin
=
initOriginMessage
(
hostURL
,
queryQuotationDetailMethodNew
,
""
,
"Post"
,
JSON
.
toJSONString
(
postConfirm
));
carZhiMaService
.
save
(
agtransvehiclemsgorigin
);
/*System.out.print("" + postConfirm.getDatas().getPriceinfo().getVehInfo().getRegistrationNumber());
System.out.print("getTotalPremium," + postConfirm.getDatas().getPriceinfo().getTotalPremium());
System.out.print("getBzPremium," + postConfirm.getDatas().getPriceinfo().getBzPremium());
System.out.print("getTcPremium," + postConfirm.getDatas().getPriceinfo().getTcPremium());
System.out.print("getAllCharge," + postConfirm.getDatas().getPriceinfo().getAllCharge());
System.out.println("getVsltax," + postConfirm.getDatas().getPriceinfo().getVsltax());
System.out.print("getAllCharge," + postConfirm.getDatas().getPriceinfo().getAllCharge());
System.out.print("," + dateToString(list.get(i).getCreateDate()));
System.out.println("");*/
}
}
quotationResponse
.
setTotalPremium
(
totalPremium
);
quotationResponse
.
setBzPremium
(
bzPremium
);
quotationResponse
.
setTcPremium
(
tcPremium
);
quotationResponse
.
setTsltax
(
vsltax
);
quotationResponse
.
setAllCharge
(
allCharge
);
return
quotationResponse
;
}
public
PolicyResponse
postQuotationList
(
String
urlQuery
,
String
queryURLParams
,
String
token
)
{
PolicyResponse
list
=
null
;
list
=
HttpHelpZhiMa
.
postUrlMap2JavaBean
(
urlQuery
,
queryURLParams
,
token
,
PolicyResponse
.
class
);
return
list
;
}
public
static
QuotationDetail
getComfirmationDetail
(
String
urlQuery
,
String
queryParams
,
String
token
)
{
QuotationDetail
confirm
=
null
;
confirm
=
HttpHelpZhiMa
.
getUrlMap2JavaBean
(
urlQuery
,
token
,
QuotationDetail
.
class
);
return
confirm
;
}
private
static
AgTransVehicleMsgOrigin
initOriginMessage
(
final
String
requestHost
,
final
String
requestMethod
,
final
String
requestParams
,
final
String
requestType
,
final
String
responseMessage
)
{
AgTransVehicleMsgOrigin
agtransvehiclemsgorigin
=
new
AgTransVehicleMsgOrigin
();
agtransvehiclemsgorigin
.
setQuoteProviderId
(
2L
);
agtransvehiclemsgorigin
.
setQuoteProviderType
(
"V"
);
agtransvehiclemsgorigin
.
setQuoteProvider
(
"芝麻"
);
agtransvehiclemsgorigin
.
setRequestHost
(
requestHost
);
agtransvehiclemsgorigin
.
setRequestParams
(
requestParams
);
agtransvehiclemsgorigin
.
setRequestMethod
(
requestMethod
);
agtransvehiclemsgorigin
.
setRequestType
(
requestType
);
agtransvehiclemsgorigin
.
setRequestDate
(
new
Date
());
agtransvehiclemsgorigin
.
setUserId
(
36
);
agtransvehiclemsgorigin
.
setUserName
(
"simon"
);
agtransvehiclemsgorigin
.
setResponseMessage
(
responseMessage
);
return
agtransvehiclemsgorigin
;
}
public
static
TokenZhiMa
getToken
(
String
urlQuery
,
String
queryParams
)
{
TokenZhiMa
returnToken
=
(
TokenZhiMa
)
HttpHelpZhiMa
.
getToken
(
urlQuery
,
queryParams
);
return
returnToken
;
}
}
\ No newline at end of file
ajb-car-api/src/main/java/com/ajb/global/authorize/AuthorizeController.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
authorize
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ajb.global.authorize.service.AuthorizeService
;
import
com.ajb.global.authorize.vo.CheckTokenRequestVO
;
import
com.ajb.car.vo.common.JsonResult
;
import
com.ajb.global.authorize.vo.CheckTokenResponseVO
;
import
com.ajb.global.authorize.vo.ObtainTokenRequestVO
;
import
com.ajb.global.authorize.vo.ObtainTokenResponseVO
;
@RestController
@RequestMapping
(
"/authorize"
)
public
class
AuthorizeController
{
@Autowired
private
AuthorizeService
authorizeService
;
@RequestMapping
(
"/obtainToken"
)
public
Object
obtainToken
(
@RequestBody
ObtainTokenRequestVO
requestVO
){
JsonResult
result
=
new
JsonResult
();
ObtainTokenResponseVO
responseVO
=
authorizeService
.
obtainToken
(
requestVO
);
result
.
setData
(
responseVO
);
return
result
;
}
@RequestMapping
(
"/checkToken"
)
public
Object
checkToken
(
@RequestBody
CheckTokenRequestVO
requestVO
){
JsonResult
result
=
new
JsonResult
();
CheckTokenResponseVO
responseVO
=
authorizeService
.
checkToken
(
requestVO
);
result
.
setData
(
responseVO
);
return
result
;
}
}
ajb-car-api/src/main/java/com/ajb/global/authorize/service/AuthorizeService.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
authorize
.
service
;
import
com.ajb.global.authorize.vo.CheckTokenRequestVO
;
import
com.ajb.global.authorize.vo.CheckTokenResponseVO
;
import
com.ajb.global.authorize.vo.ObtainTokenRequestVO
;
import
com.ajb.global.authorize.vo.ObtainTokenResponseVO
;
public
interface
AuthorizeService
{
public
ObtainTokenResponseVO
obtainToken
(
ObtainTokenRequestVO
requestVO
);
public
CheckTokenResponseVO
checkToken
(
CheckTokenRequestVO
requestVO
);
}
ajb-car-api/src/main/java/com/ajb/global/authorize/service/impl/AuthorizeServiceImpl.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
authorize
.
service
.
impl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ajb.global.authorize.service.AuthorizeService
;
import
com.ajb.global.authorize.util.AudienceSetting
;
import
com.ajb.global.authorize.util.JwtTokenUtil
;
import
com.ajb.global.authorize.vo.CheckTokenRequestVO
;
import
com.ajb.car.vo.common.CommonResult
;
import
com.ajb.common.utils.string.CommonUtil
;
import
com.ajb.global.enums.ParamVerifyEnum
;
import
com.ajb.global.enums.ResultEnum
;
import
com.ajb.global.authorize.vo.CheckTokenResponseVO
;
import
com.ajb.global.authorize.vo.ObtainTokenRequestVO
;
import
com.ajb.global.authorize.vo.ObtainTokenResponseVO
;
@Service
(
"authorizeService"
)
public
class
AuthorizeServiceImpl
implements
AuthorizeService
{
@Autowired
private
JwtTokenUtil
jwtTokenUtil
;
@Autowired
private
AudienceSetting
audienceSetting
;
@Override
public
ObtainTokenResponseVO
obtainToken
(
ObtainTokenRequestVO
requestVO
)
{
boolean
success
=
true
;
String
message
=
ResultEnum
.
QUERY_SUCCESS
.
getMessage
();
ObtainTokenResponseVO
responseVO
=
new
ObtainTokenResponseVO
();
if
(
requestVO
==
null
||
CommonUtil
.
isNullOrBlank
(
requestVO
.
getTicket
())){
responseVO
.
setCommonResult
(
new
CommonResult
(
false
,
ParamVerifyEnum
.
PARAM_NOT_NULL
.
getMessage
()));
return
responseVO
;
}
String
token
=
jwtTokenUtil
.
generateToken
(
requestVO
.
getTicket
());
responseVO
.
setToken
(
token
);
responseVO
.
setCommonResult
(
new
CommonResult
(
success
,
message
));
return
responseVO
;
}
@Override
public
CheckTokenResponseVO
checkToken
(
CheckTokenRequestVO
requestVO
)
{
boolean
success
=
true
;
String
message
=
"校验通过"
;
CheckTokenResponseVO
responseVO
=
new
CheckTokenResponseVO
();
if
(
requestVO
==
null
||
CommonUtil
.
isNullOrBlank
(
requestVO
.
getToken
())){
responseVO
.
setCommonResult
(
new
CommonResult
(
false
,
ParamVerifyEnum
.
PARAM_NOT_NULL
.
getMessage
()));
return
responseVO
;
}
String
token
=
requestVO
.
getToken
();
if
(
token
.
startsWith
(
audienceSetting
.
issuer
)){
token
=
token
.
substring
(
audienceSetting
.
issuer
.
length
()+
1
);
}
boolean
isTokenValid
=
jwtTokenUtil
.
validateToken
(
token
);
boolean
isTokenExpired
=
jwtTokenUtil
.
isTokenExpired
(
token
);
if
(
isTokenExpired
){
success
=
false
;
message
=
"token已失效!"
;
}
else
if
(
isTokenValid
){
String
ticket
=
requestVO
.
getTicket
();
if
(!
CommonUtil
.
isNullOrBlank
(
ticket
)){
boolean
valid
=
jwtTokenUtil
.
validateToken
(
token
,
ticket
);
if
(!
valid
){
success
=
false
;
message
=
"由token解析出的ticket和传入的ticket不一致!"
;
}
}
}
else
{
success
=
false
;
message
=
"token格式不合法!"
;
}
responseVO
.
setCommonResult
(
new
CommonResult
(
success
,
message
));
return
responseVO
;
}
}
ajb-car-api/src/main/java/com/ajb/global/authorize/util/AudienceSetting.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
authorize
.
util
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
/**
* jwt安全验证设置 head tag,seal封条,过期时间,发行,bypass
* @author Simon Cheng
*/
@Service
public
class
AudienceSetting
{
@Value
(
"${jwt.header}"
)
public
String
header
;
@Value
(
"${jwt.seal}"
)
public
String
seal
;
@Value
(
"${jwt.expiration}"
)
public
Long
expiration
;
@Value
(
"${jwt.issuer}"
)
public
String
issuer
;
@Value
(
"${jwt.bypass}"
)
public
String
bypass
;
}
ajb-car-api/src/main/java/com/ajb/global/authorize/util/JwtTokenUtil.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
authorize
.
util
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
io.jsonwebtoken.Claims
;
import
io.jsonwebtoken.ExpiredJwtException
;
import
io.jsonwebtoken.Jws
;
import
io.jsonwebtoken.JwtParser
;
import
io.jsonwebtoken.Jwts
;
import
io.jsonwebtoken.MalformedJwtException
;
import
io.jsonwebtoken.SignatureAlgorithm
;
import
io.jsonwebtoken.SignatureException
;
import
io.jsonwebtoken.UnsupportedJwtException
;
/**
* jwt 工具类
* @author
*/
@Service
public
class
JwtTokenUtil
{
private
static
final
String
CLAIM_KEY_SUBJECT
=
"sub"
;
// private static final String CLAIM_KEY_ISSURE = "iss";
// private static final String CLAIM_KEY_AUDIENCE = "aud";
private
static
final
String
CLAIM_KEY_CREATED
=
"created"
;
// private static final String CLAIM_KEY_BIRTHDAY = "birthDay";
// private static final String CLAIM_KEY_ADDRESS = "address";
@Autowired
private
AudienceSetting
audienceSetting
;
/**
* 从token中获取subject
* @param token
* @return
*/
public
String
getSubjectFromToken
(
String
token
)
{
String
subject
=
null
;
Map
<
String
,
Object
>
map
=
getClaimsFromToken
(
token
);
String
resultCode
=
(
String
)
map
.
get
(
"resultCode"
);
if
(
"SUCCESS"
.
equals
(
resultCode
)){
Object
obj
=
map
.
get
(
"claims"
);
if
(
obj
!=
null
){
Claims
claims
=
(
Claims
)
obj
;
subject
=
claims
.
getSubject
();
}
}
return
subject
;
}
/**
* 获取创建时间
* @param token
* @return
*/
public
Date
getCreatedDateFromToken
(
String
token
)
{
Date
created
=
null
;
Map
<
String
,
Object
>
map
=
getClaimsFromToken
(
token
);
String
resultCode
=
(
String
)
map
.
get
(
"resultCode"
);
if
(
"SUCCESS"
.
equals
(
resultCode
)){
Object
obj
=
map
.
get
(
"claims"
);
if
(
obj
!=
null
){
Claims
claims
=
(
Claims
)
obj
;
created
=
new
Date
((
Long
)
claims
.
get
(
CLAIM_KEY_CREATED
));
}
}
return
created
;
}
/**
* 获取过期时间
* @param token
* @return
*/
public
Date
getExpirationDateFromToken
(
String
token
){
Date
expiration
=
null
;
Map
<
String
,
Object
>
map
=
getClaimsFromToken
(
token
);
String
resultCode
=
(
String
)
map
.
get
(
"resultCode"
);
if
(
"SUCCESS"
.
equals
(
resultCode
)){
Object
obj
=
map
.
get
(
"claims"
);
if
(
obj
!=
null
){
Claims
claims
=
(
Claims
)
obj
;
expiration
=
claims
.
getExpiration
();
}
}
return
expiration
;
}
/**
* check token是否过期
* @param token
* @return
*/
public
Boolean
isTokenExpired
(
String
token
)
{
boolean
result
=
false
;
Map
<
String
,
Object
>
map
=
getClaimsFromToken
(
token
);
String
resultCode
=
(
String
)
map
.
get
(
"resultCode"
);
if
(
"EXPIRED"
.
equals
(
resultCode
)){
result
=
true
;
}
else
if
(
"SUCCESS"
.
equals
(
resultCode
)){
Date
expiration
=
getExpirationDateFromToken
(
token
);
if
(
expiration
!=
null
){
result
=
expiration
.
before
(
new
Date
());
}
}
return
result
;
}
/**
* 检查是否可以被刷新
* @param token
* @param lastPasswordReset
* @return
*/
public
Boolean
canTokenBeRefreshed
(
String
token
,
Date
lastPasswordReset
)
{
//如果过期则不可以刷新
if
(
isTokenExpired
(
token
)){
return
false
;
}
Date
created
=
getCreatedDateFromToken
(
token
);
if
(
created
==
null
){
return
false
;
}
//如果token是在上次密码重置前生成则不可以刷新
if
(
lastPasswordReset
!=
null
&&
created
.
before
(
lastPasswordReset
)){
return
false
;
}
return
true
;
}
/**
* 刷新token
* @param token
* @return
*/
public
String
refreshToken
(
String
token
)
{
String
refreshedToken
=
null
;
Map
<
String
,
Object
>
map
=
getClaimsFromToken
(
token
);
String
resultCode
=
(
String
)
map
.
get
(
"resultCode"
);
if
(
"SUCCESS"
.
equals
(
resultCode
)){
Object
obj
=
map
.
get
(
"claims"
);
if
(
obj
!=
null
){
Claims
claims
=
(
Claims
)
obj
;
claims
.
put
(
CLAIM_KEY_CREATED
,
new
Date
());
refreshedToken
=
generateToken
(
claims
);
}
}
return
refreshedToken
;
}
/**
* 根据ticket验证token有效
* @param ticket
* @param user
* @return
*/
public
Boolean
validateToken
(
String
token
,
String
ticket
)
{
boolean
result
=
false
;
final
String
subject
=
getSubjectFromToken
(
token
);
if
(
subject
==
null
){
return
false
;
}
if
(!
isTokenExpired
(
token
)){
if
(
ticket
!=
null
&&
subject
.
equals
(
ticket
)){
result
=
true
;
}
}
return
result
;
}
/**
* 判断token是否有效(主要是格式是否有效)
* @param token
* @return
*/
public
Boolean
validateToken
(
String
token
)
{
boolean
result
=
true
;
Map
<
String
,
Object
>
map
=
getClaimsFromToken
(
token
);
String
resultCode
=
(
String
)
map
.
get
(
"resultCode"
);
if
(
"INVALID"
.
equals
(
resultCode
)){
result
=
false
;
}
return
result
;
}
/**
* 生成过期时间
* @return
*/
private
Date
generateExpirationDate
()
{
Date
expirationDate
=
new
Date
(
System
.
currentTimeMillis
()
+
audienceSetting
.
expiration
*
1000
);
return
expirationDate
;
}
/**
* 根据ticket生成token
* @param ticket
* @return
*/
public
String
generateToken
(
String
ticket
){
String
token
=
null
;
Map
<
String
,
Object
>
claims
=
new
HashMap
<>();
claims
.
put
(
CLAIM_KEY_SUBJECT
,
ticket
);
claims
.
put
(
CLAIM_KEY_CREATED
,
new
Date
());
token
=
generateToken
(
claims
);
token
=
audienceSetting
.
issuer
+
" "
+
token
;
return
token
;
}
/**
* 根据Map 生成token串
* @param Map<String, Object>claims
* @return
*/
private
String
generateToken
(
Map
<
String
,
Object
>
claims
)
{
return
Jwts
.
builder
()
.
setClaims
(
claims
)
.
setExpiration
(
generateExpirationDate
())
.
signWith
(
SignatureAlgorithm
.
HS512
,
audienceSetting
.
seal
)
.
compact
();
}
/**
* 根据token获取Claims,申明内容
* @param token
* @return
*/
private
Map
<
String
,
Object
>
getClaimsFromToken
(
String
token
){
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
String
resultCode
=
"SUCCESS"
;
Claims
claims
=
null
;
try
{
JwtParser
jwtParser
=
Jwts
.
parser
().
setSigningKey
(
audienceSetting
.
seal
);
Jws
<
Claims
>
jwsClaims
=
jwtParser
.
parseClaimsJws
(
token
);
claims
=
jwsClaims
.
getBody
();
}
catch
(
ExpiredJwtException
e
){
resultCode
=
"EXPIRED"
;
}
catch
(
UnsupportedJwtException
|
MalformedJwtException
|
SignatureException
|
IllegalArgumentException
e
){
resultCode
=
"INVALID"
;
}
catch
(
Exception
e
){
resultCode
=
"INVALID"
;
}
map
.
put
(
"resultCode"
,
resultCode
);
map
.
put
(
"claims"
,
claims
);
return
map
;
}
}
ajb-car-api/src/main/java/com/ajb/global/authorize/vo/CheckTokenRequestVO.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
authorize
.
vo
;
public
class
CheckTokenRequestVO
{
private
String
token
;
private
String
ticket
;
public
String
getToken
()
{
return
token
;
}
public
void
setToken
(
String
token
)
{
this
.
token
=
token
;
}
public
String
getTicket
()
{
return
ticket
;
}
public
void
setTicket
(
String
ticket
)
{
this
.
ticket
=
ticket
;
}
}
ajb-car-api/src/main/java/com/ajb/global/authorize/vo/CheckTokenResponseVO.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
authorize
.
vo
;
import
com.ajb.car.vo.common.CommonResult
;
public
class
CheckTokenResponseVO
{
private
CommonResult
commonResult
;
public
CommonResult
getCommonResult
()
{
return
commonResult
;
}
public
void
setCommonResult
(
CommonResult
commonResult
)
{
this
.
commonResult
=
commonResult
;
}
}
ajb-car-api/src/main/java/com/ajb/global/authorize/vo/ObtainTokenRequestVO.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
authorize
.
vo
;
public
class
ObtainTokenRequestVO
{
private
String
ticket
;
private
String
ipAddress
;
private
String
loginId
;
public
String
getTicket
()
{
return
ticket
;
}
public
void
setTicket
(
String
ticket
)
{
this
.
ticket
=
ticket
;
}
public
String
getIpAddress
()
{
return
ipAddress
;
}
public
void
setIpAddress
(
String
ipAddress
)
{
this
.
ipAddress
=
ipAddress
;
}
public
String
getLoginId
()
{
return
loginId
;
}
public
void
setLoginId
(
String
loginId
)
{
this
.
loginId
=
loginId
;
}
}
ajb-car-api/src/main/java/com/ajb/global/authorize/vo/ObtainTokenResponseVO.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
authorize
.
vo
;
import
com.ajb.car.vo.common.CommonResult
;
public
class
ObtainTokenResponseVO
{
private
String
token
;
private
CommonResult
commonResult
;
public
String
getToken
()
{
return
token
;
}
public
void
setToken
(
String
token
)
{
this
.
token
=
token
;
}
public
CommonResult
getCommonResult
()
{
return
commonResult
;
}
public
void
setCommonResult
(
CommonResult
commonResult
)
{
this
.
commonResult
=
commonResult
;
}
}
ajb-car-api/src/main/java/com/ajb/global/config/DruidConfiguration.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
config
;
import
javax.sql.DataSource
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
com.alibaba.druid.pool.DruidDataSource
;
/***
* alibaba druid datasource configuration
*
* @author fan
*
*/
@Configuration
public
class
DruidConfiguration
{
/***
* ConditionalOnMissingBean 当不存在时 返回Bean的实例
* 通过ConfigurationProperties自动注入配置
* @return
*/
@Bean
@ConditionalOnMissingBean
@ConfigurationProperties
(
prefix
=
"spring.datasource"
)
public
DataSource
druidDataSource
(){
DruidDataSource
druidDataSource
=
new
DruidDataSource
();
return
druidDataSource
;
}
}
ajb-car-api/src/main/java/com/ajb/global/config/HttpZuihuibiAuthorizeConfig.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
config
;
/**
* Register security zuihuibi filter
*/
import
javax.servlet.Filter
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
com.ajb.global.filter.HttpZuihuibiAuthorizeFilter
;
@Configuration
public
class
HttpZuihuibiAuthorizeConfig
{
@Bean
public
Filter
AuthFilter
()
{
return
new
HttpZuihuibiAuthorizeFilter
();
}
}
ajb-car-api/src/main/java/com/ajb/global/config/ServletInitializer.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
config
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.boot.web.support.SpringBootServletInitializer
;
import
com.ajb.Application
;
public
class
ServletInitializer
extends
SpringBootServletInitializer
{
@Override
protected
SpringApplicationBuilder
configure
(
SpringApplicationBuilder
application
)
{
return
application
.
sources
(
Application
.
class
);
}
}
\ No newline at end of file
ajb-car-api/src/main/java/com/ajb/global/config/SpringContextUtil.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
config
;
import
org.springframework.beans.BeansException
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.context.annotation.Configuration
;
/**
* 通过上下文过去注入的bean instance
* @author Simon Cheng
*
*/
@Configuration
public
class
SpringContextUtil
implements
ApplicationContextAware
{
private
static
ApplicationContext
applicationContext
;
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
SpringContextUtil
.
applicationContext
=
applicationContext
;
}
public
static
ApplicationContext
getApplicationContext
()
{
return
SpringContextUtil
.
applicationContext
;
}
public
static
<
T
>
T
getBean
(
Class
<
T
>
t
)
{
return
SpringContextUtil
.
applicationContext
.
getBean
(
t
);
}
// 通过name获取Bean.
public
static
<
T
>
T
getBean
(
String
name
)
{
T
bean
=
(
T
)
SpringContextUtil
.
applicationContext
.
getBean
(
name
);
return
bean
;
}
}
ajb-car-api/src/main/java/com/ajb/global/config/SpringMvcConfig.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
config
;
import
javax.servlet.Filter
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.cors.CorsConfiguration
;
import
org.springframework.web.cors.UrlBasedCorsConfigurationSource
;
import
org.springframework.web.filter.CorsFilter
;
@Configuration
public
class
SpringMvcConfig
{
/**
* 解决同源策略问题的filter
* @return
*/
@Bean
public
Filter
corsFilter
(){
UrlBasedCorsConfigurationSource
source
=
new
UrlBasedCorsConfigurationSource
();
CorsConfiguration
config
=
new
CorsConfiguration
();
config
.
addAllowedOrigin
(
"*"
);
config
.
addAllowedHeader
(
"*"
);
config
.
addAllowedMethod
(
"OPTIONS"
);
config
.
addAllowedMethod
(
"HEAD"
);
config
.
addAllowedMethod
(
"GET"
);
config
.
addAllowedMethod
(
"PUT"
);
config
.
addAllowedMethod
(
"POST"
);
config
.
addAllowedMethod
(
"DELETE"
);
config
.
addAllowedMethod
(
"PATCH"
);
source
.
registerCorsConfiguration
(
"/**"
,
config
);
return
new
CorsFilter
(
source
);
}
}
ajb-car-api/src/main/java/com/ajb/global/config/ZhimaConnection.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
config
;
import
java.util.Date
;
import
com.ajb.car.entity.apimessage.AgTransVehicleMsgOrigin
;
import
com.ajb.car.metadata.service.SystemConfigService
;
import
com.ajb.car.quotation.service.AgTransVehicleMsgOriginService
;
import
com.ajb.car.vo.zhima.TokenZhiMa
;
import
com.ajb.common.utils.http.HttpHelpZhiMa
;
import
com.ajb.common.utils.string.CommonUtil
;
import
com.alibaba.fastjson.JSON
;
/**
* 获取芝麻车险访问连接
* @author Simon Cheng
*
*/
public
class
ZhimaConnection
{
private
static
String
auth2ParamProduction
=
""
;
private
static
String
hostURL
=
""
;
private
static
String
tokenMethod
=
""
;
private
static
String
token
=
""
;
private
static
ZhimaConnection
zhimaConnection
=
null
;
public
static
synchronized
ZhimaConnection
getInstance
(){
if
(
zhimaConnection
==
null
)
{
SystemConfigService
systemConfigService
=
(
SystemConfigService
)
SpringContextUtil
.
getBean
(
"systemConfigService"
);
zhimaConnection
=
new
ZhimaConnection
();
auth2ParamProduction
=
systemConfigService
.
getSingleConfigValue
(
"LinkerSoftAPITokenAuth2Param"
);
hostURL
=
systemConfigService
.
getSingleConfigValue
(
"LinkerSoftAPIHostURL"
);
tokenMethod
=
systemConfigService
.
getSingleConfigValue
(
"LinkerSoftAPITokenMethod"
);
}
return
zhimaConnection
;
}
public
static
String
getAuth2ParamProduction
()
{
getInstance
();
return
auth2ParamProduction
;
}
public
static
String
getHostURL
()
{
getInstance
();
return
hostURL
;
}
public
static
String
getTokenMethod
()
{
getInstance
();
return
tokenMethod
;
}
/**
* 获取芝麻API接口的token
* @param urlQuery
* @param queryParams
* @return
*/
private
static
TokenZhiMa
getToken
(
String
urlQuery
,
String
queryParams
)
{
TokenZhiMa
returnToken
=
(
TokenZhiMa
)
HttpHelpZhiMa
.
getToken
(
urlQuery
,
queryParams
);
return
returnToken
;
}
public
static
String
getToken
()
{
getInstance
();
if
(
CommonUtil
.
isNullOrBlank
(
token
))
{
TokenZhiMa
returnToken
=
(
TokenZhiMa
)
getToken
(
hostURL
+
tokenMethod
,
auth2ParamProduction
);
token
=
returnToken
.
getDatas
().
getTokenInfo
().
getToken
();
}
return
token
;
}
public
static
String
refreshToken
()
{
getInstance
();
TokenZhiMa
returnToken
=
(
TokenZhiMa
)
getToken
(
hostURL
+
tokenMethod
,
auth2ParamProduction
);
token
=
returnToken
.
getDatas
().
getTokenInfo
().
getToken
();
return
token
;
}
public
static
<
T
>
T
postUrlMap2JavaBean
(
String
urlQuery
,
String
queryParams
,
Class
<
T
>
beanClass
)
{
T
t
=
postUrlMap2JavaBean
(
urlQuery
,
queryParams
,
getToken
(),
beanClass
);
return
t
;
}
public
static
<
T
>
T
postUrlMap2JavaBean
(
String
urlQuery
,
String
queryParams
,
String
token
,
Class
<
T
>
beanClass
)
{
T
t
=
HttpHelpZhiMa
.
postUrlMap2JavaBean
(
urlQuery
,
queryParams
,
token
,
beanClass
);
//写原始消息入表
AgTransVehicleMsgOrigin
agtransvehiclemsgorigin
=
new
AgTransVehicleMsgOrigin
();
agtransvehiclemsgorigin
=
initOriginMessage
(
ZhimaConnection
.
getHostURL
(),
urlQuery
,
queryParams
,
"Post"
,
JSON
.
toJSONString
(
t
));
AgTransVehicleMsgOriginService
carZhiMaService
=
(
AgTransVehicleMsgOriginService
)
SpringContextUtil
.
getBean
(
"agTransVehicleMsgOriginService"
);
carZhiMaService
.
save
(
agtransvehiclemsgorigin
);
return
t
;
}
public
static
<
T
>
T
getUrlMap2JavaBean
(
String
urlQuery
,
Class
<
T
>
beanClass
)
{
T
t
=
getUrlMap2JavaBean
(
urlQuery
,
getToken
(),
beanClass
);
return
t
;
}
public
static
<
T
>
T
getUrlMap2JavaBean
(
String
urlQuery
,
String
token
,
Class
<
T
>
beanClass
)
{
T
t
=
HttpHelpZhiMa
.
getUrlMap2JavaBean
(
urlQuery
,
token
,
beanClass
);
//写原始消息入表
AgTransVehicleMsgOrigin
agtransvehiclemsgorigin
=
new
AgTransVehicleMsgOrigin
();
agtransvehiclemsgorigin
=
initOriginMessage
(
ZhimaConnection
.
getHostURL
(),
urlQuery
,
""
,
"Get"
,
JSON
.
toJSONString
(
t
));
AgTransVehicleMsgOriginService
carZhiMaService
=
(
AgTransVehicleMsgOriginService
)
SpringContextUtil
.
getBean
(
"agTransVehicleMsgOriginService"
);
carZhiMaService
.
save
(
agtransvehiclemsgorigin
);
return
t
;
}
/**
* 记录请求log,初始化日志项
* @param requestHost
* @param requestMethod
* @param requestParams
* @param requestType
* @param responseMessage
* @return
*/
private
static
AgTransVehicleMsgOrigin
initOriginMessage
(
final
String
requestHost
,
final
String
requestMethod
,
final
String
requestParams
,
final
String
requestType
,
final
String
responseMessage
)
{
AgTransVehicleMsgOrigin
agtransvehiclemsgorigin
=
new
AgTransVehicleMsgOrigin
();
agtransvehiclemsgorigin
.
setQuoteProviderId
(
2L
);
agtransvehiclemsgorigin
.
setQuoteProviderType
(
"V"
);
agtransvehiclemsgorigin
.
setQuoteProvider
(
"芝麻"
);
agtransvehiclemsgorigin
.
setRequestHost
(
requestHost
);
agtransvehiclemsgorigin
.
setRequestParams
(
requestParams
);
agtransvehiclemsgorigin
.
setRequestMethod
(
requestMethod
);
agtransvehiclemsgorigin
.
setRequestType
(
requestType
);
agtransvehiclemsgorigin
.
setRequestDate
(
new
Date
());
agtransvehiclemsgorigin
.
setUserId
(
36
);
agtransvehiclemsgorigin
.
setUserName
(
"simon"
);
agtransvehiclemsgorigin
.
setResponseMessage
(
responseMessage
);
return
agtransvehiclemsgorigin
;
}
}
ajb-car-api/src/main/java/com/ajb/global/enums/ParamVerifyEnum.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
enums
;
public
enum
ParamVerifyEnum
{
/**
* 参数不能为空
*/
PARAM_NOT_NULL
(
1
,
"参数不能为空!"
),
/**
* 参数不正确
*/
PARAM_ERROR
(
2
,
"参数不正确!"
),
/**
* 常用联系人类型不能为空
*/
CONTACTTYPE_NOT_NULL
(
11
,
"常用联系人类型不能为空!"
),
/**
* 常用联系人姓名不能为空
*/
CONTACTNAME_NOT_NULL
(
12
,
"常用联系人姓名不能为空!"
),
/**
* 与投保人关系不能为空
*/
RELATIONID_NOT_NULL
(
13
,
"与投保人关系不能为空!"
),
/**
* 身份证件类型不能为空
*/
IDTYPEID_NOT_NULL
(
14
,
"身份证件类型不能为空!"
),
/**
* 身份证件号码不能为空
*/
IDNO_NOT_NULL
(
15
,
"身份证件号码不能为空!"
),
/**
* 性别不能为空
*/
GENDER_NOT_NULL
(
16
,
"性别不能为空!"
),
/**
* 手机号码不能为空
*/
MOBILENO_NOT_NULL
(
17
,
"手机号码不能为空!"
),
/**
* 生日不能为空
*/
BIRTHDATE_NOT_NULL
(
18
,
"生日不能为空!"
),
/**
* 投保人ID不能为空
*/
CUSTOMERID_NOT_NULL
(
19
,
"投保人ID不能为空!"
)
;
private
int
code
;
private
String
message
;
public
int
getCode
()
{
return
code
;
}
public
String
getMessage
()
{
return
message
;
}
private
ParamVerifyEnum
(
int
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
}
ajb-car-api/src/main/java/com/ajb/global/enums/ResultEnum.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
enums
;
public
enum
ResultEnum
{
/**
* 查询成功
*/
QUERY_SUCCESS
(
1
,
"查询成功!"
),
/**
* 查询失败
*/
QUERY_FAIL
(
2
,
"查询失败!"
),
/**
* 保存成功
*/
SAVE_SUCCESS
(
3
,
"保存成功!"
),
/**
* 被保人信息已更新
*/
USER_IS_EXIST
(
4
,
"被保人信息已更新"
),
/**
* 删除成功
*/
DELETE_SUCCESS
(
5
,
"删除成功"
)
;
private
int
code
;
private
String
message
;
public
int
getCode
()
{
return
code
;
}
public
String
getMessage
()
{
return
message
;
}
private
ResultEnum
(
int
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
}
ajb-car-api/src/main/java/com/ajb/global/exception/GlobalExceptionHandler.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
exception
;
import
javax.servlet.http.HttpServletRequest
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.bind.annotation.ControllerAdvice
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.ajb.car.vo.common.JsonResult
;
import
com.ajb.common.utils.string.CommonUtil
;
/***
* 统一异常处理
* @author fan
*
*/
@ControllerAdvice
@ResponseBody
public
class
GlobalExceptionHandler
{
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
GlobalExceptionHandler
.
class
);
/**
*
* @param req
* @param ex
* @return
* @throws Exception
*/
@ExceptionHandler
(
value
=
Exception
.
class
)
public
JsonResult
handler
(
HttpServletRequest
req
,
Exception
ex
)
throws
Exception
{
logger
.
error
(
"request url is:"
+
req
.
getRequestURL
()+
" \n "
+
CommonUtil
.
parseExceptionStack
(
ex
));
//ex.getMessage()
JsonResult
result
=
new
JsonResult
();
result
.
setSuccess
(
false
);
result
.
setMessage
(
"system error"
+
ex
.
getMessage
());
//TODO log
return
result
;
}
}
ajb-car-api/src/main/java/com/ajb/global/filter/HttpZuihuibiAuthorizeFilter.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
global
.
filter
;
import
java.io.IOException
;
import
javax.servlet.Filter
;
import
javax.servlet.FilterChain
;
import
javax.servlet.FilterConfig
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.ServletResponse
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.httpclient.HttpStatus
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.ajb.global.authorize.util.AudienceSetting
;
import
com.ajb.global.authorize.util.JwtTokenUtil
;
import
com.ajb.common.utils.string.CommonUtil
;
/**
* jwt过滤器
* @author
* zuihuibi intercept all request from client, check whether token is there,verify the token is valid.
*/
public
class
HttpZuihuibiAuthorizeFilter
implements
Filter
{
@Autowired
private
JwtTokenUtil
jwtTokenUtil
;
@Autowired
private
AudienceSetting
audienceSetting
;
private
static
final
String
BY_PASS_ALL
=
"TEST"
;
@Override
public
void
destroy
()
{}
/**
* 过滤器,对客户请求过滤,验证
*/
@Override
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
HttpServletRequest
httpRequest
=
(
HttpServletRequest
)
request
;
HttpServletResponse
httpResponse
=
(
HttpServletResponse
)
response
;
httpResponse
.
setHeader
(
"Access-Control-Allow-Origin"
,
"*"
);
String
requestUri
=
httpRequest
.
getRequestURI
();
boolean
isDoFilter
=
false
;
//这里通过判断请求的方法,判断此次是否是预检请求,如果是,立即返回一个204状态吗,标示,允许跨域;预检后,正式请求,这个方法参数就是我们设置的post了
if
(
"OPTIONS"
.
equals
(
httpRequest
.
getMethod
())){
//HttpStatus.SC_NO_CONTENT = 204
httpResponse
.
setStatus
(
HttpStatus
.
SC_NO_CONTENT
);
httpResponse
.
setHeader
(
"Access-Control-Allow-Methods"
,
"POST, GET, DELETE, OPTIONS, DELETE"
);
//当判定为预检请求后,设定允许请求的方法
httpResponse
.
setHeader
(
"Access-Control-Allow-Headers"
,
"Content-Type, x-requested-with, Token, X-Authorization"
);
//当判定为预检请求后,设定允许请求的头部类型
httpResponse
.
addHeader
(
"Access-Control-Max-Age"
,
"1"
);
chain
.
doFilter
(
request
,
response
);
return
;
}
String
byPass
=
audienceSetting
.
bypass
;
if
(!
CommonUtil
.
isNullOrBlank
(
byPass
)){
if
(
byPass
.
contains
(
BY_PASS_ALL
)){
//bypass配置为TEST时所有方法都放过
isDoFilter
=
true
;
}
else
{
if
(
byPass
.
contains
(
requestUri
)){
//完整路径匹配
isDoFilter
=
true
;
}
else
{
//按照“,”拆分后逐个模糊匹配
String
[]
arr
=
byPass
.
split
(
","
);
for
(
String
item
:
arr
){
if
(
item
.
startsWith
(
"*"
)
&&
item
.
endsWith
(
"*"
)){
//以*开头且以*结尾
if
(
requestUri
.
contains
(
item
.
replace
(
"*"
,
""
))){
isDoFilter
=
true
;
break
;
}
}
else
if
(
item
.
startsWith
(
"*"
)){
//仅以*开头
if
(
requestUri
.
endsWith
(
item
.
replace
(
"*"
,
""
))){
isDoFilter
=
true
;
break
;
}
}
else
if
(
item
.
endsWith
(
"*"
)){
//仅以*结尾
if
(
requestUri
.
startsWith
(
item
.
replace
(
"*"
,
""
))){
isDoFilter
=
true
;
break
;
}
}
}
//for arr
}
//!byPass.contains(requestUri)
}
//not BY_PASS_ALL
}
//byPass != null
if
(
isDoFilter
){
chain
.
doFilter
(
request
,
response
);
return
;
}
//其他的URL请求,先获取head中的token,进行验证即可
int
issuerLength
=
audienceSetting
.
issuer
.
length
();
String
token
=
httpRequest
.
getHeader
(
audienceSetting
.
header
);
if
(!
CommonUtil
.
isNullOrBlank
(
token
)
&&
token
.
length
()
>
issuerLength
){
String
headStr
=
token
.
substring
(
0
,
issuerLength
).
toLowerCase
();
if
(
headStr
.
compareTo
(
audienceSetting
.
issuer
)
==
0
){
token
=
token
.
substring
(
issuerLength
,
token
.
length
());
//token格式合法并且没有失效
if
(
jwtTokenUtil
.
validateToken
(
token
)
&&
!
jwtTokenUtil
.
isTokenExpired
(
token
)){
chain
.
doFilter
(
request
,
response
);
return
;
}
}
}
//验证失败,返回错误提示
httpResponse
.
setCharacterEncoding
(
"UTF-8"
);
httpResponse
.
setContentType
(
"application/json; charset=utf-8"
);
httpResponse
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
String
responseJson
=
"{"
+
"\n \"success\": false,"
+
"\n \"errorCode\": \"T001\","
+
"\n \"message\": \"Invalid token!\""
+
"\n}"
;
httpResponse
.
getWriter
().
write
(
responseJson
);
return
;
}
@Override
public
void
init
(
FilterConfig
arg0
)
throws
ServletException
{}
}
ajb-car-api/src/main/java/com/ajb/
car/Car
Controller.java
→
ajb-car-api/src/main/java/com/ajb/
web/Data
Controller.java
View file @
744bf4ee
package
com
.
ajb
.
car
;
package
com
.
ajb
.
web
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
...
...
@@ -9,18 +9,26 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ajb.car.schedule.ScheduledTaskService
;
import
com.ajb.car.vo.common.CommonResult
;
import
com.ajb.car.vo.zhima.quotation.QuotationRequestVO
;
import
com.ajb.car.vo.zhima.quotation.QuotationResponse
;
import
com.ajb.car.vo.zhima.user.UserdataRequestVO
;
import
com.ajb.global.config.ZhimaConnection
;
import
com.ajb.web.zhima.ZhimaDataSyncService
;
@RestController
public
class
CarController
{
@Autowired
private
ScheduledTaskService
taskService
;
public
class
DataController
{
@RequestMapping
(
"/quotations"
)
@Autowired
private
ZhimaDataSyncService
taskService
;
/**
* 同步芝麻车险报价数据
* @param loginRequestVO
* @return
* @throws Exception
*/
@RequestMapping
(
"/syncquotations"
)
public
Object
synch
(
@RequestBody
QuotationRequestVO
loginRequestVO
)
throws
Exception
{
QuotationResponse
quotationResponse
=
new
QuotationResponse
();
...
...
@@ -34,9 +42,22 @@ public class CarController {
quotationResponse
=
taskService
.
synchQuotaion
(
begin
,
end
);
}
catch
(
Exception
ex
){
quotationResponse
.
setCommonResult
(
new
CommonResult
(
false
,
"Error! begindate and enddate format yyyy-MM-dd!ex:{\"begindate\":\"2018-06-10\",\"enddate\":\"2018-06-10\"}"
));
quotationResponse
.
setErrorCode
(
"S01"
);
quotationResponse
.
setErrorMessage
(
"系统出现问题,我们正在加紧解决!"
);
}
finally
{
}
quotationResponse
.
setCommonResult
(
new
CommonResult
(
true
,
"Success!"
));
return
quotationResponse
;
}
/**
* 批处理表中的一列,多列
* @param userdataRequestVO
* @return
* @throws Exception
*/
@RequestMapping
(
"/encryptbatch"
)
public
Object
query
(
@RequestBody
UserdataRequestVO
userdataRequestVO
)
throws
Exception
{
return
null
;
}
}
ajb-car-api/src/main/java/com/ajb/web/MetaDataController.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
web
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* 车险相关系统数据
* @author Simon Cheng
*
*/
@RestController
public
class
MetaDataController
{
/**
* 输出省份,省份简称列表
* @return
* @throws Exception
*/
@RequestMapping
(
value
=
"/listprovince"
,
method
=
RequestMethod
.
GET
)
public
Object
queryProvince
()
throws
Exception
{
//ProvinceResponse quotationResponse = new ProvinceResponse();
//TODO
return
null
;
}
/**
* 关键字查询品牌,大众,别克,宝马,奔驰
* @param keyword
* @return
* @throws Exception
*/
@RequestMapping
(
value
=
"/queryallbrand"
,
method
=
RequestMethod
.
GET
)
public
Object
queryAllBrand
()
throws
Exception
{
//ProvinceResponse quotationResponse = new ProvinceResponse();
//TODO
return
null
;
}
/**
* 关键字查询品牌,大众,别克,宝马,奔驰
* @param keyword
* @return
* @throws Exception
*/
@RequestMapping
(
value
=
"/querybrand/{keyword}"
,
method
=
RequestMethod
.
GET
)
public
Object
queryBrand
(
@PathVariable
String
keyword
)
throws
Exception
{
//ProvinceResponse quotationResponse = new ProvinceResponse();
//TODO
return
null
;
}
/**
* 查询型号详细信息,指导价格
* @param modelnumber
* @return
* @throws Exception
*/
@RequestMapping
(
value
=
"/querybrandmodel/{modelnumber}"
,
method
=
RequestMethod
.
GET
)
public
Object
queryBrandModel
(
@PathVariable
String
modelnumber
)
throws
Exception
{
//ProvinceResponse quotationResponse = new ProvinceResponse();
//TODO
return
null
;
}
}
\ No newline at end of file
ajb-car-api/src/main/java/com/ajb/web/OrderController.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
web
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ajb.car.vo.quotation.AgPoQuotationRequestVO
;
import
com.ajb.car.vo.quotation.QuotationRequestVO
;
import
com.ajb.common.utils.encryption.MaskUtils
;
import
com.ajb.web.quotation.AgPoQuotationWebService
;
/**
* 车险报价
* @author Simon Cheng
*
*/
@RestController
public
class
OrderController
{
@Autowired
private
AgPoQuotationWebService
agPoOrderWebService
;
/**
* 支付报价
* 参数:
* 返回:
* @param requestVO
* @return
* @throws Exception
*/
@RequestMapping
(
"/paymentorder"
)
public
Object
paymentOrder
(
@RequestBody
QuotationRequestVO
requestVO
)
throws
Exception
{
//ProvinceResponse quotationResponse = new ProvinceResponse();
return
null
;
}
/**
* 查询订单
* 参数:
* 返回:
* @param requestVO
* @return
* @throws Exception
*/
@RequestMapping
(
"/queryorder"
)
public
Object
queryOrder
(
@RequestBody
QuotationRequestVO
requestVO
)
throws
Exception
{
//ProvinceResponse quotationResponse = new ProvinceResponse();
return
null
;
}
/**
* 取消订单
* 参数:
* 返回:
* @param requestVO
* @return
* @throws Exception
*/
@RequestMapping
(
"/cancelorder"
)
public
Object
cancelOrder
(
@RequestBody
QuotationRequestVO
requestVO
)
throws
Exception
{
//ProvinceResponse quotationResponse = new ProvinceResponse();
return
null
;
}
}
\ No newline at end of file
ajb-car-api/src/main/java/com/ajb/web/QuotationController.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
web
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ajb.car.vo.quotation.AgPoQuotationRequestVO
;
import
com.ajb.car.vo.quotation.QuotationRequestVO
;
import
com.ajb.common.utils.encryption.MaskUtils
;
import
com.ajb.global.config.ZhimaConnection
;
import
com.ajb.web.quotation.AgPoQuotationWebService
;
/**
* 车险报价
* @author Simon Cheng
*
*/
@RestController
public
class
QuotationController
{
@Autowired
private
AgPoQuotationWebService
agPoQuotationWebService
;
/**
* 查询用户报价详细信息(某一个保险公司的)
* 保费,保障详情,服务和礼包,车辆信息
* @param quotationId
* @param model
* @return
* @throws Exception
*/
@RequestMapping
(
value
=
"/quotation/{quotationId}"
,
method
=
RequestMethod
.
GET
)
public
AgPoQuotationRequestVO
queryAgPoQuotation
(
@PathVariable
String
quotationId
,
Model
model
)
throws
Exception
{
AgPoQuotationRequestVO
quotationResponse
=
agPoQuotationWebService
.
queryAgPoQuotation
(
Long
.
valueOf
(
quotationId
));
quotationResponse
.
setCustomerMobileMask
(
MaskUtils
.
maskCellphone
(
quotationResponse
.
getCustomerMobile
()));
model
.
addAttribute
(
"quotation"
,
quotationResponse
);
return
quotationResponse
;
}
/**
* 车牌号,车架号,发动机号,车主,身份证号,
* 报价查询,能查到去年的历史,返回上年的投保范围方案
* 没有的话,就获取车险投保方案(见车险投保推荐方案)
* @param requestVO
* @return
* @throws Exception
*/
@RequestMapping
(
"/lastyearquotation"
)
public
Object
lastYearQuotation
(
@RequestBody
QuotationRequestVO
requestVO
)
throws
Exception
{
//ProvinceResponse quotationResponse = new ProvinceResponse();
return
null
;
}
/**
* 车险投保推荐方案,自选,推荐,基础型三种
* @param requestVO
* @return
* @throws Exception
*/
@RequestMapping
(
"/recommendcoverages"
)
public
Object
recommendCoverages
(
@RequestBody
QuotationRequestVO
requestVO
)
throws
Exception
{
//ProvinceResponse quotationResponse = new ProvinceResponse();
return
null
;
}
/**
* 提交用户报价信息
* 参数:用户在一种推荐方案的基础上修改
* 返回:根据用户选择的保障范围,查询各家保险公司的报价返回
* @param requestVO
* @return
* @throws Exception
*/
@RequestMapping
(
"/postquotation"
)
public
Object
postQuotation
(
@RequestBody
QuotationRequestVO
requestVO
)
throws
Exception
{
//ProvinceResponse quotationResponse = new ProvinceResponse();
return
null
;
}
/**
* 修改用户报价信息
* 参数:用户在一种推荐方案的基础上修改
* 返回:根据用户选择的保障范围,查询各家保险公司的报价返回
* @param requestVO
* @return
* @throws Exception
*/
@RequestMapping
(
"/modifyquotation"
)
public
Object
modifyQuotation
(
@RequestBody
QuotationRequestVO
requestVO
)
throws
Exception
{
//ProvinceResponse quotationResponse = new ProvinceResponse();
return
null
;
}
/**
* 确认用户报价信息,阅读保险条款并同意
* 参数:阅读保险条款并同意
* 返回:
* @param requestVO
* @return
* @throws Exception
*/
@RequestMapping
(
"/confirmquotation"
)
public
Object
confirmQuotation
(
@RequestBody
QuotationRequestVO
requestVO
)
throws
Exception
{
//ProvinceResponse quotationResponse = new ProvinceResponse();
return
null
;
}
/**
* 确认用户报价信息后,提交收件地址
* 参数:
* 返回:
* @param requestVO
* @return
* @throws Exception
*/
@RequestMapping
(
"/postrecieveaddress"
)
public
Object
postRecieveAddress
(
@RequestBody
QuotationRequestVO
requestVO
)
throws
Exception
{
//ProvinceResponse quotationResponse = new ProvinceResponse();
return
null
;
}
/**
* 确认用户报价信息后,提交发票信息
* 参数:阅读保险条款并同意
* 返回:
* @param requestVO
* @return
* @throws Exception
*/
@RequestMapping
(
"/postinvoiceinfo"
)
public
Object
postInvoiceInfo
(
@RequestBody
QuotationRequestVO
requestVO
)
throws
Exception
{
//ProvinceResponse quotationResponse = new ProvinceResponse();
return
null
;
}
}
\ No newline at end of file
ajb-car-api/src/main/java/com/ajb/
car/Userd
ataController.java
→
ajb-car-api/src/main/java/com/ajb/
web/UserD
ataController.java
View file @
744bf4ee
package
com
.
ajb
.
car
;
package
com
.
ajb
.
web
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -6,16 +6,15 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ajb.car.user.UserdataWebService
;
import
com.ajb.car.vo.common.DESCommon
;
import
com.ajb.car.vo.common.JsonResult
;
import
com.ajb.car.vo.zhima.user.UserdataRequestVO
;
import
com.ajb.car.vo.zhima.user.UserdataResponseVO
;
import
com.ajb.common.utils.encryption.DESUtils
;
import
com.ajb.web.user.UserdataWebService
;
@RestController
@RequestMapping
(
"/userdata"
)
public
class
UserdataController
{
public
class
UserDataController
{
@Autowired
private
UserdataWebService
userdataWebService
;
...
...
ajb-car-api/src/main/java/com/ajb/web/metadata/MetaDataService.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
web
.
metadata
;
import
java.util.List
;
import
com.ajb.car.vo.zhima.meta.VehicleModels
;
public
interface
MetaDataService
{
public
List
<
String
>
searchmodel1
(
String
keyword
);
public
List
<
VehicleModels
>
searchmodel2
(
String
modelNumber
);
}
ajb-car-api/src/main/java/com/ajb/
car/user
/impl/UserdataWebServiceImpl.java
→
ajb-car-api/src/main/java/com/ajb/
web/metadata
/impl/UserdataWebServiceImpl.java
View file @
744bf4ee
package
com
.
ajb
.
car
.
user
.
impl
;
package
com
.
ajb
.
web
.
metadata
.
impl
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -8,13 +7,12 @@ import org.springframework.transaction.annotation.Transactional;
import
com.ajb.car.entity.meta.Userdata
;
import
com.ajb.car.metadata.service.UserdataService
;
import
com.ajb.car.user.UserdataWebService
;
import
com.ajb.car.vo.common.CommonResult
;
import
com.ajb.car.vo.zhima.user.UserdataDeleteRequestVO
;
import
com.ajb.car.vo.zhima.user.UserdataRequestVO
;
import
com.ajb.car.vo.zhima.user.UserdataResponseVO
;
import
com.ajb.common.utils.encryption.MaskUtils
;
import
com.ajb.web.user.UserdataWebService
;
@Service
(
"userdataWebService"
)
public
class
UserdataWebServiceImpl
implements
UserdataWebService
{
...
...
ajb-car-api/src/main/java/com/ajb/
car
/quotation/AgPoQuotationWebService.java
→
ajb-car-api/src/main/java/com/ajb/
web
/quotation/AgPoQuotationWebService.java
View file @
744bf4ee
package
com
.
ajb
.
car
.
quotation
;
package
com
.
ajb
.
web
.
quotation
;
import
java.util.Date
;
...
...
ajb-car-api/src/main/java/com/ajb/
car
/quotation/impl/AgPoQuotationConverter.java
→
ajb-car-api/src/main/java/com/ajb/
web
/quotation/impl/AgPoQuotationConverter.java
View file @
744bf4ee
package
com
.
ajb
.
car
.
quotation
.
impl
;
package
com
.
ajb
.
web
.
quotation
.
impl
;
import
java.math.BigDecimal
;
import
java.util.Date
;
...
...
ajb-car-api/src/main/java/com/ajb/
car
/quotation/impl/AgPoQuotationWebServiceImpl.java
→
ajb-car-api/src/main/java/com/ajb/
web
/quotation/impl/AgPoQuotationWebServiceImpl.java
View file @
744bf4ee
package
com
.
ajb
.
car
.
quotation
.
impl
;
package
com
.
ajb
.
web
.
quotation
.
impl
;
import
java.math.BigDecimal
;
import
java.util.Date
;
...
...
@@ -14,7 +14,6 @@ import com.ajb.car.entity.quotation.AgPoQuotationCover;
import
com.ajb.car.entity.quotation.AgPoQuotationTax
;
import
com.ajb.car.entity.quotation.AgPoQuotationVehicle
;
import
com.ajb.car.entity.quotation.AgPoQuotationVehicleRelation
;
import
com.ajb.car.quotation.AgPoQuotationWebService
;
import
com.ajb.car.quotation.service.AgPoQuotationService
;
import
com.ajb.car.quotation.service.AgPoQuotationTaxService
;
import
com.ajb.car.quotation.service.AgPoQuotationConfirmService
;
...
...
@@ -23,19 +22,15 @@ import com.ajb.car.quotation.service.AgPoQuotationCoverService;
import
com.ajb.car.quotation.service.AgPoQuotationVehicleRelationService
;
import
com.ajb.car.vo.quotation.AgPoQuotationRequestVO
;
import
com.ajb.car.vo.zhima.quotation.Applicant
;
import
com.ajb.car.vo.zhima.quotation.BzCoverages
;
import
com.ajb.car.vo.zhima.quotation.CarBodyPaintCoverage
;
import
com.ajb.car.vo.zhima.quotation.CarBodyPaintExemptDeductibleSpecialClause
;
import
com.ajb.car.vo.zhima.quotation.Claimant
;
import
com.ajb.car.vo.zhima.quotation.ConfirmInfo
;
import
com.ajb.car.vo.zhima.quotation.DamageLossCoverage
;
import
com.ajb.car.vo.zhima.quotation.DamageLossExemptDeductibleSpecialClause
;
import
com.ajb.car.vo.zhima.quotation.Priceinfo
;
import
com.ajb.car.vo.zhima.quotation.TcCoverages
;
import
com.ajb.car.vo.zhima.quotation.ThirdPartyLiabilityCoverage
;
import
com.ajb.car.vo.zhima.quotation.ThirdPartyLiabilityExemptDeductibleSpecialClause
;
import
com.ajb.car.vo.zhima.quotation.VehInfo
;
import
com.ajb.car.vo.zhima.quotation.VsltaxInfo
;
import
com.ajb.web.quotation.AgPoQuotationWebService
;
@Service
(
"agPoQuotationWebService"
)
public
class
AgPoQuotationWebServiceImpl
implements
AgPoQuotationWebService
{
...
...
ajb-car-api/src/main/java/com/ajb/
car
/user/UserdataWebService.java
→
ajb-car-api/src/main/java/com/ajb/
web
/user/UserdataWebService.java
View file @
744bf4ee
package
com
.
ajb
.
car
.
user
;
package
com
.
ajb
.
web
.
user
;
import
com.ajb.car.vo.zhima.user.UserdataRequestVO
;
import
com.ajb.car.vo.zhima.user.UserdataResponseVO
;
...
...
ajb-car-api/src/main/java/com/ajb/web/zhima/ZhimaDataSyncService.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
web
.
zhima
;
import
java.util.Date
;
import
com.ajb.car.vo.zhima.quotation.QuotationResponse
;
public
interface
ZhimaDataSyncService
{
public
QuotationResponse
synchQuotaion
(
Date
begin
,
Date
end
)
throws
InterruptedException
;
}
ajb-car-api/src/main/java/com/ajb/web/zhima/impl/ZhimaDataSyncServiceImpl.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
web
.
zhima
.
impl
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ajb.car.entity.quotation.AgPoQuotation
;
import
com.ajb.car.metadata.service.SystemConfigService
;
import
com.ajb.car.quotation.service.AgPoQuotationService
;
import
com.ajb.car.vo.zhima.policy.PolicyInfo
;
import
com.ajb.car.vo.zhima.policy.PolicyResponse
;
import
com.ajb.car.vo.zhima.quotation.QuotationDetail
;
import
com.ajb.car.vo.zhima.quotation.QuotationResponse
;
import
com.ajb.common.utils.string.CommonUtil
;
import
com.ajb.global.config.ZhimaConnection
;
import
com.ajb.web.quotation.AgPoQuotationWebService
;
import
com.ajb.web.zhima.ZhimaDataSyncService
;
/**
* 同步芝麻车险报价数据
* @author Simon Cheng
*
*/
@Service
(
"zhimaDataSyncService"
)
public
class
ZhimaDataSyncServiceImpl
implements
ZhimaDataSyncService
{
@Autowired
private
SystemConfigService
systemConfigService
;
@Autowired
AgPoQuotationWebService
agPoQuotationWebService
;
@Autowired
AgPoQuotationService
agPoQuotationService
;
//报价列表查询
private
static
String
queryQuotationURLScopeParam
=
""
;
private
static
String
queryQuotationMethod
=
""
;
//获取报价单详情
private
static
String
queryQuotationDetailMethod
=
""
;
/**
* 同步报价数据
* @param begin
* @param end
* @return
* @throws InterruptedException
*/
@Override
public
QuotationResponse
synchQuotaion
(
Date
begin
,
Date
end
)
throws
InterruptedException
{
queryQuotationMethod
=
systemConfigService
.
getSingleConfigValue
(
"LinkerSoftAPIQueryQuotationMethod"
);
queryQuotationURLScopeParam
=
systemConfigService
.
getSingleConfigValue
(
"LinkerSoftAPIQueryQuotationURLScopeParam"
);
queryQuotationDetailMethod
=
systemConfigService
.
getSingleConfigValue
(
"LinkerSoftAPIQueryQuotationDetailMethod"
);
String
startTime
=
CommonUtil
.
dateParseString
(
begin
,
"yyyy-MM-dd"
);
String
endTime
=
CommonUtil
.
dateParseString
(
end
,
"yyyy-MM-dd"
);
return
syncPolicyList
(
startTime
,
endTime
);
}
/**
* 同步芝麻报价数据
* @param startTime
* @param endTime
* @param token
* @return
*/
private
QuotationResponse
syncPolicyList
(
String
startTime
,
String
endTime
)
{
QuotationResponse
quotationResponse
;
quotationResponse
=
new
QuotationResponse
();
QuotationResponse
quotationResponsePage
=
new
QuotationResponse
();
Integer
start
=
0
;
Integer
total
=
0
;
Integer
size
=
15
;
//询价单列表,按状态,1,2,3
PolicyResponse
policyList
=
null
;
policyList
=
queryListOnePage
(
startTime
,
endTime
,
start
);
total
=
Integer
.
parseInt
(
policyList
.
getDatas
().
getPolicyPage
().
getTotal
());
System
.
out
.
println
(
"Total:"
+
total
);
quotationResponse
.
setTotal
(
total
);
while
(
start
<
total
)
{
quotationResponsePage
=
new
QuotationResponse
();
//分页,开始行,页行数queryQuotationURLParam
System
.
out
.
println
(
"start:"
+
start
);
policyList
=
queryListOnePage
(
startTime
,
endTime
,
start
);
quotationResponsePage
=
displayList
(
policyList
.
getDatas
().
getPolicyPage
().
getRows
());
quotationResponse
.
setTotalPremium
(
quotationResponse
.
getTotalPremium
().
add
(
quotationResponsePage
.
getTotalPremium
()));
quotationResponse
.
setBzPremium
(
quotationResponse
.
getBzPremium
().
add
(
quotationResponsePage
.
getBzPremium
()));
quotationResponse
.
setTcPremium
(
quotationResponse
.
getTcPremium
().
add
(
quotationResponsePage
.
getTcPremium
()));
quotationResponse
.
setTsltax
(
quotationResponse
.
getTsltax
().
add
(
quotationResponsePage
.
getTsltax
()));
quotationResponse
.
setAllCharge
(
quotationResponse
.
getAllCharge
().
add
(
quotationResponsePage
.
getAllCharge
()));
if
(
start
>
0
&&
(
start
+
size
>
total
))
{
break
;
}
else
{
start
=
start
+
size
;
}
}
return
quotationResponse
;
}
/**
* 同步一页数据
* @param startTime
* @param endTime
* @param start
* @param token
* @return
*/
private
PolicyResponse
queryListOnePage
(
String
startTime
,
String
endTime
,
Integer
start
)
{
String
queryQuotationMethodStep
=
String
.
format
(
queryQuotationMethod
,
start
.
toString
(),
"15"
);
queryQuotationURLScopeParam
=
String
.
format
(
queryQuotationURLScopeParam
,
startTime
,
endTime
);
PolicyResponse
policyList
=
ZhimaConnection
.
postUrlMap2JavaBean
(
ZhimaConnection
.
getHostURL
()
+
queryQuotationMethodStep
,
queryQuotationURLScopeParam
,
PolicyResponse
.
class
);
return
policyList
;
}
/**
* 同步一页报价详情
* @param list
* @param token
* @return
*/
private
QuotationResponse
displayList
(
List
<
PolicyInfo
>
list
)
{
QuotationResponse
quotationResponse
=
new
QuotationResponse
();
String
policyCode
=
null
;
Date
quotationDate
=
null
;
BigDecimal
totalPremium
=
new
BigDecimal
(
0
);
BigDecimal
bzPremium
=
new
BigDecimal
(
0
);
BigDecimal
tcPremium
=
new
BigDecimal
(
0
);
BigDecimal
vsltax
=
new
BigDecimal
(
0
);
BigDecimal
allCharge
=
new
BigDecimal
(
0
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
policyCode
=
list
.
get
(
i
).
getPolicycode
();
quotationDate
=
list
.
get
(
i
).
getCreateDate
();
System
.
out
.
print
(
""
+
list
.
get
(
i
).
getCarNumber
());
totalPremium
=
totalPremium
.
add
(
BigDecimal
.
valueOf
(
list
.
get
(
i
).
getTotalPremium
()));
bzPremium
=
bzPremium
.
add
(
BigDecimal
.
valueOf
(
list
.
get
(
i
).
getBzPremium
()));
tcPremium
=
tcPremium
.
add
(
BigDecimal
.
valueOf
(
list
.
get
(
i
).
getTcPremium
()));
vsltax
=
vsltax
.
add
(
BigDecimal
.
valueOf
(
list
.
get
(
i
).
getVsltax
()));
allCharge
=
allCharge
.
add
(
BigDecimal
.
valueOf
(
list
.
get
(
i
).
getAllCharge
()));
System
.
out
.
print
(
"getTotalPremium,"
+
list
.
get
(
i
).
getTotalPremium
());
System
.
out
.
print
(
"getBzPremium,"
+
list
.
get
(
i
).
getBzPremium
());
System
.
out
.
print
(
"getTcPremium,"
+
list
.
get
(
i
).
getTcPremium
());
System
.
out
.
print
(
"getVsltax,"
+
list
.
get
(
i
).
getVsltax
());
System
.
out
.
println
(
"getAllCharge,"
+
list
.
get
(
i
).
getAllCharge
());
//检查是否已经存在
AgPoQuotation
one
=
agPoQuotationService
.
findByQuoteNo
(
policyCode
);
if
(
one
==
null
)
{
String
queryQuotationDetailMethodNew
=
String
.
format
(
queryQuotationDetailMethod
,
policyCode
);
//QuotationDetail postConfirm = getComfirmationDetail(ZhimaConnection.getHostURL() + queryQuotationDetailMethodNew,null,token);
QuotationDetail
postConfirm
=
ZhimaConnection
.
getUrlMap2JavaBean
(
ZhimaConnection
.
getHostURL
()
+
queryQuotationDetailMethodNew
,
QuotationDetail
.
class
);
//写车辆信息,报价信息,coverages入表
//agPoQuotationWebService.saveAgPoQuotation(postConfirm.getDatas().getPriceinfo());
agPoQuotationWebService
.
saveAgPoQuotationAndConfirm
(
quotationDate
,
postConfirm
.
getDatas
().
getPriceinfo
(),
postConfirm
.
getDatas
().
getConfirmInfo
());
//写确认信息入表confirmInfo
//agPoQuotationWebService.saveAgPoQuotationConfirm(postConfirm.getDatas().getConfirmInfo());
/*System.out.print("" + postConfirm.getDatas().getPriceinfo().getVehInfo().getRegistrationNumber());
System.out.print("getTotalPremium," + postConfirm.getDatas().getPriceinfo().getTotalPremium());
System.out.print("getBzPremium," + postConfirm.getDatas().getPriceinfo().getBzPremium());
System.out.print("getTcPremium," + postConfirm.getDatas().getPriceinfo().getTcPremium());
System.out.print("getAllCharge," + postConfirm.getDatas().getPriceinfo().getAllCharge());
System.out.println("getVsltax," + postConfirm.getDatas().getPriceinfo().getVsltax());
System.out.print("getAllCharge," + postConfirm.getDatas().getPriceinfo().getAllCharge());
System.out.print("," + dateToString(list.get(i).getCreateDate()));
System.out.println("");*/
}
}
quotationResponse
.
setTotalPremium
(
totalPremium
);
quotationResponse
.
setBzPremium
(
bzPremium
);
quotationResponse
.
setTcPremium
(
tcPremium
);
quotationResponse
.
setTsltax
(
vsltax
);
quotationResponse
.
setAllCharge
(
allCharge
);
return
quotationResponse
;
}
}
\ No newline at end of file
ajb-car-api/src/main/resources/application-local.properties
View file @
744bf4ee
...
...
@@ -56,7 +56,7 @@ spring.jpa.properties.hibernate.format_sql=false
spring.jpa.properties.hibernate.use_sql_comments
=
false
# Hibernate ddl auto (create, create-drop, update)
spring.jpa.hibernate.ddl-auto
=
updat
e
spring.jpa.hibernate.ddl-auto
=
non
e
# Naming strategy
#[org.hibernate.cfg.ImprovedNamingStrategy #org.hibernate.cfg.DefaultNamingStrategy]
spring.jpa.hibernate.naming-strategy
=
org.hibernate.cfg.ImprovedNamingStrategy
...
...
ajb-car-utils/src/main/java/com/ajb/common/utils/cache/SystemCacheManager.java
View file @
744bf4ee
ajb-car-utils/src/main/java/com/ajb/common/utils/encryption/DESUtils.java
View file @
744bf4ee
ajb-car-utils/src/main/java/com/ajb/common/utils/encryption/EncryptUtil.java
View file @
744bf4ee
ajb-car-utils/src/main/java/com/ajb/common/utils/encryption/JPACryptoConverter.java
View file @
744bf4ee
ajb-car-utils/src/main/java/com/ajb/common/utils/encryption/JPASensitiveSetting.java
View file @
744bf4ee
ajb-car-utils/src/main/java/com/ajb/common/utils/encryption/MD5Util.java
View file @
744bf4ee
ajb-car-utils/src/main/java/com/ajb/common/utils/encryption/MaskUtils.java
View file @
744bf4ee
ajb-car-utils/src/main/java/com/ajb/common/utils/http/HttpHelpZhiMa.java
View file @
744bf4ee
...
...
@@ -76,7 +76,6 @@ public class HttpHelpZhiMa {
public
static
String
doGet
(
String
url
,
String
token
)
{
String
returnValue
=
null
;
RequestBody
body
=
null
;
OkHttpClient
client
=
new
OkHttpClient
();
...
...
@@ -117,6 +116,7 @@ public class HttpHelpZhiMa {
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
return
returnValue
;
}
public
static
String
doPost
(
String
url
,
String
requestBody
,
String
token
)
...
...
ajb-car-utils/src/main/java/com/ajb/common/utils/http/HttpUtil.java
View file @
744bf4ee
ajb-car-utils/src/main/java/com/ajb/common/utils/office/ExcelUtils.java
View file @
744bf4ee
ajb-car-utils/src/main/java/com/ajb/common/utils/string/CommonUtil.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
common
.
utils
.
string
;
import
java.io.BufferedReader
;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.OutputStreamWriter
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.io.UnsupportedEncodingException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.net.Inet4Address
;
import
java.net.Inet6Address
;
import
java.net.InetAddress
;
import
java.net.NetworkInterface
;
import
java.net.SocketException
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.text.DecimalFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
javax.servlet.http.HttpServletRequest
;
public
class
CommonUtil
{
private
static
final
String
EMAIL_REGEX
=
"^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"
;
//邮箱正则表达式
/*
* 日期格式:http://blog.csdn.net/linghu_java/article/details/38379603
* yyyy-MM-dd HH:mm:ss:SSS 24小时制
* yyyy-MM-dd hh:mm:ss:SSS 12小时制
*/
/**
* 日期转换成字符串
* @param source
* @param pattern 例如 yyyy-MM-dd HH:mm:ss
* @return
*/
public
static
String
dateParseString
(
Date
source
,
String
pattern
){
if
(
source
==
null
){
return
null
;
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
pattern
);
return
sdf
.
format
(
source
);
}
/**
* 字符串转换成日期
* @param source
* @param pattern 例如 yyyy-MM-dd HH:mm:ss
* @return
*/
public
static
Date
stringParseDate
(
String
source
,
String
pattern
){
if
(
isNullOrBlank
(
source
)
||
isNullOrBlank
(
pattern
)){
return
null
;
}
Date
date
=
null
;
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
pattern
);
try
{
date
=
sdf
.
parse
(
source
);
}
catch
(
ParseException
e
)
{
return
null
;
}
return
date
;
}
public
static
double
doubleFormat
(
Double
source
,
int
num
){
if
(
source
==
null
){
source
=
0
d
;
}
BigDecimal
bd
=
new
BigDecimal
(
source
);
double
result
=
bd
.
setScale
(
num
,
BigDecimal
.
ROUND_HALF_UP
).
doubleValue
();
return
result
;
}
public
static
String
doubleParseString
(
Double
source
,
String
parten
){
if
(
source
==
null
){
source
=
0
d
;
}
if
(
parten
==
null
){
parten
=
"##,###,###,##0.00"
;
}
DecimalFormat
fmt
=
new
DecimalFormat
(
parten
);
return
fmt
.
format
(
source
);
}
public
static
String
longParseString
(
Long
source
,
String
parten
){
if
(
source
==
null
){
source
=
0L
;
}
if
(
parten
==
null
){
parten
=
"##,###,###,###"
;
}
DecimalFormat
fmt
=
new
DecimalFormat
(
parten
);
return
fmt
.
format
(
source
);
}
/**
* 空字符串付默认值
* @param source
* @param defaultValue
* @return
*/
public
static
String
nullStringToDefault
(
String
source
,
String
defaultValue
){
String
result
=
source
;
if
(
isNullOrBlank
(
source
)){
result
=
defaultValue
;
}
return
result
;
}
public
static
Integer
stringParseInt
(
String
source
){
Integer
result
=
null
;
if
(
isNullOrBlank
(
source
)){
return
null
;
}
else
{
try
{
result
=
Integer
.
parseInt
(
source
);
}
catch
(
Exception
e
){}
}
return
result
;
}
public
static
Long
stringParseLong
(
String
source
){
Long
result
=
null
;
if
(
isNullOrBlank
(
source
)){
return
null
;
}
else
{
try
{
result
=
Long
.
parseLong
(
source
);
}
catch
(
Exception
e
){}
}
return
result
;
}
public
static
Double
stringParseDouble
(
String
source
){
Double
result
=
null
;
if
(
isNullOrBlank
(
source
)){
return
null
;
}
else
{
try
{
result
=
Double
.
parseDouble
(
source
);
}
catch
(
Exception
e
){}
}
return
result
;
}
public
static
boolean
isNullOrBlank
(
String
source
){
boolean
result
=
false
;
if
(
source
==
null
){
result
=
true
;
}
else
if
(
""
.
equals
(
source
.
trim
())){
result
=
true
;
}
return
result
;
}
public
static
String
getClassType
(
Object
source
){
String
classType
=
"Integer"
;
if
(
source
==
null
){
return
null
;
}
String
className
=
source
.
getClass
().
getName
();
if
(
className
.
contains
(
"java.lang.Integer"
)){
classType
=
"Integer"
;
}
else
if
(
className
.
contains
(
"java.lang.Long"
)){
classType
=
"Long"
;
}
else
if
(
className
.
contains
(
"java.lang.Double"
)){
classType
=
"Double"
;
}
else
if
(
className
.
contains
(
"java.math.BigInteger"
)){
classType
=
"BigInteger"
;
}
else
if
(
className
.
contains
(
"java.math.BigDecimal"
)){
classType
=
"BigDecimal"
;
}
return
classType
;
}
public
static
Integer
intValue
(
Object
source
){
Integer
result
=
null
;
if
(
source
==
null
){
return
0
;
}
try
{
if
(
"Integer"
.
equals
(
getClassType
(
source
))){
result
=
((
Integer
)
source
).
intValue
();
}
else
if
(
"BigInteger"
.
equals
(
getClassType
(
source
))){
result
=
((
BigInteger
)
source
).
intValue
();
}
else
if
(
"BigDecimal"
.
equals
(
getClassType
(
source
))){
result
=
((
BigDecimal
)
source
).
intValue
();
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
result
;
}
public
static
boolean
isNullOrZero
(
Object
source
){
boolean
result
=
false
;
if
(
source
==
null
){
result
=
true
;
}
else
{
if
(
"Integer"
.
equals
(
getClassType
(
source
))){
int
value
=
((
Integer
)
source
).
intValue
();
if
(
value
==
0
){
result
=
true
;
}
}
else
if
(
"Long"
.
equals
(
getClassType
(
source
))){
long
value
=
((
Long
)
source
).
longValue
();
if
(
value
==
0
){
result
=
true
;
}
}
else
if
(
"Double"
.
equals
(
getClassType
(
source
))){
double
value
=
((
Double
)
source
).
doubleValue
();
if
(
value
==
0
){
result
=
true
;
}
}
else
if
(
"BigInteger"
.
equals
(
getClassType
(
source
))){
double
value
=
((
BigInteger
)
source
).
doubleValue
();
if
(
value
==
0
){
result
=
true
;
}
}
else
if
(
"BigDecimal"
.
equals
(
getClassType
(
source
))){
double
value
=
((
BigDecimal
)
source
).
doubleValue
();
if
(
value
==
0
){
result
=
true
;
}
}
}
return
result
;
}
/**
* 求时间差
* @param source 终止时间
* @param target 开始时间
* @param unit D天 H小时 M分 S秒 MS毫秒
* @return
*/
public
static
long
getDatePeriod
(
Date
source
,
Date
target
,
String
unit
){
long
result
=
0
;
long
nd
=
1000
*
24
*
60
*
60
;
long
nh
=
1000
*
60
*
60
;
long
nm
=
1000
*
60
;
long
ns
=
1000
;
long
ms
=
1
;
// 获得两个时间的毫秒时间差异
long
diff
=
source
.
getTime
()
-
target
.
getTime
();
/*
// 计算差多少天
long day = diff / nd;
// 计算差多少小时
long hour = diff % nd / nh;
// 计算差多少分钟
long min = diff % nd % nh / nm;
// 计算差多少秒//输出结果
long sec = diff % nd % nh % nm / ns;
//return day + "天" + hour + "小时" + min + "分钟";
*/
if
(
"D"
.
equals
(
unit
)){
result
=
diff
/
nd
;
}
else
if
(
"H"
.
equals
(
unit
)){
result
=
diff
/
nh
;
}
else
if
(
"M"
.
equals
(
unit
)){
result
=
diff
/
nm
;
}
else
if
(
"S"
.
equals
(
unit
)){
result
=
diff
/
ns
;
}
else
if
(
"MS"
.
equals
(
unit
)){
result
=
diff
/
ms
;
}
return
result
;
}
/**
*
* @param source
* @param operation ADD或SUB
* @param unit S秒 M分钟 H小时 D天 W周 Mon月 Y年
* @param number
* @return
*/
public
static
Date
dateOperation
(
Date
source
,
String
operation
,
String
unit
,
int
number
){
Date
result
=
null
;
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
source
);
int
field
=
Calendar
.
SECOND
;
if
(
"S"
.
equals
(
unit
)){
field
=
Calendar
.
SECOND
;
}
else
if
(
"M"
.
equals
(
unit
)){
field
=
Calendar
.
MINUTE
;
}
else
if
(
"H"
.
equals
(
unit
)){
field
=
Calendar
.
HOUR_OF_DAY
;
}
else
if
(
"D"
.
equals
(
unit
)){
field
=
Calendar
.
DATE
;
}
else
if
(
"W"
.
equals
(
unit
)){
field
=
Calendar
.
WEEK_OF_MONTH
;
}
else
if
(
"Mon"
.
equals
(
unit
)){
field
=
Calendar
.
MONTH
;
}
else
if
(
"Y"
.
equals
(
unit
)){
field
=
Calendar
.
YEAR
;
}
if
(
"SUB"
.
equals
(
operation
)){
calendar
.
add
(
field
,
-
number
);
}
else
{
calendar
.
add
(
field
,
number
);
}
result
=
calendar
.
getTime
();
return
result
;
}
/**
* 由出生日期获得年龄
* @param birthDay
* @return
* @throws Exception
*/
public
static
int
getAge
(
Date
birthDay
){
int
age
=
0
;
if
(
birthDay
==
null
){
return
0
;
}
try
{
Calendar
cal
=
Calendar
.
getInstance
();
if
(
cal
.
before
(
birthDay
))
{
// throw new IllegalArgumentException("The birthDay is before Now.It's unbelievable!");
return
-
1
;
}
int
yearNow
=
cal
.
get
(
Calendar
.
YEAR
);
int
monthNow
=
cal
.
get
(
Calendar
.
MONTH
);
int
dayOfMonthNow
=
cal
.
get
(
Calendar
.
DAY_OF_MONTH
);
cal
.
setTime
(
birthDay
);
int
yearBirth
=
cal
.
get
(
Calendar
.
YEAR
);
int
monthBirth
=
cal
.
get
(
Calendar
.
MONTH
);
int
dayOfMonthBirth
=
cal
.
get
(
Calendar
.
DAY_OF_MONTH
);
age
=
yearNow
-
yearBirth
;
if
(
monthNow
<=
monthBirth
)
{
if
(
monthNow
==
monthBirth
)
{
if
(
dayOfMonthNow
<
dayOfMonthBirth
){
age
--;
}
}
else
{
age
--;
}
}
}
catch
(
Exception
e
){}
return
age
;
}
/**
* 根据异常对象获取异常堆栈字符串
* @param e
* @return
*/
public
static
String
parseExceptionStack
(
Exception
e
){
String
exceptionStack
=
null
;
/*StringBuffer sbf = new StringBuffer();
StackTraceElement[] stack = e.getStackTrace();
StackTraceElement element = null;
String message = e.toString();
sbf.append(message+"\n");
for(int i=0;i<stack.length;i++){
element = stack[i];
String fileName = element.getFileName();
String methodName = element.getMethodName();
String className = element.getClassName();
int lineNumber = element.getLineNumber();
String append = fileName+":"+lineNumber;
boolean isNativeMethod = element.isNativeMethod();
if(isNativeMethod){
append = "Native Method";
}
sbf.append(" at "+className+"."+methodName+"("+append+")\n");
}
exceptionStack = sbf.toString();*/
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
e
.
printStackTrace
(
pw
);
exceptionStack
=
sw
.
toString
();
return
exceptionStack
;
}
public
static
boolean
isValidDate
(
String
source
,
String
pattern
)
{
boolean
convertSuccess
=
true
;
if
(
isNullOrBlank
(
source
)){
return
false
;
}
SimpleDateFormat
format
=
new
SimpleDateFormat
(
pattern
);
try
{
format
.
setLenient
(
false
);
format
.
parse
(
source
);
}
catch
(
Exception
e
)
{
convertSuccess
=
false
;
}
return
convertSuccess
;
}
public
static
boolean
checkEmail
(
String
email
){
return
Pattern
.
matches
(
EMAIL_REGEX
,
email
.
trim
());
}
/**
*
* @param area 省份名、城市名、县名
* @param birthDay 出生日期,格式(19891019)
* @param gender 性别(范围:1-9,男:奇数,女:偶数)
* @param age
* @return
*/
public
static
String
createID
(
String
area
,
String
birthDay
,
String
gender
,
Integer
age
){
String
idNo
=
null
;
String
areaCode
=
null
;
String
seqNo
=
getRandomNum
(
2
)+
""
;
// (两位)顺序号,格式(00-99)
Random
random
=
new
Random
();
String
areaCodeFile
=
CommonUtil
.
class
.
getResource
(
""
).
getPath
()+
File
.
separator
+
"areaCode.txt"
;
List
<
String
>
areaList
=
readFile
(
areaCodeFile
,
"UTF-8"
);
if
(
area
==
null
||
""
.
equals
(
area
)){
String
item
=
areaList
.
get
(
random
.
nextInt
(
areaList
.
size
())
-
1
);
areaCode
=
item
.
split
(
" "
)[
0
];
}
else
{
for
(
String
item
:
areaList
){
if
(
item
.
contains
(
area
)){
areaCode
=
item
.
split
(
" "
)[
0
];
break
;
}
}
}
if
(
areaCode
==
null
){
areaCode
=
"110101"
;}
if
(
birthDay
==
null
||
""
.
equals
(
birthDay
)){
if
(
age
==
null
||
age
<=
0
){
int
[]
arr
=
new
int
[]{
1
,
2
,
3
,
4
};
int
a
=
arr
[
random
.
nextInt
(
4
)];
String
ageStr
=
a
+
getRandomNum
(
1
);
age
=
Integer
.
parseInt
(
ageStr
);
}
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
add
(
Calendar
.
YEAR
,
-
age
);
int
randomDay
=
1
+(
int
)(
Math
.
random
()*
360
);
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
-
randomDay
);
birthDay
=
dateParseString
(
calendar
.
getTime
(),
"yyyyMMdd"
);
}
if
(
gender
==
null
||
""
.
equals
(
gender
)){
gender
=
getRandomNum
(
1
)+
""
;
}
// 前17位要除以的数:7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2
int
finalAreaCode
=
Integer
.
parseInt
(
areaCode
.
substring
(
0
,
1
))
*
7
+
Integer
.
parseInt
(
areaCode
.
substring
(
1
,
2
))
*
9
+
Integer
.
parseInt
(
areaCode
.
substring
(
2
,
3
))
*
10
+
Integer
.
parseInt
(
areaCode
.
substring
(
3
,
4
))
*
5
+
Integer
.
parseInt
(
areaCode
.
substring
(
4
,
5
))
*
8
+
Integer
.
parseInt
(
areaCode
.
substring
(
5
,
6
))
*
4
;
int
finalBirthday
=
Integer
.
parseInt
(
birthDay
.
substring
(
0
,
1
))
*
2
+
Integer
.
parseInt
(
birthDay
.
substring
(
1
,
2
))
*
1
+
Integer
.
parseInt
(
birthDay
.
substring
(
2
,
3
))
*
6
+
Integer
.
parseInt
(
birthDay
.
substring
(
3
,
4
))
*
3
+
Integer
.
parseInt
(
birthDay
.
substring
(
4
,
5
))
*
7
+
Integer
.
parseInt
(
birthDay
.
substring
(
5
,
6
))
*
9
+
Integer
.
parseInt
(
birthDay
.
substring
(
6
,
7
))
*
10
+
Integer
.
parseInt
(
birthDay
.
substring
(
7
,
8
))
*
5
;
int
NoIs
=
(
Integer
.
parseInt
(
seqNo
.
substring
(
0
,
1
)))
*
8
+
(
Integer
.
parseInt
(
seqNo
.
substring
(
1
,
2
)))
*
4
;
int
sexNo
=
(
Integer
.
parseInt
(
gender
.
substring
(
0
,
1
)))
*
2
;
int
checkCode
=
(
finalAreaCode
+
finalBirthday
+
NoIs
+
sexNo
)
%
11
;
int
finalCheckCode
=
0
;
// 余数范围: 0 1 2 3 4 5 6 7 8 9 10
// 余数对应的数:1 0 X 9 8 7 6 5 4 3 2
// 计算出最终的校验码:finalCheckCode
switch
(
checkCode
)
{
case
0
:
finalCheckCode
=
1
;
break
;
case
1
:
finalCheckCode
=
0
;
break
;
case
2
:
finalCheckCode
=
-
3
;
break
;
case
3
:
finalCheckCode
=
9
;
break
;
case
4
:
finalCheckCode
=
8
;
break
;
case
5
:
finalCheckCode
=
7
;
break
;
case
6
:
finalCheckCode
=
6
;
break
;
case
7
:
finalCheckCode
=
5
;
break
;
case
8
:
finalCheckCode
=
4
;
break
;
case
9
:
finalCheckCode
=
3
;
break
;
case
10
:
finalCheckCode
=
2
;
break
;
default
:
break
;
}
// 区域编号(6位数)+出生日期(8位数)+顺序编号(2位数)+性别号(1位数)+校验码(1位数)=身份证号(18位数)
String
checkInd
=
null
;
if
(
finalCheckCode
==
-
3
){
checkInd
=
"X"
;
}
else
{
checkInd
=
finalCheckCode
+
""
;
}
idNo
=
areaCode
+
birthDay
+
seqNo
+
gender
+
checkInd
;
return
idNo
;
}
public
static
String
createMail
(){
String
mail
=
getRandomString
(
5
)+
"@163.com"
;
return
mail
;
}
public
static
String
createPhoneNo
(){
return
"139"
+
getRandomNum
(
8
);
}
public
static
String
getRandomString
(
int
length
)
{
//length表示生成字符串的长度
String
base
=
"abcdefghijklmnopqrstuvwxyz0123456789"
;
Random
random
=
new
Random
();
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
int
number
=
random
.
nextInt
(
base
.
length
());
sb
.
append
(
base
.
charAt
(
number
));
}
return
sb
.
toString
();
}
public
static
String
getRandomNum
(
int
length
)
{
//length表示生成字符串的长度
String
base
=
"0123456789"
;
Random
random
=
new
Random
();
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
int
number
=
random
.
nextInt
(
base
.
length
());
sb
.
append
(
base
.
charAt
(
number
));
}
return
sb
.
toString
();
}
public
static
String
createName
(){
Random
random
=
new
Random
(
System
.
currentTimeMillis
());
/* 598 百家姓 */
String
[]
Surname
=
{
"赵"
,
"钱"
,
"孙"
,
"李"
,
"周"
,
"吴"
,
"郑"
,
"王"
,
"冯"
,
"陈"
,
"褚"
,
"卫"
,
"蒋"
,
"沈"
,
"韩"
,
"杨"
,
"朱"
,
"秦"
,
"尤"
,
"许"
,
"何"
,
"吕"
,
"施"
,
"张"
,
"孔"
,
"曹"
,
"严"
,
"华"
,
"金"
,
"魏"
,
"陶"
,
"姜"
,
"戚"
,
"谢"
,
"邹"
,
"喻"
,
"柏"
,
"水"
,
"窦"
,
"章"
,
"云"
,
"苏"
,
"潘"
,
"葛"
,
"奚"
,
"范"
,
"彭"
,
"郎"
,
"鲁"
,
"韦"
,
"昌"
,
"马"
,
"苗"
,
"凤"
,
"花"
,
"方"
,
"俞"
,
"任"
,
"袁"
,
"柳"
,
"酆"
,
"鲍"
,
"史"
,
"唐"
,
"费"
,
"廉"
,
"岑"
,
"薛"
,
"雷"
,
"贺"
,
"倪"
,
"汤"
,
"滕"
,
"殷"
,
"罗"
,
"毕"
,
"郝"
,
"邬"
,
"安"
,
"常"
,
"乐"
,
"于"
,
"时"
,
"傅"
,
"皮"
,
"卞"
,
"齐"
,
"康"
,
"伍"
,
"余"
,
"元"
,
"卜"
,
"顾"
,
"孟"
,
"平"
,
"黄"
,
"和"
,
"穆"
,
"萧"
,
"尹"
,
"姚"
,
"邵"
,
"湛"
,
"汪"
,
"祁"
,
"毛"
,
"禹"
,
"狄"
,
"米"
,
"贝"
,
"明"
,
"臧"
,
"计"
,
"伏"
,
"成"
,
"戴"
,
"谈"
,
"宋"
,
"茅"
,
"庞"
,
"熊"
,
"纪"
,
"舒"
,
"屈"
,
"项"
,
"祝"
,
"董"
,
"梁"
,
"杜"
,
"阮"
,
"蓝"
,
"闵"
,
"席"
,
"季"
,
"麻"
,
"强"
,
"贾"
,
"路"
,
"娄"
,
"危"
,
"江"
,
"童"
,
"颜"
,
"郭"
,
"梅"
,
"盛"
,
"林"
,
"刁"
,
"钟"
,
"徐"
,
"邱"
,
"骆"
,
"高"
,
"夏"
,
"蔡"
,
"田"
,
"樊"
,
"胡"
,
"凌"
,
"霍"
,
"虞"
,
"万"
,
"支"
,
"柯"
,
"昝"
,
"管"
,
"卢"
,
"莫"
,
"经"
,
"房"
,
"裘"
,
"缪"
,
"干"
,
"解"
,
"应"
,
"宗"
,
"丁"
,
"宣"
,
"贲"
,
"邓"
,
"郁"
,
"单"
,
"杭"
,
"洪"
,
"包"
,
"诸"
,
"左"
,
"石"
,
"崔"
,
"吉"
,
"钮"
,
"龚"
,
"程"
,
"嵇"
,
"邢"
,
"滑"
,
"裴"
,
"陆"
,
"荣"
,
"翁"
,
"荀"
,
"羊"
,
"于"
,
"惠"
,
"甄"
,
"曲"
,
"家"
,
"封"
,
"芮"
,
"羿"
,
"储"
,
"靳"
,
"汲"
,
"邴"
,
"糜"
,
"松"
,
"井"
,
"段"
,
"富"
,
"巫"
,
"乌"
,
"焦"
,
"巴"
,
"弓"
,
"牧"
,
"隗"
,
"山"
,
"谷"
,
"车"
,
"侯"
,
"宓"
,
"蓬"
,
"全"
,
"郗"
,
"班"
,
"仰"
,
"秋"
,
"仲"
,
"伊"
,
"宫"
,
"宁"
,
"仇"
,
"栾"
,
"暴"
,
"甘"
,
"钭"
,
"厉"
,
"戎"
,
"祖"
,
"武"
,
"符"
,
"刘"
,
"景"
,
"詹"
,
"束"
,
"龙"
,
"叶"
,
"幸"
,
"司"
,
"韶"
,
"郜"
,
"黎"
,
"蓟"
,
"溥"
,
"印"
,
"宿"
,
"白"
,
"怀"
,
"蒲"
,
"邰"
,
"从"
,
"鄂"
,
"索"
,
"咸"
,
"籍"
,
"赖"
,
"卓"
,
"蔺"
,
"屠"
,
"蒙"
,
"池"
,
"乔"
,
"阴"
,
"郁"
,
"胥"
,
"能"
,
"苍"
,
"双"
,
"闻"
,
"莘"
,
"党"
,
"翟"
,
"谭"
,
"贡"
,
"劳"
,
"逄"
,
"姬"
,
"申"
,
"扶"
,
"堵"
,
"冉"
,
"宰"
,
"郦"
,
"雍"
,
"却"
,
"璩"
,
"桑"
,
"桂"
,
"濮"
,
"牛"
,
"寿"
,
"通"
,
"边"
,
"扈"
,
"燕"
,
"冀"
,
"浦"
,
"尚"
,
"农"
,
"温"
,
"别"
,
"庄"
,
"晏"
,
"柴"
,
"瞿"
,
"阎"
,
"充"
,
"慕"
,
"连"
,
"茹"
,
"习"
,
"宦"
,
"艾"
,
"鱼"
,
"容"
,
"向"
,
"古"
,
"易"
,
"慎"
,
"戈"
,
"廖"
,
"庾"
,
"终"
,
"暨"
,
"居"
,
"衡"
,
"步"
,
"都"
,
"耿"
,
"满"
,
"弘"
,
"匡"
,
"国"
,
"文"
,
"寇"
,
"广"
,
"禄"
,
"阙"
,
"东"
,
"欧"
,
"殳"
,
"沃"
,
"利"
,
"蔚"
,
"越"
,
"夔"
,
"隆"
,
"师"
,
"巩"
,
"厍"
,
"聂"
,
"晁"
,
"勾"
,
"敖"
,
"融"
,
"冷"
,
"訾"
,
"辛"
,
"阚"
,
"那"
,
"简"
,
"饶"
,
"空"
,
"曾"
,
"毋"
,
"沙"
,
"乜"
,
"养"
,
"鞠"
,
"须"
,
"丰"
,
"巢"
,
"关"
,
"蒯"
,
"相"
,
"查"
,
"后"
,
"荆"
,
"红"
,
"游"
,
"郏"
,
"竺"
,
"权"
,
"逯"
,
"盖"
,
"益"
,
"桓"
,
"公"
,
"仉"
,
"督"
,
"岳"
,
"帅"
,
"缑"
,
"亢"
,
"况"
,
"郈"
,
"有"
,
"琴"
,
"归"
,
"海"
,
"晋"
,
"楚"
,
"闫"
,
"法"
,
"汝"
,
"鄢"
,
"涂"
,
"钦"
,
"商"
,
"牟"
,
"佘"
,
"佴"
,
"伯"
,
"赏"
,
"墨"
,
"哈"
,
"谯"
,
"篁"
,
"年"
,
"爱"
,
"阳"
,
"佟"
,
"言"
,
"福"
,
"南"
,
"火"
,
"铁"
,
"迟"
,
"漆"
,
"官"
,
"冼"
,
"真"
,
"展"
,
"繁"
,
"檀"
,
"祭"
,
"密"
,
"敬"
,
"揭"
,
"舜"
,
"楼"
,
"疏"
,
"冒"
,
"浑"
,
"挚"
,
"胶"
,
"随"
,
"高"
,
"皋"
,
"原"
,
"种"
,
"练"
,
"弥"
,
"仓"
,
"眭"
,
"蹇"
,
"覃"
,
"阿"
,
"门"
,
"恽"
,
"来"
,
"綦"
,
"召"
,
"仪"
,
"风"
,
"介"
,
"巨"
,
"木"
,
"京"
,
"狐"
,
"郇"
,
"虎"
,
"枚"
,
"抗"
,
"达"
,
"杞"
,
"苌"
,
"折"
,
"麦"
,
"庆"
,
"过"
,
"竹"
,
"端"
,
"鲜"
,
"皇"
,
"亓"
,
"老"
,
"是"
,
"秘"
,
"畅"
,
"邝"
,
"还"
,
"宾"
,
"闾"
,
"辜"
,
"纵"
,
"侴"
,
"万俟"
,
"司马"
,
"上官"
,
"欧阳"
,
"夏侯"
,
"诸葛"
,
"闻人"
,
"东方"
,
"赫连"
,
"皇甫"
,
"羊舌"
,
"尉迟"
,
"公羊"
,
"澹台"
,
"公冶"
,
"宗正"
,
"濮阳"
,
"淳于"
,
"单于"
,
"太叔"
,
"申屠"
,
"公孙"
,
"仲孙"
,
"轩辕"
,
"令狐"
,
"钟离"
,
"宇文"
,
"长孙"
,
"慕容"
,
"鲜于"
,
"闾丘"
,
"司徒"
,
"司空"
,
"兀官"
,
"司寇"
,
"南门"
,
"呼延"
,
"子车"
,
"颛孙"
,
"端木"
,
"巫马"
,
"公西"
,
"漆雕"
,
"车正"
,
"壤驷"
,
"公良"
,
"拓跋"
,
"夹谷"
,
"宰父"
,
"谷梁"
,
"段干"
,
"百里"
,
"东郭"
,
"微生"
,
"梁丘"
,
"左丘"
,
"东门"
,
"西门"
,
"南宫"
,
"第五"
,
"公仪"
,
"公乘"
,
"太史"
,
"仲长"
,
"叔孙"
,
"屈突"
,
"尔朱"
,
"东乡"
,
"相里"
,
"胡母"
,
"司城"
,
"张廖"
,
"雍门"
,
"毋丘"
,
"贺兰"
,
"綦毋"
,
"屋庐"
,
"独孤"
,
"南郭"
,
"北宫"
,
"王孙"
};
int
index
=
random
.
nextInt
(
Surname
.
length
-
1
);
String
name
=
Surname
[
index
];
//获得一个随机的姓氏
/* 从常用字中选取一个或两个字作为名 */
if
(
random
.
nextBoolean
()){
name
+=
getChinese
()+
getChinese
();
}
else
{
name
+=
getChinese
();
}
// System.out.println(name);
return
name
;
}
public
static
String
getChinese
()
{
String
str
=
null
;
int
highPos
,
lowPos
;
Random
random
=
new
Random
();
highPos
=
(
176
+
Math
.
abs
(
random
.
nextInt
(
71
)));
//区码,0xA0打头,从第16区开始,即0xB0=11*16=176,16~55一级汉字,56~87二级汉字
random
=
new
Random
();
lowPos
=
161
+
Math
.
abs
(
random
.
nextInt
(
94
));
//位码,0xA0打头,范围第1~94列
byte
[]
bArr
=
new
byte
[
2
];
bArr
[
0
]
=
(
new
Integer
(
highPos
)).
byteValue
();
bArr
[
1
]
=
(
new
Integer
(
lowPos
)).
byteValue
();
try
{
str
=
new
String
(
bArr
,
"GB2312"
);
//区位码组合成汉字
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
return
str
;
}
public
static
void
main
(
String
[]
args
){
// String idNo = createID("南部县", "19940929", "1", null);
String
idNo
=
createID
(
"长丰县"
,
null
,
"1"
,
31
);
System
.
out
.
println
(
idNo
);
System
.
out
.
println
(
IDcardValidator
.
isIdcardValid
(
idNo
));
}
@SuppressWarnings
(
"rawtypes"
)
public
static
String
currentIP
(){
String
currentIP
=
null
;
try
{
Enumeration
allNetInterfaces
=
NetworkInterface
.
getNetworkInterfaces
();
InetAddress
ip
=
null
;
while
(
allNetInterfaces
.
hasMoreElements
()){
NetworkInterface
netInterface
=
(
NetworkInterface
)
allNetInterfaces
.
nextElement
();
//System.out.println(netInterface.getName());
Enumeration
addresses
=
netInterface
.
getInetAddresses
();
while
(
addresses
.
hasMoreElements
()){
ip
=
(
InetAddress
)
addresses
.
nextElement
();
if
(
ip
!=
null
&&
ip
instanceof
Inet4Address
){
if
(
currentIP
==
null
){
currentIP
=
""
;
}
currentIP
+=
ip
.
getHostAddress
()+
";"
;
// System.out.println("本机的IP = " + currentIP);
}
if
(
ip
!=
null
&&
ip
instanceof
Inet6Address
){
if
(
currentIP
==
null
){
currentIP
=
""
;
}
currentIP
+=
ip
.
getHostAddress
()+
":"
;
}
}
}
}
catch
(
SocketException
e
)
{
e
.
printStackTrace
();
}
return
currentIP
;
}
/**
* 获取HttpServletRequest请求IP
* @param request
* @return
*/
public
static
String
getIpAddress
(
HttpServletRequest
request
)
{
String
ip
=
request
.
getHeader
(
"x-forwarded-for"
);
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"Proxy-Client-IP"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"WL-Proxy-Client-IP"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"HTTP_CLIENT_IP"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"HTTP_X_FORWARDED_FOR"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getRemoteAddr
();
}
return
ip
;
}
@SuppressWarnings
(
"rawtypes"
)
public
static
void
simpleObjectCopy
(
Object
source
,
Object
target
){
if
(
source
==
null
||
target
==
null
){
return
;
}
try
{
Method
[]
sourceMethods
=
source
.
getClass
().
getDeclaredMethods
();
for
(
Method
smethod
:
sourceMethods
){
Class
returnType
=
smethod
.
getReturnType
();
String
sourceMethodName
=
smethod
.
getName
();
if
(!
returnType
.
getTypeName
().
equals
(
"void"
)
&&
sourceMethodName
.
startsWith
(
"get"
)){
Object
[]
paramArr
=
null
;
Object
getValue
=
smethod
.
invoke
(
source
,
paramArr
);
if
(
getValue
!=
null
){
// System.out.println("--------------in simpleObjectCopy returnType : "+returnType.getTypeName()+" sourceMethodName="+sourceMethodName);
Method
[]
targetMethods
=
target
.
getClass
().
getDeclaredMethods
();
for
(
Method
tmethod
:
targetMethods
){
String
targetMethodName
=
tmethod
.
getName
();
if
(
targetMethodName
.
equals
(
"set"
+
sourceMethodName
.
substring
(
3
))){
Class
[]
parameterTypes
=
tmethod
.
getParameterTypes
();
if
(
parameterTypes
!=
null
&&
parameterTypes
.
length
==
1
&&
parameterTypes
[
0
].
getTypeName
().
equals
(
returnType
.
getTypeName
())){
// System.out.println("--------------in simpleObjectCopy targetMethodName:"+targetMethodName);
tmethod
.
invoke
(
target
,
getValue
);
}
//set value
break
;
}
//set
}
//for targetMethod
}
//get value != null
}
//get
}
//for sourceMethod
}
catch
(
IllegalAccessException
|
IllegalArgumentException
|
InvocationTargetException
e
)
{
e
.
printStackTrace
();
}
}
public
static
String
getInputStreamContent
(
InputStream
inputStream
,
String
charset
)
throws
Exception
{
String
content
=
null
;
if
(
inputStream
==
null
){
return
null
;
}
if
(
charset
==
null
){
charset
=
"UTF-8"
;
}
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
inputStream
,
charset
));
// 为了进行一行读取操作
StringBuilder
buffer
=
new
StringBuilder
();
String
line
=
""
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
buffer
.
append
(
line
);
}
content
=
buffer
.
toString
();
return
content
;
}
public
static
List
<
String
>
readFile
(
String
fileName
,
String
encoding
){
List
<
String
>
contents
=
new
ArrayList
<
String
>();
File
file
=
new
File
(
fileName
);
FileInputStream
fi
=
null
;
InputStreamReader
ir
=
null
;
BufferedReader
br
=
null
;
try
{
fi
=
new
FileInputStream
(
file
);
ir
=
new
InputStreamReader
(
fi
,
encoding
);
br
=
new
BufferedReader
(
ir
);
while
(
br
.
ready
()){
String
line
=
br
.
readLine
();
contents
.
add
(
line
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
fi
.
close
();
ir
.
close
();
br
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
return
contents
;
}
public
static
void
writeFile
(
List
<
String
>
contents
,
String
fileName
,
boolean
appending
,
String
encoding
){
File
file
=
new
File
(
fileName
);
FileOutputStream
fo
=
null
;
OutputStreamWriter
or
=
null
;
BufferedWriter
bw
=
null
;
try
{
fo
=
new
FileOutputStream
(
file
,
appending
);
or
=
new
OutputStreamWriter
(
fo
,
encoding
);
bw
=
new
BufferedWriter
(
or
);
for
(
String
line
:
contents
){
bw
.
write
(
line
);
bw
.
newLine
();
}
bw
.
flush
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
fo
.
close
();
or
.
close
();
bw
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
/**
* 判断是否是数字
*/
private
static
final
Pattern
NUMBER_PATTERN
=
Pattern
.
compile
(
"[0-9]*"
);
public
static
boolean
isNumeric
(
String
str
){
// Pattern pattern = Pattern.compile("[0-9]*");
// Matcher isNum = pattern.matcher(str);
Matcher
numMatcher
=
NUMBER_PATTERN
.
matcher
(
str
);
if
(
!
numMatcher
.
matches
()
){
return
false
;
}
return
true
;
}
// 根据Unicode编码完美的判断中文汉字和符号
public
static
boolean
isChinese
(
char
c
)
{
Character
.
UnicodeBlock
ub
=
Character
.
UnicodeBlock
.
of
(
c
);
if
(
ub
==
Character
.
UnicodeBlock
.
CJK_UNIFIED_IDEOGRAPHS
||
ub
==
Character
.
UnicodeBlock
.
CJK_COMPATIBILITY_IDEOGRAPHS
||
ub
==
Character
.
UnicodeBlock
.
CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
||
ub
==
Character
.
UnicodeBlock
.
CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
||
ub
==
Character
.
UnicodeBlock
.
CJK_SYMBOLS_AND_PUNCTUATION
||
ub
==
Character
.
UnicodeBlock
.
HALFWIDTH_AND_FULLWIDTH_FORMS
||
ub
==
Character
.
UnicodeBlock
.
GENERAL_PUNCTUATION
)
{
return
true
;
}
return
false
;
}
public
static
Double
calcuPersonalTAX
(
Double
amount
){
Double
tax
=
0
d
;
if
(
amount
<=
800
){
tax
=
0.0d
;
}
else
if
(
800
<
amount
&&
amount
<=
4000
){
tax
=
(
amount
-
800
)
*
0.2
;
}
else
if
(
4000
<
amount
&&
amount
<=
25000
){
tax
=
amount
*
(
1
-
0.2
)
*
0.2
;
}
else
if
(
25000
<
amount
&&
amount
<=
62500
){
tax
=
amount
*
(
1
-
0.2
)
*
0.3
-
2000
;
}
else
if
(
62500
<
amount
){
tax
=
amount
*
(
1
-
0.2
)
*
0.4
-
7000
;
}
return
tax
;
}
/**
* 判断字符串中是否含有数字
* @param content
* @return
*/
public
static
boolean
hasDigit
(
String
content
)
{
boolean
flag
=
false
;
Pattern
pattern
=
Pattern
.
compile
(
".*\\d+.*"
);
Matcher
m
=
pattern
.
matcher
(
content
);
if
(
m
.
matches
())
{
flag
=
true
;
}
return
flag
;
}
/**
* 判断是否含有特殊字符
*
* @param str
* @return true为包含,false为不包含
*/
public
static
final
String
DEFAULT_QUERY_REGEX
=
"[ _`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]|\n|\r|\t"
;
public
static
boolean
isSpecialCharacter
(
String
str
)
{
Pattern
p
=
Pattern
.
compile
(
DEFAULT_QUERY_REGEX
);
Matcher
m
=
p
.
matcher
(
str
);
return
m
.
find
();
}
/**
* 通过ip地址获取该ip的实际地理地址
* @param ip
* @return
*/
public
static
String
getAddressByIP
(
String
ip
){
String
address
=
null
;
try
{
URL
url
=
new
URL
(
"http://ip.taobao.com/service/getIpInfo.php?ip="
+
ip
);
URLConnection
conn
=
url
.
openConnection
();
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
conn
.
getInputStream
(),
"utf-8"
));
String
line
=
null
;
StringBuffer
result
=
new
StringBuffer
();
while
((
line
=
reader
.
readLine
())
!=
null
){
result
.
append
(
line
);
}
reader
.
close
();
String
ipInfo
=
result
.
toString
();
IpToAddress
ipToAddress
=
(
IpToAddress
)
JsonUtil
.
jsonToObj
(
ipInfo
,
IpToAddress
.
class
);
if
(
ipToAddress
!=
null
)
{
if
(
"0"
.
equals
(
ipToAddress
.
getCode
())){
String
area
=
ipToAddress
.
getData
().
getCountry
();
if
(
area
==
null
&&
""
.
equals
(
area
))
{
area
=
ipToAddress
.
getData
().
getArea
();
}
String
region
=
ipToAddress
.
getData
().
getRegion
();
String
city
=
ipToAddress
.
getData
().
getCity
();
String
isp
=
ipToAddress
.
getData
().
getIsp
();
address
=
area
+
"_"
+
region
+
"_"
+
city
+
"_"
+
isp
;
}
}
}
catch
(
IOException
e
){
System
.
out
.
println
(
"获取失败!!!!"
);
}
return
address
;
}
/**
* 判断姓名(中文姓名和英文姓名)
*/
public
static
boolean
isConSpeCharacters
(
String
str
)
{
if
(
str
.
replaceAll
(
"[\u4e00-\u9fa5]*[a-z]*[A-Z]*\\d*-*_*\\s*"
,
""
).
length
()
==
0
)
{
return
false
;
}
return
true
;
}
/**
* 通过身份证号码获取出生日期、性别、年龄
* @param certificateNo
* @return 返回的出生日期格式:1990-01-01 性别格式:F-女,M-男
*/
/**
* 通过身份证号码获取出生日期、性别、年龄
* @param certificateNo 身份证号码
* @param type birthday -- 出生年月日 age--年龄 sex--性别
* @return 结果 sex--性别 1-男 2-女
*/
public
static
String
getBirAgeSex
(
String
certificateNo
,
String
type
)
{
String
birthday
=
""
;
String
age
=
""
;
String
sexCode
=
""
;
String
result
=
""
;
int
year
=
Calendar
.
getInstance
().
get
(
Calendar
.
YEAR
);
char
[]
number
=
certificateNo
.
toCharArray
();
boolean
flag
=
true
;
if
(
number
.
length
==
15
)
{
for
(
int
x
=
0
;
x
<
number
.
length
;
x
++)
{
if
(!
flag
)
return
null
;
flag
=
Character
.
isDigit
(
number
[
x
]);
}
}
else
if
(
number
.
length
==
18
)
{
for
(
int
x
=
0
;
x
<
number
.
length
-
1
;
x
++)
{
if
(!
flag
)
return
null
;
flag
=
Character
.
isDigit
(
number
[
x
]);
}
}
if
(
flag
&&
certificateNo
.
length
()
==
15
)
{
birthday
=
"19"
+
certificateNo
.
substring
(
6
,
8
)
+
"-"
+
certificateNo
.
substring
(
8
,
10
)
+
"-"
+
certificateNo
.
substring
(
10
,
12
);
sexCode
=
Integer
.
parseInt
(
certificateNo
.
substring
(
certificateNo
.
length
()
-
3
,
certificateNo
.
length
()))
%
2
==
0
?
"F"
:
"M"
;
age
=
(
year
-
Integer
.
parseInt
(
"19"
+
certificateNo
.
substring
(
6
,
8
)))
+
""
;
}
else
if
(
flag
&&
certificateNo
.
length
()
==
18
)
{
birthday
=
certificateNo
.
substring
(
6
,
10
)
+
"-"
+
certificateNo
.
substring
(
10
,
12
)
+
"-"
+
certificateNo
.
substring
(
12
,
14
);
sexCode
=
Integer
.
parseInt
(
certificateNo
.
substring
(
certificateNo
.
length
()
-
4
,
certificateNo
.
length
()
-
1
))
%
2
==
0
?
"F"
:
"M"
;
age
=
(
year
-
Integer
.
parseInt
(
certificateNo
.
substring
(
6
,
10
)))
+
""
;
}
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
.
put
(
"birthday"
,
birthday
);
map
.
put
(
"age"
,
age
);
map
.
put
(
"sexCode"
,
sexCode
);
if
(
"birthday"
.
equals
(
type
))
{
result
=
birthday
;
}
else
if
(
"age"
.
equals
(
type
)){
result
=
age
;
}
else
if
(
"sex"
.
equals
(
type
)){
if
(
"F"
.
equals
(
sexCode
)){
sexCode
=
"2"
;
}
else
if
(
"M"
.
equals
(
sexCode
))
{
sexCode
=
"1"
;
}
result
=
sexCode
;
}
return
result
;
}
}
ajb-car-utils/src/main/java/com/ajb/common/utils/string/Data.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
common
.
utils
.
string
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
public
class
Data
{
private
String
ip
;
private
String
country
;
private
String
area
;
private
String
region
;
private
String
city
;
private
String
county
;
private
String
isp
;
private
String
countryId
;
private
String
areaId
;
private
String
regionId
;
private
String
cityId
;
private
String
countyId
;
private
String
ispId
;
public
String
getIp
()
{
return
ip
;
}
public
void
setIp
(
String
ip
)
{
this
.
ip
=
ip
;
}
public
String
getCountry
()
{
return
country
;
}
public
void
setCountry
(
String
country
)
{
this
.
country
=
country
;
}
public
String
getArea
()
{
return
area
;
}
public
void
setArea
(
String
area
)
{
this
.
area
=
area
;
}
public
String
getRegion
()
{
return
region
;
}
public
void
setRegion
(
String
region
)
{
this
.
region
=
region
;
}
public
String
getCity
()
{
return
city
;
}
public
void
setCity
(
String
city
)
{
this
.
city
=
city
;
}
public
String
getCounty
()
{
return
county
;
}
public
void
setCounty
(
String
county
)
{
this
.
county
=
county
;
}
public
String
getIsp
()
{
return
isp
;
}
public
void
setIsp
(
String
isp
)
{
this
.
isp
=
isp
;
}
@JsonProperty
(
"country_id"
)
public
String
getCountryId
()
{
return
countryId
;
}
@JsonProperty
(
value
=
"country_id"
)
public
void
setCountryId
(
String
countryId
)
{
this
.
countryId
=
countryId
;
}
@JsonProperty
(
"area_id"
)
public
String
getAreaId
()
{
return
areaId
;
}
@JsonProperty
(
value
=
"area_id"
)
public
void
setAreaId
(
String
areaId
)
{
this
.
areaId
=
areaId
;
}
@JsonProperty
(
"region_id"
)
public
String
getRegionId
()
{
return
regionId
;
}
@JsonProperty
(
value
=
"region_id"
)
public
void
setRegionId
(
String
regionId
)
{
this
.
regionId
=
regionId
;
}
@JsonProperty
(
"city_id"
)
public
String
getCityId
()
{
return
cityId
;
}
@JsonProperty
(
value
=
"city_id"
)
public
void
setCityId
(
String
cityId
)
{
this
.
cityId
=
cityId
;
}
@JsonProperty
(
"county_id"
)
public
String
getCountyId
()
{
return
countyId
;
}
@JsonProperty
(
value
=
"county_id"
)
public
void
setCountyId
(
String
countyId
)
{
this
.
countyId
=
countyId
;
}
@JsonProperty
(
"isp_id"
)
public
String
getIspId
()
{
return
ispId
;
}
@JsonProperty
(
value
=
"isp_id"
)
public
void
setIspId
(
String
ispId
)
{
this
.
ispId
=
ispId
;
}
}
ajb-car-utils/src/main/java/com/ajb/common/utils/string/IDcardValidator.java
View file @
744bf4ee
ajb-car-utils/src/main/java/com/ajb/common/utils/string/IpToAddress.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
common
.
utils
.
string
;
public
class
IpToAddress
{
private
String
code
;
private
Data
data
;
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
Data
getData
()
{
return
data
;
}
public
void
setData
(
Data
data
)
{
this
.
data
=
data
;
}
}
ajb-car-utils/src/main/java/com/ajb/common/utils/string/JsonUtil.java
View file @
744bf4ee
ajb-car-utils/src/main/java/com/ajb/common/utils/string/StringUtil.java
View file @
744bf4ee
ajb-car-utils/src/main/java/com/ajb/common/utils/string/XmlUtil.java
View file @
744bf4ee
ajb-car-vo/src/main/java/com/ajb/car/vo/quotation/QuotationRequestVO.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
car
.
vo
.
quotation
;
public
class
QuotationRequestVO
implements
java
.
io
.
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
/**
* 车架号
*/
private
String
frameNumber
;
/**
* 发动机号
*/
private
String
engineNumber
;
/**
* 注册日期
*/
private
String
firstRegistrationDate
;
/**
* 品牌型号
*/
private
String
brandModel
;
/**
* 车主姓名
*/
private
String
customerName
;
/**
* 身份证号
*/
private
String
customerCert
;
/**
* 手机号
*/
private
String
customerMobile
;
public
String
getCustomerMobile
()
{
return
customerMobile
;
}
public
void
setCustomerMobile
(
String
customerMobile
)
{
this
.
customerMobile
=
customerMobile
;
}
public
String
getCustomerCert
()
{
return
customerCert
;
}
public
void
setCustomerCert
(
String
customerCert
)
{
this
.
customerCert
=
customerCert
;
}
public
String
getCustomerName
()
{
return
customerName
;
}
public
void
setCustomerName
(
String
customerName
)
{
this
.
customerName
=
customerName
;
}
public
String
getBrandModel
()
{
return
brandModel
;
}
public
void
setBrandModel
(
String
brandModel
)
{
this
.
brandModel
=
brandModel
;
}
public
String
getFirstRegistrationDate
()
{
return
firstRegistrationDate
;
}
public
void
setFirstRegistrationDate
(
String
firstRegistrationDate
)
{
this
.
firstRegistrationDate
=
firstRegistrationDate
;
}
public
String
getEngineNumber
()
{
return
engineNumber
;
}
public
void
setEngineNumber
(
String
engineNumber
)
{
this
.
engineNumber
=
engineNumber
;
}
public
String
getFrameNumber
()
{
return
frameNumber
;
}
public
void
setFrameNumber
(
String
frameNumber
)
{
this
.
frameNumber
=
frameNumber
;
}
}
ajb-car-vo/src/main/java/com/ajb/car/vo/zhima/meta/VehicleModels.java
0 → 100644
View file @
744bf4ee
package
com
.
ajb
.
car
.
vo
.
zhima
.
meta
;
/**
* Auto-generated: 2018-08-08 10:22:33
*
* @author bejson.com (i@bejson.com)
* @website http://www.bejson.com/java2pojo/
*/
public
class
VehicleModels
{
private
String
modelNumber
;
private
String
standardName
;
private
String
vehicleCode
;
private
String
price
;
private
String
remark
;
private
String
brandName
;
private
String
vehicleAlias
;
private
String
seat
;
private
String
marketDate
;
private
String
englineDesc
;
private
String
vehicleHyName
;
public
String
getModelNumber
()
{
return
modelNumber
;
}
public
void
setModelNumber
(
String
modelNumber
)
{
this
.
modelNumber
=
modelNumber
;
}
public
String
getStandardName
()
{
return
standardName
;
}
public
void
setStandardName
(
String
standardName
)
{
this
.
standardName
=
standardName
;
}
public
String
getVehicleCode
()
{
return
vehicleCode
;
}
public
void
setVehicleCode
(
String
vehicleCode
)
{
this
.
vehicleCode
=
vehicleCode
;
}
public
String
getPrice
()
{
return
price
;
}
public
void
setPrice
(
String
price
)
{
this
.
price
=
price
;
}
public
String
getRemark
()
{
return
remark
;
}
public
void
setRemark
(
String
remark
)
{
this
.
remark
=
remark
;
}
public
String
getBrandName
()
{
return
brandName
;
}
public
void
setBrandName
(
String
brandName
)
{
this
.
brandName
=
brandName
;
}
public
String
getVehicleAlias
()
{
return
vehicleAlias
;
}
public
void
setVehicleAlias
(
String
vehicleAlias
)
{
this
.
vehicleAlias
=
vehicleAlias
;
}
public
String
getSeat
()
{
return
seat
;
}
public
void
setSeat
(
String
seat
)
{
this
.
seat
=
seat
;
}
public
String
getMarketDate
()
{
return
marketDate
;
}
public
void
setMarketDate
(
String
marketDate
)
{
this
.
marketDate
=
marketDate
;
}
public
String
getEnglineDesc
()
{
return
englineDesc
;
}
public
void
setEnglineDesc
(
String
englineDesc
)
{
this
.
englineDesc
=
englineDesc
;
}
public
String
getVehicleHyName
()
{
return
vehicleHyName
;
}
public
void
setVehicleHyName
(
String
vehicleHyName
)
{
this
.
vehicleHyName
=
vehicleHyName
;
}
}
\ No newline at end of file
ajb-car-vo/src/main/java/com/ajb/car/vo/zhima/quotation/QuotationResponse.java
View file @
744bf4ee
...
...
@@ -5,6 +5,9 @@ import java.math.BigDecimal;
import
com.ajb.car.vo.common.CommonResult
;
public
class
QuotationResponse
{
private
String
errorCode
;
//错误代码,E01-入参校验不通过,E02-重复投保,S01-保存失败
private
String
errorMessage
;
//错误信息
private
Integer
total
=
0
;
private
BigDecimal
totalPremium
=
new
BigDecimal
(
0
);
private
BigDecimal
bzPremium
=
new
BigDecimal
(
0
);
...
...
@@ -69,4 +72,20 @@ public class QuotationResponse {
this
.
bzPremium
=
bzPremium
;
}
public
String
getErrorCode
()
{
return
errorCode
;
}
public
void
setErrorCode
(
String
errorCode
)
{
this
.
errorCode
=
errorCode
;
}
public
String
getErrorMessage
()
{
return
errorMessage
;
}
public
void
setErrorMessage
(
String
errorMessage
)
{
this
.
errorMessage
=
errorMessage
;
}
}
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