Commit 45fc9486 authored by dahai's avatar dahai

上传查询个人邮寄信息API

上传查询XML信息
parent 6aa5dbf5
......@@ -5,7 +5,6 @@ import com.yxproject.start.entity.NewFilesEntity;
import com.yxproject.start.entity.PreproPersonEntity;
import com.yxproject.start.service.NewFilesService;
import com.yxproject.start.service.PreproPersonService;
import com.yxproject.start.utils.QuerySequenceSercive;
import org.apache.commons.lang.time.DateFormatUtils;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
......@@ -34,8 +33,6 @@ public class ExportXMLApi {
private PreproPersonService preproPersonService;
@Autowired
private NewFilesService newFilesService;
@Autowired
private QuerySequenceSercive querySequenceSercive;
/**
* 导出制证数据包
......@@ -55,7 +52,7 @@ public class ExportXMLApi {
filesEntity.setDwdm("410600000000");
filesEntity.setDwmc("北京市公安局");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddhhmmss");
filesEntity.setCreatTime(simpleDateFormat.format(new Date()));
filesEntity.setCreateTime(simpleDateFormat.format(new Date()));
try {
fout = createToMakePackageXML(preproPersonEntities, filesEntity, "\\zhang");
......
......@@ -9,9 +9,11 @@ import com.yxproject.start.utils.YXJSONResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.ibatis.annotations.Param;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
......@@ -45,7 +47,7 @@ public class ReadExcelApi {
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@Transactional(rollbackFor = Exception.class)
public boolean ReadPersonPost(HttpServletResponse resp, HttpServletRequest requ) {
public boolean ReadPersonPost(@RequestParam("formStartTime") String startDate,@RequestParam("formDeadLine") String endDate, HttpServletResponse resp, HttpServletRequest requ) {
YXJSONResponse yxresp = new YXJSONResponse();
resp.setCharacterEncoding("UTF-8");
String filename = "";
......@@ -92,18 +94,16 @@ public class ReadExcelApi {
} catch (IOException e) {
e.printStackTrace();
}
// CommonsMultipartFile cf= (CommonsMultipartFile)item;
// DiskFileItem fi = (DiskFileItem)cf.getFileItem();
// File file = fi.getStoreLocation();
ReadExcel readExcel = new ReadExcel();
List list1 = readExcel.readExcel(file);
//保存EXCEL文件信息
FileNameDicEntity fileNameDicEntity = new FileNameDicEntity();
fileNameDicEntity.setFileName(filename);
fileNameDicEntity.setUploadDate(new Date());
fileNameDicEntity.setFormStartTime(startDate);
fileNameDicEntity.setFormDeadline(endDate);
long l = fileNameDicService.saveFileNameDic(fileNameDicEntity);
//保存个人邮寄信息
// long fileID = fileNameDicService.saveFileNameDic(fileNameDicEntity);
List<PersonPostEntity> entityList = new ArrayList<>();
for (int i = 0; i < list1.size(); i++) {
PersonPostEntity personPostEntity = new PersonPostEntity();
......@@ -136,11 +136,10 @@ public class ReadExcelApi {
personPostEntity.setNatureOfTheInternal((String) list2.get(21));
personPostEntity.setNatureOfTheInformation((String) list2.get(22));
personPostEntity.setFirstWhite((String) list2.get(23));
personPostEntity.setFileId(l);
entityList.add(personPostEntity);
}
personPostService.savePersonPost(entityList);
} catch (Exception e) {
e.printStackTrace();
yxresp.outPutError("Exception", "上传文件时发生错误,非法XML文件:" + filename);
......@@ -164,4 +163,23 @@ public class ReadExcelApi {
}
return true;
}
/**
* 查询个人邮寄解析信息
* @param fileName 文件名称
* @param analysisState 解析状态
* @param currPage 当前页
* @param pageSize 每页数量
* @param resp
* @return
*/
@RequestMapping("queryPersonPost")
public String queryPersonPost(@RequestParam("fileName") String fileName,@RequestParam("analysisState") String analysisState,@RequestParam("currPage") String currPage,@RequestParam("pageSize") String pageSize, HttpServletResponse resp) {
List<FileNameDicEntity> fileNameDicEntities = fileNameDicService.queryFileNameDic(fileName, Long.valueOf(analysisState), Long.valueOf(currPage), Long.valueOf(pageSize));
YXJSONResponse yxjsonResponse = new YXJSONResponse();
resp.setCharacterEncoding("UTF-8");
yxjsonResponse.outPutSuccess(fileNameDicEntities);
return yxjsonResponse.toJSONString();
}
}
\ No newline at end of file
package com.yxproject.start.api;
import com.yxproject.start.entity.CountDataEntity;
import com.yxproject.start.entity.FilesEntity;
import com.yxproject.start.entity.PreproPersonEntity;
import com.yxproject.start.service.ImportXmlService;
......@@ -13,6 +14,7 @@ import org.dom4j.DocumentException;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
......@@ -122,5 +124,20 @@ public class ReadXmlApi {
return true;
}
/**
* 查询XML解析信息
* @param importDate 上传时间
* @param state 状态
* @param resp
* @return
*/
@RequestMapping("queryPersonXMLCount")
public String queryPersonXMLCount(@RequestParam("importDate") String importDate, @RequestParam("state") String state, HttpServletResponse resp) {
List<CountDataEntity> countDataEntities = importXmlService.queryPersonXmlCount(importDate, Long.valueOf(state));
YXJSONResponse yxjsonResponse = new YXJSONResponse();
resp.setCharacterEncoding("UTF-8");
yxjsonResponse.outPutSuccess(countDataEntities);
return yxjsonResponse.toJSONString();
}
}
......@@ -8,6 +8,7 @@ public class CountDataEntity {
private Integer cardCount;
private Integer commonCardCount;
private Integer postCardCount;
private long state;
public String getUploadDate() {
return uploadDate;
......@@ -48,4 +49,13 @@ public class CountDataEntity {
public void setPostCardCount(Integer postCardCount) {
this.postCardCount = postCardCount;
}
public long getState() {
return state;
}
public void setState(long state) {
this.state = state;
}
}
......@@ -12,7 +12,7 @@ public class FilesEntity {
private String dwdm;
private String dwmc;
private Long recordNumber;
private String creatTime;
private String createTime;
private String sourceFileName;
private Date newTime;
......@@ -57,13 +57,13 @@ public class FilesEntity {
}
@Basic
@Column(name = "CREAT_TIME")
public String getCreatTime() {
return creatTime;
@Column(name = "CREATE_TIME")
public String getCreateTime() {
return createTime;
}
public void setCreatTime(String creatTime) {
this.creatTime = creatTime;
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
@Id
......@@ -95,13 +95,13 @@ public class FilesEntity {
Objects.equals(dwdm, that.dwdm) &&
Objects.equals(dwmc, that.dwmc) &&
Objects.equals(recordNumber, that.recordNumber) &&
Objects.equals(creatTime, that.creatTime) &&
Objects.equals(createTime, that.createTime) &&
Objects.equals(sourceFileName, that.sourceFileName) &&
Objects.equals(newTime, that.newTime);
}
@Override
public int hashCode() {
return Objects.hash(versionCode, dwdm, dwmc, recordNumber, creatTime, sourceFileName, newTime);
return Objects.hash(versionCode, dwdm, dwmc, recordNumber, createTime, sourceFileName, newTime);
}
}
......@@ -2,6 +2,10 @@ package com.yxproject.start.mapper;
import com.yxproject.start.entity.FileNameDicEntity;
import org.apache.ibatis.annotations.*;
import org.hibernate.validator.constraints.SafeHtml;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @auther zhangyusheng
......@@ -9,11 +13,41 @@ import org.apache.ibatis.annotations.*;
*/
@Mapper
public interface FileNameDicMapper {
@Insert("INSERT INTO FILE_NAME_DIC (FILE_NAME,UPLOAD_DATE) VALUES (#{fileName},#{uploadDate})")
/**
* 保存个人邮寄信息字典表
* @param fileNameDicEntity
* @return
*/
@Insert("INSERT INTO FILE_NAME_DIC (FILE_NAME,UPLOAD_DATE,FORM_START_TIME,FORM_DEADLINE) VALUES (#{fileName},#{uploadDate},#{formStartTime},#{formDeadline})")
@Options(useGeneratedKeys=true, keyProperty="fileId", keyColumn="fileId")
public long saveFileNameDic(FileNameDicEntity fileNameDicEntity);
/**
* 更新个人邮寄字典表的解析状态
* 更新为已解析
* @param fileId 文件ID
* @return
*/
@Update("Updata FILE_NAME_DIC.STATE = 1 WHERE FILE_ID = #{fileId}")
public boolean updataState(@Param("fileId")String fileId);
/**
* 按条件查询个人邮寄字典表
* @param fileName 文件名称
* @param analysisState 解析状态
* @param currPage 当前页
* @param pageSize 每页数量
* @return
*/
@Select("select * from (select FILE_NAME_DIC.*,rownum rn from FILE_NAME_DIC " +
"<where> 1=1 " +
"<if test='analysisState != -1' >" +
" and STATE =#{analysisState}" +
"</if>" +
"<if test='fileName != null ' >" +
" and FILE_NAME =#{fileName}" +
"</if> </where>" +
"and ROWNUM <= 40 ) where rn>= 21")
public List<FileNameDicEntity> queryFileNameDic(@Param("fileName") String fileName, @Param("analysisState") long analysisState, @Param("currPage") long currPage, @Param("pageSize") long pageSize);
}
......@@ -2,21 +2,29 @@ package com.yxproject.start.mapper;
import com.yxproject.start.entity.CountDataEntity;
import com.yxproject.start.entity.FilesEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface FilesMapper {
@Insert("INSERT INTO FILES (VERSION_CODE,DWDM,DWMC,RECORD_NUMBER,CREAT_TIME,SOURCE_FILE_NAME)" +
"VALUES(#{versionCode},#{dwdm},#{dwmc},#{recordNumber},#{creatTime},#{sourceFileName})")
public boolean insertFiles(FilesEntity filesEntity);
@Insert("INSERT INTO FILES (VERSION_CODE,DWDM,DWMC,RECORD_NUMBER,CREATE_TIME,SOURCE_FILE_NAME)" +
"VALUES(#{versionCode},#{dwdm},#{dwmc},#{recordNumber},#{createTime},#{sourceFileName})")
@Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
public long insertFiles(FilesEntity filesEntity);
@Select("")
public List<CountDataEntity> selectFilesCount();
@Select("SELECT FILES.upload_date,count(PREPRO_PERSON.FILE_ID),count(prepro_person.JMSFZSLH) FROM PREPRO_PERSON\n" +
"left join FILES on PREPRO_PERSON.FILE_ID = FILES.ID\n" +
"<where> 1=1" +
"<if test='importDate !=null'>" +
" and to_char(FILES.UPLOAD_DATE,'yyyyMMdd')= #{importDate}" +
"</if>" +
"<if test='state !=-1'>" +
" and PREPRO_PERSON.STATE = #{state}" +
"</if> </where>" +
" group by FILES.upload_date")
public List<CountDataEntity> selectFilesCount(@Param("importDate") String importDate,@Param("state") long state);
}
......@@ -2,10 +2,27 @@ package com.yxproject.start.service;
import com.yxproject.start.entity.FileNameDicEntity;
import java.util.List;
/**
* @auther zhangyusheng
* 2019/3/1 10:42
*/
public interface FileNameDicService {
/**
* 保存个人邮寄信息字典表
* @param fileNameDicEntity
* @return
*/
public long saveFileNameDic(FileNameDicEntity fileNameDicEntity);
/**
* 查询个人邮寄信息字典表
* @param fileName 文件名称
* @param analysisState 解析状态
* @param currPage 当前页
* @param pageSize 页面数量
* @return
*/
public List<FileNameDicEntity> queryFileNameDic(String fileName, long analysisState, long currPage, long pageSize);
}
package com.yxproject.start.service;
import com.yxproject.start.entity.CountDataEntity;
import com.yxproject.start.entity.FilesEntity;
import com.yxproject.start.entity.PreproPersonEntity;
......@@ -12,4 +13,6 @@ import java.util.List;
public interface ImportXmlService {
public boolean importPersonXml(List<PreproPersonEntity> preproPersonEntities,FilesEntity filesEntity);
public List<CountDataEntity> queryPersonXmlCount(String importDate,long state);
}
package com.yxproject.start.service;
import com.yxproject.start.entity.FileNameDicEntity;
import com.yxproject.start.entity.PersonPostEntity;
import java.util.Date;
......@@ -25,5 +26,5 @@ public interface PersonPostService {
public boolean deletePersonalData(String applicantName,String orderNumber,String state,String latticeMouthInformation,List<String> getToCounty,String uploadDate);
public List<FileNameDicEntity> queryFileNameDic(String fileName, long analysisState, long currPage, long pageSize);
}
......@@ -6,6 +6,8 @@ import com.yxproject.start.service.FileNameDicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @auther zhangyusheng
* 2019/3/1 10:43
......@@ -20,4 +22,9 @@ public class FileNameDicServiceImpl implements FileNameDicService {
long fileId = fileNameDicMapper.saveFileNameDic(fileNameDicEntity);
return fileId;
}
@Override
public List<FileNameDicEntity> queryFileNameDic(String fileName, long analysisState, long currPage, long pageSize) {
return fileNameDicMapper.queryFileNameDic(fileName, analysisState, currPage, pageSize);
}
}
package com.yxproject.start.service.impl;
import com.yxproject.start.entity.CountDataEntity;
import com.yxproject.start.entity.FilesEntity;
import com.yxproject.start.entity.PreproPersonEntity;
import com.yxproject.start.mapper.FilesMapper;
......@@ -21,17 +22,25 @@ public class ImportXmlServiceImpl implements ImportXmlService {
@Autowired
private FilesMapper filesMapper;
/**
*
* @param preproPersonEntities
* @param filesEntity
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean importPersonXml(List<PreproPersonEntity> preproPersonEntities,FilesEntity filesEntity) {
filesMapper.insertFiles(filesEntity);
for (PreproPersonEntity preproPersonEntity:preproPersonEntities){
System.out.println(preproPersonEntity.getJmsfzslh()+"___________");
preproPersonMapper.savePreproPersonEntity(preproPersonEntity);
public boolean importPersonXml(List<PreproPersonEntity> preproPersonEntities, FilesEntity filesEntity) {
long l = filesMapper.insertFiles(filesEntity);
for (PreproPersonEntity preproPersonEntity : preproPersonEntities) {
preproPersonEntity.setFileId(l);
preproPersonMapper.savePreproPersonEntity(preproPersonEntity);
}
return true;
}
@Override
public List<CountDataEntity> queryPersonXmlCount(String importDate, long state) {
return filesMapper.selectFilesCount(importDate,state);
}
}
package com.yxproject.start.service.impl;
import com.yxproject.start.entity.FileNameDicEntity;
import com.yxproject.start.entity.PersonPostEntity;
import com.yxproject.start.mapper.FileNameDicMapper;
import com.yxproject.start.mapper.PersonPostMapper;
......@@ -62,5 +63,17 @@ public class PersonPostServiceImpl implements PersonPostService {
return true;
}
/**
* 查询个人邮寄信息
* @param fileName 文件名
* @param analysisState 解析时间
* @param currPage 当前页
* @param pageSize 每页数量
* @return
*/
@Override
public List<FileNameDicEntity> queryFileNameDic(String fileName, long analysisState, long currPage, long pageSize) {
return null;
}
}
package com.yxproject.start.utils;
//import com.yingxin.hibernate.domain.ProductionEntity;
import com.yxproject.start.entity.FilesEntity;
import com.yxproject.start.entity.PreproPersonEntity;
import org.dom4j.Document;
......@@ -41,7 +40,7 @@ public class IDCardFactory {
filesEntity.setDwmc(DWMC);
Date date = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddhhmmss");
filesEntity.setCreatTime(simpleDateFormat.format(date));
filesEntity.setCreateTime(simpleDateFormat.format(date));
List<Element> recordlist = records.elements("RECORD");
for (Element e : recordlist) {
......@@ -70,6 +69,7 @@ public class IDCardFactory {
preproPersonEntity.setSjrLxdh(e.element("SJR_LXDH").getStringValue());
preproPersonEntity.setSjrYzbm(e.element("SJR_YZBM").getStringValue());
preproPersonEntity.setSjrTxdz(e.element("SJR_TXDZ").getStringValue());
// preproPersonEntity.setFileId();
preproPersonEntityList.add(preproPersonEntity);
System.out.println(preproPersonEntity.getJmsfzslh()+"--------------");
}
......
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