Commit 57eaa4f8 authored by tianbo's avatar tianbo

bugfix:

管道列表优化
parent fce10494
...@@ -32,10 +32,12 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -32,10 +32,12 @@ import org.springframework.beans.factory.annotation.Autowired;
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.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StopWatch;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
...@@ -52,6 +54,7 @@ import java.util.stream.IntStream; ...@@ -52,6 +54,7 @@ import java.util.stream.IntStream;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import static com.alibaba.fastjson.JSON.toJSONString; import static com.alibaba.fastjson.JSON.toJSONString;
/** /**
* 管道工程装置表服务实现类 * 管道工程装置表服务实现类
...@@ -197,6 +200,7 @@ public class IdxBizJgProjectContraptionServiceImpl extends BaseService<IdxBizJgP ...@@ -197,6 +200,7 @@ public class IdxBizJgProjectContraptionServiceImpl extends BaseService<IdxBizJgP
.isNull(IdxBizJgProjectContraption::getProjectContraptionParentId) .isNull(IdxBizJgProjectContraption::getProjectContraptionParentId)
.orderByDesc(IdxBizJgProjectContraption::getRecDate) .orderByDesc(IdxBizJgProjectContraption::getRecDate)
.page(page); .page(page);
if (!ValidationUtil.isEmpty(pageList.getRecords())) {
pageList.getRecords().forEach(record -> { pageList.getRecords().forEach(record -> {
BigDecimal pipelineLength = BigDecimal.valueOf(record.getPipelineLength()); BigDecimal pipelineLength = BigDecimal.valueOf(record.getPipelineLength());
BigDecimal roundedValue = pipelineLength.setScale(3, RoundingMode.HALF_UP); BigDecimal roundedValue = pipelineLength.setScale(3, RoundingMode.HALF_UP);
...@@ -208,42 +212,87 @@ public class IdxBizJgProjectContraptionServiceImpl extends BaseService<IdxBizJgP ...@@ -208,42 +212,87 @@ public class IdxBizJgProjectContraptionServiceImpl extends BaseService<IdxBizJgP
.map(value -> value == null ? "" : value) .map(value -> value == null ? "" : value)
.collect(Collectors.joining()) .collect(Collectors.joining())
); );
record.setCanEdit(this.checkContraptionIsCanEdit(record.getSequenceNbr()));
record.setCanDelete(this.checkContraptionIsCanDelete(record.getSequenceNbr(),isIntoManagement));
//判断是否有检验结果录入
judgeCheckResult(record);
}); });
List<Long> projectContraptionIdList = pageList.getRecords().stream().map(IdxBizJgProjectContraption::getSequenceNbr).collect(Collectors.toList());
Map<String, Boolean> canEditMap = this.checkContraptionIsCanEdit(projectContraptionIdList);
pageList.getRecords().forEach(record -> record.setCanEdit(canEditMap.get(record.getSequenceNbr())));
Map<String, Boolean> canDeleteMap = this.checkContraptionIsCanDelete(projectContraptionIdList, isIntoManagement);
pageList.getRecords().forEach(record -> record.setCanDelete(canDeleteMap.get(record.getSequenceNbr())));
//判断是否有检验结果录入
judgeCheckResult(pageList.getRecords());
}
return pageList; return pageList;
} }
/** /**
* 此处判断是否有检验结果 所有的管道信息都需要有检验结果才可以展示 * 此处判断是否有检验结果 所有的管道信息都需要有检验结果才可以展示
* @param record * @param records
*/ */
private void judgeCheckResult(IdxBizJgProjectContraption record) { private void judgeCheckResult(List<IdxBizJgProjectContraption> records) {
record.setDisableBasicButton(true); List<IdxBizJgProjectContraption> pipelineList = records.stream().filter(record -> PipelineEnum.PRESSURE_PIPELINE.getCode().equals(record.getEquList())).collect(Collectors.toList());
if ("8200".equals(record.getEquCategory()) || "8100".equals(record.getEquCategory()) || "8300".equals(record.getEquCategory())) { if (!ValidationUtil.isEmpty(pipelineList)) {
int notNullCount = this.baseMapper.selectCheckCountByNotNull(String.valueOf(record.getSequenceNbr())); StopWatch watch1 = new StopWatch();
long total = this.baseMapper.selectEquipCount(String.valueOf(record.getSequenceNbr())); List<Long> projectContraptionIdList = pipelineList.stream().map(IdxBizJgProjectContraption::getSequenceNbr).collect(Collectors.toList());
if(total==notNullCount && total !=0){ watch1.start();
List<Map<String, Integer>> notNullCountList = this.baseMapper.selectCheckCountByNotNull(projectContraptionIdList);
watch1.stop();
System.out.println("watch1:" + watch1.getTotalTimeMillis());
StopWatch watch2 = new StopWatch();
watch2.start();
List<Map<String, Integer>> totalList = this.baseMapper.selectEquipCount(projectContraptionIdList);
watch2.stop();
System.out.println("watch2:" + watch2.getTotalTimeMillis());
for (IdxBizJgProjectContraption record : pipelineList) {
Map<String, Integer> totalMap = totalList.stream().filter(item -> String.valueOf(record.getSequenceNbr()).equals(item.get("project_contraption_id"))).findFirst().orElse(new HashMap<>());
Map<String, Integer> notNullCountMap = notNullCountList.stream().filter(item -> String.valueOf(record.getSequenceNbr()).equals(item.get("project_contraption_id"))).findFirst().orElse(new HashMap<>());
Integer total = totalMap.get("count");
Integer notNullCount = notNullCountMap.get("count");
if(total != null && total.equals(notNullCount) && total != 0){
record.setDisableBasicButton(false); record.setDisableBasicButton(false);
} }
} }
} }
}
private Map<String, Boolean> checkContraptionIsCanEdit(List<Long> projectContraptionIdList) {
Map<String, Boolean> resultMap = new HashMap<>();
if (ValidationUtil.isEmpty(projectContraptionIdList)) {
return resultMap;
}
List<Map<String, Integer>> inUseTimeMap = this.baseMapper.countContraptionInUseTimesForEdit(projectContraptionIdList);
return getCheckResultMap(projectContraptionIdList, resultMap, inUseTimeMap);
}
private Boolean checkContraptionIsCanEdit(Long projectContraptionId) {
Integer inUseTime = this.baseMapper.countContraptionInUseTimesForEdit(projectContraptionId); private Map<String, Boolean> checkContraptionIsCanDelete(List<Long> projectContraptionIdList, Boolean isIntoManagement) {
return inUseTime <= 0; Map<String, Boolean> resultMap = new HashMap<>();
if (ValidationUtil.isEmpty(projectContraptionIdList)) {
return resultMap;
}
List<Map<String, Integer>> inUseTimeMap;
if(isIntoManagement) {
inUseTimeMap = this.baseMapper.countContraptionInUseTimesForDeleteByIntoManagementBatch(projectContraptionIdList);
} else {
inUseTimeMap = this.baseMapper.countContraptionInUseTimesForDelete(projectContraptionIdList);
}
return getCheckResultMap(projectContraptionIdList, resultMap, inUseTimeMap);
} }
private Boolean checkContraptionIsCanDelete(Long projectContraptionId,Boolean isIntoManagement) { private Map<String, Boolean> getCheckResultMap(List<Long> projectContraptionIdList, Map<String, Boolean> resultMap, List<Map<String, Integer>> inUseTimeMap) {
Integer inUseTime = 0; for (Long projectContraptionId : projectContraptionIdList) {
if(isIntoManagement){ Optional<Integer> inUseCountOpt = inUseTimeMap.stream()
inUseTime= this.baseMapper.countContraptionInUseTimesForDeleteByIntoManagement(projectContraptionId); .filter(map -> projectContraptionId.toString().equals(map.get("project_contraption_id")))
}else { .map(map -> map.get("inUseNumber"))
inUseTime = this.baseMapper.countContraptionInUseTimesForDelete(projectContraptionId); .filter(Objects::nonNull)
.findFirst();
Integer inUseCount = inUseCountOpt.orElse(0);
resultMap.put(String.valueOf(projectContraptionId), inUseCount <= 0);
} }
return inUseTime <= 0; return resultMap;
} }
@Override @Override
...@@ -307,7 +356,8 @@ public class IdxBizJgProjectContraptionServiceImpl extends BaseService<IdxBizJgP ...@@ -307,7 +356,8 @@ public class IdxBizJgProjectContraptionServiceImpl extends BaseService<IdxBizJgP
page.setCurrent(current); page.setCurrent(current);
page.setSize(size); page.setSize(size);
page.setRecords(baseMapper.selectEquipListPage(sequenceNbr, (current - 1) * size, size)); page.setRecords(baseMapper.selectEquipListPage(sequenceNbr, (current - 1) * size, size));
page.setTotal(baseMapper.selectEquipCount(sequenceNbr)); Map<String, Integer> totalMap = baseMapper.selectEquipCount(new ArrayList<>(Collections.singletonList(Long.parseLong(sequenceNbr)))).get(0);
page.setTotal(totalMap.get("count"));
return page; return page;
} }
......
package com.yeejoin.amos.boot.module.ymt.api.mapper; package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectConstruction;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption; import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* 管道工程装置表 Mapper 接口 * 管道工程装置表 Mapper 接口
...@@ -27,17 +24,37 @@ public interface IdxBizJgProjectContraptionMapper extends BaseMapper<IdxBizJgPro ...@@ -27,17 +24,37 @@ public interface IdxBizJgProjectContraptionMapper extends BaseMapper<IdxBizJgPro
/** /**
* 统计工程装置的引用次数(非待提交、非已撤回、非已驳回) * 统计工程装置的引用次数(非待提交、非已撤回、非已驳回)
* *
* @param projectContraptionId 工程装置唯一标识 * @param projectContraptionIdList 工程装置唯一标识
* @return 被引用次数 > 0 则设备不可编辑 * @return 被引用次数 > 0 则设备不可编辑
*/ */
Integer countContraptionInUseTimesForEdit(@Param("projectContraptionId") Long projectContraptionId); List<Map<String, Integer>> countContraptionInUseTimesForEdit(@Param("projectContraptionIdList") List<Long> projectContraptionIdList);
/** /**
* 统计设备被引用的次数(只有存在就算引用-作废除外) * 统计设备被引用的次数(只有存在就算引用-作废除外)
* @param projectContraptionIdList 设备唯一标识
* @return 被引用次数 > 0 则设备不可删除
*/
List<Map<String, Integer>> countContraptionInUseTimesForDelete(@Param("projectContraptionIdList") List<Long> projectContraptionIdList);
/**
* 获取管道信息总数
*
* @param projectContraptionIdList
* @return
*/
List<Map<String, Integer>> selectEquipCount(@Param("projectContraptionIdList") List<Long> projectContraptionIdList);
/**
* 获取不为空的检验信息个数
*/
List<Map<String, Integer>> selectCheckCountByNotNull(@Param("projectContraptionIdList") List<Long> projectContraptionIdList);
/**
* 统计已纳管设备被引用的次数(只有存在就算引用-作废除外)
* @param projectContraptionId 设备唯一标识 * @param projectContraptionId 设备唯一标识
* @return 被引用次数 > 0 则设备不可删除 * @return 被引用次数 > 0 则设备不可删除
*/ */
Integer countContraptionInUseTimesForDelete(@Param("projectContraptionId") Long projectContraptionId); Integer countContraptionInUseTimesForDeleteByIntoManagement(@Param("projectContraptionId")Long projectContraptionId);
List<IdxBizJgProjectContraption> selectErrorManagementProject(); List<IdxBizJgProjectContraption> selectErrorManagementProject();
...@@ -62,13 +79,6 @@ public interface IdxBizJgProjectContraptionMapper extends BaseMapper<IdxBizJgPro ...@@ -62,13 +79,6 @@ public interface IdxBizJgProjectContraptionMapper extends BaseMapper<IdxBizJgPro
List<Map<String, Object>> selectEquipListPage(@Param("sequenceNbr") String sequenceNbr, @Param("current") int current, @Param("size") int size); List<Map<String, Object>> selectEquipListPage(@Param("sequenceNbr") String sequenceNbr, @Param("current") int current, @Param("size") int size);
/** /**
* 获取管道信息总数
* @param sequenceNbr
* @return
*/
long selectEquipCount(@Param("sequenceNbr") String sequenceNbr);
/**
* 获取导出传输/公共管道的信息 * 获取导出传输/公共管道的信息
* @param sequenceNbr * @param sequenceNbr
* @return * @return
...@@ -76,14 +86,9 @@ public interface IdxBizJgProjectContraptionMapper extends BaseMapper<IdxBizJgPro ...@@ -76,14 +86,9 @@ public interface IdxBizJgProjectContraptionMapper extends BaseMapper<IdxBizJgPro
List<Map<String, Object>> selectEquipListByExport(@Param("sequenceNbr") String sequenceNbr); List<Map<String, Object>> selectEquipListByExport(@Param("sequenceNbr") String sequenceNbr);
/** /**
* 获取不为空的检验信息个数
*/
int selectCheckCountByNotNull(@Param("sequenceNbr") String sequenceNbr);
/**
* 统计已纳管设备被引用的次数(只有存在就算引用-作废除外) * 统计已纳管设备被引用的次数(只有存在就算引用-作废除外)
* @param projectContraptionId 设备唯一标识 * @param projectContraptionId 设备唯一标识
* @return 被引用次数 > 0 则设备不可删除 * @return 被引用次数 > 0 则设备不可删除
*/ */
Integer countContraptionInUseTimesForDeleteByIntoManagement(@Param("projectContraptionId")Long projectContraptionId); List<Map<String, Integer>> countContraptionInUseTimesForDeleteByIntoManagementBatch(@Param("projectContraptionIdList") List<Long> projectContraptionIdList);
} }
...@@ -81,48 +81,78 @@ ...@@ -81,48 +81,78 @@
ORDER BY ibjtpp.REC_DATE ASC ORDER BY ibjtpp.REC_DATE ASC
</select> </select>
<select id="countContraptionInUseTimesForEdit" resultType="java.lang.Integer"> <resultMap id="projectContraptionResultMap" type="java.util.Map">
<result property="project_contraption_id" column="project_contraption_id"/>
<result property="inUseNumber" column="inUseNumber" javaType="java.lang.Integer"/>
</resultMap>
<select id="countContraptionInUseTimesForEdit" resultMap="projectContraptionResultMap">
SELECT SELECT
SUM(inUseNumber) project_contraption_id,
SUM(inUseNumber) inUseNumber
FROM ( FROM (
SELECT SELECT
a.project_contraption_id,
COUNT(1) as inUseNumber COUNT(1) as inUseNumber
FROM FROM
tzs_jg_use_registration a tzs_jg_use_registration a
WHERE a.project_contraption_id = #{projectContraptionId} WHERE a.project_contraption_id in
<foreach collection ='projectContraptionIdList' item='id' index='index' open="(" close= ")" separator=",">
#{id}
</foreach>
AND a.is_delete = 0 AND a.is_delete = 0
AND (a.status <![CDATA[ <> ]]> '使用单位待提交' and a.status <![CDATA[ <> ]]> '一级受理已驳回' and a.status <![CDATA[ <> ]]> '使用单位已撤回' and a.status <![CDATA[ <> ]]> '已作废') AND (a.status <![CDATA[ <> ]]> '使用单位待提交' and a.status <![CDATA[ <> ]]> '一级受理已驳回' and a.status <![CDATA[ <> ]]> '使用单位已撤回' and a.status <![CDATA[ <> ]]> '已作废')
group by a.project_contraption_id
UNION UNION
SELECT SELECT
a.project_contraption_id,
COUNT(1) as inUseNumber COUNT(1) as inUseNumber
FROM FROM
tzs_jg_installation_notice a tzs_jg_installation_notice a
WHERE a.project_contraption_id = #{projectContraptionId} WHERE a.project_contraption_id in
<foreach collection ='projectContraptionIdList' item='id' index='index' open="(" close= ")" separator=",">
#{id}
</foreach>
AND a.notice_status <![CDATA[ <> ]]> '6610' AND a.notice_status <![CDATA[ <> ]]> '6610'
AND a.notice_status <![CDATA[ <> ]]> '6615' AND a.notice_status <![CDATA[ <> ]]> '6615'
AND a.notice_status <![CDATA[ <> ]]> '6614' AND a.notice_status <![CDATA[ <> ]]> '6614'
group by a.project_contraption_id
) )
GROUP BY project_contraption_id
</select> </select>
<select id="countContraptionInUseTimesForDelete" resultType="java.lang.Integer">
<select id="countContraptionInUseTimesForDelete" resultMap="projectContraptionResultMap">
SELECT SELECT
SUM(inUseNumber) project_contraption_id,
SUM(inUseNumber) inUseNumber
FROM ( FROM (
SELECT SELECT
a.project_contraption_id,
COUNT(1) AS inUseNumber COUNT(1) AS inUseNumber
FROM FROM
tzs_jg_use_registration a tzs_jg_use_registration a
WHERE a.project_contraption_id = #{projectContraptionId} WHERE a.project_contraption_id in
<foreach collection="projectContraptionIdList" item="projectContraptionId" index='index' open="(" close= ")" separator=",">
#{projectContraptionId}
</foreach>
AND a.is_delete = 0 AND a.is_delete = 0
AND ( a.status <![CDATA[ <> ]]> '已作废') AND ( a.status <![CDATA[ <> ]]> '已作废')
group by a.project_contraption_id
UNION UNION
SELECT SELECT
a.project_contraption_id,
COUNT(1) AS inUseNumber COUNT(1) AS inUseNumber
FROM FROM
tzs_jg_installation_notice a tzs_jg_installation_notice a
WHERE a.project_contraption_id = #{projectContraptionId} WHERE a.project_contraption_id in
<foreach collection="projectContraptionIdList" item="projectContraptionId" index='index' open="(" close= ")" separator=",">
#{projectContraptionId}
</foreach>
AND (a.notice_status <![CDATA[ <> ]]> '6617') AND (a.notice_status <![CDATA[ <> ]]> '6617')
group by a.project_contraption_id
) )
GROUP BY
project_contraption_id;
</select> </select>
<select id="selectErrorManagementProject" <select id="selectErrorManagementProject"
resultType="com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption"> resultType="com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption">
...@@ -174,12 +204,14 @@ ...@@ -174,12 +204,14 @@
limit #{current},#{size} limit #{current},#{size}
</select> </select>
<select id="selectEquipCount" resultType="long"> <select id="selectEquipCount" resultType="java.util.Map">
SELECT count(1) SELECT ibjui.project_contraption_id, CAST(count(1) AS INTEGER) AS count
FROM idx_biz_jg_use_info ibjui FROM idx_biz_jg_use_info ibjui
LEFT JOIN idx_biz_jg_tech_params_pipeline ibjtpp ON ibjui.RECORD = ibjtpp.RECORD WHERE ibjui.project_contraption_id in
WHERE ibjui.project_contraption_id = #{sequenceNbr} <foreach collection ='projectContraptionIdList' item='id' index='index' open="(" close= ")" separator=",">
ORDER BY ibjtpp.REC_DATE ASC #{id}
</foreach>
GROUP BY ibjui.project_contraption_id
</select> </select>
<select id="queryJgProjectContraptionPage" <select id="queryJgProjectContraptionPage"
resultType="com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption"> resultType="com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption">
...@@ -257,22 +289,27 @@ ...@@ -257,22 +289,27 @@
ORDER BY ibjtpp.REC_DATE ASC ORDER BY ibjtpp.REC_DATE ASC
</select> </select>
<select id="selectCheckCountByNotNull" resultType="int"> <select id="selectCheckCountByNotNull" resultType="java.util.Map">
SELECT COUNT(1) SELECT A.project_contraption_id,CAST(count(1) AS INTEGER) AS count
FROM FROM
( (
SELECT SELECT
ibjui.project_contraption_id,
( SELECT INSPECT_ORG_NAME FROM idx_biz_jg_inspection_detection_info WHERE "RECORD" = ibjui."RECORD" ORDER BY INSPECT_DATE DESC LIMIT 1 ) inspectOrgName, ( SELECT INSPECT_ORG_NAME FROM idx_biz_jg_inspection_detection_info WHERE "RECORD" = ibjui."RECORD" ORDER BY INSPECT_DATE DESC LIMIT 1 ) inspectOrgName,
( SELECT INSPECT_CONCLUSION FROM idx_biz_jg_inspection_detection_info WHERE "RECORD" = ibjui."RECORD" ORDER BY INSPECT_DATE DESC LIMIT 1 ) inspectConclusion, ( SELECT INSPECT_CONCLUSION FROM idx_biz_jg_inspection_detection_info WHERE "RECORD" = ibjui."RECORD" ORDER BY INSPECT_DATE DESC LIMIT 1 ) inspectConclusion,
( SELECT NEXT_INSPECT_DATE FROM idx_biz_jg_inspection_detection_info WHERE "RECORD" = ibjui."RECORD" ORDER BY INSPECT_DATE DESC LIMIT 1 ) nextInspectDate ( SELECT NEXT_INSPECT_DATE FROM idx_biz_jg_inspection_detection_info WHERE "RECORD" = ibjui."RECORD" ORDER BY INSPECT_DATE DESC LIMIT 1 ) nextInspectDate
FROM FROM
idx_biz_jg_use_info ibjui idx_biz_jg_use_info ibjui
WHERE WHERE
ibjui.project_contraption_id = #{sequenceNbr} ibjui.project_contraption_id in
<foreach collection ='projectContraptionIdList' item='id' index='index' open="(" close= ")" separator=",">
#{id}
</foreach>
) A ) A
WHERE WHERE
A.inspectOrgName IS NOT NULL AND A.inspectOrgName != '' AND A.inspectConclusion IS NOT NULL and A.inspectConclusion!='' A.inspectOrgName IS NOT NULL AND A.inspectOrgName != '' AND A.inspectConclusion IS NOT NULL and A.inspectConclusion!=''
and A.nextInspectDate IS NOT NULL and A.nextInspectDate IS NOT NULL
GROUP BY A.project_contraption_id
</select> </select>
<select id="countContraptionInUseTimesForDeleteByIntoManagement" resultType="java.lang.Integer"> <select id="countContraptionInUseTimesForDeleteByIntoManagement" resultType="java.lang.Integer">
...@@ -382,4 +419,173 @@ ...@@ -382,4 +419,173 @@
AND ( a.status != '6617') AND ( a.status != '6617')
) )
</select> </select>
<select id="countContraptionInUseTimesForDeleteByIntoManagementBatch" resultMap="projectContraptionResultMap">
SELECT
project_contraption_id,
SUM(inUseNumber) inUseNumber
FROM (
SELECT
c.project_contraption_id,
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 in
<foreach collection="projectContraptionIdList" item="projectContraptionId" index='index' open="(" close= ")" separator=",">
#{projectContraptionId}
</foreach>
AND a.is_delete = 0
AND ( a.apply_status != '6617')
GROUP BY c.project_contraption_id
UNION
SELECT
a.project_contraption_id,
COUNT(1) AS inUseNumber
FROM
tzs_jg_use_registration a
WHERE a.project_contraption_id in
<foreach collection="projectContraptionIdList" item="projectContraptionId" index='index' open="(" close= ")" separator=",">
#{projectContraptionId}
</foreach>
AND a.is_delete = 0
AND ( a.status != '已作废')
GROUP BY a.project_contraption_id
UNION
SELECT
c.project_contraption_id,
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 in
<foreach collection="projectContraptionIdList" item="projectContraptionId" index='index' open="(" close= ")" separator=",">
#{projectContraptionId}
</foreach>
AND a.is_delete = 0
AND ( a.status != '已作废')
GROUP BY c.project_contraption_id
UNION
SELECT
c.project_contraption_id,
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 in
<foreach collection="projectContraptionIdList" item="projectContraptionId" index='index' open="(" close= ")" separator=",">
#{projectContraptionId}
</foreach>
AND a.is_delete = 0
AND ( a.audit_status != '已作废')
GROUP BY c.project_contraption_id
UNION
SELECT
c.project_contraption_id,
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 in
<foreach collection="projectContraptionIdList" item="projectContraptionId" index='index' open="(" close= ")" separator=",">
#{projectContraptionId}
</foreach>
AND a.is_delete = 0
AND ( a.audit_status != '使用单位已撤回')
GROUP BY c.project_contraption_id
UNION
SELECT
c.project_contraption_id,
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 in
<foreach collection="projectContraptionIdList" item="projectContraptionId" index='index' open="(" close= ")" separator=",">
#{projectContraptionId}
</foreach>
AND a.is_delete = 0
AND ( a.audit_status != '使用单位已撤回')
GROUP BY c.project_contraption_id
UNION
SELECT
c.project_contraption_id,
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 in
<foreach collection="projectContraptionIdList" item="projectContraptionId" index='index' open="(" close= ")" separator=",">
#{projectContraptionId}
</foreach>
AND a.is_delete = 0
AND ( a.audit_status != '使用单位已撤回')
GROUP BY c.project_contraption_id
UNION
SELECT
a.project_contraption_id,
COUNT(1) AS inUseNumber
FROM
tzs_jg_installation_notice a
WHERE a.project_contraption_id in
<foreach collection="projectContraptionIdList" item="projectContraptionId" index='index' open="(" close= ")" separator=",">
#{projectContraptionId}
</foreach>
AND (a.notice_status != '6617')
GROUP BY a.project_contraption_id
UNION
SELECT
c.project_contraption_id,
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 in
<foreach collection="projectContraptionIdList" item="projectContraptionId" index='index' open="(" close= ")" separator=",">
#{projectContraptionId}
</foreach>
AND a.is_delete = 0
AND ( a.notice_status != '6617')
GROUP BY c.project_contraption_id
UNION
SELECT
c.project_contraption_id,
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 in
<foreach collection="projectContraptionIdList" item="projectContraptionId" index='index' open="(" close= ")" separator=",">
#{projectContraptionId}
</foreach>
AND a.is_delete = 0
AND ( a.notice_status != '6617')
GROUP BY c.project_contraption_id
UNION
SELECT
c.project_contraption_id,
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 in
<foreach collection="projectContraptionIdList" item="projectContraptionId" index='index' open="(" close= ")" separator=",">
#{projectContraptionId}
</foreach>
AND a.is_delete = 0
AND ( a.notice_status != '6617')
GROUP BY c.project_contraption_id
UNION
SELECT
a.project_contraption_id,
COUNT(1) AS inUseNumber
FROM tz_jyjc_inspection_application a
WHERE a.project_contraption_id in
<foreach collection="projectContraptionIdList" item="projectContraptionId" index='index' open="(" close= ")" separator=",">
#{projectContraptionId}
</foreach>
AND ( a.status != '6617')
GROUP BY a.project_contraption_id
) GROUP BY project_contraption_id
</select>
</mapper> </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