From 9a8d9ef43c70fe6d70b494f49b19e5ca6ef01d4b Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期五, 14 三月 2025 17:52:46 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceTypeServiceImpl.java |   85 +++++++++++++++++++++++++-----------------
 1 files changed, 50 insertions(+), 35 deletions(-)

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceTypeServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceTypeServiceImpl.java
index e00d918..fa5d47b 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceTypeServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceTypeServiceImpl.java
@@ -10,17 +10,12 @@
 import org.jeecg.modules.dnc.response.ProcessInfoCode;
 import org.jeecg.modules.dnc.service.IDeviceTypeService;
 import org.jeecg.modules.dnc.utils.ValidateUtil;
-import org.jeecg.modules.mdc.entity.MdcEquipment;
-import org.jeecg.modules.mdc.service.IMdcEquipmentService;
-import org.jeecg.modules.mdc.service.IMdcProductionEquipmentService;
-import org.jeecg.modules.system.entity.MdcProductionEquipment;
 import org.jeecg.modules.system.entity.SysParams;
 import org.jeecg.modules.system.service.ISysParamsService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
-import java.util.stream.Collectors;
 
 @Service
 public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceType> implements IDeviceTypeService {
@@ -28,28 +23,32 @@
     @Autowired
     private ISysParamsService sysParamsService;
 
-    @Autowired
-    private IMdcEquipmentService mdcEquipmentService;
-
-    @Autowired
-    private IMdcProductionEquipmentService mdcProductionEquipmentService;
-
     /**
      * 鏂板璁惧绫�
      * @param deviceType
      * @return
      */
+    @Override
     public Result<?> add(DeviceType deviceType){
-        SysParams sysParams = sysParamsService.getSysPramBySettingKey("dnc_nc_device_type");
-        if ("-1".equals(sysParams.getSettingValue())){
+        SysParams sysParams;
+        if (deviceType.getAttributionType()==5){
+            //宸ュ簭璁惧绫�
+            sysParams = sysParamsService.getSysPramBySettingKey("dnc_device_type_process");
+        }else {
+            //宸ユ璁惧绫�
+            sysParams = sysParamsService.getSysPramBySettingKey("dnc_device_type_step");
+        }
+        if ("0".equals(sysParams.getSettingValue())){
             //鏈惎鍔ㄨ澶囩被
             return Result.error("璁惧绫绘湭鍚姩,璇疯仈绯荤鐞嗗憳");
         }else {
             //宸插惎鍔ㄨ澶囩被
-            if(deviceType == null)
-                ExceptionCast.cast(CommonCode.INVALID_PARAM);
-            if(!ValidateUtil.validateString(deviceType.getProcessStepId()))
+            if(!ValidateUtil.validateString(deviceType.getAttributionId()))
                 Result.error("鏃犳晥鐨勮澶囩被");
+            List<DeviceType> deviceTypes=this.getByProductionIdAndDeviceManagementId(deviceType);
+            if(!deviceTypes.isEmpty()){
+                return Result.error("璁惧绫诲悕绉板凡瀛樺湪");
+            }
             boolean save = this.save(deviceType);
             if(save){
                 return Result.OK("娣诲姞璁惧绫绘垚鍔�");
@@ -62,14 +61,27 @@
      * @param deviceType
      * @return
      */
+    @Override
     public Result<?> edit(DeviceType deviceType){
         if(deviceType == null)
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
-        if(deviceType.getDeviceType()==null)
+        if(deviceType.getDeviceManagementId()==null)
             ExceptionCast.cast(ProcessInfoCode.PROCESS_NAME_NONE);
         DeviceType en = super.getById(deviceType.getId());
         if(en == null)
             ExceptionCast.cast(ProcessInfoCode.WORKSTEP_NOT_EXIST);
+        //鍒ゆ柇璁惧绫绘槸鍚︿负鏈韩
+        if(en.getDeviceManagementId().equals(deviceType.getDeviceManagementId())
+                &&en.getProductionId().equals(deviceType.getProductionId())
+                &&en.getAttributionId().equals(deviceType.getAttributionId())
+                &&en.getAttributionType().equals(deviceType.getAttributionType())){
+            return Result.OK("璁惧绫荤紪杈戞垚鍔�");
+        }
+        //鍒ゆ柇璁惧绫绘槸鍚﹁浣跨敤
+        List<DeviceType> deviceTypeList=this.getByProductionIdAndDeviceManagementId(deviceType);
+        if(!deviceTypeList.isEmpty()){
+            return Result.error("璁惧绫诲凡瀛樺湪");
+        }
         boolean save = this.updateById(deviceType);
         if(save){
             return Result.OK("璁惧绫荤紪杈戞垚鍔�");
@@ -81,6 +93,7 @@
      * @param id
      * @return
      */
+    @Override
     public Result<?> delete(String id){
         if(!ValidateUtil.validateString(id))
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
@@ -99,15 +112,24 @@
      * @param deviceTypes
      * @return
      */
+    @Override
     public Result<?> getByDeviceType(List<DeviceType> deviceTypes){
-        if (deviceTypes == null || deviceTypes.isEmpty()) {
-            return Result.error("璁惧绫讳俊鎭负绌�");
-        }
-        List<Integer> deviceTypeIds = deviceTypes.stream().map(DeviceType::getDeviceType).collect(Collectors.toList());
-        QueryWrapper<MdcEquipment> queryWrapper = new QueryWrapper<>();
-        queryWrapper.in("device_type", deviceTypeIds);
-        List<MdcEquipment> mdcEquipmentList = mdcEquipmentService.list(queryWrapper);
-        return Result.OK(mdcEquipmentList);
+        return Result.OK(null);
+    }
+
+    /**
+     * 閫氳繃杞﹂棿id涓庤澶囩被id鏌ヨ璁惧淇℃伅
+     * @param deviceType
+     * @return
+     */
+    public List<DeviceType> getByProductionIdAndDeviceManagementId(DeviceType deviceType) {
+        List<DeviceType> list = this.list(new QueryWrapper<DeviceType>().eq("attribution_id", deviceType.getAttributionId())
+               .eq("attribution_type", deviceType.getAttributionType())
+           .eq("device_management_id", deviceType.getDeviceManagementId()));
+        list.forEach(item->{
+            item.setDeviceManagementCode(item.getDeviceManagementId());
+        });
+        return list;
     }
 
     /**
@@ -116,18 +138,11 @@
      * @param type
      * @return
      */
+    @Override
     public Result<?> getByBusinessId(String businessId,String type){
-        List<DeviceType> list = this.list(new QueryWrapper<DeviceType>().eq("production_id", businessId).eq("type", type));
-        if (list == null || list.isEmpty()) {
-            return Result.error("璁惧绫讳俊鎭负绌�");
-        }
-        List<Integer> deviceTypeIds = list.stream().map(DeviceType::getDeviceType).collect(Collectors.toList());
-        List<String> equipmentIds=mdcProductionEquipmentService.list(new QueryWrapper<MdcProductionEquipment>().in("production_id",deviceTypeIds))
-                .stream().map(MdcProductionEquipment::getEquipmentId).collect(Collectors.toList());
+        List<DeviceType> list = this.list(new QueryWrapper<DeviceType>().eq("attribution_id", businessId).eq("attribution_type", type));
         list.forEach(item->{
-            List<MdcEquipment> mdcEquipmentList = mdcEquipmentService.list(new QueryWrapper<MdcEquipment>()
-                    .eq("device_type", item.getDeviceType()).in("id", equipmentIds));
-            item.setEquipmentList(mdcEquipmentList);
+            item.setDeviceManagementCode(item.getDeviceManagementId());
         });
         return Result.OK(list);
     }

--
Gitblit v1.9.3