From 16cd6a3d63f3352c1a20abb5fc73f48a4204bc62 Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期四, 10 七月 2025 19:51:19 +0800
Subject: [PATCH] art: 技术状态鉴定工单-数据库设计修改

---
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamMaintenanceStandardServiceImpl.java |   46 +++++++++++++++++++++++++++++++++++++---------
 1 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamMaintenanceStandardServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamMaintenanceStandardServiceImpl.java
index 6ac4eae..1238b1b 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamMaintenanceStandardServiceImpl.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamMaintenanceStandardServiceImpl.java
@@ -22,8 +22,8 @@
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.system.entity.BaseFactory;
 import org.jeecg.modules.system.entity.BaseFactoryUser;
-import org.jeecg.modules.system.service.IBaseFactoryService;
-import org.jeecg.modules.system.service.IBaseFactoryUserService;
+import org.jeecg.modules.system.entity.SysParams;
+import org.jeecg.modules.system.service.*;
 import org.jeecg.modules.eam.constant.BusinessCodeConst;
 import org.jeecg.modules.eam.constant.EamMaintenanceStandardDetailCategory;
 import org.jeecg.modules.eam.constant.MaintenanceStandardStatusEnum;
@@ -45,8 +45,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.ISysBusinessCodeRuleService;
-import org.jeecg.modules.system.service.ISysUserService;
 import org.jeecg.modules.system.vo.UserSelector;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -97,6 +95,8 @@
     private IEamEquipmentExtendService eamEquipmentExtendService;
     @Autowired
     private ISysBusinessCodeRuleService businessCodeRuleService;
+    @Autowired
+    private ISysParamsService sysParamsService;
 
     // 甯搁噺瀹氫箟
     private static final String REPAIR_TITLE = "缁翠慨浜哄憳淇濆吇鍐呭";
@@ -127,9 +127,11 @@
             List<BaseFactoryUser> baseFactoryUserList=baseFactoryUserService.
                     list(new LambdaQueryWrapper<BaseFactoryUser>().eq(BaseFactoryUser::getUserId,sysUser.getId()));
             if(!CollectionUtils.isEmpty(baseFactoryUserList)){
-                List<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toList());
-                List<String> factoryCode= baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getFactoryCode).collect(Collectors.toList());
+                Set<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toSet());
+                Set<String> factoryCode= baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getOrgCode).collect(Collectors.toSet());
                 queryWrapper.in("e.factory_org_code", factoryCode);
+            } else {
+                return page;
             }
         }
         if(eamMaintenanceStandard != null) {
@@ -596,6 +598,18 @@
                 eamMaintenanceStandardDetailService.saveBatch(allDetails);
             }
 
+            SysParams sysParams = sysParamsService.getSysPramBySettingKey("maintenance_import_type");
+
+            if (sysParams != null) {
+                if (sysParams.getSettingValue().equals("1")){
+                    //瑙﹀彂淇濆吇娴佺▼
+                    eamMaintenanceStandard.setStandardStatus(MaintenanceStandardStatusEnum.WAIT_SUBMIT.name());
+                    eamMaintenanceStandardMapper.updateById(eamMaintenanceStandard);
+                }
+            }else {
+                return Result.error("鏈壘鍒颁繚鍏绘祦绋嬪鍏ョ浉鍏抽厤缃�,璇疯仈绯荤鐞嗗憳");
+            }
+
             return Result.OK("鐐规琛ㄥ鍏ユ垚鍔�");
 
         } catch (Exception e) {
@@ -760,6 +774,7 @@
             // 鍒涘缓椤圭洰璇︽儏
             EamMaintenanceStandardDetail detail = new EamMaintenanceStandardDetail();
             detail.setStandardId(standard.getId());
+            detail.setItemCode(Integer.parseInt(getCellStringValue(row.getCell(0))));
             detail.setItemName(getCellStringValue(row.getCell(1)));
             detail.setItemCategory(itemCategory);
 
@@ -958,7 +973,6 @@
 
             List<XWPFTable> tables = doc.getTables();
             EamMaintenanceStandard standard = null;
-            boolean firstTableProcessed = false;
             List<EamMaintenanceStandardDetail> items = new ArrayList<>();
             String standardId = null;
 
@@ -1021,6 +1035,18 @@
             // 4. 淇濆瓨椤圭洰
             eamMaintenanceStandardDetailService.saveBatch(items);
 
+
+            SysParams sysParams = sysParamsService.getSysPramBySettingKey("maintenance_import_type");
+
+            if (sysParams != null) {
+                if (sysParams.getSettingValue().equals("1")) {
+                    standard.setStandardStatus(MaintenanceStandardStatusEnum.WAIT_SUBMIT.name());
+                    eamMaintenanceStandardMapper.updateById(standard);
+                }
+            }else {
+                return Result.error("鏈壘鍒颁繚鍏绘祦绋嬪鍏ョ浉鍏抽厤缃�,璇疯仈绯荤鐞嗗憳");
+            }
+
             return Result.ok(fileName + ": 瀵煎叆鎴愬姛, 椤圭洰鏁�: " + items.size());
 
         } catch (ImportException e) {
@@ -1043,15 +1069,17 @@
             if (!items.isEmpty()) {
                 items.remove(0);
             }
-
             // 2. 涓虹己澶遍儴浣嶇殑鏁版嵁濉厖鍓嶄竴鏉$殑淇濆吇閮ㄤ綅
             String lastPart = "";
+            int i =1;
             for (EamMaintenanceStandardDetail item : items) {
+                item.setItemCode(i);
                 if (item.getItemPart() != null && !item.getItemPart().isEmpty()) {
                     lastPart = item.getItemPart();
                 } else if (!lastPart.isEmpty()) {
                     item.setItemPart(lastPart);
                 }
+                i++;
             }
         }
     }
@@ -1183,7 +1211,7 @@
             } else if (cellContents.size() == 1) {
                 // 鍗曞垪妯″紡锛氳涓哄唴瀹�
                 item.setItemName(cellContents.get(0));
-            } else if (cellContents.isEmpty() && !isRowEmpty(row)) {
+            } else if (!isRowEmpty(row)) {
                 // 鐗规畩澶勭悊锛氳闈炵┖浣嗘病鏈夋彁鍙栧埌鍐呭锛堝彲鑳芥槸澶嶆潅鍚堝苟鍗曞厓鏍硷級
                 // 灏濊瘯鎻愬彇鏁磋鏂囨湰浣滀负鍐呭
                 StringBuilder content = new StringBuilder();

--
Gitblit v1.9.3