md
This commit is contained in:
parent
9a54bbc61b
commit
0ff3a02c1f
@ -20,11 +20,14 @@ import com.xdadan.erp.common.utils.StringUtils;
|
||||
import com.xdadan.erp.common.utils.poi.ExcelUtil;
|
||||
import com.xdadan.erp.emis.domain.EmisBrand;
|
||||
import com.xdadan.erp.emis.domain.EmisWaybill;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.emis.domain.vo.AddressParseResult;
|
||||
import com.xdadan.erp.emis.domain.vo.Reciever;
|
||||
import com.xdadan.erp.emis.domain.vo.Sender;
|
||||
import com.xdadan.erp.emis.domain.vo.WaybillOrder;
|
||||
import com.xdadan.erp.emis.service.IEmisBrandService;
|
||||
import com.xdadan.erp.emis.service.IEmisElectronicPagService;
|
||||
import com.xdadan.erp.emis.service.IEmisRegionService;
|
||||
import com.xdadan.erp.emis.service.IEmisWaybillService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@ -47,7 +50,7 @@ public class EmisCommonController extends BaseController
|
||||
private IEmisElectronicPagService emisElectronicPagService;
|
||||
|
||||
@Autowired
|
||||
private IEmisWaybillService emisWaybillService;
|
||||
private IEmisRegionService emisRegionService;
|
||||
|
||||
|
||||
/**
|
||||
@ -65,5 +68,26 @@ public class EmisCommonController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取解析地址
|
||||
*/
|
||||
@PostMapping(value = "/parseAddress")
|
||||
public AjaxResult parseAddress(String content)
|
||||
{
|
||||
try {
|
||||
AddressParseResult addressParseResult = emisRegionService.parseAddress(content);
|
||||
return AjaxResult.success("解析成功",addressParseResult);
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
// 返回子定义异常
|
||||
if(ex instanceof EmisBizError){
|
||||
return AjaxResult.error("("+((EmisBizError)ex).getErrorCode()+")"+ex.getMessage());
|
||||
}
|
||||
|
||||
return AjaxResult.error("服务器异常,联系客服");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -106,7 +106,6 @@ public class EmisTmsScanRecordController extends BaseController
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/scanBatch")
|
||||
@JacksonFilter(include= {"id","code","name","nameEn","logo"},value= EmisBrand.class,type= JacksonFilter.JscksonFilterType.RESPONSE)
|
||||
public AjaxResult scanBatch(String[] billCodes,String scanType)
|
||||
{
|
||||
List<EmisWaybill> newList = new ArrayList<>();
|
||||
@ -124,121 +123,7 @@ public class EmisTmsScanRecordController extends BaseController
|
||||
// }
|
||||
|
||||
return AjaxResult.success("批量扫描成功");
|
||||
|
||||
|
||||
// scanType 揽收扫描 emis_tab_scan_type
|
||||
/*
|
||||
"emis_tab_scan_type": [
|
||||
{
|
||||
"label": "收件扫描",
|
||||
"sort": 1,
|
||||
"value": "ACCEPT"
|
||||
},
|
||||
{
|
||||
"label": "揽件扫描",
|
||||
"sort": 2,
|
||||
"value": "GOT"
|
||||
},
|
||||
{
|
||||
"label": "入中转",
|
||||
"sort": 3,
|
||||
"value": "ARRIVAL"
|
||||
},
|
||||
{
|
||||
"label": "出中转",
|
||||
"sort": 4,
|
||||
"value": "DEPARTURE"
|
||||
},
|
||||
{
|
||||
"label": "派件中",
|
||||
"sort": 5,
|
||||
"value": "SENT"
|
||||
},
|
||||
{
|
||||
"label": "第三方代收入库",
|
||||
"sort": 6,
|
||||
"value": "INBOUND"
|
||||
},
|
||||
{
|
||||
"label": "第三方代收快递员取出",
|
||||
"sort": 7,
|
||||
"value": "OUTBOUND"
|
||||
},
|
||||
{
|
||||
"label": "已签收",
|
||||
"sort": 8,
|
||||
"value": "SIGNED"
|
||||
},
|
||||
{
|
||||
"label": "签收失败",
|
||||
"sort": 9,
|
||||
"value": "SIGNFAIL"
|
||||
},
|
||||
{
|
||||
"label": "退回件",
|
||||
"sort": 10,
|
||||
"value": "RETURN"
|
||||
},
|
||||
{
|
||||
"label": "问题件",
|
||||
"sort": 11,
|
||||
"value": "ISSUE"
|
||||
},
|
||||
{
|
||||
"label": "拒收",
|
||||
"sort": 12,
|
||||
"value": "REJECTION"
|
||||
},
|
||||
{
|
||||
"label": "其他",
|
||||
"sort": 13,
|
||||
"value": "OTHER"
|
||||
},
|
||||
{
|
||||
"label": "入库扫描",
|
||||
"sort": 14,
|
||||
"value": "OVERSEA_IN"
|
||||
},
|
||||
{
|
||||
"label": "出库扫描",
|
||||
"sort": 15,
|
||||
"value": "OVERSEA_OUT"
|
||||
},
|
||||
{
|
||||
"label": "清关开始",
|
||||
"sort": 16,
|
||||
"value": "CLEARANCE_START"
|
||||
},
|
||||
{
|
||||
"label": "清关结束",
|
||||
"sort": 17,
|
||||
"value": "CLEARANCE_FINISH"
|
||||
},
|
||||
{
|
||||
"label": "清关失败",
|
||||
"sort": 18,
|
||||
"value": "CLEARANCE_FAIL"
|
||||
},
|
||||
{
|
||||
"label": "干线到达",
|
||||
"sort": 19,
|
||||
"value": "OVERSEA_ARRIVAL"
|
||||
},
|
||||
{
|
||||
"label": "干线离开",
|
||||
"sort": 20,
|
||||
"value": "OVERSEA_DEPARTURE"
|
||||
},
|
||||
{
|
||||
"label": "转单",
|
||||
"sort": 20,
|
||||
"value": "TRANSFER"
|
||||
}
|
||||
],
|
||||
"desc": "扫描类型"
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// return getDataTable(newList);
|
||||
}
|
||||
|
||||
|
||||
@ -15,9 +15,14 @@ public enum EmisBizErrorType {
|
||||
BILL_LOCK("E901", "已锁账,不允许修改"),
|
||||
NOT_EXISTS("E902","运单不存在"),
|
||||
|
||||
PARSE_ADDRESS_ERROR("E980","地址解析错误"),
|
||||
|
||||
|
||||
SUCCESS("0000", "成功"),
|
||||
SYS_EXCEPTION("9998", "系统异常"),
|
||||
FAIL("9999", "失败"),
|
||||
|
||||
|
||||
;
|
||||
|
||||
private String errorCode;
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package com.xdadan.erp.emis.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AddressParseResult {
|
||||
|
||||
private String name;
|
||||
private String phone;
|
||||
|
||||
private String country;
|
||||
private String province;
|
||||
private String city;
|
||||
private String county;
|
||||
|
||||
private String countryName;
|
||||
private String provinceName;
|
||||
private String cityName;
|
||||
private String countyName;
|
||||
|
||||
|
||||
private String address;
|
||||
}
|
||||
@ -88,6 +88,9 @@ public class EmisBaseService {
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Autowired
|
||||
private EmisRegionMapper emisRegionMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前登录用户
|
||||
@ -106,6 +109,21 @@ public class EmisBaseService {
|
||||
return emisWaybillMapper.selectEmisWaybillByBillCode(billCode);
|
||||
}
|
||||
|
||||
public EmisRegion getRegionByName(String name,Integer regionType ){
|
||||
|
||||
EmisRegion queryRegion = new EmisRegion();
|
||||
queryRegion.setRegionName(name);
|
||||
queryRegion.setRegionType(regionType);
|
||||
|
||||
List<EmisRegion> list=emisRegionMapper.selectEmisRegionList(queryRegion);
|
||||
if(!CollectionUtils.isEmpty(list)){
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public EmisSite getSiteByCode(String siteCode){
|
||||
EmisSite querySite = new EmisSite();
|
||||
|
||||
@ -11,6 +11,8 @@ package com.xdadan.erp.emis.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.xdadan.erp.emis.domain.EmisRegion;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.emis.domain.vo.AddressParseResult;
|
||||
|
||||
/**
|
||||
* @ClassName EmisRegionService
|
||||
@ -66,4 +68,7 @@ public interface IEmisRegionService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmisRegionById(Long id);
|
||||
|
||||
public AddressParseResult parseAddress(String content) throws EmisBizError;
|
||||
|
||||
}
|
||||
|
||||
@ -12,6 +12,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.EmisBizError;
|
||||
import com.xdadan.erp.emis.domain.vo.AddressParseResult;
|
||||
import com.xdadan.erp.emis.domain.vo.WaybillOrder;
|
||||
|
||||
/**
|
||||
|
||||
@ -11,6 +11,12 @@
|
||||
package com.xdadan.erp.emis.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.emis.domain.vo.AddressParseResult;
|
||||
import com.xdadan.erp.emis.service.EmisBaseService;
|
||||
import com.xdadan.erp.emis.utils.WaybillHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.xdadan.erp.emis.domain.EmisRegion;
|
||||
@ -24,7 +30,7 @@ import com.xdadan.erp.emis.service.IEmisRegionService;
|
||||
* @date 2024-04-11 15:05:24
|
||||
*/
|
||||
@Service
|
||||
public class EmisRegionServiceImpl implements IEmisRegionService
|
||||
public class EmisRegionServiceImpl extends EmisBaseService implements IEmisRegionService
|
||||
{
|
||||
@Autowired
|
||||
private EmisRegionMapper emisRegionMapper;
|
||||
@ -101,4 +107,53 @@ public class EmisRegionServiceImpl implements IEmisRegionService
|
||||
return emisRegionMapper.deleteEmisRegionById(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 智能解析地址
|
||||
* @param content
|
||||
* @return
|
||||
* @throws EmisBizError
|
||||
*/
|
||||
@Override
|
||||
public AddressParseResult parseAddress(String content) throws EmisBizError {
|
||||
AddressParseResult addressParseResult= null;
|
||||
JSONObject rst = WaybillHelper.parseChinaAddress(content);
|
||||
if(rst!=null){
|
||||
addressParseResult = new AddressParseResult();
|
||||
addressParseResult.setAddress(rst.getString("address"));
|
||||
addressParseResult.setName(rst.getString("name"));
|
||||
addressParseResult.setPhone(rst.getString("phone"));
|
||||
|
||||
String provinceName = rst.getString("province");
|
||||
String citeName = rst.getString("city");
|
||||
String countyName = rst.getString("county");
|
||||
|
||||
addressParseResult.setProvinceName(provinceName);
|
||||
addressParseResult.setCityName(provinceName);
|
||||
addressParseResult.setCountyName(provinceName);
|
||||
|
||||
EmisRegion provinceRegion=getRegionByName(provinceName,1);
|
||||
if(provinceRegion!=null){
|
||||
addressParseResult.setProvince(provinceRegion.getRegionCode());
|
||||
}
|
||||
|
||||
EmisRegion cityRegion=getRegionByName(citeName,2);
|
||||
if(cityRegion!=null){
|
||||
addressParseResult.setCity(cityRegion.getRegionCode());
|
||||
}
|
||||
|
||||
EmisRegion countyRegion=getRegionByName(countyName,3);
|
||||
if(countyRegion!=null){
|
||||
addressParseResult.setCounty(countyRegion.getRegionName());
|
||||
}
|
||||
|
||||
String countryName ="中国";
|
||||
String country ="0086";
|
||||
addressParseResult.setCountry(country);
|
||||
addressParseResult.setCountryName(countryName);
|
||||
|
||||
}
|
||||
return addressParseResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ import com.xdadan.erp.emis.domain.*;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
||||
import com.xdadan.erp.emis.domain.vo.*;
|
||||
import com.xdadan.erp.emis.mapper.EmisRegionMapper;
|
||||
import com.xdadan.erp.emis.mapper.EmisTransLineMapper;
|
||||
import com.xdadan.erp.emis.service.*;
|
||||
import com.xdadan.erp.emis.utils.WaybillHelper;
|
||||
@ -54,6 +55,9 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private IEmisWaybillFeeitemService emisWaybillFeeitemMapper;
|
||||
|
||||
@ -570,6 +574,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Snowflake snowflake = IdUtil.getSnowflake(0, 0);
|
||||
|
||||
@ -2,10 +2,17 @@ package com.xdadan.erp.emis.utils;
|
||||
|
||||
import cn.hutool.core.lang.Snowflake;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xdadan.erp.common.utils.DBUtil;
|
||||
import com.xdadan.erp.common.utils.HTTPHelperV3;
|
||||
import com.xdadan.erp.common.utils.StringUtils;
|
||||
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class WaybillHelper {
|
||||
|
||||
@ -31,6 +38,9 @@ public class WaybillHelper {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 小数进位计算
|
||||
* @param weight
|
||||
@ -132,20 +142,64 @@ public class WaybillHelper {
|
||||
return settledFee;
|
||||
}
|
||||
|
||||
public static JSONObject parseChinaAddress(String content) throws EmisBizError {
|
||||
String url = "http://api2.xdadan.com/api/qcdata/query/express/parseChinaAddress";
|
||||
Map postData = new HashMap();
|
||||
postData.put("content", content);
|
||||
postData.put("appID", "tanex");
|
||||
Map header = new HashMap();
|
||||
|
||||
try {
|
||||
String result = HTTPHelperV3.postWithHeader(url, postData, header);
|
||||
if (!StringUtils.isEmpty(result)) {
|
||||
JSONObject jobj = JSONObject.parseObject(result);
|
||||
if ("0000".equals(jobj.getString("code"))) {
|
||||
return jobj.getJSONObject("info");
|
||||
} else {
|
||||
throw new EmisBizError(EmisBizErrorType.PARSE_ADDRESS_ERROR,jobj.getString("message") );
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
throw new EmisBizError(EmisBizErrorType.SYS_EXCEPTION,"系统异常,联系客服!");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
//1: 1.02 1.1 1.11
|
||||
// 1.02*10 = 10.2 , 1.11*10 = 11.1
|
||||
// 0.2
|
||||
|
||||
double m=0.000001D;
|
||||
double vw=m*(1000000.0D/5000.0D);
|
||||
double d= Double.parseDouble(dfCalc.format(vw));
|
||||
// double m=0.000001D;
|
||||
// double vw=m*(1000000.0D/5000.0D);
|
||||
// double d= Double.parseDouble(dfCalc.format(vw));
|
||||
// get_double = Double.parseDouble(df.format(result_value));
|
||||
// vw 1.005D
|
||||
// double w=calcSettledWeight(vw,"2");
|
||||
// double w=calcSettledFee(1.49D,"2");
|
||||
// System.out.println(w);
|
||||
System.out.println(d);
|
||||
// System.out.println(d);
|
||||
|
||||
try {
|
||||
|
||||
long startAll = System.currentTimeMillis();
|
||||
|
||||
for(int i=0;i<100;i++) {
|
||||
long start = System.currentTimeMillis();
|
||||
JSONObject rst = WaybillHelper.parseChinaAddress("13818415183 孙丹 广西壮族自治区南宁市西乡塘区衡阳街道广西省南宁市衡阳西路34号大院"+i);
|
||||
System.out.println(rst);
|
||||
long end4 = System.currentTimeMillis();
|
||||
System.out.println("escape time single:" + (end4 - start) + "ms");
|
||||
}
|
||||
long endAll = System.currentTimeMillis();
|
||||
|
||||
System.out.println("All escape time:" + (endAll - startAll) + "ms");
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,6 +161,13 @@
|
||||
and start_date <![CDATA[ <= ]]> now() and end_date <![CDATA[ > ]]> now() and status=1
|
||||
</if>
|
||||
|
||||
<if test="params.chargeType != null and params.chargeType==1">
|
||||
and fee_type='1001'
|
||||
</if>
|
||||
<if test="params.chargeType != null and params.chargeType==2">
|
||||
and fee_type!='1001'
|
||||
</if>
|
||||
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user