2020-08-04 14:26:26 +08:00

891 lines
37 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.tenwa.httpclient.controller;
import java.io.File;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.regex.Pattern;
import com.tenwa.httpclient.PyPafUtils;
import com.tenwa.httpclient.pypafhtml.PyHtmlCreate;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.dom4j.tree.DefaultAttribute;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.amarsoft.are.util.StringFunction;
import com.amarsoft.awe.Configure;
import com.amarsoft.awe.control.model.Page;
import com.amarsoft.awe.util.ASResultSet;
import com.amarsoft.awe.util.SqlObject;
import com.amarsoft.awe.util.Transaction;
import com.amarsoft.dict.als.manage.CodeManager;
import com.amarsoft.dict.als.object.Item;
import com.tenwa.comm.exception.BusinessException;
import com.tenwa.httpclient.HttpClientUtil;
import com.tenwa.httpclient.PyUtils;
import com.tenwa.httpclient.resources.BigDataPropertiesUtil;
import com.tenwa.reckon.util.UUIDUtil;
import com.tenwa.util.SerialNumberUtil;
public class BigDataController {
public String getDataApplyId(Page CurPage, String type, Transaction Sqlca) throws Exception {
String count = BigDataPropertiesUtil.get("count");
String sql = "select max(id) applyid, count(1) cou from bigdata_" + type + " where fullname='"+CurPage.getParameter("fullName")
+"' and fullcertId='"+CurPage.getParameter("fullcertId")+"' and fullphone='"+CurPage.getParameter("fullphone")+"' and {keyword} group by {gkeyword}";
StringBuffer keyword = new StringBuffer("");
StringBuffer gkeyword = new StringBuffer("");
String FlowNo = "";
for(int i = 1; i <= 5; i ++) {
String key = BigDataPropertiesUtil.get("keyword" + i);
String keyValue = CurPage.getParameter(key);
FlowNo = CurPage.getParameter("FlowNo");
if(key == null || keyValue == null) {
continue;
}
if(keyword.length() != 0) {
keyword.append(" and ");
gkeyword.append(",");
}
keyword.append("keyword").append(i).append("='").append(keyValue).append("'");
gkeyword.append("keyword").append(i);
}
if("ExceedTimLlimitApply".equals(FlowNo)&&keyword.length() != 0 ){
keyword.append(" and keyword3").append("='").append(FlowNo).append("'");
}else{
keyword.append(" and keyword3 is null");
}
sql = sql.replaceAll("\\{keyword\\}", keyword.length() == 0 ? "" : keyword.toString()).replaceAll("\\{gkeyword\\}", gkeyword.length() == 0 ? "" : gkeyword.toString());
System.out.println("======================sql========================================================");
System.out.println("======================"+sql+"========================================================");
System.out.println("======================sql========================================================");
ASResultSet rs = Sqlca.getASResultSet(new SqlObject(sql));
String result = "";
if(rs.next()) {
result = "true@" + rs.getString("applyid") + (rs.getString("cou").equals(count) ? "@done" : "@" + rs.getString("cou"));
} else {
result = "false";
}
System.out.println("======================result========================================================");
System.out.println("======================"+result+"========================================================");
System.out.println("======================result========================================================");
return result;
}
public String getAndSavePengyuanData(Map<String, String> params, String table, Transaction Sqlca, String actionType, String applyId, Page CurPage) throws Exception {
return this.getAndSavePengyuanData(params, table, Sqlca, actionType, applyId, CurPage, null);
}
public String getAndSavePengyuanData(Map<String, String> params, String table, Transaction Sqlca, String actionType, String applyId, Page CurPage, Map<String, String> id) throws Exception {
String type = "html";
String htmlFile = "";
System.out.println("------------------<2D><>Ԫ("+table+")<29><>ȡʱ<C8A1><CAB1>----------------------");
System.out.println("");
System.out.println("");
System.out.println("------------------"+StringFunction.getTodayNow()+"----------------------");
System.out.println("");
System.out.println("");
System.out.println("------------------<2D><>Ԫ("+table+")<29><>ȡʱ<C8A1><CAB1>----------------------");
if("GET".equals(actionType)) {
if(id != null) {
id.put("applyId", applyId);
}
htmlFile = Sqlca.getString(new SqlObject("select html_data from bigdata_" + table + " where id = '" + applyId + "'"));
return htmlFile == null ? "" : htmlFile;
}
Connection conn = Sqlca.getConnection(Sqlca);
@SuppressWarnings("deprecation")
Configure configure = Configure.getInstance();
String fileSavePath = configure.getParameter("FileSavePath") + "/" + "pengyuan" + "/";
String FlowNo = CurPage.getParameter("FlowNo");
String fullcardNo = CurPage.getParameter("fullcardNo");
if(fullcardNo==null||"".equals(fullcardNo)){fullcardNo="default";}
String queryCondition = HttpClientUtil.getQueryCondition(params);
if(!"pengyuan_af".equals(table)){
System.out.println("==========<3D><><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD>˷<EFBFBD><CBB7><EFBFBD>թ<EFBFBD>ӿ<EFBFBD>=====================table=<3D><>pengyuan_af<61><66>or "+ table);
System.out.println("==================" + table + "@" + type + "<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>====================");
String result = this.getQueryReport(params, type,CurPage.getAttribute("SubjectId").toString());
System.err.println(result);
System.out.println("==================" + table + "@" + type + "<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>====================");
try{
htmlFile = HttpClientUtil.queryReport(result, type, fileSavePath, applyId);
if(id != null) {
id.put("applyId", applyId);
}
//<2F>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>¼<EFBFBD><C2BC><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>Ϣ
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("insert into bigdata_" + table + "_log (id, apply_id, type, html_url, html_param, inputuserid, inputorgid, inputtime,fullName,fullcertId,fullphone,fullcardNo)"
+ " values(REPLACE(UUID(),'-',''), ?, 'apply', ?, ?, ?, ?, ? ,?, ?, ?,? )");
ps.setString(1, applyId);
ps.setString(2, BigDataPropertiesUtil.get("pengyuanUrl"));
ps.setString(3, queryCondition + "," + BigDataPropertiesUtil.get("user") + "," + BigDataPropertiesUtil.get("password") + "," + type);
ps.setString(4, CurPage.getUser().getUserID());
ps.setString(5, CurPage.getUser().getOrgID());
ps.setString(6, StringFunction.getTodayNow());
ps.setString(7, CurPage.getParameter("fullName"));
ps.setString(8, CurPage.getParameter("fullcertId"));
ps.setString(9, CurPage.getParameter("fullphone"));
ps.setString(10, fullcardNo);
ps.execute();
} catch(Exception e) {
e.printStackTrace();
throw new BusinessException("<EFBFBD><EFBFBD><EFBFBD>ݴ洢ʧ<EFBFBD><EFBFBD>");
} finally {
if(ps != null) ps.close();
}
String html_data = Sqlca.getString(new SqlObject("select html_data from bigdata_" + table + " where id = '" + applyId + "'"));
PreparedStatement ps1 = null;
if("ExceedTimLlimitApply".equals(FlowNo)&&html_data != null){//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD><DAB0><EFBFBD><EFBFBD>ٴε<D9B4><CEB5><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>save״̬
ps1 = conn.prepareStatement("update bigdata_" + table + " set keyword3 = '"+FlowNo+"' where keyword1 = ? and keyword2 = ?");
ps1.setString(1, CurPage.getParameter("ProjectId"));
ps1.setString(2, CurPage.getParameter("CustId"));
ps1.execute();
htmlFile = html_data;
if(ps != null) ps1.close();
return htmlFile;
}
if(html_data != null) {
htmlFile = html_data;
return htmlFile;
}
} catch(Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
}
}else {
System.out.println("====================<3D><><EFBFBD>˷<EFBFBD><CBB7><EFBFBD>թ<EFBFBD><D5A9>HTML<4D><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>ӿڻ<D3BF>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>====================");
}
type = "xml";
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("update bigdata_" + table + "_log set " + type + "_url = ?, " + type + "_param = ? where apply_id = ?");
ps.setString(1, BigDataPropertiesUtil.get("pengyuanUrl"));
ps.setString(2, queryCondition + "," + BigDataPropertiesUtil.get("user") + "," + BigDataPropertiesUtil.get("password") + "," + type);
ps.setString(3, applyId);
ps.execute();
} catch(Exception e) {
e.printStackTrace();
throw new BusinessException("<EFBFBD><EFBFBD><EFBFBD>ݴ洢ʧ<EFBFBD><EFBFBD>");
} finally {
if(ps != null) ps.close();
}
System.out.println("==================" + table + "@" + type + "<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>====================");
String xmlResult = this.getQueryReport(params, type,CurPage.getAttribute("SubjectId").toString());
System.out.println("==================" + table + "@" + type + "<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>====================");
String xmlPath = HttpClientUtil.queryReport(xmlResult, type, fileSavePath + "xml" + File.separator + applyId + File.separator);
if("pengyuan_af".equals(table)){
htmlFile = PyHtmlCreate.createHtmlFile(xmlPath, fileSavePath);
}
savePengyuanData(applyId, xmlPath, table, conn);
StringBuffer keyword = new StringBuffer();
StringBuffer keywordValue = new StringBuffer();
for(int i = 1; i <= 5; i ++) {
String key = BigDataPropertiesUtil.get("keyword" + i);
String keyValue = CurPage.getParameter(key);
if(key == null || keyValue == null) {
continue;
}
if(keyword.length() != 0) {
keyword.append(",");
keywordValue.append(",");
}
keyword.append("keyword").append(i);
keywordValue.append("'").append(keyValue).append("'");
}
if("ExceedTimLlimitApply".equals(FlowNo)&&keyword.length() != 0){
keyword.append(",keyword3");
keywordValue.append(",'"+FlowNo+"'");
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>Ҫ<EFBFBD><D2AA>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if("ebank_af".equals(table)){
SqlObject sql_d = new SqlObject("delete from bigdata_ebank_af where fullcertId='"+CurPage.getParameter("fullcertId")+"'");
Sqlca.executeSQL(sql_d);
}
if(!"pengyuan_af".equals(table)){
htmlFile = htmlFile.split("@")[1];
}
SqlObject sql = new SqlObject(("insert into bigdata_" + table + " (id," + keyword.toString() + ",xml_data,html_data,"
+ "inputuserid,inputorgid,inputtime,fullName,fullcertId,fullphone,fullcardNo) values('" + applyId + "'," + keywordValue.toString() + ",'"
+ xmlResult + "','" + htmlFile + "','" + CurPage.getUserId() + "','" + CurPage.getUser().getOrgID() + "','" + StringFunction.getTodayNow() +"','"
+CurPage.getParameter("fullName")+"','"+CurPage.getParameter("fullcertId")+"','"+CurPage.getParameter("fullphone")+"','"+fullcardNo+"')").replaceAll(":", "<EFBFBD><EFBFBD>"));
sql.setDebugSql(sql.getDebugSql().replaceAll("<EFBFBD><EFBFBD>", ":"));
sql.setOriginalSql(sql.getOriginalSql().replaceAll("<EFBFBD><EFBFBD>", ":"));
sql.setRunSql(sql.getRunSql().replaceAll("<EFBFBD><EFBFBD>", ":"));
System.err.println("****************************<2A><>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>************************");
String insertsql =sql.getOriginalSql();
System.err.println(insertsql);
System.err.println("****************************<2A><>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>************************");
Sqlca.executeSQL(sql);
return htmlFile;
}
@SuppressWarnings({ "unchecked"})
public static void savePengyuanData(String applyId, String xmlPath, String type, Connection conn) throws Exception {
SAXReader reader = new SAXReader();
File file = new File(xmlPath);
Document document = reader.read(file);
Element root = document.getRootElement();
Map<String, String> otherFields = new HashMap<String, String>();
otherFields.put("APPLY_ID", applyId);
Statement stat = null;
try {
stat = conn.createStatement();
List<DefaultAttribute> rootAttribute = root.attributes();
JSONObject obj = new JSONObject();
String reportID = "";
String batNo = "";
List<String> stringFields = new ArrayList<String>();
stringFields.add("batNo");
stringFields.add("reportID");
Map<String, String> dateFields = new HashMap<String, String>();
dateFields.put("receiveTime", "yyyymmdd hh24:mi:ss");
dateFields.put("buildEndTime", "yyyy-mm-dd hh24:mi:ss");
for(DefaultAttribute el : rootAttribute) {
if("batNo".equals(el.getName())) {
batNo = el.getStringValue();
}
obj.put(el.getName(), el.getStringValue());
}
//<2F>洢cisReports
stat.execute(getInsertSql(obj, "bigdata_py_cis_report", null, otherFields, true, dateFields, stringFields));
otherFields.remove("ID");
otherFields.put("BAT_NO", batNo);
List<Element> cisReports = root.elements();
for(Element cisReport : cisReports) {
//<2F>洢cisReport
obj = new JSONObject();
List<DefaultAttribute> crAttributes = cisReport.attributes();
for(DefaultAttribute crAttribute : crAttributes) {
if("reportID".equals(crAttribute.getName())) {
reportID = crAttribute.getStringValue();
}
obj.put(crAttribute.getName(), crAttribute.getStringValue());
}
stat.execute(getInsertSql(obj, "bigdata_py_cis_report_list", null, otherFields, true, dateFields, stringFields));
otherFields.remove("ID");
otherFields.put("REPORTID", reportID);
//<2F>洢queryConditions
Element queryCondition = cisReport.element("queryConditions");
List<Element> items = queryCondition.elements("item");
for(Element item : items) {
obj = new JSONObject();
List<Element> subItem = item.elements();
for(Element si : subItem) {
obj.put(si.getName(), si.getTextTrim());
}
stat.execute(getInsertSql(obj, "bigdata_py_cis_query_condition", null, otherFields, true, dateFields, stringFields));
otherFields.remove("ID");
}
if("pengyuan_pr".equals(type)) {//<2F><><EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
JSONObject object = new JSONObject();
object.put("type", "table");
object.put("tableName", "bigdata_py_person_risk_assess");
List<String> fieldList = new ArrayList<String>();
fieldList.add("checkResult");
fieldList.add("riskType");
object.put("field", fieldList);
savePengyuanResultData(object, cisReport, "personRiskAssess", stat, otherFields, dateFields, stringFields);
}else if("ebank_af".equals(type)){//<2F><><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD>ѯ
//<2F>洢queryConditions
Element personBankCheckInfo = cisReport.element("personBankCheckInfo");
Element ebankitem = personBankCheckInfo.element("item");
if(ebankitem != null) {
Element ebankcondition = ebankitem.element("condition");
if(ebankcondition != null){
obj = new JSONObject();
List<Element> subItem = ebankcondition.elements();
for(Element si : subItem) {
obj.put(si.getName(), si.getTextTrim());
}
obj.put(ebankitem.element("status").getName(), ebankitem.element("status").getTextTrim());
stat.execute(getInsertSql(obj, "bigdata_py_ebank_condition", null, otherFields, true, dateFields, stringFields));
otherFields.remove("ID");
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>׼<EFBFBD>¼
Element ebankCondition = cisReport.element("personCardTransRecordInfo");
List<Element> ebankitems = ebankCondition.elements("item");
for(Element item : ebankitems) {
obj = new JSONObject();
List<Element> subItem = item.elements();
for(Element si : subItem) {
obj.put(si.getName(), si.getTextTrim());
}
stat.execute(getInsertSql(obj, "bigdata_py_ebank_record", null, otherFields, true, dateFields, stringFields));
otherFields.remove("ID");
}
} else if("pengyuan_af".equals(type)){//<2F><><EFBFBD>˷<EFBFBD><CBB7><EFBFBD>թ
PyPafUtils.savePafData(applyId, batNo, reportID, stat, cisReport);
}
}
} catch(Exception e) {
e.printStackTrace();
throw new BusinessException("<EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD>洢ʧ<EFBFBD><EFBFBD>");
} finally {
if(stat != null) stat.close();
}
}
@SuppressWarnings("unchecked")
public static void savePengyuanResultData(JSONObject dataType, Element parentElement, String elementName, Statement stat, Map<String, String> otherFields, Map<String, String> dateFields, List<String> stringFields) throws Exception {
Element element = parentElement.element(elementName);
if(element == null ){
return ;
}
JSONObject obj = new JSONObject();
List<DefaultAttribute> praAttributes = element.attributes();
for(DefaultAttribute praAttribute : praAttributes) {
obj.put(praAttribute.getName(), praAttribute.getStringValue().trim());
}
if(!obj.isEmpty()) {
stat.execute(getInsertSql(obj, "bigdata_py_result", null, otherFields, true, dateFields, stringFields));
otherFields.put("RESULT_ID", otherFields.remove("ID"));
}
savePengyuanResultSubTable(dataType, element, stat, otherFields, dateFields, stringFields);
otherFields.remove("RESULT_ID");
}
@SuppressWarnings("unchecked")
public static void savePengyuanResultSubTable(JSONObject dataType, Element parentElement, Statement stat, Map<String, String> otherFields, Map<String, String> dateFields, List<String> stringFields) throws SQLException {
if(dataType != null) {
JSONObject obj = null;
if("table".equals(dataType.get("type"))) {
List<String> fieldList = (List<String>)dataType.get("field");
obj = new JSONObject();
for(String field : fieldList) {
Element fieldElement = parentElement.element(field);
if(fieldElement != null) {
obj.put(fieldElement.getName(), fieldElement.getStringValue().trim());
}
}
if(!obj.isEmpty()) {
stat.execute(getInsertSql(obj, dataType.getString("tableName"), null, otherFields, true, dateFields, stringFields));
otherFields.remove("ID");
}
} else if("arrayTable".equals(dataType.get("type"))) {
List<String> fieldList = (List<String>)dataType.get("field");
List<Element> items = parentElement.elements("item");
if(items != null) {
for(Element el : items) {
obj = new JSONObject();
for(String field : fieldList) {
Element fieldElement = el.element(field);
if(fieldElement != null) {
obj.put(fieldElement.getName(), fieldElement.getStringValue().trim());
}
}
if(!obj.isEmpty()) {
stat.execute(getInsertSql(obj, dataType.getString("tableName"), null, otherFields, true, dateFields, stringFields));
otherFields.remove("ID");
}
}
}
} else {
JSONArray subTable = dataType.getJSONArray("subTable");
if(subTable != null) {
for(int i = 0; i < subTable.size(); i ++) {
JSONObject subObject = subTable.getJSONObject(i);
Element subElement = parentElement.element(subObject.getString("name"));
if(subElement != null) {
savePengyuanResultSubTable(subObject, subElement, stat, otherFields, dateFields, stringFields);
}
}
}
}
}
}
public static void saveDetail(JSONObject obj, String dataName, String tableName, String tableListName,
List<String> excludeFields, Map<String, String> detailOtherFields, Map<String, String> arrayOtherFields, Statement stat) throws SQLException {
excludeFields.clear();
excludeFields.add(dataName.toUpperCase());
stat.execute(getInsertSql(obj, tableName, excludeFields, detailOtherFields));
arrayOtherFields.put("PID", detailOtherFields.remove("ID"));
JSONArray array = obj.getJSONArray(dataName);
if(array != null) {
for(int k = 0; k < array.size(); k ++) {
stat.execute(getInsertSql(array.getJSONObject(k), tableListName, excludeFields, arrayOtherFields));
arrayOtherFields.remove("ID");
}
}
}
public static void saveDetailData(JSONObject obj, String dataName, String tableName, String tableListName,
List<String> excludeFields, Map<String, String> detailOtherFields, Map<String, String> arrayOtherFields, Statement stat) throws SQLException {
excludeFields.clear();
excludeFields.add(dataName.toUpperCase());
excludeFields.add("DATA");
stat.execute(getInsertSql(obj, tableName, excludeFields, detailOtherFields));
String pid = detailOtherFields.remove("ID");
JSONArray array = obj.getJSONArray(dataName);
List<String> dataExcludeField = new ArrayList<String>();
if(array != null) {
for(int k = 0; k < array.size(); k ++) {
arrayOtherFields.put("PID", pid);
JSONObject data = array.getJSONObject(k);
stat.execute(getInsertSql(data, tableListName, excludeFields, arrayOtherFields));
arrayOtherFields.put("PID", arrayOtherFields.remove("ID"));
JSONArray dataArray = data.getJSONArray("data");
if(dataArray == null) {
continue;
}
for(int i = 0; i < dataArray.size(); i ++) {
JSONObject daObj = new JSONObject();
daObj.put("data", dataArray.get(i));
stat.execute(getInsertSql(daObj, "bigdata_td_data", dataExcludeField, arrayOtherFields));
arrayOtherFields.remove("ID");
}
}
}
}
public static String getInsertSql(JSONObject obj, String tableName, List<String> excludeFields, Map<String, String> otherFields) {
return getInsertSql(obj, tableName, excludeFields, otherFields, true, null, null);
}
public static String getInsertSql(JSONObject obj, String tableName, List<String> excludeFields,
Map<String, String> otherFields, boolean isCheckNumber, Map<String, String> dateFields, List<String> stringFields) {
String sql = "INSERT INTO " + tableName.toUpperCase() + "({keys}) VALUES({values})";
String keys = "";
String values = "";
Set<Entry<String, Object>> fields = obj.entrySet();
if(fields.size() == 0) {
return "";
}
boolean flag = false;
String id = "";
for(Entry<String, Object> field : fields) {
String key = field.getKey();
if("ID".equals(key.toUpperCase())) {
id = (String)field.getValue();
flag = true;
}
Object value = field.getValue();
if(excludeFields != null && excludeFields.contains(key.toUpperCase())) {
continue;
}
if(keys.length() > 0) {
keys += ",";
values += ",";
}
keys += changeKey(key, true);;
if(value != null) {
String valueString = value + "";
if(isCheckNumber && isNumber(valueString)) {
if(stringFields != null && stringFields.contains(key)) {
values += changeStringToDate(key, valueString, dateFields);
} else {
values += valueString;
}
} else {
values += changeStringToDate(key, valueString, dateFields);
}
} else {
values += "''";
}
}
if(!otherFields.isEmpty()) {
for(Entry<String, String> otherField : otherFields.entrySet()) {
if(keys.length() > 0) {
keys += ",";
values += ",";
}
keys += otherField.getKey().toUpperCase();
values += "'" + otherField.getValue() + "'";
}
}
if(!flag) {
id = UUIDUtil.getUUID();
keys += ",ID";
values += ",'" + id + "'";
}
otherFields.put("ID", id);
sql = sql.replaceAll("\\{keys\\}", keys).replaceAll("\\{values\\}", values);
System.out.println("<><D6B4>]" + sql);
return sql;
}
public static boolean isNumber(String value) {
try {
new BigDecimal(value);
} catch(Exception e) {
return false;
}
return true;
}
public static String changeStringToDate(String key, String value, Map<String, String> dateFields) {
if(dateFields != null) {
for(Entry<String, String> dateField : dateFields.entrySet()) {
if(dateField.getKey().equals(key)) {
// return "DATE_FORMAT('" + value + "', '" + dateField.getValue() + "')";
return "'" + value + "'";
}
}
return "'" + value + "'";
}
return "'" + value + "'";
}
public static String changeKey(String key) {
return BigDataController.changeKey(key, false);
}
public static String changeKey(String key, boolean toUpperCase) {
String[] keys = key.split("");
boolean flag = false;
if(flag) {
if(toUpperCase) {
return key.toUpperCase();
} else {
return key;
}
}
key = "";
int lockField = -1;
ot : for(int k = 0; k < keys.length; k ++) {
if("".equals(keys[k]) || keys[k] == null) {
continue;
}
if(lockField == k) {
key += keys[k].toLowerCase();
lockField = -1;
continue;
}
if(keys[k].matches("[0-9]") && lockField == -1) {
int i = k + 1;;
for(; i < keys.length; i ++) {
if("p".equals(keys[i])) {
break;
}
if(Character.isUpperCase(keys[i].charAt(0))) {
lockField = i;
key += "_" + keys[k];
continue ot;
}
}
}
if(k == keys.length -2 && "I".equals(keys[k]) && ("I".equals(keys[k + 1]) || "D".equals(keys[k + 1]))) {
key += keys[k].toLowerCase() + keys[k + 1].toLowerCase();
break;
} else if(Character.isUpperCase(keys[k].charAt(0))) {
key += "_" + keys[k].toLowerCase();
} else {
key += keys[k];
}
}
return toUpperCase ? key.toUpperCase() : key;
}
public String getQueryReport(Map<String, String> params, String type, String SubjectId) throws Exception {
System.out.println("========================<3D><>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>==================");
System.out.println(params);
String queryCondition = HttpClientUtil.getQueryCondition(params);
System.out.println(queryCondition);
Object[] para =null;
if("d989246c11c111eaaa0000163e0e11e6".equals(SubjectId)){
System.out.println("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾<EFBFBD><EFBFBD><EFBFBD>ýӿڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>id=d989246c11c111eaaa0000163e0e11e6");
para = new Object[]{
BigDataPropertiesUtil.get("t_userId"),
BigDataPropertiesUtil.get("t_password"),
queryCondition,
type};
}else //if("aa740e4111c111eaaa0000163e0e11e6".equals(SubjectId))
{
System.out.println("<EFBFBD><EFBFBD><EFBFBD>ڹ<EFBFBD>˾<EFBFBD><EFBFBD><EFBFBD>ýӿڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>id=aa740e4111c111eaaa0000163e0e11e6");
para = new Object[]{
BigDataPropertiesUtil.get("userId"),
BigDataPropertiesUtil.get("password"),
queryCondition,
type};
}
System.out.println(para);
System.out.println("========================<3D><>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>==================");
String result = "";
try{
if("d989246c11c111eaaa0000163e0e11e6".equals(SubjectId)){
System.out.println("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾<EFBFBD><EFBFBD><EFBFBD>ýӿڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>id=d989246c11c111eaaa0000163e0e11e6");
result = PyUtils.requestApi(
BigDataPropertiesUtil.get("t_pengyuanUrl")+BigDataPropertiesUtil.get("t_pengyuanServer"),
BigDataPropertiesUtil.get("t_methodType"),
para);
}else //if("aa740e4111c111eaaa0000163e0e11e6".equals(SubjectId))
{
System.out.println("<EFBFBD><EFBFBD><EFBFBD>ڹ<EFBFBD>˾<EFBFBD><EFBFBD><EFBFBD>ýӿڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>id=aa740e4111c111eaaa0000163e0e11e6");
result = PyUtils.requestApi(
BigDataPropertiesUtil.get("pengyuanUrl")+BigDataPropertiesUtil.get("pengyuanServer"),
BigDataPropertiesUtil.get("methodType"),
para);
}
System.out.println(result);
} catch(Exception e) {
e.printStackTrace();
throw new BusinessException("<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>");
}
return result;
}
public static Map<String, String> getMapCustomerInfoPerson(String flowunid, Transaction Sqlca) throws Exception {
String sql = " select p.mobile, "
+ " p.fullname, "
+ " p.certid, "
+ " ca.acc_number,"
+ " address.FULLADDRESS,"
+ " acl.itemname,"
+ " c.bankno "
+ " from lb_union_lessee_temp lb "
+ " left join CUSTOMER_PERSON_TEMP p "
+ " on p.customerid = lb.customer_id "
+ " and p.flowunid = lb.flowunid "
+ " left join customer_address_temp address "
+ " on address.customerid = p.customerid "
+ " left join Customer_Account_Temp ca "
+ " on lb.project_id = ca.project_id "
+ " and ca.flowunid = lb.flowunid "
+ " and ca.acc_info = 'Debit' "
+ " left join customer_cert_temp cert on cert.customerid=p.customerid and cert.flowunid=p.flowunid "
+ " left join code_library c on c.itemno=cert.certtype and c.codeno='CertType' "
+ " left join code_library acl on acl.itemno = address.RESIDENTCITY and acl.codeno='AreaCode' "
+ " where lb.flowunid = '"+flowunid+"' ";
ASResultSet rs = Sqlca.getASResultSet(new SqlObject(sql));
Map<String, String> MapParams = new HashMap<String, String>();
if(rs.next()) {
String fullname=rs.getString("fullname");
String certid=rs.getString("certid");
String mobile=rs.getString("mobile");
String acc_number=rs.getString("acc_number");
String bankno=rs.getString("bankno");
String fullAddress=rs.getString("FULLADDRESS");
String city = rs.getString("itemname");
city = city == null ? "" : city;
String regexp = "^[\u4e00-\u9fa5]+ʡ[\u4e00-\u9fa5]+<2B><>[\u4e00-\u9fa5]*$";
if(Pattern.matches(regexp, city)) {
city = city.substring(city.indexOf("ʡ") + 1, city.indexOf("<EFBFBD><EFBFBD>"));
}
MapParams.put("idNo", certid);
MapParams.put("idType", bankno == null ? "0" : bankno);
MapParams.put("name", fullname);
MapParams.put("mobileNo", mobile);
MapParams.put("address", fullAddress);
MapParams.put("cardNo", acc_number == null ? "0" : acc_number);
MapParams.put("cardNos", acc_number);
MapParams.put("email", "luojiankuaiyug@163.com");
MapParams.put("city", city);
}
return MapParams;
}
public static Map<String, String> getMapGuaranteeInfoPerson(String flowunid, String CustId, Transaction Sqlca) throws Exception {
String sql = " select lgut.assuror, cpt.mobile, cpt.fullname, cpt.certid, cat.fulladdress,acl.itemname "
+ " from LB_GUARANTEE_UNIT_TEMP lgut "
+ " left join CUSTOMER_PERSON_TEMP cpt "
+ " on cpt.customerid = lgut.assuror "
+ " and cpt.flowunid = lgut.flowunid "
+ " left join CUSTOMER_ADDRESS_TEMP cat "
+ " on cat.customerid = lgut.assuror "
+ " and cat.flowunid = lgut.flowunid "
+ " left join code_library acl on acl.itemno = cat.RESIDENTCITY and acl.codeno = 'AreaCode' "
+ " where lgut.flowunid = '"+flowunid+"' "
+ " and lgut.assuror = '"+CustId+"'";
ASResultSet rs = Sqlca.getASResultSet(new SqlObject(sql));
Map<String, String> MapParams = new HashMap<String,String>();
if(rs.next()) {
String fullname=rs.getString("fullname");
String certid=rs.getString("certid");
String mobile=rs.getString("mobile");
String fullAddress=rs.getString("fulladdress");
String city = rs.getString("itemname");
city = city == null ? "" : city;
String regexp = "^[\u4e00-\u9fa5]+ʡ[\u4e00-\u9fa5]+<2B><>[\u4e00-\u9fa5]*$";
if(Pattern.matches(regexp, city)) {
city = city.substring(city.indexOf("ʡ") + 1, city.indexOf("<EFBFBD><EFBFBD>"));
}
MapParams.put("idNo", certid);
MapParams.put("idType", "0");
MapParams.put("name", fullname);
MapParams.put("mobileNo", mobile);
MapParams.put("address", fullAddress);
MapParams.put("cardNo", "0");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><D0BF><EFBFBD>Ϣ
MapParams.put("cardNos", "0");
MapParams.put("email", "luojiankuaiyug@163.com");
MapParams.put("city", city);
}
return MapParams;
}
public String getCustomerInfoPerson(String flowunid, Transaction Sqlca) throws Exception {
String sql = " select p.mobile, "
+ " p.fullname, "
+ " p.certid, "
+ " ca.acc_number,"
+ " c.bankno "
+ " from lb_union_lessee_temp lb "
+ " left join CUSTOMER_PERSON_TEMP p "
+ " on p.customerid = lb.customer_id "
+ " and p.flowunid = lb.flowunid "
+ " left join customer_address_temp address "
+ " on address.customerid = p.customerid and address.flowunid = lb.flowunid "
+ " left join Customer_Account_Temp ca "
+ " on lb.project_id = ca.project_id "
+ " and ca.flowunid = lb.flowunid "
+ " and ca.acc_info = 'Debit' "
+ " left join customer_cert_temp cert on cert.customerid=p.customerid and cert.flowunid=p.flowunid "
+ " left join code_library c on c.itemno=cert.certtype and c.codeno='CertType' "
+ " where lb.flowunid = '"+flowunid+"' ";
ASResultSet rs = Sqlca.getASResultSet(new SqlObject(sql));
String result = "";
if(rs.next()) {
String fullname=rs.getString("fullname") ;
String certid=rs.getString("certid") ;
String mobile=rs.getString("mobile") ;
String acc_number=rs.getString("acc_number") ;
result = "true@" + fullname +"@"+ certid+"@"+mobile+"@"+acc_number;
} else {
result = "false";
}
return result;
}
public boolean checkData(String applyId, BizObject rule, Transaction tran, JSONObject object) throws Exception {
String bigDataType = rule.getAttribute("BIGDATATYPE").toString();
String ruleId = rule.getAttribute("ID").toString();
String ruleNumber = rule.getAttribute("RULENUMBER").toString();
String ruleFormula = rule.getAttribute("RULELOGIC").toString();
String ruleCompare = rule.getAttribute("RETURNRESULT").toString();
Item item = CodeManager.getItem("bigdata_rule", ruleNumber);
if(item == null) {
throw new BusinessException("δ<EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>");
}
String itemDescribe = item.getItemDescribe();
if(itemDescribe == null || "".equals(itemDescribe)) {
return false;
}
String tableName = itemDescribe.split("@")[0];
String field = itemDescribe.split("@")[1];
String value = "";
if("tongdun".equals(bigDataType)){
if("26221714".equals(ruleNumber)){
value = tran.getString("select " + field + " from " + tableName + " where rownum = 1 and apply_id = '" + applyId + "' and description like '%3<><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD>ƽ̨<C6BD><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%' ");
}else{
value = tran.getString("select " + field + " from " + tableName + " where rownum = 1 and apply_id = '" + applyId + "' and rule_id = '"+ruleCompare+"' ");
}
}else if("pengyuan_af".equals(bigDataType)){
if("subReportType(14227)".equals(ruleNumber)||"subReportType(14239)".equals(ruleNumber)){
value = tran.getString("select case when " + field + " > 0 then '<27><>' else '<27><>' end from " + tableName + " where rownum = 1 and apply_id = '" + applyId + "'");
}else{
value = tran.getString("select " + field + " from " + tableName + " where rownum = 1 and apply_id = '" + applyId + "'");
}
}else{
value = tran.getString("select " + field + " from " + tableName + " where rownum = 1 and apply_id = '" + applyId + "'");
}
object.put("APPLY_ID", applyId);
object.put("RULE_ID", ruleId);
object.put("OLDRESULT", ruleCompare);
object.put("NEWRESULT", value);
if(value == null || "".equals(value)) {
object.put("ISHIT", "0");
return false;
}
if("".equals(ruleCompare) || ruleCompare == null) {
object.put("ISHIT", "0");
return false;
}
switch(ruleFormula) {
case ">":
if(!isNumber(value) || !isNumber(ruleCompare)) {
throw new BusinessException("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƚ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD>");
}
if(new BigDecimal(value).compareTo(new BigDecimal(ruleCompare)) > 0) {
return true;
}
break;
case "=":
if(value.equals(ruleCompare)) {
return true;
}
break;
case "<":
if(!isNumber(value) || !isNumber(ruleCompare)) {
throw new BusinessException("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƚ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD>");
}
if(new BigDecimal(value).compareTo(new BigDecimal(ruleCompare)) < 0) {
return true;
}
break;
case "<>":
if(ruleCompare.split(",").length<2){
throw new BusinessException("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݹ<EFBFBD><EFBFBD>򷵻<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
if(!isNumber(value) || !isNumber(ruleCompare.split(",")[0]) || !isNumber(ruleCompare.split(",")[1])) {
throw new BusinessException("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƚ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD>");
}
if(new BigDecimal(value).compareTo(new BigDecimal(ruleCompare.split(",")[0])) >= 0 && new BigDecimal(value).compareTo(new BigDecimal(ruleCompare.split(",")[1])) <= 0) {
return true;
}
break;
}
object.put("ISHIT", "0");
return false;
}
public void getPengyuanAfData(Page CurPage, Transaction Sqlca, Map<String, String> applyIds) throws Exception {
String type = "";
String applyId = "";
String flowunid = CurPage.getParameter("ObjectNo");
String result = this.getDataApplyId(CurPage, "pengyuan_af", Sqlca);
if("false".equals(result)) {
JBOTransaction tx = JBOFactory.createJBOTransaction();
applyId = SerialNumberUtil.getPengyuanNumber(tx);
tx.commit();
type = "SAVE";
} else {
String[] res = result.split("@");
applyId = res[1];
type = "GET";
}
Map<String,String> params = new HashMap<String,String>(); //<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
String resultals = this.getCustomerInfoPerson(flowunid, Sqlca) ;
if(!"false".equals(resultals)){
String[] sReturn = resultals.split("@");
params.put("queryType","25136");
params.put("name",sReturn[1]);
params.put("documentNo",sReturn[2]);
params.put("phone",sReturn[3]);
params.put("queryReasonID","101");
params.put("subreportIDs","96043");
params.put("refID","");
}
Map<String, String> id = new HashMap<String, String>();
this.getAndSavePengyuanData(params, "pengyuan_af", Sqlca, type, applyId, CurPage, id);
applyIds.put("pengyuan_af", applyId);
}
}