From afb22090c509befbf68e7aaef00f06795d11337d Mon Sep 17 00:00:00 2001
From: 唐耀东 <18861537@qq.com>
Date: 星期一, 07 二月 2022 17:49:29 +0800
Subject: [PATCH] 设备,外设单元修改

---
 ruoyi-oa/src/main/java/com/ruoyi/oa/service/impl/DevEquipmentServiceImpl.java |   62 ++++++++++++++++++++++--------
 1 files changed, 45 insertions(+), 17 deletions(-)

diff --git a/ruoyi-oa/src/main/java/com/ruoyi/oa/service/impl/DevEquipmentServiceImpl.java b/ruoyi-oa/src/main/java/com/ruoyi/oa/service/impl/DevEquipmentServiceImpl.java
index 4bfe12a..63ef9bd 100644
--- a/ruoyi-oa/src/main/java/com/ruoyi/oa/service/impl/DevEquipmentServiceImpl.java
+++ b/ruoyi-oa/src/main/java/com/ruoyi/oa/service/impl/DevEquipmentServiceImpl.java
@@ -4,6 +4,7 @@
 import cn.hutool.http.HttpStatus;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.PageUtils;
 import com.ruoyi.common.core.page.PagePlus;
@@ -123,45 +124,72 @@
         DevEquipment po = baseMapper.selectOne(new QueryWrapper<DevEquipment>().lambda()
             .eq(DevEquipment::getSequenceCode, bo.getSequenceCode()));
         // 璁惧瀛樺湪锛岀洿鎺ヨ繑鍥炶澶囦俊鎭�
-        if (StringUtils.isEmpty(po)) {
+        if (StringUtils.isNotEmpty(po)) {
             return po;
         }
         // 璁惧涓嶅瓨鍦ㄥ垯鏂板缓
         else {
-            // 鍏堟牴鎹簭鍒楃爜鐢熸垚搴忓垪鍙�
-            DevEquipmentCode c = new DevEquipmentCode();
-            c.setSequenceCode(bo.getSequenceCode());
-            devEquipmentCodeMapper.insert(c);
-            // 娣诲姞璁惧
-            DevEquipment add = BeanUtil.toBean(bo, DevEquipment.class);
-            add.setSerialNumber(c.getId());
-            baseMapper.insert(add);
-            return add;
+            if(bo.isRegister()) {
+                // 鍏堟牴鎹簭鍒楃爜鐢熸垚搴忓垪鍙�
+                DevEquipmentCode c = new DevEquipmentCode();
+                c.setCreateTime(DateUtils.getNowDate());
+                devEquipmentCodeMapper.insert(c);
+                // 娣诲姞璁惧
+                DevEquipment add = BeanUtil.toBean(bo, DevEquipment.class);
+                add.setSerialNumber(c.getId());
+                baseMapper.insert(add);
+                return add;
+            }else{
+                return po;
+            }
         }
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public DevEquipment equipmentEdit(DevEquipmentBo bo) {
         DevEquipment po = baseMapper.selectById(bo.getId());
+        if (po == null) {
+            throw new ServiceException("娌℃湁璁惧淇℃伅", HttpStatus.HTTP_PARTIAL);
+        }
         if (null != bo.getSchoolId()) {
             po.setSchoolId(bo.getSchoolId());
         }
-        if (StringUtils.isEmpty(bo.getHostId())) {
+        if (StringUtils.isNotBlank(bo.getHostId())) {
             po.setHostId(bo.getHostId());
         }
-        if (StringUtils.isEmpty(bo.getNetworkId())) {
-            po.setNetworkId(bo.getNetworkId());
+        if(StringUtils.isNotBlank(bo.getEdition())){
+            po.setEdition(bo.getEdition());
         }
-        if (StringUtils.isEmpty(bo.getFrequencyBand())) {
-            po.setFrequencyBand(bo.getFrequencyBand());
+//        if (StringUtils.isEmpty(bo.getNetworkId())) {
+//            po.setNetworkId(bo.getNetworkId());
+//        }
+//        if (StringUtils.isEmpty(bo.getFrequencyBand())) {
+//            po.setFrequencyBand(bo.getFrequencyBand());
+//        }
+//        if (null != bo.getBatchId()) {
+//            po.setBatchId(bo.getBatchId());
+//        }
+//        if (StringUtils.isEmpty(bo.getRemarks())) {
+//            po.setRemarks(bo.getRemarks());
+//        }
+        baseMapper.updateById(po);
+        return po;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void submitComment(DevEquipmentBo bo) {
+        DevEquipment po = baseMapper.selectById(bo.getId());
+        if (po == null) {
+            throw new ServiceException("娌℃湁璁惧淇℃伅", HttpStatus.HTTP_PARTIAL);
         }
         if (null != bo.getBatchId()) {
             po.setBatchId(bo.getBatchId());
         }
-        if (StringUtils.isEmpty(bo.getRemarks())) {
+        if (StringUtils.isNotBlank(bo.getRemarks())) {
             po.setRemarks(bo.getRemarks());
         }
         baseMapper.updateById(po);
-        return po;
     }
 }

--
Gitblit v1.9.1