作者 zhangFan

kakoIMF check some message

#登录账号
loginname = KAKO
loginname = KAOR
#登录密码
loginpass = KAKO
loginpass = KAOR
#发送报文目录,相对程序目录
readDirectory = sendDirectory
#接收存储报文目录
bakDirectory = receiveDirectory
#IMF MEAT报头配置
RCVR=
TYPE=KAKO
STYP=CARM
... ...
... ... @@ -8,8 +8,8 @@ import com.sy.model.LandBusinessTypeList;
import com.sy.model.LandRoadVe;
import com.sy.service.LandBusListService;
import com.sy.service.LandRoadVeService;
import com.sy.socket.CommandClient;
import com.sy.utils.FileTool;
import com.sy.utils.UUIDCreate;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -24,6 +24,7 @@ import java.net.URL;
import java.net.URLConnection;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;
... ... @@ -65,20 +66,35 @@ public class LogicOperation {
for (LandBusinessTypeList list:lists) {
//查询是否做了出场申请
if(list.getContrastflag()=="" | list.getContrastflag()==null){
//判断车重
//判断载货重量是否符合所设定的范围
double goodsWt = GoodsWt(list.getMasterList(),"E");
if(checkResult(growsswWt,Double.parseDouble(ve.getSelfWt()),goodsWt)){
sign = true;
}
//发送放行指令
String flag = "";
CommandClient.Client(info,flag);
list.setContrastflag("已出站");
logic.listService.updateById(list);
if("货物流转".equals(list.getBusinesstype()) |"分拨分流".equals(list.getBusinesstype())){
if(list.getMasterList().length()>0) {
createTypeList(list);
}
}
}
}
}else {
ietype = "进场站";
lists = listService.selectByFrameNoAndType(info.getIcvename(),ietype);
for (LandBusinessTypeList list:lists) {
//查询是否做了出场申请
if(list.getContrastflag()=="" | list.getContrastflag()==null){
//判断载货重量是否符合所设定的范围
double goodsWt = GoodsWt(list.getMasterList(),"I");
if(checkResult(growsswWt,Double.parseDouble(ve.getSelfWt()),goodsWt)){
sign = true;
}
list.setContrastflag("已进站");
logic.listService.updateById(list);
}
}
}
return sign;
}
... ... @@ -119,10 +135,12 @@ public class LogicOperation {
* 获取货物总重
* */
public static double GoodsWt(String mainifast,String ietype){
String [] mainifastList = mainifast.split(",");
Double sum = 0.0;
for (String mainBill:mainifastList) {
sum = sum+=getGrossWt(mainBill,ietype);
if(mainifast.length()>0){
String [] mainifastList = mainifast.split(",");
for (String mainBill:mainifastList) {
sum = sum+=getGrossWt(mainBill,ietype);
}
}
return sum;
}
... ... @@ -162,4 +180,32 @@ public class LogicOperation {
}
return bg;
}
/**
* 分拨或者流转业务生成新的进站申请
* */
public static int createTypeList(LandBusinessTypeList list){
LandBusinessTypeList typeList = new LandBusinessTypeList();
typeList.setId(UUIDCreate.getUUID());
typeList.setAgentname(list.getAgentname());
typeList.setAgentno(list.getAgentno());
typeList.setAisle("1号卡口");
typeList.setCreateBy(list.getCreateBy());
typeList.setUpdateBy(list.getUpdateBy());
typeList.setCreateDate(new Date());
typeList.setUpdateDate(new Date());
typeList.setCocode(list.getCocode());
typeList.setDriverid(list.getDriverid());
typeList.setStartport(list.getEndport());
typeList.setStartsatation(list.getEndstation());
typeList.setEndport(list.getStartport());
typeList.setEndstation(list.getStartsatation());
typeList.setTrailerFrameNo(list.getTrailerFrameNo());
typeList.setTrailerLicenseNo(list.getTrailerFrameNo());
typeList.setTurnoverflag("进场站");
typeList.setProdectTime(new Date());
typeList.setMasterList(list.getMasterList());
typeList.setBusinesstype(list.getBusinesstype());
int result = logic.listService.saveList(typeList);
return result;
}
}
... ...
... ... @@ -18,4 +18,5 @@ public interface airone_ex_stockMapper {
int updateByPrimaryKey(airone_ex_stock record);
airone_ex_stock selectByMawbNo(String mawbNo);
}
\ No newline at end of file
... ...
... ... @@ -13,6 +13,8 @@ public interface airone_im_stockMapper {
airone_im_stock selectByPrimaryKey(String workNo);
airone_im_stock selectByMawbAndHawb(String mawbNo,String hawbNo);
int updateByPrimaryKeySelective(airone_im_stock record);
int updateByPrimaryKey(airone_im_stock record);
... ...
... ... @@ -10,4 +10,6 @@ public interface LandBusListService {
List<LandBusinessTypeList> selectByFrameNoAndType(String frameNo, String flag);
int updateById(LandBusinessTypeList list);
int saveList(LandBusinessTypeList list);
}
... ...
... ... @@ -6,4 +6,8 @@ public interface aironeExStockService {
int save(airone_ex_stock ex);
airone_ex_stock selectByMawbNo(String mawbNo);
int delectByWorkNo(String workNo);
}
... ...
... ... @@ -5,4 +5,10 @@ import com.sy.model.airone_im_stock;
public interface aironeImStockService {
int save(airone_im_stock im);
//根据主分单查询
airone_im_stock selectByMawbAndHawb(String manwNo,String hawbNo);
int updateById(airone_im_stock stock);
int delectByWarkNo(String workNo);
}
... ...
... ... @@ -31,4 +31,9 @@ public class LandBusListServiceImpl implements LandBusListService {
}
return 0;
}
@Override
public int saveList(LandBusinessTypeList list) {
return listMapper.insert(list);
}
}
... ...
... ... @@ -6,7 +6,7 @@ import com.sy.service.aironeExStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service("exStockService")
@Service
public class aironeExStockServiceImpl implements aironeExStockService {
@Autowired
... ... @@ -22,4 +22,26 @@ public class aironeExStockServiceImpl implements aironeExStockService {
}
return row;
}
@Override
public airone_ex_stock selectByMawbNo(String mawbNo) {
airone_ex_stock stock = null;
try{
stock = exStockMapper.selectByMawbNo(mawbNo);
}catch (Exception e){
e.printStackTrace();
}
return stock;
}
@Override
public int delectByWorkNo(String workNo) {
int result = 0;
try{
result = exStockMapper.deleteByPrimaryKey(workNo);
}catch (Exception e){
e.printStackTrace();
}
return result;
}
}
... ...
... ... @@ -21,4 +21,31 @@ public class aironeImStockServiceImpl implements aironeImStockService {
}
return row;
}
@Override
public int updateById(airone_im_stock stock) {
return imStockMapper.updateByPrimaryKeySelective(stock);
}
@Override
public airone_im_stock selectByMawbAndHawb(String manwNo, String hawbNo) {
airone_im_stock stock = null;
try {
stock = imStockMapper.selectByMawbAndHawb(manwNo,hawbNo);
}catch (Exception e){
e.printStackTrace();
}
return stock;
}
@Override
public int delectByWarkNo(String workNo) {
int result = 0;
try{
result = imStockMapper.deleteByPrimaryKey(workNo);
}catch (Exception e){
e.printStackTrace();
}
return result;
}
}
... ...
... ... @@ -26,37 +26,41 @@ public class CommandClient {
socket = new Socket("192.168.1.107", 9002);
logger.info("socket通讯创建连接成功");
op = socket.getOutputStream();
//xml字节流
byte[]xBody =xmlBody.getBytes("GB2312");
//包头
byte[] head = new byte[4];
head[0]=(byte)0xE2;
head[1]=(byte)0x5C;
head[2]=(byte)0x4B;
head[3]=(byte)0x89;
byte[]packge = intToByte4((40+xBody.length));
//消息类型
byte[] mType = new byte[1];
mType[0] = (byte)0x22;
byte[]station ="4257010001".getBytes("ASCII");
byte[]aisle ="4257011005".getBytes("ASCII");
byte[]eType ="E".getBytes("ASCII");
//场站号
byte[]station =info.getAreaid().getBytes("ASCII");
//通道号
byte[]aisle =info.getChnlno().getBytes("ASCII");
//进出标识
byte[]eType =info.getIetype().getBytes("ASCII");
//标识符
byte[] bwFlag = new byte[4];
bwFlag[0]=(byte)0xFF;
bwFlag[1]=(byte)0xFF;
bwFlag[2]=(byte)0xFF;
bwFlag[3]=(byte)0xFF;
//xml字节流长度
byte[]xmlLength = intToByte4(xBody.length);
//包尾
byte[]end = new byte[2];
end[0]=(byte)0xFF;
end[1]=(byte)0xFF;
byte[]b1 = byteMerger(head,packge);
byte[]b2 = byteMerger(mType,station);
byte[]b3 = byteMerger(aisle,eType);
byte[]b4 = byteMerger(bwFlag, xmlLength);
byte[]b5 = byteMerger(xBody, end);
byte[]b6 = byteMerger(b1,b2);
byte[]b7 = byteMerger(b3,b4);
byte[]b8 = byteMerger(b5,b6);
byte[]b9 = byteMerger(b7,b8);
op.write(b9);
//总长
byte [] packge = intToByte4((head.length+xBody.length+mType.length+station.length+aisle.length+eType
.length+bwFlag.length+xmlLength.length+end.length));
byte[]allByte = byteMergerAll(head,packge,mType,station,aisle,eType,bwFlag,xmlLength,xBody,end);
op.write(allByte);
op.flush();
op.close();
logger.info("发送完毕");
socket.close();
... ... @@ -70,15 +74,24 @@ public class CommandClient {
}
/**
* @Param info 卡口采集信息
* @Param flag 放行标识
* */
private static String getXmlInfo(GatherInfo info,String flag) {
String message = null;
if ("11".equals(flag)){
message="直接放行";
}else{
message = "禁止通行,载重比对不在可控范围";
}
StringBuffer buffer = new StringBuffer();
buffer.append("<?xml version='1.0' encoding='GB2312' ?>");
buffer.append("<COMMAND_INFO AREA_ID="+info.getAreaid()+" CHNL_NO="+info.getChnlno()+" I_E_TYPE="+info
.getIetype()+" SEQ_NO="+info.getSeqno()+">");
buffer.append("<CHECK_RESULT>11000000000000000000</CHECK_RESULT><OP_HINT>数据不完整</OP_HINT>");
buffer.append("<COMMAND_INFO AREA_ID=\""+info.getAreaid()+"\" CHNL_NO=\""+info.getChnlno()+"\" I_E_TYPE=\""+info
.getIetype()+"\" SEQ_NO=\""+info.getSeqno()+"\">");
buffer.append("<CHECK_RESULT>"+flag+"000000000000000000</CHECK_RESULT><OP_HINT>"+message+"</OP_HINT>");
buffer.append("<SEAL>");
buffer.append("<ESEAL_ID></ESEAL_ID>");
buffer.append("<SEAL_KEY></SEAL_KEY>");
buffer.append("<ESEAL_ID>"+info.getEsealid()+"</ESEAL_ID>");
buffer.append("<SEAL_KEY>"+info.getSealkey()+"</SEAL_KEY>");
buffer.append("<OPEN_TIMES></OPEN_TIMES>");
buffer.append("<ESEAL_IC_NO></ESEAL_IC_NO>");
buffer.append("</SEAL>");
... ... @@ -88,7 +101,7 @@ public class CommandClient {
}
//int转byte
public static byte[] intToByte4(int i) {
private static byte[] intToByte4(int i) {
byte[] targets = new byte[4];
//低位到高位
targets[0] = (byte) (i & 0xFF);
... ... @@ -98,15 +111,8 @@ public class CommandClient {
return targets;
}
//合并两个byte数组
public static byte[] byteMerger(byte[] bt1, byte[] bt2) {
byte[] bt3 = new byte[bt1.length + bt2.length];
System.arraycopy(bt1, 0, bt3, 0, bt1.length);
System.arraycopy(bt2, 0, bt3, bt1.length, bt2.length);
return bt3;
}
//byte转int
public static int byteArrayToInt(byte[] bytes) {
private static int byteArrayToInt(byte[] bytes) {
int value = 0;
// 由高位到低位
for (int i = 0; i < 4; i++) {
... ... @@ -116,4 +122,19 @@ public class CommandClient {
return value;
}
private static byte[] byteMergerAll(byte[]... values) {
int length_byte = 0;
for (int i = 0; i < values.length; i++) {
length_byte += values[i].length;
}
byte[] all_byte = new byte[length_byte];
int countLength = 0;
for (int i = 0; i < values.length; i++) {
byte[] b = values[i];
System.arraycopy(b, 0, all_byte, countLength, b.length);
countLength += b.length;
}
return all_byte;
}
}
... ...
... ... @@ -26,10 +26,10 @@ public final class FileTool {
if (rightOrwrong){
stringBuffer.append(xmlRootDirectory).append("/").append(path).append("/").append(DateTimeConverter.getFormat())
.append("/").append(uuidCreate.getUUID()).append(".log");
.append("/").append(UUIDCreate.getUUID()).append(".log");
}else {
stringBuffer.append(errorRootDirectory).append("/").append(path).append("/").append(DateTimeConverter.getDay())
.append("/").append(uuidCreate.getUUID()).append(".log");
.append("/").append(UUIDCreate.getUUID()).append(".log");
}
File file = new File(stringBuffer.toString());
... ... @@ -67,7 +67,7 @@ public final class FileTool {
public static void writeFileToBak(String content){
String bakDir = readProperties("bakDirectory");
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(bakDir).append("/").append(uuidCreate.getUUID()).append(".txt");
stringBuffer.append(bakDir).append("/").append(UUIDCreate.getUUID()).append(".txt");
File file = new File(stringBuffer.toString());
... ...
... ... @@ -3,7 +3,7 @@ package com.sy.utils;
import java.util.UUID;
public class uuidCreate {
public class UUIDCreate {
public static String getUUID() {
String uuid = UUID.randomUUID().toString().replace("-","");
return uuid;
... ...
... ... @@ -88,6 +88,12 @@
from airone_ex_stock
where WORK_NO = #{workNo,jdbcType=VARCHAR}
</select>
<select id="selectByMawbNo" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from airone_ex_stock
where MAWB_NO = #{mawbNo,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from airone_ex_stock
where WORK_NO = #{workNo,jdbcType=VARCHAR}
... ...
... ... @@ -85,6 +85,13 @@
from airone_im_stock
where WORK_NO = #{workNo,jdbcType=VARCHAR}
</select>
<select id="selectByMawbAndHawb" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from airone_im_stock
where MAWB_NO = #{mawbNo,jdbcType=VARCHAR}
and HAWB_NO = #{hawbNo,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from airone_im_stock
where WORK_NO = #{workNo,jdbcType=VARCHAR}
... ...