Commit ba10f664 by 丁伟峰

清理order_change

1 parent 86528141
......@@ -7,18 +7,18 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.time.LocalDate;
import java.util.Date;
@Repository
public interface OrderEventDao extends JpaRepository<OrderEventEntity, Integer> {
@Query("select a from OrderEventEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgClusterId = :clusterId and DATE(a.createTime) = :date")
Page<OrderEventEntity> findAllByClusterId(String clusterId, LocalDate date, Pageable pageable);
Page<OrderEventEntity> findAllByClusterId(String clusterId, Date date, Pageable pageable);
@Query("select a from OrderEventEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgBranchId = :branchId and DATE(a.createTime) = :date")
Page<OrderEventEntity> findAllByBranchId(String branchId, LocalDate date, Pageable pageable);
Page<OrderEventEntity> findAllByBranchId(String branchId, Date date, Pageable pageable);
@Query("select a from OrderEventEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgGroupId = :groupId and DATE(a.createTime) = :date")
Page<OrderEventEntity> findAllByGroupId(String groupId, LocalDate date, Pageable pageable);
Page<OrderEventEntity> findAllByGroupId(String groupId, Date date, Pageable pageable);
}
package com.dituhui.pea.order.entity;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;
@Entity
@Data
@Accessors(chain = true)
@Table(name="order_change")
public class OrderChangeEntity {
/**
* 自增id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 工单id
*/
private String orderId;
/**
* 子工单id
*/
private String suborderId;
/**
* 变更发起源(bean/pea-web/pea-backend)
*/
private String source;
/**
* 发起人
*/
private String operator;
/**
* 操作内容,指派,规划路线
*/
private String content;
/**
* 变更前的信息
*/
private String contentOld;
/**
* 备注
*/
private String memo;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 创建时间
*/
private LocalDateTime updateTime;
public OrderChangeEntity() {}
}
package com.dituhui.pea.order.service.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.DateUtils;
import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.OrderChangeListDTO;
import com.dituhui.pea.order.dto.WorkbenchSummaryResp;
import com.dituhui.pea.order.entity.OrderChangeEntity;
import com.dituhui.pea.order.entity.OrderEventEntity;
import com.dituhui.pea.order.entity.OrderRequest;
import com.dituhui.pea.order.entity.OrderRequestEntity;
import com.dituhui.pea.order.service.WorkbenchService;
......@@ -18,13 +18,7 @@ import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.dituhui.pea.order.config.OrderConfig.PATTERN_DATE;
import java.util.*;
@Slf4j
@Service
......@@ -51,34 +45,33 @@ public class WorkbenchServiceImpl implements WorkbenchService {
@Override
public Result<?> getOrderChangeList(OrderChangeListDTO.Request reqDTO) {
Pageable pageable = PageRequest.of(reqDTO.getPage() - 1, reqDTO.getSize());
Page<?> changes;
Page<OrderEventEntity> page;
String levelType = reqDTO.getLevelType();
String levelValue = reqDTO.getLevelValue();
LocalDate date = LocalDate.parse(reqDTO.getDate());
Date date = DateUtil.parse(reqDTO.getDate());
if ("cluster".equals(levelType)) {
changes = orderEventDao.findAllByClusterId(levelValue, date, pageable);
page = orderEventDao.findAllByClusterId(levelValue, date, pageable);
} else if ("branch".equals(levelType)) {
changes = orderEventDao.findAllByBranchId(levelValue, date, pageable);
page = orderEventDao.findAllByBranchId(levelValue, date, pageable);
} else {
changes = orderEventDao.findAllByGroupId(levelValue, date, pageable);
page = orderEventDao.findAllByGroupId(levelValue, date, pageable);
}
List<OrderChangeListDTO.Content> contents = new ArrayList<>();
for (Object e1 : changes.getContent()) {
OrderChangeEntity e = (OrderChangeEntity) e1;
for (OrderEventEntity entity : page.getContent()) {
OrderChangeListDTO.Content content = new OrderChangeListDTO.Content();
OrderRequestEntity orderRequestEntity = orderRequestDao.getByOrderId(e.getOrderId());
content.setOrderId(e.getOrderId())
OrderRequestEntity orderRequestEntity = orderRequestDao.getByOrderId(entity.getOrderId());
content.setOrderId(entity.getOrderId())
.setCustomerName(orderRequestEntity.getName())
.setOperator(e.getOperator())
.setDescription(e.getContent())
.setMemo(e.getMemo())
.setUpdateTime(e.getUpdateTime());
.setOperator(entity.getOperator())
.setDescription(entity.getDescription())
.setMemo(entity.getMemo())
.setUpdateTime(entity.getUpdateTime());
contents.add(content);
}
OrderChangeListDTO.Result rs = new OrderChangeListDTO.Result();
rs.setTotal(changes.getTotalElements())
.setPages(changes.getTotalPages())
.setPageSize(changes.getSize())
rs.setTotal(page.getTotalElements())
.setPages(page.getTotalPages())
.setPageSize(page.getSize())
.setContent(contents);
return Result.success(rs);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!