Commit a50bec33 authored by neo's avatar neo

[DEV] query cell template per group dto

parent ce226612
......@@ -4,6 +4,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import pwc.taxtech.atms.MyMapper;
import pwc.taxtech.atms.dto.GroupId;
import pwc.taxtech.atms.dto.vatdto.CellTemplatePerGroupDto;
import java.util.List;
......@@ -33,5 +34,16 @@ public interface FormulaAdminMapper extends MyMapper {
" AND template.template_group_id = #{groupId}")
List<CellTemplatePerGroupDto> getCellTemplatePerGroupDto(@Param("groupId") String groupId);
@Select("SELECT " +
" rule.template_group_id as groupId, rule.is_default as isDefault " +
"FROM " +
" Project p, " +
" tax_payer_report_rule rule " +
"WHERE " +
" (p.OrganizationID = rule.organization_id " +
" OR rule.is_default = 1) " +
" AND p.ID = #{projectId}")
List<GroupId> getTemplateGroupId(@Param("projectId") String projectId);
}
package pwc.taxtech.atms.dto;
public class GroupId {
public String groupId;
public Integer isDefault;
}
......@@ -8,12 +8,14 @@ import org.apache.poi.ss.formula.functions.FreeRefFunction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pwc.taxtech.atms.constant.enums.EnumServiceType;
import pwc.taxtech.atms.dto.GroupId;
import pwc.taxtech.atms.dto.vatdto.CellTemplatePerGroupDto;
import pwc.taxtech.atms.entitiy.ProjectServiceType;
import pwc.taxtech.atms.entitiy.ProjectServiceTypeExample;
import pwc.taxtech.atms.vat.service.impl.report.functions.FormulaAgent;
import pwc.taxtech.atms.vat.service.impl.report.functions.FormulaContext;
import java.util.Comparator;
import java.util.List;
public class ReportFormulaFactory {
......@@ -25,7 +27,7 @@ public class ReportFormulaFactory {
protected ReportBaseFormula(FormulaContext context) {
this.context = context;
this.agent=context.getFormulaAgent();
this.agent = context.getFormulaAgent();
}
static String resolverString(ValueEval[] args, OperationEvaluationContext ec, int index)
......@@ -129,9 +131,21 @@ public class ReportFormulaFactory {
ProjectServiceTypeExample pst = new ProjectServiceTypeExample();
pst.createCriteria().andTemplateGroupIDEqualTo(Long.valueOf(context.getReportTemplateGroupID()))
.andServiceTypeIDEqualTo(EnumServiceType.VAT.getCode()+"");
List<ProjectServiceType> pstReult=agent.projectServiceTypeMapper.selectByExample(pst);
List<CellTemplatePerGroupDto> cellTemplates=agent.adminMp.getCellTemplatePerGroupDto(context.getReportTemplateGroupID());
.andServiceTypeIDEqualTo(EnumServiceType.VAT.getCode() + "");
List<ProjectServiceType> pstReult = agent.projectServiceTypeMapper.selectByExample(pst);
List<CellTemplatePerGroupDto> cellTemplates = agent.adminMp.getCellTemplatePerGroupDto(context.getReportTemplateGroupID());
if (pstReult == null || pstReult.isEmpty()) {
List<GroupId> groupIds = agent.adminMp.getTemplateGroupId(context.getProjectID());
GroupId groupId;
if (groupIds.size() > 0) {
groupId = groupIds.stream().filter(m -> m.isDefault != 1).findFirst().get();
if (groupId == null) groupId = groupIds.get(0);
cellTemplates.addAll(agent.adminMp.getCellTemplatePerGroupDto(groupId.groupId));
}
}
} catch (EvaluationException e) {
......
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