Commit e0c409be authored by neo's avatar neo

[dev] add input output module and fixe api

parent 02073fc3
......@@ -330,6 +330,13 @@
<artifactId>httpclient</artifactId>
<version>4.5.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcomponents-client -->
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-commons -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
</dependencies>
<profiles>
......
package pwc.taxtech.atms.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -9,11 +10,10 @@ 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.dpo.PagingResultDto;
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.dto.vatdto.InputVATInvoiceDto;
import pwc.taxtech.atms.service.IdentityService;
import pwc.taxtech.atms.thirdparty.ExcelSheet;
import pwc.taxtech.atms.thirdparty.ExcelUtil;
......@@ -29,6 +29,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import static javax.servlet.http.HttpServletResponse.SC_NO_CONTENT;
import static javax.servlet.http.HttpServletResponse.SC_OK;
......@@ -43,7 +44,7 @@ public class InputInvoiceImportController {
@RequestMapping(value = "inputInvoicePreviewList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
PagingResultDto<InputVATInvoiceDto> getInputInvoiceTreeViewData(@RequestBody InputInvoicePreviewQueryParam paras) {
Page<InputInvoice> getInputInvoiceTreeViewData(@RequestBody InputInvoicePreviewQueryParam paras) {
return inputInvoiceDataImportService.getInputInvoiceTreeViewData(paras);
}
......@@ -80,7 +81,7 @@ public class InputInvoiceImportController {
}
private int getDownloadFilePath(InputInvoicePreviewQueryParam paras, OutputStream outputStream) {
List<InputVATInvoiceDto> list = inputInvoiceDataImportService.getInputInvoiceTreeViewData(paras).getList();
List<InputInvoice> list = inputInvoiceDataImportService.getInputInvoiceTreeViewData(paras).get().collect(Collectors.toList())
if (list.size() == 0) {
return 0;
}
......@@ -115,7 +116,7 @@ public class InputInvoiceImportController {
excelSheetB.setSheetName("sheetB");
List<InputVatInvoiceItem> inputInvoiceItemList = new ArrayList<>();
for (InputVATInvoiceDto item : list) {
for (InputInvoice item : list) {
inputInvoiceItemList.addAll(inputInvoiceDataImportService.getInputInvoiceItemTreeViewData(item.getId()));
}
excelSheetB.setDataset(inputInvoiceItemList);
......
package pwc.taxtech.atms.dto.vatdto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class InputInvoice {
private String id;
private String fpdm;
private String fphm;
private String kprq;
private String gfsh;
private String gfmc;
private String gfdzdh;
private String gfyhzh;
private String xfsh;
private String xfmc;
private String xfdzdh;
private String xfyhzh;
private String jym;
private String fplx;
private String fplc;
private String jqbh;
private String hjje;
private String hjse;
private String jshj;
private String mwq;
private String kpr;
private String skr;
private String fhr;
private String bz;
private String pzh;
private String dzdh;
private String xtly;
private String fpzt;
private String cyzt;
private String rzzt;
private String rzsq;
private String rzsj;
private String rzjg;
private String rzjgms;
private String cjsj;
private String lcbh;
private String fpyx;
private String blyy;
private String lrrq;
private String companyid;
}
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 org.apache.ibatis.jdbc.ScriptRunner;
import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.constant.enums.EnumTbImportType;
import pwc.taxtech.atms.constant.enums.EnumValidationType;
import pwc.taxtech.atms.dpo.PagingResultDto;
import pwc.taxtech.atms.dto.FieldsMapper;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vatdto.InputInvoice;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceDto;
import pwc.taxtech.atms.vat.dpo.InputInvoicePreviewQueryParam;
import pwc.taxtech.atms.vat.entity.InputVatInvoice;
......@@ -18,6 +25,7 @@ import pwc.taxtech.atms.vat.entity.InputVatInvoiceExample;
import pwc.taxtech.atms.vat.entity.InputVatInvoiceItem;
import pwc.taxtech.atms.vat.entity.InputVatInvoiceItemExample;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Comparator;
......@@ -33,25 +41,25 @@ public class InputInvoiceDataImportServiceImpl extends VatAbstractService {
@Autowired
private SqlSessionTemplate dynamicSqlSessionTemplate;
public PagingResultDto<InputVATInvoiceDto> getInputInvoiceTreeViewData(InputInvoicePreviewQueryParam paras) {
PagingResultDto<InputVATInvoiceDto> qResult = new PagingResultDto<>();
qResult.setPageInfo(paras.getPageInfo());
qResult.setList(new ArrayList<>());
long result = inputVATInvoiceMapper.getInputVATInvoiceCountByCondition(paras);
qResult.getPageInfo().setTotalCount((int) result);
if (result > 0) {
int limitFrom = paras.getPageInfo().getPageSize() * (paras.getPageInfo().getPageIndex() - 1);
List<InputVATInvoiceDto> fResult = new ArrayList<>();
inputVATInvoiceMapper.getInputVATInvoiceCountByConditionWithPaging(paras, limitFrom).forEach(a -> {
InputVATInvoiceDto inputVATInvoiceDto = new InputVATInvoiceDto();
CommonUtils.copyProperties(a, inputVATInvoiceDto);
fResult.add(inputVATInvoiceDto);
});
qResult.setList(fResult);
public Page<InputInvoice> getInputInvoiceTreeViewData(InputInvoicePreviewQueryParam paras) {
return get(paras.getInvoiceCode(), paras.getPeriodStart(), paras.getPageInfo().getPageIndex(), paras.getPageInfo().getPageSize());
}
private Page<InputInvoice> get(String code, int period, int page, int size) {
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)) {
return JSONObject.parseObject(EntityUtils.toString(response.getEntity()), new TypeReference<Page<InputInvoice>>() {
});
}
} catch (IOException e) {
e.printStackTrace();
}
return qResult;
return Page.empty();
}
public List<InputVatInvoiceItem> getInputInvoiceItemTreeViewData(String id) {
InputVatInvoiceItemExample example = new InputVatInvoiceItemExample();
example.createCriteria().andInputVATInvoiceIdEqualTo(id);
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>atms</artifactId>
<groupId>pwc.taxtech.atms</groupId>
<version>0.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>atms-invoice</artifactId>
<properties>
<java.version>1.8</java.version>
<hibernate-tools-maven-plugin.version>0.1.0</hibernate-tools-maven-plugin.version>
<project.properties.encoding>UTF-8</project.properties.encoding>
<project.build.sourceEncoding>${project.properties.encoding}</project.build.sourceEncoding>
<project.properties.license.name>apache_v2</project.properties.license.name>
<project.properties.license.txtName>Apache License, Version 2.0</project.properties.license.txtName>
<project.properties.license.url>http://www.apache.org/licenses/LICENSE-2.0.txt</project.properties.license.url>
<java.version>1.8</java.version>
<junit.version>4.12</junit.version>
<log4j.version>2.8.2</log4j.version>
<lombok.version>1.16.18</lombok.version>
<slf4j.version>1.7.25</slf4j.version>
<commons-lang3.version>3.7</commons-lang3.version>
<commons-io.version>2.6</commons-io.version>
<commons-collections4.version>4.1</commons-collections4.version>
<commons-cli.version>1.4</commons-cli.version>
<maven-compiler-plugin.version>3.6.1</maven-compiler-plugin.version>
<maven-assembly-plugin.version>3.1.0</maven-assembly-plugin.version>
<maven-source-plugin.version>3.0.1</maven-source-plugin.version>
<maven-javadoc-plugin.version>2.10.4</maven-javadoc-plugin.version>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<scm.repository.owner>udamken</scm.repository.owner>
<scm.repository.name>mybatter</scm.repository.name>
<scm.repository.repo>${scm.repository.owner}/${scm.repository.name}</scm.repository.repo>
<scm.repository.url>https://www.github.com/${scm.repository.repo}</scm.repository.url>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>oracle</groupId>
<artifactId>ojdbc</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ojdbc6.jar</systemPath>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>23.0</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.0.3.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>http://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
\ No newline at end of file
package pwc.taxtech.invoice;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
private static final Logger log = LoggerFactory.getLogger(Application.class);
public static void main(String[] args) {
SpringApplication.run(Application.class);
}
}
package pwc.taxtech.invoice.input;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Getter
@Setter
@Table(name = "INPUT_INVOICE")
public class InputInvoice {
@Id
@Column(name = "ID")
@GeneratedValue(strategy = GenerationType.AUTO)
private String id;
@Column(name = "FPDM")
private String fpdm;
@Column(name = "FPHM")
private String fphm;
@Column(name = "KPRQ")
private String kprq;
@Column(name = "GFSH")
private String gfsh;
@Column(name = "GFMC")
private String gfmc;
@Column(name = "GFDZDH")
private String gfdzdh;
@Column(name = "GFYHZH")
private String gfyhzh;
@Column(name = "XFSH")
private String xfsh;
@Column(name = "XFMC")
private String xfmc;
@Column(name = "XFDZDH")
private String xfdzdh;
@Column(name = "XFYHZH")
private String xfyhzh;
@Column(name = "JYM")
private String jym;
@Column(name = "FPLX")
private String fplx;
@Column(name = "FPLC")
private String fplc;
@Column(name = "JQBH")
private String jqbh;
@Column(name = "HJJE")
private String hjje;
@Column(name = "HJSE")
private String hjse;
@Column(name = "JSHJ")
private String jshj;
@Column(name = "MWQ")
private String mwq;
@Column(name = "KPR")
private String kpr;
@Column(name = "SKR")
private String skr;
@Column(name = "FHR")
private String fhr;
@Column(name = "BZ")
private String bz;
@Column(name = "PZH")
private String pzh;
@Column(name = "DZDH")
private String dzdh;
@Column(name = "XTLY")
private String xtly;
@Column(name = "FPZT")
private String fpzt;
@Column(name = "CYZT")
private String cyzt;
@Column(name = "RZZT")
private String rzzt;
@Column(name = "RZSQ")
private String rzsq;
@Column(name = "RZSJ")
private String rzsj;
@Column(name = "RZJG")
private String rzjg;
@Column(name = "RZJGMS")
private String rzjgms;
@Column(name = "CJSJ")
private String cjsj;
@Column(name = "LCBH")
private String lcbh;
@Column(name = "FPYX")
private String fpyx;
@Column(name = "BLYY")
private String blyy;
@Column(name = "LRRQ")
private String lrrq;
@Column(name = "COMPANYID")
private String companyid;
}
package pwc.taxtech.invoice.input;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
@RestController
@RequestMapping("/input_invoices")
public class InputInvoiceController {
@Autowired
InputInvoiceRepository repository;
@RequestMapping(method = GET)
public Page<InputInvoice> getAll(@RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "20") int size) {
return repository.findAll(PageRequest.of(page, size));
}
}
package pwc.taxtech.invoice.input;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
interface InputInvoiceRepository extends PagingAndSortingRepository<InputInvoice, String> {
}
package pwc.taxtech.invoice.output;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Getter
@Setter
@Table(name = "OUTPUT_INVOICE")
public class OutputInvoice {
@Id
@Column(name = "ID")
@GeneratedValue(strategy = GenerationType.AUTO)
private String id;
@Column(name = "FPQQLSH")
private String fpqqlsh;
@Column(name = "FPDM")
private String fpdm;
@Column(name = "FPHM")
private String fphm;
@Column(name = "KPRQ")
private String kprq;
@Column(name = "FPLXDM")
private String fplxdm;
@Column(name = "EWM")
private String ewm;
@Column(name = "JQBH")
private String jqbh;
@Column(name = "JYM")
private String jym;
@Column(name = "GFMC")
private String gfmc;
@Column(name = "GFSH")
private String gfsh;
@Column(name = "GFDZDH")
private String gfdzdh;
@Column(name = "GFYHZH")
private String gfyhzh;
@Column(name = "XFSH")
private String xfsh;
@Column(name = "XFMC")
private String xfmc;
@Column(name = "XFDZDH")
private String xfdzdh;
@Column(name = "XFYHZH")
private String xfyhzh;
@Column(name = "BZ")
private String bz;
@Column(name = "SKR")
private String skr;
@Column(name = "FHR")
private String fhr;
@Column(name = "KPR")
private String kpr;
@Column(name = "KDDH")
private String kddh;
@Column(name = "KDUUID")
private String kduuid;
@Column(name = "FPLX")
private String fplx;
@Column(name = "KPZT")
private String kpzt;
@Column(name = "FPZT")
private String fpzt;
@Column(name = "YFPDM")
private String yfpdm;
@Column(name = "YFPHM")
private String yfphm;
@Column(name = "GFGSBM")
private String gfgsbm;
@Column(name = "XFGSBM")
private String xfgsbm;
@Column(name = "SPBH")
private String spbh;
@Column(name = "XTLY")
private String xtly;
@Column(name = "CJSJ")
private String cjsj;
@Column(name = "HJJE")
private String hjje;
@Column(name = "HJSE")
private String hjse;
@Column(name = "JSHJ")
private String jshj;
@Column(name = "XXBBH")
private String xxbbh;
@Column(name = "DYZT")
private String dyzt;
@Column(name = "GDJLH")
private String gdjlh;
@Column(name = "ZKJE")
private String zkje;
@Column(name = "ZKSE")
private String zkse;
@Column(name = "ZKJSHJ")
private String zkjshj;
@Column(name = "SLV")
private String slv;
@Column(name = "QY")
private String qy;
@Column(name = "JSZT")
private String jszt;
@Column(name = "KDGS")
private String kdgs;
@Column(name = "SHZT")
private String shzt;
@Column(name = "THKPSQ")
private String thkpsq;
@Column(name = "JSFJ")
private String jsfj;
@Column(name = "SQR")
private String sqr;
@Column(name = "BSCDM")
private String bscdm;
@Column(name = "BSC")
private String bsc;
@Column(name = "QYDM")
private String qydm;
@Column(name = "SQBH")
private String sqbh;
@Column(name = "HTBH")
private String htbh;
@Column(name = "SQRQ")
private String sqrq;
@Column(name = "YZRQ")
private String yzrq;
}
package pwc.taxtech.invoice.output;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
@RestController
@RequestMapping("/output_invoices")
public class OutputInvoiceController {
@Autowired
OutputInvoiceRepository repository;
@RequestMapping(method = GET)
public Page<OutputInvoice> getAll(@RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "20") int size) {
return repository.findAll(PageRequest.of(page, size));
}
}
package pwc.taxtech.invoice.output;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
interface OutputInvoiceRepository extends PagingAndSortingRepository<OutputInvoice, String> {
}
server.port: 8089
spring:
datasource:
url: jdbc:oracle:thin:@10.158.230.144:11521:XE
username: system
password: taxadmin2018
driver-class-name: oracle.jdbc.driver.OracleDriver
jpa:
show-sql: true
properties.hibernate:
default_schema: pwc_invoice
dialect: org.hibernate.dialect.Oracle10gDialect
hibernate:
ddl-auto: update
naming.physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
......@@ -10,6 +10,7 @@
<module>atms-api</module>
<module>atms-web</module>
<module>atms-dao</module>
<module>atms-invoice</module>
</modules>
<properties>
......
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