Commit a460dcf7 by chamberone

Merge branch 'develop' of https://zhangguoping@gitlab.dituhui.com/bsh/project/pr…

…oject.git into develop
2 parents 32808101 80dfe85a
...@@ -36,8 +36,9 @@ public class ScheduleController { ...@@ -36,8 +36,9 @@ public class ScheduleController {
public Result<?> getScheduleOverview(@RequestParam long page, @RequestParam long size, @RequestParam String date, public Result<?> getScheduleOverview(@RequestParam long page, @RequestParam long size, @RequestParam String date,
@RequestParam String levelType, @RequestParam("levelValue") List<String> levelIds) { @RequestParam String levelType, @RequestParam("levelValue") List<String> levelIds) {
Result<?> res = null; Result<?> res = null;
LocalDate localDate = TimeUtils.IsoDate2LocalDate(date);
try { try {
res = scheduleService.getScheduleOverview(page, size, date, levelType, levelIds); res = scheduleService.getScheduleOverview(page, size, localDate, levelType, levelIds);
} catch (BusinessException e) { } catch (BusinessException e) {
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
} }
...@@ -47,8 +48,9 @@ public class ScheduleController { ...@@ -47,8 +48,9 @@ public class ScheduleController {
@GetMapping("/schedule/engineer/overview") @GetMapping("/schedule/engineer/overview")
public Result<?> getScheduleEngineerOverview(@RequestParam String date, @RequestParam String engineerCode) { public Result<?> getScheduleEngineerOverview(@RequestParam String date, @RequestParam String engineerCode) {
Result<?> res = null; Result<?> res = null;
LocalDate localDate = TimeUtils.IsoDate2LocalDate(date);
try { try {
res = scheduleService.getScheduleEngineerOverview(date, engineerCode); res = scheduleService.getScheduleEngineerOverview(localDate, engineerCode);
} catch (BusinessException e) { } catch (BusinessException e) {
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
} }
......
...@@ -9,7 +9,7 @@ public interface ScheduleService { ...@@ -9,7 +9,7 @@ public interface ScheduleService {
Result<?> getScheduleSummary(LocalDate date, String levelType, List<String> levelIds); Result<?> getScheduleSummary(LocalDate date, String levelType, List<String> levelIds);
Result<?> getScheduleOverview(long page, long size, String date, String levelType, List<String> levelIds); Result<?> getScheduleOverview(long page, long size, LocalDate date, String levelType, List<String> levelIds);
Result<?> getScheduleEngineerOverview(String date, String engineerCode); Result<?> getScheduleEngineerOverview(LocalDate date, String engineerCode);
} }
...@@ -89,6 +89,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -89,6 +89,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
if (capacityEngineerStat == null) { if (capacityEngineerStat == null) {
log.warn("技术员当日的容量数据不存在,{}{}", engineerCode, reqDTO.getDate()); log.warn("技术员当日的容量数据不存在,{}{}", engineerCode, reqDTO.getDate());
} else { } else {
log.info("====== {} ==== {} ", capacityEngineerStat.getCapTotal(), capacityEngineerStat.getCapUsed());
engineer.setCapTotal(capacityEngineerStat.getCapTotal().toString()).setCapUsed(capacityEngineerStat.getCapUsed().toString()); engineer.setCapTotal(capacityEngineerStat.getCapTotal().toString()).setCapUsed(capacityEngineerStat.getCapUsed().toString());
} }
if (mapEngineers.containsKey(engineerCode)) { if (mapEngineers.containsKey(engineerCode)) {
......
...@@ -3,9 +3,11 @@ package com.dituhui.pea.order.service.impl; ...@@ -3,9 +3,11 @@ package com.dituhui.pea.order.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dituhui.pea.common.BusinessException; import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.ListUtils;
import com.dituhui.pea.order.common.TimeUtils; import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.*; import com.dituhui.pea.order.dto.*;
...@@ -68,14 +70,17 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -68,14 +70,17 @@ public class ScheduleServiceImpl implements ScheduleService {
} }
@Override @Override
public Result<?> getScheduleOverview(long page, long size, String date, String levelType, List<String> levelIds) { public Result<?> getScheduleOverview(long page, long size, LocalDate date, String levelType, List<String> levelIds) {
// 获取team列表 // 获取team列表, 以team排序分页
IPage<OrgTeam> pg = this.queryOrgTeams(page, size, levelType, levelIds); IPage<OrgTeam> pg = this.queryOrgTeams(page, size, levelType, levelIds);
List<OrgTeam> orgTeams = pg.getRecords(); List<OrgTeam> orgTeams = pg.getRecords();
List<ScheduleOverviewResp.Team> teams = new ArrayList<>(); List<ScheduleOverviewResp.Team> teams = new ArrayList<>();
// 获取skill与skill_category的映射
HashMap<String, String> skillMapping = this.getSkillMapping();
// 获取工单列表 // 获取工单列表
for (OrgTeam t : orgTeams) { for (OrgTeam t : orgTeams) {
ScheduleOverviewResp.Team team = new ScheduleOverviewResp.Team(); ScheduleOverviewResp.Team team = new ScheduleOverviewResp.Team();
...@@ -85,11 +90,11 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -85,11 +90,11 @@ public class ScheduleServiceImpl implements ScheduleService {
// 获取改team订单列表 // 获取改team订单列表
List<OrderRequest> orders = this.queryOrderRequests(t.getTeamId(), date); List<OrderRequest> orders = this.queryOrderRequests(t.getTeamId(), date);
team.setOrder(this.getTeamOrderSum(orders)); team.setOrder(this.getTeamOrderSum(orders, skillMapping));
// 技术员指派单列表 // 技术员指派单列表
Map<String, List<OrderAppointment>> engineerOrders = new HashMap<>(); Map<String, List<OrderAppointment>> engineerOrders = new HashMap<>();
if (orders != null && !orders.isEmpty()) { if (ListUtils.isNotEmpty(orders)) {
List<String> orderRequestIds = orders.stream().map(OrderRequest::getOrderId).collect(Collectors.toList()); List<String> orderRequestIds = orders.stream().map(OrderRequest::getOrderId).collect(Collectors.toList());
List<OrderAppointment> orderAppointments = this.queryOrderAppointments(orderRequestIds, date); List<OrderAppointment> orderAppointments = this.queryOrderAppointments(orderRequestIds, date);
engineerOrders = orderAppointments.stream().collect(Collectors.groupingBy(OrderAppointment::getEngineerCode)); engineerOrders = orderAppointments.stream().collect(Collectors.groupingBy(OrderAppointment::getEngineerCode));
...@@ -97,9 +102,8 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -97,9 +102,8 @@ public class ScheduleServiceImpl implements ScheduleService {
// 获取team技术员列表 // 获取team技术员列表
List<OrgTeamEngineer> teamEngineers = this.queryOrgTeamEngineers(t.getTeamId()); List<OrgTeamEngineer> teamEngineers = this.queryOrgTeamEngineers(t.getTeamId());
List<String> engineerCodes = teamEngineers.stream().map(OrgTeamEngineer::getEngineerCode).collect(Collectors.toList());
// 获取技术员列表 List<EngineerInfo> engineerInfoList = engineerInfoMPDao.selectByEngineerCodes(engineerCodes);
List<EngineerInfo> engineerInfoList = engineerInfoMPDao.selectByGroupId(t.getGroupId());
Map<String, List<EngineerInfo>> engineers = engineerInfoList.stream().collect(Collectors.groupingBy(EngineerInfo::getEngineerCode)); Map<String, List<EngineerInfo>> engineers = engineerInfoList.stream().collect(Collectors.groupingBy(EngineerInfo::getEngineerCode));
List<ScheduleOverviewResp.Item> children = new ArrayList<>(); List<ScheduleOverviewResp.Item> children = new ArrayList<>();
...@@ -107,6 +111,7 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -107,6 +111,7 @@ public class ScheduleServiceImpl implements ScheduleService {
ScheduleOverviewResp.Item child = new ScheduleOverviewResp.Item(); ScheduleOverviewResp.Item child = new ScheduleOverviewResp.Item();
//技术员信息
String engineerCode = entry.getKey(); String engineerCode = entry.getKey();
EngineerInfo engineerInfo = entry.getValue().get(0); EngineerInfo engineerInfo = entry.getValue().get(0);
...@@ -122,7 +127,7 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -122,7 +127,7 @@ public class ScheduleServiceImpl implements ScheduleService {
child.setName(engineerInfo.getName()); child.setName(engineerInfo.getName());
child.setValue(engineerCode); child.setValue(engineerCode);
child.setLevel("engineer"); child.setLevel("engineer");
child.setOrder(this.getTeamOrderSum(orders2)); child.setOrder(this.getTeamOrderSum(orders2, skillMapping));
child.setOrderDesc(Integer.toString(orders2.size())); child.setOrderDesc(Integer.toString(orders2.size()));
child.setDistanceDesc(""); child.setDistanceDesc("");
...@@ -147,14 +152,14 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -147,14 +152,14 @@ public class ScheduleServiceImpl implements ScheduleService {
} }
@Override @Override
public Result<?> getScheduleEngineerOverview(String date, String engineerCode) throws BusinessException { public Result<?> getScheduleEngineerOverview(LocalDate date, String engineerCode) throws BusinessException {
EngineerInfo engineer = engineerInfoMPDao.getByEngineerCode(engineerCode); EngineerInfo engineer = engineerInfoMPDao.getByEngineerCode(engineerCode);
if (engineer == null) { if (engineer == null) {
throw new BusinessException("分销员不存在"); throw new BusinessException("分销员不存在");
} }
List<LabelValueDTO> emptyTips = new ArrayList<>(); List<LabelValueDTO> emptyTips = new ArrayList<>();
List<OrderAppointment> orderAppointments = this.queryOrderAppointmentsByEngineerCode(engineerCode, date); List<OrderAppointment> orderAppointments = orderAppointmentMPDao.selectByEngineerCodeAndDt(engineerCode, date);
List<TimeLineDTO> timelines = new ArrayList<>(); List<TimeLineDTO> timelines = new ArrayList<>();
for (OrderAppointment o : orderAppointments) { for (OrderAppointment o : orderAppointments) {
TimeLineDTO item = new TimeLineDTO(); TimeLineDTO item = new TimeLineDTO();
...@@ -173,7 +178,7 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -173,7 +178,7 @@ public class ScheduleServiceImpl implements ScheduleService {
List<LabelValueDTO> dynamics = new ArrayList<>(); List<LabelValueDTO> dynamics = new ArrayList<>();
dynamics.add(new LabelValueDTO("姓名", engineer.getName())); dynamics.add(new LabelValueDTO("姓名", engineer.getName()));
dynamics.add(new LabelValueDTO("日期", date)); dynamics.add(new LabelValueDTO("日期", TimeUtils.IsoLocalDate2String(date)));
dynamics.add(new LabelValueDTO("状态", "上班")); dynamics.add(new LabelValueDTO("状态", "上班"));
dynamics.add(new LabelValueDTO("待服务", Integer.toString(countPending))); dynamics.add(new LabelValueDTO("待服务", Integer.toString(countPending)));
dynamics.add(new LabelValueDTO("服务中", Integer.toString(statusGroup.getOrDefault("STARTED", empty).size()))); dynamics.add(new LabelValueDTO("服务中", Integer.toString(statusGroup.getOrDefault("STARTED", empty).size())));
...@@ -250,46 +255,57 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -250,46 +255,57 @@ public class ScheduleServiceImpl implements ScheduleService {
return orgTeamEngineerMPDao.selectList(lqw); return orgTeamEngineerMPDao.selectList(lqw);
} }
private List<OrderRequest> queryOrderRequests(String teamId, String date) { private List<OrderRequest> queryOrderRequests(String teamId, LocalDate date) {
LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrderRequest::getDt, date);
lqw.in(OrderRequest::getOrgTeamId, teamId); lqw.in(OrderRequest::getOrgTeamId, teamId);
lqw.eq(OrderRequest::getAppointmentStatus, "ASSIGNED"); lqw.eq(OrderRequest::getAppointmentStatus, "ASSIGNED");
lqw.ge(OrderRequest::getExpectTimeBegin, TimeUtils.IsoDateTime2Timestamp(String.format("%s 00:00:00", date)));
lqw.le(OrderRequest::getExpectTimeBegin, TimeUtils.IsoDateTime2Timestamp(String.format("%s 23:59:59", date)));
return orderRequestMPDao.selectList(lqw); return orderRequestMPDao.selectList(lqw);
} }
private List<OrderAppointment> queryOrderAppointments(List<String> orderIds, String date) { private List<OrderAppointment> queryOrderAppointments(List<String> orderIds, LocalDate date) {
LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>();
lqw.in(OrderAppointment::getOrderId, orderIds); lqw.in(OrderAppointment::getOrderId, orderIds);
lqw.ge(OrderAppointment::getExpectStartTime, TimeUtils.IsoDateTime2Timestamp(String.format("%s 00:00:00", date))); lqw.eq(OrderAppointment::getDt, date);
lqw.le(OrderAppointment::getExpectEndTime, TimeUtils.IsoDateTime2Timestamp(String.format("%s 23:59:59", date))); lqw.orderByAsc(OrderAppointment::getEngineerCode);
return orderAppointmentMPDao.selectList(lqw); return orderAppointmentMPDao.selectList(lqw);
} }
private List<OrderAppointment> queryOrderAppointmentsByEngineerCode(String engineerCode, String date) { private ScheduleOverviewResp.OrderSum getTeamOrderSum(List<OrderRequest> orders, HashMap<String, String> skillMapping) {
LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>(); ScheduleOverviewResp.OrderSum s = new ScheduleOverviewResp.OrderSum();
lqw.in(OrderAppointment::getEngineerCode, engineerCode);
lqw.ge(OrderAppointment::getExpectStartTime, TimeUtils.IsoDateTime2Timestamp(String.format("%s 00:00:00", date)));
lqw.le(OrderAppointment::getExpectEndTime, TimeUtils.IsoDateTime2Timestamp(String.format("%s 23:59:59", date)));
return orderAppointmentMPDao.selectList(lqw);
}
private ScheduleOverviewResp.OrderSum getTeamOrderSum(List<OrderRequest> orders) { List<OrderRequest> emtpy = new ArrayList<>();
ScheduleOverviewResp.OrderSum s = new ScheduleOverviewResp.OrderSum(); HashMap<String, Integer> skillCounter = new HashMap<>();
Map<String, List<OrderRequest>> cc = orders.stream().collect(Collectors.groupingBy(OrderRequest::getSkill)); Map<String, List<OrderRequest>> cc = orders.stream().collect(Collectors.groupingBy(OrderRequest::getSkill));
List<OrderRequest> emtpy = new ArrayList<>(); for(Map.Entry<String, List<OrderRequest>> entry: cc.entrySet()){
String skill = entry.getKey();
Integer count = entry.getValue().size();
String skillCategory = skillMapping.get(skill);
Integer v = skillCounter.getOrDefault(skillCategory, 0);
v += count;
skillCounter.put(skillCategory, v);
}
s.setTotal(orders.size()); s.setTotal(orders.size());
s.setInstallNum(cc.getOrDefault("安装", emtpy).size()); s.setInstallNum(skillCounter.getOrDefault("安装", 0));
s.setFixNum(cc.getOrDefault("维修", emtpy).size()); s.setFixNum(skillCounter.getOrDefault("维修", 0));
s.setDesignNum(cc.getOrDefault("设计", emtpy).size()); s.setDesignNum(skillCounter.getOrDefault("整改", 0));
s.setCleanNum(cc.getOrDefault("清洗", emtpy).size()); s.setCleanNum(skillCounter.getOrDefault("清洁保养", 0));
return s; return s;
} }
private HashMap<String, String> getSkillMapping() {
LambdaQueryWrapper<SkillInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(SkillInfo::getSkill, SkillInfo::getSkillCategory)
.groupBy(SkillInfo::getSkill, SkillInfo::getSkillCategory);
List<SkillInfo> skillList = skillInfoMPDao.selectList(queryWrapper);
return skillList.stream().collect(Collectors.toMap(
SkillInfo::getSkill, SkillInfo::getSkillCategory, (oldValue, newValue) -> newValue, HashMap::new));
}
private HashMap<String, Integer> queryCountBySkill(LocalDate date, String levelType, List<String> levelValue) { private HashMap<String, Integer> queryCountBySkill(LocalDate date, String levelType, List<String> levelValue) {
HashMap<String, Integer> map = new HashMap<>(); HashMap<String, Integer> map = new HashMap<>();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!