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
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,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