Commit 0bf47e57 authored by neo's avatar neo

[DEV] input invoice get item impl

parent d9a990d2
......@@ -4,23 +4,35 @@ import org.apache.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import pwc.taxtech.atms.dto.PagingResultDto;
import pwc.taxtech.atms.dto.vatdto.*;
import pwc.taxtech.atms.dto.vatdto.InputInvoicePreviewQueryParam;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceBaseDto;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceDto;
import pwc.taxtech.atms.thirdparty.ExcelSheet;
import pwc.taxtech.atms.thirdparty.ExcelUtil;
import pwc.taxtech.atms.vat.service.InputInvoiceDataImportService;
import pwc.taxtech.atms.vat.entity.InputVATInvoiceItem;
import pwc.taxtech.atms.vat.service.impl.InputInvoiceDataImportServiceImpl;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@RestController
@RequestMapping(value = "api/v1/inputInvoiceImport")
public class InputInvoiceImportController {
@Autowired
InputInvoiceDataImportService inputInvoiceDataImportService;
InputInvoiceDataImportServiceImpl inputInvoiceDataImportService;
@RequestMapping(value = "inputInvoicePreviewList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
......@@ -55,6 +67,11 @@ public class InputInvoiceImportController {
return ResponseEntity.ok().body(inputInvoiceDataImportService.getInputInvoiceList(period));
}
@RequestMapping(value = "getInputInvoiceItemList/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity getInputInvoiceItemList(@PathVariable Integer period) {
return ResponseEntity.ok().body(inputInvoiceDataImportService.getInputInvoiceItemList(period));
}
private int getDownloadFilePath(InputInvoicePreviewQueryParam paras, OutputStream outputStream) {
List<InputVATInvoiceDto> list = inputInvoiceDataImportService.getInputInvoiceTreeViewData(paras).getList();
if (list.size() == 0) {
......@@ -90,12 +107,9 @@ public class InputInvoiceImportController {
excelSheetB.setHeaders(header2);
excelSheetB.setSheetName("sheetB");
List<InputVATInvoiceItemDto> inputInvoiceItemList = new ArrayList<>();
List<InputVATInvoiceItem> inputInvoiceItemList = new ArrayList<>();
for (InputVATInvoiceDto item : list) {
List<InputVATInvoiceItemDto> tempResult = inputInvoiceDataImportService.getInputInvoiceItemTreeViewData(item.getID());
for (InputVATInvoiceItemDto r : tempResult) {
inputInvoiceItemList.add(r);
}
inputInvoiceItemList.addAll(inputInvoiceDataImportService.getInputInvoiceItemTreeViewData(item.getID()));
}
excelSheetB.setDataset(inputInvoiceItemList);
List<ExcelSheet<InputVATInvoiceBaseDto>> sheets = new ArrayList<>();
......
package pwc.taxtech.atms.dto.vatdto;
public class InputVATInvoiceItemDto extends InputVATInvoiceBaseDto {
}
package pwc.taxtech.atms.vat.service;
import pwc.taxtech.atms.dto.PagingResultDto;
import pwc.taxtech.atms.dto.vatdto.InputInvoicePreviewQueryParam;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceDto;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceItemDto;
import java.util.List;
public interface InputInvoiceDataImportService {
PagingResultDto<InputVATInvoiceDto> getInputInvoiceTreeViewData(InputInvoicePreviewQueryParam paras);
List<InputVATInvoiceItemDto> getInputInvoiceItemTreeViewData(String id);
List<InputVATInvoiceDto> getInputInvoiceList(Integer period);
}
......@@ -3,26 +3,21 @@ package pwc.taxtech.atms.vat.service.impl;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.dto.FieldsMapper;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.PagingResultDto;
import pwc.taxtech.atms.dto.vatdto.InputInvoicePreviewQueryParam;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceDto;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceItemDto;
import pwc.taxtech.atms.dto.vatdto.QueryOutputDto;
import pwc.taxtech.atms.vat.entity.InputVATInvoice;
import pwc.taxtech.atms.vat.entity.InputVATInvoiceExample;
import pwc.taxtech.atms.vat.entity.InputVATInvoiceItem;
import pwc.taxtech.atms.vat.entity.InputVATInvoiceItemExample;
import pwc.taxtech.atms.vat.service.InputInvoiceDataImportService;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@Service
public class InputInvoiceDataImportServiceImpl extends VatAbstractService implements InputInvoiceDataImportService {
public class InputInvoiceDataImportServiceImpl extends VatAbstractService {
@Override
public PagingResultDto<InputVATInvoiceDto> getInputInvoiceTreeViewData(InputInvoicePreviewQueryParam paras) {
PagingResultDto<InputVATInvoiceDto> qResult = new PagingResultDto<>();
qResult.setPageInfo(paras.getPageInfo());
......@@ -42,34 +37,25 @@ public class InputInvoiceDataImportServiceImpl extends VatAbstractService implem
return qResult;
}
@Override
public List<InputVATInvoiceItemDto> getInputInvoiceItemTreeViewData(String id) {
public List<InputVATInvoiceItem> getInputInvoiceItemTreeViewData(String id) {
InputVATInvoiceItemExample example = new InputVATInvoiceItemExample();
example.createCriteria().andInputVATInvoiceIDEqualTo(id);
List<InputVATInvoiceItem> list = inputVATInvoiceItemMapper.selectByExample(example);
List<InputVATInvoiceItemDto> result = new ArrayList<>();
list.forEach(a -> {
InputVATInvoiceItemDto dto = new InputVATInvoiceItemDto();
CommonUtils.copyProperties(a, dto);
result.add(dto);
});
return result;
return inputVATInvoiceItemMapper.selectByExample(example);
}
@Override
public List<InputVATInvoiceDto> getInputInvoiceList(Integer period) {
InputVATInvoiceExample inputVATInvoiceExample = new InputVATInvoiceExample();
inputVATInvoiceExample.createCriteria().andPeriodIDEqualTo(period.intValue());
List<InputVATInvoice> inputVatEntity =inputVATInvoiceMapper.selectByExample(inputVATInvoiceExample);
List<InputVATInvoice> inputVatEntity = inputVATInvoiceMapper.selectByExample(inputVATInvoiceExample);
inputVatEntity.sort(Comparator.comparing(InputVATInvoice::getInvoiceNumber));
inputVatEntity.sort(Comparator.comparing(InputVATInvoice::getCreateTime));
List<InputVATInvoiceDto> result = new ArrayList<>(inputVatEntity.size());
inputVatEntity.forEach(m->{
InputVATInvoiceDto dto=new InputVATInvoiceDto();
inputVatEntity.forEach(m -> {
InputVATInvoiceDto dto = new InputVATInvoiceDto();
try {
FieldsMapper.map(m,dto);
FieldsMapper.map(m, dto);
} catch (ClassNotFoundException e) {
e.printStackTrace();//TODO:should be fixed with exception filter (neo)
} catch (IllegalAccessException e) {
......@@ -80,4 +66,10 @@ public class InputInvoiceDataImportServiceImpl extends VatAbstractService implem
return result;
}
public List<InputVATInvoiceItem> getInputInvoiceItemList(Integer period) {
InputVATInvoiceItemExample example = new InputVATInvoiceItemExample();
example.createCriteria().andPeriodIDEqualTo(period.intValue());
return inputVATInvoiceItemMapper.selectByExample(example);
}
}
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