Merge remote-tracking branch 'origin/master'

master
philip 3 years ago
commit 2d88f7836b

@ -3,6 +3,9 @@ package com.foreverwin.mesnac.equip.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.common.util.StringUtil;
import com.foreverwin.mesnac.equip.mapper.ResourceStatusReceiveMapper;
import com.foreverwin.mesnac.equip.model.ResourceStatusReceive;
import com.foreverwin.mesnac.equip.service.ResourceStatusReceiveService;
import com.foreverwin.mesnac.meapi.model.Resrce;
import com.foreverwin.mesnac.meapi.service.ResrceService;
import com.foreverwin.modular.core.exception.BusinessException;
@ -14,6 +17,8 @@ import com.foreverwin.mesnac.equip.model.ResourceFaultReceive;
import com.foreverwin.mesnac.equip.mapper.ResourceFaultReceiveMapper;
import com.foreverwin.mesnac.equip.service.ResourceFaultReceiveService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@ -35,11 +40,15 @@ import java.util.UUID;
@Transactional(rollbackFor = Exception.class)
public class ResourceFaultReceiveServiceImpl extends ServiceImpl<ResourceFaultReceiveMapper, ResourceFaultReceive> implements ResourceFaultReceiveService {
private static Logger logger = LoggerFactory.getLogger(ResourceFaultReceiveServiceImpl.class);
@Autowired
private ResourceFaultReceiveService resourceFaultReceiveService;
@Autowired
private ResrceService resrceService;
@Autowired
private ResourceStatusReceiveService resourceStatusReceiveService;
@Autowired
private ResourceStatusReceiveMapper resourceStatusReceiveMapper;
@Override
public IPage<ResourceFaultReceive> selectPage(FrontPage<ResourceFaultReceive> frontPage, ResourceFaultReceive resourceFaultReceive) {
@ -102,6 +111,30 @@ public class ResourceFaultReceiveServiceImpl extends ServiceImpl<ResourceFaultRe
resourceFaultReceive.setHandle(UUID.randomUUID().toString());
resourceFaultReceiveService.save(resourceFaultReceive);
ResourceStatusReceive resourceStatus = resourceStatusReceiveMapper.getOneByMaxCreateDateTime(site,resource);
if (resourceStatus != null){
resourceStatus.setStatus("WARN");
resourceStatus.setCreateUser(user);
resourceStatus.setCreatedDateTime(resourceStatus.getModifiedDateTime());
resourceStatus.setModifiedDateTime(faultDate);
resourceStatus.setModifyUser(user);
resourceStatusReceiveMapper.updateById(resourceStatus);
}else{
// 数据库录入新数据
ResourceStatusReceive resourceStatusReceive = new ResourceStatusReceive();
resourceStatusReceive.setHandle(UUID.randomUUID().toString());
resourceStatusReceive.setSite(site);
resourceStatusReceive.setResrce(resource);
resourceStatusReceive.setStatus("WARN");
resourceStatusReceive.setCreateUser(user);
resourceStatusReceive.setCreatedDateTime(faultDate);
resourceStatusReceive.setModifyUser(user);
resourceStatusReceive.setModifiedDateTime(faultDate);
resourceStatusReceiveMapper.insert(resourceStatusReceive);
logger.info("设备编号:" + resource + ",为设备状态表记录第一笔数据!");
}
}

@ -98,6 +98,7 @@ public class ResourceStatusReceiveServiceImpl extends ServiceImpl<ResourceStatus
// 获取最新数据
ResourceStatusReceive resourceStatus = resourceStatusReceiveMapper.getOneByMaxCreateDateTime(site,resource);
if (resourceStatus != null){
resourceStatus.setStatus(sendStatus);
resourceStatus.setCreateUser(user);
resourceStatus.setCreatedDateTime(resourceStatus.getModifiedDateTime());
resourceStatus.setModifiedDateTime(dateTime);

Loading…
Cancel
Save