Commit 933e6f8d authored by 高建强's avatar 高建强

Merge branch 'dev_dl_plan6_temp_sync' into develop_dl_plan6_temp

parents 47c133b0 71871411
package com.yeejoin.amos.boot.module.common.api.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
public class OrgUsrSyncDto {
protected Long sequenceNbr;
protected Date recDate;
protected String recUserId;
protected String recUserName;
/**
* 是否删除
*/
public Boolean isDelete = false;
@ApiModelProperty(value = "机构/部门名称")
private String bizOrgName;
@ApiModelProperty(value = "机构编码")
private String bizOrgCode;
@ApiModelProperty(value = "amos中公司/部门ID")
private String amosOrgId;
@ApiModelProperty(value = "amos中公司/部门编码")
private String amosOrgCode;
@ApiModelProperty(value = "机构类型`")
private String bizOrgType;
@ApiModelProperty(value = "所属建筑名称")
private String buildName;
@ApiModelProperty(value = "所属建筑ID")
private String buildId;
@ApiModelProperty(value = "归属机构/部门/人员")
private String parentId;
@ApiModelProperty(value = "扩展属性1")
private String orgExpandAttr1;
@ApiModelProperty(value = "扩展属性2")
private String orgExpandAttr2;
@ApiModelProperty(value = "扩展属性3")
private String orgExpandAttr3;
@ApiModelProperty(value = "扩展属性4")
private String orgExpandAttr4;
private String orgExpandAttr5;
private String orgExpandAttr6;
private String orgExpandAttr7;
private String orgExpandAttr8;
@ApiModelProperty(value = "省市区code,用逗号分隔")
private String pczCode;
@ApiModelProperty(value = "省市区名称,用逗号分隔")
private String pczName;
@ApiModelProperty(value = "省市区名称,用逗号分隔")
private String parentName;
@ApiModelProperty(value = "唯一编号")
private String code;
private String companyBizName;
private String companyBizCode;
private String fireManagementPost;
private String typeCode;
private String certificatesNumber;
private String employeeNumber;
private String telephone;
private String isCertificate;
private String isFirefighters;
private String personImg;
private String jobTitle;
}
package com.yeejoin.amos.boot.module.common.api.enums;
public enum DataSyncTopicEnum {
EQM_PATROL_CREATED("userSync", "emq.user.created"),
ORG_USR("orgUsr", "userSync/sync/orgUsr");
private String type;
private String topic;
DataSyncTopicEnum(String type, String topic) {
this.type = type;
this.topic = topic;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getTopic() {
return topic;
}
public void setTopic(String topic) {
this.topic = topic;
}
}
......@@ -135,4 +135,6 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
List<DynamicFormInstance> checkCertificatesNumber(String certificatesNumber, Long orgUserId);
OrgUsr queryByCompanyCode(@Param("companyCode") String companyCode);
List<OrgUsrSyncDto>getOrgUsrSyncDataList(Map<String, Object> map);
}
package com.yeejoin.amos.boot.module.common.api.service;
/**
* <h1>数据消息数据同步</h1>
*
* @Author Jianqiang Gao
* @Date 2022-11-03 14:27
*/
public interface IDataSyncService {
void OrgUsrSyncDtoDataSync(Long id);
}
......@@ -1077,4 +1077,124 @@ LEFT JOIN (
AND code = #{companyCode}
</if>
</select>
<select id="getOrgUsrSyncDataList" resultType="com.yeejoin.amos.boot.module.common.api.dto.OrgUsrSyncDto">
SELECT
u.*,
case
when u.biz_org_type = 'person'
and (
SELECT
s.biz_org_type
from
cb_org_usr s
WHERE
s.sequence_nbr = u.parent_id) = 'DEPARTMENT'
then (
SELECT
s.biz_org_name
from
cb_org_usr s
WHERE
s.sequence_nbr = (
SELECT
s.parent_id
from
cb_org_usr s
WHERE
s.sequence_nbr = u.parent_id))
when u.biz_org_type = 'person'
and (
SELECT
s.biz_org_type
from
cb_org_usr s
WHERE
s.sequence_nbr = u.parent_id) = 'COMPANY'
then u.parent_name
else u.biz_org_name
end as company_biz_name,
case
when u.biz_org_type = 'person'
and (
SELECT
s.biz_org_type
from
cb_org_usr s
WHERE
s.sequence_nbr = u.parent_id) = 'DEPARTMENT'
then (
SELECT
s.biz_org_code
from
cb_org_usr s
WHERE
s.sequence_nbr = (
SELECT
s.parent_id
from
cb_org_usr s
WHERE
s.sequence_nbr = u.parent_id))
when u.biz_org_type = 'person'
and (
SELECT
s.biz_org_type
from
cb_org_usr s
WHERE
s.sequence_nbr = u.parent_id) = 'COMPANY'
then (
SELECT
s.biz_org_code
from
cb_org_usr s
WHERE
s.sequence_nbr = u.parent_id)
else u.biz_org_code
end as company_biz_code,
cfp.fire_management_post,
cft.type_code,
cf.certificate_number certificatesNumber,
cf.employee_number ,
cf.mobile_phone telephone,
( CASE
WHEN cfp.post_qualification IS NULL THEN 0
ELSE 1
END ) AS is_certificate,
IF
((
SELECT
field_value
FROM
cb_dynamic_form_instance dfi
WHERE
dfi.field_code = 'peopleType'
AND dfi.instance_id = u.sequence_nbr )= 2,
1,
0 ) AS is_firefighters,
(
SELECT
field_value
FROM
cb_dynamic_form_instance dfi
WHERE
dfi.field_code = 'personImg'
AND dfi.instance_id = u.sequence_nbr ) AS personImg,
cfp.job_title
FROM
cb_org_usr u
LEFT JOIN cb_firefighters_post cfp ON
cfp.org_usr_id = u.sequence_nbr
LEFT JOIN cb_firefighters cf ON
cf.org_usr_id = u.sequence_nbr
LEFT JOIN cb_fire_team cft ON
cft.sequence_nbr = cf.fire_team_id
WHERE
u.is_delete = 0
<if test="id != null">
AND u.sequence_nbr = #{id}
</if>
GROUP BY
u.sequence_nbr
</select>
</mapper>
package com.yeejoin.amos.patrol.common.enums;
public enum PatrolDataSyncTopicEnum {
EQM_PATROL_CREATED("patrolSync", "emq.patrol.created"),
CHECK("check", "patrol/sync/check"),
CHECK_INPUT("checkInput", "patrol/sync/checkInput"),
CHECK_SHOT("checkShot", "patrol/sync/checkShot"),
PLAN_TASK("planTask", "patrol/sync/planTask"),
PLAN_TASK_DETAIL("planTaskDetail", "patrol/sync/planTaskDetail"),
CHECK_INPUT_BO("checkInputBo", "patrol/sync/checkInputBo");
private String type;
private String topic;
PatrolDataSyncTopicEnum(String type, String topic) {
this.type = type;
this.topic = topic;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getTopic() {
return topic;
}
public void setTopic(String topic) {
this.topic = topic;
}
}
package com.yeejoin.amos.boot.module.common.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.common.api.dto.OrgUsrSyncDto;
import com.yeejoin.amos.boot.module.common.api.enums.DataSyncTopicEnum;
import com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper;
import com.yeejoin.amos.boot.module.common.api.service.IDataSyncService;
import com.yeejoin.amos.component.rule.config.RuleConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.component.emq.EmqKeeper;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Async
@Slf4j
public class DataSyncServiceImpl implements IDataSyncService {
@Autowired
private EmqKeeper emqKeeper;
@Autowired
private OrgUsrMapper orgUsrMapper;
@Override
public void OrgUsrSyncDtoDataSync(Long id) {
try {
if (id != null) {
Map<String, Object> map = new HashMap<>();
map.put("id", id);
List<OrgUsrSyncDto> list = orgUsrMapper.getOrgUsrSyncDataList(map);
if (CollectionUtils.isNotEmpty(list)) {
for (OrgUsrSyncDto x : list) {
String message = buildSyncMessage(DataSyncTopicEnum.ORG_USR.getTopic(), x);
emqKeeper.getMqttClient().publish(DataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), message.getBytes(), RuleConfig.DEFAULT_QOS, false);
}
emqKeeper.getMqttClient().publish(DataSyncTopicEnum.ORG_USR.getTopic(), JSONObject.toJSONString(list).getBytes(), RuleConfig.DEFAULT_QOS, false);
} else {
// 同步删除人员信息
OrgUsrSyncDto orgUsrSyncDto = new OrgUsrSyncDto();
orgUsrSyncDto.setSequenceNbr(id);
String message = buildSyncMessage(DataSyncTopicEnum.ORG_USR.getTopic(), orgUsrSyncDto);
emqKeeper.getMqttClient().publish(DataSyncTopicEnum.EQM_PATROL_CREATED.getTopic(), message.getBytes(), RuleConfig.DEFAULT_QOS, false);
emqKeeper.getMqttClient().publish(DataSyncTopicEnum.ORG_USR.getTopic(), JSONObject.toJSONString(orgUsrSyncDto).getBytes(), RuleConfig.DEFAULT_QOS, false);
}
}
} catch (Exception e) {
log.error("站端与中心级人员数据【OrgUsrSyncDto】同步推送失败-----------" + 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.boot.module.common.biz.service.impl;
import java.util.*;
import java.util.stream.Collectors;
import com.yeejoin.amos.boot.biz.common.dao.mapper.DataDictionaryMapper;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.module.common.api.dto.*;
import com.yeejoin.amos.boot.module.common.api.entity.*;
import com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper;
import com.yeejoin.amos.component.feign.model.Page;
import com.yeejoin.amos.boot.module.common.api.service.IDataSyncService;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator;
......@@ -35,7 +34,6 @@ import com.yeejoin.amos.boot.module.common.api.service.IFirefightersService;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
/**
* 消防队员 服务实现类
......@@ -62,6 +60,8 @@ public class FirefightersServiceImpl extends BaseService<FirefightersDto, Firefi
@Autowired
private OrgUsrMapper orgUsrMapper;
@Autowired
private IDataSyncService dataSyncService;
@Override
public List<FirefightersZhDto> getFirefighters(int pageNum, int pageSize, FirefightersDto par) {
......@@ -257,6 +257,14 @@ public class FirefightersServiceImpl extends BaseService<FirefightersDto, Firefi
// 更新紧急联系人
ifirefightersContactsService.updateById(peopleInfoDto.getFirefightersContacts());
}
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
dataSyncService.OrgUsrSyncDtoDataSync(id);
}
});
return peopleInfoDto;
}
......
......@@ -12,7 +12,6 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.constants.CommonConstant;
import com.yeejoin.amos.boot.biz.common.dao.mapper.DataDictionaryMapper;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.interceptors.PermissionInterceptorContext;
......@@ -27,12 +26,12 @@ import com.yeejoin.amos.boot.module.common.api.enums.UserRolesEnum;
import com.yeejoin.amos.boot.module.common.api.enums.UserUnitTypeEnum;
import com.yeejoin.amos.boot.module.common.api.feign.AmosTrainingFeignClient;
import com.yeejoin.amos.boot.module.common.api.mapper.*;
import com.yeejoin.amos.boot.module.common.api.service.IDataSyncService;
import com.yeejoin.amos.boot.module.common.api.service.IMaintenanceCompanyService;
import com.yeejoin.amos.boot.module.common.api.service.IOrgUsrService;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -43,6 +42,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.context.RequestContext;
......@@ -160,6 +161,9 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
FirefightersContactsServiceImpl ifirefightersContactsService;
@Autowired
private IDataSyncService dataSyncService;
@Autowired
RedisUtils redisUtils;
public static List<OrgMenuDto> buildTreeParallel(List<OrgUsr> list) {
......@@ -2999,14 +3003,14 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
// 2.保存cb_dynamic_form_instance表 人员基本信息
OrgUsrDto orgUsrDto = saveDynamicformInstance(orgUsr, peopleInfoDto.getFirefighters());
if (!ObjectUtils.isEmpty(orgUsrDto.getSequenceNbr())) {
peopleInfoDto.getFirefightersContacts().setOrgUsrId(orgUsrDto.getSequenceNbr().toString());
peopleInfoDto.getFirefighters().setOrgUsrId(orgUsrDto.getSequenceNbr().toString());
peopleInfoDto.getPostEduDtoObj().getFirefightersWorkexperience().setOrgUsrId(orgUsrDto.getSequenceNbr().toString());
peopleInfoDto.getPostEduDtoObj().getFirefightersEducation().setOrgUsrId(orgUsrDto.getSequenceNbr().toString());
peopleInfoDto.getPostEduDtoObj().getFirefightersPost().setOrgUsrId(orgUsrDto.getSequenceNbr().toString());
peopleInfoDto.getFirefighters().setSequenceNbr(orgUsrDto.getSequenceNbr().toString());
Long sequenceNbr = orgUsrDto.getSequenceNbr();
if (!ObjectUtils.isEmpty(sequenceNbr)) {
peopleInfoDto.getFirefightersContacts().setOrgUsrId(sequenceNbr.toString());
peopleInfoDto.getFirefighters().setOrgUsrId(sequenceNbr.toString());
peopleInfoDto.getPostEduDtoObj().getFirefightersWorkexperience().setOrgUsrId(sequenceNbr.toString());
peopleInfoDto.getPostEduDtoObj().getFirefightersEducation().setOrgUsrId(sequenceNbr.toString());
peopleInfoDto.getPostEduDtoObj().getFirefightersPost().setOrgUsrId(sequenceNbr.toString());
peopleInfoDto.getFirefighters().setSequenceNbr(sequenceNbr.toString());
}
if (peopleInfoDto.getFirefighters() != null && "1601".equals(peopleInfoDto.getFirefighters().getPeopleType())) {
......@@ -3017,7 +3021,15 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
saveFirefightersContacts(peopleInfoDto);
}
// 4.保存岗位信息
saveFirefightersPost(peopleInfoDto.getPostEduDtoObj(), orgUsrDto.getSequenceNbr());
saveFirefightersPost(peopleInfoDto.getPostEduDtoObj(), sequenceNbr);
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
dataSyncService.OrgUsrSyncDtoDataSync(sequenceNbr);
}
});
return peopleInfoDto;
}
......@@ -3336,7 +3348,14 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
if ("1601".equals(type)) {
deleteFirefighters(id);
}
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
dataSyncService.OrgUsrSyncDtoDataSync(id);
}
});
return "0";
}
......
......@@ -105,6 +105,7 @@ public class FirefightersController extends BaseController {
RedisUtils redisUtils;
@Autowired
DataDictionaryServiceImpl dataDictionaryService;
@Value("${redis.cache.failure.time}")
private long time;
@Autowired
......
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);
}
......@@ -42,4 +42,7 @@ public interface IPlanTaskDetailDao extends BaseDao<PlanTaskDetail, Long> {
@Query(value = "select * FROM p_plan_task_detail WHERE point_id IN (?1)", nativeQuery = true)
List<PlanTaskDetail> findALLByPointId(Long pointId);
@Query(value = "select * FROM p_plan_task_detail WHERE id = ?1 AND `status` = ?2", nativeQuery = true)
List<PlanTaskDetail> findAllByIdAndStatus(long id, String status);
}
......@@ -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,11 @@ 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 +132,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,7 +19,10 @@ 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;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -30,6 +33,8 @@ import org.springframework.cglib.beans.BeanMap;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.ObjectUtils;
import com.alibaba.fastjson.JSONArray;
......@@ -42,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;
......@@ -148,14 +149,12 @@ public class CheckServiceImpl implements ICheckService {
@Autowired
private PlanServiceImpl planService;
// @Value("${file.ip}")
// private String fileIp;
//
// @Value("${file.port}")
// private String filePort;
// @Value("${file.url}")
// private String fileUrl;
@Autowired
private IPatrolDataSyncService patrolDataSyncService;
@Autowired
private CheckInputMapper checkInputMapper;
@Override
public Page<CheckInfoVo> getCheckInfo(String toke,String product,String appKey,CheckInfoPageParam param) {
long total = checkMapper.getCheckInfoCount(param);
......@@ -213,6 +212,15 @@ public class CheckServiceImpl implements ICheckService {
check.setShotNumber(check.getShotNumber() + imgList.size());
checkDao.save(check);
checkShotDao.saveAll(imgList);
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
patrolDataSyncService.checkDataSync(check);
patrolDataSyncService.checkShotDataSync(imgList);
}
});
}
@Override
......@@ -431,6 +439,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();
......@@ -666,6 +685,22 @@ 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);
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;
import com.yeejoin.amos.patrol.dao.entity.*;
import com.yeejoin.amos.patrol.mqtt.WebMqttComponent;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
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
@Slf4j
public class PatrolDataSyncServiceImpl implements IPatrolDataSyncService {
@Autowired
private WebMqttComponent webMqttComponent;
@Autowired
private IPlanTaskDetailDao planTaskDetailDao;
@Override
public void checkDataSync(Check check) {
if (check != null) {
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);
if (CollectionUtils.isNotEmpty(planTaskDetailList)) {
planTaskDetailList.forEach(x -> {
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());
}
}
}
@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);
});
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());
}
}
}
@Override
public void checkInputDataSync(List<CheckInput> checkInputList) {
try {
if (CollectionUtils.isNotEmpty(checkInputList)) {
checkInputList.forEach(x -> {
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());
}
}
@Override
public void checkShotDataSync(List<CheckShot> checkShotList) {
try {
if (CollectionUtils.isNotEmpty(checkShotList)) {
checkShotList.forEach(x -> {
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());
}
}
@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);
webMqttComponent.publish(PatrolDataSyncTopicEnum.CHECK_INPUT_BO.getTopic(), JSONObject.toJSONString(checkInputSyncBo));
}
} 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);
});
webMqttComponent.publish(PatrolDataSyncTopicEnum.CHECK_INPUT_BO.getTopic(), JSONObject.toJSONString(checkInputSyncBoList));
}
} catch (Exception e) {
log.error("站端与中心级巡检数据【CheckInputSyncBo】同步推送失败-----------" + e.getMessage());
}
}
@Override
public void planTaskDataSync(PlanTask planTask) {
try {
if (planTask != null) {
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());
}
}
@Override
public void planTaskDataSync(List<PlanTask> planTaskList) {
try {
if (CollectionUtils.isNotEmpty(planTaskList)) {
planTaskList.forEach(x -> {
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());
}
}
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);
}
}
......@@ -11,6 +11,7 @@ import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.rule.RuleTrigger;
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.PlanMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskDetailMapper;
......@@ -29,6 +30,7 @@ import com.yeejoin.amos.patrol.business.feign.JcsFeignClient;
import com.yeejoin.amos.patrol.business.param.CheckPtListPageParam;
import com.yeejoin.amos.patrol.business.param.PlanTaskPageParam;
import com.yeejoin.amos.patrol.business.service.intfc.ICheckService;
import com.yeejoin.amos.patrol.business.service.intfc.IPatrolDataSyncService;
import com.yeejoin.amos.patrol.business.service.intfc.IPlanTaskService;
import com.yeejoin.amos.patrol.business.util.PlanTaskUtil;
import com.yeejoin.amos.patrol.business.util.Toke;
......@@ -55,10 +57,13 @@ 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;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
......@@ -116,9 +121,6 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
private EquipFeign equipFeign;
@Autowired
private RulePlanService rulePlanService;
@Autowired
private RuleTrigger ruleTrigger;
@Autowired
......@@ -126,6 +128,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
@Autowired
JcsFeignClient jcsFeignClient;
@Autowired
private IPatrolDataSyncService patrolDataSyncService;
private final String PATROL_PLAN_TASK_KEY = "PATROL_PLAN_ID:";
private final String packageId = "消息/addCheckRule";
......@@ -734,6 +739,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
}
List<PlanTask> planTaskList = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startTime = list.get(i).get("BEGIN_TIME").toString();
......@@ -828,6 +834,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
// 定时任务监控
jobService.planTaskAddJob(planTask);
planTaskList.add(planTask);
}
// 3.如果为自动任务调用,则更新id,如果重做或且下次时间大于等于明天,则更新planTaskId到plan表
......@@ -849,13 +856,19 @@ 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);
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RuntimeException(e.getMessage());
}
// return deptMap;
}
......@@ -924,6 +937,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
}
List<PlanTask> planTaskList = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startTime = list.get(i).get("BEGIN_TIME").toString();
......@@ -1018,6 +1032,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
// 定时任务监控
jobService.planTaskAddJob(planTask);
planTaskList.add(planTask);
}
// 3.如果为自动任务调用,则更新id,如果重做或且下次时间大于等于明天,则更新planTaskId到plan表
......@@ -1039,11 +1054,17 @@ 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);
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
}
// return deptMap;
}
......
......@@ -7,45 +7,43 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.dao.mapper.InputItemMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PointMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.RouteMapper;
import com.yeejoin.amos.patrol.business.dao.repository.*;
import com.yeejoin.amos.patrol.business.dto.PointClassifySynDto;
import com.yeejoin.amos.patrol.business.entity.mybatis.CheckChkExListBo;
import com.yeejoin.amos.patrol.business.entity.mybatis.CheckPtListBo;
import com.yeejoin.amos.patrol.business.entity.mybatis.PushTargetBo;
import com.yeejoin.amos.patrol.business.feign.EquipFeign;
import com.yeejoin.amos.patrol.business.feign.JcsFeignClient;
import com.yeejoin.amos.patrol.business.param.*;
import com.yeejoin.amos.patrol.business.service.intfc.IPatrolDataSyncService;
import com.yeejoin.amos.patrol.business.service.intfc.IPointService;
import com.yeejoin.amos.patrol.business.util.DaoCriteria;
import com.yeejoin.amos.patrol.business.vo.*;
import com.yeejoin.amos.patrol.common.enums.PointStatusEnum;
import com.yeejoin.amos.patrol.core.common.request.CommonPageable;
import com.yeejoin.amos.patrol.core.common.response.PointResponse;
import com.yeejoin.amos.patrol.core.enums.QueryOperatorEnum;
import com.yeejoin.amos.patrol.core.util.StringUtil;
import com.yeejoin.amos.patrol.core.util.query.BaseQuerySpecification;
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.safety.common.cache.PointStatusCache;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.assertj.core.util.Sets;
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;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
......@@ -57,10 +55,7 @@ import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.beans.PropertyDescriptor;
import java.math.BigInteger;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;
@Service("pointService")
......@@ -91,7 +86,6 @@ public class PointServiceImpl implements IPointService {
@Autowired
private IRoutePointItemDao iRoutePointItemDao;
@Resource
private RouteMapper routeMapper;
......@@ -112,6 +106,9 @@ public class PointServiceImpl implements IPointService {
@Autowired
private JcsFeignClient jcsFeignClient;
@Autowired
private IPatrolDataSyncService patrolDataSyncService;
@Override
@Transactional
public Point addPoint(PointParam pointParam) {
......@@ -648,6 +645,7 @@ public class PointServiceImpl implements IPointService {
iRoutePointItemDao.delRoutePointItem(routePointId.longValue());
iRoutePointDao.deleteById(Long.parseLong(routePointId.toString()));
}
List<PlanTask> planTaskList = new ArrayList<>();
for (long pointId : idList) {
List<PlanTaskDetail> planDetailList = iPlanTaskDetailDao.findALLByPointId(pointId);
for (PlanTaskDetail planTaskDetail : planDetailList) {
......@@ -659,15 +657,26 @@ public class PointServiceImpl implements IPointService {
planTask.setFinishNum(planTask.getFinishNum() - 1);
planTask.setPointNum(planTask.getPointNum() - 1);
planTaskDao.save(planTask);
planTaskList.add(planTask);
} else {
planTask.setPointNum(planTask.getPointNum() - 1);
planTaskDao.save(planTask);
planTaskList.add(planTask);
}
}
}
iPlanTaskDetailDao.deletePlanTaskDetailByPointId(idList); // 删除p_plan_task_detail相关行
iPointDao.delPointById(idList);
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
patrolDataSyncService.planTaskDataSync(planTaskList);
}
});
return idList;
}
......
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;
import com.yeejoin.amos.patrol.dao.entity.PlanTask;
import java.util.List;
/**
* <h1></h1>
*
* @Author Jianqiang Gao
* @Date 2021-04-01 14:27
*/
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);
void planTaskDataSync(PlanTask planTask);
void planTaskDataSync(List<PlanTask> planTaskList);
}
......@@ -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