md
This commit is contained in:
parent
bd18753775
commit
b53eecbdb1
@ -264,6 +264,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
@Transactional
|
@Transactional
|
||||||
public int realSubmitOrder(EmisWaybill emisWaybillSave) throws EmisBizError {
|
public int realSubmitOrder(EmisWaybill emisWaybillSave) throws EmisBizError {
|
||||||
|
|
||||||
|
|
||||||
boolean isNew = true;
|
boolean isNew = true;
|
||||||
EmisWaybill emisWaybillOld = null;
|
EmisWaybill emisWaybillOld = null;
|
||||||
|
|
||||||
@ -301,6 +302,10 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
addWayBill(emisWaybillSave);
|
addWayBill(emisWaybillSave);
|
||||||
}else{
|
}else{
|
||||||
emisWaybillSave.setId(emisWaybillOld.getId());
|
emisWaybillSave.setId(emisWaybillOld.getId());
|
||||||
|
|
||||||
|
// 把历史发货日期带过来用于重新计算预估到到时间
|
||||||
|
emisWaybillSave.setSendDate(emisWaybillOld.getSendDate());
|
||||||
|
|
||||||
updateWayBill(emisWaybillSave);
|
updateWayBill(emisWaybillSave);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,12 +313,14 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void calcWayBillCommonInfo(EmisWaybill emisWaybillSave) throws EmisBizError {
|
private void calcWayBillCommonInfo(EmisWaybill emisWaybillSave,boolean isNew) throws EmisBizError {
|
||||||
|
|
||||||
String orderSn = WaybillHelper.genOrderSn();
|
String orderSn = WaybillHelper.genOrderSn();
|
||||||
|
|
||||||
// 订单号
|
// 订单号
|
||||||
emisWaybillSave.setOrderSn(orderSn);
|
if(isNew) {
|
||||||
|
emisWaybillSave.setOrderSn(orderSn);
|
||||||
|
}
|
||||||
|
|
||||||
// 登记网点
|
// 登记网点
|
||||||
emisWaybillSave.setRegisterSiteCode(getCurrentUser().getOwnerSiteCode());
|
emisWaybillSave.setRegisterSiteCode(getCurrentUser().getOwnerSiteCode());
|
||||||
@ -322,48 +329,52 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
|
|
||||||
|
|
||||||
// 发件网点
|
// 发件网点
|
||||||
String sendSiteCode=emisWaybillSave.getSendSiteCode();
|
if(StringUtils.isEmpty(emisWaybillSave.getSendSiteCode())){
|
||||||
if(StringUtils.isEmpty(sendSiteCode)){
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"寄件网点必填");
|
||||||
sendSiteCode = getCurrentUser().getOwnerSiteCode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EmisSite sendSite = getSiteByCode(sendSiteCode);
|
// 目的网点
|
||||||
emisWaybillSave.setSendSiteCode(sendSite.getSiteCode());
|
if(StringUtils.isEmpty(emisWaybillSave.getDispatchUnderlingSiteCode())){
|
||||||
emisWaybillSave.setSendSiteName(sendSite.getSiteName());
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"目的网点必填");
|
||||||
|
}
|
||||||
|
|
||||||
// 派件网点
|
// 订单运单初始状态 订单为已接单,运单未初始,待揽收
|
||||||
emisWaybillSave.setDispatchSiteCode(emisWaybillSave.getDispatchUnderlingSiteCode());
|
emisWaybillSave.setOrderStatus("1");
|
||||||
|
|
||||||
// 订单运单初始状态
|
|
||||||
emisWaybillSave.setOrderStatus("0");
|
|
||||||
emisWaybillSave.setWaybillStatus("0");
|
emisWaybillSave.setWaybillStatus("0");
|
||||||
|
|
||||||
// 目的网点3段码
|
// 计算三段码 目的网点2字码+目的地名称
|
||||||
|
|
||||||
|
|
||||||
String destSite3Code = "";
|
String destSite3Code = "";
|
||||||
EmisSite destSite=getSiteByCode(emisWaybillSave.getDispatchUnderlingSiteCode());
|
EmisSite destSite=getSiteByCode(emisWaybillSave.getDispatchUnderlingSiteCode());
|
||||||
if(destSite!=null){
|
if(destSite!=null){
|
||||||
destSite3Code=destSite.getSizeCode2();
|
destSite3Code=destSite.getSizeCode2();
|
||||||
}
|
}
|
||||||
|
// 目的地名称
|
||||||
// 三段码
|
|
||||||
EmisDestination destination=getDestinationByCode(emisWaybillSave.getDestinationCode());
|
EmisDestination destination=getDestinationByCode(emisWaybillSave.getDestinationCode());
|
||||||
String destName="";
|
String destName="";
|
||||||
if(destination!=null){
|
if(destination!=null){
|
||||||
destName=destination.getDestName();
|
destName=destination.getDestName();
|
||||||
}
|
}
|
||||||
|
|
||||||
String thirdCode="["+emisWaybillSave.getSendSiteName()+'-'+destName+"]["+destSite3Code+"]";
|
String thirdCode="["+emisWaybillSave.getSendSiteName()+'-'+destName+"]["+destSite3Code+"]";
|
||||||
emisWaybillSave.setThirdCode(thirdCode);
|
emisWaybillSave.setThirdCode(thirdCode);
|
||||||
|
|
||||||
// 下单时间
|
// 下单时间
|
||||||
emisWaybillSave.setOrderDate(new Date());
|
emisWaybillSave.setOrderDate(emisWaybillSave.getSendDate());
|
||||||
|
|
||||||
// 订单类型为正式单
|
// 订单类型为正式单
|
||||||
emisWaybillSave.setOrderType("1");
|
emisWaybillSave.setOrderType("1");
|
||||||
|
|
||||||
// 寄件地址
|
// 寄件地址
|
||||||
|
if(StringUtils.isAnyEmpty(
|
||||||
|
emisWaybillSave.getSendCountry(),
|
||||||
|
emisWaybillSave.getSendName(),
|
||||||
|
emisWaybillSave.getSendMobile(),
|
||||||
|
emisWaybillSave.getSendProvince(),
|
||||||
|
emisWaybillSave.getSendAddress()
|
||||||
|
)
|
||||||
|
){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"寄件人信息不完整,名称, 电话,国家,省份,地址必填");
|
||||||
|
}
|
||||||
|
|
||||||
EmisCustomerAddress sendAddress = new EmisCustomerAddress();
|
EmisCustomerAddress sendAddress = new EmisCustomerAddress();
|
||||||
sendAddress.setCountry(emisWaybillSave.getSendCountry());
|
sendAddress.setCountry(emisWaybillSave.getSendCountry());
|
||||||
sendAddress.setName(emisWaybillSave.getSendName());
|
sendAddress.setName(emisWaybillSave.getSendName());
|
||||||
@ -380,6 +391,18 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
sendAddress.setAddressType("1");
|
sendAddress.setAddressType("1");
|
||||||
|
|
||||||
// 收件地址
|
// 收件地址
|
||||||
|
if(StringUtils.isAnyEmpty(
|
||||||
|
emisWaybillSave.getReceiveCountry(),
|
||||||
|
emisWaybillSave.getReceiveName(),
|
||||||
|
emisWaybillSave.getReceiveMobile(),
|
||||||
|
emisWaybillSave.getReceiveProvince(),
|
||||||
|
emisWaybillSave.getReceiveAddress()
|
||||||
|
)
|
||||||
|
|
||||||
|
){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"收件人信息不完整,名称, 电话,国家,省份,地址必填");
|
||||||
|
}
|
||||||
|
|
||||||
EmisCustomerAddress recieveAddress = new EmisCustomerAddress();
|
EmisCustomerAddress recieveAddress = new EmisCustomerAddress();
|
||||||
recieveAddress.setCountry(emisWaybillSave.getReceiveCountry());
|
recieveAddress.setCountry(emisWaybillSave.getReceiveCountry());
|
||||||
recieveAddress.setName(emisWaybillSave.getReceiveName());
|
recieveAddress.setName(emisWaybillSave.getReceiveName());
|
||||||
@ -399,6 +422,10 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
String customerCode=null;
|
String customerCode=null;
|
||||||
String customerName=null;
|
String customerName=null;
|
||||||
|
|
||||||
|
if( emisWaybillSave.getPaymentType()==null) {
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"支付方式必填");
|
||||||
|
}
|
||||||
|
|
||||||
// 月结客户直接根据月结编号获取客户编码和名称
|
// 月结客户直接根据月结编号获取客户编码和名称
|
||||||
if(
|
if(
|
||||||
"2".equals(emisWaybillSave.getPaymentType())
|
"2".equals(emisWaybillSave.getPaymentType())
|
||||||
@ -497,6 +524,16 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
emisWaybillSave.setCustomerCode(customerCode);
|
emisWaybillSave.setCustomerCode(customerCode);
|
||||||
emisWaybillSave.setCustomerName(customerName);
|
emisWaybillSave.setCustomerName(customerName);
|
||||||
|
|
||||||
|
if( StringUtils.isAnyEmpty(
|
||||||
|
emisWaybillSave.getTransLineType(),
|
||||||
|
emisWaybillSave.getProductType()
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"线路、产品必填");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 获取泡重比
|
// 获取泡重比
|
||||||
EmisTransLine emisTransLine = getTransLineByCode(emisWaybillSave.getTransLineType());
|
EmisTransLine emisTransLine = getTransLineByCode(emisWaybillSave.getTransLineType());
|
||||||
emisWaybillSave.setMeterType(emisTransLine.getMeterRate());
|
emisWaybillSave.setMeterType(emisTransLine.getMeterRate());
|
||||||
@ -509,6 +546,11 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
emisWaybillSave.setSendDate(new Date());
|
emisWaybillSave.setSendDate(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isNew) {
|
||||||
|
if( emisWaybillSave.getSendDate()==null ){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"发件日期必填");
|
||||||
|
}
|
||||||
|
}
|
||||||
// 开单当天不算时效
|
// 开单当天不算时效
|
||||||
Date estDate = getEstimateDate(
|
Date estDate = getEstimateDate(
|
||||||
emisWaybillSave.getSendDate(),emisWaybillSave.getProductType(),
|
emisWaybillSave.getSendDate(),emisWaybillSave.getProductType(),
|
||||||
@ -523,7 +565,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
if("1".equals(emisWaybillSave.getBlGenSubbill()) ){
|
if("1".equals(emisWaybillSave.getBlGenSubbill()) ){
|
||||||
// 子单号拼接
|
// 子单号拼接
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for(int i=0;i<emisWaybillSave.getParcelQty().intValue() && i<20;i++){
|
for(int i=0;i<emisWaybillSave.getParcelQty().intValue() && i<15;i++){
|
||||||
sb.append(emisWaybillSave.getBillCode()+ StringUtils.leftPad(String.valueOf(i),4,"0")+",");
|
sb.append(emisWaybillSave.getBillCode()+ StringUtils.leftPad(String.valueOf(i),4,"0")+",");
|
||||||
}
|
}
|
||||||
emisWaybillSave.setBillCodeSub(sb.toString());
|
emisWaybillSave.setBillCodeSub(sb.toString());
|
||||||
@ -546,7 +588,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 公共计算部分
|
// 公共计算部分
|
||||||
calcWayBillCommonInfo(emisWaybillSave);
|
calcWayBillCommonInfo(emisWaybillSave,true);
|
||||||
|
|
||||||
|
|
||||||
//补齐数据
|
//补齐数据
|
||||||
@ -590,7 +632,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
private void updateWayBill(EmisWaybill emisWaybillSave) throws EmisBizError {
|
private void updateWayBill(EmisWaybill emisWaybillSave) throws EmisBizError {
|
||||||
|
|
||||||
// 公共计算部分
|
// 公共计算部分
|
||||||
calcWayBillCommonInfo(emisWaybillSave);
|
calcWayBillCommonInfo(emisWaybillSave,false);
|
||||||
|
|
||||||
emisWaybillSave.preUpdate();
|
emisWaybillSave.preUpdate();
|
||||||
// 基础信息更新
|
// 基础信息更新
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user