From f2adeab8f64ffb99d9529a14577784d7b569df86 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 28 Jun 2024 10:35:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dredis=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E4=B8=B4=E6=97=B6=E8=A1=8C=E7=A8=8B=E8=A7=84=E5=88=92?= =?UTF-8?q?=E5=8D=95=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/in/OrderPublicController.java | 8 +++++ .../application/out/OrderOutController.java | 18 ++++++---- .../application/queryies/OrderQuery.java | 11 ++++-- .../application/system/UserController.java | 2 +- .../domain/aggregates/base/BaseEvent.java | 5 +++ .../aggregates/base/EventManageable.java | 5 +++ .../order/RouteCustomExtensionField.java | 1 - .../domain/aggregates/order/RouteOrder.java | 2 ++ .../domain/aggregates/order/RouteRequest.java | 5 +++ .../order/RouterOrderExtensionField.java | 2 ++ .../domain/aggregates/system/SystemCode.java | 15 ++++++++ .../system/SystemCodeExtensionField.java | 36 +++++++++++++++++++ .../aggregates/system/SystemOrganization.java | 10 ++++++ .../chint/domain/aggregates/user/Role.java | 2 -- .../SystemOrganizationRepository.java | 2 ++ .../infrastructure/constant/LegConstant.java | 11 ++++++ .../repository/RouteRepositoryImpl.java | 9 ++++- .../SystemOrganizationRepositoryImpl.java | 12 +++++++ .../interfaces/rest/amap/AmapUserRequest.java | 6 +++- .../rest/amap/request/TokenRequest.java | 6 +++- 20 files changed, 153 insertions(+), 15 deletions(-) create mode 100644 src/main/java/com/chint/domain/aggregates/system/SystemCodeExtensionField.java diff --git a/src/main/java/com/chint/application/in/OrderPublicController.java b/src/main/java/com/chint/application/in/OrderPublicController.java index 9fed960a..b2c353e8 100644 --- a/src/main/java/com/chint/application/in/OrderPublicController.java +++ b/src/main/java/com/chint/application/in/OrderPublicController.java @@ -1,6 +1,7 @@ package com.chint.application.in; import com.chint.application.dtos.DeleteLegData; +import com.chint.application.dtos.LegApprovalParam; import com.chint.application.queryies.OrderQuery; import com.chint.application.services.OrderApplicationService; import com.chint.domain.aggregates.order.RouteOrder; @@ -53,6 +54,13 @@ public class OrderPublicController { return Result.Success(SUCCESS); } + @ApiOperation("提交需要审批的行程节点") + @PostMapping("/approve/leg") + public Result approveOrder(@RequestBody LegApprovalParam param) { + + return Result.Success(SUCCESS); + } + @ApiOperation("审批拒绝行程规划单") @PostMapping("/reject") diff --git a/src/main/java/com/chint/application/out/OrderOutController.java b/src/main/java/com/chint/application/out/OrderOutController.java index b9ce12df..8de60f97 100644 --- a/src/main/java/com/chint/application/out/OrderOutController.java +++ b/src/main/java/com/chint/application/out/OrderOutController.java @@ -73,14 +73,20 @@ public class OrderOutController { public Result queryOrder(@RequestBody OrderQueryData queryData) { String fakeOrderNo = queryData.getFakeOrderNo(); String sysCode = queryData.getSysCode(); - RouteOrder routeOrder; + Long routeId = queryData.getRouteId(); + RouteOrder routeOrder = null; if (fakeOrderNo != null && sysCode != null) { routeOrder = routeRepository.findTempRouteOrderBySysCodeAndBillCode(sysCode, fakeOrderNo); - } else { - routeOrder = orderQuery.queryById(queryData.getRouteId()).reloadStatus(); } - RouteOrderRes routeOrderRes = orderQuery.queryRouteRes(routeOrder); - return Result.Success(SUCCESS, routeOrderRes); + if (routeId != null) { + routeOrder = orderQuery.queryById(routeId).reloadStatus(); + } + if (routeOrder != null) { + RouteOrderRes routeOrderRes = orderQuery.queryRouteRes(routeOrder); + return Result.Success(SUCCESS, routeOrderRes); + } else { + return Result.error("无法查询到相关差旅申请单"); + } } @ApiOperation("分页查询行程规划订单") @@ -137,8 +143,8 @@ public class OrderOutController { legResList.forEach(it -> it.setUserName(userRepository.findByUserEmployeeNo(routeOrder.getUserId()).getName())); legDomainService.getSupplierName(legResList, routeOrder); return Result.Success(SUCCESS, legResList); - } + } @ApiOperation("查询单日行程规划单") @PostMapping("/query/route/filed") public Result> queryRoutOrderField(@RequestBody RoutOrderFieldParam param) { diff --git a/src/main/java/com/chint/application/queryies/OrderQuery.java b/src/main/java/com/chint/application/queryies/OrderQuery.java index 748b5dfc..9eb9f4fd 100644 --- a/src/main/java/com/chint/application/queryies/OrderQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderQuery.java @@ -335,7 +335,13 @@ public class OrderQuery { routeOrder = routeRepository.queryById(queryData.getRouteId()); } - if(routeOrder != null){ + if (routeOrder != null) { + if (routeOrder.getCreateTime() == null) { + routeOrder.setCreateTime(LocalDateTime.now()); + } + if (routeOrder.getUpdateTime() == null) { + routeOrder.setUpdateTime(LocalDateTime.now()); + } routeOrder.reloadStatus(); } @@ -576,7 +582,8 @@ public class OrderQuery { !order.getLegItems().isEmpty() && order.getLegItems().stream().anyMatch(leg -> !leg.getLegType().equals(LEG_TYPE_OTHER))) .filter(order -> order.getSupplierName() == null) - .filter(order -> order.getLegItems().stream().map(Leg::getLegType).anyMatch(allowSupplierProductList::contains)) //判断有无允许预订的商品 + .filter(order -> order.getLegItems().stream().map(Leg::getLegType).anyMatch(allowSupplierProductList::contains))//判断有无允许预订的商品 + .filter(order -> order.getEndTime().isAfter(LocalDateTime.now())) //如果是已经过期的差旅行程单,那么就取消需要同步的订单 .sorted(Comparator.comparing(RouteOrder::getUpdateTime).reversed()) .map(order -> { User user = userRepository.findByUserEmployeeNo(order.getUserId()); diff --git a/src/main/java/com/chint/application/system/UserController.java b/src/main/java/com/chint/application/system/UserController.java index b6565410..e56e1d43 100644 --- a/src/main/java/com/chint/application/system/UserController.java +++ b/src/main/java/com/chint/application/system/UserController.java @@ -64,7 +64,7 @@ public class UserController { @ApiOperation("根据Id查询用户信息") @PostMapping("/query") public Result getUserByEmployeeNo() { - User currentUser = BaseContext.getCurrentUser().loadRoleOrg(); + User currentUser = BaseContext.getCurrentUser(); return Result.Success(SUCCESS, BeanUtil.copyProperties(currentUser, UserRes.class)); } diff --git a/src/main/java/com/chint/domain/aggregates/base/BaseEvent.java b/src/main/java/com/chint/domain/aggregates/base/BaseEvent.java index 715f2312..6899c35f 100644 --- a/src/main/java/com/chint/domain/aggregates/base/BaseEvent.java +++ b/src/main/java/com/chint/domain/aggregates/base/BaseEvent.java @@ -34,4 +34,9 @@ public abstract class BaseEvent implements Serializable { } return this; } + + public BaseEvent extension(String extension) { + this.extension = extension; + return this; + } } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/base/EventManageable.java b/src/main/java/com/chint/domain/aggregates/base/EventManageable.java index 07dd32b5..a8d2fc98 100644 --- a/src/main/java/com/chint/domain/aggregates/base/EventManageable.java +++ b/src/main/java/com/chint/domain/aggregates/base/EventManageable.java @@ -1,5 +1,7 @@ package com.chint.domain.aggregates.base; +import com.chint.domain.aggregates.order.LegApprovalEvent; + import java.util.List; public interface EventManageable { @@ -18,4 +20,7 @@ public interface EventManageable { List eventList = getEvents(); return eventList.isEmpty() ? null : eventList.get(eventList.size() - 1); } + + + List get(); } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/order/RouteCustomExtensionField.java b/src/main/java/com/chint/domain/aggregates/order/RouteCustomExtensionField.java index 80b899f8..482ee7f0 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouteCustomExtensionField.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouteCustomExtensionField.java @@ -17,7 +17,6 @@ public class RouteCustomExtensionField implements Serializable { private Long id; @Column("route_id") private Long routeId; - private Long routeOrderKey; private String fieldName; private String fieldValue; private String extension; diff --git a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java index 247d8761..cccf0320 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java @@ -135,6 +135,8 @@ public class RouteOrder implements Serializable { } if (data.getCreator() != null) { approveOrderNo.setCreator(data.getCreator()); + } else { + approveOrderNo.setCreator(this.userId); } if (data.getAccountCompany() != null) { approveOrderNo.setAccountCompanyName(data.getAccountCompany()); diff --git a/src/main/java/com/chint/domain/aggregates/order/RouteRequest.java b/src/main/java/com/chint/domain/aggregates/order/RouteRequest.java index a8033ad8..de07ff00 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouteRequest.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouteRequest.java @@ -71,6 +71,11 @@ public class RouteRequest implements Serializable, EventManageable { return this.eventList; } + @Override + public List get() { + return List.of(); + } + public RouteRequest reloadStatus() { BaseEvent lastEvent = this.getLastEvent().reloadStatus(); this.status = lastEvent.getEventType(); diff --git a/src/main/java/com/chint/domain/aggregates/order/RouterOrderExtensionField.java b/src/main/java/com/chint/domain/aggregates/order/RouterOrderExtensionField.java index 1dbf4619..39b6886d 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouterOrderExtensionField.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouterOrderExtensionField.java @@ -22,4 +22,6 @@ public class RouterOrderExtensionField implements Serializable { private String belongDeptCode; + private String companyCode; + } diff --git a/src/main/java/com/chint/domain/aggregates/system/SystemCode.java b/src/main/java/com/chint/domain/aggregates/system/SystemCode.java index 5727fab0..586baeb6 100644 --- a/src/main/java/com/chint/domain/aggregates/system/SystemCode.java +++ b/src/main/java/com/chint/domain/aggregates/system/SystemCode.java @@ -2,6 +2,7 @@ package com.chint.domain.aggregates.system; import lombok.Data; import org.springframework.data.annotation.Id; +import org.springframework.data.annotation.Transient; import org.springframework.data.relational.core.mapping.MappedCollection; import org.springframework.data.relational.core.mapping.Table; @@ -25,4 +26,18 @@ public class SystemCode implements Serializable { private List companyInfos; @MappedCollection(idColumn = "system_code_id") private SystemCodeUrl systemCodeUrl; + @Transient +// @MappedCollection(idColumn = "system_id", keyColumn = "system_key") + private List systemCodeExtensionFieldList; + + + public String getApprovalPlatformMark() { + if (systemCodeExtensionFieldList == null || systemCodeExtensionFieldList.isEmpty()) { + return null; + } + return this.systemCodeExtensionFieldList.stream().filter(it -> it.getFieldName().equals("ApprovalPlatformMark")) + .map(SystemCodeExtensionField::getFieldValue) + .findFirst() + .orElse(""); + } } diff --git a/src/main/java/com/chint/domain/aggregates/system/SystemCodeExtensionField.java b/src/main/java/com/chint/domain/aggregates/system/SystemCodeExtensionField.java new file mode 100644 index 00000000..316ebd8c --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/system/SystemCodeExtensionField.java @@ -0,0 +1,36 @@ +package com.chint.domain.aggregates.system; + +import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Column; +import org.springframework.data.relational.core.mapping.Table; + +import java.io.Serial; +import java.io.Serializable; + +@Data +@Table("system_code_extension_field") +public class SystemCodeExtensionField implements Serializable { + @Serial + private static final long serialVersionUID = 8167639173251119570L; + @Id + private Long id; + @Column("system_code_id") + private Long systemCodeId; + private String fieldName; + private String fieldValue; + private String extension; + + private SystemCodeExtensionField(String fieldName, String fieldValue, String extension) { + this.fieldName = fieldName; + this.fieldValue = fieldValue; + this.extension = extension; + } + + public static SystemCodeExtensionField of(String fieldName, String fieldValue, String extension) { + return new SystemCodeExtensionField(fieldName, fieldValue, extension); + } + + +} + diff --git a/src/main/java/com/chint/domain/aggregates/system/SystemOrganization.java b/src/main/java/com/chint/domain/aggregates/system/SystemOrganization.java index 8240f478..ed833cd9 100644 --- a/src/main/java/com/chint/domain/aggregates/system/SystemOrganization.java +++ b/src/main/java/com/chint/domain/aggregates/system/SystemOrganization.java @@ -92,4 +92,14 @@ public class SystemOrganization implements Serializable { public RoleOrganizationVO mapToRoleOrganizationVO() { return BeanUtil.copyProperties(this, RoleOrganizationVO.class); } + + public String getApprovalPlatformMark() { + if (systemOrganizationExtensionList == null || systemOrganizationExtensionList.isEmpty()) { + return null; + } + return this.systemOrganizationExtensionList.stream().filter(it -> it.getFieldName().equals("ApprovalPlatformMark")) + .map(SystemOrganizationExtension::getFieldValue) + .findFirst() + .orElse(""); + } } diff --git a/src/main/java/com/chint/domain/aggregates/user/Role.java b/src/main/java/com/chint/domain/aggregates/user/Role.java index 2facb295..c307199e 100644 --- a/src/main/java/com/chint/domain/aggregates/user/Role.java +++ b/src/main/java/com/chint/domain/aggregates/user/Role.java @@ -102,6 +102,4 @@ public class Role implements Serializable { } return role; } - - } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/repository/SystemOrganizationRepository.java b/src/main/java/com/chint/domain/repository/SystemOrganizationRepository.java index 54f99ad8..fd6c7573 100644 --- a/src/main/java/com/chint/domain/repository/SystemOrganizationRepository.java +++ b/src/main/java/com/chint/domain/repository/SystemOrganizationRepository.java @@ -26,4 +26,6 @@ public interface SystemOrganizationRepository { SystemOrganization queryChild(SystemOrganization systemOrganization); List expandOrganizations(List systemOrganizations); + + Optional findByOrgCodeContainingOrOrgNameContaining(String orgCode, String orgName); } diff --git a/src/main/java/com/chint/infrastructure/constant/LegConstant.java b/src/main/java/com/chint/infrastructure/constant/LegConstant.java index 94485314..dd0a4dfb 100644 --- a/src/main/java/com/chint/infrastructure/constant/LegConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/LegConstant.java @@ -23,6 +23,17 @@ public class LegConstant { public static final int LEG_STATUS_REJECT = -1; public static final String LEG_STATUS_REJECT_NAME = "审批未通过"; + public static final int LEG_APPROVAL_STATUS_NOT = -1; + public static final String LEG_APPROVAL_STATUS_NOT_NAME = "无需审批"; + public static final int LEG_APPROVAL_STATUS_PREPARE = 0; + public static final String LEG_APPROVAL_STATUS_PREPARE_NAME = "未审批"; + public static final int LEG_APPROVAL_STATUS_SUBMIT = 1; + public static final String LEG_APPROVAL_STATUS_SUBMIT_NAME = "审批中"; + public static final int LEG_APPROVAL_STATUS_SUCCESS = 2; + public static final String LEG_APPROVAL_STATUS_SUCCESS_NAME = "已通过"; + public static final int LEG_APPROVAL_STATUS_REJECT = 3; + public static final String LEG_APPROVAL_STATUS_REJECT_NAME = "已驳回"; + // 规划节点运输方式 public static final int LEG_TYPE_TRAIN = 0; diff --git a/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java index 24f5adeb..f9466f19 100644 --- a/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java @@ -205,8 +205,15 @@ public class RouteRepositoryImpl implements RouteRepository { @Override public RouteOrder saveTempRouteOrder(RouteOrder routeOrder, Long hours) { ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); + routeOrder.reloadStatus(); + if (routeOrder.getCreateTime() == null) { + routeOrder.setCreateTime(LocalDateTime.now()); + } + if (routeOrder.getUpdateTime() == null) { + routeOrder.setUpdateTime(LocalDateTime.now()); + } String redisKey = "TemporaryRouteOrder:" + approveOrderNo.getSysCode() + "-" + approveOrderNo.getFakeOrderNo(); - redisTemplate.opsForValue().set(redisKey, routeOrder, hours, TimeUnit.HOURS); + redisTemplate.opsForValue().set(redisKey, routeOrder, 7L, TimeUnit.DAYS); return routeOrder; } } diff --git a/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java index 4a8e5f6e..39e7e38b 100644 --- a/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java @@ -11,6 +11,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.Optional; +import java.util.stream.Stream; @Repository public class SystemOrganizationRepositoryImpl implements SystemOrganizationRepository { @@ -127,6 +128,17 @@ public class SystemOrganizationRepositoryImpl implements SystemOrganizationRepos return allOrganizations; } + @Override + public Optional findByOrgCodeContainingOrOrgNameContaining(String orgCode, String orgName) { + return Stream.of( + jdbcSystemOrganizationRepository.findByOrgCode(orgCode).stream().findFirst(), + jdbcSystemOrganizationRepository.findByOrgName(orgName).stream().findFirst() + ) + .filter(Optional::isPresent) + .map(Optional::get) + .findFirst(); + } + private void expandOrganizationRecursively(SystemOrganization org, List allOrganizations) { if (org == null) { diff --git a/src/main/java/com/chint/interfaces/rest/amap/AmapUserRequest.java b/src/main/java/com/chint/interfaces/rest/amap/AmapUserRequest.java index 5613c852..9cbe9a02 100644 --- a/src/main/java/com/chint/interfaces/rest/amap/AmapUserRequest.java +++ b/src/main/java/com/chint/interfaces/rest/amap/AmapUserRequest.java @@ -139,7 +139,11 @@ public class AmapUserRequest implements UserSync { UserParam userParam = new UserParam(); userParam.setUserId(user.getEmployeeNo()); userParam.setEmail(user.getEmail()); - userParam.setMobile(user.getPhoneNumber()); + String phoneNumber = user.getPhoneNumber(); + if (phoneNumber.startsWith("+86")) { + phoneNumber = phoneNumber.replace("+86", ""); + } + userParam.setMobile(phoneNumber); userNameRepository.findByEmployeeNo(user.getEmployeeNo()).ifPresentOrElse( it -> userParam.setRealName(it.getIdName()), () -> userParam.setRealName(user.getName())); diff --git a/src/main/java/com/chint/interfaces/rest/amap/request/TokenRequest.java b/src/main/java/com/chint/interfaces/rest/amap/request/TokenRequest.java index 574578f1..2f25597a 100644 --- a/src/main/java/com/chint/interfaces/rest/amap/request/TokenRequest.java +++ b/src/main/java/com/chint/interfaces/rest/amap/request/TokenRequest.java @@ -32,7 +32,11 @@ public class TokenRequest { public TokenDto getTokenDto(User user) { TokenDto tokenDto = new TokenDto(); TokenDto.UserInfo userInfo = new TokenDto.UserInfo(); - userInfo.setMobile(user.getPhoneNumber()); + String phoneNumber = user.getPhoneNumber(); + if(phoneNumber.startsWith("+86")){ + phoneNumber = phoneNumber.replace("+86", ""); + } + userInfo.setMobile(phoneNumber); userInfo.setUserId(user.getEmployeeNo()); String json = gson.toJson(userInfo); tokenDto.setUserInfo(json);