作者 朱兆平

抬杆指令逻辑优化

... ... @@ -24,3 +24,4 @@
/nbdist/
/.nb-gradle/
/logs/
/bw/
... ...
... ... @@ -38,8 +38,9 @@ public class KAKO_Reader extends Thread{
analysisRoute.setMessage(message);
threadPoolEs.execute(analysisRoute);
logger.info("[THREADPOOL-INFO]-当前运行线程总数量: " + threadPoolEs.getActiveCount());
logger.info("[THREADPOOL-INFO]-线程队列数量: " + threadPoolEs.getQueue().size());
logger.info("[THREADPOOL-INFO]-当前线程数量: " + threadPoolEs.getTaskCount());
logger.info("[THREADPOOL-INFO]-完成的线程总数量: " + threadPoolEs.getCompletedTaskCount());
logger.info("[THREADPOOL-INFO]-线程队列数量: " + threadPoolEs.getQueue().size());
logger.info("[THREADPOOL-INFO]-空闲线程释放时间(秒): " + threadPoolEs.getKeepAliveTime(TimeUnit.SECONDS));
//AnalysisRoute.analysis(message);
... ...
... ... @@ -101,7 +101,8 @@ public class AnalysisRoute implements Runnable{
if(info.getBarcode().length()>0){
//LogicOperation.operation(info)
try {
if(LiftBar.liftBar(info)){
LiftBar lift = new LiftBar();
if(lift.liftBar(info)){
String type = null;
if("I".equals(info.getIetype())){
type="进入";
... ... @@ -112,6 +113,7 @@ public class AnalysisRoute implements Runnable{
logger.info("------->>>>>>>"+info.getVename()+"已"+type+info.getAreaid()+"场站<<<<<<<-----");
}
} catch (InterruptedException e) {
logger.error(e);
e.printStackTrace();
}
}else{
... ...
... ... @@ -2,6 +2,7 @@ package com.sy.logic;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sy.crossDomain.buildBarCode;
import com.sy.model.*;
import com.sy.relation.VeManifestRelation;
... ... @@ -23,6 +24,7 @@ import org.springframework.stereotype.Component;
import org.apache.log4j.Logger;
import javax.annotation.PostConstruct;
import javax.validation.constraints.NotNull;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
... ... @@ -41,6 +43,7 @@ import java.util.Map;
@Component
public class LiftBar {
private static final Logger logger = Logger.getLogger(LiftBar.class);
private static final org.slf4j.Logger log4 = org.slf4j.LoggerFactory.getLogger(LiftBar.class);
@Autowired
private LandBusListService listService;//进出场申请表
@Autowired
... ... @@ -76,10 +79,18 @@ public class LiftBar {
private static String ERRORWT = "出起始场站的重量和进目的场站的重量不一致";
private static String IEPORSE = "无相对应进出场申请";
private static String FANGXING="有运单未放行";
private static String FENBO = "装载运单的分拨申请舱单未通过校验";
//分拨申请回执
private static String ALLOCATE_01 = "39301 分拨申请审核通过。";
private static String ALLOCATE_04 = "39103 分拨申请重复传输,海关审核不通过。";
@Autowired
private FeignService feignService;
@Autowired
private NmmsService nmmsService;
@PostConstruct
public void init() {
logic = this;
... ... @@ -94,13 +105,14 @@ public class LiftBar {
logic.wharfHost=this.wharfHost;
logic.nmmsHost=this.nmmsHost;
logic.feignService=this.feignService;
logic.nmmsService=this.nmmsService;
}
/**
* @Param info 卡口采集数据
* @Result 计算卡口采集数据并发送报文
*/
public static boolean liftBar(GatherInfo info) throws InterruptedException {
public boolean liftBar(GatherInfo info) throws InterruptedException {
PropertyConfigurator.configure("config/log4j.properties");
//默认返回值
boolean result = false;
... ... @@ -114,8 +126,9 @@ public class LiftBar {
//1. 若无车牌号,返回未识别错误
if (vaName.length() <= 0) {
CommandClient.Client(info, NO_CHEPAI + vaName);
logger.error(NO_CHEPAI+vaName);
CommandClient.Client(info, NO_CHEPAI + vaName);
return result;
}
... ... @@ -170,20 +183,25 @@ public class LiftBar {
diffVal = inWt- growssWt;
}
log4.info("[CHECK-INFO]-出场过磅重量:{}-申报装载货物重量:{}-入场过磅重量:{}-进出差值:{}-车重:{}",growssWt,goodsWt,inWt,diffVal,ve.getSelfWt());
//判断场站出场是否要重量校验,配置文件中配置的场站直接抬杆放行.
if(FileTool.readProperties("station").equals(list.getEndstation())||FileTool.readProperties("stationsf").equals(list.getEndstation())){
checkResult=true;
//货物类型判断,直接放行的.todo:这个逻辑比较强大,后期要看怎么处理
}else if(!"普通货物".equals(list.getCocode()) && !"转关货物".equals(list.getCocode())){
//todo:比如货物类型为快件货物,只走重量校验,不走放行信息等校验.
logger.info("车辆装载货物为:"+list.getCocode());
checkResult=true;
}else {
// 出场校验根据业务类型
logger.info("[进出场申请]-业务类型为:"+list.getCocode()+list.getBusinesstype());
switch (list.getBusinesstype()){
case "出口送货":
if (logic.weightCheckHandleService.checkExportDownLoading(growssWt, Double.parseDouble(ve.getSelfWt()), goodsWt,inWt)){
checkResult=true;
}else{
logger.error("[出口送货]-出场重量未通过校验:"+GROWSSEXCETION);
CommandClient.Client(info, GROWSSEXCETION);
return false;
}
... ... @@ -197,21 +215,50 @@ public class LiftBar {
checkResult=true;
}else {
//有运单未放行
logger.error("[进口提货]-出场未通过校验:"+FANGXING+list.getMasterList());
CommandClient.Client(info, FANGXING);
return false;
}
//todo:装载运单历史数据累加超重判定
}else{
logger.error("[进口提货]-出场重量未通过校验:"+GROWSSEXCETION);
CommandClient.Client(info, GROWSSEXCETION);
return false;
}
break;
case "分拨业务":
if (logic.weightCheckHandleService.checkAllocateOrDispatch(growssWt, Double.parseDouble(ve.getSelfWt()), goodsWt,inWt)){
//todo:检查分拨申请
boolean allocatCheck = checkNmmsAllocate(list.getMasterList());
if(!allocatCheck){
logger.error("[分拨业务]-分拨申请舱单未通过校验:"+FENBO);
CommandClient.Client(info, FENBO);
return false;
}
checkResult=true;
//todo:分拨运抵通知,重车入场视为运抵
}else{
logger.error("[分拨业务]-出场重量未通过校验:"+GROWSSEXCETION);
CommandClient.Client(info, GROWSSEXCETION);
return false;
}
break;
case "调拨业务":
if (logic.weightCheckHandleService.checkAllocateOrDispatch(growssWt, Double.parseDouble(ve.getSelfWt()), goodsWt,inWt)){
checkResult=true;
//检查运单放行
if (logic.resMessageService.checkManifestRelease(list.getMasterList())){
checkResult=true;
}else {
//有运单未放行
logger.error("[调拨业务]-出场未通过校验:"+FANGXING+list.getMasterList());
CommandClient.Client(info, FANGXING);
return false;
}
//todo:检查ULD放行.
}else{
logger.error("[调拨业务]-出场未通过校验:"+GROWSSEXCETION);
CommandClient.Client(info, GROWSSEXCETION);
return false;
}
... ... @@ -222,22 +269,25 @@ public class LiftBar {
}
check = logic.weightCheckHandleService.checkResult(growssWt, Double.parseDouble(ve.getSelfWt()), goodsWt,inWt);
if("出口送货".equals(list.getBusinesstype())){
if(check){
checkResult=true;
}else{
CommandClient.Client(info, GROWSSEXCETION);
}
}else{
//其他业务的装载运单放行判断
checkMainfest = logic.checkManifest(list.getMasterList());
if(checkMainfest){
checkResult=check || checkMainfest;
}else{
CommandClient.Client(info, FANGXING);//有运单未放行
}
}
//旧业务逻辑,不启用了
// check = logic.weightCheckHandleService.checkResult(growssWt, Double.parseDouble(ve.getSelfWt()), goodsWt,inWt);
// if("出口送货".equals(list.getBusinesstype())){
// if(check){
// checkResult=true;
// }else{
// CommandClient.Client(info, GROWSSEXCETION);
// }
// }else{
// //其他业务的装载运单放行判断
// checkMainfest = logic.checkManifest(list.getMasterList());
// if(checkMainfest){
// checkResult=check || checkMainfest;
// }else{
// CommandClient.Client(info, FANGXING);//有运单未放行
// }
// }
}
}
... ... @@ -279,7 +329,8 @@ public class LiftBar {
int count=logic.listService.selectlaststation(list.getTrailerFrameNo(),list.getBarcode());
//二维码失效
if(count==0){
buildBarCode.cancleBarCode(vaName);
//测试注释掉
// buildBarCode.cancleBarCode(vaName);
}
/**
... ... @@ -482,14 +533,17 @@ public class LiftBar {
if (!(waybill.indexOf("-") != -1)) {
waybill = waybill.substring(0, 3) + "-" + waybill.substring(3);
}
String url = logic.nmmsHost+"orig/orig?waybill=" + waybill + "&imp=" + imp;
// String url = "http://tjfx.15miaoo.com:8003/tj/orig/orig?waybill=" + waybill + "&imp=" + imp;
// String url = logic.nmmsHost+"orig/orig?waybill=" + waybill + "&imp=" + imp;
String url = "http://tjfx.15miaoo.com:8003/tj/orig/orig?waybill=" + waybill + "&imp=" + imp;
StringBuilder json = new StringBuilder();
Map map = null;
double bg = 0;
try {
URL Url = new URL(url);
URLConnection yc = Url.openConnection();
//设置接口超时
yc.setReadTimeout(5000);
yc.setConnectTimeout(3000);
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream(), "utf-8"));
String inputLine = null;
while ((inputLine = in.readLine()) != null) {
... ... @@ -577,6 +631,7 @@ public class LiftBar {
}
}
}
/**
* 为提前运抵服务发送数据
*
... ... @@ -594,5 +649,57 @@ public class LiftBar {
Map<String,Object> map=logic.feignService.sendMessage(arrive);
logger.info(""+map);
}
/**
* 新舱单分拨申请数据查询
* @param waybill 查询的运单号
* @return
*/
public Map nmmsAllocate(@NotNull String waybill){
logger.info("新舱单查询分拨申请数据开始");
Map map = logic.nmmsService.getAllocate(waybill,0,10);
logger.info(""+map);
return map;
}
public boolean checkNmmsAllocate(String waybill){
if (waybill.length() < 1) {
return false;
}
waybill = waybill.replace("-", "");
//中文逗号替换
waybill = waybill.replace(",", ",");
String[] maifest = waybill.split(",");
logger.info("运单列表:" + waybill);
boolean flag = false;
for (String awb : maifest) {
Map map= nmmsAllocate(awb);
if (map.containsKey("reslut")){
String result = map.get("reslut").toString();
JSONObject jsonObject = JSON.parseObject(result);
if (jsonObject.containsKey("ds")) {
JSONArray ds = jsonObject.getJSONArray("ds");
JSONObject awbinfo = ds.getJSONObject(0);
if (awbinfo.containsKey("RECEIPTINFORMATION")){
if (awbinfo.getString("RECEIPTINFORMATION").contains("39301") || awbinfo.getString("RECEIPTINFORMATION").contains("39103")){
log4.info("运单:{},分拨回执查询结果:{}",awb,awbinfo.getString("RECEIPTINFORMATION"));
}else {
log4.info("运单{}分拨申请回执不正常:{}",awb,awbinfo.getString("RECEIPTINFORMATION"));
return false;
}
}
}else {
log4.info("运单:{}分拨申请回执未查询到,或未进行分拨申请",awb);
return false;
}
}else{
log4.info("运单:{}分拨申请回执未查询到,或未进行分拨申请",awb);
return false;
}
}
return true;
}
}
... ...
... ... @@ -4,5 +4,5 @@ import com.sy.model.LandRoadVe;
public interface LandRoadVeService {
public LandRoadVe selectByFrameNo(String frameNo);
LandRoadVe selectByFrameNo(String frameNo);
}
... ...
package com.sy.service;
import com.sy.service.impl.MessageServiceHystrix;
import com.sy.service.impl.NmmsServiceHystrix;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Map;
/**
* @author mrz
*/
@Component
@FeignClient(name = "nmmsFeign",url = "http://nmms1.15miaoo.com:17999",fallback = NmmsServiceHystrix.class)
public interface NmmsService {
@ResponseBody
@PostMapping("/Allocate/querypage_inportallocate")
Map getAllocate(
@RequestParam(value = "waybill", required = true) String waybill,
@RequestParam(value = "pageIndex", required = true,defaultValue = "0") int pageIndex,
@RequestParam(value = "pageSize", required = true,defaultValue = "10") int pageSize
);
}
... ...
... ... @@ -6,10 +6,12 @@ import com.sy.service.LandRoadVeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class LandRoadVeServiceImpl implements LandRoadVeService {
@Autowired
@Resource
private LandRoadVeMapper veMapper;
@Override
... ...
package com.sy.service.impl;
import com.sy.service.NmmsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.util.Map;
@Service
public class NmmsServiceHystrix implements NmmsService {
private static final Logger logger = LoggerFactory.getLogger(NmmsServiceHystrix.class);
@Override
public Map<String, Object> getAllocate(String waybill, int pageIndex, int pageSize) {
logger.error("查询分拨申请数据失败,{}",waybill);
return null;
}
}
... ...
... ... @@ -18,6 +18,7 @@ public class WeightCheckHandleServiceImpl implements WeightCheckHandleService {
//从配置文件中读取货物重差可控范围
private static String checkWt = FileTool.readProperties("grossWt");
/**
* 校验载重和称重是否在合理的范围
*
... ... @@ -72,9 +73,12 @@ public class WeightCheckHandleServiceImpl implements WeightCheckHandleService {
double result2= 0.0;
if(grossWt>0){
result = Double.parseDouble(df.format(Math.abs((inWt - goodsWt - grossWt)) / grossWt));
System.out.println("进出场比对差值:"+result);
result2 = Double.parseDouble(df.format(Math.abs((grossWt-wt)) / grossWt));
System.out.println("空车出场差值:"+result2);
}
if (result <= valueDob() || result2 <= valueDob()) {
double range = valueDob();
if (result <= range || result2 <= range) {
flag = true;
}
return flag;
... ... @@ -96,12 +100,30 @@ public class WeightCheckHandleServiceImpl implements WeightCheckHandleService {
DecimalFormat df = new DecimalFormat("0.00");
boolean flag = false;
double result= 0.0;
double result1= 0.0;
if(grossWt>0){
//进场过磅重量+带货重量 = 出场过磅重量
result = Double.parseDouble(df.format(Math.abs((inWt + goodsWt - grossWt)) / grossWt));
//todo:这里没有加空车离场判定,暂时不加,进口提货业务空车离场走空车验放判定系统.
//车辆备案重量+货物重量 = 出场过磅重量,测试用,生产关闭
result1 = Double.parseDouble(df.format(Math.abs((wt + goodsWt - grossWt)) / grossWt));
}
if (result <= valueDob()) {
double range = valueDob();
System.out.println("进出场差值:"+result);
System.out.println("提货离场差值:"+result1);
if (result <= range) {
flag = true;
}
//车辆备案重量+货物重量 = 出场过磅重量,测试用,生产关闭
if (result1 <= range) {
return true;
}
return flag;
}
... ... @@ -133,8 +155,12 @@ public class WeightCheckHandleServiceImpl implements WeightCheckHandleService {
result = Double.parseDouble(df.format(Math.abs((inWt + goodsWt - grossWt)) / grossWt));
result2 = Double.parseDouble(df.format(Math.abs((grossWt-wt)) / grossWt));
result3 = Double.parseDouble(df.format(Math.abs((inWt - goodsWt - grossWt)) / grossWt));
System.out.println("进场提货离场差值:"+result);
System.out.println("空车离场差值:"+result2);
System.out.println("进场卸货离场差值:"+result3);
}
if (result <= valueDob() || result2 <= valueDob() || result3 <= valueDob() ) {
double range = valueDob();
if (result <= range || result2 <= range || result3 <= range ) {
flag = true;
}
return flag;
... ...
... ... @@ -7,6 +7,7 @@ import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter;
public class NumberConverter extends AbstractSingleValueConverter{
@Override
public boolean canConvert(Class type) {
return type.equals(BigDecimal.class);
}
... ...
package com.sy;
import com.sy.bwAnalysis.AnalysisRoute;
import com.sy.logic.LiftBar;
import com.sy.utils.XMLThreadPoolFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.concurrent.ThreadPoolExecutor;
@RunWith(SpringRunner.class)
@SpringBootTest
public class BeihuoAllocateTests {
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(LiftBar.class);
private static ThreadPoolExecutor threadPoolEs = XMLThreadPoolFactory.instance("kakou");
private AnalysisRoute analysisRoute=new AnalysisRoute();
//车牌号
private String voNo = "豫A61CR7";
//备案重量
private String vo_weight = "2000";
//过卡重量
private String cross_weight= "2324";
//场站编号
private String areaID = "4604600000";
//通道编号
private String chnlNo = "4604601010";
//进出场类型I/E
private String ie = "I";
//二维码
private String barcode = "613f5c";
//进通道报文
private static String IMPORT_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<MSG>\n" +
"\t<META>\n" +
"\t\t<SNDR>KAO</SNDR>\n" +
"\t\t<RCVR/>\n" +
"\t\t<SEQN>20220624063157</SEQN>\n" +
"\t\t<DDTM>20220624063157</DDTM>\n" +
"\t\t<TYPE>KAKO</TYPE>\n" +
"\t\t<STYP>CARM</STYP>\n" +
"\t</META>\n" +
"\t<GATHER_INFO AREA_ID=\"${areaID}\" CHNL_NO=\"${chnlNo}\" I_E_TYPE=\"${IETYPE}\" SEQ_NO=\"20220624063118000004\">\n" +
"\t\t<IC>\n" +
"\t\t\t<DR_IC_NO/>\n" +
"\t\t\t<IC_DR_CUSTOMS_NO/>\n" +
"\t\t\t<IC_CO_CUSTOMS_NO/>\n" +
"\t\t\t<IC_BILL_NO/>\n" +
"\t\t\t<IC_FORM_TYPE/>\n" +
"\t\t\t<IC_GROSS_WT/>\n" +
"\t\t\t<IC_VE_CUSTOMS_NO/>\n" +
"\t\t\t<IC_VE_NAME/>\n" +
"\t\t\t<IC_CONTA_ID/>\n" +
"\t\t\t<IC_ESEAL_ID/>\n" +
"\t\t\t<IC_REG_DATETIME/>\n" +
"\t\t\t<IC_PER_DAY_DUE/>\n" +
"\t\t\t<GPS_ID/>\n" +
"\t\t</IC>\n" +
"\t\t<WEIGHT>\n" +
"\t\t\t<GROSS_WT>${cross_weight}</GROSS_WT>\n" +
"\t\t</WEIGHT>\n" +
"\t\t<CAR>\n" +
"\t\t\t<VE_NAME>${car}</VE_NAME>\n" +
"\t\t\t<CAR_EC_NO/>\n" +
"\t\t\t<CAR_EC_NO2/>\n" +
"\t\t\t<VE_CUSTOMS_NO/>\n" +
"\t\t\t<VE_WT/>\n" +
"\t\t</CAR>\n" +
"\t\t<CONTA>\n" +
"\t\t\t<CONTA_NUM/>\n" +
"\t\t\t<CONTA_RECO>1</CONTA_RECO>\n" +
"\t\t\t<CONTA_ID_F/>\n" +
"\t\t\t<CONTA_ID_B/>\n" +
"\t\t\t<CONTA_MODEL_F/>\n" +
"\t\t\t<CONTA_MODEL_B/>\n" +
"\t\t</CONTA>\n" +
"\t\t<ORDER_NUM/>\n" +
"\t\t<BAR_CODE>${barcode}</BAR_CODE>\n" +
"\t\t<SEAL>\n" +
"\t\t\t<ESEAL_ID/>\n" +
"\t\t\t<SEAL_KEY/>\n" +
"\t\t</SEAL>\n" +
"\t</GATHER_INFO>\n" +
"</MSG>";
/**
* 分拨业务_进场测试_入场提货_第一场站_空车进北货
*/
@Test
public void allocate_I1() throws InterruptedException {
//车牌号
String voNo = "豫A61CR9";
//过卡重量
String cross_weight= "4300";
//场站编号-北货
String areaID = "4604600000";
//通道编号
String chnlNo = "4604601030";
//进出场类型I/E
String ie = "I";
//二维码
String barcode = "9cc260";
logger.error("开始分拨业务进场测试1");
IMPORT_XML= IMPORT_XML.replace("${car}",voNo)
.replace("${cross_weight}",cross_weight)
.replace("${areaID}",areaID)
.replace("${chnlNo}",chnlNo)
.replace("${IETYPE}",ie)
.replace("${barcode}",barcode);
//进港提货测试
analysisRoute.setMessage(IMPORT_XML);
analysisRoute.run();
}
/**
* 分拨业务_离场测试_提货离场_第一场站_提货出北货
*/
@Test
public void allocate_E1() throws InterruptedException {
//车牌号
String voNo = "豫A61CR9";
//过卡重量
String cross_weight= String.valueOf(4300+1921);
//场站编号-北货
String areaID = "4604600000";
//通道编号
String chnlNo = "4604600030";
//进出场类型I/E
String ie = "E";
//二维码
String barcode = "9cc260";
logger.error("开始分拨离场测试1");
IMPORT_XML= IMPORT_XML.replace("${car}",voNo)
.replace("${cross_weight}",cross_weight)
.replace("${areaID}",areaID)
.replace("${chnlNo}",chnlNo)
.replace("${IETYPE}",ie)
.replace("${barcode}",barcode);
//进港提货测试
analysisRoute.setMessage(IMPORT_XML);
analysisRoute.run();
}
/**
* 分拨业务_进场测试_入场提货_第二场站_载货进第二场站
*/
@Test
public void allocate_I2() throws InterruptedException {
//车牌号
String voNo = "豫A61CR9";
//过卡重量
String cross_weight= String.valueOf(4300+2310.00);
//场站编号-西货站
String areaID = "4604000000";
//通道编号
String chnlNo = "4604333321";
//进出场类型I/E
String ie = "I";
//二维码
String barcode = "9cc260";
logger.error("开始分拨业务进场测试1");
IMPORT_XML= IMPORT_XML.replace("${car}",voNo)
.replace("${cross_weight}",cross_weight)
.replace("${areaID}",areaID)
.replace("${chnlNo}",chnlNo)
.replace("${IETYPE}",ie)
.replace("${barcode}",barcode);
//进港提货测试
analysisRoute.setMessage(IMPORT_XML);
analysisRoute.run();
}
/**
* 分拨业务_离场测试_提货离场_第一场站_提货出北货
*/
@Test
public void allocate_E2() throws InterruptedException {
//车牌号
String voNo = "豫A61CR9";
//过卡重量
String cross_weight= String.valueOf(4300);
//场站编号-北货
String areaID = "4604000000";
//通道编号
String chnlNo = "4604333322";
//进出场类型I/E
String ie = "E";
//二维码
String barcode = "9cc260";
logger.error("开始分拨离场测试1");
IMPORT_XML= IMPORT_XML.replace("${car}",voNo)
.replace("${cross_weight}",cross_weight)
.replace("${areaID}",areaID)
.replace("${chnlNo}",chnlNo)
.replace("${IETYPE}",ie)
.replace("${barcode}",barcode);
//进港提货测试
analysisRoute.setMessage(IMPORT_XML);
analysisRoute.run();
}
/**
* 调拨申请查询
*/
@Test
public void allocate(){
LiftBar liftBar = new LiftBar();
liftBar.checkNmmsAllocate("160-14342370,172-36357112,180-66012590,82814608112");
}
}
... ...
... ... @@ -3,7 +3,6 @@ package com.sy;
import com.sy.bwAnalysis.AnalysisRoute;
import com.sy.logic.LiftBar;
import com.sy.utils.XMLThreadPoolFactory;
import org.apache.log4j.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
... ... @@ -16,8 +15,7 @@ import java.util.concurrent.TimeUnit;
@SpringBootTest
public class BeihuoTests {
private static final Logger logger = Logger.getLogger(LiftBar.class);
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(LiftBar.class);
private static ThreadPoolExecutor threadPoolEs = XMLThreadPoolFactory.instance("kakou");
private AnalysisRoute analysisRoute=new AnalysisRoute();
... ... @@ -93,13 +91,72 @@ public class BeihuoTests {
"\t</GATHER_INFO>\n" +
"</MSG>";
public static String XML = "<MSG>\n" +
"\t<META>\n" +
"\t\t<SNDR>KAO</SNDR>\n" +
"\t\t<RCVR/>\n" +
"\t\t<SEQN>20220624063157</SEQN>\n" +
"\t\t<DDTM>20220624063157</DDTM>\n" +
"\t\t<TYPE>KAKO</TYPE>\n" +
"\t\t<STYP>CARM</STYP>\n" +
"\t</META>\n" +
"\t<GATHER_INFO AREA_ID=\"0000000000\" CHNL_NO=\"0000000000\" I_E_TYPE=\"I\" SEQ_NO=\"123\">\n" +
"\t\t<IC>\n" +
"\t\t\t<DR_IC_NO/>\n" +
"\t\t\t<IC_DR_CUSTOMS_NO/>\n" +
"\t\t\t<IC_CO_CUSTOMS_NO/>\n" +
"\t\t\t<IC_BILL_NO/>\n" +
"\t\t\t<IC_GROSS_WT/>\n" +
"\t\t\t<IC_VE_CUSTOMS_NO/>\n" +
"\t\t\t<IC_VE_NAME/>\n" +
"\t\t\t<IC_CONTA_ID/>\n" +
"\t\t\t<IC_ESEAL_ID/>\n" +
"\t\t\t<IC_EX_DATA/>\n" +
"\t\t</IC>\n" +
"\t\t<WEIGHT>\n" +
"\t\t\t<GROSS_WT>22000</GROSS_WT>\n" +
"\t\t</WEIGHT>\n" +
"\t\t<CAR>\n" +
"\t\t\t<VE_NAME/>\n" +
"\t\t\t<CAR_EC_NO/>\n" +
"\t\t\t<CAR_EC_NO2/>\n" +
"\t\t\t<VE_CUSTOMS_NO/>\n" +
"\t\t\t<VE_WT/>\n" +
"\t\t</CAR>\n" +
"\t\t<CONTA>\n" +
"\t\t\t<CONTA_NUM/>\n" +
"\t\t\t<CONTA_RECO/>\n" +
"\t\t\t<CONTA_MODEL_F/>\n" +
"\t\t\t<CONTA_MODEL_B/>\n" +
"\t\t\t<CONTA_ID_F/>\n" +
"\t\t\t<CONTA_ID_B/>\n" +
"\t\t</CONTA>\n" +
"\t\t<SEAL>\n" +
"\t\t\t<ESEAL_ID/>\n" +
"\t\t</SEAL>\n" +
"\t\t<BAR_CODE>1111</BAR_CODE>\n" +
"\t</GATHER_INFO>\n" +
"</MSG>";
/**
* 出口送货_进场测试
* 进场测试
*/
@Test
public void exportDownload_I(){
public void exportDownload_I() throws InterruptedException {
//车牌号
String voNo = "豫A61CR7";
//过卡重量
String cross_weight= "2000";
//场站编号
String areaID = "4604600000";
//通道编号
String chnlNo = "4604601011";
//进出场类型I/E
String ie = "I";
//二维码
String barcode = "5198ad";
logger.error("开始进场测试");
IMPORT_XML= IMPORT_XML.replace("${car}",voNo)
IMPORT_XML= XML.replace("${car}",voNo)
.replace("${cross_weight}",cross_weight)
.replace("${areaID}",areaID)
.replace("${chnlNo}",chnlNo)
... ... @@ -108,21 +165,19 @@ public class BeihuoTests {
//进港提货测试
analysisRoute.setMessage(IMPORT_XML);
analysisRoute.run();
}
/**
* 出口送货_出场测试
* 出场测试
*/
@Test
public void exportDownload_E(){
//车牌号
String voNo = "豫A61CR7";
//备案重量
String vo_weight = "2000";
//过卡重量
String cross_weight= "2324";
String cross_weight= String.valueOf(2000);
//场站编号
String areaID = "4604600000";
//通道编号
... ... @@ -130,7 +185,7 @@ public class BeihuoTests {
//进出场类型I/E
String ie = "E";
//二维码
String barcode = "613f5c";
String barcode = "5198ad";
logger.error("开始出口送货离场测试");
IMPORT_XML= IMPORT_XML.replace("${car}",voNo)
.replace("${cross_weight}",cross_weight)
... ... @@ -140,14 +195,175 @@ public class BeihuoTests {
.replace("${barcode}",barcode);
//进港提货测试
analysisRoute.setMessage(IMPORT_XML);
threadPoolEs.execute(analysisRoute);
analysisRoute.run();
System.out.println("[THREAD-INFI]-线程运行线程总数量 = " + threadPoolEs.getActiveCount());
System.out.println("[THREAD-INFI]-线程队列数量 = " + threadPoolEs.getQueue().size());
System.out.println("threadPoolEs.getCompletedTaskCount() = " + threadPoolEs.getCompletedTaskCount());
System.out.println("threadPoolEs.getKeepAliveTime(TimeUnit.SECONDS) = " + threadPoolEs.getKeepAliveTime(TimeUnit.SECONDS));
System.out.println("threadPoolEs.getTaskCount() = " + threadPoolEs.getTaskCount());
}
/**
* 带货送货测试
*/
@Test
public void exportDownload_I_withGoods() {
//车牌号
voNo = "豫A61CR7";
//过卡重量
cross_weight= "3000";
//场站编号
areaID = "4604600000";
//通道编号
chnlNo = "4604601011";
//进出场类型I/E
ie = "I";
//二维码
barcode = "78825a";
message();
}
@Test
public void exportDownload_e_withGoods() {
//车牌号
voNo = "豫A61CR7";
//过卡重量
cross_weight= String.valueOf(3000-402.00);
//场站编号
areaID = "4604600000";
//通道编号
chnlNo = "4604600011";
//进出场类型I/E
ie = "E";
//二维码
barcode = "78825a";
message();
}
/**
* 带货提货测试
*/
@Test
public void DLV_I_withGoods() {
//车牌号
voNo = "豫A61CR7";
//过卡重量
cross_weight= "4000";
//场站编号
areaID = "4604600000";
//通道编号
chnlNo = "4604601011";
//进出场类型I/E
ie = "I";
//二维码
barcode = "14e13a";
message();
}
@Test
public void DLV_e_withGoods() {
//车牌号
voNo = "豫A61CR7";
//过卡重量
cross_weight= String.valueOf(4000+3000);
//场站编号
areaID = "4604600000";
//通道编号
chnlNo = "4604600011";
//进出场类型I/E
ie = "E";
//二维码
barcode = "14e13a";
message();
}
/**
* 分批送货,加带货送货一起了
*/
@Test
public void export_I_withGoodsSplit() {
//车牌号
voNo = "豫A61CR7";
//过卡重量
cross_weight= "4000";
//场站编号
areaID = "4604600000";
//通道编号
chnlNo = "4604601011";
//进出场类型I/E
ie = "I";
//二维码
barcode = "1498f9";
message();
}
@Test
public void export_E_withGoodsSplit() {
//车牌号
voNo = "豫A61CR7";
//过卡重量
cross_weight= String.valueOf(4000-2742);
//场站编号
areaID = "4604600000";
//通道编号
chnlNo = "4604600011";
//进出场类型I/E
ie = "E";
//二维码
barcode = "1498f9";
message();
}
/**
* 分批提货+带货提货
*/
@Test
public void dlv_I_withGoodsSplit() {
//车牌号
voNo = "豫A61CR7";
//过卡重量
cross_weight= "4000";
//场站编号
areaID = "4604600000";
//通道编号
chnlNo = "4604601011";
//进出场类型I/E
ie = "I";
//二维码
barcode = "7d0368";
message();
}
@Test
public void dlv_E_withGoodsSplit() {
//车牌号
voNo = "豫A61CR7";
//过卡重量
cross_weight= String.valueOf(4000+2700);
//场站编号
areaID = "4604600000";
//通道编号
chnlNo = "4604600011";
//进出场类型I/E
ie = "E";
//二维码
barcode = "7d0368";
message();
}
/**
*
*/
public void message(){
logger.error("开始进场测试");
IMPORT_XML= IMPORT_XML.replace("${car}",voNo)
.replace("${cross_weight}",cross_weight)
.replace("${areaID}",areaID)
.replace("${chnlNo}",chnlNo)
.replace("${IETYPE}",ie)
.replace("${barcode}",barcode);
//进港提货测试
analysisRoute.setMessage(IMPORT_XML);
analysisRoute.run();
}
}
... ...
package com.sy;
import com.sy.bwAnalysis.AnalysisRoute;
import com.sy.logic.LiftBar;
import com.sy.utils.XMLThreadPoolFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.concurrent.ThreadPoolExecutor;
/**
* 调拨测试
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class BeihuoTransfersTests {
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(LiftBar.class);
private static ThreadPoolExecutor threadPoolEs = XMLThreadPoolFactory.instance("kakou");
private AnalysisRoute analysisRoute=new AnalysisRoute();
//车牌号
private String voNo = "豫A61CR8";
//备案重量
private String vo_weight = "4200";
//过卡重量
private String cross_weight= "2324";
//场站编号
private String areaID = "4604600000";
//通道编号
private String chnlNo = "4604601010";
//进出场类型I/E
private String ie = "I";
//二维码
private String barcode = "613f5c";
//进通道报文
private static String IMPORT_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<MSG>\n" +
"\t<META>\n" +
"\t\t<SNDR>KAO</SNDR>\n" +
"\t\t<RCVR/>\n" +
"\t\t<SEQN>20220624063157</SEQN>\n" +
"\t\t<DDTM>20220624063157</DDTM>\n" +
"\t\t<TYPE>KAKO</TYPE>\n" +
"\t\t<STYP>CARM</STYP>\n" +
"\t</META>\n" +
"\t<GATHER_INFO AREA_ID=\"${areaID}\" CHNL_NO=\"${chnlNo}\" I_E_TYPE=\"${IETYPE}\" SEQ_NO=\"20220624063118000004\">\n" +
"\t\t<IC>\n" +
"\t\t\t<DR_IC_NO/>\n" +
"\t\t\t<IC_DR_CUSTOMS_NO/>\n" +
"\t\t\t<IC_CO_CUSTOMS_NO/>\n" +
"\t\t\t<IC_BILL_NO/>\n" +
"\t\t\t<IC_FORM_TYPE/>\n" +
"\t\t\t<IC_GROSS_WT/>\n" +
"\t\t\t<IC_VE_CUSTOMS_NO/>\n" +
"\t\t\t<IC_VE_NAME/>\n" +
"\t\t\t<IC_CONTA_ID/>\n" +
"\t\t\t<IC_ESEAL_ID/>\n" +
"\t\t\t<IC_REG_DATETIME/>\n" +
"\t\t\t<IC_PER_DAY_DUE/>\n" +
"\t\t\t<GPS_ID/>\n" +
"\t\t</IC>\n" +
"\t\t<WEIGHT>\n" +
"\t\t\t<GROSS_WT>${cross_weight}</GROSS_WT>\n" +
"\t\t</WEIGHT>\n" +
"\t\t<CAR>\n" +
"\t\t\t<VE_NAME>${car}</VE_NAME>\n" +
"\t\t\t<CAR_EC_NO/>\n" +
"\t\t\t<CAR_EC_NO2/>\n" +
"\t\t\t<VE_CUSTOMS_NO/>\n" +
"\t\t\t<VE_WT/>\n" +
"\t\t</CAR>\n" +
"\t\t<CONTA>\n" +
"\t\t\t<CONTA_NUM/>\n" +
"\t\t\t<CONTA_RECO>1</CONTA_RECO>\n" +
"\t\t\t<CONTA_ID_F/>\n" +
"\t\t\t<CONTA_ID_B/>\n" +
"\t\t\t<CONTA_MODEL_F/>\n" +
"\t\t\t<CONTA_MODEL_B/>\n" +
"\t\t</CONTA>\n" +
"\t\t<ORDER_NUM/>\n" +
"\t\t<BAR_CODE>${barcode}</BAR_CODE>\n" +
"\t\t<SEAL>\n" +
"\t\t\t<ESEAL_ID/>\n" +
"\t\t\t<SEAL_KEY/>\n" +
"\t\t</SEAL>\n" +
"\t</GATHER_INFO>\n" +
"</MSG>";
/**
* 分拨业务_进场测试_入场提货_第一场站_空车进北货
*/
@Test
public void allocate_I1() throws InterruptedException {
//车牌号
String voNo = "豫A61CR8";
//过卡重量
String cross_weight= "4200";
//场站编号-综保区
String areaID = "4600329012";
//通道编号-主卡
String chnlNo = "4600011005";
//进出场类型I/E
String ie = "I";
//二维码
String barcode = "9aeb41";
logger.error("开始出口调拨业务进场测试1");
IMPORT_XML= IMPORT_XML.replace("${car}",voNo)
.replace("${cross_weight}",cross_weight)
.replace("${areaID}",areaID)
.replace("${chnlNo}",chnlNo)
.replace("${IETYPE}",ie)
.replace("${barcode}",barcode);
//进港提货测试
analysisRoute.setMessage(IMPORT_XML);
analysisRoute.run();
}
/**
* 分拨业务_离场测试_提货离场_第一场站_提货出北货
*/
@Test
public void allocate_E1() throws InterruptedException {
//车牌号
String voNo = "豫A61CR8";
//过卡重量
String cross_weight= String.valueOf(4200+1701.00);
//场站编号-综保区
String areaID = "4600329012";
//通道编号-主卡6
String chnlNo = "4600010006";
//进出场类型I/E
String ie = "E";
//二维码
String barcode = "9aeb41";
logger.error("开始分拨离场测试1");
IMPORT_XML= IMPORT_XML.replace("${car}",voNo)
.replace("${cross_weight}",cross_weight)
.replace("${areaID}",areaID)
.replace("${chnlNo}",chnlNo)
.replace("${IETYPE}",ie)
.replace("${barcode}",barcode);
//进港提货测试
analysisRoute.setMessage(IMPORT_XML);
analysisRoute.run();
}
/**
* 分拨业务_进场测试_入场提货_第二场站_载货进第二场站
*/
@Test
public void allocate_I2() throws InterruptedException {
//车牌号
String voNo = "豫A61CR8";
//过卡重量
String cross_weight= String.valueOf(4200+1701.00);
//场站编号-北货站
String areaID = "4604600000";
//通道编号-三号进
String chnlNo = "4604601030";
//进出场类型I/E
String ie = "I";
//二维码
String barcode = "9aeb41";
logger.error("开始调拨业务进场测试2,带货入场");
IMPORT_XML= IMPORT_XML.replace("${car}",voNo)
.replace("${cross_weight}",cross_weight)
.replace("${areaID}",areaID)
.replace("${chnlNo}",chnlNo)
.replace("${IETYPE}",ie)
.replace("${barcode}",barcode);
//进港提货测试
analysisRoute.setMessage(IMPORT_XML);
analysisRoute.run();
}
/**
* 分拨业务_离场测试_提货离场_第一场站_提货出北货
*/
@Test
public void allocate_E2() throws InterruptedException {
//车牌号
String voNo = "豫A61CR8";
//过卡重量
String cross_weight= String.valueOf(4200);
//场站编号-北货
String areaID = "4604600000";
//通道编号
String chnlNo = "4604600030";
//进出场类型I/E
String ie = "E";
//二维码
String barcode = "9aeb41";
logger.error("开始调拨离场测试2");
IMPORT_XML= IMPORT_XML.replace("${car}",voNo)
.replace("${cross_weight}",cross_weight)
.replace("${areaID}",areaID)
.replace("${chnlNo}",chnlNo)
.replace("${IETYPE}",ie)
.replace("${barcode}",barcode);
//进港提货测试
analysisRoute.setMessage(IMPORT_XML);
analysisRoute.run();
}
}
... ...