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

add get template method

parent 009c7b6b
package pwc.taxtech.atms.constant.enums;
public enum EnumServiceType {
/// <summary>
/// 后台admin
/// </summary>
Administration(1),
/// <summary>
/// 增值税申报分析
/// </summary>
VAT(2),
/// <summary>
/// 电子税务管理
/// </summary>
AM (3),
/// <summary>
/// 财务尽职调查
/// </summary>
FDD (4),
/// <summary>
/// 税务管理平台
/// </summary>
Dashboard (5),
/// <summary>
/// 企业所得税
/// </summary>
CIT(6),
/// <summary>
/// 电子税务审计
/// </summary>
TCS(7);
private Integer code;
EnumServiceType(Integer code) {
this.code = code;
}
public Integer getCode() {
return code;
}
}
......@@ -52,7 +52,7 @@ public class InputInvoiceImportController {
private int getDownloadFilePath(InputInvoicePreviewQueryParam paras, OutputStream outputStream) {
List<InputVATInvoiceDto> list = inputInvoiceDataImportService.getInputInvoiceTreeViewData(paras).getList();
if (list.size() == 0) {
//return 0;
return 0;
}
Map<String, String> header = new HashMap<>();
header.put("PeriodID", "期间");
......
package pwc.taxtech.atms.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import pwc.taxtech.atms.constant.enums.EnumServiceType;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vatdto.ReportDto;
import pwc.taxtech.atms.vat.service.ReportService;
import java.util.List;
@RestController
@RequestMapping(value = "api/v1/Report")
public class ReportController {
@Autowired
ReportService reportService;
@RequestMapping(value = "template/{organizationID}/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<List<ReportDto>> getTemplate(@PathVariable String organizationID, @PathVariable Integer period) {
return reportService.getReportTemplate(organizationID, EnumServiceType.VAT, period);
}
}
......@@ -9,6 +9,7 @@ import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyMapper;
import pwc.taxtech.atms.dto.TemplateAndGroupDbDto;
import pwc.taxtech.atms.dto.TemplateUniqDto;
import pwc.taxtech.atms.dto.vatdto.ReportDto;
import pwc.taxtech.atms.entitiy.Template;
import pwc.taxtech.atms.entitiy.TemplateExample;
......@@ -123,4 +124,6 @@ public interface TemplateMapper extends MyMapper {
TemplateAndGroupDbDto getTemplateAndGroupByID(@Param("ID") String ID);
long getCountOfTemplateAndGroupByTemplateName(Map<String,Object> map);
List<ReportDto> getTemplateLeftJoinReport(Map<String, Object> map);
}
\ No newline at end of file
package pwc.taxtech.atms.dto.vatdto;
import java.util.Date;
public class ReportDto {
private String ID ;
private String templateID ;
private String templateCode ;
private String templateName ;
private int period ;
private String creator ;
private Date createTime ;
private String updater ;
private Date updateTime ;
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID = ID;
}
public String getTemplateID() {
return templateID;
}
public void setTemplateID(String templateID) {
this.templateID = templateID;
}
public String getTemplateCode() {
return templateCode;
}
public void setTemplateCode(String templateCode) {
this.templateCode = templateCode;
}
public String getTemplateName() {
return templateName;
}
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
public int getPeriod() {
return period;
}
public void setPeriod(int period) {
this.period = period;
}
public String getCreator() {
return creator;
}
public void setCreator(String creator) {
this.creator = creator;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getUpdater() {
return updater;
}
public void setUpdater(String updater) {
this.updater = updater;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
package pwc.taxtech.atms.vat.service;
import pwc.taxtech.atms.constant.enums.EnumServiceType;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vatdto.ReportDto;
import java.util.List;
public interface ReportService {
OperationResultDto<List<ReportDto>> getReportTemplate(String projectID, EnumServiceType serviceType, Integer period);
}
package pwc.taxtech.atms.vat.service.impl;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.datasource.ShardingContextHolder;
import pwc.taxtech.atms.constant.enums.EnumServiceType;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vatdto.ReportDto;
import pwc.taxtech.atms.entitiy.*;
import pwc.taxtech.atms.vat.service.ReportService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@Service
public class ReportServiceImpl extends VatAbstractService implements ReportService {
@Override
public OperationResultDto<List<ReportDto>> getReportTemplate(String projectID, EnumServiceType serviceType, Integer periodParam) {
int period = periodParam != null ? periodParam : 0;
OperationResultDto<List<ReportDto>> operationResult = new OperationResultDto<>();
Project project = projectMapper.selectByPrimaryKey(projectID);
String organizationID = project == null ? null : project.getOrganizationID();
if (organizationID == null) {
operationResult.setResult(false);
operationResult.setResultMsg("NoOrganization");
return operationResult;
}
String templateGroupID;
/*
对于VAT,从Rule Engine中获取TemplateGroupID
对于其他Service Type,直接从ProjectServiceType中获取
*/
if (serviceType.equals(EnumServiceType.VAT)) {
TaxPayerReportRuleExample example = new TaxPayerReportRuleExample();
example.createCriteria().andOrganizationIDLike(organizationID);
List<TaxPayerReportRule> taxPayerReportRules = taxPayerReportRuleMapper.selectByExample(example);
Optional<TaxPayerReportRule> taxPayerReportRule = taxPayerReportRules.stream().findFirst();
if (!taxPayerReportRule.isPresent()) {
Optional<TaxPayerReportRule> defaultRule = taxPayerReportRules.stream().filter(x -> x.getIsDefault()).findFirst();
if (!defaultRule.isPresent()) {
operationResult.setResultMsg("NoDefaultRule");
return operationResult;
}
templateGroupID = defaultRule.get().getTemplateGroupID();
} else {
templateGroupID = taxPayerReportRule.get().getTemplateGroupID();
}
} else {
String serviceTypeStr = serviceType.getCode().toString();
ProjectServiceTypeExample projectServiceTypeExample = new ProjectServiceTypeExample();
projectServiceTypeExample.createCriteria().andServiceTypeIDEqualTo(serviceTypeStr).andProjectIDEqualTo(projectID);
templateGroupID = projectServiceTypeMapper.selectByExample(projectServiceTypeExample).stream().map(ProjectServiceType::getTemplateGroupID).findFirst().get();
}
String dbName = ShardingContextHolder.getDataSourceKey();
Map<String, Object> map = new HashMap<>();
map.put("dbName", dbName);
map.put("period", period);
map.put("projectID", projectID);
map.put("templateGroupID", templateGroupID);
List<ReportDto> reportDtos = templateMapper.getTemplateLeftJoinReport(map);
if (reportDtos.isEmpty()) {
operationResult.setResultMsg("No Template");
return operationResult;
}
operationResult.setResult(true);
operationResult.setData(reportDtos);
return operationResult;
}
}
\ No newline at end of file
......@@ -3,6 +3,10 @@ package pwc.taxtech.atms.vat.service.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import pwc.taxtech.atms.dao.ProjectMapper;
import pwc.taxtech.atms.dao.ProjectServiceTypeMapper;
import pwc.taxtech.atms.dao.TaxPayerReportRuleMapper;
import pwc.taxtech.atms.dao.TemplateMapper;
import pwc.taxtech.atms.vat.dao.*;
public class VatAbstractService {
......@@ -24,4 +28,12 @@ public class VatAbstractService {
OutputVATInvoiceItemMapper outputVATInvoiceItemMapper;
@Autowired
InputVATInvoiceItemMapper inputVATInvoiceItemMapper;
@Autowired
ProjectMapper projectMapper;
@Autowired
TaxPayerReportRuleMapper taxPayerReportRuleMapper;
@Autowired
ProjectServiceTypeMapper projectServiceTypeMapper;
@Autowired
TemplateMapper templateMapper;
}
......@@ -461,4 +461,33 @@
</if>
</where>
</select>
<resultMap id="reportDto" type="pwc.taxtech.atms.dto.vatdto.ReportDto">
<id column="ID" jdbcType="VARCHAR" property="ID"/>
<result column="period" jdbcType="INTEGER" property="period"/>
<result column="templateID" jdbcType="VARCHAR" property="templateID"/>
<result column="templateName" jdbcType="VARCHAR" property="templateName"/>
<result column="templateCode" jdbcType="VARCHAR" property="templateCode"/>
</resultMap>
<select id="getTemplateLeftJoinReport" parameterType="map" resultMap="reportDto">
SELECT
d.ID AS ID,
d.Period AS period,
c.ID AS templateID,
c.Name AS templateName,
c.Code AS templateCode
FROM (SELECT
a.ID,
a.Name,
a.Code
FROM tax_admin.Template a
WHERE a.TemplateGroupID = #{templateGroupID,jdbcType=VARCHAR}
AND a.IsActiveAssociation = 1
ORDER BY a.OrderIndex) c
LEFT JOIN (SELECT b.ID,b.Period,b.TemplateID
FROM ${dbName}.Report b
WHERE b.Period = #{period,jdbcType=INTEGER}
AND b.ProjectID = #{ProjectID,jdbcType=VARCHAR}) d
ON c.ID = d.TemplateID
</select>
</mapper>
\ 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