Selaa lähdekoodia

fix(system): 修复设备信息编辑时的重复校验逻辑

- 增加了对站点 ID 的查询,确保设备的唯一性
SheepHy 3 viikkoa sitten
vanhempi
commit
f679511e28

+ 4 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/controller/AppDeviceController.java

@@ -15,6 +15,7 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.modules.system.app.entity.AppDevice;
+import org.jeecg.modules.system.app.entity.AppSite;
 import org.jeecg.modules.system.app.mapper.AppSiteMapper;
 import org.jeecg.modules.system.app.service.IAppDeviceService;
 import org.springframework.transaction.annotation.Transactional;
@@ -105,10 +106,12 @@ public class AppDeviceController extends JeecgController<AppDevice, IAppDeviceSe
 	@PostMapping(value = "/edit")
 	@Transactional
 	public Result<String> edit(@RequestBody AppDevice appDevice) {
-		appDevice.setOrgCode(appSiteMapper.selectById(appDevice.getSiteId()).getOrgCode());
+		AppSite appSite = appSiteMapper.selectById(appDevice.getSiteId());
+		appDevice.setOrgCode(appSite.getOrgCode());
 		if(AppDeviceService.getOne(Wrappers.<AppDevice>lambdaQuery()
 				.eq(AppDevice::getDeviceSerial,appDevice.getDeviceSerial())
 				.eq(AppDevice::getDeviceNo,appDevice.getDeviceNo())
+				.eq(AppDevice::getSiteId,appDevice.getSiteId())
 				.eq(AppDevice::getDeviceType,appDevice.getDeviceType())) != null) {
 			return Result.error("设备已存在!");
 		}