Commit 4a272701 authored by chase's avatar chase

fix bug

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