企业主体库问题修改
This commit is contained in:
parent
b8341a9d8c
commit
b49b7d63c7
|
|
@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
@ -62,7 +63,28 @@ public class EnterpriseService {
|
||||||
* @date 2025/10/22 16:18
|
* @date 2025/10/22 16:18
|
||||||
*/
|
*/
|
||||||
public List<EnterpriseVo> getList(EnterpriseDto dto) {
|
public List<EnterpriseVo> getList(EnterpriseDto dto) {
|
||||||
return imdEnterpriseService.getList(dto);
|
List<EnterpriseVo> list = imdEnterpriseService.getList(dto);
|
||||||
|
for (EnterpriseVo vo : list) {
|
||||||
|
ErrorInfo errorQueryDto = createErrorQueryDto(vo);
|
||||||
|
// 查询异常消息
|
||||||
|
List<String> errorList = imdErrorInfoService.getErrorInfoByTable(errorQueryDto);
|
||||||
|
vo.setErrorInfos(errorList);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建查询条件
|
||||||
|
* @param vo
|
||||||
|
* @return ErrorInfo
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2025/11/17 13:27
|
||||||
|
*/
|
||||||
|
public static ErrorInfo createErrorQueryDto(EnterpriseVo vo){
|
||||||
|
ErrorInfo errorInfo = new ErrorInfo();
|
||||||
|
errorInfo.setSourceTable(TableConstants.TB_ENTERPRISE);
|
||||||
|
errorInfo.setBusinessId(vo.getEnterpriseId());
|
||||||
|
return errorInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -94,11 +116,9 @@ public class EnterpriseService {
|
||||||
file.setSourceTable(TableConstants.TB_ENTERPRISE); // 来源表
|
file.setSourceTable(TableConstants.TB_ENTERPRISE); // 来源表
|
||||||
}
|
}
|
||||||
sourceFileService.saveResourceFile(dto.getFiles());
|
sourceFileService.saveResourceFile(dto.getFiles());
|
||||||
// 4.检查身份证是否过期,存在过期则保存至异常信息表
|
// 4.检查身份证和营业执照是否过期,存在过期则保存至异常信息表
|
||||||
ErrorInfo errorInfo = CertificateUtil.checkCertificateState(dto.getIdCardStartDate(), CertificateConstants.NATIONAL_EMBLEM_ID_CARD,
|
List<ErrorInfo> errorInfos = checkCertificateStates(dto);
|
||||||
dto.getEnterpriseId(), dto.getEnterpriseId(),TableConstants.TB_ENTERPRISE);
|
if (CollectionUtils.isNotEmpty(errorInfos)) {
|
||||||
if (Objects.nonNull(errorInfo)) {
|
|
||||||
List<ErrorInfo> errorInfos = Collections.singletonList(errorInfo);
|
|
||||||
imdErrorInfoService.addErrorInfo(errorInfos);
|
imdErrorInfoService.addErrorInfo(errorInfos);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -145,13 +165,14 @@ public class EnterpriseService {
|
||||||
sourceFileService.delResourceFile(dto.getDelFiles(), TableConstants.TB_ENTERPRISE);
|
sourceFileService.delResourceFile(dto.getDelFiles(), TableConstants.TB_ENTERPRISE);
|
||||||
}
|
}
|
||||||
// 5.删除异常信息数据
|
// 5.删除异常信息数据
|
||||||
|
List<String> errorType = new ArrayList<>();
|
||||||
|
errorType.add(CertificateConstants.NATIONAL_EMBLEM_ID_CARD);
|
||||||
|
errorType.add(CertificateConstants.BUSINESS_LICENSE);
|
||||||
imdErrorInfoService.delErrorInfo(dto.getEnterpriseId(), TableConstants.TB_ENTERPRISE,
|
imdErrorInfoService.delErrorInfo(dto.getEnterpriseId(), TableConstants.TB_ENTERPRISE,
|
||||||
Collections.singletonList(CertificateConstants.NATIONAL_EMBLEM_ID_CARD));
|
errorType);
|
||||||
// 6.检查身份证是否过期,存在过期则保存至异常信息表
|
// 6.检查身份证和营业执照是否过期,存在过期则保存至异常信息表
|
||||||
ErrorInfo errorInfo = CertificateUtil.checkCertificateState(dto.getIdCardStartDate(), CertificateConstants.NATIONAL_EMBLEM_ID_CARD,
|
List<ErrorInfo> errorInfos = checkCertificateStates(dto);
|
||||||
dto.getEnterpriseId(), dto.getEnterpriseId(),TableConstants.TB_ENTERPRISE);
|
if (CollectionUtils.isNotEmpty(errorInfos)) {
|
||||||
if (Objects.nonNull(errorInfo)) {
|
|
||||||
List<ErrorInfo> errorInfos = Collections.singletonList(errorInfo);
|
|
||||||
imdErrorInfoService.addErrorInfo(errorInfos);
|
imdErrorInfoService.addErrorInfo(errorInfos);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -162,6 +183,27 @@ public class EnterpriseService {
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<ErrorInfo> checkCertificateStates(EnterpriseDto dto) {
|
||||||
|
List<ErrorInfo> errorInfos = new ArrayList<>();
|
||||||
|
addIfNotNull(errorInfos,
|
||||||
|
CertificateUtil.checkCertificateState(dto.getIdCardStartDate(),
|
||||||
|
CertificateConstants.NATIONAL_EMBLEM_ID_CARD,
|
||||||
|
dto.getEnterpriseId(), dto.getEnterpriseId(), TableConstants.TB_ENTERPRISE));
|
||||||
|
|
||||||
|
addIfNotNull(errorInfos,
|
||||||
|
CertificateUtil.checkCertificateState(dto.getBusinessTerm(),
|
||||||
|
CertificateConstants.BUSINESS_LICENSE,
|
||||||
|
dto.getEnterpriseId(), dto.getEnterpriseId(), TableConstants.TB_ENTERPRISE));
|
||||||
|
|
||||||
|
return errorInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addIfNotNull(List<ErrorInfo> list, ErrorInfo item) {
|
||||||
|
if (Objects.nonNull(item)) {
|
||||||
|
list.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主体库->删除主体库
|
* 主体库->删除主体库
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,7 @@ public class CertificateConstants {
|
||||||
|
|
||||||
/**身份证*/
|
/**身份证*/
|
||||||
public static final String NATIONAL_EMBLEM_ID_CARD = "national_emblem_id_card";
|
public static final String NATIONAL_EMBLEM_ID_CARD = "national_emblem_id_card";
|
||||||
|
|
||||||
|
/**营业执照*/
|
||||||
|
public static final String BUSINESS_LICENSE = "business_license";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,17 +23,18 @@ public class CertificateUtil {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// 初始化证书类型与错误信息的映射
|
// 初始化证书类型与错误信息的映射
|
||||||
CERTIFICATE_ERROR_MAP.put("national_emblem_id_card", "身份证过期");
|
CERTIFICATE_ERROR_MAP.put("national_emblem_id_card", "【身份证】已过期");
|
||||||
CERTIFICATE_ERROR_MAP.put("constructor_certificate", "建造师证书过期");
|
CERTIFICATE_ERROR_MAP.put("business_license", "【营业执照】已过期");
|
||||||
CERTIFICATE_ERROR_MAP.put("safety_assessment_certificate_b", "安全考核B证过期");
|
CERTIFICATE_ERROR_MAP.put("constructor_certificate", "【建造师证书】已过期");
|
||||||
CERTIFICATE_ERROR_MAP.put("safety_assessment_certificate_c", "安全考核C证过期");
|
CERTIFICATE_ERROR_MAP.put("safety_assessment_certificate_b", "【安全考核B证】已过期");
|
||||||
CERTIFICATE_ERROR_MAP.put("professional_title_certificate", "质检员证过期");
|
CERTIFICATE_ERROR_MAP.put("safety_assessment_certificate_c", "【安全考核C证】已过期");
|
||||||
CERTIFICATE_ERROR_MAP.put("quality_inspector_certificate", "质检员证过期");
|
CERTIFICATE_ERROR_MAP.put("professional_title_certificate", "【质检员证】已过期");
|
||||||
CERTIFICATE_ERROR_MAP.put("construction_worker_certificate", "施工员证过期");
|
CERTIFICATE_ERROR_MAP.put("quality_inspector_certificate", "【质检员证】已过期");
|
||||||
CERTIFICATE_ERROR_MAP.put("materials_officer_certificate", "材料员证过期");
|
CERTIFICATE_ERROR_MAP.put("construction_worker_certificate", "【施工员证】已过期");
|
||||||
CERTIFICATE_ERROR_MAP.put("document_clerk_certificate", "资料员证过期");
|
CERTIFICATE_ERROR_MAP.put("materials_officer_certificate", "【材料员证】已过期");
|
||||||
CERTIFICATE_ERROR_MAP.put("mechanic_s_certificate", "机械员证过期");
|
CERTIFICATE_ERROR_MAP.put("document_clerk_certificate", "【资料员证】已过期");
|
||||||
CERTIFICATE_ERROR_MAP.put("cost_engineer_certificate", "造价员证过期");
|
CERTIFICATE_ERROR_MAP.put("mechanic_s_certificate", "【机械员证】已过期");
|
||||||
|
CERTIFICATE_ERROR_MAP.put("cost_engineer_certificate", "【造价员证】已过期");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -74,8 +75,8 @@ public class CertificateUtil {
|
||||||
return true; // 如果日期为空,视为过期
|
return true; // 如果日期为空,视为过期
|
||||||
}
|
}
|
||||||
|
|
||||||
// 身份证特殊处理
|
// 身份证、营业执照特殊处理
|
||||||
if ("national_emblem_id_card".equals(certificateType)) {
|
if ("national_emblem_id_card".equals(certificateType) || "business_license".equals(certificateType)) {
|
||||||
return isIdCardExpired(endDate);
|
return isIdCardExpired(endDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -470,8 +470,8 @@ public class DateTimeHelper {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// getWeekDataList("2023-08-01");
|
// getWeekDataList("2023-08-01");
|
||||||
|
System.err.println(isExpired("2018.02.14"));
|
||||||
System.err.println(getDayADDorReduce("2023-01-01", -7));
|
// System.err.println(getDayADDorReduce("2023-01-01", -7));
|
||||||
// System.err.println(getWeekStartOrEndTime("2023-09-01",true));
|
// System.err.println(getWeekStartOrEndTime("2023-09-01",true));
|
||||||
// System.err.println(getWeekStartOrEndTime("2023-09-01",false));
|
// System.err.println(getWeekStartOrEndTime("2023-09-01",false));
|
||||||
}
|
}
|
||||||
|
|
@ -789,24 +789,41 @@ public class DateTimeHelper {
|
||||||
* @return true: 已超过当前日期(过期), false: 未超过当前日期
|
* @return true: 已超过当前日期(过期), false: 未超过当前日期
|
||||||
*/
|
*/
|
||||||
public static boolean isExpired(String dateStr) {
|
public static boolean isExpired(String dateStr) {
|
||||||
return isExpired(dateStr, "yyyy-MM-dd");
|
return dateIsExpired(dateStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断传入日期是否超过当前日期(自定义格式)
|
* 判断传入日期是否超过当前日期(自定义格式)
|
||||||
* @param dateStr 日期字符串
|
* @param dateStr 日期字符串
|
||||||
* @param pattern 日期格式
|
|
||||||
* @return true: 已超过当前日期(过期), false: 未超过当前日期
|
* @return true: 已超过当前日期(过期), false: 未超过当前日期
|
||||||
*/
|
*/
|
||||||
public static boolean isExpired(String dateStr, String pattern) {
|
public static boolean dateIsExpired(String dateStr) {
|
||||||
try {
|
try {
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
// 尝试多种常见日期格式
|
||||||
LocalDate inputDate = LocalDate.parse(dateStr, formatter);
|
String[] patterns = {
|
||||||
LocalDate currentDate = LocalDate.now();
|
"yyyy-MM-dd",
|
||||||
return inputDate.isBefore(currentDate);
|
"yyyy.MM.dd",
|
||||||
|
"yyyy/MM/dd",
|
||||||
|
"yyyyMMdd"
|
||||||
|
};
|
||||||
|
|
||||||
|
for (String pattern : patterns) {
|
||||||
|
try {
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||||
|
LocalDate inputDate = LocalDate.parse(dateStr, formatter);
|
||||||
|
LocalDate currentDate = LocalDate.now();
|
||||||
|
return inputDate.isBefore(currentDate);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 尝试下一种格式
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.error("日期格式无法识别: {}", dateStr);
|
||||||
|
return false;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("日期格式错误:{}", dateStr);
|
log.error("日期解析异常: {}", dateStr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,4 +56,13 @@ public interface IMDErrorInfoMapper {
|
||||||
* @date 2025/10/24 12:18
|
* @date 2025/10/24 12:18
|
||||||
*/
|
*/
|
||||||
void delErrorInfoByBusinessId(List<ErrorInfo> list);
|
void delErrorInfoByBusinessId(List<ErrorInfo> list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询异常消息
|
||||||
|
* @param errorQueryDto
|
||||||
|
* @return List<String>
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2025/11/17 13:28
|
||||||
|
*/
|
||||||
|
List<String> getErrorInfoByTable(ErrorInfo errorQueryDto);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,4 +54,13 @@ public interface IMDErrorInfoService {
|
||||||
* @date 2025/10/24 12:18
|
* @date 2025/10/24 12:18
|
||||||
*/
|
*/
|
||||||
void delErrorInfoByBusinessId(List<ErrorInfo> errorInfoList);
|
void delErrorInfoByBusinessId(List<ErrorInfo> errorInfoList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询异常消息
|
||||||
|
* @param errorQueryDto
|
||||||
|
* @return List<String>
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2025/11/17 13:28
|
||||||
|
*/
|
||||||
|
List<String> getErrorInfoByTable(ErrorInfo errorQueryDto);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -43,4 +44,9 @@ public class MDErrorInfoServiceImpl implements IMDErrorInfoService {
|
||||||
public void delErrorInfoByBusinessId(List<ErrorInfo> errorInfoList) {
|
public void delErrorInfoByBusinessId(List<ErrorInfo> errorInfoList) {
|
||||||
imdErrorInfoMapper.delErrorInfoByBusinessId(errorInfoList);
|
imdErrorInfoMapper.delErrorInfoByBusinessId(errorInfoList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getErrorInfoByTable(ErrorInfo errorQueryDto) {
|
||||||
|
return imdErrorInfoMapper.getErrorInfoByTable(errorQueryDto);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,4 +58,9 @@
|
||||||
AND tb_error_info.business_type = t.business_type
|
AND tb_error_info.business_type = t.business_type
|
||||||
)
|
)
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<!--查询异常消息-->
|
||||||
|
<select id="getErrorInfoByTable" resultType="java.lang.String">
|
||||||
|
SELECT error_content FROM tb_error_info WHERE source_table = #{sourceTable} AND business_id = #{businessId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue