Commit 0203759d authored by suhuiguang's avatar suhuiguang

reafact(jg): 业务作废

1.作废逻辑修正
parent 2bdcceb3
......@@ -81,6 +81,8 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> {
Integer countEquipInUseTimesWithOutZF(String record);
Integer countEquipInUseTimesForDiscard(String record);
List<String> refreshTheDetailsDataOfCompletedUsageRegistration(String since);
/**
......
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistration;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationEq;
import com.yeejoin.amos.boot.module.jg.api.vo.SortVo;
import com.yeejoin.amos.boot.module.jg.api.vo.tableDataExportVo.RegistrationVo;
import org.apache.ibatis.annotations.Param;
......@@ -144,4 +145,7 @@ public interface JgUseRegistrationMapper extends BaseMapper<JgUseRegistration> {
Page<JgNoticeToBeSubmitDto> queryRegistrationToBeSubmitPage(@Param("page") Page<JgNoticeToBeSubmitDto> page, @Param("companyCode")String companyCode);
List<JgUseRegistrationEq> selectListForInstallNoticeDiscard(@Param("records") List<String> records);
List<JgUseRegistrationEq> selectListForSelfDiscard(@Param("records") List<String> records);
}
......@@ -3178,4 +3178,42 @@
ORDER BY n.audit_pass_date DESC
) t3
</select>
<select id="countEquipInUseTimesForDiscard" resultType="java.lang.Integer" flushCache="true">
select
sum(inUseNumber)
from (
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.is_delete = 0
and (a.notice_status <![CDATA[ <> ]]> '6617')
UNION all
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.is_delete = 0
and ( a.status <![CDATA[ <> ]]> '已作废')
UNION all
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.is_delete = 0
and (a.status <![CDATA[ <> ]]> '已作废')
)
</select>
</mapper>
......@@ -1928,4 +1928,151 @@
WHERE dedup.rn = 1
ORDER BY dedup.createDate DESC, dedup.applyNo DESC
</select>
<select id="selectListForInstallNoticeDiscard" resultType="com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationEq">
SELECT
eq.sequence_nbr,
u.apply_no as recUserName
FROM "tzs_jg_use_registration_eq" eq, tzs_jg_use_registration u
where
u.sequence_nbr = eq.equip_transfer_id
and u.is_delete = false
and u.status != '已作废'
and eq.equ_id = ANY(ARRAY[
<foreach collection="records" item="record" separator=",">
#{record}
</foreach>
])
</select>
<select id="selectListForSelfDiscard"
resultType="com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationEq">
select
a.apply_no as recUserName,
b.equ_id as equId
from
tzs_jg_change_registration_reform a,
tzs_jg_change_registration_reform_eq b
where
a.sequence_nbr = b.equip_transfer_id
and a.is_delete = 0
and b.equ_id = ANY(ARRAY[
<foreach collection="records" item="record" separator=",">
#{record}
</foreach>
and (a.audit_status <![CDATA[ <> ]]> '已作废')
UNION all
select
a.apply_no as recUserName,
b.equ_id as equId
from
tzs_jg_change_registration_transfer a,
tzs_jg_change_registration_transfer_eq b
where
a.sequence_nbr = b.equip_transfer_id
and a.is_delete = 0
and b.equ_id = ANY(ARRAY[
<foreach collection="records" item="record" separator=",">
#{record}
</foreach>])
and ( a.audit_status <![CDATA[ <> ]]> '已作废')
UNION all
select
a.apply_no as recUserName,
b.equ_id as equId
from
tzs_jg_change_registration_unit a,
tzs_jg_change_registration_unit_eq b
where
a.sequence_nbr = b.unit_change_registration_id
and a.is_delete = 0
and b.equ_id = ANY(ARRAY[
<foreach collection="records" item="record" separator=",">
#{record}
</foreach>])
and (a.status <![CDATA[ <> ]]> '已作废')
UNION all
select
a.apply_no as recUserName,
b.equ_id as equId
from
tzs_jg_scrap_cancel a,
tzs_jg_scrap_cancel_eq b
where
a.sequence_nbr = b.equip_transfer_id
and a.is_delete = 0
and b.equ_id = ANY(ARRAY[
<foreach collection="records" item="record" separator=",">
#{record}
</foreach>])
and (a.audit_status <![CDATA[ <> ]]> '已作废')
UNION all
select
a.apply_no as recUserName,
b.equ_id as equId
from
tzs_jg_enable_disable a,
tzs_jg_enable_disable_eq b
where
a.sequence_nbr = b.enable_disable_apply_id
and a.is_delete = 0
and b.equ_id = ANY(ARRAY[
<foreach collection="records" item="record" separator=",">
#{record}
</foreach>])
and (a.audit_status <![CDATA[ <> ]]> '已作废')
UNION all
select
a.apply_no as recUserName,
ne.record as equId
from
(SELECT
json_array_elements(e.equip_info)->>'SEQUENCE_NBR' AS record
FROM
tzs_jg_change_registration_name_eq e,
tzs_jg_change_registration_name n
where
n.sequence_nbr = e.name_change_registration_id
and n.is_delete = 0
and n.audit_status <![CDATA[ <> ]]> '已作废') ne
where
ne.record = ANY(ARRAY[
<foreach collection="records" item="record" separator=",">
#{record}
</foreach>])
UNION all
select
a.apply_no as recUserName,
b.equip_transfer_id as equId
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')
and a.is_delete = 0
UNION all
select
a.apply_no as recUserName,
b.equip_transfer_id as equId
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')
and a.is_delete = 0
UNION all
select
a.apply_no as recUserName,
b.equip_transfer_id as equId
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')
and a.is_delete = 0
</select>
</mapper>
package com.yeejoin.amos.boot.module.jg.biz.discardOrder.factory;
import com.yeejoin.amos.boot.module.jg.biz.discardOrder.factory.support.DiscardOrderCheck;
import com.yeejoin.amos.boot.module.jg.biz.discardOrder.factory.support.SupportableDiscardOrderCheck;
import com.yeejoin.amos.boot.module.jg.biz.discardOrder.wrapper.DiscardOrderCheckWrapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@RequiredArgsConstructor
public class DiscardOrderCheckFactory {
private final List<SupportableDiscardOrderCheck> discardOrderChecks;
public DiscardOrderCheck getDiscardOrderCheck(String clazz) {
for (SupportableDiscardOrderCheck discardOrderCheck : discardOrderChecks) {
if (discardOrderCheck.getClass().getName().equals(clazz)) {
return new DiscardOrderCheckWrapper(discardOrderCheck);
}
}
throw new UnsupportedOperationException("not support discard order check" + "{" + clazz + "}");
}
}
package com.yeejoin.amos.boot.module.jg.biz.discardOrder.factory.support;
import java.util.List;
public interface DiscardOrderCheck {
Boolean check(List<String> records);
}
package com.yeejoin.amos.boot.module.jg.biz.discardOrder.factory.support;
public interface SupportableDiscardOrderCheck extends DiscardOrderCheck {
boolean support(String clazz);
}
package com.yeejoin.amos.boot.module.jg.biz.discardOrder.strategy;
import com.yeejoin.amos.boot.module.jg.biz.discardOrder.factory.support.SupportableDiscardOrderCheck;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.*;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class GenericDiscardOrderCheck implements SupportableDiscardOrderCheck {
@Override
public boolean support(String clazz) {
return JgMaintainNoticeServiceImpl.class.getSimpleName().equals(clazz) ||
JgTransferNoticeServiceImpl.class.getSimpleName().equals(clazz) ||
JgReformNoticeServiceImpl.class.getSimpleName().equals(clazz) ||
JgMaintenanceContractServiceImpl.class.getSimpleName().equals(clazz) ||
JgChangeRegistrationReformServiceImpl.class.getSimpleName().equals(clazz);
}
@Override
public Boolean check(List<String> records) {
return true;
}
}
package com.yeejoin.amos.boot.module.jg.biz.discardOrder.strategy;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationEq;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationMapper;
import com.yeejoin.amos.boot.module.jg.biz.discardOrder.factory.support.SupportableDiscardOrderCheck;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
public class InstallNoticeDiscardOrderCheck implements SupportableDiscardOrderCheck {
private final JgUseRegistrationMapper useRegistrationMapper;
@Override
public boolean support(String clazz) {
return JgInstallationNoticeServiceImpl.class.getSimpleName().equals(clazz);
}
@Override
public Boolean check(List<String> records) {
List<JgUseRegistrationEq> useRegistrationEqs = useRegistrationMapper.selectListForInstallNoticeDiscard(records);
if (!useRegistrationEqs.isEmpty()) {
String msg = String.format("存在设备正在办理或已办理使用登记,登记单编号:%s,不能进行作废!", String.join(",", useRegistrationEqs.stream().map(BaseEntity::getRecUserName).collect(Collectors.toSet())));
throw new RuntimeException(msg);
}
return true;
}
}
package com.yeejoin.amos.boot.module.jg.biz.discardOrder.strategy;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationEq;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationMapper;
import com.yeejoin.amos.boot.module.jg.biz.discardOrder.factory.support.SupportableDiscardOrderCheck;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistrationServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
public class UseRegisterDiscardOrderCheck implements SupportableDiscardOrderCheck {
private final JgUseRegistrationMapper useRegistrationMapper;
@Override
public boolean support(String clazz) {
return JgUseRegistrationServiceImpl.class.getName().equals(clazz);
}
@Override
public Boolean check(List<String> records) {
List<JgUseRegistrationEq> useRegistrationEqs = useRegistrationMapper.selectListForSelfDiscard(records);
if (!useRegistrationEqs.isEmpty()) {
String msg = String.format("存在设备正在办理或已办理使用登记,单据编号:%s,不能进行作废!", String.join(",", useRegistrationEqs.stream().map(BaseEntity::getRecUserName).collect(Collectors.toSet())));
throw new RuntimeException(msg);
}
return true;
}
}
package com.yeejoin.amos.boot.module.jg.biz.discardOrder.wrapper;
import com.yeejoin.amos.boot.module.jg.biz.discardOrder.factory.support.DiscardOrderCheck;
import com.yeejoin.amos.boot.module.jg.biz.discardOrder.factory.support.SupportableDiscardOrderCheck;
import java.util.List;
public class DiscardOrderCheckWrapper implements DiscardOrderCheck {
private final SupportableDiscardOrderCheck supportableDiscardOrderCheck;
public DiscardOrderCheckWrapper(SupportableDiscardOrderCheck supportableDiscardOrderCheck) {
this.supportableDiscardOrderCheck = supportableDiscardOrderCheck;
}
@Override
public Boolean check(List<String> records) {
return supportableDiscardOrderCheck.check(records);
}
}
......@@ -5,6 +5,7 @@ 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.common.biz.refresh.DataRefreshEvent;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper;
import com.yeejoin.amos.boot.module.jg.biz.event.dto.CancelEquipItem;
import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.EquipCreateOrEditEvent;
......@@ -31,6 +32,8 @@ public class ManageStatusDataUpdateService {
private final ICommonService commonService;
private final CommonMapper commonMapper;
private final ESEquipmentCategory esEquipmentCategoryDao;
private final IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService;
......@@ -52,9 +55,9 @@ public class ManageStatusDataUpdateService {
*/
public void cancelAndGrade(String record) {
// 所有业务单据(除去作废、删除状态单据),有在引用设备的则不修改设备纳管状态
Boolean inUsed = commonService.checkEquipIsUsed(record);
Integer inUsedNum = commonMapper.countEquipInUseTimesForDiscard(record);
// 无引用则进行修改纳管状态为未纳管
if (!inUsed) {
if (inUsedNum == 0) {
try {
// 更新已纳管为未纳管 - 数据库
updateEquipData(idxBizJgUseInfoService, record, idxBizJgRegisterInfoService, esEquipmentCategoryDao);
......@@ -72,9 +75,9 @@ public class ManageStatusDataUpdateService {
@Transactional(rollbackFor = Exception.class)
public void dealDataAndAsyncEs(String record) {
// 所有业务单据(除去作废、删除状态单据),有在引用设备的则不修改设备纳管状态
Boolean inUsed = commonService.checkEquipIsUsed(record);
Integer inUsedNum = commonMapper.countEquipInUseTimesForDiscard(record);
// 无引用则进行修改纳管状态为未纳管
if (!inUsed) {
if (inUsedNum == 0) {
try {
updateEquipData(idxBizJgUseInfoService, record, idxBizJgRegisterInfoService, esEquipmentCategoryDao);
// 发送数据刷新消息
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import org.springframework.stereotype.Service;
@Service
public class DiscardOrderServiceImpl {
}
......@@ -1819,6 +1819,8 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class)
public JgInstallationNotice cancelApplication(Long sequenceNbr, String cancelReason) {
// 0.校验是否做过使用登记,已发起使用登记(非删除状态)则提示不能进行作废
// 1.更新为已作废
JgInstallationNotice installationNotice = this.getById(sequenceNbr);
String oldNoticeStatus = installationNotice.getNoticeStatus();
......
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