From 80f4ce8b76ad73f826fff2eed82a7acdebceca04 Mon Sep 17 00:00:00 2001
From: cuikaidong <ckd2942379034@163.com>
Date: 星期二, 20 五月 2025 17:59:53 +0800
Subject: [PATCH] 借出归还-审批流程增加

---
 db/数据库产品化设计.pdma.json                                                                                |   20 +++++++++
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EamEquipmentLeanOut.java                  |    4 ++
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentLeanOutServiceImpl.java |   54 ++++++++++++++++++++++++--
 3 files changed, 72 insertions(+), 6 deletions(-)

diff --git "a/db/\346\225\260\346\215\256\345\272\223\344\272\247\345\223\201\345\214\226\350\256\276\350\256\241.pdma.json" "b/db/\346\225\260\346\215\256\345\272\223\344\272\247\345\223\201\345\214\226\350\256\276\350\256\241.pdma.json"
index 6a30267..e6e737e 100644
--- "a/db/\346\225\260\346\215\256\345\272\223\344\272\247\345\223\201\345\214\226\350\256\276\350\256\241.pdma.json"
+++ "b/db/\346\225\260\346\215\256\345\272\223\344\272\247\345\223\201\345\214\226\350\256\276\350\256\241.pdma.json"
@@ -4,7 +4,7 @@
   "avatar": "",
   "version": "4.9.2",
   "createdTime": "2025-3-10 16:38:19",
-  "updatedTime": "2025-5-19 17:03:40",
+  "updatedTime": "2025-5-20 17:13:15",
   "dbConns": [],
   "profile": {
     "default": {
@@ -12193,6 +12193,24 @@
           "extProps": {},
           "domain": "9092C4E0-1A54-4859-ABBB-5B62DBC27573",
           "id": "FC0C30BA-AA78-41F8-A683-B7D2562934F1"
+        },
+        {
+          "defKey": "return_comment",
+          "defName": "褰掕繕澶囨敞",
+          "comment": "",
+          "type": "",
+          "len": "",
+          "scale": "",
+          "primaryKey": false,
+          "notNull": false,
+          "autoIncrement": false,
+          "defaultValue": "",
+          "hideInGraph": false,
+          "refDict": "",
+          "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64",
+          "extProps": {},
+          "domain": "9092C4E0-1A54-4859-ABBB-5B62DBC27573",
+          "id": "5177F684-EFAD-42F4-B1BC-50E1E312B58C"
         }
       ],
       "correlations": [],
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EamEquipmentLeanOut.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EamEquipmentLeanOut.java
index fa1da43..b4202d8 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EamEquipmentLeanOut.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EamEquipmentLeanOut.java
@@ -119,6 +119,10 @@
 	@Excel(name = "澶囨敞", width = 15)
     @ApiModelProperty(value = "澶囨敞")
 	private String remark;
+	/**澶囨敞*/
+	@Excel(name = "褰掕繕澶囨敞", width = 15)
+	@ApiModelProperty(value = "褰掕繕澶囨敞")
+	private String returnComment;
 
 	//鍒楄〃灞曠ず
 	@TableField(exist = false)
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentLeanOutServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentLeanOutServiceImpl.java
index 7f89f3f..1f075cc 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentLeanOutServiceImpl.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentLeanOutServiceImpl.java
@@ -17,7 +17,6 @@
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.eam.constant.AssetStatusEnum;
 import org.jeecg.modules.eam.constant.EquipmentLeanOutStatusEnum;
-import org.jeecg.modules.eam.constant.EquipmentMaintenanceStatus;
 import org.jeecg.modules.eam.entity.EamEquipment;
 import org.jeecg.modules.eam.entity.EamEquipmentLeanOut;
 import org.jeecg.modules.eam.mapper.EamEquipmentLeanOutMapper;
@@ -30,7 +29,6 @@
 import org.jeecg.modules.flowable.apithird.service.FlowCommonService;
 import org.jeecg.modules.flowable.service.IFlowDefinitionService;
 import org.jeecg.modules.flowable.service.IFlowTaskService;
-import org.jeecg.modules.system.service.IMdcProductionService;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -238,10 +236,43 @@
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public EamEquipmentLeanOut approval(EamEquipmentLeanOut request) {
-        // TODO
-        return null;
+    public EamEquipmentLeanOut approval(EamEquipmentLeanOut eamEquipmentLeanOut) {
+        try {
+            // 妫�鏌ヨ姹傚弬鏁�
+            if (!isValidRequest(eamEquipmentLeanOut)) {
+                throw new JeecgBootException("闈炴硶鍙傛暟");
+            }
+            if (EquipmentLeanOutStatusEnum.WAIT_APPROVAL.name().equals(eamEquipmentLeanOut.getLeanStatus())) {
+                eamEquipmentLeanOut.setLeanStatus(EquipmentLeanOutStatusEnum.WAIT_RETURN.name());
+                // 寰呭綊杩�
+            } else if (EquipmentLeanOutStatusEnum.WAIT_RETURN.name().equals(eamEquipmentLeanOut.getLeanStatus())) {
+                // 寰呯‘璁�
+                eamEquipmentLeanOut.setLeanStatus(EquipmentLeanOutStatusEnum.WAIT_CONFIRM.name());
+            } else if (EquipmentLeanOutStatusEnum.WAIT_CONFIRM.name().equals(eamEquipmentLeanOut.getLeanStatus())) {
+                // 宸插畬鎴�
+                eamEquipmentLeanOut.setLeanStatus(EquipmentLeanOutStatusEnum.COMPLETE.name());
+            }
+            // 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛
+            LoginUser sysUser = getCurrentUser();
+            if (sysUser == null || StrUtil.isBlank(sysUser.getId())) {
+                throw new JeecgBootException("璐﹀彿涓嶅瓨鍦�");
+            }
+            // 瀹℃壒浜�
+            eamEquipmentLeanOut.setApprovalUser(sysUser.getUsername());
+            //妫�鏌ヨ澶�
+            EamEquipment equipment = eamEquipmentService.getById(eamEquipmentLeanOut.getEquipmentId());
+            if (equipment == null) {
+                throw new JeecgBootException("璁惧涓嶅瓨鍦紒");
+            }
+            eamEquipmentLeanOut.setLeanPerson(sysUser.getUsername());
+            this.updateById(eamEquipmentLeanOut);
+            // 鑾峰彇娴佺▼涓氬姟璁板綍
+            return eamEquipmentLeanOut;
+        } catch (Exception e) {
+            throw new JeecgBootException("鎿嶄綔澶辫触锛�" + e.getMessage());
+        }
     }
+
 
     @Override
     public void afterFlowHandle(FlowMyBusiness business) {
@@ -250,6 +281,19 @@
         business.getActStatus();
     }
 
+
+    private boolean isValidRequest(EamEquipmentLeanOut request) {
+        return StrUtil.isNotBlank(request.getCode()) && StrUtil.isNotBlank(request.getEquipmentId());
+    }
+
+    private LoginUser getCurrentUser() {
+        try {
+            return (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
     @Override
     public Object getBusinessDataById(String dataId) {
         return this.getById(dataId);

--
Gitblit v1.9.3