Commit 018ee398 authored by chase's avatar chase

fixbug

parent 35e17785
......@@ -53,11 +53,11 @@ public class FileTypesServiceImpl {
fileTypes.setCreateTime(new Date());
fileTypes.setCreator(authUserHelper.getCurrentAuditor().get());
fileTypes.setCreatorId(authUserHelper.getCurrentUserId());
Long id = fileTypesMapper.insert(fileTypes);
if (id > 0) {
int num = fileTypesMapper.insert(fileTypes);
if (num > 0) {
OperationLogFileType actionEntity = buildOperationLogFileType();
actionEntity.setOperationAction("新增");
actionEntity.setId(id.toString());
actionEntity.setId(fileTypes.getId().toString());
actionEntity.setUpdateState(fileTypes.toString());
boolean result = operationLogFileTypeService.addFileTypesList(actionEntity);
if (result) {
......
package pwc.taxtech.atms.service.impl;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.common.AuthUserHelper;
import pwc.taxtech.atms.constant.enums.FileUploadEnum;
import pwc.taxtech.atms.constant.enums.ReportFileUploadEnum;
import pwc.taxtech.atms.dao.TaxDocumentMapper;
import pwc.taxtech.atms.dto.TaxDocumentDto;
import pwc.taxtech.atms.dto.didiFileUpload.DidiFileIUploadParam;
import pwc.taxtech.atms.dto.didiFileUpload.DidiFileUploadDetailResult;
import pwc.taxtech.atms.entity.OperationLogTaxDocument;
import pwc.taxtech.atms.entity.TaxDocument;
import pwc.taxtech.atms.entity.TaxDocumentExample;
import pwc.taxtech.atms.vat.entity.FileUpload;
import pwc.taxtech.atms.vat.entity.ReportFileUpload;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
......@@ -19,9 +28,8 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
......@@ -41,14 +49,37 @@ public class TaxDocumentServiceImpl {
@Autowired
private OperationLogTaxDocServiceImpl operationLogTaxDocService;
@Autowired
ReportFileUploadService reportFileUploadService;
@Autowired
DidiFileUploadService didiFileUploadService;
@Autowired
private OrganizationServiceImpl organizationService;
public List<TaxDocument> selectTaxDocumentList(TaxDocumentDto taxDocumentDto) {
List<TaxDocument> taxDocuments = taxDocumentMapper.selectByExample(getExample(taxDocumentDto));
return taxDocuments;
List<TaxDocument> dataList = taxDocumentMapper.selectByExample(getExample(taxDocumentDto));
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())){
urlMap = uploadDetail.getList().stream().collect(Collectors.toMap(DidiFileUploadDetailResult::getUid, didiFileUploadDetailResult -> didiFileUploadDetailResult.getViewHttpUrl()));
}
if(urlMap!=null){
for(TaxDocument data:dataList){
data.setFilePositionUrl(urlMap.get(data.getFileUploadId()));
}
}
return dataList;
}
/**
* 根据条件查询
*
......@@ -134,8 +165,24 @@ public class TaxDocumentServiceImpl {
}
@Transactional
public synchronized boolean addTaxDocumentList(TaxDocument taxDocument) {
public synchronized boolean addTaxDocumentList(MultipartFile file, TaxDocument taxDocument) {
try {
//上传文件
if(StringUtils.isBlank(taxDocument.getFileUploadId())){
FileUpload fileUpload = didiFileUploadService.uploadFile(file,file.getOriginalFilename(), FileUploadEnum.BizSource.RECORD_UPLOAD.name());
taxDocument.setFileUploadId(fileUpload.getUid());
taxDocument.setFilePositionUrl(fileUpload.getViewHttpUrl());
if(ReportFileUploadEnum.ReportType.MAPPING.containsKey(taxDocument.getFileType())){
ReportFileUpload reportFileUpload = new ReportFileUpload();
reportFileUpload.setOrgId(taxDocument.getCompanyId());
reportFileUpload.setSourceType(ReportFileUploadEnum.SuorceType.RECORD.name());
String period = String.valueOf(taxDocument.getOwnTime()).substring(0,6);
reportFileUpload.setPeriod(Integer.valueOf(period));
reportFileUpload.setFileUploadId(fileUpload.getUid());
reportFileUpload.setReportType(taxDocument.getFileType());
reportFileUploadService.saveData(file,reportFileUpload);
}
}
//设置创建人 创建时间信息 设置年份区分
taxDocument.setCreateTime(new Date());
taxDocument.setUpdateTime(new Date());
......@@ -143,12 +190,12 @@ public class TaxDocumentServiceImpl {
taxDocument.setCreatorId(authUserHelper.getCurrentUserId());
taxDocument.setUploadTime(new Date());
taxDocument.setYearRedundancy(Calendar.getInstance().get(Calendar.YEAR));
int num = taxDocumentMapper.insert(taxDocument);
//根据公司Id 设置业务线
String businessLine = organizationService.queryBusinessByCompanyId(taxDocument.getCompanyId());
if (StringUtils.isNotBlank(businessLine)) {
taxDocument.setBusinessLine(businessLine);
}
int num = taxDocumentMapper.insert(taxDocument);
if (num > 0) {
OperationLogTaxDocument actionEntity = buildOperationLogTaxDocument();
actionEntity.setId(taxDocument.getId().toString());
......@@ -232,8 +279,8 @@ public class TaxDocumentServiceImpl {
if (num > 0) {
OperationLogTaxDocument actionEntity = buildOperationLogTaxDocument();
actionEntity.setOperationAction("修改");
actionEntity.setId(taxDocument.getId().toString());
//设置更新值
actionEntity.setOriginalState(taxDocumentMapper.selectByPrimaryKey(taxDocument.getId()).toString());
actionEntity.setUpdateState(taxDocument.toString());
boolean result = operationLogTaxDocService.addTaxDocumentList(actionEntity);
if (result) {
......@@ -298,7 +345,6 @@ public class TaxDocumentServiceImpl {
return false;
}
}
public void downloadAllFile(HttpServletResponse response, List<Long> ids) {
String downloadName = "多选附件.zip";
try {
......
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