From 218ab860ed4708f6f70a519775c56c9554000fe7 Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期五, 27 六月 2025 13:42:41 +0800
Subject: [PATCH] 去除多余引用

---
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EquipmentCategoryController.java |   57 +++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 47 insertions(+), 10 deletions(-)

diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EquipmentCategoryController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EquipmentCategoryController.java
index 976ede5..00e305e 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EquipmentCategoryController.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EquipmentCategoryController.java
@@ -10,6 +10,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import org.jeecg.common.api.vo.CommonGenericTree;
@@ -25,6 +26,10 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
 
+import org.jeecg.modules.system.entity.SysDict;
+import org.jeecg.modules.system.entity.SysDictItem;
+import org.jeecg.modules.system.service.ISysDictItemService;
+import org.jeecg.modules.system.service.ISysDictService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -54,7 +59,11 @@
 public class EquipmentCategoryController extends JeecgController<EquipmentCategory, IEquipmentCategoryService> {
 	@Autowired
 	private IEquipmentCategoryService equipmentCategoryService;
-	
+	@Autowired
+	private ISysDictService sysDictService;
+	@Autowired
+	private ISysDictItemService sysDictItemService;
+
 	/**
 	 * 鍒嗛〉鍒楄〃鏌ヨ
 	 *
@@ -108,7 +117,8 @@
 		}
 		return Result.OK(pageList);
 	}
-	
+
+
 	/**
 	 *   娣诲姞
 	 *
@@ -120,13 +130,24 @@
 	//@RequiresPermissions("org.jeecg.modules.demo:mom_eam_equipment_category:add")
 	@PostMapping(value = "/add")
 	public Result<String> add(@RequestBody EquipmentCategory equipmentCategory) {
-		if(!StringUtils.isNotBlank( equipmentCategory.getParentId())){
-			equipmentCategory.setParentId("-1");
+		if(equipmentCategory.getParentId().equals("-1")){
+			SysDict sysDict = sysDictService.getOne(new QueryWrapper<SysDict>().eq("dict_code","equipment_category"),false);
+			if(ObjectUtils.isNotNull(sysDict)){
+				List<SysDictItem> sysDictItems = sysDictItemService.selectItemsByMainId(sysDict.getId());
+				for(SysDictItem sysDictItem:sysDictItems){
+					if(equipmentCategory.getName().equals(sysDictItem.getItemText())){
+						equipmentCategory.setEquipmentCategoryUda1(sysDictItem.getItemValue());
+					}
+				}
+			}
+			else {
+				return Result.error("娣诲姞澶辫触锛岄渶瑕佸幓缁存姢鏁版嵁瀛楀吀璁惧澶х被锛�");
+			}
 		}
 		equipmentCategoryService.save(equipmentCategory);
 		return Result.OK("娣诲姞鎴愬姛锛�");
 	}
-	
+
 	/**
 	 *  缂栬緫
 	 *
@@ -138,10 +159,16 @@
 	//@RequiresPermissions("org.jeecg.modules.demo:mom_eam_equipment_category:edit")
 	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
 	public Result<String> edit(@RequestBody EquipmentCategory equipmentCategory) {
+		List<EquipmentCategory> equipmentCategories = equipmentCategory.getEquipmentCategoryDtlList();
+		for(EquipmentCategory equipmentCategoryChild:equipmentCategories){
+			equipmentCategoryChild.setEquipmentCategoryUda1(equipmentCategory.getEquipmentCategoryUda1());
+			equipmentCategoryChild.setEquipmentCategoryUda2(equipmentCategory.getEquipmentCategoryUda2());
+		}
+		equipmentCategoryService.saveOrUpdateBatch(equipmentCategories);
 		equipmentCategoryService.updateById(equipmentCategory);
 		return Result.OK("缂栬緫鎴愬姛!");
 	}
-	
+
 	/**
 	 *   閫氳繃id鍒犻櫎
 	 *
@@ -158,7 +185,7 @@
 		equipmentCategoryService.updateById(equipmentCategory);
 		return Result.OK("鍒犻櫎鎴愬姛!");
 	}
-	
+
 	/**
 	 *  鎵归噺鍒犻櫎
 	 *
@@ -178,7 +205,7 @@
 		}
 		return Result.OK("鎵归噺鍒犻櫎鎴愬姛!");
 	}
-	
+
 	/**
 	 * 閫氳繃id鏌ヨ
 	 *
@@ -205,7 +232,7 @@
     //@RequiresPermissions("org.jeecg.modules.demo:mom_eam_equipment_category:exportXls")
     @RequestMapping(value = "/exportXls")
     public ModelAndView exportXls(HttpServletRequest request, EquipmentCategory equipmentCategory) {
-        return super.exportXls(request, equipmentCategory, EquipmentCategory.class, "mom_eam_equipment_category");
+        return super.exportXls(request, equipmentCategory, EquipmentCategory.class, "璁惧鍒嗙被");
     }
 
     /**
@@ -227,8 +254,18 @@
 	  */
 	 @GetMapping("/loadTree")
 	 public Result<?> loadTree(HttpServletRequest httpServletRequest) {
-		 List<CommonGenericTree> list = equipmentCategoryService.loadTree();
+		 List<CommonGenericTree> list = equipmentCategoryService.loadTreeByRecurrence();
 		 return Result.ok(list);
 	 }
+	 @GetMapping(value = "/getAllChildren")
+	 public Result<IPage<EquipmentCategory>> getAllChildren(EquipmentCategory equipmentCategory,
+															@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+															@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+															HttpServletRequest req){
+		 QueryWrapper<EquipmentCategory> queryWrapper = Wrappers.query();
+		 Page<EquipmentCategory> page = new Page<EquipmentCategory>(pageNo, pageSize);
+		 IPage<EquipmentCategory> pageList = equipmentCategoryService.getAllChildren(page, equipmentCategory);
+		 return Result.OK(pageList);
+	 }
 
 }

--
Gitblit v1.9.3