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