|
|
@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.tree.Tree;
|
|
|
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
|
|
import cn.hutool.core.lang.tree.TreeUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.gz.common.DataGlobalVariable;
|
|
|
import com.gz.dto.borrow.ArchiveBorrowDTO;
|
|
|
@@ -60,54 +61,74 @@ public class SelectStatisticsServiceImpl implements SelectStatisticsService {
|
|
|
|
|
|
@Override
|
|
|
public List<ArchiveStatisticsRVO> selectStatisticsByType(StatisticsVO vo) {
|
|
|
- if (vo.getMl() != null) {
|
|
|
- vo.setMlCodes(getMl(vo.getMl()));
|
|
|
- }
|
|
|
- if (!StringUtils.isEmpty(vo.getTime())) {
|
|
|
- vo.setStartTime(vo.getTime().split(" - ")[0]);
|
|
|
- vo.setEndTime(vo.getTime().split(" - ")[1]);
|
|
|
- }
|
|
|
- // 统计结果
|
|
|
- List<ArchiveStatisticsRVO> tree = selectStatisticsMapper.selectArchiveStatistics(vo);
|
|
|
- tree.forEach(e -> {
|
|
|
- if (e.getParentId() == -1) {
|
|
|
- for (ArchiveStatisticsRVO node : tree) {
|
|
|
- Integer archiveCount = 0;
|
|
|
- Integer fileCount = 0;
|
|
|
- if (e.getId().equals(node.getParentId())) {
|
|
|
- archiveCount += node.getArchiveCount();
|
|
|
- fileCount += node.getFileCount();
|
|
|
+ String key = String.format(DataGlobalVariable.CACHE_KEY_FOMAT, this.getClass().getName(), Thread.currentThread().getStackTrace()[1].getMethodName(), JSONObject.toJSONString(vo));
|
|
|
+ if (stringRedisTemplate.hasKey(key)) {
|
|
|
+ return JSONArray.parseArray(stringRedisTemplate.opsForValue().get(key), ArchiveStatisticsRVO.class);
|
|
|
+ } else {
|
|
|
+ if (vo.getMl() != null) {
|
|
|
+ vo.setMlCodes(getMl(vo.getMl()));
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(vo.getTime())) {
|
|
|
+ vo.setStartTime(vo.getTime().split(" - ")[0]);
|
|
|
+ vo.setEndTime(vo.getTime().split(" - ")[1]);
|
|
|
+ }
|
|
|
+ // 统计结果
|
|
|
+ List<ArchiveStatisticsRVO> tree = selectStatisticsMapper.selectArchiveStatistics(vo);
|
|
|
+ tree.forEach(e -> {
|
|
|
+ if (e.getParentId() == -1) {
|
|
|
+ for (ArchiveStatisticsRVO node : tree) {
|
|
|
+ Integer archiveCount = 0;
|
|
|
+ Integer fileCount = 0;
|
|
|
+ if (e.getId().equals(node.getParentId())) {
|
|
|
+ archiveCount += node.getArchiveCount();
|
|
|
+ fileCount += node.getFileCount();
|
|
|
+ }
|
|
|
+ e.setArchiveCount(e.getArchiveCount() + archiveCount);
|
|
|
+ e.setFileCount(e.getFileCount() + fileCount);
|
|
|
}
|
|
|
- e.setArchiveCount(e.getArchiveCount() + archiveCount);
|
|
|
- e.setFileCount(e.getFileCount() + fileCount);
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
- return tree;
|
|
|
+ });
|
|
|
+ stringRedisTemplate.opsForValue().set(key, JSONObject.toJSONString(tree), DataGlobalVariable.CACHE_EXPIRES, DataGlobalVariable.TIME_UNIT);
|
|
|
+ return tree;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<ArchiveYearStatisticsRVO> selectArchiveYearStatistics(StatisticsVO vo) {
|
|
|
- if (vo.getMl() != null) {
|
|
|
- vo.setMlCodes(getMl(vo.getMl()));
|
|
|
- }
|
|
|
- if (!StringUtils.isEmpty(vo.getTime())) {
|
|
|
- vo.setStartTime(vo.getTime().split(" - ")[0]);
|
|
|
- vo.setEndTime(vo.getTime().split(" - ")[1]);
|
|
|
+ String key = String.format(DataGlobalVariable.CACHE_KEY_FOMAT, this.getClass().getName(), Thread.currentThread().getStackTrace()[1].getMethodName(), JSONObject.toJSONString(vo));
|
|
|
+ if (stringRedisTemplate.hasKey(key)) {
|
|
|
+ return JSONArray.parseArray(stringRedisTemplate.opsForValue().get(key), ArchiveYearStatisticsRVO.class);
|
|
|
+ } else {
|
|
|
+ if (vo.getMl() != null) {
|
|
|
+ vo.setMlCodes(getMl(vo.getMl()));
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(vo.getTime())) {
|
|
|
+ vo.setStartTime(vo.getTime().split(" - ")[0]);
|
|
|
+ vo.setEndTime(vo.getTime().split(" - ")[1]);
|
|
|
+ }
|
|
|
+ List<ArchiveYearStatisticsRVO> archiveYearStatisticsRVOS = selectStatisticsMapper.selectArchiveYearStatistics(vo);
|
|
|
+ stringRedisTemplate.opsForValue().set(key, JSONObject.toJSONString(archiveYearStatisticsRVOS), DataGlobalVariable.CACHE_EXPIRES, DataGlobalVariable.TIME_UNIT);
|
|
|
+ return archiveYearStatisticsRVOS;
|
|
|
}
|
|
|
- return selectStatisticsMapper.selectArchiveYearStatistics(vo);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<BorrowStatisticsRVO> selectBorrowStatistics(StatisticsVO vo) {
|
|
|
- if (vo.getMl() != null) {
|
|
|
- vo.setMlCodes(getMl(vo.getMl()));
|
|
|
- }
|
|
|
- if (!StringUtils.isEmpty(vo.getTime())) {
|
|
|
- vo.setStartTime(vo.getTime().split(" - ")[0]);
|
|
|
- vo.setEndTime(vo.getTime().split(" - ")[1]);
|
|
|
+ String key = String.format(DataGlobalVariable.CACHE_KEY_FOMAT, this.getClass().getName(), Thread.currentThread().getStackTrace()[1].getMethodName(), JSONObject.toJSONString(vo));
|
|
|
+ if (stringRedisTemplate.hasKey(key)) {
|
|
|
+ return JSONArray.parseArray(stringRedisTemplate.opsForValue().get(key), BorrowStatisticsRVO.class);
|
|
|
+ } else {
|
|
|
+ if (vo.getMl() != null) {
|
|
|
+ vo.setMlCodes(getMl(vo.getMl()));
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(vo.getTime())) {
|
|
|
+ vo.setStartTime(vo.getTime().split(" - ")[0]);
|
|
|
+ vo.setEndTime(vo.getTime().split(" - ")[1]);
|
|
|
+ }
|
|
|
+ List<BorrowStatisticsRVO> borrowStatisticsRVOS = selectStatisticsMapper.selectBorrowStatistics(vo);
|
|
|
+ stringRedisTemplate.opsForValue().set(key, JSONObject.toJSONString(borrowStatisticsRVOS), DataGlobalVariable.CACHE_EXPIRES, DataGlobalVariable.TIME_UNIT);
|
|
|
+ return borrowStatisticsRVOS;
|
|
|
}
|
|
|
- return selectStatisticsMapper.selectBorrowStatistics(vo);
|
|
|
}
|
|
|
|
|
|
private List<String> getMl(Integer id) {
|
|
|
@@ -130,7 +151,7 @@ public class SelectStatisticsServiceImpl implements SelectStatisticsService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public Map<String,Integer> selectUserBorrowCountStatistics() {
|
|
|
+ public Map<String, Integer> selectUserBorrowCountStatistics() {
|
|
|
ArchiveBorrowDTO param = new ArchiveBorrowDTO();
|
|
|
param.setAdminId(JwtUtils.getCurrentUserJwtPayload().getId());
|
|
|
List<ArchiveBorrowDTO> selectResult = archiveBorrowMapper.select(param);
|
|
|
@@ -145,22 +166,22 @@ public class SelectStatisticsServiceImpl implements SelectStatisticsService {
|
|
|
// 预计归还时间
|
|
|
DateTime estimateReturnTime = DateUtil.parseDate(item.getEstimateReturnTime());
|
|
|
// 已经过期 未归还 原件借阅 借阅审核已通过
|
|
|
- if (now.before(estimateReturnTime) && item.getReturnStatus() == 0 && item.getBorrowType() == 1 && item.getAuditStatus() == 2){
|
|
|
- dqwgh ++;
|
|
|
+ if (now.before(estimateReturnTime) && item.getReturnStatus() == 0 && item.getBorrowType() == 1 && item.getAuditStatus() == 2) {
|
|
|
+ dqwgh++;
|
|
|
}
|
|
|
// 剩余3天为即将到期
|
|
|
- if (DateUtil.between(now,estimateReturnTime, DateUnit.DAY) == 3){
|
|
|
- jjdq ++;
|
|
|
+ if (DateUtil.between(now, estimateReturnTime, DateUnit.DAY) == 3) {
|
|
|
+ jjdq++;
|
|
|
}
|
|
|
- if (item.getBorrowType() == 1 && item.getAuditStatus() == 0){
|
|
|
- sqwcl ++;
|
|
|
+ if (item.getBorrowType() == 1 && item.getAuditStatus() == 0) {
|
|
|
+ sqwcl++;
|
|
|
}
|
|
|
}
|
|
|
- Map<String,Integer> result = new HashMap<>();
|
|
|
+ Map<String, Integer> result = new HashMap<>();
|
|
|
result.put("dqwgh", dqwgh);
|
|
|
result.put("jjdq", jjdq);
|
|
|
result.put("sqwcl", sqwcl);
|
|
|
- result.put("lsjyw",lsjyw);
|
|
|
+ result.put("lsjyw", lsjyw);
|
|
|
return result;
|
|
|
}
|
|
|
}
|