Commit 60317ff1 authored by suhuiguang's avatar suhuiguang

reafact(jg): 业务作废

1.作废逻辑修正
parent bc665a36
......@@ -6,6 +6,7 @@ import com.yeejoin.amos.boot.module.jg.api.dto.CompanyEquipCountDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgVehicleInformationDto;
import com.yeejoin.amos.boot.module.jg.api.dto.ReminderItemDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgVehicleInformation;
import com.yeejoin.amos.boot.module.jg.api.entity.JgVehicleInformationEq;
import com.yeejoin.amos.boot.module.jg.api.vo.SortVo;
import com.yeejoin.amos.boot.module.jg.api.vo.tableDataExportVo.VehicleInformationVo;
import org.apache.ibatis.annotations.MapKey;
......@@ -55,4 +56,6 @@ public interface JgVehicleInformationMapper extends BaseMapper<JgVehicleInformat
List<Map<String, Object>> getVehicleInfoOfPassWithEquId();
List<ReminderItemDto> queryUnitVehiclesForReminderList(@Param("records") List<String> records);
List<JgVehicleInformationEq> selectListForSelfDiscard(@Param("records")List<String> records);
}
......@@ -2021,7 +2021,7 @@
and b.equ_id = ANY(ARRAY[
<foreach collection="records" item="record" separator=",">
#{record}
</foreach>
</foreach>])
and (a.audit_status <![CDATA[ <> ]]> '已作废')
UNION all
select
......@@ -2085,11 +2085,12 @@
and (a.audit_status <![CDATA[ <> ]]> '已作废')
UNION all
select
a.apply_no as recUserName,
ne.apply_no as recUserName,
ne.record as equId
from
(SELECT
json_array_elements(e.equip_info)->>'SEQUENCE_NBR' AS record
json_array_elements(e.equip_info)->>'SEQUENCE_NBR' AS record,
n.apply_no
FROM
tzs_jg_change_registration_name_eq e,
tzs_jg_change_registration_name n
......@@ -2111,7 +2112,10 @@
tzs_jg_maintain_notice_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and b.equ_id = ANY(ARRAY[
<foreach collection="records" item="record" separator=",">
#{record}
</foreach>])
and (a.notice_status <![CDATA[ <> ]]> '6617')
and a.is_delete = 0
UNION all
......@@ -2123,7 +2127,10 @@
tzs_jg_reform_notice_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and b.equ_id = ANY(ARRAY[
<foreach collection="records" item="record" separator=",">
#{record}
</foreach>])
and (a.notice_status <![CDATA[ <> ]]> '6617')
and a.is_delete = 0
UNION all
......@@ -2135,8 +2142,26 @@
tzs_jg_transfer_notice_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and b.equ_id = ANY(ARRAY[
<foreach collection="records" item="record" separator=",">
#{record}
</foreach>])
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_equip_transfer a,
tzs_jg_equip_transfer_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = ANY(ARRAY[
<foreach collection="records" item="record" separator=",">
#{record}
</foreach>])
and (a.apply_status <![CDATA[ <> ]]> '6617')
</select>
</mapper>
......@@ -368,4 +368,20 @@
#{record}
</foreach>
</select>
<select id="selectListForSelfDiscard" resultType="com.yeejoin.amos.boot.module.jg.api.entity.JgVehicleInformationEq">
select
a.apply_no as recUserName,
b.equ_id
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 = ANY(ARRAY[
<foreach collection="records" item="record" separator=",">
#{record}
</foreach>])
and a.is_delete = 0
and (a.status <![CDATA[ <> ]]> '已作废')
</select>
</mapper>
\ No newline at end of file
......@@ -150,12 +150,13 @@ public class JgUseRegistrationController extends BaseController {
list.getRecords().forEach(x -> {
x.put("companyType", info.getCompany().getCompanyType());
x.put("regType", RegTypeEnum.getNameByCode(String.valueOf(x.get("regType"))).orElse(RegTypeEnum.REGISTRATION_NEW.getName()));
if ("8000".equals(String.valueOf(x.get("equListCode"))) && !ValidationUtil.isEmpty(x.get("projectContraptionId"))) {
x.put("canVoided", jgProjectContraptionMapper.countContraptionInUseTimesForDeleteByIntoManagement(Objects.toString(x.get("projectContraptionId"))) == 0);
} else {
x.put("canVoided", Optional.ofNullable(x.get("useRegistrationCode")).map(jgUseRegistrationServiceImpl::countUseTimesForInvalid)
.orElse(true));
}
// if ("8000".equals(String.valueOf(x.get("equListCode"))) && !ValidationUtil.isEmpty(x.get("projectContraptionId"))) {
// x.put("canVoided", jgProjectContraptionMapper.countContraptionInUseTimesForDeleteByIntoManagement(Objects.toString(x.get("projectContraptionId"))) == 0);
// } else {
// x.put("canVoided", Optional.ofNullable(x.get("useRegistrationCode")).map(jgUseRegistrationServiceImpl::countUseTimesForInvalid)
// .orElse(true));
// }
x.put("canVoided", true);
});
return ResponseHelper.buildResponse(list);
}
......
......@@ -16,7 +16,7 @@ public class DiscardOrderCheckFactory {
public DiscardOrderCheck getDiscardOrderCheck(String clazz) {
for (SupportableDiscardOrderCheck discardOrderCheck : discardOrderChecks) {
if (discardOrderCheck.getClass().getName().equals(clazz)) {
if (discardOrderCheck.support(clazz)) {
return new DiscardOrderCheckWrapper(discardOrderCheck);
}
}
......
package com.yeejoin.amos.boot.module.jg.biz.discardOrder.strategy;
import cn.hutool.core.util.ReUtil;
import com.yeejoin.amos.boot.module.jg.biz.discardOrder.factory.support.SupportableDiscardOrderCheck;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public class GenericDiscardOrderCheck implements SupportableDiscardOrderCheck {
......@@ -21,4 +24,10 @@ public class GenericDiscardOrderCheck implements SupportableDiscardOrderCheck {
public Boolean check(List<String> records) {
return true;
}
public static String buildErrorMsg(String applyNo) {
String prefix = ReUtil.get("^[a-zA-Z]+", applyNo, 0);
String name = Optional.ofNullable(ApplicationFormTypeEnum.getByCode(prefix)).map(ApplicationFormTypeEnum::getBusinessName).orElse("");
return String.format("%s:%s", name, applyNo);
}
}
......@@ -26,7 +26,7 @@ public class InstallNoticeDiscardOrderCheck implements SupportableDiscardOrderCh
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())));
String msg = String.format("存在设备正在办理或已办理使用登记,登记单编号:%s,不能进行作废!", String.join(",", useRegistrationEqs.stream().map(u->GenericDiscardOrderCheck.buildErrorMsg(u.getRecUserName())).collect(Collectors.toSet())));
throw new RuntimeException(msg);
}
return true;
......
......@@ -19,16 +19,18 @@ public class UseRegisterDiscardOrderCheck implements SupportableDiscardOrderChec
@Override
public boolean support(String clazz) {
return JgUseRegistrationServiceImpl.class.getName().equals(clazz);
return JgUseRegistrationServiceImpl.class.getSimpleName().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())));
String msg = String.format("存在设备正在办理或已办理后续业务,单据编号:%s,不能进行作废!", String.join(",", useRegistrationEqs.stream().map(u->GenericDiscardOrderCheck.buildErrorMsg(u.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.module.jg.api.entity.JgVehicleInformationEq;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgVehicleInformationMapper;
import com.yeejoin.amos.boot.module.jg.biz.discardOrder.factory.support.SupportableDiscardOrderCheck;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgVehicleInformationServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
public class VehicleInformationDiscardOrderCheck implements SupportableDiscardOrderCheck {
private final JgVehicleInformationMapper jgVehicleInformationMapper;
@Override
public boolean support(String clazz) {
return JgVehicleInformationServiceImpl.class.getSimpleName().equals(clazz);
}
@Override
public Boolean check(List<String> records) {
List<JgVehicleInformationEq> eqs = jgVehicleInformationMapper.selectListForSelfDiscard(records);
if (!eqs.isEmpty()) {
String msg = String.format("存在设备正在办理或已办理后续业务,单据编号:%s,不能进行作废!", String.join(",", eqs.stream().map(u -> GenericDiscardOrderCheck.buildErrorMsg(u.getRecUserName())).collect(Collectors.toSet())));
throw new RuntimeException(msg);
}
return true;
}
}
......@@ -39,6 +39,7 @@ import com.yeejoin.amos.boot.module.jg.api.vo.tableDataExportVo.InstallationVo;
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.FlowingEquipRedisContext;
import com.yeejoin.amos.boot.module.jg.biz.discardOrder.factory.DiscardOrderCheckFactory;
import com.yeejoin.amos.boot.module.jg.biz.edit.permission.FillingEditPermForCurrentUser;
import com.yeejoin.amos.boot.module.jg.biz.event.CancellationEvent;
import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher;
......@@ -92,6 +93,7 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
......@@ -214,6 +216,9 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
private ToBeSubmitDetailStrategyFactory toBeSubmitDetailStrategyFactory;
@Resource
private DiscardOrderCheckFactory discardOrderCheckFactory;
/**
* 安装改造维修单位吱资质类型:1234-安改维、1236-制造单位
*/
......@@ -1819,10 +1824,10 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class)
public JgInstallationNotice cancelApplication(Long sequenceNbr, String cancelReason) {
JgInstallationNotice installationNotice = this.getById(sequenceNbr);
// 0.校验是否做过使用登记,已发起使用登记(非删除状态)则提示不能进行作废
discardOrderCheckFactory.getDiscardOrderCheck(this.getClass().getSimpleName()).check(getEquList(installationNotice));
// 1.更新为已作废
JgInstallationNotice installationNotice = this.getById(sequenceNbr);
String oldNoticeStatus = installationNotice.getNoticeStatus();
installationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_DISCARD.getCode()));
installationNotice.setCancelReason(cancelReason);
......
......@@ -44,6 +44,7 @@ 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.context.EquipUsedCheckStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext;
import com.yeejoin.amos.boot.module.jg.biz.discardOrder.factory.DiscardOrderCheckFactory;
import com.yeejoin.amos.boot.module.jg.biz.edit.permission.FillingEditPermForCurrentUser;
import com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.useRegister.UseRegisterBackupManager;
import com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler.PieLineLevelTypeHandler;
......@@ -297,6 +298,9 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
@Autowired
private RestHighLevelClient restHighLevelClient;
@javax.annotation.Resource
private DiscardOrderCheckFactory discardOrderCheckFactory;
/**
* @param auditPassDate 通过时间
* @param exportParamsMap 参数map
......@@ -3374,16 +3378,17 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 6000000)
public JgUseRegistration cancelApplication(Long sequenceNbr, String cancelReason) {
// 1.单据更新为已作废
JgUseRegistration jgUseRegistration = this.getById(sequenceNbr);
List<JgUseRegistrationEq> eqList = getJgUseRegistrationEqs(jgUseRegistration);
List<String> records = eqList.stream().map(JgUseRegistrationEq::getEquId).collect(Collectors.toList());
discardOrderCheckFactory.getDiscardOrderCheck(this.getClass().getSimpleName()).check(records);
// 1.单据更新为已作废
String oldStatus = jgUseRegistration.getStatus();
jgUseRegistration.setCancelReason(cancelReason);
jgUseRegistration.setCancelDate(new Date());
jgUseRegistration.setCancelUserId(RequestContext.getExeUserId());
jgUseRegistration.setNextExecuteUserIds("");
jgUseRegistration.setPromoter("");
List<JgUseRegistrationEq> eqList = getJgUseRegistrationEqs(jgUseRegistration);
List<String> records = eqList.stream().map(JgUseRegistrationEq::getEquId).collect(Collectors.toList());
jgUseRegistration.setStatus(FlowStatusEnum.TO_BE_DISCARD.getName());
// 单位办理
......
......@@ -37,6 +37,7 @@ 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.context.EquipUsedCheckStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext;
import com.yeejoin.amos.boot.module.jg.biz.discardOrder.factory.DiscardOrderCheckFactory;
import com.yeejoin.amos.boot.module.jg.biz.edit.permission.FillingEditPermForCurrentUser;
import com.yeejoin.amos.boot.module.jg.biz.event.CancellationAndGradeEvent;
import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher;
......@@ -85,6 +86,7 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.math.BigDecimal;
......@@ -186,6 +188,9 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
@Autowired
private JgVehicleInformationMapper jgVehicleInformationMapper;
@Resource
private DiscardOrderCheckFactory discardOrderCheckFactory;
/**
* @param auditPassDate 通过时间
* @param exportParamsMap 参数map
......@@ -1486,8 +1491,10 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class)
public JgVehicleInformation cancelApplication(Long sequenceNbr, String cancelReason) {
// 1.更新为已作废
JgVehicleInformation vehicleInformation = this.getById(sequenceNbr);
// 0.作废校验
discardOrderCheckFactory.getDiscardOrderCheck(this.getClass().getSimpleName()).check(getEquList(vehicleInformation));
// 1.更新为已作废
String oldStatus = vehicleInformation.getStatus();
vehicleInformation.setStatus(FlowStatusEnum.TO_BE_DISCARD.getName());
vehicleInformation.setCancelReason(cancelReason);
......
......@@ -18,25 +18,25 @@ public enum ApplicationFormTypeEnum {
/**
* 申请单枚举
*/
AZGZ("AZGZ", "GZ_AZ"),//安装告知
WBBA("WBBA", "WB_BA"),//维保合同备案
SYDJ("SYDJ", "DJ_SY"),//使用登记
BZDJ("BZDJ", "DJ_BZ"),// 补证登记
SBYJ("SBYJ", "SB_YJ"),//设备移交
GZGZ("GZGZ", "GZ_GZ"),//改造告知
WXGZ("WXGZ", "GZ_WX"),//维修告知
YZGZ("YZGZ", "GZ_YZ"),//移装告知
GZBG("GZBG", "DJ_GZ"),//改造变更登记
YZBG("YZBG", "DJ_YZ"),//移装变更登记
DWBG("DWBG", "DJ_DW"),//单位变更登记
JY("JY", ""),
SE("SE", ""),// 检验结果
ZX("ZX", "BF_YZ"),//电梯(设备)移装注销
BF("BF", "BF_ZX"),//电梯(设备)报废注销
GMBG("GMBG", "DJ_GM"),//更名变更
SBQY("SBQY", "SB_QY"),//设备启用
CSJ("CSJ", "DJ_CSJ"),//超设计年限
SBTY("SBTY", "SB_TY");//设备启用
AZGZ("AZGZ", "GZ_AZ", "安装告知"),//安装告知
WBBA("WBBA", "WB_BA", "维保合同备案"),//维保合同备案
SYDJ("SYDJ", "DJ_SY", "使用登记"),//使用登记
BZDJ("BZDJ", "DJ_BZ", "补证登记"),// 补证登记
SBYJ("SBYJ", "SB_YJ", "设备移交"),//设备移交
GZGZ("GZGZ", "GZ_GZ", "改造告知"),//改造告知
WXGZ("WXGZ", "GZ_WX", "维修告知"),//维修告知
YZGZ("YZGZ", "GZ_YZ", "移装告知"),//移装告知
GZBG("GZBG", "DJ_GZ", "改造变更登记"),//改造变更登记
YZBG("YZBG", "DJ_YZ", "移装变更登记"),//移装变更登记
DWBG("DWBG", "DJ_DW", "单位变更登记"),//单位变更登记
JY("JY", "", "检验"),
SE("SE", "", "检验结果"),// 检验结果
ZX("ZX", "BF_YZ", "移装注销"),//电梯(设备)移装注销
BF("BF", "BF_ZX", "报废注销"),//电梯(设备)报废注销
GMBG("GMBG", "DJ_GM", "更名变更"),//更名变更
SBQY("SBQY", "SB_QY", "设备启用"),//设备启用
CSJ("CSJ", "DJ_CSJ", "超设计年限"),//超设计年限
SBTY("SBTY", "SB_TY", "设备启用");//设备启用
/**
* 编号
......@@ -48,6 +48,8 @@ public enum ApplicationFormTypeEnum {
*/
private final String businessCode;
private final String businessName;
public static Map<String, String> getBusinessCode = new HashMap<>();
public static Map<String, String> getCode = new HashMap<>();
......@@ -59,4 +61,16 @@ public enum ApplicationFormTypeEnum {
}
public static ApplicationFormTypeEnum getByCode(String code) {
for (ApplicationFormTypeEnum e : ApplicationFormTypeEnum.values()) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}
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