Commit 061d3b27 authored by 高建强's avatar 高建强

item:巡查数据-站端与中心级数据同步

parent c7f385f5
package com.yeejoin.amos.patrol.common.enums;
public enum PatrolDataSyncTopicEnum {
EQM_PATROL_CREATED("check", "eqm.patrol.created"),
CHECK("check", "patrol/sync/check"),
CHECK_INPUT("checkInput", "patrol/sync/checkInput"),
CHECK_SHOT("checkShot", "patrol/sync/checkShot"),
PLAN_TASK_DETAIL("planTaskDetail", "patrol/sync/planTaskDetail");
PLAN_TASK("planTask", "patrol/sync/planTask"),
PLAN_TASK_DETAIL("planTaskDetail", "patrol/sync/planTaskDetail"),
CHECK_INPUT_BO("checkInputBo", "patrol/sync/checkShotBo");
private String type;
private String topic;
......
package com.yeejoin.amos.patrol.business.bo;
import lombok.Data;
import java.util.Date;
/**
* 基本实体扩展类
*/
@Data
public class BasicEntityBo {
private long id;
private Date createDate;
}
package com.yeejoin.amos.patrol.business.bo;
import lombok.Data;
/**
* @ProjectName: YeeAMOSPatrolRoot
* @Package: com.yeejoin.amos.patrol.business.bo
* @ClassName: CheckInputBo
* @Author: Jianqiang Gao
* @Description: CheckInputBo
* @Date: 2022/6/1 9:30
* @Version: 1.0
*/
@Data
public class CheckInputSyncBo extends BasicEntityBo {
/**
* 巡检记录id
*/
private Long checkId;
/**
* 检查项id
*/
private Long inputId;
/**
* 巡检点检查项
*/
private Long routePointItemId;
/**
* 是否合格
*/
private String isOk;
/**
* 序号
*/
private int orderNo;
/**
* 权限系统org code
*/
private String orgCode;
/**
* 检查点分类id
*/
private Long pointClassifyId;
/**
* 检查点分类名称
*/
private String pointClassifyName;
/**
* 评分
*/
private int score;
/**
* 备注
*/
private String remark;
private String bizOrgName;
private String bizOrgCode;
private String pointName;
private String pointId;
private String inputName;
private String inputValue;
private String checkStatus;
private String planName;
private String planId;
private String routeName;
private String routeId;
private String userName;
private String userId;
private String depName;
private String depId;
private String eqName;
private String eqId;
private String eqCode;
private String systemName;
private String planTaskId;
private String planCompletionTime;
private String equipmentTypeCode;
private String companyCode;
private String inputCode;
private String pointCode;
private String buildName;
private String buildCode;
private String protectedObjectCode;
private String protectedObjectName;
private String checkTime;
}
\ No newline at end of file
package com.yeejoin.amos.patrol.business.dao.mapper;
import com.yeejoin.amos.patrol.business.bo.CheckInputSyncBo;
import com.yeejoin.amos.patrol.business.dto.InputCheckDto;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface CheckInputMapper extends BaseMapper {
InputCheckDto getByCheckIdAndItemId(@Param(value = "checkId") Long checkId, @Param(value = "itemId") Long itemId);
InputCheckDto getByCheckIdAndItemIdAndRoutePointItemId(@Param(value = "checkId") Long checkId, @Param(value =
"itemId") Long itemId, @Param(value = "routePointItemId") Long routePointItemId, @Param(value = "checkInputId") Long checkInputId);
List<CheckInputSyncBo> getCheckInputSyncBoList(Map<String, Object> map);
}
......@@ -3,9 +3,12 @@ package com.yeejoin.amos.patrol.business.service.action;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.patrol.business.bo.CheckInputSyncBo;
import com.yeejoin.amos.patrol.business.dao.mapper.CheckInputMapper;
import com.yeejoin.amos.patrol.business.dao.repository.ICheckInputDao;
import com.yeejoin.amos.patrol.business.dao.repository.IInputItemDao;
import com.yeejoin.amos.patrol.business.entity.mybatis.EquipmentInputItemRo;
import com.yeejoin.amos.patrol.business.service.intfc.IPatrolDataSyncService;
import com.yeejoin.amos.patrol.common.enums.CheckStatusEnum;
import com.yeejoin.amos.patrol.common.enums.YesOrNoEnum;
import com.yeejoin.amos.patrol.dao.entity.CheckInput;
......@@ -16,7 +19,12 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
......@@ -38,6 +46,12 @@ public class AcceptEquipmentRules {
@Value("${input.statute.prefix}")
private String statutePre;
@Autowired
private IPatrolDataSyncService patrolDataSyncService;
@Autowired
private CheckInputMapper checkInputMapper;
public void getContent(
String itemNo,
......@@ -119,6 +133,17 @@ 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);
}
});
log.info(checkInput.getPointClassifyName()+"规则校验返回结果修改成功");
}
}
......@@ -19,6 +19,8 @@ import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.MessageModel;
import com.yeejoin.amos.patrol.business.bo.CheckInputSyncBo;
import com.yeejoin.amos.patrol.business.dao.mapper.*;
import com.yeejoin.amos.patrol.business.feign.JcsFeignClient;
import com.yeejoin.amos.patrol.business.service.intfc.IPatrolDataSyncService;
import com.yeejoin.amos.patrol.dao.entity.Plan;
......@@ -45,10 +47,6 @@ import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.dao.mapper.CheckMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskDetailMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.RouteMapper;
import com.yeejoin.amos.patrol.business.dao.repository.ICatalogTreeDao;
import com.yeejoin.amos.patrol.business.dao.repository.ICheckDao;
import com.yeejoin.amos.patrol.business.dao.repository.ICheckInputDao;
......@@ -154,6 +152,9 @@ public class CheckServiceImpl implements ICheckService {
@Autowired
private IPatrolDataSyncService patrolDataSyncService;
@Autowired
private CheckInputMapper checkInputMapper;
// @Value("${file.ip}")
// private String fileIp;
//
......@@ -446,6 +447,17 @@ 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);
}
});
return new CheckDto(check.getId(), unqualifiedcheckItemList);
} catch (Exception e) {
e.printStackTrace();
......@@ -692,7 +704,17 @@ public class CheckServiceImpl implements ICheckService {
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);
}
});
return checkDto;
} catch (Exception e) {
e.printStackTrace();
......
......@@ -13,6 +13,7 @@ import com.yeejoin.amos.boot.biz.common.bo.RoleBo;
import com.yeejoin.amos.boot.biz.common.service.impl.WorkflowExcuteServiceImpl;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import com.yeejoin.amos.patrol.business.bo.CheckInputSyncBo;
import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.dao.mapper.CheckInputMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.LatentDangerFlowRecordMapper;
......@@ -45,6 +46,7 @@ import com.yeejoin.amos.patrol.business.param.LatentDangerPatrolItemParam;
import com.yeejoin.amos.patrol.business.param.LatentDangerPatrolParam;
import com.yeejoin.amos.patrol.business.param.PageParam;
import com.yeejoin.amos.patrol.business.service.intfc.ILatentDangerService;
import com.yeejoin.amos.patrol.business.service.intfc.IPatrolDataSyncService;
import com.yeejoin.amos.patrol.business.service.intfc.IRiskJudgmentTaskService;
import com.yeejoin.amos.patrol.business.util.CommonResponse;
import com.yeejoin.amos.patrol.business.util.CommonResponseUtil;
......@@ -73,10 +75,7 @@ import com.yeejoin.amos.patrol.core.async.AsyncTask;
import com.yeejoin.amos.patrol.core.common.request.LatentDangerResultPushSpcRequest;
import com.yeejoin.amos.patrol.core.common.response.DangerListResponse;
import com.yeejoin.amos.patrol.core.util.StringUtil;
import com.yeejoin.amos.patrol.dao.entity.Check;
import com.yeejoin.amos.patrol.dao.entity.CheckShot;
import com.yeejoin.amos.patrol.dao.entity.InputItem;
import com.yeejoin.amos.patrol.dao.entity.PointClassify;
import com.yeejoin.amos.patrol.dao.entity.*;
import com.yeejoin.amos.patrol.exception.YeeException;
import com.yeejoin.amos.patrol.feign.RemoteSecurityService;
import com.yeejoin.amos.patrol.mqtt.WebMqttComponent;
......@@ -92,6 +91,8 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
......@@ -181,6 +182,9 @@ public class LatentDangerServiceImpl implements ILatentDangerService {
@Autowired
private WorkflowExcuteServiceImpl workflowExecuteService;
@Autowired
private IPatrolDataSyncService patrolDataSyncService;
private static final String permissionType = "SUBMENU";
private static final String acctivePermissionType = "activitiItem";
......@@ -386,6 +390,17 @@ 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);
}
});
}
private String buildLocalHost() {
......
package com.yeejoin.amos.patrol.business.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.patrol.business.bo.CheckInputSyncBo;
import com.yeejoin.amos.patrol.business.dao.repository.IPlanTaskDetailDao;
import com.yeejoin.amos.patrol.business.service.intfc.IPatrolDataSyncService;
import com.yeejoin.amos.patrol.common.enums.PatrolDataSyncTopicEnum;
......@@ -15,7 +16,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Async
......@@ -32,12 +35,16 @@ public class PatrolDataSyncServiceImpl implements IPatrolDataSyncService {
public void checkDataSync(Check check) {
if (check != null) {
try {
webMqttComponent.publish(PatrolDataSyncTopicEnum.CHECK.getTopic(), JSONObject.toJSONString(check));
String message = buildSyncMessage(PatrolDataSyncTopicEnum.CHECK.getTopic(), check);
webMqttComponent.publish(PatrolDataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), message);
String isOk = check.getIsOk();
long taskDetailId = check.getPlanTaskDetailId();
List<PlanTaskDetail> planTaskDetailList = planTaskDetailDao.findAllByIdAndStatus(taskDetailId, isOk);
if (CollectionUtils.isNotEmpty(planTaskDetailList)) {
planTaskDetailList.forEach(x -> webMqttComponent.publish(PatrolDataSyncTopicEnum.PLAN_TASK_DETAIL.getTopic(), JSONObject.toJSONString(x)));
planTaskDetailList.forEach(x -> {
String detailMessage = buildSyncMessage(PatrolDataSyncTopicEnum.PLAN_TASK_DETAIL.getTopic(), x);
webMqttComponent.publish(PatrolDataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), detailMessage);
});
}
} catch (Exception e) {
log.error("站端与中心级巡检数据【check或planTaskDetail】同步推送失败-----------" + e.getMessage());
......@@ -46,10 +53,36 @@ public class PatrolDataSyncServiceImpl implements IPatrolDataSyncService {
}
@Override
public void checkDataSync(List<Check> checkList) {
if (CollectionUtils.isNotEmpty(checkList)) {
try {
checkList.forEach(check -> {
String message = buildSyncMessage(PatrolDataSyncTopicEnum.CHECK.getTopic(), check);
webMqttComponent.publish(PatrolDataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), message);
String isOk = check.getIsOk();
long taskDetailId = check.getPlanTaskDetailId();
List<PlanTaskDetail> planTaskDetailList = planTaskDetailDao.findAllByIdAndStatus(taskDetailId, isOk);
if (CollectionUtils.isNotEmpty(planTaskDetailList)) {
planTaskDetailList.forEach(x -> {
String detailMessage = buildSyncMessage(PatrolDataSyncTopicEnum.PLAN_TASK_DETAIL.getTopic(), x);
webMqttComponent.publish(PatrolDataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), detailMessage);
});
}
});
} catch (Exception e) {
log.error("站端与中心级巡检数据【check或planTaskDetail】同步推送失败-----------" + e.getMessage());
}
}
}
@Override
public void checkInputDataSync(List<CheckInput> checkInputList) {
try {
if (CollectionUtils.isNotEmpty(checkInputList)) {
checkInputList.forEach(x -> webMqttComponent.publish(PatrolDataSyncTopicEnum.CHECK_INPUT.getTopic(), JSONObject.toJSONString(x)));
checkInputList.forEach(x -> {
String message = buildSyncMessage(PatrolDataSyncTopicEnum.CHECK_INPUT.getTopic(), x);
webMqttComponent.publish(PatrolDataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), message);
});
}
} catch (Exception e) {
log.error("站端与中心级巡检数据【checkInput】同步推送失败-----------" + e.getMessage());
......@@ -60,10 +93,46 @@ public class PatrolDataSyncServiceImpl implements IPatrolDataSyncService {
public void checkShotDataSync(List<CheckShot> checkShotList) {
try {
if (CollectionUtils.isNotEmpty(checkShotList)) {
checkShotList.forEach(x -> webMqttComponent.publish(PatrolDataSyncTopicEnum.CHECK_SHOT.getTopic(), JSONObject.toJSONString(x)));
checkShotList.forEach(x -> {
String message = buildSyncMessage(PatrolDataSyncTopicEnum.CHECK_SHOT.getTopic(), x);
webMqttComponent.publish(PatrolDataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), message);
});
}
} catch (Exception e) {
log.error("站端与中心级巡检数据【checkShot】同步推送失败-----------" + e.getMessage());
}
}
@Override
public void checkInputBoDataSync(CheckInputSyncBo checkInputSyncBo) {
try {
if (checkInputSyncBo != null) {
String message = buildSyncMessage(PatrolDataSyncTopicEnum.CHECK_INPUT_BO.getTopic(), checkInputSyncBo);
webMqttComponent.publish(PatrolDataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), message);
}
} catch (Exception e) {
log.error("站端与中心级巡检数据【CheckInputSyncBo】同步推送失败-----------" + e.getMessage());
}
}
@Override
public void checkInputBoDataSync(List<CheckInputSyncBo> checkInputSyncBoList) {
try {
if (CollectionUtils.isNotEmpty(checkInputSyncBoList)) {
checkInputSyncBoList.forEach(x -> {
String message = buildSyncMessage(PatrolDataSyncTopicEnum.CHECK_INPUT_BO.getTopic(), x);
webMqttComponent.publish(PatrolDataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), message);
});
}
} catch (Exception e) {
log.error("站端与中心级巡检数据【CheckInputSyncBo】同步推送失败-----------" + e.getMessage());
}
}
public String buildSyncMessage(String topic, Object object) {
Map<String, Object> map = new HashMap<>();
map.put("topic", topic);
map.put("data", object);
return JSONObject.toJSONString(map);
}
}
package com.yeejoin.amos.patrol.business.service.intfc;
import com.yeejoin.amos.patrol.business.bo.CheckInputSyncBo;
import com.yeejoin.amos.patrol.dao.entity.Check;
import com.yeejoin.amos.patrol.dao.entity.CheckInput;
import com.yeejoin.amos.patrol.dao.entity.CheckShot;
......@@ -17,7 +18,13 @@ public interface IPatrolDataSyncService {
void checkDataSync(Check check);
void checkDataSync(List<Check> checkList);
void checkInputDataSync(List<CheckInput> checkInputList);
void checkShotDataSync(List<CheckShot> checkShotList);
void checkInputBoDataSync(CheckInputSyncBo checkInputSyncBo);
void checkInputBoDataSync(List<CheckInputSyncBo> checkInputSyncBoList);
}
......@@ -57,4 +57,91 @@
</where>
limit 1
</select>
<select id="getCheckInputSyncBoList" resultType="com.yeejoin.amos.patrol.business.bo.CheckInputSyncBo" parameterType="java.util.Map">
<![CDATA[
SELECT
ci.id,
ci.input_name,
ci.input_value,
ci.is_ok AS check_status,
ci.is_ok,
ci.check_id,
ci.create_date,
ci.danger_handle_state,
ci.input_id,
ci.order_no,
ci.point_classify_id,
ci.point_classify_name,
ci.remark,
ci.route_point_item_id,
ci.score,
ci.org_code,
cou.bzOrgCode AS biz_org_code,
cou.biz_org_name AS biz_org_name,
c.point_id,
c.point_name,
c.check_time,
pt.end_time AS `date`,
c.plan_id,
c.plan_name,
c.route_id,
c.route_name,
c.user_id,
c.user_name,
c.dep_id,
c.dep_name,
es.id AS eq_id,
es.`name` eq_name,
es.`code` eq_code,
(
SELECT
GROUP_CONCAT(ffs.`name`)
FROM
f_fire_fighting_system ffs
WHERE
find_in_set(ffs.id, es.system_id)
) AS system_name,
CONCAT(pt.id, '') AS plan_task_id,
pt.end_time AS plan_completion_time,
cou.`code` AS company_code,
es.equipment_code AS equipment_type_code,
pii.item_no AS input_code,
pp.point_no as pointCode,
wws.`code` as buildCode,
wws.full_name as buildName
FROM
p_check_input ci
LEFT JOIN p_input_item pii ON pii.id = ci.input_id
LEFT JOIN p_check c ON c.id = ci.check_id
LEFT JOIN p_point pp ON pp.id = c.point_id
LEFT JOIN p_plan_task pt ON pt.id = c.plan_task_id
LEFT JOIN p_point_classify pc ON pc.id = ci.point_classify_id
LEFT JOIN wl_equipment_specific es ON es.id = pc.equipment_id
LEFT JOIN wl_warehouse_structure wws ON wws.id = pp.risk_source_id
LEFT JOIN (
SELECT
biz_org_name,
biz_org_code bzOrgCode,
amos_org_id,
amos_org_code,
`code`
FROM
cb_org_usr
WHERE
amos_org_code <> ''
AND amos_org_code IS NOT NULL
AND biz_org_type = 'COMPANY'
) cou ON cou.amos_org_code = ci.org_code ]]>
<where>
<if test="id != null">
ci.id = #{id}
</if>
<if test="idList != null and idList.size() >0">
AND ci.id IN
<foreach collection="idList" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
</mapper>
\ No newline at end of file
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