Commit 1a410f85 authored by 5743's avatar 5743

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

parent 631fa897
......@@ -10,6 +10,8 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import com.google.common.util.concurrent.RateLimiter;
import java.util.Arrays;
import java.util.List;
import leaf.database.service.BusinessModelService;
import uncertain.composite.CompositeMap;
......@@ -18,51 +20,101 @@ import java.io.IOException;
public class JYCInterfaceController extends BaseController {
private static final RateLimiter rateLimiter = RateLimiter.create(1.0); // 每秒允许1个请求
private static final String IP_LIMIT="39.97.244.233,39.98.188.246";
private static final String WJ="wj";
private static final String BM_PATH="cont.jyc_equno_query" ;
private static final String WJFL_FIELD="WJFL" ;
public boolean checkInterfacePara(String equNo,String type,String reqClientIp,JSONObject resultjson){
String[] ipLimit = IP_LIMIT.split(",");
if( equNo == null || equNo.isEmpty()||type == null || type.isEmpty()||reqClientIp == null || reqClientIp.isEmpty()){
resultjson.put("JYCResponseBody",null);
resultjson.put("ResponseCode","02");
resultjson.put("ResponseMsg","交易异常,入参缺少必填字段!");
return false;
}
if(!type.equals(WJ)){
resultjson.put("JYCResponseBody",null);
resultjson.put("ResponseCode","05");
resultjson.put("ResponseMsg","查询渠道不正确!");
return false;
}
if(!Arrays.asList(ipLimit).contains(reqClientIp)){
resultjson.put("JYCResponseBody",null);
resultjson.put("ResponseCode","04");
resultjson.put("ResponseMsg","客户实际IP不在自名单内!");
return false;
}
return true;
}
@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,
public JSONObject getEquStatus(@RequestParam(value = "equNo") String equNo,
@RequestParam(value = "type") String type,
@RequestParam(value = "reqClientIp") 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) {
boolean checkFlag= checkInterfacePara(equNo,type,reqClientIp,resultjson);
if(checkFlag) {
DatabaseServiceFactory dsf = ObjectRegistryHolder.getInstanceOfType(DatabaseServiceFactory.class);
CompositeMap context = new CompositeMap();
CompositeMap param = new CompositeMap();
Boolean existsFlag = false;
if (equNo != null) {
param.put("machine_number", equNo);
}
BusinessModelService bms = dsf.getModelService(BM_PATH, context);
CompositeMap result = bms.queryAsMap(param);
if (result != null) {
List<CompositeMap> valueList = result.getChilds();
if (valueList != null) {
if(valueList.size()>0){
existsFlag = true;
CompositeMap child=valueList.get(0);
JSONObject JYCResponseBody= new JSONObject();
JYCResponseBody.put("equNm",child.getString("equnm"));
JYCResponseBody.put("brandName",child.getString("brandname"));
JYCResponseBody.put("equMdl",child.getString("equmdl"));
JYCResponseBody.put("vinNo",child.getString("vinno"));
JYCResponseBody.put("machineNo",child.getString("machineno"));
JYCResponseBody.put("status",child.getString("status"));
JYCResponseBody.put("platform",WJFL_FIELD);
resultjson.put("JYCResponseBody",JYCResponseBody);
resultjson.put("ResponseCode","01");
resultjson.put("ResponseMsg","交易正常");
}
/*for (CompositeMap child : valueList) {
existsFlag = true;
if (child == null) {
continue;
}
Long existcont = child.getLong("existcont");
if (existcont > 0) {
}
}*/
}
}
}
if (existsFlag) {
resultjson.put("message", "查得");
} else {
resultjson.put("message", "未查得");
if (!existsFlag) {
resultjson.put("JYCResponseBody",null);
resultjson.put("ResponseCode","03");
resultjson.put("ResponseMsg","未查到该车架号/整车编号对应信息");
}
}
}catch(Exception e){
resultjson.put("message", "接口故障");
resultjson.put("JYCResponseBody",null);
resultjson.put("ResponseCode","06");
resultjson.put("ResponseMsg","接口故障!"+e.getMessage());
}
}else{
resultjson.put("message","接口次数超出限制");
resultjson.put("JYCResponseBody",null);
resultjson.put("ResponseCode","06");
resultjson.put("ResponseMsg","接口1秒内查询次数超出限制!");
}
return resultjson;
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: lpc 9874
$Date: 2017/11/21 9:39:12
$Revision: 1.0
$Purpose:
$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}
select t2.equnm,
t2.brandname,
t2.equmdl,
t2.vinno,
t2.machineno,
t2.status
from (select t1.*
from (select li.LEASE_NAME equnm,
li.BRAND_VALUE brandname,
li.PATTERN equmdl,
nvl(li.machine_number, li.machine_number_70) vinno,
null machineno,
'1' status,
p.creation_date
from prj_project p, prj_project_lease_item li
where p.project_status not in ('CLOSED', 'CONTRACT_CREATED')
and p.project_id = li.project_id
and p.division != '95'
and (li.machine_number=${@machine_number} or li.machine_number_70=${@machine_number})
union
select li.LEASE_NAME equnm,
li.BRAND_VALUE brandname,
li.PATTERN equmdl,
nvl(li.machine_number, li.machine_number_70) vinno,
null machineno,
CASE
WHEN CC.CONTRACT_STATUS IN
('REPUR', 'ET', 'TERMINATE') then
'3'
else
nvl((select '2'
from con_unearned_finance_income ci
where ci.contract_id = cc.contract_id
and rownum = 1),
'1')
end status,
cc.inception_of_lease creation_date
from con_contract cc, prj_project_lease_item li
where cc.project_id = li.project_id
and cc.data_class = 'NORMAL'
and cc.contract_status not in
('RESCIND', 'CANCEL', 'CLOSED')
and cc.division != '95'
and (li.machine_number=${@machine_number} or li.machine_number_70=${@machine_number})
union
select lil.ASSET_NAME equnm,
li.BRAND_VALUE brandname,
lil.SPECIFICATION equmdl,
lil.ASSET_NUM vinno,
null machineno,
'1' status,
p.creation_date
from prj_project p,
prj_project_lease_item li,
prj_project_lease_item_list lil
where p.project_status not in ('CLOSED', 'CONTRACT_CREATED')
and p.project_id = li.project_id
and li.project_lease_item_id = lil.project_lease_item_id
and p.division != '95'
and lil.ASSET_NUM=${@machine_number}
union
select lil.ASSET_NAME equnm,
li.BRAND_VALUE brandname,
lil.SPECIFICATION equmdl,
lil.ASSET_NUM vinno,
null machineno,
CASE
WHEN CC.CONTRACT_STATUS IN
('REPUR', 'ET', 'TERMINATE') then
'3'
else
nvl((select '2'
from con_unearned_finance_income ci
where ci.contract_id = cc.contract_id
and rownum = 1),
'1')
end status,
cc.inception_of_lease creation_date
from con_contract cc,
prj_project_lease_item li,
prj_project_lease_item_list lil
where cc.project_id = li.project_id
and cc.data_class = 'NORMAL'
and cc.contract_status not in
('RESCIND', 'CANCEL', 'CLOSED')
and li.project_lease_item_id = lil.project_lease_item_id
and cc.division != '95'
and lil.ASSET_NUM=${/@machine_number}
) t1
order by nvl(t1.creation_date, to_date('2000-01-01', 'yyyy-mm-dd')) desc) t2
where rownum = 1
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="existcont" databaseType="NUMBER" datatype="java.lang.Long"/>
<bm:field name="equnm" databaseType="VARCHAR2" datatype="java.lang.String"/>
<bm:field name="brandname" databaseType="VARCHAR2" datatype="java.lang.String"/>
<bm:field name="equmdl" databaseType="VARCHAR2" datatype="java.lang.String"/>
<bm:field name="vinno" databaseType="VARCHAR2" datatype="java.lang.String"/>
<bm:field name="machineno" databaseType="VARCHAR2" datatype="java.lang.String"/>
<bm:field name="status" databaseType="VARCHAR2" datatype="java.lang.String"/>
</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