Commit 72420771 authored by Lambertliu's avatar Lambertliu

Merge remote-tracking branch 'origin/develop_tzs_register' into develop_tzs_register

parents c7378d9b 8dcedf37
......@@ -171,6 +171,18 @@ public class IdxBizJgProjectContraptionController extends BaseController {
}
/**
* 根据sequenceNbr删除datasource为jg_his_gd_pl的数据
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/deleteByHisGdPl")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除datasource为jg_his_gd_pl的数据", notes = "根据sequenceNbr删除datasource为jg_his_gd_pl的数据")
public ResponseModel<Boolean> deleteByHisGdPl(@RequestParam(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(idxBizJgProjectContraptionServiceImpl.deleteByHisGdPl(sequenceNbr));
}
/**
* 获取检验信息详情
*
* @return
......
......@@ -24,4 +24,6 @@ public interface IIdxBizJgProjectContraptionService extends IService<IdxBizJgPro
IPage<IdxBizJgProjectContraption> proConPageByParams(Map<String, String> params, Page<IdxBizJgProjectContraption> page, ReginParams reginParams);
List<IdxBizJgProjectContraption> proConListByParams(Map<String, String> params, ReginParams reginParams);
Boolean deleteByHisGdPl(Long sequenceNbr);
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -8,16 +10,21 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
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.converter.DictParamsConverter;
import com.yeejoin.amos.boot.module.jg.api.dto.InspectConclusionConverter;
import com.yeejoin.amos.boot.module.jg.api.dto.InspectTypeConverter;
import com.yeejoin.amos.boot.module.jg.api.dto.PipingExcelDto;
import com.yeejoin.amos.boot.module.jg.api.enums.CompanyTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.EquipSourceEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.PipelineEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgVehicleInformationMapper;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgProjectContraptionService;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.service.*;
import com.yeejoin.amos.boot.module.ymt.api.dto.IdxBizJgProjectContraptionDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgInspectionDetectionInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseEnterpriseInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgProjectContraptionMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper;
import com.yeejoin.amos.feign.privilege.Privilege;
......@@ -87,6 +94,26 @@ public class IdxBizJgProjectContraptionServiceImpl extends BaseService<IdxBizJgP
private JgVehicleInformationMapper jgVehicleInformationMapper;
@Autowired
private JgInstallationNoticeServiceImpl jgInstallationNoticeService;
@Autowired
private IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService;
@Autowired
private IdxBizJgDesignInfoServiceImpl idxBizJgDesignInfoService;
@Autowired
private IdxBizJgFactoryInfoServiceImpl idxBizJgFactoryInfoService;
@Autowired
private IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService;
@Autowired
private IdxBizJgSupervisionInfoServiceImpl idxBizJgSupervisionInfoService;
@Autowired
private IdxBizJgOtherInfoServiceImpl idxBizJgOtherInfoService;
@Autowired
private IdxBizJgTechParamsPipelineServiceImpl idxBizJgTechParamsPipelineService;
@Autowired
private IdxBizJgInspectionDetectionInfoServiceImpl idxBizJgInspectionDetectionInfoService;
@Autowired
private IdxBizJgConstructionInfoServiceImpl idxBizJgConstructionInfoService;
@Autowired
private ESEquipmentCategory esEquipmentCategory;
@Override
public boolean saveOrUpdateData(IdxBizJgProjectContraption projectContraption) {
......@@ -182,7 +209,7 @@ public class IdxBizJgProjectContraptionServiceImpl extends BaseService<IdxBizJgP
.collect(Collectors.joining())
);
record.setCanEdit(this.checkContraptionIsCanEdit(record.getSequenceNbr()));
record.setCanDelete(this.checkContraptionIsCanDelete(record.getSequenceNbr()));
record.setCanDelete(this.checkContraptionIsCanDelete(record.getSequenceNbr(),isIntoManagement));
//判断是否有检验结果录入
judgeCheckResult(record);
});
......@@ -209,8 +236,13 @@ public class IdxBizJgProjectContraptionServiceImpl extends BaseService<IdxBizJgP
return inUseTime <= 0;
}
private Boolean checkContraptionIsCanDelete(Long projectContraptionId) {
Integer inUseTime = this.baseMapper.countContraptionInUseTimesForDelete(projectContraptionId);
private Boolean checkContraptionIsCanDelete(Long projectContraptionId,Boolean isIntoManagement) {
Integer inUseTime = 0;
if(isIntoManagement){
inUseTime= this.baseMapper.countContraptionInUseTimesForDeleteByIntoManagement(projectContraptionId);
}else {
inUseTime = this.baseMapper.countContraptionInUseTimesForDelete(projectContraptionId);
}
return inUseTime <= 0;
}
......@@ -474,4 +506,82 @@ public class IdxBizJgProjectContraptionServiceImpl extends BaseService<IdxBizJgP
projectContraption.setUseUnitCreditCode(companyInfoMap.get("creditCode").toString());
return this.saveOrUpdateData(projectContraption);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean deleteByHisGdPl(Long sequenceNbr) {
IdxBizJgProjectContraption idxBizJgProjectContraption = baseMapper.selectById(sequenceNbr);
if(Objects.nonNull(idxBizJgProjectContraption)){
String dataSource = idxBizJgProjectContraption.getDataSource();
if(!"jg_his_gd_pl".equals(dataSource)){
throw new BadRequest("数据源不是导入类型禁止删除");
}
// 删除管道对应的idx表数据
this.deletePipInfoToIdxTables(idxBizJgProjectContraption);
// 删除工程装置表信息
removeById(idxBizJgProjectContraption.getSequenceNbr());
}
return Boolean.TRUE;
}
private void deletePipInfoToIdxTables(IdxBizJgProjectContraption idxBizJgProjectContraption) {
Long jgProjectContraptionSequenceNbr = idxBizJgProjectContraption.getSequenceNbr();
LambdaQueryWrapper<IdxBizJgUseInfo> jgUseInfoWrapper = new LambdaQueryWrapper<>();
jgUseInfoWrapper.eq(IdxBizJgUseInfo::getProjectContraptionId,jgProjectContraptionSequenceNbr);
List<IdxBizJgUseInfo> useInfos = idxBizJgUseInfoService.list(jgUseInfoWrapper);
//获取records
List<String> records = new ArrayList<>();
if(CollectionUtil.isNotEmpty(useInfos)){
for (IdxBizJgUseInfo useInfo : useInfos) {
records.add(useInfo.getRecord());
}
}
if(CollectionUtil.isNotEmpty(records)){
// 删除检验检测信息
LambdaQueryWrapper<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfoWrapper = new LambdaQueryWrapper<>();
inspectionDetectionInfoWrapper.in(IdxBizJgInspectionDetectionInfo::getRecord,records);
idxBizJgInspectionDetectionInfoService.remove(inspectionDetectionInfoWrapper);
// 删除设计信息
LambdaQueryWrapper<IdxBizJgDesignInfo> designInfoWrapper = new LambdaQueryWrapper<>();
designInfoWrapper.in(IdxBizJgDesignInfo::getRecord,records);
idxBizJgDesignInfoService.remove(designInfoWrapper);
// 删除制造信息
LambdaQueryWrapper<IdxBizJgFactoryInfo> factoryInfoWrapper = new LambdaQueryWrapper<>();
factoryInfoWrapper.in(IdxBizJgFactoryInfo::getRecord,records);
idxBizJgFactoryInfoService.remove(factoryInfoWrapper);
// 删除施工信息
LambdaQueryWrapper<IdxBizJgConstructionInfo> constructionInfoWrapper = new LambdaQueryWrapper<>();
constructionInfoWrapper.in(IdxBizJgConstructionInfo::getRecord,records);
idxBizJgConstructionInfoService.remove(constructionInfoWrapper);
// 删除注册登记信息
LambdaQueryWrapper<IdxBizJgRegisterInfo> registerInfoWrapper = new LambdaQueryWrapper<>();
registerInfoWrapper.in(IdxBizJgRegisterInfo::getRecord,records);
idxBizJgRegisterInfoService.remove(registerInfoWrapper);
// 删除监督管理
LambdaQueryWrapper<IdxBizJgSupervisionInfo> supervisionInfoWrapper = new LambdaQueryWrapper<>();
supervisionInfoWrapper.in(IdxBizJgSupervisionInfo::getRecord,records);
idxBizJgSupervisionInfoService.remove(supervisionInfoWrapper);
// 删除其他信息
LambdaQueryWrapper<IdxBizJgOtherInfo> otherInfoWrapper = new LambdaQueryWrapper<>();
otherInfoWrapper.in(IdxBizJgOtherInfo::getRecord,records);
idxBizJgOtherInfoService.remove(otherInfoWrapper);
// 删除管道技术参数
LambdaQueryWrapper<IdxBizJgTechParamsPipeline> techParamsPipelineWrapper = new LambdaQueryWrapper<>();
techParamsPipelineWrapper.in(IdxBizJgTechParamsPipeline::getRecord,records);
idxBizJgTechParamsPipelineService.remove(techParamsPipelineWrapper);
//删除es数据
for (String record : records) {
esEquipmentCategory.deleteById(record);
}
// 删除使用信息
idxBizJgUseInfoService.remove(jgUseInfoWrapper);
}
}
}
\ No newline at end of file
......@@ -730,8 +730,7 @@
select * from (
<include refid="page-list-pipeline"/>
WHERE
ri."EQU_CATEGORY" = '8300'
and ui."PROJECT_CONTRAPTION_ID" = #{projectContraptionSeq}
ui."PROJECT_CONTRAPTION_ID" = #{projectContraptionSeq}
ORDER BY ui.REC_DATE DESC
)
</select>
......
......@@ -79,4 +79,11 @@ public interface IdxBizJgProjectContraptionMapper extends BaseMapper<IdxBizJgPro
* 获取不为空的检验信息个数
*/
int selectCheckCountByNotNull(@Param("sequenceNbr") String sequenceNbr);
/**
* 统计已纳管设备被引用的次数(只有存在就算引用-作废除外)
* @param projectContraptionId 设备唯一标识
* @return 被引用次数 > 0 则设备不可删除
*/
Integer countContraptionInUseTimesForDeleteByIntoManagement(@Param("projectContraptionId")Long projectContraptionId);
}
......@@ -263,4 +263,112 @@
A.inspectOrgName != NULL AND A.inspectOrgName != '' AND A.inspectConclusion!=NULL and A.inspectConclusion!=''
and A.nextInspectDate != NULL
</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>
</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