md
This commit is contained in:
parent
1532574b6e
commit
f04499fe04
@ -15,7 +15,7 @@ import java.util.List;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xdadan.erp.emis.domain.exception.CalcException;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.emis.domain.vo.*;
|
||||
import com.xdadan.erp.emis.service.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -68,9 +68,15 @@ public class EmisWaybillController extends BaseController
|
||||
}
|
||||
|
||||
return AjaxResult.success("获取成功",waybillOrder);
|
||||
}catch (Exception ex){
|
||||
}
|
||||
catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
return AjaxResult.error(ex.getMessage());
|
||||
// 返回子定义异常
|
||||
if(ex instanceof EmisBizError){
|
||||
return AjaxResult.error("("+((EmisBizError)ex).getErrorCode()+")"+ex.getMessage());
|
||||
}
|
||||
|
||||
return AjaxResult.error("服务器异常,联系客服");
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,8 +100,17 @@ public class EmisWaybillController extends BaseController
|
||||
// jObjOut.put("prodName", waybillOrder.getProductType());
|
||||
|
||||
return AjaxResult.success("下单成功", jObjOut);
|
||||
}catch (Exception ex){
|
||||
}catch(EmisBizError ex){
|
||||
ex.printStackTrace();
|
||||
return AjaxResult.error("("+ex.getErrorCode()+")"+ex.getMessage());
|
||||
}
|
||||
catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
// 返回子定义异常
|
||||
if(ex instanceof EmisBizError){
|
||||
return AjaxResult.error("("+((EmisBizError)ex).getErrorCode()+")"+ex.getMessage());
|
||||
}
|
||||
|
||||
return AjaxResult.error("服务器异常,联系客服");
|
||||
}
|
||||
}
|
||||
@ -117,16 +132,15 @@ public class EmisWaybillController extends BaseController
|
||||
|
||||
return AjaxResult.success("计算成功", jObjFee);
|
||||
}
|
||||
catch(CalcException ex){
|
||||
catch(EmisBizError ex){
|
||||
ex.printStackTrace();
|
||||
// (E3001)参数不完整
|
||||
return AjaxResult.error("("+ex.getErrorCode()+")"+ex.getMessage());
|
||||
}
|
||||
catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
// 返回子定义异常
|
||||
if(ex instanceof CalcException ){
|
||||
return AjaxResult.error("("+((CalcException)ex).getErrorCode()+")"+ex.getMessage());
|
||||
if(ex instanceof EmisBizError){
|
||||
return AjaxResult.error("("+((EmisBizError)ex).getErrorCode()+")"+ex.getMessage());
|
||||
}
|
||||
|
||||
return AjaxResult.error("服务器异常,联系客服");
|
||||
@ -150,8 +164,8 @@ public class EmisWaybillController extends BaseController
|
||||
catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
// 返回子定义异常
|
||||
if(ex instanceof CalcException ){
|
||||
return AjaxResult.error("("+((CalcException)ex).getErrorCode()+")"+ex.getMessage());
|
||||
if(ex instanceof EmisBizError){
|
||||
return AjaxResult.error("("+((EmisBizError)ex).getErrorCode()+")"+ex.getMessage());
|
||||
}
|
||||
|
||||
return AjaxResult.error("服务器异常,联系客服");
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
package com.xdadan.erp.emis.domain.exception;
|
||||
|
||||
public class CalcException extends Exception {
|
||||
|
||||
private String errorCode;
|
||||
|
||||
public CalcException(String errorCode, String message) {
|
||||
super(message);
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.xdadan.erp.emis.domain.exception;
|
||||
|
||||
public class EmisBizError extends Exception {
|
||||
|
||||
private EmisBizErrorType errorCode;
|
||||
|
||||
public EmisBizError(EmisBizErrorType errorCode, String errorMessage) {
|
||||
super(errorMessage);
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public EmisBizErrorType getErrorCode() {
|
||||
return errorCode;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.xdadan.erp.emis.domain.exception;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum EmisBizErrorType {
|
||||
|
||||
PARAM_ERROR1("E0001", "参数不完整"),
|
||||
CALC_FEE_ERROR("E0001", "运费计算错误"),
|
||||
CALC_WEIGHT_ERROR("E0002", "重量计算错误"),
|
||||
|
||||
|
||||
CALC_QUOTE_ERROR("E3002", "报价未配置"),
|
||||
|
||||
|
||||
BILL_LOCK("E9001", "已锁账,不允许修改"),
|
||||
|
||||
SUCCESS("0000", "成功"),
|
||||
FAIL("9999", "失败"),
|
||||
|
||||
;
|
||||
|
||||
private String errorCode;
|
||||
private String errorMessage;
|
||||
|
||||
EmisBizErrorType(String errorCode, String errorMessage) {
|
||||
this.errorCode = errorCode;
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
}
|
||||
@ -146,6 +146,24 @@ public class EmisBaseService {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 超时锁账时间
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static boolean isOutTime(Date data) {
|
||||
//24小时
|
||||
long house=60*60*24;
|
||||
//系统当前时间,
|
||||
long currentTime = System.currentTimeMillis()/1000;
|
||||
//业务时间
|
||||
long endTime=data.getTime()/1000;
|
||||
if((endTime + house) < currentTime ){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算预估到达时间
|
||||
|
||||
@ -11,7 +11,7 @@ package com.xdadan.erp.emis.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.xdadan.erp.emis.domain.EmisWaybill;
|
||||
import com.xdadan.erp.emis.domain.exception.CalcException;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.emis.domain.vo.WaybillOrder;
|
||||
|
||||
/**
|
||||
@ -99,17 +99,17 @@ public interface IEmisWaybillService
|
||||
|
||||
public WaybillOrder getWaybillDetail(String billCode);
|
||||
|
||||
// public int realSubmitOrder(WaybillOrder waybillOrder) throws Exception;
|
||||
|
||||
public int realSubmitOrder(EmisWaybill emisWaybill) throws Exception;
|
||||
// 账单保存
|
||||
public int realSubmitOrder(EmisWaybill emisWaybill) throws EmisBizError;
|
||||
|
||||
|
||||
//计算运单费用
|
||||
public void calcWaybillFee(EmisWaybill emisWaybill) throws CalcException;
|
||||
public void calcWaybillFee(EmisWaybill emisWaybill) throws EmisBizError;
|
||||
|
||||
|
||||
// 计算结算重量
|
||||
public void calcSettledWeight(EmisWaybill emisWaybill) throws CalcException;
|
||||
public void calcSettledWeight(EmisWaybill emisWaybill) throws EmisBizError;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -24,7 +24,8 @@ import com.googlecode.aviator.AviatorEvaluator;
|
||||
import com.xdadan.erp.common.utils.DateUtils;
|
||||
import com.xdadan.erp.common.utils.SecurityUtils;
|
||||
import com.xdadan.erp.emis.domain.*;
|
||||
import com.xdadan.erp.emis.domain.exception.CalcException;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizErrorType;
|
||||
import com.xdadan.erp.emis.domain.vo.*;
|
||||
import com.xdadan.erp.emis.mapper.EmisTransLineMapper;
|
||||
import com.xdadan.erp.emis.service.*;
|
||||
@ -158,19 +159,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
return emisWaybillMapper.deleteEmisWaybillById(id);
|
||||
}
|
||||
|
||||
public static boolean isOutTime(Date data) throws Exception {
|
||||
//24小时
|
||||
long house=60*60*24;
|
||||
//系统当前时间,
|
||||
long currentTime = System.currentTimeMillis()/1000;
|
||||
//业务时间
|
||||
long endTime=data.getTime()/1000;
|
||||
if((endTime + house) < currentTime ){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@ -210,7 +199,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int realSubmitOrder(EmisWaybill emisWaybillSave) throws Exception {
|
||||
public int realSubmitOrder(EmisWaybill emisWaybillSave) throws EmisBizError {
|
||||
|
||||
boolean isNew = true;
|
||||
EmisWaybill emisWaybillOld = null;
|
||||
@ -231,10 +220,9 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
|
||||
// 判断运单状态,如果已锁账,则不允许修改
|
||||
// 下单超过 24小时
|
||||
|
||||
if(emisWaybillOld!=null ) {
|
||||
if ("1".equals(emisWaybillOld.getBlBill()) || isOutTime(emisWaybillOld.getCreateTime())) {
|
||||
throw new Exception("已锁账,不允许修改");
|
||||
throw new EmisBizError(EmisBizErrorType.BILL_LOCK, "已锁账,不允许修改");
|
||||
}
|
||||
}
|
||||
|
||||
@ -351,7 +339,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void calcWaybillFee(EmisWaybill emisWaybill) throws CalcException {
|
||||
public void calcWaybillFee(EmisWaybill emisWaybill) throws EmisBizError {
|
||||
|
||||
/**
|
||||
* 计算逻辑,获取表达式进行计算
|
||||
@ -363,7 +351,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
emisWaybill.getCalcFeeType()
|
||||
)
|
||||
){
|
||||
throw new CalcException("E3001","参数不完整");
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "参数不完整");
|
||||
}
|
||||
|
||||
List<EmisQuotePrice> emisQuotePriceList=getValidQuotePriceList(emisWaybill.getProductType(),
|
||||
@ -372,7 +360,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
|
||||
|
||||
if(CollectionUtils.isEmpty(emisQuotePriceList)){
|
||||
throw new CalcException("E3002","报价未配置");
|
||||
throw new EmisBizError(EmisBizErrorType.CALC_QUOTE_ERROR, "报价未配置");
|
||||
}
|
||||
|
||||
// 根据表达式计算费用
|
||||
@ -462,16 +450,16 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calcSettledWeight(EmisWaybill emisWaybill) throws CalcException {
|
||||
public void calcSettledWeight(EmisWaybill emisWaybill) throws EmisBizError {
|
||||
|
||||
if (
|
||||
StringUtils.isEmpty(emisWaybill.getProductType())
|
||||
|| emisWaybill.getBillWeight() == null
|
||||
|| emisWaybill.getTotalVolume() == null
|
||||
)
|
||||
{
|
||||
{
|
||||
|
||||
throw new CalcException("E2001", "参数不完整");
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "参数不完整");
|
||||
}
|
||||
|
||||
double billWeight=emisWaybill.getBillWeight().doubleValue();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user