|
|
@@ -5,6 +5,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import shop.alien.entity.store.*;
|
|
|
import shop.alien.entity.storePlatform.vo.StoreLicenseHistoryDto;
|
|
|
import shop.alien.entity.storePlatform.vo.StoreLicenseHistoryVO;
|
|
|
@@ -16,9 +17,7 @@ import shop.alien.storeplatform.service.LicenseService;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 证照管理服务实现类
|
|
|
@@ -134,26 +133,26 @@ public class LicenseServiceImpl implements LicenseService {
|
|
|
public List<StoreLicenseHistoryDto> queryLicenceByStatusList (Integer storeId) {
|
|
|
|
|
|
List<StoreLicenseHistory> licenseList = licenseHistoryMapper.queryLicenceByStatusList(storeId, 2, 1);
|
|
|
-
|
|
|
+
|
|
|
// 创建日期格式化对象,格式为 yyyy-MM-dd
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
-
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
|
|
+
|
|
|
// 创建返回的 VO 列表
|
|
|
List<StoreLicenseHistoryDto> voList = new java.util.ArrayList<>();
|
|
|
-
|
|
|
+
|
|
|
for (StoreLicenseHistory license : licenseList) {
|
|
|
// 创建 VO 对象
|
|
|
StoreLicenseHistoryDto vo = new StoreLicenseHistoryDto();
|
|
|
|
|
|
// 将实体对象属性复制到 VO 对象
|
|
|
BeanUtils.copyProperties(license, vo);
|
|
|
-
|
|
|
+
|
|
|
// 将创建时间格式化为 yyyy-MM-dd 格式,去除时分秒
|
|
|
if (license.getCreatedTime() != null) {
|
|
|
String dateStr = sdf.format(license.getCreatedTime());
|
|
|
vo.setCreatedDateFormat(dateStr);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 设置审核状态名称
|
|
|
if (license.getLicenseExecuteStatus() != null) {
|
|
|
switch (license.getLicenseExecuteStatus()) {
|
|
|
@@ -171,10 +170,10 @@ public class LicenseServiceImpl implements LicenseService {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
voList.add(vo);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return voList;
|
|
|
}
|
|
|
|
|
|
@@ -185,6 +184,8 @@ public class LicenseServiceImpl implements LicenseService {
|
|
|
Optional<Integer> storeId = storeImgList.stream().map(StoreImg::getStoreId).findFirst();
|
|
|
int value = storeId.orElse(0);
|
|
|
int num = 0;
|
|
|
+
|
|
|
+ Date date = new Date();
|
|
|
//先清除数据
|
|
|
storeImgMapper.delete(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType,22).eq(StoreImg::getStoreId,value));
|
|
|
for (StoreImg renewContract : storeImgList) {
|
|
|
@@ -197,10 +198,7 @@ public class LicenseServiceImpl implements LicenseService {
|
|
|
storeImg.setCreatedUserId(renewContract.getCreatedUserId());
|
|
|
num = storeImgMapper.insert(storeImg);
|
|
|
|
|
|
- // 经营许可证历史表删除
|
|
|
- licenseHistoryMapper.delete(new LambdaQueryWrapper<StoreLicenseHistory>()
|
|
|
- .eq(StoreLicenseHistory::getLicenseStatus,1)
|
|
|
- .eq(StoreLicenseHistory::getStoreId,storeImg.getStoreId()));
|
|
|
+
|
|
|
// 经营许可证历史表插入
|
|
|
StoreLicenseHistory licenseHistory = new StoreLicenseHistory();
|
|
|
licenseHistory.setStoreId(storeImg.getStoreId());
|
|
|
@@ -208,6 +206,7 @@ public class LicenseServiceImpl implements LicenseService {
|
|
|
licenseHistory.setLicenseExecuteStatus(2);
|
|
|
licenseHistory.setImgUrl(storeImg.getImgUrl());
|
|
|
licenseHistory.setDeleteFlag(0);
|
|
|
+ licenseHistory.setCreatedTime(date);
|
|
|
licenseHistoryMapper.insert(licenseHistory);
|
|
|
}
|
|
|
if (num > 0) {
|
|
|
@@ -221,6 +220,168 @@ public class LicenseServiceImpl implements LicenseService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getStoreFoodLicenceStatus(int id) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ StoreInfo storeInfo = storeInfoMapper.selectOne(new LambdaQueryWrapper<StoreInfo>().eq(StoreInfo::getId, id));
|
|
|
+ //审核通过给前台反显未提交
|
|
|
+ if (storeInfo.getFoodLicenceStatus() == 1) {
|
|
|
+ map.put("foodLicenceStatus", 0);
|
|
|
+ } else {
|
|
|
+ map.put("foodLicenceStatus", storeInfo.getFoodLicenceStatus());
|
|
|
+ }
|
|
|
+ //食品经营许可证照片列表
|
|
|
+ List<StoreImg> storeImgList = storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 24).eq(StoreImg::getStoreId, id));
|
|
|
+ if (!CollectionUtils.isEmpty(storeImgList)) {
|
|
|
+ map.put("foodLicenceImgList", storeImgList);
|
|
|
+ } else {
|
|
|
+ map.put("foodLicenceImgList", "");
|
|
|
+ }
|
|
|
+ if (storeInfo.getFoodLicenceReason() != null) {
|
|
|
+ map.put("foodLicenceReason", storeInfo.getFoodLicenceReason());
|
|
|
+ } else {
|
|
|
+ map.put("foodLicenceReason", "");
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getStoreContractStatus(int id) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ StoreInfo storeInfo = storeInfoMapper.selectOne(new LambdaQueryWrapper<StoreInfo>().eq(StoreInfo::getId, id));
|
|
|
+ //审核通过给前台反显未提交
|
|
|
+ if (storeInfo.getRenewContractStatus() == 1) {
|
|
|
+ map.put("renewContractStatus", 0);
|
|
|
+ } else {
|
|
|
+ map.put("renewContractStatus", storeInfo.getRenewContractStatus());
|
|
|
+ }
|
|
|
+ //续签合同照片列表
|
|
|
+ List<StoreImg> storeImgList = storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 22).eq(StoreImg::getStoreId, id));
|
|
|
+ if (!CollectionUtils.isEmpty(storeImgList)) {
|
|
|
+ map.put("contractImgList", storeImgList);
|
|
|
+ } else {
|
|
|
+ map.put("contractImgList", "");
|
|
|
+ }
|
|
|
+ if (storeInfo.getContractReason() != null) {
|
|
|
+ map.put("contractReason", storeInfo.getContractReason());
|
|
|
+ } else {
|
|
|
+ map.put("contractReason", "");
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据商户ID查询合同历史记录列表(按时间分组)
|
|
|
+ * <p>
|
|
|
+ * 查询指定商户的合同历史记录,将创建时间格式化为 yyyy-MM-dd HH:mm:ss 格式,
|
|
|
+ * 并按照时间进行分组,相同时间的数据存储到 licenseList 中
|
|
|
+ * 返回按时间去重后的列表,每个元素包含该时间下的所有记录
|
|
|
+ * 排序规则:时间倒序(最新的在前),同一时间内ID升序
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @param storeId 商户ID
|
|
|
+ * @return 按时间分组的证照历史记录列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<StoreLicenseHistoryDto> queryContractByStatusList (Integer storeId) {
|
|
|
+
|
|
|
+ // 查询证照类型为1(合同管理)的记录
|
|
|
+ List<StoreLicenseHistory> licenseList = licenseHistoryMapper.queryLicenceByStatusList(storeId, 1, 1);
|
|
|
+
|
|
|
+ // 第一步:对原始数据进行排序
|
|
|
+ // 时间倒序(最新的在前),同一时间内ID升序
|
|
|
+ licenseList.sort((o1, o2) -> {
|
|
|
+ // 先按时间倒序排序(最新的在前)
|
|
|
+ if (o1.getCreatedTime() != null && o2.getCreatedTime() != null) {
|
|
|
+ int timeCompare = o2.getCreatedTime().compareTo(o1.getCreatedTime());
|
|
|
+ if (timeCompare != 0) {
|
|
|
+ return timeCompare;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 时间相同时,按ID升序排序
|
|
|
+ if (o1.getId() != null && o2.getId() != null) {
|
|
|
+ return o1.getId().compareTo(o2.getId());
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ });
|
|
|
+
|
|
|
+ // 创建日期格式化对象,格式为 yyyy-MM-dd HH:mm:ss
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
|
|
|
|
|
+ // 使用 LinkedHashMap 按时间分组,保持插入顺序
|
|
|
+ Map<String, List<StoreLicenseHistoryDto>> timeGroupMap = new LinkedHashMap<>();
|
|
|
+
|
|
|
+ // 第二步:按时间分组,将所有数据按时间归类
|
|
|
+ for (StoreLicenseHistory license : licenseList) {
|
|
|
+ // 创建 VO 对象
|
|
|
+ StoreLicenseHistoryDto vo = new StoreLicenseHistoryDto();
|
|
|
+
|
|
|
+ // 将实体对象属性复制到 VO 对象
|
|
|
+ BeanUtils.copyProperties(license, vo);
|
|
|
+
|
|
|
+ // 格式化创建时间
|
|
|
+ String dateKey = "";
|
|
|
+ if (license.getCreatedTime() != null) {
|
|
|
+ String dateStr = sdf.format(license.getCreatedTime());
|
|
|
+ vo.setCreatedDateFormat(dateStr);
|
|
|
+ // 使用日期时间作为分组 key
|
|
|
+ dateKey = dateStr;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置审核状态名称
|
|
|
+ if (license.getLicenseExecuteStatus() != null) {
|
|
|
+ switch (license.getLicenseExecuteStatus()) {
|
|
|
+ case 1:
|
|
|
+ vo.setLicenseExecuteName("审核通过");
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ vo.setLicenseExecuteName("审核中");
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ vo.setLicenseExecuteName("审核失败");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ vo.setLicenseExecuteName("未知");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 将 VO 对象添加到对应时间的列表中
|
|
|
+ if (!dateKey.isEmpty()) {
|
|
|
+ timeGroupMap.computeIfAbsent(dateKey, k -> new ArrayList<>()).add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 第三步:将分组后的数据转换为列表结构
|
|
|
+ // 每个时间节点创建一个父对象,将该时间的所有记录存储到 licenseList 中
|
|
|
+ List<StoreLicenseHistoryDto> resultList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Map.Entry<String, List<StoreLicenseHistoryDto>> entry : timeGroupMap.entrySet()) {
|
|
|
+ String timeKey = entry.getKey();
|
|
|
+ List<StoreLicenseHistoryDto> sameTimeList = entry.getValue();
|
|
|
+
|
|
|
+ // 创建一个父对象,代表这个时间节点
|
|
|
+ StoreLicenseHistoryDto parentVo = new StoreLicenseHistoryDto();
|
|
|
+
|
|
|
+ // 使用第一条记录的基本信息作为父对象的信息(ID最小的那条)
|
|
|
+ if (!sameTimeList.isEmpty()) {
|
|
|
+ StoreLicenseHistoryDto firstItem = sameTimeList.get(0);
|
|
|
+ BeanUtils.copyProperties(firstItem, parentVo);
|
|
|
+
|
|
|
+ // 将相同时间的所有记录存储到 licenseList 中(已按ID升序排列)
|
|
|
+ parentVo.setLicenseList(sameTimeList);
|
|
|
+ parentVo.setCreatedDateFormat(timeKey);
|
|
|
+
|
|
|
+ resultList.add(parentVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("queryContractByStatusList - 共查询到 {} 条记录,按时间分组后 {} 个时间节点",
|
|
|
+ licenseList.size(), resultList.size());
|
|
|
+
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
}
|
|
|
|