Commit bc398078 authored by neo's avatar neo

[dev] add project for period report logic

parent d4ce6f59
......@@ -19,7 +19,7 @@ public class SpringContextUtil implements ApplicationContextAware {
private static ApplicationContext webApplicationContext;
public static FormulaAdminMapper formulaAdminMapper;
public static ReportMapper reportMapper;
public static PeriodReportMapper reportMapper;
public static CellDataMapper cellDataMapper;
public static DistributedIdService distributedIdService;
public static PeriodFormulaBlockMapper formulaBlockMapper;
......@@ -59,7 +59,7 @@ public class SpringContextUtil implements ApplicationContextAware {
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
webApplicationContext = applicationContext;
formulaAdminMapper = webApplicationContext.getBean(FormulaAdminMapper.class);
reportMapper = webApplicationContext.getBean(ReportMapper.class);
reportMapper = webApplicationContext.getBean(PeriodReportMapper.class);
cellDataMapper = webApplicationContext.getBean(CellDataMapper.class);
distributedIdService = webApplicationContext.getBean(DistributedIdService.class);
formulaBlockMapper = webApplicationContext.getBean(PeriodFormulaBlockMapper.class);
......
......@@ -64,14 +64,14 @@ public class ReportController {
}
@RequestMapping(value = "report/{templateId}/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<ReportDto> getReportByTemplate(@PathVariable Long templateId, @PathVariable Integer period) {
public OperationResultDto<ReportDto> getReportByTemplate(@PathVariable Long templateId, @PathVariable Integer period, @RequestHeader String from) {
OperationResultDto resultDto = new OperationResultDto();
if (templateId == null || templateId == 0L || period == null || period == 0) {
resultDto.setResult(false);
resultDto.setResultMsg("templateId or period is invalid");
return resultDto;
}
return reportService.getReportByTemplate(templateId, period);
return reportService.getReportByTemplate(templateId, period, from);
}
@RequestMapping(value = "getCellTemplateConfig/{reportTemplateId}/{period}/{rowIndex}/{columnIndex}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
......@@ -90,8 +90,8 @@ public class ReportController {
}
@RequestMapping(value = "addCellManualData", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto addCellManualDataSource(@RequestBody ManualDataSourceDto data) {
return reportService.addCellManualDataSource(data);
public OperationResultDto addCellManualDataSource(@RequestBody ManualDataSourceDto data, @RequestHeader String from) {
return reportService.addCellManualDataSource(data, from);
}
@RequestMapping(value = "addDataSource", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
......
......@@ -26,7 +26,7 @@ public interface ReportService {
OperationResultDto<ReportDataDto> getCellData(Long reportId, String porjectId);
OperationResultDto<ReportDto> getReportByTemplate(Long templateId, Integer period);
OperationResultDto<ReportDto> getReportByTemplate(Long templateId, Integer period, String projectId);
OperationResultDto<PeriodCellTemplateConfig> getCellTemplateConfig(Long reportTemplateId, Integer periodParam, int rowIndex, int columnIndex);
......@@ -40,7 +40,7 @@ public interface ReportService {
* @param data 数据源数据
* @return 添加结果
*/
OperationResultDto addCellManualDataSource(ManualDataSourceDto data);
OperationResultDto addCellManualDataSource(ManualDataSourceDto data, String projectId);
OperationResultDto<String> addDataSource(DataSourceDto datasource);
......
......@@ -11,11 +11,11 @@ import pwc.taxtech.atms.entity.ProjectServiceType;
import pwc.taxtech.atms.entity.ProjectServiceTypeExample;
import pwc.taxtech.atms.exception.Exceptions;
import pwc.taxtech.atms.vat.dao.CellDataMapper;
import pwc.taxtech.atms.vat.dao.ReportMapper;
import pwc.taxtech.atms.vat.dao.PeriodReportMapper;
import pwc.taxtech.atms.vat.entity.CellData;
import pwc.taxtech.atms.vat.entity.CellDataExample;
import pwc.taxtech.atms.vat.entity.Report;
import pwc.taxtech.atms.vat.entity.ReportExample;
import pwc.taxtech.atms.vat.entity.PeriodReport;
import pwc.taxtech.atms.vat.entity.PeriodReportExample;
import java.util.List;
......@@ -26,7 +26,7 @@ public class FormulaAgent extends VatAbstractService {
@Autowired
public FormulaAdminMapper adminMp;
@Autowired
public ReportMapper reportMapper;
public PeriodReportMapper periodReportMapper;
@Autowired
public CellDataMapper cellDataMapper;
......@@ -50,11 +50,11 @@ public class FormulaAgent extends VatAbstractService {
return cellTemplates;
}
private Report getReportByTemplate(String templateId, Integer periodId) {
ReportExample example = new ReportExample();
example.createCriteria().andTemplateIdEqualTo(Long.valueOf(templateId))
private PeriodReport getReportByTemplate(String templateId, Integer periodId, String projectId) {
PeriodReportExample example = new PeriodReportExample();
example.createCriteria().andProjectIdEqualTo(projectId).andTemplateIdEqualTo(Long.valueOf(templateId))
.andPeriodEqualTo(periodId);
List<Report> reports = reportMapper.selectByExample(example);
List<PeriodReport> reports = periodReportMapper.selectByExample(example);
if (reports != null && !reports.isEmpty()) return reports.get(FIRST_OR_DEFAULT);
return null;
......@@ -73,8 +73,8 @@ public class FormulaAgent extends VatAbstractService {
return adminMp.getPastProjectId(year, orgId);
}
public CellData getCellData(String templateId, String cellId, int periodId) {
Report report = getReportByTemplate(templateId, periodId);
public CellData getCellData(String templateId, String cellId, int periodId, String projectId) {
PeriodReport report = getReportByTemplate(templateId, periodId, projectId);
MyAsserts.assertNotNull(report, Exceptions.BB_REPORT_NULL);
CellData cellData = getCellDataListByTemplate(cellId, report.getId());
......
......@@ -49,6 +49,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static pwc.taxtech.atms.common.util.SpringContextUtil.reportMapper;
import static pwc.taxtech.atms.constant.Constant.EMPTY;
@Component
......@@ -196,7 +197,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
if (templateId > 0) {
//todo: create report into DB
Report report = new Report();
PeriodReport report = new PeriodReport();
Long reportId = distributedIdService.nextId();
report.setId(reportId);
report.setTemplateId(templateId);
......@@ -206,6 +207,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
report.setCreateTime(createTime);
report.setUpdateBy("Admin");
report.setUpdateTime(createTime);
report.setProjectId(projectId);
reportMapper.insertSelective(report);
List<PeriodCellTemplateConfig> periodCellTemplateConfigs = periodCellTemplateConfigList.stream()
......
......@@ -403,7 +403,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
OperationResultDto resultDto = new OperationResultDto();
ReportDataDto dataDto = new ReportDataDto();
try {
Report report = reportMapper.selectByPrimaryKey(reportId);
PeriodReport report = periodReportMapper.selectByPrimaryKey(reportId);
if (report == null) {
resultDto.setResult(false);
resultDto.setResultMsg("NoReport");
......@@ -608,12 +608,12 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
}
@Override
public OperationResultDto<ReportDto> getReportByTemplate(Long templateId, Integer period) {
public OperationResultDto<ReportDto> getReportByTemplate(Long templateId, Integer period, String projectId) {
OperationResultDto resultDto = new OperationResultDto();
try {
ReportExample example = new ReportExample();
example.createCriteria().andTemplateIdEqualTo(templateId).andPeriodEqualTo(period);
Optional<Report> report = reportMapper.selectByExample(example).stream().findFirst();
PeriodReportExample example = new PeriodReportExample();
example.createCriteria().andProjectIdEqualTo(projectId).andTemplateIdEqualTo(templateId).andPeriodEqualTo(period);
Optional<PeriodReport> report = periodReportMapper.selectByExample(example).stream().findFirst();
if (report.isPresent()) {
resultDto.setResult(true);
ReportDto reportDto = new ReportDto();
......@@ -721,7 +721,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
}
@Override
public OperationResultDto addCellManualDataSource(ManualDataSourceDto data) {
public OperationResultDto addCellManualDataSource(ManualDataSourceDto data, String projectId) {
OperationResultDto operationResultDto = new OperationResultDto();
try {
......@@ -810,9 +810,9 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
templateId = periodCellTemplate.get().getReportTemplateId();
}
//3. use the template id get the reportid, use the reportid get the celltemplateids, then use the celltemplateids and cell name get the datasource which should be updated.
ReportExample reportExample = new ReportExample();
reportExample.createCriteria().andTemplateIdEqualTo(templateId).andPeriodEqualTo(data.getPeriod());
Optional<Report> report = reportMapper.selectByExample(reportExample).stream().findFirst();
PeriodReportExample reportExample = new PeriodReportExample();
reportExample.createCriteria().andProjectIdEqualTo(projectId).andTemplateIdEqualTo(templateId).andPeriodEqualTo(data.getPeriod());
Optional<PeriodReport> report = periodReportMapper.selectByExample(reportExample).stream().findFirst();
if (report.isPresent()) {
Long reportId = report.get().getId();
CellDataExample cellDataExample = new CellDataExample();
......
......@@ -72,7 +72,7 @@ public class VatAbstractService {
@Autowired
public PeriodFormulaBlockMapper periodFormulaBlockMapper;
@Autowired
public ReportMapper reportMapper;
public PeriodReportMapper periodReportMapper;
@Autowired
public CellDataMapper cellDataMapper;
@Autowired
......
......@@ -114,7 +114,7 @@ public class BB extends FunctionBase implements FreeRefFunction {
MyAsserts.assertNotEmpty(projectId, Exceptions.PROJECT_EMPTY);
cellData = agent.getCellData(cellTemplateData.getReportTemplateId(),
cellTemplateData.getCellTemplateId(), curPeriod.getCurPeriod());
cellTemplateData.getCellTemplateId(), curPeriod.getCurPeriod(), formulaContext.getProjectId());
nullCellDto.extractFromGroup(bo, curPeriod, cellData, cellTemplateData);
// todo: fix datasource name by templateList(neo)
......
......@@ -7,7 +7,7 @@ import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.FreeRefFunction;
import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.vat.entity.Report;
import pwc.taxtech.atms.vat.entity.PeriodReport;
import java.util.Calendar;
import java.util.Date;
......@@ -56,7 +56,7 @@ public class ProjectContext extends FunctionBase implements FreeRefFunction {
, formulaContext.getPeriod(), calendar.get(Calendar.DAY_OF_MONTH), formulaContext.getYear()
, formulaContext.getPeriod(), calendar2.get(Calendar.DAY_OF_MONTH)));
case "FillForm":
Report report = SpringContextUtil.reportMapper.selectByPrimaryKey(formulaContext.getReportId());
PeriodReport report = SpringContextUtil.reportMapper.selectByPrimaryKey(formulaContext.getReportId());
if (report != null) {
return new StringEval(String.format(Constant.ReportBuildInStringFormat.FillForm, report.getUpdateTime().getYear()
, report.getUpdateTime().getMonth(), report.getUpdateTime().getDay()));
......
package pwc.taxtech.atms.vat.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.vat.entity.Report;
import pwc.taxtech.atms.vat.entity.ReportExample;
@Mapper
public interface ReportMapper extends MyVatMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table TAX_PROJECT.REPORT
*
* @mbg.generated
*/
long countByExample(ReportExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table TAX_PROJECT.REPORT
*
* @mbg.generated
*/
int deleteByExample(ReportExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table TAX_PROJECT.REPORT
*
* @mbg.generated
*/
int deleteByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table TAX_PROJECT.REPORT
*
* @mbg.generated
*/
int insert(Report record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table TAX_PROJECT.REPORT
*
* @mbg.generated
*/
int insertSelective(Report record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table TAX_PROJECT.REPORT
*
* @mbg.generated
*/
List<Report> selectByExampleWithRowbounds(ReportExample example, RowBounds rowBounds);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table TAX_PROJECT.REPORT
*
* @mbg.generated
*/
List<Report> selectByExample(ReportExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table TAX_PROJECT.REPORT
*
* @mbg.generated
*/
Report selectByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table TAX_PROJECT.REPORT
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") Report record, @Param("example") ReportExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table TAX_PROJECT.REPORT
*
* @mbg.generated
*/
int updateByExample(@Param("record") Report record, @Param("example") ReportExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table TAX_PROJECT.REPORT
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(Report record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table TAX_PROJECT.REPORT
*
* @mbg.generated
*/
int updateByPrimaryKey(Report record);
}
\ No newline at end of file
package pwc.taxtech.atms.vat.entity;
import java.io.Serializable;
import java.util.Date;
/**
*
* This class was generated by MyBatis Generator.
* This class corresponds to the database table TAX_PROJECT.REPORT
*
* @mbg.generated do_not_delete_during_merge
*/
public class Report implements Serializable {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column TAX_PROJECT.REPORT.ID
*
* @mbg.generated
*/
private Long id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column TAX_PROJECT.REPORT.TEMPLATE_ID
*
* @mbg.generated
*/
private Long templateId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column TAX_PROJECT.REPORT.PERIOD
*
* @mbg.generated
*/
private Integer period;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column TAX_PROJECT.REPORT.PROJECT_ID
*
* @mbg.generated
*/
private String projectId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column TAX_PROJECT.REPORT.CREATE_BY
*
* @mbg.generated
*/
private String createBy;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column TAX_PROJECT.REPORT.CREATE_TIME
*
* @mbg.generated
*/
private Date createTime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column TAX_PROJECT.REPORT.UPDATE_BY
*
* @mbg.generated
*/
private String updateBy;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column TAX_PROJECT.REPORT.UPDATE_TIME
*
* @mbg.generated
*/
private Date updateTime;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table TAX_PROJECT.REPORT
*
* @mbg.generated
*/
private static final long serialVersionUID = 1L;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column TAX_PROJECT.REPORT.ID
*
* @return the value of TAX_PROJECT.REPORT.ID
*
* @mbg.generated
*/
public Long getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column TAX_PROJECT.REPORT.ID
*
* @param id the value for TAX_PROJECT.REPORT.ID
*
* @mbg.generated
*/
public void setId(Long id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column TAX_PROJECT.REPORT.TEMPLATE_ID
*
* @return the value of TAX_PROJECT.REPORT.TEMPLATE_ID
*
* @mbg.generated
*/
public Long getTemplateId() {
return templateId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column TAX_PROJECT.REPORT.TEMPLATE_ID
*
* @param templateId the value for TAX_PROJECT.REPORT.TEMPLATE_ID
*
* @mbg.generated
*/
public void setTemplateId(Long templateId) {
this.templateId = templateId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column TAX_PROJECT.REPORT.PERIOD
*
* @return the value of TAX_PROJECT.REPORT.PERIOD
*
* @mbg.generated
*/
public Integer getPeriod() {
return period;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column TAX_PROJECT.REPORT.PERIOD
*
* @param period the value for TAX_PROJECT.REPORT.PERIOD
*
* @mbg.generated
*/
public void setPeriod(Integer period) {
this.period = period;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column TAX_PROJECT.REPORT.PROJECT_ID
*
* @return the value of TAX_PROJECT.REPORT.PROJECT_ID
*
* @mbg.generated
*/
public String getProjectId() {
return projectId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column TAX_PROJECT.REPORT.PROJECT_ID
*
* @param projectId the value for TAX_PROJECT.REPORT.PROJECT_ID
*
* @mbg.generated
*/
public void setProjectId(String projectId) {
this.projectId = projectId == null ? null : projectId.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column TAX_PROJECT.REPORT.CREATE_BY
*
* @return the value of TAX_PROJECT.REPORT.CREATE_BY
*
* @mbg.generated
*/
public String getCreateBy() {
return createBy;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column TAX_PROJECT.REPORT.CREATE_BY
*
* @param createBy the value for TAX_PROJECT.REPORT.CREATE_BY
*
* @mbg.generated
*/
public void setCreateBy(String createBy) {
this.createBy = createBy == null ? null : createBy.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column TAX_PROJECT.REPORT.CREATE_TIME
*
* @return the value of TAX_PROJECT.REPORT.CREATE_TIME
*
* @mbg.generated
*/
public Date getCreateTime() {
return createTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column TAX_PROJECT.REPORT.CREATE_TIME
*
* @param createTime the value for TAX_PROJECT.REPORT.CREATE_TIME
*
* @mbg.generated
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column TAX_PROJECT.REPORT.UPDATE_BY
*
* @return the value of TAX_PROJECT.REPORT.UPDATE_BY
*
* @mbg.generated
*/
public String getUpdateBy() {
return updateBy;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column TAX_PROJECT.REPORT.UPDATE_BY
*
* @param updateBy the value for TAX_PROJECT.REPORT.UPDATE_BY
*
* @mbg.generated
*/
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy == null ? null : updateBy.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column TAX_PROJECT.REPORT.UPDATE_TIME
*
* @return the value of TAX_PROJECT.REPORT.UPDATE_TIME
*
* @mbg.generated
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column TAX_PROJECT.REPORT.UPDATE_TIME
*
* @param updateTime the value for TAX_PROJECT.REPORT.UPDATE_TIME
*
* @mbg.generated
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table TAX_PROJECT.REPORT
*
* @mbg.generated
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", templateId=").append(templateId);
sb.append(", period=").append(period);
sb.append(", projectId=").append(projectId);
sb.append(", createBy=").append(createBy);
sb.append(", createTime=").append(createTime);
sb.append(", updateBy=").append(updateBy);
sb.append(", updateTime=").append(updateTime);
sb.append("]");
return sb.toString();
}
}
\ No newline at end of file
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