Commit 3a8bd898 authored by Lambertliu's avatar Lambertliu

fix(jg):作废功能bug修改完

parent eafb8348
......@@ -132,78 +132,226 @@
tzs_jg_use_registration ur
</sql>
<select id="getListPage" resultType="java.util.Map">
select
*
<sql id="page-list-sub-pipline">
select
ur.sequence_nbr as sequenceNbr,
ur.audit_status as auditStatus,
date_format(ur.reg_date,'%Y-%m-%d') as regDate,
ur.use_unit_name as useUnitName,
ur.status,
ur.receive_org_name as receiveOrgName,
ur.use_address as place,
ur.instance_id as instanceId,
ur.apply_no as applyNo,
ur.next_execute_ids as nextExecuteIds,
ur.promoter,
ur.use_registration_code as useRegistrationCode,
date_format(ur.audit_pass_date,'%Y-%m-%d') as auditPassDate,
date_format(ur.create_date,'%Y-%m-%d') as createDate,
ur.receive_org_name as receiveOrgName,
ur.next_execute_user_ids as nextExecuteUserIds,
ur.next_task_id as nextTaskId,
ur.create_user_id as createUserId,
ur.rec_date as recDate,
ur.manage_type as manageType,
ur.reg_type as regType,
ur.is_delete,
ur.create_date,
ur.receive_company_code,
ur.use_unit_credit_code,
ur.transfer_to_user_ids,
ur.supervision_org_code,
ur.use_address as fullAddress,
ur.cancel_reason as cancelReason,
ur.project_contraption_id as projectContraptionId,
(select group_concat(re.equ_id) from tzs_jg_use_registration_eq re where ur.sequence_nbr = re.equip_transfer_id) as equipId,
(SELECT
ibjpc.supervisory_code
from
idx_biz_jg_project_contraption ibjpc where ibjpc.sequence_nbr = ur.project_contraption_id) as supervisoryCode,
(SELECT
group_concat(DISTINCT other.CODE96333)
from
idx_biz_jg_register_info jri
LEFT JOIN idx_biz_jg_other_info other on jri.RECORD = other.RECORD where jri.RECORD in (select re.equ_id from tzs_jg_use_registration_eq re where ur.sequence_nbr = re.equip_transfer_id)) as code96333 ,
(SELECT
group_concat(jri.PRODUCT_NAME)
from
idx_biz_jg_register_info jri where jri.RECORD in (select re.equ_id from tzs_jg_use_registration_eq re where ur.sequence_nbr = re.equip_transfer_id)) as productName,
(SELECT
ibjpc.equ_code
from
idx_biz_jg_project_contraption ibjpc where ibjpc.sequence_nbr = ur.project_contraption_id) as equCode,
(SELECT
group_concat(DISTINCT jri.EQU_LIST)
from
idx_biz_jg_register_info jri where jri.RECORD in (select re.equ_id from tzs_jg_use_registration_eq re where ur.sequence_nbr = re.equip_transfer_id)) as equListCode,
(SELECT
group_concat(DISTINCT jri.EQU_CATEGORY)
from
idx_biz_jg_register_info jri where jri.RECORD in (select re.equ_id from tzs_jg_use_registration_eq re where ur.sequence_nbr = re.equip_transfer_id)) as equCategoryCode,
(SELECT
group_concat(DISTINCT jri."EQU_DEFINE")
from
idx_biz_jg_register_info jri where jri.RECORD in (select re.equ_id from tzs_jg_use_registration_eq re where ur.sequence_nbr = re.equip_transfer_id)) as equDefineCode,
(SELECT
group_concat(DISTINCT c.name)
from
idx_biz_jg_register_info jri,tz_equipment_category c where jri.EQU_LIST = c.code and jri.RECORD in (select re.equ_id from tzs_jg_use_registration_eq re where ur.sequence_nbr = re.equip_transfer_id)) as equListName,
(SELECT
group_concat(DISTINCT c.name)
from
idx_biz_jg_register_info jri,tz_equipment_category c where jri.EQU_CATEGORY = c.code and jri.RECORD in (select re.equ_id from tzs_jg_use_registration_eq re where ur.sequence_nbr = re.equip_transfer_id)) as equCategory,
(SELECT
group_concat(DISTINCT c.name)
from
idx_biz_jg_register_info jri,tz_equipment_category c where jri.EQU_DEFINE = c.code and jri.RECORD in (select re.equ_id from tzs_jg_use_registration_eq re where ur.sequence_nbr = re.equip_transfer_id)) as equDefine,
(SELECT
group_concat(DISTINCT ibjsi.ORG_BRANCH_NAME)
from
idx_biz_jg_supervision_info ibjsi where ibjsi.RECORD in (select re.equ_id from tzs_jg_use_registration_eq re where ur.sequence_nbr = re.equip_transfer_id)) as orgBranchName
from
(
<include refid="page-list-sub-select"/>
tzs_jg_use_registration ur
</sql>
<select id="getListPage" resultType="java.util.Map">
SELECT * FROM (
-- 查询 equListCode = '8000' 的情况
SELECT *
FROM (
<include refid="page-list-sub-select"/>
)
<where>
is_delete = 0
AND equListCode <![CDATA[<>]]>'8000'
<if test="dto.equList != null and dto.equList != ''">
AND equListCode = #{dto.equList}
</if>
<if test="dto.equCategory != null and dto.equCategory != ''">
AND equCategoryCode = #{dto.equCategory}
</if>
<if test="dto.equDefine != null and dto.equDefine != ''">
AND equDefineCode = #{dto.equDefine}
</if>
<if test="dto.status != null and dto.status != ''">
AND status = #{dto.status}
</if>
<if test="dto.applicationDate != null">
AND create_date LIKE CONCAT('%', DATE_FORMAT(#{dto.applicationDate}, '%Y-%m-%d'), '%')
</if>
<if test="dto.equCode != null and dto.equCode != ''">
AND equCode LIKE CONCAT('%', #{dto.equCode}, '%')
</if>
<if test="dto.code96333 != null and dto.code96333 != ''">
AND code96333 LIKE CONCAT('%', #{dto.code96333}, '%')
</if>
<if test="dto.supervisoryCode != null and dto.supervisoryCode != ''">
AND supervisoryCode LIKE CONCAT('%', #{dto.supervisoryCode}, '%')
</if>
<if test="dto.fullAddress != null and dto.fullAddress != ''">
AND fullAddress LIKE CONCAT('%', #{dto.fullAddress}, '%')
</if>
<if test="dto.useUnitName != null and dto.useUnitName != ''">
AND useUnitName LIKE CONCAT('%', #{dto.useUnitName}, '%')
</if>
<if test="dto.applyNo != null and dto.applyNo != ''">
AND applyNo LIKE CONCAT('%', #{dto.applyNo}, '%')
</if>
<if test="dto.useRegistrationCode != null and dto.useRegistrationCode != ''">
AND useRegistrationCode LIKE CONCAT('%', #{dto.useRegistrationCode}, '%')
</if>
<if test="dto.useUnitCode != null and dto.useUnitCode != ''">
AND use_unit_credit_code = #{dto.useUnitCode}
</if>
<if test="dto.auditPassDateStart != null and dto.auditPassDateEnd != null">
AND auditPassDate BETWEEN #{dto.auditPassDateStart} AND #{dto.auditPassDateEnd}
</if>
<if test="dto.dataType == 'supervision' ">
<choose>
<when test="client == 'jgAudit'">
AND (receive_company_code = #{dto.receiveCompanyCode}
OR transfer_to_user_ids LIKE CONCAT('%', #{dto.currentUserId}, '%'))
</when>
<otherwise>
AND supervision_org_code LIKE CONCAT(#{dto.supervisionOrgCode}, '%')
</otherwise>
</choose>
AND status <![CDATA[<>]]> '使用单位待提交'
</if>
<if test="dto.dataType == 'company' ">
AND (use_unit_credit_code = #{dto.unitCode} OR transfer_to_user_ids LIKE CONCAT ('%',#{dto.currentUserId}, '%'))
</if>
</where>
UNION ALL
-- 查询 equListCode != '8000' 的情况
SELECT *
FROM (
<include refid="page-list-sub-pipline"/>
)
<where>
is_delete = 0
AND equListCode = '8000'
<if test="dto.equList != null and dto.equList != ''">
and equListCode= #{dto.equList}
AND #{dto.equList} = ANY(string_to_array(equListCode, ','))
</if>
<if test="dto.equCategory != null and dto.equCategory != ''">
and equCategoryCode = #{dto.equCategory}
AND equCategoryCode = #{dto.equCategory}
</if>
<if test="dto.equDefine != null and dto.equDefine != ''">
and equDefineCode = #{dto.equDefine}
AND equDefineCode = #{dto.equDefine}
</if>
<if test="dto.status != null and dto.status != ''">
and status = #{dto.status}
AND status = #{dto.status}
</if>
<if test="dto.applicationDate != null">
and create_date like concat('%',DATE_FORMAT(#{dto.applicationDate},'%Y-%m-%d'),'%')
AND create_date LIKE CONCAT('%', DATE_FORMAT(#{dto.applicationDate}, '%Y-%m-%d'), '%')
</if>
<if test="dto.equCode != null and dto.equCode != ''">
and equCode like concat('%',#{dto.equCode},'%')
AND equCode LIKE CONCAT('%', #{dto.equCode}, '%')
</if>
<if test="dto.code96333 != null and dto.code96333 != ''">
and code96333 like concat('%',#{dto.code96333},'%')
AND code96333 LIKE CONCAT('%', #{dto.code96333}, '%')
</if>
<if test="dto.supervisoryCode != null and dto.supervisoryCode != ''">
and supervisoryCode like concat('%',#{dto.supervisoryCode},'%')
AND supervisoryCode LIKE CONCAT('%', #{dto.supervisoryCode}, '%')
</if>
<if test="dto.fullAddress != null and dto.fullAddress != ''">
AND fullAddress LIKE CONCAT('%', #{dto.fullAddress}, '%')
AND fullAddress LIKE CONCAT('%', #{dto.fullAddress}, '%')
</if>
<if test="dto.useUnitName != null and dto.useUnitName != ''">
and useUnitName like concat('%',#{dto.useUnitName},'%')
AND useUnitName LIKE CONCAT('%', #{dto.useUnitName}, '%')
</if>
<if test="dto.applyNo != null and dto.applyNo != ''">
and applyNo like concat('%',#{dto.applyNo},'%')
AND applyNo LIKE CONCAT('%', #{dto.applyNo}, '%')
</if>
<if test="dto.useRegistrationCode != null and dto.useRegistrationCode != ''">
and useRegistrationCode like concat('%',#{dto.useRegistrationCode},'%')
AND useRegistrationCode LIKE CONCAT('%', #{dto.useRegistrationCode}, '%')
</if>
<if test="dto.useUnitCode != null and dto.useUnitCode != ''">
and use_unit_credit_code = #{dto.useUnitCode}
AND use_unit_credit_code = #{dto.useUnitCode}
</if>
<if test="dto.auditPassDateStart != null and dto.auditPassDateEnd != null">
AND auditPassDate BETWEEN #{dto.auditPassDateStart} AND #{dto.auditPassDateEnd}
</if>
<if test="dto.dataType == 'supervision' ">
<choose>
<when test="client == 'jgAudit'">
AND
(
receive_company_code = #{dto.receiveCompanyCode}
OR transfer_to_user_ids LIKE concat ('%',#{dto.currentUserId}, '%')
)
</when>
<otherwise>
and supervision_org_code LIKE concat (#{dto.supervisionOrgCode}, '%')
</otherwise>
</choose>
AND status <![CDATA[<>]]> '使用单位待提交'
<choose>
<when test="client == 'jgAudit'">
AND (receive_company_code = #{dto.receiveCompanyCode}
OR transfer_to_user_ids LIKE CONCAT('%', #{dto.currentUserId}, '%'))
</when>
<otherwise>
AND supervision_org_code LIKE CONCAT(#{dto.supervisionOrgCode}, '%')
</otherwise>
</choose>
AND status <![CDATA[<>]]> '使用单位待提交'
</if>
<if test="dto.dataType == 'company' ">
AND (use_unit_credit_code = #{dto.unitCode} or transfer_to_user_ids LIKE concat ('%',#{dto.currentUserId}, '%'))
AND (use_unit_credit_code = #{dto.unitCode} OR transfer_to_user_ids LIKE CONCAT ('%',#{dto.currentUserId}, '%'))
</if>
</where>
order by
) AS combined_results
ORDER BY
<choose>
<when test="sort != null">
${sort.field} ${sort.sortType}
......
......@@ -84,6 +84,8 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -502,11 +504,13 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
projectContraption.setEquCategoryName(equCategoryName);
projectContraption.setEquDefineName(equDefineName);
projectContraption.setPipelineLength(
pipelineList.stream()
.map(pipeline -> pipeline.get("pipeLength"))
.filter(Objects::nonNull)
.mapToDouble(pipeLength -> Double.parseDouble(String.valueOf(pipeLength)))
.sum()
BigDecimal.valueOf(pipelineList.stream()
.map(pipeline -> pipeline.get("pipeLength"))
.filter(Objects::nonNull)
.mapToDouble(pipeLength -> Double.parseDouble(String.valueOf(pipeLength)))
.sum())
.setScale(2, RoundingMode.HALF_UP)
.doubleValue()
);
projectContraption.setUscUnitName(companyInfoMap.get("companyName").toString());
......
......@@ -89,6 +89,8 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -1923,7 +1925,9 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
result.fluentPut("deviceList", deviceList)
.fluentPut("projectContraption", projectContraption.getProjectContraption())
.fluentPut("projectContraptionNo", projectContraption.getProjectContraptionNo())
.fluentPut("pipelineLength", projectContraption.getPipelineLength())
.fluentPut("pipelineLength", BigDecimal.valueOf(projectContraption.getPipelineLength())
.setScale(2, RoundingMode.HALF_UP)
.doubleValue())
.fluentPut("projectContraptionId", projectContraptionSeq);
if (!ValidationUtil.isEmpty(projectContraption.getCity())) {
result.fluentPut("city", projectContraption.getCity() + "_" + projectContraption.getCityName());
......
......@@ -534,6 +534,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
IdxBizJgOtherInfo otherInfo = otherInfoMapper.selectOne(otherLambda);
String supervisoryCode = otherInfo.getSupervisoryCode();
jgUseRegistration.setSupervisoryCode(supervisoryCode);
jgUseRegistration.setManageType("set");
if (!ObjectUtils.isEmpty(map.get("otherAccessories"))) {
jgUseRegistration.setOtherAccessories(JSONObject.toJSONString(map.get("otherAccessories")));
......@@ -742,8 +743,18 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
lambda.select(JgUseRegistrationEq::getEquId);
List<JgUseRegistrationEq> eqList = jgRelationEquipMapper.selectList(lambda);
// 在使用单位待提交、一级受理已驳回、使用单位已撤回后清除关联的设备,保证可以再次新提单子选择相同的设备进行提交及原有单子的提交校验数据准备
if (NOT_FLOWING_STATE.contains(useRegistrationDb.getStatus())) {
if (NOT_FLOWING_STATE.contains(useRegistrationDb.getStatus()) ||
FlowStatusEnum.TO_BE_DISCARD.getName().equals(data.getStatus())) {
List<String> records = eqList.stream().map(JgUseRegistrationEq::getEquId).collect(toList());
//合并的管道只需要子工程装置管道集合
if (Objects.nonNull(data.getOriginProjectContraptionIds()) &&
!data.getOriginProjectContraptionIds().contains(data.getProjectContraptionId())){
List<IdxBizJgUseInfo> useInfoRecords = idxBizJgUseInfoService.lambdaQuery()
.select(IdxBizJgUseInfo::getRecord)
.in(IdxBizJgUseInfo::getProjectContraptionId, Arrays.asList(data.getOriginProjectContraptionIds().split(",")))
.list();
records = useInfoRecords.stream().map(IdxBizJgUseInfo::getRecord).collect(Collectors.toList());
}
EquipUsedCheckStrategyContext.getUsedStrategy(DEFINITION_KEY)
.delDataForCheckEquipRepeatUsed(records, data.getUseUnitCreditCode());
}
......@@ -2457,21 +2468,22 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
throw new BadRequest("没有查询到汇总信息!");
}
JSONArray allEquipment = new JSONArray();
// 用Set存储已添加的equCode,防止重复添加
Set<String> addedEquCodes = new HashSet<>();
registrationHistoryList.forEach(historyList -> {
JSONObject jsonObject = JSONObject.parseObject(historyList.getChangeData());
JSONArray equipmentLists = (JSONArray) jsonObject.get("equipmentLists");
if("安装告知".equals(type)){
equipmentLists =(JSONArray) jsonObject.get("deviceList");
}
// 填充投用年月
String useDateValue = (String) jsonObject.get("useDate");
JSONArray equipmentLists = "安装告知".equals(type)
? (JSONArray) jsonObject.get("deviceList")
: (JSONArray) jsonObject.get("equipmentLists");
final String useDateValue = jsonObject.getString("useDate");
if (CollectionUtils.isNotEmpty(equipmentLists)) {
equipmentLists = equipmentLists.stream()
equipmentLists.stream()
.map(obj -> (JSONObject) obj)
.peek(equipmentItem -> equipmentItem.put("useDate", timeToMonths(useDateValue)))
.filter(equipmentItem -> this.checkEquStatusInUse(equipmentItem.getString("record")))
.collect(Collectors.toCollection(JSONArray::new));
allEquipment.addAll(equipmentLists);
.filter(equipmentItem -> addedEquCodes.add(equipmentItem.getString("equCode")))
.forEach(allEquipment::add);
}
});
total = allEquipment.size();
......@@ -2935,6 +2947,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
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());
// 单位办理
if ("unit".equals(jgUseRegistration.getManageType())){
......@@ -2960,7 +2973,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
}
} else{
//判断是否管道
if (FlowStatusEnum.TO_BE_FINISHED.getName().equals(jgUseRegistration.getStatus()) &&
if (FlowStatusEnum.TO_BE_FINISHED.getName().equals(oldStatus) &&
jgUseRegistration.getUseRegistrationCode().startsWith("管")) {
JgUseRegistration lastUseRegistration = jgUseRegistrationMapper.selectOne(new LambdaQueryWrapper<JgUseRegistration>()
.select(JgUseRegistration::getApplyNo)
......@@ -2974,10 +2987,9 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
throw new BadRequest("作废失败,该使用登记证下有合并工程装置,请先作废最新单据后再作废此单据!");
}
if (jgUseRegistration.getProjectContraptionId() == null) {
throw new BadRequest("该作废单据没有工程装置,请联系管理员处理此单据!");
throw new BadRequest("该作废单据没有工程装置,请联系管理员处理此单据:"+ jgUseRegistration.getApplyNo());
}
}
if (jgUseRegistration.getProjectContraptionId() != null) {
//2.合并后作废
if (!jgUseRegistration.getOriginProjectContraptionIds().contains(jgUseRegistration.getProjectContraptionId())){
......@@ -3048,24 +3060,25 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
// 统一处理设备的纳管状态
registerAfterCommitTask(records);
processElseDataByStatus(oldStatus, jgUseRegistration);
// 计算管道长度并更新
double originPipelineLength = originProjectContraptionList.stream()
.map(IdxBizJgProjectContraption::getPipelineLength)
.filter(Objects::nonNull)
.mapToDouble(Double::doubleValue)
.sum();
projectContraption.setPipelineLength(projectContraption.getPipelineLength() - originPipelineLength);
if (FlowStatusEnum.TO_BE_FINISHED.getName().equals(oldStatus)) {
// 计算管道长度并更新
double originPipelineLength = originProjectContraptionList.stream()
.map(IdxBizJgProjectContraption::getPipelineLength)
.filter(Objects::nonNull)
.mapToDouble(Double::doubleValue)
.sum();
projectContraption.setPipelineLength(projectContraption.getPipelineLength() - originPipelineLength);
}
}
jgProjectContraptionService.updateById(projectContraption);
}
}
//1.子工程装置作废,正常逻辑
else {
// 统一处理设备的纳管状态【注册事务提交后的操作】
registerAfterCommitTask(records);
processElseDataByStatus(oldStatus, jgUseRegistration);
this.rollBackForPieLine(jgUseRegistration);
}
}
//气瓶
......@@ -3084,7 +3097,6 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
// 统一处理设备的纳管状态【注册事务提交后的操作】
registerAfterCommitTask(records);
}
jgUseRegistration.setStatus(FlowStatusEnum.TO_BE_DISCARD.getName());
this.updateById(jgUseRegistration);
return jgUseRegistration;
}
......@@ -3104,32 +3116,33 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
private void clearUseInfoOfEquip(JgUseRegistration jgUseRegistration) {
List<JgUseRegistrationEq> eqList = getJgUseRegistrationEqs(jgUseRegistration);
// 0.压力管道 清空装置表的使用登记证编号、删除装置的检验信息
this.rollBackForPieLine(jgUseRegistration);
eqList.forEach(e -> {
String record = e.getEquId();
Boolean flag = Boolean.FALSE;
LambdaQueryWrapper<IdxBizJgRegisterInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(IdxBizJgRegisterInfo::getRecord, record);
IdxBizJgRegisterInfo idxBizJgRegisterInfo = idxBizJgRegisterInfoMapper.selectOne(lambdaQueryWrapper);
if (!ObjectUtils.isEmpty(idxBizJgRegisterInfo)) {
String equCategory = idxBizJgRegisterInfo.getEquCategory();
List<String> codes = UseRegisterCancelEquipEnum.getCodes();
if (codes.contains(equCategory)) {
flag = Boolean.TRUE;
//非管道
if(StringUtils.isEmpty(jgUseRegistration.getProjectContraptionId())){
eqList.forEach(e -> {
String record = e.getEquId();
Boolean flag = Boolean.FALSE;
LambdaQueryWrapper<IdxBizJgRegisterInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(IdxBizJgRegisterInfo::getRecord, record);
IdxBizJgRegisterInfo idxBizJgRegisterInfo = idxBizJgRegisterInfoMapper.selectOne(lambdaQueryWrapper);
if (!ObjectUtils.isEmpty(idxBizJgRegisterInfo)) {
String equCategory = idxBizJgRegisterInfo.getEquCategory();
List<String> codes = UseRegisterCancelEquipEnum.getCodes();
if (codes.contains(equCategory)) {
flag = Boolean.TRUE;
}
}
}
// 1.使用信息表部分字段赋空
this.rollBackUseInfo(record, flag);
// 2.回滚更新idx_biz_jg_register_info表
this.rollBackRegisterInfo(record);
// 3.回滚更新idx_biz_jg_supervision_info表
this.rollBackSupervisionInfo(record);
// 4.es的EQU_STATE, USE_ORG_CODE、ORG_BRANCH_CODE、ORG_BRANCH_NAME、STATUS
this.rollBackForEquipEsInfo(record, flag,jgUseRegistration);
// 5.历史设备处理
this.dealHisRegEquipData(jgUseRegistration, record);
});
// 1.使用信息表部分字段赋空
this.rollBackUseInfo(record, flag);
// 2.回滚更新idx_biz_jg_register_info表
this.rollBackRegisterInfo(record);
// 3.回滚更新idx_biz_jg_supervision_info表
this.rollBackSupervisionInfo(record);
// 4.es的EQU_STATE, USE_ORG_CODE、ORG_BRANCH_CODE、ORG_BRANCH_NAME、STATUS
this.rollBackForEquipEsInfo(record, flag,jgUseRegistration);
// 5.历史设备处理
this.dealHisRegEquipData(jgUseRegistration, record);
});
}
Set<String> equipTransferIds = eqList.stream()
.map(JgUseRegistrationEq::getEquipTransferId)
.filter(Objects::nonNull)
......@@ -3147,7 +3160,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
updateWrapper.set(IdxBizJgProjectContraption::getUseRegistrationCode, null);
idxBizJgProjectContraptionMapper.update(null, updateWrapper);
// 删除改装置的检验信息【只有是在使用登记页面新增的才会删除,使用登记终审通过时,插入的检验信息id为使用登记的主键】
projectInspectionMapper.deleteById(jgUseRegistration.getSequenceNbr());
// projectInspectionMapper.deleteById(jgUseRegistration.getSequenceNbr());
}
}
......@@ -4223,9 +4236,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
.put("projectContraptionNo", projectContraption.getProjectContraptionNo())
.put("isFirstMerge", projectContraption.getIsFirstMerge())
.put("pipelineLength", totalPipelineLength);
if (Objects.nonNull(projectContraption.getUseRegistrationCode())){
setProjectContraptionInfo(projectContraption, resultBuilder);
}
setProjectContraptionInfo(projectContraption, resultBuilder);
return resultBuilder.build();
}
......@@ -4233,11 +4244,11 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
// 查询最新的历史记录
JgRegistrationHistory history = jgRegistrationHistoryService.queryLatestRegistrationHistory(projectContraption.getSequenceNbr());
Map<String, Object> fieldMappings = new HashMap<>();
if (history != null && history.getChangeData() != null) {
JSONObject hisJson = JSON.parseObject(history.getChangeData());
Map<String, Object> fieldMappings = new HashMap<>();
fieldMappings.put("useRegistrationCode", projectContraption.getUseRegistrationCode());
fieldMappings.put("safetyManager", hisJson.get("safetyManagerId") + "_" +hisJson.get("safetyManager"));
fieldMappings.put("safetyManager", hisJson.get("safetyManagerId") + "_" + hisJson.get("safetyManager"));
fieldMappings.put("useDate", hisJson.get("useDate"));
fieldMappings.put("otherAccessories", hisJson.get("otherAccessories"));
fieldMappings.put("factoryUseSiteStreet", hisJson.get("factoryUseSiteStreet"));
......@@ -4256,8 +4267,18 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
hisJson.get("endLatitudeLongitude"));
fieldMappings.put("estateUnitName", hisJson.get("estateUnitName"));
fieldMappings.put("orgBranchCode", hisJson.get("orgBranchCode"));
fieldMappings.forEach(re::put);
} else {
fieldMappings.put("province", projectContraption.getProvince());
fieldMappings.put("city", projectContraption.getCity());
fieldMappings.put("county", projectContraption.getCounty());
fieldMappings.put("factoryUseSiteStreet", projectContraption.getStreet());
fieldMappings.put("address", projectContraption.getAddress());
fieldMappings.put("startLatitudeLongitude", JSON.parseObject(projectContraption.getStartLatitudeLongitude()));
fieldMappings.put("endLatitudeLongitude", JSON.parseObject(projectContraption.getEndLatitudeLongitude()));
fieldMappings.put("orgBranchCode", projectContraption.getOrgCode()+"_"+ projectContraption.getOrgName());
}
fieldMappings.forEach(re::put);
}
private void setConstructionInfo(String projectContraptionSeq, Map<String, Object> re) {
......
......@@ -276,110 +276,47 @@
</select>
<select id="countContraptionInUseTimesForDeleteByIntoManagement" resultType="java.lang.Integer">
SELECT
SUM(inUseNumber)
FROM (
SELECT
COUNT(1) AS inUseNumber
FROM tzs_jg_equip_transfer a
LEFT JOIN tzs_jg_equip_transfer_eq b ON b.equip_transfer_id=a.sequence_nbr
LEFT JOIN idx_biz_jg_use_info c ON b.equ_id=c.record
WHERE c.project_contraption_id = #{projectContraptionId}
AND a.is_delete = 0
AND ( a.apply_status != '6617')
UNION
SELECT
COUNT(1) AS inUseNumber
FROM
tzs_jg_use_registration a
WHERE a.project_contraption_id = #{projectContraptionId}
AND a.is_delete = 0
AND ( a.status != '已作废')
UNION
SELECT
COUNT(1) AS inUseNumber
FROM tzs_jg_change_registration_unit a
LEFT JOIN tzs_jg_change_registration_unit_eq b ON b.unit_change_registration_id=a.sequence_nbr
LEFT JOIN idx_biz_jg_use_info c ON b.equ_id=c.record
WHERE c.project_contraption_id = #{projectContraptionId}
AND a.is_delete = 0
AND ( a.status != '已作废')
UNION
SELECT
COUNT(1) AS inUseNumber
FROM tzs_jg_enable_disable a
LEFT JOIN tzs_jg_enable_disable_eq b ON b.enable_disable_apply_id=a.sequence_nbr
LEFT JOIN idx_biz_jg_use_info c ON b.equ_id=c.record
WHERE c.project_contraption_id = #{projectContraptionId}
AND a.is_delete = 0
AND ( a.audit_status != '已作废')
UNION
SELECT
COUNT(1) AS inUseNumber
FROM tzs_jg_scrap_cancel a
LEFT JOIN tzs_jg_scrap_cancel_eq b ON b.equip_transfer_id=a.sequence_nbr
LEFT JOIN idx_biz_jg_use_info c ON b.equ_id=c.record
WHERE c.project_contraption_id = #{projectContraptionId}
AND a.is_delete = 0
AND ( a.audit_status != '使用单位已撤回')
UNION
SELECT
COUNT(1) AS inUseNumber
FROM tzs_jg_change_registration_transfer a
LEFT JOIN tzs_jg_change_registration_transfer_eq b ON b.equip_transfer_id=a.sequence_nbr
LEFT JOIN idx_biz_jg_use_info c ON b.equ_id=c.record
WHERE c.project_contraption_id = #{projectContraptionId}
AND a.is_delete = 0
AND ( a.audit_status != '使用单位已撤回')
UNION
SELECT
COUNT(1) AS inUseNumber
FROM tzs_jg_change_registration_name a
LEFT JOIN tzs_jg_change_registration_name_eq b ON b.name_change_registration_id=a.sequence_nbr
LEFT JOIN idx_biz_jg_use_info c ON b.equ_id=c.record
WHERE c.project_contraption_id = #{projectContraptionId}
AND a.is_delete = 0
AND ( a.audit_status != '使用单位已撤回')
UNION
SELECT
COUNT(1) AS inUseNumber
FROM
tzs_jg_installation_notice a
WHERE a.project_contraption_id = #{projectContraptionId}
AND (a.notice_status != '6617')
UNION
SELECT
COUNT(1) AS inUseNumber
FROM tzs_jg_maintain_notice a
LEFT JOIN tzs_jg_maintain_notice_eq b ON b.equip_transfer_id=a.sequence_nbr
LEFT JOIN idx_biz_jg_use_info c ON b.equ_id=c.record
WHERE c.project_contraption_id = #{projectContraptionId}
AND a.is_delete = 0
AND ( a.notice_status != '6617')
UNION
SELECT
COUNT(1) AS inUseNumber
FROM tzs_jg_reform_notice a
LEFT JOIN tzs_jg_reform_notice_eq b ON b.equip_transfer_id=a.sequence_nbr
LEFT JOIN idx_biz_jg_use_info c ON b.equ_id=c.record
WHERE c.project_contraption_id = #{projectContraptionId}
AND a.is_delete = 0
AND ( a.notice_status != '6617')
UNION
SELECT
COUNT(1) AS inUseNumber
FROM tzs_jg_transfer_notice a
LEFT JOIN tzs_jg_transfer_notice_eq b ON b.equip_transfer_id=a.sequence_nbr
LEFT JOIN idx_biz_jg_use_info c ON b.equ_id=c.record
WHERE c.project_contraption_id = #{projectContraptionId}
AND a.is_delete = 0
AND ( a.notice_status != '6617')
UNION
SELECT
COUNT(1) AS inUseNumber
FROM tz_jyjc_inspection_application a
WHERE a.project_contraption_id = #{projectContraptionId}
AND ( a.status != '6617')
)
SELECT SUM(inUseNumber) FROM (
SELECT COUNT(DISTINCT A.sequence_nbr) AS inUseNumber FROM tzs_jg_equip_transfer A
LEFT JOIN tzs_jg_equip_transfer_eq b ON b.equip_transfer_id = A.sequence_nbr
LEFT JOIN idx_biz_jg_use_info C ON b.equ_id = C.record
WHERE C.project_contraption_id = #{projectContraptionId}
AND A.is_delete = 0
AND A.apply_status != '6617'
UNION
SELECT COUNT(1) AS inUseNumber FROM tzs_jg_use_registration A
WHERE A.project_contraption_id = #{projectContraptionId}
AND A.is_delete = 0
AND A.status != '已作废'
UNION
SELECT COUNT(DISTINCT A.sequence_nbr) AS inUseNumber FROM tzs_jg_change_registration_unit A
LEFT JOIN tzs_jg_change_registration_unit_eq b ON b.unit_change_registration_id = A.sequence_nbr
LEFT JOIN idx_biz_jg_use_info C ON b.equ_id = C.record
WHERE C.project_contraption_id = #{projectContraptionId}
AND A.is_delete = 0
AND A.status != '已作废'
UNION
SELECT COUNT(DISTINCT A.sequence_nbr) AS inUseNumber FROM tzs_jg_enable_disable A
LEFT JOIN tzs_jg_enable_disable_eq b ON b.enable_disable_apply_id = A.sequence_nbr
LEFT JOIN idx_biz_jg_use_info C ON b.equ_id = C.record
WHERE C.project_contraption_id = #{projectContraptionId}
AND A.is_delete = 0
AND A.audit_status != '已作废'
UNION
SELECT COUNT(DISTINCT A.sequence_nbr) AS inUseNumber FROM tzs_jg_scrap_cancel A
LEFT JOIN tzs_jg_scrap_cancel_eq b ON b.equip_transfer_id = A.sequence_nbr
LEFT JOIN idx_biz_jg_use_info C ON b.equ_id = C.record
WHERE C.project_contraption_id = #{projectContraptionId}
AND A.is_delete = 0
AND A.audit_status != '使用单位已撤回'
UNION
SELECT COUNT(1) AS inUseNumber FROM tzs_jg_installation_notice A
WHERE A.project_contraption_id = #{projectContraptionId}
AND A.notice_status != '6617'
UNION
SELECT COUNT(1) AS inUseNumber FROM tz_jyjc_inspection_application A
WHERE A.project_contraption_id = #{projectContraptionId}
AND A.status != '6617'
) AS result
</select>
</mapper>
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