diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/tag/controller/OilTagController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/tag/controller/OilTagController.java index 50014e5f6..43ed1f264 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/tag/controller/OilTagController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/tag/controller/OilTagController.java @@ -4,6 +4,7 @@ package com.fuint.business.tag.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fuint.business.tag.entity.OilTag; @@ -11,14 +12,18 @@ 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.util.TagUtils; +import com.fuint.business.tag.vo.OilTagVO; import com.fuint.framework.web.BaseController; import com.fuint.framework.web.ResponseObject; import org.apache.ibatis.annotations.Param; +import org.springframework.beans.BeanUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.io.Serializable; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; /** * 码牌配置表(OilTag)表控制层 @@ -57,7 +62,24 @@ public class OilTagController extends BaseController { queryWrapper.eq(OilTag::getSnCode,oilTag.getSnCode()); } queryWrapper.orderByDesc(OilTag::getCreateTime); - return getSuccessResult(this.oilTagService.page(page, queryWrapper)); + ArrayList oilTagVOArrayList = new ArrayList<>(); + IPage page1 = this.oilTagService.page(page, queryWrapper); + List records = page1.getRecords(); + for (OilTag record : records) { + Integer oilTagId = record.getId(); + LambdaQueryWrapper queryWrapper1 = new LambdaQueryWrapper<>(); + queryWrapper1.eq(TagCodeRecord::getOilTagId,oilTagId); + TagCodeRecord one = tagCodeRecordService.getOne(queryWrapper1); + OilTagVO oilTagVO = new OilTagVO(); + BeanUtils.copyProperties(record,oilTagVO); + if (ObjectUtils.isNotEmpty(one)){ + oilTagVO.setStoreName(one.getStoreName()); + } + + oilTagVOArrayList.add(oilTagVO); + } + page1.setRecords(oilTagVOArrayList); + return getSuccessResult(page1); } /** @@ -103,7 +125,20 @@ public class OilTagController extends BaseController { */ @DeleteMapping("{id}") public ResponseObject delete(@PathVariable("id") Long id) { - return getSuccessResult(this.oilTagService.removeById(id)); + OilTag oilTag = this.oilTagService.getById(id); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(TagCodeRecord::getOilTagId,oilTag.getId()); + TagCodeRecord tagCodeRecord = this.tagCodeRecordService.getOne(queryWrapper); + if (ObjectUtils.isNotEmpty(tagCodeRecord.getStaffId())){ + return getSuccessResult("该码牌已绑定员工,请先解绑员工!"); + }else { + this.tagCodeRecordService.removeById(tagCodeRecord.getId()); + oilTag.setStatus("0"); + this.oilTagService.updateById(oilTag); + return getSuccessResult("解绑成功!"); + } + /* TagCodeRecord tagCodeRecord = this.tagCodeRecordService.getById(id); + return getSuccessResult(this.oilTagService.removeById(id));*/ }