Commit f70d1a53 by 罗胜

2023-11-12 罗胜

1.新增航线论证类型
parent 9a6ebd6b
...@@ -13,7 +13,7 @@ jdbc.maxActive=20 ...@@ -13,7 +13,7 @@ jdbc.maxActive=20
jdbc.maxIdle=100 jdbc.maxIdle=100
#\u6ca1\u6709\u4eba\u7528\u8fde\u63a5\u7684\u65f6\u5019\uff0c\u6700\u5c0f\u95f2\u7f6e\u7684\u8fde\u63a5\u4e2a\u6570\u3002 #\u6ca1\u6709\u4eba\u7528\u8fde\u63a5\u7684\u65f6\u5019\uff0c\u6700\u5c0f\u95f2\u7f6e\u7684\u8fde\u63a5\u4e2a\u6570\u3002
jdbc.minIdle=0 jdbc.minIdle=0
#\u8d85\u65f6\u7b49\u5f85\u65f6\u95f4\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d #\u8d85\u65f6\u7b49\u5f85\u65f6\u95f4\u4ee5\u6beb/api/ac\u79d2\u4e3a\u5355\u4f4d
jdbc.maxWait=10000 jdbc.maxWait=10000
#\u662f\u5426\u81ea\u52a8\u56de\u6536\u8d85\u65f6\u8fde\u63a5 #\u662f\u5426\u81ea\u52a8\u56de\u6536\u8d85\u65f6\u8fde\u63a5
jdbc.removeAbandoned=true jdbc.removeAbandoned=true
......
...@@ -33,4 +33,6 @@ ...@@ -33,4 +33,6 @@
WHERE a.del_flag = '0' WHERE a.del_flag = '0'
AND a.parent_id != '1' AND a.parent_id != '0' AND a.parent_id != '1' AND a.parent_id != '0'
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -13,6 +13,24 @@ ...@@ -13,6 +13,24 @@
</if> </if>
where id=#{id} where id=#{id}
</update> </update>
<update id="updateRemarkAndConclusion" >
update foc_flight_dynamics_sta sta
set sta.extra_oil_conclusion=#{conclusion} ,
sta.remark=#{bean.remark}
where sta.total_oil !=''
and sta.std <![CDATA[>=]]> date_format(#{bean.minDepTime}, '%Y-%c-%d %H:%i')
and sta.std <![CDATA[<]]> date_format(#{bean.maxDepTime}, '%Y-%c-%d %H:%i')
<choose>
<when test="bean.conclusion == '暂无原因'">
and ( substring_index( sta.extra_oil_fuel_reason_new, ':',- 1 ) is null or substring_index( sta.extra_oil_fuel_reason_new, ':',- 1 ) = '')
</when>
<otherwise>
and substring_index( sta.extra_oil_fuel_reason_new, ':',- 1 ) like CONCAT('%',#{bean.extraOilReason},'%')
</otherwise>
</choose>
</update>
<select id="getExcelOilAnalysisData1" resultType="com.ejweb.modules.airport.entity.OilAnalysisEntity"> <select id="getExcelOilAnalysisData1" resultType="com.ejweb.modules.airport.entity.OilAnalysisEntity">
select DATE_FORMAT(sta.std, '%Y/%m/%d %H:%i')as std, select DATE_FORMAT(sta.std, '%Y/%m/%d %H:%i')as std,
DATE_FORMAT(sta.std, '%Y/%m/%d %H:%i:%s')as stdExcel, DATE_FORMAT(sta.std, '%Y/%m/%d %H:%i:%s')as stdExcel,
...@@ -432,7 +450,7 @@ ...@@ -432,7 +450,7 @@
select temp.ac_type_name, select temp.ac_type_name,
TRUNCATE(avg(IFNULL(rate, 0)), 2) as rate, 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.plan_left_over, 0)), 2) as plan_left_over,
TRUNCATE(AVG(IFNULL(temp.left_over_oil_target, 0)), 2) TRUNCATE(AVG(IFNULL(temp.extra, 0)), 2)
as avg_left_over_oil as avg_left_over_oil
from (SELECT DATE_FORMAT(sta.std, '%Y/%m/%d %H:%i') AS std, from (SELECT DATE_FORMAT(sta.std, '%Y/%m/%d %H:%i') AS std,
sta.id, sta.id,
...@@ -444,6 +462,7 @@ ...@@ -444,6 +462,7 @@
TRUNCATE(((2 - ifnull(plan.plan_left_over, 0) / ifnull(loo.left_over_oil_target, 0))) * 100, TRUNCATE(((2 - ifnull(plan.plan_left_over, 0) / ifnull(loo.left_over_oil_target, 0))) * 100,
2) as rate, 2) as rate,
loo.left_over_oil_target, loo.left_over_oil_target,
plan.extra,
loo.ac_type loo.ac_type
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
...@@ -531,6 +550,7 @@ ...@@ -531,6 +550,7 @@
select ac_type,left_over_oil_target from foc_left_over_oil_target where year=YEAR(now()) group by ac_type,month select ac_type,left_over_oil_target from foc_left_over_oil_target where year=YEAR(now()) group by ac_type,month
</select> </select>
<!--已不用--> <!--已不用-->
<!-- <!--
<select id="getOilAnalysisData" resultType="com.ejweb.modules.airport.entity.OilAnalysisEntity"> <select id="getOilAnalysisData" resultType="com.ejweb.modules.airport.entity.OilAnalysisEntity">
......
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ejweb.modules.airport.dao.StatisticalDao"> <mapper namespace="com.ejweb.modules.airport.dao.StatisticalDao">
<insert id="insertAirlineVerify">
insert into foc_airline_verify
(id,verif_no,verif_type,verif_status,create_by,create_date,del_flag,route_no,depIata,arrIata,state,source,create_time
,aircraft_type,depart_id,update_by,update_date)
values
(#{id},#{verifNo},#{verifType},'02',#{userCode},now(),0,#{routeNo},#{depIata},#{arrIata},#{state},'1',now(),#{acTypeId},#{departId},#{userCode},now())
</insert>
<insert id="insertAirlineConnect">
insert into foc_airline_connect
(id,verif_id,del_flag,depIata,arrIata,Is_main,create_date)
values
(#{id1},#{verifyId},0,#{depIata},#{arrIata},'1',now())
</insert>
<insert id="insertAirlineVerifyType">
insert into foc_airline_verify2type
(id,verif_id,type_id,create_by,create_date,del_flag)
values
(#{id},#{verifyId},#{acTypeId},#{userCode},now(),0)
</insert>
<select id="getStatisticalList" resultType="com.ejweb.modules.airport.entity.StatisticalEntity"> <select id="getStatisticalList" resultType="com.ejweb.modules.airport.entity.StatisticalEntity">
SELECT a.verif_no as verifNo, SELECT a.verif_no as verifNo,
a.id as verifId, a.id as verifId,
...@@ -233,4 +257,16 @@ ...@@ -233,4 +257,16 @@
FROM FROM
foc_check_iata foc_check_iata
</select> </select>
<select id="findIdByAcType" resultType="java.lang.String">
select id from foc_aircraft_type where type_name=#{acType}
</select>
<select id="getDepartIdByUserId" resultType="java.lang.String">
select depart_id from sys_user_profiles where user_id = #{userId}
</select>
<select id="findVerifyByVerifyNoAndRouteNo" resultType="java.lang.Integer">
select count(1) from foc_airline_verify where verif_no=#{verifNo} and route_no=#{routeNo} and del_flag=0
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -73,4 +73,6 @@ ...@@ -73,4 +73,6 @@
<select id="getDepartIdByUserId" resultType="java.lang.String"> <select id="getDepartIdByUserId" resultType="java.lang.String">
select depart_id from sys_user_profiles where user_id = #{userId} select depart_id from sys_user_profiles where user_id = #{userId}
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -237,7 +237,7 @@ union (SELECT apply_no,create_time AS create_date ...@@ -237,7 +237,7 @@ union (SELECT apply_no,create_time AS create_date
AND del_flag = '0') AND del_flag = '0')
) a ) a
order by create_date desc order by apply_no desc
LIMIT 1 LIMIT 1
</select> </select>
<update id="updateNo"> <update id="updateNo">
......
package com.ejweb.core.api; package com.ejweb.core.api;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ClassUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ejweb.core.exception.CommonException; import com.ejweb.core.exception.CommonException;
...@@ -15,6 +17,7 @@ import java.util.List; ...@@ -15,6 +17,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors;
/** /**
* 所有的接口请求实体类 * 所有的接口请求实体类
...@@ -56,21 +59,30 @@ public class RequestBean { ...@@ -56,21 +59,30 @@ public class RequestBean {
* @param clazz * @param clazz
* @return * @return
*/ */
public <T> T getObjectBean(Type clazz){ public <T> T getObjectBean(Class<T> clazz){
if(content == null) if(content == null)
return null; return null;
try { try {
JSONObject jsonObject = JSONObject.parseObject(content); JSONObject jsonObject = JSONObject.parseObject(content);
Set<String> keySet = jsonObject.keySet(); Set<String> keySet = jsonObject.keySet();
if (keySet.contains("sort")) { for (String key : keySet) {
String sort = jsonObject.getString("sort"); if(StringUtils.equalsIgnoreCase(key,"sort")){
String sort = jsonObject.getString(key);
if (StringUtils.isNotBlank(sort)) { if (StringUtils.isNotBlank(sort)) {
if (containsSqlInjection(sort)) { if (containsSqlInjection(sort)) {
throw new CommonException("sort参数有sql注入风险"); throw new CommonException("sort参数有sql注入风险");
} }
} }
} }
return JSON.parseObject(content, clazz);
}
Class<Type> aClass = ClassUtil.getClass(clazz);
System.out.println("aClass = " + aClass);
Class<?> aClass1 = ClassUtil.getClassLoader().loadClass(clazz.getTypeName());
System.out.println("clazz.getTypeName() = " + clazz.getTypeName());
String str = JSONObject.toJSONString(jsonObject);
return BeanUtil.toBean(jsonObject,clazz);
}catch (CommonException e){ }catch (CommonException e){
throw new CommonException("sort参数有sql注入风险"); throw new CommonException("sort参数有sql注入风险");
} catch (Exception e) { } catch (Exception e) {
...@@ -87,8 +99,12 @@ public class RequestBean { ...@@ -87,8 +99,12 @@ public class RequestBean {
* @return * @return
*/ */
public static boolean containsSqlInjection(Object obj){ 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|(\\*|;|\\+|'|%)"); String str = obj.toString().toLowerCase();
Matcher matcher=pattern.matcher(obj.toString().toLowerCase()); if(StringUtils.contains(str,"Extractvalue(1,CONCAT(0x7e,Version()))")){
return true;
}
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(str);
return matcher.find(); return matcher.find();
} }
......
package com.ejweb.core.exception; package com.ejweb.core.exception;
import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.alibaba.fastjson.JSONObject;
import com.ejweb.core.util.Util;
import com.ejweb.modules.user.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.utils.DateUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
...@@ -15,7 +22,6 @@ import com.ejweb.core.api.ResponseBean; ...@@ -15,7 +22,6 @@ import com.ejweb.core.api.ResponseBean;
import com.ejweb.core.conf.ErrorCode; import com.ejweb.core.conf.ErrorCode;
import com.ejweb.core.conf.GConstants; import com.ejweb.core.conf.GConstants;
import com.ejweb.core.util.EmailStackTraceHandler; import com.ejweb.core.util.EmailStackTraceHandler;
import com.ejweb.core.util.Util;
/** /**
* 错误处理,抛出的异常会被这里截取,返回message * 错误处理,抛出的异常会被这里截取,返回message
...@@ -27,8 +33,10 @@ import com.ejweb.core.util.Util; ...@@ -27,8 +33,10 @@ import com.ejweb.core.util.Util;
*/ */
@ControllerAdvice(annotations={Controller.class, RestController.class}) @ControllerAdvice(annotations={Controller.class, RestController.class})
public class ErrorHandler { public class ErrorHandler {
Logger logger=Logger.getLogger(ErrorHandler.class);
private final static Logger LOG = Logger.getLogger(ErrorHandler.class);
@ExceptionHandler @ExceptionHandler(Exception.class)
@ResponseBody @ResponseBody
public ResponseBean handleException(HttpServletRequest request, Exception e) { public ResponseBean handleException(HttpServletRequest request, Exception e) {
...@@ -37,12 +45,18 @@ public class ErrorHandler { ...@@ -37,12 +45,18 @@ public class ErrorHandler {
try { try {
e.printStackTrace(); e.printStackTrace();
String error = Util.getStackTrace(e); String error = Util.getStackTrace(e);
bean.setData(error); // bean.setData(error);
logger.error("异常信息:{}",e);
System.out.println("异常:"+ JSONObject.toJSON(e));
if (e instanceof RuntimeException) { if (e instanceof RuntimeException) {
bean.setMessage(e.getMessage()); bean.setMessage(e.getMessage());
} else { } else {
bean.setMessage(e.toString()); bean.setMessage(e.toString());
} }
if(StringUtils.isBlank(bean.getMessage())){
bean.setMessage("系统异常");
}
LOG.error(DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss")+"系统报错,发送的请求失败!报错"+error);
if(GConstants.getBoolean("is.send.error.mail", false)){ if(GConstants.getBoolean("is.send.error.mail", false)){
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
Map<?,?> requestParams = request.getParameterMap(); Map<?,?> requestParams = request.getParameterMap();
......
...@@ -250,9 +250,11 @@ public class HCFetcher { ...@@ -250,9 +250,11 @@ public class HCFetcher {
EntityUtils.consume(httpEntity); EntityUtils.consume(httpEntity);
} }
} catch (IOException e) { } catch (IOException e) {
LOG.error("请求地址:"+url+"调用报错!信息返回:"+entity.getMessage()+",状态码:"+entity.getStatus()+",异常问题:"+e.getCause());
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (Exception e) { } catch (Exception e) {
LOG.error("请求地址:"+url+"调用报错!信息返回:"+entity.getMessage()+",状态码:"+entity.getStatus()+",异常问题:"+e.getMessage());
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
...@@ -273,7 +275,6 @@ public class HCFetcher { ...@@ -273,7 +275,6 @@ public class HCFetcher {
} }
} }
public FetchEntity post(final String url, List<BasicNameValuePair> params, final byte[] data) { public FetchEntity post(final String url, List<BasicNameValuePair> params, final byte[] data) {
synchronized (mutex) { synchronized (mutex) {
long currentTimeMillis = System.currentTimeMillis(); long currentTimeMillis = System.currentTimeMillis();
......
...@@ -11,6 +11,7 @@ import com.ejweb.core.security.GlobalUtil; ...@@ -11,6 +11,7 @@ import com.ejweb.core.security.GlobalUtil;
import com.ejweb.modules.call.util.PhoneAreaEntity; import com.ejweb.modules.call.util.PhoneAreaEntity;
import com.ejweb.modules.call.util.PhoneAreaUtil; import com.ejweb.modules.call.util.PhoneAreaUtil;
import com.ejweb.modules.im.entity.GroupEntity; import com.ejweb.modules.im.entity.GroupEntity;
import com.huawei.esdk.uc.professional.local.constant.ResultCode;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -564,6 +565,8 @@ public class Util { ...@@ -564,6 +565,8 @@ public class Util {
String plain = Encodes.unescapeHtml(plainPassword); String plain = Encodes.unescapeHtml(plainPassword);
byte[] salt = Encodes.decodeHex(password.substring(0, 16)); byte[] salt = Encodes.decodeHex(password.substring(0, 16));
byte[] hashPassword = Digests.sha1(plain.getBytes(), salt, GConstants.HASH_INTERATIONS); byte[] hashPassword = Digests.sha1(plain.getBytes(), salt, GConstants.HASH_INTERATIONS);
System.out.println();
System.out.println(Encodes.encodeHex(hashPassword));
return password.equals(Encodes.encodeHex(salt) + Encodes.encodeHex(hashPassword)); return password.equals(Encodes.encodeHex(salt) + Encodes.encodeHex(hashPassword));
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
...@@ -571,6 +574,9 @@ public class Util { ...@@ -571,6 +574,9 @@ public class Util {
return false; return false;
} }
public static String getGenericCode() { public static String getGenericCode() {
try { try {
return UUID.randomUUID().toString().replaceAll("-", "").toLowerCase(); return UUID.randomUUID().toString().replaceAll("-", "").toLowerCase();
...@@ -741,10 +747,6 @@ public class Util { ...@@ -741,10 +747,6 @@ public class Util {
} }
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(Util.validatePassword("Hjwx#1234", "247fd14c5d908a8312dc23e175e86c4f2e011fb76e08827cd65c962b")); System.out.println(Util.validatePassword("1qaz@WSX", "247fd14c5d908a8312dc23e175e86c4f2e011fb76e08827cd65c962b"));
System.out.println(phoneReg("18501501226"));
System.out.println(phoneReg("018501501226"));
System.out.println(phoneReg("0018501501226"));
System.out.println(phoneReg("51018501501226"));
} }
} }
...@@ -9,15 +9,14 @@ import java.io.IOException; ...@@ -9,15 +9,14 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Collections; import java.util.*;
import java.util.Comparator; import java.util.stream.Collectors;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSONObject;
import com.ejweb.modules.airport.entity.StatisticalEntity;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
...@@ -92,8 +91,10 @@ public class ExportExcel { ...@@ -92,8 +91,10 @@ public class ExportExcel {
public ExportExcel(String title, Class<?> cls, int type, int... groups){ public ExportExcel(String title, Class<?> cls, int type, int... groups){
// Get annotation field // Get annotation field
Field[] fs = cls.getDeclaredFields(); Field[] fs = cls.getDeclaredFields();
for (Field f : fs){ for (Field f : fs){
ExcelField ef = f.getAnnotation(ExcelField.class); ExcelField ef = f.getAnnotation(ExcelField.class);
System.out.println("ef = " + ef);
if (ef != null && (ef.type()==0 || ef.type()==type)){ if (ef != null && (ef.type()==0 || ef.type()==type)){
if (groups!=null && groups.length>0){ if (groups!=null && groups.length>0){
boolean inGroup = false; boolean inGroup = false;
...@@ -118,6 +119,7 @@ public class ExportExcel { ...@@ -118,6 +119,7 @@ public class ExportExcel {
Method[] ms = cls.getDeclaredMethods(); Method[] ms = cls.getDeclaredMethods();
for (Method m : ms){ for (Method m : ms){
ExcelField ef = m.getAnnotation(ExcelField.class); ExcelField ef = m.getAnnotation(ExcelField.class);
System.out.println("ef = " + ef);
if (ef != null && (ef.type()==0 || ef.type()==type)){ if (ef != null && (ef.type()==0 || ef.type()==type)){
if (groups!=null && groups.length>0){ if (groups!=null && groups.length>0){
boolean inGroup = false; boolean inGroup = false;
...@@ -138,15 +140,14 @@ public class ExportExcel { ...@@ -138,15 +140,14 @@ public class ExportExcel {
} }
} }
} }
System.out.println(111);
// Field sorting // Field sorting
Collections.sort(annotationList, new Comparator<Object[]>() { annotationList=annotationList.stream().sorted((s1,s2)->{return ((ExcelField)s1[0]).sort()-((ExcelField)s2[0]).sort();}).collect(Collectors.toList());
public int compare(Object[] o1, Object[] o2) {
return new Integer(((ExcelField)o1[0]).sort()).compareTo( System.out.println(222);
new Integer(((ExcelField)o2[0]).sort()));
};
});
// Initialize // Initialize
List<String> headerList = Lists.newArrayList(); List<String> headerList = Lists.newArrayList();
System.out.println("headerList = " + headerList);
for (Object[] os : annotationList){ for (Object[] os : annotationList){
String t = ((ExcelField)os[0]).title(); String t = ((ExcelField)os[0]).title();
// 如果是导出,则去掉注释 // 如果是导出,则去掉注释
...@@ -572,4 +573,62 @@ public class ExportExcel { ...@@ -572,4 +573,62 @@ public class ExportExcel {
// //
// } // }
public static void main(String[] args) {
Field[] fs = StatisticalEntity.class.getDeclaredFields();
List<Object[]> annotationList=new ArrayList<>();
int[] groups={};
Integer type =1;
for (Field f : fs){
ExcelField ef = f.getAnnotation(ExcelField.class);
System.out.println("ef = " + ef);
if (ef != null && (ef.type()==0 || ef.type()==type)){
if (groups!=null && groups.length>0){
boolean inGroup = false;
for (int g : groups){
if (inGroup){
break;
}
for (int efg : ef.groups()){
if (g == efg){
inGroup = true;
annotationList.add(new Object[]{ef, f});
break;
}
}
}
}else{
annotationList.add(new Object[]{ef, f});
}
}
}
// Get annotation method
Method[] ms = StatisticalEntity.class.getDeclaredMethods();
for (Method m : ms){
ExcelField ef = m.getAnnotation(ExcelField.class);
System.out.println("ef = " + ef);
if (ef != null && (ef.type()==0 || ef.type()==type)){
if (groups!=null && groups.length>0){
boolean inGroup = false;
for (int g : groups){
if (inGroup){
break;
}
for (int efg : ef.groups()){
if (g == efg){
inGroup = true;
annotationList.add(new Object[]{ef, m});
break;
}
}
}
}else{
annotationList.add(new Object[]{ef, m});
}
}
}
annotationList=annotationList.stream().sorted((s1,s2)->{return ((ExcelField)s1[0]).sort()-((ExcelField)s2[0]).sort();}).collect(Collectors.toList());
for (Object[] objects : annotationList) {
System.out.println(JSONObject.toJSONString(objects));
}
}
} }
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
*/ */
package com.ejweb.core.utils.excel; package com.ejweb.core.utils.excel;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import com.ejweb.core.utils.excel.annotation.ExcelField; import com.ejweb.core.utils.excel.annotation.ExcelField;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -23,6 +25,7 @@ import java.lang.reflect.Field; ...@@ -23,6 +25,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* 导入Excel文件(支持“XLS”和“XLSX”格式) * 导入Excel文件(支持“XLS”和“XLSX”格式)
...@@ -253,13 +256,15 @@ public class ImportExcel { ...@@ -253,13 +256,15 @@ public class ImportExcel {
} }
} }
// Field sorting // Field sorting
Collections.sort(annotationList, new Comparator<Object[]>() { // Collections.sort(annotationList, new Comparator<Object[]>() {
public int compare(Object[] o1, Object[] o2) { // public int compare(Object[] o1, Object[] o2) {
return new Integer(((ExcelField) o1[0]).sort()).compareTo(new Integer(((ExcelField) o2[0]).sort())); // return new Integer(((ExcelField) o1[0]).sort()).compareTo(new Integer(((ExcelField) o2[0]).sort()));
} // }
//
// ;
// });
; annotationList=annotationList.stream().sorted((s1,s2)->{return ((ExcelField)s1[0]).sort()-((ExcelField)s2[0]).sort();}).collect(Collectors.toList());
});
// log.debug("Import column count:"+annotationList.size()); // log.debug("Import column count:"+annotationList.size());
// Get excel data // Get excel data
List<E> dataList = Lists.newArrayList(); List<E> dataList = Lists.newArrayList();
...@@ -342,4 +347,156 @@ public class ImportExcel { ...@@ -342,4 +347,156 @@ public class ImportExcel {
} }
return dataList; return dataList;
} }
/**
* 获取单行标题导入数据列表
*
* @param cls 导入对象类型
* @param groups 导入分组
*/
public <E> List<E> getDataList1(Class<E> cls, int... groups) throws InstantiationException, IllegalAccessException {
List<Object[]> annotationList = Lists.newArrayList();
// Get annotation field
Field[] fs = cls.getDeclaredFields();
for (Field f : fs) {
ExcelField ef = f.getAnnotation(ExcelField.class);
if (ef != null && (ef.type() == 0 || ef.type() == 2)) {
if (groups != null && groups.length > 0) {
boolean inGroup = false;
for (int g : groups) {
if (inGroup) {
break;
}
for (int efg : ef.groups()) {
if (g == efg) {
inGroup = true;
annotationList.add(new Object[]{ef, f});
break;
}
}
}
} else {
annotationList.add(new Object[]{ef, f});
}
}
}
// Get annotation method
Method[] ms = cls.getDeclaredMethods();
for (Method m : ms) {
ExcelField ef = m.getAnnotation(ExcelField.class);
if (ef != null && (ef.type() == 0 || ef.type() == 2)) {
if (groups != null && groups.length > 0) {
boolean inGroup = false;
for (int g : groups) {
if (inGroup) {
break;
}
for (int efg : ef.groups()) {
if (g == efg) {
inGroup = true;
annotationList.add(new Object[]{ef, m});
break;
}
}
}
} else {
annotationList.add(new Object[]{ef, m});
}
}
}
// Field sorting
// CollUtil.sort(annotationList, new Comparator<Object[]>() {
// public int compare(Object[] o1, Object[] o2) {
// return Integer.compare(((ExcelField) o1[0]).sort(), ((ExcelField) o2[0]).sort());
// }
// ;
// });
List<Object[]> fields = new ArrayList<>();
for (Object[] objects : annotationList) {
ExcelField field = (ExcelField)objects[0];
fields.add(field.sort()-11, objects);
}
annotationList=fields;
// log.debug("Import column count:"+annotationList.size());
// Get excel data
List<E> dataList = Lists.newArrayList();
for (int i = this.getDataRowNum()-1; i < this.getLastDataRowNum(); i++) {
E e = (E) cls.newInstance();
int column = 0;
Row row = this.getRow(i);
StringBuilder sb = new StringBuilder();
for (Object[] os : annotationList) {
Object val = this.getCellValue(row, column++);
if (val != null) {
ExcelField ef = (ExcelField) os[0];
// If is dict type, get dict value
/* if (StringUtils.isNotBlank(ef.dictType())) {
val = DictUtils.getDictValue(val.toString(), ef.dictType(), "");
// log.debug("Dictionary type value: ["+i+","+colunm+"]
// " + val);
}
*/ // Get param type and type cast
Class<?> valType = Class.class;
if (os[1] instanceof Field) {
valType = ((Field) os[1]).getType();
} else if (os[1] instanceof Method) {
Method method = ((Method) os[1]);
if ("get".equals(method.getName().substring(0, 3))) {
valType = method.getReturnType();
} else if ("set".equals(method.getName().substring(0, 3))) {
valType = ((Method) os[1]).getParameterTypes()[0];
}
}
// log.debug("Import value type: ["+i+","+column+"] " +
// valType);
try {
if (valType == String.class) {
String s = String.valueOf(val.toString());
if (StringUtils.endsWith(s, ".0")) {
val = StringUtils.substringBefore(s, ".0");
} else {
val = String.valueOf(val.toString());
}
} else if (valType == Integer.class) {
val = Double.valueOf(val.toString()).intValue();
} else if (valType == Long.class) {
val = Double.valueOf(val.toString()).longValue();
} else if (valType == Double.class) {
val = Double.valueOf(val.toString());
} else if (valType == Float.class) {
val = Float.valueOf(val.toString());
} else if (valType == Date.class) {
val = DateUtil.getJavaDate((Double) val);
} else {
if (ef.fieldType() != Class.class) {
val = ef.fieldType().getMethod("getValue", String.class).invoke(null, val.toString());
} else {
val = Class
.forName(this.getClass().getName().replaceAll(this.getClass().getSimpleName(),
"fieldtype." + valType.getSimpleName() + "Type"))
.getMethod("getValue", String.class).invoke(null, val.toString());
}
}
} catch (Exception ex) {
log.info("Get cell value [" + i + "," + column + "] error: " + ex.toString());
val = null;
}
// set entity value
if (os[1] instanceof Field) {
Reflections.invokeSetter(e, ((Field) os[1]).getName(), val);
} else if (os[1] instanceof Method) {
String mthodName = ((Method) os[1]).getName();
if ("get".equals(mthodName.substring(0, 3))) {
mthodName = "set" + StringUtils.substringAfter(mthodName, "get");
}
Reflections.invokeMethod(e, mthodName, new Class[]{valType}, new Object[]{val});
}
}
sb.append(val + ", ");
}
dataList.add(e);
log.debug("Read success: [" + i + "] " + sb.toString());
}
return dataList;
}
} }
...@@ -7,6 +7,7 @@ import java.util.List; ...@@ -7,6 +7,7 @@ import java.util.List;
import com.ejweb.core.base.BaseDao; import com.ejweb.core.base.BaseDao;
import com.ejweb.modules.aircraft.entity.TypeEntity; import com.ejweb.modules.aircraft.entity.TypeEntity;
import org.apache.ibatis.annotations.Param;
/** /**
* *
...@@ -22,4 +23,6 @@ public interface TypeDao extends BaseDao { ...@@ -22,4 +23,6 @@ public interface TypeDao extends BaseDao {
public List<TypeEntity> findParentlist(); public List<TypeEntity> findParentlist();
public List<TypeEntity> findChildlist(); public List<TypeEntity> findChildlist();
} }
...@@ -7,14 +7,13 @@ import com.ejweb.core.base.PageEntity; ...@@ -7,14 +7,13 @@ 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;
import com.ejweb.core.utils.excel.ExportExcel; import com.ejweb.core.utils.excel.ExportExcel;
import com.ejweb.modules.airport.bean.ExtraOilReasonBean; import com.ejweb.modules.airport.bean.*;
import com.ejweb.modules.airport.bean.OilAnalysisBean;
import com.ejweb.modules.airport.bean.OilAnalysisIdBean;
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.OilTargetEntity;
import com.ejweb.modules.airport.entity.ResidualOilSummaryEntity; import com.ejweb.modules.airport.entity.ResidualOilSummaryEntity;
import com.ejweb.modules.airport.service.OilAnalysisService; import com.ejweb.modules.airport.service.OilAnalysisService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
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.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -111,7 +110,7 @@ public class OilAnalysisController { ...@@ -111,7 +110,7 @@ public class OilAnalysisController {
public ResponseBean getOilReason(RequestBean requestBean) { public ResponseBean getOilReason(RequestBean requestBean) {
ResponseBean responseBean = new ResponseBean(); ResponseBean responseBean = new ResponseBean();
ExtraOilReasonBean bean = requestBean.getObjectBean(ExtraOilReasonBean.class); ExtraOilReasonBean bean = requestBean.getObjectBean(ExtraOilReasonBean.class);
List<String> reasons=oilAnalysisService.getOilReason(bean); List<String> reasons = oilAnalysisService.getOilReason(bean);
responseBean.setMessage(GConstants.OK); responseBean.setMessage(GConstants.OK);
responseBean.setStatus(ErrorCode.STATUS_CODE_2000); responseBean.setStatus(ErrorCode.STATUS_CODE_2000);
responseBean.setData(reasons); responseBean.setData(reasons);
...@@ -121,10 +120,10 @@ public class OilAnalysisController { ...@@ -121,10 +120,10 @@ public class OilAnalysisController {
@RequestMapping(value = "/acTypeResidualOil") @RequestMapping(value = "/acTypeResidualOil")
@ResponseBody @ResponseBody
public ResponseBean acTypeResidualOil(RequestBean requestBean){ public ResponseBean acTypeResidualOil(RequestBean requestBean) {
ResponseBean responseBean = new ResponseBean(); ResponseBean responseBean = new ResponseBean();
OilAnalysisBean bean = requestBean.getObjectBean(OilAnalysisBean.class); OilAnalysisBean bean = requestBean.getObjectBean(OilAnalysisBean.class);
List<ResidualOilSummaryEntity> list=oilAnalysisService.getAcTypeResidualOil(bean); List<ResidualOilSummaryEntity> list = oilAnalysisService.getAcTypeResidualOil(bean);
if (list == null) { if (list == null) {
responseBean.setMessage(GConstants.EMPTY); responseBean.setMessage(GConstants.EMPTY);
responseBean.setStatus(ErrorCode.STATUS_CODE_2001); responseBean.setStatus(ErrorCode.STATUS_CODE_2001);
...@@ -139,10 +138,10 @@ public class OilAnalysisController { ...@@ -139,10 +138,10 @@ public class OilAnalysisController {
@RequestMapping(value = "/acTypeResidualOilExcel") @RequestMapping(value = "/acTypeResidualOilExcel")
@ResponseBody @ResponseBody
public ResponseBean acTypeResidualOilExcel(RequestBean requestBean,HttpServletResponse response){ public ResponseBean acTypeResidualOilExcel(RequestBean requestBean, HttpServletResponse response) {
ResponseBean responseBean = new ResponseBean(); ResponseBean responseBean = new ResponseBean();
OilAnalysisBean bean = requestBean.getObjectBean(OilAnalysisBean.class); OilAnalysisBean bean = requestBean.getObjectBean(OilAnalysisBean.class);
List<ResidualOilSummaryEntity> list=oilAnalysisService.getAcTypeResidualOil(bean); List<ResidualOilSummaryEntity> list = oilAnalysisService.getAcTypeResidualOil(bean);
//自定义导出序号 //自定义导出序号
String fileName = "机型剩油汇总.xlsx"; String fileName = "机型剩油汇总.xlsx";
try { try {
...@@ -157,10 +156,10 @@ public class OilAnalysisController { ...@@ -157,10 +156,10 @@ public class OilAnalysisController {
@RequestMapping(value = "/getNowYearTarget") @RequestMapping(value = "/getNowYearTarget")
@ResponseBody @ResponseBody
public ResponseBean getNowYearTarget(RequestBean requestBean){ public ResponseBean getNowYearTarget(RequestBean requestBean) {
ResponseBean responseBean = new ResponseBean(); ResponseBean responseBean = new ResponseBean();
List<OilTargetEntity> list=oilAnalysisService.findNowYearTarget(); List<OilTargetEntity> list = oilAnalysisService.findNowYearTarget();
if (list == null||list.size()==0) { if (list == null || list.size() == 0) {
responseBean.setMessage(GConstants.EMPTY); responseBean.setMessage(GConstants.EMPTY);
responseBean.setStatus(ErrorCode.STATUS_CODE_2001); responseBean.setStatus(ErrorCode.STATUS_CODE_2001);
return responseBean; return responseBean;
...@@ -172,4 +171,27 @@ public class OilAnalysisController { ...@@ -172,4 +171,27 @@ public class OilAnalysisController {
return responseBean; return responseBean;
} }
@RequestMapping(value = "/updateRemarkAndConclusion")
@ResponseBody
public ResponseBean updateRemarkAndConclusion(RequestBean requestBean) {
ResponseBean responseBean = new ResponseBean();
OilBatchUpdateBean bean = requestBean.getObjectBean(OilBatchUpdateBean.class);
if(StringUtils.isBlank(bean.getExtraOilReason())){
responseBean.setMessage("额外油原因不能为空!");
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
}else if(StringUtils.isBlank(bean.getExtraOilReason())||StringUtils.isBlank(bean.getExtraOilReason())){
responseBean.setMessage("计划起飞时间开始和结束不能为空!");
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
}else if(StringUtils.isBlank(bean.getConclusion())){
responseBean.setMessage("计划起飞时间开始和结束不能为空!");
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
}
oilAnalysisService.updateRemarkAndConclusion(bean);
responseBean.setMessage(GConstants.OK);
responseBean.setStatus(ErrorCode.STATUS_CODE_2000);
return responseBean;
}
} }
...@@ -9,22 +9,37 @@ import com.ejweb.core.api.ResponseBean; ...@@ -9,22 +9,37 @@ import com.ejweb.core.api.ResponseBean;
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;
import com.ejweb.core.exception.CommonException;
import com.ejweb.core.utils.excel.ExportExcel; import com.ejweb.core.utils.excel.ExportExcel;
import com.ejweb.core.utils.excel.ImportExcel;
import com.ejweb.modules.airport.bean.StatisticalBean; import com.ejweb.modules.airport.bean.StatisticalBean;
import com.ejweb.modules.airport.bean.StatisticalImportBean;
import com.ejweb.modules.airport.bean.StatisticalListBean; import com.ejweb.modules.airport.bean.StatisticalListBean;
import com.ejweb.modules.airport.bean.TypeBean; import com.ejweb.modules.airport.bean.TypeBean;
import com.ejweb.modules.airport.entity.StatisticalEntity; import com.ejweb.modules.airport.entity.StatisticalEntity;
import com.ejweb.modules.airport.entity.StatisticalImportEntity;
import com.ejweb.modules.airport.entity.StatisticalListEntity; import com.ejweb.modules.airport.entity.StatisticalListEntity;
import com.ejweb.modules.airport.service.StatisticalService; import com.ejweb.modules.airport.service.StatisticalService;
import com.ejweb.modules.crew.scores.bean.MainBean;
import com.ejweb.modules.crew.scores.entity.MainEntity;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
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.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
/** /**
* 数据统计 * 数据统计
...@@ -78,7 +93,7 @@ public class StatisticalController { ...@@ -78,7 +93,7 @@ public class StatisticalController {
StatisticalBean bean = requestBean.getObjectBean(StatisticalBean.class); StatisticalBean bean = requestBean.getObjectBean(StatisticalBean.class);
String message = statisticalService.validate(bean); String message = statisticalService.validate(bean);
if (message == null) { if (message == null) {
bean.setPageSize(1000); bean.setPageSize(10000);
// 参数校验为通过 // 参数校验为通过
PageEntity<StatisticalEntity> page = statisticalService.getStatisticalList(bean); PageEntity<StatisticalEntity> page = statisticalService.getStatisticalList(bean);
List<StatisticalEntity> list = new ArrayList<StatisticalEntity>(); List<StatisticalEntity> list = new ArrayList<StatisticalEntity>();
...@@ -140,31 +155,31 @@ public class StatisticalController { ...@@ -140,31 +155,31 @@ public class StatisticalController {
list = page.getList(); list = page.getList();
//自定义导出序号 //自定义导出序号
int no = 1; int no = 1;
for (StatisticalListEntity s:list for (StatisticalListEntity s : list
) { ) {
//自定义导出格式 //自定义导出格式
s.setDepIataLabel(s.getDepIataName()+s.getDepIata()+"-"+s.getArrIataName()+s.getArrIata()); s.setDepIataLabel(s.getDepIataName() + s.getDepIata() + "-" + s.getArrIataName() + s.getArrIata());
s.setNo(no); s.setNo(no);
no++; no++;
//航线状态自定义 //航线状态自定义
if (s.getAirlineStatus() == 0){ if (s.getAirlineStatus() == 0) {
s.setStatus("失效"); s.setStatus("失效");
} }
if (s.getAirlineStatus() == 1){ if (s.getAirlineStatus() == 1) {
s.setStatus("有效"); s.setStatus("有效");
} }
//机型状态自定义 //机型状态自定义
List<TypeBean> typeBeans = JSON.parseArray(s.getAirlineJson(),TypeBean.class); List<TypeBean> typeBeans = JSON.parseArray(s.getAirlineJson(), TypeBean.class);
s.setTypeOne(typeInfo(typeBeans.get(0),s.getAirlineStatus())); s.setTypeOne(typeInfo(typeBeans.get(0), s.getAirlineStatus()));
s.setTypeTwo(typeInfo(typeBeans.get(typeBeans.size()-4),s.getAirlineStatus())); s.setTypeTwo(typeInfo(typeBeans.get(typeBeans.size() - 4), s.getAirlineStatus()));
s.setTypeThree(typeInfo(typeBeans.get(typeBeans.size()-3),s.getAirlineStatus())); s.setTypeThree(typeInfo(typeBeans.get(typeBeans.size() - 3), s.getAirlineStatus()));
s.setTypeFour(typeInfo(typeBeans.get(typeBeans.size()-2),s.getAirlineStatus())); s.setTypeFour(typeInfo(typeBeans.get(typeBeans.size() - 2), s.getAirlineStatus()));
s.setTypeFive(typeInfo(typeBeans.get(typeBeans.size()-1),s.getAirlineStatus())); s.setTypeFive(typeInfo(typeBeans.get(typeBeans.size() - 1), s.getAirlineStatus()));
} }
String fileName = "航线执行期监控统计.xlsx"; String fileName = "航线执行期监控统计.xlsx";
try { try {
new ExportExcel("航线执行期监控统计---"+bean.getBenchmarkingTime(), StatisticalListEntity.class).setDataList(list).write(response, fileName).dispose(); new ExportExcel("航线执行期监控统计---" + bean.getBenchmarkingTime(), StatisticalListEntity.class).setDataList(list).write(response, fileName).dispose();
} catch (IOException e) { } catch (IOException e) {
responseBean.setMessage("导出数据失败" + e.getMessage()); responseBean.setMessage("导出数据失败" + e.getMessage());
return responseBean; return responseBean;
...@@ -180,23 +195,81 @@ public class StatisticalController { ...@@ -180,23 +195,81 @@ public class StatisticalController {
return responseBean; return responseBean;
} }
private String typeInfo(TypeBean s,Integer status){ private String typeInfo(TypeBean s, Integer status) {
if (status == 0){ if (status == 0) {
if (s.getStatus() == 3){ if (s.getStatus() == 3) {
return "不可用"; return "不可用";
} }
return "论证失效"; return "论证失效";
}else{ } else {
if (s.getStatus() == 1){ if (s.getStatus() == 1) {
return s.getLastTime(); return s.getLastTime();
} }
if (s.getStatus() == 2){ if (s.getStatus() == 2) {
return "可用"; return "可用";
} }
if (s.getStatus() == 3){ if (s.getStatus() == 3) {
return "不可用"; return "不可用";
} }
} }
return null; return null;
} }
/**
* 开航指令集导入
*
* @param request
* @param file
* @param requestBean
* @return
*/
@ResponseBody
@RequestMapping(value = "upload")
public ResponseBean upload(HttpServletRequest request,
@RequestParam("file") CommonsMultipartFile file,
RequestBean requestBean) {
ResponseBean responseBean = new ResponseBean();
StatisticalImportBean bean = requestBean.getObjectBean(StatisticalImportBean.class);
String message = statisticalService.validate(bean);
if (message != null) {
responseBean.setMessage(message);
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
}
String originalFilename = file.getOriginalFilename();
if (StringUtils.isNotBlank(originalFilename)) {// 文件扩展名称不能为NULL
if (originalFilename.contains("%") || originalFilename.contains(";")) {
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
responseBean.setMessage("上传文件不允许含有非法字符,请改正!");
return responseBean;
}
}
int length = 0;
try {
if (originalFilename.toLowerCase(Locale.ENGLISH).endsWith("xls")) {
HSSFWorkbook hwb = new HSSFWorkbook(file.getInputStream());
length = hwb.getNumberOfSheets();//判断有几张活动的sheet表
} else if (originalFilename.toLowerCase(Locale.ENGLISH).endsWith("xlsx")) {
XSSFWorkbook hwb = new XSSFWorkbook(file.getInputStream());
length = hwb.getNumberOfSheets();//判断有几张活动的sheet表
}
try {
ImportExcel ei = new ImportExcel(file, 1, 0);
List<StatisticalImportEntity> list = ei.getDataList1(StatisticalImportEntity.class);
statisticalService.saveData(list,bean.getUserCode());
}catch (InvalidFormatException | InstantiationException | IllegalAccessException |CommonException e) {
// TODO Auto-generated catch block
throw new CommonException(e.getMessage());
}
return responseBean;
} catch (IOException e) {
// TODO Auto-generated catch block
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
responseBean.setMessage(e.getMessage());
return responseBean;
}
}
} }
package com.ejweb.modules.airport.bean;
import com.ejweb.core.base.GenericBean;
import java.io.Serializable;
/**
* 油量分析两个
*
* @author luos
* @version 1.0
* @team suzhou
* @time 2022年3月1日
*/
public class OilBatchUpdateBean extends GenericBean implements Serializable {
//最低起飞时间
private String minDepTime;
//最大起飞时间
private String maxDepTime;
//额外油原因
private String extraOilReason;
//额外油结论
private String conclusion;
//备注
private String remark;
public OilBatchUpdateBean() {
}
public String getConclusion() {
return conclusion;
}
public void setConclusion(String conclusion) {
this.conclusion = conclusion;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getMinDepTime() {
return minDepTime;
}
public void setMinDepTime(String minDepTime) {
this.minDepTime = minDepTime;
}
public String getMaxDepTime() {
return maxDepTime;
}
public void setMaxDepTime(String maxDepTime) {
this.maxDepTime = maxDepTime;
}
public String getExtraOilReason() {
return extraOilReason;
}
public void setExtraOilReason(String extraOilReason) {
this.extraOilReason = extraOilReason;
}
}
package com.ejweb.modules.airport.bean;
import com.ejweb.core.base.GenericBean;
import org.hibernate.validator.constraints.NotEmpty;
public class StatisticalImportBean extends GenericBean {
@NotEmpty(message = "userCode不能为空")
private String userCode;
public String getUserCode() {
return userCode;
}
public void setUserCode(String userCode) {
this.userCode = userCode;
}
}
...@@ -3,6 +3,7 @@ package com.ejweb.modules.airport.dao; ...@@ -3,6 +3,7 @@ package com.ejweb.modules.airport.dao;
import com.ejweb.core.base.BaseDao; import com.ejweb.core.base.BaseDao;
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.bean.OilBatchUpdateBean;
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.OilTargetEntity;
import com.ejweb.modules.airport.entity.ResidualOilSummaryEntity; import com.ejweb.modules.airport.entity.ResidualOilSummaryEntity;
...@@ -30,4 +31,5 @@ public interface OilAnalysisDao extends BaseDao { ...@@ -30,4 +31,5 @@ public interface OilAnalysisDao extends BaseDao {
List<OilTargetEntity> selectNowYearTarget(); List<OilTargetEntity> selectNowYearTarget();
void updateRemarkAndConclusion(@Param("bean") OilBatchUpdateBean bean,@Param("conclusion") String conclusion);
} }
...@@ -38,4 +38,21 @@ public interface StatisticalDao extends BaseDao { ...@@ -38,4 +38,21 @@ public interface StatisticalDao extends BaseDao {
* @return luoh * @return luoh
*/ */
List<StatiscalCheckBean> getCheckList (); List<StatiscalCheckBean> getCheckList ();
public String findIdByAcType(@Param("acType") String acType);
public String getDepartIdByUserId(@Param("userId") String userId);
void insertAirlineVerify(@Param("id") String verifyId,@Param("verifNo") String verifNo,@Param("verifType") String verifType
,@Param("departId") String departId,@Param("acTypeId") String acTypeId,@Param("userCode") String userCode,
@Param("depIata") String depIata,@Param("arrIata") String arrIata,@Param("routeNo") String routeNo,
@Param("state") String state);
void insertAirlineConnect(@Param("id1") String id1,@Param("id2") String id2,@Param("verifyId") String verifyId
,@Param("depIata") String depIata,@Param("arrIata") String arrIata);
void insertAirlineVerifyType(@Param("id") String id,@Param("verifyId") String verifyId
,@Param("acTypeId") String acTypeId,@Param("userCode") String userCode);
Integer findVerifyByVerifyNoAndRouteNo(@Param("verifNo") String verifNo,@Param("routeNo") String routeNo);
} }
...@@ -125,66 +125,68 @@ public class OilAnalysisEntity { ...@@ -125,66 +125,68 @@ public class OilAnalysisEntity {
private String planLeftOver;//计划落地剩油 private String planLeftOver;//计划落地剩油
@ExcelField(title = "计划落地剩油增减量", type = 0, align = 1, sort = 65) @ExcelField(title = "计划落地剩油增减量", type = 0, align = 1, sort = 65)
private Integer increaseOrDecrease;//计划落地剩油增减量 private Integer increaseOrDecrease;//计划落地剩油增减量
@ExcelField(title = "CFP标志", type = 0, align = 1, sort = 66) @ExcelField(title = "计划落地剩油完成率", type = 0, align = 1, sort = 66)
private String rate;//计划落地剩油完成率
@ExcelField(title = "CFP标志", type = 0, align = 1, sort = 67)
private String cfpFlag;// private String cfpFlag;//
@ExcelField(title = "计算起飞重量", type = 0, align = 1, sort = 67) @ExcelField(title = "计算起飞重量", type = 0, align = 1, sort = 68)
private String takeoffWeight;// private String takeoffWeight;//
@ExcelField(title = "计算落地重量", type = 0, align = 1, sort = 68) @ExcelField(title = "计算落地重量", type = 0, align = 1, sort = 69)
private String landingWeight;// private String landingWeight;//
@ExcelField(title = "计算业载", type = 0, align = 1, sort = 69) @ExcelField(title = "计算业载", type = 0, align = 1, sort = 70)
private String payloadWeight;// private String payloadWeight;//
@ExcelField(title = "计算零油量重量", type = 0, align = 1, sort = 70) @ExcelField(title = "计算零油量重量", type = 0, align = 1, sort =71 )
private String zeroFuel;// private String zeroFuel;//
@ExcelField(title = "计算货物重量", type = 0, align = 1, sort = 71) @ExcelField(title = "计算货物重量", type = 0, align = 1, sort = 72)
private String kalCargoLoad;// private String kalCargoLoad;//
@ExcelField(title = "油箱最大容积", type = 0, align = 1, sort = 72) @ExcelField(title = "油箱最大容积", type = 0, align = 1, sort = 73)
private String maximumFuelCapacity;// private String maximumFuelCapacity;//
@ExcelField(title = "总油", type = 0, align = 1, sort = 73) @ExcelField(title = "总油", type = 0, align = 1, sort = 74)
private String total;// private String total;//
@ExcelField(title = "总时间", type = 0, align = 1, sort = 74) @ExcelField(title = "总时间", type = 0, align = 1, sort = 75)
private String totalTime;// private String totalTime;//
@ExcelField(title = "航线耗油", type = 0, align = 1, sort = 75) @ExcelField(title = "航线耗油", type = 0, align = 1, sort = 76)
private String trip;// private String trip;//
@ExcelField(title = "航线时间", type = 0, align = 1, sort = 76) @ExcelField(title = "航线时间", type = 0, align = 1, sort = 77)
private String tripTime;// private String tripTime;//
@ExcelField(title = "航线距离", type = 0, align = 1, sort = 77) @ExcelField(title = "航线距离", type = 0, align = 1, sort = 78)
private String tripDist;// private String tripDist;//
@ExcelField(title = "预计到达时刻", type = 0, align = 1, sort = 78) @ExcelField(title = "预计到达时刻", type = 0, align = 1, sort = 79)
private String arrivalTime;// private String arrivalTime;//
@ExcelField(title = "备降耗油", type = 0, align = 1, sort = 79) @ExcelField(title = "备降耗油", type = 0, align = 1, sort = 80)
private String alternateFuel;// private String alternateFuel;//
@ExcelField(title = "备降时间", type = 0, align = 1, sort = 80) @ExcelField(title = "备降时间", type = 0, align = 1, sort = 81)
private String alternateTime;// private String alternateTime;//
@ExcelField(title = "备降距离", type = 0, align = 1, sort = 81) @ExcelField(title = "备降距离", type = 0, align = 1, sort = 82)
private String alternateDist;// private String alternateDist;//
@ExcelField(title = "滑出油", type = 0, align = 1, sort = 82) @ExcelField(title = "滑出油", type = 0, align = 1, sort = 83)
private String taxiOut;// private String taxiOut;//
@ExcelField(title = "滑出时间", type = 0, align = 1, sort = 83) @ExcelField(title = "滑出时间", type = 0, align = 1, sort = 84)
private String taxiOutTime;// private String taxiOutTime;//
@ExcelField(title = "最后储备油", type = 0, align = 1, sort = 84) @ExcelField(title = "最后储备油", type = 0, align = 1, sort = 85)
private String hold;//最后储存油 private String hold;//最后储存油
@ExcelField(title = "不可预期燃油", type = 0, align = 1, sort = 85) @ExcelField(title = "不可预期燃油", type = 0, align = 1, sort = 86)
private String reserve;//不可预期燃油 private String reserve;//不可预期燃油
@ExcelField(title = "不可预期时间", type = 0, align = 1, sort = 86) @ExcelField(title = "不可预期时间", type = 0, align = 1, sort = 87)
private String reserveTime;//不可预期燃油 private String reserveTime;//不可预期燃油
@ExcelField(title = "计算额外油", type = 0, align = 1, sort = 87) @ExcelField(title = "计算额外油", type = 0, align = 1, sort = 88)
private String extra;// private String extra;//
@ExcelField(title = "计算额外时间", type = 0, align = 1, sort = 88) @ExcelField(title = "计算额外时间", type = 0, align = 1, sort = 89)
private String extraTime;// private String extraTime;//
@ExcelField(title = "录入额外时间", type = 0, align = 1, sort = 89) @ExcelField(title = "录入额外时间", type = 0, align = 1, sort = 90)
private String customExtraTime;// private String customExtraTime;//
@ExcelField(title = "性能限制起飞重量", type = 0, align = 1, sort = 90) @ExcelField(title = "性能限制起飞重量", type = 0, align = 1, sort = 91)
private String limitingTakeoffWeight;// private String limitingTakeoffWeight;//
@ExcelField(title = "性能限制落地重量", type = 0, align = 1, sort = 91) @ExcelField(title = "性能限制落地重量", type = 0, align = 1, sort = 92)
private String limitingLandingWeight;// private String limitingLandingWeight;//
@ExcelField(title = "Etop油量", type = 0, align = 1, sort = 92) @ExcelField(title = "Etop油量", type = 0, align = 1, sort = 93)
private String etop;// private String etop;//
@ExcelField(title = "Etop时间", type = 0, align = 1, sort = 93) @ExcelField(title = "Etop时间", type = 0, align = 1, sort = 94)
private String etopTime;// private String etopTime;//
@ExcelField(title = "备注", type = 0, align = 1, sort = 94) @ExcelField(title = "备注", type = 0, align = 1, sort = 95)
private String remark;//备注 private String remark;//备注
@ExcelField(title = "完成率", type = 0, align = 1, sort = 95)
private String rate;//完成率
......
package com.ejweb.modules.airport.entity;
import com.ejweb.core.base.BaseEntity;
import com.ejweb.core.utils.excel.annotation.ExcelField;
public class StatisticalImportEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
@ExcelField(title="航班号", type=0, align=1, sort=11)
private String flightNo;
@ExcelField(title = "论证单号",type = 0,align = 1,sort = 12)
private String verifNo;
@ExcelField(title = "论证机型",type = 0,align = 1,sort = 13)
private String acType;
@ExcelField(title = "起飞地三字码",type = 0,align = 1,sort = 14)
private String depIata;
@ExcelField(title = "到达地三字码",type = 0,align = 1,sort = 15)
private String arrIata;
@ExcelField(title = "失效状态",type = 0,align = 1,sort = 16)
private String stateStr;
private String state;
@ExcelField(title = "论证类型",type = 0,align = 1,sort = 17)
private String verifTypeStr;
private String verifType;
@ExcelField(title = "开航指令编号",type = 0,align = 1,sort = 18)
private String routeNo;
public String getFlightNo() {
return flightNo;
}
public void setFlightNo(String flightNo) {
this.flightNo = flightNo;
}
public String getVerifNo() {
return verifNo;
}
public void setVerifNo(String verifNo) {
this.verifNo = verifNo;
}
public String getAcType() {
return acType;
}
public void setAcType(String acType) {
this.acType = acType;
}
public String getDepIata() {
return depIata;
}
public void setDepIata(String depIata) {
this.depIata = depIata;
}
public String getArrIata() {
return arrIata;
}
public void setArrIata(String arrIata) {
this.arrIata = arrIata;
}
public String getStateStr() {
return stateStr;
}
public void setStateStr(String stateStr) {
this.stateStr = stateStr;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getVerifTypeStr() {
return verifTypeStr;
}
public void setVerifTypeStr(String verifTypeStr) {
this.verifTypeStr = verifTypeStr;
}
public String getVerifType() {
return verifType;
}
public void setVerifType(String verifType) {
this.verifType = verifType;
}
public String getRouteNo() {
return routeNo;
}
public void setRouteNo(String routeNo) {
this.routeNo = routeNo;
}
}
...@@ -5,6 +5,7 @@ import com.ejweb.core.base.PageEntity; ...@@ -5,6 +5,7 @@ import com.ejweb.core.base.PageEntity;
import com.ejweb.modules.airport.bean.ExtraOilReasonBean; 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.bean.OilBatchUpdateBean;
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.OilAnalysisEntity; import com.ejweb.modules.airport.entity.OilAnalysisEntity;
...@@ -109,9 +110,9 @@ public class OilAnalysisService extends BaseService<OilAnalysisDao> { ...@@ -109,9 +110,9 @@ public class OilAnalysisService extends BaseService<OilAnalysisDao> {
} }
} }
oilAnalysisEntity.setPlanLeftOver(oilAnalysisEntity.getPlanLeftOver()); oilAnalysisEntity.setPlanLeftOver(oilAnalysisEntity.getPlanLeftOver());
System.out.println(oilAnalysisEntity.getAcTypeName()); // 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("");
...@@ -286,4 +287,9 @@ public class OilAnalysisService extends BaseService<OilAnalysisDao> { ...@@ -286,4 +287,9 @@ public class OilAnalysisService extends BaseService<OilAnalysisDao> {
public List<OilTargetEntity> findNowYearTarget() { public List<OilTargetEntity> findNowYearTarget() {
return oilAnalysisDao.selectNowYearTarget(); return oilAnalysisDao.selectNowYearTarget();
} }
public void updateRemarkAndConclusion(OilBatchUpdateBean bean) {
oilAnalysisDao.updateRemarkAndConclusion(bean,bean.getConclusion());
}
} }
...@@ -3,18 +3,24 @@ ...@@ -3,18 +3,24 @@
*/ */
package com.ejweb.modules.airport.service; package com.ejweb.modules.airport.service;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ejweb.core.api.ResponseBean;
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.core.exception.CommonException;
import com.ejweb.core.util.IdWorker;
import com.ejweb.modules.aircraft.dao.TypeDao;
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;
import com.ejweb.modules.airport.dao.StatisticalDao; import com.ejweb.modules.airport.dao.StatisticalDao;
import com.ejweb.modules.airport.entity.AirportInfoEntity; import com.ejweb.modules.airport.entity.AirportInfoEntity;
import com.ejweb.modules.airport.entity.StatisticalEntity; import com.ejweb.modules.airport.entity.StatisticalEntity;
import com.ejweb.modules.airport.entity.StatisticalImportEntity;
import com.ejweb.modules.airport.entity.StatisticalListEntity; import com.ejweb.modules.airport.entity.StatisticalListEntity;
import com.ejweb.modules.depart.dao.DepartDao;
import com.ejweb.modules.verify.bean.AirlineVerifiedAddBean; import com.ejweb.modules.verify.bean.AirlineVerifiedAddBean;
import com.ejweb.modules.verify.dao.AirlineVerifiedDao; import com.ejweb.modules.verify.dao.AirlineVerifiedDao;
import com.ejweb.modules.verify.dao.AirlineVerifyDao; import com.ejweb.modules.verify.dao.AirlineVerifyDao;
...@@ -27,6 +33,7 @@ import org.apache.commons.lang3.time.DateUtils; ...@@ -27,6 +33,7 @@ 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.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.text.ParseException; import java.text.ParseException;
...@@ -50,6 +57,11 @@ public class StatisticalService extends BaseService<StatisticalDao> { ...@@ -50,6 +57,11 @@ public class StatisticalService extends BaseService<StatisticalDao> {
@Autowired @Autowired
private StatisticalDao statisticalDao; private StatisticalDao statisticalDao;
@Autowired
private TypeDao typeDao;
@Autowired
private DepartDao departDao;
public PageEntity<StatisticalEntity> getStatisticalList(StatisticalBean bean) { public PageEntity<StatisticalEntity> getStatisticalList(StatisticalBean bean) {
//查询同一机场被屏蔽三字码数据(历史数据关联) //查询同一机场被屏蔽三字码数据(历史数据关联)
if (StringUtils.isNotEmpty(bean.getArrIata())) { if (StringUtils.isNotEmpty(bean.getArrIata())) {
...@@ -96,7 +108,7 @@ public class StatisticalService extends BaseService<StatisticalDao> { ...@@ -96,7 +108,7 @@ public class StatisticalService extends BaseService<StatisticalDao> {
if (StringUtils.isNotBlank(lastTime)) { if (StringUtils.isNotBlank(lastTime)) {
try { try {
Date date = DateUtils.addDays(DateUtils.parseDate(lastTime, "yyyy-MM-dd"), 180); Date date = DateUtils.addDays(DateUtils.parseDate(lastTime, "yyyy-MM-dd"), 180);
if (DateUtils.truncatedCompareTo(date,new Date(),Calendar.DATE)>0){ if (DateUtils.truncatedCompareTo(date, new Date(), Calendar.DATE) > 0) {
e.setRecentFlyStatus(true); e.setRecentFlyStatus(true);
} }
} catch (ParseException parseException) { } catch (ParseException parseException) {
...@@ -232,4 +244,92 @@ public class StatisticalService extends BaseService<StatisticalDao> { ...@@ -232,4 +244,92 @@ public class StatisticalService extends BaseService<StatisticalDao> {
} }
@Transactional(rollbackFor = Exception.class)
public void saveData(List<StatisticalImportEntity> list,String userCode) {
String departId = statisticalDao.getDepartIdByUserId(userCode);
StringBuilder errorMsg = new StringBuilder();
for (StatisticalImportEntity entity : list) {
try {
if (StringUtils.isBlank(entity.getVerifNo())) {
errorMsg.append(entity.getFlightNo()).append("论证单号不能为空");
throw new CommonException(errorMsg.toString());
}
if (StringUtils.isBlank(entity.getAcType())) {
errorMsg.append(entity.getFlightNo()).append("论证机型不能为空");
throw new CommonException(errorMsg.toString());
}
if (StringUtils.isBlank(entity.getDepIata())) {
errorMsg.append(entity.getFlightNo()).append("起飞地三字码不能为空");
throw new CommonException(errorMsg.toString());
}
if (StringUtils.isBlank(entity.getArrIata())) {
errorMsg.append(entity.getFlightNo()).append("到达地三字码不能为空");
throw new CommonException(errorMsg.toString());
}
String state = "";
if (StringUtils.equalsIgnoreCase(entity.getStateStr(), "正常")) {
state = "0";
} else if (StringUtils.equalsIgnoreCase(entity.getStateStr(), "失效")) {
state = "1";
} else if (StringUtils.equalsIgnoreCase(entity.getStateStr(), "重开")) {
state = "2";
}
if (StringUtils.isBlank(state)) {
errorMsg.append(entity.getFlightNo()).append("失效状态不正确");
throw new CommonException(errorMsg.toString());
} else {
entity.setState(state);
}
String verifType = "";
if (StringUtils.equalsIgnoreCase(entity.getVerifTypeStr().trim(), "新开-国内")) {
verifType = "01";
} else if (StringUtils.equalsIgnoreCase(entity.getVerifTypeStr().trim(), "新开-国际")) {
verifType = "02";
} else if (StringUtils.equalsIgnoreCase(entity.getVerifTypeStr().trim(), "重开-国内")) {
verifType = "03";
} else if (StringUtils.equalsIgnoreCase(entity.getVerifTypeStr().trim(), "重开-国际")) {
verifType = "04";
} else if (StringUtils.equalsIgnoreCase(entity.getVerifTypeStr().trim(), " 调机")) {
verifType = "05";
}else if (StringUtils.equalsIgnoreCase(entity.getVerifTypeStr().trim(), "备降场")) {
verifType = "06";
} else if (StringUtils.equalsIgnoreCase(entity.getVerifTypeStr().trim(), "过夜")) {
verifType = "07";
} else if (StringUtils.equalsIgnoreCase(entity.getVerifTypeStr().trim(), "训练场")) {
verifType = "08";
} else if (StringUtils.equalsIgnoreCase(entity.getVerifTypeStr().trim(), "计划变更")) {
verifType = "09";
} else if (StringUtils.equalsIgnoreCase(entity.getVerifTypeStr().trim(), "新开-国内货运")) {
verifType = "10";
}else if (StringUtils.equalsIgnoreCase(entity.getVerifTypeStr().trim(), "新开-国际货运")) {
verifType = "11";
}
if (StringUtils.isBlank(verifType)) {
errorMsg.append(entity.getFlightNo()).append("论证类型不正确");
throw new CommonException(errorMsg.toString());
} else {
entity.setVerifType(verifType);
}
String acTypeId = statisticalDao.findIdByAcType(entity.getAcType());
if(StringUtils.isBlank(acTypeId)){
errorMsg.append(entity.getFlightNo()).append("论证机型不正确");
throw new CommonException(errorMsg.toString());
}
String verifyId = IdWorker.getNextId();
Integer count = statisticalDao.findVerifyByVerifyNoAndRouteNo(entity.getVerifNo(), entity.getRouteNo());
if (count>0) {
errorMsg.append(entity.getFlightNo()).append("论证单号:").append(entity.getVerifNo()).append("或")
.append("开航指令号:").append(entity.getRouteNo()).append("已存在!");
throw new CommonException(errorMsg.toString());
}
statisticalDao.insertAirlineVerify(verifyId,entity.getVerifNo(),entity.getVerifType(),departId,acTypeId,userCode,
entity.getDepIata(),entity.getArrIata(), entity.getRouteNo(), entity.getState());
statisticalDao.insertAirlineConnect(IdWorker.getNextId(),IdWorker.getNextId(),verifyId,entity.getDepIata(),entity.getArrIata());
statisticalDao.insertAirlineVerifyType(IdWorker.getNextId(),verifyId,acTypeId,userCode);
} catch (Exception e) {
throw new CommonException(e.getMessage());
}
}
}
} }
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
*/ */
package com.ejweb.modules.call.util; package com.ejweb.modules.call.util;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
...@@ -13,10 +17,9 @@ import com.ejweb.core.fetcher.FetchEntity; ...@@ -13,10 +17,9 @@ import com.ejweb.core.fetcher.FetchEntity;
import com.ejweb.core.fetcher.HCFetcher; import com.ejweb.core.fetcher.HCFetcher;
/** /**
*
* @team IT Team
* @author renmb * @author renmb
* @version 1.0 * @version 1.0
* @team IT Team
* @time 2016年10月30日 * @time 2016年10月30日
*/ */
public class PhoneAreaUtil { public class PhoneAreaUtil {
...@@ -24,30 +27,42 @@ public class PhoneAreaUtil { ...@@ -24,30 +27,42 @@ public class PhoneAreaUtil {
/** /**
* 360安全卫士提供的手机号归属地查询接口 * 360安全卫士提供的手机号归属地查询接口
* *
* @author renmb
* @time 2016年10月30日
* @param phone * @param phone
* @return * @return
* @author renmb
* @time 2016年10月30日
*/ */
public static PhoneAreaEntity get360PhoneArea(String mobile){ public static PhoneAreaEntity get360PhoneArea(String mobile) {
try { try {
if(StringUtils.isBlank(mobile)) if (StringUtils.isBlank(mobile))
return null; return null;
HCFetcher fetcher = HCFetcher.getInstance(); // HCFetcher fetcher = HCFetcher.getInstance();
FetchEntity entity = fetcher.get(GConstants.getValue("cx.shouji.360.cn", "http://cx.shouji.360.cn/phonearea.php")+"?number="+mobile); // FetchEntity entity = fetcher.get(GConstants.getValue("cx.shouji.360.cn", "http://cx.shouji.360.cn/phonearea.php") + "?number=" + mobile);
if(entity != null && entity.isSuccess()){ // JSONObject jsonObject = JSONObject.parseObject(s);
// JSONObject data = jsonObject.getJSONObject("data");
String txt = entity.getContent("UTF-8"); // System.out.println(data.getString("province"));
JSONObject object = JSON.parseObject(txt); // if(entity != null && entity.isSuccess()){
JSONObject data = object.getJSONObject("data"); //
// String txt = entity.getContent("UTF-8");
if(StringUtils.isNotBlank(data.getString("province"))){ // JSONObject object = JSON.parseObject(txt);
// JSONObject data = object.getJSONObject("data");
//
//
// }
String url = GConstants.getValue("cx.shouji.360.cn", "http://cx.shouji.360.cn/phonearea.php") + "?number=" + mobile;
url ="http://cx.shouji.360.cn/phonearea.php?number="+ mobile;
HttpRequest request = HttpUtil.createGet(url);
request.setConnectionTimeout(20);
HttpResponse execute = request.execute();
JSONObject jsonObject = JSONObject.parseObject(execute.body());
JSONObject data = jsonObject.getJSONObject("data");
if (ObjUtil.isNotNull(data)) {
String province = data.getString("province");
if (StringUtils.isNotBlank(province)) {
PhoneAreaEntity area = new PhoneAreaEntity(); PhoneAreaEntity area = new PhoneAreaEntity();
area.setProvince(data.getString("province")); area.setProvince(province);
area.setCity(data.getString("city")); area.setCity(data.getString("city"));
area.setSp(data.getString("sp")); area.setSp(data.getString("sp"));
return area; return area;
} }
} }
...@@ -57,23 +72,31 @@ public class PhoneAreaUtil { ...@@ -57,23 +72,31 @@ public class PhoneAreaUtil {
return null; return null;
} }
public static void main(String[] args) {
String url = "http://cx.shouji.360.cn/phonearea.php?number=15995791570";
String s = HttpUtil.get(url);
JSONObject jsonObject = JSONObject.parseObject(s);
JSONObject data = jsonObject.getJSONObject("data");
PhoneAreaEntity phoneArea = PhoneAreaUtil.get360PhoneArea("15995791570");
}
/** /**
* 百度号码认证平台提供 * 百度号码认证平台提供
* * <p>
* http://haoma.baidu.com/ * http://haoma.baidu.com/
* *
* @author renmb
* @time 2017年3月3日
* @param mobile * @param mobile
* @return * @return
* @author renmb
* @time 2017年3月3日
*/ */
public static PhoneAreaEntity getBaiduPhoneArea(String mobile){ public static PhoneAreaEntity getBaiduPhoneArea(String mobile) {
try { try {
if(StringUtils.isBlank(mobile)) if (StringUtils.isBlank(mobile))
return null; return null;
HCFetcher fetcher = HCFetcher.getInstance(); HCFetcher fetcher = HCFetcher.getInstance();
FetchEntity entity = fetcher.get(GConstants.getValue("sp0.baidu.com", "https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv")+"/api.php?query="+mobile+"&co=&resource_id=6004&t="+System.currentTimeMillis()+"&ie=utf8&oe=gbk&cb=&format=json&tn=baidu&cb=&_="+System.currentTimeMillis()); FetchEntity entity = fetcher.get(GConstants.getValue("sp0.baidu.com", "https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv") + "/api.php?query=" + mobile + "&co=&resource_id=6004&t=" + System.currentTimeMillis() + "&ie=utf8&oe=gbk&cb=&format=json&tn=baidu&cb=&_=" + System.currentTimeMillis());
if(entity != null && entity.isSuccess()){ if (entity != null && entity.isSuccess()) {
String txt = entity.getContent("gbk"); String txt = entity.getContent("gbk");
// if(GConstants.DEBUG){ // if(GConstants.DEBUG){
...@@ -83,9 +106,9 @@ public class PhoneAreaUtil { ...@@ -83,9 +106,9 @@ public class PhoneAreaUtil {
// } // }
JSONObject object = JSON.parseObject(txt); JSONObject object = JSON.parseObject(txt);
JSONArray data = object.getJSONArray("data"); JSONArray data = object.getJSONArray("data");
if(data != null && data.size()>0){ if (data != null && data.size() > 0) {
JSONObject row = data.getJSONObject(0); JSONObject row = data.getJSONObject(0);
if(StringUtils.isNotEmpty(row.getString("prov"))){ if (StringUtils.isNotEmpty(row.getString("prov"))) {
PhoneAreaEntity area = new PhoneAreaEntity(); PhoneAreaEntity area = new PhoneAreaEntity();
area.setProvince(row.getString("prov")); area.setProvince(row.getString("prov"));
...@@ -103,6 +126,7 @@ public class PhoneAreaUtil { ...@@ -103,6 +126,7 @@ public class PhoneAreaUtil {
} }
// public static void main(String[] args){ // public static void main(String[] args){
// String mobile = "13357826763"; // String mobile = "13357826763";
// String s = "https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv" + "/api.php?query=" + mobile + "&co=&resource_id=6004&t=" + System.currentTimeMillis() + "&ie=utf8&oe=gbk&cb=&format=json&tn=baidu&cb=&_=" + System.currentTimeMillis();
// PhoneAreaEntity area = PhoneAreaUtil.getBaiduPhoneArea(mobile); // PhoneAreaEntity area = PhoneAreaUtil.getBaiduPhoneArea(mobile);
// System.out.println(JSON.toJSONString(area)); // System.out.println(JSON.toJSONString(area));
// PhoneAreaEntity area360 = PhoneAreaUtil.get360PhoneArea(mobile); // PhoneAreaEntity area360 = PhoneAreaUtil.get360PhoneArea(mobile);
......
...@@ -22,5 +22,5 @@ public interface DepartDao extends BaseDao{ ...@@ -22,5 +22,5 @@ public interface DepartDao extends BaseDao{
public List<DepartEntity> findDepartByList(@Param(value="type") String type, @Param(value = "isVerif") String isVerif); public List<DepartEntity> findDepartByList(@Param(value="type") String type, @Param(value = "isVerif") String isVerif);
public List<DepartTypeEntity> findDepartAllList(); public List<DepartTypeEntity> findDepartAllList();
public String getDepartIdByUserId(@Param("userId") String userId); String getDepartIdByUserId(@Param("userId") String userCode);
} }
\ No newline at end of file
...@@ -38,6 +38,27 @@ public class FlightCrewListEntity extends BaseEntity { ...@@ -38,6 +38,27 @@ public class FlightCrewListEntity extends BaseEntity {
private int huaweiStatus;// 华为绑定状态: 0 位绑定 1 已绑定 private int huaweiStatus;// 华为绑定状态: 0 位绑定 1 已绑定
private Integer state=0; // 用户UC在线状态 private Integer state=0; // 用户UC在线状态
public FlightCrewListEntity() {
}
public FlightCrewListEntity(String rankSd, String crewTypeId, String staffId, String staffName, String photo
, String phone, String mobile, String companyName, String officeName, String sector, String sectorNick
, int huaweiStatus, Integer state) {
this.rankSd = rankSd;
this.crewTypeId = crewTypeId;
this.staffId = staffId;
this.staffName = staffName;
this.photo = photo;
this.phone = phone;
this.mobile = mobile;
this.companyName = companyName;
this.officeName = officeName;
this.sector = sector;
this.sectorNick = sectorNick;
this.huaweiStatus = huaweiStatus;
this.state = state;
}
public String getRankSd() { public String getRankSd() {
return rankSd; return rankSd;
} }
......
...@@ -145,4 +145,64 @@ public class AirCarrierService extends BaseService<AirCarrierDao> { ...@@ -145,4 +145,64 @@ public class AirCarrierService extends BaseService<AirCarrierDao> {
} }
return null; return null;
} }
public static void main(String[] args) {
List<FlightCrewListEntity> crewList =new ArrayList<>();
crewList.add(new FlightCrewListEntity("乘务员","2","1000067632","彭琼斯","images/user/avatar/female_avatar.png","01064506313"
,"18675877423","北京首都航空有限公司","海口乘务二中队","LYI-KWL","沂-桂",0,0));
// 乘务员 1000067632 彭琼斯 2 LYI-KWL 沂-桂 images/user/avatar/female_avatar.png 01064506313 18675877423 北京首都航空有限公司 海口乘务二中队 0
// 机长 1000074230 周鹏 1 LYI-KWL 沂-桂 images/user/avatar/male_avatar.png 18689972723 北京首都航空有限公司 海口一中队 0
// 乘务长 1000126503 李姗珊 2 LYI-KWL 沂-桂 images/user/avatar/female_avatar.png 13639330824 北京首都航空有限公司 海口乘务一中队 0
// 一副 1000141665 黄万林 1 LYI-KWL 沂-桂 images/user/avatar/male_avatar.png 18671707572 北京首都航空有限公司 海口一中队 0
// 两舱乘务员 1000801882 马明月 2 LYI-KWL 沂-桂 images/user/avatar/female_avatar.png 01069615030 18308903665 北京首都航空有限公司 海口乘务三中队 0
// 见习乘务员 1000942813 于沛 2 LYI-KWL 沂-桂 images/user/avatar/female_avatar.png 18661962106 北京首都航空有限公司 青岛乘务三中队 0
// 安全员 1000954218 王浩宇6 2 LYI-KWL 沂-桂 images/user/avatar/male_avatar.png 18742145675 北京首都航空有限公司 安全员海口中队 0
// 二副 1001006416 娄元昊 1 LYI-KWL 沂-桂 images/user/avatar/male_avatar.png 17709096291 北京首都航空有限公司 海口一中队 0
if(crewList != null && crewList.size() != 0){
Map<String, List<FlightCrewListEntity>> items = new HashMap<String, List<FlightCrewListEntity>>();
List<String> names = new ArrayList<String>();
names.add("飞行员");
names.add("乘务员");
names.add("安全员");
// 1飞行员,2乘务员,3安全员,4空警
Map<String, String> crews = new HashMap<String, String>();
crews.put("1", "飞行员");
crews.put("2", "乘务员");
crews.put("3", "安全员");
crews.put("4", "安全员");
// crews.put("其他人员", "其他人员");
for(FlightCrewListEntity crewListEntity:crewList){
String key = crews.get(crewListEntity.getCrewTypeId());
if(StringUtils.isBlank(key)){// 人员分组判断
continue ;
// key = "其他人员";
}
// System.out.println(key+"=>"+crewListEntity.getCrewTypeId());
crewListEntity.setPhoto(Util.getAbsoluteUrl(crewListEntity.getPhoto()));// 设置用户头像
List<FlightCrewListEntity> item = items.get(key);
if(item == null){// 如果还不存在则添加一个分组列表
item = new ArrayList<FlightCrewListEntity>();
item.add(crewListEntity);
items.put(key, item);
} else {
item.add(crewListEntity);
}
}
// 组装用户分组
List<FlightCrewGroupEntity> crewGroupList = new ArrayList<FlightCrewGroupEntity>();
for(String key:names){
FlightCrewGroupEntity crewGroup = new FlightCrewGroupEntity();
crewGroup.setName(key);
crewGroup.setList(items.get(crewGroup.getName()));
crewGroupList.add(crewGroup);
}
System.out.println(crewGroupList);
}
}
} }
...@@ -146,19 +146,22 @@ public class FlightService extends BaseService<FlightDao> { ...@@ -146,19 +146,22 @@ public class FlightService extends BaseService<FlightDao> {
HuaweiUserStatInfoBean huaweiUserStatInfoBean = new HuaweiUserStatInfoBean(); HuaweiUserStatInfoBean huaweiUserStatInfoBean = new HuaweiUserStatInfoBean();
huaweiUserStatInfoBean.setQueryUsers(userIds); huaweiUserStatInfoBean.setQueryUsers(userIds);
List<HuaweiUserStatEntity> huaweiUserStatEntities = huaweiInterfaseService.presence(huaweiUserStatInfoBean); List<HuaweiUserStatEntity> huaweiUserStatEntities = huaweiInterfaseService.presence(huaweiUserStatInfoBean);
if (huaweiUserStatEntities != null && huaweiUserStatEntities.size() > 0) { // if (huaweiUserStatEntities != null && huaweiUserStatEntities.size() > 0) {
for (HuaweiUserStatEntity statEntityTmp : huaweiUserStatEntities) { // for (HuaweiUserStatEntity statEntityTmp : huaweiUserStatEntities) {
for (FlightCrewListEntity crewListEntity : crewList) { for (FlightCrewListEntity crewListEntity : crewList) {
crewListEntity.setState(0);
crewListEntity.setState(Util.parseInt(statEntityTmp.getNewState(), 0));
}
}
} }
// }
// }
} }
} }
return dao.getFlightCrewList(bean); return dao.getFlightCrewList(bean);
} }
public static void main(String[] args) {
}
/** /**
* 处理航班的机组人员,对机组人员进行分组展示 * 处理航班的机组人员,对机组人员进行分组展示
* *
......
...@@ -6,6 +6,7 @@ import com.ejweb.core.api.RequestBean; ...@@ -6,6 +6,7 @@ import com.ejweb.core.api.RequestBean;
import com.ejweb.core.api.ResponseBean; import com.ejweb.core.api.ResponseBean;
import com.ejweb.core.conf.ErrorCode; import com.ejweb.core.conf.ErrorCode;
import com.ejweb.core.conf.GConstants; import com.ejweb.core.conf.GConstants;
import com.ejweb.core.exception.CommonException;
import com.ejweb.core.fetcher.FetchEntity; import com.ejweb.core.fetcher.FetchEntity;
import com.ejweb.core.fetcher.HCFetcher; import com.ejweb.core.fetcher.HCFetcher;
import com.ejweb.core.util.IdWorker; import com.ejweb.core.util.IdWorker;
...@@ -33,6 +34,7 @@ import org.springframework.util.CollectionUtils; ...@@ -33,6 +34,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.subethamail.smtp.server.CommandException;
import sun.misc.BASE64Decoder; import sun.misc.BASE64Decoder;
import javax.crypto.Cipher; import javax.crypto.Cipher;
......
...@@ -10,6 +10,7 @@ import com.ejweb.core.fetcher.FetchEntity; ...@@ -10,6 +10,7 @@ import com.ejweb.core.fetcher.FetchEntity;
import com.ejweb.core.fetcher.HCFetcher; import com.ejweb.core.fetcher.HCFetcher;
import com.ejweb.core.util.IdWorker; import com.ejweb.core.util.IdWorker;
import com.ejweb.core.util.Util; import com.ejweb.core.util.Util;
import com.ejweb.core.util.VerifyEmailHandler;
import com.ejweb.modules.im.bean.ImUserListBean; import com.ejweb.modules.im.bean.ImUserListBean;
import com.ejweb.modules.im.bean.OfficeBean; import com.ejweb.modules.im.bean.OfficeBean;
import com.ejweb.modules.im.bean.SearchUserBean; import com.ejweb.modules.im.bean.SearchUserBean;
...@@ -17,17 +18,20 @@ import com.ejweb.modules.im.entity.UserSeatListEntity; ...@@ -17,17 +18,20 @@ import com.ejweb.modules.im.entity.UserSeatListEntity;
import com.ejweb.modules.user.bean.*; import com.ejweb.modules.user.bean.*;
import com.ejweb.modules.user.dao.UserDao; import com.ejweb.modules.user.dao.UserDao;
import com.ejweb.modules.user.entity.*; import com.ejweb.modules.user.entity.*;
import com.ejweb.modules.verify.dao.AirlineVerifyDao;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.jdair.util.http.client.HTTPClientUtil; import com.jdair.util.http.client.HTTPClientUtil;
import com.jdair.util.security.DESPlus; import com.jdair.util.security.DESPlus;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -40,6 +44,9 @@ public class UserService extends CurdService<UserDao, UserEntity> { ...@@ -40,6 +44,9 @@ public class UserService extends CurdService<UserDao, UserEntity> {
public static final int HASH_INTERATIONS = 1024; public static final int HASH_INTERATIONS = 1024;
public static final int SALT_SIZE = 8; public static final int SALT_SIZE = 8;
@Autowired
AirlineVerifyDao verifyDao;
/** /**
* 通过CODE获取用户ID * 通过CODE获取用户ID
* *
...@@ -355,11 +362,33 @@ public class UserService extends CurdService<UserDao, UserEntity> { ...@@ -355,11 +362,33 @@ public class UserService extends CurdService<UserDao, UserEntity> {
LOG.info("[UserService login][validateServerPassword][URL]:" + buf.toString()); LOG.info("[UserService login][validateServerPassword][URL]:" + buf.toString());
HCFetcher fetcher = HCFetcher.getInstance(); HCFetcher fetcher = HCFetcher.getInstance();
FetchEntity entity = fetcher.get(buf.toString()); FetchEntity entity = null;
try {
LOG.info("第一次调用开始");
entity=fetcher.get(buf.toString());
// 再次重新尝试获取内容 // 再次重新尝试获取内容
if (entity == null) { if (entity == null||entity.getStatus()!=200) {
LOG.error("第一次调用失败!");
entity = fetcher.get(buf.toString()); throw new Exception();
}
}catch(Exception ex){
try {
String replace = StringUtils.replace(buf.toString(), "https://dsp.jdair.net", "https://dsp2.jdair.net");
LOG.info("第二次调用开始,地址:"+replace);
entity=fetcher.get(replace);
if (entity == null||entity.getStatus()!=200) {
LOG.error("第二次调用失败!");
throw new Exception();
}
}catch (Exception ex1){
try{
LOG.info("调用登录2次都失败!发送邮件!");
VerifyEmailHandler instance = VerifyEmailHandler.getInstance();
instance.sendEmail("登录异常","首航系统2次调用登录失败!",null, Arrays.asList("chl.zhou@hnair.com","695220370@qq.com"));
}catch (Exception ex2){
ex.printStackTrace();
}
}
} }
if (entity != null) { if (entity != null) {
String text = entity.getContent("UTF-8"); String text = entity.getContent("UTF-8");
......
...@@ -300,7 +300,8 @@ public class AirlineVerifyService extends BaseService<AirlineVerifyDao> { ...@@ -300,7 +300,8 @@ public class AirlineVerifyService extends BaseService<AirlineVerifyDao> {
case "02": case "02":
case "03": case "03":
case "04": case "04":
case "09": { case "09":
case "11":{
List<Connect> connects = new ArrayList<>(); List<Connect> connects = new ArrayList<>();
Connect connect = new Connect(); Connect connect = new Connect();
connect.setId(IdWorker.getNextId()); connect.setId(IdWorker.getNextId());
......
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