Commit b3ec20cc authored by frank.xa.zhang's avatar frank.xa.zhang

add new api for report generate with work flow and data save

parent 444ed5a1
......@@ -297,10 +297,7 @@
<columnOverride column="Path" javaType="java.lang.String" jdbcType="VARCHAR"/>
</table>
<table tableName="Report" domainObjectName="Report">
<property name="useActualColumnNames" value="true" />
<property name="ignoreQualifiersAtRuntime" value="true"/>
</table>
<table tableName="StandardAccount" domainObjectName="VatStandardAccount">
<property name="useActualColumnNames" value="true" />
......@@ -376,5 +373,8 @@
<columnOverride column="is_system_type" javaType="java.lang.Boolean"/>
<columnOverride column="is_active_association" javaType="java.lang.Boolean"/>
</table>
<table tableName="report" domainObjectName="Report">
<property name="ignoreQualifiersAtRuntime" value="true"/>
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
rem see http://www.mybatis.org/generator/running/runningFromCmdLine.html
cd /d %~dp0
call java -classpath .;./* org.mybatis.generator.api.ShellRunner -configfile vatGeneratorConfig.xml -overwrite -verbose -tables period_cell_template_config
call java -classpath .;./* org.mybatis.generator.api.ShellRunner -configfile vatGeneratorConfig.xml -overwrite -verbose -tables cell_data
echo @@@@@@@@@@@ DONE @@@@@@@@@@@
pause
......@@ -2,14 +2,18 @@ package pwc.taxtech.atms.common;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public class POIUtil {
......@@ -42,7 +46,7 @@ public class POIUtil {
Row targetRow = targetSheet.createRow(r);
for (int c = row.getFirstCellNum(); c <= row.getLastCellNum(); c++) {
Cell cell = row.getCell(c);
if (null == cell){
if (null == cell) {
continue;
}
Cell targetCell = targetRow.createCell(c);
......
......@@ -25,4 +25,9 @@ public class ReportController {
public OperationResultDto updateConfig(@PathVariable String projectId, @PathVariable Integer period, @RequestParam String generator) {
return reportService.updateConfig(projectId, period, generator);
}
@RequestMapping(value = "generateByTotal/{projectId}/{ifDeleteManualDataSource}/{period}",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto generateAllData(@PathVariable String projectId,@PathVariable Boolean ifDeleteManualDataSource,@PathVariable Integer period,@RequestParam String generator){
return reportService.generateData(projectId,EnumServiceType.VAT,ifDeleteManualDataSource,period,null,generator);
}
}
......@@ -12,7 +12,7 @@ import pwc.taxtech.atms.vat.entity.ReportExample;
public interface ReportMapper extends MyVatMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table Report
* This method corresponds to the database table report
*
* @mbg.generated
*/
......@@ -20,7 +20,7 @@ public interface ReportMapper extends MyVatMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table Report
* This method corresponds to the database table report
*
* @mbg.generated
*/
......@@ -28,15 +28,15 @@ public interface ReportMapper extends MyVatMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table Report
* This method corresponds to the database table report
*
* @mbg.generated
*/
int deleteByPrimaryKey(String ID);
int deleteByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table Report
* This method corresponds to the database table report
*
* @mbg.generated
*/
......@@ -44,7 +44,7 @@ public interface ReportMapper extends MyVatMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table Report
* This method corresponds to the database table report
*
* @mbg.generated
*/
......@@ -52,7 +52,7 @@ public interface ReportMapper extends MyVatMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table Report
* This method corresponds to the database table report
*
* @mbg.generated
*/
......@@ -60,7 +60,7 @@ public interface ReportMapper extends MyVatMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table Report
* This method corresponds to the database table report
*
* @mbg.generated
*/
......@@ -68,15 +68,15 @@ public interface ReportMapper extends MyVatMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table Report
* This method corresponds to the database table report
*
* @mbg.generated
*/
Report selectByPrimaryKey(String ID);
Report selectByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table Report
* This method corresponds to the database table report
*
* @mbg.generated
*/
......@@ -84,7 +84,7 @@ public interface ReportMapper extends MyVatMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table Report
* This method corresponds to the database table report
*
* @mbg.generated
*/
......@@ -92,7 +92,7 @@ public interface ReportMapper extends MyVatMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table Report
* This method corresponds to the database table report
*
* @mbg.generated
*/
......@@ -100,7 +100,7 @@ public interface ReportMapper extends MyVatMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table Report
* This method corresponds to the database table report
*
* @mbg.generated
*/
......
......@@ -27,7 +27,7 @@ public class CellData implements Serializable {
*
* @mbg.generated
*/
private String reportId;
private Long reportId;
/**
*
......@@ -36,7 +36,7 @@ public class CellData implements Serializable {
*
* @mbg.generated
*/
private String cellTemplateId;
private Long cellTemplateId;
/**
*
......@@ -132,7 +132,7 @@ public class CellData implements Serializable {
*
* @mbg.generated
*/
public String getReportId() {
public Long getReportId() {
return reportId;
}
......@@ -144,8 +144,8 @@ public class CellData implements Serializable {
*
* @mbg.generated
*/
public void setReportId(String reportId) {
this.reportId = reportId == null ? null : reportId.trim();
public void setReportId(Long reportId) {
this.reportId = reportId;
}
/**
......@@ -156,7 +156,7 @@ public class CellData implements Serializable {
*
* @mbg.generated
*/
public String getCellTemplateId() {
public Long getCellTemplateId() {
return cellTemplateId;
}
......@@ -168,8 +168,8 @@ public class CellData implements Serializable {
*
* @mbg.generated
*/
public void setCellTemplateId(String cellTemplateId) {
this.cellTemplateId = cellTemplateId == null ? null : cellTemplateId.trim();
public void setCellTemplateId(Long cellTemplateId) {
this.cellTemplateId = cellTemplateId;
}
/**
......
......@@ -265,62 +265,52 @@ public class CellDataExample {
return (Criteria) this;
}
public Criteria andReportIdEqualTo(String value) {
public Criteria andReportIdEqualTo(Long value) {
addCriterion("report_id =", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotEqualTo(String value) {
public Criteria andReportIdNotEqualTo(Long value) {
addCriterion("report_id <>", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdGreaterThan(String value) {
public Criteria andReportIdGreaterThan(Long value) {
addCriterion("report_id >", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdGreaterThanOrEqualTo(String value) {
public Criteria andReportIdGreaterThanOrEqualTo(Long value) {
addCriterion("report_id >=", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLessThan(String value) {
public Criteria andReportIdLessThan(Long value) {
addCriterion("report_id <", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLessThanOrEqualTo(String value) {
public Criteria andReportIdLessThanOrEqualTo(Long value) {
addCriterion("report_id <=", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLike(String value) {
addCriterion("report_id like", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotLike(String value) {
addCriterion("report_id not like", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdIn(List<String> values) {
public Criteria andReportIdIn(List<Long> values) {
addCriterion("report_id in", values, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotIn(List<String> values) {
public Criteria andReportIdNotIn(List<Long> values) {
addCriterion("report_id not in", values, "reportId");
return (Criteria) this;
}
public Criteria andReportIdBetween(String value1, String value2) {
public Criteria andReportIdBetween(Long value1, Long value2) {
addCriterion("report_id between", value1, value2, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotBetween(String value1, String value2) {
public Criteria andReportIdNotBetween(Long value1, Long value2) {
addCriterion("report_id not between", value1, value2, "reportId");
return (Criteria) this;
}
......@@ -335,62 +325,52 @@ public class CellDataExample {
return (Criteria) this;
}
public Criteria andCellTemplateIdEqualTo(String value) {
public Criteria andCellTemplateIdEqualTo(Long value) {
addCriterion("cell_template_id =", value, "cellTemplateId");
return (Criteria) this;
}
public Criteria andCellTemplateIdNotEqualTo(String value) {
public Criteria andCellTemplateIdNotEqualTo(Long value) {
addCriterion("cell_template_id <>", value, "cellTemplateId");
return (Criteria) this;
}
public Criteria andCellTemplateIdGreaterThan(String value) {
public Criteria andCellTemplateIdGreaterThan(Long value) {
addCriterion("cell_template_id >", value, "cellTemplateId");
return (Criteria) this;
}
public Criteria andCellTemplateIdGreaterThanOrEqualTo(String value) {
public Criteria andCellTemplateIdGreaterThanOrEqualTo(Long value) {
addCriterion("cell_template_id >=", value, "cellTemplateId");
return (Criteria) this;
}
public Criteria andCellTemplateIdLessThan(String value) {
public Criteria andCellTemplateIdLessThan(Long value) {
addCriterion("cell_template_id <", value, "cellTemplateId");
return (Criteria) this;
}
public Criteria andCellTemplateIdLessThanOrEqualTo(String value) {
public Criteria andCellTemplateIdLessThanOrEqualTo(Long value) {
addCriterion("cell_template_id <=", value, "cellTemplateId");
return (Criteria) this;
}
public Criteria andCellTemplateIdLike(String value) {
addCriterion("cell_template_id like", value, "cellTemplateId");
return (Criteria) this;
}
public Criteria andCellTemplateIdNotLike(String value) {
addCriterion("cell_template_id not like", value, "cellTemplateId");
return (Criteria) this;
}
public Criteria andCellTemplateIdIn(List<String> values) {
public Criteria andCellTemplateIdIn(List<Long> values) {
addCriterion("cell_template_id in", values, "cellTemplateId");
return (Criteria) this;
}
public Criteria andCellTemplateIdNotIn(List<String> values) {
public Criteria andCellTemplateIdNotIn(List<Long> values) {
addCriterion("cell_template_id not in", values, "cellTemplateId");
return (Criteria) this;
}
public Criteria andCellTemplateIdBetween(String value1, String value2) {
public Criteria andCellTemplateIdBetween(Long value1, Long value2) {
addCriterion("cell_template_id between", value1, value2, "cellTemplateId");
return (Criteria) this;
}
public Criteria andCellTemplateIdNotBetween(String value1, String value2) {
public Criteria andCellTemplateIdNotBetween(Long value1, Long value2) {
addCriterion("cell_template_id not between", value1, value2, "cellTemplateId");
return (Criteria) this;
}
......
package pwc.taxtech.atms.vat.service;
import java.util.List;
public interface ReportGenerator {
String generateData(String projectId, List<Long> templateIds, Boolean ifDeleteManualDataSource, List<String> exceptCellTemplates,Integer periodParam, String generator);
}
......@@ -10,4 +10,6 @@ public interface ReportService {
OperationResultDto<List<ReportDto>> getReportTemplate(String projectID, EnumServiceType serviceType, Integer period);
OperationResultDto updateConfig(String projectId,Integer period,String generator);
OperationResultDto generateData(String projectId, EnumServiceType serviceType, Boolean ifDeleteManualDataSource, Integer periodParam, Integer reportType, String generator);
}
......@@ -10,8 +10,10 @@ import pwc.taxtech.atms.entitiy.*;
import pwc.taxtech.atms.vat.entity.PeriodCellTemplate;
import pwc.taxtech.atms.vat.entity.PeriodCellTemplateConfig;
import pwc.taxtech.atms.vat.entity.PeriodTemplate;
import pwc.taxtech.atms.vat.entity.PeriodTemplateExample;
import pwc.taxtech.atms.vat.service.ReportService;
import javax.ws.rs.NotSupportedException;
import java.util.*;
import java.util.stream.Collectors;
......@@ -219,4 +221,50 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
}
return null;
}
}
\ No newline at end of file
@Override
public OperationResultDto generateData(String projectId, EnumServiceType serviceType, Boolean ifDeleteManualDataSource, Integer periodParam, Integer reportType, String generator) {
OperationResultDto operationResultDto = new OperationResultDto();
if (serviceType.equals(EnumServiceType.VAT) && (periodParam == null && periodParam <= 0)) {
operationResultDto.setResultMsg("PeriodRequiredForVAT");
return operationResultDto;
}
if (serviceType != EnumServiceType.VAT) {
// 暂不支持非CIT/VAT service批量后端生成报表
throw new NotSupportedException();
}
int period = periodParam != null ? periodParam : 0;
String serviceTypeStr = serviceType.getCode().toString();
ProjectServiceTypeExample projectServiceTypeExample = new ProjectServiceTypeExample();
projectServiceTypeExample.createCriteria().andServiceTypeIDEqualTo(serviceTypeStr).andProjectIDEqualTo(projectId);
Optional<Long> templateGroupID = projectServiceTypeMapper.selectByExample(projectServiceTypeExample).stream().map(ProjectServiceType::getTemplateGroupID).findFirst();
if (templateGroupID == null) {
operationResultDto.setResultMsg("TemplateGroupNotExist");
return operationResultDto;
}
List<Long> templateIds;
if (reportType != null) {
PeriodTemplateExample periodTemplateExample = new PeriodTemplateExample();
periodTemplateExample.createCriteria().andTemplateGroupIdEqualTo(templateGroupID.get()).andPeriodEqualTo(period).andIsActiveAssociationEqualTo(true).andReportTypeEqualTo(reportType);
templateIds = periodTemplateMapper.selectByExample(periodTemplateExample).stream().map(PeriodTemplate::getId).collect(Collectors.toList());
} else {
PeriodTemplateExample periodTemplateExample = new PeriodTemplateExample();
periodTemplateExample.createCriteria().andTemplateGroupIdEqualTo(templateGroupID.get()).andPeriodEqualTo(period).andIsActiveAssociationEqualTo(true);
templateIds = periodTemplateMapper.selectByExample(periodTemplateExample).stream().map(PeriodTemplate::getId).collect(Collectors.toList());
}
String rslt = reportGenerator.generateData(projectId, templateIds, ifDeleteManualDataSource, null, periodParam, generator);
if (StringUtils.isBlank(rslt)) {
operationResultDto.setResultMsg("ReportGenerateFailed!");
return operationResultDto;
}
operationResultDto.setResult(true);
return operationResultDto;
}
}
......@@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import pwc.taxtech.atms.dao.*;
import pwc.taxtech.atms.service.impl.DistributedIDService;
import pwc.taxtech.atms.vat.dao.*;
import pwc.taxtech.atms.vat.service.ReportGenerator;
public class VatAbstractService {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
......@@ -52,5 +53,7 @@ public class VatAbstractService {
CellTemplateConfigMapper cellTemplateConfigMapper;
@Autowired
EnterpriseAccountMapper enterpriseAccountMapper;
@Autowired
ReportGenerator reportGenerator;
}
......@@ -7,8 +7,8 @@
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="report_id" jdbcType="VARCHAR" property="reportId" />
<result column="cell_template_id" jdbcType="VARCHAR" property="cellTemplateId" />
<result column="report_id" jdbcType="BIGINT" property="reportId" />
<result column="cell_template_id" jdbcType="BIGINT" property="cellTemplateId" />
<result column="data" jdbcType="VARCHAR" property="data" />
<result column="formula_exp" jdbcType="VARCHAR" property="formulaExp" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
......@@ -145,7 +145,7 @@
"data", formula_exp, create_by,
create_time, update_by, update_time
)
values (#{id,jdbcType=BIGINT}, #{reportId,jdbcType=VARCHAR}, #{cellTemplateId,jdbcType=VARCHAR},
values (#{id,jdbcType=BIGINT}, #{reportId,jdbcType=BIGINT}, #{cellTemplateId,jdbcType=BIGINT},
#{data,jdbcType=VARCHAR}, #{formulaExp,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}
)
......@@ -190,10 +190,10 @@
#{id,jdbcType=BIGINT},
</if>
<if test="reportId != null">
#{reportId,jdbcType=VARCHAR},
#{reportId,jdbcType=BIGINT},
</if>
<if test="cellTemplateId != null">
#{cellTemplateId,jdbcType=VARCHAR},
#{cellTemplateId,jdbcType=BIGINT},
</if>
<if test="data != null">
#{data,jdbcType=VARCHAR},
......@@ -236,10 +236,10 @@
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.reportId != null">
report_id = #{record.reportId,jdbcType=VARCHAR},
report_id = #{record.reportId,jdbcType=BIGINT},
</if>
<if test="record.cellTemplateId != null">
cell_template_id = #{record.cellTemplateId,jdbcType=VARCHAR},
cell_template_id = #{record.cellTemplateId,jdbcType=BIGINT},
</if>
<if test="record.data != null">
"data" = #{record.data,jdbcType=VARCHAR},
......@@ -271,8 +271,8 @@
-->
update cell_data
set id = #{record.id,jdbcType=BIGINT},
report_id = #{record.reportId,jdbcType=VARCHAR},
cell_template_id = #{record.cellTemplateId,jdbcType=VARCHAR},
report_id = #{record.reportId,jdbcType=BIGINT},
cell_template_id = #{record.cellTemplateId,jdbcType=BIGINT},
"data" = #{record.data,jdbcType=VARCHAR},
formula_exp = #{record.formulaExp,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR},
......@@ -291,10 +291,10 @@
update cell_data
<set>
<if test="reportId != null">
report_id = #{reportId,jdbcType=VARCHAR},
report_id = #{reportId,jdbcType=BIGINT},
</if>
<if test="cellTemplateId != null">
cell_template_id = #{cellTemplateId,jdbcType=VARCHAR},
cell_template_id = #{cellTemplateId,jdbcType=BIGINT},
</if>
<if test="data != null">
"data" = #{data,jdbcType=VARCHAR},
......@@ -323,8 +323,8 @@
This element is automatically generated by MyBatis Generator, do not modify.
-->
update cell_data
set report_id = #{reportId,jdbcType=VARCHAR},
cell_template_id = #{cellTemplateId,jdbcType=VARCHAR},
set report_id = #{reportId,jdbcType=BIGINT},
cell_template_id = #{cellTemplateId,jdbcType=BIGINT},
"data" = #{data,jdbcType=VARCHAR},
formula_exp = #{formulaExp,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
......
package pwc.taxtech.atms.common;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.FreeRefFunction;
import org.apache.poi.ss.formula.udf.AggregatingUDFFinder;
import org.apache.poi.ss.formula.udf.DefaultUDFFinder;
import org.apache.poi.ss.formula.udf.UDFFinder;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellReference;
import java.io.*;
......
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