Commit 784096b4 by 丁伟峰

Merge branch 'feat-dingwf-mvp616' into develop

# Conflicts:
#	project-order/src/main/resources/application.yaml
2 parents b9884613 9eb4f183
package com.alibaba.cloud.integration.order.controller;
import com.alibaba.cloud.integration.common.BusinessException;
import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dto.WorkbenchOrderChangeListReqDTO;
import com.alibaba.cloud.integration.order.service.WorkbenchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
public class WorkbenchController {
@Autowired
WorkbenchService workbenchService;
@PostMapping("/workbench/serviceOrder/change/list")
public Result<?> orderChangeList(@Validated @RequestBody WorkbenchOrderChangeListReqDTO reqDTO) {
Result<?> res = null;
try {
res = workbenchService.getOrderChangeList(reqDTO.getLevelType(), reqDTO.getLevelValue(), reqDTO.getPage(), reqDTO.getSize());
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
}
package com.alibaba.cloud.integration.order.dao;
import com.alibaba.cloud.integration.order.entity.OrderChangeEntity;
import org.hibernate.annotations.Where;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
@Repository
@Where(clause = "status = 1")
public interface OrderChangeDao extends JpaRepository<OrderChangeEntity, Integer> {
@Query("select a from OrderChangeEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgClusterId = :clusterId")
Page<OrderChangeEntity> findAllByClusterId(Pageable pageable, String clusterId);
@Query("select a from OrderChangeEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgBranchId = :branchId")
Page<OrderChangeEntity> findAllByBranchId(Pageable pageable, String branchId);
@Query("select a from OrderChangeEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgGroupId = :groupId")
Page<OrderChangeEntity> findAllByGroupId(Pageable pageable, String groupId);
}
......@@ -2,6 +2,10 @@ package com.alibaba.cloud.integration.order.dao;
import com.alibaba.cloud.integration.order.entity.OrderRequestEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface OrderRequestDao extends JpaRepository <OrderRequestEntity, Long> {
OrderRequestEntity getByOrderId(String orderId);
}
package com.alibaba.cloud.integration.order.dto;
@lombok.Data
public class WorkbenchOrderChangeListReqDTO {
/**
* 查询范围:root/cluster/branch/group
*/
private String levelType;
/**
* levelType对应的id值
*/
private String levelValue;
private int page;
private int size;
/**
* 排序
*/
private String sort;
}
package com.alibaba.cloud.integration.order.dto;
import lombok.experimental.Accessors;
import java.util.List;
@lombok.Data
@Accessors(chain = true)
public class WorkbenchOrderChangeListRespDTO {
private List<?> content;
private long pageCurrent;
private long pages;
private long pageSize;
private long total;
@lombok.Data
@Accessors(chain = true)
public static class Content {
/**
* 客户姓名
*/
private String customerName;
/**
* 描述
*/
private String description;
/**
* 备注
*/
private String memo;
/**
* 操作员
*/
private String operator;
/**
* 服务单号
*/
private String orderId;
/**
* 更新时间
*/
private String updateTime;
}
}
package com.alibaba.cloud.integration.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.util.Date;
@Entity
@Data
@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 Date createTime;
/**
* 创建时间
*/
private Date updateTime;
public OrderChangeEntity() {}
}
......@@ -20,9 +20,6 @@ import com.alibaba.cloud.integration.common.BusinessException;
import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dto.OrderCreateReqDTO;
/**
* @author TrevorLink
*/
public interface OrderService {
Result<?> initParameter();
......
package com.alibaba.cloud.integration.order.service;
import com.alibaba.cloud.integration.common.Result;
public interface WorkbenchService {
Result<?> getOrderChangeList(String levelType, String levelId, int page, int pageSize);
}
package com.alibaba.cloud.integration.order.service.impl;
import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dao.OrderChangeDao;
import com.alibaba.cloud.integration.order.dao.OrderRequestDao;
import com.alibaba.cloud.integration.order.dto.WorkbenchOrderChangeListRespDTO;
import com.alibaba.cloud.integration.order.entity.OrderChangeEntity;
import com.alibaba.cloud.integration.order.entity.OrderRequestEntity;
import com.alibaba.cloud.integration.order.service.WorkbenchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Pageable;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Service
public class WorkbenchServiceImpl implements WorkbenchService {
@Autowired
OrderChangeDao orderChangeDao;
@Autowired
OrderRequestDao orderRequestDao;
@Override
public Result<?> getOrderChangeList(String levelType, String levelId, int page, int pageSize) {
Pageable pageable = PageRequest.of(page - 1, pageSize);
Page<?> changes;
if ("cluster".equals(levelType)) {
changes = orderChangeDao.findAllByClusterId(pageable, levelId);
} else if ("branch".equals(levelType)) {
changes = orderChangeDao.findAllByBranchId(pageable, levelId);
} else {
changes = orderChangeDao.findAllByGroupId(pageable, levelId);
}
List<WorkbenchOrderChangeListRespDTO.Content> contents = new ArrayList<>();
for (Object e1 : changes.getContent()) {
OrderChangeEntity e = (OrderChangeEntity) e1;
WorkbenchOrderChangeListRespDTO.Content content = new WorkbenchOrderChangeListRespDTO.Content();
OrderRequestEntity orderRequestEntity = orderRequestDao.getByOrderId(e.getOrderId());
content.setOrderId(e.getOrderId())
.setCustomerName(orderRequestEntity.getName())
.setOperator(e.getOperator())
.setDescription(e.getContent())
.setMemo(e.getMemo())
.setUpdateTime(e.getUpdateTime().toString());
contents.add(content);
}
WorkbenchOrderChangeListRespDTO resp = new WorkbenchOrderChangeListRespDTO();
resp.setTotal(changes.getTotalElements())
.setPages(changes.getTotalPages())
.setPageSize(changes.getSize())
.setContent(contents);
return Result.success(resp);
}
}
......@@ -22,9 +22,9 @@ spring:
# - optional:nacos:datasource-config.yaml
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://119.3.12.237:3306/saas_aftersale_test?serverTimezone=UTC
url: jdbc:mysql://10.10.0.171:52003/saas_aftersale_test?serverTimezone=UTC
username: root
password: 123456
password: dituhui123456
type: com.alibaba.druid.pool.DruidDataSource
seata:
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!