Commit 9a6ebd6b by 罗胜

2023-03-10 罗胜

1.油量分析新需求
2.开航指令航线状态判断
parent dbc87957
...@@ -329,5 +329,8 @@ ...@@ -329,5 +329,8 @@
WHERE a.verif_id=#{verifId} WHERE a.verif_id=#{verifId}
AND a.del_flag = #{DEL_FLAG_NORMAL} AND a.del_flag = #{DEL_FLAG_NORMAL}
</select> </select>
<select id="findAirLineSta" resultType="java.lang.String">
select max(last_airline_time) from foc_airline_sta where dep_iata=#{depIata} and arr_iata=#{arrIata}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -25,10 +25,35 @@ ...@@ -25,10 +25,35 @@
</select> </select>
<select id="selectOilByAcTyoeAndIataId" resultType="double"> <select id="selectOilByAcTyoeAndIataId" resultType="double">
select avg_left_over_oil from foc_avg_left_over_oil where ac_type=#{acType} and airport=#{airport} and `year`=#{year} and `month`=#{month} limit 1 select avg_left_over_oil
from foc_avg_left_over_oil
where ac_type = #{acType}
and airport = #{airport}
and `year` = #{year}
and `month` = #{month}
limit 1
</select> </select>
<select id="selectOilByAirport" resultType="double"> <select id="selectOilByAirport" resultType="double">
select avg_left_over_oil from foc_avg_left_over_oil where airport=#{acType} and `year`=#{year} and `month`=#{month} limit 1 select avg_left_over_oil
from foc_avg_left_over_oil
where airport = #{acType}
and `year` = #{year}
and `month` = #{month}
limit 1
</select>
<select id="selectLeftOverOilByAcTypeAndDate" resultType="java.lang.Integer">
select avg(ifnull(left_over_oil_target,0)) from (select left_over_oil_target,case when CHAR_LENGTH(month)=1 then
CONCAT(`year`,'-0',`month`) else CONCAT(`year`,'-',`month`) end as yearMonth from foc_left_over_oil_target where
ac_type=#{acType}
<trim prefixOverrides="And" prefix="having">
<if test="startMonth !=null and startMonth != ''">
yearMonth <![CDATA[>=]]> #{startMonth}
</if>
<if test="endMonth !=null and endMonth!=''">
and yearMonth <![CDATA[<=]]> #{endMonth}
</if>
</trim>
) temp
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -143,10 +143,8 @@ ...@@ -143,10 +143,8 @@
plan.alternate_dist, plan.alternate_dist,
plan.taxi_out, plan.taxi_out,
plan.taxi_out_time, plan.taxi_out_time,
plan.hold,
plan.etop, plan.etop,
plan.etop_time, plan.etop_time,
plan.reserve,
plan.reserve_time, plan.reserve_time,
plan.extra_time, plan.extra_time,
plan.extra, plan.extra,
...@@ -157,10 +155,14 @@ ...@@ -157,10 +155,14 @@
ELSE '有二放和ETOPS' END) AS cfp_flag, ELSE '有二放和ETOPS' END) AS cfp_flag,
plan.custom_extra_time, plan.custom_extra_time,
plan.limiting_takeoff_weight, plan.limiting_takeoff_weight,
plan.limiting_landing_weight plan.limiting_landing_weight,
TRUNCATE(((2-ifnull(plan.plan_left_over,0)/ifnull(loo.left_over_oil_target,0)))*100,2) as rate
from foc_flight_dynamics_sta sta from foc_flight_dynamics_sta sta
LEFT JOIN foc_flight_plan plan ON sta.id = plan.dynamics_sta_id LEFT JOIN foc_flight_plan plan ON sta.id = plan.dynamics_sta_id left join
where 1=1 (select *,case when LENGTH(`month`)=1 THEN CONCAT(`year`,'-0',month) else
CONCAT(`year`,'-',month) end as yearMonth from foc_left_over_oil_target ) loo on
loo.year=SUBSTR(sta.std,1,4) and loo.month= SUBSTR(sta.std,6,2) and loo.ac_type=sta.ac_type_name
where sta.total_oil !=''
<if test="arrIata!=null and arrIata!='' "> <if test="arrIata!=null and arrIata!='' ">
and sta.arr_iata_id = #{arrIata} and sta.arr_iata_id = #{arrIata}
</if> </if>
...@@ -214,6 +216,14 @@ ...@@ -214,6 +216,14 @@
GROUP BY GROUP BY
sta.std, sta.std,
sta.flight_no sta.flight_no
<trim prefixOverrides="And" prefix="having">
<if test="minRate !=null">
rate <![CDATA[>=]]> #{minRate}
</if>
<if test="maxRate !=null">
and rate <![CDATA[<]]> #{maxRate}
</if>
</trim>
ORDER BY ORDER BY
sta.std DESC sta.std DESC
...@@ -303,11 +313,15 @@ ...@@ -303,11 +313,15 @@
DATE_FORMAT( sta.update_date, '%Y/%m/%d' ) AS updateDate, DATE_FORMAT( sta.update_date, '%Y/%m/%d' ) AS updateDate,
DATE_FORMAT( sta.update_time, '%Y/%m/%d %H:%i:%s' ) AS updateTime, DATE_FORMAT( sta.update_time, '%Y/%m/%d %H:%i:%s' ) AS updateTime,
sta.ac_type_name, sta.ac_type_name,
TRUNCATE(((2-ifnull(plan.plan_left_over,0)/ifnull(loo.left_over_oil_target,0)))*100,2) as rate,
sta.remark sta.remark
FROM FROM
foc_flight_dynamics_sta sta foc_flight_dynamics_sta sta
LEFT JOIN foc_flight_plan plan ON sta.id = plan.dynamics_sta_id LEFT JOIN foc_flight_plan plan ON sta.id = plan.dynamics_sta_id left join
where 1=1 ( select *,case when LENGTH(`month`)=1 THEN CONCAT(`year`,'-0',month) else
CONCAT(`year`,'-',month) end as yearMonth from foc_left_over_oil_target ) loo on
loo.year=SUBSTR(sta.std,1,4) and loo.month= SUBSTR(sta.std,6,2) and loo.ac_type=sta.ac_type_name
where sta.total_oil !=''
<if test="arrIata!=null and arrIata!='' "> <if test="arrIata!=null and arrIata!='' ">
and sta.arr_iata_id = #{arrIata} and sta.arr_iata_id = #{arrIata}
</if> </if>
...@@ -361,13 +375,20 @@ ...@@ -361,13 +375,20 @@
GROUP BY GROUP BY
sta.std, sta.std,
sta.flight_no sta.flight_no
<trim prefixOverrides="And" prefix="having">
<if test="minRate !=null">
rate <![CDATA[>=]]> #{minRate}
</if>
<if test="maxRate !=null">
and rate <![CDATA[<]]> #{maxRate}
</if>
</trim>
ORDER BY ORDER BY
sta.std DESC sta.std desc
</select> </select>
<select id="getById" resultType="com.ejweb.modules.airport.entity.OilAnalysisEntity"> <select id="getById" resultType="com.ejweb.modules.airport.entity.OilAnalysisEntity">
SELECT SELECT DATE_FORMAT(sta.std, '%Y/%m/%d %H:%i') AS std,
DATE_FORMAT( sta.std, '%Y/%m/%d %H:%i' ) AS std,
sta.id, sta.id,
sta.flight_no, sta.flight_no,
sta.ac_no, sta.ac_no,
...@@ -381,13 +402,12 @@ ...@@ -381,13 +402,12 @@
plan.plan_left_over, plan.plan_left_over,
plan.hold, plan.hold,
plan.reserve, plan.reserve,
DATE_FORMAT( sta.update_date, '%Y/%m/%d' ) AS updateDate, DATE_FORMAT(sta.update_date, '%Y/%m/%d') AS updateDate,
DATE_FORMAT( sta.update_time, '%Y/%m/%d %H:%i:%s' ) AS updateTime, DATE_FORMAT(sta.update_time, '%Y/%m/%d %H:%i:%s') AS updateTime,
sta.ac_type_name sta.ac_type_name
FROM FROM foc_flight_dynamics_sta sta
foc_flight_dynamics_sta sta LEFT JOIN foc_flight_plan plan ON sta.flight_no = plan.flight_no and sta.std = plan.std
LEFT JOIN foc_flight_plan plan ON sta.flight_no = plan.flight_no and sta.std=plan.std where sta.id = #{id}
where sta.id=#{id}
</select> </select>
<select id="getOilReasons" resultType="string"> <select id="getOilReasons" resultType="string">
SELECT DISTINCT SELECT DISTINCT
...@@ -405,6 +425,112 @@ ...@@ -405,6 +425,112 @@
and substring_index( extra_oil_fuel_reason_new, ':',- 1 ) != '' and substring_index( extra_oil_fuel_reason_new, ':',- 1 ) != ''
</select> </select>
<select id="selectAcTypeResidualOil" resultType="com.ejweb.modules.airport.entity.ResidualOilSummaryEntity">
select *
from (select DISTINCT ac_type from foc_left_over_oil_target where `year` = year(NOW())) act
left join (
select temp.ac_type_name,
TRUNCATE(avg(IFNULL(rate, 0)), 2) as rate,
TRUNCATE(AVG(IFNULL(temp.plan_left_over, 0)), 2) as plan_left_over,
TRUNCATE(AVG(IFNULL(temp.left_over_oil_target, 0)), 2)
as avg_left_over_oil
from (SELECT DATE_FORMAT(sta.std, '%Y/%m/%d %H:%i') AS std,
sta.id,
sta.flight_no,
sta.ac_no,
plan.plan_left_over,
sta.ac_type_name,
sta.remark,
TRUNCATE(((2 - ifnull(plan.plan_left_over, 0) / ifnull(loo.left_over_oil_target, 0))) * 100,
2) as rate,
loo.left_over_oil_target,
loo.ac_type
FROM foc_flight_dynamics_sta sta
LEFT JOIN foc_flight_plan plan ON sta.id = plan.dynamics_sta_id
left join
(select *,case when LENGTH(`month`)=1 THEN CONCAT(`year`,'-0',month) else
CONCAT(`year`,'-',month) end as yearMonth from foc_left_over_oil_target) loo
on loo.year = SUBSTR(sta.std, 1, 4) and loo.month = SUBSTR(sta.std, 6, 2) and
loo.ac_type = sta.ac_type_name
where sta.total_oil != ''
<if test="arrIata!=null and arrIata!='' ">
and sta.arr_iata_id = #{arrIata}
</if>
<if test="depIata!=null and depIata!='' ">
and sta.dep_iata_id = #{depIata}
</if>
<if test="flightNo!=null and flightNo!='' ">
and sta.flight_no LIKE CONCAT('%',#{flightNo}, '%')
</if>
<if test="dispatcherZH!=null and dispatcherZH!=''">
and sta.dispatcher_account LIKE CONCAT('%',#{dispatcherZH}, '%')
</if>
<if test="dispatcherENG!=null and dispatcherENG!=''">
and sta.dispatcher_name LIKE CONCAT('%',#{dispatcherENG}, '%')
</if>
<if test="minDepTime !=null and minDepTime!=''">
and sta.std <![CDATA[>=]]> date_format(#{minDepTime},'%Y-%c-%d %H:%i')
</if>
<if test="maxDepTime !=null and maxDepTime!=''">
and sta.std <![CDATA[<]]> date_format(#{maxDepTime},'%Y-%c-%d %H:%i')
</if>
<if test="minLeftOverOil !=null and minLeftOverOil !=0">
and plan.plan_left_over >= #{minLeftOverOil}
</if>
<if test="maxLeftOverOil !=null and maxLeftOverOil !=0">
and plan.plan_left_over <![CDATA[<]]> #{maxLeftOverOil}
</if>
<if test="acType !=null and acType!=''">
and sta.ac_type_name like CONCAT('%',#{acType},'%')
</if>
<if test="minExtraOil !=null and minExtraOil!=0">
and substring_index(sta.extra_oil_fuel_reason_new,':',1) >= #{minExtraOil}
</if>
<if test="maxExtraOil !=null and maxExtraOil!=0">
and substring_index(sta.extra_oil_fuel_reason_new,':',1) <![CDATA[<]]> #{maxExtraOil}
</if>
<if test="extraOilReason !=null and extraOilReason!=''">
and substring_index( sta.extra_oil_fuel_reason_new, ':',- 1 ) like CONCAT('%',#{extraOilReason},'%')
</if>
GROUP BY sta.std,
sta.flight_no
<trim prefixOverrides="And" prefix="having">
<if test="minRate !=null">
rate <![CDATA[>=]]> #{minRate}
</if>
<if test="maxRate !=null">
and rate <![CDATA[<]]> #{maxRate}
</if>
</trim>
ORDER BY sta.std desc
) temp
group by temp.ac_type_name
) temp1 on act.ac_type = temp1.ac_type_name
</select>
<resultMap id="oilTargetEntity" type="com.ejweb.modules.airport.entity.OilTargetEntity">
<result property="acType" column="ac_type"></result>
<collection property="target" ofType="integer">
<result column="left_over_oil_target"></result>
</collection>
</resultMap>
<select id="selectNowYearTarget" resultMap="oilTargetEntity">
select ac_type,left_over_oil_target from foc_left_over_oil_target where year=YEAR(now()) group by ac_type,month
</select>
<!--已不用--> <!--已不用-->
<!-- <!--
<select id="getOilAnalysisData" resultType="com.ejweb.modules.airport.entity.OilAnalysisEntity"> <select id="getOilAnalysisData" resultType="com.ejweb.modules.airport.entity.OilAnalysisEntity">
......
package com.ejweb.core.api; package com.ejweb.core.api;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ejweb.core.exception.CommonException;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.util.SystemOutLogger; import org.apache.poi.util.SystemOutLogger;
import org.hibernate.validator.constraints.NotEmpty; import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError; import org.springframework.validation.ObjectError;
import org.subethamail.smtp.server.CommandException;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* 所有的接口请求实体类 * 所有的接口请求实体类
...@@ -53,14 +60,38 @@ public class RequestBean { ...@@ -53,14 +60,38 @@ public class RequestBean {
if(content == null) if(content == null)
return null; return null;
try { try {
JSONObject jsonObject = JSONObject.parseObject(content);
Set<String> keySet = jsonObject.keySet();
if (keySet.contains("sort")) {
String sort = jsonObject.getString("sort");
if (StringUtils.isNotBlank(sort)) {
if (containsSqlInjection(sort)) {
throw new CommonException("sort参数有sql注入风险");
}
}
}
return JSON.parseObject(content, clazz); return JSON.parseObject(content, clazz);
}catch (CommonException e){
throw new CommonException("sort参数有sql注入风险");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
// TODO: handle exception // TODO: handle exception
} }
return null; return null;
} }
/**
* 是否含有sql注入,返回true表示含有
* @param obj
* @return
*/
public static boolean containsSqlInjection(Object obj){
Pattern pattern= Pattern.compile("\\b(and|exec|insert|select|drop|grant|alter|delete|update|count|chr|mid|master|truncate|char|declare|or)\\b|(\\*|;|\\+|'|%)");
Matcher matcher=pattern.matcher(obj.toString().toLowerCase());
return matcher.find();
}
/** /**
* 获取验证的错误信息 * 获取验证的错误信息
* @param errors * @param errors
......
package com.ejweb.core.exception;
/**
* @Author
* @Date 2023/2/23
* @Desc 公共异常
**/
public class CommonException extends RuntimeException {
private static final long serialVersionUID = 1L;
private String msg;
private int code = 500;
public CommonException(String msg) {
super(msg);
this.msg = msg;
}
public CommonException(String msg, Throwable e) {
super(msg, e);
this.msg = msg;
}
public CommonException(String msg, int code) {
super(msg);
this.msg = msg;
this.code = code;
}
public CommonException(String msg, int code, Throwable e) {
super(msg, e);
this.msg = msg;
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
}
...@@ -111,8 +111,8 @@ public class BasicVerifyFilter implements Filter { ...@@ -111,8 +111,8 @@ public class BasicVerifyFilter implements Filter {
if (content != null) { if (content != null) {
message = "无效请求"; message = "无效请求";
System.out.println(content); System.out.println(content);
BaseUserBean baseUserBean = JSON.parseObject(content, BaseUserBean.class); // BaseUserBean baseUserBean = JSON.parseObject(content, BaseUserBean.class);
// BaseUserBean baseUserBean = JSON.parseObject("{\"userSign\":\"1000849147\"}", BaseUserBean.class); //测试使用 BaseUserBean baseUserBean = JSON.parseObject("{\"userSign\":\"1000849147\"}", BaseUserBean.class); //测试使用
String userSign = baseUserBean.getUserSign(); String userSign = baseUserBean.getUserSign();
if (userSign != null && !"".equals(userSign) && !"undefind".equals(userSign)) { if (userSign != null && !"".equals(userSign) && !"undefind".equals(userSign)) {
ServletContext context = request.getServletContext(); ServletContext context = request.getServletContext();
......
...@@ -3,7 +3,6 @@ package com.ejweb.modules.airport.api; ...@@ -3,7 +3,6 @@ package com.ejweb.modules.airport.api;
import com.ejweb.core.api.RequestBean; import com.ejweb.core.api.RequestBean;
import com.ejweb.core.api.ResponseBean; import com.ejweb.core.api.ResponseBean;
import com.ejweb.core.base.GenericBean;
import com.ejweb.core.base.PageEntity; import com.ejweb.core.base.PageEntity;
import com.ejweb.core.conf.ErrorCode; import com.ejweb.core.conf.ErrorCode;
import com.ejweb.core.conf.GConstants; import com.ejweb.core.conf.GConstants;
...@@ -13,10 +12,11 @@ import com.ejweb.modules.airport.bean.OilAnalysisBean; ...@@ -13,10 +12,11 @@ import com.ejweb.modules.airport.bean.OilAnalysisBean;
import com.ejweb.modules.airport.bean.OilAnalysisIdBean; import com.ejweb.modules.airport.bean.OilAnalysisIdBean;
import com.ejweb.modules.airport.bean.OilAnalysisUpdateBean; import com.ejweb.modules.airport.bean.OilAnalysisUpdateBean;
import com.ejweb.modules.airport.entity.OilAnalysisEntity; import com.ejweb.modules.airport.entity.OilAnalysisEntity;
import com.ejweb.modules.airport.entity.OilTargetEntity;
import com.ejweb.modules.airport.entity.ResidualOilSummaryEntity;
import com.ejweb.modules.airport.service.OilAnalysisService; import com.ejweb.modules.airport.service.OilAnalysisService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -119,6 +119,57 @@ public class OilAnalysisController { ...@@ -119,6 +119,57 @@ public class OilAnalysisController {
return responseBean; return responseBean;
} }
@RequestMapping(value = "/acTypeResidualOil")
@ResponseBody
public ResponseBean acTypeResidualOil(RequestBean requestBean){
ResponseBean responseBean = new ResponseBean();
OilAnalysisBean bean = requestBean.getObjectBean(OilAnalysisBean.class);
List<ResidualOilSummaryEntity> list=oilAnalysisService.getAcTypeResidualOil(bean);
if (list == null) {
responseBean.setMessage(GConstants.EMPTY);
responseBean.setStatus(ErrorCode.STATUS_CODE_2001);
return responseBean;
} else {
responseBean.setData(list);
responseBean.setMessage(GConstants.OK);
responseBean.setStatus(ErrorCode.STATUS_CODE_2000);
}
return responseBean;
}
@RequestMapping(value = "/acTypeResidualOilExcel")
@ResponseBody
public ResponseBean acTypeResidualOilExcel(RequestBean requestBean,HttpServletResponse response){
ResponseBean responseBean = new ResponseBean();
OilAnalysisBean bean = requestBean.getObjectBean(OilAnalysisBean.class);
List<ResidualOilSummaryEntity> list=oilAnalysisService.getAcTypeResidualOil(bean);
//自定义导出序号
String fileName = "机型剩油汇总.xlsx";
try {
new ExportExcel("机型剩油汇总", ResidualOilSummaryEntity.class).setDataList(list).write(response, fileName).dispose();
// new ExportExcel("油量分析统计(油量单位:KGS)", OilAnalysisEntity.class).setDataList(list).writeFile("D:\\"+fileName).dispose();
} catch (IOException e) {
responseBean.setMessage("导出数据失败" + e.getMessage());
return responseBean;
}
return responseBean;
}
@RequestMapping(value = "/getNowYearTarget")
@ResponseBody
public ResponseBean getNowYearTarget(RequestBean requestBean){
ResponseBean responseBean = new ResponseBean();
List<OilTargetEntity> list=oilAnalysisService.findNowYearTarget();
if (list == null||list.size()==0) {
responseBean.setMessage(GConstants.EMPTY);
responseBean.setStatus(ErrorCode.STATUS_CODE_2001);
return responseBean;
} else {
responseBean.setData(list);
responseBean.setMessage(GConstants.OK);
responseBean.setStatus(ErrorCode.STATUS_CODE_2000);
}
return responseBean;
}
} }
...@@ -51,6 +51,28 @@ public class OilAnalysisBean extends GenericBean { ...@@ -51,6 +51,28 @@ public class OilAnalysisBean extends GenericBean {
//最高额外油 //最高额外油
private Integer maxExtraOil; private Integer maxExtraOil;
//完成率
private Double minRate;
//完成率
private Double maxRate;
public Double getMinRate() {
return minRate;
}
public void setMinRate(Double minRate) {
this.minRate = minRate;
}
public Double getMaxRate() {
return maxRate;
}
public void setMaxRate(Double maxRate) {
this.maxRate = maxRate;
}
public Integer getMinLeftOverOil() { public Integer getMinLeftOverOil() {
return minLeftOverOil; return minLeftOverOil;
} }
......
...@@ -16,4 +16,6 @@ public interface LeftOverOilDao extends BaseDao { ...@@ -16,4 +16,6 @@ public interface LeftOverOilDao extends BaseDao {
Double selectOilByAirport(@Param("acType")String acType,@Param("year") int year, @Param("month") int month); Double selectOilByAirport(@Param("acType")String acType,@Param("year") int year, @Param("month") int month);
Integer selectLeftOverOilByAcTypeAndDate(@Param("acType") String acType, @Param("startMonth") String startMonth, @Param("endMonth") String endMonth);
} }
package com.ejweb.modules.airport.dao; package com.ejweb.modules.airport.dao;
import com.ejweb.core.base.BaseDao; import com.ejweb.core.base.BaseDao;
import com.ejweb.modules.airport.bean.AirportListBean;
import com.ejweb.modules.airport.bean.ExtraOilReasonBean;
import com.ejweb.modules.airport.bean.OilAnalysisBean; import com.ejweb.modules.airport.bean.OilAnalysisBean;
import com.ejweb.modules.airport.bean.OilAnalysisUpdateBean; import com.ejweb.modules.airport.bean.OilAnalysisUpdateBean;
import com.ejweb.modules.airport.entity.AirportListEntity;
import com.ejweb.modules.airport.entity.OilAnalysisEntity; import com.ejweb.modules.airport.entity.OilAnalysisEntity;
import com.ejweb.modules.airport.entity.OilTargetEntity;
import com.ejweb.modules.airport.entity.ResidualOilSummaryEntity;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -27,4 +26,8 @@ public interface OilAnalysisDao extends BaseDao { ...@@ -27,4 +26,8 @@ public interface OilAnalysisDao extends BaseDao {
//获取近一个月的理由 //获取近一个月的理由
List<String> getOilReasons(@Param("startTime") String startTime,@Param("endTime") String endTime); List<String> getOilReasons(@Param("startTime") String startTime,@Param("endTime") String endTime);
List<ResidualOilSummaryEntity> selectAcTypeResidualOil(OilAnalysisBean bean);
List<OilTargetEntity> selectNowYearTarget();
} }
...@@ -183,9 +183,8 @@ public class OilAnalysisEntity { ...@@ -183,9 +183,8 @@ public class OilAnalysisEntity {
private String etopTime;// private String etopTime;//
@ExcelField(title = "备注", type = 0, align = 1, sort = 94) @ExcelField(title = "备注", type = 0, align = 1, sort = 94)
private String remark;//备注 private String remark;//备注
@ExcelField(title = "完成率", type = 0, align = 1, sort = 95)
private String rate;//完成率
...@@ -199,6 +198,16 @@ public class OilAnalysisEntity { ...@@ -199,6 +198,16 @@ public class OilAnalysisEntity {
private String totalOil; // 总油量 private String totalOil; // 总油量
private String std; // 计划起飞时间 private String std; // 计划起飞时间
public String getRate() {
return rate;
}
public void setRate(String rate) {
this.rate = rate;
}
public String getLandingWeight() { public String getLandingWeight() {
return landingWeight; return landingWeight;
} }
......
package com.ejweb.modules.airport.entity;
import java.util.List;
/**
* 年每月剩油指标
*/
public class OilTargetEntity {
private String acType;
private List<Integer> target;
public String getAcType() {
return acType;
}
public void setAcType(String acType) {
this.acType = acType;
}
public List<Integer> getTarget() {
return target;
}
public void setTarget(List<Integer> target) {
this.target = target;
}
}
package com.ejweb.modules.airport.entity;
import com.ejweb.core.utils.excel.annotation.ExcelField;
/**
* 剩油指标汇总
*/
public class ResidualOilSummaryEntity {
@ExcelField(title = "指标/kg", type = 0, align = 1, sort = 1)
private String acType;
@ExcelField(title = "平均计划剩油", type = 0, align = 1, sort = 2)
private Double planLeftOver;
@ExcelField(title = "完成率", type = 0, align = 1, sort = 3)
private String rate;
@ExcelField(title = "平均额外油", type = 0, align = 1, sort = 4)
private Integer avgLeftOverOil;
public String getAcType() {
return acType;
}
public void setAcType(String acType) {
this.acType = acType;
}
public Double getPlanLeftOver() {
return planLeftOver;
}
public void setPlanLeftOver(Double planLeftOver) {
this.planLeftOver = planLeftOver;
}
public String getRate() {
return rate;
}
public void setRate(String rate) {
this.rate = rate;
}
public Integer getAvgLeftOverOil() {
return avgLeftOverOil;
}
public void setAvgLeftOverOil(Integer avgLeftOverOil) {
this.avgLeftOverOil = avgLeftOverOil;
}
}
...@@ -39,6 +39,17 @@ public class StatisticalEntity extends BaseEntity { ...@@ -39,6 +39,17 @@ public class StatisticalEntity extends BaseEntity {
private String verifuedCount; private String verifuedCount;
private List<String> typeList; private List<String> typeList;
private String roundtripType; private String roundtripType;
private boolean recentFlyStatus;
public boolean isRecentFlyStatus() {
return recentFlyStatus;
}
public void setRecentFlyStatus(boolean recentFlyStatus) {
this.recentFlyStatus = recentFlyStatus;
}
public String getRoundtripType() { public String getRoundtripType() {
return roundtripType; return roundtripType;
} }
......
...@@ -7,21 +7,22 @@ import com.ejweb.modules.airport.bean.OilAnalysisBean; ...@@ -7,21 +7,22 @@ import com.ejweb.modules.airport.bean.OilAnalysisBean;
import com.ejweb.modules.airport.bean.OilAnalysisUpdateBean; import com.ejweb.modules.airport.bean.OilAnalysisUpdateBean;
import com.ejweb.modules.airport.dao.LeftOverOilDao; import com.ejweb.modules.airport.dao.LeftOverOilDao;
import com.ejweb.modules.airport.dao.OilAnalysisDao; import com.ejweb.modules.airport.dao.OilAnalysisDao;
import com.ejweb.modules.airport.entity.LeftOverOilEntity;
import com.ejweb.modules.airport.entity.OilAnalysisEntity; import com.ejweb.modules.airport.entity.OilAnalysisEntity;
import com.ejweb.modules.airport.entity.OilTargetEntity;
import com.ejweb.modules.airport.entity.ResidualOilSummaryEntity;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.utils.DateUtils; import org.apache.http.client.utils.DateUtils;
import org.apache.lucene.util.MathUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Service @Service
public class OilAnalysisService extends BaseService<OilAnalysisDao> { public class OilAnalysisService extends BaseService<OilAnalysisDao> {
...@@ -49,20 +50,18 @@ public class OilAnalysisService extends BaseService<OilAnalysisDao> { ...@@ -49,20 +50,18 @@ public class OilAnalysisService extends BaseService<OilAnalysisDao> {
} }
PageInfo<OilAnalysisEntity> pageInfo = null; PageInfo<OilAnalysisEntity> pageInfo = null;
List<OilAnalysisEntity> oilAnalysisEntityList =null; List<OilAnalysisEntity> oilAnalysisEntityList = null;
if(isPage){ if (isPage) {
oilAnalysisEntityList= oilAnalysisDao.getOilAnalysisData(bean); oilAnalysisEntityList = oilAnalysisDao.getOilAnalysisData(bean);
}else{ } else {
oilAnalysisEntityList = oilAnalysisDao.getExcelOilAnalysisData(bean); oilAnalysisEntityList = oilAnalysisDao.getExcelOilAnalysisData(bean);
} }
for (OilAnalysisEntity oilAnalysisEntity : oilAnalysisEntityList) { for (OilAnalysisEntity oilAnalysisEntity : oilAnalysisEntityList) {
int index = oilAnalysisEntityList.indexOf(oilAnalysisEntity); int index = oilAnalysisEntityList.indexOf(oilAnalysisEntity);
oilAnalysisEntity.setNo(index + 1); oilAnalysisEntity.setNo(index + 1);
oilAnalysisEntity.setRate(oilAnalysisEntity.getRate() + "%");
String totalOil = oilAnalysisEntity.getTotalOil(); String totalOil = oilAnalysisEntity.getTotalOil();
String[] oilArr = totalOil.split("/"); String[] oilArr = totalOil.split("/");
if (oilArr != null && oilArr.length == 2) { if (oilArr != null && oilArr.length == 2) {
String strKGS = oilArr[0]; String strKGS = oilArr[0];
String strLBS = oilArr[1]; String strLBS = oilArr[1];
...@@ -77,42 +76,47 @@ public class OilAnalysisService extends BaseService<OilAnalysisDao> { ...@@ -77,42 +76,47 @@ public class OilAnalysisService extends BaseService<OilAnalysisDao> {
oilAnalysisEntity.setTotalOilKGS(Integer.valueOf(strKGS.replaceAll("KGS", ""))); oilAnalysisEntity.setTotalOilKGS(Integer.valueOf(strKGS.replaceAll("KGS", "")));
oilAnalysisEntity.setTotalOilLBS(Integer.valueOf(strLBS.replaceAll("LBS", ""))); oilAnalysisEntity.setTotalOilLBS(Integer.valueOf(strLBS.replaceAll("LBS", "")));
} }
//新增加的字段处理 //新增加的字段处理
String oilFuelReason = oilAnalysisEntity.getExtraOilFuelReasonNew(); String oilFuelReason = oilAnalysisEntity.getExtraOilFuelReasonNew();
String[] arr = oilFuelReason.split(":"); String[] arr = oilFuelReason.split(":");
if(oilFuelReason.startsWith(":")&& !oilFuelReason.endsWith(":")){ if (oilFuelReason.startsWith(":") && !oilFuelReason.endsWith(":")) {
oilAnalysisEntity.setExtraOil(""); oilAnalysisEntity.setExtraOil("");
oilAnalysisEntity.setExtraOilReason(arr[0]); oilAnalysisEntity.setExtraOilReason(arr[0]);
}else if(oilFuelReason.endsWith(":")&& !oilFuelReason.startsWith(":")){ } else if (oilFuelReason.endsWith(":") && !oilFuelReason.startsWith(":")) {
oilAnalysisEntity.setExtraOil(arr[0].equals("0")?"":arr[0]); oilAnalysisEntity.setExtraOil(arr[0].equals("0") ? "" : arr[0]);
oilAnalysisEntity.setExtraOilReason(""); oilAnalysisEntity.setExtraOilReason("");
}else if(!oilFuelReason.startsWith(":")&& !oilFuelReason.endsWith(":")){ } else if (!oilFuelReason.startsWith(":") && !oilFuelReason.endsWith(":")) {
oilAnalysisEntity.setExtraOil(arr[0].equals("0")?"":arr[0]); oilAnalysisEntity.setExtraOil(arr[0].equals("0") ? "" : arr[0]);
oilAnalysisEntity.setExtraOilReason(arr[1]); oilAnalysisEntity.setExtraOilReason(arr[1]);
}else{ } else {
oilAnalysisEntity.setExtraOil(""); oilAnalysisEntity.setExtraOil("");
oilAnalysisEntity.setExtraOilReason(""); oilAnalysisEntity.setExtraOilReason("");
} }
if(ObjectUtils.notEqual(oilAnalysisEntity.getPlanLeftOver(),null)){ if (ObjectUtils.notEqual(oilAnalysisEntity.getPlanLeftOver(), null)) {
String planLeftOver=String.valueOf(oilAnalysisEntity.getPlanLeftOver()); String planLeftOver = String.valueOf(oilAnalysisEntity.getPlanLeftOver());
//0下标为年,1位月,2位日 //0下标为年,1位月,2位日
String[] timeArr = oilAnalysisEntity.getStd().split("/"); String[] timeArr = oilAnalysisEntity.getStd().split("/");
int year=Integer.valueOf(timeArr[0]); int year = Integer.valueOf(timeArr[0]);
int month=Integer.valueOf(timeArr[1]); int month = Integer.valueOf(timeArr[1]);
Double leftOverOil =leftOverOilDao.selectOilByAcTyoeAndIataId(oilAnalysisEntity.getAcTypeName(),oilAnalysisEntity.getArrIcaoId(),year,month); Double leftOverOil = leftOverOilDao.selectOilByAcTyoeAndIataId(oilAnalysisEntity.getAcTypeName(), oilAnalysisEntity.getArrIcaoId(), year, month);
if(!ObjectUtils.notEqual(leftOverOil,null)){ if (!ObjectUtils.notEqual(leftOverOil, null)) {
leftOverOil=leftOverOilDao.selectOilByAirport(oilAnalysisEntity.getAcTypeName(),year,month); Double aDouble = leftOverOilDao.selectOilByAirport(oilAnalysisEntity.getAcTypeName(), year, month);
if (aDouble == null) {
leftOverOil = 0D;
} else {
leftOverOil = aDouble;
}
} }
oilAnalysisEntity.setPlanLeftOver(oilAnalysisEntity.getPlanLeftOver()); oilAnalysisEntity.setPlanLeftOver(oilAnalysisEntity.getPlanLeftOver());
System.out.println(oilAnalysisEntity.getAcTypeName());
System.out.println(planLeftOver); System.out.println(planLeftOver);
System.out.println(leftOverOil); System.out.println(leftOverOil);
oilAnalysisEntity.setIncreaseOrDecrease(Integer.valueOf(planLeftOver)-leftOverOil.intValue()); oilAnalysisEntity.setIncreaseOrDecrease(Integer.valueOf(planLeftOver) - leftOverOil.intValue());
}else{ } else {
oilAnalysisEntity.setPlanLeftOver(""); oilAnalysisEntity.setPlanLeftOver("");
} }
if("0".equals(oilAnalysisEntity.getExtraOil())){ if ("0".equals(oilAnalysisEntity.getExtraOil())) {
oilAnalysisEntity.setExtraOil(""); oilAnalysisEntity.setExtraOil("");
} }
// String oilFuelReason = oilAnalysisEntity.getExtraOilFuelReason(); // String oilFuelReason = oilAnalysisEntity.getExtraOilFuelReason();
...@@ -202,16 +206,84 @@ public class OilAnalysisService extends BaseService<OilAnalysisDao> { ...@@ -202,16 +206,84 @@ public class OilAnalysisService extends BaseService<OilAnalysisDao> {
} }
public List<String> getOilReason(ExtraOilReasonBean bean) { public List<String> getOilReason(ExtraOilReasonBean bean) {
String startTime=DateUtils.formatDate(org.apache.commons.lang3.time.DateUtils.addDays(new Date(),-30), "yyyy/MM/dd"); String startTime = DateUtils.formatDate(org.apache.commons.lang3.time.DateUtils.addDays(new Date(), -30), "yyyy/MM/dd");
String endTime=DateUtils.formatDate(new Date(), "yyyy/MM/dd"); String endTime = DateUtils.formatDate(new Date(), "yyyy/MM/dd");
if(org.apache.commons.lang3.StringUtils.isNotBlank(bean.getStartTime())){ if (org.apache.commons.lang3.StringUtils.isNotBlank(bean.getStartTime())) {
startTime=bean.getStartTime(); startTime = bean.getStartTime();
} }
if(org.apache.commons.lang3.StringUtils.isNotBlank(bean.getEndTime())){ if (org.apache.commons.lang3.StringUtils.isNotBlank(bean.getEndTime())) {
endTime=bean.getEndTime(); endTime = bean.getEndTime();
} }
return oilAnalysisDao.getOilReasons(startTime,endTime); return oilAnalysisDao.getOilReasons(startTime, endTime);
} }
public List<ResidualOilSummaryEntity> getAcTypeResidualOil(OilAnalysisBean bean) {
//派遣员条件为账号和名字
if (!StringUtils.isEmpty(bean.getDispatcher())) {
if (bean.getDispatcher().matches("[\u4E00-\u9FA5]+")) {
//内容是中文
bean.setDispatcherZH(bean.getDispatcher());
} else {
//内容包含非中文
bean.setDispatcherENG(bean.getDispatcher());
}
}
List<ResidualOilSummaryEntity> list = new ArrayList<>();
list = oilAnalysisDao.selectAcTypeResidualOil(bean);
for (ResidualOilSummaryEntity entity : list) {
if (ObjectUtils.equals(entity.getRate(),null)) {
entity.setRate("0");
}
if (ObjectUtils.equals(entity.getPlanLeftOver(),null)) {
entity.setPlanLeftOver(0D);
}
if(ObjectUtils.equals(entity.getAvgLeftOverOil(),null)){
String startMonth=null;
String endMonth=null;
if(StringUtils.isNotBlank(bean.getMinDepTime())){
startMonth=StringUtils.substring(StringUtils.replace(bean.getMinDepTime(), "/", "-"),0,7);
}
if(StringUtils.isNotBlank(bean.getMaxDepTime())){
endMonth=StringUtils.substring(StringUtils.replace(bean.getMaxDepTime(), "/", "-"),0,7);
}
Integer aDouble = leftOverOilDao.selectLeftOverOilByAcTypeAndDate(entity.getAcType(), startMonth, endMonth);
entity.setAvgLeftOverOil(aDouble);
}
}
Double planLeftOverAvg = list.size() == 0 ? 0D : list.parallelStream().map(s -> {
if (ObjectUtils.equals(s.getPlanLeftOver(), null)) {
return BigDecimal.valueOf(0);
}
return BigDecimal.valueOf(s.getPlanLeftOver());
})
.reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(list.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
Integer leftOverOilAvg = list.size() == 0 ? 0 : list.parallelStream().map(s -> {
if (ObjectUtils.equals(s.getAvgLeftOverOil(), null)) {
return BigDecimal.valueOf(0);
}
return BigDecimal.valueOf(s.getAvgLeftOverOil());
})
.reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(list.size()), 2, BigDecimal.ROUND_HALF_UP).intValue();
String rateAvg = list.size() == 0 ? "0" : list.parallelStream().map(s -> {
if (ObjectUtils.equals(s.getRate(), null)) {
return BigDecimal.valueOf(0);
}
return BigDecimal.valueOf(Double.parseDouble(s.getRate()));
})
.reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(list.size()), 2, BigDecimal.ROUND_HALF_UP).toString();
ResidualOilSummaryEntity residualOilSummaryEntity = new ResidualOilSummaryEntity();
residualOilSummaryEntity.setAcType("总计");
residualOilSummaryEntity.setAvgLeftOverOil(leftOverOilAvg);
residualOilSummaryEntity.setPlanLeftOver(planLeftOverAvg);
residualOilSummaryEntity.setRate(rateAvg);
list.add(residualOilSummaryEntity);
return list.parallelStream().peek(s -> s.setRate(s.getRate() + "%")).collect(Collectors.toList());
}
public List<OilTargetEntity> findNowYearTarget() {
return oilAnalysisDao.selectNowYearTarget();
}
} }
...@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSON; ...@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ejweb.core.base.BaseService; import com.ejweb.core.base.BaseService;
import com.ejweb.core.base.PageEntity; import com.ejweb.core.base.PageEntity;
import com.ejweb.core.exception.CommonException;
import com.ejweb.modules.airport.bean.StatiscalCheckBean; import com.ejweb.modules.airport.bean.StatiscalCheckBean;
import com.ejweb.modules.airport.bean.StatisticalBean; import com.ejweb.modules.airport.bean.StatisticalBean;
import com.ejweb.modules.airport.bean.StatisticalListBean; import com.ejweb.modules.airport.bean.StatisticalListBean;
...@@ -22,11 +23,13 @@ import com.github.pagehelper.PageHelper; ...@@ -22,11 +23,13 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import net.sf.jasperreports.engine.design.events.CollectionListenerAdapter; import net.sf.jasperreports.engine.design.events.CollectionListenerAdapter;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -87,6 +90,19 @@ public class StatisticalService extends BaseService<StatisticalDao> { ...@@ -87,6 +90,19 @@ public class StatisticalService extends BaseService<StatisticalDao> {
} else { } else {
e.setReStart(false); e.setReStart(false);
} }
//判断航线180天内是否有飞行过
String lastTime = airlineVerifiedDao.findAirLineSta(e.getDepIata(), e.getArrIata());
e.setRecentFlyStatus(false);
if (StringUtils.isNotBlank(lastTime)) {
try {
Date date = DateUtils.addDays(DateUtils.parseDate(lastTime, "yyyy-MM-dd"), 180);
if (DateUtils.truncatedCompareTo(date,new Date(),Calendar.DATE)>0){
e.setRecentFlyStatus(true);
}
} catch (ParseException parseException) {
throw new CommonException("航线:" + e.getDepIataName() + "到" + e.getArrIataName() + "航线论证最后一班事件:" + lastTime + "转换异常");
}
}
// 根据调机进行状态修改 // 根据调机进行状态修改
String startTime = e.getStartTime(); String startTime = e.getStartTime();
Date date = new Date(); Date date = new Date();
...@@ -172,26 +188,26 @@ public class StatisticalService extends BaseService<StatisticalDao> { ...@@ -172,26 +188,26 @@ public class StatisticalService extends BaseService<StatisticalDao> {
//筛选foc_check_iata中 不需要的航班 add by luoh //筛选foc_check_iata中 不需要的航班 add by luoh
Iterator<StatisticalListEntity> iterCheck = lists.iterator(); Iterator<StatisticalListEntity> iterCheck = lists.iterator();
String a321neoStr="{\"status\":\"3\",\"type\":\"321neo\"}"; String a321neoStr = "{\"status\":\"3\",\"type\":\"321neo\"}";
while (iterCheck.hasNext()) { while (iterCheck.hasNext()) {
StatisticalListEntity entity = iterCheck.next(); StatisticalListEntity entity = iterCheck.next();
String iataStr = entity.getDepIata() + "-" + entity.getArrIata(); String iataStr = entity.getDepIata() + "-" + entity.getArrIata();
for (StatiscalCheckBean check:checkList) { for (StatiscalCheckBean check : checkList) {
if (iataStr.equals(check.getIata())){ if (iataStr.equals(check.getIata())) {
iterCheck.remove(); iterCheck.remove();
break; break;
} }
} }
List<String> list = JSON.parseArray(entity.getAirlineJson(), String.class); List<String> list = JSON.parseArray(entity.getAirlineJson(), String.class);
List<String> newList=new ArrayList<>(); List<String> newList = new ArrayList<>();
if(list.size()==4&&list.get(1).contains("A321")){ if (list.size() == 4 && list.get(1).contains("A321")) {
newList.add(list.get(0)); newList.add(list.get(0));
newList.add(list.get(2)); newList.add(list.get(2));
newList.add(a321neoStr); newList.add(a321neoStr);
newList.add(list.get(1)); newList.add(list.get(1));
newList.add(list.get(3)); newList.add(list.get(3));
}else{ } else {
newList=list; newList = list;
} }
entity.setAirlineJson(newList.toString()); entity.setAirlineJson(newList.toString());
} }
...@@ -215,4 +231,5 @@ public class StatisticalService extends BaseService<StatisticalDao> { ...@@ -215,4 +231,5 @@ public class StatisticalService extends BaseService<StatisticalDao> {
return pageEntity; return pageEntity;
} }
} }
...@@ -14,6 +14,7 @@ import com.ejweb.modules.verify.entity.AirlineVerifyEntity; ...@@ -14,6 +14,7 @@ import com.ejweb.modules.verify.entity.AirlineVerifyEntity;
import com.ejweb.modules.verify.entity.FocStartnoEntity; import com.ejweb.modules.verify.entity.FocStartnoEntity;
import com.ejweb.modules.verify.entity.RouteverifyEntity; import com.ejweb.modules.verify.entity.RouteverifyEntity;
import com.ejweb.modules.verify.entity.VerifiedDetailEntity; import com.ejweb.modules.verify.entity.VerifiedDetailEntity;
import org.apache.ibatis.annotations.Param;
/** /**
* 航线论证Dao * 航线论证Dao
...@@ -56,4 +57,6 @@ public interface AirlineVerifiedDao extends BaseDao { ...@@ -56,4 +57,6 @@ public interface AirlineVerifiedDao extends BaseDao {
void updateStatus(AirlineVerifyUpdateStatusBean bean); void updateStatus(AirlineVerifyUpdateStatusBean bean);
String findAirLineSta(@Param("depIata") String depIata, @Param("arrIata") String arrIata);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment