修复bug
This commit is contained in:
parent
7b67196eff
commit
d771a5b068
|
@ -0,0 +1,48 @@
|
|||
package com.chint.application.dtos.response;
|
||||
|
||||
|
||||
import com.chint.domain.aggregates.order.Location;
|
||||
import com.chint.domain.aggregates.order.OrderDetail;
|
||||
import com.chint.domain.value_object.enums.CurrencyType;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class LegRes {
|
||||
@Id
|
||||
private Long legId;
|
||||
|
||||
private String legNo;
|
||||
|
||||
private Integer legType;
|
||||
|
||||
private LocalDateTime startTime;
|
||||
|
||||
private LocalDateTime endTime;
|
||||
|
||||
private String estimateAmount;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private LocationRes originLocation;
|
||||
|
||||
private LocationRes destinationLocation;
|
||||
|
||||
@Transient
|
||||
private String amount;
|
||||
@Transient
|
||||
private String legTypeName;
|
||||
@Transient
|
||||
private Integer legStatus;
|
||||
@Transient
|
||||
private String legStatusName;
|
||||
@Transient
|
||||
private CurrencyType currencyType;
|
||||
@Transient
|
||||
private List<OrderDetail> orderDetails; //这个属性不做持久化保存 ,根据下单事件进行获取
|
||||
}
|
|
@ -1,12 +1,17 @@
|
|||
package com.chint.application.dtos.response;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chint.domain.aggregates.order.Location;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
|
||||
@Data
|
||||
public class LocationRes {
|
||||
@Id
|
||||
private Long locationId;
|
||||
private String locationName;
|
||||
|
||||
public static LocationRes copyFrom(Location location) {
|
||||
return BeanUtil.copyProperties(location, LocationRes.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package com.chint.application.dtos.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OrderDetailRes {
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.chint.application.dtos.response;
|
||||
|
||||
|
||||
import com.chint.domain.aggregates.order.ApproveOrderNo;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Embedded;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class RouteOrderPageRes {
|
||||
@Id
|
||||
@Column("route_id")
|
||||
private Long routeId;
|
||||
|
||||
//差旅订单单号
|
||||
private String routeOrderNo;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime bookingTime;
|
||||
private Long userId;
|
||||
//审批订单号
|
||||
@Embedded.Nullable
|
||||
private ApproveOrderNo approveOrderNo;
|
||||
//差旅订单总价值
|
||||
|
||||
private String amount;
|
||||
private String estimateAmount;
|
||||
private Integer orderStatus;
|
||||
private String approvalStatus;
|
||||
private String orderStatusName;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
private String supplierName;
|
||||
private String supplierCNName;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.chint.application.dtos.response;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
|
||||
@Data
|
||||
public class UserRes {
|
||||
@Id
|
||||
private Long userId;
|
||||
private Long employeeNo;
|
||||
private Integer employeeLevel;
|
||||
private String name;
|
||||
private String email;
|
||||
private String gender;
|
||||
private String phoneNumber;
|
||||
private String password;
|
||||
@Transient
|
||||
private String rankCode;
|
||||
@Transient
|
||||
private String companyCode;
|
||||
@Transient
|
||||
private String workStatus;
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package com.chint.application.out;
|
||||
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chint.application.dtos.response.RouteOrderPageRes;
|
||||
import com.chint.application.dtos.trip.TripCallback;
|
||||
import com.chint.application.queryies.OrderQuery;
|
||||
import com.chint.domain.aggregates.order.RouteOrder;
|
||||
|
@ -17,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.chint.infrastructure.constant.Constant.SUCCESS;
|
||||
|
||||
@RestController
|
||||
|
@ -43,8 +47,14 @@ public class OrderOutController {
|
|||
|
||||
@ApiOperation("分页查询行程规划订单")
|
||||
@PostMapping("/pageQuery")
|
||||
public Result<PageResult<RouteOrder>> pageQuery(@RequestBody OrderQueryData queryData) {
|
||||
return Result.Success(SUCCESS, orderQuery.pageQuery(queryData));
|
||||
public Result<PageResult<RouteOrderPageRes>> pageQuery(@RequestBody OrderQueryData queryData) {
|
||||
PageResult<RouteOrder> routeOrderPageResult = orderQuery.pageQuery(queryData);
|
||||
List<RouteOrderPageRes> routeOrderPageRes = routeOrderPageResult
|
||||
.getRecords()
|
||||
.stream()
|
||||
.map(routeOrder -> BeanUtil.copyProperties(routeOrder, RouteOrderPageRes.class))
|
||||
.toList();
|
||||
return Result.Success(SUCCESS, new PageResult<>(routeOrderPageResult.getTotal(), routeOrderPageRes));
|
||||
}
|
||||
|
||||
@ApiOperation("查询火车估算价格")
|
||||
|
|
|
@ -1,29 +1,25 @@
|
|||
package com.chint.application.out;
|
||||
|
||||
import com.chint.domain.repository.UserRepository;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chint.application.dtos.response.UserRes;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.infrastructure.util.BaseContext;
|
||||
import com.chint.infrastructure.util.Result;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static com.chint.infrastructure.constant.Constant.SUCCESS;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/users")
|
||||
public class UserController {
|
||||
// @Autowired
|
||||
// private final UserRepository userRepository;
|
||||
//
|
||||
//
|
||||
//
|
||||
// @ApiOperation("根据Id查询用户信息")
|
||||
// @PostMapping("/query")
|
||||
// public Result<UserVO> getUserById(@RequestBody long id) {
|
||||
// UserVO user = userService.findById(id);
|
||||
// if (user != null) {
|
||||
// return new Result<UserVO>(SUCCESS, user);
|
||||
// } else {
|
||||
// return Result.error(FAILURE);
|
||||
// }
|
||||
// }
|
||||
|
||||
@ApiOperation("根据Id查询用户信息")
|
||||
@PostMapping("/query")
|
||||
public Result<UserRes> getUserByEmployeeNo() {
|
||||
User currentUser = BaseContext.getCurrentUser();
|
||||
return Result.Success(SUCCESS, BeanUtil.copyProperties(currentUser, UserRes.class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ public class Leg {
|
|||
|
||||
private Integer legType;
|
||||
|
||||
|
||||
private LocalDateTime startTime;
|
||||
|
||||
private LocalDateTime endTime;
|
||||
|
|
|
@ -39,7 +39,7 @@ public class RouteOrder extends BaseEntity {
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime bookingTime;
|
||||
private Long userId;
|
||||
|
||||
private String supplierName;
|
||||
//审批订单号
|
||||
@Embedded.Nullable
|
||||
private ApproveOrderNo approveOrderNo;
|
||||
|
@ -58,8 +58,9 @@ public class RouteOrder extends BaseEntity {
|
|||
private String startTime;
|
||||
@Transient
|
||||
private String endTime;
|
||||
@Transient
|
||||
private String supplierCNName;
|
||||
|
||||
private String supplierName;
|
||||
|
||||
@MappedCollection(idColumn = "route_id", keyColumn = "route_order_key")
|
||||
private List<Leg> legItems;
|
||||
|
@ -119,7 +120,7 @@ public class RouteOrder extends BaseEntity {
|
|||
}
|
||||
|
||||
public RouteOrder addOrderDetail(OrderDetail orderDetail) {
|
||||
if(this.orderDetails == null){
|
||||
if (this.orderDetails == null) {
|
||||
this.orderDetails = new ArrayList<>();
|
||||
}
|
||||
this.orderDetails.add(orderDetail);
|
||||
|
@ -127,14 +128,14 @@ public class RouteOrder extends BaseEntity {
|
|||
}
|
||||
|
||||
public RouteOrder addApprovalEvent(ApprovalEvent approvalEvent) {
|
||||
if(this.approveEvents == null){
|
||||
if (this.approveEvents == null) {
|
||||
this.approveEvents = new ArrayList<>();
|
||||
}
|
||||
this.approveEvents.add(approvalEvent);
|
||||
return this;
|
||||
}
|
||||
|
||||
private RouteOrder reloadApprovalStatus(){
|
||||
private RouteOrder reloadApprovalStatus() {
|
||||
if (this.approveEvents != null && !this.approveEvents.isEmpty()) {
|
||||
this.approveEvents.stream()
|
||||
.max(Comparator.comparingLong(ApprovalEvent::getApprovalEventId))
|
||||
|
@ -161,7 +162,14 @@ public class RouteOrder extends BaseEntity {
|
|||
.orElse(KEEP_TWO_DECIMAL_ZERO);
|
||||
this.updateStatus();
|
||||
this.orderStatusName = translateOrderStatus(this.orderStatus);
|
||||
|
||||
//根据节点时间更新订单时间
|
||||
reloadTime();
|
||||
|
||||
//更新供应商中文名称
|
||||
if(this.supplierName != null){
|
||||
this.supplierCNName = translateOrderSupplierName(this.supplierName);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -213,7 +221,10 @@ public class RouteOrder extends BaseEntity {
|
|||
}
|
||||
|
||||
public void updateStatus() {
|
||||
if (allItemsInStatus(4)) {
|
||||
// 首先检查所有项是否都为-1状态
|
||||
if (allItemsInStatus(-1)) {
|
||||
this.orderStatus = -1;
|
||||
} else if (allItemsInStatus(4)) {
|
||||
this.orderStatus = 4;
|
||||
} else if (allItemsInStatus(3)) {
|
||||
this.orderStatus = 3;
|
||||
|
@ -221,19 +232,17 @@ public class RouteOrder extends BaseEntity {
|
|||
this.orderStatus = 2;
|
||||
} else if (allItemsInStatus(1)) {
|
||||
this.orderStatus = 1;
|
||||
} else if (allItemsInStatus(-1)) {
|
||||
this.orderStatus = -1;
|
||||
} else {
|
||||
this.orderStatus = 0; // 或其他适当的默认状态
|
||||
}
|
||||
}
|
||||
|
||||
private boolean allItemsInStatus(int targetStatus) {
|
||||
if (this.getLegItems().isEmpty()) {
|
||||
if (this.legItems.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
for (Leg item : this.legItems) {
|
||||
if (item.getLegStatus() < targetStatus) {
|
||||
if (item.getLegStatus() != targetStatus) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -266,4 +275,12 @@ public class RouteOrder extends BaseEntity {
|
|||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private String translateOrderSupplierName(String supplierName) {
|
||||
return switch (supplierName) {
|
||||
case SUPPLIER_L_Y -> SUPPLIER_L_Y_CN_NAME;
|
||||
case SUPPLIER_C_TRIP -> SUPPLIER_C_TRIP_CN_NAME;
|
||||
default -> "未知供应商";
|
||||
};
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.chint.domain.aggregates.user;
|
|||
|
||||
import com.auth0.jwt.interfaces.Claim;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import com.chint.domain.aggregates.base.BaseEntity;
|
||||
import com.chint.domain.value_object.UserLoginParam;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
|
@ -155,7 +155,9 @@ public class Constant {
|
|||
public static final String TRAVEL_RANK_BASE_URL = "http://10.10.14.178:8080";
|
||||
public static final String TRAVEL_RANK_PATH = "/fssc/queryBill/queryTravelLevelByRank";
|
||||
public static final String SUPPLIER_C_TRIP = "CTrip";
|
||||
public static final String SUPPLIER_C_TRIP_CN_NAME = "携程";
|
||||
public static final String SUPPLIER_L_Y = "LY";
|
||||
public static final String SUPPLIER_L_Y_CN_NAME = "同程";
|
||||
|
||||
// 携程
|
||||
public static final String C_TRIP_BASE_URL = "https://ct.ctrip.com";
|
||||
|
|
|
@ -6,6 +6,9 @@ package com.chint.interfaces.rest.user;
|
|||
//import com.chint.dc.api.dto.DataCenterOption;
|
||||
//import com.chint.dc.api.service.DataCenterService;
|
||||
|
||||
import com.chint.dc.api.DataCenterResult;
|
||||
import com.chint.dc.api.dto.DataCenterOption;
|
||||
import com.chint.dc.api.service.DataCenterService;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.interfaces.rest.base.PostRequest;
|
||||
import com.chint.interfaces.rest.user.dto.*;
|
||||
|
@ -41,14 +44,14 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
}
|
||||
|
||||
private User loadSFAndRank(User user) {
|
||||
// List<UserDataDTO> loadSFInfo = loadSFInfo(user);
|
||||
// String custManaLevel = loadSFInfo.get(0).getCust_manaLevel();
|
||||
// String level = custManaLevel != null ? custManaLevel : "M0";
|
||||
// if (level.contains("R")) {
|
||||
// level = level.substring(0, level.length() - 3) + "M0";
|
||||
// }
|
||||
// TravelRankDTO loadTravelRank = loadTravelRank(new TravelRankParam(level));
|
||||
// user.setRankCode(loadTravelRank.getLEVEL_MAPPING_CODE());
|
||||
List<UserDataDTO> loadSFInfo = loadSFInfo(user);
|
||||
String custManaLevel = loadSFInfo.get(0).getCust_manaLevel();
|
||||
String level = custManaLevel != null ? custManaLevel : "M0";
|
||||
if (level.contains("R")) {
|
||||
level = level.substring(0, level.length() - 3) + "M0";
|
||||
}
|
||||
TravelRankDTO loadTravelRank = loadTravelRank(new TravelRankParam(level));
|
||||
user.setRankCode(loadTravelRank.getLEVEL_MAPPING_CODE());
|
||||
user.setRankCode("测试职级");
|
||||
return user;
|
||||
}
|
||||
|
@ -68,33 +71,33 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
}
|
||||
|
||||
private List<UserDataDTO> loadSFInfo(User user) {
|
||||
// Gson gson = new Gson();
|
||||
// AccessKeyDTO akSkLoad = akSkLoad();
|
||||
// DataCenterOption option = new DataCenterOption();
|
||||
// option.setSk(akSkLoad.sk);
|
||||
// option.setAk(akSkLoad.ak);
|
||||
// option.setUrl(OPENAI_BASE_URL);
|
||||
// DataCenterService dataCenterService = new DataCenterService(option);
|
||||
// LinkedHashMap map = new LinkedHashMap<String, Object>();
|
||||
// map.put("LoginUsername", user.getEmployeeNo().toString());
|
||||
// map.put("start", 0);
|
||||
// map.put("pageSize", 1);
|
||||
// DataCenterResult result = dataCenterService.post(USER_DATA_PATH, map);
|
||||
// Type type = new TypeToken<List<UserDataDTO>>() {
|
||||
// }.getType();
|
||||
// if (result.getData() != null) {
|
||||
// List<UserDataDTO> fromJson = gson.fromJson(result.getData().toString(), type);
|
||||
// UserDataDTO userDataDTO = fromJson.get(0);
|
||||
// user.setCompanyCode(userDataDTO.getCompany());
|
||||
// user.setWorkStatus(userDataDTO.getStatus());
|
||||
// user.setGender(userDataDTO.getGender());
|
||||
// user.setName(userDataDTO.getUname());
|
||||
// user.setPhoneNumber(userDataDTO.getMobilePhone());
|
||||
// return fromJson;
|
||||
// } else {
|
||||
// throw new RuntimeException("用户数据不存在");
|
||||
// }
|
||||
return null;
|
||||
Gson gson = new Gson();
|
||||
AccessKeyDTO akSkLoad = akSkLoad();
|
||||
DataCenterOption option = new DataCenterOption();
|
||||
option.setSk(akSkLoad.sk);
|
||||
option.setAk(akSkLoad.ak);
|
||||
option.setUrl(OPENAI_BASE_URL);
|
||||
DataCenterService dataCenterService = new DataCenterService(option);
|
||||
LinkedHashMap map = new LinkedHashMap<String, Object>();
|
||||
map.put("LoginUsername", user.getEmployeeNo().toString());
|
||||
map.put("start", 0);
|
||||
map.put("pageSize", 1);
|
||||
DataCenterResult result = dataCenterService.post(USER_DATA_PATH, map);
|
||||
Type type = new TypeToken<List<UserDataDTO>>() {
|
||||
}.getType();
|
||||
if (result.getData() != null) {
|
||||
List<UserDataDTO> fromJson = gson.fromJson(result.getData().toString(), type);
|
||||
UserDataDTO userDataDTO = fromJson.get(0);
|
||||
user.setCompanyCode(userDataDTO.getCompany());
|
||||
user.setWorkStatus(userDataDTO.getStatus());
|
||||
user.setGender(userDataDTO.getGender());
|
||||
user.setName(userDataDTO.getUname());
|
||||
user.setPhoneNumber(userDataDTO.getMobilePhone());
|
||||
return fromJson;
|
||||
} else {
|
||||
throw new RuntimeException("用户数据不存在");
|
||||
}
|
||||
// return null;
|
||||
}
|
||||
|
||||
private TravelRankDTO loadTravelRank(TravelRankParam travelRankParam) {
|
||||
|
|
|
@ -31,7 +31,7 @@ class RouteApplicationTests {
|
|||
|
||||
@Test
|
||||
void loginSign() {
|
||||
String sfno = "230615020";
|
||||
String sfno = "231116009";
|
||||
String syscode = "abc";
|
||||
String billcode = "KK12321412323";
|
||||
String sec = "Superdandan";
|
||||
|
|
Loading…
Reference in New Issue