2024-07-13 11:07:46 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Project: emis
|
|
|
|
|
* @Title: EmisWaybillController.java
|
|
|
|
|
* @author linfso
|
|
|
|
|
* @date 2024-02-29 08:15:14
|
|
|
|
|
* @Copyright: ShangHai Duta 2022 All rights reserved.
|
|
|
|
|
* @version v1.0
|
|
|
|
|
* @Description: <p> 运单列表 控制器 </p>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package com.xdadan.erp.apiweb;
|
|
|
|
|
|
2024-07-15 16:43:52 +00:00
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
2024-07-13 11:07:46 +00:00
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.xdadan.erp.common.annotation.Log;
|
2024-07-15 16:43:52 +00:00
|
|
|
import com.xdadan.erp.common.annotation.filter.jackson.JacksonFilter;
|
2024-07-13 11:07:46 +00:00
|
|
|
import com.xdadan.erp.common.config.PayConfig;
|
|
|
|
|
import com.xdadan.erp.common.core.controller.BaseController;
|
|
|
|
|
import com.xdadan.erp.common.core.domain.AjaxResult;
|
|
|
|
|
import com.xdadan.erp.common.core.domain.entity.SysUser;
|
|
|
|
|
import com.xdadan.erp.common.core.page.TableDataInfo;
|
|
|
|
|
import com.xdadan.erp.common.enums.BusinessType;
|
|
|
|
|
import com.xdadan.erp.common.utils.DateUtils;
|
|
|
|
|
import com.xdadan.erp.common.utils.idgen.UUID;
|
|
|
|
|
import com.xdadan.erp.emis.domain.EmisTmsScanRecord;
|
|
|
|
|
import com.xdadan.erp.emis.domain.EmisWaybill;
|
|
|
|
|
import com.xdadan.erp.emis.domain.enumtype.ScanType;
|
|
|
|
|
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
|
|
|
|
import com.xdadan.erp.emis.domain.vo.FeeItem;
|
|
|
|
|
import com.xdadan.erp.emis.domain.vo.WaybillOrder;
|
|
|
|
|
import com.xdadan.erp.emis.service.EmisBaseService;
|
|
|
|
|
import com.xdadan.erp.emis.service.IEmisElectronicSitePagService;
|
|
|
|
|
import com.xdadan.erp.emis.service.IEmisTmsScanRecordService;
|
|
|
|
|
import com.xdadan.erp.emis.service.IEmisWaybillService;
|
|
|
|
|
import com.xdadan.erp.emis.service.print.IXddTplPrint;
|
|
|
|
|
import com.xdadan.erp.emis.service.print.tanex.TanexTplPrintImpl;
|
|
|
|
|
import com.xdadan.erp.emis.utils.WaybillHelper;
|
|
|
|
|
import com.xdadan.erp.system.domain.SysFileInfo;
|
2024-07-15 16:43:52 +00:00
|
|
|
import com.xdadan.erp.system.domain.SysPost;
|
2024-07-13 11:07:46 +00:00
|
|
|
import com.xdadan.erp.system.service.ISysFileInfoService;
|
2024-07-15 16:43:52 +00:00
|
|
|
import com.xdadan.erp.system.service.ISysPostService;
|
2024-07-13 11:07:46 +00:00
|
|
|
import com.xdadan.erp.system.service.ISysUserService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 运单列表Controller
|
|
|
|
|
*
|
|
|
|
|
* @author linfso
|
|
|
|
|
* @date 2024-02-29 08:15:14
|
|
|
|
|
*/
|
|
|
|
|
@Slf4j
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/apiweb/emisWaybill")
|
|
|
|
|
public class WaybillController extends BaseController
|
|
|
|
|
{
|
2024-07-15 16:43:52 +00:00
|
|
|
@Autowired
|
|
|
|
|
private ISysUserService userService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysPostService postService;
|
|
|
|
|
|
2024-07-13 11:07:46 +00:00
|
|
|
@Autowired
|
|
|
|
|
private IEmisWaybillService emisWaybillService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private EmisBaseService emisBaseService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysFileInfoService sysFileInfoService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysUserService sysUserService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IEmisElectronicSitePagService emisElectronicSitePagService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IEmisTmsScanRecordService emisTmsScanRecordService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取电子运单信息
|
|
|
|
|
*/
|
2024-07-14 13:10:57 +00:00
|
|
|
@GetMapping(value = "/getWaybillDetailByOms")
|
|
|
|
|
public AjaxResult getWaybillDetailByOms(String billCode ,String orderSn)
|
2024-07-13 11:07:46 +00:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
WaybillOrder waybillOrder=null;
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isEmpty(billCode) ){
|
|
|
|
|
return AjaxResult.error("参数错误");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
billCode= WaybillHelper.formatQueryValue(billCode);
|
|
|
|
|
if(!StringUtils.isEmpty(billCode) ){
|
|
|
|
|
boolean isExists=emisBaseService.checkWaybillIsExists(billCode);
|
|
|
|
|
if(!isExists){
|
|
|
|
|
return AjaxResult.error("运单不存在");
|
|
|
|
|
}
|
|
|
|
|
String mainBillCode=emisBaseService.getMainBillCode(billCode);
|
|
|
|
|
waybillOrder = emisWaybillService.getWaybillOrderByBillCode(mainBillCode);
|
|
|
|
|
if(waybillOrder==null){
|
|
|
|
|
return AjaxResult.error("运单不存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 返回子单信息
|
|
|
|
|
waybillOrder.setBillCode(billCode);
|
|
|
|
|
|
|
|
|
|
}else if(!StringUtils.isEmpty(orderSn)){
|
|
|
|
|
waybillOrder = emisWaybillService.getWaybillOrderByOrderSn(orderSn);
|
|
|
|
|
if(waybillOrder==null){
|
|
|
|
|
return AjaxResult.error("订单不存在");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取取件员电话
|
|
|
|
|
if(!StringUtils.isEmpty(waybillOrder.getTakePieceEmployeeCode())){
|
|
|
|
|
SysUser user= sysUserService.selectUserByUserName(waybillOrder.getTakePieceEmployeeCode());
|
|
|
|
|
waybillOrder.setTakePieceEmployeePhone(user.getPhonenumber());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success("获取成功",waybillOrder);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex){
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
// 返回子定义异常
|
|
|
|
|
if(ex instanceof EmisBizError){
|
|
|
|
|
return AjaxResult.error(ex.getMessage(),((EmisBizError)ex).getErrorCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return AjaxResult.error("服务器异常,联系客服");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-15 09:34:13 +00:00
|
|
|
@Log(title = "OMSExcel草稿方式下单", businessType = BusinessType.INSERT)
|
2024-07-14 13:10:57 +00:00
|
|
|
@PostMapping(value = "/draftSubmitOrderByOms")
|
|
|
|
|
public AjaxResult draftSubmitOrderByOms(@RequestBody EmisWaybill emisWaybillSave)
|
2024-07-13 11:07:46 +00:00
|
|
|
{
|
|
|
|
|
JSONObject jObjOut = new JSONObject();
|
|
|
|
|
String result="success";
|
|
|
|
|
String msg="下单成功";
|
|
|
|
|
try {
|
|
|
|
|
|
2024-07-15 09:34:13 +00:00
|
|
|
emisWaybillService.draftSubmitOrder(emisWaybillSave,true);
|
2024-07-13 11:07:46 +00:00
|
|
|
jObjOut.put("billDetail", emisWaybillSave);
|
|
|
|
|
|
|
|
|
|
}catch(EmisBizError ex){
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
|
|
|
|
|
result="fail";
|
|
|
|
|
msg=ex.getErrorCode()+":"+ex.getMessage();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (DuplicateKeyException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
result="fail";
|
|
|
|
|
msg="运单号重复";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex){
|
|
|
|
|
result="fail";
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
msg="系统异常:"+ex.getMessage();
|
|
|
|
|
// 返回子定义异常
|
|
|
|
|
if(ex instanceof EmisBizError){
|
|
|
|
|
msg=((EmisBizError)ex).getErrorCode()+":"+ex.getMessage();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
jObjOut.put("result", result);
|
|
|
|
|
jObjOut.put("msg", msg);
|
|
|
|
|
return AjaxResult.success("成功", jObjOut);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Log(title = "取消订单", businessType = BusinessType.INSERT)
|
2024-07-14 13:10:57 +00:00
|
|
|
@PostMapping(value = "/cancelOrderByOms")
|
|
|
|
|
public AjaxResult cancelOrderByOms(@Valid @RequestBody WaybillOrder waybillOrder)
|
2024-07-13 11:07:46 +00:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isEmpty(waybillOrder.getOrderSn()) ){
|
|
|
|
|
return AjaxResult.error("订单号不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EmisWaybill emisWaybill = new EmisWaybill();
|
|
|
|
|
emisWaybill.setOrderSn(waybillOrder.getOrderSn());
|
|
|
|
|
emisWaybill.setOrderRemark(waybillOrder.getOrderRemark());
|
|
|
|
|
emisWaybillService.cancelOrder(emisWaybill);
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success("取消成功");
|
|
|
|
|
}catch(EmisBizError ex){
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
return AjaxResult.error("("+ex.getErrorCode()+")"+ex.getMessage());
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex){
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
// 返回子定义异常
|
|
|
|
|
if(ex instanceof EmisBizError){
|
|
|
|
|
return AjaxResult.error(ex.getMessage(),((EmisBizError)ex).getErrorCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return AjaxResult.error("服务器异常,联系客服");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-14 13:10:57 +00:00
|
|
|
|
|
|
|
|
@Log(title = "OMS实时下单", businessType = BusinessType.INSERT)
|
|
|
|
|
@PostMapping(value = "/realSubmitOrderByOms")
|
|
|
|
|
public AjaxResult realSubmitOrderByOms(@Valid @RequestBody WaybillOrder waybillOrder, Integer isModify)
|
2024-07-13 11:07:46 +00:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isEmpty(waybillOrder.getBillCode()) ){
|
|
|
|
|
waybillOrder.setBillCode(emisElectronicSitePagService.realMatchWaybill(waybillOrder.getSendSiteCode(),"T7080"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EmisWaybill emisWaybillSave = waybillOrder.toDb();
|
|
|
|
|
|
2024-07-14 13:10:57 +00:00
|
|
|
emisWaybillService.realSubmitOrderByOms(emisWaybillSave);
|
2024-07-13 11:07:46 +00:00
|
|
|
|
|
|
|
|
JSONObject jObjOut = new JSONObject();
|
|
|
|
|
jObjOut.put("billCode", waybillOrder.getBillCode());
|
|
|
|
|
// jObjOut.put("prodName", waybillOrder.getProductType());
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success("下单成功", jObjOut);
|
|
|
|
|
}catch(EmisBizError ex){
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
return AjaxResult.error("("+ex.getErrorCode()+")"+ex.getMessage());
|
|
|
|
|
}
|
|
|
|
|
catch (DuplicateKeyException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return AjaxResult.error("运单号重复!");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex){
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
// 返回子定义异常
|
|
|
|
|
if(ex instanceof EmisBizError){
|
2024-07-14 13:10:57 +00:00
|
|
|
return AjaxResult.error(ex.getMessage(),((EmisBizError)ex).getErrorCode());
|
2024-07-13 11:07:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return AjaxResult.error("服务器异常,联系客服");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Log(title = "运费试算", businessType = BusinessType.OTHER)
|
2024-07-14 13:10:57 +00:00
|
|
|
@PostMapping(value = "/preCalcWaybillFeeByOms")
|
|
|
|
|
public AjaxResult preCalcWaybillFeeByOms(@RequestBody WaybillOrder waybillOrder)
|
2024-07-13 11:07:46 +00:00
|
|
|
{
|
|
|
|
|
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(ex.getMessage(),((EmisBizError)ex).getErrorCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return AjaxResult.error("服务器异常,联系客服");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-15 16:43:52 +00:00
|
|
|
|
2024-07-13 11:07:46 +00:00
|
|
|
}
|