Commit 3105fbe1 authored by 5743's avatar 5743

机易查初版框架性开发提交v1.0

parent 5eb17a31
...@@ -222,7 +222,12 @@ ...@@ -222,7 +222,12 @@
<artifactId>commons-codec</artifactId> <artifactId>commons-codec</artifactId>
<version>1.10</version> <version>1.10</version>
</dependency> </dependency>
<!-- 机易查接口限流使用 -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>29.0-jre</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
......
package com.hand.hls.hlcm.hlinteface.controllers;
import com.alibaba.fastjson.JSONObject;
import com.hand.hap.system.controllers.BaseController;
import leaf.database.service.DatabaseServiceFactory;
import leaf.utils.ObjectRegistryHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import com.google.common.util.concurrent.RateLimiter;
import java.util.List;
import leaf.database.service.BusinessModelService;
import uncertain.composite.CompositeMap;
import java.io.IOException;
@Controller
public class JYCInterfaceController extends BaseController {
private static final RateLimiter rateLimiter = RateLimiter.create(1.0); // 每秒允许1个请求
@RequestMapping(value = "/wjflwar2/getEquStatus")
@ResponseBody
public JSONObject getEquStatus(@RequestParam(value = "equNo",required = true) String equNo,
@RequestParam(value = "type",required = true) String type,
@RequestParam(value = "reqClientIp",required = true) String reqClientIp,
HttpServletResponse response) {
//机易查接口
JSONObject resultjson = new JSONObject();
if(rateLimiter.tryAcquire()){
try {
DatabaseServiceFactory dsf = ObjectRegistryHolder.getInstanceOfType(DatabaseServiceFactory.class);
String queryBm = "cont.jyc_equno_query";
CompositeMap context = new CompositeMap();
CompositeMap param = new CompositeMap();
Boolean existsFlag = false;
if (equNo != null) {
param.put("machine_number", equNo);
}
BusinessModelService bms = dsf.getModelService(queryBm, context);
CompositeMap result = bms.queryAsMap(param);
if (result != null) {
List<CompositeMap> valueList = result.getChilds();
if (valueList != null) {
for (CompositeMap child : valueList) {
if (child == null) {
continue;
}
Long existcont = child.getLong("existcont");
if (existcont > 0) {
existsFlag = true;
}
}
}
}
if (existsFlag) {
resultjson.put("message", "查得");
} else {
resultjson.put("message", "未查得");
}
}catch(Exception e){
resultjson.put("message", "接口故障");
}
}else{
resultjson.put("message","接口次数超出限制");
}
return resultjson;
}
}
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
<http security="none" pattern="/modules/interface/INTERFACE_WX/wx_update_trailer_result.lsc"/> <http security="none" pattern="/modules/interface/INTERFACE_WX/wx_update_trailer_result.lsc"/>
<http security="none" pattern="/modules/interface/INTERFACE_WX/get_wx_trailer_Info.lsc"/> <http security="none" pattern="/modules/interface/INTERFACE_WX/get_wx_trailer_Info.lsc"/>
<http security="none" pattern="/modules/interface/INTERFACE_WX/get_wx_usedcar_Info.lsc"/> <http security="none" pattern="/modules/interface/INTERFACE_WX/get_wx_usedcar_Info.lsc"/>
<http security="none" pattern="/wjflwar2/getEquStatus"/>
<http security="none" pattern="/contract/signature/**"/> <http security="none" pattern="/contract/signature/**"/>
<http security="none" pattern="/jacob/**"/> <http security="none" pattern="/jacob/**"/>
<!--<http security="none" pattern="/**/*.lsc"/>--> <!--<http security="none" pattern="/**/*.lsc"/>-->
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: lpc 9874
$Date: 2017/11/21 9:39:12
$Revision: 1.0
$Purpose:
-->
<bm:model xmlns:s="leaf.plugin.script" xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select count(1) existcont from prj_project_lease_item li where li.machine_number=${@machine_number}
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="existcont" databaseType="NUMBER" datatype="java.lang.Long"/>
</bm:fields>
</bm:model>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment