Commit 4a272701 authored by chase's avatar chase

fix bug

parent 1520226a
...@@ -64,19 +64,19 @@ public class TaxDocumentServiceImpl { ...@@ -64,19 +64,19 @@ public class TaxDocumentServiceImpl {
private OrganizationServiceImpl organizationService; private OrganizationServiceImpl organizationService;
public List<TaxDocument> selectTaxDocumentList(TaxDocumentDto taxDocumentDto,List<String> orgIds) { public List<TaxDocument> selectTaxDocumentList(TaxDocumentDto taxDocumentDto, List<String> orgIds) {
List<TaxDocument> dataList = taxDocumentMapper.selectByExample(getExample(taxDocumentDto,orgIds)); List<TaxDocument> dataList = taxDocumentMapper.selectByExample(getExample(taxDocumentDto, orgIds));
DidiFileIUploadParam fileParam = new DidiFileIUploadParam(); DidiFileIUploadParam fileParam = new DidiFileIUploadParam();
fileParam.setUuids(dataList.stream() fileParam.setUuids(dataList.stream()
.map(o -> o.getFileUploadId()).collect(Collectors.toList())); .map(o -> o.getFileUploadId()).collect(Collectors.toList()));
PageInfo<DidiFileUploadDetailResult> uploadDetail = didiFileUploadService.queryPage(fileParam); PageInfo<DidiFileUploadDetailResult> uploadDetail = didiFileUploadService.queryPage(fileParam);
Map<String,String> urlMap = null; Map<String, String> urlMap = null;
if(CollectionUtils.isNotEmpty(uploadDetail.getList())){ if (CollectionUtils.isNotEmpty(uploadDetail.getList())) {
urlMap = uploadDetail.getList().stream().collect(Collectors.toMap(DidiFileUploadDetailResult::getUid, didiFileUploadDetailResult -> didiFileUploadDetailResult.getViewHttpUrl())); urlMap = uploadDetail.getList().stream().collect(Collectors.toMap(DidiFileUploadDetailResult::getUid, didiFileUploadDetailResult -> didiFileUploadDetailResult.getViewHttpUrl()));
} }
if(urlMap!=null){ if (urlMap != null) {
for(TaxDocument data:dataList){ for (TaxDocument data : dataList) {
data.setFilePositionUrl(urlMap.get(data.getFileUploadId())); data.setFilePositionUrl(urlMap.get(data.getFileUploadId()));
} }
} }
...@@ -92,7 +92,7 @@ public class TaxDocumentServiceImpl { ...@@ -92,7 +92,7 @@ public class TaxDocumentServiceImpl {
* @param taxDocumentDto * @param taxDocumentDto
* @return * @return
*/ */
private TaxDocumentExample getExample(TaxDocumentDto taxDocumentDto,List<String> orgIds) { private TaxDocumentExample getExample(TaxDocumentDto taxDocumentDto, List<String> orgIds) {
TaxDocumentExample example = new TaxDocumentExample(); TaxDocumentExample example = new TaxDocumentExample();
TaxDocumentExample.Criteria criteria = example.createCriteria(); TaxDocumentExample.Criteria criteria = example.createCriteria();
criteria.andCompanyIdIn(orgIds); criteria.andCompanyIdIn(orgIds);
...@@ -173,7 +173,7 @@ public class TaxDocumentServiceImpl { ...@@ -173,7 +173,7 @@ public class TaxDocumentServiceImpl {
criteria.andCreatorLike("%" + taxDocumentDto.getCreator() + "%"); criteria.andCreatorLike("%" + taxDocumentDto.getCreator() + "%");
} }
//ids //ids
if (null!= taxDocumentDto.getIds() && taxDocumentDto.getIds().size()>0){ if (null != taxDocumentDto.getIds() && taxDocumentDto.getIds().size() > 0) {
criteria.andIdIn(taxDocumentDto.getIds()); criteria.andIdIn(taxDocumentDto.getIds());
} }
//设置查询可用的数据 //设置查询可用的数据
...@@ -186,27 +186,27 @@ public class TaxDocumentServiceImpl { ...@@ -186,27 +186,27 @@ public class TaxDocumentServiceImpl {
public synchronized boolean addTaxDocumentList(MultipartFile file, TaxDocument taxDocument) { public synchronized boolean addTaxDocumentList(MultipartFile file, TaxDocument taxDocument) {
try { try {
//上传文件 //上传文件
if(StringUtils.isBlank(taxDocument.getFileUploadId())){ if (StringUtils.isBlank(taxDocument.getFileUploadId())) {
if(ReportFileUploadEnum.ReportType.MAPPING.containsKey(taxDocument.getFileType())){ if (ReportFileUploadEnum.ReportType.MAPPING.containsKey(taxDocument.getFileType())) {
//重新命名 //重新命名
String fileName = taxDocument.getCompanyName()+"_"+taxDocument.getFileType()+"_"+taxDocument.getOwnTime(); String fileName = taxDocument.getCompanyName() + "_" + taxDocument.getFileType() + "_" + taxDocument.getOwnTime();
fileName+=file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); fileName += file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
FileUpload fileUpload = didiFileUploadService.uploadFile(file,fileName, FileUploadEnum.BizSource.RECORD_UPLOAD.name()); FileUpload fileUpload = didiFileUploadService.uploadFile(file, fileName, FileUploadEnum.BizSource.RECORD_UPLOAD.name());
taxDocument.setFileUploadId(fileUpload.getUid()); taxDocument.setFileUploadId(fileUpload.getUid());
taxDocument.setFilePositionUrl(fileUpload.getViewHttpUrl()); taxDocument.setFilePositionUrl(fileUpload.getViewHttpUrl());
taxDocument.setFileName(fileName); taxDocument.setFileName(fileName);
ReportFileUpload reportFileUpload = new ReportFileUpload(); ReportFileUpload reportFileUpload = new ReportFileUpload();
reportFileUpload.setOrgId(taxDocument.getCompanyId()); reportFileUpload.setOrgId(taxDocument.getCompanyId());
reportFileUpload.setSourceType(ReportFileUploadEnum.SuorceType.RECORD.name()); reportFileUpload.setSourceType(ReportFileUploadEnum.SuorceType.RECORD.name());
String period = String.valueOf(taxDocument.getOwnTime()).substring(0,6); String period = String.valueOf(taxDocument.getOwnTime()).substring(0, 6);
reportFileUpload.setPeriod(Integer.valueOf(period)); reportFileUpload.setPeriod(Integer.valueOf(period));
reportFileUpload.setFileUploadId(fileUpload.getUid()); reportFileUpload.setFileUploadId(fileUpload.getUid());
reportFileUpload.setReportType(taxDocument.getFileType()); reportFileUpload.setReportType(taxDocument.getFileType());
reportFileUpload.setReportFileName(fileName); reportFileUpload.setReportFileName(fileName);
reportFileUploadService.saveData(file,reportFileUpload); reportFileUploadService.saveData(file, reportFileUpload);
}else{ } else {
FileUpload fileUpload = didiFileUploadService.uploadFile(file,file.getOriginalFilename(), FileUploadEnum.BizSource.RECORD_UPLOAD.name()); FileUpload fileUpload = didiFileUploadService.uploadFile(file, file.getOriginalFilename(), FileUploadEnum.BizSource.RECORD_UPLOAD.name());
taxDocument.setFileUploadId(fileUpload.getUid()); taxDocument.setFileUploadId(fileUpload.getUid());
taxDocument.setFilePositionUrl(fileUpload.getViewHttpUrl()); taxDocument.setFilePositionUrl(fileUpload.getViewHttpUrl());
} }
...@@ -409,7 +409,7 @@ public class TaxDocumentServiceImpl { ...@@ -409,7 +409,7 @@ public class TaxDocumentServiceImpl {
} }
//创建人 creator //创建人 creator
if (StringUtils.isNotBlank(taxDocument.getCreator())) { if (StringUtils.isNotBlank(taxDocument.getCreator())) {
criteria.andCreatorEqualTo( taxDocument.getCreator()); criteria.andCreatorEqualTo(taxDocument.getCreator());
} }
//设置查询可用的数据 //设置查询可用的数据
criteria.andEnableEqualTo("T"); criteria.andEnableEqualTo("T");
...@@ -423,6 +423,7 @@ public class TaxDocumentServiceImpl { ...@@ -423,6 +423,7 @@ public class TaxDocumentServiceImpl {
return new TaxDocument(); return new TaxDocument();
} }
} }
public void downloadAllFile(HttpServletResponse response, List<Long> ids) { public void downloadAllFile(HttpServletResponse response, List<Long> ids) {
//如果只选择了一个附件,则不打包 //如果只选择了一个附件,则不打包
if (null != ids && ids.size() == 1) { if (null != ids && ids.size() == 1) {
...@@ -573,7 +574,7 @@ public class TaxDocumentServiceImpl { ...@@ -573,7 +574,7 @@ public class TaxDocumentServiceImpl {
// } // }
//检查文件名是否有重复 //检查文件名是否有重复
int fileNameRepeatTimes = 0; int fileNameRepeatTimes = 0;
if (fileNameList.size()>0){ if (fileNameList.size() > 0) {
fileNameRepeatTimes = Collections.frequency(fileNameList, item.getFileName()); fileNameRepeatTimes = Collections.frequency(fileNameList, item.getFileName());
} }
String fileName; String fileName;
...@@ -648,8 +649,9 @@ public class TaxDocumentServiceImpl { ...@@ -648,8 +649,9 @@ public class TaxDocumentServiceImpl {
} }
} }
public Map<String,Object> multipalInitData(String address) {
if (StringUtils.isBlank(address)){ public Map<String, Object> multipalInitData(String address) {
if (StringUtils.isBlank(address)) {
throw new RuntimeException("地址格式错误"); throw new RuntimeException("地址格式错误");
} }
Map<String, Object> resultMap = Maps.newHashMap(); Map<String, Object> resultMap = Maps.newHashMap();
...@@ -659,11 +661,11 @@ public class TaxDocumentServiceImpl { ...@@ -659,11 +661,11 @@ public class TaxDocumentServiceImpl {
ArrayList<String> existedFileNameList = Lists.newArrayList(); ArrayList<String> existedFileNameList = Lists.newArrayList();
//读取固定文件目录下的所有文件的文件名 //读取固定文件目录下的所有文件的文件名
File iniTfile = new File(address); File iniTfile = new File(address);
if (!iniTfile.isDirectory() || !iniTfile.exists()){ if (!iniTfile.isDirectory() || !iniTfile.exists()) {
throw new RuntimeException("文件夹地址错误"); throw new RuntimeException("文件夹地址错误");
} }
List<File> files = Arrays.asList(iniTfile.listFiles()); List<File> files = Arrays.asList(iniTfile.listFiles());
if (files.size()<1){ if (files.size() < 1) {
throw new RuntimeException("文件列表为空"); throw new RuntimeException("文件列表为空");
} }
/*List<String> fileNames = files.stream().filter(e -> e.isFile()).map(File::getName).collect(Collectors.toList()); /*List<String> fileNames = files.stream().filter(e -> e.isFile()).map(File::getName).collect(Collectors.toList());
...@@ -673,7 +675,7 @@ public class TaxDocumentServiceImpl { ...@@ -673,7 +675,7 @@ public class TaxDocumentServiceImpl {
//公司名简称和公司序号Map(name-id) //公司名简称和公司序号Map(name-id)
Map<String, String> companyNameAndId; Map<String, String> companyNameAndId;
try { try {
companyNameAndId = organizationService.findAllOrganizations().stream().collect(Collectors.toMap(Organization::getAbbreviation, Organization::getId,(value1, value2 )->{ companyNameAndId = organizationService.findAllOrganizations().stream().collect(Collectors.toMap(Organization::getAbbreviation, Organization::getId, (value1, value2) -> {
return value2; return value2;
})); }));
} catch (Exception e) { } catch (Exception e) {
...@@ -685,14 +687,15 @@ public class TaxDocumentServiceImpl { ...@@ -685,14 +687,15 @@ public class TaxDocumentServiceImpl {
//递归处理 //递归处理
recursiveSolveFile(errorFileNameList, successFileNameList, existedFileNameList, files, companyNameAndId); recursiveSolveFile(errorFileNameList, successFileNameList, existedFileNameList, files, companyNameAndId);
//返回成功列表和失败列表 //返回成功列表和失败列表
resultMap.put("successFileNameList",successFileNameList); resultMap.put("successFileNameList", successFileNameList);
resultMap.put("errorFileNameList",errorFileNameList); resultMap.put("errorFileNameList", errorFileNameList);
resultMap.put("existedFileNameList",existedFileNameList); resultMap.put("existedFileNameList", existedFileNameList);
return resultMap; return resultMap;
} }
/** /**
* 递归循环文件夹 处理 * 递归循环文件夹 处理
*
* @param errorFileNameList * @param errorFileNameList
* @param successFileNameList * @param successFileNameList
* @param existedFileNameList * @param existedFileNameList
...@@ -700,9 +703,9 @@ public class TaxDocumentServiceImpl { ...@@ -700,9 +703,9 @@ public class TaxDocumentServiceImpl {
* @param companyNameAndId * @param companyNameAndId
*/ */
private void recursiveSolveFile(ArrayList<String> errorFileNameList, ArrayList<String> successFileNameList, ArrayList<String> existedFileNameList, List<File> files, Map<String, String> companyNameAndId) { private void recursiveSolveFile(ArrayList<String> errorFileNameList, ArrayList<String> successFileNameList, ArrayList<String> existedFileNameList, List<File> files, Map<String, String> companyNameAndId) {
files.forEach(file->{ files.forEach(file -> {
if (file.isDirectory()){ if (file.isDirectory()) {
recursiveSolveFile(errorFileNameList,successFileNameList,existedFileNameList,Arrays.asList(file.listFiles()),companyNameAndId); recursiveSolveFile(errorFileNameList, successFileNameList, existedFileNameList, Arrays.asList(file.listFiles()), companyNameAndId);
return; return;
} }
String fileName = file.getName();//文件名/ String fileName = file.getName();//文件名/
...@@ -714,15 +717,15 @@ public class TaxDocumentServiceImpl { ...@@ -714,15 +717,15 @@ public class TaxDocumentServiceImpl {
} }
//根据文件名格式分割,以 "_"来分割 //根据文件名格式分割,以 "_"来分割
try { try {
List<String> params = Arrays.asList(fileName.substring(0,fileName.indexOf(".")).split("_")); List<String> params = Arrays.asList(fileName.substring(0, fileName.indexOf(".")).split("_"));
//根据分割的长度来进行匹配对比 如果长度<3或者>6或公司简称匹配不上则添加至失败列表(目前最少的是3个,若以后有更改请更改此处参数) //根据分割的长度来进行匹配对比 如果长度<3或者>6或公司简称匹配不上则添加至失败列表(目前最少的是3个,若以后有更改请更改此处参数)
if (params.size() < 3 || params.size() > 6 || !companyNameAndId.containsKey(params.get(0))) { if (params.size() < 3 || params.size() > 6 || !companyNameAndId.containsKey(params.get(0))) {
errorFileNameList.add(filePath); errorFileNameList.add(filePath);
return;//此处相当于continue return;//此处相当于continue
} }
//根据档案类型匹配并初始化值 //根据档案类型匹配并初始化值
matchFileTypeToInitData(errorFileNameList, successFileNameList, existedFileNameList, companyNameAndId, fileName, params,filePath); matchFileTypeToInitData(errorFileNameList, successFileNameList, existedFileNameList, companyNameAndId, file, params, filePath);
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
errorFileNameList.add(filePath); errorFileNameList.add(filePath);
return;//此处相当于continue return;//此处相当于continue
...@@ -935,7 +938,7 @@ public class TaxDocumentServiceImpl { ...@@ -935,7 +938,7 @@ public class TaxDocumentServiceImpl {
* *
* @return * @return
*/ */
private TaxDocument buildBaseTaxDocument(Map<String, String> companyNameAndId, List<String> params ,String fileName) { private TaxDocument buildBaseTaxDocument(Map<String, String> companyNameAndId, List<String> params, String fileName) {
TaxDocument taxDocument = new TaxDocument(); TaxDocument taxDocument = new TaxDocument();
taxDocument.setFileName(fileName); taxDocument.setFileName(fileName);
taxDocument.setCompanyId(companyNameAndId.get(params.get(0))); taxDocument.setCompanyId(companyNameAndId.get(params.get(0)));
...@@ -956,13 +959,13 @@ public class TaxDocumentServiceImpl { ...@@ -956,13 +959,13 @@ public class TaxDocumentServiceImpl {
/** /**
* 根据档案类型匹配并初始化值 * 根据档案类型匹配并初始化值
*
* @param errorFileNameList * @param errorFileNameList
* @param successeFileNameList * @param successeFileNameList
* @param companyNameAndId * @param companyNameAndId
* @param fileName
* @param params * @param params
*/ */
private void matchFileTypeToInitData(ArrayList<String> errorFileNameList, ArrayList<String> successeFileNameList, ArrayList<String> existedFileNameList, Map<String, String> companyNameAndId, String fileName, List<String> params,String filePath) { private void matchFileTypeToInitData(ArrayList<String> errorFileNameList, ArrayList<String> successeFileNameList, ArrayList<String> existedFileNameList, Map<String, String> companyNameAndId, File file, List<String> params, String filePath) {
//长度为3(先验证是否国际类型并校验匹配,若是国际类型档案类型索引为2(国际类型第三个为档案类型),否则索引为1为档案类型 //长度为3(先验证是否国际类型并校验匹配,若是国际类型档案类型索引为2(国际类型第三个为档案类型),否则索引为1为档案类型
if (params.size() == 3 if (params.size() == 3
&& (//国际类型 公司簡稱_档案属性_档案类型 && (//国际类型 公司簡稱_档案属性_档案类型
...@@ -978,93 +981,93 @@ public class TaxDocumentServiceImpl { ...@@ -978,93 +981,93 @@ public class TaxDocumentServiceImpl {
(internationalGroupOfCompanyFileAttrFileType4.keySet().contains(params.get(2)) (internationalGroupOfCompanyFileAttrFileType4.keySet().contains(params.get(2))
&& internationalGroupOfCompanyFileAttrFileType4.values().contains(params.get(1))))) { && internationalGroupOfCompanyFileAttrFileType4.values().contains(params.get(1))))) {
//构建基础对象 设置基础值 公司简称 Id 文件名 //构建基础对象 设置基础值 公司简称 Id 文件名
TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId,params,fileName); TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId, params, file.getName());
//设置档案属性 档案类型 //设置档案属性 档案类型
taxDocument.setFileAttr(params.get(1)); taxDocument.setFileAttr(params.get(1));
taxDocument.setFileType(params.get(2)); taxDocument.setFileType(params.get(2));
//校验是否已存在 //校验是否已存在
checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, fileName, taxDocument,filePath); checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, file, taxDocument, filePath);
}else if (params.size() == 3//公司簡稱_档案类型_文件生效日期 } else if (params.size() == 3//公司簡稱_档案类型_文件生效日期
&& groupOfCompanyFileTypeFIleTime.keySet().contains(params.get(1)) && groupOfCompanyFileTypeFIleTime.keySet().contains(params.get(1))
&& null != DateUtils.stringToDate4yyyyMMdd(params.get(2))){//文件生效日期校验 && null != DateUtils.stringToDate4yyyyMMdd(params.get(2))) {//文件生效日期校验
//构建基础对象 设置基础值 公司简称 Id 文件名 //构建基础对象 设置基础值 公司简称 Id 文件名
TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId,params,fileName); TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId, params, file.getName());
//设置档案属性 档案类型 文件生效日期 //设置档案属性 档案类型 文件生效日期
taxDocument.setFileType(params.get(1)); taxDocument.setFileType(params.get(1));
taxDocument.setFileAttr(groupOfCompanyFileTypeFIleTime.get(params.get(1))); taxDocument.setFileAttr(groupOfCompanyFileTypeFIleTime.get(params.get(1)));
taxDocument.setFileTime(DateUtils.stringToDate4yyyyMMdd(params.get(2))); taxDocument.setFileTime(DateUtils.stringToDate4yyyyMMdd(params.get(2)));
//校验是否已存在 //校验是否已存在
checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, fileName, taxDocument,filePath); checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, file, taxDocument, filePath);
}else if (params.size() == 3//公司簡稱_档案类型_到期日 } else if (params.size() == 3//公司簡稱_档案类型_到期日
&& groupOfCompanyFileTypeEffectiveTime.keySet().contains(params.get(1)) && groupOfCompanyFileTypeEffectiveTime.keySet().contains(params.get(1))
&& null != DateUtils.stringToDate4yyyyMMdd(params.get(2))){//到期日校验 && null != DateUtils.stringToDate4yyyyMMdd(params.get(2))) {//到期日校验
//构建基础对象 设置基础值 公司简称 Id 文件名 //构建基础对象 设置基础值 公司简称 Id 文件名
TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId,params,fileName); TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId, params, file.getName());
//设置档案属性 档案类型 到期日 //设置档案属性 档案类型 到期日
taxDocument.setFileType(params.get(1)); taxDocument.setFileType(params.get(1));
taxDocument.setFileAttr(groupOfCompanyFileTypeEffectiveTime.get(params.get(1))); taxDocument.setFileAttr(groupOfCompanyFileTypeEffectiveTime.get(params.get(1)));
taxDocument.setEffectiveTime(DateUtils.stringToDate4yyyyMMdd(params.get(2))); taxDocument.setEffectiveTime(DateUtils.stringToDate4yyyyMMdd(params.get(2)));
//校验是否已存在 //校验是否已存在
checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, fileName, taxDocument,filePath); checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, file, taxDocument, filePath);
}else if (params.size() == 4 //国际类型 公司簡稱_档案属性_档案类型_所属期间 } else if (params.size() == 4 //国际类型 公司簡稱_档案属性_档案类型_所属期间
&& (internationalGroupOfCompanyFileAttrFileTypeOwnTime.keySet().contains(params.get(2)) && (internationalGroupOfCompanyFileAttrFileTypeOwnTime.keySet().contains(params.get(2))
&& internationalGroupOfCompanyFileAttrFileTypeOwnTime.values().contains(params.get(1))) && internationalGroupOfCompanyFileAttrFileTypeOwnTime.values().contains(params.get(1)))
&& checkOwnTime(params.get(3))){//所属期间校验 && checkOwnTime(params.get(3))) {//所属期间校验
//构建基础对象 设置基础值 公司简称 Id 文件名 //构建基础对象 设置基础值 公司简称 Id 文件名
TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId,params,fileName); TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId, params, file.getName());
//设置档案属性 档案类型 所属期间 //设置档案属性 档案类型 所属期间
taxDocument.setFileAttr(params.get(1)); taxDocument.setFileAttr(params.get(1));
taxDocument.setFileType(params.get(2)); taxDocument.setFileType(params.get(2));
taxDocument.setOwnTime(Integer.valueOf(params.get(3))); taxDocument.setOwnTime(Integer.valueOf(params.get(3)));
//校验是否已存在 //校验是否已存在
checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, fileName, taxDocument,filePath); checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, file, taxDocument, filePath);
}else if (params.size() == 4 //公司簡稱_档案类型_所属期间_文件生效日期 } else if (params.size() == 4 //公司簡稱_档案类型_所属期间_文件生效日期
&& groupOfCompanyFileTypeOwnTimeFileTime.keySet().contains(params.get(1)) && groupOfCompanyFileTypeOwnTimeFileTime.keySet().contains(params.get(1))
&& checkOwnTime(params.get(2))//所属期间校验 && checkOwnTime(params.get(2))//所属期间校验
&& null != DateUtils.stringToDate4yyyyMMdd(params.get(3))){//文件生效日期校验 && null != DateUtils.stringToDate4yyyyMMdd(params.get(3))) {//文件生效日期校验
//构建基础对象 设置基础值 公司简称 Id 文件名 //构建基础对象 设置基础值 公司简称 Id 文件名
TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId,params,fileName); TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId, params, file.getName());
//设置档案类型 档案属性 所属期间 文件生效日期 //设置档案类型 档案属性 所属期间 文件生效日期
taxDocument.setFileType(params.get(1)); taxDocument.setFileType(params.get(1));
taxDocument.setFileAttr(groupOfCompanyFileTypeOwnTimeFileTime.get(params.get(1))); taxDocument.setFileAttr(groupOfCompanyFileTypeOwnTimeFileTime.get(params.get(1)));
taxDocument.setOwnTime(Integer.valueOf(params.get(2))); taxDocument.setOwnTime(Integer.valueOf(params.get(2)));
taxDocument.setFileTime(DateUtils.stringToDate4yyyyMMdd(params.get(3))); taxDocument.setFileTime(DateUtils.stringToDate4yyyyMMdd(params.get(3)));
//校验是否已存在 //校验是否已存在
checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, fileName, taxDocument,filePath); checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, file, taxDocument, filePath);
}else if (params.size() == 4 //公司簡稱_档案类型_所属期间_到期日 } else if (params.size() == 4 //公司簡稱_档案类型_所属期间_到期日
&& groupOfCompanyFileTypeOwnTimeEffectiveTime.keySet().contains(params.get(1)) && groupOfCompanyFileTypeOwnTimeEffectiveTime.keySet().contains(params.get(1))
&& checkOwnTime(params.get(2))//所属期间校验 && checkOwnTime(params.get(2))//所属期间校验
&& null != DateUtils.stringToDate4yyyyMMdd(params.get(3))){//到期日校验 && null != DateUtils.stringToDate4yyyyMMdd(params.get(3))) {//到期日校验
//构建基础对象 设置基础值 公司简称 Id 文件名 //构建基础对象 设置基础值 公司简称 Id 文件名
TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId,params,fileName); TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId, params, file.getName());
//设置档案类型 档案属性 所属期间 到期日 //设置档案类型 档案属性 所属期间 到期日
taxDocument.setFileType(params.get(1)); taxDocument.setFileType(params.get(1));
taxDocument.setFileAttr(groupOfCompanyFileTypeOwnTimeEffectiveTime.get(params.get(1))); taxDocument.setFileAttr(groupOfCompanyFileTypeOwnTimeEffectiveTime.get(params.get(1)));
taxDocument.setOwnTime(Integer.valueOf(params.get(2))); taxDocument.setOwnTime(Integer.valueOf(params.get(2)));
taxDocument.setEffectiveTime(DateUtils.stringToDate4yyyyMMdd(params.get(3))); taxDocument.setEffectiveTime(DateUtils.stringToDate4yyyyMMdd(params.get(3)));
//校验是否已存在 //校验是否已存在
checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, fileName, taxDocument,filePath); checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, file, taxDocument, filePath);
}else if (params.size() == 5 //国际类型 公司簡稱_档案属性_档案类型_税种_所属期间 } else if (params.size() == 5 //国际类型 公司簡稱_档案属性_档案类型_税种_所属期间
&& (internationalGroupOfCompanyFileAttrFileTypeTaxTypeOwnTime.keySet().contains(params.get(2)) && (internationalGroupOfCompanyFileAttrFileTypeTaxTypeOwnTime.keySet().contains(params.get(2))
&& internationalGroupOfCompanyFileAttrFileTypeTaxTypeOwnTime.values().contains(params.get(1))) && internationalGroupOfCompanyFileAttrFileTypeTaxTypeOwnTime.values().contains(params.get(1)))
&& taxsList.contains(params.get(3))//税种校验 && taxsList.contains(params.get(3))//税种校验
&& checkOwnTime(params.get(4))){//所属期间校验 && checkOwnTime(params.get(4))) {//所属期间校验
//构建基础对象 设置基础值 公司简称 Id 文件名 //构建基础对象 设置基础值 公司简称 Id 文件名
TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId,params,fileName); TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId, params, file.getName());
//设置档案属性 档案类型 税种 所属期间 //设置档案属性 档案类型 税种 所属期间
taxDocument.setFileAttr(params.get(1)); taxDocument.setFileAttr(params.get(1));
taxDocument.setFileType(params.get(2)); taxDocument.setFileType(params.get(2));
taxDocument.setTaxType(params.get(3)); taxDocument.setTaxType(params.get(3));
taxDocument.setOwnTime(Integer.valueOf(params.get(4))); taxDocument.setOwnTime(Integer.valueOf(params.get(4)));
//校验是否已存在 //校验是否已存在
checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, fileName, taxDocument,filePath); checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, file, taxDocument, filePath);
}else if (params.size() == 5 //公司簡稱_档案类型_税种_所属期间_文件生效日期 } else if (params.size() == 5 //公司簡稱_档案类型_税种_所属期间_文件生效日期
&& groupOfCompanyFileTypeTaxTypeOwnTimeFileTime.keySet().contains(params.get(1)) && groupOfCompanyFileTypeTaxTypeOwnTimeFileTime.keySet().contains(params.get(1))
&& taxsList.contains(params.get(2))//税种校验 && taxsList.contains(params.get(2))//税种校验
&& checkOwnTime(params.get(3))//所属期间校验 && checkOwnTime(params.get(3))//所属期间校验
&& null != DateUtils.stringToDate4yyyyMMdd(params.get(4))){//文件生效日期校验 && null != DateUtils.stringToDate4yyyyMMdd(params.get(4))) {//文件生效日期校验
//构建基础对象 设置基础值 公司简称 Id 文件名 //构建基础对象 设置基础值 公司简称 Id 文件名
TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId,params,fileName); TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId, params, file.getName());
//设置档案类型 档案属性 税种 所属期间 文件生效日期 //设置档案类型 档案属性 税种 所属期间 文件生效日期
taxDocument.setFileType(params.get(1)); taxDocument.setFileType(params.get(1));
taxDocument.setFileAttr(groupOfCompanyFileTypeTaxTypeOwnTimeFileTime.get(params.get(1))); taxDocument.setFileAttr(groupOfCompanyFileTypeTaxTypeOwnTimeFileTime.get(params.get(1)));
...@@ -1072,13 +1075,13 @@ public class TaxDocumentServiceImpl { ...@@ -1072,13 +1075,13 @@ public class TaxDocumentServiceImpl {
taxDocument.setOwnTime(Integer.valueOf(params.get(3))); taxDocument.setOwnTime(Integer.valueOf(params.get(3)));
taxDocument.setFileTime(DateUtils.stringToDate4yyyyMMdd(params.get(4))); taxDocument.setFileTime(DateUtils.stringToDate4yyyyMMdd(params.get(4)));
//校验是否已存在 //校验是否已存在
checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, fileName, taxDocument,filePath); checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, file, taxDocument, filePath);
}else if (params.size() == 6 //公司簡稱_档案类型_所属期间_文件生效日期_实物存放地点_实物保管人 } else if (params.size() == 6 //公司簡稱_档案类型_所属期间_文件生效日期_实物存放地点_实物保管人
&& groupOfCompanyFileTypeOwnTimeFileTimeStorageAreaKeeper.keySet().contains(params.get(1)) && groupOfCompanyFileTypeOwnTimeFileTimeStorageAreaKeeper.keySet().contains(params.get(1))
&& checkOwnTime(params.get(2))//所属期间校验 && checkOwnTime(params.get(2))//所属期间校验
&& null != DateUtils.stringToDate4yyyyMMdd(params.get(3))){//文件生效日期校验 && null != DateUtils.stringToDate4yyyyMMdd(params.get(3))) {//文件生效日期校验
//构建基础对象 设置基础值 公司简称 Id 文件名 //构建基础对象 设置基础值 公司简称 Id 文件名
TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId,params,fileName); TaxDocument taxDocument = buildBaseTaxDocument(companyNameAndId, params, file.getName());
//设置档案类型 档案属性 所属期间 文件生效日期 实物存放地点 实物保管人 //设置档案类型 档案属性 所属期间 文件生效日期 实物存放地点 实物保管人
taxDocument.setFileType(params.get(1)); taxDocument.setFileType(params.get(1));
taxDocument.setFileAttr(groupOfCompanyFileTypeOwnTimeFileTimeStorageAreaKeeper.get(params.get(1))); taxDocument.setFileAttr(groupOfCompanyFileTypeOwnTimeFileTimeStorageAreaKeeper.get(params.get(1)));
...@@ -1087,15 +1090,38 @@ public class TaxDocumentServiceImpl { ...@@ -1087,15 +1090,38 @@ public class TaxDocumentServiceImpl {
taxDocument.setStorageArea(params.get(4)); taxDocument.setStorageArea(params.get(4));
taxDocument.setKeeper(params.get(5)); taxDocument.setKeeper(params.get(5));
//校验是否已存在 //校验是否已存在
checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, fileName, taxDocument,filePath); checkExistedAndInsertOrUpdate(successeFileNameList, existedFileNameList, file, taxDocument, filePath);
}else { } else {
errorFileNameList.add(filePath); errorFileNameList.add(filePath);
} }
} }
private void checkExistedAndInsertOrUpdate(ArrayList<String> successeFileNameList, ArrayList<String> existedFileNameList, String fileName, TaxDocument taxDocument,String filePath) { private void checkExistedAndInsertOrUpdate(ArrayList<String> successeFileNameList, ArrayList<String> existedFileNameList, File file, TaxDocument taxDocument, String filePath) {
if (null == queryWhetherData(taxDocument).getId()) { if (null == queryWhetherData(taxDocument).getId()) {
//TODO 上传文件 并填充文件url 上传人等信息 //TODO 上传文件 并填充文件url 上传人等信息
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try {
fis = new FileInputStream(file);
bos = new ByteArrayOutputStream(1000);
byte[] b = new byte[1000];
int n;
while ((n = fis.read(b)) != -1) {
bos.write(b, 0, n);
}
FileUpload fileUpload = didiFileUploadService.uploadFile(bos.toByteArray(), file.getName(), FileUploadEnum.BizSource.RECORD_UPLOAD.name());
taxDocument.setFileUploadId(fileUpload.getUid());
taxDocument.setFilePositionUrl(fileUpload.getViewHttpUrl());
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fis.close();
bos.close();
} catch (Exception e) {
}
}
//插入数据 //插入数据
taxDocumentMapper.insert(taxDocument); taxDocumentMapper.insert(taxDocument);
//添加到成功列表中 //添加到成功列表中
...@@ -1109,6 +1135,7 @@ public class TaxDocumentServiceImpl { ...@@ -1109,6 +1135,7 @@ public class TaxDocumentServiceImpl {
/** /**
* 检查所属期间转换是否正常 * 检查所属期间转换是否正常
*
* @param s * @param s
* @return * @return
*/ */
......
...@@ -8,10 +8,8 @@ import com.google.common.collect.Lists; ...@@ -8,10 +8,8 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap; import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.io.FileUtils;
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.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFCell;
...@@ -26,7 +24,6 @@ import org.springframework.stereotype.Component; ...@@ -26,7 +24,6 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.multipart.MultipartHttpServletRequest;
import pwc.taxtech.atms.analysis.entity.AnalysisTax;
import pwc.taxtech.atms.common.CommonUtils; import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.POIUtil; import pwc.taxtech.atms.common.POIUtil;
import pwc.taxtech.atms.common.message.ErrorMessage; import pwc.taxtech.atms.common.message.ErrorMessage;
...@@ -61,7 +58,10 @@ import pwc.taxtech.atms.vat.service.impl.report.functions.FormulaHelper; ...@@ -61,7 +58,10 @@ import pwc.taxtech.atms.vat.service.impl.report.functions.FormulaHelper;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -71,7 +71,6 @@ import java.util.regex.Matcher; ...@@ -71,7 +71,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static pwc.taxtech.atms.common.util.FileExcelUtil.downloadExcel;
import static pwc.taxtech.atms.dto.vatdto.WrapPeriodJobDto.*; import static pwc.taxtech.atms.dto.vatdto.WrapPeriodJobDto.*;
@Component @Component
...@@ -352,17 +351,15 @@ public class ReportServiceImpl extends BaseService { ...@@ -352,17 +351,15 @@ public class ReportServiceImpl extends BaseService {
andStartDateLessThanOrEqualTo(queryDate).andEndDateGreaterThanOrEqualTo(queryDate). andStartDateLessThanOrEqualTo(queryDate).andEndDateGreaterThanOrEqualTo(queryDate).
andStatusEqualTo(0); andStatusEqualTo(0);
List<RevenueTypeMapping> mappingList = revenueTypeMappingMapper.selectByExample(mappingExample); List<RevenueTypeMapping> mappingList = revenueTypeMappingMapper.selectByExample(mappingExample);
//先清除数据
InvoiceRecord delRecord = new InvoiceRecord();
delRecord.setRevenueCofId(null);
if (!isMergeManualData) {
delRecord.setModifyRevenueCofId(null);
}
InvoiceRecordExample delExample = new InvoiceRecordExample(); InvoiceRecordExample delExample = new InvoiceRecordExample();
delExample.createCriteria().andProjectIdEqualTo(projectId) delExample.createCriteria().andProjectIdEqualTo(projectId).
.andProjectIdEqualTo(projectId).
andPeriodEqualTo(Integer.valueOf(queryDate.replace("-", ""))); andPeriodEqualTo(Integer.valueOf(queryDate.replace("-", "")));
invoiceRecordMapper.deleteByExample(delExample); if (isMergeManualData) {
invoiceRecordMapper.clearRevenueCof(true, false, delExample);
} else {
invoiceRecordMapper.clearRevenueCof(true, true, delExample);
}
Map<String, Long> map = new HashMap<>(); Map<String, Long> map = new HashMap<>();
for (RevenueTypeMapping mapping : mappingList) { for (RevenueTypeMapping mapping : mappingList) {
if (!map.containsKey(mapping.getContent())) { if (!map.containsKey(mapping.getContent())) {
......
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