Commit 94b72cae authored by 高建强's avatar 高建强

item:巡查数据-站端与中心级数据同步,新增同步开关

parent a09cf9f3
......@@ -52,6 +52,8 @@ public class AcceptEquipmentRules {
@Autowired
private CheckInputMapper checkInputMapper;
@Value("${dataSync.patrol.emqx.switch}")
private Boolean patrolSyncSwitch;
public void getContent(
String itemNo,
......@@ -133,17 +135,19 @@ public class AcceptEquipmentRules {
checkInput.setIsOk(CheckStatusEnum.UNQUALIFIED.getCode());
}
checkInputDao.save(checkInput);
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
Map<String, Object> map = new HashMap<>();
map.put("id", checkInput.getId());
List<CheckInputSyncBo> checkInputSyncBoList = checkInputMapper.getCheckInputSyncBoList(map);
patrolDataSyncService.checkInputBoDataSync(checkInputSyncBoList);
}
});
if (patrolSyncSwitch) {
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
Map<String, Object> map = new HashMap<>();
map.put("id", checkInput.getId());
List<CheckInputSyncBo> checkInputSyncBoList = checkInputMapper.getCheckInputSyncBoList(map);
patrolDataSyncService.checkInputBoDataSync(checkInputSyncBoList);
}
});
}
log.info(checkInput.getPointClassifyName()+"规则校验返回结果修改成功");
}
}
......@@ -155,6 +155,9 @@ public class CheckServiceImpl implements ICheckService {
@Autowired
private CheckInputMapper checkInputMapper;
@Value("${dataSync.patrol.emqx.switch}")
private Boolean patrolSyncSwitch;
// @Value("${file.ip}")
// private String fileIp;
//
......@@ -221,14 +224,16 @@ public class CheckServiceImpl implements ICheckService {
checkDao.save(check);
checkShotDao.saveAll(imgList);
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
patrolDataSyncService.checkDataSync(check);
patrolDataSyncService.checkShotDataSync(imgList);
}
});
if (patrolSyncSwitch) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
patrolDataSyncService.checkDataSync(check);
patrolDataSyncService.checkShotDataSync(imgList);
}
});
}
}
@Override
......@@ -447,17 +452,19 @@ public class CheckServiceImpl implements ICheckService {
updateTaskStatus(plan.getId(), null);
}
}
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
Map<String, Object> map = new HashMap<>();
map.put("idList", checkInputList.stream().map(CheckInput::getId).collect(Collectors.toList()));
List<CheckInputSyncBo> checkInputSyncBoList = checkInputMapper.getCheckInputSyncBoList(map);
patrolDataSyncService.checkInputBoDataSync(checkInputSyncBoList);
}
});
if (patrolSyncSwitch) {
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
Map<String, Object> map = new HashMap<>();
map.put("idList", checkInputList.stream().map(CheckInput::getId).collect(Collectors.toList()));
List<CheckInputSyncBo> checkInputSyncBoList = checkInputMapper.getCheckInputSyncBoList(map);
patrolDataSyncService.checkInputBoDataSync(checkInputSyncBoList);
}
});
}
return new CheckDto(check.getId(), unqualifiedcheckItemList);
} catch (Exception e) {
e.printStackTrace();
......@@ -694,27 +701,23 @@ public class CheckServiceImpl implements ICheckService {
}
CheckDto checkDto= new CheckDto(check.getId(), unqualifiedcheckItemList);
// 巡检站端与中心级数据同步
Check finalCheck = check;
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
patrolDataSyncService.checkDataSync(finalCheck);
patrolDataSyncService.checkInputDataSync(checkInputList);
}
});
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
Map<String, Object> map = new HashMap<>();
map.put("idList", checkInputList.stream().map(CheckInput::getId).collect(Collectors.toList()));
List<CheckInputSyncBo> checkInputSyncBoList = checkInputMapper.getCheckInputSyncBoList(map);
patrolDataSyncService.checkInputBoDataSync(checkInputSyncBoList);
}
});
if (patrolSyncSwitch) {
// 巡检站端与中心级数据同步
Check finalCheck = check;
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
patrolDataSyncService.checkDataSync(finalCheck);
patrolDataSyncService.checkInputDataSync(checkInputList);
Map<String, Object> map = new HashMap<>();
map.put("idList", checkInputList.stream().map(CheckInput::getId).collect(Collectors.toList()));
List<CheckInputSyncBo> checkInputSyncBoList = checkInputMapper.getCheckInputSyncBoList(map);
patrolDataSyncService.checkInputBoDataSync(checkInputSyncBoList);
}
});
}
return checkDto;
} catch (Exception e) {
e.printStackTrace();
......
......@@ -218,6 +218,9 @@ public class LatentDangerServiceImpl implements ILatentDangerService {
@Value("${emergency.command.section.id}")
private String emergencyCommandSectionId;
@Value("${dataSync.patrol.emqx.switch}")
private Boolean patrolSyncSwitch;
@Transactional
@Override
public CommonResponse saveNormal(LatentDangerNormalParam latentDangerParam, String userId, String userRealName, String departmentId, String departmentName, String companyId, String orgCode, RoleBo role) {
......@@ -390,17 +393,19 @@ public class LatentDangerServiceImpl implements ILatentDangerService {
private void updateCheckInputDangerState(Long id, int code) {
latentDangerMapper.updateCheckInputDangerState(id, code);
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
Map<String, Object> map = new HashMap<>();
map.put("id", id);
List<CheckInputSyncBo> checkInputSyncBoList = checkInputMapper.getCheckInputSyncBoList(map);
patrolDataSyncService.checkInputBoDataSync(checkInputSyncBoList);
}
});
if (patrolSyncSwitch) {
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
Map<String, Object> map = new HashMap<>();
map.put("id", id);
List<CheckInputSyncBo> checkInputSyncBoList = checkInputMapper.getCheckInputSyncBoList(map);
patrolDataSyncService.checkInputBoDataSync(checkInputSyncBoList);
}
});
}
}
private String buildLocalHost() {
......
......@@ -34,6 +34,7 @@ public class PatrolDataSyncServiceImpl implements IPatrolDataSyncService {
try {
String message = buildSyncMessage(PatrolDataSyncTopicEnum.CHECK.getTopic(), check);
webMqttComponent.publish(PatrolDataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), message);
webMqttComponent.publish(PatrolDataSyncTopicEnum.CHECK.getTopic(), JSONObject.toJSONString(check));
String isOk = check.getIsOk();
long taskDetailId = check.getPlanTaskDetailId();
List<PlanTaskDetail> planTaskDetailList = planTaskDetailDao.findAllByIdAndStatus(taskDetailId, isOk);
......@@ -42,6 +43,7 @@ public class PatrolDataSyncServiceImpl implements IPatrolDataSyncService {
String detailMessage = buildSyncMessage(PatrolDataSyncTopicEnum.PLAN_TASK_DETAIL.getTopic(), x);
webMqttComponent.publish(PatrolDataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), detailMessage);
});
webMqttComponent.publish(PatrolDataSyncTopicEnum.PLAN_TASK_DETAIL.getTopic(), JSONObject.toJSONString(planTaskDetailList));
}
} catch (Exception e) {
log.error("站端与中心级巡检数据【check或planTaskDetail】同步推送失败-----------" + e.getMessage());
......@@ -64,8 +66,10 @@ public class PatrolDataSyncServiceImpl implements IPatrolDataSyncService {
String detailMessage = buildSyncMessage(PatrolDataSyncTopicEnum.PLAN_TASK_DETAIL.getTopic(), x);
webMqttComponent.publish(PatrolDataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), detailMessage);
});
webMqttComponent.publish(PatrolDataSyncTopicEnum.PLAN_TASK_DETAIL.getTopic(), JSONObject.toJSONString(planTaskDetailList));
}
});
webMqttComponent.publish(PatrolDataSyncTopicEnum.CHECK.getTopic(), JSONObject.toJSONString(checkList));
} catch (Exception e) {
log.error("站端与中心级巡检数据【check或planTaskDetail】同步推送失败-----------" + e.getMessage());
}
......@@ -80,6 +84,7 @@ public class PatrolDataSyncServiceImpl implements IPatrolDataSyncService {
String message = buildSyncMessage(PatrolDataSyncTopicEnum.CHECK_INPUT.getTopic(), x);
webMqttComponent.publish(PatrolDataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), message);
});
webMqttComponent.publish(PatrolDataSyncTopicEnum.CHECK_INPUT.getTopic(), JSONObject.toJSONString(checkInputList));
}
} catch (Exception e) {
log.error("站端与中心级巡检数据【checkInput】同步推送失败-----------" + e.getMessage());
......@@ -94,6 +99,7 @@ public class PatrolDataSyncServiceImpl implements IPatrolDataSyncService {
String message = buildSyncMessage(PatrolDataSyncTopicEnum.CHECK_SHOT.getTopic(), x);
webMqttComponent.publish(PatrolDataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), message);
});
webMqttComponent.publish(PatrolDataSyncTopicEnum.CHECK_SHOT.getTopic(), JSONObject.toJSONString(checkShotList));
}
} catch (Exception e) {
log.error("站端与中心级巡检数据【checkShot】同步推送失败-----------" + e.getMessage());
......@@ -106,6 +112,7 @@ public class PatrolDataSyncServiceImpl implements IPatrolDataSyncService {
if (checkInputSyncBo != null) {
String message = buildSyncMessage(PatrolDataSyncTopicEnum.CHECK_INPUT_BO.getTopic(), checkInputSyncBo);
webMqttComponent.publish(PatrolDataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), message);
webMqttComponent.publish(PatrolDataSyncTopicEnum.CHECK_INPUT_BO.getTopic(), JSONObject.toJSONString(checkInputSyncBo));
}
} catch (Exception e) {
log.error("站端与中心级巡检数据【CheckInputSyncBo】同步推送失败-----------" + e.getMessage());
......@@ -120,6 +127,7 @@ public class PatrolDataSyncServiceImpl implements IPatrolDataSyncService {
String message = buildSyncMessage(PatrolDataSyncTopicEnum.CHECK_INPUT_BO.getTopic(), x);
webMqttComponent.publish(PatrolDataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), message);
});
webMqttComponent.publish(PatrolDataSyncTopicEnum.CHECK_INPUT_BO.getTopic(), JSONObject.toJSONString(checkInputSyncBoList));
}
} catch (Exception e) {
log.error("站端与中心级巡检数据【CheckInputSyncBo】同步推送失败-----------" + e.getMessage());
......@@ -130,8 +138,9 @@ public class PatrolDataSyncServiceImpl implements IPatrolDataSyncService {
public void planTaskDataSync(PlanTask planTask) {
try {
if (planTask != null) {
String message = buildSyncMessage(PatrolDataSyncTopicEnum.CHECK_INPUT_BO.getTopic(), planTask);
String message = buildSyncMessage(PatrolDataSyncTopicEnum.PLAN_TASK.getTopic(), planTask);
webMqttComponent.publish(PatrolDataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), message);
webMqttComponent.publish(PatrolDataSyncTopicEnum.PLAN_TASK.getTopic(), JSONObject.toJSONString(planTask));
}
} catch (Exception e) {
log.error("站端与中心级巡检数据【planTask】同步推送失败-----------" + e.getMessage());
......@@ -146,6 +155,7 @@ public class PatrolDataSyncServiceImpl implements IPatrolDataSyncService {
String message = buildSyncMessage(PatrolDataSyncTopicEnum.PLAN_TASK.getTopic(), x);
webMqttComponent.publish(PatrolDataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), message);
});
webMqttComponent.publish(PatrolDataSyncTopicEnum.PLAN_TASK.getTopic(), JSONObject.toJSONString(planTaskList));
}
} catch (Exception e) {
log.error("站端与中心级巡检数据【PlanTask】同步推送失败-----------" + e.getMessage());
......
......@@ -57,6 +57,7 @@ import org.apache.commons.compress.utils.Sets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Service;
......@@ -130,6 +131,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
@Autowired
private IPatrolDataSyncService patrolDataSyncService;
@Value("${dataSync.patrol.emqx.switch}")
private Boolean patrolSyncSwitch;
private final String PATROL_PLAN_TASK_KEY = "PATROL_PLAN_ID:";
private final String packageId = "消息/addCheckRule";
......@@ -855,14 +859,16 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
paramMap.put("next_gen_date", DateUtil.formatDatrToStr(now, "yyyy-MM-dd"));
}
planMapper.updPlanStatusOrGenDate(paramMap);// 更新下次任务生成日期
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
patrolDataSyncService.planTaskDataSync(planTaskList);
}
});
if (patrolSyncSwitch) {
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
patrolDataSyncService.planTaskDataSync(planTaskList);
}
});
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RuntimeException(e.getMessage());
......@@ -1053,14 +1059,16 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
paramMap.put("next_gen_date", DateUtil.formatDatrToStr(now, "yyyy-MM-dd"));
}
planMapper.updPlanStatusOrGenDate(paramMap);// 更新下次任务生成日期
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
patrolDataSyncService.planTaskDataSync(planTaskList);
}
});
if (patrolSyncSwitch) {
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
patrolDataSyncService.planTaskDataSync(planTaskList);
}
});
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
......
......@@ -37,6 +37,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.*;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
......@@ -108,6 +109,9 @@ public class PointServiceImpl implements IPointService {
@Autowired
private IPatrolDataSyncService patrolDataSyncService;
@Value("${dataSync.patrol.emqx.switch}")
private Boolean patrolSyncSwitch;
@Override
@Transactional
public Point addPoint(PointParam pointParam) {
......@@ -668,14 +672,16 @@ public class PointServiceImpl implements IPointService {
iPlanTaskDetailDao.deletePlanTaskDetailByPointId(idList); // 删除p_plan_task_detail相关行
iPointDao.delPointById(idList);
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
patrolDataSyncService.planTaskDataSync(planTaskList);
}
});
if (patrolSyncSwitch) {
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
patrolDataSyncService.planTaskDataSync(planTaskList);
}
});
}
return idList;
}
......
......@@ -96,6 +96,9 @@ public class JobService implements IJobService {
@Autowired
JcsFeignClient jcsFeignClient;
@Value("${dataSync.patrol.emqx.switch}")
private Boolean patrolSyncSwitch;
@Override
@Transactional
......@@ -379,18 +382,20 @@ public class JobService implements IJobService {
} catch (Exception e) {
log.error("数字换流站页面推送失败-----------" + e.getMessage());
}
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
patrolDataSyncService.checkDataSync(checkList);
Map<String, Object> map = new HashMap<>();
map.put("idList", checkInputIdList);
List<CheckInputSyncBo> checkInputSyncBoList = checkInputMapper.getCheckInputSyncBoList(map);
patrolDataSyncService.checkInputBoDataSync(checkInputSyncBoList);
}
});
if (patrolSyncSwitch) {
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
patrolDataSyncService.checkDataSync(checkList);
Map<String, Object> map = new HashMap<>();
map.put("idList", checkInputIdList);
List<CheckInputSyncBo> checkInputSyncBoList = checkInputMapper.getCheckInputSyncBoList(map);
patrolDataSyncService.checkInputBoDataSync(checkInputSyncBoList);
}
});
}
}
private void removeJob(String jobName) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment