Commit 7aa564ba by java-李谡

修复个别安全隐患

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