From 2816415f539ef54839e331657edae7055c243ad8 Mon Sep 17 00:00:00 2001
From: chen.llin <1442464845@qq.comm>
Date: 星期六, 17 一月 2026 19:27:45 +0800
Subject: [PATCH] agv缓存库位清空和标记功能
---
src/main/java/com/zy/asrs/controller/AppVersionController.java | 159 ++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 139 insertions(+), 20 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/AppVersionController.java b/src/main/java/com/zy/asrs/controller/AppVersionController.java
index dd879b2..16a6111 100644
--- a/src/main/java/com/zy/asrs/controller/AppVersionController.java
+++ b/src/main/java/com/zy/asrs/controller/AppVersionController.java
@@ -12,6 +12,10 @@
import com.zy.asrs.entity.AppVersion;
import com.zy.asrs.service.AppVersionService;
import com.zy.common.web.BaseController;
+import com.zy.system.entity.Permission;
+import com.zy.system.entity.RolePermission;
+import com.zy.system.service.PermissionService;
+import com.zy.system.service.RolePermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.ClassUtils;
@@ -22,10 +26,15 @@
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
+import java.util.stream.Collectors;
@RestController
public class AppVersionController extends BaseController {
+ @Autowired
+ private PermissionService permissionService;
+ @Autowired
+ private RolePermissionService rolePermissionService;
@Autowired
private AppVersionService appVersionService;
@@ -37,17 +46,19 @@
@RequestMapping(value = "/appVersion/list/auth")
@ManagerAuth
- public R list(@RequestParam(defaultValue = "1")Integer curr,
- @RequestParam(defaultValue = "10")Integer limit,
- @RequestParam(required = false)String orderByField,
- @RequestParam(required = false)String orderByType,
- @RequestParam(required = false)String condition,
- @RequestParam Map<String, Object> param){
+ public R list(@RequestParam(defaultValue = "1") Integer curr,
+ @RequestParam(defaultValue = "10") Integer limit,
+ @RequestParam(required = false) String orderByField,
+ @RequestParam(required = false) String orderByType,
+ @RequestParam(required = false) String condition,
+ @RequestParam Map<String, Object> param) {
EntityWrapper<AppVersion> wrapper = new EntityWrapper<>();
excludeTrash(param);
convert(param, wrapper);
allLike(AppVersion.class, param.keySet(), wrapper, condition);
- if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
+ if (!Cools.isEmpty(orderByField)) {
+ wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));
+ }
return R.ok(appVersionService.selectPage(new Page<>(curr, limit), wrapper));
}
@@ -55,6 +66,7 @@
public R checkUpdate(@PathVariable("version") String version,
@PathVariable("type") Integer type) {
EntityWrapper<AppVersion> wrapper = new EntityWrapper<>();
+ wrapper.eq("type", type);
AppVersion appVersion = appVersionService.selectOne(wrapper);
if (Cools.isEmpty(appVersion)) {
return R.ok("宸叉槸鏈�鏂扮増鏈�");
@@ -71,10 +83,10 @@
return R.ok("鏈夋柊鐗堟湰锛岄渶瑕佹洿鏂�").add(latestApp);
}
- private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){
- for (Map.Entry<String, Object> entry : map.entrySet()){
+ private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper) {
+ for (Map.Entry<String, Object> entry : map.entrySet()) {
String val = String.valueOf(entry.getValue());
- if (val.contains(RANGE_TIME_LINK)){
+ if (val.contains(RANGE_TIME_LINK)) {
String[] dates = val.split(RANGE_TIME_LINK);
wrapper.ge(entry.getKey(), DateUtils.convert(dates[0]));
wrapper.le(entry.getKey(), DateUtils.convert(dates[1]));
@@ -97,8 +109,8 @@
@RequestMapping(value = "/appVersion/update/auth")
@ManagerAuth
- public R update(AppVersion appVersion){
- if (Cools.isEmpty(appVersion) || null==appVersion.getId()){
+ public R update(AppVersion appVersion) {
+ if (Cools.isEmpty(appVersion) || null == appVersion.getId()) {
return R.error();
}
if (appVersion.getLatest() == 1) {
@@ -111,8 +123,8 @@
@RequestMapping(value = "/appVersion/delete/auth")
@ManagerAuth
- public R delete(@RequestParam(value="ids[]") Long[] ids){
- for (Long id : ids){
+ public R delete(@RequestParam(value = "ids[]") Long[] ids) {
+ for (Long id : ids) {
appVersionService.deleteById(id);
}
return R.ok();
@@ -120,7 +132,7 @@
@RequestMapping(value = "/appVersion/export/auth")
@ManagerAuth
- public R export(@RequestBody JSONObject param){
+ public R export(@RequestBody JSONObject param) {
EntityWrapper<AppVersion> wrapper = new EntityWrapper<>();
List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
Map<String, Object> map = excludeTrash(param.getJSONObject("appVersion"));
@@ -136,7 +148,7 @@
wrapper.like("id", condition);
Page<AppVersion> page = appVersionService.selectPage(new Page<>(0, 10), wrapper);
List<Map<String, Object>> result = new ArrayList<>();
- for (AppVersion appVersion : page.getRecords()){
+ for (AppVersion appVersion : page.getRecords()) {
Map<String, Object> map = new HashMap<>();
map.put("id", appVersion.getId());
map.put("value", appVersion.getId());
@@ -149,7 +161,7 @@
@ManagerAuth
public R query(@RequestBody JSONObject param) {
Wrapper<AppVersion> wrapper = new EntityWrapper<AppVersion>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val"));
- if (null != appVersionService.selectOne(wrapper)){
+ if (null != appVersionService.selectOne(wrapper)) {
return R.parse(BaseRes.REPEAT).add(getComment(AppVersion.class, String.valueOf(param.get("key"))));
}
return R.ok();
@@ -158,12 +170,12 @@
@RequestMapping(value = "/appVersion/uploadApp/auth")
@ManagerAuth
public R uploadApp(@RequestParam("id") Integer id,
- @RequestParam("file") MultipartFile[] files){
+ @RequestParam("file") MultipartFile[] files) {
AppVersion appVersion = appVersionService.selectById(id);
MultipartFile file = files[0];
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss");
- String path = ClassUtils.getDefaultClassLoader().getResource("appVersion").getPath();
+ String path = ClassUtils.getDefaultClassLoader().getResource("appVersion").getPath();
//鏂囦欢鍚庣紑鍚�
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
//涓婁紶鏂囦欢鍚�
@@ -174,7 +186,7 @@
//鏈嶅姟鍣ㄧ淇濆瓨鐨勬枃浠跺璞�
File serverFile = new File(filepath);
- if(!serverFile.exists()) {
+ if (!serverFile.exists()) {
try {
//鍒涘缓鏂囦欢
serverFile.createNewFile();
@@ -218,4 +230,111 @@
response.setStatus(404);
}
}
+ @RequestMapping("/menu/pda/auth")
+ @ManagerAuth
+ public R menuPda(){
+ // 鐩存帴浠� sys_permission 琛ㄨ鍙栨墍鏈夎彍鍗曪紝涓嶆鏌ユ潈闄愬垎閰�
+ // 鏌ヨ鎵�鏈夌姸鎬佷负1锛堟甯革級鐨勬潈闄�
+ List<Permission> permissions = permissionService.selectList(
+ new EntityWrapper<Permission>()
+ .eq("status", 1) // 鍙繑鍥炴甯哥姸鎬佺殑鏉冮檺
+ );
+
+ // 妫�鏌ユ槸鍚︽湁灞傜骇缁撴瀯锛堢埗鑿滃崟锛歛ction涓虹┖瀛楃涓诧紝瀛愯彍鍗曪細resource_id鎸囧悜鐖惰彍鍗曠殑permission.id锛�
+ // 鏌ヨ鎵�鏈夌埗鑿滃崟锛坅ction涓虹┖瀛楃涓茬殑鏉冮檺锛�
+ List<Permission> parentMenus = permissions.stream()
+ .filter(p -> p.getAction() == null || p.getAction().isEmpty())
+ .collect(Collectors.toList());
+
+ // 鏀堕泦鎵�鏈夌埗鑿滃崟ID锛堢敤浜庤繃婊ょ嫭绔嬭彍鍗曪級
+ java.util.Set<Long> parentMenuIds = parentMenus.stream()
+ .map(Permission::getId)
+ .collect(Collectors.toSet());
+
+ if (!parentMenus.isEmpty()) {
+ // 鏋勫缓灞傜骇缁撴瀯
+ List<Map<String, Object>> result = new ArrayList<>();
+
+ for (Permission parentMenu : parentMenus) {
+ // 鏌ユ壘璇ョ埗鑿滃崟涓嬬殑瀛愯彍鍗�
+ // 鏂瑰紡1锛歳esource_id鎸囧悜鐖惰彍鍗曠殑id
+ // 鏂瑰紡2锛歳esource_id涓�0鎴杗ull锛屼絾鏍规嵁action璺緞鍖归厤鐖惰彍鍗�
+ List<Permission> children = permissions.stream()
+ .filter(p -> {
+ // 鎺掗櫎鐖惰彍鍗曟湰韬�
+ if (p.getAction() == null || p.getAction().isEmpty()) {
+ return false;
+ }
+ // 鏂瑰紡1锛歳esource_id鎸囧悜鐖惰彍鍗曠殑id
+ if (p.getResourceId() != null && p.getResourceId().equals(parentMenu.getId())) {
+ return true;
+ }
+ // 鏂瑰紡2锛歳esource_id涓�0鎴杗ull锛屾牴鎹產ction璺緞鍖归厤
+ if ((p.getResourceId() == null || p.getResourceId() == 0)) {
+ String action = p.getAction();
+ String parentName = parentMenu.getName();
+ // 鏍规嵁鐖惰彍鍗曞悕绉板尮閰峚ction璺緞
+ if ("鍏ュ簱绠$悊".equals(parentName)) {
+ return action != null && (action.startsWith("/pakin/") || action.startsWith("/order/"));
+ } else if ("AGV绠$悊".equals(parentName)) {
+ return action != null && action.startsWith("/AGV/");
+ } else if ("搴撳瓨绠$悊".equals(parentName)) {
+ return action != null && action.startsWith("/stock/");
+ }
+ }
+ return false;
+ })
+ .collect(Collectors.toList());
+
+ // 鍙湁鏈夊瓙鑿滃崟鐨勭埗鑿滃崟鎵嶈繑鍥�
+ if (!children.isEmpty()) {
+ Map<String, Object> parentMap = new HashMap<>();
+ parentMap.put("id", parentMenu.getId());
+ parentMap.put("name", parentMenu.getName());
+ parentMap.put("action", parentMenu.getAction());
+ parentMap.put("type", "parent"); // 鏍囪瘑涓虹埗鑿滃崟
+
+ // 鏋勫缓瀛愯彍鍗曞垪琛�
+ List<Map<String, Object>> childrenList = new ArrayList<>();
+ for (Permission child : children) {
+ Map<String, Object> childMap = new HashMap<>();
+ childMap.put("id", child.getId());
+ childMap.put("name", child.getName());
+ childMap.put("action", child.getAction());
+ childMap.put("type", "child"); // 鏍囪瘑涓哄瓙鑿滃崟
+ childrenList.add(childMap);
+ }
+ parentMap.put("children", childrenList);
+ result.add(parentMap);
+ }
+ }
+
+ // 娣诲姞娌℃湁鐖惰彍鍗曠殑鐙珛鏉冮檺锛坮esource_id涓篘ULL鐨勬潈闄愶級
+ List<Permission> standalonePermissions = permissions.stream()
+ .filter(p -> {
+ // 鍙繑鍥炴湁action鐨勬潈闄愶紙鎺掗櫎鐖惰彍鍗曪級
+ if (p.getAction() == null || p.getAction().isEmpty()) {
+ return false;
+ }
+ // 濡傛灉resource_id涓篘ULL锛岃鏄庢槸鐙珛鑿滃崟
+ return p.getResourceId() == null;
+ })
+ .collect(Collectors.toList());
+
+ for (Permission permission : standalonePermissions) {
+ Map<String, Object> item = new HashMap<>();
+ item.put("id", permission.getId());
+ item.put("name", permission.getName());
+ item.put("action", permission.getAction());
+ item.put("type", "standalone"); // 鐙珛鑿滃崟
+ result.add(item);
+ }
+
+ return R.ok().add(result);
+ }
+
+ // 濡傛灉娌℃湁灞傜骇缁撴瀯锛岃繑鍥炲師鏉ョ殑骞抽摵缁撴瀯锛堝吋瀹规棫閫昏緫锛�
+ return R.ok().add(permissions);
+ }
}
+
--
Gitblit v1.9.1