作者 王勇

运输工具服务,基本定型

... ... @@ -7,6 +7,9 @@ import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* @author 子诚
*/
@SpringBootApplication
@MapperScan("com.sunyo.wlpt.transport.provide.mapper")
@EnableFeignClients
... ...
package com.sunyo.wlpt.transport.provide.common;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @author 子诚
* Description:实体类:新舱单——理货信息.最终返回结果类
* 时间:2020/5/20 10:40
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultExitData implements Serializable {
private static final long serialVersionUID = -260680809813827352L;
/**
* 1.id
*/
private String autoId;
/**
* 2.运单号
*/
private String waybillNoMaster;
/**
* 3.航班号
*/
private String flightNo;
/**
* 4.航班日期
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date flightDate;
/**
* 5.航段
*/
private String segment;
/**
* 6.航班起始站
*/
private String originatingStation;
/**
* 7.航班目的站
*/
private String destinationStation;
/**
* 8.理货件数
*/
private String tallyTotalPiece;
/**
* 9.理货重量
*/
private String tallyTotalWeight;
/**
* 10.承运人二字码
*/
private String carrier;
/**
* 11.发货人名称
*/
private String shipperName;
/**
* 12.收货人名称
*/
private String consigneeName;
/**
* 13.货物目的站
*/
private String aimStation;
/**
* 14.国家代码
*/
private String country;
/**
* 15.航班目的区域,中文描述,所属洲
*/
private String areaDescChn;
/**
* 16.代理人全称
*/
private String fullName;
/**
* 17.货主类型
* 111 = 发货代理
* 222 = 订舱代理
* 333 = 操作代理/结算代理
*/
private String theShipperType;
/**
* 18.品名
*/
private String sdCargoName;
/**
* 19.二级类名称
*/
private String twoTypeName;
/**
* 20.一级类名称
*/
private String typeName;
/**
* 21.航空公司
*/
private String airCompany;
/**
* 22.机型
*/
private String cfTp;
/**
* 23.机号
*/
private String cfNo;
/**
* 24.航班(起飞)时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date flightTime;
/**
* 25.航班计划日期
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date flightPlanDate;
/**
* 26.航班计划时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date flightPlanTime;
}
... ...
package com.sunyo.wlpt.transport.provide.controller;
import com.sunyo.wlpt.transport.provide.common.ResultExitData;
import com.sunyo.wlpt.transport.provide.domain.DePeAir;
import com.sunyo.wlpt.transport.provide.domain.FlightDfDl;
import com.sunyo.wlpt.transport.provide.service.DePeAirService;
import com.sunyo.wlpt.transport.provide.service.FlightDfDlService;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
* @author 子诚
* Description:
* 时间:2020/5/22 11:04
*/
@CrossOrigin
@RequestMapping("transport")
@RestController
public class TransportController {
@Resource
private FlightDfDlService flightDfDlService;
@Resource
private DePeAirService dePeAirService;
/**
* 根据承运人二字码、航班号、航班日期,获取,运输工具服务中的相关数据
* 航空公司、机型、机号、实际起飞时间、计划起飞时间
*
* @param resultList {@link ResultExitData}
* @return
*/
@PutMapping("/getInfo")
public List<ResultExitData> getInfo(@RequestBody List<ResultExitData> resultList) {
System.out.println("开始调用:运输工具服务");
System.out.println("长度为" + resultList.size());
for (int i = 0, resultSize = resultList.size(); i < resultSize; i++) {
ResultExitData result = resultList.get(i);
System.out.println(i + "运单号" + result.getWaybillNoMaster());
List<FlightDfDl> fd = flightDfDlService.getFlightDfDlInfo(result);
if (fd != null && fd.size() > 0) {
//机型
result.setCfTp(fd.get(0).getCfTp());
//机号
result.setCfNo(fd.get(0).getCfNo());
//航班计划日期,直接设置为航班日期的值
result.setFlightPlanDate(result.getFlightDate());
List<DePeAir> dePeAirs = dePeAirService.getDePeAirInfo(fd.get(0).getFlId());
if (dePeAirs != null && dePeAirs.size() > 0) {
//航班公司
result.setAirCompany(dePeAirs.get(0).getFfId().substring(0, 2));
//航班实际起飞时间(航班时间)
result.setFlightTime(dePeAirs.get(0).getFrTt());
//航班计划时间,直接设置为航班时间
result.setFlightPlanTime(dePeAirs.get(0).getFrTt());
}
}
}
System.out.println("完成调用:运输工具服务");
return resultList;
}
}
... ...
package com.sunyo.wlpt.transport.provide.domain;
import java.io.Serializable;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author 子诚
* Description:运输工具——航班离港信息
* 时间:2020/5/22 11:00
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DePeAir implements Serializable {
private static final long serialVersionUID = 5631854615861533199L;
/**
* 航班id
*/
private String flId;
/**
* 航班,标识
* 航空公司二字码-航班号-计划时间
*/
private String ffId;
/**
* 航班实际起飞时间
*/
private Date frTt;
}
... ...
package com.sunyo.wlpt.transport.provide.domain;
import java.io.Serializable;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author 子诚
* Description:运输工具
* 时间:2020/5/22 10:26
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class FlightDfDl implements Serializable {
private static final long serialVersionUID = 5811801930754677941L;
/**
* 航班唯一 id
*/
private String flId;
/**
* 航班,标识
* 航空公司二字码-航班号-计划时间
*/
private String ffId;
/**
* 承运人
*/
private String awCd;
/**
* 航班号
*/
private String flNo;
/**
* 航班计划起飞日期
*/
private Date feXd;
/**
* 机型
*/
private String cfTp;
/**
* 机号
*/
private String cfNo;
}
... ...
package com.sunyo.wlpt.transport.provide.mapper;
import com.sunyo.wlpt.transport.provide.domain.DePeAir;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author 子诚
* Description:
* 时间:2020/5/22 11:00
*/
@Mapper
public interface DePeAirMapper {
/**
* 根据 航班唯一 id 查询 运输工具——航班离港信息.
*
* @param flId 航班唯一 id
* @return {@link DePeAir}
*/
List<DePeAir> getDePeAirInfo(String flId);
}
... ...
package com.sunyo.wlpt.transport.provide.mapper;
import com.sunyo.wlpt.transport.provide.common.ResultExitData;
import com.sunyo.wlpt.transport.provide.domain.FlightDfDl;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author 子诚
* Description:
* 时间:2020/5/22 10:26
*/
@Mapper
public interface FlightDfDlMapper {
/**
* 获取运输工具的相关信息
*
* @param result 新舱单传输来的最终结果类
* @return {@link FlightDfDl}
*/
List<FlightDfDl> getFlightDfDlInfo(ResultExitData result);
}
... ...
package com.sunyo.wlpt.transport.provide.service;
import com.sunyo.wlpt.transport.provide.domain.DePeAir;
import java.util.List;
/**
* @author 子诚
* Description:
* 时间:2020/5/22 11:00
*/
public interface DePeAirService {
/**
* 根据 航班唯一 id 查询 运输工具——航班离港信息.
*
* @param flId 航班唯一 id
* @return {@link DePeAir}
*/
List<DePeAir> getDePeAirInfo(String flId);
}
... ...
package com.sunyo.wlpt.transport.provide.service;
import com.sunyo.wlpt.transport.provide.common.ResultExitData;
import com.sunyo.wlpt.transport.provide.domain.FlightDfDl;
import java.util.List;
/**
* @author 子诚
* Description:
* 时间:2020/5/22 10:26
*/
public interface FlightDfDlService {
/**
* 获取运输工具的相关信息
*
* @param result 新舱单传输来的最终结果类
* @return {@link FlightDfDl}
*/
List<FlightDfDl> getFlightDfDlInfo(ResultExitData result);
}
... ...
package com.sunyo.wlpt.transport.provide.service.impl;
import com.sunyo.wlpt.transport.provide.domain.DePeAir;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.sunyo.wlpt.transport.provide.mapper.DePeAirMapper;
import com.sunyo.wlpt.transport.provide.service.DePeAirService;
import java.util.List;
/**
* @author 子诚
* Description:
* 时间:2020/5/22 11:00
*/
@Service
public class DePeAirServiceImpl implements DePeAirService {
@Resource
private DePeAirMapper dePeAirMapper;
@Override
public List<DePeAir> getDePeAirInfo(String flId) {
return dePeAirMapper.getDePeAirInfo(flId);
}
}
... ...
package com.sunyo.wlpt.transport.provide.service.impl;
import com.sunyo.wlpt.transport.provide.common.ResultExitData;
import com.sunyo.wlpt.transport.provide.domain.FlightDfDl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.sunyo.wlpt.transport.provide.mapper.FlightDfDlMapper;
import com.sunyo.wlpt.transport.provide.service.FlightDfDlService;
import java.util.List;
/**
* @author 子诚
* Description:
* 时间:2020/5/22 10:26
*/
@Service
public class FlightDfDlServiceImpl implements FlightDfDlService {
@Resource
private FlightDfDlMapper flightDfDlMapper;
@Override
public List<FlightDfDl> getFlightDfDlInfo(ResultExitData result) {
return flightDfDlMapper.getFlightDfDlInfo(result);
}
}
... ...
... ... @@ -4,7 +4,7 @@ server:
# spring \u914D\u7F6E
spring:
application:
name: cgonms-provide
name: transport-provide
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
... ... @@ -39,7 +39,7 @@ mybatis:
# level:
# com.sunyo.wlpt.transport.provide.mapper: debug
#logback:
# appname: cgonms-provide
# appname: transport-provide
# logdir: ./log
... ...
<?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.sunyo.wlpt.transport.provide.mapper.DePeAirMapper">
<resultMap id="BaseResultMap" type="com.sunyo.wlpt.transport.provide.domain.DePeAir">
<!--@mbg.generated-->
<!--@Table depe_air-->
<id column="FLID" jdbcType="VARCHAR" property="flId"/>
<result column="FFID" jdbcType="VARCHAR" property="ffId"/>
<result column="FRTT" jdbcType="TIMESTAMP" property="frTt"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
FLID, FFID, FRTT
</sql>
<select id="getDePeAirInfo" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from depe_air
where FLID =#{flId,jdbcType=VARCHAR}
</select>
</mapper>
... ...
<?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.sunyo.wlpt.transport.provide.mapper.FlightDfDlMapper">
<resultMap id="BaseResultMap" type="com.sunyo.wlpt.transport.provide.domain.FlightDfDl">
<!--@mbg.generated-->
<!--@Table flight_dfdl-->
<id column="FLID" jdbcType="VARCHAR" property="flId"/>
<result column="FFID" jdbcType="VARCHAR" property="ffId"/>
<result column="AWCD" jdbcType="VARCHAR" property="awCd"/>
<result column="FLNO" jdbcType="VARCHAR" property="flNo"/>
<result column="FEXD" jdbcType="DATE" property="feXd"/>
<result column="CFTP" jdbcType="VARCHAR" property="cfTp"/>
<result column="CFNO" jdbcType="VARCHAR" property="cfNo"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
FLID, FFID, AWCD, FLNO, FEXD, CFTP, CFNO
</sql>
<select id="getFlightDfDlInfo" parameterType="com.sunyo.wlpt.transport.provide.common.ResultExitData"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from flight_dfdl
where
AWCD = #{carrier,jdbcType=VARCHAR}
and
concat_ws('',AWCD,FLNO) = #{flightNo,jdbcType=VARCHAR}
and
FEXD=#{flightDate,jdbcType=DATE}
</select>
</mapper>
... ...