Commit 2d8b9faa by 丁伟峰

Merge remote-tracking branch 'origin/develop' into develop

# Conflicts:
#	project-order/src/main/java/com/dituhui/pea/order/service/impl/WorkbenchServiceImpl.java
2 parents 40c240f5 c275449f
...@@ -10,13 +10,12 @@ import java.util.List; ...@@ -10,13 +10,12 @@ import java.util.List;
public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long> { public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long> {
OrderInfoEntity getByOrderId(String orderId); OrderInfoEntity getByOrderId(String orderId);
OrderInfoEntity getByOrderIdAndDt(String orderId, LocalDate dt); OrderInfoEntity getByOrderIdAndDt(String orderId, LocalDate dt);
List<OrderInfoEntity> findByOrderId(String orderId); List<OrderInfoEntity> findByOrderId(String orderId);
List<OrderInfoEntity> findByDtAndEngineerCodeIn(LocalDate date, List<String> engineerCodes); List<OrderInfoEntity> findByDtAndEngineerCodeIn(LocalDate date, List<String> engineerCodes);
List<OrderInfoEntity> findByDtAndEngineerCode(LocalDate date, String engineerCode);
@Query("SELECT o.orderId, s.skillCategory as skillCaption FROM OrderInfoEntity o JOIN SkillInfoEntity s on o.brand=s.brand and o.type=s.type and o.skill=s.skill WHERE o.orderId = :orderId") @Query("SELECT o.orderId, s.skillCategory as skillCaption FROM OrderInfoEntity o JOIN SkillInfoEntity s on o.brand=s.brand and o.type=s.type and o.skill=s.skill WHERE o.orderId = :orderId")
OrderSkillProjection getOrderSkillCaptionByOrderId(String orderId); OrderSkillProjection getOrderSkillCaptionByOrderId(String orderId);
List<OrderInfoEntity> findAllByOrderIdIn(List<String> orderIds); List<OrderInfoEntity> findAllByOrderIdIn(List<String> orderIds);
List<OrderInfoEntity> findAllByDtAndOrderIdIn(LocalDate dt, List<String> orderIds);
List<OrderInfoEntity> findByEngineerCodeAndDtAndAppointmentStatusIn(String engineerCode, LocalDate dt, List<String> appointmentStatus);
} }
...@@ -15,6 +15,8 @@ public interface OrgGroupDao extends JpaRepository<OrgGroupEntity, Integer> { ...@@ -15,6 +15,8 @@ public interface OrgGroupDao extends JpaRepository<OrgGroupEntity, Integer> {
List<OrgGroupEntity> findAllByClusterId(String clusterId); List<OrgGroupEntity> findAllByClusterId(String clusterId);
List<OrgGroupEntity> findAllByGroupId(String groupId);
OrgGroupEntity getByGroupId(String groupId); OrgGroupEntity getByGroupId(String groupId);
public List<OrgGroupEntity> findByGroupIdIn(List<String> ids); public List<OrgGroupEntity> findByGroupIdIn(List<String> ids);
......
...@@ -22,6 +22,9 @@ public interface OrgTeamDao extends JpaRepository<OrgTeamEntity, Integer> { ...@@ -22,6 +22,9 @@ public interface OrgTeamDao extends JpaRepository<OrgTeamEntity, Integer> {
@Query("select t from OrgTeamEntity t where t.groupId = :groupId and t.status=1") @Query("select t from OrgTeamEntity t where t.groupId = :groupId and t.status=1")
List<OrgTeamEntity> findAllByGroupId(String groupId); List<OrgTeamEntity> findAllByGroupId(String groupId);
@Query("select t from OrgTeamEntity t where t.teamId = :teamId and t.status=1")
List<OrgTeamEntity> findAllByTeamId(String teamId);
@Query("select t from OrgTeamEntity t where t.groupId = :groupId and t.status=1") @Query("select t from OrgTeamEntity t where t.groupId = :groupId and t.status=1")
Page<OrgTeamEntity> findAllByGroupId(String groupId, Pageable pageable); Page<OrgTeamEntity> findAllByGroupId(String groupId, Pageable pageable);
......
...@@ -23,4 +23,6 @@ public interface WarehouseInfoDao extends JpaRepository<OrgWarehouseInfoEntity, ...@@ -23,4 +23,6 @@ public interface WarehouseInfoDao extends JpaRepository<OrgWarehouseInfoEntity,
OrgWarehouseInfoEntity getOrgWarehouseInfoEntityByWarehouseId(String wareHouseId); OrgWarehouseInfoEntity getOrgWarehouseInfoEntityByWarehouseId(String wareHouseId);
List<OrgWarehouseInfoEntity> findByBranchId(String branchId);
} }
...@@ -11,6 +11,12 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -11,6 +11,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -21,19 +27,19 @@ import java.util.stream.Stream; ...@@ -21,19 +27,19 @@ import java.util.stream.Stream;
public class EngineerTimelineServiceImpl implements EngineerTimelineService { public class EngineerTimelineServiceImpl implements EngineerTimelineService {
@Autowired @Autowired
private OrderInfoMPDao orderInfoMPDao; private OrderInfoDao orderInfoDao;
@Autowired @Autowired
private EngineerInfoMPDao engineerInfoMPDao; private EngineerInfoDao engineerInfoDao;
@Autowired @Autowired
private WarehouseInfoMPDao warehouseInfoMPDao; private WarehouseInfoDao warehouseInfoDao;
@Autowired @Autowired
private OrgGroupMPDao orgGroupMPDao; private OrgGroupDao orgGroupDao;
@Autowired @Autowired
private OrderEventMPDao orderEventMPDao; private EntityManager entityManager;
@Transactional @Transactional
@Override @Override
...@@ -42,14 +48,14 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService { ...@@ -42,14 +48,14 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
LocalDate localDate = TimeUtils.IsoDate2LocalDate(date); LocalDate localDate = TimeUtils.IsoDate2LocalDate(date);
// 工程師信息 // 工程師信息
EngineerInfo engineerInfo = engineerInfoMPDao.getByEngineerCode(engineerCode); EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(engineerCode);
// 获取工程师date日的订单数据 // 获取工程师date日的订单数据
List<OrderInfo> orders = this.selectEngineerOrders(engineerCode, localDate); List<OrderInfoEntity> orders = this.selectEngineerOrders(engineerCode, localDate);
// 获取工程师已完成的timeline数据 // 获取工程师已完成的timeline数据
List<String> orderIds = orders.stream().map(OrderInfo::getOrderId).collect(Collectors.toList()); List<String> orderIds = orders.stream().map(OrderInfoEntity::getOrderId).collect(Collectors.toList());
List<OrderEvent> timelines = this.engineerTimelines(orderIds, date); List<OrderEventEntity> timelines = this.engineerTimelines(orderIds, date);
// 获取客户地址 // 获取客户地址
HashMap<String, String> orderLocations = this.orderRequestsLocation(orders); HashMap<String, String> orderLocations = this.orderRequestsLocation(orders);
...@@ -67,30 +73,39 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService { ...@@ -67,30 +73,39 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
return Result.success(res); return Result.success(res);
} }
private List<OrderInfo> selectEngineerOrders(String engineerCode, LocalDate dt){ private List<OrderInfoEntity> selectEngineerOrders(String engineerCode, LocalDate dt){
LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>(); List<OrderInfoEntity> orders = orderInfoDao.findByEngineerCodeAndDtAndAppointmentStatusIn(
lqw.eq(OrderInfo::getDt, dt); engineerCode, dt, List.of("PRE", "CONFIRM"));
lqw.eq(OrderInfo::getEngineerCode, engineerCode); return orders.stream().filter(o -> !o.getOrderStatus().equals("CANCEL")).collect(Collectors.toList());
lqw.ne(OrderInfo::getAppointmentStatus, "INIT");
lqw.ne(OrderInfo::getOrderStatus, "CANCEL");
return orderInfoMPDao.selectList(lqw);
} }
private List<OrderEvent> engineerTimelines(List<String> orderIds, String date){ public List<OrderEventEntity> engineerTimelines(List<String> orderIds, String date) {
// 获取工程师timeline List<String> events = Arrays.asList("分站取还配件", "已出发", "加单");
List<String> events = Stream.of("分站取还配件", "已出发", "加单").collect(Collectors.toList());
LambdaQueryWrapper<OrderEvent> lqw = new LambdaQueryWrapper<>(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
lqw.in(OrderEvent::getOrderId, orderIds); CriteriaQuery<OrderEventEntity> criteriaQuery = criteriaBuilder.createQuery(OrderEventEntity.class);
lqw.ge(OrderEvent::getHappen, date+" 00:00:00"); Root<OrderEvent> root = criteriaQuery.from(OrderEvent.class);
lqw.le(OrderEvent::getHappen, date + " 23:59:59");
lqw.in(OrderEvent::getEvent, events); List<Predicate> predicates = new ArrayList<>();
return orderEventMPDao.selectList(lqw);
predicates.add(root.get("orderId").in(orderIds));
predicates.add(criteriaBuilder.greaterThanOrEqualTo(root.get("happen"), date + " 00:00:00"));
predicates.add(criteriaBuilder.lessThanOrEqualTo(root.get("happen"), date + " 23:59:59"));
predicates.add(root.get("event").in(events));
criteriaQuery.where(predicates.toArray(new Predicate[0]));
TypedQuery<OrderEventEntity> typedQuery = entityManager.createQuery(criteriaQuery);
List<OrderEventEntity> result = typedQuery.getResultList();
return result;
} }
private HashMap<String, String> orderRequestsLocation(List<OrderInfo> orders) {
private HashMap<String, String> orderRequestsLocation(List<OrderInfoEntity> orders) {
// 获取客户地址location // 获取客户地址location
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
for(OrderInfo o: orders){ for(OrderInfoEntity o: orders){
map.put(o.getOrderId(), String.format("%s,%s", o.getX(), o.getY())); map.put(o.getOrderId(), String.format("%s,%s", o.getX(), o.getY()));
} }
return map; return map;
...@@ -98,38 +113,30 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService { ...@@ -98,38 +113,30 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
private String getWarehouseLocation(String branchId) { private String getWarehouseLocation(String branchId) {
// 获取配送站location // 获取配送站location
LambdaQueryWrapper<OrgWarehouseInfo> lqw = new LambdaQueryWrapper<>(); List<OrgWarehouseInfoEntity> wares = warehouseInfoDao.findByBranchId(branchId);
lqw.eq(OrgWarehouseInfo::getBranchId, branchId); OrgWarehouseInfoEntity w = wares.get(0);
List<OrgWarehouseInfo> wares = warehouseInfoMPDao.selectList(lqw);
OrgWarehouseInfo w = wares.get(0);
return String.format("%s,%s", w.getX(), w.getY()); return String.format("%s,%s", w.getX(), w.getY());
} }
private String getEngineerBranchId(String engineerCode) { private String getEngineerBranchId(String engineerCode) {
LambdaQueryWrapper<EngineerInfo> lqw = new LambdaQueryWrapper<>(); EngineerInfoEntity e = engineerInfoDao.getByEngineerCode(engineerCode);
lqw.select(EngineerInfo::getGroupId);
lqw.eq(EngineerInfo::getEngineerCode, engineerCode);
EngineerInfo e = engineerInfoMPDao.selectOne(lqw);
if (e == null) { if (e == null) {
return ""; return "";
} }
OrgGroupEntity g = orgGroupDao.getByGroupId(e.getGroupId());
LambdaQueryWrapper<OrgGroup> lqw2 = new LambdaQueryWrapper<>();
lqw2.select(OrgGroup::getBranchId);
lqw2.eq(OrgGroup::getGroupId, e.getGroupId());
OrgGroup g = orgGroupMPDao.selectOne(lqw2);
return (g==null)? "": g.getBranchId(); return (g==null)? "": g.getBranchId();
} }
private List<EngineerTimelineResp.DynamicItem> packItems(List<OrderEvent> timelines, List<OrderInfo> orders, HashMap<String, String> locations, String warehouseLocation) { private List<EngineerTimelineResp.DynamicItem> packItems(List<OrderEventEntity> timelines, List<OrderInfoEntity> orders,
HashMap<String, String> locations, String warehouseLocation) {
int index = 0; int index = 0;
String order_id, title, type, text, location; String order_id, title, type, text, location;
List<EngineerTimelineResp.DynamicItem> items = new ArrayList<>(); List<EngineerTimelineResp.DynamicItem> items = new ArrayList<>();
Set<String> s = new HashSet<>(); Set<String> s = new HashSet<>();
for (OrderEvent t: timelines){ for (OrderEventEntity t: timelines){
EngineerTimelineResp.DynamicItem item = new EngineerTimelineResp.DynamicItem(); EngineerTimelineResp.DynamicItem item = new EngineerTimelineResp.DynamicItem();
if (t.getEvent().equals("分站取还配件")) { if (t.getEvent().equals("分站取还配件")) {
...@@ -146,7 +153,7 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService { ...@@ -146,7 +153,7 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
continue; continue;
} }
item.setTitle(title); item.setTitle(title);
item.setTime(TimeUtils.IsoTimestamp2DateTime(t.getHappen())); item.setTime(TimeUtils.IsoLocalDateTime2String(t.getHappen()));
item.setStatus(1); item.setStatus(1);
item.setText(text); item.setText(text);
...@@ -157,8 +164,8 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService { ...@@ -157,8 +164,8 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
s.add(t.getOrderId() + t.getSuborderId()); s.add(t.getOrderId() + t.getSuborderId());
} }
List<OrderInfo> records = orders.stream().sorted(Comparator.comparing(OrderInfo::getPlanStartTime)).collect(Collectors.toList()); List<OrderInfoEntity> records = orders.stream().sorted(Comparator.comparing(OrderInfoEntity::getPlanStartTime)).collect(Collectors.toList());
for(OrderInfo o: records){ for(OrderInfoEntity o: records){
order_id = o.getOrderId() + o.getSubId(); order_id = o.getOrderId() + o.getSubId();
if (s.contains(order_id)) { if (s.contains(order_id)) {
continue; continue;
...@@ -166,7 +173,7 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService { ...@@ -166,7 +173,7 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
index += 1; index += 1;
EngineerTimelineResp.DynamicItem item = new EngineerTimelineResp.DynamicItem(); EngineerTimelineResp.DynamicItem item = new EngineerTimelineResp.DynamicItem();
item.setTitle(String.format("第%d单出发", index)); item.setTitle(String.format("第%d单出发", index));
item.setTime(TimeUtils.IsoTimestamp2DateTime(o.getPlanStartTime())); item.setTime(TimeUtils.IsoLocalDateTime2String(o.getPlanStartTime()));
item.setStatus(0); item.setStatus(0);
item.setText(String.format("%d", index)); item.setText(String.format("%d", index));
item.setLocation(locations.get(o.getOrderId())); item.setLocation(locations.get(o.getOrderId()));
......
...@@ -28,10 +28,10 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -28,10 +28,10 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
private OrderInfoMPDao orderInfoMPDao; private OrderInfoMPDao orderInfoMPDao;
@Autowired @Autowired
private EngineerInfoMPDao engineerInfoMPDao; private EngineerInfoDao engineerInfoDao;
@Autowired @Autowired
private OrgBranchMPDao orgBranchMPDao; private OrgBranchDao orgBranchDao;
@Transactional @Transactional
@Override @Override
...@@ -167,8 +167,8 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -167,8 +167,8 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
if(engineerCodes.isEmpty()){ if(engineerCodes.isEmpty()){
return new HashMap<>(); return new HashMap<>();
} }
List<EngineerInfo> engineers = engineerInfoMPDao.selectByEngineerCodes(new ArrayList<>(engineerCodes)); List<EngineerInfoEntity> engineers = engineerInfoDao.findByEngineerCodeIn(new ArrayList<>(engineerCodes));
return engineers.stream().collect(Collectors.toMap(EngineerInfo::getEngineerCode, EngineerInfo::getName)); return engineers.stream().collect(Collectors.toMap(EngineerInfoEntity::getEngineerCode, EngineerInfoEntity::getName));
} }
private Map<String, String> getBranchNames(List<OrderInfo> orders){ private Map<String, String> getBranchNames(List<OrderInfo> orders){
...@@ -182,10 +182,8 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -182,10 +182,8 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
if(branches.isEmpty()){ if(branches.isEmpty()){
return new HashMap<>(); return new HashMap<>();
} }
LambdaQueryWrapper<OrgBranch> lqw = new LambdaQueryWrapper<>(); List<OrgBranchEntity> records = orgBranchDao.findByBranchIdIn(new ArrayList<>(branches));
lqw.in(OrgBranch::getBranchId, new ArrayList<>(branches)); return records.stream().collect(Collectors.toMap(OrgBranchEntity::getBranchId, OrgBranchEntity::getBranchName));
List<OrgBranch> records = orgBranchMPDao.selectList(lqw);
return records.stream().collect(Collectors.toMap(OrgBranch::getBranchId, OrgBranch::getBranchName));
} }
private List<String> getOrderEngineerNames(String engineerCode, String engineerCodeSub, Map<String,String> engineerNames){ private List<String> getOrderEngineerNames(String engineerCode, String engineerCodeSub, Map<String,String> engineerNames){
......
...@@ -27,16 +27,22 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -27,16 +27,22 @@ public class ScheduleServiceImpl implements ScheduleService {
private OrderInfoMPDao orderInfoMPDao; private OrderInfoMPDao orderInfoMPDao;
@Autowired @Autowired
private OrderInfoDao orderInfoDao;
@Autowired
private OrgTeamMPDao orgTeamMPDao; private OrgTeamMPDao orgTeamMPDao;
@Autowired @Autowired
private OrgTeamEngineerMPDao orgTeamEngineerMPDao; private OrgTeamEngineerDao orgTeamEngineerDao;
@Autowired @Autowired
private OrgGroupMPDao orgGroupMPDao; private OrgGroupMPDao orgGroupMPDao;
@Autowired @Autowired
private EngineerInfoMPDao engineerInfoMPDao; private OrgGroupDao orgGroupDao;
@Autowired
private EngineerInfoDao engineerInfoDao;
@Autowired @Autowired
private SkillInfoMPDao skillInfoMPDao; private SkillInfoMPDao skillInfoMPDao;
...@@ -97,18 +103,19 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -97,18 +103,19 @@ public class ScheduleServiceImpl implements ScheduleService {
} }
// 获取team技术员列表 // 获取team技术员列表
List<OrgTeamEngineer> teamEngineers = this.queryOrgTeamEngineers(t.getTeamId()); List<OrgTeamEngineerEntity> teamEngineers = orgTeamEngineerDao.findAllByTeamId(t.getTeamId());
List<String> engineerCodes = teamEngineers.stream().map(OrgTeamEngineer::getEngineerCode).collect(Collectors.toList()); List<String> engineerCodes = teamEngineers.stream().map(OrgTeamEngineerEntity::getEngineerCode).collect(Collectors.toList());
List<EngineerInfo> engineerInfoList = engineerInfoMPDao.selectByEngineerCodes(engineerCodes); List<EngineerInfoEntity> engineerInfoList = engineerInfoDao.findByEngineerCodeIn(engineerCodes);
Map<String, List<EngineerInfo>> engineers = engineerInfoList.stream().collect(Collectors.groupingBy(EngineerInfo::getEngineerCode)); Map<String, List<EngineerInfoEntity>> engineers = engineerInfoList.stream().collect(
Collectors.groupingBy(EngineerInfoEntity::getEngineerCode));
List<ScheduleOverviewResp.Item> children = new ArrayList<>(); List<ScheduleOverviewResp.Item> children = new ArrayList<>();
for (Map.Entry<String, List<EngineerInfo>> entry : engineers.entrySet()) { for (Map.Entry<String, List<EngineerInfoEntity>> entry : engineers.entrySet()) {
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); EngineerInfoEntity engineerInfo = entry.getValue().get(0);
// 获取技术员已经指派的订单列表 // 获取技术员已经指派的订单列表
List<OrderInfo> orders2 = engineerOrders.getOrDefault(engineerCode, new ArrayList<>()); List<OrderInfo> orders2 = engineerOrders.getOrDefault(engineerCode, new ArrayList<>());
...@@ -144,28 +151,27 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -144,28 +151,27 @@ public class ScheduleServiceImpl implements ScheduleService {
public Result<?> getScheduleEngineerOverview(LocalDate date, String engineerCode) throws BusinessException { public Result<?> getScheduleEngineerOverview(LocalDate date, String engineerCode) throws BusinessException {
// 获取技术员已排班概况 // 获取技术员已排班概况
EngineerInfo engineer = engineerInfoMPDao.getByEngineerCode(engineerCode); EngineerInfoEntity engineer = engineerInfoDao.getByEngineerCode(engineerCode);
if (engineer == null) { if (engineer == null) {
throw new BusinessException("分销员不存在"); throw new BusinessException("分销员不存在");
} }
List<LabelValueDTO> emptyTips = new ArrayList<>(); List<LabelValueDTO> emptyTips = new ArrayList<>();
LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>(); List<OrderInfoEntity> orderAppointments = orderInfoDao.findByEngineerCodeAndDtAndAppointmentStatusIn(
lqw.eq(OrderInfo::getDt, date).eq(OrderInfo::getEngineerCode, engineerCode).in(OrderInfo::getAppointmentStatus, List.of("PRE", "CONFIRM")); engineerCode, date, List.of("PRE", "CONFIRM"));
List<OrderInfo> orderAppointments = orderInfoMPDao.selectList(lqw);
List<TimeLineDTO> timelines = new ArrayList<>(); List<TimeLineDTO> timelines = new ArrayList<>();
for (OrderInfo o : orderAppointments) { for (OrderInfoEntity o : orderAppointments) {
TimeLineDTO item = new TimeLineDTO(); TimeLineDTO item = new TimeLineDTO();
item.setOrderId(o.getOrderId()); item.setOrderId(o.getOrderId());
item.setAppointmentStatus(o.getAppointmentStatus()); item.setAppointmentStatus(o.getAppointmentStatus());
item.setStartTime(TimeUtils.IsoTimestamp2DateTime(o.getPlanStartTime())); item.setStartTime(TimeUtils.IsoLocalDateTime2String(o.getPlanStartTime()));
item.setEndTime(TimeUtils.IsoTimestamp2DateTime(o.getPlanEndTime())); item.setEndTime(TimeUtils.IsoLocalDateTime2String(o.getPlanEndTime()));
item.setTips(emptyTips); item.setTips(emptyTips);
timelines.add(item); timelines.add(item);
} }
Map<String, List<OrderInfo>> statusGroup = orderAppointments.stream().collect(Collectors.groupingBy(OrderInfo::getServiceStatus)); Map<String, List<OrderInfoEntity>> statusGroup = orderAppointments.stream().collect(Collectors.groupingBy(OrderInfoEntity::getServiceStatus));
List<OrderInfo> empty = new ArrayList<>(); List<OrderInfoEntity> empty = new ArrayList<>();
Integer countPending = statusGroup.getOrDefault("INIT", empty).size() + statusGroup.getOrDefault("CONTACTED", empty).size() + statusGroup.getOrDefault("PENDING", empty).size(); Integer countPending = statusGroup.getOrDefault("INIT", empty).size() + statusGroup.getOrDefault("CONTACTED", empty).size() + statusGroup.getOrDefault("PENDING", empty).size();
List<LabelValueDTO> dynamics = new ArrayList<>(); List<LabelValueDTO> dynamics = new ArrayList<>();
...@@ -182,13 +188,13 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -182,13 +188,13 @@ public class ScheduleServiceImpl implements ScheduleService {
dynamics.add(new LabelValueDTO("工作时间", "08:00-18:00")); dynamics.add(new LabelValueDTO("工作时间", "08:00-18:00"));
dynamics.add(new LabelValueDTO("交通工具", "电动车")); dynamics.add(new LabelValueDTO("交通工具", "电动车"));
List<String> orderIds = orderAppointments.stream().map(OrderInfo::getOrderId).collect(Collectors.toList()); List<String> orderIds = orderAppointments.stream().map(OrderInfoEntity::getOrderId).collect(Collectors.toList());
List<OrderInfo> orderRequests = new ArrayList<>(); List<OrderInfoEntity> orderRequests = new ArrayList<>();
if (orderIds != null && !orderIds.isEmpty()) { if (orderIds != null && !orderIds.isEmpty()) {
orderRequests = orderInfoMPDao.selectByDtAndOrderIds(date, orderIds); orderRequests = orderInfoDao.findAllByDtAndOrderIdIn(date, orderIds);
} }
List<ScheduleEngineerOverviewResp.Order> orders = new ArrayList<>(); List<ScheduleEngineerOverviewResp.Order> orders = new ArrayList<>();
for (OrderInfo o : orderRequests) { for (OrderInfoEntity o : orderRequests) {
ScheduleEngineerOverviewResp.Order item = new ScheduleEngineerOverviewResp.Order(); ScheduleEngineerOverviewResp.Order item = new ScheduleEngineerOverviewResp.Order();
item.setOrderId(o.getOrderId()); item.setOrderId(o.getOrderId());
item.setLocation(String.format("%s,%s", o.getX(), o.getY())); item.setLocation(String.format("%s,%s", o.getX(), o.getY()));
...@@ -207,7 +213,7 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -207,7 +213,7 @@ public class ScheduleServiceImpl implements ScheduleService {
} }
String groupName = ""; String groupName = "";
OrgGroup group = orgGroupMPDao.getByGroupId(engineer.getGroupId()); OrgGroupEntity group = orgGroupDao.getByGroupId(engineer.getGroupId());
if (group != null) { if (group != null) {
groupName = group.getGroupName(); groupName = group.getGroupName();
} }
...@@ -240,13 +246,6 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -240,13 +246,6 @@ public class ScheduleServiceImpl implements ScheduleService {
return pg; return pg;
} }
private List<OrgTeamEngineer> queryOrgTeamEngineers(String teamId) {
LambdaQueryWrapper<OrgTeamEngineer> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrgTeamEngineer::getTeamId, teamId);
lqw.eq(OrgTeamEngineer::getStatus, 1);
return orgTeamEngineerMPDao.selectList(lqw);
}
private List<OrderInfo> queryOrderRequests(String teamId, LocalDate date) { private List<OrderInfo> queryOrderRequests(String teamId, LocalDate date) {
LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrderInfo::getDt, date); lqw.eq(OrderInfo::getDt, date);
......
package com.dituhui.pea.order.service.impl; package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dao.SkillGroupMPDao; import com.dituhui.pea.order.dao.SkillGroupDao;
import com.dituhui.pea.order.entity.SkillGroup; import com.dituhui.pea.order.entity.SkillGroupEntity;
import com.dituhui.pea.order.service.SkillGroupCategoryService; import com.dituhui.pea.order.service.SkillGroupCategoryService;
import lombok.Data; import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -17,15 +17,15 @@ import java.util.stream.Collectors; ...@@ -17,15 +17,15 @@ import java.util.stream.Collectors;
public class SkillGroupCategoryServiceImpl implements SkillGroupCategoryService { public class SkillGroupCategoryServiceImpl implements SkillGroupCategoryService {
@Autowired @Autowired
SkillGroupMPDao skillGroupMPDao; SkillGroupDao skillGroupDao;
@Override @Override
public Result<?> querySkillGroupCategoryService() { public Result<?> querySkillGroupCategoryService() {
List<SkillGroup> records = skillGroupMPDao.selectList(null).stream().sorted( List<SkillGroupEntity> records = skillGroupDao.findAll().stream().sorted(
Comparator.comparing(SkillGroup::getCategory)).collect(Collectors.toList()); Comparator.comparing(SkillGroupEntity::getCategory)).collect(Collectors.toList());
List<Category> items = new ArrayList<>(); List<Category> items = new ArrayList<>();
for (SkillGroup r : records) { for (SkillGroupEntity r : records) {
items.add(new Category(r.getSkillGroupCode(), r.getSkillGroup(), r.getCategory())); items.add(new Category(r.getSkillGroupCode(), r.getSkillGroup(), r.getCategory()));
} }
Response res = new Response(); Response res = new Response();
......
...@@ -4,12 +4,12 @@ import cn.hutool.core.date.DateUtil; ...@@ -4,12 +4,12 @@ import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.DateUtils; import com.dituhui.pea.order.common.DateUtils;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.dao.OrderEventDao;
import com.dituhui.pea.order.dao.OrderInfoDao;
import com.dituhui.pea.order.dto.OrderChangeListDTO; import com.dituhui.pea.order.dto.OrderChangeListDTO;
import com.dituhui.pea.order.dto.WorkbenchSummaryResp; import com.dituhui.pea.order.dto.WorkbenchSummaryResp;
import com.dituhui.pea.order.entity.OrderEventEntity; import com.dituhui.pea.order.entity.OrderEventEntity;
import com.dituhui.pea.order.entity.OrderInfoEntity; import com.dituhui.pea.order.entity.OrderInfoEntity;
import com.dituhui.pea.order.entity.OrderInfo;
import com.dituhui.pea.order.service.WorkbenchService; import com.dituhui.pea.order.service.WorkbenchService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -18,8 +18,15 @@ import org.springframework.data.domain.PageRequest; ...@@ -18,8 +18,15 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
...@@ -29,10 +36,10 @@ public class WorkbenchServiceImpl implements WorkbenchService { ...@@ -29,10 +36,10 @@ public class WorkbenchServiceImpl implements WorkbenchService {
private OrderEventDao orderEventDao; private OrderEventDao orderEventDao;
@Autowired @Autowired
private OrderInfoMPDao orderInfoMPDao; private OrderInfoDao orderInfoDao;
@Autowired @Autowired
private OrderInfoDao orderInfoDao; private EntityManager entityManager;
@Override @Override
public Result<?> getOrderChangeList(OrderChangeListDTO.Request reqDTO) { public Result<?> getOrderChangeList(OrderChangeListDTO.Request reqDTO) {
...@@ -90,27 +97,95 @@ public class WorkbenchServiceImpl implements WorkbenchService { ...@@ -90,27 +97,95 @@ public class WorkbenchServiceImpl implements WorkbenchService {
} }
private List<Map<String, Object>> queryCountByAppointmentMethod(String levelType, String levelValue, LocalDate dt) { private List<Map<String, Object>> queryCountByAppointmentMethod(String levelType, String levelValue, LocalDate dt) {
QueryWrapper<OrderInfo> wrapper = new QueryWrapper<>(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
wrapper.select("appointment_method, appointment_status, COUNT(*) as count") CriteriaQuery<Object[]> criteriaQuery = criteriaBuilder.createQuery(Object[].class);
.lambda() Root<OrderInfoEntity> root = criteriaQuery.from(OrderInfoEntity.class);
.eq(OrderInfo::getDt, dt)
.eq(levelType.equals("cluster"), OrderInfo::getOrgClusterId, levelValue) criteriaQuery.multiselect(
.eq(levelType.equals("branch"), OrderInfo::getOrgBranchId, levelValue) root.get("appointmentMethod"),
.eq(levelType.equals("group"), OrderInfo::getOrgGroupId, levelValue) root.get("appointmentStatus"),
.groupBy(OrderInfo::getAppointmentMethod, OrderInfo::getAppointmentStatus); criteriaBuilder.count(root).alias("count")
return orderInfoMPDao.selectMaps(wrapper); );
}
Predicate datePredicate = criteriaBuilder.equal(root.get("dt"), dt);
private List<Map<String, Object>> queryCountByOrderStatus(String levelType, String levelValue, LocalDate dt) { Predicate levelPredicate = null;
QueryWrapper<OrderInfo> wrapper = new QueryWrapper<>();
wrapper.select("service_status, COUNT(*) as count") if ("cluster".equals(levelType)) {
.lambda() levelPredicate = criteriaBuilder.equal(root.get("orgClusterId"), levelValue);
.eq(OrderInfo::getDt, dt) } else if ("branch".equals(levelType)) {
.eq(levelType.equals("cluster"), OrderInfo::getOrgClusterId, levelValue) levelPredicate = criteriaBuilder.equal(root.get("orgBranchId"), levelValue);
.eq(levelType.equals("branch"), OrderInfo::getOrgBranchId, levelValue) } else if ("group".equals(levelType)) {
.eq(levelType.equals("group"), OrderInfo::getOrgGroupId, levelValue) levelPredicate = criteriaBuilder.equal(root.get("orgGroupId"), levelValue);
.groupBy(OrderInfo::getServiceStatus); }
return orderInfoMPDao.selectMaps(wrapper);
if (levelPredicate != null) {
criteriaQuery.where(datePredicate, levelPredicate);
} else {
criteriaQuery.where(datePredicate);
}
criteriaQuery.groupBy(root.get("appointmentMethod"), root.get("appointmentStatus"));
TypedQuery<Object[]> typedQuery = entityManager.createQuery(criteriaQuery);
List<Object[]> results = typedQuery.getResultList();
List<Map<String, Object>> mappedResults = results.stream()
.map(result -> {
Map<String, Object> map = Map.of(
"appointmentMethod", result[0],
"appointmentStatus", result[1],
"count", result[2]
);
return map;
})
.collect(Collectors.toList());
return mappedResults;
}
public List<Map<String, Object>> queryCountByOrderStatus(String levelType, String levelValue, LocalDate dt) {
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Object[]> criteriaQuery = criteriaBuilder.createQuery(Object[].class);
Root<OrderInfoEntity> root = criteriaQuery.from(OrderInfoEntity.class);
criteriaQuery.multiselect(
root.get("serviceStatus"),
criteriaBuilder.count(root).alias("count")
);
Predicate datePredicate = criteriaBuilder.equal(root.get("dt"), dt);
Predicate levelPredicate = null;
if ("cluster".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgClusterId"), levelValue);
} else if ("branch".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgBranchId"), levelValue);
} else if ("group".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgGroupId"), levelValue);
}
if (levelPredicate != null) {
criteriaQuery.where(datePredicate, levelPredicate);
} else {
criteriaQuery.where(datePredicate);
}
criteriaQuery.groupBy(root.get("serviceStatus"));
TypedQuery<Object[]> typedQuery = entityManager.createQuery(criteriaQuery);
List<Object[]> results = typedQuery.getResultList();
List<Map<String, Object>> mappedResults = results.stream()
.map(result -> {
Map<String, Object> map = Map.of(
"serviceStatus", result[0],
"count", result[1]
);
return map;
})
.collect(Collectors.toList());
return mappedResults;
} }
private HashMap<String, Long> transAppointmentMethod(List<Map<String, Object>> results) { private HashMap<String, Long> transAppointmentMethod(List<Map<String, Object>> results) {
...@@ -120,8 +195,8 @@ public class WorkbenchServiceImpl implements WorkbenchService { ...@@ -120,8 +195,8 @@ public class WorkbenchServiceImpl implements WorkbenchService {
Long autoTotal = 0L; Long autoTotal = 0L;
Long total = 0L; Long total = 0L;
for (Map<String, Object> result : results) { for (Map<String, Object> result : results) {
String method = (String) result.get("appointment_method"); String method = (String) result.get("appointmentMethod");
String status = (String) result.get("appointment_status"); String status = (String) result.get("appointmentStatus");
Long count = (long) result.get("count"); Long count = (long) result.get("count");
total += count; total += count;
...@@ -148,7 +223,7 @@ public class WorkbenchServiceImpl implements WorkbenchService { ...@@ -148,7 +223,7 @@ public class WorkbenchServiceImpl implements WorkbenchService {
HashMap<String, Long> map = new HashMap<>(); HashMap<String, Long> map = new HashMap<>();
for (Map<String, Object> result : results) { for (Map<String, Object> result : results) {
String status = (String) result.get("service_status"); String status = (String) result.get("serviceStatus");
Long count = (long) result.get("count"); Long count = (long) result.get("count");
map.put(status, count); map.put(status, count);
} }
...@@ -212,12 +287,10 @@ public class WorkbenchServiceImpl implements WorkbenchService { ...@@ -212,12 +287,10 @@ public class WorkbenchServiceImpl implements WorkbenchService {
return items; return items;
} }
private <T> HashMap<String, List<T>> packParams(String key, T ...values) { private <T> HashMap<String, List<T>> packParams(String key, T... values) {
HashMap<String, List<T>> map = new HashMap<>(); HashMap<String, List<T>> map = new HashMap<>();
List<T> value = new ArrayList<>(); List<T> value = new ArrayList<>();
for(T v: values){ Collections.addAll(value, values);
value.add(v);
}
map.put(key, value); map.put(key, value);
return map; return map;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!