|
@@ -1,16 +1,25 @@
|
|
|
package com.care.bigscreen.service.impl;
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.care.bigscreen.entity.StOrganization;
|
|
|
+import com.care.bigscreen.entity.StStation;
|
|
|
import com.care.bigscreen.mapper.BigSreenMapper;
|
|
|
+import com.care.bigscreen.mapper.StOrganizationMapper;
|
|
|
+import com.care.bigscreen.mapper.StStationMapper;
|
|
|
import com.care.bigscreen.service.BigScreenService;
|
|
|
import com.care.bigscreen.vo.*;
|
|
|
import com.care.bigscreen.websocket.BigScreenWebSocketEndpoint;
|
|
|
import com.care.common.service.CareStationService;
|
|
|
+import com.care.common.util.DomainEquals;
|
|
|
import com.care.common.vo.PageResVO;
|
|
|
import com.care.common.util.PageUtil;
|
|
|
+import org.apache.logging.log4j.LogManager;
|
|
|
+import org.apache.logging.log4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@@ -22,11 +31,20 @@ import java.util.List;
|
|
|
*/
|
|
|
@Service
|
|
|
public class BigScreenServiceImpl implements BigScreenService {
|
|
|
+ private static final Logger logger = LogManager.getLogger(BigScreenServiceImpl.class);
|
|
|
|
|
|
@Autowired
|
|
|
private BigSreenMapper bigSreenMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private CareStationService careStationService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StStationMapper stStationMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StOrganizationMapper stOrganizationMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 大屏统计查询
|
|
|
* @return 搜索符合条件的大屏统计数据
|
|
@@ -176,6 +194,67 @@ public class BigScreenServiceImpl implements BigScreenService {
|
|
|
*/
|
|
|
@Override
|
|
|
public void pushRtEventFlag(String stationId) {
|
|
|
+ //触发统计
|
|
|
+ exeStatistics();
|
|
|
BigScreenWebSocketEndpoint.sendMsgToFront(stationId,"rt_event_happen");
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 进行统计
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void exeStatistics(){
|
|
|
+ try {
|
|
|
+ List<StStation> stStationList = stStationMapper.selectStStationList();
|
|
|
+ for(StStation stStation : stStationList) {
|
|
|
+ QueryWrapper<StStation> queryWrapper = new QueryWrapper<>();
|
|
|
+ //查询表中是否存在
|
|
|
+ queryWrapper.lambda().eq(StStation::getStationId, stStation.getStationId());
|
|
|
+ StStation stStationDb = stStationMapper.selectOne(queryWrapper);
|
|
|
+ if (stStationDb == null) { //插入
|
|
|
+ Date now = new Date();
|
|
|
+ stStation.setCreateTime(now);
|
|
|
+ stStation.setModifyTime(now);
|
|
|
+ stStationMapper.insert(stStation);
|
|
|
+ } else { //更新
|
|
|
+ stStation.setCreateTime(stStationDb.getCreateTime());
|
|
|
+ stStation.setModifyTime(stStationDb.getModifyTime());
|
|
|
+ stStation.setId(stStationDb.getId());
|
|
|
+ //其余属性不一样的就更新
|
|
|
+ if (!DomainEquals.domainEquals(stStation,stStationDb)){
|
|
|
+ Date now = new Date();
|
|
|
+ stStation.setModifyTime(now);
|
|
|
+ stStationMapper.updateById(stStation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<StOrganization> stOrganizationList = stOrganizationMapper.selectStOrganizationList();
|
|
|
+ for(StOrganization stOrganization : stOrganizationList) {
|
|
|
+ QueryWrapper<StOrganization> queryWrapper = new QueryWrapper<>();
|
|
|
+ //查询表中是否存在
|
|
|
+ queryWrapper.lambda().eq(StOrganization::getOrgId, stOrganization.getOrgId());
|
|
|
+ StOrganization stOrganizationDb = stOrganizationMapper.selectOne(queryWrapper);
|
|
|
+ if (stOrganizationDb == null) { //插入
|
|
|
+ Date now = new Date();
|
|
|
+ stOrganization.setCreateTime(now);
|
|
|
+ stOrganization.setModifyTime(now);
|
|
|
+ stOrganizationMapper.insert(stOrganization);
|
|
|
+ } else { //更新
|
|
|
+ stOrganization.setCreateTime(stOrganizationDb.getCreateTime());
|
|
|
+ stOrganization.setModifyTime(stOrganizationDb.getModifyTime());
|
|
|
+ stOrganization.setId(stOrganizationDb.getId());
|
|
|
+ //其余属性不一样的就更新
|
|
|
+ if (!DomainEquals.domainEquals(stOrganization,stOrganizationDb)) {
|
|
|
+ Date now = new Date();
|
|
|
+ stOrganization.setModifyTime(now);
|
|
|
+ stOrganizationMapper.updateById(stOrganization);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("统计计算出错:{}", e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|