Commit 9f3ef673 authored by zhkwei's avatar zhkwei

CIT数据导入功能模块

parent 01a3158a
package pwc.taxtech.atms.constant.enums;
public enum EnumCitImportType {
Undefined(0),
JournalAdjust(1),
BalanceSheet(2),
RedLetterInfoTable(3),
AdjustmentTable(4),
CashFlow(5),
CoupaPurchasingReport(6),
InvoiceData(7)
;
private Integer code;
EnumCitImportType(Integer code) {
this.code = code;
}
public Integer getCode() {
return code;
}
}
...@@ -34,10 +34,7 @@ public class CitImportExcelController { ...@@ -34,10 +34,7 @@ public class CitImportExcelController {
*/ */
@RequestMapping(value = "/journalAdjustImport", method = RequestMethod.POST) @RequestMapping(value = "/journalAdjustImport", method = RequestMethod.POST)
public @ResponseBody public @ResponseBody
ApiResultDto assetsImport(@RequestParam MultipartFile file, ApiResultDto assetsImport(@RequestParam MultipartFile file,@RequestParam String periodDate,@RequestParam Integer importType){
@RequestParam String filename,
@RequestParam String tempFileName,
@RequestParam String projectId){
logger.info("CIT调整版日记账导入"); logger.info("CIT调整版日记账导入");
ApiResultDto apiResultDto = new ApiResultDto(); ApiResultDto apiResultDto = new ApiResultDto();
try{ try{
...@@ -49,16 +46,10 @@ public class CitImportExcelController { ...@@ -49,16 +46,10 @@ public class CitImportExcelController {
} }
logger.debug("file name: " + file.getOriginalFilename()); logger.debug("file name: " + file.getOriginalFilename());
InputStream input = null; InputStream input = null;
try {
input = file.getInputStream(); input = file.getInputStream();
//调用资产导入业务逻辑 //调用资产导入业务逻辑
citImportExcelService.importJournalAdjust(input, file.getOriginalFilename(), periodDate, importType);
} catch (IOException e) {
apiResultDto.setCode(-2);
apiResultDto.setMessage("获取文件流失败");
logger.warn("获取文件流失败");
return apiResultDto;
}
apiResultDto.setCode(1); apiResultDto.setCode(1);
apiResultDto.setMessage("资产导入成功"); apiResultDto.setMessage("资产导入成功");
......
...@@ -17,6 +17,7 @@ import pwc.taxtech.atms.common.message.ErrorMessage; ...@@ -17,6 +17,7 @@ import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.common.message.ErrorMessageCN; import pwc.taxtech.atms.common.message.ErrorMessageCN;
import pwc.taxtech.atms.common.util.DateUtils; import pwc.taxtech.atms.common.util.DateUtils;
import pwc.taxtech.atms.constant.Constant; import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.constant.enums.EnumCitImportType;
import pwc.taxtech.atms.constant.enums.EnumImportType; import pwc.taxtech.atms.constant.enums.EnumImportType;
import pwc.taxtech.atms.constant.enums.EnumTbImportType; import pwc.taxtech.atms.constant.enums.EnumTbImportType;
import pwc.taxtech.atms.dao.*; import pwc.taxtech.atms.dao.*;
...@@ -68,7 +69,7 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -68,7 +69,7 @@ public class CitImportExcelServiceImpl extends BaseService {
* @throws InvalidFormatException * @throws InvalidFormatException
* @throws ParseException * @throws ParseException
*/ */
public OperationResultDto importJournalAdjust(InputStream inputStream, String fileName, Integer importType) throws IOException, InvalidFormatException, ParseException { public OperationResultDto importJournalAdjust(InputStream inputStream, String fileName, String periodDate, Integer importType) throws IOException, InvalidFormatException, ParseException {
OperationResultDto<Object> saveResult = new OperationResultDto<>(); OperationResultDto<Object> saveResult = new OperationResultDto<>();
Workbook workbook = fileService.getWorkbook(inputStream, fileName, "citJournalAdjust"); Workbook workbook = fileService.getWorkbook(inputStream, fileName, "citJournalAdjust");
if(workbook == null){ if(workbook == null){
...@@ -85,6 +86,7 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -85,6 +86,7 @@ public class CitImportExcelServiceImpl extends BaseService {
} }
List<CitJournalEntryAdjust> journalAdjustList = new ArrayList<>(); List<CitJournalEntryAdjust> journalAdjustList = new ArrayList<>();
List<CitDataImportLog> citDataImportLogList = new ArrayList<>();
Integer period = new Integer(CitCommonUtil.getValue(sheet.getRow(1).getCell(2)).toString().replace("-", "")); Integer period = new Integer(CitCommonUtil.getValue(sheet.getRow(1).getCell(2)).toString().replace("-", ""));
String companyName = CitCommonUtil.getValue(sheet.getRow(1).getCell(17)).toString(); String companyName = CitCommonUtil.getValue(sheet.getRow(1).getCell(17)).toString();
String companyCode = CitCommonUtil.getValue(sheet.getRow(1).getCell(9)).toString();; String companyCode = CitCommonUtil.getValue(sheet.getRow(1).getCell(9)).toString();;
...@@ -119,10 +121,15 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -119,10 +121,15 @@ public class CitImportExcelServiceImpl extends BaseService {
} }
int insertBatchNum = citJournalEntryAdjustMapper.insertBatch(journalAdjustList); int insertBatchNum = citJournalEntryAdjustMapper.insertBatch(journalAdjustList);
CitDataImportLog citDataImportLog = generalCitDataImportLog(companyCode, orgId, taxPayerId, CitDataImportLog citDataImportLog = generalCitDataImportLog(companyCode, orgId, taxPayerId,
EnumImportType.CashFlow.getCode(), period / 100, EnumCitImportType.JournalAdjust.getCode(), period / 100,
0, period % 100, 0, period % 100,
companyName, "1"); companyName, "日记账调整");
citDataImportLog.setRecordSize(insertBatchNum); citDataImportLog.setRecordSize(insertBatchNum);
citDataImportLogList.add(citDataImportLog);
if(EnumTbImportType.CoverImport.getCode().equals(importType)){
updateImportLog(1);
}
addDataImportLog(citDataImportLogList);
return null; return null;
} }
...@@ -147,7 +154,7 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -147,7 +154,7 @@ public class CitImportExcelServiceImpl extends BaseService {
* @throws InvalidFormatException * @throws InvalidFormatException
* @throws ParseException * @throws ParseException
*/ */
public OperationResultDto importTrialBalance(InputStream inputStream, String fileName, Integer importType) throws IOException, InvalidFormatException, ParseException { public OperationResultDto importTrialBalance(InputStream inputStream, String fileName, String periodDate, Integer importType) throws IOException, InvalidFormatException, ParseException {
OperationResultDto<Object> saveResult = new OperationResultDto<>(); OperationResultDto<Object> saveResult = new OperationResultDto<>();
Workbook workbook = fileService.getWorkbook(inputStream, fileName, "citTrialBalance"); Workbook workbook = fileService.getWorkbook(inputStream, fileName, "citTrialBalance");
if(workbook == null){ if(workbook == null){
...@@ -261,9 +268,14 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -261,9 +268,14 @@ public class CitImportExcelServiceImpl extends BaseService {
} }
private int updateImportLog(Integer type){
int updateDisplayOld = citDataImportLogMapper.updateDisplayOld(type);
return updateDisplayOld;
}
private int addDataImportLog(List<CitDataImportLog> dataImportLogs) { private int addDataImportLog(List<CitDataImportLog> dataImportLogs) {
//在添加import log前先将原来导入的数据版本置为旧版本 //在添加import log前先将原来导入的数据版本置为旧版本
citDataImportLogMapper.updateDisplayOld(dataImportLogs.get(0).getType()); // citDataImportLogMapper.updateDisplayOld(dataImportLogs.get(0).getType());
int res = 0; int res = 0;
for (CitDataImportLog dataImportLog : dataImportLogs) { for (CitDataImportLog dataImportLog : dataImportLogs) {
res += citDataImportLogMapper.insertSelective(dataImportLog); res += citDataImportLogMapper.insertSelective(dataImportLog);
......
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