Commit 2d0be1a5 by huluobin

update

parent 43d25133
......@@ -26,6 +26,7 @@ import com.gogirl.infrastructure.common.config.property.GogirlProperties;
import com.gogirl.infrastructure.common.exception.ErrorCode;
import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.common.util.*;
import com.gogirl.infrastructure.common.util.thread.ThreadUtil;
import com.gogirl.infrastructure.mapper.market.discount.LeisureDiscountConfigLabelMapper;
import com.gogirl.infrastructure.mapper.market.discount.LeisureDiscountConfigLimitMapper;
import com.gogirl.infrastructure.mapper.market.discount.LeisureDiscountConfigMapper;
......@@ -57,7 +58,8 @@ import java.text.SimpleDateFormat;
import java.time.*;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static com.gogirl.domain.order.serve.OrderServe.COMMENT_STATUS_NO;
......@@ -279,47 +281,54 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
});
//线程池加速
ForkJoinPool myPool = new ForkJoinPool(qry.getDateTimeList().size());
List<IdleTimeDTO> idleTimeDTOList = new ArrayList<>(qry.getDateTimeList().size());
myPool.submit(() -> qry.getDateTimeList()
.forEach(dateTime -> {
//每个主服务由不同的美甲师做,setter主服务的时间period
mainScheduleServeQueryLinkedList.forEach(mainScheduleServeQuery -> {
Period period = new Period(dateTime, dateTime + mainScheduleServeQuery.getLengthTimeForEndTime().longValue() * 60000);
mainScheduleServeQuery.setPeriod(period);
});
List<IdleTimeDTO> idleTimeDTOList = new ArrayList<>(qry.getDateTimeList().size());
//主服务深度克隆
Queue<ScheduleServeQuery> cloneMainServeDTOList = mainScheduleServeQueryLinkedList.stream().map(SerializationUtils::clone).collect(Collectors.toCollection(LinkedList::new));
ExecutorService threadPool = ThreadUtil.newExecutor(qry.getDateTimeList().size());
for (Long dateTime : qry.getDateTimeList()) {
threadPool.submit(() -> {
System.out.println("threadName:" + Thread.currentThread().getName());
//美甲师深度克隆
List<StoreTechnicianPeriod> cloneStoreTechnicianDTOList = storeTechnicianDTOList.stream().map(SerializationUtils::clone).collect(Collectors.toList());
//每个主服务由不同的美甲师做,setter主服务的时间period
mainScheduleServeQueryLinkedList.forEach(mainScheduleServeQuery -> {
Period period = new Period(dateTime, dateTime + mainScheduleServeQuery.getLengthTimeForEndTime().longValue() * 60000);
mainScheduleServeQuery.setPeriod(period);
});
//根据需要预约的服务和美甲师构造预约方案树🌲
TreeProgram treeProgram = this.buildTreeProgram(cloneMainServeDTOList, cloneStoreTechnicianDTOList, TreeProgram.root());
//主服务深度克隆
Queue<ScheduleServeQuery> cloneMainServeDTOList = mainScheduleServeQueryLinkedList.stream().map(SerializationUtils::clone).collect(Collectors.toCollection(LinkedList::new));
Map<Integer, List<TechnicianServe>> technicianServeMap = technicianServeMapper.selectList(new LambdaQueryWrapper<TechnicianServe>().in(TechnicianServe::getServeId, cloneMainServeDTOList.stream().map(ScheduleServeQuery::getServeId).collect(Collectors.toList())))
.stream().collect(Collectors.groupingBy(TechnicianServe::getServeId));
//美甲师深度克隆
List<StoreTechnicianPeriod> cloneStoreTechnicianDTOList = storeTechnicianDTOList.stream().map(SerializationUtils::clone).collect(Collectors.toList());
//构造默认美甲师
List<TreeProgram> defaultNodeList = new ArrayList<>();
this.buildDefaultNodeList(defaultNodeList, treeProgram);
//根据需要预约的服务和美甲师构造预约方案树🌲
TreeProgram treeProgram = this.buildTreeProgram(cloneMainServeDTOList, cloneStoreTechnicianDTOList, TreeProgram.root(), technicianServeMap);
IdleTimeDTO idleTimeDTO = new IdleTimeDTO();
idleTimeDTO.setDateTime(dateTime);
idleTimeDTO.setTime(new SimpleDateFormat("HH:mm").format(new Date(dateTime)));
//构造默认美甲师
List<TreeProgram> defaultNodeList = new ArrayList<>();
this.buildDefaultNodeList(defaultNodeList, treeProgram);
/*关键信息 节点是否可用*/
idleTimeDTO.setStatus(!treeProgram.childNull());
idleTimeDTO.setTreeProgram(treeProgram);
idleTimeDTO.setDefaultNodeList(defaultNodeList);
IdleTimeDTO idleTimeDTO = new IdleTimeDTO();
idleTimeDTO.setDateTime(dateTime);
idleTimeDTO.setTime(new SimpleDateFormat("HH:mm").format(new Date(dateTime)));
idleTimeDTOList.add(idleTimeDTO);
/*关键信息 节点是否可用*/
idleTimeDTO.setStatus(!treeProgram.childNull());
idleTimeDTO.setTreeProgram(treeProgram);
idleTimeDTO.setDefaultNodeList(defaultNodeList);
})).get();
idleTimeDTOList.add(idleTimeDTO);
});
}
myPool.shutdown();
threadPool.shutdown();
//等待直到所有任务完成
try {
threadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.MINUTES);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (qry.getShowNodeDetail() != null && !qry.getShowNodeDetail()) {
idleTimeDTOList.forEach(idleTimeDTO -> {
......@@ -356,7 +365,8 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
private TreeProgram buildTreeProgram(Queue<ScheduleServeQuery> scheduleServeQueryList,
List<StoreTechnicianPeriod> storeTechnicians,
TreeProgram parent) {
TreeProgram parent,
Map<Integer, List<TechnicianServe>> technicianServeMap) {
final ScheduleServeQuery scheduleServeQuery = scheduleServeQueryList.poll();
......@@ -365,7 +375,8 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
//遍历每一个美甲师
storeTechnicians.stream()
.filter(storeTechnicianPeriod -> {
List<TechnicianServe> technicianServeList = technicianServeMapper.selectList(new LambdaQueryWrapper<TechnicianServe>().eq(TechnicianServe::getServeId, scheduleServeQuery.getServeId()));
List<TechnicianServe> technicianServeList = technicianServeMap.get(scheduleServeQuery.getServeId());
return technicianServeList.stream().map(TechnicianServe::getTechnicianId).collect(Collectors.toList()).contains(storeTechnicianPeriod.getTechnicianId());
})
.forEach(storeTechnician -> {
......@@ -421,7 +432,7 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
//如果还有服务 继续构造子树
if (!CollectionUtils.isEmpty(scheduleServeQueryList)) {
Queue<ScheduleServeQuery> cloneScheduleServeQueryList = scheduleServeQueryList.stream().map(SerializationUtils::clone).collect(Collectors.toCollection(LinkedList::new));
this.buildTreeProgram(cloneScheduleServeQueryList, storeTechnicians, node);
this.buildTreeProgram(cloneScheduleServeQueryList, storeTechnicians, node, technicianServeMap);
//如果构造的子树为空
if (!node.childNull()) {
......
......@@ -2,8 +2,10 @@ package com.gogirl.infrastructure.mapper.product.serve;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gogirl.domain.product.serve.TechnicianServe;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
public interface TechnicianServeMapper extends BaseMapper<TechnicianServe> {
List<TechnicianServe> selectByServeId(Integer serveId);
}
......@@ -46,7 +46,7 @@ spring:
#redis配置
redis:
# host: host.docker.internal
host: 127.0.0.1
host: 106.55.55.253
port: 6379
database: 0
lettuce:
......@@ -56,6 +56,7 @@ spring:
max-idle: 200
min-idle: 0
timeout: 60000ms
password: 'gogirl2020test.'
mail:
host: smtp.qq.com
......
spring:
profiles:
active: prod
active: pre
servlet:
#文件上传最大容量
multipart:
......@@ -14,8 +14,8 @@ spring:
mybatis-plus:
mapper-locations:
- classpath:mapper/**/*.xml
# configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
server:
undertow:
......
......@@ -120,7 +120,7 @@
<!-- 测试环境日志级别为INFO -->
<springProfile name="pre">
<logger name="com.gogirl" level="DEBUG"/>
<logger name="*" level="DEBUG"/>
<logger name="org.springframework" level="INFO"/>
<!--日志打印的包的范围,及分类日志文件存储 -->
......@@ -132,7 +132,7 @@
<appender-ref ref="INFO"/>
</logger>
<root level="INFO" additivity="false">
<root level="DEBUG" additivity="false">
<appender-ref ref="STDOUT"/>
</root>
</springProfile>
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.gogirl.infrastructure.mapper.product.serve.TechnicianServeMapper">
<select id="selectByServeId" resultType="com.gogirl.domain.product.serve.TechnicianServe" useCache="true">
select *
from technician_serve
where serve_id = #{serveId}
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment