This commit is contained in:
linfso 2024-06-16 10:53:29 +08:00
parent 2ac446d6eb
commit 800da20506
12 changed files with 946 additions and 41 deletions

View File

@ -0,0 +1,134 @@
/**
* @Project: emis
* @Title: EmisSiteBillControlController.java
* @author linfso
* @date 2024-06-16 01:59:34
* @Copyright: ShangHai Duta 2022 All rights reserved.
* @version v1.0
* @Description: <p> 对账单锁账 控制器 </p>
*/
package com.xdadan.erp.web.emis;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xdadan.erp.common.annotation.Log;
import com.xdadan.erp.common.core.controller.BaseController;
import com.xdadan.erp.common.core.domain.AjaxResult;
import com.xdadan.erp.common.core.page.TableDataInfo;
import com.xdadan.erp.common.enums.BusinessType;
import com.xdadan.erp.common.utils.StringUtils;
import com.xdadan.erp.common.utils.poi.ExcelUtil;
import com.xdadan.erp.emis.domain.EmisSiteBillControl;
import com.xdadan.erp.emis.service.IEmisSiteBillControlService;
/**
* 对账单锁账Controller
*
* @author linfso
* @date 2024-06-16 01:59:34
*/
@RestController
@RequestMapping("/emis/emisSiteBillControl")
public class EmisSiteBillControlController extends BaseController
{
@Autowired
private IEmisSiteBillControlService emisSiteBillControlService;
/**
* 查询对账单锁账列表
*/
@PreAuthorize("@ss.hasPermi('emis:emisSiteBillControl:list')")
@GetMapping("/list")
public TableDataInfo list(EmisSiteBillControl emisSiteBillControl)
{
startPage();
List<EmisSiteBillControl> list = emisSiteBillControlService.selectEmisSiteBillControlList(emisSiteBillControl);
return getDataTable(list);
}
/**
* 检查是否重复
*
* @param emisSiteBillControl
* @return 数量
*/
@PreAuthorize("@ss.hasPermi('emis:emisSiteBillControl:list')")
@GetMapping("/checkUnique")
public AjaxResult checkUnique(EmisSiteBillControl emisSiteBillControl)
{
int cnt=emisSiteBillControlService.checkUnique(emisSiteBillControl);
return AjaxResult.success("检查成功",cnt);
}
/**
* 导出对账单锁账列表
*/
@PreAuthorize("@ss.hasPermi('emis:emisSiteBillControl:export')")
@Log(title = "对账单锁账", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, EmisSiteBillControl emisSiteBillControl)
{
List<EmisSiteBillControl> list = emisSiteBillControlService.selectEmisSiteBillControlList(emisSiteBillControl);
ExcelUtil<EmisSiteBillControl> util = new ExcelUtil<EmisSiteBillControl>(EmisSiteBillControl.class);
util.exportExcel(response, list, "对账单锁账数据");
}
/**
* 获取对账单锁账详细信息
*/
@PreAuthorize("@ss.hasPermi('emis:emisSiteBillControl:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(emisSiteBillControlService.selectEmisSiteBillControlById(id));
}
/**
* 新增对账单锁账
*/
@PreAuthorize("@ss.hasPermi('emis:emisSiteBillControl:add')")
@Log(title = "对账单锁账", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EmisSiteBillControl emisSiteBillControl)
{
return toAjax(emisSiteBillControlService.insertEmisSiteBillControl(emisSiteBillControl));
}
/**
* 修改对账单锁账
*/
@PreAuthorize("@ss.hasPermi('emis:emisSiteBillControl:edit')")
@Log(title = "对账单锁账", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EmisSiteBillControl emisSiteBillControl)
{
return toAjax(emisSiteBillControlService.updateEmisSiteBillControl(emisSiteBillControl));
}
/**
* 删除对账单锁账
*/
@PreAuthorize("@ss.hasPermi('emis:emisSiteBillControl:remove')")
@Log(title = "对账单锁账", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(emisSiteBillControlService.deleteEmisSiteBillControlByIds(ids));
}
}

View File

@ -139,7 +139,38 @@ public class EmisWaybillController extends EmisBaseController
}
}
// @PreAuthorize("@ss.hasPermi('emis:emisWaybill:add')")
@Log(title = "Excel草稿方式下单", businessType = BusinessType.INSERT)
@PostMapping(value = "/draftSubmitOrder")
public AjaxResult draftSubmitOrder(@RequestBody EmisWaybill emisWaybillSave)
{
try {
emisWaybillService.draftSubmitOrder(emisWaybillSave);
JSONObject jObjOut = new JSONObject();
jObjOut.put("billCode", emisWaybillSave.getBillCode());
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){
return AjaxResult.error("("+((EmisBizError)ex).getErrorCode()+")"+ex.getMessage());
}
return AjaxResult.error("服务器异常,联系客服");
}
}
@Log(title = "运单实时下单", businessType = BusinessType.INSERT)
@PostMapping(value = "/realSubmitOrder")
public AjaxResult realSubmitOrder(@Valid @RequestBody WaybillOrder waybillOrder,Integer isModify)

View File

@ -0,0 +1,48 @@
/**
* @Project: emis
* @Title: EmisSiteBillControl.java
* @author linfso
* @date 2024-06-16 01:59:34
* @Copyright: ShangHai Duta 2022 All rights reserved.
* @version v1.0
* @Description: <p> 对账单锁账 实体类 </p>
*/
package com.xdadan.erp.emis.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.xdadan.erp.common.annotation.Excel;
import com.xdadan.erp.common.core.domain.BaseEntity;
import com.xdadan.erp.common.core.domain.TreeEntity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
/**
* @ClassName EmisSiteBillControl
* @Description 对账单锁账
* @author linfso
* @date 2024-06-16 01:59:34
*/
@Data
public class EmisSiteBillControl extends BaseEntity
{
private static final long serialVersionUID = 1L;
/* id */
private Long id;
/* 寄件网点 */
private String sendSiteCode;
/* 目的网点 */
private String destSiteCode;
/* 控制时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date controlDate;
/* 1-启用 */
private String blOpen;
}

View File

@ -0,0 +1,80 @@
/**
* @Project: emis
* @Title: EmisSiteBillControlMapper.java
* @author linfso
* @date 2024-06-16 01:59:34
* @Copyright: ShangHai Doitinfo 2022 All rights reserved.
* @version v1.0
* @Description: <p> 对账单锁账 Mapper 接口 </p>
* <span style='color:red'> Warning : This file is generate by ai tools,don't edit!!! </span>
*/
package com.xdadan.erp.emis.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xdadan.erp.emis.domain.EmisSiteBillControl;
/**
* @ClassName EmisSiteBillControlMapper
* @Description <p> 对账单锁账 Mapper 接口 </p>
* @author linfso
* @date 2024-06-16 01:59:34
*/
public interface EmisSiteBillControlMapper extends BaseMapper<EmisSiteBillControl>
{
/**
* 主键查询
* @param id
* @return
*/
public EmisSiteBillControl selectEmisSiteBillControlById(Long id);
/**
* 查询列表
*
* @param emisSiteBillControl
* @return 集合
*/
public List<EmisSiteBillControl> selectEmisSiteBillControlList(EmisSiteBillControl emisSiteBillControl);
/**
* 检查是否重复
*
* @param emisSiteBillControl
* @return 数量
*/
public int checkUnique(EmisSiteBillControl emisSiteBillControl);
/**
* 新增
*
* @param emisSiteBillControl
* @return
*/
public int insertEmisSiteBillControl(EmisSiteBillControl emisSiteBillControl);
/**
* 修改
*
* @param emisSiteBillControl
* @return
*/
public int updateEmisSiteBillControl(EmisSiteBillControl emisSiteBillControl);
/**
* 删除
*
* @param id 主键
* @return 结果
*/
public int deleteEmisSiteBillControlById(Long id);
/**
* 批量删除
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteEmisSiteBillControlByIds(Long[] ids);
}

View File

@ -125,6 +125,10 @@ public class EmisBaseService {
@Autowired
private EmisSiteAccountMapper emisSiteAccountMapper;
@Autowired
private EmisCountryMapper emisCountryMapper;
/**
* 获取客户完整手机号 国家+电话 eg: 0086-1381861188
@ -219,6 +223,55 @@ public class EmisBaseService {
return null;
}
/**
* 计算目的地
* @param country
* @param lineCode
* @param province
* @param city
* @param county
* @param address
* @return
*/
public EmisDestination calcDestSite(String country,String lineCode, String province, String city, String county, String address) {
// 目前只根据目的省份获取目的地
// 获取 areaId
Long areaId = null;
EmisRegion queryEmisRegion = new EmisRegion();
queryEmisRegion.setRegionCode(province);
List<EmisRegion> regionList= emisRegionMapper.selectEmisRegionList(queryEmisRegion);
if(!CollectionUtil.isEmpty(regionList)){
areaId = regionList.get(0).getAreaId();
country = regionList.get(0).getCountryCode();
// 根据大区获取目的网点
EmisDestination queryEmisDestination = new EmisDestination();
queryEmisDestination.setCountryAreaId(areaId);
queryEmisDestination.setStatus(1);
List<EmisDestination> destinationList=emisDestinationMapper.selectEmisDestinationList(queryEmisDestination);
if(!CollectionUtil.isEmpty(destinationList)){
return destinationList.get(0);
}
else{
// 根据国家查询
queryEmisDestination = new EmisDestination();
queryEmisDestination.setCountry(country);
queryEmisDestination.setStatus(1);
destinationList=emisDestinationMapper.selectEmisDestinationList(queryEmisDestination);
if(!CollectionUtil.isEmpty(destinationList)){
return destinationList.get(0);
}
}
}
return null;
}
/**
* 获取跟踪信息
@ -1032,11 +1085,18 @@ public class EmisBaseService {
return null;
}
/**
* 获取快递员 by empCode
* @param empCode
* @return
*/
public SysUser getEmisStaffByCode(String empCode){
return sysUserMapper.selectUserByUserName(empCode);
}
/**
* 产生客户编码 规则: siteCode+ 000000
* @param siteCode
@ -1185,6 +1245,21 @@ public class EmisBaseService {
return null;
}
/**
* 根据线路名称获取线路信息
* @param lineName
* @return
*/
public EmisTransLine getTransLineByName(String lineName) {
EmisTransLine queryEmisTransLine = new EmisTransLine();
queryEmisTransLine.setLineName(lineName);
List<EmisTransLine> list=emisTransLineMapper.selectEmisTransLineList(queryEmisTransLine);
if(!CollectionUtils.isEmpty(list)) {
return list.get(0);
}
return null;
}
/**
* 获取产品
* @param code
@ -1203,6 +1278,64 @@ public class EmisBaseService {
}
/**
* 通过名称获取产品 线路下的产品
* @param lineCode
* @param prodName
* @return
*/
public EmisTransProduct getTransProductByName(String lineCode,String prodName) {
EmisTransProduct emisTransProduct = new EmisTransProduct();
emisTransProduct.setTransLineCode(lineCode);
emisTransProduct.setProdName(prodName);
List<EmisTransProduct> list=emisTransProductMapper.selectEmisTransProductList(emisTransProduct);
if(!CollectionUtils.isEmpty(list)) {
return list.get(0);
}
return null;
}
/**
* 根据国家名称获取国家
* @param name
* @return
*/
public EmisCountry getCountryByName(String name) {
EmisCountry emisCountry = new EmisCountry();
emisCountry.setName(name);
List<EmisCountry> list=emisCountryMapper.selectEmisCountryList(emisCountry);
if(!CollectionUtils.isEmpty(list)) {
return list.get(0);
}
return null;
}
/**
* 根据区域名称获取区域
* @param countryCode
* @param parentCode
* @param name
* @return
*/
public EmisRegion getRegionByName(String countryCode,String parentCode,String name) {
EmisRegion emisRegion = new EmisRegion();
emisRegion.setRegionName(name);
emisRegion.setParentCode(parentCode);
emisRegion.setCountryCode(countryCode);
List<EmisRegion> list=emisRegionMapper.selectEmisRegionList(emisRegion);
if(!CollectionUtils.isEmpty(list)) {
return list.get(0);
}
return null;
}

View File

@ -0,0 +1,78 @@
/**
* @Project: emis
* @Title: EmisSiteBillControlService.java
* @author linfso
* @date 2024-06-16 01:59:34
* @Copyright: ShangHai Duta 2022 All rights reserved.
* @version v1.0
* @Description: <p> 对账单锁账 服务类接口 </p>
*/
package com.xdadan.erp.emis.service;
import java.util.List;
import com.xdadan.erp.emis.domain.EmisSiteBillControl;
/**
* @ClassName EmisSiteBillControlService
* @Description 对账单锁账
* @author linfso
* @date 2024-06-16 01:59:34
*/
public interface IEmisSiteBillControlService
{
/**
* 主键查询
* @param id
* @return
*/
public EmisSiteBillControl selectEmisSiteBillControlById(Long id);
/**
* 查询对账单锁账列表
*
* @param emisSiteBillControl 对账单锁账
* @return 对账单锁账集合
*/
public List<EmisSiteBillControl> selectEmisSiteBillControlList(EmisSiteBillControl emisSiteBillControl);
/**
* 检查是否重复
*
* @param emisSiteBillControl
* @return 数量
*/
public int checkUnique(EmisSiteBillControl emisSiteBillControl);
/**
* 新增对账单锁账
*
* @param emisSiteBillControl 对账单锁账
* @return 结果
*/
public int insertEmisSiteBillControl(EmisSiteBillControl emisSiteBillControl);
/**
* 修改对账单锁账
*
* @param emisSiteBillControl 对账单锁账
* @return 结果
*/
public int updateEmisSiteBillControl(EmisSiteBillControl emisSiteBillControl);
/**
* 批量删除对账单锁账
*
* @param ids 需要删除的对账单锁账主键集合
* @return 结果
*/
public int deleteEmisSiteBillControlByIds(Long[] ids);
/**
* 删除对账单锁账信息
*
* @param id 对账单锁账主键
* @return 结果
*/
public int deleteEmisSiteBillControlById(Long id);
}

View File

@ -114,15 +114,24 @@ public interface IEmisWaybillService
*/
public WaybillOrder getWaybillDetailByOrderSn(String orderSn) throws EmisBizError;
/**
* 草稿方式下单
* @param emisWaybill
* @return
* @throws EmisBizError
*/
public int draftSubmitOrder(EmisWaybill emisWaybill) throws EmisBizError;
/**
* 账单保存
/**
* 下单
* @param emisWaybill
* @return
* @throws EmisBizError
*/
public int realSubmitOrder(EmisWaybill emisWaybill) throws EmisBizError;
/**
* 费用试算
* @param emisWaybill

View File

@ -16,6 +16,7 @@ import cn.hutool.core.collection.CollectionUtil;
import com.xdadan.erp.common.core.domain.entity.SysTenant;
import com.xdadan.erp.emis.domain.EmisRegion;
import com.xdadan.erp.emis.mapper.EmisRegionMapper;
import com.xdadan.erp.emis.service.EmisBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xdadan.erp.emis.domain.EmisDestination;
@ -29,7 +30,7 @@ import com.xdadan.erp.emis.service.IEmisDestinationService;
* @date 2024-01-10 02:53:35
*/
@Service
public class EmisDestinationServiceImpl implements IEmisDestinationService
public class EmisDestinationServiceImpl extends EmisBaseService implements IEmisDestinationService
{
@Autowired
private EmisDestinationMapper emisDestinationMapper;
@ -72,42 +73,7 @@ public class EmisDestinationServiceImpl implements IEmisDestinationService
*/
@Override
public EmisDestination calcDestSite(String country,String lineCode, String province, String city, String county, String address) {
// 目前只根据目的省份获取目的地
// 获取 areaId
Long areaId = null;
EmisRegion queryEmisRegion = new EmisRegion();
queryEmisRegion.setRegionCode(province);
List<EmisRegion> regionList= emisRegionMapper.selectEmisRegionList(queryEmisRegion);
if(!CollectionUtil.isEmpty(regionList)){
areaId = regionList.get(0).getAreaId();
country = regionList.get(0).getCountryCode();
// 根据大区获取目的网点
EmisDestination queryEmisDestination = new EmisDestination();
queryEmisDestination.setCountryAreaId(areaId);
queryEmisDestination.setStatus(1);
List<EmisDestination> destinationList=emisDestinationMapper.selectEmisDestinationList(queryEmisDestination);
if(!CollectionUtil.isEmpty(destinationList)){
return destinationList.get(0);
}
else{
// 根据国家查询
queryEmisDestination = new EmisDestination();
queryEmisDestination.setCountry(country);
queryEmisDestination.setStatus(1);
destinationList=emisDestinationMapper.selectEmisDestinationList(queryEmisDestination);
if(!CollectionUtil.isEmpty(destinationList)){
return destinationList.get(0);
}
}
}
return null;
return calcDestSite(country,lineCode,province,city,county,address);
}
/**

View File

@ -0,0 +1,117 @@
/**
* @Project: emis
* @Title: EmisSiteBillControlServiceImpl.java
* @author linfso
* @date 2024-06-16 01:59:34
* @Copyright: ShangHai Duta 2022 All rights reserved.
* @version v1.0
* @Description: <p> 对账单锁账 实体类 </p>
*/
package com.xdadan.erp.emis.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xdadan.erp.emis.domain.EmisSiteBillControl;
import com.xdadan.erp.emis.mapper.EmisSiteBillControlMapper;
import com.xdadan.erp.emis.service.IEmisSiteBillControlService;
/**
* 对账单锁账Service业务层处理
*
* @author linfso
* @date 2024-06-16 01:59:34
*/
@Service
public class EmisSiteBillControlServiceImpl implements IEmisSiteBillControlService
{
@Autowired
private EmisSiteBillControlMapper emisSiteBillControlMapper;
/**
* 查询对账单锁账
*
* @param id 对账单锁账主键
* @return 对账单锁账
*/
@Override
public EmisSiteBillControl selectEmisSiteBillControlById(Long id)
{
return emisSiteBillControlMapper.selectEmisSiteBillControlById(id);
}
/**
* 查询对账单锁账列表
*
* @param emisSiteBillControl 对账单锁账
* @return 对账单锁账
*/
@Override
public List<EmisSiteBillControl> selectEmisSiteBillControlList(EmisSiteBillControl emisSiteBillControl)
{
return emisSiteBillControlMapper.selectEmisSiteBillControlList(emisSiteBillControl);
}
/**
* 检查是否重复
*
* @param emisSiteBillControl
* @return 数量
*/
@Override
public int checkUnique(EmisSiteBillControl emisSiteBillControl)
{
return emisSiteBillControlMapper.checkUnique(emisSiteBillControl);
}
/**
* 新增对账单锁账
*
* @param emisSiteBillControl 对账单锁账
* @return 结果
*/
@Override
public int insertEmisSiteBillControl(EmisSiteBillControl emisSiteBillControl)
{
return emisSiteBillControlMapper.insertEmisSiteBillControl(emisSiteBillControl);
}
/**
* 修改对账单锁账
*
* @param emisSiteBillControl 对账单锁账
* @return 结果
*/
@Override
public int updateEmisSiteBillControl(EmisSiteBillControl emisSiteBillControl)
{
return emisSiteBillControlMapper.updateEmisSiteBillControl(emisSiteBillControl);
}
/**
* 批量删除对账单锁账
*
* @param ids 需要删除的对账单锁账主键
* @return 结果
*/
@Override
public int deleteEmisSiteBillControlByIds(Long[] ids)
{
return emisSiteBillControlMapper.deleteEmisSiteBillControlByIds(ids);
}
/**
* 删除对账单锁账信息
*
* @param id 对账单锁账主键
* @return 结果
*/
@Override
public int deleteEmisSiteBillControlById(Long id)
{
return emisSiteBillControlMapper.deleteEmisSiteBillControlById(id);
}
}

View File

@ -22,6 +22,7 @@ import com.googlecode.aviator.AviatorEvaluator;
import com.xdadan.erp.common.core.domain.AjaxResult;
import com.xdadan.erp.common.utils.DateUtils;
import com.xdadan.erp.common.utils.DictUtils;
import com.xdadan.erp.common.utils.SecurityUtils;
import com.xdadan.erp.emis.domain.*;
import com.xdadan.erp.emis.domain.enumtype.*;
import com.xdadan.erp.emis.domain.exception.EmisBizError;
@ -286,6 +287,186 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
}
/**
* 草稿下单接口
* @param emisWaybillSave
* @return
*/
@Override
@Transactional
public int draftSubmitOrder(EmisWaybill emisWaybillSave) throws EmisBizError {
boolean isNew = true;
EmisWaybill emisWaybillOld = null;
// 如果没有单号就生成单号,如果有单号需要判断是否重复
if( !StringUtils.isEmpty(emisWaybillSave.getBillCode()) ) {
boolean isExists = this.checkWaybillIsExists(emisWaybillSave.getBillCode());
if (isExists) {
throw new EmisBizError(EmisBizErrorType.EXISTS, "运单号重复");
}
}else{
// 下单网点
String sendSiteCode=SecurityUtils.getLoginUser().getUser().getOwnerSiteCode();
emisWaybillSave.setSendSiteCode(sendSiteCode);
// 生成新的运单号
String waybillNo = emisElectronicSitePagService.realMatchWaybill(sendSiteCode,"T7080");
emisWaybillSave.setBillCode(waybillNo);
}
// 转换草稿数据到真实数据
cvtWaybillDraftToReal(emisWaybillSave);
// 开始下单
addWayBill(emisWaybillSave);
return 1;
}
/**
* 转换草稿数据到真实数据
* @param emisWaybillSave
* @throws EmisBizError
*/
private void cvtWaybillDraftToReal(EmisWaybill emisWaybillSave) throws EmisBizError {
// 线路转换
EmisTransLine transLine=getTransLineByName(emisWaybillSave.getTransLineType());
if(transLine==null){
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "线路不正确");
}
emisWaybillSave.setTransLineType(transLine.getLineCode());
// 产品转换
EmisTransProduct transProduct=getTransProductByName(transLine.getLineCode(),emisWaybillSave.getProductType());
if(transProduct==null){
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "产品不正确");
}
emisWaybillSave.setProductType(transProduct.getProdCode());
// 收件国家省市区转换
String receiveCountryCode=getCountryCodeByName(emisWaybillSave.getReceiveCountry());
if(receiveCountryCode==null){
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "收件国家不正确");
}
String rcvProviceCode=getChildRegionCodeByName(receiveCountryCode,null,emisWaybillSave.getReceiveProvince());
if(rcvProviceCode==null){
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "收件省不正确");
}
String rcvCityCode=getChildRegionCodeByName(receiveCountryCode,rcvProviceCode,emisWaybillSave.getReceiveCity());
String rcvDistrictCode=getChildRegionCodeByName(receiveCountryCode,rcvCityCode,emisWaybillSave.getReceiveCounty());
emisWaybillSave.setReceiveCountry(receiveCountryCode);
emisWaybillSave.setReceiveProvince(rcvProviceCode);
emisWaybillSave.setReceiveCity(rcvCityCode);
emisWaybillSave.setReceiveCounty(rcvDistrictCode);
// 寄件国家省市区
String sendCountryCode=getCountryCodeByName(emisWaybillSave.getSendCountry());
if(sendCountryCode==null){
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "寄件国家不正确");
}
String sendProviceCode=getChildRegionCodeByName(sendCountryCode,null,emisWaybillSave.getSendProvince());
if(sendProviceCode==null){
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "寄件省不正确");
}
String sendCityCode=getChildRegionCodeByName(sendCountryCode,sendProviceCode,emisWaybillSave.getSendCity());
String sendDistrictCode=getChildRegionCodeByName(sendCountryCode,sendCityCode,emisWaybillSave.getSendCounty());
emisWaybillSave.setSendCountry(sendCountryCode);
emisWaybillSave.setSendProvince(sendProviceCode);
emisWaybillSave.setSendCity(sendCityCode);
emisWaybillSave.setSendCounty(sendDistrictCode);
// 取件方式
String pickupMethod=DictUtils.getDictValue("emis_qujian_fangshi",emisWaybillSave.getPickupMethod());
if(pickupMethod==null){
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "取件方式不正确");
}
emisWaybillSave.setPickupMethod(pickupMethod);
// 派送方式
String dispatchMethod=DictUtils.getDictValue("emis_tab_dispatch_mode",emisWaybillSave.getDispatchMethod());
if(dispatchMethod==null){
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "派送方式不正确");
}
emisWaybillSave.setDispatchMethod(dispatchMethod);
// 付款方式
String paymentType=DictUtils.getDictValue("emis_payment_type",emisWaybillSave.getPaymentType());
if(paymentType==null){
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "付款方式不正确");
}
emisWaybillSave.setPaymentType(paymentType);
// 报关方式
String customsEclaration=DictUtils.getDictValue("emis_declare_mode",emisWaybillSave.getCustomsEclaration());
if(customsEclaration==null){
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "报关方式不正确");
}
emisWaybillSave.setCustomsEclaration(customsEclaration);
// 清关方式
String customsClear=DictUtils.getDictValue("emis_customs_clear",emisWaybillSave.getCustomsClear());
if(customsClear==null){
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "清关方式不正确");
}
emisWaybillSave.setCustomsClear(customsClear);
// 计算目的地
EmisDestination destination=calcDestSite(receiveCountryCode,transLine.getLineCode(),rcvProviceCode,rcvCityCode,rcvDistrictCode,emisWaybillSave.getReceiveAddress());
if(destination==null){
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "找不到目的地");
}
try {
// 计算体积重量
calcVolumeWeight(emisWaybillSave);
// 计算结算重量
calcSettledWeight(emisWaybillSave);
// 计算应收费
calcWaybillFee(emisWaybillSave);
}catch (Exception ex){
ex.printStackTrace();
log.error("===草稿下单模式,计费错误:",ex.getMessage());
}
// 如果填写了运费则使用一口价模式
if(emisWaybillSave.getFreight()!=null){
// 一口价模式
emisWaybillSave.setCalcFeeType("3");
}
}
/**
* 根据父区域获取行政区代码
* @return
*/
private String getCountryCodeByName(String name){
EmisCountry country=getCountryByName(name);
if(country!=null){
return country.getCode();
}
return null;
}
/**
* 根据父区域获取行政区代码
* @return
*/
private String getChildRegionCodeByName(String countryCode,String parentCode,String name){
EmisRegion region=getRegionByName(countryCode,parentCode,name);
if(region!=null){
return region.getRegionCode();
}
return null;
}
/**
* 下单接口

View File

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xdadan.erp.emis.mapper.EmisSiteBillControlMapper">
<resultMap type="EmisSiteBillControl" id="EmisSiteBillControlResult">
<result property="id" column="id" />
<result property="sendSiteCode" column="send_site_code" />
<result property="destSiteCode" column="dest_site_code" />
<result property="controlDate" column="control_date" />
<result property="blOpen" column="bl_open" />
</resultMap>
<sql id="selectEmisSiteBillControlVo">
select id, send_site_code, dest_site_code, control_date, bl_open, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_site_bill_control
</sql>
<select id="selectEmisSiteBillControlList" parameterType="EmisSiteBillControl" resultMap="EmisSiteBillControlResult">
<include refid="selectEmisSiteBillControlVo"/>
<where>
del_flag='0'
<if test="id != null "> and id = #{id}</if>
<if test="sendSiteCode != null and sendSiteCode != ''"> and send_site_code like concat('%', #{sendSiteCode}, '%')</if>
<if test="destSiteCode != null and destSiteCode != ''"> and dest_site_code like concat('%', #{destSiteCode}, '%')</if>
<if test="controlDate != null "> and control_date = #{controlDate}</if>
<if test="blOpen != null and blOpen != ''"> and bl_open like concat('%', #{blOpen}, '%')</if>
<if test="remark != null and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
<if test="delFlag != null and delFlag != ''"> and del_flag like concat('%', #{delFlag}, '%')</if>
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="createSite != null and createSite != ''"> and create_site like concat('%', #{createSite}, '%')</if>
<if test="updateSite != null and updateSite != ''"> and update_site like concat('%', #{updateSite}, '%')</if>
</where>
order by create_time desc
</select>
<select id="checkUnique" parameterType="EmisSiteBillControl" resultType="int">
select count(1) from emis_site_bill_control
where del_flag='0'
and id = #{id}
and send_site_code = #{sendSiteCode}
and dest_site_code = #{destSiteCode}
and control_date = #{controlDate}
and bl_open = #{blOpen}
and remark = #{remark}
and del_flag = #{delFlag}
and create_by = #{createBy}
and create_time = #{createTime}
and update_by = #{updateBy}
and update_time = #{updateTime}
and create_site = #{createSite}
and update_site = #{updateSite}
limit 1
</select>
<select id="selectEmisSiteBillControlById" parameterType="Long" resultMap="EmisSiteBillControlResult">
select id, send_site_code, dest_site_code, control_date, bl_open, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_site_bill_control a
where a.id = #{id}
</select>
<insert id="insertEmisSiteBillControl" parameterType="EmisSiteBillControl" useGeneratedKeys="true" keyProperty="id">
insert into emis_site_bill_control
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="sendSiteCode != null and sendSiteCode != ''">send_site_code,</if>
<if test="destSiteCode != null and destSiteCode != ''">dest_site_code,</if>
<if test="controlDate != null">control_date,</if>
<if test="blOpen != null and blOpen != ''">bl_open,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="createSite != null and createSite != ''">create_site,</if>
<if test="updateSite != null and updateSite != ''">update_site,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="sendSiteCode != null and sendSiteCode != ''">#{sendSiteCode},</if>
<if test="destSiteCode != null and destSiteCode != ''">#{destSiteCode},</if>
<if test="controlDate != null">#{controlDate},</if>
<if test="blOpen != null and blOpen != ''">#{blOpen},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createSite != null and createSite != ''">#{createSite},</if>
<if test="updateSite != null and updateSite != ''">#{updateSite},</if>
</trim>
</insert>
<update id="updateEmisSiteBillControl" parameterType="EmisSiteBillControl">
update emis_site_bill_control
<trim prefix="SET" suffixOverrides=",">
<if test="sendSiteCode != null and sendSiteCode != ''">send_site_code = #{sendSiteCode},</if>
<if test="destSiteCode != null and destSiteCode != ''">dest_site_code = #{destSiteCode},</if>
<if test="controlDate != null">control_date = #{controlDate},</if>
<if test="blOpen != null and blOpen != ''">bl_open = #{blOpen},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createSite != null and createSite != ''">create_site = #{createSite},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEmisSiteBillControlById" parameterType="Long">
delete from emis_site_bill_control where id = #{id}
</delete>
<delete id="deleteEmisSiteBillControlByIds" parameterType="String">
delete from emis_site_bill_control where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -41,7 +41,7 @@
<where>
del_flag = '0'
<if test="id != null "> and id = #{id}</if>
<if test="lineCode != null and lineCode != ''"> and line_code like concat('%', #{lineCode}, '%')</if>
<if test="lineCode != null and lineCode != ''"> and line_code=#{lineCode}</if>
<if test="lineName != null and lineName != ''"> and line_name like concat('%', #{lineName}, '%')</if>
<if test="lineNameEn != null and lineNameEn != ''"> and line_name_en like concat('%', #{lineNameEn}, '%')</if>
<if test="meterRate != null and meterRate != ''"> and meter_rate like concat('%', #{meterRate}, '%')</if>