|
|
@@ -910,10 +910,13 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
storeInfo.setFoodLicenceStatus(2);
|
|
|
storeInfo.setUpdateFoodLicenceTime(new Date());
|
|
|
}
|
|
|
- } else if (storeInfoDto.getFoodLicenceExpirationTime() != null) {
|
|
|
- // 没有食品经营许可证URL,但有传入到期时间时直接使用
|
|
|
- storeInfo.setFoodLicenceExpirationTime(storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
- log.info("无食品经营许可证URL,使用DTO中的到期时间:{}", storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
+ } else {
|
|
|
+ // 没有食品经营许可证URL,初始化状态为"未提交"(字典值0)
|
|
|
+ storeInfo.setFoodLicenceStatus(0);
|
|
|
+ if (storeInfoDto.getFoodLicenceExpirationTime() != null) {
|
|
|
+ storeInfo.setFoodLicenceExpirationTime(storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
+ log.info("无食品经营许可证URL,使用DTO中的到期时间:{}", storeInfoDto.getFoodLicenceExpirationTime());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 处理娱乐经营许可证OCR数据(复用营业执照OCR类型,数据库中ocr_type存的是BUSINESS_LICENSE)
|
|
|
@@ -961,13 +964,78 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
storeInfo.setEntertainmentLicenceStatus(2);
|
|
|
storeInfo.setUpdateEntertainmentLicenceTime(new Date());
|
|
|
}
|
|
|
- } else if (storeInfoDto.getEntertainmentLicenceExpirationTime() != null) {
|
|
|
- // 没有娱乐经营许可证URL,但有传入到期时间时直接使用
|
|
|
- storeInfo.setEntertainmentLicenceExpirationTime(storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
- log.info("无娱乐经营许可证URL,使用DTO中的到期时间:{}", storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
+ } else {
|
|
|
+ // 没有娱乐经营许可证URL,初始化状态为"未提交"(字典值0)
|
|
|
+ storeInfo.setEntertainmentLicenceStatus(0);
|
|
|
+ if (storeInfoDto.getEntertainmentLicenceExpirationTime() != null) {
|
|
|
+ storeInfo.setEntertainmentLicenceExpirationTime(storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
+ log.info("无娱乐经营许可证URL,使用DTO中的到期时间:{}", storeInfoDto.getEntertainmentLicenceExpirationTime());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理营业执照OCR数据(复用营业执照OCR类型,数据库中ocr_type存的是BUSINESS_LICENSE)
|
|
|
+ // 营业执照使用 businessLicenseAddress 列表中的第一个URL查询OCR
|
|
|
+ String businessLicenseOcrUrl = null;
|
|
|
+ if (!CollectionUtils.isEmpty(storeInfoDto.getBusinessLicenseAddress())) {
|
|
|
+ businessLicenseOcrUrl = storeInfoDto.getBusinessLicenseAddress().get(0);
|
|
|
+ } else if (StringUtils.isNotEmpty(storeInfoDto.getBusinessLicenseUrl())) {
|
|
|
+ businessLicenseOcrUrl = storeInfoDto.getBusinessLicenseUrl();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(businessLicenseOcrUrl)) {
|
|
|
+ // 查询营业执照OCR识别记录
|
|
|
+ OcrImageUpload businessLicenseOcr = ocrImageUploadMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<OcrImageUpload>()
|
|
|
+ .eq(OcrImageUpload::getImageUrl, businessLicenseOcrUrl)
|
|
|
+ .eq(OcrImageUpload::getOcrType, OcrTypeEnum.BUSINESS_LICENSE.getCode())
|
|
|
+ .orderByDesc(OcrImageUpload::getCreateTime)
|
|
|
+ .last("limit 1")
|
|
|
+ );
|
|
|
+ if (businessLicenseOcr != null && StringUtils.isNotEmpty(businessLicenseOcr.getOcrResult())) {
|
|
|
+ try {
|
|
|
+ com.alibaba.fastjson2.JSONObject ocrResult = com.alibaba.fastjson2.JSONObject.parseObject(businessLicenseOcr.getOcrResult());
|
|
|
+ // 营业执照OCR字段:validToDate(优先,格式"20241217")、validPeriod(格式"2020年09月04日至2022年09月03日")
|
|
|
+ Date expirationTime = parseBusinessLicenseExpirationDate(ocrResult);
|
|
|
+ if (expirationTime != null) {
|
|
|
+ storeInfo.setBusinessLicenseExpirationTime(expirationTime);
|
|
|
+ } else if (storeInfoDto.getBusinessLicenseExpirationTime() != null) {
|
|
|
+ // OCR解析结果为空时,使用DTO中传入的值
|
|
|
+ storeInfo.setBusinessLicenseExpirationTime(storeInfoDto.getBusinessLicenseExpirationTime());
|
|
|
+ log.info("使用DTO中的营业执照到期时间:{}", storeInfoDto.getBusinessLicenseExpirationTime());
|
|
|
+ }
|
|
|
+ // 设置营业执照状态为"待审核"(字典值2)
|
|
|
+ storeInfo.setBusinessLicenseStatus(2);
|
|
|
+ storeInfo.setUpdateBusinessLicenseTime(new Date());
|
|
|
+ log.info("营业执照OCR数据解析成功,到期时间:{}", storeInfo.getBusinessLicenseExpirationTime());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("解析营业执照OCR数据失败", e);
|
|
|
+ // 解析失败时使用DTO中传入的值
|
|
|
+ if (storeInfoDto.getBusinessLicenseExpirationTime() != null) {
|
|
|
+ storeInfo.setBusinessLicenseExpirationTime(storeInfoDto.getBusinessLicenseExpirationTime());
|
|
|
+ log.info("OCR解析失败,使用DTO中的营业执照到期时间:{}", storeInfoDto.getBusinessLicenseExpirationTime());
|
|
|
+ }
|
|
|
+ storeInfo.setBusinessLicenseStatus(2);
|
|
|
+ storeInfo.setUpdateBusinessLicenseTime(new Date());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 没有OCR记录时,使用DTO中传入的值
|
|
|
+ if (storeInfoDto.getBusinessLicenseExpirationTime() != null) {
|
|
|
+ storeInfo.setBusinessLicenseExpirationTime(storeInfoDto.getBusinessLicenseExpirationTime());
|
|
|
+ log.info("无OCR记录,使用DTO中的营业执照到期时间:{}", storeInfoDto.getBusinessLicenseExpirationTime());
|
|
|
+ }
|
|
|
+ storeInfo.setBusinessLicenseStatus(2);
|
|
|
+ storeInfo.setUpdateBusinessLicenseTime(new Date());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 没有营业执照URL,初始化状态为"未提交"(字典值0)
|
|
|
+ storeInfo.setBusinessLicenseStatus(0);
|
|
|
+ if (storeInfoDto.getBusinessLicenseExpirationTime() != null) {
|
|
|
+ storeInfo.setBusinessLicenseExpirationTime(storeInfoDto.getBusinessLicenseExpirationTime());
|
|
|
+ log.info("无营业执照URL,使用DTO中的到期时间:{}", storeInfoDto.getBusinessLicenseExpirationTime());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- // 计算并设置到期时间为三个过期时间的最小值
|
|
|
+ // 计算并设置到期时间为四个过期时间的最小值
|
|
|
List<Date> expirationTimeList = new ArrayList<>();
|
|
|
// 收集所有非空的过期时间
|
|
|
if (storeInfoDto.getExpirationTime() != null) {
|
|
|
@@ -979,11 +1047,14 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
if (storeInfo.getEntertainmentLicenceExpirationTime() != null) {
|
|
|
expirationTimeList.add(storeInfo.getEntertainmentLicenceExpirationTime());
|
|
|
}
|
|
|
+ if (storeInfo.getBusinessLicenseExpirationTime() != null) {
|
|
|
+ expirationTimeList.add(storeInfo.getBusinessLicenseExpirationTime());
|
|
|
+ }
|
|
|
// 取最小值设置为门店到期时间
|
|
|
if (!expirationTimeList.isEmpty()) {
|
|
|
Date minExpirationTime = Collections.min(expirationTimeList);
|
|
|
storeInfo.setExpirationTime(minExpirationTime);
|
|
|
- log.info("设置门店到期时间为三个过期时间的最小值:{}", minExpirationTime);
|
|
|
+ log.info("设置门店到期时间为四个过期时间的最小值:{}", minExpirationTime);
|
|
|
}
|
|
|
|
|
|
storeInfoMapper.insert(storeInfo);
|
|
|
@@ -5285,6 +5356,41 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
log.warn("娱乐经营许可证OCR结果中未找到有效的到期时间,validToDate={},validPeriod={}", validToDate, validPeriod);
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 解析营业执照OCR结果中的到期时间(复用营业执照OCR类型)
|
|
|
+ * 营业执照OCR返回字段:validToDate(格式"20241217"或空)、validPeriod(可能为空)
|
|
|
+ * 注意:营业执照的validToDate可能为空,表示长期有效
|
|
|
+ *
|
|
|
+ * @param ocrResult OCR识别结果JSON对象
|
|
|
+ * @return 到期日期,如果解析失败或为长期有效则返回null
|
|
|
+ */
|
|
|
+ private Date parseBusinessLicenseExpirationDate(com.alibaba.fastjson2.JSONObject ocrResult) {
|
|
|
+ if (ocrResult == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 优先使用validToDate字段(格式为yyyyMMdd,如"20241217",可能为空表示长期有效)
|
|
|
+ String validToDate = ocrResult.getString("validToDate");
|
|
|
+ if (StringUtils.isNotEmpty(validToDate)) {
|
|
|
+ Date date = parseDateString(validToDate);
|
|
|
+ if (date != null) {
|
|
|
+ return date;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 其次使用validPeriod字段(格式为"2020年09月04日至2022年09月03日",可能为空)
|
|
|
+ String validPeriod = ocrResult.getString("validPeriod");
|
|
|
+ if (StringUtils.isNotEmpty(validPeriod)) {
|
|
|
+ Date date = parseValidPeriodEndDate(validPeriod);
|
|
|
+ if (date != null) {
|
|
|
+ return date;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("营业执照OCR结果中未找到有效的到期时间,validToDate={},validPeriod={},可能为长期有效", validToDate, validPeriod);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 解析日期字符串
|