完成离职人员关卡
This commit is contained in:
parent
487055cbd2
commit
266889852b
|
@ -0,0 +1,18 @@
|
|||
package com.chint.application.commands;
|
||||
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UserDisabledCommand extends Command {
|
||||
private User user;
|
||||
private List<User> userList;
|
||||
|
||||
public UserDisabledCommand user(User user) {
|
||||
this.user = user;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@ import com.chint.infrastructure.util.PageResult;
|
|||
import com.chint.infrastructure.util.Result;
|
||||
import com.chint.interfaces.rest.ctrip.order.CTripOrderRecordAutoSave;
|
||||
import com.chint.interfaces.rest.ly.reconciliation.dto.PageInfo;
|
||||
import com.chint.interfaces.rest.user.BatchUserWorker;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -38,6 +39,18 @@ public class AutoWorkController {
|
|||
@Autowired
|
||||
private LyStatementOrder lyStatementOrder;
|
||||
|
||||
@Autowired
|
||||
private BatchUserWorker batchUserWorker;
|
||||
|
||||
|
||||
@ApiOperation("用户状态检查,离职用户将关闭开卡")
|
||||
@PostMapping("/user/status/check")
|
||||
public Result<String> autoCheckUserStatus(){
|
||||
batchUserWorker.checkUserStatus();
|
||||
return Result.Success(SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@ApiOperation("自动拉取昨天的流水号,每天晚上8点执行")
|
||||
@PostMapping("/cTrip/record/save")
|
||||
|
|
|
@ -150,11 +150,9 @@ public class LoginController {
|
|||
@PostMapping("/AN/login/sso")
|
||||
public Result<UserLoginResult> ANLoginSSO(@RequestBody UserLoginParam userLoginParam) {
|
||||
String employeeNo = anFeiShuLoginStrategy.login(userLoginParam.getCode());
|
||||
|
||||
userLoginParam.setSfno(employeeNo);
|
||||
UserLoginResult userLoginResult = authenticateService
|
||||
.authenticateEmployeeNo(userLoginParam);
|
||||
|
||||
//异步执行更新用户信息到同程
|
||||
User currentUser = BaseContext.getCurrentUser();
|
||||
loginEventBoarder(currentUser);
|
||||
|
@ -163,7 +161,6 @@ public class LoginController {
|
|||
|
||||
|
||||
private void loginEventBoarder(User user) {
|
||||
Command.of(UserSFCommand.class).user(user).sendToQueue();
|
||||
Command.of(UserLoginCommand.class).user(user).sendToQueue();
|
||||
user.setSyncTime(LocalDateTime.now());
|
||||
userRepository.save(user);
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.chint.domain.aggregates.user.UserDepartmentInfo;
|
|||
import com.chint.domain.repository.UserRepository;
|
||||
import com.chint.infrastructure.util.BaseContext;
|
||||
import com.chint.infrastructure.util.Result;
|
||||
import com.chint.interfaces.rest.user.PushUser;
|
||||
import com.chint.interfaces.rest.user.BatchUserWorker;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -22,7 +22,7 @@ import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
|
|||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private PushUser pushUser;
|
||||
private BatchUserWorker pushUser;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
|
|
@ -57,6 +57,7 @@ public class User implements Serializable {
|
|||
private String phoneNumber;
|
||||
private String password;
|
||||
private LocalDateTime syncTime;
|
||||
private Integer status;
|
||||
@Transient
|
||||
private String manaLevel;
|
||||
@Transient
|
||||
|
@ -82,6 +83,12 @@ public class User implements Serializable {
|
|||
if (this.userDepartmentInfoList == null || this.userDepartmentInfoList.isEmpty()) {
|
||||
//如果发现 用户的 部门信息为空, 那么直接调用 sf查询
|
||||
Command.of(UserSFCommand.class).user(this).sendToQueue();
|
||||
} else {
|
||||
for (UserDepartmentInfo userDepartmentInfo : userDepartmentInfoList) {
|
||||
if (userDepartmentInfo.getUname() == null) {
|
||||
Command.of(UserSFCommand.class).user(this).sendToQueue();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (userDepartmentInfoList == null) {
|
||||
throw new NotFoundException(SF_DATA_NOT_EXIST);
|
||||
|
@ -116,7 +123,6 @@ public class User implements Serializable {
|
|||
UserDepartmentInfo fallbackDeptInfo = getFallbackDeptInfo();
|
||||
loadInfoFromDeptInfo(fallbackDeptInfo);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -392,9 +392,6 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
|
|||
hotelOrderDetail = new HotelOrderDetail();
|
||||
}
|
||||
|
||||
|
||||
// hotelOrderDetail.setSupplier(SUPPLIER_C_TRIP_EXTENSION_NAME);
|
||||
|
||||
hotelOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
|
||||
|
||||
if (routeOrder != null) {
|
||||
|
@ -421,7 +418,10 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
|
|||
user = userRepository.findByUserEmployeeNo(EmployeeNo);
|
||||
|
||||
}
|
||||
Optional<OrderDetail> first = routeOrder.getOrderDetails().stream().filter(orderDetail -> orderDetail.getOrderNo().equals(orderNo)).findFirst();
|
||||
Optional<OrderDetail> first = routeOrder
|
||||
.getOrderDetails()
|
||||
.stream()
|
||||
.filter(orderDetail -> orderDetail.getOrderNo().equals(orderNo)).findFirst();
|
||||
first.ifPresent(orderDetail -> {
|
||||
OrderEvent lastEvent = orderDetail.getLastEvent();
|
||||
if (lastEvent != null) {
|
||||
|
@ -546,6 +546,8 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
|
|||
|
||||
@Override
|
||||
public HotelOrderDetail updateHotelOrderDetailData(HotelOrderDetail hotelOrderDetail, Object hotelOrderInfo) {
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,20 @@ package com.chint.domain.repository;
|
|||
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserRepository {
|
||||
User findById(Long id);
|
||||
|
||||
User findByUserEmployeeNo(String employeeNo);
|
||||
|
||||
User save(User user);
|
||||
|
||||
void saveAll(List<User> userList);
|
||||
|
||||
List<User> findAll();
|
||||
|
||||
List<User> findByStatus(Integer status);
|
||||
|
||||
List<User> findByStatusIsNull();
|
||||
}
|
|
@ -16,6 +16,7 @@ import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
|||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcLegRepository;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository;
|
||||
import com.chint.infrastructure.util.DateTimeUtil;
|
||||
import com.chint.interfaces.rest.bpm.BPMParamFactory;
|
||||
import com.chint.interfaces.rest.bpm.BPMRequest;
|
||||
import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest;
|
||||
|
@ -211,7 +212,7 @@ public class OrderDomainService {
|
|||
if (!orderEventType.equals(ORDER_EVENT_ETA) && orderDetail.getProductType().equals(LEG_TYPE_AIRPLANE)) {
|
||||
cTripFlightRefundAndChangeOrder(orderDetail.getOrderNo());
|
||||
}
|
||||
if (!orderEventType.equals(ORDER_EVENT_ETA) && orderDetail.getProductType().equals(LEG_TYPE_HOTEL)) {
|
||||
if (orderDetail.getProductType().equals(LEG_TYPE_HOTEL)) {
|
||||
cTripHotelRefundAndChangeOrder(orderDetail.getOrderNo());
|
||||
}
|
||||
if (!orderEventType.equals(ORDER_EVENT_ETA) && orderDetail.getProductType().equals(LEG_TYPE_TAXI)) {
|
||||
|
@ -309,17 +310,16 @@ public class OrderDomainService {
|
|||
|
||||
private void cTripHotelRefundAndChangeOrder(String orderNo) {
|
||||
SearchOrderResponse response = cTripOrderSearchRequest.searchOrderResponseByOrderId(orderNo);
|
||||
HotelOrderInfoEntity flightOrderInfoEntity = response.getItineraryList().get(0).getHotelOrderInfoList().get(0);
|
||||
List<RefundInfo> refundInfo = flightOrderInfoEntity.getRefundInfo();
|
||||
HotelOrderInfoEntity hotelOrderInfoEntity = response.getItineraryList().get(0).getHotelOrderInfoList().get(0);
|
||||
List<RefundInfo> refundInfo = hotelOrderInfoEntity.getRefundInfo();
|
||||
if (refundInfo != null && !refundInfo.isEmpty()) {
|
||||
for (RefundInfo flightRefundInfo : refundInfo) {
|
||||
if (flightOrderInfoEntity.getOrderDetailStatus().equals("Cancelled")) {
|
||||
Command.of(RefundOrderGenerateCommand.class).Info(String.valueOf(flightRefundInfo.getRefundInfoID()),
|
||||
flightOrderInfoEntity.getOrderID(),
|
||||
Command.of(RefundOrderGenerateCommand.class)
|
||||
.Info(String.valueOf(flightRefundInfo.getRefundInfoID()),
|
||||
hotelOrderInfoEntity.getOrderID(),
|
||||
"-" + flightRefundInfo.getRefundCustomerAmount(),
|
||||
"4",
|
||||
flightOrderInfoEntity.getCancelTime()).sendToQueue();
|
||||
}
|
||||
DateTimeUtil.timeToStrCommon(LocalDateTime.now())).sendToQueue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -425,7 +425,7 @@ public class OrderDomainService {
|
|||
}
|
||||
|
||||
public RouteOrder checkRouteOrderStatus(RouteOrder routeOrder) {
|
||||
if(routeOrder.getOrderStatus() == null ) {
|
||||
if (routeOrder.getOrderStatus() == null) {
|
||||
routeOrder.reloadStatus();
|
||||
routeRepository.save(routeOrder);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,9 @@ import org.springframework.cache.annotation.CacheEvict;
|
|||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public class UserRepositoryImpl implements UserRepository {
|
||||
|
||||
|
@ -32,4 +35,28 @@ public class UserRepositoryImpl implements UserRepository {
|
|||
public User save(User user) {
|
||||
return jdbcUserRepository.save(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAll(List<User> userList) {
|
||||
jdbcUserRepository.saveAll(userList);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<User> findAll() {
|
||||
List<User> userList = new ArrayList<>();
|
||||
jdbcUserRepository.findAll()
|
||||
.forEach(userList::add);
|
||||
return userList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> findByStatus(Integer status) {
|
||||
return jdbcUserRepository.findByStatus(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> findByStatusIsNull() {
|
||||
return jdbcUserRepository.findByStatusIsNull();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,13 @@ import com.chint.domain.aggregates.user.User;
|
|||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface JdbcUserRepository extends CrudRepository<User, String> {
|
||||
User findByEmployeeNo(String employeeNo);
|
||||
|
||||
List<User> findByStatus(Integer status);
|
||||
|
||||
List<User> findByStatusIsNull();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.chint.interfaces.rest.amap;
|
||||
|
||||
import com.chint.application.commands.UserDisabledCommand;
|
||||
import com.chint.application.commands.UserLoginCommand;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.repository.UserNameRepository;
|
||||
|
@ -80,6 +81,17 @@ public class AmapUserRequest implements UserSync {
|
|||
return user;
|
||||
}
|
||||
|
||||
@ListenTo(command = "UserDisabledCommand",order = 0)
|
||||
@Override
|
||||
public Boolean disableUserToSupplier(UserDisabledCommand command) {
|
||||
User user = command.getUser();
|
||||
String updateUserUrl = BaseUrl + USER_UPDATE_PATH;
|
||||
UserParam userParamByUser = createUserParamByUser(user);
|
||||
userParamByUser.setStatus(0);
|
||||
BaseResponse post = amapRequest.post(updateUserUrl, userParamByUser, BaseResponse.class);
|
||||
return post.getCode().equals(1);
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class UserParam extends BaseRequestParam {
|
||||
private String userId; // 用户Id
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.chint.interfaces.rest.ctrip;
|
||||
|
||||
import com.chint.application.commands.UserDisabledCommand;
|
||||
import com.chint.application.commands.UserLoginCommand;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.repository.UserNameRepository;
|
||||
|
@ -86,6 +87,11 @@ public class CTripUserSaveRequest implements UserSync {
|
|||
}
|
||||
|
||||
public void saveUserToCTrip(User user) {
|
||||
AuthenticationListRequest authenticationListRequest = buildUserParam(user);
|
||||
postRequest.post(userUrl, authenticationListRequest, AuthenticationResponseList.class);
|
||||
}
|
||||
|
||||
private AuthenticationListRequest buildUserParam(User user) {
|
||||
String ticket = ticketRequest.loadTicket();
|
||||
AuthenticationEntity authenticationEntity = buildAuthenticationEntityWithUser(user);
|
||||
AuthenticationListRequest authenticationListRequest = new AuthenticationListRequest();
|
||||
|
@ -96,7 +102,7 @@ public class CTripUserSaveRequest implements UserSync {
|
|||
authenticationInfo.setSequence("0");
|
||||
authenticationInfo.setAuthentication(authenticationEntity);
|
||||
authenticationListRequest.setAuthenticationInfoList(List.of(authenticationInfo));
|
||||
postRequest.post(userUrl, authenticationListRequest, AuthenticationResponseList.class);
|
||||
return authenticationListRequest;
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,12 +111,12 @@ public class CTripUserSaveRequest implements UserSync {
|
|||
userNameRepository.findByEmployeeNo(user.getEmployeeNo()).ifPresentOrElse(it -> authenticationEntity.setName(it.getIdName()),
|
||||
() -> authenticationEntity.setName(user.getName()));
|
||||
authenticationEntity.setEmployeeID(user.getEmployeeNo());
|
||||
authenticationEntity.setValid(user.getWorkStatus().charAt(0));
|
||||
authenticationEntity.setValid(user.getWorkStatus() == null ? 'A' : 'I');
|
||||
authenticationEntity.setSubAccountName(subAccountName);
|
||||
return authenticationEntity;
|
||||
}
|
||||
|
||||
@ListenTo(command = "UserLoginCommand",order = 1)
|
||||
@ListenTo(command = "UserLoginCommand", order = 1)
|
||||
@Override
|
||||
public User syncUserInfoToSupplier(UserLoginCommand command) {
|
||||
User user = command.getUser();
|
||||
|
@ -122,4 +128,18 @@ public class CTripUserSaveRequest implements UserSync {
|
|||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@ListenTo(command = "UserDisabledCommand", order = 1)
|
||||
@Override
|
||||
public Boolean disableUserToSupplier(UserDisabledCommand command) {
|
||||
User user = command.getUser();
|
||||
AuthenticationListRequest authenticationListRequest = buildUserParam(user);
|
||||
List<AuthenticationInfo> authenticationInfoList = authenticationListRequest.getAuthenticationInfoList();
|
||||
if (authenticationInfoList != null && !authenticationInfoList.isEmpty()) {
|
||||
AuthenticationInfo authenticationInfo = authenticationInfoList.get(0);
|
||||
authenticationInfo.getAuthentication().setValid('I');
|
||||
}
|
||||
AuthenticationResponseList response = postRequest.post(userUrl, authenticationListRequest, AuthenticationResponseList.class);
|
||||
return response.getResult().equals("Success");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.chint.interfaces.rest.ctrip.in;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chint.application.commands.OrderStatusChangeCommand;
|
||||
import com.chint.domain.aggregates.order.OrderDetail;
|
||||
import com.chint.domain.repository.SupplierCallBackLogRepository;
|
||||
|
@ -15,6 +16,7 @@ import com.chint.interfaces.rest.ctrip.dto.put.CTripStatusNotification;
|
|||
import com.chint.interfaces.rest.ctrip.dto.search.ItineraryEntity;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.hotel.HotelOrderInfoEntity;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.hotel.RefundInfo;
|
||||
import com.chint.interfaces.rest.ctrip.tools.CTripUtils;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -29,9 +31,11 @@ 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 java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.chint.infrastructure.constant.LegConstant.*;
|
||||
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_REFUND;
|
||||
import static com.chint.infrastructure.constant.OrderConstant.ORDER_STATUS_REFUSE_MSG;
|
||||
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
|
||||
|
||||
|
@ -159,7 +163,12 @@ public class CTripNoteController {
|
|||
.extension(getETAReason(response, LEG_TYPE_AIRPLANE));
|
||||
break;
|
||||
case LEG_TYPE_HOTEL:
|
||||
command.eventType(CTripUtils.mapHotelStatus(orderStatus))
|
||||
Integer eventType = CTripUtils.mapHotelStatus(orderStatus);
|
||||
if (!eventType.equals(ORDER_EVENT_REFUND)) {
|
||||
//如果是酒店的话会存在部分退款的情况 ,需要额外发送一个部分退款状态
|
||||
checkHotelIfRefund(response, command);
|
||||
}
|
||||
command.eventType(eventType)
|
||||
.extension(getETAReason(response, LEG_TYPE_HOTEL));
|
||||
break;
|
||||
case LEG_TYPE_TRAIN:
|
||||
|
@ -175,6 +184,21 @@ public class CTripNoteController {
|
|||
return Result.Success("成功收到消息");
|
||||
}
|
||||
|
||||
|
||||
private void checkHotelIfRefund(SearchOrderResponse response, OrderStatusChangeCommand command) {
|
||||
ItineraryEntity itineraryEntity = response.getItineraryList().get(0);
|
||||
List<HotelOrderInfoEntity> hotelOrderInfoList = itineraryEntity.getHotelOrderInfoList();
|
||||
if (hotelOrderInfoList != null && !hotelOrderInfoList.isEmpty()) {
|
||||
HotelOrderInfoEntity hotelOrderInfoEntity = hotelOrderInfoList.get(0);
|
||||
List<RefundInfo> refundInfo = hotelOrderInfoEntity.getRefundInfo();
|
||||
if (refundInfo != null && !refundInfo.isEmpty()) {
|
||||
OrderStatusChangeCommand orderStatusChangeCommand = BeanUtil
|
||||
.copyProperties(command, OrderStatusChangeCommand.class);
|
||||
orderStatusChangeCommand.outStatus("部分退款").eventType(ORDER_EVENT_REFUND).sendToQueue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getETAReason(SearchOrderResponse response, Integer productType) {
|
||||
ItineraryEntity itineraryEntity = response.getItineraryList().get(0);
|
||||
return switch (productType) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.chint.interfaces.rest.ly;
|
||||
|
||||
import com.chint.application.commands.UserDisabledCommand;
|
||||
import com.chint.application.commands.UserLoginCommand;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.repository.UserNameRepository;
|
||||
|
@ -113,4 +114,16 @@ public class LYUserRequest implements UserSync {
|
|||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@ListenTo(command = "UserDisabledCommand",order = 3)
|
||||
@Override
|
||||
public Boolean disableUserToSupplier(UserDisabledCommand command) {
|
||||
User user = command.getUser();
|
||||
EmployeeEntity employeeEntity = user2LYEmployee(user);
|
||||
employeeEntity.setWorkingState(0);
|
||||
EmployeeRequest employeeData = new EmployeeRequest();
|
||||
employeeData.setParam(employeeEntity);
|
||||
UserResponse post = postRequest.post(userUrl, employeeData, UserResponse.class);
|
||||
return post.isSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.chint.interfaces.rest.user;
|
||||
|
||||
import com.chint.application.commands.UserDisabledCommand;
|
||||
import com.chint.dc.api.DataCenterResult;
|
||||
import com.chint.dc.api.dto.DataCenterOption;
|
||||
import com.chint.dc.api.service.DataCenterService;
|
||||
|
@ -7,6 +8,7 @@ import com.chint.domain.aggregates.user.User;
|
|||
import com.chint.domain.repository.StaffRankRepository;
|
||||
import com.chint.domain.repository.UserRepository;
|
||||
import com.chint.domain.service.JTCompanyDomainService;
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import com.chint.interfaces.rest.ctrip.CTripUserSaveRequest;
|
||||
import com.chint.interfaces.rest.ly.LYUserRequest;
|
||||
import com.chint.interfaces.rest.user.dto.AccessKeyDTO;
|
||||
|
@ -35,7 +37,7 @@ import static com.chint.infrastructure.constant.SFConstant.*;
|
|||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PushUser {
|
||||
public class BatchUserWorker {
|
||||
|
||||
@Value("${sf.systemId}")
|
||||
private String systemId;
|
||||
|
@ -79,12 +81,38 @@ public class PushUser {
|
|||
}
|
||||
}
|
||||
|
||||
public void checkUserStatus() {
|
||||
List<User> userList = userRepository.findByStatus(1);
|
||||
List<User> byStatusIsNull = userRepository.findByStatusIsNull();
|
||||
userList.addAll(byStatusIsNull);
|
||||
List<User> userStatusChangeList = new ArrayList<>();
|
||||
for (User user : userList) {
|
||||
List<UserDataDTO> userSFDataFromOpenApi = userSFRequest.getUserSFDataFromOpenApi(user);
|
||||
for (UserDataDTO userDataDTO : userSFDataFromOpenApi) {
|
||||
user.addDeptInfo(userDataDTO);
|
||||
}
|
||||
List<UserDataDTO> userDataDTOList = userSFDataFromOpenApi
|
||||
.stream()
|
||||
.filter(it -> it.getStatus().equals("A"))
|
||||
.toList();
|
||||
if (userDataDTOList.isEmpty()) {
|
||||
//如果这里不存在状态为A的SF数据,说明他已经处于离职状态
|
||||
user.setStatus(0);
|
||||
user.loadInfoFromDept();
|
||||
Command.of(UserDisabledCommand.class).user(user).sendToQueue();
|
||||
userStatusChangeList.add(user);
|
||||
}
|
||||
}
|
||||
if (!userStatusChangeList.isEmpty()) {
|
||||
userRepository.saveAll(userStatusChangeList);
|
||||
}
|
||||
}
|
||||
|
||||
public List<User> getUserSFDataFromOpenApiBatch() {
|
||||
int pageSize = 1000;
|
||||
int page = 1;
|
||||
List<User> list = new ArrayList<>();
|
||||
boolean shouldContinue = true;
|
||||
|
||||
while (shouldContinue) {
|
||||
int start = (page - 1) * pageSize;
|
||||
log.info("Pulling user data. Page={}", page);
|
||||
|
@ -135,12 +163,12 @@ public class PushUser {
|
|||
shouldContinue = false;
|
||||
}
|
||||
}
|
||||
|
||||
return list.stream()
|
||||
.filter(user -> user.getEmployeeNo() != null)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
private List<UserDataDTO> parseUserData(DataCenterResult result) {
|
||||
Type type = new TypeToken<List<UserDataDTO>>() {
|
||||
}.getType();
|
||||
|
@ -175,7 +203,6 @@ public class PushUser {
|
|||
Optional.ofNullable(userRepository.findByUserEmployeeNo(user.getEmployeeNo()))
|
||||
.ifPresentOrElse(
|
||||
it -> {
|
||||
// user.setUserId(it.getUserId());
|
||||
if (it.checkSyncTime()) {
|
||||
it.setWorkStatus(user.getWorkStatus());
|
||||
asyncUser(it);
|
|
@ -1,10 +1,11 @@
|
|||
package com.chint.interfaces.rest.user;
|
||||
|
||||
|
||||
import com.chint.application.commands.UserDisabledCommand;
|
||||
import com.chint.application.commands.UserLoginCommand;
|
||||
import com.chint.application.commands.UserSFCommand;
|
||||
import com.chint.domain.aggregates.standards.Ranks;
|
||||
import com.chint.domain.aggregates.standards.StaffRank;
|
||||
import com.chint.domain.aggregates.system.JTCompany;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.aggregates.user.UserDepartmentInfo;
|
||||
import com.chint.domain.exceptions.NotFoundException;
|
||||
|
@ -15,6 +16,7 @@ import com.chint.domain.service.JTCompanyDomainService;
|
|||
import com.chint.domain.service.RankDomainService;
|
||||
import com.chint.infrastructure.constant.SFConstant;
|
||||
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import com.chint.infrastructure.util.BaseContext;
|
||||
import com.chint.infrastructure.util.StringCheck;
|
||||
import com.chint.interfaces.rest.base.PostRequest;
|
||||
|
@ -120,6 +122,15 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
}
|
||||
|
||||
|
||||
@ListenTo(command = "UserLoginCommand", order = 0)
|
||||
public void loadSfInfo(UserLoginCommand command) {
|
||||
User user = command.getUser();
|
||||
if (user.checkSyncTime()) {
|
||||
loadSFInfo(Command.of(UserSFCommand.class).user(user));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ListenTo(command = "UserSFCommand", order = 0)
|
||||
public User loadSFInfo(UserSFCommand command) {
|
||||
User user = command.getUser();
|
||||
|
@ -139,6 +150,14 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
for (UserDataDTO userDataDTO : fromJson) {
|
||||
user.addDeptInfo(userDataDTO);
|
||||
}
|
||||
|
||||
if(fromJson.isEmpty()){
|
||||
user.setStatus(0);
|
||||
user.loadInfoFromDept();
|
||||
Command.of(UserDisabledCommand.class).user(user).sendToQueue();
|
||||
} else {
|
||||
user.setStatus(1);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package com.chint.interfaces.rest.user;
|
||||
|
||||
import com.chint.application.commands.UserDisabledCommand;
|
||||
import com.chint.application.commands.UserLoginCommand;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
public interface UserSync {
|
||||
User syncUserInfoToSupplier(UserLoginCommand command);
|
||||
|
||||
Boolean disableUserToSupplier(UserDisabledCommand command);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,9 @@ public class AmapTest {
|
|||
@Autowired
|
||||
private AmapLocationRequest amapLocationRequest;
|
||||
|
||||
@Autowired
|
||||
private OrderDetailRequest orderDetailRequest;
|
||||
|
||||
private Gson gson = new Gson();
|
||||
|
||||
private User user = new User(1L, "230615020", 1, "卢麟哲", "lulz1@chint.com", "15857193365", "A30000001");
|
||||
|
@ -43,12 +46,19 @@ public class AmapTest {
|
|||
@Autowired
|
||||
private SettleBillRequest settleBillRequest;
|
||||
|
||||
@Test
|
||||
public void search() {
|
||||
Gson gson = new Gson();
|
||||
OrderDetailResponse orderDetailResponse = orderDetailRequest.queryOrderDetail("40920084001340019626730137");
|
||||
System.out.println(gson.toJson(orderDetailResponse));
|
||||
}
|
||||
|
||||
/**
|
||||
* 完单数据查询
|
||||
*/
|
||||
@Test
|
||||
public void pageFinishedOrder() {
|
||||
List<FinishedOrderResponse> responses= settleBillRequest.pageFinishedOrder("20240401", "20240431");
|
||||
List<FinishedOrderResponse> responses = settleBillRequest.pageFinishedOrder("20240401", "20240431");
|
||||
System.out.println(responses);
|
||||
}
|
||||
|
||||
|
@ -59,25 +69,25 @@ public class AmapTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void queryUser(){
|
||||
public void queryUser() {
|
||||
UserQueryResponse userQueryResponse = amapUserRequest.queryUser(user2);
|
||||
System.out.println(gson.toJson(userQueryResponse));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateUser(){
|
||||
public void updateUser() {
|
||||
BaseResponse baseResponse = amapUserRequest.updateUser(user);
|
||||
System.out.println(gson.toJson(baseResponse));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void login(){
|
||||
public void login() {
|
||||
H5LoginResponse h5LoginResponse = amapLoginRequest.h5Login(user);
|
||||
System.out.println(gson.toJson(h5LoginResponse.getRedirectUrl()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryLocation(){
|
||||
public void queryLocation() {
|
||||
LocationResponse locationQuery = amapLocationRequest.locationQuery("北京");
|
||||
System.out.println(gson.toJson(locationQuery.getData()));
|
||||
}
|
||||
|
@ -85,8 +95,6 @@ public class AmapTest {
|
|||
@Autowired
|
||||
private TokenRequest tokenRequest;
|
||||
|
||||
@Autowired
|
||||
private OrderDetailRequest orderDetailRequest;
|
||||
|
||||
@Test
|
||||
public void gaoDe() {
|
||||
|
@ -114,7 +122,7 @@ public class AmapTest {
|
|||
/**
|
||||
* 取消订单
|
||||
*/
|
||||
// @Test
|
||||
// @Test
|
||||
public void cancelOrder() {
|
||||
takeCarRequest.cancelOrder("20240301", "行程变更");
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import com.chint.domain.aggregates.location.basedata.CountryLevelInfoEntity;
|
|||
import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity;
|
||||
import com.chint.domain.aggregates.order.Leg;
|
||||
import com.chint.domain.aggregates.order.Location;
|
||||
import com.chint.domain.aggregates.order.RouteOrder;
|
||||
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHotelRecord;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.repository.*;
|
||||
|
@ -38,7 +37,7 @@ import com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach.OrderInfo;
|
|||
import com.chint.interfaces.rest.ly.dto.search.response.hotel.HotelDetailResponse;
|
||||
import com.chint.interfaces.rest.ly.dto.strokepush.StrokePushResult;
|
||||
import com.chint.interfaces.rest.ly.dto.strokepush.TrainChange.TrainChangeRequest;
|
||||
import com.chint.interfaces.rest.user.PushUser;
|
||||
import com.chint.interfaces.rest.user.BatchUserWorker;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequestImpl;
|
||||
import com.chint.interfaces.rest.user.UserSFRequest;
|
||||
|
@ -49,17 +48,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.chint.infrastructure.constant.LocationConstant.*;
|
||||
import static com.chint.infrastructure.constant.RankConstant.DEFAULT_RANK_NAME;
|
||||
import static com.chint.infrastructure.util.DateTimeUtil.formatter;
|
||||
import static com.chint.infrastructure.util.DateTimeUtil.lastMonthStr;
|
||||
|
||||
@Slf4j
|
||||
|
@ -134,7 +130,7 @@ class RouteApplicationTests {
|
|||
private UserSFRequest userSFRequest;
|
||||
|
||||
@Autowired
|
||||
private PushUser pushUser;
|
||||
private BatchUserWorker pushUser;
|
||||
|
||||
|
||||
@Autowired
|
||||
|
|
Loading…
Reference in New Issue