|
|
@@ -864,6 +864,77 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
if (null == storeInfo.getCommissionRate()) {
|
|
|
storeInfo.setCommissionRate("3");
|
|
|
}
|
|
|
+
|
|
|
+ // 处理食品经营许可证OCR数据
|
|
|
+ if (StringUtils.isNotEmpty(storeInfoDto.getFoodLicenceUrl())) {
|
|
|
+ // 查询食品经营许可证OCR识别记录
|
|
|
+ OcrImageUpload foodLicenceOcr = ocrImageUploadMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<OcrImageUpload>()
|
|
|
+ .eq(OcrImageUpload::getImageUrl, storeInfoDto.getFoodLicenceUrl())
|
|
|
+ .eq(OcrImageUpload::getOcrType, OcrTypeEnum.FOOD_MANAGE_LICENSE.getCode())
|
|
|
+ .orderByDesc(OcrImageUpload::getCreateTime)
|
|
|
+ .last("limit 1")
|
|
|
+ );
|
|
|
+ if (foodLicenceOcr != null && StringUtils.isNotEmpty(foodLicenceOcr.getOcrResult())) {
|
|
|
+ try {
|
|
|
+ com.alibaba.fastjson2.JSONObject ocrResult = com.alibaba.fastjson2.JSONObject.parseObject(foodLicenceOcr.getOcrResult());
|
|
|
+ // 食品经营许可证OCR字段:validToDate(优先)、standardizedValidToDate
|
|
|
+ Date expirationTime = parseFoodLicenceExpirationDate(ocrResult);
|
|
|
+ if (expirationTime != null) {
|
|
|
+ storeInfo.setFoodLicenceExpirationTime(expirationTime);
|
|
|
+ }
|
|
|
+ // 设置食品经营许可证状态为"待审核"(字典值2)
|
|
|
+ storeInfo.setFoodLicenceStatus(2);
|
|
|
+ storeInfo.setUpdateFoodLicenceTime(new Date());
|
|
|
+ log.info("食品经营许可证OCR数据解析成功,到期时间:{}", expirationTime);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("解析食品经营许可证OCR数据失败", e);
|
|
|
+ // 解析失败时仍设置状态为待审核
|
|
|
+ storeInfo.setFoodLicenceStatus(2);
|
|
|
+ storeInfo.setUpdateFoodLicenceTime(new Date());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 没有OCR记录时,设置状态为待审核
|
|
|
+ storeInfo.setFoodLicenceStatus(2);
|
|
|
+ storeInfo.setUpdateFoodLicenceTime(new Date());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理娱乐经营许可证OCR数据(复用营业执照OCR类型,数据库中ocr_type存的是BUSINESS_LICENSE)
|
|
|
+ if (StringUtils.isNotEmpty(storeInfoDto.getEntertainmentLicenceUrl())) {
|
|
|
+ // 查询娱乐经营许可证OCR识别记录
|
|
|
+ OcrImageUpload entertainmentLicenceOcr = ocrImageUploadMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<OcrImageUpload>()
|
|
|
+ .eq(OcrImageUpload::getImageUrl, storeInfoDto.getEntertainmentLicenceUrl())
|
|
|
+ .eq(OcrImageUpload::getOcrType, OcrTypeEnum.BUSINESS_LICENSE.getCode())
|
|
|
+ .orderByDesc(OcrImageUpload::getCreateTime)
|
|
|
+ .last("limit 1")
|
|
|
+ );
|
|
|
+ if (entertainmentLicenceOcr != null && StringUtils.isNotEmpty(entertainmentLicenceOcr.getOcrResult())) {
|
|
|
+ try {
|
|
|
+ com.alibaba.fastjson2.JSONObject ocrResult = com.alibaba.fastjson2.JSONObject.parseObject(entertainmentLicenceOcr.getOcrResult());
|
|
|
+ // 娱乐经营许可证OCR字段(复用营业执照类型):validToDate(优先,格式"20220903")、validPeriod(格式"2020年09月04日至2022年09月03日")
|
|
|
+ Date expirationTime = parseEntertainmentLicenceExpirationDate(ocrResult);
|
|
|
+ if (expirationTime != null) {
|
|
|
+ storeInfo.setEntertainmentLicenceExpirationTime(expirationTime);
|
|
|
+ }
|
|
|
+ // 设置娱乐经营许可证状态为"待审核"(字典值2)
|
|
|
+ storeInfo.setEntertainmentLicenceStatus(2);
|
|
|
+ storeInfo.setUpdateEntertainmentLicenceTime(new Date());
|
|
|
+ log.info("娱乐经营许可证OCR数据解析成功,到期时间:{}", expirationTime);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("解析娱乐经营许可证OCR数据失败", e);
|
|
|
+ // 解析失败时仍设置状态为待审核
|
|
|
+ storeInfo.setEntertainmentLicenceStatus(2);
|
|
|
+ storeInfo.setUpdateEntertainmentLicenceTime(new Date());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 没有OCR记录时,设置状态为待审核
|
|
|
+ storeInfo.setEntertainmentLicenceStatus(2);
|
|
|
+ storeInfo.setUpdateEntertainmentLicenceTime(new Date());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
storeInfoMapper.insert(storeInfo);
|
|
|
result.setId(storeInfo.getId());
|
|
|
nearMeService.inGeolocation(new Point(Double.parseDouble(storeInfoDto.getStorePositionLongitude()), Double.parseDouble(storeInfoDto.getStorePositionLatitude())), storeInfo.getId().toString(), Boolean.TRUE);
|
|
|
@@ -2833,11 +2904,37 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
storeImg.setImgType(24);
|
|
|
storeImg.setImgDescription("经营许可证审核通过前图片");
|
|
|
storeImgMapper.insert(storeImg);
|
|
|
+
|
|
|
//更新店铺
|
|
|
StoreInfo storeInfo = new StoreInfo();
|
|
|
storeInfo.setFoodLicenceStatus(2);
|
|
|
storeInfo.setId(storeImg.getStoreId());
|
|
|
storeInfo.setUpdateFoodLicenceTime(new Date());
|
|
|
+
|
|
|
+ // 从OCR识别记录中获取食品经营许可证到期时间
|
|
|
+ if (StringUtils.isNotEmpty(storeImg.getImgUrl())) {
|
|
|
+ OcrImageUpload foodLicenceOcr = ocrImageUploadMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<OcrImageUpload>()
|
|
|
+ .eq(OcrImageUpload::getImageUrl, storeImg.getImgUrl())
|
|
|
+ .eq(OcrImageUpload::getOcrType, OcrTypeEnum.FOOD_MANAGE_LICENSE.getCode())
|
|
|
+ .orderByDesc(OcrImageUpload::getCreateTime)
|
|
|
+ .last("limit 1")
|
|
|
+ );
|
|
|
+ if (foodLicenceOcr != null && StringUtils.isNotEmpty(foodLicenceOcr.getOcrResult())) {
|
|
|
+ try {
|
|
|
+ com.alibaba.fastjson2.JSONObject ocrResult = com.alibaba.fastjson2.JSONObject.parseObject(foodLicenceOcr.getOcrResult());
|
|
|
+ // 解析食品经营许可证到期时间(优先validToDate,其次standardizedValidToDate)
|
|
|
+ Date expirationTime = parseFoodLicenceExpirationDate(ocrResult);
|
|
|
+ if (expirationTime != null) {
|
|
|
+ storeInfo.setFoodLicenceExpirationTime(expirationTime);
|
|
|
+ log.info("食品经营许可证OCR数据解析成功,门店ID:{},到期时间:{}", storeImg.getStoreId(), expirationTime);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("解析食品经营许可证OCR数据失败,门店ID:{}", storeImg.getStoreId(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return storeInfoMapper.updateById(storeInfo);
|
|
|
}
|
|
|
|
|
|
@@ -4988,4 +5085,226 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public int uploadEntertainmentLicence(StoreImg storeImg) {
|
|
|
+ storeImgMapper.delete(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 24).eq(StoreImg::getStoreId, storeImg.getStoreId()));
|
|
|
+ storeImg.setImgType(24);
|
|
|
+ storeImg.setImgDescription("娱乐经营许可证审核通过前图片");
|
|
|
+ storeImgMapper.insert(storeImg);
|
|
|
+
|
|
|
+ //更新店铺
|
|
|
+ StoreInfo storeInfo = new StoreInfo();
|
|
|
+ storeInfo.setEntertainmentLicenceStatus(2);
|
|
|
+ storeInfo.setId(storeImg.getStoreId());
|
|
|
+ storeInfo.setUpdateEntertainmentLicenceTime(new Date());
|
|
|
+
|
|
|
+ // 从OCR识别记录中获取娱乐经营许可证到期时间(复用营业执照OCR类型,数据库中ocr_type存的是BUSINESS_LICENSE)
|
|
|
+ if (StringUtils.isNotEmpty(storeImg.getImgUrl())) {
|
|
|
+ OcrImageUpload entertainmentLicenceOcr = ocrImageUploadMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<OcrImageUpload>()
|
|
|
+ .eq(OcrImageUpload::getImageUrl, storeImg.getImgUrl())
|
|
|
+ .eq(OcrImageUpload::getOcrType, OcrTypeEnum.BUSINESS_LICENSE.getCode())
|
|
|
+ .orderByDesc(OcrImageUpload::getCreateTime)
|
|
|
+ .last("limit 1")
|
|
|
+ );
|
|
|
+ if (entertainmentLicenceOcr != null && StringUtils.isNotEmpty(entertainmentLicenceOcr.getOcrResult())) {
|
|
|
+ try {
|
|
|
+ com.alibaba.fastjson2.JSONObject ocrResult = com.alibaba.fastjson2.JSONObject.parseObject(entertainmentLicenceOcr.getOcrResult());
|
|
|
+ // 解析娱乐经营许可证到期时间(优先validToDate,其次validPeriod)
|
|
|
+ Date expirationTime = parseEntertainmentLicenceExpirationDate(ocrResult);
|
|
|
+ if (expirationTime != null) {
|
|
|
+ storeInfo.setEntertainmentLicenceExpirationTime(expirationTime);
|
|
|
+ log.info("娱乐经营许可证OCR数据解析成功,门店ID:{},到期时间:{}", storeImg.getStoreId(), expirationTime);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("解析娱乐经营许可证OCR数据失败,门店ID:{}", storeImg.getStoreId(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return storeInfoMapper.updateById(storeInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getStoreEntertainmentLicenceStatus(int id) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ StoreInfo storeInfo = storeInfoMapper.selectOne(new LambdaQueryWrapper<StoreInfo>().eq(StoreInfo::getId, id));
|
|
|
+ //审核通过给前台反显未提交
|
|
|
+ if (storeInfo.getEntertainmentLicenceStatus() == 1) {
|
|
|
+ map.put("entertainmentLicenceStatus", 0);
|
|
|
+ } else {
|
|
|
+ map.put("entertainmentLicenceStatus", storeInfo.getEntertainmentLicenceStatus());
|
|
|
+ }
|
|
|
+ //娱乐经营许可证照片列表
|
|
|
+ List<StoreImg> storeImgList = storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getStoreId, id).eq(StoreImg::getImgType, 24));
|
|
|
+ if (!CollectionUtils.isEmpty(storeImgList)) {
|
|
|
+ map.put("entertainmentLicenceImgList", storeImgList);
|
|
|
+ } else {
|
|
|
+ map.put("entertainmentLicenceImgList", "");
|
|
|
+ }
|
|
|
+ if (storeInfo.getEntertainmentLicenceReason() != null) {
|
|
|
+ map.put("entertainmentLicenceReason", storeInfo.getEntertainmentLicenceReason());
|
|
|
+ } else {
|
|
|
+ map.put("entertainmentLicenceReason", "");
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int entertainmentLicenceType(int id) {
|
|
|
+ //删除原娱乐经营许可证照片
|
|
|
+ LambdaUpdateWrapper<StoreImg> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ lambdaUpdateWrapper.eq(StoreImg::getStoreId, id);
|
|
|
+ lambdaUpdateWrapper.eq(StoreImg::getImgType, 26);
|
|
|
+ lambdaUpdateWrapper.set(StoreImg::getDeleteFlag, 1);
|
|
|
+ storeImgMapper.update(null, lambdaUpdateWrapper);
|
|
|
+ //修改娱乐经营许可证类型为审核通过类型
|
|
|
+ List<StoreImg> storeImgList = storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getStoreId, id).eq(StoreImg::getImgType, 24));
|
|
|
+ List<Integer> imgList = storeImgList.stream().map(StoreImg::getId).collect(Collectors.toList());
|
|
|
+ LambdaUpdateWrapper<StoreImg> imgLambdaUpdateWrapper = new LambdaUpdateWrapper();
|
|
|
+ imgLambdaUpdateWrapper.in(StoreImg::getId, imgList).set(StoreImg::getImgType, 26).set(StoreImg::getImgDescription, "娱乐经营许可证审核通过图片");
|
|
|
+ int num = storeImgMapper.update(null, imgLambdaUpdateWrapper);
|
|
|
+ return num;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 解析食品经营许可证OCR结果中的到期时间
|
|
|
+ * 食品经营许可证OCR返回字段:validToDate、standardizedValidToDate
|
|
|
+ *
|
|
|
+ * @param ocrResult OCR识别结果JSON对象
|
|
|
+ * @return 到期日期,如果解析失败则返回null
|
|
|
+ */
|
|
|
+ private Date parseFoodLicenceExpirationDate(com.alibaba.fastjson2.JSONObject ocrResult) {
|
|
|
+ if (ocrResult == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 优先使用validToDate字段(格式可能为空或yyyyMMdd)
|
|
|
+ String validToDate = ocrResult.getString("validToDate");
|
|
|
+ if (StringUtils.isNotEmpty(validToDate)) {
|
|
|
+ Date date = parseDateString(validToDate);
|
|
|
+ if (date != null) {
|
|
|
+ return date;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 其次使用standardizedValidToDate字段
|
|
|
+ String standardizedValidToDate = ocrResult.getString("standardizedValidToDate");
|
|
|
+ if (StringUtils.isNotEmpty(standardizedValidToDate)) {
|
|
|
+ Date date = parseDateString(standardizedValidToDate);
|
|
|
+ if (date != null) {
|
|
|
+ return date;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ log.warn("食品经营许可证OCR结果中未找到有效的到期时间,validToDate={},standardizedValidToDate={}", validToDate, standardizedValidToDate);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 解析娱乐经营许可证OCR结果中的到期时间(复用营业执照OCR类型)
|
|
|
+ * 娱乐经营许可证OCR返回字段:validToDate(格式"20220903")、validPeriod(格式"2020年09月04日至2022年09月03日")
|
|
|
+ *
|
|
|
+ * @param ocrResult OCR识别结果JSON对象
|
|
|
+ * @return 到期日期,如果解析失败则返回null
|
|
|
+ */
|
|
|
+ private Date parseEntertainmentLicenceExpirationDate(com.alibaba.fastjson2.JSONObject ocrResult) {
|
|
|
+ if (ocrResult == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 优先使用validToDate字段(格式为yyyyMMdd,如"20220903")
|
|
|
+ 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.warn("娱乐经营许可证OCR结果中未找到有效的到期时间,validToDate={},validPeriod={}", validToDate, validPeriod);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 解析日期字符串
|
|
|
+ * 支持的格式:yyyyMMdd、yyyy-MM-dd、yyyy/MM/dd、yyyy年MM月dd日
|
|
|
+ *
|
|
|
+ * @param dateStr 日期字符串
|
|
|
+ * @return 日期对象,如果解析失败则返回null
|
|
|
+ */
|
|
|
+ private Date parseDateString(String dateStr) {
|
|
|
+ if (StringUtils.isEmpty(dateStr)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理"长期"或"永久"情况
|
|
|
+ if (dateStr.contains("长期") || dateStr.contains("永久")) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ String normalizedDateStr = dateStr.trim();
|
|
|
+
|
|
|
+ // 如果包含中文年月日,转换格式
|
|
|
+ if (normalizedDateStr.contains("年")) {
|
|
|
+ normalizedDateStr = normalizedDateStr.replaceAll("[年月]", "-").replaceAll("日", "").trim();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 尝试多种日期格式解析
|
|
|
+ String[] dateFormats = {"yyyyMMdd", "yyyy-MM-dd", "yyyy/MM/dd"};
|
|
|
+ for (String format : dateFormats) {
|
|
|
+ try {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat(format);
|
|
|
+ sdf.setLenient(false);
|
|
|
+ return sdf.parse(normalizedDateStr);
|
|
|
+ } catch (Exception ignored) {
|
|
|
+ // 尝试下一个格式
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ log.warn("无法解析日期字符串: {}", dateStr);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 解析有效期字符串,获取结束日期
|
|
|
+ * 支持的格式:
|
|
|
+ * - "2020年09月04日至2022年09月03日"
|
|
|
+ * - "2020-01-01至2025-12-31"
|
|
|
+ * - "长期" 或 "永久" 返回null(表示长期有效)
|
|
|
+ *
|
|
|
+ * @param validPeriod 有效期字符串
|
|
|
+ * @return 结束日期,如果解析失败或为长期有效则返回null
|
|
|
+ */
|
|
|
+ private Date parseValidPeriodEndDate(String validPeriod) {
|
|
|
+ if (StringUtils.isEmpty(validPeriod)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理"长期"或"永久"情况
|
|
|
+ if (validPeriod.contains("长期") || validPeriod.contains("永久")) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ String endDateStr = validPeriod;
|
|
|
+
|
|
|
+ // 如果包含"至",取后半部分作为结束日期
|
|
|
+ if (validPeriod.contains("至")) {
|
|
|
+ String[] parts = validPeriod.split("至");
|
|
|
+ if (parts.length >= 2) {
|
|
|
+ endDateStr = parts[1].trim();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return parseDateString(endDateStr);
|
|
|
+ }
|
|
|
}
|