From 64e53c35351e20baa4b7dcfd5040131bbab5a20f Mon Sep 17 00:00:00 2001 From: lizhicheng Date: Fri, 14 Oct 2022 14:57:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mapper/device/TbDeviceDao.xml | 2 +- .../resources/mapper/resource/ResourceDao.xml | 63 ++++++++++--------- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/renren-admin/src/main/resources/mapper/device/TbDeviceDao.xml b/renren-admin/src/main/resources/mapper/device/TbDeviceDao.xml index a82cda63..0815b9dd 100644 --- a/renren-admin/src/main/resources/mapper/device/TbDeviceDao.xml +++ b/renren-admin/src/main/resources/mapper/device/TbDeviceDao.xml @@ -18,7 +18,7 @@ SELECT sd.name AS deptName, tdr.name AS resourceName, tdr.type, tdr.create_date AS createDate, - if(tdr.del_flag=0, '审核通过', '审核中') AS approveStatus, trma.instance_id AS applyNumber - FROM (SELECT IF(d.type='组件服务', A.attr_value, d.type) AS type, d.id, d.del_flag, d.dept_id, d.create_date, + CASE WHEN (tdr.del_flag=0 OR tdr.del_flag=5) THEN '通过' WHEN tdr.del_flag=6 THEN '不通过' ELSE '审核中' END AS approveStatus, trma.instance_id AS applyNumber + FROM (SELECT IF(d.type='组件服务', a.attr_value, d.type) AS type, d.id, d.del_flag, d.dept_id, d.create_date, d.name FROM tb_data_resource d LEFT JOIN tb_data_attr a ON d.id=a.data_resource_id AND a.attr_type='组件类型' AND a.del_flag=0 @@ -1845,13 +1845,16 @@ WHERE 1=1 AND tdr.dept_id=sd.id - AND tdr.del_flag = 0 + AND tdr.del_flag in (0, 5) - AND tdr.del_flag in (2, 3) + AND tdr.del_flag not in (0, 1, 5, 6) + + + AND tdr.del_flag=6 - AND tdr.del_flag in (0, 2, 3) + AND tdr.del_flag != 1 @@ -1904,14 +1907,6 @@ AND su.dept_id = sd.id AND taa.resource_id = tdr.id AND dept.id = tdr.dept_id - AND taa.approve_status = #{approveStatus} @@ -1925,22 +1920,34 @@ AND SUBSTR(taa.create_date, 1, 10) BETWEEN #{startDate} AND #{endDate} + + UNION ALL - UNION ALL - - SELECT - tmb.dept AS 'deptName', - tm.`name` AS 'resourceName', - '青岛市大数据发展管理局' AS 'resourceDeptName', - '会议室' AS 'type', - tm.create_date AS 'createDate', - CASE tmb.state WHEN 1 THEN '申请中' WHEN 2 THEN '通过' WHEN 3 THEN '不通过' ELSE '申请中' END AS 'approveStatus', - '' AS 'applyNumber' - FROM - t_meetingroom_book tmb, - t_meetingroom tm - WHERE - tmb.room_id = tm.id + SELECT + tmb.dept AS 'deptName', + tm.`name` AS 'resourceName', + '青岛市大数据发展管理局' AS 'resourceDeptName', + '会议室' AS 'type', + tm.create_date AS 'createDate', + CASE tmb.state WHEN 1 THEN '审核中' WHEN 2 THEN '通过' WHEN 3 THEN '不通过' ELSE '审核中' END AS 'approveStatus', + '' AS 'applyNumber' + FROM + t_meetingroom_book tmb, + t_meetingroom tm + WHERE + tmb.room_id = tm.id + + + AND tmb.state=2 + + + AND tmb.state=3 + + + AND tmb.state not in (2, 3) + + + ORDER BY createDate DESC From 85d1e9eddf9afdcf48a797956ae05f1de2353d23 Mon Sep 17 00:00:00 2001 From: lizhicheng Date: Fri, 14 Oct 2022 17:23:53 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=BE=E5=A4=87=E8=AF=A6=E6=83=85=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/device/service/Impl/TbDeviceApplyServiceImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/renren-admin/src/main/java/io/renren/modules/device/service/Impl/TbDeviceApplyServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/device/service/Impl/TbDeviceApplyServiceImpl.java index 05ee2fe3..4fc7d50e 100644 --- a/renren-admin/src/main/java/io/renren/modules/device/service/Impl/TbDeviceApplyServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/device/service/Impl/TbDeviceApplyServiceImpl.java @@ -91,6 +91,10 @@ public class TbDeviceApplyServiceImpl extends CrudServiceImpl dtoList = tbDeviceApplyDao.queryList(params); List result = dtoList.stream().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList()); + result.stream().forEach(it -> { + it.setTbDeviceDTO(tbDeviceService.get(it.getDeviceId())); + it.setAuditorName(sysUserService.get(it.getAuditor()).getRealName()); + }); return new PageData(result, dtoList.size()); } } From ce11e658fffbb75ffd2414bb52ff41d2c5e4a6ae Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 17 Oct 2022 13:09:46 +0800 Subject: [PATCH 3/3] =?UTF-8?q?HIQDUCS-100=20=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ResourceServiceImpl.java | 251 +++++++++++------- .../resources/mapper/resource/ResourceDao.xml | 17 +- 2 files changed, 172 insertions(+), 96 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java index 35b3c2ca..3050c8e8 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java @@ -478,34 +478,31 @@ public class ResourceServiceImpl extends CrudServiceImpl { - List temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast) - .sorted(Comparator.comparing(x -> { - Map index = (Map) x; - int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString()); - String total = (index.get("total") == null) ? "0" : index.get("total").toString(); - if (pingTOp_ <= 0) { - return 0l + Long.valueOf(total) == 0 ? -1 : Long.valueOf(total); - } - long pingTOp = (index.get("pin_top_time") == null) ? 0 + (Long.valueOf(total) == 0 ? -1 : Long.valueOf(total)) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(total); - return (pingTOp % 1000) == 0 ? -1 : pingTOp % 1000; - }).reversed() - ).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList()); + List temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> { + Map index = (Map) x; + int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString()); + String total = (index.get("total") == null) ? "0" : index.get("total").toString(); + if (pingTOp_ <= 0) { + return 0l + Long.valueOf(total) == 0 ? -1 : Long.valueOf(total); + } + long pingTOp = (index.get("pin_top_time") == null) ? 0 + (Long.valueOf(total) == 0 ? -1 : Long.valueOf(total)) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(total); + return (pingTOp % 1000) == 0 ? -1 : pingTOp % 1000; + }).reversed()).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList()); return temp; }).get(); break; case "ASC": // total 升序 ids = customThreadPool.submit(() -> { - List temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast) - .sorted(Comparator.comparing(x -> { - Map index = (Map) x; - int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString()); - String total = (index.get("total") == null) ? "0" : index.get("total").toString(); - if (pingTOp_ <= 0) { - return 0l + Long.valueOf(total) == 0 ? -1 : Long.valueOf(total); - } - long pingTOp = (index.get("pin_top_time") == null) ? 0 + (Long.valueOf(total) == 0 ? -1 : Long.valueOf(total)) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(total); - return (pingTOp % 1000) == 0 ? -1 : pingTOp % 1000; - })).skip((pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList()); + List temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> { + Map index = (Map) x; + int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString()); + String total = (index.get("total") == null) ? "0" : index.get("total").toString(); + if (pingTOp_ <= 0) { + return 0l + Long.valueOf(total) == 0 ? -1 : Long.valueOf(total); + } + long pingTOp = (index.get("pin_top_time") == null) ? 0 + (Long.valueOf(total) == 0 ? -1 : Long.valueOf(total)) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(total); + return (pingTOp % 1000) == 0 ? -1 : pingTOp % 1000; + })).skip((pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList()); return temp; }).get(); break; @@ -513,32 +510,30 @@ public class ResourceServiceImpl extends CrudServiceImpl { - ResourceDTO index = (ResourceDTO) x; - int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); - long index_; - if (pinTop > 0) { - index_ = index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? -1L : index.getTotal()) : index.getPinTopTime().getTime() + (index.getTotal() == null ? -1L : index.getTotal()); - index_ = index_ % 1000; - } else { - index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal())); - } - return index_ == 0 ? -1 : index_; - }).reversed() - ).collect(Collectors.toList()); + ResourceDTO index = (ResourceDTO) x; + int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); + long index_; + if (pinTop > 0) { + index_ = index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? -1L : index.getTotal()) : index.getPinTopTime().getTime() + (index.getTotal() == null ? -1L : index.getTotal()); + index_ = index_ % 1000; + } else { + index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal())); + } + return index_ == 0 ? -1 : index_; + }).reversed()).collect(Collectors.toList()); } else { resourceDTOS = resourceDTOS.stream().sorted(Comparator.comparing(x -> { - ResourceDTO index = x; - int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); - long index_; - if (pinTop > 0) { - index_ = index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? -1L : index.getTotal()) : index.getPinTopTime().getTime() + (index.getTotal() == null ? -1L : index.getTotal()); - index_ = index_ % 1000; - } else { - index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal())); - } - return index_ == 0 ? -1 : index_; - }) - ).collect(Collectors.toList()); + ResourceDTO index = x; + int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); + long index_; + if (pinTop > 0) { + index_ = index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? -1L : index.getTotal()) : index.getPinTopTime().getTime() + (index.getTotal() == null ? -1L : index.getTotal()); + index_ = index_ % 1000; + } else { + index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal())); + } + return index_ == 0 ? -1 : index_; + })).collect(Collectors.toList()); } customThreadPool.shutdown(); } else { // 非总体评价排序时 @@ -693,11 +688,7 @@ public class ResourceServiceImpl extends CrudServiceImpl page = new Page<>(jsonObject.getIntValue("pageNum"), jsonObject.getIntValue("pageSize")); QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type")) - .eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()) - .ne("type", "知识库") - .ne("type", "赋能案例") - .orderByDesc("create_date"); + queryWrapper.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type")).eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()).ne("type", "知识库").ne("type", "赋能案例").orderByDesc("create_date"); IPage resourceEntityIPage = resourceDao.selectPage(page, queryWrapper); IPage resourceDTOIPage = new Page<>(); resourceDTOIPage.setPages(resourceEntityIPage.getPages()); @@ -819,24 +810,23 @@ public class ResourceServiceImpl extends CrudServiceImpl>> listMap = typeMapList.stream().collect(Collectors.groupingBy(m -> m.get("type").toString())); //区级要根据行政区划多加一层结构 - List tasks = - listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).map(item -> { - CompletableFuture task = CompletableFuture.runAsync(() -> { - HashMap map = new HashMap<>(); - map.put("type", item.getKey()); - Integer integer = resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type")); - map.put("total", integer); - item.getValue().forEach(item1 -> { - item1.remove("type"); - item1.remove("regionSort"); - }); - map.put("dataList", item.getValue()); - if (integer != 0) { - resultList.add(map); - } - }, executor); - return task; - }).collect(Collectors.toList()); + List tasks = listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).map(item -> { + CompletableFuture task = CompletableFuture.runAsync(() -> { + HashMap map = new HashMap<>(); + map.put("type", item.getKey()); + Integer integer = resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type")); + map.put("total", integer); + item.getValue().forEach(item1 -> { + item1.remove("type"); + item1.remove("regionSort"); + }); + map.put("dataList", item.getValue()); + if (integer != 0) { + resultList.add(map); + } + }, executor); + return task; + }).collect(Collectors.toList()); CompletableFuture.allOf(tasks.toArray(new CompletableFuture[tasks.size()])).join(); Optional>> areaList = Optional.ofNullable(listMap.get("区级")); @@ -1115,8 +1105,7 @@ public class ResourceServiceImpl extends CrudServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("instance_id", instanceId) - .eq("approve_status", "通过"); + queryWrapper.eq("instance_id", instanceId).eq("approve_status", "通过"); List applicationEntities = tAbilityApplicationDao.selectList(queryWrapper); ArrayList cameraList = new ArrayList(); applicationEntities.forEach(index -> { @@ -1919,8 +1908,7 @@ public class ResourceServiceImpl extends CrudServiceImpl> typeCountListByDept = resourceDao.selectDeptDetailTypeCountList(params); - Map>> typeCountListMap = typeCountListByDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString())); - ArrayList resultList = new ArrayList<>(); + Map>> typeCountListMap = // 市级部门 + typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("2")).collect(Collectors.groupingBy(m -> m.get("dept_id").toString())); + List> resultList = getDeptTemp1(); + resultList.addAll(getDeptTemp2()); Map countMap = new HashMap<>(); - typeCountListMap.forEach((k, v) -> { - HashMap map = new HashMap<>(); - map.put("count", v.stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); - map.put("name", k); - v.forEach(item -> { - map.put(item.get("type").toString(), item.get("count")); - if (countMap.containsKey(item.get("type"))) { - countMap.replace(item.get("type").toString(), Integer.parseInt(item.get("count").toString()) + countMap.get(item.get("type"))); - } else { - countMap.put(item.get("type").toString(), Integer.parseInt(item.get("count").toString())); - } - }); - resultList.add(map); - }); + resultList = resultList.stream().map(index -> { + if (typeCountListMap.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息 + index.put("count", typeCountListMap.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + typeCountListMap.get(index.get("dept_id").toString()).stream().forEach(count -> { + index.put(count.get("type").toString(), count.get("count")); + if (countMap.containsKey(count.get("type"))) { + countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type"))); + } else { + countMap.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString())); + } + }); + } + return index; + }).collect(Collectors.toList()); + Map>> typeCountListMap1 = // 区级部门 + typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("3")).collect(Collectors.groupingBy(m -> m.get("district").toString())); + resultList = resultList.stream().map(index -> { + if (typeCountListMap1.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息 + index.put("count", typeCountListMap1.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + typeCountListMap1.get(index.get("dept_id").toString()).stream().forEach(count -> { + index.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + Integer.parseInt(index.getOrDefault(count.get("type").toString(), "0").toString())); + if (countMap.containsKey(count.get("type"))) { + countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type"))); + } else { + countMap.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString())); + } + }); + } + return index; + }).collect(Collectors.toList()); +// typeCountListMap.forEach((k, v) -> { +// HashMap map = new HashMap<>(); +// map.put("count", v.stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); +// map.put("name", k); +// v.forEach(item -> { +// map.put(item.get("type").toString(), item.get("count")); +// if (countMap.containsKey(item.get("type"))) { +// countMap.replace(item.get("type").toString(), Integer.parseInt(item.get("count").toString()) + countMap.get(item.get("type"))); +// } else { +// countMap.put(item.get("type").toString(), Integer.parseInt(item.get("count").toString())); +// } +// }); +// resultList.add(map); +// }); + Integer total = 0; for (Integer count : countMap.values()) { total += count; @@ -2098,6 +2119,56 @@ public class ResourceServiceImpl extends CrudServiceImpl> getDeptTemp1() { + List> resultList; + List> maps = jdbcTemplate.queryForList("SELECT id,`name`,type,pid,district FROM sys_dept WHERE type = 2 ORDER BY sys_dept.sort;"); + resultList = maps.stream().map(index -> { + HashMap map = new HashMap<>(); + map.put("count", 0); // + map.put("name", index.get("name").toString()); + map.put("dept_id", index.get("id").toString()); + map.put("yyzy", "0"); + map.put("znsf", "0"); + map.put("tcfw", "0"); + map.put("kfzj", "0"); + map.put("ywzj", "0"); + map.put("jcss", "0"); + map.put("zsk", "0"); + map.put("sjzy", "0"); + return map; + }).collect(Collectors.toList()); + return resultList; + } + + /** + * 获取区的初级构造 + * + * @return + */ + private List> getDeptTemp2() { + List> resultList; + List> maps = jdbcTemplate.queryForList("SELECT id,`name` FROM sys_region WHERE tree_level = 3 AND leaf = 0 ORDER BY sort;"); + resultList = maps.stream().map(index -> { + HashMap map = new HashMap<>(); + map.put("count", 0); // + map.put("name", index.get("name").toString()); + map.put("dept_id", index.get("id").toString()); + map.put("yyzy", "0"); + map.put("znsf", "0"); + map.put("tcfw", "0"); + map.put("kfzj", "0"); + map.put("ywzj", "0"); + map.put("jcss", "0"); + map.put("zsk", "0"); + map.put("sjzy", "0"); + return map; + }).collect(Collectors.toList()); + return resultList; + } + @Override public Object selectCensusResourceTable(Map params) { return resourceDao.selectCensusResourceTable(params); diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index 5462c9cb..6d5d1d67 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -722,10 +722,10 @@ @@ -759,7 +759,8 @@ ( SELECT DISTINCT sd.id AS "deptId", - ( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type" + ( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS + "type" FROM sys_dept sd WHERE @@ -1790,6 +1791,9 @@ SELECT COUNT( tdr.id ) AS "count", sd.NAME AS "deptName", + sd.id AS "dept_id", + sd.type AS "deptType", + sd.district AS "district", (CASE tdr.type WHEN '应用资源' THEN 'yyzy' WHEN '智能算法' THEN 'znsf' @@ -1934,7 +1938,8 @@ '青岛市大数据发展管理局' AS 'resourceDeptName', '会议室' AS 'type', tm.create_date AS 'createDate', - CASE tmb.state WHEN 1 THEN '申请中' WHEN 2 THEN '通过' WHEN 3 THEN '不通过' ELSE '申请中' END AS 'approveStatus', + CASE tmb.state WHEN 1 THEN '申请中' WHEN 2 THEN '通过' WHEN 3 THEN '不通过' ELSE '申请中' END AS + 'approveStatus', '' AS 'applyNumber' FROM t_meetingroom_book tmb,