Commit 6221af56 by liulianglang

协作单位字典

parent ff3ee8fd
......@@ -55,6 +55,9 @@ public class BladeConfiguration implements WebMvcConfigurer {
secureRegistry.excludePathPatterns("/tjpg/*");
secureRegistry.excludePathPatterns("/bbkwp/*");
secureRegistry.excludePathPatterns("/queryCodeByType");
secureRegistry.excludePathPatterns("/refreshQyxzCodeCache");
secureRegistry.excludePathPatterns("/queryQyxzCodeByType");
secureRegistry.excludePathPatterns("/reloadQyxzXzxtDict");
secureRegistry.excludePathPatterns("/whitelist/check");
secureRegistry.excludePathPatterns("/sysuser/zcinsertUserNew");
secureRegistry.excludePathPatterns("/qqzc/flow/getDzqqByAsjbhAndSjhCount");
......
......@@ -47,6 +47,88 @@ public class DictitemController {
return R.error();
}
}
@RequestMapping(value = "/queryQyxzCodeByType", method = RequestMethod.GET)
@ResponseBody
public R queryQyxzCodeByType(String type, String id, String startId, String yycj, String name, String codes, String grade) {
try {
if ("prev".equals(grade)) {
JSONObject jsonObject = getXzqyPreNodes(type, id);
return R.ok().data("data", jsonObject.getJSONArray("data"));
} else {
List<ZTreeNode> ZTreeNodeList = queryQyxzTypeCode(type, id, startId, yycj, name, codes);
return R.ok().data("rows", ZTreeNodeList);
}
} catch (Exception e) {
e.printStackTrace();
return R.error();
}
}
private JSONObject getXzqyPreNodes(String type, String code) {
JSONObject resultObj = new JSONObject();
List<Map<String, Object>> rtList = new ArrayList<>();
ZTreeNode curNode = null;
String pid = null;
List<ZTreeNode> siblingNodes;
while (!StringUtils.isEmpty(code)) {
curNode = getQyxzNodeByCode(type, code);
pid = curNode.getPId();
if (!StringUtils.isEmpty(pid)) {
siblingNodes = queryQyxzTypeCode(type, pid, null, null, null, null);
code = pid;
} else {
siblingNodes = queryQyxzTypeCode(type, null, null, null, null, null);
code = null;
}
Map<String, Object> map = new HashMap<>();
map.put("pid", pid);
map.put("items", siblingNodes);
rtList.add(map);
}
int index1 = 0;
int index2 = 0;
for (int i = rtList.size() - 1; i >= 0; i--) {
Map<String, Object> itemMap = rtList.get(i);
String parentid = (String) itemMap.get("pid");
JSONArray items = JSONArray.parseArray(JSONObject.toJSONString(itemMap.get("items")));
if (i == rtList.size() - 1) {
resultObj.put("data", items);
} else {
if (i == rtList.size() - 2) {
JSONArray lastArray = resultObj.getJSONArray("data");
for (int j = 0; j < lastArray.size(); j++) {
if (parentid.equals(lastArray.getJSONObject(j).getString("id"))) {
index1 = j;
lastArray.getJSONObject(j).put("children", items);
break;
}
}
}
if (i == rtList.size() - 3) {
JSONArray array2 = resultObj.getJSONArray("data").getJSONObject(index1).getJSONArray("children");
for (int k = 0; k < array2.size(); k++) {
if (parentid.equals(array2.getJSONObject(k).getString("id"))) {
index2 = k;
array2.getJSONObject(k).put("children", items);
break;
}
}
}
if (i == rtList.size() - 4) {
JSONArray array3 = resultObj.getJSONArray("data").getJSONObject(index1).getJSONArray("children").getJSONObject(index2).getJSONArray("children");
for (int m = 0; m < array3.size(); m++) {
if (parentid.equals(array3.getJSONObject(m).getString("id"))) {
index2 = m;
array3.getJSONObject(m).put("children", items);
break;
}
}
}
}
}
return resultObj;
}
private JSONObject getPreNodes(String type, String code) {
JSONObject resultObj = new JSONObject();
......@@ -121,7 +203,13 @@ public class DictitemController {
}
return zTreeNodeList.get(0);
}
private ZTreeNode getQyxzNodeByCode(String type, String code) {
List<ZTreeNode> zTreeNodeList = dicItemService.queryQyxzCodes(type, code, null);
if (zTreeNodeList == null || zTreeNodeList.size() < 1) {
return new ZTreeNode();
}
return zTreeNodeList.get(0);
}
@RequestMapping(value = "/queryTypeCode", method = RequestMethod.GET)
@ResponseBody
public List<ZTreeNode> queryTypeCode(String type, String id, String startId, String yycj, String name, String codes) {
......@@ -161,7 +249,45 @@ public class DictitemController {
ZTreeNodeList = Sort(ZTreeNodeList);
return ZTreeNodeList;
}
@RequestMapping(value = "/queryQyxzTypeCode", method = RequestMethod.GET)
@ResponseBody
public List<ZTreeNode> queryQyxzTypeCode(String type, String id, String startId, String yycj, String name, String codes) {
List<ZTreeNode> ZTreeNodeList = new ArrayList<ZTreeNode>();
if (type != null && !"".equals(type)) {
if (type.equals("CODE_JY")) {//添加警员查询的字典
ZTreeNodeList = dicItemService.queryTypeUsercode(startId, name);//查询警员字典
} else {
if (codes != null && !"".equals(codes)) {
ZTreeNodeList = dicItemService.queryCodes(type, codes, name);
} else {
// 立案单位走这条路
ZTreeNodeList = dicItemService.queryQyxzTypeCode(type, id, startId, yycj, name);
}
}
}
if("CODE_QGUNIT".equals(type) && StringUtils.isEmpty(id)){
List<ZTreeNode> bjdwList = new ArrayList<>();
List<ZTreeNode> sjdwList = new ArrayList<>();
for (ZTreeNode node : ZTreeNodeList){
String codestr = node.getId();
if (codestr.startsWith("01")){
bjdwList.add(node);
}else {
sjdwList.add(node);
}
}
bjdwList = Sort(bjdwList);
sjdwList = Sort(sjdwList);
sjdwList.addAll(bjdwList);
return sjdwList;
}
ZTreeNodeList = Sort(ZTreeNodeList);
return ZTreeNodeList;
}
private List<ZTreeNode> Sort(List<ZTreeNode> ZTreeNodeList) {
Collections.sort(ZTreeNodeList, new Comparator<ZTreeNode>() {
@Override
......@@ -232,6 +358,25 @@ public class DictitemController {
}
/**
* 根据类别重新刷新redis缓存
*/
@RequestMapping("/refreshQyxzCodeCache")
@ResponseBody
public R refreshQyxzCodeCache(String type) {
String result = "";
try {
importCode.insertQyxzIntoRedis(type);
type = (null == type || "null" == type) ? "" : type;
result = "字典" + type + "成功加入缓存";
return R.ok().data("result", result);
} catch (Exception e) {
e.printStackTrace();
result = "刷新字典发生异常!" + "\n" + e.getMessage();
return R.error(result);
}
}
@RequestMapping(value = "/reloadXzxtDict", method = RequestMethod.GET)
@ResponseBody
public R reloadXzxtDict(String type) {
......@@ -253,6 +398,27 @@ public class DictitemController {
return R.error(e.getMessage());
}
}
@RequestMapping(value = "/reloadQyxzXzxtDict", method = RequestMethod.GET)
@ResponseBody
public R reloadQyxzXzxtDict(String type) {
try {
List<String> types;
if (StringUtils.isEmpty(type)) {
types = importCode.getAllTypes(null);
} else if ("SHCE".equals(type)) {
types = importCode.getAllTypes("SHCE");
} else {
types = Arrays.asList(type.split(","));
}
for (String str : types) {
getQyxzAllDicJson(str);
}
return R.ok();
} catch (Exception e) {
e.printStackTrace();
return R.error(e.getMessage());
}
}
//生成对应groupid的字典的json文件
private void getAllDicJson(String type) throws Exception {
......@@ -297,6 +463,51 @@ public class DictitemController {
}
}
//生成对应groupid的字典的json文件
private void getQyxzAllDicJson(String type) throws Exception {
System.out.println("type===========" + type);
String jsonStr = "";
JSONObject jsonObject = new JSONObject();
List<ZTreeNode> ZTreeNodeList = dicItemService.queryQyxzTypeCode(type, null, null, null, null);
ZTreeNodeList = Sort(ZTreeNodeList);
//拿到所有父节点,通过父节点去查询所有的子节点,然后生成json串
for (int i = 0; i < ZTreeNodeList.size(); i++) {
ZTreeNode zTreeNode1 = ZTreeNodeList.get(i);
//判断是否为父节点
if (zTreeNode1.isIsParent()) {//为父节点拿到子节点
List<ZTreeNode> ZTreeNodeChildrenList1 = dicItemService.queryQyxzTypeCode(type, zTreeNode1.getId(), null, null, null);
getqyxzZdList(ZTreeNodeChildrenList1, type);
zTreeNode1.setChildren(ZTreeNodeChildrenList1);
}
}
jsonObject.put("success", true);
jsonObject.put("code", 200);
jsonObject.put("message", "成功");
Map<String, Object> dataMap = new HashMap();
dataMap.put("rows", ZTreeNodeList);
jsonObject.put("data", dataMap);
jsonStr = JSONObject.toJSONString(jsonObject, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue,
SerializerFeature.WriteDateUseDateFormat);
try {
String filePath = jsonPath + File.separator;
File file = new File(filePath);
if (!file.exists()) {
file.mkdir();
}
String fileName = filePath + type + ".json";
String encoding = "utf-8";
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(fileName), encoding));
out.write(jsonStr); // \r\n即为换行
out.flush(); // 把缓存区内容压入文件
out.close(); // 最后记得关闭文件
} catch (IOException e) {
throw new IOException(e);
}
}
public void getZdList(List<ZTreeNode> ZTreeNodeChildrenList, String type) {
if (ZTreeNodeChildrenList != null && ZTreeNodeChildrenList.size() > 0) {
ZTreeNodeChildrenList = Sort(ZTreeNodeChildrenList);
......@@ -311,4 +522,20 @@ public class DictitemController {
}
}
}
public void getqyxzZdList(List<ZTreeNode> ZTreeNodeChildrenList, String type) {
if (ZTreeNodeChildrenList != null && ZTreeNodeChildrenList.size() > 0) {
ZTreeNodeChildrenList = Sort(ZTreeNodeChildrenList);
for (int t = 0; t < ZTreeNodeChildrenList.size(); t++) {
ZTreeNode zTreeNode = ZTreeNodeChildrenList.get(t);
if (zTreeNode.isIsParent()) {
List<ZTreeNode> ZTreeNodeChildrenList1 = dicItemService.queryQyxzTypeCode(type, zTreeNode.getId(), null, null, null);
ZTreeNodeChildrenList1 = Sort(ZTreeNodeChildrenList1);
zTreeNode.setChildren(ZTreeNodeChildrenList1);
getqyxzZdList(ZTreeNodeChildrenList1, type);
}
}
}
}
}
......@@ -14,6 +14,8 @@ import java.util.Map;
public interface DictitemMapper {
List<SysDictitem> findCodeAllByType(String value);
List<SysDictitem> findQyxzCodeAllByType(String value);
List<User> queryAllUnitUser(Map m);
List<String> getAllTypes(@Param(value = "type") String type);
......
......@@ -40,6 +40,35 @@
order by code asc
</select>
<select id="findQyxzCodeAllByType" parameterType="java.lang.String" resultType="org.springblade.modules.system.entity.SysDictitem">
select distinct
id,
isparent,
groupid,
code ,
name,
groupname,
pid,
description,
yycj1,
yycj2,
yycj3,
yycj4,
yycj5,
yycj6,
yycj7,
yycj8,
yycj9,
startcode,
endcode
from tb_yw_xzqq_xzdwdm
where 1=1
and scbz = '0'
<if test="value != null">
and groupid=#{value, jdbcType=VARCHAR}
</if>
order by code asc
</select>
<select id="getAllTypes" resultType="java.lang.String">
select distinct(groupid) from sys_dictitem
......
......@@ -8,6 +8,8 @@ public interface IDicItemService {
List<ZTreeNode> queryTypeCode(String code_type, String id, String startId, String yycj, String name);
List<ZTreeNode> queryQyxzTypeCode(String code_type, String id, String startId, String yycj, String name);
/**
* 查询指定节点的代码
* @param code_type
......@@ -15,6 +17,7 @@ public interface IDicItemService {
* @return
*/
List<ZTreeNode> queryCodes(String code_type, String codes, String name);
List<ZTreeNode> queryQyxzCodes(String code_type, String codes, String name);
/**
* 根据条件查询代码
......
......@@ -120,6 +120,75 @@ public class IDicItemServiceImpl implements IDicItemService {
return ztreeNodes;
}
@Override
public List<ZTreeNode> queryQyxzTypeCode(String type, String id, String startId, String yycj, String name) {
List<ZTreeNode> ztreeNodes = new ArrayList<>();
if (null != ssdw && !"".equals(ssdw) && ssdw.length() >= 2) {
ssdw = ssdw.substring(0, 2);
}
if(id==null||"".equals(id)){//根节点
id=null;
if("CODE_UNIT".equals(type)){//单位代码增加起始单位过滤功能
if(startId!=null){
id=startId.substring(0,2)+"000000000000".substring(startId.length()-2);
}
}else if("CODE_AJXZLB".equals(type)||"CODE_XALBDMBCMS".equals(type)){
id=startId;
//System.out.println("startId="+startId);
}
}
if(name==null||"".equals(name)){
name="*";
}else{
name="*"+name+"*";
id="*";
}
if(startId==null||"".equals(startId)){
startId="*";
}else{
startId=startId+"*";
}
//获取符合条件的key
String keys = "qyxz"+ssdw + ":" + type + ":"+id+":"+startId+":"+name+":*";
Set<String> set = redisTemplate.keys(keys);
//System.out.println("keys="+keys);
//System.out.println("=============");
//System.out.println(set);
Iterator<String> iterator = set.iterator();
while(iterator.hasNext()){
String str = iterator.next();
//System.out.println("key="+str);
String jsonStr=redisTemplate.opsForValue().get(str);
//System.out.println("jsonStr="+jsonStr);
jsonStr=jsonStr.replaceAll("\\\\","");
if(jsonStr.startsWith("\"")){
jsonStr=jsonStr.substring(1,jsonStr.length());
}
if(jsonStr.endsWith("\"")){
jsonStr=jsonStr.substring(0,jsonStr.length()-1);
}
//System.out.println("jsonStr="+jsonStr);
SysDictitem sysDictitem= JSON.parseObject(jsonStr, SysDictitem.class);
ZTreeNode node=new ZTreeNode();
node=parseSysDictitemToNode(node,sysDictitem);
if(node.getPId()==null||"".equals(node.getPId())||node.isIsParent()){
node.setState("closed"); //显示文件夹图标
}else{
node.setState(null); //显示叶子图标
}
ztreeNodes.add(node);
}
//System.out.println("------------------------");
//System.out.println(ztreeNodes.toString());
return ztreeNodes;
}
public List<ZTreeNode> getZtreeNodeByName(String code_type, String id, String yycj, String unitcode, String name) {
List<ZTreeNode> ztreeNodes = new ArrayList<>();
if (null != ssdw && !"".equals(ssdw) && ssdw.length() >= 2) {
......@@ -237,6 +306,47 @@ public class IDicItemServiceImpl implements IDicItemService {
}
@Override
public List<ZTreeNode> queryQyxzCodes(String type, String codes, String name) {
List<ZTreeNode> ztreeNodes = new ArrayList<ZTreeNode>();
if (null != ssdw && !"".equals(ssdw) && ssdw.length() >= 2) {
ssdw = ssdw.substring(0, 2);
}
if(codes.endsWith(",")){
codes=codes.substring(0,codes.length()-1);
}
if(name==null||"".equals(name)){
name="*";
}
String[] codeArray=codes.split(",");
for(String code:codeArray){
//获取符合条件的key
System.out.println("code="+code);
String key = "qyxz"+ssdw + ":" + type + ":*:"+code+":"+name+":*";
Set<String> set = redisTemplate.keys(key);
Iterator<String> iterator = set.iterator();
while(iterator.hasNext()){
String str = iterator.next();
String jsonStr=redisTemplate.opsForValue().get(str);
if(jsonStr!=null){
jsonStr=jsonStr.replaceAll("\\\\","");
if(jsonStr.startsWith("\"")){
jsonStr=jsonStr.substring(1,jsonStr.length());
}
if(jsonStr.endsWith("\"")){
jsonStr=jsonStr.substring(0,jsonStr.length()-1);
}
SysDictitem sysDictitem= JSON.parseObject(jsonStr, SysDictitem.class);
ZTreeNode node=new ZTreeNode();
node=parseSysDictitemToNode(node,sysDictitem);
node.setState(null); //显示叶子图标
ztreeNodes.add(node);
}
}
}
return ztreeNodes;
}
......
......@@ -21,6 +21,7 @@ public class ImportCode {
private DictitemMapper iDictitemDao;
@Value("${ssdw}")
private String ssdw; //所属单位
@Autowired
private StringRedisTemplate redisTemplate;
......@@ -51,6 +52,34 @@ public class ImportCode {
System.out.println("字典"+type+"成功加入缓存---------------------------------------------");
}
public void insertQyxzIntoRedis(String type) {
if (null != ssdw && !"".equals(ssdw) && ssdw.length() >= 2) {
ssdw = ssdw.substring(0, 2);
}
//先删除指定key缓存,再加入缓存
String keys=ssdw+":*";
if(null!=type && "null"!=type){
keys=ssdw+":"+type+"*";
}
System.out.println("ssdw="+ssdw);
System.out.println("keys="+keys);
Set<String> dictitemKeys = redisTemplate.keys("qyxz"+keys);
redisTemplate.delete(dictitemKeys);
List<SysDictitem> zTreeNodeList = iDictitemDao.findQyxzCodeAllByType(type);
for(SysDictitem node:zTreeNodeList){
String nodeStr= JSON.toJSONString(node);
String pid=null;
if(!StringUtils.isEmpty(node.getPid())){
pid=node.getPid();
}
String key ="qyxz"+ ssdw+":"+node.getGroupid()+":"+pid+":"+node.getCode()+":"+node.getName()+":"+node.getId()+"|"+node.getName();
redisTemplate.opsForValue().set(key,nodeStr);
}
type = (null==type || "null"==type)?"":type;
System.out.println("字典"+type+"成功加入缓存---------------------------------------------");
}
//获取字典表中相关的的groupid
public List<String> getAllTypes(String type) {
return iDictitemDao.getAllTypes(type);
......
......@@ -94,7 +94,7 @@ public class TbYwXzqqXx implements Serializable {
private Date spsj;
/**
* 协作状态 1-待审核,2-协作中,3-完成 ,4-审核不通过,5-管理员驳回
* 协作状态0-草稿 1-待审核,2-协作中,3-完成 ,4-审核不通过,5-管理员驳回
*/
private String xzzt;
private String xzztStr;
......
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