小虎:上传初版,还未同步到第三方hdfs文件系统上。
This commit is contained in:
parent
15318f59e2
commit
9295f04650
|
|
@ -5,7 +5,6 @@
|
|||
<th:block th:include="include :: datetimepicker-css" />
|
||||
<title>csv管理</title>
|
||||
<meta name="decorator" content="default"/>
|
||||
<link href="/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
.myTable{
|
||||
|
|
@ -45,7 +44,7 @@
|
|||
var fc = 0;
|
||||
// 原来的 "^[A-Za-z]-([0-9]{4})_([0-9]{14})_([0-9]+).csv$"
|
||||
var reg = "^[A-Z]-([A-Z0-9]{4})_([0-9]{14})(.*?).csv$";//验证文件名格式正则 如: B-3251_20171115045933_479365185.csv
|
||||
var base = "${ctx}/csvmanager/infoFlight";
|
||||
var base = "/arj21/csvmanager/qarDataImport";
|
||||
var tbody_html = "";
|
||||
var allSuccess = true;//所有上传任务都成功
|
||||
$(document).ready(function() {
|
||||
|
|
@ -126,7 +125,7 @@
|
|||
//机型
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '${ctx}/csvmanager/infoFlight/getAcTypeByArn',
|
||||
url: '/arj21/csvmanager/getAcTypeByArn',
|
||||
data: {arn:airNo},
|
||||
dataType:'json',
|
||||
cache: false,
|
||||
|
|
@ -165,7 +164,7 @@
|
|||
tbody_html += "</td>";
|
||||
tbody_html += "<td>";
|
||||
//上传人
|
||||
tbody_html +='<%=UserUtils.getUser().getName()%>';
|
||||
tbody_html +='';
|
||||
tbody_html += "</td>";
|
||||
tbody_html += "<td class=\"td_time_"+m+"\">";
|
||||
//上传时间
|
||||
|
|
@ -253,6 +252,7 @@
|
|||
//xhr.upload.addEventListener("progress", progressFunction, false);
|
||||
xhr.send(form);
|
||||
}
|
||||
|
||||
function progressFunction(evt) {
|
||||
var progressBar = $("#progressBar").find("#"+j+"barj");
|
||||
if (evt.lengthComputable) {
|
||||
|
|
@ -28,5 +28,6 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
|
|||
|
|
@ -18,5 +18,14 @@
|
|||
<groupId>cn.com.infosouth</groupId>
|
||||
<artifactId>infosouth-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 核心模块-->
|
||||
<dependency>
|
||||
<groupId>cn.com.infosouth</groupId>
|
||||
<artifactId>infosouth-framework</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -1,18 +1,19 @@
|
|||
package cn.com.infosouth.arj21.controller.csvmanager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import cn.com.infosouth.arj21.domain.InfoFlight;
|
||||
import cn.com.infosouth.arj21.service.IInfoFlightService;
|
||||
import cn.com.infosouth.common.annotation.Log;
|
||||
|
|
@ -22,9 +23,6 @@ import cn.com.infosouth.common.core.page.TableDataInfo;
|
|||
import cn.com.infosouth.common.enums.BusinessType;
|
||||
import cn.com.infosouth.common.utils.poi.ExcelUtil;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 航班信息Controller
|
||||
*
|
||||
|
|
@ -45,6 +43,35 @@ public class InfoFlightController extends BaseController {
|
|||
return prefix + "/flight";
|
||||
}
|
||||
|
||||
/**
|
||||
* @Title: getAcTypeByArn
|
||||
* @Description: TODO(根据飞机号获取机型)
|
||||
* @param: @param arn
|
||||
* @param: @return
|
||||
* @return: Map<String,Object>
|
||||
* @throws
|
||||
*/
|
||||
@RequestMapping(value = "getAcTypeByArn")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getAcTypeByArn(String arn) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("status", "1001");
|
||||
map.put("data", "");
|
||||
//String info_ac_type_id = "";
|
||||
String acType = "";
|
||||
try {
|
||||
acType = infoFlightService.getAcTypeByArn(arn);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
map.put("status", "1002");
|
||||
logger.error("-------getAcTypeByArn()--查询出错!----------");
|
||||
}
|
||||
|
||||
map.put("data", acType);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询航班信息列表
|
||||
*/
|
||||
|
|
@ -121,6 +148,7 @@ public class InfoFlightController extends BaseController {
|
|||
return toAjax(infoFlightService.deleteInfoFlightByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,350 @@
|
|||
package cn.com.infosouth.arj21.controller.csvmanager;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.InetAddress;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
||||
|
||||
import cn.com.infosouth.arj21.domain.InfoAcType;
|
||||
import cn.com.infosouth.arj21.domain.InfoAircraft;
|
||||
import cn.com.infosouth.arj21.domain.InfoFlight;
|
||||
import cn.com.infosouth.arj21.domain.InfoHeaderParams;
|
||||
import cn.com.infosouth.arj21.domain.InfoImexportLog;
|
||||
import cn.com.infosouth.arj21.domain.InfoResource;
|
||||
import cn.com.infosouth.arj21.service.IInfoAcTypeService;
|
||||
import cn.com.infosouth.arj21.service.IInfoAircraftService;
|
||||
import cn.com.infosouth.arj21.service.IInfoFlightService;
|
||||
import cn.com.infosouth.arj21.service.IInfoHeaderParamsService;
|
||||
import cn.com.infosouth.arj21.service.IInfoImexportLogService;
|
||||
import cn.com.infosouth.arj21.service.IInfoResourceService;
|
||||
import cn.com.infosouth.arj21.utils_oneselef.FileUtils;
|
||||
import cn.com.infosouth.arj21.utils_oneselef.IdGeneratorUtils;
|
||||
import cn.com.infosouth.common.core.controller.BaseController;
|
||||
import cn.com.infosouth.common.utils.StringUtils;
|
||||
import cn.com.infosouth.framework.util.ShiroUtils;
|
||||
import cn.com.infosouth.system.domain.SysUser;
|
||||
|
||||
/**
|
||||
* @author Tiger
|
||||
* @date 2020/3/6 9:32
|
||||
* @description :
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/arj21/csvmanager/qarDataImport")
|
||||
public class QARDataImportController extends BaseController {
|
||||
|
||||
private String prefix = "arj21/csvmanager";
|
||||
|
||||
@Resource
|
||||
private IInfoResourceService infoResourceService;
|
||||
@Resource
|
||||
private IInfoAircraftService infoAircraftService;
|
||||
@Resource
|
||||
private IInfoAcTypeService infoActypeSevice;
|
||||
@Resource
|
||||
private IInfoFlightService infoFlightService;
|
||||
@Resource
|
||||
private IInfoHeaderParamsService infoHeaderParamsService;
|
||||
@Resource
|
||||
private IInfoImexportLogService infoImexportLogService;
|
||||
|
||||
|
||||
@RequiresPermissions("csvmanager:qarDataImport:view")
|
||||
@RequestMapping(value = {"import", ""})
|
||||
public String _import(InfoFlight infoFlight, Model model) {
|
||||
model.addAttribute("infoFlight", infoFlight);
|
||||
return prefix + "/qarDataImport";
|
||||
}
|
||||
|
||||
@RequiresPermissions("csvmanager:qarDataImport:upload")
|
||||
@PostMapping("/upload")
|
||||
@ResponseBody
|
||||
public Map<String,String> upload(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestParam("files") MultipartFile[] files) throws IOException {
|
||||
System.out.println("");
|
||||
Enumeration<String> attributeNames = request.getSession().getAttributeNames();
|
||||
Map<String,String> returnMap = new HashMap<String, String>();
|
||||
String index = request.getParameter("index");
|
||||
if(files.length > 0){
|
||||
String message = uploadSingleFile(request,files[0]);
|
||||
returnMap.put("index", index);
|
||||
returnMap.put("message", message);
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
|
||||
private String uploadSingleFile(HttpServletRequest request,MultipartFile files) throws IOException{
|
||||
String fileName = files.getOriginalFilename();
|
||||
//设置上传文件名
|
||||
|
||||
System.out.println("01.上传文件名:"+fileName);
|
||||
//文件名js已验证
|
||||
/*if(fileName.length() <25){
|
||||
out.print("2");
|
||||
return;
|
||||
}*/
|
||||
|
||||
|
||||
//1.解析文件名中的飞机号,航班日期
|
||||
String airNo = fileName.substring(0, 6);
|
||||
//set AirNo
|
||||
|
||||
InfoAircraft air = infoAircraftService.getByAcReg(airNo);
|
||||
if(air == null){
|
||||
return "飞机号不存在";
|
||||
}
|
||||
//通过飞机号查询机型,此处测试默认CRJ-900 //TODO
|
||||
String airId = air.getId();//飞机id
|
||||
// String acTypeId = air.getInfoAcType().getId(); //"CRJ-900";//机型 (id)
|
||||
InfoAcType actype = infoActypeSevice.selectInfoAcTypeById(air.getInfoAcTypeId());
|
||||
String acTypeId = "";
|
||||
if(actype != null) {
|
||||
acTypeId = actype.getId();
|
||||
}
|
||||
|
||||
String resourceId = air.getUploadDirId();
|
||||
|
||||
String flightDateStr = fileName.substring(7, 21);
|
||||
Date flightDate = null;
|
||||
InfoResource resource = infoResourceService.selectInfoResourceById(resourceId);
|
||||
String csvPath = "";
|
||||
if(resource != null){
|
||||
csvPath = resource.getMappingPath();
|
||||
}
|
||||
try
|
||||
{
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
flightDate = sdf.parse(flightDateStr);
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
System.out.println("02.flightDateStr:"+flightDateStr);
|
||||
|
||||
InfoFlight flight = new InfoFlight();
|
||||
flight.setArn(airId);
|
||||
flight.setFlDate(flightDate);
|
||||
|
||||
String flightNo = " ";//航班号暂时默认为空
|
||||
flight.setFlNo(flightNo);
|
||||
String pod = "";//起飞机场
|
||||
String poa = "";//落地机场
|
||||
////////////////////////////////////////////////////////////正则匹配起落机场是否在CSV名中设置
|
||||
//{0}_{1}_{2}-{3}.CSV
|
||||
String pod_poa_str = fileName.substring(fileName.lastIndexOf('_')+1, fileName.lastIndexOf('.')).toUpperCase();
|
||||
String regexStr = "^([A-Z]{3,6})\\-([A-Z]{3,6})$";
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(regexStr);
|
||||
java.util.regex.Matcher matcher = pattern.matcher(pod_poa_str);
|
||||
if(matcher.find())
|
||||
{
|
||||
pod = matcher.group(1);
|
||||
poa = matcher.group(2);
|
||||
}
|
||||
|
||||
System.out.println("03.pod=" + pod + ", poa=" + poa);
|
||||
|
||||
flight.setPod(pod);
|
||||
flight.setPoa(poa);
|
||||
flight.setRemarks("");
|
||||
flight.setCsvName(fileName);
|
||||
flight.setAcType(acTypeId);
|
||||
flight.setInfoResourceId(resourceId);
|
||||
flight.setCsvPath(csvPath);//hdfs存储路径\
|
||||
|
||||
//创建导入导出日志实体类
|
||||
InfoImexportLog oprationLogBean = new InfoImexportLog();
|
||||
SysUser user = ShiroUtils.getSysUser();
|
||||
|
||||
String currentUserName = user.getLoginName();
|
||||
//机型
|
||||
|
||||
InfoAcType infoAcType = infoActypeSevice.selectInfoAcTypeById(acTypeId);
|
||||
|
||||
oprationLogBean.setCsvName(fileName);
|
||||
oprationLogBean.setArn(airNo);
|
||||
oprationLogBean.setFlDate(flightDate);
|
||||
oprationLogBean.setFlNo(flightNo);
|
||||
oprationLogBean.setCsvPath(csvPath);
|
||||
oprationLogBean.setOperateType("import");
|
||||
oprationLogBean.setOperateBy(currentUserName);
|
||||
oprationLogBean.setOperateDate(new Date());
|
||||
oprationLogBean.setAcType(infoAcType.getAcTpye());
|
||||
//设置用户的IP
|
||||
try {
|
||||
oprationLogBean.setHostIp(getClientIpAddr(request));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
boolean flag = false;
|
||||
boolean uploadflag = false;
|
||||
String fileSizeStr = "";
|
||||
//String uploadPath = request.getSession().getServletContext().getRealPath(path);
|
||||
String uploadPath = "/tmp";
|
||||
//根据机型插入机型对应的记录参数数据info_header_params
|
||||
int version = actype.getVersionId().intValue();
|
||||
InfoHeaderParams infoHeaderParams = infoHeaderParamsService.getByVersionId(version);
|
||||
if(infoHeaderParams == null || !StringUtils.isNotEmpty(infoHeaderParams.getHeaderParams())){
|
||||
String headerParams = "";
|
||||
int headerIndex = actype.getCsvHeaderIndex().intValue();
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(files.getInputStream()));
|
||||
String line = null;
|
||||
while((line=reader.readLine())!=null){
|
||||
if(headerIndex == 0){
|
||||
headerParams = line.replace("\"", "");
|
||||
break;
|
||||
}
|
||||
headerIndex--;
|
||||
}
|
||||
if(infoHeaderParams == null)
|
||||
infoHeaderParams = new InfoHeaderParams();
|
||||
infoHeaderParams.setVersionId(version + "");
|
||||
infoHeaderParams.setHeaderParams(headerParams);
|
||||
infoHeaderParams.setRemarks("");
|
||||
infoHeaderParams.setId(IdGeneratorUtils.uuid());
|
||||
infoHeaderParamsService.save(infoHeaderParams);
|
||||
} catch (Exception e) {
|
||||
//读取csv参数名行时出错...
|
||||
System.out.println("读取csv参数名行时出错...");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (files.getSize() > 0) {
|
||||
try {
|
||||
org.apache.commons.io.FileUtils.copyInputStreamToFile(files.getInputStream(),
|
||||
new File(uploadPath, files.getOriginalFilename()));//将上传的文件拷贝到上传文件临时目录
|
||||
fileSizeStr = FileUtils.getFileSizeByPath(uploadPath +"/" + files.getOriginalFilename());
|
||||
oprationLogBean.setFileSize(fileSizeStr);
|
||||
|
||||
try {
|
||||
// HDFSHandleService.uploadCSV2HDFSAsync(uploadPath +"/" + file.getOriginalFilename(), csvPath+File.separator+file.getOriginalFilename());
|
||||
//直接将file.getInputStream()上传到hdfs,上一步就不需要了
|
||||
oprationLogBean.setIsSucce("true");
|
||||
oprationLogBean.setFailType("");
|
||||
uploadflag = true;
|
||||
|
||||
System.out.println("04.uploadCSV2HDFSAsync storageFullPath=>"+ csvPath+File.separator+files.getOriginalFilename());
|
||||
} catch (Exception e) {
|
||||
System.out.println("04.catch uploadCSV2HDFSAsync error=>"+ e.getMessage());
|
||||
|
||||
System.out.println("上传失败,原因:HDFSHandleService.uploadCSV2HDFSAsync 异常:");
|
||||
oprationLogBean.setIsSucce("false");
|
||||
oprationLogBean.setFailType(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(!uploadflag){
|
||||
oprationLogBean.setIsSucce("false");
|
||||
oprationLogBean.setFailType("上传失败,原因:HDFSHandleService.uploadCSV2HDFSAsync 异常");
|
||||
}
|
||||
|
||||
boolean result =infoFlightService.csvExist(fileName);
|
||||
System.out.println("05.infoFlightService.csvExist("+ fileName + ") => return result="+result);
|
||||
|
||||
if(result){
|
||||
//已上传过
|
||||
String oldCsvId= infoFlightService.getIdByCsvName(fileName);
|
||||
flight.setId(oldCsvId);
|
||||
|
||||
flight.setUpdateDate(new Date());
|
||||
}
|
||||
flight.setCreateBy(user.getLoginName());
|
||||
flight.setId(IdGeneratorUtils.uuid());
|
||||
flight.setCreateDate(new Date());
|
||||
flight.setCreateTime(new Date());
|
||||
flight.setUpdateDate(new Date());
|
||||
flight.setUpdateTime(new Date());
|
||||
flight.setUpdateBy(user.getLoginName());
|
||||
flight.setRemarks(" ");
|
||||
flight.setDelFlag("0");
|
||||
infoFlightService.insertInfoFlight(flight);
|
||||
flag = true;
|
||||
} catch (Exception e) {
|
||||
System.out.println("上传失败:");
|
||||
oprationLogBean.setIsSucce("false");
|
||||
oprationLogBean.setFailType(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
oprationLogBean.setId(IdGeneratorUtils.uuid());
|
||||
oprationLogBean.setCreateDate(new Date());
|
||||
oprationLogBean.setCreateTime(new Date());
|
||||
oprationLogBean.setCreateBy(user.getLoginName());
|
||||
oprationLogBean.setUpdateDate(new Date());
|
||||
oprationLogBean.setUpdateTime(new Date());
|
||||
oprationLogBean.setUpdateBy(user.getLoginName());
|
||||
oprationLogBean.setRemarks(" ");
|
||||
oprationLogBean.setDelFlag("0");
|
||||
infoImexportLogService.insertInfoImexportLog(oprationLogBean);
|
||||
|
||||
}
|
||||
|
||||
if (flag == true) {
|
||||
return "1";
|
||||
} else {
|
||||
return "上传失败";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 获取客户端IP地址
|
||||
*/
|
||||
private String getClientIpAddr(HttpServletRequest request) {
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
if(ip.equals("127.0.0.1")){
|
||||
//根据网卡取本机配置的IP
|
||||
InetAddress inet=null;
|
||||
try {
|
||||
inet = InetAddress.getLocalHost();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ip= inet.getHostAddress();
|
||||
}
|
||||
}
|
||||
// 多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
|
||||
if(ip != null && ip.length() > 15){
|
||||
if(ip.indexOf(",")>0){
|
||||
ip = ip.substring(0,ip.indexOf(","));
|
||||
}
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ public class InfoAircraft extends BaseEntity
|
|||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** null */
|
||||
/** id */
|
||||
private String id;
|
||||
|
||||
/** 创建时间 */
|
||||
|
|
@ -50,6 +50,7 @@ public class InfoAircraft extends BaseEntity
|
|||
@Excel(name = "null")
|
||||
private String aircompanyid;
|
||||
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
* Copyright © 2013-2017 <a href="https://www.infosouth.com.cn/">Infosouth</a> All rights reserved.
|
||||
*/
|
||||
package cn.com.infosouth.arj21.domain;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 导入csv时不同机型对应的header参数Entity
|
||||
* @author cyh
|
||||
* @version 2018-03-06
|
||||
*/
|
||||
public class InfoHeaderParams{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String id; //id
|
||||
private String versionId; // 版本
|
||||
private String headerParams; // 参数
|
||||
private String refParams; //csv文件第一行参数
|
||||
private String remarks; //备注
|
||||
|
||||
public InfoHeaderParams() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Size(min=1, max=11, message="版本长度必须介于 1 和 11 之间")
|
||||
public String getVersionId() {
|
||||
return versionId;
|
||||
}
|
||||
|
||||
public void setVersionId(String versionId) {
|
||||
this.versionId = versionId;
|
||||
}
|
||||
|
||||
public String getHeaderParams() {
|
||||
return headerParams;
|
||||
}
|
||||
|
||||
public void setHeaderParams(String headerParams) {
|
||||
this.headerParams = headerParams;
|
||||
}
|
||||
|
||||
public String getRefParams() {
|
||||
return this.refParams;
|
||||
}
|
||||
|
||||
public void setRefParams(String refParams) {
|
||||
this.refParams = refParams;
|
||||
}
|
||||
|
||||
public String getRemarks() {
|
||||
return remarks;
|
||||
}
|
||||
|
||||
public void setRemarks(String remark) {
|
||||
this.remarks = remark;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ public class InfoImexportLog extends BaseEntity
|
|||
|
||||
/** 文件大小 */
|
||||
@Excel(name = "文件大小")
|
||||
private Long fileSize;
|
||||
private String fileSize;
|
||||
|
||||
/** 操作类型--导入,导出 */
|
||||
@Excel(name = "操作类型--导入,导出")
|
||||
|
|
@ -94,6 +94,7 @@ public class InfoImexportLog extends BaseEntity
|
|||
/** 备注 */
|
||||
@Excel(name = "备注")
|
||||
private String remarks;
|
||||
|
||||
|
||||
/** 删除标志 */
|
||||
private String delFlag;
|
||||
|
|
@ -215,12 +216,12 @@ public class InfoImexportLog extends BaseEntity
|
|||
{
|
||||
return hostIp;
|
||||
}
|
||||
public void setFileSize(Long fileSize)
|
||||
public void setFileSize(String fileSize)
|
||||
{
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
|
||||
public Long getFileSize()
|
||||
public String getFileSize()
|
||||
{
|
||||
return fileSize;
|
||||
}
|
||||
|
|
@ -316,4 +317,5 @@ public class InfoImexportLog extends BaseEntity
|
|||
.append("delFlag", getDelFlag())
|
||||
.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,4 +58,6 @@ public interface InfoAircraftMapper
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteInfoAircraftByIds(String[] ids);
|
||||
|
||||
public InfoAircraft getByAcReg(String airNo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,4 +60,15 @@ public interface InfoFlightMapper
|
|||
public int deleteInfoFlightByIds(String[] ids);
|
||||
|
||||
public String findFlightCount();
|
||||
|
||||
/**
|
||||
* 根据飞机号获得飞机机型
|
||||
* @param arn
|
||||
* @return
|
||||
*/
|
||||
public String getAcTypeByArn(String arn);
|
||||
|
||||
public int csvExist(String csvName);
|
||||
|
||||
public String getIdByCsvName(String csvName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* Copyright © 2013-2017 <a href="https://www.infosouth.com.cn/">Infosouth</a> All rights reserved.
|
||||
*/
|
||||
package cn.com.infosouth.arj21.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import cn.com.infosouth.arj21.domain.InfoHeaderParams;
|
||||
|
||||
|
||||
/**
|
||||
* 导入csv时不同机型对应的header参数DAO接口
|
||||
* @author cyh
|
||||
* @version 2018-03-06
|
||||
*/
|
||||
@Mapper
|
||||
public interface InfoHeaderParamsMapper{
|
||||
public InfoHeaderParams getByVersionId(int versionId);
|
||||
|
||||
public int addRefParams(@Param("versionId")String versionId,@Param("refParams")String refParams);
|
||||
|
||||
public String checkRefParam(@Param("versionId")String versionId,@Param("refParam")String refParams);
|
||||
|
||||
public void insert();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -58,4 +58,6 @@ public interface IInfoAircraftService
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteInfoAircraftById(String id);
|
||||
|
||||
public InfoAircraft getByAcReg(String airNo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,4 +64,17 @@ public interface IInfoFlightService
|
|||
* @return
|
||||
*/
|
||||
public String findFlightCount();
|
||||
|
||||
/**
|
||||
* 根据飞机号获取机型
|
||||
* @param arn
|
||||
* @return
|
||||
*/
|
||||
public String getAcTypeByArn(String arn);
|
||||
|
||||
public boolean csvExist(String fileName);
|
||||
|
||||
public String getIdByCsvName(String fileName);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
package cn.com.infosouth.arj21.service;
|
||||
|
||||
import cn.com.infosouth.arj21.domain.InfoHeaderParams;
|
||||
|
||||
public interface IInfoHeaderParamsService {
|
||||
|
||||
InfoHeaderParams getByVersionId(int version);
|
||||
|
||||
void save(InfoHeaderParams infoHeaderParams);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package cn.com.infosouth.arj21.service.impl;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import cn.com.infosouth.arj21.domain.InfoHeaderParams;
|
||||
import cn.com.infosouth.arj21.mapper.InfoHeaderParamsMapper;
|
||||
import cn.com.infosouth.arj21.service.IInfoHeaderParamsService;
|
||||
|
||||
@Service
|
||||
public class IInfoHeaderParamsServiceImpl implements IInfoHeaderParamsService{
|
||||
|
||||
@Resource
|
||||
private InfoHeaderParamsMapper infoHeaderParamsMapper;
|
||||
|
||||
@Override
|
||||
public InfoHeaderParams getByVersionId(int versionId) {
|
||||
return infoHeaderParamsMapper.getByVersionId(versionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(InfoHeaderParams infoHeaderParams) {
|
||||
infoHeaderParamsMapper.insert();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -91,4 +91,9 @@ public class InfoAircraftServiceImpl implements IInfoAircraftService
|
|||
{
|
||||
return infoAircraftMapper.deleteInfoAircraftById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InfoAircraft getByAcReg(String airNo) {
|
||||
return infoAircraftMapper.getByAcReg(airNo);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,4 +96,27 @@ public class InfoFlightServiceImpl implements IInfoFlightService
|
|||
public String findFlightCount() {
|
||||
return infoFlightMapper.findFlightCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAcTypeByArn(String arn) {
|
||||
return infoFlightMapper.getAcTypeByArn(arn);
|
||||
}
|
||||
|
||||
//csv文件是否已存在
|
||||
@Override
|
||||
public boolean csvExist(String csvName) {
|
||||
int count = infoFlightMapper.csvExist(csvName);
|
||||
return count > 0 ? true: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Title: getIdByCsvName
|
||||
* @Description: TODO(这里用一句话描述这个方法的作用)
|
||||
* @param: @return
|
||||
* @return: String
|
||||
* @throws
|
||||
*/
|
||||
public String getIdByCsvName(String csvName){
|
||||
return infoFlightMapper.getIdByCsvName(csvName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package cn.com.infosouth.arj21.utils_oneselef;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* 自定义文件工具类
|
||||
* @author lenove
|
||||
*
|
||||
*/
|
||||
public class FileUtils {
|
||||
|
||||
|
||||
// 将byte流输出到文件
|
||||
public static String getFileSizeByPath(String dstFilePath) {
|
||||
String fileSize = "";
|
||||
File file = null;
|
||||
try {
|
||||
file = new File(dstFilePath);
|
||||
if (!file.exists() && file.isDirectory()) {// 判断是否是文件夹
|
||||
file.mkdirs();
|
||||
System.out.println("there not exist that file" + dstFilePath);
|
||||
} else {
|
||||
fileSize = String.valueOf(file.length());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* Copyright © 2013-2017 <a href="https://www.infosouth.com.cn/">Infosouth</a> All rights reserved.
|
||||
*/
|
||||
package cn.com.infosouth.arj21.utils_oneselef;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
/**
|
||||
* 代码生成工具类
|
||||
* @author numberone
|
||||
* @version 2013-11-16
|
||||
*/
|
||||
public class IdGeneratorUtils {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(IdGeneratorUtils.class);
|
||||
|
||||
/**
|
||||
* 封装JDK自带的UUID, 通过Random数字生成, 中间无-分割.
|
||||
*/
|
||||
public static String uuid() {
|
||||
return UUID.randomUUID().toString().replaceAll("-", "");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
自己编写的工具类
|
||||
|
|
@ -17,12 +17,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="uploadDirId" column="upload_dir_id" />
|
||||
<result property="aircompanyid" column="airCompanyId" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
<sql id="infoAircraftJoins">
|
||||
left join info_ac_type b on b.id = a.info_ac_type_id
|
||||
left join info_resource c on c.id = a.upload_dir_id
|
||||
left join info_version v on b.version_id = v.id
|
||||
left join sys_office o on a.airCompanyId = o.id
|
||||
</sql>
|
||||
|
||||
<sql id="infoAircraftColumns">
|
||||
a.id AS "id",
|
||||
a.create_by AS "create_by",
|
||||
a.create_date AS "create_date",
|
||||
a.update_by AS "update_by",
|
||||
a.update_date AS "update_by",
|
||||
a.remarks AS "remarks",
|
||||
a.del_flag AS "del_flag",
|
||||
a.ac_reg AS "ac_reg",
|
||||
a.info_ac_type_id AS "info_ac_type_id",
|
||||
a.upload_dir_id AS "upload_dir_id",
|
||||
a.airCompanyId AS "airCompanyId",
|
||||
v.csv_header_index AS "infoAcType.csvHeaderIndex",
|
||||
v.csv_content_index AS "infoAcType.csvContentIndex",
|
||||
b.version_id AS "infoAcType.versionId",
|
||||
b.ac_tpye AS "infoAcType.acTpye",
|
||||
b.remarks AS "infoAcType.remarks",
|
||||
c.mapping_path AS "infoResource.mappingPath",
|
||||
c.id AS "resParentId",
|
||||
o.name AS "airCompanyName"
|
||||
</sql>
|
||||
<sql id="selectInfoAircraftVo">
|
||||
select id, create_by, create_date, update_by, update_date, remarks, del_flag, ac_reg, info_ac_type_id, upload_dir_id, airCompanyId from info_aircraft
|
||||
</sql>
|
||||
|
||||
<select id="selectInfoAircraftList" parameterType="InfoAircraft" resultMap="InfoAircraftResult">
|
||||
<select id="selectInfoAircraftList" parameterType="InfoAircraft" >
|
||||
<include refid="selectInfoAircraftVo"/>
|
||||
<where>
|
||||
<if test="acReg != null and acReg != ''"> and ac_reg = #{acReg}</if>
|
||||
|
|
@ -31,7 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectInfoAircraftById" parameterType="String" resultMap="InfoAircraftResult">
|
||||
<select id="selectInfoAircraftById" parameterType="String" >
|
||||
<include refid="selectInfoAircraftVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
|
@ -94,4 +123,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getByAcReg" resultMap="InfoAircraftResult">
|
||||
SELECT
|
||||
<include refid="infoAircraftColumns"/>
|
||||
FROM info_aircraft a
|
||||
<include refid="infoAircraftJoins"/>
|
||||
WHERE a.ac_reg = #{acReg}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -24,6 +24,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="delFlag" column="del_flag" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
<sql id="infoFlightColumns">
|
||||
a.id AS "id",
|
||||
a.fl_date AS "flDate",
|
||||
a.fl_no AS "flNo",
|
||||
<!-- a.arn AS "arId", -->
|
||||
c.ac_reg AS "arn",
|
||||
<!-- a.ac_type AS "acTypeId", -->
|
||||
d.ac_tpye AS "acType",
|
||||
a.pod AS "pod",
|
||||
a.poa AS "poa",
|
||||
a.airline AS "airline",
|
||||
a.csv_path AS "csvPath",
|
||||
a.csv_name AS "csvName",
|
||||
a.create_by AS "createBy.id",
|
||||
a.info_resource_id AS "infoResourceId",
|
||||
a.create_date AS "createDate",
|
||||
a.update_by AS "updateBy.id",
|
||||
a.update_date AS "updateDate",
|
||||
a.remarks AS "remarks",
|
||||
a.del_flag AS "delFlag"
|
||||
</sql>
|
||||
<sql id="infoFlightJoins">
|
||||
left join info_resource b
|
||||
on a.info_resource_id = b.id
|
||||
left join info_aircraft c
|
||||
on a.arn = c.id
|
||||
left join info_ac_type d
|
||||
on a.ac_type = d.id
|
||||
</sql>
|
||||
|
||||
<sql id="selectInfoFlightVo">
|
||||
select id, fl_date, fl_no, arn, ac_type, pod, poa, airline, csv_path, csv_name, info_resource_id, create_by, create_date, update_by, update_date, remarks, del_flag from info_flight
|
||||
</sql>
|
||||
|
|
@ -139,5 +170,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getAcTypeByArn" resultType="String">
|
||||
SELECT
|
||||
ac_tpye as acType
|
||||
FROM info_ac_type a left join info_aircraft b on a.id=b.info_ac_type_id
|
||||
where
|
||||
b.ac_reg=#{arn}
|
||||
and a.del_flag=0
|
||||
and b.del_flag=0
|
||||
</select>
|
||||
|
||||
<select id="csvExist" resultType="int">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
FROM info_flight a
|
||||
<include refid="infoFlightJoins"/>
|
||||
WHERE a.csv_name = #{csvName}
|
||||
and a.del_flag=0
|
||||
and b.del_flag=0
|
||||
</select>
|
||||
|
||||
<select id="getIdByCsvName" resultType="String">
|
||||
SELECT
|
||||
<include refid="infoFlightColumns"/>,
|
||||
c.ac_reg AS "arn"
|
||||
FROM info_flight a
|
||||
<include refid="infoFlightJoins"/>
|
||||
WHERE a.csv_name = #{csvName}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.com.infosouth.arj21.mapper.InfoHeaderParamsMapper">
|
||||
|
||||
<sql id="infoHeaderParamsColumns">
|
||||
a.id AS "id",
|
||||
a.version_id AS "versionId",
|
||||
a.header_params AS "headerParams",
|
||||
a.ref_params AS "refParams",
|
||||
a.create_by AS "createBy.id",
|
||||
a.create_date AS "createDate",
|
||||
a.update_by AS "updateBy.id",
|
||||
a.update_date AS "updateDate",
|
||||
a.remarks AS "remarks",
|
||||
a.del_flag AS "delFlag"
|
||||
</sql>
|
||||
|
||||
<sql id="infoHeaderParamsJoins">
|
||||
|
||||
</sql>
|
||||
|
||||
<select id="get" resultType="InfoHeaderParams">
|
||||
SELECT
|
||||
<include refid="infoHeaderParamsColumns"/>
|
||||
FROM info_header_params a
|
||||
<include refid="infoHeaderParamsJoins"/>
|
||||
WHERE a.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getByVersionId" resultType="InfoHeaderParams">
|
||||
SELECT
|
||||
<include refid="infoHeaderParamsColumns"/>
|
||||
FROM info_header_params a
|
||||
<include refid="infoHeaderParamsJoins"/>
|
||||
WHERE a.version_id = #{versionId}
|
||||
</select>
|
||||
|
||||
<select id="findList" resultType="InfoHeaderParams">
|
||||
SELECT
|
||||
<include refid="infoHeaderParamsColumns"/>
|
||||
FROM info_header_params a
|
||||
<include refid="infoHeaderParamsJoins"/>
|
||||
<where>
|
||||
a.del_flag = #{DEL_FLAG_NORMAL}
|
||||
</where>
|
||||
<choose>
|
||||
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
||||
ORDER BY ${page.orderBy}
|
||||
</when>
|
||||
<otherwise>
|
||||
ORDER BY a.update_date DESC
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<select id="findAllList" resultType="InfoHeaderParams">
|
||||
SELECT
|
||||
<include refid="infoHeaderParamsColumns"/>
|
||||
FROM info_header_params a
|
||||
<include refid="infoHeaderParamsJoins"/>
|
||||
<where>
|
||||
a.del_flag = #{DEL_FLAG_NORMAL}
|
||||
</where>
|
||||
<choose>
|
||||
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
||||
ORDER BY ${page.orderBy}
|
||||
</when>
|
||||
<otherwise>
|
||||
ORDER BY a.update_date DESC
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<select id="checkRefParam" resultType="String">
|
||||
SELECT #{refParam} param from info_header_params where version_id = #{versionId} and
|
||||
(
|
||||
find_in_set(#{refParam}, header_params)
|
||||
AND NOT find_in_set(#{refParam}, ref_params)
|
||||
)
|
||||
</select>
|
||||
|
||||
<insert id="insert">
|
||||
INSERT INTO info_header_params(
|
||||
id,
|
||||
version_id,
|
||||
header_params,
|
||||
ref_params,
|
||||
create_by,
|
||||
create_date,
|
||||
update_by,
|
||||
update_date,
|
||||
remarks,
|
||||
del_flag
|
||||
) VALUES (
|
||||
#{id},
|
||||
#{versionId},
|
||||
#{headerParams},
|
||||
'',
|
||||
#{createBy.id},
|
||||
#{createDate},
|
||||
#{updateBy.id},
|
||||
#{updateDate},
|
||||
#{remarks},
|
||||
#{delFlag}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
UPDATE info_header_params SET
|
||||
version_id = #{versionId},
|
||||
header_params = #{headerParams},
|
||||
update_by = #{updateBy.id},
|
||||
update_date = #{updateDate},
|
||||
remarks = #{remarks}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
<update id="addRefParams">
|
||||
UPDATE info_header_params SET
|
||||
ref_params = concat_ws(',',ref_params,#{refParams})
|
||||
WHERE version_id = #{versionId}
|
||||
</update>
|
||||
|
||||
<update id="delete">
|
||||
UPDATE info_header_params SET
|
||||
del_flag = #{DEL_FLAG_DELETE}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue