Commit f0cb87c6 authored by neo's avatar neo

[dev] fixed input and output invoice from datasource not jpa api

parent 08771f7f
package pwc.taxtech.atms.controller;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
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 org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.dto.vatdto.ImportInputInvoiceDto;
import pwc.taxtech.atms.dto.vatdto.ImportInputInvoiceItemDto;
import pwc.taxtech.atms.dto.vatdto.InputInvoice;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceBaseDto;
import pwc.taxtech.atms.service.impl.IdentityServiceImpl;
import pwc.taxtech.atms.thirdparty.ExcelSheet;
import pwc.taxtech.atms.thirdparty.ExcelUtil;
import pwc.taxtech.atms.vat.dpo.InputInvoicePreviewQueryParam;
import pwc.taxtech.atms.vat.entity.InputInvoice;
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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.*;
import static javax.servlet.http.HttpServletResponse.SC_NO_CONTENT;
import static javax.servlet.http.HttpServletResponse.SC_OK;
......@@ -46,7 +37,7 @@ public class InputInvoiceImportController {
@RequestMapping(value = "inputInvoicePreviewList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
PagingResultDto<InputInvoice> getInputInvoiceTreeViewData(@RequestBody InputInvoicePreviewQueryParam paras) {
PageInfo<InputInvoice> getInputInvoiceTreeViewData(@RequestBody InputInvoicePreviewQueryParam paras) {
return inputInvoiceDataImportService.getInputInvoiceTreeViewData(paras);
}
......@@ -119,7 +110,7 @@ public class InputInvoiceImportController {
List<InputVatInvoiceItem> inputInvoiceItemList = new ArrayList<>();
for (InputInvoice item : list) {
inputInvoiceItemList.addAll(inputInvoiceDataImportService.getInputInvoiceItemTreeViewData(item.getId()));
inputInvoiceItemList.addAll(inputInvoiceDataImportService.getInputInvoiceItemTreeViewData(item.getID()));
}
excelSheetB.setDataset(inputInvoiceItemList);
List<ExcelSheet<InputVATInvoiceBaseDto>> sheets = new ArrayList<>();
......
package pwc.taxtech.atms.controller;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
......@@ -13,13 +14,13 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
import pwc.taxtech.atms.constant.enums.EnumModule;
import pwc.taxtech.atms.dpo.PagingResultDto;
import pwc.taxtech.atms.dto.vatdto.ImportOutputInvoiceDto;
import pwc.taxtech.atms.dto.vatdto.OutputInvoice;
import pwc.taxtech.atms.dto.vatdto.QueryEvidenceDto;
import pwc.taxtech.atms.service.impl.IdentityServiceImpl;
import pwc.taxtech.atms.thirdparty.ExcelUtil;
import pwc.taxtech.atms.vat.dpo.OutputVATInvoiceInfoDto;
import pwc.taxtech.atms.vat.dpo.QueryOutputDto;
import pwc.taxtech.atms.vat.entity.ImportFile;
import pwc.taxtech.atms.vat.entity.OutputInvoice;
import pwc.taxtech.atms.vat.service.impl.FileUploadAdapter;
import pwc.taxtech.atms.vat.service.impl.OutputInvoiceServiceImpl;
......@@ -49,7 +50,7 @@ public class OutputInvoiceController {
private FileUploadAdapter fileUploadAdapter;
@RequestMapping(value = "queryOutputInvoiceList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public PagingResultDto<OutputInvoice> queryOutputInvoiceList(@RequestBody QueryOutputDto queryDto) {
public PageInfo<OutputInvoice> queryOutputInvoiceList(@RequestBody QueryOutputDto queryDto) {
return outputInvoiceService.queryOutputInvoiceList(queryDto);
}
......
package pwc.taxtech.atms.vat.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.jdbc.ScriptRunner;
import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate;
......@@ -16,18 +11,13 @@ import pwc.taxtech.atms.constant.enums.EnumTbImportType;
import pwc.taxtech.atms.constant.enums.EnumValidationType;
import pwc.taxtech.atms.dto.FieldsMapper;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.PagingResultDto;
import pwc.taxtech.atms.dto.vatdto.InputInvoice;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceDto;
import pwc.taxtech.atms.invoice.InputInvoiceMapper;
import pwc.taxtech.atms.vat.dao.InputVatInvoiceItemMapper;
import pwc.taxtech.atms.vat.dao.InputVatInvoiceMapper;
import pwc.taxtech.atms.vat.dpo.InputInvoicePreviewQueryParam;
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.entity.*;
import java.io.IOException;
import java.io.StringReader;
import java.util.*;
......@@ -43,28 +33,16 @@ public class InputInvoiceDataImportServiceImpl {
private SqlSessionTemplate dynamicSqlSessionTemplate;
@Autowired
private InputVatInvoiceItemMapper inputVATInvoiceItemMapper;
@Autowired
private InputInvoiceMapper inputInvoiceMapper;
public PagingResultDto<InputInvoice> getInputInvoiceTreeViewData(InputInvoicePreviewQueryParam paras) {
return get(paras.getInvoiceCode(), paras.getPeriodStart(), paras.getPageInfo().getPageIndex(), paras.getPageInfo().getPageSize());
}
private PagingResultDto<InputInvoice> get(String code, int period, int page, int size) {
PagingResultDto<InputInvoice> pageInput = null;
try (CloseableHttpClient httpclient = HttpClients.createDefault();) {
HttpGet httpget = new HttpGet("http://localhost:8089/input_invoices?page=" + page + "&size=" + size
+ "&code=" + code + "&period=" + period);
try (CloseableHttpResponse response = httpclient.execute(httpget)) {
String inputStr = EntityUtils.toString(response.getEntity());
pageInput = JSONObject.parseObject(inputStr, new TypeReference<PagingResultDto<InputInvoice>>() {
}.getType());
}
} catch (IOException e) {
e.printStackTrace();
}
return pageInput;
public PageInfo<InputInvoice> getInputInvoiceTreeViewData(InputInvoicePreviewQueryParam paras) {
PageHelper.startPage(paras.getPageInfo().getPageIndex(), paras.getPageInfo().getPageSize());
List<InputInvoice> invoices = inputInvoiceMapper.selectByExample(new InputInvoiceExample());
PageInfo<InputInvoice> pageInfo = new PageInfo<>(invoices);
return pageInfo;
}
public List<InputVatInvoiceItem> getInputInvoiceItemTreeViewData(String id) {
InputVatInvoiceItemExample example = new InputVatInvoiceItemExample();
example.createCriteria().andInputVATInvoiceIdEqualTo(id);
......
......@@ -2,6 +2,8 @@ package pwc.taxtech.atms.vat.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
......@@ -19,8 +21,8 @@ import pwc.taxtech.atms.constant.enums.EnumTbImportType;
import pwc.taxtech.atms.dpo.PagingResultDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vatdto.ImportOutputInvoiceDto;
import pwc.taxtech.atms.dto.vatdto.OutputInvoice;
import pwc.taxtech.atms.dto.vatdto.QueryEvidenceDto;
import pwc.taxtech.atms.invoice.OutputInvoiceMapper;
import pwc.taxtech.atms.vat.dao.ImportFileMapper;
import pwc.taxtech.atms.vat.dao.OutputVatInvoiceItemMapper;
import pwc.taxtech.atms.vat.dao.OutputVatInvoiceMapper;
......@@ -48,25 +50,14 @@ public class OutputInvoiceServiceImpl {
private OutputVatInvoiceMapper outputVATInvoiceMapper;
@Autowired
private OutputVatInvoiceItemMapper outputVATInvoiceItemMapper;
@Autowired
private OutputInvoiceMapper outputInvoiceMapper;
public PagingResultDto<OutputInvoice> queryOutputInvoiceList(QueryOutputDto queryDto) {
return get("", queryDto.getPeriodStart(), queryDto.getPageInfo().getPageIndex(), queryDto.getPageInfo().getPageSize());
}
private PagingResultDto<OutputInvoice> get(String code, int period, int page, int size) {
PagingResultDto<OutputInvoice> pageInput = null;
try (CloseableHttpClient httpclient = HttpClients.createDefault();) {
HttpGet httpget = new HttpGet("http://localhost:8089/output_invoices?page=" + page + "&size=" + size
+ "&code=" + code + "&period=" + period);
try (CloseableHttpResponse response = httpclient.execute(httpget)) {
String inputStr = EntityUtils.toString(response.getEntity());
pageInput = JSONObject.parseObject(inputStr, new TypeReference<PagingResultDto<OutputInvoice>>() {
}.getType());
}
} catch (IOException e) {
e.printStackTrace();
}
return pageInput;
public PageInfo<OutputInvoice> queryOutputInvoiceList(QueryOutputDto queryDto) {
PageHelper.startPage(queryDto.getPageInfo().getPageIndex(),queryDto.getPageInfo().getPageSize());
List<OutputInvoice> invoices = outputInvoiceMapper.selectByExample(new OutputInvoiceExample());
PageInfo<OutputInvoice> pageInfo = new PageInfo<>(invoices);
return pageInfo;
}
public OperationResultDto<List<OutputVATInvoiceInfoDto>> getExportOutputInvoiceList(QueryOutputDto queryDto) {
......
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