hecheng лет назад: 3
Родитель
Сommit
22246aa628

+ 2 - 2
zd-modules/zd-bottle-parent/zd-bottle-api/src/main/java/com/zd/bottle/domain/UsegasApply.java

@@ -46,11 +46,11 @@ public class UsegasApply extends BaseBean {
     @NotNull(message = "联系方式不能为空!")
     private String phone;
 
-    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     @ApiModelProperty("期限开始")
     private Date startTime;
 
-    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     @ApiModelProperty("期限结束")
     @NotNull(message = "使用期限不能为空!")
     private Date endTime;

+ 29 - 17
zd-modules/zd-bottle-parent/zd-bottle/src/main/java/com/zd/bottle/service/impl/AlarmRecordServiceImpl.java

@@ -5,11 +5,13 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.zd.bottle.domain.AlarmRecord;
 import com.zd.bottle.domain.BottleStorage;
 import com.zd.bottle.domain.RfidTag;
+import com.zd.bottle.domain.UsegasApply;
 import com.zd.bottle.mapper.AlarmRecordMapper;
 import com.zd.bottle.service.AlarmRecordService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zd.bottle.service.BottleStorageService;
 import com.zd.bottle.service.RfidTagService;
+import com.zd.bottle.service.UsegasApplyService;
 import com.zd.bottle.vo.AlarmRecordVo;
 import com.zd.bottle.vo.BottleStorageVo;
 import com.zd.common.core.constant.HttpStatus;
@@ -74,6 +76,9 @@ public class AlarmRecordServiceImpl extends ServiceImpl<AlarmRecordMapper, Alarm
     @Resource
     private RfidTagService tagService;
 
+    @Resource
+    private UsegasApplyService applyService;
+
     private static final String MSG_MATCH = "==================>{},{}";
 
     @Override
@@ -119,29 +124,36 @@ public class AlarmRecordServiceImpl extends ServiceImpl<AlarmRecordMapper, Alarm
         wrapper.eq(BottleStorage::getElectronicTag, rfidTag.getId());
         BottleStorage bottleStorage = storageService.getOne(wrapper);
         if (bottleStorage != null) {
-            Long id = bottleStorage.getId();
-            String key = FRID_CODE + electronicTag + id;
-            String frid = redisService.getCacheObject(key);
-            if (frid != null) {
-                return true;
+            String airName = bottleStorage.getAirName();
+            LambdaQueryWrapper<UsegasApply> lambdaQuery = Wrappers.lambdaQuery(UsegasApply.class);
+            lambdaQuery.eq(UsegasApply::getUseGasName,airName)
+                    .eq(UsegasApply::getEndTime,Calendar.getInstance().getTime()).eq(UsegasApply::getLeadAuditStaus,1);
+            List<UsegasApply> applies = applyService.list(lambdaQuery);
+            if (applies.isEmpty()){
+                Long id = bottleStorage.getId();
+                String key = FRID_CODE + electronicTag + id;
+                String frid = redisService.getCacheObject(key);
+                if (frid != null) {
+                    return true;
+                }
+                // 发送报警消息
+                sendAlarm(bottleStorage);
+                redisService.setCacheObject(key, electronicTag, 300L, TimeUnit.SECONDS);
+                AlarmRecord alarmRecord = new AlarmRecord();
+                alarmRecord.setElectronicTag(electronicTag)
+                        .setAlarmTime(Calendar.getInstance().getTime())
+                        .setMasterId(id)
+                        .setType(1)
+                        .setProductType(1)
+                        .setDeptId(bottleStorage.getDeptId());
+                return save(alarmRecord);
             }
-            // 发送报警消息
-            sendAlarm(bottleStorage);
-            redisService.setCacheObject(key, electronicTag, 300L, TimeUnit.SECONDS);
-            AlarmRecord alarmRecord = new AlarmRecord();
-            alarmRecord.setElectronicTag(electronicTag)
-                    .setAlarmTime(Calendar.getInstance().getTime())
-                    .setMasterId(id)
-                    .setType(1)
-                    .setProductType(1)
-                    .setDeptId(bottleStorage.getDeptId());
-            return save(alarmRecord);
         } else {
             if (hardware != null) {
                 log.info(MSG_MATCH, electronicTag, "标签未绑定气瓶");
             }
-            return false;
         }
+        return false;
     }
 
     private void sendAlarm(BottleStorage storage) {