From 191eb1ae75824ebfd80881a541e7f00489d8e27a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=BD=90=E5=A4=A9=E5=A4=A7=E5=9C=A3?= <17615834396@163.com>
Date: Thu, 28 Mar 2024 09:45:59 +0800
Subject: [PATCH] bug

---
 .../controller/TagCodeRecordController.java   | 23 ++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/tag/controller/TagCodeRecordController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/tag/controller/TagCodeRecordController.java
index fa5db9905..fefaa2967 100644
--- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/tag/controller/TagCodeRecordController.java
+++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/tag/controller/TagCodeRecordController.java
@@ -12,9 +12,11 @@ import com.fuint.business.member.entity.LJStaff;
 import com.fuint.business.member.service.ILJStaffService;
 import com.fuint.business.tag.dto.TagCodeRecordDTO;
 import com.fuint.business.tag.entity.OilTag;
+import com.fuint.business.tag.entity.TagCode;
 import com.fuint.business.tag.entity.TagCodeRecord;
 import com.fuint.business.tag.service.OilTagService;
 import com.fuint.business.tag.service.TagCodeRecordService;
+import com.fuint.business.tag.service.TagCodeService;
 import com.fuint.common.dto.AccountInfo;
 import com.fuint.common.util.TokenUtil;
 import com.fuint.framework.exception.BusinessCheckException;
@@ -126,15 +128,34 @@ public class TagCodeRecordController extends BaseController {
         return getSuccessResult("该员工暂未绑定码牌!");
     }
 
+    @Resource
+    private TagCodeService tagCodeService;
     /**
      * 码牌与油站解绑
      *
      * @param id 主键结合
      * @return 删除结果
      */
-    @DeleteMapping("id")
+    @DeleteMapping("{id}")
     public ResponseObject delete(@PathVariable Long id) {
+
         TagCodeRecord tagCodeRecord = this.tagCodeRecordService.getById(id);
+
+        OilTag oilTag = oilTagService.getById(tagCodeRecord.getOilTagId());
+
+        TagCode tagCode = tagCodeService.getById(oilTag.getTagCodeId());
+
+        String collection = "";
+        if (tagCode.getCollection().contains("storeId")){
+            String[] storeIds = tagCode.getCollection().split("storeId");
+            String storeId = storeIds[0];
+            String[] sns = storeIds[1].split("sn");
+            String sn = sns[1];
+            collection = storeId + "sn" + sn;
+            tagCode.setCollection(collection);
+            tagCodeService.updateById(tagCode);
+        }
+
         if (ObjectUtils.isNotEmpty(tagCodeRecord.getStaffId())){
             return getSuccessResult("该码牌已绑定员工,请先解绑员工!");
         }else {