Commit 92744707 authored by xinglei's avatar xinglei

*)修改查询复议诉讼接口

parent bce33775
......@@ -30,6 +30,8 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.*;
import static java.util.regex.Pattern.compile;
@Service
public class InspectionServiceImpl implements InspectionService {
......@@ -171,18 +173,23 @@ public class InspectionServiceImpl implements InspectionService {
Object companyId = JsonValueUtils.getValueByKey(JSONObject.parse(JSON.toJSONString(agencyUserModel)), "companys", "companys.0.sequenceNbr");
Collection<CompanyModel> result = Privilege.companyClient.queryAgencyTree(null).getResult();
JSONObject jsonObject = getParentCompanyName(JSONArray.parseArray(JSONArray.toJSONString(result)), companyId);
if (!ValidationUtil.isEmpty(jsonObject)) {
String parentCompanyName = jsonObject.getString("companyName");
jsonObject.clear();
jsonObject.put("reconsiderOrgName", parentCompanyName + "/" + parentCompanyName.substring(0, parentCompanyName.indexOf("区") + 1) + "人民政府");
jsonObject.put("lawsuitOrgName", parentCompanyName.substring(0, parentCompanyName.indexOf("区") + 1) + "人员法院");
JSONObject jsonObject = findParentCompanyById(JSONArray.parseArray(JSONArray.toJSONString(result)), companyId);
String parentCompanyName = null;
String regionName = null;
if (!ValidationUtil.isEmpty(jsonObject)) { // 有上级单位
parentCompanyName = jsonObject.getString("companyName");
String selfCompanyName = JsonValueUtils.getValueByKey(JSONObject.parse(JSON.toJSONString(agencyUserModel)), "companys", "companys.0.companyName").toString();
regionName = StringUtils.getStrByPattern(selfCompanyName, compile("(.*?)省|(.*?)市|(.*?)区"));
} else {
jsonObject = new JSONObject();
jsonObject.put("reconsiderOrgName", null);
jsonObject.put("lawsuitOrgName", null);
jsonObject = findCompanyById(JSONArray.parseArray(JSONArray.toJSONString(result)), companyId);
parentCompanyName = jsonObject.getString("companyName");
regionName = StringUtils.getStrByPattern(parentCompanyName, compile("(.*?)省"));
}
jsonObject.clear();
jsonObject.put("reconsiderOrgName", parentCompanyName + "/" + regionName + "人民政府");
jsonObject.put("lawsuitOrgName", regionName + "人员法院");
return jsonObject;
}
......@@ -229,7 +236,7 @@ public class InspectionServiceImpl implements InspectionService {
return sql;
}
private static JSONObject getParentCompanyName(JSONArray companyModels, Object companyId) {
private static JSONObject findParentCompanyById(JSONArray companyModels, Object companyId) {
for (int i = 0; i < companyModels.size(); i++) {
JSONObject jsonObject = findCompanyById(companyModels.getJSONObject(i), companyId);
if (!ValidationUtil.isEmpty(jsonObject)) {
......@@ -239,6 +246,16 @@ public class InspectionServiceImpl implements InspectionService {
return null;
}
private static JSONObject findCompanyById(JSONArray companyModels, Object companyId) {
for (int i = 0; i < companyModels.size(); i++) {
JSONObject jsonObject = findCompanyById(companyModels.getJSONObject(i), companyId);
if (!ValidationUtil.isEmpty(jsonObject)) {
return findCompanyById(companyModels.getJSONObject(i), jsonObject.getString("sequenceNbr"));
}
}
return null;
}
private static JSONObject findCompanyById(JSONObject treeNode, Object companyId) {
if (treeNode.getString("sequenceNbr").equals(String.valueOf(companyId))) {
return treeNode;
......
......@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.tzs.biz.utils;
import java.util.Map;
import java.util.StringJoiner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @Author: xl
......@@ -21,4 +23,12 @@ public class StringUtils {
public static String str2sqlValue(String str){
return "'" + str + "'";
}
public static String getStrByPattern(String str, Pattern reg){
Matcher mat = reg.matcher(str);
while (mat.find()) {
return mat.group(0);
}
return "";
}
}
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