|
@@ -1,6 +1,7 @@
|
|
|
package com.kxs.product.biz.service.impl;
|
|
package com.kxs.product.biz.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
|
|
+import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -21,16 +22,22 @@ import com.kxs.product.biz.mapper.KxsMachineMapper;
|
|
|
import com.kxs.product.biz.mapper.KxsMachineTrackMapper;
|
|
import com.kxs.product.biz.mapper.KxsMachineTrackMapper;
|
|
|
import com.kxs.product.biz.mapper.KxsMachineTransferMapper;
|
|
import com.kxs.product.biz.mapper.KxsMachineTransferMapper;
|
|
|
import com.kxs.product.biz.service.KxsMachineService;
|
|
import com.kxs.product.biz.service.KxsMachineService;
|
|
|
|
|
+import com.kxs.store.api.feign.RemoteKxsStoreService;
|
|
|
import com.kxs.user.api.feign.RemoteKxsUserService;
|
|
import com.kxs.user.api.feign.RemoteKxsUserService;
|
|
|
import com.kxs.user.api.model.KxsUser;
|
|
import com.kxs.user.api.model.KxsUser;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
+import java.time.Duration;
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
import java.time.LocalTime;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.function.Function;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 客小爽机具表(KxsMachine)表服务实现类
|
|
* 客小爽机具表(KxsMachine)表服务实现类
|
|
@@ -50,6 +57,8 @@ public class KxsMachineServiceImpl extends ServiceImpl<KxsMachineMapper, KxsMach
|
|
|
|
|
|
|
|
private final RemoteKxsUserService remoteKxsUserService;
|
|
private final RemoteKxsUserService remoteKxsUserService;
|
|
|
|
|
|
|
|
|
|
+ private final RemoteKxsStoreService remoteKxsStoreService;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public IPage<MachineStoreListVO> machineStoreList(Page<MachineStoreListVO> page, MachineStoreListDTO param) {
|
|
public IPage<MachineStoreListVO> machineStoreList(Page<MachineStoreListVO> page, MachineStoreListDTO param) {
|
|
|
|
|
|
|
@@ -224,6 +233,72 @@ public class KxsMachineServiceImpl extends ServiceImpl<KxsMachineMapper, KxsMach
|
|
|
return baseMapper.activateMachineMonthTotalDetail(page, param);
|
|
return baseMapper.activateMachineMonthTotalDetail(page, param);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<ExpiredModalBrandVO> expiredModal() {
|
|
|
|
|
+ Long userId = SecurityUtils.getUser().getId();
|
|
|
|
|
+ // 开始时间
|
|
|
|
|
+ long stime = System.currentTimeMillis();
|
|
|
|
|
+
|
|
|
|
|
+ List<ExpiredModalBrandVO> result = new ArrayList<>();
|
|
|
|
|
+ //查询用户已经申请了回收的机具
|
|
|
|
|
+ R<List<String>> listR = remoteKxsStoreService.recycleSnList(SecurityConstants.FROM_IN);
|
|
|
|
|
+ List<String> sns = RetOps.of(listR)
|
|
|
|
|
+ .getData()
|
|
|
|
|
+ .orElse(new ArrayList<>());
|
|
|
|
|
+ //查询品牌
|
|
|
|
|
+ List<KxsBrand> brands = kxsBrandMapper.selectList(Wrappers.emptyWrapper());
|
|
|
|
|
+ //转map方便查询
|
|
|
|
|
+ Map<Integer, KxsBrand> brandMap = brands.stream().collect(Collectors.toMap(KxsBrand::getId, Function.identity()));
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 查询思路
|
|
|
|
|
+ 获取昨天的开始时间
|
|
|
|
|
+ 所有循环机 and 未绑定 and 循环结束时间小于于昨天的开始时间 and 用户ID
|
|
|
|
|
+ */
|
|
|
|
|
+ LocalDateTime startDay = LocalDate.now().plusDays(1).atStartOfDay();
|
|
|
|
|
+ LocalDateTime endDay = LocalDate.now().minusDays(29).atStartOfDay();
|
|
|
|
|
+ List<KxsMachine> machines = baseMapper.selectList(Wrappers.<KxsMachine>lambdaQuery()
|
|
|
|
|
+ .eq(KxsMachine::getUserId, userId)
|
|
|
|
|
+ .eq(KxsMachine::getMachineType, MachineTypeEnum.M_TYPE_RE.getType())
|
|
|
|
|
+ .eq(KxsMachine::getBindStatus, MachineTypeEnum.NO_BIND.getType())
|
|
|
|
|
+ .eq(KxsMachine::getStatus, MachineTypeEnum.STATUS_OUT.getType())
|
|
|
|
|
+ .lt(KxsMachine::getRecycleEndTime, startDay)
|
|
|
|
|
+ .gt(KxsMachine::getRecycleEndTime, endDay)
|
|
|
|
|
+ );
|
|
|
|
|
+ // 结束时间
|
|
|
|
|
+ long etime = System.currentTimeMillis();
|
|
|
|
|
+ //过滤已申请回收的机具
|
|
|
|
|
+ machines = machines.stream().filter(machine -> !sns.contains(machine.getPosSn())).toList();
|
|
|
|
|
+ //组装数据
|
|
|
|
|
+ Map<Integer, List<KxsMachine>> groupMachine = machines.stream().collect(Collectors.groupingBy(KxsMachine::getBrandId));
|
|
|
|
|
+ groupMachine.keySet().forEach(brandId -> {
|
|
|
|
|
+ KxsBrand kxsBrand = brandMap.get(brandId);
|
|
|
|
|
+ if (kxsBrand != null) {
|
|
|
|
|
+ List<KxsMachine> kxsMachines = groupMachine.get(brandId);
|
|
|
|
|
+ ExpiredModalBrandVO expiredModalBrandVO = new ExpiredModalBrandVO();
|
|
|
|
|
+ expiredModalBrandVO.setBrandName(kxsBrand.getName());
|
|
|
|
|
+ //转换为返回的格式
|
|
|
|
|
+ List<ExpiredModalVO> list = kxsMachines.stream().map(item -> {
|
|
|
|
|
+ ExpiredModalVO expiredModalVO = new ExpiredModalVO();
|
|
|
|
|
+ expiredModalVO.setPosSn(item.getPosSn());
|
|
|
|
|
+ Duration between = LocalDateTimeUtil.between(item.getRecycleEndTime(), LocalDateTime.now());
|
|
|
|
|
+
|
|
|
|
|
+ expiredModalVO.setExpiredDay(between.toDays());
|
|
|
|
|
+ return expiredModalVO;
|
|
|
|
|
+ }).toList();
|
|
|
|
|
+ expiredModalBrandVO.setList(list);
|
|
|
|
|
+ result.add(expiredModalBrandVO);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ // 结束时间
|
|
|
|
|
+ long etime1 = System.currentTimeMillis();
|
|
|
|
|
+ // 计算执行时间
|
|
|
|
|
+ System.out.printf("执行时长:%d 毫秒.", (etime - stime));
|
|
|
|
|
+ System.out.printf("执行时长:%d 毫秒.", (etime1 - stime));
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|