Commit b3e5cdc6 authored by suhuiguang's avatar suhuiguang

1.作废功能进行流程作废时,要判断设备是否有其他流程正常存在,如果有则设备的纳管状态依然为已纳管,且设备不可编辑;

2.作废流程后,设备没有任何流程数据时,变更设备纳管状态为未纳管;设备可以编辑。
parent 515cce39
...@@ -63,6 +63,13 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> { ...@@ -63,6 +63,13 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> {
*/ */
Integer countEquipInUseTimesForDel(String record); Integer countEquipInUseTimesForDel(String record);
/**
* 统计设备被引用的次数(只有存在就算引用-作废除外)
* @param record 设备唯一标识
* @return 被引用次数 > 0 则设备不可删除
*/
Integer countEquipInUseTimesWithOutZF(String record);
List<String> refreshTheDetailsDataOfCompletedUsageRegistration(String since); List<String> refreshTheDetailsDataOfCompletedUsageRegistration(String since);
......
...@@ -2248,4 +2248,149 @@ ...@@ -2248,4 +2248,149 @@
WHERE tjvi."USE_UNIT_CREDIT_CODE" = #{useCode} WHERE tjvi."USE_UNIT_CREDIT_CODE" = #{useCode}
AND tjvi.is_delete = '0' AND tjvi.is_delete = '0'
</select> </select>
<select id="countEquipInUseTimesWithOutZF" resultType="java.lang.Integer">
select
sum(inUseNumber)
from (
select
count(1) as inUseNumber
from
tzs_jg_use_registration a,
tzs_jg_use_registration_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and ( a.status <![CDATA[ <> ]]> '已作废')
UNION
select
count(1) as inUseNumber
from
tzs_jg_change_registration_reform a,
tzs_jg_change_registration_reform_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and ( a.audit_status <![CDATA[ <> ]]> '已作废')
UNION
select
count(1) as inUseNumber
from
tzs_jg_change_registration_transfer a,
tzs_jg_change_registration_transfer_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and (a.audit_status <![CDATA[ <> ]]> '已作废')
UNION
select
count(1) as inUseNumber
from
tzs_jg_change_registration_unit a,
tzs_jg_change_registration_unit_eq b
where
a.sequence_nbr = b.unit_change_registration_id
and b.equ_id = #{record}
and (a.status <![CDATA[ <> ]]> '已作废')
UNION
select
count(1) as inUseNumber
from
tzs_jg_enable_disable a,
tzs_jg_enable_disable_eq b
where
a.sequence_nbr = b.enable_disable_apply_id
and b.equ_id = #{record}
and (a.audit_status <![CDATA[ <> ]]> '已作废')
UNION
select
count(1) as inUseNumber
from
tzs_jg_equip_transfer a,
tzs_jg_equip_transfer_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and (a.apply_status <![CDATA[ <> ]]> '6617')
UNION
select
count(1) as inUseNumber
from
tzs_jg_installation_notice a,
tzs_jg_installation_notice_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and (a.notice_status <![CDATA[ <> ]]> '6617')
UNION
select
count(1) as inUseNumber
from
tzs_jg_maintain_notice a,
tzs_jg_maintain_notice_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and (a.notice_status <![CDATA[ <> ]]> '6617')
UNION
select
count(1) as inUseNumber
from
tzs_jg_maintenance_contract a,
tzs_jg_maintenance_contract_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and (a.status <![CDATA[ <> ]]> '已作废')
UNION
select
count(1) as inUseNumber
from
tzs_jg_reform_notice a,
tzs_jg_reform_notice_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and (a.notice_status <![CDATA[ <> ]]> '6617')
UNION
select
count(1) as inUseNumber
from
tzs_jg_scrap_cancel a,
tzs_jg_scrap_cancel_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and (a.audit_status <![CDATA[ <> ]]> '已作废')
UNION
select
count(1) as inUseNumber
from
tzs_jg_transfer_notice a,
tzs_jg_transfer_notice_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and ( a.notice_status <![CDATA[ <> ]]> '6617')
UNION
select
count(1) as inUseNumber
from
tzs_jg_vehicle_information a,
tzs_jg_vehicle_information_eq b
where
a.sequence_nbr = b.vehicle_id
and b.equ_id = #{record}
and (a.status <![CDATA[ <> ]]> '已作废')
UNION
select
count(1) as inUseNumber
from
tzs_jg_change_vehicle_registration_unit a,
tzs_jg_change_vehicle_registration_unit_eq b
where
a.sequence_nbr = b.unit_change_id
and b.equ_id = #{record}
and (a.status <![CDATA[ <> ]]> '已作废')
)
</select>
</mapper> </mapper>
package com.yeejoin.amos.boot.module.jg.biz.event;
import lombok.Getter;
import org.springframework.context.ApplicationEvent;
import java.util.List;
/**
* @author Administrator
*/
@Getter
public class CancellationEvent extends ApplicationEvent {
private List<String> records;
/**
* Create a new {@code ApplicationEvent}.
*
* @param source the object on which the event initially occurred or with
* which the event is associated (never {@code null})
*/
public CancellationEvent(Object source, List<String> records) {
super(source);
this.records = records;
}
}
package com.yeejoin.amos.boot.module.jg.biz.event.listener;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper;
import com.yeejoin.amos.boot.module.jg.biz.event.CancellationEvent;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgUseInfoMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
/**
* @author Administrator
*/
@Component
@Slf4j
public class CancellationEventListener {
@Value("${cancellation.deal.thread.number:1}")
private int threadNumber;
private CommonMapper commonMapper;
private ESEquipmentCategory esEquipmentCategoryDao;
private IdxBizJgUseInfoMapper idxBizJgUseInfoMapper;
private BlockingQueue<String> queue = new LinkedBlockingQueue<>();
public CancellationEventListener(CommonMapper commonMapper, ESEquipmentCategory esEquipmentCategoryDao, IdxBizJgUseInfoMapper idxBizJgUseInfoMapper) {
this.commonMapper = commonMapper;
this.esEquipmentCategoryDao = esEquipmentCategoryDao;
this.idxBizJgUseInfoMapper = idxBizJgUseInfoMapper;
}
@EventListener(value = CancellationEvent.class)
public void handleTransactionalEvent(CancellationEvent event) {
List<String> records = event.getRecords();
log.info("收到作废消息:{}", JSONObject.toJSONString(records));
queue.addAll(records);
}
private Boolean checkEquipIsUsed(String record) {
Integer useTime = commonMapper.countEquipInUseTimesWithOutZF(record);
return useTime <= 0;
}
@PostConstruct
public void init() {
ExecutorService executorService = Executors.newFixedThreadPool(threadNumber);
for (int i = 0; i < threadNumber; i++) {
executorService.execute(() -> {
while (true) {
try {
String record = queue.take();
this.dealData(record);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
});
}
}
private void dealData(String record) {
// 所有业务单据(除去作废状态单据),有在引用设备的则不修改设备纳管状态
Boolean inUsed = this.checkEquipIsUsed(record);
// 无引用则进行修改纳管状态为未纳管
if (!inUsed) {
// 更新已纳管为未纳管-数据库
LambdaUpdateWrapper<IdxBizJgUseInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IdxBizJgUseInfo::getRecord, record);
updateWrapper.set(IdxBizJgUseInfo::getIsIntoManagement, false);
idxBizJgUseInfoMapper.update(null, updateWrapper);
// 更新已纳管为未纳管-es
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategoryDao.findById(record);
if (optional.isPresent()) {
ESEquipmentCategoryDto esEquipmentCategoryDto = optional.get();
esEquipmentCategoryDto.setIS_INTO_MANAGEMENT(false);
esEquipmentCategoryDao.save(esEquipmentCategoryDto);
}
}
}
}
package com.yeejoin.amos.boot.module.jg.biz.event.publisher;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
/**
* @author Administrator
*/
@Component
public class EventPublisher {
private ApplicationEventPublisher publisher;
public EventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
@Async
public void publish(ApplicationEvent event) {
publisher.publishEvent(event);
}
}
\ No newline at end of file
...@@ -32,6 +32,8 @@ import com.yeejoin.amos.boot.module.jg.api.vo.SortVo; ...@@ -32,6 +32,8 @@ import com.yeejoin.amos.boot.module.jg.api.vo.SortVo;
import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest; import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext; import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext; import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext;
import com.yeejoin.amos.boot.module.jg.biz.event.CancellationEvent;
import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient; import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService; import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgConstructionInfoService; import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgConstructionInfoService;
...@@ -65,6 +67,8 @@ import org.springframework.core.io.Resource; ...@@ -65,6 +67,8 @@ import org.springframework.core.io.Resource;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; 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.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -189,6 +193,9 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -189,6 +193,9 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
@Autowired @Autowired
private EquipTechParamPipelineMapper equipTechParamPipelineMapper; private EquipTechParamPipelineMapper equipTechParamPipelineMapper;
@Autowired
EventPublisher eventPublisher;
/** /**
* 根据sequenceNbr查询 * 根据sequenceNbr查询
* *
...@@ -1051,11 +1058,15 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -1051,11 +1058,15 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
* @param jgInstallationNotice 安装告知entry * @param jgInstallationNotice 安装告知entry
*/ */
private void delRepeatUseEquipData(JgInstallationNotice jgInstallationNotice) { private void delRepeatUseEquipData(JgInstallationNotice jgInstallationNotice) {
List<String> ids = getEquList(jgInstallationNotice);
EquipUsedCheckStrategyContext.getUsedStrategy(PROCESS_INSTALL_NOTICE_KEY).delDataForCheckEquipRepeatUsed(ids, jgInstallationNotice.getInstallUnitCreditCode());
}
private List<String> getEquList(JgInstallationNotice jgInstallationNotice) {
LambdaQueryWrapper<JgInstallationNoticeEq> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<JgInstallationNoticeEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgInstallationNoticeEq::getEquipTransferId, jgInstallationNotice.getSequenceNbr()); queryWrapper.eq(JgInstallationNoticeEq::getEquipTransferId, jgInstallationNotice.getSequenceNbr());
List<JgInstallationNoticeEq> jgInstallationNoticeEqs = jgInstallationNoticeEqMapper.selectList(queryWrapper); List<JgInstallationNoticeEq> jgInstallationNoticeEqs = jgInstallationNoticeEqMapper.selectList(queryWrapper);
List<String> ids = jgInstallationNoticeEqs.stream().map(item -> item.getEquId()).collect(Collectors.toList()); return jgInstallationNoticeEqs.stream().map(JgInstallationNoticeEq::getEquId).collect(Collectors.toList());
EquipUsedCheckStrategyContext.getUsedStrategy(PROCESS_INSTALL_NOTICE_KEY).delDataForCheckEquipRepeatUsed(ids, jgInstallationNotice.getInstallUnitCreditCode());
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -1505,9 +1516,16 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -1505,9 +1516,16 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
this.updateById(installationNotice); this.updateById(installationNotice);
// 2.更新关联的业务 // 2.更新关联的业务
this.processElseDataByStatus(Objects.requireNonNull(FlowStatusEnum.getEumByCode(Integer.parseInt(oldNoticeStatus))), installationNotice); this.processElseDataByStatus(Objects.requireNonNull(FlowStatusEnum.getEumByCode(Integer.parseInt(oldNoticeStatus))), installationNotice);
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
eventPublisher.publish(new CancellationEvent(this, getEquList(installationNotice)));
}
});
return installationNotice; return installationNotice;
} }
private void processElseDataByStatus(FlowStatusEnum oldNoticeStatus, JgInstallationNotice installationNotice) { private void processElseDataByStatus(FlowStatusEnum oldNoticeStatus, JgInstallationNotice installationNotice) {
switch (oldNoticeStatus) { switch (oldNoticeStatus) {
case TO_BE_SUBMITTED: // 待提交 case TO_BE_SUBMITTED: // 待提交
...@@ -1568,7 +1586,6 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -1568,7 +1586,6 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
updateWrapper.eq(IdxBizJgUseInfo::getRecord, jgRelationEquip.getEquId()); // 设置更新条件 updateWrapper.eq(IdxBizJgUseInfo::getRecord, jgRelationEquip.getEquId()); // 设置更新条件
updateWrapper.set(IdxBizJgUseInfo::getUseUnitCreditCode, null); updateWrapper.set(IdxBizJgUseInfo::getUseUnitCreditCode, null);
updateWrapper.set(IdxBizJgUseInfo::getUseUnitName, null); updateWrapper.set(IdxBizJgUseInfo::getUseUnitName, null);
updateWrapper.set(IdxBizJgUseInfo::getIsIntoManagement, Boolean.FALSE);
useInfoService.update(updateWrapper); useInfoService.update(updateWrapper);
// 2.2 es的USE_UNIT_CREDIT_CODE赋空 // 2.2 es的USE_UNIT_CREDIT_CODE赋空
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(jgRelationEquip.getEquId()); Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(jgRelationEquip.getEquId());
...@@ -1576,7 +1593,6 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -1576,7 +1593,6 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
ESEquipmentCategoryDto esEquipmentCategoryDto = optional.get(); ESEquipmentCategoryDto esEquipmentCategoryDto = optional.get();
esEquipmentCategoryDto.setUSE_UNIT_CREDIT_CODE(null); esEquipmentCategoryDto.setUSE_UNIT_CREDIT_CODE(null);
esEquipmentCategoryDto.setUSE_UNIT_NAME(null); esEquipmentCategoryDto.setUSE_UNIT_NAME(null);
esEquipmentCategoryDto.setIS_INTO_MANAGEMENT(Boolean.FALSE);
esEquipmentCategory.save(esEquipmentCategoryDto); esEquipmentCategory.save(esEquipmentCategoryDto);
} }
}); });
......
...@@ -14,6 +14,7 @@ import com.yeejoin.amos.boot.module.jg.api.dto.*; ...@@ -14,6 +14,7 @@ import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintenanceContract; import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintenanceContract;
import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintenanceContractEq; import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintenanceContractEq;
import com.yeejoin.amos.boot.module.jg.api.entity.JgRegistrationHistory; import com.yeejoin.amos.boot.module.jg.api.entity.JgRegistrationHistory;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationEq;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum; import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.CompanyTypeEnum; import com.yeejoin.amos.boot.module.jg.api.enums.CompanyTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.SafetyProblemTypeEnum; import com.yeejoin.amos.boot.module.jg.api.enums.SafetyProblemTypeEnum;
...@@ -26,6 +27,8 @@ import com.yeejoin.amos.boot.module.jg.api.service.IJgMaintenanceContractService ...@@ -26,6 +27,8 @@ import com.yeejoin.amos.boot.module.jg.api.service.IJgMaintenanceContractService
import com.yeejoin.amos.boot.module.jg.api.vo.JgMaintenanceContractVo; import com.yeejoin.amos.boot.module.jg.api.vo.JgMaintenanceContractVo;
import com.yeejoin.amos.boot.module.jg.api.vo.SortVo; import com.yeejoin.amos.boot.module.jg.api.vo.SortVo;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext; import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.event.CancellationEvent;
import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient; import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService; import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgUseInfoService; import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgUseInfoService;
...@@ -47,6 +50,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -47,6 +50,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; 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.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -108,6 +113,9 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC ...@@ -108,6 +113,9 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC
@Autowired @Autowired
IIdxBizJgUseInfoService useInfoService; IIdxBizJgUseInfoService useInfoService;
@Autowired
EventPublisher eventPublisher;
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -239,6 +247,11 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC ...@@ -239,6 +247,11 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC
} }
} }
private List<String> getEquList(Long id) {
List<JgMaintenanceContractEq> list = jgMaintenanceContractEqService.lambdaQuery().eq(JgMaintenanceContractEq::getEquipTransferId, id).list();
return list.stream().map(JgMaintenanceContractEq::getEquId).collect(Collectors.toList());
}
private void delRepeatUseEquipData(Long id, String companyCode) { private void delRepeatUseEquipData(Long id, String companyCode) {
List<JgMaintenanceContractEq> list = jgMaintenanceContractEqService.lambdaQuery().eq(JgMaintenanceContractEq::getEquipTransferId, id).list(); List<JgMaintenanceContractEq> list = jgMaintenanceContractEqService.lambdaQuery().eq(JgMaintenanceContractEq::getEquipTransferId, id).list();
// 获取单位变更设备列表 // 获取单位变更设备列表
...@@ -796,6 +809,12 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC ...@@ -796,6 +809,12 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC
maintenanceContract.setPromoter(null); maintenanceContract.setPromoter(null);
this.updateById(maintenanceContract); this.updateById(maintenanceContract);
this.processElseDataByStatus(this.confirmBusinessPhase(oldNoticeStatus), maintenanceContract); this.processElseDataByStatus(this.confirmBusinessPhase(oldNoticeStatus), maintenanceContract);
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
eventPublisher.publish(new CancellationEvent(this, getEquList(maintenanceContract.getSequenceNbr())));
}
});
return maintenanceContract; return maintenanceContract;
} }
......
...@@ -33,6 +33,8 @@ import com.yeejoin.amos.boot.module.jg.api.vo.SortVo; ...@@ -33,6 +33,8 @@ import com.yeejoin.amos.boot.module.jg.api.vo.SortVo;
import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest; import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext; import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext; import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext;
import com.yeejoin.amos.boot.module.jg.biz.event.CancellationEvent;
import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient; import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.feign.WorkFlowFeignService; import com.yeejoin.amos.boot.module.jg.biz.feign.WorkFlowFeignService;
import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService; import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService;
...@@ -62,7 +64,12 @@ import org.springframework.beans.BeanUtils; ...@@ -62,7 +64,12 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.event.TransactionalEventListener;
import org.springframework.transaction.reactive.TransactionalOperator;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
...@@ -131,6 +138,9 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -131,6 +138,9 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
@Autowired @Autowired
EquipTechParamPipelineMapper equipTechParamPipelineMapper; EquipTechParamPipelineMapper equipTechParamPipelineMapper;
@Autowired @Autowired
EventPublisher eventPublisher;
@Autowired
DataDictionaryServiceImpl iDataDictionaryService; DataDictionaryServiceImpl iDataDictionaryService;
String[] jsonFields = {"productPhoto", "factoryStandard", "productQualityYieldProve", "insUseMaintainExplain", String[] jsonFields = {"productPhoto", "factoryStandard", "productQualityYieldProve", "insUseMaintainExplain",
"inspectReport", "designStandard", "designDoc", "longitudeLatitude", "otherAccessoriesDes", "otherAccessoriesFact", "inspectReport", "designStandard", "designDoc", "longitudeLatitude", "otherAccessoriesDes", "otherAccessoriesFact",
...@@ -2346,6 +2356,13 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -2346,6 +2356,13 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
this.updateById(jgUseRegistration); this.updateById(jgUseRegistration);
// 2.更新关联的业务 // 2.更新关联的业务
processElseDataByStatus(oldStatus, jgUseRegistration); processElseDataByStatus(oldStatus, jgUseRegistration);
List<JgUseRegistrationEq> eqList = getJgUseRegistrationEqs(jgUseRegistration);
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
eventPublisher.publish(new CancellationEvent(this, eqList.stream().map(JgUseRegistrationEq::getEquId).collect(Collectors.toList())));
}
});
return jgUseRegistration; return jgUseRegistration;
} }
...@@ -2376,8 +2393,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -2376,8 +2393,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
} }
private void clearUseInfoOfEquip(JgUseRegistration jgUseRegistration) { private void clearUseInfoOfEquip(JgUseRegistration jgUseRegistration) {
LambdaQueryWrapper<JgUseRegistrationEq> eqLambdaQueryWrapper = new LambdaQueryWrapper<JgUseRegistrationEq>().eq(JgUseRegistrationEq::getEquipTransferId, jgUseRegistration.getSequenceNbr()); List<JgUseRegistrationEq> eqList = getJgUseRegistrationEqs(jgUseRegistration);
List<JgUseRegistrationEq> eqList = jgRelationEquipMapper.selectList(eqLambdaQueryWrapper);
eqList.forEach(e -> { eqList.forEach(e -> {
String record = e.getEquId(); String record = e.getEquId();
Boolean flag = Boolean.FALSE; Boolean flag = Boolean.FALSE;
...@@ -2404,6 +2420,11 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -2404,6 +2420,11 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
}); });
} }
private List<JgUseRegistrationEq> getJgUseRegistrationEqs(JgUseRegistration jgUseRegistration) {
LambdaQueryWrapper<JgUseRegistrationEq> eqLambdaQueryWrapper = new LambdaQueryWrapper<JgUseRegistrationEq>().eq(JgUseRegistrationEq::getEquipTransferId, jgUseRegistration.getSequenceNbr());
return jgRelationEquipMapper.selectList(eqLambdaQueryWrapper);
}
private void rollBackForEquipEsInfo(String record, Boolean flag) { private void rollBackForEquipEsInfo(String record, Boolean flag) {
LambdaQueryWrapper<IdxBizJgConstructionInfo> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizJgConstructionInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.select(IdxBizJgConstructionInfo::getUscUnitCreditCode, wrapper.select(IdxBizJgConstructionInfo::getUscUnitCreditCode,
...@@ -2425,11 +2446,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -2425,11 +2446,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
if (jgConstructionInfo != null){ if (jgConstructionInfo != null){
esEquipmentCategoryDto.setUSC_UNIT_NAME(jgConstructionInfo.getUscUnitName()); esEquipmentCategoryDto.setUSC_UNIT_NAME(jgConstructionInfo.getUscUnitName());
esEquipmentCategoryDto.setUSC_UNIT_CREDIT_CODE(jgConstructionInfo.getUscUnitCreditCode()); esEquipmentCategoryDto.setUSC_UNIT_CREDIT_CODE(jgConstructionInfo.getUscUnitCreditCode());
esEquipmentCategory.save(esEquipmentCategoryDto);
} }
if (flag) {
esEquipmentCategoryDto.setIS_INTO_MANAGEMENT(Boolean.FALSE);
}
esEquipmentCategory.save(esEquipmentCategoryDto);
} }
} }
...@@ -2514,9 +2532,6 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -2514,9 +2532,6 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
updateWrapper.set(IdxBizJgUseInfo::getSafetyManagerId, null); updateWrapper.set(IdxBizJgUseInfo::getSafetyManagerId, null);
updateWrapper.set(IdxBizJgUseInfo::getSafetyManager, null); updateWrapper.set(IdxBizJgUseInfo::getSafetyManager, null);
updateWrapper.set(IdxBizJgUseInfo::getFactoryUseSiteStreet, null); updateWrapper.set(IdxBizJgUseInfo::getFactoryUseSiteStreet, null);
if (flag) {
updateWrapper.set(IdxBizJgUseInfo::getIsIntoManagement, Boolean.FALSE);
}
useInfoMapper.update(null, updateWrapper); useInfoMapper.update(null, updateWrapper);
} }
......
...@@ -31,6 +31,8 @@ import com.yeejoin.amos.boot.module.jg.api.vo.SortVo; ...@@ -31,6 +31,8 @@ import com.yeejoin.amos.boot.module.jg.api.vo.SortVo;
import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest; import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext; import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext; import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext;
import com.yeejoin.amos.boot.module.jg.biz.event.CancellationEvent;
import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient; import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.feign.WorkFlowFeignService; import com.yeejoin.amos.boot.module.jg.biz.feign.WorkFlowFeignService;
import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService; import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService;
...@@ -61,6 +63,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -61,6 +63,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; 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.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -164,6 +168,9 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -164,6 +168,9 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
private Map<String, Object> fillingMediumMap; private Map<String, Object> fillingMediumMap;
@Autowired
EventPublisher eventPublisher;
/** /**
* @param auditPassDate 通过时间 * @param auditPassDate 通过时间
* @param exportParamsMap 参数map * @param exportParamsMap 参数map
...@@ -444,6 +451,13 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -444,6 +451,13 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
} }
} }
private List<String> getEquList(JgVehicleInformation notice) {
LambdaQueryWrapper<JgVehicleInformationEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgVehicleInformationEq::getVehicleId, notice.getSequenceNbr());
List<JgVehicleInformationEq> noticeEqList = jgVehicleInformationEqService.list(queryWrapper);
return noticeEqList.stream().map(JgVehicleInformationEq::getEquId).collect(Collectors.toList());
}
private void rollBackForDelRedisData() { private void rollBackForDelRedisData() {
FlowingEquipRedisContext.getContext().forEach(e -> { FlowingEquipRedisContext.getContext().forEach(e -> {
EquipUsedCheckStrategyContext.getUsedStrategy(DEFINITION_KEY) EquipUsedCheckStrategyContext.getUsedStrategy(DEFINITION_KEY)
...@@ -1343,6 +1357,12 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -1343,6 +1357,12 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
this.updateById(vehicleInformation); this.updateById(vehicleInformation);
// 2.更新关联的业务 // 2.更新关联的业务
processElseDataByStatus(oldStatus, vehicleInformation); processElseDataByStatus(oldStatus, vehicleInformation);
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
eventPublisher.publish(new CancellationEvent(this, getEquList(vehicleInformation)));
}
});
return vehicleInformation; return vehicleInformation;
} }
...@@ -1451,7 +1471,6 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -1451,7 +1471,6 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
esEquipmentCategoryDto.setEQU_STATE(null); esEquipmentCategoryDto.setEQU_STATE(null);
esEquipmentCategoryDto.setORG_BRANCH_CODE(null); esEquipmentCategoryDto.setORG_BRANCH_CODE(null);
esEquipmentCategoryDto.setORG_BRANCH_NAME(null); esEquipmentCategoryDto.setORG_BRANCH_NAME(null);
esEquipmentCategoryDto.setIS_INTO_MANAGEMENT(Boolean.FALSE);
esEquipmentCategory.save(esEquipmentCategoryDto); esEquipmentCategory.save(esEquipmentCategoryDto);
} }
} }
...@@ -1495,7 +1514,6 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -1495,7 +1514,6 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
updateWrapper.set(IdxBizJgUseInfo::getSafetyManagerId, null); updateWrapper.set(IdxBizJgUseInfo::getSafetyManagerId, null);
updateWrapper.set(IdxBizJgUseInfo::getSafetyManager, null); updateWrapper.set(IdxBizJgUseInfo::getSafetyManager, null);
updateWrapper.set(IdxBizJgUseInfo::getFactoryUseSiteStreet, null); updateWrapper.set(IdxBizJgUseInfo::getFactoryUseSiteStreet, null);
updateWrapper.set(IdxBizJgUseInfo::getIsIntoManagement, Boolean.FALSE);
useInfoMapper.update(null, updateWrapper); useInfoMapper.update(null, updateWrapper);
} }
......
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