Преглед изворни кода

气瓶标签更换、绑定的标签不允许删除

liujh пре 3 година
родитељ
комит
3b0a118693

+ 8 - 0
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/controller/QpBottleStorageController.java

@@ -239,6 +239,14 @@ public class QpBottleStorageController extends BaseController {
         return ResultData.result(qpBottleStorageService.bottleStorageBinding(qpBottleStorage));
     }
 
+    @ApiOperation(value = "电子标签更换")
+    //@PreAuthorize(hasPermi = "airbottle:storage:edit")
+    @Log(title = "电子标签更换", businessType = BusinessType.UPDATE)
+    @GetMapping(value = "/change")
+    public ResultData<Boolean> change(String newTag, Long id) {
+        return ResultData.result(qpBottleStorageService.bottleStorageChange(newTag,id));
+    }
+
     /***
      * 供应商首页待办事项列表
      * @param storageInfoVo

+ 1 - 1
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/controller/QpBottleStorageManageController.java

@@ -96,7 +96,7 @@ public class QpBottleStorageManageController extends BaseController
      */
     @ApiOperation(value = "导出气瓶入库列表")
     //@PreAuthorize(hasPermi = "airbottle:storage:export")
-//    @PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_STORAGE+ PerFun.EXPORT)
+    @PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_STORAGE+ PerFun.EXPORT)
     @Log(title = "气瓶入库", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response,QpBottleStorageVO qpBottleStorage) throws IOException

+ 12 - 12
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/controller/QpRfidTagController.java

@@ -4,8 +4,10 @@ import com.zd.airbottle.domain.QpRfidTag;
 import com.zd.airbottle.service.IQpRfidTagService;
 import com.zd.common.core.annotation.Log;
 import com.zd.common.core.annotation.PreAuthorize;
+import com.zd.common.core.exception.ServiceException;
 import com.zd.common.core.log.BusinessType;
 import com.zd.common.core.utils.ExcelUtil;
+import com.zd.common.core.utils.StringUtils;
 import com.zd.common.core.web.controller.BaseController;
 import com.zd.model.domain.ResultData;
 import com.zd.model.domain.per.PerFun;
@@ -102,18 +104,16 @@ public class QpRfidTagController extends BaseController<QpRfidTag> {
     @Log(title = "RFID标签管理", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
     public ResultData<Boolean> remove(@PathVariable Long[] ids) {
+        StringBuilder strTag = new StringBuilder();
+        for(int i=0;i<ids.length;i++){
+            QpRfidTag tag =  qpRfidTagService.selectQpRfidTagById(ids[i]);
+            if(1==tag.getIsBind()){
+                strTag.append(tag.getTagCode()+",");
+            }
+        }
+        if(StringUtils.isNotNull(strTag)){
+            throw new ServiceException(strTag+"已被绑定");
+        }
         return ResultData.result(qpRfidTagService.deleteQpRfidTagByIds(ids));
     }
-
-    /**
-     * 修改RFID标签管理-小程序
-     */
-    @ApiOperation(value = "修改RFID标签管理-小程序")
-    @Log(title = "RFID标签管理", businessType = BusinessType.UPDATE)
-    @PostMapping("/update")
-    public ResultData<Boolean> update(@RequestBody QpRfidTag qpRfidTag) {
-        QpRfidTag tag = qpRfidTagService.selectByTag(qpRfidTag.getTagCode());
-        tag.setIsBind(qpRfidTag.getIsBind());
-        return ResultData.result(qpRfidTagService.updateQpRfidTag(tag));
-    }
 }

+ 5 - 0
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/service/IQpBottleStorageService.java

@@ -130,6 +130,11 @@ public interface IQpBottleStorageService {
     int bottleStorageBinding(QpBottleStorage qpBottleStorage);
 
     /**
+     * 更换
+     */
+    int bottleStorageChange(String newTag,Long id);
+
+    /**
      * 根据对象参数查询入库气瓶信息
      * @param bottleStorage 气瓶参数
      * @return 集合对象

+ 42 - 1
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/service/impl/QpBottleStorageServiceImpl.java

@@ -107,7 +107,10 @@ public class QpBottleStorageServiceImpl implements IQpBottleStorageService {
             qpBottleStorage.setRejectionApplyTime(new Date());
         } else if (qpBottleStorage.getAirStatus() == 0) {
             //入库
-
+            QpBottleStorage qs = qpBottleStorageMapper.getByElectronicTag(qpBottleStorage.getElectronicTag());
+            if(qs!=null){
+                throw new ServiceException("该标签已被使用!");
+            }
             //查询标签信息
             QpRfidTag rfidTag = qpRfidTagService.selectByTag(qpBottleStorage.getElectronicTag());
             if (rfidTag == null) {
@@ -348,6 +351,44 @@ public class QpBottleStorageServiceImpl implements IQpBottleStorageService {
         return flg;
     }
 
+    /**
+     * 更换
+     *
+     * @param newTag
+     * @param id
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int bottleStorageChange(String newTag, Long id) {
+        //查询新标签信息
+        QpRfidTag rfidTag = qpRfidTagService.selectByTag(newTag);
+        if(rfidTag==null){
+            throw new ServiceException("该标签不存在!");
+        }else if(1==rfidTag.getIsBind() ){
+            throw new ServiceException("该标签已绑定!");
+        }
+
+        //查询标签入库信息
+        QpBottleStorageVO vo = qpBottleStorageMapper.selectQpBottleStorageById(id);
+
+        //查询旧标签信息
+        QpRfidTag rfidTagOld = qpRfidTagService.selectByTag(vo.getElectronicTag());
+        //刷新 旧标签状态,解绑
+        rfidTagOld.setIsBind(0);
+        qpRfidTagService.updateQpRfidTag(rfidTagOld);
+
+        //刷新 新标签状态,绑定
+        QpRfidTag tag = qpRfidTagService.selectQpRfidTagById(rfidTag.getId());
+        tag.setIsBind(1);
+        qpRfidTagService.updateQpRfidTag(tag);
+
+        //标签更换
+        vo.setElectronicTag(newTag);
+        qpBottleStorageMapper.updateQpBottleStorage(vo);
+
+        return 1;
+    }
+
     @Override
     public List<QpBottleStorage> getList(QpBottleStorage bottleStorage) {
         return qpBottleStorageMapper.getList(bottleStorage);

+ 1 - 1
zd-modules/zd-airbottle/src/main/resources/mapper/airbottle/QpBottleStorageMapper.xml

@@ -641,7 +641,7 @@
         <if test="confirm == false ">and bs.rejection_userid is null</if>
     </select>
 
-    <!-- 查询入库的气瓶-->
+    <!-- 查询实验室负责人-->
     <select id="selectSubectDetalsById" resultType="java.util.Map">
         select admin_id adminId from lab_subject where id= #{subjectId};
     </select>