Commit 7aa564ba by java-李谡

修复个别安全隐患

parent 6923b82a
package com.ejweb.core.util;
import java.awt.AlphaComposite;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import com.ejweb.core.conf.GConstants;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGEncodeParam;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import org.apache.commons.lang3.StringUtils;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.geom.RoundRectangle2D;
import java.awt.image.AffineTransformOp;
......@@ -17,26 +18,15 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
import org.apache.commons.lang3.StringUtils;
import com.ejweb.core.conf.GConstants;
import com.ejweb.core.util.FileManipulation;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGEncodeParam;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
/**
* 图片处理工具类
*
* <p>
* 来源 http://www.2cto.com/weixin/201503/382943.html
*
* @team IT Team
* @author renmb
* @version 1.0
* @time 2016年10月5日
*
* @team IT Team
* @time 2016年10月5日
*/
public final class ImageUtil {
......@@ -49,9 +39,9 @@ public final class ImageUtil {
public static String combineHighQuality(List<String> paths) {
try {
if(paths != null && paths.size() == 1){
if(StringUtils.isNotEmpty(paths.get(0))){
if (paths != null && paths.size() == 1) {
if (StringUtils.isNotEmpty(paths.get(0))) {
return paths.get(0).replace(GConstants.FILE_UPLOAD_DIR, "");
}
}
......@@ -117,18 +107,18 @@ public final class ImageUtil {
}
String baseDatePath = PathFormatUtils.parse(PATH_FORMAt)+ GConstants.FS + "group" + GConstants.FS;
String baseDatePath = PathFormatUtils.parse(PATH_FORMAt) + GConstants.FS + "group" + GConstants.FS;
// 验证文件安全
baseDatePath= FileManipulation.validateFile(baseDatePath);
File baseUploadDir = new File(GConstants.FILE_UPLOAD_DIR, baseDatePath);
baseDatePath = FileManipulation.validateFile(baseDatePath);
File baseUploadDir = new File(GConstants.FILE_UPLOAD_DIR, baseDatePath);
if (!baseUploadDir.exists()) {// 如果文件夹不存在则创建
baseUploadDir.mkdirs();
}
String fileName = IdWorker.getNextId()+"."+PNG;
String fileName = IdWorker.getNextId() + "." + PNG;
String fullFileName = baseUploadDir + GConstants.FS + fileName;
// File uploadFilePath = new File(baseUploadDir, fileName);
writeHighQuality(outImage, fullFileName);
return baseDatePath+fileName;
return baseDatePath + fileName;
} catch (Exception e) {
e.printStackTrace();
}
......@@ -142,10 +132,10 @@ public final class ImageUtil {
try {
// 验证文件安全
src= FileManipulation.validateFile(src);
src = FileManipulation.validateFile(src);
File srcfile = new File(src);
if (!srcfile.exists()) {
srcfile = new File(GConstants.FILE_UPLOAD_DIR+src);
srcfile = new File(GConstants.FILE_UPLOAD_DIR + src);
if (!srcfile.exists()) {
// System.out.println("文件不存在");
return null;
......@@ -181,56 +171,58 @@ public final class ImageUtil {
try {
// 验证文件安全
FileManipulation.validateFile(fileFullPath);
/*输出到文件流*/
/*输出到文件流*/
FileOutputStream newimage = new FileOutputStream(fileFullPath);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(newimage);
JPEGEncodeParam jep = JPEGCodec.getDefaultJPEGEncodeParam(im);
/* 压缩质量 */
/* 压缩质量 */
jep.setQuality(0.9f, true);
encoder.encode(im, jep);
/*近JPEG编码*/
/*近JPEG编码*/
newimage.close();
return true;
} catch (Exception e) {
return false;
}
}
/******** 新版生成头像end ********/
private static final String PNG = "png";
private static final String PATH_FORMAt = GConstants.getValue("file.path.format", "{yyyy}{mm}{dd}");
/**
* 生成组合头像,目前最多支持4张图片
*
* @author renmb
* @time 2016年10月5日
* @param paths 相对路径或者觉得路径均可
* @return
* @author renmb
* @time 2016年10月5日
*/
public static String combine(List<String> paths){
public static String combine(List<String> paths) {
try {
if(paths == null || paths.size() == 0)
if (paths == null || paths.size() == 0)
return null;
List<BufferedImage> bufferedImages = new ArrayList<BufferedImage>();
// 压缩图片所有的图片生成尺寸同意的 为 50x50
int size = paths.size();// > 4 ? 4 : paths.size();
List<String> realPaths = new ArrayList<String>(4);
for (int i = 0, j=0; i < size && j<4; i++) {
for (int i = 0, j = 0; i < size && j < 4; i++) {
// 验证文件安全
String path=FileManipulation.validateFile(paths.get(i));
String path = FileManipulation.validateFile(paths.get(i));
File f = new File(path);
if(f.exists()){
if (f.exists()) {
j++;
bufferedImages.add(ImageUtil.resize(paths.get(i), 100, 100, true));
realPaths.add(paths.get(i));
} else {
f = new File(GConstants.FILE_UPLOAD_DIR+paths.get(i));
if(f.exists()){
f = new File(GConstants.FILE_UPLOAD_DIR + paths.get(i));
if (f.exists()) {
j++;
realPaths.add(GConstants.FILE_UPLOAD_DIR+paths.get(i));
bufferedImages.add(ImageUtil.resize(GConstants.FILE_UPLOAD_DIR+paths.get(i), 100, 100, true));
realPaths.add(GConstants.FILE_UPLOAD_DIR + paths.get(i));
bufferedImages.add(ImageUtil.resize(GConstants.FILE_UPLOAD_DIR + paths.get(i), 100, 100, true));
}
}
}
......@@ -238,7 +230,7 @@ public final class ImageUtil {
int height = 112; // 这是画板的高度
// BufferedImage.TYPE_INT_RGB可以自己定义可查看API
BufferedImage outImage = null;
if(realPaths.size() == 1){// 只有一个图片
if (realPaths.size() == 1) {// 只有一个图片
BufferedImage imageSrc = ImageUtil.resize(realPaths.get(0), 100, 100, true);
......@@ -259,7 +251,7 @@ public final class ImageUtil {
// ImageUtil.setClip(outImage, 20);
g2d.drawImage(imageSrc, 6, 6, null);
} else{
} else {
outImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
// 生成画布
Graphics g = outImage.getGraphics();
......@@ -303,18 +295,18 @@ public final class ImageUtil {
}
}
String baseDatePath = PathFormatUtils.parse(PATH_FORMAt)+ GConstants.FS + "group" + GConstants.FS;
File baseUploadDir = new File(GConstants.FILE_UPLOAD_DIR, baseDatePath);
String baseDatePath = PathFormatUtils.parse(PATH_FORMAt) + GConstants.FS + "group" + GConstants.FS;
File baseUploadDir = new File(GConstants.FILE_UPLOAD_DIR, baseDatePath);
if (!baseUploadDir.exists()) {// 如果文件夹不存在则创建
baseUploadDir.mkdirs();
}
String fileName = IdWorker.getNextId()+"."+PNG;
String fileName = IdWorker.getNextId() + "." + PNG;
File uploadFilePath = new File(baseUploadDir, fileName);
// System.out.println(uploadFilePath.getAbsolutePath());
ImageIO.write(outImage, PNG.toUpperCase(), uploadFilePath);
return baseDatePath+fileName;
return baseDatePath + fileName;
} catch (Exception e) {
// TODO: handle exception
}
......@@ -325,9 +317,9 @@ public final class ImageUtil {
* 图片缩放
*
* @param filePath 图片路径
* @param height 高度
* @param width 宽度
* @param bb 比例不对时是否需要补白
* @param height 高度
* @param width 宽度
* @param bb 比例不对时是否需要补白
*/
public static BufferedImage resize(String filePath, int height, int width, boolean bb) {
try {
......@@ -365,32 +357,34 @@ public final class ImageUtil {
}
return null;
}
/**
* 图片设置圆角
*
* @author renmb
* @time 2016年10月7日
* @param srcImage
* @return
* @throws IOException
* @author renmb
* @time 2016年10月7日
*/
public static BufferedImage setRadius(BufferedImage srcImage) throws IOException{
public static BufferedImage setRadius(BufferedImage srcImage) throws IOException {
int radius = (srcImage.getWidth() + srcImage.getHeight()) / 6;
return setRadius(srcImage, radius, 2, 5);
}
/**
* 图片设置圆角
*
* @author renmb
* @time 2016年10月7日
* @param srcImage
* @param radius
* @param border
* @param padding
* @return
* @throws IOException
* @author renmb
* @time 2016年10月7日
*/
public static BufferedImage setRadius(BufferedImage srcImage, int radius, int border, int padding) throws IOException{
public static BufferedImage setRadius(BufferedImage srcImage, int radius, int border, int padding) throws IOException {
int width = srcImage.getWidth();
int height = srcImage.getHeight();
int canvasWidth = width + padding * 2;
......@@ -404,7 +398,7 @@ public final class ImageUtil {
gs.fill(new RoundRectangle2D.Float(0, 0, canvasWidth, canvasHeight, radius, radius));
gs.setComposite(AlphaComposite.SrcAtop);
gs.drawImage(setClip(srcImage, radius), padding, padding, null);
if(border !=0){
if (border != 0) {
gs.setColor(Color.GRAY);
gs.setStroke(new BasicStroke(border));
gs.drawRoundRect(padding, padding, canvasWidth - 2 * padding, canvasHeight - 2 * padding, radius, radius);
......@@ -412,17 +406,18 @@ public final class ImageUtil {
gs.dispose();
return image;
}
/**
* 图片切圆角
* http://www.cnblogs.com/rubekid/p/4047259.html
*
* @author renmb
* @time 2016年10月7日
* @param srcImage
* @param radius
* @return
* @author renmb
* @time 2016年10月7日
*/
public static BufferedImage setClip(BufferedImage srcImage, int radius){
public static BufferedImage setClip(BufferedImage srcImage, int radius) {
int width = srcImage.getWidth();
int height = srcImage.getHeight();
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
......@@ -434,14 +429,4 @@ public final class ImageUtil {
gs.dispose();
return image;
}
public static void main(String[] args){
List<String> list = new ArrayList<String>();
list.add("C:\\Users\\owner\\Desktop\\female_avatar.png");
// list.add("C:\\Users\\owner\\Desktop\\male_avatar.png");
// list.add("C:\\Users\\owner\\Desktop\\female_avatar.png");
// list.add("C:\\Users\\owner\\Desktop\\male_avatar.png");
String fileName = ImageUtil.combine(list);
System.out.println(fileName);
}
}
\ No newline at end of file
package com.ejweb.core.util;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TimeZone;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ejweb.core.conf.ErrorCode;
import com.ejweb.core.conf.GConstants;
import com.ejweb.core.fetcher.FetchEntity;
import com.ejweb.core.fetcher.HCFetcher;
import com.ejweb.core.fetcher.HttpClientUtil;
import com.ejweb.core.security.Digests;
import com.ejweb.core.security.GlobalUtil;
import com.ejweb.modules.call.util.PhoneAreaEntity;
import com.ejweb.modules.call.util.PhoneAreaUtil;
import com.ejweb.modules.im.entity.GroupEntity;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.*;
public class Util {
public static String phoneNumberFormat(String phone){
if(phone == null)
return null;
public static String phoneNumberFormat(String phone) {
if (phone == null)
return null;
int len = phone.length();
if(len>=8){
if (len >= 8) {
// return phone.replaceAll("(\\d{3})\\d{4}(\\d+)","$1****$2");// 正则匹配
return phone.substring(0, 3)+"****"+phone.substring(7,len);// 字符串拼接
return phone.substring(0, 3) + "****" + phone.substring(7, len);// 字符串拼接
}
return phone;
return phone;
}
/**
* 根据已经格式化过后的手机或者座机号显示长号
*
* @author renmb
* @time 2017年3月24日
*
* @param phone
* @return
* @author renmb
* @time 2017年3月24日
*/
public static String getShowPhone(String phone){
if(StringUtils.isEmpty(phone))// 未知
public static String getShowPhone(String phone) {
if (StringUtils.isEmpty(phone))// 未知
return "";
if(phone.startsWith("1") && phone.length() == 11)// 手机号
if (phone.startsWith("1") && phone.length() == 11)// 手机号
return phone;
if(phone.startsWith("01") && phone.length() == 12)// 手机号
if (phone.startsWith("01") && phone.length() == 12)// 手机号
return phone.substring(1);
if(phone.startsWith("001") && phone.length() == 13)// 手机号
if (phone.startsWith("001") && phone.length() == 13)// 手机号
return phone.substring(2);
if(phone.startsWith("5") && phone.length() == 4)// 座机号
return "6961"+phone;
if (phone.startsWith("5") && phone.length() == 4)// 座机号
return "6961" + phone;
return phone;// 座机
}
/**
* 获取电话类型
*
* @author renmb
* @time 2017年3月19日
*
* @param phone
* @return
* @author renmb
* @time 2017年3月19日
*/
public static String getPhoneType(String phone){
if(StringUtils.isEmpty(phone))// 未知
public static String getPhoneType(String phone) {
if (StringUtils.isEmpty(phone))// 未知
return "UNKNOWN";
if(phone.startsWith("1") && phone.length() == 11)// 手机号
if (phone.startsWith("1") && phone.length() == 11)// 手机号
return "MOBILE";
if(phone.startsWith("01") && phone.length() == 12)// 手机号
if (phone.startsWith("01") && phone.length() == 12)// 手机号
return "MOBILE";
if(phone.startsWith("001") && phone.length() == 13)// 手机号
if (phone.startsWith("001") && phone.length() == 13)// 手机号
return "MOBILE";
if(phone.startsWith("6") && phone.length() == 4)// 华为短号
if (phone.startsWith("6") && phone.length() == 4)// 华为短号
return "HWNUBMER";
return "PHONE";// 座机
}
/**
* 更新群的用户头像和用户数量
*
* @author renmb
* @time 2017年3月19日
*
* @param groupId
* @param userCode
* @return
* @author renmb
* @time 2017年3月19日
*/
public static GroupEntity updateGroupAvatar(String groupId, String userCode) {
try {
if (StringUtils.isNotBlank(groupId)) {
StringBuilder url = new StringBuilder(GConstants.getValue("foc.update.group.avatar.url",
StringBuilder url = new StringBuilder(GConstants.getValue("foc.update.group.avatar.url",
"http://127.0.0.1:8080/api/im/group/updateGroupAvatar"));
Map<String, String> params = new HashMap<String, String>();
params.put("content", "{\"lang\":\"CN\",\"platform\":\"PC\",\"deviceToken\":\"deviceToken\","
+ "\"appCode\":\"10001\",\"language\":\"zh_CN\",\"versionName\":\"1.0\",\"userCode\":\""
+ (StringUtils.isBlank(userCode) ? "123" : userCode) + "\",\"groupId\":\"" + groupId + "\"}");
String sign = GlobalUtil.getParamsSignStr(GConstants.SIGN_PRIVATE_KEY, params.get("content"));
params.put("sign", sign);
String res = HttpClientUtil.doPost(url.toString(), params, "UTF-8");
// System.out.println(res);
JSONObject object = JSON.parseObject(res);
if(object != null && object.containsKey("status")){
if(ErrorCode.STATUS_CODE_2000.equals(object.getString("status"))){
if (object != null && object.containsKey("status")) {
if (ErrorCode.STATUS_CODE_2000.equals(object.getString("status"))) {
return JSON.parseObject(object.getString("data"), GroupEntity.class);
}
}
......@@ -122,9 +115,9 @@ public class Util {
}
return null;
}
public static int parseInt(String val, int want){
if(StringUtils.isEmpty(val))
public static int parseInt(String val, int want) {
if (StringUtils.isEmpty(val))
return want;
try {
return Integer.parseInt(val);
......@@ -133,19 +126,20 @@ public class Util {
}
return want;
}
public static Date utc2Local(String utcTime) {
try {
String pattern = null;
if("yyyy-MM-dd HH:mm".length() == utcTime.length()){
if ("yyyy-MM-dd HH:mm".length() == utcTime.length()) {
pattern = "yyyy-MM-dd HH:mm";
} else if("yyyy-MM-dd HH:mm:ss".length() == utcTime.length()){
} else if ("yyyy-MM-dd HH:mm:ss".length() == utcTime.length()) {
pattern = "yyyy-MM-dd HH:mm:ss";
} else if("yyyy-MM-dd".length() == utcTime.length()){
} else if ("yyyy-MM-dd".length() == utcTime.length()) {
pattern = "yyyy-MM-dd";
}
SimpleDateFormat utcFormater = new SimpleDateFormat(pattern);
......@@ -162,121 +156,123 @@ public class Util {
}
return null;
}
public static Date utc2Local(Date utcDate) {
try {
// TimeZone bjtz = TimeZone.getTimeZone("Asia/Shanghai");
// TimeZone bjtz = TimeZone.getDefault();
// TimeZone bjtz = TimeZone.getTimeZone("Asia/Shanghai");
// TimeZone bjtz = TimeZone.getDefault();
TimeZone oldZone = TimeZone.getTimeZone("UTC");
TimeZone newZone = TimeZone.getTimeZone("GMT+08:00");
// int timeOffset = oldZone.getRawOffset() - newZone.getRawOffset();
// int timeOffset = oldZone.getRawOffset() - newZone.getRawOffset();
return changeTimeZone(utcDate, oldZone, newZone);
} catch (Exception e) {
// TODO: handle exception
}
return null;
}
/**
*
*
* @author renmb
* @time 2016年10月1日
* @param date
* @return
* @author renmb
* @time 2016年10月1日
*/
public static Date local2Utc(Date date) {
try {
// TimeZone bjtz = TimeZone.getTimeZone("Asia/Shanghai");
// TimeZone bjtz = TimeZone.getDefault();
// TimeZone bjtz = TimeZone.getTimeZone("Asia/Shanghai");
// TimeZone bjtz = TimeZone.getDefault();
TimeZone oldZone = TimeZone.getTimeZone("GMT+08:00");
TimeZone newZone = TimeZone.getTimeZone("UTC");
// int timeOffset = oldZone.getRawOffset() - newZone.getRawOffset();
// int timeOffset = oldZone.getRawOffset() - newZone.getRawOffset();
return changeTimeZone(date, oldZone, newZone);
} catch (Exception e) {
// TODO: handle exception
}
return null;
}
/**
* 时区转换
*
* @author renmb
* @time 2016年10月1日
*
* @param date
* @param oldZone
* @param newZone
* @return
* @author renmb
* @time 2016年10月1日
*/
public static Date changeTimeZone(Date date, TimeZone oldZone, TimeZone newZone) {
try {
GregorianCalendar localGregorianCalendar1 = new GregorianCalendar(oldZone);
localGregorianCalendar1.setTime(date);
GregorianCalendar localGregorianCalendar2 = new GregorianCalendar(newZone);
localGregorianCalendar2.setTimeInMillis(localGregorianCalendar1.getTimeInMillis());
return new Date(localGregorianCalendar2.getTimeInMillis());
} catch (Exception e) {
// TODO: handle exception
}
return null;
}
public static String getDurationTime(long time){
public static String getDurationTime(long time) {
String buffer = "";
buffer = ":"+time%1000+"纳秒";
time = time/1000;//微秒
buffer = ":"+time%1000+"微秒"+buffer;
time = time/1000;//毫秒
buffer = ":"+time%1000+"毫秒"+buffer;
time = time/1000;//毫秒
buffer = ":"+time%60+"秒"+buffer;
time = time/60;//秒
buffer =time+"分钟"+buffer;
buffer = ":" + time % 1000 + "纳秒";
time = time / 1000;//微秒
buffer = ":" + time % 1000 + "微秒" + buffer;
time = time / 1000;//毫秒
buffer = ":" + time % 1000 + "毫秒" + buffer;
time = time / 1000;//毫秒
buffer = ":" + time % 60 + "秒" + buffer;
time = time / 60;//秒
buffer = time + "分钟" + buffer;
return buffer;
}
/**
* 格式化手机号
*
* @author renmb
* @time 2016年12月12日
*
* @param mobile
* @return
* @author renmb
* @time 2016年12月12日
*/
public static String formatedMobile(String mobile){
if(mobile == null || mobile.length() == 0)
public static String formatedMobile(String mobile) {
if (mobile == null || mobile.length() == 0)
return mobile;
try {
String[] species = mobile.split("\\s+");// 只使用第一个手机号
if(species.length>1 && species[0].matches("1\\d+") && species[1].matches("1\\d+")){
if (species.length > 1 && species[0].matches("1\\d+") && species[1].matches("1\\d+")) {
mobile = species[0];
}
mobile = mobile.replaceAll("+", "+");// 处理错误字符
mobile = mobile.replaceAll("[^0-9|+]+", "");// 将非电话号码替换为空
// System.out.println("mobile:"+mobile);
if(mobile.startsWith("+")){// 国外手机号,前面加拨3个0
return "000"+mobile.replace("+", "");
} else if(mobile.matches("\\d+")){
if (mobile.startsWith("+")) {// 国外手机号,前面加拨3个0
return "000" + mobile.replace("+", "");
} else if (mobile.matches("\\d+")) {
PhoneAreaEntity area = PhoneAreaUtil.get360PhoneArea(mobile);
if(area == null){// 二次请求
if (area == null) {// 二次请求
area = PhoneAreaUtil.get360PhoneArea(mobile);
}
if(area != null && StringUtils.isNotBlank(area.getProvince())){// 能够查到省份信息
if(area.getProvince().contains("北京")
|| (StringUtils.isNotBlank(area.getCity())
&& area.getCity().contains("北京"))){// 北京前面加拨一个0
return "0"+mobile;
if (area != null && StringUtils.isNotBlank(area.getProvince())) {// 能够查到省份信息
if (area.getProvince().contains("北京")
|| (StringUtils.isNotBlank(area.getCity())
&& area.getCity().contains("北京"))) {// 北京前面加拨一个0
return "0" + mobile;
} else {// 非北京号码加拨两个0
return "00"+mobile;
return "00" + mobile;
}
}
}
......@@ -285,49 +281,50 @@ public class Util {
}
return mobile;
}
/**
* 格式化座机号
*
* @author renmb
* @time 2016年12月12日
*
* @param workPhone
* @return
* @author renmb
* @time 2016年12月12日
*/
public static String formatedWorkPhone(String workPhone){
if(workPhone == null || workPhone.length() == 0)
public static String formatedWorkPhone(String workPhone) {
if (workPhone == null || workPhone.length() == 0)
return workPhone;
try {
workPhone = workPhone.replaceAll("[^\\d|+]+", "");
if(workPhone.matches("0+")){ // 非座机号设置为空
if (workPhone.matches("0+")) { // 非座机号设置为空
workPhone = "";
} else if(workPhone.startsWith("0") == false){ // 非0开头的号码需要处理
if(workPhone.startsWith("1") && workPhone.length() == 11){// 非座机号,是手机号,将号码处理为空
} else if (workPhone.startsWith("0") == false) { // 非0开头的号码需要处理
if (workPhone.startsWith("1") && workPhone.length() == 11) {// 非座机号,是手机号,将号码处理为空
workPhone = "";
}
}
if(workPhone.startsWith("+") == false){// 去掉电话号码中间的加号
if (workPhone.startsWith("+") == false) {// 去掉电话号码中间的加号
workPhone = workPhone.replace("+", "");
}
if(workPhone.startsWith("0106961")){// 1、010 6961 xxxx -> xxxx 内部号码,直接拨短号
if (workPhone.startsWith("0106961")) {// 1、010 6961 xxxx -> xxxx 内部号码,直接拨短号
workPhone = workPhone.replace("0106961", "");
} else if(workPhone.startsWith("06961")){// 2、06961 xxxx -> xxxx 内部号码,直接拨短号
} else if (workPhone.startsWith("06961")) {// 2、06961 xxxx -> xxxx 内部号码,直接拨短号
workPhone = workPhone.replace("06961", "");
} else if(workPhone.startsWith("6961")){// 2、6961 xxxx -> xxxx 内部号码,直接拨短号
} else if (workPhone.startsWith("6961")) {// 2、6961 xxxx -> xxxx 内部号码,直接拨短号
workPhone = workPhone.replace("6961", "");
} else if(workPhone.startsWith("010")){// 3、010 xxxx xxxx -> 0 xxxx xxxx 北京号码,去掉区号,加拨0
} else if (workPhone.startsWith("010")) {// 3、010 xxxx xxxx -> 0 xxxx xxxx 北京号码,去掉区号,加拨0
workPhone = workPhone.replace("010", "0");
} else if(workPhone.startsWith("+")){// 4、+ xxxx xxxx -> 000 xxxx xxxx 北京号码,去掉+号,加拨000
} else if (workPhone.startsWith("+")) {// 4、+ xxxx xxxx -> 000 xxxx xxxx 北京号码,去掉+号,加拨000
workPhone = workPhone.replace("+", "000");
} else {// 5、xxx xxxx xxxx -> 0 xxx xxxx xxxx 国内非北京号码,加拨0
workPhone = "0"+workPhone;
workPhone = "0" + workPhone;
}
return workPhone;
} catch (Exception e) {
......@@ -335,24 +332,25 @@ public class Util {
}
return workPhone;
}
/**
* 获取堆栈信息
*
* @author renmb
* @time 2016年10月21日
*
* @param e
* @return
* @author renmb
* @time 2016年10月21日
*/
public static String getStackTrace(Throwable e) {
String error = "";
Writer errors = null;
PrintWriter printWriter = null;
try {
errors = new StringWriter();
printWriter = new PrintWriter(errors);
e.printStackTrace(printWriter);
error = errors.toString();
printWriter.close();
......@@ -363,57 +361,62 @@ public class Util {
}
return error;
}
/**
* 设置图片全名称
*
* @author renmb
* @time 2016年12月11日
*
* @param url
* @param want
* @return
* @author renmb
* @time 2016年12月11日
*/
public static String getAbsoluteUrl(String url, String want) {
if(StringUtils.isBlank(url))
if (StringUtils.isBlank(url))
return getAbsoluteUrl(want);
if(url.startsWith("http://") || url.startsWith("https://"))// 绝对路径
if (url.startsWith("http://") || url.startsWith("https://"))// 绝对路径
return url;
if(GConstants.FILE_PREFIX_URL.endsWith("/") && url.startsWith("/"))// 相对路径
return GConstants.FILE_PREFIX_URL+url.replaceAll("^/+", "");
return GConstants.FILE_PREFIX_URL+url;
if (GConstants.FILE_PREFIX_URL.endsWith("/") && url.startsWith("/"))// 相对路径
return GConstants.FILE_PREFIX_URL + url.replaceAll("^/+", "");
return GConstants.FILE_PREFIX_URL + url;
}
/**
* 获取文件的绝对路径
*
* @author renmb
* @time 2016年9月1日
*
* @param url
* @return
* @author renmb
* @time 2016年9月1日
*/
public static String getAbsoluteUrl(String url) {
if(StringUtils.isBlank(url))
if (StringUtils.isBlank(url))
return "";
if(url.startsWith("http://") || url.startsWith("https://"))// 绝对路径
if (url.startsWith("http://") || url.startsWith("https://"))// 绝对路径
return url;
if(GConstants.FILE_PREFIX_URL.endsWith("/") && url.startsWith("/"))// 相对路径
return GConstants.FILE_PREFIX_URL+url.replaceAll("^/+", "");
return GConstants.FILE_PREFIX_URL+url;
if (GConstants.FILE_PREFIX_URL.endsWith("/") && url.startsWith("/"))// 相对路径
return GConstants.FILE_PREFIX_URL + url.replaceAll("^/+", "");
return GConstants.FILE_PREFIX_URL + url;
}
/**
* 获取相对路径地址
*
* @author renmb
* @time 2017年1月13日
*
* @param url
* @return
* @author renmb
* @time 2017年1月13日
*/
public static String getRelativePath(String url) {
if(StringUtils.isBlank(url))
if (StringUtils.isBlank(url))
return "";
return url.replaceAll(GConstants.FILE_PREFIX_URL, "");
// return url;
}
/**
* 获取文件的扩展名称
*
* @param filename
* @return
*/
......@@ -425,78 +428,79 @@ public class Util {
// return "."+species[species.length-1].toLowerCase();
// }
// return null;
if(filename == null || filename.length() == 0)
if (filename == null || filename.length() == 0)
return "";
int startIndex = filename.lastIndexOf(".")+1;
int startIndex = filename.lastIndexOf(".") + 1;
int length = filename.length();
if(startIndex>0 && startIndex<length){
return "."+filename.substring(startIndex, length);
if (startIndex > 0 && startIndex < length) {
return "." + filename.substring(startIndex, length);
}
return "";
}
/**
* 获取文件扩展名,不带“.”
*
* @author renmb
* @time 2017年2月10日
*
* @param filename
* @return
* @author renmb
* @time 2017年2月10日
*/
public static String getFileExtensionName(String filename) {
if(filename == null || filename.length() == 0)
if (filename == null || filename.length() == 0)
return "";
int startIndex = filename.lastIndexOf(".")+1;
int startIndex = filename.lastIndexOf(".") + 1;
int length = filename.length();
if(startIndex>0 && startIndex<length){
if (startIndex > 0 && startIndex < length) {
return filename.substring(startIndex, length);
}
return "";
}
/**
* 新就版本进行比较,如果新版本比老版本高则返回true,否则返回false
*
* @author renmb
* @time 2016年8月3日
*
* @param oldVersion
* @param version
* @return
* @author renmb
* @time 2016年8月3日
*/
public static boolean compareVersion(String oldVersion, String version) {
if(version != null && oldVersion != null) {
if (version != null && oldVersion != null) {
String checkVersion[] = version.split("\\.");
String originalVersion[] = oldVersion.split("\\.");
int maxlength = (originalVersion.length >= checkVersion.length)?originalVersion.length:checkVersion.length;
int maxlength = (originalVersion.length >= checkVersion.length) ? originalVersion.length : checkVersion.length;
// go through all Version-parts
for(int i= 0; i < maxlength; i++) {
for (int i = 0; i < maxlength; i++) {
// if the checked version is too short
if ( checkVersion.length <= i
&& originalVersion[i].equals(0))
if (checkVersion.length <= i
&& originalVersion[i].equals(0))
return true;
else if (checkVersion.length <= i)
return false;
// if the original version is long enough
if(originalVersion.length > i) {
if (originalVersion.length > i) {
// convert to integer
try {
int originalVersNumber = Integer.valueOf(originalVersion[i]).intValue();
int checkVersNumber = Integer.valueOf(checkVersion[i]).intValue();
// check the numbers
if(checkVersNumber > originalVersNumber) {
if (checkVersNumber > originalVersNumber) {
return true;
} else if(checkVersNumber < originalVersNumber) {
} else if (checkVersNumber < originalVersNumber) {
return false;
}
} catch(Exception e) {
} catch (Exception e) {
return false;
}
}
else {
} else {
return true;
}
}
......@@ -504,65 +508,66 @@ public class Util {
}
return false;
}
/**
* 生成安全的密码,生成随机的16位salt并经过1024次 sha-1 hash
*
* @author renmb
* @time 2017年3月27日
*
* @param plainPassword
* @return
* @author renmb
* @time 2017年3月27日
*/
public static String entryptPassword(String plainPassword) {
try {
String plain = Encodes.unescapeHtml(plainPassword);
byte[] salt = Digests.generateSalt(GConstants.SALT_SIZE);
byte[] hashPassword = Digests.sha1(plain.getBytes(), salt, GConstants.HASH_INTERATIONS);
return Encodes.encodeHex(salt)+Encodes.encodeHex(hashPassword);
return Encodes.encodeHex(salt) + Encodes.encodeHex(hashPassword);
} catch (Exception e) {
// TODO: handle exception
}
return null;
}
/**
* 验证密码
*
* @author renmb
* @time 2017年3月27日
*
* @param plainPassword
* @param password
* @return
* @author renmb
* @time 2017年3月27日
*/
public static boolean validatePassword(String plainPassword, String password) {
try {
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);
return password.equals(Encodes.encodeHex(salt)+Encodes.encodeHex(hashPassword));
return password.equals(Encodes.encodeHex(salt) + Encodes.encodeHex(hashPassword));
} catch (Exception e) {
// TODO: handle exception
}
return false;
}
public static String getGenericCode(){
public static String getGenericCode() {
try {
return UUID.randomUUID().toString().replaceAll("-", "").toLowerCase();
} catch (Exception e) {
// TODO: handle exception
}
return null;
}
public static boolean isrContainValues(JSONArray data, String... values) {
if(data == null || values == null)
if (data == null || values == null)
return false;
int count = 0;
int len = data.size();
for(String val:values){
for(int j=0;j<len;j++){
if(val !=null && val.equals(data.getString(j))){
for (String val : values) {
for (int j = 0; j < len; j++) {
if (val != null && val.equals(data.getString(j))) {
count++;
if (count == values.length) {
return true;
......@@ -572,29 +577,32 @@ public class Util {
}
return false;
}
public static boolean isPraramerValue(JSONObject data, String... colums) {
if(data == null || colums == null)
if (data == null || colums == null)
return false;
for(String colum:colums){
if(data.containsKey(colum) == false){
for (String colum : colums) {
if (data.containsKey(colum) == false) {
return false;
}
}
return true;
}
public static boolean isInValue(String val, String... vals) {
if(val == null || vals == null)
if (val == null || vals == null)
return false;
for(String v:vals){
if(val.equals(v)){
for (String v : vals) {
if (val.equals(v)) {
return true;
}
}
return false;
}
/**
* 生成稳健的随机数
*
* @param min
* @param max
* @return
......@@ -608,63 +616,58 @@ public class Util {
// return randomNumber-1;
// }
public static int getRandom(int min, int max) {
int randomNumber;
try {
SecureRandom number = SecureRandom.getInstance("SHA1PRNG");
int randomNumber = (number.nextInt(max-min+3)+min);//(int)(Math.random()*(max-min+3)+min);
while (randomNumber == min || randomNumber == max+2) {
randomNumber = (number.nextInt(max-min+3)+min);
randomNumber = (number.nextInt(max - min + 3) + min);//(int)(Math.random()*(max-min+3)+min);
while (randomNumber == min || randomNumber == max + 2) {
randomNumber = (number.nextInt(max - min + 3) + min);
}
return randomNumber-1;
} catch (Exception e){
return randomNumber - 1;
} catch (Exception e) {
e.printStackTrace();
}
int randomNumber = (int)(Math.random()*(max-min+3)+min);
while (randomNumber == min || randomNumber == max+2) {
randomNumber = (int)(Math.random()*(max-min+3)+min);
randomNumber = (int) (Math.random() * (max - min + 3) + min);
while (randomNumber == min || randomNumber == max + 2) {
randomNumber = (int) (Math.random() * (max - min + 3) + min);
}
return randomNumber-1;
}
public static double getRandom(double max) {
double randomNumber = Math.random()*(max+2);
while (randomNumber >= max+1) {
randomNumber = Math.random()*(max+2);
}
return randomNumber;
return randomNumber - 1;
}
/**
* 获取客户端真实IP地址
*
* @param request
* @return
*/
public static String getOnlineIP(HttpServletRequest request) {
//获取X-Forwarded-For
if(request == null)
if (request == null)
return "Unknown";
String ip = request.getHeader("X-Real-IP");
if(StringUtils.isBlank(ip) || "Unknown".equalsIgnoreCase(ip)){
if (StringUtils.isBlank(ip) || "Unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("x-forwarded-for");
if(StringUtils.isBlank(ip) || "Unknown".equalsIgnoreCase(ip)){
if (StringUtils.isBlank(ip) || "Unknown".equalsIgnoreCase(ip)) {
//获取HTTP_CLIENT_IP
ip = request.getHeader("Proxy-Client-IP");
if(StringUtils.isBlank(ip) || "Unknown".equalsIgnoreCase(ip)){
if (StringUtils.isBlank(ip) || "Unknown".equalsIgnoreCase(ip)) {
//HTTP_X_FORWARDED_FOR
ip = request.getHeader("WL-Proxy-Client-IP");
if(StringUtils.isBlank(ip) || "Unknown".equalsIgnoreCase(ip)){
if (StringUtils.isBlank(ip) || "Unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
}
}
}
if(StringUtils.isBlank(ip))
if (StringUtils.isBlank(ip))
return "Unknown";
return ip.split(",")[0];
}
/**
* 得到请求的根目录
*
*
* @param request
* @return
*/
......@@ -683,7 +686,7 @@ public class Util {
/**
* 得到结构目录
*
*
* @param request
* @return
*/
......@@ -722,6 +725,7 @@ public class Util {
/**
* 得到Uc账号,判断规则,如果同时满足前缀,后缀,直接返回该账号。否则按照前缀,后缀规则,添加后返回账号
*
* @return
*/
public static String getUcAccount(String str) {
......@@ -740,7 +744,8 @@ public class Util {
}
return str;
}
// public static void main(String[] args){
// public static void main(String[] args){
// Map<Integer, Integer> counter = new HashMap<>();
// for(int i=0;i<100000;i++){
// int a = getRandom(0,200);
......
......@@ -3,36 +3,26 @@
*/
package com.ejweb.core.utils.excel;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import com.ejweb.core.utils.excel.annotation.ExcelField;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;
import com.ejweb.core.utils.excel.annotation.ExcelField;
import com.google.common.collect.Lists;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 导入Excel文件(支持“XLS”和“XLSX”格式)
......@@ -136,9 +126,9 @@ public class ImportExcel {
throws InvalidFormatException, IOException {
if (StringUtils.isBlank(fileName)) {
throw new RuntimeException("导入文档为空!");
} else if (fileName.toLowerCase().endsWith("xls")) {
} else if (fileName.toLowerCase(Locale.ENGLISH).endsWith("xls")) {
this.wb = new HSSFWorkbook(is);
} else if (fileName.toLowerCase().endsWith("xlsx")) {
} else if (fileName.toLowerCase(Locale.ENGLISH).endsWith("xlsx")) {
this.wb = new XSSFWorkbook(is);
} else {
throw new RuntimeException("文档格式不正确!");
......@@ -203,11 +193,7 @@ public class ImportExcel {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
// 处理日期格式、时间格式
if (HSSFDateUtil.isCellDateFormatted(cell)) {
SimpleDateFormat sdf = null;
if (cell.getCellStyle().getDataFormat() == HSSFDataFormat
.getBuiltinFormat("h:mm")) {
sdf = new SimpleDateFormat("HH:mm");
}
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
Date date = cell.getDateCellValue();
val = sdf.format(date);
} else {
......@@ -379,19 +365,4 @@ public class ImportExcel {
}
return dataList;
}
/**
* 导入测试
*/
public static void main(String[] args) throws Throwable {
ImportExcel ei = new ImportExcel("C:\\Users\\yiping\\Desktop\\任务跟踪表-车库网2016-8-24.xlsx", 1);
for (int i = ei.getDataRowNum(); i < ei.getLastDataRowNum(); i++) {
Row row = ei.getRow(i);
for (int j = 0; j < ei.getLastCellNum(); j++) {
Object val = ei.getCellValue(row, j);
System.out.print(val + ", ");
}
System.out.print("\n");
}
}
}
......@@ -43,7 +43,7 @@ public class StationUserListEntity extends BaseEntity {
private String dutyName; // 职务
private String huaweiNum;
private String huaweiAccount; //华为账号
private String huaweiPassword; //华为密码
private transient String huaweiPassword; //华为密码
private int huaweiStatus;// 华为绑定状态: 0 位绑定 1 已绑定
private int jiewenStatus;// 捷文绑定状态: 0 位绑定 1 已绑定
......
......@@ -6,6 +6,7 @@ import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
......@@ -117,7 +118,7 @@ public class MainController{
}
return responseBean;
}
@ResponseBody
@RequestMapping(value = "upload")
public ResponseBean upload(HttpServletRequest request,
......@@ -145,10 +146,10 @@ public class MainController{
int length = 0;
try {
if(originalFilename.toLowerCase().endsWith("xls")){
if (originalFilename.toLowerCase(Locale.ENGLISH).endsWith("xls")) {
HSSFWorkbook hwb = new HSSFWorkbook(file.getInputStream());
length = hwb.getNumberOfSheets();//判断有几张活动的sheet表
}else if(originalFilename.toLowerCase().endsWith("xlsx")){
} else if (originalFilename.toLowerCase(Locale.ENGLISH).endsWith("xlsx")) {
XSSFWorkbook hwb = new XSSFWorkbook(file.getInputStream());
length = hwb.getNumberOfSheets();//判断有几张活动的sheet表
}
......
......@@ -3,36 +3,34 @@
*/
package com.ejweb.modules.flight.service;
import java.text.SimpleDateFormat;
import java.util.*;
import com.ejweb.modules.flight.bean.*;
import com.ejweb.modules.flight.entity.*;
import com.ejweb.modules.flightPlan.bean.FlightingDynamicListBean;
import com.ejweb.modules.im.entity.FlightPlanSignedTimeEntity;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ejweb.core.base.BaseService;
import com.ejweb.core.base.PageEntity;
import com.ejweb.core.util.Util;
import com.ejweb.modules.flight.bean.*;
import com.ejweb.modules.flight.dao.FlightDao;
import com.ejweb.modules.flight.entity.*;
import com.ejweb.modules.flightPlan.bean.FlightingDynamicListBean;
import com.ejweb.modules.im.bean.HuaweiUserStatInfoBean;
import com.ejweb.modules.im.entity.FlightPlanSignedTimeEntity;
import com.ejweb.modules.im.entity.HuaweiUserStatEntity;
import com.ejweb.modules.im.service.HuaweiInterfaseService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.text.SimpleDateFormat;
import java.util.*;
/**
*
* @team IT Team
* @author renmb
* @version 1.0
* @time 2016年8月28日
* @team IT Team
* @time 2016年8月28日
*/
@Service
@Transactional(readOnly = true)
......@@ -40,30 +38,30 @@ public class FlightService extends BaseService<FlightDao> {
@Autowired
private HuaweiInterfaseService huaweiInterfaseService;
/**
* 获取航班列表
*
*
* @author renmb
* @time 2016年8月30日
* @time 2016年8月30日
* @param bean
* @return
*/
public FlightPageEntity getFlightDynamicList(FlightListBean bean){
public FlightPageEntity getFlightDynamicList(FlightListBean bean) {
PageInfo<FlightDynamicListEntity> pageInfo = null;
// 必须紧贴dao的查询方法
PageHelper.startPage(bean.getPageNo(), bean.getPageSize());
pageInfo = new PageInfo<FlightDynamicListEntity>(dao.getFlightDynamicList(bean));
if(pageInfo.getPages()<bean.getPageNo()){// 页码大于总页数,则返回NULL
if (pageInfo.getPages() < bean.getPageNo()) {// 页码大于总页数,则返回NULL
return null;
}
List<FlightDynamicListEntity> list = pageInfo.getList();
if (list == null || list.size() == 0) {// 如果没有数据则返回NULL
return null;
}
FlightPageEntity page = new FlightPageEntity();
......@@ -75,15 +73,16 @@ public class FlightService extends BaseService<FlightDao> {
return page;
}
/**
* 获取指定航班的
*
*
* @author renmb
* @time 2016年8月30日
* @time 2016年8月30日
* @return
*/
public FlightDynamicDetailEntity getFlightDynamicDetail(String flightNo, Date flightDate,String acNo, String depStn, String arrStn){
public FlightDynamicDetailEntity getFlightDynamicDetail(String flightNo, Date flightDate, String acNo, String depStn, String arrStn) {
FlightDetailBean bean = new FlightDetailBean();
bean.setFlightNo(flightNo);
bean.setFlightDate(flightDate);
......@@ -92,37 +91,40 @@ public class FlightService extends BaseService<FlightDao> {
bean.setAcNo(acNo);
return dao.getFlightDynamicDetail(bean);
}
/**
* 查询前航班信息
*
*
* @author renmb
* @time 2016年10月25日
* @time 2016年10月25日
* @param acLongNo
* @param ataChn
* @return
*/
public FlightDynamicDetailEntity findPreFlightDetail(String acLongNo, Date ataChn){
public FlightDynamicDetailEntity findPreFlightDetail(String acLongNo, Date ataChn) {
FlightDynamicDetailEntity bean = new FlightDynamicDetailEntity();
bean.setAcLongNo(acLongNo);
bean.setAta(ataChn);
return dao.findPreFlightDetail(bean);
}
public FlightDynamicDetailEntity findPreFlightDetail(FlightDynamicDetailEntity entity){
public FlightDynamicDetailEntity findPreFlightDetail(FlightDynamicDetailEntity entity) {
return dao.findPreFlightDetail(entity);
}
/**
* 获取航班的机组人员列表
*
* @author renmb
* @time 2016年8月30日
*
* @param flightNo
* @return
* @author renmb
* @time 2016年8月30日
*/
public List<FlightCrewListEntity> getFlightCrewList(String flightNo, Date flightDate,
String acNo, String depStn, String arrStn, int needOnlineState){
String acNo, String depStn, String arrStn, int needOnlineState) {
FlightDetailBean bean = new FlightDetailBean();
bean.setFlightNo(flightNo);
bean.setFlightDate(flightDate);
......@@ -130,13 +132,13 @@ public class FlightService extends BaseService<FlightDao> {
bean.setArrStn(arrStn);
bean.setAcNo(acNo);
bean.setNeedOnlineState(needOnlineState);
List<FlightCrewListEntity> crewList = dao.getFlightCrewList(bean);
if(crewList != null && crewList.size() > 0){
if (crewList != null && crewList.size() > 0) {
List<String> userIds = new ArrayList<String>();
for(FlightCrewListEntity crewListEntity:crewList){
if(1 == crewListEntity.getHuaweiStatus()){
for (FlightCrewListEntity crewListEntity : crewList) {
if (1 == crewListEntity.getHuaweiStatus()) {
userIds.add(crewListEntity.getStaffId());
}
}
......@@ -146,8 +148,8 @@ public class FlightService extends BaseService<FlightDao> {
List<HuaweiUserStatEntity> huaweiUserStatEntities = huaweiInterfaseService.presence(huaweiUserStatInfoBean);
if (huaweiUserStatEntities != null && huaweiUserStatEntities.size() > 0) {
for (HuaweiUserStatEntity statEntityTmp : huaweiUserStatEntities) {
for(FlightCrewListEntity crewListEntity:crewList){
for (FlightCrewListEntity crewListEntity : crewList) {
crewListEntity.setState(Util.parseInt(statEntityTmp.getNewState(), 0));
}
}
......@@ -156,18 +158,18 @@ public class FlightService extends BaseService<FlightDao> {
}
return dao.getFlightCrewList(bean);
}
/**
* 处理航班的机组人员,对机组人员进行分组展示
*
*
* @author renmb
* @time 2016年8月30日
* @time 2016年8月30日
* @return
*/
public List<FlightCrewGroupEntity> getFlightCrewGroupList(String flightNo, Date flightDate,
String acNo, String depStn, String arrStn, int needOnlineState){
String acNo, String depStn, String arrStn, int needOnlineState) {
List<FlightCrewListEntity> crewList = this.getFlightCrewList(flightNo, flightDate, acNo, depStn, arrStn, needOnlineState);
if(crewList != null && crewList.size() != 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("飞行员");
......@@ -180,31 +182,31 @@ public class FlightService extends BaseService<FlightDao> {
crews.put("3", "安全员");
crews.put("4", "安全员");
// crews.put("其他人员", "其他人员");
for(FlightCrewListEntity crewListEntity:crewList){
for (FlightCrewListEntity crewListEntity : crewList) {
String key = crews.get(crewListEntity.getCrewTypeId());
if(StringUtils.isBlank(key)){// 人员分组判断
if (StringUtils.isBlank(key)) {// 人员分组判断
continue;
// key = "其他人员";
}
crewListEntity.setPhoto(Util.getAbsoluteUrl(crewListEntity.getPhoto()));// 设置用户头像
List<FlightCrewListEntity> item = items.get(key);
if(item == null){// 如果还不存在则添加一个分组列表
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){
for (String key : names) {
FlightCrewGroupEntity crewGroup = new FlightCrewGroupEntity();
crewGroup.setName(key);
crewGroup.setList(items.get(crewGroup.getName()));
......@@ -214,43 +216,47 @@ public class FlightService extends BaseService<FlightDao> {
}
return null;
}
/**
* 查询飞机的航班信息,用于查询“航段信息”
*
*
* @author renmb
* @time 2016年10月23日
* @time 2016年10月23日
* @param flightDate
* @param acNo
* @return
*/
public List<FlightDynamicListEntity> getAcFlightDynamicList(Date flightDate,String acNo){
public List<FlightDynamicListEntity> getAcFlightDynamicList(Date flightDate, String acNo) {
FlightDynamicDetailEntity entity = new FlightDynamicDetailEntity();
entity.setFlightDate(flightDate);
entity.setAcLongNo(acNo);
return dao.getAcFlightDynamicList(entity);
}
public List<FlightDynamicListEntity> getAcFlightDynamicList(FlightDynamicDetailEntity entity){
public List<FlightDynamicListEntity> getAcFlightDynamicList(FlightDynamicDetailEntity entity) {
return dao.getAcFlightDynamicList(entity);
}
/**
* 用于查询“全航程”
*
* @author renmb
* @time 2016年10月23日
*
* @param flightDate
* @return
* @author renmb
* @time 2016年10月23日
*/
public List<FlightDynamicListEntity> getEstFlightDynamicList(String flightNo,Date flightDate){
public List<FlightDynamicListEntity> getEstFlightDynamicList(String flightNo, Date flightDate) {
FlightDynamicDetailEntity entity = new FlightDynamicDetailEntity();
entity.setFlightNo(flightNo);
entity.setFlightDate(flightDate);
return dao.getEstFlightDynamicList(entity);
}
public List<FlightDynamicListEntity> getEstFlightDynamicList(FlightDynamicDetailEntity entity){
public List<FlightDynamicListEntity> getEstFlightDynamicList(FlightDynamicDetailEntity entity) {
return dao.getEstFlightDynamicList(entity);
}
......@@ -287,15 +293,16 @@ public class FlightService extends BaseService<FlightDao> {
public List<SignFlightEntity> getUserFlight(MySignListBean bean) {
return dao.getUserFlight(bean);
}
/**
*
*
* 筛选状态
* @author huhy
* @time 2016年11月25日
* @time 2016年11月25日
* @param bean
* @return
*/
public List<FlightStatusEntity> getFlightStatus(FlightStatusBean bean){
public List<FlightStatusEntity> getFlightStatus(FlightStatusBean bean) {
return dao.getFlightStatus(bean);
}
......@@ -369,7 +376,7 @@ public class FlightService extends BaseService<FlightDao> {
//如果有准备会前签到,需要获取基地,席位相关的信息
if (returnSignTime.isHasPrepare40Sign()) {
NextSignEntity seatSignEntity = dao.getOdsSeatInfo(returnSignTime, bean.getUserId(), bean.getDefaultSeatName());
if (seatSignEntity != null) {
if (seatSignEntity != null && returnSignTime != null) {
returnSignTime.setSeatId(seatSignEntity.getSeatId());
returnSignTime.setSeatName(seatSignEntity.getSeatName());
returnSignTime.setStationName(seatSignEntity.getStationName());
......@@ -382,13 +389,13 @@ public class FlightService extends BaseService<FlightDao> {
/**
* 签到时间
*
*
* @author huhy
* @time 2016年12月4日
* @time 2016年12月4日
* @param bean
* @return
*/
public List<SignDateEntity> getSignTime(MyFlightListBean bean){
public List<SignDateEntity> getSignTime(MyFlightListBean bean) {
return dao.getSignTime(bean);
}
......@@ -440,7 +447,7 @@ public class FlightService extends BaseService<FlightDao> {
* @return
*/
public List<SignUserEntity> getSignedUserList(SignFlightEntity entityTmp, String type) {
List<SignUserEntity> signedUserList = dao.getSignedUserList(entityTmp, type);
List<SignUserEntity> signedUserList = dao.getSignedUserList(entityTmp, type);
if (!CollectionUtils.isEmpty(signedUserList)) {
for (SignUserEntity signUserEntityTmp : signedUserList) {
signUserEntityTmp.setPhoto(Util.getAbsoluteUrl(signUserEntityTmp.getPhoto()));
......@@ -481,14 +488,14 @@ public class FlightService extends BaseService<FlightDao> {
* @param bean
* @return
*/
public PageEntity<SignFlightListEntity> getSignFlightList(SignFlightListBean bean){
public PageEntity<SignFlightListEntity> getSignFlightList(SignFlightListBean bean) {
PageInfo<SignFlightListEntity> pageInfo = null;
// 必须紧贴dao的查询方法
PageHelper.startPage(bean.getPageNo(), bean.getPageSize());
pageInfo = new PageInfo<SignFlightListEntity>(dao.getSignFlightList(bean));
if(pageInfo.getPages()<bean.getPageNo()){// 页码大于总页数,则返回NULL
if (pageInfo.getPages() < bean.getPageNo()) {// 页码大于总页数,则返回NULL
return null;
}
......@@ -551,20 +558,20 @@ public class FlightService extends BaseService<FlightDao> {
/**
* 查询航班正在执行的航班列表
*
*
* @author renmb
* @time 2016年12月20日
* @time 2016年12月20日
* @param userId
* @return
*/
public List<FlightingListEntity> getFlightingDynamicList(String userId){
public List<FlightingListEntity> getFlightingDynamicList(String userId) {
FlightingDynamicListBean bean = new FlightingDynamicListBean();
bean.setUserId(userId);
SimpleDateFormat sfa = new SimpleDateFormat("yyyy-MM-dd");
String startFlightDate = sfa.format(new Date());
bean.setStartFlightDate(startFlightDate);
SimpleDateFormat sfb = new SimpleDateFormat("yyyy-MM-dd");
String endFlightDate = sfb.format(DateUtils.addDays(new Date(), 1));
bean.setEndFlightDate(endFlightDate);
......
......@@ -36,6 +36,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
/**
* app端搜索
......@@ -266,8 +267,8 @@ public class ImSearchController {
if (message == null) { // 通过参数校验
bean.setKeyWords(bean.getKeyWords().trim());
ImBigSearchEntityV2 bigSearchEntity = new ImBigSearchEntityV2();
if (StringUtils.isBlank(bean.getType()) || "USER".equals(bean.getType().toUpperCase())) {// 类型为空或者人员,查询人员相关信息
if (StringUtils.isBlank(bean.getType()) || "USER".equals(bean.getType().toUpperCase(Locale.ENGLISH))) {// 类型为空或者人员,查询人员相关信息
//人员信息
UserSeatListBean userSeatListBean = new UserSeatListBean();
userSeatListBean.setKeywords(bean.getKeyWords());
......@@ -342,7 +343,7 @@ public class ImSearchController {
bigSearchEntity.setUserList(userSeatEntityPage);
}
if (StringUtils.isBlank(bean.getType()) || "FLIGHT".equals(bean.getType().toUpperCase())) {// 航班信息
if (StringUtils.isBlank(bean.getType()) || "FLIGHT".equals(bean.getType().toUpperCase(Locale.ENGLISH))) {// 航班信息
FlightListBean flightListBean = new FlightListBean();
flightListBean.setKeywords(bean.getKeyWords());
flightListBean.setPageNo(bean.getFlightPageNo());
......
......@@ -11,23 +11,23 @@ import com.ejweb.core.base.BaseEntity;
*/
public class UcAccountEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
private String bindId; //绑定ID 用户ID或者席位ID
private String bindType = "USER"; //类型 USER 个人账号 SEAT 席位账号
private String bindStatus = "FAILD"; //绑定状态 FAILD 绑定失败 SUCCESS 绑定成功 UNBIND 已解绑
private String huaweiNum; //华为SIP号
private String huaweiId; //华为UC账号ID
private String huaweiPassword; //登录华为密码
private String updateBy; //最后一次者
private Date updateDate; //最后一次时间
private String syncMessage; //同步过程描述
private static final long serialVersionUID = 1L;
private String bindId; //绑定ID 用户ID或者席位ID
private String bindType = "USER"; //类型 USER 个人账号 SEAT 席位账号
private String bindStatus = "FAILD"; //绑定状态 FAILD 绑定失败 SUCCESS 绑定成功 UNBIND 已解绑
private String huaweiNum; //华为SIP号
private String huaweiId; //华为UC账号ID
private transient String huaweiPassword; //登录华为密码
private String updateBy; //最后一次者
private Date updateDate; //最后一次时间
private String syncMessage; //同步过程描述
//同步到录音系统的状态
private String recordingStatus = "FAILD";
//同步到录音系统的状态
private String recordingStatus = "FAILD";
//同步到录音系统的URL
private String recordingUrl;
//同步到录音系统的URL
private String recordingUrl;
public UcAccountEntity() {
}
......
......@@ -94,8 +94,8 @@ public class HuaweiUCSyncService {
@Transactional(readOnly = false)
public String sync(HuaweiUCSyncBean bean) {
StringBuffer sb = new StringBuffer();
List<UserProfileEntity> userProfileEntities = null;
List<SeatEntity> seatEntities = null;
List<UserProfileEntity> userProfileEntities = new ArrayList<>();
List<SeatEntity> seatEntities = new ArrayList<>();
if (bean.isAll()) {
userProfileEntities = huaweiUCSyncDao.findAllUserList(bean);
seatEntities = huaweiUCSyncDao.findAllSeatList(bean);
......@@ -1534,11 +1534,11 @@ public class HuaweiUCSyncService {
*/
public String addAccountToUc(HuaweiUCAddAccountBean bean) {
StringBuffer sb = new StringBuffer();
List<UserProfileEntity> userProfileEntities = null;
List<SeatEntity> seatEntities = null;
List<UserProfileEntity> userProfileEntities = new ArrayList<>();
List<SeatEntity> seatEntities = new ArrayList<>();
if (bean.isAll()) {
userProfileEntities = huaweiUCSyncDao.findUserListAll(bean);
seatEntities = huaweiUCSyncDao.findAllSeatList(bean);
seatEntities = huaweiUCSyncDao.findAllSeatList(bean);
} else {
if (isNotEmptyList(bean.getUserIds())) {
userProfileEntities = huaweiUCSyncDao.findUserList(bean);
......
......@@ -18,7 +18,7 @@ public class MailEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
private String mailAddress;
private String password;
private transient String password;
public String getMailAddress() {
return mailAddress;
}
......
......@@ -16,11 +16,11 @@ public class LoginUserEntity extends BaseEntity {
private String verify;
private String officeName; // 归属部门
private String officeFullName; // 归属部门
@JSONField(serialize=false)
@JSONField(serialize = false)
private String loginName;// 登录名
@JSONField(serialize=false)
private String password;// 密码
@JSONField(serialize=false)
@JSONField(serialize = false)
private transient String password;// 密码
@JSONField(serialize = false)
private String no; // 工号
@JSONField(name="username")
private String name; // 姓名
......@@ -35,7 +35,7 @@ public class LoginUserEntity extends BaseEntity {
private String photo; // 头像
private String dutyName;// 职务名称
private String huaweiUCAccount;
private String huaweiUCPassword;
private transient String huaweiUCPassword;
private int huaweiStatus;// 华为绑定状态: 0 位绑定 1 已绑定
private int jiewenStatus;// 捷文绑定状态: 0 位绑定 1 已绑定
private String sex;
......
......@@ -9,15 +9,14 @@ import com.ejweb.core.base.BaseEntity;
/**
* @author HH
*
*/
public class User extends BaseEntity{
public class User extends BaseEntity {
private static final long serialVersionUID = 1L;
private String userCode;
private Office company; // 归属公司
private Office office; // 归属部门
private String loginName;// 登录名
private String password;// 密码
private transient String password;// 密码
private String no; // 工号
private String name; // 姓名
private String email; // 邮箱
......
......@@ -24,8 +24,8 @@ public class UserEntity extends BaseEntity{
private String nickname;
// 指定字段不序列化
@JSONField(serialize=false)
private String password;
@JSONField(serialize = false)
private transient String password;
// 日期格式化注解
@JSONField(name="create_date",format="yyyy-MM-dd HH:mm:ss")
......
......@@ -18,7 +18,7 @@ public class UserExport extends BaseEntity {
private String company; // 归属公司
private String office; // 归属部门
private String loginName;// 登录名
private String password;// 密码
private transient String password;// 密码
private String no; // 工号
private String name; // 姓名
......@@ -33,7 +33,7 @@ public class UserExport extends BaseEntity {
private String photo; // 头像
private String oldLoginName;// 原登录名
private String newPassword; // 新密码
private transient String newPassword; // 新密码
public static long getSerialVersionUID() {
return serialVersionUID;
......
......@@ -17,7 +17,7 @@ public class UserProfileEntity extends BaseEntity {
private Office company; // 归属公司
private Office office; // 归属部门
private String loginName;// 登录名
private String password;// 密码
private transient String password;// 密码
private String no; // 工号
private String name; // 姓名
private String email; // 邮箱
......@@ -25,19 +25,19 @@ public class UserProfileEntity extends BaseEntity {
private String mobile; // 手机
private String userType;// 用户类型
private String loginIp; // 最后登陆IP
private Date loginDate; // 最后登陆日期
private Date loginDate; // 最后登陆日期
private String loginFlag; // 是否允许登陆
private String photo; // 头像
private String departId; //论证部门id
private String oldLoginName;// 原登录名
private String newPassword; // 新密码
private transient String oldLoginName;// 原登录名
private transient String newPassword; // 新密码
private Date createDate;
private String remarks; // 备注
private String oldLoginIp; // 上次登陆IP
private Date oldLoginDate; // 上次登陆日期
public UserProfileEntity() {
super();
this.loginFlag = GConstants.YES;
......
......@@ -21,7 +21,7 @@ public class UserSeatEntity extends BaseEntity {
private String seatHuaweiNum;
private String stationName;// 席位场站名称
private String huaweiUCAccount;
private String huaweiUCPassword;
private transient String huaweiUCPassword;
private String photo; // 头像
@JSONField(name="userCode")
......
package com.ejweb.modules.verify.api;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ejweb.core.api.RequestBean;
import com.ejweb.core.api.ResponseBean;
import com.ejweb.core.base.PageEntity;
......@@ -27,32 +8,46 @@ import com.ejweb.core.conf.GConstants;
import com.ejweb.core.file.Html2File;
import com.ejweb.core.utils.excel.ExportExcel;
import com.ejweb.modules.upload.bean.UploadFileBean;
import com.ejweb.modules.verify.bean.AirlineConclusionDetailBean;
import com.ejweb.modules.verify.bean.AirlineConclusionListBean;
import com.ejweb.modules.verify.bean.AirlineConclusionUpdateBean;
import com.ejweb.modules.verify.bean.AirlineVerifyDetailBean;
import com.ejweb.modules.verify.bean.ConclusionBackBean;
import com.ejweb.modules.verify.bean.VerifyProcessAddBean;
import com.ejweb.modules.verify.bean.*;
import com.ejweb.modules.verify.entity.AirlineConclusionDetailEntity;
import com.ejweb.modules.verify.entity.AirlineConclusionListEntity;
import com.ejweb.modules.verify.service.AirlineConclusionService;
import com.ejweb.modules.verify.service.VerifyProcessService;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 论证总结Controller
* @author lyw
*
* @author lyw
*/
@Controller
@RequestMapping("/api/airline/conclusion/")
public class AirlineConclusionController {
@Autowired
private AirlineConclusionService airlineConclusionService;
@Autowired
private VerifyProcessService verifyProcessService;
/**
* 获取论证列表
*
* @param requestBean
* @return
*/
......@@ -62,9 +57,9 @@ public class AirlineConclusionController {
ResponseBean responseBean = new ResponseBean();
AirlineConclusionListBean bean = requestBean.getObjectBean(AirlineConclusionListBean.class);
String message = airlineConclusionService.validate(bean);
if(message == null){// 通过参数校验
if (message == null) {// 通过参数校验
PageEntity<AirlineConclusionListEntity> list = airlineConclusionService.getList(bean);
if(list == null){// 查询结果为空
if (list == null) {// 查询结果为空
responseBean.setMessage(GConstants.EMPTY);
responseBean.setStatus(ErrorCode.STATUS_CODE_2001);
return responseBean;
......@@ -77,9 +72,10 @@ public class AirlineConclusionController {
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
}
/**
* 获取论证总结详情
*
* @param requestBean
* @return
*/
......@@ -89,19 +85,19 @@ public class AirlineConclusionController {
ResponseBean responseBean = new ResponseBean();
AirlineConclusionDetailBean bean = requestBean.getObjectBean(AirlineConclusionDetailBean.class);
String message = airlineConclusionService.validate(bean);
if(message == null){// 通过参数校验
if (message == null) {// 通过参数校验
AirlineConclusionDetailEntity airlineConclusionDetailEntity = airlineConclusionService.get(bean);
if(airlineConclusionDetailEntity == null){// 查询结果为空
if (airlineConclusionDetailEntity == null) {// 查询结果为空
responseBean.setMessage("查询数据为空");
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
}
List<Map<String, String>> list= airlineConclusionService.getVerifyFile(bean);
List<Map<String, String>> list = airlineConclusionService.getVerifyFile(bean);
if(list!=null&& list.size()!=0){
if (list != null && list.size() != 0) {
airlineConclusionDetailEntity.setVerifyFile(airlineConclusionService.getVerifyFile(bean));
}
responseBean.setData(airlineConclusionDetailEntity);
return responseBean;
}
......@@ -110,48 +106,49 @@ public class AirlineConclusionController {
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
}
/**
* 更新评估总结状态
*
* @param requestBean
* @return
*/
@ResponseBody
@RequestMapping("update")
public ResponseBean update(HttpServletRequest request ) {
public ResponseBean update(HttpServletRequest request) {
ResponseBean responseBean = new ResponseBean();
RequestBean requestBean=new RequestBean();
String content=request.getParameter("content");
String sign=request.getParameter("sign");
// String formText=request.getParameter("formText");
RequestBean requestBean = new RequestBean();
String content = request.getParameter("content");
String sign = request.getParameter("sign");
// String formText=request.getParameter("formText");
requestBean.setContent(content);
requestBean.setSign(sign);
AirlineConclusionUpdateBean bean = requestBean.getObjectBean(AirlineConclusionUpdateBean.class);
// bean.setFormText(formText);
// bean.setFormText(formText);
String message = airlineConclusionService.validate(bean);
if(message == null){// 通过参数校验
if (message == null) {// 通过参数校验
airlineConclusionService.update(bean);
if("1".equals(bean.getStatus())&&"02".equals(bean.getConclusionStatus())){
if ("1".equals(bean.getStatus()) && "02".equals(bean.getConclusionStatus())) {
VerifyProcessAddBean bean1 = new VerifyProcessAddBean();
bean1.setUserCode(bean.getUserCode());
bean1.setProcessValue("airline_conclusion");
bean1.setVerifId(bean.getVerifId());
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
bean1.setNodeDate(format.format(new Date()));
bean1.setNodeDate(format.format(new Date()));
bean1.setProcessDate(format.format(new Date()));
bean1.setNodeName("论证总结");
bean1.setNodeSort(7);
verifyProcessService.add(bean1);
/**
* 邮件发送 组织协调单元论证总结完成
*/
*/
airlineConclusionService.sendMail(bean.getVerifId());
}else if("1".equals(bean.getStatus())&&"03".equals(bean.getConclusionStatus())){
} else if ("1".equals(bean.getStatus()) && "03".equals(bean.getConclusionStatus())) {
airlineConclusionService.sendMailCancel(bean.getVerifId());
}
return responseBean;
}
// 参数校验为通过
......@@ -162,6 +159,7 @@ public class AirlineConclusionController {
/**
* 导出excel
*
* @author liuyw
* @time 2016年9月19日
*/
......@@ -169,10 +167,10 @@ public class AirlineConclusionController {
public void export(RequestBean requestBean, HttpServletRequest request, HttpServletResponse response) {
AirlineConclusionListBean bean = requestBean.getObjectBean(AirlineConclusionListBean.class);
String message = airlineConclusionService.validate(bean);
if(message == null){// 通过参数校验
if (message == null) {// 通过参数校验
List<AirlineConclusionListEntity> list = airlineConclusionService.getListAll(bean);
String fileName = "待论证总结"+ new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())+".xlsx";
String fileName = "待论证总结" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".xlsx";
try {
new ExportExcel("待论证总结", AirlineConclusionListEntity.class).setDataList(list).write(response, fileName).dispose();
} catch (IOException e) {
......@@ -182,70 +180,68 @@ public class AirlineConclusionController {
throw new RuntimeException(message);
}
}
@ResponseBody
@RequestMapping("download")
public void download(RequestBean requestBean,HttpServletResponse response,HttpServletRequest request){
public void download(RequestBean requestBean, HttpServletResponse response, HttpServletRequest request) {
AirlineVerifyDetailBean bean = requestBean.getObjectBean(AirlineVerifyDetailBean.class);
String formText = airlineConclusionService.getFromText(bean.getVerifId());
UploadFileBean uploadFileBean=Html2File.convertHtml2Word(formText);
InputStream in = null;
OutputStream out = null;
try {
//设置文件MIME类型
response.setContentType("application/form-data;charset=utf-8");
String filename=airlineConclusionService.getFileName(bean.getVerifId());
String downloadFileName=new String( filename.getBytes("gbk"),"ISO8859-1");
String agent = (String)request.getHeader("USER-AGENT");
if(agent != null && agent.toLowerCase().indexOf("firefox") > 0)
{
downloadFileName = "=?UTF-8?B?" + (new String(Base64.encodeBase64(filename.getBytes("UTF-8")))) + "?=";
}
//设置Content-Disposition
response.setHeader("Content-Disposition", "attachment; filename="+downloadFileName);
//获取目标文件的绝对路径
String fullFileName = GConstants.FILE_UPLOAD_DIR+uploadFileBean.getPath();
String formText = airlineConclusionService.getFromText(bean.getVerifId());
UploadFileBean uploadFileBean = Html2File.convertHtml2Word(formText);
InputStream in = null;
OutputStream out = null;
try {
//设置文件MIME类型
response.setContentType("application/form-data;charset=utf-8");
String filename = airlineConclusionService.getFileName(bean.getVerifId());
String downloadFileName = new String(filename.getBytes("gbk"), "ISO8859-1");
String agent = (String) request.getHeader("USER-AGENT");
if (agent != null && agent.toLowerCase().indexOf("firefox") > 0) {
downloadFileName = "=?UTF-8?B?" + (new String(Base64.encodeBase64(filename.getBytes("UTF-8")))) + "?=";
}
//设置Content-Disposition
response.setHeader("Content-Disposition", "attachment; filename=" + downloadFileName);
//获取目标文件的绝对路径
String fullFileName = GConstants.FILE_UPLOAD_DIR + uploadFileBean.getPath();
//读取文件
in = new FileInputStream(fullFileName);
out = response.getOutputStream();
//写文件
int b;
while ((b = in.read()) != -1) {
out.write(b);
}
} catch (Exception e) {
// TODO: handle exception
} finally {
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(out);
}
//读取文件
in = new FileInputStream(fullFileName);
out = response.getOutputStream();
//写文件
int b;
while((b=in.read())!= -1)
{
out.write(b);
}
} catch (Exception e) {
// TODO: handle exception
} finally{
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(out);
}
}
/**
* 更新评估总结状态
*
* @param requestBean
* @return
*/
@ResponseBody
@RequestMapping("back")
public ResponseBean back(RequestBean requestBean, HttpServletRequest request, HttpServletResponse response ) {
public ResponseBean back(RequestBean requestBean, HttpServletRequest request, HttpServletResponse response) {
ResponseBean responseBean = new ResponseBean();
ConclusionBackBean bean = requestBean.getObjectBean(ConclusionBackBean.class);
// bean.setFormText(formText);
// bean.setFormText(formText);
String message = airlineConclusionService.validate(bean);
if(message == null){// 通过参数校验
if (message == null) {// 通过参数校验
airlineConclusionService.updateBack(bean);
return responseBean;
}
// 参数校验为通过
......@@ -253,5 +249,5 @@ public class AirlineConclusionController {
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
}
}
......@@ -9,6 +9,7 @@ import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
......@@ -210,7 +211,7 @@ public class AirlineVerifyController {
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
} else if (!bean.getVerifyFile().get(0).getFileName().toLowerCase().endsWith("xls") && !bean.getVerifyFile().get(0).getFileName().toLowerCase().endsWith("xlsx")) {
} else if (!bean.getVerifyFile().get(0).getFileName().toLowerCase(Locale.ENGLISH).endsWith("xls") && !bean.getVerifyFile().get(0).getFileName().toLowerCase().endsWith("xlsx")) {
responseBean.setMessage("编排航班计划只支持xls,xlsx");
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
......
......@@ -10,14 +10,12 @@ import com.ejweb.modules.verify.bean.DocumentDownloadBean;
import com.ejweb.modules.verify.bean.VerifyDocumentListBean;
import com.ejweb.modules.verify.entity.VerifyDocumentListEntity;
import com.ejweb.modules.verify.service.VerifyDocumentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
......@@ -64,7 +62,7 @@ public class VerifyDocumentController {
}
@RequestMapping("downloadFiles")
public ResponseBean getVerifyFiles (RequestBean requestBean, HttpServletResponse response) {
public ResponseBean getVerifyFiles(RequestBean requestBean, HttpServletResponse response) {
ResponseBean responseBean = new ResponseBean();
DocumentDownloadBean bean = requestBean.getObjectBean(DocumentDownloadBean.class);
if (bean == null || bean.getIds() == null || bean.getIds().size() == 0) {
......@@ -78,12 +76,12 @@ public class VerifyDocumentController {
ZipOutputStream zos = null;
String fileName = "批量下载" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".zip";
try {
response.addHeader("Content-Disposition","attachment; filename=" + new String(fileName.getBytes("gbk"), "ISO8859-1"));
response.addHeader("Content-Disposition", "attachment; filename=" + new String(fileName.getBytes("gbk"), "ISO8859-1"));
zos = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
} catch (IOException e) {
e.printStackTrace();
}
byte[] bufs = new byte[1024*10];
byte[] bufs = new byte[1024 * 10];
for (VerifyDocumentListEntity entityTmp : documentListEntities) {
try {
File fTmp = new File(FileManipulation.validateFile(GConstants.FILE_UPLOAD_DIR + entityTmp.getFilePath()));
......@@ -93,12 +91,14 @@ public class VerifyDocumentController {
break;
}
ZipEntry zipEntry = new ZipEntry(entityTmp.getFileName());
zos.putNextEntry(zipEntry);
if (zos != null) {
zos.putNextEntry(zipEntry);
}
fis = new FileInputStream(fTmp);
bis = new BufferedInputStream(fis, 1024*10);
bis = new BufferedInputStream(fis, 1024 * 10);
int read = 0;
while((read=bis.read(bufs, 0, 1024*10)) != -1){
zos.write(bufs,0,read);
while ((read = bis.read(bufs, 0, 1024 * 10)) != -1) {
zos.write(bufs, 0, read);
}
} catch (IOException e) {
e.printStackTrace();
......@@ -106,9 +106,15 @@ public class VerifyDocumentController {
}
try {
if (fis != null) {fis.close();}
if (bis != null) {bis.close();}
if (zos != null) {zos.close();}
if (fis != null) {
fis.close();
}
if (bis != null) {
bis.close();
}
if (zos != null) {
zos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
......
/**
*
*
*/
package com.ejweb.modules.verify.api;
import java.io.IOException;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ejweb.core.api.RequestBean;
import com.ejweb.core.api.ResponseBean;
......@@ -26,13 +12,7 @@ import com.ejweb.core.util.IdWorker;
import com.ejweb.core.utils.excel.ExportExcel;
import com.ejweb.modules.role.bean.UserRolesBean;
import com.ejweb.modules.verify.annotation.VerifyField;
import com.ejweb.modules.verify.bean.AirlineVerifyUpdateStatusBean;
import com.ejweb.modules.verify.bean.RecordAddBean;
import com.ejweb.modules.verify.bean.VerifiedUpdateBean;
import com.ejweb.modules.verify.bean.VerifyManageAddBean;
import com.ejweb.modules.verify.bean.VerifyManageBean;
import com.ejweb.modules.verify.bean.VerifyManageUpdateBean;
import com.ejweb.modules.verify.bean.VerifyProcessAddBean;
import com.ejweb.modules.verify.bean.*;
import com.ejweb.modules.verify.entity.VerifiedDetailEntity;
import com.ejweb.modules.verify.entity.VerifyCountEntity;
import com.ejweb.modules.verify.entity.VerifyManageDetailEntity;
......@@ -41,28 +21,43 @@ import com.ejweb.modules.verify.service.AirlineVerifyService;
import com.ejweb.modules.verify.service.RecordService;
import com.ejweb.modules.verify.service.VerifyManageService;
import com.ejweb.modules.verify.service.VerifyProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 申请单管理
* @team IT Team
*
* @author zhanglg
* @version 1.0
* @time 2016年9月14日
* @team IT Team
* @time 2016年9月14日
*/
@Controller
@RequestMapping("/api/verify/manage/")
public class VerifyManageController {
@Autowired
private VerifyManageService manageService;
@Autowired
private AirlineVerifyService airLineVerifyService;
private AirlineVerifyService airLineVerifyService;
@Autowired
private RecordService recordService;
@Autowired
private VerifyProcessService verifyProcessService;
// 同步锁
private final Object mutex = new Object();
/**
* 获取论证列表
* @param requestBean
......@@ -72,11 +67,11 @@ public class VerifyManageController {
@RequestMapping("list")
public ResponseBean list(RequestBean requestBean) {
ResponseBean responseBean = new ResponseBean();
VerifyManageBean bean= requestBean.getObjectBean(VerifyManageBean.class);
VerifyManageBean bean = requestBean.getObjectBean(VerifyManageBean.class);
String message = manageService.validate(bean);
if(message == null){// 通过参数校验
if (message == null) {// 通过参数校验
PageEntity<VerifyManageEntity> list = manageService.findList(bean);
if(list == null){// 查询结果为空
if (list == null) {// 查询结果为空
responseBean.setMessage(GConstants.EMPTY);
responseBean.setStatus(ErrorCode.STATUS_CODE_2001);
return responseBean;
......@@ -89,22 +84,23 @@ public class VerifyManageController {
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
}
//编辑
@ResponseBody
@RequestMapping("update")
public ResponseBean update(RequestBean requestBean){
public ResponseBean update(RequestBean requestBean) {
ResponseBean responseBean = new ResponseBean();
VerifyManageUpdateBean managebean=requestBean.getObjectBean(VerifyManageUpdateBean.class);
VerifyManageUpdateBean managebean = requestBean.getObjectBean(VerifyManageUpdateBean.class);
String message = airLineVerifyService.validate(managebean);
if(message == null){// 通过参数校验
AirlineVerifyUpdateStatusBean bean =new AirlineVerifyUpdateStatusBean();
if (message == null) {// 通过参数校验
AirlineVerifyUpdateStatusBean bean = new AirlineVerifyUpdateStatusBean();
bean.setVerifId(managebean.getVerifId());
bean.setUserCode(managebean.getUserCode());
bean.setVerifStatus(managebean.getManageStatus());
airLineVerifyService.updateByStatus(bean);
manageService.delete_airline_verified(bean.getVerifId(),"foc_airline_verified");
manageService.delete_airline_verified(bean.getVerifId(), "foc_airline_verified");
return responseBean;
}
// 参数校验为通过
......@@ -112,19 +108,20 @@ public class VerifyManageController {
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
}
//删除
@ResponseBody
@RequestMapping("delete")
public ResponseBean delete(RequestBean requestBean){
public ResponseBean delete(RequestBean requestBean) {
ResponseBean responseBean = new ResponseBean();
VerifyManageUpdateBean bean=requestBean.getObjectBean(VerifyManageUpdateBean.class);
VerifyManageUpdateBean bean = requestBean.getObjectBean(VerifyManageUpdateBean.class);
String message = null;
if(bean.getVerifId()==null||"".equals(bean.getVerifId())){
message ="VerifId 不能为空";
if (bean.getVerifId() == null || "".equals(bean.getVerifId())) {
message = "VerifId 不能为空";
}
if(message == null){// 通过参数校验
if (message == null) {// 通过参数校验
manageService.updateDelFlag(bean.getVerifId());
// airLineVerifyService.delete(bean);
// airLineVerifyService.delete(bean);
return responseBean;
}
// 参数校验为通过
......@@ -132,157 +129,157 @@ public class VerifyManageController {
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
}
// 申请单修改
@ResponseBody
@RequestMapping("updateDetail")
public ResponseBean updateDetail(RequestBean requestBean) {
synchronized (mutex) {
ResponseBean responseBean = new ResponseBean();
VerifyManageDetailEntity bean = requestBean.getObjectBean(VerifyManageDetailEntity.class);
String message = airLineVerifyService.validate(bean);
if (message == null) {// 通过参数校验
VerifyManageDetailEntity entity = manageService.detail(bean);
if(entity==null){
responseBean.setMessage(GConstants.EMPTY);
responseBean.setStatus(ErrorCode.STATUS_CODE_2001);
return responseBean;
}
String status= manageService.verifiedStatus(bean.getId());
// 操作履历类型
String type="0";
// 联程、附件、子机型类型
String type1="2";
if("0".equals(status)){
type="2";
type1="0";
}
bean.setDelFlag(type1);
// 删除未审核记录
bean.setRecordStatus("03");
manageService.deleteRecordNew(bean);
// 删除未审核修改
// manageService.deleteChange(bean.getId());
// 删除未审核的附件修改
// manageService.delete_verify_file(bean.getId(),"foc_verify_file",type1);
// manageService.updateCheck(bean.getId(),"foc_verify_file","2", "0");
// 删除未审核的联程数据
// manageService.delete_airline_connect(bean.getId(),"foc_airline_connect",type1);
// manageService.updateCheck(bean.getId(),"foc_airline_connect","2", "0");
// 删除未审核子机型
// manageService.delete_airline_verify2type(bean.getId(),"foc_airline_verify2type",type1);
// manageService.updateCheck(bean.getId(),"foc_airline_verify2type","2", "0");
//子机型比较
VerifyManageAddBean add1=manageService.typeChange(bean,type,type1);
//联程比较
VerifyManageAddBean add2=manageService.ConnectChange(bean,type,type1);
//附件比较
VerifyManageAddBean add3=manageService.fileChange(bean,type,type1);
List<VerifyManageAddBean> list = new ArrayList<VerifyManageAddBean>();
if(add1!=null){
list.add(add1);
}
if(add2!=null){
list.add(add2);
}
if(add3!=null){
list.add(add3);
}
Field[] f2 = bean.getClass().getDeclaredFields();
for (Field field : f2) {
field.setAccessible(true);
VerifyField vf = field.getAnnotation(VerifyField.class);
if (vf != null) {
if("limitCondition".equals(vf.value())||"peopleCount".equals(vf.value())){
continue;
}
try {
String newValue=field.get(bean)==null?"":field.get(bean).toString();
String oldValue=field.get(entity)==null?"":field.get(entity).toString();
if (!oldValue.equals(newValue)) {
VerifyManageAddBean addbean = new VerifyManageAddBean();
addbean.setFieldName(vf.title());
addbean.setFieldValue(vf.value());
if("depIata".equals(vf.value())&&("06".equals(entity.getVerifType())||"07".equals(entity.getVerifType())||"08".equals(entity.getVerifType()))){
addbean.setFieldName("机场名称");
ResponseBean responseBean = new ResponseBean();
VerifyManageDetailEntity bean = requestBean.getObjectBean(VerifyManageDetailEntity.class);
String message = airLineVerifyService.validate(bean);
if (message == null) {// 通过参数校验
VerifyManageDetailEntity entity = manageService.detail(bean);
if (entity == null) {
responseBean.setMessage(GConstants.EMPTY);
responseBean.setStatus(ErrorCode.STATUS_CODE_2001);
return responseBean;
}
String status = manageService.verifiedStatus(bean.getId());
// 操作履历类型
String type = "0";
// 联程、附件、子机型类型
String type1 = "2";
if ("0".equals(status)) {
type = "2";
type1 = "0";
}
bean.setDelFlag(type1);
// 删除未审核记录
bean.setRecordStatus("03");
manageService.deleteRecordNew(bean);
// 删除未审核修改
// manageService.deleteChange(bean.getId());
// 删除未审核的附件修改
// manageService.delete_verify_file(bean.getId(),"foc_verify_file",type1);
// manageService.updateCheck(bean.getId(),"foc_verify_file","2", "0");
// 删除未审核的联程数据
// manageService.delete_airline_connect(bean.getId(),"foc_airline_connect",type1);
// manageService.updateCheck(bean.getId(),"foc_airline_connect","2", "0");
// 删除未审核子机型
// manageService.delete_airline_verify2type(bean.getId(),"foc_airline_verify2type",type1);
// manageService.updateCheck(bean.getId(),"foc_airline_verify2type","2", "0");
//子机型比较
VerifyManageAddBean add1 = manageService.typeChange(bean, type, type1);
//联程比较
VerifyManageAddBean add2 = manageService.ConnectChange(bean, type, type1);
//附件比较
VerifyManageAddBean add3 = manageService.fileChange(bean, type, type1);
List<VerifyManageAddBean> list = new ArrayList<VerifyManageAddBean>();
if (add1 != null) {
list.add(add1);
}
if (add2 != null) {
list.add(add2);
}
if (add3 != null) {
list.add(add3);
}
Field[] f2 = bean.getClass().getDeclaredFields();
for (Field field : f2) {
field.setAccessible(true);
VerifyField vf = field.getAnnotation(VerifyField.class);
if (vf != null) {
if ("limitCondition".equals(vf.value()) || "peopleCount".equals(vf.value())) {
continue;
}
try {
String newValue = field.get(bean) == null ? "" : field.get(bean).toString();
String oldValue = field.get(entity) == null ? "" : field.get(entity).toString();
if (!oldValue.equals(newValue)) {
VerifyManageAddBean addbean = new VerifyManageAddBean();
addbean.setFieldName(vf.title());
addbean.setFieldValue(vf.value());
if ("depIata".equals(vf.value()) && ("06".equals(entity.getVerifType()) || "07".equals(entity.getVerifType()) || "08".equals(entity.getVerifType()))) {
addbean.setFieldName("机场名称");
}
addbean.setId(IdWorker.getNextId());
addbean.setEditFrom(oldValue);
addbean.setEditTo(newValue);
addbean.setVerifId(bean.getId());
addbean.setUpdateBy(bean.getUserCode());
addbean.setUpdateDate(new Date());
addbean.setDelFlag(type);
list.add(addbean);
}
addbean.setId(IdWorker.getNextId());
addbean.setEditFrom(oldValue);
addbean.setEditTo(newValue);
addbean.setVerifId(bean.getId());
addbean.setUpdateBy(bean.getUserCode());
addbean.setUpdateDate(new Date());
addbean.setDelFlag(type);
list.add(addbean);
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
if(list.size()>0){
manageService.deleteChange(bean.getId());
manageService.insert(list);
}
RecordAddBean rBean=new RecordAddBean();
rBean.setRecordType("01");
rBean.setVerifId(bean.getId());
rBean.setId(IdWorker.getNextId());
rBean.setUserCode(bean.getUserCode());
recordService.insert(rBean);
// 未审核数据直接通过
if("2".equals(type)){
bean.setRecordStatus("01");
if(!entity.getStartTime().equals(bean.getStartTime())){
manageService.updateProcess(bean,false);
if (list.size() > 0) {
manageService.deleteChange(bean.getId());
manageService.insert(list);
}
RecordAddBean rBean = new RecordAddBean();
rBean.setRecordType("01");
rBean.setVerifId(bean.getId());
rBean.setId(IdWorker.getNextId());
rBean.setUserCode(bean.getUserCode());
recordService.insert(rBean);
// 未审核数据直接通过
if ("2".equals(type)) {
bean.setRecordStatus("01");
if (!entity.getStartTime().equals(bean.getStartTime())) {
manageService.updateProcess(bean, false);
}
manageService.updateRecord(bean);
manageService.updateByPrimaryKey(bean);
return responseBean;
}
manageService.updateRecord(bean);
manageService.updateByPrimaryKey(bean);
// 删除节点
manageService.deleteProcess(bean.getId(), 5);
manageService.sendnotify(bean, type);
return responseBean;
}
// 删除节点
manageService.deleteProcess(bean.getId(),5);
manageService.sendnotify(bean,type);
// 参数校验为通过
responseBean.setMessage(message);
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
}
// 参数校验为通过
responseBean.setMessage(message);
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
}
}
@RequestMapping("export")
public void export(RequestBean requestBean, HttpServletRequest request, HttpServletResponse response) {
VerifyManageBean bean= requestBean.getObjectBean(VerifyManageBean.class);
VerifyManageBean bean = requestBean.getObjectBean(VerifyManageBean.class);
String message = manageService.validate(bean);
if(message == null){// 通过参数校验
if (message == null) {// 通过参数校验
bean.setPageNo(1);
bean.setPageSize(10000);
PageEntity<VerifyManageEntity> page = manageService.findList(bean);
List<VerifyManageEntity> list =new ArrayList<VerifyManageEntity>();
if(page!=null)list=page.getList();
String fileName = "申请单管理"+ new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())+".xlsx";
List<VerifyManageEntity> list = new ArrayList<VerifyManageEntity>();
if (page != null) list = page.getList();
String fileName = "申请单管理" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".xlsx";
try {
new ExportExcel("申请单管理", VerifyManageEntity.class).setDataList(list).write(response, fileName).dispose();
} catch (IOException e) {
......@@ -291,11 +288,12 @@ public class VerifyManageController {
}
}
/**
* 回退论证模式/修改时间节点
*
*
* @author zhanglg
* @time 2016年10月10日
* @time 2016年10月10日
* @param requestBean
* @return
*/
......@@ -304,44 +302,44 @@ public class VerifyManageController {
public ResponseBean back(RequestBean requestBean) {
ResponseBean responseBean = new ResponseBean();
VerifiedUpdateBean bean= requestBean.getObjectBean(VerifiedUpdateBean.class);
VerifiedUpdateBean bean = requestBean.getObjectBean(VerifiedUpdateBean.class);
String message = manageService.validate(bean);
if(message == null){// 通过参数校验
if (message == null) {// 通过参数校验
// 判断是否处于待审核状态
VerifiedDetailEntity entity= manageService.getVerifed(bean.getVerifId());
VerifiedDetailEntity entity = manageService.getVerifed(bean.getVerifId());
// 更新开航时间节点
VerifyManageDetailEntity beand=new VerifyManageDetailEntity();
VerifyManageDetailEntity beand = new VerifyManageDetailEntity();
beand.setId(bean.getVerifId());
beand.setRecordStatus("01");
if(!entity.getSailingDate().equals(bean.getSailingDate())){
if (!entity.getSailingDate().equals(bean.getSailingDate())) {
beand.setStartTime(bean.getSailingDate());
manageService.updateProcess(beand,true);
manageService.updateProcess(beand, true);
}
// 处于待审核状态时只更新开航时间
if("00".equals(entity.getVerifiedStatus())){
if ("00".equals(entity.getVerifiedStatus())) {
// 发送论证变更邮件
manageService.sendMailChange(bean.getVerifId(),entity.getSailingDate(),bean.getSailingDate());
manageService.sendMailChange(bean.getVerifId(), entity.getSailingDate(), bean.getSailingDate());
return responseBean;
}else{
manageService.saveRecord(bean,entity);
} else {
manageService.saveRecord(bean, entity);
}
// 更新审核信息时间(初始、提交局方、截至反馈时间)
manageService.updateVerifed(bean);
// 更新反馈信息(清空论证意见,保留自定义表单)
manageService.updateRoute(bean.getVerifId(),"00");
manageService.updateRoute(bean.getVerifId(), "00");
// 风险评估信息更新
// 删除相关数据
manageService.delete(bean.getVerifId());
// 删除节点
manageService.deleteProcess(bean.getVerifId(),1);
manageService.deleteProcess(bean.getVerifId(), 1);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
VerifyProcessAddBean bean10 = new VerifyProcessAddBean();
bean10.setUserCode(bean.getUserCode());
bean10.setProcessValue("airline_verify");
......@@ -351,14 +349,14 @@ public class VerifyManageController {
bean10.setNodeName("开航时间");
bean10.setNodeSort(10);
verifyProcessService.add(bean10);
// 新增加节点
// 新增加节点
VerifyProcessAddBean bean1 = new VerifyProcessAddBean();
bean1.setUserCode(bean.getUserCode());
bean1.setProcessValue("airline_verified");
bean1.setVerifId(bean.getVerifId());
bean1.setNodeDate(bean.getMaterial());
bean1.setProcessDate(format.format(new Date()));
bean1.setNodeName("提交局方材料时间");
bean1.setNodeSort(4);
......@@ -372,7 +370,7 @@ public class VerifyManageController {
bean2.setNodeName("初始反馈时间");
bean2.setNodeSort(3);
verifyProcessService.add(bean2);
VerifyProcessAddBean bean3 = new VerifyProcessAddBean();
bean3.setUserCode(bean.getUserCode());
bean3.setProcessValue("airline_verified");
......@@ -391,9 +389,9 @@ public class VerifyManageController {
bean4.setNodeName("组织协调单元审核");
bean4.setNodeSort(2);
verifyProcessService.add(bean4);
// 发送论证变更邮件
manageService.sendMailChange(bean.getVerifId(),entity.getSailingDate(),bean.getSailingDate());
manageService.sendMailChange(bean.getVerifId(), entity.getSailingDate(), bean.getSailingDate());
return responseBean;
}
// 参数校验不为通过
......@@ -401,15 +399,16 @@ public class VerifyManageController {
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
}
@ResponseBody
@RequestMapping("getCount")
public ResponseBean getCount(RequestBean requestBean) {
ResponseBean responseBean = new ResponseBean();
UserRolesBean bean = requestBean.getObjectBean(UserRolesBean.class);
String message = airLineVerifyService.validate(bean);
if(message == null){// 通过参数校验
if (message == null) {// 通过参数校验
VerifyCountEntity entity = manageService.getCount(bean.getUserCode());
if(entity == null){// 查询结果为空
if (entity == null) {// 查询结果为空
responseBean.setMessage(GConstants.EMPTY);
responseBean.setStatus(ErrorCode.STATUS_CODE_2001);
return responseBean;
......
......@@ -5,6 +5,7 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.apache.ibatis.builder.xml.XMLMapperBuilder;
import org.apache.ibatis.executor.ErrorContext;
......@@ -177,7 +178,7 @@ public class MybatisRunnable implements java.lang.Runnable {
File file = files[i];
if (file.isDirectory()) {
refreshs.addAll(this.getRefreshFile(file, beforeTime));
} else if (file.isFile() && file.getName().toLowerCase().endsWith(".xml")) {
} else if (file.isFile() && file.getName().toLowerCase(Locale.ENGLISH).endsWith(".xml")) {
if (this.check(file, beforeTime)) {
refreshs.add(file);
}
......
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