Commit 55edaa13 authored by 刘林's avatar 刘林

fix(jg):历史管道导入作废Bug修改

parent 1752420f
......@@ -118,4 +118,6 @@ public interface JgUseRegistrationMapper extends BaseMapper<JgUseRegistration> {
* @return List<Map<String, Object>>
*/
List<Map<String, Object>> selectPieLineListByOfCanReg(@Param("projectContraptionSeqList") List<String> projectContraptionSeqList);
Integer countUseTimesForInvalid(@Param("code") Object code);
}
......@@ -46,4 +46,6 @@ public interface JgVehicleInformationMapper extends BaseMapper<JgVehicleInformat
String getEquCategoryNameByCode(String code);
List<CompanyEquipCountDto> queryForFlowingEquipList();
Integer countUseTimesForInvalid(@Param("code") Object code);
}
......@@ -1323,4 +1323,49 @@
AND A.is_delete = 0
AND A.supervision_org_code is not null
</select>
<select id="countUseTimesForInvalid" resultType="java.lang.Integer">
select sum(inUseNumber) from (
select count(1) as inUseNumber
from
tzs_jg_change_registration_reform a
where a.use_registration_code = #{code}
AND a.is_delete = 0
AND a.status != '已作废'
UNION
select
count(1) as inUseNumber
from
tzs_jg_change_registration_transfer a,
tzs_jg_change_registration_transfer_eq b
where a.sequence_nbr = b.equip_transfer_id
AND b.use_registration_code = #{code}
AND a.is_delete = 0
AND a.status != '已作废'
UNION
SELECT COUNT(*) AS inUseNumber
FROM tzs_jg_enable_disable a
WHERE a.use_registration_code LIKE CONCAT('%',#{code},'%')
AND a.is_delete = 0
AND a.audit_status != '已作废'
UNION
SELECT COUNT(*) AS inUseNumber
FROM tzs_jg_scrap_cancel a
WHERE a.use_registration_code LIKE CONCAT('%',#{code},'%')
AND a.is_delete = 0
AND a.audit_status != '已作废'
UNION
select
count(1) as inUseNumber
from
"tzs_jg_use_registration_eq" ae
JOIN tzs_jg_use_registration A ON A.sequence_nbr = ae.equip_transfer_id
JOIN "tzs_jg_equip_transfer_eq" tjete ON ae.equ_id = tjete."equ_id"
JOIN tzs_jg_equip_transfer tjet ON tjete."equip_transfer_id" = tjet."sequence_nbr"
where
A.use_registration_code = #{code}
AND tjet.is_delete = 0
AND tjet.apply_status != '已作废'
)
</select>
</mapper>
......@@ -303,4 +303,23 @@
and a.status in ('三级待受理', '二级待受理', '一级待受理')
GROUP BY a.use_unit_credit_code
</select>
<select id="countUseTimesForInvalid" resultType="java.lang.Integer">
SELECT SUM(inUseNumber)
FROM (SELECT COUNT(*) AS inUseNumber
FROM tzs_jg_enable_disable a
WHERE a.use_registration_code LIKE CONCAT('%',#{code},'%')
AND a.is_delete = 0
AND a.audit_status != '已作废'
UNION
SELECT
count(1) as inUseNumber
FROM
tzs_jg_change_vehicle_registration_unit a,
tzs_jg_vehicle_information b
WHERE
a.car_number = b.car_number
AND b.use_registration_code = #{code}
AND a.status != '已作废')
</select>
</mapper>
......@@ -149,6 +149,9 @@ public class JgUseRegistrationController extends BaseController {
x.put("regType", "1".equals(x.get("regType")) ? "历史登记": "2".equals(x.get("regType")) ? "特殊历史登记": "新增登记");
if ("8000".equals(String.valueOf(x.get("equListCode"))) && !ValidationUtil.isEmpty(x.get("projectContraptionId"))){
x.put("canVoided", jgProjectContraptionMapper.countContraptionInUseTimesForDeleteByIntoManagement(Long.parseLong((String) x.get("projectContraptionId"))) == 0);
} else {
x.put("canVoided", Optional.ofNullable(x.get("useRegistrationCode")).map(jgUseRegistrationServiceImpl::countUseTimesForInvalid)
.orElse(true));
}
});
return ResponseHelper.buildResponse(list);
......
......@@ -13,6 +13,7 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgVehicleInformationServiceImpl;
import org.typroject.tyboot.component.event.RestEventTrigger;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
......@@ -152,6 +153,9 @@ public class JgVehicleInformationController extends BaseController {
list.getRecords().forEach(x -> {
x.put("companyType", info.getCompany().getCompanyType());
x.put("regTypeDesc", "1".equals(x.get("regType")) ? "历史登记" : "新增登记");
x.put("canVoided", Optional.ofNullable(x.get("useRegistrationCode"))
.map(jgVehicleInformationServiceImpl::countUseTimesForInvalid)
.orElse(true));
});
return ResponseHelper.buildResponse(list);
}
......
......@@ -14,7 +14,6 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
......@@ -26,6 +25,7 @@ import com.yeejoin.amos.boot.module.jg.api.converter.EquDefineConverter;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.entity.*;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationMapper;
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.entity.*;
......@@ -53,17 +53,13 @@ import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.InputStream;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.temporal.ValueRange;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.toJSONString;
@Slf4j
......@@ -104,6 +100,7 @@ public class DataDockServiceImpl {
private final JgCertificateChangeRecordEqServiceImpl certificateChangeRecordEqService;
private final Map<String, Object> resultError = new HashMap<>();
private final JgUseRegistrationMapper jgUseRegistrationMapper;
List<String> useInnerCodeList = new ArrayList<>();// 单位内部编号集合
List<String> equCodeList = new ArrayList<>();// 设备代码集合
List<String> factoryNumList = new ArrayList<>();// 出厂编码集合
......@@ -1459,7 +1456,6 @@ public class DataDockServiceImpl {
if (ValidationUtil.isEmpty(fileData) || !"inspectReport".equals(fileData.getString("key"))) {
continue;
}
JSONArray value = fileData.getJSONArray("value");
if (value != null) {
equ.setInspectReport(value.toJSONString());
......@@ -1467,34 +1463,32 @@ public class DataDockServiceImpl {
}
}
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
// 监管——历史——管道——批量
String dataSource = "jg_his_gd_pl";
// 公共参数提取
EquipRequestParamsDto paramsDto = this.extractCommonData(dataSource, reginParams, equipInfo, equLists);
// 是否工业管道
boolean isGYGD = "8300".equals(paramsDto.getEquCategoryCode());
boolean haveUseRegistration = false;
// 确保使用登记证和工程装置在该单位下都是不存在的,方可导入数据
if (isGYGD) {
this.checkTheUnitRegManageAlreadyExists(paramsDto);
haveUseRegistration = this.checkTheUnitRegManageAlreadyExists(paramsDto, haveUseRegistration);
}
this.checkTheUnitProConMatching(paramsDto);
this.checkTheUnitProConAlreadyExists(paramsDto);
// 生成工程装置表信息
IdxBizJgProjectContraption proCon = this.saveProjectContraption(paramsDto);
// 保存管道对应的idx表数据
List<String> records = this.savePipInfoToIdxTables(equLists, paramsDto, proCon);
if (isGYGD) {
// 生成使用登记表信息 + 设备关系表 + 历史表
JgUseRegistration useReg = this.saveUseRegAndEq(paramsDto, records, proCon);
// 生成使用登记证表数据
JgUseRegistrationManage regManage = this.saveUseRegManage(paramsDto, useReg);
// 流水表
this.saveCertChangeRecord(useReg, regManage, records, paramsDto);
if (!haveUseRegistration){
JgUseRegistrationManage regManage = this.saveUseRegManage(paramsDto, useReg);
// 流水表
this.saveCertChangeRecord(useReg, regManage, records, paramsDto);
}
}
return Boolean.TRUE;
}
......@@ -1531,22 +1525,32 @@ public class DataDockServiceImpl {
}
/**
* 检查本单位是否存在使用等级证编号 + 不能是系统未生成的
* 检查本单位是否存在使用登记证编号 + 不能是系统未生成的
*
* @param paramsDto
* @param paramsDto 设备请求参数
*/
public void checkTheUnitRegManageAlreadyExists(EquipRequestParamsDto paramsDto) {
public boolean checkTheUnitRegManageAlreadyExists(EquipRequestParamsDto paramsDto, boolean haveUseRegistration) {
// 1. 判断是否使用未来系统生成编号
idxBizJgRegisterInfoServiceImpl.checkUseRegistrationCode(paramsDto.getUseOrgCode(), "unit");
Integer useRegManageCount = jgUseRegistrationManageService.lambdaQuery()
.eq(JgUseRegistrationManage::getUseUnitCreditCode, paramsDto.getCompanyCode())
.eq(JgUseRegistrationManage::getUseUnitName, paramsDto.getCompanyName())
.eq(JgUseRegistrationManage::getUseRegistrationCode, paramsDto.getUseOrgCode())
.eq(JgUseRegistrationManage::getEquList, paramsDto.getEquListName())
.eq(JgUseRegistrationManage::getEquCategory, paramsDto.getEquCategoryName())
.count();
if (useRegManageCount > 0) {
throw new BadRequest("系统已存在该使用登记证编号!");
// 2. 获取使用登记管理列表
List<JgUseRegistration> useRegistrationList = jgUseRegistrationMapper.selectList(
new LambdaQueryWrapper<JgUseRegistration>()
.eq(JgUseRegistration::getUseRegistrationCode, paramsDto.getUseOrgCode())
.eq(JgUseRegistration::getIsDelete, 0)
.eq(JgUseRegistration::getStatus, "已完成")
.orderByDesc(JgUseRegistration::getRecDate)
.last("limit 1"));
if (!useRegistrationList.isEmpty()) {
if (useRegistrationList.stream().filter(map -> !"1".equals(map.getRegType())).count() > 1) {
throw new BadRequest("该使用登记证编号已由系统自动生成,不能导入,请确认使用登记证编号是否正确!");
}
if (useRegistrationList.stream().filter(map -> !paramsDto.getCompanyCode().equals(map.getUseUnitCreditCode())).count() > 1) {
throw new BadRequest("该使用登记证编号在其他企业使用,不能导入,请确认使用登记证编号是否正确!");
}
haveUseRegistration = true;
}
return haveUseRegistration;
}
/**
......@@ -1899,7 +1903,6 @@ public class DataDockServiceImpl {
registrationHistory.setCreateUserId(paramsDto.getExecUserId());
registrationHistory.setRecUserName(paramsDto.getExecUserName());
jgRegistrationHistoryService.save(registrationHistory);
return useReg;
}
......
......@@ -2999,7 +2999,6 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
if ("unit".equals(jgUseRegistration.getManageType())){
//单位办理-历史作废
if ("1".equals(jgUseRegistration.getRegType())){
this.updateById(jgUseRegistration);
// 构建设备删除的 DTO 列表
List<ESEquipmentCategoryDto> esDtoList = records.stream().map(v -> {
ESEquipmentCategoryDto esDto = new ESEquipmentCategoryDto();
......@@ -4427,4 +4426,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
}
}
}
public Object countUseTimesForInvalid(Object code) {
return jgUseRegistrationMapper.countUseTimesForInvalid(code) == 0;
}
}
\ No newline at end of file
......@@ -179,6 +179,8 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
@Autowired
EventPublisher eventPublisher;
@Autowired
private JgVehicleInformationMapper jgVehicleInformationMapper;
/**
* @param auditPassDate 通过时间
......@@ -2403,4 +2405,8 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
}
}
}
public boolean countUseTimesForInvalid(Object code) {
return jgVehicleInformationMapper.countUseTimesForInvalid(code) <= 0;
}
}
\ No newline at end of file
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