变更打车添加城市字段bug处理
This commit is contained in:
parent
89e0e49b40
commit
9ec2c25fbe
|
@ -3,6 +3,7 @@ package com.chint.domain.repository;
|
|||
import com.chint.application.dtos.LocationParam;
|
||||
import com.chint.domain.aggregates.order.Location;
|
||||
import com.chint.infrastructure.util.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package com.chint.infrastructure.util;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ApplicationContextUtils implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext applicationContext;
|
||||
|
||||
//方式一:传Class对象
|
||||
//新建对象实例并注入其他springbean
|
||||
public static <T> T newAutoWiredInstance(Class<T> beanClass) {
|
||||
@SuppressWarnings("unchecked")
|
||||
T instance = (T) applicationContext.getAutowireCapableBeanFactory()
|
||||
.autowire(beanClass, AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT, true);
|
||||
return instance;
|
||||
}
|
||||
|
||||
//方式二:传bean对象
|
||||
//已经new出来的对象进行注入
|
||||
public static <T> T autowire(T bean) {
|
||||
applicationContext.getAutowireCapableBeanFactory()
|
||||
.autowireBeanProperties(bean, AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT, true);
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
ApplicationContextUtils.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.chint.interfaces.rest.bpm.dto;
|
||||
|
||||
import com.chint.domain.aggregates.order.Leg;
|
||||
import com.chint.infrastructure.util.ApplicationContextUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -19,7 +20,7 @@ public class BaseChangeDto {
|
|||
if (JT_FI_CLBGSQ_ITEM_NewTrip == null) {
|
||||
JT_FI_CLBGSQ_ITEM_NewTrip = new ArrayList<>();
|
||||
}
|
||||
JT_FI_CLBGSQ_ITEM_NewTrip.add(new LegTrip().ofLegNewTrip(leg));
|
||||
JT_FI_CLBGSQ_ITEM_NewTrip.add(ApplicationContextUtils.newAutoWiredInstance(LegTrip.class).ofLegNewTrip(leg));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -27,7 +28,7 @@ public class BaseChangeDto {
|
|||
if (JT_FI_CLBGSQ_ITEM_OldTrip == null) {
|
||||
JT_FI_CLBGSQ_ITEM_OldTrip = new ArrayList<>();
|
||||
}
|
||||
JT_FI_CLBGSQ_ITEM_OldTrip.add(new LegTrip().ofLegOldTrip(leg));
|
||||
JT_FI_CLBGSQ_ITEM_OldTrip.add(ApplicationContextUtils.newAutoWiredInstance(LegTrip.class).ofLegOldTrip(leg));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -35,7 +36,7 @@ public class BaseChangeDto {
|
|||
if (JT_FI_CLBGSQ_ITEM_ChangeTrip == null) {
|
||||
JT_FI_CLBGSQ_ITEM_ChangeTrip = new ArrayList<>();
|
||||
}
|
||||
JT_FI_CLBGSQ_ITEM_ChangeTrip.add(new LegTrip().ofLegChangeTrip(leg));
|
||||
JT_FI_CLBGSQ_ITEM_ChangeTrip.add(ApplicationContextUtils.newAutoWiredInstance(LegTrip.class).ofLegChangeTrip(leg));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.chint.interfaces.rest.bpm.dto;
|
||||
|
||||
import com.chint.domain.aggregates.order.Leg;
|
||||
import com.chint.infrastructure.util.ApplicationContextUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
@ -29,7 +30,7 @@ public class JTH3ChangeDto {
|
|||
if (JT_FI_CLBGSQ_ITEM_NewTrip == null) {
|
||||
JT_FI_CLBGSQ_ITEM_NewTrip = new ArrayList<>();
|
||||
}
|
||||
JT_FI_CLBGSQ_ITEM_NewTrip.add(new LegTrip().ofLegNewTrip(leg));
|
||||
JT_FI_CLBGSQ_ITEM_NewTrip.add(ApplicationContextUtils.newAutoWiredInstance(LegTrip.class).ofLegNewTrip(leg));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -37,7 +38,7 @@ public class JTH3ChangeDto {
|
|||
if (JT_FI_CLBGSQ_ITEM_OldTrip == null) {
|
||||
JT_FI_CLBGSQ_ITEM_OldTrip = new ArrayList<>();
|
||||
}
|
||||
JT_FI_CLBGSQ_ITEM_OldTrip.add(new LegTrip().ofLegOldTrip(leg));
|
||||
JT_FI_CLBGSQ_ITEM_OldTrip.add(ApplicationContextUtils.newAutoWiredInstance(LegTrip.class).ofLegOldTrip(leg));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -45,7 +46,7 @@ public class JTH3ChangeDto {
|
|||
if (JT_FI_CLBGSQ_ITEM_ChangeTrip == null) {
|
||||
JT_FI_CLBGSQ_ITEM_ChangeTrip = new ArrayList<>();
|
||||
}
|
||||
JT_FI_CLBGSQ_ITEM_ChangeTrip.add(new LegTrip().ofLegChangeTrip(leg));
|
||||
JT_FI_CLBGSQ_ITEM_ChangeTrip.add(ApplicationContextUtils.newAutoWiredInstance(LegTrip.class).ofLegChangeTrip(leg));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package com.chint.interfaces.rest.bpm.dto;
|
||||
|
||||
import com.chint.RouteApplication;
|
||||
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 com.chint.infrastructure.repository.LocationRepositoryImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
@ -28,17 +32,17 @@ public class LegTrip {
|
|||
.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.getLegType().equals(LEG_TYPE_TAXI) && leg.getOriginLocation() == null) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
//如果是打车
|
||||
if (leg.getLegType().equals(LEG_TYPE_TAXI) && leg.getDestinationLocation() == null) {
|
||||
legNewTrip.setArriveCitiesName(getCarCity(leg));
|
||||
}
|
||||
return legNewTrip;
|
||||
}
|
||||
|
@ -51,17 +55,17 @@ public class LegTrip {
|
|||
.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.getLegType().equals(LEG_TYPE_TAXI) && leg.getOriginLocation() == null) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
//如果是打车
|
||||
if (leg.getLegType().equals(LEG_TYPE_TAXI) && leg.getDestinationLocation() == null) {
|
||||
legOldTrip.setArriveCitiesName(getCarCity(leg));
|
||||
}
|
||||
return legOldTrip;
|
||||
}
|
||||
|
@ -76,17 +80,17 @@ public class LegTrip {
|
|||
|
||||
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.getLegType().equals(LEG_TYPE_TAXI) && leg.getOriginLocation() == null) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
//如果是打车
|
||||
if (leg.getLegType().equals(LEG_TYPE_TAXI) && leg.getDestinationLocation() == null) {
|
||||
legChangeTrip.setArriveCitiesName(getCarCity(leg));
|
||||
}
|
||||
return legChangeTrip;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.chint.interfaces.rest.bpm.dto;
|
||||
|
||||
import com.chint.domain.aggregates.order.Leg;
|
||||
import com.chint.infrastructure.util.ApplicationContextUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
@ -24,7 +25,7 @@ public class XNChangeDto {
|
|||
if (XN_AS_CLBGSQ_ITEM_NewTrip == null) {
|
||||
XN_AS_CLBGSQ_ITEM_NewTrip = new ArrayList<>();
|
||||
}
|
||||
XN_AS_CLBGSQ_ITEM_NewTrip.add(new LegTrip().ofLegNewTrip(leg));
|
||||
XN_AS_CLBGSQ_ITEM_NewTrip.add(ApplicationContextUtils.newAutoWiredInstance(LegTrip.class).ofLegNewTrip(leg));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -32,7 +33,7 @@ public class XNChangeDto {
|
|||
if (XN_AS_CLBGSQ_ITEM_OldTrip == null) {
|
||||
XN_AS_CLBGSQ_ITEM_OldTrip = new ArrayList<>();
|
||||
}
|
||||
XN_AS_CLBGSQ_ITEM_OldTrip.add(new LegTrip().ofLegOldTrip(leg));
|
||||
XN_AS_CLBGSQ_ITEM_OldTrip.add(ApplicationContextUtils.newAutoWiredInstance(LegTrip.class).ofLegOldTrip(leg));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -40,7 +41,7 @@ public class XNChangeDto {
|
|||
if (XN_AS_CLBGSQ_ITEM_ChangeTrip == null) {
|
||||
XN_AS_CLBGSQ_ITEM_ChangeTrip = new ArrayList<>();
|
||||
}
|
||||
XN_AS_CLBGSQ_ITEM_ChangeTrip.add(new LegTrip().ofLegChangeTrip(leg));
|
||||
XN_AS_CLBGSQ_ITEM_ChangeTrip.add(ApplicationContextUtils.newAutoWiredInstance(LegTrip.class).ofLegChangeTrip(leg));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.chint.interfaces.rest.bpm.dto;
|
||||
|
||||
import com.chint.domain.aggregates.order.Leg;
|
||||
import com.chint.infrastructure.util.ApplicationContextUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
@ -25,7 +26,7 @@ public class ZWChangeDto {
|
|||
if (ZW_AS_CLBGSQ_ITEM_NewTrip == null) {
|
||||
ZW_AS_CLBGSQ_ITEM_NewTrip = new ArrayList<>();
|
||||
}
|
||||
ZW_AS_CLBGSQ_ITEM_NewTrip.add(new LegTrip().ofLegNewTrip(leg));
|
||||
ZW_AS_CLBGSQ_ITEM_NewTrip.add(ApplicationContextUtils.newAutoWiredInstance(LegTrip.class).ofLegNewTrip(leg));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -33,7 +34,7 @@ public class ZWChangeDto {
|
|||
if (ZW_AS_CLBGSQ_ITEM_OldTrip == null) {
|
||||
ZW_AS_CLBGSQ_ITEM_OldTrip = new ArrayList<>();
|
||||
}
|
||||
ZW_AS_CLBGSQ_ITEM_OldTrip.add(new LegTrip().ofLegOldTrip(leg));
|
||||
ZW_AS_CLBGSQ_ITEM_OldTrip.add(ApplicationContextUtils.newAutoWiredInstance(LegTrip.class).ofLegOldTrip(leg));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -41,7 +42,7 @@ public class ZWChangeDto {
|
|||
if (ZW_AS_CLBGSQ_ITEM_ChangeTrip == null) {
|
||||
ZW_AS_CLBGSQ_ITEM_ChangeTrip = new ArrayList<>();
|
||||
}
|
||||
ZW_AS_CLBGSQ_ITEM_ChangeTrip.add(new LegTrip().ofLegChangeTrip(leg));
|
||||
ZW_AS_CLBGSQ_ITEM_ChangeTrip.add(ApplicationContextUtils.newAutoWiredInstance(LegTrip.class).ofLegChangeTrip(leg));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue