变更打车添加城市字段

This commit is contained in:
dengwc 2024-03-15 00:09:59 +08:00
parent 46189c0d5f
commit 546383fc69
10 changed files with 197 additions and 59 deletions

View File

@ -26,21 +26,22 @@ import com.chint.infrastructure.util.BaseContext;
import com.chint.interfaces.rest.bpm.BPMRequest;
import com.chint.interfaces.rest.bpm.dto.JTH3ChangeDto;
import com.chint.interfaces.rest.bpm.dto.XNChangeDto;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Optional;
import java.util.*;
import static com.chint.infrastructure.constant.BPMConstant.H3_BPM;
import static com.chint.infrastructure.constant.BPMConstant.XNYS_BPM;
import static com.chint.infrastructure.constant.CommonMessageConstant.LEG_CHANGE_MAX_ERROR;
import static com.chint.infrastructure.constant.DataMessageConstant.DATA_NOT_FOUND;
import static com.chint.infrastructure.constant.DataMessageConstant.ORDER_STATUS_ERROR;
import static com.chint.infrastructure.constant.LegConstant.LEG_CHANGE_MAX_NUM;
import static com.chint.infrastructure.constant.LegConstant.LEG_EVENT_CHANGE;
import static com.chint.infrastructure.constant.LegConstant.*;
import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_PREPARE;
import static com.chint.infrastructure.constant.UtilConstant.RESULT_ORDER_DETAIL;
@ -349,4 +350,6 @@ public class LegEventHandler implements LegEventService {
legEvent.setExtension(command.getReason());
legRepository.save(byLegId);
}
}

View File

@ -0,0 +1,25 @@
package com.chint.interfaces.rest.bpm.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
@Data
@Accessors(chain = true)
public class ANExceedStandardDto {
private String sourceSystemNum;
private String sourceSystem;
private String applicant;
private String applyNo;
private String orderNo;
private String orderType;
private String orderSource;
private String legNo;
private String startPlace;
private String endPlace;
private LocalDateTime startTime;
private LocalDateTime endTime;
private String orderMoney;
}

View File

@ -1,21 +1,29 @@
package com.chint.interfaces.rest.bpm.dto;
import com.chint.domain.aggregates.order.Leg;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
@Data
public class BaseChangeDto {
@Autowired
@JsonIgnore
private LegTrip legTrip;
private List<LegNewTrip> JT_FI_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填
private List<LegOldTrip> JT_FI_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填
private List<LegChangeTrip> JT_FI_CLBGSQ_ITEM_ChangeTrip;//变更行程信息 是否必填
public BaseChangeDto addLegNewTrip(Leg leg) {
if (JT_FI_CLBGSQ_ITEM_NewTrip == null) {
JT_FI_CLBGSQ_ITEM_NewTrip = new ArrayList<>();
}
JT_FI_CLBGSQ_ITEM_NewTrip.add(LegNewTrip.of(leg));
JT_FI_CLBGSQ_ITEM_NewTrip.add(legTrip.ofLegNewTrip(leg));
return this;
}
@ -23,7 +31,7 @@ public class BaseChangeDto {
if (JT_FI_CLBGSQ_ITEM_OldTrip == null) {
JT_FI_CLBGSQ_ITEM_OldTrip = new ArrayList<>();
}
JT_FI_CLBGSQ_ITEM_OldTrip.add(LegOldTrip.of(leg));
JT_FI_CLBGSQ_ITEM_OldTrip.add(legTrip.ofLegOldTrip(leg));
return this;
}
@ -31,7 +39,7 @@ public class BaseChangeDto {
if (JT_FI_CLBGSQ_ITEM_ChangeTrip == null) {
JT_FI_CLBGSQ_ITEM_ChangeTrip = new ArrayList<>();
}
JT_FI_CLBGSQ_ITEM_ChangeTrip.add(LegChangeTrip.of(leg));
JT_FI_CLBGSQ_ITEM_ChangeTrip.add(legTrip.ofLegChangeTrip(leg));
return this;
}
}

View File

@ -1,8 +1,10 @@
package com.chint.interfaces.rest.bpm.dto;
import com.chint.domain.aggregates.order.Leg;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
@ -13,6 +15,11 @@ import java.util.List;
@Data
@Accessors(chain = true)
public class JTH3ChangeDto {
@Autowired
@JsonIgnore
private LegTrip legTrip;
private String StartTime;//出差开始时间 是否必填
private String EndTime;//出差结束时间 是否必填
private String Reason;//出差说明 是否必填
@ -25,7 +32,7 @@ public class JTH3ChangeDto {
if (JT_FI_CLBGSQ_ITEM_NewTrip == null) {
JT_FI_CLBGSQ_ITEM_NewTrip = new ArrayList<>();
}
JT_FI_CLBGSQ_ITEM_NewTrip.add(LegNewTrip.of(leg));
JT_FI_CLBGSQ_ITEM_NewTrip.add(legTrip.ofLegNewTrip(leg));
return this;
}
@ -33,7 +40,7 @@ public class JTH3ChangeDto {
if (JT_FI_CLBGSQ_ITEM_OldTrip == null) {
JT_FI_CLBGSQ_ITEM_OldTrip = new ArrayList<>();
}
JT_FI_CLBGSQ_ITEM_OldTrip.add(LegOldTrip.of(leg));
JT_FI_CLBGSQ_ITEM_OldTrip.add(legTrip.ofLegOldTrip(leg));
return this;
}
@ -41,7 +48,7 @@ public class JTH3ChangeDto {
if (JT_FI_CLBGSQ_ITEM_ChangeTrip == null) {
JT_FI_CLBGSQ_ITEM_ChangeTrip = new ArrayList<>();
}
JT_FI_CLBGSQ_ITEM_ChangeTrip.add(LegChangeTrip.of(leg));
JT_FI_CLBGSQ_ITEM_ChangeTrip.add(legTrip.ofLegChangeTrip(leg));
return this;
}
}

View File

@ -16,20 +16,5 @@ public class LegChangeTrip {
private String edDate;//结束时间 是否必填
private String Reason;//新增行程原因 是否必填
public static LegChangeTrip of(Leg leg) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LegChangeTrip legChangeTrip = new LegChangeTrip();
legChangeTrip.setAllowProductTypes(leg.getLegTypeName())
.setBsDate(formatter.format(leg.getStartTime()))
.setEdDate(formatter.format(leg.getStartTime()))
.setReason(null);
if (leg.getOriginId() != null) {
legChangeTrip.setDepartCitiesName(leg.getOriginLocation().getLocationName());
}
if (leg.getDestinationId() != null) {
legChangeTrip.setArriveCitiesName(leg.getDestinationLocation().getLocationName());
}
return legChangeTrip;
}
}

View File

@ -3,9 +3,12 @@ package com.chint.interfaces.rest.bpm.dto;
import com.chint.domain.aggregates.order.Leg;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;
import java.time.format.DateTimeFormatter;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI;
@Data
@Accessors(chain = true)
public class LegNewTrip {
@ -16,19 +19,4 @@ public class LegNewTrip {
private String edDate;//结束时间 是否必填
private String Reason;//新增行程原因 是否必填
public static LegNewTrip of(Leg leg) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LegNewTrip legNewTrip = new LegNewTrip();
legNewTrip.setAllowProductTypes(leg.getLegTypeName())
.setBsDate(formatter.format(leg.getStartTime()))
.setEdDate(formatter.format(leg.getStartTime()))
.setReason(null);
if(leg.getOriginId() != null){
legNewTrip.setDepartCitiesName(leg.getOriginLocation().getLocationName());
}
if(leg.getDestinationId() != null){
legNewTrip.setArriveCitiesName(leg.getDestinationLocation().getLocationName());
}
return legNewTrip;
}
}

View File

@ -15,18 +15,5 @@ public class LegOldTrip {
private String bsDate;//开始时间 是否必填
private String edDate;//结束时间 是否必填
public static LegOldTrip of(Leg leg) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LegOldTrip legChangeTrip = new LegOldTrip();
legChangeTrip.setAllowProductTypes(leg.getLegTypeName())
.setBsDate(formatter.format(leg.getStartTime()))
.setEdDate(formatter.format(leg.getStartTime()));
if(leg.getOriginId() != null){
legChangeTrip.setDepartCitiesName(leg.getOriginLocation().getLocationName());
}
if(leg.getDestinationId() != null){
legChangeTrip.setArriveCitiesName(leg.getDestinationLocation().getLocationName());
}
return legChangeTrip;
}
}

View File

@ -0,0 +1,122 @@
package com.chint.interfaces.rest.bpm.dto;
import com.chint.domain.aggregates.order.Leg;
import com.chint.domain.aggregates.order.LegExtensionField;
import com.chint.domain.aggregates.order.Location;
import com.chint.domain.repository.LocationRepository;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.format.DateTimeFormatter;
import java.util.*;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI;
@Service
public class LegTrip {
@Autowired
private LocationRepository locationRepository;
public LegNewTrip ofLegNewTrip(Leg leg) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LegNewTrip legNewTrip = new LegNewTrip();
legNewTrip.setAllowProductTypes(leg.getLegTypeName())
.setBsDate(formatter.format(leg.getStartTime()))
.setEdDate(formatter.format(leg.getStartTime()))
.setReason(null);
if (leg.getOriginId() != null) {
legNewTrip.setDepartCitiesName(leg.getOriginLocation().getLocationName());
//如果是打车
if (leg.getLegType().equals(LEG_TYPE_TAXI) && StringUtils.isBlank(leg.getOriginLocation().getLocationName())) {
legNewTrip.setDepartCitiesName(getCarCity(leg));
}
}
if (leg.getDestinationId() != null) {
legNewTrip.setArriveCitiesName(leg.getDestinationLocation().getLocationName());
//如果是打车
if (leg.getLegType().equals(LEG_TYPE_TAXI) && StringUtils.isBlank(leg.getDestinationLocation().getLocationName())) {
legNewTrip.setArriveCitiesName(getCarCity(leg));
}
}
return legNewTrip;
}
public LegOldTrip ofLegOldTrip(Leg leg) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LegOldTrip legOldTrip = new LegOldTrip();
legOldTrip.setAllowProductTypes(leg.getLegTypeName())
.setBsDate(formatter.format(leg.getStartTime()))
.setEdDate(formatter.format(leg.getStartTime()));
if (leg.getOriginId() != null) {
legOldTrip.setDepartCitiesName(leg.getOriginLocation().getLocationName());
//如果是打车
if (leg.getLegType().equals(LEG_TYPE_TAXI) && StringUtils.isBlank(leg.getOriginLocation().getLocationName())) {
legOldTrip.setDepartCitiesName(getCarCity(leg));
}
}
if (leg.getDestinationId() != null) {
legOldTrip.setArriveCitiesName(leg.getDestinationLocation().getLocationName());
//如果是打车
if (leg.getLegType().equals(LEG_TYPE_TAXI) && StringUtils.isBlank(leg.getDestinationLocation().getLocationName())) {
legOldTrip.setArriveCitiesName(getCarCity(leg));
}
}
return legOldTrip;
}
public LegChangeTrip ofLegChangeTrip(Leg leg) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LegChangeTrip legChangeTrip = new LegChangeTrip();
legChangeTrip.setAllowProductTypes(leg.getLegTypeName())
.setBsDate(formatter.format(leg.getStartTime()))
.setEdDate(formatter.format(leg.getStartTime()))
.setReason(null);
if (leg.getOriginId() != null) {
legChangeTrip.setDepartCitiesName(leg.getOriginLocation().getLocationName());
//如果是打车
if (leg.getLegType().equals(LEG_TYPE_TAXI) && StringUtils.isBlank(leg.getOriginLocation().getLocationName())) {
legChangeTrip.setDepartCitiesName(getCarCity(leg));
}
}
if (leg.getDestinationId() != null) {
legChangeTrip.setArriveCitiesName(leg.getDestinationLocation().getLocationName());
//如果是打车
if (leg.getLegType().equals(LEG_TYPE_TAXI) && StringUtils.isBlank(leg.getDestinationLocation().getLocationName())) {
legChangeTrip.setArriveCitiesName(getCarCity(leg));
}
}
return legChangeTrip;
}
/**
* 获取打车城市
*/
public String getCarCity(Leg leg) {
StringBuilder carCityBuilder = new StringBuilder();
LegExtensionField legExtensionField = leg.getLegExtensionField();
if (Objects.nonNull(legExtensionField)) {
List<String> cityNameList = legExtensionField
.getLocationIdsAsLong()
.stream()
.map(it -> {
Location location = locationRepository.findById(it);
return location.getLocationName();
}).toList();
for (String cityName : cityNameList) {
carCityBuilder.append(cityName).append(",");
}
}
// 移除最后一个逗号
if (!carCityBuilder.isEmpty()) {
carCityBuilder.setLength(carCityBuilder.length() - 1);
}
//去重
String cityStr = carCityBuilder.toString();
String[] array = cityStr.split(",");
Set<String> set = new LinkedHashSet<>(Arrays.asList(array));
return String.join(",", set);
}
}

View File

@ -1,14 +1,20 @@
package com.chint.interfaces.rest.bpm.dto;
import com.chint.domain.aggregates.order.Leg;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
@Data
@Accessors(chain = true)
public class XNChangeDto {
@Autowired
@JsonIgnore
private LegTrip legTrip;
private String StartTime;//出差开始时间 是否必填
private String EndTime;//出差结束时间 是否必填
private String Reason;//出差说明 是否必填
@ -21,7 +27,7 @@ public class XNChangeDto {
if (XN_AS_CLBGSQ_ITEM_NewTrip == null) {
XN_AS_CLBGSQ_ITEM_NewTrip = new ArrayList<>();
}
XN_AS_CLBGSQ_ITEM_NewTrip.add(LegNewTrip.of(leg));
XN_AS_CLBGSQ_ITEM_NewTrip.add(legTrip.ofLegNewTrip(leg));
return this;
}
@ -29,7 +35,7 @@ public class XNChangeDto {
if (XN_AS_CLBGSQ_ITEM_OldTrip == null) {
XN_AS_CLBGSQ_ITEM_OldTrip = new ArrayList<>();
}
XN_AS_CLBGSQ_ITEM_OldTrip.add(LegOldTrip.of(leg));
XN_AS_CLBGSQ_ITEM_OldTrip.add(legTrip.ofLegOldTrip(leg));
return this;
}
@ -37,7 +43,7 @@ public class XNChangeDto {
if (XN_AS_CLBGSQ_ITEM_ChangeTrip == null) {
XN_AS_CLBGSQ_ITEM_ChangeTrip = new ArrayList<>();
}
XN_AS_CLBGSQ_ITEM_ChangeTrip.add(LegChangeTrip.of(leg));
XN_AS_CLBGSQ_ITEM_ChangeTrip.add(legTrip.ofLegChangeTrip(leg));
return this;
}
}

View File

@ -1,8 +1,10 @@
package com.chint.interfaces.rest.bpm.dto;
import com.chint.domain.aggregates.order.Leg;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
@ -10,6 +12,11 @@ import java.util.List;
@Data
@Accessors(chain = true)
public class ZWChangeDto{
@Autowired
@JsonIgnore
private LegTrip legTrip;
private String StartTime;//出差开始时间 是否必填
private String EndTime;//出差结束时间 是否必填
private String Reason;//出差说明 是否必填
@ -21,7 +28,7 @@ public class ZWChangeDto{
if (ZW_AS_CLBGSQ_ITEM_NewTrip == null) {
ZW_AS_CLBGSQ_ITEM_NewTrip = new ArrayList<>();
}
ZW_AS_CLBGSQ_ITEM_NewTrip.add(LegNewTrip.of(leg));
ZW_AS_CLBGSQ_ITEM_NewTrip.add(legTrip.ofLegNewTrip(leg));
return this;
}
@ -29,7 +36,7 @@ public class ZWChangeDto{
if (ZW_AS_CLBGSQ_ITEM_OldTrip == null) {
ZW_AS_CLBGSQ_ITEM_OldTrip = new ArrayList<>();
}
ZW_AS_CLBGSQ_ITEM_OldTrip.add(LegOldTrip.of(leg));
ZW_AS_CLBGSQ_ITEM_OldTrip.add(legTrip.ofLegOldTrip(leg));
return this;
}
@ -37,7 +44,7 @@ public class ZWChangeDto{
if (ZW_AS_CLBGSQ_ITEM_ChangeTrip == null) {
ZW_AS_CLBGSQ_ITEM_ChangeTrip = new ArrayList<>();
}
ZW_AS_CLBGSQ_ITEM_ChangeTrip.add(LegChangeTrip.of(leg));
ZW_AS_CLBGSQ_ITEM_ChangeTrip.add(legTrip.ofLegChangeTrip(leg));
return this;
}
}