Commit f2a2d5f3 authored by dahai's avatar dahai

导入个人邮寄信息

parent b4fbca5b
package com.yxproject.start.api;
import com.yxproject.start.service.PreproPersonService;
import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Date;
/**
* @auther zhangyusheng
* 2019/3/1 11:18
*/
@RestController
@RequestMapping("exportXML")
public class ExportXMLApi {
@Autowired
private PreproPersonService preproPersonService;
/**
* 导出邮寄制证数据包
*/
@RequestMapping("printPostXmlData")
// @RequiresPermissions("userInfo.add")//权限管理;
public byte[] printXmlData(@RequestParam("date") String date, HttpServletResponse response){
response.setContentType("application/x-download");
response.setCharacterEncoding("UTF-8");
String dateTime = DateFormatUtils.format(new Date(), "yyyyMMddHH");
// //使用Servlet实现文件下载的时候,避免浏览器自动打开文件
String fout = null;
//TODO
// List<PersonPostAbnormalEntity> postAbnormalEntity = personPostService.getAllPersonPostAbnormalEntity(date);
// fout = ExportExcel.exportPersonPostAbnormalExcel(postAbnormalEntity);
String outFile = dateTime + "制证数据包";
try {
FileInputStream fis = new FileInputStream(new File(fout));
byte[] b = new byte[fis.available()];
fis.read(b);
fis.close();
response.addHeader("Content-Disposition", "attachment;filename=" + outFile + ".xml");
return b;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
package com.yxproject.start.api;
import com.yxproject.start.entity.FileNameDicEntity;
import com.yxproject.start.entity.PersonPostEntity;
import com.yxproject.start.service.FileNameDicService;
import com.yxproject.start.service.PersonPostService;
import com.yxproject.start.utils.ReadExcel;
import com.yxproject.start.utils.YXJSONResponse;
......@@ -9,6 +11,7 @@ import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -17,10 +20,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.Context;
import java.io.*;
import java.sql.Time;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
*
......@@ -33,12 +33,15 @@ public class ReadExcelApi {
@Autowired
PersonPostService personPostService;
@Autowired
FileNameDicService fileNameDicService;
Boolean result = null;
/**
* 导入个人邮寄信息表
*/
@RequestMapping("ReadPersonPost")
@Transactional(rollbackFor = Exception.class)
public String ReadPersonPost(@Context HttpServletResponse resp, @Context HttpServletRequest requ){
YXJSONResponse yxresp = new YXJSONResponse();
resp.setCharacterEncoding("UTF-8");
......@@ -71,6 +74,7 @@ public class ReadExcelApi {
// 如果fileitem中封装的是上传文件
// 得到上传的文件名称,
filename = item.getName();
if (filename == null || filename.trim().equals("")) {
continue;
}
......@@ -86,6 +90,12 @@ public class ReadExcelApi {
}
ReadExcel readExcel = new ReadExcel();
List list1 = readExcel.readExcel(file);
//保存EXCEL文件信息
FileNameDicEntity fileNameDicEntity = new FileNameDicEntity();
fileNameDicEntity.setFileName(filename);
fileNameDicEntity.setUploadDate(new Date());
//保存个人邮寄信息
long fileID = fileNameDicService.saveFileNameDic(fileNameDicEntity);
List<PersonPostEntity> entityList= new ArrayList<PersonPostEntity>();
for (int i = 0; i < list1.size(); i++){
PersonPostEntity personPostEntity = new PersonPostEntity();
......@@ -117,13 +127,12 @@ public class ReadExcelApi {
personPostEntity.setNatureOfTheInternal((String) list2.get(20));
personPostEntity.setNatureOfTheInformation((String) list2.get(21));
personPostEntity.setFirstWhite((String) list2.get(22));
personPostEntity.setFileId(fileID);
entityList.add(personPostEntity);
}
boolean b = personPostService.savePersonPost(entityList);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
yxresp.outPutError("UnsupportedEncodingException", "上传文件时发现文件编码错误:" + e.getMessage());
continue;
} catch (IOException e) {
......
package com.yxproject.start.entity;
import javax.persistence.*;
import java.sql.Time;
import java.util.Date;
import java.util.Objects;
/**
* @auther zhangyusheng
* 2019/3/1 10:39
*/
@Entity
@Table(name = "FILE_NAME_DIC", schema = "YX", catalog = "")
public class FileNameDicEntity {
private long fileId;
private String fileName;
private Date uploadDate;
private Date analysisDate;
private Date printDate;
private String formStartTime;
private String formDeadline;
@Id
@Column(name = "FILE_ID")
public long getFileId() {
return fileId;
}
public void setFileId(long fileId) {
this.fileId = fileId;
}
@Basic
@Column(name = "FILE_NAME")
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
@Basic
@Column(name = "UPLOAD_DATE")
public Date getUploadDate() {
return uploadDate;
}
public void setUploadDate(Date uploadDate) {
this.uploadDate = uploadDate;
}
@Basic
@Column(name = "ANALYSIS_DATE")
public Date getAnalysisDate() {
return analysisDate;
}
public void setAnalysisDate(Date analysisDate) {
this.analysisDate = analysisDate;
}
@Basic
@Column(name = "PRINT_DATE")
public Date getPrintDate() {
return printDate;
}
public void setPrintDate(Date printDate) {
this.printDate = printDate;
}
@Basic
@Column(name = "FORM_START_TIME")
public String getFormStartTime() {
return formStartTime;
}
public void setFormStartTime(String formStartTime) {
this.formStartTime = formStartTime;
}
@Basic
@Column(name = "FORM_DEADLINE")
public String getFormDeadline() {
return formDeadline;
}
public void setFormDeadline(String formDeadline) {
this.formDeadline = formDeadline;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FileNameDicEntity that = (FileNameDicEntity) o;
return fileId == that.fileId &&
Objects.equals(fileName, that.fileName) &&
Objects.equals(uploadDate, that.uploadDate) &&
Objects.equals(analysisDate, that.analysisDate) &&
Objects.equals(printDate, that.printDate) &&
Objects.equals(formStartTime, that.formStartTime) &&
Objects.equals(formDeadline, that.formDeadline);
}
@Override
public int hashCode() {
return Objects.hash(fileId, fileName, uploadDate, analysisDate, printDate, formStartTime, formDeadline);
}
}
......@@ -37,12 +37,7 @@ public class PersonPostEntity {
private Time validPeriodEnd;
private String note;
private Long state;
private Time uploadDate;
private Long fileId;
private Time analysisDate;
private Time printDate;
private Time formStartTime;
private Time formDeadline;
@Id
@Column(name = "WAYBILL_NUMBER")
......@@ -344,15 +339,6 @@ public class PersonPostEntity {
this.state = state;
}
@Basic
@Column(name = "UPLOAD_DATE")
public Time getUploadDate() {
return uploadDate;
}
public void setUploadDate(Time uploadDate) {
this.uploadDate = uploadDate;
}
@Basic
@Column(name = "FILE_ID")
......@@ -364,45 +350,6 @@ public class PersonPostEntity {
this.fileId = fileId;
}
@Basic
@Column(name = "ANALYSIS_DATE")
public Time getAnalysisDate() {
return analysisDate;
}
public void setAnalysisDate(Time analysisDate) {
this.analysisDate = analysisDate;
}
@Basic
@Column(name = "PRINT_DATE")
public Time getPrintDate() {
return printDate;
}
public void setPrintDate(Time printDate) {
this.printDate = printDate;
}
@Basic
@Column(name = "FORM_START_TIME")
public Time getFormStartTime() {
return formStartTime;
}
public void setFormStartTime(Time formStartTime) {
this.formStartTime = formStartTime;
}
@Basic
@Column(name = "FORM_DEADLINE")
public Time getFormDeadline() {
return formDeadline;
}
public void setFormDeadline(Time formDeadline) {
this.formDeadline = formDeadline;
}
@Override
public boolean equals(Object o) {
......@@ -439,16 +386,11 @@ public class PersonPostEntity {
Objects.equals(validPeriodEnd, that.validPeriodEnd) &&
Objects.equals(note, that.note) &&
Objects.equals(state, that.state) &&
Objects.equals(uploadDate, that.uploadDate) &&
Objects.equals(fileId, that.fileId) &&
Objects.equals(analysisDate, that.analysisDate) &&
Objects.equals(printDate, that.printDate) &&
Objects.equals(formStartTime, that.formStartTime) &&
Objects.equals(formDeadline, that.formDeadline);
Objects.equals(fileId, that.fileId) ;
}
@Override
public int hashCode() {
return Objects.hash(waybillNumber, backWaybillNumber, orderNumber, createDate, openid, wcPlayOrderNumber, playState, orderState, applicantName, senderName, senderPhone, senderAddress, recipientName, recipientPhone, recipientAddress, orderBlankNumber, getToProvince, getToCity, getToCounty, businessType, latticeMouthInformation, natureOfTheInternal, natureOfTheInformation, firstWhite, idCard, acceptTheMatter, beginUsefulLife, validPeriodEnd, note, state, uploadDate, fileId, analysisDate, printDate, formStartTime, formDeadline);
return Objects.hash(waybillNumber, backWaybillNumber, orderNumber, createDate, openid, wcPlayOrderNumber, playState, orderState, applicantName, senderName, senderPhone, senderAddress, recipientName, recipientPhone, recipientAddress, orderBlankNumber, getToProvince, getToCity, getToCounty, businessType, latticeMouthInformation, natureOfTheInternal, natureOfTheInformation, firstWhite, idCard, acceptTheMatter, beginUsefulLife, validPeriodEnd, note, state, fileId);
}
}
package com.yxproject.start.mapper;
import com.yxproject.start.entity.FileNameDicEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
/**
* @auther zhangyusheng
* 2019/3/1 10:41
*/
@Mapper
public interface FileNameDicMapper {
@Insert("INSERT INTO FILE_NAME_DIC (FILE_NAME,UPLOAD_DATE) VALUES (#{fileName},#{uploadDate})")
@Options(useGeneratedKeys=true, keyProperty="fileId", keyColumn="fileId")
public long saveFileNameDic(FileNameDicEntity fileNameDicEntity);
}
......@@ -3,8 +3,11 @@ package com.yxproject.start.mapper;
import com.yxproject.start.entity.PreproPersonEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;
/**
* Created by Administrator on 2019/2/15.
*/
......@@ -21,4 +24,13 @@ public interface PreproPersonMapper {
/*更新制证数据是否邮寄*/
@Update("UPDATE PREPRO_PERSON SET IS_POST=#{isPost} where JMSFZSLH=#{jmsfzslh}")
public boolean updatePreproPersonEntity(PreproPersonEntity personEntity);
/*按条件查询制证数据*/
@Select("select * from PREPRO_PERSON \n" +
"left join files on PREPRO_PERSON.FILE_ID = files.ID\n" +
"left join NEW_FILES on PREPRO_PERSON.FILE_ID = NEW_FILES.ID " +
"where PREPRO_PERSON.JMSFZSLH = #{uploadNo} and GMSFHM = #{IDCard}" +
//TODO
"and files.SOURCE_FILE_NAME =#{oldFile} and ")
public List<PreproPersonEntity> selectPreproPerson(String uploadNo,String IDCard,String oldFile,String newFile,String SSXQDM,String cardType,String state,String uploadDate);
}
package com.yxproject.start.service;
import com.yxproject.start.entity.FileNameDicEntity;
/**
* @auther zhangyusheng
* 2019/3/1 10:42
*/
public interface FileNameDicService {
public long saveFileNameDic(FileNameDicEntity fileNameDicEntity);
}
......@@ -13,4 +13,5 @@ public interface PersonPostService {
* 导入个人邮寄异常信息
*/
public boolean savePersonPost(List<PersonPostEntity> personPostEntities);
}
package com.yxproject.start.service;
/**
* @auther zhangyusheng
* 2019/3/1 11:24
*/
public interface PreproPersonService {
}
package com.yxproject.start.service.impl;
import com.yxproject.start.entity.FileNameDicEntity;
import com.yxproject.start.mapper.FileNameDicMapper;
import com.yxproject.start.service.FileNameDicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @auther zhangyusheng
* 2019/3/1 10:43
*/
@Service
public class FileNameDicServiceImpl implements FileNameDicService {
@Autowired
private FileNameDicMapper fileNameDicMapper;
@Override
public long saveFileNameDic(FileNameDicEntity fileNameDicEntity) {
long fileId = fileNameDicMapper.saveFileNameDic(fileNameDicEntity);
return fileId;
}
}
package com.yxproject.start.service.impl;
import com.yxproject.start.mapper.PreproPersonMapper;
import com.yxproject.start.service.PreproPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @auther zhangyusheng
* 2019/3/1 11:25
*/
@Service
public class PreproPersonServiceImpl implements PreproPersonService {
@Autowired
private PreproPersonMapper preproPersonMapper;
}
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