|
@@ -1,24 +1,20 @@
|
|
|
package com.ruoyi.project.eoeg.controller;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
|
|
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
|
|
-import com.ruoyi.project.eoeg.domain.TEoegLockChange;
|
|
|
-import com.ruoyi.project.eoeg.service.ITEoegLockChangeService;
|
|
|
import com.ruoyi.framework.web.controller.BaseController;
|
|
|
import com.ruoyi.framework.web.domain.AjaxResult;
|
|
|
-import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
import com.ruoyi.framework.web.page.TableDataInfo;
|
|
|
+import com.ruoyi.project.eoeg.domain.TEoegLockChange;
|
|
|
+import com.ruoyi.project.eoeg.service.ITEoegLockChangeService;
|
|
|
+import com.ruoyi.project.system.domain.SysUser;
|
|
|
+import com.ruoyi.project.system.service.ISysUserService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* EOEG 锁开锁关申请Controller
|
|
@@ -32,6 +28,8 @@ public class TEoegLockChangeController extends BaseController
|
|
|
{
|
|
|
@Autowired
|
|
|
private ITEoegLockChangeService tEoegLockChangeService;
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService sysUserService;
|
|
|
|
|
|
/**
|
|
|
* 查询EOEG 锁开锁关申请列表
|
|
@@ -74,9 +72,13 @@ public class TEoegLockChangeController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('eoeg:eoegChange:add')")
|
|
|
@Log(title = "EOEG 锁开锁关申请", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
- public AjaxResult add(@RequestBody TEoegLockChange tEoegLockChange)
|
|
|
- {
|
|
|
- return toAjax(tEoegLockChangeService.insertTEoegLockChange(tEoegLockChange));
|
|
|
+ public AjaxResult add(@RequestBody TEoegLockChange tEoegLockChange) {
|
|
|
+ try {
|
|
|
+ fillUserNames(tEoegLockChange);
|
|
|
+ return toAjax(tEoegLockChangeService.insertTEoegLockChange(tEoegLockChange));
|
|
|
+ } catch (Exception e) {
|
|
|
+ return AjaxResult.error("添加失败:" + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -85,11 +87,46 @@ public class TEoegLockChangeController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('eoeg:eoegChange:edit')")
|
|
|
@Log(title = "EOEG 锁开锁关申请", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
- public AjaxResult edit(@RequestBody TEoegLockChange tEoegLockChange)
|
|
|
- {
|
|
|
- return toAjax(tEoegLockChangeService.updateTEoegLockChange(tEoegLockChange));
|
|
|
+ public AjaxResult edit(@RequestBody TEoegLockChange tEoegLockChange) {
|
|
|
+ try {
|
|
|
+ fillUserNames(tEoegLockChange);
|
|
|
+ return toAjax(tEoegLockChangeService.updateTEoegLockChange(tEoegLockChange));
|
|
|
+ } catch (Exception e) {
|
|
|
+ return AjaxResult.error("更新失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 填充用户名称字段
|
|
|
+ */
|
|
|
+ private void fillUserNames(TEoegLockChange tEoegLockChange) {
|
|
|
+ tEoegLockChange.setSafaerName(getUserNameById(tEoegLockChange.getSafaer()));
|
|
|
+ tEoegLockChange.setExecutorName(getUserNameById(tEoegLockChange.getExecutor()));
|
|
|
+ tEoegLockChange.setChangeConfirmerName(getUserNameById(tEoegLockChange.getChangeConfirmer()));
|
|
|
+ tEoegLockChange.setChangeExecutorName(getUserNameById(tEoegLockChange.getChangeExecutor()));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据ID获取用户名
|
|
|
+ */
|
|
|
+ private String getUserNameById(String userIdStr) {
|
|
|
+ if (userIdStr == null || userIdStr.trim().isEmpty()) {
|
|
|
+ throw new IllegalArgumentException("用户ID不能为空");
|
|
|
+ }
|
|
|
+ Long userId;
|
|
|
+ try {
|
|
|
+ userId = Long.valueOf(userIdStr);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ throw new IllegalArgumentException("用户ID格式不正确: " + userIdStr);
|
|
|
+ }
|
|
|
+ SysUser user = sysUserService.selectUserById(userId);
|
|
|
+ if (user == null) {
|
|
|
+ throw new IllegalArgumentException("找不到ID为 " + userId + " 的用户");
|
|
|
+ }
|
|
|
+ return user.getNickName();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 删除EOEG 锁开锁关申请
|
|
|
*/
|