md
This commit is contained in:
parent
87cb20bdb3
commit
da5d54263a
@ -12,7 +12,9 @@
|
||||
package com.xdadan.erp.web.emis;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.xdadan.erp.common.annotation.filter.jackson.JacksonFilter;
|
||||
@ -21,6 +23,7 @@ import com.xdadan.erp.emis.domain.*;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.emis.domain.vo.scan.ScanInfo;
|
||||
import com.xdadan.erp.emis.domain.vo.scan.ScanResult;
|
||||
import com.xdadan.erp.emis.service.EmisBaseService;
|
||||
import com.xdadan.erp.emis.service.IEmisTmsTransPlanDtlService;
|
||||
import com.xdadan.erp.emis.service.IEmisWaybillService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -61,6 +64,9 @@ public class EmisTmsScanRecordController extends BaseController
|
||||
@Autowired
|
||||
private IEmisWaybillService emisWaybillService;
|
||||
|
||||
@Autowired
|
||||
private EmisBaseService emisBaseService;
|
||||
|
||||
@Autowired
|
||||
private IEmisTmsTransPlanDtlService emisTmsTransPlanDtlService;
|
||||
|
||||
@ -151,6 +157,37 @@ public class EmisTmsScanRecordController extends BaseController
|
||||
// return getDataTable(newList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询物流轨迹信息
|
||||
* @param trackingNo
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/queryWaybillTraceInfo")
|
||||
public AjaxResult queryWaybillTraceInfo(String trackingNo,String lang)
|
||||
{
|
||||
if(StringUtils.isEmpty(trackingNo)){
|
||||
return AjaxResult.error("跟踪号不能为空");
|
||||
}
|
||||
|
||||
String[] billCodeArr = trackingNo.split(",");
|
||||
// 最多不超过50个
|
||||
if(billCodeArr.length>50){
|
||||
return AjaxResult.error("每次最多不超过50单号");
|
||||
}
|
||||
|
||||
List<Map> rstList = new ArrayList();
|
||||
for (String billCode:billCodeArr) {
|
||||
Map<String,Object> rstMap = new HashMap<>();
|
||||
rstMap.put("billCode",billCode);
|
||||
List<Map> stepList=emisTmsScanRecordService.queryWaybillTraceInfo(billCode,lang);
|
||||
rstMap.put("steps",stepList);
|
||||
rstList.add(rstMap);
|
||||
}
|
||||
|
||||
return AjaxResult.success("查询成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询TMS扫描记录列表
|
||||
*/
|
||||
|
||||
@ -148,6 +148,31 @@ public class EmisWaybillController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Log(title = "运费试算", businessType = BusinessType.OTHER)
|
||||
@PostMapping(value = "/preCalcWaybillFee")
|
||||
public AjaxResult preCalcWaybillFee(@RequestBody WaybillOrder waybillOrder)
|
||||
{
|
||||
try {
|
||||
EmisWaybill emisWaybillSave = waybillOrder.toDb();
|
||||
List<Map> estList=emisWaybillService.preCalcWaybillFee(emisWaybillSave);
|
||||
return AjaxResult.success("试算成功", estList);
|
||||
}
|
||||
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("服务器异常,联系客服");
|
||||
}
|
||||
}
|
||||
|
||||
@Log(title = "计算运费", businessType = BusinessType.OTHER)
|
||||
@PostMapping(value = "/calcWaybillFee")
|
||||
public AjaxResult calcWaybillFee(@RequestBody WaybillOrder waybillOrder)
|
||||
|
||||
@ -62,4 +62,9 @@ public class EmisWaybillFeeitem extends BaseEntity
|
||||
/* 排序 */
|
||||
private Integer orderNum;
|
||||
|
||||
// 其他扩展字段
|
||||
// 最低报价
|
||||
private BigDecimal leastPrice;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -67,4 +67,8 @@ public interface EmisTmsScanPicInfoMapper extends BaseMapper<EmisTmsScanPicInfo>
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmisTmsScanPicInfoByIds(Long[] ids);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ package com.xdadan.erp.emis.mapper;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xdadan.erp.emis.domain.EmisTmsScanPicInfo;
|
||||
import com.xdadan.erp.emis.domain.EmisTmsScanRecord;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@ -76,4 +77,8 @@ public interface EmisTmsScanRecordMapper extends BaseMapper<EmisTmsScanRecord>
|
||||
// and to_days(scan_date) = to_days(#{scanDate})
|
||||
|
||||
public int checkSiteScanUnique(@Param("billCode")String billCode, @Param("scanType")String scanType, @Param("scanSiteCode")String scanSiteCode, @Param("scanDate")Date scanDate);
|
||||
|
||||
|
||||
public List<EmisTmsScanRecord> selectTraceListByBillCode(String billCode);
|
||||
|
||||
}
|
||||
|
||||
@ -604,6 +604,22 @@ public class EmisBaseService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取产品列表 通过线路代码
|
||||
* @param lineCode
|
||||
* @return
|
||||
*/
|
||||
public List<EmisTransProduct> getTransProductByTransLine(String lineCode) {
|
||||
EmisTransProduct emisTransProduct = new EmisTransProduct();
|
||||
emisTransProduct.setTransLineCode(lineCode);
|
||||
return emisTransProductMapper.selectEmisTransProductList(emisTransProduct);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取有效产品报价
|
||||
* @param prodCode
|
||||
|
||||
@ -10,6 +10,8 @@
|
||||
package com.xdadan.erp.emis.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.xdadan.erp.emis.domain.EmisTmsScanRecord;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.emis.domain.vo.scan.ScanInfo;
|
||||
@ -76,4 +78,19 @@ public interface IEmisTmsScanRecordService
|
||||
*/
|
||||
public ScanResult scan(ScanInfo scanInfo) throws EmisBizError;
|
||||
|
||||
/**
|
||||
* 根据运单号获取扫描记录
|
||||
* @param billCode
|
||||
* @return
|
||||
*/
|
||||
public List<EmisTmsScanRecord> getTraceListByBillCode(String billCode);
|
||||
|
||||
/**
|
||||
* 获取跟踪信息
|
||||
* @param billCode
|
||||
* @param lang
|
||||
* @return
|
||||
*/
|
||||
public List<Map> queryWaybillTraceInfo(String billCode, String lang);
|
||||
|
||||
}
|
||||
|
||||
@ -111,6 +111,8 @@ public interface IEmisWaybillService
|
||||
// 账单保存
|
||||
public int realSubmitOrder(EmisWaybill emisWaybill) throws EmisBizError;
|
||||
|
||||
// 费用试算
|
||||
public List<Map> preCalcWaybillFee(EmisWaybill emisWaybill) throws EmisBizError;
|
||||
|
||||
//计算运单费用
|
||||
public void calcWaybillFee(EmisWaybill emisWaybill) throws EmisBizError;
|
||||
|
||||
@ -11,10 +11,7 @@
|
||||
package com.xdadan.erp.emis.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import com.xdadan.erp.common.core.domain.entity.SysUser;
|
||||
import com.xdadan.erp.common.utils.DateUtils;
|
||||
@ -589,6 +586,129 @@ public class EmisTmsScanRecordServiceImpl extends EmisBaseService implements IEm
|
||||
return scanResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取物流轨迹表
|
||||
* @param billCode
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<EmisTmsScanRecord> getTraceListByBillCode(String billCode) {
|
||||
return emisTmsScanRecordMapper.selectTraceListByBillCode(billCode);
|
||||
}
|
||||
|
||||
// 获取物流跟踪列表
|
||||
@Override
|
||||
public List<Map> queryWaybillTraceInfo(String billCode,String lang) {
|
||||
|
||||
List<Map> stepList = new ArrayList<>();
|
||||
List<EmisTmsScanRecord> listTraceList= getTraceListByBillCode(billCode);
|
||||
for(EmisTmsScanRecord scanRecord:listTraceList){
|
||||
|
||||
String content=cvtRecordToStr(scanRecord);
|
||||
if(content!=null) {
|
||||
Map<String, Object> step = new HashMap<>();
|
||||
step.put("time", scanRecord.getScanDate());
|
||||
step.put("status", scanRecord.getScanDate());
|
||||
step.put("content", content);
|
||||
stepList.add(step);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return stepList;
|
||||
}
|
||||
|
||||
private String cvtRecordToStr(EmisTmsScanRecord scanRecord){
|
||||
String content = null;
|
||||
|
||||
String scanType=scanRecord.getScanType();
|
||||
|
||||
|
||||
// content = scanSite ;
|
||||
// if(opCode.contains("收件")) {
|
||||
// content=content+" 快件已揽收 ,业务员:"+scanMan;
|
||||
// }
|
||||
// else if(opCode.contains("到达") || opCode.contains("到件")) {
|
||||
// content=content+"快件已到达"+scanSite;
|
||||
// }
|
||||
// else if(opCode.contains("发件") ) {
|
||||
// content=content+"快件已离开"+scanSite +" 发往 "+preOrNextStation;
|
||||
// }
|
||||
// else if(opCode.contains("派件扫描") ) {
|
||||
// content=content+"派件扫描,派件员:"+scanMan;
|
||||
// }
|
||||
// else if(opCode.contains("派件") ) {
|
||||
// content=content+"派件中,派件员:"+scanMan;
|
||||
// }
|
||||
// else if(opCode.contains("签收") ) {
|
||||
// content=content+"已签收,签收人:"+scanMan;
|
||||
// }
|
||||
// else {
|
||||
// content=content+""+opCode;
|
||||
// }
|
||||
|
||||
|
||||
// 揽收扫描
|
||||
if(ScanType.GOT.opCode.equals(scanType)){
|
||||
content=" 已揽收,业务员:"+scanRecord.getDispatchOrSendMan();
|
||||
// +" 电话:" +scanRecord.getDispatchOrSendManPhone();
|
||||
}
|
||||
// 发件扫描
|
||||
else if(ScanType.DEPARTURE.opCode.equals(scanType)){
|
||||
content="快件已离开 "+scanRecord.getScanSite() +" 发往 "+scanRecord.getPreOrNextStation();
|
||||
}
|
||||
// 到件扫描
|
||||
else if(ScanType.ARRIVAL.opCode.equals(scanType)){
|
||||
content="快件已到达 "+scanRecord.getScanSite();
|
||||
}
|
||||
// 派送扫描
|
||||
else if(ScanType.SENT.opCode.equals(scanType)){
|
||||
content="派件扫描,派件员:"+scanRecord.getDispatchOrSendMan();
|
||||
}
|
||||
// 签收扫描
|
||||
else if(ScanType.SIGNED.opCode.equals(scanType)){
|
||||
content="已签收,签收人:"+scanRecord.getSignMan();
|
||||
}
|
||||
// 留仓
|
||||
else if(ScanType.HOLD.opCode.equals(scanType)){
|
||||
content=" 已留仓,网点:"+scanRecord.getScanSite() ;
|
||||
}
|
||||
// 转单扫描
|
||||
else if(ScanType.TRANSFER.opCode.equals(scanType)){
|
||||
content=" 已转单:";
|
||||
// 查询转单轨迹
|
||||
}
|
||||
// 问题件
|
||||
else if(ScanType.ISSUE.opCode.equals(scanType)){
|
||||
|
||||
content=" 问题件:";
|
||||
}
|
||||
// 合包
|
||||
else if(ScanType.CO_PACKING.opCode.equals(scanType)){
|
||||
|
||||
}
|
||||
else if(ScanType.UN_PACKING.opCode.equals(scanType)){
|
||||
}
|
||||
// 装车
|
||||
else if(ScanType.LOADING.opCode.equals(scanType)){
|
||||
|
||||
}
|
||||
// 卸车
|
||||
else if(ScanType.UN_LOADING.opCode.equals(scanType)){
|
||||
|
||||
}
|
||||
// 报关扫描
|
||||
else if(ScanType.DECLEARE.opCode.equals(scanType)){
|
||||
content=" 报关扫描";
|
||||
}
|
||||
// 清关扫描
|
||||
else if(ScanType.CLEARANCE.opCode.equals(scanType)){
|
||||
content=" 清关扫描";
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -12,9 +12,7 @@ package com.xdadan.erp.emis.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Snowflake;
|
||||
@ -515,8 +513,8 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
}
|
||||
|
||||
EmisWaybillFeeitem feeItem = new EmisWaybillFeeitem();
|
||||
// 重量计费
|
||||
if("1".equals(calcFeeType)){
|
||||
// 重量计费 , 一口价
|
||||
if("1".equals(calcFeeType) || "3".equals(calcFeeType)){
|
||||
for (EmisQuoteExpression exprItem: exprList) {
|
||||
log.info("计算项目:"+JSONObject.toJSONString(exprItem)+",重量:"+emisWaybill.getSettlementWeight().doubleValue());
|
||||
|
||||
@ -530,6 +528,9 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
feeItem.setQuoteId(quoteItem.getQuoteId());
|
||||
feeItem.setExprId(exprItem.getId());
|
||||
|
||||
// 最低报价
|
||||
feeItem.setLeastPrice(quoteItem.getLeastPrice());
|
||||
|
||||
String calcExp = exprItem.getCalculateExpression();
|
||||
feeItem.setCalcExp(calcExp);
|
||||
feeItem.setAddWeightPrice(BigDecimal.valueOf(exprItem.getAdditionalWeight()));
|
||||
@ -571,25 +572,43 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
&& exprItem.getEndWeight().doubleValue() > emisWaybill.getTotalVolume().doubleValue()
|
||||
){
|
||||
feeItem.setFeeCode(quoteItem.getFeeType());
|
||||
String feeName=DictUtils.getDictLabel("emis_fee_type",quoteItem.getFeeType());
|
||||
feeItem.setFeeName(feeName);
|
||||
|
||||
feeItem.setQuoteId(quoteItem.getQuoteId());
|
||||
feeItem.setExprId(exprItem.getId());
|
||||
|
||||
// 最低报价
|
||||
feeItem.setLeastPrice(quoteItem.getLeastPrice());
|
||||
|
||||
String calcExp = exprItem.getCalculateExpression();
|
||||
feeItem.setCalcExp(calcExp);
|
||||
feeItem.setAddWeightPrice(BigDecimal.valueOf(exprItem.getAdditionalWeight()));
|
||||
feeItem.setInitialWeightFee(BigDecimal.valueOf(exprItem.getInitialWeight()));
|
||||
|
||||
|
||||
String exprStr = exprItem.getCalculateExpression();
|
||||
String calcExprStr=exprStr.replaceAll("w",emisWaybill.getTotalVolume().toString());
|
||||
log.info("计算公式:"+calcExprStr+",体积:"+emisWaybill.getTotalVolume());
|
||||
|
||||
double fee = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString());
|
||||
fee=WaybillHelper.calcSettledFee(fee,quoteItem.getPriceType());
|
||||
|
||||
feeItem.setFee(BigDecimal.valueOf(fee));
|
||||
feeItem.setRealFee(BigDecimal.valueOf(fee));
|
||||
|
||||
log.info("计算后费用:"+feeItem.getFee());
|
||||
totalFee=totalFee+fee;
|
||||
feeItem.setRemark(JSONObject.toJSONString(exprItem));
|
||||
feeItem.setRemark(feeItem.getCalcExp());
|
||||
feeItem.setBlAutoGen("1");
|
||||
|
||||
feeList.add(feeItem);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if("3".equals(calcFeeType)){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 设置费用明细
|
||||
@ -598,6 +617,86 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 运单费用计算接口
|
||||
* @param emisWaybill
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Map> preCalcWaybillFee(EmisWaybill emisWaybill) throws EmisBizError {
|
||||
|
||||
/**
|
||||
* 计算逻辑,获取表达式进行计算
|
||||
*/
|
||||
|
||||
if(StringUtils.isAnyEmpty(emisWaybill.getTransLineType(),
|
||||
emisWaybill.getSendSiteCode(),
|
||||
emisWaybill.getDispatchUnderlingSiteCode(),
|
||||
emisWaybill.getCalcFeeType()
|
||||
)
|
||||
){
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "参数不完整");
|
||||
}
|
||||
|
||||
if(StringUtils.isAnyEmpty(emisWaybill.getTransLineType(),
|
||||
emisWaybill.getSendSiteCode(),
|
||||
emisWaybill.getDispatchUnderlingSiteCode(),
|
||||
emisWaybill.getCalcFeeType())
|
||||
|| emisWaybill.getBillWeight()==null
|
||||
|| emisWaybill.getTotalVolume()==null
|
||||
|
||||
){
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "参数不完整");
|
||||
}
|
||||
|
||||
if(emisWaybill.getBillWeight().floatValue()<=0.0f
|
||||
&& emisWaybill.getTotalVolume().floatValue()<=0.0f){
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "重量和体积需要大于0");
|
||||
}
|
||||
|
||||
// 获取产品
|
||||
List<Map> estList = new ArrayList<>();
|
||||
|
||||
List<EmisTransProduct> list=getTransProductByTransLine(emisWaybill.getTransLineType());
|
||||
for (EmisTransProduct emisTransProduct: list) {
|
||||
|
||||
try {
|
||||
emisWaybill.setProductType(emisTransProduct.getProdCode());
|
||||
// 计算体积重
|
||||
calcVolumeWeight(emisWaybill);
|
||||
// 计算结算重量
|
||||
calcSettledWeight(emisWaybill);
|
||||
// 计算费用
|
||||
calcWaybillFee(emisWaybill);
|
||||
|
||||
Map<String, Object> estFeeMap = new HashMap<>();
|
||||
|
||||
estFeeMap.put("productType",emisTransProduct.getProdCode());
|
||||
estFeeMap.put("productTypeName",emisTransProduct.getProdName());
|
||||
estFeeMap.put("agingDesc",emisTransProduct.getAgingDesc());
|
||||
for (EmisWaybillFeeitem feeItem:emisWaybill.getFeeitemList()) {
|
||||
// 只取运输费的最低报价
|
||||
if("1001".equals(feeItem.getFeeCode()) ){
|
||||
estFeeMap.put("leastPrice",feeItem.getLeastPrice());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
estFeeMap.put("estFee",emisWaybill.getFreight());
|
||||
estFeeMap.put("orderNum",emisTransProduct.getOrderNum());
|
||||
|
||||
|
||||
estList.add(estFeeMap);
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return estList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void calcSettledWeight(EmisWaybill emisWaybill) throws EmisBizError {
|
||||
|
||||
|
||||
@ -133,6 +133,8 @@
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<!-- and params.queryType = 2-->
|
||||
|
||||
<select id="selectEmisTmsScanRecordById" parameterType="Long" resultMap="EmisTmsScanRecordResult">
|
||||
@ -307,4 +309,12 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="selectTraceListByBillCode" parameterType="string" resultMap="EmisTmsScanRecordResult">
|
||||
<include refid="selectEmisTmsScanRecordVo"/>
|
||||
where del_flag='0' and bill_code=#{billCode}
|
||||
order by create_time desc;
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user